@bleedingdev/modern-js-plugin-tanstack 3.8.3-ultramodern.6 → 3.9.0-ultramodern.10
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/dist/cjs/cli/index.js +9 -0
- package/dist/cjs/cli/tanstackTypes/source.js +3 -1
- package/dist/cjs/runtime/basepathRewrite.js +13 -6
- package/dist/cjs/runtime/lifecycle.js +7 -7
- package/dist/cjs/runtime/plugin.js +1 -1
- package/dist/cjs/runtime/plugin.node.js +5 -1
- package/dist/cjs/runtime/prefetchLink.js +2 -7
- package/dist/cjs/runtime/register.js +0 -2
- package/dist/cjs/runtime/routeTree/construction.js +2 -0
- package/dist/cjs/runtime/router.js +25 -9
- package/dist/cjs/runtime/state.js +2 -2
- package/dist/cjs/runtime/utils.js +2 -0
- package/dist/esm/cli/index.mjs +13 -5
- package/dist/esm/cli/tanstackTypes/source.mjs +3 -1
- package/dist/esm/runtime/basepathRewrite.mjs +10 -3
- package/dist/esm/runtime/lifecycle.mjs +1 -1
- package/dist/esm/runtime/plugin.mjs +1 -1
- package/dist/esm/runtime/plugin.node.mjs +5 -1
- package/dist/esm/runtime/prefetchLink.mjs +1 -6
- package/dist/esm/runtime/register.mjs +0 -2
- package/dist/esm/runtime/routeTree/construction.mjs +2 -0
- package/dist/esm/runtime/router.mjs +27 -11
- package/dist/esm/runtime/state.mjs +1 -1
- package/dist/esm/runtime/utils.mjs +2 -0
- package/dist/esm-node/cli/index.mjs +15 -5
- package/dist/esm-node/cli/tanstackTypes/source.mjs +3 -1
- package/dist/esm-node/runtime/basepathRewrite.mjs +10 -3
- package/dist/esm-node/runtime/lifecycle.mjs +1 -1
- package/dist/esm-node/runtime/plugin.mjs +1 -1
- package/dist/esm-node/runtime/plugin.node.mjs +5 -1
- package/dist/esm-node/runtime/prefetchLink.mjs +1 -6
- package/dist/esm-node/runtime/register.mjs +0 -2
- package/dist/esm-node/runtime/routeTree/construction.mjs +2 -0
- package/dist/esm-node/runtime/router.mjs +27 -11
- package/dist/esm-node/runtime/state.mjs +1 -1
- package/dist/esm-node/runtime/utils.mjs +2 -0
- package/dist/types/cli/index.d.ts +5 -5
- package/dist/types/cli/tanstackTypes/shared.d.ts +1 -1
- package/dist/types/cli/tanstackTypes.d.ts +3 -3
- package/dist/types/cli.d.ts +2 -2
- package/dist/types/runtime/basepathRewrite.d.ts +2 -1
- package/dist/types/runtime/dataMutation.d.ts +3 -3
- package/dist/types/runtime/index.d.ts +14 -14
- package/dist/types/runtime/lifecycle.d.ts +9 -2
- package/dist/types/runtime/loaderBridge.d.ts +2 -2
- package/dist/types/runtime/plugin.d.ts +2 -2
- package/dist/types/runtime/plugin.node.d.ts +2 -2
- package/dist/types/runtime/plugin.worker.d.ts +1 -1
- package/dist/types/runtime/pluginShared.d.ts +2 -2
- package/dist/types/runtime/register.d.ts +1 -9
- package/dist/types/runtime/routeTree/construction.d.ts +1 -1
- package/dist/types/runtime/routeTree/index.d.ts +2 -2
- package/dist/types/runtime/routeTree/loaders.d.ts +1 -1
- package/dist/types/runtime/routeTree/tanstackRoutes.d.ts +1 -1
- package/dist/types/runtime/router.d.ts +2 -13
- package/dist/types/runtime/rsc/CompositeComponent.d.ts +1 -1
- package/dist/types/runtime/rsc/RscNodeRenderer.d.ts +1 -1
- package/dist/types/runtime/rsc/client.d.ts +4 -4
- package/dist/types/runtime/rsc/createRscProxy.d.ts +1 -1
- package/dist/types/runtime/rsc/payloadFetch.d.ts +1 -1
- package/dist/types/runtime/rsc/payloadRouter.d.ts +2 -2
- package/dist/types/runtime/rsc/payloadStorage.d.ts +1 -1
- package/dist/types/runtime/rsc/server.d.ts +3 -3
- package/dist/types/runtime/rsc/shared.d.ts +1 -1
- package/dist/types/runtime/rsc/slotUsageSanitizer.d.ts +1 -1
- package/dist/types/runtime/ssrManagedTags.d.ts +1 -1
- package/dist/types/runtime/ssrPreload.d.ts +1 -1
- package/dist/types/runtime/state.d.ts +1 -1
- package/dist/types/runtime/submitAction.d.ts +1 -1
- package/dist/types/runtime/types.d.ts +2 -1
- package/dist/types/runtime/utils.d.ts +1 -1
- package/dist/types/runtime.d.ts +1 -1
- package/package.json +19 -16
- package/rstest.config.mts +1 -24
- package/src/cli/index.ts +10 -0
- package/src/cli/tanstackTypes/source.ts +3 -1
- package/src/runtime/basepathRewrite.ts +11 -2
- package/src/runtime/lifecycle.ts +14 -3
- package/src/runtime/plugin.node.tsx +9 -2
- package/src/runtime/plugin.tsx +5 -1
- package/src/runtime/prefetchLink.tsx +1 -23
- package/src/runtime/register.ts +1 -12
- package/src/runtime/routeTree/construction.ts +2 -0
- package/src/runtime/router.ts +25 -40
- package/src/runtime/state.ts +1 -1
- package/src/runtime/types.ts +2 -2
- package/src/runtime/utils.tsx +3 -1
- package/tests/router/cli.test.ts +148 -824
- package/tests/router/dataMutation.test.tsx +17 -85
- package/tests/router/flightSerialization.roundtrip.test.tsx +9 -6
- package/tests/router/generateRouteArtifacts.test.ts +68 -28
- package/tests/router/loaderBridge.test.ts +0 -25
- package/tests/router/localisedIdentity.test.tsx +95 -0
- package/tests/router/prefetchLink.test.tsx +17 -21
- package/tests/router/prefetchLinkPreload.test.tsx +11 -31
- package/tests/router/routeHooks.test.ts +41 -105
- package/tests/router/routeTree.test.ts +144 -836
- package/tests/router/rsc.test.tsx +131 -166
- package/tests/router/serverPlugin.test.ts +43 -1
- package/tests/router/tanstackTypes.test.ts +109 -973
- package/tests/realm-isolation.test.ts +0 -114
- package/tests/router/fastDefaults.test.ts +0 -32
- package/tests/router/fixtures/legacyRuntimeRouter.ts +0 -10
- package/tests/router/fixtures/rscDecoderSecurityChild.cjs +0 -162
- package/tests/router/hooks.test.ts +0 -40
- package/tests/router/hydrationBoundary.test.tsx +0 -23
- package/tests/router/packageSurface.test.ts +0 -24
- package/tests/router/preloadRedirect.test.ts +0 -64
- package/tests/router/register.test.ts +0 -8
- package/tests/router/routerCompatibility.test.ts +0 -239
- package/tests/router/rscDecoderSecurity.test.ts +0 -113
- package/tests/router/rscPayloadRouterMatrix.test.ts +0 -197
- /package/dist/esm/{rslib-runtime.mjs → rslib-runtime~1.mjs} +0 -0
- /package/dist/esm-node/{rslib-runtime.mjs → rslib-runtime~0.mjs} +0 -0
|
@@ -1,113 +1,49 @@
|
|
|
1
|
-
|
|
2
|
-
useChildMatches: [],
|
|
3
|
-
useMatch: [],
|
|
4
|
-
useMatches: [],
|
|
5
|
-
useParentMatches: [],
|
|
6
|
-
useRouterState: [],
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
rstest.mock('@tanstack/react-router', () => ({
|
|
10
|
-
useChildMatches: (options: unknown) => {
|
|
11
|
-
calls.useChildMatches.push(options);
|
|
12
|
-
return options;
|
|
13
|
-
},
|
|
14
|
-
useMatch: (options: unknown) => {
|
|
15
|
-
calls.useMatch.push(options);
|
|
16
|
-
return options;
|
|
17
|
-
},
|
|
18
|
-
useMatches: (options: unknown) => {
|
|
19
|
-
calls.useMatches.push(options);
|
|
20
|
-
return options;
|
|
21
|
-
},
|
|
22
|
-
useParentMatches: (options: unknown) => {
|
|
23
|
-
calls.useParentMatches.push(options);
|
|
24
|
-
return options;
|
|
25
|
-
},
|
|
26
|
-
useRouterState: (options: unknown) => {
|
|
27
|
-
calls.useRouterState.push(options);
|
|
28
|
-
return options;
|
|
29
|
-
},
|
|
30
|
-
}));
|
|
31
|
-
|
|
1
|
+
import { createMemoryHistory } from '@tanstack/history';
|
|
32
2
|
import {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
3
|
+
createRootRoute,
|
|
4
|
+
createRoute,
|
|
5
|
+
createRouter,
|
|
6
|
+
RouterProvider,
|
|
7
|
+
} from '@tanstack/react-router';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { renderToString } from 'react-dom/server';
|
|
10
|
+
import { useMatches } from '../../src/runtime/routeHooks';
|
|
11
|
+
|
|
12
|
+
function MatchIds() {
|
|
13
|
+
const matches = useMatches();
|
|
14
|
+
return React.createElement(
|
|
15
|
+
'output',
|
|
16
|
+
{ 'data-testid': 'route-ids' },
|
|
17
|
+
matches.map(match => match.routeId).join(','),
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
test('updates whole match objects after navigation with the structural-sharing guard', async () => {
|
|
22
|
+
const rootRoute = createRootRoute({ component: MatchIds });
|
|
23
|
+
const homeRoute = createRoute({
|
|
24
|
+
getParentRoute: () => rootRoute,
|
|
25
|
+
path: '/',
|
|
26
|
+
component: () => null,
|
|
50
27
|
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
useParentMatches();
|
|
56
|
-
useChildMatches();
|
|
57
|
-
useRouterState();
|
|
58
|
-
|
|
59
|
-
expect(getLastCall('useMatch')).toEqual({
|
|
60
|
-
from: '/',
|
|
61
|
-
structuralSharing: false,
|
|
62
|
-
});
|
|
63
|
-
expect(getLastCall('useMatches')).toEqual({
|
|
64
|
-
structuralSharing: false,
|
|
65
|
-
});
|
|
66
|
-
expect(getLastCall('useParentMatches')).toEqual({
|
|
67
|
-
structuralSharing: false,
|
|
68
|
-
});
|
|
69
|
-
expect(getLastCall('useChildMatches')).toEqual({
|
|
70
|
-
structuralSharing: false,
|
|
71
|
-
});
|
|
72
|
-
expect(getLastCall('useRouterState')).toEqual({
|
|
73
|
-
structuralSharing: false,
|
|
74
|
-
});
|
|
28
|
+
const settingsRoute = createRoute({
|
|
29
|
+
getParentRoute: () => rootRoute,
|
|
30
|
+
path: '/settings',
|
|
31
|
+
component: () => null,
|
|
75
32
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const matchesOptions = { select };
|
|
81
|
-
const stateOptions = { select };
|
|
82
|
-
|
|
83
|
-
useMatch(matchOptions as never);
|
|
84
|
-
useMatches(matchesOptions as never);
|
|
85
|
-
useParentMatches(matchesOptions as never);
|
|
86
|
-
useChildMatches(matchesOptions as never);
|
|
87
|
-
useRouterState(stateOptions as never);
|
|
88
|
-
|
|
89
|
-
expect(getLastCall('useMatch')).toBe(matchOptions);
|
|
90
|
-
expect(getLastCall('useMatches')).toBe(matchesOptions);
|
|
91
|
-
expect(getLastCall('useParentMatches')).toBe(matchesOptions);
|
|
92
|
-
expect(getLastCall('useChildMatches')).toBe(matchesOptions);
|
|
93
|
-
expect(getLastCall('useRouterState')).toBe(stateOptions);
|
|
33
|
+
const router = createRouter({
|
|
34
|
+
routeTree: rootRoute.addChildren([homeRoute, settingsRoute]),
|
|
35
|
+
history: createMemoryHistory({ initialEntries: ['/'] }),
|
|
36
|
+
defaultStructuralSharing: true,
|
|
94
37
|
});
|
|
95
38
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
39
|
+
await router.load();
|
|
40
|
+
expect(
|
|
41
|
+
renderToString(React.createElement(RouterProvider, { router })),
|
|
42
|
+
).toContain('__root__');
|
|
100
43
|
|
|
101
|
-
|
|
102
|
-
useMatches(enabled as never);
|
|
103
|
-
useParentMatches(disabled as never);
|
|
104
|
-
useChildMatches(enabled as never);
|
|
105
|
-
useRouterState(disabled as never);
|
|
44
|
+
await router.navigate({ to: '/settings' });
|
|
106
45
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
expect(getLastCall('useChildMatches')).toBe(enabled);
|
|
111
|
-
expect(getLastCall('useRouterState')).toBe(disabled);
|
|
112
|
-
});
|
|
46
|
+
expect(
|
|
47
|
+
renderToString(React.createElement(RouterProvider, { router })),
|
|
48
|
+
).toContain('/settings');
|
|
113
49
|
});
|