basalt-ui 2.12.0 → 2.13.1
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/CHANGELOG.md +35 -0
- package/MIGRATING.md +50 -12
- package/agent/rules/basalt-state.md +1 -1
- package/agent/skills/basalt-app/SKILL.md +1 -1
- 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 +3 -3
- package/dist/cli/doctor-upgrade.d.ts.map +1 -1
- package/dist/cli/doctor-upgrade.js +28 -44
- package/dist/cli/doctor.js +3 -3
- package/dist/cli/index.d.ts +4 -28
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +10 -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 +18 -13
- 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/index.d.ts +2 -2
- package/dist/provider/index.d.ts.map +1 -1
- package/dist/provider/index.js +23 -7
- 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.d.ts +5 -0
- package/dist/router-tanstack/nav.d.ts.map +1 -1
- 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.d.ts +4 -2
- package/dist/router-tanstack/use-nav.d.ts.map +1 -1
- package/dist/router-tanstack/use-nav.js +55 -18
- package/dist/shell/app-breadcrumbs.d.ts +1 -3
- package/dist/shell/app-breadcrumbs.d.ts.map +1 -1
- package/dist/shell/app-breadcrumbs.js +1 -6
- package/dist/shell/index.d.ts +14 -5
- package/dist/shell/index.d.ts.map +1 -1
- package/dist/shell/index.js +6 -29
- package/dist/shell/nav-types.d.ts +7 -0
- package/dist/shell/nav-types.d.ts.map +1 -1
- package/dist/shell/page-aside.d.ts +4 -2
- package/dist/shell/page-aside.d.ts.map +1 -1
- package/dist/shell/page-aside.js +41 -23
- package/dist/shell/page-bar.d.ts +1 -1
- package/dist/shell/page-bar.d.ts.map +1 -1
- package/dist/shell/page-bar.js +39 -33
- 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 +9 -5
- package/package.json +1 -1
- package/src/cli/basalt-install.ts +9 -0
- package/src/cli/check-theme.ts +1 -1
- package/src/cli/doctor-upgrade.ts +40 -61
- package/src/cli/doctor.ts +3 -3
- package/src/cli/index.ts +14 -71
- 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 +27 -21
- 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/index.tsx +27 -9
- package/src/query-client.ts +20 -78
- package/src/router-tanstack/nav.ts +5 -0
- 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 +116 -76
- package/src/shell/app-breadcrumbs.tsx +1 -12
- package/src/shell/index.tsx +22 -55
- package/src/shell/nav-types.ts +8 -0
- package/src/shell/page-aside.tsx +59 -26
- package/src/shell/page-bar.tsx +63 -59
- 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
package/src/shell/page-bar.tsx
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
* Originally extracted from argo's `apps/dashboard/src/components/app-shell/page-header.tsx`;
|
|
23
23
|
* linewatch's `page-header.tsx` measure-and-publish effect became the framework behaviour below.
|
|
24
24
|
*/
|
|
25
|
-
import { createContext, useCallback, useContext, useEffect, useRef, useState } from 'react'
|
|
25
|
+
import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react'
|
|
26
26
|
import type { ReactNode } from 'react'
|
|
27
27
|
import { createPortal } from 'react-dom'
|
|
28
28
|
import { cx } from '../common/props'
|
|
@@ -50,7 +50,7 @@ export const PAGE_BAR_HEIGHT_VAR = '--basalt-page-bar-h'
|
|
|
50
50
|
* What a `PageAside` publishes when it projects itself into row 2 below `sm`
|
|
51
51
|
* (`docs/ASIDE-SPEC.md` §0 "Desktop and mobile are one declaration"). Metadata only — the aside's
|
|
52
52
|
* CHILDREN never travel through this context: they are portalled into the sheet's own node
|
|
53
|
-
* ({@link
|
|
53
|
+
* ({@link AsidePanelSlot.panelTarget}), because a `ReactNode` in state would be a fresh object on
|
|
54
54
|
* every parent render and the claim effect would loop.
|
|
55
55
|
*/
|
|
56
56
|
export type AsidePanelClaim = {
|
|
@@ -60,49 +60,36 @@ export type AsidePanelClaim = {
|
|
|
60
60
|
readonly icon: ReactNode
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
/** Narrow, memoized contexts: a reader of one is not re-rendered by a change to another. */
|
|
64
|
+
type PortalTargets = {
|
|
64
65
|
/** The header node row 1 portals into. `null` outside a shell, and until the outlet mounts. */
|
|
65
66
|
target: HTMLElement | null
|
|
66
67
|
setTarget: (el: HTMLElement | null) => void
|
|
67
|
-
/**
|
|
68
|
-
* The BAND node row 2 portals into — a shell-owned box between the header and the scrollport.
|
|
69
|
-
* Same mechanism as `target` one region down, and it exists for the same reason: where a row
|
|
70
|
-
* renders must not depend on where the consumer wrote `<PageBar>` in its page tree. Row 2 used to
|
|
71
|
-
* render in flow at the top of Main and stick there, which meant a bar nested inside a `Stack`
|
|
72
|
-
* (every real page) had `position: sticky` clamped to that wrapper and sat one shell padding low.
|
|
73
|
-
* `null` outside a shell, and until the outlet mounts.
|
|
74
|
-
*/
|
|
68
|
+
/** The shell-owned band between the header and the scrollport that row 2 portals into. */
|
|
75
69
|
bandTarget: HTMLElement | null
|
|
76
70
|
setBandTarget: (el: HTMLElement | null) => void
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
/** How many page kebabs are mounted. `> 0` means the shell must not render one of its own. */
|
|
82
|
-
kebabClaims: number
|
|
83
|
-
claimKebab: () => () => void
|
|
84
|
-
/** True while a mounted `PageBar` is rendering a row 2 — the row that can host the aside's pill.
|
|
85
|
-
* Without one the aside keeps its in-flow mobile form; there is nowhere to put the trigger. */
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
type AsidePanelSlot = {
|
|
74
|
+
/** True while a mounted `PageBar` renders a row 2 (the only host for the aside's pill). */
|
|
86
75
|
panelHost: boolean
|
|
87
76
|
claimPanelHost: () => () => void
|
|
88
|
-
/** The projecting aside, or `null`.
|
|
77
|
+
/** The projecting aside, or `null`. */
|
|
89
78
|
panel: AsidePanelClaim | null
|
|
90
79
|
claimPanel: (panel: AsidePanelClaim) => () => void
|
|
91
|
-
/** The node inside the open panel sheet the aside's children portal into
|
|
92
|
-
* the Drawer unmounts its body, which is what keeps ONE node mounted at a time (law C9). */
|
|
80
|
+
/** The node inside the open panel sheet the aside's children portal into; `null` while closed. */
|
|
93
81
|
panelTarget: HTMLElement | null
|
|
94
82
|
setPanelTarget: (el: HTMLElement | null) => void
|
|
95
83
|
}
|
|
96
84
|
|
|
97
|
-
const
|
|
85
|
+
const NO_TARGETS: PortalTargets = {
|
|
98
86
|
target: null,
|
|
99
87
|
setTarget: () => {},
|
|
100
88
|
bandTarget: null,
|
|
101
89
|
setBandTarget: () => {},
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
claimKebab: () => () => {},
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const NO_PANEL_SLOT: AsidePanelSlot = {
|
|
106
93
|
panelHost: false,
|
|
107
94
|
claimPanelHost: () => () => {},
|
|
108
95
|
panel: null,
|
|
@@ -111,7 +98,12 @@ const NO_SLOTS: PageBarSlots = {
|
|
|
111
98
|
setPanelTarget: () => {},
|
|
112
99
|
}
|
|
113
100
|
|
|
114
|
-
const
|
|
101
|
+
const PortalTargetsContext = createContext<PortalTargets>(NO_TARGETS)
|
|
102
|
+
const AsidePanelContext = createContext<AsidePanelSlot>(NO_PANEL_SLOT)
|
|
103
|
+
/** True only under `BasaltShell` — the provider is shell-internal, so the context IS the probe. */
|
|
104
|
+
const InShellContext = createContext(false)
|
|
105
|
+
/** True while a page's `ActionGroup` holds the header's one mobile kebab. */
|
|
106
|
+
const KebabClaimedContext = createContext(false)
|
|
115
107
|
|
|
116
108
|
/**
|
|
117
109
|
* Internal — mounted by `BasaltShell`. Owns the portal target, and the single-kebab claim that
|
|
@@ -151,37 +143,47 @@ export function PageBarProvider({
|
|
|
151
143
|
}
|
|
152
144
|
}, [])
|
|
153
145
|
|
|
154
|
-
const mobileMoreActions =
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
146
|
+
const mobileMoreActions = useMemo(
|
|
147
|
+
() =>
|
|
148
|
+
globalActions
|
|
149
|
+
.filter((action, index) => (action.mobile ?? (index < 2 ? 'bar' : 'more')) === 'more')
|
|
150
|
+
.map(globalActionAsBarAction),
|
|
151
|
+
[globalActions],
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
const targets = useMemo(
|
|
155
|
+
() => ({ target, setTarget, bandTarget, setBandTarget }),
|
|
156
|
+
[target, bandTarget],
|
|
157
|
+
)
|
|
158
|
+
const panelSlot = useMemo(
|
|
159
|
+
() => ({
|
|
160
|
+
panelHost: panelHostClaims > 0,
|
|
161
|
+
claimPanelHost,
|
|
162
|
+
panel,
|
|
163
|
+
claimPanel,
|
|
164
|
+
panelTarget,
|
|
165
|
+
setPanelTarget,
|
|
166
|
+
}),
|
|
167
|
+
[panelHostClaims, claimPanelHost, panel, claimPanel, panelTarget],
|
|
168
|
+
)
|
|
169
|
+
const extras = useMemo(() => ({ mobileMoreActions, claimKebab }), [mobileMoreActions, claimKebab])
|
|
174
170
|
|
|
175
171
|
return (
|
|
176
|
-
<
|
|
177
|
-
<
|
|
178
|
-
|
|
172
|
+
<InShellContext.Provider value>
|
|
173
|
+
<PortalTargetsContext.Provider value={targets}>
|
|
174
|
+
<KebabClaimedContext.Provider value={kebabClaims > 0}>
|
|
175
|
+
<AsidePanelContext.Provider value={panelSlot}>
|
|
176
|
+
<BarExtrasProvider value={extras}>{children}</BarExtrasProvider>
|
|
177
|
+
</AsidePanelContext.Provider>
|
|
178
|
+
</KebabClaimedContext.Provider>
|
|
179
|
+
</PortalTargetsContext.Provider>
|
|
180
|
+
</InShellContext.Provider>
|
|
179
181
|
)
|
|
180
182
|
}
|
|
181
183
|
|
|
182
184
|
/** Internal — the app-shell header node the active page's row 1 portals into. */
|
|
183
185
|
export function PageBarOutlet({ className }: { className?: string }) {
|
|
184
|
-
const { setTarget } = useContext(
|
|
186
|
+
const { setTarget } = useContext(PortalTargetsContext)
|
|
185
187
|
return <div ref={setTarget} className={className} />
|
|
186
188
|
}
|
|
187
189
|
|
|
@@ -195,7 +197,7 @@ export function PageBarOutlet({ className }: { className?: string }) {
|
|
|
195
197
|
* `app-main.module.css` is what makes "nothing mounted" and "nothing painted" the same state.
|
|
196
198
|
*/
|
|
197
199
|
export function PageBarBandOutlet({ className }: { className?: string }) {
|
|
198
|
-
const { setBandTarget } = useContext(
|
|
200
|
+
const { setBandTarget } = useContext(PortalTargetsContext)
|
|
199
201
|
return <div ref={setBandTarget} className={className} />
|
|
200
202
|
}
|
|
201
203
|
|
|
@@ -205,12 +207,12 @@ export function PageBarBandOutlet({ className }: { className?: string }) {
|
|
|
205
207
|
* sticky in the document and `Section` must clear it.
|
|
206
208
|
*/
|
|
207
209
|
export function useInPageBarShell(): boolean {
|
|
208
|
-
return useContext(
|
|
210
|
+
return useContext(InShellContext)
|
|
209
211
|
}
|
|
210
212
|
|
|
211
213
|
/** Internal — `true` while a page's `ActionGroup` owns the header's one mobile kebab. */
|
|
212
214
|
export function usePageKebabClaimed(): boolean {
|
|
213
|
-
return useContext(
|
|
215
|
+
return useContext(KebabClaimedContext)
|
|
214
216
|
}
|
|
215
217
|
|
|
216
218
|
/**
|
|
@@ -236,7 +238,8 @@ export function useAsidePanelSlot(): {
|
|
|
236
238
|
claim: (panel: AsidePanelClaim) => () => void
|
|
237
239
|
target: HTMLElement | null
|
|
238
240
|
} {
|
|
239
|
-
const { panelHost, claimPanel, panelTarget
|
|
241
|
+
const { panelHost, claimPanel, panelTarget } = useContext(AsidePanelContext)
|
|
242
|
+
const inShell = useContext(InShellContext)
|
|
240
243
|
const [settled, setSettled] = useState(false)
|
|
241
244
|
useIsomorphicLayoutEffect(() => {
|
|
242
245
|
setSettled(true)
|
|
@@ -398,8 +401,9 @@ export function PageBar({
|
|
|
398
401
|
style,
|
|
399
402
|
classNames,
|
|
400
403
|
}: PageBarProps): ReactNode {
|
|
401
|
-
const { target, bandTarget
|
|
402
|
-
|
|
404
|
+
const { target, bandTarget } = useContext(PortalTargetsContext)
|
|
405
|
+
const { panel, claimPanelHost, setPanelTarget } = useContext(AsidePanelContext)
|
|
406
|
+
const inShell = useContext(InShellContext)
|
|
403
407
|
// An overlay's open flag, like `FilterPill`'s and `FilterSet`'s — not page state (C3).
|
|
404
408
|
const [panelOpened, setPanelOpened] = useState(false)
|
|
405
409
|
|
package/src/telemetry.ts
CHANGED
|
@@ -58,8 +58,21 @@ type ChatAttrs = {
|
|
|
58
58
|
export type BasaltEvent =
|
|
59
59
|
| Ok<'route.navigate', RouteAttrs>
|
|
60
60
|
| Err<'route.error', { 'basalt.route.id': string }>
|
|
61
|
-
| Err<
|
|
62
|
-
|
|
61
|
+
| Err<
|
|
62
|
+
'query.error',
|
|
63
|
+
{
|
|
64
|
+
/** `groupingId(queryHash)`: an opaque grouping id, not the key. */
|
|
65
|
+
'basalt.query.hash': string
|
|
66
|
+
'basalt.query.failure_count': number
|
|
67
|
+
}
|
|
68
|
+
>
|
|
69
|
+
| Err<
|
|
70
|
+
'mutation.error',
|
|
71
|
+
{
|
|
72
|
+
/** `groupingId(JSON.stringify(key))`: an opaque grouping id, not the key. */
|
|
73
|
+
'basalt.mutation.key': string
|
|
74
|
+
}
|
|
75
|
+
>
|
|
63
76
|
| Err<'render.error', { 'basalt.error.boundary': 'root' }>
|
|
64
77
|
| Err<'window.error', { 'basalt.error.source': 'error' | 'unhandledrejection' }>
|
|
65
78
|
| Ok<'chat.turn', ChatAttrs>
|
|
@@ -128,6 +141,26 @@ export type Telemetry = ((event: BasaltEvent) => void) & {
|
|
|
128
141
|
|
|
129
142
|
export const now = (): number => performance.timeOrigin + performance.now()
|
|
130
143
|
|
|
144
|
+
/**
|
|
145
|
+
* An opaque grouping id (32-bit djb2, hex) for a query or mutation key, so events from one key group
|
|
146
|
+
* together and the key's segments (ids, slugs) stay out of the event. NOT a privacy guarantee: it is
|
|
147
|
+
* non-cryptographic and a short or guessable key can be recovered by trying candidates.
|
|
148
|
+
*/
|
|
149
|
+
export function groupingId(value: string): string {
|
|
150
|
+
let h = 5381
|
|
151
|
+
for (let i = 0; i < value.length; i++) h = (h * 33) ^ value.charCodeAt(i)
|
|
152
|
+
return (h >>> 0).toString(16)
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* The sink an unset `telemetry` gets outside production: query and mutation failures, which nothing
|
|
157
|
+
* else surfaces (route, render and window errors already log themselves). Ids and error names only.
|
|
158
|
+
*/
|
|
159
|
+
export const devConsoleSink: Telemetry = (event) => {
|
|
160
|
+
if (event.type === 'query.error' || event.type === 'mutation.error')
|
|
161
|
+
console.error(`[basalt] ${event.type}`, event.attributes)
|
|
162
|
+
}
|
|
163
|
+
|
|
131
164
|
/** `error.name`, `'Error'` for a non-`Error` throw. */
|
|
132
165
|
export const errorName = (error: unknown): string => (error instanceof Error ? error.name : 'Error')
|
|
133
166
|
|
|
@@ -155,24 +188,49 @@ export function createLiveEmitter(read: () => Telemetry | undefined): Telemetry
|
|
|
155
188
|
})
|
|
156
189
|
}
|
|
157
190
|
|
|
158
|
-
function noop(): void {}
|
|
159
|
-
|
|
160
191
|
/**
|
|
161
192
|
* The provider's wrapped emitter, for hooks that emit their own events (`useAgentThreadRuns`'
|
|
162
193
|
* `chat.turn`). `undefined` outside a `BasaltProvider`, where such a hook emits nothing.
|
|
163
194
|
*/
|
|
164
195
|
export const TelemetryContext = createContext<Telemetry | undefined>(undefined)
|
|
165
196
|
|
|
166
|
-
/**
|
|
167
|
-
|
|
197
|
+
/**
|
|
198
|
+
* On `context.__basalt` of a `basaltRouterOptions` router: where its `defaultOnCatch` reports to.
|
|
199
|
+
* The factory and `bindRouteError` are the only two places that know this key.
|
|
200
|
+
*/
|
|
201
|
+
export type RouterHook = { onRouteError?: ((error: unknown) => void) | undefined }
|
|
168
202
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
}
|
|
203
|
+
function hookOf(context: unknown): RouterHook | undefined {
|
|
204
|
+
if (typeof context !== 'object' || context === null || !('__basalt' in context)) return undefined
|
|
205
|
+
const hook = context.__basalt
|
|
206
|
+
return typeof hook === 'object' && hook !== null ? hook : undefined
|
|
174
207
|
}
|
|
175
208
|
|
|
176
|
-
|
|
177
|
-
|
|
209
|
+
const MISSING_HOOK =
|
|
210
|
+
'[basalt] route.error telemetry is off: the router was not built with `basaltRouterOptions()` (or `createBasaltRouter`).'
|
|
211
|
+
let warnedMissingHook = false
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Points the router's `route.error` hook at `handler` (the provider's emitter); returns the unbind.
|
|
215
|
+
* The binding happens in the provider's effect, so a route error thrown before the first provider
|
|
216
|
+
* effect (a loader failing during the initial load) reaches the console only, never the sink. A
|
|
217
|
+
* router without the hook was not built with `basaltRouterOptions`: nothing is bound and it warns.
|
|
218
|
+
*/
|
|
219
|
+
export function bindRouteError(
|
|
220
|
+
router: { options: { context?: unknown } },
|
|
221
|
+
handler: (error: unknown) => void,
|
|
222
|
+
): () => void {
|
|
223
|
+
const hook = hookOf(router.options.context)
|
|
224
|
+
if (!hook) {
|
|
225
|
+
// Dev warns on every bind; production once per document.
|
|
226
|
+
if (process.env.NODE_ENV !== 'production' || !warnedMissingHook) {
|
|
227
|
+
warnedMissingHook = true
|
|
228
|
+
console.warn(MISSING_HOOK)
|
|
229
|
+
}
|
|
230
|
+
return () => {}
|
|
231
|
+
}
|
|
232
|
+
hook.onRouteError = handler
|
|
233
|
+
return () => {
|
|
234
|
+
if (hook.onRouteError === handler) hook.onRouteError = undefined
|
|
235
|
+
}
|
|
178
236
|
}
|