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
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import { HotkeyBinder } from "../provider/hotkeys.js";
|
|
2
|
+
import { registerSlot } from "../provider/slots.js";
|
|
3
|
+
import { SpotlightMount } from "../provider/spotlight-mount.js";
|
|
4
|
+
import { setActiveCommands } from "./command-stash.js";
|
|
2
5
|
function defineCommands(spec) {
|
|
3
|
-
|
|
6
|
+
setActiveCommands(spec);
|
|
7
|
+
registerSlot("spotlight", SpotlightMount);
|
|
8
|
+
if (Object.values(spec).some((c) => c.shortcut !== void 0))
|
|
9
|
+
registerSlot("hotkeys", HotkeyBinder);
|
|
4
10
|
return spec;
|
|
5
11
|
}
|
|
6
12
|
function defineCommand(cmd) {
|
|
7
13
|
return cmd;
|
|
8
14
|
}
|
|
9
|
-
function getActiveCommands() {
|
|
10
|
-
return activeCommands;
|
|
11
|
-
}
|
|
12
15
|
export {
|
|
13
16
|
defineCommand,
|
|
14
|
-
defineCommands
|
|
15
|
-
getActiveCommands
|
|
17
|
+
defineCommands
|
|
16
18
|
};
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
* A form dialog is an entry whose `render` returns the form; open it from a row action with
|
|
9
9
|
* `overlays.open('id', props)` and put its component in a `*-modal.tsx`.
|
|
10
10
|
*
|
|
11
|
-
* Uses @mantine/modals under the hood.
|
|
11
|
+
* Uses @mantine/modals under the hood. Calling `defineOverlays` registers the `ModalsProvider` mount
|
|
12
|
+
* (a sibling of the router, in `BasaltProvider`) — an app that defines none ships none of the peer.
|
|
12
13
|
*
|
|
13
14
|
* @example
|
|
14
15
|
* // overlays.ts (app-side)
|
|
@@ -30,13 +31,6 @@
|
|
|
30
31
|
*/
|
|
31
32
|
import type { ReactNode } from 'react';
|
|
32
33
|
import type { Slot } from '../register.js';
|
|
33
|
-
/**
|
|
34
|
-
* Internal — `BasaltProvider` declares its `ModalsProvider` as live for as long as it is mounted,
|
|
35
|
-
* and gets back the function that retracts it. There is no way to detect the provider from outside
|
|
36
|
-
* React (its context is only readable through `useModals()`, and `confirm` is an imperative call),
|
|
37
|
-
* so the registration is explicit. Not on the `./commands` barrel.
|
|
38
|
-
*/
|
|
39
|
-
export declare function registerModalsProvider(): () => void;
|
|
40
34
|
/**
|
|
41
35
|
* A single registered overlay. The per-overlay props type P is the consumer's own payload.
|
|
42
36
|
*
|
|
@@ -137,10 +131,10 @@ export type ConfirmDeleteOptions = {
|
|
|
137
131
|
* other exit (cancel, escape, click-outside, the close button). `onConfirm`/`onCancel` fire exactly
|
|
138
132
|
* once each at most, before the promise settles.
|
|
139
133
|
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
134
|
+
* The first call registers the modals mount and waits for the `BasaltProvider` to commit it — a tick
|
|
135
|
+
* normally, up to 5 s while a provider is mounted and busy. Rejects with a named `[basalt]` error when
|
|
136
|
+
* no `BasaltProvider` is mounted (after a 500 ms grace for one mounting now): the imperative API is a
|
|
137
|
+
* window event bus, and with nothing subscribed the promise would stay pending forever.
|
|
144
138
|
*
|
|
145
139
|
* @example
|
|
146
140
|
* if (await overlays.confirm({ title: 'Discard draft?', onConfirm: () => reset() })) navigate('/')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define-overlays.d.ts","sourceRoot":"","sources":["../../src/commands/define-overlays.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"define-overlays.d.ts","sourceRoot":"","sources":["../../src/commands/define-overlays.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEtC,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AASvC;;;;;;;;GAQG;AAEH,MAAM,MAAM,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IACjD,yDAAyD;IACzD,KAAK,CAAC,EAAE,SAAS,CAAA;IACjB,iDAAiD;IACjD,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,SAAS,CAAA;CAChC,CAAA;AAED;;;;;;;GAOG;AAEH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAA;AAIrD,wEAAwE;AACxE,KAAK,QAAQ,GAAG,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;AAE5C;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,QAAQ,EAAE,MAAM,CAAC,CAAA;AAaxD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,KAAK,CAAC,CAAC,SAAS,UAAU,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAIrE;AAID;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAE1F;AAID,8FAA8F;AAC9F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+1,11 @@
|
|
|
1
1
|
import { missingLayer } from "../common/errors.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return modalsPromise;
|
|
6
|
-
}
|
|
7
|
-
let mountedModalsProviders = 0;
|
|
8
|
-
function registerModalsProvider() {
|
|
9
|
-
mountedModalsProviders++;
|
|
10
|
-
let released = false;
|
|
11
|
-
return () => {
|
|
12
|
-
if (released) return;
|
|
13
|
-
released = true;
|
|
14
|
-
mountedModalsProviders--;
|
|
15
|
-
};
|
|
16
|
-
}
|
|
2
|
+
import { modals } from "@mantine/modals";
|
|
3
|
+
import { ensureModalsMount, registerModalsMount } from "../provider/modals-mount.js";
|
|
4
|
+
let closeGeneration = 0;
|
|
17
5
|
let activeOverlays = {};
|
|
18
6
|
function defineOverlays(spec) {
|
|
19
7
|
activeOverlays = spec;
|
|
8
|
+
registerModalsMount();
|
|
20
9
|
return spec;
|
|
21
10
|
}
|
|
22
11
|
function defineOverlay(overlay) {
|
|
@@ -32,17 +21,13 @@ async function confirm(options) {
|
|
|
32
21
|
onConfirm,
|
|
33
22
|
onCancel
|
|
34
23
|
} = options;
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"@mantine/modals",
|
|
41
|
-
"install the @mantine/modals peer and mount <BasaltProvider>"
|
|
42
|
-
)
|
|
43
|
-
);
|
|
24
|
+
const startedAt = closeGeneration;
|
|
25
|
+
const live = await ensureModalsMount();
|
|
26
|
+
if (startedAt !== closeGeneration) {
|
|
27
|
+
onCancel?.();
|
|
28
|
+
return false;
|
|
44
29
|
}
|
|
45
|
-
if (
|
|
30
|
+
if (!live) {
|
|
46
31
|
throw new Error(
|
|
47
32
|
missingLayer(
|
|
48
33
|
"overlays.confirm",
|
|
@@ -107,12 +92,21 @@ const overlays = {
|
|
|
107
92
|
console.warn(`[basalt] overlays.open: no overlay registered for "${String(key)}"`);
|
|
108
93
|
return;
|
|
109
94
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
95
|
+
const startedAt = closeGeneration;
|
|
96
|
+
void ensureModalsMount().then((live) => {
|
|
97
|
+
if (startedAt !== closeGeneration) return;
|
|
98
|
+
if (!live) {
|
|
99
|
+
if (process.env.NODE_ENV !== "production") {
|
|
100
|
+
console.warn("[basalt] overlays.open: no mounted <BasaltProvider> to show the overlay");
|
|
101
|
+
}
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
modals.open({ title: spec.title, children: spec.render(props) });
|
|
106
|
+
} catch (error) {
|
|
107
|
+
if (process.env.NODE_ENV !== "production") console.error("[basalt] overlay failed", error);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
116
110
|
},
|
|
117
111
|
/**
|
|
118
112
|
* Open a confirm dialog and resolve to the answer — see {@link confirm}.
|
|
@@ -135,12 +129,12 @@ const overlays = {
|
|
|
135
129
|
* overlays.close()
|
|
136
130
|
*/
|
|
137
131
|
close() {
|
|
138
|
-
|
|
132
|
+
closeGeneration++;
|
|
133
|
+
modals.closeAll();
|
|
139
134
|
}
|
|
140
135
|
};
|
|
141
136
|
export {
|
|
142
137
|
defineOverlay,
|
|
143
138
|
defineOverlays,
|
|
144
|
-
overlays
|
|
145
|
-
registerModalsProvider
|
|
139
|
+
overlays
|
|
146
140
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fonts-hint.d.ts","sourceRoot":"","sources":["../../src/guard/fonts-hint.ts"],"names":[],"mappings":"AAAA,uGAAuG;AACvG,eAAO,MAAM,cAAc,kEAAkE,CAAA"}
|
package/dist/guard/index.d.ts
CHANGED
|
@@ -174,7 +174,7 @@ export declare const GUARD_RULES: {
|
|
|
174
174
|
readonly 'raw-font-family': {
|
|
175
175
|
readonly kind: "raw-font-family";
|
|
176
176
|
readonly pattern: RegExp;
|
|
177
|
-
readonly message: "Route the font stack through createBasaltTheme(overrides, { fonts }) / the shipped --basalt-font-sans|head|mono vars instead of a hardcoded fontFamily literal.";
|
|
177
|
+
readonly message: "Route the font stack through createBasaltTheme(overrides, { fonts }) / the shipped --basalt-font-sans|head|mono vars instead of a hardcoded fontFamily literal (provider-free page: `basalt-ui fonts:css --out src/fonts.css`).";
|
|
178
178
|
};
|
|
179
179
|
readonly 'off-identity-accent': {
|
|
180
180
|
readonly kind: "off-identity-accent";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/guard/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/guard/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAM7E,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,aAAa,EAAE,CAAA;AAgU9D;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CA8BpE,CAAA;AA8cD,8EAA8E;AAC9E,eAAO,MAAM,oBAAoB,EAAE,WAiBlC,CAAA;AAED;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AAExE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,eAAO,MAAM,kBAAkB,EAAE,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,CAAM,CAAA;AAoF5E,sGAAsG;A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ANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { vxFamilyOf } from "../common/vx-family.js";
|
|
2
2
|
import { BASALT_VX_FAMILIES } from "../common/vx-families.js";
|
|
3
|
+
import { FONTS_CSS_HINT } from "./fonts-hint.js";
|
|
3
4
|
import { BASALT_VX_NAMES } from "./vx-names.js";
|
|
4
5
|
const HEX = /#(?!(?<=&#)\d+;)[0-9a-fA-F]{3,8}\b/g;
|
|
5
6
|
const FUNC = /\b(?:rgba?|hsla?)\((?!\s*\$\{)/g;
|
|
@@ -748,7 +749,7 @@ const GUARD_RULES = {
|
|
|
748
749
|
"raw-font-family": {
|
|
749
750
|
kind: "raw-font-family",
|
|
750
751
|
pattern: RAW_FONT_FAMILY,
|
|
751
|
-
message:
|
|
752
|
+
message: `Route the font stack through createBasaltTheme(overrides, { fonts }) / the shipped --basalt-font-sans|head|mono vars instead of a hardcoded fontFamily literal (${FONTS_CSS_HINT}).`
|
|
752
753
|
},
|
|
753
754
|
"off-identity-accent": {
|
|
754
755
|
kind: "off-identity-accent",
|
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* `@mantine/*`. One import path per symbol: `docs/V2-SPEC.md` § 1; the per-symbol verdicts are
|
|
6
6
|
* `docs/waves/v2-surface.md`.
|
|
7
7
|
*/
|
|
8
|
-
export { BasaltProvider } from './provider/index.js';
|
|
9
|
-
export { createBasaltRouter, type BasaltRouter, type BasaltRouterContext, } from './provider/create-router.js';
|
|
8
|
+
export { BasaltProvider, type BasaltProviderProps } from './provider/index.js';
|
|
9
|
+
export { basaltRouterOptions, createBasaltRouter, type BasaltRouter, type BasaltRouterOptions, type BasaltRouterContext, } from './provider/create-router.js';
|
|
10
10
|
export type { BasaltEvent, ChatTurnEnd, ChatTurnTrace, Telemetry, TraceHeaders } from './telemetry.js';
|
|
11
11
|
export { defineNav, navGroup, navTarget, flattenNav, useBasaltNav, type NavItemId, } from './router-tanstack/index.js';
|
|
12
12
|
export { scrollParentOf, useCoarsePointer, type Tone } from './common/index.js';
|
|
@@ -14,6 +14,6 @@ export { createBasaltTheme } from './theme/index.js';
|
|
|
14
14
|
export { ThemeToggle } from './theme/theme-toggle.js';
|
|
15
15
|
export { BasaltShell, PageBar, PageAside, useSizeClass, PageTitle, type ShellBaseProps, type SidebarBlock, type SettingsMenuItem, } from './shell/index.js';
|
|
16
16
|
export { WidgetHeader, DeltaBadge, Section, StatCard, type StatCardBreakdownRow, type StatCardSparklineSize, StatGroup, EmptyState, SettingsSection, SettingsRow, DangerZone, } from './dashboard/index.js';
|
|
17
|
-
export { unwrap } from './
|
|
17
|
+
export { unwrap } from './unwrap.js';
|
|
18
18
|
export type { BasaltRegister, SeriesKey } from './register.js';
|
|
19
19
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACrE,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,GACzB,MAAM,0BAA0B,CAAA;AACjC,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AACnG,OAAO,EACL,SAAS,EACT,QAAQ,EACR,SAAS,EACT,UAAU,EACV,YAAY,EACZ,KAAK,SAAS,GACf,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,KAAK,IAAI,EAAE,MAAM,UAAU,CAAA;AACtE,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAA;AAClD,OAAO,EACL,WAAW,EACX,OAAO,EACP,SAAS,EACT,YAAY,EACZ,SAAS,EACT,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,gBAAgB,GACtB,MAAM,SAAS,CAAA;AAChB,OAAO,EACL,YAAY,EACZ,UAAU,EACV,OAAO,EACP,QAAQ,EACR,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,SAAS,EACT,UAAU,EACV,eAAe,EACf,WAAW,EACX,UAAU,GACX,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAMjC,YAAY,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BasaltProvider } from "./provider/index.js";
|
|
2
2
|
import {
|
|
3
|
+
basaltRouterOptions,
|
|
3
4
|
createBasaltRouter
|
|
4
5
|
} from "./provider/create-router.js";
|
|
5
6
|
import {
|
|
@@ -30,7 +31,7 @@ import {
|
|
|
30
31
|
SettingsRow,
|
|
31
32
|
DangerZone
|
|
32
33
|
} from "./dashboard/index.js";
|
|
33
|
-
import { unwrap } from "./
|
|
34
|
+
import { unwrap } from "./unwrap.js";
|
|
34
35
|
export {
|
|
35
36
|
BasaltProvider,
|
|
36
37
|
BasaltShell,
|
|
@@ -47,6 +48,7 @@ export {
|
|
|
47
48
|
StatGroup,
|
|
48
49
|
ThemeToggle,
|
|
49
50
|
WidgetHeader,
|
|
51
|
+
basaltRouterOptions,
|
|
50
52
|
createBasaltRouter,
|
|
51
53
|
createBasaltTheme,
|
|
52
54
|
defineNav,
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import type { QueryClient, QueryClientConfig } from '@tanstack/react-query';
|
|
2
2
|
import { Router } from '@tanstack/react-router';
|
|
3
|
-
import type { AnyRoute, RouterHistory } from '@tanstack/react-router';
|
|
3
|
+
import type { AnyRoute, ErrorComponentProps, RouterHistory } from '@tanstack/react-router';
|
|
4
|
+
import type { RouterHook } from '../telemetry.js';
|
|
5
|
+
import { routeViewTransition } from './route-transition.js';
|
|
4
6
|
/** The root route's context: `createRootRouteWithContext<BasaltRouterContext>()`. */
|
|
5
7
|
export type BasaltRouterContext = {
|
|
6
8
|
queryClient: QueryClient;
|
|
9
|
+
/** Set by `basaltRouterOptions`; the mounted provider points `onRouteError` at its emitter. */
|
|
10
|
+
__basalt?: RouterHook;
|
|
7
11
|
};
|
|
8
12
|
type BasaltRouterBase<TRouteTree extends AnyRoute> = Router<TRouteTree, 'never', false, RouterHistory, Record<string, any>>;
|
|
9
13
|
declare const basaltRouterBrand: unique symbol;
|
|
@@ -18,11 +22,59 @@ declare const basaltRouterBrand: unique symbol;
|
|
|
18
22
|
export type BasaltRouter<TRouteTree extends AnyRoute = any> = BasaltRouterBase<TRouteTree> & {
|
|
19
23
|
readonly [basaltRouterBrand]: true;
|
|
20
24
|
};
|
|
25
|
+
declare function PendingComponent(): import("react").JSX.Element;
|
|
26
|
+
declare function ErrorComponent({ error, reset }: ErrorComponentProps): import("react").JSX.Element;
|
|
27
|
+
declare function NotFoundComponent(): import("react").JSX.Element;
|
|
28
|
+
/** The options `createBasaltRouter` owns. Each is `never` on it: basalt's, not a consumer knob. */
|
|
29
|
+
type ManagedKeys = Exclude<keyof BasaltRouterOptions, 'context'>;
|
|
30
|
+
/** `queryClient` and `__basalt` are basalt's: a consumer's would be replaced, so the type rejects them. */
|
|
31
|
+
type ExtraContext = {
|
|
32
|
+
queryClient?: never;
|
|
33
|
+
__basalt?: never;
|
|
34
|
+
};
|
|
35
|
+
type NoContext = Record<never, never>;
|
|
36
|
+
type RouterOptionsInput<TContext extends object> = {
|
|
37
|
+
/** Context beyond `queryClient`; the root route's context type extends `BasaltRouterContext`. */
|
|
38
|
+
context?: (TContext & ExtraContext) | undefined;
|
|
39
|
+
/** Merged over basalt's QueryClient defaults (`staleTime` 30 s, `gcTime` 5 min, `retry` twice, never a 4xx but 408/425/429, no refetch on focus). */
|
|
40
|
+
query?: QueryClientConfig | undefined;
|
|
41
|
+
};
|
|
42
|
+
/** What `basaltRouterOptions` returns: the router options basalt owns, plus the context. */
|
|
43
|
+
export type BasaltRouterOptions<TContext extends object = NoContext> = {
|
|
44
|
+
context: TContext & BasaltRouterContext;
|
|
45
|
+
defaultPreload: 'intent';
|
|
46
|
+
defaultPreloadStaleTime: number;
|
|
47
|
+
scrollRestoration: boolean;
|
|
48
|
+
/** Route transitions are basalt's (V2-SPEC § 5): the router's own would double them. */
|
|
49
|
+
defaultViewTransition: typeof routeViewTransition | false;
|
|
50
|
+
defaultPendingComponent: typeof PendingComponent;
|
|
51
|
+
defaultErrorComponent: typeof ErrorComponent;
|
|
52
|
+
defaultNotFoundComponent: typeof NotFoundComponent;
|
|
53
|
+
defaultOnCatch: (error: unknown) => void;
|
|
54
|
+
};
|
|
21
55
|
/**
|
|
56
|
+
* Everything `createBasaltRouter` sets, for a router the app builds itself (TanStack Start's
|
|
57
|
+
* `getRouter()`): spread it into `createRouter`, and the provider mounted inside gets `route.error`
|
|
58
|
+
* telemetry, intent preloading, the route transition and the default pending/error/not-found UI.
|
|
59
|
+
* A `TContext` with required keys makes `context` required. Spread it LAST: the keys are basalt's.
|
|
22
60
|
* Side effect, once per document: wraps `document.startViewTransition` so a skipped route
|
|
23
61
|
* transition (`AbortError`) never becomes an unhandled rejection (`guardViewTransitionRejections`).
|
|
24
|
-
* Nothing else global is touched.
|
|
25
62
|
*
|
|
63
|
+
* @example
|
|
64
|
+
* export const getRouter = () => createRouter({ routeTree, ...basaltRouterOptions() })
|
|
65
|
+
*/
|
|
66
|
+
export declare function basaltRouterOptions(options?: RouterOptionsInput<NoContext>): BasaltRouterOptions;
|
|
67
|
+
export declare function basaltRouterOptions<TContext extends object>(options: RouterOptionsInput<TContext> & {
|
|
68
|
+
context: TContext & ExtraContext;
|
|
69
|
+
}): BasaltRouterOptions<TContext>;
|
|
70
|
+
type CreateRouterInput<TRouteTree extends AnyRoute> = {
|
|
71
|
+
routeTree: TRouteTree;
|
|
72
|
+
history?: RouterHistory;
|
|
73
|
+
basepath?: string;
|
|
74
|
+
} & {
|
|
75
|
+
[K in ManagedKeys]?: never;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
26
78
|
* @example
|
|
27
79
|
* const router = createBasaltRouter({ routeTree })
|
|
28
80
|
* declare module '@tanstack/react-router' {
|
|
@@ -31,14 +83,9 @@ export type BasaltRouter<TRouteTree extends AnyRoute = any> = BasaltRouterBase<T
|
|
|
31
83
|
* // extra context (argo's auth) extends BasaltRouterContext:
|
|
32
84
|
* const router = createBasaltRouter({ routeTree, context: { auth }, query: { queryCache } })
|
|
33
85
|
*/
|
|
34
|
-
export declare function createBasaltRouter<TRouteTree extends AnyRoute
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
context?: TContext;
|
|
38
|
-
/** Merged over basalt's QueryClient defaults (`staleTime` 30 s, `gcTime` 5 min, `retry` 2, no refetch on focus). */
|
|
39
|
-
query?: QueryClientConfig;
|
|
40
|
-
/** Route transitions are basalt's (V2-SPEC § 5): the router's would double them. */
|
|
41
|
-
defaultViewTransition?: never;
|
|
86
|
+
export declare function createBasaltRouter<TRouteTree extends AnyRoute>(options: CreateRouterInput<TRouteTree> & RouterOptionsInput<NoContext>): BasaltRouter<TRouteTree>;
|
|
87
|
+
export declare function createBasaltRouter<TRouteTree extends AnyRoute, TContext extends object>(options: CreateRouterInput<TRouteTree> & RouterOptionsInput<TContext> & {
|
|
88
|
+
context: TContext & ExtraContext;
|
|
42
89
|
}): BasaltRouter<TRouteTree>;
|
|
43
90
|
export {};
|
|
44
91
|
//# sourceMappingURL=create-router.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-router.d.ts","sourceRoot":"","sources":["../../src/provider/create-router.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAC3E,OAAO,EAAE,MAAM,EAAgB,MAAM,wBAAwB,CAAA;AAC7D,OAAO,KAAK,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"create-router.d.ts","sourceRoot":"","sources":["../../src/provider/create-router.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAC3E,OAAO,EAAE,MAAM,EAAgB,MAAM,wBAAwB,CAAA;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAG1F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAEL,mBAAmB,EAEpB,MAAM,oBAAoB,CAAA;AAE3B,qFAAqF;AACrF,MAAM,MAAM,mBAAmB,GAAG;IAChC,WAAW,EAAE,WAAW,CAAA;IACxB,+FAA+F;IAC/F,QAAQ,CAAC,EAAE,UAAU,CAAA;CACtB,CAAA;AAED,KAAK,gBAAgB,CAAC,UAAU,SAAS,QAAQ,IAAI,MAAM,CACzD,UAAU,EACV,OAAO,EACP,KAAK,EACL,aAAa,EACb,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CACpB,CAAA;AAED,OAAO,CAAC,MAAM,iBAAiB,EAAE,OAAO,MAAM,CAAA;AAE9C;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,CACtB,UAAU,SAAS,QAAQ,GAAG,GAAG,IAC/B,gBAAgB,CAAC,UAAU,CAAC,GAAG;IACjC,QAAQ,CAAC,CAAC,iBAAiB,CAAC,EAAE,IAAI,CAAA;CACnC,CAAA;AAED,iBAAS,gBAAgB,gCAMxB;AAED,iBAAS,cAAc,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAA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,QAAQ,CAAC,GAAG;IAAE,OAAO,EAAE,QAAQ,GAAG,YAAY,CAAA;CAAE,GAC3E,mBAAmB,CAAC,QAAQ,CAAC,CAAA;AAwChC,KAAK,iBAAiB,CAAC,UAAU,SAAS,QAAQ,IAAI;IACpD,SAAS,EAAE,UAAU,CAAA;IACrB,OAAO,CAAC,EAAE,aAAa,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,GAAG;KAAG,CAAC,IAAI,WAAW,CAAC,CAAC,EAAE,KAAK;CAAE,CAAA;AAElC;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,SAAS,QAAQ,EAC5D,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,GAAG,kBAAkB,CAAC,SAAS,CAAC,GACrE,YAAY,CAAC,UAAU,CAAC,CAAA;AAC3B,wBAAgB,kBAAkB,CAAC,UAAU,SAAS,QAAQ,EAAE,QAAQ,SAAS,MAAM,EACrF,OAAO,EAAE,iBAAiB,CAAC,UAAU,CAAC,GACpC,kBAAkB,CAAC,QAAQ,CAAC,GAAG;IAAE,OAAO,EAAE,QAAQ,GAAG,YAAY,CAAA;CAAE,GACpE,YAAY,CAAC,UAAU,CAAC,CAAA"}
|
|
@@ -3,7 +3,6 @@ import { Button, Center, Loader, Stack, Text } from "@mantine/core";
|
|
|
3
3
|
import { Router, createRouter } from "@tanstack/react-router";
|
|
4
4
|
import { toErrorMessage } from "../common/errors.js";
|
|
5
5
|
import { makeQueryClient } from "../query-client.js";
|
|
6
|
-
import { errorName, now, routerTelemetry } from "../telemetry.js";
|
|
7
6
|
import {
|
|
8
7
|
guardViewTransitionRejections,
|
|
9
8
|
routeViewTransition,
|
|
@@ -25,12 +24,19 @@ function NotFoundComponent() {
|
|
|
25
24
|
/* @__PURE__ */ jsx(Text, { c: "dimmed", size: "sm", children: "This address does not match any page." })
|
|
26
25
|
] });
|
|
27
26
|
}
|
|
28
|
-
function
|
|
27
|
+
function basaltRouterOptions(options = {}) {
|
|
28
|
+
return buildRouterOptions(options);
|
|
29
|
+
}
|
|
30
|
+
function buildRouterOptions(options) {
|
|
29
31
|
guardViewTransitionRejections();
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
const hook = {};
|
|
33
|
+
const context = {
|
|
34
|
+
...options.context,
|
|
35
|
+
queryClient: makeQueryClient(options.query),
|
|
36
|
+
__basalt: hook
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
context,
|
|
34
40
|
defaultPreload: "intent",
|
|
35
41
|
// Query owns freshness: a preload must not be cached a second time by the router.
|
|
36
42
|
defaultPreloadStaleTime: 0,
|
|
@@ -42,21 +48,26 @@ function createBasaltRouter(options) {
|
|
|
42
48
|
defaultErrorComponent: ErrorComponent,
|
|
43
49
|
defaultNotFoundComponent: NotFoundComponent,
|
|
44
50
|
defaultOnCatch: (error) => {
|
|
45
|
-
if (process.env.NODE_ENV !== "production"
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
failed: true,
|
|
49
|
-
start: now(),
|
|
50
|
-
attributes: {
|
|
51
|
-
"basalt.route.id": router.state.matches.at(-1)?.routeId ?? "unknown",
|
|
52
|
-
"exception.type": errorName(error),
|
|
53
|
-
"basalt.error.kind": "route"
|
|
54
|
-
}
|
|
55
|
-
});
|
|
51
|
+
if (process.env.NODE_ENV !== "production" || !hook.onRouteError)
|
|
52
|
+
console.error("[basalt] route error", error);
|
|
53
|
+
hook.onRouteError?.(error);
|
|
56
54
|
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function createBasaltRouter({
|
|
58
|
+
routeTree,
|
|
59
|
+
context,
|
|
60
|
+
query,
|
|
61
|
+
...passthrough
|
|
62
|
+
}) {
|
|
63
|
+
const router = createRouter({
|
|
64
|
+
...passthrough,
|
|
65
|
+
routeTree,
|
|
66
|
+
...buildRouterOptions({ context, query })
|
|
57
67
|
});
|
|
58
68
|
return router;
|
|
59
69
|
}
|
|
60
70
|
export {
|
|
71
|
+
basaltRouterOptions,
|
|
61
72
|
createBasaltRouter
|
|
62
73
|
};
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type { Command } from '../commands/define-commands.js';
|
|
2
|
-
/**
|
|
3
|
-
* Runs a command, swallowing a sync throw or async rejection so a failing command never becomes an
|
|
4
|
-
* unhandled rejection (which the provider would report as a `window.error`). Dev logs it.
|
|
5
|
-
*/
|
|
6
|
-
export declare function runCommandSafely(cmd: Command): void;
|
|
7
1
|
export declare function useRegistryHotkeys(): void;
|
|
2
|
+
/** The `hotkeys` slot mount: renders nothing, binds the registry's shortcuts. */
|
|
3
|
+
export declare function HotkeyBinder(): null;
|
|
8
4
|
//# sourceMappingURL=hotkeys.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hotkeys.d.ts","sourceRoot":"","sources":["../../src/provider/hotkeys.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hotkeys.d.ts","sourceRoot":"","sources":["../../src/provider/hotkeys.ts"],"names":[],"mappings":"AAYA,wBAAgB,kBAAkB,IAAI,IAAI,CA2CzC;AAED,iFAAiF;AACjF,wBAAgB,YAAY,IAAI,IAAI,CAGnC"}
|
package/dist/provider/hotkeys.js
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
2
|
-
import { getActiveCommands } from "../commands/
|
|
3
|
-
function runCommandSafely(cmd) {
|
|
4
|
-
const report = (error) => {
|
|
5
|
-
if (process.env.NODE_ENV !== "production") console.error("[basalt] command failed", error);
|
|
6
|
-
};
|
|
7
|
-
try {
|
|
8
|
-
Promise.resolve(cmd.run()).catch(report);
|
|
9
|
-
} catch (error) {
|
|
10
|
-
report(error);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
1
|
+
import { useEffect, useSyncExternalStore } from "react";
|
|
2
|
+
import { getActiveCommands, runCommandSafely, subscribeCommands } from "../commands/command-stash.js";
|
|
13
3
|
function useRegistryHotkeys() {
|
|
4
|
+
const registry = useSyncExternalStore(subscribeCommands, getActiveCommands, getActiveCommands);
|
|
14
5
|
useEffect(() => {
|
|
15
|
-
const commands = Object.values(
|
|
6
|
+
const commands = Object.values(registry).filter((c) => c.shortcut !== void 0);
|
|
16
7
|
if (commands.length === 0) return;
|
|
17
8
|
let cancelled = false;
|
|
18
9
|
const handles = [];
|
|
@@ -42,9 +33,13 @@ function useRegistryHotkeys() {
|
|
|
42
33
|
cancelled = true;
|
|
43
34
|
for (const handle of handles) handle.unregister();
|
|
44
35
|
};
|
|
45
|
-
}, []);
|
|
36
|
+
}, [registry]);
|
|
37
|
+
}
|
|
38
|
+
function HotkeyBinder() {
|
|
39
|
+
useRegistryHotkeys();
|
|
40
|
+
return null;
|
|
46
41
|
}
|
|
47
42
|
export {
|
|
48
|
-
|
|
43
|
+
HotkeyBinder,
|
|
49
44
|
useRegistryHotkeys
|
|
50
45
|
};
|
package/dist/provider/index.d.ts
CHANGED
|
@@ -5,14 +5,14 @@ import type { BuildPaletteOpts } from '../tokens/core.js';
|
|
|
5
5
|
import type { SizeClass } from '../shell/use-size-class.js';
|
|
6
6
|
import type { Telemetry } from '../telemetry.js';
|
|
7
7
|
import type { BasaltRouter } from './create-router.js';
|
|
8
|
-
import type { FlatNavItem } from '../router-tanstack/nav.js';
|
|
8
|
+
import type { FlatNavItem } from '../router-tanstack/nav-stash.js';
|
|
9
9
|
type BasaltProviderCommonProps = {
|
|
10
10
|
/** Theme override merged onto the Basalt base. Defaults to `createBasaltTheme()`. */
|
|
11
11
|
theme?: MantineProviderProps['theme'];
|
|
12
12
|
/**
|
|
13
13
|
* Typed events (V2-SPEC § 7) — navigations, route/query/mutation/render/window errors. Called
|
|
14
14
|
* synchronously and wrapped in `try/catch`, so a throwing sink never breaks a render. Events carry
|
|
15
|
-
* ids, hashes, counts and durations only
|
|
15
|
+
* ids, hashes, counts and durations only. No sink, no events in production; in development an unset sink logs query and mutation failures to the console.
|
|
16
16
|
*/
|
|
17
17
|
telemetry?: Telemetry;
|
|
18
18
|
/** The root error boundary's UI. Unset → a minimal page with a reload button; `null` renders nothing. */
|
|
@@ -47,8 +47,10 @@ type BasaltProviderCommonProps = {
|
|
|
47
47
|
*/
|
|
48
48
|
navCommandLabel?: (item: FlatNavItem) => string;
|
|
49
49
|
/**
|
|
50
|
-
* Mount Basalt's `<Spotlight>` (Cmd+K) with the generated nav + command actions. Default `true
|
|
51
|
-
*
|
|
50
|
+
* Mount Basalt's `<Spotlight>` (Cmd+K) with the generated nav + command actions. Default `true`, and
|
|
51
|
+
* it mounts only when the app calls `defineNav` or `defineCommands` (nav entries and commands are
|
|
52
|
+
* what it lists). Set `false` when the app owns its own palette: neither the component nor its
|
|
53
|
+
* action wiring mounts.
|
|
52
54
|
*/
|
|
53
55
|
spotlight?: boolean;
|
|
54
56
|
} & Omit<MantineProviderProps, 'children' | 'theme' | 'defaultColorScheme' | 'cssVariablesResolver'>;
|
|
@@ -56,7 +58,7 @@ type BasaltProviderCommonProps = {
|
|
|
56
58
|
* Two modes, never both: pass a `createBasaltRouter` `router` and the provider mounts it, or pass
|
|
57
59
|
* `children` and render the provider INSIDE a router the app does not own (around the `<Outlet />`
|
|
58
60
|
* of TanStack Start's root route component) — the router then comes from `useRouter()` and must carry
|
|
59
|
-
* `context.queryClient
|
|
61
|
+
* `context.queryClient`: spread `basaltRouterOptions()` into its `createRouter` (Start's `getRouter()`).
|
|
60
62
|
*/
|
|
61
63
|
export type BasaltProviderProps = BasaltProviderCommonProps & ({
|
|
62
64
|
/** From `createBasaltRouter`; the provider mounts it and reads its `queryClient`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/provider/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/provider/index.tsx"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AA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