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.
Files changed (151) hide show
  1. package/AGENTS.md +1 -1
  2. package/CHANGELOG.md +39 -0
  3. package/MIGRATING.md +51 -12
  4. package/README.md +2 -0
  5. package/agent/rules/basalt-mantine.md +1 -1
  6. package/agent/rules/basalt-state.md +1 -1
  7. package/agent/skills/basalt-app/SKILL.md +2 -2
  8. package/agent/templates/main.tpl +1 -0
  9. package/dist/cli/basalt-install.d.ts +10 -0
  10. package/dist/cli/basalt-install.d.ts.map +1 -0
  11. package/dist/cli/basalt-install.js +0 -0
  12. package/dist/cli/check-theme.js +1 -1
  13. package/dist/cli/doctor-upgrade.d.ts +5 -6
  14. package/dist/cli/doctor-upgrade.d.ts.map +1 -1
  15. package/dist/cli/doctor-upgrade.js +85 -56
  16. package/dist/cli/doctor.js +3 -3
  17. package/dist/cli/index.d.ts +5 -27
  18. package/dist/cli/index.d.ts.map +1 -1
  19. package/dist/cli/index.js +12 -49
  20. package/dist/cli/provider-tags.d.ts +12 -0
  21. package/dist/cli/provider-tags.d.ts.map +1 -0
  22. package/dist/cli/provider-tags.js +28 -0
  23. package/dist/cli/render-imports.d.ts +24 -0
  24. package/dist/cli/render-imports.d.ts.map +1 -0
  25. package/dist/cli/render-imports.js +74 -0
  26. package/dist/cli/router-wiring.d.ts +12 -0
  27. package/dist/cli/router-wiring.d.ts.map +1 -1
  28. package/dist/cli/router-wiring.js +18 -0
  29. package/dist/cli/source-text.d.ts +7 -0
  30. package/dist/cli/source-text.d.ts.map +1 -1
  31. package/dist/cli/source-text.js +34 -0
  32. package/dist/cli/sync.d.ts.map +1 -1
  33. package/dist/cli/sync.js +19 -13
  34. package/dist/commands/command-stash.d.ts +15 -0
  35. package/dist/commands/command-stash.d.ts.map +1 -0
  36. package/dist/commands/command-stash.js +31 -0
  37. package/dist/commands/define-commands.d.ts +2 -3
  38. package/dist/commands/define-commands.d.ts.map +1 -1
  39. package/dist/commands/define-commands.js +9 -7
  40. package/dist/commands/define-overlays.d.ts +6 -12
  41. package/dist/commands/define-overlays.d.ts.map +1 -1
  42. package/dist/commands/define-overlays.js +28 -34
  43. package/dist/commands/projectors.js +1 -1
  44. package/dist/guard/fonts-hint.d.ts +3 -0
  45. package/dist/guard/fonts-hint.d.ts.map +1 -0
  46. package/dist/guard/fonts-hint.js +4 -0
  47. package/dist/guard/index.d.ts +1 -1
  48. package/dist/guard/index.d.ts.map +1 -1
  49. package/dist/guard/index.js +2 -1
  50. package/dist/index.d.ts +3 -3
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/index.js +3 -1
  53. package/dist/provider/create-router.d.ts +57 -10
  54. package/dist/provider/create-router.d.ts.map +1 -1
  55. package/dist/provider/create-router.js +28 -17
  56. package/dist/provider/hotkeys.d.ts +2 -6
  57. package/dist/provider/hotkeys.d.ts.map +1 -1
  58. package/dist/provider/hotkeys.js +10 -15
  59. package/dist/provider/index.d.ts +7 -5
  60. package/dist/provider/index.d.ts.map +1 -1
  61. package/dist/provider/index.js +35 -42
  62. package/dist/provider/modals-mount.d.ts +16 -0
  63. package/dist/provider/modals-mount.d.ts.map +1 -0
  64. package/dist/provider/modals-mount.js +42 -0
  65. package/dist/provider/notifier.d.ts +22 -0
  66. package/dist/provider/notifier.d.ts.map +1 -0
  67. package/dist/provider/notifier.js +36 -0
  68. package/dist/provider/route-transition.d.ts +1 -1
  69. package/dist/provider/route-transition.d.ts.map +1 -1
  70. package/dist/provider/route-transition.js +1 -1
  71. package/dist/provider/slots.d.ts +25 -0
  72. package/dist/provider/slots.d.ts.map +1 -0
  73. package/dist/provider/slots.js +29 -0
  74. package/dist/provider/spotlight-actions.d.ts +1 -1
  75. package/dist/provider/spotlight-actions.d.ts.map +1 -1
  76. package/dist/provider/spotlight-actions.js +2 -3
  77. package/dist/provider/spotlight-mount.d.ts +3 -0
  78. package/dist/provider/spotlight-mount.d.ts.map +1 -0
  79. package/dist/provider/spotlight-mount.js +26 -0
  80. package/dist/query-client.d.ts +2 -62
  81. package/dist/query-client.d.ts.map +1 -1
  82. package/dist/query-client.js +13 -18
  83. package/dist/router-tanstack/nav-stash.d.ts +24 -0
  84. package/dist/router-tanstack/nav-stash.d.ts.map +1 -0
  85. package/dist/router-tanstack/nav-stash.js +23 -0
  86. package/dist/router-tanstack/nav.d.ts +5 -15
  87. package/dist/router-tanstack/nav.d.ts.map +1 -1
  88. package/dist/router-tanstack/nav.js +6 -16
  89. package/dist/router-tanstack/search-store-warnings.d.ts +33 -0
  90. package/dist/router-tanstack/search-store-warnings.d.ts.map +1 -0
  91. package/dist/router-tanstack/search-store-warnings.js +77 -0
  92. package/dist/router-tanstack/search-store.d.ts +2 -5
  93. package/dist/router-tanstack/search-store.d.ts.map +1 -1
  94. package/dist/router-tanstack/search-store.js +111 -110
  95. package/dist/router-tanstack/use-nav.js +1 -1
  96. package/dist/surfaces.d.ts +1 -1
  97. package/dist/surfaces.js +1 -1
  98. package/dist/telemetry.d.ts +31 -2
  99. package/dist/telemetry.d.ts.map +1 -1
  100. package/dist/telemetry.js +32 -12
  101. package/dist/theme/ctl-theme.d.ts.map +1 -1
  102. package/dist/theme/ctl-theme.js +17 -30
  103. package/dist/theme/extend.d.ts +18 -0
  104. package/dist/theme/extend.d.ts.map +1 -0
  105. package/dist/theme/extend.js +6 -0
  106. package/dist/theme/index.d.ts.map +1 -1
  107. package/dist/theme/index.js +44 -84
  108. package/dist/unwrap.d.ts +29 -0
  109. package/dist/unwrap.d.ts.map +1 -0
  110. package/dist/unwrap.js +18 -0
  111. package/llms.txt +11 -7
  112. package/package.json +2 -2
  113. package/src/cli/basalt-install.ts +9 -0
  114. package/src/cli/check-theme.ts +1 -1
  115. package/src/cli/doctor-upgrade.ts +117 -72
  116. package/src/cli/doctor.ts +3 -3
  117. package/src/cli/index.ts +15 -70
  118. package/src/cli/provider-tags.ts +38 -0
  119. package/src/cli/render-imports.ts +104 -0
  120. package/src/cli/router-wiring.ts +23 -0
  121. package/src/cli/source-text.ts +39 -0
  122. package/src/cli/sync.ts +28 -22
  123. package/src/commands/command-stash.ts +44 -0
  124. package/src/commands/define-commands.ts +10 -17
  125. package/src/commands/define-overlays.ts +40 -68
  126. package/src/commands/projectors.ts +1 -1
  127. package/src/guard/fonts-hint.ts +2 -0
  128. package/src/guard/index.ts +2 -2
  129. package/src/index.ts +4 -2
  130. package/src/provider/create-router.tsx +103 -39
  131. package/src/provider/hotkeys.ts +14 -22
  132. package/src/provider/index.tsx +55 -61
  133. package/src/provider/modals-mount.tsx +66 -0
  134. package/src/provider/notifier.ts +52 -0
  135. package/src/provider/route-transition.ts +1 -1
  136. package/src/provider/slots.ts +59 -0
  137. package/src/provider/spotlight-actions.tsx +3 -4
  138. package/src/provider/spotlight-mount.tsx +33 -0
  139. package/src/query-client.ts +20 -78
  140. package/src/router-tanstack/nav-stash.ts +41 -0
  141. package/src/router-tanstack/nav.ts +11 -31
  142. package/src/router-tanstack/search-store-warnings.ts +120 -0
  143. package/src/router-tanstack/search-store.ts +200 -206
  144. package/src/router-tanstack/use-nav.ts +1 -1
  145. package/src/surfaces.ts +1 -1
  146. package/src/telemetry.ts +71 -13
  147. package/src/theme/__snapshots__/plain-theme.test.ts.snap +2354 -0
  148. package/src/theme/ctl-theme.tsx +20 -19
  149. package/src/theme/extend.ts +18 -0
  150. package/src/theme/index.ts +50 -49
  151. package/src/unwrap.ts +44 -0
