@storybook/tanstack-react 10.6.0-alpha.3 → 10.6.0-alpha.4

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.
@@ -23,7 +23,7 @@ import {
23
23
  createRoute as createRoute2,
24
24
  createRouter,
25
25
  RouterProvider,
26
- interpolatePath,
26
+ interpolatePath as interpolatePath2,
27
27
  defaultStringifySearch
28
28
  } from "@tanstack/react-router";
29
29
 
@@ -32,6 +32,7 @@ import {
32
32
  createRoute,
33
33
  RootRoute,
34
34
  createRootRouteWithContext,
35
+ interpolatePath,
35
36
  joinPaths
36
37
  } from "@tanstack/react-router";
37
38
  var MAX_PARENT_WALK = 50;
@@ -55,12 +56,14 @@ function initSourceTree(route, counter) {
55
56
  initSourceTree(child, counter);
56
57
  }
57
58
  function cloneChild(oldRoute, parent, overrides, byId) {
58
- let options = oldRoute.options ?? {}, { id: originalId, getParentRoute: _g, ...rest } = options, override = getOverrideFor(overrides, oldRoute.id), merged = { ...rest, ...override }, cloned = createRoute({
59
- ...!merged.path && originalId != null ? { id: originalId } : {},
59
+ let options = oldRoute.options ?? {}, { id: originalId, getParentRoute: _g, ...rest } = options, override = getOverrideFor(overrides, oldRoute.id), { id: overrideId, ...overrideRest } = override, merged = { ...rest, ...overrideRest }, explicitId = "id" in override ? overrideId : originalId, cloned = createRoute({
60
+ ...!merged.path && explicitId != null ? { id: explicitId } : {},
60
61
  ...merged,
61
62
  getParentRoute: () => parent
62
63
  });
63
- byId.set(oldRoute.id, cloned);
64
+ merged.path && explicitId != null && cloned.update({ id: explicitId });
65
+ let lazyFn = oldRoute.lazyFn;
66
+ lazyFn && cloned.lazy(lazyFn), byId.set(oldRoute.id, cloned);
64
67
  let children = oldRoute.children;
65
68
  if (children?.length) {
66
69
  let clonedChildren = children.map(
@@ -80,8 +83,8 @@ function duplicateRouteTree(rootRoute, { overrides } = {}) {
80
83
  } = rootOptions, newRoot = createRootRouteWithContext()({
81
84
  ...restRoot,
82
85
  ...rootOverride
83
- });
84
- byId.set("__root__", newRoot);
86
+ }), rootLazyFn = rootRoute.lazyFn;
87
+ rootLazyFn && newRoot.lazy(rootLazyFn), byId.set("__root__", newRoot);
85
88
  let children = rootRoute.children;
86
89
  if (children?.length) {
87
90
  let clonedChildren = children.map(
@@ -106,13 +109,27 @@ function originalRouteId(tree, route) {
106
109
  if (cloned === route)
107
110
  return id;
108
111
  }
109
- function resolveStoryLeaf(tree, { path, boundRouteId }) {
112
+ function resolveStoryLeaf(tree, {
113
+ path,
114
+ boundRouteId,
115
+ params
116
+ }) {
110
117
  let { root, byId } = tree;
111
118
  if (path) {
112
- let bestMatch, bestMatchLength = -1;
119
+ let bound = boundRouteId ? byId.get(boundRouteId) : void 0;
120
+ if (bound) {
121
+ let boundCandidate = mountPathFor(bound), boundInterpolated = params ? interpolatePath({ path: boundCandidate, params }).interpolatedPath : boundCandidate;
122
+ if (boundCandidate === path || boundInterpolated === path)
123
+ return bound;
124
+ }
125
+ let bestMatch, bestLiteral = !1, bestMatchLength = -1;
113
126
  for (let route of byId.values()) {
114
- let fullPath = route.fullPath;
115
- fullPath && fullPath === path && fullPath.length > bestMatchLength && (bestMatch = route, bestMatchLength = fullPath.length);
127
+ if (route === root)
128
+ continue;
129
+ let candidate = mountPathFor(route), isLiteral = candidate === path, interpolated = params ? interpolatePath({ path: candidate, params }).interpolatedPath : candidate;
130
+ if (!isLiteral && interpolated !== path)
131
+ continue;
132
+ (isLiteral === bestLiteral ? candidate.length > bestMatchLength : isLiteral) && (bestMatch = route, bestLiteral = isLiteral, bestMatchLength = candidate.length);
116
133
  }
117
134
  if (bestMatch)
118
135
  return bestMatch;
@@ -159,7 +176,7 @@ function createStoryRouter({
159
176
  context,
160
177
  routerContext
161
178
  }) {
162
- let routerParameters = context.parameters.tanstack?.router ?? {}, { tree, leaf } = resolveTree(Story, context), routeTree = tree.root, inferredPath = routerParameters?.path || leaf.fullPath || (leaf.id ? normalizeFileRoutePath(leaf.id) : void 0) || mountPathFor(leaf), resolvedPath = interpolatePath({
179
+ let routerParameters = context.parameters.tanstack?.router ?? {}, { tree, leaf } = resolveTree(Story, context), routeTree = tree.root, inferredPath = routerParameters?.path || leaf.fullPath || (leaf.id ? normalizeFileRoutePath(leaf.id) : void 0) || mountPathFor(leaf), resolvedPath = interpolatePath2({
163
180
  path: inferredPath,
164
181
  params: routerParameters?.params ?? {}
165
182
  }).interpolatedPath, search = routerParameters?.query ? defaultStringifySearch(routerParameters.query) : "";
@@ -206,7 +223,8 @@ function resolveTree(Story, context) {
206
223
  if (rootRoute) {
207
224
  let tree = duplicateRouteTree(rootRoute, { overrides: routeOverrides }), leaf = resolveStoryLeaf(tree, {
208
225
  path: routerParameters.path,
209
- boundRouteId: resolvedRoute && resolvedRoute !== rootRoute ? resolvedRoute.id : void 0
226
+ boundRouteId: resolvedRoute && resolvedRoute !== rootRoute ? resolvedRoute.id : void 0,
227
+ params: routerParameters.params
210
228
  });
211
229
  injectStoryComponent(leaf, Story, routeOverrides, originalRouteId(tree, leaf) ?? leaf.id);
212
230
  let renderLeaf = ensureMatchableLeaf(tree, leaf);
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  preview_exports
3
- } from "./_browser-chunks/chunk-XY6TESST.js";
3
+ } from "./_browser-chunks/chunk-5B7CRIA6.js";
4
4
  import "./_browser-chunks/chunk-LTDGLEVR.js";
5
5
  import "./_browser-chunks/chunk-4BE7D4DS.js";
6
6
 
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_0sqooo0adxx9 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_0sqooo0adxx9 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_0sqooo0adxx9 from "node:module";
1
+ import CJS_COMPAT_NODE_URL_fr5elf42854 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_fr5elf42854 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_fr5elf42854 from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_0sqooo0adxx9.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_0sqooo0adxx9.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_0sqooo0adxx9.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_fr5elf42854.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_fr5elf42854.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_fr5elf42854.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
package/dist/preset.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_0sqooo0adxx9 from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_0sqooo0adxx9 from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_0sqooo0adxx9 from "node:module";
1
+ import CJS_COMPAT_NODE_URL_fr5elf42854 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_fr5elf42854 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_fr5elf42854 from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_0sqooo0adxx9.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_0sqooo0adxx9.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_0sqooo0adxx9.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_fr5elf42854.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_fr5elf42854.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_fr5elf42854.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -360,16 +360,17 @@ function moduleInterceptionPlugin({
360
360
  enforce: "pre",
361
361
  resolveId: {
362
362
  order: "pre",
363
- handler(id, importer) {
363
+ async handler(id, importer) {
364
+ let resolveMock = async (mockPath) => await this.resolve(mockPath, importer, { skipSelf: !0 }) ?? mockPath;
364
365
  if ((id === "@tanstack/react-router" || id.startsWith("@tanstack/react-router/")) && importer && !importer.includes("export-mocks"))
365
- return routerMockPath;
366
+ return resolveMock(routerMockPath);
366
367
  if (START_SERVER_MODULES.includes(id) || id === "@tanstack/react-start")
367
- return startMockPath;
368
+ return resolveMock(startMockPath);
368
369
  if (id === "@tanstack/start-storage-context")
369
- return startStorageContextMockPath;
370
+ return resolveMock(startStorageContextMockPath);
370
371
  for (let pattern of INTERCEPTED_PATTERNS)
371
372
  if (id.includes(pattern))
372
- return startMockPath;
373
+ return resolveMock(startMockPath);
373
374
  return null;
374
375
  }
375
376
  },
package/dist/preview.js CHANGED
@@ -3,7 +3,7 @@ import {
3
3
  loaders,
4
4
  optimizeDeps,
5
5
  parameters
6
- } from "./_browser-chunks/chunk-XY6TESST.js";
6
+ } from "./_browser-chunks/chunk-5B7CRIA6.js";
7
7
  import "./_browser-chunks/chunk-LTDGLEVR.js";
8
8
  import "./_browser-chunks/chunk-4BE7D4DS.js";
9
9
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/tanstack-react",
3
- "version": "10.6.0-alpha.3",
3
+ "version": "10.6.0-alpha.4",
4
4
  "description": "Storybook for TanStack (React, Vite): Router and Start ready Storybook framework",
5
5
  "keywords": [
6
6
  "storybook",
@@ -75,9 +75,9 @@
75
75
  "!src/**/*"
76
76
  ],
77
77
  "dependencies": {
78
- "@storybook/builder-vite": "10.6.0-alpha.3",
79
- "@storybook/react": "10.6.0-alpha.3",
80
- "@storybook/react-vite": "10.6.0-alpha.3"
78
+ "@storybook/builder-vite": "10.6.0-alpha.4",
79
+ "@storybook/react": "10.6.0-alpha.4",
80
+ "@storybook/react-vite": "10.6.0-alpha.4"
81
81
  },
82
82
  "devDependencies": {
83
83
  "@tanstack/react-router": "^1.168.10",
@@ -95,7 +95,7 @@
95
95
  "@tanstack/start-client-core": "^1.167.9",
96
96
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
97
97
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
98
- "storybook": "^10.6.0-alpha.3",
98
+ "storybook": "^10.6.0-alpha.4",
99
99
  "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
100
100
  },
101
101
  "peerDependenciesMeta": {