@wow-two-beta/fe 0.0.33 → 0.0.35

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.
Files changed (45) hide show
  1. package/dist/chunks/{BackToTopButton.vue_vue_type_script_setup_true_lang-dmN5MH2T.js → BackToTopButton.vue_vue_type_script_setup_true_lang-DHSpEajG.js} +74 -31
  2. package/dist/chunks/BackToTopButton.vue_vue_type_script_setup_true_lang-DHSpEajG.js.map +1 -0
  3. package/dist/chunks/{KanbanCard.vue_vue_type_script_setup_true_lang-BrQFyOiU.js → KanbanCard.vue_vue_type_script_setup_true_lang-akNFA0JK.js} +545 -312
  4. package/dist/chunks/KanbanCard.vue_vue_type_script_setup_true_lang-akNFA0JK.js.map +1 -0
  5. package/dist/chunks/{UseTypedConfirmation-CvY2T4Up.js → RowsField.vue_vue_type_script_setup_true_lang-C0L-DjCW.js} +967 -840
  6. package/dist/chunks/RowsField.vue_vue_type_script_setup_true_lang-C0L-DjCW.js.map +1 -0
  7. package/dist/chunks/{TypedConfirmModal.vue_vue_type_script_setup_true_lang-CoIaH_xx.js → TypedConfirmModal.vue_vue_type_script_setup_true_lang-3Sdgh0cV.js} +26 -13
  8. package/dist/chunks/{TypedConfirmModal.vue_vue_type_script_setup_true_lang-CoIaH_xx.js.map → TypedConfirmModal.vue_vue_type_script_setup_true_lang-3Sdgh0cV.js.map} +1 -1
  9. package/dist/foundation/device/hooks/UseBreakpointRange.d.ts +21 -0
  10. package/dist/foundation/device/index.d.ts +1 -0
  11. package/dist/foundation/device/index.js +13 -0
  12. package/dist/foundation/device/index.js.map +1 -1
  13. package/dist/foundation/storage/PersistentRef.d.ts +25 -0
  14. package/dist/foundation/storage/index.d.ts +1 -0
  15. package/dist/foundation/storage/index.js +46 -1
  16. package/dist/foundation/storage/index.js.map +1 -1
  17. package/dist/index.js +232 -228
  18. package/dist/presentation/actions/index.d.ts +1 -0
  19. package/dist/presentation/actions/index.js +12 -11
  20. package/dist/presentation/actions/refreshButton/RefreshButton.vue.d.ts +26 -0
  21. package/dist/presentation/actions/refreshButton/index.d.ts +1 -0
  22. package/dist/presentation/display/badge/Badge.variants.d.ts +77 -10
  23. package/dist/presentation/display/badge/Badge.vue.d.ts +18 -1
  24. package/dist/presentation/display/badge/index.d.ts +1 -1
  25. package/dist/presentation/display/card/CardLink.vue.d.ts +19 -0
  26. package/dist/presentation/display/card/index.d.ts +1 -0
  27. package/dist/presentation/display/index.js +152 -150
  28. package/dist/presentation/display/listGroup/ListGroupItem.vue.d.ts +17 -0
  29. package/dist/presentation/display/sparkline/Sparkline.vue.d.ts +32 -2
  30. package/dist/presentation/display/sparkline/index.d.ts +1 -1
  31. package/dist/presentation/feedback/dataRegion/DataRegion.vue.d.ts +1 -1
  32. package/dist/presentation/forms/index.d.ts +1 -0
  33. package/dist/presentation/forms/index.js +59 -58
  34. package/dist/presentation/forms/rowsField/RowsField.vue.d.ts +56 -0
  35. package/dist/presentation/forms/rowsField/index.d.ts +1 -0
  36. package/dist/presentation/overlays/index.js +1 -1
  37. package/dist/presentation/overlays/typedConfirmModal/TypedConfirmModal.vue.d.ts +20 -4
  38. package/dist/router/adapters/vueRouter/hooks/UseListDetailRoute.d.ts +28 -0
  39. package/dist/router/adapters/vueRouter/index.d.ts +1 -0
  40. package/dist/router/index.js +34 -0
  41. package/dist/router/index.js.map +1 -1
  42. package/package.json +1 -1
  43. package/dist/chunks/BackToTopButton.vue_vue_type_script_setup_true_lang-dmN5MH2T.js.map +0 -1
  44. package/dist/chunks/KanbanCard.vue_vue_type_script_setup_true_lang-BrQFyOiU.js.map +0 -1
  45. package/dist/chunks/UseTypedConfirmation-CvY2T4Up.js.map +0 -1
@@ -0,0 +1,21 @@
1
+ import { ComputedRef, MaybeRefOrGetter, ShallowRef } from 'vue';
2
+ import { BreakpointScale } from '../Breakpoints';
3
+ /**
4
+ * Reports whether the viewport is at least the `key` breakpoint of the caller's scale — `md` and wider for `'md'`.
5
+ * One media query, so a layout that only asks "desktop or not" never tracks the whole scale.
6
+ *
7
+ * SSR-safe: `false` on the server and until mounted, the mobile-first base.
8
+ * ```ts
9
+ * const isDesktop = useBreakpointUp(TailwindBreakpoints, 'lg');
10
+ * ```
11
+ */
12
+ export declare function useBreakpointUp<TScale extends BreakpointScale>(scale: MaybeRefOrGetter<TScale>, key: MaybeRefOrGetter<Extract<keyof TScale, string>>): Readonly<ShallowRef<boolean>>;
13
+ /**
14
+ * Reports whether the viewport is narrower than the `key` breakpoint of the caller's scale — a phone below `'md'`.
15
+ *
16
+ * SSR-safe: `true` on the server and until mounted, the mobile-first base.
17
+ * ```ts
18
+ * const isPhone = useBreakpointBelow(TailwindBreakpoints, 'md');
19
+ * ```
20
+ */
21
+ export declare function useBreakpointBelow<TScale extends BreakpointScale>(scale: MaybeRefOrGetter<TScale>, key: MaybeRefOrGetter<Extract<keyof TScale, string>>): ComputedRef<boolean>;
@@ -6,5 +6,6 @@ export { useDisplayMode, useIsInstalled } from './hooks/UseDisplayMode';
6
6
  export { Platform, getPlatform } from './Platform';
7
7
  export { type BreakpointScale, type BreakpointQuery, TailwindBreakpoints, toBreakpointQueries, resolveBreakpoint, } from './Breakpoints';
8
8
  export { useBreakpoint } from './hooks/UseBreakpoint';
9
+ export { useBreakpointUp, useBreakpointBelow } from './hooks/UseBreakpointRange';
9
10
  export { useMediaQuery } from './hooks/UseMediaQuery';
10
11
  export * from './hooks/UseReducedMotion';
@@ -149,6 +149,17 @@ function useBreakpoint(scale) {
149
149
  });
150
150
  return computed(() => active.value);
151
151
  }
