@storybook/addon-svelte-csf 4.0.1 → 4.0.3

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.
@@ -1,5 +1,4 @@
1
1
  interface StoryDef {
2
- storyId: string;
3
2
  name: string;
4
3
  template: boolean;
5
4
  source: string;
@@ -1,5 +1,4 @@
1
1
  import * as svelte from 'svelte/compiler';
2
- import { storyNameFromExport, toId } from '@storybook/csf';
3
2
  import dedent from 'dedent';
4
3
  import { extractId } from './extract-id.js';
5
4
  function getStaticAttribute(name, node) {
@@ -85,7 +84,6 @@ export function extractStories(component) {
85
84
  source = dedent `${component.substr(start, end - start)}`;
86
85
  }
87
86
  stories[isTemplate ? `tpl:${id}` : id] = {
88
- storyId: toId(meta.id || meta.title || id, storyNameFromExport(id)),
89
87
  name,
90
88
  template: isTemplate,
91
89
  source,
@@ -22,7 +22,6 @@ describe('extractSource', () => {
22
22
  "hasArgs": false,
23
23
  "name": "MyStory",
24
24
  "source": "<div>a story</div>",
25
- "storyId": "mystory--my-story",
26
25
  "template": false,
27
26
  },
28
27
  },
@@ -50,7 +49,6 @@ describe('extractSource', () => {
50
49
  "hasArgs": false,
51
50
  "name": "MyStory",
52
51
  "source": "<div>a story</div>",
53
- "storyId": "myid--my-id",
54
52
  "template": false,
55
53
  },
56
54
  },
@@ -78,7 +76,6 @@ describe('extractSource', () => {
78
76
  "hasArgs": true,
79
77
  "name": "MyStory",
80
78
  "source": "<div>a story</div>",
81
- "storyId": "mystory--my-story",
82
79
  "template": false,
83
80
  },
84
81
  },
@@ -106,7 +103,6 @@ describe('extractSource', () => {
106
103
  "hasArgs": false,
107
104
  "name": "MyTemplate",
108
105
  "source": "<div>a template</div>",
109
- "storyId": "mytemplate--my-template",
110
106
  "template": true,
111
107
  },
112
108
  },
@@ -134,7 +130,6 @@ describe('extractSource', () => {
134
130
  "hasArgs": false,
135
131
  "name": "default",
136
132
  "source": "<div>a template</div>",
137
- "storyId": "default--default",
138
133
  "template": true,
139
134
  },
140
135
  },
@@ -165,14 +160,12 @@ describe('extractSource', () => {
165
160
  "hasArgs": false,
166
161
  "name": "Story1",
167
162
  "source": "<div>story 1</div>",
168
- "storyId": "story1--story-1",
169
163
  "template": false,
170
164
  },
171
165
  "Story2": {
172
166
  "hasArgs": false,
173
167
  "name": "Story2",
174
168
  "source": "<div>story 2</div>",
175
- "storyId": "story2--story-2",
176
169
  "template": false,
177
170
  },
178
171
  },
@@ -206,7 +199,6 @@ describe('extractSource', () => {
206
199
  "hasArgs": false,
207
200
  "name": "Story1",
208
201
  "source": "<div>story 1</div>",
209
- "storyId": "test--story-1",
210
202
  "template": false,
211
203
  },
212
204
  },
@@ -236,7 +228,6 @@ describe('extractSource', () => {
236
228
  "hasArgs": false,
237
229
  "name": "Button",
238
230
  "source": "<div>a story</div>",
239
- "storyId": "button77471352--button-77471352",
240
231
  "template": false,
241
232
  },
242
233
  },
@@ -3,6 +3,7 @@ export declare function svelteIndexer(fileName: any, { makeTitle }: {
3
3
  }): Promise<{
4
4
  meta: {
5
5
  title: any;
6
+ id?: string | undefined;
6
7
  };
7
8
  stories: {
8
9
  id: string;
@@ -2,6 +2,7 @@ import * as svelte from 'svelte/compiler';
2
2
  import { extractStories } from '../parser/extract-stories.js';
3
3
  import fs from 'fs-extra';
4
4
  import { loadSvelteConfig } from '../config-loader.js';
5
+ import { storyNameFromExport, toId } from '@storybook/csf';
5
6
  export async function svelteIndexer(fileName, { makeTitle }) {
6
7
  let code = (await fs.readFile(fileName, 'utf-8')).toString();
7
8
  const svelteOptions = await loadSvelteConfig();
@@ -9,12 +10,13 @@ export async function svelteIndexer(fileName, { makeTitle }) {
9
10
  code = (await svelte.preprocess(code, svelteOptions.preprocess, { filename: fileName })).code;
10
11
  }
11
12
  const defs = extractStories(code);
13
+ const meta = { ...defs.meta, title: makeTitle(defs.meta.title) };
12
14
  return {
13
- meta: { title: makeTitle(defs.meta.title) },
15
+ meta,
14
16
  stories: Object.entries(defs.stories)
15
17
  .filter(([id, story]) => !story.template)
16
18
  .map(([id, story]) => ({
17
- id: story.storyId,
19
+ id: toId(meta.id || meta.title || id, storyNameFromExport(id)),
18
20
  name: story.name,
19
21
  })),
20
22
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/addon-svelte-csf",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
4
4
  "description": "Allows to write stories in Svelte syntax",
5
5
  "keywords": [
6
6
  "storybook-addons",