histoire 0.7.9 → 0.8.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 (160) hide show
  1. package/dist/bundled/App.js +166 -0
  2. package/dist/bundled/_virtual/plugin-vue_export-helper.js +8 -0
  3. package/dist/bundled/api.js +1 -32
  4. package/dist/bundled/assets/histoire-text-dark.js +2 -0
  5. package/dist/bundled/assets/histoire-text.js +2 -0
  6. package/dist/bundled/{HomeView.js → assets/histoire.js} +1 -23
  7. package/dist/bundled/components/HomeView.js +24 -0
  8. package/dist/bundled/components/app/AppHeader.js +67 -0
  9. package/dist/bundled/components/app/AppLogo.js +26 -0
  10. package/dist/bundled/components/app/Breadcrumb.js +95 -0
  11. package/dist/bundled/components/app/Breadcrumb.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
  12. package/dist/bundled/components/app/InitialLoading.js +48 -0
  13. package/dist/bundled/components/app/MobileOverlay.js +41 -0
  14. package/dist/bundled/components/base/BaseCheckbox.js +75 -0
  15. package/dist/bundled/{BaseEmpty.js → components/base/BaseEmpty.js} +4 -4
  16. package/dist/bundled/components/base/BaseEmpty.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
  17. package/dist/bundled/components/base/BaseListItemLink.js +50 -0
  18. package/dist/bundled/components/base/BaseOverflowMenu.js +97 -0
  19. package/dist/bundled/components/base/BaseOverflowTab.js +45 -0
  20. package/dist/bundled/components/base/BaseSelect.js +88 -0
  21. package/dist/bundled/{MobileOverlay.js → components/base/BaseSplitPane.js} +9 -130
  22. package/dist/bundled/components/base/BaseSplitPane.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
  23. package/dist/bundled/components/base/BaseTab.js +45 -0
  24. package/dist/bundled/components/misc/CheckerboardPattern.js +41 -0
  25. package/dist/bundled/components/misc/HatchedPattern.js +11 -0
  26. package/dist/bundled/components/misc/HatchedPattern.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
  27. package/dist/bundled/components/panel/ControlsComponentPropItem.js +98 -0
  28. package/dist/bundled/components/panel/ControlsComponentProps.js +42 -0
  29. package/dist/bundled/components/panel/PaneTabs.js +110 -0
  30. package/dist/bundled/components/panel/StatePresets.js +184 -0
  31. package/dist/bundled/components/panel/StoryControls.js +66 -0
  32. package/dist/bundled/components/panel/StoryDocs.js +48 -0
  33. package/dist/bundled/components/panel/StoryEvent.js +56 -0
  34. package/dist/bundled/components/panel/StoryEvents.js +49 -0
  35. package/dist/bundled/components/panel/StorySidePanel.js +68 -0
  36. package/dist/bundled/components/panel/StorySourceCode.js +110 -0
  37. package/dist/bundled/components/panel/StorySourceCode.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
  38. package/dist/bundled/components/search/SearchItem.js +113 -0
  39. package/dist/bundled/components/search/SearchItem.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
  40. package/dist/bundled/components/search/SearchLoading.js +19 -0
  41. package/dist/bundled/components/search/SearchModal.js +46 -0
  42. package/dist/bundled/components/search/SearchPane.js +263 -0
  43. package/dist/bundled/{search-docs-data.js → components/search/search-docs-data.js} +1 -1
  44. package/dist/bundled/components/search/search-title-data.js +7 -0
  45. package/dist/bundled/components/story/StoryResponsivePreview.js +180 -0
  46. package/dist/bundled/components/story/StoryResponsivePreview.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
  47. package/dist/bundled/components/story/StoryVariantGrid.js +94 -0
  48. package/dist/bundled/components/story/StoryVariantGridItem.js +106 -0
  49. package/dist/bundled/components/story/StoryVariantGridItem.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
  50. package/dist/bundled/components/story/StoryVariantListItem.js +58 -0
  51. package/dist/bundled/components/story/StoryVariantListItem.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
  52. package/dist/bundled/components/story/StoryVariantSingle.js +115 -0
  53. package/dist/bundled/components/story/StoryVariantSingle.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
  54. package/dist/bundled/components/story/StoryVariantSinglePreviewNative.js +43 -0
  55. package/dist/bundled/components/story/StoryVariantSinglePreviewRemote.js +119 -0
  56. package/dist/bundled/components/story/StoryVariantSingleView.js +49 -0
  57. package/dist/bundled/components/story/StoryView.js +107 -0
  58. package/dist/bundled/components/story/StoryViewer.js +57 -0
  59. package/dist/bundled/components/story/StoryViewer.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
  60. package/dist/bundled/components/toolbar/StoryVariantBackground.js +85 -0
  61. package/dist/bundled/components/toolbar/StoryVariantBackground.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
  62. package/dist/bundled/components/toolbar/StoryVariantNewTab.js +33 -0
  63. package/dist/bundled/components/toolbar/StoryVariantResponsiveSize.js +129 -0
  64. package/dist/bundled/components/toolbar/StoryVariantTitle.js +24 -0
  65. package/dist/bundled/components/tree/StoryGroup.js +74 -0
  66. package/dist/bundled/components/tree/StoryList.js +37 -0
  67. package/dist/bundled/components/tree/StoryListFolder.js +89 -0
  68. package/dist/bundled/components/tree/StoryListFolder.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
  69. package/dist/bundled/components/tree/StoryListItem.js +72 -0
  70. package/dist/bundled/components/tree/StoryListItem.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
  71. package/dist/bundled/index.js +28 -5
  72. package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/common.js +40 -0
  73. package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/en.js +5 -0
  74. package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/advanced.js +11 -0
  75. package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/balance.js +26 -0
  76. package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/simple.js +10 -0
  77. package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang.js +50 -0
  78. package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/type.js +8 -0
  79. package/dist/bundled/router.js +28 -0
  80. package/dist/bundled/sandbox.js +11 -14
  81. package/dist/bundled/{events.js → stores/events.js} +3 -3
  82. package/dist/bundled/stores/folder.js +46 -0
  83. package/dist/bundled/stores/preview-settings.js +15 -0
  84. package/dist/bundled/{story.js → stores/story.js} +4 -30
  85. package/dist/bundled/style.css +58 -58
  86. package/dist/bundled/{config.js → util/config.js} +1 -1
  87. package/dist/bundled/{const.js → util/const.js} +1 -1
  88. package/dist/bundled/util/dark.js +4 -0
  89. package/dist/bundled/util/env.js +2 -0
  90. package/dist/bundled/util/events.js +32 -0
  91. package/dist/bundled/util/keyboard.js +84 -0
  92. package/dist/bundled/{mapping.js → util/mapping.js} +5 -5
  93. package/dist/bundled/util/preview-settings.js +6 -0
  94. package/dist/bundled/util/responsive.js +3 -0
  95. package/dist/bundled/util/sandbox.js +8 -0
  96. package/dist/bundled/util/scroll.js +28 -0
  97. package/dist/bundled/util/state.js +27 -0
  98. package/dist/bundled/util/tooltip.js +12 -0
  99. package/dist/bundled/util/variant.js +35 -0
  100. package/dist/client/app/App.vue +0 -1
  101. package/dist/client/app/components/app/Breadcrumb.vue +1 -1
  102. package/dist/client/app/components/app/MobileOverlay.vue +1 -1
  103. package/dist/client/app/components/base/BaseCheckbox.vue +2 -1
  104. package/dist/client/app/components/base/BaseCopyIcon.vue +34 -0
  105. package/dist/client/app/components/base/BaseOverflowMenu.vue +1 -0
  106. package/dist/client/app/components/base/BaseSplitPane.vue +1 -0
  107. package/dist/client/app/components/panel/StatePresets.vue +3 -3
  108. package/dist/client/app/components/panel/StorySidePanel.vue +1 -1
  109. package/dist/client/app/components/panel/StorySourceCode.vue +1 -1
  110. package/dist/client/app/components/story/StoryVariantGridItem.vue +1 -0
  111. package/dist/client/app/components/story/StoryVariantSingle.vue +5 -7
  112. package/dist/client/app/components/story/StoryVariantSinglePreviewRemote.vue +3 -6
  113. package/dist/client/app/components/story/StoryViewer.vue +2 -2
  114. package/dist/client/app/components/tree/StoryList.vue +1 -1
  115. package/dist/client/app/components/tree/StoryListItem.vue +2 -2
  116. package/dist/client/app/index.js +1 -3
  117. package/dist/client/app/sandbox.js +3 -2
  118. package/dist/client/app/stores/story.d.ts +30 -30
  119. package/dist/client/app/util/dark.d.ts +1 -1
  120. package/dist/client/app/util/mapping.js +3 -3
  121. package/dist/client/app/util/responsive.d.ts +1 -1
  122. package/dist/client/app/util/scroll.js +1 -1
  123. package/dist/client/app/util/state.d.ts +1 -1
  124. package/dist/client/app/util/state.js +11 -8
  125. package/dist/node/build.js +1 -1
  126. package/dist/node/config.js +24 -5
  127. package/dist/node/vite.d.ts +1 -1
  128. package/dist/node/vite.js +10 -4
  129. package/package.json +9 -15
  130. package/src/client/app/App.vue +0 -1
  131. package/src/client/app/components/app/Breadcrumb.vue +1 -1
  132. package/src/client/app/components/app/MobileOverlay.vue +1 -1
  133. package/src/client/app/components/base/BaseCheckbox.vue +2 -1
  134. package/src/client/app/components/base/BaseCopyIcon.vue +34 -0
  135. package/src/client/app/components/base/BaseOverflowMenu.vue +1 -0
  136. package/src/client/app/components/base/BaseSplitPane.vue +1 -0
  137. package/src/client/app/components/panel/StatePresets.vue +3 -3
  138. package/src/client/app/components/panel/StorySidePanel.vue +1 -1
  139. package/src/client/app/components/panel/StorySourceCode.vue +1 -1
  140. package/src/client/app/components/story/StoryVariantGridItem.vue +1 -0
  141. package/src/client/app/components/story/StoryVariantSingle.vue +5 -7
  142. package/src/client/app/components/story/StoryVariantSinglePreviewRemote.vue +3 -6
  143. package/src/client/app/components/story/StoryViewer.vue +2 -2
  144. package/src/client/app/components/tree/StoryList.vue +1 -1
  145. package/src/client/app/components/tree/StoryListItem.vue +2 -2
  146. package/src/client/app/index.ts +1 -5
  147. package/src/client/app/sandbox.ts +3 -2
  148. package/src/client/app/util/mapping.ts +3 -3
  149. package/src/client/app/util/scroll.ts +1 -1
  150. package/src/client/app/util/state.ts +11 -8
  151. package/src/node/build.ts +1 -1
  152. package/src/node/config.ts +24 -5
  153. package/src/node/vite.ts +11 -3
  154. package/tsconfig.json +11 -0
  155. package/vite.config.ts +20 -10
  156. package/dist/bundled/SearchPane.js +0 -506
  157. package/dist/bundled/StoryView.js +0 -2264
  158. package/dist/bundled/dark.js +0 -4
  159. package/dist/bundled/index2.js +0 -843
  160. package/dist/bundled/state.js +0 -25
