@storybook/svelte 11.0.0-rc.3 → 11.0.0-rc.4
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/_node-chunks/{build-docgen-IN2KQQ7N.js → build-docgen-WKQQLLW6.js} +45 -27
- package/dist/_node-chunks/{chunk-5PSMHZ5O.js → chunk-6H4J2KOI.js} +19 -0
- package/dist/_node-chunks/{chunk-OAEBQIZS.js → chunk-CHEX5NQS.js} +3 -8
- package/dist/_node-chunks/{svelte-project-manager-UM2UGPYV.js → svelte-project-manager-VBLFKDZ3.js} +1 -2
- package/dist/docgen/component-docgen/svelte2tsx/generate-docgen.d.ts +1 -4
- package/dist/docgen/component-docgen/svelte2tsx/generate-docgen.js +1 -2
- package/dist/docgen/docgen-worker.js +6 -2
- package/dist/preset.js +77 -46
- package/package.json +2 -2
- package/dist/_node-chunks/chunk-RLLUKTHS.js +0 -15
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
|
+
readComponentDescription,
|
|
2
3
|
resolveStoryComponent,
|
|
3
4
|
resolveStorySubcomponents
|
|
4
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-6H4J2KOI.js";
|
|
5
6
|
import {
|
|
6
7
|
UNPRINTABLE_DEFAULT
|
|
7
|
-
} from "./chunk-
|
|
8
|
-
import "./chunk-RLLUKTHS.js";
|
|
8
|
+
} from "./chunk-CHEX5NQS.js";
|
|
9
9
|
import "./chunk-2Z47YIHP.js";
|
|
10
10
|
import "./chunk-XXIY25TZ.js";
|
|
11
11
|
import "./chunk-FZFWZSUN.js";
|
|
@@ -13,13 +13,11 @@ import "./chunk-FZFWZSUN.js";
|
|
|
13
13
|
// src/docgen/component-docgen/build-docgen.ts
|
|
14
14
|
import { readFile } from "node:fs/promises";
|
|
15
15
|
import { resolve } from "node:path";
|
|
16
|
-
import { preprocess } from "svelte/compiler";
|
|
17
16
|
import {
|
|
18
17
|
componentPathFromStory,
|
|
19
18
|
getComponentIdFromEntry,
|
|
20
19
|
getStoryImportPathFromEntry
|
|
21
20
|
} from "storybook/internal/common";
|
|
22
|
-
import { extractComponentDescription } from "storybook/internal/csf-tools";
|
|
23
21
|
|
|
24
22
|
// src/docgen/component-docgen/api-description/api-description.ts
|
|
25
23
|
import ts from "typescript";
|
|
@@ -210,20 +208,43 @@ function createServerArgTypes(docgen) {
|
|
|
210
208
|
}
|
|
211
209
|
|
|
212
210
|
// src/docgen/component-docgen/build-docgen.ts
|
|
211
|
+
async function describeStoryComponent(input) {
|
|
212
|
+
let component = await resolveStoryComponent(input.entry);
|
|
213
|
+
return component && {
|
|
214
|
+
component,
|
|
215
|
+
docs: { name: component.name, ...await readDocs(component.componentPath) }
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
var titleName = ({ entry }) => entry.title.split("/").at(-1) ?? entry.title, failure = (error) => ({
|
|
219
|
+
name: "Svelte docgen failed",
|
|
220
|
+
message: error instanceof Error ? error.message : String(error)
|
|
221
|
+
}), basePayload = (input, path) => ({
|
|
222
|
+
id: getComponentIdFromEntry(input.entry),
|
|
223
|
+
name: titleName(input),
|
|
224
|
+
path,
|
|
225
|
+
jsDocTags: {},
|
|
226
|
+
renderer: "svelte"
|
|
227
|
+
});
|
|
228
|
+
async function buildBasicDocgen(input) {
|
|
229
|
+
let path = getStoryImportPathFromEntry(input.entry);
|
|
230
|
+
if (path)
|
|
231
|
+
try {
|
|
232
|
+
let described = await describeStoryComponent(input);
|
|
233
|
+
return described && { ...basePayload(input, path), ...described.docs };
|
|
234
|
+
} catch (error) {
|
|
235
|
+
return { ...basePayload(input, path), error: failure(error) };
|
|
236
|
+
}
|
|
237
|
+
}
|
|
213
238
|
async function buildDocgenPayload(input, context) {
|
|
214
239
|
let path = getStoryImportPathFromEntry(input.entry);
|
|
215
240
|
if (!path) return;
|
|
216
|
-
let base =
|
|
217
|
-
id: getComponentIdFromEntry(input.entry),
|
|
218
|
-
name: input.entry.title.split("/").at(-1) ?? input.entry.title,
|
|
219
|
-
path,
|
|
220
|
-
jsDocTags: {},
|
|
221
|
-
renderer: "svelte"
|
|
222
|
-
};
|
|
241
|
+
let base = basePayload(input, path), docs;
|
|
223
242
|
try {
|
|
224
|
-
let
|
|
225
|
-
if (!
|
|
226
|
-
let
|
|
243
|
+
let described = await describeStoryComponent(input);
|
|
244
|
+
if (!described) return;
|
|
245
|
+
let { component } = described;
|
|
246
|
+
docs = described.docs;
|
|
247
|
+
let props = componentProps(component.componentPath, component.name, context), subcomponents = {};
|
|
227
248
|
for (let [name, subcomponent] of Object.entries(
|
|
228
249
|
await resolveStorySubcomponents(input.entry)
|
|
229
250
|
))
|
|
@@ -231,38 +252,35 @@ async function buildDocgenPayload(input, context) {
|
|
|
231
252
|
subcomponents[name] = {
|
|
232
253
|
name,
|
|
233
254
|
path: componentPathFromStory(path, resolve(path), subcomponent.componentPath),
|
|
234
|
-
...await
|
|
255
|
+
...await readDocs(subcomponent.componentPath),
|
|
256
|
+
...componentProps(subcomponent.componentPath, name, context)
|
|
235
257
|
};
|
|
236
258
|
} catch {
|
|
237
259
|
continue;
|
|
238
260
|
}
|
|
239
261
|
return {
|
|
240
262
|
...base,
|
|
241
|
-
name: component.name,
|
|
242
263
|
...docs,
|
|
264
|
+
...props,
|
|
243
265
|
...Object.keys(subcomponents).length ? { subcomponents } : {}
|
|
244
266
|
};
|
|
245
267
|
} catch (error) {
|
|
246
268
|
return {
|
|
247
269
|
...base,
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
message: error instanceof Error ? error.message : String(error)
|
|
251
|
-
}
|
|
270
|
+
...docs,
|
|
271
|
+
error: failure(error)
|
|
252
272
|
};
|
|
253
273
|
}
|
|
254
274
|
}
|
|
255
|
-
async
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
documentationSource: documentationSource.code
|
|
259
|
-
});
|
|
275
|
+
var readDocs = async (componentPath) => readComponentDescription(await readFile(componentPath, "utf8"));
|
|
276
|
+
function componentProps(componentPath, name, context) {
|
|
277
|
+
let docgen = context.componentMetaManager.generateDocgen(componentPath, { server: !0 });
|
|
260
278
|
return {
|
|
261
|
-
...extractComponentDescription(void 0, docgen.description, docgen.jsDocTags),
|
|
262
279
|
argTypes: createServerArgTypes(docgen),
|
|
263
280
|
apiDescription: buildApiDescription(name, docgen)
|
|
264
281
|
};
|
|
265
282
|
}
|
|
266
283
|
export {
|
|
284
|
+
buildBasicDocgen,
|
|
267
285
|
buildDocgenPayload
|
|
268
286
|
};
|
|
@@ -6,6 +6,23 @@ import {
|
|
|
6
6
|
getDefineMetaFirstArgumentObjectExpression
|
|
7
7
|
} from "./chunk-XXIY25TZ.js";
|
|
8
8
|
|
|
9
|
+
// src/docgen/component-docgen/component-comment.ts
|
|
10
|
+
import { extractComponentDescription, extractJSDocInfo } from "storybook/internal/csf-tools";
|
|
11
|
+
import { parse, preprocess } from "svelte/compiler";
|
|
12
|
+
function extractComponentComment(root) {
|
|
13
|
+
let comments = root.fragment.nodes.filter(
|
|
14
|
+
(node) => node.type === "Comment" && /@component\b/.test(node.data)
|
|
15
|
+
), comment = comments.find((node) => /^\s*@component\b/.test(node.data)) ?? comments[0];
|
|
16
|
+
return comment ? extractJSDocInfo(
|
|
17
|
+
comment.data.replace(/@component\b/, "").replace(/\s+(@[a-zA-Z]+\b)/g, `
|
|
18
|
+
$1`).trim()
|
|
19
|
+
) : void 0;
|
|
20
|
+
}
|
|
21
|
+
async function readComponentDescription(source) {
|
|
22
|
+
let { code } = await preprocess(source, { style: () => ({ code: "" }) }), comment = extractComponentComment(parse(code, { modern: !0 }));
|
|
23
|
+
return extractComponentDescription(void 0, comment?.description.trim(), comment?.tags);
|
|
24
|
+
}
|
|
25
|
+
|
|
9
26
|
// src/docgen/component-docgen/resolve-component/resolve-component.ts
|
|
10
27
|
import { readFileSync } from "node:fs";
|
|
11
28
|
import { readFile } from "node:fs/promises";
|
|
@@ -125,6 +142,8 @@ async function readSvelteMeta(file, storyPath) {
|
|
|
125
142
|
}
|
|
126
143
|
|
|
127
144
|
export {
|
|
145
|
+
extractComponentComment,
|
|
146
|
+
readComponentDescription,
|
|
128
147
|
resolveStoryComponent,
|
|
129
148
|
resolveCsfComponent,
|
|
130
149
|
resolveStorySubcomponents
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
extractComponentComment
|
|
3
|
-
} from "./chunk-RLLUKTHS.js";
|
|
4
|
-
|
|
5
1
|
// src/docgen/component-docgen/svelte2tsx/generate-docgen.ts
|
|
6
2
|
import path from "node:path";
|
|
7
3
|
import { fileURLToPath } from "node:url";
|
|
8
4
|
import svelte2tsx, { internalHelpers } from "svelte2tsx";
|
|
9
|
-
import { VERSION
|
|
5
|
+
import { VERSION } from "svelte/compiler";
|
|
10
6
|
import ts from "typescript";
|
|
11
7
|
var UNPRINTABLE_DEFAULT = "...";
|
|
12
8
|
function convertType(type, checker) {
|
|
@@ -363,14 +359,13 @@ function extractDocgen(program, checker, targetFileName, options) {
|
|
|
363
359
|
}
|
|
364
360
|
});
|
|
365
361
|
});
|
|
366
|
-
let
|
|
362
|
+
let typeParams = renderFunction.typeParameters?.map((param) => param.getText()).join(", "), omittedTypes = propsType && omitted.size ? [...new Set(libraryTypesWithOmittedProps(propsType, omitted, checker))] : [];
|
|
367
363
|
return {
|
|
368
364
|
props: Array.from(propMap.values()),
|
|
369
365
|
events,
|
|
370
366
|
slots,
|
|
371
367
|
...typeParams ? { typeParams } : {},
|
|
372
|
-
...omittedTypes.length ? { omittedTypes } : {}
|
|
373
|
-
...docs ? { description: docs.description.trim(), jsDocTags: docs.tags } : {}
|
|
368
|
+
...omittedTypes.length ? { omittedTypes } : {}
|
|
374
369
|
};
|
|
375
370
|
}
|
|
376
371
|
|
package/dist/_node-chunks/{svelte-project-manager-UM2UGPYV.js → svelte-project-manager-VBLFKDZ3.js}
RENAMED
|
@@ -6,8 +6,7 @@ import {
|
|
|
6
6
|
inferredCommandLine,
|
|
7
7
|
parseSvelteConfig,
|
|
8
8
|
virtualFileName
|
|
9
|
-
} from "./chunk-
|
|
10
|
-
import "./chunk-RLLUKTHS.js";
|
|
9
|
+
} from "./chunk-CHEX5NQS.js";
|
|
11
10
|
|
|
12
11
|
// src/docgen/component-docgen/component-meta/svelte-project-manager.ts
|
|
13
12
|
import { statSync } from "node:fs";
|
|
@@ -2,11 +2,9 @@ import ts from "typescript";
|
|
|
2
2
|
|
|
3
3
|
//#region code/renderers/svelte/.dts-emit/code/renderers/svelte/src/docgen/component-docgen/svelte2tsx/generate-docgen.d.ts
|
|
4
4
|
type Docgen = {
|
|
5
|
-
name?: string;
|
|
6
|
-
description?: string; /** The `generics` attribute of the instance script, such as `Value extends string`. */
|
|
5
|
+
name?: string; /** The `generics` attribute of the instance script, such as `Value extends string`. */
|
|
7
6
|
typeParams?: string; /** The library types the props extend whose members `props` leaves out, such as `HTMLInputAttributes`. */
|
|
8
7
|
omittedTypes?: string[];
|
|
9
|
-
jsDocTags?: Record<string, string[]>;
|
|
10
8
|
props: PropInfo[];
|
|
11
9
|
events?: PropInfo[];
|
|
12
10
|
slots?: PropInfo[];
|
|
@@ -71,7 +69,6 @@ interface SvelteCommandLine {
|
|
|
71
69
|
}
|
|
72
70
|
type DocgenOptions = {
|
|
73
71
|
server?: boolean;
|
|
74
|
-
documentationSource?: string;
|
|
75
72
|
};
|
|
76
73
|
/** Map a `.svelte` component to the `.svelte.tsx` file svelte2tsx compiles it to. */
|
|
77
74
|
declare function virtualFileName(fileName: string): string;
|
|
@@ -8,8 +8,7 @@ import {
|
|
|
8
8
|
inferredCommandLine,
|
|
9
9
|
parseSvelteConfig,
|
|
10
10
|
virtualFileName
|
|
11
|
-
} from "../../../_node-chunks/chunk-
|
|
12
|
-
import "../../../_node-chunks/chunk-RLLUKTHS.js";
|
|
11
|
+
} from "../../../_node-chunks/chunk-CHEX5NQS.js";
|
|
13
12
|
export {
|
|
14
13
|
UNPRINTABLE_DEFAULT,
|
|
15
14
|
assertCompilerApi,
|
|
@@ -11,8 +11,8 @@ var createDocgenProvider = () => createLazyDocgenMiddleware({
|
|
|
11
11
|
try {
|
|
12
12
|
await loadTypeScriptCompilerApi(() => import("typescript"));
|
|
13
13
|
let [{ SvelteComponentMetaManager }, { buildDocgenPayload }] = await Promise.all([
|
|
14
|
-
import("../_node-chunks/svelte-project-manager-
|
|
15
|
-
import("../_node-chunks/build-docgen-
|
|
14
|
+
import("../_node-chunks/svelte-project-manager-VBLFKDZ3.js"),
|
|
15
|
+
import("../_node-chunks/build-docgen-WKQQLLW6.js")
|
|
16
16
|
]), componentMetaManager = new SvelteComponentMetaManager();
|
|
17
17
|
return componentMetaManager.startWatching(), { componentMetaManager, buildDocgenPayload };
|
|
18
18
|
} catch (error) {
|
|
@@ -22,6 +22,10 @@ var createDocgenProvider = () => createLazyDocgenMiddleware({
|
|
|
22
22
|
return;
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
|
+
extractBasic: async (input) => {
|
|
26
|
+
let { buildBasicDocgen } = await import("../_node-chunks/build-docgen-WKQQLLW6.js");
|
|
27
|
+
return buildBasicDocgen(input);
|
|
28
|
+
},
|
|
25
29
|
extract: async (context, input) => context.buildDocgenPayload(input, context)
|
|
26
30
|
});
|
|
27
31
|
export {
|
package/dist/preset.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
extractComponentComment,
|
|
2
3
|
resolveCsfComponent
|
|
3
|
-
} from "./_node-chunks/chunk-
|
|
4
|
-
import {
|
|
5
|
-
extractComponentComment
|
|
6
|
-
} from "./_node-chunks/chunk-RLLUKTHS.js";
|
|
4
|
+
} from "./_node-chunks/chunk-6H4J2KOI.js";
|
|
7
5
|
import {
|
|
8
6
|
SVELTE_DOCGEN_STORY_FILE_TEST_REGEXP
|
|
9
7
|
} from "./_node-chunks/chunk-4AFBO5RP.js";
|
|
@@ -91,6 +89,7 @@ import {
|
|
|
91
89
|
} from "storybook/internal/csf-tools";
|
|
92
90
|
import {
|
|
93
91
|
createHoleMarks,
|
|
92
|
+
layOutWrittenTag,
|
|
94
93
|
withHoleSpace
|
|
95
94
|
} from "storybook/internal/docs-tools";
|
|
96
95
|
|
|
@@ -171,8 +170,34 @@ function printTemplate({
|
|
|
171
170
|
}, isArgsSpread = (attribute) => attribute.type === "SpreadAttribute" && attribute.expression.type === "Identifier" && attribute.expression.name === name, at = (node) => {
|
|
172
171
|
let range = span(node);
|
|
173
172
|
return { start: range.start - offset, end: range.end - offset };
|
|
174
|
-
}, written = ({ start, end }) => code.slice(start, end), edits = [];
|
|
175
|
-
|
|
173
|
+
}, written = ({ start, end }) => code.slice(start, end), edits = [], spreadTags = /* @__PURE__ */ new Map();
|
|
174
|
+
function layOutTag({ element, spreads }) {
|
|
175
|
+
let { start } = at(element), nameEnd = start + 1 + element.name.length, lastAttribute = element.attributes.at(-1), closeStart = lastAttribute ? at(lastAttribute).end : nameEnd;
|
|
176
|
+
for (; /\s/.test(code[closeStart] ?? ""); ) closeStart++;
|
|
177
|
+
let close = code.startsWith("/>", closeStart) ? "/>" : code[closeStart] === ">" ? ">" : "";
|
|
178
|
+
if (!close) return;
|
|
179
|
+
let attributes = element.attributes.flatMap((attribute) => {
|
|
180
|
+
let pieces = spreads.get(attribute);
|
|
181
|
+
if (pieces) return [...pieces.props, pieces.added];
|
|
182
|
+
let range = at(attribute), own = edits.filter((edit) => edit.start >= range.start && edit.end <= range.end).map((edit) => ({
|
|
183
|
+
start: edit.start - range.start,
|
|
184
|
+
end: edit.end - range.start,
|
|
185
|
+
value: edit.marked ?? edit.value
|
|
186
|
+
}));
|
|
187
|
+
return [applyEdits(written(range), own)];
|
|
188
|
+
}), text = layOutWrittenTag(code, { start, nameEnd, closeStart, close }, attributes, {
|
|
189
|
+
measure: marks2?.unmark
|
|
190
|
+
});
|
|
191
|
+
if (text === void 0) return;
|
|
192
|
+
let outside = edits.filter((edit) => edit.start < nameEnd || edit.end > closeStart);
|
|
193
|
+
return edits.splice(0, edits.length, ...outside, {
|
|
194
|
+
start: nameEnd,
|
|
195
|
+
end: closeStart,
|
|
196
|
+
value: text,
|
|
197
|
+
marked: text
|
|
198
|
+
}), closeStart;
|
|
199
|
+
}
|
|
200
|
+
walk(ast.fragment, null, {
|
|
176
201
|
Attribute(node, { path, next }) {
|
|
177
202
|
let element = path.at(-1), spreadAfter = element && "attributes" in element && element.attributes.some(
|
|
178
203
|
(attribute) => isArgsSpread(attribute) && attribute.start > node.start
|
|
@@ -208,35 +233,27 @@ function printTemplate({
|
|
|
208
233
|
]), passed = (key) => !writtenProps.has(key) && !destructured.has(key), props = Object.entries(args).flatMap(([key, value]) => {
|
|
209
234
|
let printed = propValue(value);
|
|
210
235
|
return key in snippets || !passed(key) || printed === void 0 ? [] : [[key, printProp(key, printed)]];
|
|
211
|
-
}),
|
|
236
|
+
}), except = [
|
|
212
237
|
...props.map(([key]) => key),
|
|
213
238
|
...writtenProps,
|
|
214
239
|
...destructured,
|
|
215
240
|
...Object.keys(snippets)
|
|
216
|
-
]
|
|
217
|
-
|
|
241
|
+
], pieces = {
|
|
242
|
+
props: props.map(([arg, prop]) => mark({ kind: "prop", arg }, prop)),
|
|
243
|
+
// The args a control adds stand `space` apart, as the props of the spread do.
|
|
244
|
+
added: (space) => mark({ kind: "props", except, separator: space, spread: !0 }, "", space)
|
|
245
|
+
};
|
|
246
|
+
if (edits.push(spreadPlace(code, at(node), pieces)), !element || !("attributes" in element) || !("name" in element) || typeof element.name != "string")
|
|
247
|
+
return;
|
|
248
|
+
let tag = spreadTags.get(element) ?? {
|
|
249
|
+
element: { ...element, name: element.name },
|
|
250
|
+
spreads: /* @__PURE__ */ new Map()
|
|
251
|
+
};
|
|
252
|
+
tag.spreads.set(node, pieces), spreadTags.set(element, tag);
|
|
218
253
|
let children = Object.entries(snippets).flatMap(
|
|
219
254
|
([key, snippet2]) => passed(key) ? [snippet2] : []
|
|
220
255
|
);
|
|
221
|
-
|
|
222
|
-
let { start, end } = at(element);
|
|
223
|
-
if (code.slice(start, end).endsWith("/>")) {
|
|
224
|
-
let from = end - 2;
|
|
225
|
-
for (; from > spread.end && /[ \t]/.test(code[from - 1]); ) from--;
|
|
226
|
-
edits.push({
|
|
227
|
-
start: from,
|
|
228
|
-
end,
|
|
229
|
-
value: `>
|
|
230
|
-
${children.join(`
|
|
231
|
-
`)}
|
|
232
|
-
</${element.name}>`
|
|
233
|
-
});
|
|
234
|
-
} else {
|
|
235
|
-
let close = code.lastIndexOf("</", end - 1);
|
|
236
|
-
edits.push({ start: close, end: close, value: `${children.join(`
|
|
237
|
-
`)}
|
|
238
|
-
` });
|
|
239
|
-
}
|
|
256
|
+
children.length && element.type === "Component" && (tag.children = children);
|
|
240
257
|
},
|
|
241
258
|
ExpressionTag(node, { path }) {
|
|
242
259
|
let range = at(node.expression), replaced = replaceArgsReads(written(range), reads);
|
|
@@ -278,7 +295,27 @@ ${children.join(`
|
|
|
278
295
|
}
|
|
279
296
|
next();
|
|
280
297
|
}
|
|
281
|
-
})
|
|
298
|
+
});
|
|
299
|
+
for (let tag of spreadTags.values()) {
|
|
300
|
+
let closeStart = layOutTag(tag);
|
|
301
|
+
tag.children && edits.push(openedFor(tag, tag.children, closeStart));
|
|
302
|
+
}
|
|
303
|
+
return edits;
|
|
304
|
+
function openedFor({ element }, children, closeStart) {
|
|
305
|
+
let { end } = at(element);
|
|
306
|
+
if (!code.slice(0, end).endsWith("/>")) {
|
|
307
|
+
let close = code.lastIndexOf("</", end - 1);
|
|
308
|
+
return { start: close, end: close, value: `${children.join(`
|
|
309
|
+
`)}
|
|
310
|
+
` };
|
|
311
|
+
}
|
|
312
|
+
let from = closeStart ?? end - 2;
|
|
313
|
+
if (closeStart === void 0) for (; /[ \t]/.test(code[from - 1]); ) from--;
|
|
314
|
+
return { start: from, end, value: `>
|
|
315
|
+
${children.join(`
|
|
316
|
+
`)}
|
|
317
|
+
</${element.name}>` };
|
|
318
|
+
}
|
|
282
319
|
}, snippet = applyEdits(code, collect()), marks = createHoleMarks([snippet]), marked = collect(marks).map((edit) => ({ ...edit, value: edit.marked ?? edit.value })), template = marks.toTemplate(applyEdits(code, marked));
|
|
283
320
|
return {
|
|
284
321
|
snippet,
|
|
@@ -294,27 +331,21 @@ function propValue(value) {
|
|
|
294
331
|
code: textOf(value)
|
|
295
332
|
};
|
|
296
333
|
}
|
|
297
|
-
function spreadPlace(code, span2,
|
|
298
|
-
let
|
|
299
|
-
|
|
300
|
-
|
|
334
|
+
function spreadPlace(code, span2, { props, added }) {
|
|
335
|
+
let { end } = span2, { start } = span2, lineStart = code.lastIndexOf(`
|
|
336
|
+
`, start - 1) + 1, lineEnd = code.indexOf(`
|
|
337
|
+
`, end), ownLine = lineEnd !== -1 && !code.slice(lineStart, start).trim() && !code.slice(end, lineEnd).trim();
|
|
301
338
|
if (props.length) {
|
|
302
|
-
let
|
|
303
|
-
|
|
339
|
+
let separator = ownLine ? `
|
|
340
|
+
${code.slice(lineStart, start)}` : " ";
|
|
341
|
+
return {
|
|
304
342
|
start,
|
|
305
343
|
end,
|
|
306
|
-
value:
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
marked: `
|
|
310
|
-
${marked}${added(separator)}
|
|
311
|
-
`
|
|
312
|
-
} : { start, end, value, marked: `${marked}${added(separator)}` };
|
|
344
|
+
value: props.join(separator),
|
|
345
|
+
marked: `${props.join(separator)}${added(separator)}`
|
|
346
|
+
};
|
|
313
347
|
}
|
|
314
|
-
|
|
315
|
-
`, start - 1) + 1, lineEnd = code.indexOf(`
|
|
316
|
-
`, end);
|
|
317
|
-
return lineEnd !== -1 && !code.slice(lineStart, start).trim() && !code.slice(end, lineEnd).trim() ? {
|
|
348
|
+
return ownLine ? {
|
|
318
349
|
start: lineStart - 1,
|
|
319
350
|
end: lineEnd,
|
|
320
351
|
value: "",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/svelte",
|
|
3
|
-
"version": "11.0.0-rc.
|
|
3
|
+
"version": "11.0.0-rc.4",
|
|
4
4
|
"description": "Storybook Svelte renderer: Develop, document, and test UI components in isolation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"zimmerframe": "^1.1.2"
|
|
107
107
|
},
|
|
108
108
|
"peerDependencies": {
|
|
109
|
-
"storybook": "^11.0.0-rc.
|
|
109
|
+
"storybook": "^11.0.0-rc.4",
|
|
110
110
|
"svelte": "^5.0.0",
|
|
111
111
|
"typescript": "^5.9.0 || ^6.0.0 || ^7.0.0"
|
|
112
112
|
},
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
// src/docgen/component-docgen/component-comment.ts
|
|
2
|
-
import { extractJSDocInfo } from "storybook/internal/csf-tools";
|
|
3
|
-
function extractComponentComment(root) {
|
|
4
|
-
let comments = root.fragment.nodes.filter(
|
|
5
|
-
(node) => node.type === "Comment" && /@component\b/.test(node.data)
|
|
6
|
-
), comment = comments.find((node) => /^\s*@component\b/.test(node.data)) ?? comments[0];
|
|
7
|
-
return comment ? extractJSDocInfo(
|
|
8
|
-
comment.data.replace(/@component\b/, "").replace(/\s+(@[a-zA-Z]+\b)/g, `
|
|
9
|
-
$1`).trim()
|
|
10
|
-
) : void 0;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export {
|
|
14
|
-
extractComponentComment
|
|
15
|
-
};
|