@bgub/fig-tanstack-router 0.1.0-alpha.2 → 0.1.0-alpha.3
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 +22 -0
- package/dist-development/router.js +995 -0
- package/dist-development/router.js.map +1 -0
- package/package.json +7 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
## @bgub/fig-tanstack-router@0.1.0-alpha.3
|
|
2
|
+
|
|
3
|
+
### Let Fig's Vite integration own runtime configuration
|
|
4
|
+
|
|
5
|
+
The new `fig()` Vite integration defines Fig's development gate and installs
|
|
6
|
+
Fast Refresh. TanStack Start composes it automatically, so applications no
|
|
7
|
+
longer need to configure Fig's compile-time mode or SSR package bundling
|
|
8
|
+
themselves.
|
|
9
|
+
|
|
10
|
+
`@bgub/fig-vite` now uses the application's Fig DOM renderer as a peer instead
|
|
11
|
+
of installing a private renderer copy.
|
|
12
|
+
|
|
13
|
+
The development gate follows Vite's command rather than its mode: serving
|
|
14
|
+
enables development behavior, while builds—including `--mode development`—strip
|
|
15
|
+
it from production output.
|
|
16
|
+
|
|
17
|
+
Published npm packages now expose development artifacts through a Fig-owned
|
|
18
|
+
condition, allowing the Vite integration to enable diagnostics and Fast Refresh
|
|
19
|
+
for ordinary installs while explicit static overrides remain authoritative and
|
|
20
|
+
default production imports retain their previous dead-code elimination. A
|
|
21
|
+
static `false` override also disables Fast Refresh instrumentation.
|
|
22
|
+
|
|
1
23
|
## @bgub/fig-tanstack-router@0.1.0-alpha.1
|
|
2
24
|
|
|
3
25
|
### Add the TanStack Router adapter for Fig
|
|
@@ -0,0 +1,995 @@
|
|
|
1
|
+
import { createBrowserHistory, createHashHistory, createMemoryHistory } from "@tanstack/history";
|
|
2
|
+
import { BaseRootRoute, BaseRoute, BaseRouteApi, RouterCore, appendUniqueUserTags, createControlledPromise, createNonReactiveMutableStore, createNonReactiveReadonlyStore, deepEqual, defaultParseSearch, defaultStringifySearch, escapeHtml, exactPathTest, getAssetCrossOrigin, getLocationChangeInfo, getScriptPreloadAttrs, isDangerousProtocol, isNotFound, isNotFound as isNotFound$1, isRedirect, lazyFn, notFound, notFound as notFound$1, parseSearchWith, redirect, removeTrailingSlash, replaceEqualDeep, resolveManifestCssLink, retainSearchParams, rootRouteId, rootRouteId as rootRouteId$1, setupScrollRestoration, stringifySearchWith, stripSearchParams } from "@tanstack/router-core";
|
|
3
|
+
import { ErrorBoundary, Suspense, assets, createContext, createElement, readContext, readPromise, transition, useBeforePaint, useCallback, useMemo, useReactive, useState, useSyncExternalStore } from "@bgub/fig";
|
|
4
|
+
import { batch, createAtom } from "@tanstack/store";
|
|
5
|
+
import { composeBind, on } from "@bgub/fig-dom";
|
|
6
|
+
import { getScrollRestorationScriptForRouter } from "@tanstack/router-core/scroll-restoration-script";
|
|
7
|
+
import { assetResourceDestination, assetResourceFromHostProps, preventAssetResourceHoist } from "@bgub/fig/internal";
|
|
8
|
+
//#region src/data-context.ts
|
|
9
|
+
async function ensureRouteData(context, resource, ...args) {
|
|
10
|
+
await context.data.ensureData(resource, ...args);
|
|
11
|
+
}
|
|
12
|
+
function dataStoreFromContext(context) {
|
|
13
|
+
return context?.data;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/store.ts
|
|
17
|
+
const getStoreConfig = (options) => {
|
|
18
|
+
if (options.isServer ?? typeof document === "undefined") return {
|
|
19
|
+
batch: (callback) => callback(),
|
|
20
|
+
createMutableStore: createNonReactiveMutableStore,
|
|
21
|
+
createReadonlyStore: createNonReactiveReadonlyStore
|
|
22
|
+
};
|
|
23
|
+
return {
|
|
24
|
+
batch,
|
|
25
|
+
createMutableStore: createAtom,
|
|
26
|
+
createReadonlyStore: createAtom
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
function selectStoreValue(value) {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
function doNothing() {}
|
|
33
|
+
function useReadableStore(store, select = selectStoreValue, equal = Object.is) {
|
|
34
|
+
const subscribe = useCallback((onChange) => store.subscribe?.(onChange).unsubscribe ?? doNothing, [store]);
|
|
35
|
+
const getSnapshot = useMemo(() => {
|
|
36
|
+
let source;
|
|
37
|
+
let selected;
|
|
38
|
+
let initialized = false;
|
|
39
|
+
return () => {
|
|
40
|
+
const nextSource = store.get();
|
|
41
|
+
if (initialized && Object.is(source, nextSource)) return selected;
|
|
42
|
+
const nextSelected = select(nextSource);
|
|
43
|
+
source = nextSource;
|
|
44
|
+
if (initialized && equal(selected, nextSelected)) return selected;
|
|
45
|
+
selected = nextSelected;
|
|
46
|
+
initialized = true;
|
|
47
|
+
return selected;
|
|
48
|
+
};
|
|
49
|
+
}, [
|
|
50
|
+
equal,
|
|
51
|
+
select,
|
|
52
|
+
store
|
|
53
|
+
]);
|
|
54
|
+
return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/hooks.tsx
|
|
58
|
+
const RouterContext = createContext(null);
|
|
59
|
+
const MatchContext = createContext(null);
|
|
60
|
+
const missingMatch = Symbol("missing route match");
|
|
61
|
+
const missingMatchStore = { get: () => void 0 };
|
|
62
|
+
function useRouter() {
|
|
63
|
+
return requireRouter(readContext(RouterContext));
|
|
64
|
+
}
|
|
65
|
+
function requireRouter(router) {
|
|
66
|
+
if (router === null) throw new Error("Router hooks must be used inside <RouterProvider>.");
|
|
67
|
+
return router;
|
|
68
|
+
}
|
|
69
|
+
function useStoreSelector(router, options) {
|
|
70
|
+
const previous = useMemo(() => ({
|
|
71
|
+
initialized: false,
|
|
72
|
+
value: void 0
|
|
73
|
+
}), []);
|
|
74
|
+
const select = options?.select;
|
|
75
|
+
const structuralSharing = options?.structuralSharing ?? router.options.defaultStructuralSharing ?? false;
|
|
76
|
+
return useCallback((value) => {
|
|
77
|
+
let selected = select === void 0 ? value : select(value);
|
|
78
|
+
if (structuralSharing && previous.initialized) selected = replaceEqualDeep(previous.value, selected);
|
|
79
|
+
previous.initialized = true;
|
|
80
|
+
previous.value = selected;
|
|
81
|
+
return selected;
|
|
82
|
+
}, [
|
|
83
|
+
previous,
|
|
84
|
+
select,
|
|
85
|
+
structuralSharing
|
|
86
|
+
]);
|
|
87
|
+
}
|
|
88
|
+
function useRouterState(options) {
|
|
89
|
+
const router = requireRouter(options?.router ?? readContext(RouterContext));
|
|
90
|
+
const select = useStoreSelector(router, options);
|
|
91
|
+
return useReadableStore(router.stores.__store, select);
|
|
92
|
+
}
|
|
93
|
+
function useLocation(options) {
|
|
94
|
+
const router = useRouter();
|
|
95
|
+
const select = useStoreSelector(router, options);
|
|
96
|
+
return useReadableStore(router.stores.location, select);
|
|
97
|
+
}
|
|
98
|
+
function useBlocker(options) {
|
|
99
|
+
const { disabled = false, enableBeforeUnload = true, shouldBlockFn, withResolver = false } = options;
|
|
100
|
+
const router = useRouter();
|
|
101
|
+
const [resolver, setResolver] = useState(idleBlockerResolver);
|
|
102
|
+
useBeforePaint((signal) => {
|
|
103
|
+
if (disabled) return void 0;
|
|
104
|
+
let settlePending;
|
|
105
|
+
const unblock = router.history.block({
|
|
106
|
+
enableBeforeUnload,
|
|
107
|
+
blockerFn: async (args) => {
|
|
108
|
+
const current = blockerLocation(router, args.currentLocation);
|
|
109
|
+
const next = blockerLocation(router, args.nextLocation);
|
|
110
|
+
const shouldBlock = await shouldBlockFn({
|
|
111
|
+
action: args.action,
|
|
112
|
+
current,
|
|
113
|
+
next
|
|
114
|
+
});
|
|
115
|
+
if (!withResolver || !shouldBlock) return shouldBlock;
|
|
116
|
+
const resolved = await new Promise((resolve) => {
|
|
117
|
+
settlePending = resolve;
|
|
118
|
+
setResolver({
|
|
119
|
+
action: args.action,
|
|
120
|
+
current,
|
|
121
|
+
next,
|
|
122
|
+
proceed: () => resolve(false),
|
|
123
|
+
reset: () => resolve(true),
|
|
124
|
+
status: "blocked"
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
settlePending = void 0;
|
|
128
|
+
setResolver(idleBlockerResolver);
|
|
129
|
+
return resolved;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
signal.addEventListener("abort", () => {
|
|
133
|
+
unblock();
|
|
134
|
+
settlePending?.(false);
|
|
135
|
+
}, { once: true });
|
|
136
|
+
}, [
|
|
137
|
+
disabled,
|
|
138
|
+
enableBeforeUnload,
|
|
139
|
+
router,
|
|
140
|
+
shouldBlockFn,
|
|
141
|
+
withResolver
|
|
142
|
+
]);
|
|
143
|
+
return withResolver ? resolver : void 0;
|
|
144
|
+
}
|
|
145
|
+
function useCanGoBack() {
|
|
146
|
+
const router = useRouter();
|
|
147
|
+
return useReadableStore(router.stores.location, router.history.canGoBack);
|
|
148
|
+
}
|
|
149
|
+
function blockerLocation(router, location) {
|
|
150
|
+
const parsed = router.parseLocation(location);
|
|
151
|
+
const matched = router.getMatchedRoutes(parsed.pathname);
|
|
152
|
+
return {
|
|
153
|
+
fullPath: matched.foundRoute?.fullPath ?? parsed.pathname,
|
|
154
|
+
params: matched.routeParams,
|
|
155
|
+
pathname: parsed.pathname,
|
|
156
|
+
routeId: matched.foundRoute?.id ?? "__notFound__",
|
|
157
|
+
search: parsed.search
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
const idleBlockerResolver = {
|
|
161
|
+
action: void 0,
|
|
162
|
+
current: void 0,
|
|
163
|
+
next: void 0,
|
|
164
|
+
proceed: void 0,
|
|
165
|
+
reset: void 0,
|
|
166
|
+
status: "idle"
|
|
167
|
+
};
|
|
168
|
+
function useMatch(options) {
|
|
169
|
+
return useMatchValue(options?.from, options, (match) => match, options?.shouldThrow);
|
|
170
|
+
}
|
|
171
|
+
function useMatchSelection(from, select, shouldThrow = true, structuralSharing) {
|
|
172
|
+
const router = useRouter();
|
|
173
|
+
const nearestMatchStore = readContext(MatchContext);
|
|
174
|
+
const store = from === void 0 || nearestMatchStore?.get().routeId === from ? nearestMatchStore : router.stores.getRouteMatchStore(from);
|
|
175
|
+
const selectMatch = useStoreSelector(router, {
|
|
176
|
+
select,
|
|
177
|
+
structuralSharing
|
|
178
|
+
});
|
|
179
|
+
const selectPresentMatch = useCallback((match) => match === void 0 ? missingMatch : selectMatch(match), [selectMatch]);
|
|
180
|
+
const selected = useReadableStore(store ?? missingMatchStore, selectPresentMatch);
|
|
181
|
+
if (selected === missingMatch) {
|
|
182
|
+
if (shouldThrow) {
|
|
183
|
+
const target = from ? `route ${JSON.stringify(from)}` : "the nearest route";
|
|
184
|
+
throw new Error(`Could not find an active match for ${target}.`);
|
|
185
|
+
}
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
return selected;
|
|
189
|
+
}
|
|
190
|
+
function useMatchValue(from, options, getValue, shouldThrow = true) {
|
|
191
|
+
return useMatchSelection(from, (match) => {
|
|
192
|
+
const value = getValue(match);
|
|
193
|
+
return options?.select === void 0 ? value : options.select(value);
|
|
194
|
+
}, shouldThrow, options?.structuralSharing);
|
|
195
|
+
}
|
|
196
|
+
function useParams(options) {
|
|
197
|
+
return useMatchValue(options?.from, options, (match) => match.params, options?.shouldThrow);
|
|
198
|
+
}
|
|
199
|
+
function useSearch(options) {
|
|
200
|
+
return useMatchValue(options?.from, options, (match) => match.search, options?.shouldThrow);
|
|
201
|
+
}
|
|
202
|
+
function useLoaderDeps(options) {
|
|
203
|
+
return useMatchValue(options?.from, options, (match) => match.loaderDeps);
|
|
204
|
+
}
|
|
205
|
+
function useRouteContext(options) {
|
|
206
|
+
return useMatchValue(options?.from, options, (match) => match.context);
|
|
207
|
+
}
|
|
208
|
+
function useNavigate(options) {
|
|
209
|
+
return useNavigateFrom(options?.from);
|
|
210
|
+
}
|
|
211
|
+
function useNavigateFrom(from) {
|
|
212
|
+
const router = useRouter();
|
|
213
|
+
return useCallback(((navigateOptions) => router.navigate({
|
|
214
|
+
...navigateOptions,
|
|
215
|
+
from: navigateOptions.from ?? from
|
|
216
|
+
})), [from, router]);
|
|
217
|
+
}
|
|
218
|
+
function Navigate(props) {
|
|
219
|
+
const navigate = useNavigateFrom(void 0);
|
|
220
|
+
const previous = useMemo(() => ({ props: void 0 }), []);
|
|
221
|
+
useBeforePaint(() => {
|
|
222
|
+
if (previous.props === void 0 || !deepEqual(previous.props, props)) {
|
|
223
|
+
previous.props = props;
|
|
224
|
+
navigate(props);
|
|
225
|
+
}
|
|
226
|
+
}, [
|
|
227
|
+
navigate,
|
|
228
|
+
previous,
|
|
229
|
+
props
|
|
230
|
+
]);
|
|
231
|
+
return null;
|
|
232
|
+
}
|
|
233
|
+
function useMatches(options) {
|
|
234
|
+
const router = useRouter();
|
|
235
|
+
const select = useStoreSelector(router, options);
|
|
236
|
+
return useReadableStore(router.stores.matches, select);
|
|
237
|
+
}
|
|
238
|
+
function useMatchRoute() {
|
|
239
|
+
const router = useRouter();
|
|
240
|
+
useReadableStore(router.stores.matchRouteDeps);
|
|
241
|
+
return useCallback((options) => {
|
|
242
|
+
const { pending, caseSensitive, fuzzy, includeSearch, ...location } = options;
|
|
243
|
+
return router.matchRoute(location, {
|
|
244
|
+
pending,
|
|
245
|
+
caseSensitive,
|
|
246
|
+
fuzzy,
|
|
247
|
+
includeSearch
|
|
248
|
+
});
|
|
249
|
+
}, [router]);
|
|
250
|
+
}
|
|
251
|
+
function MatchRoute(props) {
|
|
252
|
+
const { children, ...options } = props;
|
|
253
|
+
const params = useMatchRoute()(options);
|
|
254
|
+
if (typeof children === "function") return children(params === false ? void 0 : params);
|
|
255
|
+
return params === false ? null : children;
|
|
256
|
+
}
|
|
257
|
+
//#endregion
|
|
258
|
+
//#region src/link.tsx
|
|
259
|
+
function Link(props) {
|
|
260
|
+
const router = useRouter();
|
|
261
|
+
const currentLocation = useReadableStore(router.stores.resolvedLocation) ?? router.stores.location.get();
|
|
262
|
+
const [isTransitioning, setIsTransitioning] = useState(false);
|
|
263
|
+
const state = useMemo(() => ({}), []);
|
|
264
|
+
useBeforePaint((signal) => {
|
|
265
|
+
signal.addEventListener("abort", () => {
|
|
266
|
+
state.unsubscribe?.();
|
|
267
|
+
if (state.preloadTimeout !== void 0) clearTimeout(state.preloadTimeout);
|
|
268
|
+
}, { once: true });
|
|
269
|
+
}, [state]);
|
|
270
|
+
const { _fromLocation, activeOptions, activeProps, children, disabled, from: _from, hash: _hash, hashScrollIntoView: _hashScrollIntoView, href: explicitHref, ignoreBlocker: _ignoreBlocker, inactiveProps, mask: _mask, mix, params: _params, preload: requestedPreload, preloadDelay: requestedPreloadDelay, reloadDocument, replace: _replace, resetScroll: _resetScroll, search: _search, startTransition: _startTransition, state: _state, target, to, unsafeRelative: _unsafeRelative, viewTransition: _viewTransition, ...anchorProps } = props;
|
|
271
|
+
const absolute = isAbsoluteLinkTarget(to, router.origin);
|
|
272
|
+
const next = !absolute ? router.buildLocation({
|
|
273
|
+
...props,
|
|
274
|
+
_isNavigate: false
|
|
275
|
+
}) : void 0;
|
|
276
|
+
const displayedLocation = next?.maskedLocation ?? next;
|
|
277
|
+
const href = disabled ? void 0 : explicitHref ?? (absolute ? to : void 0) ?? (displayedLocation === void 0 ? void 0 : router.history.createHref(displayedLocation.publicHref) || "/");
|
|
278
|
+
const external = absolute || displayedLocation?.external === true || explicitHref !== void 0 && isAbsoluteLinkTarget(explicitHref, router.origin);
|
|
279
|
+
const dangerous = href !== void 0 ? isDangerousProtocol(href, router.protocolAllowlist) : false;
|
|
280
|
+
const preload = reloadDocument || external || dangerous || explicitHref !== void 0 ? false : requestedPreload ?? router.options.defaultPreload;
|
|
281
|
+
const preloadDelay = requestedPreloadDelay ?? router.options.defaultPreloadDelay ?? 0;
|
|
282
|
+
const isActive = next !== void 0 && !external && linkPathIsActive(currentLocation.pathname, next.pathname, router.basepath, activeOptions?.exact ?? false) && (!(activeOptions?.includeSearch ?? true) || deepEqual(currentLocation.search, next.search, {
|
|
283
|
+
ignoreUndefined: !activeOptions?.explicitUndefined,
|
|
284
|
+
partial: !(activeOptions?.exact ?? false)
|
|
285
|
+
})) && (!activeOptions?.includeHash || currentLocation.hash === next.hash);
|
|
286
|
+
const selectedStateProps = isActive ? activeProps : inactiveProps;
|
|
287
|
+
const { bind: stateBind, class: stateClass, mix: stateMix, style: stateStyle, ...stateAnchorProps } = (typeof selectedStateProps === "function" ? selectedStateProps() : selectedStateProps) ?? {};
|
|
288
|
+
const linkBind = composeBind(anchorProps.bind, stateBind);
|
|
289
|
+
const linkClass = typeof anchorProps.class === "string" && typeof stateClass === "string" ? `${anchorProps.class} ${stateClass}` : stateClass ?? anchorProps.class;
|
|
290
|
+
const linkStyle = typeof anchorProps.style === "object" && anchorProps.style !== null && typeof stateStyle === "object" && stateStyle !== null ? {
|
|
291
|
+
...anchorProps.style,
|
|
292
|
+
...stateStyle
|
|
293
|
+
} : stateStyle ?? anchorProps.style;
|
|
294
|
+
const renderedChildren = typeof children === "function" ? children({
|
|
295
|
+
isActive,
|
|
296
|
+
isTransitioning
|
|
297
|
+
}) : children;
|
|
298
|
+
const preloadRoute = useCallback(() => {
|
|
299
|
+
router.preloadRoute(props).catch((error) => {
|
|
300
|
+
console.warn("Error preloading route", error);
|
|
301
|
+
});
|
|
302
|
+
}, [href, router]);
|
|
303
|
+
useReactive(() => {
|
|
304
|
+
if (!disabled && preload === "render") preloadRoute();
|
|
305
|
+
}, [
|
|
306
|
+
disabled,
|
|
307
|
+
preload,
|
|
308
|
+
preloadRoute
|
|
309
|
+
]);
|
|
310
|
+
const viewportBind = useCallback((element, signal) => {
|
|
311
|
+
if (disabled || preload !== "viewport") return void 0;
|
|
312
|
+
const observer = new IntersectionObserver((entries) => {
|
|
313
|
+
if (entries.some((entry) => entry.isIntersecting)) {
|
|
314
|
+
observer.disconnect();
|
|
315
|
+
preloadRoute();
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
observer.observe(element);
|
|
319
|
+
signal.addEventListener("abort", () => observer.disconnect(), { once: true });
|
|
320
|
+
}, [
|
|
321
|
+
disabled,
|
|
322
|
+
preload,
|
|
323
|
+
preloadRoute
|
|
324
|
+
]);
|
|
325
|
+
const beginIntentPreload = () => {
|
|
326
|
+
if (disabled || preload !== "intent") return;
|
|
327
|
+
if (preloadDelay === 0) {
|
|
328
|
+
preloadRoute();
|
|
329
|
+
return;
|
|
330
|
+
}
|
|
331
|
+
if (state.preloadTimeout !== void 0) return;
|
|
332
|
+
state.preloadTimeout = setTimeout(() => {
|
|
333
|
+
state.preloadTimeout = void 0;
|
|
334
|
+
preloadRoute();
|
|
335
|
+
}, preloadDelay);
|
|
336
|
+
};
|
|
337
|
+
const cancelIntentPreload = () => {
|
|
338
|
+
if (state.preloadTimeout === void 0) return;
|
|
339
|
+
clearTimeout(state.preloadTimeout);
|
|
340
|
+
state.preloadTimeout = void 0;
|
|
341
|
+
};
|
|
342
|
+
return createElement("a", {
|
|
343
|
+
...anchorProps,
|
|
344
|
+
...stateAnchorProps,
|
|
345
|
+
"aria-current": isActive ? "page" : void 0,
|
|
346
|
+
"aria-disabled": disabled ? true : void 0,
|
|
347
|
+
"data-status": isActive ? "active" : void 0,
|
|
348
|
+
"data-transitioning": isTransitioning ? "transitioning" : void 0,
|
|
349
|
+
bind: preload === "viewport" ? composeBind(linkBind, viewportBind) : linkBind,
|
|
350
|
+
class: linkClass,
|
|
351
|
+
href: dangerous ? void 0 : href,
|
|
352
|
+
mix: [
|
|
353
|
+
mix,
|
|
354
|
+
stateMix,
|
|
355
|
+
on("click", (event) => {
|
|
356
|
+
const elementTarget = event.currentTarget instanceof Element ? event.currentTarget.getAttribute("target") : null;
|
|
357
|
+
const effectiveTarget = target ?? elementTarget;
|
|
358
|
+
if (disabled || dangerous || external || reloadDocument || event.defaultPrevented || event.button !== 0 || event.metaKey || event.altKey || event.ctrlKey || event.shiftKey || effectiveTarget !== null && effectiveTarget !== "" && effectiveTarget !== "_self" || anchorProps.download !== void 0) return;
|
|
359
|
+
event.preventDefault();
|
|
360
|
+
state.unsubscribe?.();
|
|
361
|
+
setIsTransitioning(true);
|
|
362
|
+
const unsubscribe = router.subscribe("onResolved", () => {
|
|
363
|
+
unsubscribe();
|
|
364
|
+
state.unsubscribe = void 0;
|
|
365
|
+
setIsTransitioning(false);
|
|
366
|
+
});
|
|
367
|
+
state.unsubscribe = unsubscribe;
|
|
368
|
+
router.navigate(props);
|
|
369
|
+
}),
|
|
370
|
+
preload === "intent" && on("mouseenter", beginIntentPreload),
|
|
371
|
+
preload === "intent" && on("mouseleave", cancelIntentPreload),
|
|
372
|
+
preload === "intent" && on("focus", beginIntentPreload),
|
|
373
|
+
preload === "intent" && on("blur", cancelIntentPreload),
|
|
374
|
+
preload === "intent" && on("touchstart", () => {
|
|
375
|
+
if (!disabled) preloadRoute();
|
|
376
|
+
})
|
|
377
|
+
],
|
|
378
|
+
role: disabled ? "link" : stateAnchorProps.role ?? anchorProps.role,
|
|
379
|
+
style: linkStyle,
|
|
380
|
+
target
|
|
381
|
+
}, renderedChildren);
|
|
382
|
+
}
|
|
383
|
+
function linkPathIsActive(currentPathname, nextPathname, basepath, exact) {
|
|
384
|
+
if (exact) return exactPathTest(currentPathname, nextPathname, basepath);
|
|
385
|
+
const current = removeTrailingSlash(currentPathname, basepath);
|
|
386
|
+
const next = removeTrailingSlash(nextPathname, basepath);
|
|
387
|
+
return current.startsWith(next) && (current.length === next.length || current[next.length] === "/");
|
|
388
|
+
}
|
|
389
|
+
function isAbsoluteLinkTarget(value, origin) {
|
|
390
|
+
if (typeof value !== "string") return false;
|
|
391
|
+
if (!value.startsWith("//") && !value.includes(":")) return false;
|
|
392
|
+
try {
|
|
393
|
+
new URL(value, origin);
|
|
394
|
+
return true;
|
|
395
|
+
} catch {
|
|
396
|
+
return false;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
//#endregion
|
|
400
|
+
//#region src/route-assets.ts
|
|
401
|
+
function collectRouteAssets(router, match, manifest) {
|
|
402
|
+
const nonce = router.options.ssr?.nonce;
|
|
403
|
+
const resources = [];
|
|
404
|
+
const links = [];
|
|
405
|
+
const headScripts = [];
|
|
406
|
+
const scripts = [];
|
|
407
|
+
const manifestRoute = manifest?.routes[match.routeId];
|
|
408
|
+
for (const link of match.links ?? []) {
|
|
409
|
+
if (link === void 0) continue;
|
|
410
|
+
collectTag({
|
|
411
|
+
tag: "link",
|
|
412
|
+
attrs: {
|
|
413
|
+
...link,
|
|
414
|
+
nonce
|
|
415
|
+
}
|
|
416
|
+
}, resources, links);
|
|
417
|
+
}
|
|
418
|
+
for (const link of manifestRoute?.css ?? []) {
|
|
419
|
+
const resolved = resolveManifestCssLink(link);
|
|
420
|
+
collectTag({
|
|
421
|
+
tag: "link",
|
|
422
|
+
attrs: {
|
|
423
|
+
rel: "stylesheet",
|
|
424
|
+
...resolved,
|
|
425
|
+
crossOrigin: getAssetCrossOrigin(router.options.assetCrossOrigin, "stylesheet") ?? resolved.crossOrigin,
|
|
426
|
+
nonce,
|
|
427
|
+
suppressHydrationWarning: true
|
|
428
|
+
}
|
|
429
|
+
}, resources, links);
|
|
430
|
+
}
|
|
431
|
+
for (const link of manifestRoute?.preloads ?? []) collectTag({
|
|
432
|
+
tag: "link",
|
|
433
|
+
attrs: {
|
|
434
|
+
...getScriptPreloadAttrs(manifest, link, router.options.assetCrossOrigin),
|
|
435
|
+
nonce
|
|
436
|
+
}
|
|
437
|
+
}, resources, links);
|
|
438
|
+
collectScripts(match.headScripts, nonce, resources, headScripts);
|
|
439
|
+
collectScripts(match.scripts, nonce, resources, scripts);
|
|
440
|
+
for (const script of manifestRoute?.scripts ?? []) collectTag({
|
|
441
|
+
tag: "script",
|
|
442
|
+
attrs: {
|
|
443
|
+
...script.attrs,
|
|
444
|
+
nonce
|
|
445
|
+
},
|
|
446
|
+
children: script.children
|
|
447
|
+
}, resources, scripts);
|
|
448
|
+
return {
|
|
449
|
+
resources,
|
|
450
|
+
links,
|
|
451
|
+
headScripts,
|
|
452
|
+
scripts
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
function renderRouterHeadTags(tags) {
|
|
456
|
+
const resources = [];
|
|
457
|
+
const nodes = [];
|
|
458
|
+
for (const tag of tags) {
|
|
459
|
+
const resource = resourceFromTag(tag);
|
|
460
|
+
if (resource === null || assetResourceDestination(resource) !== "head") nodes.push(renderPositionedRouterTag(tag));
|
|
461
|
+
else resources.push(resource);
|
|
462
|
+
}
|
|
463
|
+
return resources.length === 0 ? nodes : assets(resources, nodes);
|
|
464
|
+
}
|
|
465
|
+
function renderPositionedRouterTag(tag) {
|
|
466
|
+
return createElement(tag.tag, preventAssetResourceHoist({
|
|
467
|
+
...nativeAttributes(tag.attrs),
|
|
468
|
+
...tag.children === void 0 ? {} : { unsafeHTML: tag.children }
|
|
469
|
+
}));
|
|
470
|
+
}
|
|
471
|
+
function nativeAttributes(attrs) {
|
|
472
|
+
if (attrs === void 0) return {};
|
|
473
|
+
const result = { ...attrs };
|
|
474
|
+
renameAttribute(result, "charSet", "charset");
|
|
475
|
+
renameAttribute(result, "className", "class");
|
|
476
|
+
renameAttribute(result, "crossOrigin", "crossorigin");
|
|
477
|
+
renameAttribute(result, "fetchPriority", "fetchpriority");
|
|
478
|
+
renameAttribute(result, "httpEquiv", "http-equiv");
|
|
479
|
+
renameAttribute(result, "referrerPolicy", "referrerpolicy");
|
|
480
|
+
return result;
|
|
481
|
+
}
|
|
482
|
+
function collectScripts(values, nonce, resources, positioned) {
|
|
483
|
+
for (const script of values ?? []) {
|
|
484
|
+
if (script === void 0) continue;
|
|
485
|
+
const { children, ...attrs } = script;
|
|
486
|
+
collectTag({
|
|
487
|
+
tag: "script",
|
|
488
|
+
attrs: {
|
|
489
|
+
...attrs,
|
|
490
|
+
nonce,
|
|
491
|
+
suppressHydrationWarning: true
|
|
492
|
+
},
|
|
493
|
+
children
|
|
494
|
+
}, resources, positioned);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
function collectTag(tag, resources, positioned) {
|
|
498
|
+
const resource = resourceFromTag(tag);
|
|
499
|
+
if (resource === null) positioned.push(tag);
|
|
500
|
+
else resources.push(resource);
|
|
501
|
+
}
|
|
502
|
+
function resourceFromTag(tag) {
|
|
503
|
+
return assetResourceFromHostProps(tag.tag, {
|
|
504
|
+
...nativeAttributes(tag.attrs),
|
|
505
|
+
children: tag.children
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
function renameAttribute(attrs, from, to) {
|
|
509
|
+
if (attrs[from] !== void 0 && attrs[to] === void 0) attrs[to] = attrs[from];
|
|
510
|
+
delete attrs[from];
|
|
511
|
+
}
|
|
512
|
+
//#endregion
|
|
513
|
+
//#region src/matches.tsx
|
|
514
|
+
function RouterProvider({ router, ...options }) {
|
|
515
|
+
if (Object.keys(options).length > 0) {
|
|
516
|
+
if ("context" in options) options.context = {
|
|
517
|
+
...router.options.context,
|
|
518
|
+
...options.context
|
|
519
|
+
};
|
|
520
|
+
router.update(options);
|
|
521
|
+
}
|
|
522
|
+
return createElement(RouterContext, { value: router }, createElement(Transitioner), createElement(Matches));
|
|
523
|
+
}
|
|
524
|
+
function Transitioner() {
|
|
525
|
+
const router = useRouter();
|
|
526
|
+
const state = useMemo(() => ({
|
|
527
|
+
active: false,
|
|
528
|
+
generation: 0,
|
|
529
|
+
initialLoadStarted: false,
|
|
530
|
+
phase: "idle"
|
|
531
|
+
}), [router]);
|
|
532
|
+
const settleLifecycle = useCallback(() => {
|
|
533
|
+
if (state.phase === "idle") return;
|
|
534
|
+
const isLoading = router.stores.isLoading.get();
|
|
535
|
+
const hasPending = router.stores.hasPending.get();
|
|
536
|
+
const isTransitioning = router.stores.isTransitioning.get();
|
|
537
|
+
const changeInfo = getLocationChangeInfo(router.stores.location.get(), router.stores.resolvedLocation.get());
|
|
538
|
+
if (!isLoading && state.phase === "loading") {
|
|
539
|
+
state.phase = "loaded";
|
|
540
|
+
router.emit({
|
|
541
|
+
type: "onLoad",
|
|
542
|
+
...changeInfo
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
if (!isLoading && !hasPending && state.phase === "loaded") {
|
|
546
|
+
state.phase = "mounting";
|
|
547
|
+
router.emit({
|
|
548
|
+
type: "onBeforeRouteMount",
|
|
549
|
+
...changeInfo
|
|
550
|
+
});
|
|
551
|
+
}
|
|
552
|
+
if (!isLoading && !hasPending && !isTransitioning) {
|
|
553
|
+
state.phase = "idle";
|
|
554
|
+
router.emit({
|
|
555
|
+
type: "onResolved",
|
|
556
|
+
...changeInfo
|
|
557
|
+
});
|
|
558
|
+
batch(() => {
|
|
559
|
+
router.stores.status.set("idle");
|
|
560
|
+
router.stores.resolvedLocation.set(router.stores.location.get());
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
}, [router, state]);
|
|
564
|
+
const runRouterTransition = useCallback((callback) => {
|
|
565
|
+
const startsPending = !router.stores.isTransitioning.get();
|
|
566
|
+
if (startsPending) router.stores.isTransitioning.set(true);
|
|
567
|
+
let result;
|
|
568
|
+
try {
|
|
569
|
+
const publishesPending = router.stores.pendingMatches.get().some((match) => match.status === "pending");
|
|
570
|
+
if (startsPending || !publishesPending) transition(() => {
|
|
571
|
+
result = callback();
|
|
572
|
+
});
|
|
573
|
+
else result = callback();
|
|
574
|
+
} catch (error) {
|
|
575
|
+
if (startsPending) router.stores.isTransitioning.set(false);
|
|
576
|
+
throw error;
|
|
577
|
+
}
|
|
578
|
+
const promise = result;
|
|
579
|
+
if (typeof promise?.then !== "function") {
|
|
580
|
+
if (startsPending) router.stores.isTransitioning.set(false);
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
const generation = state.generation += 1;
|
|
584
|
+
state.phase = "loading";
|
|
585
|
+
const finish = () => {
|
|
586
|
+
if (state.active && state.generation === generation) router.stores.isTransitioning.set(false);
|
|
587
|
+
};
|
|
588
|
+
promise.then(finish, (error) => {
|
|
589
|
+
finish();
|
|
590
|
+
queueMicrotask(() => {
|
|
591
|
+
throw error;
|
|
592
|
+
});
|
|
593
|
+
});
|
|
594
|
+
}, [router, state]);
|
|
595
|
+
const commitWithoutRouterViewTransition = useCallback((commit) => {
|
|
596
|
+
router.shouldViewTransition = void 0;
|
|
597
|
+
commit();
|
|
598
|
+
}, [router]);
|
|
599
|
+
useBeforePaint((signal) => {
|
|
600
|
+
const previousStartTransition = router.startTransition;
|
|
601
|
+
const previousStartViewTransition = router.startViewTransition;
|
|
602
|
+
const subscriptions = [
|
|
603
|
+
router.stores.isLoading.subscribe(settleLifecycle),
|
|
604
|
+
router.stores.hasPending.subscribe(settleLifecycle),
|
|
605
|
+
router.stores.isTransitioning.subscribe(settleLifecycle)
|
|
606
|
+
];
|
|
607
|
+
state.active = true;
|
|
608
|
+
router.startTransition = runRouterTransition;
|
|
609
|
+
router.startViewTransition = commitWithoutRouterViewTransition;
|
|
610
|
+
signal.addEventListener("abort", () => {
|
|
611
|
+
for (const subscription of subscriptions) subscription.unsubscribe();
|
|
612
|
+
state.active = false;
|
|
613
|
+
state.generation += 1;
|
|
614
|
+
if (router.startTransition === runRouterTransition) router.startTransition = previousStartTransition;
|
|
615
|
+
if (router.startViewTransition === commitWithoutRouterViewTransition) router.startViewTransition = previousStartViewTransition;
|
|
616
|
+
if (router.stores.isTransitioning.get()) router.stores.isTransitioning.set(false);
|
|
617
|
+
}, { once: true });
|
|
618
|
+
}, [
|
|
619
|
+
commitWithoutRouterViewTransition,
|
|
620
|
+
router,
|
|
621
|
+
runRouterTransition,
|
|
622
|
+
settleLifecycle,
|
|
623
|
+
state
|
|
624
|
+
]);
|
|
625
|
+
useBeforePaint((signal) => {
|
|
626
|
+
setupScrollRestoration(router);
|
|
627
|
+
const unsubscribe = router.history.subscribe((update) => {
|
|
628
|
+
router.load(update).catch(logRouterLoadError);
|
|
629
|
+
});
|
|
630
|
+
signal.addEventListener("abort", unsubscribe, { once: true });
|
|
631
|
+
if (state.initialLoadStarted) return void 0;
|
|
632
|
+
state.initialLoadStarted = true;
|
|
633
|
+
const nextLocation = router.buildLocation({
|
|
634
|
+
_includeValidateSearch: true,
|
|
635
|
+
hash: true,
|
|
636
|
+
params: true,
|
|
637
|
+
search: true,
|
|
638
|
+
state: true,
|
|
639
|
+
to: router.latestLocation.pathname
|
|
640
|
+
});
|
|
641
|
+
if (router.latestLocation.publicHref !== nextLocation.publicHref) router.commitLocation({
|
|
642
|
+
...nextLocation,
|
|
643
|
+
replace: true
|
|
644
|
+
}).catch(logRouterLoadError);
|
|
645
|
+
else if (!router.isServer && router.ssr === void 0 && router.stores.matchesId.get().length === 0) router.load().catch(logRouterLoadError);
|
|
646
|
+
}, [
|
|
647
|
+
router,
|
|
648
|
+
router.history,
|
|
649
|
+
router.options.scrollRestoration,
|
|
650
|
+
state
|
|
651
|
+
]);
|
|
652
|
+
return null;
|
|
653
|
+
}
|
|
654
|
+
function logRouterLoadError(error) {
|
|
655
|
+
console.error("Error loading route", error);
|
|
656
|
+
}
|
|
657
|
+
function OnRendered() {
|
|
658
|
+
const router = useRouter();
|
|
659
|
+
const state = useMemo(() => ({ previous: void 0 }), [router]);
|
|
660
|
+
useBeforePaint(() => {
|
|
661
|
+
if (router.isServer) return void 0;
|
|
662
|
+
const current = router.stores.resolvedLocation.get();
|
|
663
|
+
const previous = state.previous;
|
|
664
|
+
if (current !== void 0 && (previous === void 0 || previous.href !== current.href)) router.emit({
|
|
665
|
+
type: "onRendered",
|
|
666
|
+
...getLocationChangeInfo(router.stores.location.get(), previous ?? current)
|
|
667
|
+
});
|
|
668
|
+
state.previous = current;
|
|
669
|
+
}, [
|
|
670
|
+
useReadableStore(router.stores.resolvedLocation, (location) => location?.state.__TSR_key),
|
|
671
|
+
router,
|
|
672
|
+
state
|
|
673
|
+
]);
|
|
674
|
+
return null;
|
|
675
|
+
}
|
|
676
|
+
function Matches() {
|
|
677
|
+
const router = useRouter();
|
|
678
|
+
const firstMatchId = useReadableStore(router.stores.firstId);
|
|
679
|
+
const content = firstMatchId === void 0 ? null : createElement(Match, { matchId: firstMatchId });
|
|
680
|
+
if (router.isServer || router.ssr !== void 0) return content;
|
|
681
|
+
const PendingComponent = router.routesById[rootRouteId$1].options.pendingComponent ?? router.options.defaultPendingComponent;
|
|
682
|
+
return createElement(Suspense, { fallback: PendingComponent === void 0 ? null : createElement(PendingComponent) }, content);
|
|
683
|
+
}
|
|
684
|
+
function Match({ matchId }) {
|
|
685
|
+
const router = useRouter();
|
|
686
|
+
const [manualResetKey, setManualResetKey] = useState(0);
|
|
687
|
+
const store = router.stores.matchStores.get(matchId);
|
|
688
|
+
if (store === void 0) throw new Error(`Could not find route match ${JSON.stringify(matchId)}.`);
|
|
689
|
+
const match = useReadableStore(store);
|
|
690
|
+
const route = router.routesById[match.routeId];
|
|
691
|
+
if (route === void 0) throw new Error(`Could not find route ${JSON.stringify(match.routeId)}.`);
|
|
692
|
+
if (match.loaderData !== void 0 && dataStoreFromContext(match.context) !== void 0) throw new Error(`Route ${JSON.stringify(match.routeId)} loader returned a value while router.context.data is configured. Fig data resources are the single route-data cache: load with ensureRouteData or context.data.preloadData in the loader, read with readData in the component, and return void. For navigation-scoped values, derive them from loaderDeps, search params, or beforeLoad context instead.`);
|
|
693
|
+
const PendingComponent = route.options.pendingComponent ?? router.options.defaultPendingComponent;
|
|
694
|
+
const ErrorComponent = route.options.errorComponent ?? router.options.defaultErrorComponent;
|
|
695
|
+
const NotFoundComponent = route.options.notFoundComponent ?? (route.isRoot ? router.options.defaultNotFoundComponent : void 0);
|
|
696
|
+
const noSsr = match.ssr === false || match.ssr === "data-only";
|
|
697
|
+
const shouldWrapInSuspense = (!route.isRoot || route.options.wrapInSuspense || noSsr) && (route.options.wrapInSuspense ?? (PendingComponent !== void 0 || ErrorComponent?.preload || noSsr));
|
|
698
|
+
const pending = PendingComponent ? createElement(PendingComponent) : null;
|
|
699
|
+
let content = createElement(MatchContent, {
|
|
700
|
+
match,
|
|
701
|
+
route
|
|
702
|
+
});
|
|
703
|
+
if (noSsr || match._displayPending) content = createElement(ClientOnly, { fallback: pending }, content);
|
|
704
|
+
if (shouldWrapInSuspense) content = createElement(Suspense, { fallback: pending }, content);
|
|
705
|
+
const matchContent = createElement(MatchContext, { value: store }, ErrorComponent || NotFoundComponent ? createElement(ErrorBoundary, {
|
|
706
|
+
key: match.status === "error" ? `route-error:${match.fetchCount}` : `route:${manualResetKey}`,
|
|
707
|
+
fallback: (error) => {
|
|
708
|
+
if (isNotFound$1(error)) {
|
|
709
|
+
error.routeId ??= match.routeId;
|
|
710
|
+
if (NotFoundComponent === void 0 || error.routeId !== match.routeId) throw error;
|
|
711
|
+
return createElement(NotFoundComponent, {
|
|
712
|
+
...error,
|
|
713
|
+
isNotFound: true
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
if (!ErrorComponent) throw error;
|
|
717
|
+
return createElement(ErrorComponent, {
|
|
718
|
+
error,
|
|
719
|
+
reset: () => {
|
|
720
|
+
dataStoreFromContext(match.context)?.invalidateDataError(error);
|
|
721
|
+
router.invalidate().then(() => {
|
|
722
|
+
if ((router.stores.matchStores.get(match.id)?.get())?.status !== "error") setManualResetKey((key) => key + 1);
|
|
723
|
+
});
|
|
724
|
+
}
|
|
725
|
+
});
|
|
726
|
+
},
|
|
727
|
+
onError: (error, info) => {
|
|
728
|
+
if (!isNotFound$1(error)) if (route.options.onCatch) route.options.onCatch(error);
|
|
729
|
+
else router.options.defaultOnCatch?.(error, info);
|
|
730
|
+
}
|
|
731
|
+
}, content) : content);
|
|
732
|
+
const matchAssets = collectRouteAssets(router, match, router.ssr?.manifest).resources;
|
|
733
|
+
const ownedMatchContent = matchAssets.length === 0 ? matchContent : assets(matchAssets, matchContent);
|
|
734
|
+
if (route.parentRoute?.id !== rootRouteId$1) return ownedMatchContent;
|
|
735
|
+
return [
|
|
736
|
+
ownedMatchContent,
|
|
737
|
+
createElement(OnRendered),
|
|
738
|
+
router.options.scrollRestoration && router.isServer ? renderScrollRestorationScript(router) : null
|
|
739
|
+
];
|
|
740
|
+
}
|
|
741
|
+
function MatchContent({ match, route }) {
|
|
742
|
+
const router = useRouter();
|
|
743
|
+
if (match._displayPending) return readMatchPromise(router, match, "displayPendingPromise");
|
|
744
|
+
if (match._forcePending) return readMatchPromise(router, match, "minPendingPromise");
|
|
745
|
+
if (match.status === "pending") {
|
|
746
|
+
const pendingMinMs = route.options.pendingMinMs ?? router.options.defaultPendingMinMs;
|
|
747
|
+
const PendingComponent = route.options.pendingComponent ?? router.options.defaultPendingComponent;
|
|
748
|
+
const currentMatch = router.getMatch(match.id);
|
|
749
|
+
if (pendingMinMs && PendingComponent && !router.isServer && currentMatch !== void 0 && currentMatch._nonReactive.minPendingPromise === void 0) {
|
|
750
|
+
const minPendingPromise = createControlledPromise();
|
|
751
|
+
currentMatch._nonReactive.minPendingPromise = minPendingPromise;
|
|
752
|
+
setTimeout(() => {
|
|
753
|
+
minPendingPromise.resolve();
|
|
754
|
+
currentMatch._nonReactive.minPendingPromise = void 0;
|
|
755
|
+
}, pendingMinMs);
|
|
756
|
+
}
|
|
757
|
+
return readMatchPromise(router, match, "loadPromise");
|
|
758
|
+
}
|
|
759
|
+
if (match.status === "error") {
|
|
760
|
+
const ErrorComponent = route.options.errorComponent ?? router.options.defaultErrorComponent;
|
|
761
|
+
if (router.isServer && ErrorComponent) return createElement(ErrorComponent, {
|
|
762
|
+
error: match.error,
|
|
763
|
+
reset: () => void 0
|
|
764
|
+
});
|
|
765
|
+
throw match.error;
|
|
766
|
+
}
|
|
767
|
+
if (match.status === "redirected") return readMatchPromise(router, match, "loadPromise");
|
|
768
|
+
if (match.status === "notFound") return renderNotFound(router, route, match);
|
|
769
|
+
const Component = route.options.component ?? router.options.defaultComponent;
|
|
770
|
+
const remountDeps = (route.options.remountDeps ?? router.options.defaultRemountDeps)?.({
|
|
771
|
+
loaderDeps: match.loaderDeps,
|
|
772
|
+
params: match._strictParams,
|
|
773
|
+
routeId: match.routeId,
|
|
774
|
+
search: match._strictSearch
|
|
775
|
+
});
|
|
776
|
+
return Component === void 0 ? createElement(Outlet) : createElement(Component, { key: remountDeps ? JSON.stringify(remountDeps) : void 0 });
|
|
777
|
+
}
|
|
778
|
+
function readMatchPromise(router, match, key) {
|
|
779
|
+
const promise = router.getMatch(match.id)?._nonReactive[key] ?? match._nonReactive[key];
|
|
780
|
+
if (promise !== void 0) readPromise(promise);
|
|
781
|
+
return null;
|
|
782
|
+
}
|
|
783
|
+
function ClientOnly({ children, fallback }) {
|
|
784
|
+
return useSyncExternalStore(subscribeHydration, () => true, () => false) ? children : fallback;
|
|
785
|
+
}
|
|
786
|
+
function subscribeHydration() {
|
|
787
|
+
return () => void 0;
|
|
788
|
+
}
|
|
789
|
+
function renderScrollRestorationScript(router) {
|
|
790
|
+
const script = getScrollRestorationScriptForRouter(router);
|
|
791
|
+
return script === null ? null : renderPositionedRouterTag({
|
|
792
|
+
attrs: { nonce: router.options.ssr?.nonce },
|
|
793
|
+
children: `${script};document.currentScript.remove()`,
|
|
794
|
+
tag: "script"
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
function Outlet() {
|
|
798
|
+
const router = useRouter();
|
|
799
|
+
const parentMatch = readContext(MatchContext)?.get();
|
|
800
|
+
const matchIds = useReadableStore(router.stores.matchesId);
|
|
801
|
+
const parentIndex = matchIds.findIndex((id) => id === parentMatch?.id);
|
|
802
|
+
if (parentMatch?.globalNotFound === true) {
|
|
803
|
+
const route = router.routesById[parentMatch.routeId];
|
|
804
|
+
if (route === void 0) throw new Error(`Could not find route ${JSON.stringify(parentMatch.routeId)}.`);
|
|
805
|
+
return renderNotFound(router, route, parentMatch);
|
|
806
|
+
}
|
|
807
|
+
if (parentMatch !== void 0 && parentIndex === -1) return null;
|
|
808
|
+
const childMatchId = matchIds[parentIndex + 1];
|
|
809
|
+
return childMatchId === void 0 ? null : createElement(Match, { matchId: childMatchId });
|
|
810
|
+
}
|
|
811
|
+
function HeadContent() {
|
|
812
|
+
const router = useRouter();
|
|
813
|
+
const selectTags = useCallback((matches) => buildHeadTags(router, matches), [router]);
|
|
814
|
+
return renderRouterHeadTags(useReadableStore(router.stores.matches, selectTags, deepEqual));
|
|
815
|
+
}
|
|
816
|
+
function Scripts() {
|
|
817
|
+
const router = useRouter();
|
|
818
|
+
const selectTags = useCallback((matches) => matches.flatMap((match) => collectRouteAssets(router, match, router.ssr?.manifest).scripts), [router]);
|
|
819
|
+
const tags = [...useReadableStore(router.stores.matches, selectTags, deepEqual)];
|
|
820
|
+
const buffered = router.serverSsr?.takeBufferedScripts();
|
|
821
|
+
if (buffered !== void 0) tags.unshift(buffered);
|
|
822
|
+
return tags.map(renderPositionedRouterTag);
|
|
823
|
+
}
|
|
824
|
+
function buildHeadTags(router, matches) {
|
|
825
|
+
const nonce = router.options.ssr?.nonce;
|
|
826
|
+
const manifest = router.ssr?.manifest;
|
|
827
|
+
const metaTags = [];
|
|
828
|
+
const seenMeta = /* @__PURE__ */ new Set();
|
|
829
|
+
let selectedTitle;
|
|
830
|
+
for (let matchIndex = matches.length - 1; matchIndex >= 0; matchIndex -= 1) {
|
|
831
|
+
const routeMeta = matches[matchIndex]?.meta ?? [];
|
|
832
|
+
for (let metaIndex = routeMeta.length - 1; metaIndex >= 0; metaIndex -= 1) {
|
|
833
|
+
const value = routeMeta[metaIndex];
|
|
834
|
+
if (value === void 0) continue;
|
|
835
|
+
const title = "title" in value && typeof value.title === "string" ? value.title : void 0;
|
|
836
|
+
if (title !== void 0) {
|
|
837
|
+
selectedTitle ??= {
|
|
838
|
+
tag: "title",
|
|
839
|
+
children: title
|
|
840
|
+
};
|
|
841
|
+
continue;
|
|
842
|
+
}
|
|
843
|
+
if ("script:ld+json" in value) {
|
|
844
|
+
try {
|
|
845
|
+
metaTags.push({
|
|
846
|
+
tag: "script",
|
|
847
|
+
attrs: { type: "application/ld+json" },
|
|
848
|
+
children: escapeHtml(JSON.stringify(value["script:ld+json"]))
|
|
849
|
+
});
|
|
850
|
+
} catch {}
|
|
851
|
+
continue;
|
|
852
|
+
}
|
|
853
|
+
const identity = ("name" in value && typeof value.name === "string" ? value.name : void 0) ?? ("property" in value && typeof value.property === "string" ? value.property : void 0);
|
|
854
|
+
if (identity !== void 0) {
|
|
855
|
+
if (seenMeta.has(identity)) continue;
|
|
856
|
+
seenMeta.add(identity);
|
|
857
|
+
}
|
|
858
|
+
metaTags.push({
|
|
859
|
+
tag: "meta",
|
|
860
|
+
attrs: {
|
|
861
|
+
...value,
|
|
862
|
+
nonce
|
|
863
|
+
}
|
|
864
|
+
});
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
if (selectedTitle !== void 0) metaTags.push(selectedTitle);
|
|
868
|
+
if (nonce !== void 0) metaTags.push({
|
|
869
|
+
tag: "meta",
|
|
870
|
+
attrs: {
|
|
871
|
+
content: nonce,
|
|
872
|
+
property: "csp-nonce"
|
|
873
|
+
}
|
|
874
|
+
});
|
|
875
|
+
metaTags.reverse();
|
|
876
|
+
const tags = [];
|
|
877
|
+
appendUniqueUserTags(tags, metaTags);
|
|
878
|
+
appendUniqueUserTags(tags, matches.flatMap((match) => collectRouteAssets(router, match, manifest).links));
|
|
879
|
+
if (manifest?.inlineStyle !== void 0) tags.push({
|
|
880
|
+
tag: "style",
|
|
881
|
+
attrs: {
|
|
882
|
+
...manifest.inlineStyle.attrs,
|
|
883
|
+
nonce
|
|
884
|
+
},
|
|
885
|
+
children: manifest.inlineStyle.children,
|
|
886
|
+
inlineCss: true
|
|
887
|
+
});
|
|
888
|
+
appendUniqueUserTags(tags, matches.flatMap((match) => (match.styles ?? []).filter((style) => style !== void 0).map(({ children, ...attrs }) => ({
|
|
889
|
+
tag: "style",
|
|
890
|
+
attrs: {
|
|
891
|
+
...attrs,
|
|
892
|
+
nonce
|
|
893
|
+
},
|
|
894
|
+
children
|
|
895
|
+
}))));
|
|
896
|
+
appendUniqueUserTags(tags, matches.flatMap((match) => collectRouteAssets(router, match, manifest).headScripts));
|
|
897
|
+
return tags;
|
|
898
|
+
}
|
|
899
|
+
function renderNotFound(router, route, match) {
|
|
900
|
+
const NotFoundComponent = route.options.notFoundComponent ?? router.options.defaultNotFoundComponent;
|
|
901
|
+
return NotFoundComponent === void 0 ? null : createElement(NotFoundComponent, {
|
|
902
|
+
data: match.error,
|
|
903
|
+
isNotFound: true,
|
|
904
|
+
routeId: match.routeId
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
//#endregion
|
|
908
|
+
//#region src/route.tsx
|
|
909
|
+
function linkOptions(options) {
|
|
910
|
+
return options;
|
|
911
|
+
}
|
|
912
|
+
function bindRouteApi(getId, useFullPath) {
|
|
913
|
+
return {
|
|
914
|
+
Link: (props) => createElement(Link, {
|
|
915
|
+
...props,
|
|
916
|
+
from: useFullPath()
|
|
917
|
+
}),
|
|
918
|
+
notFound: (options) => notFound$1({
|
|
919
|
+
routeId: getId(),
|
|
920
|
+
...options
|
|
921
|
+
}),
|
|
922
|
+
useLoaderDeps: (options) => useMatchValue(getId(), options, (match) => match.loaderDeps),
|
|
923
|
+
useMatch: (options) => useMatchValue(getId(), options, (match) => match),
|
|
924
|
+
useNavigate: () => useNavigateFrom(useFullPath()),
|
|
925
|
+
useParams: (options) => useMatchValue(getId(), options, (match) => match.params),
|
|
926
|
+
useRouteContext: (options) => useMatchValue(getId(), options, (match) => match.context),
|
|
927
|
+
useSearch: (options) => useMatchValue(getId(), options, (match) => match.search)
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
function attachRouteApi(route) {
|
|
931
|
+
return Object.assign(route, bindRouteApi(() => route.id, () => route.fullPath));
|
|
932
|
+
}
|
|
933
|
+
function createRouteMask(options) {
|
|
934
|
+
return options;
|
|
935
|
+
}
|
|
936
|
+
function createRouter(options) {
|
|
937
|
+
return new RouterCore(options.defaultPreloadStaleTime === void 0 && dataStoreFromContext(options.context) !== void 0 ? {
|
|
938
|
+
...options,
|
|
939
|
+
defaultPreloadStaleTime: 0
|
|
940
|
+
} : options, getStoreConfig);
|
|
941
|
+
}
|
|
942
|
+
function getRouteApi(id) {
|
|
943
|
+
return new RouteApi({ id });
|
|
944
|
+
}
|
|
945
|
+
var RouteApi = class extends BaseRouteApi {
|
|
946
|
+
constructor({ id }) {
|
|
947
|
+
super({ id });
|
|
948
|
+
Object.assign(this, bindRouteApi(() => String(this.id), () => {
|
|
949
|
+
return useRouter().routesById[String(this.id)].fullPath;
|
|
950
|
+
}));
|
|
951
|
+
}
|
|
952
|
+
};
|
|
953
|
+
function createRoute(options) {
|
|
954
|
+
return attachRouteApi(new BaseRoute(options));
|
|
955
|
+
}
|
|
956
|
+
function createFileRoute(_path) {
|
|
957
|
+
return ((options) => {
|
|
958
|
+
const route = attachRouteApi(new BaseRoute(options));
|
|
959
|
+
route.isRoot = false;
|
|
960
|
+
return route;
|
|
961
|
+
});
|
|
962
|
+
}
|
|
963
|
+
function createLazyFileRoute(id) {
|
|
964
|
+
return (options) => ({ options: {
|
|
965
|
+
id,
|
|
966
|
+
...options
|
|
967
|
+
} });
|
|
968
|
+
}
|
|
969
|
+
function lazyRouteComponent(importer, exportName = "default") {
|
|
970
|
+
let component;
|
|
971
|
+
let loadPromise;
|
|
972
|
+
const load = () => loadPromise ??= importer().then((module) => {
|
|
973
|
+
const imported = module[exportName];
|
|
974
|
+
if (!isRouteComponent(imported)) throw new TypeError(`Route module export ${JSON.stringify(exportName)} is not a component.`);
|
|
975
|
+
component = imported;
|
|
976
|
+
return imported;
|
|
977
|
+
});
|
|
978
|
+
const LazyComponent = (props) => createElement(component ?? readPromise(load()), props);
|
|
979
|
+
return Object.assign(LazyComponent, { preload: async () => {
|
|
980
|
+
await load();
|
|
981
|
+
} });
|
|
982
|
+
}
|
|
983
|
+
function isRouteComponent(value) {
|
|
984
|
+
return typeof value === "function";
|
|
985
|
+
}
|
|
986
|
+
function createRootRoute(options) {
|
|
987
|
+
return attachRouteApi(new BaseRootRoute(options));
|
|
988
|
+
}
|
|
989
|
+
function createRootRouteWithContext() {
|
|
990
|
+
return (options) => createRootRoute(options);
|
|
991
|
+
}
|
|
992
|
+
//#endregion
|
|
993
|
+
export { HeadContent, Link, MatchRoute, Matches, Navigate, Outlet, RouterProvider, Scripts, createBrowserHistory, createFileRoute, createHashHistory, createLazyFileRoute, createMemoryHistory, createRootRoute, createRootRouteWithContext, createRoute, createRouteMask, createRouter, defaultParseSearch, defaultStringifySearch, ensureRouteData, getRouteApi, isNotFound, isRedirect, lazyFn, lazyRouteComponent, linkOptions, notFound, parseSearchWith, redirect, retainSearchParams, rootRouteId, stringifySearchWith, stripSearchParams, useBlocker, useCanGoBack, useLoaderDeps, useLocation, useMatch, useMatchRoute, useMatches, useNavigate, useParams, useRouteContext, useRouter, useRouterState, useSearch };
|
|
994
|
+
|
|
995
|
+
//# sourceMappingURL=router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.js","names":["rootRouteId","isNotFound","createNotFound"],"sources":["../src/data-context.ts","../src/store.ts","../src/hooks.tsx","../src/link.tsx","../src/route-assets.ts","../src/matches.tsx","../src/route.tsx"],"sourcesContent":["import type { DataResource, FigDataStoreHandle } from \"@bgub/fig\";\n\nexport type RouteDataContext = {\n data: FigDataStoreHandle;\n};\n\nexport async function ensureRouteData<TArgs extends unknown[], TValue>(\n context: RouteDataContext,\n resource: DataResource<TArgs, TValue>,\n ...args: TArgs\n): Promise<void> {\n await context.data.ensureData(resource, ...args);\n}\n\nexport function dataStoreFromContext(\n context: Partial<RouteDataContext> | null | undefined,\n): FigDataStoreHandle | undefined {\n return context?.data;\n}\n","import { useCallback, useMemo, useSyncExternalStore } from \"@bgub/fig\";\nimport {\n createNonReactiveMutableStore,\n createNonReactiveReadonlyStore,\n type GetStoreConfig,\n} from \"@tanstack/router-core\";\nimport { batch, createAtom, type Readable } from \"@tanstack/store\";\n\ndeclare module \"@tanstack/router-core\" {\n interface RouterReadableStore<TValue> extends Readable<TValue> {}\n}\n\nexport const getStoreConfig: GetStoreConfig = (options) => {\n if (options.isServer ?? typeof document === \"undefined\") {\n return {\n batch: (callback) => callback(),\n createMutableStore: createNonReactiveMutableStore,\n createReadonlyStore: createNonReactiveReadonlyStore,\n };\n }\n\n return {\n batch,\n createMutableStore: createAtom,\n createReadonlyStore: createAtom,\n };\n};\n\nfunction selectStoreValue<TValue>(value: TValue): TValue {\n return value;\n}\n\ntype ReadableRouterStore<TValue> = {\n get: () => TValue;\n subscribe?: Readable<TValue>[\"subscribe\"];\n};\n\nfunction doNothing(): void {}\n\nexport function useReadableStore<TValue, TSelected = TValue>(\n store: ReadableRouterStore<TValue>,\n select: (value: TValue) => TSelected = selectStoreValue as (\n value: TValue,\n ) => TSelected,\n equal: (previous: TSelected, next: TSelected) => boolean = Object.is,\n): TSelected {\n const subscribe = useCallback(\n (onChange: () => void) =>\n store.subscribe?.(onChange).unsubscribe ?? doNothing,\n [store],\n );\n const getSnapshot = useMemo(() => {\n let source: TValue | undefined;\n let selected: TSelected;\n let initialized = false;\n return () => {\n const nextSource = store.get();\n if (initialized && Object.is(source, nextSource)) return selected;\n const nextSelected = select(nextSource);\n source = nextSource;\n if (initialized && equal(selected, nextSelected)) return selected;\n selected = nextSelected;\n initialized = true;\n return selected;\n };\n }, [equal, select, store]);\n return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);\n}\n","import {\n createContext,\n type FigNode,\n readContext,\n useBeforePaint,\n useCallback,\n useMemo,\n useState,\n} from \"@bgub/fig\";\nimport type {\n BlockerFnArgs,\n HistoryAction,\n HistoryLocation,\n} from \"@tanstack/history\";\nimport {\n type AnyRoute,\n type AnyRouteMatch,\n type AnyRouter,\n type DeepPartial,\n deepEqual,\n type Expand,\n type FromPathOption,\n type MakeOptionalPathParams,\n type MakeOptionalSearchParams,\n type MakeRouteMatch,\n type MakeRouteMatchUnion,\n type MaskOptions,\n type MatchRouteOptions,\n type NavigateOptions,\n type ParseRoute,\n replaceEqualDeep,\n type RegisteredRouter,\n type ResolveRoute,\n type ResolveUseLoaderDeps,\n type ResolveUseParams,\n type ResolveUseSearch,\n type RouteIds,\n type RouterReadableStore,\n type RouterState,\n type StrictOrFrom,\n type ThrowConstraint,\n type ThrowOrOptional,\n type ToSubOptionsProps,\n type UseLoaderDepsResult,\n type UseNavigateResult,\n type UseParamsResult,\n type UseRouteContextResult,\n type UseSearchResult,\n} from \"@tanstack/router-core\";\nimport { useReadableStore } from \"./store.ts\";\n\nexport type StructuralSharingOptions = {\n structuralSharing?: boolean;\n};\n\nexport type SelectRouteValue<TValue, TSelected> = StructuralSharingOptions & {\n select?: (value: TValue) => TSelected;\n};\n\nexport type RouteMatchResult<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TSelected,\n> = unknown extends TSelected\n ? TStrict extends true\n ? MakeRouteMatch<TRouter[\"routeTree\"], TFrom, true>\n : MakeRouteMatchUnion<TRouter>\n : TSelected;\n\nexport const RouterContext = createContext<AnyRouter | null>(null);\nexport const MatchContext =\n createContext<RouterReadableStore<AnyRouteMatch> | null>(null);\nconst missingMatch = Symbol(\"missing route match\");\nconst missingMatchStore = {\n get: () => undefined,\n};\nexport function useRouter<\n TRouter extends AnyRouter = RegisteredRouter,\n>(): TRouter {\n return requireRouter(readContext(RouterContext)) as TRouter;\n}\n\nfunction requireRouter(router: AnyRouter | null): AnyRouter {\n if (router === null) {\n throw new Error(\"Router hooks must be used inside <RouterProvider>.\");\n }\n return router;\n}\n\nfunction useStoreSelector<TValue, TSelected = TValue>(\n router: AnyRouter,\n options?: SelectRouteValue<TValue, TSelected>,\n): (value: TValue) => TSelected {\n const previous = useMemo<{ initialized: boolean; value: TSelected }>(\n () => ({ initialized: false, value: undefined as TSelected }),\n [],\n );\n const select = options?.select;\n const structuralSharing =\n options?.structuralSharing ??\n router.options.defaultStructuralSharing ??\n false;\n return useCallback(\n (value: TValue) => {\n let selected = (\n select === undefined ? value : select(value)\n ) as TSelected;\n if (structuralSharing && previous.initialized) {\n selected = replaceEqualDeep(previous.value, selected);\n }\n previous.initialized = true;\n previous.value = selected;\n return selected;\n },\n [previous, select, structuralSharing],\n );\n}\n\nexport function useRouterState<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = RouterState<TRouter[\"routeTree\"]>,\n>(\n options?: SelectRouteValue<RouterState<TRouter[\"routeTree\"]>, TSelected> & {\n router?: TRouter;\n },\n): TSelected {\n const router = requireRouter(options?.router ?? readContext(RouterContext));\n const select = useStoreSelector(router, options);\n return useReadableStore(router.stores.__store, select) as TSelected;\n}\n\nexport function useLocation<\n TRouter extends AnyRouter = RegisteredRouter,\n TLocation = RouterState<TRouter[\"routeTree\"]>[\"location\"],\n>(\n options?: SelectRouteValue<\n RouterState<TRouter[\"routeTree\"]>[\"location\"],\n TLocation\n >,\n): TLocation {\n const router = useRouter<TRouter>();\n const select = useStoreSelector(router, options);\n return useReadableStore(router.stores.location, select) as TLocation;\n}\n\ntype BlockerLocation<\n out TRouteId = string,\n out TFullPath = string,\n out TParams = unknown,\n out TSearch = unknown,\n> = {\n fullPath: TFullPath;\n params: TParams;\n pathname: string;\n routeId: TRouteId;\n search: TSearch;\n};\n\ntype BlockerLocationUnion<\n TRouter extends AnyRouter = RegisteredRouter,\n TRoute extends AnyRoute = ParseRoute<TRouter[\"routeTree\"]>,\n> = TRoute extends AnyRoute\n ? BlockerLocation<\n TRoute[\"id\"],\n TRoute[\"fullPath\"],\n TRoute[\"types\"][\"allParams\"],\n TRoute[\"types\"][\"fullSearchSchema\"]\n >\n : never;\n\ntype BlockerResolver<TRouter extends AnyRouter = RegisteredRouter> =\n | {\n action: HistoryAction;\n current: BlockerLocationUnion<TRouter>;\n next: BlockerLocationUnion<TRouter>;\n proceed: () => void;\n reset: () => void;\n status: \"blocked\";\n }\n | {\n action: undefined;\n current: undefined;\n next: undefined;\n proceed: undefined;\n reset: undefined;\n status: \"idle\";\n };\n\nexport type ShouldBlockFn<TRouter extends AnyRouter = RegisteredRouter> =\n (args: {\n action: HistoryAction;\n current: BlockerLocationUnion<TRouter>;\n next: BlockerLocationUnion<TRouter>;\n }) => boolean | Promise<boolean>;\n\nexport type UseBlockerOpts<\n TRouter extends AnyRouter = RegisteredRouter,\n TWithResolver extends boolean = boolean,\n> = {\n disabled?: boolean;\n enableBeforeUnload?: boolean | (() => boolean);\n shouldBlockFn: ShouldBlockFn<TRouter>;\n withResolver?: TWithResolver;\n};\n\nexport function useBlocker<\n TRouter extends AnyRouter = RegisteredRouter,\n TWithResolver extends boolean = false,\n>(\n options: UseBlockerOpts<TRouter, TWithResolver>,\n): TWithResolver extends true ? BlockerResolver<TRouter> : void {\n const {\n disabled = false,\n enableBeforeUnload = true,\n shouldBlockFn,\n withResolver = false,\n } = options;\n const router = useRouter<TRouter>();\n const [resolver, setResolver] =\n useState<BlockerResolver<TRouter>>(idleBlockerResolver);\n\n useBeforePaint(\n (signal) => {\n if (disabled) return undefined;\n let settlePending: ((shouldBlock: boolean) => void) | undefined;\n const unblock = router.history.block({\n enableBeforeUnload,\n blockerFn: async (args: BlockerFnArgs) => {\n const current = blockerLocation(router, args.currentLocation);\n const next = blockerLocation(router, args.nextLocation);\n const shouldBlock = await shouldBlockFn({\n action: args.action,\n current,\n next,\n });\n if (!withResolver || !shouldBlock) return shouldBlock;\n\n const resolved = await new Promise<boolean>((resolve) => {\n settlePending = resolve;\n setResolver({\n action: args.action,\n current,\n next,\n proceed: () => resolve(false),\n reset: () => resolve(true),\n status: \"blocked\",\n });\n });\n settlePending = undefined;\n setResolver(idleBlockerResolver);\n return resolved;\n },\n });\n signal.addEventListener(\n \"abort\",\n () => {\n unblock();\n settlePending?.(false);\n },\n { once: true },\n );\n return undefined;\n },\n [disabled, enableBeforeUnload, router, shouldBlockFn, withResolver],\n );\n\n return (withResolver ? resolver : undefined) as TWithResolver extends true\n ? BlockerResolver<TRouter>\n : void;\n}\n\nexport function useCanGoBack(): boolean {\n const router = useRouter<AnyRouter>();\n return useReadableStore(router.stores.location, router.history.canGoBack);\n}\n\nfunction blockerLocation<TRouter extends AnyRouter>(\n router: TRouter,\n location: HistoryLocation,\n): BlockerLocationUnion<TRouter> {\n const parsed = router.parseLocation(location);\n const matched = router.getMatchedRoutes(parsed.pathname);\n return {\n fullPath: matched.foundRoute?.fullPath ?? parsed.pathname,\n params: matched.routeParams,\n pathname: parsed.pathname,\n routeId: matched.foundRoute?.id ?? \"__notFound__\",\n search: parsed.search,\n } as BlockerLocationUnion<TRouter>;\n}\n\nconst idleBlockerResolver = {\n action: undefined,\n current: undefined,\n next: undefined,\n proceed: undefined,\n reset: undefined,\n status: \"idle\",\n} as const;\n\ntype TypedMatchOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TThrow extends boolean,\n TSelected,\n> = StrictOrFrom<TRouter, TFrom, TStrict> &\n SelectRouteValue<\n MakeRouteMatch<TRouter[\"routeTree\"], TFrom, TStrict>,\n TSelected\n > & {\n shouldThrow?: TThrow;\n };\n\nexport function useMatch<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TStrict extends boolean = true,\n TThrow extends boolean = true,\n TSelected = unknown,\n>(\n options?: TypedMatchOptions<\n TRouter,\n TFrom,\n TStrict,\n ThrowConstraint<TStrict, TThrow>,\n TSelected\n >,\n): ThrowOrOptional<\n RouteMatchResult<TRouter, TFrom, TStrict, TSelected>,\n TThrow\n> {\n return useMatchValue(\n options?.from,\n options,\n (match) => match as MakeRouteMatch<TRouter[\"routeTree\"], TFrom, TStrict>,\n options?.shouldThrow,\n ) as ThrowOrOptional<\n RouteMatchResult<TRouter, TFrom, TStrict, TSelected>,\n TThrow\n >;\n}\n\nfunction useMatchSelection(\n from: string | undefined,\n select: ((match: AnyRouteMatch) => unknown) | undefined,\n shouldThrow = true,\n structuralSharing?: boolean,\n): unknown {\n const router = useRouter<AnyRouter>();\n const nearestMatchStore = readContext(MatchContext);\n const store =\n from === undefined || nearestMatchStore?.get().routeId === from\n ? nearestMatchStore\n : router.stores.getRouteMatchStore(from);\n const selectMatch = useStoreSelector(router, { select, structuralSharing });\n\n const selectPresentMatch = useCallback(\n (match: AnyRouteMatch | undefined) =>\n match === undefined ? missingMatch : selectMatch(match),\n [selectMatch],\n );\n const selected = useReadableStore(\n store ?? missingMatchStore,\n selectPresentMatch,\n );\n if (selected === missingMatch) {\n if (shouldThrow) {\n const target = from\n ? `route ${JSON.stringify(from)}`\n : \"the nearest route\";\n throw new Error(`Could not find an active match for ${target}.`);\n }\n return undefined;\n }\n return selected;\n}\n\nexport function useMatchValue<TValue>(\n from: string | undefined,\n options: SelectRouteValue<TValue, unknown> | undefined,\n getValue: (match: AnyRouteMatch) => TValue,\n shouldThrow = true,\n): unknown {\n return useMatchSelection(\n from,\n (match) => {\n const value = getValue(match);\n return options?.select === undefined ? value : options.select(value);\n },\n shouldThrow,\n options?.structuralSharing,\n );\n}\n\ntype TypedRouteValueOptions<\n TRouter extends AnyRouter,\n TFrom,\n TStrict extends boolean,\n TValue,\n TSelected,\n> = StrictOrFrom<TRouter, TFrom, TStrict> & SelectRouteValue<TValue, TSelected>;\n\nexport function useParams<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TStrict extends boolean = true,\n TThrow extends boolean = true,\n TSelected = unknown,\n>(\n options?: TypedRouteValueOptions<\n TRouter,\n TFrom,\n TStrict,\n ResolveUseParams<TRouter, TFrom, TStrict>,\n TSelected\n > & { shouldThrow?: ThrowConstraint<TStrict, TThrow> },\n): ThrowOrOptional<\n UseParamsResult<TRouter, TFrom, TStrict, TSelected>,\n TThrow\n> {\n return useMatchValue(\n options?.from,\n options,\n (match) => match.params as ResolveUseParams<TRouter, TFrom, TStrict>,\n options?.shouldThrow,\n ) as ThrowOrOptional<\n UseParamsResult<TRouter, TFrom, TStrict, TSelected>,\n TThrow\n >;\n}\n\nexport function useSearch<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TStrict extends boolean = true,\n TThrow extends boolean = true,\n TSelected = unknown,\n>(\n options?: TypedRouteValueOptions<\n TRouter,\n TFrom,\n TStrict,\n ResolveUseSearch<TRouter, TFrom, TStrict>,\n TSelected\n > & { shouldThrow?: ThrowConstraint<TStrict, TThrow> },\n): ThrowOrOptional<\n UseSearchResult<TRouter, TFrom, TStrict, TSelected>,\n TThrow\n> {\n return useMatchValue(\n options?.from,\n options,\n (match) => match.search as ResolveUseSearch<TRouter, TFrom, TStrict>,\n options?.shouldThrow,\n ) as ThrowOrOptional<\n UseSearchResult<TRouter, TFrom, TStrict, TSelected>,\n TThrow\n >;\n}\n\nexport function useLoaderDeps<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends RouteIds<TRouter[\"routeTree\"]> = RouteIds<\n TRouter[\"routeTree\"]\n >,\n TSelected = unknown,\n>(\n options?: SelectRouteValue<\n ResolveUseLoaderDeps<TRouter, TFrom>,\n TSelected\n > & { from: TFrom },\n): UseLoaderDepsResult<TRouter, TFrom, TSelected> {\n return useMatchValue(\n options?.from,\n options,\n (match) => match.loaderDeps as ResolveUseLoaderDeps<TRouter, TFrom>,\n ) as UseLoaderDepsResult<TRouter, TFrom, TSelected>;\n}\n\nexport function useRouteContext<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string | undefined = undefined,\n TStrict extends boolean = true,\n TSelected = unknown,\n>(\n options?: TypedRouteValueOptions<\n TRouter,\n TFrom,\n TStrict,\n UseRouteContextResult<TRouter, TFrom, TStrict, unknown>,\n TSelected\n >,\n): UseRouteContextResult<TRouter, TFrom, TStrict, TSelected> {\n return useMatchValue(\n options?.from,\n options,\n (match) =>\n match.context as UseRouteContextResult<TRouter, TFrom, TStrict, unknown>,\n ) as UseRouteContextResult<TRouter, TFrom, TStrict, TSelected>;\n}\n\nexport function useNavigate<\n TRouter extends AnyRouter = RegisteredRouter,\n TDefaultFrom extends string = string,\n>(options?: {\n from?: FromPathOption<TRouter, TDefaultFrom>;\n}): UseNavigateResult<TDefaultFrom> {\n return useNavigateFrom(options?.from) as UseNavigateResult<TDefaultFrom>;\n}\n\nexport function useNavigateFrom(\n from: string | undefined,\n): UseNavigateResult<string> {\n const router = useRouter<AnyRouter>();\n return useCallback(\n ((navigateOptions: NavigateOptions) =>\n router.navigate({\n ...navigateOptions,\n from: navigateOptions.from ?? from,\n } as never)) as UseNavigateResult<string>,\n [from, router],\n );\n}\n\nexport function Navigate<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = \"\",\n>(props: NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): null {\n const navigate = useNavigateFrom(undefined);\n const previous = useMemo<{ props: typeof props | undefined }>(\n () => ({ props: undefined }),\n [],\n );\n useBeforePaint(() => {\n if (previous.props === undefined || !deepEqual(previous.props, props)) {\n previous.props = props;\n void navigate(props as never);\n }\n return undefined;\n }, [navigate, previous, props]);\n return null;\n}\n\nexport type UseMatchesOptions<\n TRouter extends AnyRouter,\n TSelected,\n> = StructuralSharingOptions & {\n select?: (matches: Array<MakeRouteMatchUnion<TRouter>>) => TSelected;\n};\n\nexport type UseMatchesResult<\n TRouter extends AnyRouter,\n TSelected,\n> = unknown extends TSelected ? Array<MakeRouteMatchUnion<TRouter>> : TSelected;\n\nexport function useMatches<\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n options?: UseMatchesOptions<TRouter, TSelected>,\n): UseMatchesResult<TRouter, TSelected> {\n const router = useRouter<TRouter>();\n const select = useStoreSelector(router, options);\n return useReadableStore(\n router.stores.matches,\n select as (matches: AnyRouteMatch[]) => TSelected,\n ) as UseMatchesResult<TRouter, TSelected>;\n}\n\nexport type UseMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = \"\",\n> = ToSubOptionsProps<TRouter, TFrom, TTo> &\n DeepPartial<MakeOptionalSearchParams<TRouter, TFrom, TTo>> &\n DeepPartial<MakeOptionalPathParams<TRouter, TFrom, TTo>> &\n MaskOptions<TRouter, TMaskFrom, TMaskTo> &\n MatchRouteOptions;\n\nexport type MatchRouteFn<TRouter extends AnyRouter = RegisteredRouter> = <\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = \"\",\n>(\n options: UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n) => false | Expand<ResolveRoute<TRouter, TFrom, TTo>[\"types\"][\"allParams\"]>;\n\nexport function useMatchRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n>(): MatchRouteFn<TRouter> {\n const router = useRouter<TRouter>();\n useReadableStore(router.stores.matchRouteDeps);\n return useCallback(\n (options: UseMatchRouteOptions<TRouter>) => {\n const { pending, caseSensitive, fuzzy, includeSearch, ...location } =\n options;\n return router.matchRoute(location as never, {\n pending,\n caseSensitive,\n fuzzy,\n includeSearch,\n });\n },\n [router],\n ) as MatchRouteFn<TRouter>;\n}\n\nexport type MakeMatchRouteOptions<\n TRouter extends AnyRouter = RegisteredRouter,\n TFrom extends string = string,\n TTo extends string | undefined = undefined,\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = \"\",\n> = UseMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {\n children?:\n | FigNode\n | ((\n params?: Expand<\n ResolveRoute<TRouter, TFrom, TTo>[\"types\"][\"allParams\"]\n >,\n ) => FigNode);\n};\n\nexport function MatchRoute<\n TRouter extends AnyRouter = RegisteredRouter,\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = \"\",\n>(\n props: MakeMatchRouteOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>,\n): FigNode {\n const { children, ...options } = props;\n const params = useMatchRoute<TRouter>()(options as never);\n if (typeof children === \"function\") {\n return children(params === false ? undefined : params);\n }\n return params === false ? null : children;\n}\n","import {\n createElement,\n type FigNode,\n useBeforePaint,\n useCallback,\n useMemo,\n useReactive,\n useState,\n} from \"@bgub/fig\";\nimport { composeBind, type HostIntrinsicElements, on } from \"@bgub/fig-dom\";\nimport {\n deepEqual,\n exactPathTest,\n isDangerousProtocol,\n type LinkOptions,\n type RegisteredRouter,\n removeTrailingSlash,\n} from \"@tanstack/router-core\";\nimport { useRouter } from \"./hooks.tsx\";\nimport { useReadableStore } from \"./store.ts\";\n\ntype AnchorProps = HostIntrinsicElements[\"a\"];\ntype LinkStateProps = Partial<\n Omit<AnchorProps, \"children\" | \"href\" | \"target\">\n>;\n\nexport type LinkRenderState = {\n isActive: boolean;\n isTransitioning: boolean;\n};\n\nexport type LinkProps<\n TFrom extends string = string,\n TTo extends string | undefined = \".\",\n TMaskFrom extends string = TFrom,\n TMaskTo extends string = \".\",\n> = Omit<AnchorProps, \"children\"> &\n LinkOptions<RegisteredRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {\n activeProps?: LinkStateProps | (() => LinkStateProps);\n children?: FigNode | ((state: LinkRenderState) => FigNode);\n inactiveProps?: LinkStateProps | (() => LinkStateProps);\n preloadIntentProximity?: never;\n };\n\nexport function Link<\n const TFrom extends string = string,\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = \"\",\n>(props: LinkProps<TFrom, TTo, TMaskFrom, TMaskTo>): FigNode {\n const router = useRouter<RegisteredRouter>();\n const resolvedLocation = useReadableStore(router.stores.resolvedLocation);\n const currentLocation = resolvedLocation ?? router.stores.location.get();\n const [isTransitioning, setIsTransitioning] = useState(false);\n const state = useMemo<{\n preloadTimeout?: ReturnType<typeof setTimeout>;\n unsubscribe?: () => void;\n }>(() => ({}), []);\n useBeforePaint(\n (signal) => {\n signal.addEventListener(\n \"abort\",\n () => {\n state.unsubscribe?.();\n if (state.preloadTimeout !== undefined) {\n clearTimeout(state.preloadTimeout);\n }\n },\n { once: true },\n );\n return undefined;\n },\n [state],\n );\n const {\n _fromLocation,\n activeOptions,\n activeProps,\n children,\n disabled,\n from: _from,\n hash: _hash,\n hashScrollIntoView: _hashScrollIntoView,\n href: explicitHref,\n ignoreBlocker: _ignoreBlocker,\n inactiveProps,\n mask: _mask,\n mix,\n params: _params,\n preload: requestedPreload,\n preloadDelay: requestedPreloadDelay,\n reloadDocument,\n replace: _replace,\n resetScroll: _resetScroll,\n search: _search,\n startTransition: _startTransition,\n state: _state,\n target,\n to,\n unsafeRelative: _unsafeRelative,\n viewTransition: _viewTransition,\n ...anchorProps\n } = props;\n const absolute = isAbsoluteLinkTarget(to, router.origin);\n const next = !absolute\n ? router.buildLocation<RegisteredRouter, TTo, TFrom, TMaskFrom, TMaskTo>({\n ...props,\n _isNavigate: false,\n })\n : undefined;\n const displayedLocation = next?.maskedLocation ?? next;\n const href = disabled\n ? undefined\n : (explicitHref ??\n (absolute ? to : undefined) ??\n (displayedLocation === undefined\n ? undefined\n : router.history.createHref(displayedLocation.publicHref) || \"/\"));\n const external =\n absolute ||\n displayedLocation?.external === true ||\n (explicitHref !== undefined &&\n isAbsoluteLinkTarget(explicitHref, router.origin));\n const dangerous =\n href !== undefined\n ? isDangerousProtocol(href, router.protocolAllowlist)\n : false;\n const preload =\n reloadDocument || external || dangerous || explicitHref !== undefined\n ? false\n : (requestedPreload ?? router.options.defaultPreload);\n const preloadDelay =\n requestedPreloadDelay ?? router.options.defaultPreloadDelay ?? 0;\n const isActive =\n next !== undefined &&\n !external &&\n linkPathIsActive(\n currentLocation.pathname,\n next.pathname,\n router.basepath,\n activeOptions?.exact ?? false,\n ) &&\n (!(activeOptions?.includeSearch ?? true) ||\n deepEqual(currentLocation.search, next.search, {\n ignoreUndefined: !activeOptions?.explicitUndefined,\n partial: !(activeOptions?.exact ?? false),\n })) &&\n (!activeOptions?.includeHash || currentLocation.hash === next.hash);\n const selectedStateProps = isActive ? activeProps : inactiveProps;\n const stateProps =\n (typeof selectedStateProps === \"function\"\n ? selectedStateProps()\n : selectedStateProps) ?? {};\n const {\n bind: stateBind,\n class: stateClass,\n mix: stateMix,\n style: stateStyle,\n ...stateAnchorProps\n } = stateProps;\n const linkBind = composeBind(anchorProps.bind, stateBind);\n const linkClass =\n typeof anchorProps.class === \"string\" && typeof stateClass === \"string\"\n ? `${anchorProps.class} ${stateClass}`\n : (stateClass ?? anchorProps.class);\n const linkStyle =\n typeof anchorProps.style === \"object\" &&\n anchorProps.style !== null &&\n typeof stateStyle === \"object\" &&\n stateStyle !== null\n ? { ...anchorProps.style, ...stateStyle }\n : (stateStyle ?? anchorProps.style);\n const renderedChildren =\n typeof children === \"function\"\n ? children({ isActive, isTransitioning })\n : children;\n\n const preloadRoute = useCallback(() => {\n void router\n .preloadRoute<TFrom, TTo, TMaskFrom, TMaskTo>(props)\n .catch((error: unknown) => {\n console.warn(\"Error preloading route\", error);\n });\n }, [href, router]);\n\n useReactive(() => {\n if (!disabled && preload === \"render\") preloadRoute();\n }, [disabled, preload, preloadRoute]);\n\n const viewportBind = useCallback(\n (element: HTMLAnchorElement, signal: AbortSignal): undefined => {\n if (disabled || preload !== \"viewport\") return undefined;\n const observer = new IntersectionObserver((entries) => {\n if (entries.some((entry) => entry.isIntersecting)) {\n observer.disconnect();\n preloadRoute();\n }\n });\n observer.observe(element);\n signal.addEventListener(\"abort\", () => observer.disconnect(), {\n once: true,\n });\n return undefined;\n },\n [disabled, preload, preloadRoute],\n );\n\n const beginIntentPreload = () => {\n if (disabled || preload !== \"intent\") return;\n if (preloadDelay === 0) {\n preloadRoute();\n return;\n }\n if (state.preloadTimeout !== undefined) return;\n state.preloadTimeout = setTimeout(() => {\n state.preloadTimeout = undefined;\n preloadRoute();\n }, preloadDelay);\n };\n const cancelIntentPreload = () => {\n if (state.preloadTimeout === undefined) return;\n clearTimeout(state.preloadTimeout);\n state.preloadTimeout = undefined;\n };\n\n return createElement(\n \"a\",\n {\n ...anchorProps,\n ...stateAnchorProps,\n \"aria-current\": isActive ? \"page\" : undefined,\n \"aria-disabled\": disabled ? true : undefined,\n \"data-status\": isActive ? \"active\" : undefined,\n \"data-transitioning\": isTransitioning ? \"transitioning\" : undefined,\n bind:\n preload === \"viewport\" ? composeBind(linkBind, viewportBind) : linkBind,\n class: linkClass,\n href: dangerous ? undefined : href,\n mix: [\n mix,\n stateMix,\n on(\"click\", (event) => {\n const elementTarget =\n event.currentTarget instanceof Element\n ? event.currentTarget.getAttribute(\"target\")\n : null;\n const effectiveTarget = target ?? elementTarget;\n if (\n disabled ||\n dangerous ||\n external ||\n reloadDocument ||\n event.defaultPrevented ||\n event.button !== 0 ||\n event.metaKey ||\n event.altKey ||\n event.ctrlKey ||\n event.shiftKey ||\n (effectiveTarget !== null &&\n effectiveTarget !== \"\" &&\n effectiveTarget !== \"_self\") ||\n anchorProps.download !== undefined\n ) {\n return;\n }\n event.preventDefault();\n state.unsubscribe?.();\n setIsTransitioning(true);\n const unsubscribe = router.subscribe(\"onResolved\", () => {\n unsubscribe();\n state.unsubscribe = undefined;\n setIsTransitioning(false);\n });\n state.unsubscribe = unsubscribe;\n void router.navigate<\n RegisteredRouter,\n TTo,\n TFrom,\n TMaskFrom,\n TMaskTo\n >(props);\n }),\n preload === \"intent\" && on(\"mouseenter\", beginIntentPreload),\n preload === \"intent\" && on(\"mouseleave\", cancelIntentPreload),\n preload === \"intent\" && on(\"focus\", beginIntentPreload),\n preload === \"intent\" && on(\"blur\", cancelIntentPreload),\n preload === \"intent\" &&\n on(\"touchstart\", () => {\n if (!disabled) preloadRoute();\n }),\n ],\n role: disabled ? \"link\" : (stateAnchorProps.role ?? anchorProps.role),\n style: linkStyle,\n target,\n },\n renderedChildren,\n );\n}\n\nfunction linkPathIsActive(\n currentPathname: string,\n nextPathname: string,\n basepath: string,\n exact: boolean,\n): boolean {\n if (exact) return exactPathTest(currentPathname, nextPathname, basepath);\n const current = removeTrailingSlash(currentPathname, basepath);\n const next = removeTrailingSlash(nextPathname, basepath);\n return (\n current.startsWith(next) &&\n (current.length === next.length || current[next.length] === \"/\")\n );\n}\n\nfunction isAbsoluteLinkTarget(\n value: unknown,\n origin: string | undefined,\n): value is string {\n if (typeof value !== \"string\") return false;\n if (!value.startsWith(\"//\") && !value.includes(\":\")) return false;\n try {\n new URL(value, origin);\n return true;\n } catch {\n return false;\n }\n}\n","import {\n assets,\n createElement,\n type FigAssetResource,\n type FigNode,\n} from \"@bgub/fig\";\nimport {\n assetResourceDestination,\n assetResourceFromHostProps,\n preventAssetResourceHoist,\n} from \"@bgub/fig/internal\";\nimport {\n getAssetCrossOrigin,\n getScriptPreloadAttrs,\n resolveManifestCssLink,\n type AnyRouteMatch,\n type AnyRouter,\n type Manifest,\n type RouterManagedTag,\n} from \"@tanstack/router-core\";\n\ninterface RouteAssets {\n resources: FigAssetResource[];\n links: RouterManagedTag[];\n headScripts: RouterManagedTag[];\n scripts: RouterManagedTag[];\n}\n\nexport function collectRouteAssets(\n router: AnyRouter,\n match: AnyRouteMatch,\n manifest: Manifest | undefined,\n): RouteAssets {\n const nonce = router.options.ssr?.nonce;\n const resources: FigAssetResource[] = [];\n const links: RouterManagedTag[] = [];\n const headScripts: RouterManagedTag[] = [];\n const scripts: RouterManagedTag[] = [];\n const manifestRoute = manifest?.routes[match.routeId];\n\n for (const link of match.links ?? []) {\n if (link === undefined) continue;\n collectTag({ tag: \"link\", attrs: { ...link, nonce } }, resources, links);\n }\n\n for (const link of manifestRoute?.css ?? []) {\n const resolved = resolveManifestCssLink(link);\n collectTag(\n {\n tag: \"link\",\n attrs: {\n rel: \"stylesheet\",\n ...resolved,\n crossOrigin:\n getAssetCrossOrigin(\n router.options.assetCrossOrigin,\n \"stylesheet\",\n ) ?? resolved.crossOrigin,\n nonce,\n suppressHydrationWarning: true,\n },\n },\n resources,\n links,\n );\n }\n\n for (const link of manifestRoute?.preloads ?? []) {\n collectTag(\n {\n tag: \"link\",\n attrs: {\n ...getScriptPreloadAttrs(\n manifest,\n link,\n router.options.assetCrossOrigin,\n ),\n nonce,\n },\n },\n resources,\n links,\n );\n }\n\n collectScripts(match.headScripts, nonce, resources, headScripts);\n collectScripts(match.scripts, nonce, resources, scripts);\n\n for (const script of manifestRoute?.scripts ?? []) {\n collectTag(\n {\n tag: \"script\",\n attrs: { ...script.attrs, nonce },\n children: script.children,\n },\n resources,\n scripts,\n );\n }\n\n return { resources, links, headScripts, scripts };\n}\n\nexport function renderRouterHeadTags(tags: RouterManagedTag[]): FigNode {\n const resources: FigAssetResource[] = [];\n const nodes: FigNode[] = [];\n for (const tag of tags) {\n const resource = resourceFromTag(tag);\n if (resource === null || assetResourceDestination(resource) !== \"head\") {\n nodes.push(renderPositionedRouterTag(tag));\n } else {\n resources.push(resource);\n }\n }\n return resources.length === 0 ? nodes : assets(resources, nodes);\n}\n\nexport function renderPositionedRouterTag(tag: RouterManagedTag): FigNode {\n return createElement(\n tag.tag,\n preventAssetResourceHoist({\n ...nativeAttributes(tag.attrs),\n ...(tag.children === undefined ? {} : { unsafeHTML: tag.children }),\n }),\n );\n}\n\nfunction nativeAttributes(\n attrs: Record<string, unknown> | undefined,\n): Record<string, unknown> {\n if (attrs === undefined) return {};\n const result = { ...attrs };\n renameAttribute(result, \"charSet\", \"charset\");\n renameAttribute(result, \"className\", \"class\");\n renameAttribute(result, \"crossOrigin\", \"crossorigin\");\n renameAttribute(result, \"fetchPriority\", \"fetchpriority\");\n renameAttribute(result, \"httpEquiv\", \"http-equiv\");\n renameAttribute(result, \"referrerPolicy\", \"referrerpolicy\");\n return result;\n}\n\nfunction collectScripts(\n values: AnyRouteMatch[\"scripts\"],\n nonce: string | undefined,\n resources: FigAssetResource[],\n positioned: RouterManagedTag[],\n): void {\n for (const script of values ?? []) {\n if (script === undefined) continue;\n const { children, ...attrs } = script;\n collectTag(\n {\n tag: \"script\",\n attrs: { ...attrs, nonce, suppressHydrationWarning: true },\n children: children as string | undefined,\n },\n resources,\n positioned,\n );\n }\n}\n\nfunction collectTag(\n tag: RouterManagedTag,\n resources: FigAssetResource[],\n positioned: RouterManagedTag[],\n): void {\n const resource = resourceFromTag(tag);\n if (resource === null) positioned.push(tag);\n else resources.push(resource);\n}\n\nfunction resourceFromTag(tag: RouterManagedTag): FigAssetResource | null {\n return assetResourceFromHostProps(tag.tag, {\n ...nativeAttributes(tag.attrs),\n children: tag.children,\n });\n}\n\nfunction renameAttribute(\n attrs: Record<string, unknown>,\n from: string,\n to: string,\n): void {\n if (attrs[from] !== undefined && attrs[to] === undefined) {\n attrs[to] = attrs[from];\n }\n delete attrs[from];\n}\n","import {\n assets,\n createElement,\n ErrorBoundary,\n type FigNode,\n readContext,\n readPromise,\n Suspense,\n transition,\n useBeforePaint,\n useCallback,\n useMemo,\n useState,\n useSyncExternalStore,\n} from \"@bgub/fig\";\nimport type { HostIntrinsicElements } from \"@bgub/fig-dom\";\nimport type { RouterHistory } from \"@tanstack/history\";\nimport {\n type AnyRoute,\n type AnyRouteMatch,\n type AnyRouter,\n appendUniqueUserTags,\n createControlledPromise,\n deepEqual,\n escapeHtml,\n getLocationChangeInfo,\n isNotFound,\n type MetaDescriptor,\n type RegisteredRouter,\n type RouterManagedTag,\n rootRouteId,\n setupScrollRestoration,\n} from \"@tanstack/router-core\";\nimport { getScrollRestorationScriptForRouter } from \"@tanstack/router-core/scroll-restoration-script\";\nimport { batch } from \"@tanstack/store\";\nimport { dataStoreFromContext } from \"./data-context.ts\";\nimport { MatchContext, RouterContext, useRouter } from \"./hooks.tsx\";\nimport {\n collectRouteAssets,\n renderPositionedRouterTag,\n renderRouterHeadTags,\n} from \"./route-assets.ts\";\nimport type { AsyncRouteComponent } from \"./route.tsx\";\nimport { useReadableStore } from \"./store.ts\";\n\ndeclare const __FIG_DEV__: boolean | undefined;\n\nconst __DEV__ = typeof __FIG_DEV__ === \"boolean\" ? __FIG_DEV__ : false;\n\ndeclare module \"@tanstack/router-core\" {\n interface RouteMatchExtensions {\n headScripts?: Array<HostIntrinsicElements[\"script\"] | undefined>;\n links?: Array<HostIntrinsicElements[\"link\"] | undefined>;\n meta?: Array<HostIntrinsicElements[\"meta\"] | MetaDescriptor | undefined>;\n scripts?: Array<HostIntrinsicElements[\"script\"] | undefined>;\n styles?: Array<HostIntrinsicElements[\"style\"] | undefined>;\n }\n}\n\ntype HistoryUpdate = Parameters<Parameters<RouterHistory[\"subscribe\"]>[0]>[0];\n\nexport type RouterProviderProps<TRouter extends AnyRouter = RegisteredRouter> =\n Partial<Omit<TRouter[\"options\"], \"context\">> & {\n context?: Partial<TRouter[\"options\"][\"context\"]>;\n router: TRouter;\n };\n\nexport function RouterProvider<TRouter extends AnyRouter = RegisteredRouter>({\n router,\n ...options\n}: RouterProviderProps<TRouter>): FigNode {\n if (Object.keys(options).length > 0) {\n if (\"context\" in options) {\n options.context = {\n ...router.options.context,\n ...options.context,\n };\n }\n router.update(options as never);\n }\n\n return createElement(\n RouterContext,\n { value: router },\n createElement(Transitioner),\n createElement(Matches),\n );\n}\n\ntype RouterTransitionState = {\n active: boolean;\n generation: number;\n initialLoadStarted: boolean;\n phase: \"idle\" | \"loading\" | \"loaded\" | \"mounting\";\n};\n\nfunction Transitioner(): FigNode {\n const router = useRouter<AnyRouter>();\n const state = useMemo<RouterTransitionState>(\n () => ({\n active: false,\n generation: 0,\n initialLoadStarted: false,\n phase: \"idle\",\n }),\n [router],\n );\n const settleLifecycle = useCallback(() => {\n if (state.phase === \"idle\") return;\n const isLoading = router.stores.isLoading.get();\n const hasPending = router.stores.hasPending.get();\n const isTransitioning = router.stores.isTransitioning.get();\n const changeInfo = getLocationChangeInfo(\n router.stores.location.get(),\n router.stores.resolvedLocation.get(),\n );\n if (!isLoading && state.phase === \"loading\") {\n state.phase = \"loaded\";\n router.emit({ type: \"onLoad\", ...changeInfo });\n }\n if (!isLoading && !hasPending && state.phase === \"loaded\") {\n state.phase = \"mounting\";\n router.emit({ type: \"onBeforeRouteMount\", ...changeInfo });\n }\n if (!isLoading && !hasPending && !isTransitioning) {\n state.phase = \"idle\";\n router.emit({ type: \"onResolved\", ...changeInfo });\n batch(() => {\n router.stores.status.set(\"idle\");\n router.stores.resolvedLocation.set(router.stores.location.get());\n });\n }\n }, [router, state]);\n const runRouterTransition = useCallback(\n (callback: () => void) => {\n const startsPending = !router.stores.isTransitioning.get();\n if (startsPending) router.stores.isTransitioning.set(true);\n\n let result: unknown;\n try {\n const publishesPending = router.stores.pendingMatches\n .get()\n .some((match) => match.status === \"pending\");\n if (startsPending || !publishesPending) {\n transition(() => {\n result = callback();\n });\n } else {\n result = callback();\n }\n } catch (error) {\n if (startsPending) {\n router.stores.isTransitioning.set(false);\n }\n throw error;\n }\n\n const promise = result as PromiseLike<unknown>;\n if (typeof promise?.then !== \"function\") {\n if (startsPending) {\n router.stores.isTransitioning.set(false);\n }\n return;\n }\n\n const generation = (state.generation += 1);\n state.phase = \"loading\";\n const finish = () => {\n if (state.active && state.generation === generation) {\n router.stores.isTransitioning.set(false);\n }\n };\n void promise.then(finish, (error: unknown) => {\n finish();\n queueMicrotask(() => {\n throw error;\n });\n });\n },\n [router, state],\n );\n const commitWithoutRouterViewTransition = useCallback(\n (commit: () => Promise<void>) => {\n router.shouldViewTransition = undefined;\n void commit();\n },\n [router],\n );\n\n useBeforePaint(\n (signal) => {\n const previousStartTransition = router.startTransition;\n const previousStartViewTransition = router.startViewTransition;\n const subscriptions = [\n router.stores.isLoading.subscribe(settleLifecycle),\n router.stores.hasPending.subscribe(settleLifecycle),\n router.stores.isTransitioning.subscribe(settleLifecycle),\n ];\n state.active = true;\n router.startTransition = runRouterTransition;\n router.startViewTransition = commitWithoutRouterViewTransition;\n signal.addEventListener(\n \"abort\",\n () => {\n for (const subscription of subscriptions) {\n subscription.unsubscribe();\n }\n state.active = false;\n state.generation += 1;\n if (router.startTransition === runRouterTransition) {\n router.startTransition = previousStartTransition;\n }\n if (\n router.startViewTransition === commitWithoutRouterViewTransition\n ) {\n router.startViewTransition = previousStartViewTransition;\n }\n if (router.stores.isTransitioning.get()) {\n router.stores.isTransitioning.set(false);\n }\n },\n { once: true },\n );\n return undefined;\n },\n [\n commitWithoutRouterViewTransition,\n router,\n runRouterTransition,\n settleLifecycle,\n state,\n ],\n );\n\n useBeforePaint(\n (signal) => {\n setupScrollRestoration(router);\n const unsubscribe = router.history.subscribe((update: HistoryUpdate) => {\n void router.load(update).catch(logRouterLoadError);\n });\n signal.addEventListener(\"abort\", unsubscribe, { once: true });\n\n if (state.initialLoadStarted) return undefined;\n state.initialLoadStarted = true;\n const nextLocation = router.buildLocation({\n _includeValidateSearch: true,\n hash: true,\n params: true,\n search: true,\n state: true,\n to: router.latestLocation.pathname,\n });\n if (router.latestLocation.publicHref !== nextLocation.publicHref) {\n void router\n .commitLocation({ ...nextLocation, replace: true })\n .catch(logRouterLoadError);\n } else if (\n !router.isServer &&\n router.ssr === undefined &&\n router.stores.matchesId.get().length === 0\n ) {\n void router.load().catch(logRouterLoadError);\n }\n return undefined;\n },\n [router, router.history, router.options.scrollRestoration, state],\n );\n\n return null;\n}\n\nfunction logRouterLoadError(error: unknown): void {\n console.error(\"Error loading route\", error);\n}\n\nfunction OnRendered(): FigNode {\n const router = useRouter<AnyRouter>();\n type ResolvedLocation = ReturnType<typeof router.stores.resolvedLocation.get>;\n const state = useMemo<{ previous: ResolvedLocation }>(\n () => ({ previous: undefined }),\n [router],\n );\n const resolvedLocationKey = useReadableStore(\n router.stores.resolvedLocation,\n (location) => location?.state.__TSR_key,\n );\n\n useBeforePaint(() => {\n if (router.isServer) return undefined;\n const current = router.stores.resolvedLocation.get();\n const previous = state.previous;\n if (\n current !== undefined &&\n (previous === undefined || previous.href !== current.href)\n ) {\n router.emit({\n type: \"onRendered\",\n ...getLocationChangeInfo(\n router.stores.location.get(),\n previous ?? current,\n ),\n });\n }\n state.previous = current;\n return undefined;\n }, [resolvedLocationKey, router, state]);\n\n return null;\n}\n\nexport function Matches(): FigNode {\n const router = useRouter<AnyRouter>();\n const firstMatchId = useReadableStore(router.stores.firstId);\n const content =\n firstMatchId === undefined\n ? null\n : createElement(Match, { matchId: firstMatchId });\n if (router.isServer || router.ssr !== undefined) return content;\n\n const rootRoute = router.routesById[rootRouteId];\n const PendingComponent =\n rootRoute.options.pendingComponent ??\n router.options.defaultPendingComponent;\n return createElement(\n Suspense,\n {\n fallback:\n PendingComponent === undefined ? null : createElement(PendingComponent),\n },\n content,\n );\n}\n\nfunction Match({ matchId }: { matchId: string }): FigNode {\n const router = useRouter<AnyRouter>();\n const [manualResetKey, setManualResetKey] = useState(0);\n const store = router.stores.matchStores.get(matchId);\n if (store === undefined) {\n throw new Error(`Could not find route match ${JSON.stringify(matchId)}.`);\n }\n const match = useReadableStore(store);\n const route = router.routesById[match.routeId];\n if (route === undefined) {\n throw new Error(`Could not find route ${JSON.stringify(match.routeId)}.`);\n }\n if (\n __DEV__ &&\n match.loaderData !== undefined &&\n dataStoreFromContext(match.context) !== undefined\n ) {\n throw new Error(\n `Route ${JSON.stringify(match.routeId)} loader returned a value while ` +\n \"router.context.data is configured. Fig data resources are the single \" +\n \"route-data cache: load with ensureRouteData or \" +\n \"context.data.preloadData in the loader, read with readData in the \" +\n \"component, and return void. For navigation-scoped values, derive \" +\n \"them from loaderDeps, search params, or beforeLoad context instead.\",\n );\n }\n\n const PendingComponent =\n route.options.pendingComponent ?? router.options.defaultPendingComponent;\n const ErrorComponent =\n route.options.errorComponent ?? router.options.defaultErrorComponent;\n const NotFoundComponent =\n route.options.notFoundComponent ??\n (route.isRoot ? router.options.defaultNotFoundComponent : undefined);\n const noSsr = match.ssr === false || match.ssr === \"data-only\";\n const shouldWrapInSuspense =\n (!route.isRoot || route.options.wrapInSuspense || noSsr) &&\n (route.options.wrapInSuspense ??\n (PendingComponent !== undefined ||\n (ErrorComponent as AsyncRouteComponent | undefined)?.preload ||\n noSsr));\n\n const pending = PendingComponent ? createElement(PendingComponent) : null;\n let content: FigNode = createElement(MatchContent, { match, route });\n if (noSsr || match._displayPending) {\n content = createElement(ClientOnly, { fallback: pending }, content);\n }\n if (shouldWrapInSuspense) {\n content = createElement(Suspense, { fallback: pending }, content);\n }\n\n const matchContent = createElement(\n MatchContext,\n { value: store },\n ErrorComponent || NotFoundComponent\n ? createElement(\n ErrorBoundary,\n {\n key:\n match.status === \"error\"\n ? `route-error:${match.fetchCount}`\n : `route:${manualResetKey}`,\n fallback: (error) => {\n if (isNotFound(error)) {\n error.routeId ??= match.routeId;\n if (\n NotFoundComponent === undefined ||\n error.routeId !== match.routeId\n ) {\n throw error;\n }\n return createElement(NotFoundComponent, {\n ...error,\n isNotFound: true,\n });\n }\n if (!ErrorComponent) throw error;\n return createElement(ErrorComponent, {\n error,\n reset: () => {\n dataStoreFromContext(match.context)?.invalidateDataError(\n error,\n );\n void router.invalidate().then(() => {\n const updatedMatch = router.stores.matchStores\n .get(match.id)\n ?.get();\n if (updatedMatch?.status !== \"error\") {\n setManualResetKey((key) => key + 1);\n }\n });\n },\n });\n },\n onError: (error, info) => {\n if (!isNotFound(error)) {\n if (route.options.onCatch) {\n route.options.onCatch(error as Error);\n } else {\n router.options.defaultOnCatch?.(error as Error, info);\n }\n }\n },\n },\n content,\n )\n : content,\n );\n const matchAssets = collectRouteAssets(\n router,\n match,\n router.ssr?.manifest,\n ).resources;\n const ownedMatchContent =\n matchAssets.length === 0 ? matchContent : assets(matchAssets, matchContent);\n\n if (route.parentRoute?.id !== rootRouteId) return ownedMatchContent;\n return [\n ownedMatchContent,\n createElement(OnRendered),\n router.options.scrollRestoration && router.isServer\n ? renderScrollRestorationScript(router)\n : null,\n ];\n}\n\nfunction MatchContent({\n match,\n route,\n}: {\n match: AnyRouteMatch;\n route: AnyRoute;\n}): FigNode {\n const router = useRouter<AnyRouter>();\n\n if (match._displayPending)\n return readMatchPromise(router, match, \"displayPendingPromise\");\n if (match._forcePending)\n return readMatchPromise(router, match, \"minPendingPromise\");\n if (match.status === \"pending\") {\n const pendingMinMs =\n route.options.pendingMinMs ?? router.options.defaultPendingMinMs;\n const PendingComponent =\n route.options.pendingComponent ?? router.options.defaultPendingComponent;\n const currentMatch = router.getMatch(match.id);\n if (\n pendingMinMs &&\n PendingComponent &&\n !router.isServer &&\n currentMatch !== undefined &&\n currentMatch._nonReactive.minPendingPromise === undefined\n ) {\n const minPendingPromise = createControlledPromise<void>();\n currentMatch._nonReactive.minPendingPromise = minPendingPromise;\n setTimeout(() => {\n minPendingPromise.resolve();\n currentMatch._nonReactive.minPendingPromise = undefined;\n }, pendingMinMs);\n }\n return readMatchPromise(router, match, \"loadPromise\");\n }\n if (match.status === \"error\") {\n const ErrorComponent =\n route.options.errorComponent ?? router.options.defaultErrorComponent;\n if (router.isServer && ErrorComponent) {\n return createElement(ErrorComponent, {\n error: match.error,\n reset: () => undefined,\n });\n }\n throw match.error;\n }\n if (match.status === \"redirected\") {\n return readMatchPromise(router, match, \"loadPromise\");\n }\n if (match.status === \"notFound\") return renderNotFound(router, route, match);\n\n const Component = route.options.component ?? router.options.defaultComponent;\n const remount =\n route.options.remountDeps ?? router.options.defaultRemountDeps;\n const remountDeps = remount?.({\n loaderDeps: match.loaderDeps,\n params: match._strictParams,\n routeId: match.routeId,\n search: match._strictSearch,\n });\n return Component === undefined\n ? createElement(Outlet)\n : createElement(Component, {\n key: remountDeps ? JSON.stringify(remountDeps) : undefined,\n });\n}\n\ntype MatchPromiseKey =\n | \"displayPendingPromise\"\n | \"loadPromise\"\n | \"minPendingPromise\";\n\nfunction readMatchPromise(\n router: AnyRouter,\n match: AnyRouteMatch,\n key: MatchPromiseKey,\n): FigNode {\n const promise =\n router.getMatch(match.id)?._nonReactive[key] ?? match._nonReactive[key];\n if (promise !== undefined) readPromise(promise);\n return null;\n}\n\nfunction ClientOnly({\n children,\n fallback,\n}: {\n children?: FigNode;\n fallback: FigNode;\n}): FigNode {\n const hydrated = useSyncExternalStore(\n subscribeHydration,\n () => true,\n () => false,\n );\n return hydrated ? children : fallback;\n}\n\nfunction subscribeHydration(): () => void {\n return () => undefined;\n}\n\nfunction renderScrollRestorationScript(router: AnyRouter): FigNode {\n const script = getScrollRestorationScriptForRouter(router);\n return script === null\n ? null\n : renderPositionedRouterTag({\n attrs: { nonce: router.options.ssr?.nonce },\n children: `${script};document.currentScript.remove()`,\n tag: \"script\",\n });\n}\n\nexport function Outlet(): FigNode {\n const router = useRouter<AnyRouter>();\n const parentMatchStore = readContext(MatchContext);\n const parentMatch = parentMatchStore?.get();\n const matchIds = useReadableStore(router.stores.matchesId);\n const parentIndex = matchIds.findIndex((id) => id === parentMatch?.id);\n if (parentMatch?.globalNotFound === true) {\n const route = router.routesById[parentMatch.routeId];\n if (route === undefined) {\n throw new Error(\n `Could not find route ${JSON.stringify(parentMatch.routeId)}.`,\n );\n }\n return renderNotFound(router, route, parentMatch);\n }\n if (parentMatch !== undefined && parentIndex === -1) return null;\n const childMatchId = matchIds[parentIndex + 1];\n return childMatchId === undefined\n ? null\n : createElement(Match, { matchId: childMatchId });\n}\n\nexport function HeadContent(): FigNode {\n const router = useRouter<AnyRouter>();\n const selectTags = useCallback(\n (matches: AnyRouteMatch[]) => buildHeadTags(router, matches),\n [router],\n );\n const tags = useReadableStore(router.stores.matches, selectTags, deepEqual);\n return renderRouterHeadTags(tags);\n}\n\nexport function Scripts(): FigNode {\n const router = useRouter<AnyRouter>();\n const selectTags = useCallback(\n (matches: AnyRouteMatch[]) =>\n matches.flatMap(\n (match) =>\n collectRouteAssets(router, match, router.ssr?.manifest).scripts,\n ),\n [router],\n );\n const selectedTags = useReadableStore(\n router.stores.matches,\n selectTags,\n deepEqual,\n );\n const tags = [...selectedTags];\n\n const buffered = router.serverSsr?.takeBufferedScripts();\n if (buffered !== undefined) tags.unshift(buffered);\n return tags.map(renderPositionedRouterTag);\n}\n\nfunction buildHeadTags(\n router: AnyRouter,\n matches: AnyRouteMatch[],\n): RouterManagedTag[] {\n const nonce = router.options.ssr?.nonce;\n const manifest = router.ssr?.manifest;\n const metaTags: RouterManagedTag[] = [];\n const seenMeta = new Set<string>();\n let selectedTitle: RouterManagedTag | undefined;\n\n for (let matchIndex = matches.length - 1; matchIndex >= 0; matchIndex -= 1) {\n const routeMeta = matches[matchIndex]?.meta ?? [];\n for (let metaIndex = routeMeta.length - 1; metaIndex >= 0; metaIndex -= 1) {\n const value = routeMeta[metaIndex];\n if (value === undefined) continue;\n const title =\n \"title\" in value && typeof value.title === \"string\"\n ? value.title\n : undefined;\n if (title !== undefined) {\n selectedTitle ??= { tag: \"title\", children: title };\n continue;\n }\n if (\"script:ld+json\" in value) {\n try {\n metaTags.push({\n tag: \"script\",\n attrs: { type: \"application/ld+json\" },\n children: escapeHtml(JSON.stringify(value[\"script:ld+json\"])),\n });\n } catch {\n // Invalid JSON-LD is omitted, matching TanStack Router's adapters.\n }\n continue;\n }\n const identity =\n (\"name\" in value && typeof value.name === \"string\"\n ? value.name\n : undefined) ??\n (\"property\" in value && typeof value.property === \"string\"\n ? value.property\n : undefined);\n if (identity !== undefined) {\n if (seenMeta.has(identity)) continue;\n seenMeta.add(identity);\n }\n metaTags.push({ tag: \"meta\", attrs: { ...value, nonce } });\n }\n }\n if (selectedTitle !== undefined) metaTags.push(selectedTitle);\n if (nonce !== undefined) {\n metaTags.push({\n tag: \"meta\",\n attrs: { content: nonce, property: \"csp-nonce\" },\n });\n }\n metaTags.reverse();\n\n const tags: RouterManagedTag[] = [];\n appendUniqueUserTags(tags, metaTags);\n appendUniqueUserTags(\n tags,\n matches.flatMap(\n (match) => collectRouteAssets(router, match, manifest).links,\n ),\n );\n if (manifest?.inlineStyle !== undefined) {\n tags.push({\n tag: \"style\",\n attrs: { ...manifest.inlineStyle.attrs, nonce },\n children: manifest.inlineStyle.children,\n inlineCss: true,\n });\n }\n appendUniqueUserTags(\n tags,\n matches.flatMap((match) =>\n (match.styles ?? [])\n .filter((style) => style !== undefined)\n .map(({ children, ...attrs }) => ({\n tag: \"style\" as const,\n attrs: { ...attrs, nonce },\n children: children as string | undefined,\n })),\n ),\n );\n appendUniqueUserTags(\n tags,\n matches.flatMap(\n (match) => collectRouteAssets(router, match, manifest).headScripts,\n ),\n );\n return tags;\n}\n\nfunction renderNotFound(\n router: AnyRouter,\n route: AnyRoute,\n match: AnyRouteMatch,\n): FigNode {\n const NotFoundComponent =\n route.options.notFoundComponent ?? router.options.defaultNotFoundComponent;\n return NotFoundComponent === undefined\n ? null\n : createElement(NotFoundComponent, {\n data: match.error,\n isNotFound: true,\n routeId: match.routeId,\n });\n}\n","import {\n createElement,\n type ComponentType,\n type ErrorInfo,\n type FigNode,\n type Props,\n readPromise,\n} from \"@bgub/fig\";\nimport type { RouterHistory } from \"@tanstack/history\";\nimport {\n type AnyContext,\n type AnyRoute,\n type AnyRouter,\n type AssetCrossOriginConfig,\n BaseRootRoute,\n BaseRoute,\n BaseRouteApi,\n type Constrain,\n type ConstrainLiteral,\n type CreateFileRoute,\n type CreateLazyFileRoute,\n type FileRoutesByPath as CoreFileRoutesByPath,\n type InferFrom,\n type InferMaskFrom,\n type InferMaskTo,\n type InferTo,\n type LinkOptions,\n type MakeRouteMatch,\n type NotFoundError,\n type NotFoundRouteProps,\n notFound as createNotFound,\n type Register,\n type RegisteredRouter,\n type ResolveFullPath,\n type ResolveId,\n type ResolveParams,\n type ResolveUseLoaderDeps,\n type ResolveUseParams,\n type ResolveUseSearch,\n type RootRouteId,\n type RootRouteOptions,\n type RouteConstraints,\n type RouteIds,\n type RouteMask,\n type RouteOptions,\n type RouteTypesById,\n RouterCore,\n type RouterConstructorOptions,\n type ToMaskOptions,\n type TrailingSlashOption,\n type UseLoaderDepsResult,\n type UseNavigateResult,\n type UseParamsResult,\n type UseRouteContextResult,\n type UseSearchResult,\n} from \"@tanstack/router-core\";\nimport { dataStoreFromContext } from \"./data-context.ts\";\nimport {\n type RouteMatchResult,\n type SelectRouteValue,\n useMatchValue,\n useNavigateFrom,\n useRouter,\n} from \"./hooks.tsx\";\nimport { Link, type LinkProps } from \"./link.tsx\";\nimport { getStoreConfig } from \"./store.ts\";\n\ntype ValidateLinkOptions<\n TRouter extends AnyRouter,\n TOptions,\n TDefaultFrom extends string = string,\n> = Constrain<\n TOptions,\n LinkOptions<\n TRouter,\n InferFrom<TOptions, TDefaultFrom>,\n InferTo<TOptions>,\n InferMaskFrom<TOptions>,\n InferMaskTo<TOptions>\n >\n>;\n\ntype ValidateLinkOptionsArray<\n TRouter extends AnyRouter,\n TOptions extends ReadonlyArray<unknown>,\n TDefaultFrom extends string = string,\n> = {\n [TIndex in keyof TOptions]: ValidateLinkOptions<\n TRouter,\n TOptions[TIndex],\n TDefaultFrom\n >;\n};\n\nexport type LinkOptionsFnOptions<\n TOptions,\n TRouter extends AnyRouter = RegisteredRouter,\n> =\n TOptions extends ReadonlyArray<unknown>\n ? ValidateLinkOptionsArray<TRouter, TOptions>\n : ValidateLinkOptions<TRouter, TOptions>;\n\nexport function linkOptions<\n const TOptions,\n TRouter extends AnyRouter = RegisteredRouter,\n>(options: LinkOptionsFnOptions<TOptions, TRouter>): TOptions {\n return options as TOptions;\n}\n\nexport interface FileRoutesByPath extends CoreFileRoutesByPath {}\n\nexport type RouteErrorComponentProps = {\n error: unknown;\n reset: () => void;\n};\n\nexport type RouteComponent = ComponentType;\nexport type ErrorRouteComponent = ComponentType<RouteErrorComponentProps>;\nexport type NotFoundRouteComponent = ComponentType<NotFoundRouteProps>;\n\nexport type UseMatchRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n options?: SelectRouteValue<\n MakeRouteMatch<TRouter[\"routeTree\"], TFrom, true>,\n TSelected\n >,\n) => RouteMatchResult<TRouter, TFrom, true, TSelected>;\n\nexport type UseParamsRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n options?: SelectRouteValue<ResolveUseParams<TRouter, TFrom, true>, TSelected>,\n) => UseParamsResult<TRouter, TFrom, true, TSelected>;\n\nexport type UseSearchRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n options?: SelectRouteValue<ResolveUseSearch<TRouter, TFrom, true>, TSelected>,\n) => UseSearchResult<TRouter, TFrom, true, TSelected>;\n\nexport type UseLoaderDepsRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n options?: SelectRouteValue<ResolveUseLoaderDeps<TRouter, TFrom>, TSelected>,\n) => UseLoaderDepsResult<TRouter, TFrom, TSelected>;\n\nexport type UseRouteContextRoute<out TFrom> = <\n TRouter extends AnyRouter = RegisteredRouter,\n TSelected = unknown,\n>(\n options?: SelectRouteValue<\n UseRouteContextResult<TRouter, TFrom, true, unknown>,\n TSelected\n >,\n) => UseRouteContextResult<TRouter, TFrom, true, TSelected>;\n\nexport type LinkComponentRoute<TFrom extends string> = <\n const TTo extends string | undefined = undefined,\n const TMaskFrom extends string = TFrom,\n const TMaskTo extends string = \"\",\n>(\n props: Omit<LinkProps<TFrom, TTo, TMaskFrom, TMaskTo>, \"from\">,\n) => FigNode;\n\nexport type RouteApiMethods<TId extends string, TFullPath extends string> = {\n Link: LinkComponentRoute<TFullPath>;\n notFound: (options?: NotFoundError) => NotFoundError;\n useLoaderDeps: UseLoaderDepsRoute<TId>;\n useMatch: UseMatchRoute<TId>;\n useNavigate: () => UseNavigateResult<TFullPath>;\n useParams: UseParamsRoute<TId>;\n useRouteContext: UseRouteContextRoute<TId>;\n useSearch: UseSearchRoute<TId>;\n};\n\nfunction bindRouteApi<TId extends string, TFullPath extends string>(\n getId: () => TId,\n useFullPath: () => TFullPath,\n): RouteApiMethods<TId, TFullPath> {\n return {\n Link: (props) =>\n createElement(Link, {\n ...props,\n from: useFullPath(),\n } as never),\n notFound: (options) =>\n createNotFound({ routeId: getId(), ...options } as never),\n useLoaderDeps: (options) =>\n useMatchValue(getId(), options, (match) => match.loaderDeps) as never,\n useMatch: (options) =>\n useMatchValue(getId(), options, (match) => match) as never,\n useNavigate: () => useNavigateFrom(useFullPath()) as never,\n useParams: (options) =>\n useMatchValue(getId(), options, (match) => match.params) as never,\n useRouteContext: (options) =>\n useMatchValue(getId(), options, (match) => match.context) as never,\n useSearch: (options) =>\n useMatchValue(getId(), options, (match) => match.search) as never,\n };\n}\n\ntype RouteWithApi<\n TRoute,\n TId extends string,\n TFullPath extends string,\n> = TRoute & RouteApiMethods<TId, TFullPath>;\n\nfunction attachRouteApi<\n TId extends string,\n TFullPath extends string,\n TRoute extends { readonly fullPath: TFullPath; readonly id: TId },\n>(route: TRoute): RouteWithApi<TRoute, TId, TFullPath> {\n return Object.assign(\n route,\n bindRouteApi(\n () => route.id,\n () => route.fullPath,\n ),\n );\n}\n\ndeclare module \"@tanstack/router-core\" {\n interface RouteExtensions<\n in out TId extends string,\n in out TFullPath extends string,\n > {\n Link: LinkComponentRoute<TFullPath>;\n notFound: (options?: NotFoundError) => NotFoundError;\n useLoaderDeps: UseLoaderDepsRoute<TId>;\n useMatch: UseMatchRoute<TId>;\n useNavigate: () => UseNavigateResult<TFullPath>;\n useParams: UseParamsRoute<TId>;\n useRouteContext: UseRouteContextRoute<TId>;\n useSearch: UseSearchRoute<TId>;\n }\n\n interface UpdatableRouteOptionsExtensions {\n component?: RouteComponent;\n errorComponent?: false | null | ErrorRouteComponent;\n notFoundComponent?: NotFoundRouteComponent;\n pendingComponent?: RouteComponent;\n }\n\n interface RouterOptionsExtensions {\n assetCrossOrigin?: AssetCrossOriginConfig;\n defaultComponent?: RouteComponent;\n defaultErrorComponent?: ErrorRouteComponent;\n defaultNotFoundComponent?: NotFoundRouteComponent;\n defaultOnCatch?: (error: Error, info: ErrorInfo) => void;\n defaultPendingComponent?: RouteComponent;\n }\n}\n\nexport function createRouteMask<\n TRouteTree extends AnyRoute,\n TFrom extends string,\n TTo extends string,\n>(\n options: { routeTree: TRouteTree } & ToMaskOptions<\n RouterCore<TRouteTree, \"never\", boolean>,\n TFrom,\n TTo\n >,\n): RouteMask<TRouteTree> {\n return options as RouteMask<TRouteTree>;\n}\n\nexport function createRouter<\n TRouteTree extends AnyRoute,\n TTrailingSlashOption extends TrailingSlashOption = \"never\",\n TDefaultStructuralSharingOption extends boolean = false,\n TRouterHistory extends RouterHistory = RouterHistory,\n TDehydrated extends Record<string, unknown> = Record<string, unknown>,\n>(\n options: RouterConstructorOptions<\n TRouteTree,\n TTrailingSlashOption,\n TDefaultStructuralSharingOption,\n TRouterHistory,\n TDehydrated\n >,\n) {\n return new RouterCore(\n options.defaultPreloadStaleTime === undefined &&\n dataStoreFromContext(options.context) !== undefined\n ? { ...options, defaultPreloadStaleTime: 0 }\n : options,\n getStoreConfig,\n );\n}\n\nexport function getRouteApi<\n const TId extends string,\n TRouter extends AnyRouter = RegisteredRouter,\n>(id: ConstrainLiteral<TId, RouteIds<TRouter[\"routeTree\"]>>) {\n return new RouteApi<TId, TRouter>({ id });\n}\n\nclass RouteApi<\n TId extends string,\n TRouter extends AnyRouter = RegisteredRouter,\n> extends BaseRouteApi<TId, TRouter> {\n declare Link: LinkComponentRoute<RouteTypesById<TRouter, TId>[\"fullPath\"]>;\n declare useLoaderDeps: UseLoaderDepsRoute<TId>;\n declare useMatch: UseMatchRoute<TId>;\n declare useNavigate: () => UseNavigateResult<\n RouteTypesById<TRouter, TId>[\"fullPath\"]\n >;\n declare useParams: UseParamsRoute<TId>;\n declare useRouteContext: UseRouteContextRoute<TId>;\n declare useSearch: UseSearchRoute<TId>;\n\n constructor({ id }: { id: TId }) {\n super({ id });\n Object.assign(\n this,\n bindRouteApi(\n () => String(this.id),\n () => {\n const router = useRouter<TRouter>();\n return router.routesById[String(this.id)].fullPath;\n },\n ),\n );\n }\n}\n\nexport function createRoute<\n TRegister = unknown,\n TParentRoute extends RouteConstraints[\"TParentRoute\"] = AnyRoute,\n TPath extends RouteConstraints[\"TPath\"] = \"/\",\n TFullPath extends RouteConstraints[\"TFullPath\"] = ResolveFullPath<\n TParentRoute,\n TPath\n >,\n TCustomId extends RouteConstraints[\"TCustomId\"] = string,\n TId extends RouteConstraints[\"TId\"] = ResolveId<\n TParentRoute,\n TCustomId,\n TPath\n >,\n TSearchValidator = undefined,\n TParams = ResolveParams<TPath>,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, unknown> = {},\n TLoaderFn = undefined,\n TChildren = unknown,\n TSSR = unknown,\n const TServerMiddlewares = unknown,\n THandlers = undefined,\n>(\n options: RouteOptions<\n TRegister,\n TParentRoute,\n TId,\n TCustomId,\n TFullPath,\n TPath,\n TSearchValidator,\n TParams,\n TLoaderDeps,\n TLoaderFn,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TSSR,\n TServerMiddlewares,\n THandlers\n >,\n): RouteWithApi<\n BaseRoute<\n TRegister,\n TParentRoute,\n TPath,\n TFullPath,\n TCustomId,\n TId,\n TSearchValidator,\n TParams,\n AnyContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TChildren,\n unknown,\n TSSR,\n TServerMiddlewares,\n THandlers\n >,\n TId,\n TFullPath\n> {\n return attachRouteApi(new BaseRoute(options));\n}\n\nexport function createFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TParentRoute extends AnyRoute = FileRoutesByPath[TFilePath][\"parentRoute\"],\n TId extends RouteConstraints[\"TId\"] = FileRoutesByPath[TFilePath][\"id\"],\n TPath extends RouteConstraints[\"TPath\"] = FileRoutesByPath[TFilePath][\"path\"],\n TFullPath extends RouteConstraints[\"TFullPath\"] =\n FileRoutesByPath[TFilePath][\"fullPath\"],\n>(\n _path?: TFilePath,\n): CreateFileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath> {\n return ((options) => {\n const route = attachRouteApi(new BaseRoute(options as never));\n route.isRoot = false as never;\n return route as never;\n }) as CreateFileRoute<TFilePath, TParentRoute, TId, TPath, TFullPath>;\n}\n\nexport function createLazyFileRoute<\n TFilePath extends keyof FileRoutesByPath,\n TRoute extends FileRoutesByPath[TFilePath][\"preLoaderRoute\"],\n>(id: TFilePath): CreateLazyFileRoute<TRoute> {\n return (options) => ({ options: { id, ...options } });\n}\n\nexport type AsyncRouteComponent<TProps = Props> = ComponentType<TProps> & {\n preload?: () => Promise<void>;\n};\n\ntype ImportedRouteComponent<TValue> =\n TValue extends ComponentType<infer TProps>\n ? AsyncRouteComponent<TProps>\n : never;\n\nexport function lazyRouteComponent<TComponent>(\n importer: () => Promise<{ default: TComponent }>,\n): ImportedRouteComponent<TComponent>;\nexport function lazyRouteComponent<\n TModule extends Record<string, unknown>,\n TKey extends keyof TModule,\n>(\n importer: () => Promise<TModule>,\n exportName: TKey,\n): ImportedRouteComponent<TModule[TKey]>;\nexport function lazyRouteComponent(\n importer: () => Promise<Record<string, unknown>>,\n exportName = \"default\",\n): AsyncRouteComponent {\n let component: ComponentType | undefined;\n let loadPromise: Promise<ComponentType> | undefined;\n\n const load = () =>\n (loadPromise ??= importer().then((module) => {\n const imported = module[exportName];\n if (!isRouteComponent(imported)) {\n throw new TypeError(\n `Route module export ${JSON.stringify(exportName)} is not a component.`,\n );\n }\n component = imported;\n return imported;\n }));\n\n const LazyComponent: ComponentType = (props) =>\n createElement(component ?? readPromise(load()), props);\n\n return Object.assign(LazyComponent, {\n preload: async () => {\n await load();\n },\n });\n}\n\nfunction isRouteComponent(value: unknown): value is ComponentType {\n return typeof value === \"function\";\n}\n\nexport function createRootRoute<\n TRegister = Register,\n TSearchValidator = undefined,\n TRouterContext = {},\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TLoaderDeps extends Record<string, unknown> = {},\n TLoaderFn = undefined,\n TSSR = unknown,\n const TServerMiddlewares = unknown,\n THandlers = undefined,\n>(\n options?: RootRouteOptions<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TSSR,\n TServerMiddlewares,\n THandlers\n >,\n): RouteWithApi<\n BaseRootRoute<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n unknown,\n unknown,\n TSSR,\n TServerMiddlewares,\n THandlers\n >,\n RootRouteId,\n \"/\"\n> {\n return attachRouteApi(new BaseRootRoute(options));\n}\n\nexport function createRootRouteWithContext<TRouterContext extends object>() {\n return <\n TRegister = Register,\n TRouteContextFn = AnyContext,\n TBeforeLoadFn = AnyContext,\n TSearchValidator = undefined,\n TLoaderDeps extends Record<string, unknown> = {},\n TLoaderFn = undefined,\n TSSR = unknown,\n TServerMiddlewares = unknown,\n THandlers = undefined,\n >(\n options?: RootRouteOptions<\n TRegister,\n TSearchValidator,\n TRouterContext,\n TRouteContextFn,\n TBeforeLoadFn,\n TLoaderDeps,\n TLoaderFn,\n TSSR,\n TServerMiddlewares,\n THandlers\n >,\n ) => createRootRoute(options);\n}\n"],"mappings":";;;;;;;;AAMA,eAAsB,gBACpB,SACA,UACA,GAAG,MACY;CACf,MAAM,QAAQ,KAAK,WAAW,UAAU,GAAG,IAAI;AACjD;AAEA,SAAgB,qBACd,SACgC;CAChC,OAAO,SAAS;AAClB;;;ACNA,MAAa,kBAAkC,YAAY;CACzD,IAAI,QAAQ,YAAY,OAAO,aAAa,aAC1C,OAAO;EACL,QAAQ,aAAa,SAAS;EAC9B,oBAAoB;EACpB,qBAAqB;CACvB;CAGF,OAAO;EACL;EACA,oBAAoB;EACpB,qBAAqB;CACvB;AACF;AAEA,SAAS,iBAAyB,OAAuB;CACvD,OAAO;AACT;AAOA,SAAS,YAAkB,CAAC;AAE5B,SAAgB,iBACd,OACA,SAAuC,kBAGvC,QAA2D,OAAO,IACvD;CACX,MAAM,YAAY,aACf,aACC,MAAM,YAAY,QAAQ,CAAC,CAAC,eAAe,WAC7C,CAAC,KAAK,CACR;CACA,MAAM,cAAc,cAAc;EAChC,IAAI;EACJ,IAAI;EACJ,IAAI,cAAc;EAClB,aAAa;GACX,MAAM,aAAa,MAAM,IAAI;GAC7B,IAAI,eAAe,OAAO,GAAG,QAAQ,UAAU,GAAG,OAAO;GACzD,MAAM,eAAe,OAAO,UAAU;GACtC,SAAS;GACT,IAAI,eAAe,MAAM,UAAU,YAAY,GAAG,OAAO;GACzD,WAAW;GACX,cAAc;GACd,OAAO;EACT;CACF,GAAG;EAAC;EAAO;EAAQ;CAAK,CAAC;CACzB,OAAO,qBAAqB,WAAW,aAAa,WAAW;AACjE;;;ACGA,MAAa,gBAAgB,cAAgC,IAAI;AACjE,MAAa,eACX,cAAyD,IAAI;AAC/D,MAAM,eAAe,OAAO,qBAAqB;AACjD,M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1
1
|
{
|
|
2
2
|
"name": "@bgub/fig-tanstack-router",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.3",
|
|
4
4
|
"description": "TanStack Router adapter for Fig",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"fig",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
14
|
"types": "./dist/router.d.ts",
|
|
15
|
+
"fig-development": "./dist-development/router.js",
|
|
15
16
|
"import": "./dist/router.js",
|
|
16
17
|
"default": "./dist/router.js"
|
|
17
18
|
},
|
|
@@ -20,6 +21,7 @@
|
|
|
20
21
|
"types": "./dist/router.d.ts",
|
|
21
22
|
"files": [
|
|
22
23
|
"dist",
|
|
24
|
+
"dist-development",
|
|
23
25
|
"CHANGELOG.md",
|
|
24
26
|
"COMPATIBILITY.md"
|
|
25
27
|
],
|
|
@@ -43,12 +45,12 @@
|
|
|
43
45
|
"@tanstack/store": "0.9.3"
|
|
44
46
|
},
|
|
45
47
|
"peerDependencies": {
|
|
46
|
-
"@bgub/fig": "0.1.0-alpha.
|
|
47
|
-
"@bgub/fig-dom": "0.1.0-alpha.
|
|
48
|
+
"@bgub/fig": "0.1.0-alpha.3",
|
|
49
|
+
"@bgub/fig-dom": "0.1.0-alpha.3"
|
|
48
50
|
},
|
|
49
51
|
"devDependencies": {
|
|
50
|
-
"@bgub/fig": "0.1.0-alpha.
|
|
51
|
-
"@bgub/fig-dom": "0.1.0-alpha.
|
|
52
|
+
"@bgub/fig": "0.1.0-alpha.3",
|
|
53
|
+
"@bgub/fig-dom": "0.1.0-alpha.3"
|
|
52
54
|
},
|
|
53
55
|
"engines": {
|
|
54
56
|
"node": "^20.19.0 || >=22.12.0"
|