@illinois-grad/grad-vue 7.2.7 → 7.2.8
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/README.md +28 -0
- package/dist/components/GAppUpdateNotice.vue.d.ts +93 -0
- package/dist/compose/useAppUpdateCheck.d.ts +30 -0
- package/dist/{grad-vue-COt_mmY9.js → grad-vue-DSPqd1gb.js} +726 -644
- package/dist/grad-vue-DSPqd1gb.js.map +1 -0
- package/dist/grad-vue-elements.css +30 -30
- package/dist/grad-vue.css +1 -1
- package/dist/grad-vue.d.ts +4 -1
- package/dist/grad-vue.js +1 -1
- package/dist/plugin.d.ts +2 -1
- package/dist/plugin.js +4 -4
- package/dist/plugin.js.map +1 -1
- package/dist/vite.d.ts +22 -0
- package/dist/vite.js +38 -0
- package/dist/vite.js.map +1 -0
- package/package.json +13 -1
- package/dist/grad-vue-COt_mmY9.js.map +0 -1
package/README.md
CHANGED
|
@@ -76,6 +76,34 @@ import { GButton } from '@illinois-grad/grad-vue'
|
|
|
76
76
|
</template>
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
+
### Notify Users About New Deploys
|
|
80
|
+
|
|
81
|
+
`GAppUpdateNotice` asks users to refresh when a newer build is deployed while
|
|
82
|
+
their tab is open. Add the Vite plugin, which gives each build a unique ID and
|
|
83
|
+
emits `version.json`:
|
|
84
|
+
|
|
85
|
+
```javascript
|
|
86
|
+
// vite.config.ts
|
|
87
|
+
import { appBuildVersion } from '@illinois-grad/grad-vue/vite'
|
|
88
|
+
|
|
89
|
+
export default defineConfig({
|
|
90
|
+
plugins: [vue(), appBuildVersion()],
|
|
91
|
+
})
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Render `<GAppUpdateNotice />` once in the app's root component, and serve
|
|
95
|
+
`version.json` without caching, e.g. in nginx:
|
|
96
|
+
|
|
97
|
+
```nginx
|
|
98
|
+
location = /version.json {
|
|
99
|
+
add_header Cache-Control "no-store" always;
|
|
100
|
+
try_files $uri =404;
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Optionally call `reloadOnStaleChunks()` in `main.ts` to reload once when a
|
|
105
|
+
lazily loaded chunk was removed by a deploy.
|
|
106
|
+
|
|
79
107
|
## Development
|
|
80
108
|
|
|
81
109
|
### Bootstrapping a New Component
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tells users that a newer version of the app has been deployed while their tab
|
|
3
|
+
* stayed open, and offers to refresh the page.
|
|
4
|
+
*
|
|
5
|
+
* Build the app with the `appBuildVersion()` Vite plugin, which gives each build
|
|
6
|
+
* a unique ID. The notice checks the deployed version when the tab regains focus
|
|
7
|
+
* or visibility, and every 10 minutes while it is visible. It does nothing in
|
|
8
|
+
* development or without the plugin.
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* // vite.config.ts
|
|
12
|
+
* import { appBuildVersion } from "@illinois-grad/grad-vue/vite";
|
|
13
|
+
*
|
|
14
|
+
* export default defineConfig({
|
|
15
|
+
* plugins: [vue(), appBuildVersion()],
|
|
16
|
+
* });
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* ```vue
|
|
20
|
+
* <GAppUpdateNotice />
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* Serve `version.json` with `Cache-Control: no-store`, and optionally call
|
|
24
|
+
* `reloadOnStaleChunks()` at startup to recover from lazily loaded chunks that
|
|
25
|
+
* a deploy removed.
|
|
26
|
+
*/
|
|
27
|
+
declare const _default: typeof __VLS_export;
|
|
28
|
+
export default _default;
|
|
29
|
+
declare const __VLS_export: import("vue").DefineComponent<{
|
|
30
|
+
/**
|
|
31
|
+
* Message shown when an update is available
|
|
32
|
+
* @demo
|
|
33
|
+
*/
|
|
34
|
+
message?: string;
|
|
35
|
+
/**
|
|
36
|
+
* Refresh button text
|
|
37
|
+
* @demo
|
|
38
|
+
*/
|
|
39
|
+
reloadLabel?: string;
|
|
40
|
+
/**
|
|
41
|
+
* Dismiss button text
|
|
42
|
+
* @demo
|
|
43
|
+
*/
|
|
44
|
+
dismissLabel?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Milliseconds between checks while the tab is visible
|
|
47
|
+
*/
|
|
48
|
+
intervalMs?: number;
|
|
49
|
+
/**
|
|
50
|
+
* URL of the deployed version file, defaults to the one set by `appBuildVersion()`
|
|
51
|
+
*/
|
|
52
|
+
versionUrl?: string;
|
|
53
|
+
/**
|
|
54
|
+
* Build ID of the running app, defaults to the one set by `appBuildVersion()`
|
|
55
|
+
*/
|
|
56
|
+
currentBuildId?: string;
|
|
57
|
+
}, {
|
|
58
|
+
/** Checks for a new version immediately */
|
|
59
|
+
check: () => Promise<void>;
|
|
60
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
|
|
61
|
+
/**
|
|
62
|
+
* Message shown when an update is available
|
|
63
|
+
* @demo
|
|
64
|
+
*/
|
|
65
|
+
message?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Refresh button text
|
|
68
|
+
* @demo
|
|
69
|
+
*/
|
|
70
|
+
reloadLabel?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Dismiss button text
|
|
73
|
+
* @demo
|
|
74
|
+
*/
|
|
75
|
+
dismissLabel?: string;
|
|
76
|
+
/**
|
|
77
|
+
* Milliseconds between checks while the tab is visible
|
|
78
|
+
*/
|
|
79
|
+
intervalMs?: number;
|
|
80
|
+
/**
|
|
81
|
+
* URL of the deployed version file, defaults to the one set by `appBuildVersion()`
|
|
82
|
+
*/
|
|
83
|
+
versionUrl?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Build ID of the running app, defaults to the one set by `appBuildVersion()`
|
|
86
|
+
*/
|
|
87
|
+
currentBuildId?: string;
|
|
88
|
+
}> & Readonly<{}>, {
|
|
89
|
+
message: string;
|
|
90
|
+
reloadLabel: string;
|
|
91
|
+
dismissLabel: string;
|
|
92
|
+
intervalMs: number;
|
|
93
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/** Name of the `<meta>` tag that `appBuildVersion()` from `@illinois-grad/grad-vue/vite` adds to `index.html`. */
|
|
2
|
+
export declare const APP_BUILD_ID_META = "app-build-id";
|
|
3
|
+
export interface AppUpdateCheckOptions {
|
|
4
|
+
/** Milliseconds between checks while the tab is visible. Defaults to 10 minutes. */
|
|
5
|
+
intervalMs?: number;
|
|
6
|
+
/** URL of the deployed build's version file. Defaults to the one set by `appBuildVersion()`. */
|
|
7
|
+
versionUrl?: string;
|
|
8
|
+
/** Build ID of the running app. Defaults to the one set by `appBuildVersion()`. */
|
|
9
|
+
currentBuildId?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Detects that a newer build was deployed while this tab stayed open, so the user can reload
|
|
13
|
+
* instead of running stale code against an updated API.
|
|
14
|
+
*
|
|
15
|
+
* Checks when the tab regains focus or visibility, and periodically while it is visible.
|
|
16
|
+
* Does nothing unless the app is built with `appBuildVersion()` from `@illinois-grad/grad-vue/vite`,
|
|
17
|
+
* or `currentBuildId` and `versionUrl` are given.
|
|
18
|
+
*/
|
|
19
|
+
export declare function useAppUpdateCheck(options?: AppUpdateCheckOptions): {
|
|
20
|
+
updateAvailable: import("vue").Ref<boolean, boolean>;
|
|
21
|
+
check: () => Promise<void>;
|
|
22
|
+
reload: () => void;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Reloads once when a lazily loaded chunk is missing because a newer build replaced it.
|
|
26
|
+
* A second failure shortly after a reload is left to surface instead of looping.
|
|
27
|
+
*
|
|
28
|
+
* Call it once at startup, e.g. in `main.ts`.
|
|
29
|
+
*/
|
|
30
|
+
export declare function reloadOnStaleChunks(): void;
|