@storybook/react 10.1.0-beta.3 → 10.1.0-beta.5

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.
Files changed (2) hide show
  1. package/dist/preset.js +20 -34
  2. package/package.json +3 -3
package/dist/preset.js CHANGED
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_myofsff6kim from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_myofsff6kim from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_myofsff6kim from "node:module";
1
+ import CJS_COMPAT_NODE_URL_jftxvcjteu8 from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_jftxvcjteu8 from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_jftxvcjteu8 from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_myofsff6kim.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_myofsff6kim.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_myofsff6kim.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_jftxvcjteu8.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_jftxvcjteu8.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_jftxvcjteu8.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -3796,29 +3796,6 @@ function getImportTag(docgen) {
3796
3796
  return (jsdocComment ? extractJSDocInfo(jsdocComment).tags : void 0)?.import?.[0];
3797
3797
  }
3798
3798
 
3799
- // src/componentManifest/valid-package-name.ts
3800
- var scopedPackagePattern = new RegExp("^(?:@([^/]+?)[/])?([^/]+?)$");
3801
- function stripSubpath(name) {
3802
- let parts = name.split("/");
3803
- return name.startsWith("@") ? parts.length >= 3 ? `${parts[0]}/${parts[1]}` : name : parts[0];
3804
- }
3805
- function validPackageName(name) {
3806
- if (!name.length || name.startsWith(".") || name.match(/^_/) || name.trim() !== name || name.length > 214 || name.toLowerCase() !== name || /[~'!()*]/.test(name.split("/").slice(-1)[0]))
3807
- return !1;
3808
- if (encodeURIComponent(name) !== name) {
3809
- let nameMatch = name.match(scopedPackagePattern);
3810
- if (nameMatch) {
3811
- let org = nameMatch[1], pkg = nameMatch[2];
3812
- if (pkg.startsWith("."))
3813
- return !1;
3814
- if (encodeURIComponent(org) === org && encodeURIComponent(pkg) === pkg)
3815
- return !0;
3816
- }
3817
- return !1;
3818
- }
3819
- return !0;
3820
- }
3821
-
3822
3799
  // src/componentManifest/getComponentImports.ts
3823
3800
  var baseIdentifier = (component) => component.split(".")[0] ?? component, isTypeSpecifier = (s) => t3.isImportSpecifier(s) && s.importKind === "type", importedName = (im) => t3.isIdentifier(im) ? im.name : im.value, addUniqueBy = (arr, item, eq) => {
3824
3801
  arr.find(eq) || arr.push(item);
@@ -3895,7 +3872,7 @@ var baseIdentifier = (component) => component.split(".")[0] ?? component, isType
3895
3872
  importName: direct.importName
3896
3873
  } : { componentName: c };
3897
3874
  }).map((component) => {
3898
- let path2;
3875
+ let path2, isPackage = !1;
3899
3876
  try {
3900
3877
  component.importId && storyFilePath && (path2 = cachedResolveImport(matchPath(component.importId, dirname4(storyFilePath)), {
3901
3878
  basedir: dirname4(storyFilePath)
@@ -3903,16 +3880,21 @@ var baseIdentifier = (component) => component.split(".")[0] ?? component, isType
3903
3880
  } catch (e) {
3904
3881
  logger3.debug(e);
3905
3882
  }
3883
+ try {
3884
+ component.importId && !component.importId.startsWith(".") && storyFilePath && (cachedResolveImport(component.importId, { basedir: dirname4(storyFilePath) }), isPackage = !0);
3885
+ } catch {
3886
+ }
3887
+ let componentWithPackage = { ...component, isPackage };
3906
3888
  if (path2) {
3907
- let reactDocgen = getReactDocgen(path2, component);
3889
+ let reactDocgen = getReactDocgen(path2, componentWithPackage);
3908
3890
  return {
3909
- ...component,
3891
+ ...componentWithPackage,
3910
3892
  path: path2,
3911
3893
  reactDocgen,
3912
3894
  importOverride: reactDocgen.type === "success" ? getImportTag(reactDocgen.data) : void 0
3913
3895
  };
3914
3896
  }
3915
- return component;
3897
+ return componentWithPackage;
3916
3898
  }).sort((a, b) => a.componentName.localeCompare(b.componentName));
3917
3899
  }, getImports = ({
3918
3900
  components,
@@ -3927,7 +3909,11 @@ var baseIdentifier = (component) => component.split(".")[0] ?? component, isType
3927
3909
  } catch {
3928
3910
  return;
3929
3911
  }
3930
- })(), rewritten = overrideSource !== void 0 ? overrideSource : packageName && !validPackageName(stripSubpath(importId)) ? packageName : importId;
3912
+ })(), rewritten = overrideSource !== void 0 ? overrideSource : (
3913
+ // only rewrite to the package name it the import id is not already a valid package
3914
+ // tsconfig paths such as ~/components/Button and components/Button are not seen as packages
3915
+ packageName && !c.isPackage ? packageName : importId
3916
+ );
3931
3917
  return { c, src: t3.stringLiteral(rewritten), key: rewritten, ord: idx };
3932
3918
  }), orderOfSource = {};
3933
3919
  for (let w of withSource)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/react",
3
- "version": "10.1.0-beta.3",
3
+ "version": "10.1.0-beta.5",
4
4
  "description": "Storybook React renderer",
5
5
  "keywords": [
6
6
  "storybook"
@@ -54,7 +54,7 @@
54
54
  },
55
55
  "dependencies": {
56
56
  "@storybook/global": "^5.0.0",
57
- "@storybook/react-dom-shim": "10.1.0-beta.3",
57
+ "@storybook/react-dom-shim": "10.1.0-beta.5",
58
58
  "react-docgen": "^8.0.2"
59
59
  },
60
60
  "devDependencies": {
@@ -81,7 +81,7 @@
81
81
  "peerDependencies": {
82
82
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
83
83
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
84
- "storybook": "^10.1.0-beta.3",
84
+ "storybook": "^10.1.0-beta.5",
85
85
  "typescript": ">= 4.9.x"
86
86
  },
87
87
  "peerDependenciesMeta": {