@illinois-grad/grad-vue 7.2.6 → 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 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>;
@@ -112,8 +112,8 @@ declare const __VLS_export: import("vue").DefineComponent<{
112
112
  }>, {
113
113
  label: string;
114
114
  required: boolean;
115
- radio: boolean;
116
115
  name: string;
116
+ radio: boolean;
117
117
  instructions: string;
118
118
  errors: string[];
119
119
  formKey: string;
@@ -1,9 +1,11 @@
1
- declare var __VLS_1: {}, __VLS_3: {};
2
- type __VLS_Slots = {} & {
3
- default?: (props: typeof __VLS_1) => any;
4
- } & {
5
- fallback?: (props: typeof __VLS_3) => any;
1
+ declare const __VLS_template: () => {
2
+ __VLS_Slots: {
3
+ default?: (props: {}) => any;
4
+ } & {
5
+ fallback?: (props: {}) => any;
6
+ };
6
7
  };
8
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
7
9
  declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
8
10
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
9
11
  declare const _default: typeof __VLS_export;
@@ -70,9 +70,9 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
70
70
  onSubmit?: ((values: Record<string, any>) => any) | undefined;
71
71
  "onUpdate:modelValue"?: ((value: Record<string, any>) => any) | undefined;
72
72
  }>, {
73
- formKey: string;
74
73
  action: string;
75
74
  method: string;
75
+ formKey: string;
76
76
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
77
77
  default?: (props: {
78
78
  isSubmitting: boolean;
@@ -141,11 +141,11 @@ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<{
141
141
  placeholder: string;
142
142
  required: boolean;
143
143
  name: string;
144
+ prefix: string;
144
145
  disabled: boolean;
145
146
  instructions: string;
146
147
  errors: string[];
147
148
  formKey: string;
148
- prefix: string;
149
149
  suffix: string;
150
150
  debounce: number;
151
151
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>, {
@@ -4,12 +4,14 @@ interface Props {
4
4
  */
5
5
  label: string;
6
6
  }
7
- declare var __VLS_1: {}, __VLS_3: {};
8
- type __VLS_Slots = {} & {
9
- label?: (props: typeof __VLS_1) => any;
10
- } & {
11
- default?: (props: typeof __VLS_3) => any;
7
+ declare const __VLS_template: () => {
8
+ __VLS_Slots: {
9
+ label?: (props: {}) => any;
10
+ } & {
11
+ default?: (props: {}) => any;
12
+ };
12
13
  };
14
+ type __VLS_Slots = ReturnType<typeof __VLS_template>['__VLS_Slots'];
13
15
  declare const __VLS_base: import("vue").DefineComponent<Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
14
16
  declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
15
17
  declare const _default: typeof __VLS_export;
@@ -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;