histoire 0.7.1 → 0.7.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.
Files changed (118) hide show
  1. package/client.d.ts +1 -1
  2. package/dist/bundled/MobileOverlay.js +2 -2
  3. package/dist/bundled/StoryView.js +22 -19
  4. package/dist/bundled/dark.js +4 -0
  5. package/dist/bundled/index.js +0 -1
  6. package/dist/bundled/index2.js +6 -6
  7. package/dist/bundled/mapping.js +78 -0
  8. package/dist/bundled/sandbox.js +7 -6
  9. package/dist/bundled/state.js +13 -44
  10. package/dist/bundled/style.css +17 -17
  11. package/dist/client/app/App.vue +2 -2
  12. package/dist/client/app/components/base/BaseSplitPane.vue +6 -6
  13. package/dist/client/app/components/panel/ControlsComponentPropItem.vue +13 -6
  14. package/dist/client/app/components/panel/ControlsComponentProps.vue +2 -1
  15. package/dist/client/app/components/panel/StatePresets.vue +2 -1
  16. package/dist/client/app/components/panel/StoryControls.vue +1 -1
  17. package/dist/client/app/components/panel/StorySourceCode.vue +2 -2
  18. package/dist/client/app/components/story/StoryVariantGridItem.vue +1 -1
  19. package/dist/client/app/components/story/StoryVariantSinglePreviewNative.vue +1 -1
  20. package/dist/client/app/components/story/StoryVariantSinglePreviewRemote.vue +3 -2
  21. package/dist/client/app/components/story/StoryVariantSingleView.vue +1 -1
  22. package/dist/client/app/components/toolbar/StoryVariantNewTab.vue +1 -1
  23. package/dist/client/app/components/tree/StoryGroup.vue +1 -1
  24. package/dist/client/app/index.js +0 -2
  25. package/dist/client/app/sandbox.js +4 -5
  26. package/dist/client/app/style/main.pcss +3 -3
  27. package/dist/client/app/style/sandbox.css +1 -1
  28. package/dist/client/app/types.d.ts +1 -52
  29. package/dist/client/app/util/mapping.d.ts +1 -1
  30. package/dist/client/app/util/mapping.js +50 -36
  31. package/dist/client/app/{components/sandbox/lib.d.ts → util/sandbox.d.ts} +1 -1
  32. package/dist/client/app/{components/sandbox/lib.js → util/sandbox.js} +1 -1
  33. package/dist/client/app/util/state.d.ts +1 -5
  34. package/dist/client/app/util/state.js +12 -44
  35. package/dist/node/collect/index.d.ts +2 -2
  36. package/dist/node/collect/index.js +3 -0
  37. package/dist/node/collect/run.d.ts +2 -0
  38. package/dist/{client/server/index.js → node/collect/run.js} +1 -1
  39. package/dist/node/collect/worker.d.ts +3 -3
  40. package/dist/node/collect/worker.js +4 -1
  41. package/dist/node/config.d.ts +3 -3
  42. package/dist/node/context.d.ts +2 -2
  43. package/dist/node/plugin.d.ts +3 -3
  44. package/dist/node/stories.d.ts +4 -4
  45. package/dist/node/tree.d.ts +3 -22
  46. package/dist/style.css +80 -4
  47. package/package.json +4 -2
  48. package/src/client/app/App.vue +2 -2
  49. package/src/client/app/components/base/BaseSplitPane.vue +6 -6
  50. package/src/client/app/components/panel/ControlsComponentPropItem.vue +13 -6
  51. package/src/client/app/components/panel/ControlsComponentProps.vue +2 -1
  52. package/src/client/app/components/panel/StatePresets.vue +2 -1
  53. package/src/client/app/components/panel/StoryControls.vue +1 -1
  54. package/src/client/app/components/panel/StorySourceCode.vue +2 -2
  55. package/src/client/app/components/story/StoryVariantGridItem.vue +1 -1
  56. package/src/client/app/components/story/StoryVariantSinglePreviewNative.vue +1 -1
  57. package/src/client/app/components/story/StoryVariantSinglePreviewRemote.vue +3 -2
  58. package/src/client/app/components/story/StoryVariantSingleView.vue +1 -1
  59. package/src/client/app/components/toolbar/StoryVariantNewTab.vue +1 -1
  60. package/src/client/app/components/tree/StoryGroup.vue +1 -1
  61. package/src/client/app/index.ts +0 -2
  62. package/src/client/app/sandbox.ts +4 -5
  63. package/src/client/app/style/main.pcss +3 -3
  64. package/src/client/app/style/sandbox.css +1 -1
  65. package/src/client/app/types.ts +6 -57
  66. package/src/client/app/util/mapping.ts +47 -34
  67. package/src/client/app/{components/sandbox/lib.ts → util/sandbox.ts} +2 -2
  68. package/src/client/app/util/state.ts +15 -44
  69. package/src/node/collect/index.ts +5 -2
  70. package/src/node/collect/run.ts +13 -0
  71. package/src/node/collect/worker.ts +8 -6
  72. package/src/node/config.ts +3 -3
  73. package/src/node/context.ts +2 -2
  74. package/src/node/plugin.ts +2 -2
  75. package/src/node/server.ts +2 -2
  76. package/src/node/stories.ts +4 -4
  77. package/src/node/tree.ts +7 -31
  78. package/tailwind.config.cjs +1 -1
  79. package/vite.config.ts +12 -7
  80. package/dist/bundled/SandboxVue3.js +0 -706
  81. package/dist/bundled/global-components.js +0 -213
  82. package/dist/client/app/codegen/const.d.ts +0 -1
  83. package/dist/client/app/codegen/const.js +0 -3
  84. package/dist/client/app/codegen/serialize-js.d.ts +0 -1
  85. package/dist/client/app/codegen/serialize-js.js +0 -113
  86. package/dist/client/app/codegen/util.d.ts +0 -10
  87. package/dist/client/app/codegen/util.js +0 -70
  88. package/dist/client/app/codegen/vue3.d.ts +0 -4
  89. package/dist/client/app/codegen/vue3.js +0 -357
  90. package/dist/client/app/components/exposed/Story.vue +0 -106
  91. package/dist/client/app/components/exposed/Variant.vue +0 -78
  92. package/dist/client/app/components/sandbox/RouterLinkStub.d.ts +0 -21
  93. package/dist/client/app/components/sandbox/RouterLinkStub.js +0 -43
  94. package/dist/client/app/components/sandbox/SandboxVue3.vue +0 -185
  95. package/dist/client/app/global-components.d.ts +0 -2
  96. package/dist/client/app/global-components.js +0 -10
  97. package/dist/client/server/index.d.ts +0 -7
  98. package/dist/client/server/vue3/Story.vue +0 -120
  99. package/dist/client/server/vue3/Variant.vue +0 -52
  100. package/dist/client/server/vue3/run.d.ts +0 -2
  101. package/dist/client/server/vue3/run.js +0 -45
  102. package/dist/node/types.d.ts +0 -50
  103. package/dist/node/types.js +0 -1
  104. package/src/client/app/codegen/const.ts +0 -3
  105. package/src/client/app/codegen/serialize-js.ts +0 -119
  106. package/src/client/app/codegen/util.ts +0 -79
  107. package/src/client/app/codegen/vue3.ts +0 -361
  108. package/src/client/app/components/exposed/Story.vue +0 -106
  109. package/src/client/app/components/exposed/Variant.vue +0 -78
  110. package/src/client/app/components/sandbox/RouterLinkStub.ts +0 -49
  111. package/src/client/app/components/sandbox/SandboxVue3.vue +0 -185
  112. package/src/client/app/global-components.ts +0 -13
  113. package/src/client/server/index.ts +0 -19
  114. package/src/client/server/vue3/Story.vue +0 -120
  115. package/src/client/server/vue3/Variant.vue +0 -52
  116. package/src/client/server/vue3/run.ts +0 -55
  117. package/src/components.d.ts +0 -143
  118. package/src/node/types.ts +0 -53
