@slidev/cli 0.31.2 → 0.32.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.
@@ -46,10 +46,6 @@ var __esm = (fn, res) => function __init() {
46
46
  var __commonJS = (cb, mod) => function __require2() {
47
47
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
48
48
  };
49
- var __export = (target, all) => {
50
- for (var name in all)
51
- __defProp(target, name, { get: all[name], enumerable: true });
52
- };
53
49
  var __copyProps = (to, from, except, desc) => {
54
50
  if (from && typeof from === "object" || typeof from === "function") {
55
51
  for (let key of __getOwnPropNames(from))
@@ -151,6 +147,11 @@ function generateGoogleFontsUrl(options) {
151
147
  const fonts = options.webfonts.map((i) => `family=${i.replace(/^(['"])(.*)\1$/, "$1").replace(/\s+/g, "+")}:${options.italic ? "ital," : ""}wght@${weights}`).join("&");
152
148
  return `https://fonts.googleapis.com/css2?${fonts}&display=swap`;
153
149
  }
150
+ function packageExists(name) {
151
+ if (resolveImportPath(`${name}/package.json`))
152
+ return true;
153
+ return false;
154
+ }
154
155
 
155
156
 
156
157
 
@@ -170,4 +171,4 @@ function generateGoogleFontsUrl(options) {
170
171
 
171
172
 
172
173
 
173
- exports.__spreadValues = __spreadValues; exports.__spreadProps = __spreadProps; exports.__require = __require; exports.__objRest = __objRest; exports.__commonJS = __commonJS; exports.__export = __export; exports.__toESM = __toESM; exports.__privateGet = __privateGet; exports.__privateAdd = __privateAdd; exports.__privateSet = __privateSet; exports.__privateWrapper = __privateWrapper; exports.init_cjs_shims = init_cjs_shims; exports.toAtFS = toAtFS; exports.resolveImportPath = resolveImportPath; exports.resolveGlobalImportPath = resolveGlobalImportPath; exports.stringifyMarkdownTokens = stringifyMarkdownTokens; exports.generateGoogleFontsUrl = generateGoogleFontsUrl;
174
+ exports.__spreadValues = __spreadValues; exports.__spreadProps = __spreadProps; exports.__require = __require; exports.__objRest = __objRest; exports.__commonJS = __commonJS; exports.__toESM = __toESM; exports.__privateGet = __privateGet; exports.__privateAdd = __privateAdd; exports.__privateSet = __privateSet; exports.__privateWrapper = __privateWrapper; exports.init_cjs_shims = init_cjs_shims; exports.toAtFS = toAtFS; exports.resolveImportPath = resolveImportPath; exports.resolveGlobalImportPath = resolveGlobalImportPath; exports.stringifyMarkdownTokens = stringifyMarkdownTokens; exports.generateGoogleFontsUrl = generateGoogleFontsUrl; exports.packageExists = packageExists;
@@ -46,10 +46,6 @@ var __esm = (fn, res) => function __init() {
46
46
  var __commonJS = (cb, mod) => function __require2() {
47
47
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
48
48
  };
49
- var __export = (target, all) => {
50
- for (var name in all)
51
- __defProp(target, name, { get: all[name], enumerable: true });
52
- };
53
49
  var __copyProps = (to, from, except, desc) => {
54
50
  if (from && typeof from === "object" || typeof from === "function") {
55
51
  for (let key of __getOwnPropNames(from))
@@ -158,6 +154,11 @@ function generateGoogleFontsUrl(options) {
158
154
  const fonts = options.webfonts.map((i) => `family=${i.replace(/^(['"])(.*)\1$/, "$1").replace(/\s+/g, "+")}:${options.italic ? "ital," : ""}wght@${weights}`).join("&");
159
155
  return `https://fonts.googleapis.com/css2?${fonts}&display=swap`;
160
156
  }
157
+ function packageExists(name) {
158
+ if (resolveImportPath(`${name}/package.json`))
159
+ return true;
160
+ return false;
161
+ }
161
162
 
162
163
  export {
163
164
  __spreadValues,
@@ -165,7 +166,6 @@ export {
165
166
  __require,
166
167
  __objRest,
167
168
  __commonJS,
168
- __export,
169
169
  __toESM,
170
170
  __privateGet,
171
171
  __privateAdd,
@@ -178,5 +178,6 @@ export {
178
178
  resolveImportPath,
179
179
  resolveGlobalImportPath,
180
180
  stringifyMarkdownTokens,
181
- generateGoogleFontsUrl
181
+ generateGoogleFontsUrl,
182
+ packageExists
182
183
  };
package/dist/cli.js CHANGED
@@ -1,26 +1,24 @@
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 _chunkUGIPPIZXjs = require('./chunk-UGIPPIZX.js');
4
3
 
5
4
 
6
5
 
7
6
 
8
7
 
9
8
 
9
+ var _chunkALT27UGEjs = require('./chunk-ALT27UGE.js');
10
10
 
11
- var _chunkZN6VJBWPjs = require('./chunk-ZN6VJBWP.js');
12
11
 
12
+ var _chunk64ARPHPAjs = require('./chunk-64ARPHPA.js');
13
13
 
14
- var _chunkN6ENRMDMjs = require('./chunk-N6ENRMDM.js');
15
14
 
16
15
 
17
16
 
18
-
19
- var _chunkOVW2G2MHjs = require('./chunk-OVW2G2MH.js');
17
+ var _chunkJWGORJY6js = require('./chunk-JWGORJY6.js');
20
18
 
21
19
  // node/cli.ts
22
- _chunkOVW2G2MHjs.init_cjs_shims.call(void 0, );
23
- var import_fast_deep_equal = _chunkOVW2G2MHjs.__toESM.call(void 0, _chunkN6ENRMDMjs.require_fast_deep_equal.call(void 0, ));
20
+ _chunkJWGORJY6js.init_cjs_shims.call(void 0, );
21
+ var import_fast_deep_equal = _chunkJWGORJY6js.__toESM.call(void 0, _chunk64ARPHPAjs.require_fast_deep_equal.call(void 0, ));
24
22
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
25
23
  var _net = require('net'); var _net2 = _interopRequireDefault(_net);
26
24
  var _os = require('os'); var _os2 = _interopRequireDefault(_os);
@@ -38,7 +36,7 @@ var CONFIG_RESTART_FIELDS = [
38
36
  "routerMode",
39
37
  "fonts"
40
38
  ];
41
- var cli = _yargs2.default.scriptName("slidev").usage("$0 [args]").version(_chunkZN6VJBWPjs.version).strict().showHelpOnFail(false).alias("h", "help").alias("v", "version");
39
+ var cli = _yargs2.default.scriptName("slidev").usage("$0 [args]").version(_chunkALT27UGEjs.version).strict().showHelpOnFail(false).alias("h", "help").alias("v", "version");
42
40
  cli.command("* [entry]", "Start a local server for Slidev", (args) => commonOptions(args).option("port", {
43
41
  alias: "p",
44
42
  type: "number",
@@ -49,8 +47,7 @@ cli.command("* [entry]", "Start a local server for Slidev", (args) => commonOpti
49
47
  type: "boolean",
50
48
  describe: "open in browser"
51
49
  }).option("remote", {
52
- default: false,
53
- type: "boolean",
50
+ type: "string",
54
51
  describe: "listen public host and enable remote control"
55
52
  }).option("log", {
56
53
  default: "warn",
@@ -82,20 +79,20 @@ cli.command("* [entry]", "Start a local server for Slidev", (args) => commonOpti
82
79
  async function initServer() {
83
80
  if (server)
84
81
  await server.close();
85
- const options = await _chunkZN6VJBWPjs.resolveOptions.call(void 0, { entry, theme }, "dev");
82
+ const options = await _chunkALT27UGEjs.resolveOptions.call(void 0, { entry, remote, theme }, "dev");
86
83
  port = userPort || await findFreePort(3030);
87
- server = await _chunkUGIPPIZXjs.createServer.call(void 0, options, {
84
+ server = await _chunkALT27UGEjs.createServer.call(void 0, options, {
88
85
  server: {
89
86
  port,
90
87
  strictPort: true,
91
88
  open,
92
- host: remote ? "0.0.0.0" : "localhost",
89
+ host: remote !== void 0 ? "0.0.0.0" : "localhost",
93
90
  force
94
91
  },
95
92
  logLevel: log
96
93
  }, {
97
94
  onDataReload(newData, data) {
98
- if (!theme && _chunkZN6VJBWPjs.resolveThemeName.call(void 0, newData.config.theme) !== _chunkZN6VJBWPjs.resolveThemeName.call(void 0, data.config.theme)) {
95
+ if (!theme && _chunkALT27UGEjs.resolveThemeName.call(void 0, newData.config.theme) !== _chunkALT27UGEjs.resolveThemeName.call(void 0, data.config.theme)) {
99
96
  console.log(_kolorist.yellow.call(void 0, "\n restarting on theme change\n"));
100
97
  initServer();
101
98
  } else if (CONFIG_RESTART_FIELDS.some((i) => !(0, import_fast_deep_equal.default)(newData.config[i], data.config[i]))) {
@@ -171,8 +168,8 @@ cli.command("build [entry]", "Build hostable SPA", (args) => commonOptions(args)
171
168
  type: "boolean",
172
169
  describe: "allow download as PDF"
173
170
  }).strict().help(), async ({ entry, theme, watch, base, download, out }) => {
174
- const { build } = await Promise.resolve().then(() => _chunkOVW2G2MHjs.__toESM.call(void 0, _chunkOVW2G2MHjs.__require.call(void 0, "./build-DHS7EAI7.js")));
175
- const options = await _chunkZN6VJBWPjs.resolveOptions.call(void 0, { entry, theme }, "build");
171
+ const { build } = await Promise.resolve().then(() => _chunkJWGORJY6js.__toESM.call(void 0, _chunkJWGORJY6js.__require.call(void 0, "./build-OV5R3MX7.js")));
172
+ const options = await _chunkALT27UGEjs.resolveOptions.call(void 0, { entry, theme }, "build");
176
173
  if (download && !options.data.config.download)
177
174
  options.data.config.download = download;
178
175
  printInfo(options);
@@ -185,26 +182,26 @@ cli.command("build [entry]", "Build hostable SPA", (args) => commonOptions(args)
185
182
  });
186
183
  });
187
184
  cli.command("format [entry]", "Format the markdown file", (args) => commonOptions(args).strict().help(), async ({ entry }) => {
188
- const data = await _chunkZN6VJBWPjs.fs_exports.load(entry);
189
- _chunkZN6VJBWPjs.fs_exports.prettify(data);
190
- await _chunkZN6VJBWPjs.fs_exports.save(data);
185
+ const data = await _chunkALT27UGEjs.parser.load(entry);
186
+ _chunkALT27UGEjs.parser.prettify(data);
187
+ await _chunkALT27UGEjs.parser.save(data);
191
188
  });
192
189
  cli.command("theme [subcommand]", "Theme related operations", (command) => {
193
190
  return command.command("eject", "Eject current theme into local file system", (args) => commonOptions(args).option("dir", {
194
191
  type: "string",
195
192
  default: "theme"
196
193
  }), async ({ entry, dir, theme: themeInput }) => {
197
- const data = await _chunkZN6VJBWPjs.fs_exports.load(entry);
198
- const theme = _chunkZN6VJBWPjs.resolveThemeName.call(void 0, themeInput || data.config.theme);
194
+ const data = await _chunkALT27UGEjs.parser.load(entry);
195
+ const theme = _chunkALT27UGEjs.resolveThemeName.call(void 0, themeInput || data.config.theme);
199
196
  if (theme === "none") {
200
197
  console.error('Can not eject theme "none"');
201
198
  process.exit(1);
202
199
  }
203
- if (_chunkZN6VJBWPjs.isPath.call(void 0, theme)) {
200
+ if (_chunkALT27UGEjs.isPath.call(void 0, theme)) {
204
201
  console.error("Theme is already ejected");
205
202
  process.exit(1);
206
203
  }
207
- const roots = _chunkZN6VJBWPjs.getThemeRoots.call(void 0, theme, entry);
204
+ const roots = _chunkALT27UGEjs.getThemeRoots.call(void 0, theme, entry);
208
205
  if (!roots.length) {
209
206
  console.error(`Does not found theme "${theme}"`);
210
207
  process.exit(1);
@@ -216,7 +213,7 @@ cli.command("theme [subcommand]", "Theme related operations", (command) => {
216
213
  const dirPath = `./${dir}`;
217
214
  data.slides[0].frontmatter.theme = dirPath;
218
215
  data.slides[0].raw = null;
219
- await _chunkZN6VJBWPjs.fs_exports.save(data);
216
+ await _chunkALT27UGEjs.parser.save(data);
220
217
  console.log(`Theme "${theme}" ejected successfully to "${dirPath}"`);
221
218
  });
222
219
  }, () => {
@@ -225,7 +222,7 @@ cli.command("theme [subcommand]", "Theme related operations", (command) => {
225
222
  });
226
223
  cli.command("export [entry]", "Export slides to PDF", (args) => commonOptions(args).option("output", {
227
224
  type: "string",
228
- describe: "path to the the port output"
225
+ describe: "path to the output"
229
226
  }).option("format", {
230
227
  default: "pdf",
231
228
  type: "string",
@@ -258,17 +255,17 @@ cli.command("export [entry]", "Export slides to PDF", (args) => commonOptions(ar
258
255
  "with-clicks": withClicks
259
256
  }) => {
260
257
  process.env.NODE_ENV = "production";
261
- const { exportSlides } = await Promise.resolve().then(() => _chunkOVW2G2MHjs.__toESM.call(void 0, _chunkOVW2G2MHjs.__require.call(void 0, "./export-JHHUB6BA.js")));
258
+ const { exportSlides } = await Promise.resolve().then(() => _chunkJWGORJY6js.__toESM.call(void 0, _chunkJWGORJY6js.__require.call(void 0, "./export-M6HJUIFY.js")));
262
259
  const port = await findFreePort(12445);
263
- const options = await _chunkZN6VJBWPjs.resolveOptions.call(void 0, { entry, theme }, "build");
260
+ const options = await _chunkALT27UGEjs.resolveOptions.call(void 0, { entry, theme }, "build");
264
261
  output = output || options.data.config.exportFilename || `${_path2.default.basename(entry, ".md")}-export`;
265
- const server = await _chunkUGIPPIZXjs.createServer.call(void 0, options, {
262
+ const server = await _chunkALT27UGEjs.createServer.call(void 0, options, {
266
263
  server: { port },
267
264
  clearScreen: false
268
265
  });
269
266
  await server.listen(port);
270
267
  printInfo(options);
271
- _chunkZN6VJBWPjs.fs_exports.filterDisabled(options.data);
268
+ _chunkALT27UGEjs.parser.filterDisabled(options.data);
272
269
  const width = options.data.config.canvasWidth;
273
270
  const height = Math.round(width / options.data.config.aspectRatio);
274
271
  output = await exportSlides({
@@ -306,24 +303,27 @@ function printInfo(options, port, remote) {
306
303
  console.log();
307
304
  console.log();
308
305
  console.log(` ${_kolorist.cyan.call(void 0, "\u25CF") + _kolorist.blue.call(void 0, "\u25A0") + _kolorist.yellow.call(void 0, "\u25B2")}`);
309
- console.log(`${_kolorist.bold.call(void 0, " Slidev")} ${_kolorist.blue.call(void 0, `v${_chunkZN6VJBWPjs.version}`)} ${_isinstalledglobally2.default ? _kolorist.yellow.call(void 0, "(global)") : ""}`);
306
+ console.log(`${_kolorist.bold.call(void 0, " Slidev")} ${_kolorist.blue.call(void 0, `v${_chunkALT27UGEjs.version}`)} ${_isinstalledglobally2.default ? _kolorist.yellow.call(void 0, "(global)") : ""}`);
310
307
  console.log();
311
308
  console.log(_kolorist.dim.call(void 0, " theme ") + (options.theme ? _kolorist.green.call(void 0, options.theme) : _kolorist.gray.call(void 0, "none")));
312
309
  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));
313
310
  if (port) {
314
- const presenterPath = `${options.data.config.routerMode === "hash" ? "/#/" : "/"}presenter`;
311
+ const query = remote ? `?password=${remote}` : "";
312
+ const presenterPath = `${options.data.config.routerMode === "hash" ? "/#/" : "/"}presenter/${query}`;
315
313
  console.log();
316
- console.log(`${_kolorist.dim.call(void 0, " slide show ")} > ${_kolorist.cyan.call(void 0, `http://localhost:${_kolorist.bold.call(void 0, port)}/`)}`);
317
- console.log(`${_kolorist.dim.call(void 0, " presenter mode ")} > ${_kolorist.blue.call(void 0, `http://localhost:${_kolorist.bold.call(void 0, port)}${presenterPath}`)}`);
318
- if (remote) {
314
+ console.log(`${_kolorist.dim.call(void 0, " public slide show ")} > ${_kolorist.cyan.call(void 0, `http://localhost:${_kolorist.bold.call(void 0, port)}/`)}`);
315
+ if (query)
316
+ console.log(`${_kolorist.dim.call(void 0, " private slide show ")} > ${_kolorist.cyan.call(void 0, `http://localhost:${_kolorist.bold.call(void 0, port)}/${query}`)}`);
317
+ console.log(`${_kolorist.dim.call(void 0, " presenter mode ")} > ${_kolorist.blue.call(void 0, `http://localhost:${_kolorist.bold.call(void 0, port)}${presenterPath}`)}`);
318
+ if (remote !== void 0) {
319
319
  Object.values(_os2.default.networkInterfaces()).forEach((v) => (v || []).filter((details) => details.family === "IPv4" && !details.address.includes("127.0.0.1")).forEach(({ address }) => {
320
- console.log(`${_kolorist.dim.call(void 0, " remote control ")} > ${_kolorist.blue.call(void 0, `http://${address}:${port}${presenterPath}`)}`);
320
+ console.log(`${_kolorist.dim.call(void 0, " remote control ")} > ${_kolorist.blue.call(void 0, `http://${address}:${port}${presenterPath}`)}`);
321
321
  }));
322
322
  } else {
323
- console.log(`${_kolorist.dim.call(void 0, " remote control ")} > ${_kolorist.dim.call(void 0, "pass --remote to enable")}`);
323
+ console.log(`${_kolorist.dim.call(void 0, " remote control ")} > ${_kolorist.dim.call(void 0, "pass --remote to enable")}`);
324
324
  }
325
325
  console.log();
326
- console.log(`${_kolorist.dim.call(void 0, " shortcuts ")} > ${_kolorist.underline.call(void 0, "r")}${_kolorist.dim.call(void 0, "estart | ")}${_kolorist.underline.call(void 0, "o")}${_kolorist.dim.call(void 0, "pen | ")}${_kolorist.underline.call(void 0, "e")}${_kolorist.dim.call(void 0, "dit")}`);
326
+ console.log(`${_kolorist.dim.call(void 0, " shortcuts ")} > ${_kolorist.underline.call(void 0, "r")}${_kolorist.dim.call(void 0, "estart | ")}${_kolorist.underline.call(void 0, "o")}${_kolorist.dim.call(void 0, "pen | ")}${_kolorist.underline.call(void 0, "e")}${_kolorist.dim.call(void 0, "dit")}`);
327
327
  }
328
328
  console.log();
329
329
  console.log();
package/dist/cli.mjs CHANGED
@@ -1,23 +1,21 @@
1
1
  import {
2
- createServer
3
- } from "./chunk-MRYU4L7C.mjs";
4
- import {
5
- fs_exports,
2
+ createServer,
6
3
  getThemeRoots,
7
4
  isPath,
5
+ parser,
8
6
  resolveOptions,
9
7
  resolveThemeName,
10
8
  version
11
- } from "./chunk-U4YYUHKV.mjs";
9
+ } from "./chunk-36AQIIEM.mjs";
12
10
  import {
13
11
  require_fast_deep_equal
14
- } from "./chunk-55JD2XFU.mjs";
12
+ } from "./chunk-2OKC6HYP.mjs";
15
13
  import {
16
14
  __dirname,
17
15
  __require,
18
16
  __toESM,
19
17
  init_esm_shims
20
- } from "./chunk-D6ZT4BYV.mjs";
18
+ } from "./chunk-NOFZO6W4.mjs";
21
19
 
22
20
  // node/cli.ts
23
21
  init_esm_shims();
@@ -50,8 +48,7 @@ cli.command("* [entry]", "Start a local server for Slidev", (args) => commonOpti
50
48
  type: "boolean",
51
49
  describe: "open in browser"
52
50
  }).option("remote", {
53
- default: false,
54
- type: "boolean",
51
+ type: "string",
55
52
  describe: "listen public host and enable remote control"
56
53
  }).option("log", {
57
54
  default: "warn",
@@ -83,14 +80,14 @@ cli.command("* [entry]", "Start a local server for Slidev", (args) => commonOpti
83
80
  async function initServer() {
84
81
  if (server)
85
82
  await server.close();
86
- const options = await resolveOptions({ entry, theme }, "dev");
83
+ const options = await resolveOptions({ entry, remote, theme }, "dev");
87
84
  port = userPort || await findFreePort(3030);
88
85
  server = await createServer(options, {
89
86
  server: {
90
87
  port,
91
88
  strictPort: true,
92
89
  open,
93
- host: remote ? "0.0.0.0" : "localhost",
90
+ host: remote !== void 0 ? "0.0.0.0" : "localhost",
94
91
  force
95
92
  },
96
93
  logLevel: log
@@ -172,7 +169,7 @@ cli.command("build [entry]", "Build hostable SPA", (args) => commonOptions(args)
172
169
  type: "boolean",
173
170
  describe: "allow download as PDF"
174
171
  }).strict().help(), async ({ entry, theme, watch, base, download, out }) => {
175
- const { build } = await Promise.resolve().then(() => __toESM(__require("./build-HKOWIJTJ.mjs")));
172
+ const { build } = await Promise.resolve().then(() => __toESM(__require("./build-RKDPZPJ4.mjs")));
176
173
  const options = await resolveOptions({ entry, theme }, "build");
177
174
  if (download && !options.data.config.download)
178
175
  options.data.config.download = download;
@@ -186,16 +183,16 @@ cli.command("build [entry]", "Build hostable SPA", (args) => commonOptions(args)
186
183
  });
187
184
  });
188
185
  cli.command("format [entry]", "Format the markdown file", (args) => commonOptions(args).strict().help(), async ({ entry }) => {
189
- const data = await fs_exports.load(entry);
190
- fs_exports.prettify(data);
191
- await fs_exports.save(data);
186
+ const data = await parser.load(entry);
187
+ parser.prettify(data);
188
+ await parser.save(data);
192
189
  });
193
190
  cli.command("theme [subcommand]", "Theme related operations", (command) => {
194
191
  return command.command("eject", "Eject current theme into local file system", (args) => commonOptions(args).option("dir", {
195
192
  type: "string",
196
193
  default: "theme"
197
194
  }), async ({ entry, dir, theme: themeInput }) => {
198
- const data = await fs_exports.load(entry);
195
+ const data = await parser.load(entry);
199
196
  const theme = resolveThemeName(themeInput || data.config.theme);
200
197
  if (theme === "none") {
201
198
  console.error('Can not eject theme "none"');
@@ -217,7 +214,7 @@ cli.command("theme [subcommand]", "Theme related operations", (command) => {
217
214
  const dirPath = `./${dir}`;
218
215
  data.slides[0].frontmatter.theme = dirPath;
219
216
  data.slides[0].raw = null;
220
- await fs_exports.save(data);
217
+ await parser.save(data);
221
218
  console.log(`Theme "${theme}" ejected successfully to "${dirPath}"`);
222
219
  });
223
220
  }, () => {
@@ -226,7 +223,7 @@ cli.command("theme [subcommand]", "Theme related operations", (command) => {
226
223
  });
227
224
  cli.command("export [entry]", "Export slides to PDF", (args) => commonOptions(args).option("output", {
228
225
  type: "string",
229
- describe: "path to the the port output"
226
+ describe: "path to the output"
230
227
  }).option("format", {
231
228
  default: "pdf",
232
229
  type: "string",
@@ -259,7 +256,7 @@ cli.command("export [entry]", "Export slides to PDF", (args) => commonOptions(ar
259
256
  "with-clicks": withClicks
260
257
  }) => {
261
258
  process.env.NODE_ENV = "production";
262
- const { exportSlides } = await Promise.resolve().then(() => __toESM(__require("./export-HA4VXV3M.mjs")));
259
+ const { exportSlides } = await Promise.resolve().then(() => __toESM(__require("./export-GIPHUNUX.mjs")));
263
260
  const port = await findFreePort(12445);
264
261
  const options = await resolveOptions({ entry, theme }, "build");
265
262
  output = output || options.data.config.exportFilename || `${path.basename(entry, ".md")}-export`;
@@ -269,7 +266,7 @@ cli.command("export [entry]", "Export slides to PDF", (args) => commonOptions(ar
269
266
  });
270
267
  await server.listen(port);
271
268
  printInfo(options);
272
- fs_exports.filterDisabled(options.data);
269
+ parser.filterDisabled(options.data);
273
270
  const width = options.data.config.canvasWidth;
274
271
  const height = Math.round(width / options.data.config.aspectRatio);
275
272
  output = await exportSlides({
@@ -312,19 +309,22 @@ function printInfo(options, port, remote) {
312
309
  console.log(dim(" theme ") + (options.theme ? green(options.theme) : gray("none")));
313
310
  console.log(dim(" entry ") + dim(path.dirname(options.entry) + path.sep) + path.basename(options.entry));
314
311
  if (port) {
315
- const presenterPath = `${options.data.config.routerMode === "hash" ? "/#/" : "/"}presenter`;
312
+ const query = remote ? `?password=${remote}` : "";
313
+ const presenterPath = `${options.data.config.routerMode === "hash" ? "/#/" : "/"}presenter/${query}`;
316
314
  console.log();
317
- console.log(`${dim(" slide show ")} > ${cyan(`http://localhost:${bold(port)}/`)}`);
318
- console.log(`${dim(" presenter mode ")} > ${blue(`http://localhost:${bold(port)}${presenterPath}`)}`);
319
- if (remote) {
315
+ console.log(`${dim(" public slide show ")} > ${cyan(`http://localhost:${bold(port)}/`)}`);
316
+ if (query)
317
+ console.log(`${dim(" private slide show ")} > ${cyan(`http://localhost:${bold(port)}/${query}`)}`);
318
+ console.log(`${dim(" presenter mode ")} > ${blue(`http://localhost:${bold(port)}${presenterPath}`)}`);
319
+ if (remote !== void 0) {
320
320
  Object.values(os.networkInterfaces()).forEach((v) => (v || []).filter((details) => details.family === "IPv4" && !details.address.includes("127.0.0.1")).forEach(({ address }) => {
321
- console.log(`${dim(" remote control ")} > ${blue(`http://${address}:${port}${presenterPath}`)}`);
321
+ console.log(`${dim(" remote control ")} > ${blue(`http://${address}:${port}${presenterPath}`)}`);
322
322
  }));
323
323
  } else {
324
- console.log(`${dim(" remote control ")} > ${dim("pass --remote to enable")}`);
324
+ console.log(`${dim(" remote control ")} > ${dim("pass --remote to enable")}`);
325
325
  }
326
326
  console.log();
327
- console.log(`${dim(" shortcuts ")} > ${underline("r")}${dim("estart | ")}${underline("o")}${dim("pen | ")}${underline("e")}${dim("dit")}`);
327
+ console.log(`${dim(" shortcuts ")} > ${underline("r")}${dim("estart | ")}${underline("o")}${dim("pen | ")}${underline("e")}${dim("dit")}`);
328
328
  }
329
329
  console.log();
330
330
  console.log();
@@ -1,11 +1,9 @@
1
- import {
2
- packageExists
3
- } from "./chunk-U4YYUHKV.mjs";
4
1
  import {
5
2
  __require,
6
3
  __toESM,
7
- init_esm_shims
8
- } from "./chunk-D6ZT4BYV.mjs";
4
+ init_esm_shims,
5
+ packageExists
6
+ } from "./chunk-NOFZO6W4.mjs";
9
7
 
10
8
  // node/export.ts
11
9
  init_esm_shims();
@@ -1,14 +1,12 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
2
 
3
- var _chunkZN6VJBWPjs = require('./chunk-ZN6VJBWP.js');
4
3
 
5
4
 
6
5
 
7
-
8
- var _chunkOVW2G2MHjs = require('./chunk-OVW2G2MH.js');
6
+ var _chunkJWGORJY6js = require('./chunk-JWGORJY6.js');
9
7
 
10
8
  // node/export.ts
11
- _chunkOVW2G2MHjs.init_cjs_shims.call(void 0, );
9
+ _chunkJWGORJY6js.init_cjs_shims.call(void 0, );
12
10
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
13
11
  var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
14
12
  var _kolorist = require('kolorist');
@@ -62,10 +60,10 @@ async function exportSlides({
62
60
  height = 1080,
63
61
  withClicks = false
64
62
  }) {
65
- if (!_chunkZN6VJBWPjs.packageExists.call(void 0, "playwright-chromium"))
63
+ if (!_chunkJWGORJY6js.packageExists.call(void 0, "playwright-chromium"))
66
64
  throw new Error("The exporting for Slidev is powered by Playwright, please installed it via `npm i -D playwright-chromium`");
67
65
  const pages = _core.parseRangeString.call(void 0, total, range);
68
- const { chromium } = await Promise.resolve().then(() => _chunkOVW2G2MHjs.__toESM.call(void 0, _chunkOVW2G2MHjs.__require.call(void 0, "playwright-chromium")));
66
+ const { chromium } = await Promise.resolve().then(() => _chunkJWGORJY6js.__toESM.call(void 0, _chunkJWGORJY6js.__require.call(void 0, "playwright-chromium")));
69
67
  const browser = await chromium.launch();
70
68
  const context = await browser.newContext({
71
69
  viewport: {
package/dist/index.d.ts CHANGED
@@ -6,9 +6,11 @@ import WindiCSS from 'vite-plugin-windicss';
6
6
  import RemoteAssets from 'vite-plugin-remote-assets';
7
7
  import ServerRef from 'vite-plugin-vue-server-ref';
8
8
  import { ArgumentsType } from '@antfu/utils';
9
- import { SlidevMarkdown, SlidevThemeMeta, SlidevConfig, FontOptions, ResolvedFontOptions, SlideInfoBase, SlidevFeatureFlags, SlideInfoWithPath } from '@slidev/types';
9
+ import { SlidevMarkdown } from '@slidev/types';
10
10
  import * as vite from 'vite';
11
11
  import { InlineConfig, Plugin } from 'vite';
12
+ import * as fs from '@slidev/parser/fs';
13
+ export { fs as parser };
12
14
 
13
15
  interface SlidevEntryOptions {
14
16
  /**
@@ -21,6 +23,10 @@ interface SlidevEntryOptions {
21
23
  * Theme id
22
24
  */
23
25
  theme?: string;
26
+ /**
27
+ * Remote password
28
+ */
29
+ remote?: string;
24
30
  /**
25
31
  * Root path
26
32
  *
@@ -36,8 +42,10 @@ interface ResolvedSlidevOptions {
36
42
  clientRoot: string;
37
43
  theme: string;
38
44
  themeRoots: string[];
45
+ addonRoots: string[];
39
46
  roots: string[];
40
47
  mode: 'dev' | 'build';
48
+ remote?: string;
41
49
  }
42
50
  interface SlidevPluginOptions extends SlidevEntryOptions {
43
51
  vue?: ArgumentsType<typeof Vue>[0];
@@ -55,6 +63,8 @@ declare function getClientRoot(): string;
55
63
  declare function getCLIRoot(): string;
56
64
  declare function isPath(name: string): boolean;
57
65
  declare function getThemeRoots(name: string, entry: string): string[];
66
+ declare function getAddonRoots(addons: string[], entry: string): string[];
67
+ declare function getRoot(name: string, entry: string): string;
58
68
  declare function getUserRoot(options: SlidevEntryOptions): {
59
69
  entry: string;
60
70
  userRoot: string;
@@ -76,72 +86,6 @@ declare function createServer(options: ResolvedSlidevOptions, viteConfig?: Inlin
76
86
 
77
87
  declare function ViteSlidevPlugin(options: ResolvedSlidevOptions, pluginOptions: SlidevPluginOptions, serverOptions?: SlidevServerOptions): Promise<Plugin[]>;
78
88
 
79
- declare function createWindiCSSPlugin({ themeRoots, clientRoot, userRoot, roots, data }: ResolvedSlidevOptions, { windicss: windiOptions }: SlidevPluginOptions): Promise<vite.Plugin[]>;
80
-
81
- /**
82
- * 1,3-5,8 => [1, 3, 4, 5, 8]
83
- */
84
- declare function parseRangeString(total: number, rangeStr?: string): number[];
85
- /**
86
- * Accepts `16/9` `1:1` `3x4`
87
- */
88
- declare function parseAspectRatio(str: string | number): number;
89
-
90
- declare function resolveConfig(headmatter: any, themeMeta?: SlidevThemeMeta): SlidevConfig;
91
- declare function resolveFonts(fonts?: FontOptions): ResolvedFontOptions;
92
-
93
- declare function stringify(data: SlidevMarkdown): string;
94
- declare function filterDisabled(data: SlidevMarkdown): SlidevMarkdown;
95
- declare function stringifySlide(data: SlideInfoBase, idx?: number): string;
96
- declare function prettifySlide(data: SlideInfoBase): SlideInfoBase;
97
- declare function prettify(data: SlidevMarkdown): SlidevMarkdown;
98
- declare function detectFeatures(code: string): SlidevFeatureFlags;
99
- declare function parseSlide(raw: string): SlideInfoBase;
100
- declare function parse(markdown: string, filepath?: string, themeMeta?: SlidevThemeMeta): SlidevMarkdown;
101
- declare function mergeFeatureFlags(a: SlidevFeatureFlags, b: SlidevFeatureFlags): SlidevFeatureFlags;
102
- declare function scanMonacoModules(md: string): string[];
103
-
104
- declare function load(filepath: string, themeMeta?: SlidevThemeMeta, content?: string): Promise<SlidevMarkdown>;
105
- declare function save(data: SlidevMarkdown, filepath?: string): Promise<void>;
106
- declare function saveExternalSlide(slide: SlideInfoWithPath): Promise<void>;
107
-
108
- declare const fs_load: typeof load;
109
- declare const fs_save: typeof save;
110
- declare const fs_saveExternalSlide: typeof saveExternalSlide;
111
- declare const fs_parseRangeString: typeof parseRangeString;
112
- declare const fs_parseAspectRatio: typeof parseAspectRatio;
113
- declare const fs_resolveConfig: typeof resolveConfig;
114
- declare const fs_resolveFonts: typeof resolveFonts;
115
- declare const fs_stringify: typeof stringify;
116
- declare const fs_filterDisabled: typeof filterDisabled;
117
- declare const fs_stringifySlide: typeof stringifySlide;
118
- declare const fs_prettifySlide: typeof prettifySlide;
119
- declare const fs_prettify: typeof prettify;
120
- declare const fs_detectFeatures: typeof detectFeatures;
121
- declare const fs_parseSlide: typeof parseSlide;
122
- declare const fs_parse: typeof parse;
123
- declare const fs_mergeFeatureFlags: typeof mergeFeatureFlags;
124
- declare const fs_scanMonacoModules: typeof scanMonacoModules;
125
- declare namespace fs {
126
- export {
127
- fs_load as load,
128
- fs_save as save,
129
- fs_saveExternalSlide as saveExternalSlide,
130
- fs_parseRangeString as parseRangeString,
131
- fs_parseAspectRatio as parseAspectRatio,
132
- fs_resolveConfig as resolveConfig,
133
- fs_resolveFonts as resolveFonts,
134
- fs_stringify as stringify,
135
- fs_filterDisabled as filterDisabled,
136
- fs_stringifySlide as stringifySlide,
137
- fs_prettifySlide as prettifySlide,
138
- fs_prettify as prettify,
139
- fs_detectFeatures as detectFeatures,
140
- fs_parseSlide as parseSlide,
141
- fs_parse as parse,
142
- fs_mergeFeatureFlags as mergeFeatureFlags,
143
- fs_scanMonacoModules as scanMonacoModules,
144
- };
145
- }
89
+ declare function createWindiCSSPlugin({ themeRoots, addonRoots, clientRoot, userRoot, roots, data }: ResolvedSlidevOptions, { windicss: windiOptions }: SlidevPluginOptions): Promise<vite.Plugin[]>;
146
90
 
147
- export { ResolvedSlidevOptions, SlidevEntryOptions, SlidevPluginOptions, SlidevServerOptions, ViteSlidevPlugin, createServer, createWindiCSSPlugin, getCLIRoot, getClientRoot, getThemeRoots, getUserRoot, isPath, fs as parser, resolveOptions };
91
+ export { ResolvedSlidevOptions, SlidevEntryOptions, SlidevPluginOptions, SlidevServerOptions, ViteSlidevPlugin, createServer, createWindiCSSPlugin, getAddonRoots, getCLIRoot, getClientRoot, getRoot, getThemeRoots, getUserRoot, isPath, resolveOptions };
package/dist/index.js CHANGED
@@ -1,6 +1,5 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkUGIPPIZXjs = require('./chunk-UGIPPIZX.js');
4
3
 
5
4
 
6
5
 
@@ -9,20 +8,23 @@ var _chunkUGIPPIZXjs = require('./chunk-UGIPPIZX.js');
9
8
 
10
9
 
11
10
 
12
- var _chunkZN6VJBWPjs = require('./chunk-ZN6VJBWP.js');
13
11
 
12
+ var _chunkALT27UGEjs = require('./chunk-ALT27UGE.js');
14
13
 
15
14
 
16
- var _chunkN6ENRMDMjs = require('./chunk-N6ENRMDM.js');
17
15
 
16
+ var _chunk64ARPHPAjs = require('./chunk-64ARPHPA.js');
18
17
 
19
- var _chunkOVW2G2MHjs = require('./chunk-OVW2G2MH.js');
18
+
19
+ var _chunkJWGORJY6js = require('./chunk-JWGORJY6.js');
20
20
 
21
21
  // node/index.ts
22
- _chunkOVW2G2MHjs.init_cjs_shims.call(void 0, );
22
+ _chunkJWGORJY6js.init_cjs_shims.call(void 0, );
23
23
 
24
24
  // node/declare.ts
25
- _chunkOVW2G2MHjs.init_cjs_shims.call(void 0, );
25
+ _chunkJWGORJY6js.init_cjs_shims.call(void 0, );
26
+
27
+
26
28
 
27
29
 
28
30
 
@@ -34,4 +36,4 @@ _chunkOVW2G2MHjs.init_cjs_shims.call(void 0, );
34
36
 
35
37
 
36
38
 
37
- exports.ViteSlidevPlugin = _chunkN6ENRMDMjs.ViteSlidevPlugin; exports.createServer = _chunkUGIPPIZXjs.createServer; exports.createWindiCSSPlugin = _chunkN6ENRMDMjs.createWindiCSSPlugin; exports.getCLIRoot = _chunkZN6VJBWPjs.getCLIRoot; exports.getClientRoot = _chunkZN6VJBWPjs.getClientRoot; exports.getThemeRoots = _chunkZN6VJBWPjs.getThemeRoots; exports.getUserRoot = _chunkZN6VJBWPjs.getUserRoot; exports.isPath = _chunkZN6VJBWPjs.isPath; exports.parser = _chunkZN6VJBWPjs.fs_exports; exports.resolveOptions = _chunkZN6VJBWPjs.resolveOptions;
39
+ exports.ViteSlidevPlugin = _chunk64ARPHPAjs.ViteSlidevPlugin; exports.createServer = _chunkALT27UGEjs.createServer; exports.createWindiCSSPlugin = _chunk64ARPHPAjs.createWindiCSSPlugin; exports.getAddonRoots = _chunkALT27UGEjs.getAddonRoots; exports.getCLIRoot = _chunkALT27UGEjs.getCLIRoot; exports.getClientRoot = _chunkALT27UGEjs.getClientRoot; exports.getRoot = _chunkALT27UGEjs.getRoot; exports.getThemeRoots = _chunkALT27UGEjs.getThemeRoots; exports.getUserRoot = _chunkALT27UGEjs.getUserRoot; exports.isPath = _chunkALT27UGEjs.isPath; exports.parser = _chunkALT27UGEjs.parser; exports.resolveOptions = _chunkALT27UGEjs.resolveOptions;