@vivliostyle/cli 9.0.0-next.6 → 9.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.
- package/README.md +34 -48
- package/dist/{chunk-QC3BOE2G.js → chunk-4Y2QIRBA.js} +1 -1
- package/dist/{chunk-DMGAKSPH.js → chunk-5AUWIYEK.js} +8 -10
- package/dist/{chunk-Y3ETBU5J.js → chunk-FQMQ7BWY.js} +1 -1
- package/dist/{chunk-VBEHGS67.js → chunk-PY4J4NG6.js} +52 -42
- package/dist/{chunk-LASMQBPP.js → chunk-QZWMJ4L2.js} +2 -2
- package/dist/{chunk-E7QOXL6M.js → chunk-XRR6RKA6.js} +1 -1
- package/dist/commands/build.js +7 -4
- package/dist/commands/init.js +2 -2
- package/dist/commands/preview.js +7 -4
- package/dist/config/schema.d.ts +11030 -4957
- package/dist/index.js +6 -6
- package/dist/vite-adapter.js +2 -2
- package/package.json +87 -83
package/README.md
CHANGED
|
@@ -49,8 +49,7 @@ Options:
|
|
|
49
49
|
-l, --language <language> language
|
|
50
50
|
-s, --size <size> paper size
|
|
51
51
|
-T, --theme <theme> theme
|
|
52
|
-
--log-level <level> specify a log level of console outputs (choices: "silent", "info",
|
|
53
|
-
"verbose", "debug", default: "info")
|
|
52
|
+
--log-level <level> specify a log level of console outputs (choices: "silent", "info", "verbose", "debug", default: "info")
|
|
54
53
|
-h, --help display help for command
|
|
55
54
|
```
|
|
56
55
|
|
|
@@ -64,28 +63,22 @@ Put [vivliostyle.config.js](https://github.com/vivliostyle/create-book/blob/mast
|
|
|
64
63
|
vivliostyle build
|
|
65
64
|
```
|
|
66
65
|
|
|
67
|
-