@@ -1,5 +1,5 @@
1
1
  <script lang="ts" setup>
2
- import { computed, ref } from 'vue'
2
+ import { computed } from 'vue'
3
3
  import { useStoryStore } from '../../stores/story'
4
4
  import { Icon } from '@iconify/vue'
5
5
  import { isMobile } from '../../util/responsive'
@@ -20,12 +20,11 @@ const variant = computed(() => storyStore.currentVariant)
20
20
 
21
21
  <template>
22
22
  <div
23
- v-if="hasSingleVariant && storyStore.currentVariant"
23
+ v-if="hasSingleVariant && variant"
24
24
  class="htw-p-2 htw-h-full"
25
25
  >
26
26
  <StoryVariantSingleView
27
- v-if="storyStore.currentVariant.configReady"
28
- :variant="storyStore.currentVariant"
27
+ :variant="variant"
29
28
  :story="storyStore.currentStory"
30
29
  />
31
30
  </div>
@@ -63,7 +62,6 @@ const variant = computed(() => storyStore.currentVariant)
63
62
  class="htw-p-2 htw-h-full"
64
63
  >
65
64
  <StoryVariantSingleView
66
- v-if="storyStore.currentVariant.configReady"
67
65
  :variant="storyStore.currentVariant"
68
66
  :story="storyStore.currentStory"
