@storybook/addon-svelte-csf 5.1.1 → 5.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/compiler/post-transform/appendix/create-export-order.test.d.ts +1 -0
  2. package/dist/compiler/post-transform/appendix/create-export-order.test.js +21 -0
  3. package/dist/compiler/post-transform/appendix/create-import.test.d.ts +1 -0
  4. package/dist/compiler/post-transform/appendix/create-import.test.js +9 -0
  5. package/dist/compiler/post-transform/appendix/create-named-export-stories.test.d.ts +1 -0
  6. package/dist/compiler/post-transform/appendix/create-named-export-stories.test.js +35 -0
  7. package/dist/compiler/post-transform/appendix/create-runtime-story-variable-declaration.test.d.ts +1 -0
  8. package/dist/compiler/post-transform/appendix/create-runtime-story-variable-declaration.test.js +100 -0
  9. package/dist/compiler/post-transform/appendix/create-variable-from-runtime-stories-call.test.d.ts +1 -0
  10. package/dist/compiler/post-transform/appendix/create-variable-from-runtime-stories-call.test.js +22 -0
  11. package/dist/compiler/post-transform/define-meta/index.test.d.ts +1 -0
  12. package/dist/compiler/post-transform/define-meta/index.test.js +96 -0
  13. package/dist/compiler/post-transform/index.test.d.ts +1 -0
  14. package/dist/compiler/post-transform/index.test.js +279 -0
  15. package/dist/compiler/post-transform/remove-export-default.test.d.ts +1 -0
  16. package/dist/compiler/post-transform/remove-export-default.test.js +33 -0
  17. package/dist/compiler/post-transform/story/index.test.d.ts +1 -0
  18. package/dist/compiler/post-transform/story/index.test.js +147 -0
  19. package/dist/compiler/pre-transform/codemods/component-meta-to-define-meta.test.d.ts +1 -0
  20. package/dist/compiler/pre-transform/codemods/component-meta-to-define-meta.test.js +121 -0
  21. package/dist/compiler/pre-transform/codemods/export-const-to-define-meta.test.d.ts +1 -0
  22. package/dist/compiler/pre-transform/codemods/export-const-to-define-meta.test.js +68 -0
  23. package/dist/compiler/pre-transform/codemods/import-declaration.test.d.ts +1 -0
  24. package/dist/compiler/pre-transform/codemods/import-declaration.test.js +24 -0
  25. package/dist/compiler/pre-transform/codemods/legacy-story.test.d.ts +1 -0
  26. package/dist/compiler/pre-transform/codemods/legacy-story.test.js +287 -0
  27. package/dist/compiler/pre-transform/codemods/template-to-snippet.test.d.ts +1 -0
  28. package/dist/compiler/pre-transform/codemods/template-to-snippet.test.js +75 -0
  29. package/dist/compiler/pre-transform/index.test.d.ts +1 -0
  30. package/dist/compiler/pre-transform/index.test.js +256 -0
  31. package/dist/parser/analyse/story/attributes/identifiers.test.d.ts +1 -0
  32. package/dist/parser/analyse/story/attributes/identifiers.test.js +294 -0
  33. package/dist/parser/analyse/story/attributes.test.d.ts +1 -0
  34. package/dist/parser/analyse/story/attributes.test.js +151 -0
  35. package/dist/parser/analyse/story/content.test.d.ts +1 -0
  36. package/dist/parser/analyse/story/content.test.js +263 -0
  37. package/dist/parser/extract/svelte/define-meta.test.d.ts +1 -0
  38. package/dist/parser/extract/svelte/define-meta.test.js +32 -0
  39. package/dist/parser/extract/svelte/fragment-nodes.test.d.ts +1 -0
  40. package/dist/parser/extract/svelte/fragment-nodes.test.js +101 -0
  41. package/dist/parser/extract/svelte/module-nodes.test.d.ts +1 -0
  42. package/dist/parser/extract/svelte/module-nodes.test.js +143 -0
  43. package/dist/parser/extract/svelte/nodes.test.d.ts +1 -0
  44. package/dist/parser/extract/svelte/nodes.test.js +29 -0
  45. package/dist/parser/extract/svelte/story/attributes.test.d.ts +1 -0
  46. package/dist/parser/extract/svelte/story/attributes.test.js +50 -0
  47. package/dist/parser/extract/svelte/story/template.test.d.ts +1 -0
  48. package/dist/parser/extract/svelte/story/template.test.js +51 -0
  49. package/dist/runtime/emit-code.test.d.ts +1 -0
  50. package/dist/runtime/emit-code.test.js +149 -0
  51. package/dist/utils/identifier-utils.test.d.ts +1 -0
  52. package/dist/utils/identifier-utils.test.js +22 -0
  53. package/package.json +22 -27
