histoire 0.7.3 → 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 (109) hide show
  1. package/client.d.ts +1 -1
  2. package/dist/bundled/StoryView.js +22 -19
  3. package/dist/bundled/dark.js +4 -0
  4. package/dist/bundled/index.js +0 -1
  5. package/dist/bundled/index2.js +6 -6
  6. package/dist/bundled/mapping.js +78 -0
  7. package/dist/bundled/sandbox.js +7 -6
  8. package/dist/bundled/state.js +4 -39
  9. package/dist/bundled/style.css +3 -3
  10. package/dist/client/app/App.vue +2 -2
  11. package/dist/client/app/components/panel/ControlsComponentPropItem.vue +13 -6
  12. package/dist/client/app/components/panel/ControlsComponentProps.vue +2 -1
  13. package/dist/client/app/components/panel/StatePresets.vue +2 -1
  14. package/dist/client/app/components/panel/StoryControls.vue +1 -1
  15. package/dist/client/app/components/panel/StorySourceCode.vue +2 -2
  16. package/dist/client/app/components/story/StoryVariantGridItem.vue +1 -1
  17. package/dist/client/app/components/story/StoryVariantSinglePreviewNative.vue +1 -1
  18. package/dist/client/app/components/story/StoryVariantSinglePreviewRemote.vue +3 -2
  19. package/dist/client/app/components/story/StoryVariantSingleView.vue +1 -1
  20. package/dist/client/app/components/toolbar/StoryVariantNewTab.vue +1 -1
  21. package/dist/client/app/components/tree/StoryGroup.vue +1 -1
  22. package/dist/client/app/index.js +0 -2
  23. package/dist/client/app/sandbox.js +4 -5
  24. package/dist/client/app/types.d.ts +1 -52
  25. package/dist/client/app/util/mapping.d.ts +1 -1
  26. package/dist/client/app/util/mapping.js +50 -36
  27. package/dist/client/app/{components/sandbox/lib.d.ts → util/sandbox.d.ts} +1 -1
  28. package/dist/client/app/{components/sandbox/lib.js → util/sandbox.js} +1 -1
  29. package/dist/client/app/util/state.d.ts +0 -4
  30. package/dist/client/app/util/state.js +3 -39
  31. package/dist/node/collect/index.d.ts +2 -2
  32. package/dist/node/collect/index.js +3 -0
  33. package/dist/node/collect/run.d.ts +2 -0
  34. package/dist/{client/server/index.js → node/collect/run.js} +1 -1
  35. package/dist/node/collect/worker.d.ts +3 -3
  36. package/dist/node/collect/worker.js +4 -1
  37. package/dist/node/config.d.ts +3 -3
  38. package/dist/node/context.d.ts +2 -2
  39. package/dist/node/plugin.d.ts +3 -3
  40. package/dist/node/stories.d.ts +4 -4
  41. package/dist/node/tree.d.ts +3 -22
  42. package/package.json +4 -2
  43. package/src/client/app/App.vue +2 -2
  44. package/src/client/app/components/panel/ControlsComponentPropItem.vue +13 -6
  45. package/src/client/app/components/panel/ControlsComponentProps.vue +2 -1
  46. package/src/client/app/components/panel/StatePresets.vue +2 -1
  47. package/src/client/app/components/panel/StoryControls.vue +1 -1
  48. package/src/client/app/components/panel/StorySourceCode.vue +2 -2
  49. package/src/client/app/components/story/StoryVariantGridItem.vue +1 -1
  50. package/src/client/app/components/story/StoryVariantSinglePreviewNative.vue +1 -1
  51. package/src/client/app/components/story/StoryVariantSinglePreviewRemote.vue +3 -2
  52. package/src/client/app/components/story/StoryVariantSingleView.vue +1 -1
  53. package/src/client/app/components/toolbar/StoryVariantNewTab.vue +1 -1
  54. package/src/client/app/components/tree/StoryGroup.vue +1 -1
  55. package/src/client/app/index.ts +0 -2
  56. package/src/client/app/sandbox.ts +4 -5
  57. package/src/client/app/types.ts +6 -57
  58. package/src/client/app/util/mapping.ts +47 -34
  59. package/src/client/app/{components/sandbox/lib.ts → util/sandbox.ts} +2 -2
  60. package/src/client/app/util/state.ts +4 -39
  61. package/src/node/collect/index.ts +5 -2
  62. package/src/node/collect/run.ts +13 -0
  63. package/src/node/collect/worker.ts +8 -6
  64. package/src/node/config.ts +3 -3
  65. package/src/node/context.ts +2 -2
  66. package/src/node/plugin.ts +2 -2
  67. package/src/node/server.ts +2 -2
  68. package/src/node/stories.ts +4 -4
  69. package/src/node/tree.ts +7 -31
  70. package/vite.config.ts +12 -7
  71. package/dist/bundled/SandboxVue3.js +0 -717
  72. package/dist/bundled/global-components.js +0 -213
  73. package/dist/client/app/codegen/const.d.ts +0 -1
  74. package/dist/client/app/codegen/const.js +0 -3
  75. package/dist/client/app/codegen/serialize-js.d.ts +0 -1
  76. package/dist/client/app/codegen/serialize-js.js +0 -126
  77. package/dist/client/app/codegen/util.d.ts +0 -10
  78. package/dist/client/app/codegen/util.js +0 -70
  79. package/dist/client/app/codegen/vue3.d.ts +0 -4
  80. package/dist/client/app/codegen/vue3.js +0 -357
  81. package/dist/client/app/components/exposed/Story.vue +0 -106
  82. package/dist/client/app/components/exposed/Variant.vue +0 -78
  83. package/dist/client/app/components/sandbox/RouterLinkStub.d.ts +0 -21
  84. package/dist/client/app/components/sandbox/RouterLinkStub.js +0 -43
  85. package/dist/client/app/components/sandbox/SandboxVue3.vue +0 -185
  86. package/dist/client/app/global-components.d.ts +0 -2
  87. package/dist/client/app/global-components.js +0 -10
  88. package/dist/client/server/index.d.ts +0 -7
  89. package/dist/client/server/vue3/Story.vue +0 -120
  90. package/dist/client/server/vue3/Variant.vue +0 -52
  91. package/dist/client/server/vue3/run.d.ts +0 -2
  92. package/dist/client/server/vue3/run.js +0 -45
  93. package/dist/node/types.d.ts +0 -50
  94. package/dist/node/types.js +0 -1
  95. package/src/client/app/codegen/const.ts +0 -3
  96. package/src/client/app/codegen/serialize-js.ts +0 -133
  97. package/src/client/app/codegen/util.ts +0 -79
  98. package/src/client/app/codegen/vue3.ts +0 -361
  99. package/src/client/app/components/exposed/Story.vue +0 -106
  100. package/src/client/app/components/exposed/Variant.vue +0 -78
  101. package/src/client/app/components/sandbox/RouterLinkStub.ts +0 -49
  102. package/src/client/app/components/sandbox/SandboxVue3.vue +0 -185
  103. package/src/client/app/global-components.ts +0 -13
  104. package/src/client/server/index.ts +0 -19
  105. package/src/client/server/vue3/Story.vue +0 -120
  106. package/src/client/server/vue3/Variant.vue +0 -52
  107. package/src/client/server/vue3/run.ts +0 -55
  108. package/src/components.d.ts +0 -143
  109. package/src/node/types.ts +0 -53