|
|
68
|
-
|
|
69
66
|
#### CLI options
|
|
70
67
|
|
|
71
68
|
```
|
|
72
69
|
Options:
|
|
73
70
|
-c, --config <config_file> path to vivliostyle.config.js [vivliostyle.config.js]
|
|
74
71
|
-o, --output <path> specify output file name or directory [<title>.pdf]
|
|
75
|
-
This option can be specified multiple, then each -o options can
|
|
76
|
-
be supplied one -f option.
|
|
72
|
+
This option can be specified multiple, then each -o options can be supplied one -f option.
|
|
77
73
|
ex: -o output1 -f webpub -o output2.pdf -f pdf
|
|
78
74
|
-f, --format <format> specify output format corresponding output target
|
|
79
|
-
If an extension is specified on -o option, this field will be
|
|
80
|
-
inferenced automatically.
|
|
75
|
+
If an extension is specified on -o option, this field will be inferenced automatically.
|
|
81
76
|
-s, --size <size> output pdf size
|
|
82
|
-
preset: A5, A4, A3, B5, B4, JIS-B5, JIS-B4, letter, legal,
|
|
83
|
-
ledger
|
|
77
|
+
preset: A5, A4, A3, B5, B4, JIS-B5, JIS-B4, letter, legal, ledger
|
|
84
78
|
custom(comma separated): 182mm,257mm or 8.5in,11in
|
|
85
79
|
-m, --crop-marks print crop marks
|
|
86
80
|
--bleed <bleed> extent of the bleed area for printing with crop marks [3mm]
|
|
87
|
-
--crop-offset <offset> distance between the edge of the trim size and the edge of the
|
|
88
|
-
media size. [auto (13mm + bleed)]
|
|
81
|
+
--crop-offset <offset> distance between the edge of the trim size and the edge of the media size. [auto (13mm + bleed)]
|
|
89
82
|
--css <CSS> custom style CSS code. (ex: ":root {--my-color: lime;}")
|
|
90
83
|
--style <stylesheet> additional stylesheet URL or path
|
|
91
84
|
--user-style <user_stylesheet> user stylesheet URL or path
|
|
@@ -93,36 +86,32 @@ Options:
|
|
|
93
86
|
-p, --press-ready make generated PDF compatible with press ready PDF/X-1a [false]
|
|
94
87
|
This option is equivalent with "--preflight press-ready"
|
|
95
88
|
-t, --timeout <seconds> timeout limit for waiting Vivliostyle process [120]
|
|
96
|
-
-T, --theme <theme
|
|
89
|
+
-T, --theme <theme...> theme path or package name
|
|
97
90
|
--title <title> title
|
|
98
91
|
--author <author> author
|
|
99
92
|
-l, --language <language> language
|
|
100
93
|
--reading-progression <direction> Direction of reading progression (choices: "ltr", "rtl")
|
|
101
|
-
--render-mode <mode> if docker is set, Vivliostyle try to render PDF on Docker
|
|
102
|
-
|
|
103
|
-
--preflight <mode> apply the process to generate PDF for printing (choices:
|
|
104
|
-
"press-ready", "press-ready-local")
|
|
94
|
+
--render-mode <mode> if docker is set, Vivliostyle try to render PDF on Docker container [local] (choices: "local", "docker")
|
|
95
|
+
--preflight <mode> apply the process to generate PDF for printing (choices: "press-ready", "press-ready-local")
|
|
105
96
|
--preflight-option <options...> options for preflight process (ex: gray-scale, enforce-outline)
|
|
106
|
-
Please refer the document of press-ready for further
|
|
107
|
-
information.
|
|
97
|
+
Please refer the document of press-ready for further information.
|
|
108
98
|
https://github.com/vibranthq/press-ready
|
|
109
99
|
--executable-browser <path> specify a path of executable browser you installed
|
|
110
100
|
--image <image> specify a docker image to render
|
|
111
|
-
--
|
|
112
|
-
It is useful that
|
|
113
|
-
--viewer <
|
|
114
|
-
one
|
|
115
|
-
It is useful that using own viewer that has staging features.
|
|
116
|
-
(ex: https://vivliostyle.vercel.app/)
|
|
117
|
-
--viewer-param <parameters> specify viewer parameters. (ex:
|
|
118
|
-
"allowScripts=false&pixelRatio=16")
|
|
101
|
+
--viewer <URL> specify a URL of displaying viewer instead of vivliostyle-cli's one
|
|
102
|
+
It is useful that using own viewer that has staging features. (ex: https://vivliostyle.vercel.app/)
|
|
103
|
+
--viewer-param <parameters> specify viewer parameters. (ex: "allowScripts=false&pixelRatio=16")
|
|
119
104
|
--proxy-server <proxyServer> HTTP/SOCK proxy server url for underlying Playwright
|
|
120
105
|
--proxy-bypass <proxyBypass> optional comma-separated domains to bypass proxy
|
|
121
106
|
--proxy-user <proxyUser> optional username for HTTP proxy authentication
|
|
122
107
|
--proxy-pass <proxyPass> optional password for HTTP proxy authentication
|
|
123
|
-
--log-level <level> specify a log level of console outputs (choices: "silent",
|
|
124
|
-
"info", "verbose", "debug", default: "info")
|
|
108
|
+
--log-level <level> specify a log level of console outputs (choices: "silent", "info", "verbose", "debug", default: "info")
|
|
125
109
|
--ignore-https-errors true to ignore HTTPS errors when Playwright browser opens a new page
|
|
110
|
+
--host <host> IP address the server should listen on
|
|
111
|
+
--port <port> port the server should listen on
|
|
112
|
+
--no-enable-static-serve disable static file serving
|
|
113
|
+
--vite-config-file <path> Vite config file path
|
|
114
|
+
--no-vite-config-file ignore Vite config file even if it exists
|
|
126
115
|
-h, --help display help for command
|
|
127
116
|
```
|
|
128
117
|
|
|
@@ -139,15 +128,13 @@ vivliostyle preview
|
|
|
139
128
|
```
|
|
140
129
|
Options:
|
|
141
130
|
-c, --config <config_file> path to vivliostyle.config.js
|
|
142
|
-
-T, --theme <theme
|
|
131
|
+
-T, --theme <theme...> theme path or package name
|
|
143
132
|
-s, --size <size> output pdf size
|
|
144
|
-
preset: A5, A4, A3, B5, B4, JIS-B5, JIS-B4, letter, legal,
|
|
145
|
-
ledger
|
|
133
|
+
preset: A5, A4, A3, B5, B4, JIS-B5, JIS-B4, letter, legal, ledger
|
|
146
134
|
custom(comma separated): 182mm,257mm or 8.5in,11in
|
|
147
135
|
-m, --crop-marks print crop marks
|
|
148
136
|
--bleed <bleed> extent of the bleed area for printing with crop marks [3mm]
|
|
149
|
-
--crop-offset <offset> distance between the edge of the trim size and the edge of the
|
|
150
|
-
media size. [auto (13mm + bleed)]
|
|
137
|
+
--crop-offset <offset> distance between the edge of the trim size and the edge of the media size. [auto (13mm + bleed)]
|
|
151
138
|
--css <CSS> custom style CSS code. (ex: ":root {--my-color: lime;}")
|
|
152
139
|
--style <stylesheet> additional stylesheet URL or path
|
|
153
140
|
--user-style <user_stylesheet> user stylesheet URL or path
|
|
@@ -158,25 +145,24 @@ Options:
|
|
|
158
145
|
-l, --language <language> language
|
|
159
146
|
--reading-progression <direction> Direction of reading progression (choices: "ltr", "rtl")
|
|
160
147
|
--executable-browser <path> specify a path of executable browser you installed
|
|
161
|
-
--
|
|
162
|
-
It is useful that
|
|
163
|
-
--viewer <
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
(ex: https://vivliostyle.vercel.app/)
|
|
167
|
-
--viewer-param <parameters> specify viewer parameters. (ex:
|
|
168
|
-
"allowScripts=false&pixelRatio=16")
|
|
169
|
-
--browser <browser> EXPERIMENTAL SUPPORT: Specify a browser type to launch
|
|
170
|
-
Vivliostyle viewer [chromium]
|
|
171
|
-
Currently, Firefox and Webkit support preview command only!
|
|
172
|
-
(choices: "chromium", "firefox", "webkit")
|
|
148
|
+
--viewer <URL> specify a URL of displaying viewer instead of vivliostyle-cli's one
|
|
149
|
+
It is useful that using own viewer that has staging features. (ex: https://vivliostyle.vercel.app/)
|
|
150
|
+
--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")
|
|
173
153
|
--proxy-server <proxyServer> HTTP/SOCK proxy server url for underlying Playwright
|
|
174
154
|
--proxy-bypass <proxyBypass> optional comma-separated domains to bypass proxy
|
|
175
155
|
--proxy-user <proxyUser> optional username for HTTP proxy authentication
|
|
176
156
|
--proxy-pass <proxyPass> optional password for HTTP proxy authentication
|
|
177
|
-
--log-level <level> specify a log level of console outputs (choices: "silent",
|
|
178
|
-
"info", "verbose", "debug", default: "info")
|
|
157
|
+
--log-level <level> specify a log level of console outputs (choices: "silent", "info", "verbose", "debug", default: "info")
|
|
179
158
|
--ignore-https-errors true to ignore HTTPS errors when Playwright browser opens a new page
|
|
159
|
+
--host <host> IP address the server should listen on
|
|
160
|
+
--port <port> port the server should listen on
|
|
161
|
+
--no-open-viewer do not open viewer
|
|
162
|
+
--no-enable-static-serve disable static file serving
|
|
163
|
+
--no-enable-viewer-start-page disable viewer start page
|
|
164
|
+
--vite-config-file <path> Vite config file path
|
|
165
|
+
--no-vite-config-file ignore Vite config file even if it exists
|
|
180
166
|
-h, --help display help for command
|
|
181
167
|
```
|
|
182
168
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveViteConfig
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-4Y2QIRBA.js";
|
|
4
4
|
import {
|
|
5
5
|
Logger,
|
|
6
6
|
buildPDFWithContainer,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
setupConfigFromFlags,
|
|
29
29
|
toContainerPath,
|
|
30
30
|
warnDeprecatedConfig
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-PY4J4NG6.js";
|
|
32
32
|
import {
|
|
33
33
|
coreVersion
|
|
34
34
|
} from "./chunk-EX7EA34F.js";
|
|
@@ -524,20 +524,18 @@ async function build(inlineConfig) {
|
|
|
524
524
|
__callDispose(_stack, _error, _hasError);
|
|
525
525
|
}
|
|
526
526
|
}
|
|
527
|
+
server = await createViteServer({
|
|
528
|
+
config,
|
|
529
|
+
viteConfig,
|
|
530
|
+
inlineConfig,
|
|
531
|
+
mode: "build"
|
|
532
|
+
});
|
|
527
533
|
if (isWebPubConfig(config)) {
|
|
528
534
|
await cleanupWorkspace(config);
|
|
529
535
|
await prepareThemeDirectory(config);
|
|
530
536
|
await compile(config);
|
|
531
537
|
await copyAssets(config);
|
|
532
538
|
}
|
|
533
|
-
if (config.outputs.some((o) => o.format === "pdf")) {
|
|
534
|
-
server = await createViteServer({
|
|
535
|
-
config,
|
|
536
|
-
viteConfig,
|
|
537
|
-
inlineConfig,
|
|
538
|
-
mode: "build"
|
|
539
|
-
});
|
|
540
|
-
}
|
|
541
539
|
}
|
|
542
540
|
for (const target of config.outputs) {
|
|
543
541
|
let output = null;
|
|
@@ -34,10 +34,9 @@ import {
|
|
|
34
34
|
evaluate,
|
|
35
35
|
parse
|
|
36
36
|
} from "@humanwhocodes/momoa";
|
|
37
|
-
import
|
|
38
|
-
import
|
|
37
|
+
import { Ajv } from "ajv";
|
|
38
|
+
import formatsPlugin from "ajv-formats";
|
|
39
39
|
import { XMLParser } from "fast-xml-parser";
|
|
40
|
-
import { removeSync } from "fs-extra/esm";
|
|
41
40
|
import StreamZip from "node-stream-zip";
|
|
42
41
|
import fs from "node:fs";
|
|
43
42
|
import readline from "node:readline";
|
|
@@ -896,7 +895,7 @@ function useTmpDirectory() {
|
|
|
896
895
|
}]);
|
|
897
896
|
}
|
|
898
897
|
const callback = () => {
|
|
899
|
-
|
|
898
|
+
fs.rmSync(path, { force: true, recursive: true });
|
|
900
899
|
};
|
|
901
900
|
registerExitHandler(
|
|
902
901
|
`Removing the temporary directory: ${path}`,
|
|
@@ -911,7 +910,7 @@ function touchTmpFile(path) {
|
|
|
911
910
|
fs.closeSync(fs.openSync(path, "a"));
|
|
912
911
|
Logger.debug(`Created the temporary file: ${path}`);
|
|
913
912
|
const callback = () => {
|
|
914
|
-
|
|
913
|
+
fs.rmSync(path, { force: true, recursive: true });
|
|
915
914
|
};
|
|
916
915
|
registerExitHandler(`Removing the temporary file: ${path}`, callback);
|
|
917
916
|
return callback;
|
|
@@ -929,11 +928,14 @@ function isValidUri(str) {
|
|
|
929
928
|
function isInContainer() {
|
|
930
929
|
return fs.existsSync("/opt/vivliostyle-cli/.vs-cli-version");
|
|
931
930
|
}
|
|
931
|
+
function isRunningOnWSL() {
|
|
932
|
+
return fs.existsSync("/proc/version") && fs.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft");
|
|
933
|
+
}
|
|
932
934
|
async function openEpub(epubPath, tmpDir) {
|
|
933
935
|
await inflateZip(epubPath, tmpDir);
|
|
934
936
|
Logger.debug(`Created the temporary EPUB directory: ${tmpDir}`);
|
|
935
937
|
const deleteEpub = () => {
|
|
936
|
-
fs.rmSync(tmpDir, { recursive: true });
|
|
938
|
+
fs.rmSync(tmpDir, { force: true, recursive: true });
|
|
937
939
|
};
|
|
938
940
|
registerExitHandler(
|
|
939
941
|
`Removing the temporary EPUB directory: ${tmpDir}`,
|
|
@@ -967,10 +969,9 @@ function getEpubRootDir(epubOpfPath) {
|
|
|
967
969
|
}
|
|
968
970
|
return traverse(upath.dirname(epubOpfPath));
|
|
969
971
|
}
|
|
970
|
-
var Ajv = AjvModule.default;
|
|
971
|
-
var addFormats = AjvFormatsModule.default;
|
|
972
972
|
var getAjvValidatorFunction = (schema, refSchemas) => (obj) => {
|
|
973
973
|
const ajv = new Ajv({ strict: false });
|
|
974
|
+
const addFormats = formatsPlugin;
|
|
974
975
|
addFormats(ajv);
|
|
975
976
|
if (refSchemas) {
|
|
976
977
|
ajv.addSchema(refSchemas);
|
|
@@ -1301,16 +1302,16 @@ async function launchBrowser({
|
|
|
1301
1302
|
headless,
|
|
1302
1303
|
args: [
|
|
1303
1304
|
"--allow-file-access-from-files",
|
|
1304
|
-
disableWebSecurity
|
|
1305
|
-
disableDevShmUsage
|
|
1305
|
+
...disableWebSecurity ? ["--disable-web-security"] : [],
|
|
1306
|
+
...disableDevShmUsage ? ["--disable-dev-shm-usage"] : [],
|
|
1306
1307
|
// #357: Set devicePixelRatio=1 otherwise it causes layout issues in HiDPI displays
|
|
1307
|
-
headless
|
|
1308
|
-
//
|
|
1309
|
-
"--
|
|
1310
|
-
//
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
]
|
|
1308
|
+
...headless ? ["--force-device-scale-factor=1"] : [],
|
|
1309
|
+
// #565: Add --disable-gpu option when running on WSL
|
|
1310
|
+
...isRunningOnWSL() ? ["--disable-gpu"] : [],
|
|
1311
|
+
// set Chromium language to English to avoid locale-dependent issues
|
|
1312
|
+
"--lang=en",
|
|
1313
|
+
...!headless && process.platform === "darwin" ? ["", "-AppleLanguages", "(en)"] : []
|
|
1314
|
+
],
|
|
1314
1315
|
env: { ...process.env, LANG: "en.UTF-8" },
|
|
1315
1316
|
proxy
|
|
1316
1317
|
} : (
|
|
@@ -1866,7 +1867,6 @@ function resolveTaskConfig(config, options) {
|
|
|
1866
1867
|
outputs,
|
|
1867
1868
|
temporaryFilePrefix,
|
|
1868
1869
|
themeIndexes,
|
|
1869
|
-
rootUrl,
|
|
1870
1870
|
cover
|
|
1871
1871
|
});
|
|
1872
1872
|
for (const output of outputs) {
|
|
@@ -2041,7 +2041,7 @@ function resolveSingleInputConfig({
|
|
|
2041
2041
|
let webbookPath;
|
|
2042
2042
|
if (isValidUri(sourcePath)) {
|
|
2043
2043
|
const url = new URL(sourcePath);
|
|
2044
|
-
if (/^https?:/i.test(url.protocol) && !url.pathname.endsWith("/") &&
|
|
2044
|
+
if (/^https?:/i.test(url.protocol) && !url.pathname.endsWith("/") && !/\.\w+$/.test(url.pathname)) {
|
|
2045
2045
|
url.pathname = `${url.pathname}/`;
|
|
2046
2046
|
}
|
|
2047
2047
|
webbookEntryUrl = url.href;
|
|
@@ -2093,7 +2093,6 @@ function resolveComposedProjectConfig({
|
|
|
2093
2093
|
outputs,
|
|
2094
2094
|
temporaryFilePrefix,
|
|
2095
2095
|
themeIndexes,
|
|
2096
|
-
rootUrl,
|
|
2097
2096
|
cover
|
|
2098
2097
|
}) {
|
|
2099
2098
|
Logger.debug("entering composed project config mode");
|
|
@@ -2155,7 +2154,7 @@ function resolveComposedProjectConfig({
|
|
|
2155
2154
|
} else if (entryPath.startsWith("/")) {
|
|
2156
2155
|
return {
|
|
2157
2156
|
type: "uri",
|
|
2158
|
-
href:
|
|
2157
|
+
href: entryPath,
|
|
2159
2158
|
rootDir: upath5.join(workspaceDir, "localhost")
|
|
2160
2159
|
};
|
|
2161
2160
|
}
|
|
@@ -2189,7 +2188,7 @@ function resolveComposedProjectConfig({
|
|
|
2189
2188
|
case "uri": {
|
|
2190
2189
|
const url = new URL(source.href, "a://dummy");
|
|
2191
2190
|
let pathname = url.pathname;
|
|
2192
|
-
if (
|
|
2191
|
+
if (!/\.\w+$/.test(pathname)) {
|
|
2193
2192
|
pathname = `${pathname.replace(/\/$/, "")}/index.html`;
|
|
2194
2193
|
}
|
|
2195
2194
|
return upath5.join(source.rootDir, pathname);
|
|
@@ -2357,7 +2356,7 @@ Maybe you want to set the "output" field instead.`
|
|
|
2357
2356
|
}
|
|
2358
2357
|
|
|
2359
2358
|
// src/processor/compile.ts
|
|
2360
|
-
import { copy as copy3, move
|
|
2359
|
+
import { copy as copy3, move } from "fs-extra/esm";
|
|
2361
2360
|
import fs9 from "node:fs";
|
|
2362
2361
|
import picomatch from "picomatch";
|
|
2363
2362
|
import prettier from "prettier";
|
|
@@ -2367,7 +2366,7 @@ import upath9 from "upath";
|
|
|
2367
2366
|
import MIMEType2 from "whatwg-mimetype";
|
|
2368
2367
|
|
|
2369
2368
|
// src/output/webbook.ts
|
|
2370
|
-
import { copy as copy2
|
|
2369
|
+
import { copy as copy2 } from "fs-extra/esm";
|
|
2371
2370
|
import { lookup as mime3 } from "mime-types";
|
|
2372
2371
|
import fs7 from "node:fs";
|
|
2373
2372
|
import { pathToFileURL as pathToFileURL6 } from "node:url";
|
|
@@ -2415,7 +2414,10 @@ var createVirtualConsole = (onError) => {
|
|
|
2415
2414
|
});
|
|
2416
2415
|
return virtualConsole;
|
|
2417
2416
|
};
|
|
2418
|
-
var htmlPurify = DOMPurify(
|
|
2417
|
+
var htmlPurify = DOMPurify(
|
|
2418
|
+
// @ts-expect-error: jsdom.DOMWindow should have trustedTypes property
|
|
2419
|
+
new JSDOM("").window
|
|
2420
|
+
);
|
|
2419
2421
|
var ResourceLoader = class extends BaseResourceLoader {
|
|
2420
2422
|
fetcherMap = /* @__PURE__ */ new Map();
|
|
2421
2423
|
fetch(url, options) {
|
|
@@ -2932,7 +2934,7 @@ function parsePageListDocument(dom) {
|
|
|
2932
2934
|
import archiver from "archiver";
|
|
2933
2935
|
import { lookup as lookupLanguage } from "bcp-47-match";
|
|
2934
2936
|
import { XMLBuilder } from "fast-xml-parser";
|
|
2935
|
-
import { copy
|
|
2937
|
+
import { copy } from "fs-extra/esm";
|
|
2936
2938
|
import GithubSlugger from "github-slugger";
|
|
2937
2939
|
import { lookup as mime2 } from "mime-types";
|
|
2938
2940
|
import fs6 from "node:fs";
|
|
@@ -3164,7 +3166,10 @@ async function exportEpub({
|
|
|
3164
3166
|
});
|
|
3165
3167
|
}
|
|
3166
3168
|
if (relManifestPath) {
|
|
3167
|
-
await
|
|
3169
|
+
await fs6.promises.rm(upath7.join(tmpDir, "EPUB", relManifestPath), {
|
|
3170
|
+
force: true,
|
|
3171
|
+
recursive: true
|
|
3172
|
+
});
|
|
3168
3173
|
delete manifestItem[relManifestPath];
|
|
3169
3174
|
}
|
|
3170
3175
|
fs6.writeFileSync(
|
|
@@ -3492,7 +3497,7 @@ async function prepareWebPublicationDirectory({
|
|
|
3492
3497
|
}) {
|
|
3493
3498
|
if (fs7.existsSync(outputDir)) {
|
|
3494
3499
|
Logger.debug("going to remove existing webpub", outputDir);
|
|
3495
|
-
await
|
|
3500
|
+
await fs7.promises.rm(outputDir, { force: true, recursive: true });
|
|
3496
3501
|
}
|
|
3497
3502
|
fs7.mkdirSync(outputDir, { recursive: true });
|
|
3498
3503
|
}
|
|
@@ -4037,7 +4042,7 @@ async function cleanupWorkspace({
|
|
|
4037
4042
|
);
|
|
4038
4043
|
await move(themesDir, movedThemePath);
|
|
4039
4044
|
}
|
|
4040
|
-
await
|
|
4045
|
+
await fs9.promises.rm(workspaceDir, { recursive: true, force: true });
|
|
4041
4046
|
if (movedWorkspacePath) {
|
|
4042
4047
|
await move(movedWorkspacePath, workspaceDir);
|
|
4043
4048
|
}
|
|
@@ -4071,11 +4076,13 @@ async function transformManuscript(entry, {
|
|
|
4071
4076
|
entries,
|
|
4072
4077
|
language,
|
|
4073
4078
|
documentProcessorFactory,
|
|
4074
|
-
vfmOptions
|
|
4079
|
+
vfmOptions,
|
|
4080
|
+
rootUrl
|
|
4075
4081
|
}) {
|
|
4076
4082
|
const source = entry.rel === "contents" || entry.rel === "cover" ? entry.template : entry.source;
|
|
4077
4083
|
let content;
|
|
4078
4084
|
let resourceLoader;
|
|
4085
|
+
let resourceUrl;
|
|
4079
4086
|
const style = entry.themes.flatMap(
|
|
4080
4087
|
(theme) => locateThemePath(theme, upath9.dirname(entry.target))
|
|
4081
4088
|
);
|
|
@@ -4106,10 +4113,11 @@ async function transformManuscript(entry, {
|
|
|
4106
4113
|
}
|
|
4107
4114
|
}
|
|
4108
4115
|
} else if (source?.type === "uri") {
|
|
4116
|
+
resourceUrl = /^https?:/.test(source.href) ? source.href : `${rootUrl}${source.href}`;
|
|
4109
4117
|
resourceLoader = new ResourceLoader();
|
|
4110
4118
|
try {
|
|
4111
4119
|
await getJsdomFromUrlOrFile({
|
|
4112
|
-
src:
|
|
4120
|
+
src: resourceUrl,
|
|
4113
4121
|
resourceLoader,
|
|
4114
4122
|
virtualConsole: createVirtualConsole((error) => {
|
|
4115
4123
|
Logger.logError(`Failed to fetch resources: ${error.detail}`);
|
|
@@ -4117,16 +4125,16 @@ async function transformManuscript(entry, {
|
|
|
4117
4125
|
});
|
|
4118
4126
|
} catch (error) {
|
|
4119
4127
|
throw new DetailError(
|
|
4120
|
-
`Failed to fetch the content from ${
|
|
4128
|
+
`Failed to fetch the content from ${resourceUrl}`,
|
|
4121
4129
|
error.stack ?? error.message
|
|
4122
4130
|
);
|
|
4123
4131
|
}
|
|
4124
|
-
const contentFetcher = resourceLoader.fetcherMap.get(
|
|
4132
|
+
const contentFetcher = resourceLoader.fetcherMap.get(resourceUrl);
|
|
4125
4133
|
if (contentFetcher) {
|
|
4126
4134
|
const buffer = await contentFetcher;
|
|
4127
4135
|
const contentType = contentFetcher.response?.headers["content-type"];
|
|
4128
4136
|
if (!contentType || new MIMEType2(contentType).essence !== "text/html") {
|
|
4129
|
-
throw new Error(`The content is not an HTML document: ${
|
|
4137
|
+
throw new Error(`The content is not an HTML document: ${resourceUrl}`);
|
|
4130
4138
|
}
|
|
4131
4139
|
content = getJsdomFromString({ html: buffer.toString("utf8") });
|
|
4132
4140
|
content = await processManuscriptHtml(content, {
|
|
@@ -4201,18 +4209,18 @@ async function transformManuscript(entry, {
|
|
|
4201
4209
|
if (!source || source.type === "file" && !pathEquals(source.pathname, entry.target)) {
|
|
4202
4210
|
writeFileIfChanged(entry.target, htmlBuffer);
|
|
4203
4211
|
}
|
|
4204
|
-
if (source?.type === "uri" && resourceLoader) {
|
|
4205
|
-
const { response } = resourceLoader.fetcherMap.get(
|
|
4212
|
+
if (source?.type === "uri" && resourceLoader && resourceUrl) {
|
|
4213
|
+
const { response } = resourceLoader.fetcherMap.get(resourceUrl);
|
|
4206
4214
|
const contentFetcher = Promise.resolve(
|
|
4207
4215
|
htmlBuffer
|
|
4208
4216
|
);
|
|
4209
4217
|
contentFetcher.abort = () => {
|
|
4210
4218
|
};
|
|
4211
4219
|
contentFetcher.response = response;
|
|
4212
|
-
resourceLoader.fetcherMap.set(
|
|
4220
|
+
resourceLoader.fetcherMap.set(resourceUrl, contentFetcher);
|
|
4213
4221
|
await ResourceLoader.saveFetchedResources({
|
|
4214
4222
|
fetcherMap: resourceLoader.fetcherMap,
|
|
4215
|
-
rootUrl:
|
|
4223
|
+
rootUrl: resourceUrl,
|
|
4216
4224
|
outputDir: source.rootDir
|
|
4217
4225
|
});
|
|
4218
4226
|
}
|
|
@@ -4510,10 +4518,11 @@ function vsDevServerPlugin({
|
|
|
4510
4518
|
server?.watcher.add(config.viewerInput.manifestPath);
|
|
4511
4519
|
}
|
|
4512
4520
|
}
|
|
4513
|
-
async function transform(entry, config2) {
|
|
4521
|
+
async function transform(entry, config2, host) {
|
|
4522
|
+
const rootUrl = host ? `${server?.config.server.https ? "https" : "http"}://${host}` : config2.rootUrl;
|
|
4514
4523
|
const promise = (async () => {
|
|
4515
4524
|
try {
|
|
4516
|
-
const html = await transformManuscript(entry, config2);
|
|
4525
|
+
const html = await transformManuscript(entry, { ...config2, rootUrl });
|
|
4517
4526
|
if (!html) {
|
|
4518
4527
|
transformCache.delete(entry.target);
|
|
4519
4528
|
return;
|
|
@@ -4580,15 +4589,16 @@ function vsDevServerPlugin({
|
|
|
4580
4589
|
return res.end(cached.content);
|
|
4581
4590
|
}
|
|
4582
4591
|
}
|
|
4592
|
+
const { host } = req.headers;
|
|
4583
4593
|
if (entry.rel === "contents") {
|
|
4584
4594
|
const _config2 = { ...config };
|
|
4585
4595
|
await Promise.all(
|
|
4586
4596
|
_config2.entries.flatMap(
|
|
4587
|
-
(e) => isWebPubConfig(_config2) && e.rel !== "contents" && e.rel !== "cover" ? transform(e, _config2) : []
|
|
4597
|
+
(e) => isWebPubConfig(_config2) && e.rel !== "contents" && e.rel !== "cover" ? transform(e, _config2, host) : []
|
|
4588
4598
|
)
|
|
4589
4599
|
);
|
|
4590
4600
|
}
|
|
4591
|
-
const result = await transform(entry, config);
|
|
4601
|
+
const result = await transform(entry, config, host);
|
|
4592
4602
|
if (!result) {
|
|
4593
4603
|
return next();
|
|
4594
4604
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveViteConfig
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-4Y2QIRBA.js";
|
|
4
4
|
import {
|
|
5
5
|
Logger,
|
|
6
6
|
createViteServer,
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
resolveTaskConfig,
|
|
14
14
|
setupConfigFromFlags,
|
|
15
15
|
warnDeprecatedConfig
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-PY4J4NG6.js";
|
|
17
17
|
import {
|
|
18
18
|
cliVersion
|
|
19
19
|
} from "./chunk-EX7EA34F.js";
|
package/dist/commands/build.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
build
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-5AUWIYEK.js";
|
|
4
|
+
import "../chunk-4Y2QIRBA.js";
|
|
5
5
|
import {
|
|
6
6
|
Logger,
|
|
7
7
|
gracefulError,
|
|
8
8
|
isInContainer,
|
|
9
9
|
parseFlagsToInlineConfig
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-PY4J4NG6.js";
|
|
11
11
|
import "../chunk-EX7EA34F.js";
|
|
12
12
|
import "../chunk-WX6JHPSL.js";
|
|
13
13
|
import "../chunk-DMARNPN5.js";
|
|
@@ -135,7 +135,10 @@ It is useful that using own viewer that has staging features. (ex: https://vivli
|
|
|
135
135
|
"--ignore-https-errors",
|
|
136
136
|
`true to ignore HTTPS errors when Playwright browser opens a new page`
|
|
137
137
|
)
|
|
138
|
-
).option("--host <host>", "IP address the server should listen on").option("--port <port>", "port the server should listen on", parseInt).option("--no-enable-static-serve", "disable static file serving").
|
|
138
|
+
).option("--host <host>", "IP address the server should listen on").option("--port <port>", "port the server should listen on", parseInt).option("--no-enable-static-serve", "disable static file serving").option("--vite-config-file <path>", "Vite config file path").option(
|
|
139
|
+
"--no-vite-config-file",
|
|
140
|
+
"ignore Vite config file even if it exists"
|
|
141
|
+
).addOption(new Option("--executable-chromium <path>").hideHelp()).addOption(new Option("--verbose").hideHelp()).addOption(new Option("--http").hideHelp()).action((_arg, option) => {
|
|
139
142
|
let invalid = targets.find((it) => !("path" in it));
|
|
140
143
|
if (invalid) {
|
|
141
144
|
throw new Error(
|
package/dist/commands/init.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
init
|
|
3
|
-
} from "../chunk-
|
|
3
|
+
} from "../chunk-XRR6RKA6.js";
|
|
4
4
|
import {
|
|
5
5
|
gracefulError,
|
|
6
6
|
parseFlagsToInlineConfig
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-PY4J4NG6.js";
|
|
8
8
|
import "../chunk-EX7EA34F.js";
|
|
9
9
|
import "../chunk-WX6JHPSL.js";
|
|
10
10
|
import "../chunk-DMARNPN5.js";
|
package/dist/commands/preview.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
preview
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-QZWMJ4L2.js";
|
|
4
|
+
import "../chunk-4Y2QIRBA.js";
|
|
5
5
|
import {
|
|
6
6
|
gracefulError,
|
|
7
7
|
parseFlagsToInlineConfig
|
|
8
|
-
} from "../chunk-
|
|
8
|
+
} from "../chunk-PY4J4NG6.js";
|
|
9
9
|
import "../chunk-EX7EA34F.js";
|
|
10
10
|
import "../chunk-WX6JHPSL.js";
|
|
11
11
|
import "../chunk-DMARNPN5.js";
|
|
@@ -82,7 +82,10 @@ Currently, Firefox and Webkit support preview command only!`
|
|
|
82
82
|
"--ignore-https-errors",
|
|
83
83
|
`true to ignore HTTPS errors when Playwright browser opens a new page`
|
|
84
84
|
)
|
|
85
|
-
).option("--host <host>", "IP address the server should listen on").option("--port <port>", "port the server should listen on", parseInt).option("--no-open-viewer", "do not open viewer").option("--no-enable-static-serve", "disable static file serving").option("--no-enable-viewer-start-page", "disable viewer start page").
|
|
85
|
+
).option("--host <host>", "IP address the server should listen on").option("--port <port>", "port the server should listen on", parseInt).option("--no-open-viewer", "do not open viewer").option("--no-enable-static-serve", "disable static file serving").option("--no-enable-viewer-start-page", "disable viewer start page").option("--vite-config-file <path>", "Vite config file path").option(
|
|
86
|
+
"--no-vite-config-file",
|
|
87
|
+
"ignore Vite config file even if it exists"
|
|
88
|
+
).addOption(new Option("--executable-chromium <path>").hideHelp()).addOption(new Option("--verbose").hideHelp()).addOption(new Option("--http").hideHelp());
|
|
86
89
|
return program;
|
|
87
90
|
}
|
|
88
91
|
|