69
67
  />
@@ -79,9 +77,9 @@ const variant = computed(() => storyStore.currentVariant)
79
77
  <template #first>
80
78
  <div class="htw-h-full htw-overflow-y-auto">
81
79
  <StoryVariantListItem
82
- v-for="(variant, index) of storyStore.currentStory.variants"
80
+ v-for="(v, index) of storyStore.currentStory.variants"
83
81
  :key="index"
84
- :variant="variant"
82
+ :variant="v"
85
83
  />
86
84
  </div>
87
85
  </template>
@@ -1,12 +1,9 @@
1
1
  <script lang="ts" setup>
2
- import { computed, onUnmounted, Ref, ref, toRaw, watch } from 'vue'
2
+ import { computed, ref, toRaw, watch } from 'vue'
3
3
  import { useEventListener } from '@vueuse/core'
4
- import { Icon } from '@iconify/vue'
5
- import { applyStateToVariant } from '@histoire/shared'
4
+ import { applyState } from '@histoire/shared'
6
5
  import { STATE_SYNC, PREVIEW_SETTINGS_SYNC, SANDBOX_READY, EVENT_SEND } from '../../util/const'
7
6
  import type { Story, Variant } from '../../types'
8
- import HatchedPattern from '../misc/HatchedPattern.vue'
9
- import CheckerboardPattern from '../misc/CheckerboardPattern.vue'
10
7
  import { getSandboxUrl } from '../../util/sandbox'
11
8
  import { usePreviewSettingsStore } from '../../stores/preview-settings'
12
9
  import { HstEvent, useEventsStore } from '../../stores/events'
