@storybook/angular-vite 11.0.0-beta.0 → 11.0.0-beta.2
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/dist/_browser-chunks/{chunk-IEOSIOYC.js → chunk-FDLKT4EQ.js} +39 -5
- package/dist/_browser-chunks/{chunk-GCT6OYDT.js → chunk-JSKZYOEY.js} +1 -1
- package/dist/_browser-chunks/{chunk-VFDWJHES.js → chunk-OAG3JRJQ.js} +3 -3
- package/dist/_browser-chunks/{chunk-RMTRNQGG.js → chunk-VA3FEKPB.js} +39 -3
- package/dist/_node-chunks/{chunk-E664BXNN.js → chunk-2F3CYJX5.js} +6 -6
- package/dist/_node-chunks/{chunk-ATBUCPE5.js → chunk-ETGWD5QX.js} +6 -6
- package/dist/_node-chunks/{story-docs-template-analysis-TF3YWXBE.js → chunk-VQ2WVY73.js} +52 -23
- package/dist/_node-chunks/{chunk-I67O6S5U.js → chunk-WCYA5VMZ.js} +9 -9
- package/dist/_node-chunks/story-docs-template-analysis-65HGKMRZ.js +19 -0
- package/dist/builders/build-storybook/index.js +8 -8
- package/dist/builders/start-storybook/index.js +8 -8
- package/dist/client/config.js +2 -2
- package/dist/client/docs/config.js +2 -2
- package/dist/client/index.js +4 -4
- package/dist/client/vitest-compiler-setup.js +2 -0
- package/dist/docgen/docgen-worker.js +1651 -196
- package/dist/index.js +4 -4
- package/dist/node/index.js +6 -6
- package/dist/node/vitest.js +8 -8
- package/dist/preset.js +254 -137
- package/package.json +7 -5
- package/start-schema.json +1 -1
- package/template/cli/button.stories.ts +11 -14
- package/template/cli/header.stories.ts +6 -9
- package/template/cli/page.stories.ts +6 -9
package/dist/index.js
CHANGED
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
componentWrapperDecorator,
|
|
6
6
|
moduleMetadata,
|
|
7
7
|
setProjectAnnotations
|
|
8
|
-
} from "./_browser-chunks/chunk-
|
|
9
|
-
import "./_browser-chunks/chunk-
|
|
10
|
-
import "./_browser-chunks/chunk-
|
|
11
|
-
import "./_browser-chunks/chunk-
|
|
8
|
+
} from "./_browser-chunks/chunk-OAG3JRJQ.js";
|
|
9
|
+
import "./_browser-chunks/chunk-JSKZYOEY.js";
|
|
10
|
+
import "./_browser-chunks/chunk-VA3FEKPB.js";
|
|
11
|
+
import "./_browser-chunks/chunk-FDLKT4EQ.js";
|
|
12
12
|
export {
|
|
13
13
|
__definePreview,
|
|
14
14
|
applicationConfig,
|
package/dist/node/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_yl4v0bl5wmj from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_yl4v0bl5wmj from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_yl4v0bl5wmj from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_yl4v0bl5wmj.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_yl4v0bl5wmj.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_yl4v0bl5wmj.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
package/dist/node/vitest.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_yl4v0bl5wmj from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_yl4v0bl5wmj from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_yl4v0bl5wmj from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_yl4v0bl5wmj.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_yl4v0bl5wmj.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_yl4v0bl5wmj.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
@@ -25,7 +25,7 @@ var ENV_KEY = "STORYBOOK_ANGULAR_BUILDER_OPTIONS_JSON", findNodeModulesRoots = (
|
|
|
25
25
|
dir = parent;
|
|
26
26
|
}
|
|
27
27
|
return roots;
|
|
28
|
-
}, COMPILER_SETUP = "@angular/compiler";
|
|
28
|
+
}, COMPILER_SETUP = "@storybook/angular-vite/internal/vitest-compiler-setup";
|
|
29
29
|
function storybookAngularVitest(options = {}) {
|
|
30
30
|
let serialized;
|
|
31
31
|
try {
|
|
@@ -47,7 +47,7 @@ function storybookAngularVitest(options = {}) {
|
|
|
47
47
|
// `node_modules` (with `@angular/compiler`) lives at the workspace root. Vite only treats
|
|
48
48
|
// `pnpm-workspace.yaml`, `lerna.json`, or a `workspaces` field as workspace-root markers, so a
|
|
49
49
|
// plain Angular workspace resolves the root to the library folder — and the `@angular/compiler`
|
|
50
|
-
// setup file
|
|
50
|
+
// module that the setup file imports falls outside `server.fs.allow`, failing to load in the browser with
|
|
51
51
|
// "Failed to fetch dynamically imported module". Allow every ancestor that contains
|
|
52
52
|
// `node_modules`. `configureServer` is required: Vitest builds the browser server's allow-list
|
|
53
53
|
// itself, so entries added via the `config` hook or static config never reach it.
|
package/dist/preset.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import CJS_COMPAT_NODE_URL_yl4v0bl5wmj from 'node:url';
|
|
2
|
+
import CJS_COMPAT_NODE_PATH_yl4v0bl5wmj from 'node:path';
|
|
3
|
+
import CJS_COMPAT_NODE_MODULE_yl4v0bl5wmj from "node:module";
|
|
4
4
|
|
|
5
|
-
var __filename =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
5
|
+
var __filename = CJS_COMPAT_NODE_URL_yl4v0bl5wmj.fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = CJS_COMPAT_NODE_PATH_yl4v0bl5wmj.dirname(__filename);
|
|
7
|
+
var require = CJS_COMPAT_NODE_MODULE_yl4v0bl5wmj.createRequire(import.meta.url);
|
|
8
8
|
|
|
9
9
|
// ------------------------------------------------------------
|
|
10
10
|
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
11
|
// ------------------------------------------------------------
|
|
12
12
|
import {
|
|
13
13
|
findTsconfigUp
|
|
14
|
-
} from "./_node-chunks/chunk-
|
|
14
|
+
} from "./_node-chunks/chunk-ETGWD5QX.js";
|
|
15
15
|
import {
|
|
16
16
|
parseStoryFile
|
|
17
|
-
} from "./_node-chunks/chunk-
|
|
17
|
+
} from "./_node-chunks/chunk-2F3CYJX5.js";
|
|
18
|
+
import {
|
|
19
|
+
materializeLike
|
|
20
|
+
} from "./_node-chunks/chunk-VQ2WVY73.js";
|
|
18
21
|
|
|
19
22
|
// src/preset.ts
|
|
20
23
|
import { findConfigFile, isTypeScriptReadyForDocgen } from "storybook/internal/common";
|
|
@@ -234,6 +237,7 @@ var COMPODOC_LOCK = ".compodoc.lock", COMPODOC_RUN_MARKER = ".compodoc.run", RUN
|
|
|
234
237
|
|
|
235
238
|
// src/docgen/preset.ts
|
|
236
239
|
import { fileURLToPath } from "node:url";
|
|
240
|
+
import { getTypeScriptSpecifierForDocgen } from "storybook/internal/common";
|
|
237
241
|
|
|
238
242
|
// src/docgen/worker-specifier.ts
|
|
239
243
|
var DOCGEN_WORKER_SPECIFIER = "@storybook/angular-vite/internal/docgen-worker";
|
|
@@ -243,7 +247,8 @@ var experimental_docgenProvider = async (existing = [], options) => {
|
|
|
243
247
|
let features2 = await options?.presets?.apply("features", {}), descriptor = {
|
|
244
248
|
moduleSpecifier: fileURLToPath(import.meta.resolve(DOCGEN_WORKER_SPECIFIER)),
|
|
245
249
|
options: {
|
|
246
|
-
propsTable: resolvePropsTable(await options?.presets?.apply("frameworkOptions"), features2)
|
|
250
|
+
propsTable: resolvePropsTable(await options?.presets?.apply("frameworkOptions"), features2),
|
|
251
|
+
typeScriptSpecifier: options && await getTypeScriptSpecifierForDocgen(options)
|
|
247
252
|
}
|
|
248
253
|
};
|
|
249
254
|
return [...existing, descriptor];
|
|
@@ -295,8 +300,157 @@ import {
|
|
|
295
300
|
unwrapExpression
|
|
296
301
|
} from "storybook/internal/csf-tools";
|
|
297
302
|
|
|
303
|
+
// src/snippet-values.ts
|
|
304
|
+
var isValidIdentifier = (name) => /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(name), quoteExpressionString = (value) => `'${value.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/\n/g, "\\n").replace(/\r/g, "\\r")}'`, printExpressionValue = (value, unprintable) => {
|
|
305
|
+
let parents = /* @__PURE__ */ new Set(), print = (value2) => {
|
|
306
|
+
if (typeof value2 == "string")
|
|
307
|
+
return quoteExpressionString(value2);
|
|
308
|
+
if (unprintable && hasNoExpression(value2, parents))
|
|
309
|
+
return unprintable();
|
|
310
|
+
if (typeof value2 != "object" || value2 === null)
|
|
311
|
+
return `${value2}`;
|
|
312
|
+
parents.add(value2);
|
|
313
|
+
let printed = Array.isArray(value2) ? `[${value2.map((element) => print(element ?? null)).join(", ")}]` : `{${Object.entries(value2).filter(([, entryValue]) => entryValue !== void 0).map(
|
|
314
|
+
([key, entryValue]) => `${isValidIdentifier(key) ? key : quoteExpressionString(key)}: ${print(entryValue)}`
|
|
315
|
+
).join(", ")}}`;
|
|
316
|
+
return parents.delete(value2), printed;
|
|
317
|
+
};
|
|
318
|
+
return print(value);
|
|
319
|
+
}, hasNoExpression = (value, parents) => {
|
|
320
|
+
if (typeof value != "object" || value === null)
|
|
321
|
+
return typeof value == "function" || typeof value == "symbol" || typeof value == "bigint";
|
|
322
|
+
let prototype = Object.getPrototypeOf(value);
|
|
323
|
+
return parents.has(value) || !Array.isArray(value) && prototype !== Object.prototype && prototype !== null;
|
|
324
|
+
}, escapeAttributeExpression = (expression) => expression.replace(/&(?=#|\w+;)/g, "&").replace(/"/g, """), escapeTemplateLiteral = (template) => template.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${"), inputBinding = (name, expression) => `[${name}]="${expression}"`, textValue = (value) => typeof value == "string" ? value : typeof value == "number" || typeof value == "boolean" ? String(value) : void 0, angularText = (text) => text.includes("{{") ? void 0 : text.replace(/[{}@]|\$$/g, (syntax) => `&#${syntax.charCodeAt(0)};`), indentLines = (code, indent) => code.split(`
|
|
325
|
+
`).join(`
|
|
326
|
+
${indent}`);
|
|
327
|
+
|
|
328
|
+
// src/docgen/story-docs-args.ts
|
|
329
|
+
var EVAL_FAILED = /* @__PURE__ */ Symbol("story-docs-eval-failed"), createArgExternalizer = (enums) => (node) => {
|
|
330
|
+
let value = evaluateNode(node, enums);
|
|
331
|
+
return value === EVAL_FAILED ? void 0 : parseExpression(printExpressionValue(value));
|
|
332
|
+
}, evaluateArgLiteral = (node, enums) => {
|
|
333
|
+
let value = evaluateNode(unwrapExpression(node), enums);
|
|
334
|
+
return value === EVAL_FAILED ? void 0 : printExpressionValue(value);
|
|
335
|
+
}, argFieldValue = (node) => expandTabs(detachedTextOf(unwrapExpression(node))), evaluateArgExpression = (node, enums) => {
|
|
336
|
+
let literal = evaluateArgLiteral(node, enums);
|
|
337
|
+
return escapeAttributeExpression(
|
|
338
|
+
literal ?? expandTabs(withoutComments(detachedTextOf(unwrapExpression(node))))
|
|
339
|
+
);
|
|
340
|
+
}, expandTabs = (code) => {
|
|
341
|
+
let result = code, deepest = Math.max(0, ...result.split(`
|
|
342
|
+
`).map((line) => /^\t*/.exec(line)[0].length));
|
|
343
|
+
for (let depth = deepest; depth > 0; depth--)
|
|
344
|
+
result = reindent(result, " ".repeat(depth), " ".repeat(depth));
|
|
345
|
+
return result;
|
|
346
|
+
}, withoutComments = (code) => {
|
|
347
|
+
let { code: wrapped, comments } = parseModule(`(${code}
|
|
348
|
+
)`), result = "", cursor = 0;
|
|
349
|
+
for (let comment of comments)
|
|
350
|
+
result += wrapped.slice(cursor, comment.start), cursor = comment.end + /^[ \t]*/.exec(wrapped.slice(comment.end))[0].length, wrapped[cursor] === `
|
|
351
|
+
` ? result = result.replace(/[ \t]+$/, "") : /[\w$]$/.test(result) && /[\w$]/.test(wrapped[cursor]) && (result += " ");
|
|
352
|
+
return result += wrapped.slice(cursor), result.slice(1, -2);
|
|
353
|
+
}, evaluateNode = (node, enums) => {
|
|
354
|
+
let unwrapped = unwrapExpression(node);
|
|
355
|
+
if (unwrapped.type === "Literal") {
|
|
356
|
+
let { value } = unwrapped;
|
|
357
|
+
return typeof value == "string" || typeof value == "number" || typeof value == "boolean" ? value : "regex" in unwrapped || "bigint" in unwrapped ? EVAL_FAILED : null;
|
|
358
|
+
}
|
|
359
|
+
if (!(unwrapped.type === "Identifier" && unwrapped.name === "undefined") && !(unwrapped.type === "UnaryExpression" && unwrapped.operator === "void")) {
|
|
360
|
+
if (unwrapped.type === "UnaryExpression" && unwrapped.operator === "-" && unwrapped.argument.type === "Literal" && typeof unwrapped.argument.value == "number")
|
|
361
|
+
return -unwrapped.argument.value;
|
|
362
|
+
if (unwrapped.type === "TemplateLiteral" && unwrapped.expressions.length === 0)
|
|
363
|
+
return unwrapped.quasis[0]?.value.cooked ?? EVAL_FAILED;
|
|
364
|
+
if (unwrapped.type === "ArrayExpression") {
|
|
365
|
+
let values = [];
|
|
366
|
+
for (let element of unwrapped.elements) {
|
|
367
|
+
if (element === null || element.type === "SpreadElement")
|
|
368
|
+
return EVAL_FAILED;
|
|
369
|
+
let value = evaluateNode(element, enums);
|
|
370
|
+
if (value === EVAL_FAILED)
|
|
371
|
+
return EVAL_FAILED;
|
|
372
|
+
values.push(value);
|
|
373
|
+
}
|
|
374
|
+
return values;
|
|
375
|
+
}
|
|
376
|
+
if (unwrapped.type === "ObjectExpression") {
|
|
377
|
+
let value = {};
|
|
378
|
+
for (let property of unwrapped.properties) {
|
|
379
|
+
if (property.type !== "Property" || property.method || property.kind !== "init")
|
|
380
|
+
return EVAL_FAILED;
|
|
381
|
+
let key = staticKey(property);
|
|
382
|
+
if (key === void 0)
|
|
383
|
+
return EVAL_FAILED;
|
|
384
|
+
let propertyValue = evaluateNode(property.value, enums);
|
|
385
|
+
if (propertyValue === EVAL_FAILED)
|
|
386
|
+
return EVAL_FAILED;
|
|
387
|
+
value[key] = propertyValue;
|
|
388
|
+
}
|
|
389
|
+
return value;
|
|
390
|
+
}
|
|
391
|
+
if (unwrapped.type === "MemberExpression" && !unwrapped.computed && unwrapped.object.type === "Identifier" && unwrapped.property.type === "Identifier") {
|
|
392
|
+
let objectName = unwrapped.object.name, propertyName = unwrapped.property.name;
|
|
393
|
+
return enums.find((enumeration) => enumeration.name === objectName)?.members.find((candidate) => candidate.name === propertyName)?.value ?? EVAL_FAILED;
|
|
394
|
+
}
|
|
395
|
+
return EVAL_FAILED;
|
|
396
|
+
}
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
// src/docgen/story-docs-holes.ts
|
|
400
|
+
import {
|
|
401
|
+
createHoleMarks,
|
|
402
|
+
stripHoles,
|
|
403
|
+
withHoleSpace
|
|
404
|
+
} from "storybook/internal/docs-tools";
|
|
405
|
+
var printValues = {
|
|
406
|
+
show: (_arg, _kind, value) => value,
|
|
407
|
+
unset: () => {
|
|
408
|
+
}
|
|
409
|
+
}, printMarks = (snippet) => {
|
|
410
|
+
let marks = createHoleMarks([snippet]), read = (marked) => {
|
|
411
|
+
let template = marks.toTemplate(marked);
|
|
412
|
+
return template && withUnsetSpace(template);
|
|
413
|
+
};
|
|
414
|
+
return {
|
|
415
|
+
show: (arg, kind, value) => marks.mark({ kind, arg }, value),
|
|
416
|
+
unset: (arg) => marks.mark({ kind: "prop", arg }, ""),
|
|
417
|
+
unmarked(code) {
|
|
418
|
+
let template = read(code);
|
|
419
|
+
return template ? stripHoles(template) : code;
|
|
420
|
+
},
|
|
421
|
+
template(marked) {
|
|
422
|
+
let template = read(marked);
|
|
423
|
+
if (!(!template || stripHoles(template) !== snippet))
|
|
424
|
+
return withHoleSpace(template, ({ kind }) => kind === "prop" || kind === "text");
|
|
425
|
+
}
|
|
426
|
+
};
|
|
427
|
+
}, withUnsetSpace = (template) => {
|
|
428
|
+
let result = [];
|
|
429
|
+
for (let segment of template) {
|
|
430
|
+
let previous = result.at(-1), space = typeof previous == "string" ? /\s*$/.exec(previous)[0] : "";
|
|
431
|
+
if (typeof segment == "string" || !isUnset(segment) || space === "") {
|
|
432
|
+
result.push(segment);
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
let before = previous.slice(0, -space.length);
|
|
436
|
+
result.splice(-1, 1, ...before ? [before] : [], { ...segment, space });
|
|
437
|
+
}
|
|
438
|
+
return result;
|
|
439
|
+
}, isUnset = (hole) => hole.kind === "prop" && hole.text === "";
|
|
440
|
+
|
|
441
|
+
// src/docgen/story-docs-markup.ts
|
|
442
|
+
import {
|
|
443
|
+
importedName,
|
|
444
|
+
isCanonicalCsf2BindCall,
|
|
445
|
+
isStringLiteral,
|
|
446
|
+
oneLineTextOf,
|
|
447
|
+
staticKey as staticKey2,
|
|
448
|
+
templateParts,
|
|
449
|
+
unwrapExpression as unwrapExpression2
|
|
450
|
+
} from "storybook/internal/csf-tools";
|
|
451
|
+
|
|
298
452
|
// src/template-grammar.ts
|
|
299
|
-
var
|
|
453
|
+
var formatPropInTemplate = (propertyName) => isValidIdentifier(propertyName) ? propertyName : `this['${propertyName}']`;
|
|
300
454
|
var VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
301
455
|
"area",
|
|
302
456
|
"base",
|
|
@@ -314,14 +468,14 @@ var VOID_ELEMENTS = /* @__PURE__ */ new Set([
|
|
|
314
468
|
"source",
|
|
315
469
|
"track",
|
|
316
470
|
"wbr"
|
|
317
|
-
]), LEADING_CLASS = /^\..+/, LEADING_ATTRIBUTE = /^\[.+?]/, ID = /#([\w-]+)/, CLASS_RUN = /(\.[\w-]+)+/, ATTRIBUTE = /\[(.+?)]/g, ELEMENT_AND_ATTRIBUTES = /(\S+)(.*)/, MAX_SINGLE_LINE = 80, buildTemplate = (selector, { inputs, outputs, innerTemplate = "", selfClosing = !1 }) => {
|
|
471
|
+
]), LEADING_CLASS = /^\..+/, LEADING_ATTRIBUTE = /^\[.+?]/, ID = /#([\w-]+)/, CLASS_RUN = /(\.[\w-]+)+/, ATTRIBUTE = /\[(.+?)]/g, ELEMENT_AND_ATTRIBUTES = /(\S+)(.*)/, MAX_SINGLE_LINE = 80, asWritten = (code) => code, buildTemplate = (selector, { inputs, outputs, innerTemplate = "", selfClosing = !1 }, unmarked = asWritten) => {
|
|
318
472
|
let bindings = [
|
|
319
|
-
...inputs.map(({ name, expression }) =>
|
|
473
|
+
...inputs.map(({ name, expression, attribute }) => attribute ?? inputBinding(name, expression)),
|
|
320
474
|
...outputs.map((name) => `(${name})="${formatPropInTemplate(name)}($event)"`)
|
|
321
475
|
], firstSelector = selector.split(",")[0];
|
|
322
476
|
return (LEADING_CLASS.test(firstSelector) || LEADING_ATTRIBUTE.test(firstSelector) ? `div${firstSelector}` : firstSelector).replace(ID, ' id="$1"').replace(CLASS_RUN, (classes) => ` class="${classes.split(".").join(" ").trim()}"`).replace(ATTRIBUTE, " $1").replace(ELEMENT_AND_ATTRIBUTES, (_, element, attributes) => {
|
|
323
477
|
let closesItself = VOID_ELEMENTS.has(element) || selfClosing && element.includes("-") && innerTemplate === "", inlineTag = `<${element}${attributes}${bindings.map((binding) => ` ${binding}`).join("")}`, inline = closesItself ? `${inlineTag} />` : `${inlineTag}>${innerTemplate}</${element}>`;
|
|
324
|
-
if (inline.length <= MAX_SINGLE_LINE || bindings.
|
|
478
|
+
if (unmarked(inline).length <= MAX_SINGLE_LINE || bindings.every((binding) => unmarked(binding) === ""))
|
|
325
479
|
return inline;
|
|
326
480
|
let brokenTag = `<${element}${attributes}
|
|
327
481
|
${bindings.map((binding) => ` ${binding}`).join(`
|
|
@@ -369,9 +523,9 @@ ${innerTemplate}
|
|
|
369
523
|
}
|
|
370
524
|
let trailing = markup.slice(lastIndex).trim();
|
|
371
525
|
return trailing && stack.at(-1).children.push(trailing), stack.length === 1 ? root.children : void 0;
|
|
372
|
-
}, MARKUP_ATTRIBUTE = /[^\s=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|\S+))
|
|
526
|
+
}, MARKUP_ATTRIBUTE = /[^\s=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|\S+))?[\uE000-\uF8FF]*/g, openTagLines = (node, pad, forceAttrBreak, unmarked) => {
|
|
373
527
|
let inlineOpen = `${pad}${node.rawOpen}`, attrs = node.attrText.match(MARKUP_ATTRIBUTE) ?? [];
|
|
374
|
-
if (inlineOpen.length <= MAX_SINGLE_LINE && !forceAttrBreak || attrs.
|
|
528
|
+
if (unmarked(inlineOpen).length <= MAX_SINGLE_LINE && !forceAttrBreak || attrs.every((attr) => unmarked(attr) === ""))
|
|
375
529
|
return [inlineOpen];
|
|
376
530
|
let bracket = node.closed ? " />" : ">";
|
|
377
531
|
return [
|
|
@@ -380,112 +534,34 @@ ${innerTemplate}
|
|
|
380
534
|
(attr, index) => `${pad}${INDENT}${attr}${index === attrs.length - 1 ? bracket : ""}`
|
|
381
535
|
)
|
|
382
536
|
];
|
|
383
|
-
}, printMarkup = (markup, node, depth) => {
|
|
537
|
+
}, printMarkup = (markup, node, depth, unmarked) => {
|
|
384
538
|
let pad = INDENT.repeat(depth);
|
|
385
539
|
if (typeof node == "string")
|
|
386
540
|
return [`${pad}${node}`];
|
|
387
541
|
let hasElementChild = node.children.some((child) => typeof child != "string"), verbatim = markup.slice(node.start, node.end);
|
|
388
|
-
if (!hasElementChild && pad.length + verbatim.length <= MAX_SINGLE_LINE)
|
|
542
|
+
if (!hasElementChild && pad.length + unmarked(verbatim).length <= MAX_SINGLE_LINE)
|
|
389
543
|
return [`${pad}${verbatim}`];
|
|
390
|
-
let openLines = openTagLines(node, pad, !hasElementChild);
|
|
544
|
+
let openLines = openTagLines(node, pad, !hasElementChild, unmarked);
|
|
391
545
|
return node.closed ? openLines : [
|
|
392
546
|
...openLines,
|
|
393
|
-
...node.children.flatMap((child) => printMarkup(markup, child, depth + 1)),
|
|
547
|
+
...node.children.flatMap((child) => printMarkup(markup, child, depth + 1, unmarked)),
|
|
394
548
|
`${pad}</${node.tag}>`
|
|
395
549
|
];
|
|
396
|
-
}, formatTemplateMarkup = (markup) => {
|
|
550
|
+
}, formatTemplateMarkup = (markup, unmarked = asWritten) => {
|
|
397
551
|
let children = parseMarkup(markup);
|
|
398
|
-
return !children || children.length === 0 ? markup : children.flatMap((child) => printMarkup(markup, child, 0)).join(`
|
|
552
|
+
return !children || children.length === 0 ? markup : children.flatMap((child) => printMarkup(markup, child, 0, unmarked)).join(`
|
|
399
553
|
`);
|
|
400
554
|
};
|
|
401
555
|
|
|
402
|
-
// src/docgen/story-docs-args.ts
|
|
403
|
-
var EVAL_FAILED = /* @__PURE__ */ Symbol("story-docs-eval-failed"), createArgExternalizer = (enums) => (node) => {
|
|
404
|
-
let value = evaluateNode(node, enums);
|
|
405
|
-
return value === EVAL_FAILED ? void 0 : parseExpression(printExpressionValue(value, /* @__PURE__ */ new Set()));
|
|
406
|
-
}, evaluateArgLiteral = (node, enums) => {
|
|
407
|
-
let value = evaluateNode(unwrapExpression(node), enums);
|
|
408
|
-
return value === EVAL_FAILED ? void 0 : printExpressionValue(value, /* @__PURE__ */ new Set());
|
|
409
|
-
}, argFieldValue = (node) => expandTabs(detachedTextOf(unwrapExpression(node))), evaluateArgExpression = (node, enums) => {
|
|
410
|
-
let literal = evaluateArgLiteral(node, enums);
|
|
411
|
-
return escapeAttributeExpression(
|
|
412
|
-
literal ?? expandTabs(withoutComments(detachedTextOf(unwrapExpression(node))))
|
|
413
|
-
);
|
|
414
|
-
}, expandTabs = (code) => {
|
|
415
|
-
let result = code, deepest = Math.max(0, ...result.split(`
|
|
416
|
-
`).map((line) => /^\t*/.exec(line)[0].length));
|
|
417
|
-
for (let depth = deepest; depth > 0; depth--)
|
|
418
|
-
result = reindent(result, " ".repeat(depth), " ".repeat(depth));
|
|
419
|
-
return result;
|
|
420
|
-
}, withoutComments = (code) => {
|
|
421
|
-
let { code: wrapped, comments } = parseModule(`(${code}
|
|
422
|
-
)`), result = "", cursor = 0;
|
|
423
|
-
for (let comment of comments)
|
|
424
|
-
result += wrapped.slice(cursor, comment.start), cursor = comment.end + /^[ \t]*/.exec(wrapped.slice(comment.end))[0].length, wrapped[cursor] === `
|
|
425
|
-
` ? result = result.replace(/[ \t]+$/, "") : /[\w$]$/.test(result) && /[\w$]/.test(wrapped[cursor]) && (result += " ");
|
|
426
|
-
return result += wrapped.slice(cursor), result.slice(1, -2);
|
|
427
|
-
}, quoteExpressionString = (value) => `'${value.replace(/\\/g, "\\\\").replace(/'/g, "\\'").replace(/\n/g, "\\n").replace(/\r/g, "\\r")}'`, printExpressionValue = (value, seen) => typeof value == "string" ? quoteExpressionString(value) : typeof value != "object" || value === null ? `${value}` : seen.has(value) ? quoteExpressionString("[Circular]") : (seen.add(value), Array.isArray(value) ? `[${value.map((element) => printExpressionValue(element ?? null, seen)).join(", ")}]` : `{${Object.entries(value).filter(([, entryValue]) => entryValue !== void 0).map(
|
|
428
|
-
([key, entryValue]) => `${isValidIdentifier(key) ? key : quoteExpressionString(key)}: ${printExpressionValue(entryValue, seen)}`
|
|
429
|
-
).join(", ")}}`), escapeAttributeExpression = (expression) => expression.replace(/&(?=#|\w+;)/g, "&").replace(/"/g, """), evaluateNode = (node, enums) => {
|
|
430
|
-
let unwrapped = unwrapExpression(node);
|
|
431
|
-
if (unwrapped.type === "Literal") {
|
|
432
|
-
let { value } = unwrapped;
|
|
433
|
-
return typeof value == "string" || typeof value == "number" || typeof value == "boolean" ? value : "regex" in unwrapped || "bigint" in unwrapped ? EVAL_FAILED : null;
|
|
434
|
-
}
|
|
435
|
-
if (!(unwrapped.type === "Identifier" && unwrapped.name === "undefined") && !(unwrapped.type === "UnaryExpression" && unwrapped.operator === "void")) {
|
|
436
|
-
if (unwrapped.type === "UnaryExpression" && unwrapped.operator === "-" && unwrapped.argument.type === "Literal" && typeof unwrapped.argument.value == "number")
|
|
437
|
-
return -unwrapped.argument.value;
|
|
438
|
-
if (unwrapped.type === "TemplateLiteral" && unwrapped.expressions.length === 0)
|
|
439
|
-
return unwrapped.quasis[0]?.value.cooked ?? EVAL_FAILED;
|
|
440
|
-
if (unwrapped.type === "ArrayExpression") {
|
|
441
|
-
let values = [];
|
|
442
|
-
for (let element of unwrapped.elements) {
|
|
443
|
-
if (element === null || element.type === "SpreadElement")
|
|
444
|
-
return EVAL_FAILED;
|
|
445
|
-
let value = evaluateNode(element, enums);
|
|
446
|
-
if (value === EVAL_FAILED)
|
|
447
|
-
return EVAL_FAILED;
|
|
448
|
-
values.push(value);
|
|
449
|
-
}
|
|
450
|
-
return values;
|
|
451
|
-
}
|
|
452
|
-
if (unwrapped.type === "ObjectExpression") {
|
|
453
|
-
let value = {};
|
|
454
|
-
for (let property of unwrapped.properties) {
|
|
455
|
-
if (property.type !== "Property" || property.method || property.kind !== "init")
|
|
456
|
-
return EVAL_FAILED;
|
|
457
|
-
let key = staticKey(property);
|
|
458
|
-
if (key === void 0)
|
|
459
|
-
return EVAL_FAILED;
|
|
460
|
-
let propertyValue = evaluateNode(property.value, enums);
|
|
461
|
-
if (propertyValue === EVAL_FAILED)
|
|
462
|
-
return EVAL_FAILED;
|
|
463
|
-
value[key] = propertyValue;
|
|
464
|
-
}
|
|
465
|
-
return value;
|
|
466
|
-
}
|
|
467
|
-
if (unwrapped.type === "MemberExpression" && !unwrapped.computed && unwrapped.object.type === "Identifier" && unwrapped.property.type === "Identifier") {
|
|
468
|
-
let objectName = unwrapped.object.name, propertyName = unwrapped.property.name;
|
|
469
|
-
return enums.find((enumeration) => enumeration.name === objectName)?.members.find((candidate) => candidate.name === propertyName)?.value ?? EVAL_FAILED;
|
|
470
|
-
}
|
|
471
|
-
return EVAL_FAILED;
|
|
472
|
-
}
|
|
473
|
-
};
|
|
474
|
-
|
|
475
556
|
// src/docgen/story-docs-markup.ts
|
|
476
|
-
import {
|
|
477
|
-
importedName,
|
|
478
|
-
isCanonicalCsf2BindCall,
|
|
479
|
-
isStringLiteral,
|
|
480
|
-
oneLineTextOf,
|
|
481
|
-
staticKey as staticKey2,
|
|
482
|
-
templateParts,
|
|
483
|
-
unwrapExpression as unwrapExpression2
|
|
484
|
-
} from "storybook/internal/csf-tools";
|
|
485
557
|
var bindingAttributes = ({ inputs, outputs }, filter, representedArgs) => {
|
|
486
558
|
let allowed = (name) => filter.include ? filter.include.includes(name) : !filter.exclude?.includes(name), representedInputs = inputs.filter(({ name }) => allowed(name)), representedOutputs = outputs.filter(allowed);
|
|
487
|
-
return representedInputs.forEach(({ name }) =>
|
|
488
|
-
|
|
559
|
+
return representedInputs.forEach(({ name, unset }) => {
|
|
560
|
+
unset || representedArgs.add(name);
|
|
561
|
+
}), representedOutputs.forEach((name) => representedArgs.add(name)), {
|
|
562
|
+
inputAttributes: representedInputs.map(
|
|
563
|
+
({ name, expression, attribute }) => attribute ?? inputBinding(name, expression)
|
|
564
|
+
),
|
|
489
565
|
outputAttributes: representedOutputs.map((name) => ({
|
|
490
566
|
name,
|
|
491
567
|
markup: `(${name})="${formatPropInTemplate(name)}($event)"`
|
|
@@ -593,8 +669,11 @@ var bindingAttributes = ({ inputs, outputs }, filter, representedArgs) => {
|
|
|
593
669
|
return;
|
|
594
670
|
let argName = scope.argBindings.get(expression.name);
|
|
595
671
|
if (argName !== void 0) {
|
|
596
|
-
let
|
|
597
|
-
|
|
672
|
+
let written = shape.unresolvedArgs.length === 0 ? literalText(shape.args[argName]) : void 0;
|
|
673
|
+
if (written === void 0)
|
|
674
|
+
return;
|
|
675
|
+
let text = angularText(written) ?? written;
|
|
676
|
+
return representedArgs.add(argName), shape.printer ? shape.printer.show(argName, "text", text) : text;
|
|
598
677
|
}
|
|
599
678
|
if (scope.parameterNames.has(expression.name) || scope.bodyDeclared.has(expression.name))
|
|
600
679
|
return;
|
|
@@ -626,10 +705,8 @@ var bindingAttributes = ({ inputs, outputs }, filter, representedArgs) => {
|
|
|
626
705
|
return filter;
|
|
627
706
|
}, stringArray = (node) => node?.type === "ArrayExpression" && node.elements.every(isStringLiteral) ? node.elements.map((element) => element.value) : void 0, literalText = (node) => {
|
|
628
707
|
let unwrapped = node && unwrapExpression2(node);
|
|
629
|
-
if (unwrapped?.type
|
|
630
|
-
return;
|
|
631
|
-
let { value } = unwrapped;
|
|
632
|
-
return typeof value == "string" ? value : typeof value == "number" || typeof value == "boolean" ? String(value) : void 0;
|
|
708
|
+
if (unwrapped?.type === "Literal")
|
|
709
|
+
return textValue(unwrapped.value);
|
|
633
710
|
}, isNullLiteral = (node) => node.type === "Literal" && node.value === null && !("regex" in node) && !("bigint" in node), resolvedMember = (members, key) => {
|
|
634
711
|
let node = members.properties[key];
|
|
635
712
|
return node !== void 0 ? members.shadowed.includes(key) ? { kind: "unresolvable", node } : { kind: "value", node } : members.unresolved.length > 0 ? { kind: "unresolvable" } : { kind: "missing" };
|
|
@@ -772,10 +849,8 @@ var ngModulesFromDecorators = (decorators, componentName) => {
|
|
|
772
849
|
};
|
|
773
850
|
|
|
774
851
|
// src/docgen/story-docs-snippet.ts
|
|
775
|
-
var HOST_SELECTOR = "app-demo", HOST_CLASS = "DemoComponent"
|
|
776
|
-
var memberName = (name) => isValidIdentifier(name) ? name : `['${name}']`, memberValue = (value) => value
|
|
777
|
-
`).join(`
|
|
778
|
-
`), importabilityWarning = ({
|
|
852
|
+
var HOST_SELECTOR = "app-demo", HOST_CLASS = "DemoComponent";
|
|
853
|
+
var memberName = (name) => isValidIdentifier(name) ? name : `['${name}']`, memberValue = (value) => indentLines(value, " "), importabilityWarning = ({
|
|
779
854
|
componentName,
|
|
780
855
|
componentImport,
|
|
781
856
|
viaComponentOutlet,
|
|
@@ -894,6 +969,7 @@ var buildStoryDocsPayload = async (input, context) => {
|
|
|
894
969
|
name,
|
|
895
970
|
...rendered === void 0 ? {} : { snippet: rendered.snippet },
|
|
896
971
|
...rendered?.warning === void 0 ? {} : { warning: rendered.warning },
|
|
972
|
+
...rendered?.template === void 0 ? {} : { template: rendered.template },
|
|
897
973
|
...description ? { description } : {},
|
|
898
974
|
...summary === void 0 ? {} : { summary }
|
|
899
975
|
};
|
|
@@ -913,10 +989,22 @@ var buildStoryDocsPayload = async (input, context) => {
|
|
|
913
989
|
}, authored = authoredSource(authoredShape, deps.resolveStoryArgs.ctx);
|
|
914
990
|
if (authored.kind === "code")
|
|
915
991
|
return { snippet: authored.code };
|
|
916
|
-
if (authored.kind === "disabled")
|
|
992
|
+
if (authored.kind === "disabled" || !deps.snippetMeta)
|
|
917
993
|
return;
|
|
918
|
-
let
|
|
919
|
-
|
|
994
|
+
let decorators = shape.members.properties.decorators, derived = await renderStorySnippet(deps.snippetMeta, shape, decorators, deps, printValues), template = await storyTemplate(deps.snippetMeta, shape, decorators, deps, derived).catch(
|
|
995
|
+
() => ({})
|
|
996
|
+
), authoredWarning = authored.kind === "unresolvable" ? unresolvedWarning([authored.source]) : void 0;
|
|
997
|
+
return { ...withWarnings(derived, authoredWarning), ...template };
|
|
998
|
+
}, storyTemplate = async (snippetMeta, shape, decorators, deps, derived) => {
|
|
999
|
+
let marks = printMarks(derived.snippet), marked = await renderStorySnippet(
|
|
1000
|
+
snippetMeta,
|
|
1001
|
+
shape,
|
|
1002
|
+
decorators,
|
|
1003
|
+
deps,
|
|
1004
|
+
marks,
|
|
1005
|
+
derived.analysis
|
|
1006
|
+
), template = marks.template(marked.snippet);
|
|
1007
|
+
return template === void 0 ? {} : { template };
|
|
920
1008
|
}, storyShape = (exportName, deps) => {
|
|
921
1009
|
let resolved = deps.resolveStoryArgs.resolve(exportName), enums = deps.snippetMeta?.enums ?? [], unresolved = [...resolved.unresolved];
|
|
922
1010
|
for (let value of Object.values(resolved.args))
|
|
@@ -929,8 +1017,8 @@ var buildStoryDocsPayload = async (input, context) => {
|
|
|
929
1017
|
args: resolved.args,
|
|
930
1018
|
unresolvedArgs: unresolved
|
|
931
1019
|
};
|
|
932
|
-
}, renderStorySnippet = async (snippetMeta,
|
|
933
|
-
let { componentImport } = deps, localName = componentNameOf(shape.csf._metaAnnotations.component) ?? snippetMeta.name, ngModules = storyNgModules(storyDecorators, deps), expansion = argsExpansion(snippetMeta, shape), userMarkup = userTemplate(shape, shape.unresolvedArgs.length === 0 ? expansion : void 0), host = (template, viaComponentOutlet, outputs, fields2) => buildHostComponentSnippet({
|
|
1020
|
+
}, renderStorySnippet = async (snippetMeta, baseShape, storyDecorators, deps, printer, valuesAnalysis) => {
|
|
1021
|
+
let shape = { ...baseShape, printer }, { componentImport } = deps, localName = componentNameOf(shape.csf._metaAnnotations.component) ?? snippetMeta.name, ngModules = storyNgModules(storyDecorators, deps), expansion = argsExpansion(snippetMeta, shape, printer), userMarkup = userTemplate(shape, shape.unresolvedArgs.length === 0 ? expansion : void 0), host = (template, viaComponentOutlet, outputs, fields2) => buildHostComponentSnippet({
|
|
934
1022
|
template,
|
|
935
1023
|
componentName: localName,
|
|
936
1024
|
componentImport,
|
|
@@ -941,15 +1029,16 @@ var buildStoryDocsPayload = async (input, context) => {
|
|
|
941
1029
|
fields: fields2
|
|
942
1030
|
});
|
|
943
1031
|
if (userMarkup?.kind === "literal") {
|
|
944
|
-
let { analyzeStoryTemplate } = await import("./_node-chunks/story-docs-template-analysis-
|
|
1032
|
+
let { analyzeStoryTemplate } = await import("./_node-chunks/story-docs-template-analysis-65HGKMRZ.js"), analysis = valuesAnalysis ?? analyzeStoryTemplate(userMarkup.markup, userMarkup.expansions), markup = valuesAnalysis ? materializeLike(valuesAnalysis, userMarkup.markup, userMarkup.expansions) : analysis.markup, referencedNames = new Set(analysis.kind === "resolved" ? analysis.referencedNames : []), boundOutputs = analysis.kind === "resolved" ? snippetMeta.outputs.filter((name) => analysis.boundOutputs.includes(name)) : [], hostArgs = referencedArgFields(
|
|
945
1033
|
referencedNames,
|
|
946
1034
|
userMarkup.representedArgs,
|
|
947
1035
|
shape,
|
|
948
1036
|
boundOutputs,
|
|
949
|
-
snippetMeta.enums
|
|
1037
|
+
snippetMeta.enums,
|
|
1038
|
+
printer
|
|
950
1039
|
);
|
|
951
|
-
return withWarnings(
|
|
952
|
-
host(formatTemplateMarkup(
|
|
1040
|
+
return { ...withWarnings(
|
|
1041
|
+
host(formatTemplateMarkup(markup, printer.unmarked), !1, boundOutputs, hostArgs.fields),
|
|
953
1042
|
unresolvedWarning([
|
|
954
1043
|
...shape.metaMembers.unresolved,
|
|
955
1044
|
...shape.members.unresolved,
|
|
@@ -961,7 +1050,7 @@ var buildStoryDocsPayload = async (input, context) => {
|
|
|
961
1050
|
...userMarkup.representedArgs,
|
|
962
1051
|
...referencedNames
|
|
963
1052
|
])
|
|
964
|
-
);
|
|
1053
|
+
), analysis };
|
|
965
1054
|
}
|
|
966
1055
|
let markupSources = userMarkup?.source === void 0 ? [] : [userMarkup.source];
|
|
967
1056
|
if (!snippetMeta.selector)
|
|
@@ -969,10 +1058,10 @@ var buildStoryDocsPayload = async (input, context) => {
|
|
|
969
1058
|
host(buildComponentOutletTemplate(localName, { selfClosing: !0 }), !0, []),
|
|
970
1059
|
unresolvedWarning(markupSources)
|
|
971
1060
|
);
|
|
972
|
-
let { bindings, fields } = componentBindings(snippetMeta, shape);
|
|
1061
|
+
let { bindings, fields } = componentBindings(snippetMeta, shape, printer);
|
|
973
1062
|
return withWarnings(
|
|
974
1063
|
host(
|
|
975
|
-
buildTemplate(snippetMeta.selector, { ...bindings, selfClosing: !0 }),
|
|
1064
|
+
buildTemplate(snippetMeta.selector, { ...bindings, selfClosing: !0 }, printer.unmarked),
|
|
976
1065
|
!1,
|
|
977
1066
|
snippetMeta.outputs,
|
|
978
1067
|
fields
|
|
@@ -980,7 +1069,7 @@ var buildStoryDocsPayload = async (input, context) => {
|
|
|
980
1069
|
unresolvedWarning([...markupSources, ...shape.unresolvedArgs]),
|
|
981
1070
|
unboundArgsWarning(localName, snippetMeta, shape)
|
|
982
1071
|
);
|
|
983
|
-
}, referencedArgFields = (referencedNames, representedArgs, shape, boundOutputs, enums) => {
|
|
1072
|
+
}, referencedArgFields = (referencedNames, representedArgs, shape, boundOutputs, enums, printer) => {
|
|
984
1073
|
let taken = /* @__PURE__ */ new Set([...representedArgs, ...boundOutputs]), fields = [], unresolved = [];
|
|
985
1074
|
for (let [name, node] of Object.entries(shape.args)) {
|
|
986
1075
|
if (taken.has(name) || !referencedNames.has(name))
|
|
@@ -990,7 +1079,7 @@ var buildStoryDocsPayload = async (input, context) => {
|
|
|
990
1079
|
unresolved.push(oneLineTextOf(node));
|
|
991
1080
|
continue;
|
|
992
1081
|
}
|
|
993
|
-
fields.push({ name, value });
|
|
1082
|
+
fields.push({ name, value: printer.show(name, "field", value) });
|
|
994
1083
|
}
|
|
995
1084
|
return { fields, unresolved };
|
|
996
1085
|
}, withWarnings = (rendered, ...parts) => {
|
|
@@ -1007,22 +1096,48 @@ var buildStoryDocsPayload = async (input, context) => {
|
|
|
1007
1096
|
return;
|
|
1008
1097
|
let reason = new Set(unbound.map(({ kind }) => kind)).size === 1 ? `declares no such ${unbound[0].kind}` : "declares no compatible input or output";
|
|
1009
1098
|
return `Incomplete snippet: ${unbound.map(({ name }) => `\`${name}\``).join(", ")} could not be bound, since ${componentName} ${reason}.`;
|
|
1010
|
-
}, componentBindings = (snippetMeta, shape) => {
|
|
1099
|
+
}, componentBindings = (snippetMeta, shape, printer) => {
|
|
1011
1100
|
let inputNames = new Set(snippetMeta.inputs), inputs = [], fields = [];
|
|
1012
1101
|
for (let [name, node] of Object.entries(shape.args))
|
|
1013
1102
|
if (inputNames.has(name)) {
|
|
1014
1103
|
if (evaluateArgLiteral(node, snippetMeta.enums) === void 0 && isSelfContained(node)) {
|
|
1015
|
-
fields.push({ name, value: argFieldValue(node) }), inputs.push({ name, expression: formatPropInTemplate(name) });
|
|
1104
|
+
fields.push({ name, value: printer.show(name, "field", argFieldValue(node)) }), inputs.push({ name, expression: formatPropInTemplate(name) });
|
|
1016
1105
|
continue;
|
|
1017
1106
|
}
|
|
1018
|
-
inputs.push({
|
|
1107
|
+
inputs.push({
|
|
1108
|
+
name,
|
|
1109
|
+
expression: printer.show(name, "bind", evaluateArgExpression(node, snippetMeta.enums))
|
|
1110
|
+
});
|
|
1019
1111
|
}
|
|
1020
|
-
return { bindings: { inputs, outputs: snippetMeta.outputs }, fields };
|
|
1021
|
-
},
|
|
1112
|
+
return inputs.push(...unsetInputs(snippetMeta, shape, printer, (name) => !(name in shape.args))), { bindings: { inputs, outputs: snippetMeta.outputs }, fields };
|
|
1113
|
+
}, unsetInputs = (snippetMeta, shape, printer, isUnset2) => snippetMeta.inputs.flatMap((name) => {
|
|
1114
|
+
if (!isUnset2(name))
|
|
1115
|
+
return [];
|
|
1116
|
+
let attribute = printer.unset(name);
|
|
1117
|
+
return attribute === void 0 ? [] : [{ name, expression: "", attribute, unset: !0 }];
|
|
1118
|
+
}), argsExpansion = (snippetMeta, shape, printer) => {
|
|
1022
1119
|
let inputNames = new Set(snippetMeta.inputs), outputNames = new Set(snippetMeta.outputs), inputs = [], outputs = [];
|
|
1023
1120
|
for (let [name, node] of Object.entries(shape.args))
|
|
1024
|
-
|
|
1025
|
-
|
|
1121
|
+
if (!isUndefinedValue(node)) {
|
|
1122
|
+
if (isFunctionValue(node))
|
|
1123
|
+
outputNames.has(name) && outputs.push(name);
|
|
1124
|
+
else if (inputNames.has(name)) {
|
|
1125
|
+
let expression = evaluateArgExpression(node, snippetMeta.enums);
|
|
1126
|
+
inputs.push({
|
|
1127
|
+
name,
|
|
1128
|
+
expression,
|
|
1129
|
+
attribute: printer.show(name, "prop", inputBinding(name, expression))
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
}
|
|
1133
|
+
return inputs.push(
|
|
1134
|
+
...unsetInputs(
|
|
1135
|
+
snippetMeta,
|
|
1136
|
+
shape,
|
|
1137
|
+
printer,
|
|
1138
|
+
(name) => !(name in shape.args) || isUndefinedValue(shape.args[name])
|
|
1139
|
+
)
|
|
1140
|
+
), { inputs, outputs };
|
|
1026
1141
|
}, isFunctionValue = (node) => {
|
|
1027
1142
|
let unwrapped = unwrapExpression4(node);
|
|
1028
1143
|
return unwrapped.type === "ArrowFunctionExpression" || unwrapped.type === "FunctionExpression" || unwrapped.type === "FunctionDeclaration";
|
|
@@ -1048,7 +1163,9 @@ var warnedMissingDocgenService = !1, getDocgenPayload = async (componentId) => {
|
|
|
1048
1163
|
});
|
|
1049
1164
|
|
|
1050
1165
|
// src/preset.ts
|
|
1051
|
-
var isDocgenProviderEnabled = (_existing, options) => isTypeScriptReadyForDocgen((specifier) => import.meta.resolve(specifier), options
|
|
1166
|
+
var isDocgenProviderEnabled = (_existing, options) => isTypeScriptReadyForDocgen((specifier) => import.meta.resolve(specifier), options, {
|
|
1167
|
+
apis: ["compiler", "native"]
|
|
1168
|
+
}), addons = [], features = async (existing) => ({
|
|
1052
1169
|
...existing,
|
|
1053
1170
|
componentsManifest: !0
|
|
1054
1171
|
}), previewAnnotations = async (entries = [], options) => {
|