@@ -39,7 +39,7 @@ defineProps<{
39
39
 
40
40
  <!-- Preview -->
41
41
  <StoryVariantSinglePreviewNative
42
- v-if="story.layout.iframe === false"
42
+ v-if="story.layout?.iframe === false"
43
43
  :story="story"
44
44
  :variant="variant"
45
45
  />
@@ -2,7 +2,7 @@
2
2
  import { Icon } from '@iconify/vue'
3
3
  import type { Story, Variant } from '../../types'
4
4
  import { computed } from 'vue'
5
- import { getSandboxUrl } from '../sandbox/lib'
5
+ import { getSandboxUrl } from '../../util/sandbox'
6
6
 
7
7
  const props = defineProps<{
8
8
  variant: Variant
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import type { Story, TreeGroup, TreeFolder, TreeLeaf } from '../../types'
2
+ import type { Story, TreeGroup } from '../../types'
3
3
  import StoryListItem from './StoryListItem.vue'
4
4
  import StoryListFolder from './StoryListFolder.vue'
5
5
  import { Icon } from '@iconify/vue'
@@ -5,7 +5,6 @@ import { createApp } from 'vue';
5
5
  import { createPinia } from 'pinia';
6
6
  import FloatingVue from 'floating-vue';
7
7
  import App from './App.vue';
8
- import { registerGlobalComponents } from './global-components.js';
9
8
  import { router } from './router';
10
9
  export function mountMainApp() {
11
10
  const app = createApp(App);
@@ -24,7 +23,6 @@ export function mountMainApp() {
24
23
  },
25
24
  });
26
25
  app.use(router);
27
- registerGlobalComponents(app);
28
26
  app.mount('#app');
29
27
  if (import.meta.hot) {
30
28
  import.meta.hot.send('histoire:mount', {});
@@ -1,8 +1,8 @@
1
1
  import { parseQuery } from 'vue-router';
2
2
  import { computed, createApp, h, onMounted, ref, watch } from 'vue';
3
3
  import { createPinia } from 'pinia';
4
- import { registerGlobalComponents } from './global-components';
5
- import SandboxVue3 from './components/sandbox/SandboxVue3.vue';
4
+ import { applyStateToVariant } from '@histoire/shared';
5
+ import { SandboxVue3, MountStoryVue3 } from '@histoire/plugin-vue/client';
6
6
  import { mapFile } from './util/mapping';
7
7
  // @ts-expect-error virtual module
8
8
  import { files } from '$histoire-stories';
@@ -10,7 +10,7 @@ import { PREVIEW_SETTINGS_SYNC, STATE_SYNC, SANDBOX_READY } from './util/const.j
10
10
  import { applyPreviewSettings } from './util/preview-settings.js';
11
11
  import { isDark } from './util/dark.js';
12
12
  import { histoireConfig } from './util/config.js';
13
- import { applyStateToVariant, toRawDeep } from './util/state';
13
+ import { toRawDeep } from './util/state.js';
14
14
  const query = parseQuery(window.location.search);
15
15
  const file = ref(mapFile(files.find(f => f.id === query.storyId)));
16
16
  const app = createApp({
@@ -54,7 +54,7 @@ const app = createApp({
54
54
  render() {
55
55
  return [
56
56
  h('div', { class: 'htw-sandbox-hidden' }, [
57
- h(file.value.component, {
57
+ h(MountStoryVue3, {
58
58
  story: file.value.story,
59
59
  }),
60
60
  ]),
@@ -73,7 +73,6 @@ const app = createApp({
73
73
  },
74
74
  });
75
75
  app.use(createPinia());
76
- registerGlobalComponents(app);
77
76
  app.mount('#app');
78
77
  watch(isDark, value => {
79
78
  if (value) {
@@ -50,16 +50,16 @@ body,
50
50
 
51
51
  html {
52
52
  font-family: 'Lato', sans-serif;
53
- font-size: 16px;
53
+ font-size: 1rem;
54
54
  }
55
55
 
56
56
  body {
57
- font-size: 18px;
57
+ font-size: 1.125rem;
58
58
  }
59
59
 
60
60
  @media (min-width: 640px) {
61
61
  body {
62
- font-size: 14px;
62
+ font-size: .875rem;
63
63
  }
64
64
  }
65
65
 
@@ -10,7 +10,7 @@ body {
10
10
  }
11
11
 
12
12
  html {
13
- font-size: 14px;
13
+ font-size: .875rem;
14
14
  font-family: 'Lato', sans-serif;
15
15
  }
16
16
 
@@ -1,45 +1,5 @@
1
1
  import type { RouteLocationRaw } from 'vue-router';
2
- export interface StoryFile {
3
- id: string;
4
- framework: string;
5
- component: any;
6
- story: Story;
7
- path: string[];
8
- }
9
- export declare type StoryLayout = {
10
- type: 'single';
11
- iframe?: boolean;
12
- } | {
13
- type: 'grid';
14
- width?: number | string;
15
- };
16
- export interface Story {
17
- id: string;
18
- title: string;
19
- group?: string;
20
- variants: Variant[];
21
- layout?: StoryLayout;
22
- icon?: string;
23
- iconColor?: string;
24
- docsOnly?: boolean;
25
- file?: StoryFile;
26
- lastSelectedVariant?: Variant;
27
- slots?: () => Readonly<any>;
28
- }
29
- export interface Variant {
30
- id: string;
31
- title: string;
32
- icon?: string;
33
- iconColor?: string;
34
- initState?: () => any;
35
- setupApp?: (payload: any) => unknown;
36
- slots?: () => Readonly<any>;
37
- state?: any;
38
- source?: string;
39
- responsiveDisabled?: boolean;
40
- configReady?: boolean;
41
- previewReady?: boolean;
42
- }
2
+ export type { StoryFile, StoryLayout, Story, Variant, } from '@histoire/shared';
43
3
  export declare type TreeLeaf = {
44
4
  title: string;
45
5
  index: number;
@@ -72,14 +32,3 @@ export interface PreviewSettings {
72
32
  backgroundColor: string;
73
33
  checkerboard: boolean;
74
34
  }
75
- export interface PropDefinition {
76
- name: string;
77
- types?: string[];
78
- required?: boolean;
79
- default?: any;
80
- }
81
- export interface AutoPropComponentDefinition {
82
- name: string;
83
- index: number;
84
- props: PropDefinition[];
85
- }
@@ -1,3 +1,3 @@
1
1
  import type { StoryFile, Variant } from '../types';
2
2
  export declare function mapFile(file: StoryFile, existingFile?: StoryFile): StoryFile;
3
- export declare function mapVariant(variant: Variant): Variant;
3
+ export declare function mapVariant(variant: Variant, existingVariant?: Variant): Variant;
@@ -10,46 +10,60 @@ const copiedFromExistingVariant = [
10
10
  'previewReady',
11
11
  ];
12
12
  export function mapFile(file, existingFile) {
13
- const result = {
14
- ...file,
15
- component: markRaw(file.component),
16
- story: {
17
- ...file.story,
18
- title: file.story.title,
19
- file: markRaw(file),
20
- variants: file.story.variants.map(v => mapVariant(v)),
21
- slots: () => ({}),
22
- },
23
- };
13
+ let result;
24
14
  if (existingFile) {
25
- for (const index in result.story.variants) {
26
- const variant = result.story.variants[index];
27
- const existingVariant = existingFile.story.variants[index];
28
- if (existingVariant) {
29
- for (const key of copiedFromExistingVariant) {
30
- if (typeof existingVariant[key] !== 'undefined') {
31
- if (key === 'state') {
32
- variant.state = existingVariant.state;
33
- continue;
34
- }
35
- variant[key] = existingVariant[key];
36
- }
37
- }
15
+ // Update
16
+ result = existingFile;
17
+ for (const key in file) {
18
+ if (key === 'story') {
19
+ Object.assign(result.story, {
20
+ ...file.story,
21
+ file: markRaw(result),
22
+ variants: file.story.variants.map(v => mapVariant(v, existingFile.story.variants.find(item => item.id === v.id))),
23
+ });
24
+ }
25
+ else if (key !== 'component') {
26
+ result[key] = file[key];
38
27
  }
39
- }
40
- if (existingFile.story.lastSelectedVariant) {
41
- result.story.lastSelectedVariant = result.story.variants.find(v => v.id === existingFile.story.lastSelectedVariant.id);
42
28
  }
43
29
  }
30
+ else {
31
+ // Create
32
+ result = {
33
+ ...file,
34
+ component: markRaw(file.component),
35
+ story: {
36
+ ...file.story,
37
+ title: file.story.title,
38
+ file: markRaw(file),
39
+ variants: file.story.variants.map(v => mapVariant(v)),
40
+ slots: () => ({}),
41
+ },
42
+ };
43
+ }
44
44
  return result;
45
45
  }
46
- export function mapVariant(variant) {
47
- return {
48
- ...variant,
49
- state: null,
50
- initState: null,
51
- setupApp: null,
52
- slots: () => ({}),
53
- previewReady: false,
54
- };
46
+ export function mapVariant(variant, existingVariant) {
47
+ let result;
48
+ if (existingVariant) {
49
+ // Update
50
+ result = existingVariant;
51
+ for (const key in variant) {
52
+ if (!copiedFromExistingVariant.includes(key)) {
53
+ result[key] = variant[key];
54
+ }
55
+ }
56
+ }
57
+ else {
58
+ // Create
59
+ result = {
60
+ ...variant,
61
+ state: null,
62
+ initState: null,
63
+ setupApp: null,
64
+ slots: () => ({}),
65
+ previewReady: false,
66
+ };
67
+ }
68
+ return result;
55
69
  }
@@ -1,2 +1,2 @@
1
- import { Story, Variant } from '../../types';
1
+ import { Story, Variant } from '../types';
2
2
  export declare function getSandboxUrl(story: Story, variant: Variant): string;
@@ -1,4 +1,4 @@
1
- import { base } from '../../router';
1
+ import { base } from '../router';
2
2
  export function getSandboxUrl(story, variant) {
3
3
  const url = new URLSearchParams();
4
4
  url.append('storyId', story.id);
@@ -1,5 +1 @@
1
- import type { Variant } from '../types';
2
- export declare function toRawDeep(val: any): any;
3
- export declare function clone(data: any): any;
4
- export declare function omit(data: any, keys: string[]): {};
5
- export declare function applyStateToVariant(variant: Variant, state: any): void;
1
+ export declare function toRawDeep(val: any, seen?: Set<unknown>): any;
@@ -1,55 +1,23 @@
1
1
  import { unref, isRef } from 'vue';
2
2
  const isObject = (val) => val !== null && typeof val === 'object';
3
- export function toRawDeep(val) {
3
+ export function toRawDeep(val, seen = new Set()) {
4
4
  const unwrappedValue = isRef(val) ? unref(val) : val;
5
+ if (typeof unwrappedValue === 'symbol') {
6
+ return unwrappedValue.toString();
7
+ }
8
+ if (seen.has(unwrappedValue)) {
9
+ return Array.isArray(unwrappedValue) ? [] : {};
10
+ }
11
+ seen.add(unwrappedValue);
5
12
  if (!isObject(unwrappedValue)) {
6
13
  return unwrappedValue;
7
14
  }
8
15
  if (Array.isArray(unwrappedValue)) {
9
- return unwrappedValue.map(toRawDeep);
16
+ return unwrappedValue.map(value => toRawDeep(value, seen));
10
17
  }
11
- return toRawObject(unwrappedValue);
18
+ return toRawObject(unwrappedValue, seen);
12
19
  }
13
- const toRawObject = (obj) => Object.keys(obj).reduce((raw, key) => {
14
- raw[key] = toRawDeep(obj[key]);
20
+ const toRawObject = (obj, seen = new Set()) => Object.keys(obj).reduce((raw, key) => {
21
+ raw[key] = toRawDeep(obj[key], seen);
15
22
  return raw;
16
23
  }, {});
17
- export function clone(data) {
18
- try {
19
- return structuredClone(data);
20
- }
21
- catch (e) {
22
- console.warn(e, `Fallback to JSON cloning`);
23
- try {
24
- return JSON.parse(JSON.stringify(data));
25
- }
26
- catch (e) {
27
- console.error(e);
28
- }
29
- return data;
30
- }
31
- }
32
- export function omit(data, keys) {
33
- const copy = {};
34
- for (const key in data) {
35
- if (!keys.includes(key)) {
36
- copy[key] = data[key];
37
- }
38
- }
39
- return copy;
40
- }
41
- export function applyStateToVariant(variant, state) {
42
- if (variant.state) {
43
- for (const key in state) {
44
- if (variant.state[key] && !key.startsWith('_h') && typeof variant.state[key] === 'object' && !Array.isArray(variant.state[key])) {
45
- Object.assign(variant.state[key], state[key]);
46
- }
47
- else {
48
- variant.state[key] = state[key];
49
- }
50
- }
51
- }
52
- else {
53
- variant.state = state;
54
- }
55
- }
@@ -1,5 +1,5 @@
1
1
  import type { ViteDevServer } from 'vite';
2
- import type { StoryFile } from '../types.js';
2
+ import type { ServerStoryFile } from '@histoire/shared';
3
3
  import type { Context } from '../context.js';
4
4
  export interface UseCollectStoriesOptions {
5
5
  server: ViteDevServer;
@@ -7,6 +7,6 @@ export interface UseCollectStoriesOptions {
7
7
  }
8
8
  export declare function useCollectStories(options: UseCollectStoriesOptions, ctx: Context): {
9
9
  clearCache: () => void;
10
- executeStoryFile: (storyFile: StoryFile) => Promise<void>;
10
+ executeStoryFile: (storyFile: ServerStoryFile) => Promise<void>;
11
11
  destroy: () => Promise<void>;
12
12
  };
@@ -12,7 +12,10 @@ export function useCollectStories(options, ctx) {
12
12
  deps: {
13
13
  inline: [
14
14
  /histoire\/dist/,
15
+ /@histoire\/[\w\d-]+\/dist/,
16
+ /histoire-[\w\d-]+\/dist/,
15
17
  /@vue\/devtools-api/,
18
+ /vuetify/,
16
19
  ...ctx.config.viteNodeInlineDeps ?? [],
17
20
  ],
18
21
  },
@@ -0,0 +1,2 @@
1
+ import type { ServerRunPayload } from '@histoire/shared';
2
+ export declare function run(payload: ServerRunPayload): Promise<any>;
@@ -2,7 +2,7 @@ export async function run(payload) {
2
2
  let result;
3
3
  // @TODO if (vue3)
4
4
  {
5
- const { run } = await import('./vue3/run.js');
5
+ const { run } = await import('@histoire/plugin-vue/collect');
6
6
  result = await run(payload);
7
7
  }
8
8
  return result;
@@ -1,14 +1,14 @@
1
1
  /// <reference types="node" />
2
2
  import type { MessagePort } from 'worker_threads';
3
- import type { StoryFile, Story } from '../types.js';
3
+ import type { ServerStoryFile, ServerStory } from '@histoire/shared';
4
4
  export interface Payload {
5
5
  root: string;
6
6
  base: string;
7
7
  port: MessagePort;
8
- storyFile: StoryFile;
8
+ storyFile: ServerStoryFile;
9
9
  }
10
10
  export interface ReturnData {
11
- storyData: Story[];
11
+ storyData: ServerStory[];
12
12
  }
13
13
  declare const _default: (payload: Payload) => Promise<ReturnData>;
14
14
  export default _default;
@@ -20,9 +20,12 @@ export default async (payload) => {
20
20
  },
21
21
  });
22
22
  const { destroy: destroyDomEnv } = createDomEnv();
23
+ if (!global.CSS.supports) {
24
+ global.CSS.supports = () => false;
25
+ }
23
26
  const el = window.document.createElement('div');
24
27
  // Mount app to collect stories/variants
25
- const { run } = (await runner.executeFile(resolve(__dirname, '../../client/server/index.js')));
28
+ const { run } = (await runner.executeFile(resolve(__dirname, './run.js')));
26
29
  const storyData = [];
27
30
  await run({
28
31
  file: payload.storyFile,
@@ -1,6 +1,6 @@
1
1
  import { UserConfig as ViteConfig, ConfigEnv as ViteConfigEnv } from 'vite';
2
2
  import type MarkdownIt from 'markdown-it';
3
- import { TreeFile } from './tree.js';
3
+ import type { ServerTreeFile } from '@histoire/shared';
4
4
  import { Plugin } from './plugin.js';
5
5
  declare type CustomizableColors = 'primary' | 'gray';
6
6
  declare type ColorKeys = '50' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
@@ -17,7 +17,7 @@ export interface BackgroundPreset {
17
17
  export interface TreeGroupConfig {
18
18
  title: string;
19
19
  id?: string;
20
- include?: (file: TreeFile) => boolean;
20
+ include?: (file: ServerTreeFile) => boolean;
21
21
  }
22
22
  export interface HistoireConfig {
23
23
  plugins: Plugin[];
@@ -42,7 +42,7 @@ export interface HistoireConfig {
42
42
  *
43
43
  * Use `'path'` use the real folder structure on your computer.
44
44
  */
45
- file?: 'title' | 'path' | ((file: TreeFile) => string[]);
45
+ file?: 'title' | 'path' | ((file: ServerTreeFile) => string[]);
46
46
  order?: 'asc' | ((a: string, b: string) => number);
47
47
  groups?: TreeGroupConfig[];
48
48
  };
@@ -1,10 +1,10 @@
1
+ import type { ServerStoryFile } from '@histoire/shared';
1
2
  import { HistoireConfig, ConfigMode } from './config.js';
2
- import type { StoryFile } from './types.js';
3
3
  export interface Context {
4
4
  root: string;
5
5
  config: HistoireConfig;
6
6
  mode: ConfigMode;
7
- storyFiles: StoryFile[];
7
+ storyFiles: ServerStoryFile[];
8
8
  }
9
9
  export interface CreateContextOptions {
10
10
  mode: Context['mode'];
@@ -1,10 +1,10 @@
1
1
  /// <reference types="node" />
2
2
  import chokidar from 'chokidar';
3
3
  import fs from 'fs-extra';
4
+ import type { ServerStory, ServerVariant } from '@histoire/shared';
4
5
  import type { ConfigMode, HistoireConfig } from './config.js';
5
6
  import type { Context } from './context.js';
6
7
  import type { ModuleLoader } from './load.js';
7
- import type { Story, Variant } from './types.js';
8
8
  export interface Plugin {
9
9
  /**
10
10
  * Name of the plugin
@@ -55,8 +55,8 @@ export declare class DevPluginApi extends BasePluginApi {
55
55
  export declare type BuildEndCallback = () => Promise<void> | void;
56
56
  export declare type PreviewStoryCallback = (payload: {
57
57
  file: string;
58
- story: Story;
59
- variant: Variant;
58
+ story: ServerStory;
59
+ variant: ServerVariant;
60
60
  url: string;
61
61
  }) => Promise<void> | void;
62
62
  export declare class BuildPluginApi extends BasePluginApi {
@@ -1,11 +1,11 @@
1
1
  import chokidar from 'chokidar';
2
+ import type { ServerStoryFile } from '@histoire/shared';
2
3
  import { Context } from './context.js';
3
- import type { StoryFile } from './types.js';
4
- declare type StoryChangeHandler = (file?: StoryFile) => unknown;
4
+ declare type StoryChangeHandler = (file?: ServerStoryFile) => unknown;
5
5
  export declare function onStoryChange(handler: StoryChangeHandler): void;
6
6
  export declare function watchStories(newContext: Context): Promise<chokidar.FSWatcher>;
7
- export declare function notifyStoryChange(file?: StoryFile): void;
8
- export declare function addStory(relativeFilePath: string): StoryFile;
7
+ export declare function notifyStoryChange(file?: ServerStoryFile): void;
8
+ export declare function addStory(relativeFilePath: string): ServerStoryFile;
9
9
  export declare function removeStory(relativeFilePath: string): void;
10
10
  export declare function findAllStories(newContext: Context): Promise<void>;
11
11
  export {};
@@ -1,23 +1,4 @@
1
+ import type { ServerStoryFile, ServerTree, ServerTreeFile } from '@histoire/shared';
1
2
  import type { HistoireConfig } from './config.js';
2
- import type { StoryFile } from './types.js';
3
- export interface TreeFile {
4
- title: string;
5
- path: string;
6
- }
7
- export interface TreeLeaf {
8
- title: string;
9
- index: number;
10
- }
11
- export interface TreeFolder {
12
- title: string;
13
- children: (TreeFolder | TreeLeaf)[];
14
- }
15
- export interface TreeGroup {
16
- group: true;
17
- id: string;
18
- title: string;
19
- children: (TreeFolder | TreeLeaf)[];
20
- }
21
- export declare type Tree = (TreeGroup | TreeFolder | TreeLeaf)[];
22
- export declare function createPath(config: HistoireConfig, file: TreeFile): string[];
23
- export declare function makeTree(config: HistoireConfig, files: StoryFile[]): Tree;
3
+ export declare function createPath(config: HistoireConfig, file: ServerTreeFile): string[];
4
+ export declare function makeTree(config: HistoireConfig, files: ServerStoryFile[]): ServerTree;