@bleedingdev/modern-js-plugin-tanstack 3.5.0-ultramodern.1 → 3.5.0-ultramodern.11
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/esm-node/cli/index.mjs +2 -2
- package/dist/types/runtime/pluginCore.d.ts +14 -10
- package/dist/types/runtime/types.d.ts +42 -4
- package/dist/types/runtime/utils.d.ts +4 -3
- package/package.json +10 -10
- package/src/runtime/pluginCore.ts +23 -15
- package/src/runtime/types.ts +46 -16
- package/src/runtime/utils.tsx +5 -3
|
@@ -6,13 +6,13 @@ import { collectCanonicalRoutesForEntry, generateTanstackRouterTypesSourceForEnt
|
|
|
6
6
|
import { __webpack_require__ } from "../rslib-runtime.mjs";
|
|
7
7
|
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
8
8
|
import { dirname as __rspack_dirname } from "node:path";
|
|
9
|
+
var __rspack_import_meta_dirname__ = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
9
10
|
import * as __rspack_external__modern_js_runtime_cli_401ee077 from "@modern-js/runtime/cli";
|
|
10
11
|
__webpack_require__.add({
|
|
11
12
|
"@modern-js/runtime/cli?9b14" (module) {
|
|
12
13
|
module.exports = __rspack_external__modern_js_runtime_cli_401ee077;
|
|
13
14
|
}
|
|
14
15
|
});
|
|
15
|
-
var cli_dirname = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
16
16
|
const DEFAULT_ROUTES_DIR = 'routes';
|
|
17
17
|
const DEFAULT_GENERATED_DIR_NAME = 'modern-tanstack';
|
|
18
18
|
const ENTRYPOINTS_KEY = '@modern-js/plugin-tanstack';
|
|
@@ -172,7 +172,7 @@ function tanstackRouterPlugin(options = {}) {
|
|
|
172
172
|
/[\\/]node_modules[\\/]@tanstack[\\/]react-router[\\/]/,
|
|
173
173
|
/[\\/]node_modules[\\/]@tanstack[\\/]router-core[\\/]/,
|
|
174
174
|
/[\\/]node_modules[\\/]@tanstack[\\/]react-store[\\/]/,
|
|
175
|
-
node_path.resolve(
|
|
175
|
+
node_path.resolve(__rspack_import_meta_dirname__, '..', '..')
|
|
176
176
|
]
|
|
177
177
|
}
|
|
178
178
|
}));
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { Plugin, RuntimePluginExtends } from '@modern-js/plugin';
|
|
2
|
-
import type { RuntimePluginAPI } from '@modern-js/plugin/runtime';
|
|
3
1
|
import { type TInternalRuntimeContext } from '@modern-js/runtime/context';
|
|
4
2
|
import type { RouterExtendsHooks } from './hooks';
|
|
5
3
|
import type { RouterConfig } from './types';
|
|
@@ -8,14 +6,20 @@ export type TanstackRouterRuntimeConfig = {
|
|
|
8
6
|
router?: Partial<RouterConfig>;
|
|
9
7
|
[key: string]: unknown;
|
|
10
8
|
};
|
|
11
|
-
type
|
|
12
|
-
|
|
9
|
+
type RuntimeInterrupt = (value?: unknown) => unknown;
|
|
10
|
+
export type TanstackRouterPluginAPI = {
|
|
11
|
+
getRuntimeConfig: () => TanstackRouterRuntimeConfig;
|
|
12
|
+
getHooks: () => RouterExtendsHooks;
|
|
13
|
+
onBeforeRender: (listener: (context: TInternalRuntimeContext, interrupt: RuntimeInterrupt) => unknown) => void;
|
|
14
|
+
wrapRoot: (listener: (App: any) => any) => void;
|
|
15
|
+
[key: string]: any;
|
|
13
16
|
};
|
|
14
|
-
export type
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
globalApp: import("react").ComponentClass<{}, any> | import("react").FunctionComponent<{}> | undefined;
|
|
17
|
+
export type TanstackRouterRuntimePlugin = {
|
|
18
|
+
name?: string;
|
|
19
|
+
registryHooks?: RouterExtendsHooks;
|
|
20
|
+
setup?: (api: TanstackRouterPluginAPI) => unknown;
|
|
21
|
+
[key: string]: unknown;
|
|
20
22
|
};
|
|
23
|
+
export declare function getMergedRouterConfig(api: TanstackRouterPluginAPI, userConfig: Partial<RouterConfig>): RouterConfig;
|
|
24
|
+
export declare function getFinalRouteConfig(mergedConfig: RouterConfig): RouterConfig['routesConfig'];
|
|
21
25
|
export {};
|
|
@@ -1,8 +1,46 @@
|
|
|
1
|
-
import type { RouterFramework } from '@modern-js/runtime/context';
|
|
2
1
|
import type { RouteObject } from '@modern-js/runtime-utils/router';
|
|
3
|
-
import type { NestedRoute, PageRoute } from '@modern-js/types';
|
|
4
2
|
import type React from 'react';
|
|
5
|
-
export type
|
|
3
|
+
export type BuiltInRouterFramework = 'react-router' | 'tanstack';
|
|
4
|
+
export type RouterFramework = BuiltInRouterFramework | (string & {});
|
|
5
|
+
export type ModernRoute = {
|
|
6
|
+
type: 'nested' | 'page';
|
|
7
|
+
path?: string;
|
|
8
|
+
id?: string;
|
|
9
|
+
component?: React.ComponentType | string;
|
|
10
|
+
children?: ModernRoute[];
|
|
11
|
+
[key: string]: any;
|
|
12
|
+
};
|
|
13
|
+
export type RouterRouteMatchSnapshot = {
|
|
14
|
+
routeId: string;
|
|
15
|
+
assetRouteId?: string;
|
|
16
|
+
pathname?: string;
|
|
17
|
+
params?: Record<string, string>;
|
|
18
|
+
};
|
|
19
|
+
export type InternalRouterServerSnapshot = {
|
|
20
|
+
framework?: RouterFramework;
|
|
21
|
+
basename?: string;
|
|
22
|
+
statusCode?: number;
|
|
23
|
+
errors?: Record<string, unknown>;
|
|
24
|
+
routerData?: {
|
|
25
|
+
loaderData?: Record<string, unknown>;
|
|
26
|
+
errors?: Record<string, unknown>;
|
|
27
|
+
};
|
|
28
|
+
hydrationScript?: string;
|
|
29
|
+
hydrationScripts?: string[];
|
|
30
|
+
matchedRouteIds?: string[];
|
|
31
|
+
matches?: RouterRouteMatchSnapshot[];
|
|
32
|
+
};
|
|
33
|
+
export type InternalRouterRuntimeState = {
|
|
34
|
+
framework: RouterFramework;
|
|
35
|
+
basename?: string;
|
|
36
|
+
instance?: unknown;
|
|
37
|
+
hydrationScript?: string;
|
|
38
|
+
hydrationScripts?: string[];
|
|
39
|
+
matchedRouteIds?: string[];
|
|
40
|
+
matches?: RouterRouteMatchSnapshot[];
|
|
41
|
+
serverSnapshot?: InternalRouterServerSnapshot;
|
|
42
|
+
cleanup?: () => void | Promise<void>;
|
|
43
|
+
};
|
|
6
44
|
/**
|
|
7
45
|
* TanStack-specific router config. Unlike the react-router provider config,
|
|
8
46
|
* this intentionally has no `oldVersion`/`future` fields — those are
|
|
@@ -12,7 +50,7 @@ export type RouterConfig = {
|
|
|
12
50
|
framework?: RouterFramework;
|
|
13
51
|
routesConfig: {
|
|
14
52
|
globalApp?: React.ComponentType<any>;
|
|
15
|
-
routes?:
|
|
53
|
+
routes?: ModernRoute[];
|
|
16
54
|
};
|
|
17
55
|
serverBase?: string[];
|
|
18
56
|
supportHtml5History?: boolean;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { RouteObject } from '@modern-js/runtime-utils/router';
|
|
2
|
-
import type { NestedRoute, PageRoute, SSRMode } from '@modern-js/types';
|
|
3
2
|
import React from 'react';
|
|
3
|
+
import type { ModernRoute } from './types';
|
|
4
|
+
export type SSRMode = 'string' | 'stream';
|
|
4
5
|
type RouterConfig = {
|
|
5
6
|
routesConfig: {
|
|
6
7
|
globalApp?: React.ComponentType<any>;
|
|
7
|
-
routes?:
|
|
8
|
+
routes?: ModernRoute[];
|
|
8
9
|
};
|
|
9
10
|
};
|
|
10
11
|
type GlobalAppProps = {
|
|
@@ -21,7 +22,7 @@ export type ModernRouteObject = RouteObject & {
|
|
|
21
22
|
default: React.ComponentType;
|
|
22
23
|
}>;
|
|
23
24
|
};
|
|
24
|
-
export declare function getRouteObjects(routes:
|
|
25
|
+
export declare function getRouteObjects(routes: ModernRoute[], { globalApp, ssrMode, props, }: {
|
|
25
26
|
globalApp?: React.ComponentType<GlobalAppProps>;
|
|
26
27
|
ssrMode?: SSRMode;
|
|
27
28
|
props?: Record<string, unknown>;
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"modern.js",
|
|
19
19
|
"tanstack-router"
|
|
20
20
|
],
|
|
21
|
-
"version": "3.5.0-ultramodern.
|
|
21
|
+
"version": "3.5.0-ultramodern.11",
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=20"
|
|
24
24
|
},
|
|
@@ -77,29 +77,29 @@
|
|
|
77
77
|
"@swc/helpers": "^0.5.23",
|
|
78
78
|
"@tanstack/react-router": "1.170.16",
|
|
79
79
|
"@tanstack/router-core": "1.171.13",
|
|
80
|
-
"@modern-js/
|
|
81
|
-
"@modern-js/
|
|
82
|
-
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.5.0-ultramodern.
|
|
83
|
-
"@modern-js/
|
|
80
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.11",
|
|
81
|
+
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.5.0-ultramodern.11",
|
|
82
|
+
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.5.0-ultramodern.11",
|
|
83
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.11"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
|
-
"@modern-js/runtime": "3.5.0-ultramodern.
|
|
86
|
+
"@modern-js/runtime": "3.5.0-ultramodern.11",
|
|
87
87
|
"react": "^19.2.7",
|
|
88
88
|
"react-dom": "^19.2.7"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
|
-
"@rslib/core": "0.23.
|
|
91
|
+
"@rslib/core": "0.23.1",
|
|
92
92
|
"@tanstack/history": "1.162.0",
|
|
93
93
|
"@testing-library/dom": "^10.4.1",
|
|
94
94
|
"@testing-library/react": "^16.3.2",
|
|
95
95
|
"@types/node": "^26.0.1",
|
|
96
96
|
"@types/react": "^19.2.17",
|
|
97
97
|
"@types/react-dom": "^19.2.3",
|
|
98
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
98
|
+
"@typescript/native-preview": "7.0.0-dev.20260628.1",
|
|
99
99
|
"react": "^19.2.7",
|
|
100
100
|
"react-dom": "^19.2.7",
|
|
101
|
-
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.5.0-ultramodern.
|
|
102
|
-
"@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.5.0-ultramodern.
|
|
101
|
+
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.5.0-ultramodern.11",
|
|
102
|
+
"@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.5.0-ultramodern.11",
|
|
103
103
|
"@scripts/rstest-config": "2.66.0"
|
|
104
104
|
},
|
|
105
105
|
"sideEffects": [
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { Plugin, RuntimePluginExtends } from '@modern-js/plugin';
|
|
2
|
-
import type { RuntimePluginAPI } from '@modern-js/plugin/runtime';
|
|
3
1
|
import {
|
|
4
2
|
getGlobalLayoutApp,
|
|
5
3
|
getGlobalRoutes,
|
|
@@ -15,19 +13,27 @@ export type TanstackRouterRuntimeConfig = {
|
|
|
15
13
|
[key: string]: unknown;
|
|
16
14
|
};
|
|
17
15
|
|
|
18
|
-
type
|
|
19
|
-
RuntimePluginExtends<TanstackRouterRuntimeConfig, TInternalRuntimeContext>
|
|
20
|
-
> & {
|
|
21
|
-
extendHooks: RouterExtendsHooks;
|
|
22
|
-
};
|
|
16
|
+
type RuntimeInterrupt = (value?: unknown) => unknown;
|
|
23
17
|
|
|
24
|
-
export type TanstackRouterPluginAPI =
|
|
25
|
-
|
|
18
|
+
export type TanstackRouterPluginAPI = {
|
|
19
|
+
getRuntimeConfig: () => TanstackRouterRuntimeConfig;
|
|
20
|
+
getHooks: () => RouterExtendsHooks;
|
|
21
|
+
onBeforeRender: (
|
|
22
|
+
listener: (
|
|
23
|
+
context: TInternalRuntimeContext,
|
|
24
|
+
interrupt: RuntimeInterrupt,
|
|
25
|
+
) => unknown,
|
|
26
|
+
) => void;
|
|
27
|
+
wrapRoot: (listener: (App: any) => any) => void;
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
};
|
|
26
30
|
|
|
27
|
-
export type TanstackRouterRuntimePlugin =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
+
export type TanstackRouterRuntimePlugin = {
|
|
32
|
+
name?: string;
|
|
33
|
+
registryHooks?: RouterExtendsHooks;
|
|
34
|
+
setup?: (api: TanstackRouterPluginAPI) => unknown;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
};
|
|
31
37
|
|
|
32
38
|
export function getMergedRouterConfig(
|
|
33
39
|
api: TanstackRouterPluginAPI,
|
|
@@ -39,9 +45,11 @@ export function getMergedRouterConfig(
|
|
|
39
45
|
return merge(pluginConfig.router || {}, userConfig) as RouterConfig;
|
|
40
46
|
}
|
|
41
47
|
|
|
42
|
-
export function getFinalRouteConfig(
|
|
48
|
+
export function getFinalRouteConfig(
|
|
49
|
+
mergedConfig: RouterConfig,
|
|
50
|
+
): RouterConfig['routesConfig'] {
|
|
43
51
|
return {
|
|
44
|
-
routes: getGlobalRoutes(),
|
|
52
|
+
routes: getGlobalRoutes() as RouterConfig['routesConfig']['routes'],
|
|
45
53
|
globalApp: getGlobalLayoutApp(),
|
|
46
54
|
...mergedConfig.routesConfig,
|
|
47
55
|
};
|
package/src/runtime/types.ts
CHANGED
|
@@ -1,21 +1,51 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
RouterFramework,
|
|
3
|
-
// The router runtime state types are owned by @modern-js/runtime; they are
|
|
4
|
-
// imported through the `/context` seam instead of being copied here so
|
|
5
|
-
// upstream fixes propagate to this package automatically.
|
|
6
|
-
} from '@modern-js/runtime/context';
|
|
7
1
|
import type { RouteObject } from '@modern-js/runtime-utils/router';
|
|
8
|
-
import type { NestedRoute, PageRoute } from '@modern-js/types';
|
|
9
2
|
import type React from 'react';
|
|
10
3
|
|
|
11
|
-
export type
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
export type BuiltInRouterFramework = 'react-router' | 'tanstack';
|
|
5
|
+
export type RouterFramework = BuiltInRouterFramework | (string & {});
|
|
6
|
+
|
|
7
|
+
export type ModernRoute = {
|
|
8
|
+
type: 'nested' | 'page';
|
|
9
|
+
path?: string;
|
|
10
|
+
id?: string;
|
|
11
|
+
component?: React.ComponentType | string;
|
|
12
|
+
children?: ModernRoute[];
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export type RouterRouteMatchSnapshot = {
|
|
17
|
+
routeId: string;
|
|
18
|
+
assetRouteId?: string;
|
|
19
|
+
pathname?: string;
|
|
20
|
+
params?: Record<string, string>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export type InternalRouterServerSnapshot = {
|
|
24
|
+
framework?: RouterFramework;
|
|
25
|
+
basename?: string;
|
|
26
|
+
statusCode?: number;
|
|
27
|
+
errors?: Record<string, unknown>;
|
|
28
|
+
routerData?: {
|
|
29
|
+
loaderData?: Record<string, unknown>;
|
|
30
|
+
errors?: Record<string, unknown>;
|
|
31
|
+
};
|
|
32
|
+
hydrationScript?: string;
|
|
33
|
+
hydrationScripts?: string[];
|
|
34
|
+
matchedRouteIds?: string[];
|
|
35
|
+
matches?: RouterRouteMatchSnapshot[];
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type InternalRouterRuntimeState = {
|
|
39
|
+
framework: RouterFramework;
|
|
40
|
+
basename?: string;
|
|
41
|
+
instance?: unknown;
|
|
42
|
+
hydrationScript?: string;
|
|
43
|
+
hydrationScripts?: string[];
|
|
44
|
+
matchedRouteIds?: string[];
|
|
45
|
+
matches?: RouterRouteMatchSnapshot[];
|
|
46
|
+
serverSnapshot?: InternalRouterServerSnapshot;
|
|
47
|
+
cleanup?: () => void | Promise<void>;
|
|
48
|
+
};
|
|
19
49
|
|
|
20
50
|
/**
|
|
21
51
|
* TanStack-specific router config. Unlike the react-router provider config,
|
|
@@ -26,7 +56,7 @@ export type RouterConfig = {
|
|
|
26
56
|
framework?: RouterFramework;
|
|
27
57
|
routesConfig: {
|
|
28
58
|
globalApp?: React.ComponentType<any>;
|
|
29
|
-
routes?:
|
|
59
|
+
routes?: ModernRoute[];
|
|
30
60
|
};
|
|
31
61
|
serverBase?: string[];
|
|
32
62
|
supportHtml5History?: boolean;
|
package/src/runtime/utils.tsx
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
// @effect-diagnostics strictBooleanExpressions:off
|
|
2
2
|
import type { RouteObject } from '@modern-js/runtime-utils/router';
|
|
3
|
-
import type { NestedRoute, PageRoute, SSRMode } from '@modern-js/types';
|
|
4
3
|
import React from 'react';
|
|
4
|
+
import type { ModernRoute } from './types';
|
|
5
|
+
|
|
6
|
+
export type SSRMode = 'string' | 'stream';
|
|
5
7
|
|
|
6
8
|
type RouterConfig = {
|
|
7
9
|
routesConfig: {
|
|
8
10
|
globalApp?: React.ComponentType<any>;
|
|
9
|
-
routes?:
|
|
11
|
+
routes?: ModernRoute[];
|
|
10
12
|
};
|
|
11
13
|
};
|
|
12
14
|
|
|
@@ -29,7 +31,7 @@ export type ModernRouteObject = RouteObject & {
|
|
|
29
31
|
};
|
|
30
32
|
|
|
31
33
|
export function getRouteObjects(
|
|
32
|
-
routes:
|
|
34
|
+
routes: ModernRoute[],
|
|
33
35
|
{
|
|
34
36
|
globalApp,
|
|
35
37
|
ssrMode,
|