@@ -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
1
  export declare function toRawDeep(val: any, seen?: Set<unknown>): 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;
@@ -2,6 +2,9 @@ import { unref, isRef } from 'vue';
2
2
  const isObject = (val) => val !== null && typeof val === 'object';
3
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
+ }
5
8
  if (seen.has(unwrappedValue)) {
6
9
  return Array.isArray(unwrappedValue) ? [] : {};
7
10
  }
@@ -18,42 +21,3 @@ const toRawObject = (obj, seen = new Set()) => Object.keys(obj).reduce((raw, key
18
21
  raw[key] = toRawDeep(obj[key], seen);
19
22
  return raw;
20
23
  }, {});
21
- export function clone(data) {
22
- try {
23
- return structuredClone(data);
24
- }
25
- catch (e) {
26
- console.warn(e, `Fallback to JSON cloning`);
27
- try {
28
- return JSON.parse(JSON.stringify(data));
29
- }
30
- catch (e) {
31
- console.error(e);
32
- }
33
- return data;
34
- }
35
- }
36
- export function omit(data, keys) {
37
- const copy = {};
38
- for (const key in data) {
39
- if (!keys.includes(key)) {
40
- copy[key] = data[key];
41
- }
42
- }
43
- return copy;
44
- }
45
- export function applyStateToVariant(variant, state) {
46
- if (variant.state) {
47
- for (const key in state) {
48
- if (variant.state[key] && !key.startsWith('_h') && typeof variant.state[key] === 'object' && !Array.isArray(variant.state[key])) {
49
- Object.assign(variant.state[key], state[key]);
50
- }
51
- else {
52
- variant.state[key] = state[key];
53
- }
54
- }
55
- }
56
- else {
57
- variant.state = state;
58
- }
59
- }
@@ -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;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "histoire",
3
- "version": "0.7.3",
3
+ "version": "0.7.4",
4
4
  "description": "A fast story book powered by Vite",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -33,7 +33,9 @@
