@bleedingdev/modern-js-plugin-tanstack 3.5.0-ultramodern.99 → 3.8.1-ultramodern.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/dist/cjs/cli/index.js +10 -2
  2. package/dist/cjs/cli/tanstackTypes/source.js +9 -20
  3. package/dist/cjs/runtime/plugin.node.js +12 -5
  4. package/dist/cjs/runtime/pluginShared.js +3 -3
  5. package/dist/cjs/runtime/rsc/payloadErrors.js +2 -2
  6. package/dist/cjs/runtime/rsc/shared.js +1 -1
  7. package/dist/cjs/runtime/rsc/treeGetter.js +5 -9
  8. package/dist/cjs/runtime/submitAction.js +4 -5
  9. package/dist/esm/cli/index.mjs +10 -2
  10. package/dist/esm/cli/tanstackTypes/source.mjs +9 -10
  11. package/dist/esm/runtime/plugin.node.mjs +12 -5
  12. package/dist/esm/runtime/pluginShared.mjs +3 -3
  13. package/dist/esm/runtime/rsc/payloadErrors.mjs +1 -1
  14. package/dist/esm/runtime/rsc/shared.mjs +1 -1
  15. package/dist/esm/runtime/rsc/treeGetter.mjs +5 -9
  16. package/dist/esm/runtime/submitAction.mjs +4 -5
  17. package/dist/esm-node/cli/index.mjs +10 -2
  18. package/dist/esm-node/cli/tanstackTypes/source.mjs +9 -10
  19. package/dist/esm-node/runtime/plugin.node.mjs +12 -5
  20. package/dist/esm-node/runtime/pluginShared.mjs +3 -3
  21. package/dist/esm-node/runtime/rsc/payloadErrors.mjs +1 -1
  22. package/dist/esm-node/runtime/rsc/shared.mjs +1 -1
  23. package/dist/esm-node/runtime/rsc/treeGetter.mjs +5 -9
  24. package/dist/esm-node/runtime/submitAction.mjs +4 -5
  25. package/dist/types/runtime/clientHydration.d.ts +1 -1
  26. package/dist/types/runtime/ssrTypes.d.ts +0 -2
  27. package/package.json +27 -20
  28. package/rstest.config.mts +2 -0
  29. package/src/cli/index.ts +12 -0
  30. package/src/cli/tanstackTypes/canonicalRoutes.ts +0 -1
  31. package/src/cli/tanstackTypes/shared.ts +0 -1
  32. package/src/cli/tanstackTypes/source.ts +3 -4
  33. package/src/runtime/plugin.node.tsx +17 -11
  34. package/src/runtime/plugin.tsx +0 -2
  35. package/src/runtime/pluginShared.ts +8 -7
  36. package/src/runtime/rsc/payloadErrors.ts +1 -1
  37. package/src/runtime/rsc/shared.ts +1 -1
  38. package/src/runtime/rsc/treeGetter.tsx +9 -8
  39. package/src/runtime/ssrManagedTags.ts +0 -2
  40. package/src/runtime/ssrTypes.ts +0 -4
  41. package/src/runtime/submitAction.ts +6 -11
  42. package/src/types/react-server-dom-rspack.d.ts +4 -52
  43. package/tests/router/cli.test.ts +204 -96
  44. package/tests/router/clientHydration.test.tsx +140 -1
  45. package/tests/router/dataMutation.test.tsx +50 -9
  46. package/tests/router/fixtures/rscDecoderSecurityChild.cjs +162 -0
  47. package/tests/router/preloadRedirect.test.ts +3 -8
  48. package/tests/router/routeTree.test.ts +73 -19
  49. package/tests/router/routerCompatibility.test.ts +0 -6
  50. package/tests/router/rscDecoderSecurity.test.ts +113 -0
  51. package/tests/router/serverPlugin.test.ts +115 -0
  52. package/tests/router/tanstackTypes.test.ts +668 -356
  53. package/src/runtime/ssr-shim.d.ts +0 -10
  54. package/tests/castRatchet.test.ts +0 -85
  55. package/tests/router/fixtures/router-gen.golden.txt +0 -71
