@solidnative-dev/navigation 0.0.0-stage → 0.1.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,98 @@
1
+ import { type AnyRouter, type CreateRouterFn, type GetStoreConfig, type MakeRouteMatchUnion, type MatchRouteOptions, type NavigateOptions, type RegisteredRouter, type RouterState, type UseNavigateResult } from "@tanstack/router-core";
2
+ import { type AccessibilityState, type PressableProps } from "@solidnative-dev/core";
3
+ import { type NativeNode } from "@solidnative-dev/renderer";
4
+ import { type Accessor } from "solid-js";
5
+ export { BaseRootRoute as TanStackRootRoute, BaseRoute as TanStackRoute, redirect as tanStackRedirect, } from "@tanstack/router-core";
6
+ export type { AnyRoute as AnyTanStackRoute, AnyRouter as AnyTanStackRouter, RouterState as TanStackRouterState, } from "@tanstack/router-core";
7
+ /**
8
+ * Solid 2 store implementation for TanStack Router's framework extension
9
+ * point. `flush(fn)` is the Solid 2 atomic publication boundary replacing the
10
+ * Solid 1 `batch(fn)` primitive used by the published Solid router binding.
11
+ * When TanStack publishes settled router state (`resolvedLocation` and `status`)
12
+ * via `router.batch(...)` after `startTransition`, running the flush inside the
13
+ * router's active causal scope keeps every resulting native commit attributed
14
+ * to the navigation task that triggered it.
15
+ */
16
+ export declare const getSolidNativeRouterStoreConfig: GetStoreConfig;
17
+ /**
18
+ * Creates the framework-neutral TanStack routing engine with Solid 2-owned
19
+ * reactive stores. Native runtimes are always clients, even though they do not
20
+ * expose a DOM.
21
+ */
22
+ export declare const createTanStackNativeRouter: CreateRouterFn;
23
+ export interface TanStackNativeRouterProviderProps<TRouter extends AnyRouter = AnyRouter> {
24
+ readonly router: TRouter;
25
+ readonly children: NativeNode;
26
+ readonly onReady?: (router: TRouter) => unknown;
27
+ readonly onError?: (error: unknown) => unknown;
28
+ }
29
+ /**
30
+ * Owns the core history subscription and initial load for one native Solid
31
+ * subtree. Solid 2 `onSettled` supplies component setup/teardown, while the
32
+ * router transition hook acknowledges publication after the reactive graph
33
+ * settles.
34
+ */
35
+ export declare function TanStackNativeRouterProvider<TRouter extends AnyRouter = AnyRouter>(props: TanStackNativeRouterProviderProps<TRouter>): NativeNode;
36
+ export declare function useTanStackNativeRouter<TRouter extends AnyRouter = RegisteredRouter>(): TRouter;
37
+ export interface UseTanStackNativeNavigateOptions<TDefaultFrom extends string = string> {
38
+ readonly from?: TDefaultFrom;
39
+ }
40
+ /** Returns TanStack's registered-router navigation function without a DOM. */
41
+ export declare function useTanStackNativeNavigate<TDefaultFrom extends string = string>(defaultOptions?: UseTanStackNativeNavigateOptions<TDefaultFrom>): UseNavigateResult<TDefaultFrom>;
42
+ export interface TanStackNativeLinkState {
43
+ /** Whether the underlying native press gesture is currently active. */
44
+ readonly pressed: boolean;
45
+ /** Whether the destination matches the router's committed location. */
46
+ readonly isActive: boolean;
47
+ /** Whether the destination matches TanStack's pending location. */
48
+ readonly isPending: boolean;
49
+ /** Whether this link owns an unsettled navigation request. */
50
+ readonly isTransitioning: boolean;
51
+ /** Whether this link owns an unsettled route preload. */
52
+ readonly isPreloading: boolean;
53
+ }
54
+ export type TanStackNativeLinkPreload = false | "intent" | "render";
55
+ export type TanStackNativeLinkPressableProps = Omit<PressableProps, "accessibilityRole" | "accessibilityState" | "children" | "disabled" | "onPress" | "role"> & {
56
+ readonly accessibilityState?: Omit<AccessibilityState, "busy" | "disabled" | "selected">;
57
+ };
58
+ export interface TanStackNativeLinkProps<TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = ".", TMaskFrom extends string = TFrom, TMaskTo extends string = "."> {
59
+ /** Defaults to the nearest `TanStackNativeRouterProvider`. */
60
+ readonly router?: TRouter;
61
+ /** TanStack's registered-router navigation contract, including typed params. */
62
+ readonly options: NavigateOptions<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>;
63
+ /** Controls active and pending route matching. */
64
+ readonly activeOptions?: Omit<MatchRouteOptions, "pending">;
65
+ readonly disabled?: boolean;
66
+ /**
67
+ * `intent` preloads at native press-in; `render` preloads after the first
68
+ * Solid settlement. Defaults to the router's compatible preload policy.
69
+ */
70
+ readonly preload?: TanStackNativeLinkPreload;
71
+ /** Native interaction, styling, testing, and accessibility-label props. */
72
+ readonly pressableProps?: TanStackNativeLinkPressableProps;
73
+ readonly children: NativeNode | ((state: TanStackNativeLinkState) => NativeNode);
74
+ readonly onPreloadError?: (error: unknown) => unknown;
75
+ readonly onNavigationError?: (error: unknown) => unknown;
76
+ readonly onNavigationSettled?: () => unknown;
77
+ }
78
+ /**
79
+ * Presents a typed TanStack destination as a real native Pressable. The link's
80
+ * active and pending states are Solid memos over TanStack's stores; no React
81
+ * component, DOM anchor, or duplicated route matcher participates.
82
+ */
83
+ export declare function TanStackNativeLink<TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = ".", TMaskFrom extends string = TFrom, TMaskTo extends string = ".">(props: TanStackNativeLinkProps<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>): NativeNode;
84
+ export type TanStackNativeRouteMatch<TRouter extends AnyRouter> = MakeRouteMatchUnion<TRouter>;
85
+ export interface TanStackNativeRouteViewProps<TRouter extends AnyRouter = AnyRouter> {
86
+ readonly router?: TRouter;
87
+ readonly children: (match: Accessor<TanStackNativeRouteMatch<TRouter>>) => NativeNode;
88
+ readonly renderPending: (state: Accessor<RouterState<TRouter["routeTree"]>>) => NativeNode;
89
+ readonly renderError: (error: Accessor<unknown>, retry: () => Promise<void>, match: Accessor<TanStackNativeRouteMatch<TRouter>>) => NativeNode;
90
+ readonly renderNotFound: (match: Accessor<TanStackNativeRouteMatch<TRouter>>) => NativeNode;
91
+ }
92
+ /**
93
+ * Projects the active leaf match into native content without owning matching
94
+ * or loading policy. TanStack supplies the state machine; Solid preserves one
95
+ * branch owner for pending, error, not-found, and successful presentation.
96
+ */
97
+ export declare function TanStackNativeRouteView<TRouter extends AnyRouter = AnyRouter>(props: TanStackNativeRouteViewProps<TRouter>): Nativ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EAAE,SAAS,EAAE,OAAO,CAAC,GACtE,UAAU,CAwMZ;AAED,MAAM,MAAM,wBAAwB,CAAC,OAAO,SAAS,SAAS,IAC5D,mBAAmB,CAAC,OAAO,CAAC,CAAC;AAE/B,MAAM,WAAW,4BAA4B,CAC3C,OAAO,SAAS,SAAS,GAAG,SAAS;IAErC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,CACjB,KAAK,EAAE,QAAQ,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC,KAC/C,UAAU,CAAC;IAChB,QAAQ,CAAC,aAAa,EAAE,CACtB,KAAK,EAAE,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,KAC/C,UAAU,CAAC;IAChB,QAAQ,CAAC,WAAW,EAAE,CACpB,KAAK,EAAE,QAAQ,CAAC,OAAO,CAAC,EACxB,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAC1B,KAAK,EAAE,QAAQ,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC,KAC/C,UAAU,CAAC;IAChB,QAAQ,CAAC,cAAc,EAAE,CACvB,KAAK,EAAE,QAAQ,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAC,KAC/C,UAAU,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,SAAS,SAAS,GAAG,SAAS,EAC3E,KAAK,EAAE,4BAA4B,CAAC,OAAO,CAAC,GAC3C,UAAU,CAwDZ"}
@@ -0,0 +1,501 @@
1
+ import { RouterCore, } from "@tanstack/router-core";
2
+ import { Pressable, } from "@solidnative-dev/core";
3
+ import { useNativeCausalScopeFactory, } from "@solidnative-dev/renderer";
4
+ import { Show, createComponent as solidCreateComponent, createContext, createMemo, createSignal, flush, onSettled, useContext, } from "solid-js";
5
+ import { reportIsolatedError } from "./error-reporting.js";
6
+ export { BaseRootRoute as TanStackRootRoute, BaseRoute as TanStackRoute, redirect as tanStackRedirect, } from "@tanstack/router-core";
7
+ function createSolidMutableStore(initialValue) {
8
+ // TanStack's router stores contain locations, statuses, IDs, and matches,
9
+ // never callable values. The cast selects Solid 2's plain-signal overload
10
+ // rather than its function-as-computation overload for this generic factory.
11
+ const [read, write] = createSignal(initialValue, { ownedWrite: true });
12
+ return { get: read, set: write };
13
+ }
14
+ function createSolidReadonlyStore(read) {
15
+ return { get: createMemo(read) };
16
+ }
17
+ const boundRouters = new WeakSet();
18
+ const routerCausalScopeFactories = new WeakMap();
19
+ const activeRouterCausalScopes = new WeakMap();
20
+ function beginRouterCausalScope(router, name, fallbackFactory) {
21
+ const createScope = routerCausalScopeFactories.get(router) ?? fallbackFactory;
22
+ if (createScope === undefined)
23
+ return undefined;
24
+ // TanStack navigation is latest-wins. Reflect that ownership directly in the
25
+ // causal stream instead of leaving a displaced route task open.
26
+ const previous = activeRouterCausalScopes.get(router);
27
+ if (previous?.state === "active")
28
+ previous.cancel();
29
+ const scope = createScope(name);
30
+ activeRouterCausalScopes.set(router, scope);
31
+ return scope;
32
+ }
33
+ function runRouterCausalScope(scope, callback) {
34
+ return scope?.state === "active" ? scope.run(callback) : callback();
35
+ }
36
+ function settleRouterCausalScope(router, scope, status, error) {
37
+ if (scope === undefined)
38
+ return;
39
+ if (activeRouterCausalScopes.get(router) === scope) {
40
+ activeRouterCausalScopes.delete(router);
41
+ }
42
+ if (status === "finished")
43
+ scope.finish();
44
+ else
45
+ scope.fail(error);
46
+ }
47
+ /**
48
+ * Solid 2 store implementation for TanStack Router's framework extension
49
+ * point. `flush(fn)` is the Solid 2 atomic publication boundary replacing the
50
+ * Solid 1 `batch(fn)` primitive used by the published Solid router binding.
51
+ * When TanStack publishes settled router state (`resolvedLocation` and `status`)
52
+ * via `router.batch(...)` after `startTransition`, running the flush inside the
53
+ * router's active causal scope keeps every resulting native commit attributed
54
+ * to the navigation task that triggered it.
55
+ */
56
+ export const getSolidNativeRouterStoreConfig = (opts) => ({
57
+ createMutableStore: createSolidMutableStore,
58
+ createReadonlyStore: createSolidReadonlyStore,
59
+ batch(fn) {
60
+ runRouterCausalScope(typeof opts === "object" && opts !== null
61
+ ? activeRouterCausalScopes.get(opts)
62
+ : undefined, () => flush(fn));
63
+ },
64
+ });
65
+ /**
66
+ * Creates the framework-neutral TanStack routing engine with Solid 2-owned
67
+ * reactive stores. Native runtimes are always clients, even though they do not
68
+ * expose a DOM.
69
+ */
70
+ export const createTanStackNativeRouter = (options) => {
71
+ if (options.isServer === true) {
72
+ throw new Error("A Solid Native TanStack router must use isServer: false.");
73
+ }
74
+ const router = new RouterCore({ ...options, isServer: false, scrollRestoration: false }, getSolidNativeRouterStoreConfig);
75
+ // Core installs a browser-oriented onRendered reset even when restoration is
76
+ // disabled. A false predicate keeps that listener inert without enabling its
77
+ // document/sessionStorage setup during construction. Native scroll state is
78
+ // owned by native scroll containers, not globalThis.scrollTo.
79
+ router.options.scrollRestoration = () => false;
80
+ return router;
81
+ };
82
+ const TanStackNativeRouterContext = createContext();
83
+ const TanStackNativeRouterContextProvider = TanStackNativeRouterContext;
84
+ function reportRouterError(error, handler) {
85
+ if (reportIsolatedError(handler, error))
86
+ return;
87
+ void Promise.resolve().then(() => {
88
+ throw error;
89
+ });
90
+ }
91
+ function hasResolvedLatestLocation(router) {
92
+ const resolved = router.stores.resolvedLocation.get();
93
+ if (resolved === undefined || resolved.href !== router.latestLocation.href) {
94
+ return false;
95
+ }
96
+ return resolved.state.__TSR_key === router.latestLocation.state.__TSR_key;
97
+ }
98
+ /**
99
+ * Owns the core history subscription and initial load for one native Solid
100
+ * subtree. Solid 2 `onSettled` supplies component setup/teardown, while the
101
+ * router transition hook acknowledges publication after the reactive graph
102
+ * settles.
103
+ */
104
+ export function TanStackNativeRouterProvider(props) {
105
+ const createCausalScope = useNativeCausalScopeFactory();
106
+ const content = solidCreateComponent(TanStackNativeRouterContextProvider, {
107
+ value: props.router,
108
+ get children() {
109
+ return props.children;
110
+ },
111
+ });
112
+ onSettled(() => {
113
+ const router = props.router;
114
+ if (boundRouters.has(router)) {
115
+ throw new Error("A TanStack native router cannot be mounted by more than one provider.");
116
+ }
117
+ boundRouters.add(router);
118
+ routerCausalScopeFactories.set(router, createCausalScope);
119
+ let active = true;
120
+ let settleCurrent;
121
+ const previousStartTransition = router.startTransition;
122
+ const previousBatch = router.batch;
123
+ const startTransition = (publish) => {
124
+ settleCurrent?.(false);
125
+ return new Promise((resolve, reject) => {
126
+ const settle = (rendered) => {
127
+ if (settleCurrent !== settle)
128
+ return;
129
+ settleCurrent = undefined;
130
+ resolve(rendered);
131
+ };
132
+ settleCurrent = settle;
133
+ try {
134
+ const publishTransition = () => {
135
+ flush(() => {
136
+ if (active && settleCurrent === settle)
137
+ publish();
138
+ });
139
+ };
140
+ runRouterCausalScope(activeRouterCausalScopes.get(router), publishTransition);
141
+ // `flush` has already drained every reactive consumer of the router
142
+ // stores. Unlike Solid 1's async transition primitive, Solid 2 needs
143
+ // no second scheduler turn to acknowledge this synchronous publish.
144
+ settle(true);
145
+ }
146
+ catch (error) {
147
+ if (settleCurrent === settle)
148
+ settleCurrent = undefined;
149
+ reject(error);
150
+ }
151
+ });
152
+ };
153
+ const batch = (publish) => {
154
+ runRouterCausalScope(activeRouterCausalScopes.get(router), () => previousBatch(publish));
155
+ };
156
+ router.startTransition = startTransition;
157
+ router.batch = batch;
158
+ let unsubscribe;
159
+ try {
160
+ const history = router.history;
161
+ unsubscribe = history.subscribe((update) => {
162
+ void router.load(update).catch((error) => {
163
+ reportRouterError(error, props.onError);
164
+ });
165
+ });
166
+ }
167
+ catch (error) {
168
+ active = false;
169
+ router.startTransition = previousStartTransition;
170
+ router.batch = previousBatch;
171
+ boundRouters.delete(router);
172
+ if (routerCausalScopeFactories.get(router) === createCausalScope) {
173
+ routerCausalScopeFactories.delete(router);
174
+ }
175
+ throw error;
176
+ }
177
+ void Promise.resolve().then(() => {
178
+ if (!active)
179
+ return;
180
+ const initialLoad = hasResolvedLatestLocation(router)
181
+ ? Promise.resolve()
182
+ : router.load();
183
+ void initialLoad
184
+ .then(() => {
185
+ if (!active)
186
+ return;
187
+ try {
188
+ props.onReady?.(router);
189
+ }
190
+ catch (error) {
191
+ reportRouterError(error, props.onError);
192
+ }
193
+ })
194
+ .catch((error) => {
195
+ reportRouterError(error, props.onError);
196
+ });
197
+ });
198
+ return () => {
199
+ active = false;
200
+ settleCurrent?.(false);
201
+ settleCurrent = undefined;
202
+ unsubscribe?.();
203
+ if (router.startTransition === startTransition) {
204
+ router.startTransition = previousStartTransition;
205
+ }
206
+ if (router.batch === batch) {
207
+ router.batch = previousBatch;
208
+ }
209
+ const causalScope = activeRouterCausalScopes.get(router);
210
+ if (causalScope !== undefined) {
211
+ activeRouterCausalScopes.delete(router);
212
+ causalScope.cancel();
213
+ }
214
+ if (routerCausalScopeFactories.get(router) === createCausalScope) {
215
+ routerCausalScopeFactories.delete(router);
216
+ }
217
+ boundRouters.delete(router);
218
+ };
219
+ });
220
+ return content;
221
+ }
222
+ export function useTanStackNativeRouter() {
223
+ const router = useContext(TanStackNativeRouterContext);
224
+ if (router === undefined) {
225
+ throw new Error("A TanStack native router hook requires a TanStackNativeRouterProvider ancestor.");
226
+ }
227
+ return router;
228
+ }
229
+ /** Returns TanStack's registered-router navigation function without a DOM. */
230
+ export function useTanStackNativeNavigate(defaultOptions = {}) {
231
+ const router = useTanStackNativeRouter();
232
+ const createCausalScope = useNativeCausalScopeFactory();
233
+ const navigate = (navigationOptions) => {
234
+ const from = navigationOptions.from ?? defaultOptions.from;
235
+ const resolvedOptions = from === undefined ? navigationOptions : { ...navigationOptions, from };
236
+ assertNativeNavigationOptions(resolvedOptions);
237
+ const scope = beginRouterCausalScope(router, "navigation.programmatic", createCausalScope);
238
+ let navigation;
239
+ try {
240
+ navigation = runRouterCausalScope(scope, () => router.navigate(resolvedOptions));
241
+ }
242
+ catch (error) {
243
+ settleRouterCausalScope(router, scope, "failed", error);
244
+ throw error;
245
+ }
246
+ return navigation.then(() => settleRouterCausalScope(router, scope, "finished"), (error) => {
247
+ settleRouterCausalScope(router, scope, "failed", error);
248
+ throw error;
249
+ });
250
+ };
251
+ return navigate;
252
+ }
253
+ function assertNativeNavigationOptions(options) {
254
+ if (options.href !== undefined || options.reloadDocument === true) {
255
+ throw new Error("TanStackNativeLink only accepts client-native route navigation. Use a platform linking service for external URLs instead of href or reloadDocument.");
256
+ }
257
+ }
258
+ /**
259
+ * Presents a typed TanStack destination as a real native Pressable. The link's
260
+ * active and pending states are Solid memos over TanStack's stores; no React
261
+ * component, DOM anchor, or duplicated route matcher participates.
262
+ */
263
+ export function TanStackNativeLink(props) {
264
+ const router = props.router ?? useTanStackNativeRouter();
265
+ const createCausalScope = useNativeCausalScopeFactory();
266
+ const options = () => {
267
+ const current = props.options;
268
+ assertNativeNavigationOptions(current);
269
+ return current;
270
+ };
271
+ const isActive = createMemo(() => Boolean(router.matchRoute(options(), {
272
+ ...props.activeOptions,
273
+ pending: false,
274
+ })));
275
+ const isPending = createMemo(() => Boolean(router.matchRoute(options(), {
276
+ ...props.activeOptions,
277
+ pending: true,
278
+ })));
279
+ const [isTransitioning, setIsTransitioning] = createSignal(false);
280
+ const [isPreloading, setIsPreloading] = createSignal(false);
281
+ let navigationInFlight = false;
282
+ let preloadInFlight;
283
+ let active = true;
284
+ const preloadStrategy = () => {
285
+ const configured = props.preload ?? router.options.defaultPreload ?? false;
286
+ // A native component has no DOM IntersectionObserver. Applications that
287
+ // share a web router config must opt into render preloading explicitly.
288
+ return configured === "intent" || configured === "render"
289
+ ? configured
290
+ : false;
291
+ };
292
+ const preload = () => {
293
+ if (!active ||
294
+ props.disabled === true ||
295
+ isActive() ||
296
+ preloadInFlight !== undefined) {
297
+ return;
298
+ }
299
+ const onPreloadError = props.onPreloadError;
300
+ let request;
301
+ try {
302
+ request = router.preloadRoute(options());
303
+ }
304
+ catch (error) {
305
+ reportIsolatedError(onPreloadError, error);
306
+ return;
307
+ }
308
+ preloadInFlight = request;
309
+ setIsPreloading(true);
310
+ void request
311
+ .catch((error) => {
312
+ reportIsolatedError(onPreloadError, error);
313
+ })
314
+ .finally(() => {
315
+ if (preloadInFlight !== request)
316
+ return;
317
+ preloadInFlight = undefined;
318
+ if (active)
319
+ setIsPreloading(false);
320
+ });
321
+ };
322
+ onSettled(() => {
323
+ if (preloadStrategy() === "render")
324
+ preload();
325
+ return () => {
326
+ active = false;
327
+ };
328
+ });
329
+ const navigate = async () => {
330
+ if (props.disabled === true || navigationInFlight)
331
+ return;
332
+ const onNavigationError = props.onNavigationError;
333
+ const causalScope = beginRouterCausalScope(router, "navigation.link", createCausalScope);
334
+ let navigationError;
335
+ let navigationFailed = false;
336
+ navigationInFlight = true;
337
+ runRouterCausalScope(causalScope, () => setIsTransitioning(true));
338
+ try {
339
+ await runRouterCausalScope(causalScope, () => router.navigate(options()));
340
+ }
341
+ catch (error) {
342
+ navigationFailed = true;
343
+ navigationError = error;
344
+ reportRouterError(error, onNavigationError);
345
+ }
346
+ finally {
347
+ navigationInFlight = false;
348
+ if (active) {
349
+ runRouterCausalScope(causalScope, () => {
350
+ setIsTransitioning(false);
351
+ try {
352
+ props.onNavigationSettled?.();
353
+ }
354
+ catch (error) {
355
+ reportRouterError(error, onNavigationError);
356
+ }
357
+ });
358
+ }
359
+ settleRouterCausalScope(router, causalScope, navigationFailed ? "failed" : "finished", navigationError);
360
+ }
361
+ };
362
+ const pressableOverrides = {
363
+ get accessibilityRole() {
364
+ return "link";
365
+ },
366
+ get accessibilityState() {
367
+ return {
368
+ ...props.pressableProps?.accessibilityState,
369
+ disabled: props.disabled === true,
370
+ selected: isActive(),
371
+ busy: isPending() || isTransitioning(),
372
+ };
373
+ },
374
+ get disabled() {
375
+ return props.disabled === true;
376
+ },
377
+ onPress() {
378
+ void navigate();
379
+ },
380
+ onPressIn(event) {
381
+ const result = props.pressableProps?.onPressIn?.(event);
382
+ if (preloadStrategy() === "intent")
383
+ preload();
384
+ return result;
385
+ },
386
+ children: (pressableState) => {
387
+ const state = Object.freeze({
388
+ get pressed() {
389
+ return pressableState.pressed;
390
+ },
391
+ get isActive() {
392
+ return isActive();
393
+ },
394
+ get isPending() {
395
+ return isPending();
396
+ },
397
+ get isTransitioning() {
398
+ return isTransitioning();
399
+ },
400
+ get isPreloading() {
401
+ return isPreloading();
402
+ },
403
+ });
404
+ const children = props.children;
405
+ return typeof children === "function" ? children(state) : children;
406
+ },
407
+ };
408
+ // Preserve getter-backed nested props without sacrificing Pressable's
409
+ // render-function descriptor, which it uses to expose pressed state once.
410
+ const nativePressableProps = new Proxy(pressableOverrides, {
411
+ get(target, property, receiver) {
412
+ if (Reflect.getOwnPropertyDescriptor(target, property) !== undefined) {
413
+ return Reflect.get(target, property, receiver);
414
+ }
415
+ const forwarded = props.pressableProps;
416
+ return forwarded === undefined
417
+ ? undefined
418
+ : Reflect.get(forwarded, property, forwarded);
419
+ },
420
+ getOwnPropertyDescriptor(target, property) {
421
+ const owned = Reflect.getOwnPropertyDescriptor(target, property);
422
+ if (owned !== undefined)
423
+ return owned;
424
+ const forwarded = props.pressableProps;
425
+ const descriptor = forwarded === undefined
426
+ ? undefined
427
+ : Reflect.getOwnPropertyDescriptor(forwarded, property);
428
+ return descriptor === undefined
429
+ ? undefined
430
+ : { ...descriptor, configurable: true };
431
+ },
432
+ ownKeys(target) {
433
+ return [
434
+ ...new Set([
435
+ ...Reflect.ownKeys(props.pressableProps ?? {}),
436
+ ...Reflect.ownKeys(target),
437
+ ]),
438
+ ];
439
+ },
440
+ });
441
+ return solidCreateComponent(Pressable, nativePressableProps);
442
+ }
443
+ /**
444
+ * Projects the active leaf match into native content without owning matching
445
+ * or loading policy. TanStack supplies the state machine; Solid preserves one
446
+ * branch owner for pending, error, not-found, and successful presentation.
447
+ */
448
+ export function TanStackNativeRouteView(props) {
449
+ const router = props.router ?? useTanStackNativeRouter();
450
+ const state = router.stores.__store.get;
451
+ const match = createMemo(() => {
452
+ const matches = router.stores.matches.get();
453
+ return (matches.find((candidate) => candidate._notFound === true) ??
454
+ matches.at(-1));
455
+ });
456
+ const requiredMatch = match;
457
+ const retry = () => {
458
+ const id = requiredMatch().id;
459
+ return router.invalidate({
460
+ forcePending: true,
461
+ filter: (candidate) => candidate.id === id,
462
+ });
463
+ };
464
+ const notFound = solidCreateComponent(Show, {
465
+ get when() {
466
+ const current = match();
467
+ return current?.status === "notFound" || current?._notFound === true
468
+ ? current
469
+ : undefined;
470
+ },
471
+ children: () => props.renderNotFound(requiredMatch),
472
+ });
473
+ const errored = solidCreateComponent(Show, {
474
+ get when() {
475
+ const current = match();
476
+ return current?.status === "error" ? current : undefined;
477
+ },
478
+ fallback: notFound,
479
+ children: () => props.renderError(() => requiredMatch().error, retry, requiredMatch),
480
+ });
481
+ const resolved = solidCreateComponent(Show, {
482
+ get when() {
483
+ const current = match();
484
+ return current?.status === "success" && current._notFound !== true
485
+ ? current
486
+ : undefined;
487
+ },
488
+ fallback: errored,
489
+ children: () => props.children(requiredMatch),
490
+ });
491
+ return solidCreateComponent(Show, {
492
+ get when() {
493
+ return state().status !== "pending";
494
+ },
495
+ get fallback() {
496
+ return props.renderPending(state);
497
+ },
498
+ children: () => resolved,
499
+ });
500
+ }
501
+ //# sourceMappingURL=tanstack-router.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tanstack-router.js","sourceRoot":"","sources":["../src/tanstack-router.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,GAYX,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,SAAS,GAGV,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAIL,2BAA2B,GAC5B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,IAAI,EACJ,eAAe,IAAI,oBAAoB,EACvC,aAAa,EACb,UAAU,EACV,YAAY,EACZ,KAAK,EACL,SAAS,EACT,UAAU,GAGX,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAE3D,OAAO,EACL,a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