@bleedingdev/modern-js-plugin-tanstack 3.8.1-ultramodern.1 → 3.8.1-ultramodern.3
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/tanstackTypes/shared.js +8 -6
- package/dist/cjs/runtime/clientHydration.js +2 -2
- package/dist/cjs/runtime/loaderBridge.js +11 -8
- package/dist/cjs/runtime/plugin.js +6 -7
- package/dist/cjs/runtime/plugin.node.js +5 -6
- package/dist/cjs/runtime/pluginShared.js +2 -3
- package/dist/cjs/runtime/routeTree/components.js +1 -1
- package/dist/cjs/runtime/routeTree/construction.js +4 -3
- package/dist/cjs/runtime/routeTree/loaders.js +7 -43
- package/dist/cjs/runtime/routeTree/staticData.js +0 -16
- package/dist/cjs/runtime/rsc/client.js +2 -6
- package/dist/cjs/runtime/rsc/server.js +2 -6
- package/dist/cjs/runtime/submitAction.js +3 -12
- package/dist/cjs/runtime/utils.js +2 -7
- package/dist/cjs/{runtime/rsc/index.js → shared/routeStaticData.js} +6 -10
- package/dist/esm/cli/tanstackTypes/shared.mjs +8 -6
- package/dist/esm/runtime/clientHydration.mjs +1 -1
- package/dist/esm/runtime/loaderBridge.mjs +2 -8
- package/dist/esm/runtime/plugin.mjs +5 -6
- package/dist/esm/runtime/plugin.node.mjs +3 -4
- package/dist/esm/runtime/pluginShared.mjs +2 -3
- package/dist/esm/runtime/routeTree/components.mjs +1 -1
- package/dist/esm/runtime/routeTree/construction.mjs +3 -2
- package/dist/esm/runtime/routeTree/loaders.mjs +8 -44
- package/dist/esm/runtime/routeTree/staticData.mjs +1 -14
- package/dist/esm/runtime/rsc/client.mjs +1 -2
- package/dist/esm/runtime/rsc/server.mjs +1 -2
- package/dist/esm/runtime/submitAction.mjs +1 -10
- package/dist/esm/runtime/utils.mjs +2 -7
- package/dist/esm/shared/routeStaticData.mjs +4 -0
- package/dist/esm-node/cli/tanstackTypes/shared.mjs +8 -6
- package/dist/esm-node/runtime/clientHydration.mjs +1 -1
- package/dist/esm-node/runtime/loaderBridge.mjs +2 -8
- package/dist/esm-node/runtime/plugin.mjs +5 -6
- package/dist/esm-node/runtime/plugin.node.mjs +3 -4
- package/dist/esm-node/runtime/pluginShared.mjs +2 -3
- package/dist/esm-node/runtime/routeTree/components.mjs +1 -1
- package/dist/esm-node/runtime/routeTree/construction.mjs +3 -2
- package/dist/esm-node/runtime/routeTree/loaders.mjs +8 -44
- package/dist/esm-node/runtime/routeTree/staticData.mjs +1 -14
- package/dist/esm-node/runtime/rsc/client.mjs +1 -2
- package/dist/esm-node/runtime/rsc/server.mjs +1 -2
- package/dist/esm-node/runtime/submitAction.mjs +1 -10
- package/dist/esm-node/runtime/utils.mjs +2 -7
- package/dist/esm-node/shared/routeStaticData.mjs +5 -0
- package/dist/types/runtime/loaderBridge.d.ts +17 -13
- package/dist/types/runtime/pluginShared.d.ts +1 -3
- package/dist/types/runtime/routeTree/components.d.ts +1 -2
- package/dist/types/runtime/routeTree/staticData.d.ts +2 -14
- package/dist/types/runtime/rsc/client.d.ts +0 -1
- package/dist/types/runtime/rsc/server.d.ts +0 -1
- package/dist/types/runtime/utils.d.ts +0 -3
- package/dist/types/shared/routeStaticData.d.ts +1 -0
- package/package.json +9 -9
- package/src/cli/tanstackTypes/shared.ts +13 -21
- package/src/runtime/loaderBridge.ts +5 -38
- package/src/runtime/plugin.node.tsx +2 -3
- package/src/runtime/plugin.tsx +4 -5
- package/src/runtime/pluginShared.ts +1 -4
- package/src/runtime/routeTree/components.ts +2 -5
- package/src/runtime/routeTree/construction.ts +3 -2
- package/src/runtime/routeTree/loaders.ts +13 -77
- package/src/runtime/routeTree/staticData.ts +2 -53
- package/src/runtime/rsc/client.tsx +0 -2
- package/src/runtime/rsc/server.tsx +0 -2
- package/src/runtime/submitAction.ts +1 -7
- package/src/runtime/utils.tsx +2 -12
- package/src/shared/routeStaticData.ts +7 -0
- package/tests/router/cli.test.ts +3 -1
- package/dist/cjs/runtime/routeTree.js +0 -46
- package/dist/esm/runtime/routeTree.mjs +0 -1
- package/dist/esm/runtime/rsc/index.mjs +0 -1
- package/dist/esm-node/runtime/routeTree.mjs +0 -2
- package/dist/esm-node/runtime/rsc/index.mjs +0 -2
- package/dist/types/runtime/routeTree.d.ts +0 -1
- package/dist/types/runtime/rsc/index.d.ts +0 -2
- package/src/runtime/routeTree.ts +0 -7
- package/src/runtime/rsc/index.ts +0 -10
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// @effect-diagnostics asyncFunction:off strictBooleanExpressions:off
|
|
2
2
|
|
|
3
3
|
export function mergeModernRouteHandle(route: {
|
|
4
|
-
config?:
|
|
4
|
+
config?: unknown;
|
|
5
5
|
handle?: Record<string, unknown>;
|
|
6
|
+
[key: string]: unknown;
|
|
6
7
|
}) {
|
|
7
8
|
const config = route.config as { handle?: Record<string, unknown> } | null;
|
|
8
9
|
const handle = {
|
|
@@ -12,55 +13,3 @@ export function mergeModernRouteHandle(route: {
|
|
|
12
13
|
|
|
13
14
|
return Object.keys(handle).length > 0 ? handle : undefined;
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
export function createRouteStaticData(opts: {
|
|
17
|
-
modernRouteId?: string;
|
|
18
|
-
modernRouteAction?: unknown;
|
|
19
|
-
modernRouteHandle?: unknown;
|
|
20
|
-
modernRouteHasAction?: boolean;
|
|
21
|
-
modernRouteHasClientLoader?: boolean;
|
|
22
|
-
modernRouteHasLoader?: boolean;
|
|
23
|
-
modernRouteIsClientComponent?: boolean;
|
|
24
|
-
modernRouteLoader?: unknown;
|
|
25
|
-
modernRouteShouldRevalidate?: unknown;
|
|
26
|
-
}) {
|
|
27
|
-
const staticData: Record<string, unknown> = {};
|
|
28
|
-
|
|
29
|
-
if (opts.modernRouteId) {
|
|
30
|
-
staticData.modernRouteId = opts.modernRouteId;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
if (opts.modernRouteAction) {
|
|
34
|
-
staticData.modernRouteAction = opts.modernRouteAction;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (opts.modernRouteHandle) {
|
|
38
|
-
staticData.modernRouteHandle = opts.modernRouteHandle;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (opts.modernRouteHasAction) {
|
|
42
|
-
staticData.modernRouteHasAction = true;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (opts.modernRouteHasClientLoader) {
|
|
46
|
-
staticData.modernRouteHasClientLoader = true;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
if (opts.modernRouteHasLoader) {
|
|
50
|
-
staticData.modernRouteHasLoader = true;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
if (opts.modernRouteIsClientComponent) {
|
|
54
|
-
staticData.modernRouteIsClientComponent = true;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (opts.modernRouteLoader) {
|
|
58
|
-
staticData.modernRouteLoader = opts.modernRouteLoader;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (opts.modernRouteShouldRevalidate) {
|
|
62
|
-
staticData.modernRouteShouldRevalidate = opts.modernRouteShouldRevalidate;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return Object.keys(staticData).length > 0 ? staticData : undefined;
|
|
66
|
-
}
|
|
@@ -188,8 +188,6 @@ export function getTanstackRscSerializationAdapters() {
|
|
|
188
188
|
return [adapter];
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
export const rscSerializationAdapter = getTanstackRscSerializationAdapters;
|
|
192
|
-
|
|
193
191
|
function createReadableStreamEmitter<T>(): SlotEmitter<T> {
|
|
194
192
|
let closed = false;
|
|
195
193
|
const queue: T[] = [];
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
formDataToUrlSearchParams,
|
|
7
7
|
toFormData,
|
|
8
8
|
} from './formData';
|
|
9
|
+
import { isRedirectResponse } from './loaderBridge';
|
|
9
10
|
|
|
10
11
|
export class RouteActionResponseError<TData = unknown> extends Error {
|
|
11
12
|
readonly response: Response;
|
|
@@ -55,13 +56,6 @@ function resolveRouteHandlers(router: AnyRouter, actionTo: string) {
|
|
|
55
56
|
};
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
function isRedirectResponse(value: unknown): value is Response {
|
|
59
|
-
if (!(value instanceof Response)) {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
return [301, 302, 303, 307, 308].includes(value.status);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
59
|
async function parseResponseData(response: Response) {
|
|
66
60
|
if (response.status === 204) {
|
|
67
61
|
return null;
|
package/src/runtime/utils.tsx
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// @effect-diagnostics strictBooleanExpressions:off
|
|
2
2
|
import type { RouteObject } from '@modern-js/runtime-utils/router';
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import { mergeModernRouteHandle } from './routeTree/staticData';
|
|
4
5
|
import type { ModernRoute } from './types';
|
|
5
6
|
|
|
6
|
-
export type SSRMode = 'string' | 'stream';
|
|
7
|
-
|
|
8
7
|
type RouterConfig = {
|
|
9
8
|
routesConfig: {
|
|
10
9
|
globalApp?: React.ComponentType<any>;
|
|
@@ -49,13 +48,6 @@ function withGlobalLayout(
|
|
|
49
48
|
};
|
|
50
49
|
}
|
|
51
50
|
|
|
52
|
-
function getRouteHandle(route: ModernRoute) {
|
|
53
|
-
return {
|
|
54
|
-
...route.handle,
|
|
55
|
-
...(typeof route.config === 'object' ? route.config?.handle : {}),
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
|
|
59
51
|
function toTanstackRouteObject(
|
|
60
52
|
route: ModernRoute,
|
|
61
53
|
globalApp?: React.ComponentType<GlobalAppProps>,
|
|
@@ -67,7 +59,7 @@ function toTanstackRouteObject(
|
|
|
67
59
|
loader: route.loader,
|
|
68
60
|
action: route.action,
|
|
69
61
|
shouldRevalidate: route.shouldRevalidate,
|
|
70
|
-
handle:
|
|
62
|
+
handle: mergeModernRouteHandle(route) ?? {},
|
|
71
63
|
index: route.index,
|
|
72
64
|
hasLoader: route.hasLoader || Boolean(route.loader),
|
|
73
65
|
hasClientLoader: route.hasClientLoader || Boolean(route.clientData),
|
|
@@ -108,8 +100,6 @@ export function createTanstackRouteObjectsFromConfig({
|
|
|
108
100
|
routesConfig,
|
|
109
101
|
}: {
|
|
110
102
|
routesConfig: RouterConfig['routesConfig'];
|
|
111
|
-
props?: Record<string, unknown>;
|
|
112
|
-
ssrMode?: SSRMode;
|
|
113
103
|
}): RouteObject[] | null {
|
|
114
104
|
if (!routesConfig) {
|
|
115
105
|
return null;
|
package/tests/router/cli.test.ts
CHANGED
|
@@ -306,13 +306,14 @@ describe('tanstack router cli plugin', () => {
|
|
|
306
306
|
});
|
|
307
307
|
});
|
|
308
308
|
|
|
309
|
-
test('
|
|
309
|
+
test('typechecks custom runtime module augmentations', async () => {
|
|
310
310
|
tempDir = await mkdtemp(path.join(tmpdir(), 'modern-tanstack-cli-'));
|
|
311
311
|
const srcDirectory = path.join(tempDir, 'src');
|
|
312
312
|
|
|
313
313
|
await writeTanstackRegisterFile({
|
|
314
314
|
entries: ['main'],
|
|
315
315
|
generatedDirName: 'tanstack',
|
|
316
|
+
runtimeModule: '@my-org/tanstack/runtime',
|
|
316
317
|
srcDirectory,
|
|
317
318
|
canonicalRoutes: {
|
|
318
319
|
'/talks': 'Record<string, never>',
|
|
@@ -324,6 +325,7 @@ describe('tanstack router cli plugin', () => {
|
|
|
324
325
|
entries: ['main'],
|
|
325
326
|
generatedDirName: 'tanstack',
|
|
326
327
|
srcDirectory,
|
|
328
|
+
runtimeModule: '@my-org/tanstack/runtime',
|
|
327
329
|
i18nRuntimeModule: '@my-org/i18n/runtime',
|
|
328
330
|
canonicalTypeChecks: [
|
|
329
331
|
"import type { UltramodernCanonicalRoutes } from '@my-org/i18n/runtime';",
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __webpack_require__ = {};
|
|
3
|
-
(()=>{
|
|
4
|
-
__webpack_require__.d = (exports1, getters, values)=>{
|
|
5
|
-
var define = (defs, kind)=>{
|
|
6
|
-
for(var key in defs)if (__webpack_require__.o(defs, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
[kind]: defs[key]
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
define(getters, "get");
|
|
12
|
-
define(values, "value");
|
|
13
|
-
};
|
|
14
|
-
})();
|
|
15
|
-
(()=>{
|
|
16
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
17
|
-
})();
|
|
18
|
-
(()=>{
|
|
19
|
-
__webpack_require__.r = (exports1)=>{
|
|
20
|
-
if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
21
|
-
value: 'Module'
|
|
22
|
-
});
|
|
23
|
-
Object.defineProperty(exports1, '__esModule', {
|
|
24
|
-
value: true
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
})();
|
|
28
|
-
var __webpack_exports__ = {};
|
|
29
|
-
__webpack_require__.r(__webpack_exports__);
|
|
30
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
31
|
-
createRouteTreeFromRouteObjects: ()=>index_js_namespaceObject.createRouteTreeFromRouteObjects,
|
|
32
|
-
getModernRouteIdsFromMatches: ()=>index_js_namespaceObject.getModernRouteIdsFromMatches,
|
|
33
|
-
pickRouteModuleComponent: ()=>index_js_namespaceObject.pickRouteModuleComponent
|
|
34
|
-
});
|
|
35
|
-
const index_js_namespaceObject = require("./routeTree/index.js");
|
|
36
|
-
exports.createRouteTreeFromRouteObjects = __webpack_exports__.createRouteTreeFromRouteObjects;
|
|
37
|
-
exports.getModernRouteIdsFromMatches = __webpack_exports__.getModernRouteIdsFromMatches;
|
|
38
|
-
exports.pickRouteModuleComponent = __webpack_exports__.pickRouteModuleComponent;
|
|
39
|
-
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
40
|
-
"createRouteTreeFromRouteObjects",
|
|
41
|
-
"getModernRouteIdsFromMatches",
|
|
42
|
-
"pickRouteModuleComponent"
|
|
43
|
-
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
44
|
-
Object.defineProperty(exports, '__esModule', {
|
|
45
|
-
value: true
|
|
46
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createRouteTreeFromRouteObjects, getModernRouteIdsFromMatches, pickRouteModuleComponent } from "./routeTree/index.mjs";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { CompositeComponent, getTanstackRscSerializationAdapters, rscSerializationAdapter } from "./client.mjs";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createRouteTreeFromRouteObjects, getModernRouteIdsFromMatches, pickRouteModuleComponent, } from './routeTree/index';
|
package/src/runtime/routeTree.ts
DELETED
package/src/runtime/rsc/index.ts
DELETED