@@ -66,7 +63,7 @@ useEventListener(window, 'message', (event) => {
66
63
 
67
64
  function updateVariantState (state: any) {
68
65
  synced = true
69
- applyStateToVariant(props.variant, state)
66
+ applyState(props.variant.state, state)
70
67
  }
71
68
 
72
69
  function logEvent (event: HstEvent) {
@@ -39,9 +39,9 @@ watch(variant, () => {
39
39
  @close="closeMenu"
40
40
  >
41
41
  <StoryVariantListItem
42
- v-for="(variant, index) of storyStore.currentStory.variants"
42
+ v-for="(v, index) of storyStore.currentStory.variants"
43
43
  :key="index"
44
- :variant="variant"
44
+ :variant="v"
45
45
  />
46
46
  </MobileOverlay>
47
47
  </template>
@@ -4,7 +4,7 @@ import StoryListItem from './StoryListItem.vue'
4
4
  import StoryListFolder from './StoryListFolder.vue'
5
5
  import StoryGroup from './StoryGroup.vue'
6
6
 
7
- const props = defineProps<{
7
+ defineProps<{
8
8
  tree: Tree
9
9
  stories: Story[]
10
10
  }>()
@@ -18,9 +18,9 @@ const filePadding = computed(() => {
18
18
  })
19
19
 
20
20
  const route = useRoute()
21
- const active = computed(() => route.params.storyId === props.story.id)
21
+ const isActive = computed(() => route.params.storyId === props.story.id)
22
22
  const el = ref<HTMLDivElement>()
23
- useScrollOnActive(active, el)
23
+ useScrollOnActive(isActive, el)
24
24
  </script>
25
25
 
26
26
  <template>
@@ -1,9 +1,7 @@
1
- /* eslint-disable import/first */
2
- // export * from 'vue'
3
1
  import '$histoire-theme';
4
2
  import { createApp } from 'vue';
5
3
  import { createPinia } from 'pinia';
6
- import FloatingVue from 'floating-vue';
4
+ import { FloatingVue } from 'floating-vue';
7
5
  import App from './App.vue';
8
6
  import { router } from './router';
9
7
  export function mountMainApp() {
@@ -1,7 +1,7 @@
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 { applyStateToVariant } from '@histoire/shared';
4
+ import { applyState } from '@histoire/shared';
5
5
  import { SandboxVue3, MountStoryVue3 } from '@histoire/plugin-vue/client';
6
6
  import { mapFile } from './util/mapping';
7
7
  // @ts-expect-error virtual module
@@ -21,11 +21,12 @@ const app = createApp({
21
21
  let synced = false;
22
22
  let mounted = false;
23
23
  window.addEventListener('message', event => {
24
+ // console.log('[sandbox] received message', event.data)
24
25
  if (event.data?.type === STATE_SYNC) {
25
26
  if (!mounted)
26
27
  return;
27
28
  synced = true;
28
- applyStateToVariant(variant.value, event.data.state);
29
+ applyState(variant.value.state, event.data.state);
29
30
  }
30
31
  else if (event.data?.type === PREVIEW_SETTINGS_SYNC) {
31
32
  applyPreviewSettings(event.data.settings);
@@ -9,12 +9,12 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
9
9
  title: string;
10
10
  icon?: string;
11
11
  iconColor?: string;
12
- initState?: () => any;
13
12
  setupApp?: (payload: any) => unknown;
14
13
  slots?: () => Readonly<any>;
15
- state?: any;
14
+ state: any;
16
15
  source?: string;
17
16
  responsiveDisabled?: boolean;
17
+ autoPropsDisabled?: boolean;
18
18
  configReady?: boolean;
19
19
  previewReady?: boolean;
20
20
  }[];
@@ -40,12 +40,12 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
40
40
  title: string;
41
41
  icon?: string;
42
42
  iconColor?: string;
43
- initState?: () => any;
44
43
  setupApp?: (payload: any) => unknown;
45
44
  slots?: () => Readonly<any>;
46
- state?: any;
45
+ state: any;
47
46
  source?: string;
48
47
  responsiveDisabled?: boolean;
48
+ autoPropsDisabled?: boolean;
49
49
  configReady?: boolean;
50
50
  previewReady?: boolean;
51
51
  };
@@ -61,12 +61,12 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
61
61
  title: string;
62
62
  icon?: string;
63
63
  iconColor?: string;
64
- initState?: () => any;
65
64
  setupApp?: (payload: any) => unknown;
66
65
  slots?: () => Readonly<any>;
67
- state?: any;
66
+ state: any;
68
67
  source?: string;
69
68
  responsiveDisabled?: boolean;
69
+ autoPropsDisabled?: boolean;
70
70
  configReady?: boolean;
71
71
  previewReady?: boolean;
72
72
  }[];
@@ -92,12 +92,12 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
92
92
  title: string;
93
93
  icon?: string;
94
94
  iconColor?: string;
95
- initState?: () => any;
96
95
  setupApp?: (payload: any) => unknown;
97
96
  slots?: () => Readonly<any>;
98
- state?: any;
97
+ state: any;
99
98
  source?: string;
100
99
  responsiveDisabled?: boolean;
100
+ autoPropsDisabled?: boolean;
101
101
  configReady?: boolean;
102
102
  previewReady?: boolean;
103
103
  };
@@ -108,12 +108,12 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
108
108
  title: string;
109
109
  icon?: string;
110
110
  iconColor?: string;
111
- initState?: () => any;
112
111
  setupApp?: (payload: any) => unknown;
113
112
  slots?: () => Readonly<any>;
114
- state?: any;
113
+ state: any;
115
114
  source?: string;
116
115
  responsiveDisabled?: boolean;
116
+ autoPropsDisabled?: boolean;
117
117
  configReady?: boolean;
118
118
  previewReady?: boolean;
119
119
  }>;
@@ -129,12 +129,12 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
129
129
  title: string;
130
130
  icon?: string;
131
131
  iconColor?: string;
132
- initState?: () => any;
133
132
  setupApp?: (payload: any) => unknown;
134
133
  slots?: () => Readonly<any>;
135
- state?: any;
134
+ state: any;
136
135
  source?: string;
137
136
  responsiveDisabled?: boolean;
137
+ autoPropsDisabled?: boolean;
138
138
  configReady?: boolean;
139
139
  previewReady?: boolean;
140
140
  }[];
@@ -160,12 +160,12 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
160
160
  title: string;
161
161
  icon?: string;
162
162
  iconColor?: string;
163
- initState?: () => any;
164
163
  setupApp?: (payload: any) => unknown;
165
164
  slots?: () => Readonly<any>;
166
- state?: any;
165
+ state: any;
167
166
  source?: string;
168
167
  responsiveDisabled?: boolean;
168
+ autoPropsDisabled?: boolean;
169
169
  configReady?: boolean;
170
170
  previewReady?: boolean;
171
171
  };
@@ -181,12 +181,12 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
181
181
  title: string;
182
182
  icon?: string;
183
183
  iconColor?: string;
184
- initState?: () => any;
185
184
  setupApp?: (payload: any) => unknown;
186
185
  slots?: () => Readonly<any>;
187
- state?: any;
186
+ state: any;
188
187
  source?: string;
189
188
  responsiveDisabled?: boolean;
189
+ autoPropsDisabled?: boolean;
190
190
  configReady?: boolean;
191
191
  previewReady?: boolean;
192
192
  }[];
@@ -212,12 +212,12 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
212
212
  title: string;
213
213
  icon?: string;
214
214
  iconColor?: string;
215
- initState?: () => any;
216
215
  setupApp?: (payload: any) => unknown;
217
216
  slots?: () => Readonly<any>;
218
- state?: any;
217
+ state: any;
219
218
  source?: string;
220
219
  responsiveDisabled?: boolean;
220
+ autoPropsDisabled?: boolean;
221
221
  configReady?: boolean;
222
222
  previewReady?: boolean;
223
223
  };
@@ -228,12 +228,12 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
228
228
  title: string;
229
229
  icon?: string;
230
230
  iconColor?: string;
231
- initState?: () => any;
232
231
  setupApp?: (payload: any) => unknown;
233
232
  slots?: () => Readonly<any>;
234
- state?: any;
233
+ state: any;
235
234
  source?: string;
236
235
  responsiveDisabled?: boolean;
236
+ autoPropsDisabled?: boolean;
237
237
  configReady?: boolean;
238
238
  previewReady?: boolean;
239
239
  }>;
@@ -249,12 +249,12 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
249
249
  title: string;
250
250
  icon?: string;
251
251
  iconColor?: string;
252
- initState?: () => any;
253
252
  setupApp?: (payload: any) => unknown;
254
253
  slots?: () => Readonly<any>;
255
- state?: any;
254
+ state: any;
256
255
  source?: string;
257
256
  responsiveDisabled?: boolean;
257
+ autoPropsDisabled?: boolean;
258
258
  configReady?: boolean;
259
259
  previewReady?: boolean;
260
260
  }[];
@@ -280,12 +280,12 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
280
280
  title: string;
281
281
  icon?: string;
282
282
  iconColor?: string;
283
- initState?: () => any;
284
283
  setupApp?: (payload: any) => unknown;
285
284
  slots?: () => Readonly<any>;
286
- state?: any;
285
+ state: any;
287
286
  source?: string;
288
287
  responsiveDisabled?: boolean;
288
+ autoPropsDisabled?: boolean;
289
289
  configReady?: boolean;
290
290
  previewReady?: boolean;
291
291
  };
