@slidev/cli 0.29.1 → 0.30.1
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/{build-DYW4YDUF.js → build-MOXNSJPP.js} +18 -16
- package/dist/{build-MKWMU6W4.mjs → build-SSLWFRFJ.mjs} +11 -9
- package/dist/{chunk-NLYVEPP6.js → chunk-3GNNQ2GU.js} +1962 -1989
- package/dist/{chunk-G22DGVU7.mjs → chunk-46RYGQQC.mjs} +2 -2
- package/dist/{chunk-UEIFQWPY.mjs → chunk-4AVLCCHB.mjs} +81 -15
- package/dist/{chunk-7F2QYO53.js → chunk-7FQD47HM.js} +133 -67
- package/dist/{chunk-5BL2KALH.js → chunk-HBDQZUZK.js} +4 -4
- package/dist/{chunk-OJT6Z67R.mjs → chunk-HJCTB5CG.mjs} +1868 -1896
- package/dist/{chunk-7QXPSYEZ.js → chunk-IXNT7VMK.js} +16 -16
- package/dist/{chunk-VYBQLH2X.mjs → chunk-XMETW2MS.mjs} +12 -16
- package/dist/cli.js +30 -29
- package/dist/cli.mjs +13 -12
- package/dist/{export-GXF6EY3F.mjs → export-2FIFRI4R.mjs} +71 -66
- package/dist/{export-7OOFII75.js → export-X3EA2DO6.js} +71 -66
- package/dist/index.js +7 -7
- package/dist/index.mjs +4 -4
- package/package.json +17 -18
|
@@ -21,7 +21,6 @@ var __spreadValues = (a, b) => {
|
|
|
21
21
|
return a;
|
|
22
22
|
};
|
|
23
23
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
24
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
26
25
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
27
26
|
}) : x)(function(x) {
|
|
@@ -30,31 +29,31 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
30
29
|
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
31
30
|
});
|
|
32
31
|
var __esm = (fn, res) => function __init() {
|
|
33
|
-
return fn && (res = (0, fn[
|
|
32
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
34
33
|
};
|
|
35
34
|
var __commonJS = (cb, mod) => function __require2() {
|
|
36
|
-
return mod || (0, cb[
|
|
35
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
37
36
|
};
|
|
38
37
|
var __export = (target, all) => {
|
|
39
|
-
__markAsModule(target);
|
|
40
38
|
for (var name in all)
|
|
41
39
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
42
40
|
};
|
|
43
|
-
var
|
|
44
|
-
if (
|
|
45
|
-
for (let key of __getOwnPropNames(
|
|
46
|
-
if (!__hasOwnProp.call(
|
|
47
|
-
__defProp(
|
|
41
|
+
var __copyProps = (to, from, except, desc) => {
|
|
42
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
+
for (let key of __getOwnPropNames(from))
|
|
44
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
48
46
|
}
|
|
49
|
-
return
|
|
50
|
-
};
|
|
51
|
-
var __toModule = (module) => {
|
|
52
|
-
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
|
|
47
|
+
return to;
|
|
53
48
|
};
|
|
49
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
54
50
|
|
|
55
|
-
// ../../node_modules/.pnpm/tsup@5.
|
|
51
|
+
// ../../node_modules/.pnpm/tsup@5.12.5_typescript@4.6.3/node_modules/tsup/assets/cjs_shims.js
|
|
52
|
+
var getImportMetaUrl, importMetaUrl;
|
|
56
53
|
var init_cjs_shims = __esm({
|
|
57
|
-
"../../node_modules/.pnpm/tsup@5.
|
|
54
|
+
"../../node_modules/.pnpm/tsup@5.12.5_typescript@4.6.3/node_modules/tsup/assets/cjs_shims.js"() {
|
|
55
|
+
getImportMetaUrl = () => typeof document === "undefined" ? new URL("file:" + __filename).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
56
|
+
importMetaUrl = exports.importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
58
57
|
}
|
|
59
58
|
});
|
|
60
59
|
|
|
@@ -129,4 +128,5 @@ function generateGoogleFontsUrl(options) {
|
|
|
129
128
|
|
|
130
129
|
|
|
131
130
|
|
|
132
|
-
|
|
131
|
+
|
|
132
|
+
exports.__spreadValues = __spreadValues; exports.__spreadProps = __spreadProps; exports.__require = __require; exports.__commonJS = __commonJS; exports.__export = __export; exports.__toESM = __toESM; exports.importMetaUrl = importMetaUrl; exports.init_cjs_shims = init_cjs_shims; exports.toAtFS = toAtFS; exports.resolveImportPath = resolveImportPath; exports.resolveGlobalImportPath = resolveGlobalImportPath; exports.stringifyMarkdownTokens = stringifyMarkdownTokens; exports.generateGoogleFontsUrl = generateGoogleFontsUrl;
|
|
@@ -21,7 +21,6 @@ var __spreadValues = (a, b) => {
|
|
|
21
21
|
return a;
|
|
22
22
|
};
|
|
23
23
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
-
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
25
24
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
26
25
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
27
26
|
}) : x)(function(x) {
|
|
@@ -30,34 +29,31 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
30
29
|
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
31
30
|
});
|
|
32
31
|
var __esm = (fn, res) => function __init() {
|
|
33
|
-
return fn && (res = (0, fn[
|
|
32
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
34
33
|
};
|
|
35
34
|
var __commonJS = (cb, mod) => function __require2() {
|
|
36
|
-
return mod || (0, cb[
|
|
35
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
37
36
|
};
|
|
38
37
|
var __export = (target, all) => {
|
|
39
|
-
__markAsModule(target);
|
|
40
38
|
for (var name in all)
|
|
41
39
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
42
40
|
};
|
|
43
|
-
var
|
|
44
|
-
if (
|
|
45
|
-
for (let key of __getOwnPropNames(
|
|
46
|
-
if (!__hasOwnProp.call(
|
|
47
|
-
__defProp(
|
|
41
|
+
var __copyProps = (to, from, except, desc) => {
|
|
42
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
43
|
+
for (let key of __getOwnPropNames(from))
|
|
44
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
45
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
48
46
|
}
|
|
49
|
-
return
|
|
50
|
-
};
|
|
51
|
-
var __toModule = (module) => {
|
|
52
|
-
return __reExport(__markAsModule(__defProp(module != null ? __create(__getProtoOf(module)) : {}, "default", module && module.__esModule && "default" in module ? { get: () => module.default, enumerable: true } : { value: module, enumerable: true })), module);
|
|
47
|
+
return to;
|
|
53
48
|
};
|
|
49
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
54
50
|
|
|
55
|
-
// ../../node_modules/.pnpm/tsup@5.
|
|
51
|
+
// ../../node_modules/.pnpm/tsup@5.12.5_typescript@4.6.3/node_modules/tsup/assets/esm_shims.js
|
|
56
52
|
import { fileURLToPath } from "url";
|
|
57
53
|
import path from "path";
|
|
58
54
|
var getFilename, getDirname, __dirname, __filename;
|
|
59
55
|
var init_esm_shims = __esm({
|
|
60
|
-
"../../node_modules/.pnpm/tsup@5.
|
|
56
|
+
"../../node_modules/.pnpm/tsup@5.12.5_typescript@4.6.3/node_modules/tsup/assets/esm_shims.js"() {
|
|
61
57
|
getFilename = () => fileURLToPath(import.meta.url);
|
|
62
58
|
getDirname = () => path.dirname(getFilename());
|
|
63
59
|
__dirname = /* @__PURE__ */ getDirname();
|
|
@@ -129,7 +125,7 @@ export {
|
|
|
129
125
|
__require,
|
|
130
126
|
__commonJS,
|
|
131
127
|
__export,
|
|
132
|
-
|
|
128
|
+
__toESM,
|
|
133
129
|
__dirname,
|
|
134
130
|
__filename,
|
|
135
131
|
init_esm_shims,
|
package/dist/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict"; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _chunkHBDQZUZKjs = require('./chunk-HBDQZUZK.js');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
@@ -8,19 +8,19 @@ var _chunk5BL2KALHjs = require('./chunk-5BL2KALH.js');
|
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var _chunk3GNNQ2GUjs = require('./chunk-3GNNQ2GU.js');
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
var
|
|
14
|
+
var _chunk7FQD47HMjs = require('./chunk-7FQD47HM.js');
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var _chunkIXNT7VMKjs = require('./chunk-IXNT7VMK.js');
|
|
20
20
|
|
|
21
21
|
// node/cli.ts
|
|
22
|
-
|
|
23
|
-
var import_fast_deep_equal =
|
|
22
|
+
_chunkIXNT7VMKjs.init_cjs_shims.call(void 0, );
|
|
23
|
+
var import_fast_deep_equal = _chunkIXNT7VMKjs.__toESM.call(void 0, _chunk7FQD47HMjs.require_fast_deep_equal.call(void 0, ));
|
|
24
24
|
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
25
25
|
var _net = require('net'); var _net2 = _interopRequireDefault(_net);
|
|
26
26
|
var _os = require('os'); var _os2 = _interopRequireDefault(_os);
|
|
@@ -38,7 +38,7 @@ var CONFIG_RESTART_FIELDS = [
|
|
|
38
38
|
"routerMode",
|
|
39
39
|
"fonts"
|
|
40
40
|
];
|
|
41
|
-
var cli = _yargs2.default.scriptName("slidev").usage("$0 [args]").version(
|
|
41
|
+
var cli = _yargs2.default.scriptName("slidev").usage("$0 [args]").version(_chunk3GNNQ2GUjs.version).strict().showHelpOnFail(false).alias("h", "help").alias("v", "version");
|
|
42
42
|
cli.command("* [entry]", "Start a local server for Slidev", (args) => commonOptions(args).option("port", {
|
|
43
43
|
alias: "p",
|
|
44
44
|
type: "number",
|
|
@@ -82,9 +82,9 @@ cli.command("* [entry]", "Start a local server for Slidev", (args) => commonOpti
|
|
|
82
82
|
async function initServer() {
|
|
83
83
|
if (server)
|
|
84
84
|
await server.close();
|
|
85
|
-
const options = await
|
|
85
|
+
const options = await _chunk3GNNQ2GUjs.resolveOptions.call(void 0, { entry, theme }, "dev");
|
|
86
86
|
port = userPort || await findFreePort(3030);
|
|
87
|
-
server = await
|
|
87
|
+
server = await _chunkHBDQZUZKjs.createServer.call(void 0, options, {
|
|
88
88
|
server: {
|
|
89
89
|
port,
|
|
90
90
|
strictPort: true,
|
|
@@ -95,7 +95,7 @@ cli.command("* [entry]", "Start a local server for Slidev", (args) => commonOpti
|
|
|
95
95
|
logLevel: log
|
|
96
96
|
}, {
|
|
97
97
|
onDataReload(newData, data) {
|
|
98
|
-
if (!theme &&
|
|
98
|
+
if (!theme && _chunk3GNNQ2GUjs.resolveThemeName.call(void 0, newData.config.theme) !== _chunk3GNNQ2GUjs.resolveThemeName.call(void 0, data.config.theme)) {
|
|
99
99
|
console.log(_kolorist.yellow.call(void 0, "\n restarting on theme change\n"));
|
|
100
100
|
initServer();
|
|
101
101
|
} else if (CONFIG_RESTART_FIELDS.some((i) => !(0, import_fast_deep_equal.default)(newData.config[i], data.config[i]))) {
|
|
@@ -171,8 +171,8 @@ cli.command("build [entry]", "Build hostable SPA", (args) => commonOptions(args)
|
|
|
171
171
|
type: "boolean",
|
|
172
172
|
describe: "allow download as PDF"
|
|
173
173
|
}).strict().help(), async ({ entry, theme, watch, base, download, out }) => {
|
|
174
|
-
const { build } = await Promise.resolve().then(() =>
|
|
175
|
-
const options = await
|
|
174
|
+
const { build } = await Promise.resolve().then(() => _chunkIXNT7VMKjs.__toESM.call(void 0, _chunkIXNT7VMKjs.__require.call(void 0, "./build-MOXNSJPP.js")));
|
|
175
|
+
const options = await _chunk3GNNQ2GUjs.resolveOptions.call(void 0, { entry, theme }, "build");
|
|
176
176
|
if (download && !options.data.config.download)
|
|
177
177
|
options.data.config.download = download;
|
|
178
178
|
printInfo(options);
|
|
@@ -185,26 +185,26 @@ cli.command("build [entry]", "Build hostable SPA", (args) => commonOptions(args)
|
|
|
185
185
|
});
|
|
186
186
|
});
|
|
187
187
|
cli.command("format [entry]", "Format the markdown file", (args) => commonOptions(args).strict().help(), async ({ entry }) => {
|
|
188
|
-
const data = await
|
|
189
|
-
|
|
190
|
-
await
|
|
188
|
+
const data = await _chunk3GNNQ2GUjs.fs_exports.load(entry);
|
|
189
|
+
_chunk3GNNQ2GUjs.fs_exports.prettify(data);
|
|
190
|
+
await _chunk3GNNQ2GUjs.fs_exports.save(data);
|
|
191
191
|
});
|
|
192
192
|
cli.command("theme [subcommand]", "Theme related operations", (command) => {
|
|
193
193
|
return command.command("eject", "Eject current theme into local file system", (args) => commonOptions(args).option("dir", {
|
|
194
194
|
type: "string",
|
|
195
195
|
default: "theme"
|
|
196
196
|
}), async ({ entry, dir, theme: themeInput }) => {
|
|
197
|
-
const data = await
|
|
198
|
-
const theme =
|
|
197
|
+
const data = await _chunk3GNNQ2GUjs.fs_exports.load(entry);
|
|
198
|
+
const theme = _chunk3GNNQ2GUjs.resolveThemeName.call(void 0, themeInput || data.config.theme);
|
|
199
199
|
if (theme === "none") {
|
|
200
200
|
console.error('Can not eject theme "none"');
|
|
201
201
|
process.exit(1);
|
|
202
202
|
}
|
|
203
|
-
if (
|
|
203
|
+
if (_chunk3GNNQ2GUjs.isPath.call(void 0, theme)) {
|
|
204
204
|
console.error("Theme is already ejected");
|
|
205
205
|
process.exit(1);
|
|
206
206
|
}
|
|
207
|
-
const roots =
|
|
207
|
+
const roots = _chunk3GNNQ2GUjs.getThemeRoots.call(void 0, theme, entry);
|
|
208
208
|
if (!roots.length) {
|
|
209
209
|
console.error(`Does not found theme "${theme}"`);
|
|
210
210
|
process.exit(1);
|
|
@@ -216,7 +216,7 @@ cli.command("theme [subcommand]", "Theme related operations", (command) => {
|
|
|
216
216
|
const dirPath = `./${dir}`;
|
|
217
217
|
data.slides[0].frontmatter.theme = dirPath;
|
|
218
218
|
data.slides[0].raw = null;
|
|
219
|
-
await
|
|
219
|
+
await _chunk3GNNQ2GUjs.fs_exports.save(data);
|
|
220
220
|
console.log(`Theme "${theme}" ejected successfully to "${dirPath}"`);
|
|
221
221
|
});
|
|
222
222
|
}, () => {
|
|
@@ -229,12 +229,12 @@ cli.command("export [entry]", "Export slides to PDF", (args) => commonOptions(ar
|
|
|
229
229
|
}).option("format", {
|
|
230
230
|
default: "pdf",
|
|
231
231
|
type: "string",
|
|
232
|
-
choices: ["pdf", "png"],
|
|
232
|
+
choices: ["pdf", "png", "md"],
|
|
233
233
|
describe: "output format"
|
|
234
234
|
}).option("timeout", {
|
|
235
|
-
default:
|
|
235
|
+
default: 3e4,
|
|
236
236
|
type: "number",
|
|
237
|
-
describe: "timeout for rendering
|
|
237
|
+
describe: "timeout for rendering the print page"
|
|
238
238
|
}).option("range", {
|
|
239
239
|
type: "string",
|
|
240
240
|
describe: 'page ranges to export, for example "1,4-5,6"'
|
|
@@ -259,20 +259,21 @@ cli.command("export [entry]", "Export slides to PDF", (args) => commonOptions(ar
|
|
|
259
259
|
}) => {
|
|
260
260
|
output = output || `${_path2.default.basename(entry, ".md")}-export`;
|
|
261
261
|
process.env.NODE_ENV = "production";
|
|
262
|
-
const { exportSlides } = await Promise.resolve().then(() =>
|
|
262
|
+
const { exportSlides } = await Promise.resolve().then(() => _chunkIXNT7VMKjs.__toESM.call(void 0, _chunkIXNT7VMKjs.__require.call(void 0, "./export-X3EA2DO6.js")));
|
|
263
263
|
const port = await findFreePort(12445);
|
|
264
|
-
const options = await
|
|
265
|
-
const server = await
|
|
264
|
+
const options = await _chunk3GNNQ2GUjs.resolveOptions.call(void 0, { entry, theme }, "build");
|
|
265
|
+
const server = await _chunkHBDQZUZKjs.createServer.call(void 0, options, {
|
|
266
266
|
server: { port },
|
|
267
267
|
clearScreen: false
|
|
268
268
|
});
|
|
269
269
|
await server.listen(port);
|
|
270
270
|
printInfo(options);
|
|
271
|
-
|
|
272
|
-
const width =
|
|
271
|
+
_chunk3GNNQ2GUjs.fs_exports.filterDisabled(options.data);
|
|
272
|
+
const width = options.data.config.canvasWidth;
|
|
273
273
|
const height = Math.round(width / options.data.config.aspectRatio);
|
|
274
274
|
output = await exportSlides({
|
|
275
275
|
port,
|
|
276
|
+
slides: options.data.slides,
|
|
276
277
|
total: options.data.slides.length,
|
|
277
278
|
range,
|
|
278
279
|
format,
|
|
@@ -305,7 +306,7 @@ function printInfo(options, port, remote) {
|
|
|
305
306
|
console.log();
|
|
306
307
|
console.log();
|
|
307
308
|
console.log(` ${_kolorist.cyan.call(void 0, "\u25CF") + _kolorist.blue.call(void 0, "\u25A0") + _kolorist.yellow.call(void 0, "\u25B2")}`);
|
|
308
|
-
console.log(`${_kolorist.bold.call(void 0, " Slidev")} ${_kolorist.blue.call(void 0, `v${
|
|
309
|
+
console.log(`${_kolorist.bold.call(void 0, " Slidev")} ${_kolorist.blue.call(void 0, `v${_chunk3GNNQ2GUjs.version}`)} ${_isinstalledglobally2.default ? _kolorist.yellow.call(void 0, "(global)") : ""}`);
|
|
309
310
|
console.log();
|
|
310
311
|
console.log(_kolorist.dim.call(void 0, " theme ") + (options.theme ? _kolorist.green.call(void 0, options.theme) : _kolorist.gray.call(void 0, "none")));
|
|
311
312
|
console.log(_kolorist.dim.call(void 0, " entry ") + _kolorist.dim.call(void 0, _path2.default.dirname(options.entry) + _path2.default.sep) + _path2.default.basename(options.entry));
|
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createServer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-46RYGQQC.mjs";
|
|
4
4
|
import {
|
|
5
5
|
fs_exports,
|
|
6
6
|
getThemeRoots,
|
|
@@ -8,20 +8,20 @@ import {
|
|
|
8
8
|
resolveOptions,
|
|
9
9
|
resolveThemeName,
|
|
10
10
|
version
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-HJCTB5CG.mjs";
|
|
12
12
|
import {
|
|
13
13
|
require_fast_deep_equal
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-4AVLCCHB.mjs";
|
|
15
15
|
import {
|
|
16
16
|
__dirname,
|
|
17
17
|
__require,
|
|
18
|
-
|
|
18
|
+
__toESM,
|
|
19
19
|
init_esm_shims
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-XMETW2MS.mjs";
|
|
21
21
|
|
|
22
22
|
// node/cli.ts
|
|
23
23
|
init_esm_shims();
|
|
24
|
-
var import_fast_deep_equal =
|
|
24
|
+
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
|
25
25
|
import path from "path";
|
|
26
26
|
import net from "net";
|
|
27
27
|
import os from "os";
|
|
@@ -172,7 +172,7 @@ cli.command("build [entry]", "Build hostable SPA", (args) => commonOptions(args)
|
|
|
172
172
|
type: "boolean",
|
|
173
173
|
describe: "allow download as PDF"
|
|
174
174
|
}).strict().help(), async ({ entry, theme, watch, base, download, out }) => {
|
|
175
|
-
const { build } = await Promise.resolve().then(() =>
|
|
175
|
+
const { build } = await Promise.resolve().then(() => __toESM(__require("./build-SSLWFRFJ.mjs")));
|
|
176
176
|
const options = await resolveOptions({ entry, theme }, "build");
|
|
177
177
|
if (download && !options.data.config.download)
|
|
178
178
|
options.data.config.download = download;
|
|
@@ -230,12 +230,12 @@ cli.command("export [entry]", "Export slides to PDF", (args) => commonOptions(ar
|
|
|
230
230
|
}).option("format", {
|
|
231
231
|
default: "pdf",
|
|
232
232
|
type: "string",
|
|
233
|
-
choices: ["pdf", "png"],
|
|
233
|
+
choices: ["pdf", "png", "md"],
|
|
234
234
|
describe: "output format"
|
|
235
235
|
}).option("timeout", {
|
|
236
|
-
default:
|
|
236
|
+
default: 3e4,
|
|
237
237
|
type: "number",
|
|
238
|
-
describe: "timeout for rendering
|
|
238
|
+
describe: "timeout for rendering the print page"
|
|
239
239
|
}).option("range", {
|
|
240
240
|
type: "string",
|
|
241
241
|
describe: 'page ranges to export, for example "1,4-5,6"'
|
|
@@ -260,7 +260,7 @@ cli.command("export [entry]", "Export slides to PDF", (args) => commonOptions(ar
|
|
|
260
260
|
}) => {
|
|
261
261
|
output = output || `${path.basename(entry, ".md")}-export`;
|
|
262
262
|
process.env.NODE_ENV = "production";
|
|
263
|
-
const { exportSlides } = await Promise.resolve().then(() =>
|
|
263
|
+
const { exportSlides } = await Promise.resolve().then(() => __toESM(__require("./export-2FIFRI4R.mjs")));
|
|
264
264
|
const port = await findFreePort(12445);
|
|
265
265
|
const options = await resolveOptions({ entry, theme }, "build");
|
|
266
266
|
const server = await createServer(options, {
|
|
@@ -270,10 +270,11 @@ cli.command("export [entry]", "Export slides to PDF", (args) => commonOptions(ar
|
|
|
270
270
|
await server.listen(port);
|
|
271
271
|
printInfo(options);
|
|
272
272
|
fs_exports.filterDisabled(options.data);
|
|
273
|
-
const width =
|
|
273
|
+
const width = options.data.config.canvasWidth;
|
|
274
274
|
const height = Math.round(width / options.data.config.aspectRatio);
|
|
275
275
|
output = await exportSlides({
|
|
276
276
|
port,
|
|
277
|
+
slides: options.data.slides,
|
|
277
278
|
total: options.data.slides.length,
|
|
278
279
|
range,
|
|
279
280
|
format,
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
packageExists
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HJCTB5CG.mjs";
|
|
4
4
|
import {
|
|
5
5
|
__require,
|
|
6
|
-
|
|
6
|
+
__toESM,
|
|
7
7
|
init_esm_shims
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-XMETW2MS.mjs";
|
|
9
9
|
|
|
10
10
|
// node/export.ts
|
|
11
11
|
init_esm_shims();
|
|
12
12
|
import path from "path";
|
|
13
13
|
import fs from "fs-extra";
|
|
14
|
-
import {
|
|
15
|
-
import { blue, cyan, green, yellow } from "kolorist";
|
|
14
|
+
import { blue, cyan, dim, green, yellow } from "kolorist";
|
|
16
15
|
import { Presets, SingleBar } from "cli-progress";
|
|
17
16
|
import { parseRangeString } from "@slidev/parser/core";
|
|
18
|
-
function createSlidevProgress() {
|
|
17
|
+
function createSlidevProgress(indeterminate = false) {
|
|
19
18
|
function getSpinner(n = 0) {
|
|
20
19
|
return [cyan("\u25CF"), green("\u25C6"), blue("\u25A0"), yellow("\u25B2")][n % 4];
|
|
21
20
|
}
|
|
@@ -25,7 +24,7 @@ function createSlidevProgress() {
|
|
|
25
24
|
const progress = new SingleBar({
|
|
26
25
|
clearOnComplete: true,
|
|
27
26
|
hideCursor: true,
|
|
28
|
-
format: ` {spin} ${yellow("rendering")} {bar} {value}/{total}`,
|
|
27
|
+
format: ` {spin} ${yellow("rendering")}${indeterminate ? dim(yellow("...")) : " {bar} {value}/{total}"}`,
|
|
29
28
|
linewrap: false,
|
|
30
29
|
barsize: 30
|
|
31
30
|
}, Presets.shades_grey);
|
|
@@ -54,8 +53,9 @@ async function exportSlides({
|
|
|
54
53
|
range,
|
|
55
54
|
format = "pdf",
|
|
56
55
|
output = "slides",
|
|
56
|
+
slides,
|
|
57
57
|
base = "/",
|
|
58
|
-
timeout =
|
|
58
|
+
timeout = 3e4,
|
|
59
59
|
dark = false,
|
|
60
60
|
routerMode = "history",
|
|
61
61
|
width = 1920,
|
|
@@ -64,86 +64,91 @@ async function exportSlides({
|
|
|
64
64
|
}) {
|
|
65
65
|
if (!packageExists("playwright-chromium"))
|
|
66
66
|
throw new Error("The exporting for Slidev is powered by Playwright, please installed it via `npm i -D playwright-chromium`");
|
|
67
|
-
const
|
|
67
|
+
const pages = parseRangeString(total, range);
|
|
68
|
+
const { chromium } = await Promise.resolve().then(() => __toESM(__require("playwright-chromium")));
|
|
68
69
|
const browser = await chromium.launch();
|
|
69
70
|
const context = await browser.newContext({
|
|
70
71
|
viewport: {
|
|
71
72
|
width,
|
|
72
|
-
height
|
|
73
|
+
height: height * pages.length
|
|
73
74
|
},
|
|
74
75
|
deviceScaleFactor: 1
|
|
75
76
|
});
|
|
76
77
|
const page = await context.newPage();
|
|
77
|
-
const progress = createSlidevProgress();
|
|
78
|
+
const progress = createSlidevProgress(true);
|
|
78
79
|
async function go(no, clicks) {
|
|
79
|
-
progress.update(no);
|
|
80
80
|
const path2 = `${no}?print${withClicks ? "=clicks" : ""}${clicks ? `&clicks=${clicks}` : ""}`;
|
|
81
81
|
const url = routerMode === "hash" ? `http://localhost:${port}${base}#${path2}` : `http://localhost:${port}${base}${path2}`;
|
|
82
82
|
await page.goto(url, {
|
|
83
|
-
waitUntil: "networkidle"
|
|
83
|
+
waitUntil: "networkidle",
|
|
84
|
+
timeout
|
|
84
85
|
});
|
|
85
|
-
await page.waitForTimeout(timeout);
|
|
86
86
|
await page.waitForLoadState("networkidle");
|
|
87
87
|
await page.emulateMedia({ colorScheme: dark ? "dark" : "light", media: "screen" });
|
|
88
|
+
const elements = await page.locator("[data-waitfor]");
|
|
89
|
+
const count = await elements.count();
|
|
90
|
+
for (let index = 0; index < count; index++) {
|
|
91
|
+
const element = await elements.nth(index);
|
|
92
|
+
const attribute = await element.getAttribute("data-waitfor");
|
|
93
|
+
if (attribute)
|
|
94
|
+
await element.locator(attribute).waitFor();
|
|
95
|
+
}
|
|
96
|
+
const frames = await page.frames();
|
|
97
|
+
await Promise.all(frames.map((frame) => frame.waitForLoadState()));
|
|
88
98
|
}
|
|
89
|
-
function
|
|
90
|
-
|
|
91
|
-
|
|
99
|
+
async function genPagePdf() {
|
|
100
|
+
if (!output.endsWith(".pdf"))
|
|
101
|
+
output = `${output}.pdf`;
|
|
102
|
+
await go("print");
|
|
103
|
+
await page.pdf({
|
|
104
|
+
path: output,
|
|
105
|
+
width,
|
|
106
|
+
height,
|
|
107
|
+
margin: {
|
|
108
|
+
left: 0,
|
|
109
|
+
top: 0,
|
|
110
|
+
right: 0,
|
|
111
|
+
bottom: 0
|
|
112
|
+
},
|
|
113
|
+
printBackground: true,
|
|
114
|
+
preferCSSPageSize: true
|
|
115
|
+
});
|
|
92
116
|
}
|
|
93
|
-
async function
|
|
94
|
-
await
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
117
|
+
async function genPagePng() {
|
|
118
|
+
await go("print");
|
|
119
|
+
const slides2 = await page.locator(".slide-container");
|
|
120
|
+
const count = await slides2.count();
|
|
121
|
+
for (let i = 0; i < count; i++) {
|
|
122
|
+
progress.update(i + 1);
|
|
123
|
+
const buffer = await slides2.nth(i).screenshot();
|
|
124
|
+
await fs.ensureDir(output);
|
|
125
|
+
await fs.writeFile(path.join(output, `${(i + 1).toString().padStart(2, "0")}.png`), buffer);
|
|
100
126
|
}
|
|
101
127
|
}
|
|
102
|
-
|
|
128
|
+
async function genPageMd(pages2, slides2) {
|
|
129
|
+
var _a, _b, _c;
|
|
130
|
+
const mds = [];
|
|
131
|
+
for (const i of pages2) {
|
|
132
|
+
const mdImg = `![${(_a = slides2[i - 1]) == null ? void 0 : _a.title}](./${output}/${i.toString().padStart(2, "0")}.png)
|
|
133
|
+
|
|
134
|
+
`;
|
|
135
|
+
const mdNote = ((_b = slides2[i - 1]) == null ? void 0 : _b.note) ? `${(_c = slides2[i - 1]) == null ? void 0 : _c.note}
|
|
136
|
+
|
|
137
|
+
` : "";
|
|
138
|
+
mds.push(`${mdImg}${mdNote}`);
|
|
139
|
+
}
|
|
140
|
+
if (!output.endsWith(".md"))
|
|
141
|
+
output = `${output}.md`;
|
|
142
|
+
await fs.writeFile(output, mds.join(""));
|
|
143
|
+
}
|
|
103
144
|
progress.start(pages.length);
|
|
104
145
|
if (format === "pdf") {
|
|
105
|
-
|
|
106
|
-
const genPdfBuffer = async (i, clicks) => {
|
|
107
|
-
await go(i, clicks);
|
|
108
|
-
const pdf = await page.pdf({
|
|
109
|
-
width,
|
|
110
|
-
height,
|
|
111
|
-
margin: {
|
|
112
|
-
left: 0,
|
|
113
|
-
top: 0,
|
|
114
|
-
right: 0,
|
|
115
|
-
bottom: 0
|
|
116
|
-
},
|
|
117
|
-
pageRanges: "1",
|
|
118
|
-
printBackground: true,
|
|
119
|
-
preferCSSPageSize: true
|
|
120
|
-
});
|
|
121
|
-
buffers.push(pdf);
|
|
122
|
-
};
|
|
123
|
-
for (const i of pages)
|
|
124
|
-
await genPageWithClicks(genPdfBuffer, i);
|
|
125
|
-
const mergedPdf = await PDFDocument.create({});
|
|
126
|
-
for (const pdfBytes of buffers) {
|
|
127
|
-
const pdf = await PDFDocument.load(pdfBytes);
|
|
128
|
-
const copiedPages = await mergedPdf.copyPages(pdf, pdf.getPageIndices());
|
|
129
|
-
copiedPages.forEach((page2) => {
|
|
130
|
-
mergedPdf.addPage(page2);
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
const buffer = await mergedPdf.save();
|
|
134
|
-
if (!output.endsWith(".pdf"))
|
|
135
|
-
output = `${output}.pdf`;
|
|
136
|
-
await fs.writeFile(output, buffer);
|
|
146
|
+
await genPagePdf();
|
|
137
147
|
} else if (format === "png") {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
path: path.join(output, `${i.toString().padStart(2, "0")}${clicks ? `-${clicks}` : ""}.png`)
|
|
143
|
-
});
|
|
144
|
-
};
|
|
145
|
-
for (const i of pages)
|
|
146
|
-
await genPageWithClicks(genScreenshot, i);
|
|
148
|
+
await genPagePng();
|
|
149
|
+
} else if (format === "md") {
|
|
150
|
+
await genPagePng();
|
|
151
|
+
await genPageMd(pages, slides);
|
|
147
152
|
} else {
|
|
148
153
|
throw new Error(`Unsupported exporting format "${format}"`);
|
|
149
154
|
}
|