This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component } from "react"; | |
import { pageVisibilityApi } from "../pageVisibilityUtils"; | |
const { hidden, visibilityChange } = pageVisibilityApi(); | |
class VisibilityManager extends Component { | |
state = { | |
isVisible: true | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const pageVisibilityApi = () => { | |
let hidden, visibilityChange; | |
if (typeof document.hidden !== "undefined") { | |
// Opera 12.10 and Firefox 18 and later support | |
hidden = "hidden"; | |
visibilityChange = "visibilitychange"; | |
} else if (typeof document.msHidden !== "undefined") { | |
hidden = "msHidden"; | |
visibilityChange = "msvisibilitychange"; | |
} else if (typeof document.webkitHidden !== "undefined") { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from "react"; | |
class Video extends Component { | |
videoRef = React.createRef(); | |
// Safari won't allow playing the video without user interaction | |
componentDidUpdate() { | |
const video = this.videoRef.current; | |
if (this.props.active) video.play(); | |
else video.pause(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import ReactDOM from "react-dom"; | |
import VisiblityManager from "./components/VisibilityManager"; | |
import Video from "./components/Video"; | |
const App = () => ( | |
<VisiblityManager> | |
{isVisible => <Video active={isVisible} src="https://www.sample-videos.com/video/mp4/480/big_buck_bunny_480p_30mb.mp4" />} | |
</VisiblityManager> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpGet] | |
public HttpResponseMessage PushStreamContent() | |
{ | |
var response = Request.CreateResponse(); | |
response.Content = | |
new PushStreamContent((stream, content, context) => | |
{ | |
foreach (var staffMember in _staffMembers) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"rules": [ | |
{ | |
"test": {}, | |
"include": [ | |
"/path/to/project/next-pwa" | |
], | |
"exclude": {}, | |
"use": { | |
"loader": "next-babel-loader", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { join } = require('path'); | |
const express = require('express'); | |
const next = require('next'); | |
const cache = require('lru-cache'); // for using least-recently-used based caching | |
const PORT = 8000; | |
const dev = process.env.NODE_ENV !== 'production'; | |
const app = next({ dev }); | |
const handle = app.getRequestHandler(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const withCSS = require('@zeit/next-css'); | |
const NextWorkboxPlugin = require('next-workbox-webpack-plugin'); | |
const WebpackPwaManifest = require('webpack-pwa-manifest'); | |
const path = require('path'); | |
module.exports = withCSS({ | |
webpack(config, { isServer, buildId, dev }) { | |
// Fixes npm packages that depend on `fs` module | |
config.node = { | |
fs: 'empty', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const withCSS = require('@zeit/next-css'); | |
const NextWorkboxPlugin = require('next-workbox-webpack-plugin'); | |
const WebpackPwaManifest = require('webpack-pwa-manifest'); | |
const path = require('path'); | |
module.exports = withCSS({ | |
webpack(config, { isServer, buildId, dev }) { | |
const workboxOptions = { | |
clientsClaim: true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const withCSS = require('@zeit/next-css'); | |
const NextWorkboxPlugin = require('next-workbox-webpack-plugin'); | |
module.exports = withCSS({ | |
webpack(config, { isServer, buildId, dev }) { | |
const workboxOptions = { | |
clientsClaim: true, | |
skipWaiting: true, | |
globPatterns: ['.next/static/*', '.next/static/commons/*'], |