@gusnips/react 0.9.24 → 0.9.26
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 +173 -36
- package/dist/api-client.d.ts +51 -51
- package/dist/api-client.d.ts.map +1 -1
- package/dist/api-client.js +3 -3
- package/dist/api-error.d.ts +11 -11
- package/dist/api-error.js +11 -11
- package/dist/auth-email.d.ts +40 -0
- package/dist/auth-email.d.ts.map +1 -0
- package/dist/auth-email.js +106 -0
- package/dist/auth-email.js.map +1 -0
- package/dist/auth-store.d.ts +23 -23
- package/dist/auth-store.js +13 -13
- package/dist/commands.d.ts +80 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +192 -0
- package/dist/commands.js.map +1 -0
- package/dist/copy.d.ts +3 -3
- package/dist/copy.js +3 -3
- package/dist/deploy-recovery.d.ts +40 -40
- package/dist/deploy-recovery.js +40 -40
- package/dist/describe-error.d.ts +68 -68
- package/dist/describe-error.d.ts.map +1 -1
- package/dist/describe-error.js +5 -5
- package/dist/error-boundary.d.ts +12 -12
- package/dist/guards.d.ts +15 -15
- package/dist/guards.js +3 -3
- package/dist/hydrate.d.ts +15 -16
- package/dist/hydrate.d.ts.map +1 -1
- package/dist/hydrate.js +9 -9
- package/dist/hydrate.js.map +1 -1
- package/dist/i18n.d.ts +15 -16
- package/dist/i18n.d.ts.map +1 -1
- package/dist/i18n.js +5 -6
- package/dist/i18n.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/internal-path.d.ts +8 -7
- package/dist/internal-path.d.ts.map +1 -1
- package/dist/internal-path.js +8 -7
- package/dist/internal-path.js.map +1 -1
- package/dist/prerender-contract.d.ts +7 -7
- package/dist/prerender-contract.js +7 -7
- package/dist/query.d.ts +16 -17
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +2 -2
- package/dist/query.js.map +1 -1
- package/dist/sse.d.ts +19 -20
- package/dist/sse.d.ts.map +1 -1
- package/dist/sse.js +18 -19
- package/dist/sse.js.map +1 -1
- package/dist/states.d.ts +12 -12
- package/dist/states.d.ts.map +1 -1
- package/dist/supabase-session.d.ts +47 -48
- package/dist/supabase-session.d.ts.map +1 -1
- package/dist/supabase-session.js +35 -35
- package/dist/supabase-session.js.map +1 -1
- package/dist/theme.d.ts +4 -4
- package/dist/theme.js +4 -4
- package/dist/ui/class-name.d.ts +3 -4
- package/dist/ui/class-name.d.ts.map +1 -1
- package/dist/ui/class-name.js +3 -4
- package/dist/ui/class-name.js.map +1 -1
- package/dist/ui/combobox.d.ts +11 -11
- package/dist/ui/combobox.d.ts.map +1 -1
- package/dist/ui/dialog.d.ts +5 -5
- package/dist/ui/dialog.js +2 -2
- package/dist/ui/drawer.d.ts +10 -10
- package/dist/ui/drawer.d.ts.map +1 -1
- package/dist/ui/drawer.js +2 -2
- package/dist/ui/input.d.ts +2 -2
- package/dist/ui/input.js +2 -2
- package/dist/ui/menu.d.ts +9 -9
- package/dist/ui/menu.d.ts.map +1 -1
- package/dist/ui/menu.js +4 -4
- package/dist/ui/menu.js.map +1 -1
- package/dist/ui/select.d.ts +12 -12
- package/dist/ui/select.d.ts.map +1 -1
- package/dist/ui/select.js +3 -3
- package/dist/ui/tabs.d.ts +14 -15
- package/dist/ui/tabs.d.ts.map +1 -1
- package/dist/ui/tabs.js +13 -14
- package/dist/ui/tabs.js.map +1 -1
- package/package.json +5 -1
- package/src/api-client.ts +51 -51
- package/src/api-error.ts +11 -11
- package/src/auth-email.test.ts +145 -0
- package/src/auth-email.ts +112 -0
- package/src/auth-store.ts +23 -23
- package/src/commands-hook.test.ts +444 -0
- package/src/commands.test.ts +245 -0
- package/src/commands.ts +268 -0
- package/src/copy.ts +3 -3
- package/src/deploy-recovery.ts +40 -40
- package/src/describe-error.ts +68 -68
- package/src/error-boundary.tsx +12 -12
- package/src/guards.tsx +15 -15
- package/src/hydrate.ts +15 -16
- package/src/i18n.ts +15 -16
- package/src/index.ts +2 -0
- package/src/internal-path.ts +8 -7
- package/src/prerender-contract.ts +7 -7
- package/src/query.ts +16 -17
- package/src/sse.ts +19 -20
- package/src/states.ts +12 -12
- package/src/supabase-session.ts +46 -47
- package/src/theme.ts +4 -4
- package/src/ui/class-name.ts +3 -4
- package/src/ui/combobox.tsx +11 -11
- package/src/ui/dialog.tsx +5 -5
- package/src/ui/drawer.tsx +10 -10
- package/src/ui/input.tsx +2 -2
- package/src/ui/menu.tsx +8 -8
- package/src/ui/select.tsx +12 -12
- package/src/ui/tabs.tsx +14 -15
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.js","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAkBxC,oEAAoE;AACpE,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,IAAI,yBAAyB,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACtD,MAAM,KAAK,GAAG,kCAAkC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5D,IAAI,CAAC,KAAK;QAAE,OAAO,IAAI,CAAC;IACxB,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;IAC5C,OAAO,KAAK,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACrE,CAAC;AAOD,yEAAyE;AACzE,MAAM,UAAU,cAAc,CAC5B,QAAsB,EACtB,IAAY;IAEZ,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACjC,IAAI,CAAC,KAAK;QAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EA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I,KAAK,CAAC,GAAG,KAAK,KAAK,CAAC,EAAE,CAAC;gBAC7D,KAAK,CAAC,cAAc,EAAE,CAAC;gBACvB,IAAI,KAAK,CAAC,GAAG,KAAK,KAAK,EAAE,CAAC;oBACxB,QAAQ,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;gBAC1C,CAAC;qBAAM,IAAI,UAAU,EAAE,IAAI,KAAK,WAAW,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;oBACjE,OAAO,CAAC,UAAU,CAAC,CAAC;gBACtB,CAAC;qBAAM,CAAC;oBACN,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;gBAC7B,CAAC;gBACD,OAAO,IAAI,CAAC;YACd,CAAC;QACH,CAAC;QACD,IAAI,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO,EAAE,CAAC;YACpC,KAAK,CAAC,cAAc,EAAE,CAAC;YACvB,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC9B,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO;QACL,MAAM;QACN,IAAI;QACJ,KAAK;QACL,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,MAAM;QACN,MAAM;QACN,MAAM;QACN,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS;QAC7C,SAAS;QACT,KAAK;QACL,OAAO;QACP,IAAI;QACJ,MAAM;QACN,aAAa;KACd,CAAC;AACJ,CAAC"}
|
package/dist/copy.d.ts
CHANGED
|
@@ -8,9 +8,9 @@ export interface CopyOptions {
|
|
|
8
8
|
failedMs?: number;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
* A copy with an outcome the reader can see.
|
|
12
|
-
* and copy it yourself", in a label or a toast
|
|
13
|
-
* needs `aria-live="polite"` to be heard.
|
|
11
|
+
* A copy with an outcome the reader can see. You choose what it says, such as "Copied" or "Select
|
|
12
|
+
* it and copy it yourself", in a label or a toast. You also choose how to announce it: a label that
|
|
13
|
+
* changes needs `aria-live="polite"` to be heard.
|
|
14
14
|
*
|
|
15
15
|
* The outcome goes back to `"idle"` on its own. A "Copied" that never clears makes the second copy
|
|
16
16
|
* look like it did not take.
|
package/dist/copy.js
CHANGED
|
@@ -18,9 +18,9 @@ export async function copyText(text) {
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
* A copy with an outcome the reader can see.
|
|
22
|
-
* and copy it yourself", in a label or a toast
|
|
23
|
-
* needs `aria-live="polite"` to be heard.
|
|
21
|
+
* A copy with an outcome the reader can see. You choose what it says, such as "Copied" or "Select
|
|
22
|
+
* it and copy it yourself", in a label or a toast. You also choose how to announce it: a label that
|
|
23
|
+
* changes needs `aria-live="polite"` to be heard.
|
|
24
24
|
*
|
|
25
25
|
* The outcome goes back to `"idle"` on its own. A "Copied" that never clears makes the second copy
|
|
26
26
|
* look like it did not take.
|
|
@@ -5,26 +5,26 @@
|
|
|
5
5
|
* every hashed asset underneath whatever tabs are already open, and those tabs go on running
|
|
6
6
|
* yesterday's bundle. It surfaces two ways, and only one of them looks like a missing file:
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* 1. The next navigation asks for a chunk whose hashed name is gone. React's lazy boundary throws,
|
|
9
|
+
* and the person gets a white screen on a click that worked a minute ago. 2. The old bundle reads a
|
|
10
|
+
* field the API has since renamed, and throws. That one arrives as a plain `TypeError` with nothing
|
|
11
|
+
* in it about a deploy: no file, no hash, no signal.
|
|
12
12
|
*
|
|
13
13
|
* So there are two detectors here and they are not interchangeable. {@link isChunkLoadError}
|
|
14
|
-
* matches the message, which is all you have for a failure that never reaches a boundary.
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* matches the message, which is all you have for a failure that never reaches a boundary. {@link
|
|
15
|
+
* isStaleBuild} asks the server for evidence rather than a guess. It is the only one that catches
|
|
16
|
+
* case 2 at all.
|
|
17
17
|
*
|
|
18
18
|
* **The deepest fix is not in this file, and it is worth more than everything in it.** A static
|
|
19
|
-
* host answers a missing `/assets/x.js` with the SPA fallback
|
|
20
|
-
* `text/html
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
19
|
+
* host answers a missing `/assets/x.js` with the SPA fallback, `index.html`, at a 200, as
|
|
20
|
+
* `text/html`. That is what the browser's "MIME type text/html" module-script refusal actually is.
|
|
21
|
+
* Hosts then match cache rules against the REQUEST PATH rather than the outcome, so the `immutable,
|
|
22
|
+
* max-age=31536000` rule written for hashed assets gets applied to that HTML body: one poisoned
|
|
23
|
+
* asset URL, at the edge and in every browser that touched it, for a year. One adopter removed the
|
|
24
|
+
* cause instead of recovering from it: no blanket fallback over `/assets/`, and an edge function
|
|
25
|
+
* that refuses to answer an asset path with `text/html`. That turns a dead chunk into a real,
|
|
26
|
+
* uncacheable 404 and lets everything below be recovery rather than the plan. A package cannot ship
|
|
27
|
+
* that; it can refuse to let it go unwritten.
|
|
28
28
|
*/
|
|
29
29
|
/**
|
|
30
30
|
* One stamp for every reason to reload, which is the part that is easy to get wrong.
|
|
@@ -40,14 +40,14 @@
|
|
|
40
40
|
*/
|
|
41
41
|
export declare const RELOAD_GUARD_KEY = "frontkit:reload-at";
|
|
42
42
|
/**
|
|
43
|
-
* A lazy-chunk fetch failure
|
|
43
|
+
* A lazy-chunk fetch failure that a reload can fix.
|
|
44
44
|
*
|
|
45
|
-
* Matched by message because no browser gives it a shared type. Every phrasing in the wild is
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
45
|
+
* Matched by message because no browser gives it a shared type. Every phrasing in the wild is here:
|
|
46
|
+
* Chrome/Edge "Failed to fetch dynamically imported module", Firefox "error loading dynamically
|
|
47
|
+
* imported module", Safari "Importing a module script failed", webpack's ChunkLoadError and
|
|
48
|
+
* "Loading chunk N failed", and the SPA-fallback "MIME type" refusal. The last one that fires on a
|
|
49
|
+
* static host that has not fixed the cause above, because the missing `.js` is answered with
|
|
50
|
+
* `index.html`.
|
|
51
51
|
*
|
|
52
52
|
* A standalone predicate rather than a method on the boundary, so a global `unhandledrejection`
|
|
53
53
|
* handler can classify the same failure without importing a component.
|
|
@@ -56,13 +56,13 @@ export declare function isChunkLoadError(error: unknown): boolean;
|
|
|
56
56
|
/**
|
|
57
57
|
* Is the build this tab is running still the one being served?
|
|
58
58
|
*
|
|
59
|
-
* Asked of the server, so the answer is evidence rather than a guess.
|
|
60
|
-
*
|
|
61
|
-
*
|
|
59
|
+
* Asked of the server, so the answer is evidence rather than a guess. An offline request, a non-200
|
|
60
|
+
* response, a captive portal or a timed-out probe resolves to `false`: dressing a genuine bug up as
|
|
61
|
+
* an update hides it from the user and from us.
|
|
62
62
|
*
|
|
63
63
|
* It asks for the PAGE, not for the asset, and that is not the obvious choice. A missing asset
|
|
64
64
|
* looks like the direct question, but a CDN commonly serves assets with a long `s-maxage`, so a
|
|
65
|
-
* bundle a deploy retired an hour ago still answers 200 from the edge
|
|
65
|
+
* bundle a deploy retired an hour ago still answers 200 from the edge. It would report "current"
|
|
66
66
|
* during exactly the window when skew is most likely. The page is the one URL that cannot lie: it
|
|
67
67
|
* ships `max-age=0, must-revalidate` and never enters the edge cache.
|
|
68
68
|
*/
|
|
@@ -73,9 +73,9 @@ export declare function isStaleBuild(): Promise<boolean>;
|
|
|
73
73
|
* rather than watching the same attempt loop.
|
|
74
74
|
*
|
|
75
75
|
* The guard is the part that matters. Reloading on a failure is obvious; reloading on a failure
|
|
76
|
-
* that the reload does not fix is an infinite loop with the user inside it. At most one reload
|
|
77
|
-
*
|
|
78
|
-
*
|
|
76
|
+
* that the reload does not fix is an infinite loop with the user inside it. At most one reload per
|
|
77
|
+
* minute, so a genuinely broken deploy shows the error screen instead of flickering forever. That
|
|
78
|
+
* screen can at least say something.
|
|
79
79
|
*
|
|
80
80
|
* `sessionStorage` and not `localStorage`: the guard is about this tab's current predicament, and
|
|
81
81
|
* a stale stamp in another tab must not suppress a reload this one needs. Wrapped because storage
|
|
@@ -86,22 +86,22 @@ export declare function reloadOnce(): boolean;
|
|
|
86
86
|
/**
|
|
87
87
|
* Vite's *hint* failure, which is not the same thing and must not be treated as one.
|
|
88
88
|
*
|
|
89
|
-
* Vite injects a speculative `<link rel="stylesheet">` for a chunk's CSS before importing it.
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
89
|
+
* Vite injects a speculative `<link rel="stylesheet">` for a chunk's CSS before importing it. When
|
|
90
|
+
* that link fails, the import itself still runs right after and usually succeeds, so this one is
|
|
91
|
+
* worth swallowing, where a failure of the import is the real thing {@link isChunkLoadError}
|
|
92
|
+
* matches. Vite builds this message in exactly one place and only ever for a stylesheet link;
|
|
93
|
+
* script hints never reject.
|
|
94
94
|
*/
|
|
95
95
|
export declare function isPreloadHintFailure(error: unknown): boolean;
|
|
96
96
|
/**
|
|
97
97
|
* Install the `vite:preloadError` listener. Call once, from the browser entry.
|
|
98
98
|
*
|
|
99
|
-
* Vite offers `preventDefault()` here so an app can own a failed asset itself
|
|
100
|
-
*
|
|
99
|
+
* Vite offers `preventDefault()` here so an app can own a failed asset itself, but taking that deal
|
|
100
|
+
* unconditionally resolves the dynamic import with `undefined` (Vite's helper ends in
|
|
101
101
|
* `baseModule().catch(handlePreloadError)`), and `React.lazy` then reads `.default` off nothing.
|
|
102
|
-
* The user gets the crash screen and the developer gets a TypeError with only React frames in
|
|
103
|
-
*
|
|
104
|
-
*
|
|
102
|
+
* The user gets the crash screen and the developer gets a TypeError with only React frames in it,
|
|
103
|
+
* naming no chunk. So it is taken ONLY for a failed preload hint, where the import still runs. A
|
|
104
|
+
* real module failure is left to throw, where the error boundary can recognise it.
|
|
105
105
|
*/
|
|
106
106
|
export declare function installPreloadErrorHandler(): void;
|
|
107
107
|
//# sourceMappingURL=deploy-recovery.d.ts.map
|
package/dist/deploy-recovery.js
CHANGED
|
@@ -5,26 +5,26 @@
|
|
|
5
5
|
* every hashed asset underneath whatever tabs are already open, and those tabs go on running
|
|
6
6
|
* yesterday's bundle. It surfaces two ways, and only one of them looks like a missing file:
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* 1. The next navigation asks for a chunk whose hashed name is gone. React's lazy boundary throws,
|
|
9
|
+
* and the person gets a white screen on a click that worked a minute ago. 2. The old bundle reads a
|
|
10
|
+
* field the API has since renamed, and throws. That one arrives as a plain `TypeError` with nothing
|
|
11
|
+
* in it about a deploy: no file, no hash, no signal.
|
|
12
12
|
*
|
|
13
13
|
* So there are two detectors here and they are not interchangeable. {@link isChunkLoadError}
|
|
14
|
-
* matches the message, which is all you have for a failure that never reaches a boundary.
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* matches the message, which is all you have for a failure that never reaches a boundary. {@link
|
|
15
|
+
* isStaleBuild} asks the server for evidence rather than a guess. It is the only one that catches
|
|
16
|
+
* case 2 at all.
|
|
17
17
|
*
|
|
18
18
|
* **The deepest fix is not in this file, and it is worth more than everything in it.** A static
|
|
19
|
-
* host answers a missing `/assets/x.js` with the SPA fallback
|
|
20
|
-
* `text/html
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
19
|
+
* host answers a missing `/assets/x.js` with the SPA fallback, `index.html`, at a 200, as
|
|
20
|
+
* `text/html`. That is what the browser's "MIME type text/html" module-script refusal actually is.
|
|
21
|
+
* Hosts then match cache rules against the REQUEST PATH rather than the outcome, so the `immutable,
|
|
22
|
+
* max-age=31536000` rule written for hashed assets gets applied to that HTML body: one poisoned
|
|
23
|
+
* asset URL, at the edge and in every browser that touched it, for a year. One adopter removed the
|
|
24
|
+
* cause instead of recovering from it: no blanket fallback over `/assets/`, and an edge function
|
|
25
|
+
* that refuses to answer an asset path with `text/html`. That turns a dead chunk into a real,
|
|
26
|
+
* uncacheable 404 and lets everything below be recovery rather than the plan. A package cannot ship
|
|
27
|
+
* that; it can refuse to let it go unwritten.
|
|
28
28
|
*/
|
|
29
29
|
/**
|
|
30
30
|
* One stamp for every reason to reload, which is the part that is easy to get wrong.
|
|
@@ -44,14 +44,14 @@ const RELOAD_WINDOW_MS = 60_000;
|
|
|
44
44
|
* land on the real error screen instead of an endless spinner. */
|
|
45
45
|
const PROBE_TIMEOUT_MS = 4_000;
|
|
46
46
|
/**
|
|
47
|
-
* A lazy-chunk fetch failure
|
|
47
|
+
* A lazy-chunk fetch failure that a reload can fix.
|
|
48
48
|
*
|
|
49
|
-
* Matched by message because no browser gives it a shared type. Every phrasing in the wild is
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
49
|
+
* Matched by message because no browser gives it a shared type. Every phrasing in the wild is here:
|
|
50
|
+
* Chrome/Edge "Failed to fetch dynamically imported module", Firefox "error loading dynamically
|
|
51
|
+
* imported module", Safari "Importing a module script failed", webpack's ChunkLoadError and
|
|
52
|
+
* "Loading chunk N failed", and the SPA-fallback "MIME type" refusal. The last one that fires on a
|
|
53
|
+
* static host that has not fixed the cause above, because the missing `.js` is answered with
|
|
54
|
+
* `index.html`.
|
|
55
55
|
*
|
|
56
56
|
* A standalone predicate rather than a method on the boundary, so a global `unhandledrejection`
|
|
57
57
|
* handler can classify the same failure without importing a component.
|
|
@@ -86,13 +86,13 @@ function runningEntry() {
|
|
|
86
86
|
/**
|
|
87
87
|
* Is the build this tab is running still the one being served?
|
|
88
88
|
*
|
|
89
|
-
* Asked of the server, so the answer is evidence rather than a guess.
|
|
90
|
-
*
|
|
91
|
-
*
|
|
89
|
+
* Asked of the server, so the answer is evidence rather than a guess. An offline request, a non-200
|
|
90
|
+
* response, a captive portal or a timed-out probe resolves to `false`: dressing a genuine bug up as
|
|
91
|
+
* an update hides it from the user and from us.
|
|
92
92
|
*
|
|
93
93
|
* It asks for the PAGE, not for the asset, and that is not the obvious choice. A missing asset
|
|
94
94
|
* looks like the direct question, but a CDN commonly serves assets with a long `s-maxage`, so a
|
|
95
|
-
* bundle a deploy retired an hour ago still answers 200 from the edge
|
|
95
|
+
* bundle a deploy retired an hour ago still answers 200 from the edge. It would report "current"
|
|
96
96
|
* during exactly the window when skew is most likely. The page is the one URL that cannot lie: it
|
|
97
97
|
* ships `max-age=0, must-revalidate` and never enters the edge cache.
|
|
98
98
|
*/
|
|
@@ -119,9 +119,9 @@ export async function isStaleBuild() {
|
|
|
119
119
|
* rather than watching the same attempt loop.
|
|
120
120
|
*
|
|
121
121
|
* The guard is the part that matters. Reloading on a failure is obvious; reloading on a failure
|
|
122
|
-
* that the reload does not fix is an infinite loop with the user inside it. At most one reload
|
|
123
|
-
*
|
|
124
|
-
*
|
|
122
|
+
* that the reload does not fix is an infinite loop with the user inside it. At most one reload per
|
|
123
|
+
* minute, so a genuinely broken deploy shows the error screen instead of flickering forever. That
|
|
124
|
+
* screen can at least say something.
|
|
125
125
|
*
|
|
126
126
|
* `sessionStorage` and not `localStorage`: the guard is about this tab's current predicament, and
|
|
127
127
|
* a stale stamp in another tab must not suppress a reload this one needs. Wrapped because storage
|
|
@@ -145,11 +145,11 @@ export function reloadOnce() {
|
|
|
145
145
|
/**
|
|
146
146
|
* Vite's *hint* failure, which is not the same thing and must not be treated as one.
|
|
147
147
|
*
|
|
148
|
-
* Vite injects a speculative `<link rel="stylesheet">` for a chunk's CSS before importing it.
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
*
|
|
148
|
+
* Vite injects a speculative `<link rel="stylesheet">` for a chunk's CSS before importing it. When
|
|
149
|
+
* that link fails, the import itself still runs right after and usually succeeds, so this one is
|
|
150
|
+
* worth swallowing, where a failure of the import is the real thing {@link isChunkLoadError}
|
|
151
|
+
* matches. Vite builds this message in exactly one place and only ever for a stylesheet link;
|
|
152
|
+
* script hints never reject.
|
|
153
153
|
*/
|
|
154
154
|
export function isPreloadHintFailure(error) {
|
|
155
155
|
return error instanceof Error && error.message.startsWith("Unable to preload CSS for");
|
|
@@ -157,12 +157,12 @@ export function isPreloadHintFailure(error) {
|
|
|
157
157
|
/**
|
|
158
158
|
* Install the `vite:preloadError` listener. Call once, from the browser entry.
|
|
159
159
|
*
|
|
160
|
-
* Vite offers `preventDefault()` here so an app can own a failed asset itself
|
|
161
|
-
*
|
|
160
|
+
* Vite offers `preventDefault()` here so an app can own a failed asset itself, but taking that deal
|
|
161
|
+
* unconditionally resolves the dynamic import with `undefined` (Vite's helper ends in
|
|
162
162
|
* `baseModule().catch(handlePreloadError)`), and `React.lazy` then reads `.default` off nothing.
|
|
163
|
-
* The user gets the crash screen and the developer gets a TypeError with only React frames in
|
|
164
|
-
*
|
|
165
|
-
*
|
|
163
|
+
* The user gets the crash screen and the developer gets a TypeError with only React frames in it,
|
|
164
|
+
* naming no chunk. So it is taken ONLY for a failed preload hint, where the import still runs. A
|
|
165
|
+
* real module failure is left to throw, where the error boundary can recognise it.
|
|
166
166
|
*/
|
|
167
167
|
export function installPreloadErrorHandler() {
|
|
168
168
|
window.addEventListener("vite:preloadError", (event) => {
|
package/dist/describe-error.d.ts
CHANGED
|
@@ -3,21 +3,21 @@ import { ApiError } from "./api-error.ts";
|
|
|
3
3
|
* Turning anything thrown into copy a person can act on.
|
|
4
4
|
*
|
|
5
5
|
* The API already answers with a message written for a developer, a stable `messageKey` for the
|
|
6
|
-
* domain refusals, and `details` carrying the parts that make a refusal actionable. This is the
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* domain refusals, and `details` carrying the parts that make a refusal actionable. This is the one
|
|
7
|
+
* place that decides what the SCREEN says. It is not always the same sentence. "Monthly quota
|
|
8
|
+
* spent, upgrade or buy a pack" is right in a JSON body and wrong under a button that could just
|
|
9
|
+
* say what to do next.
|
|
10
10
|
*
|
|
11
11
|
* `cause` is what happened. `fix` is what to do about it. **A surface that shows only the first
|
|
12
|
-
* half is the dead end this exists to prevent
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* half is the dead end this exists to prevent**. That is why the type has two fields and not one,
|
|
13
|
+
* and why `fix` being absent should be a deliberate choice at each call site rather than the
|
|
14
|
+
* default nobody noticed.
|
|
15
15
|
*
|
|
16
|
-
* `fix`, and not the `hint` this returned until 0.6.0. `ErrorStateProps
|
|
17
|
-
* package ships for the component that renders this
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
16
|
+
* `fix`, and not the `hint` this returned until 0.6.0. `ErrorStateProps`, the contract this same
|
|
17
|
+
* package ships for the component that renders this, has always called it `fix`, so every adopter
|
|
18
|
+
* wrote `fix={hint}` at every error surface: a rename adapter, which is the shape of an API we got
|
|
19
|
+
* wrong. It also clears a collision, because in at least one adopter a form field's `hint` is the
|
|
20
|
+
* requirement text under the input, which is a different thing entirely.
|
|
21
21
|
*
|
|
22
22
|
* The per-code switch stays in the product: two donors' switches shared their SHAPE and almost
|
|
23
23
|
* no arms, because the arms are that API's vocabulary. What ships is the scaffolding around it,
|
|
@@ -26,11 +26,11 @@ import { ApiError } from "./api-error.ts";
|
|
|
26
26
|
/**
|
|
27
27
|
* Which control to offer beside the words.
|
|
28
28
|
*
|
|
29
|
-
* The fourth adopter had this and the package did not, which left every adopter re-deriving
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
29
|
+
* The fourth adopter had this and the package did not, which left every adopter re-deriving "can a
|
|
30
|
+
* second attempt fix this" from its own switch, beside a `shouldRetry` already deciding exactly
|
|
31
|
+
* that for react-query. Two answers to one question drift, and the drift is visible: a screen
|
|
32
|
+
* offering "try again" for a refusal the query layer refuses to retry, so the button does nothing
|
|
33
|
+
* and the reader presses it twice.
|
|
34
34
|
*
|
|
35
35
|
* So this is DERIVED from `shouldRetry`, not switched on separately. One rule, two consumers.
|
|
36
36
|
*/
|
|
@@ -49,7 +49,7 @@ export interface ErrorCopy {
|
|
|
49
49
|
cause: string;
|
|
50
50
|
/** What to do about it. Its absence should be a decision, not an oversight. */
|
|
51
51
|
fix?: string;
|
|
52
|
-
/** Override the derived kind
|
|
52
|
+
/** Override the derived kind. A 429 whose code means a spent quota is `"none"`, not `"wait"`. */
|
|
53
53
|
recover?: RecoveryKind;
|
|
54
54
|
/** Override the request id. Rarely wanted; the envelope's is used by default. */
|
|
55
55
|
reference?: string;
|
|
@@ -59,14 +59,14 @@ export interface DescribedError extends ErrorCopy {
|
|
|
59
59
|
recover: RecoveryKind;
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
-
* The subset of i18next's `t` this module needs
|
|
62
|
+
* The subset of i18next's `t` this module needs, typed here so `i18next` stays optional.
|
|
63
63
|
*
|
|
64
|
-
* `Key` is a parameter and not plain `string` for a reason the first migration found. Every app
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
64
|
+
* `Key` is a parameter and not plain `string` for a reason the first migration found. Every app on
|
|
65
|
+
* this stack declares `CustomTypeOptions.resources`, which types `t` to accept ONLY the keys its
|
|
66
|
+
* catalog has, so a `t` is not assignable to anything asking for `(key: string) => string`, and the
|
|
67
|
+
* adopter is left with a cast. Naming the keys instead turns that around: each function below asks
|
|
68
|
+
* for exactly the keys it looks up, a typed `t` accepts a superset of them and goes in directly,
|
|
69
|
+
* and a catalog missing one is a compile error rather than a raw key on screen.
|
|
70
70
|
*/
|
|
71
71
|
export type Translate<Key extends string = string> = (key: Key, params?: Record<string, unknown>) => string;
|
|
72
72
|
/** The three names {@link humanizeWait} looks up, under whatever prefix you pass it. */
|
|
@@ -75,8 +75,8 @@ type WaitName = "waitSeconds" | "waitMinutes" | "waitHours";
|
|
|
75
75
|
* Every name {@link createErrorDescriber} looks up itself. Your catalog carries all of them.
|
|
76
76
|
*
|
|
77
77
|
* The three wait names are deliberately NOT here, which is the other half of 0.6.0. This module
|
|
78
|
-
* used to humanize a stated wait itself, so `waitSeconds`/`waitMinutes`/`waitHours
|
|
79
|
-
*
|
|
78
|
+
* used to humanize a stated wait itself, so `waitSeconds`/`waitMinutes`/`waitHours`, each with an
|
|
79
|
+
* ICU plural, landed in the key union of every adopter's `t` whether or not a wait was ever
|
|
80
80
|
* rendered. An app that formats waits with `Intl.RelativeTimeFormat` needs none of them and was
|
|
81
81
|
* left adding six entries per language to satisfy a compiler. `formatWait` owns that now.
|
|
82
82
|
*/
|
|
@@ -86,26 +86,26 @@ type CopyName = "network" | "networkHint" | "unexpected" | "retrySoon";
|
|
|
86
86
|
*
|
|
87
87
|
* i18next keeps `seatLimitReached_one` and `seatLimitReached_other`; the server sends
|
|
88
88
|
* `serverErrors.seatLimitReached`, because that is the key a person resolves with a `count`. So
|
|
89
|
-
* `Object.keys` on a catalog does NOT contain the name the server actually sends, and a gate
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
89
|
+
* `Object.keys` on a catalog does NOT contain the name the server actually sends, and a gate built
|
|
90
|
+
* from it alone rejects a sentence the app is carrying, falling back to the server's English for
|
|
91
|
+
* the one refusal that had a written answer. Measured in the seventh migration: two of that API's
|
|
92
|
+
* 112 keys, both of them plan limits, both of them the exact screen where a specific sentence earns
|
|
93
|
+
* its keep.
|
|
94
94
|
*/
|
|
95
95
|
type PluralSuffix = "zero" | "one" | "two" | "few" | "many" | "other";
|
|
96
96
|
type PluralBase<N extends string> = N extends `${infer Base}_${PluralSuffix}` ? Base : N;
|
|
97
97
|
/**
|
|
98
|
-
* "in 4 minutes"
|
|
98
|
+
* Format a wait as "in 4 minutes" or "in 2 hours", without making the reader convert seconds.
|
|
99
99
|
*
|
|
100
100
|
* The thresholds are deliberately not round: 90 seconds rather than 60, so "in 75 seconds" does
|
|
101
101
|
* not become the less precise "in 1 minute", and 90 minutes rather than 60 for the same reason
|
|
102
102
|
* one rung up. Needs `waitSeconds` / `waitMinutes` / `waitHours` under `prefix`, each with a
|
|
103
103
|
* `count` plural.
|
|
104
104
|
*
|
|
105
|
-
* This is what you pass as `formatWait` when your catalog carries those three:
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
105
|
+
* This is what you pass as `formatWait` when your catalog carries those three: `formatWait: (secs)
|
|
106
|
+
* => humanizeWait(t, secs, "errors.")`. An app that formats a wait with `Intl.RelativeTimeFormat`
|
|
107
|
+
* passes its own one-liner instead and needs no wait keys at all. It also gets correct plurals in
|
|
108
|
+
* languages with more than two forms, for free.
|
|
109
109
|
*/
|
|
110
110
|
export declare function humanizeWait<Prefix extends string>(t: Translate<`${Prefix}${WaitName}`>, secs: number, prefix: Prefix): string;
|
|
111
111
|
export interface ErrorContext {
|
|
@@ -129,17 +129,17 @@ interface DescriberRules {
|
|
|
129
129
|
* How a stated wait becomes words, for the `wait` an arm reads off its context.
|
|
130
130
|
*
|
|
131
131
|
* Required rather than defaulted, because there is no answer that is right for everyone and a
|
|
132
|
-
* default hid the cost: {@link humanizeWait} reads three ICU plural keys out of your catalog,
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
132
|
+
* default hid the cost: {@link humanizeWait} reads three ICU plural keys out of your catalog, and
|
|
133
|
+
* an app that already formats relative time with `Intl` would have had to add them to compile.
|
|
134
|
+
* Pass `(secs) => humanizeWait(t, secs, "errors.")` or your own `(secs) => formatIn(secs,
|
|
135
|
+
* locale)`. The choice makes the catalog you need visible.
|
|
136
136
|
*/
|
|
137
137
|
formatWait: (secs: number) => string;
|
|
138
138
|
/**
|
|
139
139
|
* Per-code copy. Everything not listed falls through to the default arm.
|
|
140
140
|
*
|
|
141
|
-
* The arms look up the app's own keys, so they close over the app's `t` rather than being
|
|
142
|
-
*
|
|
141
|
+
* The arms look up the app's own keys, so they close over the app's `t` rather than being handed
|
|
142
|
+
* one. This module has no names for that copy and no business typing it.
|
|
143
143
|
*
|
|
144
144
|
* Annotate your object `Partial<Record<YourErrorCode, ErrorArm>>` where you write it, and a
|
|
145
145
|
* code that does not exist is a compile error at the arm rather than a branch that never runs.
|
|
@@ -149,21 +149,21 @@ interface DescriberRules {
|
|
|
149
149
|
* What to say when nothing in `codes` matches: a code this build has no arm for, or an answer
|
|
150
150
|
* with no envelope at all.
|
|
151
151
|
*
|
|
152
|
-
* The built-in arm hands the reader the server's own `message`, and for one API in the fleet
|
|
153
|
-
*
|
|
152
|
+
* The built-in arm hands the reader the server's own `message`, and for one API in the fleet that
|
|
153
|
+
* is right, because its message IS the sentence a person should read. For another it is exactly
|
|
154
154
|
* wrong: that repo's own i18n rules say `message` is "the English fallback for logs", and it
|
|
155
155
|
* ships three languages, so the built-in would put developer English in front of a reader who
|
|
156
|
-
* does not speak it. One default cannot be right for both, and the one baked in here was
|
|
157
|
-
*
|
|
156
|
+
* does not speak it. One default cannot be right for both, and the one baked in here was simply
|
|
157
|
+
* the first adopter's convention, mistaken for a fact.
|
|
158
158
|
*
|
|
159
159
|
* An arm here is also handed the stated wait, which the built-in spends on nothing: a refusal
|
|
160
160
|
* with no arm of its own could state its expiry and have that go unsaid.
|
|
161
161
|
*/
|
|
162
162
|
fallback?: ErrorArm;
|
|
163
163
|
/**
|
|
164
|
-
* The codes that mean "this limit does not clear by waiting"
|
|
165
|
-
* `queryDefaults`**, because it answers the same question and a second copy is a second
|
|
166
|
-
*
|
|
164
|
+
* The codes that mean "this limit does not clear by waiting". Pass **the same list to
|
|
165
|
+
* `queryDefaults`**, because it answers the same question and a second copy is a second chance to
|
|
166
|
+
* disagree with the retry rule. Declare it once in the app and pass it twice.
|
|
167
167
|
*/
|
|
168
168
|
durableLimitCodes?: readonly string[];
|
|
169
169
|
/** Longest stated wait still worth a retry rather than a countdown. Matches `queryDefaults`. */
|
|
@@ -173,23 +173,23 @@ export interface ErrorDescriberOptions<Prefix extends string, ServerPrefix exten
|
|
|
173
173
|
/**
|
|
174
174
|
* Checked against the keys, never used to find them: the three type parameters come from
|
|
175
175
|
* `copyPrefix`, `messageKeyPrefix` and `knownMessageKeys`. With `t` as a source too, the call
|
|
176
|
-
* every adopter writes
|
|
176
|
+
* every adopter writes, an inline `(key, params) => i18n.t(key, params)` beside an inline arm,
|
|
177
177
|
* failed overload resolution (TS2769, measured on TypeScript 5.9.3) once the one-language
|
|
178
|
-
* overload existed, although this signature alone accepted it. A typed `t` missing a key is
|
|
179
|
-
*
|
|
178
|
+
* overload existed, although this signature alone accepted it. A typed `t` missing a key is still
|
|
179
|
+
* refused.
|
|
180
180
|
*/
|
|
181
181
|
t: Translate<NoInfer<`${Prefix}${CopyName}` | `${ServerPrefix}${ServerName | PluralBase<ServerName>}`>>;
|
|
182
182
|
/** Catalog namespace for this module's own copy, e.g. `"errors."`. */
|
|
183
183
|
copyPrefix: Prefix;
|
|
184
184
|
/**
|
|
185
185
|
* The server's own catalog namespace, e.g. `"serverErrors."`. A `messageKey` outside it is
|
|
186
|
-
* ignored
|
|
186
|
+
* ignored. The server names a sentence, it does not get to name any key in the app.
|
|
187
187
|
*
|
|
188
|
-
* The `code` is read under this prefix too, for an API that has no `messageKey` field and
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
*
|
|
188
|
+
* The `code` is read under this prefix too, for an API that has no `messageKey` field and lets
|
|
189
|
+
* the code name the sentence. One repo in the fleet has 98 of those, `errors.NOT_FOUND` and its
|
|
190
|
+
* siblings, against another repo's `messageKey`. Both are the same claim ("the server named a
|
|
191
|
+
* sentence this app carries"), both pass the same gate below, and an app that uses neither is
|
|
192
|
+
* unaffected because nothing matches.
|
|
193
193
|
*/
|
|
194
194
|
messageKeyPrefix: ServerPrefix;
|
|
195
195
|
/**
|
|
@@ -197,13 +197,13 @@ export interface ErrorDescriberOptions<Prefix extends string, ServerPrefix exten
|
|
|
197
197
|
* catalog. Passing the catalog itself is both the membership test and the proof the compiler
|
|
198
198
|
* wants: a name that is in it IS a key, so the lookup below needs no cast.
|
|
199
199
|
*
|
|
200
|
-
* It is required because leaving it out
|
|
201
|
-
*
|
|
200
|
+
* It is required because leaving it out reintroduces the bug the option exists to prevent rather
|
|
201
|
+
* than making this smaller. i18next answers a key it does not have with the key itself, so a
|
|
202
202
|
* deploy landing ahead of the bundle a tab is still running would render `serverErrors.foo` at
|
|
203
203
|
* somebody. A name that is absent falls back to the server's English `message` instead.
|
|
204
204
|
*
|
|
205
|
-
* Hand it over as it is. A plural sits in the catalog under suffixed names while the server
|
|
206
|
-
*
|
|
205
|
+
* Hand it over as it is. A plural sits in the catalog under suffixed names while the server names
|
|
206
|
+
* the base, so the base is admitted too. See {@link PluralBase}.
|
|
207
207
|
*/
|
|
208
208
|
knownMessageKeys: Record<ServerName, unknown>;
|
|
209
209
|
/**
|
|
@@ -211,13 +211,13 @@ export interface ErrorDescriberOptions<Prefix extends string, ServerPrefix exten
|
|
|
211
211
|
*
|
|
212
212
|
* The envelope carries what the SERVER knows, which is not always a word anyone should read: a
|
|
213
213
|
* role id (`admin`), an action verb (`approve_content`). The sentence needs whatever the app's
|
|
214
|
-
* own screens call those things, and the substitution happens here
|
|
215
|
-
* reads `params
|
|
216
|
-
*
|
|
217
|
-
*
|
|
214
|
+
* own screens call those things, and the substitution happens here, inside the one lookup that
|
|
215
|
+
* reads `params`. There is nowhere else an adopter could intervene. Without this seam the choice
|
|
216
|
+
* is to ship the raw id into `{{role}}`, or to stop using the server's sentence at all and
|
|
217
|
+
* re-resolve every key by hand, which is how i18n ended up inside a transport once already.
|
|
218
218
|
*
|
|
219
219
|
* Optional, and identity by default: an API whose params are already words passes nothing. It
|
|
220
|
-
* deliberately takes only the params
|
|
220
|
+
* deliberately takes only the params. An arm that needs the error has `ctx` for that.
|
|
221
221
|
*/
|
|
222
222
|
localizeParams?: (params: Record<string, string | number> | undefined) => Record<string, unknown> | undefined;
|
|
223
223
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"describe-error.d.ts","sourceRoot":"","sources":["../src/describe-error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,MAAM,YAAY;AACtB,mDAAmD;AACjD,OAAO;AACT,gEAAgE;GAC9D,QAAQ;AACV,gFAAgF;GAC9E,MAAM;AACR,iFAAiF;GAC/E,MAAM,CAAC;AAEX,+FAA+F;AAC/F,MAAM,WAAW,SAAS;IACxB,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,
|
|
1
|
+
{"version":3,"file":"describe-error.d.ts","sourceRoot":"","sources":["../src/describe-error.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG1C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH;;;;;;;;;;GAUG;AACH,MAAM,MAAM,YAAY;AACtB,mDAAmD;AACjD,OAAO;AACT,gEAAgE;GAC9D,QAAQ;AACV,gFAAgF;GAC9E,MAAM;AACR,iFAAiF;GAC/E,MAAM,CAAC;AAEX,+FAA+F;AAC/F,MAAM,WAAW,SAAS;IACxB,4CAA4C;IAC5C,KAAK,EAAE,MAAM,CAAC;IACd,+EAA+E;IAC/E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,iGAAiG;IACjG,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,iFAAiF;IACjF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,mFAAmF;IACnF,OAAO,EAAE,YAAY,CAAC;CACvB;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,SAAS,CAAC,GAAG,SAAS,MAAM,GAAG,MAAM,IA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C3B,UAAU,SAAS,MAAM,EAEzB,OAAO,EAAE,qBAAqB,CAAC,MAAM,EAAE,YAAY,EAAE,UAAU,CAAC,GAC/D,CAAC,KAAK,EAAE,OAAO,KAAK,cAAc,CAAC"}
|
package/dist/describe-error.js
CHANGED
|
@@ -3,17 +3,17 @@ import { ApiError } from "./api-error.js";
|
|
|
3
3
|
import { shouldRetry } from "./query.js";
|
|
4
4
|
const PLURAL_SUFFIX = /_(zero|one|two|few|many|other)$/;
|
|
5
5
|
/**
|
|
6
|
-
* "in 4 minutes"
|
|
6
|
+
* Format a wait as "in 4 minutes" or "in 2 hours", without making the reader convert seconds.
|
|
7
7
|
*
|
|
8
8
|
* The thresholds are deliberately not round: 90 seconds rather than 60, so "in 75 seconds" does
|
|
9
9
|
* not become the less precise "in 1 minute", and 90 minutes rather than 60 for the same reason
|
|
10
10
|
* one rung up. Needs `waitSeconds` / `waitMinutes` / `waitHours` under `prefix`, each with a
|
|
11
11
|
* `count` plural.
|
|
12
12
|
*
|
|
13
|
-
* This is what you pass as `formatWait` when your catalog carries those three:
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
13
|
+
* This is what you pass as `formatWait` when your catalog carries those three: `formatWait: (secs)
|
|
14
|
+
* => humanizeWait(t, secs, "errors.")`. An app that formats a wait with `Intl.RelativeTimeFormat`
|
|
15
|
+
* passes its own one-liner instead and needs no wait keys at all. It also gets correct plurals in
|
|
16
|
+
* languages with more than two forms, for free.
|
|
17
17
|
*/
|
|
18
18
|
export function humanizeWait(t, secs, prefix) {
|
|
19
19
|
// Up, never to the nearest: a wait is a floor, and "in 2 hours" for 2h24 sends the reader back
|