@@ -301,12 +301,12 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
301
301
  title: string;
302
302
  icon?: string;
303
303
  iconColor?: string;
304
- initState?: () => any;
305
304
  setupApp?: (payload: any) => unknown;
306
305
  slots?: () => Readonly<any>;
307
- state?: any;
306
+ state: any;
308
307
  source?: string;
309
308
  responsiveDisabled?: boolean;
309
+ autoPropsDisabled?: boolean;
310
310
  configReady?: boolean;
311
311
  previewReady?: boolean;
312
312
  }[];
@@ -332,12 +332,12 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
332
332
  title: string;
333
333
  icon?: string;
334
334
  iconColor?: string;
335
- initState?: () => any;
336
335
  setupApp?: (payload: any) => unknown;
337
336
  slots?: () => Readonly<any>;
338
- state?: any;
337
+ state: any;
339
338
  source?: string;
340
339
  responsiveDisabled?: boolean;
340
+ autoPropsDisabled?: boolean;
341
341
  configReady?: boolean;
342
342
  previewReady?: boolean;
343
343
  };
@@ -348,12 +348,12 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
348
348
  title: string;
349
349
  icon?: string;
350
350
  iconColor?: string;
351
- initState?: () => any;
352
351
  setupApp?: (payload: any) => unknown;
