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.
- 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 +58 -58
- 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/util/state.js +27 -0
- 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/panel/StorySourceCode.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.d.ts +1 -1
- package/dist/client/app/util/state.js +11 -8
- package/dist/node/build.js +1 -1
- package/dist/node/config.js +24 -5
- package/dist/node/vite.d.ts +1 -1
- package/dist/node/vite.js +10 -4
- package/package.json +9 -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/panel/StorySourceCode.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 +11 -8
- package/src/node/build.ts +1 -1
- package/src/node/config.ts +24 -5
- package/src/node/vite.ts +11 -3
- package/tsconfig.json +11 -0
- package/vite.config.ts +20 -10
- 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
- package/dist/bundled/state.js +0 -25
|
@@ -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
|
|
|
@@ -19,7 +19,7 @@ const highlighter = shallowRef<Highlighter>()
|
|
|
19
19
|
const error = ref<string>(null)
|
|
20
20
|
|
|
21
21
|
onMounted(async () => {
|
|
22
|
-
setCDN('https://unpkg.com/shiki/')
|
|
22
|
+
setCDN('https://unpkg.com/shiki@0.10.1/')
|
|
23
23
|
highlighter.value = await getHighlighter({
|
|
24
24
|
langs: [
|
|
25
25
|
'html',
|
|
@@ -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 => {
|
|
@@ -2,11 +2,10 @@ import { unref, isRef } from 'vue'
|
|
|
2
2
|
|
|
3
3
|
const isObject = (val) => val !== null && typeof val === 'object'
|
|
4
4
|
|
|
5
|
-
export function toRawDeep (val, seen = new
|
|
5
|
+
export function toRawDeep (val, seen = new Map()) {
|
|
6
6
|
const unwrappedValue = isRef(val) ? unref(val) : val
|
|
7
|
-
const valueType = typeof unwrappedValue
|
|
8
7
|
|
|
9
|
-
if (
|
|
8
|
+
if (typeof unwrappedValue === 'symbol') {
|
|
10
9
|
return unwrappedValue.toString()
|
|
11
10
|
}
|
|
12
11
|
|
|
@@ -15,19 +14,23 @@ export function toRawDeep (val, seen = new Set()) {
|
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
if (seen.has(unwrappedValue)) {
|
|
18
|
-
return
|
|
17
|
+
return seen.get(unwrappedValue)
|
|
19
18
|
}
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
let result
|
|
22
21
|
|
|
23
22
|
if (Array.isArray(unwrappedValue)) {
|
|
24
|
-
|
|
23
|
+
result = unwrappedValue.map(value => toRawDeep(value, seen))
|
|
24
|
+
} else {
|
|
25
|
+
result = toRawObject(unwrappedValue, seen)
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
|
|
28
|
+
seen.set(unwrappedValue, result)
|
|
29
|
+
|
|
30
|
+
return result
|
|
28
31
|
}
|
|
29
32
|
|
|
30
|
-
const toRawObject = (obj: Record<any, any>, seen = new
|
|
33
|
+
const toRawObject = (obj: Record<any, any>, seen = new Map()) => Object.keys(obj).reduce((raw, key) => {
|
|
31
34
|
raw[key] = toRawDeep(obj[key], seen)
|
|
32
35
|
return raw
|
|
33
36
|
}, {})
|
package/src/node/build.ts
CHANGED
|
@@ -100,7 +100,7 @@ export async function build (ctx: Context) {
|
|
|
100
100
|
const vuePlugin = config.plugins.find((p: any) => p.name === 'vite:vue') as VitePlugin
|
|
101
101
|
if (vuePlugin) {
|
|
102
102
|
const original = vuePlugin.configureServer.bind(vuePlugin)
|
|
103
|
-
vuePlugin.configureServer = (
|
|
103
|
+
vuePlugin.configureServer = () => {
|
|
104
104
|
original({
|
|
105
105
|
...server,
|
|
106
106
|
config: {
|
package/src/node/config.ts
CHANGED
|
@@ -271,10 +271,21 @@ export function getDefaultConfig (): HistoireConfig {
|
|
|
271
271
|
],
|
|
272
272
|
sandboxDarkClass: 'dark',
|
|
273
273
|
routerMode: 'history',
|
|
274
|
-
vite: {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
274
|
+
vite: (config) => {
|
|
275
|
+
// Remove vite:legacy plugins https://github.com/histoire-dev/histoire/issues/156
|
|
276
|
+
const index = config.plugins?.findIndex(plugin => Array.isArray(plugin) &&
|
|
277
|
+
typeof plugin[0] === 'object' &&
|
|
278
|
+
!Array.isArray(plugin[0]) &&
|
|
279
|
+
plugin[0].name.startsWith('vite:legacy'))
|
|
280
|
+
if (index !== -1) {
|
|
281
|
+
config.plugins?.splice(index, 1)
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return {
|
|
285
|
+
build: {
|
|
286
|
+
lib: false,
|
|
287
|
+
},
|
|
288
|
+
}
|
|
278
289
|
},
|
|
279
290
|
}
|
|
280
291
|
}
|
|
@@ -324,7 +335,15 @@ export async function loadConfigFile (configFile: string): Promise<Partial<Histo
|
|
|
324
335
|
|
|
325
336
|
export const mergeConfig = createDefu((obj: any, key, value) => {
|
|
326
337
|
if (obj[key] && key === 'vite') {
|
|
327
|
-
|
|
338
|
+
const initialValue = obj[key]
|
|
339
|
+
if (typeof value === 'function') {
|
|
340
|
+
obj[key] = async (...args) => {
|
|
341
|
+
const result = await value(...args)
|
|
342
|
+
return mergeViteConfig(initialValue, result)
|
|
343
|
+
}
|
|
344
|
+
} else {
|
|
345
|
+
obj[key] = mergeViteConfig(initialValue, value)
|
|
346
|
+
}
|
|
328
347
|
return true
|
|
329
348
|
}
|
|
330
349
|
|
package/src/node/vite.ts
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
ResolvedConfig,
|
|
8
8
|
InlineConfig,
|
|
9
9
|
mergeConfig as mergeViteConfig,
|
|
10
|
+
loadConfigFromFile as loadViteConfigFromFile,
|
|
10
11
|
} from 'vite'
|
|
11
12
|
import { lookup as lookupMime } from 'mrmime'
|
|
12
13
|
import { APP_PATH, DIST_PATH, TEMP_PATH } from './alias.js'
|
|
@@ -59,10 +60,12 @@ async function mergeHistoireViteConfig (viteConfig: InlineConfig, ctx: Context)
|
|
|
59
60
|
return viteConfig
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
export async function getViteConfigWithPlugins (
|
|
63
|
+
export async function getViteConfigWithPlugins (isServer: boolean, ctx: Context): Promise<InlineConfig> {
|
|
63
64
|
const resolvedViteConfig = await resolveViteConfig(ctx)
|
|
64
65
|
|
|
65
|
-
const
|
|
66
|
+
const userViteConfig = await loadViteConfigFromFile({ command: ctx.mode === 'dev' ? 'serve' : 'build', mode: ctx.mode })
|
|
67
|
+
|
|
68
|
+
const inlineConfig = await mergeHistoireViteConfig(userViteConfig.config ?? {}, ctx)
|
|
66
69
|
const plugins: VitePlugin[] = []
|
|
67
70
|
|
|
68
71
|
plugins.push({
|
|
@@ -76,7 +79,7 @@ export async function getViteConfigWithPlugins (server: boolean, ctx: Context):
|
|
|
76
79
|
],
|
|
77
80
|
},
|
|
78
81
|
optimizeDeps: {
|
|
79
|
-
disabled:
|
|
82
|
+
disabled: isServer,
|
|
80
83
|
entries: [
|
|
81
84
|
`${APP_PATH}/bundle-main.js`,
|
|
82
85
|
`${APP_PATH}/bundle-sandbox.js`,
|
|
@@ -106,6 +109,8 @@ export async function getViteConfigWithPlugins (server: boolean, ctx: Context):
|
|
|
106
109
|
define: {
|
|
107
110
|
// We need to force this to be able to use `devtoolsRawSetupState`
|
|
108
111
|
__VUE_PROD_DEVTOOLS__: 'true',
|
|
112
|
+
// Disable warnings
|
|
113
|
+
'process.env.NODE_ENV': JSON.stringify(isServer ? 'production' : process.env.NODE_ENV ?? 'development'),
|
|
109
114
|
},
|
|
110
115
|
}
|
|
111
116
|
},
|
|
@@ -275,6 +280,7 @@ if (import.meta.hot) {
|
|
|
275
280
|
// Apply Vite HTML transforms. This injects the Vite HMR client, and
|
|
276
281
|
// also applies HTML transforms from Vite plugins
|
|
277
282
|
html = await server.transformIndexHtml(req.url, html)
|
|
283
|
+
res.setHeader('content-type', 'text/html; charset=UTF-8')
|
|
278
284
|
res.end(html)
|
|
279
285
|
return
|
|
280
286
|
}
|
|
@@ -306,6 +312,7 @@ if (import.meta.hot) {
|
|
|
306
312
|
// Apply Vite HTML transforms. This injects the Vite HMR client, and
|
|
307
313
|
// also applies HTML transforms from Vite plugins
|
|
308
314
|
html = await server.transformIndexHtml(req.url, html)
|
|
315
|
+
res.setHeader('content-type', 'text/html; charset=UTF-8')
|
|
309
316
|
res.end(html)
|
|
310
317
|
return
|
|
311
318
|
}
|
|
@@ -339,6 +346,7 @@ if (import.meta.hot) {
|
|
|
339
346
|
}
|
|
340
347
|
|
|
341
348
|
return mergeViteConfig(inlineConfig, {
|
|
349
|
+
configFile: false,
|
|
342
350
|
plugins,
|
|
343
351
|
}) as InlineConfig
|
|
344
352
|
}
|
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,16 @@
|
|
|
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
|
+
"vue-router": ["./node_modules/@histoire/vendors/dist/client/vue-router"],
|
|
40
|
+
"@vueuse/core": ["./node_modules/@histoire/vendors/dist/client/vue-use"],
|
|
41
|
+
"vue": ["./node_modules/@histoire/vendors/dist/client/vue"]
|
|
42
|
+
}
|
|
32
43
|
},
|
|
33
44
|
"include": [
|
|
34
45
|
"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,18 @@ 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
|
+
'vue-router': '@histoire/vendors/dist/client/vue-router.js',
|
|
42
|
+
'@vueuse/core': '@histoire/vendors/dist/client/vue-use.js',
|
|
43
|
+
vue: '@histoire/vendors/dist/client/vue.js',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
|
|
38
47
|
build: {
|
|
39
48
|
emptyOutDir: false,
|
|
40
49
|
outDir: 'dist/bundled',
|
|
@@ -46,7 +55,6 @@ export default defineConfig({
|
|
|
46
55
|
external: [
|
|
47
56
|
/\$histoire/,
|
|
48
57
|
/@histoire/,
|
|
49
|
-
/@vue\/*/,
|
|
50
58
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
51
59
|
...Object.keys(require('./package.json').dependencies),
|
|
52
60
|
],
|
|
@@ -66,7 +74,9 @@ export default defineConfig({
|
|
|
66
74
|
entryFileNames: '[name].js',
|
|
67
75
|
chunkFileNames: '[name].js',
|
|
68
76
|
assetFileNames: '[name][extname]',
|
|
69
|
-
hoistTransitiveImports: false,
|
|
77
|
+
// hoistTransitiveImports: false,
|
|
78
|
+
preserveModules: true,
|
|
79
|
+
preserveModulesRoot: 'src/client/app',
|
|
70
80
|
},
|
|
71
81
|
treeshake: false,
|
|
72
82
|
preserveEntrySignatures: 'strict',
|