@storybook/react 10.6.0-alpha.6 → 10.6.0-alpha.8
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
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_qwngdwe5vmo from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_qwngdwe5vmo from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_qwngdwe5vmo from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_qwngdwe5vmo.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_qwngdwe5vmo.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_qwngdwe5vmo.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -13095,10 +13095,6 @@ function up2(name, options) {
|
|
|
13095
13095
|
}
|
|
13096
13096
|
|
|
13097
13097
|
// src/componentManifest/utils.ts
|
|
13098
|
-
var groupBy = (items, keySelector) => items.reduce((acc = {}, item, index) => {
|
|
13099
|
-
let key = keySelector(item, index);
|
|
13100
|
-
return Array.isArray(acc[key]) || (acc[key] = []), acc[key].push(item), acc;
|
|
13101
|
-
}, {});
|
|
13102
13098
|
function groupByToMap(items, getKey) {
|
|
13103
13099
|
let result = /* @__PURE__ */ new Map();
|
|
13104
13100
|
for (let item of items) {
|
|
@@ -13112,7 +13108,7 @@ function invariant(condition, message) {
|
|
|
13112
13108
|
throw new Error((typeof message == "function" ? message() : message) ?? "Invariant failed");
|
|
13113
13109
|
}
|
|
13114
13110
|
var memoStore = /* @__PURE__ */ new WeakMap(), asyncMemoStore = /* @__PURE__ */ new WeakMap(), textFileCache = /* @__PURE__ */ new Map(), cached = (fn, opts = {}) => {
|
|
13115
|
-
let
|
|
13111
|
+
let keyOf = opts.key ?? ((...args) => {
|
|
13116
13112
|
try {
|
|
13117
13113
|
return JSON.stringify(args);
|
|
13118
13114
|
} catch {
|
|
@@ -13120,14 +13116,14 @@ var memoStore = /* @__PURE__ */ new WeakMap(), asyncMemoStore = /* @__PURE__ */
|
|
|
13120
13116
|
}
|
|
13121
13117
|
});
|
|
13122
13118
|
return (...args) => {
|
|
13123
|
-
let k =
|
|
13119
|
+
let k = keyOf(...args), name = fn.name || opts.name || "anonymous", store = memoStore.get(fn);
|
|
13124
13120
|
if (store || (store = /* @__PURE__ */ new Map(), memoStore.set(fn, store)), store.has(k))
|
|
13125
13121
|
return logger.verbose(`[cache] hit ${name} key=${k}`), store.get(k);
|
|
13126
13122
|
let start = Date.now(), result = fn(...args), duration = Date.now() - start;
|
|
13127
13123
|
return store.set(k, result), logger.verbose(`[cache] miss ${name} took ${duration}ms key=${k}`), result;
|
|
13128
13124
|
};
|
|
13129
13125
|
}, asyncCache = (fn, opts = {}) => {
|
|
13130
|
-
let
|
|
13126
|
+
let keyOf = opts.key ?? ((...args) => {
|
|
13131
13127
|
try {
|
|
13132
13128
|
return JSON.stringify(args);
|
|
13133
13129
|
} catch {
|
|
@@ -13135,7 +13131,7 @@ var memoStore = /* @__PURE__ */ new WeakMap(), asyncMemoStore = /* @__PURE__ */
|
|
|
13135
13131
|
}
|
|
13136
13132
|
});
|
|
13137
13133
|
return (...args) => {
|
|
13138
|
-
let k =
|
|
13134
|
+
let k = keyOf(...args), name = fn.name || opts.name || "anonymous", store = asyncMemoStore.get(fn);
|
|
13139
13135
|
store || (store = /* @__PURE__ */ new Map(), asyncMemoStore.set(fn, store));
|
|
13140
13136
|
let existing = store.get(k);
|
|
13141
13137
|
if (existing)
|
|
@@ -13179,6 +13175,7 @@ import {
|
|
|
13179
13175
|
import * as path from "path";
|
|
13180
13176
|
|
|
13181
13177
|
// src/componentManifest/componentMeta/componentMetaExtractor.ts
|
|
13178
|
+
import { extractComponentJsDocInfo } from "storybook/internal/component-meta";
|
|
13182
13179
|
var LARGE_SOURCE_THRESHOLD = 30, MAX_UNWRAP_DEPTH = 5, MAX_SERIALIZATION_DEPTH = 5;
|
|
13183
13180
|
function isLiteralType(type) {
|
|
13184
13181
|
return type.isStringLiteral() || type.isNumberLiteral();
|
|
@@ -13639,8 +13636,8 @@ function getJSDocDefault(typescript, prop, checker) {
|
|
|
13639
13636
|
if (tag.name === "default" || tag.name === "defaultValue")
|
|
13640
13637
|
return typescript.displayPartsToString(tag.text) || void 0;
|
|
13641
13638
|
}
|
|
13642
|
-
function extractPropItem(typescript, checker, prop, contextNode, defaultsMap) {
|
|
13643
|
-
let isRequired = !!!(prop.flags & typescript.SymbolFlags.Optional), propType = checker.getTypeOfSymbolAtLocation(prop, contextNode), type = serializeType(typescript, checker, propType, isRequired), description = typescript.displayPartsToString(prop.getDocumentationComment(checker)), parent = getParentType(typescript, prop), declarations = getAllDeclarationParents(typescript, prop), propName = prop.getName(), destructuringDefault = defaultsMap?.get(propName), jsDocDefault = getJSDocDefault(typescript, prop, checker), defaultStr = destructuringDefault ?? jsDocDefault;
|
|
13639
|
+
function extractPropItem(typescript, checker, prop, contextNode, defaultsMap, typeOverride) {
|
|
13640
|
+
let isRequired = !!!(prop.flags & typescript.SymbolFlags.Optional), propType = typeOverride ?? checker.getTypeOfSymbolAtLocation(prop, contextNode), type = serializeType(typescript, checker, propType, isRequired), description = typescript.displayPartsToString(prop.getDocumentationComment(checker)), parent = getParentType(typescript, prop), declarations = getAllDeclarationParents(typescript, prop), propName = prop.getName(), destructuringDefault = defaultsMap?.get(propName), jsDocDefault = getJSDocDefault(typescript, prop, checker), defaultStr = destructuringDefault ?? jsDocDefault;
|
|
13644
13641
|
return {
|
|
13645
13642
|
name: propName,
|
|
13646
13643
|
required: isRequired,
|
|
@@ -13679,18 +13676,6 @@ function computeDisplayName({
|
|
|
13679
13676
|
let exportName = exportSymbol.getName();
|
|
13680
13677
|
return exportName === "default" ? resolvedName && resolvedName !== "default" && resolvedName !== "__function" ? resolvedName : void 0 : exportName;
|
|
13681
13678
|
}
|
|
13682
|
-
function extractComponentJsDocTags(typescript, checker, symbol) {
|
|
13683
|
-
let tags = symbol.getJsDocTags(checker);
|
|
13684
|
-
if (tags.length === 0)
|
|
13685
|
-
return;
|
|
13686
|
-
let groupedTags = groupBy(tags, (tag) => tag.name);
|
|
13687
|
-
return Object.fromEntries(
|
|
13688
|
-
Object.entries(groupedTags).map(([name, grouped]) => [
|
|
13689
|
-
name,
|
|
13690
|
-
(grouped ?? []).map((tag) => typescript.displayPartsToString(tag.text ?? []).trim())
|
|
13691
|
-
])
|
|
13692
|
-
);
|
|
13693
|
-
}
|
|
13694
13679
|
function serializeComponentDoc(typescript, checker, {
|
|
13695
13680
|
sourceFile,
|
|
13696
13681
|
resolvedComponent,
|
|
@@ -13744,13 +13729,20 @@ function serializeComponentDoc(typescript, checker, {
|
|
|
13744
13729
|
for (let prop of allProperties) {
|
|
13745
13730
|
if (excluded.has(prop.getName()))
|
|
13746
13731
|
continue;
|
|
13747
|
-
let
|
|
13732
|
+
let unionProp = isUnionType(propsType) ? checker.getPropertyOfType(propsType, prop.getName()) : void 0, unionPropType = unionProp ? checker.getTypeOfSymbolAtLocation(unionProp, contextNode) : void 0, item = extractPropItem(
|
|
13733
|
+
typescript,
|
|
13734
|
+
checker,
|
|
13735
|
+
prop,
|
|
13736
|
+
contextNode,
|
|
13737
|
+
defaultsMap,
|
|
13738
|
+
unionPropType
|
|
13739
|
+
);
|
|
13748
13740
|
unionForceOptional?.has(prop.getName()) && (item.required = !1), props[prop.getName()] = item;
|
|
13749
13741
|
}
|
|
13750
13742
|
let displayName = (isMemberSelection ? displayNameOverride : void 0) ?? computeDisplayName({
|
|
13751
13743
|
exportSymbol,
|
|
13752
13744
|
resolvedSymbol: resolved
|
|
13753
|
-
}) ?? displayNameOverride,
|
|
13745
|
+
}) ?? displayNameOverride, resolvedJsDocInfo = extractComponentJsDocInfo(typescript, checker, resolved), description = resolvedJsDocInfo.description, selectedJsDocTags = resolvedJsDocInfo.jsDocTags, exportResolved = exportSymbol && exportSymbol !== resolved ? resolveAliasedSymbol(typescript, checker, exportSymbol) : void 0, exportJsDocTags = exportResolved ? extractComponentJsDocInfo(typescript, checker, exportResolved).jsDocTags : void 0, jsDocTags = selectedJsDocTags?.import || !exportJsDocTags?.import ? selectedJsDocTags : {
|
|
13754
13746
|
...selectedJsDocTags ?? {},
|
|
13755
13747
|
import: exportJsDocTags.import
|
|
13756
13748
|
};
|
|
@@ -15320,7 +15312,11 @@ var import_ts_dedent2 = __toESM(require_dist(), 1), TsconfigPaths = __toESM(requ
|
|
|
15320
15312
|
import { existsSync as existsSync2 } from "node:fs";
|
|
15321
15313
|
import { dirname as dirname3, sep } from "node:path";
|
|
15322
15314
|
import { babelParse, types as t } from "storybook/internal/babel";
|
|
15323
|
-
import {
|
|
15315
|
+
import {
|
|
15316
|
+
findTsconfigPathForPath,
|
|
15317
|
+
getTsconfigPathsBaseDir,
|
|
15318
|
+
supportedExtensions as supportedExtensions2
|
|
15319
|
+
} from "storybook/internal/common";
|
|
15324
15320
|
import { extractJSDocInfo } from "storybook/internal/csf-tools";
|
|
15325
15321
|
import { logger as logger3 } from "storybook/internal/node-logger";
|
|
15326
15322
|
import {
|
|
@@ -15490,11 +15486,11 @@ function getMatchingDocgen(docgens, component) {
|
|
|
15490
15486
|
function matchPath(id, importerPath) {
|
|
15491
15487
|
importerPath ??= process.cwd();
|
|
15492
15488
|
let tsconfig = getTsConfig(importerPath);
|
|
15493
|
-
return tsconfig.resultType === "success" ? TsconfigPaths.createMatchPath(
|
|
15494
|
-
|
|
15495
|
-
|
|
15496
|
-
"main"
|
|
15497
|
-
|
|
15489
|
+
return tsconfig.resultType === "success" ? TsconfigPaths.createMatchPath(
|
|
15490
|
+
getTsconfigPathsBaseDir(tsconfig.configFileAbsolutePath),
|
|
15491
|
+
tsconfig.paths,
|
|
15492
|
+
["browser", "module", "main"]
|
|
15493
|
+
)(id, void 0, void 0, supportedExtensions2) ?? id : id;
|
|
15498
15494
|
}
|
|
15499
15495
|
var getTsConfig = cached(
|
|
15500
15496
|
(path2) => {
|
|
@@ -15957,41 +15953,49 @@ var delimiter = globalThis.process?.platform === "win32" ? ";" : ":", _platforms
|
|
|
15957
15953
|
// src/componentManifest/generateCodeSnippet.ts
|
|
15958
15954
|
import { types as t2 } from "storybook/internal/babel";
|
|
15959
15955
|
import {
|
|
15960
|
-
|
|
15961
|
-
keyOf,
|
|
15956
|
+
createStoryArgsResolver,
|
|
15962
15957
|
metaObjectPath,
|
|
15963
|
-
mergeArgsRecords,
|
|
15964
|
-
metaArgsRecord,
|
|
15965
15958
|
normalizeStoryDeclaration,
|
|
15966
|
-
resolveRenderFunction
|
|
15967
|
-
storyAssignedArgsPath
|
|
15959
|
+
resolveRenderFunction
|
|
15968
15960
|
} from "storybook/internal/csf-tools";
|
|
15969
|
-
function
|
|
15970
|
-
|
|
15961
|
+
function renderFunctionOf(resolution) {
|
|
15962
|
+
return resolution.kind === "resolved" ? resolution.path : resolution.kind === "unresolved" ? resolution.shadowedRender : void 0;
|
|
15963
|
+
}
|
|
15964
|
+
function getCodeSnippet(csf, storyName, componentName, resolver = createStoryArgsResolver(csf)) {
|
|
15965
|
+
let { args, imports, unresolved } = resolver.resolve(storyName);
|
|
15966
|
+
return {
|
|
15967
|
+
node: buildSnippetNode(csf, storyName, componentName, args, resolver.ctx),
|
|
15968
|
+
imports,
|
|
15969
|
+
unresolved
|
|
15970
|
+
};
|
|
15971
|
+
}
|
|
15972
|
+
function buildSnippetNode(csf, storyName, componentName, merged, ctx) {
|
|
15973
|
+
let storyDeclaration = csf._storyDeclarationPath[storyName];
|
|
15971
15974
|
if (!storyDeclaration) {
|
|
15972
15975
|
let message = "Expected story to be a function or variable declaration";
|
|
15973
15976
|
throw csf._storyPaths[storyName]?.buildCodeFrameError(message) ?? message;
|
|
15974
15977
|
}
|
|
15975
15978
|
let normalizedStory = normalizeStoryDeclaration(storyDeclaration), storyFn;
|
|
15976
15979
|
normalizedStory.type === "fn" && (storyFn = normalizedStory.path);
|
|
15977
|
-
let
|
|
15978
|
-
storyFn || (storyFn = storyRender
|
|
15979
|
-
let
|
|
15980
|
-
...mergeArgsRecords(metaArgs, storyArgs),
|
|
15981
|
-
...storyAssignedArgs
|
|
15982
|
-
}, entries = Object.entries(merged).filter(([k]) => k !== "children"), validEntries = entries.filter(([k, v]) => isValidJsxAttrName(k) && v != null), invalidEntries = entries.filter(([k, v]) => !isValidJsxAttrName(k) && v != null), injectedAttrs = validEntries.map(([k, v]) => toAttr(k, v)).filter((a) => a != null);
|
|
15980
|
+
let storyConfigPath = normalizedStory.type === "config" ? normalizedStory.path : void 0, metaRender = resolveRenderFunction(metaObjectPath(csf), storyDeclaration, ctx), storyRender = resolveRenderFunction(storyConfigPath, storyDeclaration, ctx);
|
|
15981
|
+
storyFn || (storyFn = renderFunctionOf(storyRender) ?? (storyRender.kind === "missing" ? renderFunctionOf(metaRender) : void 0));
|
|
15982
|
+
let entries = Object.entries(merged).filter(([k]) => k !== "children"), validEntries = entries.filter(([k, v]) => isValidJsxAttrName(k) && v != null), invalidEntries = entries.filter(([k, v]) => !isValidJsxAttrName(k) && v != null), injectedAttrs = validEntries.map(([k, v]) => toAttr(k, v)).filter((a) => a != null);
|
|
15983
15983
|
if (storyFn) {
|
|
15984
15984
|
let fn = storyFn.node;
|
|
15985
15985
|
if (t2.isArrowFunctionExpression(fn) && (t2.isJSXElement(fn.body) || t2.isJSXFragment(fn.body))) {
|
|
15986
15986
|
let spreadRes = transformArgsSpreadsInJsx(fn.body, merged), inlineRes = inlineArgsInJsx(spreadRes.node, merged);
|
|
15987
15987
|
if (spreadRes.changed || inlineRes.changed) {
|
|
15988
|
-
let newFn = t2.arrowFunctionExpression(
|
|
15988
|
+
let newFn = t2.arrowFunctionExpression(
|
|
15989
|
+
remainingParams(fn, inlineRes.node),
|
|
15990
|
+
inlineRes.node,
|
|
15991
|
+
fn.async
|
|
15992
|
+
);
|
|
15989
15993
|
return t2.variableDeclaration("const", [
|
|
15990
15994
|
t2.variableDeclarator(t2.identifier(storyName), newFn)
|
|
15991
15995
|
]);
|
|
15992
15996
|
}
|
|
15993
15997
|
}
|
|
15994
|
-
let stmts = t2.isFunctionDeclaration(fn) || t2.isArrowFunctionExpression(fn) && t2.isBlockStatement(fn.body) || t2.isFunctionExpression(fn) && t2.isBlockStatement(fn.body) ? fn.body.body : void 0;
|
|
15998
|
+
let stmts = t2.isFunctionDeclaration(fn) || t2.isObjectMethod(fn) || t2.isArrowFunctionExpression(fn) && t2.isBlockStatement(fn.body) || t2.isFunctionExpression(fn) && t2.isBlockStatement(fn.body) ? fn.body.body : void 0;
|
|
15995
15999
|
if (stmts) {
|
|
15996
16000
|
let changed = !1, newBody = stmts.map((stmt) => {
|
|
15997
16001
|
if (t2.isReturnStatement(stmt) && stmt.argument && (t2.isJSXElement(stmt.argument) || t2.isJSXFragment(stmt.argument))) {
|
|
@@ -16001,21 +16005,22 @@ function getCodeSnippet(csf, storyName, componentName) {
|
|
|
16001
16005
|
}
|
|
16002
16006
|
return stmt;
|
|
16003
16007
|
});
|
|
16004
|
-
if (changed)
|
|
16005
|
-
|
|
16006
|
-
|
|
16007
|
-
[],
|
|
16008
|
-
t2.blockStatement(newBody),
|
|
16009
|
-
fn.generator,
|
|
16010
|
-
fn.async
|
|
16011
|
-
) : t2.variableDeclaration("const", [
|
|
16008
|
+
if (changed) {
|
|
16009
|
+
let body = t2.blockStatement(newBody), params = remainingParams(fn, body);
|
|
16010
|
+
return t2.isFunctionDeclaration(fn) ? t2.functionDeclaration(t2.identifier(storyName), params, body, fn.generator, fn.async) : t2.variableDeclaration("const", [
|
|
16012
16011
|
t2.variableDeclarator(
|
|
16013
16012
|
t2.identifier(storyName),
|
|
16014
|
-
t2.arrowFunctionExpression(
|
|
16013
|
+
t2.arrowFunctionExpression(params, body, fn.async)
|
|
16015
16014
|
)
|
|
16016
16015
|
]);
|
|
16016
|
+
}
|
|
16017
16017
|
}
|
|
16018
|
-
return t2.isFunctionDeclaration(fn) ? t2.functionDeclaration(t2.identifier(storyName), fn.params, fn.body, fn.generator, fn.async) : t2.variableDeclaration("const", [
|
|
16018
|
+
return t2.isFunctionDeclaration(fn) ? t2.functionDeclaration(t2.identifier(storyName), fn.params, fn.body, fn.generator, fn.async) : t2.variableDeclaration("const", [
|
|
16019
|
+
t2.variableDeclarator(
|
|
16020
|
+
t2.identifier(storyName),
|
|
16021
|
+
t2.isObjectMethod(fn) ? t2.arrowFunctionExpression(fn.params, fn.body, fn.async) : fn
|
|
16022
|
+
)
|
|
16023
|
+
]);
|
|
16019
16024
|
}
|
|
16020
16025
|
invariant(componentName, "Could not generate snippet without component name.");
|
|
16021
16026
|
let invalidSpread = buildInvalidSpread(invalidEntries), name = t2.jsxIdentifier(componentName), openingElAttrs = invalidSpread ? [...injectedAttrs, invalidSpread] : injectedAttrs, children = toJsxChildren(merged.children), selfClosing = children.length === 0, arrow = t2.arrowFunctionExpression(
|
|
@@ -16029,6 +16034,15 @@ function getCodeSnippet(csf, storyName, componentName) {
|
|
|
16029
16034
|
);
|
|
16030
16035
|
return t2.variableDeclaration("const", [t2.variableDeclarator(t2.identifier(storyName), arrow)]);
|
|
16031
16036
|
}
|
|
16037
|
+
function remainingParams(fn, body) {
|
|
16038
|
+
return readsArgs(body) ? fn.params : [];
|
|
16039
|
+
}
|
|
16040
|
+
function readsArgs(node) {
|
|
16041
|
+
let named = /* @__PURE__ */ new Set(), reads = !1;
|
|
16042
|
+
return t2.traverseFast(node, (current2) => {
|
|
16043
|
+
t2.isMemberExpression(current2) && !current2.computed && named.add(current2.property), (t2.isObjectProperty(current2) || t2.isObjectMethod(current2)) && !current2.computed && named.add(current2.key), t2.isIdentifier(current2) && current2.name === "args" && !named.has(current2) && (reads = !0);
|
|
16044
|
+
}), reads;
|
|
16045
|
+
}
|
|
16032
16046
|
function buildInvalidSpread(entries) {
|
|
16033
16047
|
if (entries.length === 0)
|
|
16034
16048
|
return null;
|
|
@@ -16343,8 +16357,13 @@ function normalizeFileName(typescript, fileName) {
|
|
|
16343
16357
|
|
|
16344
16358
|
// src/componentManifest/resolveComponents.ts
|
|
16345
16359
|
import { recast } from "storybook/internal/babel";
|
|
16346
|
-
import { storyNameFromExport } from "storybook/internal/csf";
|
|
16347
|
-
import {
|
|
16360
|
+
import { storyNameFromExport } from "storybook/internal/csf/csf-utils";
|
|
16361
|
+
import {
|
|
16362
|
+
createStoryArgsResolver as createStoryArgsResolver2,
|
|
16363
|
+
extractStoryJSDocInfo,
|
|
16364
|
+
loadCsf,
|
|
16365
|
+
unresolvedWarning
|
|
16366
|
+
} from "storybook/internal/csf-tools";
|
|
16348
16367
|
|
|
16349
16368
|
// src/componentManifest/getComponentImports.ts
|
|
16350
16369
|
import { dirname as dirname6 } from "node:path";
|
|
@@ -16550,32 +16569,38 @@ async function resolveStoryFileComponents(options) {
|
|
|
16550
16569
|
}));
|
|
16551
16570
|
return { storyPath, storyFile, csf, componentName, allComponents, component, subcomponents };
|
|
16552
16571
|
}
|
|
16553
|
-
function extractStorySnippets(csf, componentName, filterStoryIds) {
|
|
16554
|
-
|
|
16572
|
+
function extractStorySnippets(csf, componentName, filterStoryIds, references) {
|
|
16573
|
+
let imports = [], resolver = createStoryArgsResolver2(csf, references);
|
|
16574
|
+
return { stories: Object.entries(csf._stories).filter(([, story]) => !filterStoryIds || filterStoryIds.has(story.id)).map(([storyExport, story]) => {
|
|
16555
16575
|
let name = story.name ?? storyNameFromExport(storyExport);
|
|
16556
16576
|
try {
|
|
16557
|
-
let { description, summary } = extractStoryJSDocInfo(csf._storyStatements[storyExport]);
|
|
16577
|
+
let { description, summary } = extractStoryJSDocInfo(csf._storyStatements[storyExport]), snippet = getCodeSnippet(csf, storyExport, componentName, resolver);
|
|
16578
|
+
imports.push(...snippet.imports);
|
|
16579
|
+
let warning = unresolvedWarning(snippet.unresolved);
|
|
16558
16580
|
return {
|
|
16559
16581
|
id: story.id,
|
|
16560
16582
|
name,
|
|
16561
|
-
snippet: recast.print(
|
|
16583
|
+
snippet: recast.print(snippet.node).code,
|
|
16562
16584
|
description,
|
|
16563
|
-
summary
|
|
16585
|
+
summary,
|
|
16586
|
+
...warning ? { warning } : {}
|
|
16564
16587
|
};
|
|
16565
16588
|
} catch (e) {
|
|
16566
16589
|
let err = e instanceof Error ? e : new Error(String(e));
|
|
16567
16590
|
return { id: story.id, name, error: { name: err.name, message: err.message } };
|
|
16568
16591
|
}
|
|
16569
|
-
});
|
|
16592
|
+
}), imports };
|
|
16570
16593
|
}
|
|
16571
16594
|
|
|
16572
16595
|
// src/componentManifest/buildReactComponentDocgen.ts
|
|
16573
16596
|
import { getComponentIdFromEntry } from "storybook/internal/common";
|
|
16574
16597
|
import {
|
|
16575
16598
|
buildImportStatements as buildImportStatements2,
|
|
16599
|
+
createStoryReferenceResolver,
|
|
16576
16600
|
extractComponentDescription,
|
|
16577
16601
|
extractDescription
|
|
16578
16602
|
} from "storybook/internal/csf-tools";
|
|
16603
|
+
var openStoryReferences = createStoryReferenceResolver();
|
|
16579
16604
|
function getPackageInfo(componentPath, fallbackPath) {
|
|
16580
16605
|
let nearestPkg = cachedFindUp("package.json", {
|
|
16581
16606
|
cwd: posix.dirname(componentPath ?? fallbackPath)
|
|
@@ -16673,14 +16698,17 @@ function buildStoryDocsFromResolved({
|
|
|
16673
16698
|
allComponents,
|
|
16674
16699
|
filterStoryIds
|
|
16675
16700
|
}) {
|
|
16676
|
-
let id = getComponentIdFromEntry(entry), title = entry.title.split("/").at(-1).replace(/\s+/g, ""), packageName = getPackageInfo(component?.path, storyPath), fallbackImport = getFallbackImport(packageName, componentName),
|
|
16677
|
-
|
|
16701
|
+
let id = getComponentIdFromEntry(entry), title = entry.title.split("/").at(-1).replace(/\s+/g, ""), packageName = getPackageInfo(component?.path, storyPath), fallbackImport = getFallbackImport(packageName, componentName), storyEntries = extractStorySnippets(csf, component?.componentName, filterStoryIds, {
|
|
16702
|
+
filePath: storyPath,
|
|
16703
|
+
...openStoryReferences()
|
|
16704
|
+
}), argRefs = storyEntries.imports.map((ref2) => ({ ...ref2, isPackage: !0 })), imports = buildImportStatements2({ refs: [...allComponents, ...argRefs], packageName }).join(`
|
|
16705
|
+
`).trim() || fallbackImport;
|
|
16678
16706
|
return {
|
|
16679
16707
|
id,
|
|
16680
16708
|
name: componentName ?? title,
|
|
16681
16709
|
path: storyFilePath,
|
|
16682
16710
|
...imports ? { import: imports } : {},
|
|
16683
|
-
stories: Object.fromEntries(storyEntries.map((story) => [story.id, story]))
|
|
16711
|
+
stories: Object.fromEntries(storyEntries.stories.map((story) => [story.id, story]))
|
|
16684
16712
|
};
|
|
16685
16713
|
}
|
|
16686
16714
|
function buildComponentDocgenFromResolved({
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_qwngdwe5vmo from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_qwngdwe5vmo from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_qwngdwe5vmo from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_qwngdwe5vmo.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_qwngdwe5vmo.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_qwngdwe5vmo.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
extractArgTypes,
|
|
16
16
|
posix,
|
|
17
17
|
resolveStoryFileComponents
|
|
18
|
-
} from "../_node-chunks/chunk-
|
|
18
|
+
} from "../_node-chunks/chunk-AI46LAWL.js";
|
|
19
19
|
|
|
20
20
|
// src/docgen/docgen-worker.ts
|
|
21
21
|
import { createLazyDocgenMiddleware } from "storybook/internal/common";
|
package/dist/preset.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_qwngdwe5vmo from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_qwngdwe5vmo from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_qwngdwe5vmo from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_qwngdwe5vmo.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_qwngdwe5vmo.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_qwngdwe5vmo.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
parseWithReactDocgen,
|
|
23
23
|
posix,
|
|
24
24
|
resolveStoryFileComponents
|
|
25
|
-
} from "./_node-chunks/chunk-
|
|
25
|
+
} from "./_node-chunks/chunk-AI46LAWL.js";
|
|
26
26
|
|
|
27
27
|
// src/preset.ts
|
|
28
28
|
import path2, { join as join3 } from "node:path";
|
|
@@ -466,7 +466,7 @@ var enrichCsf = async (input, options) => {
|
|
|
466
466
|
return;
|
|
467
467
|
let { format: format3 } = await getPrettier(), node, snippet;
|
|
468
468
|
try {
|
|
469
|
-
node = getCodeSnippet(csfSource, key, csfSource._meta?.component);
|
|
469
|
+
node = getCodeSnippet(csfSource, key, csfSource._meta?.component).node;
|
|
470
470
|
} catch (e) {
|
|
471
471
|
if (!(e instanceof Error))
|
|
472
472
|
return;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/react",
|
|
3
|
-
"version": "10.6.0-alpha.
|
|
3
|
+
"version": "10.6.0-alpha.8",
|
|
4
4
|
"description": "Storybook React renderer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook"
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
],
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@storybook/global": "^5.0.0",
|
|
52
|
-
"@storybook/react-dom-shim": "10.6.0-alpha.
|
|
52
|
+
"@storybook/react-dom-shim": "10.6.0-alpha.8",
|
|
53
53
|
"react-docgen": "^8.0.2",
|
|
54
54
|
"react-docgen-typescript": "^2.2.2"
|
|
55
55
|
},
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"@types/react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
83
83
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
84
84
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
85
|
-
"storybook": "^10.6.0-alpha.
|
|
85
|
+
"storybook": "^10.6.0-alpha.8",
|
|
86
86
|
"typescript": ">= 4.9.x"
|
|
87
87
|
},
|
|
88
88
|
"peerDependenciesMeta": {
|