@tristan2828/ui-foundation 4.27.0 → 4.29.0
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/conventions/AGENTS.md +3 -1
- package/conventions/docs/add-an-entity.md +29 -0
- package/conventions/docs/cell-patterns.md +5 -1
- package/conventions/docs/design-language.md +44 -0
- package/conventions/docs/timed-screens.md +114 -8
- package/dist/components/app/app-shell.d.ts +10 -1
- package/dist/components/app/app-shell.js +2 -2
- package/dist/components/app/foundation-providers.js +5 -1
- package/dist/components/app/icon-component.d.ts +12 -0
- package/dist/components/app/icon-component.js +1 -0
- package/dist/components/app/image-field.d.ts +37 -0
- package/dist/components/app/image-field.js +103 -0
- package/dist/components/app/markdown.js +1 -1
- package/dist/components/app/milkdown-editor.d.ts +1 -1
- package/dist/components/app/milkdown-editor.js +84 -5
- package/dist/components/app/rich-text-editor.d.ts +16 -0
- package/dist/components/app/rich-text-editor.js +5 -0
- package/dist/components/app/rich-text-image-upload.d.ts +42 -0
- package/dist/components/app/rich-text-image-upload.js +174 -0
- package/dist/components/app/rich-text-toolbar.d.ts +6 -2
- package/dist/components/app/rich-text-toolbar.js +36 -28
- package/dist/components/app/widget-card.d.ts +7 -3
- package/dist/error-reporting/error-reporting-provider.js +7 -1
- package/dist/error-reporting/reporter.d.ts +20 -1
- package/dist/error-reporting/reporter.js +60 -6
- package/dist/hooks/use-session-clock.d.ts +19 -4
- package/dist/hooks/use-session-clock.js +35 -6
- package/dist/index.d.ts +4 -1
- package/dist/index.js +3 -1
- package/dist/lib/audio-cues.d.ts +28 -6
- package/dist/lib/audio-cues.js +57 -8
- package/dist/lib/image-file.d.ts +37 -0
- package/dist/lib/image-file.js +82 -0
- package/dist/lib/markdown-merge.js +1 -1
- package/dist/lib/stale-chunk-reload.d.ts +14 -0
- package/dist/lib/stale-chunk-reload.js +64 -0
- package/package.json +1 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// After a deploy, a tab opened on the build before it still runs that
|
|
2
|
+
// build, and its content-hashed chunks are gone from the server: the next
|
|
3
|
+
// lazy import (the rich-text editor's, say) fails with "Failed to fetch
|
|
4
|
+
// dynamically imported module" (#206). Vite's preload helper announces it
|
|
5
|
+
// first as a cancelable `vite:preloadError` on `window`, for the package's
|
|
6
|
+
// own lazy chunks too once the app's build bundles them. On it, the page
|
|
7
|
+
// reloads once onto the new build, and the failure is not reported.
|
|
8
|
+
//
|
|
9
|
+
// Once, because a file missing from the new build too would reload
|
|
10
|
+
// forever: the reload is remembered in sessionStorage, and a second
|
|
11
|
+
// failure within `windowMs` of it is let through to the error boundary
|
|
12
|
+
// (and reported, since that one is a real missing file). Where nothing
|
|
13
|
+
// can be remembered, nothing reloads.
|
|
14
|
+
//
|
|
15
|
+
// createStaleChunkReload takes its storage, reload and clock, so the rules
|
|
16
|
+
// are unit tested in node (tests/stale-chunk-reload.test.ts);
|
|
17
|
+
// FoundationProviders installs the shared instance over the real ones.
|
|
18
|
+
const KEY = 'ui-foundation:stale-chunk-reload';
|
|
19
|
+
const WINDOW_MS = 60_000;
|
|
20
|
+
export function createStaleChunkReload({ storage, reload, now = Date.now, windowMs = WINDOW_MS, }) {
|
|
21
|
+
let reloading = false;
|
|
22
|
+
const remember = () => {
|
|
23
|
+
try {
|
|
24
|
+
const store = storage();
|
|
25
|
+
if (!store)
|
|
26
|
+
return false;
|
|
27
|
+
const last = Number(store.getItem(KEY));
|
|
28
|
+
if (Number.isFinite(last) && last > 0 && now() - last < windowMs)
|
|
29
|
+
return false;
|
|
30
|
+
store.setItem(KEY, String(now()));
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const onPreloadError = (event) => {
|
|
38
|
+
if (reloading) {
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (!remember())
|
|
43
|
+
return;
|
|
44
|
+
reloading = true;
|
|
45
|
+
event.preventDefault();
|
|
46
|
+
reload();
|
|
47
|
+
};
|
|
48
|
+
return {
|
|
49
|
+
isReloading: () => reloading,
|
|
50
|
+
install(target) {
|
|
51
|
+
target.addEventListener('vite:preloadError', onPreloadError);
|
|
52
|
+
return () => target.removeEventListener('vite:preloadError', onPreloadError);
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
let shared = null;
|
|
57
|
+
/** The one instance over the real window, sessionStorage and reload. */
|
|
58
|
+
export function browserStaleChunkReload() {
|
|
59
|
+
shared ??= createStaleChunkReload({
|
|
60
|
+
storage: () => (typeof sessionStorage === 'undefined' ? undefined : sessionStorage),
|
|
61
|
+
reload: () => window.location.reload(),
|
|
62
|
+
});
|
|
63
|
+
return shared;
|
|
64
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tristan2828/ui-foundation",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.29.0",
|
|
4
4
|
"description": "Shared UI foundation for contract-first, database-backed React apps: shadcn primitives, DataTable/EntityForm composites, auth, the gateway error seam, design tokens, lint rules and the AI playbook.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|