@storybook/svelte 11.0.0-beta.1 → 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-SLNVXRXZ.js → chunk-D3HHTIN7.js} +5 -18
- package/dist/_browser-chunks/chunk-QPNLWHUT.js +84 -0
- package/dist/_node-chunks/{build-docgen-N3H7WY5Y.js → build-docgen-7AHJE6KZ.js} +10 -10
- package/dist/_node-chunks/{chunk-KTJYHSDK.js → chunk-66EAYIKL.js} +7 -8
- package/dist/_node-chunks/{chunk-Z3GMEEYK.js → chunk-BTI2FV5C.js} +8 -8
- package/dist/_node-chunks/{chunk-SUST2I22.js → chunk-CYGU5LDL.js} +8 -8
- package/dist/_node-chunks/{chunk-O2XZFQTE.js → chunk-H5ZZRYXC.js} +8 -8
- package/dist/_node-chunks/{chunk-ELPMU4JK.js → chunk-QRTOLIGT.js} +6 -6
- package/dist/_node-chunks/{chunk-BHACKENJ.js → chunk-RB7ABCI3.js} +6 -6
- package/dist/_node-chunks/{chunk-ZZ6YLTQN.js → chunk-T3JGM6K4.js} +6 -6
- package/dist/_node-chunks/{parsers-J2VH6MOH.js → parsers-MK4OQQPG.js} +6 -6
- package/dist/_node-chunks/{svelte-project-manager-NQA46LSQ.js → svelte-project-manager-FOBYCND4.js} +7 -7
- package/dist/_node-chunks/walk-INTMVV36.js +17 -0
- package/dist/docgen/component-docgen/svelte2tsx/generate-docgen.js +7 -7
- package/dist/docgen/docgen-worker.js +9 -9
- package/dist/entry-preview-docs.js +6 -3
- package/dist/index.js +2 -1
- package/dist/preset.js +234 -155
- package/dist/svelte-csf/addon-check.js +6 -6
- package/dist/svelte-csf/compiler/transform.d.ts +1 -32
- package/dist/svelte-csf/compiler/transform.js +799 -299
- package/dist/svelte-csf/indexer/index.js +8 -8
- package/dist/svelte-csf/runtime/component-helpers.js +10 -13
- package/package.json +4 -10
- package/dist/_node-chunks/walk-6OEIONKD.js +0 -17
package/dist/preset.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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 =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
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-
|
|
14
|
+
} from "./_node-chunks/chunk-RB7ABCI3.js";
|
|
15
15
|
import {
|
|
16
16
|
parseSvelteSource
|
|
17
|
-
} from "./_node-chunks/chunk-
|
|
17
|
+
} from "./_node-chunks/chunk-H5ZZRYXC.js";
|
|
18
18
|
import {
|
|
19
19
|
findMetaRenderSnippetBlock,
|
|
20
20
|
findStoryAttributeTemplateSnippetBlock,
|
|
21
21
|
getStoryContentRawCode,
|
|
22
22
|
span
|
|
23
|
-
} from "./_node-chunks/chunk-
|
|
23
|
+
} from "./_node-chunks/chunk-BTI2FV5C.js";
|
|
24
24
|
import {
|
|
25
25
|
extractSvelteASTNodes,
|
|
26
26
|
getDefineMetaFirstArgumentObjectExpression
|
|
27
|
-
} from "./_node-chunks/chunk-
|
|
27
|
+
} from "./_node-chunks/chunk-CYGU5LDL.js";
|
|
28
28
|
import {
|
|
29
29
|
extractStoryAttributesNodes,
|
|
30
30
|
extractStoryTemplateSnippetBlock,
|
|
@@ -32,10 +32,10 @@ import {
|
|
|
32
32
|
getStoryChain,
|
|
33
33
|
getStoryContent,
|
|
34
34
|
getStoryParents
|
|
35
|
-
} from "./_node-chunks/chunk-
|
|
35
|
+
} from "./_node-chunks/chunk-66EAYIKL.js";
|
|
36
36
|
import {
|
|
37
37
|
walk
|
|
38
|
-
} from "./_node-chunks/chunk-
|
|
38
|
+
} from "./_node-chunks/chunk-QRTOLIGT.js";
|
|
39
39
|
|
|
40
40
|
// src/preset.ts
|
|
41
41
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
@@ -84,6 +84,7 @@ import {
|
|
|
84
84
|
unresolvedWarning,
|
|
85
85
|
unwrapExpression as unwrapExpression3
|
|
86
86
|
} from "storybook/internal/csf-tools";
|
|
87
|
+
import { prependToTemplate } from "storybook/internal/docs-tools";
|
|
87
88
|
|
|
88
89
|
// src/docgen/story-docs/print-template.ts
|
|
89
90
|
import {
|
|
@@ -93,6 +94,30 @@ import {
|
|
|
93
94
|
unwrapExpression,
|
|
94
95
|
walk as walkEstree
|
|
95
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("&", "&").replaceAll('"', """).replaceAll("'", "'");
|
|
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
|
+
}
|
|
96
121
|
|
|
97
122
|
// src/docgen/story-docs/markup.ts
|
|
98
123
|
import { parse } from "svelte/compiler";
|
|
@@ -125,7 +150,7 @@ function patternNames(pattern) {
|
|
|
125
150
|
}
|
|
126
151
|
}
|
|
127
152
|
function applyEdits(code, edits) {
|
|
128
|
-
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))
|
|
129
154
|
code = code.slice(0, edit.start) + edit.value + code.slice(edit.end);
|
|
130
155
|
return code;
|
|
131
156
|
}
|
|
@@ -140,118 +165,167 @@ function printTemplate({
|
|
|
140
165
|
snippets = {},
|
|
141
166
|
argsComplete = !1
|
|
142
167
|
}) {
|
|
143
|
-
let { ast, offset } = parseMarkup(code, typescript),
|
|
144
|
-
args,
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
next();
|
|
166
|
-
},
|
|
167
|
-
SpreadAttribute(node, { path, next }) {
|
|
168
|
-
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;
|
|
169
190
|
next();
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
...
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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: `>
|
|
198
235
|
${children.join(`
|
|
199
236
|
`)}
|
|
200
237
|
</${element.name}>`
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
start: close,
|
|
206
|
-
end: close,
|
|
207
|
-
value: `${children.join(`
|
|
238
|
+
});
|
|
239
|
+
} else {
|
|
240
|
+
let close = code.lastIndexOf("</", end - 1);
|
|
241
|
+
edits.push({ start: close, end: close, value: `${children.join(`
|
|
208
242
|
`)}
|
|
209
|
-
`
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
243
|
+
` });
|
|
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);
|
|
228
266
|
edits.push({
|
|
229
|
-
...
|
|
230
|
-
value
|
|
267
|
+
...place,
|
|
268
|
+
value,
|
|
269
|
+
marked: mark({ ...wholeRead, arg }, value)
|
|
231
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();
|
|
232
285
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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
|
+
};
|
|
236
293
|
}
|
|
237
|
-
function
|
|
294
|
+
function propValue(value) {
|
|
238
295
|
let node = unwrapExpression(value);
|
|
239
|
-
|
|
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
|
+
};
|
|
240
301
|
}
|
|
241
|
-
function
|
|
242
|
-
let
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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(`
|
|
250
320
|
`, start - 1) + 1, lineEnd = code.indexOf(`
|
|
251
321
|
`, end);
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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(" ") });
|
|
255
329
|
}
|
|
256
330
|
function blockExpressions(node) {
|
|
257
331
|
switch (node.type) {
|
|
@@ -282,42 +356,52 @@ function blockExpressions(node) {
|
|
|
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 = [],
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
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
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
...
|
|
299
|
-
}), !1
|
|
300
|
-
start: node.start - 1,
|
|
301
|
-
end: node.end - 1,
|
|
302
|
-
value: "undefined"
|
|
303
|
-
}), !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;
|
|
304
381
|
}
|
|
305
382
|
if (node.type === "Property" && node.shorthand && node.value.type === "Identifier") {
|
|
306
|
-
let
|
|
307
|
-
return
|
|
308
|
-
start: node.start - 1,
|
|
309
|
-
end: node.end - 1,
|
|
310
|
-
value: `${node.value.name}: ${read2.value}`
|
|
311
|
-
}), !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);
|
|
312
385
|
}
|
|
313
386
|
if (parent?.type === "MemberExpression" && parent.property === node && !parent.computed || parent?.type === "Property" && parent.key === node && !parent.computed) return;
|
|
314
|
-
let
|
|
315
|
-
|
|
387
|
+
let key = aliasOf(node);
|
|
388
|
+
key !== void 0 && push(key, node.start - 1, node.end - 1, valueOf(key));
|
|
316
389
|
}), !edits.length) return;
|
|
317
|
-
let [only] = edits,
|
|
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;
|
|
318
391
|
return {
|
|
319
392
|
value: applyEdits(expression, edits),
|
|
320
|
-
|
|
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
|
+
}
|
|
321
405
|
};
|
|
322
406
|
}
|
|
323
407
|
function argsPath(node, editor, name) {
|
|
@@ -334,7 +418,7 @@ function printRead(value, keys) {
|
|
|
334
418
|
if (!member) break;
|
|
335
419
|
node = unwrapExpression(member), rest = rest.slice(1);
|
|
336
420
|
}
|
|
337
|
-
let accessors = rest
|
|
421
|
+
let accessors = printAccessors(rest);
|
|
338
422
|
return {
|
|
339
423
|
value: isPrimary(node) ? `${textOf(node)}${accessors}` : `(${textOf(node)})${accessors}`,
|
|
340
424
|
...rest.length ? {} : { node }
|
|
@@ -366,12 +450,6 @@ function isPrimary(node) {
|
|
|
366
450
|
return !1;
|
|
367
451
|
}
|
|
368
452
|
}
|
|
369
|
-
function isPlain(value) {
|
|
370
|
-
return !/[{}<>"\\&\r\n\t]/.test(value);
|
|
371
|
-
}
|
|
372
|
-
function escapeAttribute(value) {
|
|
373
|
-
return value.replaceAll("&", "&").replaceAll('"', """).replaceAll("'", "'");
|
|
374
|
-
}
|
|
375
453
|
|
|
376
454
|
// src/docgen/story-docs/snippet-imports.ts
|
|
377
455
|
import {
|
|
@@ -749,14 +827,14 @@ function storySnippet(exportName, resolved, { file, bindings, importOverride, co
|
|
|
749
827
|
let snippet = snippetArg(key, node, file, bindings);
|
|
750
828
|
snippet !== void 0 && (snippets[key] = snippet);
|
|
751
829
|
}
|
|
752
|
-
let
|
|
830
|
+
let printed = printTemplate({
|
|
753
831
|
code: template,
|
|
754
832
|
args: resolved.args,
|
|
755
833
|
typescript: file.typescript,
|
|
756
834
|
parameter: story?.parameter,
|
|
757
835
|
snippets,
|
|
758
836
|
argsComplete: resolved.unresolved.length === 0
|
|
759
|
-
}), importBlock = () => buildSnippetImportBlock(markup, {
|
|
837
|
+
}), markup = printed.snippet, holes = printed.template, importBlock = () => buildSnippetImportBlock(markup, {
|
|
760
838
|
bindings,
|
|
761
839
|
importOverride,
|
|
762
840
|
instanceScript: file.instanceScript,
|
|
@@ -773,10 +851,10 @@ function storySnippet(exportName, resolved, { file, bindings, importOverride, co
|
|
|
773
851
|
if (!missing.length) break;
|
|
774
852
|
for (let name of missing) {
|
|
775
853
|
declared.add(name);
|
|
776
|
-
let { parameters, body } = file.snippets.get(name)
|
|
777
|
-
markup += `
|
|
854
|
+
let { parameters, body } = file.snippets.get(name), declaration = `
|
|
778
855
|
|
|
779
856
|
{#snippet ${name}(${parameters})}${body}{/snippet}`;
|
|
857
|
+
markup += declaration, holes &&= [...holes, declaration];
|
|
780
858
|
}
|
|
781
859
|
imported = importBlock();
|
|
782
860
|
}
|
|
@@ -785,12 +863,13 @@ function storySnippet(exportName, resolved, { file, bindings, importOverride, co
|
|
|
785
863
|
imported.unresolvedIdentifiers?.map((name) => `Identifier not resolved: \`${name}\`.`).join(" "),
|
|
786
864
|
unresolvedWarning(resolved.unresolved.filter((name) => !imported.declared.includes(name))),
|
|
787
865
|
renders ? RENDER_WARNING : void 0
|
|
788
|
-
].filter(Boolean)
|
|
789
|
-
return {
|
|
790
|
-
snippet: imported.block ? `${imported.block}
|
|
866
|
+
].filter(Boolean), importCode = imported.block ? `${imported.block}
|
|
791
867
|
|
|
792
|
-
|
|
793
|
-
|
|
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) }
|
|
794
873
|
};
|
|
795
874
|
}
|
|
796
875
|
function snippetArg(key, value, file, bindings) {
|
|
@@ -829,7 +908,7 @@ var isDocgenProviderEnabled = (_existing, options) => isTypeScriptReadyForDocgen
|
|
|
829
908
|
docsEnabled ? [fileURLToPath3(import.meta.resolve("@storybook/svelte/entry-preview-docs"))] : []
|
|
830
909
|
);
|
|
831
910
|
}, experimental_importParsers = async (input = []) => {
|
|
832
|
-
let { svelteImportParser } = await import("./_node-chunks/parsers-
|
|
911
|
+
let { svelteImportParser } = await import("./_node-chunks/parsers-MK4OQQPG.js");
|
|
833
912
|
return [...input, svelteImportParser];
|
|
834
913
|
}, experimental_indexers = async (existingIndexers) => {
|
|
835
914
|
let { createIndexer } = await import("./svelte-csf/indexer/index.js");
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
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 =
|
|
6
|
-
var __dirname =
|
|
7
|
-
var require =
|
|
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 code/renderers/svelte/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:
|
|
1056
|
+
map: string;
|
|
1088
1057
|
}>;
|
|
1089
1058
|
//#endregion
|
|
1090
1059
|
export { SVELTE_CSF_RUNTIME_STORIES_IMPORT_SOURCE, svelteCsfRuntimeStoriesPath, transformSvelteCsf };
|