histoire 0.7.7 → 0.8.0
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.
- package/dist/bundled/App.js +166 -0
- package/dist/bundled/_virtual/plugin-vue_export-helper.js +8 -0
- package/dist/bundled/api.js +1 -32
- package/dist/bundled/assets/histoire-text-dark.js +2 -0
- package/dist/bundled/assets/histoire-text.js +2 -0
- package/dist/bundled/{HomeView.js → assets/histoire.js} +1 -23
- package/dist/bundled/components/HomeView.js +24 -0
- package/dist/bundled/components/app/AppHeader.js +67 -0
- package/dist/bundled/components/app/AppLogo.js +26 -0
- package/dist/bundled/components/app/Breadcrumb.js +95 -0
- package/dist/bundled/components/app/Breadcrumb.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/app/InitialLoading.js +48 -0
- package/dist/bundled/components/app/MobileOverlay.js +41 -0
- package/dist/bundled/components/base/BaseCheckbox.js +75 -0
- package/dist/bundled/{BaseEmpty.js → components/base/BaseEmpty.js} +4 -4
- package/dist/bundled/components/base/BaseEmpty.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/base/BaseListItemLink.js +50 -0
- package/dist/bundled/components/base/BaseOverflowMenu.js +97 -0
- package/dist/bundled/components/base/BaseOverflowTab.js +45 -0
- package/dist/bundled/components/base/BaseSelect.js +88 -0
- package/dist/bundled/{MobileOverlay.js → components/base/BaseSplitPane.js} +9 -130
- package/dist/bundled/components/base/BaseSplitPane.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/base/BaseTab.js +45 -0
- package/dist/bundled/components/misc/CheckerboardPattern.js +41 -0
- package/dist/bundled/components/misc/HatchedPattern.js +11 -0
- package/dist/bundled/components/misc/HatchedPattern.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/panel/ControlsComponentPropItem.js +98 -0
- package/dist/bundled/components/panel/ControlsComponentProps.js +42 -0
- package/dist/bundled/components/panel/PaneTabs.js +110 -0
- package/dist/bundled/components/panel/StatePresets.js +184 -0
- package/dist/bundled/components/panel/StoryControls.js +66 -0
- package/dist/bundled/components/panel/StoryDocs.js +48 -0
- package/dist/bundled/components/panel/StoryEvent.js +56 -0
- package/dist/bundled/components/panel/StoryEvents.js +49 -0
- package/dist/bundled/components/panel/StorySidePanel.js +68 -0
- package/dist/bundled/components/panel/StorySourceCode.js +110 -0
- package/dist/bundled/components/panel/StorySourceCode.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/search/SearchItem.js +113 -0
- package/dist/bundled/components/search/SearchItem.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/search/SearchLoading.js +19 -0
- package/dist/bundled/components/search/SearchModal.js +46 -0
- package/dist/bundled/components/search/SearchPane.js +263 -0
- package/dist/bundled/{search-docs-data.js → components/search/search-docs-data.js} +1 -1
- package/dist/bundled/components/search/search-title-data.js +7 -0
- package/dist/bundled/components/story/StoryResponsivePreview.js +180 -0
- package/dist/bundled/components/story/StoryResponsivePreview.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/story/StoryVariantGrid.js +94 -0
- package/dist/bundled/components/story/StoryVariantGridItem.js +106 -0
- package/dist/bundled/components/story/StoryVariantGridItem.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/story/StoryVariantListItem.js +58 -0
- package/dist/bundled/components/story/StoryVariantListItem.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/story/StoryVariantSingle.js +115 -0
- package/dist/bundled/components/story/StoryVariantSingle.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/story/StoryVariantSinglePreviewNative.js +43 -0
- package/dist/bundled/components/story/StoryVariantSinglePreviewRemote.js +119 -0
- package/dist/bundled/components/story/StoryVariantSingleView.js +49 -0
- package/dist/bundled/components/story/StoryView.js +107 -0
- package/dist/bundled/components/story/StoryViewer.js +57 -0
- package/dist/bundled/components/story/StoryViewer.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/toolbar/StoryVariantBackground.js +85 -0
- package/dist/bundled/components/toolbar/StoryVariantBackground.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/toolbar/StoryVariantNewTab.js +33 -0
- package/dist/bundled/components/toolbar/StoryVariantResponsiveSize.js +129 -0
- package/dist/bundled/components/toolbar/StoryVariantTitle.js +24 -0
- package/dist/bundled/components/tree/StoryGroup.js +74 -0
- package/dist/bundled/components/tree/StoryList.js +37 -0
- package/dist/bundled/components/tree/StoryListFolder.js +89 -0
- package/dist/bundled/components/tree/StoryListFolder.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/components/tree/StoryListItem.js +72 -0
- package/dist/bundled/components/tree/StoryListItem.vue_vue_type_style_index_0_scoped_true_lang.js +2 -0
- package/dist/bundled/index.js +28 -5
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/common.js +40 -0
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/en.js +5 -0
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/advanced.js +11 -0
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/balance.js +26 -0
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang/latin/simple.js +10 -0
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/lang.js +50 -0
- package/dist/bundled/node_modules/.pnpm/flexsearch@0.7.21/node_modules/flexsearch/dist/module/type.js +8 -0
- package/dist/bundled/router.js +28 -0
- package/dist/bundled/sandbox.js +11 -14
- package/dist/bundled/{events.js → stores/events.js} +3 -3
- package/dist/bundled/stores/folder.js +46 -0
- package/dist/bundled/stores/preview-settings.js +15 -0
- package/dist/bundled/{story.js → stores/story.js} +4 -30
- package/dist/bundled/style.css +56 -56
- package/dist/bundled/{config.js → util/config.js} +1 -1
- package/dist/bundled/{const.js → util/const.js} +1 -1
- package/dist/bundled/util/dark.js +4 -0
- package/dist/bundled/util/env.js +2 -0
- package/dist/bundled/util/events.js +32 -0
- package/dist/bundled/util/keyboard.js +84 -0
- package/dist/bundled/{mapping.js → util/mapping.js} +5 -5
- package/dist/bundled/util/preview-settings.js +6 -0
- package/dist/bundled/util/responsive.js +3 -0
- package/dist/bundled/util/sandbox.js +8 -0
- package/dist/bundled/util/scroll.js +28 -0
- package/dist/bundled/{state.js → util/state.js} +4 -3
- package/dist/bundled/util/tooltip.js +12 -0
- package/dist/bundled/util/variant.js +35 -0
- package/dist/client/app/App.vue +0 -1
- package/dist/client/app/components/app/Breadcrumb.vue +1 -1
- package/dist/client/app/components/app/MobileOverlay.vue +1 -1
- package/dist/client/app/components/base/BaseCheckbox.vue +2 -1
- package/dist/client/app/components/base/BaseCopyIcon.vue +34 -0
- package/dist/client/app/components/base/BaseOverflowMenu.vue +1 -0
- package/dist/client/app/components/base/BaseSplitPane.vue +1 -0
- package/dist/client/app/components/panel/StatePresets.vue +3 -3
- package/dist/client/app/components/panel/StorySidePanel.vue +1 -1
- package/dist/client/app/components/story/StoryVariantGridItem.vue +1 -0
- package/dist/client/app/components/story/StoryVariantSingle.vue +5 -7
- package/dist/client/app/components/story/StoryVariantSinglePreviewRemote.vue +3 -6
- package/dist/client/app/components/story/StoryViewer.vue +2 -2
- package/dist/client/app/components/tree/StoryList.vue +1 -1
- package/dist/client/app/components/tree/StoryListItem.vue +2 -2
- package/dist/client/app/index.js +1 -3
- package/dist/client/app/sandbox.js +3 -2
- package/dist/client/app/stores/story.d.ts +30 -30
- package/dist/client/app/util/dark.d.ts +1 -1
- package/dist/client/app/util/mapping.js +3 -3
- package/dist/client/app/util/responsive.d.ts +1 -1
- package/dist/client/app/util/scroll.js +1 -1
- package/dist/client/app/util/state.js +2 -1
- package/dist/node/build.js +8 -1
- package/dist/node/commands/dev.js +1 -1
- package/dist/node/server.js +5 -4
- package/dist/node/util/log.d.ts +1 -0
- package/dist/node/util/log.js +9 -0
- package/dist/node/vite.d.ts +1 -1
- package/dist/node/vite.js +5 -3
- package/dist/style.css +21 -0
- package/index.d.ts +0 -2
- package/package.json +8 -15
- package/src/client/app/App.vue +0 -1
- package/src/client/app/components/app/Breadcrumb.vue +1 -1
- package/src/client/app/components/app/MobileOverlay.vue +1 -1
- package/src/client/app/components/base/BaseCheckbox.vue +2 -1
- package/src/client/app/components/base/BaseCopyIcon.vue +34 -0
- package/src/client/app/components/base/BaseOverflowMenu.vue +1 -0
- package/src/client/app/components/base/BaseSplitPane.vue +1 -0
- package/src/client/app/components/panel/StatePresets.vue +3 -3
- package/src/client/app/components/panel/StorySidePanel.vue +1 -1
- package/src/client/app/components/story/StoryVariantGridItem.vue +1 -0
- package/src/client/app/components/story/StoryVariantSingle.vue +5 -7
- package/src/client/app/components/story/StoryVariantSinglePreviewRemote.vue +3 -6
- package/src/client/app/components/story/StoryViewer.vue +2 -2
- package/src/client/app/components/tree/StoryList.vue +1 -1
- package/src/client/app/components/tree/StoryListItem.vue +2 -2
- package/src/client/app/index.ts +1 -5
- package/src/client/app/sandbox.ts +3 -2
- package/src/client/app/util/mapping.ts +3 -3
- package/src/client/app/util/scroll.ts +1 -1
- package/src/client/app/util/state.ts +2 -1
- package/src/node/build.ts +13 -3
- package/src/node/commands/dev.ts +1 -1
- package/src/node/server.ts +5 -4
- package/src/node/util/log.ts +9 -0
- package/src/node/vite.ts +5 -3
- package/tsconfig.json +12 -0
- package/vite.config.ts +21 -10
- package/vue.d.ts +1 -0
- package/dist/bundled/SearchPane.js +0 -506
- package/dist/bundled/StoryView.js +0 -2264
- package/dist/bundled/dark.js +0 -4
- package/dist/bundled/index2.js +0 -843
|
@@ -9,6 +9,7 @@ const props = defineProps({
|
|
|
9
9
|
})
|
|
10
10
|
|
|
11
11
|
const emit = defineEmits({
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
12
13
|
'update:modelValue': (newValue: boolean) => true,
|
|
13
14
|
})
|
|
14
15
|
|
|
@@ -25,7 +26,7 @@ const progress = computed(() => props.modelValue ? 1 : 0)
|
|
|
25
26
|
const dashoffset = computed(() => (1 - progress.value) * dasharray.value)
|
|
26
27
|
const animationEnabled = ref(false)
|
|
27
28
|
|
|
28
|
-
watch(path,
|
|
29
|
+
watch(path, () => {
|
|
29
30
|
dasharray.value = path.value.getTotalLength?.() ?? 21.21
|
|
30
31
|
})
|
|
31
32
|
</script>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
export default {
|
|
3
|
+
name: 'HstCopyIcon',
|
|
4
|
+
}
|
|
5
|
+
</script>
|
|
6
|
+
|
|
7
|
+
<script lang="ts" setup>
|
|
8
|
+
import { Icon } from '@iconify/vue'
|
|
9
|
+
import { useClipboard } from '@vueuse/core'
|
|
10
|
+
import { VTooltip as vTooltip } from 'floating-vue'
|
|
11
|
+
|
|
12
|
+
const props = defineProps<{
|
|
13
|
+
content: string
|
|
14
|
+
}>()
|
|
15
|
+
|
|
16
|
+
const { copy, copied } = useClipboard()
|
|
17
|
+
|
|
18
|
+
const action = () => copy(props.content)
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<template>
|
|
22
|
+
<Icon
|
|
23
|
+
v-tooltip="{
|
|
24
|
+
content: 'Copied!',
|
|
25
|
+
triggers: [],
|
|
26
|
+
shown: copied,
|
|
27
|
+
distance: 12,
|
|
28
|
+
delay: 0,
|
|
29
|
+
}"
|
|
30
|
+
icon="carbon:copy-file"
|
|
31
|
+
class="htw-w-4 htw-h-4 htw-opacity-50 hover:htw-opacity-100 hover:htw-text-primary-500 htw-cursor-pointer"
|
|
32
|
+
@click="action()"
|
|
33
|
+
/>
|
|
34
|
+
</template>
|
|
@@ -2,7 +2,7 @@
|
|
|
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 {
|
|
5
|
+
import { applyState, clone, omit } from '@histoire/shared'
|
|
6
6
|
import BaseSelect from '../base/BaseSelect.vue'
|
|
7
7
|
import { toRawDeep } from '../../util/state'
|
|
8
8
|
import type { Story, Variant } from '../../types'
|
|
@@ -40,14 +40,14 @@ const presetsOptions = computed(() => {
|
|
|
40
40
|
|
|
41
41
|
function resetState () {
|
|
42
42
|
selectedOption.value = DEFAULT_ID
|
|
43
|
-
|
|
43
|
+
applyState(props.variant.state, clone(defaultState))
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
function applyPreset (id) {
|
|
47
47
|
if (id === DEFAULT_ID) {
|
|
48
48
|
resetState()
|
|
49
49
|
} else if (presetStates.value.has(id)) {
|
|
50
|
-
|
|
50
|
+
applyState(props.variant.state, clone(presetStates.value.get(id).state))
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -32,7 +32,7 @@ const panelContentComponent = computed(() => {
|
|
|
32
32
|
<span>Select a variant</span>
|
|
33
33
|
</BaseEmpty>
|
|
34
34
|
|
|
35
|
-
<BaseEmpty v-else-if="!storyStore.currentVariant.previewReady">
|
|
35
|
+
<BaseEmpty v-else-if="!storyStore.currentVariant.configReady || !storyStore.currentVariant.previewReady">
|
|
36
36
|
<span>Loading...</span>
|
|
37
37
|
</BaseEmpty>
|
|
38
38
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import { computed
|
|
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 &&
|
|
23
|
+
v-if="hasSingleVariant && variant"
|
|
24
24
|
class="htw-p-2 htw-h-full"
|
|
25
25
|
>
|
|
26
26
|
<StoryVariantSingleView
|
|
27
|
-
|
|
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="(
|
|
80
|
+
v-for="(v, index) of storyStore.currentStory.variants"
|
|
83
81
|
:key="index"
|
|
84
|
-
: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,
|
|
2
|
+
import { computed, ref, toRaw, watch } from 'vue'
|
|
3
3
|
import { useEventListener } from '@vueuse/core'
|
|
4
|
-
import {
|
|
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
|
-
|
|
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="(
|
|
42
|
+
v-for="(v, index) of storyStore.currentStory.variants"
|
|
43
43
|
:key="index"
|
|
44
|
-
:variant="
|
|
44
|
+
:variant="v"
|
|
45
45
|
/>
|
|
46
46
|
</MobileOverlay>
|
|
47
47
|
</template>
|
|
@@ -18,9 +18,9 @@ const filePadding = computed(() => {
|
|
|
18
18
|
})
|
|
19
19
|
|
|
20
20
|
const route = useRoute()
|
|
21
|
-
const
|
|
21
|
+
const isActive = computed(() => route.params.storyId === props.story.id)
|
|
22
22
|
const el = ref<HTMLDivElement>()
|
|
23
|
-
useScrollOnActive(
|
|
23
|
+
useScrollOnActive(isActive, el)
|
|
24
24
|
</script>
|
|
25
25
|
|
|
26
26
|
<template>
|
package/src/client/app/index.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
/* eslint-disable import/first */
|
|
2
|
-
|
|
3
|
-
// export * from 'vue'
|
|
4
|
-
|
|
5
1
|
import '$histoire-theme'
|
|
6
2
|
import { createApp } from 'vue'
|
|
7
3
|
import { createPinia } from 'pinia'
|
|
8
|
-
import FloatingVue from 'floating-vue'
|
|
4
|
+
import { FloatingVue } from 'floating-vue'
|
|
9
5
|
import App from './App.vue'
|
|
10
6
|
import { router } from './router'
|
|
11
7
|
|
|
@@ -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 {
|
|
4
|
+
import { applyState } from '@histoire/shared'
|
|
5
5
|
import { SandboxVue3, MountStoryVue3 } from '@histoire/plugin-vue/client'
|
|
6
6
|
import type { StoryFile } from './types'
|
|
7
7
|
import { mapFile } from './util/mapping'
|
|
@@ -27,10 +27,11 @@ const app = createApp({
|
|
|
27
27
|
let mounted = false
|
|
28
28
|
|
|
29
29
|
window.addEventListener('message', event => {
|
|
30
|
+
// console.log('[sandbox] received message', event.data)
|
|
30
31
|
if (event.data?.type === STATE_SYNC) {
|
|
31
32
|
if (!mounted) return
|
|
32
33
|
synced = true
|
|
33
|
-
|
|
34
|
+
applyState(variant.value.state, event.data.state)
|
|
34
35
|
} else if (event.data?.type === PREVIEW_SETTINGS_SYNC) {
|
|
35
36
|
applyPreviewSettings(event.data.settings)
|
|
36
37
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { markRaw } from 'vue'
|
|
2
|
+
import { reactive as _reactive } from '@histoire/vendors/dist/client/vue'
|
|
2
3
|
import type { StoryFile, Variant } from '../types'
|
|
3
4
|
|
|
4
5
|
const copiedFromExistingVariant = [
|
|
5
6
|
'state',
|
|
6
7
|
'slots',
|
|
7
|
-
'initState',
|
|
8
8
|
'source',
|
|
9
9
|
'responsiveDisabled',
|
|
10
|
+
'autoPropsDisabled',
|
|
10
11
|
'setupApp',
|
|
11
12
|
'configReady',
|
|
12
13
|
'previewReady',
|
|
@@ -62,8 +63,7 @@ export function mapVariant (variant: Variant, existingVariant?: Variant): Varian
|
|
|
62
63
|
// Create
|
|
63
64
|
result = {
|
|
64
65
|
...variant,
|
|
65
|
-
state:
|
|
66
|
-
initState: null,
|
|
66
|
+
state: _reactive({}),
|
|
67
67
|
setupApp: null,
|
|
68
68
|
slots: () => ({}),
|
|
69
69
|
previewReady: false,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { watch, onMounted, Ref } from 'vue'
|
|
2
|
-
import scrollIntoView from 'scroll-into-view-if-needed'
|
|
2
|
+
import { scrollIntoView } from 'scroll-into-view-if-needed'
|
|
3
3
|
|
|
4
4
|
export function useScrollOnActive (active: Ref<boolean>, el: Ref<HTMLElement>) {
|
|
5
5
|
watch(active, value => {
|
|
@@ -4,8 +4,9 @@ const isObject = (val) => val !== null && typeof val === 'object'
|
|
|
4
4
|
|
|
5
5
|
export function toRawDeep (val, seen = new Set()) {
|
|
6
6
|
const unwrappedValue = isRef(val) ? unref(val) : val
|
|
7
|
+
const valueType = typeof unwrappedValue
|
|
7
8
|
|
|
8
|
-
if (
|
|
9
|
+
if (valueType === 'symbol' || valueType === 'function') {
|
|
9
10
|
return unwrappedValue.toString()
|
|
10
11
|
}
|
|
11
12
|
|
package/src/node/build.ts
CHANGED
|
@@ -2,8 +2,10 @@ import { join } from 'pathe'
|
|
|
2
2
|
import {
|
|
3
3
|
build as viteBuild,
|
|
4
4
|
createServer as createViteServer,
|
|
5
|
+
InlineConfig as ViteInlineConfig,
|
|
5
6
|
ResolvedConfig as ViteConfig,
|
|
6
7
|
mergeConfig as mergeViteConfig,
|
|
8
|
+
Plugin as VitePlugin,
|
|
7
9
|
} from 'vite'
|
|
8
10
|
import fs from 'fs-extra'
|
|
9
11
|
import { lookup as lookupMime } from 'mrmime'
|
|
@@ -65,7 +67,7 @@ export async function build (ctx: Context) {
|
|
|
65
67
|
const variantCount = ctx.storyFiles.reduce((sum, file) => sum + (file.story?.variants.length ?? 0), 0)
|
|
66
68
|
const emptyStoryCount = ctx.storyFiles.length - storyCount
|
|
67
69
|
|
|
68
|
-
const buildViteConfig = mergeViteConfig(await getViteConfigWithPlugins(false, ctx), {
|
|
70
|
+
const buildViteConfig: ViteInlineConfig = mergeViteConfig(await getViteConfigWithPlugins(false, ctx), {
|
|
69
71
|
mode: 'development',
|
|
70
72
|
build: {
|
|
71
73
|
rollupOptions: {
|
|
@@ -95,7 +97,7 @@ export async function build (ctx: Context) {
|
|
|
95
97
|
buildViteConfig.plugins.push({
|
|
96
98
|
name: 'histoire-vue-plugin-override',
|
|
97
99
|
config (config) {
|
|
98
|
-
const vuePlugin = config.plugins.find((p: any) => p.name === 'vite:vue')
|
|
100
|
+
const vuePlugin = config.plugins.find((p: any) => p.name === 'vite:vue') as VitePlugin
|
|
99
101
|
if (vuePlugin) {
|
|
100
102
|
const original = vuePlugin.configureServer.bind(vuePlugin)
|
|
101
103
|
vuePlugin.configureServer = () => {
|
|
@@ -110,11 +112,19 @@ export async function build (ctx: Context) {
|
|
|
110
112
|
},
|
|
111
113
|
})
|
|
112
114
|
}
|
|
113
|
-
vuePlugin.configureServer()
|
|
115
|
+
vuePlugin.configureServer(server)
|
|
114
116
|
}
|
|
115
117
|
},
|
|
116
118
|
})
|
|
117
119
|
|
|
120
|
+
buildViteConfig.plugins.push({
|
|
121
|
+
name: 'histoire-build-config-override',
|
|
122
|
+
config (config) {
|
|
123
|
+
// Don't externalize
|
|
124
|
+
config.build.rollupOptions.external = []
|
|
125
|
+
},
|
|
126
|
+
})
|
|
127
|
+
|
|
118
128
|
const results = await viteBuild(buildViteConfig)
|
|
119
129
|
const result = Array.isArray(results) ? results[0] : results as RollupOutput
|
|
120
130
|
|
package/src/node/commands/dev.ts
CHANGED
|
@@ -38,7 +38,7 @@ export async function devCommand (options: DevOptions) {
|
|
|
38
38
|
async function restart (source: string) {
|
|
39
39
|
if (stop) {
|
|
40
40
|
console.log(pc.blue(`${source} config changed, restarting...`))
|
|
41
|
-
stop()
|
|
41
|
+
await stop()
|
|
42
42
|
stop = null // Don't call stop again until new start() is done
|
|
43
43
|
stop = await start()
|
|
44
44
|
}
|
package/src/node/server.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { onStoryChange, watchStories } from './stories.js'
|
|
|
6
6
|
import { useCollectStories } from './collect/index.js'
|
|
7
7
|
import { DevPluginApi } from './plugin.js'
|
|
8
8
|
import { useModuleLoader } from './load.js'
|
|
9
|
+
import { wrapLogError } from './util/log.js'
|
|
9
10
|
|
|
10
11
|
export async function createServer (ctx: Context, port: number) {
|
|
11
12
|
const server = await createViteServer(await getViteConfigWithPlugins(false, ctx))
|
|
@@ -143,11 +144,11 @@ export async function createServer (ctx: Context, port: number) {
|
|
|
143
144
|
|
|
144
145
|
async function close () {
|
|
145
146
|
for (const cb of pluginOnCleanups) {
|
|
146
|
-
await cb()
|
|
147
|
+
await wrapLogError('plugin.onDev.onCleanup', () => cb())
|
|
147
148
|
}
|
|
148
|
-
await server.close()
|
|
149
|
-
await nodeServer.close()
|
|
150
|
-
await destroyCollectStories()
|
|
149
|
+
await wrapLogError('server.close', () => server.close())
|
|
150
|
+
await wrapLogError('nodeServer', () => nodeServer.close())
|
|
151
|
+
await wrapLogError('destroyCollectStories', () => destroyCollectStories())
|
|
151
152
|
}
|
|
152
153
|
|
|
153
154
|
return {
|
package/src/node/vite.ts
CHANGED
|
@@ -59,7 +59,7 @@ async function mergeHistoireViteConfig (viteConfig: InlineConfig, ctx: Context)
|
|
|
59
59
|
return viteConfig
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
export async function getViteConfigWithPlugins (
|
|
62
|
+
export async function getViteConfigWithPlugins (isServer: boolean, ctx: Context): Promise<InlineConfig> {
|
|
63
63
|
const resolvedViteConfig = await resolveViteConfig(ctx)
|
|
64
64
|
|
|
65
65
|
const inlineConfig = await mergeHistoireViteConfig({}, ctx)
|
|
@@ -76,7 +76,7 @@ export async function getViteConfigWithPlugins (server: boolean, ctx: Context):
|
|
|
76
76
|
],
|
|
77
77
|
},
|
|
78
78
|
optimizeDeps: {
|
|
79
|
-
disabled:
|
|
79
|
+
disabled: isServer,
|
|
80
80
|
entries: [
|
|
81
81
|
`${APP_PATH}/bundle-main.js`,
|
|
82
82
|
`${APP_PATH}/bundle-sandbox.js`,
|
|
@@ -100,12 +100,14 @@ export async function getViteConfigWithPlugins (server: boolean, ctx: Context):
|
|
|
100
100
|
allow: [DIST_PATH, TEMP_PATH, resolvedViteConfig.root, process.cwd()],
|
|
101
101
|
},
|
|
102
102
|
watch: {
|
|
103
|
-
ignored: [`!**/node_modules/.histoire
|
|
103
|
+
ignored: [`!**/node_modules/.histoire/**`, '**/vite.config.*'],
|
|
104
104
|
},
|
|
105
105
|
},
|
|
106
106
|
define: {
|
|
107
107
|
// We need to force this to be able to use `devtoolsRawSetupState`
|
|
108
108
|
__VUE_PROD_DEVTOOLS__: 'true',
|
|
109
|
+
// Disable warnings
|
|
110
|
+
'process.env.NODE_ENV': JSON.stringify(isServer ? 'production' : process.env.NODE_ENV ?? 'development'),
|
|
109
111
|
},
|
|
110
112
|
}
|
|
111
113
|
},
|
package/tsconfig.json
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"sourceMap": false,
|
|
22
22
|
"preserveWatchOutput": true,
|
|
23
23
|
"preserveSymlinks": true,
|
|
24
|
+
"declaration": true,
|
|
24
25
|
// Strict
|
|
25
26
|
"noImplicitAny": false,
|
|
26
27
|
"noImplicitThis": true,
|
|
@@ -29,6 +30,17 @@
|
|
|
29
30
|
"strictFunctionTypes": true,
|
|
30
31
|
// Volar
|
|
31
32
|
"jsx": "preserve",
|
|
33
|
+
// Alias
|
|
34
|
+
"paths": {
|
|
35
|
+
"floating-vue": ["./node_modules/@histoire/vendors/dist/client/floating-vue"],
|
|
36
|
+
"@iconify/vue": ["./node_modules/@histoire/vendors/dist/client/iconify"],
|
|
37
|
+
"pinia": ["./node_modules/@histoire/vendors/dist/client/pinia"],
|
|
38
|
+
"scroll-into-view-if-needed": ["./node_modules/@histoire/vendors/dist/client/scroll"],
|
|
39
|
+
"shiki": ["./node_modules/@histoire/vendors/dist/client/shiki"],
|
|
40
|
+
"vue-router": ["./node_modules/@histoire/vendors/dist/client/vue-router"],
|
|
41
|
+
"@vueuse/core": ["./node_modules/@histoire/vendors/dist/client/vue-use"],
|
|
42
|
+
"vue": ["./node_modules/@histoire/vendors/dist/client/vue"]
|
|
43
|
+
}
|
|
32
44
|
},
|
|
33
45
|
"include": [
|
|
34
46
|
"src"
|
package/vite.config.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { defineConfig } from 'vite'
|
|
2
2
|
import vue from '@vitejs/plugin-vue'
|
|
3
3
|
import fs from 'fs-extra'
|
|
4
|
-
import
|
|
4
|
+
import { globbySync } from 'globby'
|
|
5
5
|
|
|
6
6
|
export default defineConfig({
|
|
7
7
|
plugins: [
|
|
@@ -18,14 +18,11 @@ export default defineConfig({
|
|
|
18
18
|
},
|
|
19
19
|
closeBundle () {
|
|
20
20
|
try {
|
|
21
|
-
const files =
|
|
21
|
+
const files = globbySync('./dist/bundled/**/*.js')
|
|
22
22
|
for (const file of files) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (content.includes('import__meta')) {
|
|
27
|
-
fs.writeFileSync(filePath, content.replace(/import__meta/g, 'import.meta'), 'utf-8')
|
|
28
|
-
}
|
|
23
|
+
const content = fs.readFileSync(file, 'utf-8')
|
|
24
|
+
if (content.includes('import__meta')) {
|
|
25
|
+
fs.writeFileSync(file, content.replace(/import__meta/g, 'import.meta'), 'utf-8')
|
|
29
26
|
}
|
|
30
27
|
}
|
|
31
28
|
} catch (e) {
|
|
@@ -35,6 +32,19 @@ export default defineConfig({
|
|
|
35
32
|
},
|
|
36
33
|
],
|
|
37
34
|
|
|
35
|
+
resolve: {
|
|
36
|
+
alias: {
|
|
37
|
+
'floating-vue': '@histoire/vendors/dist/client/floating-vue.js',
|
|
38
|
+
'@iconify/vue': '@histoire/vendors/dist/client/iconify.js',
|
|
39
|
+
pinia: '@histoire/vendors/dist/client/pinia.js',
|
|
40
|
+
'scroll-into-view-if-needed': '@histoire/vendors/dist/client/scroll.js',
|
|
41
|
+
shiki: '@histoire/vendors/dist/client/shiki.js',
|
|
42
|
+
'vue-router': '@histoire/vendors/dist/client/vue-router.js',
|
|
43
|
+
'@vueuse/core': '@histoire/vendors/dist/client/vue-use.js',
|
|
44
|
+
vue: '@histoire/vendors/dist/client/vue.js',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
|
|
38
48
|
build: {
|
|
39
49
|
emptyOutDir: false,
|
|
40
50
|
outDir: 'dist/bundled',
|
|
@@ -46,7 +56,6 @@ export default defineConfig({
|
|
|
46
56
|
external: [
|
|
47
57
|
/\$histoire/,
|
|
48
58
|
/@histoire/,
|
|
49
|
-
/@vue\/*/,
|
|
50
59
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
51
60
|
...Object.keys(require('./package.json').dependencies),
|
|
52
61
|
],
|
|
@@ -66,7 +75,9 @@ export default defineConfig({
|
|
|
66
75
|
entryFileNames: '[name].js',
|
|
67
76
|
chunkFileNames: '[name].js',
|
|
68
77
|
assetFileNames: '[name][extname]',
|
|
69
|
-
hoistTransitiveImports: false,
|
|
78
|
+
// hoistTransitiveImports: false,
|
|
79
|
+
preserveModules: true,
|
|
80
|
+
preserveModulesRoot: 'src/client/app',
|
|
70
81
|
},
|
|
71
82
|
treeshake: false,
|
|
72
83
|
preserveEntrySignatures: 'strict',
|
package/vue.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@histoire/plugin-vue/components'
|