@vivliostyle/cli 9.9.0 → 10.0.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.
Files changed (55) hide show
  1. package/README.md +74 -30
  2. package/dist/{chunk-QWX5MAON.js → chunk-2M2KXPDN.js} +16 -17
  3. package/dist/chunk-2M2KXPDN.js.map +1 -0
  4. package/dist/{chunk-OZ4XTSAH.js → chunk-5DB6XVJN.js} +2 -2
  5. package/dist/chunk-5DB6XVJN.js.map +1 -0
  6. package/dist/{chunk-3O3N2V7D.js → chunk-5K3NGLBV.js} +6 -7
  7. package/dist/chunk-5K3NGLBV.js.map +1 -0
  8. package/dist/{chunk-UYKCTF6F.js → chunk-IIKRNYAM.js} +445 -228
  9. package/dist/chunk-IIKRNYAM.js.map +1 -0
  10. package/dist/{chunk-G3GROLBN.js → chunk-MQYXBSRJ.js} +397 -88
  11. package/dist/chunk-MQYXBSRJ.js.map +1 -0
  12. package/dist/chunk-RPMMYPTR.js +1076 -0
  13. package/dist/chunk-RPMMYPTR.js.map +1 -0
  14. package/dist/{chunk-WELNNHOB.js → chunk-YN3JNBNT.js} +415 -384
  15. package/dist/chunk-YN3JNBNT.js.map +1 -0
  16. package/dist/{chunk-6UU7DEUR.js → chunk-YVNDJXMI.js} +32 -33
  17. package/dist/chunk-YVNDJXMI.js.map +1 -0
  18. package/dist/{chunk-FXUEYQRY.js → chunk-ZIK6DINS.js} +3 -3
  19. package/dist/chunk-ZIK6DINS.js.map +1 -0
  20. package/dist/chunk-ZKEIYNLT.js +331 -0
  21. package/dist/chunk-ZKEIYNLT.js.map +1 -0
  22. package/dist/cli.js +7 -8
  23. package/dist/cli.js.map +1 -1
  24. package/dist/commands/build.js +29 -17
  25. package/dist/commands/build.js.map +1 -1
  26. package/dist/commands/create.d.ts +2 -0
  27. package/dist/commands/create.js +64 -0
  28. package/dist/commands/create.js.map +1 -0
  29. package/dist/commands/init.js +23 -14
  30. package/dist/commands/init.js.map +1 -1
  31. package/dist/commands/preview.js +26 -20
  32. package/dist/commands/preview.js.map +1 -1
  33. package/dist/config/schema.d.ts +7815 -4012
  34. package/dist/config/schema.js +16 -4
  35. package/dist/index.d.ts +46 -7
  36. package/dist/index.js +24 -16
  37. package/dist/index.js.map +1 -1
  38. package/dist/node-modules.d.ts +5 -5
  39. package/dist/node-modules.js +1 -1
  40. package/dist/vite-adapter.d.ts +1 -0
  41. package/dist/vite-adapter.js +6 -6
  42. package/package.json +37 -26
  43. package/dist/chunk-3O3N2V7D.js.map +0 -1
  44. package/dist/chunk-4IIM6RSG.js +0 -71
  45. package/dist/chunk-4IIM6RSG.js.map +0 -1
  46. package/dist/chunk-6KEOMYDZ.js +0 -89
  47. package/dist/chunk-6KEOMYDZ.js.map +0 -1
  48. package/dist/chunk-6UU7DEUR.js.map +0 -1
  49. package/dist/chunk-FXUEYQRY.js.map +0 -1
  50. package/dist/chunk-G3GROLBN.js.map +0 -1
  51. package/dist/chunk-OZ4XTSAH.js.map +0 -1
  52. package/dist/chunk-QWX5MAON.js.map +0 -1
  53. package/dist/chunk-UYKCTF6F.js.map +0 -1
  54. package/dist/chunk-WELNNHOB.js.map +0 -1
  55. package/types/playwright.d.ts +0 -49
package/README.md CHANGED
@@ -5,7 +5,11 @@
5
5
 
6
6
  [npm-url]: https://npmjs.org/package/@vivliostyle/cli
7
7
 
8
- Supercharge your command-line publication workflow.
8
+ <div align="center">
9
+ <b>Supercharge your command-line publication workflow.</b>
10
+ </div>
11
+
12
+ # Vivliostyle CLI
9
13
 
10
14
  ## Install
11
15
 
