@storybook/react 10.6.0-alpha.5 → 10.6.0-alpha.7

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.
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_o9l9ewgtxdb from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_o9l9ewgtxdb from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_o9l9ewgtxdb from "node:module";
1
+ import CJS_COMPAT_NODE_URL_5mro4fxxrdb from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_5mro4fxxrdb from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_5mro4fxxrdb from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_o9l9ewgtxdb.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_o9l9ewgtxdb.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_o9l9ewgtxdb.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_5mro4fxxrdb.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_5mro4fxxrdb.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_5mro4fxxrdb.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -13,9 +13,9 @@ import {
13
13
  ComponentMetaManager,
14
14
  buildComponentDocgenFromResolved,
15
15
  extractArgTypes,
16
- path,
16
+ posix,
17
17
  resolveStoryFileComponents
18
- } from "../_node-chunks/chunk-3FLTYXW5.js";
18
+ } from "../_node-chunks/chunk-7MQEKIVD.js";
19
19
 
20
20
  // src/docgen/docgen-worker.ts
21
21
  import { createLazyDocgenMiddleware } from "storybook/internal/common";
@@ -45,7 +45,7 @@ async function buildDocgenPayload(input, context) {
45
45
  let storyFilePath = getStoryImportPathFromEntry(input.entry);
46
46
  if (!storyFilePath)
47
47
  return;
48
- let storyPath = (context.resolvePath ?? ((importPath) => path.join(process.cwd(), importPath)))(storyFilePath), resolved;
48
+ let storyPath = (context.resolvePath ?? ((importPath) => posix.join(process.cwd(), importPath)))(storyFilePath), resolved;
49
49
  try {
50
50
  resolved = await resolveStoryFileComponents({
51
51
  storyPath,
package/dist/preset.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_o9l9ewgtxdb from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_o9l9ewgtxdb from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_o9l9ewgtxdb from "node:module";
1
+ import CJS_COMPAT_NODE_URL_5mro4fxxrdb from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_5mro4fxxrdb from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_5mro4fxxrdb from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_o9l9ewgtxdb.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_o9l9ewgtxdb.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_o9l9ewgtxdb.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_5mro4fxxrdb.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_5mro4fxxrdb.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_5mro4fxxrdb.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -14,19 +14,18 @@ import {
14
14
  buildReactComponentDocgenFromResolved,
15
15
  buildStoryDocsFromResolved,
16
16
  cachedReadFileSync,
17
- dirname,
18
17
  extractArgTypes,
19
18
  getCodeSnippet,
20
19
  invalidateCache,
21
20
  invalidateParser,
22
21
  join,
23
22
  parseWithReactDocgen,
24
- path,
23
+ posix,
25
24
  resolveStoryFileComponents
26
- } from "./_node-chunks/chunk-3FLTYXW5.js";
25
+ } from "./_node-chunks/chunk-7MQEKIVD.js";
27
26
 
28
27
  // src/preset.ts
29
- import path2, { join as join2 } from "node:path";
28
+ import path2, { join as join3 } from "node:path";
30
29
  import { fileURLToPath as fileURLToPath3 } from "node:url";
31
30
  import { getProjectRoot } from "storybook/internal/common";
32
31
 
@@ -158,18 +157,76 @@ var hasOwnProperty = {}.hasOwnProperty;
158
157
  var RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace], own = {}.hasOwnProperty;
159
158
  var isWindows = process.platform === "win32", globalCache = globalThis.__EXSOLVE_CACHE__ ||= /* @__PURE__ */ new Map();
160
159
 
160
+ // ../../core/node_modules/pathe/dist/shared/pathe.ff20891b.mjs
161
+ var _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
162
+ function normalizeWindowsPath(input = "") {
163
+ return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
164
+ }
165
+ var _UNC_REGEX = /^[/\\]{2}/, _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
166
+ var normalize = function(path3) {
167
+ if (path3.length === 0)
168
+ return ".";
169
+ path3 = normalizeWindowsPath(path3);
170
+ let isUNCPath = path3.match(_UNC_REGEX), isPathAbsolute = isAbsolute(path3), trailingSeparator = path3[path3.length - 1] === "/";
171
+ return path3 = normalizeString(path3, !isPathAbsolute), path3.length === 0 ? isPathAbsolute ? "/" : trailingSeparator ? "./" : "." : (trailingSeparator && (path3 += "/"), _DRIVE_LETTER_RE.test(path3) && (path3 += "/"), isUNCPath ? isPathAbsolute ? `//${path3}` : `//./${path3}` : isPathAbsolute && !isAbsolute(path3) ? `/${path3}` : path3);
172
+ }, join2 = function(...arguments_) {
173
+ if (arguments_.length === 0)
174
+ return ".";
175
+ let joined;
176
+ for (let argument of arguments_)
177
+ argument && argument.length > 0 && (joined === void 0 ? joined = argument : joined += `/${argument}`);
178
+ return joined === void 0 ? "." : normalize(joined.replace(/\/\/+/g, "/"));
179
+ };
180
+ function normalizeString(path3, allowAboveRoot) {
181
+ let res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;
182
+ for (let index = 0; index <= path3.length; ++index) {
183
+ if (index < path3.length)
184
+ char = path3[index];
185
+ else {
186
+ if (char === "/")
187
+ break;
188
+ char = "/";
189
+ }
190
+ if (char === "/") {
191
+ if (!(lastSlash === index - 1 || dots === 1)) if (dots === 2) {
192
+ if (res.length < 2 || lastSegmentLength !== 2 || res[res.length - 1] !== "." || res[res.length - 2] !== ".") {
193
+ if (res.length > 2) {
194
+ let lastSlashIndex = res.lastIndexOf("/");
195
+ lastSlashIndex === -1 ? (res = "", lastSegmentLength = 0) : (res = res.slice(0, lastSlashIndex), lastSegmentLength = res.length - 1 - res.lastIndexOf("/")), lastSlash = index, dots = 0;
196
+ continue;
197
+ } else if (res.length > 0) {
198
+ res = "", lastSegmentLength = 0, lastSlash = index, dots = 0;
199
+ continue;
200
+ }
201
+ }
202
+ allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
203
+ } else
204
+ res.length > 0 ? res += `/${path3.slice(lastSlash + 1, index)}` : res = path3.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
205
+ lastSlash = index, dots = 0;
206
+ } else char === "." && dots !== -1 ? ++dots : dots = -1;
207
+ }
208
+ return res;
209
+ }
210
+ var isAbsolute = function(p) {
211
+ return _IS_ABSOLUTE_RE.test(p);
212
+ };
213
+ var dirname = function(p) {
214
+ let segments = normalizeWindowsPath(p).replace(/\/$/, "").split("/").slice(0, -1);
215
+ return segments.length === 1 && _DRIVE_LETTER_RE.test(segments[0]) && (segments[0] += "/"), segments.join("/") || (isAbsolute(p) ? "/" : ".");
216
+ };
217
+
161
218
  // ../../core/src/shared/utils/module.ts
162
219
  var importMetaResolve = (...args) => typeof import.meta.resolve != "function" && process.env.VITEST === "true" ? (console.warn(
163
220
  "importMetaResolve from within Storybook is being used in a Vitest test, but it shouldn't be. Please report this at https://github.com/storybookjs/storybook/issues/new?template=bug_report.yml"
164
221
  ), pathToFileURL(args[0]).href) : import.meta.resolve(...args), resolvePackageDir = (pkg, parent) => {
165
222
  try {
166
- return dirname(fileURLToPath(importMetaResolve(join(pkg, "package.json"), parent)));
223
+ return dirname(fileURLToPath(importMetaResolve(join2(pkg, "package.json"), parent)));
167
224
  } catch {
168
225
  try {
169
- return dirname(fileURLToPath(importMetaResolve(join(pkg, "package.json"))));
226
+ return dirname(fileURLToPath(importMetaResolve(join2(pkg, "package.json"))));
170
227
  } catch {
171
228
  let req = createRequire(parent ?? import.meta.url);
172
- return dirname(req.resolve(join(pkg, "package.json")));
229
+ return dirname(req.resolve(join2(pkg, "package.json")));
173
230
  }
174
231
  }
175
232
  };
@@ -211,7 +268,8 @@ var extractArgTypesFromDocgen = ({
211
268
  import { logger as logger2 } from "storybook/internal/node-logger";
212
269
 
213
270
  // src/componentManifest/reactDocgen/utils.ts
214
- import { dirname as dirname2 } from "path";
271
+ import { findTsconfigPathForFile } from "storybook/internal/common";
272
+ import { dirname as dirname2 } from "node:path";
215
273
  var REACT_NODE_TYPES = /* @__PURE__ */ new Set([
216
274
  "JSX.Element",
217
275
  "ComponentType",
@@ -238,10 +296,10 @@ var REACT_NODE_TYPES = /* @__PURE__ */ new Set([
238
296
  "any",
239
297
  "unknown"
240
298
  ]);
241
- var getTsConfig = async () => {
299
+ var getTsConfig = async (componentFilePath) => {
242
300
  try {
243
- let ts = await import("typescript"), tsconfigPath = ts.findConfigFile(process.cwd(), ts.sys.fileExists);
244
- if (console.log({ tsconfigPath }), tsconfigPath === void 0)
301
+ let ts = await import("typescript"), tsconfigPath = componentFilePath ? findTsconfigPathForFile(dirname2(componentFilePath), componentFilePath) : ts.findConfigFile(process.cwd(), ts.sys.fileExists);
302
+ if (tsconfigPath === void 0)
245
303
  return {};
246
304
  let basePath = dirname2(tsconfigPath), { config, error } = ts.readConfigFile(tsconfigPath, ts.sys.readFile);
247
305
  return error ? {} : ts.parseJsonConfigFileContent(config, ts.sys, basePath, {}, tsconfigPath).options;
@@ -263,7 +321,7 @@ var extractArgTypesFromDocgenTypescript = async ({
263
321
  propFilter: (prop) => prop.parent ? !/node_modules/.test(prop.parent.fileName) : !0,
264
322
  // We *need* this set so that RDT returns default values in the same format as react-docgen
265
323
  savePropValueAsString: !0
266
- }, tsConfig = await getTsConfig(), mergedOptions = {
324
+ }, tsConfig = await getTsConfig(componentFilePath), mergedOptions = {
267
325
  ...defaultOptions,
268
326
  ...reactDocgenTypescriptOptions,
269
327
  // Always ensure savePropValueAsString is true for consistency
@@ -336,7 +394,7 @@ var manifests = async (existingManifests = {}, options) => {
336
394
  let storyFilePath = getStoryImportPathFromEntry(entry);
337
395
  if (!storyFilePath)
338
396
  throw new Error(`No story file path for index entry ${entry.id}`);
339
- let storyPath = path.join(process.cwd(), storyFilePath), resolved = await resolveStoryFileComponents({
397
+ let storyPath = posix.join(process.cwd(), storyFilePath), resolved = await resolveStoryFileComponents({
340
398
  storyPath,
341
399
  title: entry.title,
342
400
  typescriptOptions,
@@ -406,16 +464,16 @@ var enrichCsf = async (input, options) => {
406
464
  let promises = Object.keys(csf._stories).map(async (key) => {
407
465
  if (!csfSource._meta?.component)
408
466
  return;
409
- let { format: format2 } = await getPrettier(), node, snippet;
467
+ let { format: format3 } = await getPrettier(), node, snippet;
410
468
  try {
411
- node = getCodeSnippet(csfSource, key, csfSource._meta?.component);
469
+ node = getCodeSnippet(csfSource, key, csfSource._meta?.component).node;
412
470
  } catch (e) {
413
471
  if (!(e instanceof Error))
414
472
  return;
415
473
  snippet = e.message;
416
474
  }
417
475
  try {
418
- !snippet && node && (snippet = await format2(recast.print(node).code, {
476
+ !snippet && node && (snippet = await format3(recast.print(node).code, {
419
477
  filepath: join(process.cwd(), "component.tsx")
420
478
  }));
421
479
  } catch (e) {
@@ -488,7 +546,7 @@ async function buildStoryDocsPayload(input, context) {
488
546
  let storyFilePath = getStoryImportPathFromEntry2(input.entry);
489
547
  if (!storyFilePath)
490
548
  return;
491
- let storyPath = (context.resolvePath ?? ((importPath) => path.join(process.cwd(), importPath)))(storyFilePath), resolved;
549
+ let storyPath = (context.resolvePath ?? ((importPath) => posix.join(process.cwd(), importPath)))(storyFilePath), resolved;
492
550
  try {
493
551
  resolved = await resolveStoryFileComponents({
494
552
  storyPath,
@@ -568,7 +626,7 @@ async function internal_getArgTypesData(_input, options) {
568
626
  let { reactDocgen = "react-docgen", reactDocgenTypescriptOptions } = typescriptOptions;
569
627
  if (reactDocgen === !1)
570
628
  return null;
571
- let resolvedFilePath = path2.isAbsolute(componentFilePath) ? componentFilePath : join2(getProjectRoot(), componentFilePath), argTypesData;
629
+ let resolvedFilePath = path2.isAbsolute(componentFilePath) ? componentFilePath : join3(getProjectRoot(), componentFilePath), argTypesData;
572
630
  return reactDocgen === "react-docgen-typescript" ? argTypesData = await extractArgTypesFromDocgenTypescript({
573
631
  componentFilePath: resolvedFilePath,
574
632
  componentExportName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react",
3
- "version": "10.6.0-alpha.5",
3
+ "version": "10.6.0-alpha.7",
4
4
  "description": "Storybook React renderer",
5
5
  "keywords": [
6
6
  "storybook"
@@ -30,11 +30,6 @@
30
30
  "./entry-preview-argtypes": "./dist/entry-preview-argtypes.js",
31
31
  "./entry-preview-docs": "./dist/entry-preview-docs.js",
32
32
  "./entry-preview-rsc": "./dist/entry-preview-rsc.js",
33
- "./experimental-playwright": {
34
- "types": "./dist/playwright.d.ts",
35
- "code": "./src/playwright.ts",
36
- "default": "./dist/playwright.js"
37
- },
38
33
  "./internal/docgen-worker": "./dist/docgen/docgen-worker.js",
39
34
  "./package.json": "./package.json",
40
35
  "./preset": "./dist/preset.js",
@@ -54,7 +49,7 @@
54
49
  ],
55
50
  "dependencies": {
56
51
  "@storybook/global": "^5.0.0",
57
- "@storybook/react-dom-shim": "10.6.0-alpha.5",
52
+ "@storybook/react-dom-shim": "10.6.0-alpha.7",
58
53
  "react-docgen": "^8.0.2",
59
54
  "react-docgen-typescript": "^2.2.2"
60
55
  },
@@ -87,7 +82,7 @@
87
82
  "@types/react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
88
83
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
89
84
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
90
- "storybook": "^10.6.0-alpha.5",
85
+ "storybook": "^10.6.0-alpha.7",
91
86
  "typescript": ">= 4.9.x"
92
87
  },
93
88
  "peerDependenciesMeta": {
@@ -1,2 +0,0 @@
1
- import { createPlaywrightTest as createTest } from "storybook/preview-api";
2
- export { createTest };
@@ -1,7 +0,0 @@
1
- import "./_browser-chunks/chunk-UAWMPV5J.js";
2
-
3
- // src/playwright.ts
4
- import { createPlaywrightTest } from "storybook/preview-api";
5
- export {
6
- createPlaywrightTest as createTest
7
- };