353
352
  slots?: () => Readonly<any>;
354
- state?: any;
353
+ state: any;
355
354
  source?: string;
356
355
  responsiveDisabled?: boolean;
356
+ autoPropsDisabled?: boolean;
357
357
  configReady?: boolean;
358
358
  previewReady?: boolean;
359
359
  }>;
@@ -1,2 +1,2 @@
1
- export declare const isDark: import("vue").WritableComputedRef<boolean>;
1
+ export declare const isDark: import("vue-demi").WritableComputedRef<boolean>;
2
2
  export declare const toggleDark: (value?: boolean) => boolean;
@@ -1,10 +1,11 @@
1
1
  import { markRaw } from 'vue';
2
+ import { reactive as _reactive } from '@histoire/vendors/dist/client/vue';
2
3
  const copiedFromExistingVariant = [
3
4
  'state',
4
5
  'slots',
5
- 'initState',
6
6
  'source',
7
7
  'responsiveDisabled',
8
+ 'autoPropsDisabled',
8
9
  'setupApp',
9
10
  'configReady',
10
11
  'previewReady',
@@ -58,8 +59,7 @@ export function mapVariant(variant, existingVariant) {
58
59
  // Create
59
60
  result = {
60
61
  ...variant,
61
- state: null,
62
- initState: null,
62
+ state: _reactive({}),
63
63
  setupApp: null,
64
64
  slots: () => ({}),
65
65
  previewReady: false,
@@ -1 +1 @@
1
- export declare const isMobile: import("vue").Ref<boolean>;
1
+ export declare const isMobile: import("vue-demi").Ref<boolean>;
@@ -1,5 +1,5 @@
1
1
  import { watch, onMounted } from 'vue';
2
- import scrollIntoView from 'scroll-into-view-if-needed';
2
+ import { scrollIntoView } from 'scroll-into-view-if-needed';
3
3
  export function useScrollOnActive(active, el) {
4
4
  watch(active, value => {
5
5
  if (value) {
@@ -1 +1 @@
1
- export declare function toRawDeep(val: any, seen?: Set<unknown>): any;
1
+ export declare function toRawDeep(val: any, seen?: Map<any, any>): any;
@@ -1,24 +1,27 @@
1
1
  import { unref, isRef } from 'vue';
2
2
  const isObject = (val) => val !== null && typeof val === 'object';
3
- export function toRawDeep(val, seen = new Set()) {
3
+ export function toRawDeep(val, seen = new Map()) {
4
4
  const unwrappedValue = isRef(val) ? unref(val) : val;
5
- const valueType = typeof unwrappedValue;
6
- if (valueType === 'symbol' || valueType === 'function') {
5
+ if (typeof unwrappedValue === 'symbol') {
7
6
  return unwrappedValue.toString();
8
7
  }
9
8
  if (!isObject(unwrappedValue)) {
10
9
  return unwrappedValue;
11
10
  }
12
11
  if (seen.has(unwrappedValue)) {
13
- return Array.isArray(unwrappedValue) ? [] : {};
12
+ return seen.get(unwrappedValue);
14
13
  }
15
- seen.add(unwrappedValue);
14
+ let result;
16
15
  if (Array.isArray(unwrappedValue)) {
17
- return unwrappedValue.map(value => toRawDeep(value, seen));
16
+ result = unwrappedValue.map(value => toRawDeep(value, seen));
18
17
  }
19
- return toRawObject(unwrappedValue, seen);
18
+ else {
19
+ result = toRawObject(unwrappedValue, seen);
20
+ }
21
+ seen.set(unwrappedValue, result);
22
+ return result;
20
23
  }
21
- const toRawObject = (obj, seen = new Set()) => Object.keys(obj).reduce((raw, key) => {
24
+ const toRawObject = (obj, seen = new Map()) => Object.keys(obj).reduce((raw, key) => {
22
25
  raw[key] = toRawDeep(obj[key], seen);
23
26
  return raw;
24
27
  }, {});
@@ -81,7 +81,7 @@ export async function build(ctx) {
81
81
  const vuePlugin = config.plugins.find((p) => p.name === 'vite:vue');
82
82
  if (vuePlugin) {
83
83
  const original = vuePlugin.configureServer.bind(vuePlugin);
84
- vuePlugin.configureServer = (s) => {
84
+ vuePlugin.configureServer = () => {
85
85
  original({
86
86
  ...server,
87
87
  config: {
@@ -95,10 +95,20 @@ export function getDefaultConfig() {
95
95
  ],
96
96
  sandboxDarkClass: 'dark',
97
97
  routerMode: 'history',
98
- vite: {
99
- build: {
100
- lib: false,
101
- },
98
+ vite: (config) => {
99
+ // Remove vite:legacy plugins https://github.com/histoire-dev/histoire/issues/156
100
+ const index = config.plugins?.findIndex(plugin => Array.isArray(plugin) &&
101
+ typeof plugin[0] === 'object' &&
102
+ !Array.isArray(plugin[0]) &&
103
+ plugin[0].name.startsWith('vite:legacy'));
104
+ if (index !== -1) {
105
+ config.plugins?.splice(index, 1);
106
+ }
107
+ return {
108
+ build: {
109
+ lib: false,
110
+ },
111
+ };
102
112
  },
103
113
  };
104
114
  }
@@ -145,7 +155,16 @@ export async function loadConfigFile(configFile) {
145
155
  }
146
156
  export const mergeConfig = createDefu((obj, key, value) => {
147
157
  if (obj[key] && key === 'vite') {
148
- obj[key] = mergeViteConfig(obj[key], value);
158
+ const initialValue = obj[key];
159
+ if (typeof value === 'function') {
160
+ obj[key] = async (...args) => {
161
+ const result = await value(...args);
162
+ return mergeViteConfig(initialValue, result);
163
+ };
164
+ }
165
+ else {
166
+ obj[key] = mergeViteConfig(initialValue, value);
167
+ }
149
168
  return true;
150
169
  }
151
170
  if (obj[key] && key === 'plugins') {
@@ -17,4 +17,4 @@ export declare const RESOLVED_GENERATED_GLOBAL_SETUP: string;
17
17
  export declare const GENERATED_SETUP_CODE = "$histoire-generated-setup-code";
18
18
  export declare const RESOLVED_GENERATED_SETUP_CODE: string;
19
19
  export declare function resolveViteConfig(ctx: Context): Promise<ResolvedConfig>;
20
- export declare function getViteConfigWithPlugins(server: boolean, ctx: Context): Promise<InlineConfig>;
20
+ export declare function getViteConfigWithPlugins(isServer: boolean, ctx: Context): Promise<InlineConfig>;
package/dist/node/vite.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from 'module';
2
2
  import { relative, dirname, resolve } from 'pathe';
3
- import { resolveConfig as resolveViteConfigInternal, mergeConfig as mergeViteConfig, } from 'vite';
3
+ import { resolveConfig as resolveViteConfigInternal, mergeConfig as mergeViteConfig, loadConfigFromFile as loadViteConfigFromFile, } from 'vite';
4
4
  import { lookup as lookupMime } from 'mrmime';
5
5
  import { APP_PATH, DIST_PATH, TEMP_PATH } from './alias.js';
6
6
  import { notifyStoryChange } from './stories.js';
@@ -46,9 +46,10 @@ async function mergeHistoireViteConfig(viteConfig, ctx) {
46
46
  }
47
47
  return viteConfig;
48
48
  }
49
- export async function getViteConfigWithPlugins(server, ctx) {
49
+ export async function getViteConfigWithPlugins(isServer, ctx) {
50
50
  const resolvedViteConfig = await resolveViteConfig(ctx);
51
- const inlineConfig = await mergeHistoireViteConfig({}, ctx);
51
+ const userViteConfig = await loadViteConfigFromFile({ command: ctx.mode === 'dev' ? 'serve' : 'build', mode: ctx.mode });
52
+ const inlineConfig = await mergeHistoireViteConfig(userViteConfig.config ?? {}, ctx);
52
53
  const plugins = [];
53
54
  plugins.push({
54
55
  name: 'histoire-vite-plugin',
@@ -60,7 +61,7 @@ export async function getViteConfigWithPlugins(server, ctx) {
60
61
  ],
61
62
  },
62
63
  optimizeDeps: {
63
- disabled: server,
64
+ disabled: isServer,
64
65
  entries: [
65
66
  `${APP_PATH}/bundle-main.js`,
66
67
  `${APP_PATH}/bundle-sandbox.js`,
@@ -90,6 +91,8 @@ export async function getViteConfigWithPlugins(server, ctx) {
90
91
  define: {
91
92
  // We need to force this to be able to use `devtoolsRawSetupState`
92
93
  __VUE_PROD_DEVTOOLS__: 'true',
94
+ // Disable warnings
95
+ 'process.env.NODE_ENV': JSON.stringify(isServer ? 'production' : process.env.NODE_ENV ?? 'development'),
93
96
  },
94
97
  };
95
98
  },
@@ -256,6 +259,7 @@ if (import.meta.hot) {
256
259
  // Apply Vite HTML transforms. This injects the Vite HMR client, and
257
260
  // also applies HTML transforms from Vite plugins
258
261
  html = await server.transformIndexHtml(req.url, html);
262
+ res.setHeader('content-type', 'text/html; charset=UTF-8');
259
263
  res.end(html);
260
264
  return;
261
265
  }
@@ -285,6 +289,7 @@ if (import.meta.hot) {
285
289
  // Apply Vite HTML transforms. This injects the Vite HMR client, and
286
290
  // also applies HTML transforms from Vite plugins
287
291
  html = await server.transformIndexHtml(req.url, html);
292
+ res.setHeader('content-type', 'text/html; charset=UTF-8');
288
293
  res.end(html);
289
294
  return;
290
295
  }
@@ -315,6 +320,7 @@ if (import.meta.hot) {
315
320
  });
316
321
  }
317
322
  return mergeViteConfig(inlineConfig, {
323
+ configFile: false,
318
324
  plugins,
319
325
  });
320
326
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "histoire",
3
- "version": "0.7.9",
3
+ "version": "0.8.2",
4
4
  "description": "A fast story book powered by Vite",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -33,12 +33,12 @@
33
33
  "histoire": "./bin.mjs"
34
34
  },
35
35
  "dependencies": {
36
- "@histoire/controls": "^0.7.9",
37
- "@histoire/plugin-vue": "^0.7.9",
38
- "@histoire/shared": "^0.7.9",
39
- "@iconify/vue": "^3.2.1",
36
+ "@histoire/controls": "^0.8.2",
37
+ "@histoire/plugin-vue": "^0.8.2",
38
+ "@histoire/shared": "^0.8.2",
39
+ "@histoire/vendors": "^0.8.2",
40
+ "@types/flexsearch": "^0.7.3",
40
41
  "@types/markdown-it": "^12.2.3",
41
- "@vueuse/core": "^8.2.5",
42
42
  "birpc": "^0.1.1",
43
43
  "case": "^1.6.3",
44
44
  "chokidar": "^3.5.3",
@@ -46,7 +46,6 @@
46
46
  "defu": "^6.0.0",
47
47
  "diacritics": "^1.3.0",
48
48
  "flexsearch": "^0.7.21",
49
- "floating-vue": "^2.0.0-beta.16",
50
49
  "fs-extra": "^10.0.1",
51
50
  "globby": "^13.1.1",
52
51
  "happy-dom": "^2.55.0",
@@ -57,15 +56,11 @@
57
56
  "mrmime": "^1.0.0",
58
57
  "pathe": "^0.2.0",
59
58
  "picocolors": "^1.0.0",
60
- "pinia": "^2.0.13",
61
59
  "sade": "^1.8.1",
62
- "scroll-into-view-if-needed": "^2.2.29",
63
- "shiki": "^0.10.1",
60
+ "shiki": "0.10.1",
64
61
  "sirv": "^2.0.2",
65
62
  "tinypool": "^0.1.2",
66
- "vite-node": "0.12.1",
67
- "vue-router": "^4.0.14",
68
- "vue": "^3.2.31"
63
+ "vite-node": "0.12.1"
69
64
  },
70
65
  "peerDependencies": {
71
66
  "vite": "^2.9.0"
@@ -73,7 +68,6 @@
73
68
  "devDependencies": {
74
69
  "@peeky/test": "^0.13.5",
75
70
  "@tailwindcss/typography": "^0.5.2",
76
- "@types/flexsearch": "^0.7.3",
77
71
  "@types/fs-extra": "^9.0.13",
78
72
  "@types/markdown-it": "^12.2.3",
79
73
  "@types/node": "^17.0.32",
@@ -83,7 +77,7 @@
83
77
  "postcss": "^8.4.12",
84
78
  "postcss-import": "^14.1.0",
85
79
  "tailwindcss": "^3.0.23",
86
- "typescript": "^4.6.3",
80
+ "typescript": "^4.7.4",
87
81
  "vite": "^2.9.1",
88
82
  "vue": "^3.2.31"
89
83
  },
@@ -80,7 +80,6 @@ const loading = ref(false)
80
80
 
81
81
  if (import.meta.hot && !rawFiles.length) {
82
82
  loading.value = true
83
- console.log('loading...')
84
83
  import.meta.hot.on('histoire:all-stories-loaded', () => {
85
84
  loading.value = false
86
85
  })
@@ -6,7 +6,7 @@ import { Story, Tree } from '../../types'
6
6
  import MobileOverlay from './MobileOverlay.vue'
7
7
  import StoryList from '../tree/StoryList.vue'
8
8
 
9
- const props = defineProps<{
9
+ defineProps<{
10
10
  tree: Tree
11
11
  stories: Story[]
12
12
  }>()
@@ -1,7 +1,7 @@
1
1
  <script lang="ts" setup>
2
2
  import { Icon } from '@iconify/vue'
3
3
 
4
- const props = defineProps<{
4
+ defineProps<{
5
5
  title: string
6
6
  opened: boolean
7
7
  }>()