histoire 1.0.0-alpha.2 → 1.0.0-alpha.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/bin.js CHANGED
@@ -13,6 +13,7 @@ program.command('dev')
13
13
  .option('-p, --port <port>', 'Listening port of the server')
14
14
  .option('-c, --config <file>', `[string] use specified config file`)
15
15
  .option('--open', 'Open in your default browser')
16
+ .option('--host <host>', '[string] specify hostname')
16
17
  .action(async (options) => {
17
18
  const { devCommand } = await import('./commands/dev.js');
18
19
  return devCommand(options);
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/node/build.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AA+B3C,wBAAsB,KAAK,CAAC,GAAG,EAAE,OAAO,iBA6MvC"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/node/build.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AA+B3C,wBAAsB,KAAK,CAAC,GAAG,EAAE,OAAO,iBA8MvC"}
@@ -106,6 +106,7 @@ export async function build(ctx) {
106
106
  },
107
107
  });
108
108
  };
109
+ // @ts-expect-error vue plugin use function form
109
110
  vuePlugin.configureServer(server);
110
111
  }
111
112
  },
@@ -72,9 +72,9 @@ export function tailwindTokens(options = {}) {
72
72
  };
73
73
  }
74
74
  function storyTemplate(tailwindConfig) {
75
- return `import 'histoire-style'
76
- import './style.css'
77
- import { createApp, h, markRaw, ref } from ${getInjectedImport('@histoire/vendors/vue')}
75
+ // import 'histoire-style'
76
+ // import './style.css'
77
+ return `import { createApp, h, markRaw, ref } from ${getInjectedImport('@histoire/vendors/vue')}
78
78
  import {
79
79
  HstColorShades,
80
80
  HstTokenList,
@@ -1,6 +1,7 @@
1
1
  export interface DevOptions {
2
2
  port: number;
3
3
  open?: boolean;
4
+ host?: string | boolean;
4
5
  config?: string;
5
6
  }
6
7
  export declare function devCommand(options: DevOptions): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/node/commands/dev.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,UAAU,iBAmDnD"}
1
+ {"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../../../src/node/commands/dev.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACvB,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,UAAU,iBAoDnD"}
@@ -13,6 +13,7 @@ export async function devCommand(options) {
13
13
  const { server, viteConfigFile, close } = await createServer(ctx, {
14
14
  port: options.port,
15
15
  open: options.open,
16
+ host: options.host,
16
17
  });
17
18
  server.printUrls();
18
19
  // Histoire config watcher
@@ -1 +1 @@
1
- {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/node/dom/env.ts"],"names":[],"mappings":"AAMA,wBAAgB,YAAY;;;EAgC3B"}
1
+ {"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../../src/node/dom/env.ts"],"names":[],"mappings":"AAMA,wBAAgB,YAAY;;;EA0C3B"}
@@ -21,6 +21,15 @@ export function createDomEnv() {
21
21
  observe(_target, _options) { }
22
22
  unobserve(_target) { }
23
23
  };
24
+ window.IntersectionObserver = window.IntersectionObserver || class IntersectionObserver {
25
+ root;
26
+ rootMargin;
27
+ thresholds;
28
+ disconnect() { }
29
+ observe = (_target) => void { /* noop */};
30
+ unobserve(_target) { }
31
+ takeRecords() { return []; }
32
+ };
24
33
  return {
25
34
  window,
26
35
  destroy,
@@ -2,6 +2,7 @@ import type { Context } from './context.js';
2
2
  export interface CreateServerOptions {
3
3
  port?: number;
4
4
  open?: boolean;
5
+ host?: string | boolean;
5
6
  }
6
7
  export declare function createServer(ctx: Context, options?: CreateServerOptions): Promise<{
7
8
  server: import("vite").ViteDevServer;
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/node/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAa3C,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,wBAAsB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,GAAE,mBAAwB;;;;GAgNjF"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/node/server.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAa3C,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CACxB;AAED,wBAAsB,YAAY,CAAC,GAAG,EAAE,OAAO,EAAE,OAAO,GAAE,mBAAwB;;;;GAsNjF"}
@@ -12,11 +12,16 @@ import { getViteConfigWithPlugins } from './vite.js';
12
12
  export async function createServer(ctx, options = {}) {
13
13
  const getViteServer = async (collecting) => {
14
14
  const { viteConfig, viteConfigFile } = await getViteConfigWithPlugins(collecting, ctx);
15
- if (!collecting && options.open) {
16
- viteConfig.server.open = true;
15
+ if (!collecting) {
16
+ if (options.open) {
17
+ viteConfig.server.open = true;
18
+ }
19
+ if (options.host) {
20
+ viteConfig.server.host = options.host;
21
+ }
17
22
  }
18
23
  const server = await createViteServer(mergeViteConfig(viteConfig, {
19
- optimizeDeps: { include: [], noDiscovery: true },
24
+ optimizeDeps: { include: viteConfig.optimizeDeps?.include ?? [], noDiscovery: true },
20
25
  }));
21
26
  await server.pluginContainer.buildStart({});
22
27
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../src/node/vite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAGb,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAe3C,wBAAsB,uBAAuB,CAAC,UAAU,EAAE,YAAY,EAAE,GAAG,EAAE,OAAO,yBAmCnF;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,YAAY,CAAA;IACxB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B;AAED,wBAAsB,wBAAwB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAmS9G"}
1
+ {"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../../src/node/vite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EAGb,MAAM,MAAM,CAAA;AACb,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAe3C,wBAAsB,uBAAuB,CAAC,UAAU,EAAE,YAAY,EAAE,GAAG,EAAE,OAAO,yBAmCnF;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,YAAY,CAAA;IACxB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;CAC9B;AAED,wBAAsB,wBAAwB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAyS9G"}
package/dist/node/vite.js CHANGED
@@ -304,6 +304,11 @@ export async function getViteConfigWithPlugins(isServer, ctx) {
304
304
  },
305
305
  });
306
306
  }
307
+ for (const plugin of ctx.config.plugins) {
308
+ if (plugin.vitePlugins) {
309
+ await plugin.vitePlugins(plugins);
310
+ }
311
+ }
307
312
  const viteConfig = mergeViteConfig(inlineConfig, {
308
313
  configFile: false,
309
314
  plugins,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "histoire",
3
3
  "type": "module",
4
- "version": "1.0.0-alpha.2",
4
+ "version": "1.0.0-alpha.4",
5
5
  "description": "A fast story book powered by Vite",
6
6
  "author": {
7
7
  "name": "Guillaume Chau"
@@ -37,7 +37,7 @@
37
37
  "histoire": "./bin.mjs"
38
38
  },
39
39
  "peerDependencies": {
40
- "vite": "^6.0.1"
40
+ "vite": "^7.0.0"
41
41
  },
42
42
  "dependencies": {
43
43
  "@akryum/tinypool": "^0.3.1",
@@ -64,11 +64,11 @@
64
64
  "sade": "^1.8.1",
65
65
  "shiki": "^3.0.0",
66
66
  "sirv": "^3.0.0",
67
- "vite-node": "0.34.7",
68
- "@histoire/app": "^1.0.0-alpha.2",
69
- "@histoire/shared": "^1.0.0-alpha.2",
70
- "@histoire/vendors": "^1.0.0-alpha.2",
71
- "@histoire/controls": "^1.0.0-alpha.2"
67
+ "vite-node": "3.2.4",
68
+ "@histoire/app": "^1.0.0-alpha.4",
69
+ "@histoire/controls": "^1.0.0-alpha.4",
70
+ "@histoire/vendors": "^1.0.0-alpha.4",
71
+ "@histoire/shared": "^1.0.0-alpha.4"
72
72
  },
73
73
  "devDependencies": {
74
74
  "@types/fs-extra": "^11.0.4",
@@ -76,7 +76,7 @@
76
76
  "esbuild": "^0.24.0",
77
77
  "rollup": "^4.28.0",
78
78
  "typescript": "5.6.3",
79
- "vite": "^6.0.5",
79
+ "vite": "^7.0.0",
80
80
  "vitest": "0.34.6"
81
81
  },
82
82
  "scripts": {
package/src/node/bin.ts CHANGED
@@ -18,6 +18,7 @@ program.command('dev')
18
18
  .option('-p, --port <port>', 'Listening port of the server')
19
19
  .option('-c, --config <file>', `[string] use specified config file`)
20
20
  .option('--open', 'Open in your default browser')
21
+ .option('--host <host>', '[string] specify hostname')
21
22
  .action(async (options) => {
22
23
  const { devCommand } = await import('./commands/dev.js')
23
24
  return devCommand(options)
package/src/node/build.ts CHANGED
@@ -133,6 +133,7 @@ export async function build(ctx: Context) {
133
133
  },
134
134
  })
135
135
  }
136
+ // @ts-expect-error vue plugin use function form
136
137
  vuePlugin.configureServer(server)
137
138
  }
138
139
  },
@@ -84,9 +84,9 @@ export function tailwindTokens(options: TailwindTokensOptions = {}): Plugin {
84
84
  }
85
85
 
86
86
  function storyTemplate(tailwindConfig: any) {
87
- return `import 'histoire-style'
88
- import './style.css'
89
- import { createApp, h, markRaw, ref } from ${getInjectedImport('@histoire/vendors/vue')}
87
+ // import 'histoire-style'
88
+ // import './style.css'
89
+ return `import { createApp, h, markRaw, ref } from ${getInjectedImport('@histoire/vendors/vue')}
90
90
  import {
91
91
  HstColorShades,
92
92
  HstTokenList,
@@ -8,6 +8,7 @@ import { createServer } from '../server.js'
8
8
  export interface DevOptions {
9
9
  port: number
10
10
  open?: boolean
11
+ host?: string | boolean
11
12
  config?: string
12
13
  }
13
14
 
@@ -22,6 +23,7 @@ export async function devCommand(options: DevOptions) {
22
23
  const { server, viteConfigFile, close } = await createServer(ctx, {
23
24
  port: options.port,
24
25
  open: options.open,
26
+ host: options.host,
25
27
  })
26
28
  server.printUrls()
27
29
 
@@ -32,6 +32,16 @@ export function createDomEnv() {
32
32
  unobserve(_target: Element): void { /* noop */ }
33
33
  }
34
34
 
35
+ window.IntersectionObserver = window.IntersectionObserver || class IntersectionObserver {
36
+ root: Element
37
+ rootMargin: string
38
+ thresholds: number[]
39
+ disconnect(): void { /* noop */ }
40
+ observe = (_target: Element) => void { /* noop */ }
41
+ unobserve(_target: Element): void { /* noop */ }
42
+ takeRecords(): IntersectionObserverEntry[] { return [] }
43
+ }
44
+
35
45
  return {
36
46
  window,
37
47
  destroy,
@@ -15,19 +15,26 @@ import { getViteConfigWithPlugins } from './vite.js'
15
15
  export interface CreateServerOptions {
16
16
  port?: number
17
17
  open?: boolean
18
+ host?: string | boolean
18
19
  }
19
20
 
20
21
  export async function createServer(ctx: Context, options: CreateServerOptions = {}) {
21
22
  const getViteServer = async (collecting: boolean) => {
22
23
  const { viteConfig, viteConfigFile } = await getViteConfigWithPlugins(collecting, ctx)
23
24
 
24
- if (!collecting && options.open) {
25
- viteConfig.server.open = true
25
+ if (!collecting) {
26
+ if (options.open) {
27
+ viteConfig.server.open = true
28
+ }
29
+
30
+ if (options.host) {
31
+ viteConfig.server.host = options.host
32
+ }
26
33
  }
27
34
 
28
35
  const server = await createViteServer(
29
36
  mergeViteConfig(viteConfig, {
30
- optimizeDeps: { include: [], noDiscovery: true },
37
+ optimizeDeps: { include: viteConfig.optimizeDeps?.include ?? [], noDiscovery: true },
31
38
  }),
32
39
  )
33
40
  await server.pluginContainer.buildStart({})
package/src/node/vite.ts CHANGED
@@ -154,7 +154,7 @@ export async function getViteConfigWithPlugins(isServer: boolean, ctx: Context):
154
154
  },
155
155
 
156
156
  options() {
157
- this.meta.histoire = {
157
+ (this.meta as any).histoire = {
158
158
  isCollecting: isServer,
159
159
  }
160
160
  },
@@ -342,6 +342,12 @@ export async function getViteConfigWithPlugins(isServer: boolean, ctx: Context):
342
342
  })
343
343
  }
344
344
 
345
+ for (const plugin of ctx.config.plugins) {
346
+ if (plugin.vitePlugins) {
347
+ await plugin.vitePlugins(plugins)
348
+ }
349
+ }
350
+
345
351
  const viteConfig = mergeViteConfig(inlineConfig, {
346
352
  configFile: false,
347
353
  plugins,