histoire 0.16.2 → 0.16.5

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.
@@ -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} stories (${variantCount} variants) in ${Math.round(duration / 1000 * 100) / 100}s`));
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);
@@ -228,8 +228,8 @@ export default {
228
228
  }, ({ token }) => h('div', {
229
229
  class: '__hst-truncate',
230
230
  style: {
231
- fontSize: token.value[0],
232
- ...token.value[1],
231
+ fontSize: Array.isArray(token.value) ? token.value[0] : token.value,
232
+ ...(Array.isArray(token.value) && typeof token.value[1] === "object" ? token.value[1] : { lineHeight: token.value[1] })
233
233
  },
234
234
  }, sampleText.value))),
235
235
  onMountControls: (api) => mountApp(api, () => [
@@ -10,5 +10,5 @@ declare const _default: import("@histoire/vendors/vue").DefineComponent<{
10
10
  type: _PropType<Story>;
11
11
  required: true;
12
12
  };
13
- }>>, {}>;
13
+ }>>, {}, {}>;
14
14
  export default _default;
@@ -34,5 +34,5 @@ declare const _default: import("@histoire/vendors/vue").DefineComponent<{
34
34
  onReady?: () => any;
35
35
  }, {
36
36
  slotName: string;
37
- }>;
37
+ }, {}>;
38
38
  export default _default;
@@ -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} threads for story collection`));
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)
@@ -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 paths`));
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
@@ -5,6 +5,11 @@ export function createPath(config, file) {
5
5
  }
6
6
  if (config.tree.file === 'path') {
7
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
+ }
8
13
  return [...paths, file.title];
9
14
  }
10
15
  return config.tree.file(file);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "histoire",
3
- "version": "0.16.2",
3
+ "version": "0.16.5",
4
4
  "description": "A fast story book powered by Vite",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -44,49 +44,49 @@
44
44
  "change-case": "^4.1.2",
45
45
  "chokidar": "^3.5.3",
46
46
  "connect": "^3.7.0",
47
- "defu": "^6.0.0",
47
+ "defu": "^6.1.2",
48
48
  "diacritics": "^1.3.0",
49
49
  "flexsearch": "0.7.21",
50
- "fs-extra": "^10.0.1",
51
- "globby": "^13.1.1",
50
+ "fs-extra": "^10.1.0",
51
+ "globby": "^13.2.2",
52
52
  "gray-matter": "^4.0.3",
53
- "jiti": "^1.18.2",
53
+ "jiti": "^1.19.1",
54
54
  "jsdom": "^20.0.3",
55
55
  "markdown-it": "^12.3.2",
56
- "markdown-it-anchor": "^8.6.2",
57
- "markdown-it-attrs": "^4.1.3",
58
- "markdown-it-emoji": "^2.0.0",
56
+ "markdown-it-anchor": "^8.6.7",
57
+ "markdown-it-attrs": "^4.1.6",
58
+ "markdown-it-emoji": "^2.0.2",
59
59
  "micromatch": "^4.0.5",
60
- "mrmime": "^1.0.0",
60
+ "mrmime": "^1.0.1",
61
61
  "pathe": "^0.2.0",
62
62
  "picocolors": "^1.0.0",
63
63
  "sade": "^1.8.1",
64
64
  "shiki-es": "^0.2.0",
65
- "sirv": "^2.0.2",
65
+ "sirv": "^2.0.3",
66
66
  "vite-node": "0.28.4",
67
- "@histoire/app": "^0.16.1",
68
- "@histoire/shared": "^0.16.1",
69
- "@histoire/vendors": "^0.16.0",
70
- "@histoire/controls": "^0.16.1"
67
+ "@histoire/app": "^0.16.5",
68
+ "@histoire/controls": "^0.16.5",
69
+ "@histoire/shared": "^0.16.5",
70
+ "@histoire/vendors": "^0.16.5"
71
71
  },
72
72
  "peerDependencies": {
73
73
  "vite": "^2.9.0 || ^3.0.0 || ^4.0.0"
74
74
  },
75
75
  "devDependencies": {
76
- "@peeky/server": "^0.14.0",
77
- "@peeky/test": "^0.14.1",
78
76
  "@types/fs-extra": "^9.0.13",
79
77
  "@types/markdown-it": "^12.2.3",
80
78
  "@types/micromatch": "^4.0.2",
81
- "@types/node": "^17.0.32",
82
- "rollup": "^3.5.1",
79
+ "@types/node": "^17.0.45",
80
+ "esbuild": "^0.18.20",
81
+ "rollup": "^3.28.0",
83
82
  "typescript": "^4.9.5",
84
- "vite": "^4.2.0"
83
+ "vite": "^4.4.9",
84
+ "vitest": "^0.34.1"
85
85
  },
86
86
  "scripts": {
87
87
  "build": "rimraf dist && tsc -d",
88
88
  "watch": "tsc -d -w --sourceMap",
89
- "test:open": "peeky open",
90
- "test": "peeky run"
89
+ "test": "vitest run",
90
+ "test:dev": "vitest"
91
91
  }
92
92
  }
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} stories (${variantCount} variants) in ${Math.round(duration / 1000 * 100) / 100}s`))
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) {
@@ -239,8 +239,8 @@ export default {
239
239
  }, ({ token }) => h('div', {
240
240
  class: '__hst-truncate',
241
241
  style: {
242
- fontSize: token.value[0],
243
- ...token.value[1],
242
+ fontSize: Array.isArray(token.value) ? token.value[0] : token.value,
243
+ ...(Array.isArray(token.value) && typeof token.value[1] === "object" ? token.value[1] : { lineHeight: token.value[1] })
244
244
  },
245
245
  }, sampleText.value))),
246
246
  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} threads for story collection`))
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,
@@ -298,7 +298,7 @@ export async function processConfig (ctx: Context) {
298
298
 
299
299
  const fileCheck = (file: string, resolvedFile: string, configPathForError: string) => {
300
300
  if (!file.startsWith('http') && !file.startsWith('@') && !fs.existsSync(resolvedFile)) {
301
- console.warn(pc.yellow(`Histoire config: ${configPathForError} file ${file} does not exist (resolved to ${resolvedFile}), check for typos in the paths`))
301
+ console.warn(pc.yellow(`Histoire config: ${configPathForError} file ${file} does not exist (resolved to ${resolvedFile}), check for typos in the path`))
302
302
  }
303
303
  }
304
304
 
@@ -1,4 +1,4 @@
1
- import { describe, test, expect } from '@peeky/test'
1
+ import { describe, test, expect } from 'vitest'
2
2
  import { makeTree } from './tree'
3
3
  import { getDefaultConfig } from './config'
4
4
  import type { StoryFile } from './types'
package/src/node/tree.ts CHANGED
@@ -14,6 +14,14 @@ export function createPath (config: HistoireConfig, file: ServerTreeFile) {
14
14
 
15
15
  if (config.tree.file === 'path') {
16
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
+
17
25
  return [...paths, file.title]
18
26
  }
19
27
 
package/tsconfig.json CHANGED
@@ -12,8 +12,7 @@
12
12
  "resolveJsonModule": true,
13
13
  "skipLibCheck": true,
14
14
  "types": [
15
- "node",
16
- "@peeky/test"
15
+ "node"
17
16
  ],
18
17
  "lib": [
19
18
  "ESNext",