@bleedingdev/modern-js-plugin-tanstack 3.2.0-ultramodern.0
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/LICENSE +21 -0
- package/dist/cjs/cli/index.js +268 -0
- package/dist/cjs/cli/tanstackTypes.js +388 -0
- package/dist/cjs/cli.js +65 -0
- package/dist/cjs/runtime/DefaultNotFound.js +47 -0
- package/dist/cjs/runtime/basepathRewrite.js +62 -0
- package/dist/cjs/runtime/dataMutation.js +345 -0
- package/dist/cjs/runtime/hooks.js +57 -0
- package/dist/cjs/runtime/index.js +114 -0
- package/dist/cjs/runtime/lifecycle.js +125 -0
- package/dist/cjs/runtime/plugin.js +250 -0
- package/dist/cjs/runtime/plugin.node.js +304 -0
- package/dist/cjs/runtime/prefetchLink.js +55 -0
- package/dist/cjs/runtime/routeTree.js +492 -0
- package/dist/cjs/runtime/rsc/ClientSlot.js +53 -0
- package/dist/cjs/runtime/rsc/CompositeComponent.js +75 -0
- package/dist/cjs/runtime/rsc/ReplayableStream.js +141 -0
- package/dist/cjs/runtime/rsc/RscNodeRenderer.js +65 -0
- package/dist/cjs/runtime/rsc/SlotContext.js +54 -0
- package/dist/cjs/runtime/rsc/client.js +93 -0
- package/dist/cjs/runtime/rsc/createRscProxy.js +141 -0
- package/dist/cjs/runtime/rsc/index.js +42 -0
- package/dist/cjs/runtime/rsc/payloadRouter.js +211 -0
- package/dist/cjs/runtime/rsc/server.js +246 -0
- package/dist/cjs/runtime/rsc/slotUsageSanitizer.js +65 -0
- package/dist/cjs/runtime/rsc/symbols.js +72 -0
- package/dist/cjs/runtime/types.js +18 -0
- package/dist/cjs/runtime/utils.js +142 -0
- package/dist/cjs/runtime.js +58 -0
- package/dist/esm/cli/index.mjs +201 -0
- package/dist/esm/cli/tanstackTypes.mjs +341 -0
- package/dist/esm/cli.mjs +2 -0
- package/dist/esm/rslib-runtime.mjs +18 -0
- package/dist/esm/runtime/DefaultNotFound.mjs +13 -0
- package/dist/esm/runtime/basepathRewrite.mjs +28 -0
- package/dist/esm/runtime/dataMutation.mjs +305 -0
- package/dist/esm/runtime/hooks.mjs +8 -0
- package/dist/esm/runtime/index.mjs +6 -0
- package/dist/esm/runtime/lifecycle.mjs +82 -0
- package/dist/esm/runtime/plugin.mjs +214 -0
- package/dist/esm/runtime/plugin.node.mjs +268 -0
- package/dist/esm/runtime/prefetchLink.mjs +18 -0
- package/dist/esm/runtime/routeTree.mjs +452 -0
- package/dist/esm/runtime/rsc/ClientSlot.mjs +19 -0
- package/dist/esm/runtime/rsc/CompositeComponent.mjs +41 -0
- package/dist/esm/runtime/rsc/ReplayableStream.mjs +104 -0
- package/dist/esm/runtime/rsc/RscNodeRenderer.mjs +31 -0
- package/dist/esm/runtime/rsc/SlotContext.mjs +17 -0
- package/dist/esm/runtime/rsc/client.mjs +53 -0
- package/dist/esm/runtime/rsc/createRscProxy.mjs +107 -0
- package/dist/esm/runtime/rsc/index.mjs +1 -0
- package/dist/esm/runtime/rsc/payloadRouter.mjs +162 -0
- package/dist/esm/runtime/rsc/server.mjs +200 -0
- package/dist/esm/runtime/rsc/slotUsageSanitizer.mjs +31 -0
- package/dist/esm/runtime/rsc/symbols.mjs +17 -0
- package/dist/esm/runtime/types.mjs +0 -0
- package/dist/esm/runtime/utils.mjs +89 -0
- package/dist/esm/runtime.mjs +1 -0
- package/dist/esm-node/cli/index.mjs +205 -0
- package/dist/esm-node/cli/tanstackTypes.mjs +342 -0
- package/dist/esm-node/cli.mjs +3 -0
- package/dist/esm-node/rslib-runtime.mjs +19 -0
- package/dist/esm-node/runtime/DefaultNotFound.mjs +14 -0
- package/dist/esm-node/runtime/basepathRewrite.mjs +29 -0
- package/dist/esm-node/runtime/dataMutation.mjs +306 -0
- package/dist/esm-node/runtime/hooks.mjs +9 -0
- package/dist/esm-node/runtime/index.mjs +7 -0
- package/dist/esm-node/runtime/lifecycle.mjs +83 -0
- package/dist/esm-node/runtime/plugin.mjs +215 -0
- package/dist/esm-node/runtime/plugin.node.mjs +269 -0
- package/dist/esm-node/runtime/prefetchLink.mjs +19 -0
- package/dist/esm-node/runtime/routeTree.mjs +453 -0
- package/dist/esm-node/runtime/rsc/ClientSlot.mjs +20 -0
- package/dist/esm-node/runtime/rsc/CompositeComponent.mjs +42 -0
- package/dist/esm-node/runtime/rsc/ReplayableStream.mjs +105 -0
- package/dist/esm-node/runtime/rsc/RscNodeRenderer.mjs +32 -0
- package/dist/esm-node/runtime/rsc/SlotContext.mjs +18 -0
- package/dist/esm-node/runtime/rsc/client.mjs +54 -0
- package/dist/esm-node/runtime/rsc/createRscProxy.mjs +108 -0
- package/dist/esm-node/runtime/rsc/index.mjs +2 -0
- package/dist/esm-node/runtime/rsc/payloadRouter.mjs +163 -0
- package/dist/esm-node/runtime/rsc/server.mjs +201 -0
- package/dist/esm-node/runtime/rsc/slotUsageSanitizer.mjs +32 -0
- package/dist/esm-node/runtime/rsc/symbols.mjs +18 -0
- package/dist/esm-node/runtime/types.mjs +1 -0
- package/dist/esm-node/runtime/utils.mjs +90 -0
- package/dist/esm-node/runtime.mjs +2 -0
- package/dist/types/cli/index.d.ts +20 -0
- package/dist/types/cli/tanstackTypes.d.ts +11 -0
- package/dist/types/cli.d.ts +2 -0
- package/dist/types/runtime/DefaultNotFound.d.ts +2 -0
- package/dist/types/runtime/basepathRewrite.d.ts +8 -0
- package/dist/types/runtime/dataMutation.d.ts +29 -0
- package/dist/types/runtime/hooks.d.ts +18 -0
- package/dist/types/runtime/index.d.ts +9 -0
- package/dist/types/runtime/lifecycle.d.ts +22 -0
- package/dist/types/runtime/plugin.d.ts +17 -0
- package/dist/types/runtime/plugin.node.d.ts +17 -0
- package/dist/types/runtime/prefetchLink.d.ts +11 -0
- package/dist/types/runtime/routeTree.d.ts +11 -0
- package/dist/types/runtime/rsc/ClientSlot.d.ts +5 -0
- package/dist/types/runtime/rsc/CompositeComponent.d.ts +3 -0
- package/dist/types/runtime/rsc/ReplayableStream.d.ts +24 -0
- package/dist/types/runtime/rsc/RscNodeRenderer.d.ts +5 -0
- package/dist/types/runtime/rsc/SlotContext.d.ts +11 -0
- package/dist/types/runtime/rsc/client.d.ts +11 -0
- package/dist/types/runtime/rsc/createRscProxy.d.ts +7 -0
- package/dist/types/runtime/rsc/index.d.ts +2 -0
- package/dist/types/runtime/rsc/payloadRouter.d.ts +24 -0
- package/dist/types/runtime/rsc/server.d.ts +14 -0
- package/dist/types/runtime/rsc/slotUsageSanitizer.d.ts +2 -0
- package/dist/types/runtime/rsc/symbols.d.ts +46 -0
- package/dist/types/runtime/types.d.ts +68 -0
- package/dist/types/runtime/utils.d.ts +36 -0
- package/dist/types/runtime.d.ts +1 -0
- package/dist/types-direct/cli/index.d.ts +20 -0
- package/dist/types-direct/cli/tanstackTypes.d.ts +11 -0
- package/dist/types-direct/cli.d.ts +2 -0
- package/dist/types-direct/runtime/DefaultNotFound.d.ts +2 -0
- package/dist/types-direct/runtime/basepathRewrite.d.ts +8 -0
- package/dist/types-direct/runtime/dataMutation.d.ts +29 -0
- package/dist/types-direct/runtime/hooks.d.ts +18 -0
- package/dist/types-direct/runtime/index.d.ts +9 -0
- package/dist/types-direct/runtime/lifecycle.d.ts +22 -0
- package/dist/types-direct/runtime/plugin.d.ts +17 -0
- package/dist/types-direct/runtime/plugin.node.d.ts +17 -0
- package/dist/types-direct/runtime/prefetchLink.d.ts +11 -0
- package/dist/types-direct/runtime/routeTree.d.ts +11 -0
- package/dist/types-direct/runtime/rsc/ClientSlot.d.ts +5 -0
- package/dist/types-direct/runtime/rsc/CompositeComponent.d.ts +3 -0
- package/dist/types-direct/runtime/rsc/ReplayableStream.d.ts +24 -0
- package/dist/types-direct/runtime/rsc/RscNodeRenderer.d.ts +5 -0
- package/dist/types-direct/runtime/rsc/SlotContext.d.ts +11 -0
- package/dist/types-direct/runtime/rsc/client.d.ts +11 -0
- package/dist/types-direct/runtime/rsc/createRscProxy.d.ts +7 -0
- package/dist/types-direct/runtime/rsc/index.d.ts +2 -0
- package/dist/types-direct/runtime/rsc/payloadRouter.d.ts +24 -0
- package/dist/types-direct/runtime/rsc/server.d.ts +14 -0
- package/dist/types-direct/runtime/rsc/slotUsageSanitizer.d.ts +2 -0
- package/dist/types-direct/runtime/rsc/symbols.d.ts +46 -0
- package/dist/types-direct/runtime/types.d.ts +68 -0
- package/dist/types-direct/runtime/utils.d.ts +36 -0
- package/dist/types-direct/runtime.d.ts +1 -0
- package/package.json +126 -0
- package/rslib.config.mts +4 -0
- package/rstest.config.mts +43 -0
- package/src/cli/index.ts +388 -0
- package/src/cli/tanstackTypes.ts +503 -0
- package/src/cli.ts +2 -0
- package/src/runtime/DefaultNotFound.tsx +15 -0
- package/src/runtime/basepathRewrite.ts +59 -0
- package/src/runtime/dataMutation.tsx +517 -0
- package/src/runtime/hooks.ts +34 -0
- package/src/runtime/index.tsx +30 -0
- package/src/runtime/lifecycle.ts +150 -0
- package/src/runtime/plugin.node.tsx +534 -0
- package/src/runtime/plugin.tsx +395 -0
- package/src/runtime/prefetchLink.tsx +87 -0
- package/src/runtime/routeTree.ts +942 -0
- package/src/runtime/rsc/ClientSlot.tsx +25 -0
- package/src/runtime/rsc/CompositeComponent.tsx +65 -0
- package/src/runtime/rsc/ReplayableStream.ts +155 -0
- package/src/runtime/rsc/RscNodeRenderer.tsx +45 -0
- package/src/runtime/rsc/SlotContext.tsx +31 -0
- package/src/runtime/rsc/client.tsx +90 -0
- package/src/runtime/rsc/createRscProxy.tsx +189 -0
- package/src/runtime/rsc/index.ts +10 -0
- package/src/runtime/rsc/payloadRouter.ts +318 -0
- package/src/runtime/rsc/server.tsx +303 -0
- package/src/runtime/rsc/slotUsageSanitizer.ts +76 -0
- package/src/runtime/rsc/symbols.ts +106 -0
- package/src/runtime/ssr-shim.d.ts +12 -0
- package/src/runtime/types.ts +83 -0
- package/src/runtime/utils.tsx +161 -0
- package/src/runtime.ts +1 -0
- package/tests/router/cli.test.ts +386 -0
- package/tests/router/dataMutation.test.tsx +396 -0
- package/tests/router/prefetchLink.test.tsx +43 -0
- package/tests/router/routeTree.test.ts +502 -0
- package/tests/router/rsc.test.tsx +256 -0
- package/tests/router/tanstackTypes.test.ts +62 -0
- package/tsconfig.json +12 -0
- package/tsconfig.tsgo.json +6 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Plugin, RuntimePluginExtends } from '@modern-js/plugin';
|
|
2
|
+
import type { RuntimePluginAPI } from '@modern-js/plugin/runtime';
|
|
3
|
+
import { type TInternalRuntimeContext } from '@modern-js/runtime/context';
|
|
4
|
+
import { type RouterExtendsHooks } from './hooks';
|
|
5
|
+
import type { RouterConfig } from './types';
|
|
6
|
+
type TanstackRouterRuntimeConfig = {
|
|
7
|
+
plugins?: TanstackRouterRuntimePlugin[];
|
|
8
|
+
router?: Partial<RouterConfig>;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
type TanstackRouterRuntimeExtends = Required<RuntimePluginExtends<TanstackRouterRuntimeConfig, TInternalRuntimeContext>> & {
|
|
12
|
+
extendHooks: RouterExtendsHooks;
|
|
13
|
+
};
|
|
14
|
+
type TanstackRouterPluginAPI = RuntimePluginAPI<TanstackRouterRuntimeExtends>;
|
|
15
|
+
type TanstackRouterRuntimePlugin = Plugin<TanstackRouterPluginAPI, TInternalRuntimeContext>;
|
|
16
|
+
export declare const tanstackRouterPlugin: (userConfig?: Partial<RouterConfig>) => TanstackRouterRuntimePlugin;
|
|
17
|
+
export default tanstackRouterPlugin;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Plugin, RuntimePluginExtends } from '@modern-js/plugin';
|
|
2
|
+
import type { RuntimePluginAPI } from '@modern-js/plugin/runtime';
|
|
3
|
+
import { type TInternalRuntimeContext } from '@modern-js/runtime/context';
|
|
4
|
+
import { type RouterExtendsHooks } from './hooks';
|
|
5
|
+
import type { RouterConfig } from './types';
|
|
6
|
+
type TanstackRouterRuntimeConfig = {
|
|
7
|
+
plugins?: TanstackRouterRuntimePlugin[];
|
|
8
|
+
router?: Partial<RouterConfig>;
|
|
9
|
+
[key: string]: unknown;
|
|
10
|
+
};
|
|
11
|
+
type TanstackRouterRuntimeExtends = Required<RuntimePluginExtends<TanstackRouterRuntimeConfig, TInternalRuntimeContext>> & {
|
|
12
|
+
extendHooks: RouterExtendsHooks;
|
|
13
|
+
};
|
|
14
|
+
type TanstackRouterPluginAPI = RuntimePluginAPI<TanstackRouterRuntimeExtends>;
|
|
15
|
+
type TanstackRouterRuntimePlugin = Plugin<TanstackRouterPluginAPI, TInternalRuntimeContext>;
|
|
16
|
+
export declare const tanstackRouterPlugin: (userConfig?: Partial<RouterConfig>) => TanstackRouterRuntimePlugin;
|
|
17
|
+
export default tanstackRouterPlugin;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type AnyRouter, type LinkComponentProps, type RegisteredRouter } from '@tanstack/react-router';
|
|
2
|
+
import type { ReactElement } from 'react';
|
|
3
|
+
export type PrefetchBehavior = 'intent' | 'render' | 'viewport' | 'none';
|
|
4
|
+
export type LinkProps<TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = '.', TMaskFrom extends string = TFrom, TMaskTo extends string = '.'> = LinkComponentProps<'a', TRouter, TFrom, TTo, TMaskFrom, TMaskTo> & {
|
|
5
|
+
prefetch?: PrefetchBehavior;
|
|
6
|
+
};
|
|
7
|
+
export type NavLinkProps<TRouter extends AnyRouter = RegisteredRouter, TFrom extends string = string, TTo extends string | undefined = '.', TMaskFrom extends string = TFrom, TMaskTo extends string = '.'> = LinkProps<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>;
|
|
8
|
+
type LinkComponent = <TRouter extends AnyRouter = RegisteredRouter, const TFrom extends string = string, const TTo extends string | undefined = undefined, const TMaskFrom extends string = TFrom, const TMaskTo extends string = ''>(props: LinkProps<TRouter, TFrom, TTo, TMaskFrom, TMaskTo>) => ReactElement;
|
|
9
|
+
export declare const Link: LinkComponent;
|
|
10
|
+
export declare const NavLink: LinkComponent;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RouteObject } from '@modern-js/runtime-utils/router';
|
|
2
|
+
import type { NestedRoute, PageRoute } from '@modern-js/types';
|
|
3
|
+
import type { AnyRouter, RootRoute as TanstackRootRoute } from '@tanstack/react-router';
|
|
4
|
+
type ModernTanstackRootRoute = TanstackRootRoute;
|
|
5
|
+
type RouteTreeOptions = {
|
|
6
|
+
rscPayloadRouter?: boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare function createRouteTreeFromModernRoutes(routes: Array<NestedRoute | PageRoute>, options?: RouteTreeOptions): ModernTanstackRootRoute;
|
|
9
|
+
export declare function createRouteTreeFromRouteObjects(routes: RouteObject[], options?: RouteTreeOptions): ModernTanstackRootRoute;
|
|
10
|
+
export declare function getModernRouteIdsFromMatches(router: AnyRouter): string[];
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface ReplayableStreamOptions {
|
|
2
|
+
signal?: AbortSignal;
|
|
3
|
+
}
|
|
4
|
+
export declare const REPLAYABLE_STREAM_MARKER: unique symbol;
|
|
5
|
+
export declare class ReplayableStream<T = Uint8Array> {
|
|
6
|
+
private source;
|
|
7
|
+
private options;
|
|
8
|
+
readonly [REPLAYABLE_STREAM_MARKER] = true;
|
|
9
|
+
private chunks;
|
|
10
|
+
private done;
|
|
11
|
+
private error;
|
|
12
|
+
private waiter;
|
|
13
|
+
private released;
|
|
14
|
+
private reader;
|
|
15
|
+
private abortListener;
|
|
16
|
+
constructor(source: ReadableStream<T>, options?: ReplayableStreamOptions);
|
|
17
|
+
private start;
|
|
18
|
+
private detachAbortListener;
|
|
19
|
+
private notify;
|
|
20
|
+
private wait;
|
|
21
|
+
release(): void;
|
|
22
|
+
isReleased(): boolean;
|
|
23
|
+
createReplayStream(): ReadableStream<T>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export type SlotImplementations = Record<string, unknown>;
|
|
3
|
+
export declare function useSlotContext(): {
|
|
4
|
+
implementations: SlotImplementations;
|
|
5
|
+
strict: boolean;
|
|
6
|
+
} | null;
|
|
7
|
+
export declare function SlotProvider({ children, implementations, strict, }: {
|
|
8
|
+
children?: React.ReactNode;
|
|
9
|
+
implementations: SlotImplementations;
|
|
10
|
+
strict?: boolean;
|
|
11
|
+
}): React.JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CompositeComponent } from './CompositeComponent';
|
|
2
|
+
import type { AnyCompositeComponent, RscSlotUsageEvent } from './symbols';
|
|
3
|
+
export type { AnyCompositeComponent, AnyRenderableServerComponent, CompositeComponentProps, } from './symbols';
|
|
4
|
+
export { CompositeComponent };
|
|
5
|
+
type SerializedRsc = {
|
|
6
|
+
kind: 'renderable' | 'composite';
|
|
7
|
+
stream: ReadableStream<Uint8Array>;
|
|
8
|
+
slotUsagesStream?: ReadableStream<RscSlotUsageEvent>;
|
|
9
|
+
};
|
|
10
|
+
export declare function getTanstackRscSerializationAdapters(): import("@tanstack/router-core").SerializationAdapter<AnyCompositeComponent<Record<string, unknown>, import("react").ReactNode>, SerializedRsc, never>[];
|
|
11
|
+
export declare const rscSerializationAdapter: typeof getTanstackRscSerializationAdapters;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type RscSlotUsageEvent, type ServerComponentStream } from './symbols';
|
|
2
|
+
export declare function createRscProxy(getTree: () => unknown, options?: {
|
|
3
|
+
renderable?: boolean;
|
|
4
|
+
slotUsages?: RscSlotUsageEvent[];
|
|
5
|
+
slotUsagesStream?: ReadableStream<RscSlotUsageEvent>;
|
|
6
|
+
stream?: ServerComponentStream;
|
|
7
|
+
}): any;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ServerPayload } from '@modern-js/runtime/context';
|
|
2
|
+
type PayloadDecoder = (stream: ReadableStream<Uint8Array>) => Promise<unknown>;
|
|
3
|
+
type TanstackPayloadRouterLike = {
|
|
4
|
+
state?: {
|
|
5
|
+
location?: unknown;
|
|
6
|
+
matches?: unknown;
|
|
7
|
+
statusCode?: unknown;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
type LoadRouteDataOptions = {
|
|
11
|
+
hasClientLoader?: boolean;
|
|
12
|
+
loadClientData: () => Promise<unknown>;
|
|
13
|
+
request: Request;
|
|
14
|
+
routeId?: string;
|
|
15
|
+
};
|
|
16
|
+
export declare function createTanstackRscServerPayload(router: TanstackPayloadRouterLike, options?: {
|
|
17
|
+
omitClientLoaderData?: boolean;
|
|
18
|
+
}): ServerPayload;
|
|
19
|
+
export declare function handleTanstackRscRedirect(headers: Headers, basename: string, status: number): Response;
|
|
20
|
+
export declare function isTanstackRscPayloadNavigationEnabled(): boolean;
|
|
21
|
+
export declare function loadTanstackRscPayload(request: Request): Promise<ServerPayload>;
|
|
22
|
+
export declare function loadTanstackRscRouteData({ hasClientLoader, loadClientData, request, routeId, }: LoadRouteDataOptions): Promise<unknown>;
|
|
23
|
+
export declare function __setTanstackRscPayloadDecoderForTests(decoder?: PayloadDecoder): void;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RawStream } from '@tanstack/router-core';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { type AnyCompositeComponent, type AnyRenderableServerComponent, type RscSlotUsageEvent } from './symbols';
|
|
4
|
+
export { CompositeComponent } from './CompositeComponent';
|
|
5
|
+
export type { AnyCompositeComponent, AnyRenderableServerComponent, CompositeComponentProps, } from './symbols';
|
|
6
|
+
export declare function renderServerComponent<TNode extends React.ReactNode>(node: TNode): Promise<TNode & AnyRenderableServerComponent<TNode>>;
|
|
7
|
+
export declare function createCompositeComponent<TProps extends object = Record<string, unknown>, TReturn = React.ReactNode>(component: (props: TProps) => React.ReactNode | Promise<React.ReactNode>): Promise<AnyCompositeComponent<TProps, TReturn>>;
|
|
8
|
+
type SerializedRsc = {
|
|
9
|
+
kind: 'renderable' | 'composite';
|
|
10
|
+
stream: RawStream;
|
|
11
|
+
slotUsagesStream?: ReadableStream<RscSlotUsageEvent>;
|
|
12
|
+
};
|
|
13
|
+
export declare function getTanstackRscSerializationAdapters(): import("@tanstack/router-core").SerializationAdapter<AnyCompositeComponent<Record<string, unknown>, React.ReactNode> | AnyRenderableServerComponent<React.ReactNode>, SerializedRsc, never>[];
|
|
14
|
+
export declare const rscSerializationAdapter: typeof getTanstackRscSerializationAdapters;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export interface ServerComponentStream {
|
|
3
|
+
createReplayStream: () => ReadableStream<Uint8Array>;
|
|
4
|
+
}
|
|
5
|
+
export declare const SERVER_COMPONENT_STREAM: unique symbol;
|
|
6
|
+
export declare const RENDERABLE_RSC: unique symbol;
|
|
7
|
+
export declare const RSC_PROXY_GET_TREE: unique symbol;
|
|
8
|
+
export declare const RSC_PROXY_PATH: unique symbol;
|
|
9
|
+
export declare const RSC_SLOT_USAGES_STREAM: unique symbol;
|
|
10
|
+
export declare const RSC_SLOT_USAGES: unique symbol;
|
|
11
|
+
export type SerializableSlotArg = string | number | boolean | bigint | null | undefined | SerializableSlotArg[] | {
|
|
12
|
+
[key: string]: SerializableSlotArg;
|
|
13
|
+
};
|
|
14
|
+
export type RscSlotUsageEvent = {
|
|
15
|
+
slot: string;
|
|
16
|
+
args?: SerializableSlotArg[];
|
|
17
|
+
};
|
|
18
|
+
export interface AnyRenderableServerComponent<TNode = React.ReactNode> {
|
|
19
|
+
[SERVER_COMPONENT_STREAM]: ServerComponentStream;
|
|
20
|
+
[RENDERABLE_RSC]: true;
|
|
21
|
+
[RSC_PROXY_GET_TREE]?: () => unknown;
|
|
22
|
+
[RSC_PROXY_PATH]?: string[];
|
|
23
|
+
[RSC_SLOT_USAGES_STREAM]?: ReadableStream<RscSlotUsageEvent>;
|
|
24
|
+
'~types'?: {
|
|
25
|
+
node: TNode;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
export interface AnyCompositeComponent<TProps extends object = Record<string, unknown>, TReturn = React.ReactNode> {
|
|
29
|
+
[SERVER_COMPONENT_STREAM]?: ServerComponentStream;
|
|
30
|
+
[RSC_PROXY_GET_TREE]?: () => unknown;
|
|
31
|
+
[RSC_PROXY_PATH]?: string[];
|
|
32
|
+
[RSC_SLOT_USAGES]?: RscSlotUsageEvent[];
|
|
33
|
+
[RSC_SLOT_USAGES_STREAM]?: ReadableStream<RscSlotUsageEvent>;
|
|
34
|
+
'~types'?: {
|
|
35
|
+
props: TProps;
|
|
36
|
+
return: TReturn;
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
type InferCompositeProps<TComp extends AnyCompositeComponent> = TComp extends AnyCompositeComponent<infer TProps, unknown> ? TProps : Record<string, unknown>;
|
|
40
|
+
export type CompositeComponentProps<TComp extends AnyCompositeComponent> = {
|
|
41
|
+
src: TComp;
|
|
42
|
+
strict?: boolean;
|
|
43
|
+
} & InferCompositeProps<TComp>;
|
|
44
|
+
export declare function isServerComponent(value: unknown): value is AnyCompositeComponent | AnyRenderableServerComponent;
|
|
45
|
+
export declare function isRenderableServerComponent(value: unknown): boolean;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { RequestContext } from '@modern-js/runtime-utils/node';
|
|
2
|
+
import type { RouteObject } from '@modern-js/runtime-utils/router';
|
|
3
|
+
import type { NestedRoute, PageRoute } from '@modern-js/types';
|
|
4
|
+
import type React from 'react';
|
|
5
|
+
export type BuiltInRouterFramework = 'react-router' | 'tanstack';
|
|
6
|
+
export type RouterFramework = BuiltInRouterFramework | (string & {});
|
|
7
|
+
export type RouterConfig = {
|
|
8
|
+
framework?: RouterFramework;
|
|
9
|
+
routesConfig: {
|
|
10
|
+
globalApp?: React.ComponentType<any>;
|
|
11
|
+
routes?: (NestedRoute | PageRoute)[];
|
|
12
|
+
};
|
|
13
|
+
oldVersion?: boolean;
|
|
14
|
+
serverBase?: string[];
|
|
15
|
+
supportHtml5History?: boolean;
|
|
16
|
+
basename?: string;
|
|
17
|
+
createRoutes?: () => RouteObject[];
|
|
18
|
+
future?: Partial<{
|
|
19
|
+
v7_startTransition: boolean;
|
|
20
|
+
}>;
|
|
21
|
+
unstable_reloadOnURLMismatch?: boolean;
|
|
22
|
+
};
|
|
23
|
+
export interface RouterRouteMatchSnapshot {
|
|
24
|
+
routeId: string;
|
|
25
|
+
assetRouteId?: string;
|
|
26
|
+
pathname?: string;
|
|
27
|
+
params?: Record<string, string>;
|
|
28
|
+
}
|
|
29
|
+
export interface InternalRouterServerSnapshot {
|
|
30
|
+
framework?: RouterFramework;
|
|
31
|
+
basename?: string;
|
|
32
|
+
statusCode?: number;
|
|
33
|
+
errors?: Record<string, unknown>;
|
|
34
|
+
routerData?: {
|
|
35
|
+
loaderData?: Record<string, unknown>;
|
|
36
|
+
errors?: Record<string, unknown>;
|
|
37
|
+
};
|
|
38
|
+
hydrationScript?: string;
|
|
39
|
+
hydrationScripts?: string[];
|
|
40
|
+
matchedRouteIds?: string[];
|
|
41
|
+
matches?: RouterRouteMatchSnapshot[];
|
|
42
|
+
}
|
|
43
|
+
export interface InternalRouterRuntimeState {
|
|
44
|
+
framework: RouterFramework;
|
|
45
|
+
basename?: string;
|
|
46
|
+
instance?: unknown;
|
|
47
|
+
hydrationScript?: string;
|
|
48
|
+
hydrationScripts?: string[];
|
|
49
|
+
matchedRouteIds?: string[];
|
|
50
|
+
matches?: RouterRouteMatchSnapshot[];
|
|
51
|
+
serverSnapshot?: InternalRouterServerSnapshot;
|
|
52
|
+
cleanup?: () => void | Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
export interface RouterServerPrepareResult {
|
|
55
|
+
state: InternalRouterRuntimeState;
|
|
56
|
+
snapshot?: InternalRouterServerSnapshot;
|
|
57
|
+
redirect?: Response;
|
|
58
|
+
cleanup?: () => void | Promise<void>;
|
|
59
|
+
}
|
|
60
|
+
interface DataFunctionArgs<D = any> {
|
|
61
|
+
request: Request;
|
|
62
|
+
params: Record<string, string>;
|
|
63
|
+
context?: D;
|
|
64
|
+
}
|
|
65
|
+
export type LoaderFunctionArgs<P extends Record<string, unknown> = Record<string, unknown>> = DataFunctionArgs<RequestContext<P>>;
|
|
66
|
+
type DataFunctionValue = Response | NonNullable<unknown> | null;
|
|
67
|
+
export type LoaderFunction = <P extends Record<string, unknown> = Record<string, unknown>>(args: LoaderFunctionArgs<P>) => Promise<DataFunctionValue> | DataFunctionValue;
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { RouteObject } from '@modern-js/runtime-utils/router';
|
|
2
|
+
import type { NestedRoute, PageRoute, SSRMode } from '@modern-js/types';
|
|
3
|
+
import React from 'react';
|
|
4
|
+
type RouterConfig = {
|
|
5
|
+
routesConfig: {
|
|
6
|
+
globalApp?: React.ComponentType<any>;
|
|
7
|
+
routes?: (NestedRoute | PageRoute)[];
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
type GlobalAppProps = {
|
|
11
|
+
Component: React.ComponentType;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
};
|
|
14
|
+
export type ModernRouteObject = RouteObject & {
|
|
15
|
+
isClientComponent?: boolean;
|
|
16
|
+
hasClientLoader?: boolean;
|
|
17
|
+
hasLoader?: boolean;
|
|
18
|
+
hasAction?: boolean;
|
|
19
|
+
inValidSSRRoute?: boolean;
|
|
20
|
+
lazyImport?: () => Promise<{
|
|
21
|
+
default: React.ComponentType;
|
|
22
|
+
}>;
|
|
23
|
+
};
|
|
24
|
+
export declare function getRouteObjects(routes: (NestedRoute | PageRoute)[], { globalApp, ssrMode, props, }: {
|
|
25
|
+
globalApp?: React.ComponentType<GlobalAppProps>;
|
|
26
|
+
ssrMode?: SSRMode;
|
|
27
|
+
props?: Record<string, unknown>;
|
|
28
|
+
}): RouteObject[];
|
|
29
|
+
export declare function createRouteObjectsFromConfig({ routesConfig, props, ssrMode, }: {
|
|
30
|
+
routesConfig: RouterConfig['routesConfig'];
|
|
31
|
+
props?: Record<string, unknown>;
|
|
32
|
+
ssrMode?: SSRMode;
|
|
33
|
+
}): RouteObject[] | null;
|
|
34
|
+
export declare const urlJoin: (...parts: string[]) => string;
|
|
35
|
+
export declare function standardSlash(str: string): string;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './runtime/index';
|
package/package.json
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bleedingdev/modern-js-plugin-tanstack",
|
|
3
|
+
"description": "TanStack Router integration for Modern.js.",
|
|
4
|
+
"homepage": "https://github.com/BleedingDev/ultramodern.js#readme",
|
|
5
|
+
"bugs": {
|
|
6
|
+
"url": "https://github.com/BleedingDev/ultramodern.js/issues"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/BleedingDev/ultramodern.js.git",
|
|
11
|
+
"directory": "packages/runtime/plugin-tanstack"
|
|
12
|
+
},
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"keywords": [
|
|
15
|
+
"react",
|
|
16
|
+
"framework",
|
|
17
|
+
"modern",
|
|
18
|
+
"modern.js",
|
|
19
|
+
"tanstack-router"
|
|
20
|
+
],
|
|
21
|
+
"version": "3.2.0-ultramodern.0",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=20"
|
|
24
|
+
},
|
|
25
|
+
"types": "./dist/types/cli/index.d.ts",
|
|
26
|
+
"main": "./dist/cjs/cli/index.js",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/types/cli/index.d.ts",
|
|
30
|
+
"node": {
|
|
31
|
+
"import": "./dist/esm-node/cli/index.mjs",
|
|
32
|
+
"require": "./dist/cjs/cli/index.js"
|
|
33
|
+
},
|
|
34
|
+
"default": "./dist/cjs/cli/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./package.json": "./package.json",
|
|
37
|
+
"./cli": {
|
|
38
|
+
"types": "./dist/types/cli/index.d.ts",
|
|
39
|
+
"node": {
|
|
40
|
+
"import": "./dist/esm-node/cli/index.mjs",
|
|
41
|
+
"require": "./dist/cjs/cli/index.js"
|
|
42
|
+
},
|
|
43
|
+
"default": "./dist/cjs/cli/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./runtime": {
|
|
46
|
+
"types": "./dist/types/runtime/index.d.ts",
|
|
47
|
+
"node": {
|
|
48
|
+
"module": "./dist/esm/runtime/index.mjs"
|
|
49
|
+
},
|
|
50
|
+
"default": "./dist/esm/runtime/index.mjs"
|
|
51
|
+
},
|
|
52
|
+
"./runtime/rsc": {
|
|
53
|
+
"types": "./dist/types/runtime/rsc/index.d.ts",
|
|
54
|
+
"default": "./dist/esm/runtime/rsc/index.mjs"
|
|
55
|
+
},
|
|
56
|
+
"./runtime/rsc/client": {
|
|
57
|
+
"types": "./dist/types/runtime/rsc/client.d.ts",
|
|
58
|
+
"default": "./dist/esm/runtime/rsc/client.mjs"
|
|
59
|
+
},
|
|
60
|
+
"./runtime/rsc/server": {
|
|
61
|
+
"types": "./dist/types/runtime/rsc/server.d.ts",
|
|
62
|
+
"default": "./dist/esm/runtime/rsc/server.mjs"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"typesVersions": {
|
|
66
|
+
"*": {
|
|
67
|
+
".": [
|
|
68
|
+
"./dist/types/cli/index.d.ts"
|
|
69
|
+
],
|
|
70
|
+
"cli": [
|
|
71
|
+
"./dist/types/cli/index.d.ts"
|
|
72
|
+
],
|
|
73
|
+
"runtime": [
|
|
74
|
+
"./dist/types/runtime/index.d.ts"
|
|
75
|
+
],
|
|
76
|
+
"runtime/rsc": [
|
|
77
|
+
"./dist/types/runtime/rsc/index.d.ts"
|
|
78
|
+
],
|
|
79
|
+
"runtime/rsc/client": [
|
|
80
|
+
"./dist/types/runtime/rsc/client.d.ts"
|
|
81
|
+
],
|
|
82
|
+
"runtime/rsc/server": [
|
|
83
|
+
"./dist/types/runtime/rsc/server.d.ts"
|
|
84
|
+
]
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
"dependencies": {
|
|
88
|
+
"@swc/helpers": "^0.5.21",
|
|
89
|
+
"@tanstack/react-router": "1.170.1",
|
|
90
|
+
"@tanstack/router-core": "1.170.1",
|
|
91
|
+
"@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.2.0-ultramodern.0",
|
|
92
|
+
"@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.2.0-ultramodern.0",
|
|
93
|
+
"@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.2.0-ultramodern.0",
|
|
94
|
+
"@modern-js/types": "npm:@bleedingdev/modern-js-types@3.2.0-ultramodern.0"
|
|
95
|
+
},
|
|
96
|
+
"peerDependencies": {
|
|
97
|
+
"@modern-js/runtime": "3.2.0-ultramodern.0",
|
|
98
|
+
"react": "^19.2.6",
|
|
99
|
+
"react-dom": "^19.2.6"
|
|
100
|
+
},
|
|
101
|
+
"devDependencies": {
|
|
102
|
+
"@rslib/core": "0.21.5",
|
|
103
|
+
"@tanstack/history": "1.162.0",
|
|
104
|
+
"@testing-library/dom": "^10.4.1",
|
|
105
|
+
"@testing-library/react": "^16.3.2",
|
|
106
|
+
"@types/node": "^25.8.0",
|
|
107
|
+
"@types/react": "^19.2.14",
|
|
108
|
+
"@types/react-dom": "^19.2.3",
|
|
109
|
+
"@typescript/native-preview": "7.0.0-dev.20260516.1",
|
|
110
|
+
"react": "^19.2.6",
|
|
111
|
+
"react-dom": "^19.2.6",
|
|
112
|
+
"@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.2.0-ultramodern.0",
|
|
113
|
+
"@modern-js/runtime": "npm:@bleedingdev/modern-js-runtime@3.2.0-ultramodern.0",
|
|
114
|
+
"@scripts/rstest-config": "2.66.0"
|
|
115
|
+
},
|
|
116
|
+
"sideEffects": false,
|
|
117
|
+
"publishConfig": {
|
|
118
|
+
"registry": "https://registry.npmjs.org/",
|
|
119
|
+
"access": "public"
|
|
120
|
+
},
|
|
121
|
+
"scripts": {
|
|
122
|
+
"dev": "rslib build --watch",
|
|
123
|
+
"build": "rslib build && pnpm -w tsgo:dts \"$PWD\"",
|
|
124
|
+
"test": "rstest --passWithNoTests"
|
|
125
|
+
}
|
|
126
|
+
}
|
package/rslib.config.mts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { ProjectConfig } from '@rstest/core';
|
|
2
|
+
import { withTestPreset } from '@scripts/rstest-config';
|
|
3
|
+
|
|
4
|
+
const commonConfig: ProjectConfig = {
|
|
5
|
+
setupFiles: ['@scripts/rstest-config/setup.ts'],
|
|
6
|
+
globals: true,
|
|
7
|
+
tools: {
|
|
8
|
+
swc: {
|
|
9
|
+
jsc: {
|
|
10
|
+
transform: {
|
|
11
|
+
react: {
|
|
12
|
+
runtime: 'automatic',
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export default {
|
|
21
|
+
projects: [
|
|
22
|
+
withTestPreset({
|
|
23
|
+
name: 'plugin-tanstack-node',
|
|
24
|
+
testEnvironment: 'node',
|
|
25
|
+
include: [
|
|
26
|
+
'tests/router/cli.test.ts',
|
|
27
|
+
'tests/router/rsc.test.tsx',
|
|
28
|
+
'tests/router/tanstackTypes.test.ts',
|
|
29
|
+
'tests/router/routeTree.test.ts',
|
|
30
|
+
],
|
|
31
|
+
extends: commonConfig,
|
|
32
|
+
}),
|
|
33
|
+
withTestPreset({
|
|
34
|
+
name: 'plugin-tanstack-client',
|
|
35
|
+
testEnvironment: 'happy-dom',
|
|
36
|
+
include: [
|
|
37
|
+
'tests/router/dataMutation.test.tsx',
|
|
38
|
+
'tests/router/prefetchLink.test.tsx',
|
|
39
|
+
],
|
|
40
|
+
extends: commonConfig,
|
|
41
|
+
}),
|
|
42
|
+
],
|
|
43
|
+
};
|