MCPcopy Create free account
hub / github.com/FlowiseAI/Flowise / register

Function register

packages/ui/src/serviceWorker.js:89–120  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

87}
88
89export function register(config) {
90 if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
91 // The URL constructor is available in all browsers that support SW.
92 const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href)
93 if (publicUrl.origin !== window.location.origin) {
94 // Our service worker won't work if PUBLIC_URL is on a different origin
95 // from what our page is served on. This might happen if a CDN is used to
96 // serve assets; see https://github.com/facebook/create-react-app/issues/2374
97 return
98 }
99
100 window.addEventListener('load', () => {
101 const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`
102
103 if (isLocalhost) {
104 // This is running on localhost. Let's check if a service worker still exists or not.
105 checkValidServiceWorker(swUrl, config)
106
107 // Add some additional logging to localhost, pointing developers to the
108 // service worker/PWA documentation.
109 navigator.serviceWorker.ready.then(() => {
110 console.info(
111 'This web app is being served cache-first by a service worker. To learn more, visit https://bit.ly/CRA-PWA'
112 )
113 })
114 } else {
115 // Is not localhost. Just register service worker
116 registerValidSW(swUrl, config)
117 }
118 })
119 }
120}
121
122export function unregister() {
123 if ('serviceWorker' in navigator) {

Callers

nothing calls this directly

Calls 2

checkValidServiceWorkerFunction · 0.85
registerValidSWFunction · 0.85

Tested by

no test coverage detected