@slidev/cli 0.22.6 → 0.23.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -13
- package/dist/{build-M5EATJMB.mjs → build-IEU5WUDM.mjs} +26 -20
- package/dist/{build-NE7OFJDC.js → build-QDRV2UJ5.js} +28 -22
- package/dist/chunk-6LUF2SCB.mjs +10259 -0
- package/dist/{chunk-3QL4BHWJ.js → chunk-M25N7CYC.js} +173 -147
- package/dist/{chunk-WW3PRZGC.mjs → chunk-NHK2R4LN.mjs} +198 -172
- package/dist/chunk-S6F4YP7Z.js +10259 -0
- package/dist/{chunk-ZRBGXFM7.js → chunk-UJKYYHMF.js} +3 -2
- package/dist/{chunk-WM7KTGRL.mjs → chunk-VWK3TRVU.mjs} +2 -1
- package/dist/cli.js +29 -21
- package/dist/cli.mjs +17 -9
- package/dist/{export-JCHMAWVR.mjs → export-SNR56WLB.mjs} +1 -1
- package/dist/{export-74CUV4GO.js → export-ZTTMEOKV.js} +2 -2
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/index.mjs +3 -3
- package/package.json +30 -29
- package/dist/chunk-DJLELPCD.mjs +0 -9983
- package/dist/chunk-ZCNASYZV.js +0 -9983
|
@@ -56,7 +56,7 @@ var require_fast_deep_equal = _chunkKRCSYS75js.__commonJS.call(void 0, {
|
|
|
56
56
|
});
|
|
57
57
|
|
|
58
58
|
// node/common.ts
|
|
59
|
-
var _fs = require('fs');
|
|
59
|
+
var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
|
|
60
60
|
var _path = require('path');
|
|
61
61
|
var _utils = require('@antfu/utils');
|
|
62
62
|
async function getIndexHtml({ clientRoot, themeRoots, data, userRoot }) {
|
|
@@ -92,15 +92,13 @@ ${(((_b = index.match(/<body>([\s\S]*?)<\/body>/im)) == null ? void 0 : _b[1]) |
|
|
|
92
92
|
|
|
93
93
|
|
|
94
94
|
var _vitepluginwindicss = require('vite-plugin-windicss'); var _vitepluginwindicss2 = _interopRequireDefault(_vitepluginwindicss);
|
|
95
|
-
|
|
96
|
-
// node/plugins/jiti.ts
|
|
97
|
-
var _jiti2 = require('jiti'); var _jiti3 = _interopRequireDefault(_jiti2);
|
|
98
|
-
var jiti = _jiti3.default.call(void 0, __filename);
|
|
95
|
+
var _jiti = require('jiti'); var _jiti2 = _interopRequireDefault(_jiti);
|
|
99
96
|
|
|
100
97
|
// node/plugins/setupNode.ts
|
|
101
98
|
|
|
102
99
|
var _fsextra = require('fs-extra'); var _fsextra2 = _interopRequireDefault(_fsextra);
|
|
103
100
|
|
|
101
|
+
|
|
104
102
|
function deepMerge(a, b, rootPath = "") {
|
|
105
103
|
a = _chunkKRCSYS75js.__spreadValues.call(void 0, {}, a);
|
|
106
104
|
Object.keys(b).forEach((key) => {
|
|
@@ -118,7 +116,7 @@ async function loadSetups(roots, name, arg, initial, merge = true) {
|
|
|
118
116
|
for (const root of roots) {
|
|
119
117
|
const path = _path.resolve.call(void 0, root, "setup", name);
|
|
120
118
|
if (_fsextra.existsSync.call(void 0, path)) {
|
|
121
|
-
const { default: setup } =
|
|
119
|
+
const { default: setup } = _jiti2.default.call(void 0, __filename)(path);
|
|
122
120
|
const result = await setup(arg);
|
|
123
121
|
if (result !== null) {
|
|
124
122
|
returns = merge ? deepMerge(returns, result) : result;
|
|
@@ -136,7 +134,7 @@ async function createWindiCSSPlugin({ themeRoots, clientRoot, userRoot, roots, d
|
|
|
136
134
|
_path.resolve.call(void 0, clientRoot, "windi.config.ts")
|
|
137
135
|
]);
|
|
138
136
|
const configFile = configFiles.find((i) => _fs.existsSync.call(void 0, i));
|
|
139
|
-
let config =
|
|
137
|
+
let config = _jiti2.default.call(void 0, __filename)(configFile);
|
|
140
138
|
if (config.default)
|
|
141
139
|
config = config.default;
|
|
142
140
|
config = await loadSetups(roots, "windicss.ts", {}, config, true);
|
|
@@ -171,42 +169,134 @@ async function createWindiCSSPlugin({ themeRoots, clientRoot, userRoot, roots, d
|
|
|
171
169
|
|
|
172
170
|
// node/plugins/preset.ts
|
|
173
171
|
var _pluginvue = require('@vitejs/plugin-vue'); var _pluginvue2 = _interopRequireDefault(_pluginvue);
|
|
174
|
-
var
|
|
175
|
-
var
|
|
172
|
+
var _vite = require('unplugin-icons/vite'); var _vite2 = _interopRequireDefault(_vite);
|
|
173
|
+
var _resolver = require('unplugin-icons/resolver'); var _resolver2 = _interopRequireDefault(_resolver);
|
|
174
|
+
var _vite3 = require('unplugin-vue-components/vite'); var _vite4 = _interopRequireDefault(_vite3);
|
|
176
175
|
var _vitepluginremoteassets = require('vite-plugin-remote-assets'); var _vitepluginremoteassets2 = _interopRequireDefault(_vitepluginremoteassets);
|
|
176
|
+
var _vitepluginvueserverref = require('vite-plugin-vue-server-ref'); var _vitepluginvueserverref2 = _interopRequireDefault(_vitepluginvueserverref);
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
// node/drawings.ts
|
|
177
180
|
|
|
178
181
|
|
|
179
|
-
|
|
182
|
+
var _fastglob = require('fast-glob'); var _fastglob2 = _interopRequireDefault(_fastglob);
|
|
183
|
+
function resolveDrawingsDir(options) {
|
|
184
|
+
return options.data.config.drawings.persist ? _path.resolve.call(void 0, _path.dirname.call(void 0, options.entry), options.data.config.drawings.persist) : void 0;
|
|
185
|
+
}
|
|
186
|
+
async function loadDrawings(options) {
|
|
187
|
+
const dir = resolveDrawingsDir(options);
|
|
188
|
+
if (!dir || !_fsextra2.default.existsSync(dir))
|
|
189
|
+
return {};
|
|
190
|
+
const files = await _fastglob2.default.call(void 0, "*.svg", {
|
|
191
|
+
onlyFiles: true,
|
|
192
|
+
cwd: dir,
|
|
193
|
+
absolute: true
|
|
194
|
+
});
|
|
195
|
+
const obj = {};
|
|
196
|
+
Promise.all(files.map(async (path) => {
|
|
197
|
+
const num = +_path.basename.call(void 0, path, ".svg");
|
|
198
|
+
if (Number.isNaN(num))
|
|
199
|
+
return;
|
|
200
|
+
const content = await _fsextra2.default.readFile(path, "utf8");
|
|
201
|
+
const lines = content.split(/\n/g);
|
|
202
|
+
obj[num.toString()] = lines.slice(1, -1).join("\n");
|
|
203
|
+
}));
|
|
204
|
+
return obj;
|
|
205
|
+
}
|
|
206
|
+
async function writeDarwings(options, drawing) {
|
|
207
|
+
const dir = resolveDrawingsDir(options);
|
|
208
|
+
if (!dir)
|
|
209
|
+
return;
|
|
210
|
+
const width = options.data.config.canvasWidth;
|
|
211
|
+
const height = Math.round(width / options.data.config.aspectRatio);
|
|
212
|
+
const SVG_HEAD = `<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">`;
|
|
213
|
+
await _fsextra2.default.ensureDir(dir);
|
|
214
|
+
return Promise.all(Object.entries(drawing).map(async ([key, value]) => {
|
|
215
|
+
if (!value)
|
|
216
|
+
return;
|
|
217
|
+
const svg = `${SVG_HEAD}
|
|
218
|
+
${value}
|
|
219
|
+
</svg>`;
|
|
220
|
+
await _fsextra2.default.writeFile(_path.join.call(void 0, dir, `${key}.svg`), svg, "utf-8");
|
|
221
|
+
}));
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// node/plugins/extendConfig.ts
|
|
180
225
|
|
|
181
|
-
var
|
|
226
|
+
var _vite5 = require('vite');
|
|
182
227
|
var _isinstalledglobally = require('is-installed-globally'); var _isinstalledglobally2 = _interopRequireDefault(_isinstalledglobally);
|
|
228
|
+
var _resolveglobal = require('resolve-global'); var _resolveglobal2 = _interopRequireDefault(_resolveglobal);
|
|
229
|
+
|
|
183
230
|
|
|
184
231
|
// ../client/package.json
|
|
185
232
|
var dependencies = {
|
|
186
|
-
"@antfu/utils": "^0.
|
|
233
|
+
"@antfu/utils": "^0.3.0",
|
|
187
234
|
"@slidev/parser": "workspace:*",
|
|
188
235
|
"@slidev/types": "workspace:*",
|
|
189
|
-
"@vueuse/core": "^
|
|
236
|
+
"@vueuse/core": "^6.3.3",
|
|
190
237
|
"@vueuse/head": "^0.6.0",
|
|
191
|
-
"@vueuse/motion": "^1.
|
|
192
|
-
codemirror: "^5.62.
|
|
238
|
+
"@vueuse/motion": "^1.6.0",
|
|
239
|
+
codemirror: "^5.62.3",
|
|
240
|
+
drauu: "^0.1.0",
|
|
193
241
|
"file-saver": "^2.0.5",
|
|
194
|
-
"js-base64": "^3.
|
|
242
|
+
"js-base64": "^3.7.0",
|
|
195
243
|
"js-yaml": "^4.1.0",
|
|
196
|
-
katex: "^0.13.
|
|
197
|
-
mermaid: "8.
|
|
198
|
-
"monaco-editor": "^0.
|
|
199
|
-
nanoid: "^3.1.
|
|
200
|
-
prettier: "^2.
|
|
244
|
+
katex: "^0.13.18",
|
|
245
|
+
mermaid: "^8.12.1",
|
|
246
|
+
"monaco-editor": "^0.27.0",
|
|
247
|
+
nanoid: "^3.1.25",
|
|
248
|
+
prettier: "^2.4.0",
|
|
201
249
|
recordrtc: "^5.6.2",
|
|
202
250
|
resolve: "^1.20.0",
|
|
203
|
-
"vite-plugin-windicss": "^1.2
|
|
204
|
-
vue: "^3.
|
|
205
|
-
"vue-router": "^4.0.
|
|
206
|
-
windicss: "^3.1.
|
|
251
|
+
"vite-plugin-windicss": "^1.4.2",
|
|
252
|
+
vue: "^3.2.11",
|
|
253
|
+
"vue-router": "^4.0.11",
|
|
254
|
+
windicss: "^3.1.7"
|
|
207
255
|
};
|
|
208
256
|
|
|
209
|
-
// node/
|
|
257
|
+
// node/vite/searchRoot.ts
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
var ROOT_FILES = [
|
|
261
|
+
"pnpm-workspace.yaml"
|
|
262
|
+
];
|
|
263
|
+
function hasWorkspacePackageJSON(root) {
|
|
264
|
+
const path = _path.join.call(void 0, root, "package.json");
|
|
265
|
+
try {
|
|
266
|
+
_fs2.default.accessSync(path, _fs2.default.constants.R_OK);
|
|
267
|
+
} catch (e2) {
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
const content = JSON.parse(_fs2.default.readFileSync(path, "utf-8")) || {};
|
|
271
|
+
return !!content.workspaces;
|
|
272
|
+
}
|
|
273
|
+
function hasRootFile(root) {
|
|
274
|
+
return ROOT_FILES.some((file) => _fs2.default.existsSync(_path.join.call(void 0, root, file)));
|
|
275
|
+
}
|
|
276
|
+
function hasPackageJSON(root) {
|
|
277
|
+
const path = _path.join.call(void 0, root, "package.json");
|
|
278
|
+
return _fs2.default.existsSync(path);
|
|
279
|
+
}
|
|
280
|
+
function searchForPackageRoot(current, root = current) {
|
|
281
|
+
if (hasPackageJSON(current))
|
|
282
|
+
return current;
|
|
283
|
+
const dir = _path.dirname.call(void 0, current);
|
|
284
|
+
if (!dir || dir === current)
|
|
285
|
+
return root;
|
|
286
|
+
return searchForPackageRoot(dir, root);
|
|
287
|
+
}
|
|
288
|
+
function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
|
|
289
|
+
if (hasRootFile(current))
|
|
290
|
+
return current;
|
|
291
|
+
if (hasWorkspacePackageJSON(current))
|
|
292
|
+
return current;
|
|
293
|
+
const dir = _path.dirname.call(void 0, current);
|
|
294
|
+
if (!dir || dir === current)
|
|
295
|
+
return root;
|
|
296
|
+
return searchForWorkspaceRoot(dir, root);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// node/plugins/extendConfig.ts
|
|
210
300
|
var EXCLUDE = [
|
|
211
301
|
"@slidev/shared",
|
|
212
302
|
"@slidev/types",
|
|
@@ -221,11 +311,7 @@ function createConfigPlugin(options) {
|
|
|
221
311
|
name: "slidev:config",
|
|
222
312
|
config(config) {
|
|
223
313
|
const injection = {
|
|
224
|
-
define:
|
|
225
|
-
__SLIDEV_CLIENT_ROOT__: JSON.stringify(_chunkKRCSYS75js.toAtFS.call(void 0, options.clientRoot)),
|
|
226
|
-
__SLIDEV_HASH_ROUTE__: options.data.config.routerMode === "hash",
|
|
227
|
-
__DEV__: options.mode === "dev" ? "true" : "false"
|
|
228
|
-
},
|
|
314
|
+
define: getDefine(options),
|
|
229
315
|
resolve: {
|
|
230
316
|
alias: {
|
|
231
317
|
"@slidev/client/": `${_chunkKRCSYS75js.toAtFS.call(void 0, options.clientRoot)}/`
|
|
@@ -243,13 +329,19 @@ function createConfigPlugin(options) {
|
|
|
243
329
|
"prettier/esm/parser-babel",
|
|
244
330
|
"prettier/esm/parser-html",
|
|
245
331
|
"prettier/esm/parser-typescript",
|
|
246
|
-
"mermaid/dist/mermaid.min"
|
|
332
|
+
"mermaid/dist/mermaid.min",
|
|
333
|
+
"vite-plugin-vue-server-ref/client"
|
|
247
334
|
],
|
|
248
335
|
exclude: EXCLUDE
|
|
249
336
|
},
|
|
250
337
|
server: {
|
|
251
338
|
fs: {
|
|
252
|
-
strict: true
|
|
339
|
+
strict: true,
|
|
340
|
+
allow: _utils.uniq.call(void 0, [
|
|
341
|
+
searchForWorkspaceRoot(options.userRoot),
|
|
342
|
+
searchForWorkspaceRoot(options.cliRoot),
|
|
343
|
+
..._isinstalledglobally2.default ? [_path.dirname.call(void 0, _resolveglobal2.default.call(void 0, "@slidev/client/package.json"))] : []
|
|
344
|
+
])
|
|
253
345
|
}
|
|
254
346
|
}
|
|
255
347
|
};
|
|
@@ -258,12 +350,13 @@ function createConfigPlugin(options) {
|
|
|
258
350
|
injection.root = options.cliRoot;
|
|
259
351
|
injection.resolve.alias.vue = `${_chunkKRCSYS75js.resolveImportPath.call(void 0, "vue/dist/vue.esm-browser.js", true)}`;
|
|
260
352
|
}
|
|
261
|
-
return
|
|
353
|
+
return _vite5.mergeConfig.call(void 0, config, injection);
|
|
262
354
|
},
|
|
263
355
|
configureServer(server) {
|
|
264
356
|
return () => {
|
|
265
357
|
server.middlewares.use(async (req, res, next) => {
|
|
266
358
|
if (req.url.endsWith(".html")) {
|
|
359
|
+
res.setHeader("Content-Type", "text/html");
|
|
267
360
|
res.statusCode = 200;
|
|
268
361
|
res.end(await getIndexHtml(options));
|
|
269
362
|
return;
|
|
@@ -274,12 +367,21 @@ function createConfigPlugin(options) {
|
|
|
274
367
|
}
|
|
275
368
|
};
|
|
276
369
|
}
|
|
370
|
+
function getDefine(options) {
|
|
371
|
+
return {
|
|
372
|
+
__SLIDEV_CLIENT_ROOT__: JSON.stringify(_chunkKRCSYS75js.toAtFS.call(void 0, options.clientRoot)),
|
|
373
|
+
__SLIDEV_HASH_ROUTE__: JSON.stringify(options.data.config.routerMode === "hash"),
|
|
374
|
+
__SLIDEV_FEATURE_DRAWINGS__: JSON.stringify(options.data.config.drawings.enabled === true || options.data.config.drawings.enabled === options.mode),
|
|
375
|
+
__SLIDEV_FEATURE_DRAWINGS_PERSIST__: JSON.stringify(!!options.data.config.drawings.persist === true),
|
|
376
|
+
__DEV__: options.mode === "dev" ? "true" : "false"
|
|
377
|
+
};
|
|
378
|
+
}
|
|
277
379
|
|
|
278
380
|
// node/plugins/loaders.ts
|
|
279
381
|
var import_fast_deep_equal = _chunkKRCSYS75js.__toModule.call(void 0, require_fast_deep_equal());
|
|
280
382
|
|
|
281
383
|
|
|
282
|
-
|
|
384
|
+
|
|
283
385
|
|
|
284
386
|
var _markdownit = require('markdown-it'); var _markdownit2 = _interopRequireDefault(_markdownit);
|
|
285
387
|
var _markdownitlinkattributes = require('markdown-it-link-attributes'); var _markdownitlinkattributes2 = _interopRequireDefault(_markdownitlinkattributes);
|
|
@@ -292,13 +394,13 @@ var _fs3 = require('@slidev/parser/fs');
|
|
|
292
394
|
var regexId = /^\/\@slidev\/slide\/(\d+)\.(md|json)(?:\?import)?$/;
|
|
293
395
|
var regexIdQuery = /(\d+?)\.(md|json)$/;
|
|
294
396
|
function getBodyJson(req) {
|
|
295
|
-
return new Promise((
|
|
397
|
+
return new Promise((resolve5, reject) => {
|
|
296
398
|
let body = "";
|
|
297
399
|
req.on("data", (chunk) => body += chunk);
|
|
298
400
|
req.on("error", reject);
|
|
299
401
|
req.on("end", () => {
|
|
300
402
|
try {
|
|
301
|
-
|
|
403
|
+
resolve5(JSON.parse(body) || {});
|
|
302
404
|
} catch (e) {
|
|
303
405
|
reject(e);
|
|
304
406
|
}
|
|
@@ -410,7 +512,7 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, userRoot, roo
|
|
|
410
512
|
return md2;
|
|
411
513
|
}
|
|
412
514
|
}));
|
|
413
|
-
} catch (
|
|
515
|
+
} catch (e3) {
|
|
414
516
|
}
|
|
415
517
|
}))).flatMap((i) => i || []);
|
|
416
518
|
hmrPages.clear();
|
|
@@ -489,6 +591,7 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, userRoot, roo
|
|
|
489
591
|
const layoutName = (frontmatter == null ? void 0 : frontmatter.layout) || (pageNo === 0 ? "cover" : "default");
|
|
490
592
|
if (!layouts[layoutName])
|
|
491
593
|
throw new Error(`Unknown layout "${layoutName}"`);
|
|
594
|
+
delete frontmatter.title;
|
|
492
595
|
const imports = [
|
|
493
596
|
`import InjectedLayout from "${_chunkKRCSYS75js.toAtFS.call(void 0, layouts[layoutName])}"`,
|
|
494
597
|
`const frontmatter = ${JSON.stringify(frontmatter)}`
|
|
@@ -653,7 +756,7 @@ export default {
|
|
|
653
756
|
}
|
|
654
757
|
}
|
|
655
758
|
|
|
656
|
-
// node/plugins/
|
|
759
|
+
// node/plugins/monacoTransform.ts
|
|
657
760
|
|
|
658
761
|
|
|
659
762
|
|
|
@@ -669,7 +772,7 @@ function createMonacoTypesLoader() {
|
|
|
669
772
|
const match = id.match(/^\/\@slidev-monaco-types\/(.*)$/);
|
|
670
773
|
if (match) {
|
|
671
774
|
const pkg = match[1];
|
|
672
|
-
const info =
|
|
775
|
+
const info = _vite5.resolvePackageData.call(void 0, pkg, process.cwd());
|
|
673
776
|
if (!info)
|
|
674
777
|
return;
|
|
675
778
|
const typePath = info.data.types || info.data.typings;
|
|
@@ -735,98 +838,6 @@ function createClientSetupPlugin({ clientRoot, themeRoots, userRoot }) {
|
|
|
735
838
|
};
|
|
736
839
|
}
|
|
737
840
|
|
|
738
|
-
// node/plugins/server-ref.ts
|
|
739
|
-
var PREFIX = "/@server-ref/";
|
|
740
|
-
function VitePluginServerRef(options = {}) {
|
|
741
|
-
const {
|
|
742
|
-
dataMap = {},
|
|
743
|
-
debounceMs = 10,
|
|
744
|
-
debug = true
|
|
745
|
-
} = options;
|
|
746
|
-
return {
|
|
747
|
-
name: "vite-plugin-server-ref",
|
|
748
|
-
resolveId(id) {
|
|
749
|
-
return id.startsWith(PREFIX) ? id : null;
|
|
750
|
-
},
|
|
751
|
-
configureServer(server) {
|
|
752
|
-
server.middlewares.use(async (req, res, next) => {
|
|
753
|
-
var _a, _b;
|
|
754
|
-
if (!((_a = req.url) == null ? void 0 : _a.startsWith(PREFIX)) || req.method !== "POST")
|
|
755
|
-
return next();
|
|
756
|
-
const name = req.url.slice(PREFIX.length);
|
|
757
|
-
const { data, timestamp } = await getBodyJson(req);
|
|
758
|
-
const module = server.moduleGraph.getModuleById(PREFIX + name);
|
|
759
|
-
if (module)
|
|
760
|
-
server.moduleGraph.invalidateModule(module);
|
|
761
|
-
dataMap[name] = data;
|
|
762
|
-
server.ws.send({
|
|
763
|
-
type: "custom",
|
|
764
|
-
event: "server-ref",
|
|
765
|
-
data: {
|
|
766
|
-
name,
|
|
767
|
-
data,
|
|
768
|
-
timestamp
|
|
769
|
-
}
|
|
770
|
-
});
|
|
771
|
-
(_b = options.onChanged) == null ? void 0 : _b.call(options, name, data, timestamp);
|
|
772
|
-
res.write("");
|
|
773
|
-
res.end();
|
|
774
|
-
});
|
|
775
|
-
},
|
|
776
|
-
load(id) {
|
|
777
|
-
var _a;
|
|
778
|
-
if (!id.startsWith(PREFIX))
|
|
779
|
-
return;
|
|
780
|
-
const name = id.slice(PREFIX.length);
|
|
781
|
-
return `
|
|
782
|
-
import { ref, watch } from "vue"
|
|
783
|
-
|
|
784
|
-
const data = ref(${JSON.stringify((_a = dataMap[name]) != null ? _a : null)})
|
|
785
|
-
|
|
786
|
-
if (import.meta.hot) {
|
|
787
|
-
${debug ? `console.log("[server-ref] [${name}] ref", data)` : ""}
|
|
788
|
-
${debug ? `console.log("[server-ref] [${name}] initial", data.value)` : ""}
|
|
789
|
-
|
|
790
|
-
let skipNext = false
|
|
791
|
-
let timer = null
|
|
792
|
-
import.meta.hot.on("server-ref", (payload) =>{
|
|
793
|
-
if (payload.name !== "${name}")
|
|
794
|
-
return
|
|
795
|
-
skipNext = true
|
|
796
|
-
data.value = payload.data
|
|
797
|
-
${debug ? `console.log("[server-ref] [${name}] incoming", payload.data)` : ""}
|
|
798
|
-
})
|
|
799
|
-
watch(data, (v) => {
|
|
800
|
-
if (skipNext) {
|
|
801
|
-
skipNext = false
|
|
802
|
-
return
|
|
803
|
-
}
|
|
804
|
-
if (timer)
|
|
805
|
-
clearTimeout(timer)
|
|
806
|
-
|
|
807
|
-
timer = setTimeout(()=>{
|
|
808
|
-
${debug ? `console.log("[server-ref] [${name}] outgoing", data.value)` : ""}
|
|
809
|
-
fetch('${PREFIX + name}', {
|
|
810
|
-
method: 'POST',
|
|
811
|
-
headers: {
|
|
812
|
-
'Content-Type': 'application/json',
|
|
813
|
-
},
|
|
814
|
-
body: JSON.stringify({
|
|
815
|
-
data: data.value,
|
|
816
|
-
timestamp: Date.now(),
|
|
817
|
-
})
|
|
818
|
-
})
|
|
819
|
-
}, ${debounceMs})
|
|
820
|
-
}, { flush: 'sync', deep: true })
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
export default data
|
|
824
|
-
`;
|
|
825
|
-
}
|
|
826
|
-
};
|
|
827
|
-
}
|
|
828
|
-
var server_ref_default = VitePluginServerRef;
|
|
829
|
-
|
|
830
841
|
// node/plugins/markdown.ts
|
|
831
842
|
var _vitepluginmd = require('vite-plugin-md'); var _vitepluginmd2 = _interopRequireDefault(_vitepluginmd);
|
|
832
843
|
var _jsbase64 = require('js-base64'); var _jsbase642 = _interopRequireDefault(_jsbase64);
|
|
@@ -1244,16 +1255,21 @@ function escapeVueInCode(md2) {
|
|
|
1244
1255
|
return md2.replace(/{{(.*?)}}/g, "{{$1}}");
|
|
1245
1256
|
}
|
|
1246
1257
|
|
|
1247
|
-
// node/plugins/
|
|
1248
|
-
|
|
1249
|
-
|
|
1258
|
+
// node/plugins/patchTransform.ts
|
|
1259
|
+
|
|
1260
|
+
function createFixPlugins(options) {
|
|
1261
|
+
const define = _utils.objectEntries.call(void 0, getDefine(options));
|
|
1250
1262
|
return [
|
|
1251
1263
|
{
|
|
1252
1264
|
name: "slidev:flags",
|
|
1253
1265
|
enforce: "pre",
|
|
1254
1266
|
transform(code, id) {
|
|
1255
|
-
if (id.endsWith(".vue"))
|
|
1256
|
-
|
|
1267
|
+
if (id.endsWith(".vue")) {
|
|
1268
|
+
define.forEach(([from, to]) => {
|
|
1269
|
+
code = code.replace(new RegExp(from, "g"), to);
|
|
1270
|
+
});
|
|
1271
|
+
return code;
|
|
1272
|
+
}
|
|
1257
1273
|
}
|
|
1258
1274
|
}
|
|
1259
1275
|
];
|
|
@@ -1305,12 +1321,13 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
|
|
|
1305
1321
|
}, vueOptions == null ? void 0 : vueOptions.template)
|
|
1306
1322
|
}, vueOptions));
|
|
1307
1323
|
const MarkdownPlugin = await createMarkdownPlugin(options, pluginOptions);
|
|
1324
|
+
const drawingData = await loadDrawings(options);
|
|
1308
1325
|
return [
|
|
1309
1326
|
await createWindiCSSPlugin(options, pluginOptions),
|
|
1310
1327
|
MarkdownPlugin,
|
|
1311
1328
|
VuePlugin,
|
|
1312
1329
|
createSlidesLoader(options, pluginOptions, serverOptions, VuePlugin, MarkdownPlugin),
|
|
1313
|
-
|
|
1330
|
+
_vite4.default.call(void 0, _chunkKRCSYS75js.__spreadValues.call(void 0, {
|
|
1314
1331
|
extensions: ["vue", "md", "ts"],
|
|
1315
1332
|
dirs: [
|
|
1316
1333
|
`${clientRoot}/builtin`,
|
|
@@ -1319,14 +1336,15 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
|
|
|
1319
1336
|
"src/components",
|
|
1320
1337
|
"components"
|
|
1321
1338
|
],
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1339
|
+
include: [/\.vue$/, /\.vue\?vue/, /\.md$/],
|
|
1340
|
+
exclude: [],
|
|
1341
|
+
resolvers: [
|
|
1342
|
+
_resolver2.default.call(void 0, {
|
|
1343
|
+
prefix: ""
|
|
1326
1344
|
})
|
|
1327
1345
|
]
|
|
1328
1346
|
}, componentsOptions)),
|
|
1329
|
-
|
|
1347
|
+
_vite2.default.call(void 0, _chunkKRCSYS75js.__spreadValues.call(void 0, {}, iconsOptions)),
|
|
1330
1348
|
config.remoteAssets === true || config.remoteAssets === mode ? _vitepluginremoteassets2.default.call(void 0, _chunkKRCSYS75js.__spreadValues.call(void 0, {
|
|
1331
1349
|
rules: [
|
|
1332
1350
|
..._vitepluginremoteassets.DefaultRules,
|
|
@@ -1338,13 +1356,21 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
|
|
|
1338
1356
|
resolveMode: (id) => id.endsWith("index.html") ? "relative" : "@fs",
|
|
1339
1357
|
awaitDownload: mode === "build"
|
|
1340
1358
|
}, remoteAssetsOptions)) : null,
|
|
1341
|
-
|
|
1342
|
-
|
|
1359
|
+
_vitepluginvueserverref2.default.call(void 0, {
|
|
1360
|
+
debug: process.env.NODE_ENV === "development",
|
|
1361
|
+
state: {
|
|
1343
1362
|
sync: false,
|
|
1344
|
-
|
|
1363
|
+
nav: {
|
|
1345
1364
|
page: 0,
|
|
1346
1365
|
clicks: 0
|
|
1347
|
-
}
|
|
1366
|
+
},
|
|
1367
|
+
drawings: drawingData
|
|
1368
|
+
},
|
|
1369
|
+
onChanged(key, data, patch) {
|
|
1370
|
+
if (!options.data.config.drawings.persist)
|
|
1371
|
+
return;
|
|
1372
|
+
if (key === "drawings")
|
|
1373
|
+
writeDarwings(options, patch != null ? patch : data);
|
|
1348
1374
|
}
|
|
1349
1375
|
}),
|
|
1350
1376
|
createConfigPlugin(options),
|