@@ -1,11 +1,9 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { MantineProvider, useMantineColorScheme, useMantineTheme } from "@mantine/core";
3
- import { ModalsProvider } from "@mantine/modals";
4
3
  import { Notifications } from "@mantine/notifications";
5
- import { Spotlight } from "@mantine/spotlight";
6
4
  import { QueryClientProvider } from "@tanstack/react-query";
7
5
  import { RouterProvider, useRouter } from "@tanstack/react-router";
8
- import { Component, Suspense, lazy, useCallback, useEffect, useMemo, useRef, useState } from "react";
6
+ import { Component, Suspense, lazy, useEffect, useMemo, useRef, useState } from "react";
9
7
  import fallbackClasses from "./error-fallback.module.css";
10
8
  import { cssVariablesResolver } from "../theme/index.js";
11
9
  import { useLabTheme } from "./lab-theme.js";
@@ -13,20 +11,20 @@ import { buildDensityCss, buildFontsCss, buildPaletteCss, buildRadiusCss } from
13
11
  import { isDefaultDeriveConfig } from "../tokens/derive.js";
14
12
  import { buildPaletteData } from "../tokens/palette.js";
15
13
  import { useMediaQuery } from "../common/use-media-query.js";
16
- import { registerModalsProvider } from "../commands/define-overlays.js";
17
14
  import { registerColorSchemeSetter } from "../commands/shell-bridge.js";
18
15
  import { useIsomorphicLayoutEffect } from "../common/isomorphic-layout-effect.js";
19
16
  import { PageTitle } from "../shell/page-title.js";
20
17
  import { SizeClassHintContext } from "../shell/use-size-class.js";
21
18
  import {
22
19
  TelemetryContext,
23
- bindRouterTelemetry,
20
+ bindRouteError,
24
21
  createLiveEmitter,
22
+ devConsoleSink,
25
23
  errorName,
24
+ groupingId,
26
25
  now
27
26
  } from "../telemetry.js";