@@ -1,10 +0,0 @@
1
- declare module '@tanstack/react-router/ssr/client' {
2
- export function hydrate(router: unknown): Promise<unknown>;
3
- }
4
-
5
- declare module '@tanstack/react-router/ssr/server' {
6
- export function attachRouterServerSsrUtils(opts: {
7
- router: unknown;
8
- manifest?: unknown;
9
- }): void;
10
- }
@@ -1,85 +0,0 @@
1
- import { readdirSync, readFileSync } from 'node:fs';
2
- import path from 'node:path';
3
-
4
- const SRC_DIR = path.join(__dirname, '../src');
5
- const CAST_RATCHET_BASELINE = 40;
6
- const CAST_PATTERN = /\bas\s+unknown\s+as\b|\bas\s+any\b/g;
7
- const SOURCE_FILE_PATTERN = /\.(?:ts|tsx)$/u;
8
-
9
- type CastLocation = {
10
- cast: string;
11
- columnNumber: number;
12
- filePath: string;
13
- lineNumber: number;
14
- sourceLine: string;
15
- };
16
-
17
- const collectSourceFiles = (directory: string): string[] => {
18
- const entries = readdirSync(directory, { withFileTypes: true }).sort((a, b) =>
19
- a.name.localeCompare(b.name),
20
- );
21
-
22
- return entries.flatMap(entry => {
23
- const entryPath = path.join(directory, entry.name);
24
-
25
- if (entry.isDirectory()) {
26
- return collectSourceFiles(entryPath);
27
- }
28
-
29
- return SOURCE_FILE_PATTERN.test(entry.name) ? [entryPath] : [];
30
- });
31
- };
32
-
33
- const collectCastLocations = (): CastLocation[] =>
34
- collectSourceFiles(SRC_DIR).flatMap(filePath => {
35
- const relativeFilePath = path
36
- .relative(SRC_DIR, filePath)
37
- .split(path.sep)
38
- .join('/');
39
- const lines = readFileSync(filePath, 'utf-8').split(/\r?\n/u);
40
- const locations: CastLocation[] = [];
41
-
42
- lines.forEach((sourceLine, index) => {
43
- CAST_PATTERN.lastIndex = 0;
44
-
45
- let match: RegExpExecArray | null;
46
- while ((match = CAST_PATTERN.exec(sourceLine))) {
47
- locations.push({
48
- cast: match[0],
49
- columnNumber: match.index + 1,
50
- filePath: relativeFilePath,
51
- lineNumber: index + 1,
52
- sourceLine: sourceLine.trim(),
53
- });
54
- }
55
- });
56
-
57
- return locations;
58
- });
59
-
60
- const formatCastLocations = (locations: CastLocation[]): string =>
61
- locations
62
- .map(
63
- location =>
64
- ` ${location.filePath}:${location.lineNumber}:${location.columnNumber} ${location.cast} :: ${location.sourceLine}`,
65
- )
66
- .join('\n');
67
-
68
- describe('tanstack unsafe cast ratchet', () => {
69
- test('does not add new as-any casts in src', () => {
70
- const castLocations = collectCastLocations();
71
-
72
- if (castLocations.length > CAST_RATCHET_BASELINE) {
73
- throw new Error(
74
- [
75
- `Expected at most ${CAST_RATCHET_BASELINE} unsafe casts in plugin-tanstack src, found ${castLocations.length}.`,
76
- 'Remove the new cast or lower the ratchet baseline after deleting existing casts.',
77
- 'Current cast locations:',
78
- formatCastLocations(castLocations),
79
- ].join('\n'),
80
- );
81
- }
82
-
83
- expect(castLocations.length).toBeLessThanOrEqual(CAST_RATCHET_BASELINE);
84
- });
85
- });
@@ -1,71 +0,0 @@
1
- // This file is auto-generated by Modern.js. Do not edit manually.
2
-
3
- import {
4
- createMemoryHistory,
5
- createRootRouteWithContext,
6
- createRoute,
7
- createRouter,
8
- createRouteStaticData,
9
- type ModernRouterContext,
10
- modernLoaderToTanstack,
11
- modernTanstackRouterFastDefaults,
12
- } from '@modern-js/plugin-tanstack/runtime';
13
-
14
- import component_0 from "../../routes/(app)/layout";
15
- import { loader as loader_0, action as action_0 } from "../../routes/(app)/users/(userId)/page.data";
16
- import { validateSearch as validateSearch_0 } from "../../routes/search.contract";
17
- import { loaderDeps as loaderDeps_0 } from "../../routes/search.contract";
18
- import component_1 from "../../routes/(app)/users/(userId)/page";
19
- import component_2 from "../../routes/(app)/docs/splat";
20
-
21
- export const rootRoute = createRootRouteWithContext<ModernRouterContext>()({
22
-
23
- staticData: createRouteStaticData({
24
- modernRouteId: "layout",
25
- }),
26
- });
27
-
28
- const route__app__layout__base = createRoute({
29
- getParentRoute: () => rootRoute,
30
- component: component_0,
31
- id: "(app)/layout",
32
- staticData: createRouteStaticData({
33
- modernRouteId: "(app)/layout",
34
- }),
35
- });
36
-
37
- const route__app__users__userId__page = createRoute({
38
- getParentRoute: () => route__app__layout__base,
39
- component: component_1,
40
- path: "users/$userId",
41
- loader: modernLoaderToTanstack({ hasSplat: false }, loader_0),
42
- validateSearch: validateSearch_0,
43
- loaderDeps: loaderDeps_0,
44
- staticData: createRouteStaticData({
45
- modernRouteId: "(app)/users/(userId)/page",
46
- modernRouteLoader: loader_0,
47
- modernRouteAction: action_0,
48
- }),
49
- });
50
-
51
- const route__app__docs_splat_page = createRoute({
52
- getParentRoute: () => route__app__layout__base,
53
- component: component_2,
54
- path: "docs/$",
55
- staticData: createRouteStaticData({
56
- modernRouteId: "(app)/docs/splat/page",
57
- }),
58
- });
59
-
60
- const route__app__layout = route__app__layout__base.addChildren([route__app__users__userId__page, route__app__docs_splat_page]);
61
-
62
- export const routeTree = rootRoute.addChildren([route__app__layout]);
63
-
64
- export const router = createRouter({
65
- ...modernTanstackRouterFastDefaults,
66
- routeTree,
67
- history: createMemoryHistory({
68
- initialEntries: ['/'],
69
- }),
70
- context: {} as ModernRouterContext,
71
- });