@storybook/svelte 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.
Files changed (31) hide show
  1. package/dist/_browser-chunks/{chunk-SLNVXRXZ.js → chunk-D3HHTIN7.js} +5 -18
  2. package/dist/_browser-chunks/chunk-QPNLWHUT.js +84 -0
  3. package/dist/_node-chunks/{build-docgen-MSJ3SPME.js → build-docgen-7AHJE6KZ.js} +10 -10
  4. package/dist/_node-chunks/{chunk-MHATCRYC.js → chunk-66EAYIKL.js} +29 -18
  5. package/dist/_node-chunks/{chunk-XTPACDWA.js → chunk-BTI2FV5C.js} +76 -8
  6. package/dist/_node-chunks/{chunk-X4C3MPED.js → chunk-CYGU5LDL.js} +8 -8
  7. package/dist/_node-chunks/{chunk-CWKCHCWY.js → chunk-H5ZZRYXC.js} +16 -10
  8. package/dist/_node-chunks/{chunk-OZSDLXII.js → chunk-QRTOLIGT.js} +6 -6
  9. package/dist/_node-chunks/{chunk-S5NTL526.js → chunk-RB7ABCI3.js} +6 -6
  10. package/dist/_node-chunks/{chunk-EHBEHVES.js → chunk-T3JGM6K4.js} +6 -6
  11. package/dist/_node-chunks/{parsers-2O2L5JOB.js → parsers-MK4OQQPG.js} +6 -6
  12. package/dist/_node-chunks/{svelte-project-manager-U5Z7RBKO.js → svelte-project-manager-FOBYCND4.js} +7 -7
  13. package/dist/_node-chunks/walk-INTMVV36.js +17 -0
  14. package/dist/docgen/component-docgen/svelte2tsx/generate-docgen.js +7 -7
  15. package/dist/docgen/docgen-worker.js +9 -9
  16. package/dist/entry-preview-docs.js +6 -3
  17. package/dist/index.js +2 -1
  18. package/dist/preset.js +239 -153
  19. package/dist/svelte-csf/addon-check.js +6 -6
  20. package/dist/svelte-csf/compiler/transform.d.ts +1 -32
  21. package/dist/svelte-csf/compiler/transform.js +2257 -963
  22. package/dist/svelte-csf/indexer/index.js +8 -8
  23. package/dist/svelte-csf/runtime/component-helpers.js +10 -13
  24. package/package.json +5 -11
  25. package/template/cli/js/Button.stories.svelte +2 -2
  26. package/template/cli/js/Header.stories.svelte +2 -2
  27. package/template/cli/js/Page.stories.svelte +2 -2
  28. package/template/cli/ts/Button.stories.svelte +2 -2
  29. package/template/cli/ts/Header.stories.svelte +2 -2
  30. package/template/cli/ts/Page.stories.svelte +2 -2
  31. package/dist/_node-chunks/walk-OTIE5SYQ.js +0 -17
@@ -1,7 +1,10 @@
1
1
  import {
2
- decorators
3
- } from "./_browser-chunks/chunk-SLNVXRXZ.js";
2
+ decorators,
3
+ parameters
4
+ } from "./_browser-chunks/chunk-QPNLWHUT.js";
5
+ import "./_browser-chunks/chunk-D3HHTIN7.js";
4
6
  import "./_browser-chunks/chunk-4BE7D4DS.js";
5
7
  export {
6
- decorators
8
+ decorators,
9
+ parameters
7
10
  };
package/dist/index.js CHANGED
@@ -4,7 +4,8 @@ import {
4
4
  } from "./_browser-chunks/chunk-FPEMDWKX.js";
5
5
  import {
6
6
  entry_preview_docs_exports
7
- } from "./_browser-chunks/chunk-SLNVXRXZ.js";
7
+ } from "./_browser-chunks/chunk-QPNLWHUT.js";
8
+ import "./_browser-chunks/chunk-D3HHTIN7.js";
8
9
  import "./_browser-chunks/chunk-4BE7D4DS.js";
9
10
 
10
11
  // src/globals.ts
package/dist/preset.js CHANGED
@@ -1,29 +1,30 @@
1
- import CJS_COMPAT_NODE_URL_t3g1exktcfr from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_t3g1exktcfr from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_t3g1exktcfr from "node:module";
1
+ import CJS_COMPAT_NODE_URL_f7geiagcxxk from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_f7geiagcxxk from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_f7geiagcxxk from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_t3g1exktcfr.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_t3g1exktcfr.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_t3g1exktcfr.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_f7geiagcxxk.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_f7geiagcxxk.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_f7geiagcxxk.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
  SVELTE_DOCGEN_STORY_FILE_TEST_REGEXP
