@slidev/cli 0.34.0 → 0.34.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.
@@ -1,113 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
2
-
3
-
4
-
5
-
6
- var _chunkFROLEDLCjs = require('./chunk-FROLEDLC.js');
7
-
8
-
9
-
10
-
11
- var _chunkSO7T6GEWjs = require('./chunk-SO7T6GEW.js');
12
-
13
- // node/build.ts
14
- _chunkSO7T6GEWjs.init_cjs_shims.call(void 0, );
15
- var _path = require('path');
16
- var _http = require('http'); var _http2 = _interopRequireDefault(_http);
17
- var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
18
- var _vite = require('vite');
19
- var _connect = require('connect'); var _connect2 = _interopRequireDefault(_connect);
20
- var _kolorist = require('kolorist');
21
- async function build(options, viteConfig = {}) {
22
- const indexPath = _path.resolve.call(void 0, options.userRoot, "index.html");
23
- const rawConfig = await _vite.resolveConfig.call(void 0, {}, "build");
24
- const pluginOptions = rawConfig.slidev || {};
25
- let originalIndexHTML;
26
- if (_fsextra2.default.existsSync(indexPath))
27
- originalIndexHTML = await _fsextra2.default.readFile(indexPath, "utf-8");
28
- await _fsextra2.default.writeFile(indexPath, await _chunkFROLEDLCjs.getIndexHtml.call(void 0, options), "utf-8");
29
- let config = void 0;
30
- try {
31
- const inlineConfig = await _chunkFROLEDLCjs.mergeViteConfigs.call(void 0, options, viteConfig, {
32
- root: options.userRoot,
33
- plugins: [
34
- await _chunkFROLEDLCjs.ViteSlidevPlugin.call(void 0, options, pluginOptions),
35
- {
36
- name: "resolve-config",
37
- configResolved(_config) {
38
- config = _config;
39
- }
40
- }
41
- ],
42
- build: {
43
- chunkSizeWarningLimit: 2e3
44
- }
45
- }, "build");
46
- await _vite.build.call(void 0, inlineConfig);
47
- if (options.data.features.monaco) {
48
- if (options.data.config.monaco === "dev") {
49
- console.log(_kolorist.yellow.call(void 0, " Monaco is disabled in the build, to enabled it, set `monaco: true` in the frontmatter"));
50
- } else {
51
- console.log(_kolorist.blue.call(void 0, " building for Monaco...\n"));
52
- await _vite.build.call(void 0, await _chunkFROLEDLCjs.mergeViteConfigs.call(void 0, options, inlineConfig, {
53
- root: _path.join.call(void 0, options.clientRoot, "iframes/monaco"),
54
- base: `${config.base}iframes/monaco/`,
55
- build: {
56
- outDir: _path.resolve.call(void 0, config.build.outDir, "iframes/monaco"),
57
- rollupOptions: {
58
- output: {
59
- manualChunks: {
60
- jsonWorker: ["monaco-editor/esm/vs/language/json/json.worker"],
61
- cssWorker: ["monaco-editor/esm/vs/language/css/css.worker"],
62
- htmlWorker: ["monaco-editor/esm/vs/language/html/html.worker"],
63
- tsWorker: ["monaco-editor/esm/vs/language/typescript/ts.worker"],
64
- editorWorker: ["monaco-editor/esm/vs/editor/editor.worker"]
65
- }
66
- }
67
- }
68
- }
69
- }, "build"));
70
- }
71
- }
72
- } finally {
73
- if (originalIndexHTML != null)
74
- await _fsextra2.default.writeFile(indexPath, originalIndexHTML, "utf-8");
75
- else
76
- await _fsextra2.default.unlink(indexPath);
77
- }
78
- const outDir = _path.resolve.call(void 0, options.userRoot, config.build.outDir);
79
- const outFilename = options.data.config.exportFilename || "slidev-exported.pdf";
80
- await _fsextra2.default.copyFile(_path.resolve.call(void 0, outDir, "index.html"), _path.resolve.call(void 0, outDir, "404.html"));
81
- const redirectsPath = _path.resolve.call(void 0, outDir, "_redirects");
82
- if (!_fsextra2.default.existsSync(redirectsPath))
83
- await _fsextra2.default.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
84
- `, "utf-8");
85
- if ([true, "true", "auto"].includes(options.data.config.download)) {
86
- const { exportSlides } = await Promise.resolve().then(() => _chunkSO7T6GEWjs.__toESM.call(void 0, _chunkSO7T6GEWjs.__require.call(void 0, "./export-URR4VZNO.js")));
87
- const port = 12445;
88
- const app = _connect2.default.call(void 0, );
89
- const server = _http2.default.createServer(app);
90
- app.use(config.base, _chunkFROLEDLCjs.build_default.call(void 0, outDir, {
91
- etag: true,
92
- single: true,
93
- dev: true
94
- }));
95
- server.listen(port);
96
- await exportSlides({
97
- port,
98
- slides: options.data.slides,
99
- total: options.data.slides.length,
100
- format: "pdf",
101
- output: _path.join.call(void 0, outDir, outFilename),
102
- base: config.base,
103
- dark: options.data.config.colorSchema === "dark",
104
- width: options.data.config.canvasWidth,
105
- height: Math.round(options.data.config.canvasWidth / options.data.config.aspectRatio),
106
- routerMode: options.data.config.routerMode
107
- });
108
- server.close();
109
- }
110
- }
111
-
112
-
113
- exports.build = build;
@@ -1,113 +0,0 @@
1
- import {
2
- ViteSlidevPlugin,
3
- build_default,
4
- getIndexHtml,
5
- mergeViteConfigs
6
- } from "./chunk-OGKTSZVU.mjs";
7
- import {
8
- __require,
9
- __toESM,
10
- init_esm_shims
11
- } from "./chunk-IWKTUAXD.mjs";
12
-
13
- // node/build.ts
14
- init_esm_shims();
15
- import { join, resolve } from "path";
16
- import http from "http";
17
- import fs from "fs-extra";
18
- import { resolveConfig, build as viteBuild } from "vite";
19
- import connect from "connect";
20
- import { blue, yellow } from "kolorist";
21
- async function build(options, viteConfig = {}) {
22
- const indexPath = resolve(options.userRoot, "index.html");
23
- const rawConfig = await resolveConfig({}, "build");
24
- const pluginOptions = rawConfig.slidev || {};
25
- let originalIndexHTML;
26
- if (fs.existsSync(indexPath))
27
- originalIndexHTML = await fs.readFile(indexPath, "utf-8");
28
- await fs.writeFile(indexPath, await getIndexHtml(options), "utf-8");
29
- let config = void 0;
30
- try {
31
- const inlineConfig = await mergeViteConfigs(options, viteConfig, {
32
- root: options.userRoot,
33
- plugins: [
34
- await ViteSlidevPlugin(options, pluginOptions),
35
- {
36
- name: "resolve-config",
37
- configResolved(_config) {
38
- config = _config;
39
- }
40
- }
41
- ],
42
- build: {
43
- chunkSizeWarningLimit: 2e3
44
- }
45
- }, "build");
46
- await viteBuild(inlineConfig);
47
- if (options.data.features.monaco) {
48
- if (options.data.config.monaco === "dev") {
49
- console.log(yellow(" Monaco is disabled in the build, to enabled it, set `monaco: true` in the frontmatter"));
50
- } else {
51
- console.log(blue(" building for Monaco...\n"));
52
- await viteBuild(await mergeViteConfigs(options, inlineConfig, {
53
- root: join(options.clientRoot, "iframes/monaco"),
54
- base: `${config.base}iframes/monaco/`,
55
- build: {
56
- outDir: resolve(config.build.outDir, "iframes/monaco"),
57
- rollupOptions: {
58
- output: {
59
- manualChunks: {
60
- jsonWorker: ["monaco-editor/esm/vs/language/json/json.worker"],
61
- cssWorker: ["monaco-editor/esm/vs/language/css/css.worker"],
62
- htmlWorker: ["monaco-editor/esm/vs/language/html/html.worker"],
63
- tsWorker: ["monaco-editor/esm/vs/language/typescript/ts.worker"],
64
- editorWorker: ["monaco-editor/esm/vs/editor/editor.worker"]
65
- }
66
- }
67
- }
68
- }
69
- }, "build"));
70
- }
71
- }
72
- } finally {
73
- if (originalIndexHTML != null)
74
- await fs.writeFile(indexPath, originalIndexHTML, "utf-8");
75
- else
76
- await fs.unlink(indexPath);
77
- }
78
- const outDir = resolve(options.userRoot, config.build.outDir);
79
- const outFilename = options.data.config.exportFilename || "slidev-exported.pdf";
80
- await fs.copyFile(resolve(outDir, "index.html"), resolve(outDir, "404.html"));
81
- const redirectsPath = resolve(outDir, "_redirects");
82
- if (!fs.existsSync(redirectsPath))
83
- await fs.writeFile(redirectsPath, `${config.base}* ${config.base}index.html 200
84
- `, "utf-8");
85
- if ([true, "true", "auto"].includes(options.data.config.download)) {
86
- const { exportSlides } = await Promise.resolve().then(() => __toESM(__require("./export-Z44PM4CT.mjs")));
87
- const port = 12445;
88
- const app = connect();
89
- const server = http.createServer(app);
90
- app.use(config.base, build_default(outDir, {
91
- etag: true,
92
- single: true,
93
- dev: true
94
- }));
95
- server.listen(port);
96
- await exportSlides({
97
- port,
98
- slides: options.data.slides,
99
- total: options.data.slides.length,
100
- format: "pdf",
101
- output: join(outDir, outFilename),
102
- base: config.base,
103
- dark: options.data.config.colorSchema === "dark",
104
- width: options.data.config.canvasWidth,
105
- height: Math.round(options.data.config.canvasWidth / options.data.config.aspectRatio),
106
- routerMode: options.data.config.routerMode
107
- });
108
- server.close();
109
- }
110
- }
111
- export {
112
- build
113
- };