@slidev/cli 0.27.20 → 0.28.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-LK5RLV7L.js → build-QOWIXXQM.js} +28 -36
- package/dist/{build-OT76Q4KA.mjs → build-RXLELNJK.mjs} +32 -40
- package/dist/{chunk-3LH2GTGU.mjs → chunk-4OPORETI.mjs} +8 -2
- package/dist/{chunk-FN2B33RM.mjs → chunk-GWFBEY26.mjs} +23 -21
- package/dist/{chunk-VN5XPBZO.js → chunk-HF2PX43I.js} +4 -4
- package/dist/{chunk-3ND6GSCF.js → chunk-MFCJMLB5.js} +73 -71
- package/dist/{chunk-2TTM3NLX.mjs → chunk-MSSOXTVZ.mjs} +2 -2
- package/dist/{chunk-RUL3XRPS.js → chunk-QT3EQ43A.js} +9 -3
- package/dist/{chunk-JGWGLMRC.mjs → chunk-S4SUAR5N.mjs} +3241 -193
- package/dist/{chunk-XEDZVJCH.js → chunk-TJBBZIND.js} +3472 -424
- package/dist/cli.js +26 -26
- package/dist/cli.mjs +13 -13
- package/dist/{export-FUMCNU5W.js → export-KTPRCIUI.js} +5 -5
- package/dist/{export-IU4RLVW7.mjs → export-MHGYZJHW.mjs} +2 -2
- package/dist/index.d.ts +68 -4
- package/dist/index.js +9 -11
- package/dist/index.mjs +6 -8
- package/package.json +33 -32
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
__commonJS,
|
|
3
3
|
__dirname,
|
|
4
|
+
__export,
|
|
4
5
|
__require,
|
|
6
|
+
__spreadProps,
|
|
7
|
+
__spreadValues,
|
|
5
8
|
__toModule,
|
|
6
9
|
init_esm_shims,
|
|
7
10
|
resolveImportPath
|
|
8
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-4OPORETI.mjs";
|
|
9
12
|
|
|
10
13
|
// ../../node_modules/.pnpm/semver@7.3.5/node_modules/semver/internal/constants.js
|
|
11
14
|
var require_constants = __commonJS({
|
|
@@ -366,7 +369,7 @@ var require_parse2 = __commonJS({
|
|
|
366
369
|
var { re, t } = require_re();
|
|
367
370
|
var SemVer = require_semver();
|
|
368
371
|
var parseOptions = require_parse_options();
|
|
369
|
-
var
|
|
372
|
+
var parse2 = (version3, options) => {
|
|
370
373
|
options = parseOptions(options);
|
|
371
374
|
if (version3 instanceof SemVer) {
|
|
372
375
|
return version3;
|
|
@@ -387,7 +390,7 @@ var require_parse2 = __commonJS({
|
|
|
387
390
|
return null;
|
|
388
391
|
}
|
|
389
392
|
};
|
|
390
|
-
module.exports =
|
|
393
|
+
module.exports = parse2;
|
|
391
394
|
}
|
|
392
395
|
});
|
|
393
396
|
|
|
@@ -395,9 +398,9 @@ var require_parse2 = __commonJS({
|
|
|
395
398
|
var require_valid = __commonJS({
|
|
396
399
|
"../../node_modules/.pnpm/semver@7.3.5/node_modules/semver/functions/valid.js"(exports, module) {
|
|
397
400
|
init_esm_shims();
|
|
398
|
-
var
|
|
401
|
+
var parse2 = require_parse2();
|
|
399
402
|
var valid = (version3, options) => {
|
|
400
|
-
const v =
|
|
403
|
+
const v = parse2(version3, options);
|
|
401
404
|
return v ? v.version : null;
|
|
402
405
|
};
|
|
403
406
|
module.exports = valid;
|
|
@@ -408,9 +411,9 @@ var require_valid = __commonJS({
|
|
|
408
411
|
var require_clean = __commonJS({
|
|
409
412
|
"../../node_modules/.pnpm/semver@7.3.5/node_modules/semver/functions/clean.js"(exports, module) {
|
|
410
413
|
init_esm_shims();
|
|
411
|
-
var
|
|
414
|
+
var parse2 = require_parse2();
|
|
412
415
|
var clean = (version3, options) => {
|
|
413
|
-
const s =
|
|
416
|
+
const s = parse2(version3.trim().replace(/^[=v]+/, ""), options);
|
|
414
417
|
return s ? s.version : null;
|
|
415
418
|
};
|
|
416
419
|
module.exports = clean;
|
|
@@ -461,14 +464,14 @@ var require_eq = __commonJS({
|
|
|
461
464
|
var require_diff = __commonJS({
|
|
462
465
|
"../../node_modules/.pnpm/semver@7.3.5/node_modules/semver/functions/diff.js"(exports, module) {
|
|
463
466
|
init_esm_shims();
|
|
464
|
-
var
|
|
467
|
+
var parse2 = require_parse2();
|
|
465
468
|
var eq = require_eq();
|
|
466
469
|
var diff = (version1, version22) => {
|
|
467
470
|
if (eq(version1, version22)) {
|
|
468
471
|
return null;
|
|
469
472
|
} else {
|
|
470
|
-
const v1 =
|
|
471
|
-
const v2 =
|
|
473
|
+
const v1 = parse2(version1);
|
|
474
|
+
const v2 = parse2(version22);
|
|
472
475
|
const hasPre = v1.prerelease.length || v2.prerelease.length;
|
|
473
476
|
const prefix = hasPre ? "pre" : "";
|
|
474
477
|
const defaultResult = hasPre ? "prerelease" : "";
|
|
@@ -520,9 +523,9 @@ var require_patch = __commonJS({
|
|
|
520
523
|
var require_prerelease = __commonJS({
|
|
521
524
|
"../../node_modules/.pnpm/semver@7.3.5/node_modules/semver/functions/prerelease.js"(exports, module) {
|
|
522
525
|
init_esm_shims();
|
|
523
|
-
var
|
|
526
|
+
var parse2 = require_parse2();
|
|
524
527
|
var prerelease = (version3, options) => {
|
|
525
|
-
const parsed =
|
|
528
|
+
const parsed = parse2(version3, options);
|
|
526
529
|
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
|
|
527
530
|
};
|
|
528
531
|
module.exports = prerelease;
|
|
@@ -684,7 +687,7 @@ var require_coerce = __commonJS({
|
|
|
684
687
|
"../../node_modules/.pnpm/semver@7.3.5/node_modules/semver/functions/coerce.js"(exports, module) {
|
|
685
688
|
init_esm_shims();
|
|
686
689
|
var SemVer = require_semver();
|
|
687
|
-
var
|
|
690
|
+
var parse2 = require_parse2();
|
|
688
691
|
var { re, t } = require_re();
|
|
689
692
|
var coerce = (version3, options) => {
|
|
690
693
|
if (version3 instanceof SemVer) {
|
|
@@ -712,7 +715,7 @@ var require_coerce = __commonJS({
|
|
|
712
715
|
}
|
|
713
716
|
if (match === null)
|
|
714
717
|
return null;
|
|
715
|
-
return
|
|
718
|
+
return parse2(`${match[2]}.${match[3] || "0"}.${match[4] || "0"}`, options);
|
|
716
719
|
};
|
|
717
720
|
module.exports = coerce;
|
|
718
721
|
}
|
|
@@ -1377,28 +1380,28 @@ var require_range = __commonJS({
|
|
|
1377
1380
|
"../../node_modules/.pnpm/semver@7.3.5/node_modules/semver/classes/range.js"(exports, module) {
|
|
1378
1381
|
init_esm_shims();
|
|
1379
1382
|
var Range = class {
|
|
1380
|
-
constructor(
|
|
1383
|
+
constructor(range2, options) {
|
|
1381
1384
|
options = parseOptions(options);
|
|
1382
|
-
if (
|
|
1383
|
-
if (
|
|
1384
|
-
return
|
|
1385
|
+
if (range2 instanceof Range) {
|
|
1386
|
+
if (range2.loose === !!options.loose && range2.includePrerelease === !!options.includePrerelease) {
|
|
1387
|
+
return range2;
|
|
1385
1388
|
} else {
|
|
1386
|
-
return new Range(
|
|
1389
|
+
return new Range(range2.raw, options);
|
|
1387
1390
|
}
|
|
1388
1391
|
}
|
|
1389
|
-
if (
|
|
1390
|
-
this.raw =
|
|
1391
|
-
this.set = [[
|
|
1392
|
+
if (range2 instanceof Comparator) {
|
|
1393
|
+
this.raw = range2.value;
|
|
1394
|
+
this.set = [[range2]];
|
|
1392
1395
|
this.format();
|
|
1393
1396
|
return this;
|
|
1394
1397
|
}
|
|
1395
1398
|
this.options = options;
|
|
1396
1399
|
this.loose = !!options.loose;
|
|
1397
1400
|
this.includePrerelease = !!options.includePrerelease;
|
|
1398
|
-
this.raw =
|
|
1399
|
-
this.set =
|
|
1401
|
+
this.raw = range2;
|
|
1402
|
+
this.set = range2.split(/\s*\|\|\s*/).map((range3) => this.parseRange(range3.trim())).filter((c) => c.length);
|
|
1400
1403
|
if (!this.set.length) {
|
|
1401
|
-
throw new TypeError(`Invalid SemVer Range: ${
|
|
1404
|
+
throw new TypeError(`Invalid SemVer Range: ${range2}`);
|
|
1402
1405
|
}
|
|
1403
1406
|
if (this.set.length > 1) {
|
|
1404
1407
|
const first = this.set[0];
|
|
@@ -1425,24 +1428,24 @@ var require_range = __commonJS({
|
|
|
1425
1428
|
toString() {
|
|
1426
1429
|
return this.range;
|
|
1427
1430
|
}
|
|
1428
|
-
parseRange(
|
|
1429
|
-
|
|
1431
|
+
parseRange(range2) {
|
|
1432
|
+
range2 = range2.trim();
|
|
1430
1433
|
const memoOpts = Object.keys(this.options).join(",");
|
|
1431
|
-
const memoKey = `parseRange:${memoOpts}:${
|
|
1434
|
+
const memoKey = `parseRange:${memoOpts}:${range2}`;
|
|
1432
1435
|
const cached = cache.get(memoKey);
|
|
1433
1436
|
if (cached)
|
|
1434
1437
|
return cached;
|
|
1435
1438
|
const loose = this.options.loose;
|
|
1436
1439
|
const hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
|
|
1437
|
-
|
|
1438
|
-
debug2("hyphen replace",
|
|
1439
|
-
|
|
1440
|
-
debug2("comparator trim",
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1440
|
+
range2 = range2.replace(hr, hyphenReplace(this.options.includePrerelease));
|
|
1441
|
+
debug2("hyphen replace", range2);
|
|
1442
|
+
range2 = range2.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
|
|
1443
|
+
debug2("comparator trim", range2, re[t.COMPARATORTRIM]);
|
|
1444
|
+
range2 = range2.replace(re[t.TILDETRIM], tildeTrimReplace);
|
|
1445
|
+
range2 = range2.replace(re[t.CARETTRIM], caretTrimReplace);
|
|
1446
|
+
range2 = range2.split(/\s+/).join(" ");
|
|
1444
1447
|
const compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
|
|
1445
|
-
const rangeList =
|
|
1448
|
+
const rangeList = range2.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options)).filter(this.options.loose ? (comp) => !!comp.match(compRe) : () => true).map((comp) => new Comparator(comp, this.options));
|
|
1446
1449
|
const l = rangeList.length;
|
|
1447
1450
|
const rangeMap = /* @__PURE__ */ new Map();
|
|
1448
1451
|
for (const comp of rangeList) {
|
|
@@ -1456,12 +1459,12 @@ var require_range = __commonJS({
|
|
|
1456
1459
|
cache.set(memoKey, result);
|
|
1457
1460
|
return result;
|
|
1458
1461
|
}
|
|
1459
|
-
intersects(
|
|
1460
|
-
if (!(
|
|
1462
|
+
intersects(range2, options) {
|
|
1463
|
+
if (!(range2 instanceof Range)) {
|
|
1461
1464
|
throw new TypeError("a Range is required");
|
|
1462
1465
|
}
|
|
1463
1466
|
return this.set.some((thisComparators) => {
|
|
1464
|
-
return isSatisfiable(thisComparators, options) &&
|
|
1467
|
+
return isSatisfiable(thisComparators, options) && range2.set.some((rangeComparators) => {
|
|
1465
1468
|
return isSatisfiable(rangeComparators, options) && thisComparators.every((thisComparator) => {
|
|
1466
1469
|
return rangeComparators.every((rangeComparator) => {
|
|
1467
1470
|
return thisComparator.intersects(rangeComparator, options);
|
|
@@ -1696,20 +1699,20 @@ var require_range = __commonJS({
|
|
|
1696
1699
|
}
|
|
1697
1700
|
return `${from} ${to}`.trim();
|
|
1698
1701
|
};
|
|
1699
|
-
var testSet = (
|
|
1700
|
-
for (let i = 0; i <
|
|
1701
|
-
if (!
|
|
1702
|
+
var testSet = (set2, version3, options) => {
|
|
1703
|
+
for (let i = 0; i < set2.length; i++) {
|
|
1704
|
+
if (!set2[i].test(version3)) {
|
|
1702
1705
|
return false;
|
|
1703
1706
|
}
|
|
1704
1707
|
}
|
|
1705
1708
|
if (version3.prerelease.length && !options.includePrerelease) {
|
|
1706
|
-
for (let i = 0; i <
|
|
1707
|
-
debug2(
|
|
1708
|
-
if (
|
|
1709
|
+
for (let i = 0; i < set2.length; i++) {
|
|
1710
|
+
debug2(set2[i].semver);
|
|
1711
|
+
if (set2[i].semver === Comparator.ANY) {
|
|
1709
1712
|
continue;
|
|
1710
1713
|
}
|
|
1711
|
-
if (
|
|
1712
|
-
const allowed =
|
|
1714
|
+
if (set2[i].semver.prerelease.length > 0) {
|
|
1715
|
+
const allowed = set2[i].semver;
|
|
1713
1716
|
if (allowed.major === version3.major && allowed.minor === version3.minor && allowed.patch === version3.patch) {
|
|
1714
1717
|
return true;
|
|
1715
1718
|
}
|
|
@@ -1829,13 +1832,13 @@ var require_satisfies = __commonJS({
|
|
|
1829
1832
|
"../../node_modules/.pnpm/semver@7.3.5/node_modules/semver/functions/satisfies.js"(exports, module) {
|
|
1830
1833
|
init_esm_shims();
|
|
1831
1834
|
var Range = require_range();
|
|
1832
|
-
var satisfies2 = (version3,
|
|
1835
|
+
var satisfies2 = (version3, range2, options) => {
|
|
1833
1836
|
try {
|
|
1834
|
-
|
|
1837
|
+
range2 = new Range(range2, options);
|
|
1835
1838
|
} catch (er) {
|
|
1836
1839
|
return false;
|
|
1837
1840
|
}
|
|
1838
|
-
return
|
|
1841
|
+
return range2.test(version3);
|
|
1839
1842
|
};
|
|
1840
1843
|
module.exports = satisfies2;
|
|
1841
1844
|
}
|
|
@@ -1846,7 +1849,7 @@ var require_to_comparators = __commonJS({
|
|
|
1846
1849
|
"../../node_modules/.pnpm/semver@7.3.5/node_modules/semver/ranges/to-comparators.js"(exports, module) {
|
|
1847
1850
|
init_esm_shims();
|
|
1848
1851
|
var Range = require_range();
|
|
1849
|
-
var toComparators = (
|
|
1852
|
+
var toComparators = (range2, options) => new Range(range2, options).set.map((comp) => comp.map((c) => c.value).join(" ").trim().split(" "));
|
|
1850
1853
|
module.exports = toComparators;
|
|
1851
1854
|
}
|
|
1852
1855
|
});
|
|
@@ -1857,12 +1860,12 @@ var require_max_satisfying = __commonJS({
|
|
|
1857
1860
|
init_esm_shims();
|
|
1858
1861
|
var SemVer = require_semver();
|
|
1859
1862
|
var Range = require_range();
|
|
1860
|
-
var maxSatisfying = (versions,
|
|
1863
|
+
var maxSatisfying = (versions, range2, options) => {
|
|
1861
1864
|
let max = null;
|
|
1862
1865
|
let maxSV = null;
|
|
1863
1866
|
let rangeObj = null;
|
|
1864
1867
|
try {
|
|
1865
|
-
rangeObj = new Range(
|
|
1868
|
+
rangeObj = new Range(range2, options);
|
|
1866
1869
|
} catch (er) {
|
|
1867
1870
|
return null;
|
|
1868
1871
|
}
|
|
@@ -1886,12 +1889,12 @@ var require_min_satisfying = __commonJS({
|
|
|
1886
1889
|
init_esm_shims();
|
|
1887
1890
|
var SemVer = require_semver();
|
|
1888
1891
|
var Range = require_range();
|
|
1889
|
-
var minSatisfying = (versions,
|
|
1892
|
+
var minSatisfying = (versions, range2, options) => {
|
|
1890
1893
|
let min = null;
|
|
1891
1894
|
let minSV = null;
|
|
1892
1895
|
let rangeObj = null;
|
|
1893
1896
|
try {
|
|
1894
|
-
rangeObj = new Range(
|
|
1897
|
+
rangeObj = new Range(range2, options);
|
|
1895
1898
|
} catch (er) {
|
|
1896
1899
|
return null;
|
|
1897
1900
|
}
|
|
@@ -1916,19 +1919,19 @@ var require_min_version = __commonJS({
|
|
|
1916
1919
|
var SemVer = require_semver();
|
|
1917
1920
|
var Range = require_range();
|
|
1918
1921
|
var gt = require_gt();
|
|
1919
|
-
var minVersion = (
|
|
1920
|
-
|
|
1922
|
+
var minVersion = (range2, loose) => {
|
|
1923
|
+
range2 = new Range(range2, loose);
|
|
1921
1924
|
let minver = new SemVer("0.0.0");
|
|
1922
|
-
if (
|
|
1925
|
+
if (range2.test(minver)) {
|
|
1923
1926
|
return minver;
|
|
1924
1927
|
}
|
|
1925
1928
|
minver = new SemVer("0.0.0-0");
|
|
1926
|
-
if (
|
|
1929
|
+
if (range2.test(minver)) {
|
|
1927
1930
|
return minver;
|
|
1928
1931
|
}
|
|
1929
1932
|
minver = null;
|
|
1930
|
-
for (let i = 0; i <
|
|
1931
|
-
const comparators =
|
|
1933
|
+
for (let i = 0; i < range2.set.length; ++i) {
|
|
1934
|
+
const comparators = range2.set[i];
|
|
1932
1935
|
let setMin = null;
|
|
1933
1936
|
comparators.forEach((comparator) => {
|
|
1934
1937
|
const compver = new SemVer(comparator.semver.version);
|
|
@@ -1956,7 +1959,7 @@ var require_min_version = __commonJS({
|
|
|
1956
1959
|
if (setMin && (!minver || gt(minver, setMin)))
|
|
1957
1960
|
minver = setMin;
|
|
1958
1961
|
}
|
|
1959
|
-
if (minver &&
|
|
1962
|
+
if (minver && range2.test(minver)) {
|
|
1960
1963
|
return minver;
|
|
1961
1964
|
}
|
|
1962
1965
|
return null;
|
|
@@ -1970,9 +1973,9 @@ var require_valid2 = __commonJS({
|
|
|
1970
1973
|
"../../node_modules/.pnpm/semver@7.3.5/node_modules/semver/ranges/valid.js"(exports, module) {
|
|
1971
1974
|
init_esm_shims();
|
|
1972
1975
|
var Range = require_range();
|
|
1973
|
-
var validRange = (
|
|
1976
|
+
var validRange = (range2, options) => {
|
|
1974
1977
|
try {
|
|
1975
|
-
return new Range(
|
|
1978
|
+
return new Range(range2, options).range || "*";
|
|
1976
1979
|
} catch (er) {
|
|
1977
1980
|
return null;
|
|
1978
1981
|
}
|
|
@@ -1994,9 +1997,9 @@ var require_outside = __commonJS({
|
|
|
1994
1997
|
var lt = require_lt();
|
|
1995
1998
|
var lte = require_lte();
|
|
1996
1999
|
var gte = require_gte();
|
|
1997
|
-
var outside = (version3,
|
|
2000
|
+
var outside = (version3, range2, hilo, options) => {
|
|
1998
2001
|
version3 = new SemVer(version3, options);
|
|
1999
|
-
|
|
2002
|
+
range2 = new Range(range2, options);
|
|
2000
2003
|
let gtfn, ltefn, ltfn, comp, ecomp;
|
|
2001
2004
|
switch (hilo) {
|
|
2002
2005
|
case ">":
|
|
@@ -2016,11 +2019,11 @@ var require_outside = __commonJS({
|
|
|
2016
2019
|
default:
|
|
2017
2020
|
throw new TypeError('Must provide a hilo val of "<" or ">"');
|
|
2018
2021
|
}
|
|
2019
|
-
if (satisfies2(version3,
|
|
2022
|
+
if (satisfies2(version3, range2, options)) {
|
|
2020
2023
|
return false;
|
|
2021
2024
|
}
|
|
2022
|
-
for (let i = 0; i <
|
|
2023
|
-
const comparators =
|
|
2025
|
+
for (let i = 0; i < range2.set.length; ++i) {
|
|
2026
|
+
const comparators = range2.set[i];
|
|
2024
2027
|
let high = null;
|
|
2025
2028
|
let low = null;
|
|
2026
2029
|
comparators.forEach((comparator) => {
|
|
@@ -2055,7 +2058,7 @@ var require_gtr = __commonJS({
|
|
|
2055
2058
|
"../../node_modules/.pnpm/semver@7.3.5/node_modules/semver/ranges/gtr.js"(exports, module) {
|
|
2056
2059
|
init_esm_shims();
|
|
2057
2060
|
var outside = require_outside();
|
|
2058
|
-
var gtr = (version3,
|
|
2061
|
+
var gtr = (version3, range2, options) => outside(version3, range2, ">", options);
|
|
2059
2062
|
module.exports = gtr;
|
|
2060
2063
|
}
|
|
2061
2064
|
});
|
|
@@ -2065,7 +2068,7 @@ var require_ltr = __commonJS({
|
|
|
2065
2068
|
"../../node_modules/.pnpm/semver@7.3.5/node_modules/semver/ranges/ltr.js"(exports, module) {
|
|
2066
2069
|
init_esm_shims();
|
|
2067
2070
|
var outside = require_outside();
|
|
2068
|
-
var ltr = (version3,
|
|
2071
|
+
var ltr = (version3, range2, options) => outside(version3, range2, "<", options);
|
|
2069
2072
|
module.exports = ltr;
|
|
2070
2073
|
}
|
|
2071
2074
|
});
|
|
@@ -2090,29 +2093,29 @@ var require_simplify = __commonJS({
|
|
|
2090
2093
|
init_esm_shims();
|
|
2091
2094
|
var satisfies2 = require_satisfies();
|
|
2092
2095
|
var compare = require_compare();
|
|
2093
|
-
module.exports = (versions,
|
|
2094
|
-
const
|
|
2096
|
+
module.exports = (versions, range2, options) => {
|
|
2097
|
+
const set2 = [];
|
|
2095
2098
|
let min = null;
|
|
2096
2099
|
let prev = null;
|
|
2097
2100
|
const v = versions.sort((a, b) => compare(a, b, options));
|
|
2098
2101
|
for (const version3 of v) {
|
|
2099
|
-
const included = satisfies2(version3,
|
|
2102
|
+
const included = satisfies2(version3, range2, options);
|
|
2100
2103
|
if (included) {
|
|
2101
2104
|
prev = version3;
|
|
2102
2105
|
if (!min)
|
|
2103
2106
|
min = version3;
|
|
2104
2107
|
} else {
|
|
2105
2108
|
if (prev) {
|
|
2106
|
-
|
|
2109
|
+
set2.push([min, prev]);
|
|
2107
2110
|
}
|
|
2108
2111
|
prev = null;
|
|
2109
2112
|
min = null;
|
|
2110
2113
|
}
|
|
2111
2114
|
}
|
|
2112
2115
|
if (min)
|
|
2113
|
-
|
|
2116
|
+
set2.push([min, null]);
|
|
2114
2117
|
const ranges = [];
|
|
2115
|
-
for (const [min2, max] of
|
|
2118
|
+
for (const [min2, max] of set2) {
|
|
2116
2119
|
if (min2 === max)
|
|
2117
2120
|
ranges.push(min2);
|
|
2118
2121
|
else if (!max && min2 === v[0])
|
|
@@ -2125,8 +2128,8 @@ var require_simplify = __commonJS({
|
|
|
2125
2128
|
ranges.push(`${min2} - ${max}`);
|
|
2126
2129
|
}
|
|
2127
2130
|
const simplified = ranges.join(" || ");
|
|
2128
|
-
const original = typeof
|
|
2129
|
-
return simplified.length < original.length ? simplified :
|
|
2131
|
+
const original = typeof range2.raw === "string" ? range2.raw : String(range2);
|
|
2132
|
+
return simplified.length < original.length ? simplified : range2;
|
|
2130
2133
|
};
|
|
2131
2134
|
}
|
|
2132
2135
|
});
|
|
@@ -2324,8 +2327,3052 @@ var require_semver2 = __commonJS({
|
|
|
2324
2327
|
}
|
|
2325
2328
|
});
|
|
2326
2329
|
|
|
2330
|
+
// ../parser/src/fs.ts
|
|
2331
|
+
var fs_exports = {};
|
|
2332
|
+
__export(fs_exports, {
|
|
2333
|
+
detectFeatures: () => detectFeatures,
|
|
2334
|
+
filterDisabled: () => filterDisabled,
|
|
2335
|
+
load: () => load2,
|
|
2336
|
+
mergeFeatureFlags: () => mergeFeatureFlags,
|
|
2337
|
+
parse: () => parse,
|
|
2338
|
+
parseAspectRatio: () => parseAspectRatio,
|
|
2339
|
+
parseRangeString: () => parseRangeString,
|
|
2340
|
+
parseSlide: () => parseSlide,
|
|
2341
|
+
prettify: () => prettify,
|
|
2342
|
+
prettifySlide: () => prettifySlide,
|
|
2343
|
+
resolveConfig: () => resolveConfig,
|
|
2344
|
+
resolveFonts: () => resolveFonts,
|
|
2345
|
+
save: () => save,
|
|
2346
|
+
saveExternalSlide: () => saveExternalSlide,
|
|
2347
|
+
scanMonacoModules: () => scanMonacoModules,
|
|
2348
|
+
stringify: () => stringify,
|
|
2349
|
+
stringifySlide: () => stringifySlide
|
|
2350
|
+
});
|
|
2351
|
+
init_esm_shims();
|
|
2352
|
+
import { promises as fs } from "fs";
|
|
2353
|
+
import { dirname, resolve } from "path";
|
|
2354
|
+
import Markdown from "markdown-it";
|
|
2355
|
+
|
|
2356
|
+
// ../parser/src/core.ts
|
|
2357
|
+
init_esm_shims();
|
|
2358
|
+
|
|
2359
|
+
// ../../node_modules/.pnpm/js-yaml@4.1.0/node_modules/js-yaml/dist/js-yaml.mjs
|
|
2360
|
+
init_esm_shims();
|
|
2361
|
+
function isNothing(subject) {
|
|
2362
|
+
return typeof subject === "undefined" || subject === null;
|
|
2363
|
+
}
|
|
2364
|
+
function isObject(subject) {
|
|
2365
|
+
return typeof subject === "object" && subject !== null;
|
|
2366
|
+
}
|
|
2367
|
+
function toArray(sequence) {
|
|
2368
|
+
if (Array.isArray(sequence))
|
|
2369
|
+
return sequence;
|
|
2370
|
+
else if (isNothing(sequence))
|
|
2371
|
+
return [];
|
|
2372
|
+
return [sequence];
|
|
2373
|
+
}
|
|
2374
|
+
function extend(target, source) {
|
|
2375
|
+
var index, length, key, sourceKeys;
|
|
2376
|
+
if (source) {
|
|
2377
|
+
sourceKeys = Object.keys(source);
|
|
2378
|
+
for (index = 0, length = sourceKeys.length; index < length; index += 1) {
|
|
2379
|
+
key = sourceKeys[index];
|
|
2380
|
+
target[key] = source[key];
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
return target;
|
|
2384
|
+
}
|
|
2385
|
+
function repeat(string, count) {
|
|
2386
|
+
var result = "", cycle;
|
|
2387
|
+
for (cycle = 0; cycle < count; cycle += 1) {
|
|
2388
|
+
result += string;
|
|
2389
|
+
}
|
|
2390
|
+
return result;
|
|
2391
|
+
}
|
|
2392
|
+
function isNegativeZero(number) {
|
|
2393
|
+
return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
|
|
2394
|
+
}
|
|
2395
|
+
var isNothing_1 = isNothing;
|
|
2396
|
+
var isObject_1 = isObject;
|
|
2397
|
+
var toArray_1 = toArray;
|
|
2398
|
+
var repeat_1 = repeat;
|
|
2399
|
+
var isNegativeZero_1 = isNegativeZero;
|
|
2400
|
+
var extend_1 = extend;
|
|
2401
|
+
var common = {
|
|
2402
|
+
isNothing: isNothing_1,
|
|
2403
|
+
isObject: isObject_1,
|
|
2404
|
+
toArray: toArray_1,
|
|
2405
|
+
repeat: repeat_1,
|
|
2406
|
+
isNegativeZero: isNegativeZero_1,
|
|
2407
|
+
extend: extend_1
|
|
2408
|
+
};
|
|
2409
|
+
function formatError(exception2, compact) {
|
|
2410
|
+
var where = "", message = exception2.reason || "(unknown reason)";
|
|
2411
|
+
if (!exception2.mark)
|
|
2412
|
+
return message;
|
|
2413
|
+
if (exception2.mark.name) {
|
|
2414
|
+
where += 'in "' + exception2.mark.name + '" ';
|
|
2415
|
+
}
|
|
2416
|
+
where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")";
|
|
2417
|
+
if (!compact && exception2.mark.snippet) {
|
|
2418
|
+
where += "\n\n" + exception2.mark.snippet;
|
|
2419
|
+
}
|
|
2420
|
+
return message + " " + where;
|
|
2421
|
+
}
|
|
2422
|
+
function YAMLException$1(reason, mark) {
|
|
2423
|
+
Error.call(this);
|
|
2424
|
+
this.name = "YAMLException";
|
|
2425
|
+
this.reason = reason;
|
|
2426
|
+
this.mark = mark;
|
|
2427
|
+
this.message = formatError(this, false);
|
|
2428
|
+
if (Error.captureStackTrace) {
|
|
2429
|
+
Error.captureStackTrace(this, this.constructor);
|
|
2430
|
+
} else {
|
|
2431
|
+
this.stack = new Error().stack || "";
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
2434
|
+
YAMLException$1.prototype = Object.create(Error.prototype);
|
|
2435
|
+
YAMLException$1.prototype.constructor = YAMLException$1;
|
|
2436
|
+
YAMLException$1.prototype.toString = function toString(compact) {
|
|
2437
|
+
return this.name + ": " + formatError(this, compact);
|
|
2438
|
+
};
|
|
2439
|
+
var exception = YAMLException$1;
|
|
2440
|
+
function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
|
|
2441
|
+
var head = "";
|
|
2442
|
+
var tail = "";
|
|
2443
|
+
var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
|
|
2444
|
+
if (position - lineStart > maxHalfLength) {
|
|
2445
|
+
head = " ... ";
|
|
2446
|
+
lineStart = position - maxHalfLength + head.length;
|
|
2447
|
+
}
|
|
2448
|
+
if (lineEnd - position > maxHalfLength) {
|
|
2449
|
+
tail = " ...";
|
|
2450
|
+
lineEnd = position + maxHalfLength - tail.length;
|
|
2451
|
+
}
|
|
2452
|
+
return {
|
|
2453
|
+
str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
|
|
2454
|
+
pos: position - lineStart + head.length
|
|
2455
|
+
};
|
|
2456
|
+
}
|
|
2457
|
+
function padStart(string, max) {
|
|
2458
|
+
return common.repeat(" ", max - string.length) + string;
|
|
2459
|
+
}
|
|
2460
|
+
function makeSnippet(mark, options) {
|
|
2461
|
+
options = Object.create(options || null);
|
|
2462
|
+
if (!mark.buffer)
|
|
2463
|
+
return null;
|
|
2464
|
+
if (!options.maxLength)
|
|
2465
|
+
options.maxLength = 79;
|
|
2466
|
+
if (typeof options.indent !== "number")
|
|
2467
|
+
options.indent = 1;
|
|
2468
|
+
if (typeof options.linesBefore !== "number")
|
|
2469
|
+
options.linesBefore = 3;
|
|
2470
|
+
if (typeof options.linesAfter !== "number")
|
|
2471
|
+
options.linesAfter = 2;
|
|
2472
|
+
var re = /\r?\n|\r|\0/g;
|
|
2473
|
+
var lineStarts = [0];
|
|
2474
|
+
var lineEnds = [];
|
|
2475
|
+
var match;
|
|
2476
|
+
var foundLineNo = -1;
|
|
2477
|
+
while (match = re.exec(mark.buffer)) {
|
|
2478
|
+
lineEnds.push(match.index);
|
|
2479
|
+
lineStarts.push(match.index + match[0].length);
|
|
2480
|
+
if (mark.position <= match.index && foundLineNo < 0) {
|
|
2481
|
+
foundLineNo = lineStarts.length - 2;
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
if (foundLineNo < 0)
|
|
2485
|
+
foundLineNo = lineStarts.length - 1;
|
|
2486
|
+
var result = "", i, line;
|
|
2487
|
+
var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
|
|
2488
|
+
var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
|
|
2489
|
+
for (i = 1; i <= options.linesBefore; i++) {
|
|
2490
|
+
if (foundLineNo - i < 0)
|
|
2491
|
+
break;
|
|
2492
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo - i], lineEnds[foundLineNo - i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]), maxLineLength);
|
|
2493
|
+
result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
|
|
2494
|
+
}
|
|
2495
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
|
|
2496
|
+
result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
|
|
2497
|
+
result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
|
|
2498
|
+
for (i = 1; i <= options.linesAfter; i++) {
|
|
2499
|
+
if (foundLineNo + i >= lineEnds.length)
|
|
2500
|
+
break;
|
|
2501
|
+
line = getLine(mark.buffer, lineStarts[foundLineNo + i], lineEnds[foundLineNo + i], mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]), maxLineLength);
|
|
2502
|
+
result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n";
|
|
2503
|
+
}
|
|
2504
|
+
return result.replace(/\n$/, "");
|
|
2505
|
+
}
|
|
2506
|
+
var snippet = makeSnippet;
|
|
2507
|
+
var TYPE_CONSTRUCTOR_OPTIONS = [
|
|
2508
|
+
"kind",
|
|
2509
|
+
"multi",
|
|
2510
|
+
"resolve",
|
|
2511
|
+
"construct",
|
|
2512
|
+
"instanceOf",
|
|
2513
|
+
"predicate",
|
|
2514
|
+
"represent",
|
|
2515
|
+
"representName",
|
|
2516
|
+
"defaultStyle",
|
|
2517
|
+
"styleAliases"
|
|
2518
|
+
];
|
|
2519
|
+
var YAML_NODE_KINDS = [
|
|
2520
|
+
"scalar",
|
|
2521
|
+
"sequence",
|
|
2522
|
+
"mapping"
|
|
2523
|
+
];
|
|
2524
|
+
function compileStyleAliases(map2) {
|
|
2525
|
+
var result = {};
|
|
2526
|
+
if (map2 !== null) {
|
|
2527
|
+
Object.keys(map2).forEach(function(style) {
|
|
2528
|
+
map2[style].forEach(function(alias) {
|
|
2529
|
+
result[String(alias)] = style;
|
|
2530
|
+
});
|
|
2531
|
+
});
|
|
2532
|
+
}
|
|
2533
|
+
return result;
|
|
2534
|
+
}
|
|
2535
|
+
function Type$1(tag, options) {
|
|
2536
|
+
options = options || {};
|
|
2537
|
+
Object.keys(options).forEach(function(name) {
|
|
2538
|
+
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
|
|
2539
|
+
throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
|
|
2540
|
+
}
|
|
2541
|
+
});
|
|
2542
|
+
this.options = options;
|
|
2543
|
+
this.tag = tag;
|
|
2544
|
+
this.kind = options["kind"] || null;
|
|
2545
|
+
this.resolve = options["resolve"] || function() {
|
|
2546
|
+
return true;
|
|
2547
|
+
};
|
|
2548
|
+
this.construct = options["construct"] || function(data) {
|
|
2549
|
+
return data;
|
|
2550
|
+
};
|
|
2551
|
+
this.instanceOf = options["instanceOf"] || null;
|
|
2552
|
+
this.predicate = options["predicate"] || null;
|
|
2553
|
+
this.represent = options["represent"] || null;
|
|
2554
|
+
this.representName = options["representName"] || null;
|
|
2555
|
+
this.defaultStyle = options["defaultStyle"] || null;
|
|
2556
|
+
this.multi = options["multi"] || false;
|
|
2557
|
+
this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
|
|
2558
|
+
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
|
2559
|
+
throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
var type = Type$1;
|
|
2563
|
+
function compileList(schema2, name) {
|
|
2564
|
+
var result = [];
|
|
2565
|
+
schema2[name].forEach(function(currentType) {
|
|
2566
|
+
var newIndex = result.length;
|
|
2567
|
+
result.forEach(function(previousType, previousIndex) {
|
|
2568
|
+
if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
|
|
2569
|
+
newIndex = previousIndex;
|
|
2570
|
+
}
|
|
2571
|
+
});
|
|
2572
|
+
result[newIndex] = currentType;
|
|
2573
|
+
});
|
|
2574
|
+
return result;
|
|
2575
|
+
}
|
|
2576
|
+
function compileMap() {
|
|
2577
|
+
var result = {
|
|
2578
|
+
scalar: {},
|
|
2579
|
+
sequence: {},
|
|
2580
|
+
mapping: {},
|
|
2581
|
+
fallback: {},
|
|
2582
|
+
multi: {
|
|
2583
|
+
scalar: [],
|
|
2584
|
+
sequence: [],
|
|
2585
|
+
mapping: [],
|
|
2586
|
+
fallback: []
|
|
2587
|
+
}
|
|
2588
|
+
}, index, length;
|
|
2589
|
+
function collectType(type2) {
|
|
2590
|
+
if (type2.multi) {
|
|
2591
|
+
result.multi[type2.kind].push(type2);
|
|
2592
|
+
result.multi["fallback"].push(type2);
|
|
2593
|
+
} else {
|
|
2594
|
+
result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
|
|
2595
|
+
}
|
|
2596
|
+
}
|
|
2597
|
+
for (index = 0, length = arguments.length; index < length; index += 1) {
|
|
2598
|
+
arguments[index].forEach(collectType);
|
|
2599
|
+
}
|
|
2600
|
+
return result;
|
|
2601
|
+
}
|
|
2602
|
+
function Schema$1(definition) {
|
|
2603
|
+
return this.extend(definition);
|
|
2604
|
+
}
|
|
2605
|
+
Schema$1.prototype.extend = function extend2(definition) {
|
|
2606
|
+
var implicit = [];
|
|
2607
|
+
var explicit = [];
|
|
2608
|
+
if (definition instanceof type) {
|
|
2609
|
+
explicit.push(definition);
|
|
2610
|
+
} else if (Array.isArray(definition)) {
|
|
2611
|
+
explicit = explicit.concat(definition);
|
|
2612
|
+
} else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
|
|
2613
|
+
if (definition.implicit)
|
|
2614
|
+
implicit = implicit.concat(definition.implicit);
|
|
2615
|
+
if (definition.explicit)
|
|
2616
|
+
explicit = explicit.concat(definition.explicit);
|
|
2617
|
+
} else {
|
|
2618
|
+
throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
|
|
2619
|
+
}
|
|
2620
|
+
implicit.forEach(function(type$1) {
|
|
2621
|
+
if (!(type$1 instanceof type)) {
|
|
2622
|
+
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
2623
|
+
}
|
|
2624
|
+
if (type$1.loadKind && type$1.loadKind !== "scalar") {
|
|
2625
|
+
throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
|
|
2626
|
+
}
|
|
2627
|
+
if (type$1.multi) {
|
|
2628
|
+
throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
|
|
2629
|
+
}
|
|
2630
|
+
});
|
|
2631
|
+
explicit.forEach(function(type$1) {
|
|
2632
|
+
if (!(type$1 instanceof type)) {
|
|
2633
|
+
throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
|
|
2634
|
+
}
|
|
2635
|
+
});
|
|
2636
|
+
var result = Object.create(Schema$1.prototype);
|
|
2637
|
+
result.implicit = (this.implicit || []).concat(implicit);
|
|
2638
|
+
result.explicit = (this.explicit || []).concat(explicit);
|
|
2639
|
+
result.compiledImplicit = compileList(result, "implicit");
|
|
2640
|
+
result.compiledExplicit = compileList(result, "explicit");
|
|
2641
|
+
result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
|
|
2642
|
+
return result;
|
|
2643
|
+
};
|
|
2644
|
+
var schema = Schema$1;
|
|
2645
|
+
var str = new type("tag:yaml.org,2002:str", {
|
|
2646
|
+
kind: "scalar",
|
|
2647
|
+
construct: function(data) {
|
|
2648
|
+
return data !== null ? data : "";
|
|
2649
|
+
}
|
|
2650
|
+
});
|
|
2651
|
+
var seq = new type("tag:yaml.org,2002:seq", {
|
|
2652
|
+
kind: "sequence",
|
|
2653
|
+
construct: function(data) {
|
|
2654
|
+
return data !== null ? data : [];
|
|
2655
|
+
}
|
|
2656
|
+
});
|
|
2657
|
+
var map = new type("tag:yaml.org,2002:map", {
|
|
2658
|
+
kind: "mapping",
|
|
2659
|
+
construct: function(data) {
|
|
2660
|
+
return data !== null ? data : {};
|
|
2661
|
+
}
|
|
2662
|
+
});
|
|
2663
|
+
var failsafe = new schema({
|
|
2664
|
+
explicit: [
|
|
2665
|
+
str,
|
|
2666
|
+
seq,
|
|
2667
|
+
map
|
|
2668
|
+
]
|
|
2669
|
+
});
|
|
2670
|
+
function resolveYamlNull(data) {
|
|
2671
|
+
if (data === null)
|
|
2672
|
+
return true;
|
|
2673
|
+
var max = data.length;
|
|
2674
|
+
return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
|
|
2675
|
+
}
|
|
2676
|
+
function constructYamlNull() {
|
|
2677
|
+
return null;
|
|
2678
|
+
}
|
|
2679
|
+
function isNull(object) {
|
|
2680
|
+
return object === null;
|
|
2681
|
+
}
|
|
2682
|
+
var _null = new type("tag:yaml.org,2002:null", {
|
|
2683
|
+
kind: "scalar",
|
|
2684
|
+
resolve: resolveYamlNull,
|
|
2685
|
+
construct: constructYamlNull,
|
|
2686
|
+
predicate: isNull,
|
|
2687
|
+
represent: {
|
|
2688
|
+
canonical: function() {
|
|
2689
|
+
return "~";
|
|
2690
|
+
},
|
|
2691
|
+
lowercase: function() {
|
|
2692
|
+
return "null";
|
|
2693
|
+
},
|
|
2694
|
+
uppercase: function() {
|
|
2695
|
+
return "NULL";
|
|
2696
|
+
},
|
|
2697
|
+
camelcase: function() {
|
|
2698
|
+
return "Null";
|
|
2699
|
+
},
|
|
2700
|
+
empty: function() {
|
|
2701
|
+
return "";
|
|
2702
|
+
}
|
|
2703
|
+
},
|
|
2704
|
+
defaultStyle: "lowercase"
|
|
2705
|
+
});
|
|
2706
|
+
function resolveYamlBoolean(data) {
|
|
2707
|
+
if (data === null)
|
|
2708
|
+
return false;
|
|
2709
|
+
var max = data.length;
|
|
2710
|
+
return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
|
|
2711
|
+
}
|
|
2712
|
+
function constructYamlBoolean(data) {
|
|
2713
|
+
return data === "true" || data === "True" || data === "TRUE";
|
|
2714
|
+
}
|
|
2715
|
+
function isBoolean(object) {
|
|
2716
|
+
return Object.prototype.toString.call(object) === "[object Boolean]";
|
|
2717
|
+
}
|
|
2718
|
+
var bool = new type("tag:yaml.org,2002:bool", {
|
|
2719
|
+
kind: "scalar",
|
|
2720
|
+
resolve: resolveYamlBoolean,
|
|
2721
|
+
construct: constructYamlBoolean,
|
|
2722
|
+
predicate: isBoolean,
|
|
2723
|
+
represent: {
|
|
2724
|
+
lowercase: function(object) {
|
|
2725
|
+
return object ? "true" : "false";
|
|
2726
|
+
},
|
|
2727
|
+
uppercase: function(object) {
|
|
2728
|
+
return object ? "TRUE" : "FALSE";
|
|
2729
|
+
},
|
|
2730
|
+
camelcase: function(object) {
|
|
2731
|
+
return object ? "True" : "False";
|
|
2732
|
+
}
|
|
2733
|
+
},
|
|
2734
|
+
defaultStyle: "lowercase"
|
|
2735
|
+
});
|
|
2736
|
+
function isHexCode(c) {
|
|
2737
|
+
return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
|
|
2738
|
+
}
|
|
2739
|
+
function isOctCode(c) {
|
|
2740
|
+
return 48 <= c && c <= 55;
|
|
2741
|
+
}
|
|
2742
|
+
function isDecCode(c) {
|
|
2743
|
+
return 48 <= c && c <= 57;
|
|
2744
|
+
}
|
|
2745
|
+
function resolveYamlInteger(data) {
|
|
2746
|
+
if (data === null)
|
|
2747
|
+
return false;
|
|
2748
|
+
var max = data.length, index = 0, hasDigits = false, ch;
|
|
2749
|
+
if (!max)
|
|
2750
|
+
return false;
|
|
2751
|
+
ch = data[index];
|
|
2752
|
+
if (ch === "-" || ch === "+") {
|
|
2753
|
+
ch = data[++index];
|
|
2754
|
+
}
|
|
2755
|
+
if (ch === "0") {
|
|
2756
|
+
if (index + 1 === max)
|
|
2757
|
+
return true;
|
|
2758
|
+
ch = data[++index];
|
|
2759
|
+
if (ch === "b") {
|
|
2760
|
+
index++;
|
|
2761
|
+
for (; index < max; index++) {
|
|
2762
|
+
ch = data[index];
|
|
2763
|
+
if (ch === "_")
|
|
2764
|
+
continue;
|
|
2765
|
+
if (ch !== "0" && ch !== "1")
|
|
2766
|
+
return false;
|
|
2767
|
+
hasDigits = true;
|
|
2768
|
+
}
|
|
2769
|
+
return hasDigits && ch !== "_";
|
|
2770
|
+
}
|
|
2771
|
+
if (ch === "x") {
|
|
2772
|
+
index++;
|
|
2773
|
+
for (; index < max; index++) {
|
|
2774
|
+
ch = data[index];
|
|
2775
|
+
if (ch === "_")
|
|
2776
|
+
continue;
|
|
2777
|
+
if (!isHexCode(data.charCodeAt(index)))
|
|
2778
|
+
return false;
|
|
2779
|
+
hasDigits = true;
|
|
2780
|
+
}
|
|
2781
|
+
return hasDigits && ch !== "_";
|
|
2782
|
+
}
|
|
2783
|
+
if (ch === "o") {
|
|
2784
|
+
index++;
|
|
2785
|
+
for (; index < max; index++) {
|
|
2786
|
+
ch = data[index];
|
|
2787
|
+
if (ch === "_")
|
|
2788
|
+
continue;
|
|
2789
|
+
if (!isOctCode(data.charCodeAt(index)))
|
|
2790
|
+
return false;
|
|
2791
|
+
hasDigits = true;
|
|
2792
|
+
}
|
|
2793
|
+
return hasDigits && ch !== "_";
|
|
2794
|
+
}
|
|
2795
|
+
}
|
|
2796
|
+
if (ch === "_")
|
|
2797
|
+
return false;
|
|
2798
|
+
for (; index < max; index++) {
|
|
2799
|
+
ch = data[index];
|
|
2800
|
+
if (ch === "_")
|
|
2801
|
+
continue;
|
|
2802
|
+
if (!isDecCode(data.charCodeAt(index))) {
|
|
2803
|
+
return false;
|
|
2804
|
+
}
|
|
2805
|
+
hasDigits = true;
|
|
2806
|
+
}
|
|
2807
|
+
if (!hasDigits || ch === "_")
|
|
2808
|
+
return false;
|
|
2809
|
+
return true;
|
|
2810
|
+
}
|
|
2811
|
+
function constructYamlInteger(data) {
|
|
2812
|
+
var value = data, sign = 1, ch;
|
|
2813
|
+
if (value.indexOf("_") !== -1) {
|
|
2814
|
+
value = value.replace(/_/g, "");
|
|
2815
|
+
}
|
|
2816
|
+
ch = value[0];
|
|
2817
|
+
if (ch === "-" || ch === "+") {
|
|
2818
|
+
if (ch === "-")
|
|
2819
|
+
sign = -1;
|
|
2820
|
+
value = value.slice(1);
|
|
2821
|
+
ch = value[0];
|
|
2822
|
+
}
|
|
2823
|
+
if (value === "0")
|
|
2824
|
+
return 0;
|
|
2825
|
+
if (ch === "0") {
|
|
2826
|
+
if (value[1] === "b")
|
|
2827
|
+
return sign * parseInt(value.slice(2), 2);
|
|
2828
|
+
if (value[1] === "x")
|
|
2829
|
+
return sign * parseInt(value.slice(2), 16);
|
|
2830
|
+
if (value[1] === "o")
|
|
2831
|
+
return sign * parseInt(value.slice(2), 8);
|
|
2832
|
+
}
|
|
2833
|
+
return sign * parseInt(value, 10);
|
|
2834
|
+
}
|
|
2835
|
+
function isInteger(object) {
|
|
2836
|
+
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
|
|
2837
|
+
}
|
|
2838
|
+
var int = new type("tag:yaml.org,2002:int", {
|
|
2839
|
+
kind: "scalar",
|
|
2840
|
+
resolve: resolveYamlInteger,
|
|
2841
|
+
construct: constructYamlInteger,
|
|
2842
|
+
predicate: isInteger,
|
|
2843
|
+
represent: {
|
|
2844
|
+
binary: function(obj) {
|
|
2845
|
+
return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
|
|
2846
|
+
},
|
|
2847
|
+
octal: function(obj) {
|
|
2848
|
+
return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
|
|
2849
|
+
},
|
|
2850
|
+
decimal: function(obj) {
|
|
2851
|
+
return obj.toString(10);
|
|
2852
|
+
},
|
|
2853
|
+
hexadecimal: function(obj) {
|
|
2854
|
+
return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
|
|
2855
|
+
}
|
|
2856
|
+
},
|
|
2857
|
+
defaultStyle: "decimal",
|
|
2858
|
+
styleAliases: {
|
|
2859
|
+
binary: [2, "bin"],
|
|
2860
|
+
octal: [8, "oct"],
|
|
2861
|
+
decimal: [10, "dec"],
|
|
2862
|
+
hexadecimal: [16, "hex"]
|
|
2863
|
+
}
|
|
2864
|
+
});
|
|
2865
|
+
var YAML_FLOAT_PATTERN = new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");
|
|
2866
|
+
function resolveYamlFloat(data) {
|
|
2867
|
+
if (data === null)
|
|
2868
|
+
return false;
|
|
2869
|
+
if (!YAML_FLOAT_PATTERN.test(data) || data[data.length - 1] === "_") {
|
|
2870
|
+
return false;
|
|
2871
|
+
}
|
|
2872
|
+
return true;
|
|
2873
|
+
}
|
|
2874
|
+
function constructYamlFloat(data) {
|
|
2875
|
+
var value, sign;
|
|
2876
|
+
value = data.replace(/_/g, "").toLowerCase();
|
|
2877
|
+
sign = value[0] === "-" ? -1 : 1;
|
|
2878
|
+
if ("+-".indexOf(value[0]) >= 0) {
|
|
2879
|
+
value = value.slice(1);
|
|
2880
|
+
}
|
|
2881
|
+
if (value === ".inf") {
|
|
2882
|
+
return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
|
|
2883
|
+
} else if (value === ".nan") {
|
|
2884
|
+
return NaN;
|
|
2885
|
+
}
|
|
2886
|
+
return sign * parseFloat(value, 10);
|
|
2887
|
+
}
|
|
2888
|
+
var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
|
|
2889
|
+
function representYamlFloat(object, style) {
|
|
2890
|
+
var res;
|
|
2891
|
+
if (isNaN(object)) {
|
|
2892
|
+
switch (style) {
|
|
2893
|
+
case "lowercase":
|
|
2894
|
+
return ".nan";
|
|
2895
|
+
case "uppercase":
|
|
2896
|
+
return ".NAN";
|
|
2897
|
+
case "camelcase":
|
|
2898
|
+
return ".NaN";
|
|
2899
|
+
}
|
|
2900
|
+
} else if (Number.POSITIVE_INFINITY === object) {
|
|
2901
|
+
switch (style) {
|
|
2902
|
+
case "lowercase":
|
|
2903
|
+
return ".inf";
|
|
2904
|
+
case "uppercase":
|
|
2905
|
+
return ".INF";
|
|
2906
|
+
case "camelcase":
|
|
2907
|
+
return ".Inf";
|
|
2908
|
+
}
|
|
2909
|
+
} else if (Number.NEGATIVE_INFINITY === object) {
|
|
2910
|
+
switch (style) {
|
|
2911
|
+
case "lowercase":
|
|
2912
|
+
return "-.inf";
|
|
2913
|
+
case "uppercase":
|
|
2914
|
+
return "-.INF";
|
|
2915
|
+
case "camelcase":
|
|
2916
|
+
return "-.Inf";
|
|
2917
|
+
}
|
|
2918
|
+
} else if (common.isNegativeZero(object)) {
|
|
2919
|
+
return "-0.0";
|
|
2920
|
+
}
|
|
2921
|
+
res = object.toString(10);
|
|
2922
|
+
return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
|
|
2923
|
+
}
|
|
2924
|
+
function isFloat(object) {
|
|
2925
|
+
return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
|
|
2926
|
+
}
|
|
2927
|
+
var float = new type("tag:yaml.org,2002:float", {
|
|
2928
|
+
kind: "scalar",
|
|
2929
|
+
resolve: resolveYamlFloat,
|
|
2930
|
+
construct: constructYamlFloat,
|
|
2931
|
+
predicate: isFloat,
|
|
2932
|
+
represent: representYamlFloat,
|
|
2933
|
+
defaultStyle: "lowercase"
|
|
2934
|
+
});
|
|
2935
|
+
var json = failsafe.extend({
|
|
2936
|
+
implicit: [
|
|
2937
|
+
_null,
|
|
2938
|
+
bool,
|
|
2939
|
+
int,
|
|
2940
|
+
float
|
|
2941
|
+
]
|
|
2942
|
+
});
|
|
2943
|
+
var core = json;
|
|
2944
|
+
var YAML_DATE_REGEXP = new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$");
|
|
2945
|
+
var YAML_TIMESTAMP_REGEXP = new RegExp("^([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]))?))?$");
|
|
2946
|
+
function resolveYamlTimestamp(data) {
|
|
2947
|
+
if (data === null)
|
|
2948
|
+
return false;
|
|
2949
|
+
if (YAML_DATE_REGEXP.exec(data) !== null)
|
|
2950
|
+
return true;
|
|
2951
|
+
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null)
|
|
2952
|
+
return true;
|
|
2953
|
+
return false;
|
|
2954
|
+
}
|
|
2955
|
+
function constructYamlTimestamp(data) {
|
|
2956
|
+
var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
|
|
2957
|
+
match = YAML_DATE_REGEXP.exec(data);
|
|
2958
|
+
if (match === null)
|
|
2959
|
+
match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
2960
|
+
if (match === null)
|
|
2961
|
+
throw new Error("Date resolve error");
|
|
2962
|
+
year = +match[1];
|
|
2963
|
+
month = +match[2] - 1;
|
|
2964
|
+
day = +match[3];
|
|
2965
|
+
if (!match[4]) {
|
|
2966
|
+
return new Date(Date.UTC(year, month, day));
|
|
2967
|
+
}
|
|
2968
|
+
hour = +match[4];
|
|
2969
|
+
minute = +match[5];
|
|
2970
|
+
second = +match[6];
|
|
2971
|
+
if (match[7]) {
|
|
2972
|
+
fraction = match[7].slice(0, 3);
|
|
2973
|
+
while (fraction.length < 3) {
|
|
2974
|
+
fraction += "0";
|
|
2975
|
+
}
|
|
2976
|
+
fraction = +fraction;
|
|
2977
|
+
}
|
|
2978
|
+
if (match[9]) {
|
|
2979
|
+
tz_hour = +match[10];
|
|
2980
|
+
tz_minute = +(match[11] || 0);
|
|
2981
|
+
delta = (tz_hour * 60 + tz_minute) * 6e4;
|
|
2982
|
+
if (match[9] === "-")
|
|
2983
|
+
delta = -delta;
|
|
2984
|
+
}
|
|
2985
|
+
date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
|
|
2986
|
+
if (delta)
|
|
2987
|
+
date.setTime(date.getTime() - delta);
|
|
2988
|
+
return date;
|
|
2989
|
+
}
|
|
2990
|
+
function representYamlTimestamp(object) {
|
|
2991
|
+
return object.toISOString();
|
|
2992
|
+
}
|
|
2993
|
+
var timestamp = new type("tag:yaml.org,2002:timestamp", {
|
|
2994
|
+
kind: "scalar",
|
|
2995
|
+
resolve: resolveYamlTimestamp,
|
|
2996
|
+
construct: constructYamlTimestamp,
|
|
2997
|
+
instanceOf: Date,
|
|
2998
|
+
represent: representYamlTimestamp
|
|
2999
|
+
});
|
|
3000
|
+
function resolveYamlMerge(data) {
|
|
3001
|
+
return data === "<<" || data === null;
|
|
3002
|
+
}
|
|
3003
|
+
var merge = new type("tag:yaml.org,2002:merge", {
|
|
3004
|
+
kind: "scalar",
|
|
3005
|
+
resolve: resolveYamlMerge
|
|
3006
|
+
});
|
|
3007
|
+
var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
|
|
3008
|
+
function resolveYamlBinary(data) {
|
|
3009
|
+
if (data === null)
|
|
3010
|
+
return false;
|
|
3011
|
+
var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
|
|
3012
|
+
for (idx = 0; idx < max; idx++) {
|
|
3013
|
+
code = map2.indexOf(data.charAt(idx));
|
|
3014
|
+
if (code > 64)
|
|
3015
|
+
continue;
|
|
3016
|
+
if (code < 0)
|
|
3017
|
+
return false;
|
|
3018
|
+
bitlen += 6;
|
|
3019
|
+
}
|
|
3020
|
+
return bitlen % 8 === 0;
|
|
3021
|
+
}
|
|
3022
|
+
function constructYamlBinary(data) {
|
|
3023
|
+
var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = [];
|
|
3024
|
+
for (idx = 0; idx < max; idx++) {
|
|
3025
|
+
if (idx % 4 === 0 && idx) {
|
|
3026
|
+
result.push(bits >> 16 & 255);
|
|
3027
|
+
result.push(bits >> 8 & 255);
|
|
3028
|
+
result.push(bits & 255);
|
|
3029
|
+
}
|
|
3030
|
+
bits = bits << 6 | map2.indexOf(input.charAt(idx));
|
|
3031
|
+
}
|
|
3032
|
+
tailbits = max % 4 * 6;
|
|
3033
|
+
if (tailbits === 0) {
|
|
3034
|
+
result.push(bits >> 16 & 255);
|
|
3035
|
+
result.push(bits >> 8 & 255);
|
|
3036
|
+
result.push(bits & 255);
|
|
3037
|
+
} else if (tailbits === 18) {
|
|
3038
|
+
result.push(bits >> 10 & 255);
|
|
3039
|
+
result.push(bits >> 2 & 255);
|
|
3040
|
+
} else if (tailbits === 12) {
|
|
3041
|
+
result.push(bits >> 4 & 255);
|
|
3042
|
+
}
|
|
3043
|
+
return new Uint8Array(result);
|
|
3044
|
+
}
|
|
3045
|
+
function representYamlBinary(object) {
|
|
3046
|
+
var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP;
|
|
3047
|
+
for (idx = 0; idx < max; idx++) {
|
|
3048
|
+
if (idx % 3 === 0 && idx) {
|
|
3049
|
+
result += map2[bits >> 18 & 63];
|
|
3050
|
+
result += map2[bits >> 12 & 63];
|
|
3051
|
+
result += map2[bits >> 6 & 63];
|
|
3052
|
+
result += map2[bits & 63];
|
|
3053
|
+
}
|
|
3054
|
+
bits = (bits << 8) + object[idx];
|
|
3055
|
+
}
|
|
3056
|
+
tail = max % 3;
|
|
3057
|
+
if (tail === 0) {
|
|
3058
|
+
result += map2[bits >> 18 & 63];
|
|
3059
|
+
result += map2[bits >> 12 & 63];
|
|
3060
|
+
result += map2[bits >> 6 & 63];
|
|
3061
|
+
result += map2[bits & 63];
|
|
3062
|
+
} else if (tail === 2) {
|
|
3063
|
+
result += map2[bits >> 10 & 63];
|
|
3064
|
+
result += map2[bits >> 4 & 63];
|
|
3065
|
+
result += map2[bits << 2 & 63];
|
|
3066
|
+
result += map2[64];
|
|
3067
|
+
} else if (tail === 1) {
|
|
3068
|
+
result += map2[bits >> 2 & 63];
|
|
3069
|
+
result += map2[bits << 4 & 63];
|
|
3070
|
+
result += map2[64];
|
|
3071
|
+
result += map2[64];
|
|
3072
|
+
}
|
|
3073
|
+
return result;
|
|
3074
|
+
}
|
|
3075
|
+
function isBinary(obj) {
|
|
3076
|
+
return Object.prototype.toString.call(obj) === "[object Uint8Array]";
|
|
3077
|
+
}
|
|
3078
|
+
var binary = new type("tag:yaml.org,2002:binary", {
|
|
3079
|
+
kind: "scalar",
|
|
3080
|
+
resolve: resolveYamlBinary,
|
|
3081
|
+
construct: constructYamlBinary,
|
|
3082
|
+
predicate: isBinary,
|
|
3083
|
+
represent: representYamlBinary
|
|
3084
|
+
});
|
|
3085
|
+
var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
|
|
3086
|
+
var _toString$2 = Object.prototype.toString;
|
|
3087
|
+
function resolveYamlOmap(data) {
|
|
3088
|
+
if (data === null)
|
|
3089
|
+
return true;
|
|
3090
|
+
var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
|
|
3091
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
3092
|
+
pair = object[index];
|
|
3093
|
+
pairHasKey = false;
|
|
3094
|
+
if (_toString$2.call(pair) !== "[object Object]")
|
|
3095
|
+
return false;
|
|
3096
|
+
for (pairKey in pair) {
|
|
3097
|
+
if (_hasOwnProperty$3.call(pair, pairKey)) {
|
|
3098
|
+
if (!pairHasKey)
|
|
3099
|
+
pairHasKey = true;
|
|
3100
|
+
else
|
|
3101
|
+
return false;
|
|
3102
|
+
}
|
|
3103
|
+
}
|
|
3104
|
+
if (!pairHasKey)
|
|
3105
|
+
return false;
|
|
3106
|
+
if (objectKeys.indexOf(pairKey) === -1)
|
|
3107
|
+
objectKeys.push(pairKey);
|
|
3108
|
+
else
|
|
3109
|
+
return false;
|
|
3110
|
+
}
|
|
3111
|
+
return true;
|
|
3112
|
+
}
|
|
3113
|
+
function constructYamlOmap(data) {
|
|
3114
|
+
return data !== null ? data : [];
|
|
3115
|
+
}
|
|
3116
|
+
var omap = new type("tag:yaml.org,2002:omap", {
|
|
3117
|
+
kind: "sequence",
|
|
3118
|
+
resolve: resolveYamlOmap,
|
|
3119
|
+
construct: constructYamlOmap
|
|
3120
|
+
});
|
|
3121
|
+
var _toString$1 = Object.prototype.toString;
|
|
3122
|
+
function resolveYamlPairs(data) {
|
|
3123
|
+
if (data === null)
|
|
3124
|
+
return true;
|
|
3125
|
+
var index, length, pair, keys, result, object = data;
|
|
3126
|
+
result = new Array(object.length);
|
|
3127
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
3128
|
+
pair = object[index];
|
|
3129
|
+
if (_toString$1.call(pair) !== "[object Object]")
|
|
3130
|
+
return false;
|
|
3131
|
+
keys = Object.keys(pair);
|
|
3132
|
+
if (keys.length !== 1)
|
|
3133
|
+
return false;
|
|
3134
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
3135
|
+
}
|
|
3136
|
+
return true;
|
|
3137
|
+
}
|
|
3138
|
+
function constructYamlPairs(data) {
|
|
3139
|
+
if (data === null)
|
|
3140
|
+
return [];
|
|
3141
|
+
var index, length, pair, keys, result, object = data;
|
|
3142
|
+
result = new Array(object.length);
|
|
3143
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
3144
|
+
pair = object[index];
|
|
3145
|
+
keys = Object.keys(pair);
|
|
3146
|
+
result[index] = [keys[0], pair[keys[0]]];
|
|
3147
|
+
}
|
|
3148
|
+
return result;
|
|
3149
|
+
}
|
|
3150
|
+
var pairs = new type("tag:yaml.org,2002:pairs", {
|
|
3151
|
+
kind: "sequence",
|
|
3152
|
+
resolve: resolveYamlPairs,
|
|
3153
|
+
construct: constructYamlPairs
|
|
3154
|
+
});
|
|
3155
|
+
var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
3156
|
+
function resolveYamlSet(data) {
|
|
3157
|
+
if (data === null)
|
|
3158
|
+
return true;
|
|
3159
|
+
var key, object = data;
|
|
3160
|
+
for (key in object) {
|
|
3161
|
+
if (_hasOwnProperty$2.call(object, key)) {
|
|
3162
|
+
if (object[key] !== null)
|
|
3163
|
+
return false;
|
|
3164
|
+
}
|
|
3165
|
+
}
|
|
3166
|
+
return true;
|
|
3167
|
+
}
|
|
3168
|
+
function constructYamlSet(data) {
|
|
3169
|
+
return data !== null ? data : {};
|
|
3170
|
+
}
|
|
3171
|
+
var set = new type("tag:yaml.org,2002:set", {
|
|
3172
|
+
kind: "mapping",
|
|
3173
|
+
resolve: resolveYamlSet,
|
|
3174
|
+
construct: constructYamlSet
|
|
3175
|
+
});
|
|
3176
|
+
var _default = core.extend({
|
|
3177
|
+
implicit: [
|
|
3178
|
+
timestamp,
|
|
3179
|
+
merge
|
|
3180
|
+
],
|
|
3181
|
+
explicit: [
|
|
3182
|
+
binary,
|
|
3183
|
+
omap,
|
|
3184
|
+
pairs,
|
|
3185
|
+
set
|
|
3186
|
+
]
|
|
3187
|
+
});
|
|
3188
|
+
var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
3189
|
+
var CONTEXT_FLOW_IN = 1;
|
|
3190
|
+
var CONTEXT_FLOW_OUT = 2;
|
|
3191
|
+
var CONTEXT_BLOCK_IN = 3;
|
|
3192
|
+
var CONTEXT_BLOCK_OUT = 4;
|
|
3193
|
+
var CHOMPING_CLIP = 1;
|
|
3194
|
+
var CHOMPING_STRIP = 2;
|
|
3195
|
+
var CHOMPING_KEEP = 3;
|
|
3196
|
+
var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
|
|
3197
|
+
var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
|
|
3198
|
+
var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
|
|
3199
|
+
var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
|
|
3200
|
+
var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
|
|
3201
|
+
function _class(obj) {
|
|
3202
|
+
return Object.prototype.toString.call(obj);
|
|
3203
|
+
}
|
|
3204
|
+
function is_EOL(c) {
|
|
3205
|
+
return c === 10 || c === 13;
|
|
3206
|
+
}
|
|
3207
|
+
function is_WHITE_SPACE(c) {
|
|
3208
|
+
return c === 9 || c === 32;
|
|
3209
|
+
}
|
|
3210
|
+
function is_WS_OR_EOL(c) {
|
|
3211
|
+
return c === 9 || c === 32 || c === 10 || c === 13;
|
|
3212
|
+
}
|
|
3213
|
+
function is_FLOW_INDICATOR(c) {
|
|
3214
|
+
return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
|
|
3215
|
+
}
|
|
3216
|
+
function fromHexCode(c) {
|
|
3217
|
+
var lc;
|
|
3218
|
+
if (48 <= c && c <= 57) {
|
|
3219
|
+
return c - 48;
|
|
3220
|
+
}
|
|
3221
|
+
lc = c | 32;
|
|
3222
|
+
if (97 <= lc && lc <= 102) {
|
|
3223
|
+
return lc - 97 + 10;
|
|
3224
|
+
}
|
|
3225
|
+
return -1;
|
|
3226
|
+
}
|
|
3227
|
+
function escapedHexLen(c) {
|
|
3228
|
+
if (c === 120) {
|
|
3229
|
+
return 2;
|
|
3230
|
+
}
|
|
3231
|
+
if (c === 117) {
|
|
3232
|
+
return 4;
|
|
3233
|
+
}
|
|
3234
|
+
if (c === 85) {
|
|
3235
|
+
return 8;
|
|
3236
|
+
}
|
|
3237
|
+
return 0;
|
|
3238
|
+
}
|
|
3239
|
+
function fromDecimalCode(c) {
|
|
3240
|
+
if (48 <= c && c <= 57) {
|
|
3241
|
+
return c - 48;
|
|
3242
|
+
}
|
|
3243
|
+
return -1;
|
|
3244
|
+
}
|
|
3245
|
+
function simpleEscapeSequence(c) {
|
|
3246
|
+
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 ? "" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "\x85" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
|
|
3247
|
+
}
|
|
3248
|
+
function charFromCodepoint(c) {
|
|
3249
|
+
if (c <= 65535) {
|
|
3250
|
+
return String.fromCharCode(c);
|
|
3251
|
+
}
|
|
3252
|
+
return String.fromCharCode((c - 65536 >> 10) + 55296, (c - 65536 & 1023) + 56320);
|
|
3253
|
+
}
|
|
3254
|
+
var simpleEscapeCheck = new Array(256);
|
|
3255
|
+
var simpleEscapeMap = new Array(256);
|
|
3256
|
+
for (i = 0; i < 256; i++) {
|
|
3257
|
+
simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
|
|
3258
|
+
simpleEscapeMap[i] = simpleEscapeSequence(i);
|
|
3259
|
+
}
|
|
3260
|
+
var i;
|
|
3261
|
+
function State$1(input, options) {
|
|
3262
|
+
this.input = input;
|
|
3263
|
+
this.filename = options["filename"] || null;
|
|
3264
|
+
this.schema = options["schema"] || _default;
|
|
3265
|
+
this.onWarning = options["onWarning"] || null;
|
|
3266
|
+
this.legacy = options["legacy"] || false;
|
|
3267
|
+
this.json = options["json"] || false;
|
|
3268
|
+
this.listener = options["listener"] || null;
|
|
3269
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
3270
|
+
this.typeMap = this.schema.compiledTypeMap;
|
|
3271
|
+
this.length = input.length;
|
|
3272
|
+
this.position = 0;
|
|
3273
|
+
this.line = 0;
|
|
3274
|
+
this.lineStart = 0;
|
|
3275
|
+
this.lineIndent = 0;
|
|
3276
|
+
this.firstTabInLine = -1;
|
|
3277
|
+
this.documents = [];
|
|
3278
|
+
}
|
|
3279
|
+
function generateError(state, message) {
|
|
3280
|
+
var mark = {
|
|
3281
|
+
name: state.filename,
|
|
3282
|
+
buffer: state.input.slice(0, -1),
|
|
3283
|
+
position: state.position,
|
|
3284
|
+
line: state.line,
|
|
3285
|
+
column: state.position - state.lineStart
|
|
3286
|
+
};
|
|
3287
|
+
mark.snippet = snippet(mark);
|
|
3288
|
+
return new exception(message, mark);
|
|
3289
|
+
}
|
|
3290
|
+
function throwError(state, message) {
|
|
3291
|
+
throw generateError(state, message);
|
|
3292
|
+
}
|
|
3293
|
+
function throwWarning(state, message) {
|
|
3294
|
+
if (state.onWarning) {
|
|
3295
|
+
state.onWarning.call(null, generateError(state, message));
|
|
3296
|
+
}
|
|
3297
|
+
}
|
|
3298
|
+
var directiveHandlers = {
|
|
3299
|
+
YAML: function handleYamlDirective(state, name, args) {
|
|
3300
|
+
var match, major, minor;
|
|
3301
|
+
if (state.version !== null) {
|
|
3302
|
+
throwError(state, "duplication of %YAML directive");
|
|
3303
|
+
}
|
|
3304
|
+
if (args.length !== 1) {
|
|
3305
|
+
throwError(state, "YAML directive accepts exactly one argument");
|
|
3306
|
+
}
|
|
3307
|
+
match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
|
|
3308
|
+
if (match === null) {
|
|
3309
|
+
throwError(state, "ill-formed argument of the YAML directive");
|
|
3310
|
+
}
|
|
3311
|
+
major = parseInt(match[1], 10);
|
|
3312
|
+
minor = parseInt(match[2], 10);
|
|
3313
|
+
if (major !== 1) {
|
|
3314
|
+
throwError(state, "unacceptable YAML version of the document");
|
|
3315
|
+
}
|
|
3316
|
+
state.version = args[0];
|
|
3317
|
+
state.checkLineBreaks = minor < 2;
|
|
3318
|
+
if (minor !== 1 && minor !== 2) {
|
|
3319
|
+
throwWarning(state, "unsupported YAML version of the document");
|
|
3320
|
+
}
|
|
3321
|
+
},
|
|
3322
|
+
TAG: function handleTagDirective(state, name, args) {
|
|
3323
|
+
var handle, prefix;
|
|
3324
|
+
if (args.length !== 2) {
|
|
3325
|
+
throwError(state, "TAG directive accepts exactly two arguments");
|
|
3326
|
+
}
|
|
3327
|
+
handle = args[0];
|
|
3328
|
+
prefix = args[1];
|
|
3329
|
+
if (!PATTERN_TAG_HANDLE.test(handle)) {
|
|
3330
|
+
throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
|
|
3331
|
+
}
|
|
3332
|
+
if (_hasOwnProperty$1.call(state.tagMap, handle)) {
|
|
3333
|
+
throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
|
|
3334
|
+
}
|
|
3335
|
+
if (!PATTERN_TAG_URI.test(prefix)) {
|
|
3336
|
+
throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
|
|
3337
|
+
}
|
|
3338
|
+
try {
|
|
3339
|
+
prefix = decodeURIComponent(prefix);
|
|
3340
|
+
} catch (err) {
|
|
3341
|
+
throwError(state, "tag prefix is malformed: " + prefix);
|
|
3342
|
+
}
|
|
3343
|
+
state.tagMap[handle] = prefix;
|
|
3344
|
+
}
|
|
3345
|
+
};
|
|
3346
|
+
function captureSegment(state, start, end, checkJson) {
|
|
3347
|
+
var _position, _length, _character, _result;
|
|
3348
|
+
if (start < end) {
|
|
3349
|
+
_result = state.input.slice(start, end);
|
|
3350
|
+
if (checkJson) {
|
|
3351
|
+
for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
|
|
3352
|
+
_character = _result.charCodeAt(_position);
|
|
3353
|
+
if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
|
|
3354
|
+
throwError(state, "expected valid JSON character");
|
|
3355
|
+
}
|
|
3356
|
+
}
|
|
3357
|
+
} else if (PATTERN_NON_PRINTABLE.test(_result)) {
|
|
3358
|
+
throwError(state, "the stream contains non-printable characters");
|
|
3359
|
+
}
|
|
3360
|
+
state.result += _result;
|
|
3361
|
+
}
|
|
3362
|
+
}
|
|
3363
|
+
function mergeMappings(state, destination, source, overridableKeys) {
|
|
3364
|
+
var sourceKeys, key, index, quantity;
|
|
3365
|
+
if (!common.isObject(source)) {
|
|
3366
|
+
throwError(state, "cannot merge mappings; the provided source object is unacceptable");
|
|
3367
|
+
}
|
|
3368
|
+
sourceKeys = Object.keys(source);
|
|
3369
|
+
for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
|
|
3370
|
+
key = sourceKeys[index];
|
|
3371
|
+
if (!_hasOwnProperty$1.call(destination, key)) {
|
|
3372
|
+
destination[key] = source[key];
|
|
3373
|
+
overridableKeys[key] = true;
|
|
3374
|
+
}
|
|
3375
|
+
}
|
|
3376
|
+
}
|
|
3377
|
+
function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
|
|
3378
|
+
var index, quantity;
|
|
3379
|
+
if (Array.isArray(keyNode)) {
|
|
3380
|
+
keyNode = Array.prototype.slice.call(keyNode);
|
|
3381
|
+
for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
|
|
3382
|
+
if (Array.isArray(keyNode[index])) {
|
|
3383
|
+
throwError(state, "nested arrays are not supported inside keys");
|
|
3384
|
+
}
|
|
3385
|
+
if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
|
|
3386
|
+
keyNode[index] = "[object Object]";
|
|
3387
|
+
}
|
|
3388
|
+
}
|
|
3389
|
+
}
|
|
3390
|
+
if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
|
|
3391
|
+
keyNode = "[object Object]";
|
|
3392
|
+
}
|
|
3393
|
+
keyNode = String(keyNode);
|
|
3394
|
+
if (_result === null) {
|
|
3395
|
+
_result = {};
|
|
3396
|
+
}
|
|
3397
|
+
if (keyTag === "tag:yaml.org,2002:merge") {
|
|
3398
|
+
if (Array.isArray(valueNode)) {
|
|
3399
|
+
for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
|
|
3400
|
+
mergeMappings(state, _result, valueNode[index], overridableKeys);
|
|
3401
|
+
}
|
|
3402
|
+
} else {
|
|
3403
|
+
mergeMappings(state, _result, valueNode, overridableKeys);
|
|
3404
|
+
}
|
|
3405
|
+
} else {
|
|
3406
|
+
if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) {
|
|
3407
|
+
state.line = startLine || state.line;
|
|
3408
|
+
state.lineStart = startLineStart || state.lineStart;
|
|
3409
|
+
state.position = startPos || state.position;
|
|
3410
|
+
throwError(state, "duplicated mapping key");
|
|
3411
|
+
}
|
|
3412
|
+
if (keyNode === "__proto__") {
|
|
3413
|
+
Object.defineProperty(_result, keyNode, {
|
|
3414
|
+
configurable: true,
|
|
3415
|
+
enumerable: true,
|
|
3416
|
+
writable: true,
|
|
3417
|
+
value: valueNode
|
|
3418
|
+
});
|
|
3419
|
+
} else {
|
|
3420
|
+
_result[keyNode] = valueNode;
|
|
3421
|
+
}
|
|
3422
|
+
delete overridableKeys[keyNode];
|
|
3423
|
+
}
|
|
3424
|
+
return _result;
|
|
3425
|
+
}
|
|
3426
|
+
function readLineBreak(state) {
|
|
3427
|
+
var ch;
|
|
3428
|
+
ch = state.input.charCodeAt(state.position);
|
|
3429
|
+
if (ch === 10) {
|
|
3430
|
+
state.position++;
|
|
3431
|
+
} else if (ch === 13) {
|
|
3432
|
+
state.position++;
|
|
3433
|
+
if (state.input.charCodeAt(state.position) === 10) {
|
|
3434
|
+
state.position++;
|
|
3435
|
+
}
|
|
3436
|
+
} else {
|
|
3437
|
+
throwError(state, "a line break is expected");
|
|
3438
|
+
}
|
|
3439
|
+
state.line += 1;
|
|
3440
|
+
state.lineStart = state.position;
|
|
3441
|
+
state.firstTabInLine = -1;
|
|
3442
|
+
}
|
|
3443
|
+
function skipSeparationSpace(state, allowComments, checkIndent) {
|
|
3444
|
+
var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
|
|
3445
|
+
while (ch !== 0) {
|
|
3446
|
+
while (is_WHITE_SPACE(ch)) {
|
|
3447
|
+
if (ch === 9 && state.firstTabInLine === -1) {
|
|
3448
|
+
state.firstTabInLine = state.position;
|
|
3449
|
+
}
|
|
3450
|
+
ch = state.input.charCodeAt(++state.position);
|
|
3451
|
+
}
|
|
3452
|
+
if (allowComments && ch === 35) {
|
|
3453
|
+
do {
|
|
3454
|
+
ch = state.input.charCodeAt(++state.position);
|
|
3455
|
+
} while (ch !== 10 && ch !== 13 && ch !== 0);
|
|
3456
|
+
}
|
|
3457
|
+
if (is_EOL(ch)) {
|
|
3458
|
+
readLineBreak(state);
|
|
3459
|
+
ch = state.input.charCodeAt(state.position);
|
|
3460
|
+
lineBreaks++;
|
|
3461
|
+
state.lineIndent = 0;
|
|
3462
|
+
while (ch === 32) {
|
|
3463
|
+
state.lineIndent++;
|
|
3464
|
+
ch = state.input.charCodeAt(++state.position);
|
|
3465
|
+
}
|
|
3466
|
+
} else {
|
|
3467
|
+
break;
|
|
3468
|
+
}
|
|
3469
|
+
}
|
|
3470
|
+
if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
|
|
3471
|
+
throwWarning(state, "deficient indentation");
|
|
3472
|
+
}
|
|
3473
|
+
return lineBreaks;
|
|
3474
|
+
}
|
|
3475
|
+
function testDocumentSeparator(state) {
|
|
3476
|
+
var _position = state.position, ch;
|
|
3477
|
+
ch = state.input.charCodeAt(_position);
|
|
3478
|
+
if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
|
|
3479
|
+
_position += 3;
|
|
3480
|
+
ch = state.input.charCodeAt(_position);
|
|
3481
|
+
if (ch === 0 || is_WS_OR_EOL(ch)) {
|
|
3482
|
+
return true;
|
|
3483
|
+
}
|
|
3484
|
+
}
|
|
3485
|
+
return false;
|
|
3486
|
+
}
|
|
3487
|
+
function writeFoldedLines(state, count) {
|
|
3488
|
+
if (count === 1) {
|
|
3489
|
+
state.result += " ";
|
|
3490
|
+
} else if (count > 1) {
|
|
3491
|
+
state.result += common.repeat("\n", count - 1);
|
|
3492
|
+
}
|
|
3493
|
+
}
|
|
3494
|
+
function readPlainScalar(state, nodeIndent, withinFlowCollection) {
|
|
3495
|
+
var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
|
|
3496
|
+
ch = state.input.charCodeAt(state.position);
|
|
3497
|
+
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) {
|
|
3498
|
+
return false;
|
|
3499
|
+
}
|
|
3500
|
+
if (ch === 63 || ch === 45) {
|
|
3501
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
3502
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
3503
|
+
return false;
|
|
3504
|
+
}
|
|
3505
|
+
}
|
|
3506
|
+
state.kind = "scalar";
|
|
3507
|
+
state.result = "";
|
|
3508
|
+
captureStart = captureEnd = state.position;
|
|
3509
|
+
hasPendingContent = false;
|
|
3510
|
+
while (ch !== 0) {
|
|
3511
|
+
if (ch === 58) {
|
|
3512
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
3513
|
+
if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
|
|
3514
|
+
break;
|
|
3515
|
+
}
|
|
3516
|
+
} else if (ch === 35) {
|
|
3517
|
+
preceding = state.input.charCodeAt(state.position - 1);
|
|
3518
|
+
if (is_WS_OR_EOL(preceding)) {
|
|
3519
|
+
break;
|
|
3520
|
+
}
|
|
3521
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
|
|
3522
|
+
break;
|
|
3523
|
+
} else if (is_EOL(ch)) {
|
|
3524
|
+
_line = state.line;
|
|
3525
|
+
_lineStart = state.lineStart;
|
|
3526
|
+
_lineIndent = state.lineIndent;
|
|
3527
|
+
skipSeparationSpace(state, false, -1);
|
|
3528
|
+
if (state.lineIndent >= nodeIndent) {
|
|
3529
|
+
hasPendingContent = true;
|
|
3530
|
+
ch = state.input.charCodeAt(state.position);
|
|
3531
|
+
continue;
|
|
3532
|
+
} else {
|
|
3533
|
+
state.position = captureEnd;
|
|
3534
|
+
state.line = _line;
|
|
3535
|
+
state.lineStart = _lineStart;
|
|
3536
|
+
state.lineIndent = _lineIndent;
|
|
3537
|
+
break;
|
|
3538
|
+
}
|
|
3539
|
+
}
|
|
3540
|
+
if (hasPendingContent) {
|
|
3541
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
3542
|
+
writeFoldedLines(state, state.line - _line);
|
|
3543
|
+
captureStart = captureEnd = state.position;
|
|
3544
|
+
hasPendingContent = false;
|
|
3545
|
+
}
|
|
3546
|
+
if (!is_WHITE_SPACE(ch)) {
|
|
3547
|
+
captureEnd = state.position + 1;
|
|
3548
|
+
}
|
|
3549
|
+
ch = state.input.charCodeAt(++state.position);
|
|
3550
|
+
}
|
|
3551
|
+
captureSegment(state, captureStart, captureEnd, false);
|
|
3552
|
+
if (state.result) {
|
|
3553
|
+
return true;
|
|
3554
|
+
}
|
|
3555
|
+
state.kind = _kind;
|
|
3556
|
+
state.result = _result;
|
|
3557
|
+
return false;
|
|
3558
|
+
}
|
|
3559
|
+
function readSingleQuotedScalar(state, nodeIndent) {
|
|
3560
|
+
var ch, captureStart, captureEnd;
|
|
3561
|
+
ch = state.input.charCodeAt(state.position);
|
|
3562
|
+
if (ch !== 39) {
|
|
3563
|
+
return false;
|
|
3564
|
+
}
|
|
3565
|
+
state.kind = "scalar";
|
|
3566
|
+
state.result = "";
|
|
3567
|
+
state.position++;
|
|
3568
|
+
captureStart = captureEnd = state.position;
|
|
3569
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
3570
|
+
if (ch === 39) {
|
|
3571
|
+
captureSegment(state, captureStart, state.position, true);
|
|
3572
|
+
ch = state.input.charCodeAt(++state.position);
|
|
3573
|
+
if (ch === 39) {
|
|
3574
|
+
captureStart = state.position;
|
|
3575
|
+
state.position++;
|
|
3576
|
+
captureEnd = state.position;
|
|
3577
|
+
} else {
|
|
3578
|
+
return true;
|
|
3579
|
+
}
|
|
3580
|
+
} else if (is_EOL(ch)) {
|
|
3581
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
3582
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
3583
|
+
captureStart = captureEnd = state.position;
|
|
3584
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
3585
|
+
throwError(state, "unexpected end of the document within a single quoted scalar");
|
|
3586
|
+
} else {
|
|
3587
|
+
state.position++;
|
|
3588
|
+
captureEnd = state.position;
|
|
3589
|
+
}
|
|
3590
|
+
}
|
|
3591
|
+
throwError(state, "unexpected end of the stream within a single quoted scalar");
|
|
3592
|
+
}
|
|
3593
|
+
function readDoubleQuotedScalar(state, nodeIndent) {
|
|
3594
|
+
var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
|
|
3595
|
+
ch = state.input.charCodeAt(state.position);
|
|
3596
|
+
if (ch !== 34) {
|
|
3597
|
+
return false;
|
|
3598
|
+
}
|
|
3599
|
+
state.kind = "scalar";
|
|
3600
|
+
state.result = "";
|
|
3601
|
+
state.position++;
|
|
3602
|
+
captureStart = captureEnd = state.position;
|
|
3603
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
3604
|
+
if (ch === 34) {
|
|
3605
|
+
captureSegment(state, captureStart, state.position, true);
|
|
3606
|
+
state.position++;
|
|
3607
|
+
return true;
|
|
3608
|
+
} else if (ch === 92) {
|
|
3609
|
+
captureSegment(state, captureStart, state.position, true);
|
|
3610
|
+
ch = state.input.charCodeAt(++state.position);
|
|
3611
|
+
if (is_EOL(ch)) {
|
|
3612
|
+
skipSeparationSpace(state, false, nodeIndent);
|
|
3613
|
+
} else if (ch < 256 && simpleEscapeCheck[ch]) {
|
|
3614
|
+
state.result += simpleEscapeMap[ch];
|
|
3615
|
+
state.position++;
|
|
3616
|
+
} else if ((tmp = escapedHexLen(ch)) > 0) {
|
|
3617
|
+
hexLength = tmp;
|
|
3618
|
+
hexResult = 0;
|
|
3619
|
+
for (; hexLength > 0; hexLength--) {
|
|
3620
|
+
ch = state.input.charCodeAt(++state.position);
|
|
3621
|
+
if ((tmp = fromHexCode(ch)) >= 0) {
|
|
3622
|
+
hexResult = (hexResult << 4) + tmp;
|
|
3623
|
+
} else {
|
|
3624
|
+
throwError(state, "expected hexadecimal character");
|
|
3625
|
+
}
|
|
3626
|
+
}
|
|
3627
|
+
state.result += charFromCodepoint(hexResult);
|
|
3628
|
+
state.position++;
|
|
3629
|
+
} else {
|
|
3630
|
+
throwError(state, "unknown escape sequence");
|
|
3631
|
+
}
|
|
3632
|
+
captureStart = captureEnd = state.position;
|
|
3633
|
+
} else if (is_EOL(ch)) {
|
|
3634
|
+
captureSegment(state, captureStart, captureEnd, true);
|
|
3635
|
+
writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
|
|
3636
|
+
captureStart = captureEnd = state.position;
|
|
3637
|
+
} else if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
3638
|
+
throwError(state, "unexpected end of the document within a double quoted scalar");
|
|
3639
|
+
} else {
|
|
3640
|
+
state.position++;
|
|
3641
|
+
captureEnd = state.position;
|
|
3642
|
+
}
|
|
3643
|
+
}
|
|
3644
|
+
throwError(state, "unexpected end of the stream within a double quoted scalar");
|
|
3645
|
+
}
|
|
3646
|
+
function readFlowCollection(state, nodeIndent) {
|
|
3647
|
+
var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = Object.create(null), keyNode, keyTag, valueNode, ch;
|
|
3648
|
+
ch = state.input.charCodeAt(state.position);
|
|
3649
|
+
if (ch === 91) {
|
|
3650
|
+
terminator = 93;
|
|
3651
|
+
isMapping = false;
|
|
3652
|
+
_result = [];
|
|
3653
|
+
} else if (ch === 123) {
|
|
3654
|
+
terminator = 125;
|
|
3655
|
+
isMapping = true;
|
|
3656
|
+
_result = {};
|
|
3657
|
+
} else {
|
|
3658
|
+
return false;
|
|
3659
|
+
}
|
|
3660
|
+
if (state.anchor !== null) {
|
|
3661
|
+
state.anchorMap[state.anchor] = _result;
|
|
3662
|
+
}
|
|
3663
|
+
ch = state.input.charCodeAt(++state.position);
|
|
3664
|
+
while (ch !== 0) {
|
|
3665
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
3666
|
+
ch = state.input.charCodeAt(state.position);
|
|
3667
|
+
if (ch === terminator) {
|
|
3668
|
+
state.position++;
|
|
3669
|
+
state.tag = _tag;
|
|
3670
|
+
state.anchor = _anchor;
|
|
3671
|
+
state.kind = isMapping ? "mapping" : "sequence";
|
|
3672
|
+
state.result = _result;
|
|
3673
|
+
return true;
|
|
3674
|
+
} else if (!readNext) {
|
|
3675
|
+
throwError(state, "missed comma between flow collection entries");
|
|
3676
|
+
} else if (ch === 44) {
|
|
3677
|
+
throwError(state, "expected the node content, but found ','");
|
|
3678
|
+
}
|
|
3679
|
+
keyTag = keyNode = valueNode = null;
|
|
3680
|
+
isPair = isExplicitPair = false;
|
|
3681
|
+
if (ch === 63) {
|
|
3682
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
3683
|
+
if (is_WS_OR_EOL(following)) {
|
|
3684
|
+
isPair = isExplicitPair = true;
|
|
3685
|
+
state.position++;
|
|
3686
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
3687
|
+
}
|
|
3688
|
+
}
|
|
3689
|
+
_line = state.line;
|
|
3690
|
+
_lineStart = state.lineStart;
|
|
3691
|
+
_pos = state.position;
|
|
3692
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
3693
|
+
keyTag = state.tag;
|
|
3694
|
+
keyNode = state.result;
|
|
3695
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
3696
|
+
ch = state.input.charCodeAt(state.position);
|
|
3697
|
+
if ((isExplicitPair || state.line === _line) && ch === 58) {
|
|
3698
|
+
isPair = true;
|
|
3699
|
+
ch = state.input.charCodeAt(++state.position);
|
|
3700
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
3701
|
+
composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
|
|
3702
|
+
valueNode = state.result;
|
|
3703
|
+
}
|
|
3704
|
+
if (isMapping) {
|
|
3705
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
|
|
3706
|
+
} else if (isPair) {
|
|
3707
|
+
_result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
|
|
3708
|
+
} else {
|
|
3709
|
+
_result.push(keyNode);
|
|
3710
|
+
}
|
|
3711
|
+
skipSeparationSpace(state, true, nodeIndent);
|
|
3712
|
+
ch = state.input.charCodeAt(state.position);
|
|
3713
|
+
if (ch === 44) {
|
|
3714
|
+
readNext = true;
|
|
3715
|
+
ch = state.input.charCodeAt(++state.position);
|
|
3716
|
+
} else {
|
|
3717
|
+
readNext = false;
|
|
3718
|
+
}
|
|
3719
|
+
}
|
|
3720
|
+
throwError(state, "unexpected end of the stream within a flow collection");
|
|
3721
|
+
}
|
|
3722
|
+
function readBlockScalar(state, nodeIndent) {
|
|
3723
|
+
var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
|
|
3724
|
+
ch = state.input.charCodeAt(state.position);
|
|
3725
|
+
if (ch === 124) {
|
|
3726
|
+
folding = false;
|
|
3727
|
+
} else if (ch === 62) {
|
|
3728
|
+
folding = true;
|
|
3729
|
+
} else {
|
|
3730
|
+
return false;
|
|
3731
|
+
}
|
|
3732
|
+
state.kind = "scalar";
|
|
3733
|
+
state.result = "";
|
|
3734
|
+
while (ch !== 0) {
|
|
3735
|
+
ch = state.input.charCodeAt(++state.position);
|
|
3736
|
+
if (ch === 43 || ch === 45) {
|
|
3737
|
+
if (CHOMPING_CLIP === chomping) {
|
|
3738
|
+
chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
|
|
3739
|
+
} else {
|
|
3740
|
+
throwError(state, "repeat of a chomping mode identifier");
|
|
3741
|
+
}
|
|
3742
|
+
} else if ((tmp = fromDecimalCode(ch)) >= 0) {
|
|
3743
|
+
if (tmp === 0) {
|
|
3744
|
+
throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
|
|
3745
|
+
} else if (!detectedIndent) {
|
|
3746
|
+
textIndent = nodeIndent + tmp - 1;
|
|
3747
|
+
detectedIndent = true;
|
|
3748
|
+
} else {
|
|
3749
|
+
throwError(state, "repeat of an indentation width identifier");
|
|
3750
|
+
}
|
|
3751
|
+
} else {
|
|
3752
|
+
break;
|
|
3753
|
+
}
|
|
3754
|
+
}
|
|
3755
|
+
if (is_WHITE_SPACE(ch)) {
|
|
3756
|
+
do {
|
|
3757
|
+
ch = state.input.charCodeAt(++state.position);
|
|
3758
|
+
} while (is_WHITE_SPACE(ch));
|
|
3759
|
+
if (ch === 35) {
|
|
3760
|
+
do {
|
|
3761
|
+
ch = state.input.charCodeAt(++state.position);
|
|
3762
|
+
} while (!is_EOL(ch) && ch !== 0);
|
|
3763
|
+
}
|
|
3764
|
+
}
|
|
3765
|
+
while (ch !== 0) {
|
|
3766
|
+
readLineBreak(state);
|
|
3767
|
+
state.lineIndent = 0;
|
|
3768
|
+
ch = state.input.charCodeAt(state.position);
|
|
3769
|
+
while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
|
|
3770
|
+
state.lineIndent++;
|
|
3771
|
+
ch = state.input.charCodeAt(++state.position);
|
|
3772
|
+
}
|
|
3773
|
+
if (!detectedIndent && state.lineIndent > textIndent) {
|
|
3774
|
+
textIndent = state.lineIndent;
|
|
3775
|
+
}
|
|
3776
|
+
if (is_EOL(ch)) {
|
|
3777
|
+
emptyLines++;
|
|
3778
|
+
continue;
|
|
3779
|
+
}
|
|
3780
|
+
if (state.lineIndent < textIndent) {
|
|
3781
|
+
if (chomping === CHOMPING_KEEP) {
|
|
3782
|
+
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
3783
|
+
} else if (chomping === CHOMPING_CLIP) {
|
|
3784
|
+
if (didReadContent) {
|
|
3785
|
+
state.result += "\n";
|
|
3786
|
+
}
|
|
3787
|
+
}
|
|
3788
|
+
break;
|
|
3789
|
+
}
|
|
3790
|
+
if (folding) {
|
|
3791
|
+
if (is_WHITE_SPACE(ch)) {
|
|
3792
|
+
atMoreIndented = true;
|
|
3793
|
+
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
3794
|
+
} else if (atMoreIndented) {
|
|
3795
|
+
atMoreIndented = false;
|
|
3796
|
+
state.result += common.repeat("\n", emptyLines + 1);
|
|
3797
|
+
} else if (emptyLines === 0) {
|
|
3798
|
+
if (didReadContent) {
|
|
3799
|
+
state.result += " ";
|
|
3800
|
+
}
|
|
3801
|
+
} else {
|
|
3802
|
+
state.result += common.repeat("\n", emptyLines);
|
|
3803
|
+
}
|
|
3804
|
+
} else {
|
|
3805
|
+
state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
|
|
3806
|
+
}
|
|
3807
|
+
didReadContent = true;
|
|
3808
|
+
detectedIndent = true;
|
|
3809
|
+
emptyLines = 0;
|
|
3810
|
+
captureStart = state.position;
|
|
3811
|
+
while (!is_EOL(ch) && ch !== 0) {
|
|
3812
|
+
ch = state.input.charCodeAt(++state.position);
|
|
3813
|
+
}
|
|
3814
|
+
captureSegment(state, captureStart, state.position, false);
|
|
3815
|
+
}
|
|
3816
|
+
return true;
|
|
3817
|
+
}
|
|
3818
|
+
function readBlockSequence(state, nodeIndent) {
|
|
3819
|
+
var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
|
|
3820
|
+
if (state.firstTabInLine !== -1)
|
|
3821
|
+
return false;
|
|
3822
|
+
if (state.anchor !== null) {
|
|
3823
|
+
state.anchorMap[state.anchor] = _result;
|
|
3824
|
+
}
|
|
3825
|
+
ch = state.input.charCodeAt(state.position);
|
|
3826
|
+
while (ch !== 0) {
|
|
3827
|
+
if (state.firstTabInLine !== -1) {
|
|
3828
|
+
state.position = state.firstTabInLine;
|
|
3829
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
3830
|
+
}
|
|
3831
|
+
if (ch !== 45) {
|
|
3832
|
+
break;
|
|
3833
|
+
}
|
|
3834
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
3835
|
+
if (!is_WS_OR_EOL(following)) {
|
|
3836
|
+
break;
|
|
3837
|
+
}
|
|
3838
|
+
detected = true;
|
|
3839
|
+
state.position++;
|
|
3840
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
3841
|
+
if (state.lineIndent <= nodeIndent) {
|
|
3842
|
+
_result.push(null);
|
|
3843
|
+
ch = state.input.charCodeAt(state.position);
|
|
3844
|
+
continue;
|
|
3845
|
+
}
|
|
3846
|
+
}
|
|
3847
|
+
_line = state.line;
|
|
3848
|
+
composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
|
|
3849
|
+
_result.push(state.result);
|
|
3850
|
+
skipSeparationSpace(state, true, -1);
|
|
3851
|
+
ch = state.input.charCodeAt(state.position);
|
|
3852
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
3853
|
+
throwError(state, "bad indentation of a sequence entry");
|
|
3854
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
3855
|
+
break;
|
|
3856
|
+
}
|
|
3857
|
+
}
|
|
3858
|
+
if (detected) {
|
|
3859
|
+
state.tag = _tag;
|
|
3860
|
+
state.anchor = _anchor;
|
|
3861
|
+
state.kind = "sequence";
|
|
3862
|
+
state.result = _result;
|
|
3863
|
+
return true;
|
|
3864
|
+
}
|
|
3865
|
+
return false;
|
|
3866
|
+
}
|
|
3867
|
+
function readBlockMapping(state, nodeIndent, flowIndent) {
|
|
3868
|
+
var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
|
|
3869
|
+
if (state.firstTabInLine !== -1)
|
|
3870
|
+
return false;
|
|
3871
|
+
if (state.anchor !== null) {
|
|
3872
|
+
state.anchorMap[state.anchor] = _result;
|
|
3873
|
+
}
|
|
3874
|
+
ch = state.input.charCodeAt(state.position);
|
|
3875
|
+
while (ch !== 0) {
|
|
3876
|
+
if (!atExplicitKey && state.firstTabInLine !== -1) {
|
|
3877
|
+
state.position = state.firstTabInLine;
|
|
3878
|
+
throwError(state, "tab characters must not be used in indentation");
|
|
3879
|
+
}
|
|
3880
|
+
following = state.input.charCodeAt(state.position + 1);
|
|
3881
|
+
_line = state.line;
|
|
3882
|
+
if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
|
|
3883
|
+
if (ch === 63) {
|
|
3884
|
+
if (atExplicitKey) {
|
|
3885
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
3886
|
+
keyTag = keyNode = valueNode = null;
|
|
3887
|
+
}
|
|
3888
|
+
detected = true;
|
|
3889
|
+
atExplicitKey = true;
|
|
3890
|
+
allowCompact = true;
|
|
3891
|
+
} else if (atExplicitKey) {
|
|
3892
|
+
atExplicitKey = false;
|
|
3893
|
+
allowCompact = true;
|
|
3894
|
+
} else {
|
|
3895
|
+
throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
|
|
3896
|
+
}
|
|
3897
|
+
state.position += 1;
|
|
3898
|
+
ch = following;
|
|
3899
|
+
} else {
|
|
3900
|
+
_keyLine = state.line;
|
|
3901
|
+
_keyLineStart = state.lineStart;
|
|
3902
|
+
_keyPos = state.position;
|
|
3903
|
+
if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
|
|
3904
|
+
break;
|
|
3905
|
+
}
|
|
3906
|
+
if (state.line === _line) {
|
|
3907
|
+
ch = state.input.charCodeAt(state.position);
|
|
3908
|
+
while (is_WHITE_SPACE(ch)) {
|
|
3909
|
+
ch = state.input.charCodeAt(++state.position);
|
|
3910
|
+
}
|
|
3911
|
+
if (ch === 58) {
|
|
3912
|
+
ch = state.input.charCodeAt(++state.position);
|
|
3913
|
+
if (!is_WS_OR_EOL(ch)) {
|
|
3914
|
+
throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
|
|
3915
|
+
}
|
|
3916
|
+
if (atExplicitKey) {
|
|
3917
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
3918
|
+
keyTag = keyNode = valueNode = null;
|
|
3919
|
+
}
|
|
3920
|
+
detected = true;
|
|
3921
|
+
atExplicitKey = false;
|
|
3922
|
+
allowCompact = false;
|
|
3923
|
+
keyTag = state.tag;
|
|
3924
|
+
keyNode = state.result;
|
|
3925
|
+
} else if (detected) {
|
|
3926
|
+
throwError(state, "can not read an implicit mapping pair; a colon is missed");
|
|
3927
|
+
} else {
|
|
3928
|
+
state.tag = _tag;
|
|
3929
|
+
state.anchor = _anchor;
|
|
3930
|
+
return true;
|
|
3931
|
+
}
|
|
3932
|
+
} else if (detected) {
|
|
3933
|
+
throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
|
|
3934
|
+
} else {
|
|
3935
|
+
state.tag = _tag;
|
|
3936
|
+
state.anchor = _anchor;
|
|
3937
|
+
return true;
|
|
3938
|
+
}
|
|
3939
|
+
}
|
|
3940
|
+
if (state.line === _line || state.lineIndent > nodeIndent) {
|
|
3941
|
+
if (atExplicitKey) {
|
|
3942
|
+
_keyLine = state.line;
|
|
3943
|
+
_keyLineStart = state.lineStart;
|
|
3944
|
+
_keyPos = state.position;
|
|
3945
|
+
}
|
|
3946
|
+
if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
|
|
3947
|
+
if (atExplicitKey) {
|
|
3948
|
+
keyNode = state.result;
|
|
3949
|
+
} else {
|
|
3950
|
+
valueNode = state.result;
|
|
3951
|
+
}
|
|
3952
|
+
}
|
|
3953
|
+
if (!atExplicitKey) {
|
|
3954
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
|
|
3955
|
+
keyTag = keyNode = valueNode = null;
|
|
3956
|
+
}
|
|
3957
|
+
skipSeparationSpace(state, true, -1);
|
|
3958
|
+
ch = state.input.charCodeAt(state.position);
|
|
3959
|
+
}
|
|
3960
|
+
if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
|
|
3961
|
+
throwError(state, "bad indentation of a mapping entry");
|
|
3962
|
+
} else if (state.lineIndent < nodeIndent) {
|
|
3963
|
+
break;
|
|
3964
|
+
}
|
|
3965
|
+
}
|
|
3966
|
+
if (atExplicitKey) {
|
|
3967
|
+
storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
|
|
3968
|
+
}
|
|
3969
|
+
if (detected) {
|
|
3970
|
+
state.tag = _tag;
|
|
3971
|
+
state.anchor = _anchor;
|
|
3972
|
+
state.kind = "mapping";
|
|
3973
|
+
state.result = _result;
|
|
3974
|
+
}
|
|
3975
|
+
return detected;
|
|
3976
|
+
}
|
|
3977
|
+
function readTagProperty(state) {
|
|
3978
|
+
var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
|
|
3979
|
+
ch = state.input.charCodeAt(state.position);
|
|
3980
|
+
if (ch !== 33)
|
|
3981
|
+
return false;
|
|
3982
|
+
if (state.tag !== null) {
|
|
3983
|
+
throwError(state, "duplication of a tag property");
|
|
3984
|
+
}
|
|
3985
|
+
ch = state.input.charCodeAt(++state.position);
|
|
3986
|
+
if (ch === 60) {
|
|
3987
|
+
isVerbatim = true;
|
|
3988
|
+
ch = state.input.charCodeAt(++state.position);
|
|
3989
|
+
} else if (ch === 33) {
|
|
3990
|
+
isNamed = true;
|
|
3991
|
+
tagHandle = "!!";
|
|
3992
|
+
ch = state.input.charCodeAt(++state.position);
|
|
3993
|
+
} else {
|
|
3994
|
+
tagHandle = "!";
|
|
3995
|
+
}
|
|
3996
|
+
_position = state.position;
|
|
3997
|
+
if (isVerbatim) {
|
|
3998
|
+
do {
|
|
3999
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4000
|
+
} while (ch !== 0 && ch !== 62);
|
|
4001
|
+
if (state.position < state.length) {
|
|
4002
|
+
tagName = state.input.slice(_position, state.position);
|
|
4003
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4004
|
+
} else {
|
|
4005
|
+
throwError(state, "unexpected end of the stream within a verbatim tag");
|
|
4006
|
+
}
|
|
4007
|
+
} else {
|
|
4008
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
4009
|
+
if (ch === 33) {
|
|
4010
|
+
if (!isNamed) {
|
|
4011
|
+
tagHandle = state.input.slice(_position - 1, state.position + 1);
|
|
4012
|
+
if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
|
|
4013
|
+
throwError(state, "named tag handle cannot contain such characters");
|
|
4014
|
+
}
|
|
4015
|
+
isNamed = true;
|
|
4016
|
+
_position = state.position + 1;
|
|
4017
|
+
} else {
|
|
4018
|
+
throwError(state, "tag suffix cannot contain exclamation marks");
|
|
4019
|
+
}
|
|
4020
|
+
}
|
|
4021
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4022
|
+
}
|
|
4023
|
+
tagName = state.input.slice(_position, state.position);
|
|
4024
|
+
if (PATTERN_FLOW_INDICATORS.test(tagName)) {
|
|
4025
|
+
throwError(state, "tag suffix cannot contain flow indicator characters");
|
|
4026
|
+
}
|
|
4027
|
+
}
|
|
4028
|
+
if (tagName && !PATTERN_TAG_URI.test(tagName)) {
|
|
4029
|
+
throwError(state, "tag name cannot contain such characters: " + tagName);
|
|
4030
|
+
}
|
|
4031
|
+
try {
|
|
4032
|
+
tagName = decodeURIComponent(tagName);
|
|
4033
|
+
} catch (err) {
|
|
4034
|
+
throwError(state, "tag name is malformed: " + tagName);
|
|
4035
|
+
}
|
|
4036
|
+
if (isVerbatim) {
|
|
4037
|
+
state.tag = tagName;
|
|
4038
|
+
} else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
|
|
4039
|
+
state.tag = state.tagMap[tagHandle] + tagName;
|
|
4040
|
+
} else if (tagHandle === "!") {
|
|
4041
|
+
state.tag = "!" + tagName;
|
|
4042
|
+
} else if (tagHandle === "!!") {
|
|
4043
|
+
state.tag = "tag:yaml.org,2002:" + tagName;
|
|
4044
|
+
} else {
|
|
4045
|
+
throwError(state, 'undeclared tag handle "' + tagHandle + '"');
|
|
4046
|
+
}
|
|
4047
|
+
return true;
|
|
4048
|
+
}
|
|
4049
|
+
function readAnchorProperty(state) {
|
|
4050
|
+
var _position, ch;
|
|
4051
|
+
ch = state.input.charCodeAt(state.position);
|
|
4052
|
+
if (ch !== 38)
|
|
4053
|
+
return false;
|
|
4054
|
+
if (state.anchor !== null) {
|
|
4055
|
+
throwError(state, "duplication of an anchor property");
|
|
4056
|
+
}
|
|
4057
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4058
|
+
_position = state.position;
|
|
4059
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
4060
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4061
|
+
}
|
|
4062
|
+
if (state.position === _position) {
|
|
4063
|
+
throwError(state, "name of an anchor node must contain at least one character");
|
|
4064
|
+
}
|
|
4065
|
+
state.anchor = state.input.slice(_position, state.position);
|
|
4066
|
+
return true;
|
|
4067
|
+
}
|
|
4068
|
+
function readAlias(state) {
|
|
4069
|
+
var _position, alias, ch;
|
|
4070
|
+
ch = state.input.charCodeAt(state.position);
|
|
4071
|
+
if (ch !== 42)
|
|
4072
|
+
return false;
|
|
4073
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4074
|
+
_position = state.position;
|
|
4075
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
|
|
4076
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4077
|
+
}
|
|
4078
|
+
if (state.position === _position) {
|
|
4079
|
+
throwError(state, "name of an alias node must contain at least one character");
|
|
4080
|
+
}
|
|
4081
|
+
alias = state.input.slice(_position, state.position);
|
|
4082
|
+
if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
|
|
4083
|
+
throwError(state, 'unidentified alias "' + alias + '"');
|
|
4084
|
+
}
|
|
4085
|
+
state.result = state.anchorMap[alias];
|
|
4086
|
+
skipSeparationSpace(state, true, -1);
|
|
4087
|
+
return true;
|
|
4088
|
+
}
|
|
4089
|
+
function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
|
|
4090
|
+
var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent;
|
|
4091
|
+
if (state.listener !== null) {
|
|
4092
|
+
state.listener("open", state);
|
|
4093
|
+
}
|
|
4094
|
+
state.tag = null;
|
|
4095
|
+
state.anchor = null;
|
|
4096
|
+
state.kind = null;
|
|
4097
|
+
state.result = null;
|
|
4098
|
+
allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
|
|
4099
|
+
if (allowToSeek) {
|
|
4100
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
4101
|
+
atNewLine = true;
|
|
4102
|
+
if (state.lineIndent > parentIndent) {
|
|
4103
|
+
indentStatus = 1;
|
|
4104
|
+
} else if (state.lineIndent === parentIndent) {
|
|
4105
|
+
indentStatus = 0;
|
|
4106
|
+
} else if (state.lineIndent < parentIndent) {
|
|
4107
|
+
indentStatus = -1;
|
|
4108
|
+
}
|
|
4109
|
+
}
|
|
4110
|
+
}
|
|
4111
|
+
if (indentStatus === 1) {
|
|
4112
|
+
while (readTagProperty(state) || readAnchorProperty(state)) {
|
|
4113
|
+
if (skipSeparationSpace(state, true, -1)) {
|
|
4114
|
+
atNewLine = true;
|
|
4115
|
+
allowBlockCollections = allowBlockStyles;
|
|
4116
|
+
if (state.lineIndent > parentIndent) {
|
|
4117
|
+
indentStatus = 1;
|
|
4118
|
+
} else if (state.lineIndent === parentIndent) {
|
|
4119
|
+
indentStatus = 0;
|
|
4120
|
+
} else if (state.lineIndent < parentIndent) {
|
|
4121
|
+
indentStatus = -1;
|
|
4122
|
+
}
|
|
4123
|
+
} else {
|
|
4124
|
+
allowBlockCollections = false;
|
|
4125
|
+
}
|
|
4126
|
+
}
|
|
4127
|
+
}
|
|
4128
|
+
if (allowBlockCollections) {
|
|
4129
|
+
allowBlockCollections = atNewLine || allowCompact;
|
|
4130
|
+
}
|
|
4131
|
+
if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
|
|
4132
|
+
if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
|
|
4133
|
+
flowIndent = parentIndent;
|
|
4134
|
+
} else {
|
|
4135
|
+
flowIndent = parentIndent + 1;
|
|
4136
|
+
}
|
|
4137
|
+
blockIndent = state.position - state.lineStart;
|
|
4138
|
+
if (indentStatus === 1) {
|
|
4139
|
+
if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
|
|
4140
|
+
hasContent = true;
|
|
4141
|
+
} else {
|
|
4142
|
+
if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
|
|
4143
|
+
hasContent = true;
|
|
4144
|
+
} else if (readAlias(state)) {
|
|
4145
|
+
hasContent = true;
|
|
4146
|
+
if (state.tag !== null || state.anchor !== null) {
|
|
4147
|
+
throwError(state, "alias node should not have any properties");
|
|
4148
|
+
}
|
|
4149
|
+
} else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
|
|
4150
|
+
hasContent = true;
|
|
4151
|
+
if (state.tag === null) {
|
|
4152
|
+
state.tag = "?";
|
|
4153
|
+
}
|
|
4154
|
+
}
|
|
4155
|
+
if (state.anchor !== null) {
|
|
4156
|
+
state.anchorMap[state.anchor] = state.result;
|
|
4157
|
+
}
|
|
4158
|
+
}
|
|
4159
|
+
} else if (indentStatus === 0) {
|
|
4160
|
+
hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
|
|
4161
|
+
}
|
|
4162
|
+
}
|
|
4163
|
+
if (state.tag === null) {
|
|
4164
|
+
if (state.anchor !== null) {
|
|
4165
|
+
state.anchorMap[state.anchor] = state.result;
|
|
4166
|
+
}
|
|
4167
|
+
} else if (state.tag === "?") {
|
|
4168
|
+
if (state.result !== null && state.kind !== "scalar") {
|
|
4169
|
+
throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
|
|
4170
|
+
}
|
|
4171
|
+
for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
4172
|
+
type2 = state.implicitTypes[typeIndex];
|
|
4173
|
+
if (type2.resolve(state.result)) {
|
|
4174
|
+
state.result = type2.construct(state.result);
|
|
4175
|
+
state.tag = type2.tag;
|
|
4176
|
+
if (state.anchor !== null) {
|
|
4177
|
+
state.anchorMap[state.anchor] = state.result;
|
|
4178
|
+
}
|
|
4179
|
+
break;
|
|
4180
|
+
}
|
|
4181
|
+
}
|
|
4182
|
+
} else if (state.tag !== "!") {
|
|
4183
|
+
if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) {
|
|
4184
|
+
type2 = state.typeMap[state.kind || "fallback"][state.tag];
|
|
4185
|
+
} else {
|
|
4186
|
+
type2 = null;
|
|
4187
|
+
typeList = state.typeMap.multi[state.kind || "fallback"];
|
|
4188
|
+
for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
|
|
4189
|
+
if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
|
|
4190
|
+
type2 = typeList[typeIndex];
|
|
4191
|
+
break;
|
|
4192
|
+
}
|
|
4193
|
+
}
|
|
4194
|
+
}
|
|
4195
|
+
if (!type2) {
|
|
4196
|
+
throwError(state, "unknown tag !<" + state.tag + ">");
|
|
4197
|
+
}
|
|
4198
|
+
if (state.result !== null && type2.kind !== state.kind) {
|
|
4199
|
+
throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
|
|
4200
|
+
}
|
|
4201
|
+
if (!type2.resolve(state.result, state.tag)) {
|
|
4202
|
+
throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
|
|
4203
|
+
} else {
|
|
4204
|
+
state.result = type2.construct(state.result, state.tag);
|
|
4205
|
+
if (state.anchor !== null) {
|
|
4206
|
+
state.anchorMap[state.anchor] = state.result;
|
|
4207
|
+
}
|
|
4208
|
+
}
|
|
4209
|
+
}
|
|
4210
|
+
if (state.listener !== null) {
|
|
4211
|
+
state.listener("close", state);
|
|
4212
|
+
}
|
|
4213
|
+
return state.tag !== null || state.anchor !== null || hasContent;
|
|
4214
|
+
}
|
|
4215
|
+
function readDocument(state) {
|
|
4216
|
+
var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
|
|
4217
|
+
state.version = null;
|
|
4218
|
+
state.checkLineBreaks = state.legacy;
|
|
4219
|
+
state.tagMap = Object.create(null);
|
|
4220
|
+
state.anchorMap = Object.create(null);
|
|
4221
|
+
while ((ch = state.input.charCodeAt(state.position)) !== 0) {
|
|
4222
|
+
skipSeparationSpace(state, true, -1);
|
|
4223
|
+
ch = state.input.charCodeAt(state.position);
|
|
4224
|
+
if (state.lineIndent > 0 || ch !== 37) {
|
|
4225
|
+
break;
|
|
4226
|
+
}
|
|
4227
|
+
hasDirectives = true;
|
|
4228
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4229
|
+
_position = state.position;
|
|
4230
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
4231
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4232
|
+
}
|
|
4233
|
+
directiveName = state.input.slice(_position, state.position);
|
|
4234
|
+
directiveArgs = [];
|
|
4235
|
+
if (directiveName.length < 1) {
|
|
4236
|
+
throwError(state, "directive name must not be less than one character in length");
|
|
4237
|
+
}
|
|
4238
|
+
while (ch !== 0) {
|
|
4239
|
+
while (is_WHITE_SPACE(ch)) {
|
|
4240
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4241
|
+
}
|
|
4242
|
+
if (ch === 35) {
|
|
4243
|
+
do {
|
|
4244
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4245
|
+
} while (ch !== 0 && !is_EOL(ch));
|
|
4246
|
+
break;
|
|
4247
|
+
}
|
|
4248
|
+
if (is_EOL(ch))
|
|
4249
|
+
break;
|
|
4250
|
+
_position = state.position;
|
|
4251
|
+
while (ch !== 0 && !is_WS_OR_EOL(ch)) {
|
|
4252
|
+
ch = state.input.charCodeAt(++state.position);
|
|
4253
|
+
}
|
|
4254
|
+
directiveArgs.push(state.input.slice(_position, state.position));
|
|
4255
|
+
}
|
|
4256
|
+
if (ch !== 0)
|
|
4257
|
+
readLineBreak(state);
|
|
4258
|
+
if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
|
|
4259
|
+
directiveHandlers[directiveName](state, directiveName, directiveArgs);
|
|
4260
|
+
} else {
|
|
4261
|
+
throwWarning(state, 'unknown document directive "' + directiveName + '"');
|
|
4262
|
+
}
|
|
4263
|
+
}
|
|
4264
|
+
skipSeparationSpace(state, true, -1);
|
|
4265
|
+
if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
|
|
4266
|
+
state.position += 3;
|
|
4267
|
+
skipSeparationSpace(state, true, -1);
|
|
4268
|
+
} else if (hasDirectives) {
|
|
4269
|
+
throwError(state, "directives end mark is expected");
|
|
4270
|
+
}
|
|
4271
|
+
composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
|
|
4272
|
+
skipSeparationSpace(state, true, -1);
|
|
4273
|
+
if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
|
|
4274
|
+
throwWarning(state, "non-ASCII line breaks are interpreted as content");
|
|
4275
|
+
}
|
|
4276
|
+
state.documents.push(state.result);
|
|
4277
|
+
if (state.position === state.lineStart && testDocumentSeparator(state)) {
|
|
4278
|
+
if (state.input.charCodeAt(state.position) === 46) {
|
|
4279
|
+
state.position += 3;
|
|
4280
|
+
skipSeparationSpace(state, true, -1);
|
|
4281
|
+
}
|
|
4282
|
+
return;
|
|
4283
|
+
}
|
|
4284
|
+
if (state.position < state.length - 1) {
|
|
4285
|
+
throwError(state, "end of the stream or a document separator is expected");
|
|
4286
|
+
} else {
|
|
4287
|
+
return;
|
|
4288
|
+
}
|
|
4289
|
+
}
|
|
4290
|
+
function loadDocuments(input, options) {
|
|
4291
|
+
input = String(input);
|
|
4292
|
+
options = options || {};
|
|
4293
|
+
if (input.length !== 0) {
|
|
4294
|
+
if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
|
|
4295
|
+
input += "\n";
|
|
4296
|
+
}
|
|
4297
|
+
if (input.charCodeAt(0) === 65279) {
|
|
4298
|
+
input = input.slice(1);
|
|
4299
|
+
}
|
|
4300
|
+
}
|
|
4301
|
+
var state = new State$1(input, options);
|
|
4302
|
+
var nullpos = input.indexOf("\0");
|
|
4303
|
+
if (nullpos !== -1) {
|
|
4304
|
+
state.position = nullpos;
|
|
4305
|
+
throwError(state, "null byte is not allowed in input");
|
|
4306
|
+
}
|
|
4307
|
+
state.input += "\0";
|
|
4308
|
+
while (state.input.charCodeAt(state.position) === 32) {
|
|
4309
|
+
state.lineIndent += 1;
|
|
4310
|
+
state.position += 1;
|
|
4311
|
+
}
|
|
4312
|
+
while (state.position < state.length - 1) {
|
|
4313
|
+
readDocument(state);
|
|
4314
|
+
}
|
|
4315
|
+
return state.documents;
|
|
4316
|
+
}
|
|
4317
|
+
function loadAll$1(input, iterator, options) {
|
|
4318
|
+
if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
|
|
4319
|
+
options = iterator;
|
|
4320
|
+
iterator = null;
|
|
4321
|
+
}
|
|
4322
|
+
var documents = loadDocuments(input, options);
|
|
4323
|
+
if (typeof iterator !== "function") {
|
|
4324
|
+
return documents;
|
|
4325
|
+
}
|
|
4326
|
+
for (var index = 0, length = documents.length; index < length; index += 1) {
|
|
4327
|
+
iterator(documents[index]);
|
|
4328
|
+
}
|
|
4329
|
+
}
|
|
4330
|
+
function load$1(input, options) {
|
|
4331
|
+
var documents = loadDocuments(input, options);
|
|
4332
|
+
if (documents.length === 0) {
|
|
4333
|
+
return void 0;
|
|
4334
|
+
} else if (documents.length === 1) {
|
|
4335
|
+
return documents[0];
|
|
4336
|
+
}
|
|
4337
|
+
throw new exception("expected a single document in the stream, but found more");
|
|
4338
|
+
}
|
|
4339
|
+
var loadAll_1 = loadAll$1;
|
|
4340
|
+
var load_1 = load$1;
|
|
4341
|
+
var loader = {
|
|
4342
|
+
loadAll: loadAll_1,
|
|
4343
|
+
load: load_1
|
|
4344
|
+
};
|
|
4345
|
+
var _toString = Object.prototype.toString;
|
|
4346
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
4347
|
+
var CHAR_BOM = 65279;
|
|
4348
|
+
var CHAR_TAB = 9;
|
|
4349
|
+
var CHAR_LINE_FEED = 10;
|
|
4350
|
+
var CHAR_CARRIAGE_RETURN = 13;
|
|
4351
|
+
var CHAR_SPACE = 32;
|
|
4352
|
+
var CHAR_EXCLAMATION = 33;
|
|
4353
|
+
var CHAR_DOUBLE_QUOTE = 34;
|
|
4354
|
+
var CHAR_SHARP = 35;
|
|
4355
|
+
var CHAR_PERCENT = 37;
|
|
4356
|
+
var CHAR_AMPERSAND = 38;
|
|
4357
|
+
var CHAR_SINGLE_QUOTE = 39;
|
|
4358
|
+
var CHAR_ASTERISK = 42;
|
|
4359
|
+
var CHAR_COMMA = 44;
|
|
4360
|
+
var CHAR_MINUS = 45;
|
|
4361
|
+
var CHAR_COLON = 58;
|
|
4362
|
+
var CHAR_EQUALS = 61;
|
|
4363
|
+
var CHAR_GREATER_THAN = 62;
|
|
4364
|
+
var CHAR_QUESTION = 63;
|
|
4365
|
+
var CHAR_COMMERCIAL_AT = 64;
|
|
4366
|
+
var CHAR_LEFT_SQUARE_BRACKET = 91;
|
|
4367
|
+
var CHAR_RIGHT_SQUARE_BRACKET = 93;
|
|
4368
|
+
var CHAR_GRAVE_ACCENT = 96;
|
|
4369
|
+
var CHAR_LEFT_CURLY_BRACKET = 123;
|
|
4370
|
+
var CHAR_VERTICAL_LINE = 124;
|
|
4371
|
+
var CHAR_RIGHT_CURLY_BRACKET = 125;
|
|
4372
|
+
var ESCAPE_SEQUENCES = {};
|
|
4373
|
+
ESCAPE_SEQUENCES[0] = "\\0";
|
|
4374
|
+
ESCAPE_SEQUENCES[7] = "\\a";
|
|
4375
|
+
ESCAPE_SEQUENCES[8] = "\\b";
|
|
4376
|
+
ESCAPE_SEQUENCES[9] = "\\t";
|
|
4377
|
+
ESCAPE_SEQUENCES[10] = "\\n";
|
|
4378
|
+
ESCAPE_SEQUENCES[11] = "\\v";
|
|
4379
|
+
ESCAPE_SEQUENCES[12] = "\\f";
|
|
4380
|
+
ESCAPE_SEQUENCES[13] = "\\r";
|
|
4381
|
+
ESCAPE_SEQUENCES[27] = "\\e";
|
|
4382
|
+
ESCAPE_SEQUENCES[34] = '\\"';
|
|
4383
|
+
ESCAPE_SEQUENCES[92] = "\\\\";
|
|
4384
|
+
ESCAPE_SEQUENCES[133] = "\\N";
|
|
4385
|
+
ESCAPE_SEQUENCES[160] = "\\_";
|
|
4386
|
+
ESCAPE_SEQUENCES[8232] = "\\L";
|
|
4387
|
+
ESCAPE_SEQUENCES[8233] = "\\P";
|
|
4388
|
+
var DEPRECATED_BOOLEANS_SYNTAX = [
|
|
4389
|
+
"y",
|
|
4390
|
+
"Y",
|
|
4391
|
+
"yes",
|
|
4392
|
+
"Yes",
|
|
4393
|
+
"YES",
|
|
4394
|
+
"on",
|
|
4395
|
+
"On",
|
|
4396
|
+
"ON",
|
|
4397
|
+
"n",
|
|
4398
|
+
"N",
|
|
4399
|
+
"no",
|
|
4400
|
+
"No",
|
|
4401
|
+
"NO",
|
|
4402
|
+
"off",
|
|
4403
|
+
"Off",
|
|
4404
|
+
"OFF"
|
|
4405
|
+
];
|
|
4406
|
+
var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
|
|
4407
|
+
function compileStyleMap(schema2, map2) {
|
|
4408
|
+
var result, keys, index, length, tag, style, type2;
|
|
4409
|
+
if (map2 === null)
|
|
4410
|
+
return {};
|
|
4411
|
+
result = {};
|
|
4412
|
+
keys = Object.keys(map2);
|
|
4413
|
+
for (index = 0, length = keys.length; index < length; index += 1) {
|
|
4414
|
+
tag = keys[index];
|
|
4415
|
+
style = String(map2[tag]);
|
|
4416
|
+
if (tag.slice(0, 2) === "!!") {
|
|
4417
|
+
tag = "tag:yaml.org,2002:" + tag.slice(2);
|
|
4418
|
+
}
|
|
4419
|
+
type2 = schema2.compiledTypeMap["fallback"][tag];
|
|
4420
|
+
if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
|
|
4421
|
+
style = type2.styleAliases[style];
|
|
4422
|
+
}
|
|
4423
|
+
result[tag] = style;
|
|
4424
|
+
}
|
|
4425
|
+
return result;
|
|
4426
|
+
}
|
|
4427
|
+
function encodeHex(character) {
|
|
4428
|
+
var string, handle, length;
|
|
4429
|
+
string = character.toString(16).toUpperCase();
|
|
4430
|
+
if (character <= 255) {
|
|
4431
|
+
handle = "x";
|
|
4432
|
+
length = 2;
|
|
4433
|
+
} else if (character <= 65535) {
|
|
4434
|
+
handle = "u";
|
|
4435
|
+
length = 4;
|
|
4436
|
+
} else if (character <= 4294967295) {
|
|
4437
|
+
handle = "U";
|
|
4438
|
+
length = 8;
|
|
4439
|
+
} else {
|
|
4440
|
+
throw new exception("code point within a string may not be greater than 0xFFFFFFFF");
|
|
4441
|
+
}
|
|
4442
|
+
return "\\" + handle + common.repeat("0", length - string.length) + string;
|
|
4443
|
+
}
|
|
4444
|
+
var QUOTING_TYPE_SINGLE = 1;
|
|
4445
|
+
var QUOTING_TYPE_DOUBLE = 2;
|
|
4446
|
+
function State(options) {
|
|
4447
|
+
this.schema = options["schema"] || _default;
|
|
4448
|
+
this.indent = Math.max(1, options["indent"] || 2);
|
|
4449
|
+
this.noArrayIndent = options["noArrayIndent"] || false;
|
|
4450
|
+
this.skipInvalid = options["skipInvalid"] || false;
|
|
4451
|
+
this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
|
|
4452
|
+
this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
|
|
4453
|
+
this.sortKeys = options["sortKeys"] || false;
|
|
4454
|
+
this.lineWidth = options["lineWidth"] || 80;
|
|
4455
|
+
this.noRefs = options["noRefs"] || false;
|
|
4456
|
+
this.noCompatMode = options["noCompatMode"] || false;
|
|
4457
|
+
this.condenseFlow = options["condenseFlow"] || false;
|
|
4458
|
+
this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
|
|
4459
|
+
this.forceQuotes = options["forceQuotes"] || false;
|
|
4460
|
+
this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
|
|
4461
|
+
this.implicitTypes = this.schema.compiledImplicit;
|
|
4462
|
+
this.explicitTypes = this.schema.compiledExplicit;
|
|
4463
|
+
this.tag = null;
|
|
4464
|
+
this.result = "";
|
|
4465
|
+
this.duplicates = [];
|
|
4466
|
+
this.usedDuplicates = null;
|
|
4467
|
+
}
|
|
4468
|
+
function indentString(string, spaces) {
|
|
4469
|
+
var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
|
|
4470
|
+
while (position < length) {
|
|
4471
|
+
next = string.indexOf("\n", position);
|
|
4472
|
+
if (next === -1) {
|
|
4473
|
+
line = string.slice(position);
|
|
4474
|
+
position = length;
|
|
4475
|
+
} else {
|
|
4476
|
+
line = string.slice(position, next + 1);
|
|
4477
|
+
position = next + 1;
|
|
4478
|
+
}
|
|
4479
|
+
if (line.length && line !== "\n")
|
|
4480
|
+
result += ind;
|
|
4481
|
+
result += line;
|
|
4482
|
+
}
|
|
4483
|
+
return result;
|
|
4484
|
+
}
|
|
4485
|
+
function generateNextLine(state, level) {
|
|
4486
|
+
return "\n" + common.repeat(" ", state.indent * level);
|
|
4487
|
+
}
|
|
4488
|
+
function testImplicitResolving(state, str2) {
|
|
4489
|
+
var index, length, type2;
|
|
4490
|
+
for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
|
|
4491
|
+
type2 = state.implicitTypes[index];
|
|
4492
|
+
if (type2.resolve(str2)) {
|
|
4493
|
+
return true;
|
|
4494
|
+
}
|
|
4495
|
+
}
|
|
4496
|
+
return false;
|
|
4497
|
+
}
|
|
4498
|
+
function isWhitespace(c) {
|
|
4499
|
+
return c === CHAR_SPACE || c === CHAR_TAB;
|
|
4500
|
+
}
|
|
4501
|
+
function isPrintable(c) {
|
|
4502
|
+
return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
|
|
4503
|
+
}
|
|
4504
|
+
function isNsCharOrWhitespace(c) {
|
|
4505
|
+
return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
|
|
4506
|
+
}
|
|
4507
|
+
function isPlainSafe(c, prev, inblock) {
|
|
4508
|
+
var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
|
|
4509
|
+
var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
|
|
4510
|
+
return (inblock ? cIsNsCharOrWhitespace : 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;
|
|
4511
|
+
}
|
|
4512
|
+
function isPlainSafeFirst(c) {
|
|
4513
|
+
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;
|
|
4514
|
+
}
|
|
4515
|
+
function isPlainSafeLast(c) {
|
|
4516
|
+
return !isWhitespace(c) && c !== CHAR_COLON;
|
|
4517
|
+
}
|
|
4518
|
+
function codePointAt(string, pos) {
|
|
4519
|
+
var first = string.charCodeAt(pos), second;
|
|
4520
|
+
if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
|
|
4521
|
+
second = string.charCodeAt(pos + 1);
|
|
4522
|
+
if (second >= 56320 && second <= 57343) {
|
|
4523
|
+
return (first - 55296) * 1024 + second - 56320 + 65536;
|
|
4524
|
+
}
|
|
4525
|
+
}
|
|
4526
|
+
return first;
|
|
4527
|
+
}
|
|
4528
|
+
function needIndentIndicator(string) {
|
|
4529
|
+
var leadingSpaceRe = /^\n* /;
|
|
4530
|
+
return leadingSpaceRe.test(string);
|
|
4531
|
+
}
|
|
4532
|
+
var STYLE_PLAIN = 1;
|
|
4533
|
+
var STYLE_SINGLE = 2;
|
|
4534
|
+
var STYLE_LITERAL = 3;
|
|
4535
|
+
var STYLE_FOLDED = 4;
|
|
4536
|
+
var STYLE_DOUBLE = 5;
|
|
4537
|
+
function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
|
|
4538
|
+
var i;
|
|
4539
|
+
var char = 0;
|
|
4540
|
+
var prevChar = null;
|
|
4541
|
+
var hasLineBreak = false;
|
|
4542
|
+
var hasFoldableLine = false;
|
|
4543
|
+
var shouldTrackWidth = lineWidth !== -1;
|
|
4544
|
+
var previousLineBreak = -1;
|
|
4545
|
+
var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
|
|
4546
|
+
if (singleLineOnly || forceQuotes) {
|
|
4547
|
+
for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
4548
|
+
char = codePointAt(string, i);
|
|
4549
|
+
if (!isPrintable(char)) {
|
|
4550
|
+
return STYLE_DOUBLE;
|
|
4551
|
+
}
|
|
4552
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
4553
|
+
prevChar = char;
|
|
4554
|
+
}
|
|
4555
|
+
} else {
|
|
4556
|
+
for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
4557
|
+
char = codePointAt(string, i);
|
|
4558
|
+
if (char === CHAR_LINE_FEED) {
|
|
4559
|
+
hasLineBreak = true;
|
|
4560
|
+
if (shouldTrackWidth) {
|
|
4561
|
+
hasFoldableLine = hasFoldableLine || i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
|
|
4562
|
+
previousLineBreak = i;
|
|
4563
|
+
}
|
|
4564
|
+
} else if (!isPrintable(char)) {
|
|
4565
|
+
return STYLE_DOUBLE;
|
|
4566
|
+
}
|
|
4567
|
+
plain = plain && isPlainSafe(char, prevChar, inblock);
|
|
4568
|
+
prevChar = char;
|
|
4569
|
+
}
|
|
4570
|
+
hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
|
|
4571
|
+
}
|
|
4572
|
+
if (!hasLineBreak && !hasFoldableLine) {
|
|
4573
|
+
if (plain && !forceQuotes && !testAmbiguousType(string)) {
|
|
4574
|
+
return STYLE_PLAIN;
|
|
4575
|
+
}
|
|
4576
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
4577
|
+
}
|
|
4578
|
+
if (indentPerLevel > 9 && needIndentIndicator(string)) {
|
|
4579
|
+
return STYLE_DOUBLE;
|
|
4580
|
+
}
|
|
4581
|
+
if (!forceQuotes) {
|
|
4582
|
+
return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
|
|
4583
|
+
}
|
|
4584
|
+
return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
|
|
4585
|
+
}
|
|
4586
|
+
function writeScalar(state, string, level, iskey, inblock) {
|
|
4587
|
+
state.dump = function() {
|
|
4588
|
+
if (string.length === 0) {
|
|
4589
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
|
|
4590
|
+
}
|
|
4591
|
+
if (!state.noCompatMode) {
|
|
4592
|
+
if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
|
|
4593
|
+
return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
|
|
4594
|
+
}
|
|
4595
|
+
}
|
|
4596
|
+
var indent = state.indent * Math.max(1, level);
|
|
4597
|
+
var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
|
|
4598
|
+
var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
|
|
4599
|
+
function testAmbiguity(string2) {
|
|
4600
|
+
return testImplicitResolving(state, string2);
|
|
4601
|
+
}
|
|
4602
|
+
switch (chooseScalarStyle(string, singleLineOnly, state.indent, lineWidth, testAmbiguity, state.quotingType, state.forceQuotes && !iskey, inblock)) {
|
|
4603
|
+
case STYLE_PLAIN:
|
|
4604
|
+
return string;
|
|
4605
|
+
case STYLE_SINGLE:
|
|
4606
|
+
return "'" + string.replace(/'/g, "''") + "'";
|
|
4607
|
+
case STYLE_LITERAL:
|
|
4608
|
+
return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
|
|
4609
|
+
case STYLE_FOLDED:
|
|
4610
|
+
return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
|
|
4611
|
+
case STYLE_DOUBLE:
|
|
4612
|
+
return '"' + escapeString(string) + '"';
|
|
4613
|
+
default:
|
|
4614
|
+
throw new exception("impossible error: invalid scalar style");
|
|
4615
|
+
}
|
|
4616
|
+
}();
|
|
4617
|
+
}
|
|
4618
|
+
function blockHeader(string, indentPerLevel) {
|
|
4619
|
+
var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
|
|
4620
|
+
var clip = string[string.length - 1] === "\n";
|
|
4621
|
+
var keep = clip && (string[string.length - 2] === "\n" || string === "\n");
|
|
4622
|
+
var chomp = keep ? "+" : clip ? "" : "-";
|
|
4623
|
+
return indentIndicator + chomp + "\n";
|
|
4624
|
+
}
|
|
4625
|
+
function dropEndingNewline(string) {
|
|
4626
|
+
return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
|
|
4627
|
+
}
|
|
4628
|
+
function foldString(string, width) {
|
|
4629
|
+
var lineRe = /(\n+)([^\n]*)/g;
|
|
4630
|
+
var result = function() {
|
|
4631
|
+
var nextLF = string.indexOf("\n");
|
|
4632
|
+
nextLF = nextLF !== -1 ? nextLF : string.length;
|
|
4633
|
+
lineRe.lastIndex = nextLF;
|
|
4634
|
+
return foldLine(string.slice(0, nextLF), width);
|
|
4635
|
+
}();
|
|
4636
|
+
var prevMoreIndented = string[0] === "\n" || string[0] === " ";
|
|
4637
|
+
var moreIndented;
|
|
4638
|
+
var match;
|
|
4639
|
+
while (match = lineRe.exec(string)) {
|
|
4640
|
+
var prefix = match[1], line = match[2];
|
|
4641
|
+
moreIndented = line[0] === " ";
|
|
4642
|
+
result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
|
|
4643
|
+
prevMoreIndented = moreIndented;
|
|
4644
|
+
}
|
|
4645
|
+
return result;
|
|
4646
|
+
}
|
|
4647
|
+
function foldLine(line, width) {
|
|
4648
|
+
if (line === "" || line[0] === " ")
|
|
4649
|
+
return line;
|
|
4650
|
+
var breakRe = / [^ ]/g;
|
|
4651
|
+
var match;
|
|
4652
|
+
var start = 0, end, curr = 0, next = 0;
|
|
4653
|
+
var result = "";
|
|
4654
|
+
while (match = breakRe.exec(line)) {
|
|
4655
|
+
next = match.index;
|
|
4656
|
+
if (next - start > width) {
|
|
4657
|
+
end = curr > start ? curr : next;
|
|
4658
|
+
result += "\n" + line.slice(start, end);
|
|
4659
|
+
start = end + 1;
|
|
4660
|
+
}
|
|
4661
|
+
curr = next;
|
|
4662
|
+
}
|
|
4663
|
+
result += "\n";
|
|
4664
|
+
if (line.length - start > width && curr > start) {
|
|
4665
|
+
result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
|
|
4666
|
+
} else {
|
|
4667
|
+
result += line.slice(start);
|
|
4668
|
+
}
|
|
4669
|
+
return result.slice(1);
|
|
4670
|
+
}
|
|
4671
|
+
function escapeString(string) {
|
|
4672
|
+
var result = "";
|
|
4673
|
+
var char = 0;
|
|
4674
|
+
var escapeSeq;
|
|
4675
|
+
for (var i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
|
|
4676
|
+
char = codePointAt(string, i);
|
|
4677
|
+
escapeSeq = ESCAPE_SEQUENCES[char];
|
|
4678
|
+
if (!escapeSeq && isPrintable(char)) {
|
|
4679
|
+
result += string[i];
|
|
4680
|
+
if (char >= 65536)
|
|
4681
|
+
result += string[i + 1];
|
|
4682
|
+
} else {
|
|
4683
|
+
result += escapeSeq || encodeHex(char);
|
|
4684
|
+
}
|
|
4685
|
+
}
|
|
4686
|
+
return result;
|
|
4687
|
+
}
|
|
4688
|
+
function writeFlowSequence(state, level, object) {
|
|
4689
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
4690
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
4691
|
+
value = object[index];
|
|
4692
|
+
if (state.replacer) {
|
|
4693
|
+
value = state.replacer.call(object, String(index), value);
|
|
4694
|
+
}
|
|
4695
|
+
if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
|
|
4696
|
+
if (_result !== "")
|
|
4697
|
+
_result += "," + (!state.condenseFlow ? " " : "");
|
|
4698
|
+
_result += state.dump;
|
|
4699
|
+
}
|
|
4700
|
+
}
|
|
4701
|
+
state.tag = _tag;
|
|
4702
|
+
state.dump = "[" + _result + "]";
|
|
4703
|
+
}
|
|
4704
|
+
function writeBlockSequence(state, level, object, compact) {
|
|
4705
|
+
var _result = "", _tag = state.tag, index, length, value;
|
|
4706
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
4707
|
+
value = object[index];
|
|
4708
|
+
if (state.replacer) {
|
|
4709
|
+
value = state.replacer.call(object, String(index), value);
|
|
4710
|
+
}
|
|
4711
|
+
if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
|
|
4712
|
+
if (!compact || _result !== "") {
|
|
4713
|
+
_result += generateNextLine(state, level);
|
|
4714
|
+
}
|
|
4715
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
4716
|
+
_result += "-";
|
|
4717
|
+
} else {
|
|
4718
|
+
_result += "- ";
|
|
4719
|
+
}
|
|
4720
|
+
_result += state.dump;
|
|
4721
|
+
}
|
|
4722
|
+
}
|
|
4723
|
+
state.tag = _tag;
|
|
4724
|
+
state.dump = _result || "[]";
|
|
4725
|
+
}
|
|
4726
|
+
function writeFlowMapping(state, level, object) {
|
|
4727
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
|
|
4728
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
4729
|
+
pairBuffer = "";
|
|
4730
|
+
if (_result !== "")
|
|
4731
|
+
pairBuffer += ", ";
|
|
4732
|
+
if (state.condenseFlow)
|
|
4733
|
+
pairBuffer += '"';
|
|
4734
|
+
objectKey = objectKeyList[index];
|
|
4735
|
+
objectValue = object[objectKey];
|
|
4736
|
+
if (state.replacer) {
|
|
4737
|
+
objectValue = state.replacer.call(object, objectKey, objectValue);
|
|
4738
|
+
}
|
|
4739
|
+
if (!writeNode(state, level, objectKey, false, false)) {
|
|
4740
|
+
continue;
|
|
4741
|
+
}
|
|
4742
|
+
if (state.dump.length > 1024)
|
|
4743
|
+
pairBuffer += "? ";
|
|
4744
|
+
pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
|
|
4745
|
+
if (!writeNode(state, level, objectValue, false, false)) {
|
|
4746
|
+
continue;
|
|
4747
|
+
}
|
|
4748
|
+
pairBuffer += state.dump;
|
|
4749
|
+
_result += pairBuffer;
|
|
4750
|
+
}
|
|
4751
|
+
state.tag = _tag;
|
|
4752
|
+
state.dump = "{" + _result + "}";
|
|
4753
|
+
}
|
|
4754
|
+
function writeBlockMapping(state, level, object, compact) {
|
|
4755
|
+
var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
|
|
4756
|
+
if (state.sortKeys === true) {
|
|
4757
|
+
objectKeyList.sort();
|
|
4758
|
+
} else if (typeof state.sortKeys === "function") {
|
|
4759
|
+
objectKeyList.sort(state.sortKeys);
|
|
4760
|
+
} else if (state.sortKeys) {
|
|
4761
|
+
throw new exception("sortKeys must be a boolean or a function");
|
|
4762
|
+
}
|
|
4763
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
4764
|
+
pairBuffer = "";
|
|
4765
|
+
if (!compact || _result !== "") {
|
|
4766
|
+
pairBuffer += generateNextLine(state, level);
|
|
4767
|
+
}
|
|
4768
|
+
objectKey = objectKeyList[index];
|
|
4769
|
+
objectValue = object[objectKey];
|
|
4770
|
+
if (state.replacer) {
|
|
4771
|
+
objectValue = state.replacer.call(object, objectKey, objectValue);
|
|
4772
|
+
}
|
|
4773
|
+
if (!writeNode(state, level + 1, objectKey, true, true, true)) {
|
|
4774
|
+
continue;
|
|
4775
|
+
}
|
|
4776
|
+
explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
|
|
4777
|
+
if (explicitPair) {
|
|
4778
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
4779
|
+
pairBuffer += "?";
|
|
4780
|
+
} else {
|
|
4781
|
+
pairBuffer += "? ";
|
|
4782
|
+
}
|
|
4783
|
+
}
|
|
4784
|
+
pairBuffer += state.dump;
|
|
4785
|
+
if (explicitPair) {
|
|
4786
|
+
pairBuffer += generateNextLine(state, level);
|
|
4787
|
+
}
|
|
4788
|
+
if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
|
|
4789
|
+
continue;
|
|
4790
|
+
}
|
|
4791
|
+
if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
|
|
4792
|
+
pairBuffer += ":";
|
|
4793
|
+
} else {
|
|
4794
|
+
pairBuffer += ": ";
|
|
4795
|
+
}
|
|
4796
|
+
pairBuffer += state.dump;
|
|
4797
|
+
_result += pairBuffer;
|
|
4798
|
+
}
|
|
4799
|
+
state.tag = _tag;
|
|
4800
|
+
state.dump = _result || "{}";
|
|
4801
|
+
}
|
|
4802
|
+
function detectType(state, object, explicit) {
|
|
4803
|
+
var _result, typeList, index, length, type2, style;
|
|
4804
|
+
typeList = explicit ? state.explicitTypes : state.implicitTypes;
|
|
4805
|
+
for (index = 0, length = typeList.length; index < length; index += 1) {
|
|
4806
|
+
type2 = typeList[index];
|
|
4807
|
+
if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object === "object" && object instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object))) {
|
|
4808
|
+
if (explicit) {
|
|
4809
|
+
if (type2.multi && type2.representName) {
|
|
4810
|
+
state.tag = type2.representName(object);
|
|
4811
|
+
} else {
|
|
4812
|
+
state.tag = type2.tag;
|
|
4813
|
+
}
|
|
4814
|
+
} else {
|
|
4815
|
+
state.tag = "?";
|
|
4816
|
+
}
|
|
4817
|
+
if (type2.represent) {
|
|
4818
|
+
style = state.styleMap[type2.tag] || type2.defaultStyle;
|
|
4819
|
+
if (_toString.call(type2.represent) === "[object Function]") {
|
|
4820
|
+
_result = type2.represent(object, style);
|
|
4821
|
+
} else if (_hasOwnProperty.call(type2.represent, style)) {
|
|
4822
|
+
_result = type2.represent[style](object, style);
|
|
4823
|
+
} else {
|
|
4824
|
+
throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
|
|
4825
|
+
}
|
|
4826
|
+
state.dump = _result;
|
|
4827
|
+
}
|
|
4828
|
+
return true;
|
|
4829
|
+
}
|
|
4830
|
+
}
|
|
4831
|
+
return false;
|
|
4832
|
+
}
|
|
4833
|
+
function writeNode(state, level, object, block, compact, iskey, isblockseq) {
|
|
4834
|
+
state.tag = null;
|
|
4835
|
+
state.dump = object;
|
|
4836
|
+
if (!detectType(state, object, false)) {
|
|
4837
|
+
detectType(state, object, true);
|
|
4838
|
+
}
|
|
4839
|
+
var type2 = _toString.call(state.dump);
|
|
4840
|
+
var inblock = block;
|
|
4841
|
+
var tagStr;
|
|
4842
|
+
if (block) {
|
|
4843
|
+
block = state.flowLevel < 0 || state.flowLevel > level;
|
|
4844
|
+
}
|
|
4845
|
+
var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate;
|
|
4846
|
+
if (objectOrArray) {
|
|
4847
|
+
duplicateIndex = state.duplicates.indexOf(object);
|
|
4848
|
+
duplicate = duplicateIndex !== -1;
|
|
4849
|
+
}
|
|
4850
|
+
if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
|
|
4851
|
+
compact = false;
|
|
4852
|
+
}
|
|
4853
|
+
if (duplicate && state.usedDuplicates[duplicateIndex]) {
|
|
4854
|
+
state.dump = "*ref_" + duplicateIndex;
|
|
4855
|
+
} else {
|
|
4856
|
+
if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
|
|
4857
|
+
state.usedDuplicates[duplicateIndex] = true;
|
|
4858
|
+
}
|
|
4859
|
+
if (type2 === "[object Object]") {
|
|
4860
|
+
if (block && Object.keys(state.dump).length !== 0) {
|
|
4861
|
+
writeBlockMapping(state, level, state.dump, compact);
|
|
4862
|
+
if (duplicate) {
|
|
4863
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
4864
|
+
}
|
|
4865
|
+
} else {
|
|
4866
|
+
writeFlowMapping(state, level, state.dump);
|
|
4867
|
+
if (duplicate) {
|
|
4868
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
4869
|
+
}
|
|
4870
|
+
}
|
|
4871
|
+
} else if (type2 === "[object Array]") {
|
|
4872
|
+
if (block && state.dump.length !== 0) {
|
|
4873
|
+
if (state.noArrayIndent && !isblockseq && level > 0) {
|
|
4874
|
+
writeBlockSequence(state, level - 1, state.dump, compact);
|
|
4875
|
+
} else {
|
|
4876
|
+
writeBlockSequence(state, level, state.dump, compact);
|
|
4877
|
+
}
|
|
4878
|
+
if (duplicate) {
|
|
4879
|
+
state.dump = "&ref_" + duplicateIndex + state.dump;
|
|
4880
|
+
}
|
|
4881
|
+
} else {
|
|
4882
|
+
writeFlowSequence(state, level, state.dump);
|
|
4883
|
+
if (duplicate) {
|
|
4884
|
+
state.dump = "&ref_" + duplicateIndex + " " + state.dump;
|
|
4885
|
+
}
|
|
4886
|
+
}
|
|
4887
|
+
} else if (type2 === "[object String]") {
|
|
4888
|
+
if (state.tag !== "?") {
|
|
4889
|
+
writeScalar(state, state.dump, level, iskey, inblock);
|
|
4890
|
+
}
|
|
4891
|
+
} else if (type2 === "[object Undefined]") {
|
|
4892
|
+
return false;
|
|
4893
|
+
} else {
|
|
4894
|
+
if (state.skipInvalid)
|
|
4895
|
+
return false;
|
|
4896
|
+
throw new exception("unacceptable kind of an object to dump " + type2);
|
|
4897
|
+
}
|
|
4898
|
+
if (state.tag !== null && state.tag !== "?") {
|
|
4899
|
+
tagStr = encodeURI(state.tag[0] === "!" ? state.tag.slice(1) : state.tag).replace(/!/g, "%21");
|
|
4900
|
+
if (state.tag[0] === "!") {
|
|
4901
|
+
tagStr = "!" + tagStr;
|
|
4902
|
+
} else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
|
|
4903
|
+
tagStr = "!!" + tagStr.slice(18);
|
|
4904
|
+
} else {
|
|
4905
|
+
tagStr = "!<" + tagStr + ">";
|
|
4906
|
+
}
|
|
4907
|
+
state.dump = tagStr + " " + state.dump;
|
|
4908
|
+
}
|
|
4909
|
+
}
|
|
4910
|
+
return true;
|
|
4911
|
+
}
|
|
4912
|
+
function getDuplicateReferences(object, state) {
|
|
4913
|
+
var objects = [], duplicatesIndexes = [], index, length;
|
|
4914
|
+
inspectNode(object, objects, duplicatesIndexes);
|
|
4915
|
+
for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
|
|
4916
|
+
state.duplicates.push(objects[duplicatesIndexes[index]]);
|
|
4917
|
+
}
|
|
4918
|
+
state.usedDuplicates = new Array(length);
|
|
4919
|
+
}
|
|
4920
|
+
function inspectNode(object, objects, duplicatesIndexes) {
|
|
4921
|
+
var objectKeyList, index, length;
|
|
4922
|
+
if (object !== null && typeof object === "object") {
|
|
4923
|
+
index = objects.indexOf(object);
|
|
4924
|
+
if (index !== -1) {
|
|
4925
|
+
if (duplicatesIndexes.indexOf(index) === -1) {
|
|
4926
|
+
duplicatesIndexes.push(index);
|
|
4927
|
+
}
|
|
4928
|
+
} else {
|
|
4929
|
+
objects.push(object);
|
|
4930
|
+
if (Array.isArray(object)) {
|
|
4931
|
+
for (index = 0, length = object.length; index < length; index += 1) {
|
|
4932
|
+
inspectNode(object[index], objects, duplicatesIndexes);
|
|
4933
|
+
}
|
|
4934
|
+
} else {
|
|
4935
|
+
objectKeyList = Object.keys(object);
|
|
4936
|
+
for (index = 0, length = objectKeyList.length; index < length; index += 1) {
|
|
4937
|
+
inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
|
|
4938
|
+
}
|
|
4939
|
+
}
|
|
4940
|
+
}
|
|
4941
|
+
}
|
|
4942
|
+
}
|
|
4943
|
+
function dump$1(input, options) {
|
|
4944
|
+
options = options || {};
|
|
4945
|
+
var state = new State(options);
|
|
4946
|
+
if (!state.noRefs)
|
|
4947
|
+
getDuplicateReferences(input, state);
|
|
4948
|
+
var value = input;
|
|
4949
|
+
if (state.replacer) {
|
|
4950
|
+
value = state.replacer.call({ "": value }, "", value);
|
|
4951
|
+
}
|
|
4952
|
+
if (writeNode(state, 0, value, true, true))
|
|
4953
|
+
return state.dump + "\n";
|
|
4954
|
+
return "";
|
|
4955
|
+
}
|
|
4956
|
+
var dump_1 = dump$1;
|
|
4957
|
+
var dumper = {
|
|
4958
|
+
dump: dump_1
|
|
4959
|
+
};
|
|
4960
|
+
function renamed(from, to) {
|
|
4961
|
+
return function() {
|
|
4962
|
+
throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
|
|
4963
|
+
};
|
|
4964
|
+
}
|
|
4965
|
+
var Type = type;
|
|
4966
|
+
var Schema = schema;
|
|
4967
|
+
var FAILSAFE_SCHEMA = failsafe;
|
|
4968
|
+
var JSON_SCHEMA = json;
|
|
4969
|
+
var CORE_SCHEMA = core;
|
|
4970
|
+
var DEFAULT_SCHEMA = _default;
|
|
4971
|
+
var load = loader.load;
|
|
4972
|
+
var loadAll = loader.loadAll;
|
|
4973
|
+
var dump = dumper.dump;
|
|
4974
|
+
var YAMLException = exception;
|
|
4975
|
+
var types = {
|
|
4976
|
+
binary,
|
|
4977
|
+
float,
|
|
4978
|
+
map,
|
|
4979
|
+
null: _null,
|
|
4980
|
+
pairs,
|
|
4981
|
+
set,
|
|
4982
|
+
timestamp,
|
|
4983
|
+
bool,
|
|
4984
|
+
int,
|
|
4985
|
+
merge,
|
|
4986
|
+
omap,
|
|
4987
|
+
seq,
|
|
4988
|
+
str
|
|
4989
|
+
};
|
|
4990
|
+
var safeLoad = renamed("safeLoad", "load");
|
|
4991
|
+
var safeLoadAll = renamed("safeLoadAll", "loadAll");
|
|
4992
|
+
var safeDump = renamed("safeDump", "dump");
|
|
4993
|
+
var jsYaml = {
|
|
4994
|
+
Type,
|
|
4995
|
+
Schema,
|
|
4996
|
+
FAILSAFE_SCHEMA,
|
|
4997
|
+
JSON_SCHEMA,
|
|
4998
|
+
CORE_SCHEMA,
|
|
4999
|
+
DEFAULT_SCHEMA,
|
|
5000
|
+
load,
|
|
5001
|
+
loadAll,
|
|
5002
|
+
dump,
|
|
5003
|
+
YAMLException,
|
|
5004
|
+
types,
|
|
5005
|
+
safeLoad,
|
|
5006
|
+
safeLoadAll,
|
|
5007
|
+
safeDump
|
|
5008
|
+
};
|
|
5009
|
+
var js_yaml_default = jsYaml;
|
|
5010
|
+
|
|
5011
|
+
// ../parser/src/core.ts
|
|
5012
|
+
import { isObject as isObject2, isTruthy, objectMap } from "@antfu/utils";
|
|
5013
|
+
|
|
5014
|
+
// ../parser/src/config.ts
|
|
5015
|
+
init_esm_shims();
|
|
5016
|
+
import { toArray as toArray2, uniq as uniq2 } from "@antfu/utils";
|
|
5017
|
+
|
|
5018
|
+
// ../parser/src/utils.ts
|
|
5019
|
+
init_esm_shims();
|
|
5020
|
+
import { isNumber, range, uniq } from "@antfu/utils";
|
|
5021
|
+
function parseRangeString(total, rangeStr) {
|
|
5022
|
+
if (!rangeStr || rangeStr === "all" || rangeStr === "*")
|
|
5023
|
+
return range(1, total + 1);
|
|
5024
|
+
const pages = [];
|
|
5025
|
+
for (const part of rangeStr.split(/[,;]/g)) {
|
|
5026
|
+
if (!part.includes("-")) {
|
|
5027
|
+
pages.push(+part);
|
|
5028
|
+
} else {
|
|
5029
|
+
const [start, end] = part.split("-", 2);
|
|
5030
|
+
pages.push(...range(+start, !end ? total + 1 : +end + 1));
|
|
5031
|
+
}
|
|
5032
|
+
}
|
|
5033
|
+
return uniq(pages).filter((i) => i <= total).sort((a, b) => a - b);
|
|
5034
|
+
}
|
|
5035
|
+
function parseAspectRatio(str2) {
|
|
5036
|
+
if (isNumber(str2))
|
|
5037
|
+
return str2;
|
|
5038
|
+
if (!isNaN(+str2))
|
|
5039
|
+
return +str2;
|
|
5040
|
+
const [wStr = "", hStr = ""] = str2.split(/[:\/x\|]/);
|
|
5041
|
+
const w = parseFloat(wStr.trim());
|
|
5042
|
+
const h = parseFloat(hStr.trim());
|
|
5043
|
+
if (isNaN(w) || isNaN(h) || h === 0)
|
|
5044
|
+
throw new Error(`Invalid aspect ratio "${str2}"`);
|
|
5045
|
+
return w / h;
|
|
5046
|
+
}
|
|
5047
|
+
|
|
5048
|
+
// ../parser/src/config.ts
|
|
5049
|
+
function resolveConfig(headmatter, themeMeta = {}) {
|
|
5050
|
+
var _a, _b;
|
|
5051
|
+
const themeHightlighter = ["prism", "shiki"].includes(themeMeta.highlighter || "") ? themeMeta.highlighter : void 0;
|
|
5052
|
+
const themeColorSchema = ["light", "dark"].includes(themeMeta.colorSchema || "") ? themeMeta.colorSchema : void 0;
|
|
5053
|
+
const defaultConfig2 = {
|
|
5054
|
+
theme: "default",
|
|
5055
|
+
title: "Slidev",
|
|
5056
|
+
titleTemplate: "%s - Slidev",
|
|
5057
|
+
remoteAssets: false,
|
|
5058
|
+
monaco: "dev",
|
|
5059
|
+
download: false,
|
|
5060
|
+
info: false,
|
|
5061
|
+
highlighter: themeHightlighter || "prism",
|
|
5062
|
+
lineNumbers: false,
|
|
5063
|
+
colorSchema: themeColorSchema || "auto",
|
|
5064
|
+
routerMode: "history",
|
|
5065
|
+
aspectRatio: 16 / 9,
|
|
5066
|
+
canvasWidth: 980,
|
|
5067
|
+
selectable: false,
|
|
5068
|
+
themeConfig: {},
|
|
5069
|
+
fonts: {},
|
|
5070
|
+
favicon: "https://cdn.jsdelivr.net/gh/slidevjs/slidev/assets/favicon.png",
|
|
5071
|
+
drawings: {},
|
|
5072
|
+
plantUmlServer: "https://www.plantuml.com/plantuml"
|
|
5073
|
+
};
|
|
5074
|
+
const config2 = __spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, defaultConfig2), themeMeta.defaults), headmatter.config), headmatter), {
|
|
5075
|
+
fonts: resolveFonts(__spreadValues(__spreadValues(__spreadValues({}, (_a = themeMeta.defaults) == null ? void 0 : _a.fonts), (_b = headmatter.config) == null ? void 0 : _b.fonts), headmatter == null ? void 0 : headmatter.fonts)),
|
|
5076
|
+
drawings: resolveDarwings(headmatter.drawings)
|
|
5077
|
+
});
|
|
5078
|
+
if (config2.colorSchema !== "dark" && config2.colorSchema !== "light")
|
|
5079
|
+
config2.colorSchema = "auto";
|
|
5080
|
+
if (themeColorSchema && config2.colorSchema === "auto")
|
|
5081
|
+
config2.colorSchema = themeColorSchema;
|
|
5082
|
+
config2.aspectRatio = parseAspectRatio(config2.aspectRatio);
|
|
5083
|
+
if (themeColorSchema && config2.colorSchema !== themeColorSchema)
|
|
5084
|
+
console.warn(`[slidev] Color schema "${config2.colorSchema}" does not supported by the theme`);
|
|
5085
|
+
if (themeHightlighter && config2.highlighter !== themeHightlighter)
|
|
5086
|
+
console.warn(`[slidev] Syntax highlighter "${config2.highlighter}" does not supported by the theme`);
|
|
5087
|
+
return config2;
|
|
5088
|
+
}
|
|
5089
|
+
function resolveFonts(fonts = {}) {
|
|
5090
|
+
const {
|
|
5091
|
+
fallbacks = true,
|
|
5092
|
+
italic = false,
|
|
5093
|
+
provider = "google"
|
|
5094
|
+
} = fonts;
|
|
5095
|
+
let sans = toArray2(fonts.sans).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
5096
|
+
let serif = toArray2(fonts.serif).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
5097
|
+
let mono = toArray2(fonts.mono).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
5098
|
+
const weights = toArray2(fonts.weights || "200,400,600").flatMap((i) => i.toString().split(/,\s*/g)).map((i) => i.trim());
|
|
5099
|
+
const custom = toArray2(fonts.custom).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
5100
|
+
const local = toArray2(fonts.local).flatMap((i) => i.split(/,\s*/g)).map((i) => i.trim());
|
|
5101
|
+
const webfonts = fonts.webfonts ? fonts.webfonts : fallbacks ? uniq2([...sans, ...serif, ...mono, ...custom]) : [];
|
|
5102
|
+
webfonts.filter((i) => local.includes(i));
|
|
5103
|
+
function toQuoted(font) {
|
|
5104
|
+
if (/^(['"]).*\1$/.test(font))
|
|
5105
|
+
return font;
|
|
5106
|
+
return `"${font}"`;
|
|
5107
|
+
}
|
|
5108
|
+
if (fallbacks) {
|
|
5109
|
+
sans = uniq2([
|
|
5110
|
+
...sans.map(toQuoted),
|
|
5111
|
+
"ui-sans-serif",
|
|
5112
|
+
"system-ui",
|
|
5113
|
+
"-apple-system",
|
|
5114
|
+
"BlinkMacSystemFont",
|
|
5115
|
+
'"Segoe UI"',
|
|
5116
|
+
"Roboto",
|
|
5117
|
+
'"Helvetica Neue"',
|
|
5118
|
+
"Arial",
|
|
5119
|
+
'"Noto Sans"',
|
|
5120
|
+
"sans-serif",
|
|
5121
|
+
'"Apple Color Emoji"',
|
|
5122
|
+
'"Segoe UI Emoji"',
|
|
5123
|
+
'"Segoe UI Symbol"',
|
|
5124
|
+
'"Noto Color Emoji"'
|
|
5125
|
+
]);
|
|
5126
|
+
serif = uniq2([
|
|
5127
|
+
...serif.map(toQuoted),
|
|
5128
|
+
"ui-serif",
|
|
5129
|
+
"Georgia",
|
|
5130
|
+
"Cambria",
|
|
5131
|
+
'"Times New Roman"',
|
|
5132
|
+
"Times",
|
|
5133
|
+
"serif"
|
|
5134
|
+
]);
|
|
5135
|
+
mono = uniq2([
|
|
5136
|
+
...mono.map(toQuoted),
|
|
5137
|
+
"ui-monospace",
|
|
5138
|
+
"SFMono-Regular",
|
|
5139
|
+
"Menlo",
|
|
5140
|
+
"Monaco",
|
|
5141
|
+
"Consolas",
|
|
5142
|
+
'"Liberation Mono"',
|
|
5143
|
+
'"Courier New"',
|
|
5144
|
+
"monospace"
|
|
5145
|
+
]);
|
|
5146
|
+
}
|
|
5147
|
+
return {
|
|
5148
|
+
sans,
|
|
5149
|
+
serif,
|
|
5150
|
+
mono,
|
|
5151
|
+
webfonts,
|
|
5152
|
+
provider,
|
|
5153
|
+
local,
|
|
5154
|
+
italic,
|
|
5155
|
+
weights
|
|
5156
|
+
};
|
|
5157
|
+
}
|
|
5158
|
+
function resolveDarwings(options = {}) {
|
|
5159
|
+
const {
|
|
5160
|
+
enabled = true,
|
|
5161
|
+
persist = false,
|
|
5162
|
+
presenterOnly = false,
|
|
5163
|
+
syncAll = true
|
|
5164
|
+
} = options;
|
|
5165
|
+
const persistPath = typeof persist === "string" ? persist : persist ? ".slidev/drawings" : false;
|
|
5166
|
+
return {
|
|
5167
|
+
enabled,
|
|
5168
|
+
persist: persistPath,
|
|
5169
|
+
presenterOnly,
|
|
5170
|
+
syncAll
|
|
5171
|
+
};
|
|
5172
|
+
}
|
|
5173
|
+
|
|
5174
|
+
// ../parser/src/core.ts
|
|
5175
|
+
function stringify(data) {
|
|
5176
|
+
return `${data.slides.map((slide, idx) => stringifySlide(slide.inline || slide, idx)).join("\n").trim()}
|
|
5177
|
+
`;
|
|
5178
|
+
}
|
|
5179
|
+
function filterDisabled(data) {
|
|
5180
|
+
data.slides = data.slides.filter((i) => {
|
|
5181
|
+
var _a;
|
|
5182
|
+
return !((_a = i.frontmatter) == null ? void 0 : _a.disabled);
|
|
5183
|
+
});
|
|
5184
|
+
return data;
|
|
5185
|
+
}
|
|
5186
|
+
function stringifySlide(data, idx = 0) {
|
|
5187
|
+
if (data.raw == null)
|
|
5188
|
+
prettifySlide(data);
|
|
5189
|
+
return data.raw.startsWith("---") || idx === 0 ? data.raw : `---
|
|
5190
|
+
${data.raw.startsWith("\n") ? data.raw : `
|
|
5191
|
+
${data.raw}`}`;
|
|
5192
|
+
}
|
|
5193
|
+
function prettifySlide(data) {
|
|
5194
|
+
data.content = `
|
|
5195
|
+
${data.content.trim()}
|
|
5196
|
+
`;
|
|
5197
|
+
data.raw = Object.keys(data.frontmatter || {}).length ? `---
|
|
5198
|
+
${js_yaml_default.dump(data.frontmatter).trim()}
|
|
5199
|
+
---
|
|
5200
|
+
${data.content}` : data.content;
|
|
5201
|
+
if (data.note)
|
|
5202
|
+
data.raw += `
|
|
5203
|
+
<!--
|
|
5204
|
+
${data.note.trim()}
|
|
5205
|
+
-->
|
|
5206
|
+
`;
|
|
5207
|
+
else
|
|
5208
|
+
data.raw += "\n";
|
|
5209
|
+
return data;
|
|
5210
|
+
}
|
|
5211
|
+
function prettify(data) {
|
|
5212
|
+
data.slides.forEach(prettifySlide);
|
|
5213
|
+
return data;
|
|
5214
|
+
}
|
|
5215
|
+
function matter(code) {
|
|
5216
|
+
let data = {};
|
|
5217
|
+
const content = code.replace(/^---.*\r?\n([\s\S]*?)---/, (_, d) => {
|
|
5218
|
+
data = js_yaml_default.load(d);
|
|
5219
|
+
if (!isObject2(data))
|
|
5220
|
+
data = {};
|
|
5221
|
+
return "";
|
|
5222
|
+
});
|
|
5223
|
+
return { data, content };
|
|
5224
|
+
}
|
|
5225
|
+
function detectFeatures(code) {
|
|
5226
|
+
return {
|
|
5227
|
+
katex: !!code.match(/\$.*?\$/) || !!code.match(/$\$\$/),
|
|
5228
|
+
monaco: !!code.match(/{monaco.*}/),
|
|
5229
|
+
tweet: !!code.match(/<Tweet\b/),
|
|
5230
|
+
mermaid: !!code.match(/^```mermaid/m)
|
|
5231
|
+
};
|
|
5232
|
+
}
|
|
5233
|
+
function parseSlide(raw) {
|
|
5234
|
+
var _a, _b;
|
|
5235
|
+
const result = matter(raw);
|
|
5236
|
+
let note;
|
|
5237
|
+
const frontmatter = result.data || {};
|
|
5238
|
+
let content = result.content.trim();
|
|
5239
|
+
const comments = Array.from(content.matchAll(/<!--([\s\S]*?)-->/g));
|
|
5240
|
+
if (comments.length) {
|
|
5241
|
+
const last = comments[comments.length - 1];
|
|
5242
|
+
if (last.index && last.index + last[0].length >= content.length) {
|
|
5243
|
+
note = last[1].trim();
|
|
5244
|
+
content = content.slice(0, last.index).trim();
|
|
5245
|
+
}
|
|
5246
|
+
}
|
|
5247
|
+
let title;
|
|
5248
|
+
let level;
|
|
5249
|
+
if (frontmatter.title || frontmatter.name) {
|
|
5250
|
+
title = frontmatter.title || frontmatter.name;
|
|
5251
|
+
level = frontmatter.level || 1;
|
|
5252
|
+
} else {
|
|
5253
|
+
const match = content.match(/^(#+) (.*)$/m);
|
|
5254
|
+
title = (_a = match == null ? void 0 : match[2]) == null ? void 0 : _a.trim();
|
|
5255
|
+
level = (_b = match == null ? void 0 : match[1]) == null ? void 0 : _b.length;
|
|
5256
|
+
}
|
|
5257
|
+
return {
|
|
5258
|
+
raw,
|
|
5259
|
+
title,
|
|
5260
|
+
level,
|
|
5261
|
+
content,
|
|
5262
|
+
frontmatter,
|
|
5263
|
+
note
|
|
5264
|
+
};
|
|
5265
|
+
}
|
|
5266
|
+
function parse(markdown, filepath, themeMeta) {
|
|
5267
|
+
var _a, _b;
|
|
5268
|
+
const lines = markdown.split(/\r?\n/g);
|
|
5269
|
+
const slides = [];
|
|
5270
|
+
let start = 0;
|
|
5271
|
+
function slice(end) {
|
|
5272
|
+
if (start === end)
|
|
5273
|
+
return;
|
|
5274
|
+
const raw = lines.slice(start, end).join("\n");
|
|
5275
|
+
slides.push(__spreadProps(__spreadValues({}, parseSlide(raw)), {
|
|
5276
|
+
index: slides.length,
|
|
5277
|
+
start,
|
|
5278
|
+
end
|
|
5279
|
+
}));
|
|
5280
|
+
start = end + 1;
|
|
5281
|
+
}
|
|
5282
|
+
for (let i = 0; i < lines.length; i++) {
|
|
5283
|
+
const line = lines[i].trimEnd();
|
|
5284
|
+
if (line.match(/^---+/)) {
|
|
5285
|
+
slice(i);
|
|
5286
|
+
const next = lines[i + 1];
|
|
5287
|
+
if (line.match(/^---([^-].*)?$/) && !(next == null ? void 0 : next.match(/^\s*$/))) {
|
|
5288
|
+
start = i;
|
|
5289
|
+
for (i += 1; i < lines.length; i++) {
|
|
5290
|
+
if (lines[i].trimEnd().match(/^---$/))
|
|
5291
|
+
break;
|
|
5292
|
+
}
|
|
5293
|
+
}
|
|
5294
|
+
} else if (line.startsWith("```")) {
|
|
5295
|
+
for (i += 1; i < lines.length; i++) {
|
|
5296
|
+
if (lines[i].startsWith("```"))
|
|
5297
|
+
break;
|
|
5298
|
+
}
|
|
5299
|
+
}
|
|
5300
|
+
}
|
|
5301
|
+
if (start <= lines.length - 1)
|
|
5302
|
+
slice(lines.length);
|
|
5303
|
+
const headmatter = ((_a = slides[0]) == null ? void 0 : _a.frontmatter) || {};
|
|
5304
|
+
headmatter.title = headmatter.title || ((_b = slides[0]) == null ? void 0 : _b.title);
|
|
5305
|
+
const config2 = resolveConfig(headmatter, themeMeta);
|
|
5306
|
+
const features = detectFeatures(markdown);
|
|
5307
|
+
return {
|
|
5308
|
+
raw: markdown,
|
|
5309
|
+
filepath,
|
|
5310
|
+
slides,
|
|
5311
|
+
config: config2,
|
|
5312
|
+
features,
|
|
5313
|
+
headmatter,
|
|
5314
|
+
themeMeta
|
|
5315
|
+
};
|
|
5316
|
+
}
|
|
5317
|
+
function mergeFeatureFlags(a, b) {
|
|
5318
|
+
return objectMap(a, (k, v) => [k, v || b[k]]);
|
|
5319
|
+
}
|
|
5320
|
+
function scanMonacoModules(md2) {
|
|
5321
|
+
const typeModules = /* @__PURE__ */ new Set();
|
|
5322
|
+
md2.replace(/^```(\w+?)\s*{monaco([\w:,-]*)}[\s\n]*([\s\S]+?)^```/mg, (full, lang = "ts", options, code) => {
|
|
5323
|
+
options = options || "";
|
|
5324
|
+
lang = lang.trim();
|
|
5325
|
+
if (lang === "ts" || lang === "typescript") {
|
|
5326
|
+
Array.from(code.matchAll(/\s+from\s+(["'])([\/\w@-]+)\1/g)).map((i) => i[2]).filter(isTruthy).map((i) => typeModules.add(i));
|
|
5327
|
+
}
|
|
5328
|
+
return "";
|
|
5329
|
+
});
|
|
5330
|
+
return Array.from(typeModules);
|
|
5331
|
+
}
|
|
5332
|
+
|
|
5333
|
+
// ../parser/src/fs.ts
|
|
5334
|
+
var md = Markdown({ html: true });
|
|
5335
|
+
async function load2(filepath, themeMeta, content) {
|
|
5336
|
+
const dir = dirname(filepath);
|
|
5337
|
+
const markdown = content != null ? content : await fs.readFile(filepath, "utf-8");
|
|
5338
|
+
const data = parse(markdown, filepath, themeMeta);
|
|
5339
|
+
const entries = /* @__PURE__ */ new Set([
|
|
5340
|
+
filepath
|
|
5341
|
+
]);
|
|
5342
|
+
for (const slide of data.slides) {
|
|
5343
|
+
if (slide.title)
|
|
5344
|
+
slide.title = md.render(slide.title).trim().replace(/^<p>/, "").replace(/<\/p>$/, "");
|
|
5345
|
+
if (!slide.frontmatter.src)
|
|
5346
|
+
continue;
|
|
5347
|
+
const path3 = resolve(dir, slide.frontmatter.src);
|
|
5348
|
+
const raw = await fs.readFile(path3, "utf-8");
|
|
5349
|
+
const source = parseSlide(raw);
|
|
5350
|
+
const inline = __spreadValues({}, slide);
|
|
5351
|
+
slide.source = __spreadValues({
|
|
5352
|
+
filepath: path3
|
|
5353
|
+
}, source);
|
|
5354
|
+
slide.inline = inline;
|
|
5355
|
+
Object.assign(slide, slide.source);
|
|
5356
|
+
slide.frontmatter = __spreadValues(__spreadValues({}, slide.source.frontmatter), inline.frontmatter);
|
|
5357
|
+
data.features = mergeFeatureFlags(data.features, detectFeatures(raw));
|
|
5358
|
+
entries.add(path3);
|
|
5359
|
+
}
|
|
5360
|
+
data.entries = Array.from(entries);
|
|
5361
|
+
return data;
|
|
5362
|
+
}
|
|
5363
|
+
async function save(data, filepath) {
|
|
5364
|
+
filepath = filepath || data.filepath;
|
|
5365
|
+
await fs.writeFile(filepath, stringify(data), "utf-8");
|
|
5366
|
+
}
|
|
5367
|
+
async function saveExternalSlide(slide) {
|
|
5368
|
+
await fs.writeFile(slide.filepath, stringifySlide(slide), "utf-8");
|
|
5369
|
+
}
|
|
5370
|
+
|
|
5371
|
+
// node/parser.ts
|
|
5372
|
+
init_esm_shims();
|
|
5373
|
+
|
|
2327
5374
|
// package.json
|
|
2328
|
-
var version = "0.
|
|
5375
|
+
var version = "0.28.3";
|
|
2329
5376
|
|
|
2330
5377
|
// node/themes.ts
|
|
2331
5378
|
init_esm_shims();
|
|
@@ -2338,10 +5385,10 @@ init_esm_shims();
|
|
|
2338
5385
|
init_esm_shims();
|
|
2339
5386
|
import os from "os";
|
|
2340
5387
|
import { execSync } from "child_process";
|
|
2341
|
-
import
|
|
5388
|
+
import fs2 from "fs";
|
|
2342
5389
|
import path from "path";
|
|
2343
5390
|
import path2 from "path";
|
|
2344
|
-
import { resolve } from "path";
|
|
5391
|
+
import { resolve as resolve2 } from "path";
|
|
2345
5392
|
var __create = Object.create;
|
|
2346
5393
|
var __defProp = Object.defineProperty;
|
|
2347
5394
|
var __defProps = Object.defineProperties;
|
|
@@ -2353,7 +5400,7 @@ var __getProtoOf = Object.getPrototypeOf;
|
|
|
2353
5400
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
2354
5401
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
2355
5402
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2356
|
-
var
|
|
5403
|
+
var __spreadValues2 = (a, b) => {
|
|
2357
5404
|
for (var prop in b || (b = {}))
|
|
2358
5405
|
if (__hasOwnProp.call(b, prop))
|
|
2359
5406
|
__defNormalProp(a, prop, b[prop]);
|
|
@@ -2364,7 +5411,7 @@ var __spreadValues = (a, b) => {
|
|
|
2364
5411
|
}
|
|
2365
5412
|
return a;
|
|
2366
5413
|
};
|
|
2367
|
-
var
|
|
5414
|
+
var __spreadProps2 = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
2368
5415
|
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
2369
5416
|
var __require2 = (x) => {
|
|
2370
5417
|
if (typeof __require !== "undefined")
|
|
@@ -2469,11 +5516,11 @@ var require_mode = __commonJS2({
|
|
|
2469
5516
|
var require_isexe = __commonJS2({
|
|
2470
5517
|
"node_modules/.pnpm/isexe@2.0.0/node_modules/isexe/index.js"(exports, module) {
|
|
2471
5518
|
var fs22 = __require2("fs");
|
|
2472
|
-
var
|
|
5519
|
+
var core2;
|
|
2473
5520
|
if (process.platform === "win32" || global.TESTING_WINDOWS) {
|
|
2474
|
-
|
|
5521
|
+
core2 = require_windows();
|
|
2475
5522
|
} else {
|
|
2476
|
-
|
|
5523
|
+
core2 = require_mode();
|
|
2477
5524
|
}
|
|
2478
5525
|
module.exports = isexe;
|
|
2479
5526
|
isexe.sync = sync;
|
|
@@ -2496,7 +5543,7 @@ var require_isexe = __commonJS2({
|
|
|
2496
5543
|
});
|
|
2497
5544
|
});
|
|
2498
5545
|
}
|
|
2499
|
-
|
|
5546
|
+
core2(path3, options || {}, function(er, is) {
|
|
2500
5547
|
if (er) {
|
|
2501
5548
|
if (er.code === "EACCES" || options && options.ignoreErrors) {
|
|
2502
5549
|
er = null;
|
|
@@ -2508,7 +5555,7 @@ var require_isexe = __commonJS2({
|
|
|
2508
5555
|
}
|
|
2509
5556
|
function sync(path3, options) {
|
|
2510
5557
|
try {
|
|
2511
|
-
return
|
|
5558
|
+
return core2.sync(path3, options || {});
|
|
2512
5559
|
} catch (er) {
|
|
2513
5560
|
if (options && options.ignoreErrors || er.code === "EACCES") {
|
|
2514
5561
|
return false;
|
|
@@ -2644,17 +5691,17 @@ var require_kleur = __commonJS2({
|
|
|
2644
5691
|
bgCyan: init(46, 49),
|
|
2645
5692
|
bgWhite: init(47, 49)
|
|
2646
5693
|
};
|
|
2647
|
-
function run2(arr,
|
|
5694
|
+
function run2(arr, str2) {
|
|
2648
5695
|
let i = 0, tmp, beg = "", end = "";
|
|
2649
5696
|
for (; i < arr.length; i++) {
|
|
2650
5697
|
tmp = arr[i];
|
|
2651
5698
|
beg += tmp.open;
|
|
2652
5699
|
end += tmp.close;
|
|
2653
|
-
if (
|
|
2654
|
-
|
|
5700
|
+
if (str2.includes(tmp.close)) {
|
|
5701
|
+
str2 = str2.replace(tmp.rgx, tmp.close + tmp.open);
|
|
2655
5702
|
}
|
|
2656
5703
|
}
|
|
2657
|
-
return beg +
|
|
5704
|
+
return beg + str2 + end;
|
|
2658
5705
|
}
|
|
2659
5706
|
function chain(has, keys) {
|
|
2660
5707
|
let ctx = { has, keys };
|
|
@@ -2764,10 +5811,10 @@ var require_action = __commonJS2({
|
|
|
2764
5811
|
var require_strip = __commonJS2({
|
|
2765
5812
|
"node_modules/.pnpm/prompts@2.4.1/node_modules/prompts/dist/util/strip.js"(exports, module) {
|
|
2766
5813
|
"use strict";
|
|
2767
|
-
module.exports = (
|
|
5814
|
+
module.exports = (str2) => {
|
|
2768
5815
|
const pattern = ["[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)", "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"].join("|");
|
|
2769
5816
|
const RGX = new RegExp(pattern, "g");
|
|
2770
|
-
return typeof
|
|
5817
|
+
return typeof str2 === "string" ? str2.replace(RGX, "") : str2;
|
|
2771
5818
|
};
|
|
2772
5819
|
}
|
|
2773
5820
|
});
|
|
@@ -2896,7 +5943,7 @@ var require_clear = __commonJS2({
|
|
|
2896
5943
|
var _require = require_src();
|
|
2897
5944
|
var erase = _require.erase;
|
|
2898
5945
|
var cursor = _require.cursor;
|
|
2899
|
-
var width = (
|
|
5946
|
+
var width = (str2) => [...strip(str2)].length;
|
|
2900
5947
|
module.exports = function(prompt, perLine) {
|
|
2901
5948
|
if (!perLine)
|
|
2902
5949
|
return erase.line + cursor.to(0);
|
|
@@ -2975,7 +6022,7 @@ var require_style = __commonJS2({
|
|
|
2975
6022
|
render: (input) => `${input}`
|
|
2976
6023
|
}
|
|
2977
6024
|
});
|
|
2978
|
-
var render = (
|
|
6025
|
+
var render = (type2) => styles[type2] || styles.default;
|
|
2979
6026
|
var symbols = Object.freeze({
|
|
2980
6027
|
aborted: c.red(figures.cross),
|
|
2981
6028
|
done: c.green(figures.tick),
|
|
@@ -3080,10 +6127,10 @@ var require_prompt = __commonJS2({
|
|
|
3080
6127
|
if (this.in.isTTY)
|
|
3081
6128
|
this.in.setRawMode(true);
|
|
3082
6129
|
const isSelect = ["SelectPrompt", "MultiselectPrompt"].indexOf(this.constructor.name) > -1;
|
|
3083
|
-
const keypress = (
|
|
6130
|
+
const keypress = (str2, key) => {
|
|
3084
6131
|
let a = action(key, isSelect);
|
|
3085
6132
|
if (a === false) {
|
|
3086
|
-
this._ && this._(
|
|
6133
|
+
this._ && this._(str2, key);
|
|
3087
6134
|
} else if (typeof this[a] === "function") {
|
|
3088
6135
|
this[a](key);
|
|
3089
6136
|
} else {
|
|
@@ -4120,7 +7167,7 @@ var require_number = __commonJS2({
|
|
|
4120
7167
|
var figures = _require2.figures;
|
|
4121
7168
|
var clear = _require2.clear;
|
|
4122
7169
|
var lines = _require2.lines;
|
|
4123
|
-
var
|
|
7170
|
+
var isNumber2 = /[0-9]/;
|
|
4124
7171
|
var isDef = (any) => any !== void 0;
|
|
4125
7172
|
var round = (number, precision) => {
|
|
4126
7173
|
let factor = Math.pow(10, precision);
|
|
@@ -4164,7 +7211,7 @@ var require_number = __commonJS2({
|
|
|
4164
7211
|
return this.float ? parseFloat(x) : parseInt(x);
|
|
4165
7212
|
}
|
|
4166
7213
|
valid(c) {
|
|
4167
|
-
return c === `-` || c === `.` && this.float ||
|
|
7214
|
+
return c === `-` || c === `.` && this.float || isNumber2.test(c);
|
|
4168
7215
|
}
|
|
4169
7216
|
reset() {
|
|
4170
7217
|
this.typed = ``;
|
|
@@ -5055,9 +8102,9 @@ var require_prompts = __commonJS2({
|
|
|
5055
8102
|
var $ = exports;
|
|
5056
8103
|
var el = require_elements();
|
|
5057
8104
|
var noop = (v) => v;
|
|
5058
|
-
function toPrompt(
|
|
8105
|
+
function toPrompt(type2, args, opts = {}) {
|
|
5059
8106
|
return new Promise((res, rej) => {
|
|
5060
|
-
const p = new el[
|
|
8107
|
+
const p = new el[type2](args);
|
|
5061
8108
|
const onAbort = opts.onAbort || noop;
|
|
5062
8109
|
const onSubmit = opts.onSubmit || noop;
|
|
5063
8110
|
const onExit = opts.onExit || noop;
|
|
@@ -5082,7 +8129,7 @@ var require_prompts = __commonJS2({
|
|
|
5082
8129
|
$.list = (args) => {
|
|
5083
8130
|
const sep = args.separator || ",";
|
|
5084
8131
|
return toPrompt("TextPrompt", args, {
|
|
5085
|
-
onSubmit: (
|
|
8132
|
+
onSubmit: (str2) => str2.split(sep).map((s) => s.trim())
|
|
5086
8133
|
});
|
|
5087
8134
|
};
|
|
5088
8135
|
$.toggle = (args) => toPrompt("TogglePrompt", args);
|
|
@@ -5254,7 +8301,7 @@ var require_dist = __commonJS2({
|
|
|
5254
8301
|
const answers = {};
|
|
5255
8302
|
const override2 = prompt._override || {};
|
|
5256
8303
|
questions = [].concat(questions);
|
|
5257
|
-
let answer, question, quit, name,
|
|
8304
|
+
let answer, question, quit, name, type2, lastPrompt;
|
|
5258
8305
|
const getFormattedAnswer = /* @__PURE__ */ function() {
|
|
5259
8306
|
var _ref = _asyncToGenerator(function* (question2, answer2, skipValidation = false) {
|
|
5260
8307
|
if (!skipValidation && question2.validate && question2.validate(answer2) !== true) {
|
|
@@ -5272,12 +8319,12 @@ var require_dist = __commonJS2({
|
|
|
5272
8319
|
question = _step.value;
|
|
5273
8320
|
var _question = question;
|
|
5274
8321
|
name = _question.name;
|
|
5275
|
-
|
|
5276
|
-
if (typeof
|
|
5277
|
-
|
|
5278
|
-
question["type"] =
|
|
8322
|
+
type2 = _question.type;
|
|
8323
|
+
if (typeof type2 === "function") {
|
|
8324
|
+
type2 = yield type2(answer, _objectSpread({}, answers), question);
|
|
8325
|
+
question["type"] = type2;
|
|
5279
8326
|
}
|
|
5280
|
-
if (!
|
|
8327
|
+
if (!type2)
|
|
5281
8328
|
continue;
|
|
5282
8329
|
for (let key in question) {
|
|
5283
8330
|
if (passOn.includes(key))
|
|
@@ -5291,9 +8338,9 @@ var require_dist = __commonJS2({
|
|
|
5291
8338
|
}
|
|
5292
8339
|
var _question2 = question;
|
|
5293
8340
|
name = _question2.name;
|
|
5294
|
-
|
|
5295
|
-
if (prompts3[
|
|
5296
|
-
throw new Error(`prompt type (${
|
|
8341
|
+
type2 = _question2.type;
|
|
8342
|
+
if (prompts3[type2] === void 0) {
|
|
8343
|
+
throw new Error(`prompt type (${type2}) is not defined`);
|
|
5297
8344
|
}
|
|
5298
8345
|
if (override2[question.name] !== void 0) {
|
|
5299
8346
|
answer = yield getFormattedAnswer(question, override2[question.name]);
|
|
@@ -5303,7 +8350,7 @@ var require_dist = __commonJS2({
|
|
|
5303
8350
|
}
|
|
5304
8351
|
}
|
|
5305
8352
|
try {
|
|
5306
|
-
answer = prompt._injected ? getInjectedAnswer(prompt._injected, question.initial) : yield prompts3[
|
|
8353
|
+
answer = prompt._injected ? getInjectedAnswer(prompt._injected, question.initial) : yield prompts3[type2](question);
|
|
5307
8354
|
answers[name] = answer = yield getFormattedAnswer(question, answer, true);
|
|
5308
8355
|
quit = yield onSubmit(question, answer, answers);
|
|
5309
8356
|
} catch (err) {
|
|
@@ -5403,13 +8450,13 @@ var require_action2 = __commonJS2({
|
|
|
5403
8450
|
var require_strip2 = __commonJS2({
|
|
5404
8451
|
"node_modules/.pnpm/prompts@2.4.1/node_modules/prompts/lib/util/strip.js"(exports, module) {
|
|
5405
8452
|
"use strict";
|
|
5406
|
-
module.exports = (
|
|
8453
|
+
module.exports = (str2) => {
|
|
5407
8454
|
const pattern = [
|
|
5408
8455
|
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[a-zA-Z\\d]*)*)?\\u0007)",
|
|
5409
8456
|
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PRZcf-ntqry=><~]))"
|
|
5410
8457
|
].join("|");
|
|
5411
8458
|
const RGX = new RegExp(pattern, "g");
|
|
5412
|
-
return typeof
|
|
8459
|
+
return typeof str2 === "string" ? str2.replace(RGX, "") : str2;
|
|
5413
8460
|
};
|
|
5414
8461
|
}
|
|
5415
8462
|
});
|
|
@@ -5418,7 +8465,7 @@ var require_clear2 = __commonJS2({
|
|
|
5418
8465
|
"use strict";
|
|
5419
8466
|
var strip = require_strip2();
|
|
5420
8467
|
var { erase, cursor } = require_src();
|
|
5421
|
-
var width = (
|
|
8468
|
+
var width = (str2) => [...strip(str2)].length;
|
|
5422
8469
|
module.exports = function(prompt, perLine) {
|
|
5423
8470
|
if (!perLine)
|
|
5424
8471
|
return erase.line + cursor.to(0);
|
|
@@ -5477,7 +8524,7 @@ var require_style2 = __commonJS2({
|
|
|
5477
8524
|
invisible: { scale: 0, render: (input) => "" },
|
|
5478
8525
|
default: { scale: 1, render: (input) => `${input}` }
|
|
5479
8526
|
});
|
|
5480
|
-
var render = (
|
|
8527
|
+
var render = (type2) => styles[type2] || styles.default;
|
|
5481
8528
|
var symbols = Object.freeze({
|
|
5482
8529
|
aborted: c.red(figures.cross),
|
|
5483
8530
|
done: c.green(figures.tick),
|
|
@@ -5573,10 +8620,10 @@ var require_prompt2 = __commonJS2({
|
|
|
5573
8620
|
if (this.in.isTTY)
|
|
5574
8621
|
this.in.setRawMode(true);
|
|
5575
8622
|
const isSelect = ["SelectPrompt", "MultiselectPrompt"].indexOf(this.constructor.name) > -1;
|
|
5576
|
-
const keypress = (
|
|
8623
|
+
const keypress = (str2, key) => {
|
|
5577
8624
|
let a = action(key, isSelect);
|
|
5578
8625
|
if (a === false) {
|
|
5579
|
-
this._ && this._(
|
|
8626
|
+
this._ && this._(str2, key);
|
|
5580
8627
|
} else if (typeof this[a] === "function") {
|
|
5581
8628
|
this[a](key);
|
|
5582
8629
|
} else {
|
|
@@ -6479,7 +9526,7 @@ var require_number2 = __commonJS2({
|
|
|
6479
9526
|
var Prompt = require_prompt2();
|
|
6480
9527
|
var { cursor, erase } = require_src();
|
|
6481
9528
|
var { style, figures, clear, lines } = require_util2();
|
|
6482
|
-
var
|
|
9529
|
+
var isNumber2 = /[0-9]/;
|
|
6483
9530
|
var isDef = (any) => any !== void 0;
|
|
6484
9531
|
var round = (number, precision) => {
|
|
6485
9532
|
let factor = Math.pow(10, precision);
|
|
@@ -6523,7 +9570,7 @@ var require_number2 = __commonJS2({
|
|
|
6523
9570
|
return this.float ? parseFloat(x) : parseInt(x);
|
|
6524
9571
|
}
|
|
6525
9572
|
valid(c) {
|
|
6526
|
-
return c === `-` || c === `.` && this.float ||
|
|
9573
|
+
return c === `-` || c === `.` && this.float || isNumber2.test(c);
|
|
6527
9574
|
}
|
|
6528
9575
|
reset() {
|
|
6529
9576
|
this.typed = ``;
|
|
@@ -7360,9 +10407,9 @@ var require_prompts2 = __commonJS2({
|
|
|
7360
10407
|
var $ = exports;
|
|
7361
10408
|
var el = require_elements2();
|
|
7362
10409
|
var noop = (v) => v;
|
|
7363
|
-
function toPrompt(
|
|
10410
|
+
function toPrompt(type2, args, opts = {}) {
|
|
7364
10411
|
return new Promise((res, rej) => {
|
|
7365
|
-
const p = new el[
|
|
10412
|
+
const p = new el[type2](args);
|
|
7366
10413
|
const onAbort = opts.onAbort || noop;
|
|
7367
10414
|
const onSubmit = opts.onSubmit || noop;
|
|
7368
10415
|
const onExit = opts.onExit || noop;
|
|
@@ -7387,7 +10434,7 @@ var require_prompts2 = __commonJS2({
|
|
|
7387
10434
|
$.list = (args) => {
|
|
7388
10435
|
const sep = args.separator || ",";
|
|
7389
10436
|
return toPrompt("TextPrompt", args, {
|
|
7390
|
-
onSubmit: (
|
|
10437
|
+
onSubmit: (str2) => str2.split(sep).map((s) => s.trim())
|
|
7391
10438
|
});
|
|
7392
10439
|
};
|
|
7393
10440
|
$.toggle = (args) => toPrompt("TogglePrompt", args);
|
|
@@ -7427,7 +10474,7 @@ var require_lib = __commonJS2({
|
|
|
7427
10474
|
const answers = {};
|
|
7428
10475
|
const override2 = prompt._override || {};
|
|
7429
10476
|
questions = [].concat(questions);
|
|
7430
|
-
let answer, question, quit, name,
|
|
10477
|
+
let answer, question, quit, name, type2, lastPrompt;
|
|
7431
10478
|
const getFormattedAnswer = async (question2, answer2, skipValidation = false) => {
|
|
7432
10479
|
if (!skipValidation && question2.validate && question2.validate(answer2) !== true) {
|
|
7433
10480
|
return;
|
|
@@ -7435,26 +10482,26 @@ var require_lib = __commonJS2({
|
|
|
7435
10482
|
return question2.format ? await question2.format(answer2, answers) : answer2;
|
|
7436
10483
|
};
|
|
7437
10484
|
for (question of questions) {
|
|
7438
|
-
({ name, type } = question);
|
|
7439
|
-
if (typeof
|
|
7440
|
-
|
|
7441
|
-
question["type"] =
|
|
10485
|
+
({ name, type: type2 } = question);
|
|
10486
|
+
if (typeof type2 === "function") {
|
|
10487
|
+
type2 = await type2(answer, __spreadValues2({}, answers), question);
|
|
10488
|
+
question["type"] = type2;
|
|
7442
10489
|
}
|
|
7443
|
-
if (!
|
|
10490
|
+
if (!type2)
|
|
7444
10491
|
continue;
|
|
7445
10492
|
for (let key in question) {
|
|
7446
10493
|
if (passOn.includes(key))
|
|
7447
10494
|
continue;
|
|
7448
10495
|
let value = question[key];
|
|
7449
|
-
question[key] = typeof value === "function" ? await value(answer,
|
|
10496
|
+
question[key] = typeof value === "function" ? await value(answer, __spreadValues2({}, answers), lastPrompt) : value;
|
|
7450
10497
|
}
|
|
7451
10498
|
lastPrompt = question;
|
|
7452
10499
|
if (typeof question.message !== "string") {
|
|
7453
10500
|
throw new Error("prompt message is required");
|
|
7454
10501
|
}
|
|
7455
|
-
({ name, type } = question);
|
|
7456
|
-
if (prompts3[
|
|
7457
|
-
throw new Error(`prompt type (${
|
|
10502
|
+
({ name, type: type2 } = question);
|
|
10503
|
+
if (prompts3[type2] === void 0) {
|
|
10504
|
+
throw new Error(`prompt type (${type2}) is not defined`);
|
|
7458
10505
|
}
|
|
7459
10506
|
if (override2[question.name] !== void 0) {
|
|
7460
10507
|
answer = await getFormattedAnswer(question, override2[question.name]);
|
|
@@ -7464,7 +10511,7 @@ var require_lib = __commonJS2({
|
|
|
7464
10511
|
}
|
|
7465
10512
|
}
|
|
7466
10513
|
try {
|
|
7467
|
-
answer = prompt._injected ? getInjectedAnswer(prompt._injected, question.initial) : await prompts3[
|
|
10514
|
+
answer = prompt._injected ? getInjectedAnswer(prompt._injected, question.initial) : await prompts3[type2](question);
|
|
7468
10515
|
answers[name] = answer = await getFormattedAnswer(question, answer, true);
|
|
7469
10516
|
quit = await onSubmit(question, answer, answers);
|
|
7470
10517
|
} catch (err) {
|
|
@@ -7550,13 +10597,13 @@ var require_ini = __commonJS2({
|
|
|
7550
10597
|
}
|
|
7551
10598
|
return out;
|
|
7552
10599
|
};
|
|
7553
|
-
var dotSplit = (
|
|
7554
|
-
var decode = (
|
|
10600
|
+
var dotSplit = (str2) => str2.replace(/\1/g, "LITERAL\\1LITERAL").replace(/\\\./g, "").split(/\./).map((part) => part.replace(/\1/g, "\\.").replace(/\2LITERAL\\1LITERAL\2/g, ""));
|
|
10601
|
+
var decode = (str2) => {
|
|
7555
10602
|
const out = Object.create(null);
|
|
7556
10603
|
let p = out;
|
|
7557
10604
|
let section = null;
|
|
7558
10605
|
const re = /^\[([^\]]*)\]$|^([^=]+)(=(.*))?$/i;
|
|
7559
|
-
const lines =
|
|
10606
|
+
const lines = str2.split(/[\r\n]+/g);
|
|
7560
10607
|
for (const line of lines) {
|
|
7561
10608
|
if (!line || line.match(/^\s*[;#]/))
|
|
7562
10609
|
continue;
|
|
@@ -7785,7 +10832,7 @@ var require_p_locate = __commonJS2({
|
|
|
7785
10832
|
return false;
|
|
7786
10833
|
};
|
|
7787
10834
|
var pLocate = async (iterable, tester, options) => {
|
|
7788
|
-
options =
|
|
10835
|
+
options = __spreadValues2({
|
|
7789
10836
|
concurrency: Infinity,
|
|
7790
10837
|
preserveOrder: true
|
|
7791
10838
|
}, options);
|
|
@@ -7817,15 +10864,15 @@ var require_locate_path = __commonJS2({
|
|
|
7817
10864
|
directory: "isDirectory",
|
|
7818
10865
|
file: "isFile"
|
|
7819
10866
|
};
|
|
7820
|
-
function checkType({ type }) {
|
|
7821
|
-
if (
|
|
10867
|
+
function checkType({ type: type2 }) {
|
|
10868
|
+
if (type2 in typeMappings) {
|
|
7822
10869
|
return;
|
|
7823
10870
|
}
|
|
7824
|
-
throw new Error(`Invalid type specified: ${
|
|
10871
|
+
throw new Error(`Invalid type specified: ${type2}`);
|
|
7825
10872
|
}
|
|
7826
|
-
var matchType = (
|
|
10873
|
+
var matchType = (type2, stat) => type2 === void 0 || stat[typeMappings[type2]]();
|
|
7827
10874
|
module.exports = async (paths, options) => {
|
|
7828
|
-
options =
|
|
10875
|
+
options = __spreadValues2({
|
|
7829
10876
|
cwd: process.cwd(),
|
|
7830
10877
|
type: "file",
|
|
7831
10878
|
allowSymlinks: true
|
|
@@ -7842,7 +10889,7 @@ var require_locate_path = __commonJS2({
|
|
|
7842
10889
|
}, options);
|
|
7843
10890
|
};
|
|
7844
10891
|
module.exports.sync = (paths, options) => {
|
|
7845
|
-
options =
|
|
10892
|
+
options = __spreadValues2({
|
|
7846
10893
|
cwd: process.cwd(),
|
|
7847
10894
|
allowSymlinks: true,
|
|
7848
10895
|
type: "file"
|
|
@@ -7907,7 +10954,7 @@ var require_find_up = __commonJS2({
|
|
|
7907
10954
|
return foundPath;
|
|
7908
10955
|
};
|
|
7909
10956
|
while (true) {
|
|
7910
|
-
const foundPath = await runMatcher(
|
|
10957
|
+
const foundPath = await runMatcher(__spreadProps2(__spreadValues2({}, options), { cwd: directory }));
|
|
7911
10958
|
if (foundPath === stop) {
|
|
7912
10959
|
return;
|
|
7913
10960
|
}
|
|
@@ -7935,7 +10982,7 @@ var require_find_up = __commonJS2({
|
|
|
7935
10982
|
return foundPath;
|
|
7936
10983
|
};
|
|
7937
10984
|
while (true) {
|
|
7938
|
-
const foundPath = runMatcher(
|
|
10985
|
+
const foundPath = runMatcher(__spreadProps2(__spreadValues2({}, options), { cwd: directory }));
|
|
7939
10986
|
if (foundPath === stop) {
|
|
7940
10987
|
return;
|
|
7941
10988
|
}
|
|
@@ -8047,11 +11094,11 @@ var require_shebang_command = __commonJS2({
|
|
|
8047
11094
|
return null;
|
|
8048
11095
|
}
|
|
8049
11096
|
const [path3, argument] = match[0].replace(/#! ?/, "").split(" ");
|
|
8050
|
-
const
|
|
8051
|
-
if (
|
|
11097
|
+
const binary2 = path3.split("/").pop();
|
|
11098
|
+
if (binary2 === "env") {
|
|
8052
11099
|
return argument;
|
|
8053
11100
|
}
|
|
8054
|
-
return argument ? `${
|
|
11101
|
+
return argument ? `${binary2} ${argument}` : binary2;
|
|
8055
11102
|
};
|
|
8056
11103
|
}
|
|
8057
11104
|
});
|
|
@@ -8113,7 +11160,7 @@ var require_parse = __commonJS2({
|
|
|
8113
11160
|
}
|
|
8114
11161
|
return parsed;
|
|
8115
11162
|
}
|
|
8116
|
-
function
|
|
11163
|
+
function parse2(command, args, options) {
|
|
8117
11164
|
if (args && !Array.isArray(args)) {
|
|
8118
11165
|
options = args;
|
|
8119
11166
|
args = null;
|
|
@@ -8132,7 +11179,7 @@ var require_parse = __commonJS2({
|
|
|
8132
11179
|
};
|
|
8133
11180
|
return options.shell ? parsed : parseNonShell(parsed);
|
|
8134
11181
|
}
|
|
8135
|
-
module.exports =
|
|
11182
|
+
module.exports = parse2;
|
|
8136
11183
|
}
|
|
8137
11184
|
});
|
|
8138
11185
|
var require_enoent = __commonJS2({
|
|
@@ -8187,16 +11234,16 @@ var require_cross_spawn = __commonJS2({
|
|
|
8187
11234
|
"node_modules/.pnpm/cross-spawn@7.0.3/node_modules/cross-spawn/index.js"(exports, module) {
|
|
8188
11235
|
"use strict";
|
|
8189
11236
|
var cp = __require2("child_process");
|
|
8190
|
-
var
|
|
11237
|
+
var parse2 = require_parse();
|
|
8191
11238
|
var enoent = require_enoent();
|
|
8192
11239
|
function spawn(command, args, options) {
|
|
8193
|
-
const parsed =
|
|
11240
|
+
const parsed = parse2(command, args, options);
|
|
8194
11241
|
const spawned = cp.spawn(parsed.command, parsed.args, parsed.options);
|
|
8195
11242
|
enoent.hookChildProcess(spawned, parsed);
|
|
8196
11243
|
return spawned;
|
|
8197
11244
|
}
|
|
8198
11245
|
function spawnSync(command, args, options) {
|
|
8199
|
-
const parsed =
|
|
11246
|
+
const parsed = parse2(command, args, options);
|
|
8200
11247
|
const result = cp.spawnSync(parsed.command, parsed.args, parsed.options);
|
|
8201
11248
|
result.error = result.error || enoent.verifyENOENTSync(result.status, parsed);
|
|
8202
11249
|
return result;
|
|
@@ -8204,7 +11251,7 @@ var require_cross_spawn = __commonJS2({
|
|
|
8204
11251
|
module.exports = spawn;
|
|
8205
11252
|
module.exports.spawn = spawn;
|
|
8206
11253
|
module.exports.sync = spawnSync;
|
|
8207
|
-
module.exports._parse =
|
|
11254
|
+
module.exports._parse = parse2;
|
|
8208
11255
|
module.exports._enoent = enoent;
|
|
8209
11256
|
}
|
|
8210
11257
|
});
|
|
@@ -8230,7 +11277,7 @@ var require_npm_run_path = __commonJS2({
|
|
|
8230
11277
|
var path3 = __require2("path");
|
|
8231
11278
|
var pathKey = require_path_key();
|
|
8232
11279
|
var npmRunPath = (options) => {
|
|
8233
|
-
options =
|
|
11280
|
+
options = __spreadValues2({
|
|
8234
11281
|
cwd: process.cwd(),
|
|
8235
11282
|
path: process.env[pathKey()],
|
|
8236
11283
|
execPath: process.execPath
|
|
@@ -8250,10 +11297,10 @@ var require_npm_run_path = __commonJS2({
|
|
|
8250
11297
|
module.exports = npmRunPath;
|
|
8251
11298
|
module.exports.default = npmRunPath;
|
|
8252
11299
|
module.exports.env = (options) => {
|
|
8253
|
-
options =
|
|
11300
|
+
options = __spreadValues2({
|
|
8254
11301
|
env: process.env
|
|
8255
11302
|
}, options);
|
|
8256
|
-
const env =
|
|
11303
|
+
const env = __spreadValues2({}, options.env);
|
|
8257
11304
|
const path4 = pathKey({ env });
|
|
8258
11305
|
options.path = env[path4];
|
|
8259
11306
|
env[path4] = module.exports(options);
|
|
@@ -8657,7 +11704,7 @@ var require_main = __commonJS2({
|
|
|
8657
11704
|
return signals.reduce(getSignalByName, {});
|
|
8658
11705
|
};
|
|
8659
11706
|
var getSignalByName = function(signalByNameMemo, { name, number, description, supported, action, forced, standard }) {
|
|
8660
|
-
return
|
|
11707
|
+
return __spreadProps2(__spreadValues2({}, signalByNameMemo), {
|
|
8661
11708
|
[name]: { name, number, description, supported, action, forced, standard }
|
|
8662
11709
|
});
|
|
8663
11710
|
};
|
|
@@ -8855,7 +11902,7 @@ var require_signal_exit = __commonJS2({
|
|
|
8855
11902
|
module.exports = function(cb, opts) {
|
|
8856
11903
|
assert.equal(typeof cb, "function", "a callback must be provided for exit handler");
|
|
8857
11904
|
if (loaded === false) {
|
|
8858
|
-
|
|
11905
|
+
load3();
|
|
8859
11906
|
}
|
|
8860
11907
|
var ev = "exit";
|
|
8861
11908
|
if (opts && opts.alwaysLast) {
|
|
@@ -8911,9 +11958,9 @@ var require_signal_exit = __commonJS2({
|
|
|
8911
11958
|
module.exports.signals = function() {
|
|
8912
11959
|
return signals;
|
|
8913
11960
|
};
|
|
8914
|
-
module.exports.load =
|
|
11961
|
+
module.exports.load = load3;
|
|
8915
11962
|
var loaded = false;
|
|
8916
|
-
function
|
|
11963
|
+
function load3() {
|
|
8917
11964
|
if (loaded) {
|
|
8918
11965
|
return;
|
|
8919
11966
|
}
|
|
@@ -9057,7 +12104,7 @@ var require_buffer_stream = __commonJS2({
|
|
|
9057
12104
|
"use strict";
|
|
9058
12105
|
var { PassThrough: PassThroughStream } = __require2("stream");
|
|
9059
12106
|
module.exports = (options) => {
|
|
9060
|
-
options =
|
|
12107
|
+
options = __spreadValues2({}, options);
|
|
9061
12108
|
const { array } = options;
|
|
9062
12109
|
let { encoding } = options;
|
|
9063
12110
|
const isBuffer = encoding === "buffer";
|
|
@@ -9113,7 +12160,7 @@ var require_get_stream = __commonJS2({
|
|
|
9113
12160
|
if (!inputStream) {
|
|
9114
12161
|
throw new Error("Expected a stream");
|
|
9115
12162
|
}
|
|
9116
|
-
options =
|
|
12163
|
+
options = __spreadValues2({
|
|
9117
12164
|
maxBuffer: Infinity
|
|
9118
12165
|
}, options);
|
|
9119
12166
|
const { maxBuffer } = options;
|
|
@@ -9142,8 +12189,8 @@ var require_get_stream = __commonJS2({
|
|
|
9142
12189
|
return stream2.getBufferedValue();
|
|
9143
12190
|
}
|
|
9144
12191
|
module.exports = getStream;
|
|
9145
|
-
module.exports.buffer = (stream2, options) => getStream(stream2,
|
|
9146
|
-
module.exports.array = (stream2, options) => getStream(stream2,
|
|
12192
|
+
module.exports.buffer = (stream2, options) => getStream(stream2, __spreadProps2(__spreadValues2({}, options), { encoding: "buffer" }));
|
|
12193
|
+
module.exports.array = (stream2, options) => getStream(stream2, __spreadProps2(__spreadValues2({}, options), { array: true }));
|
|
9147
12194
|
module.exports.MaxBufferError = MaxBufferError;
|
|
9148
12195
|
}
|
|
9149
12196
|
});
|
|
@@ -9274,7 +12321,7 @@ var require_promise = __commonJS2({
|
|
|
9274
12321
|
var mergePromise = (spawned, promise) => {
|
|
9275
12322
|
for (const [property, descriptor] of descriptors) {
|
|
9276
12323
|
const value = typeof promise === "function" ? (...args) => Reflect.apply(descriptor.value, promise(), args) : descriptor.value.bind(promise);
|
|
9277
|
-
Reflect.defineProperty(spawned, property,
|
|
12324
|
+
Reflect.defineProperty(spawned, property, __spreadProps2(__spreadValues2({}, descriptor), { value }));
|
|
9278
12325
|
}
|
|
9279
12326
|
return spawned;
|
|
9280
12327
|
};
|
|
@@ -9359,7 +12406,7 @@ var require_execa = __commonJS2({
|
|
|
9359
12406
|
var { joinCommand, parseCommand, getEscapedCommand } = require_command();
|
|
9360
12407
|
var DEFAULT_MAX_BUFFER = 1e3 * 1e3 * 100;
|
|
9361
12408
|
var getEnv = ({ env: envOption, extendEnv, preferLocal, localDir, execPath }) => {
|
|
9362
|
-
const env = extendEnv ?
|
|
12409
|
+
const env = extendEnv ? __spreadValues2(__spreadValues2({}, process.env), envOption) : envOption;
|
|
9363
12410
|
if (preferLocal) {
|
|
9364
12411
|
return npmRunPath.env({ env, cwd: localDir, execPath });
|
|
9365
12412
|
}
|
|
@@ -9370,7 +12417,7 @@ var require_execa = __commonJS2({
|
|
|
9370
12417
|
file = parsed.command;
|
|
9371
12418
|
args = parsed.args;
|
|
9372
12419
|
options = parsed.options;
|
|
9373
|
-
options =
|
|
12420
|
+
options = __spreadValues2({
|
|
9374
12421
|
maxBuffer: DEFAULT_MAX_BUFFER,
|
|
9375
12422
|
buffer: true,
|
|
9376
12423
|
stripFinalNewline: true,
|
|
@@ -9552,7 +12599,7 @@ var require_execa = __commonJS2({
|
|
|
9552
12599
|
...nodeOptions,
|
|
9553
12600
|
scriptPath,
|
|
9554
12601
|
...Array.isArray(args) ? args : []
|
|
9555
|
-
],
|
|
12602
|
+
], __spreadProps2(__spreadValues2({}, options), {
|
|
9556
12603
|
stdin: void 0,
|
|
9557
12604
|
stdout: void 0,
|
|
9558
12605
|
stderr: void 0,
|
|
@@ -9874,14 +12921,14 @@ async function getConfig() {
|
|
|
9874
12921
|
const result = await (0, import_find_up.default)("package.json") || "";
|
|
9875
12922
|
let packageManager = "";
|
|
9876
12923
|
if (result)
|
|
9877
|
-
packageManager = (_a = JSON.parse(
|
|
12924
|
+
packageManager = (_a = JSON.parse(fs2.readFileSync(result, "utf8")).packageManager) != null ? _a : "";
|
|
9878
12925
|
const [, agent] = packageManager.match(new RegExp(`^(${Object.values(LOCKS).join("|")})@.*?$`)) || [];
|
|
9879
12926
|
if (agent)
|
|
9880
12927
|
config = Object.assign({}, defaultConfig, { defaultAgent: agent });
|
|
9881
|
-
else if (!
|
|
12928
|
+
else if (!fs2.existsSync(rcPath))
|
|
9882
12929
|
config = defaultConfig;
|
|
9883
12930
|
else
|
|
9884
|
-
config = Object.assign({}, defaultConfig, import_ini.default.parse(
|
|
12931
|
+
config = Object.assign({}, defaultConfig, import_ini.default.parse(fs2.readFileSync(rcPath, "utf-8")));
|
|
9885
12932
|
}
|
|
9886
12933
|
return config;
|
|
9887
12934
|
}
|
|
@@ -10023,7 +13070,7 @@ function terminalLink(text, url, _a = {}) {
|
|
|
10023
13070
|
return ansi_escapes_default.link(text, url);
|
|
10024
13071
|
}
|
|
10025
13072
|
terminalLink.isSupported = import_supports_hyperlinks.default.stdout;
|
|
10026
|
-
terminalLink.stderr = (text, url, options = {}) => terminalLink(text, url,
|
|
13073
|
+
terminalLink.stderr = (text, url, options = {}) => terminalLink(text, url, __spreadValues2({ target: "stderr" }, options));
|
|
10027
13074
|
terminalLink.stderr.isSupported = import_supports_hyperlinks.default.stderr;
|
|
10028
13075
|
var import_prompts = __toModule2(require_prompts3());
|
|
10029
13076
|
async function detect({ autoInstall, cwd }) {
|
|
@@ -10058,14 +13105,14 @@ async function run(fn, args, options = {}) {
|
|
|
10058
13105
|
let cwd = process.cwd();
|
|
10059
13106
|
let command;
|
|
10060
13107
|
if (args[0] === "-C") {
|
|
10061
|
-
cwd =
|
|
13108
|
+
cwd = resolve2(cwd, args[1]);
|
|
10062
13109
|
args.splice(0, 2);
|
|
10063
13110
|
}
|
|
10064
13111
|
const isGlobal = args.includes("-g");
|
|
10065
13112
|
if (isGlobal) {
|
|
10066
13113
|
command = await fn(await getGlobalAgent(), args);
|
|
10067
13114
|
} else {
|
|
10068
|
-
let agent = await detect(
|
|
13115
|
+
let agent = await detect(__spreadProps2(__spreadValues2({}, options), { cwd })) || await getDefaultAgent();
|
|
10069
13116
|
if (agent === "prompt") {
|
|
10070
13117
|
agent = (await (0, import_prompts2.default)({
|
|
10071
13118
|
name: "agent",
|
|
@@ -10097,20 +13144,19 @@ async function run(fn, args, options = {}) {
|
|
|
10097
13144
|
var import_semver = __toModule(require_semver2());
|
|
10098
13145
|
import isInstalledGlobally from "is-installed-globally";
|
|
10099
13146
|
import { underline } from "kolorist";
|
|
10100
|
-
import
|
|
13147
|
+
import fs3 from "fs-extra";
|
|
10101
13148
|
|
|
10102
13149
|
// node/options.ts
|
|
10103
13150
|
init_esm_shims();
|
|
10104
|
-
import {
|
|
10105
|
-
import { uniq } from "@antfu/utils";
|
|
10106
|
-
import * as parser from "@slidev/parser/fs";
|
|
13151
|
+
import { dirname as dirname2, join, resolve as resolve3 } from "path";
|
|
13152
|
+
import { uniq as uniq3 } from "@antfu/utils";
|
|
10107
13153
|
import _debug from "debug";
|
|
10108
13154
|
var debug = _debug("slidev:options");
|
|
10109
13155
|
function getClientRoot() {
|
|
10110
|
-
return
|
|
13156
|
+
return dirname2(resolveImportPath("@slidev/client/package.json", true));
|
|
10111
13157
|
}
|
|
10112
13158
|
function getCLIRoot() {
|
|
10113
|
-
return
|
|
13159
|
+
return resolve3(__dirname, "..");
|
|
10114
13160
|
}
|
|
10115
13161
|
function isPath(name) {
|
|
10116
13162
|
return name.startsWith("/") || /^\.\.?[\/\\]/.test(name);
|
|
@@ -10120,25 +13166,25 @@ function getThemeRoots(name, entry) {
|
|
|
10120
13166
|
return [];
|
|
10121
13167
|
if (isPath(name)) {
|
|
10122
13168
|
return [
|
|
10123
|
-
|
|
13169
|
+
resolve3(dirname2(entry), name)
|
|
10124
13170
|
];
|
|
10125
13171
|
} else {
|
|
10126
13172
|
return [
|
|
10127
|
-
|
|
13173
|
+
dirname2(resolveImportPath(`${name}/package.json`, true))
|
|
10128
13174
|
];
|
|
10129
13175
|
}
|
|
10130
13176
|
}
|
|
10131
13177
|
function getUserRoot(options) {
|
|
10132
13178
|
const { entry: rawEntry = "slides.md", userRoot = process.cwd() } = options;
|
|
10133
|
-
const fullEntry =
|
|
10134
|
-
return { entry: fullEntry, userRoot:
|
|
13179
|
+
const fullEntry = resolve3(userRoot, rawEntry);
|
|
13180
|
+
return { entry: fullEntry, userRoot: dirname2(fullEntry) };
|
|
10135
13181
|
}
|
|
10136
13182
|
async function resolveOptions(options, mode, promptForInstallation = true) {
|
|
10137
13183
|
const {
|
|
10138
13184
|
entry,
|
|
10139
13185
|
userRoot
|
|
10140
13186
|
} = getUserRoot(options);
|
|
10141
|
-
const data = await
|
|
13187
|
+
const data = await fs_exports.load(entry);
|
|
10142
13188
|
const theme = resolveThemeName(options.theme || data.config.theme);
|
|
10143
13189
|
if (promptForInstallation) {
|
|
10144
13190
|
if (await promptForThemeInstallation(theme) === false)
|
|
@@ -10152,12 +13198,12 @@ async function resolveOptions(options, mode, promptForInstallation = true) {
|
|
|
10152
13198
|
const clientRoot = getClientRoot();
|
|
10153
13199
|
const cliRoot = getCLIRoot();
|
|
10154
13200
|
const themeRoots = getThemeRoots(theme, entry);
|
|
10155
|
-
const roots =
|
|
13201
|
+
const roots = uniq3([clientRoot, ...themeRoots, userRoot]);
|
|
10156
13202
|
if (themeRoots.length) {
|
|
10157
13203
|
const themeMeta = await getThemeMeta(theme, join(themeRoots[0], "package.json"));
|
|
10158
13204
|
data.themeMeta = themeMeta;
|
|
10159
13205
|
if (themeMeta)
|
|
10160
|
-
data.config =
|
|
13206
|
+
data.config = fs_exports.resolveConfig(data.headmatter, themeMeta);
|
|
10161
13207
|
}
|
|
10162
13208
|
debug({
|
|
10163
13209
|
config: data.config,
|
|
@@ -10198,10 +13244,10 @@ function packageExists(name) {
|
|
|
10198
13244
|
return false;
|
|
10199
13245
|
}
|
|
10200
13246
|
async function getThemeMeta(name, path3) {
|
|
10201
|
-
if (!
|
|
13247
|
+
if (!fs3.existsSync(path3))
|
|
10202
13248
|
return {};
|
|
10203
13249
|
if (path3) {
|
|
10204
|
-
const { slidev = {}, engines = {} } = await
|
|
13250
|
+
const { slidev = {}, engines = {} } = await fs3.readJSON(path3);
|
|
10205
13251
|
if (engines.slidev && !(0, import_semver.satisfies)(version, engines.slidev))
|
|
10206
13252
|
throw new Error(`[slidev] theme "${name}" requires Slidev version range "${engines.slidev}" but found "${version}"`);
|
|
10207
13253
|
return slidev;
|
|
@@ -10245,6 +13291,7 @@ async function promptForThemeInstallation(name) {
|
|
|
10245
13291
|
}
|
|
10246
13292
|
|
|
10247
13293
|
export {
|
|
13294
|
+
fs_exports,
|
|
10248
13295
|
version,
|
|
10249
13296
|
packageExists,
|
|
10250
13297
|
resolveThemeName,
|
|
@@ -10255,3 +13302,4 @@ export {
|
|
|
10255
13302
|
getUserRoot,
|
|
10256
13303
|
resolveOptions
|
|
10257
13304
|
};
|
|
13305
|
+
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
|