@storybook/addon-svelte-csf 4.0.1 → 4.0.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.
@@ -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,
@@ -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.2",
4
4
  "description": "Allows to write stories in Svelte syntax",
5
5
  "keywords": [
6
6
  "storybook-addons",