basalt-ui 2.11.1 → 2.13.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/AGENTS.md +1 -1
- package/CHANGELOG.md +39 -0
- package/MIGRATING.md +51 -12
- package/README.md +2 -0
- package/agent/rules/basalt-mantine.md +1 -1
- package/agent/rules/basalt-state.md +1 -1
- package/agent/skills/basalt-app/SKILL.md +2 -2
- package/agent/templates/main.tpl +1 -0
- package/dist/cli/basalt-install.d.ts +10 -0
- package/dist/cli/basalt-install.d.ts.map +1 -0
- package/dist/cli/basalt-install.js +0 -0
- package/dist/cli/check-theme.js +1 -1
- package/dist/cli/doctor-upgrade.d.ts +5 -6
- package/dist/cli/doctor-upgrade.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.js +85 -56
- package/dist/cli/doctor.js +3 -3
- package/dist/cli/index.d.ts +5 -27
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +12 -49
- package/dist/cli/provider-tags.d.ts +12 -0
- package/dist/cli/provider-tags.d.ts.map +1 -0
- package/dist/cli/provider-tags.js +28 -0
- package/dist/cli/render-imports.d.ts +24 -0
- package/dist/cli/render-imports.d.ts.map +1 -0
- package/dist/cli/render-imports.js +74 -0
- package/dist/cli/router-wiring.d.ts +12 -0
- package/dist/cli/router-wiring.d.ts.map +1 -1
- package/dist/cli/router-wiring.js +18 -0
- package/dist/cli/source-text.d.ts +7 -0
- package/dist/cli/source-text.d.ts.map +1 -1
- package/dist/cli/source-text.js +34 -0
- package/dist/cli/sync.d.ts.map +1 -1
- package/dist/cli/sync.js +19 -13
- package/dist/commands/command-stash.d.ts +15 -0
- package/dist/commands/command-stash.d.ts.map +1 -0
- package/dist/commands/command-stash.js +31 -0
- package/dist/commands/define-commands.d.ts +2 -3
- package/dist/commands/define-commands.d.ts.map +1 -1
- package/dist/commands/define-commands.js +9 -7
- package/dist/commands/define-overlays.d.ts +6 -12
- package/dist/commands/define-overlays.d.ts.map +1 -1
- package/dist/commands/define-overlays.js +28 -34
- package/dist/commands/projectors.js +1 -1
- package/dist/guard/fonts-hint.d.ts +3 -0
- package/dist/guard/fonts-hint.d.ts.map +1 -0
- package/dist/guard/fonts-hint.js +4 -0
- package/dist/guard/index.d.ts +1 -1
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +2 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/provider/create-router.d.ts +57 -10
- package/dist/provider/create-router.d.ts.map +1 -1
- package/dist/provider/create-router.js +28 -17
- package/dist/provider/hotkeys.d.ts +2 -6
- package/dist/provider/hotkeys.d.ts.map +1 -1
- package/dist/provider/hotkeys.js +10 -15
- package/dist/provider/index.d.ts +7 -5
- package/dist/provider/index.d.ts.map +1 -1
- package/dist/provider/index.js +35 -42
- package/dist/provider/modals-mount.d.ts +16 -0
- package/dist/provider/modals-mount.d.ts.map +1 -0
- package/dist/provider/modals-mount.js +42 -0
- package/dist/provider/notifier.d.ts +22 -0
- package/dist/provider/notifier.d.ts.map +1 -0
- package/dist/provider/notifier.js +36 -0
- package/dist/provider/route-transition.d.ts +1 -1
- package/dist/provider/route-transition.d.ts.map +1 -1
- package/dist/provider/route-transition.js +1 -1
- package/dist/provider/slots.d.ts +25 -0
- package/dist/provider/slots.d.ts.map +1 -0
- package/dist/provider/slots.js +29 -0
- package/dist/provider/spotlight-actions.d.ts +1 -1
- package/dist/provider/spotlight-actions.d.ts.map +1 -1
- package/dist/provider/spotlight-actions.js +2 -3
- package/dist/provider/spotlight-mount.d.ts +3 -0
- package/dist/provider/spotlight-mount.d.ts.map +1 -0
- package/dist/provider/spotlight-mount.js +26 -0
- package/dist/query-client.d.ts +2 -62
- package/dist/query-client.d.ts.map +1 -1
- package/dist/query-client.js +13 -18
- package/dist/router-tanstack/nav-stash.d.ts +24 -0
- package/dist/router-tanstack/nav-stash.d.ts.map +1 -0
- package/dist/router-tanstack/nav-stash.js +23 -0
- package/dist/router-tanstack/nav.d.ts +5 -15
- package/dist/router-tanstack/nav.d.ts.map +1 -1
- package/dist/router-tanstack/nav.js +6 -16
- package/dist/router-tanstack/search-store-warnings.d.ts +33 -0
- package/dist/router-tanstack/search-store-warnings.d.ts.map +1 -0
- package/dist/router-tanstack/search-store-warnings.js +77 -0
- package/dist/router-tanstack/search-store.d.ts +2 -5
- package/dist/router-tanstack/search-store.d.ts.map +1 -1
- package/dist/router-tanstack/search-store.js +111 -110
- package/dist/router-tanstack/use-nav.js +1 -1
- package/dist/surfaces.d.ts +1 -1
- package/dist/surfaces.js +1 -1
- package/dist/telemetry.d.ts +31 -2
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +32 -12
- package/dist/theme/ctl-theme.d.ts.map +1 -1
- package/dist/theme/ctl-theme.js +17 -30
- package/dist/theme/extend.d.ts +18 -0
- package/dist/theme/extend.d.ts.map +1 -0
- package/dist/theme/extend.js +6 -0
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +44 -84
- package/dist/unwrap.d.ts +29 -0
- package/dist/unwrap.d.ts.map +1 -0
- package/dist/unwrap.js +18 -0
- package/llms.txt +11 -7
- package/package.json +2 -2
- package/src/cli/basalt-install.ts +9 -0
- package/src/cli/check-theme.ts +1 -1
- package/src/cli/doctor-upgrade.ts +117 -72
- package/src/cli/doctor.ts +3 -3
- package/src/cli/index.ts +15 -70
- package/src/cli/provider-tags.ts +38 -0
- package/src/cli/render-imports.ts +104 -0
- package/src/cli/router-wiring.ts +23 -0
- package/src/cli/source-text.ts +39 -0
- package/src/cli/sync.ts +28 -22
- package/src/commands/command-stash.ts +44 -0
- package/src/commands/define-commands.ts +10 -17
- package/src/commands/define-overlays.ts +40 -68
- package/src/commands/projectors.ts +1 -1
- package/src/guard/fonts-hint.ts +2 -0
- package/src/guard/index.ts +2 -2
- package/src/index.ts +4 -2
- package/src/provider/create-router.tsx +103 -39
- package/src/provider/hotkeys.ts +14 -22
- package/src/provider/index.tsx +55 -61
- package/src/provider/modals-mount.tsx +66 -0
- package/src/provider/notifier.ts +52 -0
- package/src/provider/route-transition.ts +1 -1
- package/src/provider/slots.ts +59 -0
- package/src/provider/spotlight-actions.tsx +3 -4
- package/src/provider/spotlight-mount.tsx +33 -0
- package/src/query-client.ts +20 -78
- package/src/router-tanstack/nav-stash.ts +41 -0
- package/src/router-tanstack/nav.ts +11 -31
- package/src/router-tanstack/search-store-warnings.ts +120 -0
- package/src/router-tanstack/search-store.ts +200 -206
- package/src/router-tanstack/use-nav.ts +1 -1
- package/src/surfaces.ts +1 -1
- package/src/telemetry.ts +71 -13
- package/src/theme/__snapshots__/plain-theme.test.ts.snap +2354 -0
- package/src/theme/ctl-theme.tsx +20 -19
- package/src/theme/extend.ts +18 -0
- package/src/theme/index.ts +50 -49
- package/src/unwrap.ts +44 -0
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
* silently. Compile-verified. A config whose selling point is "typos are compile errors" cannot
|
|
10
10
|
* have a hole exactly where metadata typos live.
|
|
11
11
|
*
|
|
12
|
-
* No JSX and no Mantine in this module — `./router-tanstack` is a headless barrel by contract.
|
|
12
|
+
* No JSX and no Mantine in this module — `./router-tanstack` is a headless barrel by contract. The one
|
|
13
|
+
* exception is `defineNav`'s registration of the Spotlight mount (`../provider/slots`): nav entries
|
|
14
|
+
* feed the palette, and the mount is only reachable through this call.
|
|
13
15
|
*/
|
|
14
16
|
import type { RegisteredRouter } from '@tanstack/react-router';
|
|
15
17
|
import type { ReactNode } from 'react';
|
|
@@ -146,10 +148,6 @@ export declare function defineNav<const G extends ReadonlyArray<AnyNavGroup>, co
|
|
|
146
148
|
* literal whose text is the fix (V2-SPEC § 3).
|
|
147
149
|
*/
|
|
148
150
|
type RegisteredOr<T> = 0 extends 1 & RegisteredRouter['routeTree'] ? 'basalt: declare Register { router }' : T;
|
|
149
|
-
/** @internal */
|
|
150
|
-
export declare function getActiveNav(): {
|
|
151
|
-
groups: ReadonlyArray<AnyNavGroup>;
|
|
152
|
-
} | undefined;
|
|
153
151
|
/**
|
|
154
152
|
* The link options for one destination, by id. Spreadable into `<Link>`, `router.navigate()`
|
|
155
153
|
* and `redirect()`. This is what collapses a consumer's Spotlight commands and index redirect.
|
|
@@ -161,14 +159,6 @@ export declare function getActiveNav(): {
|
|
|
161
159
|
export declare function navTarget<const C extends {
|
|
162
160
|
groups: ReadonlyArray<AnyNavGroup>;
|
|
163
161
|
}, K extends NavItemId<C['groups']>>(config: C, id: K): NavIndex<C['groups']>[K];
|
|
164
|
-
|
|
165
|
-
export type FlatNavItem
|
|
166
|
-
groupId: string;
|
|
167
|
-
groupLabel: string;
|
|
168
|
-
};
|
|
169
|
-
/** Depth-first flatten, parent then children — the leaf every other surface reads. */
|
|
170
|
-
export declare function flattenNav(config: {
|
|
171
|
-
groups: ReadonlyArray<AnyNavGroup>;
|
|
172
|
-
}): FlatNavItem[];
|
|
173
|
-
export {};
|
|
162
|
+
export { flattenNav, getActiveNav } from './nav-stash.js';
|
|
163
|
+
export type { FlatNavItem } from './nav-stash.js';
|
|
174
164
|
//# sourceMappingURL=nav.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nav.d.ts","sourceRoot":"","sources":["../../src/router-tanstack/nav.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"nav.d.ts","sourceRoot":"","sources":["../../src/router-tanstack/nav.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAItC,OAAO,KAAK,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAI9E,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,6CAA6C;IAC7C,KAAK,CAAC,EAAE,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,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,gBAAgB,CAAC,WAAW,CAAC,GAC9D,qCAAqC,GACrC,CAAC,CAAA;AAaL;;;;;;;GAOG;AACH,wBAAgB,SAAS,CACvB,KAAK,CAAC,CAAC,SAAS;IAAE,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,CAAA;CAAE,EACtD,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAChC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAM5C;AAED,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AACtD,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
+
import { registerSlot } from "../provider/slots.js";
|
|
2
|
+
import { setActiveNav } from "./nav-stash.js";
|
|
3
|
+
import { SpotlightMount } from "../provider/spotlight-mount.js";
|
|
1
4
|
function navGroup(meta, items) {
|
|
2
5
|
return { ...meta, items };
|
|
3
6
|
}
|
|
4
7
|
function defineNav(config) {
|
|
5
8
|
const nav = config;
|
|
6
|
-
|
|
9
|
+
setActiveNav(nav);
|
|
10
|
+
registerSlot("spotlight", SpotlightMount);
|
|
7
11
|
return nav;
|
|
8
12
|
}
|
|
9
|
-
let activeNav;
|
|
10
|
-
function getActiveNav() {
|
|
11
|
-
return activeNav;
|
|
12
|
-
}
|
|
13
13
|
function findById(items, id) {
|
|
14
14
|
for (const item of items) {
|
|
15
15
|
if (item.id === id) return item;
|
|
@@ -25,17 +25,7 @@ function navTarget(config, id) {
|
|
|
25
25
|
}
|
|
26
26
|
throw new Error(`navTarget: no nav item with id "${id}"`);
|
|
27
27
|
}
|
|
28
|
-
|
|
29
|
-
const out = [];
|
|
30
|
-
const walk = (items, groupId, groupLabel) => {
|
|
31
|
-
for (const item of items) {
|
|
32
|
-
out.push({ ...item, groupId, groupLabel });
|
|
33
|
-
if (item.children) walk(item.children, groupId, groupLabel);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
for (const g of config.groups) walk(g.items, g.id, g.label);
|
|
37
|
-
return out;
|
|
38
|
-
}
|
|
28
|
+
import { flattenNav, getActiveNav } from "./nav-stash.js";
|
|
39
29
|
export {
|
|
40
30
|
defineNav,
|
|
41
31
|
flattenNav,
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `createSearchStore`'s dev diagnostics and the once-only bookkeeping behind them, so the store
|
|
3
|
+
* body is the lane logic only. Every method is silent in production except `patchOwned`, which
|
|
4
|
+
* keeps the write and logs it. Each reads `process.env['NODE_ENV']` literally at its own branch —
|
|
5
|
+
* a shared helper would keep the dev text in a production bundle (`src/common/dev-gate.test.ts`).
|
|
6
|
+
*/
|
|
7
|
+
export type StoreWarnings = {
|
|
8
|
+
linkPinsFallback: (input: {
|
|
9
|
+
param: string;
|
|
10
|
+
urlValue: unknown;
|
|
11
|
+
storedValue: unknown;
|
|
12
|
+
}) => void;
|
|
13
|
+
writeHasNowhereToGo: (input: {
|
|
14
|
+
name: string;
|
|
15
|
+
param: string;
|
|
16
|
+
}) => void;
|
|
17
|
+
patchWasDropped: (input: {
|
|
18
|
+
name: string;
|
|
19
|
+
param: string;
|
|
20
|
+
}) => void;
|
|
21
|
+
patchOwned: (input: {
|
|
22
|
+
name: string;
|
|
23
|
+
owner: string;
|
|
24
|
+
param: string;
|
|
25
|
+
}) => void;
|
|
26
|
+
foreignParam: (input: {
|
|
27
|
+
name: string;
|
|
28
|
+
param: string;
|
|
29
|
+
path: string;
|
|
30
|
+
}) => void;
|
|
31
|
+
};
|
|
32
|
+
export declare function createStoreWarnings(key: string): StoreWarnings;
|
|
33
|
+
//# sourceMappingURL=search-store-warnings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-store-warnings.d.ts","sourceRoot":"","sources":["../../src/router-tanstack/search-store-warnings.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA6BH,MAAM,MAAM,aAAa,GAAG;IAC1B,gBAAgB,EAAE,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,OAAO,CAAC;QAAC,WAAW,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAA;IAC7F,mBAAmB,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IACrE,eAAe,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IACjE,UAAU,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IAC3E,YAAY,EAAE,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;CAC7E,CAAA;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CA6E9D"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
function first(seen, name) {
|
|
2
|
+
if (seen.has(name)) return false;
|
|
3
|
+
seen.add(name);
|
|
4
|
+
return true;
|
|
5
|
+
}
|
|
6
|
+
function describeValue(value) {
|
|
7
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
8
|
+
}
|
|
9
|
+
function patchOwnsFieldMessage(input) {
|
|
10
|
+
const { key, name, owner, param } = input;
|
|
11
|
+
return `basalt-ui: createSearchStore('${key}'): set('${name}', \u2026, { patch }) carries \`${param}\`, which this store's field '${owner}' owns \u2014 the URL would take it while the localStorage mirror kept the old value, so the next paramless visit and every \`linkSearch\` link disagree with the page the write happened on. Write it through \`field.${owner}.use()[1]\` instead; a \`patch\` is for keys the store does NOT own.`;
|
|
12
|
+
}
|
|
13
|
+
function createStoreWarnings(key) {
|
|
14
|
+
let pinned = false;
|
|
15
|
+
const nowhere = /* @__PURE__ */ new Set();
|
|
16
|
+
const patchDropped = /* @__PURE__ */ new Set();
|
|
17
|
+
const patchOwner = /* @__PURE__ */ new Set();
|
|
18
|
+
const foreign = /* @__PURE__ */ new Set();
|
|
19
|
+
const warn = (message) => (
|
|
20
|
+
// oxlint-disable-next-line no-console -- a dev-time wiring warning has no other channel
|
|
21
|
+
console.warn(`[basalt-ui] createSearchStore('${key}'): ${message}`)
|
|
22
|
+
);
|
|
23
|
+
return {
|
|
24
|
+
/**
|
|
25
|
+
* Once per store: the URL pins `fallback` while something else is persisted and no reader was
|
|
26
|
+
* ever called — almost always a nav link declaring the param as a module-scope literal.
|
|
27
|
+
*/
|
|
28
|
+
linkPinsFallback(input) {
|
|
29
|
+
if (process.env["NODE_ENV"] === "production" || pinned) return;
|
|
30
|
+
pinned = true;
|
|
31
|
+
const { param } = input;
|
|
32
|
+
const urlValue = describeValue(input.urlValue);
|
|
33
|
+
warn(
|
|
34
|
+
`the URL pinned \`${param}=${urlValue}\` (the fallback) while '${describeValue(input.storedValue)}' was persisted, and nothing has read this store back. A nav link is almost certainly declaring \`search: { ${param}: '${urlValue}' }\` at module scope, which overrides the stored value on every click \u2014 pass the store's own reader instead: \`search: <store>.linkSearch\`. (dev only)`
|
|
35
|
+
);
|
|
36
|
+
},
|
|
37
|
+
/** Once per field: a `persist: false` write from a route that does not validate it goes nowhere. */
|
|
38
|
+
writeHasNowhereToGo(input) {
|
|
39
|
+
if (process.env["NODE_ENV"] === "production" || !first(nowhere, input.name)) return;
|
|
40
|
+
warn(
|
|
41
|
+
`wrote field '${input.name}' from a route that does not validate \`${input.param}\`, and the field is \`persist: false\` \u2014 so the write was dropped. Either render this control on the route wired to \`validateSearch\`, or give the field the localStorage lane (drop \`persist: false\`) so a write from elsewhere survives until the owning route reads it. (dev only)`
|
|
42
|
+
);
|
|
43
|
+
},
|
|
44
|
+
/** Once per field: a patched write from a route that does not validate the field. */
|
|
45
|
+
patchWasDropped(input) {
|
|
46
|
+
if (process.env["NODE_ENV"] === "production" || !first(patchDropped, input.name)) return;
|
|
47
|
+
warn(
|
|
48
|
+
`wrote field '${input.name}' with a \`patch\` from a route that does not validate \`${input.param}\` \u2014 the field's value persisted (A1), but the patch was DROPPED: there is no navigate to merge it into. Render the control on the route wired to \`validateSearch\`, or apply that sibling param on the route that owns it. (dev only)`
|
|
49
|
+
);
|
|
50
|
+
},
|
|
51
|
+
/**
|
|
52
|
+
* A `patch` named a param another field of this store owns: thrown in dev (one-line fix, silent
|
|
53
|
+
* damage), kept and logged once in production so a stale param cannot take a page down.
|
|
54
|
+
*/
|
|
55
|
+
patchOwned(input) {
|
|
56
|
+
const message = patchOwnsFieldMessage({ key, ...input });
|
|
57
|
+
if (process.env["NODE_ENV"] !== "production") throw new Error(message);
|
|
58
|
+
if (!first(patchOwner, input.param)) return;
|
|
59
|
+
console.error(message);
|
|
60
|
+
},
|
|
61
|
+
/**
|
|
62
|
+
* Once per field and path: the param is in the URL, yet this store's `validateSearch` did not run for the location — so
|
|
63
|
+
* a different store or a hand-rolled schema owns it, and presence-based ownership will let this
|
|
64
|
+
* store's setter navigate on its behalf.
|
|
65
|
+
*/
|
|
66
|
+
foreignParam(input) {
|
|
67
|
+
if (process.env["NODE_ENV"] === "production") return;
|
|
68
|
+
if (!first(foreign, `${input.name}@${input.path}`)) return;
|
|
69
|
+
warn(
|
|
70
|
+
`\`${input.param}\` (field '${input.name}') is in the URL but this store's \`validateSearch\` has never run \u2014 another store or schema owns the param, and a write here will navigate for it. Wire \`validateSearch: <store>.validateSearch\` (or spread it into your own) on the route that owns the param. (dev only)`
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
export {
|
|
76
|
+
createStoreWarnings
|
|
77
|
+
};
|
|
@@ -58,11 +58,8 @@ export type SearchStore<S extends Record<string, AnyField>> = {
|
|
|
58
58
|
*/
|
|
59
59
|
useReset: () => () => void;
|
|
60
60
|
};
|
|
61
|
-
/**
|
|
62
|
-
|
|
63
|
-
* door.
|
|
64
|
-
*/
|
|
65
|
-
export declare function buildSearchStore<const S extends Record<string, AnyField>>(o: CreateSearchStoreOptions<S>): SearchStore<S>;
|
|
61
|
+
/** @internal Tests only — a fresh page for the next hydration. */
|
|
62
|
+
export declare function resetHydrationForTests(): void;
|
|
66
63
|
/**
|
|
67
64
|
* One store per page (or per feature), over typed fields. `key` is the localStorage key; each
|
|
68
65
|
* field's map key is its default URL param name.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-store.d.ts","sourceRoot":"","sources":["../../src/router-tanstack/search-store.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"search-store.d.ts","sourceRoot":"","sources":["../../src/router-tanstack/search-store.ts"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EACV,QAAQ,EACR,WAAW,EAGX,YAAY,EAEZ,YAAY,EACb,MAAM,iBAAiB,CAAA;AAIxB,MAAM,MAAM,wBAAwB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI;IACzE,uFAAuF;IACvF,GAAG,EAAE,MAAM,CAAA;IACX,uFAAuF;IACvF,MAAM,EAAE,CAAC,CAAA;IACT,wFAAwF;IACxF,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI;IAC5D;;;;OAIG;IACH,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,YAAY,CAAC,CAAC,CAAC,CAAA;IACjE;;;;OAIG;IACH,UAAU,EAAE,MAAM,YAAY,CAAC,CAAC,CAAC,CAAA;IACjC,iFAAiF;IACjF,UAAU,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;IAC1C,2FAA2F;IAC3F,KAAK,EAAE;SAAG,CAAC,IAAI,MAAM,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;KAAE,CAAA;IAC5C,8FAA8F;IAC9F,MAAM,EAAE,CAAC,GAAG,EAAE,OAAO,CAAC;SAAG,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;KAAE,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,CAAA;IACpF,6EAA6E;IAC7E,SAAS,EAAE,MAAM,YAAY,CAAC,CAAC,CAAC,CAAA;IAChC,oFAAoF;IACpF,cAAc,EAAE,MAAM,MAAM,CAAA;IAC5B;;;OAGG;IACH,QAAQ,EAAE,MAAM,MAAM,IAAI,CAAA;CAC3B,CAAA;AAWD,kEAAkE;AAClE,wBAAgB,sBAAsB,IAAI,IAAI,CAE7C;AA4FD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EACxE,CAAC,EAAE,wBAAwB,CAAC,CAAC,CAAC,GAC7B,WAAW,CAAC,CAAC,CAAC,CA6WhB"}
|
|
@@ -1,33 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
import { useNavigate, useRouter, useRouterState, useSearch } from "@tanstack/react-router";
|
|
2
3
|
import { createStoreCore } from "../state/fields.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
);
|
|
8
|
-
}
|
|
9
|
-
function useCurrentSearch() {
|
|
10
|
-
const search = useSearch({ strict: false });
|
|
11
|
-
return typeof search === "object" && search !== null ? search : {};
|
|
4
|
+
import { createStoreWarnings } from "./search-store-warnings.js";
|
|
5
|
+
let hydrationDone = false;
|
|
6
|
+
function resetHydrationForTests() {
|
|
7
|
+
hydrationDone = false;
|
|
12
8
|
}
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
const isDehydrating = () => typeof window !== "undefined" && "$_TSR" in window && !hydrationDone;
|
|
10
|
+
function reportFailure(error) {
|
|
11
|
+
if (typeof reportError === "function") reportError(error);
|
|
12
|
+
else
|
|
13
|
+
queueMicrotask(() => {
|
|
14
|
+
throw error;
|
|
15
|
+
});
|
|
15
16
|
}
|
|
16
|
-
function
|
|
17
|
-
const {
|
|
18
|
-
|
|
19
|
-
`[basalt-ui] createSearchStore('${key}'): wrote field '${name}' from a route that does not validate \`${param}\`, and the field is \`persist: false\` \u2014 so the write was dropped. Either render this control on the route wired to \`validateSearch\`, or give the field the localStorage lane (drop \`persist: false\`) so a write from elsewhere survives until the owning route reads it. (dev only)`
|
|
20
|
-
);
|
|
17
|
+
function navigateSearch(navigate, search, replace) {
|
|
18
|
+
const result = navigate({ to: ".", search, replace, resetScroll: false });
|
|
19
|
+
if (result !== void 0) result.catch(reportFailure);
|
|
21
20
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
return `basalt-ui: createSearchStore('${key}'): set('${name}', \u2026, { patch }) carries \`${param}\`, which this store's field '${owner}' owns \u2014 the URL would take it while the localStorage mirror kept the old value, so the next paramless visit and every \`linkSearch\` link disagree with the page the write happened on. Write it through \`field.${owner}.use()[1]\` instead; a \`patch\` is for keys the store does NOT own.`;
|
|
21
|
+
function isRecord(value) {
|
|
22
|
+
return typeof value === "object" && value !== null;
|
|
25
23
|
}
|
|
26
|
-
function
|
|
27
|
-
const {
|
|
28
|
-
|
|
29
|
-
`[basalt-ui] createSearchStore('${key}'): wrote field '${name}' with a \`patch\` from a route that does not validate \`${param}\` \u2014 the field's value persisted (A1), but the patch was DROPPED: there is no navigate to merge it into. Render the control on the route wired to \`validateSearch\`, or apply that sibling param on the route that owns it. (dev only)`
|
|
30
|
-
);
|
|
24
|
+
function useCurrentSearch() {
|
|
25
|
+
const search = useSearch({ strict: false });
|
|
26
|
+
return isRecord(search) ? search : {};
|
|
31
27
|
}
|
|
32
28
|
function assertNoLazyUrlFallback(key, fields) {
|
|
33
29
|
for (const [name, f] of Object.entries(fields)) {
|
|
@@ -50,17 +46,14 @@ function assertResetsNotOwned(input) {
|
|
|
50
46
|
function isMemoryLane(entry) {
|
|
51
47
|
return !entry.codec.lane.url && !entry.codec.lane.persist;
|
|
52
48
|
}
|
|
53
|
-
function
|
|
49
|
+
function createSearchStore(o) {
|
|
54
50
|
assertNoLazyUrlFallback(o.key, o.fields);
|
|
55
51
|
const core = createStoreCore(o);
|
|
56
52
|
let readerWired = false;
|
|
57
|
-
let warned = false;
|
|
58
53
|
const markReaderWired = () => {
|
|
59
54
|
readerWired = true;
|
|
60
55
|
};
|
|
61
|
-
const
|
|
62
|
-
const patchDroppedWarned = /* @__PURE__ */ new Set();
|
|
63
|
-
const patchOwnerLogged = /* @__PURE__ */ new Set();
|
|
56
|
+
const warnings = createStoreWarnings(o.key);
|
|
64
57
|
const paramOwners = /* @__PURE__ */ new Map();
|
|
65
58
|
for (const entry of core.urlEntries) {
|
|
66
59
|
for (const param of entry.codec.params) paramOwners.set(param, entry.name);
|
|
@@ -77,16 +70,12 @@ function buildSearchStore(o) {
|
|
|
77
70
|
const persistedNames = new Set(
|
|
78
71
|
core.entries.filter((entry) => entry.codec.lane.persist).map((entry) => entry.name)
|
|
79
72
|
);
|
|
80
|
-
const
|
|
73
|
+
const mounts = /* @__PURE__ */ new Map();
|
|
81
74
|
const assertPatchNotOwned = (entry, patch) => {
|
|
82
75
|
for (const param of Object.keys(patch)) {
|
|
83
76
|
const owner = paramOwners.get(param);
|
|
84
77
|
if (owner === void 0 || entry.codec.params.includes(param)) continue;
|
|
85
|
-
|
|
86
|
-
if (process.env["NODE_ENV"] !== "production") throw new Error(message);
|
|
87
|
-
if (patchOwnerLogged.has(param)) continue;
|
|
88
|
-
patchOwnerLogged.add(param);
|
|
89
|
-
console.error(message);
|
|
78
|
+
warnings.patchOwned({ name: entry.name, owner, param });
|
|
90
79
|
}
|
|
91
80
|
};
|
|
92
81
|
const flatten = (search, record) => {
|
|
@@ -97,30 +86,33 @@ function buildSearchStore(o) {
|
|
|
97
86
|
return out;
|
|
98
87
|
};
|
|
99
88
|
const maybeWarn = (raw, record) => {
|
|
100
|
-
if (
|
|
89
|
+
if (process.env["NODE_ENV"] === "production" || readerWired) return;
|
|
101
90
|
for (const entry of core.urlEntries) {
|
|
102
91
|
const fromUrl = entry.codec.fromSearch(raw);
|
|
103
92
|
if (fromUrl === null || !entry.codec.equals(fromUrl, entry.codec.fallback)) continue;
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
106
|
-
|
|
107
|
-
warnLinkPinsFallback({
|
|
108
|
-
key: o.key,
|
|
93
|
+
const stored2 = entry.codec.decode(record[entry.name]);
|
|
94
|
+
if (stored2 === null || entry.codec.equals(stored2, fromUrl)) continue;
|
|
95
|
+
warnings.linkPinsFallback({
|
|
109
96
|
param: entry.codec.primary,
|
|
110
|
-
urlValue:
|
|
111
|
-
storedValue:
|
|
97
|
+
urlValue: entry.codec.toSearch(fromUrl)[entry.codec.primary],
|
|
98
|
+
storedValue: entry.codec.toSearch(stored2)[entry.codec.primary]
|
|
112
99
|
});
|
|
113
100
|
return;
|
|
114
101
|
}
|
|
115
102
|
};
|
|
103
|
+
const stored = () => typeof window === "undefined" || isDehydrating() ? {} : core.readRecord();
|
|
116
104
|
const validateSearch = (raw) => {
|
|
117
|
-
const record =
|
|
105
|
+
const record = stored();
|
|
118
106
|
maybeWarn(raw, record);
|
|
119
107
|
return flatten(raw, record);
|
|
120
108
|
};
|
|
109
|
+
const runsStore = (route) => {
|
|
110
|
+
const validate = route?.options.validateSearch;
|
|
111
|
+
return typeof validate === "function" && (validate === validateSearch || Function.prototype.toString.call(validate).includes("validateSearch"));
|
|
112
|
+
};
|
|
121
113
|
const linkSearch = () => {
|
|
122
114
|
readerWired = true;
|
|
123
|
-
return flatten(null,
|
|
115
|
+
return flatten(null, stored());
|
|
124
116
|
};
|
|
125
117
|
const readStored = () => {
|
|
126
118
|
readerWired = true;
|
|
@@ -129,65 +121,72 @@ function buildSearchStore(o) {
|
|
|
129
121
|
const urlUse = (entry) => () => {
|
|
130
122
|
const search = useCurrentSearch();
|
|
131
123
|
const navigate = useNavigate();
|
|
124
|
+
const router = useRouter();
|
|
125
|
+
const pathname = useRouterState({ select: (state) => state.location.pathname });
|
|
132
126
|
const [record, setRecord] = core.usePersistedRecord();
|
|
133
127
|
markReaderWired();
|
|
134
128
|
const value = core.resolve(entry, search, record);
|
|
129
|
+
const hydrating = useRef(isDehydrating());
|
|
135
130
|
const validated = Object.hasOwn(search, entry.codec.primary);
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
const count = mounts.get(router) ?? 0;
|
|
133
|
+
mounts.set(router, count + 1);
|
|
134
|
+
return () => {
|
|
135
|
+
const left = (mounts.get(router) ?? 1) - 1;
|
|
136
|
+
if (left > 0) mounts.set(router, left);
|
|
137
|
+
else mounts.delete(router);
|
|
138
|
+
};
|
|
139
|
+
}, [router]);
|
|
140
|
+
useEffect(() => {
|
|
141
|
+
if (hydrating.current) hydrationDone = true;
|
|
142
|
+
}, []);
|
|
143
|
+
const mirrored = entry.codec.lane.persist ? entry.codec.decode(record[entry.name]) : null;
|
|
144
|
+
const mirroredKey = mirrored === null ? null : JSON.stringify(entry.codec.toSearch(mirrored));
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
if (!hydrating.current || mirrored === null) return;
|
|
147
|
+
hydrating.current = false;
|
|
148
|
+
if (!validated || entry.codec.equals(mirrored, entry.codec.fallback)) return;
|
|
149
|
+
const urlValue = entry.codec.fromSearch(search);
|
|
150
|
+
if (urlValue !== null && !entry.codec.equals(urlValue, entry.codec.fallback)) return;
|
|
151
|
+
navigateSearch(
|
|
152
|
+
(o2) => router.navigate(o2),
|
|
153
|
+
(prev) => ({ ...prev, ...entry.codec.toSearch(mirrored) }),
|
|
154
|
+
true
|
|
155
|
+
);
|
|
156
|
+
}, [mirroredKey]);
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
if (process.env["NODE_ENV"] === "production") return;
|
|
159
|
+
const { matches } = router.state;
|
|
160
|
+
const leaf = matches.at(-1);
|
|
161
|
+
if (leaf === void 0 || !isRecord(leaf.search)) return;
|
|
162
|
+
if (!Object.hasOwn(leaf.search, entry.codec.primary)) return;
|
|
163
|
+
if (matches.some((match) => runsStore(router.routesById[match.routeId]))) return;
|
|
164
|
+
warnings.foreignParam({ name: entry.name, param: entry.codec.primary, path: leaf.pathname });
|
|
165
|
+
}, [pathname]);
|
|
150
166
|
return [
|
|
151
167
|
value,
|
|
152
168
|
(next, opts) => {
|
|
153
169
|
const patch = opts?.patch;
|
|
154
170
|
if (patch !== void 0 && Object.keys(patch).length > 0) {
|
|
155
171
|
assertPatchNotOwned(entry, patch);
|
|
156
|
-
if (!validated
|
|
157
|
-
patchDroppedWarned.add(entry.name);
|
|
158
|
-
warnPatchDropped({ key: o.key, name: entry.name, param: entry.codec.primary });
|
|
159
|
-
}
|
|
172
|
+
if (!validated) warnings.patchWasDropped({ name: entry.name, param: entry.codec.primary });
|
|
160
173
|
}
|
|
161
|
-
if (validated) {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
// `patch` FIRST, the field's own params last: a patch is for keys the store does not
|
|
165
|
-
// own (clearing a sibling `detailDate` with `undefined`), so it must never be able to
|
|
166
|
-
// overwrite the value this very call is setting.
|
|
167
|
-
// `resets` only when the value moves: a no-op write (a debounced box settling back on
|
|
168
|
-
// what it held) must not throw the reader off the page they are on.
|
|
169
|
-
search: (prev) => ({
|
|
170
|
-
...prev,
|
|
171
|
-
...resetsFor(entry, prev, next),
|
|
172
|
-
...opts?.patch,
|
|
173
|
-
...entry.codec.toSearch(next)
|
|
174
|
-
}),
|
|
175
|
-
replace: entry.codec.lane.history === "replace",
|
|
176
|
-
// A filter lives halfway down a page as often as it lives in the bar, and the router's
|
|
177
|
-
// default scroll restoration treats this same-route search write as a navigation — so
|
|
178
|
-
// without this a select two screens down jumps the reader back to the top on every
|
|
179
|
-
// change. Never a prop: there is no filter write that WANTS the page to scroll.
|
|
180
|
-
resetScroll: false
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
if (entry.codec.lane.persist) {
|
|
184
|
-
core.writeField(setRecord, entry.name, next);
|
|
174
|
+
if (!validated) {
|
|
175
|
+
if (entry.codec.lane.persist) core.writeField(setRecord, entry.name, next);
|
|
176
|
+
else warnings.writeHasNowhereToGo({ name: entry.name, param: entry.codec.primary });
|
|
185
177
|
return;
|
|
186
178
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
179
|
+
navigateSearch(
|
|
180
|
+
(o2) => navigate(o2),
|
|
181
|
+
(prev) => ({
|
|
182
|
+
...prev,
|
|
183
|
+
...resetsFor(entry, prev, next),
|
|
184
|
+
...opts?.patch,
|
|
185
|
+
...entry.codec.toSearch(next)
|
|
186
|
+
}),
|
|
187
|
+
entry.codec.lane.history === "replace"
|
|
188
|
+
);
|
|
189
|
+
if (entry.codec.lane.persist) core.writeField(setRecord, entry.name, next);
|
|
191
190
|
}
|
|
192
191
|
];
|
|
193
192
|
};
|
|
@@ -204,8 +203,19 @@ function buildSearchStore(o) {
|
|
|
204
203
|
if (entry.codec.lane.persist) core.clearField(entry.name);
|
|
205
204
|
else if (!entry.codec.lane.url) core.clearMemory(entry.name);
|
|
206
205
|
if (!entry.codec.lane.url) return;
|
|
207
|
-
const
|
|
208
|
-
|
|
206
|
+
for (const router of mounts.keys()) {
|
|
207
|
+
const { search } = router.state.location;
|
|
208
|
+
if (!isRecord(search) || !Object.hasOwn(search, entry.codec.primary)) continue;
|
|
209
|
+
navigateSearch(
|
|
210
|
+
(o2) => router.navigate(o2),
|
|
211
|
+
(prev) => ({
|
|
212
|
+
...prev,
|
|
213
|
+
...resetsFor(entry, prev, entry.codec.fallback),
|
|
214
|
+
...entry.codec.toSearch(entry.codec.fallback)
|
|
215
|
+
}),
|
|
216
|
+
true
|
|
217
|
+
);
|
|
218
|
+
}
|
|
209
219
|
};
|
|
210
220
|
const field = {};
|
|
211
221
|
for (const entry of core.entries) {
|
|
@@ -246,22 +256,16 @@ function buildSearchStore(o) {
|
|
|
246
256
|
for (const entry of validatedEntries) {
|
|
247
257
|
Object.assign(patch, entry.codec.toSearch(entry.codec.fallback));
|
|
248
258
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
// `clear()`. A `Reset all` with everything already at its fallback must keep the page:
|
|
253
|
-
// this navigate REPLACES, so a page dropped here could not be got back with Back.
|
|
254
|
-
search: (prev) => {
|
|
259
|
+
navigateSearch(
|
|
260
|
+
(o2) => navigate(o2),
|
|
261
|
+
(prev) => {
|
|
255
262
|
const moved = validatedEntries.some(
|
|
256
263
|
(entry) => resetsFor(entry, prev, entry.codec.fallback) !== void 0
|
|
257
264
|
);
|
|
258
265
|
return { ...prev, ...moved ? resetPatch : void 0, ...patch };
|
|
259
266
|
},
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
// sheet must not also scroll the page it was pressed on.
|
|
263
|
-
resetScroll: false
|
|
264
|
-
});
|
|
267
|
+
true
|
|
268
|
+
);
|
|
265
269
|
}
|
|
266
270
|
if (memoryEntries.length > 0) core.resetMemory();
|
|
267
271
|
if (!core.anyPersisted) return;
|
|
@@ -293,10 +297,7 @@ function buildSearchStore(o) {
|
|
|
293
297
|
};
|
|
294
298
|
return store;
|
|
295
299
|
}
|
|
296
|
-
function createSearchStore(o) {
|
|
297
|
-
return buildSearchStore(o);
|
|
298
|
-
}
|
|
299
300
|
export {
|
|
300
|
-
|
|
301
|
-
|
|
301
|
+
createSearchStore,
|
|
302
|
+
resetHydrationForTests
|
|
302
303
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createElement, forwardRef, useMemo } from "react";
|
|
2
2
|
import { Link, useMatchRoute, useRouterState } from "@tanstack/react-router";
|
|
3
|
-
import { flattenNav } from "./nav.js";
|
|
3
|
+
import { flattenNav } from "./nav-stash.js";
|
|
4
4
|
const OverriddenAnchor = forwardRef((props, ref) => {
|
|
5
5
|
const {
|
|
6
6
|
"aria-current": _routerCurrent,
|
package/dist/surfaces.d.ts
CHANGED
|
@@ -248,7 +248,7 @@ export declare const SURFACES: {
|
|
|
248
248
|
readonly skill: readonly ["basalt-app"];
|
|
249
249
|
readonly guardKinds: readonly [];
|
|
250
250
|
readonly pluginRules: readonly [];
|
|
251
|
-
readonly description: "defineCommands (typed command bus), defineOverlays/overlays (a form dialog is a registered overlay opened with overlays.open), setColorScheme, toggleSidebar, ShortcutsHelp, defineNotifications/emit/NotificationBell (emit only accepts kinds registered in defineNotifications; folded in from ./notifications); BasaltProvider mounts Spotlight, Modals
|
|
251
|
+
readonly description: "defineCommands (typed command bus), defineOverlays/overlays (a form dialog is a registered overlay opened with overlays.open), setColorScheme, toggleSidebar, ShortcutsHelp, defineNotifications/emit/NotificationBell (emit only accepts kinds registered in defineNotifications; folded in from ./notifications); BasaltProvider mounts Notifications; Spotlight mounts once defineNav/defineCommands ran, Modals once defineOverlays/overlays.confirm ran";
|
|
252
252
|
readonly optionalPeers: readonly ["@tanstack/react-hotkeys"];
|
|
253
253
|
readonly forbiddenImports: readonly [];
|
|
254
254
|
};
|
package/dist/surfaces.js
CHANGED
|
@@ -207,7 +207,7 @@ const SURFACES = {
|
|
|
207
207
|
skill: ["basalt-app"],
|
|
208
208
|
guardKinds: [],
|
|
209
209
|
pluginRules: [],
|
|
210
|
-
description: "defineCommands (typed command bus), defineOverlays/overlays (a form dialog is a registered overlay opened with overlays.open), setColorScheme, toggleSidebar, ShortcutsHelp, defineNotifications/emit/NotificationBell (emit only accepts kinds registered in defineNotifications; folded in from ./notifications); BasaltProvider mounts Spotlight, Modals
|
|
210
|
+
description: "defineCommands (typed command bus), defineOverlays/overlays (a form dialog is a registered overlay opened with overlays.open), setColorScheme, toggleSidebar, ShortcutsHelp, defineNotifications/emit/NotificationBell (emit only accepts kinds registered in defineNotifications; folded in from ./notifications); BasaltProvider mounts Notifications; Spotlight mounts once defineNav/defineCommands ran, Modals once defineOverlays/overlays.confirm ran",
|
|
211
211
|
optionalPeers: ["@tanstack/react-hotkeys"],
|
|
212
212
|
forbiddenImports: []
|
|
213
213
|
},
|