14
- } from "./_node-chunks/chunk-S5NTL526.js";
14
+ } from "./_node-chunks/chunk-RB7ABCI3.js";
15
15
  import {
16
16
  parseSvelteSource
17
- } from "./_node-chunks/chunk-CWKCHCWY.js";
17
+ } from "./_node-chunks/chunk-H5ZZRYXC.js";
18
18
  import {
19
19
  findMetaRenderSnippetBlock,
20
20
  findStoryAttributeTemplateSnippetBlock,
21
- getStoryContentRawCode
22
- } from "./_node-chunks/chunk-XTPACDWA.js";
21
+ getStoryContentRawCode,
22
+ span
23
+ } from "./_node-chunks/chunk-BTI2FV5C.js";
23
24
  import {
24
25
  extractSvelteASTNodes,
25
26
  getDefineMetaFirstArgumentObjectExpression
26
- } from "./_node-chunks/chunk-X4C3MPED.js";
27
+ } from "./_node-chunks/chunk-CYGU5LDL.js";
27
28
  import {
28
29
  extractStoryAttributesNodes,
29
30
  extractStoryTemplateSnippetBlock,
@@ -31,10 +32,10 @@ import {
31
32
  getStoryChain,
32
33
  getStoryContent,
33
34
  getStoryParents
34
- } from "./_node-chunks/chunk-MHATCRYC.js";
35
+ } from "./_node-chunks/chunk-66EAYIKL.js";
35
36
  import {
36
37
  walk
37
- } from "./_node-chunks/chunk-OZSDLXII.js";
38
+ } from "./_node-chunks/chunk-QRTOLIGT.js";
38
39
 
39
40
  // src/preset.ts
40
41
  import { fileURLToPath as fileURLToPath3 } from "node:url";
@@ -83,6 +84,7 @@ import {
83
84
  unresolvedWarning,
84
85
  unwrapExpression as unwrapExpression3
85
86
  } from "storybook/internal/csf-tools";
87
+ import { prependToTemplate } from "storybook/internal/docs-tools";
86
88
 
87
89
  // src/docgen/story-docs/print-template.ts
