@slidev/cli 0.41.0 → 0.42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{build-KUT3K5TN.mjs → build-2HNZGPOJ.mjs} +5 -3
- package/dist/{build-3GLTTQXV.js → build-FWNZEWR3.js} +9 -7
- package/dist/chunk-6XVZLT3I.mjs +35 -0
- package/dist/chunk-6ZL4B4HQ.js +76 -0
- package/dist/{chunk-ATJEPFM2.mjs → chunk-7S3GFZIX.mjs} +8 -6
- package/dist/{chunk-AV6T2PNJ.mjs → chunk-C5RFODBO.mjs} +63 -184
- package/dist/chunk-CIUEQ4TI.mjs +76 -0
- package/dist/{chunk-46ATDXDT.js → chunk-DZKW5SLI.js} +82 -80
- package/dist/{chunk-UJUM4LW4.js → chunk-F4LLVFU7.js} +56 -177
- package/dist/chunk-KKGXM3XL.js +35 -0
- package/dist/{chunk-CTG3GV2W.mjs → chunk-L5QH2WZE.mjs} +1 -71
- package/dist/chunk-MJQETB73.js +68 -0
- package/dist/chunk-X7P5WRYP.mjs +65 -0
- package/dist/chunk-YI4ZV27K.js +65 -0
- package/dist/cli.js +38 -36
- package/dist/cli.mjs +14 -12
- package/dist/{export-KPPDUO6Z.mjs → export-KRS4L4HC.mjs} +2 -1
- package/dist/{export-GTPZJWVE.js → export-PN4EOI4Z.js} +4 -3
- package/dist/index.js +8 -4
- package/dist/index.mjs +8 -4
- package/dist/unocss-2CJUFE63.js +46 -0
- package/dist/unocss-ZLGTDCD7.mjs +46 -0
- package/dist/windicss-OSTDR2Z6.mjs +9 -0
- package/dist/windicss-YNIIPANV.js +9 -0
- package/package.json +8 -8
- package/dist/chunk-GE7W2DBE.js +0 -138
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
loadSetups
|
|
3
|
+
} from "./chunk-6XVZLT3I.mjs";
|
|
4
|
+
import {
|
|
5
5
|
generateGoogleFontsUrl,
|
|
6
6
|
resolveGlobalImportPath,
|
|
7
7
|
resolveImportPath,
|
|
8
8
|
stringifyMarkdownTokens,
|
|
9
9
|
toAtFS
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-CIUEQ4TI.mjs";
|
|
11
|
+
import {
|
|
12
|
+
__commonJS,
|
|
13
|
+
__require,
|
|
14
|
+
__toESM
|
|
15
|
+
} from "./chunk-L5QH2WZE.mjs";
|
|
11
16
|
|
|
12
17
|
// ../../node_modules/.pnpm/fast-deep-equal@3.1.3/node_modules/fast-deep-equal/index.js
|
|
13
18
|
var require_fast_deep_equal = __commonJS({
|
|
@@ -108,114 +113,24 @@ async function mergeViteConfigs({ addonRoots, themeRoots }, viteConfig, config,
|
|
|
108
113
|
return mergeConfig(viteConfig, config);
|
|
109
114
|
}
|
|
110
115
|
|
|
111
|
-
// node/plugins/setupNode.ts
|
|
112
|
-
import { resolve } from "path";
|
|
113
|
-
import { pathExists } from "fs-extra";
|
|
114
|
-
import { isObject } from "@antfu/utils";
|
|
115
|
-
import jiti from "jiti";
|
|
116
|
-
function deepMerge(a, b, rootPath = "") {
|
|
117
|
-
a = { ...a };
|
|
118
|
-
Object.keys(b).forEach((key) => {
|
|
119
|
-
if (isObject(a[key]))
|
|
120
|
-
a[key] = deepMerge(a[key], b[key], rootPath ? `${rootPath}.${key}` : key);
|
|
121
|
-
else if (Array.isArray(a[key]))
|
|
122
|
-
a[key] = [...a[key], ...b[key]];
|
|
123
|
-
else
|
|
124
|
-
a[key] = b[key];
|
|
125
|
-
});
|
|
126
|
-
return a;
|
|
127
|
-
}
|
|
128
|
-
async function loadSetups(roots, name, arg, initial, merge = true, accumulate) {
|
|
129
|
-
let returns = initial;
|
|
130
|
-
for (const root of roots) {
|
|
131
|
-
const path = resolve(root, "setup", name);
|
|
132
|
-
if (await pathExists(path)) {
|
|
133
|
-
const { default: setup } = jiti(__filename)(path);
|
|
134
|
-
const result = await setup(arg);
|
|
135
|
-
if (result !== null) {
|
|
136
|
-
returns = merge ? deepMerge(returns, result) : accumulate ? accumulate(returns, result) : result;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
return returns;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// node/plugins/windicss.ts
|
|
144
|
-
import { dirname, resolve as resolve2 } from "path";
|
|
145
|
-
import { existsSync as existsSync2 } from "fs";
|
|
146
|
-
import { slash, uniq as uniq2 } from "@antfu/utils";
|
|
147
|
-
import jiti2 from "jiti";
|
|
148
|
-
async function createWindiCSSPlugin({ themeRoots, addonRoots, clientRoot, userRoot, roots, data }, { windicss: windiOptions }) {
|
|
149
|
-
const { default: WindiCSS } = await import("vite-plugin-windicss");
|
|
150
|
-
const { defaultConfigureFiles } = await import("@windicss/config");
|
|
151
|
-
const configFiles = uniq2([
|
|
152
|
-
...defaultConfigureFiles.map((i) => resolve2(userRoot, i)),
|
|
153
|
-
...themeRoots.map((i) => `${i}/windi.config.ts`),
|
|
154
|
-
...addonRoots.map((i) => `${i}/windi.config.ts`),
|
|
155
|
-
resolve2(clientRoot, "windi.config.ts")
|
|
156
|
-
]);
|
|
157
|
-
const configFile = configFiles.find((i) => existsSync2(i));
|
|
158
|
-
let config = jiti2(__filename)(configFile);
|
|
159
|
-
if (config.default)
|
|
160
|
-
config = config.default;
|
|
161
|
-
config = await loadSetups(roots, "windicss.ts", {}, config, true);
|
|
162
|
-
return WindiCSS(
|
|
163
|
-
{
|
|
164
|
-
configFiles: [configFile],
|
|
165
|
-
config,
|
|
166
|
-
onConfigResolved(config2) {
|
|
167
|
-
if (!config2.theme)
|
|
168
|
-
config2.theme = {};
|
|
169
|
-
if (!config2.theme.extend)
|
|
170
|
-
config2.theme.extend = {};
|
|
171
|
-
if (!config2.theme.extend.fontFamily)
|
|
172
|
-
config2.theme.extend.fontFamily = {};
|
|
173
|
-
const fontFamily = config2.theme.extend.fontFamily;
|
|
174
|
-
fontFamily.sans || (fontFamily.sans = data.config.fonts.sans.join(","));
|
|
175
|
-
fontFamily.mono || (fontFamily.mono = data.config.fonts.mono.join(","));
|
|
176
|
-
fontFamily.serif || (fontFamily.serif = data.config.fonts.serif.join(","));
|
|
177
|
-
return config2;
|
|
178
|
-
},
|
|
179
|
-
onOptionsResolved(config2) {
|
|
180
|
-
themeRoots.forEach((i) => {
|
|
181
|
-
config2.scanOptions.include.push(`${i}/components/**/*.{vue,ts}`);
|
|
182
|
-
config2.scanOptions.include.push(`${i}/layouts/**/*.{vue,ts}`);
|
|
183
|
-
});
|
|
184
|
-
addonRoots.forEach((i) => {
|
|
185
|
-
config2.scanOptions.include.push(`${i}/components/**/*.{vue,ts}`);
|
|
186
|
-
config2.scanOptions.include.push(`${i}/layouts/**/*.{vue,ts}`);
|
|
187
|
-
});
|
|
188
|
-
config2.scanOptions.include.push(`!${slash(resolve2(userRoot, "node_modules"))}`);
|
|
189
|
-
config2.scanOptions.exclude.push(dirname(resolveImportPath("monaco-editor/package.json", true)));
|
|
190
|
-
config2.scanOptions.exclude.push(dirname(resolveImportPath("katex/package.json", true)));
|
|
191
|
-
config2.scanOptions.exclude.push(dirname(resolveImportPath("prettier/package.json", true)));
|
|
192
|
-
},
|
|
193
|
-
...windiOptions
|
|
194
|
-
}
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
116
|
// node/plugins/preset.ts
|
|
199
117
|
import { join as join8 } from "path";
|
|
200
|
-
import { existsSync as
|
|
118
|
+
import { existsSync as existsSync4 } from "fs";
|
|
201
119
|
import Vue from "@vitejs/plugin-vue";
|
|
202
120
|
import VueJsx from "@vitejs/plugin-vue-jsx";
|
|
203
121
|
import Icons from "unplugin-icons/vite";
|
|
204
122
|
import IconsResolver from "unplugin-icons/resolver";
|
|
205
123
|
import Components from "unplugin-vue-components/vite";
|
|
206
|
-
import RemoteAssets, { DefaultRules } from "vite-plugin-remote-assets";
|
|
207
124
|
import ServerRef from "vite-plugin-vue-server-ref";
|
|
208
125
|
import { notNullish as notNullish2 } from "@antfu/utils";
|
|
209
|
-
import Inspect from "vite-plugin-inspect";
|
|
210
|
-
import { viteStaticCopy } from "vite-plugin-static-copy";
|
|
211
126
|
|
|
212
127
|
// node/drawings.ts
|
|
213
|
-
import { basename, dirname
|
|
128
|
+
import { basename, dirname, join as join2, resolve } from "path";
|
|
214
129
|
import fs2 from "fs-extra";
|
|
215
130
|
import fg from "fast-glob";
|
|
216
131
|
function resolveDrawingsDir(options) {
|
|
217
|
-
return options.data.config.drawings.persist ?
|
|
218
|
-
|
|
132
|
+
return options.data.config.drawings.persist ? resolve(
|
|
133
|
+
dirname(options.entry),
|
|
219
134
|
options.data.config.drawings.persist
|
|
220
135
|
) : void 0;
|
|
221
136
|
}
|
|
@@ -261,21 +176,21 @@ ${value}
|
|
|
261
176
|
}
|
|
262
177
|
|
|
263
178
|
// node/plugins/extendConfig.ts
|
|
264
|
-
import { dirname as
|
|
179
|
+
import { dirname as dirname3, join as join4 } from "path";
|
|
265
180
|
import { mergeConfig as mergeConfig2 } from "vite";
|
|
266
181
|
import isInstalledGlobally from "is-installed-globally";
|
|
267
|
-
import { uniq as
|
|
182
|
+
import { uniq as uniq2 } from "@antfu/utils";
|
|
268
183
|
|
|
269
184
|
// ../client/package.json
|
|
270
185
|
var dependencies = {
|
|
271
186
|
"@antfu/utils": "^0.7.2",
|
|
272
187
|
"@slidev/parser": "workspace:*",
|
|
273
188
|
"@slidev/types": "workspace:*",
|
|
274
|
-
"@unocss/reset": "^0.
|
|
189
|
+
"@unocss/reset": "^0.52.4",
|
|
275
190
|
"@vueuse/core": "^10.1.2",
|
|
276
191
|
"@vueuse/head": "^1.1.26",
|
|
277
192
|
"@vueuse/math": "^10.1.2",
|
|
278
|
-
"@vueuse/motion": "^2.0.0
|
|
193
|
+
"@vueuse/motion": "^2.0.0",
|
|
279
194
|
codemirror: "^5.65.5",
|
|
280
195
|
defu: "^6.1.2",
|
|
281
196
|
drauu: "^0.3.2",
|
|
@@ -284,23 +199,23 @@ var dependencies = {
|
|
|
284
199
|
"js-base64": "^3.7.5",
|
|
285
200
|
"js-yaml": "^4.1.0",
|
|
286
201
|
katex: "^0.16.7",
|
|
287
|
-
mermaid: "^10.
|
|
202
|
+
mermaid: "^10.2.0",
|
|
288
203
|
"monaco-editor": "^0.37.1",
|
|
289
204
|
nanoid: "^4.0.2",
|
|
290
205
|
prettier: "^2.8.8",
|
|
291
206
|
recordrtc: "^5.6.2",
|
|
292
207
|
resolve: "^1.22.2",
|
|
293
|
-
unocss: "^0.
|
|
208
|
+
unocss: "^0.52.4",
|
|
294
209
|
"vite-plugin-windicss": "^1.9.0",
|
|
295
|
-
vue: "^3.3.
|
|
296
|
-
"vue-router": "^4.2.
|
|
210
|
+
vue: "^3.3.4",
|
|
211
|
+
"vue-router": "^4.2.1",
|
|
297
212
|
"vue-starport": "^0.3.0",
|
|
298
213
|
windicss: "^3.5.6"
|
|
299
214
|
};
|
|
300
215
|
|
|
301
216
|
// node/vite/searchRoot.ts
|
|
302
217
|
import fs3 from "fs";
|
|
303
|
-
import { dirname as
|
|
218
|
+
import { dirname as dirname2, join as join3 } from "path";
|
|
304
219
|
var ROOT_FILES = [
|
|
305
220
|
// '.git',
|
|
306
221
|
// https://pnpm.js.org/workspaces/
|
|
@@ -331,7 +246,7 @@ function hasPackageJSON(root) {
|
|
|
331
246
|
function searchForPackageRoot(current, root = current) {
|
|
332
247
|
if (hasPackageJSON(current))
|
|
333
248
|
return current;
|
|
334
|
-
const dir =
|
|
249
|
+
const dir = dirname2(current);
|
|
335
250
|
if (!dir || dir === current)
|
|
336
251
|
return root;
|
|
337
252
|
return searchForPackageRoot(dir, root);
|
|
@@ -341,7 +256,7 @@ function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
|
|
|
341
256
|
return current;
|
|
342
257
|
if (hasWorkspacePackageJSON(current))
|
|
343
258
|
return current;
|
|
344
|
-
const dir =
|
|
259
|
+
const dir = dirname2(current);
|
|
345
260
|
if (!dir || dir === current)
|
|
346
261
|
return root;
|
|
347
262
|
return searchForWorkspaceRoot(dir, root);
|
|
@@ -403,10 +318,10 @@ function createConfigPlugin(options) {
|
|
|
403
318
|
server: {
|
|
404
319
|
fs: {
|
|
405
320
|
strict: true,
|
|
406
|
-
allow:
|
|
321
|
+
allow: uniq2([
|
|
407
322
|
searchForWorkspaceRoot(options.userRoot),
|
|
408
323
|
searchForWorkspaceRoot(options.cliRoot),
|
|
409
|
-
...isInstalledGlobally ? [
|
|
324
|
+
...isInstalledGlobally ? [dirname3(resolveGlobalImportPath("@slidev/client/package.json")), dirname3(resolveGlobalImportPath("katex/package.json"))] : []
|
|
410
325
|
])
|
|
411
326
|
}
|
|
412
327
|
},
|
|
@@ -450,22 +365,22 @@ function getDefine(options) {
|
|
|
450
365
|
// node/plugins/loaders.ts
|
|
451
366
|
var import_fast_deep_equal = __toESM(require_fast_deep_equal());
|
|
452
367
|
import { basename as basename2, join as join5 } from "path";
|
|
453
|
-
import { isString, notNullish, objectMap, range, slash
|
|
368
|
+
import { isString, notNullish, objectMap, range, slash, uniq as uniq3 } from "@antfu/utils";
|
|
454
369
|
import fg2 from "fast-glob";
|
|
455
|
-
import fs4, { existsSync as
|
|
370
|
+
import fs4, { existsSync as existsSync2 } from "fs-extra";
|
|
456
371
|
import Markdown from "markdown-it";
|
|
457
372
|
import mila from "markdown-it-link-attributes";
|
|
458
373
|
import * as parser from "@slidev/parser/fs";
|
|
459
374
|
var regexId = /^\/\@slidev\/slide\/(\d+)\.(md|json)(?:\?import)?$/;
|
|
460
375
|
var regexIdQuery = /(\d+?)\.(md|json)$/;
|
|
461
376
|
function getBodyJson(req) {
|
|
462
|
-
return new Promise((
|
|
377
|
+
return new Promise((resolve3, reject) => {
|
|
463
378
|
let body = "";
|
|
464
379
|
req.on("data", (chunk) => body += chunk);
|
|
465
380
|
req.on("error", reject);
|
|
466
381
|
req.on("end", () => {
|
|
467
382
|
try {
|
|
468
|
-
|
|
383
|
+
resolve3(JSON.parse(body) || {});
|
|
469
384
|
} catch (e) {
|
|
470
385
|
reject(e);
|
|
471
386
|
}
|
|
@@ -528,7 +443,7 @@ function createSlidesLoader({ data, entry, clientRoot, themeRoots, addonRoots, u
|
|
|
528
443
|
},
|
|
529
444
|
async handleHotUpdate(ctx) {
|
|
530
445
|
var _a, _b, _c;
|
|
531
|
-
if (!data.entries.some((i) =>
|
|
446
|
+
if (!data.entries.some((i) => slash(i) === ctx.file))
|
|
532
447
|
return;
|
|
533
448
|
await ctx.read();
|
|
534
449
|
const newData = await parser.load(entry, data.themeMeta);
|
|
@@ -702,7 +617,7 @@ ${title}
|
|
|
702
617
|
var _a;
|
|
703
618
|
if (!server)
|
|
704
619
|
return;
|
|
705
|
-
server.watcher.add(((_a = data.entries) == null ? void 0 : _a.map(
|
|
620
|
+
server.watcher.add(((_a = data.entries) == null ? void 0 : _a.map(slash)) || []);
|
|
706
621
|
}
|
|
707
622
|
async function transformMarkdown(code, pageNo, data2) {
|
|
708
623
|
var _a, _b;
|
|
@@ -797,7 +712,7 @@ defineProps<{ no: number | string }>()`);
|
|
|
797
712
|
if (now - _layouts_cache_time < 2e3)
|
|
798
713
|
return _layouts_cache;
|
|
799
714
|
const layouts = {};
|
|
800
|
-
const roots2 =
|
|
715
|
+
const roots2 = uniq3([
|
|
801
716
|
userRoot,
|
|
802
717
|
...themeRoots,
|
|
803
718
|
...addonRoots,
|
|
@@ -827,7 +742,7 @@ defineProps<{ no: number | string }>()`);
|
|
|
827
742
|
`import "${toAtFS(join5(clientRoot, "styles/code.css"))}"`,
|
|
828
743
|
`import "${toAtFS(join5(clientRoot, "styles/transitions.css"))}"`
|
|
829
744
|
];
|
|
830
|
-
const roots2 =
|
|
745
|
+
const roots2 = uniq3([
|
|
831
746
|
...themeRoots,
|
|
832
747
|
...addonRoots,
|
|
833
748
|
userRoot
|
|
@@ -841,7 +756,7 @@ defineProps<{ no: number | string }>()`);
|
|
|
841
756
|
join5(root, "style.css")
|
|
842
757
|
];
|
|
843
758
|
for (const style of styles) {
|
|
844
|
-
if (
|
|
759
|
+
if (existsSync2(style)) {
|
|
845
760
|
imports.push(`import "${toAtFS(style)}"`);
|
|
846
761
|
continue;
|
|
847
762
|
}
|
|
@@ -913,8 +828,7 @@ ${Object.entries(layouts).map(([k, v]) => `"${k}": ${v}`).join(",\n")}
|
|
|
913
828
|
const redirect = ((_c = i.frontmatter) == null ? void 0 : _c.routeAlias) ? `{ path: '${(_d = i.frontmatter) == null ? void 0 : _d.routeAlias}', redirect: { path: '${no}' } }` : null;
|
|
914
829
|
no += 1;
|
|
915
830
|
return [route, redirect];
|
|
916
|
-
}).flat().filter(notNullish)
|
|
917
|
-
`{ path: "${no}", component: __layout__end, meta: { layout: "end" } }`
|
|
831
|
+
}).flat().filter(notNullish)
|
|
918
832
|
];
|
|
919
833
|
const routesStr = `export default [
|
|
920
834
|
${routes.join(",\n")}
|
|
@@ -981,7 +895,7 @@ export default {
|
|
|
981
895
|
|
|
982
896
|
// node/plugins/monacoTransform.ts
|
|
983
897
|
import { join as join6 } from "path";
|
|
984
|
-
import { slash as
|
|
898
|
+
import { slash as slash2 } from "@antfu/utils";
|
|
985
899
|
async function getPackageData(pkg) {
|
|
986
900
|
const { resolvePackageData } = await eval('import("vite")');
|
|
987
901
|
const info = resolvePackageData(pkg, process.cwd());
|
|
@@ -1010,7 +924,7 @@ function createMonacoTypesLoader() {
|
|
|
1010
924
|
const [info2, typePath2] = packageData;
|
|
1011
925
|
return [
|
|
1012
926
|
"import * as monaco from 'monaco-editor'",
|
|
1013
|
-
`import Type from "${
|
|
927
|
+
`import Type from "${slash2(join6(info2.dir, typePath2))}?raw"`,
|
|
1014
928
|
...Object.keys(info2.data.dependencies || {}).map((i) => `import "/@slidev-monaco-types/${i}"`),
|
|
1015
929
|
`monaco.languages.typescript.typescriptDefaults.addExtraLib(\`declare module "${pkg2}" { \${Type} }\`)`
|
|
1016
930
|
].join("\n");
|
|
@@ -1020,11 +934,11 @@ function createMonacoTypesLoader() {
|
|
|
1020
934
|
}
|
|
1021
935
|
|
|
1022
936
|
// node/plugins/setupClient.ts
|
|
1023
|
-
import { existsSync as
|
|
1024
|
-
import { join as join7, resolve as
|
|
1025
|
-
import { slash as
|
|
937
|
+
import { existsSync as existsSync3 } from "fs";
|
|
938
|
+
import { join as join7, resolve as resolve2 } from "path";
|
|
939
|
+
import { slash as slash3, uniq as uniq4 } from "@antfu/utils";
|
|
1026
940
|
function createClientSetupPlugin({ clientRoot, themeRoots, addonRoots, userRoot }) {
|
|
1027
|
-
const setupEntry =
|
|
941
|
+
const setupEntry = slash3(resolve2(clientRoot, "setup"));
|
|
1028
942
|
return {
|
|
1029
943
|
name: "slidev:setup",
|
|
1030
944
|
enforce: "pre",
|
|
@@ -1037,13 +951,13 @@ function createClientSetupPlugin({ clientRoot, themeRoots, addonRoots, userRoot
|
|
|
1037
951
|
const name = id.slice(setupEntry.length + 1).replace(/\?.*$/, "");
|
|
1038
952
|
const imports = [];
|
|
1039
953
|
const injections = [];
|
|
1040
|
-
const setups =
|
|
954
|
+
const setups = uniq4([
|
|
1041
955
|
...themeRoots,
|
|
1042
956
|
...addonRoots,
|
|
1043
957
|
userRoot
|
|
1044
958
|
]).map((i) => join7(i, "setup", name));
|
|
1045
959
|
setups.forEach((path, idx) => {
|
|
1046
|
-
if (!
|
|
960
|
+
if (!existsSync3(path))
|
|
1047
961
|
return;
|
|
1048
962
|
imports.push(`import __n${idx} from '${toAtFS(path)}'`);
|
|
1049
963
|
let fn = `:AWAIT:__n${idx}`;
|
|
@@ -1078,7 +992,7 @@ function createClientSetupPlugin({ clientRoot, themeRoots, addonRoots, userRoot
|
|
|
1078
992
|
// node/plugins/markdown.ts
|
|
1079
993
|
import Markdown2 from "vite-plugin-vue-markdown";
|
|
1080
994
|
import * as base64 from "js-base64";
|
|
1081
|
-
import { slash as
|
|
995
|
+
import { slash as slash4 } from "@antfu/utils";
|
|
1082
996
|
import mila2 from "markdown-it-link-attributes";
|
|
1083
997
|
import mif from "markdown-it-footnote";
|
|
1084
998
|
import { taskLists } from "@hedgedoc/markdown-it-plugins";
|
|
@@ -1358,7 +1272,7 @@ var DEFAULT_SHIKI_OPTIONS = {
|
|
|
1358
1272
|
};
|
|
1359
1273
|
async function createMarkdownPlugin({ data: { config }, roots, mode, entry }, { markdown: mdOptions }) {
|
|
1360
1274
|
const setups = [];
|
|
1361
|
-
const entryPath =
|
|
1275
|
+
const entryPath = slash4(entry);
|
|
1362
1276
|
if (config.highlighter === "shiki") {
|
|
1363
1277
|
const { getHighlighter } = await import("shiki");
|
|
1364
1278
|
const shikiOptions = await loadSetups(roots, "shiki.ts", Shiki, DEFAULT_SHIKI_OPTIONS, false);
|
|
@@ -1542,40 +1456,6 @@ function createFixPlugins(options) {
|
|
|
1542
1456
|
];
|
|
1543
1457
|
}
|
|
1544
1458
|
|
|
1545
|
-
// node/plugins/unocss.ts
|
|
1546
|
-
import { resolve as resolve5 } from "path";
|
|
1547
|
-
import { existsSync as existsSync5 } from "fs";
|
|
1548
|
-
import { deepMerge as deepMerge2, uniq as uniq6 } from "@antfu/utils";
|
|
1549
|
-
import jiti3 from "jiti";
|
|
1550
|
-
async function createUnocssPlugin({ themeRoots, addonRoots, clientRoot, roots, userRoot, data }, { unocss: unoOptions }) {
|
|
1551
|
-
var _a, _b, _c, _d;
|
|
1552
|
-
const UnoCSS = await import("unocss/vite").then((r) => r.default);
|
|
1553
|
-
const configFiles = uniq6([
|
|
1554
|
-
resolve5(userRoot, "uno.config.ts"),
|
|
1555
|
-
resolve5(userRoot, "unocss.config.ts"),
|
|
1556
|
-
...themeRoots.map((i) => `${i}/uno.config.ts`),
|
|
1557
|
-
...themeRoots.map((i) => `${i}/unocss.config.ts`),
|
|
1558
|
-
...addonRoots.map((i) => `${i}/uno.config.ts`),
|
|
1559
|
-
...addonRoots.map((i) => `${i}/unocss.config.ts`),
|
|
1560
|
-
resolve5(clientRoot, "uno.config.ts"),
|
|
1561
|
-
resolve5(clientRoot, "unocss.config.ts")
|
|
1562
|
-
]);
|
|
1563
|
-
const configFile = configFiles.find((i) => existsSync5(i));
|
|
1564
|
-
let config = jiti3(__filename)(configFile);
|
|
1565
|
-
if ("default" in config)
|
|
1566
|
-
config = config.default;
|
|
1567
|
-
config = await loadSetups(roots, "unocss.ts", {}, config, true);
|
|
1568
|
-
config.theme || (config.theme = {});
|
|
1569
|
-
(_a = config.theme).fontFamily || (_a.fontFamily = {});
|
|
1570
|
-
(_b = config.theme.fontFamily).sans || (_b.sans = data.config.fonts.sans.join(","));
|
|
1571
|
-
(_c = config.theme.fontFamily).mono || (_c.mono = data.config.fonts.mono.join(","));
|
|
1572
|
-
(_d = config.theme.fontFamily).serif || (_d.serif = data.config.fonts.serif.join(","));
|
|
1573
|
-
return UnoCSS({
|
|
1574
|
-
configFile: false,
|
|
1575
|
-
...deepMerge2(config, unoOptions || {})
|
|
1576
|
-
});
|
|
1577
|
-
}
|
|
1578
|
-
|
|
1579
1459
|
// node/plugins/preset.ts
|
|
1580
1460
|
var customElements = /* @__PURE__ */ new Set([
|
|
1581
1461
|
// katex
|
|
@@ -1639,8 +1519,8 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
|
|
|
1639
1519
|
const VueJsxPlugin = VueJsx(vuejsxOptions);
|
|
1640
1520
|
const MarkdownPlugin = await createMarkdownPlugin(options, pluginOptions);
|
|
1641
1521
|
const drawingData = await loadDrawings(options);
|
|
1642
|
-
const publicRoots = themeRoots.map((i) => join8(i, "public")).filter(
|
|
1643
|
-
|
|
1522
|
+
const publicRoots = themeRoots.map((i) => join8(i, "public")).filter(existsSync4);
|
|
1523
|
+
const plugins = [
|
|
1644
1524
|
MarkdownPlugin,
|
|
1645
1525
|
VueJsxPlugin,
|
|
1646
1526
|
VuePlugin,
|
|
@@ -1671,9 +1551,9 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
|
|
|
1671
1551
|
autoInstall: true,
|
|
1672
1552
|
...iconsOptions
|
|
1673
1553
|
}),
|
|
1674
|
-
config.remoteAssets === true || config.remoteAssets === mode ?
|
|
1554
|
+
config.remoteAssets === true || config.remoteAssets === mode ? import("vite-plugin-remote-assets").then((r) => r.default({
|
|
1675
1555
|
rules: [
|
|
1676
|
-
...DefaultRules,
|
|
1556
|
+
...r.DefaultRules,
|
|
1677
1557
|
{
|
|
1678
1558
|
match: /\b(https?:\/\/image.unsplash\.com.*?)(?=[`'")\]])/ig,
|
|
1679
1559
|
ext: ".png"
|
|
@@ -1682,7 +1562,7 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
|
|
|
1682
1562
|
resolveMode: (id) => id.endsWith("index.html") ? "relative" : "@fs",
|
|
1683
1563
|
awaitDownload: mode === "build",
|
|
1684
1564
|
...remoteAssetsOptions
|
|
1685
|
-
}) : null,
|
|
1565
|
+
})) : null,
|
|
1686
1566
|
ServerRef({
|
|
1687
1567
|
debug: process.env.NODE_ENV === "development",
|
|
1688
1568
|
state: {
|
|
@@ -1702,30 +1582,29 @@ async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
|
|
|
1702
1582
|
writeDrawings(options, patch ?? data);
|
|
1703
1583
|
}
|
|
1704
1584
|
}),
|
|
1705
|
-
publicRoots.length ? viteStaticCopy({
|
|
1706
|
-
silent: true,
|
|
1707
|
-
targets: publicRoots.map((r) => ({
|
|
1708
|
-
src: `${r}/*`,
|
|
1709
|
-
dest: "theme"
|
|
1710
|
-
}))
|
|
1711
|
-
}) : null,
|
|
1712
1585
|
createConfigPlugin(options),
|
|
1713
1586
|
createClientSetupPlugin(options),
|
|
1714
1587
|
createMonacoTypesLoader(),
|
|
1715
1588
|
createFixPlugins(options),
|
|
1716
|
-
|
|
1589
|
+
publicRoots.length ? import("vite-plugin-static-copy").then((r) => r.viteStaticCopy({
|
|
1590
|
+
silent: true,
|
|
1591
|
+
targets: publicRoots.map((r2) => ({
|
|
1592
|
+
src: `${r2}/*`,
|
|
1593
|
+
dest: "theme"
|
|
1594
|
+
}))
|
|
1595
|
+
})) : null,
|
|
1596
|
+
options.inspect ? import("vite-plugin-inspect").then((r) => r.default({
|
|
1717
1597
|
dev: true,
|
|
1718
1598
|
build: true
|
|
1719
|
-
}) : null,
|
|
1720
|
-
config.css === "none" ? null : config.css === "
|
|
1721
|
-
]
|
|
1599
|
+
})) : null,
|
|
1600
|
+
config.css === "none" ? null : config.css === "windicss" ? import("./windicss-OSTDR2Z6.mjs").then((r) => r.createWindiCSSPlugin(options, pluginOptions)) : import("./unocss-ZLGTDCD7.mjs").then((r) => r.createUnocssPlugin(options, pluginOptions))
|
|
1601
|
+
];
|
|
1602
|
+
return (await Promise.all(plugins)).flat().filter(notNullish2);
|
|
1722
1603
|
}
|
|
1723
1604
|
|
|
1724
1605
|
export {
|
|
1725
1606
|
getIndexHtml,
|
|
1726
1607
|
mergeViteConfigs,
|
|
1727
1608
|
require_fast_deep_equal,
|
|
1728
|
-
loadSetups,
|
|
1729
|
-
createWindiCSSPlugin,
|
|
1730
1609
|
ViteSlidevPlugin
|
|
1731
1610
|
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__require
|
|
3
|
+
} from "./chunk-L5QH2WZE.mjs";
|
|
4
|
+
|
|
5
|
+
// node/utils.ts
|
|
6
|
+
import { join } from "path";
|
|
7
|
+
import { ensurePrefix, slash } from "@antfu/utils";
|
|
8
|
+
import isInstalledGlobally from "is-installed-globally";
|
|
9
|
+
import { sync as resolve } from "resolve";
|
|
10
|
+
import globalDirs from "global-dirs";
|
|
11
|
+
function toAtFS(path) {
|
|
12
|
+
return `/@fs${ensurePrefix("/", slash(path))}`;
|
|
13
|
+
}
|
|
14
|
+
function resolveImportPath(importName, ensure = false) {
|
|
15
|
+
try {
|
|
16
|
+
return resolve(importName, {
|
|
17
|
+
preserveSymlinks: false
|
|
18
|
+
});
|
|
19
|
+
} catch {
|
|
20
|
+
}
|
|
21
|
+
if (isInstalledGlobally) {
|
|
22
|
+
try {
|
|
23
|
+
return __require.resolve(join(globalDirs.yarn.packages, importName));
|
|
24
|
+
} catch {
|
|
25
|
+
}
|
|
26
|
+
try {
|
|
27
|
+
return __require.resolve(join(globalDirs.npm.packages, importName));
|
|
28
|
+
} catch {
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (ensure)
|
|
32
|
+
throw new Error(`Failed to resolve package "${importName}"`);
|
|
33
|
+
return void 0;
|
|
34
|
+
}
|
|
35
|
+
function resolveGlobalImportPath(importName) {
|
|
36
|
+
try {
|
|
37
|
+
return resolve(importName, { preserveSymlinks: false, basedir: __dirname });
|
|
38
|
+
} catch {
|
|
39
|
+
}
|
|
40
|
+
try {
|
|
41
|
+
return __require.resolve(join(globalDirs.yarn.packages, importName));
|
|
42
|
+
} catch {
|
|
43
|
+
}
|
|
44
|
+
try {
|
|
45
|
+
return __require.resolve(join(globalDirs.npm.packages, importName));
|
|
46
|
+
} catch {
|
|
47
|
+
}
|
|
48
|
+
throw new Error(`Failed to resolve global package "${importName}"`);
|
|
49
|
+
}
|
|
50
|
+
function stringifyMarkdownTokens(tokens) {
|
|
51
|
+
return tokens.map(
|
|
52
|
+
(token) => {
|
|
53
|
+
var _a;
|
|
54
|
+
return (_a = token.children) == null ? void 0 : _a.filter((t) => ["text", "code_inline"].includes(t.type) && !t.content.match(/^\s*$/)).map((t) => t.content.trim()).join(" ");
|
|
55
|
+
}
|
|
56
|
+
).filter(Boolean).join(" ");
|
|
57
|
+
}
|
|
58
|
+
function generateGoogleFontsUrl(options) {
|
|
59
|
+
const weights = options.weights.flatMap((i) => options.italic ? [`0,${i}`, `1,${i}`] : [`${i}`]).sort().join(";");
|
|
60
|
+
const fonts = options.webfonts.map((i) => `family=${i.replace(/^(['"])(.*)\1$/, "$1").replace(/\s+/g, "+")}:${options.italic ? "ital," : ""}wght@${weights}`).join("&");
|
|
61
|
+
return `https://fonts.googleapis.com/css2?${fonts}&display=swap`;
|
|
62
|
+
}
|
|
63
|
+
function packageExists(name) {
|
|
64
|
+
if (resolveImportPath(`${name}/package.json`))
|
|
65
|
+
return true;
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export {
|
|
70
|
+
toAtFS,
|
|
71
|
+
resolveImportPath,
|
|
72
|
+
resolveGlobalImportPath,
|
|
73
|
+
stringifyMarkdownTokens,
|
|
74
|
+
generateGoogleFontsUrl,
|
|
75
|
+
packageExists
|
|
76
|
+
};
|