@octanejs/tanstack-start 0.1.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 +22 -0
- package/README.md +52 -0
- package/THIRD_PARTY_NOTICES.md +11 -0
- package/package.json +149 -0
- package/src/client-only.d.ts +1 -0
- package/src/client-only.js +0 -0
- package/src/client-rpc.d.ts +1 -0
- package/src/client-rpc.js +1 -0
- package/src/client.d.ts +3 -0
- package/src/client.js +2 -0
- package/src/default-entry/client.js +12 -0
- package/src/default-entry/server.js +13 -0
- package/src/default-entry/start.js +1 -0
- package/src/default-entry-paths.d.ts +5 -0
- package/src/default-entry-paths.js +11 -0
- package/src/index.d.ts +11 -0
- package/src/index.js +22 -0
- package/src/internal/README.md +15 -0
- package/src/internal/router-generator/config.d.ts +255 -0
- package/src/internal/router-generator/config.js +134 -0
- package/src/internal/router-generator/filesystem/physical/getRouteNodes.d.ts +53 -0
- package/src/internal/router-generator/filesystem/physical/getRouteNodes.js +335 -0
- package/src/internal/router-generator/filesystem/physical/rootPathId.d.ts +1 -0
- package/src/internal/router-generator/filesystem/physical/rootPathId.js +4 -0
- package/src/internal/router-generator/filesystem/virtual/config.d.ts +3 -0
- package/src/internal/router-generator/filesystem/virtual/config.js +36 -0
- package/src/internal/router-generator/filesystem/virtual/getRouteNodes.d.ts +31 -0
- package/src/internal/router-generator/filesystem/virtual/getRouteNodes.js +272 -0
- package/src/internal/router-generator/filesystem/virtual/loadConfigFile.d.ts +1 -0
- package/src/internal/router-generator/filesystem/virtual/loadConfigFile.js +10 -0
- package/src/internal/router-generator/generator.d.ts +119 -0
- package/src/internal/router-generator/generator.js +1080 -0
- package/src/internal/router-generator/index.d.ts +40 -0
- package/src/internal/router-generator/index.js +49 -0
- package/src/internal/router-generator/logger.d.ts +8 -0
- package/src/internal/router-generator/logger.js +30 -0
- package/src/internal/router-generator/plugin/types.d.ts +37 -0
- package/src/internal/router-generator/template.d.ts +38 -0
- package/src/internal/router-generator/template.js +220 -0
- package/src/internal/router-generator/transform/transform.d.ts +8 -0
- package/src/internal/router-generator/transform/transform.js +385 -0
- package/src/internal/router-generator/transform/types.d.ts +34 -0
- package/src/internal/router-generator/types.d.ts +73 -0
- package/src/internal/router-generator/utils.d.ts +270 -0
- package/src/internal/router-generator/utils.js +864 -0
- package/src/internal/router-generator/validate-route-params.d.ts +13 -0
- package/src/internal/router-generator/validate-route-params.js +75 -0
- package/src/internal/router-plugin/context.d.ts +2 -0
- package/src/internal/router-plugin/context.js +2 -0
- package/src/internal/router-plugin/core/code-splitter/compilers.d.ts +69 -0
- package/src/internal/router-plugin/core/code-splitter/compilers.js +1042 -0
- package/src/internal/router-plugin/core/code-splitter/framework-options.d.ts +11 -0
- package/src/internal/router-plugin/core/code-splitter/framework-options.js +41 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/framework-plugins.d.ts +12 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/framework-plugins.js +35 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/octane-hmr-split-route-components.d.ts +5 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/octane-hmr-split-route-components.js +106 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/octane-split-route-components.d.ts +8 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/octane-split-route-components.js +85 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/react-refresh-ignored-route-exports.d.ts +2 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/react-refresh-ignored-route-exports.js +55 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/react-refresh-route-components.d.ts +2 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/react-refresh-route-components.js +50 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/react-stable-hmr-split-route-components.d.ts +5 -0
- package/src/internal/router-plugin/core/code-splitter/plugins/react-stable-hmr-split-route-components.js +54 -0
- package/src/internal/router-plugin/core/code-splitter/plugins.d.ts +62 -0
- package/src/internal/router-plugin/core/code-splitter/types.d.ts +9 -0
- package/src/internal/router-plugin/core/config.d.ts +294 -0
- package/src/internal/router-plugin/core/config.js +56 -0
- package/src/internal/router-plugin/core/constants.d.ts +12 -0
- package/src/internal/router-plugin/core/constants.js +13 -0
- package/src/internal/router-plugin/core/framework-plugin-order.d.ts +8 -0
- package/src/internal/router-plugin/core/framework-plugin-order.js +78 -0
- package/src/internal/router-plugin/core/hmr/handle-route-update.d.ts +1 -0
- package/src/internal/router-plugin/core/hmr/handle-route-update.js +126 -0
- package/src/internal/router-plugin/core/hmr/index.d.ts +5 -0
- package/src/internal/router-plugin/core/hmr/select-adapter.d.ts +17 -0
- package/src/internal/router-plugin/core/hmr/select-adapter.js +24 -0
- package/src/internal/router-plugin/core/hmr/vite-adapter.d.ts +18 -0
- package/src/internal/router-plugin/core/hmr/vite-adapter.js +73 -0
- package/src/internal/router-plugin/core/hmr/webpack-adapter.d.ts +22 -0
- package/src/internal/router-plugin/core/hmr/webpack-adapter.js +78 -0
- package/src/internal/router-plugin/core/router-code-splitter-plugin.d.ts +10 -0
- package/src/internal/router-plugin/core/router-code-splitter-plugin.js +244 -0
- package/src/internal/router-plugin/core/router-composed-plugin.d.ts +5 -0
- package/src/internal/router-plugin/core/router-composed-plugin.js +62 -0
- package/src/internal/router-plugin/core/router-generator-plugin.d.ts +10 -0
- package/src/internal/router-plugin/core/router-generator-plugin.js +125 -0
- package/src/internal/router-plugin/core/router-hmr-plugin.d.ts +13 -0
- package/src/internal/router-plugin/core/router-hmr-plugin.js +101 -0
- package/src/internal/router-plugin/core/router-plugin-context.d.ts +5 -0
- package/src/internal/router-plugin/core/router-plugin-context.js +6 -0
- package/src/internal/router-plugin/core/utils.d.ts +17 -0
- package/src/internal/router-plugin/core/utils.js +47 -0
- package/src/internal/router-plugin/esbuild.d.ts +197 -0
- package/src/internal/router-plugin/esbuild.js +58 -0
- package/src/internal/router-plugin/index.d.ts +19 -0
- package/src/internal/router-plugin/index.js +17 -0
- package/src/internal/router-plugin/rspack.d.ts +61 -0
- package/src/internal/router-plugin/rspack.js +92 -0
- package/src/internal/router-plugin/vite.d.ts +201 -0
- package/src/internal/router-plugin/vite.js +62 -0
- package/src/internal/router-plugin/webpack.d.ts +50 -0
- package/src/internal/router-plugin/webpack.js +77 -0
- package/src/internal/start-plugin-core/build-sitemap.d.ts +34 -0
- package/src/internal/start-plugin-core/build-sitemap.js +125 -0
- package/src/internal/start-plugin-core/config-context.d.ts +30 -0
- package/src/internal/start-plugin-core/config-context.js +89 -0
- package/src/internal/start-plugin-core/constants.d.ts +20 -0
- package/src/internal/start-plugin-core/constants.js +24 -0
- package/src/internal/start-plugin-core/debug.d.ts +1 -0
- package/src/internal/start-plugin-core/hydrate-when-transform.d.ts +5 -0
- package/src/internal/start-plugin-core/hydrate-when-transform.js +661 -0
- package/src/internal/start-plugin-core/hydration-constants.d.ts +1 -0
- package/src/internal/start-plugin-core/hydration-constants.js +4 -0
- package/src/internal/start-plugin-core/import-protection/adapterUtils.d.ts +40 -0
- package/src/internal/start-plugin-core/import-protection/adapterUtils.js +42 -0
- package/src/internal/start-plugin-core/import-protection/analysis.d.ts +63 -0
- package/src/internal/start-plugin-core/import-protection/analysis.js +533 -0
- package/src/internal/start-plugin-core/import-protection/constants.d.ts +11 -0
- package/src/internal/start-plugin-core/import-protection/constants.js +39 -0
- package/src/internal/start-plugin-core/import-protection/defaults.d.ts +19 -0
- package/src/internal/start-plugin-core/import-protection/defaults.js +34 -0
- package/src/internal/start-plugin-core/import-protection/extensionlessAbsoluteIdResolver.d.ts +22 -0
- package/src/internal/start-plugin-core/import-protection/extensionlessAbsoluteIdResolver.js +94 -0
- package/src/internal/start-plugin-core/import-protection/matchers.d.ts +18 -0
- package/src/internal/start-plugin-core/import-protection/matchers.js +39 -0
- package/src/internal/start-plugin-core/import-protection/rewrite.d.ts +29 -0
- package/src/internal/start-plugin-core/import-protection/rewrite.js +184 -0
- package/src/internal/start-plugin-core/import-protection/sourceLocation.d.ts +170 -0
- package/src/internal/start-plugin-core/import-protection/sourceLocation.js +376 -0
- package/src/internal/start-plugin-core/import-protection/trace.d.ts +89 -0
- package/src/internal/start-plugin-core/import-protection/trace.js +186 -0
- package/src/internal/start-plugin-core/import-protection/utils.d.ts +78 -0
- package/src/internal/start-plugin-core/import-protection/utils.js +171 -0
- package/src/internal/start-plugin-core/import-protection/virtualModules.d.ts +38 -0
- package/src/internal/start-plugin-core/import-protection/virtualModules.js +241 -0
- package/src/internal/start-plugin-core/index.d.ts +8 -0
- package/src/internal/start-plugin-core/index.js +2 -0
- package/src/internal/start-plugin-core/planning.d.ts +44 -0
- package/src/internal/start-plugin-core/planning.js +98 -0
- package/src/internal/start-plugin-core/post-build.d.ts +12 -0
- package/src/internal/start-plugin-core/post-build.js +40 -0
- package/src/internal/start-plugin-core/prerender.d.ts +17 -0
- package/src/internal/start-plugin-core/prerender.js +172 -0
- package/src/internal/start-plugin-core/queue.d.ts +37 -0
- package/src/internal/start-plugin-core/queue.js +118 -0
- package/src/internal/start-plugin-core/resolve-entries.d.ts +10 -0
- package/src/internal/start-plugin-core/resolve-entries.js +32 -0
- package/src/internal/start-plugin-core/schema.d.ts +1799 -0
- package/src/internal/start-plugin-core/schema.js +252 -0
- package/src/internal/start-plugin-core/serialization-adapters-module.d.ts +18 -0
- package/src/internal/start-plugin-core/serialization-adapters-module.js +37 -0
- package/src/internal/start-plugin-core/start-compiler/compiler.d.ts +181 -0
- package/src/internal/start-plugin-core/start-compiler/compiler.js +1078 -0
- package/src/internal/start-plugin-core/start-compiler/config.d.ts +20 -0
- package/src/internal/start-plugin-core/start-compiler/config.js +84 -0
- package/src/internal/start-plugin-core/start-compiler/handleClientOnlyJSX.d.ts +24 -0
- package/src/internal/start-plugin-core/start-compiler/handleClientOnlyJSX.js +25 -0
- package/src/internal/start-plugin-core/start-compiler/handleCreateIsomorphicFn.d.ts +11 -0
- package/src/internal/start-plugin-core/start-compiler/handleCreateIsomorphicFn.js +24 -0
- package/src/internal/start-plugin-core/start-compiler/handleCreateMiddleware.d.ts +11 -0
- package/src/internal/start-plugin-core/start-compiler/handleCreateMiddleware.js +35 -0
- package/src/internal/start-plugin-core/start-compiler/handleCreateServerFn.d.ts +22 -0
- package/src/internal/start-plugin-core/start-compiler/handleCreateServerFn.js +292 -0
- package/src/internal/start-plugin-core/start-compiler/handleEnvOnly.d.ts +14 -0
- package/src/internal/start-plugin-core/start-compiler/handleEnvOnly.js +41 -0
- package/src/internal/start-plugin-core/start-compiler/host.d.ts +44 -0
- package/src/internal/start-plugin-core/start-compiler/host.js +75 -0
- package/src/internal/start-plugin-core/start-compiler/server-fn-resolver-module.d.ts +10 -0
- package/src/internal/start-plugin-core/start-compiler/server-fn-resolver-module.js +87 -0
- package/src/internal/start-plugin-core/start-compiler/types.d.ts +119 -0
- package/src/internal/start-plugin-core/start-compiler/utils.d.ts +27 -0
- package/src/internal/start-plugin-core/start-compiler/utils.js +36 -0
- package/src/internal/start-plugin-core/start-manifest-plugin/inlineCss.d.ts +16 -0
- package/src/internal/start-plugin-core/start-manifest-plugin/inlineCss.js +131 -0
- package/src/internal/start-plugin-core/start-manifest-plugin/manifestBuilder.d.ts +64 -0
- package/src/internal/start-plugin-core/start-manifest-plugin/manifestBuilder.js +441 -0
- package/src/internal/start-plugin-core/start-router-plugin/constants.d.ts +1 -0
- package/src/internal/start-plugin-core/start-router-plugin/constants.js +4 -0
- package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/compose-generator-plugins.d.ts +6 -0
- package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/compose-generator-plugins.js +6 -0
- package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/prerender-routes-plugin.d.ts +6 -0
- package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/prerender-routes-plugin.js +27 -0
- package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/routes-manifest-plugin.d.ts +6 -0
- package/src/internal/start-plugin-core/start-router-plugin/generator-plugins/routes-manifest-plugin.js +34 -0
- package/src/internal/start-plugin-core/start-router-plugin/pruneServerOnlySubtrees.d.ts +11 -0
- package/src/internal/start-plugin-core/start-router-plugin/pruneServerOnlySubtrees.js +42 -0
- package/src/internal/start-plugin-core/start-router-plugin/route-tree-footer.d.ts +6 -0
- package/src/internal/start-plugin-core/start-router-plugin/route-tree-footer.js +59 -0
- package/src/internal/start-plugin-core/types.d.ts +135 -0
- package/src/internal/start-plugin-core/types.js +4 -0
- package/src/internal/start-plugin-core/utils.d.ts +13 -0
- package/src/internal/start-plugin-core/utils.js +42 -0
- package/src/internal/start-plugin-core/vite/createVirtualModule.d.ts +15 -0
- package/src/internal/start-plugin-core/vite/createVirtualModule.js +27 -0
- package/src/internal/start-plugin-core/vite/dev-server-plugin/dev-styles.d.ts +26 -0
- package/src/internal/start-plugin-core/vite/dev-server-plugin/dev-styles.js +165 -0
- package/src/internal/start-plugin-core/vite/dev-server-plugin/plugin.d.ts +11 -0
- package/src/internal/start-plugin-core/vite/dev-server-plugin/plugin.js +170 -0
- package/src/internal/start-plugin-core/vite/import-protection-plugin/plugin.d.ts +4 -0
- package/src/internal/start-plugin-core/vite/import-protection-plugin/plugin.js +1553 -0
- package/src/internal/start-plugin-core/vite/import-protection-plugin/types.d.ts +103 -0
- package/src/internal/start-plugin-core/vite/import-protection-plugin/virtualModules.d.ts +40 -0
- package/src/internal/start-plugin-core/vite/import-protection-plugin/virtualModules.js +68 -0
- package/src/internal/start-plugin-core/vite/index.d.ts +13 -0
- package/src/internal/start-plugin-core/vite/index.js +4 -0
- package/src/internal/start-plugin-core/vite/load-env-plugin/plugin.d.ts +2 -0
- package/src/internal/start-plugin-core/vite/load-env-plugin/plugin.js +13 -0
- package/src/internal/start-plugin-core/vite/output-directory.d.ts +7 -0
- package/src/internal/start-plugin-core/vite/output-directory.js +18 -0
- package/src/internal/start-plugin-core/vite/planning.d.ts +112 -0
- package/src/internal/start-plugin-core/vite/planning.js +152 -0
- package/src/internal/start-plugin-core/vite/plugin.d.ts +7 -0
- package/src/internal/start-plugin-core/vite/plugin.js +208 -0
- package/src/internal/start-plugin-core/vite/plugins.d.ts +17 -0
- package/src/internal/start-plugin-core/vite/plugins.js +72 -0
- package/src/internal/start-plugin-core/vite/post-server-build.d.ts +9 -0
- package/src/internal/start-plugin-core/vite/post-server-build.js +22 -0
- package/src/internal/start-plugin-core/vite/prerender.d.ts +9 -0
- package/src/internal/start-plugin-core/vite/prerender.js +52 -0
- package/src/internal/start-plugin-core/vite/preview-server-plugin/plugin.d.ts +2 -0
- package/src/internal/start-plugin-core/vite/preview-server-plugin/plugin.js +54 -0
- package/src/internal/start-plugin-core/vite/schema.d.ts +2423 -0
- package/src/internal/start-plugin-core/vite/schema.js +17 -0
- package/src/internal/start-plugin-core/vite/serialization-adapters-plugin.d.ts +5 -0
- package/src/internal/start-plugin-core/vite/serialization-adapters-plugin.js +63 -0
- package/src/internal/start-plugin-core/vite/start-compiler-plugin/hot-update.d.ts +5 -0
- package/src/internal/start-plugin-core/vite/start-compiler-plugin/hot-update.js +14 -0
- package/src/internal/start-plugin-core/vite/start-compiler-plugin/module-specifier.d.ts +5 -0
- package/src/internal/start-plugin-core/vite/start-compiler-plugin/module-specifier.js +25 -0
- package/src/internal/start-plugin-core/vite/start-compiler-plugin/plugin.d.ts +29 -0
- package/src/internal/start-plugin-core/vite/start-compiler-plugin/plugin.js +380 -0
- package/src/internal/start-plugin-core/vite/start-manifest-plugin/normalized-client-build.d.ts +11 -0
- package/src/internal/start-plugin-core/vite/start-manifest-plugin/normalized-client-build.js +114 -0
- package/src/internal/start-plugin-core/vite/start-manifest-plugin/plugin.d.ts +3 -0
- package/src/internal/start-plugin-core/vite/start-manifest-plugin/plugin.js +103 -0
- package/src/internal/start-plugin-core/vite/start-router-plugin/plugin.d.ts +9 -0
- package/src/internal/start-plugin-core/vite/start-router-plugin/plugin.js +143 -0
- package/src/internal/start-plugin-core/vite/types.d.ts +17 -0
- package/src/package-names.js +10 -0
- package/src/plugin-vite.d.ts +23 -0
- package/src/plugin-vite.js +62 -0
- package/src/runtime/client/StartClient.d.ts +11 -0
- package/src/runtime/client/StartClient.js +16 -0
- package/src/runtime/client/hydrateStart.d.ts +4 -0
- package/src/runtime/client/hydrateStart.js +30 -0
- package/src/runtime/server/StartServer.d.ts +10 -0
- package/src/runtime/server/StartServer.js +6 -0
- package/src/runtime/server/defaultRenderHandler.d.ts +3 -0
- package/src/runtime/server/defaultRenderHandler.js +11 -0
- package/src/runtime/server/defaultStreamHandler.d.ts +3 -0
- package/src/runtime/server/defaultStreamHandler.js +13 -0
- package/src/server-entry.d.ts +11 -0
- package/src/server-entry.js +13 -0
- package/src/server-only.d.ts +1 -0
- package/src/server-only.js +0 -0
- package/src/server-rpc.d.ts +1 -0
- package/src/server-rpc.js +1 -0
- package/src/server.d.ts +6 -0
- package/src/server.js +4 -0
- package/src/ssr-rpc.d.ts +1 -0
- package/src/ssr-rpc.js +1 -0
- package/src/use-server-fn.d.ts +3 -0
- package/src/use-server-fn.js +18 -0
- package/src/validate-options.js +7 -0
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { CreateFileRoute, RegisteredRouter, RouteIds } from '@tanstack/router-core';
|
|
3
|
+
import { CodeSplitGroupings } from './constants.js';
|
|
4
|
+
export declare const splitGroupingsSchema: z.ZodArray<
|
|
5
|
+
z.ZodArray<
|
|
6
|
+
z.ZodUnion<
|
|
7
|
+
readonly [
|
|
8
|
+
z.ZodLiteral<'loader'>,
|
|
9
|
+
z.ZodLiteral<'component'>,
|
|
10
|
+
z.ZodLiteral<'pendingComponent'>,
|
|
11
|
+
z.ZodLiteral<'errorComponent'>,
|
|
12
|
+
z.ZodLiteral<'notFoundComponent'>,
|
|
13
|
+
]
|
|
14
|
+
>
|
|
15
|
+
>
|
|
16
|
+
>;
|
|
17
|
+
export type CodeSplittingOptions = {
|
|
18
|
+
/**
|
|
19
|
+
* Use this function to programmatically control the code splitting behavior
|
|
20
|
+
* based on the `routeId` for each route.
|
|
21
|
+
*
|
|
22
|
+
* If you just need to change the default behavior, you can use the `defaultBehavior` option.
|
|
23
|
+
* @param params
|
|
24
|
+
*/
|
|
25
|
+
splitBehavior?: (params: {
|
|
26
|
+
routeId: RouteIds<RegisteredRouter['routeTree']>;
|
|
27
|
+
}) => CodeSplitGroupings | undefined | void;
|
|
28
|
+
/**
|
|
29
|
+
* The default/global configuration to control your code splitting behavior per route.
|
|
30
|
+
* @default [['component'],['pendingComponent'],['errorComponent'],['notFoundComponent']]
|
|
31
|
+
*/
|
|
32
|
+
defaultBehavior?: CodeSplitGroupings;
|
|
33
|
+
/**
|
|
34
|
+
* The nodes that shall be deleted from the route.
|
|
35
|
+
* @default undefined
|
|
36
|
+
*/
|
|
37
|
+
deleteNodes?: Array<DeletableNodes>;
|
|
38
|
+
/**
|
|
39
|
+
* @default true
|
|
40
|
+
*/
|
|
41
|
+
addHmr?: boolean;
|
|
42
|
+
};
|
|
43
|
+
export type HmrStyle = 'vite' | 'webpack';
|
|
44
|
+
export type HmrOptions = {
|
|
45
|
+
/**
|
|
46
|
+
* Selects the HMR runtime style to emit code for.
|
|
47
|
+
* - `'vite'` (default): ESM `import.meta.hot` with Vite accept-callback semantics.
|
|
48
|
+
* - `'webpack'`: `import.meta.webpackHot` with webpack / Rspack `module.hot` re-execution semantics.
|
|
49
|
+
*
|
|
50
|
+
* Bundler-specific plugin entries (e.g. `rspack.ts`, `webpack.ts`) set this explicitly.
|
|
51
|
+
*/
|
|
52
|
+
style?: HmrStyle;
|
|
53
|
+
};
|
|
54
|
+
type FileRouteKeys = keyof (Parameters<CreateFileRoute<any, any, any, any, any>>[0] & {});
|
|
55
|
+
export type DeletableNodes = FileRouteKeys | (string & {});
|
|
56
|
+
export declare const configSchema: z.ZodObject<
|
|
57
|
+
{
|
|
58
|
+
target: z.ZodDefault<
|
|
59
|
+
z.ZodOptional<
|
|
60
|
+
z.ZodEnum<{
|
|
61
|
+
vue: 'vue';
|
|
62
|
+
react: 'react';
|
|
63
|
+
solid: 'solid';
|
|
64
|
+
octane: 'octane';
|
|
65
|
+
}>
|
|
66
|
+
>
|
|
67
|
+
>;
|
|
68
|
+
virtualRouteConfig: z.ZodOptional<
|
|
69
|
+
z.ZodUnion<
|
|
70
|
+
[
|
|
71
|
+
z.ZodType<
|
|
72
|
+
import('@tanstack/virtual-file-routes').VirtualRootRoute,
|
|
73
|
+
unknown,
|
|
74
|
+
z.core.$ZodTypeInternals<
|
|
75
|
+
import('@tanstack/virtual-file-routes').VirtualRootRoute,
|
|
76
|
+
unknown
|
|
77
|
+
>
|
|
78
|
+
>,
|
|
79
|
+
z.ZodString,
|
|
80
|
+
]
|
|
81
|
+
>
|
|
82
|
+
>;
|
|
83
|
+
routeFilePrefix: z.ZodOptional<z.ZodString>;
|
|
84
|
+
routeFileIgnorePrefix: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
85
|
+
routeFileIgnorePattern: z.ZodOptional<z.ZodString>;
|
|
86
|
+
routesDirectory: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
87
|
+
quoteStyle: z.ZodDefault<
|
|
88
|
+
z.ZodOptional<
|
|
89
|
+
z.ZodEnum<{
|
|
90
|
+
single: 'single';
|
|
91
|
+
double: 'double';
|
|
92
|
+
}>
|
|
93
|
+
>
|
|
94
|
+
>;
|
|
95
|
+
semicolons: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
96
|
+
disableLogging: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
97
|
+
routeTreeFileHeader: z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>;
|
|
98
|
+
indexToken: z.ZodDefault<
|
|
99
|
+
z.ZodOptional<
|
|
100
|
+
z.ZodUnion<
|
|
101
|
+
readonly [
|
|
102
|
+
z.ZodString,
|
|
103
|
+
z.ZodCustom<RegExp, RegExp>,
|
|
104
|
+
z.ZodObject<
|
|
105
|
+
{
|
|
106
|
+
regex: z.ZodString;
|
|
107
|
+
flags: z.ZodOptional<z.ZodString>;
|
|
108
|
+
},
|
|
109
|
+
z.core.$strip
|
|
110
|
+
>,
|
|
111
|
+
]
|
|
112
|
+
>
|
|
113
|
+
>
|
|
114
|
+
>;
|
|
115
|
+
routeToken: z.ZodDefault<
|
|
116
|
+
z.ZodOptional<
|
|
117
|
+
z.ZodUnion<
|
|
118
|
+
readonly [
|
|
119
|
+
z.ZodString,
|
|
120
|
+
z.ZodCustom<RegExp, RegExp>,
|
|
121
|
+
z.ZodObject<
|
|
122
|
+
{
|
|
123
|
+
regex: z.ZodString;
|
|
124
|
+
flags: z.ZodOptional<z.ZodString>;
|
|
125
|
+
},
|
|
126
|
+
z.core.$strip
|
|
127
|
+
>,
|
|
128
|
+
]
|
|
129
|
+
>
|
|
130
|
+
>
|
|
131
|
+
>;
|
|
132
|
+
pathParamsAllowedCharacters: z.ZodOptional<
|
|
133
|
+
z.ZodArray<
|
|
134
|
+
z.ZodEnum<{
|
|
135
|
+
':': ':';
|
|
136
|
+
$: '$';
|
|
137
|
+
';': ';';
|
|
138
|
+
'@': '@';
|
|
139
|
+
'&': '&';
|
|
140
|
+
'=': '=';
|
|
141
|
+
'+': '+';
|
|
142
|
+
',': ',';
|
|
143
|
+
}>
|
|
144
|
+
>
|
|
145
|
+
>;
|
|
146
|
+
generatedRouteTree: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
147
|
+
disableTypes: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
148
|
+
addExtensions: z.ZodPipe<
|
|
149
|
+
z.ZodDefault<z.ZodOptional<z.ZodUnion<readonly [z.ZodBoolean, z.ZodString]>>>,
|
|
150
|
+
z.ZodTransform<string | boolean, string | boolean>
|
|
151
|
+
>;
|
|
152
|
+
enableRouteTreeFormatting: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
153
|
+
routeTreeFileFooter: z.ZodOptional<
|
|
154
|
+
z.ZodUnion<
|
|
155
|
+
readonly [
|
|
156
|
+
z.ZodDefault<z.ZodOptional<z.ZodArray<z.ZodString>>>,
|
|
157
|
+
z.ZodCustom<() => Array<string>, () => Array<string>>,
|
|
158
|
+
]
|
|
159
|
+
>
|
|
160
|
+
>;
|
|
161
|
+
autoCodeSplitting: z.ZodOptional<z.ZodBoolean>;
|
|
162
|
+
customScaffolding: z.ZodOptional<
|
|
163
|
+
z.ZodObject<
|
|
164
|
+
{
|
|
165
|
+
routeTemplate: z.ZodOptional<z.ZodString>;
|
|
166
|
+
lazyRouteTemplate: z.ZodOptional<z.ZodString>;
|
|
167
|
+
},
|
|
168
|
+
z.core.$strip
|
|
169
|
+
>
|
|
170
|
+
>;
|
|
171
|
+
experimental: z.ZodOptional<
|
|
172
|
+
z.ZodObject<
|
|
173
|
+
{
|
|
174
|
+
enableCodeSplitting: z.ZodOptional<z.ZodBoolean>;
|
|
175
|
+
},
|
|
176
|
+
z.core.$strip
|
|
177
|
+
>
|
|
178
|
+
>;
|
|
179
|
+
plugins: z.ZodOptional<
|
|
180
|
+
z.ZodArray<
|
|
181
|
+
z.ZodCustom<
|
|
182
|
+
import('#tanstack-start/router-generator').GeneratorPlugin,
|
|
183
|
+
import('#tanstack-start/router-generator').GeneratorPlugin
|
|
184
|
+
>
|
|
185
|
+
>
|
|
186
|
+
>;
|
|
187
|
+
tmpDir: z.ZodDefault<z.ZodOptional<z.ZodString>>;
|
|
188
|
+
importRoutesUsingAbsolutePaths: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
|
|
189
|
+
enableRouteGeneration: z.ZodOptional<z.ZodBoolean>;
|
|
190
|
+
codeSplittingOptions: z.ZodOptional<z.ZodCustom<CodeSplittingOptions, CodeSplittingOptions>>;
|
|
191
|
+
plugin: z.ZodOptional<
|
|
192
|
+
z.ZodObject<
|
|
193
|
+
{
|
|
194
|
+
hmr: z.ZodOptional<
|
|
195
|
+
z.ZodObject<
|
|
196
|
+
{
|
|
197
|
+
style: z.ZodOptional<
|
|
198
|
+
z.ZodEnum<{
|
|
199
|
+
vite: 'vite';
|
|
200
|
+
webpack: 'webpack';
|
|
201
|
+
}>
|
|
202
|
+
>;
|
|
203
|
+
},
|
|
204
|
+
z.core.$strip
|
|
205
|
+
>
|
|
206
|
+
>;
|
|
207
|
+
vite: z.ZodOptional<
|
|
208
|
+
z.ZodObject<
|
|
209
|
+
{
|
|
210
|
+
environmentName: z.ZodOptional<z.ZodString>;
|
|
211
|
+
},
|
|
212
|
+
z.core.$strip
|
|
213
|
+
>
|
|
214
|
+
>;
|
|
215
|
+
},
|
|
216
|
+
z.core.$strip
|
|
217
|
+
>
|
|
218
|
+
>;
|
|
219
|
+
},
|
|
220
|
+
z.core.$strip
|
|
221
|
+
>;
|
|
222
|
+
export declare const getConfig: (
|
|
223
|
+
inlineConfig: Partial<Config>,
|
|
224
|
+
root: string,
|
|
225
|
+
) => {
|
|
226
|
+
target: 'vue' | 'react' | 'solid' | 'octane';
|
|
227
|
+
routeFileIgnorePrefix: string;
|
|
228
|
+
routesDirectory: string;
|
|
229
|
+
quoteStyle: 'single' | 'double';
|
|
230
|
+
semicolons: boolean;
|
|
231
|
+
disableLogging: boolean;
|
|
232
|
+
routeTreeFileHeader: string[];
|
|
233
|
+
indexToken:
|
|
234
|
+
| string
|
|
235
|
+
| RegExp
|
|
236
|
+
| {
|
|
237
|
+
regex: string;
|
|
238
|
+
flags?: string | undefined;
|
|
239
|
+
};
|
|
240
|
+
routeToken:
|
|
241
|
+
| string
|
|
242
|
+
| RegExp
|
|
243
|
+
| {
|
|
244
|
+
regex: string;
|
|
245
|
+
flags?: string | undefined;
|
|
246
|
+
};
|
|
247
|
+
generatedRouteTree: string;
|
|
248
|
+
disableTypes: boolean;
|
|
249
|
+
addExtensions: string | boolean;
|
|
250
|
+
enableRouteTreeFormatting: boolean;
|
|
251
|
+
tmpDir: string;
|
|
252
|
+
importRoutesUsingAbsolutePaths: boolean;
|
|
253
|
+
virtualRouteConfig?:
|
|
254
|
+
| string
|
|
255
|
+
| import('@tanstack/virtual-file-routes').VirtualRootRoute
|
|
256
|
+
| undefined;
|
|
257
|
+
routeFilePrefix?: string | undefined;
|
|
258
|
+
routeFileIgnorePattern?: string | undefined;
|
|
259
|
+
pathParamsAllowedCharacters?: (':' | '$' | ';' | '@' | '&' | '=' | '+' | ',')[] | undefined;
|
|
260
|
+
routeTreeFileFooter?: string[] | (() => Array<string>) | undefined;
|
|
261
|
+
autoCodeSplitting?: boolean | undefined;
|
|
262
|
+
customScaffolding?:
|
|
263
|
+
| {
|
|
264
|
+
routeTemplate?: string | undefined;
|
|
265
|
+
lazyRouteTemplate?: string | undefined;
|
|
266
|
+
}
|
|
267
|
+
| undefined;
|
|
268
|
+
experimental?:
|
|
269
|
+
| {
|
|
270
|
+
enableCodeSplitting?: boolean | undefined;
|
|
271
|
+
}
|
|
272
|
+
| undefined;
|
|
273
|
+
plugins?: import('#tanstack-start/router-generator').GeneratorPlugin[] | undefined;
|
|
274
|
+
enableRouteGeneration?: boolean | undefined;
|
|
275
|
+
codeSplittingOptions?: CodeSplittingOptions | undefined;
|
|
276
|
+
plugin?:
|
|
277
|
+
| {
|
|
278
|
+
hmr?:
|
|
279
|
+
| {
|
|
280
|
+
style?: 'vite' | 'webpack' | undefined;
|
|
281
|
+
}
|
|
282
|
+
| undefined;
|
|
283
|
+
vite?:
|
|
284
|
+
| {
|
|
285
|
+
environmentName?: string | undefined;
|
|
286
|
+
}
|
|
287
|
+
| undefined;
|
|
288
|
+
}
|
|
289
|
+
| undefined;
|
|
290
|
+
};
|
|
291
|
+
export type Config = z.infer<typeof configSchema>;
|
|
292
|
+
export type ConfigInput = z.input<typeof configSchema>;
|
|
293
|
+
export type ConfigOutput = z.output<typeof configSchema>;
|
|
294
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { configSchema, getConfig } from '#tanstack-start/router-generator';
|
|
3
|
+
//#region src/core/config.ts
|
|
4
|
+
var splitGroupingsSchema = z
|
|
5
|
+
.array(
|
|
6
|
+
z.array(
|
|
7
|
+
z.union([
|
|
8
|
+
z.literal('loader'),
|
|
9
|
+
z.literal('component'),
|
|
10
|
+
z.literal('pendingComponent'),
|
|
11
|
+
z.literal('errorComponent'),
|
|
12
|
+
z.literal('notFoundComponent'),
|
|
13
|
+
]),
|
|
14
|
+
),
|
|
15
|
+
{
|
|
16
|
+
message:
|
|
17
|
+
" Must be an Array of Arrays containing the split groupings. i.e. [['component'], ['pendingComponent'], ['errorComponent', 'notFoundComponent']]",
|
|
18
|
+
},
|
|
19
|
+
)
|
|
20
|
+
.superRefine((val, ctx) => {
|
|
21
|
+
const flattened = val.flat();
|
|
22
|
+
if ([...new Set(flattened)].length !== flattened.length)
|
|
23
|
+
ctx.addIssue({
|
|
24
|
+
code: 'custom',
|
|
25
|
+
message: ` Split groupings must be unique and not repeated. i.e. i.e. [['component'], ['pendingComponent'], ['errorComponent', 'notFoundComponent']].\n You input was: ${JSON.stringify(val)}.`,
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var codeSplittingOptionsSchema = z.object({
|
|
29
|
+
splitBehavior: z.custom((value) => typeof value === 'function').optional(),
|
|
30
|
+
defaultBehavior: splitGroupingsSchema.optional(),
|
|
31
|
+
deleteNodes: z.array(z.string()).optional(),
|
|
32
|
+
addHmr: z.boolean().optional().default(true),
|
|
33
|
+
});
|
|
34
|
+
var configSchema$1 = configSchema.extend({
|
|
35
|
+
enableRouteGeneration: z.boolean().optional(),
|
|
36
|
+
codeSplittingOptions: z
|
|
37
|
+
.custom((v) => {
|
|
38
|
+
return codeSplittingOptionsSchema.parse(v);
|
|
39
|
+
})
|
|
40
|
+
.optional(),
|
|
41
|
+
plugin: z
|
|
42
|
+
.object({
|
|
43
|
+
hmr: z.object({ style: z.enum(['vite', 'webpack']).optional() }).optional(),
|
|
44
|
+
vite: z.object({ environmentName: z.string().optional() }).optional(),
|
|
45
|
+
})
|
|
46
|
+
.optional(),
|
|
47
|
+
});
|
|
48
|
+
var getConfig$1 = (inlineConfig, root) => {
|
|
49
|
+
const config = getConfig(inlineConfig, root);
|
|
50
|
+
return configSchema$1.parse({
|
|
51
|
+
...inlineConfig,
|
|
52
|
+
...config,
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
//#endregion
|
|
56
|
+
export { configSchema$1 as configSchema, getConfig$1 as getConfig, splitGroupingsSchema };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const tsrSplit = 'tsr-split';
|
|
2
|
+
export declare const tsrShared = 'tsr-shared';
|
|
3
|
+
export declare const splitRouteIdentNodes: readonly [
|
|
4
|
+
'loader',
|
|
5
|
+
'component',
|
|
6
|
+
'pendingComponent',
|
|
7
|
+
'errorComponent',
|
|
8
|
+
'notFoundComponent',
|
|
9
|
+
];
|
|
10
|
+
export type SplitRouteIdentNodes = (typeof splitRouteIdentNodes)[number];
|
|
11
|
+
export type CodeSplitGroupings = Array<Array<SplitRouteIdentNodes>>;
|
|
12
|
+
export declare const defaultCodeSplitGroupings: CodeSplitGroupings;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/core/constants.ts
|
|
2
|
+
var tsrSplit = 'tsr-split';
|
|
3
|
+
var tsrShared = 'tsr-shared';
|
|
4
|
+
var splitRouteIdentNodes = [
|
|
5
|
+
'loader',
|
|
6
|
+
'component',
|
|
7
|
+
'pendingComponent',
|
|
8
|
+
'errorComponent',
|
|
9
|
+
'notFoundComponent',
|
|
10
|
+
];
|
|
11
|
+
var defaultCodeSplitGroupings = [['component'], ['errorComponent'], ['notFoundComponent']];
|
|
12
|
+
//#endregion
|
|
13
|
+
export { defaultCodeSplitGroupings, splitRouteIdentNodes, tsrShared, tsrSplit };
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
//#region src/core/framework-plugin-order.ts
|
|
2
|
+
/**
|
|
3
|
+
* Framework source transformation plugins and their required ordering relative
|
|
4
|
+
* to route analysis.
|
|
5
|
+
*/
|
|
6
|
+
var TRANSFORMATION_PLUGINS_BY_FRAMEWORK = {
|
|
7
|
+
react: [
|
|
8
|
+
{
|
|
9
|
+
pluginNames: ['vite:react-babel', 'vite:react-refresh'],
|
|
10
|
+
pkg: '@vitejs/plugin-react',
|
|
11
|
+
usage: 'react()',
|
|
12
|
+
order: 'after-router',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
pluginNames: ['vite:react-swc', 'vite:react-swc:resolve-runtime'],
|
|
16
|
+
pkg: '@vitejs/plugin-react-swc',
|
|
17
|
+
usage: 'reactSwc()',
|
|
18
|
+
order: 'after-router',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
pluginNames: ['vite:react-oxc:config', 'vite:react-oxc:refresh-runtime'],
|
|
22
|
+
pkg: '@vitejs/plugin-react-oxc',
|
|
23
|
+
usage: 'reactOxc()',
|
|
24
|
+
order: 'after-router',
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
solid: [
|
|
28
|
+
{
|
|
29
|
+
pluginNames: ['solid'],
|
|
30
|
+
pkg: 'vite-plugin-solid',
|
|
31
|
+
usage: 'solid()',
|
|
32
|
+
order: 'after-router',
|
|
33
|
+
},
|
|
34
|
+
],
|
|
35
|
+
octane: [
|
|
36
|
+
{
|
|
37
|
+
pluginNames: ['octane'],
|
|
38
|
+
pkg: 'octane/compiler/vite',
|
|
39
|
+
usage: 'octane()',
|
|
40
|
+
order: 'before-router',
|
|
41
|
+
required: true,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
};
|
|
45
|
+
function validateFrameworkPluginOrder(opts) {
|
|
46
|
+
const routerPluginIndex = opts.plugins.findIndex(
|
|
47
|
+
(plugin) => plugin.name === opts.routerPluginName,
|
|
48
|
+
);
|
|
49
|
+
if (routerPluginIndex === -1) return;
|
|
50
|
+
const frameworkPlugins = TRANSFORMATION_PLUGINS_BY_FRAMEWORK[opts.framework];
|
|
51
|
+
if (!frameworkPlugins) return;
|
|
52
|
+
for (const transformPlugin of frameworkPlugins) {
|
|
53
|
+
const transformPluginIndex = opts.plugins.findIndex((plugin) =>
|
|
54
|
+
transformPlugin.pluginNames.includes(plugin.name),
|
|
55
|
+
);
|
|
56
|
+
if (transformPluginIndex === -1) {
|
|
57
|
+
if (transformPlugin.required)
|
|
58
|
+
throw new Error(
|
|
59
|
+
`Plugin setup error: '${transformPlugin.pkg}' is required for the '${opts.framework}' target.\n\nPlease update your Vite config:\n\n plugins: [\n ${transformPlugin.usage},\n tanstackRouter(),\n ]\n`,
|
|
60
|
+
);
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
const shouldComeBeforeRouter = transformPlugin.order === 'before-router';
|
|
64
|
+
if (
|
|
65
|
+
!(shouldComeBeforeRouter
|
|
66
|
+
? transformPluginIndex > routerPluginIndex
|
|
67
|
+
: transformPluginIndex < routerPluginIndex)
|
|
68
|
+
)
|
|
69
|
+
continue;
|
|
70
|
+
const firstPlugin = shouldComeBeforeRouter ? transformPlugin.usage : 'tanstackRouter()';
|
|
71
|
+
const secondPlugin = shouldComeBeforeRouter ? 'tanstackRouter()' : transformPlugin.usage;
|
|
72
|
+
throw new Error(
|
|
73
|
+
`Plugin order error: '${transformPlugin.pkg}' is placed ${shouldComeBeforeRouter ? 'after' : 'before'} the TanStack Router integration.\n\n${shouldComeBeforeRouter ? 'This framework compiler must lower its source syntax before TanStack Router analyzes route modules.' : 'The TanStack Router integration must analyze route modules before JSX transformation plugins.'}\n\nPlease update your Vite config:\n\n plugins: [\n ${firstPlugin},\n ${secondPlugin},\n ]\n`,
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
export { validateFrameworkPluginOrder };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getHandleRouteUpdateCode(stableRouteOptionKeys: Array<string>): string;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
//#region src/core/hmr/handle-route-update.ts
|
|
2
|
+
function handleRouteUpdate(routeId, newRoute, shouldApplyRouteUpdate = true) {
|
|
3
|
+
const router = window.__TSR_ROUTER__;
|
|
4
|
+
const oldRoute = router.routesById[routeId];
|
|
5
|
+
if (!oldRoute) return;
|
|
6
|
+
if (!shouldApplyRouteUpdate) {
|
|
7
|
+
syncHotRouteExport(oldRoute);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const generatedRouteOptionKeys = new Set(['id', 'path', 'getParentRoute']);
|
|
11
|
+
const generatedRouteOptions = {};
|
|
12
|
+
generatedRouteOptionKeys.forEach((key) => {
|
|
13
|
+
if (key in oldRoute.options) generatedRouteOptions[key] = oldRoute.options[key];
|
|
14
|
+
});
|
|
15
|
+
const removedKeys = /* @__PURE__ */ new Set();
|
|
16
|
+
Object.keys(oldRoute.options).forEach((key) => {
|
|
17
|
+
if (!generatedRouteOptionKeys.has(key) && !(key in newRoute.options)) {
|
|
18
|
+
removedKeys.add(key);
|
|
19
|
+
delete oldRoute.options[key];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
const preserveComponentIdentity =
|
|
23
|
+
'shellComponent' in oldRoute.options === 'shellComponent' in newRoute.options;
|
|
24
|
+
const componentKeys = '__TSR_COMPONENT_TYPES__';
|
|
25
|
+
if (preserveComponentIdentity)
|
|
26
|
+
componentKeys.forEach((key) => {
|
|
27
|
+
if (key in oldRoute.options && key in newRoute.options)
|
|
28
|
+
newRoute.options[key] = oldRoute.options[key];
|
|
29
|
+
});
|
|
30
|
+
const nextOptions = {
|
|
31
|
+
...newRoute.options,
|
|
32
|
+
...generatedRouteOptions,
|
|
33
|
+
};
|
|
34
|
+
oldRoute.options = nextOptions;
|
|
35
|
+
oldRoute.update(nextOptions);
|
|
36
|
+
oldRoute._componentsPromise = void 0;
|
|
37
|
+
oldRoute._lazyPromise = void 0;
|
|
38
|
+
router.setRoutes(router.buildRouteTree());
|
|
39
|
+
syncHotRouteExport(oldRoute);
|
|
40
|
+
router.resolvePathCache.clear();
|
|
41
|
+
const filter = (m) => m.routeId === oldRoute.id;
|
|
42
|
+
const activeMatch = router.stores.matches.get().find(filter);
|
|
43
|
+
const pendingMatch = router.stores.pendingMatches.get().find(filter);
|
|
44
|
+
const cachedMatches = router.stores.cachedMatches.get().filter(filter);
|
|
45
|
+
if (activeMatch || pendingMatch || cachedMatches.length > 0) {
|
|
46
|
+
if (removedKeys.has('loader') || removedKeys.has('beforeLoad')) {
|
|
47
|
+
const matchIds = [
|
|
48
|
+
activeMatch?.id,
|
|
49
|
+
pendingMatch?.id,
|
|
50
|
+
...cachedMatches.map((match) => match.id),
|
|
51
|
+
].filter(Boolean);
|
|
52
|
+
router.batch(() => {
|
|
53
|
+
for (const matchId of matchIds) {
|
|
54
|
+
const store =
|
|
55
|
+
router.stores.pendingMatchStores.get(matchId) ||
|
|
56
|
+
router.stores.matchStores.get(matchId) ||
|
|
57
|
+
router.stores.cachedMatchStores.get(matchId);
|
|
58
|
+
if (store)
|
|
59
|
+
store.set((prev) => {
|
|
60
|
+
const next = { ...prev };
|
|
61
|
+
if (removedKeys.has('loader')) next.loaderData = void 0;
|
|
62
|
+
if (removedKeys.has('beforeLoad')) {
|
|
63
|
+
next.__beforeLoadContext = void 0;
|
|
64
|
+
next.context = rebuildMatchContextWithoutBeforeLoad(next);
|
|
65
|
+
}
|
|
66
|
+
return next;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
router.invalidate({
|
|
72
|
+
filter,
|
|
73
|
+
sync: true,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
function syncHotRouteExport(liveRoute) {
|
|
77
|
+
newRoute.options = liveRoute.options;
|
|
78
|
+
newRoute.parentRoute = liveRoute.parentRoute;
|
|
79
|
+
newRoute._path = liveRoute._path;
|
|
80
|
+
newRoute._id = liveRoute._id;
|
|
81
|
+
newRoute._fullPath = liveRoute._fullPath;
|
|
82
|
+
newRoute._to = liveRoute._to;
|
|
83
|
+
}
|
|
84
|
+
function getStoreMatch(matchId) {
|
|
85
|
+
return (
|
|
86
|
+
router.stores.pendingMatchStores.get(matchId)?.get() ||
|
|
87
|
+
router.stores.matchStores.get(matchId)?.get() ||
|
|
88
|
+
router.stores.cachedMatchStores.get(matchId)?.get()
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
function getMatchList(matchId) {
|
|
92
|
+
const pendingMatches = router.stores.pendingMatches.get();
|
|
93
|
+
if (pendingMatches.some((match) => match.id === matchId)) return pendingMatches;
|
|
94
|
+
const activeMatches = router.stores.matches.get();
|
|
95
|
+
if (activeMatches.some((match) => match.id === matchId)) return activeMatches;
|
|
96
|
+
const cachedMatches = router.stores.cachedMatches.get();
|
|
97
|
+
if (cachedMatches.some((match) => match.id === matchId)) return cachedMatches;
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
function getParentMatch(match) {
|
|
101
|
+
const matchList = getMatchList(match.id);
|
|
102
|
+
const matchIndex = matchList.findIndex((item) => item.id === match.id);
|
|
103
|
+
if (matchIndex <= 0) return;
|
|
104
|
+
const parentMatch = matchList[matchIndex - 1];
|
|
105
|
+
return getStoreMatch(parentMatch.id) || parentMatch;
|
|
106
|
+
}
|
|
107
|
+
function rebuildMatchContextWithoutBeforeLoad(match) {
|
|
108
|
+
const parentMatch = getParentMatch(match);
|
|
109
|
+
const getParentContext = router.getParentContext;
|
|
110
|
+
return {
|
|
111
|
+
...((getParentContext
|
|
112
|
+
? getParentContext.call(router, parentMatch)
|
|
113
|
+
: (parentMatch?.context ?? router.options.context)) ?? {}),
|
|
114
|
+
...(match.__routeContext ?? {}),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
var handleRouteUpdateStr = handleRouteUpdate.toString();
|
|
119
|
+
function getHandleRouteUpdateCode(stableRouteOptionKeys) {
|
|
120
|
+
return handleRouteUpdateStr.replace(
|
|
121
|
+
/['"]__TSR_COMPONENT_TYPES__['"]/,
|
|
122
|
+
JSON.stringify(stableRouteOptionKeys),
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
//#endregion
|
|
126
|
+
export { getHandleRouteUpdateCode };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { createRouteHmrStatement } from './select-adapter.js';
|
|
2
|
+
export type { CreateRouteHmrStatementOpts } from './select-adapter.js';
|
|
3
|
+
export { createViteHmrStatement } from './vite-adapter.js';
|
|
4
|
+
export { createWebpackHmrStatement } from './webpack-adapter.js';
|
|
5
|
+
export { getHandleRouteUpdateCode } from './handle-route-update.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Config, HmrStyle } from '../config.js';
|
|
2
|
+
import type * as t from '@babel/types';
|
|
3
|
+
export type CreateRouteHmrStatementOpts = {
|
|
4
|
+
hmrStyle: HmrStyle;
|
|
5
|
+
targetFramework: Config['target'];
|
|
6
|
+
routeId?: string;
|
|
7
|
+
routeSignature?: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Dispatches to the configured HMR adapter. `hmrStyle` is set explicitly by
|
|
11
|
+
* the bundler-specific plugin entry (e.g. `rspack.ts` → `'webpack'`), so there
|
|
12
|
+
* is no runtime inference based on config string shapes.
|
|
13
|
+
*/
|
|
14
|
+
export declare function createRouteHmrStatement(
|
|
15
|
+
stableRouteOptionKeys: Array<string>,
|
|
16
|
+
opts: CreateRouteHmrStatementOpts,
|
|
17
|
+
): Array<t.Statement>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createViteHmrStatement } from './vite-adapter.js';
|
|
2
|
+
import { createWebpackHmrStatement } from './webpack-adapter.js';
|
|
3
|
+
//#region src/core/hmr/select-adapter.ts
|
|
4
|
+
/**
|
|
5
|
+
* Dispatches to the configured HMR adapter. `hmrStyle` is set explicitly by
|
|
6
|
+
* the bundler-specific plugin entry (e.g. `rspack.ts` → `'webpack'`), so there
|
|
7
|
+
* is no runtime inference based on config string shapes.
|
|
8
|
+
*/
|
|
9
|
+
function createRouteHmrStatement(stableRouteOptionKeys, opts) {
|
|
10
|
+
const routeId = opts.routeId === '/__root' ? '__root__' : opts.routeId;
|
|
11
|
+
if (opts.hmrStyle === 'webpack')
|
|
12
|
+
return createWebpackHmrStatement(stableRouteOptionKeys, {
|
|
13
|
+
targetFramework: opts.targetFramework,
|
|
14
|
+
routeId,
|
|
15
|
+
routeSignature: opts.routeSignature,
|
|
16
|
+
});
|
|
17
|
+
return createViteHmrStatement(stableRouteOptionKeys, {
|
|
18
|
+
targetFramework: opts.targetFramework,
|
|
19
|
+
routeId,
|
|
20
|
+
routeSignature: opts.routeSignature,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
24
|
+
export { createRouteHmrStatement };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Config } from '../config.js';
|
|
2
|
+
import type * as t from '@babel/types';
|
|
3
|
+
/**
|
|
4
|
+
* Emits HMR accept code for Vite / native ESM HMR: `import.meta.hot.accept`
|
|
5
|
+
* with a callback that receives the freshly re-imported module.
|
|
6
|
+
*
|
|
7
|
+
* Framework-specific component runtimes still own component body patching.
|
|
8
|
+
* The route signature only suppresses a redundant data invalidation when an
|
|
9
|
+
* Octane update changed extracted component code but not the route definition.
|
|
10
|
+
*/
|
|
11
|
+
export declare function createViteHmrStatement(
|
|
12
|
+
stableRouteOptionKeys: Array<string>,
|
|
13
|
+
opts: {
|
|
14
|
+
targetFramework: Config['target'];
|
|
15
|
+
routeId?: string;
|
|
16
|
+
routeSignature?: string;
|
|
17
|
+
},
|
|
18
|
+
): Array<t.Statement>;
|