@bleedingdev/modern-js-plugin-tanstack 3.2.0-ultramodern.12 → 3.2.0-ultramodern.121
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/index.js +89 -31
- package/dist/cjs/cli/routeSplitting.js +55 -0
- package/dist/cjs/cli/tanstackTypes.js +172 -170
- package/dist/cjs/cli.js +12 -8
- package/dist/cjs/runtime/basepathRewrite.js +12 -8
- package/dist/cjs/runtime/dataMutation.js +9 -5
- package/dist/cjs/runtime/hooks.js +20 -19
- package/dist/cjs/runtime/hydrationBoundary.js +48 -0
- package/dist/cjs/runtime/index.js +79 -35
- package/dist/cjs/runtime/lifecycle.js +21 -91
- package/dist/cjs/runtime/loaderBridge.js +173 -0
- package/dist/cjs/runtime/outlet.js +58 -0
- package/dist/cjs/runtime/plugin.js +195 -114
- package/dist/cjs/runtime/plugin.node.js +45 -45
- package/dist/cjs/runtime/plugin.worker.js +53 -0
- package/dist/cjs/runtime/pluginCore.js +55 -0
- package/dist/cjs/runtime/prefetchLink.js +10 -6
- package/dist/cjs/runtime/register.js +56 -0
- package/dist/cjs/runtime/routeTree.js +74 -207
- package/dist/cjs/runtime/router.js +41 -0
- package/dist/cjs/runtime/rsc/ClientSlot.js +9 -5
- package/dist/cjs/runtime/rsc/CompositeComponent.js +9 -5
- package/dist/cjs/runtime/rsc/ReplayableStream.js +14 -9
- package/dist/cjs/runtime/rsc/RscNodeRenderer.js +9 -5
- package/dist/cjs/runtime/rsc/SlotContext.js +9 -5
- package/dist/cjs/runtime/rsc/client.js +9 -5
- package/dist/cjs/runtime/rsc/createRscProxy.js +9 -5
- package/dist/cjs/runtime/rsc/index.js +9 -5
- package/dist/cjs/runtime/rsc/payloadRouter.js +44 -6
- package/dist/cjs/runtime/rsc/server.js +9 -5
- package/dist/cjs/runtime/rsc/slotUsageSanitizer.js +9 -5
- package/dist/cjs/runtime/rsc/symbols.js +20 -15
- package/dist/cjs/runtime/state.js +45 -0
- package/dist/cjs/runtime/types.js +31 -1
- package/dist/cjs/runtime/utils.js +9 -10
- package/dist/cjs/runtime.js +9 -5
- package/dist/esm/cli/index.mjs +75 -27
- package/dist/esm/cli/routeSplitting.mjs +14 -0
- package/dist/esm/cli/tanstackTypes.mjs +158 -160
- package/dist/esm/runtime/hooks.mjs +1 -8
- package/dist/esm/runtime/hydrationBoundary.mjs +10 -0
- package/dist/esm/runtime/index.mjs +5 -2
- package/dist/esm/runtime/lifecycle.mjs +1 -82
- package/dist/esm/runtime/loaderBridge.mjs +114 -0
- package/dist/esm/runtime/outlet.mjs +17 -0
- package/dist/esm/runtime/plugin.mjs +191 -114
- package/dist/esm/runtime/plugin.node.mjs +40 -44
- package/dist/esm/runtime/plugin.worker.mjs +1 -0
- package/dist/esm/runtime/pluginCore.mjs +14 -0
- package/dist/esm/runtime/prefetchLink.mjs +1 -1
- package/dist/esm/runtime/register.mjs +18 -0
- package/dist/esm/runtime/routeTree.mjs +59 -193
- package/dist/esm/runtime/router.mjs +2 -0
- package/dist/esm/runtime/rsc/payloadRouter.mjs +35 -1
- package/dist/esm/runtime/state.mjs +7 -0
- package/dist/esm/runtime/types.mjs +7 -0
- package/dist/esm/runtime/utils.mjs +0 -5
- package/dist/esm-node/cli/index.mjs +75 -27
- package/dist/esm-node/cli/routeSplitting.mjs +15 -0
- package/dist/esm-node/cli/tanstackTypes.mjs +158 -160
- package/dist/esm-node/runtime/hooks.mjs +1 -8
- package/dist/esm-node/runtime/hydrationBoundary.mjs +11 -0
- package/dist/esm-node/runtime/index.mjs +5 -2
- package/dist/esm-node/runtime/lifecycle.mjs +1 -82
- package/dist/esm-node/runtime/loaderBridge.mjs +115 -0
- package/dist/esm-node/runtime/outlet.mjs +18 -0
- package/dist/esm-node/runtime/plugin.mjs +191 -114
- package/dist/esm-node/runtime/plugin.node.mjs +40 -44
- package/dist/esm-node/runtime/plugin.worker.mjs +2 -0
- package/dist/esm-node/runtime/pluginCore.mjs +15 -0
- package/dist/esm-node/runtime/prefetchLink.mjs +1 -1
- package/dist/esm-node/runtime/register.mjs +19 -0
- package/dist/esm-node/runtime/routeTree.mjs +59 -193
- package/dist/esm-node/runtime/router.mjs +3 -0
- package/dist/esm-node/runtime/rsc/payloadRouter.mjs +35 -1
- package/dist/esm-node/runtime/state.mjs +8 -0
- package/dist/esm-node/runtime/types.mjs +7 -0
- package/dist/esm-node/runtime/utils.mjs +0 -5
- package/dist/types/cli/index.d.ts +14 -1
- package/dist/types/cli/routeSplitting.d.ts +20 -0
- package/dist/types/cli/tanstackTypes.d.ts +21 -1
- package/dist/types/runtime/hooks.d.ts +8 -33
- package/dist/types/runtime/hydrationBoundary.d.ts +2 -0
- package/dist/types/runtime/index.d.ts +8 -3
- package/dist/types/runtime/lifecycle.d.ts +7 -22
- package/dist/types/runtime/loaderBridge.d.ts +48 -0
- package/dist/types/runtime/outlet.d.ts +2 -0
- package/dist/types/runtime/plugin.d.ts +2 -15
- package/dist/types/runtime/plugin.node.d.ts +2 -15
- package/dist/types/runtime/plugin.worker.d.ts +1 -0
- package/dist/types/runtime/pluginCore.d.ts +21 -0
- package/dist/types/runtime/register.d.ts +9 -0
- package/dist/types/runtime/routeTree.d.ts +0 -2
- package/dist/types/runtime/router.d.ts +14 -0
- package/dist/types/runtime/state.d.ts +16 -0
- package/dist/types/runtime/types.d.ts +14 -53
- package/package.json +42 -40
- package/rstest.config.mts +6 -0
- package/src/cli/index.ts +162 -23
- package/src/cli/routeSplitting.ts +43 -0
- package/src/cli/tanstackTypes.ts +331 -187
- package/src/runtime/hooks.ts +10 -27
- package/src/runtime/hydrationBoundary.tsx +12 -0
- package/src/runtime/index.tsx +17 -7
- package/src/runtime/lifecycle.ts +16 -151
- package/src/runtime/loaderBridge.ts +257 -0
- package/src/runtime/outlet.tsx +48 -0
- package/src/runtime/plugin.node.tsx +72 -85
- package/src/runtime/plugin.tsx +361 -206
- package/src/runtime/plugin.worker.tsx +4 -0
- package/src/runtime/pluginCore.ts +48 -0
- package/src/runtime/prefetchLink.tsx +1 -1
- package/src/runtime/register.ts +58 -0
- package/src/runtime/routeTree.ts +163 -354
- package/src/runtime/router.ts +15 -0
- package/src/runtime/rsc/payloadRouter.ts +45 -2
- package/src/runtime/ssr-shim.d.ts +1 -3
- package/src/runtime/state.ts +29 -0
- package/src/runtime/types.ts +32 -66
- package/src/runtime/utils.tsx +3 -6
- package/tests/router/cli.test.ts +586 -5
- package/tests/router/fastDefaults.test.ts +25 -0
- package/tests/router/hooks.test.ts +26 -0
- package/tests/router/hydrationBoundary.test.tsx +23 -0
- package/tests/router/loaderBridge.test.ts +211 -0
- package/tests/router/packageSurface.test.ts +24 -0
- package/tests/router/prefetchLink.test.tsx +43 -7
- package/tests/router/register.test.ts +46 -0
- package/tests/router/routeTree.test.ts +381 -81
- package/tests/router/rsc.test.tsx +70 -0
- package/tests/router/tanstackTypes.test.ts +573 -1
- package/dist/cjs/runtime/DefaultNotFound.js +0 -47
- package/dist/esm/runtime/DefaultNotFound.mjs +0 -13
- package/dist/esm-node/runtime/DefaultNotFound.mjs +0 -14
- package/dist/types/runtime/DefaultNotFound.d.ts +0 -2
- package/src/runtime/DefaultNotFound.tsx +0 -15
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { Plugin, RuntimePluginExtends } from '@modern-js/plugin';
|
|
2
|
+
import type { RuntimePluginAPI } from '@modern-js/plugin/runtime';
|
|
3
|
+
import {
|
|
4
|
+
getGlobalLayoutApp,
|
|
5
|
+
getGlobalRoutes,
|
|
6
|
+
type TInternalRuntimeContext,
|
|
7
|
+
} from '@modern-js/runtime/context';
|
|
8
|
+
import { merge } from '@modern-js/runtime-utils/merge';
|
|
9
|
+
import type { RouterExtendsHooks } from './hooks';
|
|
10
|
+
import type { RouterConfig } from './types';
|
|
11
|
+
|
|
12
|
+
export type TanstackRouterRuntimeConfig = {
|
|
13
|
+
plugins?: TanstackRouterRuntimePlugin[];
|
|
14
|
+
router?: Partial<RouterConfig>;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type TanstackRouterRuntimeExtends = Required<
|
|
19
|
+
RuntimePluginExtends<TanstackRouterRuntimeConfig, TInternalRuntimeContext>
|
|
20
|
+
> & {
|
|
21
|
+
extendHooks: RouterExtendsHooks;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type TanstackRouterPluginAPI =
|
|
25
|
+
RuntimePluginAPI<TanstackRouterRuntimeExtends>;
|
|
26
|
+
|
|
27
|
+
export type TanstackRouterRuntimePlugin = Plugin<
|
|
28
|
+
TanstackRouterPluginAPI,
|
|
29
|
+
TInternalRuntimeContext
|
|
30
|
+
>;
|
|
31
|
+
|
|
32
|
+
export function getMergedRouterConfig(
|
|
33
|
+
api: TanstackRouterPluginAPI,
|
|
34
|
+
userConfig: Partial<RouterConfig>,
|
|
35
|
+
): RouterConfig {
|
|
36
|
+
const pluginConfig = api.getRuntimeConfig() as {
|
|
37
|
+
router?: Partial<RouterConfig>;
|
|
38
|
+
};
|
|
39
|
+
return merge(pluginConfig.router || {}, userConfig) as RouterConfig;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function getFinalRouteConfig(mergedConfig: RouterConfig) {
|
|
43
|
+
return {
|
|
44
|
+
routes: getGlobalRoutes(),
|
|
45
|
+
globalApp: getGlobalLayoutApp(),
|
|
46
|
+
...mergedConfig.routesConfig,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Registers the TanStack router provider with the @modern-js/runtime router
|
|
3
|
+
* provider registry. Importing '@modern-js/plugin-tanstack/runtime' is enough
|
|
4
|
+
* to make `runtime.router.framework: 'tanstack'` resolvable by the built-in
|
|
5
|
+
* router runtime plugin.
|
|
6
|
+
*
|
|
7
|
+
* This module is intentionally side-effectful (see `sideEffects` in
|
|
8
|
+
* package.json).
|
|
9
|
+
*/
|
|
10
|
+
import {
|
|
11
|
+
type RouterProviderFactory,
|
|
12
|
+
type RouterProviderPlugin,
|
|
13
|
+
registerRouterProvider,
|
|
14
|
+
} from '@modern-js/runtime/context';
|
|
15
|
+
import { Form, RouteActionResponseError, useFetcher } from './dataMutation';
|
|
16
|
+
import { Outlet } from './outlet';
|
|
17
|
+
import { tanstackRouterPlugin } from './plugin';
|
|
18
|
+
import { Link, NavLink } from './prefetchLink';
|
|
19
|
+
|
|
20
|
+
// The TanStack runtime plugin types its API against its own hook registry,
|
|
21
|
+
// while the provider contract is typed against the built-in router hook
|
|
22
|
+
// registry of @modern-js/runtime. The two are runtime-compatible (the
|
|
23
|
+
// built-in router plugin registers the hooks and forwards its API to the
|
|
24
|
+
// resolved provider), but nominally distinct — hence the explicit adapter
|
|
25
|
+
// cast at this single boundary.
|
|
26
|
+
const tanstackRouterProviderFactory: RouterProviderFactory = userConfig =>
|
|
27
|
+
tanstackRouterPlugin(userConfig) as unknown as RouterProviderPlugin;
|
|
28
|
+
|
|
29
|
+
registerRouterProvider('tanstack', tanstackRouterProviderFactory);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Compatibility bindings for the deprecated `@modern-js/runtime/tanstack-router`
|
|
33
|
+
* alias. `@modern-js/runtime` cannot depend on this package (the dependency
|
|
34
|
+
* direction is plugin-tanstack -> runtime), so the alias resolves the
|
|
35
|
+
* Modern.js specific bindings through this `Symbol.for` slot at use time.
|
|
36
|
+
*
|
|
37
|
+
* `??=` keeps the first copy: when Module Federation evaluates a second
|
|
38
|
+
* bundled copy of this module, both copies are functionally identical and the
|
|
39
|
+
* established registration wins (mirroring the router-provider registry).
|
|
40
|
+
*/
|
|
41
|
+
const COMPAT_BINDINGS_SLOT: unique symbol = Symbol.for(
|
|
42
|
+
'@modern-js/plugin-tanstack:runtime-compat-bindings',
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
export const tanstackRouterCompatBindings = {
|
|
46
|
+
Form,
|
|
47
|
+
Link,
|
|
48
|
+
NavLink,
|
|
49
|
+
Outlet,
|
|
50
|
+
RouteActionResponseError,
|
|
51
|
+
useFetcher,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
(
|
|
55
|
+
globalThis as {
|
|
56
|
+
[COMPAT_BINDINGS_SLOT]?: typeof tanstackRouterCompatBindings;
|
|
57
|
+
}
|
|
58
|
+
)[COMPAT_BINDINGS_SLOT] ??= tanstackRouterCompatBindings;
|