histoire 0.16.1 → 0.16.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/dist/node/build.js +2 -2
- package/dist/node/builtin-plugins/tailwind-tokens.js +3 -3
- package/dist/node/collect/index.js +1 -1
- package/dist/node/config.js +10 -10
- package/dist/node/tree.js +7 -4
- package/package.json +6 -5
- package/src/node/build.ts +2 -2
- package/src/node/builtin-plugins/tailwind-tokens.ts +3 -3
- package/src/node/collect/index.ts +1 -1
- package/src/node/config.ts +12 -8
- package/src/node/tree.ts +10 -4
package/dist/node/build.js
CHANGED
|
@@ -166,9 +166,9 @@ export async function build(ctx) {
|
|
|
166
166
|
await writeFile('histoire.json', JSON.stringify(getSerializedStoryData(ctx), null, 2), ctx);
|
|
167
167
|
const duration = performance.now() - startTime;
|
|
168
168
|
if (emptyStoryCount) {
|
|
169
|
-
console.warn(pc.yellow(`⚠️ ${emptyStoryCount} empty story file`));
|
|
169
|
+
console.warn(pc.yellow(`⚠️ ${emptyStoryCount} empty story file${emptyStoryCount === 1 ? '' : 's'}`));
|
|
170
170
|
}
|
|
171
|
-
console.log(pc.green(`✅ Built ${storyCount}
|
|
171
|
+
console.log(pc.green(`✅ Built ${storyCount} stor${storyCount === 1 ? 'y' : 'ies'} (${variantCount} variant${variantCount === 1 ? '' : 's'}) in ${Math.round(duration / 1000 * 100) / 100}s`));
|
|
172
172
|
// Render
|
|
173
173
|
if (previewStoryCallbacks.length) {
|
|
174
174
|
const { baseUrl, close } = await startPreview(null, ctx);
|
|
@@ -125,7 +125,7 @@ export default {
|
|
|
125
125
|
}, ({ color}) => h('div', {
|
|
126
126
|
class: '__hst-shade',
|
|
127
127
|
style: {
|
|
128
|
-
backgroundColor: color,
|
|
128
|
+
backgroundColor: color.replace('<alpha-value>', 1),
|
|
129
129
|
},
|
|
130
130
|
})))),
|
|
131
131
|
onMountControls: (api) => mountApp(api, () => [
|
|
@@ -148,7 +148,7 @@ export default {
|
|
|
148
148
|
}, ({ color}) => h('div', {
|
|
149
149
|
class: '__hst-shade __hst-text',
|
|
150
150
|
style: {
|
|
151
|
-
color,
|
|
151
|
+
color: color.replace('<alpha-value>', 1),
|
|
152
152
|
},
|
|
153
153
|
}, 'Aa')))),
|
|
154
154
|
onMountControls: (api) => mountApp(api, () => [
|
|
@@ -171,7 +171,7 @@ export default {
|
|
|
171
171
|
}, ({ color}) => h('div', {
|
|
172
172
|
class: '__hst-shade __hst-border',
|
|
173
173
|
style: {
|
|
174
|
-
borderColor: color,
|
|
174
|
+
borderColor: color.replace('<alpha-value>', 1),
|
|
175
175
|
},
|
|
176
176
|
})))),
|
|
177
177
|
onMountControls: (api) => mountApp(api, () => [
|
|
@@ -30,7 +30,7 @@ export function useCollectStories(options, ctx) {
|
|
|
30
30
|
const threadsCount = ctx.mode === 'dev'
|
|
31
31
|
? Math.max(Math.min(maxThreads, Math.floor(cpus().length / 2)), 1)
|
|
32
32
|
: Math.max(Math.min(maxThreads, cpus().length - 1), 1);
|
|
33
|
-
console.log(pc.blue(`Using ${threadsCount}
|
|
33
|
+
console.log(pc.blue(`Using ${threadsCount} thread${threadsCount === 1 ? '' : 's'} for story collection`));
|
|
34
34
|
const threadPool = new Tinypool({
|
|
35
35
|
filename: new URL('./worker.js', import.meta.url).href,
|
|
36
36
|
// WebContainer compatibility (Stackblitz)
|
package/dist/node/config.js
CHANGED
|
@@ -167,15 +167,15 @@ export const mergeBuildConfig = createDefu((obj, key, value) => {
|
|
|
167
167
|
export const mergeConfig = createDefu((obj, key, value) => {
|
|
168
168
|
if (obj[key] && key === 'vite') {
|
|
169
169
|
const initialValue = obj[key];
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
170
|
+
// Convert to functions
|
|
171
|
+
const initialFn = typeof initialValue === 'function' ? initialValue : async () => initialValue;
|
|
172
|
+
const valueFn = typeof value === 'function' ? value : async () => value;
|
|
173
|
+
obj[key] = async (...args) => {
|
|
174
|
+
// `mergeViteConfig` doesn't accept functions so we need to call them
|
|
175
|
+
const initialResult = await initialFn(...args);
|
|
176
|
+
const valueResult = await valueFn(...args);
|
|
177
|
+
return mergeViteConfig(initialResult, valueResult);
|
|
178
|
+
};
|
|
179
179
|
return true;
|
|
180
180
|
}
|
|
181
181
|
if (obj[key] && key === 'plugins') {
|
|
@@ -265,7 +265,7 @@ export async function processConfig(ctx) {
|
|
|
265
265
|
};
|
|
266
266
|
const fileCheck = (file, resolvedFile, configPathForError) => {
|
|
267
267
|
if (!file.startsWith('http') && !file.startsWith('@') && !fs.existsSync(resolvedFile)) {
|
|
268
|
-
console.warn(pc.yellow(`Histoire config: ${configPathForError} file ${file} does not exist (resolved to ${resolvedFile}), check for typos in the
|
|
268
|
+
console.warn(pc.yellow(`Histoire config: ${configPathForError} file ${file} does not exist (resolved to ${resolvedFile}), check for typos in the path`));
|
|
269
269
|
}
|
|
270
270
|
};
|
|
271
271
|
config.outDir = resolveFsPath(config.outDir, true);
|
package/dist/node/tree.js
CHANGED
|
@@ -4,10 +4,13 @@ export function createPath(config, file) {
|
|
|
4
4
|
return file.title.split('/');
|
|
5
5
|
}
|
|
6
6
|
if (config.tree.file === 'path') {
|
|
7
|
-
const
|
|
8
|
-
path
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
const paths = file.path.split('/').slice(0, -1);
|
|
8
|
+
// check if tree file path is a plugin
|
|
9
|
+
const index = paths.findIndex(p => p.includes('.histoire'));
|
|
10
|
+
if (index !== -1) {
|
|
11
|
+
return ['plugins', file.title];
|
|
12
|
+
}
|
|
13
|
+
return [...paths, file.title];
|
|
11
14
|
}
|
|
12
15
|
return config.tree.file(file);
|
|
13
16
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "histoire",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.4",
|
|
4
4
|
"description": "A fast story book powered by Vite",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -64,10 +64,10 @@
|
|
|
64
64
|
"shiki-es": "^0.2.0",
|
|
65
65
|
"sirv": "^2.0.2",
|
|
66
66
|
"vite-node": "0.28.4",
|
|
67
|
-
"@histoire/app": "^0.16.
|
|
68
|
-
"@histoire/controls": "^0.16.
|
|
67
|
+
"@histoire/app": "^0.16.4",
|
|
68
|
+
"@histoire/controls": "^0.16.4",
|
|
69
69
|
"@histoire/vendors": "^0.16.0",
|
|
70
|
-
"@histoire/shared": "^0.16.
|
|
70
|
+
"@histoire/shared": "^0.16.4"
|
|
71
71
|
},
|
|
72
72
|
"peerDependencies": {
|
|
73
73
|
"vite": "^2.9.0 || ^3.0.0 || ^4.0.0"
|
|
@@ -79,9 +79,10 @@
|
|
|
79
79
|
"@types/markdown-it": "^12.2.3",
|
|
80
80
|
"@types/micromatch": "^4.0.2",
|
|
81
81
|
"@types/node": "^17.0.32",
|
|
82
|
+
"esbuild": "^0.18.19",
|
|
82
83
|
"rollup": "^3.5.1",
|
|
83
84
|
"typescript": "^4.9.5",
|
|
84
|
-
"vite": "^4.
|
|
85
|
+
"vite": "^4.4.8"
|
|
85
86
|
},
|
|
86
87
|
"scripts": {
|
|
87
88
|
"build": "rimraf dist && tsc -d",
|
package/src/node/build.ts
CHANGED
|
@@ -206,9 +206,9 @@ export async function build (ctx: Context) {
|
|
|
206
206
|
|
|
207
207
|
const duration = performance.now() - startTime
|
|
208
208
|
if (emptyStoryCount) {
|
|
209
|
-
console.warn(pc.yellow(`⚠️ ${emptyStoryCount} empty story file`))
|
|
209
|
+
console.warn(pc.yellow(`⚠️ ${emptyStoryCount} empty story file${emptyStoryCount === 1 ? '' : 's'}`))
|
|
210
210
|
}
|
|
211
|
-
console.log(pc.green(`✅ Built ${storyCount}
|
|
211
|
+
console.log(pc.green(`✅ Built ${storyCount} stor${storyCount === 1 ? 'y' : 'ies'} (${variantCount} variant${variantCount === 1 ? '' : 's'}) in ${Math.round(duration / 1000 * 100) / 100}s`))
|
|
212
212
|
|
|
213
213
|
// Render
|
|
214
214
|
if (previewStoryCallbacks.length) {
|
|
@@ -136,7 +136,7 @@ export default {
|
|
|
136
136
|
}, ({ color}) => h('div', {
|
|
137
137
|
class: '__hst-shade',
|
|
138
138
|
style: {
|
|
139
|
-
backgroundColor: color,
|
|
139
|
+
backgroundColor: color.replace('<alpha-value>', 1),
|
|
140
140
|
},
|
|
141
141
|
})))),
|
|
142
142
|
onMountControls: (api) => mountApp(api, () => [
|
|
@@ -159,7 +159,7 @@ export default {
|
|
|
159
159
|
}, ({ color}) => h('div', {
|
|
160
160
|
class: '__hst-shade __hst-text',
|
|
161
161
|
style: {
|
|
162
|
-
color,
|
|
162
|
+
color: color.replace('<alpha-value>', 1),
|
|
163
163
|
},
|
|
164
164
|
}, 'Aa')))),
|
|
165
165
|
onMountControls: (api) => mountApp(api, () => [
|
|
@@ -182,7 +182,7 @@ export default {
|
|
|
182
182
|
}, ({ color}) => h('div', {
|
|
183
183
|
class: '__hst-shade __hst-border',
|
|
184
184
|
style: {
|
|
185
|
-
borderColor: color,
|
|
185
|
+
borderColor: color.replace('<alpha-value>', 1),
|
|
186
186
|
},
|
|
187
187
|
})))),
|
|
188
188
|
onMountControls: (api) => mountApp(api, () => [
|
|
@@ -45,7 +45,7 @@ export function useCollectStories (options: UseCollectStoriesOptions, ctx: Conte
|
|
|
45
45
|
const threadsCount = ctx.mode === 'dev'
|
|
46
46
|
? Math.max(Math.min(maxThreads, Math.floor(cpus().length / 2)), 1)
|
|
47
47
|
: Math.max(Math.min(maxThreads, cpus().length - 1), 1)
|
|
48
|
-
console.log(pc.blue(`Using ${threadsCount}
|
|
48
|
+
console.log(pc.blue(`Using ${threadsCount} thread${threadsCount === 1 ? '' : 's'} for story collection`))
|
|
49
49
|
|
|
50
50
|
const threadPool = new Tinypool({
|
|
51
51
|
filename: new URL('./worker.js', import.meta.url).href,
|
package/src/node/config.ts
CHANGED
|
@@ -184,14 +184,18 @@ export const mergeBuildConfig = createDefu((obj: any, key, value) => {
|
|
|
184
184
|
export const mergeConfig = createDefu((obj: any, key, value) => {
|
|
185
185
|
if (obj[key] && key === 'vite') {
|
|
186
186
|
const initialValue = obj[key]
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
187
|
+
|
|
188
|
+
// Convert to functions
|
|
189
|
+
const initialFn: (...args: any[]) => Promise<any> = typeof initialValue === 'function' ? initialValue : async () => initialValue
|
|
190
|
+
const valueFn: (...args: any[]) => Promise<any> = typeof value === 'function' ? value : async () => value
|
|
191
|
+
|
|
192
|
+
obj[key] = async (...args) => {
|
|
193
|
+
// `mergeViteConfig` doesn't accept functions so we need to call them
|
|
194
|
+
const initialResult = await initialFn(...args)
|
|
195
|
+
const valueResult = await valueFn(...args)
|
|
196
|
+
return mergeViteConfig(initialResult, valueResult)
|
|
194
197
|
}
|
|
198
|
+
|
|
195
199
|
return true
|
|
196
200
|
}
|
|
197
201
|
|
|
@@ -294,7 +298,7 @@ export async function processConfig (ctx: Context) {
|
|
|
294
298
|
|
|
295
299
|
const fileCheck = (file: string, resolvedFile: string, configPathForError: string) => {
|
|
296
300
|
if (!file.startsWith('http') && !file.startsWith('@') && !fs.existsSync(resolvedFile)) {
|
|
297
|
-
console.warn(pc.yellow(`Histoire config: ${configPathForError} file ${file} does not exist (resolved to ${resolvedFile}), check for typos in the
|
|
301
|
+
console.warn(pc.yellow(`Histoire config: ${configPathForError} file ${file} does not exist (resolved to ${resolvedFile}), check for typos in the path`))
|
|
298
302
|
}
|
|
299
303
|
}
|
|
300
304
|
|
package/src/node/tree.ts
CHANGED
|
@@ -13,10 +13,16 @@ export function createPath (config: HistoireConfig, file: ServerTreeFile) {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
if (config.tree.file === 'path') {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
path
|
|
19
|
-
|
|
16
|
+
const paths = file.path.split('/').slice(0, -1)
|
|
17
|
+
|
|
18
|
+
// check if tree file path is a plugin
|
|
19
|
+
const index = paths.findIndex(p => p.includes('.histoire'))
|
|
20
|
+
|
|
21
|
+
if (index !== -1) {
|
|
22
|
+
return ['plugins', file.title]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return [...paths, file.title]
|
|
20
26
|
}
|
|
21
27
|
|
|
22
28
|
return config.tree.file(file)
|