@slidev/cli 0.49.0-beta.1 → 0.49.0-beta.3
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-XXV2EMMO.mjs → build-IFALC6GJ.mjs} +3 -2
- package/dist/chunk-BXO7ZPPU.mjs +30 -0
- package/dist/{chunk-N6NGSC4J.mjs → chunk-KUKH6IFA.mjs} +2 -2
- package/dist/chunk-Y6VNORK4.mjs +9467 -0
- package/dist/cli.mjs +6 -5
- package/dist/{export-H5Y2LN6J.mjs → export-OGDZIGG2.mjs} +1 -0
- package/dist/index.mjs +3 -2
- package/dist/{unocss-AGKZGMYO.mjs → unocss-JEKY4MJK.mjs} +1 -0
- package/package.json +8 -8
- package/dist/chunk-3IFZRBMW.mjs +0 -4999
package/dist/chunk-3IFZRBMW.mjs
DELETED
|
@@ -1,4999 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
loadSetups
|
|
3
|
-
} from "./chunk-LOUKLO2C.mjs";
|
|
4
|
-
import {
|
|
5
|
-
resolveImportPath,
|
|
6
|
-
resolveImportUrl,
|
|
7
|
-
toAtFS
|
|
8
|
-
} from "./chunk-AQQIBD5X.mjs";
|
|
9
|
-
|
|
10
|
-
// node/commands/shared.ts
|
|
11
|
-
import { existsSync, promises as fs } from "node:fs";
|
|
12
|
-
import { join } from "node:path";
|
|
13
|
-
import { loadConfigFromFile, mergeConfig, resolveConfig } from "vite";
|
|
14
|
-
|
|
15
|
-
// node/utils.ts
|
|
16
|
-
function stringifyMarkdownTokens(tokens) {
|
|
17
|
-
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(" ");
|
|
18
|
-
}
|
|
19
|
-
function generateGoogleFontsUrl(options) {
|
|
20
|
-
const weights = options.weights.flatMap((i) => options.italic ? [`0,${i}`, `1,${i}`] : [`${i}`]).sort().join(";");
|
|
21
|
-
const fonts = options.webfonts.map((i) => `family=${i.replace(/^(['"])(.*)\1$/, "$1").replace(/\s+/g, "+")}:${options.italic ? "ital," : ""}wght@${weights}`).join("&");
|
|
22
|
-
return `https://fonts.googleapis.com/css2?${fonts}&display=swap`;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// node/commands/shared.ts
|
|
26
|
-
async function getIndexHtml({ clientRoot, roots, data }) {
|
|
27
|
-
let main = await fs.readFile(join(clientRoot, "index.html"), "utf-8");
|
|
28
|
-
let head = "";
|
|
29
|
-
let body = "";
|
|
30
|
-
head += `<link rel="icon" href="${data.config.favicon}">`;
|
|
31
|
-
for (const root of roots) {
|
|
32
|
-
const path2 = join(root, "index.html");
|
|
33
|
-
if (!existsSync(path2))
|
|
34
|
-
continue;
|
|
35
|
-
const index = await fs.readFile(path2, "utf-8");
|
|
36
|
-
head += `
|
|
37
|
-
${(index.match(/<head>([\s\S]*?)<\/head>/im)?.[1] || "").trim()}`;
|
|
38
|
-
body += `
|
|
39
|
-
${(index.match(/<body>([\s\S]*?)<\/body>/im)?.[1] || "").trim()}`;
|
|
40
|
-
}
|
|
41
|
-
if (data.features.tweet)
|
|
42
|
-
body += '\n<script async src="https://platform.twitter.com/widgets.js"></script>';
|
|
43
|
-
if (data.config.fonts.webfonts.length && data.config.fonts.provider !== "none")
|
|
44
|
-
head += `
|
|
45
|
-
<link rel="stylesheet" href="${generateGoogleFontsUrl(data.config.fonts)}" type="text/css">`;
|
|
46
|
-
main = main.replace("__ENTRY__", toAtFS(join(clientRoot, "main.ts"))).replace("<!-- head -->", head).replace("<!-- body -->", body);
|
|
47
|
-
return main;
|
|
48
|
-
}
|
|
49
|
-
async function mergeViteConfigs({ roots, entry }, viteConfig, config, command) {
|
|
50
|
-
const configEnv = {
|
|
51
|
-
mode: "development",
|
|
52
|
-
command
|
|
53
|
-
};
|
|
54
|
-
const files = roots.map((i) => join(i, "vite.config.ts"));
|
|
55
|
-
for await (const file of files) {
|
|
56
|
-
if (!existsSync(file))
|
|
57
|
-
continue;
|
|
58
|
-
const viteConfig2 = await loadConfigFromFile(configEnv, file);
|
|
59
|
-
if (!viteConfig2?.config)
|
|
60
|
-
continue;
|
|
61
|
-
config = mergeConfig(config, viteConfig2.config);
|
|
62
|
-
}
|
|
63
|
-
config = mergeConfig(config, viteConfig);
|
|
64
|
-
const localConfig = await resolveConfig({}, command, entry);
|
|
65
|
-
config = mergeConfig(config, { slidev: localConfig.slidev || {} });
|
|
66
|
-
return config;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// node/vite/index.ts
|
|
70
|
-
import { join as join8 } from "node:path";
|
|
71
|
-
import { existsSync as existsSync5 } from "node:fs";
|
|
72
|
-
import process from "node:process";
|
|
73
|
-
import { fileURLToPath } from "node:url";
|
|
74
|
-
import Icons from "unplugin-icons/vite";
|
|
75
|
-
import IconsResolver from "unplugin-icons/resolver";
|
|
76
|
-
import Components from "unplugin-vue-components/vite";
|
|
77
|
-
import ServerRef from "vite-plugin-vue-server-ref";
|
|
78
|
-
import { notNullish as notNullish2 } from "@antfu/utils";
|
|
79
|
-
|
|
80
|
-
// node/integrations/drawings.ts
|
|
81
|
-
import { basename, dirname, join as join2, resolve } from "node:path";
|
|
82
|
-
import fs2 from "fs-extra";
|
|
83
|
-
import fg from "fast-glob";
|
|
84
|
-
function resolveDrawingsDir(options) {
|
|
85
|
-
return options.data.config.drawings.persist ? resolve(
|
|
86
|
-
dirname(options.entry),
|
|
87
|
-
options.data.config.drawings.persist
|
|
88
|
-
) : void 0;
|
|
89
|
-
}
|
|
90
|
-
async function loadDrawings(options) {
|
|
91
|
-
const dir = resolveDrawingsDir(options);
|
|
92
|
-
if (!dir || !fs2.existsSync(dir))
|
|
93
|
-
return {};
|
|
94
|
-
const files = await fg("*.svg", {
|
|
95
|
-
onlyFiles: true,
|
|
96
|
-
cwd: dir,
|
|
97
|
-
absolute: true,
|
|
98
|
-
suppressErrors: true
|
|
99
|
-
});
|
|
100
|
-
const obj = {};
|
|
101
|
-
await Promise.all(files.map(async (path2) => {
|
|
102
|
-
const num = +basename(path2, ".svg");
|
|
103
|
-
if (Number.isNaN(num))
|
|
104
|
-
return;
|
|
105
|
-
const content = await fs2.readFile(path2, "utf8");
|
|
106
|
-
const lines = content.split(/\n/g);
|
|
107
|
-
obj[num.toString()] = lines.slice(1, -1).join("\n");
|
|
108
|
-
}));
|
|
109
|
-
return obj;
|
|
110
|
-
}
|
|
111
|
-
async function writeDrawings(options, drawing) {
|
|
112
|
-
const dir = resolveDrawingsDir(options);
|
|
113
|
-
if (!dir)
|
|
114
|
-
return;
|
|
115
|
-
const width = options.data.config.canvasWidth;
|
|
116
|
-
const height = Math.round(width / options.data.config.aspectRatio);
|
|
117
|
-
const SVG_HEAD = `<svg width="${width}" height="${height}" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">`;
|
|
118
|
-
await fs2.ensureDir(dir);
|
|
119
|
-
return Promise.all(
|
|
120
|
-
Object.entries(drawing).map(async ([key, value]) => {
|
|
121
|
-
if (!value)
|
|
122
|
-
return;
|
|
123
|
-
const svg = `${SVG_HEAD}
|
|
124
|
-
${value}
|
|
125
|
-
</svg>`;
|
|
126
|
-
await fs2.writeFile(join2(dir, `${key}.svg`), svg, "utf-8");
|
|
127
|
-
})
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// node/vite/extendConfig.ts
|
|
132
|
-
import { join as join3 } from "node:path";
|
|
133
|
-
import { mergeConfig as mergeConfig2 } from "vite";
|
|
134
|
-
import isInstalledGlobally from "is-installed-globally";
|
|
135
|
-
import { uniq } from "@antfu/utils";
|
|
136
|
-
|
|
137
|
-
// ../client/package.json
|
|
138
|
-
var dependencies = {
|
|
139
|
-
"@antfu/utils": "^0.7.7",
|
|
140
|
-
"@iconify-json/carbon": "^1.1.31",
|
|
141
|
-
"@iconify-json/ph": "^1.1.12",
|
|
142
|
-
"@iconify-json/svg-spinners": "^1.1.2",
|
|
143
|
-
"@shikijs/monaco": "^1.3.0",
|
|
144
|
-
"@shikijs/vitepress-twoslash": "^1.3.0",
|
|
145
|
-
"@slidev/parser": "workspace:*",
|
|
146
|
-
"@slidev/rough-notation": "^0.1.0",
|
|
147
|
-
"@slidev/types": "workspace:*",
|
|
148
|
-
"@typescript/ata": "^0.9.4",
|
|
149
|
-
"@unhead/vue": "^1.9.4",
|
|
150
|
-
"@unocss/reset": "^0.59.0",
|
|
151
|
-
"@vueuse/core": "^10.9.0",
|
|
152
|
-
"@vueuse/math": "^10.9.0",
|
|
153
|
-
"@vueuse/motion": "^2.1.0",
|
|
154
|
-
codemirror: "^5.65.16",
|
|
155
|
-
drauu: "^0.4.0",
|
|
156
|
-
"file-saver": "^2.0.5",
|
|
157
|
-
"floating-vue": "^5.2.2",
|
|
158
|
-
"fuse.js": "^7.0.0",
|
|
159
|
-
"js-yaml": "^4.1.0",
|
|
160
|
-
katex: "^0.16.10",
|
|
161
|
-
"lz-string": "^1.5.0",
|
|
162
|
-
mermaid: "^10.9.0",
|
|
163
|
-
"monaco-editor": "^0.47.0",
|
|
164
|
-
prettier: "^3.2.5",
|
|
165
|
-
recordrtc: "^5.6.2",
|
|
166
|
-
shiki: "^1.3.0",
|
|
167
|
-
"shiki-magic-move": "^0.3.5",
|
|
168
|
-
typescript: "^5.4.4",
|
|
169
|
-
unocss: "^0.59.0",
|
|
170
|
-
vue: "^3.4.21",
|
|
171
|
-
"vue-demi": "^0.14.7",
|
|
172
|
-
"vue-router": "^4.3.0"
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
// node/vite/extendConfig.ts
|
|
176
|
-
var INCLUDE = [
|
|
177
|
-
...Object.keys(dependencies),
|
|
178
|
-
// CodeMirror
|
|
179
|
-
"codemirror/mode/javascript/javascript",
|
|
180
|
-
"codemirror/mode/css/css",
|
|
181
|
-
"codemirror/mode/markdown/markdown",
|
|
182
|
-
"codemirror/mode/xml/xml",
|
|
183
|
-
"codemirror/mode/htmlmixed/htmlmixed",
|
|
184
|
-
"codemirror/addon/display/placeholder",
|
|
185
|
-
// Monaco
|
|
186
|
-
"monaco-editor/esm/vs/editor/standalone/browser/standaloneServices",
|
|
187
|
-
"monaco-editor/esm/vs/platform/contextview/browser/contextViewService",
|
|
188
|
-
"monaco-editor/esm/vs/platform/instantiation/common/descriptors",
|
|
189
|
-
// Others
|
|
190
|
-
"shiki-magic-move/vue"
|
|
191
|
-
];
|
|
192
|
-
var EXCLUDE = [
|
|
193
|
-
"@slidev/shared",
|
|
194
|
-
"@slidev/types",
|
|
195
|
-
"@slidev/client",
|
|
196
|
-
"@slidev/client/constants",
|
|
197
|
-
"@slidev/client/logic/dark",
|
|
198
|
-
"@vueuse/core",
|
|
199
|
-
"@vueuse/math",
|
|
200
|
-
"@vueuse/shared",
|
|
201
|
-
"@unocss/reset",
|
|
202
|
-
"unocss",
|
|
203
|
-
"mermaid",
|
|
204
|
-
"vue-demi",
|
|
205
|
-
"vue",
|
|
206
|
-
"shiki"
|
|
207
|
-
];
|
|
208
|
-
var ASYNC_MODULES = [
|
|
209
|
-
"file-saver",
|
|
210
|
-
"vue",
|
|
211
|
-
"@vue"
|
|
212
|
-
];
|
|
213
|
-
function createConfigPlugin(options) {
|
|
214
|
-
return {
|
|
215
|
-
name: "slidev:config",
|
|
216
|
-
async config(config) {
|
|
217
|
-
const injection = {
|
|
218
|
-
define: getDefine(options),
|
|
219
|
-
resolve: {
|
|
220
|
-
alias: [
|
|
221
|
-
{
|
|
222
|
-
find: /^@slidev\/client$/,
|
|
223
|
-
replacement: `${toAtFS(options.clientRoot)}/index.ts`
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
find: /^@slidev\/client\/(.*)/,
|
|
227
|
-
replacement: `${toAtFS(options.clientRoot)}/$1`
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
find: /^#slidev\/(.*)/,
|
|
231
|
-
replacement: "/@slidev/$1"
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
find: "vue",
|
|
235
|
-
replacement: await resolveImportPath("vue/dist/vue.esm-bundler.js", true)
|
|
236
|
-
}
|
|
237
|
-
],
|
|
238
|
-
dedupe: ["vue"]
|
|
239
|
-
},
|
|
240
|
-
optimizeDeps: {
|
|
241
|
-
exclude: EXCLUDE,
|
|
242
|
-
include: INCLUDE.filter((i) => !EXCLUDE.includes(i)).map((i) => `@slidev/cli > @slidev/client > ${i}`)
|
|
243
|
-
},
|
|
244
|
-
css: options.data.config.css === "unocss" ? {
|
|
245
|
-
postcss: {
|
|
246
|
-
plugins: [
|
|
247
|
-
await import("postcss-nested").then((r) => (r.default || r)())
|
|
248
|
-
]
|
|
249
|
-
}
|
|
250
|
-
} : {},
|
|
251
|
-
server: {
|
|
252
|
-
fs: {
|
|
253
|
-
strict: true,
|
|
254
|
-
allow: uniq([
|
|
255
|
-
options.userWorkspaceRoot,
|
|
256
|
-
options.cliRoot,
|
|
257
|
-
options.clientRoot,
|
|
258
|
-
...options.roots
|
|
259
|
-
])
|
|
260
|
-
}
|
|
261
|
-
},
|
|
262
|
-
publicDir: join3(options.userRoot, "public"),
|
|
263
|
-
build: {
|
|
264
|
-
rollupOptions: {
|
|
265
|
-
output: {
|
|
266
|
-
chunkFileNames(chunkInfo) {
|
|
267
|
-
const DEFAULT = "assets/[name]-[hash].js";
|
|
268
|
-
if (chunkInfo.name.includes("/"))
|
|
269
|
-
return DEFAULT;
|
|
270
|
-
if (chunkInfo.moduleIds.filter((i) => isSlidevClient(i)).length > chunkInfo.moduleIds.length * 0.6)
|
|
271
|
-
return "assets/slidev/[name]-[hash].js";
|
|
272
|
-
if (chunkInfo.moduleIds.filter((i) => i.match(/\/monaco-editor(-core)?\//)).length > chunkInfo.moduleIds.length * 0.6)
|
|
273
|
-
return "assets/monaco/[name]-[hash].js";
|
|
274
|
-
return DEFAULT;
|
|
275
|
-
},
|
|
276
|
-
manualChunks(id) {
|
|
277
|
-
if (id.startsWith("/@slidev-monaco-types/") || id.includes("/@slidev/monaco-types") || id.endsWith("?monaco-types&raw"))
|
|
278
|
-
return "monaco/bundled-types";
|
|
279
|
-
if (id.includes("/shiki/") || id.includes("/@shikijs/"))
|
|
280
|
-
return `modules/shiki`;
|
|
281
|
-
if (id.startsWith("~icons/"))
|
|
282
|
-
return "modules/unplugin-icons";
|
|
283
|
-
const matchedAsyncModule = ASYNC_MODULES.find((i) => id.includes(`/node_modules/${i}`));
|
|
284
|
-
if (matchedAsyncModule)
|
|
285
|
-
return `modules/${matchedAsyncModule.replace("@", "").replace("/", "-")}`;
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
};
|
|
291
|
-
function isSlidevClient(id) {
|
|
292
|
-
return id.includes("/@slidev/") || id.includes("/slidev/packages/client/") || id.includes("/@vueuse/");
|
|
293
|
-
}
|
|
294
|
-
if (isInstalledGlobally) {
|
|
295
|
-
injection.cacheDir = join3(options.cliRoot, "node_modules/.vite");
|
|
296
|
-
injection.root = options.cliRoot;
|
|
297
|
-
}
|
|
298
|
-
return mergeConfig2(injection, config);
|
|
299
|
-
},
|
|
300
|
-
configureServer(server) {
|
|
301
|
-
return () => {
|
|
302
|
-
server.middlewares.use(async (req, res, next) => {
|
|
303
|
-
if (req.url.endsWith(".html")) {
|
|
304
|
-
res.setHeader("Content-Type", "text/html");
|
|
305
|
-
res.statusCode = 200;
|
|
306
|
-
res.end(await getIndexHtml(options));
|
|
307
|
-
return;
|
|
308
|
-
}
|
|
309
|
-
next();
|
|
310
|
-
});
|
|
311
|
-
};
|
|
312
|
-
}
|
|
313
|
-
};
|
|
314
|
-
}
|
|
315
|
-
function getDefine(options) {
|
|
316
|
-
return {
|
|
317
|
-
__DEV__: options.mode === "dev" ? "true" : "false",
|
|
318
|
-
__SLIDEV_CLIENT_ROOT__: JSON.stringify(toAtFS(options.clientRoot)),
|
|
319
|
-
__SLIDEV_HASH_ROUTE__: JSON.stringify(options.data.config.routerMode === "hash"),
|
|
320
|
-
__SLIDEV_FEATURE_DRAWINGS__: JSON.stringify(options.data.config.drawings.enabled === true || options.data.config.drawings.enabled === options.mode),
|
|
321
|
-
__SLIDEV_FEATURE_EDITOR__: JSON.stringify(options.mode === "dev" && options.data.config.editor !== false),
|
|
322
|
-
__SLIDEV_FEATURE_DRAWINGS_PERSIST__: JSON.stringify(!!options.data.config.drawings.persist === true),
|
|
323
|
-
__SLIDEV_FEATURE_RECORD__: JSON.stringify(options.data.config.record === true || options.data.config.record === options.mode),
|
|
324
|
-
__SLIDEV_FEATURE_PRESENTER__: JSON.stringify(options.data.config.presenter === true || options.data.config.presenter === options.mode),
|
|
325
|
-
__SLIDEV_HAS_SERVER__: options.mode !== "build" ? "true" : "false"
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
// node/vite/loaders.ts
|
|
330
|
-
import { basename as basename2 } from "node:path";
|
|
331
|
-
import { isString as isString2, isTruthy as isTruthy2, notNullish, range } from "@antfu/utils";
|
|
332
|
-
import fg3 from "fast-glob";
|
|
333
|
-
import fs4 from "fs-extra";
|
|
334
|
-
import Markdown from "markdown-it";
|
|
335
|
-
|
|
336
|
-
// ../../node_modules/.pnpm/js-yaml@4.1.0/node_modules/js-yaml/dist/js-yaml.mjs
|
|
337
|
-
function isNothing(subject) {
|
|
338
|
-
return typeof subject === "undefined" || subject === null;
|
|
339
|
-
}
|
|
340
|
-
function isObject(subject) {
|
|
341
|
-
return typeof subject === "object" && subject !== null;
|
|
342
|
-
}
|
|
343
|
-
function toArray(sequence) {
|
|
344
|
-
if (Array.isArray(sequence))
|
|
345
|
-
return sequence;
|
|
346
|
-
else if (isNothing(sequence))
|
|
347
|
-
return [];
|
|
348
|
-
return [sequence];
|
|
349
|
-
}
|
|
350
|
-
function extend(target, source) {
|
|
351
|
-
var index, length, key, sourceKeys;
|
|
352
|
-
if (source) {
|
|
353
|
-
sourceKeys = Object.keys(source);
|
|
354
|
-
for (index = 0, length = sourceKeys.length; index < length; index += 1) {
|
|
355
|
-
key = sourceKeys[index];
|
|
356
|
-
target[key] = source[key];
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
return target;
|
|
360
|
-
}
|
|
361
|
-
function repeat(string, count) {
|
|
362
|
-
var result = "", cycle;
|
|
363
|
-
for (cycle = 0; cycle < count; cycle += 1) {
|
|
364
|
-
result += string;
|
|
365
|
-
}
|
|
366
|
-
return result;
|
|
367
|
-
}
|
|
368
|
-
function isNegativeZero(number) {
|
|
369
|
-
return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
|
|
370
|
-
}
|
|
371
|
-
var isNothing_1 = isNothing;
|
|
372
|
-
var isObject_1 = isObject;
|
|
373
|
-
var toArray_1 = toArray;
|
|
374
|
-
var repeat_1 = repeat;
|
|
375
|
-
var isNegativeZero_1 = isNegativeZero;
|
|
376
|
-
var extend_1 = extend;
|
|
377
|
-
var common = {
|
|
378
|
-
isNothing: isNothing_1,
|
|
379
|
-
isObject: isObject_1,
|
|
380
|
-
toArray: toArray_1,
|
|
381
|
-
repeat: repeat_1,
|
|
382
|
-
isNegativeZero: isNegativeZero_1,
|
|
383
|
-
extend: extend_1
|
|
384
|
-
};
|
|
385
|
-
function formatError(exception2, compact) {
|
|
386
|
-
var where = "", message = exception2.reason || "(unknown reason)";
|
|
387
|
-
if (!exception2.mark)
|
|
388
|
-
return message;
|
|
389
|
-
if (exception2.mark.name) {
|
|
390
|
-
where += 'in "' + exception2.mark.name + '" ';
|
|
391
|
-
}
|
|
392
|
-
where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")";
|
|
393
|
-
if (!compact && exception2.mark.snippet) {
|
|
394
|
-
where += "\n\n" + exception2.mark.snippet;
|
|
395
|
-
}
|
|
396
|
-
return message + " " + where;
|
|
397
|
-
}
|
|
398
|
-
function YAMLException$1(reason, mark) {
|
|
399
|
-
Error.call(this);
|
|
400
|
-
this.name = "YAMLException";
|
|
401
|
-
this.reason = reason;
|
|
402
|
-
this.mark = mark;
|
|
403
|
-
this.message = formatError(this, false);
|
|
404
|
-
if (Error.captureStackTrace) {
|
|
405
|
-
Error.captureStackTrace(this, this.constructor);
|
|
406
|
-
} else {
|
|
407
|
-
this.stack = new Error().stack || "";
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
YAMLException$1.prototype = Object.create(Error.prototype);
|
|
411
|
-
YAMLException$1.prototype.constructor = YAMLException$1;
|
|
412
|
-
YAMLException$1.prototype.toString = function toString(compact) {
|
|
413
|
-
return this.name + ": " + formatError(this, compact);
|
|
414
|
-
};
|
|
415
|
-
var exception = YAMLException$1;
|
|
416
|
-
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
|
|
417
|
-
var head = "";
|
|
418
|
-
var tail = "";
|
|
419
|
-
var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
420
|
-
if (position - lineStart > maxHalfLength) {
|
|
421
|
-
head = " ... ";
|
|
422
|
-
lineStart = position - maxHalfLength + head.length;
|
|
423
|
-
}
|
|
424
|
-
if (lineEnd - position > maxHalfLength) {
|
|
425
|
-
tail = " ...";
|
|
426
|
-
lineEnd = position + maxHalfLength - tail.length;
|
|
427
|
-
}
|
|
428
|
-
return {
|
|
429
|
-
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
|
|
430
|
-
pos: position - lineStart + head.length
|
|
431
|
-
// relative position
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
function padStart(string, max) {
|
|
435
|
-
return common.repeat(" ", max - string.length) + string;
|
|
436
|
-
}
|
|
437
|
-
function makeSnippet(mark, options) {
|
|
438
|
-
options = Object.create(options || null);
|
|
439
|
-
if (!mark.buffer)
|
|
440
|
-
return null;
|
|
441
|
-
if (!options.maxLength)
|
|
442
|
-
options.maxLength = 79;
|
|
443
|
-
if (typeof options.indent !== "number")
|
|
444
|
-
options.indent = 1;
|
|
445
|
-
if (typeof options.linesBefore !== "number")
|
|
446
|
-
options.linesBefore = 3;
|
|
447
|
-
if (typeof options.linesAfter !== "number")
|
|
448
|
-
options.linesAfter = 2;
|
|
449
|
-
var re = /\r?\n|\r|\0/g;
|
|
450
|
-
var lineStarts = [0];
|
|
451
|
-
var lineEnds = [];
|
|
452
|
-
var match;
|
|
453
|
-
var foundLineNo = -1;
|
|
454
|
-
while (match = re.exec(mark.buffer)) {
|
|
455
|
-
lineEnds.push(match.index);
|
|
456
|
-
lineStarts.push(match.index + match[0].length);
|
|
457
|
-
if (mark.position <= match.index && foundLineNo < 0) {
|
|
458
|
-
foundLineNo = lineStarts.length - 2;
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
if (foundLineNo < 0)
|
|
462
|
-
foundLineNo = lineStarts.length - 1;
|
|
463
|
-
var result = "", i, line;
|
|
464
|
-
var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
|
|
465
|
-
var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
|
|
466
|
-
for (i = 1; i <= options.linesBefore; i++) {
|
|
467
|
-
if (foundLineNo - i < 0)
|
|
468
|
-
break;
|
|
469
|
-
line = getLine(
|
|
470
|
-
mark.buffer,
|
|
471
|
-
lineStarts[foundLineNo - i],
|
|
472
|
-
lineEnds[foundLineNo - i],
|
|
473
|
-
mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),
|
|
474
|
-
maxLineLength
|
|
475
|
-
);
|
|
476
|
-
result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
|
|
477
|
-
}
|
|
478
|
-
line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
|
|
479
|
-
result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
|
|
480
|
-
result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
|
|
481
|
-
for (i = 1; i <= options.linesAfter; i++) {
|
|
482
|
-
if (foundLineNo + i >= lineEnds.length)
|
|
483
|
-
break;
|
|
484
|
-
line = getLine(
|
|
485
|
-
mark.buffer,
|
|
486
|
-
lineStarts[foundLineNo + i],
|
|
487
|
-
lineEnds[foundLineNo + i],
|
|
488
|
-
mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),
|
|
489
|
-
maxLineLength
|
|
490
|
-
);
|
|
491
|
-
result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n";
|
|
492
|
-
}
|
|
493
|
-
return result.replace(/\n$/, "");
|
|
494
|
-
}
|
|
495
|
-
var snippet = makeSnippet;
|
|
496
|
-
var TYPE_CONSTRUCTOR_OPTIONS = [
|
|
497
|
-
"kind",
|
|
498
|
-
"multi",
|
|
499
|
-
"resolve",
|
|
500
|
-
"construct",
|
|
501
|
-
"instanceOf",
|
|
502
|
-
"predicate",
|
|
503
|
-
"represent",
|
|
504
|
-
"representName",
|
|
505
|
-
"defaultStyle",
|
|
506
|
-
"styleAliases"
|
|
507
|
-
];
|
|
508
|
-
var YAML_NODE_KINDS = [
|
|
509
|
-
"scalar",
|
|
510
|
-
"sequence",
|
|
511
|
-
"mapping"
|
|
512
|
-
];
|
|
513
|
-
function compileStyleAliases(map2) {
|
|
514
|
-
var result = {};
|
|
515
|
-
if (map2 !== null) {
|
|
516
|
-
Object.keys(map2).forEach(function(style) {
|
|
517
|
-
map2[style].forEach(function(alias) {
|
|
518
|
-
result[String(alias)] = style;
|
|
519
|
-
});
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
return result;
|
|
523
|
-
}
|
|
524
|
-
function Type$1(tag, options) {
|
|
525
|
-
options = options || {};
|
|
526
|
-
Object.keys(options).forEach(function(name) {
|
|
527
|
-
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
|
|
528
|
-
throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
|
529
|
-
}
|
|
530
|
-
});
|
|
531
|
-
this.options = options;
|
|
532
|
-
this.tag = tag;
|
|
533
|
-
this.kind = options["kind"] || null;
|
|
534
|
-
this.resolve = options["resolve"] || function() {
|
|
535
|
-
return true;
|
|
536
|
-
};
|
|
537
|
-
this.construct = options["construct"] || function(data) {
|
|
538
|
-
return data;
|
|
539
|
-
};
|
|
540
|
-
this.instanceOf = options["instanceOf"] || null;
|
|
541
|
-
this.predicate = options["predicate"] || null;
|
|
542
|
-
this.represent = options["represent"] || null;
|
|
543
|
-
this.representName = options["representName"] || null;
|
|
544
|
-
this.defaultStyle = options["defaultStyle"] || null;
|
|
545
|
-
this.multi = options["multi"] || false;
|
|
546
|
-
this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
|
|
547
|
-
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
|
548
|
-
throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
var type = Type$1;
|
|
552
|
-
function compileList(schema2, name) {
|
|
553
|
-
var result = [];
|
|
554
|
-
schema2[name].forEach(function(currentType) {
|
|
555
|
-
var newIndex = result.length;
|
|
556
|
-
result.forEach(function(previousType, previousIndex) {
|
|
557
|
-
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
|
|
558
|
-
newIndex = previousIndex;
|
|
559
|
-
}
|
|
560
|
-
});
|
|
561
|
-
result[newIndex] = currentType;
|
|
562
|
-
});
|
|
563
|
-
return result;
|
|
564
|
-
}
|
|
565
|
-
function compileMap() {
|
|
566
|
-
var result = {
|
|
567
|
-
scalar: {},
|
|
568
|
-
sequence: {},
|
|
569
|
-
mapping: {},
|
|
570
|
-
fallback: {},
|
|
571
|
-
multi: {
|
|
572
|
-
scalar: [],
|
|
573
|
-
sequence: [],
|
|
574
|
-
mapping: [],
|
|
575
|
-
fallback: []
|
|
576
|
-
}
|
|
577
|
-
}, index, length;
|
|
578
|
-
function collectType(type2) {
|
|
579
|
-
if (type2.multi) {
|
|
580
|
-
result.multi[type2.kind].push(type2);
|
|
581
|
-
result.multi["fallback"].push(type2);
|
|
582
|
-
} else {
|
|
583
|
-
result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
|
|
584
|
-
}
|
|
585
|
-
}
|
|
586
|
-
for (index = 0, length = arguments.length; index < length; index += 1) {
|
|
587
|
-
arguments[index].forEach(collectType);
|
|
588
|
-
}
|
|
589
|
-
return result;
|
|
590
|
-
}
|
|
591
|
-
function Schema$1(definition) {
|
|
592
|
-
return this.extend(definition);
|
|
593
|
-
}
|
|
594
|
-
Schema$1.prototype.extend = function extend2(definition) {
|
|
595
|
-
var implicit = [];
|
|
596
|
-
var explicit = [];
|
|
597
|
-
if (definition instanceof type) {
|
|
598
|
-
explicit.push(definition);
|
|
599
|
-
} else if (Array.isArray(definition)) {
|
|
600
|
-
explicit = explicit.concat(definition);
|
|
601
|
-
} else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
|
|
602
|
-
if (definition.implicit)
|
|
603
|
-
implicit = implicit.concat(definition.implicit);
|
|
604
|
-
if (definition.explicit)
|
|
605
|
-
explicit = explicit.concat(definition.explicit);
|
|
606
|
-
} else {
|
|
607
|
-
throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
|
|
608
|
-
}
|
|
609
|
-
implicit.forEach(function(type$1) {
|
|
610
|
-
if (!(type$1 instanceof type)) {
|
|
611
|
-
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
612
|
-
}
|
|
613
|
-
if (type$1.loadKind && type$1.loadKind !== "scalar") {
|
|
614
|
-
throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
|
|
615
|
-
}
|
|
616
|
-
if (type$1.multi) {
|
|
617
|
-
throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
|
|
618
|
-
}
|
|
619
|
-
});
|
|
620
|
-
explicit.forEach(function(type$1) {
|
|
621
|
-
if (!(type$1 instanceof type)) {
|
|
622
|
-
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
623
|
-
}
|
|
624
|
-
});
|
|
625
|
-
var result = Object.create(Schema$1.prototype);
|
|
626
|
-
result.implicit = (this.implicit || []).concat(implicit);
|
|
627
|
-
result.explicit = (this.explicit || []).concat(explicit);
|
|
628
|
-
result.compiledImplicit = compileList(result, "implicit");
|
|
629
|
-
result.compiledExplicit = compileList(result, "explicit");
|
|
630
|
-
result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
|
|
631
|
-
return result;
|
|
632
|
-
};
|
|
633
|
-
var schema = Schema$1;
|
|
634
|
-
var str = new type("tag:yaml.org,2002:str", {
|
|
635
|
-
kind: "scalar",
|
|
636
|
-
construct: function(data) {
|
|
637
|
-
return data !== null ? data : "";
|
|
638
|
-
}
|
|
639
|
-
});
|
|
640
|
-
var seq = new type("tag:yaml.org,2002:seq", {
|
|
641
|
-
kind: "sequence",
|
|
642
|
-
construct: function(data) {
|
|
643
|
-
return data !== null ? data : [];
|
|
644
|
-
}
|
|
645
|
-
});
|
|
646
|
-
var map = new type("tag:yaml.org,2002:map", {
|
|
647
|
-
kind: "mapping",
|
|
648
|
-
construct: function(data) {
|
|
649
|
-
return data !== null ? data : {};
|
|
650
|
-
}
|
|
651
|
-
});
|
|
652
|
-
var failsafe = new schema({
|
|
653
|
-
explicit: [
|
|
654
|
-
str,
|
|
655
|
-
seq,
|
|
656
|
-
map
|
|
657
|
-
]
|
|
658
|
-
});
|
|
659
|
-
function resolveYamlNull(data) {
|
|
660
|
-
if (data === null)
|
|
661
|
-
return true;
|
|
662
|
-
var max = data.length;
|
|
663
|
-
return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
|
|
664
|
-
}
|
|
665
|
-
function constructYamlNull() {
|
|
666
|
-
return null;
|
|
667
|
-
}
|
|
668
|
-
function isNull(object) {
|
|
669
|
-
return object === null;
|
|
670
|
-
}
|
|
671
|
-
var _null = new type("tag:yaml.org,2002:null", {
|
|
672
|
-
kind: "scalar",
|
|
673
|
-
resolve: resolveYamlNull,
|
|
674
|
-
construct: constructYamlNull,
|
|
675
|
-
predicate: isNull,
|
|
676
|
-
represent: {
|
|
677
|
-
canonical: function() {
|
|
678
|
-
return "~";
|
|
679
|
-
},
|
|
680
|
-
lowercase: function() {
|
|
681
|
-
return "null";
|
|
682
|
-
},
|
|
683
|
-
uppercase: function() {
|
|
684
|
-
return "NULL";
|
|
685
|
-
},
|
|
686
|
-
camelcase: function() {
|
|
687
|
-
return "Null";
|
|
688
|
-
},
|
|
689
|
-
empty: function() {
|
|
690
|
-
return "";
|
|
691
|
-
}
|
|
692
|
-
},
|
|
693
|
-
defaultStyle: "lowercase"
|
|
694
|
-
});
|
|
695
|
-
function resolveYamlBoolean(data) {
|
|
696
|
-
if (data === null)
|
|
697
|
-
return false;
|
|
698
|
-
var max = data.length;
|
|
699
|
-
return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
|
|
700
|
-
}
|
|
701
|
-
function constructYamlBoolean(data) {
|
|
702
|
-
return data === "true" || data === "True" || data === "TRUE";
|
|
703
|
-
}
|
|
704
|
-
function isBoolean(object) {
|
|
705
|
-
return Object.prototype.toString.call(object) === "[object Boolean]";
|
|
706
|
-
}
|
|
707
|
-
var bool = new type("tag:yaml.org,2002:bool", {
|
|
708
|
-
kind: "scalar",
|
|
709
|
-
resolve: resolveYamlBoolean,
|
|
710
|
-
construct: constructYamlBoolean,
|
|
711
|
-
predicate: isBoolean,
|
|
712
|
-
represent: {
|
|
713
|
-
lowercase: function(object) {
|
|
714
|
-
return object ? "true" : "false";
|
|
715
|
-
},
|
|
716
|
-
uppercase: function(object) {
|
|
717
|
-
return object ? "TRUE" : "FALSE";
|
|
718
|
-
},
|
|
719
|
-
camelcase: function(object) {
|
|
720
|
-
return object ? "True" : "False";
|
|
721
|
-
}
|
|
722
|
-
},
|
|
723
|
-
defaultStyle: "lowercase"
|
|
724
|
-
});
|
|
725
|
-
function isHexCode(c) {
|
|
726
|
-
return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
|
|
727
|
-
}
|
|
728
|
-
function isOctCode(c) {
|
|
729
|
-
return 48 <= c && c <= 55;
|
|
730
|
-
}
|
|
731
|
-
function isDecCode(c) {
|
|
732
|
-
return 48 <= c && c <= 57;
|
|
733
|
-
}
|
|
734
|
-
function resolveYamlInteger(data) {
|
|
735
|
-
if (data === null)
|
|
736
|
-
return false;
|
|
737
|
-
var max = data.length, index = 0, hasDigits = false, ch;
|
|
738
|
-
if (!max)
|
|
739
|
-
return false;
|
|
740
|
-
ch = data[index];
|
|
741
|
-
if (ch === "-" || ch === "+") {
|
|
742
|
-
ch = data[++index];
|
|
743
|
-
}
|
|
744
|
-
if (ch === "0") {
|
|
745
|
-
if (index + 1 === max)
|
|
746
|
-
return true;
|
|
747
|
-
ch = data[++index];
|
|
748
|
-
if (ch === "b") {
|
|
749
|
-
index++;
|
|
750
|
-
for (; index < max; index++) {
|
|
751
|
-
ch = data[index];
|
|
752
|
-
if (ch === "_")
|
|
753
|
-
continue;
|
|
754
|
-
if (ch !== "0" && ch !== "1")
|
|
755
|
-
return false;
|
|
756
|
-
hasDigits = true;
|
|
757
|
-
}
|
|
758
|
-
return hasDigits && ch !== "_";
|
|
759
|
-
}
|
|
760
|
-
if (ch === "x") {
|
|
761
|
-
index++;
|
|
762
|
-
for (; index < max; index++) {
|
|
763
|
-
ch = data[index];
|
|
764
|
-
if (ch === "_")
|
|
765
|
-
continue;
|
|
766
|
-
if (!isHexCode(data.charCodeAt(index)))
|
|
767
|
-
return false;
|
|
768
|
-
hasDigits = true;
|
|
769
|
-
}
|
|
770
|
-
return hasDigits && ch !== "_";
|
|
771
|
-
}
|
|
772
|
-
if (ch === "o") {
|
|
773
|
-
index++;
|
|
774
|
-
for (; index < max; index++) {
|
|
775
|
-
ch = data[index];
|
|
776
|
-
if (ch === "_")
|
|
777
|
-
continue;
|
|
778
|
-
if (!isOctCode(data.charCodeAt(index)))
|
|
779
|
-
return false;
|
|
780
|
-
hasDigits = true;
|
|
781
|
-
}
|
|
782
|
-
return hasDigits && ch !== "_";
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
if (ch === "_")
|
|
786
|
-
return false;
|
|
787
|
-
for (; index < max; index++) {
|
|
788
|
-
ch = data[index];
|
|
789
|
-
if (ch === "_")
|
|
790
|
-
continue;
|
|
791
|
-
if (!isDecCode(data.charCodeAt(index))) {
|
|
792
|
-
return false;
|
|
793
|
-
}
|
|
794
|
-
hasDigits = true;
|
|
795
|
-
}
|
|
796
|
-
if (!hasDigits || ch === "_")
|
|
797
|
-
return false;
|
|
798
|
-
return true;
|
|
799
|
-
}
|
|
800
|
-
function constructYamlInteger(data) {
|
|
801
|
-
var value = data, sign = 1, ch;
|
|
802
|
-
if (value.indexOf("_") !== -1) {
|
|
803
|
-
value = value.replace(/_/g, "");
|
|
804
|
-
}
|
|
805
|
-
ch = value[0];
|
|
806
|
-
if (ch === "-" || ch === "+") {
|
|
807
|
-
if (ch === "-")
|
|
808
|
-
sign = -1;
|
|
809
|
-
value = value.slice(1);
|
|
810
|
-
ch = value[0];
|
|
811
|
-
}
|
|
812
|
-
if (value === "0")
|
|
813
|
-
return 0;
|
|
814
|
-
if (ch === "0") {
|
|
815
|
-
if (value[1] === "b")
|
|
816
|
-
return sign * parseInt(value.slice(2), 2);
|
|
817
|
-
if (value[1] === "x")
|
|
818
|
-
return sign * parseInt(value.slice(2), 16);
|
|
819
|
-
if (value[1] === "o")
|
|
820
|
-
return sign * parseInt(value.slice(2), 8);
|
|
821
|
-
}
|
|
822
|
-
return sign * parseInt(value, 10);
|
|
823
|
-
}
|
|
824
|
-
function isInteger(object) {
|
|
825
|
-
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
|
|
826
|
-
}
|
|
827
|
-
var int = new type("tag:yaml.org,2002:int", {
|
|
828
|
-
kind: "scalar",
|
|
829
|
-
resolve: resolveYamlInteger,
|
|
830
|
-
construct: constructYamlInteger,
|
|
831
|
-
predicate: isInteger,
|
|
832
|
-
represent: {
|
|
833
|
-
binary: function(obj) {
|
|
834
|
-
return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
|
|
835
|
-
},
|
|
836
|
-
octal: function(obj) {
|
|
837
|
-
return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
|
|
838
|
-
},
|
|
839
|
-
decimal: function(obj) {
|
|
840
|
-
return obj.toString(10);
|
|
841
|
-
},
|
|
842
|
-
/* eslint-disable max-len */
|
|
843
|
-
hexadecimal: function(obj) {
|
|
844
|
-
return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
|
|
845
|
-
}
|
|
846
|
-
},
|
|
847
|
-
defaultStyle: "decimal",
|
|
848
|
-
styleAliases: {
|
|
849
|
-
binary: [2, "bin"],
|
|
850
|
-
octal: [8, "oct"],
|
|
851
|
-
decimal: [10, "dec"],
|
|
852
|
-
hexadecimal: [16, "hex"]
|
|
853
|
-
}
|
|
854
|
-
});
|
|
855
|
-
var YAML_FLOAT_PATTERN = new RegExp(
|
|
856
|
-
// 2.5e4, 2.5 and integers
|
|
857
|
-
"^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
|
|
858
|
-
);
|
|
859
|
-
function resolveYamlFloat(data) {
|
|
860
|
-
if (data === null)
|
|
861
|
-
return false;
|
|
862
|
-
if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
|
|
863
|
-
// Probably should update regexp & check speed
|
|
864
|
-
data[data.length - 1] === "_") {
|
|
865
|
-
return false;
|
|
866
|
-
}
|
|
867
|
-
return true;
|
|
868
|
-
}
|
|
869
|
-
function constructYamlFloat(data) {
|
|
870
|
-
var value, sign;
|
|
871
|
-
value = data.replace(/_/g, "").toLowerCase();
|
|
872
|
-
sign = value[0] === "-" ? -1 : 1;
|
|
873
|
-
if ("+-".indexOf(value[0]) >= 0) {
|
|
874
|
-
value = value.slice(1);
|
|
875
|
-
}
|
|
876
|
-
if (value === ".inf") {
|
|
877
|
-
return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
878
|
-
} else if (value === ".nan") {
|
|
879
|
-
return NaN;
|
|
880
|
-
}
|
|
881
|
-
return sign * parseFloat(value, 10);
|
|
882
|
-
}
|
|
883
|
-
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
|
884
|
-
function representYamlFloat(object, style) {
|
|
885
|
-
var res;
|
|
886
|
-
if (isNaN(object)) {
|
|
887
|
-
switch (style) {
|
|
888
|
-
case "lowercase":
|
|
889
|
-
return ".nan";
|
|
890
|
-
case "uppercase":
|
|
891
|
-
return ".NAN";
|
|
892
|
-
case "camelcase":
|
|
893
|
-
return ".NaN";
|
|
894
|
-
}
|
|
895
|
-
} else if (Number.POSITIVE_INFINITY === object) {
|
|
896
|
-
switch (style) {
|
|
897
|
-
case "lowercase":
|
|
898
|
-
return ".inf";
|
|
899
|
-
case "uppercase":
|
|
900
|
-
return ".INF";
|
|
901
|
-
case "camelcase":
|
|
902
|
-
return ".Inf";
|
|
903
|
-
}
|
|
904
|
-
} else if (Number.NEGATIVE_INFINITY === object) {
|
|
905
|
-
switch (style) {
|
|
906
|
-
case "lowercase":
|
|
907
|
-
return "-.inf";
|
|
908
|
-
case "uppercase":
|
|
909
|
-
return "-.INF";
|
|
910
|
-
case "camelcase":
|
|
911
|
-
return "-.Inf";
|
|
912
|
-
}
|
|
913
|
-
} else if (common.isNegativeZero(object)) {
|
|
914
|
-
return "-0.0";
|
|
915
|
-
}
|
|
916
|
-
res = object.toString(10);
|
|
917
|
-
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
|
|
918
|
-
}
|
|
919
|
-
function isFloat(object) {
|
|
920
|
-
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
|
|
921
|
-
}
|
|
922
|
-
var float = new type("tag:yaml.org,2002:float", {
|
|
923
|
-
kind: "scalar",
|
|
924
|
-
resolve: resolveYamlFloat,
|
|
925
|
-
construct: constructYamlFloat,
|
|
926
|
-
predicate: isFloat,
|
|
927
|
-
represent: representYamlFloat,
|
|
928
|
-
defaultStyle: "lowercase"
|
|
929
|
-
});
|
|
930
|
-
var json = failsafe.extend({
|
|
931
|
-
implicit: [
|
|
932
|
-
_null,
|
|
933
|
-
bool,
|
|
934
|
-
int,
|
|
935
|
-
float
|
|
936
|
-
]
|
|
937
|
-
});
|
|
938
|
-
var core = json;
|
|
939
|
-
var YAML_DATE_REGEXP = new RegExp(
|
|
940
|
-
"^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
|
|
941
|
-
);
|
|
942
|
-
var YAML_TIMESTAMP_REGEXP = new RegExp(
|
|
943
|
-
"^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"
|
|
944
|
-
);
|
|
945
|
-
function resolveYamlTimestamp(data) {
|
|
946
|
-
if (data === null)
|
|
947
|
-
return false;
|
|
948
|
-
if (YAML_DATE_REGEXP.exec(data) !== null)
|
|
949
|
-
return true;
|
|
950
|
-
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null)
|
|
951
|
-
return true;
|
|
952
|
-
return false;
|
|
953
|
-
}
|
|
954
|
-
function constructYamlTimestamp(data) {
|
|
955
|
-
var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
|
|
956
|
-
match = YAML_DATE_REGEXP.exec(data);
|
|
957
|
-
if (match === null)
|
|
958
|
-
match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
959
|
-
if (match === null)
|
|
960
|
-
throw new Error("Date resolve error");
|
|
961
|
-
year = +match[1];
|
|
962
|
-
month = +match[2] - 1;
|
|
963
|
-
day = +match[3];
|
|
964
|
-
if (!match[4]) {
|
|
965
|
-
return new Date(Date.UTC(year, month, day));
|
|
966
|
-
}
|
|
967
|
-
hour = +match[4];
|
|
968
|
-
minute = +match[5];
|
|
969
|
-
second = +match[6];
|
|
970
|
-
if (match[7]) {
|
|
971
|
-
fraction = match[7].slice(0, 3);
|
|
972
|
-
while (fraction.length < 3) {
|
|
973
|
-
fraction += "0";
|
|
974
|
-
}
|
|
975
|
-
fraction = +fraction;
|
|
976
|
-
}
|
|
977
|
-
if (match[9]) {
|
|
978
|
-
tz_hour = +match[10];
|
|
979
|
-
tz_minute = +(match[11] || 0);
|
|
980
|
-
delta = (tz_hour * 60 + tz_minute) * 6e4;
|
|
981
|
-
if (match[9] === "-")
|
|
982
|
-
delta = -delta;
|
|
983
|
-
}
|
|
984
|
-
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
985
|
-
if (delta)
|
|
986
|
-
date.setTime(date.getTime() - delta);
|
|
987
|
-
return date;
|
|
988
|
-
}
|
|
989
|
-
function representYamlTimestamp(object) {
|
|
990
|
-
return object.toISOString();
|
|
991
|
-
}
|
|
992
|
-
var timestamp = new type("tag:yaml.org,2002:timestamp", {
|
|
993
|
-
kind: "scalar",
|
|
994
|
-
resolve: resolveYamlTimestamp,
|
|
995
|
-
construct: constructYamlTimestamp,
|
|
996
|
-
instanceOf: Date,
|
|
997
|
-
represent: representYamlTimestamp
|
|
998
|
-
});
|
|
999
|
-
function resolveYamlMerge(data) {
|
|
1000
|
-
return data === "<<" || data === null;
|
|
1001
|
-
}
|
|
1002
|
-
var merge = new type("tag:yaml.org,2002:merge", {
|
|
1003
|
-
kind: "scalar",
|
|
1004
|
-
resolve: resolveYamlMerge
|
|
1005
|
-
});
|
|
1006
|
-
var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
|
|
1007
|
-
function resolveYamlBinary(data) {
|
|
1008
|
-
if (data === null)
|
|
1009
|
-
return false;
|
|
1010
|
-
var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
|
|
1011
|
-
for (idx = 0; idx < max; idx++) {
|
|
1012
|
-
code = map2.indexOf(data.charAt(idx));
|
|
1013
|
-
if (code > 64)
|
|
1014
|
-
continue;
|
|
1015
|
-
if (code < 0)
|
|
1016
|
-
return false;
|
|
1017
|
-
bitlen += 6;
|
|
1018
|
-
}
|
|
1019
|
-
return bitlen % 8 === 0;
|
|
1020
|
-
}
|
|
1021
|
-
function constructYamlBinary(data) {
|
|
1022
|
-
var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = [];
|
|
1023
|
-
for (idx = 0; idx < max; idx++) {
|
|
1024
|
-
if (idx % 4 === 0 && idx) {
|
|
1025
|
-
result.push(bits >> 16 & 255);
|
|
1026
|
-
result.push(bits >> 8 & 255);
|
|
1027
|
-
result.push(bits & 255);
|
|
1028
|
-
}
|
|
1029
|
-
bits = bits << 6 | map2.indexOf(input.charAt(idx));
|
|
1030
|
-
}
|
|
1031
|
-
tailbits = max % 4 * 6;
|
|
1032
|
-
if (tailbits === 0) {
|
|
1033
|
-
result.push(bits >> 16 & 255);
|
|
1034
|
-
result.push(bits >> 8 & 255);
|
|
1035
|
-
result.push(bits & 255);
|
|
1036
|
-
} else if (tailbits === 18) {
|
|
1037
|
-
result.push(bits >> 10 & 255);
|
|
1038
|
-
result.push(bits >> 2 & 255);
|
|
1039
|
-
} else if (tailbits === 12) {
|
|
1040
|
-
result.push(bits >> 4 & 255);
|
|
1041
|
-
}
|
|
1042
|
-
return new Uint8Array(result);
|
|
1043
|
-
}
|
|
1044
|
-
function representYamlBinary(object) {
|
|
1045
|
-
var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP;
|
|
1046
|
-
for (idx = 0; idx < max; idx++) {
|
|
1047
|
-
if (idx % 3 === 0 && idx) {
|
|
1048
|
-
result += map2[bits >> 18 & 63];
|
|
1049
|
-
result += map2[bits >> 12 & 63];
|
|
1050
|
-
result += map2[bits >> 6 & 63];
|
|
1051
|
-
result += map2[bits & 63];
|
|
1052
|
-
}
|
|
1053
|
-
bits = (bits << 8) + object[idx];
|
|
1054
|
-
}
|
|
1055
|
-
tail = max % 3;
|
|
1056
|
-
if (tail === 0) {
|
|
1057
|
-
result += map2[bits >> 18 & 63];
|
|
1058
|
-
result += map2[bits >> 12 & 63];
|
|
1059
|
-
result += map2[bits >> 6 & 63];
|
|
1060
|
-
result += map2[bits & 63];
|
|
1061
|
-
} else if (tail === 2) {
|
|
1062
|
-
result += map2[bits >> 10 & 63];
|
|
1063
|
-
result += map2[bits >> 4 & 63];
|
|
1064
|
-
result += map2[bits << 2 & 63];
|
|
1065
|
-
result += map2[64];
|
|
1066
|
-
} else if (tail === 1) {
|
|
1067
|
-
result += map2[bits >> 2 & 63];
|
|
1068
|
-
result += map2[bits << 4 & 63];
|
|
1069
|
-
result += map2[64];
|
|
1070
|
-
result += map2[64];
|
|
1071
|
-
}
|
|
1072
|
-
return result;
|
|
1073
|
-
}
|
|
1074
|
-
function isBinary(obj) {
|
|
1075
|
-
return Object.prototype.toString.call(obj) === "[object Uint8Array]";
|
|
1076
|
-
}
|
|
1077
|
-
var binary = new type("tag:yaml.org,2002:binary", {
|
|
1078
|
-
kind: "scalar",
|
|
1079
|
-
resolve: resolveYamlBinary,
|
|
1080
|
-
construct: constructYamlBinary,
|
|
1081
|
-
predicate: isBinary,
|
|
1082
|
-
represent: representYamlBinary
|
|
1083
|
-
});
|
|
1084
|
-
var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
1085
|
-
var _toString$2 = Object.prototype.toString;
|
|
1086
|
-
function resolveYamlOmap(data) {
|
|
1087
|
-
if (data === null)
|
|
1088
|
-
return true;
|
|
1089
|
-
var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
|
|
1090
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
1091
|
-
pair = object[index];
|
|
1092
|
-
pairHasKey = false;
|
|
1093
|
-
if (_toString$2.call(pair) !== "[object Object]")
|
|
1094
|
-
return false;
|
|
1095
|
-
for (pairKey in pair) {
|
|
1096
|
-
if (_hasOwnProperty$3.call(pair, pairKey)) {
|
|
1097
|
-
if (!pairHasKey)
|
|
1098
|
-
pairHasKey = true;
|
|
1099
|
-
else
|
|
1100
|
-
return false;
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
if (!pairHasKey)
|
|
1104
|
-
return false;
|
|
1105
|
-
if (objectKeys.indexOf(pairKey) === -1)
|
|
1106
|
-
objectKeys.push(pairKey);
|
|
1107
|
-
else
|
|
1108
|
-
return false;
|
|
1109
|
-
}
|
|
1110
|
-
return true;
|
|
1111
|
-
}
|
|
1112
|
-
function constructYamlOmap(data) {
|
|
1113
|
-
return data !== null ? data : [];
|
|
1114
|
-
}
|
|
1115
|
-
var omap = new type("tag:yaml.org,2002:omap", {
|
|
1116
|
-
kind: "sequence",
|
|
1117
|
-
resolve: resolveYamlOmap,
|
|
1118
|
-
construct: constructYamlOmap
|
|
1119
|
-
});
|
|
1120
|
-
var _toString$1 = Object.prototype.toString;
|
|
1121
|
-
function resolveYamlPairs(data) {
|
|
1122
|
-
if (data === null)
|
|
1123
|
-
return true;
|
|
1124
|
-
var index, length, pair, keys, result, object = data;
|
|
1125
|
-
result = new Array(object.length);
|
|
1126
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
1127
|
-
pair = object[index];
|
|
1128
|
-
if (_toString$1.call(pair) !== "[object Object]")
|
|
1129
|
-
return false;
|
|
1130
|
-
keys = Object.keys(pair);
|
|
1131
|
-
if (keys.length !== 1)
|
|
1132
|
-
return false;
|
|
1133
|
-
result[index] = [keys[0], pair[keys[0]]];
|
|
1134
|
-
}
|
|
1135
|
-
return true;
|
|
1136
|
-
}
|
|
1137
|
-
function constructYamlPairs(data) {
|
|
1138
|
-
if (data === null)
|
|
1139
|
-
return [];
|
|
1140
|
-
var index, length, pair, keys, result, object = data;
|
|
1141
|
-
result = new Array(object.length);
|
|
1142
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
1143
|
-
pair = object[index];
|
|
1144
|
-
keys = Object.keys(pair);
|
|
1145
|
-
result[index] = [keys[0], pair[keys[0]]];
|
|
1146
|
-
}
|
|
1147
|
-
return result;
|
|
1148
|
-
}
|
|
1149
|
-
var pairs = new type("tag:yaml.org,2002:pairs", {
|
|
1150
|
-
kind: "sequence",
|
|
1151
|
-
resolve: resolveYamlPairs,
|
|
1152
|
-
construct: constructYamlPairs
|
|
1153
|
-
});
|
|
1154
|
-
var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
1155
|
-
function resolveYamlSet(data) {
|
|
1156
|
-
if (data === null)
|
|
1157
|
-
return true;
|
|
1158
|
-
var key, object = data;
|
|
1159
|
-
for (key in object) {
|
|
1160
|
-
if (_hasOwnProperty$2.call(object, key)) {
|
|
1161
|
-
if (object[key] !== null)
|
|
1162
|
-
return false;
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
return true;
|
|
1166
|
-
}
|
|
1167
|
-
function constructYamlSet(data) {
|
|
1168
|
-
return data !== null ? data : {};
|
|
1169
|
-
}
|
|
1170
|
-
var set = new type("tag:yaml.org,2002:set", {
|
|
1171
|
-
kind: "mapping",
|
|
1172
|
-
resolve: resolveYamlSet,
|
|
1173
|
-
construct: constructYamlSet
|
|
1174
|
-
});
|
|
1175
|
-
var _default = core.extend({
|
|
1176
|
-
implicit: [
|
|
1177
|
-
timestamp,
|
|
1178
|
-
merge
|
|
1179
|
-
],
|
|
1180
|
-
explicit: [
|
|
1181
|
-
binary,
|
|
1182
|
-
omap,
|
|
1183
|
-
pairs,
|
|
1184
|
-
set
|
|
1185
|
-
]
|
|
1186
|
-
});
|
|
1187
|
-
var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
1188
|
-
var CONTEXT_FLOW_IN = 1;
|
|
1189
|
-
var CONTEXT_FLOW_OUT = 2;
|
|
1190
|
-
var CONTEXT_BLOCK_IN = 3;
|
|
1191
|
-
var CONTEXT_BLOCK_OUT = 4;
|
|
1192
|
-
var CHOMPING_CLIP = 1;
|
|
1193
|
-
var CHOMPING_STRIP = 2;
|
|
1194
|
-
var CHOMPING_KEEP = 3;
|
|
1195
|
-
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
1196
|
-
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
1197
|
-
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
|
1198
|
-
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
1199
|
-
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
1200
|
-
function _class(obj) {
|
|
1201
|
-
return Object.prototype.toString.call(obj);
|
|
1202
|
-
}
|
|
1203
|
-
function is_EOL(c) {
|
|
1204
|
-
return c === 10 || c === 13;
|
|
1205
|
-
}
|
|
1206
|
-
function is_WHITE_SPACE(c) {
|
|
1207
|
-
return c === 9 || c === 32;
|
|
1208
|
-
}
|
|
1209
|
-
function is_WS_OR_EOL(c) {
|
|
1210
|
-
return c === 9 || c === 32 || c === 10 || c === 13;
|
|
1211
|
-
}
|
|
1212
|
-
function is_FLOW_INDICATOR(c) {
|
|
1213
|
-
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
1214
|
-
}
|
|
1215
|
-
function fromHexCode(c) {
|
|
1216
|
-
var lc;
|
|
1217
|
-
if (48 <= c && c <= 57) {
|
|
1218
|
-
return c - 48;
|
|
1219
|
-
}
|
|
1220
|
-
lc = c | 32;
|
|
1221
|
-
if (97 <= lc && lc <= 102) {
|
|
1222
|
-
return lc - 97 + 10;
|
|
1223
|
-
}
|
|
1224
|
-
return -1;
|
|
1225
|
-
}
|
|
1226
|
-
function escapedHexLen(c) {
|
|
1227
|
-
if (c === 120) {
|
|
1228
|
-
return 2;
|
|
1229
|
-
}
|
|
1230
|
-
if (c === 117) {
|
|
1231
|
-
return 4;
|
|
1232
|
-
}
|
|
1233
|
-
if (c === 85) {
|
|
1234
|
-
return 8;
|
|
1235
|
-
}
|
|
1236
|
-
return 0;
|
|
1237
|
-
}
|
|
1238
|
-
function fromDecimalCode(c) {
|
|
1239
|
-
if (48 <= c && c <= 57) {
|
|
1240
|
-
return c - 48;
|
|
1241
|
-
}
|
|
1242
|
-
return -1;
|
|
1243
|
-
}
|
|
1244
|
-
function simpleEscapeSequence(c) {
|
|
1245
|
-
return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "\x85" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
|
|
1246
|
-
}
|
|
1247
|
-
function charFromCodepoint(c) {
|
|
1248
|
-
if (c <= 65535) {
|
|
1249
|
-
return String.fromCharCode(c);
|
|
1250
|
-
}
|
|
1251
|
-
return String.fromCharCode(
|
|
1252
|
-
(c - 65536 >> 10) + 55296,
|
|
1253
|
-
(c - 65536 & 1023) + 56320
|
|
1254
|
-
);
|
|
1255
|
-
}
|
|
1256
|
-
var simpleEscapeCheck = new Array(256);
|
|
1257
|
-
var simpleEscapeMap = new Array(256);
|
|
1258
|
-
for (i = 0; i < 256; i++) {
|
|
1259
|
-
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
1260
|
-
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
1261
|
-
}
|
|
1262
|
-
var i;
|
|
1263
|
-
function State$1(input, options) {
|
|
1264
|
-
this.input = input;
|
|
1265
|
-
this.filename = options["filename"] || null;
|
|
1266
|
-
this.schema = options["schema"] || _default;
|
|
1267
|
-
this.onWarning = options["onWarning"] || null;
|
|
1268
|
-
this.legacy = options["legacy"] || false;
|
|
1269
|
-
this.json = options["json"] || false;
|
|
1270
|
-
this.listener = options["listener"] || null;
|
|
1271
|
-
this.implicitTypes = this.schema.compiledImplicit;
|
|
1272
|
-
this.typeMap = this.schema.compiledTypeMap;
|
|
1273
|
-
this.length = input.length;
|
|
1274
|
-
this.position = 0;
|
|
1275
|
-
this.line = 0;
|
|
1276
|
-
this.lineStart = 0;
|
|
1277
|
-
this.lineIndent = 0;
|
|
1278
|
-
this.firstTabInLine = -1;
|
|
1279
|
-
this.documents = [];
|
|
1280
|
-
}
|
|
1281
|
-
function generateError(state, message) {
|
|
1282
|
-
var mark = {
|
|
1283
|
-
name: state.filename,
|
|
1284
|
-
buffer: state.input.slice(0, -1),
|
|
1285
|
-
// omit trailing \0
|
|
1286
|
-
position: state.position,
|
|
1287
|
-
line: state.line,
|
|
1288
|
-
column: state.position - state.lineStart
|
|
1289
|
-
};
|
|
1290
|
-
mark.snippet = snippet(mark);
|
|
1291
|
-
return new exception(message, mark);
|
|
1292
|
-
}
|
|
1293
|
-
function throwError(state, message) {
|
|
1294
|
-
throw generateError(state, message);
|
|
1295
|
-
}
|
|
1296
|
-
function throwWarning(state, message) {
|
|
1297
|
-
if (state.onWarning) {
|
|
1298
|
-
state.onWarning.call(null, generateError(state, message));
|
|
1299
|
-
}
|
|
1300
|
-
}
|
|
1301
|
-
var directiveHandlers = {
|
|
1302
|
-
YAML: function handleYamlDirective(state, name, args) {
|
|
1303
|
-
var match, major, minor;
|
|
1304
|
-
if (state.version !== null) {
|
|
1305
|
-
throwError(state, "duplication of %YAML directive");
|
|
1306
|
-
}
|
|
1307
|
-
if (args.length !== 1) {
|
|
1308
|
-
throwError(state, "YAML directive accepts exactly one argument");
|
|
1309
|
-
}
|
|
1310
|
-
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
1311
|
-
if (match === null) {
|
|
1312
|
-
throwError(state, "ill-formed argument of the YAML directive");
|
|
1313
|
-
}
|
|
1314
|
-
major = parseInt(match[1], 10);
|
|
1315
|
-
minor = parseInt(match[2], 10);
|
|
1316
|
-
if (major !== 1) {
|
|
1317
|
-
throwError(state, "unacceptable YAML version of the document");
|
|
1318
|
-
}
|
|
1319
|
-
state.version = args[0];
|
|
1320
|
-
state.checkLineBreaks = minor < 2;
|
|
1321
|
-
if (minor !== 1 && minor !== 2) {
|
|
1322
|
-
throwWarning(state, "unsupported YAML version of the document");
|
|
1323
|
-
}
|
|
1324
|
-
},
|
|
1325
|
-
TAG: function handleTagDirective(state, name, args) {
|
|
1326
|
-
var handle, prefix;
|
|
1327
|
-
if (args.length !== 2) {
|
|
1328
|
-
throwError(state, "TAG directive accepts exactly two arguments");
|
|
1329
|
-
}
|
|
1330
|
-
handle = args[0];
|
|
1331
|
-
prefix = args[1];
|
|
1332
|
-
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
1333
|
-
throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
|
|
1334
|
-
}
|
|
1335
|
-
if (_hasOwnProperty$1.call(state.tagMap, handle)) {
|
|
1336
|
-
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
|
1337
|
-
}
|
|
1338
|
-
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
1339
|
-
throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
|
|
1340
|
-
}
|
|
1341
|
-
try {
|
|
1342
|
-
prefix = decodeURIComponent(prefix);
|
|
1343
|
-
} catch (err) {
|
|
1344
|
-
throwError(state, "tag prefix is malformed: " + prefix);
|
|
1345
|
-
}
|
|
1346
|
-
state.tagMap[handle] = prefix;
|
|
1347
|
-
}
|
|
1348
|
-
};
|
|
1349
|
-
function captureSegment(state, start, end, checkJson) {
|
|
1350
|
-
var _position, _length, _character, _result;
|
|
1351
|
-
if (start < end) {
|
|
1352
|
-
_result = state.input.slice(start, end);
|
|
1353
|
-
if (checkJson) {
|
|
1354
|
-
for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
|
|
1355
|
-
_character = _result.charCodeAt(_position);
|
|
1356
|
-
if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
|
|
1357
|
-
throwError(state, "expected valid JSON character");
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
} else if (PATTERN_NON_PRINTABLE.test(_result)) {
|
|
1361
|
-
throwError(state, "the stream contains non-printable characters");
|
|
1362
|
-
}
|
|
1363
|
-
state.result += _result;
|
|
1364
|
-
}
|
|
1365
|
-
}
|
|
1366
|
-
function mergeMappings(state, destination, source, overridableKeys) {
|
|
1367
|
-
var sourceKeys, key, index, quantity;
|
|
1368
|
-
if (!common.isObject(source)) {
|
|
1369
|
-
throwError(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
1370
|
-
}
|
|
1371
|
-
sourceKeys = Object.keys(source);
|
|
1372
|
-
for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
|
|
1373
|
-
key = sourceKeys[index];
|
|
1374
|
-
if (!_hasOwnProperty$1.call(destination, key)) {
|
|
1375
|
-
destination[key] = source[key];
|
|
1376
|
-
overridableKeys[key] = true;
|
|
1377
|
-
}
|
|
1378
|
-
}
|
|
1379
|
-
}
|
|
1380
|
-
function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
|
|
1381
|
-
var index, quantity;
|
|
1382
|
-
if (Array.isArray(keyNode)) {
|
|
1383
|
-
keyNode = Array.prototype.slice.call(keyNode);
|
|
1384
|
-
for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
|
|
1385
|
-
if (Array.isArray(keyNode[index])) {
|
|
1386
|
-
throwError(state, "nested arrays are not supported inside keys");
|
|
1387
|
-
}
|
|
1388
|
-
if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
|
|
1389
|
-
keyNode[index] = "[object Object]";
|
|
1390
|
-
}
|
|
1391
|
-
}
|
|
1392
|
-
}
|
|
1393
|
-
if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
|
|
1394
|
-
keyNode = "[object Object]";
|
|
1395
|
-
}
|
|
1396
|
-
keyNode = String(keyNode);
|
|
1397
|
-
if (_result === null) {
|
|
1398
|
-
_result = {};
|
|
1399
|
-
}
|
|
1400
|
-
if (keyTag === "tag:yaml.org,2002:merge") {
|
|
1401
|
-
if (Array.isArray(valueNode)) {
|
|
1402
|
-
for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
|
|
1403
|
-
mergeMappings(state, _result, valueNode[index], overridableKeys);
|
|
1404
|
-
}
|
|
1405
|
-
} else {
|
|
1406
|
-
mergeMappings(state, _result, valueNode, overridableKeys);
|
|
1407
|
-
}
|
|
1408
|
-
} else {
|
|
1409
|
-
if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) {
|
|
1410
|
-
state.line = startLine || state.line;
|
|
1411
|
-
state.lineStart = startLineStart || state.lineStart;
|
|
1412
|
-
state.position = startPos || state.position;
|
|
1413
|
-
throwError(state, "duplicated mapping key");
|
|
1414
|
-
}
|
|
1415
|
-
if (keyNode === "__proto__") {
|
|
1416
|
-
Object.defineProperty(_result, keyNode, {
|
|
1417
|
-
configurable: true,
|
|
1418
|
-
enumerable: true,
|
|
1419
|
-
writable: true,
|
|
1420
|
-
value: valueNode
|
|
1421
|
-
});
|
|
1422
|
-
} else {
|
|
1423
|
-
_result[keyNode] = valueNode;
|
|
1424
|
-
}
|
|
1425
|
-
delete overridableKeys[keyNode];
|
|
1426
|
-
}
|
|
1427
|
-
return _result;
|
|
1428
|
-
}
|
|
1429
|
-
function readLineBreak(state) {
|
|
1430
|
-
var ch;
|
|
1431
|
-
ch = state.input.charCodeAt(state.position);
|
|
1432
|
-
if (ch === 10) {
|
|
1433
|
-
state.position++;
|
|
1434
|
-
} else if (ch === 13) {
|
|
1435
|
-
state.position++;
|
|
1436
|
-
if (state.input.charCodeAt(state.position) === 10) {
|
|
1437
|
-
state.position++;
|
|
1438
|
-
}
|
|
1439
|
-
} else {
|
|
1440
|
-
throwError(state, "a line break is expected");
|
|
1441
|
-
}
|
|
1442
|
-
state.line += 1;
|
|
1443
|
-
state.lineStart = state.position;
|
|
1444
|
-
state.firstTabInLine = -1;
|
|
1445
|
-
}
|
|
1446
|
-
function skipSeparationSpace(state, allowComments, checkIndent) {
|
|
1447
|
-
var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
|
|
1448
|
-
while (ch !== 0) {
|
|
1449
|
-
while (is_WHITE_SPACE(ch)) {
|
|
1450
|
-
if (ch === 9 && state.firstTabInLine === -1) {
|
|
1451
|
-
state.firstTabInLine = state.position;
|
|
1452
|
-
}
|
|
1453
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1454
|
-
}
|
|
1455
|
-
if (allowComments && ch === 35) {
|
|
1456
|
-
do {
|
|
1457
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1458
|
-
} while (ch !== 10 && ch !== 13 && ch !== 0);
|
|
1459
|
-
}
|
|
1460
|
-
if (is_EOL(ch)) {
|
|
1461
|
-
readLineBreak(state);
|
|
1462
|
-
ch = state.input.charCodeAt(state.position);
|
|
1463
|
-
lineBreaks++;
|
|
1464
|
-
state.lineIndent = 0;
|
|
1465
|
-
while (ch === 32) {
|
|
1466
|
-
state.lineIndent++;
|
|
1467
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1468
|
-
}
|
|
1469
|
-
} else {
|
|
1470
|
-
break;
|
|
1471
|
-
}
|
|
1472
|
-
}
|
|
1473
|
-
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
|
|
1474
|
-
throwWarning(state, "deficient indentation");
|
|
1475
|
-
}
|
|
1476
|
-
return lineBreaks;
|
|
1477
|
-
}
|
|
1478
|
-
function testDocumentSeparator(state) {
|
|
1479
|
-
var _position = state.position, ch;
|
|
1480
|
-
ch = state.input.charCodeAt(_position);
|
|
1481
|
-
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
|
|
1482
|
-
_position += 3;
|
|
1483
|
-
ch = state.input.charCodeAt(_position);
|
|
1484
|
-
if (ch === 0 || is_WS_OR_EOL(ch)) {
|
|
1485
|
-
return true;
|
|
1486
|
-
}
|
|
1487
|
-
}
|
|
1488
|
-
return false;
|
|
1489
|
-
}
|
|
1490
|
-
function writeFoldedLines(state, count) {
|
|
1491
|
-
if (count === 1) {
|
|
1492
|
-
state.result += " ";
|
|
1493
|
-
} else if (count > 1) {
|
|
1494
|
-
state.result += common.repeat("\n", count - 1);
|
|
1495
|
-
}
|
|
1496
|
-
}
|
|
1497
|
-
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
1498
|
-
var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
|
|
1499
|
-
ch = state.input.charCodeAt(state.position);
|
|
1500
|
-
if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) {
|
|
1501
|
-
return false;
|
|
1502
|
-
}
|
|
1503
|
-
if (ch === 63 || ch === 45) {
|
|
1504
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1505
|
-
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1506
|
-
return false;
|
|
1507
|
-
}
|
|
1508
|
-
}
|
|
1509
|
-
state.kind = "scalar";
|
|
1510
|
-
state.result = "";
|
|
1511
|
-
captureStart = captureEnd = state.position;
|
|
1512
|
-
hasPendingContent = false;
|
|
1513
|
-
while (ch !== 0) {
|
|
1514
|
-
if (ch === 58) {
|
|
1515
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1516
|
-
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
1517
|
-
break;
|
|
1518
|
-
}
|
|
1519
|
-
} else if (ch === 35) {
|
|
1520
|
-
preceding = state.input.charCodeAt(state.position - 1);
|
|
1521
|
-
if (is_WS_OR_EOL(preceding)) {
|
|
1522
|
-
break;
|
|
1523
|
-
}
|
|
1524
|
-
} else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
|
|
1525
|
-
break;
|
|
1526
|
-
} else if (is_EOL(ch)) {
|
|
1527
|
-
_line = state.line;
|
|
1528
|
-
_lineStart = state.lineStart;
|
|
1529
|
-
_lineIndent = state.lineIndent;
|
|
1530
|
-
skipSeparationSpace(state, false, -1);
|
|
1531
|
-
if (state.lineIndent >= nodeIndent) {
|
|
1532
|
-
hasPendingContent = true;
|
|
1533
|
-
ch = state.input.charCodeAt(state.position);
|
|
1534
|
-
continue;
|
|
1535
|
-
} else {
|
|
1536
|
-
state.position = captureEnd;
|
|
1537
|
-
state.line = _line;
|
|
1538
|
-
state.lineStart = _lineStart;
|
|
1539
|
-
state.lineIndent = _lineIndent;
|
|
1540
|
-
break;
|
|
1541
|
-
}
|
|
1542
|
-
}
|
|
1543
|
-
if (hasPendingContent) {
|
|
1544
|
-
captureSegment(state, captureStart, captureEnd, false);
|
|
1545
|
-
writeFoldedLines(state, state.line - _line);
|
|
1546
|
-
captureStart = captureEnd = state.position;
|
|
1547
|
-
hasPendingContent = false;
|
|
1548
|
-
}
|
|
1549
|
-
if (!is_WHITE_SPACE(ch)) {
|
|
1550
|
-
captureEnd = state.position + 1;
|
|
1551
|
-
}
|
|
1552
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1553
|
-
}
|
|
1554
|
-
captureSegment(state, captureStart, captureEnd, false);
|
|
1555
|
-
if (state.result) {
|
|
1556
|
-
return true;
|
|
1557
|
-
}
|
|
1558
|
-
state.kind = _kind;
|
|
1559
|
-
state.result = _result;
|
|
1560
|
-
return false;
|
|
1561
|
-
}
|
|
1562
|
-
function readSingleQuotedScalar(state, nodeIndent) {
|
|
1563
|
-
var ch, captureStart, captureEnd;
|
|
1564
|
-
ch = state.input.charCodeAt(state.position);
|
|
1565
|
-
if (ch !== 39) {
|
|
1566
|
-
return false;
|
|
1567
|
-
}
|
|
1568
|
-
state.kind = "scalar";
|
|
1569
|
-
state.result = "";
|
|
1570
|
-
state.position++;
|
|
1571
|
-
captureStart = captureEnd = state.position;
|
|
1572
|
-
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1573
|
-
if (ch === 39) {
|
|
1574
|
-
captureSegment(state, captureStart, state.position, true);
|
|
1575
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1576
|
-
if (ch === 39) {
|
|
1577
|
-
captureStart = state.position;
|
|
1578
|
-
state.position++;
|
|
1579
|
-
captureEnd = state.position;
|
|
1580
|
-
} else {
|
|
1581
|
-
return true;
|
|
1582
|
-
}
|
|
1583
|
-
} else if (is_EOL(ch)) {
|
|
1584
|
-
captureSegment(state, captureStart, captureEnd, true);
|
|
1585
|
-
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1586
|
-
captureStart = captureEnd = state.position;
|
|
1587
|
-
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1588
|
-
throwError(state, "unexpected end of the document within a single quoted scalar");
|
|
1589
|
-
} else {
|
|
1590
|
-
state.position++;
|
|
1591
|
-
captureEnd = state.position;
|
|
1592
|
-
}
|
|
1593
|
-
}
|
|
1594
|
-
throwError(state, "unexpected end of the stream within a single quoted scalar");
|
|
1595
|
-
}
|
|
1596
|
-
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
1597
|
-
var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
|
|
1598
|
-
ch = state.input.charCodeAt(state.position);
|
|
1599
|
-
if (ch !== 34) {
|
|
1600
|
-
return false;
|
|
1601
|
-
}
|
|
1602
|
-
state.kind = "scalar";
|
|
1603
|
-
state.result = "";
|
|
1604
|
-
state.position++;
|
|
1605
|
-
captureStart = captureEnd = state.position;
|
|
1606
|
-
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
1607
|
-
if (ch === 34) {
|
|
1608
|
-
captureSegment(state, captureStart, state.position, true);
|
|
1609
|
-
state.position++;
|
|
1610
|
-
return true;
|
|
1611
|
-
} else if (ch === 92) {
|
|
1612
|
-
captureSegment(state, captureStart, state.position, true);
|
|
1613
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1614
|
-
if (is_EOL(ch)) {
|
|
1615
|
-
skipSeparationSpace(state, false, nodeIndent);
|
|
1616
|
-
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
|
1617
|
-
state.result += simpleEscapeMap[ch];
|
|
1618
|
-
state.position++;
|
|
1619
|
-
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
|
1620
|
-
hexLength = tmp;
|
|
1621
|
-
hexResult = 0;
|
|
1622
|
-
for (; hexLength > 0; hexLength--) {
|
|
1623
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1624
|
-
if ((tmp = fromHexCode(ch)) >= 0) {
|
|
1625
|
-
hexResult = (hexResult << 4) + tmp;
|
|
1626
|
-
} else {
|
|
1627
|
-
throwError(state, "expected hexadecimal character");
|
|
1628
|
-
}
|
|
1629
|
-
}
|
|
1630
|
-
state.result += charFromCodepoint(hexResult);
|
|
1631
|
-
state.position++;
|
|
1632
|
-
} else {
|
|
1633
|
-
throwError(state, "unknown escape sequence");
|
|
1634
|
-
}
|
|
1635
|
-
captureStart = captureEnd = state.position;
|
|
1636
|
-
} else if (is_EOL(ch)) {
|
|
1637
|
-
captureSegment(state, captureStart, captureEnd, true);
|
|
1638
|
-
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
1639
|
-
captureStart = captureEnd = state.position;
|
|
1640
|
-
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
1641
|
-
throwError(state, "unexpected end of the document within a double quoted scalar");
|
|
1642
|
-
} else {
|
|
1643
|
-
state.position++;
|
|
1644
|
-
captureEnd = state.position;
|
|
1645
|
-
}
|
|
1646
|
-
}
|
|
1647
|
-
throwError(state, "unexpected end of the stream within a double quoted scalar");
|
|
1648
|
-
}
|
|
1649
|
-
function readFlowCollection(state, nodeIndent) {
|
|
1650
|
-
var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = /* @__PURE__ */ Object.create(null), keyNode, keyTag, valueNode, ch;
|
|
1651
|
-
ch = state.input.charCodeAt(state.position);
|
|
1652
|
-
if (ch === 91) {
|
|
1653
|
-
terminator = 93;
|
|
1654
|
-
isMapping = false;
|
|
1655
|
-
_result = [];
|
|
1656
|
-
} else if (ch === 123) {
|
|
1657
|
-
terminator = 125;
|
|
1658
|
-
isMapping = true;
|
|
1659
|
-
_result = {};
|
|
1660
|
-
} else {
|
|
1661
|
-
return false;
|
|
1662
|
-
}
|
|
1663
|
-
if (state.anchor !== null) {
|
|
1664
|
-
state.anchorMap[state.anchor] = _result;
|
|
1665
|
-
}
|
|
1666
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1667
|
-
while (ch !== 0) {
|
|
1668
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1669
|
-
ch = state.input.charCodeAt(state.position);
|
|
1670
|
-
if (ch === terminator) {
|
|
1671
|
-
state.position++;
|
|
1672
|
-
state.tag = _tag;
|
|
1673
|
-
state.anchor = _anchor;
|
|
1674
|
-
state.kind = isMapping ? "mapping" : "sequence";
|
|
1675
|
-
state.result = _result;
|
|
1676
|
-
return true;
|
|
1677
|
-
} else if (!readNext) {
|
|
1678
|
-
throwError(state, "missed comma between flow collection entries");
|
|
1679
|
-
} else if (ch === 44) {
|
|
1680
|
-
throwError(state, "expected the node content, but found ','");
|
|
1681
|
-
}
|
|
1682
|
-
keyTag = keyNode = valueNode = null;
|
|
1683
|
-
isPair = isExplicitPair = false;
|
|
1684
|
-
if (ch === 63) {
|
|
1685
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1686
|
-
if (is_WS_OR_EOL(following)) {
|
|
1687
|
-
isPair = isExplicitPair = true;
|
|
1688
|
-
state.position++;
|
|
1689
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1690
|
-
}
|
|
1691
|
-
}
|
|
1692
|
-
_line = state.line;
|
|
1693
|
-
_lineStart = state.lineStart;
|
|
1694
|
-
_pos = state.position;
|
|
1695
|
-
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1696
|
-
keyTag = state.tag;
|
|
1697
|
-
keyNode = state.result;
|
|
1698
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1699
|
-
ch = state.input.charCodeAt(state.position);
|
|
1700
|
-
if ((isExplicitPair || state.line === _line) && ch === 58) {
|
|
1701
|
-
isPair = true;
|
|
1702
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1703
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1704
|
-
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
1705
|
-
valueNode = state.result;
|
|
1706
|
-
}
|
|
1707
|
-
if (isMapping) {
|
|
1708
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
|
|
1709
|
-
} else if (isPair) {
|
|
1710
|
-
_result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
|
|
1711
|
-
} else {
|
|
1712
|
-
_result.push(keyNode);
|
|
1713
|
-
}
|
|
1714
|
-
skipSeparationSpace(state, true, nodeIndent);
|
|
1715
|
-
ch = state.input.charCodeAt(state.position);
|
|
1716
|
-
if (ch === 44) {
|
|
1717
|
-
readNext = true;
|
|
1718
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1719
|
-
} else {
|
|
1720
|
-
readNext = false;
|
|
1721
|
-
}
|
|
1722
|
-
}
|
|
1723
|
-
throwError(state, "unexpected end of the stream within a flow collection");
|
|
1724
|
-
}
|
|
1725
|
-
function readBlockScalar(state, nodeIndent) {
|
|
1726
|
-
var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
|
|
1727
|
-
ch = state.input.charCodeAt(state.position);
|
|
1728
|
-
if (ch === 124) {
|
|
1729
|
-
folding = false;
|
|
1730
|
-
} else if (ch === 62) {
|
|
1731
|
-
folding = true;
|
|
1732
|
-
} else {
|
|
1733
|
-
return false;
|
|
1734
|
-
}
|
|
1735
|
-
state.kind = "scalar";
|
|
1736
|
-
state.result = "";
|
|
1737
|
-
while (ch !== 0) {
|
|
1738
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1739
|
-
if (ch === 43 || ch === 45) {
|
|
1740
|
-
if (CHOMPING_CLIP === chomping) {
|
|
1741
|
-
chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
1742
|
-
} else {
|
|
1743
|
-
throwError(state, "repeat of a chomping mode identifier");
|
|
1744
|
-
}
|
|
1745
|
-
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
|
1746
|
-
if (tmp === 0) {
|
|
1747
|
-
throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
1748
|
-
} else if (!detectedIndent) {
|
|
1749
|
-
textIndent = nodeIndent + tmp - 1;
|
|
1750
|
-
detectedIndent = true;
|
|
1751
|
-
} else {
|
|
1752
|
-
throwError(state, "repeat of an indentation width identifier");
|
|
1753
|
-
}
|
|
1754
|
-
} else {
|
|
1755
|
-
break;
|
|
1756
|
-
}
|
|
1757
|
-
}
|
|
1758
|
-
if (is_WHITE_SPACE(ch)) {
|
|
1759
|
-
do {
|
|
1760
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1761
|
-
} while (is_WHITE_SPACE(ch));
|
|
1762
|
-
if (ch === 35) {
|
|
1763
|
-
do {
|
|
1764
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1765
|
-
} while (!is_EOL(ch) && ch !== 0);
|
|
1766
|
-
}
|
|
1767
|
-
}
|
|
1768
|
-
while (ch !== 0) {
|
|
1769
|
-
readLineBreak(state);
|
|
1770
|
-
state.lineIndent = 0;
|
|
1771
|
-
ch = state.input.charCodeAt(state.position);
|
|
1772
|
-
while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
|
|
1773
|
-
state.lineIndent++;
|
|
1774
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1775
|
-
}
|
|
1776
|
-
if (!detectedIndent && state.lineIndent > textIndent) {
|
|
1777
|
-
textIndent = state.lineIndent;
|
|
1778
|
-
}
|
|
1779
|
-
if (is_EOL(ch)) {
|
|
1780
|
-
emptyLines++;
|
|
1781
|
-
continue;
|
|
1782
|
-
}
|
|
1783
|
-
if (state.lineIndent < textIndent) {
|
|
1784
|
-
if (chomping === CHOMPING_KEEP) {
|
|
1785
|
-
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1786
|
-
} else if (chomping === CHOMPING_CLIP) {
|
|
1787
|
-
if (didReadContent) {
|
|
1788
|
-
state.result += "\n";
|
|
1789
|
-
}
|
|
1790
|
-
}
|
|
1791
|
-
break;
|
|
1792
|
-
}
|
|
1793
|
-
if (folding) {
|
|
1794
|
-
if (is_WHITE_SPACE(ch)) {
|
|
1795
|
-
atMoreIndented = true;
|
|
1796
|
-
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1797
|
-
} else if (atMoreIndented) {
|
|
1798
|
-
atMoreIndented = false;
|
|
1799
|
-
state.result += common.repeat("\n", emptyLines + 1);
|
|
1800
|
-
} else if (emptyLines === 0) {
|
|
1801
|
-
if (didReadContent) {
|
|
1802
|
-
state.result += " ";
|
|
1803
|
-
}
|
|
1804
|
-
} else {
|
|
1805
|
-
state.result += common.repeat("\n", emptyLines);
|
|
1806
|
-
}
|
|
1807
|
-
} else {
|
|
1808
|
-
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
1809
|
-
}
|
|
1810
|
-
didReadContent = true;
|
|
1811
|
-
detectedIndent = true;
|
|
1812
|
-
emptyLines = 0;
|
|
1813
|
-
captureStart = state.position;
|
|
1814
|
-
while (!is_EOL(ch) && ch !== 0) {
|
|
1815
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1816
|
-
}
|
|
1817
|
-
captureSegment(state, captureStart, state.position, false);
|
|
1818
|
-
}
|
|
1819
|
-
return true;
|
|
1820
|
-
}
|
|
1821
|
-
function readBlockSequence(state, nodeIndent) {
|
|
1822
|
-
var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
|
|
1823
|
-
if (state.firstTabInLine !== -1)
|
|
1824
|
-
return false;
|
|
1825
|
-
if (state.anchor !== null) {
|
|
1826
|
-
state.anchorMap[state.anchor] = _result;
|
|
1827
|
-
}
|
|
1828
|
-
ch = state.input.charCodeAt(state.position);
|
|
1829
|
-
while (ch !== 0) {
|
|
1830
|
-
if (state.firstTabInLine !== -1) {
|
|
1831
|
-
state.position = state.firstTabInLine;
|
|
1832
|
-
throwError(state, "tab characters must not be used in indentation");
|
|
1833
|
-
}
|
|
1834
|
-
if (ch !== 45) {
|
|
1835
|
-
break;
|
|
1836
|
-
}
|
|
1837
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1838
|
-
if (!is_WS_OR_EOL(following)) {
|
|
1839
|
-
break;
|
|
1840
|
-
}
|
|
1841
|
-
detected = true;
|
|
1842
|
-
state.position++;
|
|
1843
|
-
if (skipSeparationSpace(state, true, -1)) {
|
|
1844
|
-
if (state.lineIndent <= nodeIndent) {
|
|
1845
|
-
_result.push(null);
|
|
1846
|
-
ch = state.input.charCodeAt(state.position);
|
|
1847
|
-
continue;
|
|
1848
|
-
}
|
|
1849
|
-
}
|
|
1850
|
-
_line = state.line;
|
|
1851
|
-
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
1852
|
-
_result.push(state.result);
|
|
1853
|
-
skipSeparationSpace(state, true, -1);
|
|
1854
|
-
ch = state.input.charCodeAt(state.position);
|
|
1855
|
-
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
1856
|
-
throwError(state, "bad indentation of a sequence entry");
|
|
1857
|
-
} else if (state.lineIndent < nodeIndent) {
|
|
1858
|
-
break;
|
|
1859
|
-
}
|
|
1860
|
-
}
|
|
1861
|
-
if (detected) {
|
|
1862
|
-
state.tag = _tag;
|
|
1863
|
-
state.anchor = _anchor;
|
|
1864
|
-
state.kind = "sequence";
|
|
1865
|
-
state.result = _result;
|
|
1866
|
-
return true;
|
|
1867
|
-
}
|
|
1868
|
-
return false;
|
|
1869
|
-
}
|
|
1870
|
-
function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
1871
|
-
var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = /* @__PURE__ */ Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
|
|
1872
|
-
if (state.firstTabInLine !== -1)
|
|
1873
|
-
return false;
|
|
1874
|
-
if (state.anchor !== null) {
|
|
1875
|
-
state.anchorMap[state.anchor] = _result;
|
|
1876
|
-
}
|
|
1877
|
-
ch = state.input.charCodeAt(state.position);
|
|
1878
|
-
while (ch !== 0) {
|
|
1879
|
-
if (!atExplicitKey && state.firstTabInLine !== -1) {
|
|
1880
|
-
state.position = state.firstTabInLine;
|
|
1881
|
-
throwError(state, "tab characters must not be used in indentation");
|
|
1882
|
-
}
|
|
1883
|
-
following = state.input.charCodeAt(state.position + 1);
|
|
1884
|
-
_line = state.line;
|
|
1885
|
-
if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
|
|
1886
|
-
if (ch === 63) {
|
|
1887
|
-
if (atExplicitKey) {
|
|
1888
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1889
|
-
keyTag = keyNode = valueNode = null;
|
|
1890
|
-
}
|
|
1891
|
-
detected = true;
|
|
1892
|
-
atExplicitKey = true;
|
|
1893
|
-
allowCompact = true;
|
|
1894
|
-
} else if (atExplicitKey) {
|
|
1895
|
-
atExplicitKey = false;
|
|
1896
|
-
allowCompact = true;
|
|
1897
|
-
} else {
|
|
1898
|
-
throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
|
|
1899
|
-
}
|
|
1900
|
-
state.position += 1;
|
|
1901
|
-
ch = following;
|
|
1902
|
-
} else {
|
|
1903
|
-
_keyLine = state.line;
|
|
1904
|
-
_keyLineStart = state.lineStart;
|
|
1905
|
-
_keyPos = state.position;
|
|
1906
|
-
if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
|
1907
|
-
break;
|
|
1908
|
-
}
|
|
1909
|
-
if (state.line === _line) {
|
|
1910
|
-
ch = state.input.charCodeAt(state.position);
|
|
1911
|
-
while (is_WHITE_SPACE(ch)) {
|
|
1912
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1913
|
-
}
|
|
1914
|
-
if (ch === 58) {
|
|
1915
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1916
|
-
if (!is_WS_OR_EOL(ch)) {
|
|
1917
|
-
throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
1918
|
-
}
|
|
1919
|
-
if (atExplicitKey) {
|
|
1920
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1921
|
-
keyTag = keyNode = valueNode = null;
|
|
1922
|
-
}
|
|
1923
|
-
detected = true;
|
|
1924
|
-
atExplicitKey = false;
|
|
1925
|
-
allowCompact = false;
|
|
1926
|
-
keyTag = state.tag;
|
|
1927
|
-
keyNode = state.result;
|
|
1928
|
-
} else if (detected) {
|
|
1929
|
-
throwError(state, "can not read an implicit mapping pair; a colon is missed");
|
|
1930
|
-
} else {
|
|
1931
|
-
state.tag = _tag;
|
|
1932
|
-
state.anchor = _anchor;
|
|
1933
|
-
return true;
|
|
1934
|
-
}
|
|
1935
|
-
} else if (detected) {
|
|
1936
|
-
throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
|
|
1937
|
-
} else {
|
|
1938
|
-
state.tag = _tag;
|
|
1939
|
-
state.anchor = _anchor;
|
|
1940
|
-
return true;
|
|
1941
|
-
}
|
|
1942
|
-
}
|
|
1943
|
-
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
1944
|
-
if (atExplicitKey) {
|
|
1945
|
-
_keyLine = state.line;
|
|
1946
|
-
_keyLineStart = state.lineStart;
|
|
1947
|
-
_keyPos = state.position;
|
|
1948
|
-
}
|
|
1949
|
-
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
|
1950
|
-
if (atExplicitKey) {
|
|
1951
|
-
keyNode = state.result;
|
|
1952
|
-
} else {
|
|
1953
|
-
valueNode = state.result;
|
|
1954
|
-
}
|
|
1955
|
-
}
|
|
1956
|
-
if (!atExplicitKey) {
|
|
1957
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
|
|
1958
|
-
keyTag = keyNode = valueNode = null;
|
|
1959
|
-
}
|
|
1960
|
-
skipSeparationSpace(state, true, -1);
|
|
1961
|
-
ch = state.input.charCodeAt(state.position);
|
|
1962
|
-
}
|
|
1963
|
-
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
1964
|
-
throwError(state, "bad indentation of a mapping entry");
|
|
1965
|
-
} else if (state.lineIndent < nodeIndent) {
|
|
1966
|
-
break;
|
|
1967
|
-
}
|
|
1968
|
-
}
|
|
1969
|
-
if (atExplicitKey) {
|
|
1970
|
-
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
1971
|
-
}
|
|
1972
|
-
if (detected) {
|
|
1973
|
-
state.tag = _tag;
|
|
1974
|
-
state.anchor = _anchor;
|
|
1975
|
-
state.kind = "mapping";
|
|
1976
|
-
state.result = _result;
|
|
1977
|
-
}
|
|
1978
|
-
return detected;
|
|
1979
|
-
}
|
|
1980
|
-
function readTagProperty(state) {
|
|
1981
|
-
var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
|
|
1982
|
-
ch = state.input.charCodeAt(state.position);
|
|
1983
|
-
if (ch !== 33)
|
|
1984
|
-
return false;
|
|
1985
|
-
if (state.tag !== null) {
|
|
1986
|
-
throwError(state, "duplication of a tag property");
|
|
1987
|
-
}
|
|
1988
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1989
|
-
if (ch === 60) {
|
|
1990
|
-
isVerbatim = true;
|
|
1991
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1992
|
-
} else if (ch === 33) {
|
|
1993
|
-
isNamed = true;
|
|
1994
|
-
tagHandle = "!!";
|
|
1995
|
-
ch = state.input.charCodeAt(++state.position);
|
|
1996
|
-
} else {
|
|
1997
|
-
tagHandle = "!";
|
|
1998
|
-
}
|
|
1999
|
-
_position = state.position;
|
|
2000
|
-
if (isVerbatim) {
|
|
2001
|
-
do {
|
|
2002
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2003
|
-
} while (ch !== 0 && ch !== 62);
|
|
2004
|
-
if (state.position < state.length) {
|
|
2005
|
-
tagName = state.input.slice(_position, state.position);
|
|
2006
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2007
|
-
} else {
|
|
2008
|
-
throwError(state, "unexpected end of the stream within a verbatim tag");
|
|
2009
|
-
}
|
|
2010
|
-
} else {
|
|
2011
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2012
|
-
if (ch === 33) {
|
|
2013
|
-
if (!isNamed) {
|
|
2014
|
-
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
2015
|
-
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
2016
|
-
throwError(state, "named tag handle cannot contain such characters");
|
|
2017
|
-
}
|
|
2018
|
-
isNamed = true;
|
|
2019
|
-
_position = state.position + 1;
|
|
2020
|
-
} else {
|
|
2021
|
-
throwError(state, "tag suffix cannot contain exclamation marks");
|
|
2022
|
-
}
|
|
2023
|
-
}
|
|
2024
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2025
|
-
}
|
|
2026
|
-
tagName = state.input.slice(_position, state.position);
|
|
2027
|
-
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
2028
|
-
throwError(state, "tag suffix cannot contain flow indicator characters");
|
|
2029
|
-
}
|
|
2030
|
-
}
|
|
2031
|
-
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
|
2032
|
-
throwError(state, "tag name cannot contain such characters: " + tagName);
|
|
2033
|
-
}
|
|
2034
|
-
try {
|
|
2035
|
-
tagName = decodeURIComponent(tagName);
|
|
2036
|
-
} catch (err) {
|
|
2037
|
-
throwError(state, "tag name is malformed: " + tagName);
|
|
2038
|
-
}
|
|
2039
|
-
if (isVerbatim) {
|
|
2040
|
-
state.tag = tagName;
|
|
2041
|
-
} else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
|
|
2042
|
-
state.tag = state.tagMap[tagHandle] + tagName;
|
|
2043
|
-
} else if (tagHandle === "!") {
|
|
2044
|
-
state.tag = "!" + tagName;
|
|
2045
|
-
} else if (tagHandle === "!!") {
|
|
2046
|
-
state.tag = "tag:yaml.org,2002:" + tagName;
|
|
2047
|
-
} else {
|
|
2048
|
-
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
|
2049
|
-
}
|
|
2050
|
-
return true;
|
|
2051
|
-
}
|
|
2052
|
-
function readAnchorProperty(state) {
|
|
2053
|
-
var _position, ch;
|
|
2054
|
-
ch = state.input.charCodeAt(state.position);
|
|
2055
|
-
if (ch !== 38)
|
|
2056
|
-
return false;
|
|
2057
|
-
if (state.anchor !== null) {
|
|
2058
|
-
throwError(state, "duplication of an anchor property");
|
|
2059
|
-
}
|
|
2060
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2061
|
-
_position = state.position;
|
|
2062
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
2063
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2064
|
-
}
|
|
2065
|
-
if (state.position === _position) {
|
|
2066
|
-
throwError(state, "name of an anchor node must contain at least one character");
|
|
2067
|
-
}
|
|
2068
|
-
state.anchor = state.input.slice(_position, state.position);
|
|
2069
|
-
return true;
|
|
2070
|
-
}
|
|
2071
|
-
function readAlias(state) {
|
|
2072
|
-
var _position, alias, ch;
|
|
2073
|
-
ch = state.input.charCodeAt(state.position);
|
|
2074
|
-
if (ch !== 42)
|
|
2075
|
-
return false;
|
|
2076
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2077
|
-
_position = state.position;
|
|
2078
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
2079
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2080
|
-
}
|
|
2081
|
-
if (state.position === _position) {
|
|
2082
|
-
throwError(state, "name of an alias node must contain at least one character");
|
|
2083
|
-
}
|
|
2084
|
-
alias = state.input.slice(_position, state.position);
|
|
2085
|
-
if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
|
|
2086
|
-
throwError(state, 'unidentified alias "' + alias + '"');
|
|
2087
|
-
}
|
|
2088
|
-
state.result = state.anchorMap[alias];
|
|
2089
|
-
skipSeparationSpace(state, true, -1);
|
|
2090
|
-
return true;
|
|
2091
|
-
}
|
|
2092
|
-
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
2093
|
-
var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent;
|
|
2094
|
-
if (state.listener !== null) {
|
|
2095
|
-
state.listener("open", state);
|
|
2096
|
-
}
|
|
2097
|
-
state.tag = null;
|
|
2098
|
-
state.anchor = null;
|
|
2099
|
-
state.kind = null;
|
|
2100
|
-
state.result = null;
|
|
2101
|
-
allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
|
|
2102
|
-
if (allowToSeek) {
|
|
2103
|
-
if (skipSeparationSpace(state, true, -1)) {
|
|
2104
|
-
atNewLine = true;
|
|
2105
|
-
if (state.lineIndent > parentIndent) {
|
|
2106
|
-
indentStatus = 1;
|
|
2107
|
-
} else if (state.lineIndent === parentIndent) {
|
|
2108
|
-
indentStatus = 0;
|
|
2109
|
-
} else if (state.lineIndent < parentIndent) {
|
|
2110
|
-
indentStatus = -1;
|
|
2111
|
-
}
|
|
2112
|
-
}
|
|
2113
|
-
}
|
|
2114
|
-
if (indentStatus === 1) {
|
|
2115
|
-
while (readTagProperty(state) || readAnchorProperty(state)) {
|
|
2116
|
-
if (skipSeparationSpace(state, true, -1)) {
|
|
2117
|
-
atNewLine = true;
|
|
2118
|
-
allowBlockCollections = allowBlockStyles;
|
|
2119
|
-
if (state.lineIndent > parentIndent) {
|
|
2120
|
-
indentStatus = 1;
|
|
2121
|
-
} else if (state.lineIndent === parentIndent) {
|
|
2122
|
-
indentStatus = 0;
|
|
2123
|
-
} else if (state.lineIndent < parentIndent) {
|
|
2124
|
-
indentStatus = -1;
|
|
2125
|
-
}
|
|
2126
|
-
} else {
|
|
2127
|
-
allowBlockCollections = false;
|
|
2128
|
-
}
|
|
2129
|
-
}
|
|
2130
|
-
}
|
|
2131
|
-
if (allowBlockCollections) {
|
|
2132
|
-
allowBlockCollections = atNewLine || allowCompact;
|
|
2133
|
-
}
|
|
2134
|
-
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
|
|
2135
|
-
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
|
2136
|
-
flowIndent = parentIndent;
|
|
2137
|
-
} else {
|
|
2138
|
-
flowIndent = parentIndent + 1;
|
|
2139
|
-
}
|
|
2140
|
-
blockIndent = state.position - state.lineStart;
|
|
2141
|
-
if (indentStatus === 1) {
|
|
2142
|
-
if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
|
|
2143
|
-
hasContent = true;
|
|
2144
|
-
} else {
|
|
2145
|
-
if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
|
|
2146
|
-
hasContent = true;
|
|
2147
|
-
} else if (readAlias(state)) {
|
|
2148
|
-
hasContent = true;
|
|
2149
|
-
if (state.tag !== null || state.anchor !== null) {
|
|
2150
|
-
throwError(state, "alias node should not have any properties");
|
|
2151
|
-
}
|
|
2152
|
-
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
2153
|
-
hasContent = true;
|
|
2154
|
-
if (state.tag === null) {
|
|
2155
|
-
state.tag = "?";
|
|
2156
|
-
}
|
|
2157
|
-
}
|
|
2158
|
-
if (state.anchor !== null) {
|
|
2159
|
-
state.anchorMap[state.anchor] = state.result;
|
|
2160
|
-
}
|
|
2161
|
-
}
|
|
2162
|
-
} else if (indentStatus === 0) {
|
|
2163
|
-
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
|
2164
|
-
}
|
|
2165
|
-
}
|
|
2166
|
-
if (state.tag === null) {
|
|
2167
|
-
if (state.anchor !== null) {
|
|
2168
|
-
state.anchorMap[state.anchor] = state.result;
|
|
2169
|
-
}
|
|
2170
|
-
} else if (state.tag === "?") {
|
|
2171
|
-
if (state.result !== null && state.kind !== "scalar") {
|
|
2172
|
-
throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
|
|
2173
|
-
}
|
|
2174
|
-
for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
2175
|
-
type2 = state.implicitTypes[typeIndex];
|
|
2176
|
-
if (type2.resolve(state.result)) {
|
|
2177
|
-
state.result = type2.construct(state.result);
|
|
2178
|
-
state.tag = type2.tag;
|
|
2179
|
-
if (state.anchor !== null) {
|
|
2180
|
-
state.anchorMap[state.anchor] = state.result;
|
|
2181
|
-
}
|
|
2182
|
-
break;
|
|
2183
|
-
}
|
|
2184
|
-
}
|
|
2185
|
-
} else if (state.tag !== "!") {
|
|
2186
|
-
if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) {
|
|
2187
|
-
type2 = state.typeMap[state.kind || "fallback"][state.tag];
|
|
2188
|
-
} else {
|
|
2189
|
-
type2 = null;
|
|
2190
|
-
typeList = state.typeMap.multi[state.kind || "fallback"];
|
|
2191
|
-
for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
2192
|
-
if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
|
|
2193
|
-
type2 = typeList[typeIndex];
|
|
2194
|
-
break;
|
|
2195
|
-
}
|
|
2196
|
-
}
|
|
2197
|
-
}
|
|
2198
|
-
if (!type2) {
|
|
2199
|
-
throwError(state, "unknown tag !<" + state.tag + ">");
|
|
2200
|
-
}
|
|
2201
|
-
if (state.result !== null && type2.kind !== state.kind) {
|
|
2202
|
-
throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
|
|
2203
|
-
}
|
|
2204
|
-
if (!type2.resolve(state.result, state.tag)) {
|
|
2205
|
-
throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
|
|
2206
|
-
} else {
|
|
2207
|
-
state.result = type2.construct(state.result, state.tag);
|
|
2208
|
-
if (state.anchor !== null) {
|
|
2209
|
-
state.anchorMap[state.anchor] = state.result;
|
|
2210
|
-
}
|
|
2211
|
-
}
|
|
2212
|
-
}
|
|
2213
|
-
if (state.listener !== null) {
|
|
2214
|
-
state.listener("close", state);
|
|
2215
|
-
}
|
|
2216
|
-
return state.tag !== null || state.anchor !== null || hasContent;
|
|
2217
|
-
}
|
|
2218
|
-
function readDocument(state) {
|
|
2219
|
-
var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
|
|
2220
|
-
state.version = null;
|
|
2221
|
-
state.checkLineBreaks = state.legacy;
|
|
2222
|
-
state.tagMap = /* @__PURE__ */ Object.create(null);
|
|
2223
|
-
state.anchorMap = /* @__PURE__ */ Object.create(null);
|
|
2224
|
-
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
2225
|
-
skipSeparationSpace(state, true, -1);
|
|
2226
|
-
ch = state.input.charCodeAt(state.position);
|
|
2227
|
-
if (state.lineIndent > 0 || ch !== 37) {
|
|
2228
|
-
break;
|
|
2229
|
-
}
|
|
2230
|
-
hasDirectives = true;
|
|
2231
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2232
|
-
_position = state.position;
|
|
2233
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2234
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2235
|
-
}
|
|
2236
|
-
directiveName = state.input.slice(_position, state.position);
|
|
2237
|
-
directiveArgs = [];
|
|
2238
|
-
if (directiveName.length < 1) {
|
|
2239
|
-
throwError(state, "directive name must not be less than one character in length");
|
|
2240
|
-
}
|
|
2241
|
-
while (ch !== 0) {
|
|
2242
|
-
while (is_WHITE_SPACE(ch)) {
|
|
2243
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2244
|
-
}
|
|
2245
|
-
if (ch === 35) {
|
|
2246
|
-
do {
|
|
2247
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2248
|
-
} while (ch !== 0 && !is_EOL(ch));
|
|
2249
|
-
break;
|
|
2250
|
-
}
|
|
2251
|
-
if (is_EOL(ch))
|
|
2252
|
-
break;
|
|
2253
|
-
_position = state.position;
|
|
2254
|
-
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
2255
|
-
ch = state.input.charCodeAt(++state.position);
|
|
2256
|
-
}
|
|
2257
|
-
directiveArgs.push(state.input.slice(_position, state.position));
|
|
2258
|
-
}
|
|
2259
|
-
if (ch !== 0)
|
|
2260
|
-
readLineBreak(state);
|
|
2261
|
-
if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
|
|
2262
|
-
directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
|
2263
|
-
} else {
|
|
2264
|
-
throwWarning(state, 'unknown document directive "' + directiveName + '"');
|
|
2265
|
-
}
|
|
2266
|
-
}
|
|
2267
|
-
skipSeparationSpace(state, true, -1);
|
|
2268
|
-
if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
|
|
2269
|
-
state.position += 3;
|
|
2270
|
-
skipSeparationSpace(state, true, -1);
|
|
2271
|
-
} else if (hasDirectives) {
|
|
2272
|
-
throwError(state, "directives end mark is expected");
|
|
2273
|
-
}
|
|
2274
|
-
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
|
2275
|
-
skipSeparationSpace(state, true, -1);
|
|
2276
|
-
if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
|
2277
|
-
throwWarning(state, "non-ASCII line breaks are interpreted as content");
|
|
2278
|
-
}
|
|
2279
|
-
state.documents.push(state.result);
|
|
2280
|
-
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
2281
|
-
if (state.input.charCodeAt(state.position) === 46) {
|
|
2282
|
-
state.position += 3;
|
|
2283
|
-
skipSeparationSpace(state, true, -1);
|
|
2284
|
-
}
|
|
2285
|
-
return;
|
|
2286
|
-
}
|
|
2287
|
-
if (state.position < state.length - 1) {
|
|
2288
|
-
throwError(state, "end of the stream or a document separator is expected");
|
|
2289
|
-
} else {
|
|
2290
|
-
return;
|
|
2291
|
-
}
|
|
2292
|
-
}
|
|
2293
|
-
function loadDocuments(input, options) {
|
|
2294
|
-
input = String(input);
|
|
2295
|
-
options = options || {};
|
|
2296
|
-
if (input.length !== 0) {
|
|
2297
|
-
if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
|
|
2298
|
-
input += "\n";
|
|
2299
|
-
}
|
|
2300
|
-
if (input.charCodeAt(0) === 65279) {
|
|
2301
|
-
input = input.slice(1);
|
|
2302
|
-
}
|
|
2303
|
-
}
|
|
2304
|
-
var state = new State$1(input, options);
|
|
2305
|
-
var nullpos = input.indexOf("\0");
|
|
2306
|
-
if (nullpos !== -1) {
|
|
2307
|
-
state.position = nullpos;
|
|
2308
|
-
throwError(state, "null byte is not allowed in input");
|
|
2309
|
-
}
|
|
2310
|
-
state.input += "\0";
|
|
2311
|
-
while (state.input.charCodeAt(state.position) === 32) {
|
|
2312
|
-
state.lineIndent += 1;
|
|
2313
|
-
state.position += 1;
|
|
2314
|
-
}
|
|
2315
|
-
while (state.position < state.length - 1) {
|
|
2316
|
-
readDocument(state);
|
|
2317
|
-
}
|
|
2318
|
-
return state.documents;
|
|
2319
|
-
}
|
|
2320
|
-
function loadAll$1(input, iterator, options) {
|
|
2321
|
-
if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
|
|
2322
|
-
options = iterator;
|
|
2323
|
-
iterator = null;
|
|
2324
|
-
}
|
|
2325
|
-
var documents = loadDocuments(input, options);
|
|
2326
|
-
if (typeof iterator !== "function") {
|
|
2327
|
-
return documents;
|
|
2328
|
-
}
|
|
2329
|
-
for (var index = 0, length = documents.length; index < length; index += 1) {
|
|
2330
|
-
iterator(documents[index]);
|
|
2331
|
-
}
|
|
2332
|
-
}
|
|
2333
|
-
function load$1(input, options) {
|
|
2334
|
-
var documents = loadDocuments(input, options);
|
|
2335
|
-
if (documents.length === 0) {
|
|
2336
|
-
return void 0;
|
|
2337
|
-
} else if (documents.length === 1) {
|
|
2338
|
-
return documents[0];
|
|
2339
|
-
}
|
|
2340
|
-
throw new exception("expected a single document in the stream, but found more");
|
|
2341
|
-
}
|
|
2342
|
-
var loadAll_1 = loadAll$1;
|
|
2343
|
-
var load_1 = load$1;
|
|
2344
|
-
var loader = {
|
|
2345
|
-
loadAll: loadAll_1,
|
|
2346
|
-
load: load_1
|
|
2347
|
-
};
|
|
2348
|
-
var _toString = Object.prototype.toString;
|
|
2349
|
-
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
2350
|
-
var CHAR_BOM = 65279;
|
|
2351
|
-
var CHAR_TAB = 9;
|
|
2352
|
-
var CHAR_LINE_FEED = 10;
|
|
2353
|
-
var CHAR_CARRIAGE_RETURN = 13;
|
|
2354
|
-
var CHAR_SPACE = 32;
|
|
2355
|
-
var CHAR_EXCLAMATION = 33;
|
|
2356
|
-
var CHAR_DOUBLE_QUOTE = 34;
|
|
2357
|
-
var CHAR_SHARP = 35;
|
|
2358
|
-
var CHAR_PERCENT = 37;
|
|
2359
|
-
var CHAR_AMPERSAND = 38;
|
|
2360
|
-
var CHAR_SINGLE_QUOTE = 39;
|
|
2361
|
-
var CHAR_ASTERISK = 42;
|
|
2362
|
-
var CHAR_COMMA = 44;
|
|
2363
|
-
var CHAR_MINUS = 45;
|
|
2364
|
-
var CHAR_COLON = 58;
|
|
2365
|
-
var CHAR_EQUALS = 61;
|
|
2366
|
-
var CHAR_GREATER_THAN = 62;
|
|
2367
|
-
var CHAR_QUESTION = 63;
|
|
2368
|
-
var CHAR_COMMERCIAL_AT = 64;
|
|
2369
|
-
var CHAR_LEFT_SQUARE_BRACKET = 91;
|
|
2370
|
-
var CHAR_RIGHT_SQUARE_BRACKET = 93;
|
|
2371
|
-
var CHAR_GRAVE_ACCENT = 96;
|
|
2372
|
-
var CHAR_LEFT_CURLY_BRACKET = 123;
|
|
2373
|
-
var CHAR_VERTICAL_LINE = 124;
|
|
2374
|
-
var CHAR_RIGHT_CURLY_BRACKET = 125;
|
|
2375
|
-
var ESCAPE_SEQUENCES = {};
|
|
2376
|
-
ESCAPE_SEQUENCES[0] = "\\0";
|
|
2377
|
-
ESCAPE_SEQUENCES[7] = "\\a";
|
|
2378
|
-
ESCAPE_SEQUENCES[8] = "\\b";
|
|
2379
|
-
ESCAPE_SEQUENCES[9] = "\\t";
|
|
2380
|
-
ESCAPE_SEQUENCES[10] = "\\n";
|
|
2381
|
-
ESCAPE_SEQUENCES[11] = "\\v";
|
|
2382
|
-
ESCAPE_SEQUENCES[12] = "\\f";
|
|
2383
|
-
ESCAPE_SEQUENCES[13] = "\\r";
|
|
2384
|
-
ESCAPE_SEQUENCES[27] = "\\e";
|
|
2385
|
-
ESCAPE_SEQUENCES[34] = '\\"';
|
|
2386
|
-
ESCAPE_SEQUENCES[92] = "\\\\";
|
|
2387
|
-
ESCAPE_SEQUENCES[133] = "\\N";
|
|
2388
|
-
ESCAPE_SEQUENCES[160] = "\\_";
|
|
2389
|
-
ESCAPE_SEQUENCES[8232] = "\\L";
|
|
2390
|
-
ESCAPE_SEQUENCES[8233] = "\\P";
|
|
2391
|
-
var DEPRECATED_BOOLEANS_SYNTAX = [
|
|
2392
|
-
"y",
|
|
2393
|
-
"Y",
|
|
2394
|
-
"yes",
|
|
2395
|
-
"Yes",
|
|
2396
|
-
"YES",
|
|
2397
|
-
"on",
|
|
2398
|
-
"On",
|
|
2399
|
-
"ON",
|
|
2400
|
-
"n",
|
|
2401
|
-
"N",
|
|
2402
|
-
"no",
|
|
2403
|
-
"No",
|
|
2404
|
-
"NO",
|
|
2405
|
-
"off",
|
|
2406
|
-
"Off",
|
|
2407
|
-
"OFF"
|
|
2408
|
-
];
|
|
2409
|
-
var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
|
|
2410
|
-
function compileStyleMap(schema2, map2) {
|
|
2411
|
-
var result, keys, index, length, tag, style, type2;
|
|
2412
|
-
if (map2 === null)
|
|
2413
|
-
return {};
|
|
2414
|
-
result = {};
|
|
2415
|
-
keys = Object.keys(map2);
|
|
2416
|
-
for (index = 0, length = keys.length; index < length; index += 1) {
|
|
2417
|
-
tag = keys[index];
|
|
2418
|
-
style = String(map2[tag]);
|
|
2419
|
-
if (tag.slice(0, 2) === "!!") {
|
|
2420
|
-
tag = "tag:yaml.org,2002:" + tag.slice(2);
|
|
2421
|
-
}
|
|
2422
|
-
type2 = schema2.compiledTypeMap["fallback"][tag];
|
|
2423
|
-
if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
|
|
2424
|
-
style = type2.styleAliases[style];
|
|
2425
|
-
}
|
|
2426
|
-
result[tag] = style;
|
|
2427
|
-
}
|
|
2428
|
-
return result;
|
|
2429
|
-
}
|
|
2430
|
-
function encodeHex(character) {
|
|
2431
|
-
var string, handle, length;
|
|
2432
|
-
string = character.toString(16).toUpperCase();
|
|
2433
|
-
if (character <= 255) {
|
|
2434
|
-
handle = "x";
|
|
2435
|
-
length = 2;
|
|
2436
|
-
} else if (character <= 65535) {
|
|
2437
|
-
handle = "u";
|
|
2438
|
-
length = 4;
|
|
2439
|
-
} else if (character <= 4294967295) {
|
|
2440
|
-
handle = "U";
|
|
2441
|
-
length = 8;
|
|
2442
|
-
} else {
|
|
2443
|
-
throw new exception("code point within a string may not be greater than 0xFFFFFFFF");
|
|
2444
|
-
}
|
|
2445
|
-
return "\\" + handle + common.repeat("0", length - string.length) + string;
|
|
2446
|
-
}
|
|
2447
|
-
var QUOTING_TYPE_SINGLE = 1;
|
|
2448
|
-
var QUOTING_TYPE_DOUBLE = 2;
|
|
2449
|
-
function State(options) {
|
|
2450
|
-
this.schema = options["schema"] || _default;
|
|
2451
|
-
this.indent = Math.max(1, options["indent"] || 2);
|
|
2452
|
-
this.noArrayIndent = options["noArrayIndent"] || false;
|
|
2453
|
-
this.skipInvalid = options["skipInvalid"] || false;
|
|
2454
|
-
this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
|
|
2455
|
-
this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
|
|
2456
|
-
this.sortKeys = options["sortKeys"] || false;
|
|
2457
|
-
this.lineWidth = options["lineWidth"] || 80;
|
|
2458
|
-
this.noRefs = options["noRefs"] || false;
|
|
2459
|
-
this.noCompatMode = options["noCompatMode"] || false;
|
|
2460
|
-
this.condenseFlow = options["condenseFlow"] || false;
|
|
2461
|
-
this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
|
|
2462
|
-
this.forceQuotes = options["forceQuotes"] || false;
|
|
2463
|
-
this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
|
|
2464
|
-
this.implicitTypes = this.schema.compiledImplicit;
|
|
2465
|
-
this.explicitTypes = this.schema.compiledExplicit;
|
|
2466
|
-
this.tag = null;
|
|
2467
|
-
this.result = "";
|
|
2468
|
-
this.duplicates = [];
|
|
2469
|
-
this.usedDuplicates = null;
|
|
2470
|
-
}
|
|
2471
|
-
function indentString(string, spaces) {
|
|
2472
|
-
var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
|
|
2473
|
-
while (position < length) {
|
|
2474
|
-
next = string.indexOf("\n", position);
|
|
2475
|
-
if (next === -1) {
|
|
2476
|
-
line = string.slice(position);
|
|
2477
|
-
position = length;
|
|
2478
|
-
} else {
|
|
2479
|
-
line = string.slice(position, next + 1);
|
|
2480
|
-
position = next + 1;
|
|
2481
|
-
}
|
|
2482
|
-
if (line.length && line !== "\n")
|
|
2483
|
-
result += ind;
|
|
2484
|
-
result += line;
|
|
2485
|
-
}
|
|
2486
|
-
return result;
|
|
2487
|
-
}
|
|
2488
|
-
function generateNextLine(state, level) {
|
|
2489
|
-
return "\n" + common.repeat(" ", state.indent * level);
|
|
2490
|
-
}
|
|
2491
|
-
function testImplicitResolving(state, str2) {
|
|
2492
|
-
var index, length, type2;
|
|
2493
|
-
for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
|
|
2494
|
-
type2 = state.implicitTypes[index];
|
|
2495
|
-
if (type2.resolve(str2)) {
|
|
2496
|
-
return true;
|
|
2497
|
-
}
|
|
2498
|
-
}
|
|
2499
|
-
return false;
|
|
2500
|
-
}
|
|
2501
|
-
function isWhitespace(c) {
|
|
2502
|
-
return c === CHAR_SPACE || c === CHAR_TAB;
|
|
2503
|
-
}
|
|
2504
|
-
function isPrintable(c) {
|
|
2505
|
-
return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
|
|
2506
|
-
}
|
|
2507
|
-
function isNsCharOrWhitespace(c) {
|
|
2508
|
-
return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
|
|
2509
|
-
}
|
|
2510
|
-
function isPlainSafe(c, prev, inblock) {
|
|
2511
|
-
var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
|
|
2512
|
-
var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
|
|
2513
|
-
return (
|
|
2514
|
-
// ns-plain-safe
|
|
2515
|
-
(inblock ? (
|
|
2516
|
-
// c = flow-in
|
|
2517
|
-
cIsNsCharOrWhitespace
|
|
2518
|
-
) : cIsNsCharOrWhitespace && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET) && c !== CHAR_SHARP && !(prev === CHAR_COLON && !cIsNsChar) || isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP || prev === CHAR_COLON && cIsNsChar
|
|
2519
|
-
);
|
|
2520
|
-
}
|
|
2521
|
-
function isPlainSafeFirst(c) {
|
|
2522
|
-
return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
|
|
2523
|
-
}
|
|
2524
|
-
function isPlainSafeLast(c) {
|
|
2525
|
-
return !isWhitespace(c) && c !== CHAR_COLON;
|
|
2526
|
-
}
|
|
2527
|
-
function codePointAt(string, pos) {
|
|
2528
|
-
var first = string.charCodeAt(pos), second;
|
|
2529
|
-
if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
|
|
2530
|
-
second = string.charCodeAt(pos + 1);
|
|
2531
|
-
if (second >= 56320 && second <= 57343) {
|
|
2532
|
-
return (first - 55296) * 1024 + second - 56320 + 65536;
|
|
2533
|
-
}
|
|
2534
|
-
}
|
|
2535
|
-
return first;
|
|
2536
|
-
}
|
|
2537
|
-
function needIndentIndicator(string) {
|
|
2538
|
-
var leadingSpaceRe = /^\n* /;
|
|
2539
|
-
return leadingSpaceRe.test(string);
|
|
2540
|
-
}
|
|
2541
|
-
var STYLE_PLAIN = 1;
|
|
2542
|
-
var STYLE_SINGLE = 2;
|
|
2543
|
-
var STYLE_LITERAL = 3;
|
|
2544
|
-
var STYLE_FOLDED = 4;
|
|
2545
|
-
var STYLE_DOUBLE = 5;
|
|
2546
|
-
function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
|
|
2547
|
-
var i;
|
|
2548
|
-
var char = 0;
|
|
2549
|
-
var prevChar = null;
|
|
2550
|
-
var hasLineBreak = false;
|
|
2551
|
-
var hasFoldableLine = false;
|
|
2552
|
-
var shouldTrackWidth = lineWidth !== -1;
|
|
2553
|
-
var previousLineBreak = -1;
|
|
2554
|
-
var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
|
|
2555
|
-
if (singleLineOnly || forceQuotes) {
|
|
2556
|
-
for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
2557
|
-
char = codePointAt(string, i);
|
|
2558
|
-
if (!isPrintable(char)) {
|
|
2559
|
-
return STYLE_DOUBLE;
|
|
2560
|
-
}
|
|
2561
|
-
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
2562
|
-
prevChar = char;
|
|
2563
|
-
}
|
|
2564
|
-
} else {
|
|
2565
|
-
for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
2566
|
-
char = codePointAt(string, i);
|
|
2567
|
-
if (char === CHAR_LINE_FEED) {
|
|
2568
|
-
hasLineBreak = true;
|
|
2569
|
-
if (shouldTrackWidth) {
|
|
2570
|
-
hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
|
|
2571
|
-
i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
|
|
2572
|
-
previousLineBreak = i;
|
|
2573
|
-
}
|
|
2574
|
-
} else if (!isPrintable(char)) {
|
|
2575
|
-
return STYLE_DOUBLE;
|
|
2576
|
-
}
|
|
2577
|
-
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
2578
|
-
prevChar = char;
|
|
2579
|
-
}
|
|
2580
|
-
hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
|
|
2581
|
-
}
|
|
2582
|
-
if (!hasLineBreak && !hasFoldableLine) {
|
|
2583
|
-
if (plain && !forceQuotes && !testAmbiguousType(string)) {
|
|
2584
|
-
return STYLE_PLAIN;
|
|
2585
|
-
}
|
|
2586
|
-
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2587
|
-
}
|
|
2588
|
-
if (indentPerLevel > 9 && needIndentIndicator(string)) {
|
|
2589
|
-
return STYLE_DOUBLE;
|
|
2590
|
-
}
|
|
2591
|
-
if (!forceQuotes) {
|
|
2592
|
-
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
|
2593
|
-
}
|
|
2594
|
-
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
2595
|
-
}
|
|
2596
|
-
function writeScalar(state, string, level, iskey, inblock) {
|
|
2597
|
-
state.dump = function() {
|
|
2598
|
-
if (string.length === 0) {
|
|
2599
|
-
return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
|
|
2600
|
-
}
|
|
2601
|
-
if (!state.noCompatMode) {
|
|
2602
|
-
if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
|
|
2603
|
-
return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
|
|
2604
|
-
}
|
|
2605
|
-
}
|
|
2606
|
-
var indent = state.indent * Math.max(1, level);
|
|
2607
|
-
var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
|
2608
|
-
var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
|
|
2609
|
-
function testAmbiguity(string2) {
|
|
2610
|
-
return testImplicitResolving(state, string2);
|
|
2611
|
-
}
|
|
2612
|
-
switch (chooseScalarStyle(
|
|
2613
|
-
string,
|
|
2614
|
-
singleLineOnly,
|
|
2615
|
-
state.indent,
|
|
2616
|
-
lineWidth,
|
|
2617
|
-
testAmbiguity,
|
|
2618
|
-
state.quotingType,
|
|
2619
|
-
state.forceQuotes && !iskey,
|
|
2620
|
-
inblock
|
|
2621
|
-
)) {
|
|
2622
|
-
case STYLE_PLAIN:
|
|
2623
|
-
return string;
|
|
2624
|
-
case STYLE_SINGLE:
|
|
2625
|
-
return "'" + string.replace(/'/g, "''") + "'";
|
|
2626
|
-
case STYLE_LITERAL:
|
|
2627
|
-
return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
|
|
2628
|
-
case STYLE_FOLDED:
|
|
2629
|
-
return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
|
|
2630
|
-
case STYLE_DOUBLE:
|
|
2631
|
-
return '"' + escapeString(string) + '"';
|
|
2632
|
-
default:
|
|
2633
|
-
throw new exception("impossible error: invalid scalar style");
|
|
2634
|
-
}
|
|
2635
|
-
}();
|
|
2636
|
-
}
|
|
2637
|
-
function blockHeader(string, indentPerLevel) {
|
|
2638
|
-
var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
|
|
2639
|
-
var clip = string[string.length - 1] === "\n";
|
|
2640
|
-
var keep = clip && (string[string.length - 2] === "\n" || string === "\n");
|
|
2641
|
-
var chomp = keep ? "+" : clip ? "" : "-";
|
|
2642
|
-
return indentIndicator + chomp + "\n";
|
|
2643
|
-
}
|
|
2644
|
-
function dropEndingNewline(string) {
|
|
2645
|
-
return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
|
|
2646
|
-
}
|
|
2647
|
-
function foldString(string, width) {
|
|
2648
|
-
var lineRe = /(\n+)([^\n]*)/g;
|
|
2649
|
-
var result = function() {
|
|
2650
|
-
var nextLF = string.indexOf("\n");
|
|
2651
|
-
nextLF = nextLF !== -1 ? nextLF : string.length;
|
|
2652
|
-
lineRe.lastIndex = nextLF;
|
|
2653
|
-
return foldLine(string.slice(0, nextLF), width);
|
|
2654
|
-
}();
|
|
2655
|
-
var prevMoreIndented = string[0] === "\n" || string[0] === " ";
|
|
2656
|
-
var moreIndented;
|
|
2657
|
-
var match;
|
|
2658
|
-
while (match = lineRe.exec(string)) {
|
|
2659
|
-
var prefix = match[1], line = match[2];
|
|
2660
|
-
moreIndented = line[0] === " ";
|
|
2661
|
-
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
|
|
2662
|
-
prevMoreIndented = moreIndented;
|
|
2663
|
-
}
|
|
2664
|
-
return result;
|
|
2665
|
-
}
|
|
2666
|
-
function foldLine(line, width) {
|
|
2667
|
-
if (line === "" || line[0] === " ")
|
|
2668
|
-
return line;
|
|
2669
|
-
var breakRe = / [^ ]/g;
|
|
2670
|
-
var match;
|
|
2671
|
-
var start = 0, end, curr = 0, next = 0;
|
|
2672
|
-
var result = "";
|
|
2673
|
-
while (match = breakRe.exec(line)) {
|
|
2674
|
-
next = match.index;
|
|
2675
|
-
if (next - start > width) {
|
|
2676
|
-
end = curr > start ? curr : next;
|
|
2677
|
-
result += "\n" + line.slice(start, end);
|
|
2678
|
-
start = end + 1;
|
|
2679
|
-
}
|
|
2680
|
-
curr = next;
|
|
2681
|
-
}
|
|
2682
|
-
result += "\n";
|
|
2683
|
-
if (line.length - start > width && curr > start) {
|
|
2684
|
-
result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
|
|
2685
|
-
} else {
|
|
2686
|
-
result += line.slice(start);
|
|
2687
|
-
}
|
|
2688
|
-
return result.slice(1);
|
|
2689
|
-
}
|
|
2690
|
-
function escapeString(string) {
|
|
2691
|
-
var result = "";
|
|
2692
|
-
var char = 0;
|
|
2693
|
-
var escapeSeq;
|
|
2694
|
-
for (var i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
2695
|
-
char = codePointAt(string, i);
|
|
2696
|
-
escapeSeq = ESCAPE_SEQUENCES[char];
|
|
2697
|
-
if (!escapeSeq && isPrintable(char)) {
|
|
2698
|
-
result += string[i];
|
|
2699
|
-
if (char >= 65536)
|
|
2700
|
-
result += string[i + 1];
|
|
2701
|
-
} else {
|
|
2702
|
-
result += escapeSeq || encodeHex(char);
|
|
2703
|
-
}
|
|
2704
|
-
}
|
|
2705
|
-
return result;
|
|
2706
|
-
}
|
|
2707
|
-
function writeFlowSequence(state, level, object) {
|
|
2708
|
-
var _result = "", _tag = state.tag, index, length, value;
|
|
2709
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
2710
|
-
value = object[index];
|
|
2711
|
-
if (state.replacer) {
|
|
2712
|
-
value = state.replacer.call(object, String(index), value);
|
|
2713
|
-
}
|
|
2714
|
-
if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
|
|
2715
|
-
if (_result !== "")
|
|
2716
|
-
_result += "," + (!state.condenseFlow ? " " : "");
|
|
2717
|
-
_result += state.dump;
|
|
2718
|
-
}
|
|
2719
|
-
}
|
|
2720
|
-
state.tag = _tag;
|
|
2721
|
-
state.dump = "[" + _result + "]";
|
|
2722
|
-
}
|
|
2723
|
-
function writeBlockSequence(state, level, object, compact) {
|
|
2724
|
-
var _result = "", _tag = state.tag, index, length, value;
|
|
2725
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
2726
|
-
value = object[index];
|
|
2727
|
-
if (state.replacer) {
|
|
2728
|
-
value = state.replacer.call(object, String(index), value);
|
|
2729
|
-
}
|
|
2730
|
-
if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
|
|
2731
|
-
if (!compact || _result !== "") {
|
|
2732
|
-
_result += generateNextLine(state, level);
|
|
2733
|
-
}
|
|
2734
|
-
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2735
|
-
_result += "-";
|
|
2736
|
-
} else {
|
|
2737
|
-
_result += "- ";
|
|
2738
|
-
}
|
|
2739
|
-
_result += state.dump;
|
|
2740
|
-
}
|
|
2741
|
-
}
|
|
2742
|
-
state.tag = _tag;
|
|
2743
|
-
state.dump = _result || "[]";
|
|
2744
|
-
}
|
|
2745
|
-
function writeFlowMapping(state, level, object) {
|
|
2746
|
-
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
|
|
2747
|
-
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2748
|
-
pairBuffer = "";
|
|
2749
|
-
if (_result !== "")
|
|
2750
|
-
pairBuffer += ", ";
|
|
2751
|
-
if (state.condenseFlow)
|
|
2752
|
-
pairBuffer += '"';
|
|
2753
|
-
objectKey = objectKeyList[index];
|
|
2754
|
-
objectValue = object[objectKey];
|
|
2755
|
-
if (state.replacer) {
|
|
2756
|
-
objectValue = state.replacer.call(object, objectKey, objectValue);
|
|
2757
|
-
}
|
|
2758
|
-
if (!writeNode(state, level, objectKey, false, false)) {
|
|
2759
|
-
continue;
|
|
2760
|
-
}
|
|
2761
|
-
if (state.dump.length > 1024)
|
|
2762
|
-
pairBuffer += "? ";
|
|
2763
|
-
pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
|
|
2764
|
-
if (!writeNode(state, level, objectValue, false, false)) {
|
|
2765
|
-
continue;
|
|
2766
|
-
}
|
|
2767
|
-
pairBuffer += state.dump;
|
|
2768
|
-
_result += pairBuffer;
|
|
2769
|
-
}
|
|
2770
|
-
state.tag = _tag;
|
|
2771
|
-
state.dump = "{" + _result + "}";
|
|
2772
|
-
}
|
|
2773
|
-
function writeBlockMapping(state, level, object, compact) {
|
|
2774
|
-
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
|
|
2775
|
-
if (state.sortKeys === true) {
|
|
2776
|
-
objectKeyList.sort();
|
|
2777
|
-
} else if (typeof state.sortKeys === "function") {
|
|
2778
|
-
objectKeyList.sort(state.sortKeys);
|
|
2779
|
-
} else if (state.sortKeys) {
|
|
2780
|
-
throw new exception("sortKeys must be a boolean or a function");
|
|
2781
|
-
}
|
|
2782
|
-
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2783
|
-
pairBuffer = "";
|
|
2784
|
-
if (!compact || _result !== "") {
|
|
2785
|
-
pairBuffer += generateNextLine(state, level);
|
|
2786
|
-
}
|
|
2787
|
-
objectKey = objectKeyList[index];
|
|
2788
|
-
objectValue = object[objectKey];
|
|
2789
|
-
if (state.replacer) {
|
|
2790
|
-
objectValue = state.replacer.call(object, objectKey, objectValue);
|
|
2791
|
-
}
|
|
2792
|
-
if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
|
2793
|
-
continue;
|
|
2794
|
-
}
|
|
2795
|
-
explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
|
|
2796
|
-
if (explicitPair) {
|
|
2797
|
-
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2798
|
-
pairBuffer += "?";
|
|
2799
|
-
} else {
|
|
2800
|
-
pairBuffer += "? ";
|
|
2801
|
-
}
|
|
2802
|
-
}
|
|
2803
|
-
pairBuffer += state.dump;
|
|
2804
|
-
if (explicitPair) {
|
|
2805
|
-
pairBuffer += generateNextLine(state, level);
|
|
2806
|
-
}
|
|
2807
|
-
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
|
2808
|
-
continue;
|
|
2809
|
-
}
|
|
2810
|
-
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
2811
|
-
pairBuffer += ":";
|
|
2812
|
-
} else {
|
|
2813
|
-
pairBuffer += ": ";
|
|
2814
|
-
}
|
|
2815
|
-
pairBuffer += state.dump;
|
|
2816
|
-
_result += pairBuffer;
|
|
2817
|
-
}
|
|
2818
|
-
state.tag = _tag;
|
|
2819
|
-
state.dump = _result || "{}";
|
|
2820
|
-
}
|
|
2821
|
-
function detectType(state, object, explicit) {
|
|
2822
|
-
var _result, typeList, index, length, type2, style;
|
|
2823
|
-
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
|
2824
|
-
for (index = 0, length = typeList.length; index < length; index += 1) {
|
|
2825
|
-
type2 = typeList[index];
|
|
2826
|
-
if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object === "object" && object instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object))) {
|
|
2827
|
-
if (explicit) {
|
|
2828
|
-
if (type2.multi && type2.representName) {
|
|
2829
|
-
state.tag = type2.representName(object);
|
|
2830
|
-
} else {
|
|
2831
|
-
state.tag = type2.tag;
|
|
2832
|
-
}
|
|
2833
|
-
} else {
|
|
2834
|
-
state.tag = "?";
|
|
2835
|
-
}
|
|
2836
|
-
if (type2.represent) {
|
|
2837
|
-
style = state.styleMap[type2.tag] || type2.defaultStyle;
|
|
2838
|
-
if (_toString.call(type2.represent) === "[object Function]") {
|
|
2839
|
-
_result = type2.represent(object, style);
|
|
2840
|
-
} else if (_hasOwnProperty.call(type2.represent, style)) {
|
|
2841
|
-
_result = type2.represent[style](object, style);
|
|
2842
|
-
} else {
|
|
2843
|
-
throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
|
|
2844
|
-
}
|
|
2845
|
-
state.dump = _result;
|
|
2846
|
-
}
|
|
2847
|
-
return true;
|
|
2848
|
-
}
|
|
2849
|
-
}
|
|
2850
|
-
return false;
|
|
2851
|
-
}
|
|
2852
|
-
function writeNode(state, level, object, block, compact, iskey, isblockseq) {
|
|
2853
|
-
state.tag = null;
|
|
2854
|
-
state.dump = object;
|
|
2855
|
-
if (!detectType(state, object, false)) {
|
|
2856
|
-
detectType(state, object, true);
|
|
2857
|
-
}
|
|
2858
|
-
var type2 = _toString.call(state.dump);
|
|
2859
|
-
var inblock = block;
|
|
2860
|
-
var tagStr;
|
|
2861
|
-
if (block) {
|
|
2862
|
-
block = state.flowLevel < 0 || state.flowLevel > level;
|
|
2863
|
-
}
|
|
2864
|
-
var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate;
|
|
2865
|
-
if (objectOrArray) {
|
|
2866
|
-
duplicateIndex = state.duplicates.indexOf(object);
|
|
2867
|
-
duplicate = duplicateIndex !== -1;
|
|
2868
|
-
}
|
|
2869
|
-
if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
|
|
2870
|
-
compact = false;
|
|
2871
|
-
}
|
|
2872
|
-
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
|
2873
|
-
state.dump = "*ref_" + duplicateIndex;
|
|
2874
|
-
} else {
|
|
2875
|
-
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
|
2876
|
-
state.usedDuplicates[duplicateIndex] = true;
|
|
2877
|
-
}
|
|
2878
|
-
if (type2 === "[object Object]") {
|
|
2879
|
-
if (block && Object.keys(state.dump).length !== 0) {
|
|
2880
|
-
writeBlockMapping(state, level, state.dump, compact);
|
|
2881
|
-
if (duplicate) {
|
|
2882
|
-
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2883
|
-
}
|
|
2884
|
-
} else {
|
|
2885
|
-
writeFlowMapping(state, level, state.dump);
|
|
2886
|
-
if (duplicate) {
|
|
2887
|
-
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
2888
|
-
}
|
|
2889
|
-
}
|
|
2890
|
-
} else if (type2 === "[object Array]") {
|
|
2891
|
-
if (block && state.dump.length !== 0) {
|
|
2892
|
-
if (state.noArrayIndent && !isblockseq && level > 0) {
|
|
2893
|
-
writeBlockSequence(state, level - 1, state.dump, compact);
|
|
2894
|
-
} else {
|
|
2895
|
-
writeBlockSequence(state, level, state.dump, compact);
|
|
2896
|
-
}
|
|
2897
|
-
if (duplicate) {
|
|
2898
|
-
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
2899
|
-
}
|
|
2900
|
-
} else {
|
|
2901
|
-
writeFlowSequence(state, level, state.dump);
|
|
2902
|
-
if (duplicate) {
|
|
2903
|
-
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
2904
|
-
}
|
|
2905
|
-
}
|
|
2906
|
-
} else if (type2 === "[object String]") {
|
|
2907
|
-
if (state.tag !== "?") {
|
|
2908
|
-
writeScalar(state, state.dump, level, iskey, inblock);
|
|
2909
|
-
}
|
|
2910
|
-
} else if (type2 === "[object Undefined]") {
|
|
2911
|
-
return false;
|
|
2912
|
-
} else {
|
|
2913
|
-
if (state.skipInvalid)
|
|
2914
|
-
return false;
|
|
2915
|
-
throw new exception("unacceptable kind of an object to dump " + type2);
|
|
2916
|
-
}
|
|
2917
|
-
if (state.tag !== null && state.tag !== "?") {
|
|
2918
|
-
tagStr = encodeURI(
|
|
2919
|
-
state.tag[0] === "!" ? state.tag.slice(1) : state.tag
|
|
2920
|
-
).replace(/!/g, "%21");
|
|
2921
|
-
if (state.tag[0] === "!") {
|
|
2922
|
-
tagStr = "!" + tagStr;
|
|
2923
|
-
} else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
|
|
2924
|
-
tagStr = "!!" + tagStr.slice(18);
|
|
2925
|
-
} else {
|
|
2926
|
-
tagStr = "!<" + tagStr + ">";
|
|
2927
|
-
}
|
|
2928
|
-
state.dump = tagStr + " " + state.dump;
|
|
2929
|
-
}
|
|
2930
|
-
}
|
|
2931
|
-
return true;
|
|
2932
|
-
}
|
|
2933
|
-
function getDuplicateReferences(object, state) {
|
|
2934
|
-
var objects = [], duplicatesIndexes = [], index, length;
|
|
2935
|
-
inspectNode(object, objects, duplicatesIndexes);
|
|
2936
|
-
for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
|
|
2937
|
-
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
|
2938
|
-
}
|
|
2939
|
-
state.usedDuplicates = new Array(length);
|
|
2940
|
-
}
|
|
2941
|
-
function inspectNode(object, objects, duplicatesIndexes) {
|
|
2942
|
-
var objectKeyList, index, length;
|
|
2943
|
-
if (object !== null && typeof object === "object") {
|
|
2944
|
-
index = objects.indexOf(object);
|
|
2945
|
-
if (index !== -1) {
|
|
2946
|
-
if (duplicatesIndexes.indexOf(index) === -1) {
|
|
2947
|
-
duplicatesIndexes.push(index);
|
|
2948
|
-
}
|
|
2949
|
-
} else {
|
|
2950
|
-
objects.push(object);
|
|
2951
|
-
if (Array.isArray(object)) {
|
|
2952
|
-
for (index = 0, length = object.length; index < length; index += 1) {
|
|
2953
|
-
inspectNode(object[index], objects, duplicatesIndexes);
|
|
2954
|
-
}
|
|
2955
|
-
} else {
|
|
2956
|
-
objectKeyList = Object.keys(object);
|
|
2957
|
-
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
2958
|
-
inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
|
|
2959
|
-
}
|
|
2960
|
-
}
|
|
2961
|
-
}
|
|
2962
|
-
}
|
|
2963
|
-
}
|
|
2964
|
-
function dump$1(input, options) {
|
|
2965
|
-
options = options || {};
|
|
2966
|
-
var state = new State(options);
|
|
2967
|
-
if (!state.noRefs)
|
|
2968
|
-
getDuplicateReferences(input, state);
|
|
2969
|
-
var value = input;
|
|
2970
|
-
if (state.replacer) {
|
|
2971
|
-
value = state.replacer.call({ "": value }, "", value);
|
|
2972
|
-
}
|
|
2973
|
-
if (writeNode(state, 0, value, true, true))
|
|
2974
|
-
return state.dump + "\n";
|
|
2975
|
-
return "";
|
|
2976
|
-
}
|
|
2977
|
-
var dump_1 = dump$1;
|
|
2978
|
-
var dumper = {
|
|
2979
|
-
dump: dump_1
|
|
2980
|
-
};
|
|
2981
|
-
function renamed(from, to) {
|
|
2982
|
-
return function() {
|
|
2983
|
-
throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
|
|
2984
|
-
};
|
|
2985
|
-
}
|
|
2986
|
-
var Type = type;
|
|
2987
|
-
var Schema = schema;
|
|
2988
|
-
var FAILSAFE_SCHEMA = failsafe;
|
|
2989
|
-
var JSON_SCHEMA = json;
|
|
2990
|
-
var CORE_SCHEMA = core;
|
|
2991
|
-
var DEFAULT_SCHEMA = _default;
|
|
2992
|
-
var load = loader.load;
|
|
2993
|
-
var loadAll = loader.loadAll;
|
|
2994
|
-
var dump = dumper.dump;
|
|
2995
|
-
var YAMLException = exception;
|
|
2996
|
-
var types = {
|
|
2997
|
-
binary,
|
|
2998
|
-
float,
|
|
2999
|
-
map,
|
|
3000
|
-
null: _null,
|
|
3001
|
-
pairs,
|
|
3002
|
-
set,
|
|
3003
|
-
timestamp,
|
|
3004
|
-
bool,
|
|
3005
|
-
int,
|
|
3006
|
-
merge,
|
|
3007
|
-
omap,
|
|
3008
|
-
seq,
|
|
3009
|
-
str
|
|
3010
|
-
};
|
|
3011
|
-
var safeLoad = renamed("safeLoad", "load");
|
|
3012
|
-
var safeLoadAll = renamed("safeLoadAll", "loadAll");
|
|
3013
|
-
var safeDump = renamed("safeDump", "dump");
|
|
3014
|
-
var jsYaml = {
|
|
3015
|
-
Type,
|
|
3016
|
-
Schema,
|
|
3017
|
-
FAILSAFE_SCHEMA,
|
|
3018
|
-
JSON_SCHEMA,
|
|
3019
|
-
CORE_SCHEMA,
|
|
3020
|
-
DEFAULT_SCHEMA,
|
|
3021
|
-
load,
|
|
3022
|
-
loadAll,
|
|
3023
|
-
dump,
|
|
3024
|
-
YAMLException,
|
|
3025
|
-
types,
|
|
3026
|
-
safeLoad,
|
|
3027
|
-
safeLoadAll,
|
|
3028
|
-
safeDump
|
|
3029
|
-
};
|
|
3030
|
-
var js_yaml_default = jsYaml;
|
|
3031
|
-
|
|
3032
|
-
// node/vite/loaders.ts
|
|
3033
|
-
import { bold, gray, red, yellow } from "kolorist";
|
|
3034
|
-
import mila from "markdown-it-link-attributes";
|
|
3035
|
-
import * as parser from "@slidev/parser/fs";
|
|
3036
|
-
import equal from "fast-deep-equal";
|
|
3037
|
-
|
|
3038
|
-
// node/virtual/configs.ts
|
|
3039
|
-
import { isString } from "@antfu/utils";
|
|
3040
|
-
var templateConfigs = {
|
|
3041
|
-
id: "/@slidev/configs",
|
|
3042
|
-
getContent: async ({ data, remote }, { md: md2 }) => {
|
|
3043
|
-
function getTitle() {
|
|
3044
|
-
if (isString(data.config.title)) {
|
|
3045
|
-
const tokens = md2.parseInline(data.config.title, {});
|
|
3046
|
-
return stringifyMarkdownTokens(tokens);
|
|
3047
|
-
}
|
|
3048
|
-
return data.config.title;
|
|
3049
|
-
}
|
|
3050
|
-
const config = {
|
|
3051
|
-
...data.config,
|
|
3052
|
-
remote,
|
|
3053
|
-
title: getTitle()
|
|
3054
|
-
};
|
|
3055
|
-
if (isString(config.info))
|
|
3056
|
-
config.info = md2.render(config.info);
|
|
3057
|
-
return `export default ${JSON.stringify(config)}`;
|
|
3058
|
-
}
|
|
3059
|
-
};
|
|
3060
|
-
|
|
3061
|
-
// node/virtual/deprecated.ts
|
|
3062
|
-
var templateLegacyRoutes = {
|
|
3063
|
-
id: "/@slidev/routes",
|
|
3064
|
-
getContent() {
|
|
3065
|
-
return [
|
|
3066
|
-
`export { slides } from '#slidev/slides'`,
|
|
3067
|
-
`console.warn('[slidev] #slidev/routes is deprecated, use #slidev/slides instead')`
|
|
3068
|
-
].join("\n");
|
|
3069
|
-
}
|
|
3070
|
-
};
|
|
3071
|
-
var templateLegacyTitles = {
|
|
3072
|
-
id: "/@slidev/titles.md",
|
|
3073
|
-
async getContent() {
|
|
3074
|
-
return `
|
|
3075
|
-
<script setup lang="ts">
|
|
3076
|
-
import TitleRenderer from '#slidev/title-renderer'
|
|
3077
|
-
defineProps<{ no: number | string }>()
|
|
3078
|
-
console.warn('/@slidev/titles.md is deprecated, import from #slidev/title-renderer instead')
|
|
3079
|
-
</script>
|
|
3080
|
-
|
|
3081
|
-
<TitleRenderer :no="no" />
|
|
3082
|
-
`;
|
|
3083
|
-
}
|
|
3084
|
-
};
|
|
3085
|
-
|
|
3086
|
-
// node/virtual/global-components.ts
|
|
3087
|
-
import { existsSync as existsSync2 } from "node:fs";
|
|
3088
|
-
import { join as join4 } from "node:path";
|
|
3089
|
-
function createGlobalComponentTemplate(layer) {
|
|
3090
|
-
return {
|
|
3091
|
-
id: `/@slidev/global-components/${layer}`,
|
|
3092
|
-
getContent({ roots }) {
|
|
3093
|
-
const components = roots.flatMap((root) => {
|
|
3094
|
-
if (layer === "top") {
|
|
3095
|
-
return [
|
|
3096
|
-
join4(root, "global.vue"),
|
|
3097
|
-
join4(root, "global-top.vue"),
|
|
3098
|
-
join4(root, "GlobalTop.vue")
|
|
3099
|
-
];
|
|
3100
|
-
} else {
|
|
3101
|
-
return [
|
|
3102
|
-
join4(root, "global-bottom.vue"),
|
|
3103
|
-
join4(root, "GlobalBottom.vue")
|
|
3104
|
-
];
|
|
3105
|
-
}
|
|
3106
|
-
}).filter((i) => existsSync2(i));
|
|
3107
|
-
const imports = components.map((i, idx) => `import __n${idx} from '${toAtFS(i)}'`).join("\n");
|
|
3108
|
-
const render = components.map((i, idx) => `h(__n${idx})`).join(",");
|
|
3109
|
-
return `
|
|
3110
|
-
${imports}
|
|
3111
|
-
import { h } from 'vue'
|
|
3112
|
-
export default {
|
|
3113
|
-
render() {
|
|
3114
|
-
return [${render}]
|
|
3115
|
-
}
|
|
3116
|
-
}
|
|
3117
|
-
`;
|
|
3118
|
-
}
|
|
3119
|
-
};
|
|
3120
|
-
}
|
|
3121
|
-
var templateNavControls = {
|
|
3122
|
-
id: "/@slidev/custom-nav-controls",
|
|
3123
|
-
getContent({ roots }) {
|
|
3124
|
-
const components = roots.flatMap((root) => {
|
|
3125
|
-
return [
|
|
3126
|
-
join4(root, "custom-nav-controls.vue"),
|
|
3127
|
-
join4(root, "CustomNavControls.vue")
|
|
3128
|
-
];
|
|
3129
|
-
}).filter((i) => existsSync2(i));
|
|
3130
|
-
const imports = components.map((i, idx) => `import __n${idx} from '${toAtFS(i)}'`).join("\n");
|
|
3131
|
-
const render = components.map((i, idx) => `h(__n${idx})`).join(",");
|
|
3132
|
-
return `
|
|
3133
|
-
${imports}
|
|
3134
|
-
import { h } from 'vue'
|
|
3135
|
-
export default {
|
|
3136
|
-
render() {
|
|
3137
|
-
return [${render}]
|
|
3138
|
-
}
|
|
3139
|
-
}
|
|
3140
|
-
`;
|
|
3141
|
-
}
|
|
3142
|
-
};
|
|
3143
|
-
var templateGlobalTop = createGlobalComponentTemplate("top");
|
|
3144
|
-
var templateGlobalBottom = createGlobalComponentTemplate("bottom");
|
|
3145
|
-
|
|
3146
|
-
// node/virtual/layouts.ts
|
|
3147
|
-
import { objectMap } from "@antfu/utils";
|
|
3148
|
-
var templateLayouts = {
|
|
3149
|
-
id: "/@slidev/layouts",
|
|
3150
|
-
async getContent(_, { getLayouts }) {
|
|
3151
|
-
const imports = [];
|
|
3152
|
-
const layouts = objectMap(
|
|
3153
|
-
await getLayouts(),
|
|
3154
|
-
(k, v) => {
|
|
3155
|
-
imports.push(`import __layout_${k} from "${toAtFS(v)}"`);
|
|
3156
|
-
return [k, `__layout_${k}`];
|
|
3157
|
-
}
|
|
3158
|
-
);
|
|
3159
|
-
return [
|
|
3160
|
-
imports.join("\n"),
|
|
3161
|
-
`export default {
|
|
3162
|
-
${Object.entries(layouts).map(([k, v]) => `"${k}": ${v}`).join(",\n")}
|
|
3163
|
-
}`
|
|
3164
|
-
].join("\n\n");
|
|
3165
|
-
}
|
|
3166
|
-
};
|
|
3167
|
-
|
|
3168
|
-
// node/virtual/monaco-types.ts
|
|
3169
|
-
import { builtinModules } from "node:module";
|
|
3170
|
-
import { join as join5, resolve as resolve2 } from "node:path";
|
|
3171
|
-
import fg2 from "fast-glob";
|
|
3172
|
-
import { uniq as uniq2 } from "@antfu/utils";
|
|
3173
|
-
|
|
3174
|
-
// node/syntax/transform/monaco.ts
|
|
3175
|
-
import { isTruthy } from "@antfu/utils";
|
|
3176
|
-
import lz from "lz-string";
|
|
3177
|
-
function transformMonaco(ctx, enabled = true) {
|
|
3178
|
-
if (!enabled) {
|
|
3179
|
-
ctx.s.replace(/{monaco([\w:,-]*)}/g, "");
|
|
3180
|
-
return;
|
|
3181
|
-
}
|
|
3182
|
-
ctx.s.replace(
|
|
3183
|
-
/^```(\w+?)\s*{monaco-diff}\s*?({.*?})?\s*?\n([\s\S]+?)^~~~\s*?\n([\s\S]+?)^```/mg,
|
|
3184
|
-
(full, lang = "ts", options = "{}", code, diff, index) => {
|
|
3185
|
-
lang = lang.trim();
|
|
3186
|
-
options = options.trim() || "{}";
|
|
3187
|
-
const encoded = lz.compressToBase64(code);
|
|
3188
|
-
const encodedDiff = lz.compressToBase64(diff);
|
|
3189
|
-
ctx.ignores.push([index, index + full.length]);
|
|
3190
|
-
return `<Monaco code-lz="${encoded}" diff-lz="${encodedDiff}" lang="${lang}" v-bind="${options}" />`;
|
|
3191
|
-
}
|
|
3192
|
-
);
|
|
3193
|
-
ctx.s.replace(
|
|
3194
|
-
/^```(\w+?)\s*{monaco}\s*?({.*?})?\s*?\n([\s\S]+?)^```/mg,
|
|
3195
|
-
(full, lang = "ts", options = "{}", code, index) => {
|
|
3196
|
-
lang = lang.trim();
|
|
3197
|
-
options = options.trim() || "{}";
|
|
3198
|
-
const encoded = lz.compressToBase64(code);
|
|
3199
|
-
ctx.ignores.push([index, index + full.length]);
|
|
3200
|
-
return `<Monaco code-lz="${encoded}" lang="${lang}" v-bind="${options}" />`;
|
|
3201
|
-
}
|
|
3202
|
-
);
|
|
3203
|
-
ctx.s.replace(
|
|
3204
|
-
/^```(\w+?)\s*{monaco-run}\s*?({.*?})?\s*?\n([\s\S]+?)^```/mg,
|
|
3205
|
-
(full, lang = "ts", options = "{}", code, index) => {
|
|
3206
|
-
lang = lang.trim();
|
|
3207
|
-
options = options.trim() || "{}";
|
|
3208
|
-
const encoded = lz.compressToBase64(code);
|
|
3209
|
-
ctx.ignores.push([index, index + full.length]);
|
|
3210
|
-
return `<Monaco runnable code-lz="${encoded}" lang="${lang}" v-bind="${options}" />`;
|
|
3211
|
-
}
|
|
3212
|
-
);
|
|
3213
|
-
}
|
|
3214
|
-
function scanMonacoModules(md2) {
|
|
3215
|
-
const typeModules = /* @__PURE__ */ new Set();
|
|
3216
|
-
md2.replace(
|
|
3217
|
-
/^```(\w+?)\s*{monaco([\w:,-]*)}[\s\n]*([\s\S]+?)^```/mg,
|
|
3218
|
-
(full, lang = "ts", options, code) => {
|
|
3219
|
-
options = options || "";
|
|
3220
|
-
lang = lang.trim();
|
|
3221
|
-
if (lang === "ts" || lang === "typescript") {
|
|
3222
|
-
Array.from(code.matchAll(/\s+from\s+(["'])([\/\w@-]+)\1/g)).map((i) => i[2]).filter(isTruthy).map((i) => typeModules.add(i));
|
|
3223
|
-
}
|
|
3224
|
-
return "";
|
|
3225
|
-
}
|
|
3226
|
-
);
|
|
3227
|
-
return Array.from(typeModules);
|
|
3228
|
-
}
|
|
3229
|
-
|
|
3230
|
-
// node/virtual/monaco-types.ts
|
|
3231
|
-
var templateMonacoTypes = {
|
|
3232
|
-
id: "/@slidev/monaco-types",
|
|
3233
|
-
getContent: async ({ userRoot, data }) => {
|
|
3234
|
-
const typesRoot = join5(userRoot, "snippets");
|
|
3235
|
-
const files = await fg2(["**/*.ts", "**/*.mts", "**/*.cts"], { cwd: typesRoot });
|
|
3236
|
-
let result = 'import { addFile } from "@slidev/client/setup/monaco.ts"\n';
|
|
3237
|
-
for (const file of files) {
|
|
3238
|
-
const url = `${toAtFS(resolve2(typesRoot, file))}?monaco-types&raw`;
|
|
3239
|
-
result += `addFile(import(${JSON.stringify(url)}), ${JSON.stringify(file)})
|
|
3240
|
-
`;
|
|
3241
|
-
}
|
|
3242
|
-
const deps = [...data.config.monacoTypesAdditionalPackages];
|
|
3243
|
-
if (data.config.monacoTypesSource === "local")
|
|
3244
|
-
deps.push(...scanMonacoModules(data.slides.map((s) => s.source.raw).join()));
|
|
3245
|
-
function mapModuleNameToModule(moduleSpecifier) {
|
|
3246
|
-
if (moduleSpecifier.startsWith("node:"))
|
|
3247
|
-
return "node";
|
|
3248
|
-
if (builtinModules.includes(moduleSpecifier))
|
|
3249
|
-
return "node";
|
|
3250
|
-
const mainPackageName = moduleSpecifier.split("/")[0];
|
|
3251
|
-
if (builtinModules.includes(mainPackageName) && !mainPackageName.startsWith("@"))
|
|
3252
|
-
return "node";
|
|
3253
|
-
const [a = "", b = ""] = moduleSpecifier.split("/");
|
|
3254
|
-
const moduleName = a.startsWith("@") ? `${a}/${b}` : a;
|
|
3255
|
-
return moduleName;
|
|
3256
|
-
}
|
|
3257
|
-
for (const specifier of uniq2(deps)) {
|
|
3258
|
-
if (specifier[0] === ".")
|
|
3259
|
-
continue;
|
|
3260
|
-
const moduleName = mapModuleNameToModule(specifier);
|
|
3261
|
-
result += `import(${JSON.stringify(`/@slidev-monaco-types/resolve?pkg=${moduleName}`)})
|
|
3262
|
-
`;
|
|
3263
|
-
}
|
|
3264
|
-
return result;
|
|
3265
|
-
}
|
|
3266
|
-
};
|
|
3267
|
-
|
|
3268
|
-
// node/virtual/setups.ts
|
|
3269
|
-
import { existsSync as existsSync3 } from "node:fs";
|
|
3270
|
-
import { join as join6 } from "node:path";
|
|
3271
|
-
function createSetupTemplate(name) {
|
|
3272
|
-
return {
|
|
3273
|
-
id: `/@slidev/setups/${name}`,
|
|
3274
|
-
getContent({ roots }) {
|
|
3275
|
-
const setups = roots.flatMap((i) => {
|
|
3276
|
-
const path2 = join6(i, "setup", name);
|
|
3277
|
-
return [".ts", ".mts", ".js", ".mjs"].map((ext) => path2 + ext);
|
|
3278
|
-
}).filter((i) => existsSync3(i));
|
|
3279
|
-
const imports = [];
|
|
3280
|
-
setups.forEach((path2, idx) => {
|
|
3281
|
-
imports.push(`import __n${idx} from '${toAtFS(path2)}'`);
|
|
3282
|
-
});
|
|
3283
|
-
imports.push(`export default [${setups.map((_, idx) => `__n${idx}`).join(",")}]`);
|
|
3284
|
-
return imports.join("\n");
|
|
3285
|
-
}
|
|
3286
|
-
};
|
|
3287
|
-
}
|
|
3288
|
-
var setupModules = ["shiki", "code-runners", "monaco", "mermaid", "main", "root", "shortcuts"];
|
|
3289
|
-
var templateSetups = setupModules.map(createSetupTemplate);
|
|
3290
|
-
|
|
3291
|
-
// node/setups/shiki.ts
|
|
3292
|
-
import fs3 from "node:fs/promises";
|
|
3293
|
-
async function loadShikiSetups(clientRoot, roots) {
|
|
3294
|
-
const result = await loadSetups(
|
|
3295
|
-
clientRoot,
|
|
3296
|
-
roots,
|
|
3297
|
-
"shiki.ts",
|
|
3298
|
-
{
|
|
3299
|
-
/** @deprecated */
|
|
3300
|
-
async loadTheme(path2) {
|
|
3301
|
-
console.warn("[slidev] `loadTheme` in `setup/shiki.ts` is deprecated. Pass directly the theme name it's supported by Shiki. For custom themes, load it manually via `JSON.parse(fs.readFileSync(path, 'utf-8'))` and pass the raw JSON object instead.");
|
|
3302
|
-
return JSON.parse(await fs3.readFile(path2, "utf-8"));
|
|
3303
|
-
}
|
|
3304
|
-
},
|
|
3305
|
-
{},
|
|
3306
|
-
false
|
|
3307
|
-
);
|
|
3308
|
-
if ("theme" in result && "themes" in result)
|
|
3309
|
-
delete result.theme;
|
|
3310
|
-
if (result.theme && typeof result.theme !== "string" && !result.theme.name && !result.theme.tokenColors) {
|
|
3311
|
-
result.themes = result.theme;
|
|
3312
|
-
delete result.theme;
|
|
3313
|
-
}
|
|
3314
|
-
if (!result.theme && !result.themes) {
|
|
3315
|
-
result.themes = {
|
|
3316
|
-
dark: "vitesse-dark",
|
|
3317
|
-
light: "vitesse-light"
|
|
3318
|
-
};
|
|
3319
|
-
}
|
|
3320
|
-
if (result.themes)
|
|
3321
|
-
result.defaultColor = false;
|
|
3322
|
-
return result;
|
|
3323
|
-
}
|
|
3324
|
-
|
|
3325
|
-
// node/virtual/shiki.ts
|
|
3326
|
-
var templateShiki = {
|
|
3327
|
-
id: "/@slidev/shiki",
|
|
3328
|
-
getContent: async ({ clientRoot, roots }) => {
|
|
3329
|
-
const options = await loadShikiSetups(clientRoot, roots);
|
|
3330
|
-
const langs = await resolveLangs(options.langs || ["javascript", "typescript", "html", "css"]);
|
|
3331
|
-
const resolvedThemeOptions = "themes" in options ? {
|
|
3332
|
-
themes: Object.fromEntries(await Promise.all(
|
|
3333
|
-
Object.entries(options.themes).map(async ([name, value]) => [name, await resolveTheme(value)])
|
|
3334
|
-
))
|
|
3335
|
-
} : {
|
|
3336
|
-
theme: await resolveTheme(options.theme || "vitesse-dark")
|
|
3337
|
-
};
|
|
3338
|
-
const themes = resolvedThemeOptions.themes ? Object.values(resolvedThemeOptions.themes) : [resolvedThemeOptions.theme];
|
|
3339
|
-
const themeOptionsNames = resolvedThemeOptions.themes ? { themes: Object.fromEntries(Object.entries(resolvedThemeOptions.themes).map(([name, value]) => [name, typeof value === "string" ? value : value.name])) } : { theme: typeof resolvedThemeOptions.theme === "string" ? resolvedThemeOptions.theme : resolvedThemeOptions.theme.name };
|
|
3340
|
-
async function normalizeGetter(p) {
|
|
3341
|
-
return Promise.resolve(typeof p === "function" ? p() : p).then((r) => r.default || r);
|
|
3342
|
-
}
|
|
3343
|
-
async function resolveLangs(langs2) {
|
|
3344
|
-
return Array.from(new Set((await Promise.all(
|
|
3345
|
-
langs2.map(async (lang) => await normalizeGetter(lang).then((r) => Array.isArray(r) ? r : [r]))
|
|
3346
|
-
)).flat()));
|
|
3347
|
-
}
|
|
3348
|
-
async function resolveTheme(theme) {
|
|
3349
|
-
return typeof theme === "string" ? theme : await normalizeGetter(theme);
|
|
3350
|
-
}
|
|
3351
|
-
const langsInit = await Promise.all(
|
|
3352
|
-
langs.map(async (lang) => typeof lang === "string" ? `import('${await resolveImportUrl(`shiki/langs/${lang}.mjs`)}')` : JSON.stringify(lang))
|
|
3353
|
-
);
|
|
3354
|
-
const themesInit = await Promise.all(themes.map(async (theme) => typeof theme === "string" ? `import('${await resolveImportUrl(`shiki/themes/${theme}.mjs`)}')` : JSON.stringify(theme)));
|
|
3355
|
-
const langNames = langs.flatMap((lang) => typeof lang === "string" ? lang : lang.name);
|
|
3356
|
-
const lines = [];
|
|
3357
|
-
lines.push(
|
|
3358
|
-
`import { getHighlighterCore } from "${await resolveImportUrl("shiki/core")}"`,
|
|
3359
|
-
`export { shikiToMonaco } from "${await resolveImportUrl("@shikijs/monaco")}"`,
|
|
3360
|
-
`export const languages = ${JSON.stringify(langNames)}`,
|
|
3361
|
-
`export const themes = ${JSON.stringify(themeOptionsNames.themes || themeOptionsNames.theme)}`,
|
|
3362
|
-
"export const shiki = getHighlighterCore({",
|
|
3363
|
-
` themes: [${themesInit.join(",")}],`,
|
|
3364
|
-
` langs: [${langsInit.join(",")}],`,
|
|
3365
|
-
` loadWasm: import('${await resolveImportUrl("shiki/wasm")}'),`,
|
|
3366
|
-
"})"
|
|
3367
|
-
);
|
|
3368
|
-
return lines.join("\n");
|
|
3369
|
-
}
|
|
3370
|
-
};
|
|
3371
|
-
|
|
3372
|
-
// node/virtual/slides.ts
|
|
3373
|
-
var VIRTUAL_SLIDE_PREFIX = "/@slidev/slides/";
|
|
3374
|
-
var templateSlides = {
|
|
3375
|
-
id: "/@slidev/slides",
|
|
3376
|
-
async getContent({ data }, { getLayouts }) {
|
|
3377
|
-
const layouts = await getLayouts();
|
|
3378
|
-
const imports = [
|
|
3379
|
-
`import { shallowRef } from 'vue'`,
|
|
3380
|
-
`import * as __layout__error from '${layouts.error}'`
|
|
3381
|
-
];
|
|
3382
|
-
const slides = data.slides.map((_, idx) => {
|
|
3383
|
-
const no = idx + 1;
|
|
3384
|
-
imports.push(`import { meta as f${no} } from '${VIRTUAL_SLIDE_PREFIX}${no}.frontmatter'`);
|
|
3385
|
-
return `{
|
|
3386
|
-
no: ${no},
|
|
3387
|
-
meta: f${no},
|
|
3388
|
-
component: async () => {
|
|
3389
|
-
try {
|
|
3390
|
-
return await import('${VIRTUAL_SLIDE_PREFIX}${no}.md')
|
|
3391
|
-
}
|
|
3392
|
-
catch(e) {
|
|
3393
|
-
console.error('Failed to load slide ${no}:', e)
|
|
3394
|
-
return __layout__error
|
|
3395
|
-
}
|
|
3396
|
-
},
|
|
3397
|
-
}`;
|
|
3398
|
-
});
|
|
3399
|
-
return [
|
|
3400
|
-
...imports,
|
|
3401
|
-
`const data = [
|
|
3402
|
-
${slides.join(",\n")}
|
|
3403
|
-
]`,
|
|
3404
|
-
`if (import.meta.hot) {`,
|
|
3405
|
-
` import.meta.hot.data.slides ??= shallowRef()`,
|
|
3406
|
-
` import.meta.hot.data.slides.value = data`,
|
|
3407
|
-
` import.meta.hot.accept()`,
|
|
3408
|
-
`}`,
|
|
3409
|
-
`export const slides = import.meta.hot ? import.meta.hot.data.slides : shallowRef(data)`
|
|
3410
|
-
].join("\n");
|
|
3411
|
-
}
|
|
3412
|
-
};
|
|
3413
|
-
|
|
3414
|
-
// node/virtual/styles.ts
|
|
3415
|
-
import { join as join7 } from "node:path";
|
|
3416
|
-
import { existsSync as existsSync4 } from "node:fs";
|
|
3417
|
-
var templateStyle = {
|
|
3418
|
-
id: "/@slidev/styles",
|
|
3419
|
-
getContent: async ({ data, clientRoot, roots }) => {
|
|
3420
|
-
function resolveUrlOfClient(name) {
|
|
3421
|
-
return toAtFS(join7(clientRoot, name));
|
|
3422
|
-
}
|
|
3423
|
-
const imports = [
|
|
3424
|
-
`import "${resolveUrlOfClient("styles/vars.css")}"`,
|
|
3425
|
-
`import "${resolveUrlOfClient("styles/index.css")}"`,
|
|
3426
|
-
`import "${resolveUrlOfClient("styles/code.css")}"`,
|
|
3427
|
-
`import "${resolveUrlOfClient("styles/katex.css")}"`,
|
|
3428
|
-
`import "${resolveUrlOfClient("styles/transitions.css")}"`
|
|
3429
|
-
];
|
|
3430
|
-
for (const root of roots) {
|
|
3431
|
-
const styles = [
|
|
3432
|
-
join7(root, "styles", "index.ts"),
|
|
3433
|
-
join7(root, "styles", "index.js"),
|
|
3434
|
-
join7(root, "styles", "index.css"),
|
|
3435
|
-
join7(root, "styles.css"),
|
|
3436
|
-
join7(root, "style.css")
|
|
3437
|
-
];
|
|
3438
|
-
for (const style of styles) {
|
|
3439
|
-
if (existsSync4(style)) {
|
|
3440
|
-
imports.push(`import "${toAtFS(style)}"`);
|
|
3441
|
-
continue;
|
|
3442
|
-
}
|
|
3443
|
-
}
|
|
3444
|
-
}
|
|
3445
|
-
if (data.features.katex)
|
|
3446
|
-
imports.push(`import "${await resolveImportUrl("katex/dist/katex.min.css")}"`);
|
|
3447
|
-
if (data.config.highlighter === "shiki") {
|
|
3448
|
-
imports.push(
|
|
3449
|
-
`import "${await resolveImportUrl("@shikijs/vitepress-twoslash/style.css")}"`,
|
|
3450
|
-
`import "${resolveUrlOfClient("styles/shiki-twoslash.css")}"`
|
|
3451
|
-
);
|
|
3452
|
-
}
|
|
3453
|
-
if (data.config.css === "unocss") {
|
|
3454
|
-
imports.unshift(
|
|
3455
|
-
`import "${await resolveImportUrl("@unocss/reset/tailwind.css")}"`,
|
|
3456
|
-
'import "uno:preflights.css"',
|
|
3457
|
-
'import "uno:typography.css"',
|
|
3458
|
-
'import "uno:shortcuts.css"'
|
|
3459
|
-
);
|
|
3460
|
-
imports.push('import "uno.css"');
|
|
3461
|
-
}
|
|
3462
|
-
return imports.join("\n");
|
|
3463
|
-
}
|
|
3464
|
-
};
|
|
3465
|
-
|
|
3466
|
-
// node/virtual/titles.ts
|
|
3467
|
-
var templateTitleRendererMd = {
|
|
3468
|
-
id: "/@slidev/title-renderer.md",
|
|
3469
|
-
async getContent({ data }) {
|
|
3470
|
-
const lines = data.slides.map(({ title }, i) => `<template ${i === 0 ? "v-if" : "v-else-if"}="no === ${i + 1}">
|
|
3471
|
-
|
|
3472
|
-
${title}
|
|
3473
|
-
|
|
3474
|
-
</template>`);
|
|
3475
|
-
lines.push(
|
|
3476
|
-
`<script setup lang="ts">`,
|
|
3477
|
-
`import { useSlideContext } from '@slidev/client'`,
|
|
3478
|
-
`import { computed } from 'vue'`,
|
|
3479
|
-
`const props = defineProps<{ no?: number | string }>()`,
|
|
3480
|
-
`const { $page } = useSlideContext()`,
|
|
3481
|
-
`const no = computed(() => +(props.no ?? $page.value))`,
|
|
3482
|
-
`</script>`
|
|
3483
|
-
);
|
|
3484
|
-
return lines.join("\n");
|
|
3485
|
-
}
|
|
3486
|
-
};
|
|
3487
|
-
var templateTitleRenderer = {
|
|
3488
|
-
id: "/@slidev/title-renderer",
|
|
3489
|
-
async getContent() {
|
|
3490
|
-
return 'export { default } from "/@slidev/title-renderer.md"';
|
|
3491
|
-
}
|
|
3492
|
-
};
|
|
3493
|
-
|
|
3494
|
-
// node/virtual/index.ts
|
|
3495
|
-
var templates = [
|
|
3496
|
-
templateShiki,
|
|
3497
|
-
templateMonacoTypes,
|
|
3498
|
-
templateConfigs,
|
|
3499
|
-
templateStyle,
|
|
3500
|
-
templateGlobalBottom,
|
|
3501
|
-
templateGlobalTop,
|
|
3502
|
-
templateNavControls,
|
|
3503
|
-
templateSlides,
|
|
3504
|
-
templateLayouts,
|
|
3505
|
-
templateTitleRenderer,
|
|
3506
|
-
templateTitleRendererMd,
|
|
3507
|
-
...templateSetups,
|
|
3508
|
-
// Deprecated
|
|
3509
|
-
templateLegacyRoutes,
|
|
3510
|
-
templateLegacyTitles
|
|
3511
|
-
];
|
|
3512
|
-
|
|
3513
|
-
// node/vite/loaders.ts
|
|
3514
|
-
var regexId = /^\/\@slidev\/slide\/(\d+)\.(md|json)(?:\?import)?$/;
|
|
3515
|
-
var regexIdQuery = /(\d+?)\.(md|json|frontmatter)$/;
|
|
3516
|
-
var templateInjectionMarker = "/* @slidev-injection */";
|
|
3517
|
-
var templateImportContextUtils = `import {
|
|
3518
|
-
useSlideContext,
|
|
3519
|
-
provideFrontmatter as _provideFrontmatter,
|
|
3520
|
-
frontmatterToProps as _frontmatterToProps,
|
|
3521
|
-
} from "@slidev/client/context.ts"`.replace(/\n\s*/g, " ");
|
|
3522
|
-
var templateInitContext = `const { $slidev, $nav, $clicksContext, $clicks, $page, $renderContext, $frontmatter } = useSlideContext()`;
|
|
3523
|
-
function getBodyJson(req) {
|
|
3524
|
-
return new Promise((resolve4, reject) => {
|
|
3525
|
-
let body = "";
|
|
3526
|
-
req.on("data", (chunk) => body += chunk);
|
|
3527
|
-
req.on("error", reject);
|
|
3528
|
-
req.on("end", () => {
|
|
3529
|
-
try {
|
|
3530
|
-
resolve4(JSON.parse(body) || {});
|
|
3531
|
-
} catch (e) {
|
|
3532
|
-
reject(e);
|
|
3533
|
-
}
|
|
3534
|
-
});
|
|
3535
|
-
});
|
|
3536
|
-
}
|
|
3537
|
-
var md = Markdown({ html: true });
|
|
3538
|
-
md.use(mila, {
|
|
3539
|
-
attrs: {
|
|
3540
|
-
target: "_blank",
|
|
3541
|
-
rel: "noopener"
|
|
3542
|
-
}
|
|
3543
|
-
});
|
|
3544
|
-
function renderNote(text = "") {
|
|
3545
|
-
let clickCount = 0;
|
|
3546
|
-
const html = md.render(
|
|
3547
|
-
text.replace(/\[click(?::(\d+))?\]/gi, (_, count = 1) => {
|
|
3548
|
-
clickCount += Number(count);
|
|
3549
|
-
return `<span class="slidev-note-click-mark" data-clicks="${clickCount}"></span>`;
|
|
3550
|
-
})
|
|
3551
|
-
);
|
|
3552
|
-
return html;
|
|
3553
|
-
}
|
|
3554
|
-
function withRenderedNote(data) {
|
|
3555
|
-
return {
|
|
3556
|
-
...data,
|
|
3557
|
-
noteHTML: renderNote(data?.note)
|
|
3558
|
-
};
|
|
3559
|
-
}
|
|
3560
|
-
function createSlidesLoader(options, pluginOptions, serverOptions) {
|
|
3561
|
-
const hmrPages = /* @__PURE__ */ new Set();
|
|
3562
|
-
let server;
|
|
3563
|
-
let _layouts_cache_time = 0;
|
|
3564
|
-
let _layouts_cache = {};
|
|
3565
|
-
let skipHmr = null;
|
|
3566
|
-
const { data, clientRoot, roots, mode } = options;
|
|
3567
|
-
const templateCtx = {
|
|
3568
|
-
md,
|
|
3569
|
-
async getLayouts() {
|
|
3570
|
-
const now = Date.now();
|
|
3571
|
-
if (now - _layouts_cache_time < 2e3)
|
|
3572
|
-
return _layouts_cache;
|
|
3573
|
-
const layouts = {};
|
|
3574
|
-
for (const root of [...roots, clientRoot]) {
|
|
3575
|
-
const layoutPaths = await fg3("layouts/**/*.{vue,ts}", {
|
|
3576
|
-
cwd: root,
|
|
3577
|
-
absolute: true,
|
|
3578
|
-
suppressErrors: true
|
|
3579
|
-
});
|
|
3580
|
-
for (const layoutPath of layoutPaths) {
|
|
3581
|
-
const layout = basename2(layoutPath).replace(/\.\w+$/, "");
|
|
3582
|
-
if (layouts[layout])
|
|
3583
|
-
continue;
|
|
3584
|
-
layouts[layout] = layoutPath;
|
|
3585
|
-
}
|
|
3586
|
-
}
|
|
3587
|
-
_layouts_cache_time = now;
|
|
3588
|
-
_layouts_cache = layouts;
|
|
3589
|
-
return layouts;
|
|
3590
|
-
}
|
|
3591
|
-
};
|
|
3592
|
-
return [
|
|
3593
|
-
{
|
|
3594
|
-
name: "slidev:loader",
|
|
3595
|
-
configureServer(_server) {
|
|
3596
|
-
server = _server;
|
|
3597
|
-
updateServerWatcher();
|
|
3598
|
-
server.middlewares.use(async (req, res, next) => {
|
|
3599
|
-
const match = req.url?.match(regexId);
|
|
3600
|
-
if (!match)
|
|
3601
|
-
return next();
|
|
3602
|
-
const [, no, type2] = match;
|
|
3603
|
-
const idx = Number.parseInt(no) - 1;
|
|
3604
|
-
if (type2 === "json" && req.method === "GET") {
|
|
3605
|
-
res.write(JSON.stringify(withRenderedNote(data.slides[idx])));
|
|
3606
|
-
return res.end();
|
|
3607
|
-
}
|
|
3608
|
-
if (type2 === "json" && req.method === "POST") {
|
|
3609
|
-
const body = await getBodyJson(req);
|
|
3610
|
-
const slide = data.slides[idx];
|
|
3611
|
-
if (body.content && body.content !== slide.source.content)
|
|
3612
|
-
hmrPages.add(idx);
|
|
3613
|
-
if (body.content)
|
|
3614
|
-
slide.content = slide.source.content = body.content;
|
|
3615
|
-
if (body.note)
|
|
3616
|
-
slide.note = slide.source.note = body.note;
|
|
3617
|
-
if (body.frontmatter) {
|
|
3618
|
-
Object.assign(slide.frontmatter, body.frontmatter);
|
|
3619
|
-
slide.source.frontmatterRaw = js_yaml_default.dump(slide.frontmatter);
|
|
3620
|
-
}
|
|
3621
|
-
parser.prettifySlide(slide.source);
|
|
3622
|
-
const fileContent = await parser.save(data.markdownFiles[slide.source.filepath]);
|
|
3623
|
-
if (body.skipHmr) {
|
|
3624
|
-
skipHmr = {
|
|
3625
|
-
filePath: slide.source.filepath,
|
|
3626
|
-
fileContent
|
|
3627
|
-
};
|
|
3628
|
-
server?.moduleGraph.invalidateModule(
|
|
3629
|
-
server.moduleGraph.getModuleById(`${VIRTUAL_SLIDE_PREFIX}${no}.md`)
|
|
3630
|
-
);
|
|
3631
|
-
if (body.frontmatter) {
|
|
3632
|
-
server?.moduleGraph.invalidateModule(
|
|
3633
|
-
server.moduleGraph.getModuleById(`${VIRTUAL_SLIDE_PREFIX}${no}.frontmatter`)
|
|
3634
|
-
);
|
|
3635
|
-
}
|
|
3636
|
-
}
|
|
3637
|
-
res.statusCode = 200;
|
|
3638
|
-
res.write(JSON.stringify(withRenderedNote(slide)));
|
|
3639
|
-
return res.end();
|
|
3640
|
-
}
|
|
3641
|
-
next();
|
|
3642
|
-
});
|
|
3643
|
-
server.middlewares.use(async (req, res, next) => {
|
|
3644
|
-
const match = req.url?.match(/^\/\@slidev\/resolve-id\/(.*)$/);
|
|
3645
|
-
if (!match)
|
|
3646
|
-
return next();
|
|
3647
|
-
const [, specifier] = match;
|
|
3648
|
-
const resolved = await server.pluginContainer.resolveId(specifier);
|
|
3649
|
-
res.statusCode = 200;
|
|
3650
|
-
res.write(resolved?.id ?? "");
|
|
3651
|
-
return res.end();
|
|
3652
|
-
});
|
|
3653
|
-
},
|
|
3654
|
-
async handleHotUpdate(ctx) {
|
|
3655
|
-
if (!data.watchFiles.includes(ctx.file))
|
|
3656
|
-
return;
|
|
3657
|
-
await ctx.read();
|
|
3658
|
-
const newData = await serverOptions.loadData?.();
|
|
3659
|
-
if (!newData)
|
|
3660
|
-
return [];
|
|
3661
|
-
if (skipHmr && newData.markdownFiles[skipHmr.filePath]?.raw === skipHmr.fileContent) {
|
|
3662
|
-
skipHmr = null;
|
|
3663
|
-
return [];
|
|
3664
|
-
}
|
|
3665
|
-
const moduleIds = /* @__PURE__ */ new Set();
|
|
3666
|
-
if (data.slides.length !== newData.slides.length) {
|
|
3667
|
-
moduleIds.add(templateSlides.id);
|
|
3668
|
-
range(newData.slides.length).map((i) => hmrPages.add(i));
|
|
3669
|
-
}
|
|
3670
|
-
if (!equal(data.headmatter.defaults, newData.headmatter.defaults)) {
|
|
3671
|
-
moduleIds.add(templateSlides.id);
|
|
3672
|
-
range(data.slides.length).map((i) => hmrPages.add(i));
|
|
3673
|
-
}
|
|
3674
|
-
if (!equal(data.config, newData.config))
|
|
3675
|
-
moduleIds.add(templateConfigs.id);
|
|
3676
|
-
if (!equal(data.features, newData.features)) {
|
|
3677
|
-
setTimeout(() => {
|
|
3678
|
-
ctx.server.hot.send({ type: "full-reload" });
|
|
3679
|
-
}, 1);
|
|
3680
|
-
}
|
|
3681
|
-
const length = Math.min(data.slides.length, newData.slides.length);
|
|
3682
|
-
for (let i = 0; i < length; i++) {
|
|
3683
|
-
const a = data.slides[i];
|
|
3684
|
-
const b = newData.slides[i];
|
|
3685
|
-
if (!hmrPages.has(i) && a.content.trim() === b.content.trim() && a.title?.trim() === b.title?.trim() && equal(a.frontmatter, b.frontmatter) && Object.entries(a.snippetsUsed ?? {}).every(([file, oldContent]) => {
|
|
3686
|
-
try {
|
|
3687
|
-
const newContent = fs4.readFileSync(file, "utf-8");
|
|
3688
|
-
return oldContent === newContent;
|
|
3689
|
-
} catch {
|
|
3690
|
-
return false;
|
|
3691
|
-
}
|
|
3692
|
-
})) {
|
|
3693
|
-
if (a.note !== b.note) {
|
|
3694
|
-
ctx.server.hot.send(
|
|
3695
|
-
"slidev:update-note",
|
|
3696
|
-
{
|
|
3697
|
-
no: i + 1,
|
|
3698
|
-
note: b.note || "",
|
|
3699
|
-
noteHTML: renderNote(b.note || "")
|
|
3700
|
-
}
|
|
3701
|
-
);
|
|
3702
|
-
}
|
|
3703
|
-
continue;
|
|
3704
|
-
}
|
|
3705
|
-
ctx.server.hot.send(
|
|
3706
|
-
"slidev:update-slide",
|
|
3707
|
-
{
|
|
3708
|
-
no: i + 1,
|
|
3709
|
-
data: withRenderedNote(newData.slides[i])
|
|
3710
|
-
}
|
|
3711
|
-
);
|
|
3712
|
-
hmrPages.add(i);
|
|
3713
|
-
}
|
|
3714
|
-
Object.assign(data, newData);
|
|
3715
|
-
if (hmrPages.size > 0)
|
|
3716
|
-
moduleIds.add(templateTitleRendererMd.id);
|
|
3717
|
-
const vueModules = Array.from(hmrPages).flatMap((i) => [
|
|
3718
|
-
ctx.server.moduleGraph.getModuleById(`${VIRTUAL_SLIDE_PREFIX}${i + 1}.frontmatter`),
|
|
3719
|
-
ctx.server.moduleGraph.getModuleById(`${VIRTUAL_SLIDE_PREFIX}${i + 1}.md`)
|
|
3720
|
-
]);
|
|
3721
|
-
hmrPages.clear();
|
|
3722
|
-
const moduleEntries = [
|
|
3723
|
-
...vueModules,
|
|
3724
|
-
...Array.from(moduleIds).map((id) => ctx.server.moduleGraph.getModuleById(id))
|
|
3725
|
-
].filter(notNullish).filter((i) => !i.id?.startsWith("/@id/@vite-icons"));
|
|
3726
|
-
updateServerWatcher();
|
|
3727
|
-
return moduleEntries;
|
|
3728
|
-
},
|
|
3729
|
-
resolveId(id) {
|
|
3730
|
-
if (id.startsWith(VIRTUAL_SLIDE_PREFIX) || id.startsWith("/@slidev/"))
|
|
3731
|
-
return id;
|
|
3732
|
-
return null;
|
|
3733
|
-
},
|
|
3734
|
-
async load(id) {
|
|
3735
|
-
const template = templates.find((i) => i.id === id);
|
|
3736
|
-
if (template) {
|
|
3737
|
-
return {
|
|
3738
|
-
code: await template.getContent(options, templateCtx),
|
|
3739
|
-
map: { mappings: "" }
|
|
3740
|
-
};
|
|
3741
|
-
}
|
|
3742
|
-
if (id.startsWith(VIRTUAL_SLIDE_PREFIX)) {
|
|
3743
|
-
const remaning = id.slice(VIRTUAL_SLIDE_PREFIX.length);
|
|
3744
|
-
const match = remaning.match(regexIdQuery);
|
|
3745
|
-
if (match) {
|
|
3746
|
-
const [, no, type2] = match;
|
|
3747
|
-
const pageNo = Number.parseInt(no) - 1;
|
|
3748
|
-
const slide = data.slides[pageNo];
|
|
3749
|
-
if (!slide)
|
|
3750
|
-
return;
|
|
3751
|
-
if (type2 === "md") {
|
|
3752
|
-
return {
|
|
3753
|
-
code: slide?.content,
|
|
3754
|
-
map: { mappings: "" }
|
|
3755
|
-
};
|
|
3756
|
-
} else if (type2 === "frontmatter") {
|
|
3757
|
-
const slideBase = {
|
|
3758
|
-
...withRenderedNote(slide),
|
|
3759
|
-
frontmatter: void 0,
|
|
3760
|
-
source: void 0,
|
|
3761
|
-
// remove raw content in build, optimize the bundle size
|
|
3762
|
-
...mode === "build" ? { raw: "", content: "", note: "" } : {}
|
|
3763
|
-
};
|
|
3764
|
-
const fontmatter = getFrontmatter(pageNo);
|
|
3765
|
-
return {
|
|
3766
|
-
code: [
|
|
3767
|
-
"// @unocss-include",
|
|
3768
|
-
'import { reactive, computed } from "vue"',
|
|
3769
|
-
`export const frontmatter = reactive(${JSON.stringify(fontmatter)})`,
|
|
3770
|
-
`export const meta = reactive({
|
|
3771
|
-
layout: computed(() => frontmatter.layout),
|
|
3772
|
-
transition: computed(() => frontmatter.transition),
|
|
3773
|
-
class: computed(() => frontmatter.class),
|
|
3774
|
-
clicks: computed(() => frontmatter.clicks),
|
|
3775
|
-
name: computed(() => frontmatter.name),
|
|
3776
|
-
preload: computed(() => frontmatter.preload),
|
|
3777
|
-
slide: {
|
|
3778
|
-
...(${JSON.stringify(slideBase)}),
|
|
3779
|
-
frontmatter,
|
|
3780
|
-
filepath: ${JSON.stringify(slide.source.filepath)},
|
|
3781
|
-
start: ${JSON.stringify(slide.source.start)},
|
|
3782
|
-
id: ${pageNo},
|
|
3783
|
-
no: ${no},
|
|
3784
|
-
},
|
|
3785
|
-
__clicksContext: null,
|
|
3786
|
-
__preloaded: false,
|
|
3787
|
-
})`,
|
|
3788
|
-
"export default frontmatter",
|
|
3789
|
-
// handle HMR, update frontmatter with update
|
|
3790
|
-
"if (import.meta.hot) {",
|
|
3791
|
-
" import.meta.hot.accept(({ frontmatter: update }) => {",
|
|
3792
|
-
" if(!update) return",
|
|
3793
|
-
" Object.keys(frontmatter).forEach(key => {",
|
|
3794
|
-
" if (!(key in update)) delete frontmatter[key]",
|
|
3795
|
-
" })",
|
|
3796
|
-
" Object.assign(frontmatter, update)",
|
|
3797
|
-
" })",
|
|
3798
|
-
"}"
|
|
3799
|
-
].join("\n"),
|
|
3800
|
-
map: { mappings: "" }
|
|
3801
|
-
};
|
|
3802
|
-
}
|
|
3803
|
-
}
|
|
3804
|
-
return {
|
|
3805
|
-
code: "",
|
|
3806
|
-
map: { mappings: "" }
|
|
3807
|
-
};
|
|
3808
|
-
}
|
|
3809
|
-
}
|
|
3810
|
-
},
|
|
3811
|
-
{
|
|
3812
|
-
name: "slidev:layout-transform:pre",
|
|
3813
|
-
enforce: "pre",
|
|
3814
|
-
async transform(code, id) {
|
|
3815
|
-
if (!id.startsWith(VIRTUAL_SLIDE_PREFIX))
|
|
3816
|
-
return;
|
|
3817
|
-
const remaning = id.slice(VIRTUAL_SLIDE_PREFIX.length);
|
|
3818
|
-
const match = remaning.match(regexIdQuery);
|
|
3819
|
-
if (!match)
|
|
3820
|
-
return;
|
|
3821
|
-
const [, no, type2] = match;
|
|
3822
|
-
if (type2 !== "md")
|
|
3823
|
-
return;
|
|
3824
|
-
const pageNo = Number.parseInt(no) - 1;
|
|
3825
|
-
return transformMarkdown(code, pageNo);
|
|
3826
|
-
}
|
|
3827
|
-
},
|
|
3828
|
-
{
|
|
3829
|
-
name: "slidev:context-transform:pre",
|
|
3830
|
-
enforce: "pre",
|
|
3831
|
-
async transform(code, id) {
|
|
3832
|
-
if (!id.endsWith(".vue") || id.includes("/@slidev/client/") || id.includes("/packages/client/"))
|
|
3833
|
-
return;
|
|
3834
|
-
return transformVue(code);
|
|
3835
|
-
}
|
|
3836
|
-
},
|
|
3837
|
-
{
|
|
3838
|
-
name: "slidev:slide-transform:post",
|
|
3839
|
-
enforce: "post",
|
|
3840
|
-
transform(code, id) {
|
|
3841
|
-
if (!id.match(/\/@slidev\/slides\/\d+\.md($|\?)/))
|
|
3842
|
-
return;
|
|
3843
|
-
const replaced = code.replace("if (_rerender_only)", "if (false)");
|
|
3844
|
-
if (replaced !== code)
|
|
3845
|
-
return replaced;
|
|
3846
|
-
}
|
|
3847
|
-
},
|
|
3848
|
-
{
|
|
3849
|
-
name: "slidev:index-html-transform",
|
|
3850
|
-
transformIndexHtml() {
|
|
3851
|
-
const { info, author, keywords } = data.headmatter;
|
|
3852
|
-
return [
|
|
3853
|
-
{
|
|
3854
|
-
tag: "title",
|
|
3855
|
-
children: getTitle()
|
|
3856
|
-
},
|
|
3857
|
-
info && {
|
|
3858
|
-
tag: "meta",
|
|
3859
|
-
attrs: {
|
|
3860
|
-
name: "description",
|
|
3861
|
-
content: info
|
|
3862
|
-
}
|
|
3863
|
-
},
|
|
3864
|
-
author && {
|
|
3865
|
-
tag: "meta",
|
|
3866
|
-
attrs: {
|
|
3867
|
-
name: "author",
|
|
3868
|
-
content: author
|
|
3869
|
-
}
|
|
3870
|
-
},
|
|
3871
|
-
keywords && {
|
|
3872
|
-
tag: "meta",
|
|
3873
|
-
attrs: {
|
|
3874
|
-
name: "keywords",
|
|
3875
|
-
content: Array.isArray(keywords) ? keywords.join(", ") : keywords
|
|
3876
|
-
}
|
|
3877
|
-
}
|
|
3878
|
-
].filter(isTruthy2);
|
|
3879
|
-
}
|
|
3880
|
-
}
|
|
3881
|
-
];
|
|
3882
|
-
function updateServerWatcher() {
|
|
3883
|
-
if (!server)
|
|
3884
|
-
return;
|
|
3885
|
-
server.watcher.add(data.watchFiles);
|
|
3886
|
-
}
|
|
3887
|
-
function getFrontmatter(pageNo) {
|
|
3888
|
-
return {
|
|
3889
|
-
...data.headmatter?.defaults || {},
|
|
3890
|
-
...data.slides[pageNo]?.frontmatter || {}
|
|
3891
|
-
};
|
|
3892
|
-
}
|
|
3893
|
-
async function transformMarkdown(code, pageNo) {
|
|
3894
|
-
const layouts = await templateCtx.getLayouts();
|
|
3895
|
-
const frontmatter = getFrontmatter(pageNo);
|
|
3896
|
-
let layoutName = frontmatter?.layout || (pageNo === 0 ? "cover" : "default");
|
|
3897
|
-
if (!layouts[layoutName]) {
|
|
3898
|
-
console.error(red(`
|
|
3899
|
-
Unknown layout "${bold(layoutName)}".${yellow(" Available layouts are:")}`) + Object.keys(layouts).map((i, idx) => (idx % 3 === 0 ? "\n " : "") + gray(i.padEnd(15, " "))).join(" "));
|
|
3900
|
-
console.error();
|
|
3901
|
-
layoutName = "default";
|
|
3902
|
-
}
|
|
3903
|
-
delete frontmatter.title;
|
|
3904
|
-
const imports = [
|
|
3905
|
-
`import InjectedLayout from "${toAtFS(layouts[layoutName])}"`,
|
|
3906
|
-
`import frontmatter from "${toAtFS(`${VIRTUAL_SLIDE_PREFIX + (pageNo + 1)}.frontmatter`)}"`,
|
|
3907
|
-
templateImportContextUtils,
|
|
3908
|
-
"_provideFrontmatter(frontmatter)",
|
|
3909
|
-
templateInitContext,
|
|
3910
|
-
templateInjectionMarker
|
|
3911
|
-
];
|
|
3912
|
-
code = code.replace(/(<script setup.*>)/g, `$1
|
|
3913
|
-
${imports.join("\n")}
|
|
3914
|
-
`);
|
|
3915
|
-
const injectA = code.indexOf("<template>") + "<template>".length;
|
|
3916
|
-
const injectB = code.lastIndexOf("</template>");
|
|
3917
|
-
let body = code.slice(injectA, injectB).trim();
|
|
3918
|
-
if (body.startsWith("<div>") && body.endsWith("</div>"))
|
|
3919
|
-
body = body.slice(5, -6);
|
|
3920
|
-
code = `${code.slice(0, injectA)}
|
|
3921
|
-
<InjectedLayout v-bind="_frontmatterToProps(frontmatter,${pageNo})">
|
|
3922
|
-
${body}
|
|
3923
|
-
</InjectedLayout>
|
|
3924
|
-
${code.slice(injectB)}`;
|
|
3925
|
-
return code;
|
|
3926
|
-
}
|
|
3927
|
-
function transformVue(code) {
|
|
3928
|
-
if (code.includes(templateInjectionMarker) || code.includes("useSlideContext()"))
|
|
3929
|
-
return code;
|
|
3930
|
-
const imports = [
|
|
3931
|
-
templateImportContextUtils,
|
|
3932
|
-
templateInitContext,
|
|
3933
|
-
templateInjectionMarker
|
|
3934
|
-
];
|
|
3935
|
-
const matchScript = code.match(/<script((?!setup).)*(setup)?.*>/);
|
|
3936
|
-
if (matchScript && matchScript[2]) {
|
|
3937
|
-
return code.replace(/(<script.*>)/g, `$1
|
|
3938
|
-
${imports.join("\n")}
|
|
3939
|
-
`);
|
|
3940
|
-
} else if (matchScript && !matchScript[2]) {
|
|
3941
|
-
const matchExport = code.match(/export\s+default\s+{/);
|
|
3942
|
-
if (matchExport) {
|
|
3943
|
-
const exportIndex = (matchExport.index || 0) + matchExport[0].length;
|
|
3944
|
-
let component = code.slice(exportIndex);
|
|
3945
|
-
component = component.slice(0, component.indexOf("</script>"));
|
|
3946
|
-
const scriptIndex = (matchScript.index || 0) + matchScript[0].length;
|
|
3947
|
-
const provideImport = '\nimport { injectionSlidevContext } from "@slidev/client/constants.ts"\n';
|
|
3948
|
-
code = `${code.slice(0, scriptIndex)}${provideImport}${code.slice(scriptIndex)}`;
|
|
3949
|
-
let injectIndex = exportIndex + provideImport.length;
|
|
3950
|
-
let injectObject = "$slidev: { from: injectionSlidevContext },";
|
|
3951
|
-
const matchInject = component.match(/.*inject\s*:\s*([\[{])/);
|
|
3952
|
-
if (matchInject) {
|
|
3953
|
-
injectIndex += (matchInject.index || 0) + matchInject[0].length;
|
|
3954
|
-
if (matchInject[1] === "[") {
|
|
3955
|
-
let injects = component.slice((matchInject.index || 0) + matchInject[0].length);
|
|
3956
|
-
const injectEndIndex = injects.indexOf("]");
|
|
3957
|
-
injects = injects.slice(0, injectEndIndex);
|
|
3958
|
-
injectObject += injects.split(",").map((inject) => `${inject}: {from: ${inject}}`).join(",");
|
|
3959
|
-
return `${code.slice(0, injectIndex - 1)}{
|
|
3960
|
-
${injectObject}
|
|
3961
|
-
}${code.slice(injectIndex + injectEndIndex + 1)}`;
|
|
3962
|
-
} else {
|
|
3963
|
-
return `${code.slice(0, injectIndex)}
|
|
3964
|
-
${injectObject}
|
|
3965
|
-
${code.slice(injectIndex)}`;
|
|
3966
|
-
}
|
|
3967
|
-
}
|
|
3968
|
-
return `${code.slice(0, injectIndex)}
|
|
3969
|
-
inject: { ${injectObject} },
|
|
3970
|
-
${code.slice(injectIndex)}`;
|
|
3971
|
-
}
|
|
3972
|
-
}
|
|
3973
|
-
return `<script setup>
|
|
3974
|
-
${imports.join("\n")}
|
|
3975
|
-
</script>
|
|
3976
|
-
${code}`;
|
|
3977
|
-
}
|
|
3978
|
-
function getTitle() {
|
|
3979
|
-
if (isString2(data.config.title)) {
|
|
3980
|
-
const tokens = md.parseInline(data.config.title, {});
|
|
3981
|
-
return stringifyMarkdownTokens(tokens);
|
|
3982
|
-
}
|
|
3983
|
-
return data.config.title;
|
|
3984
|
-
}
|
|
3985
|
-
}
|
|
3986
|
-
|
|
3987
|
-
// node/vite/markdown.ts
|
|
3988
|
-
import Markdown2 from "unplugin-vue-markdown/vite";
|
|
3989
|
-
import { isTruthy as isTruthy3, slash } from "@antfu/utils";
|
|
3990
|
-
|
|
3991
|
-
// ../../node_modules/.pnpm/@hedgedoc+markdown-it-plugins@2.1.4_patch_hash=tuyuxytl56b2vxulpkzt2wf4o4_markdown-it@14.1.0/node_modules/@hedgedoc/markdown-it-plugins/dist/esm/image-size/specialCharacters.js
|
|
3992
|
-
var SpecialCharacters;
|
|
3993
|
-
(function(SpecialCharacters2) {
|
|
3994
|
-
SpecialCharacters2[SpecialCharacters2["EXCLAMATION_MARK"] = 33] = "EXCLAMATION_MARK";
|
|
3995
|
-
SpecialCharacters2[SpecialCharacters2["OPENING_BRACKET"] = 91] = "OPENING_BRACKET";
|
|
3996
|
-
SpecialCharacters2[SpecialCharacters2["OPENING_PARENTHESIS"] = 40] = "OPENING_PARENTHESIS";
|
|
3997
|
-
SpecialCharacters2[SpecialCharacters2["WHITESPACE"] = 32] = "WHITESPACE";
|
|
3998
|
-
SpecialCharacters2[SpecialCharacters2["NEW_LINE"] = 10] = "NEW_LINE";
|
|
3999
|
-
SpecialCharacters2[SpecialCharacters2["EQUALS"] = 61] = "EQUALS";
|
|
4000
|
-
SpecialCharacters2[SpecialCharacters2["LOWER_CASE_X"] = 120] = "LOWER_CASE_X";
|
|
4001
|
-
SpecialCharacters2[SpecialCharacters2["NUMBER_ZERO"] = 48] = "NUMBER_ZERO";
|
|
4002
|
-
SpecialCharacters2[SpecialCharacters2["NUMBER_NINE"] = 57] = "NUMBER_NINE";
|
|
4003
|
-
SpecialCharacters2[SpecialCharacters2["PERCENTAGE"] = 37] = "PERCENTAGE";
|
|
4004
|
-
SpecialCharacters2[SpecialCharacters2["CLOSING_PARENTHESIS"] = 41] = "CLOSING_PARENTHESIS";
|
|
4005
|
-
})(SpecialCharacters || (SpecialCharacters = {}));
|
|
4006
|
-
|
|
4007
|
-
// ../../node_modules/.pnpm/@hedgedoc+markdown-it-plugins@2.1.4_patch_hash=tuyuxytl56b2vxulpkzt2wf4o4_markdown-it@14.1.0/node_modules/@hedgedoc/markdown-it-plugins/dist/esm/task-lists/index.js
|
|
4008
|
-
import Token from "markdown-it/lib/token.mjs";
|
|
4009
|
-
var checkboxRegex = /^ *\[([\sx])] /i;
|
|
4010
|
-
function taskLists(md2, options = { enabled: false, label: false, lineNumber: false }) {
|
|
4011
|
-
md2.core.ruler.after("inline", "task-lists", (state) => processToken(state, options));
|
|
4012
|
-
md2.renderer.rules.taskListItemCheckbox = (tokens) => {
|
|
4013
|
-
const token = tokens[0];
|
|
4014
|
-
const checkedAttribute = token.attrGet("checked") ? 'checked="" ' : "";
|
|
4015
|
-
const disabledAttribute = token.attrGet("disabled") ? 'disabled="" ' : "";
|
|
4016
|
-
const line = token.attrGet("line");
|
|
4017
|
-
const idAttribute = `id="${token.attrGet("id")}" `;
|
|
4018
|
-
const dataLineAttribute = line && options.lineNumber ? `data-line="${line}" ` : "";
|
|
4019
|
-
return `<input class="task-list-item-checkbox" type="checkbox" ${checkedAttribute}${disabledAttribute}${dataLineAttribute}${idAttribute}/>`;
|
|
4020
|
-
};
|
|
4021
|
-
md2.renderer.rules.taskListItemLabel_close = () => {
|
|
4022
|
-
return "</label>";
|
|
4023
|
-
};
|
|
4024
|
-
md2.renderer.rules.taskListItemLabel_open = (tokens) => {
|
|
4025
|
-
const token = tokens[0];
|
|
4026
|
-
const id = token.attrGet("id");
|
|
4027
|
-
return `<label for="${id}">`;
|
|
4028
|
-
};
|
|
4029
|
-
}
|
|
4030
|
-
function processToken(state, options) {
|
|
4031
|
-
const allTokens = state.tokens;
|
|
4032
|
-
for (let i = 2; i < allTokens.length; i++) {
|
|
4033
|
-
if (!isTodoItem(allTokens, i)) {
|
|
4034
|
-
continue;
|
|
4035
|
-
}
|
|
4036
|
-
todoify(allTokens[i], options);
|
|
4037
|
-
allTokens[i - 2].attrJoin("class", `task-list-item ${options.enabled ? " enabled" : ""}`);
|
|
4038
|
-
const parentToken = findParentToken(allTokens, i - 2);
|
|
4039
|
-
if (parentToken) {
|
|
4040
|
-
const classes = parentToken.attrGet("class") ?? "";
|
|
4041
|
-
if (!classes.match(/(^| )contains-task-list/)) {
|
|
4042
|
-
parentToken.attrJoin("class", "contains-task-list");
|
|
4043
|
-
}
|
|
4044
|
-
}
|
|
4045
|
-
}
|
|
4046
|
-
return false;
|
|
4047
|
-
}
|
|
4048
|
-
function findParentToken(tokens, index) {
|
|
4049
|
-
const targetLevel = tokens[index].level - 1;
|
|
4050
|
-
for (let currentTokenIndex = index - 1; currentTokenIndex >= 0; currentTokenIndex--) {
|
|
4051
|
-
if (tokens[currentTokenIndex].level === targetLevel) {
|
|
4052
|
-
return tokens[currentTokenIndex];
|
|
4053
|
-
}
|
|
4054
|
-
}
|
|
4055
|
-
return void 0;
|
|
4056
|
-
}
|
|
4057
|
-
function isTodoItem(tokens, index) {
|
|
4058
|
-
return isInline(tokens[index]) && isParagraph(tokens[index - 1]) && isListItem(tokens[index - 2]) && startsWithTodoMarkdown(tokens[index]);
|
|
4059
|
-
}
|
|
4060
|
-
function todoify(token, options) {
|
|
4061
|
-
if (token.children == null) {
|
|
4062
|
-
return;
|
|
4063
|
-
}
|
|
4064
|
-
const id = generateIdForToken(token);
|
|
4065
|
-
token.children.splice(0, 0, createCheckboxToken(token, options.enabled, id));
|
|
4066
|
-
token.children[1].content = token.children[1].content.replace(checkboxRegex, "");
|
|
4067
|
-
if (options.label) {
|
|
4068
|
-
token.children.splice(1, 0, createLabelBeginToken(id));
|
|
4069
|
-
token.children.push(createLabelEndToken());
|
|
4070
|
-
}
|
|
4071
|
-
}
|
|
4072
|
-
function generateIdForToken(token) {
|
|
4073
|
-
if (token.map) {
|
|
4074
|
-
return `task-item-${token.map[0]}`;
|
|
4075
|
-
} else {
|
|
4076
|
-
return `task-item-${Math.ceil(Math.random() * (1e4 * 1e3) - 1e3)}`;
|
|
4077
|
-
}
|
|
4078
|
-
}
|
|
4079
|
-
function createCheckboxToken(token, enabled, id) {
|
|
4080
|
-
const checkbox = new Token("taskListItemCheckbox", "", 0);
|
|
4081
|
-
if (!enabled) {
|
|
4082
|
-
checkbox.attrSet("disabled", "true");
|
|
4083
|
-
}
|
|
4084
|
-
if (token.map) {
|
|
4085
|
-
checkbox.attrSet("line", token.map[0].toString());
|
|
4086
|
-
}
|
|
4087
|
-
checkbox.attrSet("id", id);
|
|
4088
|
-
const checkboxRegexResult = checkboxRegex.exec(token.content);
|
|
4089
|
-
const isChecked = checkboxRegexResult?.[1].toLowerCase() === "x";
|
|
4090
|
-
if (isChecked) {
|
|
4091
|
-
checkbox.attrSet("checked", "true");
|
|
4092
|
-
}
|
|
4093
|
-
return checkbox;
|
|
4094
|
-
}
|
|
4095
|
-
function createLabelBeginToken(id) {
|
|
4096
|
-
const labelBeginToken = new Token("taskListItemLabel_open", "", 1);
|
|
4097
|
-
labelBeginToken.attrSet("id", id);
|
|
4098
|
-
return labelBeginToken;
|
|
4099
|
-
}
|
|
4100
|
-
function createLabelEndToken() {
|
|
4101
|
-
return new Token("taskListItemLabel_close", "", -1);
|
|
4102
|
-
}
|
|
4103
|
-
function isInline(token) {
|
|
4104
|
-
return token.type === "inline";
|
|
4105
|
-
}
|
|
4106
|
-
function isParagraph(token) {
|
|
4107
|
-
return token.type === "paragraph_open";
|
|
4108
|
-
}
|
|
4109
|
-
function isListItem(token) {
|
|
4110
|
-
return token.type === "list_item_open";
|
|
4111
|
-
}
|
|
4112
|
-
function startsWithTodoMarkdown(token) {
|
|
4113
|
-
return checkboxRegex.test(token.content);
|
|
4114
|
-
}
|
|
4115
|
-
|
|
4116
|
-
// node/vite/markdown.ts
|
|
4117
|
-
import MarkdownItMdc from "markdown-it-mdc";
|
|
4118
|
-
import { SourceMapConsumer } from "source-map-js";
|
|
4119
|
-
import MagicString from "magic-string";
|
|
4120
|
-
import MarkdownItAttrs from "markdown-it-link-attributes";
|
|
4121
|
-
import MarkdownItFootnote from "markdown-it-footnote";
|
|
4122
|
-
|
|
4123
|
-
// node/syntax/markdown-it/markdown-it-katex.ts
|
|
4124
|
-
import katex from "katex";
|
|
4125
|
-
function isValidDelim(state, pos) {
|
|
4126
|
-
const max = state.posMax;
|
|
4127
|
-
let can_open = true;
|
|
4128
|
-
let can_close = true;
|
|
4129
|
-
const prevChar = pos > 0 ? state.src.charCodeAt(pos - 1) : -1;
|
|
4130
|
-
const nextChar = pos + 1 <= max ? state.src.charCodeAt(pos + 1) : -1;
|
|
4131
|
-
if (prevChar === 32 || prevChar === 9 || /* \t */
|
|
4132
|
-
nextChar >= 48 && nextChar <= 57)
|
|
4133
|
-
can_close = false;
|
|
4134
|
-
if (nextChar === 32 || nextChar === 9)
|
|
4135
|
-
can_open = false;
|
|
4136
|
-
return {
|
|
4137
|
-
can_open,
|
|
4138
|
-
can_close
|
|
4139
|
-
};
|
|
4140
|
-
}
|
|
4141
|
-
function math_inline(state, silent) {
|
|
4142
|
-
let match, token, res, pos;
|
|
4143
|
-
if (state.src[state.pos] !== "$")
|
|
4144
|
-
return false;
|
|
4145
|
-
res = isValidDelim(state, state.pos);
|
|
4146
|
-
if (!res.can_open) {
|
|
4147
|
-
if (!silent)
|
|
4148
|
-
state.pending += "$";
|
|
4149
|
-
state.pos += 1;
|
|
4150
|
-
return true;
|
|
4151
|
-
}
|
|
4152
|
-
const start = state.pos + 1;
|
|
4153
|
-
match = start;
|
|
4154
|
-
while ((match = state.src.indexOf("$", match)) !== -1) {
|
|
4155
|
-
pos = match - 1;
|
|
4156
|
-
while (state.src[pos] === "\\")
|
|
4157
|
-
pos -= 1;
|
|
4158
|
-
if ((match - pos) % 2 === 1)
|
|
4159
|
-
break;
|
|
4160
|
-
match += 1;
|
|
4161
|
-
}
|
|
4162
|
-
if (match === -1) {
|
|
4163
|
-
if (!silent)
|
|
4164
|
-
state.pending += "$";
|
|
4165
|
-
state.pos = start;
|
|
4166
|
-
return true;
|
|
4167
|
-
}
|
|
4168
|
-
if (match - start === 0) {
|
|
4169
|
-
if (!silent)
|
|
4170
|
-
state.pending += "$$";
|
|
4171
|
-
state.pos = start + 1;
|
|
4172
|
-
return true;
|
|
4173
|
-
}
|
|
4174
|
-
res = isValidDelim(state, match);
|
|
4175
|
-
if (!res.can_close) {
|
|
4176
|
-
if (!silent)
|
|
4177
|
-
state.pending += "$";
|
|
4178
|
-
state.pos = start;
|
|
4179
|
-
return true;
|
|
4180
|
-
}
|
|
4181
|
-
if (!silent) {
|
|
4182
|
-
token = state.push("math_inline", "math", 0);
|
|
4183
|
-
token.markup = "$";
|
|
4184
|
-
token.content = state.src.slice(start, match);
|
|
4185
|
-
}
|
|
4186
|
-
state.pos = match + 1;
|
|
4187
|
-
return true;
|
|
4188
|
-
}
|
|
4189
|
-
function math_block(state, start, end, silent) {
|
|
4190
|
-
let firstLine;
|
|
4191
|
-
let lastLine;
|
|
4192
|
-
let next;
|
|
4193
|
-
let lastPos;
|
|
4194
|
-
let found = false;
|
|
4195
|
-
let pos = state.bMarks[start] + state.tShift[start];
|
|
4196
|
-
let max = state.eMarks[start];
|
|
4197
|
-
if (pos + 2 > max)
|
|
4198
|
-
return false;
|
|
4199
|
-
if (state.src.slice(pos, pos + 2) !== "$$")
|
|
4200
|
-
return false;
|
|
4201
|
-
pos += 2;
|
|
4202
|
-
firstLine = state.src.slice(pos, max);
|
|
4203
|
-
if (silent)
|
|
4204
|
-
return true;
|
|
4205
|
-
if (firstLine.trim().slice(-2) === "$$") {
|
|
4206
|
-
firstLine = firstLine.trim().slice(0, -2);
|
|
4207
|
-
found = true;
|
|
4208
|
-
}
|
|
4209
|
-
for (next = start; !found; ) {
|
|
4210
|
-
next++;
|
|
4211
|
-
if (next >= end)
|
|
4212
|
-
break;
|
|
4213
|
-
pos = state.bMarks[next] + state.tShift[next];
|
|
4214
|
-
max = state.eMarks[next];
|
|
4215
|
-
if (pos < max && state.tShift[next] < state.blkIndent) {
|
|
4216
|
-
break;
|
|
4217
|
-
}
|
|
4218
|
-
if (state.src.slice(pos, max).trim().slice(-2) === "$$") {
|
|
4219
|
-
lastPos = state.src.slice(0, max).lastIndexOf("$$");
|
|
4220
|
-
lastLine = state.src.slice(pos, lastPos);
|
|
4221
|
-
found = true;
|
|
4222
|
-
}
|
|
4223
|
-
}
|
|
4224
|
-
state.line = next + 1;
|
|
4225
|
-
const token = state.push("math_block", "math", 0);
|
|
4226
|
-
token.block = true;
|
|
4227
|
-
token.content = (firstLine && firstLine.trim() ? `${firstLine}
|
|
4228
|
-
` : "") + state.getLines(start + 1, next, state.tShift[start], true) + (lastLine && lastLine.trim() ? lastLine : "");
|
|
4229
|
-
token.map = [start, state.line];
|
|
4230
|
-
token.markup = "$$";
|
|
4231
|
-
return true;
|
|
4232
|
-
}
|
|
4233
|
-
function math_plugin(md2, options) {
|
|
4234
|
-
options = options || {};
|
|
4235
|
-
const katexInline = function(latex) {
|
|
4236
|
-
options.displayMode = false;
|
|
4237
|
-
try {
|
|
4238
|
-
return katex.renderToString(latex, options);
|
|
4239
|
-
} catch (error) {
|
|
4240
|
-
if (options.throwOnError)
|
|
4241
|
-
console.warn(error);
|
|
4242
|
-
return latex;
|
|
4243
|
-
}
|
|
4244
|
-
};
|
|
4245
|
-
const inlineRenderer = function(tokens, idx) {
|
|
4246
|
-
return katexInline(tokens[idx].content);
|
|
4247
|
-
};
|
|
4248
|
-
const katexBlock = function(latex) {
|
|
4249
|
-
options.displayMode = true;
|
|
4250
|
-
try {
|
|
4251
|
-
return `<p>${katex.renderToString(latex, options)}</p>`;
|
|
4252
|
-
} catch (error) {
|
|
4253
|
-
if (options.throwOnError)
|
|
4254
|
-
console.warn(error);
|
|
4255
|
-
return latex;
|
|
4256
|
-
}
|
|
4257
|
-
};
|
|
4258
|
-
const blockRenderer = function(tokens, idx) {
|
|
4259
|
-
return `${katexBlock(tokens[idx].content)}
|
|
4260
|
-
`;
|
|
4261
|
-
};
|
|
4262
|
-
md2.inline.ruler.after("escape", "math_inline", math_inline);
|
|
4263
|
-
md2.block.ruler.after("blockquote", "math_block", math_block, {
|
|
4264
|
-
alt: ["paragraph", "reference", "blockquote", "list"]
|
|
4265
|
-
});
|
|
4266
|
-
md2.renderer.rules.math_inline = inlineRenderer;
|
|
4267
|
-
md2.renderer.rules.math_block = blockRenderer;
|
|
4268
|
-
}
|
|
4269
|
-
|
|
4270
|
-
// node/syntax/markdown-it/markdown-it-prism.ts
|
|
4271
|
-
import { createRequire } from "node:module";
|
|
4272
|
-
import Prism from "prismjs";
|
|
4273
|
-
import loadLanguages from "prismjs/components/index.js";
|
|
4274
|
-
import * as htmlparser2 from "htmlparser2";
|
|
4275
|
-
|
|
4276
|
-
// node/syntax/transform/utils.ts
|
|
4277
|
-
function normalizeRangeStr(rangeStr = "") {
|
|
4278
|
-
return !rangeStr.trim() ? [] : rangeStr.trim().split(/\|/g).map((i) => i.trim());
|
|
4279
|
-
}
|
|
4280
|
-
function escapeVueInCode(md2) {
|
|
4281
|
-
return md2.replace(/{{/g, "{{");
|
|
4282
|
-
}
|
|
4283
|
-
|
|
4284
|
-
// node/syntax/markdown-it/markdown-it-prism.ts
|
|
4285
|
-
var require2 = createRequire(import.meta.url);
|
|
4286
|
-
var Tag = class {
|
|
4287
|
-
tagname;
|
|
4288
|
-
attributes;
|
|
4289
|
-
constructor(tagname, attributes) {
|
|
4290
|
-
this.tagname = tagname;
|
|
4291
|
-
this.attributes = attributes;
|
|
4292
|
-
}
|
|
4293
|
-
asOpen() {
|
|
4294
|
-
return `<${this.tagname} ${Object.entries(this.attributes).map(([key, value]) => `${key}="${value}"`).join(" ")}>`;
|
|
4295
|
-
}
|
|
4296
|
-
asClosed() {
|
|
4297
|
-
return `</${this.tagname}>`;
|
|
4298
|
-
}
|
|
4299
|
-
};
|
|
4300
|
-
var DEFAULTS = {
|
|
4301
|
-
plugins: [],
|
|
4302
|
-
init: () => {
|
|
4303
|
-
},
|
|
4304
|
-
defaultLanguageForUnknown: void 0,
|
|
4305
|
-
defaultLanguageForUnspecified: void 0,
|
|
4306
|
-
defaultLanguage: void 0
|
|
4307
|
-
};
|
|
4308
|
-
function loadPrismLang(lang) {
|
|
4309
|
-
if (!lang)
|
|
4310
|
-
return void 0;
|
|
4311
|
-
let langObject = Prism.languages[lang];
|
|
4312
|
-
if (langObject === void 0) {
|
|
4313
|
-
loadLanguages([lang]);
|
|
4314
|
-
langObject = Prism.languages[lang];
|
|
4315
|
-
}
|
|
4316
|
-
return langObject;
|
|
4317
|
-
}
|
|
4318
|
-
function loadPrismPlugin(name) {
|
|
4319
|
-
try {
|
|
4320
|
-
require2(`prismjs/plugins/${name}/prism-${name}`);
|
|
4321
|
-
} catch (e) {
|
|
4322
|
-
throw new Error(`Cannot load Prism plugin "${name}". Please check the spelling.`);
|
|
4323
|
-
}
|
|
4324
|
-
}
|
|
4325
|
-
function selectLanguage(options, lang) {
|
|
4326
|
-
let langToUse = lang;
|
|
4327
|
-
if (langToUse === "" && options.defaultLanguageForUnspecified !== void 0)
|
|
4328
|
-
langToUse = options.defaultLanguageForUnspecified;
|
|
4329
|
-
let prismLang = loadPrismLang(langToUse);
|
|
4330
|
-
if (prismLang === void 0 && options.defaultLanguageForUnknown !== void 0) {
|
|
4331
|
-
langToUse = options.defaultLanguageForUnknown;
|
|
4332
|
-
prismLang = loadPrismLang(langToUse);
|
|
4333
|
-
}
|
|
4334
|
-
return [langToUse, prismLang];
|
|
4335
|
-
}
|
|
4336
|
-
function highlight(markdownit, options, text, lang) {
|
|
4337
|
-
const [langToUse, prismLang] = selectLanguage(options, lang);
|
|
4338
|
-
let code = text.trimEnd();
|
|
4339
|
-
code = prismLang ? highlightPrism(code, prismLang, langToUse) : markdownit.utils.escapeHtml(code);
|
|
4340
|
-
code = code.split(/\r?\n/g).map((line) => `<span class="line">${line}</span>`).join("\n");
|
|
4341
|
-
const classAttribute = langToUse ? ` class="slidev-code ${markdownit.options.langPrefix}${markdownit.utils.escapeHtml(langToUse)}"` : "";
|
|
4342
|
-
return escapeVueInCode(`<pre${classAttribute}><code>${code}</code></pre>`);
|
|
4343
|
-
}
|
|
4344
|
-
function highlightPrism(code, prismLang, langToUse) {
|
|
4345
|
-
const openTags = [];
|
|
4346
|
-
const parser2 = new htmlparser2.Parser({
|
|
4347
|
-
onopentag(tagname, attributes) {
|
|
4348
|
-
openTags.push(new Tag(tagname, attributes));
|
|
4349
|
-
},
|
|
4350
|
-
onclosetag() {
|
|
4351
|
-
openTags.pop();
|
|
4352
|
-
}
|
|
4353
|
-
});
|
|
4354
|
-
code = Prism.highlight(code, prismLang, langToUse);
|
|
4355
|
-
code = code.split(/\r?\n/g).map((line) => {
|
|
4356
|
-
const prefix = openTags.map((tag) => tag.asOpen()).join("");
|
|
4357
|
-
parser2.write(line);
|
|
4358
|
-
const postfix = openTags.reverse().map((tag) => tag.asClosed()).join("");
|
|
4359
|
-
return prefix + line + postfix;
|
|
4360
|
-
}).join("\n");
|
|
4361
|
-
parser2.end();
|
|
4362
|
-
return code;
|
|
4363
|
-
}
|
|
4364
|
-
function checkLanguageOption(options, optionName) {
|
|
4365
|
-
const language = options[optionName];
|
|
4366
|
-
if (language !== void 0 && loadPrismLang(language) === void 0)
|
|
4367
|
-
throw new Error(`Bad option ${optionName}: There is no Prism language '${language}'.`);
|
|
4368
|
-
}
|
|
4369
|
-
function markdownItPrism(markdownit, useroptions) {
|
|
4370
|
-
const options = Object.assign({}, DEFAULTS, useroptions);
|
|
4371
|
-
checkLanguageOption(options, "defaultLanguage");
|
|
4372
|
-
checkLanguageOption(options, "defaultLanguageForUnknown");
|
|
4373
|
-
checkLanguageOption(options, "defaultLanguageForUnspecified");
|
|
4374
|
-
options.defaultLanguageForUnknown = options.defaultLanguageForUnknown || options.defaultLanguage;
|
|
4375
|
-
options.defaultLanguageForUnspecified = options.defaultLanguageForUnspecified || options.defaultLanguage;
|
|
4376
|
-
options.plugins.forEach(loadPrismPlugin);
|
|
4377
|
-
options.init(Prism);
|
|
4378
|
-
markdownit.options.highlight = (text, lang) => highlight(markdownit, options, text, lang);
|
|
4379
|
-
}
|
|
4380
|
-
|
|
4381
|
-
// node/syntax/markdown-it/markdown-it-v-drag.ts
|
|
4382
|
-
function markdownItVDrag(md2, sourceMapConsumers) {
|
|
4383
|
-
const visited = /* @__PURE__ */ new WeakSet();
|
|
4384
|
-
const _parse = md2.parse;
|
|
4385
|
-
md2.parse = function(src, env) {
|
|
4386
|
-
const smc = sourceMapConsumers[env.id];
|
|
4387
|
-
const toOriginalPos = smc ? (line) => smc.originalPositionFor({ line, column: 0 }).line : (line) => line;
|
|
4388
|
-
function toMarkdownSource(map2, idx) {
|
|
4389
|
-
const [start, end] = map2;
|
|
4390
|
-
return `[${toOriginalPos(start)},${toOriginalPos(end)},${idx}]`;
|
|
4391
|
-
}
|
|
4392
|
-
return _parse.call(this, src, env).map((token) => {
|
|
4393
|
-
if (token.type !== "html_block" || !token.content.includes("v-drag") || visited.has(token))
|
|
4394
|
-
return token;
|
|
4395
|
-
token.content = token.content.replace(
|
|
4396
|
-
/<v-drag([\s>])/g,
|
|
4397
|
-
(_, space, idx) => `<v-drag :markdownSource="${toMarkdownSource(token.map, idx)}"${space}`
|
|
4398
|
-
).replace(
|
|
4399
|
-
/(?<![</\w])v-drag(=".*?")?/g,
|
|
4400
|
-
(_, value, idx) => `v-drag${value ?? ""} :markdownSource="[${token.map[0]},${token.map[1]},${idx}]"`
|
|
4401
|
-
);
|
|
4402
|
-
visited.add(token);
|
|
4403
|
-
return token;
|
|
4404
|
-
});
|
|
4405
|
-
};
|
|
4406
|
-
}
|
|
4407
|
-
|
|
4408
|
-
// node/syntax/transform/code-wrapper.ts
|
|
4409
|
-
var reCodeBlock = /^```([\w'-]+?)(?:\s*{([\d\w*,\|-]+)}\s*?({.*?})?(.*?))?\n([\s\S]+?)^```$/mg;
|
|
4410
|
-
function transformCodeWrapper(ctx) {
|
|
4411
|
-
ctx.s.replace(
|
|
4412
|
-
reCodeBlock,
|
|
4413
|
-
(full, lang = "", rangeStr = "", options = "", attrs = "", code, index) => {
|
|
4414
|
-
if (ctx.isIgnored(index))
|
|
4415
|
-
return full;
|
|
4416
|
-
const ranges = normalizeRangeStr(rangeStr);
|
|
4417
|
-
code = code.trimEnd();
|
|
4418
|
-
options = options.trim() || "{}";
|
|
4419
|
-
ctx.ignores.push([index, index + full.length]);
|
|
4420
|
-
return `
|
|
4421
|
-
<CodeBlockWrapper v-bind="${options}" :ranges='${JSON.stringify(ranges)}'>
|
|
4422
|
-
|
|
4423
|
-
\`\`\`${lang}${attrs}
|
|
4424
|
-
${code}
|
|
4425
|
-
\`\`\`
|
|
4426
|
-
|
|
4427
|
-
</CodeBlockWrapper>`;
|
|
4428
|
-
}
|
|
4429
|
-
);
|
|
4430
|
-
}
|
|
4431
|
-
|
|
4432
|
-
// node/syntax/transform/magic-move.ts
|
|
4433
|
-
import { codeToKeyedTokens } from "shiki-magic-move/core";
|
|
4434
|
-
import lz2 from "lz-string";
|
|
4435
|
-
var reMagicMoveBlock = /^````(?:md|markdown) magic-move(?:[ ]*(\{.*?\})?([^\n]*?))?\n([\s\S]+?)^````$/mg;
|
|
4436
|
-
function transformMagicMove(ctx, shiki2, shikiOptions2) {
|
|
4437
|
-
ctx.s.replace(
|
|
4438
|
-
reMagicMoveBlock,
|
|
4439
|
-
(full, options = "{}", _attrs = "", body, index) => {
|
|
4440
|
-
if (!shiki2 || !shikiOptions2)
|
|
4441
|
-
throw new Error("Shiki is required for Magic Move. You may need to set `highlighter: shiki` in your Slidev config.");
|
|
4442
|
-
const matches = Array.from(body.matchAll(reCodeBlock));
|
|
4443
|
-
if (!matches.length)
|
|
4444
|
-
throw new Error("Magic Move block must contain at least one code block");
|
|
4445
|
-
const ranges = matches.map((i) => normalizeRangeStr(i[2]));
|
|
4446
|
-
const steps = matches.map(
|
|
4447
|
-
(i) => codeToKeyedTokens(shiki2, i[5].trimEnd(), {
|
|
4448
|
-
...shikiOptions2,
|
|
4449
|
-
lang: i[1]
|
|
4450
|
-
})
|
|
4451
|
-
);
|
|
4452
|
-
const compressed = lz2.compressToBase64(JSON.stringify(steps));
|
|
4453
|
-
ctx.ignores.push([index, index + full.length]);
|
|
4454
|
-
return `<ShikiMagicMove v-bind="${options}" steps-lz="${compressed}" :step-ranges='${JSON.stringify(ranges)}' />`;
|
|
4455
|
-
}
|
|
4456
|
-
);
|
|
4457
|
-
}
|
|
4458
|
-
|
|
4459
|
-
// node/syntax/transform/mermaid.ts
|
|
4460
|
-
import lz3 from "lz-string";
|
|
4461
|
-
function transformMermaid(ctx) {
|
|
4462
|
-
ctx.s.replace(/^```mermaid\s*?({.*?})?\n([\s\S]+?)\n```/mg, (full, options = "", code = "", index) => {
|
|
4463
|
-
code = code.trim();
|
|
4464
|
-
options = options.trim() || "{}";
|
|
4465
|
-
const encoded = lz3.compressToBase64(code);
|
|
4466
|
-
ctx.ignores.push([index, index + full.length]);
|
|
4467
|
-
return `<Mermaid code-lz="${encoded}" v-bind="${options}" />`;
|
|
4468
|
-
});
|
|
4469
|
-
}
|
|
4470
|
-
|
|
4471
|
-
// node/syntax/transform/plant-uml.ts
|
|
4472
|
-
import { encode as encodePlantUml } from "plantuml-encoder";
|
|
4473
|
-
function transformPlantUml(ctx, server) {
|
|
4474
|
-
ctx.s.replace(/^```plantuml\s*?({.*?})?\n([\s\S]+?)\n```/mg, (full, options = "", content = "", index) => {
|
|
4475
|
-
const code = encodePlantUml(content.trim());
|
|
4476
|
-
options = options.trim() || "{}";
|
|
4477
|
-
ctx.ignores.push([index, index + full.length]);
|
|
4478
|
-
return `<PlantUml :code="'${code}'" :server="'${server}'" v-bind="${options}" />`;
|
|
4479
|
-
});
|
|
4480
|
-
}
|
|
4481
|
-
|
|
4482
|
-
// node/syntax/transform/snippet.ts
|
|
4483
|
-
import path from "node:path";
|
|
4484
|
-
import fs5 from "fs-extra";
|
|
4485
|
-
function dedent(text) {
|
|
4486
|
-
const lines = text.split("\n");
|
|
4487
|
-
const minIndentLength = lines.reduce((acc, line) => {
|
|
4488
|
-
for (let i = 0; i < line.length; i++) {
|
|
4489
|
-
if (line[i] !== " " && line[i] !== " ")
|
|
4490
|
-
return Math.min(i, acc);
|
|
4491
|
-
}
|
|
4492
|
-
return acc;
|
|
4493
|
-
}, Number.POSITIVE_INFINITY);
|
|
4494
|
-
if (minIndentLength < Number.POSITIVE_INFINITY)
|
|
4495
|
-
return lines.map((x) => x.slice(minIndentLength)).join("\n");
|
|
4496
|
-
return text;
|
|
4497
|
-
}
|
|
4498
|
-
function testLine(line, regexp, regionName, end = false) {
|
|
4499
|
-
const [full, tag, name] = regexp.exec(line.trim()) || [];
|
|
4500
|
-
return full && tag && name === regionName && tag.match(end ? /^[Ee]nd ?[rR]egion$/ : /^[rR]egion$/);
|
|
4501
|
-
}
|
|
4502
|
-
function findRegion(lines, regionName) {
|
|
4503
|
-
const regionRegexps = [
|
|
4504
|
-
/^\/\/ ?#?((?:end)?region) ([\w*-]+)$/,
|
|
4505
|
-
// javascript, typescript, java
|
|
4506
|
-
/^\/\* ?#((?:end)?region) ([\w*-]+) ?\*\/$/,
|
|
4507
|
-
// css, less, scss
|
|
4508
|
-
/^#pragma ((?:end)?region) ([\w*-]+)$/,
|
|
4509
|
-
// C, C++
|
|
4510
|
-
/^<!-- #?((?:end)?region) ([\w*-]+) -->$/,
|
|
4511
|
-
// HTML, markdown
|
|
4512
|
-
/^#((?:End )Region) ([\w*-]+)$/,
|
|
4513
|
-
// Visual Basic
|
|
4514
|
-
/^::#((?:end)region) ([\w*-]+)$/,
|
|
4515
|
-
// Bat
|
|
4516
|
-
/^# ?((?:end)?region) ([\w*-]+)$/
|
|
4517
|
-
// C#, PHP, Powershell, Python, perl & misc
|
|
4518
|
-
];
|
|
4519
|
-
let regexp = null;
|
|
4520
|
-
let start = -1;
|
|
4521
|
-
for (const [lineId, line] of lines.entries()) {
|
|
4522
|
-
if (regexp === null) {
|
|
4523
|
-
for (const reg of regionRegexps) {
|
|
4524
|
-
if (testLine(line, reg, regionName)) {
|
|
4525
|
-
start = lineId + 1;
|
|
4526
|
-
regexp = reg;
|
|
4527
|
-
break;
|
|
4528
|
-
}
|
|
4529
|
-
}
|
|
4530
|
-
} else if (testLine(line, regexp, regionName, true)) {
|
|
4531
|
-
return { start, end: lineId, regexp };
|
|
4532
|
-
}
|
|
4533
|
-
}
|
|
4534
|
-
return null;
|
|
4535
|
-
}
|
|
4536
|
-
function transformSnippet(ctx, options, id) {
|
|
4537
|
-
const slideId = id.match(/(\d+)\.md$/)?.[1];
|
|
4538
|
-
if (!slideId)
|
|
4539
|
-
return;
|
|
4540
|
-
const data = options.data;
|
|
4541
|
-
const slideInfo = data.slides[+slideId - 1];
|
|
4542
|
-
const dir = path.dirname(slideInfo.source?.filepath ?? options.entry ?? options.userRoot);
|
|
4543
|
-
ctx.s.replace(
|
|
4544
|
-
/^<<< *(.+?)(#[\w-]+)? *(?: (\S+?))? *(\{.*)?$/mg,
|
|
4545
|
-
(full, filepath = "", regionName = "", lang = "", meta = "") => {
|
|
4546
|
-
const firstLine = `\`\`\`${lang || path.extname(filepath).slice(1)} ${meta}`;
|
|
4547
|
-
const src = /^\@[\/]/.test(filepath) ? path.resolve(options.userRoot, filepath.slice(2)) : path.resolve(dir, filepath);
|
|
4548
|
-
data.watchFiles.push(src);
|
|
4549
|
-
const isAFile = fs5.statSync(src).isFile();
|
|
4550
|
-
if (!fs5.existsSync(src) || !isAFile) {
|
|
4551
|
-
throw new Error(isAFile ? `Code snippet path not found: ${src}` : `Invalid code snippet option`);
|
|
4552
|
-
}
|
|
4553
|
-
let content = fs5.readFileSync(src, "utf8");
|
|
4554
|
-
slideInfo.snippetsUsed ??= {};
|
|
4555
|
-
slideInfo.snippetsUsed[src] = content;
|
|
4556
|
-
if (regionName) {
|
|
4557
|
-
const lines = content.split(/\r?\n/);
|
|
4558
|
-
const region = findRegion(lines, regionName.slice(1));
|
|
4559
|
-
if (region) {
|
|
4560
|
-
content = dedent(
|
|
4561
|
-
lines.slice(region.start, region.end).filter((line) => !region.regexp.test(line.trim())).join("\n")
|
|
4562
|
-
);
|
|
4563
|
-
}
|
|
4564
|
-
}
|
|
4565
|
-
return `${firstLine}
|
|
4566
|
-
${content}
|
|
4567
|
-
\`\`\``;
|
|
4568
|
-
}
|
|
4569
|
-
);
|
|
4570
|
-
}
|
|
4571
|
-
|
|
4572
|
-
// node/syntax/transform/slot-sugar.ts
|
|
4573
|
-
function transformSlotSugar(ctx) {
|
|
4574
|
-
const linesWithNewline = ctx.s.original.split(/(\r?\n)/g);
|
|
4575
|
-
const lines = [];
|
|
4576
|
-
for (let i = 0; i < linesWithNewline.length; i += 2) {
|
|
4577
|
-
const line = linesWithNewline[i];
|
|
4578
|
-
const newline = linesWithNewline[i + 1] || "";
|
|
4579
|
-
lines.push(line + newline);
|
|
4580
|
-
}
|
|
4581
|
-
let prevSlot = false;
|
|
4582
|
-
let offset = 0;
|
|
4583
|
-
lines.forEach((line) => {
|
|
4584
|
-
const start = offset;
|
|
4585
|
-
offset += line.length;
|
|
4586
|
-
if (ctx.isIgnored(start))
|
|
4587
|
-
return;
|
|
4588
|
-
const match = line.match(/^::\s*([\w\.\-\:]+)\s*::(\s*)?$/);
|
|
4589
|
-
if (match) {
|
|
4590
|
-
ctx.s.overwrite(start, offset - match[2].length, `${prevSlot ? "\n\n</template>\n" : "\n"}<template v-slot:${match[1]}="slotProps">
|
|
4591
|
-
`);
|
|
4592
|
-
prevSlot = true;
|
|
4593
|
-
}
|
|
4594
|
-
});
|
|
4595
|
-
if (prevSlot)
|
|
4596
|
-
ctx.s.append("\n\n</template>");
|
|
4597
|
-
}
|
|
4598
|
-
|
|
4599
|
-
// node/syntax/transform/in-page-css.ts
|
|
4600
|
-
function transformPageCSS(ctx, id) {
|
|
4601
|
-
const page = id.match(/(\d+)\.md$/)?.[1];
|
|
4602
|
-
if (!page)
|
|
4603
|
-
return;
|
|
4604
|
-
ctx.s.replace(
|
|
4605
|
-
/(\n<style[^>]*?>)([\s\S]+?)(<\/style>)/g,
|
|
4606
|
-
(full, start, css, end, index) => {
|
|
4607
|
-
if (ctx.isIgnored(index))
|
|
4608
|
-
return full;
|
|
4609
|
-
if (!start.includes("scoped"))
|
|
4610
|
-
start = start.replace("<style", "<style scoped");
|
|
4611
|
-
return `${start}
|
|
4612
|
-
${css}${end}`;
|
|
4613
|
-
}
|
|
4614
|
-
);
|
|
4615
|
-
}
|
|
4616
|
-
|
|
4617
|
-
// node/syntax/transform/katex-wrapper.ts
|
|
4618
|
-
function transformKaTexWrapper(ctx) {
|
|
4619
|
-
ctx.s.replace(
|
|
4620
|
-
/^\$\$(?:\s*{([\d\w*,\|-]+)}\s*?({.*?})?\s*?)?\n([\s\S]+?)^\$\$/mg,
|
|
4621
|
-
(full, rangeStr = "", options = "", code, index) => {
|
|
4622
|
-
const ranges = !rangeStr.trim() ? [] : rangeStr.trim().split(/\|/g).map((i) => i.trim());
|
|
4623
|
-
code = code.trimEnd();
|
|
4624
|
-
options = options.trim() || "{}";
|
|
4625
|
-
ctx.ignores.push([index, index + full.length]);
|
|
4626
|
-
return `<KaTexBlockWrapper v-bind="${options}" :ranges='${JSON.stringify(ranges)}'>
|
|
4627
|
-
|
|
4628
|
-
$$
|
|
4629
|
-
${code}
|
|
4630
|
-
$$
|
|
4631
|
-
</KaTexBlockWrapper>
|
|
4632
|
-
`;
|
|
4633
|
-
}
|
|
4634
|
-
);
|
|
4635
|
-
}
|
|
4636
|
-
|
|
4637
|
-
// node/vite/markdown.ts
|
|
4638
|
-
var shiki;
|
|
4639
|
-
var shikiOptions;
|
|
4640
|
-
async function createMarkdownPlugin(options, { markdown: mdOptions }) {
|
|
4641
|
-
const { data: { config }, roots, mode, entry, clientRoot } = options;
|
|
4642
|
-
const setups = [];
|
|
4643
|
-
const entryPath = slash(entry);
|
|
4644
|
-
if (config.highlighter === "shiki") {
|
|
4645
|
-
const [
|
|
4646
|
-
options2,
|
|
4647
|
-
{ getHighlighter, bundledLanguages },
|
|
4648
|
-
markdownItShiki,
|
|
4649
|
-
transformerTwoslash
|
|
4650
|
-
] = await Promise.all([
|
|
4651
|
-
loadShikiSetups(clientRoot, roots),
|
|
4652
|
-
import("shiki").then(({ getHighlighter: getHighlighter2, bundledLanguages: bundledLanguages2 }) => ({ bundledLanguages: bundledLanguages2, getHighlighter: getHighlighter2 })),
|
|
4653
|
-
import("@shikijs/markdown-it/core").then(({ fromHighlighter }) => fromHighlighter),
|
|
4654
|
-
import("@shikijs/vitepress-twoslash").then(({ transformerTwoslash: transformerTwoslash2 }) => transformerTwoslash2)
|
|
4655
|
-
]);
|
|
4656
|
-
shikiOptions = options2;
|
|
4657
|
-
shiki = await getHighlighter({
|
|
4658
|
-
...options2,
|
|
4659
|
-
langs: options2.langs ?? Object.keys(bundledLanguages),
|
|
4660
|
-
themes: "themes" in options2 ? Object.values(options2.themes) : [options2.theme]
|
|
4661
|
-
});
|
|
4662
|
-
const twoslashEnabled = config.twoslash === true || config.twoslash === mode;
|
|
4663
|
-
const transformers = [
|
|
4664
|
-
...options2.transformers || [],
|
|
4665
|
-
twoslashEnabled && transformerTwoslash({
|
|
4666
|
-
explicitTrigger: true,
|
|
4667
|
-
twoslashOptions: {
|
|
4668
|
-
handbookOptions: {
|
|
4669
|
-
noErrorValidation: true
|
|
4670
|
-
}
|
|
4671
|
-
}
|
|
4672
|
-
}),
|
|
4673
|
-
{
|
|
4674
|
-
pre(pre) {
|
|
4675
|
-
this.addClassToHast(pre, "slidev-code");
|
|
4676
|
-
delete pre.properties.tabindex;
|
|
4677
|
-
},
|
|
4678
|
-
postprocess(code) {
|
|
4679
|
-
return escapeVueInCode(code);
|
|
4680
|
-
}
|
|
4681
|
-
}
|
|
4682
|
-
].filter(isTruthy3);
|
|
4683
|
-
const plugin = markdownItShiki(shiki, {
|
|
4684
|
-
...options2,
|
|
4685
|
-
transformers
|
|
4686
|
-
});
|
|
4687
|
-
setups.push((md2) => md2.use(plugin));
|
|
4688
|
-
} else {
|
|
4689
|
-
setups.push((md2) => md2.use(markdownItPrism));
|
|
4690
|
-
}
|
|
4691
|
-
if (config.mdc)
|
|
4692
|
-
setups.push((md2) => md2.use(MarkdownItMdc));
|
|
4693
|
-
const KatexOptions = await loadSetups(options.clientRoot, roots, "katex.ts", {}, { strict: false }, false);
|
|
4694
|
-
const sourceMapConsumers = {};
|
|
4695
|
-
return Markdown2({
|
|
4696
|
-
include: [/\.md$/],
|
|
4697
|
-
wrapperClasses: "",
|
|
4698
|
-
headEnabled: false,
|
|
4699
|
-
frontmatter: false,
|
|
4700
|
-
escapeCodeTagInterpolation: false,
|
|
4701
|
-
markdownItOptions: {
|
|
4702
|
-
quotes: `""''`,
|
|
4703
|
-
html: true,
|
|
4704
|
-
xhtmlOut: true,
|
|
4705
|
-
linkify: true,
|
|
4706
|
-
...mdOptions?.markdownItOptions
|
|
4707
|
-
},
|
|
4708
|
-
...mdOptions,
|
|
4709
|
-
markdownItSetup(md2) {
|
|
4710
|
-
md2.use(MarkdownItAttrs, {
|
|
4711
|
-
attrs: {
|
|
4712
|
-
target: "_blank",
|
|
4713
|
-
rel: "noopener"
|
|
4714
|
-
}
|
|
4715
|
-
});
|
|
4716
|
-
md2.use(MarkdownItFootnote);
|
|
4717
|
-
md2.use(taskLists, { enabled: true, lineNumber: true, label: true });
|
|
4718
|
-
md2.use(math_plugin, KatexOptions);
|
|
4719
|
-
md2.use(markdownItVDrag, sourceMapConsumers);
|
|
4720
|
-
setups.forEach((i) => i(md2));
|
|
4721
|
-
mdOptions?.markdownItSetup?.(md2);
|
|
4722
|
-
},
|
|
4723
|
-
transforms: {
|
|
4724
|
-
before(code, id) {
|
|
4725
|
-
if (id === entryPath)
|
|
4726
|
-
return "";
|
|
4727
|
-
const monacoEnabled = config.monaco === true || config.monaco === mode;
|
|
4728
|
-
const ctx = {
|
|
4729
|
-
s: new MagicString(code),
|
|
4730
|
-
ignores: [],
|
|
4731
|
-
isIgnored(index) {
|
|
4732
|
-
return index < 0 || ctx.ignores.some(([start, end]) => start <= index && index < end);
|
|
4733
|
-
}
|
|
4734
|
-
};
|
|
4735
|
-
transformSnippet(ctx, options, id);
|
|
4736
|
-
if (config.highlighter === "shiki")
|
|
4737
|
-
transformMagicMove(ctx, shiki, shikiOptions);
|
|
4738
|
-
transformMermaid(ctx);
|
|
4739
|
-
transformPlantUml(ctx, config.plantUmlServer);
|
|
4740
|
-
transformMonaco(ctx, monacoEnabled);
|
|
4741
|
-
transformCodeWrapper(ctx);
|
|
4742
|
-
transformKaTexWrapper(ctx);
|
|
4743
|
-
transformPageCSS(ctx, id);
|
|
4744
|
-
transformSlotSugar(ctx);
|
|
4745
|
-
sourceMapConsumers[id] = new SourceMapConsumer(ctx.s.generateMap());
|
|
4746
|
-
return ctx.s.toString();
|
|
4747
|
-
}
|
|
4748
|
-
}
|
|
4749
|
-
});
|
|
4750
|
-
}
|
|
4751
|
-
|
|
4752
|
-
// node/vite/compilerFlagsVue.ts
|
|
4753
|
-
import { objectEntries } from "@antfu/utils";
|
|
4754
|
-
function createVueCompilerFlagsPlugin(options) {
|
|
4755
|
-
const define = objectEntries(getDefine(options));
|
|
4756
|
-
return [
|
|
4757
|
-
{
|
|
4758
|
-
name: "slidev:flags",
|
|
4759
|
-
enforce: "pre",
|
|
4760
|
-
transform(code, id) {
|
|
4761
|
-
if (id.match(/\.vue($|\?)/)) {
|
|
4762
|
-
const original = code;
|
|
4763
|
-
define.forEach(([from, to]) => {
|
|
4764
|
-
code = code.replace(new RegExp(from, "g"), to);
|
|
4765
|
-
});
|
|
4766
|
-
if (original !== code)
|
|
4767
|
-
return code;
|
|
4768
|
-
}
|
|
4769
|
-
}
|
|
4770
|
-
}
|
|
4771
|
-
];
|
|
4772
|
-
}
|
|
4773
|
-
|
|
4774
|
-
// node/vite/monacoTypes.ts
|
|
4775
|
-
import fs6 from "node:fs/promises";
|
|
4776
|
-
import { dirname as dirname2, resolve as resolve3 } from "node:path";
|
|
4777
|
-
import { slash as slash2 } from "@antfu/utils";
|
|
4778
|
-
import fg4 from "fast-glob";
|
|
4779
|
-
import { findDepPkgJsonPath } from "vitefu";
|
|
4780
|
-
function createMonacoTypesLoader({ userRoot }) {
|
|
4781
|
-
const resolvedDepsMap = {};
|
|
4782
|
-
return {
|
|
4783
|
-
name: "slidev:monaco-types-loader",
|
|
4784
|
-
resolveId(id) {
|
|
4785
|
-
if (id.startsWith("/@slidev-monaco-types/"))
|
|
4786
|
-
return id;
|
|
4787
|
-
return null;
|
|
4788
|
-
},
|
|
4789
|
-
async load(id) {
|
|
4790
|
-
const matchResolve = id.match(/^\/\@slidev-monaco-types\/resolve\?pkg=(.*?)(?:&importer=(.*))?$/);
|
|
4791
|
-
if (matchResolve) {
|
|
4792
|
-
const [_, pkg, importer = userRoot] = matchResolve;
|
|
4793
|
-
const resolvedDeps = resolvedDepsMap[importer] ??= /* @__PURE__ */ new Set();
|
|
4794
|
-
if (resolvedDeps.has(pkg))
|
|
4795
|
-
return "";
|
|
4796
|
-
resolvedDeps.add(pkg);
|
|
4797
|
-
const pkgJsonPath = await findDepPkgJsonPath(pkg, importer);
|
|
4798
|
-
if (!pkgJsonPath)
|
|
4799
|
-
throw new Error(`Package "${pkg}" not found in "${importer}"`);
|
|
4800
|
-
const root = dirname2(pkgJsonPath);
|
|
4801
|
-
const pkgJson = JSON.parse(await fs6.readFile(pkgJsonPath, "utf-8"));
|
|
4802
|
-
const deps = pkgJson.dependencies ?? {};
|
|
4803
|
-
return [
|
|
4804
|
-
`import "/@slidev-monaco-types/load?root=${slash2(root)}&name=${pkgJson.name}"`,
|
|
4805
|
-
...Object.keys(deps).map((dep) => `import "/@slidev-monaco-types/resolve?pkg=${dep}&importer=${slash2(root)}"`)
|
|
4806
|
-
].join("\n");
|
|
4807
|
-
}
|
|
4808
|
-
const matchLoad = id.match(/^\/\@slidev-monaco-types\/load\?root=(.*?)&name=(.*)$/);
|
|
4809
|
-
if (matchLoad) {
|
|
4810
|
-
const [_, root, name] = matchLoad;
|
|
4811
|
-
const files = await fg4(
|
|
4812
|
-
[
|
|
4813
|
-
"**/*.ts",
|
|
4814
|
-
"**/*.mts",
|
|
4815
|
-
"**/*.cts",
|
|
4816
|
-
"package.json"
|
|
4817
|
-
],
|
|
4818
|
-
{
|
|
4819
|
-
cwd: root,
|
|
4820
|
-
followSymbolicLinks: true,
|
|
4821
|
-
ignore: ["**/node_modules/**"]
|
|
4822
|
-
}
|
|
4823
|
-
);
|
|
4824
|
-
if (!files.length)
|
|
4825
|
-
return "";
|
|
4826
|
-
return [
|
|
4827
|
-
'import { addFile } from "@slidev/client/setup/monaco.ts"',
|
|
4828
|
-
...files.map((file) => `addFile(import(${JSON.stringify(`${toAtFS(resolve3(root, file))}?monaco-types&raw`)}), ${JSON.stringify(`node_modules/${name}/${file}`)})`)
|
|
4829
|
-
].join("\n");
|
|
4830
|
-
}
|
|
4831
|
-
}
|
|
4832
|
-
};
|
|
4833
|
-
}
|
|
4834
|
-
|
|
4835
|
-
// node/vite/vue.ts
|
|
4836
|
-
import Vue from "@vitejs/plugin-vue";
|
|
4837
|
-
import VueJsx from "@vitejs/plugin-vue-jsx";
|
|
4838
|
-
var customElements = /* @__PURE__ */ new Set([
|
|
4839
|
-
// katex
|
|
4840
|
-
"annotation",
|
|
4841
|
-
"math",
|
|
4842
|
-
"menclose",
|
|
4843
|
-
"mfrac",
|
|
4844
|
-
"mglyph",
|
|
4845
|
-
"mi",
|
|
4846
|
-
"mlabeledtr",
|
|
4847
|
-
"mn",
|
|
4848
|
-
"mo",
|
|
4849
|
-
"mover",
|
|
4850
|
-
"mpadded",
|
|
4851
|
-
"mphantom",
|
|
4852
|
-
"mroot",
|
|
4853
|
-
"mrow",
|
|
4854
|
-
"mspace",
|
|
4855
|
-
"msqrt",
|
|
4856
|
-
"mstyle",
|
|
4857
|
-
"msub",
|
|
4858
|
-
"msubsup",
|
|
4859
|
-
"msup",
|
|
4860
|
-
"mtable",
|
|
4861
|
-
"mtd",
|
|
4862
|
-
"mtext",
|
|
4863
|
-
"mtr",
|
|
4864
|
-
"munder",
|
|
4865
|
-
"munderover",
|
|
4866
|
-
"semantics"
|
|
4867
|
-
]);
|
|
4868
|
-
async function createVuePlugin(options, pluginOptions) {
|
|
4869
|
-
const {
|
|
4870
|
-
vue: vueOptions = {},
|
|
4871
|
-
vuejsx: vuejsxOptions = {}
|
|
4872
|
-
} = pluginOptions;
|
|
4873
|
-
const VuePlugin = Vue({
|
|
4874
|
-
include: [/\.vue$/, /\.md$/],
|
|
4875
|
-
exclude: [],
|
|
4876
|
-
template: {
|
|
4877
|
-
compilerOptions: {
|
|
4878
|
-
isCustomElement(tag) {
|
|
4879
|
-
return customElements.has(tag);
|
|
4880
|
-
}
|
|
4881
|
-
},
|
|
4882
|
-
...vueOptions?.template
|
|
4883
|
-
},
|
|
4884
|
-
...vueOptions
|
|
4885
|
-
});
|
|
4886
|
-
const VueJsxPlugin = VueJsx(vuejsxOptions);
|
|
4887
|
-
return [
|
|
4888
|
-
VueJsxPlugin,
|
|
4889
|
-
VuePlugin
|
|
4890
|
-
];
|
|
4891
|
-
}
|
|
4892
|
-
|
|
4893
|
-
// node/vite/index.ts
|
|
4894
|
-
async function ViteSlidevPlugin(options, pluginOptions, serverOptions = {}) {
|
|
4895
|
-
const {
|
|
4896
|
-
components: componentsOptions = {},
|
|
4897
|
-
icons: iconsOptions = {},
|
|
4898
|
-
remoteAssets: remoteAssetsOptions = {},
|
|
4899
|
-
serverRef: serverRefOptions = {}
|
|
4900
|
-
} = pluginOptions;
|
|
4901
|
-
const {
|
|
4902
|
-
mode,
|
|
4903
|
-
themeRoots,
|
|
4904
|
-
addonRoots,
|
|
4905
|
-
roots,
|
|
4906
|
-
data: { config }
|
|
4907
|
-
} = options;
|
|
4908
|
-
const drawingData = await loadDrawings(options);
|
|
4909
|
-
const publicRoots = [...themeRoots, ...addonRoots].map((i) => join8(i, "public")).filter(existsSync5);
|
|
4910
|
-
const plugins = [
|
|
4911
|
-
createMarkdownPlugin(options, pluginOptions),
|
|
4912
|
-
createVuePlugin(options, pluginOptions),
|
|
4913
|
-
createSlidesLoader(options, pluginOptions, serverOptions),
|
|
4914
|
-
Components({
|
|
4915
|
-
extensions: ["vue", "md", "js", "ts", "jsx", "tsx"],
|
|
4916
|
-
dirs: [
|
|
4917
|
-
join8(options.clientRoot, "builtin"),
|
|
4918
|
-
...roots.map((i) => join8(i, "components")),
|
|
4919
|
-
"src/components",
|
|
4920
|
-
"components",
|
|
4921
|
-
join8(process.cwd(), "components")
|
|
4922
|
-
],
|
|
4923
|
-
include: [/\.vue$/, /\.vue\?vue/, /\.vue\?v=/, /\.md$/, /\.md\?vue/],
|
|
4924
|
-
exclude: [],
|
|
4925
|
-
resolvers: [
|
|
4926
|
-
IconsResolver({
|
|
4927
|
-
prefix: "",
|
|
4928
|
-
customCollections: Object.keys(iconsOptions.customCollections || [])
|
|
4929
|
-
})
|
|
4930
|
-
],
|
|
4931
|
-
dts: false,
|
|
4932
|
-
...componentsOptions
|
|
4933
|
-
}),
|
|
4934
|
-
Icons({
|
|
4935
|
-
defaultClass: "slidev-icon",
|
|
4936
|
-
collectionsNodeResolvePath: fileURLToPath(import.meta.url),
|
|
4937
|
-
...iconsOptions
|
|
4938
|
-
}),
|
|
4939
|
-
config.remoteAssets === true || config.remoteAssets === mode ? import("vite-plugin-remote-assets").then((r) => r.VitePluginRemoteAssets({
|
|
4940
|
-
rules: [
|
|
4941
|
-
...r.DefaultRules,
|
|
4942
|
-
{
|
|
4943
|
-
match: /\b(https?:\/\/image.unsplash\.com.*?)(?=[`'")\]])/ig,
|
|
4944
|
-
ext: ".png"
|
|
4945
|
-
}
|
|
4946
|
-
],
|
|
4947
|
-
resolveMode: (id) => id.endsWith("index.html") ? "relative" : "@fs",
|
|
4948
|
-
awaitDownload: mode === "build",
|
|
4949
|
-
...remoteAssetsOptions
|
|
4950
|
-
})) : null,
|
|
4951
|
-
ServerRef({
|
|
4952
|
-
debug: false,
|
|
4953
|
-
// process.env.NODE_ENV === 'development',
|
|
4954
|
-
state: {
|
|
4955
|
-
sync: false,
|
|
4956
|
-
nav: {
|
|
4957
|
-
page: 0,
|
|
4958
|
-
clicks: 0
|
|
4959
|
-
},
|
|
4960
|
-
drawings: drawingData,
|
|
4961
|
-
...serverRefOptions.state
|
|
4962
|
-
},
|
|
4963
|
-
onChanged(key, data, patch, timestamp2) {
|
|
4964
|
-
serverRefOptions.onChanged && serverRefOptions.onChanged(key, data, patch, timestamp2);
|
|
4965
|
-
if (!options.data.config.drawings.persist)
|
|
4966
|
-
return;
|
|
4967
|
-
if (key === "drawings")
|
|
4968
|
-
writeDrawings(options, patch ?? data);
|
|
4969
|
-
}
|
|
4970
|
-
}),
|
|
4971
|
-
createConfigPlugin(options),
|
|
4972
|
-
createMonacoTypesLoader(options),
|
|
4973
|
-
createVueCompilerFlagsPlugin(options),
|
|
4974
|
-
publicRoots.length ? import("vite-plugin-static-copy").then((r) => r.viteStaticCopy({
|
|
4975
|
-
silent: true,
|
|
4976
|
-
targets: publicRoots.map((r2) => ({
|
|
4977
|
-
src: `${r2}/*`,
|
|
4978
|
-
dest: "theme"
|
|
4979
|
-
}))
|
|
4980
|
-
})) : null,
|
|
4981
|
-
options.inspect ? import("vite-plugin-inspect").then((r) => (r.default || r)({
|
|
4982
|
-
dev: true,
|
|
4983
|
-
build: true
|
|
4984
|
-
})) : null,
|
|
4985
|
-
config.css === "none" ? null : import("./unocss-AGKZGMYO.mjs").then((r) => r.createUnocssPlugin(options, pluginOptions))
|
|
4986
|
-
];
|
|
4987
|
-
return (await Promise.all(plugins)).flat().filter(notNullish2);
|
|
4988
|
-
}
|
|
4989
|
-
|
|
4990
|
-
export {
|
|
4991
|
-
getIndexHtml,
|
|
4992
|
-
mergeViteConfigs,
|
|
4993
|
-
ViteSlidevPlugin
|
|
4994
|
-
};
|
|
4995
|
-
/*! Bundled license information:
|
|
4996
|
-
|
|
4997
|
-
js-yaml/dist/js-yaml.mjs:
|
|
4998
|
-
(*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT *)
|
|
4999
|
-
*/
|