@histoire/shared 0.14.1 → 0.15.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/types/config.d.ts +11 -1
- package/dist/types/plugin.d.ts +13 -5
- package/package.json +2 -2
- package/src/types/config.ts +11 -1
- package/src/types/plugin.ts +13 -5
package/dist/types/config.d.ts
CHANGED
|
@@ -197,7 +197,7 @@ export interface HistoireConfig {
|
|
|
197
197
|
/**
|
|
198
198
|
* Transpile dependencies when collecting stories on Node.js
|
|
199
199
|
*/
|
|
200
|
-
viteNodeInlineDeps?: RegExp[];
|
|
200
|
+
viteNodeInlineDeps?: (string | RegExp)[];
|
|
201
201
|
/**
|
|
202
202
|
* Determine the transform method of modules
|
|
203
203
|
*/
|
|
@@ -223,5 +223,15 @@ export interface HistoireConfig {
|
|
|
223
223
|
* By default based on available number of cores.
|
|
224
224
|
*/
|
|
225
225
|
collectMaxThreads?: number;
|
|
226
|
+
/**
|
|
227
|
+
* Build options
|
|
228
|
+
*/
|
|
229
|
+
build?: {
|
|
230
|
+
/**
|
|
231
|
+
* By default all dependencies in `node_modules` are bundled into a single 'vendors' file.
|
|
232
|
+
* You can use this option to exclude some dependencies from this file.
|
|
233
|
+
*/
|
|
234
|
+
excludeFromVendorsChunk?: (string | RegExp)[];
|
|
235
|
+
};
|
|
226
236
|
}
|
|
227
237
|
export type ConfigMode = 'build' | 'dev';
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type path from 'pathe';
|
|
|
2
2
|
import type fs from 'fs-extra';
|
|
3
3
|
import type pc from 'picocolors';
|
|
4
4
|
import type chokidar from 'chokidar';
|
|
5
|
+
import type { InlineConfig as ViteInlineConfig } from 'vite';
|
|
5
6
|
import type { ServerStoryFile, ServerStory, ServerVariant } from './story.js';
|
|
6
7
|
import type { HistoireConfig, ConfigMode } from './config.js';
|
|
7
8
|
import type { PluginCommand } from './command.js';
|
|
@@ -36,16 +37,19 @@ export interface PluginApiBase {
|
|
|
36
37
|
export interface PluginApiDev extends PluginApiBase {
|
|
37
38
|
watcher: typeof chokidar;
|
|
38
39
|
}
|
|
39
|
-
export type
|
|
40
|
+
export type ChangeViteConfigCallback = (config: ViteInlineConfig) => Awaitable<void>;
|
|
41
|
+
export type BuildEndCallback = () => Awaitable<void>;
|
|
40
42
|
export type PreviewStoryCallback = (payload: {
|
|
41
43
|
file: string;
|
|
42
44
|
story: ServerStory;
|
|
43
45
|
variant: ServerVariant;
|
|
44
46
|
url: string;
|
|
45
|
-
}) =>
|
|
47
|
+
}) => Awaitable<void>;
|
|
46
48
|
export interface PluginApiBuild extends PluginApiBase {
|
|
49
|
+
changeViteConfigCallbacks: ChangeViteConfigCallback[];
|
|
47
50
|
buildEndCallbacks: BuildEndCallback[];
|
|
48
51
|
previewStoryCallbacks: PreviewStoryCallback[];
|
|
52
|
+
changeViteConfig: (cb: ChangeViteConfigCallback) => void;
|
|
49
53
|
onBuildEnd: (cb: BuildEndCallback) => void;
|
|
50
54
|
onPreviewStory: (cb: PreviewStoryCallback) => void;
|
|
51
55
|
}
|
|
@@ -79,16 +83,20 @@ export interface Plugin {
|
|
|
79
83
|
/**
|
|
80
84
|
* Use this hook to read and store the final resolved histoire config.
|
|
81
85
|
*/
|
|
82
|
-
configResolved?: (config: HistoireConfig) =>
|
|
86
|
+
configResolved?: (config: HistoireConfig) => Awaitable<void>;
|
|
83
87
|
/**
|
|
84
88
|
* Use this hook to do processing during development. The `onCleanup` hook
|
|
85
89
|
* should handle cleanup tasks when development server is closed.
|
|
86
90
|
*/
|
|
87
|
-
onDev?: (api: PluginApiDev, onCleanup: (cb: () =>
|
|
91
|
+
onDev?: (api: PluginApiDev, onCleanup: (cb: () => Awaitable<void>) => void) => Awaitable<void>;
|
|
88
92
|
/**
|
|
89
93
|
* Use this hook to do processing during production build.
|
|
90
94
|
*/
|
|
91
|
-
onBuild?: (api: PluginApiBuild) =>
|
|
95
|
+
onBuild?: (api: PluginApiBuild) => Awaitable<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Use this hook to do processing when preview is started.
|
|
98
|
+
*/
|
|
99
|
+
onPreview?: () => Awaitable<void>;
|
|
92
100
|
/**
|
|
93
101
|
* This plugin exposes a support plugin (example: Vue, Svelte, etc.)
|
|
94
102
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@histoire/shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Shared utilities for Histoire",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"types": "./dist/index.d.ts",
|
|
26
26
|
"sideEffects": false,
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@histoire/vendors": "^0.
|
|
28
|
+
"@histoire/vendors": "^0.15.0",
|
|
29
29
|
"@types/fs-extra": "^9.0.13",
|
|
30
30
|
"@types/markdown-it": "^12.2.3",
|
|
31
31
|
"chokidar": "^3.5.3",
|
package/src/types/config.ts
CHANGED
|
@@ -206,7 +206,7 @@ export interface HistoireConfig {
|
|
|
206
206
|
/**
|
|
207
207
|
* Transpile dependencies when collecting stories on Node.js
|
|
208
208
|
*/
|
|
209
|
-
viteNodeInlineDeps?: RegExp[]
|
|
209
|
+
viteNodeInlineDeps?: (string | RegExp)[]
|
|
210
210
|
/**
|
|
211
211
|
* Determine the transform method of modules
|
|
212
212
|
*/
|
|
@@ -232,6 +232,16 @@ export interface HistoireConfig {
|
|
|
232
232
|
* By default based on available number of cores.
|
|
233
233
|
*/
|
|
234
234
|
collectMaxThreads?: number
|
|
235
|
+
/**
|
|
236
|
+
* Build options
|
|
237
|
+
*/
|
|
238
|
+
build?: {
|
|
239
|
+
/**
|
|
240
|
+
* By default all dependencies in `node_modules` are bundled into a single 'vendors' file.
|
|
241
|
+
* You can use this option to exclude some dependencies from this file.
|
|
242
|
+
*/
|
|
243
|
+
excludeFromVendorsChunk?: (string | RegExp)[]
|
|
244
|
+
}
|
|
235
245
|
}
|
|
236
246
|
|
|
237
247
|
export type ConfigMode = 'build' | 'dev'
|
package/src/types/plugin.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type path from 'pathe'
|
|
|
2
2
|
import type fs from 'fs-extra'
|
|
3
3
|
import type pc from 'picocolors'
|
|
4
4
|
import type chokidar from 'chokidar'
|
|
5
|
+
import type { InlineConfig as ViteInlineConfig } from 'vite'
|
|
5
6
|
import type {
|
|
6
7
|
ServerStoryFile,
|
|
7
8
|
ServerStory,
|
|
@@ -56,13 +57,16 @@ export interface PluginApiDev extends PluginApiBase {
|
|
|
56
57
|
watcher: typeof chokidar
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
export type
|
|
60
|
-
export type
|
|
60
|
+
export type ChangeViteConfigCallback = (config: ViteInlineConfig) => Awaitable<void>
|
|
61
|
+
export type BuildEndCallback = () => Awaitable<void>
|
|
62
|
+
export type PreviewStoryCallback = (payload: { file: string, story: ServerStory, variant: ServerVariant, url: string }) => Awaitable<void>
|
|
61
63
|
|
|
62
64
|
export interface PluginApiBuild extends PluginApiBase {
|
|
65
|
+
changeViteConfigCallbacks: ChangeViteConfigCallback[]
|
|
63
66
|
buildEndCallbacks: BuildEndCallback[]
|
|
64
67
|
previewStoryCallbacks: PreviewStoryCallback[]
|
|
65
68
|
|
|
69
|
+
changeViteConfig: (cb: ChangeViteConfigCallback) => void
|
|
66
70
|
onBuildEnd: (cb: BuildEndCallback) => void
|
|
67
71
|
onPreviewStory: (cb: PreviewStoryCallback) => void
|
|
68
72
|
}
|
|
@@ -98,16 +102,20 @@ export interface Plugin {
|
|
|
98
102
|
/**
|
|
99
103
|
* Use this hook to read and store the final resolved histoire config.
|
|
100
104
|
*/
|
|
101
|
-
configResolved?: (config: HistoireConfig) =>
|
|
105
|
+
configResolved?: (config: HistoireConfig) => Awaitable<void>
|
|
102
106
|
/**
|
|
103
107
|
* Use this hook to do processing during development. The `onCleanup` hook
|
|
104
108
|
* should handle cleanup tasks when development server is closed.
|
|
105
109
|
*/
|
|
106
|
-
onDev?: (api: PluginApiDev, onCleanup: (cb: () =>
|
|
110
|
+
onDev?: (api: PluginApiDev, onCleanup: (cb: () => Awaitable<void>) => void) => Awaitable<void>
|
|
107
111
|
/**
|
|
108
112
|
* Use this hook to do processing during production build.
|
|
109
113
|
*/
|
|
110
|
-
onBuild?: (api: PluginApiBuild) =>
|
|
114
|
+
onBuild?: (api: PluginApiBuild) => Awaitable<void>
|
|
115
|
+
/**
|
|
116
|
+
* Use this hook to do processing when preview is started.
|
|
117
|
+
*/
|
|
118
|
+
onPreview?: () => Awaitable<void>
|
|
111
119
|
/**
|
|
112
120
|
* This plugin exposes a support plugin (example: Vue, Svelte, etc.)
|
|
113
121
|
*/
|