histoire 0.7.1 → 0.7.4
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/client.d.ts +1 -1
- package/dist/bundled/MobileOverlay.js +2 -2
- package/dist/bundled/StoryView.js +22 -19
- package/dist/bundled/dark.js +4 -0
- package/dist/bundled/index.js +0 -1
- package/dist/bundled/index2.js +6 -6
- package/dist/bundled/mapping.js +78 -0
- package/dist/bundled/sandbox.js +7 -6
- package/dist/bundled/state.js +13 -44
- package/dist/bundled/style.css +17 -17
- package/dist/client/app/App.vue +2 -2
- package/dist/client/app/components/base/BaseSplitPane.vue +6 -6
- package/dist/client/app/components/panel/ControlsComponentPropItem.vue +13 -6
- package/dist/client/app/components/panel/ControlsComponentProps.vue +2 -1
- package/dist/client/app/components/panel/StatePresets.vue +2 -1
- package/dist/client/app/components/panel/StoryControls.vue +1 -1
- package/dist/client/app/components/panel/StorySourceCode.vue +2 -2
- package/dist/client/app/components/story/StoryVariantGridItem.vue +1 -1
- package/dist/client/app/components/story/StoryVariantSinglePreviewNative.vue +1 -1
- package/dist/client/app/components/story/StoryVariantSinglePreviewRemote.vue +3 -2
- package/dist/client/app/components/story/StoryVariantSingleView.vue +1 -1
- package/dist/client/app/components/toolbar/StoryVariantNewTab.vue +1 -1
- package/dist/client/app/components/tree/StoryGroup.vue +1 -1
- package/dist/client/app/index.js +0 -2
- package/dist/client/app/sandbox.js +4 -5
- package/dist/client/app/style/main.pcss +3 -3
- package/dist/client/app/style/sandbox.css +1 -1
- package/dist/client/app/types.d.ts +1 -52
- package/dist/client/app/util/mapping.d.ts +1 -1
- package/dist/client/app/util/mapping.js +50 -36
- package/dist/client/app/{components/sandbox/lib.d.ts → util/sandbox.d.ts} +1 -1
- package/dist/client/app/{components/sandbox/lib.js → util/sandbox.js} +1 -1
- package/dist/client/app/util/state.d.ts +1 -5
- package/dist/client/app/util/state.js +12 -44
- package/dist/node/collect/index.d.ts +2 -2
- package/dist/node/collect/index.js +3 -0
- package/dist/node/collect/run.d.ts +2 -0
- package/dist/{client/server/index.js → node/collect/run.js} +1 -1
- package/dist/node/collect/worker.d.ts +3 -3
- package/dist/node/collect/worker.js +4 -1
- package/dist/node/config.d.ts +3 -3
- package/dist/node/context.d.ts +2 -2
- package/dist/node/plugin.d.ts +3 -3
- package/dist/node/stories.d.ts +4 -4
- package/dist/node/tree.d.ts +3 -22
- package/dist/style.css +80 -4
- package/package.json +4 -2
- package/src/client/app/App.vue +2 -2
- package/src/client/app/components/base/BaseSplitPane.vue +6 -6
- package/src/client/app/components/panel/ControlsComponentPropItem.vue +13 -6
- package/src/client/app/components/panel/ControlsComponentProps.vue +2 -1
- package/src/client/app/components/panel/StatePresets.vue +2 -1
- package/src/client/app/components/panel/StoryControls.vue +1 -1
- package/src/client/app/components/panel/StorySourceCode.vue +2 -2
- package/src/client/app/components/story/StoryVariantGridItem.vue +1 -1
- package/src/client/app/components/story/StoryVariantSinglePreviewNative.vue +1 -1
- package/src/client/app/components/story/StoryVariantSinglePreviewRemote.vue +3 -2
- package/src/client/app/components/story/StoryVariantSingleView.vue +1 -1
- package/src/client/app/components/toolbar/StoryVariantNewTab.vue +1 -1
- package/src/client/app/components/tree/StoryGroup.vue +1 -1
- package/src/client/app/index.ts +0 -2
- package/src/client/app/sandbox.ts +4 -5
- package/src/client/app/style/main.pcss +3 -3
- package/src/client/app/style/sandbox.css +1 -1
- package/src/client/app/types.ts +6 -57
- package/src/client/app/util/mapping.ts +47 -34
- package/src/client/app/{components/sandbox/lib.ts → util/sandbox.ts} +2 -2
- package/src/client/app/util/state.ts +15 -44
- package/src/node/collect/index.ts +5 -2
- package/src/node/collect/run.ts +13 -0
- package/src/node/collect/worker.ts +8 -6
- package/src/node/config.ts +3 -3
- package/src/node/context.ts +2 -2
- package/src/node/plugin.ts +2 -2
- package/src/node/server.ts +2 -2
- package/src/node/stories.ts +4 -4
- package/src/node/tree.ts +7 -31
- package/tailwind.config.cjs +1 -1
- package/vite.config.ts +12 -7
- package/dist/bundled/SandboxVue3.js +0 -706
- package/dist/bundled/global-components.js +0 -213
- package/dist/client/app/codegen/const.d.ts +0 -1
- package/dist/client/app/codegen/const.js +0 -3
- package/dist/client/app/codegen/serialize-js.d.ts +0 -1
- package/dist/client/app/codegen/serialize-js.js +0 -113
- package/dist/client/app/codegen/util.d.ts +0 -10
- package/dist/client/app/codegen/util.js +0 -70
- package/dist/client/app/codegen/vue3.d.ts +0 -4
- package/dist/client/app/codegen/vue3.js +0 -357
- package/dist/client/app/components/exposed/Story.vue +0 -106
- package/dist/client/app/components/exposed/Variant.vue +0 -78
- package/dist/client/app/components/sandbox/RouterLinkStub.d.ts +0 -21
- package/dist/client/app/components/sandbox/RouterLinkStub.js +0 -43
- package/dist/client/app/components/sandbox/SandboxVue3.vue +0 -185
- package/dist/client/app/global-components.d.ts +0 -2
- package/dist/client/app/global-components.js +0 -10
- package/dist/client/server/index.d.ts +0 -7
- package/dist/client/server/vue3/Story.vue +0 -120
- package/dist/client/server/vue3/Variant.vue +0 -52
- package/dist/client/server/vue3/run.d.ts +0 -2
- package/dist/client/server/vue3/run.js +0 -45
- package/dist/node/types.d.ts +0 -50
- package/dist/node/types.js +0 -1
- package/src/client/app/codegen/const.ts +0 -3
- package/src/client/app/codegen/serialize-js.ts +0 -119
- package/src/client/app/codegen/util.ts +0 -79
- package/src/client/app/codegen/vue3.ts +0 -361
- package/src/client/app/components/exposed/Story.vue +0 -106
- package/src/client/app/components/exposed/Variant.vue +0 -78
- package/src/client/app/components/sandbox/RouterLinkStub.ts +0 -49
- package/src/client/app/components/sandbox/SandboxVue3.vue +0 -185
- package/src/client/app/global-components.ts +0 -13
- package/src/client/server/index.ts +0 -19
- package/src/client/server/vue3/Story.vue +0 -120
- package/src/client/server/vue3/Variant.vue +0 -52
- package/src/client/server/vue3/run.ts +0 -55
- package/src/components.d.ts +0 -143
- package/src/node/types.ts +0 -53
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Icon } from '@iconify/vue'
|
|
3
3
|
import type { Story, Variant } from '../../types'
|
|
4
4
|
import { computed } from 'vue'
|
|
5
|
-
import { getSandboxUrl } from '
|
|
5
|
+
import { getSandboxUrl } from '../../util/sandbox'
|
|
6
6
|
|
|
7
7
|
const props = defineProps<{
|
|
8
8
|
variant: Variant
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts" setup>
|
|
2
|
-
import type { Story, TreeGroup
|
|
2
|
+
import type { Story, TreeGroup } from '../../types'
|
|
3
3
|
import StoryListItem from './StoryListItem.vue'
|
|
4
4
|
import StoryListFolder from './StoryListFolder.vue'
|
|
5
5
|
import { Icon } from '@iconify/vue'
|
package/dist/client/app/index.js
CHANGED
|
@@ -5,7 +5,6 @@ import { createApp } from 'vue';
|
|
|
5
5
|
import { createPinia } from 'pinia';
|
|
6
6
|
import FloatingVue from 'floating-vue';
|
|
7
7
|
import App from './App.vue';
|
|
8
|
-
import { registerGlobalComponents } from './global-components.js';
|
|
9
8
|
import { router } from './router';
|
|
10
9
|
export function mountMainApp() {
|
|
11
10
|
const app = createApp(App);
|
|
@@ -24,7 +23,6 @@ export function mountMainApp() {
|
|
|
24
23
|
},
|
|
25
24
|
});
|
|
26
25
|
app.use(router);
|
|
27
|
-
registerGlobalComponents(app);
|
|
28
26
|
app.mount('#app');
|
|
29
27
|
if (import.meta.hot) {
|
|
30
28
|
import.meta.hot.send('histoire:mount', {});
|
|
@@ -1,8 +1,8 @@
|
|
|
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 {
|
|
5
|
-
import SandboxVue3 from '
|
|
4
|
+
import { applyStateToVariant } from '@histoire/shared';
|
|
5
|
+
import { SandboxVue3, MountStoryVue3 } from '@histoire/plugin-vue/client';
|
|
6
6
|
import { mapFile } from './util/mapping';
|
|
7
7
|
// @ts-expect-error virtual module
|
|
8
8
|
import { files } from '$histoire-stories';
|
|
@@ -10,7 +10,7 @@ import { PREVIEW_SETTINGS_SYNC, STATE_SYNC, SANDBOX_READY } from './util/const.j
|
|
|
10
10
|
import { applyPreviewSettings } from './util/preview-settings.js';
|
|
11
11
|
import { isDark } from './util/dark.js';
|
|
12
12
|
import { histoireConfig } from './util/config.js';
|
|
13
|
-
import {
|
|
13
|
+
import { toRawDeep } from './util/state.js';
|
|
14
14
|
const query = parseQuery(window.location.search);
|
|
15
15
|
const file = ref(mapFile(files.find(f => f.id === query.storyId)));
|
|
16
16
|
const app = createApp({
|
|
@@ -54,7 +54,7 @@ const app = createApp({
|
|
|
54
54
|
render() {
|
|
55
55
|
return [
|
|
56
56
|
h('div', { class: 'htw-sandbox-hidden' }, [
|
|
57
|
-
h(
|
|
57
|
+
h(MountStoryVue3, {
|
|
58
58
|
story: file.value.story,
|
|
59
59
|
}),
|
|
60
60
|
]),
|
|
@@ -73,7 +73,6 @@ const app = createApp({
|
|
|
73
73
|
},
|
|
74
74
|
});
|
|
75
75
|
app.use(createPinia());
|
|
76
|
-
registerGlobalComponents(app);
|
|
77
76
|
app.mount('#app');
|
|
78
77
|
watch(isDark, value => {
|
|
79
78
|
if (value) {
|
|
@@ -50,16 +50,16 @@ body,
|
|
|
50
50
|
|
|
51
51
|
html {
|
|
52
52
|
font-family: 'Lato', sans-serif;
|
|
53
|
-
font-size:
|
|
53
|
+
font-size: 1rem;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
body {
|
|
57
|
-
font-size:
|
|
57
|
+
font-size: 1.125rem;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
@media (min-width: 640px) {
|
|
61
61
|
body {
|
|
62
|
-
font-size:
|
|
62
|
+
font-size: .875rem;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
@@ -1,45 +1,5 @@
|
|
|
1
1
|
import type { RouteLocationRaw } from 'vue-router';
|
|
2
|
-
export
|
|
3
|
-
id: string;
|
|
4
|
-
framework: string;
|
|
5
|
-
component: any;
|
|
6
|
-
story: Story;
|
|
7
|
-
path: string[];
|
|
8
|
-
}
|
|
9
|
-
export declare type StoryLayout = {
|
|
10
|
-
type: 'single';
|
|
11
|
-
iframe?: boolean;
|
|
12
|
-
} | {
|
|
13
|
-
type: 'grid';
|
|
14
|
-
width?: number | string;
|
|
15
|
-
};
|
|
16
|
-
export interface Story {
|
|
17
|
-
id: string;
|
|
18
|
-
title: string;
|
|
19
|
-
group?: string;
|
|
20
|
-
variants: Variant[];
|
|
21
|
-
layout?: StoryLayout;
|
|
22
|
-
icon?: string;
|
|
23
|
-
iconColor?: string;
|
|
24
|
-
docsOnly?: boolean;
|
|
25
|
-
file?: StoryFile;
|
|
26
|
-
lastSelectedVariant?: Variant;
|
|
27
|
-
slots?: () => Readonly<any>;
|
|
28
|
-
}
|
|
29
|
-
export interface Variant {
|
|
30
|
-
id: string;
|
|
31
|
-
title: string;
|
|
32
|
-
icon?: string;
|
|
33
|
-
iconColor?: string;
|
|
34
|
-
initState?: () => any;
|
|
35
|
-
setupApp?: (payload: any) => unknown;
|
|
36
|
-
slots?: () => Readonly<any>;
|
|
37
|
-
state?: any;
|
|
38
|
-
source?: string;
|
|
39
|
-
responsiveDisabled?: boolean;
|
|
40
|
-
configReady?: boolean;
|
|
41
|
-
previewReady?: boolean;
|
|
42
|
-
}
|
|
2
|
+
export type { StoryFile, StoryLayout, Story, Variant, } from '@histoire/shared';
|
|
43
3
|
export declare type TreeLeaf = {
|
|
44
4
|
title: string;
|
|
45
5
|
index: number;
|
|
@@ -72,14 +32,3 @@ export interface PreviewSettings {
|
|
|
72
32
|
backgroundColor: string;
|
|
73
33
|
checkerboard: boolean;
|
|
74
34
|
}
|
|
75
|
-
export interface PropDefinition {
|
|
76
|
-
name: string;
|
|
77
|
-
types?: string[];
|
|
78
|
-
required?: boolean;
|
|
79
|
-
default?: any;
|
|
80
|
-
}
|
|
81
|
-
export interface AutoPropComponentDefinition {
|
|
82
|
-
name: string;
|
|
83
|
-
index: number;
|
|
84
|
-
props: PropDefinition[];
|
|
85
|
-
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { StoryFile, Variant } from '../types';
|
|
2
2
|
export declare function mapFile(file: StoryFile, existingFile?: StoryFile): StoryFile;
|
|
3
|
-
export declare function mapVariant(variant: Variant): Variant;
|
|
3
|
+
export declare function mapVariant(variant: Variant, existingVariant?: Variant): Variant;
|
|
@@ -10,46 +10,60 @@ const copiedFromExistingVariant = [
|
|
|
10
10
|
'previewReady',
|
|
11
11
|
];
|
|
12
12
|
export function mapFile(file, existingFile) {
|
|
13
|
-
|
|
14
|
-
...file,
|
|
15
|
-
component: markRaw(file.component),
|
|
16
|
-
story: {
|
|
17
|
-
...file.story,
|
|
18
|
-
title: file.story.title,
|
|
19
|
-
file: markRaw(file),
|
|
20
|
-
variants: file.story.variants.map(v => mapVariant(v)),
|
|
21
|
-
slots: () => ({}),
|
|
22
|
-
},
|
|
23
|
-
};
|
|
13
|
+
let result;
|
|
24
14
|
if (existingFile) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
15
|
+
// Update
|
|
16
|
+
result = existingFile;
|
|
17
|
+
for (const key in file) {
|
|
18
|
+
if (key === 'story') {
|
|
19
|
+
Object.assign(result.story, {
|
|
20
|
+
...file.story,
|
|
21
|
+
file: markRaw(result),
|
|
22
|
+
variants: file.story.variants.map(v => mapVariant(v, existingFile.story.variants.find(item => item.id === v.id))),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
else if (key !== 'component') {
|
|
26
|
+
result[key] = file[key];
|
|
38
27
|
}
|
|
39
|
-
}
|
|
40
|
-
if (existingFile.story.lastSelectedVariant) {
|
|
41
|
-
result.story.lastSelectedVariant = result.story.variants.find(v => v.id === existingFile.story.lastSelectedVariant.id);
|
|
42
28
|
}
|
|
43
29
|
}
|
|
30
|
+
else {
|
|
31
|
+
// Create
|
|
32
|
+
result = {
|
|
33
|
+
...file,
|
|
34
|
+
component: markRaw(file.component),
|
|
35
|
+
story: {
|
|
36
|
+
...file.story,
|
|
37
|
+
title: file.story.title,
|
|
38
|
+
file: markRaw(file),
|
|
39
|
+
variants: file.story.variants.map(v => mapVariant(v)),
|
|
40
|
+
slots: () => ({}),
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
44
|
return result;
|
|
45
45
|
}
|
|
46
|
-
export function mapVariant(variant) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
46
|
+
export function mapVariant(variant, existingVariant) {
|
|
47
|
+
let result;
|
|
48
|
+
if (existingVariant) {
|
|
49
|
+
// Update
|
|
50
|
+
result = existingVariant;
|
|
51
|
+
for (const key in variant) {
|
|
52
|
+
if (!copiedFromExistingVariant.includes(key)) {
|
|
53
|
+
result[key] = variant[key];
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
// Create
|
|
59
|
+
result = {
|
|
60
|
+
...variant,
|
|
61
|
+
state: null,
|
|
62
|
+
initState: null,
|
|
63
|
+
setupApp: null,
|
|
64
|
+
slots: () => ({}),
|
|
65
|
+
previewReady: false,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
55
69
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Story, Variant } from '
|
|
1
|
+
import { Story, Variant } from '../types';
|
|
2
2
|
export declare function getSandboxUrl(story: Story, variant: Variant): string;
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function toRawDeep(val: any): any;
|
|
3
|
-
export declare function clone(data: any): any;
|
|
4
|
-
export declare function omit(data: any, keys: string[]): {};
|
|
5
|
-
export declare function applyStateToVariant(variant: Variant, state: any): void;
|
|
1
|
+
export declare function toRawDeep(val: any, seen?: Set<unknown>): any;
|
|
@@ -1,55 +1,23 @@
|
|
|
1
1
|
import { unref, isRef } from 'vue';
|
|
2
2
|
const isObject = (val) => val !== null && typeof val === 'object';
|
|
3
|
-
export function toRawDeep(val) {
|
|
3
|
+
export function toRawDeep(val, seen = new Set()) {
|
|
4
4
|
const unwrappedValue = isRef(val) ? unref(val) : val;
|
|
5
|
+
if (typeof unwrappedValue === 'symbol') {
|
|
6
|
+
return unwrappedValue.toString();
|
|
7
|
+
}
|
|
8
|
+
if (seen.has(unwrappedValue)) {
|
|
9
|
+
return Array.isArray(unwrappedValue) ? [] : {};
|
|
10
|
+
}
|
|
11
|
+
seen.add(unwrappedValue);
|
|
5
12
|
if (!isObject(unwrappedValue)) {
|
|
6
13
|
return unwrappedValue;
|
|
7
14
|
}
|
|
8
15
|
if (Array.isArray(unwrappedValue)) {
|
|
9
|
-
return unwrappedValue.map(toRawDeep);
|
|
16
|
+
return unwrappedValue.map(value => toRawDeep(value, seen));
|
|
10
17
|
}
|
|
11
|
-
return toRawObject(unwrappedValue);
|
|
18
|
+
return toRawObject(unwrappedValue, seen);
|
|
12
19
|
}
|
|
13
|
-
const toRawObject = (obj) => Object.keys(obj).reduce((raw, key) => {
|
|
14
|
-
raw[key] = toRawDeep(obj[key]);
|
|
20
|
+
const toRawObject = (obj, seen = new Set()) => Object.keys(obj).reduce((raw, key) => {
|
|
21
|
+
raw[key] = toRawDeep(obj[key], seen);
|
|
15
22
|
return raw;
|
|
16
23
|
}, {});
|
|
17
|
-
export function clone(data) {
|
|
18
|
-
try {
|
|
19
|
-
return structuredClone(data);
|
|
20
|
-
}
|
|
21
|
-
catch (e) {
|
|
22
|
-
console.warn(e, `Fallback to JSON cloning`);
|
|
23
|
-
try {
|
|
24
|
-
return JSON.parse(JSON.stringify(data));
|
|
25
|
-
}
|
|
26
|
-
catch (e) {
|
|
27
|
-
console.error(e);
|
|
28
|
-
}
|
|
29
|
-
return data;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
export function omit(data, keys) {
|
|
33
|
-
const copy = {};
|
|
34
|
-
for (const key in data) {
|
|
35
|
-
if (!keys.includes(key)) {
|
|
36
|
-
copy[key] = data[key];
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
return copy;
|
|
40
|
-
}
|
|
41
|
-
export function applyStateToVariant(variant, state) {
|
|
42
|
-
if (variant.state) {
|
|
43
|
-
for (const key in state) {
|
|
44
|
-
if (variant.state[key] && !key.startsWith('_h') && typeof variant.state[key] === 'object' && !Array.isArray(variant.state[key])) {
|
|
45
|
-
Object.assign(variant.state[key], state[key]);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
variant.state[key] = state[key];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
variant.state = state;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ViteDevServer } from 'vite';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ServerStoryFile } from '@histoire/shared';
|
|
3
3
|
import type { Context } from '../context.js';
|
|
4
4
|
export interface UseCollectStoriesOptions {
|
|
5
5
|
server: ViteDevServer;
|
|
@@ -7,6 +7,6 @@ export interface UseCollectStoriesOptions {
|
|
|
7
7
|
}
|
|
8
8
|
export declare function useCollectStories(options: UseCollectStoriesOptions, ctx: Context): {
|
|
9
9
|
clearCache: () => void;
|
|
10
|
-
executeStoryFile: (storyFile:
|
|
10
|
+
executeStoryFile: (storyFile: ServerStoryFile) => Promise<void>;
|
|
11
11
|
destroy: () => Promise<void>;
|
|
12
12
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { MessagePort } from 'worker_threads';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ServerStoryFile, ServerStory } from '@histoire/shared';
|
|
4
4
|
export interface Payload {
|
|
5
5
|
root: string;
|
|
6
6
|
base: string;
|
|
7
7
|
port: MessagePort;
|
|
8
|
-
storyFile:
|
|
8
|
+
storyFile: ServerStoryFile;
|
|
9
9
|
}
|
|
10
10
|
export interface ReturnData {
|
|
11
|
-
storyData:
|
|
11
|
+
storyData: ServerStory[];
|
|
12
12
|
}
|
|
13
13
|
declare const _default: (payload: Payload) => Promise<ReturnData>;
|
|
14
14
|
export default _default;
|
|
@@ -20,9 +20,12 @@ export default async (payload) => {
|
|
|
20
20
|
},
|
|
21
21
|
});
|
|
22
22
|
const { destroy: destroyDomEnv } = createDomEnv();
|
|
23
|
+
if (!global.CSS.supports) {
|
|
24
|
+
global.CSS.supports = () => false;
|
|
25
|
+
}
|
|
23
26
|
const el = window.document.createElement('div');
|
|
24
27
|
// Mount app to collect stories/variants
|
|
25
|
-
const { run } = (await runner.executeFile(resolve(__dirname, '
|
|
28
|
+
const { run } = (await runner.executeFile(resolve(__dirname, './run.js')));
|
|
26
29
|
const storyData = [];
|
|
27
30
|
await run({
|
|
28
31
|
file: payload.storyFile,
|
package/dist/node/config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UserConfig as ViteConfig, ConfigEnv as ViteConfigEnv } from 'vite';
|
|
2
2
|
import type MarkdownIt from 'markdown-it';
|
|
3
|
-
import {
|
|
3
|
+
import type { ServerTreeFile } from '@histoire/shared';
|
|
4
4
|
import { Plugin } from './plugin.js';
|
|
5
5
|
declare type CustomizableColors = 'primary' | 'gray';
|
|
6
6
|
declare type ColorKeys = '50' | '100' | '200' | '300' | '400' | '500' | '600' | '700' | '800' | '900';
|
|
@@ -17,7 +17,7 @@ export interface BackgroundPreset {
|
|
|
17
17
|
export interface TreeGroupConfig {
|
|
18
18
|
title: string;
|
|
19
19
|
id?: string;
|
|
20
|
-
include?: (file:
|
|
20
|
+
include?: (file: ServerTreeFile) => boolean;
|
|
21
21
|
}
|
|
22
22
|
export interface HistoireConfig {
|
|
23
23
|
plugins: Plugin[];
|
|
@@ -42,7 +42,7 @@ export interface HistoireConfig {
|
|
|
42
42
|
*
|
|
43
43
|
* Use `'path'` use the real folder structure on your computer.
|
|
44
44
|
*/
|
|
45
|
-
file?: 'title' | 'path' | ((file:
|
|
45
|
+
file?: 'title' | 'path' | ((file: ServerTreeFile) => string[]);
|
|
46
46
|
order?: 'asc' | ((a: string, b: string) => number);
|
|
47
47
|
groups?: TreeGroupConfig[];
|
|
48
48
|
};
|
package/dist/node/context.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import type { ServerStoryFile } from '@histoire/shared';
|
|
1
2
|
import { HistoireConfig, ConfigMode } from './config.js';
|
|
2
|
-
import type { StoryFile } from './types.js';
|
|
3
3
|
export interface Context {
|
|
4
4
|
root: string;
|
|
5
5
|
config: HistoireConfig;
|
|
6
6
|
mode: ConfigMode;
|
|
7
|
-
storyFiles:
|
|
7
|
+
storyFiles: ServerStoryFile[];
|
|
8
8
|
}
|
|
9
9
|
export interface CreateContextOptions {
|
|
10
10
|
mode: Context['mode'];
|
package/dist/node/plugin.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import chokidar from 'chokidar';
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
|
+
import type { ServerStory, ServerVariant } from '@histoire/shared';
|
|
4
5
|
import type { ConfigMode, HistoireConfig } from './config.js';
|
|
5
6
|
import type { Context } from './context.js';
|
|
6
7
|
import type { ModuleLoader } from './load.js';
|
|
7
|
-
import type { Story, Variant } from './types.js';
|
|
8
8
|
export interface Plugin {
|
|
9
9
|
/**
|
|
10
10
|
* Name of the plugin
|
|
@@ -55,8 +55,8 @@ export declare class DevPluginApi extends BasePluginApi {
|
|
|
55
55
|
export declare type BuildEndCallback = () => Promise<void> | void;
|
|
56
56
|
export declare type PreviewStoryCallback = (payload: {
|
|
57
57
|
file: string;
|
|
58
|
-
story:
|
|
59
|
-
variant:
|
|
58
|
+
story: ServerStory;
|
|
59
|
+
variant: ServerVariant;
|
|
60
60
|
url: string;
|
|
61
61
|
}) => Promise<void> | void;
|
|
62
62
|
export declare class BuildPluginApi extends BasePluginApi {
|
package/dist/node/stories.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import chokidar from 'chokidar';
|
|
2
|
+
import type { ServerStoryFile } from '@histoire/shared';
|
|
2
3
|
import { Context } from './context.js';
|
|
3
|
-
|
|
4
|
-
declare type StoryChangeHandler = (file?: StoryFile) => unknown;
|
|
4
|
+
declare type StoryChangeHandler = (file?: ServerStoryFile) => unknown;
|
|
5
5
|
export declare function onStoryChange(handler: StoryChangeHandler): void;
|
|
6
6
|
export declare function watchStories(newContext: Context): Promise<chokidar.FSWatcher>;
|
|
7
|
-
export declare function notifyStoryChange(file?:
|
|
8
|
-
export declare function addStory(relativeFilePath: string):
|
|
7
|
+
export declare function notifyStoryChange(file?: ServerStoryFile): void;
|
|
8
|
+
export declare function addStory(relativeFilePath: string): ServerStoryFile;
|
|
9
9
|
export declare function removeStory(relativeFilePath: string): void;
|
|
10
10
|
export declare function findAllStories(newContext: Context): Promise<void>;
|
|
11
11
|
export {};
|
package/dist/node/tree.d.ts
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
|
+
import type { ServerStoryFile, ServerTree, ServerTreeFile } from '@histoire/shared';
|
|
1
2
|
import type { HistoireConfig } from './config.js';
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
title: string;
|
|
5
|
-
path: string;
|
|
6
|
-
}
|
|
7
|
-
export interface TreeLeaf {
|
|
8
|
-
title: string;
|
|
9
|
-
index: number;
|
|
10
|
-
}
|
|
11
|
-
export interface TreeFolder {
|
|
12
|
-
title: string;
|
|
13
|
-
children: (TreeFolder | TreeLeaf)[];
|
|
14
|
-
}
|
|
15
|
-
export interface TreeGroup {
|
|
16
|
-
group: true;
|
|
17
|
-
id: string;
|
|
18
|
-
title: string;
|
|
19
|
-
children: (TreeFolder | TreeLeaf)[];
|
|
20
|
-
}
|
|
21
|
-
export declare type Tree = (TreeGroup | TreeFolder | TreeLeaf)[];
|
|
22
|
-
export declare function createPath(config: HistoireConfig, file: TreeFile): string[];
|
|
23
|
-
export declare function makeTree(config: HistoireConfig, files: StoryFile[]): Tree;
|
|
3
|
+
export declare function createPath(config: HistoireConfig, file: ServerTreeFile): string[];
|
|
4
|
+
export declare function makeTree(config: HistoireConfig, files: ServerStoryFile[]): ServerTree;
|