33
33
  "histoire": "./bin.mjs"
34
34
  },
35
35
  "dependencies": {
36
- "@histoire/controls": "^0.7.3",
36
+ "@histoire/controls": "^0.7.4",
37
+ "@histoire/plugin-vue": "^0.7.4",
38
+ "@histoire/shared": "^0.7.4",
37
39
  "@iconify/vue": "^3.2.1",
38
40
  "@types/markdown-it": "^12.2.3",
39
41
  "@vueuse/core": "^8.2.5",
@@ -21,6 +21,7 @@ import { isMobile } from './util/responsive'
21
21
  import Breadcrumb from './components/app/Breadcrumb.vue'
22
22
  import SearchModal from './components/search/SearchModal.vue'
23
23
  import InitialLoading from './components/app/InitialLoading.vue'
24
+ import { MountStoryVue3 } from '@histoire/plugin-vue/client'
24
25
 
25
26
  const files = ref<StoryFile[]>(rawFiles.map(file => mapFile(file)))
26
27
  const tree = ref<Tree>(rawTree)
@@ -96,8 +97,7 @@ onMounted(() => {
96
97
  v-if="storyStore.currentStory"
97
98
  class="htw-hidden"
98
99
  >
99
- <component
100
- :is="storyStore.currentStory.file.component"
100
+ <MountStoryVue3
101
101
  :story="storyStore.currentStory"
102
102
  />
103
103
  </div>
@@ -1,7 +1,14 @@
1
1
  <script lang="ts" setup>
2
2
  import { computed, ref } from 'vue'
3
3
  import { Icon } from '@iconify/vue'
4
- import type { Variant, PropDefinition, AutoPropComponentDefinition } from '../../types'
4
+ import type { PropDefinition, AutoPropComponentDefinition } from '@histoire/shared'
5
+ import {
6
+ HstText,
7
+ HstNumber,
8
+ HstCheckbox,
9
+ HstTextarea,
10
+ } from '@histoire/controls'
11
+ import type { Variant } from '../../types'
5
12
 
6
13
  const props = defineProps<{
7
14
  variant: Variant
@@ -12,18 +19,18 @@ const props = defineProps<{
12
19
  const comp = computed(() => {
13
20
  switch (props.definition.types?.[0]) {
14
21
  case 'string':
15
- return 'HstText'
22
+ return HstText
16
23
  case 'number':
17
- return 'HstNumber'
24
+ return HstNumber
18
25
  case 'boolean':
19
- return 'HstCheckbox'
26
+ return HstCheckbox
20
27
  case 'object':
21
28
  default:
22
- return 'HstTextarea'
29
+ return HstTextarea
23
30
  }
24
31
  })
25
32
 
26
- const isJSON = computed(() => comp.value === 'HstTextarea')
33
+ const isJSON = computed(() => comp.value === HstTextarea)
27
34
 
28
35
  const invalidValue = ref('')
29
36
 
@@ -1,5 +1,6 @@
1
1
  <script lang="ts" setup>
2
- import type { AutoPropComponentDefinition, Variant } from '../../types'
2
+ import type { AutoPropComponentDefinition } from '@histoire/shared'
3
+ import type { Variant } from '../../types'
3
4
  import { Icon } from '@iconify/vue'
4
5
  import ControlsComponentPropItem from './ControlsComponentPropItem.vue'
5
6
 
@@ -2,8 +2,9 @@
2
2
  import { ref, computed, nextTick, onMounted } from 'vue'
3
3
  import { Icon } from '@iconify/vue'
4
4
  import { useStorage, onClickOutside, useTimeoutFn } from '@vueuse/core'
5
+ import { applyStateToVariant, clone, omit } from '@histoire/shared'
5
6
  import BaseSelect from '../base/BaseSelect.vue'
6
- import { applyStateToVariant, clone, omit, toRawDeep } from '../../util/state'
7
+ import { toRawDeep } from '../../util/state'
7
8
  import type { Story, Variant } from '../../types'
8
9
 
9
10
  const DEFAULT_ID = 'default'
@@ -1,8 +1,8 @@
1
1
  <script lang="ts" setup>
2
2
  import { PropType } from 'vue'
3
3
  import { Icon } from '@iconify/vue'
4
+ import { SandboxVue3 } from '@histoire/plugin-vue/client'
4
5
  import type { Story, Variant } from '../../types'
5
- import SandboxVue3 from '../sandbox/SandboxVue3.vue'
6
6
  import BaseEmpty from '../base/BaseEmpty.vue'
7
7
  import StatePresets from './StatePresets.vue'
8
8
  import ControlsComponentProps from './ControlsComponentProps.vue'
@@ -2,10 +2,10 @@
2
2
  import { computed, onMounted, PropType, ref, shallowRef, watch } from 'vue'
3
3
  import { getHighlighter, Highlighter, setCDN } from 'shiki'
4
4
  import { HstCopyIcon } from '@histoire/controls'
5
- import { generateSourceCode } from '../../codegen/vue3'
5
+ import { unindent } from '@histoire/shared'
6
+ import { generateSourceCode } from '@histoire/plugin-vue/client'
6
7
  import type { Variant } from '../../types'
7
8
  import { isDark } from '../../util/dark'
8
- import { unindent } from '../../codegen/util'
9
9
 
10
10
  const props = defineProps({
11
11
  variant: {
@@ -3,9 +3,9 @@ import { PropType, ref, toRefs } from 'vue'
3
3
  import { Icon } from '@iconify/vue'
4
4
  import { useRouter } from 'vue-router'
5
5
  import { useResizeObserver } from '@vueuse/core'
6
+ import { SandboxVue3 } from '@histoire/plugin-vue/client'
6
7
  import { useCurrentVariantRoute } from '../../util/variant'
7
8
  import type { Story, Variant } from '../../types'
8
- import SandboxVue3 from '../sandbox/SandboxVue3.vue'
9
9
  import { useScrollOnActive } from '../../util/scroll'
10
10
 
11
11
  const props = defineProps({
@@ -1,6 +1,6 @@
1
1
  <script lang="ts" setup>
2
+ import { SandboxVue3 } from '@histoire/plugin-vue/client'
2
3
  import type { Story, Variant } from '../../types'
3
- import SandboxVue3 from '../sandbox/SandboxVue3.vue'
4
4
  import StoryResponsivePreview from './StoryResponsivePreview.vue'
5
5
 
6
6
  const props = defineProps<{
@@ -2,15 +2,16 @@
2
2
  import { computed, onUnmounted, Ref, ref, toRaw, watch } from 'vue'
3
3
  import { useEventListener } from '@vueuse/core'
4
4
  import { Icon } from '@iconify/vue'
5
+ import { applyStateToVariant } from '@histoire/shared'
5
6
  import { STATE_SYNC, PREVIEW_SETTINGS_SYNC, SANDBOX_READY, EVENT_SEND } from '../../util/const'
6
7
  import type { Story, Variant } from '../../types'
7
8
  import HatchedPattern from '../misc/HatchedPattern.vue'
8
9
  import CheckerboardPattern from '../misc/CheckerboardPattern.vue'
9
- import { getSandboxUrl } from '../sandbox/lib'
10
+ import { getSandboxUrl } from '../../util/sandbox'
10
11
  import { usePreviewSettingsStore } from '../../stores/preview-settings'
11
12
  import { HstEvent, useEventsStore } from '../../stores/events'
12
13
  import StoryResponsivePreview from './StoryResponsivePreview.vue'
13
- import { applyStateToVariant, toRawDeep } from '../../util/state'
14
+ import { toRawDeep } from '../../util/state'
14
15
 
15
16
  const props = defineProps<{
16
17
  story: Story
@@ -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'
@@ -7,7 +7,6 @@ import { createApp } from 'vue'
7
7
  import { createPinia } from 'pinia'
8
8
  import FloatingVue from 'floating-vue'
9
9
  import App from './App.vue'
10
- import { registerGlobalComponents } from './global-components.js'
11
10
  import { router } from './router'
12
11
 
13
12
  export function mountMainApp () {
@@ -27,7 +26,6 @@ export function mountMainApp () {
27
26
  },
28
27
  })
29
28
  app.use(router)
30
- registerGlobalComponents(app)
31
29
  app.mount('#app')
32
30
 
33
31
  if (import.meta.hot) {