28
- import { useRegistryHotkeys } from "./hotkeys.js";
29
- import { buildSpotlightActions } from "./spotlight-actions.js";
27
+ import { trackProvider, useSlots } from "./slots.js";
30
28
  function DefaultErrorFallback() {
31
29
  return /* @__PURE__ */ jsxs("div", { className: fallbackClasses.root, children: [
32
30
  /* @__PURE__ */ jsx(
@@ -171,7 +169,18 @@ function useWindowErrors(emit) {
171
169
  }
172
170
  function useDataTelemetry(router, client, emit) {
173
171
  useEffect(() => {
174
- const unbind = bindRouterTelemetry(router, emit);
172
+ const routeId = () => router.state.matches.at(-1)?.routeId ?? "unknown";
173
+ const onRouteError = (error) => emit({
174
+ type: "route.error",
175
+ failed: true,
176
+ start: now(),
177
+ attributes: {
178
+ "basalt.route.id": routeId(),
179
+ "exception.type": errorName(error),
180
+ "basalt.error.kind": "route"
181
+ }
182
+ });
183
+ const unbind = bindRouteError(router, onRouteError);
175
184
  let pending;
176
185
  const offBefore = router.subscribe("onBeforeNavigate", (ev) => {
177
186
  pending = { href: ev.toLocation.href, start: now(), from: ev.fromLocation?.pathname ?? "" };
@@ -186,7 +195,7 @@ function useDataTelemetry(router, client, emit) {
186
195
  start,
187
196
  duration: now() - start,
188
197
  attributes: {
189
- "basalt.route.id": router.state.matches.at(-1)?.routeId ?? "unknown",
198
+ "basalt.route.id": routeId(),
190
199
  "basalt.route.from": from,
191
200
  "url.path": ev.toLocation.pathname
192
201
  }
@@ -199,7 +208,7 @@ function useDataTelemetry(router, client, emit) {
199
208
  failed: true,
200
209
  start: now(),
201
210
  attributes: {
202
- "basalt.query.hash": ev.query.queryHash,
211
+ "basalt.query.hash": groupingId(ev.query.queryHash),
203
212
  "basalt.query.failure_count": ev.query.state.fetchFailureCount,
204
213
  "exception.type": errorName(ev.action.error),
205
214
  "basalt.error.kind": "query"
@@ -213,7 +222,9 @@ function useDataTelemetry(router, client, emit) {
213
222
  failed: true,
214
223
  start: now(),
215
224
  attributes: {
216
- "basalt.mutation.key": JSON.stringify(ev.mutation.options.mutationKey ?? null),
225
+ "basalt.mutation.key": groupingId(
226
+ JSON.stringify(ev.mutation.options.mutationKey ?? null)
227
+ ),
217
228
  "exception.type": errorName(ev.action.error),
218
229
  "basalt.error.kind": "mutation"
219
230
  }
@@ -266,27 +277,22 @@ function BasaltProvider({
266
277
  }) {
267
278
  useDuplicateProviderGuard();
268
279
  useHostAttribute();
269
- const sinkRef = useRef(telemetry);
280
+ const sink = telemetry ?? (process.env.NODE_ENV === "production" ? void 0 : devConsoleSink);
281
+ const sinkRef = useRef(sink);
270
282
  useEffect(() => {
271
- sinkRef.current = telemetry;
283
+ sinkRef.current = sink;
272
284
  });
273
285
  const emit = useMemo(() => createLiveEmitter(() => sinkRef.current), []);
274
286
  useWindowErrors(emit);
275
- useRegistryHotkeys();
276
- useEffect(() => registerModalsProvider(), []);
287
+ const slots = useSlots();
288
+ useEffect(trackProvider, []);
277
289
  const router = useEffectiveRouter(mountedRouter);
278
290
  const client = readQueryClient(router);
279
291
  useDataTelemetry(router, client, emit);
280
292
  const [devTool, setDevTool] = useState(null);
281
- const [actions, setActions] = useState([]);
282
- const refreshActions = useCallback(
283
- () => setActions(buildSpotlightActions(router, setDevTool, navCommandLabel)),
284
- [router, navCommandLabel]
285
- );
286
- useEffect(() => {
287
- if (spotlight) refreshActions();
288
- }, [spotlight, refreshActions]);
289
293
  const resolvedTheme = useLabTheme(theme);
294
+ const { modals: Modals, hotkeys: Hotkeys, spotlight: Spotlight } = slots;
295
+ const slotProps = { router, navCommandLabel, openDevTool: setDevTool };
290
296
  return (
291
297
  // `...rest` spreads FIRST so a consumer's `MantineProviderProps` can never shadow the three
292
298
  // values that follow it — `cssVariablesResolver` in particular is the resolver the package
@@ -299,27 +305,14 @@ function BasaltProvider({
299
305
  cssVariablesResolver,
300
306
  defaultColorScheme,
301
307
  children: /* @__PURE__ */ jsx(RootBoundary, { emit, fallback, children: /* @__PURE__ */ jsx(BasaltBridge, { injectPalette, paletteOptions, nonce, children: /* @__PURE__ */ jsx(TelemetryContext.Provider, { value: emit, children: /* @__PURE__ */ jsxs(SizeClassHintContext.Provider, { value: sizeClassHint, children: [
302
- /* @__PURE__ */ jsx(QueryClientProvider, { client, children: /* @__PURE__ */ jsxs(ModalsProvider, { children: [
308
+ /* @__PURE__ */ jsxs(QueryClientProvider, { client, children: [
303
309
  mountedRouter === void 0 ? children : /* @__PURE__ */ jsx(RouterProvider, { router: mountedRouter }),
304
- LazyDevDock !== null && /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(
305
- LazyDevDock,
306
- {
307
- tool: devTool,
308
- onClose: () => setDevTool(null),
309
- router
310
- }
311
- ) })
312
- ] }) }),
310
+ Modals !== void 0 && /* @__PURE__ */ jsx(Modals, { ...slotProps }),
311
+ LazyDevDock !== null && /* @__PURE__ */ jsx(Suspense, { fallback: null, children: /* @__PURE__ */ jsx(LazyDevDock, { tool: devTool, onClose: () => setDevTool(null), router }) })
312
+ ] }),
313
313
  /* @__PURE__ */ jsx(Notifications, { position: "bottom-right", autoClose: 4e3, limit: 5 }),
314
- spotlight && /* @__PURE__ */ jsx(
315
- Spotlight,
316
- {
317
- actions,
318
- onSpotlightOpen: refreshActions,
319
- shortcut: "mod + K",
320
- maxHeight: 420
321
- }
322
- )
314
+ Hotkeys !== void 0 && /* @__PURE__ */ jsx(Hotkeys, { ...slotProps }),
315
+ spotlight && Spotlight !== void 0 && /* @__PURE__ */ jsx(Spotlight, { ...slotProps })
323
316
  ] }) }) }) })
324
317
  }
325
318
  )
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Internal — `ModalsMount` declares its `ModalsProvider` live for as long as it is mounted and gets
3
+ * back the retraction. There is no way to detect the provider from outside React (its context is only
4
+ * readable through `useModals()`, and the overlay calls are imperative), so the registration is explicit.
5
+ * Exported for the confirm tests, which mount their own host.
6
+ */
7
+ export declare const registerModalsProvider: () => () => void;
8
+ /** @internal — put the modals mount in the provider's slots; synchronous, nothing awaited. */
9
+ export declare function registerModalsMount(): void;
10
+ /**
11
+ * @internal — register the mount, then wait for it to go live: up to 5 s when a `BasaltProvider` is
12
+ * mounted (it commits the slot), 500 ms when none is. `false` means no dialog layer will serve the call.
13
+ */
14
+ export declare function ensureModalsMount(): Promise<boolean>;
15
+ export declare function ModalsMount(): import("react").JSX.Element;
16
+ //# sourceMappingURL=modals-mount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modals-mount.d.ts","sourceRoot":"","sources":["../../src/provider/modals-mount.tsx"],"names":[],"mappings":"AAiBA;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,kBAAwB,CAAA;AAyB3D,8FAA8F;AAC9F,wBAAgB,mBAAmB,IAAI,IAAI,CAE1C;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAAC,OAAO,CAAC,CAGpD;AAED,wBAAgB,WAAW,gCAG1B"}
@@ -0,0 +1,42 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { ModalsProvider } from "@mantine/modals";
3
+ import { useEffect } from "react";
4
+ import { createLiveCounter } from "./notifier.js";
5
+ import { hasMountedProvider, registerSlot } from "./slots.js";
6
+ const liveProviders = createLiveCounter();
7
+ const registerModalsProvider = liveProviders.acquire;
8
+ const COMMIT_WAIT_MS = 5e3;
9
+ const NO_PROVIDER_WAIT_MS = 500;
10
+ function whenModalsLive(timeoutMs) {
11
+ if (liveProviders.count() > 0) return Promise.resolve(true);
12
+ return new Promise((resolve) => {
13
+ let timer;
14
+ let unsubscribe;
15
+ const finish = (isLive) => {
16
+ clearTimeout(timer);
17
+ unsubscribe?.();
18
+ resolve(isLive);
19
+ };
20
+ timer = setTimeout(() => finish(false), timeoutMs);
21
+ unsubscribe = liveProviders.subscribe(() => {
22
+ if (liveProviders.count() > 0) finish(true);
23
+ });
24
+ });
25
+ }
26
+ function registerModalsMount() {
27
+ registerSlot("modals", ModalsMount);
28
+ }
29
+ function ensureModalsMount() {
30
+ registerModalsMount();
31
+ return whenModalsLive(hasMountedProvider() ? COMMIT_WAIT_MS : NO_PROVIDER_WAIT_MS);
32
+ }
33
+ function ModalsMount() {
34
+ useEffect(() => registerModalsProvider(), []);
35
+ return /* @__PURE__ */ jsx(ModalsProvider, { children: null });
36
+ }
37
+ export {
38
+ ModalsMount,
39
+ ensureModalsMount,
40
+ registerModalsMount,
41
+ registerModalsProvider
42
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The one subscribe/notify pair behind every module-level store here (slots, the command stash, the
3
+ * modals-live waiters) — shaped for `useSyncExternalStore`. A leaf: no React, nothing at import.
4
+ */
5
+ export type Notifier = {
6
+ subscribe: (listener: () => void) => () => void;
7
+ notify: () => void;
8
+ };
9
+ export declare function createNotifier(): Notifier;
10
+ export type LiveCounter = {
11
+ count: () => number;
12
+ /** Count one more live thing, notify subscribers, and return its retraction (idempotent). */
13
+ acquire: () => () => void;
14
+ subscribe: Notifier['subscribe'];
15
+ };
16
+ /**
17
+ * A COUNTER of live things — not a flag: two overlapping mounts are normal (a route swap mounts the
18
+ * next one before unmounting the previous), and a last-write-wins boolean would report the OLD one's
19
+ * teardown as "none live" while the new one serves.
20
+ */
21
+ export declare function createLiveCounter(): LiveCounter;
22
+ //# sourceMappingURL=notifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notifier.d.ts","sourceRoot":"","sources":["../../src/provider/notifier.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG;IAAE,SAAS,EAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,IAAI,CAAA;CAAE,CAAA;AAE9F,wBAAgB,cAAc,IAAI,QAAQ,CAYzC;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,MAAM,MAAM,CAAA;IACnB,6FAA6F;IAC7F,OAAO,EAAE,MAAM,MAAM,IAAI,CAAA;IACzB,SAAS,EAAE,QAAQ,CAAC,WAAW,CAAC,CAAA;CACjC,CAAA;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,WAAW,CAmB/C"}
@@ -0,0 +1,36 @@
1
+ function createNotifier() {
2
+ const listeners = /* @__PURE__ */ new Set();
3
+ return {
4
+ subscribe(listener) {
5
+ listeners.add(listener);
6
+ return () => void listeners.delete(listener);
7
+ },
8
+ // Deleting from a Set mid-iteration is safe, so a listener may unsubscribe itself here.
9
+ notify() {
10
+ for (const listener of listeners) listener();
11
+ }
12
+ };
13
+ }
14
+ function createLiveCounter() {
15
+ let live = 0;
16
+ const changes = createNotifier();
17
+ return {
18
+ count: () => live,
19
+ subscribe: changes.subscribe,
20
+ acquire() {
21
+ live++;
22
+ changes.notify();
23
+ let released = false;
24
+ return () => {
25
+ if (released) return;
26
+ released = true;
27
+ live--;
28
+ changes.notify();
29
+ };
30
+ }
31
+ };
32
+ }
33
+ export {
34
+ createLiveCounter,
35
+ createNotifier
36
+ };
@@ -8,7 +8,7 @@
8
8
  * so `ready` and `finished` are dropped on the floor.
9
9
  */
10
10
  import type { AnyRouter } from '@tanstack/react-router';
11
- import { flattenNav, getActiveNav } from '../router-tanstack/nav.js';
11
+ import { flattenNav, getActiveNav } from '../router-tanstack/nav-stash.js';
12
12
  /** The three `:active-view-transition-type()` names `styles.css` animates. Namespaced: a consumer's own cannot collide. */
13
13
  export declare const ROUTE_TRANSITION_TYPES: {
14
14
  readonly forward: "basalt-forward";
@@ -1 +1 @@
1
- {"version":3,"file":"route-transition.d.ts","sourceRoot":"","sources":["../../src/provider/route-transition.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AAEjE,2HAA2H;AAC3H,eAAO,MAAM,sBAAsB;;;;CAIzB,CAAA;AAEV,uFAAuF;AACvF,KAAK,oBAAoB,GAAG,UAAU,CACpC,OAAO,CACL,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,EACvE,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAC9B,CACF,CAAC,CAAC,CAAC,CAAA;AAEJ,sFAAsF;AACtF,KAAK,cAAc,GAAG,IAAI,CAAC,oBAAoB,EAAE,aAAa,CAAC,GAAG;IAChE,YAAY,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC,EAAE,UAAU,CAAC,CAAA;IAClF,UAAU,EAAE,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,EAAE,UAAU,CAAC,CAAA;CACjE,CAAA;AAED,KAAK,SAAS,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAAA;AAC7D,KAAK,OAAO,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAA;AAoDpD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAejF;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,cAAc,EACzD,GAAG,EAAE,SAAS,GAAG,SAAS,GACzB,MAAM,EAAE,GAAG,KAAK,CAQlB;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,IAAI,OAAO,CAIrD;AAED,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB;oBACd,cAAc;CAC/B,CAAA;AAqBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,6BAA6B,IAAI,IAAI,CAYpD"}
1
+ {"version":3,"file":"route-transition.d.ts","sourceRoot":"","sources":["../../src/provider/route-transition.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAA;AAEvE,2HAA2H;AAC3H,eAAO,MAAM,sBAAsB;;;;CAIzB,CAAA;AAEV,uFAAuF;AACvF,KAAK,oBAAoB,GAAG,UAAU,CACpC,OAAO,CACL,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,uBAAuB,CAAC,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,EACvE,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,OAAO,CAC9B,CACF,CAAC,CAAC,CAAC,CAAA;AAEJ,sFAAsF;AACtF,KAAK,cAAc,GAAG,IAAI,CAAC,oBAAoB,EAAE,aAAa,CAAC,GAAG;IAChE,YAAY,CAAC,EAAE,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,cAAc,CAAC,CAAC,EAAE,UAAU,CAAC,CAAA;IAClF,UAAU,EAAE,IAAI,CAAC,oBAAoB,CAAC,YAAY,CAAC,EAAE,UAAU,CAAC,CAAA;CACjE,CAAA;AAED,KAAK,SAAS,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC,CAAA;AAC7D,KAAK,OAAO,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAA;AAoDpD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAejF;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,EAAE,cAAc,EACzD,GAAG,EAAE,SAAS,GAAG,SAAS,GACzB,MAAM,EAAE,GAAG,KAAK,CAQlB;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,IAAI,OAAO,CAIrD;AAED,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB;oBACd,cAAc;CAC/B,CAAA;AAqBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,6BAA6B,IAAI,IAAI,CAYpD"}
@@ -1,4 +1,4 @@
1
- import { flattenNav, getActiveNav } from "../router-tanstack/nav.js";
1
+ import { flattenNav, getActiveNav } from "../router-tanstack/nav-stash.js";
2
2
  const ROUTE_TRANSITION_TYPES = {
3
3
  forward: "basalt-forward",
4
4
  back: "basalt-back",
@@ -0,0 +1,25 @@
1
+ import type { ComponentType } from 'react';
2
+ import type { AnyRouter } from '@tanstack/react-router';
3
+ import type { BasaltDevDockTool } from '../dev-dock.js';
4
+ import type { FlatNavItem } from '../router-tanstack/nav-stash.js';
5
+ /** What the provider hands every mount; a mount that needs none of it ignores it. */
6
+ export type SlotProps = {
7
+ router: AnyRouter;
8
+ navCommandLabel: ((item: FlatNavItem) => string) | undefined;
9
+ openDevTool: (tool: BasaltDevDockTool) => void;
10
+ };
11
+ export type SlotName = 'hotkeys' | 'spotlight' | 'modals';
12
+ export type Slots = {
13
+ readonly [K in SlotName]?: ComponentType<SlotProps>;
14
+ };
15
+ /** @internal — idempotent: re-registering the same component is a no-op (no notify, no new snapshot). */
16
+ export declare function registerSlot(name: SlotName, component: ComponentType<SlotProps>): void;
17
+ /** @internal — test isolation only. */
18
+ export declare function resetSlots(): void;
19
+ /** @internal — the registered mounts, read by `BasaltProvider`. */
20
+ export declare function useSlots(): Slots;
21
+ /** @internal — `BasaltProvider` declares itself mounted; returns the retraction. */
22
+ export declare const trackProvider: () => () => void;
23
+ /** @internal — whether a `BasaltProvider` is mounted to commit a slot registered right now. */
24
+ export declare function hasMountedProvider(): boolean;
25
+ //# sourceMappingURL=slots.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slots.d.ts","sourceRoot":"","sources":["../../src/provider/slots.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AAC1C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAG/D,qFAAqF;AACrF,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE,SAAS,CAAA;IACjB,eAAe,EAAE,CAAC,CAAC,IAAI,EAAE,WAAW,KAAK,MAAM,CAAC,GAAG,SAAS,CAAA;IAC5D,WAAW,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAA;CAC/C,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAA;AACzD,MAAM,MAAM,KAAK,GAAG;IAAE,QAAQ,EAAE,CAAC,IAAI,QAAQ,CAAC,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC;CAAE,CAAA;AAK3E,yGAAyG;AACzG,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,CAAC,SAAS,CAAC,GAAG,IAAI,CAItF;AAED,uCAAuC;AACvC,wBAAgB,UAAU,IAAI,IAAI,CAGjC;AAID,mEAAmE;AACnE,wBAAgB,QAAQ,IAAI,KAAK,CAEhC;AAMD,oFAAoF;AACpF,eAAO,MAAM,aAAa,kBAAoB,CAAA;AAE9C,+FAA+F;AAC/F,wBAAgB,kBAAkB,IAAI,OAAO,CAE5C"}
@@ -0,0 +1,29 @@
1
+ import { useSyncExternalStore } from "react";
2
+ import { createLiveCounter, createNotifier } from "./notifier.js";
3
+ let slots = {};
4
+ const store = createNotifier();
5
+ function registerSlot(name, component) {
6
+ if (slots[name] === component) return;
7
+ slots = { ...slots, [name]: component };
8
+ store.notify();
9
+ }
10
+ function resetSlots() {
11
+ slots = {};
12
+ store.notify();
13
+ }
14
+ const getSlots = () => slots;
15
+ function useSlots() {
16
+ return useSyncExternalStore(store.subscribe, getSlots, getSlots);
17
+ }
18
+ const providers = createLiveCounter();
19
+ const trackProvider = providers.acquire;
20
+ function hasMountedProvider() {
21
+ return providers.count() > 0;
22
+ }
23
+ export {
24
+ hasMountedProvider,
25
+ registerSlot,
26
+ resetSlots,
27
+ trackProvider,
28
+ useSlots
29
+ };
@@ -5,7 +5,7 @@
5
5
  */
6
6
  import type { SpotlightActionData } from '@mantine/spotlight';
7
7
  import type { AnyRouter } from '@tanstack/react-router';
8
- import type { FlatNavItem } from '../router-tanstack/nav.js';
8
+ import type { FlatNavItem } from '../router-tanstack/nav-stash.js';
9
9
  import type { BasaltDevDockTool } from '../dev-dock.js';
10
10
  export declare function buildSpotlightActions(router: AnyRouter, openDevTool: (tool: BasaltDevDockTool) => void, navCommandLabel?: (item: FlatNavItem) => string): SpotlightActionData[];
11
11
  //# sourceMappingURL=spotlight-actions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"spotlight-actions.d.ts","sourceRoot":"","sources":["../../src/provider/spotlight-actions.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAIvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACzD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AASpD,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,EAC9C,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,MAAM,GAC9C,mBAAmB,EAAE,CAiDvB"}
1
+ {"version":3,"file":"spotlight-actions.d.ts","sourceRoot":"","sources":["../../src/provider/spotlight-actions.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAIvD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC/D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAQpD,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,EAC9C,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,MAAM,GAC9C,mBAAmB,EAAE,CAiDvB"}
@@ -1,7 +1,6 @@
1
- import { getActiveCommands } from "../commands/define-commands.js";
1
+ import { getActiveCommands, runCommandSafely } from "../commands/command-stash.js";
2
2
  import { detectMac, formatShortcutDisplay } from "../commands/shortcut-format.js";
3
- import { flattenNav, getActiveNav } from "../router-tanstack/nav.js";
4
- import { runCommandSafely } from "./hotkeys.js";
3
+ import { flattenNav, getActiveNav } from "../router-tanstack/nav-stash.js";
5
4
  const DEV_TOOLS = [
6
5
  { tool: "router", label: "Router devtools" },
7
6
  { tool: "query", label: "Query devtools" },
@@ -0,0 +1,3 @@
1
+ import type { SlotProps } from './slots.js';
2
+ export declare function SpotlightMount({ router, navCommandLabel, openDevTool }: SlotProps): import("react").JSX.Element;
3
+ //# sourceMappingURL=spotlight-mount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spotlight-mount.d.ts","sourceRoot":"","sources":["../../src/provider/spotlight-mount.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,eAAe,EAAE,WAAW,EAAE,EAAE,SAAS,+BAqBjF"}
@@ -0,0 +1,26 @@
1
+ import { jsx } from "react/jsx-runtime";
2
+ import { Spotlight } from "@mantine/spotlight";
3
+ import { useCallback, useEffect, useState } from "react";
4
+ import { buildSpotlightActions } from "./spotlight-actions.js";
5
+ function SpotlightMount({ router, navCommandLabel, openDevTool }) {
6
+ const [actions, setActions] = useState([]);
7
+ const refreshActions = useCallback(
8
+ () => setActions(buildSpotlightActions(router, openDevTool, navCommandLabel)),
9
+ [router, openDevTool, navCommandLabel]
10
+ );
11
+ useEffect(() => {
12
+ refreshActions();
13
+ }, [refreshActions]);
14
+ return /* @__PURE__ */ jsx(
15
+ Spotlight,
16
+ {
17
+ actions,
18
+ onSpotlightOpen: refreshActions,
19
+ shortcut: "mod + K",
20
+ maxHeight: 420
21
+ }
22
+ );
23
+ }
24
+ export {
25
+ SpotlightMount
26
+ };
@@ -1,69 +1,9 @@
1
1
  /**
2
- * `unwrap` plus the QueryClient factory `createBasaltRouter` owns (V2-SPEC § 2): one client per
3
- * router, so an SSR entry gets one per request. Optional peer: @tanstack/react-query.
2
+ * The QueryClient factory `basaltRouterOptions` owns (V2-SPEC § 2): one client per router, so an
3
+ * SSR entry gets one per request. Optional peer: @tanstack/react-query.
4
4
  */
5
5
  import { QueryClient } from '@tanstack/react-query';
6
6
  import type { QueryClientConfig } from '@tanstack/react-query';
7
7
  /** QueryClient with the basalt dashboard defaults; consumer `config` wins per-query. */
8
8
  export declare function makeQueryClient(config?: QueryClientConfig): QueryClient;
9
- /**
10
- * Transport-agnostic unwrap for any `{ data, error }` envelope (Eden Treaty, raw fetch wrappers,
11
- * etc.). TData is inferred from the data field. Throws on the error branch so failures surface
12
- * to the nearest error boundary or TanStack Query's error state.
13
- *
14
- * Absence guard: if `error` is falsy but `data` is `null` OR `undefined`, unwrap throws with a
15
- * descriptive message. This catches 204 No Content responses and silent transport failures that
16
- * return `{ data: null, error: null }` — both signal an unexpected absence of data and should not
17
- * silently resolve. `undefined` joined `null` here (C5 consolidation) so a hand-rolled fetch
18
- * wrapper that leaves `data` unset on a miss — rather than explicitly `null` — is caught the same
19
- * way; the two envelope shapes argo's own pre-basalt `unwrap` and basalt's ONLY differed on.
20
- *
21
- * **One generic signature, a conditional return** — a Promise of the envelope (basalt's original
22
- * shape, `queryFn: () => unwrap(api.x.get())`) or the ALREADY-RESOLVED envelope itself
23
- * (`unwrap(await api.x.get())`), both resolve `TData` off the same conditional. The two-overload
24
- * form this replaced (1.29.0) resolved `unwrap` to `unknown` whenever it was passed as a bare
25
- * callback — `.then(unwrap)` never applies an overload, it just reads the declared type of the
26
- * `unwrap` reference — so `api.threads.get().then(unwrap)` silently widened. A single generic
27
- * signature has exactly one type to read regardless of how the reference is used.
28
- *
29
- * **The conditional infers the raw `data` type and strips `null`/`undefined` from it**, rather
30
- * than inferring the already-narrowed `Envelope<TData>`'s `TData` directly — Eden Treaty's
31
- * response type is a UNION of envelope shapes (`{ data: T; error: null } | { data: null; error:
32
- * EdenFetchError }`), and inferring through `Envelope<infer TData>` reads `TData` off whichever
33
- * union member the conditional happens to match, landing on `T | null` at every Eden call site. A
34
- * conditional type distributes over a union input when the checked type is a bare type parameter,
35
- * so inferring `D` from `{ data: infer D; error: unknown }` and wrapping the result in
36
- * `NonNullable` runs the check per union member and unions the results back together —
37
- * `NonNullable<T> | NonNullable<null>` collapses to `T`.
38
- *
39
- * @example
40
- * import { unwrap } from 'basalt-ui'
41
- *
42
- * // Promise-of-envelope — queryFn:
43
- * queryFn: () => unwrap(api.users.get({ query: params }))
44
- * // mutation:
45
- * mutationFn: (body) => unwrap(api.resource.post({ body }))
46
- *
47
- * // resolved-envelope — either shape, including a bare `.then(unwrap)` callback:
48
- * const rows = unwrap(await api.users.get())
49
- * const rows2 = await api.users.get().then(unwrap)
50
- */
51
- export declare function unwrap<R extends Envelope | Promise<Envelope>>(response: R): UnwrapResult<R>;
52
- /** Transport-agnostic `{ data, error }` result shape — Eden Treaty, a raw fetch wrapper, etc. */
53
- type Envelope<TData = unknown> = {
54
- data: TData | null | undefined;
55
- error: unknown;
56
- };
57
- /** `unwrap`'s conditional return: a `Promise<TData>` when `R` is a promised envelope, `TData` when
58
- * it is an already-resolved one — inferred off the SAME `R` the overload used to split on, and
59
- * distributing over a union `R` (see the JSDoc above) so an Eden Treaty response's null branch
60
- * never leaks into the resolved type. */
61
- type UnwrapResult<R> = R extends Promise<{
62
- data: infer TData;
63
- error: unknown;
64
- }> ? Promise<NonNullable<TData>> : R extends {
65
- data: infer TData;
66
- error: unknown;
67
- } ? NonNullable<TData> : never;
68
- export {};
69
9
  //# sourceMappingURL=query-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"query-client.d.ts","sourceRoot":"","sources":["../src/query-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAS9D,wFAAwF;AACxF,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,WAAW,CAQvE;AAID;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,EAAE,QAAQ,EAAE,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAK3F;AAED,iGAAiG;AACjG,KAAK,QAAQ,CAAC,KAAK,GAAG,OAAO,IAAI;IAAE,IAAI,EAAE,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAA;AAEnF;;;yCAGyC;AACzC,KAAK,YAAY,CAAC,CAAC,IACjB,CAAC,SAAS,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,KAAK,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAAC,GACpD,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,GAC3B,CAAC,SAAS;IAAE,IAAI,EAAE,MAAM,KAAK,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAC7C,WAAW,CAAC,KAAK,CAAC,GAClB,KAAK,CAAA"}
1
+ {"version":3,"file":"query-client.d.ts","sourceRoot":"","sources":["../src/query-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AA0B9D,wFAAwF;AACxF,wBAAgB,eAAe,CAAC,MAAM,CAAC,EAAE,iBAAiB,GAAG,WAAW,CAQvE"}
@@ -1,8 +1,19 @@
1
1
  import { QueryClient } from "@tanstack/react-query";
2
+ const MAX_RETRIES = 2;
3
+ const TRANSIENT_4XX = /* @__PURE__ */ new Set([408, 425, 429]);
4
+ const statusOf = (error) => {
5
+ if (typeof error !== "object" || error === null || !("status" in error)) return void 0;
6
+ return typeof error.status === "number" ? error.status : void 0;
7
+ };
8
+ const retry = (failureCount, error) => {
9
+ const status = statusOf(error);
10
+ const retryable = status === void 0 || status < 400 || status >= 500 || TRANSIENT_4XX.has(status);
11
+ return failureCount < MAX_RETRIES && retryable;
12
+ };
2
13
  const BASALT_QUERY_DEFAULTS = {
3
14
  staleTime: 3e4,
4
15
  gcTime: 5 * 60 * 1e3,
5
- retry: 2,
16
+ retry,
6
17
  refetchOnWindowFocus: false
7
18
  };
8
19
  function makeQueryClient(config) {
@@ -14,22 +25,6 @@ function makeQueryClient(config) {
14
25
  }
15
26
  });
16
27
  }
17
- function unwrap(response) {
18
- if (response instanceof Promise) {
19
- return response.then((envelope) => unwrapEnvelope(envelope));
20
- }
21
- return unwrapEnvelope(response);
22
- }
23
- function unwrapEnvelope(envelope) {
24
- const { data, error } = envelope;
25
- if (error) throw error;
26
- if (data === null || data === void 0)
27
- throw new Error(
28
- "unwrap: null/undefined data with no error \u2014 check for a 204 response or a transport failure"
29
- );
30
- return data;
31
- }
32
28
  export {
33
- makeQueryClient,
34
- unwrap
29
+ makeQueryClient
35
30
  };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The nav definition's runtime stash and its flatten reader, as a leaf (types only from `./nav`):
3
+ * `defineNav` fills it; Spotlight's action builder, the route transitions and the provider read it.
4
+ * Kept apart from `nav.ts` so no reader imports the module that registers the Spotlight mount.
5
+ */
6
+ import type { AnyNavGroup, AnyNavItem } from './nav.js';
7
+ /** @internal */
8
+ export declare function getActiveNav(): {
9
+ groups: ReadonlyArray<AnyNavGroup>;
10
+ } | undefined;
11
+ /** @internal — `defineNav` only. The last call wins. */
12
+ export declare function setActiveNav(nav: {
13
+ groups: ReadonlyArray<AnyNavGroup>;
14
+ }): void;
15
+ /** A flattened destination, tagged with the group it was declared in. */
16
+ export type FlatNavItem = AnyNavItem & {
17
+ groupId: string;
18
+ groupLabel: string;
19
+ };
20
+ /** Depth-first flatten, parent then children — the leaf every other surface reads. */
21
+ export declare function flattenNav(config: {
22
+ groups: ReadonlyArray<AnyNavGroup>;
23
+ }): FlatNavItem[];
24
+ //# sourceMappingURL=nav-stash.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nav-stash.d.ts","sourceRoot":"","sources":["../../src/router-tanstack/nav-stash.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAWpD,gBAAgB;AAChB,wBAAgB,YAAY,IAAI;IAAE,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,CAAA;CAAE,GAAG,SAAS,CAEjF;AAED,wDAAwD;AACxD,wBAAgB,YAAY,CAAC,GAAG,EAAE;IAAE,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,CAAA;CAAE,GAAG,IAAI,CAE9E;AAED,yEAAyE;AACzE,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAA;AAE9E,sFAAsF;AACtF,wBAAgB,UAAU,CAAC,MAAM,EAAE;IAAE,MAAM,EAAE,aAAa,CAAC,WAAW,CAAC,CAAA;CAAE,GAAG,WAAW,EAAE,CAUxF"}
@@ -0,0 +1,23 @@
1
+ let activeNav;
2
+ function getActiveNav() {
3
+ return activeNav;
4
+ }
5
+ function setActiveNav(nav) {
6
+ activeNav = nav;
7
+ }
8
+ function flattenNav(config) {
9
+ const out = [];
10
+ const walk = (items, groupId, groupLabel) => {
11
+ for (const item of items) {
12
+ out.push({ ...item, groupId, groupLabel });
13
+ if (item.children) walk(item.children, groupId, groupLabel);
14
+ }
15
+ };
16
+ for (const g of config.groups) walk(g.items, g.id, g.label);
17
+ return out;
18
+ }
19
+ export {
20
+ flattenNav,
21
+ getActiveNav,
22
+ setActiveNav
23
+ };