@slidev/cli 0.48.0-beta.3 → 0.48.0-beta.5

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,72 +0,0 @@
1
- // node/utils.ts
2
- import { join } from "node:path";
3
- import { createRequire } from "node:module";
4
- import { fileURLToPath } from "node:url";
5
- import { ensurePrefix, slash } from "@antfu/utils";
6
- import isInstalledGlobally from "is-installed-globally";
7
- import { resolvePath } from "mlly";
8
- import globalDirs from "global-directory";
9
- var require2 = createRequire(import.meta.url);
10
- function toAtFS(path) {
11
- return `/@fs${ensurePrefix("/", slash(path))}`;
12
- }
13
- async function resolveImportPath(importName, ensure = false) {
14
- try {
15
- return await resolvePath(importName, {
16
- url: fileURLToPath(import.meta.url)
17
- });
18
- } catch {
19
- }
20
- if (isInstalledGlobally) {
21
- try {
22
- return require2.resolve(join(globalDirs.yarn.packages, importName));
23
- } catch {
24
- }
25
- try {
26
- return require2.resolve(join(globalDirs.npm.packages, importName));
27
- } catch {
28
- }
29
- }
30
- if (ensure)
31
- throw new Error(`Failed to resolve package "${importName}"`);
32
- return void 0;
33
- }
34
- async function resolveGlobalImportPath(importName) {
35
- try {
36
- return await resolvePath(importName, {
37
- url: fileURLToPath(import.meta.url)
38
- });
39
- } catch {
40
- }
41
- try {
42
- return require2.resolve(join(globalDirs.yarn.packages, importName));
43
- } catch {
44
- }
45
- try {
46
- return require2.resolve(join(globalDirs.npm.packages, importName));
47
- } catch {
48
- }
49
- throw new Error(`Failed to resolve global package "${importName}"`);
50
- }
51
- function stringifyMarkdownTokens(tokens) {
52
- return tokens.map((token) => token.children?.filter((t) => ["text", "code_inline"].includes(t.type) && !t.content.match(/^\s*$/)).map((t) => t.content.trim()).join(" ")).filter(Boolean).join(" ");
53
- }
54
- function generateGoogleFontsUrl(options) {
55
- const weights = options.weights.flatMap((i) => options.italic ? [`0,${i}`, `1,${i}`] : [`${i}`]).sort().join(";");
56
- const fonts = options.webfonts.map((i) => `family=${i.replace(/^(['"])(.*)\1$/, "$1").replace(/\s+/g, "+")}:${options.italic ? "ital," : ""}wght@${weights}`).join("&");
57
- return `https://fonts.googleapis.com/css2?${fonts}&display=swap`;
58
- }
59
- async function packageExists(name) {
60
- if (await resolveImportPath(`${name}/package.json`).catch(() => false))
61
- return true;
62
- return false;
63
- }
64
-
65
- export {
66
- toAtFS,
67
- resolveImportPath,
68
- resolveGlobalImportPath,
69
- stringifyMarkdownTokens,
70
- generateGoogleFontsUrl,
71
- packageExists
72
- };