histoire 0.3.0 → 0.3.3
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/client/app/components/base/BaseEmpty.vue +1 -1
- package/dist/client/app/components/base/BaseOverflowMenu.vue +118 -0
- package/dist/client/app/components/base/BaseOverflowTab.vue +46 -0
- package/dist/client/app/components/exposed/Story.vue +12 -1
- package/dist/client/app/components/exposed/Variant.vue +6 -0
- package/dist/client/app/components/panel/PaneTabs.vue +64 -0
- package/dist/client/app/components/{story → panel}/StoryControls.vue +1 -1
- package/dist/client/app/components/{story → panel}/StoryDocs.vue +0 -0
- package/{src/client/app/components/story → dist/client/app/components/panel}/StoryEvent.vue +1 -0
- package/dist/client/app/components/{story → panel}/StoryEvents.vue +0 -0
- package/dist/client/app/components/{story → panel}/StorySidePanel.vue +3 -31
- package/dist/client/app/components/{story → panel}/StorySourceCode.vue +0 -0
- package/dist/client/app/components/sandbox/SandboxVue3.vue +10 -0
- package/dist/client/app/components/search/SearchPane.vue +19 -11
- package/dist/client/app/components/search/search-data.d.ts +9 -2
- package/dist/client/app/components/story/StoryResponsivePreview.vue +9 -131
- package/dist/client/app/components/story/StoryVariantSingle.vue +109 -0
- package/dist/client/app/components/story/StoryVariantSinglePreviewNative.vue +39 -0
- package/dist/client/app/components/story/StoryVariantSinglePreviewRemote.vue +153 -0
- package/dist/client/app/components/story/StoryVariantSingleView.vue +13 -6
- package/dist/client/app/components/story/StoryView.vue +2 -2
- package/dist/client/app/components/story/StoryViewer.vue +2 -92
- package/{src/client/app/components/story → dist/client/app/components}/toolbar/StoryVariantBackground.vue +3 -3
- package/dist/client/app/components/{story/toolbar → toolbar}/StoryVariantNewTab.vue +2 -2
- package/{src/client/app/components/story → dist/client/app/components}/toolbar/StoryVariantResponsiveSize.vue +3 -3
- package/{src/client/app/components/story → dist/client/app/components}/toolbar/StoryVariantTitle.vue +1 -1
- package/dist/client/app/stores/events.js +1 -1
- package/dist/client/app/stores/story.d.ts +27 -0
- package/dist/client/app/style/transitions.pcss +13 -0
- package/dist/client/app/types.d.ts +3 -0
- package/dist/client/app/util/mapping.js +2 -0
- package/dist/client/index.d.ts +2 -2
- package/dist/client/server/index.d.ts +7 -2
- package/dist/client/server/index.js +8 -26
- package/{src/client/server/Story.server.vue → dist/client/server/vue3/Story.vue} +1 -1
- package/dist/client/server/{Variant.server.vue → vue3/Variant.vue} +0 -0
- package/dist/client/server/vue3/run.d.ts +2 -0
- package/dist/client/server/vue3/run.js +32 -0
- package/dist/node/collect/worker.js +6 -2
- package/dist/node/search.d.ts +7 -1
- package/dist/node/search.js +21 -12
- package/dist/node/vite.js +3 -0
- package/dist/style.css +93 -69
- package/package.json +5 -6
- package/src/client/app/components/base/BaseEmpty.vue +1 -1
- package/src/client/app/components/base/BaseOverflowMenu.vue +118 -0
- package/src/client/app/components/base/BaseOverflowTab.vue +46 -0
- package/src/client/app/components/exposed/Story.vue +12 -1
- package/src/client/app/components/exposed/Variant.vue +6 -0
- package/src/client/app/components/panel/PaneTabs.vue +64 -0
- package/src/client/app/components/{story → panel}/StoryControls.vue +1 -1
- package/src/client/app/components/{story → panel}/StoryDocs.vue +0 -0
- package/{dist/client/app/components/story → src/client/app/components/panel}/StoryEvent.vue +1 -0
- package/src/client/app/components/{story → panel}/StoryEvents.vue +0 -0
- package/src/client/app/components/{story → panel}/StorySidePanel.vue +3 -31
- package/src/client/app/components/{story → panel}/StorySourceCode.vue +0 -0
- package/src/client/app/components/sandbox/SandboxVue3.vue +10 -0
- package/src/client/app/components/search/SearchPane.vue +19 -11
- package/src/client/app/components/search/search-data.ts +7 -2
- package/src/client/app/components/story/StoryResponsivePreview.vue +9 -131
- package/src/client/app/components/story/StoryVariantSingle.vue +109 -0
- package/src/client/app/components/story/StoryVariantSinglePreviewNative.vue +39 -0
- package/src/client/app/components/story/StoryVariantSinglePreviewRemote.vue +153 -0
- package/src/client/app/components/story/StoryVariantSingleView.vue +13 -6
- package/src/client/app/components/story/StoryView.vue +2 -2
- package/src/client/app/components/story/StoryViewer.vue +2 -92
- package/{dist/client/app/components/story → src/client/app/components}/toolbar/StoryVariantBackground.vue +3 -3
- package/src/client/app/components/{story/toolbar → toolbar}/StoryVariantNewTab.vue +2 -2
- package/{dist/client/app/components/story → src/client/app/components}/toolbar/StoryVariantResponsiveSize.vue +3 -3
- package/{dist/client/app/components/story → src/client/app/components}/toolbar/StoryVariantTitle.vue +1 -1
- package/src/client/app/sandbox.ts +1 -1
- package/src/client/app/stores/events.ts +1 -1
- package/src/client/app/style/transitions.pcss +13 -0
- package/src/client/app/types.ts +4 -0
- package/src/client/app/util/mapping.ts +2 -0
- package/src/client/index.ts +2 -2
- package/src/client/server/index.ts +14 -27
- package/{dist/client/server/Story.server.vue → src/client/server/vue3/Story.vue} +1 -1
- package/src/client/server/{Variant.server.vue → vue3/Variant.vue} +0 -0
- package/src/client/server/vue3/run.ts +38 -0
- package/src/node/collect/worker.ts +7 -2
- package/src/node/search.ts +23 -12
- package/src/node/vite.ts +3 -0
|
@@ -10,6 +10,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
10
10
|
icon?: string;
|
|
11
11
|
iconColor?: string;
|
|
12
12
|
initState?: () => any;
|
|
13
|
+
setupApp?: (payload: any) => unknown;
|
|
13
14
|
slots?: () => Readonly<any>;
|
|
14
15
|
state?: any;
|
|
15
16
|
source?: string;
|
|
@@ -19,6 +20,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
19
20
|
}[];
|
|
20
21
|
layout?: {
|
|
21
22
|
type: "single";
|
|
23
|
+
iframe?: boolean;
|
|
22
24
|
} | {
|
|
23
25
|
type: "grid";
|
|
24
26
|
width?: string | number;
|
|
@@ -39,6 +41,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
39
41
|
icon?: string;
|
|
40
42
|
iconColor?: string;
|
|
41
43
|
initState?: () => any;
|
|
44
|
+
setupApp?: (payload: any) => unknown;
|
|
42
45
|
slots?: () => Readonly<any>;
|
|
43
46
|
state?: any;
|
|
44
47
|
source?: string;
|
|
@@ -46,6 +49,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
46
49
|
configReady?: boolean;
|
|
47
50
|
previewReady?: boolean;
|
|
48
51
|
};
|
|
52
|
+
slots?: () => Readonly<any>;
|
|
49
53
|
}[]>;
|
|
50
54
|
setStories: (value: Story[]) => void;
|
|
51
55
|
currentStory: import("vue").ComputedRef<{
|
|
@@ -58,6 +62,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
58
62
|
icon?: string;
|
|
59
63
|
iconColor?: string;
|
|
60
64
|
initState?: () => any;
|
|
65
|
+
setupApp?: (payload: any) => unknown;
|
|
61
66
|
slots?: () => Readonly<any>;
|
|
62
67
|
state?: any;
|
|
63
68
|
source?: string;
|
|
@@ -67,6 +72,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
67
72
|
}[];
|
|
68
73
|
layout?: {
|
|
69
74
|
type: "single";
|
|
75
|
+
iframe?: boolean;
|
|
70
76
|
} | {
|
|
71
77
|
type: "grid";
|
|
72
78
|
width?: string | number;
|
|
@@ -87,6 +93,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
87
93
|
icon?: string;
|
|
88
94
|
iconColor?: string;
|
|
89
95
|
initState?: () => any;
|
|
96
|
+
setupApp?: (payload: any) => unknown;
|
|
90
97
|
slots?: () => Readonly<any>;
|
|
91
98
|
state?: any;
|
|
92
99
|
source?: string;
|
|
@@ -94,6 +101,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
94
101
|
configReady?: boolean;
|
|
95
102
|
previewReady?: boolean;
|
|
96
103
|
};
|
|
104
|
+
slots?: () => Readonly<any>;
|
|
97
105
|
}>;
|
|
98
106
|
currentVariant: import("vue").ComputedRef<{
|
|
99
107
|
id: string;
|
|
@@ -101,6 +109,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
101
109
|
icon?: string;
|
|
102
110
|
iconColor?: string;
|
|
103
111
|
initState?: () => any;
|
|
112
|
+
setupApp?: (payload: any) => unknown;
|
|
104
113
|
slots?: () => Readonly<any>;
|
|
105
114
|
state?: any;
|
|
106
115
|
source?: string;
|
|
@@ -121,6 +130,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
121
130
|
icon?: string;
|
|
122
131
|
iconColor?: string;
|
|
123
132
|
initState?: () => any;
|
|
133
|
+
setupApp?: (payload: any) => unknown;
|
|
124
134
|
slots?: () => Readonly<any>;
|
|
125
135
|
state?: any;
|
|
126
136
|
source?: string;
|
|
@@ -130,6 +140,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
130
140
|
}[];
|
|
131
141
|
layout?: {
|
|
132
142
|
type: "single";
|
|
143
|
+
iframe?: boolean;
|
|
133
144
|
} | {
|
|
134
145
|
type: "grid";
|
|
135
146
|
width?: string | number;
|
|
@@ -150,6 +161,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
150
161
|
icon?: string;
|
|
151
162
|
iconColor?: string;
|
|
152
163
|
initState?: () => any;
|
|
164
|
+
setupApp?: (payload: any) => unknown;
|
|
153
165
|
slots?: () => Readonly<any>;
|
|
154
166
|
state?: any;
|
|
155
167
|
source?: string;
|
|
@@ -157,6 +169,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
157
169
|
configReady?: boolean;
|
|
158
170
|
previewReady?: boolean;
|
|
159
171
|
};
|
|
172
|
+
slots?: () => Readonly<any>;
|
|
160
173
|
}[]>;
|
|
161
174
|
setStories: (value: Story[]) => void;
|
|
162
175
|
currentStory: import("vue").ComputedRef<{
|
|
@@ -169,6 +182,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
169
182
|
icon?: string;
|
|
170
183
|
iconColor?: string;
|
|
171
184
|
initState?: () => any;
|
|
185
|
+
setupApp?: (payload: any) => unknown;
|
|
172
186
|
slots?: () => Readonly<any>;
|
|
173
187
|
state?: any;
|
|
174
188
|
source?: string;
|
|
@@ -178,6 +192,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
178
192
|
}[];
|
|
179
193
|
layout?: {
|
|
180
194
|
type: "single";
|
|
195
|
+
iframe?: boolean;
|
|
181
196
|
} | {
|
|
182
197
|
type: "grid";
|
|
183
198
|
width?: string | number;
|
|
@@ -198,6 +213,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
198
213
|
icon?: string;
|
|
199
214
|
iconColor?: string;
|
|
200
215
|
initState?: () => any;
|
|
216
|
+
setupApp?: (payload: any) => unknown;
|
|
201
217
|
slots?: () => Readonly<any>;
|
|
202
218
|
state?: any;
|
|
203
219
|
source?: string;
|
|
@@ -205,6 +221,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
205
221
|
configReady?: boolean;
|
|
206
222
|
previewReady?: boolean;
|
|
207
223
|
};
|
|
224
|
+
slots?: () => Readonly<any>;
|
|
208
225
|
}>;
|
|
209
226
|
currentVariant: import("vue").ComputedRef<{
|
|
210
227
|
id: string;
|
|
@@ -212,6 +229,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
212
229
|
icon?: string;
|
|
213
230
|
iconColor?: string;
|
|
214
231
|
initState?: () => any;
|
|
232
|
+
setupApp?: (payload: any) => unknown;
|
|
215
233
|
slots?: () => Readonly<any>;
|
|
216
234
|
state?: any;
|
|
217
235
|
source?: string;
|
|
@@ -232,6 +250,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
232
250
|
icon?: string;
|
|
233
251
|
iconColor?: string;
|
|
234
252
|
initState?: () => any;
|
|
253
|
+
setupApp?: (payload: any) => unknown;
|
|
235
254
|
slots?: () => Readonly<any>;
|
|
236
255
|
state?: any;
|
|
237
256
|
source?: string;
|
|
@@ -241,6 +260,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
241
260
|
}[];
|
|
242
261
|
layout?: {
|
|
243
262
|
type: "single";
|
|
263
|
+
iframe?: boolean;
|
|
244
264
|
} | {
|
|
245
265
|
type: "grid";
|
|
246
266
|
width?: string | number;
|
|
@@ -261,6 +281,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
261
281
|
icon?: string;
|
|
262
282
|
iconColor?: string;
|
|
263
283
|
initState?: () => any;
|
|
284
|
+
setupApp?: (payload: any) => unknown;
|
|
264
285
|
slots?: () => Readonly<any>;
|
|
265
286
|
state?: any;
|
|
266
287
|
source?: string;
|
|
@@ -268,6 +289,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
268
289
|
configReady?: boolean;
|
|
269
290
|
previewReady?: boolean;
|
|
270
291
|
};
|
|
292
|
+
slots?: () => Readonly<any>;
|
|
271
293
|
}[]>;
|
|
272
294
|
setStories: (value: Story[]) => void;
|
|
273
295
|
currentStory: import("vue").ComputedRef<{
|
|
@@ -280,6 +302,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
280
302
|
icon?: string;
|
|
281
303
|
iconColor?: string;
|
|
282
304
|
initState?: () => any;
|
|
305
|
+
setupApp?: (payload: any) => unknown;
|
|
283
306
|
slots?: () => Readonly<any>;
|
|
284
307
|
state?: any;
|
|
285
308
|
source?: string;
|
|
@@ -289,6 +312,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
289
312
|
}[];
|
|
290
313
|
layout?: {
|
|
291
314
|
type: "single";
|
|
315
|
+
iframe?: boolean;
|
|
292
316
|
} | {
|
|
293
317
|
type: "grid";
|
|
294
318
|
width?: string | number;
|
|
@@ -309,6 +333,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
309
333
|
icon?: string;
|
|
310
334
|
iconColor?: string;
|
|
311
335
|
initState?: () => any;
|
|
336
|
+
setupApp?: (payload: any) => unknown;
|
|
312
337
|
slots?: () => Readonly<any>;
|
|
313
338
|
state?: any;
|
|
314
339
|
source?: string;
|
|
@@ -316,6 +341,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
316
341
|
configReady?: boolean;
|
|
317
342
|
previewReady?: boolean;
|
|
318
343
|
};
|
|
344
|
+
slots?: () => Readonly<any>;
|
|
319
345
|
}>;
|
|
320
346
|
currentVariant: import("vue").ComputedRef<{
|
|
321
347
|
id: string;
|
|
@@ -323,6 +349,7 @@ export declare const useStoryStore: import("pinia").StoreDefinition<"story", imp
|
|
|
323
349
|
icon?: string;
|
|
324
350
|
iconColor?: string;
|
|
325
351
|
initState?: () => any;
|
|
352
|
+
setupApp?: (payload: any) => unknown;
|
|
326
353
|
slots?: () => Readonly<any>;
|
|
327
354
|
state?: any;
|
|
328
355
|
source?: string;
|
|
@@ -11,6 +11,19 @@
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
.__histoire-scale-y {
|
|
15
|
+
&-enter-active,
|
|
16
|
+
&-leave-active {
|
|
17
|
+
transition: transform .15s, opacity .15s;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&-enter-from,
|
|
21
|
+
&-leave-to {
|
|
22
|
+
transform: scaleY(0);
|
|
23
|
+
opacity: 0;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
14
27
|
.__histoire-fade {
|
|
15
28
|
&-enter-active,
|
|
16
29
|
&-leave-active {
|
|
@@ -13,6 +13,7 @@ export interface Story {
|
|
|
13
13
|
variants: Variant[];
|
|
14
14
|
layout?: {
|
|
15
15
|
type: 'single';
|
|
16
|
+
iframe?: boolean;
|
|
16
17
|
} | {
|
|
17
18
|
type: 'grid';
|
|
18
19
|
width?: number | string;
|
|
@@ -22,6 +23,7 @@ export interface Story {
|
|
|
22
23
|
docsOnly?: boolean;
|
|
23
24
|
file?: StoryFile;
|
|
24
25
|
lastSelectedVariant?: Variant;
|
|
26
|
+
slots?: () => Readonly<any>;
|
|
25
27
|
}
|
|
26
28
|
export interface Variant {
|
|
27
29
|
id: string;
|
|
@@ -29,6 +31,7 @@ export interface Variant {
|
|
|
29
31
|
icon?: string;
|
|
30
32
|
iconColor?: string;
|
|
31
33
|
initState?: () => any;
|
|
34
|
+
setupApp?: (payload: any) => unknown;
|
|
32
35
|
slots?: () => Readonly<any>;
|
|
33
36
|
state?: any;
|
|
34
37
|
source?: string;
|
|
@@ -8,6 +8,7 @@ export function mapFile(file, existingFile) {
|
|
|
8
8
|
title: file.story.title,
|
|
9
9
|
file: markRaw(file),
|
|
10
10
|
variants: file.story.variants.map(v => mapVariant(v)),
|
|
11
|
+
slots: () => ({}),
|
|
11
12
|
},
|
|
12
13
|
};
|
|
13
14
|
if (existingFile) {
|
|
@@ -37,6 +38,7 @@ export function mapVariant(variant) {
|
|
|
37
38
|
...variant,
|
|
38
39
|
state: null,
|
|
39
40
|
initState: null,
|
|
41
|
+
setupApp: null,
|
|
40
42
|
slots: () => ({}),
|
|
41
43
|
previewReady: false,
|
|
42
44
|
};
|
package/dist/client/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { Story, Variant } from './app/types.js';
|
|
|
3
3
|
export { hstEvent } from './app/util/events';
|
|
4
4
|
export declare type Vue3StorySetupHandler = (payload: {
|
|
5
5
|
app: App;
|
|
6
|
-
story
|
|
7
|
-
variant
|
|
6
|
+
story?: Story;
|
|
7
|
+
variant?: Variant;
|
|
8
8
|
}) => Promise<void> | void;
|
|
9
9
|
export declare function defineSetupVue3(handler: Vue3StorySetupHandler): Vue3StorySetupHandler;
|
|
@@ -1,2 +1,7 @@
|
|
|
1
|
-
import type { StoryFile } from '../../node/types';
|
|
2
|
-
export
|
|
1
|
+
import type { StoryFile, Story } from '../../node/types';
|
|
2
|
+
export interface ServerRunPayload {
|
|
3
|
+
file: StoryFile;
|
|
4
|
+
storyData: Story[];
|
|
5
|
+
el: HTMLElement;
|
|
6
|
+
}
|
|
7
|
+
export declare function run(payload: ServerRunPayload): Promise<any>;
|
|
@@ -1,27 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
addStory(data) {
|
|
10
|
-
storyData.push(data);
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
render() {
|
|
14
|
-
return h(Comp, {
|
|
15
|
-
ref: 'comp',
|
|
16
|
-
data: file,
|
|
17
|
-
});
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
// eslint-disable-next-line vue/multi-word-component-names
|
|
21
|
-
app.component('Story', Story);
|
|
22
|
-
// eslint-disable-next-line vue/multi-word-component-names
|
|
23
|
-
app.component('Variant', Variant);
|
|
24
|
-
registerVueComponents(app);
|
|
25
|
-
app.mount(el);
|
|
26
|
-
app.unmount();
|
|
1
|
+
export async function run(payload) {
|
|
2
|
+
let result;
|
|
3
|
+
// @TODO if (vue3)
|
|
4
|
+
{
|
|
5
|
+
const { run } = await import('./vue3/run.js');
|
|
6
|
+
result = await run(payload);
|
|
7
|
+
}
|
|
8
|
+
return result;
|
|
27
9
|
}
|
|
File without changes
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { createApp, h } from 'vue';
|
|
2
|
+
import { registerVueComponents } from '@histoire/controls';
|
|
3
|
+
import Story from './Story.vue';
|
|
4
|
+
import Variant from './Variant.vue';
|
|
5
|
+
// @ts-expect-error virtual module id
|
|
6
|
+
import * as setup from '$histoire-setup';
|
|
7
|
+
export async function run({ file, storyData, el }) {
|
|
8
|
+
const { default: Comp } = await import(file.moduleId);
|
|
9
|
+
const app = createApp({
|
|
10
|
+
provide: {
|
|
11
|
+
addStory(data) {
|
|
12
|
+
storyData.push(data);
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
render() {
|
|
16
|
+
return h(Comp, {
|
|
17
|
+
ref: 'comp',
|
|
18
|
+
data: file,
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
if (typeof setup?.setupVue3 === 'function') {
|
|
23
|
+
await setup.setupVue3({ app });
|
|
24
|
+
}
|
|
25
|
+
// eslint-disable-next-line vue/multi-word-component-names
|
|
26
|
+
app.component('Story', Story);
|
|
27
|
+
// eslint-disable-next-line vue/multi-word-component-names
|
|
28
|
+
app.component('Variant', Variant);
|
|
29
|
+
registerVueComponents(app);
|
|
30
|
+
app.mount(el);
|
|
31
|
+
app.unmount();
|
|
32
|
+
}
|
|
@@ -26,9 +26,13 @@ export default async (payload) => {
|
|
|
26
26
|
const { destroy: destroyDomEnv } = createDomEnv();
|
|
27
27
|
const el = window.document.createElement('div');
|
|
28
28
|
// Mount app to collect stories/variants
|
|
29
|
-
const { run } = await runner.executeFile(resolve(__dirname, '../../client/server/index.js'));
|
|
29
|
+
const { run } = (await runner.executeFile(resolve(__dirname, '../../client/server/index.js')));
|
|
30
30
|
const storyData = [];
|
|
31
|
-
await run(
|
|
31
|
+
await run({
|
|
32
|
+
file: payload.storyFile,
|
|
33
|
+
storyData,
|
|
34
|
+
el,
|
|
35
|
+
});
|
|
32
36
|
destroyDomEnv();
|
|
33
37
|
return {
|
|
34
38
|
storyData,
|
package/dist/node/search.d.ts
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { Context } from './context.js';
|
|
2
|
-
export declare function generateSearchData(ctx: Context): Promise<
|
|
2
|
+
export declare function generateSearchData(ctx: Context): Promise<{
|
|
3
|
+
index: unknown;
|
|
4
|
+
idMap: Record<number, {
|
|
5
|
+
id: string;
|
|
6
|
+
kind: string;
|
|
7
|
+
}>;
|
|
8
|
+
}>;
|
package/dist/node/search.js
CHANGED
|
@@ -1,45 +1,51 @@
|
|
|
1
1
|
import { createRequire } from 'module';
|
|
2
2
|
import flexsearch from 'flexsearch';
|
|
3
3
|
import path from 'pathe';
|
|
4
|
+
import Case from 'case';
|
|
4
5
|
import { loadModule } from './load.js';
|
|
5
6
|
const require = createRequire(import.meta.url);
|
|
6
7
|
export async function generateSearchData(ctx) {
|
|
8
|
+
let uid = 0;
|
|
9
|
+
const idMap = {};
|
|
7
10
|
const flexsearchRoot = path.dirname(require.resolve('flexsearch/package.json'));
|
|
8
11
|
const searchIndex = new flexsearch.Document({
|
|
9
|
-
preset: '
|
|
12
|
+
preset: 'memory',
|
|
10
13
|
document: {
|
|
11
14
|
id: 'id',
|
|
12
15
|
index: [
|
|
13
16
|
'title',
|
|
14
17
|
'docs',
|
|
15
18
|
],
|
|
16
|
-
store: [
|
|
17
|
-
'kind',
|
|
18
|
-
],
|
|
19
19
|
},
|
|
20
20
|
charset: await loadModule(`${flexsearchRoot}/dist/module/lang/latin/advanced.js`),
|
|
21
21
|
language: await loadModule(`${flexsearchRoot}/dist/module/lang/en.js`),
|
|
22
|
-
tokenize: '
|
|
22
|
+
tokenize: 'forward',
|
|
23
23
|
});
|
|
24
|
+
function addToIdMap(id, kind) {
|
|
25
|
+
const n = uid++;
|
|
26
|
+
idMap[n] = { id, kind };
|
|
27
|
+
return n;
|
|
28
|
+
}
|
|
24
29
|
for (const storyFile of ctx.storyFiles) {
|
|
25
30
|
if (storyFile.story) {
|
|
26
31
|
searchIndex.add({
|
|
27
|
-
id: storyFile.story.id,
|
|
28
|
-
|
|
29
|
-
title: storyFile.story.title,
|
|
32
|
+
id: addToIdMap(storyFile.story.id, 'story'),
|
|
33
|
+
title: processTitle(storyFile.story.title),
|
|
30
34
|
docs: '', // @TODO
|
|
31
35
|
});
|
|
32
36
|
for (const variant of storyFile.story.variants) {
|
|
33
37
|
searchIndex.add({
|
|
34
|
-
id: `${storyFile.story.id}:${variant.id}`,
|
|
35
|
-
|
|
36
|
-
title: `${storyFile.story.title} ${variant.title}`,
|
|
38
|
+
id: addToIdMap(`${storyFile.story.id}:${variant.id}`, 'variant'),
|
|
39
|
+
title: processTitle(`${storyFile.story.title} ${variant.title}`),
|
|
37
40
|
docs: '', // @TODO
|
|
38
41
|
});
|
|
39
42
|
}
|
|
40
43
|
}
|
|
41
44
|
}
|
|
42
|
-
return
|
|
45
|
+
return {
|
|
46
|
+
index: await exportSearchIndex(searchIndex),
|
|
47
|
+
idMap,
|
|
48
|
+
};
|
|
43
49
|
}
|
|
44
50
|
const exportKeys = new Set([
|
|
45
51
|
'reg',
|
|
@@ -66,3 +72,6 @@ async function exportSearchIndex(index) {
|
|
|
66
72
|
});
|
|
67
73
|
});
|
|
68
74
|
}
|
|
75
|
+
function processTitle(title) {
|
|
76
|
+
return title.split(' ').map(str => Case.lower(str)).join(' ');
|
|
77
|
+
}
|
package/dist/node/vite.js
CHANGED