@crystaltech/hsms-shared-ui 0.7.22 → 0.7.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/ui/AppUpdateBanner.d.ts +7 -0
- package/dist/components/ui/NetworkStatusIndicator.d.ts +14 -0
- package/dist/hooks/useAppUpdate.d.ts +8 -0
- package/dist/hooks/useNetworkStatus.d.ts +20 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.es.js +6640 -6426
- package/dist/index.js +78 -78
- package/dist/pwa/appUpdate.d.ts +57 -0
- package/dist/sw.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Getting a deployed version onto screens that stay open all day.
|
|
3
|
+
*
|
|
4
|
+
* A service worker is only checked for a new version when the browser navigates, and a
|
|
5
|
+
* single-page app never does: a doctor who opened the module in the morning kept running the
|
|
6
|
+
* morning's build until somebody hard-reloaded. And when a new worker did take over by itself
|
|
7
|
+
* (`skipWaiting`), it deleted the old build's files from under the open tab, so the next screen
|
|
8
|
+
* the tab lazy-loaded failed.
|
|
9
|
+
*
|
|
10
|
+
* So here:
|
|
11
|
+
* - the worker is asked for an update every {@link UPDATE_CHECK_INTERVAL_MS}, whenever the tab
|
|
12
|
+
* comes back into view, and when the network returns;
|
|
13
|
+
* - a new version waits (the app builds with `registerType: "prompt"`), and the user is told it
|
|
14
|
+
* is there - it is never swapped in under someone writing a prescription;
|
|
15
|
+
* - "Reload" activates it and reloads once;
|
|
16
|
+
* - a screen that fails to load because its file belongs to a build that is gone reloads by
|
|
17
|
+
* itself, unless the app says there is unsaved work - then the user is asked first.
|
|
18
|
+
*
|
|
19
|
+
* Framework-free; React reads it through useAppUpdate.
|
|
20
|
+
*/
|
|
21
|
+
/** How often an open tab asks whether a new version has been deployed. */
|
|
22
|
+
export declare const UPDATE_CHECK_INTERVAL_MS: number;
|
|
23
|
+
export type AppUpdateReason =
|
|
24
|
+
/** A new version is installed and waiting. */
|
|
25
|
+
"update-ready"
|
|
26
|
+
/** A part of the app failed to load: the build it belongs to is no longer on the server. */
|
|
27
|
+
| "load-failed";
|
|
28
|
+
export interface AppUpdateState {
|
|
29
|
+
/** Something newer than what is running is waiting to be loaded. */
|
|
30
|
+
available: boolean;
|
|
31
|
+
reason: AppUpdateReason | null;
|
|
32
|
+
}
|
|
33
|
+
type Listener = (state: AppUpdateState) => void;
|
|
34
|
+
export declare const getAppUpdateState: () => AppUpdateState;
|
|
35
|
+
export declare const subscribeAppUpdate: (listener: Listener) => (() => void);
|
|
36
|
+
/**
|
|
37
|
+
* Lets the app say when reloading would lose something - a prescription being written. Then a
|
|
38
|
+
* failed load asks before reloading instead of reloading at once. Returns the function that
|
|
39
|
+
* removes the check.
|
|
40
|
+
*/
|
|
41
|
+
export declare const registerUnsavedWorkCheck: (check: () => boolean) => (() => void);
|
|
42
|
+
/** Asks the server whether a new version has been deployed. Safe to call at any time. */
|
|
43
|
+
export declare const checkForAppUpdate: () => Promise<void>;
|
|
44
|
+
/** Loads the new version: the waiting worker takes over, then the page reloads once. */
|
|
45
|
+
export declare const applyAppUpdate: () => void;
|
|
46
|
+
/**
|
|
47
|
+
* For an app's error boundary: whether the error is a part of the app that failed to load because
|
|
48
|
+
* its build is gone - and if so, handled as such (reload, or the user asked first). An error
|
|
49
|
+
* boundary catches what a lazily loaded screen throws before any window listener sees it.
|
|
50
|
+
*/
|
|
51
|
+
export declare const handleStaleBuildError: (error: unknown) => boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Starts watching for new versions. Called once per page - again is a no-op - by the shared
|
|
54
|
+
* layout, so every module gets it.
|
|
55
|
+
*/
|
|
56
|
+
export declare const startAppUpdateWatcher: (intervalMs?: number) => void;
|
|
57
|
+
export {};
|
package/dist/sw.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
if(!self.define){let e,s={};const i=(i,r)=>(i=new URL(i+".js",r).href,s[i]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()}).then(()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e}));self.define=(r,n)=>{const o=e||("document"in self?document.currentScript.src:"")||location.href;if(s[o])return;let
|
|
1
|
+
if(!self.define){let e,s={};const i=(i,r)=>(i=new URL(i+".js",r).href,s[i]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()}).then(()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e}));self.define=(r,n)=>{const o=e||("document"in self?document.currentScript.src:"")||location.href;if(s[o])return;let d={};const t=e=>i(e,o),f={module:{uri:o},exports:d,require:t};s[o]=Promise.all(r.map(e=>f[e]||t(e))).then(e=>(n(...e),d))}}define(["./workbox-3105ea8d"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"preMountSplash.js",revision:"46986fe18311b1852bd4ebf684726bab"},{url:"preMountSplash.es.js",revision:"f363010fb7eaab98ab53522f58febacb"},{url:"index.js",revision:"965e0209efd7000d76429aac1dfb6084"},{url:"index.es.js",revision:"cc07bc1b13df203d9992499e133cd52f"},{url:"hsms-shared-ui.css",revision:"7f5aef0a9303b4cde437120fbb05ea5b"},{url:"Loader-D1FpX_bV.js",revision:"c37d04f117789f8752c3fc903951c281"},{url:"manifest.webmanifest",revision:"e6d4972ea70a2ecb105e17f18dad67f9"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))});
|