@storybook/svelte 11.0.0-beta.3 → 11.0.0-beta.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/_browser-chunks/chunk-QOQZ54LJ.js +31 -0
- package/dist/_browser-chunks/{chunk-FPEMDWKX.js → chunk-UQPE7TCS.js} +3 -3
- package/dist/_node-chunks/{build-docgen-TQ6645JH.js → build-docgen-4CLD5RKH.js} +79 -177
- package/dist/_node-chunks/{chunk-QN3DI6BM.js → chunk-2Z47YIHP.js} +2 -13
- package/dist/_node-chunks/{chunk-5XOL5BKO.js → chunk-3JLJMGBT.js} +0 -12
- package/dist/_node-chunks/chunk-4AFBO5RP.js +9 -0
- package/dist/_node-chunks/{chunk-RUGG3JY2.js → chunk-4QUF46RV.js} +0 -12
- package/dist/_node-chunks/{chunk-BQ2RIMP3.js → chunk-EZI5LVNW.js} +35 -16
- package/dist/_node-chunks/{chunk-JCULIFGX.js → chunk-FZFWZSUN.js} +0 -12
- package/dist/_node-chunks/{chunk-BUMY5Y7X.js → chunk-XLMS4YUB.js} +2 -45
- package/dist/_node-chunks/{parsers-KP7MPNO3.js → parsers-ENYE653E.js} +0 -12
- package/dist/_node-chunks/{svelte-project-manager-OOWETREX.js → svelte-project-manager-Q35NEAHT.js} +1 -12
- package/dist/_node-chunks/walk-TKX2QFK2.js +6 -0
- package/dist/{chunk-Cepksr9x.d.ts → chunk-CoCY0Re5.d.ts} +6 -1
- package/dist/docgen/component-docgen/svelte2tsx/generate-docgen.js +1 -12
- package/dist/docgen/docgen-worker.js +3 -14
- package/dist/entry-preview.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/preset.js +7 -18
- package/dist/svelte-csf/addon-check.js +0 -12
- package/dist/svelte-csf/compiler/transform.js +11 -22
- package/dist/svelte-csf/indexer/index.js +2 -13
- package/dist/svelte-csf/runtime/component-helpers.d.ts +18 -4
- package/dist/svelte-csf/runtime/component-helpers.js +5 -1
- package/dist/svelte-csf/runtime/create-runtime-stories.d.ts +1 -1
- package/dist/svelte-csf/runtime/create-runtime-stories.js +9 -1
- package/package.json +2 -2
- package/static/svelte-csf/Story.svelte +17 -1
- package/static/svelte-csf/StoryRenderer.svelte +8 -1
- package/static/svelte-csf/contexts/renderer.svelte.js +6 -0
- package/dist/_node-chunks/chunk-J4TCM6ZP.js +0 -21
- package/dist/_node-chunks/walk-FGYTHLP6.js +0 -17
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// src/svelte-csf/runtime/sync-story-args.ts
|
|
2
|
+
import { UPDATE_STORY_ARGS } from "storybook/internal/core-events";
|
|
3
|
+
import { addons } from "storybook/internal/preview-api";
|
|
4
|
+
import { isEqual, isPlainObject } from "es-toolkit/predicate";
|
|
5
|
+
var snapshotArg = (value, copies = /* @__PURE__ */ new Map()) => {
|
|
6
|
+
if (!Array.isArray(value) && !isPlainObject(value))
|
|
7
|
+
return value;
|
|
8
|
+
if (copies.has(value))
|
|
9
|
+
return copies.get(value);
|
|
10
|
+
let copy = Array.isArray(value) ? [] : {};
|
|
11
|
+
copies.set(value, copy);
|
|
12
|
+
for (let [key, item] of Object.entries(value))
|
|
13
|
+
copy[key] = snapshotArg(item, copies);
|
|
14
|
+
return copy;
|
|
15
|
+
}, sentArgsByStory = /* @__PURE__ */ new Map(), syncStoryArgs = ({ exportName, storyArgs, argSources, storyId }) => {
|
|
16
|
+
let sent = sentArgsByStory.get(storyId);
|
|
17
|
+
sent || (sent = {}, sentArgsByStory.set(storyId, sent));
|
|
18
|
+
let updatedArgs = {};
|
|
19
|
+
for (let [key, value] of Object.entries(storyArgs ?? {})) {
|
|
20
|
+
if (argSources[key]?.exportName !== exportName)
|
|
21
|
+
continue;
|
|
22
|
+
let snapshot = snapshotArg(value), last = key in sent ? sent[key] : argSources[key].value;
|
|
23
|
+
isEqual(last, snapshot) || (sent[key] = snapshot, updatedArgs[key] = value);
|
|
24
|
+
}
|
|
25
|
+
Object.keys(updatedArgs).length > 0 && addons.getChannel().emit(UPDATE_STORY_ARGS, { storyId, updatedArgs });
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
snapshotArg,
|
|
30
|
+
syncStoryArgs
|
|
31
|
+
};
|
|
@@ -130,7 +130,7 @@ async function renderToCanvas({
|
|
|
130
130
|
mountedComponent && (svelte.unmount(mountedComponent), componentsByDomElement.delete(canvasElementToUnmount));
|
|
131
131
|
}
|
|
132
132
|
let existingComponent = componentsByDomElement.get(canvasElement), remount = forceRemount;
|
|
133
|
-
if (storyIdsToRemountFromResetArgsEvent.has(storyContext.id) && (remount = !0, storyIdsToRemountFromResetArgsEvent.delete(storyContext.id)), remount && unmount2(canvasElement), !existingComponent || remount) {
|
|
133
|
+
if (storyIdsToRemountFromResetArgsEvent.has(storyContext.id) && (remount = !0, storyIdsToRemountFromResetArgsEvent.delete(storyContext.id)), remount && unmount2(canvasElement), showMain(), !existingComponent || remount) {
|
|
134
134
|
let props = createReactiveProps({
|
|
135
135
|
storyFn,
|
|
136
136
|
storyContext,
|
|
@@ -149,8 +149,8 @@ async function renderToCanvas({
|
|
|
149
149
|
name,
|
|
150
150
|
title,
|
|
151
151
|
showError
|
|
152
|
-
}), await svelte.tick();
|
|
153
|
-
return
|
|
152
|
+
}), svelte.flushSync(), await svelte.tick();
|
|
153
|
+
return () => {
|
|
154
154
|
unmount2(canvasElement);
|
|
155
155
|
};
|
|
156
156
|
}
|
|
@@ -1,33 +1,24 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_ozn9e8tgwi from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_ozn9e8tgwi from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_ozn9e8tgwi from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_ozn9e8tgwi.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_ozn9e8tgwi.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_ozn9e8tgwi.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
1
|
import {
|
|
13
2
|
UNPRINTABLE_DEFAULT
|
|
14
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-3JLJMGBT.js";
|
|
15
4
|
import {
|
|
16
5
|
parseSvelteSource
|
|
17
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-2Z47YIHP.js";
|
|
18
7
|
import {
|
|
19
8
|
extractSvelteASTNodes,
|
|
20
|
-
getDefineMetaComponentValue,
|
|
21
9
|
getDefineMetaFirstArgumentObjectExpression
|
|
22
|
-
} from "./chunk-
|
|
23
|
-
import "./chunk-
|
|
10
|
+
} from "./chunk-XLMS4YUB.js";
|
|
11
|
+
import "./chunk-FZFWZSUN.js";
|
|
24
12
|
|
|
25
13
|
// src/docgen/component-docgen/build-docgen.ts
|
|
26
|
-
import { realpathSync } from "node:fs";
|
|
27
14
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
28
|
-
import {
|
|
15
|
+
import { resolve as resolve2 } from "node:path";
|
|
29
16
|
import { preprocess } from "svelte/compiler";
|
|
30
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
componentPathFromStory,
|
|
19
|
+
getComponentIdFromEntry,
|
|
20
|
+
getStoryImportPathFromEntry as getStoryImportPathFromEntry2
|
|
21
|
+
} from "storybook/internal/common";
|
|
31
22
|
import { extractComponentDescription } from "storybook/internal/csf-tools";
|
|
32
23
|
|
|
33
24
|
// src/docgen/component-docgen/api-description/api-description.ts
|
|
@@ -223,79 +214,30 @@ import { readFileSync } from "node:fs";
|
|
|
223
214
|
import { readFile } from "node:fs/promises";
|
|
224
215
|
import { resolve } from "node:path";
|
|
225
216
|
import {
|
|
226
|
-
|
|
217
|
+
createComponentNodeResolver,
|
|
227
218
|
createModuleResolver,
|
|
219
|
+
defaultResolveConditionNames,
|
|
220
|
+
extractDeclaredSubcomponents,
|
|
221
|
+
extractSubcomponents,
|
|
228
222
|
getStoryImportPathFromEntry,
|
|
229
|
-
jsTsSourceExtensions
|
|
223
|
+
jsTsSourceExtensions,
|
|
224
|
+
typescriptExtensionAlias
|
|
230
225
|
} from "storybook/internal/common";
|
|
231
226
|
import {
|
|
232
227
|
SourceEditor,
|
|
233
|
-
collectImportBindings,
|
|
234
228
|
loadCsf,
|
|
235
|
-
metaObject,
|
|
236
229
|
parseExpression,
|
|
237
|
-
|
|
238
|
-
propertyValue,
|
|
239
|
-
resolveReferencedValue,
|
|
240
|
-
staticKey,
|
|
241
|
-
unwrapExpression
|
|
230
|
+
propertyValue
|
|
242
231
|
} from "storybook/internal/csf-tools";
|
|
243
|
-
var
|
|
232
|
+
var moduleResolver = createModuleResolver({
|
|
244
233
|
extensions: [".svelte", ...jsTsSourceExtensions],
|
|
245
234
|
// TypeScript projects import `./index.ts` as `./index.js`, as SvelteKit's packaging requires.
|
|
246
|
-
extensionAlias:
|
|
235
|
+
extensionAlias: typescriptExtensionAlias,
|
|
247
236
|
mainFields: ["svelte", "module", "main"],
|
|
248
|
-
|
|
237
|
+
// Core's conditions plus `svelte`, so a `storybook` entry resolves as it does in the preview.
|
|
238
|
+
conditionNames: ["svelte", ...defaultResolveConditionNames],
|
|
249
239
|
tsconfig: "auto"
|
|
250
240
|
});
|
|
251
|
-
function resolveImport(fromFile, specifier) {
|
|
252
|
-
try {
|
|
253
|
-
return moduleResolver.resolveFileSync(fromFile, specifier);
|
|
254
|
-
} catch {
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
function importedName(specifier) {
|
|
259
|
-
return specifier.type === "ImportDefaultSpecifier" ? "default" : specifier.type === "ImportNamespaceSpecifier" ? "*" : specifier.imported?.type === "Identifier" ? String(specifier.imported.name) : String(specifier.imported?.value);
|
|
260
|
-
}
|
|
261
|
-
function exportedName(node) {
|
|
262
|
-
return node.type === "Identifier" ? node.name : String(node.value);
|
|
263
|
-
}
|
|
264
|
-
function followExport(filePath, exportName, seen = /* @__PURE__ */ new Set()) {
|
|
265
|
-
if (filePath.endsWith(".svelte") && exportName === "default") return filePath;
|
|
266
|
-
let key = `${filePath}#${exportName}`;
|
|
267
|
-
if (seen.has(key)) return;
|
|
268
|
-
seen.add(key);
|
|
269
|
-
let program = moduleProgram(filePath);
|
|
270
|
-
if (!program) return;
|
|
271
|
-
let follow = (specifier, name) => {
|
|
272
|
-
let target = resolveImport(filePath, specifier);
|
|
273
|
-
return target ? followExport(target, name, seen) : void 0;
|
|
274
|
-
}, followLocal = (localName) => {
|
|
275
|
-
for (let declaration of program.body) {
|
|
276
|
-
if (declaration.type !== "ImportDeclaration" || declaration.importKind === "type") continue;
|
|
277
|
-
let imported = declaration.specifiers.find(
|
|
278
|
-
(candidate) => candidate.local.name === localName
|
|
279
|
-
);
|
|
280
|
-
if (imported) return follow(declaration.source.value, importedName(imported));
|
|
281
|
-
}
|
|
282
|
-
};
|
|
283
|
-
for (let statement of program.body) {
|
|
284
|
-
if (statement.type === "ExportDefaultDeclaration" && exportName === "default" && statement.declaration.type === "Identifier")
|
|
285
|
-
return followLocal(statement.declaration.name);
|
|
286
|
-
if (statement.type === "ExportAllDeclaration" && !statement.exported) {
|
|
287
|
-
let found = exportName !== "default" && statement.exportKind !== "type" && follow(statement.source.value, exportName);
|
|
288
|
-
if (found) return found;
|
|
289
|
-
}
|
|
290
|
-
if (statement.type !== "ExportNamedDeclaration" || statement.exportKind === "type") continue;
|
|
291
|
-
let specifier = statement.specifiers.find(
|
|
292
|
-
(candidate) => exportedName(candidate.exported) === exportName
|
|
293
|
-
);
|
|
294
|
-
if (!specifier || specifier.exportKind === "type") continue;
|
|
295
|
-
let localName = exportedName(specifier.local);
|
|
296
|
-
return statement.source ? follow(statement.source.value, localName) : followLocal(localName);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
241
|
function moduleEditor(filePath) {
|
|
300
242
|
try {
|
|
301
243
|
let file = readFileSync(filePath, "utf8");
|
|
@@ -306,123 +248,83 @@ function moduleEditor(filePath) {
|
|
|
306
248
|
return;
|
|
307
249
|
}
|
|
308
250
|
}
|
|
309
|
-
function
|
|
310
|
-
|
|
311
|
-
}
|
|
312
|
-
function locate(storyPath, specifier, exportName, name) {
|
|
313
|
-
let filePath = resolveImport(storyPath, specifier), componentPath = filePath && followExport(filePath, exportName);
|
|
314
|
-
if (!componentPath)
|
|
315
|
-
throw new Error(`Could not resolve \`${specifier}\` export \`${exportName}\``);
|
|
316
|
-
return { componentPath, exportName, name };
|
|
251
|
+
function readModule(filePath) {
|
|
252
|
+
let editor = moduleEditor(filePath);
|
|
253
|
+
return editor && { editor, filePath };
|
|
317
254
|
}
|
|
318
|
-
|
|
255
|
+
var isComponent = (filePath, exportName) => filePath.endsWith(".svelte") && exportName === "default", exportReader = {
|
|
256
|
+
resolver: moduleResolver,
|
|
257
|
+
readModule,
|
|
258
|
+
ownsExport: isComponent
|
|
259
|
+
}, resolveComponentExpression = createComponentNodeResolver({ reader: exportReader }), unresolved = (specifier, exportName) => new Error(`Could not resolve \`${specifier}\` export \`${exportName}\``);
|
|
260
|
+
async function readStoryFile(entry) {
|
|
319
261
|
let importPath = getStoryImportPathFromEntry(entry);
|
|
320
262
|
if (!importPath) return;
|
|
321
263
|
let storyPath = resolve(importPath), file = await readFile(storyPath, "utf8");
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
return
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
);
|
|
345
|
-
let module = ast.module?.content;
|
|
346
|
-
if (!module) return;
|
|
347
|
-
let parsed = /* @__PURE__ */ new Map(), referenced = resolveReferencedValue(
|
|
348
|
-
{
|
|
349
|
-
editor: new SourceEditor(source.slice(module.start, module.end), `${storyPath}.ts`),
|
|
350
|
-
filePath: storyPath,
|
|
351
|
-
resolveModule: (fromFile, specifier2) => {
|
|
352
|
-
let target = resolveImport(fromFile, specifier2);
|
|
353
|
-
if (target) {
|
|
354
|
-
if (!parsed.has(target)) {
|
|
355
|
-
let editor = moduleEditor(target);
|
|
356
|
-
parsed.set(target, editor && { editor, filePath: target });
|
|
357
|
-
}
|
|
358
|
-
return parsed.get(target);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
},
|
|
362
|
-
component
|
|
363
|
-
);
|
|
364
|
-
if (!referenced) return;
|
|
365
|
-
let value = unwrapExpression(referenced.node);
|
|
366
|
-
if (value.type !== "Identifier") return;
|
|
367
|
-
let binding = collectImportBindings(referenced.ctx.editor.program).get(value.name);
|
|
368
|
-
return binding ? locate(
|
|
369
|
-
referenced.ctx.filePath,
|
|
370
|
-
binding.importId,
|
|
371
|
-
binding.importName,
|
|
372
|
-
component.property.name
|
|
373
|
-
) : void 0;
|
|
264
|
+
return storyPath.endsWith(".svelte") ? { storyPath, ...await readSvelteMeta(file, storyPath) } : { storyPath, csf: loadCsf(file, { makeTitle: () => entry.title }).parse() };
|
|
265
|
+
}
|
|
266
|
+
function resolveComponentNode(story, node) {
|
|
267
|
+
let { module, meta } = "csf" in story ? {
|
|
268
|
+
module: { editor: story.csf.editor, filePath: story.storyPath },
|
|
269
|
+
meta: story.csf._metaAnnotations.component
|
|
270
|
+
} : { module: story.module, meta: propertyValue(story.meta, "component") }, expression = node ?? meta;
|
|
271
|
+
if (!expression) return;
|
|
272
|
+
let resolved = resolveComponentExpression(module, expression);
|
|
273
|
+
if ("reason" in resolved)
|
|
274
|
+
switch (resolved.reason) {
|
|
275
|
+
case "unreadable-component-expression":
|
|
276
|
+
throw new Error(`Cannot resolve the component \`${resolved.expression}\``);
|
|
277
|
+
case "missing-export":
|
|
278
|
+
throw unresolved(resolved.importId, resolved.exportName);
|
|
279
|
+
case "no-meta-component":
|
|
280
|
+
case "no-component-import":
|
|
281
|
+
return;
|
|
282
|
+
default: {
|
|
283
|
+
let unhandled = resolved;
|
|
284
|
+
throw new Error(`Unhandled resolution ${JSON.stringify(unhandled)}`);
|
|
285
|
+
}
|
|
374
286
|
}
|
|
375
|
-
|
|
287
|
+
let { importId, path, exportName, localName } = resolved.component;
|
|
288
|
+
if (importId) {
|
|
289
|
+
if (!path || !isComponent(path, exportName)) throw unresolved(importId, exportName);
|
|
290
|
+
return { componentPath: path, exportName, name: localName };
|
|
376
291
|
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
);
|
|
381
|
-
if ("reason" in resolved) {
|
|
382
|
-
if (resolved.reason === "unreadable-component-expression")
|
|
383
|
-
throw new Error(`Cannot resolve the component \`${resolved.expression}\``);
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
|
-
let { importId, exportName, localName } = resolved.component;
|
|
387
|
-
return importId ? locate(storyPath, importId, exportName, localName) : void 0;
|
|
292
|
+
}
|
|
293
|
+
async function resolveStoryComponent(entry) {
|
|
294
|
+
let story = await readStoryFile(entry);
|
|
295
|
+
return story && resolveComponentNode(story);
|
|
388
296
|
}
|
|
389
297
|
async function resolveStorySubcomponents(entry) {
|
|
390
|
-
let
|
|
391
|
-
if (!
|
|
392
|
-
let
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
}
|
|
298
|
+
let story = await readStoryFile(entry);
|
|
299
|
+
if (!story) return {};
|
|
300
|
+
let declared = "csf" in story ? extractDeclaredSubcomponents(story.csf) : extractSubcomponents(
|
|
301
|
+
propertyValue(story.meta, "subcomponents"),
|
|
302
|
+
story.module.editor.program
|
|
303
|
+
), resolved = {};
|
|
304
|
+
for (let { name, node } of declared)
|
|
305
|
+
try {
|
|
306
|
+
let component = resolveComponentNode(story, node);
|
|
307
|
+
component && (resolved[name] = { ...component, name });
|
|
308
|
+
} catch {
|
|
309
|
+
continue;
|
|
310
|
+
}
|
|
404
311
|
return resolved;
|
|
405
312
|
}
|
|
406
|
-
function readCsfMeta(source, entry) {
|
|
407
|
-
let csf = loadCsf(source, { makeTitle: () => entry.title }).parse();
|
|
408
|
-
return { meta: metaObject(csf), program: csf.program };
|
|
409
|
-
}
|
|
410
313
|
async function readSvelteMeta(file, storyPath) {
|
|
411
314
|
let { source, ast } = parseSvelteSource(file), nodes = await extractSvelteASTNodes({ ast, filename: storyPath }), { start, end } = getDefineMetaFirstArgumentObjectExpression({
|
|
412
315
|
nodes,
|
|
413
316
|
filename: storyPath
|
|
414
|
-
}),
|
|
317
|
+
}), script = ast.module.content, meta = parseExpression(source.slice(start, end));
|
|
415
318
|
return {
|
|
416
319
|
meta: meta.type === "ObjectExpression" ? meta : void 0,
|
|
417
|
-
|
|
320
|
+
module: {
|
|
321
|
+
editor: new SourceEditor(source.slice(script.start, script.end), `${storyPath}.ts`),
|
|
322
|
+
filePath: storyPath
|
|
323
|
+
}
|
|
418
324
|
};
|
|
419
325
|
}
|
|
420
326
|
|
|
421
327
|
// src/docgen/component-docgen/build-docgen.ts
|
|
422
|
-
function pathFromStory(storyPath, componentPath) {
|
|
423
|
-
let fromStory = relative(dirname(realpathSync(resolve2(storyPath))), componentPath), path = join(dirname(storyPath), fromStory).replaceAll("\\", "/");
|
|
424
|
-
return isAbsolute(path) || path.startsWith("../") ? path : `./${path}`;
|
|
425
|
-
}
|
|
426
328
|
async function buildDocgenPayload(input, context) {
|
|
427
329
|
let path = getStoryImportPathFromEntry2(input.entry);
|
|
428
330
|
if (!path) return;
|
|
@@ -443,7 +345,7 @@ async function buildDocgenPayload(input, context) {
|
|
|
443
345
|
try {
|
|
444
346
|
subcomponents[name] = {
|
|
445
347
|
name,
|
|
446
|
-
path:
|
|
348
|
+
path: componentPathFromStory(path, resolve2(path), subcomponent.componentPath),
|
|
447
349
|
...await componentDocs(subcomponent.componentPath, name, context)
|
|
448
350
|
};
|
|
449
351
|
} catch {
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_ozn9e8tgwi from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_ozn9e8tgwi from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_ozn9e8tgwi from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_ozn9e8tgwi.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_ozn9e8tgwi.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_ozn9e8tgwi.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
1
|
import {
|
|
13
2
|
ArrayElementNotStringError,
|
|
14
3
|
DefaultOrNamespaceImportUsedError,
|
|
@@ -32,7 +21,7 @@ import {
|
|
|
32
21
|
getStoryIdentifiers,
|
|
33
22
|
getStoryParents,
|
|
34
23
|
hasMetaImport
|
|
35
|
-
} from "./chunk-
|
|
24
|
+
} from "./chunk-FZFWZSUN.js";
|
|
36
25
|
|
|
37
26
|
// src/svelte-csf/indexer/parser.ts
|
|
38
27
|
import fs from "node:fs/promises";
|
|
@@ -94,7 +83,7 @@ function getIndexableAST(code) {
|
|
|
94
83
|
async function parseForIndexer(filename) {
|
|
95
84
|
let [file, { walk }] = await Promise.all([
|
|
96
85
|
fs.readFile(filename, { encoding: "utf8" }),
|
|
97
|
-
import("./walk-
|
|
86
|
+
import("./walk-TKX2QFK2.js")
|
|
98
87
|
]), { ast: svelteAST } = parseSvelteSource(file), results = {
|
|
99
88
|
meta: {},
|
|
100
89
|
stories: [],
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_ozn9e8tgwi from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_ozn9e8tgwi from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_ozn9e8tgwi from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_ozn9e8tgwi.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_ozn9e8tgwi.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_ozn9e8tgwi.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
|
-
|
|
13
1
|
// src/docgen/component-docgen/svelte2tsx/generate-docgen.ts
|
|
14
2
|
import path from "node:path";
|
|
15
3
|
import { fileURLToPath } from "node:url";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// src/docgen/story-file.ts
|
|
2
|
+
import { STORY_FILE_TEST_REGEXP } from "storybook/internal/common";
|
|
3
|
+
var SVELTE_STORY_FILE_TEST_REGEXP = /\.stories\.svelte$/, SVELTE_DOCGEN_STORY_FILE_TEST_REGEXP = new RegExp(
|
|
4
|
+
`${SVELTE_STORY_FILE_TEST_REGEXP.source}|${STORY_FILE_TEST_REGEXP.source}`
|
|
5
|
+
);
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
SVELTE_DOCGEN_STORY_FILE_TEST_REGEXP
|
|
9
|
+
};
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_ozn9e8tgwi from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_ozn9e8tgwi from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_ozn9e8tgwi from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_ozn9e8tgwi.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_ozn9e8tgwi.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_ozn9e8tgwi.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
|
-
|
|
13
1
|
// ../../../node_modules/zimmerframe/src/walk.js
|
|
14
2
|
function walk(node, state, visitors) {
|
|
15
3
|
let universal = visitors._, stopped = !1;
|
|
@@ -1,25 +1,13 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_ozn9e8tgwi from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_ozn9e8tgwi from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_ozn9e8tgwi from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_ozn9e8tgwi.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_ozn9e8tgwi.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_ozn9e8tgwi.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
1
|
import {
|
|
13
|
-
extractDefineMetaPropertiesNodes
|
|
14
|
-
|
|
15
|
-
getDefineMetaComponentValue
|
|
16
|
-
} from "./chunk-BUMY5Y7X.js";
|
|
2
|
+
extractDefineMetaPropertiesNodes
|
|
3
|
+
} from "./chunk-XLMS4YUB.js";
|
|
17
4
|
import {
|
|
5
|
+
InvalidComponentValueError,
|
|
18
6
|
InvalidRenderValueError,
|
|
19
7
|
InvalidStoryTemplateAttributeError,
|
|
20
8
|
extractStoryAttributesNodes,
|
|
21
9
|
extractStoryTemplateSnippetBlock
|
|
22
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-FZFWZSUN.js";
|
|
23
11
|
|
|
24
12
|
// src/svelte-csf/parser/ast.ts
|
|
25
13
|
import { compile } from "svelte/compiler";
|
|
@@ -139,6 +127,37 @@ function findSnippetBlockByName(options) {
|
|
|
139
127
|
|
|
140
128
|
// src/svelte-csf/parser/analyse/story/content.ts
|
|
141
129
|
import { dedent } from "ts-dedent";
|
|
130
|
+
|
|
131
|
+
// src/svelte-csf/parser/analyse/define-meta/component-identifier.ts
|
|
132
|
+
import { unwrapExpression as unwrapExpression3 } from "storybook/internal/csf-tools";
|
|
133
|
+
function getDefineMetaComponentValue(params) {
|
|
134
|
+
let { nodes, filename } = params, { component } = extractDefineMetaPropertiesNodes({
|
|
135
|
+
nodes,
|
|
136
|
+
properties: ["component"],
|
|
137
|
+
filename
|
|
138
|
+
});
|
|
139
|
+
if (!component)
|
|
140
|
+
return;
|
|
141
|
+
let value = withoutTypeArguments(unwrapExpression3(component.value));
|
|
142
|
+
if (!isValidComponentValue(value))
|
|
143
|
+
throw new InvalidComponentValueError({
|
|
144
|
+
filename,
|
|
145
|
+
componentProperty: component
|
|
146
|
+
});
|
|
147
|
+
return value;
|
|
148
|
+
}
|
|
149
|
+
function withoutTypeArguments(value) {
|
|
150
|
+
let node = value;
|
|
151
|
+
return node.type === "TSInstantiationExpression" ? unwrapExpression3(node.expression) : value;
|
|
152
|
+
}
|
|
153
|
+
function isValidComponentValue(value) {
|
|
154
|
+
return value.type === "Identifier" ? !0 : value.type === "MemberExpression" && !value.computed && value.object.type === "Identifier" && value.property.type === "Identifier";
|
|
155
|
+
}
|
|
156
|
+
function getDefineMetaComponentName(value) {
|
|
157
|
+
return value ? value.type === "MemberExpression" ? `${value.object.name}.${value.property.name}` : value.name : "undefined";
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// src/svelte-csf/parser/analyse/story/content.ts
|
|
142
161
|
function getStoryContentRawCode(params) {
|
|
143
162
|
let { nodes, originalCode, filename } = params, { component, svelte } = nodes;
|
|
144
163
|
if (component.fragment.nodes.length === 0) {
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_ozn9e8tgwi from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_ozn9e8tgwi from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_ozn9e8tgwi from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_ozn9e8tgwi.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_ozn9e8tgwi.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_ozn9e8tgwi.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
|
-
|
|
13
1
|
// src/svelte-csf/constants.ts
|
|
14
2
|
var SVELTE_CSF_TAG_PREFIX = "svelte-csf", SVELTE_CSF_V5_TAG = `${SVELTE_CSF_TAG_PREFIX}-v5`, STORYBOOK_INTERNAL_PREFIX = "$__", STORYBOOK_META_IDENTIFIER = `${STORYBOOK_INTERNAL_PREFIX}meta`, RUNTIME_STORIES_IDENTIFIER = `${STORYBOOK_INTERNAL_PREFIX}stories`, SVELTE_CSF_FRAMEWORK_IMPORT_SOURCES = [
|
|
15
3
|
"@storybook/svelte-vite",
|
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_ozn9e8tgwi from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_ozn9e8tgwi from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_ozn9e8tgwi from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_ozn9e8tgwi.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_ozn9e8tgwi.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_ozn9e8tgwi.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
1
|
import {
|
|
13
2
|
DefaultOrNamespaceImportUsedError,
|
|
14
3
|
GetDefineMetaFirstArgumentError,
|
|
15
|
-
InvalidComponentValueError,
|
|
16
4
|
MissingDefineMetaImportError,
|
|
17
5
|
MissingDefineMetaVariableDeclarationError,
|
|
18
6
|
MissingModuleTagError,
|
|
@@ -22,7 +10,7 @@ import {
|
|
|
22
10
|
hasMetaImport,
|
|
23
11
|
isOneOf,
|
|
24
12
|
skipTypeCalls
|
|
25
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-FZFWZSUN.js";
|
|
26
14
|
|
|
27
15
|
// src/svelte-csf/parser/extract/svelte/module-nodes.ts
|
|
28
16
|
async function extractModuleNodes(options) {
|
|
@@ -49,7 +37,7 @@ async function extractModuleNodes(options) {
|
|
|
49
37
|
|
|
50
38
|
// src/svelte-csf/parser/extract/svelte/fragment-nodes.ts
|
|
51
39
|
async function extractFragmentNodes(params) {
|
|
52
|
-
let { walk } = await import("./walk-
|
|
40
|
+
let { walk } = await import("./walk-TKX2QFK2.js"), { fragment, moduleNodes } = params, { storyNames } = moduleNodes, latestComment, state = {
|
|
53
41
|
storyComponents: [],
|
|
54
42
|
snippetBlocks: []
|
|
55
43
|
};
|
|
@@ -97,39 +85,8 @@ function getDefineMetaFirstArgumentObjectExpression(options) {
|
|
|
97
85
|
throw new GetDefineMetaFirstArgumentError(filename);
|
|
98
86
|
}
|
|
99
87
|
|
|
100
|
-
// src/svelte-csf/parser/analyse/define-meta/component-identifier.ts
|
|
101
|
-
import { unwrapExpression as unwrapExpression2 } from "storybook/internal/csf-tools";
|
|
102
|
-
function getDefineMetaComponentValue(params) {
|
|
103
|
-
let { nodes, filename } = params, { component } = extractDefineMetaPropertiesNodes({
|
|
104
|
-
nodes,
|
|
105
|
-
properties: ["component"],
|
|
106
|
-
filename
|
|
107
|
-
});
|
|
108
|
-
if (!component)
|
|
109
|
-
return;
|
|
110
|
-
let value = withoutTypeArguments(unwrapExpression2(component.value));
|
|
111
|
-
if (!isValidComponentValue(value))
|
|
112
|
-
throw new InvalidComponentValueError({
|
|
113
|
-
filename,
|
|
114
|
-
componentProperty: component
|
|
115
|
-
});
|
|
116
|
-
return value;
|
|
117
|
-
}
|
|
118
|
-
function withoutTypeArguments(value) {
|
|
119
|
-
let node = value;
|
|
120
|
-
return node.type === "TSInstantiationExpression" ? unwrapExpression2(node.expression) : value;
|
|
121
|
-
}
|
|
122
|
-
function isValidComponentValue(value) {
|
|
123
|
-
return value.type === "Identifier" ? !0 : value.type === "MemberExpression" && !value.computed && value.object.type === "Identifier" && value.property.type === "Identifier";
|
|
124
|
-
}
|
|
125
|
-
function getDefineMetaComponentName(value) {
|
|
126
|
-
return value ? value.type === "MemberExpression" ? `${value.object.name}.${value.property.name}` : value.name : "undefined";
|
|
127
|
-
}
|
|
128
|
-
|
|
129
88
|
export {
|
|
130
89
|
extractDefineMetaPropertiesNodes,
|
|
131
90
|
getDefineMetaFirstArgumentObjectExpression,
|
|
132
|
-
getDefineMetaComponentValue,
|
|
133
|
-
getDefineMetaComponentName,
|
|
134
91
|
extractSvelteASTNodes
|
|
135
92
|
};
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_ozn9e8tgwi from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_ozn9e8tgwi from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_ozn9e8tgwi from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_ozn9e8tgwi.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_ozn9e8tgwi.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_ozn9e8tgwi.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
|
-
|
|
13
1
|
// src/parsers/svelteImportParser.ts
|
|
14
2
|
import {
|
|
15
3
|
ChangeDetectionFailureError
|
package/dist/_node-chunks/{svelte-project-manager-OOWETREX.js → svelte-project-manager-Q35NEAHT.js}
RENAMED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_ozn9e8tgwi from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_ozn9e8tgwi from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_ozn9e8tgwi from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_ozn9e8tgwi.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_ozn9e8tgwi.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_ozn9e8tgwi.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
1
|
import {
|
|
13
2
|
assertCompilerApi,
|
|
14
3
|
createDocgenCache,
|
|
@@ -17,7 +6,7 @@ import {
|
|
|
17
6
|
inferredCommandLine,
|
|
18
7
|
parseSvelteConfig,
|
|
19
8
|
virtualFileName
|
|
20
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-3JLJMGBT.js";
|
|
21
10
|
|
|
22
11
|
// src/docgen/component-docgen/component-meta/svelte-project-manager.ts
|
|
23
12
|
import { statSync } from "node:fs";
|
|
@@ -67,11 +67,16 @@ type StoriesExtractorContext<TCmp extends Cmp> = Readonly<StoriesExtractorContex
|
|
|
67
67
|
type StoriesRepository<TCmp extends Cmp> = {
|
|
68
68
|
stories: Map<string, RegisteredStoryProps<TCmp>>;
|
|
69
69
|
};
|
|
70
|
+
type ArgSources = Record<string, {
|
|
71
|
+
exportName: string;
|
|
72
|
+
value: unknown;
|
|
73
|
+
}>;
|
|
70
74
|
interface StoryRendererContextProps<TCmp extends Cmp> {
|
|
71
75
|
contentExportName: string | undefined;
|
|
72
76
|
playExportName: string | undefined;
|
|
73
77
|
asChildExportName: string | undefined;
|
|
74
78
|
asChild: boolean;
|
|
79
|
+
argSources: ArgSources;
|
|
75
80
|
args: NonNullable<StoryAnnotations$1<Record<string, any>, TCmp>['args']>;
|
|
76
81
|
storyContext: StoryContext$1<Record<string, any>>;
|
|
77
82
|
metaRenderSnippet?: Snippet<[StoryAnnotations$1<Record<string, any>, TCmp>['args'], StoryContext$1<Record<string, any>>]>;
|
|
@@ -250,4 +255,4 @@ type Loader<TArgs = StrictArgs> = LoaderFunction<SvelteRenderer, TArgs>;
|
|
|
250
255
|
type StoryContext$1<TArgs = StrictArgs> = StoryContext<SvelteRenderer, TArgs>;
|
|
251
256
|
type Preview$1 = ProjectAnnotations<SvelteRenderer>;
|
|
252
257
|
//#endregion
|
|
253
|
-
export {
|
|
258
|
+
export { StoryComponent as C, SvelteRenderer as D, StoryRendererContextProps as E, SvelteTypes as O, StoriesRepository as S, StoryRendererContext as T, ArgSources as _, Meta$1 as a, StoriesExtractorContext as b, StoryContext$1 as c, StrictArgs$1 as d, SvelteCsfStoryProps as f, __definePreview as g, SvelteStory as h, Loader as i, StoryFn as l, SveltePreview as m, Args$1 as n, Parameters$1 as o, SvelteMeta as p, Decorator as r, Preview$1 as s, ArgTypes as t, StoryObj as u, Cmp as v, StoryProps as w, StoriesExtractorContextProps as x, ComponentAnnotations$1 as y };
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_ozn9e8tgwi from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_ozn9e8tgwi from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_ozn9e8tgwi from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_ozn9e8tgwi.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_ozn9e8tgwi.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_ozn9e8tgwi.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
1
|
import {
|
|
13
2
|
UNPRINTABLE_DEFAULT,
|
|
14
3
|
assertCompilerApi,
|
|
@@ -19,7 +8,7 @@ import {
|
|
|
19
8
|
inferredCommandLine,
|
|
20
9
|
parseSvelteConfig,
|
|
21
10
|
virtualFileName
|
|
22
|
-
} from "../../../_node-chunks/chunk-
|
|
11
|
+
} from "../../../_node-chunks/chunk-3JLJMGBT.js";
|
|
23
12
|
export {
|
|
24
13
|
UNPRINTABLE_DEFAULT,
|
|
25
14
|
assertCompilerApi,
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_ozn9e8tgwi from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_ozn9e8tgwi from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_ozn9e8tgwi from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_ozn9e8tgwi.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_ozn9e8tgwi.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_ozn9e8tgwi.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
1
|
import {
|
|
13
2
|
SVELTE_DOCGEN_STORY_FILE_TEST_REGEXP
|
|
14
|
-
} from "../_node-chunks/chunk-
|
|
3
|
+
} from "../_node-chunks/chunk-4AFBO5RP.js";
|
|
15
4
|
|
|
16
5
|
// src/docgen/docgen-worker.ts
|
|
17
6
|
import { createLazyDocgenMiddleware, loadTypeScriptCompilerApi } from "storybook/internal/common";
|
|
@@ -22,8 +11,8 @@ var createDocgenProvider = () => createLazyDocgenMiddleware({
|
|
|
22
11
|
try {
|
|
23
12
|
await loadTypeScriptCompilerApi(() => import("typescript"));
|
|
24
13
|
let [{ SvelteComponentMetaManager }, { buildDocgenPayload }] = await Promise.all([
|
|
25
|
-
import("../_node-chunks/svelte-project-manager-
|
|
26
|
-
import("../_node-chunks/build-docgen-
|
|
14
|
+
import("../_node-chunks/svelte-project-manager-Q35NEAHT.js"),
|
|
15
|
+
import("../_node-chunks/build-docgen-4CLD5RKH.js")
|
|
27
16
|
]), componentMetaManager = new SvelteComponentMetaManager();
|
|
28
17
|
return componentMetaManager.startWatching(), { componentMetaManager, buildDocgenPayload };
|
|
29
18
|
} catch (error) {
|
package/dist/entry-preview.js
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as StoryComponent, D as SvelteRenderer, O as SvelteTypes, a as Meta, c as StoryContext, d as StrictArgs, f as SvelteCsfStoryProps, g as __definePreview, h as SvelteStory, i as Loader, l as StoryFn, m as SveltePreview, n as Args, o as Parameters, p as SvelteMeta, r as Decorator, s as Preview, t as ArgTypes, u as StoryObj, v as Cmp, y as ComponentAnnotations$1 } from "./chunk-CoCY0Re5.js";
|
|
2
2
|
import { Args as Args$1, ComposedStoryFn, NamedOrDefaultProjectAnnotations, NormalizedProjectAnnotations, ProjectAnnotations, Store_CSFExports, StoriesWithPartialProps, StoryAnnotationsOrFn } from "storybook/internal/types";
|
|
3
3
|
import { ComponentProps, Snippet } from "svelte";
|
|
4
4
|
import PreviewRender from "@storybook/svelte/internal/PreviewRender.svelte";
|
package/dist/index.js
CHANGED
package/dist/preset.js
CHANGED
|
@@ -1,30 +1,19 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_ozn9e8tgwi from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_ozn9e8tgwi from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_ozn9e8tgwi from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_ozn9e8tgwi.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_ozn9e8tgwi.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_ozn9e8tgwi.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
1
|
import {
|
|
13
2
|
SVELTE_DOCGEN_STORY_FILE_TEST_REGEXP
|
|
14
|
-
} from "./_node-chunks/chunk-
|
|
3
|
+
} from "./_node-chunks/chunk-4AFBO5RP.js";
|
|
15
4
|
import {
|
|
16
5
|
parseSvelteSource
|
|
17
|
-
} from "./_node-chunks/chunk-
|
|
6
|
+
} from "./_node-chunks/chunk-2Z47YIHP.js";
|
|
18
7
|
import {
|
|
19
8
|
findMetaRenderSnippetBlock,
|
|
20
9
|
findStoryAttributeTemplateSnippetBlock,
|
|
21
10
|
getStoryContentRawCode,
|
|
22
11
|
span
|
|
23
|
-
} from "./_node-chunks/chunk-
|
|
12
|
+
} from "./_node-chunks/chunk-EZI5LVNW.js";
|
|
24
13
|
import {
|
|
25
14
|
extractSvelteASTNodes,
|
|
26
15
|
getDefineMetaFirstArgumentObjectExpression
|
|
27
|
-
} from "./_node-chunks/chunk-
|
|
16
|
+
} from "./_node-chunks/chunk-XLMS4YUB.js";
|
|
28
17
|
import {
|
|
29
18
|
extractStoryAttributesNodes,
|
|
30
19
|
extractStoryTemplateSnippetBlock,
|
|
@@ -32,10 +21,10 @@ import {
|
|
|
32
21
|
getStoryChain,
|
|
33
22
|
getStoryContent,
|
|
34
23
|
getStoryParents
|
|
35
|
-
} from "./_node-chunks/chunk-
|
|
24
|
+
} from "./_node-chunks/chunk-FZFWZSUN.js";
|
|
36
25
|
import {
|
|
37
26
|
walk
|
|
38
|
-
} from "./_node-chunks/chunk-
|
|
27
|
+
} from "./_node-chunks/chunk-4QUF46RV.js";
|
|
39
28
|
|
|
40
29
|
// src/preset.ts
|
|
41
30
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
@@ -908,7 +897,7 @@ var isDocgenProviderEnabled = (_existing, options) => isTypeScriptReadyForDocgen
|
|
|
908
897
|
docsEnabled ? [fileURLToPath3(import.meta.resolve("@storybook/svelte/entry-preview-docs"))] : []
|
|
909
898
|
);
|
|
910
899
|
}, experimental_importParsers = async (input = []) => {
|
|
911
|
-
let { svelteImportParser } = await import("./_node-chunks/parsers-
|
|
900
|
+
let { svelteImportParser } = await import("./_node-chunks/parsers-ENYE653E.js");
|
|
912
901
|
return [...input, svelteImportParser];
|
|
913
902
|
}, experimental_indexers = async (existingIndexers) => {
|
|
914
903
|
let { createIndexer } = await import("./svelte-csf/indexer/index.js");
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_ozn9e8tgwi from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_ozn9e8tgwi from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_ozn9e8tgwi from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_ozn9e8tgwi.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_ozn9e8tgwi.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_ozn9e8tgwi.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
|
-
|
|
13
1
|
// src/svelte-csf/addon-check.ts
|
|
14
2
|
import { normalizeAddonName } from "storybook/internal/common";
|
|
15
3
|
|
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_ozn9e8tgwi from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_ozn9e8tgwi from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_ozn9e8tgwi from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_ozn9e8tgwi.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_ozn9e8tgwi.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_ozn9e8tgwi.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
1
|
import {
|
|
13
2
|
appendASTProperty,
|
|
14
3
|
createASTArrayExpression,
|
|
@@ -19,11 +8,11 @@ import {
|
|
|
19
8
|
getStoryContentRawCode,
|
|
20
9
|
getSvelteAST,
|
|
21
10
|
span
|
|
22
|
-
} from "../../_node-chunks/chunk-
|
|
11
|
+
} from "../../_node-chunks/chunk-EZI5LVNW.js";
|
|
23
12
|
import {
|
|
24
13
|
extractSvelteASTNodes,
|
|
25
14
|
getDefineMetaFirstArgumentObjectExpression
|
|
26
|
-
} from "../../_node-chunks/chunk-
|
|
15
|
+
} from "../../_node-chunks/chunk-XLMS4YUB.js";
|
|
27
16
|
import {
|
|
28
17
|
DefaultOrNamespaceImportUsedError,
|
|
29
18
|
NoDestructuredDefineMetaCallError,
|
|
@@ -41,7 +30,7 @@ import {
|
|
|
41
30
|
getStoryParents,
|
|
42
31
|
hasMetaImport,
|
|
43
32
|
orderByParents
|
|
44
|
-
} from "../../_node-chunks/chunk-
|
|
33
|
+
} from "../../_node-chunks/chunk-FZFWZSUN.js";
|
|
45
34
|
|
|
46
35
|
// src/svelte-csf/compiler/transform.ts
|
|
47
36
|
import fs from "node:fs";
|
|
@@ -62,7 +51,7 @@ function encodeInteger(builder, num) {
|
|
|
62
51
|
function encodeSign(num) {
|
|
63
52
|
return num < 0 ? -num << 1 | 1 : num << 1;
|
|
64
53
|
}
|
|
65
|
-
var bufLength = 1024 * 16, td = typeof TextDecoder < "u" ? new TextDecoder() : typeof Buffer < "u" ? {
|
|
54
|
+
var bufLength = 1024 * 16, td = typeof TextDecoder < "u" ? /* @__PURE__ */ new TextDecoder() : typeof Buffer < "u" ? {
|
|
66
55
|
decode(buf) {
|
|
67
56
|
return Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength).toString();
|
|
68
57
|
}
|
|
@@ -212,7 +201,7 @@ function getBtoa() {
|
|
|
212
201
|
throw new MagicStringError("unsupported environment: `btoa` or `Buffer` is required");
|
|
213
202
|
};
|
|
214
203
|
}
|
|
215
|
-
var btoa = getBtoa(), SourceMap = class {
|
|
204
|
+
var btoa = /* @__PURE__ */ getBtoa(), SourceMap = class {
|
|
216
205
|
constructor(properties) {
|
|
217
206
|
if (this.version = 3, this.file = properties.file, this.sources = properties.sources, this.sourcesContent = properties.sourcesContent, this.names = properties.names, this.mappings = typeof properties.mappings == "string" ? properties.mappings : encode(properties.mappings), typeof properties.x_google_ignoreList < "u" && (this.x_google_ignoreList = properties.x_google_ignoreList), typeof properties.debugId < "u" && (this.debugId = properties.debugId), typeof properties.rangeMappings < "u") {
|
|
218
207
|
let shouldOutputRangeMapping = !1;
|
|
@@ -280,11 +269,11 @@ var toString = Object.prototype.toString;
|
|
|
280
269
|
function isObject(thing) {
|
|
281
270
|
return toString.call(thing) === "[object Object]";
|
|
282
271
|
}
|
|
283
|
-
var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", intToChar2 = (() => {
|
|
284
|
-
let chars2 = new Uint8Array(64);
|
|
272
|
+
var BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", intToChar2 = /* @__PURE__ */ (() => {
|
|
273
|
+
let chars2 = /* @__PURE__ */ new Uint8Array(64);
|
|
285
274
|
for (let i = 0; i < 64; i++) chars2[i] = BASE64_CHARS.charCodeAt(i);
|
|
286
275
|
return chars2;
|
|
287
|
-
})(), COMMA = 44, SEMICOLON = 59, BUFFER_SIZE = 16384, FLUSH_THRESHOLD = 16348, scratch = new Uint8Array(BUFFER_SIZE);
|
|
276
|
+
})(), COMMA = 44, SEMICOLON = 59, BUFFER_SIZE = 16384, FLUSH_THRESHOLD = 16348, scratch = /* @__PURE__ */ new Uint8Array(BUFFER_SIZE);
|
|
288
277
|
function writeVlq(pos, num) {
|
|
289
278
|
num = num < 0 ? -num << 1 | 1 : num << 1;
|
|
290
279
|
do {
|
|
@@ -293,7 +282,7 @@ function writeVlq(pos, num) {
|
|
|
293
282
|
} while (num > 0);
|
|
294
283
|
return pos;
|
|
295
284
|
}
|
|
296
|
-
var decoder = new TextDecoder(), MappingsEncoder = class {
|
|
285
|
+
var decoder = /* @__PURE__ */ new TextDecoder(), MappingsEncoder = class {
|
|
297
286
|
constructor() {
|
|
298
287
|
this.out = "", this.pos = 0, this.lines = [], this.buffered = 0, this.needsComma = !1, this.prevGenColumn = 0, this.prevSourceIndex = 0, this.prevSourceLine = 0, this.prevSourceColumn = 0, this.prevNameIndex = 0;
|
|
299
288
|
}
|
|
@@ -3257,7 +3246,7 @@ function getStoryTags(params) {
|
|
|
3257
3246
|
|
|
3258
3247
|
// src/svelte-csf/parser/extract/compiled/stories.ts
|
|
3259
3248
|
async function extractStoriesNodesFromExportDefaultFn(params) {
|
|
3260
|
-
let { walk } = await import("../../_node-chunks/walk-
|
|
3249
|
+
let { walk } = await import("../../_node-chunks/walk-TKX2QFK2.js"), { nodes } = params, { storiesFunctionDeclaration, storyNames } = nodes, state = [], visitors = {
|
|
3261
3250
|
CallExpression(node, context) {
|
|
3262
3251
|
let { state: state2 } = context;
|
|
3263
3252
|
node.callee.type === "Identifier" && storyNames.includes(node.callee.name) ? state2.push(node) : context.next();
|
|
@@ -3302,7 +3291,7 @@ async function transformStoriesCode(params) {
|
|
|
3302
3291
|
|
|
3303
3292
|
// src/svelte-csf/parser/extract/compiled/nodes.ts
|
|
3304
3293
|
async function extractCompiledASTNodes(params) {
|
|
3305
|
-
let { ast, filename } = params, { walk } = await import("../../_node-chunks/walk-
|
|
3294
|
+
let { ast, filename } = params, { walk } = await import("../../_node-chunks/walk-TKX2QFK2.js"), state = { potentialStoriesFunctionDeclaration: [] }, { body } = ast, imports = findMetaImports(body), meta = findMeta(body, imports, filename);
|
|
3306
3295
|
walk(ast, state, {
|
|
3307
3296
|
FunctionDeclaration(node, { state: state2 }) {
|
|
3308
3297
|
state2.potentialStoriesFunctionDeclaration.push(node);
|
|
@@ -1,22 +1,11 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_ozn9e8tgwi from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_ozn9e8tgwi from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_ozn9e8tgwi from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_ozn9e8tgwi.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_ozn9e8tgwi.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_ozn9e8tgwi.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
1
|
import {
|
|
13
2
|
parseForIndexer
|
|
14
|
-
} from "../../_node-chunks/chunk-
|
|
3
|
+
} from "../../_node-chunks/chunk-2Z47YIHP.js";
|
|
15
4
|
import {
|
|
16
5
|
IndexerParseError,
|
|
17
6
|
SVELTE_CSF_V5_TAG,
|
|
18
7
|
StorybookSvelteCSFError
|
|
19
|
-
} from "../../_node-chunks/chunk-
|
|
8
|
+
} from "../../_node-chunks/chunk-FZFWZSUN.js";
|
|
20
9
|
|
|
21
10
|
// src/svelte-csf/indexer/index.ts
|
|
22
11
|
var createIndexer = () => ({
|
|
@@ -1,13 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { E as StoryRendererContextProps, S as StoriesRepository, T as StoryRendererContext, _ as ArgSources, b as StoriesExtractorContext, c as StoryContext, v as Cmp, w as StoryProps, x as StoriesExtractorContextProps } from "../../chunk-CoCY0Re5.js";
|
|
2
2
|
|
|
3
3
|
//#region code/renderers/svelte/.dts-emit/code/renderers/svelte/src/svelte-csf/utils/identifier-utils.d.ts
|
|
4
4
|
declare const storyNameToExportName: (name: string) => string;
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region code/renderers/svelte/.dts-emit/code/renderers/svelte/src/svelte-csf/runtime/emit-code.d.ts
|
|
7
|
-
type Params = {
|
|
7
|
+
type Params$1 = {
|
|
8
8
|
args: Record<string, any>;
|
|
9
9
|
storyContext: StoryContext<Record<string, any>>;
|
|
10
10
|
};
|
|
11
|
-
declare const emitCode: (params: Params) => void;
|
|
11
|
+
declare const emitCode: (params: Params$1) => void;
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region code/renderers/svelte/.dts-emit/code/renderers/svelte/src/svelte-csf/runtime/sync-story-args.d.ts
|
|
14
|
+
type Params = {
|
|
15
|
+
exportName: string;
|
|
16
|
+
storyArgs: Record<string, any> | undefined;
|
|
17
|
+
argSources: ArgSources;
|
|
18
|
+
storyId: string;
|
|
19
|
+
};
|
|
20
|
+
declare const syncStoryArgs: ({
|
|
21
|
+
exportName,
|
|
22
|
+
storyArgs,
|
|
23
|
+
argSources,
|
|
24
|
+
storyId
|
|
25
|
+
}: Params) => void;
|
|
12
26
|
//#endregion
|
|
13
|
-
export { type Cmp, type StoriesExtractorContext, type StoriesExtractorContextProps, type StoriesRepository, type StoryContext, type StoryProps, type StoryRendererContext, type StoryRendererContextProps, emitCode, storyNameToExportName };
|
|
27
|
+
export { type ArgSources, type Cmp, type StoriesExtractorContext, type StoriesExtractorContextProps, type StoriesRepository, type StoryContext, type StoryProps, type StoryRendererContext, type StoryRendererContextProps, emitCode, storyNameToExportName, syncStoryArgs };
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
skipSourceRender
|
|
3
3
|
} from "../../_browser-chunks/chunk-D3HHTIN7.js";
|
|
4
|
+
import {
|
|
5
|
+
syncStoryArgs
|
|
6
|
+
} from "../../_browser-chunks/chunk-QOQZ54LJ.js";
|
|
4
7
|
import "../../_browser-chunks/chunk-4BE7D4DS.js";
|
|
5
8
|
|
|
6
9
|
// src/svelte-csf/utils/identifier-utils.ts
|
|
@@ -53,5 +56,6 @@ var channel = addons.getChannel(), emitCode = (params) => {
|
|
|
53
56
|
};
|
|
54
57
|
export {
|
|
55
58
|
emitCode,
|
|
56
|
-
storyNameToExportName
|
|
59
|
+
storyNameToExportName,
|
|
60
|
+
syncStoryArgs
|
|
57
61
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v as Cmp, y as ComponentAnnotations } from "../../chunk-CoCY0Re5.js";
|
|
2
2
|
import { Component } from "svelte";
|
|
3
3
|
|
|
4
4
|
//#region code/renderers/svelte/.dts-emit/code/renderers/svelte/src/svelte-csf/runtime/create-runtime-stories.d.ts
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
snapshotArg
|
|
3
|
+
} from "../../_browser-chunks/chunk-QOQZ54LJ.js";
|
|
1
4
|
import "../../_browser-chunks/chunk-4BE7D4DS.js";
|
|
2
5
|
|
|
3
6
|
// src/svelte-csf/runtime/create-runtime-stories.ts
|
|
@@ -41,7 +44,11 @@ var createFragment = document.createDocumentFragment ? () => document.createDocu
|
|
|
41
44
|
for (let [exportName, story] of repository.stories) {
|
|
42
45
|
let chain = getStoryChain(parents, exportName).map(
|
|
43
46
|
(name) => [name, repository.stories.get(name)]
|
|
44
|
-
), [contentExportName] = chain.find(([, { children, template }]) => children || template) ?? chain[0], [playExportName, playStory] = chain.find(([, { play: play2 }]) => play2) ?? [], [asChildExportName, asChildStory] = chain.find(([, story2]) => story2.asChild !== void 0) ?? [],
|
|
47
|
+
), [contentExportName] = chain.find(([, { children, template }]) => children || template) ?? chain[0], [playExportName, playStory] = chain.find(([, { play: play2 }]) => play2) ?? [], [asChildExportName, asChildStory] = chain.find(([, story2]) => story2.asChild !== void 0) ?? [], argSources = {};
|
|
48
|
+
for (let [name, { args }] of [...chain].reverse())
|
|
49
|
+
for (let [key, value] of Object.entries(args ?? {}))
|
|
50
|
+
argSources[key] = { exportName: name, value: snapshotArg(value) };
|
|
51
|
+
let { template: _template, asChild: _asChild, extend: _extend, ...annotations } = story, storyObj = {
|
|
45
52
|
...annotations,
|
|
46
53
|
render: (args, storyContext) => ({
|
|
47
54
|
Component: StoryRenderer,
|
|
@@ -50,6 +57,7 @@ var createFragment = document.createDocumentFragment ? () => document.createDocu
|
|
|
50
57
|
playExportName,
|
|
51
58
|
asChildExportName,
|
|
52
59
|
asChild: asChildStory?.asChild ?? !1,
|
|
60
|
+
argSources,
|
|
53
61
|
Stories,
|
|
54
62
|
storyContext,
|
|
55
63
|
args,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storybook/svelte",
|
|
3
|
-
"version": "11.0.0-beta.
|
|
3
|
+
"version": "11.0.0-beta.4",
|
|
4
4
|
"description": "Storybook Svelte renderer: Develop, document, and test UI components in isolation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"storybook",
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"zimmerframe": "^1.1.2"
|
|
106
106
|
},
|
|
107
107
|
"peerDependencies": {
|
|
108
|
-
"storybook": "^11.0.0-beta.
|
|
108
|
+
"storybook": "^11.0.0-beta.4",
|
|
109
109
|
"svelte": "^5.0.0",
|
|
110
110
|
"typescript": "^5.9.0 || ^6.0.0 || ^7.0.0"
|
|
111
111
|
},
|
|
@@ -7,7 +7,10 @@
|
|
|
7
7
|
import { useStoriesExtractor } from '@storybook/svelte/internal/svelte-csf/contexts/extractor';
|
|
8
8
|
import { useStoryRenderer } from '@storybook/svelte/internal/svelte-csf/contexts/renderer';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
storyNameToExportName,
|
|
12
|
+
syncStoryArgs,
|
|
13
|
+
} from '@storybook/svelte/internal/svelte-csf/component-helpers';
|
|
11
14
|
import type { Cmp, StoryProps } from '@storybook/svelte/internal/svelte-csf/component-helpers';
|
|
12
15
|
|
|
13
16
|
type Props = StoryProps<TArgs, TCmp, TChildren> & { extend?: string };
|
|
@@ -61,6 +64,19 @@
|
|
|
61
64
|
return typeof value === 'function';
|
|
62
65
|
}
|
|
63
66
|
|
|
67
|
+
// Svelte re-evaluates the `args` prop when the state it reads changes, after the stories were
|
|
68
|
+
// extracted. Send those changes to Storybook, so that the story renders them.
|
|
69
|
+
$effect(() => {
|
|
70
|
+
if (!extractor.isExtracting) {
|
|
71
|
+
syncStoryArgs({
|
|
72
|
+
exportName,
|
|
73
|
+
storyArgs: restProps.args,
|
|
74
|
+
argSources: renderer.argSources,
|
|
75
|
+
storyId: renderer.storyContext.id,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
64
80
|
$effect(() => {
|
|
65
81
|
if (runsPlay) {
|
|
66
82
|
injectIntoPlayFunction(renderer.storyContext, play);
|
|
@@ -4,7 +4,11 @@
|
|
|
4
4
|
import { useStoryRenderer } from '@storybook/svelte/internal/svelte-csf/contexts/renderer';
|
|
5
5
|
import { emitCode } from '@storybook/svelte/internal/svelte-csf/component-helpers';
|
|
6
6
|
|
|
7
|
-
import type {
|
|
7
|
+
import type {
|
|
8
|
+
ArgSources,
|
|
9
|
+
Cmp,
|
|
10
|
+
StoryContext,
|
|
11
|
+
} from '@storybook/svelte/internal/svelte-csf/component-helpers';
|
|
8
12
|
|
|
9
13
|
type Props = {
|
|
10
14
|
Stories: Component;
|
|
@@ -12,6 +16,7 @@
|
|
|
12
16
|
playExportName: string | undefined;
|
|
13
17
|
asChildExportName: string | undefined;
|
|
14
18
|
asChild: boolean;
|
|
19
|
+
argSources: ArgSources;
|
|
15
20
|
args: Record<string, any>;
|
|
16
21
|
storyContext: StoryContext<Record<string, any>>;
|
|
17
22
|
metaRenderSnippet?: Snippet;
|
|
@@ -23,6 +28,7 @@
|
|
|
23
28
|
playExportName,
|
|
24
29
|
asChildExportName,
|
|
25
30
|
asChild,
|
|
31
|
+
argSources,
|
|
26
32
|
args,
|
|
27
33
|
storyContext,
|
|
28
34
|
metaRenderSnippet,
|
|
@@ -36,6 +42,7 @@
|
|
|
36
42
|
playExportName,
|
|
37
43
|
asChildExportName,
|
|
38
44
|
asChild,
|
|
45
|
+
argSources,
|
|
39
46
|
args,
|
|
40
47
|
storyContext,
|
|
41
48
|
metaRenderSnippet,
|
|
@@ -17,6 +17,7 @@ function buildContext(props) {
|
|
|
17
17
|
let playExportName = $state(props.playExportName);
|
|
18
18
|
let asChildExportName = $state(props.asChildExportName);
|
|
19
19
|
let asChild = $state(props.asChild);
|
|
20
|
+
let argSources = $state.raw(props.argSources);
|
|
20
21
|
let args = $state(props.args);
|
|
21
22
|
let storyContext = $state(props.storyContext);
|
|
22
23
|
let metaRenderSnippet = $state(props.metaRenderSnippet);
|
|
@@ -27,6 +28,7 @@ function buildContext(props) {
|
|
|
27
28
|
playExportName = props.playExportName;
|
|
28
29
|
asChildExportName = props.asChildExportName;
|
|
29
30
|
asChild = props.asChild;
|
|
31
|
+
argSources = props.argSources;
|
|
30
32
|
args = props.args;
|
|
31
33
|
storyContext = props.storyContext;
|
|
32
34
|
metaRenderSnippet = props.metaRenderSnippet;
|
|
@@ -51,6 +53,9 @@ function buildContext(props) {
|
|
|
51
53
|
get asChild() {
|
|
52
54
|
return asChild;
|
|
53
55
|
},
|
|
56
|
+
get argSources() {
|
|
57
|
+
return argSources;
|
|
58
|
+
},
|
|
54
59
|
get metaRenderSnippet() {
|
|
55
60
|
return metaRenderSnippet;
|
|
56
61
|
},
|
|
@@ -68,6 +73,7 @@ function createStoryRendererContext() {
|
|
|
68
73
|
playExportName: undefined,
|
|
69
74
|
asChildExportName: undefined,
|
|
70
75
|
asChild: false,
|
|
76
|
+
argSources: {},
|
|
71
77
|
args: {},
|
|
72
78
|
// The renderer sets the real story context before any story reads it
|
|
73
79
|
storyContext: /** @type {StoryContext<Record<string, any>>} */ ({}),
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_ozn9e8tgwi from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_ozn9e8tgwi from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_ozn9e8tgwi from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_ozn9e8tgwi.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_ozn9e8tgwi.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_ozn9e8tgwi.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
|
-
|
|
13
|
-
// src/docgen/story-file.ts
|
|
14
|
-
import { STORY_FILE_TEST_REGEXP } from "storybook/internal/common";
|
|
15
|
-
var SVELTE_STORY_FILE_TEST_REGEXP = /\.stories\.svelte$/, SVELTE_DOCGEN_STORY_FILE_TEST_REGEXP = new RegExp(
|
|
16
|
-
`${SVELTE_STORY_FILE_TEST_REGEXP.source}|${STORY_FILE_TEST_REGEXP.source}`
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
export {
|
|
20
|
-
SVELTE_DOCGEN_STORY_FILE_TEST_REGEXP
|
|
21
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import CJS_COMPAT_NODE_URL_ozn9e8tgwi from 'node:url';
|
|
2
|
-
import CJS_COMPAT_NODE_PATH_ozn9e8tgwi from 'node:path';
|
|
3
|
-
import CJS_COMPAT_NODE_MODULE_ozn9e8tgwi from "node:module";
|
|
4
|
-
|
|
5
|
-
var __filename = CJS_COMPAT_NODE_URL_ozn9e8tgwi.fileURLToPath(import.meta.url);
|
|
6
|
-
var __dirname = CJS_COMPAT_NODE_PATH_ozn9e8tgwi.dirname(__filename);
|
|
7
|
-
var require = CJS_COMPAT_NODE_MODULE_ozn9e8tgwi.createRequire(import.meta.url);
|
|
8
|
-
|
|
9
|
-
// ------------------------------------------------------------
|
|
10
|
-
// end of CJS compatibility banner, injected by Storybook's esbuild configuration
|
|
11
|
-
// ------------------------------------------------------------
|
|
12
|
-
import {
|
|
13
|
-
walk
|
|
14
|
-
} from "./chunk-RUGG3JY2.js";
|
|
15
|
-
export {
|
|
16
|
-
walk
|
|
17
|
-
};
|