@bleedingdev/modern-js-plugin-tanstack 3.5.0-ultramodern.2 → 3.5.0-ultramodern.21
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.
|
@@ -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.21",
|
|
22
22
|
"engines": {
|
|
23
23
|
"node": ">=20"
|
|
24
24
|
},
|
|
@@ -77,13 +77,13 @@
|
|
|
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/
|
|
83
|
-
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.
|
|
80
|
+
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.5.0-ultramodern.21",
|
|
81
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.5.0-ultramodern.21",
|
|
82
|
+
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.5.0-ultramodern.21",
|
|
83
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.5.0-ultramodern.21"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
|
-
"@modern-js/runtime": "3.5.0-ultramodern.
|
|
86
|
+
"@modern-js/runtime": "3.5.0-ultramodern.21",
|
|
87
87
|
"react": "^19.2.7",
|
|
88
88
|
"react-dom": "^19.2.7"
|
|
89
89
|
},
|
|
@@ -98,9 +98,9 @@
|
|
|
98
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.
|
|
101
|
+
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.5.0-ultramodern.21",
|
|
102
102
|
"@scripts/rstest-config": "2.66.0",
|
|
103
|
-
"@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.5.0-ultramodern.
|
|
103
|
+
"@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.5.0-ultramodern.21"
|
|
104
104
|
},
|
|
105
105
|
"sideEffects": [
|
|
106
106
|
"./src/runtime/register.ts",
|
|
@@ -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,
|