histoire 0.3.3 → 0.4.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/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/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 +9 -9
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,7 +6,7 @@ import { useResizeObserver } from '@vueuse/core'
|
|
|
6
6
|
import { useCurrentVariantRoute } from '../../util/variant'
|
|
7
7
|
import type { Story, Variant } from '../../types'
|
|
8
8
|
import SandboxVue3 from '../sandbox/SandboxVue3.vue'
|
|
9
|
-
import { useScrollOnActive } from '../../util/scroll
|
|
9
|
+
import { useScrollOnActive } from '../../util/scroll'
|
|
10
10
|
|
|
11
11
|
const props = defineProps({
|
|
12
12
|
variant: {
|
|
@@ -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
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import '$histoire-theme';
|
|
2
|
-
|
|
2
|
+
export declare function mountMainApp(): void;
|
package/dist/client/app/index.js
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
|
+
/* eslint-disable import/first */
|
|
2
|
+
// export * from 'vue'
|
|
1
3
|
import '$histoire-theme';
|
|
2
|
-
import '../../style.css';
|
|
3
4
|
import { createApp } from 'vue';
|
|
4
5
|
import { createPinia } from 'pinia';
|
|
5
6
|
import FloatingVue from 'floating-vue';
|
|
6
7
|
import App from './App.vue';
|
|
7
8
|
import { registerGlobalComponents } from './global-components.js';
|
|
8
9
|
import { router } from './router';
|
|
9
|
-
|
|
10
|
-
app
|
|
11
|
-
app.use(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
export function mountMainApp() {
|
|
11
|
+
const app = createApp(App);
|
|
12
|
+
app.use(createPinia());
|
|
13
|
+
app.use(FloatingVue, {
|
|
14
|
+
overflowPadding: 4,
|
|
15
|
+
arrowPadding: 8,
|
|
16
|
+
themes: {
|
|
17
|
+
tooltip: {
|
|
18
|
+
distance: 8,
|
|
19
|
+
},
|
|
20
|
+
dropdown: {
|
|
21
|
+
computeTransformOrigin: true,
|
|
22
|
+
distance: 8,
|
|
23
|
+
},
|
|
17
24
|
},
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
});
|
|
24
|
-
app.use(router);
|
|
25
|
-
registerGlobalComponents(app);
|
|
26
|
-
app.mount('#app');
|
|
25
|
+
});
|
|
26
|
+
app.use(router);
|
|
27
|
+
registerGlobalComponents(app);
|
|
28
|
+
app.mount('#app');
|
|
29
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function hstEvent(name: string, argument: any): void
|
|
1
|
+
export declare function hstEvent(name: string, argument: any): Promise<void>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { useEventsStore } from '../stores/events.js';
|
|
2
1
|
import { EVENT_SEND } from './const';
|
|
3
|
-
export function hstEvent(name, argument) {
|
|
2
|
+
export async function hstEvent(name, argument) {
|
|
4
3
|
console.log('[histoire] Event fired', { name, argument });
|
|
5
4
|
const event = {
|
|
6
5
|
name,
|
|
@@ -13,6 +12,7 @@ export function hstEvent(name, argument) {
|
|
|
13
12
|
});
|
|
14
13
|
}
|
|
15
14
|
else {
|
|
15
|
+
const { useEventsStore } = await import('../stores/events.js');
|
|
16
16
|
useEventsStore().addEvent(event);
|
|
17
17
|
}
|
|
18
18
|
}
|
package/dist/client/index.d.ts
CHANGED
package/dist/client/index.js
CHANGED
|
@@ -28,5 +28,13 @@ export async function run({ file, storyData, el }) {
|
|
|
28
28
|
app.component('Variant', Variant);
|
|
29
29
|
registerVueComponents(app);
|
|
30
30
|
app.mount(el);
|
|
31
|
+
if (Comp.doc) {
|
|
32
|
+
const el = document.createElement('div');
|
|
33
|
+
el.innerHTML = Comp.doc;
|
|
34
|
+
const text = el.textContent;
|
|
35
|
+
storyData.forEach(s => {
|
|
36
|
+
s.docsText = text;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
31
39
|
app.unmount();
|
|
32
40
|
}
|
package/dist/node/alias.js
CHANGED
|
@@ -2,5 +2,5 @@ import { dirname, join } from 'pathe';
|
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
3
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
4
4
|
export const DIST_PATH = join(__dirname, '../');
|
|
5
|
-
export const APP_PATH = join(DIST_PATH, 'client'
|
|
5
|
+
export const APP_PATH = join(DIST_PATH, 'client');
|
|
6
6
|
export const TEMP_PATH = join(process.cwd(), 'node_modules', '.histoire');
|
package/dist/node/build.js
CHANGED
|
@@ -57,8 +57,8 @@ export async function build(ctx) {
|
|
|
57
57
|
build: {
|
|
58
58
|
rollupOptions: {
|
|
59
59
|
input: [
|
|
60
|
-
join(APP_PATH, '
|
|
61
|
-
join(APP_PATH, 'sandbox.js'),
|
|
60
|
+
join(APP_PATH, 'bundle-main.js'),
|
|
61
|
+
join(APP_PATH, 'bundle-sandbox.js'),
|
|
62
62
|
],
|
|
63
63
|
output: {
|
|
64
64
|
manualChunks(id) {
|
|
@@ -86,13 +86,13 @@ export async function build(ctx) {
|
|
|
86
86
|
const prefetchOutputs = result.output.filter(o => PREFETCHED_MODULES.includes(o.name) && o.type === 'chunk');
|
|
87
87
|
const prefetchHtml = generateScriptLinks(prefetchOutputs.map(o => o.fileName), 'prefetch', ctx, resolvedViteConfig);
|
|
88
88
|
// Index
|
|
89
|
-
const indexOutput = result.output.find(o => o.name === '
|
|
89
|
+
const indexOutput = result.output.find(o => o.name === 'bundle-main' && o.type === 'chunk');
|
|
90
90
|
const indexHtml = generateEntryHtml(indexOutput.fileName, styleOutput.fileName, {
|
|
91
91
|
HEAD: `${preloadHtml}${prefetchHtml}`,
|
|
92
92
|
}, ctx, resolvedViteConfig);
|
|
93
93
|
await writeFile('index.html', indexHtml, ctx);
|
|
94
94
|
// Sandbox
|
|
95
|
-
const sandboxOutput = result.output.find(o => o.name === 'sandbox' && o.type === 'chunk');
|
|
95
|
+
const sandboxOutput = result.output.find(o => o.name === 'bundle-sandbox' && o.type === 'chunk');
|
|
96
96
|
const sandboxHtml = generateEntryHtml(sandboxOutput.fileName, styleOutput.fileName, {}, ctx, resolvedViteConfig);
|
|
97
97
|
await writeFile('__sandbox.html', sandboxHtml, ctx);
|
|
98
98
|
const duration = performance.now() - startTime;
|
|
@@ -83,7 +83,7 @@ defineExpose({
|
|
|
83
83
|
})
|
|
84
84
|
</script>
|
|
85
85
|
<template>
|
|
86
|
-
<Story id="tailwind" title="Tailwind" group="design-system" icon="mdi:tailwind" responsiveDisabled>
|
|
86
|
+
<Story id="tailwind" title="Tailwind" group="design-system" icon="mdi:tailwind" responsiveDisabled :layout="{ type: 'single', iframe: false }">
|
|
87
87
|
<Variant id="background-color" title="Background Color" icon="carbon:color-palette">
|
|
88
88
|
<HstColorShades
|
|
89
89
|
v-for="(shades, key) of config.theme.backgroundColor"
|
package/dist/node/search.d.ts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { Context } from './context.js';
|
|
2
|
-
export declare function
|
|
2
|
+
export declare function generateTitleSearchData(ctx: Context): Promise<{
|
|
3
3
|
index: unknown;
|
|
4
4
|
idMap: Record<number, {
|
|
5
5
|
id: string;
|
|
6
6
|
kind: string;
|
|
7
7
|
}>;
|
|
8
8
|
}>;
|
|
9
|
+
export declare function generateDocSearchData(ctx: Context): Promise<{
|
|
10
|
+
index: unknown;
|
|
11
|
+
idMap: Record<number, {
|
|
12
|
+
id: string;
|
|
13
|
+
kind: string;
|
|
14
|
+
}>;
|
|
15
|
+
}>;
|
|
16
|
+
export declare function getSearchDataJS(data: any): string;
|
package/dist/node/search.js
CHANGED
|
@@ -4,57 +4,77 @@ import path from 'pathe';
|
|
|
4
4
|
import Case from 'case';
|
|
5
5
|
import { loadModule } from './load.js';
|
|
6
6
|
const require = createRequire(import.meta.url);
|
|
7
|
-
export async function
|
|
8
|
-
|
|
9
|
-
const idMap =
|
|
7
|
+
export async function generateTitleSearchData(ctx) {
|
|
8
|
+
const searchIndex = await createIndex();
|
|
9
|
+
const { idMap, addToIdMap } = createIdMap();
|
|
10
|
+
for (const storyFile of ctx.storyFiles) {
|
|
11
|
+
if (storyFile.story) {
|
|
12
|
+
searchIndex.add({
|
|
13
|
+
id: addToIdMap(storyFile.story.id, 'story'),
|
|
14
|
+
text: convertTitleToSentence(storyFile.story.title),
|
|
15
|
+
});
|
|
16
|
+
for (const variant of storyFile.story.variants) {
|
|
17
|
+
searchIndex.add({
|
|
18
|
+
id: addToIdMap(`${storyFile.story.id}:${variant.id}`, 'variant'),
|
|
19
|
+
text: convertTitleToSentence(`${storyFile.story.title} ${variant.title}`),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
index: await exportSearchIndex(searchIndex),
|
|
26
|
+
idMap,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export async function generateDocSearchData(ctx) {
|
|
30
|
+
const searchIndex = await createIndex();
|
|
31
|
+
const { idMap, addToIdMap } = createIdMap();
|
|
32
|
+
for (const storyFile of ctx.storyFiles) {
|
|
33
|
+
if (storyFile.story && storyFile.story.docsText) {
|
|
34
|
+
searchIndex.add({
|
|
35
|
+
id: addToIdMap(storyFile.story.id, 'story'),
|
|
36
|
+
text: storyFile.story.docsText,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
index: await exportSearchIndex(searchIndex),
|
|
42
|
+
idMap,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
async function createIndex() {
|
|
10
46
|
const flexsearchRoot = path.dirname(require.resolve('flexsearch/package.json'));
|
|
11
|
-
|
|
12
|
-
preset: '
|
|
47
|
+
return new flexsearch.Document({
|
|
48
|
+
preset: 'match',
|
|
13
49
|
document: {
|
|
14
50
|
id: 'id',
|
|
15
51
|
index: [
|
|
16
|
-
'
|
|
17
|
-
'docs',
|
|
52
|
+
'text',
|
|
18
53
|
],
|
|
19
54
|
},
|
|
20
55
|
charset: await loadModule(`${flexsearchRoot}/dist/module/lang/latin/advanced.js`),
|
|
21
56
|
language: await loadModule(`${flexsearchRoot}/dist/module/lang/en.js`),
|
|
22
57
|
tokenize: 'forward',
|
|
23
58
|
});
|
|
59
|
+
}
|
|
60
|
+
function createIdMap() {
|
|
61
|
+
let uid = 0;
|
|
62
|
+
const idMap = {};
|
|
24
63
|
function addToIdMap(id, kind) {
|
|
25
64
|
const n = uid++;
|
|
26
65
|
idMap[n] = { id, kind };
|
|
27
66
|
return n;
|
|
28
67
|
}
|
|
29
|
-
for (const storyFile of ctx.storyFiles) {
|
|
30
|
-
if (storyFile.story) {
|
|
31
|
-
searchIndex.add({
|
|
32
|
-
id: addToIdMap(storyFile.story.id, 'story'),
|
|
33
|
-
title: processTitle(storyFile.story.title),
|
|
34
|
-
docs: '', // @TODO
|
|
35
|
-
});
|
|
36
|
-
for (const variant of storyFile.story.variants) {
|
|
37
|
-
searchIndex.add({
|
|
38
|
-
id: addToIdMap(`${storyFile.story.id}:${variant.id}`, 'variant'),
|
|
39
|
-
title: processTitle(`${storyFile.story.title} ${variant.title}`),
|
|
40
|
-
docs: '', // @TODO
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
68
|
return {
|
|
46
|
-
index: await exportSearchIndex(searchIndex),
|
|
47
69
|
idMap,
|
|
70
|
+
addToIdMap,
|
|
48
71
|
};
|
|
49
72
|
}
|
|
50
73
|
const exportKeys = new Set([
|
|
51
74
|
'reg',
|
|
52
|
-
'
|
|
53
|
-
'
|
|
54
|
-
'
|
|
55
|
-
'docs.cfg',
|
|
56
|
-
'docs.map',
|
|
57
|
-
'docs.ctx',
|
|
75
|
+
'text.cfg',
|
|
76
|
+
'text.map',
|
|
77
|
+
'text.ctx',
|
|
58
78
|
'tag',
|
|
59
79
|
'store',
|
|
60
80
|
]);
|
|
@@ -72,6 +92,23 @@ async function exportSearchIndex(index) {
|
|
|
72
92
|
});
|
|
73
93
|
});
|
|
74
94
|
}
|
|
75
|
-
function
|
|
76
|
-
return
|
|
95
|
+
function convertTitleToSentence(text) {
|
|
96
|
+
return text.split(' ').map(str => Case.lower(str)).join(' ');
|
|
97
|
+
}
|
|
98
|
+
// @TODO clear handlers when SearchPane unmounts
|
|
99
|
+
export function getSearchDataJS(data) {
|
|
100
|
+
return `export let searchData = ${JSON.stringify(data)}
|
|
101
|
+
const handlers = []
|
|
102
|
+
export function onUpdate (cb) {
|
|
103
|
+
handlers.push(cb)
|
|
104
|
+
}
|
|
105
|
+
if (import.meta.hot) {
|
|
106
|
+
import.meta.hot.accept(newModule => {
|
|
107
|
+
searchData = newModule.searchData
|
|
108
|
+
handlers.forEach(h => {
|
|
109
|
+
h(newModule.searchData)
|
|
110
|
+
newModule.onUpdate(h)
|
|
111
|
+
})
|
|
112
|
+
})
|
|
113
|
+
}`;
|
|
77
114
|
}
|
package/dist/node/server.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createServer as createViteServer } from 'vite';
|
|
2
|
-
import { createVitePlugins,
|
|
2
|
+
import { createVitePlugins, RESOLVED_SEARCH_TITLE_DATA_ID, RESOLVED_STORIES_ID } from './vite.js';
|
|
3
3
|
import { notifyStoryChange, onStoryChange, watchStories } from './stories.js';
|
|
4
4
|
import { useCollectStories } from './collect/index.js';
|
|
5
5
|
import { DevPluginApi } from './plugin.js';
|
|
@@ -94,7 +94,7 @@ export async function createServer(ctx, port) {
|
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
invalidateModule(RESOLVED_STORIES_ID);
|
|
97
|
-
invalidateModule(
|
|
97
|
+
invalidateModule(RESOLVED_SEARCH_TITLE_DATA_ID);
|
|
98
98
|
});
|
|
99
99
|
async function close() {
|
|
100
100
|
for (const cb of pluginOnCleanups) {
|
package/dist/node/types.d.ts
CHANGED
package/dist/node/vite.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export declare const CONFIG_ID = "$histoire-config";
|
|
|
8
8
|
export declare const RESOLVED_CONFIG_ID: string;
|
|
9
9
|
export declare const THEME_ID = "$histoire-theme";
|
|
10
10
|
export declare const RESOLVED_THEME_ID: string;
|
|
11
|
-
export declare const
|
|
12
|
-
export declare const
|
|
11
|
+
export declare const SEARCH_TITLE_DATA_ID = "$histoire-search-title-data";
|
|
12
|
+
export declare const RESOLVED_SEARCH_TITLE_DATA_ID: string;
|
|
13
|
+
export declare const SEARCH_DOCS_DATA_ID = "$histoire-search-docs-data";
|
|
14
|
+
export declare const RESOLVED_SEARCH_DOCS_DATA_ID: string;
|
|
13
15
|
export declare function createVitePlugins(ctx: Context): Promise<VitePlugin[]>;
|
package/dist/node/vite.js
CHANGED
|
@@ -7,7 +7,7 @@ import { notifyStoryChange } from './stories.js';
|
|
|
7
7
|
import { makeTree } from './tree.js';
|
|
8
8
|
import { parseColor } from './colors.js';
|
|
9
9
|
import { createMarkdownRenderer } from './markdown.js';
|
|
10
|
-
import {
|
|
10
|
+
import { getSearchDataJS, generateDocSearchData, generateTitleSearchData } from './search.js';
|
|
11
11
|
const require = createRequire(import.meta.url);
|
|
12
12
|
export const STORIES_ID = '$histoire-stories';
|
|
13
13
|
export const RESOLVED_STORIES_ID = `/${STORIES_ID}-resolved`;
|
|
@@ -17,15 +17,13 @@ export const CONFIG_ID = '$histoire-config';
|
|
|
17
17
|
export const RESOLVED_CONFIG_ID = `/${CONFIG_ID}-resolved`;
|
|
18
18
|
export const THEME_ID = '$histoire-theme';
|
|
19
19
|
export const RESOLVED_THEME_ID = `/${THEME_ID}-resolved.css`;
|
|
20
|
-
export const
|
|
21
|
-
export const
|
|
20
|
+
export const SEARCH_TITLE_DATA_ID = '$histoire-search-title-data';
|
|
21
|
+
export const RESOLVED_SEARCH_TITLE_DATA_ID = `/${SEARCH_TITLE_DATA_ID}-resolved`;
|
|
22
|
+
export const SEARCH_DOCS_DATA_ID = '$histoire-search-docs-data';
|
|
23
|
+
export const RESOLVED_SEARCH_DOCS_DATA_ID = `/${SEARCH_DOCS_DATA_ID}-resolved`;
|
|
22
24
|
export async function createVitePlugins(ctx) {
|
|
23
25
|
const viteConfig = await resolveViteConfig({}, ctx.mode === 'dev' ? 'serve' : 'build');
|
|
24
|
-
const hasVuePlugin = viteConfig.plugins.find(p => p.name === 'vite:vue');
|
|
25
26
|
const plugins = [];
|
|
26
|
-
if (!hasVuePlugin) {
|
|
27
|
-
plugins.push((await import('@vitejs/plugin-vue')).default());
|
|
28
|
-
}
|
|
29
27
|
if (ctx.config.vite) {
|
|
30
28
|
plugins.push({
|
|
31
29
|
name: 'histoire-vite-config-override',
|
|
@@ -42,14 +40,13 @@ export async function createVitePlugins(ctx) {
|
|
|
42
40
|
// force include vue to avoid duplicated copies when linked + optimized
|
|
43
41
|
include: [
|
|
44
42
|
'vue',
|
|
45
|
-
dirname(require.resolve('@vue/runtime-core/package.json')),
|
|
46
43
|
dirname(require.resolve('shiki/package.json')),
|
|
47
44
|
dirname(require.resolve('vscode-textmate/package.json')),
|
|
48
45
|
dirname(require.resolve('vscode-oniguruma/package.json')),
|
|
49
46
|
dirname(require.resolve('case/package.json')),
|
|
50
47
|
],
|
|
51
48
|
exclude: [
|
|
52
|
-
'histoire
|
|
49
|
+
'histoire',
|
|
53
50
|
],
|
|
54
51
|
},
|
|
55
52
|
server: {
|
|
@@ -83,8 +80,11 @@ export async function createVitePlugins(ctx) {
|
|
|
83
80
|
if (id.startsWith(THEME_ID)) {
|
|
84
81
|
return RESOLVED_THEME_ID;
|
|
85
82
|
}
|
|
86
|
-
if (id.startsWith(
|
|
87
|
-
return
|
|
83
|
+
if (id.startsWith(SEARCH_TITLE_DATA_ID)) {
|
|
84
|
+
return RESOLVED_SEARCH_TITLE_DATA_ID;
|
|
85
|
+
}
|
|
86
|
+
if (id.startsWith(SEARCH_DOCS_DATA_ID)) {
|
|
87
|
+
return RESOLVED_SEARCH_DOCS_DATA_ID;
|
|
88
88
|
}
|
|
89
89
|
},
|
|
90
90
|
async load(id) {
|
|
@@ -94,7 +94,10 @@ export async function createVitePlugins(ctx) {
|
|
|
94
94
|
return {
|
|
95
95
|
id: file.id,
|
|
96
96
|
path: file.treePath,
|
|
97
|
-
story:
|
|
97
|
+
story: {
|
|
98
|
+
...file.story,
|
|
99
|
+
docsText: undefined,
|
|
100
|
+
},
|
|
98
101
|
framework: 'vue3',
|
|
99
102
|
index,
|
|
100
103
|
};
|
|
@@ -142,21 +145,11 @@ if (import.meta.hot) {
|
|
|
142
145
|
css += '}';
|
|
143
146
|
return css;
|
|
144
147
|
}
|
|
145
|
-
if (id ===
|
|
146
|
-
return
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
if (import.meta.hot) {
|
|
152
|
-
import.meta.hot.accept(newModule => {
|
|
153
|
-
searchData = newModule.searchData
|
|
154
|
-
handlers.forEach(h => {
|
|
155
|
-
h(newModule.searchData)
|
|
156
|
-
newModule.onUpdate(h)
|
|
157
|
-
})
|
|
158
|
-
})
|
|
159
|
-
}`;
|
|
148
|
+
if (id === RESOLVED_SEARCH_TITLE_DATA_ID) {
|
|
149
|
+
return getSearchDataJS(await generateTitleSearchData(ctx));
|
|
150
|
+
}
|
|
151
|
+
if (id === RESOLVED_SEARCH_DOCS_DATA_ID) {
|
|
152
|
+
return getSearchDataJS(await generateDocSearchData(ctx));
|
|
160
153
|
}
|
|
161
154
|
},
|
|
162
155
|
handleHotUpdate(updateContext) {
|
|
@@ -189,7 +182,7 @@ if (import.meta.hot) {
|
|
|
189
182
|
}
|
|
190
183
|
}
|
|
191
184
|
</script>
|
|
192
|
-
<script type="module" src="/@fs/${APP_PATH}/sandbox.js"></script>
|
|
185
|
+
<script type="module" src="/@fs/${APP_PATH}/bundle-sandbox.js"></script>
|
|
193
186
|
</body>
|
|
194
187
|
</html>`;
|
|
195
188
|
// Apply Vite HTML transforms. This injects the Vite HMR client, and
|
|
@@ -218,7 +211,7 @@ if (import.meta.hot) {
|
|
|
218
211
|
</head>
|
|
219
212
|
<body>
|
|
220
213
|
<div id="app"></div>
|
|
221
|
-
<script type="module" src="/@fs/${APP_PATH}/
|
|
214
|
+
<script type="module" src="/@fs/${APP_PATH}/bundle-main.js"></script>
|
|
222
215
|
</body>
|
|
223
216
|
</html>`;
|
|
224
217
|
// Apply Vite HTML transforms. This injects the Vite HMR client, and
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "histoire",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "A fast story book powered by Vite",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"types": "./dist/node/index.d.ts"
|
|
22
22
|
},
|
|
23
23
|
"./client": {
|
|
24
|
-
"import": "./dist/client/index.js",
|
|
24
|
+
"import": "./dist/client/bundle-index.js",
|
|
25
25
|
"types": "./dist/client/index.d.ts"
|
|
26
26
|
},
|
|
27
27
|
"./*": "./*"
|
|
@@ -33,9 +33,8 @@
|
|
|
33
33
|
"histoire": "./bin.mjs"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@histoire/controls": "^0.
|
|
36
|
+
"@histoire/controls": "^0.4.0",
|
|
37
37
|
"@iconify/vue": "^3.2.1",
|
|
38
|
-
"@vitejs/plugin-vue": "^2.3.1",
|
|
39
38
|
"@vueuse/core": "^8.2.5",
|
|
40
39
|
"birpc": "^0.1.1",
|
|
41
40
|
"case": "^1.6.3",
|
|
@@ -62,11 +61,11 @@
|
|
|
62
61
|
"sirv": "^2.0.2",
|
|
63
62
|
"tinypool": "^0.1.2",
|
|
64
63
|
"vite-node": "0.7.6",
|
|
65
|
-
"vue-router": "^4.0.14"
|
|
64
|
+
"vue-router": "^4.0.14",
|
|
65
|
+
"vue": "^3.2.31"
|
|
66
66
|
},
|
|
67
67
|
"peerDependencies": {
|
|
68
|
-
"vite": "^2.9.0"
|
|
69
|
-
"vue": "^3.2.31"
|
|
68
|
+
"vite": "^2.9.0"
|
|
70
69
|
},
|
|
71
70
|
"devDependencies": {
|
|
72
71
|
"@peeky/test": "^0.13.5",
|
|
@@ -75,6 +74,7 @@
|
|
|
75
74
|
"@types/fs-extra": "^9.0.13",
|
|
76
75
|
"@types/markdown-it": "^12.2.3",
|
|
77
76
|
"@types/node": "^17.0.23",
|
|
77
|
+
"@vitejs/plugin-vue": "^2.3.1",
|
|
78
78
|
"autoprefixer": "^10.4.4",
|
|
79
79
|
"concurrently": "^7.1.0",
|
|
80
80
|
"postcss": "^8.4.12",
|
|
@@ -85,9 +85,9 @@
|
|
|
85
85
|
"vue": "^3.2.31"
|
|
86
86
|
},
|
|
87
87
|
"scripts": {
|
|
88
|
-
"build": "rimraf dist && tsc -d && pnpm run build:css && node ./scripts/copy.mjs",
|
|
88
|
+
"build": "rimraf dist && tsc -d && vite build && pnpm run build:css && node ./scripts/copy.mjs",
|
|
89
89
|
"build:css": "tailwindcss -i src/client/app/style/main.pcss -o ./dist/style.css -c tailwind.config.cjs --postcss postcss.config.cjs",
|
|
90
|
-
"watch": "concurrently \"tsc -d -w --sourceMap\" \"pnpm run build:css --watch\" \"node ./scripts/watchAndCopy.mjs\"",
|
|
90
|
+
"watch": "concurrently \"tsc -d -w --sourceMap\" \"vite build --watch\" \"pnpm run build:css --watch\" \"node ./scripts/watchAndCopy.mjs\"",
|
|
91
91
|
"test:open": "peeky open",
|
|
92
92
|
"test": "peeky run"
|
|
93
93
|
}
|
package/src/client/app/App.vue
CHANGED
|
@@ -15,8 +15,8 @@ import type { StoryFile, Tree } from './types'
|
|
|
15
15
|
import { useStoryStore } from './stores/story'
|
|
16
16
|
import { mapFile } from './util/mapping'
|
|
17
17
|
import { useTitle } from '@vueuse/core'
|
|
18
|
-
import { histoireConfig } from './util/config
|
|
19
|
-
import { onKeyboardShortcut } from './util/keyboard
|
|
18
|
+
import { histoireConfig } from './util/config'
|
|
19
|
+
import { onKeyboardShortcut } from './util/keyboard'
|
|
20
20
|
import { isMobile } from './util/responsive'
|
|
21
21
|
import Breadcrumb from './components/app/Breadcrumb.vue'
|
|
22
22
|
import SearchModal from './components/search/SearchModal.vue'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { hstEvent } from './util/events.js'
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
// @TODO remove no-check and fix vnode type errors
|
|
3
3
|
|
|
4
|
-
import { VNode, vModelText, vModelCheckbox, vModelSelect, vModelRadio, vModelDynamic } from 'vue'
|
|
5
|
-
import { Text } from '@vue/runtime-core'
|
|
4
|
+
import { VNode, vModelText, vModelCheckbox, vModelSelect, vModelRadio, vModelDynamic, Text } from 'vue'
|
|
6
5
|
import { pascal } from 'case'
|
|
7
6
|
import { createAutoBuildingObject, indent } from './util'
|
|
8
7
|
import { serializeJs } from './serialize-js'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
2
|
import { computed } from 'vue'
|
|
3
|
-
import { histoireConfig, customLogos } from '../util/config
|
|
3
|
+
import { histoireConfig, customLogos } from '../util/config'
|
|
4
4
|
import HistoireLogo from '../assets/histoire.svg'
|
|
5
5
|
|
|
6
6
|
const logoUrl = computed(() => histoireConfig.theme?.logo?.square ? customLogos.square : HistoireLogo)
|