@slidev/cli 0.43.7 → 0.43.9
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/bin/slidev.mjs +3 -0
- package/dist/{build-E7VPPALW.mjs → build-O4767R4S.mjs} +5 -5
- package/dist/{chunk-CPYGYVJ2.mjs → chunk-2ZQP2W7X.mjs} +17 -13
- package/dist/{chunk-QHOBBTS4.mjs → chunk-65ITIFTL.mjs} +1 -9
- package/dist/{chunk-PZQGSMNY.mjs → chunk-AA5PR2W4.mjs} +4 -3
- package/dist/{chunk-PNMZABHE.mjs → chunk-CNR3FZCA.mjs} +36 -33
- package/dist/{chunk-43ON36K4.mjs → chunk-CYLMMBRG.mjs} +4 -3
- package/dist/{chunk-7MRMXJYO.mjs → chunk-P35Z4724.mjs} +6 -4
- package/dist/cli.mjs +27 -14
- package/dist/{export-GFE5VFSA.mjs → export-HQUH6WSD.mjs} +2 -2
- package/dist/index.mjs +6 -6
- package/dist/{unocss-EBBZWMQM.mjs → unocss-BTVZWCXM.mjs} +4 -3
- package/dist/windicss-GLRSRVVQ.mjs +9 -0
- package/package.json +18 -16
- package/bin/slidev.js +0 -15
- package/dist/build-BMXGJSEG.js +0 -748
- package/dist/chunk-CGJOXW6I.js +0 -71
- package/dist/chunk-CPRFICJ7.js +0 -65
- package/dist/chunk-GD5JWUM3.js +0 -1703
- package/dist/chunk-IJ6NBA73.js +0 -7836
- package/dist/chunk-UWTQKD35.js +0 -35
- package/dist/chunk-YUG22S6W.js +0 -38
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -500
- package/dist/export-EYYLD3O6.js +0 -381
- package/dist/index.d.ts +0 -100
- package/dist/index.js +0 -35
- package/dist/unocss-E5M4APXD.js +0 -45
- package/dist/windicss-5I6DSVQN.mjs +0 -9
- package/dist/windicss-G7ISUN5H.js +0 -9
package/dist/chunk-UWTQKD35.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// node/plugins/setupNode.ts
|
|
2
|
-
var _path = require('path');
|
|
3
|
-
var _fsextra = require('fs-extra');
|
|
4
|
-
var _utils = require('@antfu/utils');
|
|
5
|
-
var _jiti = require('jiti'); var _jiti2 = _interopRequireDefault(_jiti);
|
|
6
|
-
function deepMerge(a, b, rootPath = "") {
|
|
7
|
-
a = { ...a };
|
|
8
|
-
Object.keys(b).forEach((key) => {
|
|
9
|
-
if (_utils.isObject.call(void 0, a[key]))
|
|
10
|
-
a[key] = deepMerge(a[key], b[key], rootPath ? `${rootPath}.${key}` : key);
|
|
11
|
-
else if (Array.isArray(a[key]))
|
|
12
|
-
a[key] = [...a[key], ...b[key]];
|
|
13
|
-
else
|
|
14
|
-
a[key] = b[key];
|
|
15
|
-
});
|
|
16
|
-
return a;
|
|
17
|
-
}
|
|
18
|
-
async function loadSetups(roots, name, arg, initial, merge = true) {
|
|
19
|
-
let returns = initial;
|
|
20
|
-
for (const root of roots) {
|
|
21
|
-
const path = _path.resolve.call(void 0, root, "setup", name);
|
|
22
|
-
if (await _fsextra.pathExists.call(void 0, path)) {
|
|
23
|
-
const { default: setup } = _jiti2.default.call(void 0, __filename)(path);
|
|
24
|
-
const result = await setup(arg);
|
|
25
|
-
if (result !== null) {
|
|
26
|
-
returns = typeof merge === "function" ? merge(returns, result) : merge ? deepMerge(returns, result) : result;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return returns;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
exports.loadSetups = loadSetups;
|
package/dist/chunk-YUG22S6W.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
-
}) : x)(function(x) {
|
|
10
|
-
if (typeof require !== "undefined")
|
|
11
|
-
return require.apply(this, arguments);
|
|
12
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
|
-
});
|
|
14
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
15
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
16
|
-
};
|
|
17
|
-
var __copyProps = (to, from, except, desc) => {
|
|
18
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
-
for (let key of __getOwnPropNames(from))
|
|
20
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
-
}
|
|
23
|
-
return to;
|
|
24
|
-
};
|
|
25
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
-
mod
|
|
32
|
-
));
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
exports.__require = __require; exports.__commonJS = __commonJS; exports.__toESM = __toESM;
|
package/dist/cli.d.ts
DELETED
package/dist/cli.js
DELETED
|
@@ -1,500 +0,0 @@
|
|
|
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 }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _chunkIJ6NBA73js = require('./chunk-IJ6NBA73.js');
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var _chunkGD5JWUM3js = require('./chunk-GD5JWUM3.js');
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var _chunkUWTQKD35js = require('./chunk-UWTQKD35.js');
|
|
19
|
-
require('./chunk-CGJOXW6I.js');
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
var _chunkYUG22S6Wjs = require('./chunk-YUG22S6W.js');
|
|
23
|
-
|
|
24
|
-
// node/cli.ts
|
|
25
|
-
var import_fast_deep_equal = _chunkYUG22S6Wjs.__toESM.call(void 0, _chunkGD5JWUM3js.require_fast_deep_equal.call(void 0, ));
|
|
26
|
-
var _path = require('path'); var _path2 = _interopRequireDefault(_path);
|
|
27
|
-
var _os = require('os'); var _os2 = _interopRequireDefault(_os);
|
|
28
|
-
var _child_process = require('child_process');
|
|
29
|
-
var _readline = require('readline'); var readline = _interopRequireWildcard(_readline);
|
|
30
|
-
var _process = require('process'); var _process2 = _interopRequireDefault(_process);
|
|
31
|
-
var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
|
|
32
|
-
var _open = require('open'); var _open2 = _interopRequireDefault(_open);
|
|
33
|
-
var _yargs = require('yargs'); var _yargs2 = _interopRequireDefault(_yargs);
|
|
34
|
-
var _prompts = require('prompts'); var _prompts2 = _interopRequireDefault(_prompts);
|
|
35
|
-
var _kolorist = require('kolorist');
|
|
36
|
-
var _isinstalledglobally = require('is-installed-globally'); var _isinstalledglobally2 = _interopRequireDefault(_isinstalledglobally);
|
|
37
|
-
var _parser = require('@slidev/parser');
|
|
38
|
-
var _fs = require('@slidev/parser/fs');
|
|
39
|
-
var _getportplease = require('get-port-please');
|
|
40
|
-
var CONFIG_RESTART_FIELDS = [
|
|
41
|
-
"highlighter",
|
|
42
|
-
"monaco",
|
|
43
|
-
"routerMode",
|
|
44
|
-
"fonts",
|
|
45
|
-
"css",
|
|
46
|
-
"mdc",
|
|
47
|
-
"editor"
|
|
48
|
-
];
|
|
49
|
-
_fs.injectPreparserExtensionLoader.call(void 0, async (headmatter, filepath) => {
|
|
50
|
-
const addons = _nullishCoalesce(_optionalChain([headmatter, 'optionalAccess', _ => _.addons]), () => ( []));
|
|
51
|
-
const roots = (
|
|
52
|
-
/* uniq */
|
|
53
|
-
[
|
|
54
|
-
_chunkIJ6NBA73js.getUserRoot.call(void 0, {}).userRoot,
|
|
55
|
-
..._chunkIJ6NBA73js.getAddonRoots.call(void 0, addons, ""),
|
|
56
|
-
_chunkIJ6NBA73js.getClientRoot.call(void 0, )
|
|
57
|
-
]
|
|
58
|
-
);
|
|
59
|
-
const mergeArrays = (a, b) => a.concat(b);
|
|
60
|
-
return await _chunkUWTQKD35js.loadSetups.call(void 0, roots, "preparser.ts", { filepath, headmatter }, [], mergeArrays);
|
|
61
|
-
});
|
|
62
|
-
var cli = _yargs2.default.scriptName("slidev").usage("$0 [args]").version(_chunkIJ6NBA73js.version).strict().showHelpOnFail(false).alias("h", "help").alias("v", "version");
|
|
63
|
-
cli.command(
|
|
64
|
-
"* [entry]",
|
|
65
|
-
"Start a local server for Slidev",
|
|
66
|
-
(args) => commonOptions(args).option("port", {
|
|
67
|
-
alias: "p",
|
|
68
|
-
type: "number",
|
|
69
|
-
describe: "port"
|
|
70
|
-
}).option("open", {
|
|
71
|
-
alias: "o",
|
|
72
|
-
default: false,
|
|
73
|
-
type: "boolean",
|
|
74
|
-
describe: "open in browser"
|
|
75
|
-
}).option("remote", {
|
|
76
|
-
type: "string",
|
|
77
|
-
describe: "listen public host and enable remote control"
|
|
78
|
-
}).option("tunnel", {
|
|
79
|
-
default: false,
|
|
80
|
-
type: "boolean",
|
|
81
|
-
describe: "open localtunnel to make Slidev available on the internet"
|
|
82
|
-
}).option("log", {
|
|
83
|
-
default: "warn",
|
|
84
|
-
type: "string",
|
|
85
|
-
choices: ["error", "warn", "info", "silent"],
|
|
86
|
-
describe: "log level"
|
|
87
|
-
}).option("inspect", {
|
|
88
|
-
default: false,
|
|
89
|
-
type: "boolean",
|
|
90
|
-
describe: "enable the inspect plugin for debugging"
|
|
91
|
-
}).option("force", {
|
|
92
|
-
alias: "f",
|
|
93
|
-
default: false,
|
|
94
|
-
type: "boolean",
|
|
95
|
-
describe: "force the optimizer to ignore the cache and re-bundle "
|
|
96
|
-
}).strict().help(),
|
|
97
|
-
async ({ entry, theme, port: userPort, open, log, remote, tunnel, force, inspect }) => {
|
|
98
|
-
if (!_fsextra2.default.existsSync(entry) && !entry.endsWith(".md"))
|
|
99
|
-
entry = `${entry}.md`;
|
|
100
|
-
if (!_fsextra2.default.existsSync(entry)) {
|
|
101
|
-
const { create } = await _prompts2.default.call(void 0, {
|
|
102
|
-
name: "create",
|
|
103
|
-
type: "confirm",
|
|
104
|
-
initial: "Y",
|
|
105
|
-
message: `Entry file ${_kolorist.yellow.call(void 0, `"${entry}"`)} does not exist, do you want to create it?`
|
|
106
|
-
});
|
|
107
|
-
if (create)
|
|
108
|
-
await _fsextra2.default.copyFile(_path2.default.resolve(__dirname, "../template.md"), entry);
|
|
109
|
-
else
|
|
110
|
-
_process2.default.exit(0);
|
|
111
|
-
}
|
|
112
|
-
let server;
|
|
113
|
-
let port = 3030;
|
|
114
|
-
let lastRemoteUrl;
|
|
115
|
-
async function initServer() {
|
|
116
|
-
if (server)
|
|
117
|
-
await server.close();
|
|
118
|
-
const options = await _chunkIJ6NBA73js.resolveOptions.call(void 0, { entry, remote, theme, inspect }, "dev");
|
|
119
|
-
port = userPort || await findFreePort(3030);
|
|
120
|
-
server = await _chunkIJ6NBA73js.createServer.call(void 0,
|
|
121
|
-
options,
|
|
122
|
-
{
|
|
123
|
-
server: {
|
|
124
|
-
port,
|
|
125
|
-
strictPort: true,
|
|
126
|
-
open,
|
|
127
|
-
host: remote !== void 0 ? "0.0.0.0" : "localhost",
|
|
128
|
-
force
|
|
129
|
-
},
|
|
130
|
-
logLevel: log
|
|
131
|
-
},
|
|
132
|
-
{
|
|
133
|
-
onDataReload(newData, data) {
|
|
134
|
-
if (!theme && _chunkIJ6NBA73js.resolveThemeName.call(void 0, newData.config.theme) !== _chunkIJ6NBA73js.resolveThemeName.call(void 0, data.config.theme)) {
|
|
135
|
-
console.log(_kolorist.yellow.call(void 0, "\n restarting on theme change\n"));
|
|
136
|
-
initServer();
|
|
137
|
-
} else if (CONFIG_RESTART_FIELDS.some((i) => !(0, import_fast_deep_equal.default)(newData.config[i], data.config[i]))) {
|
|
138
|
-
console.log(_kolorist.yellow.call(void 0, "\n restarting on config change\n"));
|
|
139
|
-
initServer();
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
);
|
|
144
|
-
await server.listen();
|
|
145
|
-
let tunnelUrl = "";
|
|
146
|
-
if (tunnel) {
|
|
147
|
-
if (remote != null)
|
|
148
|
-
tunnelUrl = await openTunnel(port);
|
|
149
|
-
else
|
|
150
|
-
console.log(_kolorist.yellow.call(void 0, "\n --remote is required for tunneling, localtunnel is not enabled.\n"));
|
|
151
|
-
}
|
|
152
|
-
lastRemoteUrl = printInfo(options, port, remote, tunnelUrl);
|
|
153
|
-
}
|
|
154
|
-
async function openTunnel(port2) {
|
|
155
|
-
const localtunnel = await Promise.resolve().then(() => require("localtunnel")).then((r) => r.default || r);
|
|
156
|
-
const tunnel2 = await localtunnel({
|
|
157
|
-
port: port2,
|
|
158
|
-
local_host: "0.0.0.0"
|
|
159
|
-
});
|
|
160
|
-
return tunnel2.url;
|
|
161
|
-
}
|
|
162
|
-
const SHORTCUTS = [
|
|
163
|
-
{
|
|
164
|
-
name: "r",
|
|
165
|
-
fullname: "restart",
|
|
166
|
-
action() {
|
|
167
|
-
initServer();
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
name: "o",
|
|
172
|
-
fullname: "open",
|
|
173
|
-
action() {
|
|
174
|
-
_open2.default.call(void 0, `http://localhost:${port}`);
|
|
175
|
-
}
|
|
176
|
-
},
|
|
177
|
-
{
|
|
178
|
-
name: "e",
|
|
179
|
-
fullname: "edit",
|
|
180
|
-
action() {
|
|
181
|
-
_child_process.exec.call(void 0, `code "${entry}"`);
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
{
|
|
185
|
-
name: "q",
|
|
186
|
-
fullname: "quit",
|
|
187
|
-
action() {
|
|
188
|
-
try {
|
|
189
|
-
_optionalChain([server, 'optionalAccess', _2 => _2.close, 'call', _3 => _3()]);
|
|
190
|
-
} finally {
|
|
191
|
-
_process2.default.exit();
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
name: "c",
|
|
197
|
-
fullname: "qrcode",
|
|
198
|
-
async action() {
|
|
199
|
-
if (!lastRemoteUrl)
|
|
200
|
-
return;
|
|
201
|
-
await Promise.resolve().then(() => require("uqr")).then((r) => {
|
|
202
|
-
const code = r.renderUnicodeCompact(lastRemoteUrl);
|
|
203
|
-
console.log(`
|
|
204
|
-
${_kolorist.dim.call(void 0, " QR Code for remote control: ")}
|
|
205
|
-
${_kolorist.blue.call(void 0, lastRemoteUrl)}
|
|
206
|
-
`);
|
|
207
|
-
console.log(code.split("\n").map((i) => ` ${i}`).join("\n"));
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
];
|
|
212
|
-
function bindShortcut() {
|
|
213
|
-
_process2.default.stdin.resume();
|
|
214
|
-
_process2.default.stdin.setEncoding("utf8");
|
|
215
|
-
readline.emitKeypressEvents(_process2.default.stdin);
|
|
216
|
-
if (_process2.default.stdin.isTTY)
|
|
217
|
-
_process2.default.stdin.setRawMode(true);
|
|
218
|
-
_process2.default.stdin.on("keypress", (str, key) => {
|
|
219
|
-
if (key.ctrl && key.name === "c") {
|
|
220
|
-
_process2.default.exit();
|
|
221
|
-
} else {
|
|
222
|
-
const [sh] = SHORTCUTS.filter((item) => item.name === str);
|
|
223
|
-
if (sh) {
|
|
224
|
-
try {
|
|
225
|
-
sh.action();
|
|
226
|
-
} catch (err) {
|
|
227
|
-
console.error(`Failed to execute shortcut ${sh.fullname}`, err);
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
});
|
|
232
|
-
}
|
|
233
|
-
initServer();
|
|
234
|
-
bindShortcut();
|
|
235
|
-
}
|
|
236
|
-
);
|
|
237
|
-
cli.command(
|
|
238
|
-
"build [entry..]",
|
|
239
|
-
"Build hostable SPA",
|
|
240
|
-
(args) => exportOptions(commonOptions(args)).option("watch", {
|
|
241
|
-
alias: "w",
|
|
242
|
-
default: false,
|
|
243
|
-
describe: "build watch"
|
|
244
|
-
}).option("out", {
|
|
245
|
-
alias: "o",
|
|
246
|
-
type: "string",
|
|
247
|
-
default: "dist",
|
|
248
|
-
describe: "output dir"
|
|
249
|
-
}).option("base", {
|
|
250
|
-
type: "string",
|
|
251
|
-
describe: "output base"
|
|
252
|
-
}).option("download", {
|
|
253
|
-
alias: "d",
|
|
254
|
-
type: "boolean",
|
|
255
|
-
describe: "allow download as PDF"
|
|
256
|
-
}).option("inspect", {
|
|
257
|
-
default: false,
|
|
258
|
-
type: "boolean",
|
|
259
|
-
describe: "enable the inspect plugin for debugging"
|
|
260
|
-
}).strict().help(),
|
|
261
|
-
async (args) => {
|
|
262
|
-
const { entry, theme, watch, base, download, out, inspect } = args;
|
|
263
|
-
const { build } = await Promise.resolve().then(() => require("./build-BMXGJSEG.js"));
|
|
264
|
-
for (const entryFile of entry) {
|
|
265
|
-
const options = await _chunkIJ6NBA73js.resolveOptions.call(void 0, { entry: entryFile, theme, inspect }, "build");
|
|
266
|
-
if (download && !options.data.config.download)
|
|
267
|
-
options.data.config.download = download;
|
|
268
|
-
printInfo(options);
|
|
269
|
-
await build(options, {
|
|
270
|
-
base,
|
|
271
|
-
build: {
|
|
272
|
-
watch: watch ? {} : void 0,
|
|
273
|
-
outDir: entry.length === 1 ? out : _path2.default.join(out, _path2.default.basename(entryFile, ".md"))
|
|
274
|
-
}
|
|
275
|
-
}, { ...args, entry: entryFile });
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
);
|
|
279
|
-
cli.command(
|
|
280
|
-
"format [entry..]",
|
|
281
|
-
"Format the markdown file",
|
|
282
|
-
(args) => commonOptions(args).strict().help(),
|
|
283
|
-
async ({ entry }) => {
|
|
284
|
-
for (const entryFile of entry) {
|
|
285
|
-
const data = await _chunkIJ6NBA73js.parser.load(entryFile);
|
|
286
|
-
_chunkIJ6NBA73js.parser.prettify(data);
|
|
287
|
-
await _chunkIJ6NBA73js.parser.save(data);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
);
|
|
291
|
-
cli.command(
|
|
292
|
-
"theme [subcommand]",
|
|
293
|
-
"Theme related operations",
|
|
294
|
-
(command) => {
|
|
295
|
-
return command.command(
|
|
296
|
-
"eject",
|
|
297
|
-
"Eject current theme into local file system",
|
|
298
|
-
(args) => commonOptions(args).option("dir", {
|
|
299
|
-
type: "string",
|
|
300
|
-
default: "theme"
|
|
301
|
-
}),
|
|
302
|
-
async ({ entry, dir, theme: themeInput }) => {
|
|
303
|
-
const data = await _chunkIJ6NBA73js.parser.load(entry);
|
|
304
|
-
const theme = _chunkIJ6NBA73js.resolveThemeName.call(void 0, themeInput || data.config.theme);
|
|
305
|
-
if (theme === "none") {
|
|
306
|
-
console.error('Cannot eject theme "none"');
|
|
307
|
-
_process2.default.exit(1);
|
|
308
|
-
}
|
|
309
|
-
if (_chunkIJ6NBA73js.isPath.call(void 0, theme)) {
|
|
310
|
-
console.error("Theme is already ejected");
|
|
311
|
-
_process2.default.exit(1);
|
|
312
|
-
}
|
|
313
|
-
const roots = _chunkIJ6NBA73js.getThemeRoots.call(void 0, theme, entry);
|
|
314
|
-
if (!roots.length) {
|
|
315
|
-
console.error(`Could not find theme "${theme}"`);
|
|
316
|
-
_process2.default.exit(1);
|
|
317
|
-
}
|
|
318
|
-
const root = roots[0];
|
|
319
|
-
await _fsextra2.default.copy(root, _path2.default.resolve(dir), {
|
|
320
|
-
filter: (i) => !/node_modules|.git/.test(_path2.default.relative(root, i))
|
|
321
|
-
});
|
|
322
|
-
const dirPath = `./${dir}`;
|
|
323
|
-
data.slides[0].frontmatter.theme = dirPath;
|
|
324
|
-
data.slides[0].raw = null;
|
|
325
|
-
await _chunkIJ6NBA73js.parser.save(data);
|
|
326
|
-
console.log(`Theme "${theme}" ejected successfully to "${dirPath}"`);
|
|
327
|
-
}
|
|
328
|
-
);
|
|
329
|
-
},
|
|
330
|
-
() => {
|
|
331
|
-
cli.showHelp();
|
|
332
|
-
_process2.default.exit(1);
|
|
333
|
-
}
|
|
334
|
-
);
|
|
335
|
-
cli.command(
|
|
336
|
-
"export [entry..]",
|
|
337
|
-
"Export slides to PDF",
|
|
338
|
-
(args) => exportOptions(commonOptions(args)).strict().help(),
|
|
339
|
-
async (args) => {
|
|
340
|
-
const { entry, theme } = args;
|
|
341
|
-
_process2.default.env.NODE_ENV = "production";
|
|
342
|
-
const { exportSlides, getExportOptions } = await Promise.resolve().then(() => require("./export-EYYLD3O6.js"));
|
|
343
|
-
const port = await findFreePort(12445);
|
|
344
|
-
for (const entryFile of entry) {
|
|
345
|
-
const options = await _chunkIJ6NBA73js.resolveOptions.call(void 0, { entry: entryFile, theme }, "export");
|
|
346
|
-
const server = await _chunkIJ6NBA73js.createServer.call(void 0,
|
|
347
|
-
options,
|
|
348
|
-
{
|
|
349
|
-
server: { port },
|
|
350
|
-
clearScreen: false
|
|
351
|
-
}
|
|
352
|
-
);
|
|
353
|
-
await server.listen(port);
|
|
354
|
-
printInfo(options);
|
|
355
|
-
_chunkIJ6NBA73js.parser.filterDisabled(options.data);
|
|
356
|
-
const result = await exportSlides({
|
|
357
|
-
port,
|
|
358
|
-
...getExportOptions({ ...args, entry: entryFile }, options)
|
|
359
|
-
});
|
|
360
|
-
console.log(`${_kolorist.green.call(void 0, " \u2713 ")}${_kolorist.dim.call(void 0, "exported to ")}./${result}
|
|
361
|
-
`);
|
|
362
|
-
server.close();
|
|
363
|
-
}
|
|
364
|
-
_process2.default.exit(0);
|
|
365
|
-
}
|
|
366
|
-
);
|
|
367
|
-
cli.command(
|
|
368
|
-
"export-notes [entry..]",
|
|
369
|
-
"Export slide notes to PDF",
|
|
370
|
-
(args) => args.positional("entry", {
|
|
371
|
-
default: "slides.md",
|
|
372
|
-
type: "string",
|
|
373
|
-
describe: "path to the slides markdown entry"
|
|
374
|
-
}).option("output", {
|
|
375
|
-
type: "string",
|
|
376
|
-
describe: "path to the output"
|
|
377
|
-
}).option("timeout", {
|
|
378
|
-
default: 3e4,
|
|
379
|
-
type: "number",
|
|
380
|
-
describe: "timeout for rendering the print page"
|
|
381
|
-
}).strict().help(),
|
|
382
|
-
async ({
|
|
383
|
-
entry,
|
|
384
|
-
output,
|
|
385
|
-
timeout
|
|
386
|
-
}) => {
|
|
387
|
-
_process2.default.env.NODE_ENV = "production";
|
|
388
|
-
const { exportNotes } = await Promise.resolve().then(() => require("./export-EYYLD3O6.js"));
|
|
389
|
-
const port = await findFreePort(12445);
|
|
390
|
-
for (const entryFile of entry) {
|
|
391
|
-
const options = await _chunkIJ6NBA73js.resolveOptions.call(void 0, { entry: entryFile }, "export");
|
|
392
|
-
const server = await _chunkIJ6NBA73js.createServer.call(void 0,
|
|
393
|
-
options,
|
|
394
|
-
{
|
|
395
|
-
server: { port },
|
|
396
|
-
clearScreen: false
|
|
397
|
-
}
|
|
398
|
-
);
|
|
399
|
-
await server.listen(port);
|
|
400
|
-
printInfo(options);
|
|
401
|
-
_chunkIJ6NBA73js.parser.filterDisabled(options.data);
|
|
402
|
-
const result = await exportNotes({
|
|
403
|
-
port,
|
|
404
|
-
output: output || (options.data.config.exportFilename ? `${options.data.config.exportFilename}-notes` : `${_path2.default.basename(entryFile, ".md")}-export-notes`),
|
|
405
|
-
timeout
|
|
406
|
-
});
|
|
407
|
-
console.log(`${_kolorist.green.call(void 0, " \u2713 ")}${_kolorist.dim.call(void 0, "exported to ")}./${result}
|
|
408
|
-
`);
|
|
409
|
-
server.close();
|
|
410
|
-
}
|
|
411
|
-
_process2.default.exit(0);
|
|
412
|
-
}
|
|
413
|
-
);
|
|
414
|
-
cli.help().parse();
|
|
415
|
-
function commonOptions(args) {
|
|
416
|
-
return args.positional("entry", {
|
|
417
|
-
default: "slides.md",
|
|
418
|
-
type: "string",
|
|
419
|
-
describe: "path to the slides markdown entry"
|
|
420
|
-
}).option("theme", {
|
|
421
|
-
alias: "t",
|
|
422
|
-
type: "string",
|
|
423
|
-
describe: "override theme"
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
function exportOptions(args) {
|
|
427
|
-
return args.option("output", {
|
|
428
|
-
type: "string",
|
|
429
|
-
describe: "path to the output"
|
|
430
|
-
}).option("format", {
|
|
431
|
-
type: "string",
|
|
432
|
-
choices: ["pdf", "png", "md"],
|
|
433
|
-
describe: "output format"
|
|
434
|
-
}).option("timeout", {
|
|
435
|
-
type: "number",
|
|
436
|
-
describe: "timeout for rendering the print page"
|
|
437
|
-
}).option("range", {
|
|
438
|
-
type: "string",
|
|
439
|
-
describe: 'page ranges to export, for example "1,4-5,6"'
|
|
440
|
-
}).option("dark", {
|
|
441
|
-
type: "boolean",
|
|
442
|
-
describe: "export as dark theme"
|
|
443
|
-
}).option("with-clicks", {
|
|
444
|
-
alias: "c",
|
|
445
|
-
type: "boolean",
|
|
446
|
-
describe: "export pages for every clicks"
|
|
447
|
-
}).option("executable-path", {
|
|
448
|
-
type: "string",
|
|
449
|
-
describe: "executable to override playwright bundled browser"
|
|
450
|
-
}).option("with-toc", {
|
|
451
|
-
type: "boolean",
|
|
452
|
-
describe: "export pages with outline"
|
|
453
|
-
}).option("per-slide", {
|
|
454
|
-
type: "boolean",
|
|
455
|
-
describe: "slide slides slide by slide. Works better with global components, but will break cross slide links and TOC in PDF"
|
|
456
|
-
});
|
|
457
|
-
}
|
|
458
|
-
function printInfo(options, port, remote, tunnelUrl) {
|
|
459
|
-
console.log();
|
|
460
|
-
console.log();
|
|
461
|
-
console.log(` ${_kolorist.cyan.call(void 0, "\u25CF") + _kolorist.blue.call(void 0, "\u25A0") + _kolorist.yellow.call(void 0, "\u25B2")}`);
|
|
462
|
-
console.log(`${_kolorist.bold.call(void 0, " Slidev")} ${_kolorist.blue.call(void 0, `v${_chunkIJ6NBA73js.version}`)} ${_isinstalledglobally2.default ? _kolorist.yellow.call(void 0, "(global)") : ""}`);
|
|
463
|
-
console.log();
|
|
464
|
-
_parser.verifyConfig.call(void 0, options.data.config, options.data.themeMeta, (v) => console.warn(_kolorist.yellow.call(void 0, ` ! ${v}`)));
|
|
465
|
-
console.log(_kolorist.dim.call(void 0, " theme ") + (options.theme ? _kolorist.green.call(void 0, options.theme) : _kolorist.gray.call(void 0, "none")));
|
|
466
|
-
console.log(_kolorist.dim.call(void 0, " css engine ") + (options.data.config.css ? _kolorist.blue.call(void 0, options.data.config.css) : _kolorist.gray.call(void 0, "none")));
|
|
467
|
-
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));
|
|
468
|
-
if (port) {
|
|
469
|
-
const query = remote ? `?password=${remote}` : "";
|
|
470
|
-
const presenterPath = `${options.data.config.routerMode === "hash" ? "/#/" : "/"}presenter/${query}`;
|
|
471
|
-
console.log();
|
|
472
|
-
console.log(`${_kolorist.dim.call(void 0, " public slide show ")} > ${_kolorist.cyan.call(void 0, `http://localhost:${_kolorist.bold.call(void 0, port)}/`)}`);
|
|
473
|
-
if (query)
|
|
474
|
-
console.log(`${_kolorist.dim.call(void 0, " private slide show ")} > ${_kolorist.cyan.call(void 0, `http://localhost:${_kolorist.bold.call(void 0, port)}/${query}`)}`);
|
|
475
|
-
console.log(`${_kolorist.dim.call(void 0, " presenter mode ")} > ${_kolorist.blue.call(void 0, `http://localhost:${_kolorist.bold.call(void 0, port)}${presenterPath}`)}`);
|
|
476
|
-
if (options.inspect)
|
|
477
|
-
console.log(`${_kolorist.dim.call(void 0, " inspector")} > ${_kolorist.yellow.call(void 0, `http://localhost:${_kolorist.bold.call(void 0, port)}/__inspect/`)}`);
|
|
478
|
-
let lastRemoteUrl = "";
|
|
479
|
-
if (remote !== void 0) {
|
|
480
|
-
Object.values(_os2.default.networkInterfaces()).forEach((v) => (v || []).filter((details) => String(details.family).slice(-1) === "4" && !details.address.includes("127.0.0.1")).forEach(({ address }) => {
|
|
481
|
-
lastRemoteUrl = `http://${address}:${port}${presenterPath}`;
|
|
482
|
-
console.log(`${_kolorist.dim.call(void 0, " remote control ")} > ${_kolorist.blue.call(void 0, lastRemoteUrl)}`);
|
|
483
|
-
}));
|
|
484
|
-
if (tunnelUrl) {
|
|
485
|
-
lastRemoteUrl = `${tunnelUrl}${presenterPath}`;
|
|
486
|
-
console.log(`${_kolorist.dim.call(void 0, " remote via tunnel")} > ${_kolorist.yellow.call(void 0, lastRemoteUrl)}`);
|
|
487
|
-
}
|
|
488
|
-
} else {
|
|
489
|
-
console.log(`${_kolorist.dim.call(void 0, " remote control ")} > ${_kolorist.dim.call(void 0, "pass --remote to enable")}`);
|
|
490
|
-
}
|
|
491
|
-
console.log();
|
|
492
|
-
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 | ")}${_kolorist.underline.call(void 0, "q")}${_kolorist.dim.call(void 0, "uit")}${lastRemoteUrl ? ` | ${_kolorist.dim.call(void 0, "qr")}${_kolorist.underline.call(void 0, "c")}${_kolorist.dim.call(void 0, "ode")}` : ""}`);
|
|
493
|
-
return lastRemoteUrl;
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
async function findFreePort(start) {
|
|
497
|
-
if (await _getportplease.checkPort.call(void 0, start) !== false)
|
|
498
|
-
return start;
|
|
499
|
-
return findFreePort(start + 1);
|
|
500
|
-
}
|