@@ -13,6 +17,10 @@ Supercharge your command-line publication workflow.
13
17
  npm install -g @vivliostyle/cli
14
18
  ```
15
19
 
20
+ ## User Guide
21
+
22
+ See [User Guide](https://github.com/vivliostyle/vivliostyle-cli/tree/HEAD/docs#readme)
23
+
16
24
  ## Use
17
25
 
18
26
  ```
@@ -23,49 +31,84 @@ Options:
23
31
  -h, --help display help for command
24
32
 
25
33
  Commands:
26
- init create vivliostyle config
27
- build build and create PDF file
28
- preview launch preview server
34
+ create Scaffold a new Vivliostyle project
35
+ init Create a Vivliostyle configuration file
36
+ build Create PDF, EPUB, and other publication files
37
+ preview Open the preview page and interactively save PDFs
29
38
  help [command] display help for command
30
39
  ```
31
40
 
32
- ### `init`
41
+ ### `create`
42
+
43
+ > Scaffold a new Vivliostyle project
33
44
 
34
- > create vivliostyle config file.
45
+ You are new to Vivliostyle? Check out our [Create Book](https://github.com/vivliostyle/vivliostyle-cli/tree/HEAD/packages/create-book#readme) project.
46
+ With Create Book, you can easily bootstrap your book project and start writing without any extra effort.
47
+
48
+ <details>
49
+ <summary><b>Full CLI options</b></summary>
35
50
 
36
- ```bash
37
- vivliostyle init
38
51
  ```
52
+ Usage: vivliostyle create [options] [projectPath]
39
53
 
40
- You are new to Vivliostyle? Check out our latest project [Create Book](https://github.com/vivliostyle/create-book#readme).
41
- With Create Book, you can easily bootstrap your book project and start writing without any extra effort.
54
+ scaffold a new Vivliostyle project
55
+
56
+ Options:
57
+ --title <title> title
58
+ --author <author> author
59
+ -l, --language <language> language
60
+ -s, --size <size> paper size
61
+ -T, --theme <theme> theme
62
+ --template <template> Template source in the format of `[provider]:repo[/subpath][#ref]` or as a local directory to copy from.
63
+ --create-config-file-only Create a Vivliostyle config file without generating project template files.
64
+ --proxy-server <proxyServer> HTTP/SOCK proxy server url
65
+ --proxy-bypass <proxyBypass> optional comma-separated domains to bypass proxy
66
+ --proxy-user <proxyUser> optional username for HTTP proxy authentication
67
+ --proxy-pass <proxyPass> optional password for HTTP proxy authentication
68
+ --log-level <level> specify a log level of console outputs (choices: "silent", "info", "verbose", "debug", default: "info")
69
+ -v, --version output the version number
70
+ -h, --help display help for command
71
+ ```
72
+
73
+ </details>
42
74
 
43
- #### CLI Options
75
+ ### `init`
76
+
77
+ > Create a Vivliostyle configuration file
78
+
79
+ <details>
80
+ <summary><b>Full CLI options</b></summary>
44
81
 
45
82
  ```
83
+ Usage: vivliostyle init [options]
84
+
85
+ create vivliostyle config file
86
+
46
87
  Options:
47
88
  --title <title> title
48
89
  --author <author> author
49
90
  -l, --language <language> language
50
- -s, --size <size> paper size
91
+ -s, --size <size> paper size
51
92
  -T, --theme <theme> theme
52
93
  --log-level <level> specify a log level of console outputs (choices: "silent", "info", "verbose", "debug", default: "info")
94
+ -v, --version output the version number
53
95
  -h, --help display help for command
54
96
  ```
55
97
 
98
+ </details>
99
+
56
100
  ### `build`
57
101
 
58
- > build and create PDF file.
102
+ > Create PDF, EPUB, and other publication files
59
103
 
60
- Put [vivliostyle.config.js](https://github.com/vivliostyle/create-book/blob/master/templates/default/vivliostyle.config.js) in the root directory, then:
104
+ <details>
105
+ <summary><b>Full CLI options</b></summary>
61
106
 
62
- ```bash
63
- vivliostyle build
64
107
  ```
108
+ Usage: vivliostyle build [options] [input]
65
109
 
66
- #### CLI options
110
+ build and create PDF file
67
111
 
68
- ```
69
112
  Options:
70
113
  -c, --config <config_file> path to vivliostyle.config.js [vivliostyle.config.js]
71
114
  -o, --output <path> specify output file name or directory [<title>.pdf]
@@ -101,6 +144,7 @@ Options:
101
144
  --viewer <URL> specify a URL of displaying viewer instead of vivliostyle-cli's one
102
145
  It is useful that using own viewer that has staging features. (ex: https://vivliostyle.vercel.app/)
103
146
  --viewer-param <parameters> specify viewer parameters. (ex: "allowScripts=false&pixelRatio=16")
147
+ --browser <browser> Specify a browser type and version to launch the Vivliostyle viewer (ex: chrome@129, firefox) [chrome]
104
148
  --proxy-server <proxyServer> HTTP/SOCK proxy server url for underlying Playwright
105
149
  --proxy-bypass <proxyBypass> optional comma-separated domains to bypass proxy
106
150
  --proxy-user <proxyUser> optional username for HTTP proxy authentication
@@ -112,20 +156,24 @@ Options:
112
156
  --no-enable-static-serve disable static file serving
113
157
  --vite-config-file <path> Vite config file path
114
158
  --no-vite-config-file ignore Vite config file even if it exists
159
+ -v, --version output the version number
115
160
  -h, --help display help for command
116
161
  ```
117
162
 
163
+ </details>
164
+
118
165
  ### `preview`
119
166
 
120
- > open preview page and save PDF interactively.
167
+ > Open the preview page and interactively save PDFs
168
+
169
+ <details>
170
+ <summary><b>Full CLI options</b></summary>
121
171
 
122
- ```bash
123
- vivliostyle preview
124
172
  ```
173
+ Usage: vivliostyle preview [options] [input]
125
174
 
126
- #### CLI options
175
+ launch preview server
127
176
 
128
- ```
129
177
  Options:
130
178
  -c, --config <config_file> path to vivliostyle.config.js
131
179
  -T, --theme <theme...> theme path or package name
@@ -148,8 +196,7 @@ Options:
148
196
  --viewer <URL> specify a URL of displaying viewer instead of vivliostyle-cli's one
149
197
  It is useful that using own viewer that has staging features. (ex: https://vivliostyle.vercel.app/)
150
198
  --viewer-param <parameters> specify viewer parameters. (ex: "allowScripts=false&pixelRatio=16")
151
- --browser <browser> EXPERIMENTAL SUPPORT: Specify a browser type to launch Vivliostyle viewer [chromium]
152
- Currently, Firefox and Webkit support preview command only! (choices: "chromium", "firefox", "webkit")
199
+ --browser <browser> Specify a browser type and version to launch the Vivliostyle viewer (ex: chrome@129, firefox) [chrome]
153
200
  --proxy-server <proxyServer> HTTP/SOCK proxy server url for underlying Playwright
154
201
  --proxy-bypass <proxyBypass> optional comma-separated domains to bypass proxy
155
202
  --proxy-user <proxyUser> optional username for HTTP proxy authentication
@@ -163,19 +210,16 @@ Options:
163
210
  --no-enable-viewer-start-page disable viewer start page
164
211
  --vite-config-file <path> Vite config file path
165
212
  --no-vite-config-file ignore Vite config file even if it exists
213
+ -v, --version output the version number
166
214
  -h, --help display help for command
167
215
  ```
168
216
 
169
- ## User Guide
170
-
171
- See [User Guide](https://docs.vivliostyle.org/#/vivliostyle-cli)
217
+ </details>
172
218
 
173
219
  ## Contribute
174
220
 
175
221
  See [Contribution Guide](CONTRIBUTING.md).
176
222
 
177
- [![](https://sourcerer.io/fame/uetchy/vivliostyle/vivliostyle-cli/images/0)](https://sourcerer.io/fame/uetchy/vivliostyle/vivliostyle-cli/links/0)[![](https://sourcerer.io/fame/uetchy/vivliostyle/vivliostyle-cli/images/1)](https://sourcerer.io/fame/uetchy/vivliostyle/vivliostyle-cli/links/1)[![](https://sourcerer.io/fame/uetchy/vivliostyle/vivliostyle-cli/images/2)](https://sourcerer.io/fame/uetchy/vivliostyle/vivliostyle-cli/links/2)[![](https://sourcerer.io/fame/uetchy/vivliostyle/vivliostyle-cli/images/3)](https://sourcerer.io/fame/uetchy/vivliostyle/vivliostyle-cli/links/3)[![](https://sourcerer.io/fame/uetchy/vivliostyle/vivliostyle-cli/images/4)](https://sourcerer.io/fame/uetchy/vivliostyle/vivliostyle-cli/links/4)[![](https://sourcerer.io/fame/uetchy/vivliostyle/vivliostyle-cli/images/5)](https://sourcerer.io/fame/uetchy/vivliostyle/vivliostyle-cli/links/5)[![](https://sourcerer.io/fame/uetchy/vivliostyle/vivliostyle-cli/images/6)](https://sourcerer.io/fame/uetchy/vivliostyle/vivliostyle-cli/links/6)[![](https://sourcerer.io/fame/uetchy/vivliostyle/vivliostyle-cli/images/7)](https://sourcerer.io/fame/uetchy/vivliostyle/vivliostyle-cli/links/7)
178
-
179
223
  ## License
180
224
 
181
225
  Licensed under [AGPL Version 3](http://www.gnu.org/licenses/agpl.html).
@@ -7,33 +7,32 @@ import {
7
7
  vsStaticServePlugin,
8
8
  vsViewerPlugin,
9
9
  warnDeprecatedConfig
10
- } from "./chunk-WELNNHOB.js";
10
+ } from "./chunk-YN3JNBNT.js";
11
11
  import {
12
12
  Logger,
13
13
  setupConfigFromFlags
14
- } from "./chunk-G3GROLBN.js";
14
+ } from "./chunk-MQYXBSRJ.js";
15
15
  import {
16
16
  VivliostyleInlineConfig
17
- } from "./chunk-UYKCTF6F.js";
17
+ } from "./chunk-IIKRNYAM.js";
18
18
 
19
19
  // src/vite-adapter.ts
20
20
  import * as v from "valibot";
21
21
  import * as vite from "vite";
22
22
  async function createVitePlugin(inlineConfig = {}) {
23
23
  const parsedInlineConfig = v.parse(VivliostyleInlineConfig, inlineConfig);
24
- Logger.setLogLevel(parsedInlineConfig.logLevel);
25
- if (parsedInlineConfig.logger) {
26
- Logger.setCustomLogger(parsedInlineConfig.logger);
27
- } else {
28
- const { info, warn, error } = vite.createLogger("info", {
29
- prefix: "[vivliostyle]"
30
- });
31
- Logger.setCustomLogger({
32
- info: (msg) => info(msg, { timestamp: true }),
33
- warn: (msg) => warn(msg, { timestamp: true }),
34
- error: (msg) => error(msg, { timestamp: true })
35
- });
36
- }
24
+ let viteLogger;
25
+ Logger.setLogOptions({
26
+ ...parsedInlineConfig,
27
+ logger: parsedInlineConfig.logger ?? {
28
+ info: (msg) => viteLogger?.info(msg, { timestamp: true }),
29
+ warn: (msg) => viteLogger?.warn(msg, { timestamp: true }),
30
+ error: (msg) => viteLogger?.error(msg, { timestamp: true })
31
+ }
32
+ });
33
+ viteLogger = vite.createLogger("info", {
34
+ prefix: "[vivliostyle]"
35
+ });
37
36
  Logger.debug("inlineConfig %O", parsedInlineConfig);
38
37
  const vivliostyleConfig = await loadVivliostyleConfig(parsedInlineConfig) ?? setupConfigFromFlags(parsedInlineConfig);
39
38
  warnDeprecatedConfig(vivliostyleConfig);
@@ -54,4 +53,4 @@ async function createVitePlugin(inlineConfig = {}) {
54
53
  export {
55
54
  createVitePlugin
56
55
  };
57
- //# sourceMappingURL=chunk-QWX5MAON.js.map
56
+ //# sourceMappingURL=chunk-2M2KXPDN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/vite-adapter.ts"],"sourcesContent":["import * as v from 'valibot';\nimport * as vite from 'vite';\nimport { setupConfigFromFlags } from './commands/cli-flags.js';\nimport { loadVivliostyleConfig, warnDeprecatedConfig } from './config/load.js';\nimport { mergeInlineConfig } from './config/merge.js';\nimport { resolveTaskConfig } from './config/resolve.js';\nimport { VivliostyleInlineConfig } from './config/schema.js';\nimport { Logger } from './logger.js';\nimport { vsBrowserPlugin } from './vite/vite-plugin-browser.js';\nimport { vsDevServerPlugin } from './vite/vite-plugin-dev-server.js';\nimport { vsStaticServePlugin } from './vite/vite-plugin-static-serve.js';\nimport { vsViewerPlugin } from './vite/vite-plugin-viewer.js';\n\nexport async function createVitePlugin(\n inlineConfig: VivliostyleInlineConfig = {},\n): Promise<vite.Plugin[]> {\n const parsedInlineConfig = v.parse(VivliostyleInlineConfig, inlineConfig);\n let viteLogger: ReturnType<typeof vite.createLogger>;\n Logger.setLogOptions({\n ...parsedInlineConfig,\n logger: parsedInlineConfig.logger ?? {\n info: (msg) => viteLogger?.info(msg, { timestamp: true }),\n warn: (msg) => viteLogger?.warn(msg, { timestamp: true }),\n error: (msg) => viteLogger?.error(msg, { timestamp: true }),\n },\n });\n viteLogger = vite.createLogger('info', {\n prefix: '[vivliostyle]',\n });\n Logger.debug('inlineConfig %O', parsedInlineConfig);\n const vivliostyleConfig =\n (await loadVivliostyleConfig(parsedInlineConfig)) ??\n setupConfigFromFlags(parsedInlineConfig);\n warnDeprecatedConfig(vivliostyleConfig);\n const { tasks, inlineOptions } = mergeInlineConfig(\n vivliostyleConfig,\n parsedInlineConfig,\n );\n const config = resolveTaskConfig(tasks[0], inlineOptions);\n Logger.debug('config %O', config);\n\n return [\n vsDevServerPlugin({ config, inlineConfig: parsedInlineConfig }),\n vsViewerPlugin({ config, inlineConfig: parsedInlineConfig }),\n vsBrowserPlugin({ config, inlineConfig: parsedInlineConfig }),\n vsStaticServePlugin({ config, inlineConfig: parsedInlineConfig }),\n ];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA,YAAY,OAAO;AACnB,YAAY,UAAU;AAYtB,eAAsB,iBACpB,eAAwC,CAAC,GACjB;AACxB,QAAM,qBAAuB,QAAM,yBAAyB,YAAY;AACxE,MAAI;AACJ,SAAO,cAAc;AAAA,IACnB,GAAG;AAAA,IACH,QAAQ,mBAAmB,UAAU;AAAA,MACnC,MAAM,CAAC,QAAQ,YAAY,KAAK,KAAK,EAAE,WAAW,KAAK,CAAC;AAAA,MACxD,MAAM,CAAC,QAAQ,YAAY,KAAK,KAAK,EAAE,WAAW,KAAK,CAAC;AAAA,MACxD,OAAO,CAAC,QAAQ,YAAY,MAAM,KAAK,EAAE,WAAW,KAAK,CAAC;AAAA,IAC5D;AAAA,EACF,CAAC;AACD,eAAkB,kBAAa,QAAQ;AAAA,IACrC,QAAQ;AAAA,EACV,CAAC;AACD,SAAO,MAAM,mBAAmB,kBAAkB;AAClD,QAAM,oBACH,MAAM,sBAAsB,kBAAkB,KAC/C,qBAAqB,kBAAkB;AACzC,uBAAqB,iBAAiB;AACtC,QAAM,EAAE,OAAO,cAAc,IAAI;AAAA,IAC/B;AAAA,IACA;AAAA,EACF;AACA,QAAM,SAAS,kBAAkB,MAAM,CAAC,GAAG,aAAa;AACxD,SAAO,MAAM,aAAa,MAAM;AAEhC,SAAO;AAAA,IACL,kBAAkB,EAAE,QAAQ,cAAc,mBAAmB,CAAC;AAAA,IAC9D,eAAe,EAAE,QAAQ,cAAc,mBAAmB,CAAC;AAAA,IAC3D,gBAAgB,EAAE,QAAQ,cAAc,mBAAmB,CAAC;AAAA,IAC5D,oBAAoB,EAAE,QAAQ,cAAc,mBAAmB,CAAC;AAAA,EAClE;AACF;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  Logger,
3
3
  useTmpDirectory
4
- } from "./chunk-G3GROLBN.js";
4
+ } from "./chunk-MQYXBSRJ.js";
5
5
 
6
6
  // src/config/vite.ts
7
7
  import upath from "upath";
@@ -74,4 +74,4 @@ async function resolveViteConfig({
74
74
  export {
75
75
  resolveViteConfig
76
76
  };
77
- //# sourceMappingURL=chunk-OZ4XTSAH.js.map
77
+ //# sourceMappingURL=chunk-5DB6XVJN.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/config/vite.ts"],"sourcesContent":["import upath from 'upath';\nimport {\n type ConfigEnv,\n createLogger,\n type InlineConfig,\n mergeConfig as mergeViteConfig,\n resolveConfig,\n type ResolvedConfig as ResolvedViteConfig,\n} from 'vite';\nimport { dim } from 'yoctocolors';\nimport { Logger } from '../logger.js';\nimport { useTmpDirectory } from '../util.js';\nimport type { ResolvedTaskConfig } from './resolve.js';\n\n// Be careful not to confuse the preview/build commands of Vivliostyle CLI with Vite's mode.\n// In Vivliostyle CLI, \"preview\" command starts the dev server in Vite,\n// and \"build\" command starts the preview server in Vite.\nconst defaultConfigEnv: Record<'preview' | 'build', ConfigEnv> = {\n preview: { command: 'serve', mode: 'development', isPreview: false },\n build: { command: 'serve', mode: 'production', isPreview: true },\n};\n\nexport async function resolveViteConfig({\n serverRootDir,\n server,\n viteConfig,\n viteConfigFile,\n logLevel,\n workspaceDir,\n mode,\n}: Pick<\n ResolvedTaskConfig,\n | 'serverRootDir'\n | 'server'\n | 'viteConfig'\n | 'viteConfigFile'\n | 'logLevel'\n | 'workspaceDir'\n> & {\n mode: 'preview' | 'build';\n}): Promise<ResolvedViteConfig> {\n const viteLogger = createLogger(\n (\n {\n silent: 'silent',\n info: 'info',\n verbose: 'info',\n debug: 'info',\n } as const\n )[logLevel],\n { allowClearScreen: false },\n );\n const warnedMessages = new Set<string>();\n viteLogger.info = (msg) => {\n Logger.logInfo(`${dim('[vite]')} ${msg}`);\n };\n viteLogger.warn = (msg) => {\n viteLogger.hasWarned = true;\n Logger.logWarn(`${dim('[vite]')} ${msg}`);\n };\n viteLogger.warnOnce = (msg) => {\n if (warnedMessages.has(msg)) {\n return;\n }\n viteLogger.hasWarned = true;\n Logger.logWarn(`${dim('[vite]')} ${msg}`);\n warnedMessages.add(msg);\n };\n viteLogger.error = (msg) => {\n viteLogger.hasWarned = true;\n Logger.logError(`${dim('[vite]')} ${msg}`);\n };\n\n const root =\n typeof serverRootDir === 'string'\n ? serverRootDir\n : (await useTmpDirectory())[0];\n\n const finalUserConfig = mergeViteConfig(viteConfig || {}, {\n server,\n preview: server,\n configFile: viteConfigFile === true ? undefined : viteConfigFile,\n root,\n customLogger: viteLogger,\n cacheDir: upath.join(workspaceDir, '.vite'),\n } satisfies InlineConfig);\n return await resolveConfig(\n finalUserConfig,\n defaultConfigEnv[mode].command,\n defaultConfigEnv[mode].mode,\n 'development',\n defaultConfigEnv[mode].isPreview,\n );\n}\n"],"mappings":";;;;;;AAAA,OAAO,WAAW;AAClB;AAAA,EAEE;AAAA,EAEA,eAAe;AAAA,EACf;AAAA,OAEK;AACP,SAAS,WAAW;AAQpB,IAAM,mBAA2D;AAAA,EAC/D,SAAS,EAAE,SAAS,SAAS,MAAM,eAAe,WAAW,MAAM;AAAA,EACnE,OAAO,EAAE,SAAS,SAAS,MAAM,cAAc,WAAW,KAAK;AACjE;AAEA,eAAsB,kBAAkB;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAUgC;AAC9B,QAAM,aAAa;AAAA,IAEf;AAAA,MACE,QAAQ;AAAA,MACR,MAAM;AAAA,MACN,SAAS;AAAA,MACT,OAAO;AAAA,IACT,EACA,QAAQ;AAAA,IACV,EAAE,kBAAkB,MAAM;AAAA,EAC5B;AACA,QAAM,iBAAiB,oBAAI,IAAY;AACvC,aAAW,OAAO,CAAC,QAAQ;AACzB,WAAO,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,GAAG,EAAE;AAAA,EAC1C;AACA,aAAW,OAAO,CAAC,QAAQ;AACzB,eAAW,YAAY;AACvB,WAAO,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,GAAG,EAAE;AAAA,EAC1C;AACA,aAAW,WAAW,CAAC,QAAQ;AAC7B,QAAI,eAAe,IAAI,GAAG,GAAG;AAC3B;AAAA,IACF;AACA,eAAW,YAAY;AACvB,WAAO,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,GAAG,EAAE;AACxC,mBAAe,IAAI,GAAG;AAAA,EACxB;AACA,aAAW,QAAQ,CAAC,QAAQ;AAC1B,eAAW,YAAY;AACvB,WAAO,SAAS,GAAG,IAAI,QAAQ,CAAC,IAAI,GAAG,EAAE;AAAA,EAC3C;AAEA,QAAM,OACJ,OAAO,kBAAkB,WACrB,iBACC,MAAM,gBAAgB,GAAG,CAAC;AAEjC,QAAM,kBAAkB,gBAAgB,cAAc,CAAC,GAAG;AAAA,IACxD;AAAA,IACA,SAAS;AAAA,IACT,YAAY,mBAAmB,OAAO,SAAY;AAAA,IAClD;AAAA,IACA,cAAc;AAAA,IACd,UAAU,MAAM,KAAK,cAAc,OAAO;AAAA,EAC5C,CAAwB;AACxB,SAAO,MAAM;AAAA,IACX;AAAA,IACA,iBAAiB,IAAI,EAAE;AAAA,IACvB,iBAAiB,IAAI,EAAE;AAAA,IACvB;AAAA,IACA,iBAAiB,IAAI,EAAE;AAAA,EACzB;AACF;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  resolveViteConfig
3
- } from "./chunk-OZ4XTSAH.js";
3
+ } from "./chunk-5DB6XVJN.js";
4
4
  import {
5
5
  createViteServer,
6
6
  getViewerFullUrl,
@@ -9,16 +9,16 @@ import {
9
9
  mergeInlineConfig,
10
10
  resolveTaskConfig,
11
11
  warnDeprecatedConfig
12
- } from "./chunk-WELNNHOB.js";
12
+ } from "./chunk-YN3JNBNT.js";
13
13
  import {
14
14
  Logger,
15
15
  isUnicodeSupported,
16
16
  randomBookSymbol,
17
17
  setupConfigFromFlags
18
- } from "./chunk-G3GROLBN.js";
18
+ } from "./chunk-MQYXBSRJ.js";
19
19
  import {
20
20
  cliVersion
21
- } from "./chunk-4IIM6RSG.js";
21
+ } from "./chunk-ZKEIYNLT.js";
22
22
  import {
23
23
  __callDispose,
24
24
  __using
@@ -28,8 +28,7 @@ import {
28
28
  import terminalLink from "terminal-link";
29
29
  import { blueBright, cyan, dim } from "yoctocolors";
30
30
  async function preview(inlineConfig) {
31
- Logger.setLogLevel(inlineConfig.logLevel);
32
- Logger.setCustomLogger(inlineConfig.logger);
31
+ Logger.setLogOptions(inlineConfig);
33
32
  Logger.debug("preview > inlineConfig %O", inlineConfig);
34
33
  let vivliostyleConfig = await loadVivliostyleConfig(inlineConfig) ?? setupConfigFromFlags(inlineConfig);
35
34
  warnDeprecatedConfig(vivliostyleConfig);
@@ -85,4 +84,4 @@ ${blueBright("\u2559\u2500")} ${dim(`Preview URL: ${terminalLink(url, url, { fal
85
84
  export {
86
85
  preview
87
86
  };
88
- //# sourceMappingURL=chunk-3O3N2V7D.js.map
87
+ //# sourceMappingURL=chunk-5K3NGLBV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/preview.ts"],"sourcesContent":["import terminalLink from 'terminal-link';\nimport type { ViteDevServer } from 'vite';\nimport { blueBright, cyan, dim } from 'yoctocolors';\nimport { setupConfigFromFlags } from '../commands/cli-flags.js';\nimport { loadVivliostyleConfig, warnDeprecatedConfig } from '../config/load.js';\nimport { mergeConfig, mergeInlineConfig } from '../config/merge.js';\nimport { resolveTaskConfig } from '../config/resolve.js';\nimport type { ParsedVivliostyleInlineConfig } from '../config/schema.js';\nimport { resolveViteConfig } from '../config/vite.js';\nimport { cliVersion } from '../const.js';\nimport { isUnicodeSupported, Logger, randomBookSymbol } from '../logger.js';\nimport { createViteServer, getViewerFullUrl } from '../server.js';\n\nexport async function preview(inlineConfig: ParsedVivliostyleInlineConfig) {\n Logger.setLogOptions(inlineConfig);\n Logger.debug('preview > inlineConfig %O', inlineConfig);\n\n let vivliostyleConfig =\n (await loadVivliostyleConfig(inlineConfig)) ??\n setupConfigFromFlags(inlineConfig);\n warnDeprecatedConfig(vivliostyleConfig);\n vivliostyleConfig = mergeInlineConfig(vivliostyleConfig, inlineConfig);\n const { tasks, inlineOptions } = vivliostyleConfig;\n Logger.debug('preview > vivliostyleConfig %O', vivliostyleConfig);\n\n // Only show preview of first entry\n let config = resolveTaskConfig(tasks[0], inlineOptions);\n Logger.debug('preview > config %O', config);\n\n let server: ViteDevServer;\n let url: string;\n {\n using _ = Logger.startLogging('Start preview');\n const viteConfig = await resolveViteConfig({\n ...config,\n mode: 'preview',\n });\n server = await createViteServer({\n config,\n viteConfig,\n inlineConfig,\n mode: 'preview',\n });\n if (server.httpServer) {\n await server.listen();\n vivliostyleConfig = mergeConfig(vivliostyleConfig, {\n temporaryFilePrefix: config.temporaryFilePrefix,\n server: server.config.server,\n });\n config = resolveTaskConfig(\n vivliostyleConfig.tasks[0],\n vivliostyleConfig.inlineOptions,\n );\n }\n url = await getViewerFullUrl(config);\n }\n\n if (server.httpServer) {\n Logger.log(`\n${cyan(`Vivliostyle CLI v${cliVersion}`)}\n${blueBright('║')} ${isUnicodeSupported ? `${randomBookSymbol} ` : ''}Up and running (press Ctrl+C to quit)\n${blueBright('╙─')} ${dim(`Preview URL: ${terminalLink(url, url, { fallback: () => url })}`)}\n`);\n }\n return server;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,kBAAkB;AAEzB,SAAS,YAAY,MAAM,WAAW;AAWtC,eAAsB,QAAQ,cAA6C;AACzE,SAAO,cAAc,YAAY;AACjC,SAAO,MAAM,6BAA6B,YAAY;AAEtD,MAAI,oBACD,MAAM,sBAAsB,YAAY,KACzC,qBAAqB,YAAY;AACnC,uBAAqB,iBAAiB;AACtC,sBAAoB,kBAAkB,mBAAmB,YAAY;AACrE,QAAM,EAAE,OAAO,cAAc,IAAI;AACjC,SAAO,MAAM,kCAAkC,iBAAiB;AAGhE,MAAI,SAAS,kBAAkB,MAAM,CAAC,GAAG,aAAa;AACtD,SAAO,MAAM,uBAAuB,MAAM;AAE1C,MAAI;AACJ,MAAI;AACJ;AACE;AAAA;AAAA,YAAMA,KAAI,uBAAO,aAAa,eAAe;AAC7C,YAAM,aAAa,MAAM,kBAAkB;AAAA,QACzC,GAAG;AAAA,QACH,MAAM;AAAA,MACR,CAAC;AACD,eAAS,MAAM,iBAAiB;AAAA,QAC9B;AAAA,QACA;AAAA,QACA;AAAA,QACA,MAAM;AAAA,MACR,CAAC;AACD,UAAI,OAAO,YAAY;AACrB,cAAM,OAAO,OAAO;AACpB,4BAAoB,YAAY,mBAAmB;AAAA,UACjD,qBAAqB,OAAO;AAAA,UAC5B,QAAQ,OAAO,OAAO;AAAA,QACxB,CAAC;AACD,iBAAS;AAAA,UACP,kBAAkB,MAAM,CAAC;AAAA,UACzB,kBAAkB;AAAA,QACpB;AAAA,MACF;AACA,YAAM,MAAM,iBAAiB,MAAM;AAAA,aAtBnC;AAAA;AAAA;AAAA;AAAA;AAAA,EAuBF;AAEA,MAAI,OAAO,YAAY;AACrB,WAAO,IAAI;AAAA,EACb,KAAK,oBAAoB,UAAU,EAAE,CAAC;AAAA,EACtC,WAAW,QAAG,CAAC,IAAI,qBAAqB,GAAG,gBAAgB,MAAM,EAAE;AAAA,EACnE,WAAW,cAAI,CAAC,IAAI,IAAI,gBAAgB,aAAa,KAAK,KAAK,EAAE,UAAU,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC;AAAA,CAC3F;AAAA,EACC;AACA,SAAO;AACT;","names":["_"]}