@@ -0,0 +1,21 @@
1
+ import { print } from 'esrap';
2
+ import { describe, it } from 'vitest';
3
+ import { createExportOrderVariableDeclaration } from './create-export-order.js';
4
+ describe(createExportOrderVariableDeclaration.name, () => {
5
+ it('correctly creates a variable with named exports order', ({ expect }) => {
6
+ const stringified = print(createExportOrderVariableDeclaration({
7
+ storiesIdentifiers: [
8
+ { exportName: 'Default', name: 'Default' },
9
+ { exportName: 'SomeComponent', name: 'Some Component' },
10
+ { exportName: 'ThisNameIsWeird', name: 'This-Name-Is-Weird' },
11
+ ],
12
+ })).code;
13
+ expect(stringified).toMatchInlineSnapshot(`
14
+ "export const __namedExportsOrder = [
15
+ "Default",
16
+ "SomeComponent",
17
+ "ThisNameIsWeird"
18
+ ];"
19
+ `);
20
+ });
21
+ });
@@ -0,0 +1,9 @@
1
+ import { print } from 'esrap';
2
+ import { describe, it } from 'vitest';
3
+ import { createRuntimeStoriesImport } from './create-import.js';
4
+ describe(createRuntimeStoriesImport.name, () => {
5
+ it('creates import correctly', ({ expect }) => {
6
+ const stringified = print(createRuntimeStoriesImport()).code;
7
+ expect(stringified).toMatchInlineSnapshot(`"import { createRuntimeStories } from "@storybook/addon-svelte-csf/internal/create-runtime-stories";"`);
8
+ });
9
+ });
@@ -0,0 +1,35 @@
1
+ import { print } from 'esrap';
2
+ import { describe, it } from 'vitest';
3
+ import { createNamedExportStories } from './create-named-export-stories.js';
4
+ describe(createNamedExportStories, () => {
5
+ it('works', ({ expect }) => {
6
+ const namedExportDeclaration = createNamedExportStories({
7
+ storiesIdentifiers: [
8
+ {
9
+ exportName: 'Default',
10
+ name: undefined,
11
+ },
12
+ {
13
+ exportName: 'Primary',
14
+ name: 'Primary',
15
+ },
16
+ {
17
+ exportName: 'Secondary',
18
+ name: 'Secondary',
19
+ },
20
+ {
21
+ exportName: 'Disabled',
22
+ name: 'Disabled',
23
+ },
24
+ ],
25
+ });
26
+ expect(print(namedExportDeclaration).code).toMatchInlineSnapshot(`
27
+ "export {
28
+ $__Default as Default,
29
+ $__Primary as Primary,
30
+ $__Secondary as Secondary,
31
+ $__Disabled as Disabled
32
+ };"
33
+ `);
34
+ });
35
+ });
@@ -0,0 +1,100 @@
1
+ import { print } from 'esrap';
2
+ import { describe, it } from 'vitest';
3
+ import { createASTArrayExpression, createASTIdentifier } from '../../../parser/ast.js';
4
+ import { SVELTE_CSF_V4_TAG } from '../../../constants.js';
5
+ import { createRuntimeStoryVariableDeclaration } from './create-runtime-story-variable-declaration.js';
6
+ import { createVariableFromRuntimeStoriesCall } from './create-variable-from-runtime-stories-call.js';
7
+ describe(createRuntimeStoryVariableDeclaration, () => {
8
+ it('correctly creates a runtime story variable', ({ expect }) => {
9
+ const stringified = print(createRuntimeStoryVariableDeclaration({
10
+ exportName: 'Default',
11
+ nodes: {
12
+ variable: createVariableFromRuntimeStoriesCall({
13
+ storiesFunctionDeclaration: {
14
+ type: 'FunctionDeclaration',
15
+ id: createASTIdentifier('Example_stories'),
16
+ body: {
17
+ type: 'BlockStatement',
18
+ body: [],
19
+ },
20
+ params: [],
21
+ },
22
+ }),
23
+ },
24
+ })).code;
25
+ expect(stringified).toMatchInlineSnapshot(`
26
+ "const $__Default = {
27
+ ...$__stories["Default"],
28
+ tags: ["svelte-csf-v5"]
29
+ };"
30
+ `);
31
+ });
32
+ it('allows passing Story-level tags', ({ expect }) => {
33
+ const stringified = print(createRuntimeStoryVariableDeclaration({
34
+ exportName: 'Default',
35
+ nodes: {
36
+ variable: createVariableFromRuntimeStoriesCall({
37
+ storiesFunctionDeclaration: {
38
+ type: 'FunctionDeclaration',
39
+ id: createASTIdentifier('Example_stories'),
40
+ body: {
41
+ type: 'BlockStatement',
42
+ body: [],
43
+ },
44
+ params: [],
45
+ },
46
+ }),
47
+ tags: createASTArrayExpression([
48
+ {
49
+ type: 'Literal',
50
+ value: 'autodocs',
51
+ },
52
+ {
53
+ type: 'Literal',
54
+ value: '!test',
55
+ },
56
+ ]),
57
+ },
58
+ })).code;
59
+ expect(stringified).toMatchInlineSnapshot(`
60
+ "const $__Default = {
61
+ ...$__stories["Default"],
62
+ tags: ["autodocs", "!test", "svelte-csf-v5"]
63
+ };"
64
+ `);
65
+ });
66
+ it('keeps Svelte CSF v4 tag if present, and does not add Svelte CSF v5 tag', ({ expect }) => {
67
+ const stringified = print(createRuntimeStoryVariableDeclaration({
68
+ exportName: 'Default',
69
+ nodes: {
70
+ variable: createVariableFromRuntimeStoriesCall({
71
+ storiesFunctionDeclaration: {
72
+ type: 'FunctionDeclaration',
73
+ id: createASTIdentifier('Example_stories'),
74
+ body: {
75
+ type: 'BlockStatement',
76
+ body: [],
77
+ },
78
+ params: [],
79
+ },
80
+ }),
81
+ tags: createASTArrayExpression([
82
+ {
83
+ type: 'Literal',
84
+ value: 'autodocs',
85
+ },
86
+ {
87
+ type: 'Literal',
88
+ value: SVELTE_CSF_V4_TAG,
89
+ },
90
+ ]),
91
+ },
92
+ })).code;
93
+ expect(stringified).toMatchInlineSnapshot(`
94
+ "const $__Default = {
95
+ ...$__stories["Default"],
96
+ tags: ["autodocs", "svelte-csf-v4"]
97
+ };"
98
+ `);
99
+ });
100
+ });
@@ -0,0 +1,22 @@
1
+ import { print } from 'esrap';
2
+ import { describe, it } from 'vitest';
3
+ import { createVariableFromRuntimeStoriesCall } from './create-variable-from-runtime-stories-call.js';
4
+ describe(createVariableFromRuntimeStoriesCall.name, () => {
5
+ it('creates a variable correctly', ({ expect }) => {
6
+ const stringified = print(createVariableFromRuntimeStoriesCall({
7
+ storiesFunctionDeclaration: {
8
+ type: 'FunctionDeclaration',
9
+ id: {
10
+ type: 'Identifier',
11
+ name: 'Example_stories',
12
+ },
13
+ body: {
14
+ type: 'BlockStatement',
15
+ body: [],
16
+ },
17
+ params: [],
18
+ },
19
+ })).code;
20
+ expect(stringified).toMatchInlineSnapshot(`"const $__stories = createRuntimeStories(Example_stories, $__meta);"`);
21
+ });
22
+ });
@@ -0,0 +1,96 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import url from 'node:url';
4
+ import { print } from 'esrap';
5
+ import MagicString from 'magic-string';
6
+ import { parseAst } from 'rollup/parseAst';
7
+ import { describe, it } from 'vitest';
8
+ import { createMetaVariableDeclaration, transformDefineMeta } from './index.js';
9
+ import { getSvelteAST } from '../../../parser/ast.js';
10
+ import { extractSvelteASTNodes } from '../../../parser/extract/svelte/nodes.js';
11
+ import { extractCompiledASTNodes } from '../../../parser/extract/compiled/nodes.js';
12
+ import { insertDefineMetaParameters } from './insert-parameters.js';
13
+ import { replaceDefineMetaArgument } from './replace-argument.js';
14
+ const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
15
+ describe(transformDefineMeta.name, () => {
16
+ it("transformed 'defineMeta' matches inlined snapshot", async ({ expect }) => {
17
+ const filename = path.resolve(__dirname, '../../../../tests/stories/Example.stories.svelte');
18
+ const originalCode = fs.readFileSync(filename).toString();
19
+ const compiledPreTransformCode = fs
20
+ .readFileSync(path.resolve(__dirname, '../../../../tests/__compiled__/pre-transform/Example.stories.dev.js'))
21
+ .toString();
22
+ const svelteAST = getSvelteAST({ code: originalCode, filename });
23
+ const svelteASTNodes = await extractSvelteASTNodes({
24
+ ast: svelteAST,
25
+ filename,
26
+ });
27
+ const compiledASTNodes = await extractCompiledASTNodes({
28
+ ast: parseAst(compiledPreTransformCode),
29
+ filename,
30
+ });
31
+ const code = new MagicString(compiledPreTransformCode);
32
+ transformDefineMeta({
33
+ code,
34
+ nodes: {
35
+ svelte: svelteASTNodes,
36
+ compiled: compiledASTNodes,
37
+ },
38
+ filename,
39
+ });
40
+ const { defineMetaVariableDeclaration } = await extractCompiledASTNodes({
41
+ ast: parseAst(code.toString()),
42
+ });
43
+ expect(print(defineMetaVariableDeclaration).code).toMatchInlineSnapshot(`"const { Story } = defineMeta($__meta);"`);
44
+ });
45
+ });
46
+ describe(createMetaVariableDeclaration.name, () => {
47
+ it('parameters are transformed correctly', async ({ expect }) => {
48
+ const filename = path.resolve(__dirname, '../../../../tests/stories/Example.stories.svelte');
49
+ const originalCode = fs.readFileSync(filename).toString();
50
+ const compiledPreTransformCode = fs
51
+ .readFileSync(path.resolve(__dirname, '../../../../tests/__compiled__/pre-transform/Example.stories.dev.js'))
52
+ .toString();
53
+ const svelteAST = getSvelteAST({ code: originalCode, filename });
54
+ const svelteASTNodes = await extractSvelteASTNodes({
55
+ ast: svelteAST,
56
+ filename,
57
+ });
58
+ const compiledASTNodes = await extractCompiledASTNodes({
59
+ ast: parseAst(compiledPreTransformCode),
60
+ filename,
61
+ });
62
+ insertDefineMetaParameters({
63
+ nodes: {
64
+ svelte: svelteASTNodes,
65
+ compiled: compiledASTNodes,
66
+ },
67
+ filename,
68
+ });
69
+ const metaObjectExpression = replaceDefineMetaArgument({
70
+ nodes: {
71
+ svelte: svelteASTNodes,
72
+ compiled: compiledASTNodes,
73
+ },
74
+ });
75
+ const metaVariableDeclaration = createMetaVariableDeclaration({ init: metaObjectExpression });
76
+ expect(print(metaVariableDeclaration).code).toMatchInlineSnapshot(`
77
+ "const $__meta = {
78
+ title: 'Example',
79
+ component: Example,
80
+ tags: ['autodocs'],
81
+ args: {
82
+ onclick: fn(),
83
+ onmouseenter: fn(),
84
+ onmouseleave: fn()
85
+ },
86
+ parameters: {
87
+ docs: {
88
+ description: {
89
+ component: "Description set explicitly in the comment above \`defineMeta\`.\\n\\nMultiline supported. And also Markdown syntax:\\n\\n* **Bold**,\\n* _Italic_,\\n* \`Code\`."
90
+ }
91
+ }
92
+ }
93
+ };"
94
+ `);
95
+ });
96
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,279 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import url from 'node:url';
4
+ import MagicString from 'magic-string';
5
+ import { parseAst } from 'rollup/parseAst';
6
+ import { describe, it } from 'vitest';
7
+ import { transformStoriesCode } from './index.js';
8
+ import { getSvelteAST } from '../../parser/ast.js';
9
+ import { extractSvelteASTNodes } from '../../parser/extract/svelte/nodes.js';
10
+ import { extractCompiledASTNodes } from '../../parser/extract/compiled/nodes.js';
11
+ const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
12
+ describe(transformStoriesCode.name, () => {
13
+ it('transformed code matches inlined snapshot', async ({ expect }) => {
14
+ const filename = path.resolve(__dirname, '../../../tests/stories/Example.stories.svelte');
15
+ const originalCode = fs.readFileSync(filename).toString();
16
+ const compiledPreTransformCode = fs
17
+ .readFileSync(path.resolve(__dirname, '../../../tests/__compiled__/pre-transform/Example.stories.dev.js'))
18
+ .toString();
19
+ const svelteAST = getSvelteAST({ code: originalCode, filename });
20
+ const svelteASTNodes = await extractSvelteASTNodes({
21
+ ast: svelteAST,
22
+ filename,
23
+ });
24
+ const compiledASTNodes = await extractCompiledASTNodes({
25
+ ast: parseAst(compiledPreTransformCode),
26
+ filename,
27
+ });
28
+ const code = new MagicString(compiledPreTransformCode);
29
+ await transformStoriesCode({
30
+ code,
31
+ nodes: {
32
+ svelte: svelteASTNodes,
33
+ compiled: compiledASTNodes,
34
+ },
35
+ filename,
36
+ originalCode,
37
+ });
38
+ expect(code.toString()).toMatchInlineSnapshot(`
39
+ "import 'svelte/internal/disclose-version';
40
+
41
+ Example_stories[$.FILENAME] = 'tests/stories/Example.stories.svelte';
42
+
43
+ import * as $ from 'svelte/internal/client';
44
+ import { fn } from 'storybook/test';
45
+ import { defineMeta } from '@storybook/addon-svelte-csf';
46
+ import Example from './Example.svelte';
47
+
48
+ /**
49
+ * Description set explicitly in the comment above \`defineMeta\`.
50
+ *
51
+ * Multiline supported. And also Markdown syntax:
52
+ *
53
+ * * **Bold**,
54
+ * * _Italic_,
55
+ * * \`Code\`.
56
+ */
57
+ const $__meta = {
58
+ title: 'Example',
59
+ component: Example,
60
+ tags: ['autodocs'],
61
+ args: {
62
+ onclick: fn(),
63
+ onmouseenter: fn(),
64
+ onmouseleave: fn()
65
+ },
66
+ parameters: {
67
+ docs: {
68
+ description: {
69
+ component: "Description set explicitly in the comment above \`defineMeta\`.\\n\\nMultiline supported. And also Markdown syntax:\\n\\n* **Bold**,\\n* _Italic_,\\n* \`Code\`."
70
+ }
71
+ }
72
+ }
73
+ };
74
+ const { Story } = defineMeta($__meta);
75
+
76
+ var root_2 = $.add_locations($.template(\`<p> </p> <br>\`, 1), Example_stories[$.FILENAME], [[37, 2], [37, 44]]);
77
+ var root = $.add_locations($.template(\`<!> <!> <!> <!> <!>\`, 1), Example_stories[$.FILENAME], []);
78
+
79
+ function Example_stories($$anchor, $$props) {
80
+ $.check_target(new.target);
81
+ $.push($$props, true, Example_stories);
82
+
83
+ const template = $.wrap_snippet(Example_stories, function ($$anchor, args = $.noop, context = $.noop) {
84
+ $.validate_snippet_args(...arguments);
85
+
86
+ var fragment = $.comment();
87
+ var node = $.first_child(fragment);
88
+
89
+ Example(node, $.spread_props(args, {
90
+ onclick: handleClick,
91
+ children: $.wrap_snippet(Example_stories, ($$anchor, $$slotProps) => {
92
+ var fragment_1 = root_2();
93
+ var p = $.first_child(fragment_1);
94
+ var text = $.child(p, true);
95
+
96
+ $.reset(p);
97
+
98
+ var text_1 = $.sibling(p);
99
+
100
+ $.next();
101
+
102
+ $.template_effect(() => {
103
+ $.set_text(text, context().name);
104
+ $.set_text(text_1, \` You clicked: \${$.get(count) ?? ''}\`);
105
+ });
106
+
107
+ $.append($$anchor, fragment_1);
108
+ }),
109
+ $$slots: { default: true }
110
+ }));
111
+
112
+ $.append($$anchor, fragment);
113
+ });
114
+
115
+ let count = $.state(0);
116
+
117
+ function handleClick() {
118
+ $.set(count, $.get(count) + 1);
119
+ }
120
+
121
+ var fragment_2 = root();
122
+ var node_1 = $.first_child(fragment_2);
123
+
124
+ Story(node_1, {
125
+ name: 'Default',
126
+ template,
127
+ parameters: {
128
+ docs: {
129
+ description: { story: "Description for the default story" }
130
+ },
131
+ __svelteCsf: {
132
+ rawCode: "<Example {...args} onclick={handleClick}>\\n <p>{context.name}</p>\\n You clicked: {count}<br />\\n</Example>"
133
+ }
134
+ }
135
+ });
136
+
137
+ var node_2 = $.sibling(node_1, 2);
138
+
139
+ Story(node_2, {
140
+ name: 'Rounded',
141
+ args: { rounded: true },
142
+ template,
143
+ parameters: {
144
+ docs: {
145
+ description: { story: "Description for the rounded story" }
146
+ },
147
+ __svelteCsf: {
148
+ rawCode: "<Example {...args} onclick={handleClick}>\\n <p>{context.name}</p>\\n You clicked: {count}<br />\\n</Example>"
149
+ }
150
+ }
151
+ });
152
+
153
+ var node_3 = $.sibling(node_2, 2);
154
+
155
+ Story(node_3, {
156
+ name: 'Square',
157
+ args: { rounded: false },
158
+ template,
159
+ parameters: {
160
+ docs: {
161
+ description: { story: "Description for the squared story" }
162
+ },
163
+ __svelteCsf: {
164
+ rawCode: "<Example {...args} onclick={handleClick}>\\n <p>{context.name}</p>\\n You clicked: {count}<br />\\n</Example>"
165
+ }
166
+ }
167
+ });
168
+
169
+ var node_4 = $.sibling(node_3, 2);
170
+
171
+ Story(node_4, {
172
+ name: 'As child',
173
+ asChild: true,
174
+ children: $.wrap_snippet(Example_stories, ($$anchor, $$slotProps) => {
175
+ var fragment_3 = $.comment();
176
+ var node_5 = $.first_child(fragment_3);
177
+
178
+ Example(node_5, {
179
+ children: $.wrap_snippet(Example_stories, ($$anchor, $$slotProps) => {
180
+ $.next();
181
+
182
+ var text_2 = $.text('Label');
183
+
184
+ $.append($$anchor, text_2);
185
+ }),
186
+ $$slots: { default: true }
187
+ });
188
+
189
+ $.append($$anchor, fragment_3);
190
+ }),
191
+ $$slots: { default: true },
192
+ parameters: {
193
+ __svelteCsf: { rawCode: "<Example>Label</Example>" }
194
+ }
195
+ });
196
+
197
+ var node_6 = $.sibling(node_4, 2);
198
+
199
+ Story(node_6, {
200
+ name: 'Children forwared',
201
+ children: $.wrap_snippet(Example_stories, ($$anchor, $$slotProps) => {
202
+ $.next();
203
+
204
+ var text_3 = $.text('Forwarded label');
205
+
206
+ $.append($$anchor, text_3);
207
+ }),
208
+ $$slots: { default: true },
209
+ parameters: {
210
+ __svelteCsf: {
211
+ rawCode: "<Example {...args}>\\n Forwarded label\\n</Example>"
212
+ }
213
+ }
214
+ });
215
+
216
+ $.append($$anchor, fragment_2);
217
+ return $.pop({ ...$.legacy_api() });
218
+ }
219
+
220
+ if (import.meta.hot) {
221
+ Example_stories = $.hmr(Example_stories, () => Example_stories[$.HMR].source);
222
+
223
+ import.meta.hot.acceptExports(["default"],(module) => {
224
+ module.default[$.HMR].source = Example_stories[$.HMR].source;
225
+ $.set(Example_stories[$.HMR].source, module.default[$.HMR].original);
226
+ });
227
+ }
228
+
229
+
230
+
231
+ import { createRuntimeStories } from "@storybook/addon-svelte-csf/internal/create-runtime-stories";
232
+
233
+ const $__stories = createRuntimeStories(Example_stories, $__meta);
234
+
235
+ export default $__meta;
236
+
237
+ export const __namedExportsOrder = [
238
+ "Default",
239
+ "Rounded",
240
+ "Square",
241
+ "AsChild",
242
+ "ChildrenForwared"
243
+ ];
244
+
245
+ const $__Default = {
246
+ ...$__stories["Default"],
247
+ tags: ["svelte-csf-v5"]
248
+ };
249
+
250
+ const $__Rounded = {
251
+ ...$__stories["Rounded"],
252
+ tags: ["svelte-csf-v5"]
253
+ };
254
+
255
+ const $__Square = {
256
+ ...$__stories["Square"],
257
+ tags: ["svelte-csf-v5"]
258
+ };
259
+
260
+ const $__AsChild = {
261
+ ...$__stories["AsChild"],
262
+ tags: ["svelte-csf-v5"]
263
+ };
264
+
265
+ const $__ChildrenForwared = {
266
+ ...$__stories["ChildrenForwared"],
267
+ tags: ["svelte-csf-v5"]
268
+ };
269
+
270
+ export {
271
+ $__Default as Default,
272
+ $__Rounded as Rounded,
273
+ $__Square as Square,
274
+ $__AsChild as AsChild,
275
+ $__ChildrenForwared as ChildrenForwared
276
+ };"
277
+ `);
278
+ });
279
+ });
@@ -0,0 +1,33 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import url from 'node:url';
4
+ import MagicString from 'magic-string';
5
+ import { parseAst } from 'rollup/parseAst';
6
+ import { describe, it } from 'vitest';
7
+ import { removeExportDefault } from './remove-export-default.js';
8
+ import { extractCompiledASTNodes } from '../../parser/extract/compiled/nodes.js';
9
+ import { StorybookSvelteCSFError } from '../../utils/error.js';
10
+ const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
11
+ describe(removeExportDefault.name, () => {
12
+ it('removes pre-transformed export default correctly', async ({ expect }) => {
13
+ const compiledPreTransformCode = fs
14
+ .readFileSync(path.resolve(__dirname, '../../../tests/__compiled__/pre-transform/Example.stories.dev.js'))
15
+ .toString();
16
+ const compiledASTNodes = await extractCompiledASTNodes({
17
+ ast: parseAst(compiledPreTransformCode),
18
+ });
19
+ const code = new MagicString(compiledPreTransformCode);
20
+ removeExportDefault({
21
+ code,
22
+ nodes: compiledASTNodes,
23
+ });
24
+ await expect(extractCompiledASTNodes({
25
+ ast: parseAst(code.toString()),
26
+ })).rejects.toThrowErrorMatchingInlineSnapshot(`
27
+ [SB_SVELTE_CSF_PARSER_EXTRACT_COMPILED_0003 (NoExportDefaultError): Could not find 'export default' in the compiled output of the stories file: <path not specified>
28
+
29
+ More info: https://github.com/storybookjs/addon-svelte-csf/blob/v${StorybookSvelteCSFError.packageVersion}/ERRORS.md#SB_SVELTE_CSF_PARSER_EXTRACT_COMPILED_0003
30
+ ]
31
+ `);
32
+ });
33
+ });
@@ -0,0 +1 @@
1
+ export {};