histoire 0.3.3 → 0.4.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/BaseEmpty.js +13 -0
- package/dist/bundled/HomeView.js +23 -0
- package/dist/bundled/MobileOverlay.js +303 -0
- package/dist/bundled/SearchPane.js +504 -0
- package/dist/bundled/StoryView.js +2330 -0
- package/dist/bundled/api.js +32 -0
- package/dist/bundled/config.js +4 -0
- package/dist/bundled/const.js +5 -0
- package/dist/bundled/dark.js +4 -0
- package/dist/bundled/events.js +29 -0
- package/dist/bundled/global-components.js +203 -0
- package/dist/bundled/index.js +7 -0
- package/dist/bundled/index2.js +762 -0
- package/dist/bundled/reactivity.js +96 -0
- package/dist/bundled/sandbox.js +97 -0
- package/dist/bundled/search-docs-data.js +7 -0
- package/dist/bundled/story.js +59 -0
- package/dist/bundled/style.css +102 -0
- package/dist/bundled/vue.runtime.esm-bundler.js +8657 -0
- package/dist/client/app/App.vue +2 -2
- package/dist/client/app/api.d.ts +1 -0
- package/dist/client/app/api.js +1 -0
- package/dist/client/app/codegen/vue3.js +1 -2
- package/dist/client/app/components/HomeView.vue +1 -1
- package/dist/client/app/components/app/AppLogo.vue +1 -1
- package/dist/client/app/components/app/MobileOverlay.vue +0 -1
- package/dist/client/app/components/base/BaseOverflowMenu.vue +1 -1
- package/dist/client/app/components/exposed/Story.vue +1 -1
- package/dist/client/app/components/search/SearchItem.vue +1 -1
- package/dist/client/app/components/search/SearchPane.vue +96 -21
- package/dist/client/app/components/search/search-docs-data.d.ts +3 -0
- package/dist/client/app/components/search/{search-data.js → search-docs-data.js} +1 -1
- package/dist/client/app/components/search/search-title-data.d.ts +3 -0
- package/dist/client/app/components/search/search-title-data.js +7 -0
- package/dist/client/app/components/search/{search-data.d.ts → types.d.ts} +0 -2
- package/dist/client/app/components/search/types.js +1 -0
- package/dist/client/app/components/story/StoryVariantGridItem.vue +1 -1
- package/dist/client/app/components/story/StoryVariantListItem.vue +1 -1
- package/dist/client/app/components/story/StoryVariantSinglePreviewNative.vue +6 -3
- package/dist/client/app/components/tree/StoryListItem.vue +1 -1
- package/dist/client/app/index.d.ts +1 -1
- package/dist/client/app/index.js +21 -18
- package/dist/client/app/sandbox.d.ts +1 -1
- package/dist/client/app/sandbox.js +0 -1
- package/dist/client/app/util/events.d.ts +1 -1
- package/dist/client/app/util/events.js +2 -2
- package/dist/client/bundle-index.js +5 -0
- package/dist/client/bundle-main.js +5 -0
- package/dist/client/bundle-sandbox.js +3 -0
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.js +1 -1
- package/dist/client/server/vue3/run.js +8 -0
- package/dist/node/alias.js +1 -1
- package/dist/node/build.js +4 -4
- package/dist/node/builtin-plugins/tailwind-tokens.js +1 -1
- package/dist/node/search.d.ts +9 -1
- package/dist/node/search.js +69 -32
- package/dist/node/server.js +2 -2
- package/dist/node/types.d.ts +1 -0
- package/dist/node/vite.d.ts +4 -2
- package/dist/node/vite.js +22 -29
- package/package.json +7 -6
- package/src/client/app/App.vue +2 -2
- package/src/client/app/api.ts +1 -0
- package/src/client/app/codegen/vue3.ts +1 -2
- package/src/client/app/components/HomeView.vue +1 -1
- package/src/client/app/components/app/AppLogo.vue +1 -1
- package/src/client/app/components/app/MobileOverlay.vue +0 -1
- package/src/client/app/components/base/BaseOverflowMenu.vue +1 -1
- package/src/client/app/components/exposed/Story.vue +1 -1
- package/src/client/app/components/search/SearchItem.vue +1 -1
- package/src/client/app/components/search/SearchPane.vue +96 -21
- package/src/client/app/components/search/{search-data.ts → search-docs-data.ts} +2 -6
- package/src/client/app/components/search/search-title-data.ts +10 -0
- package/src/client/app/components/search/types.ts +4 -0
- package/src/client/app/components/story/StoryVariantGridItem.vue +1 -1
- package/src/client/app/components/story/StoryVariantListItem.vue +1 -1
- package/src/client/app/components/story/StoryVariantSinglePreviewNative.vue +6 -3
- package/src/client/app/components/tree/StoryListItem.vue +1 -1
- package/src/client/app/index.ts +23 -19
- package/src/client/app/sandbox.ts +0 -1
- package/src/client/app/util/events.ts +2 -2
- package/src/client/bundle-index.js +5 -0
- package/src/client/bundle-main.js +5 -0
- package/src/client/bundle-sandbox.js +3 -0
- package/src/client/index.ts +1 -1
- package/src/client/server/vue3/run.ts +11 -0
- package/src/node/alias.ts +1 -1
- package/src/node/build.ts +4 -4
- package/src/node/builtin-plugins/tailwind-tokens.ts +1 -1
- package/src/node/search.ts +77 -33
- package/src/node/server.ts +2 -2
- package/src/node/types.ts +1 -0
- package/src/node/vite.ts +22 -30
- package/vite.config.ts +46 -0
|
@@ -4,7 +4,7 @@ import { useCurrentVariantRoute } from '../../util/variant'
|
|
|
4
4
|
import type { Variant } from '../../types'
|
|
5
5
|
import BaseListItemLink from '../base/BaseListItemLink.vue'
|
|
6
6
|
import { Icon } from '@iconify/vue'
|
|
7
|
-
import { useScrollOnActive } from '../../util/scroll
|
|
7
|
+
import { useScrollOnActive } from '../../util/scroll'
|
|
8
8
|
|
|
9
9
|
const props = defineProps({
|
|
10
10
|
variant: {
|
|
@@ -11,6 +11,7 @@ const props = defineProps<{
|
|
|
11
11
|
Object.assign(props.variant, {
|
|
12
12
|
previewReady: false,
|
|
13
13
|
})
|
|
14
|
+
|
|
14
15
|
function onReady () {
|
|
15
16
|
Object.assign(props.variant, {
|
|
16
17
|
previewReady: true,
|
|
@@ -25,13 +26,15 @@ function onReady () {
|
|
|
25
26
|
>
|
|
26
27
|
<div
|
|
27
28
|
:style="isResponsiveEnabled ? {
|
|
28
|
-
width: finalWidth ? `${finalWidth}px` :
|
|
29
|
-
height: finalHeight ? `${finalHeight}px` :
|
|
30
|
-
} :
|
|
29
|
+
width: finalWidth ? `${finalWidth}px` : '100%',
|
|
30
|
+
height: finalHeight ? `${finalHeight}px` : '100%',
|
|
31
|
+
} : { width: '100%', height: '100%' }"
|
|
31
32
|
>
|
|
32
33
|
<SandboxVue3
|
|
34
|
+
:key="`${story.id}-${variant.id}`"
|
|
33
35
|
:variant="variant"
|
|
34
36
|
:story="story"
|
|
37
|
+
class="htw-h-full"
|
|
35
38
|
@ready="onReady"
|
|
36
39
|
/>
|
|
37
40
|
</div>
|
|
@@ -4,7 +4,7 @@ import BaseListItemLink from '../base/BaseListItemLink.vue'
|
|
|
4
4
|
import { Icon } from '@iconify/vue'
|
|
5
5
|
import { computed, ref, withDefaults } from 'vue'
|
|
6
6
|
import { useRoute } from 'vue-router'
|
|
7
|
-
import { useScrollOnActive } from '../../util/scroll
|
|
7
|
+
import { useScrollOnActive } from '../../util/scroll'
|
|
8
8
|
|
|
9
9
|
const props = withDefaults(defineProps<{
|
|
10
10
|
story: Story
|
package/src/client/app/index.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
/* eslint-disable import/first */
|
|
2
|
+
|
|
3
|
+
// export * from 'vue'
|
|
3
4
|
|
|
5
|
+
import '$histoire-theme'
|
|
4
6
|
import { createApp } from 'vue'
|
|
5
7
|
import { createPinia } from 'pinia'
|
|
6
8
|
import FloatingVue from 'floating-vue'
|
|
@@ -8,21 +10,23 @@ import App from './App.vue'
|
|
|
8
10
|
import { registerGlobalComponents } from './global-components.js'
|
|
9
11
|
import { router } from './router'
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
app
|
|
13
|
-
app.use(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
export function mountMainApp () {
|
|
14
|
+
const app = createApp(App)
|
|
15
|
+
app.use(createPinia())
|
|
16
|
+
app.use(FloatingVue, {
|
|
17
|
+
overflowPadding: 4,
|
|
18
|
+
arrowPadding: 8,
|
|
19
|
+
themes: {
|
|
20
|
+
tooltip: {
|
|
21
|
+
distance: 8,
|
|
22
|
+
},
|
|
23
|
+
dropdown: {
|
|
24
|
+
computeTransformOrigin: true,
|
|
25
|
+
distance: 8,
|
|
26
|
+
},
|
|
23
27
|
},
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
app
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
})
|
|
29
|
+
app.use(router)
|
|
30
|
+
registerGlobalComponents(app)
|
|
31
|
+
app.mount('#app')
|
|
32
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { useEventsStore } from '../stores/events.js'
|
|
2
1
|
import { EVENT_SEND } from './const'
|
|
3
2
|
|
|
4
|
-
export function hstEvent (name: string, argument) {
|
|
3
|
+
export async function hstEvent (name: string, argument) {
|
|
5
4
|
console.log('[histoire] Event fired', { name, argument })
|
|
6
5
|
const event = {
|
|
7
6
|
name,
|
|
@@ -13,6 +12,7 @@ export function hstEvent (name: string, argument) {
|
|
|
13
12
|
event,
|
|
14
13
|
})
|
|
15
14
|
} else {
|
|
15
|
+
const { useEventsStore } = await import('../stores/events.js')
|
|
16
16
|
useEventsStore().addEvent(event)
|
|
17
17
|
}
|
|
18
18
|
}
|
package/src/client/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ import * as setup from '$histoire-setup'
|
|
|
8
8
|
|
|
9
9
|
export async function run ({ file, storyData, el }: ServerRunPayload) {
|
|
10
10
|
const { default: Comp } = await import(file.moduleId)
|
|
11
|
+
|
|
11
12
|
const app = createApp({
|
|
12
13
|
provide: {
|
|
13
14
|
addStory (data) {
|
|
@@ -34,5 +35,15 @@ export async function run ({ file, storyData, el }: ServerRunPayload) {
|
|
|
34
35
|
registerVueComponents(app)
|
|
35
36
|
|
|
36
37
|
app.mount(el)
|
|
38
|
+
|
|
39
|
+
if (Comp.doc) {
|
|
40
|
+
const el = document.createElement('div')
|
|
41
|
+
el.innerHTML = Comp.doc
|
|
42
|
+
const text = el.textContent
|
|
43
|
+
storyData.forEach(s => {
|
|
44
|
+
s.docsText = text
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
37
48
|
app.unmount()
|
|
38
49
|
}
|
package/src/node/alias.ts
CHANGED
|
@@ -4,6 +4,6 @@ import { fileURLToPath } from 'url'
|
|
|
4
4
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
5
5
|
|
|
6
6
|
export const DIST_PATH = join(__dirname, '../')
|
|
7
|
-
export const APP_PATH = join(DIST_PATH, 'client'
|
|
7
|
+
export const APP_PATH = join(DIST_PATH, 'client')
|
|
8
8
|
|
|
9
9
|
export const TEMP_PATH = join(process.cwd(), 'node_modules', '.histoire')
|
package/src/node/build.ts
CHANGED
|
@@ -67,8 +67,8 @@ export async function build (ctx: Context) {
|
|
|
67
67
|
build: {
|
|
68
68
|
rollupOptions: {
|
|
69
69
|
input: [
|
|
70
|
-
join(APP_PATH, '
|
|
71
|
-
join(APP_PATH, 'sandbox.js'),
|
|
70
|
+
join(APP_PATH, 'bundle-main.js'),
|
|
71
|
+
join(APP_PATH, 'bundle-sandbox.js'),
|
|
72
72
|
],
|
|
73
73
|
output: {
|
|
74
74
|
manualChunks (id) {
|
|
@@ -101,14 +101,14 @@ export async function build (ctx: Context) {
|
|
|
101
101
|
const prefetchHtml = generateScriptLinks(prefetchOutputs.map(o => o.fileName), 'prefetch', ctx, resolvedViteConfig)
|
|
102
102
|
|
|
103
103
|
// Index
|
|
104
|
-
const indexOutput = result.output.find(o => o.name === '
|
|
104
|
+
const indexOutput = result.output.find(o => o.name === 'bundle-main' && o.type === 'chunk')
|
|
105
105
|
const indexHtml = generateEntryHtml(indexOutput.fileName, styleOutput.fileName, {
|
|
106
106
|
HEAD: `${preloadHtml}${prefetchHtml}`,
|
|
107
107
|
}, ctx, resolvedViteConfig)
|
|
108
108
|
await writeFile('index.html', indexHtml, ctx)
|
|
109
109
|
|
|
110
110
|
// Sandbox
|
|
111
|
-
const sandboxOutput = result.output.find(o => o.name === 'sandbox' && o.type === 'chunk')
|
|
111
|
+
const sandboxOutput = result.output.find(o => o.name === 'bundle-sandbox' && o.type === 'chunk')
|
|
112
112
|
const sandboxHtml = generateEntryHtml(sandboxOutput.fileName, styleOutput.fileName, {}, ctx, resolvedViteConfig)
|
|
113
113
|
await writeFile('__sandbox.html', sandboxHtml, ctx)
|
|
114
114
|
|
|
@@ -94,7 +94,7 @@ defineExpose({
|
|
|
94
94
|
})
|
|
95
95
|
</script>
|
|
96
96
|
<template>
|
|
97
|
-
<Story id="tailwind" title="Tailwind" group="design-system" icon="mdi:tailwind" responsiveDisabled>
|
|
97
|
+
<Story id="tailwind" title="Tailwind" group="design-system" icon="mdi:tailwind" responsiveDisabled :layout="{ type: 'single', iframe: false }">
|
|
98
98
|
<Variant id="background-color" title="Background Color" icon="carbon:color-palette">
|
|
99
99
|
<HstColorShades
|
|
100
100
|
v-for="(shades, key) of config.theme.backgroundColor"
|
package/src/node/search.ts
CHANGED
|
@@ -7,23 +7,69 @@ import { loadModule } from './load.js'
|
|
|
7
7
|
|
|
8
8
|
const require = createRequire(import.meta.url)
|
|
9
9
|
|
|
10
|
-
export async function
|
|
11
|
-
|
|
12
|
-
const
|
|
10
|
+
export async function generateTitleSearchData (ctx: Context) {
|
|
11
|
+
const searchIndex = await createIndex()
|
|
12
|
+
const { idMap, addToIdMap } = createIdMap()
|
|
13
|
+
|
|
14
|
+
for (const storyFile of ctx.storyFiles) {
|
|
15
|
+
if (storyFile.story) {
|
|
16
|
+
searchIndex.add({
|
|
17
|
+
id: addToIdMap(storyFile.story.id, 'story'),
|
|
18
|
+
text: convertTitleToSentence(storyFile.story.title),
|
|
19
|
+
})
|
|
20
|
+
for (const variant of storyFile.story.variants) {
|
|
21
|
+
searchIndex.add({
|
|
22
|
+
id: addToIdMap(`${storyFile.story.id}:${variant.id}`, 'variant'),
|
|
23
|
+
text: convertTitleToSentence(`${storyFile.story.title} ${variant.title}`),
|
|
24
|
+
})
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
index: await exportSearchIndex(searchIndex),
|
|
31
|
+
idMap,
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export async function generateDocSearchData (ctx: Context) {
|
|
36
|
+
const searchIndex = await createIndex()
|
|
37
|
+
const { idMap, addToIdMap } = createIdMap()
|
|
38
|
+
|
|
39
|
+
for (const storyFile of ctx.storyFiles) {
|
|
40
|
+
if (storyFile.story && storyFile.story.docsText) {
|
|
41
|
+
searchIndex.add({
|
|
42
|
+
id: addToIdMap(storyFile.story.id, 'story'),
|
|
43
|
+
text: storyFile.story.docsText,
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return {
|
|
49
|
+
index: await exportSearchIndex(searchIndex),
|
|
50
|
+
idMap,
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function createIndex () {
|
|
13
55
|
const flexsearchRoot = path.dirname(require.resolve('flexsearch/package.json'))
|
|
14
|
-
|
|
15
|
-
preset: '
|
|
56
|
+
return new flexsearch.Document({
|
|
57
|
+
preset: 'match',
|
|
16
58
|
document: {
|
|
17
59
|
id: 'id',
|
|
18
60
|
index: [
|
|
19
|
-
'
|
|
20
|
-
'docs',
|
|
61
|
+
'text',
|
|
21
62
|
],
|
|
22
63
|
},
|
|
23
64
|
charset: await loadModule(`${flexsearchRoot}/dist/module/lang/latin/advanced.js`),
|
|
24
65
|
language: await loadModule(`${flexsearchRoot}/dist/module/lang/en.js`),
|
|
25
66
|
tokenize: 'forward',
|
|
26
67
|
})
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function createIdMap () {
|
|
71
|
+
let uid = 0
|
|
72
|
+
const idMap: Record<number, { id: string, kind: string }> = {}
|
|
27
73
|
|
|
28
74
|
function addToIdMap (id: string, kind: string) {
|
|
29
75
|
const n = uid++
|
|
@@ -31,37 +77,17 @@ export async function generateSearchData (ctx: Context) {
|
|
|
31
77
|
return n
|
|
32
78
|
}
|
|
33
79
|
|
|
34
|
-
for (const storyFile of ctx.storyFiles) {
|
|
35
|
-
if (storyFile.story) {
|
|
36
|
-
searchIndex.add({
|
|
37
|
-
id: addToIdMap(storyFile.story.id, 'story'),
|
|
38
|
-
title: processTitle(storyFile.story.title),
|
|
39
|
-
docs: '', // @TODO
|
|
40
|
-
})
|
|
41
|
-
for (const variant of storyFile.story.variants) {
|
|
42
|
-
searchIndex.add({
|
|
43
|
-
id: addToIdMap(`${storyFile.story.id}:${variant.id}`, 'variant'),
|
|
44
|
-
title: processTitle(`${storyFile.story.title} ${variant.title}`),
|
|
45
|
-
docs: '', // @TODO
|
|
46
|
-
})
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
80
|
return {
|
|
52
|
-
index: await exportSearchIndex(searchIndex),
|
|
53
81
|
idMap,
|
|
82
|
+
addToIdMap,
|
|
54
83
|
}
|
|
55
84
|
}
|
|
56
85
|
|
|
57
86
|
const exportKeys = new Set([
|
|
58
87
|
'reg',
|
|
59
|
-
'
|
|
60
|
-
'
|
|
61
|
-
'
|
|
62
|
-
'docs.cfg',
|
|
63
|
-
'docs.map',
|
|
64
|
-
'docs.ctx',
|
|
88
|
+
'text.cfg',
|
|
89
|
+
'text.map',
|
|
90
|
+
'text.ctx',
|
|
65
91
|
'tag',
|
|
66
92
|
'store',
|
|
67
93
|
])
|
|
@@ -81,6 +107,24 @@ async function exportSearchIndex (index) {
|
|
|
81
107
|
})
|
|
82
108
|
}
|
|
83
109
|
|
|
84
|
-
function
|
|
85
|
-
return
|
|
110
|
+
function convertTitleToSentence (text: string) {
|
|
111
|
+
return text.split(' ').map(str => Case.lower(str)).join(' ')
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// @TODO clear handlers when SearchPane unmounts
|
|
115
|
+
export function getSearchDataJS (data: any) {
|
|
116
|
+
return `export let searchData = ${JSON.stringify(data)}
|
|
117
|
+
const handlers = []
|
|
118
|
+
export function onUpdate (cb) {
|
|
119
|
+
handlers.push(cb)
|
|
120
|
+
}
|
|
121
|
+
if (import.meta.hot) {
|
|
122
|
+
import.meta.hot.accept(newModule => {
|
|
123
|
+
searchData = newModule.searchData
|
|
124
|
+
handlers.forEach(h => {
|
|
125
|
+
h(newModule.searchData)
|
|
126
|
+
newModule.onUpdate(h)
|
|
127
|
+
})
|
|
128
|
+
})
|
|
129
|
+
}`
|
|
86
130
|
}
|
package/src/node/server.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createServer as createViteServer } from 'vite'
|
|
2
2
|
import { Context } from './context.js'
|
|
3
|
-
import { createVitePlugins,
|
|
3
|
+
import { createVitePlugins, RESOLVED_SEARCH_TITLE_DATA_ID, RESOLVED_STORIES_ID } from './vite.js'
|
|
4
4
|
import { notifyStoryChange, onStoryChange, watchStories } from './stories.js'
|
|
5
5
|
import { useCollectStories } from './collect/index.js'
|
|
6
6
|
import type { StoryFile } from './types.js'
|
|
@@ -112,7 +112,7 @@ export async function createServer (ctx: Context, port: number) {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
invalidateModule(RESOLVED_STORIES_ID)
|
|
115
|
-
invalidateModule(
|
|
115
|
+
invalidateModule(RESOLVED_SEARCH_TITLE_DATA_ID)
|
|
116
116
|
})
|
|
117
117
|
|
|
118
118
|
async function close () {
|
package/src/node/types.ts
CHANGED
package/src/node/vite.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { notifyStoryChange } from './stories.js'
|
|
|
8
8
|
import { makeTree } from './tree.js'
|
|
9
9
|
import { parseColor } from './colors.js'
|
|
10
10
|
import { createMarkdownRenderer } from './markdown.js'
|
|
11
|
-
import {
|
|
11
|
+
import { getSearchDataJS, generateDocSearchData, generateTitleSearchData } from './search.js'
|
|
12
12
|
|
|
13
13
|
const require = createRequire(import.meta.url)
|
|
14
14
|
|
|
@@ -20,19 +20,16 @@ export const CONFIG_ID = '$histoire-config'
|
|
|
20
20
|
export const RESOLVED_CONFIG_ID = `/${CONFIG_ID}-resolved`
|
|
21
21
|
export const THEME_ID = '$histoire-theme'
|
|
22
22
|
export const RESOLVED_THEME_ID = `/${THEME_ID}-resolved.css`
|
|
23
|
-
export const
|
|
24
|
-
export const
|
|
23
|
+
export const SEARCH_TITLE_DATA_ID = '$histoire-search-title-data'
|
|
24
|
+
export const RESOLVED_SEARCH_TITLE_DATA_ID = `/${SEARCH_TITLE_DATA_ID}-resolved`
|
|
25
|
+
export const SEARCH_DOCS_DATA_ID = '$histoire-search-docs-data'
|
|
26
|
+
export const RESOLVED_SEARCH_DOCS_DATA_ID = `/${SEARCH_DOCS_DATA_ID}-resolved`
|
|
25
27
|
|
|
26
28
|
export async function createVitePlugins (ctx: Context): Promise<VitePlugin[]> {
|
|
27
29
|
const viteConfig = await resolveViteConfig({}, ctx.mode === 'dev' ? 'serve' : 'build')
|
|
28
|
-
const hasVuePlugin = viteConfig.plugins.find(p => p.name === 'vite:vue')
|
|
29
30
|
|
|
30
31
|
const plugins: VitePlugin[] = []
|
|
31
32
|
|
|
32
|
-
if (!hasVuePlugin) {
|
|
33
|
-
plugins.push((await import('@vitejs/plugin-vue')).default())
|
|
34
|
-
}
|
|
35
|
-
|
|
36
33
|
if (ctx.config.vite) {
|
|
37
34
|
plugins.push({
|
|
38
35
|
name: 'histoire-vite-config-override',
|
|
@@ -51,14 +48,13 @@ export async function createVitePlugins (ctx: Context): Promise<VitePlugin[]> {
|
|
|
51
48
|
// force include vue to avoid duplicated copies when linked + optimized
|
|
52
49
|
include: [
|
|
53
50
|
'vue',
|
|
54
|
-
dirname(require.resolve('@vue/runtime-core/package.json')),
|
|
55
51
|
dirname(require.resolve('shiki/package.json')),
|
|
56
52
|
dirname(require.resolve('vscode-textmate/package.json')),
|
|
57
53
|
dirname(require.resolve('vscode-oniguruma/package.json')),
|
|
58
54
|
dirname(require.resolve('case/package.json')),
|
|
59
55
|
],
|
|
60
56
|
exclude: [
|
|
61
|
-
'histoire
|
|
57
|
+
'histoire',
|
|
62
58
|
],
|
|
63
59
|
},
|
|
64
60
|
server: {
|
|
@@ -92,8 +88,11 @@ export async function createVitePlugins (ctx: Context): Promise<VitePlugin[]> {
|
|
|
92
88
|
if (id.startsWith(THEME_ID)) {
|
|
93
89
|
return RESOLVED_THEME_ID
|
|
94
90
|
}
|
|
95
|
-
if (id.startsWith(
|
|
96
|
-
return
|
|
91
|
+
if (id.startsWith(SEARCH_TITLE_DATA_ID)) {
|
|
92
|
+
return RESOLVED_SEARCH_TITLE_DATA_ID
|
|
93
|
+
}
|
|
94
|
+
if (id.startsWith(SEARCH_DOCS_DATA_ID)) {
|
|
95
|
+
return RESOLVED_SEARCH_DOCS_DATA_ID
|
|
97
96
|
}
|
|
98
97
|
},
|
|
99
98
|
|
|
@@ -104,7 +103,10 @@ export async function createVitePlugins (ctx: Context): Promise<VitePlugin[]> {
|
|
|
104
103
|
return {
|
|
105
104
|
id: file.id,
|
|
106
105
|
path: file.treePath,
|
|
107
|
-
story:
|
|
106
|
+
story: {
|
|
107
|
+
...file.story,
|
|
108
|
+
docsText: undefined,
|
|
109
|
+
},
|
|
108
110
|
framework: 'vue3',
|
|
109
111
|
index,
|
|
110
112
|
}
|
|
@@ -152,21 +154,11 @@ if (import.meta.hot) {
|
|
|
152
154
|
css += '}'
|
|
153
155
|
return css
|
|
154
156
|
}
|
|
155
|
-
if (id ===
|
|
156
|
-
return
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
if (import.meta.hot) {
|
|
162
|
-
import.meta.hot.accept(newModule => {
|
|
163
|
-
searchData = newModule.searchData
|
|
164
|
-
handlers.forEach(h => {
|
|
165
|
-
h(newModule.searchData)
|
|
166
|
-
newModule.onUpdate(h)
|
|
167
|
-
})
|
|
168
|
-
})
|
|
169
|
-
}`
|
|
157
|
+
if (id === RESOLVED_SEARCH_TITLE_DATA_ID) {
|
|
158
|
+
return getSearchDataJS(await generateTitleSearchData(ctx))
|
|
159
|
+
}
|
|
160
|
+
if (id === RESOLVED_SEARCH_DOCS_DATA_ID) {
|
|
161
|
+
return getSearchDataJS(await generateDocSearchData(ctx))
|
|
170
162
|
}
|
|
171
163
|
},
|
|
172
164
|
|
|
@@ -201,7 +193,7 @@ if (import.meta.hot) {
|
|
|
201
193
|
}
|
|
202
194
|
}
|
|
203
195
|
</script>
|
|
204
|
-
<script type="module" src="/@fs/${APP_PATH}/sandbox.js"></script>
|
|
196
|
+
<script type="module" src="/@fs/${APP_PATH}/bundle-sandbox.js"></script>
|
|
205
197
|
</body>
|
|
206
198
|
</html>`
|
|
207
199
|
// Apply Vite HTML transforms. This injects the Vite HMR client, and
|
|
@@ -232,7 +224,7 @@ if (import.meta.hot) {
|
|
|
232
224
|
</head>
|
|
233
225
|
<body>
|
|
234
226
|
<div id="app"></div>
|
|
235
|
-
<script type="module" src="/@fs/${APP_PATH}/
|
|
227
|
+
<script type="module" src="/@fs/${APP_PATH}/bundle-main.js"></script>
|
|
236
228
|
</body>
|
|
237
229
|
</html>`
|
|
238
230
|
// Apply Vite HTML transforms. This injects the Vite HMR client, and
|
package/vite.config.ts
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { defineConfig } from 'vite'
|
|
2
|
+
import vue from '@vitejs/plugin-vue'
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
plugins: [
|
|
6
|
+
vue(),
|
|
7
|
+
],
|
|
8
|
+
|
|
9
|
+
build: {
|
|
10
|
+
emptyOutDir: false,
|
|
11
|
+
outDir: 'dist/bundled',
|
|
12
|
+
lib: {
|
|
13
|
+
entry: '',
|
|
14
|
+
formats: ['es'],
|
|
15
|
+
},
|
|
16
|
+
rollupOptions: {
|
|
17
|
+
external: [
|
|
18
|
+
/\$histoire/,
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
20
|
+
...Object.keys(require('./package.json').dependencies),
|
|
21
|
+
],
|
|
22
|
+
|
|
23
|
+
input: [
|
|
24
|
+
'src/client/app/api.ts',
|
|
25
|
+
'src/client/app/index.ts',
|
|
26
|
+
'src/client/app/sandbox.ts',
|
|
27
|
+
],
|
|
28
|
+
|
|
29
|
+
output: {
|
|
30
|
+
// manualChunks (id) {
|
|
31
|
+
// if (id.includes('node_modules')) {
|
|
32
|
+
// return 'vendor'
|
|
33
|
+
// }
|
|
34
|
+
// },
|
|
35
|
+
entryFileNames: '[name].js',
|
|
36
|
+
chunkFileNames: '[name].js',
|
|
37
|
+
assetFileNames: '[name][extname]',
|
|
38
|
+
hoistTransitiveImports: false,
|
|
39
|
+
},
|
|
40
|
+
treeshake: false,
|
|
41
|
+
preserveEntrySignatures: 'strict',
|
|
42
|
+
},
|
|
43
|
+
cssCodeSplit: false,
|
|
44
|
+
minify: false,
|
|
45
|
+
},
|
|
46
|
+
})
|