152
+ function atLeastQuery(scale, key) {
153
+ const width = scale[key];
154
+ return typeof width === "number" && Number.isFinite(width) && width >= 0 ? `(min-width: ${width}px)` : "not all";
155
+ }
156
+ function useBreakpointUp(scale, key) {
157
+ return useMediaQuery(() => atLeastQuery(toValue(scale), toValue(key)));
158
+ }
159
+ function useBreakpointBelow(scale, key) {
160
+ const atLeast = useBreakpointUp(scale, key);
161
+ return computed(() => !atLeast.value);
162
+ }
152
163
  export {
153
164
  DisplayMode,
154
165
  Platform,
@@ -158,6 +169,8 @@ export {
158
169
  resolveBreakpoint,
159
170
  toBreakpointQueries,
160
171
  useBreakpoint,
172
+ useBreakpointBelow,
173
+ useBreakpointUp,
161
174
  useDisplayMode,
162
175
  useHoverCapability,
163
176
  useIsInstalled,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/foundation/device/enums/PointerType.ts","../../../src/foundation/device/hooks/UsePointer.ts","../../../src/foundation/device/hooks/UseOnlineStatus.ts","../../../src/foundation/device/enums/DisplayMode.ts","../../../src/foundation/device/hooks/UseDisplayMode.ts","../../../src/foundation/device/Platform.ts","../../../src/foundation/device/hooks/UseBreakpoint.ts"],"sourcesContent":["// The pointer vocabulary, kept in its own file rather than inlined into the composable so a consumer can switch\n// on `PointerType.Coarse` without pulling Vue into a pure module — the same value/composable split\n// `foundation/shortcuts` uses for `Modifier` vs `UseHotkeys`.\n\n/** How precise the primary pointing device is, per the CSS `pointer` media feature. */\nexport const PointerType = {\n /** Low-precision primary pointer — a finger on a touchscreen, a TV remote. Size hit targets generously. */\n Coarse: 'coarse',\n /** High-precision primary pointer — a mouse, trackpad, or stylus. Hover affordances are meaningful here. */\n Fine: 'fine',\n /** No pointing device at all — keyboard- or voice-driven. Also the SSR answer, where nothing is knowable yet. */\n None: 'none',\n} as const;\n\n/** One of the {@link PointerType} values. */\nexport type PointerType = (typeof PointerType)[keyof typeof PointerType];\n","// Pointer precision and hover capability, read from the CSS `pointer` / `hover` media features through the shared\n// `useMediaQuery`.\n//\n// WHY NOT A USER-AGENT SNIFF: \"is this a touch device\" is not a device question, it is an INPUT question, and the\n// two diverge constantly. A Windows laptop with a touchscreen has both a fine mouse and a coarse finger; an iPad\n// with a Magic Keyboard reports a FINE pointer; a phone in desktop-site mode still has only a finger. A UA string\n// describes none of that, is trivially spoofed, and is frozen or deprecated on every Chromium browser. The media\n// features track the pointer the user is ACTUALLY holding and re-evaluate when it changes.\n//\n// WHY NOT `'ontouchstart' in window` AS THE PRIMARY SIGNAL: it proves the touch EVENT API is implemented, not that\n// a touchscreen is attached — every desktop Chromium build ships the API, so the check reads true on a mouse-only\n// machine and the UI grows finger-sized hit targets nobody needs. It is also a one-shot boolean with no change\n// event, so it can never react to a tablet being docked to a keyboard mid-session. `(pointer: coarse)` answers the\n// question that was actually being asked, and answers it reactively.\n\nimport { computed, type ComputedRef } from 'vue';\n\nimport { useMediaQuery } from './UseMediaQuery';\n\nimport { PointerType } from '../enums/PointerType';\n\n// `pointer` / `hover` describe the PRIMARY pointing device. The `any-pointer` / `any-hover` variants report every\n// attached device instead, which is the wrong question for layout: a touchscreen laptop matches `any-pointer:\n// coarse` while the user drives it entirely by mouse, and sizing every target for the finger they are not using\n// wastes the screen. Primary is what layout should follow.\nconst FinePointerQuery = '(pointer: fine)';\nconst CoarsePointerQuery = '(pointer: coarse)';\nconst HoverQuery = '(hover: hover)';\n\n/**\n * Reports the precision of the primary pointing device — `'fine'` (mouse, trackpad, stylus), `'coarse'` (finger),\n * or `'none'`.\n *\n * Reactive: a tablet gaining a mouse flips `'coarse'` → `'fine'` without a reload.\n *\n * Under SSR this reads `'none'` (there are no media features to read) and corrects on hydration. Treat `'none'`\n * as \"no pointer known\", not as a fact — never hide an essential affordance behind it.\n *\n * @returns The active {@link PointerType}.\n */\nexport function usePointerType(): ComputedRef<PointerType> {\n const fine = useMediaQuery(FinePointerQuery);\n const coarse = useMediaQuery(CoarsePointerQuery);\n\n // `pointer` names one primary device, so at most one of these matches in practice. `fine` is tested first so\n // that a browser reporting both resolves to the more capable pointer rather than to a coincidence of ordering.\n return computed(() => {\n if (fine.value) return PointerType.Fine;\n if (coarse.value) return PointerType.Coarse;\n return PointerType.None;\n });\n}\n\n/**\n * Whether the primary pointing device can hover — the `(hover: hover)` media feature.\n *\n * Gate hover-only affordances on this: a tooltip that opens on mouseover, a table row's hover-revealed actions. On\n * a touchscreen a hover-only control is simply unreachable and needs a tap target or an always-visible equivalent.\n *\n * Reads `false` under SSR, so hover-revealed content must never be the only path to an action.\n *\n * @returns `true` when the primary pointer can hover.\n */\nexport function useHoverCapability(): ComputedRef<boolean> {\n const hover = useMediaQuery(HoverQuery);\n return computed(() => hover.value);\n}\n","// Network reachability — or as much of it as the browser is willing to admit to.\n//\n// WHAT `navigator.onLine` ACTUALLY MEANS: it is `false` only when the browser is certain there is NO network link\n// — airplane mode, Wi-Fi off, cable unplugged. It is `true` the moment a link exists and says NOTHING beyond that.\n// A captive portal nobody has logged into, hotel Wi-Fi that has not been paid for, a dropped VPN, a DNS failure,\n// or an API that is simply down all report `true`. So `false` is trustworthy and `true` is a hint.\n//\n// USE ACCORDINGLY: explain a failure that already happened (\"you appear to be offline\"), defer a retry, pause a\n// poll. Never treat `true` as a precondition — \"we are online, so this request will succeed\" is exactly the\n// inference this value cannot support. Proving the server that matters is reachable takes a request to it, which\n// is `foundation/http`'s job and not this slice's.\n//\n// The `online` / `offline` events bind through `foundation/dom`' `useEventListener` rather than a hand-rolled\n// `addEventListener`, so handler identity, attach options, and teardown follow the same rules as every other\n// listener in the library. The target is a GETTER, not a module constant: resolving `window` at module scope\n// would evaluate during a server render, and the lazy getter is the same shape `useEventListener` uses for its\n// own default.\n\nimport { onMounted, shallowRef, type ShallowRef } from 'vue';\n\nimport { useEventListener } from '../../dom';\n\n/** Resolved lazily so importing this module in an SSR pass never touches `window`. */\nconst globalTarget = (): Window | null => (typeof window === 'undefined' ? null : window);\n\n/**\n * Reads `navigator.onLine`, defaulting to online when there is no `navigator` (SSR), when the property is missing\n * (a partial polyfill), or when the read throws. Optimistic by design — see the note on the composable.\n */\nfunction readOnlineStatus(): boolean {\n try {\n if (typeof navigator === 'undefined') return true;\n return navigator.onLine !== false;\n } catch {\n return true;\n }\n}\n\n/**\n * Tracks whether the browser believes it has a network link — seeded optimistically, synced from\n * `navigator.onLine` on mount, then kept current by the window `online` / `offline` events.\n *\n * Reads `true` under SSR and whenever the status cannot be read: an offline banner rendered by a server that has\n * never met the client is worse than a missing one, and the value corrects on mount either way. Read this file's\n * header before acting on it — `false` is reliable, `true` only means a link exists.\n *\n * @returns `true` while the browser reports a network link.\n */\nexport function useOnlineStatus(): Readonly<ShallowRef<boolean>> {\n // Seeded `true` rather than read at setup: `readOnlineStatus` answers `true` under SSR anyway, and seeding a\n // constant keeps `navigator` out of the setup pass entirely.\n const online = shallowRef(true);\n\n // Re-read once on mount. Two gaps the events alone can never close: the seed was unconditional, and the link\n // can flip between setup and the listeners attaching.\n onMounted(() => {\n online.value = readOnlineStatus();\n });\n\n useEventListener(\n 'online',\n () => {\n online.value = true;\n },\n globalTarget,\n );\n useEventListener(\n 'offline',\n () => {\n online.value = false;\n },\n globalTarget,\n );\n\n return online;\n}\n","// The display-mode vocabulary. Split from its composable for the same reason as `PointerType` — a consumer\n// comparing against `DisplayMode.Standalone` should not have to import Vue to do it.\n\n/** How the document is being presented — the values of the CSS `display-mode` media feature. */\nexport const DisplayMode = {\n /** Installed and running in its own window with no browser chrome. The usual \"is this a PWA\" answer. */\n Standalone: 'standalone',\n /** Filling the screen with no OS chrome either — kiosk displays, the Fullscreen API. */\n Fullscreen: 'fullscreen',\n /** Own window with a minimal navigation strip (back / reload). Installed, but not chrome-free. */\n MinimalUi: 'minimal-ui',\n /** An ordinary browser tab. Also the SSR answer. */\n Browser: 'browser',\n} as const;\n\n/** One of the {@link DisplayMode} values. */\nexport type DisplayMode = (typeof DisplayMode)[keyof typeof DisplayMode];\n","// Display mode — how the document is presented, and by extension whether the app was installed.\n//\n// Read entirely through `display-mode` media queries on the shared `useMediaQuery`, which makes the answer\n// reactive: a window entering or leaving fullscreen updates live, where the one-shot check at startup that most\n// codebases write would be stale for the rest of the session.\n//\n// QUERY ORDER IS LOAD-BEARING, and is not alphabetical. Browsers do not reliably report exactly one match — a\n// standalone window driven into fullscreen can satisfy both `(display-mode: fullscreen)` and\n// `(display-mode: standalone)` — so the most specific presentation is tested first and wins.\n//\n// KNOWN GAP — iOS Safari only supports `display-mode` from 16.4. On older iOS an installed home-screen app reports\n// `'browser'` here. Its legacy signal is the non-standard `navigator.standalone`, deliberately NOT read: this\n// slice keeps a single detection mechanism, and adding a second, non-reactive sniffer for one stale OS version\n// buys a narrow tail at the cost of two code paths that can disagree. A consumer that needs that tail can read\n// `navigator.standalone` itself and OR it in.\n\nimport { computed, type ComputedRef } from 'vue';\n\nimport { useMediaQuery } from './UseMediaQuery';\n\nimport { DisplayMode } from '../enums/DisplayMode';\n\nconst FullscreenQuery = '(display-mode: fullscreen)';\nconst StandaloneQuery = '(display-mode: standalone)';\nconst MinimalUiQuery = '(display-mode: minimal-ui)';\n\n/**\n * Reports how the document is being presented — its {@link DisplayMode}.\n *\n * Falls back to `'browser'` when no mode query matches, which is also what SSR and any browser without\n * `display-mode` support produce. `'browser'` therefore means \"an ordinary tab, as far as can be told\", not a\n * proof that the app is uninstalled.\n *\n * @returns The active {@link DisplayMode}.\n */\nexport function useDisplayMode(): ComputedRef<DisplayMode> {\n const fullscreen = useMediaQuery(FullscreenQuery);\n const standalone = useMediaQuery(StandaloneQuery);\n const minimalUi = useMediaQuery(MinimalUiQuery);\n\n return computed(() => {\n if (fullscreen.value) return DisplayMode.Fullscreen;\n if (standalone.value) return DisplayMode.Standalone;\n if (minimalUi.value) return DisplayMode.MinimalUi;\n return DisplayMode.Browser;\n });\n}\n\n/**\n * Whether the app is running as an installed app rather than in a browser tab — any display mode other than\n * `'browser'`.\n *\n * Reads `false` under SSR and on iOS < 16.4 (see this file's header). Use it to ADD an installed-only affordance\n * — suppressing an \"Install app\" prompt, showing a custom title bar — never to withhold functionality, because a\n * `false` here can mean \"installed, but undetectable\".\n *\n * @returns `true` when the app is presented outside an ordinary browser tab.\n */\nexport function useIsInstalled(): ComputedRef<boolean> {\n const mode = useDisplayMode();\n return computed(() => mode.value !== DisplayMode.Browser);\n}\n","// Platform identification — the LAST-RESORT signal in this slice, and the only one here that asks what the\n// environment IS rather than what it can DO.\n//\n// USE IT ONLY FOR COSMETICS: rendering `⌘K` vs `Ctrl+K` in a shortcut hint, naming a modifier in help text,\n// labelling a button \"Show in Finder\" vs \"Show in Explorer\". NEVER gate a feature on it. A user agent is freely\n// spoofed, `navigator.platform` is deprecated, Chromium freezes its UA, and every question worth gating on\n// (pointer precision, hover, display mode, viewport) has a real capability query in this slice that answers it\n// truthfully. Platform sniffing gates on a guess; a media feature gates on the fact.\n//\n// The Apple branch delegates to `foundation/shortcuts`' `isApplePlatform` rather than re-sniffing: that predicate\n// already backs `mod` → ⌘ resolution, and two sniffers that drift apart would render a ⌘ hint on a Ctrl machine.\n// This file adds the other three families around it and reuses its exact source-precedence rules.\n//\n// Ordering is load-bearing. Android is tested before Linux because Android's UA names the Linux kernel; the\n// Windows pattern is anchored on real tokens (`Windows` / `Win32` / `Win64` / `WOW64`) rather than a bare `win`,\n// which would misread `Darwin` — a substring collision that silently turns a Mac into a PC.\n\nimport { isApplePlatform } from '../shortcuts';\n\n/** The coarse OS families this slice distinguishes. */\nexport const Platform = {\n /** macOS, iOS, or iPadOS. */\n Apple: 'apple',\n /** Any Windows desktop. */\n Windows: 'windows',\n /** Android phones and tablets. */\n Android: 'android',\n /** Desktop Linux, X11, and ChromeOS — all Ctrl-keyed, all Linux-idiomatic in their affordances. */\n Linux: 'linux',\n /** Nothing recognisable — SSR, a stripped user agent, or a platform outside the four above. */\n Unknown: 'unknown',\n} as const;\n\n/** One of the {@link Platform} families. */\nexport type Platform = (typeof Platform)[keyof typeof Platform];\n\n/**\n * Reads the best available platform string, preferring the modern `userAgentData.platform` over the deprecated\n * `navigator.platform` and falling back to the full user agent. Mirrors `isApplePlatform`'s precedence exactly so\n * both predicates always judge the same text. Returns `''` under SSR or if any read throws.\n */\nfunction readPlatformSource(): string {\n try {\n if (typeof navigator === 'undefined') return '';\n const nav = navigator as Navigator & { userAgentData?: { platform?: string } };\n return nav.userAgentData?.platform || nav.platform || nav.userAgent || '';\n } catch {\n // A throwing `navigator` getter (polyfill, hardened environment) reads as \"no information\", never as a crash.\n return '';\n }\n}\n\n/**\n * Identifies the OS family. Read this file's header before using it: the answer is for cosmetic, platform-idiomatic\n * decisions only, never for feature gating.\n *\n * Never throws. Returns `'unknown'` under SSR, for an unrecognised platform, and for an empty hint.\n *\n * @param hint Forces the string that is matched, instead of reading the environment — makes tests deterministic and\n * lets a server render for a client whose platform it already knows. Accepts a full user agent, a\n * `userAgentData.platform` value, or a bare token such as `'Windows'`.\n * @returns The detected {@link Platform}.\n */\nexport function getPlatform(hint?: string): Platform {\n const source = hint ?? readPlatformSource();\n\n if (isApplePlatform(source)) return Platform.Apple;\n if (/android/i.test(source)) return Platform.Android;\n if (/windows|win32|win64|wow64/i.test(source)) return Platform.Windows;\n if (/linux|x11|cros|chrome ?os/i.test(source)) return Platform.Linux;\n return Platform.Unknown;\n}\n","import {\n computed,\n onMounted,\n onScopeDispose,\n shallowRef,\n toValue,\n watch,\n type ComputedRef,\n type MaybeRefOrGetter,\n} from 'vue';\nimport { subscribeMediaQuery } from './UseMediaQuery';\nimport { resolveBreakpoint, toBreakpointQueries, type BreakpointScale } from '../Breakpoints';\n\n/** Tracks every valid breakpoint in the caller's scale and releases replaced subscriptions. */\nexport function useBreakpoint<TScale extends BreakpointScale>(\n scale: MaybeRefOrGetter<TScale>,\n): ComputedRef<Extract<keyof TScale, string> | null> {\n const queries = computed(() => toBreakpointQueries(toValue(scale)));\n const active = shallowRef<Extract<keyof TScale, string> | null>(null);\n let mounted = false;\n let dispose: (() => void) | undefined;\n function subscribe(): void {\n dispose?.();\n dispose = undefined;\n if (!mounted) return;\n const current = queries.value;\n const matches: boolean[] = current.map(() => false);\n active.value = null;\n const disposers = current.map((entry, index) =>\n subscribeMediaQuery(entry.query, (value) => {\n matches[index] = value;\n active.value = resolveBreakpoint(current, matches);\n }),\n );\n dispose = () => {\n for (const unsubscribe of disposers) unsubscribe();\n };\n }\n onMounted(() => {\n mounted = true;\n subscribe();\n });\n watch(queries, subscribe);\n onScopeDispose(() => {\n mounted = false;\n dispose?.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AK;AAClD,WAAO,QAAQ;AACf,UAAM,YAAY,QAAQ;AAAA,MAAI,CAAC,OAAO,UACpC,oBAAoB,MAAM,OAAO,CAAC,UAAU;AAC1C,gBAAQ,KAAK,IAAI;AACjB,eAAO,QAAQ,kBAAkB,SAAS,OAAO;AAAA,MACnD,CAAC;AAAA,IAAA;AAEH,cAAU,MAAM;AACd,iBAAW,eAAe,UAAW,aAAA;AAAA,IACvC;AAAA,EACF;AACA,YAAU,MAAM;AACd,cAAU;AACV,cAAA;AAAA,EACF,CAAC;AACD,QAAM,SAAS,SAAS;AACxB,iBAAe,MAAM;AACnB,cAAU;AACV,cAAA;AAAA,EACF,CAAC;AACD,SAAO,SAAS,MAAM,OAAO,KAAK;AACpC;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/foundation/device/enums/PointerType.ts","../../../src/foundation/device/hooks/UsePointer.ts","../../../src/foundation/device/hooks/UseOnlineStatus.ts","../../../src/foundation/device/enums/DisplayMode.ts","../../../src/foundation/device/hooks/UseDisplayMode.ts","../../../src/foundation/device/Platform.ts","../../../src/foundation/device/hooks/UseBreakpoint.ts","../../../src/foundation/device/hooks/UseBreakpointRange.ts"],"sourcesContent":["// The pointer vocabulary, kept in its own file rather than inlined into the composable so a consumer can switch\n// on `PointerType.Coarse` without pulling Vue into a pure module — the same value/composable split\n// `foundation/shortcuts` uses for `Modifier` vs `UseHotkeys`.\n\n/** How precise the primary pointing device is, per the CSS `pointer` media feature. */\nexport const PointerType = {\n /** Low-precision primary pointer — a finger on a touchscreen, a TV remote. Size hit targets generously. */\n Coarse: 'coarse',\n /** High-precision primary pointer — a mouse, trackpad, or stylus. Hover affordances are meaningful here. */\n Fine: 'fine',\n /** No pointing device at all — keyboard- or voice-driven. Also the SSR answer, where nothing is knowable yet. */\n None: 'none',\n} as const;\n\n/** One of the {@link PointerType} values. */\nexport type PointerType = (typeof PointerType)[keyof typeof PointerType];\n","// Pointer precision and hover capability, read from the CSS `pointer` / `hover` media features through the shared\n// `useMediaQuery`.\n//\n// WHY NOT A USER-AGENT SNIFF: \"is this a touch device\" is not a device question, it is an INPUT question, and the\n// two diverge constantly. A Windows laptop with a touchscreen has both a fine mouse and a coarse finger; an iPad\n// with a Magic Keyboard reports a FINE pointer; a phone in desktop-site mode still has only a finger. A UA string\n// describes none of that, is trivially spoofed, and is frozen or deprecated on every Chromium browser. The media\n// features track the pointer the user is ACTUALLY holding and re-evaluate when it changes.\n//\n// WHY NOT `'ontouchstart' in window` AS THE PRIMARY SIGNAL: it proves the touch EVENT API is implemented, not that\n// a touchscreen is attached — every desktop Chromium build ships the API, so the check reads true on a mouse-only\n// machine and the UI grows finger-sized hit targets nobody needs. It is also a one-shot boolean with no change\n// event, so it can never react to a tablet being docked to a keyboard mid-session. `(pointer: coarse)` answers the\n// question that was actually being asked, and answers it reactively.\n\nimport { computed, type ComputedRef } from 'vue';\n\nimport { useMediaQuery } from './UseMediaQuery';\n\nimport { PointerType } from '../enums/PointerType';\n\n// `pointer` / `hover` describe the PRIMARY pointing device. The `any-pointer` / `any-hover` variants report every\n// attached device instead, which is the wrong question for layout: a touchscreen laptop matches `any-pointer:\n// coarse` while the user drives it entirely by mouse, and sizing every target for the finger they are not using\n// wastes the screen. Primary is what layout should follow.\nconst FinePointerQuery = '(pointer: fine)';\nconst CoarsePointerQuery = '(pointer: coarse)';\nconst HoverQuery = '(hover: hover)';\n\n/**\n * Reports the precision of the primary pointing device — `'fine'` (mouse, trackpad, stylus), `'coarse'` (finger),\n * or `'none'`.\n *\n * Reactive: a tablet gaining a mouse flips `'coarse'` → `'fine'` without a reload.\n *\n * Under SSR this reads `'none'` (there are no media features to read) and corrects on hydration. Treat `'none'`\n * as \"no pointer known\", not as a fact — never hide an essential affordance behind it.\n *\n * @returns The active {@link PointerType}.\n */\nexport function usePointerType(): ComputedRef<PointerType> {\n const fine = useMediaQuery(FinePointerQuery);\n const coarse = useMediaQuery(CoarsePointerQuery);\n\n // `pointer` names one primary device, so at most one of these matches in practice. `fine` is tested first so\n // that a browser reporting both resolves to the more capable pointer rather than to a coincidence of ordering.\n return computed(() => {\n if (fine.value) return PointerType.Fine;\n if (coarse.value) return PointerType.Coarse;\n return PointerType.None;\n });\n}\n\n/**\n * Whether the primary pointing device can hover — the `(hover: hover)` media feature.\n *\n * Gate hover-only affordances on this: a tooltip that opens on mouseover, a table row's hover-revealed actions. On\n * a touchscreen a hover-only control is simply unreachable and needs a tap target or an always-visible equivalent.\n *\n * Reads `false` under SSR, so hover-revealed content must never be the only path to an action.\n *\n * @returns `true` when the primary pointer can hover.\n */\nexport function useHoverCapability(): ComputedRef<boolean> {\n const hover = useMediaQuery(HoverQuery);\n return computed(() => hover.value);\n}\n","// Network reachability — or as much of it as the browser is willing to admit to.\n//\n// WHAT `navigator.onLine` ACTUALLY MEANS: it is `false` only when the browser is certain there is NO network link\n// — airplane mode, Wi-Fi off, cable unplugged. It is `true` the moment a link exists and says NOTHING beyond that.\n// A captive portal nobody has logged into, hotel Wi-Fi that has not been paid for, a dropped VPN, a DNS failure,\n// or an API that is simply down all report `true`. So `false` is trustworthy and `true` is a hint.\n//\n// USE ACCORDINGLY: explain a failure that already happened (\"you appear to be offline\"), defer a retry, pause a\n// poll. Never treat `true` as a precondition — \"we are online, so this request will succeed\" is exactly the\n// inference this value cannot support. Proving the server that matters is reachable takes a request to it, which\n// is `foundation/http`'s job and not this slice's.\n//\n// The `online` / `offline` events bind through `foundation/dom`' `useEventListener` rather than a hand-rolled\n// `addEventListener`, so handler identity, attach options, and teardown follow the same rules as every other\n// listener in the library. The target is a GETTER, not a module constant: resolving `window` at module scope\n// would evaluate during a server render, and the lazy getter is the same shape `useEventListener` uses for its\n// own default.\n\nimport { onMounted, shallowRef, type ShallowRef } from 'vue';\n\nimport { useEventListener } from '../../dom';\n\n/** Resolved lazily so importing this module in an SSR pass never touches `window`. */\nconst globalTarget = (): Window | null => (typeof window === 'undefined' ? null : window);\n\n/**\n * Reads `navigator.onLine`, defaulting to online when there is no `navigator` (SSR), when the property is missing\n * (a partial polyfill), or when the read throws. Optimistic by design — see the note on the composable.\n */\nfunction readOnlineStatus(): boolean {\n try {\n if (typeof navigator === 'undefined') return true;\n return navigator.onLine !== false;\n } catch {\n return true;\n }\n}\n\n/**\n * Tracks whether the browser believes it has a network link — seeded optimistically, synced from\n * `navigator.onLine` on mount, then kept current by the window `online` / `offline` events.\n *\n * Reads `true` under SSR and whenever the status cannot be read: an offline banner rendered by a server that has\n * never met the client is worse than a missing one, and the value corrects on mount either way. Read this file's\n * header before acting on it — `false` is reliable, `true` only means a link exists.\n *\n * @returns `true` while the browser reports a network link.\n */\nexport function useOnlineStatus(): Readonly<ShallowRef<boolean>> {\n // Seeded `true` rather than read at setup: `readOnlineStatus` answers `true` under SSR anyway, and seeding a\n // constant keeps `navigator` out of the setup pass entirely.\n const online = shallowRef(true);\n\n // Re-read once on mount. Two gaps the events alone can never close: the seed was unconditional, and the link\n // can flip between setup and the listeners attaching.\n onMounted(() => {\n online.value = readOnlineStatus();\n });\n\n useEventListener(\n 'online',\n () => {\n online.value = true;\n },\n globalTarget,\n );\n useEventListener(\n 'offline',\n () => {\n online.value = false;\n },\n globalTarget,\n );\n\n return online;\n}\n","// The display-mode vocabulary. Split from its composable for the same reason as `PointerType` — a consumer\n// comparing against `DisplayMode.Standalone` should not have to import Vue to do it.\n\n/** How the document is being presented — the values of the CSS `display-mode` media feature. */\nexport const DisplayMode = {\n /** Installed and running in its own window with no browser chrome. The usual \"is this a PWA\" answer. */\n Standalone: 'standalone',\n /** Filling the screen with no OS chrome either — kiosk displays, the Fullscreen API. */\n Fullscreen: 'fullscreen',\n /** Own window with a minimal navigation strip (back / reload). Installed, but not chrome-free. */\n MinimalUi: 'minimal-ui',\n /** An ordinary browser tab. Also the SSR answer. */\n Browser: 'browser',\n} as const;\n\n/** One of the {@link DisplayMode} values. */\nexport type DisplayMode = (typeof DisplayMode)[keyof typeof DisplayMode];\n","// Display mode — how the document is presented, and by extension whether the app was installed.\n//\n// Read entirely through `display-mode` media queries on the shared `useMediaQuery`, which makes the answer\n// reactive: a window entering or leaving fullscreen updates live, where the one-shot check at startup that most\n// codebases write would be stale for the rest of the session.\n//\n// QUERY ORDER IS LOAD-BEARING, and is not alphabetical. Browsers do not reliably report exactly one match — a\n// standalone window driven into fullscreen can satisfy both `(display-mode: fullscreen)` and\n// `(display-mode: standalone)` — so the most specific presentation is tested first and wins.\n//\n// KNOWN GAP — iOS Safari only supports `display-mode` from 16.4. On older iOS an installed home-screen app reports\n// `'browser'` here. Its legacy signal is the non-standard `navigator.standalone`, deliberately NOT read: this\n// slice keeps a single detection mechanism, and adding a second, non-reactive sniffer for one stale OS version\n// buys a narrow tail at the cost of two code paths that can disagree. A consumer that needs that tail can read\n// `navigator.standalone` itself and OR it in.\n\nimport { computed, type ComputedRef } from 'vue';\n\nimport { useMediaQuery } from './UseMediaQuery';\n\nimport { DisplayMode } from '../enums/DisplayMode';\n\nconst FullscreenQuery = '(display-mode: fullscreen)';\nconst StandaloneQuery = '(display-mode: standalone)';\nconst MinimalUiQuery = '(display-mode: minimal-ui)';\n\n/**\n * Reports how the document is being presented — its {@link DisplayMode}.\n *\n * Falls back to `'browser'` when no mode query matches, which is also what SSR and any browser without\n * `display-mode` support produce. `'browser'` therefore means \"an ordinary tab, as far as can be told\", not a\n * proof that the app is uninstalled.\n *\n * @returns The active {@link DisplayMode}.\n */\nexport function useDisplayMode(): ComputedRef<DisplayMode> {\n const fullscreen = useMediaQuery(FullscreenQuery);\n const standalone = useMediaQuery(StandaloneQuery);\n const minimalUi = useMediaQuery(MinimalUiQuery);\n\n return computed(() => {\n if (fullscreen.value) return DisplayMode.Fullscreen;\n if (standalone.value) return DisplayMode.Standalone;\n if (minimalUi.value) return DisplayMode.MinimalUi;\n return DisplayMode.Browser;\n });\n}\n\n/**\n * Whether the app is running as an installed app rather than in a browser tab — any display mode other than\n * `'browser'`.\n *\n * Reads `false` under SSR and on iOS < 16.4 (see this file's header). Use it to ADD an installed-only affordance\n * — suppressing an \"Install app\" prompt, showing a custom title bar — never to withhold functionality, because a\n * `false` here can mean \"installed, but undetectable\".\n *\n * @returns `true` when the app is presented outside an ordinary browser tab.\n */\nexport function useIsInstalled(): ComputedRef<boolean> {\n const mode = useDisplayMode();\n return computed(() => mode.value !== DisplayMode.Browser);\n}\n","// Platform identification — the LAST-RESORT signal in this slice, and the only one here that asks what the\n// environment IS rather than what it can DO.\n//\n// USE IT ONLY FOR COSMETICS: rendering `⌘K` vs `Ctrl+K` in a shortcut hint, naming a modifier in help text,\n// labelling a button \"Show in Finder\" vs \"Show in Explorer\". NEVER gate a feature on it. A user agent is freely\n// spoofed, `navigator.platform` is deprecated, Chromium freezes its UA, and every question worth gating on\n// (pointer precision, hover, display mode, viewport) has a real capability query in this slice that answers it\n// truthfully. Platform sniffing gates on a guess; a media feature gates on the fact.\n//\n// The Apple branch delegates to `foundation/shortcuts`' `isApplePlatform` rather than re-sniffing: that predicate\n// already backs `mod` → ⌘ resolution, and two sniffers that drift apart would render a ⌘ hint on a Ctrl machine.\n// This file adds the other three families around it and reuses its exact source-precedence rules.\n//\n// Ordering is load-bearing. Android is tested before Linux because Android's UA names the Linux kernel; the\n// Windows pattern is anchored on real tokens (`Windows` / `Win32` / `Win64` / `WOW64`) rather than a bare `win`,\n// which would misread `Darwin` — a substring collision that silently turns a Mac into a PC.\n\nimport { isApplePlatform } from '../shortcuts';\n\n/** The coarse OS families this slice distinguishes. */\nexport const Platform = {\n /** macOS, iOS, or iPadOS. */\n Apple: 'apple',\n /** Any Windows desktop. */\n Windows: 'windows',\n /** Android phones and tablets. */\n Android: 'android',\n /** Desktop Linux, X11, and ChromeOS — all Ctrl-keyed, all Linux-idiomatic in their affordances. */\n Linux: 'linux',\n /** Nothing recognisable — SSR, a stripped user agent, or a platform outside the four above. */\n Unknown: 'unknown',\n} as const;\n\n/** One of the {@link Platform} families. */\nexport type Platform = (typeof Platform)[keyof typeof Platform];\n\n/**\n * Reads the best available platform string, preferring the modern `userAgentData.platform` over the deprecated\n * `navigator.platform` and falling back to the full user agent. Mirrors `isApplePlatform`'s precedence exactly so\n * both predicates always judge the same text. Returns `''` under SSR or if any read throws.\n */\nfunction readPlatformSource(): string {\n try {\n if (typeof navigator === 'undefined') return '';\n const nav = navigator as Navigator & { userAgentData?: { platform?: string } };\n return nav.userAgentData?.platform || nav.platform || nav.userAgent || '';\n } catch {\n // A throwing `navigator` getter (polyfill, hardened environment) reads as \"no information\", never as a crash.\n return '';\n }\n}\n\n/**\n * Identifies the OS family. Read this file's header before using it: the answer is for cosmetic, platform-idiomatic\n * decisions only, never for feature gating.\n *\n * Never throws. Returns `'unknown'` under SSR, for an unrecognised platform, and for an empty hint.\n *\n * @param hint Forces the string that is matched, instead of reading the environment — makes tests deterministic and\n * lets a server render for a client whose platform it already knows. Accepts a full user agent, a\n * `userAgentData.platform` value, or a bare token such as `'Windows'`.\n * @returns The detected {@link Platform}.\n */\nexport function getPlatform(hint?: string): Platform {\n const source = hint ?? readPlatformSource();\n\n if (isApplePlatform(source)) return Platform.Apple;\n if (/android/i.test(source)) return Platform.Android;\n if (/windows|win32|win64|wow64/i.test(source)) return Platform.Windows;\n if (/linux|x11|cros|chrome ?os/i.test(source)) return Platform.Linux;\n return Platform.Unknown;\n}\n","import {\n computed,\n onMounted,\n onScopeDispose,\n shallowRef,\n toValue,\n watch,\n type ComputedRef,\n type MaybeRefOrGetter,\n} from 'vue';\nimport { subscribeMediaQuery } from './UseMediaQuery';\nimport { resolveBreakpoint, toBreakpointQueries, type BreakpointScale } from '../Breakpoints';\n\n/** Tracks every valid breakpoint in the caller's scale and releases replaced subscriptions. */\nexport function useBreakpoint<TScale extends BreakpointScale>(\n scale: MaybeRefOrGetter<TScale>,\n): ComputedRef<Extract<keyof TScale, string> | null> {\n const queries = computed(() => toBreakpointQueries(toValue(scale)));\n const active = shallowRef<Extract<keyof TScale, string> | null>(null);\n let mounted = false;\n let dispose: (() => void) | undefined;\n function subscribe(): void {\n dispose?.();\n dispose = undefined;\n if (!mounted) return;\n const current = queries.value;\n const matches: boolean[] = current.map(() => false);\n active.value = null;\n const disposers = current.map((entry, index) =>\n subscribeMediaQuery(entry.query, (value) => {\n matches[index] = value;\n active.value = resolveBreakpoint(current, matches);\n }),\n );\n dispose = () => {\n for (const unsubscribe of disposers) unsubscribe();\n };\n }\n onMounted(() => {\n mounted = true;\n subscribe();\n });\n watch(queries, subscribe);\n onScopeDispose(() => {\n mounted = false;\n dispose?.();\n });\n return computed(() => active.value);\n}\n","import { computed, toValue, type ComputedRef, type MaybeRefOrGetter, type ShallowRef } from 'vue';\nimport { useMediaQuery } from './UseMediaQuery';\nimport type { BreakpointScale } from '../Breakpoints';\n\n/** The media query for \"at least `key`\", or one that never matches when the scale holds no valid width for it. */\nfunction atLeastQuery(scale: BreakpointScale, key: string): string {\n const width = scale[key];\n return typeof width === 'number' && Number.isFinite(width) && width >= 0 ? `(min-width: ${width}px)` : 'not all';\n}\n\n/**\n * Reports whether the viewport is at least the `key` breakpoint of the caller's scale — `md` and wider for `'md'`.\n * One media query, so a layout that only asks \"desktop or not\" never tracks the whole scale.\n *\n * SSR-safe: `false` on the server and until mounted, the mobile-first base.\n * ```ts\n * const isDesktop = useBreakpointUp(TailwindBreakpoints, 'lg');\n * ```\n */\nexport function useBreakpointUp<TScale extends BreakpointScale>(\n scale: MaybeRefOrGetter<TScale>,\n key: MaybeRefOrGetter<Extract<keyof TScale, string>>,\n): Readonly<ShallowRef<boolean>> {\n return useMediaQuery(() => atLeastQuery(toValue(scale), toValue(key)));\n}\n\n/**\n * Reports whether the viewport is narrower than the `key` breakpoint of the caller's scale — a phone below `'md'`.\n *\n * SSR-safe: `true` on the server and until mounted, the mobile-first base.\n * ```ts\n * const isPhone = useBreakpointBelow(TailwindBreakpoints, 'md');\n * ```\n */\nexport function useBreakpointBelow<TScale extends BreakpointScale>(\n scale: MaybeRefOrGetter<TScale>,\n key: MaybeRefOrGetter<Extract<keyof TScale, string>>,\n): ComputedRef<boolean> {\n const atLeast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Q,IAAI,MAAM,KAAK;AAClD,WAAO,QAAQ;AACf,UAAM,YAAY,QAAQ;AAAA,MAAI,CAAC,OAAO,UACpC,oBAAoB,MAAM,OAAO,CAAC,UAAU;AAC1C,gBAAQ,KAAK,IAAI;AACjB,eAAO,QAAQ,kBAAkB,SAAS,OAAO;AAAA,MACnD,CAAC;AAAA,IAAA;AAEH,cAAU,MAAM;AACd,iBAAW,eAAe,UAAW,aAAA;AAAA,IACvC;AAAA,EACF;AACA,YAAU,MAAM;AACd,cAAU;AACV,cAAA;AAAA,EACF,CAAC;AACD,QAAM,SAAS,SAAS;AACxB,iBAAe,MAAM;AACnB,cAAU;AACV,cAAA;AAAA,EACF,CAAC;AACD,SAAO,SAAS,MAAM,OAAO,KAAK;AACpC;AC3CA,SAAS,aAAa,OAAwB,KAAqB;AACjE,QAAM,QAAQ,MAAM,GAAG;AACvB,SAAO,OAAO,UAAU,YAAY,OAAO,SAAS,KAAK,KAAK,SAAS,IAAI,eAAe,KAAK,QAAQ;AACzG;AAWO,SAAS,gBACd,OACA,KAC+B;AAC/B,SAAO,cAAc,MAAM,aAAa,QAAQ,KAAK,GAAG,QAAQ,GAAG,CAAC,CAAC;AACvE;AAUO,SAAS,mBACd,OACA,KACsB;AACtB,QAAM,UAAU,gBAAgB,OAAO,GAAG;AAC1C,SAAO,SAAS,MAAM,CAAC,QAAQ,KAAK;AACtC;"}
@@ -0,0 +1,25 @@
1
+ import { Ref } from 'vue';
2
+ import { StorageBroker } from './StorageBroker';
3
+ /** Accepts a stored JSON value as `T`, or answers `undefined` for a shape it does not recognise. */
4
+ export type PersistentDecoder<T> = (stored: unknown) => T | undefined;
5
+ /** Tunes where a persistent ref stores and what it accepts back. */
6
+ export interface PersistentRefOptions<T> {
7
+ /** Validates a stored value before it is adopted; a rejection or a throw reads as `initial`. Defaults to trust. */
8
+ readonly decode?: PersistentDecoder<T>;
9
+ /** The persistence seam to read and write through; defaults to `localStorageStorageBroker`. */
10
+ readonly broker?: StorageBroker;
11
+ /** Whether another tab's write under the same key is adopted; defaults to true. Only `localStorage` reports one. */
12
+ readonly syncTabs?: boolean;
13
+ }
14
+ /**
15
+ * Creates a ref mirrored into a `StorageBroker` under `key`, meant to be created once and shared by every reader.
16
+ * It reads storage when created: a miss, a stored `null`, a value `decode` rejects or a throwing `decode` yields
17
+ * `initial`. Assigning a different value writes it through at once; reading never writes, and a failed write keeps the
18
+ * value for this visit. Backed by `localStorage`, it adopts a decoded write from another tab and returns to `initial`
19
+ * when another tab removes the key or clears storage.
20
+ *
21
+ * The ref is shallow: replace an array or object to persist it, never mutate it in place. Created inside an effect
22
+ * scope (a component's `setup`, an `effectScope`), its tab listener detaches with the scope; at module scope it lives
23
+ * as long as the page.
24
+ */
25
+ export declare function createPersistentRef<T>(key: string, initial: T, options?: PersistentRefOptions<T>): Ref<T>;
@@ -1,5 +1,6 @@
1
1
  export { type StorageBroker, localStorageStorageBroker, memoryStorageBroker } from './StorageBroker';
2
2
  export { namespacedBroker } from './NamespacedBroker';
3
+ export { type PersistentDecoder, type PersistentRefOptions, createPersistentRef } from './PersistentRef';
3
4
  export { type Migration, type MigrationMap, type VersionedStore, type VersionedStoreOptions, createVersionedStore, } from './VersionedStore';
4
5
  export * from './hooks/UseAutosave';
5
6
  export * from './hooks/UsePersistentState';
@@ -1,6 +1,6 @@
1
1
  import { l as localStorageStorageBroker } from "../../chunks/StorageBroker-BCd8Sov7.js";
2
2
  import { m } from "../../chunks/StorageBroker-BCd8Sov7.js";
3
- import { shallowRef, watch, toValue, onScopeDispose } from "vue";
3
+ import { customRef, getCurrentScope, onScopeDispose, shallowRef, watch, toValue } from "vue";
4
4
  import { p, u, a } from "../../chunks/UseRecentItems-BV7p4em6.js";
5
5
  const NamespaceSeparator = ":";
6
6
  function namespacedBroker(inner, namespace) {
@@ -17,6 +17,50 @@ function namespacedBroker(inner, namespace) {
17
17
  }
18
18
  };
19
19
  }
20
+ function createPersistentRef(key, initial, options = {}) {
21
+ const { decode, broker = localStorageStorageBroker, syncTabs = true } = options;
22
+ function readStored() {
23
+ const stored = broker.read(key);
24
+ if (stored === null) return initial;
25
+ if (decode === void 0) return stored;
26
+ try {
27
+ const decoded = decode(stored);
28
+ return decoded === void 0 ? initial : decoded;
29
+ } catch {
30
+ return initial;
31
+ }
32
+ }
33
+ let current = readStored();
34
+ let notify = () => void 0;
35
+ const value = customRef((track, trigger) => {
36
+ notify = trigger;
37
+ return {
38
+ get() {
39
+ track();
40
+ return current;
41
+ },
42
+ set(next) {
43
+ if (Object.is(next, current)) return;
44
+ current = next;
45
+ broker.write(key, next);
46
+ trigger();
47
+ }
48
+ };
49
+ });
50
+ if (syncTabs && broker === localStorageStorageBroker && typeof window !== "undefined") {
51
+ const onStorage = (event) => {
52
+ if (event.storageArea !== null && event.storageArea !== window.localStorage) return;
53
+ if (event.key !== null && event.key !== key) return;
54
+ const next = event.newValue === null ? initial : readStored();
55
+ if (Object.is(next, current)) return;
56
+ current = next;
57
+ notify();
58
+ };
59
+ window.addEventListener("storage", onStorage);
60
+ if (getCurrentScope()) onScopeDispose(() => window.removeEventListener("storage", onStorage));
61
+ }
62
+ return value;
63
+ }
20
64
  function isEnvelope(value) {
21
65
  return typeof value === "object" && value !== null && "v" in value && "data" in value && typeof value.v === "number";
22
66
  }
@@ -168,6 +212,7 @@ function useAutosave(value, save, options = {}) {
168
212
  return { status, error, lastSavedAt, flush, cancel };
169
213
  }
170
214
  export {
215
+ createPersistentRef,
171
216
  createVersionedStore,
172
217
  localStorageStorageBroker,
173
218
  m as memoryStorageBroker,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/foundation/storage/NamespacedBroker.ts","../../../src/foundation/storage/VersionedStore.ts","../../../src/foundation/storage/hooks/UseAutosave.ts"],"sourcesContent":["// A `StorageBroker` decorator that prefixes every key with a namespace. Wrapping a shared broker (one\n// `localStorage`) in a namespace keeps unrelated features — or two tenants in the same app — from colliding on\n// a bare key like `\"draft\"`, without any hook change: the persistence hooks still see a plain `StorageBroker`.\n// Composes with any broker (production, memory, or another namespace) since it only rewrites keys.\n\nimport type { StorageBroker } from './StorageBroker';\n\n/** The separator between a namespace and the caller's key. */\nconst NamespaceSeparator = ':';\n\n/**\n * Wraps `inner` so every key is transparently prefixed with `namespace` (joined by `:`). Reads, writes, and\n * removes all address the namespaced key, so two brokers with distinct namespaces over the same backing store\n * never observe each other's values. Delegates JSON handling and failure-tolerance to `inner` unchanged.\n */\nexport function namespacedBroker(inner: StorageBroker, namespace: string): StorageBroker {\n const scope = (key: string): string => `${namespace}${NamespaceSeparator}${key}`;\n\n return {\n read<T>(key: string): T | null {\n return inner.read<T>(scope(key));\n },\n\n write<T>(key: string, value: T): boolean {\n return inner.write(scope(key), value);\n },\n\n remove(key: string): boolean {\n return inner.remove(scope(key));\n },\n };\n}\n","// A versioned wrapper over a `StorageBroker`. Persisted client state outlives the code that wrote it: a user\n// carries last month's `localStorage` into today's deploy. A `VersionedStore` stamps each value with a schema\n// `version` and, on read, walks a migration chain from the stored version up to the current one — so an old\n// shape is upgraded in place instead of silently mis-parsed. It inherits the broker's failure-tolerance: any\n// unrecoverable state (missing migration, a future version, a broken read) degrades to `initial`, never a throw.\n\nimport { localStorageStorageBroker, type StorageBroker } from './StorageBroker';\n\n/** Upgrades a value from one schema version to the next. Receives the prior shape as `unknown`; returns the next. */\nexport type Migration = (previous: unknown) => unknown;\n\n/** A map from *source* version to the migration that upgrades it to the following version (`n` upgrades `n`→`n+1`). */\nexport type MigrationMap = Readonly<Record<number, Migration>>;\n\n/** Configures a versioned store. */\nexport interface VersionedStoreOptions<T> {\n /** The storage key the envelope is persisted under. */\n readonly key: string;\n\n /** The current schema version (a positive integer). A stored value below this is migrated up on read. */\n readonly version: number;\n\n /** The value returned when nothing is stored or the stored value cannot be recovered. */\n readonly initial: T;\n\n /** Migrations keyed by source version; `migrations[n]` upgrades a v`n` value to v`n+1`. */\n readonly migrations?: MigrationMap;\n\n /** The backing persistence seam; defaults to `localStorageStorageBroker`. */\n readonly broker?: StorageBroker;\n}\n\n/** A versioned view over a storage key — hydrate-with-migration on read, envelope-stamp on write. */\nexport interface VersionedStore<T> {\n /** The storage key this store owns. */\n readonly key: string;\n\n /** The current schema version. */\n readonly version: number;\n\n /** Reads and, if needed, migrates the stored value; returns `initial` on absence or any unrecoverable state. */\n read(): T;\n\n /** Writes `value` stamped with the current version. */\n write(value: T): void;\n\n /** Removes the stored value. */\n clear(): void;\n}\n\n/** The persisted shape: the schema version alongside the caller's data. */\ninterface Envelope {\n readonly v: number;\n readonly data: unknown;\n}\n\n/** Recognises a value as a version envelope (vs a legacy bare value written before versioning). */\nfunction isEnvelope(value: unknown): value is Envelope {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'v' in value &&\n 'data' in value &&\n typeof (value as Envelope).v === 'number'\n );\n}\n\n/**\n * Builds a {@link VersionedStore} over `key`. On `read`, a stored value is interpreted as:\n * - **current version** → returned as-is;\n * - **older version** → each `migrations[n]` is applied in turn from the stored version up to `version`, the\n * upgraded value is written back, and returned. A gap in the chain (a missing `migrations[n]`) yields `initial`;\n * - **newer version** (a rollback to older code) → `initial`, leaving the forward-written value untouched;\n * - **legacy bare value** (no envelope) → treated as version `0` and migrated the same way.\n *\n * Any thrown error inside migration or the broker degrades to `initial`, mirroring the broker's never-throw contract.\n */\nexport function createVersionedStore<T>(options: VersionedStoreOptions<T>): VersionedStore<T> {\n const { key, version, initial, migrations = {} } = options;\n const broker = options.broker ?? localStorageStorageBroker;\n\n /** Runs the migration chain from `fromVersion` to the current `version`; null when a step is missing. */\n function migrate(fromVersion: number, data: unknown): { data: unknown } | null {\n let current = data;\n for (let from = fromVersion; from < version; from++) {\n const step = migrations[from];\n if (step === undefined) return null; // chain gap — cannot safely interpret the old shape\n current = step(current);\n }\n return { data: current };\n }\n\n return {\n key,\n version,\n\n read(): T {\n try {\n const stored = broker.read<unknown>(key);\n if (stored === null) return initial;\n\n const { v, data } = isEnvelope(stored) ? stored : { v: 0, data: stored };\n\n if (v === version) return data as T;\n if (v > version) return initial; // forward-written by newer code — don't guess\n\n const migrated = migrate(v, data);\n if (migrated === null) return initial;\n\n // Persist the upgrade so the next read is a fast, migration-free hit.\n broker.write<Envelope>(key, { v: version, data: migrated.data });\n return migrated.data as T;\n } catch {\n return initial;\n }\n },\n\n write(value: T): void {\n broker.write<Envelope>(key, { v: version, data: value });\n },\n\n clear(): void {\n broker.remove(key);\n },\n };\n}\n","import { onScopeDispose, shallowRef, toValue, watch, type MaybeRefOrGetter, type ShallowRef } from 'vue';\nimport type { AppError, Result } from '../../results';\n\n/** The lifecycle of the latest autosave intent, including a queued trailing write. */\nexport type AutosaveStatus = 'idle' | 'pending' | 'saving' | 'saved' | 'error';\n\n/** Tunes autosave timing, gating and failure reporting. */\nexport interface UseAutosaveOptions {\n /** The quiet period in milliseconds. Defaults to 800; read when an edit is scheduled. */\n readonly delayMs?: MaybeRefOrGetter<number>;\n /** Disabling drops pending work and invalidates completion state; reenabling schedules the current value. */\n readonly enabled?: MaybeRefOrGetter<boolean>;\n /** Reports a current write's explicit failure or exception while the scope remains enabled and live. */\n readonly onError?: (error: unknown) => void | PromiseLike<void>;\n}\n\n/** The current autosave intent and explicit queue controls. */\nexport interface AutosaveControls {\n readonly status: Readonly<ShallowRef<AutosaveStatus>>;\n /** The latest current-intent failure or exception; cleared by a new edit or cancellation. */\n readonly error: Readonly<ShallowRef<unknown | null>>;\n /** Date.now() when a still-current write last succeeded; obsolete completions do not advance it. */\n readonly lastSavedAt: Readonly<ShallowRef<number | null>>;\n /**\n * Makes pending work ready immediately, still waiting for any active sink. Without pending work this is a no-op.\n */\n flush(): void;\n /** Drops queued work and invalidates active completion state. An already-started sink cannot be undone. */\n cancel(): void;\n}\n\n/**\n * Watches edits deeply and serializes saves, retaining only the latest pending value behind an active write.\n * A new edit immediately supersedes the old completion status, even while its debounce is still pending.\n * The sink receives the latest value when its turn starts. For mutable drafts, a sink that needs an immutable\n * payload must snapshot before its first await; autosave does not impose a cloning policy on domain values.\n *\n * A void sink acknowledges completion by returning normally, preserving synchronous storage adapters.\n * A Result sink acknowledges success explicitly or supplies an AppError. Neither means durable persistence\n * beyond the sink's own contract. Thrown/rejected exceptions remain the original error in the handle/onError;\n * they are not converted into an expected Result failure. Error-observer failures are reported diagnostically.\n *\n * The initial value is not saved. Disable/cancel discard queued writes and invalidate late completion state.\n * Disposal cancels scheduling and starts no new writes; the rejection of an already-started sink is observed\n * without updating disposed state or invoking onError. Flush readies queued work but does not await durability;\n * disposal still cancels a write queued behind an active sink.\n */\nexport function useAutosave<T>(\n value: MaybeRefOrGetter<T>,\n save: (value: T) => void | Result<void, AppError> | PromiseLike<void | Result<void, AppError>>,\n options: UseAutosaveOptions = {},\n): AutosaveControls {\n const { delayMs = 800, enabled = true, onError } = options;\n const status = shallowRef<AutosaveStatus>('idle');\n const error = shallowRef<unknown | null>(null);\n const lastSavedAt = shallowRef<number | null>(null);\n let timer: ReturnType<typeof setTimeout> | null = null;\n let isDisposed = false;\n let isRunning = false;\n let pending = false;\n let ready = false;\n let revision = 0;\n const isEnabled = (): boolean => toValue(enabled);\n\n function clearTimer(): void {\n if (timer === null) return;\n clearTimeout(timer);\n timer = null;\n }\n\n /** Error observers are not allowed to create an unobserved rejection in the scheduler. */\n function reportError(failure: unknown): void {\n if (!onError) return;\n const reportObserverFailure = (observerError: unknown): void => {\n console.error('Autosave onError callback failed', observerError);\n };\n try {\n void Promise.resolve(onError(failure)).catch(reportObserverFailure);\n } catch (observerError) {\n reportObserverFailure(observerError);\n }\n }\n\n async function execute(currentRevision: number): Promise<void> {\n let failed = false;\n let failure: unknown;\n try {\n const outcome = await save(toValue(value));\n if (outcome && !outcome.ok) {\n failed = true;\n failure = outcome.failure;\n }\n } catch (caught) {\n failed = true;\n failure = caught;\n }\n isRunning = false;\n if (!isDisposed && isEnabled() && currentRevision === revision) {\n status.value = failed ? 'error' : 'saved';\n error.value = failed ? failure : null;\n if (failed) reportError(failure);\n else lastSavedAt.value = Date.now();\n }\n drain();\n }\n\n function drain(): void {\n if (isDisposed || !isEnabled() || isRunning || !pending || !ready) return;\n clearTimer();\n pending = false;\n ready = false;\n isRunning = true;\n status.value = 'saving';\n void execute(revision);\n }\n\n function flush(): void {\n if (isDisposed || !isEnabled() || !pending) return;\n clearTimer();\n ready = true;\n drain();\n }\n\n function cancel(): void {\n clearTimer();\n pending = false;\n ready = false;\n revision += 1;\n if (isDisposed) return;\n status.value = 'idle';\n error.value = null;\n }\n\n watch(\n [() => toValue(value), isEnabled],\n () => {\n if (isDisposed) return;\n if (!isEnabled()) {\n cancel();\n return;\n }\n revision += 1;\n clearTimer();\n pending = true;\n ready = false;\n status.value = 'pending';\n error.value = null;\n const delay = toValue(delayMs);\n timer = setTimeout(\n () => {\n timer = null;\n ready = true;\n drain();\n },\n Number.isFinite(delay) ? Math.max(0, delay) : 800,\n );\n },\n // Invalidate a completion immediately on edit; a queued watcher could otherwise report obsolete success.\n { deep: true, flush: 'sync' },\n );\n\n onScopeDispose(() => {\n isDisposed = true;\n cancel();\n status.value = 'idle';\n error.value = null;\n });\n return { status, error, lastSavedAt, flush, cancel };\n}\n"],"names":[],"mappings":";;;;AAQA,MAAM,qBAAqB;AAOpB,SAAS,iBAAiB,OAAsB,WAAkC;AACvF,QAAM,QAAQ,CAAC,QAAwB,GAAG,SAAS,GAAG,kBAAkB,GAAG,GAAG;AAE9E,SAAO;AAAA,IACL,KAAQ,KAAuB;AAC7B,aAAO,MAAM,KAAQ,MAAM,GAAG,CAAC;AAAA,IACjC;AAAA,IAEA,MAAS,KAAa,OAAmB;AACvC,aAAO,MAAM,MAAM,MAAM,GAAG,GAAG,KAAK;AAAA,IACtC;AAAA,IAEA,OAAO,KAAsB;AAC3B,aAAO,MAAM,OAAO,MAAM,GAAG,CAAC;AAAA,IAChC;AAAA,EAAA;AAEJ;AC0BA,SAAS,WAAW,OAAmC;AACrD,SACE,OAAO,UAAU,YACjB,UAAU,QACV,OAAO,SACP,UAAU,SACV,OAAQ,MAAmB,MA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AQ;AACR,UAAA;AAAA,EACF;AAEA,WAAS,SAAe;AACtB,eAAA;AACA,cAAU;AACV,YAAQ;AACR,gBAAY;AACZ,QAAI,WAAY;AAChB,WAAO,QAAQ;AACf,UAAM,QAAQ;AAAA,EAChB;AAEA;AAAA,IACE,CAAC,MAAM,QAAQ,KAAK,GAAG,SAAS;AAAA,IAChC,MAAM;AACJ,UAAI,WAAY;AAChB,UAAI,CAAC,aAAa;AAChB,eAAA;AACA;AAAA,MACF;AACA,kBAAY;AACZ,iBAAA;AACA,gBAAU;AACV,cAAQ;AACR,aAAO,QAAQ;AACf,YAAM,QAAQ;AACd,YAAM,QAAQ,QAAQ,OAAO;AAC7B,cAAQ;AAAA,QACN,MAAM;AACJ,kBAAQ;AACR,kBAAQ;AACR,gBAAA;AAAA,QACF;AAAA,QACA,OAAO,SAAS,KAAK,IAAI,KAAK,IAAI,GAAG,KAAK,IAAI;AAAA,MAAA;AAAA,IAElD;AAAA;AAAA,IAEA,EAAE,MAAM,MAAM,OAAO,OAAA;AAAA,EAAO;AAG9B,iBAAe,MAAM;AACnB,iBAAa;AACb,WAAA;AACA,WAAO,QAAQ;AACf,UAAM,QAAQ;AAAA,EAChB,CAAC;AACD,SAAO,EAAE,QAAQ,OAAO,aAAa,OAAO,OAAA;AAC9C;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/foundation/storage/NamespacedBroker.ts","../../../src/foundation/storage/PersistentRef.ts","../../../src/foundation/storage/VersionedStore.ts","../../../src/foundation/storage/hooks/UseAutosave.ts"],"sourcesContent":["// A `StorageBroker` decorator that prefixes every key with a namespace. Wrapping a shared broker (one\n// `localStorage`) in a namespace keeps unrelated features — or two tenants in the same app — from colliding on\n// a bare key like `\"draft\"`, without any hook change: the persistence hooks still see a plain `StorageBroker`.\n// Composes with any broker (production, memory, or another namespace) since it only rewrites keys.\n\nimport type { StorageBroker } from './StorageBroker';\n\n/** The separator between a namespace and the caller's key. */\nconst NamespaceSeparator = ':';\n\n/**\n * Wraps `inner` so every key is transparently prefixed with `namespace` (joined by `:`). Reads, writes, and\n * removes all address the namespaced key, so two brokers with distinct namespaces over the same backing store\n * never observe each other's values. Delegates JSON handling and failure-tolerance to `inner` unchanged.\n */\nexport function namespacedBroker(inner: StorageBroker, namespace: string): StorageBroker {\n const scope = (key: string): string => `${namespace}${NamespaceSeparator}${key}`;\n\n return {\n read<T>(key: string): T | null {\n return inner.read<T>(scope(key));\n },\n\n write<T>(key: string, value: T): boolean {\n return inner.write(scope(key), value);\n },\n\n remove(key: string): boolean {\n return inner.remove(scope(key));\n },\n };\n}\n","// A persisted ref shared by every reader. `usePersistentState` gives each component its own copy hydrated on mount;\n// an app-wide view choice — a sidebar fold, a filter switch, the last page opened — needs one value that every\n// component reads and any of them writes. `createPersistentRef` builds it once, at module scope, over the broker,\n// and decodes what storage holds before adopting it: a value written by older code, another app or a hand edit is\n// rejected to `initial`, never trusted as `T`.\n\nimport { customRef, getCurrentScope, onScopeDispose, type Ref } from 'vue';\n\nimport { localStorageStorageBroker, type StorageBroker } from './StorageBroker';\n\n/** Accepts a stored JSON value as `T`, or answers `undefined` for a shape it does not recognise. */\nexport type PersistentDecoder<T> = (stored: unknown) => T | undefined;\n\n/** Tunes where a persistent ref stores and what it accepts back. */\nexport interface PersistentRefOptions<T> {\n /** Validates a stored value before it is adopted; a rejection or a throw reads as `initial`. Defaults to trust. */\n readonly decode?: PersistentDecoder<T>;\n\n /** The persistence seam to read and write through; defaults to `localStorageStorageBroker`. */\n readonly broker?: StorageBroker;\n\n /** Whether another tab's write under the same key is adopted; defaults to true. Only `localStorage` reports one. */\n readonly syncTabs?: boolean;\n}\n\n/**\n * Creates a ref mirrored into a `StorageBroker` under `key`, meant to be created once and shared by every reader.\n * It reads storage when created: a miss, a stored `null`, a value `decode` rejects or a throwing `decode` yields\n * `initial`. Assigning a different value writes it through at once; reading never writes, and a failed write keeps the\n * value for this visit. Backed by `localStorage`, it adopts a decoded write from another tab and returns to `initial`\n * when another tab removes the key or clears storage.\n *\n * The ref is shallow: replace an array or object to persist it, never mutate it in place. Created inside an effect\n * scope (a component's `setup`, an `effectScope`), its tab listener detaches with the scope; at module scope it lives\n * as long as the page.\n */\nexport function createPersistentRef<T>(key: string, initial: T, options: PersistentRefOptions<T> = {}): Ref<T> {\n const { decode, broker = localStorageStorageBroker, syncTabs = true } = options;\n\n /** The stored value, decoded; `initial` for a miss, a rejection or a throwing decoder. */\n function readStored(): T {\n const stored = broker.read<unknown>(key);\n if (stored === null) return initial;\n if (decode === undefined) return stored as T;\n\n try {\n const decoded = decode(stored);\n return decoded === undefined ? initial : decoded;\n } catch {\n return initial;\n }\n }\n\n let current = readStored();\n let notify = (): void => undefined;\n\n const value = customRef<T>((track, trigger) => {\n notify = trigger;\n return {\n get() {\n track();\n return current;\n },\n set(next) {\n if (Object.is(next, current)) return;\n current = next;\n broker.write(key, next);\n trigger();\n },\n };\n });\n\n if (syncTabs && broker === localStorageStorageBroker && typeof window !== 'undefined') {\n // Adoption assigns `current` directly, never through the setter, so another tab's write is never echoed back.\n const onStorage = (event: StorageEvent): void => {\n if (event.storageArea !== null && event.storageArea !== window.localStorage) return;\n if (event.key !== null && event.key !== key) return;\n const next = event.newValue === null ? initial : readStored();\n if (Object.is(next, current)) return;\n current = next;\n notify();\n };\n\n window.addEventListener('storage', onStorage);\n if (getCurrentScope()) onScopeDispose(() => window.removeEventListener('storage', onStorage));\n }\n\n return value;\n}\n","// A versioned wrapper over a `StorageBroker`. Persisted client state outlives the code that wrote it: a user\n// carries last month's `localStorage` into today's deploy. A `VersionedStore` stamps each value with a schema\n// `version` and, on read, walks a migration chain from the stored version up to the current one — so an old\n// shape is upgraded in place instead of silently mis-parsed. It inherits the broker's failure-tolerance: any\n// unrecoverable state (missing migration, a future version, a broken read) degrades to `initial`, never a throw.\n\nimport { localStorageStorageBroker, type StorageBroker } from './StorageBroker';\n\n/** Upgrades a value from one schema version to the next. Receives the prior shape as `unknown`; returns the next. */\nexport type Migration = (previous: unknown) => unknown;\n\n/** A map from *source* version to the migration that upgrades it to the following version (`n` upgrades `n`→`n+1`). */\nexport type MigrationMap = Readonly<Record<number, Migration>>;\n\n/** Configures a versioned store. */\nexport interface VersionedStoreOptions<T> {\n /** The storage key the envelope is persisted under. */\n readonly key: string;\n\n /** The current schema version (a positive integer). A stored value below this is migrated up on read. */\n readonly version: number;\n\n /** The value returned when nothing is stored or the stored value cannot be recovered. */\n readonly initial: T;\n\n /** Migrations keyed by source version; `migrations[n]` upgrades a v`n` value to v`n+1`. */\n readonly migrations?: MigrationMap;\n\n /** The backing persistence seam; defaults to `localStorageStorageBroker`. */\n readonly broker?: StorageBroker;\n}\n\n/** A versioned view over a storage key — hydrate-with-migration on read, envelope-stamp on write. */\nexport interface VersionedStore<T> {\n /** The storage key this store owns. */\n readonly key: string;\n\n /** The current schema version. */\n readonly version: number;\n\n /** Reads and, if needed, migrates the stored value; returns `initial` on absence or any unrecoverable state. */\n read(): T;\n\n /** Writes `value` stamped with the current version. */\n write(value: T): void;\n\n /** Removes the stored value. */\n clear(): void;\n}\n\n/** The persisted shape: the schema version alongside the caller's data. */\ninterface Envelope {\n readonly v: number;\n readonly data: unknown;\n}\n\n/** Recognises a value as a version envelope (vs a legacy bare value written before versioning). */\nfunction isEnvelope(value: unknown): value is Envelope {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'v' in value &&\n 'data' in value &&\n typeof (value as Envelope).v === 'number'\n );\n}\n\n/**\n * Builds a {@link VersionedStore} over `key`. On `read`, a stored value is interpreted as:\n * - **current version** → returned as-is;\n * - **older version** → each `migrations[n]` is applied in turn from the stored version up to `version`, the\n * upgraded value is written back, and returned. A gap in the chain (a missing `migrations[n]`) yields `initial`;\n * - **newer version** (a rollback to older code) → `initial`, leaving the forward-written value untouched;\n * - **legacy bare value** (no envelope) → treated as version `0` and migrated the same way.\n *\n * Any thrown error inside migration or the broker degrades to `initial`, mirroring the broker's never-throw contract.\n */\nexport function createVersionedStore<T>(options: VersionedStoreOptions<T>): VersionedStore<T> {\n const { key, version, initial, migrations = {} } = options;\n const broker = options.broker ?? localStorageStorageBroker;\n\n /** Runs the migration chain from `fromVersion` to the current `version`; null when a step is missing. */\n function migrate(fromVersion: number, data: unknown): { data: unknown } | null {\n let current = data;\n for (let from = fromVersion; from < version; from++) {\n const step = migrations[from];\n if (step === undefined) return null; // chain gap — cannot safely interpret the old shape\n current = step(current);\n }\n return { data: current };\n }\n\n return {\n key,\n version,\n\n read(): T {\n try {\n const stored = broker.read<unknown>(key);\n if (stored === null) return initial;\n\n const { v, data } = isEnvelope(stored) ? stored : { v: 0, data: stored };\n\n if (v === version) return data as T;\n if (v > version) return initial; // forward-written by newer code — don't guess\n\n const migrated = migrate(v, data);\n if (migrated === null) return initial;\n\n // Persist the upgrade so the next read is a fast, migration-free hit.\n broker.write<Envelope>(key, { v: version, data: migrated.data });\n return migrated.data as T;\n } catch {\n return initial;\n }\n },\n\n write(value: T): void {\n broker.write<Envelope>(key, { v: version, data: value });\n },\n\n clear(): void {\n broker.remove(key);\n },\n };\n}\n","import { onScopeDispose, shallowRef, toValue, watch, type MaybeRefOrGetter, type ShallowRef } from 'vue';\nimport type { AppError, Result } from '../../results';\n\n/** The lifecycle of the latest autosave intent, including a queued trailing write. */\nexport type AutosaveStatus = 'idle' | 'pending' | 'saving' | 'saved' | 'error';\n\n/** Tunes autosave timing, gating and failure reporting. */\nexport interface UseAutosaveOptions {\n /** The quiet period in milliseconds. Defaults to 800; read when an edit is scheduled. */\n readonly delayMs?: MaybeRefOrGetter<number>;\n /** Disabling drops pending work and invalidates completion state; reenabling schedules the current value. */\n readonly enabled?: MaybeRefOrGetter<boolean>;\n /** Reports a current write's explicit failure or exception while the scope remains enabled and live. */\n readonly onError?: (error: unknown) => void | PromiseLike<void>;\n}\n\n/** The current autosave intent and explicit queue controls. */\nexport interface AutosaveControls {\n readonly status: Readonly<ShallowRef<AutosaveStatus>>;\n /** The latest current-intent failure or exception; cleared by a new edit or cancellation. */\n readonly error: Readonly<ShallowRef<unknown | null>>;\n /** Date.now() when a still-current write last succeeded; obsolete completions do not advance it. */\n readonly lastSavedAt: Readonly<ShallowRef<number | null>>;\n /**\n * Makes pending work ready immediately, still waiting for any active sink. Without pending work this is a no-op.\n */\n flush(): void;\n /** Drops queued work and invalidates active completion state. An already-started sink cannot be undone. */\n cancel(): void;\n}\n\n/**\n * Watches edits deeply and serializes saves, retaining only the latest pending value behind an active write.\n * A new edit immediately supersedes the old completion status, even while its debounce is still pending.\n * The sink receives the latest value when its turn starts. For mutable drafts, a sink that needs an immutable\n * payload must snapshot before its first await; autosave does not impose a cloning policy on domain values.\n *\n * A void sink acknowledges completion by returning normally, preserving synchronous storage adapters.\n * A Result sink acknowledges success explicitly or supplies an AppError. Neither means durable persistence\n * beyond the sink's own contract. Thrown/rejected exceptions remain the original error in the handle/onError;\n * they are not converted into an expected Result failure. Error-observer failures are reported diagnostically.\n *\n * The initial value is not saved. Disable/cancel discard queued writes and invalidate late completion state.\n * Disposal cancels scheduling and starts no new writes; the rejection of an already-started sink is observed\n * without updating disposed state or invoking onError. Flush readies queued work but does not await durability;\n * disposal still cancels a write queued behind an active sink.\n */\nexport function useAutosave<T>(\n value: MaybeRefOrGetter<T>,\n save: (value: T) => void | Result<void, AppError> | PromiseLike<void | Result<void, AppError>>,\n options: UseAutosaveOptions = {},\n): AutosaveControls {\n const { delayMs = 800, enabled = true, onError } = options;\n const status = shallowRef<AutosaveStatus>('idle');\n const error = shallowRef<unknown | null>(null);\n const lastSavedAt = shallowRef<number | null>(null);\n let timer: ReturnType<typeof setTimeout> | null = null;\n let isDisposed = false;\n let isRunning = false;\n let pending = false;\n let ready = false;\n let revision = 0;\n const isEnabled = (): boolean => toValue(enabled);\n\n function clearTimer(): void {\n if (timer === null) return;\n clearTimeout(timer);\n timer = null;\n }\n\n /** Error observers are not allowed to create an unobserved rejection in the scheduler. */\n function reportError(failure: unknown): void {\n if (!onError) return;\n const reportObserverFailure = (observerError: unknown): void => {\n console.error('Autosave onError callback failed', observerError);\n };\n try {\n void Promise.resolve(onError(failure)).catch(reportObserverFailure);\n } catch (observerError) {\n reportObserverFailure(observerError);\n }\n }\n\n async function execute(currentRevision: number): Promise<void> {\n let failed = false;\n let failure: unknown;\n try {\n const outcome = await save(toValue(value));\n if (outcome && !outcome.ok) {\n failed = true;\n failure = outcome.failure;\n }\n } catch (caught) {\n failed = true;\n failure = caught;\n }\n isRunning = false;\n if (!isDisposed && isEnabled() && currentRevision === revision) {\n status.value = failed ? 'error' : 'saved';\n error.value = failed ? failure : null;\n if (failed) reportError(failure);\n else lastSavedAt.value = Date.now();\n }\n drain();\n }\n\n function drain(): void {\n if (isDisposed || !isEnabled() || isRunning || !pending || !ready) return;\n clearTimer();\n pending = false;\n ready = false;\n isRunning = true;\n status.value = 'saving';\n void execute(revision);\n }\n\n function flush(): void {\n if (isDisposed || !isEnabled() || !pending) return;\n clearTimer();\n ready = true;\n drain();\n }\n\n function cancel(): void {\n clearTimer();\n pending = false;\n ready = false;\n revision += 1;\n if (isDisposed) return;\n status.value = 'idle';\n error.value = null;\n }\n\n watch(\n [() => toValue(value), isEnabled],\n () => {\n if (isDisposed) return;\n if (!isEnabled()) {\n cancel();\n return;\n }\n revision += 1;\n clearTimer();\n pending = true;\n ready = false;\n status.value = 'pending';\n error.value = null;\n const delay = toValue(delayMs);\n timer = setTimeout(\n () => {\n timer = null;\n ready = true;\n drain();\n },\n Number.isFinite(delay) ? Math.max(0, delay) : 800,\n );\n },\n // Invalidate a completion immediately on edit; a queued watcher could otherwise report obsolete success.\n { deep: true, flush: 'sync' },\n );\n\n onScopeDispose(() => {\n isDisposed = true;\n cancel();\n status.value = 'idle';\n error.value = null;\n });\n return { status, error, lastSavedAt, flush, cancel };\n}\n"],"names":[],"mappings":";;;;AAQA,MAAM,qBAAqB;AAOpB,SAAS,iBAAiB,OAAsB,WAAkC;AACvF,QAAM,QAAQ,CAAC,QAAwB,GAAG,SAAS,GAAG,kBAAkB,GAAG,GAAG;AAE9E,SA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