88
90
  import {
@@ -92,6 +94,30 @@ import {
92
94
  unwrapExpression,
93
95
  walk as walkEstree
94
96
  } from "storybook/internal/csf-tools";
97
+ import {
98
+ createHoleMarks,
99
+ withHoleSpace
100
+ } from "storybook/internal/docs-tools";
101
+
102
+ // src/snippet-values.ts
103
+ var isPlain = (value) => !/[{}<>"\\&\r\n\t]/.test(value), escapeAttribute = (value) => value.replaceAll("&", "&amp;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
104
+ function printProp(name, value) {
105
+ return value === void 0 ? "" : value === !0 ? name : value.string !== void 0 && isPlain(value.string) ? `${name}="${value.string}"` : `${name}={${value.code}}`;
106
+ }
107
+ var printAccessors = (keys) => keys.map((key) => /^[A-Za-z_$][\w$]*$/.test(key) ? `.${key}` : `[${JSON.stringify(key)}]`).join("");
108
+ function printWholeRead(place, arg, read, string) {
109
+ let text = string?.trim() ? string : void 0, code = `${place.before}${read}${place.after}`;
110
+ switch (place.kind) {
111
+ case "attrvalue":
112
+ return text !== void 0 && isPlain(text) ? `${place.name ?? arg}="${text}"` : code;
113
+ case "quoted":
114
+ return text !== void 0 && !/[{}]/.test(text) ? escapeAttribute(text) : code;
115
+ case "fragment":
116
+ return text !== void 0 && !/[{}<>"\\&]/.test(text) ? text : code;
117
+ case "code":
118
+ return code;
119
+ }
120
+ }
95
121
 
96
122
  // src/docgen/story-docs/markup.ts
97
123
  import { parse } from "svelte/compiler";
@@ -123,13 +149,8 @@ function patternNames(pattern) {
123
149
  return [];
124
150
  }
125
151
  }
126
- function span(node) {
127
- if ("start" in node && typeof node.start == "number" && "end" in node && typeof node.end == "number")
128
- return { start: node.start, end: node.end };
129
- throw new TypeError("Svelte AST node has no source positions");
130
- }
131
152
  function applyEdits(code, edits) {
132
- for (let edit of [...edits].sort((a, b) => b.start - a.start))
153
+ for (let edit of [...edits].sort((a, b) => b.start - a.start || b.end - a.end))
133
154
  code = code.slice(0, edit.start) + edit.value + code.slice(edit.end);
134
155
  return code;
135
156
  }
@@ -144,111 +165,167 @@ function printTemplate({
144
165
  snippets = {},
145
166
  argsComplete = !1
146
167
  }) {
147
- let { ast, offset } = parseMarkup(code, typescript), destructured = new Set(Object.values(parameter?.aliases ?? {})), name = parameter ? parameter.name : "args", reads = {
148
- args,
149
- name,
150
- aliases: parameter?.aliases ?? {},
151
- typescript,
152
- argsComplete
153
- }, isArgsSpread = (attribute) => attribute.type === "SpreadAttribute" && attribute.expression.type === "Identifier" && attribute.expression.name === name, at = (node) => {
154
- let range = span(node);
155
- return { start: range.start - offset, end: range.end - offset };
156
- }, edits = [];
157
- return walk(ast.fragment, null, {
158
- Attribute(node, { path, next }) {
159
- let element = path.at(-1);
160
- if (node.name in args && element && "attributes" in element && element.attributes.some(
161
- (attribute) => isArgsSpread(attribute) && attribute.start > node.start
162
- )) {
163
- edits.push({
164
- ...at(node),
165
- value: printProp(node.name, args[node.name])[0] ?? `${node.name}={undefined}`
166
- });
167
- return;
168
- }
169
- next();
170
- },
171
- SpreadAttribute(node, { path, next }) {
172
- if (!isArgsSpread(node)) {
168
+ let { ast, offset } = parseMarkup(code, typescript), collect = (marks2) => {
169
+ let mark = marks2?.mark ?? ((_, text) => text), destructured = new Set(Object.values(parameter?.aliases ?? {})), name = parameter ? parameter.name : "args", reads = {
170
+ args,
171
+ name,
172
+ aliases: parameter?.aliases ?? {},
173
+ typescript,
174
+ argsComplete,
175
+ mark
176
+ }, isArgsSpread = (attribute) => attribute.type === "SpreadAttribute" && attribute.expression.type === "Identifier" && attribute.expression.name === name, at = (node) => {
177
+ let range = span(node);
178
+ return { start: range.start - offset, end: range.end - offset };
179
+ }, written = ({ start, end }) => code.slice(start, end), edits = [];
180
+ return walk(ast.fragment, null, {
181
+ Attribute(node, { path, next }) {
182
+ let element = path.at(-1), spreadAfter = element && "attributes" in element && element.attributes.some(
183
+ (attribute) => isArgsSpread(attribute) && attribute.start > node.start
184
+ ), range = at(node);
185
+ if (!spreadAfter || destructured.has(node.name)) {
186
+ next();
187
+ return;
188
+ }
189
+ let from = edits.length;
173
190
  next();
174
- return;
175
- }
176
- let element = path.at(-1), content = element && "fragment" in element ? element.fragment.nodes.filter(
177
- (child) => !(child.type === "Text" && !child.data.trim())
178
- ) : [], written = /* @__PURE__ */ new Set([
179
- ...element && "attributes" in element ? element.attributes.flatMap(
180
- (attribute) => attribute.type === "Attribute" || attribute.type === "BindDirective" ? [attribute.name] : []
181
- ) : [],
182
- // A snippet block inside a component sets the prop it names; other content sets `children`.
183
- ...content.map(
184
- (child) => child.type === "SnippetBlock" ? child.expression.name : "children"
185
- )
186
- ]), passed = (key) => !written.has(key) && !destructured.has(key), props = Object.entries(args).flatMap(
187
- ([key, value]) => key in snippets || !passed(key) ? [] : printProp(key, value)
188
- ), spread = spreadEdit(code, at(node), props);
189
- edits.push(spread);
190
- let children = Object.entries(snippets).flatMap(
191
- ([key, snippet]) => passed(key) ? [snippet] : []
192
- );
193
- if (!children.length || element?.type !== "Component") return;
194
- let { start, end } = at(element);
195
- if (code.slice(start, end).endsWith("/>")) {
196
- let from = end - 2;
197
- for (; from > spread.end && /[ \t]/.test(code[from - 1]); ) from--;
198
- edits.push({
199
- start: from,
200
- end,
201
- value: `>
191
+ let children = edits.splice(from).map((edit) => ({
192
+ ...edit,
193
+ start: edit.start - range.start,
194
+ end: edit.end - range.start
195
+ })), value = node.name in args ? printProp(node.name, propValue(args[node.name])) : applyEdits(written(range), children);
196
+ edits.push({ ...range, value, marked: mark({ kind: "prop", arg: node.name }, value) });
197
+ },
198
+ SpreadAttribute(node, { path, next }) {
199
+ if (!isArgsSpread(node)) {
200
+ next();
201
+ return;
202
+ }
203
+ let element = path.at(-1), content = element && "fragment" in element ? element.fragment.nodes.filter(
204
+ (child) => !(child.type === "Text" && !child.data.trim())
205
+ ) : [], writtenProps = /* @__PURE__ */ new Set([
206
+ ...element && "attributes" in element ? element.attributes.flatMap(
207
+ (attribute) => attribute.type === "Attribute" || attribute.type === "BindDirective" ? [attribute.name] : []
208
+ ) : [],
209
+ // A snippet block inside a component sets the prop it names; other content sets `children`.
210
+ ...content.map(
211
+ (child) => child.type === "SnippetBlock" ? child.expression.name : "children"
212
+ )
213
+ ]), passed = (key) => !writtenProps.has(key) && !destructured.has(key), props = Object.entries(args).flatMap(([key, value]) => {
214
+ let printed = propValue(value);
215
+ return key in snippets || !passed(key) || printed === void 0 ? [] : [[key, printProp(key, printed)]];
216
+ }), spread = spreadPlace(code, at(node), mark, props, [
217
+ ...props.map(([key]) => key),
218
+ ...writtenProps,
219
+ ...destructured,
220
+ ...Object.keys(snippets)
221
+ ]);
222
+ edits.push(spread);
223
+ let children = Object.entries(snippets).flatMap(
224
+ ([key, snippet2]) => passed(key) ? [snippet2] : []
225
+ );
226
+ if (!children.length || element?.type !== "Component") return;
227
+ let { start, end } = at(element);
228
+ if (code.slice(start, end).endsWith("/>")) {
229
+ let from = end - 2;
230
+ for (; from > spread.end && /[ \t]/.test(code[from - 1]); ) from--;
231
+ edits.push({
232
+ start: from,
233
+ end,
234
+ value: `>
202
235
  ${children.join(`
203
236
  `)}
204
237
  </${element.name}>`
205
- });
206
- } else {
207
- let close = code.lastIndexOf("</", end - 1);
208
- edits.push({ start: close, end: close, value: `${children.join(`
238
+ });
239
+ } else {
240
+ let close = code.lastIndexOf("</", end - 1);
241
+ edits.push({ start: close, end: close, value: `${children.join(`
209
242
  `)}
210
243
  ` });
211
- }
212
- },
213
- ExpressionTag(node, { path }) {
214
- let range = at(node.expression), expression = code.slice(range.start, range.end), replaced = replaceArgsReads(expression, reads);
215
- if (replaced === void 0) return;
216
- let parent = path.at(-1), text = replaced.text, quoted = parent?.type === "Attribute" && /=\s*["']/.test(code.slice(at(parent).start, range.start));
217
- parent?.type === "Attribute" && parent.value === node && text !== void 0 && isPlain(text) ? edits.push({ ...at(parent), value: `${parent.name}="${text}"` }) : parent?.type === "Attribute" && code[at(parent).start] === "{" ? edits.push({ ...at(parent), value: `${parent.name}={${replaced.value}}` }) : text !== void 0 && quoted && !/[{}]/.test(text) ? edits.push({ ...at(node), value: escapeAttribute(text) }) : text !== void 0 && parent?.type === "Fragment" && !/[{}<>"\\&]/.test(text) ? edits.push({ ...at(node), value: text }) : edits.push({ ...range, value: replaced.value });
218
- },
219
- _(node, { next }) {
220
- if (node.type === "ExpressionTag") return next();
221
- for (let expression of blockExpressions(node)) {
222
- let range = at(expression), replaced = replaceArgsReads(code.slice(range.start, range.end), reads);
223
- if (replaced === void 0) continue;
224
- let shorthand = "name" in node && node.type.endsWith("Directive") && !code.slice(at(node).start, range.start).includes("=");
244
+ }
245
+ },
246
+ ExpressionTag(node, { path }) {
247
+ let range = at(node.expression), replaced = replaceArgsReads(written(range), reads);
248
+ if (replaced === void 0) return;
249
+ if (!replaced.single) {
250
+ edits.push({ ...range, value: replaced.value, marked: replaced.marked });
251
+ return;
252
+ }
253
+ let { arg, path: members, string } = replaced.single, parent = path.at(-1), attribute = parent?.type === "Attribute" ? parent : void 0, place = attribute?.value === node ? at(attribute) : at(node), before = code.slice(place.start, range.start), after = code.slice(range.end, place.end), wholeRead;
254
+ if (attribute?.value === node) {
255
+ let shorthand = code[place.start] === "{";
256
+ wholeRead = {
257
+ kind: "attrvalue",
258
+ ...attribute.name !== arg && { name: attribute.name },
259
+ before: shorthand ? `${attribute.name}={` : before,
260
+ after: shorthand ? "}" : after,
261
+ ...members && { path: members }
262
+ };
263
+ } else
264
+ wholeRead = { kind: attribute !== void 0 && /=\s*["']/.test(code.slice(at(attribute).start, range.start)) ? "quoted" : parent?.type === "Fragment" ? "fragment" : "code", before, after, ...members && { path: members } };
265
+ let value = replaced.substituted ? printWholeRead(wholeRead, arg, replaced.value, string) : written(place);
225
266
  edits.push({
226
- ...range,
227
- value: shorthand ? `${node.name}={${replaced.value}}` : replaced.value
267
+ ...place,
268
+ value,
269
+ marked: mark({ ...wholeRead, arg }, value)
228
270
  });
271
+ },
272
+ _(node, { next }) {
273
+ if (node.type === "ExpressionTag") return next();
274
+ for (let expression of blockExpressions(node)) {
275
+ let range = at(expression), replaced = replaceArgsReads(written(range), reads);
276
+ if (replaced === void 0) continue;
277
+ if (!("name" in node && node.type.endsWith("Directive") && !code.slice(at(node).start, range.start).includes("=")) || !replaced.single) {
278
+ edits.push({ ...range, value: replaced.value, marked: replaced.marked });
279
+ continue;
280
+ }
281
+ let value = replaced.substituted ? `${node.name}={${replaced.value}}` : written(range), hole = { before: `${node.name}={`, after: "}", arg: replaced.single.arg };
282
+ edits.push({ ...range, value, marked: mark({ kind: "code", ...hole }, value) });
283
+ }
284
+ next();
229
285
  }
230
- next();
231
- }
232
- }), applyEdits(code, edits);
286
+ }), edits;
287
+ }, snippet = applyEdits(code, collect()), marks = createHoleMarks([snippet]), marked = collect(marks).map((edit) => ({ ...edit, value: edit.marked ?? edit.value })), template = marks.toTemplate(applyEdits(code, marked));
288
+ return {
289
+ snippet,
290
+ // An arg a control clears leaves no gap in the spread.
291
+ ...template && { template: withHoleSpace(template, (hole) => hole.kind === "prop") }
292
+ };
233
293
  }
234
- function printProp(key, value) {
294
+ function propValue(value) {
235
295
  let node = unwrapExpression(value);
236
- return node.type === "Identifier" && node.name === "undefined" ? [] : node.type === "Literal" && node.value === !0 ? [key] : node.type === "Literal" && typeof node.value == "string" && isPlain(node.value) ? [`${key}="${node.value}"`] : [`${key}={${textOf(value)}}`];
296
+ if (!(node.type === "Identifier" && node.name === "undefined"))
297
+ return node.type === "Literal" && node.value === !0 ? !0 : {
298
+ ...node.type === "Literal" && typeof node.value == "string" ? { string: node.value } : {},
299
+ code: textOf(value)
300
+ };
237
301
  }
238
- function spreadEdit(code, span2, props) {
239
- let value = props.join(" ").length > 50 ? `
240
- ${props.join(`
241
- `)}
242
- ` : props.join(" "), { start, end } = span2;
243
- if (value.startsWith(`
244
- `)) for (; start > 0 && /[ \t]/.test(code[start - 1]); ) start--;
245
- if (!value) {
246
- let lineStart = code.lastIndexOf(`
302
+ function spreadPlace(code, span2, mark, props, printed) {
303
+ let values = props.map(([, prop]) => prop), onePerLine = values.join(" ").length > 50, separator = onePerLine ? `
304
+ ` : " ", holes = props.map(([arg, prop]) => mark({ kind: "prop", arg }, prop)), added = (space) => mark({ kind: "props", except: printed, separator: space, spread: !0 }, "", space), { end } = span2, { start } = span2;
305
+ if (onePerLine) for (; start > 0 && /[ \t]/.test(code[start - 1]); ) start--;
306
+ if (props.length) {
307
+ let [value, marked] = [values, holes].map((pieces) => pieces.join(separator));
308
+ return onePerLine ? {
309
+ start,
310
+ end,
311
+ value: `
312
+ ${value}
313
+ `,
314
+ marked: `
315
+ ${marked}${added(separator)}
316
+ `
317
+ } : { start, end, value, marked: `${marked}${added(separator)}` };
318
+ }
319
+ let lineStart = code.lastIndexOf(`
247
320
  `, start - 1) + 1, lineEnd = code.indexOf(`
248
321
  `, end);
249
- lineEnd !== -1 && !code.slice(lineStart, start).trim() && !code.slice(end, lineEnd).trim() ? (start = lineStart, end = lineEnd + 1) : code[start - 1] === " " && start--;
250
- }
251
- return { start, end, value };
322
+ return lineEnd !== -1 && !code.slice(lineStart, start).trim() && !code.slice(end, lineEnd).trim() ? {
323
+ start: lineStart - 1,
324
+ end: lineEnd,
325
+ value: "",
326
+ marked: added(`
327
+ ${code.slice(lineStart, start)}`)
328
+ } : (code[start - 1] === " " && start--, { start, end, value: "", marked: added(" ") });
252
329
  }
253
330
  function blockExpressions(node) {
254
331
  switch (node.type) {
@@ -263,8 +340,6 @@ function blockExpressions(node) {
263
340
  case "HtmlTag":
264
341
  case "RenderTag":
265
342
  case "SpreadAttribute":
266
- return [node.expression];
267
- // `{@attach}` is newer than the AST types.
268
343
  case "AttachTag":
269
344
  return [node.expression];
270
345
  case "ConstTag":
@@ -272,46 +347,62 @@ function blockExpressions(node) {
272
347
  (declaration) => declaration.init ? [declaration.init] : []
273
348
  );
274
349
  case "ClassDirective":
275
- case "StyleDirective":
276
350
  case "OnDirective":
277
351
  case "UseDirective":
278
352
  case "TransitionDirective":
279
353
  case "AnimateDirective":
280
- return node.expression && typeof node.expression == "object" ? [node.expression] : [];
354
+ return node.expression ? [node.expression] : [];
281
355
  default:
282
356
  return [];
283
357
  }
284
358
  }
285
- function replaceArgsReads(expression, { args, name, aliases, typescript, argsComplete }) {
286
- let editor = new SourceEditor(`(${expression})`, scriptFile(typescript)), edits = [], valueOf = (node) => {
287
- if (node.type !== "Identifier" || editor.scopes.bindingOf(node)) return;
288
- let key = aliases[node.name];
289
- if (key !== void 0)
290
- return key in args ? printRead(args[key], []) : argsComplete ? { value: "undefined" } : void 0;
291
- };
359
+ function replaceArgsReads(expression, { args, name, aliases, typescript, argsComplete, mark }) {
360
+ let editor = new SourceEditor(`(${expression})`, scriptFile(typescript)), edits = [], push = (arg, start, end, read, { path, property } = {}) => {
361
+ let value = read === void 0 ? expression.slice(start, end) : property === void 0 ? read.value : `${property}: ${read.value}`, place = property === void 0 ? { kind: "value", ...path && { path } } : { kind: "property", ...property !== arg && { name: property } };
362
+ edits.push({
363
+ start,
364
+ end,
365
+ value,
366
+ node: property === void 0 ? read?.node : void 0,
367
+ marked: mark({ ...place, arg }, value),
368
+ arg,
369
+ place,
370
+ substituted: read !== void 0
371
+ });
372
+ }, valueOf = (key) => key in args ? printRead(args[key], []) : argsComplete ? { value: "undefined" } : void 0, aliasOf = (node) => node.type === "Identifier" && !editor.scopes.bindingOf(node) ? aliases[node.name] : void 0;
292
373
  if (walkEstree(editor.program, (node, parent) => {
293
374
  if (node.type === "MemberExpression") {
294
375
  let keys = name === void 0 ? void 0 : argsPath(node, editor, name);
295
- return keys?.length ? keys[0] in args ? (edits.push({
296
- start: node.start - 1,
297
- end: node.end - 1,
298
- ...printRead(args[keys[0]], keys.slice(1))
299
- }), !1) : argsComplete ? (edits.push({ start: node.start - 1, end: node.end - 1, value: "undefined" }), !1) : void 0 : void 0;
376
+ if (!keys?.length) return;
377
+ let [key2, ...members] = keys, read = key2 in args ? printRead(args[key2], members) : argsComplete ? { value: "undefined" } : void 0;
378
+ return push(key2, node.start - 1, node.end - 1, read, {
379
+ ...members.length > 0 && { path: members }
380
+ }), !1;
300
381
  }
301
382
  if (node.type === "Property" && node.shorthand && node.value.type === "Identifier") {
302
- let read2 = valueOf(node.value);
303
- return read2 ? (edits.push({
304
- start: node.start - 1,
305
- end: node.end - 1,
306
- value: `${node.value.name}: ${read2.value}`
307
- }), !1) : void 0;
383
+ let key2 = aliasOf(node.value);
384
+ return key2 === void 0 ? void 0 : (push(key2, node.start - 1, node.end - 1, valueOf(key2), { property: node.value.name }), !1);
308
385
  }
309
386
  if (parent?.type === "MemberExpression" && parent.property === node && !parent.computed || parent?.type === "Property" && parent.key === node && !parent.computed) return;
310
- let read = valueOf(node);
311
- read && edits.push({ start: node.start - 1, end: node.end - 1, ...read });
387
+ let key = aliasOf(node);
388
+ key !== void 0 && push(key, node.start - 1, node.end - 1, valueOf(key));
312
389
  }), !edits.length) return;
313
- let [only] = edits, text = edits.length === 1 && expression.slice(0, only.start).trim() === "" && expression.slice(only.end).trim() === "" && only.node?.type === "Literal" && typeof only.node.value == "string" && only.node.value.trim() ? only.node.value : void 0;
314
- return { value: applyEdits(expression, edits), ...text !== void 0 ? { text } : {} };
390
+ let [only] = edits, whole = edits.length === 1 && only.place.kind !== "property" && expression.slice(0, only.start).trim() === "" && expression.slice(only.end).trim() === "", string = only.node?.type === "Literal" && typeof only.node.value == "string" ? only.node.value : void 0;
391
+ return {
392
+ value: applyEdits(expression, edits),
393
+ marked: applyEdits(
394
+ expression,
395
+ edits.map((edit) => ({ ...edit, value: edit.marked }))
396
+ ),
397
+ substituted: edits.some((edit) => edit.substituted),
398
+ ...whole && {
399
+ single: {
400
+ arg: only.arg,
401
+ ...only.place.kind === "value" && only.place.path && { path: only.place.path },
402
+ ...string !== void 0 && { string }
403
+ }
404
+ }
405
+ };
315
406
  }
316
407
  function argsPath(node, editor, name) {
317
408
  if (node.type === "Identifier")
@@ -327,7 +418,7 @@ function printRead(value, keys) {
327
418
  if (!member) break;
328
419
  node = unwrapExpression(member), rest = rest.slice(1);
329
420
  }
330
- let accessors = rest.map((key) => /^[A-Za-z_$][\w$]*$/.test(key) ? `.${key}` : `[${JSON.stringify(key)}]`).join("");
421
+ let accessors = printAccessors(rest);
331
422
  return {
332
423
  value: isPrimary(node) ? `${textOf(node)}${accessors}` : `(${textOf(node)})${accessors}`,
333
424
  ...rest.length ? {} : { node }
@@ -359,12 +450,6 @@ function isPrimary(node) {
359
450
  return !1;
360
451
  }
361
452
  }
362
- function isPlain(value) {
363
- return !/[{}<>"\\&\r\n\t]/.test(value);
364
- }
365
- function escapeAttribute(value) {
366
- return value.replaceAll("&", "&amp;").replaceAll('"', "&quot;").replaceAll("'", "&#39;");
367
- }
368
453
 
369
454
  // src/docgen/story-docs/snippet-imports.ts
370
455
  import {
@@ -742,14 +827,14 @@ function storySnippet(exportName, resolved, { file, bindings, importOverride, co
742
827
  let snippet = snippetArg(key, node, file, bindings);
743
828
  snippet !== void 0 && (snippets[key] = snippet);
744
829
  }
745
- let markup = printTemplate({
830
+ let printed = printTemplate({
746
831
  code: template,
747
832
  args: resolved.args,
748
833
  typescript: file.typescript,
749
834
  parameter: story?.parameter,
750
835
  snippets,
751
836
  argsComplete: resolved.unresolved.length === 0
752
- }), importBlock = () => buildSnippetImportBlock(markup, {
837
+ }), markup = printed.snippet, holes = printed.template, importBlock = () => buildSnippetImportBlock(markup, {
753
838
  bindings,
754
839
  importOverride,
755
840
  instanceScript: file.instanceScript,
@@ -766,10 +851,10 @@ function storySnippet(exportName, resolved, { file, bindings, importOverride, co
766
851
  if (!missing.length) break;
767
852
  for (let name of missing) {
768
853
  declared.add(name);
769
- let { parameters, body } = file.snippets.get(name);
770
- markup += `
854
+ let { parameters, body } = file.snippets.get(name), declaration = `
771
855
 
772
856
  {#snippet ${name}(${parameters})}${body}{/snippet}`;
857
+ markup += declaration, holes &&= [...holes, declaration];
773
858
  }
774
859
  imported = importBlock();
775
860
  }
@@ -778,12 +863,13 @@ function storySnippet(exportName, resolved, { file, bindings, importOverride, co
778
863
  imported.unresolvedIdentifiers?.map((name) => `Identifier not resolved: \`${name}\`.`).join(" "),
779
864
  unresolvedWarning(resolved.unresolved.filter((name) => !imported.declared.includes(name))),
780
865
  renders ? RENDER_WARNING : void 0
781
- ].filter(Boolean);
782
- return {
783
- snippet: imported.block ? `${imported.block}
866
+ ].filter(Boolean), importCode = imported.block ? `${imported.block}
784
867
 
785
- ${markup}` : markup,
786
- ...warnings.length ? { warning: warnings.join(" ") } : {}
868
+ ` : "", warning = warnings.length ? warnings.join(" ") : void 0;
869
+ return {
870
+ snippet: importCode + markup,
871
+ ...warning === void 0 ? {} : { warning },
872
+ ...holes === void 0 ? {} : { template: prependToTemplate(importCode, holes) }
787
873
  };
788
874
  }
789
875
  function snippetArg(key, value, file, bindings) {
@@ -822,7 +908,7 @@ var isDocgenProviderEnabled = (_existing, options) => isTypeScriptReadyForDocgen
822
908
  docsEnabled ? [fileURLToPath3(import.meta.resolve("@storybook/svelte/entry-preview-docs"))] : []
823
909
  );
824
910
  }, experimental_importParsers = async (input = []) => {
825
- let { svelteImportParser } = await import("./_node-chunks/parsers-2O2L5JOB.js");
911
+ let { svelteImportParser } = await import("./_node-chunks/parsers-MK4OQQPG.js");
826
912
  return [...input, svelteImportParser];
827
913
  }, experimental_indexers = async (existingIndexers) => {
828
914
  let { createIndexer } = await import("./svelte-csf/indexer/index.js");
@@ -1,10 +1,10 @@
1
- import CJS_COMPAT_NODE_URL_t3g1exktcfr from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_t3g1exktcfr from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_t3g1exktcfr from "node:module";
1
+ import CJS_COMPAT_NODE_URL_f7geiagcxxk from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_f7geiagcxxk from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_f7geiagcxxk from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_t3g1exktcfr.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_t3g1exktcfr.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_t3g1exktcfr.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_f7geiagcxxk.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_f7geiagcxxk.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_f7geiagcxxk.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
@@ -1,36 +1,5 @@
1
1
  import { PreprocessorGroup } from "svelte/compiler";
2
2
 
3
- //#region node_modules/magic-string/dist/magic-string.es.d.mts
4
- type SourceMapSegment = [number] | [number, number, number, number] | [number, number, number, number, number];
5
- interface DecodedSourceMap {
6
- file: string;
7
- sources: string[];
8
- sourcesContent?: string[];
9
- names: string[];
10
- mappings: SourceMapSegment[][];
11
- x_google_ignoreList?: number[];
12
- }
13
- declare class SourceMap {
14
- constructor(properties: DecodedSourceMap);
15
- version: number;
16
- file: string;
17
- sources: string[];
18
- sourcesContent?: string[];
19
- names: string[];
20
- mappings: string;
21
- x_google_ignoreList?: number[];
22
- debugId?: string;
23
- /**
24
- * Returns the equivalent of `JSON.stringify(map)`
25
- */
26
- toString(): string;
27
- /**
28
- * Returns a DataURI containing the sourcemap. Useful for doing this sort of thing:
29
- * `generateMap(options?: SourceMapOptions): SourceMap;`
30
- */
31
- toUrl(): string;
32
- }
33
- //#endregion
34
3
  //#region node_modules/rollup/node_modules/@types/estree/index.d.ts
35
4
  // This definition file follows a somewhat unusual format. ESTree allows
36
5
  // runtime type checks based on the `type` parameter. In order to explain this
@@ -1084,7 +1053,7 @@ interface TransformSvelteCsfParams {
1084
1053
  }
1085
1054
  declare function transformSvelteCsf(params: TransformSvelteCsfParams): Promise<{
1086
1055
  code: string;
1087
- map: SourceMap;
1056
+ map: string;
1088
1057
  }>;
1089
1058
  //#endregion
1090
1059
  export { SVELTE_CSF_RUNTIME_STORIES_IMPORT_SOURCE, svelteCsfRuntimeStoriesPath, transformSvelteCsf };