// import '@webcomponents/scoped-custom-element-registry' // later only for @open-wc/scoped-elements@3 import 'broadcastchannel-polyfill' import '@operato/shell/app.js' import { watchForUpdate, type UpdateWatch } from './serviceworker/update' /* Export ENV */ export const PROCESS = { 'APP-VERSION': process.env['APP-VERSION'], 'NODE-ENV': process.env['NODE-ENV'] } /* Service Worker: production only */ let updates: Promise = Promise.resolve(undefined) if (process.env['NODE-ENV'] === 'production') { if ('serviceWorker' in navigator) { updates = navigator.serviceWorker .register('/service-worker.js', { scope: '/' }) .then(registration => watchForUpdate(navigator.serviceWorker, registration)) .catch(error => { console.warn('service worker not registered', error) return undefined }) } } else { /* Development: unregister stale service workers so code changes reflect immediately */ if ('serviceWorker' in navigator) { navigator.serviceWorker.getRegistrations().then(registrations => { registrations.forEach(r => r.unregister()) }) } } /* Export APIs */ /** Calls the listener when a new version of the app waits for this screen. */ export function onUpdateWaiting(listener: () => void) { updates.then(watch => watch?.onWaiting(listener)) } /** Moves this screen to the waiting version and reloads it. */ export function applyUpdate() { updates.then(watch => (watch ? watch.apply() : window.location.reload())) } /* the one rule the screen and the service worker keep a notice by */ export { storeOnce, sameNotice } from './serviceworker/store-once' // store, actions, page-view, export * from '@operato/shell' // graphql-client export * from '@operato/graphql'