@wp-playground/blueprints 0.7.0 → 0.7.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/index.cjs +22 -26
- package/index.d.ts +23 -15
- package/index.js +1212 -1412
- package/lib/steps/request.d.ts +1 -0
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
var
|
|
1
|
+
var vt = (e, t, r) => {
|
|
2
2
|
if (!t.has(e))
|
|
3
3
|
throw TypeError("Cannot " + r);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
5
|
+
var se = (e, t, r) => (vt(e, t, "read from private field"), r ? r.call(e) : t.get(e)), ee = (e, t, r) => {
|
|
6
6
|
if (t.has(e))
|
|
7
7
|
throw TypeError("Cannot add the same private member more than once");
|
|
8
8
|
t instanceof WeakSet ? t.add(e) : t.set(e, r);
|
|
9
|
-
},
|
|
10
|
-
var
|
|
9
|
+
}, fe = (e, t, r, n) => (vt(e, t, "write to private field"), n ? n.call(e, r) : t.set(e, r), r);
|
|
10
|
+
var ae = (e, t, r) => (vt(e, t, "access private method"), r);
|
|
11
11
|
const currentJsRuntime = function() {
|
|
12
12
|
var e;
|
|
13
13
|
return typeof process < "u" && ((e = process.release) == null ? void 0 : e.name) === "node" ? "NODE" : typeof window < "u" ? "WEB" : (
|
|
@@ -200,7 +200,12 @@ function createSpawnHandler(e) {
|
|
|
200
200
|
o = t;
|
|
201
201
|
else
|
|
202
202
|
throw new Error("Invalid command ", t);
|
|
203
|
-
|
|
203
|
+
try {
|
|
204
|
+
await e(o, i, n);
|
|
205
|
+
} catch (l) {
|
|
206
|
+
s.emit("error", l), typeof l == "object" && l !== null && "message" in l && typeof l.message == "string" && i.stderr(l.message), i.exit(1);
|
|
207
|
+
}
|
|
208
|
+
s.emit("spawn", !0);
|
|
204
209
|
}), s;
|
|
205
210
|
};
|
|
206
211
|
}
|
|
@@ -362,10 +367,177 @@ switch_theme( ${phpVar(t)} );
|
|
|
362
367
|
`
|
|
363
368
|
});
|
|
364
369
|
return await rm(e, { path: n }), o;
|
|
370
|
+
}, logToConsole = (e, ...t) => {
|
|
371
|
+
switch (e.severity) {
|
|
372
|
+
case "Debug":
|
|
373
|
+
console.debug(e.message, ...t);
|
|
374
|
+
break;
|
|
375
|
+
case "Info":
|
|
376
|
+
console.info(e.message, ...t);
|
|
377
|
+
break;
|
|
378
|
+
case "Warn":
|
|
379
|
+
console.warn(e.message, ...t);
|
|
380
|
+
break;
|
|
381
|
+
case "Error":
|
|
382
|
+
console.error(e.message, ...t);
|
|
383
|
+
break;
|
|
384
|
+
case "Fatal":
|
|
385
|
+
console.error(e.message, ...t);
|
|
386
|
+
break;
|
|
387
|
+
default:
|
|
388
|
+
console.log(e.message, ...t);
|
|
389
|
+
}
|
|
390
|
+
}, prepareLogMessage = (e, ...t) => [
|
|
391
|
+
typeof e == "object" ? JSON.stringify(e) : e,
|
|
392
|
+
...t.map((r) => JSON.stringify(r))
|
|
393
|
+
].join(" "), logs = [], addToLogArray = (e) => {
|
|
394
|
+
logs.push(e);
|
|
395
|
+
}, logToMemory = (e) => {
|
|
396
|
+
if (e.raw === !0)
|
|
397
|
+
addToLogArray(e.message);
|
|
398
|
+
else {
|
|
399
|
+
const t = formatLogEntry(
|
|
400
|
+
typeof e.message == "object" ? prepareLogMessage(e.message) : e.message,
|
|
401
|
+
e.severity ?? "Info",
|
|
402
|
+
e.prefix ?? "JavaScript"
|
|
403
|
+
);
|
|
404
|
+
addToLogArray(t);
|
|
405
|
+
}
|
|
406
|
+
};
|
|
407
|
+
class Logger extends EventTarget {
|
|
408
|
+
// constructor
|
|
409
|
+
constructor(t = []) {
|
|
410
|
+
super(), this.handlers = t, this.fatalErrorEvent = "playground-fatal-error";
|
|
411
|
+
}
|
|
412
|
+
/**
|
|
413
|
+
* Get all logs.
|
|
414
|
+
* @returns string[]
|
|
415
|
+
*/
|
|
416
|
+
getLogs() {
|
|
417
|
+
return this.handlers.includes(logToMemory) ? [...logs] : (this.error(`Logs aren't stored because the logToMemory handler isn't registered.
|
|
418
|
+
If you're using a custom logger instance, make sure to register logToMemory handler.
|
|
419
|
+
`), []);
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* Log message with severity.
|
|
423
|
+
*
|
|
424
|
+
* @param message any
|
|
425
|
+
* @param severity LogSeverity
|
|
426
|
+
* @param raw boolean
|
|
427
|
+
* @param args any
|
|
428
|
+
*/
|
|
429
|
+
logMessage(t, ...r) {
|
|
430
|
+
for (const n of this.handlers)
|
|
431
|
+
n(t, ...r);
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Log message
|
|
435
|
+
*
|
|
436
|
+
* @param message any
|
|
437
|
+
* @param args any
|
|
438
|
+
*/
|
|
439
|
+
log(t, ...r) {
|
|
440
|
+
this.logMessage(
|
|
441
|
+
{
|
|
442
|
+
message: t,
|
|
443
|
+
severity: void 0,
|
|
444
|
+
prefix: "JavaScript",
|
|
445
|
+
raw: !1
|
|
446
|
+
},
|
|
447
|
+
...r
|
|
448
|
+
);
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Log debug message
|
|
452
|
+
*
|
|
453
|
+
* @param message any
|
|
454
|
+
* @param args any
|
|
455
|
+
*/
|
|
456
|
+
debug(t, ...r) {
|
|
457
|
+
this.logMessage(
|
|
458
|
+
{
|
|
459
|
+
message: t,
|
|
460
|
+
severity: "Debug",
|
|
461
|
+
prefix: "JavaScript",
|
|
462
|
+
raw: !1
|
|
463
|
+
},
|
|
464
|
+
...r
|
|
465
|
+
);
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Log info message
|
|
469
|
+
*
|
|
470
|
+
* @param message any
|
|
471
|
+
* @param args any
|
|
472
|
+
*/
|
|
473
|
+
info(t, ...r) {
|
|
474
|
+
this.logMessage(
|
|
475
|
+
{
|
|
476
|
+
message: t,
|
|
477
|
+
severity: "Info",
|
|
478
|
+
prefix: "JavaScript",
|
|
479
|
+
raw: !1
|
|
480
|
+
},
|
|
481
|
+
...r
|
|
482
|
+
);
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* Log warning message
|
|
486
|
+
*
|
|
487
|
+
* @param message any
|
|
488
|
+
* @param args any
|
|
489
|
+
*/
|
|
490
|
+
warn(t, ...r) {
|
|
491
|
+
this.logMessage(
|
|
492
|
+
{
|
|
493
|
+
message: t,
|
|
494
|
+
severity: "Warn",
|
|
495
|
+
prefix: "JavaScript",
|
|
496
|
+
raw: !1
|
|
497
|
+
},
|
|
498
|
+
...r
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Log error message
|
|
503
|
+
*
|
|
504
|
+
* @param message any
|
|
505
|
+
* @param args any
|
|
506
|
+
*/
|
|
507
|
+
error(t, ...r) {
|
|
508
|
+
this.logMessage(
|
|
509
|
+
{
|
|
510
|
+
message: t,
|
|
511
|
+
severity: "Error",
|
|
512
|
+
prefix: "JavaScript",
|
|
513
|
+
raw: !1
|
|
514
|
+
},
|
|
515
|
+
...r
|
|
516
|
+
);
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
const logger = new Logger([logToMemory, logToConsole]), formatLogEntry = (e, t, r) => {
|
|
520
|
+
const n = /* @__PURE__ */ new Date(), s = new Intl.DateTimeFormat("en-GB", {
|
|
521
|
+
year: "numeric",
|
|
522
|
+
month: "short",
|
|
523
|
+
day: "2-digit",
|
|
524
|
+
timeZone: "UTC"
|
|
525
|
+
}).format(n).replace(/ /g, "-"), i = new Intl.DateTimeFormat("en-GB", {
|
|
526
|
+
hour: "2-digit",
|
|
527
|
+
minute: "2-digit",
|
|
528
|
+
second: "2-digit",
|
|
529
|
+
hour12: !1,
|
|
530
|
+
timeZone: "UTC",
|
|
531
|
+
timeZoneName: "short"
|
|
532
|
+
}).format(n);
|
|
533
|
+
return `[${s + " " + i}] ${r} ${t}: ${e}`;
|
|
365
534
|
}, request = async (e, { request: t }) => {
|
|
535
|
+
logger.warn(
|
|
536
|
+
'Deprecated: The Blueprint step "request" is deprecated and will be removed in a future release.'
|
|
537
|
+
);
|
|
366
538
|
const r = await e.request(t);
|
|
367
539
|
if (r.httpStatusCode > 399 || r.httpStatusCode < 200)
|
|
368
|
-
throw
|
|
540
|
+
throw logger.warn("WordPress response was", { response: r }), new Error(
|
|
369
541
|
`Request failed with status ${r.httpStatusCode}`
|
|
370
542
|
);
|
|
371
543
|
return r;
|
|
@@ -751,7 +923,7 @@ const login = async (e, { username: t = "admin", password: r = "password" } = {}
|
|
|
751
923
|
}
|
|
752
924
|
});
|
|
753
925
|
if (!((l = (o = (i = s.headers) == null ? void 0 : i.location) == null ? void 0 : o[0]) != null && l.includes("/wp-admin/")))
|
|
754
|
-
throw
|
|
926
|
+
throw logger.warn("WordPress response was", {
|
|
755
927
|
response: s,
|
|
756
928
|
text: s.text
|
|
757
929
|
}), new Error(
|
|
@@ -859,7 +1031,7 @@ echo json_encode($deactivated_plugins);
|
|
|
859
1031
|
}
|
|
860
1032
|
});
|
|
861
1033
|
if (u.httpStatusCode !== 200)
|
|
862
|
-
throw
|
|
1034
|
+
throw logger.warn("WordPress response was", {
|
|
863
1035
|
response: u,
|
|
864
1036
|
text: u.text,
|
|
865
1037
|
headers: u.headers
|
|
@@ -877,7 +1049,7 @@ echo json_encode($deactivated_plugins);
|
|
|
877
1049
|
PATH_CURRENT_SITE: r
|
|
878
1050
|
}
|
|
879
1051
|
});
|
|
880
|
-
const
|
|
1052
|
+
const f = new URL(await e.absoluteUrl), g = isURLScoped(f) ? "scope:" + getURLScope(f) : null;
|
|
881
1053
|
await e.writeFile(
|
|
882
1054
|
joinPaths(s, "/wp-content/sunrise.php"),
|
|
883
1055
|
`<?php
|
|
@@ -886,7 +1058,7 @@ echo json_encode($deactivated_plugins);
|
|
|
886
1058
|
}
|
|
887
1059
|
$folder = ${phpVar(g)};
|
|
888
1060
|
if ($folder && strpos($_SERVER['REQUEST_URI'],"/$folder") === false) {
|
|
889
|
-
$_SERVER['HTTP_HOST'] = ${phpVar(
|
|
1061
|
+
$_SERVER['HTTP_HOST'] = ${phpVar(f.hostname)};
|
|
890
1062
|
$_SERVER['REQUEST_URI'] = "/$folder/" . ltrim($_SERVER['REQUEST_URI'], '/');
|
|
891
1063
|
}
|
|
892
1064
|
`
|
|
@@ -1042,7 +1214,7 @@ const tmpPath = "/tmp/file.zip", unzip = async (e, { zipFile: t, zipPath: r, ext
|
|
|
1042
1214
|
await e.writeFile(
|
|
1043
1215
|
tmpPath,
|
|
1044
1216
|
await e.readFileAsBuffer(r)
|
|
1045
|
-
),
|
|
1217
|
+
), logger.warn(
|
|
1046
1218
|
'The "zipPath" option of the unzip() Blueprint step is deprecated and will be removed. Use "zipFile" instead.'
|
|
1047
1219
|
);
|
|
1048
1220
|
else if (t)
|
|
@@ -1068,13 +1240,13 @@ const tmpPath = "/tmp/file.zip", unzip = async (e, { zipFile: t, zipPath: r, ext
|
|
|
1068
1240
|
extractToPath: s
|
|
1069
1241
|
}), s = joinPaths(s, r);
|
|
1070
1242
|
const i = joinPaths(s, "wp-content"), o = joinPaths(n, "wp-content");
|
|
1071
|
-
for (const
|
|
1243
|
+
for (const f of wpContentFilesExcludedFromExport) {
|
|
1072
1244
|
const g = joinPaths(
|
|
1073
1245
|
i,
|
|
1074
|
-
|
|
1246
|
+
f
|
|
1075
1247
|
);
|
|
1076
1248
|
await removePath(e, g);
|
|
1077
|
-
const O = joinPaths(o,
|
|
1249
|
+
const O = joinPaths(o, f);
|
|
1078
1250
|
await e.fileExists(O) && (await e.mkdir(dirname(g)), await e.mv(O, g));
|
|
1079
1251
|
}
|
|
1080
1252
|
const l = joinPaths(
|
|
@@ -1087,10 +1259,10 @@ const tmpPath = "/tmp/file.zip", unzip = async (e, { zipFile: t, zipPath: r, ext
|
|
|
1087
1259
|
l
|
|
1088
1260
|
);
|
|
1089
1261
|
const d = await e.listFiles(s);
|
|
1090
|
-
for (const
|
|
1091
|
-
await removePath(e, joinPaths(n,
|
|
1092
|
-
joinPaths(s,
|
|
1093
|
-
joinPaths(n,
|
|
1262
|
+
for (const f of d)
|
|
1263
|
+
await removePath(e, joinPaths(n, f)), await e.mv(
|
|
1264
|
+
joinPaths(s, f),
|
|
1265
|
+
joinPaths(n, f)
|
|
1094
1266
|
);
|
|
1095
1267
|
await e.rmdir(s), await defineSiteUrl(e, {
|
|
1096
1268
|
siteUrl: await e.absoluteUrl
|
|
@@ -1132,9 +1304,9 @@ async function installAsset(e, {
|
|
|
1132
1304
|
prependPath: !0
|
|
1133
1305
|
});
|
|
1134
1306
|
u = u.filter((S) => !S.endsWith("/__MACOSX"));
|
|
1135
|
-
const
|
|
1307
|
+
const f = u.length === 1 && await e.isDir(u[0]);
|
|
1136
1308
|
let g, O = "";
|
|
1137
|
-
|
|
1309
|
+
f ? (O = u[0], g = u[0].split("/").pop()) : (O = d, g = i);
|
|
1138
1310
|
const C = `${t}/${g}`;
|
|
1139
1311
|
if (await e.fileExists(C)) {
|
|
1140
1312
|
if (!await e.isDir(C))
|
|
@@ -1354,7 +1526,7 @@ function cloneResponseMonitorProgress(e, t) {
|
|
|
1354
1526
|
} else
|
|
1355
1527
|
s(l, n), i.enqueue(u);
|
|
1356
1528
|
} catch (d) {
|
|
1357
|
-
|
|
1529
|
+
logger.error({ e: d }), i.error(d);
|
|
1358
1530
|
break;
|
|
1359
1531
|
}
|
|
1360
1532
|
}
|
|
@@ -1656,13 +1828,13 @@ CLI option:
|
|
|
1656
1828
|
let logged = !1;
|
|
1657
1829
|
function showCriticalErrorBox(e) {
|
|
1658
1830
|
if (!logged && (logged = !0, !(e != null && e.trim().startsWith("Program terminated with exit")))) {
|
|
1659
|
-
|
|
1831
|
+
logger.log(`${redBg}
|
|
1660
1832
|
${eol}
|
|
1661
1833
|
${bold} WASM ERROR${reset}${redBg}`);
|
|
1662
1834
|
for (const t of e.split(`
|
|
1663
1835
|
`))
|
|
1664
|
-
|
|
1665
|
-
|
|
1836
|
+
logger.log(`${eol} ${t} `);
|
|
1837
|
+
logger.log(`${reset}`);
|
|
1666
1838
|
}
|
|
1667
1839
|
}
|
|
1668
1840
|
function extractPHPFunctionsFromStack(e) {
|
|
@@ -1696,10 +1868,34 @@ ReadableStream.prototype[Symbol.asyncIterator] || (ReadableStream.prototype[Symb
|
|
|
1696
1868
|
}
|
|
1697
1869
|
}, ReadableStream.prototype.iterate = // @ts-ignore
|
|
1698
1870
|
ReadableStream.prototype[Symbol.asyncIterator]);
|
|
1871
|
+
const responseTexts = {
|
|
1872
|
+
500: "Internal Server Error",
|
|
1873
|
+
502: "Bad Gateway",
|
|
1874
|
+
404: "Not Found",
|
|
1875
|
+
403: "Forbidden",
|
|
1876
|
+
401: "Unauthorized",
|
|
1877
|
+
400: "Bad Request",
|
|
1878
|
+
301: "Moved Permanently",
|
|
1879
|
+
302: "Found",
|
|
1880
|
+
307: "Temporary Redirect",
|
|
1881
|
+
308: "Permanent Redirect",
|
|
1882
|
+
204: "No Content",
|
|
1883
|
+
201: "Created",
|
|
1884
|
+
200: "OK"
|
|
1885
|
+
};
|
|
1699
1886
|
class PHPResponse {
|
|
1700
1887
|
constructor(t, r, n, s = "", i = 0) {
|
|
1701
1888
|
this.httpStatusCode = t, this.headers = r, this.bytes = n, this.exitCode = i, this.errors = s;
|
|
1702
1889
|
}
|
|
1890
|
+
static forHttpCode(t, r = "") {
|
|
1891
|
+
return new PHPResponse(
|
|
1892
|
+
t,
|
|
1893
|
+
{},
|
|
1894
|
+
new TextEncoder().encode(
|
|
1895
|
+
r || responseTexts[t] || ""
|
|
1896
|
+
)
|
|
1897
|
+
);
|
|
1898
|
+
}
|
|
1703
1899
|
static fromRawData(t) {
|
|
1704
1900
|
return new PHPResponse(
|
|
1705
1901
|
t.httpStatusCode,
|
|
@@ -1749,411 +1945,7 @@ const SupportedPHPVersions = [
|
|
|
1749
1945
|
], SupportedPHPExtensionBundles = {
|
|
1750
1946
|
"kitchen-sink": SupportedPHPExtensionsList,
|
|
1751
1947
|
light: []
|
|
1752
|
-
},
|
|
1753
|
-
function toRelativeUrl(e) {
|
|
1754
|
-
return e.toString().substring(e.origin.length);
|
|
1755
|
-
}
|
|
1756
|
-
function removePathPrefix(e, t) {
|
|
1757
|
-
return !t || !e.startsWith(t) ? e : e.substring(t.length);
|
|
1758
|
-
}
|
|
1759
|
-
function ensurePathPrefix(e, t) {
|
|
1760
|
-
return !t || e.startsWith(t) ? e : t + e;
|
|
1761
|
-
}
|
|
1762
|
-
async function encodeAsMultipart(e) {
|
|
1763
|
-
const t = `----${Math.random().toString(36).slice(2)}`, r = `multipart/form-data; boundary=${t}`, n = new TextEncoder(), s = [];
|
|
1764
|
-
for (const [d, u] of Object.entries(e))
|
|
1765
|
-
s.push(`--${t}\r
|
|
1766
|
-
`), s.push(`Content-Disposition: form-data; name="${d}"`), u instanceof File && s.push(`; filename="${u.name}"`), s.push(`\r
|
|
1767
|
-
`), u instanceof File && (s.push("Content-Type: application/octet-stream"), s.push(`\r
|
|
1768
|
-
`)), s.push(`\r
|
|
1769
|
-
`), u instanceof File ? s.push(await fileToUint8Array(u)) : s.push(u), s.push(`\r
|
|
1770
|
-
`);
|
|
1771
|
-
s.push(`--${t}--\r
|
|
1772
|
-
`);
|
|
1773
|
-
const i = s.reduce((d, u) => d + u.length, 0), o = new Uint8Array(i);
|
|
1774
|
-
let l = 0;
|
|
1775
|
-
for (const d of s)
|
|
1776
|
-
o.set(
|
|
1777
|
-
typeof d == "string" ? n.encode(d) : d,
|
|
1778
|
-
l
|
|
1779
|
-
), l += d.length;
|
|
1780
|
-
return { bytes: o, contentType: r };
|
|
1781
|
-
}
|
|
1782
|
-
function fileToUint8Array(e) {
|
|
1783
|
-
return new Promise((t) => {
|
|
1784
|
-
const r = new FileReader();
|
|
1785
|
-
r.onload = () => {
|
|
1786
|
-
t(new Uint8Array(r.result));
|
|
1787
|
-
}, r.readAsArrayBuffer(e);
|
|
1788
|
-
});
|
|
1789
|
-
}
|
|
1790
|
-
class HttpCookieStore {
|
|
1791
|
-
constructor() {
|
|
1792
|
-
this.cookies = {};
|
|
1793
|
-
}
|
|
1794
|
-
rememberCookiesFromResponseHeaders(t) {
|
|
1795
|
-
if (t != null && t["set-cookie"])
|
|
1796
|
-
for (const r of t["set-cookie"])
|
|
1797
|
-
try {
|
|
1798
|
-
if (!r.includes("="))
|
|
1799
|
-
continue;
|
|
1800
|
-
const n = r.indexOf("="), s = r.substring(0, n), i = r.substring(n + 1).split(";")[0];
|
|
1801
|
-
this.cookies[s] = i;
|
|
1802
|
-
} catch (n) {
|
|
1803
|
-
console.error(n);
|
|
1804
|
-
}
|
|
1805
|
-
}
|
|
1806
|
-
getCookieRequestHeader() {
|
|
1807
|
-
const t = [];
|
|
1808
|
-
for (const r in this.cookies)
|
|
1809
|
-
t.push(`${r}=${this.cookies[r]}`);
|
|
1810
|
-
return t.join("; ");
|
|
1811
|
-
}
|
|
1812
|
-
}
|
|
1813
|
-
var Pe, We, ct, je, Be, ve, Ge, Ae, Ke, ft, Wt, ht, Bt, mt, Gt;
|
|
1814
|
-
class PHPRequestHandler {
|
|
1815
|
-
/**
|
|
1816
|
-
* @param php - The PHP instance.
|
|
1817
|
-
* @param config - Request Handler configuration.
|
|
1818
|
-
*/
|
|
1819
|
-
constructor(t, r = {}) {
|
|
1820
|
-
/**
|
|
1821
|
-
* Serves a static file from the PHP filesystem.
|
|
1822
|
-
*
|
|
1823
|
-
* @param fsPath - Absolute path of the static file to serve.
|
|
1824
|
-
* @returns The response.
|
|
1825
|
-
*/
|
|
1826
|
-
K(this, ft);
|
|
1827
|
-
/**
|
|
1828
|
-
* Runs the requested PHP file with all the request and $_SERVER
|
|
1829
|
-
* superglobals populated.
|
|
1830
|
-
*
|
|
1831
|
-
* @param request - The request.
|
|
1832
|
-
* @returns The response.
|
|
1833
|
-
*/
|
|
1834
|
-
K(this, ht);
|
|
1835
|
-
/**
|
|
1836
|
-
* Resolve the requested path to the filesystem path of the requested PHP file.
|
|
1837
|
-
*
|
|
1838
|
-
* Fall back to index.php as if there was a url rewriting rule in place.
|
|
1839
|
-
*
|
|
1840
|
-
* @param requestedPath - The requested pathname.
|
|
1841
|
-
* @throws {Error} If the requested path doesn't exist.
|
|
1842
|
-
* @returns The resolved filesystem path.
|
|
1843
|
-
*/
|
|
1844
|
-
K(this, mt);
|
|
1845
|
-
K(this, Pe, void 0);
|
|
1846
|
-
K(this, We, void 0);
|
|
1847
|
-
K(this, ct, void 0);
|
|
1848
|
-
K(this, je, void 0);
|
|
1849
|
-
K(this, Be, void 0);
|
|
1850
|
-
K(this, ve, void 0);
|
|
1851
|
-
K(this, Ge, void 0);
|
|
1852
|
-
K(this, Ae, void 0);
|
|
1853
|
-
K(this, Ke, void 0);
|
|
1854
|
-
ie(this, Ae, new Semaphore({ concurrency: 1 }));
|
|
1855
|
-
const {
|
|
1856
|
-
documentRoot: n = "/www/",
|
|
1857
|
-
absoluteUrl: s = typeof location == "object" ? location == null ? void 0 : location.href : "",
|
|
1858
|
-
rewriteRules: i = []
|
|
1859
|
-
} = r;
|
|
1860
|
-
this.php = t, ie(this, Ke, new HttpCookieStore()), ie(this, Pe, n);
|
|
1861
|
-
const o = new URL(s);
|
|
1862
|
-
ie(this, ct, o.hostname), ie(this, je, o.port ? Number(o.port) : o.protocol === "https:" ? 443 : 80), ie(this, We, (o.protocol || "").replace(":", ""));
|
|
1863
|
-
const l = H(this, je) !== 443 && H(this, je) !== 80;
|
|
1864
|
-
ie(this, Be, [
|
|
1865
|
-
H(this, ct),
|
|
1866
|
-
l ? `:${H(this, je)}` : ""
|
|
1867
|
-
].join("")), ie(this, ve, o.pathname.replace(/\/+$/, "")), ie(this, Ge, [
|
|
1868
|
-
`${H(this, We)}://`,
|
|
1869
|
-
H(this, Be),
|
|
1870
|
-
H(this, ve)
|
|
1871
|
-
].join("")), this.rewriteRules = i;
|
|
1872
|
-
}
|
|
1873
|
-
/**
|
|
1874
|
-
* Converts a path to an absolute URL based at the PHPRequestHandler
|
|
1875
|
-
* root.
|
|
1876
|
-
*
|
|
1877
|
-
* @param path The server path to convert to an absolute URL.
|
|
1878
|
-
* @returns The absolute URL.
|
|
1879
|
-
*/
|
|
1880
|
-
pathToInternalUrl(t) {
|
|
1881
|
-
return `${this.absoluteUrl}${t}`;
|
|
1882
|
-
}
|
|
1883
|
-
/**
|
|
1884
|
-
* Converts an absolute URL based at the PHPRequestHandler to a relative path
|
|
1885
|
-
* without the server pathname and scope.
|
|
1886
|
-
*
|
|
1887
|
-
* @param internalUrl An absolute URL based at the PHPRequestHandler root.
|
|
1888
|
-
* @returns The relative path.
|
|
1889
|
-
*/
|
|
1890
|
-
internalUrlToPath(t) {
|
|
1891
|
-
const r = new URL(t);
|
|
1892
|
-
return r.pathname.startsWith(H(this, ve)) && (r.pathname = r.pathname.slice(H(this, ve).length)), toRelativeUrl(r);
|
|
1893
|
-
}
|
|
1894
|
-
get isRequestRunning() {
|
|
1895
|
-
return H(this, Ae).running > 0;
|
|
1896
|
-
}
|
|
1897
|
-
/**
|
|
1898
|
-
* The absolute URL of this PHPRequestHandler instance.
|
|
1899
|
-
*/
|
|
1900
|
-
get absoluteUrl() {
|
|
1901
|
-
return H(this, Ge);
|
|
1902
|
-
}
|
|
1903
|
-
/**
|
|
1904
|
-
* The directory in the PHP filesystem where the server will look
|
|
1905
|
-
* for the files to serve. Default: `/var/www`.
|
|
1906
|
-
*/
|
|
1907
|
-
get documentRoot() {
|
|
1908
|
-
return H(this, Pe);
|
|
1909
|
-
}
|
|
1910
|
-
/**
|
|
1911
|
-
* Serves the request – either by serving a static file, or by
|
|
1912
|
-
* dispatching it to the PHP runtime.
|
|
1913
|
-
*
|
|
1914
|
-
* The request() method mode behaves like a web server and only works if
|
|
1915
|
-
* the PHP was initialized with a `requestHandler` option (which the online version
|
|
1916
|
-
* of WordPress Playground does by default).
|
|
1917
|
-
*
|
|
1918
|
-
* In the request mode, you pass an object containing the request information
|
|
1919
|
-
* (method, headers, body, etc.) and the path to the PHP file to run:
|
|
1920
|
-
*
|
|
1921
|
-
* ```ts
|
|
1922
|
-
* const php = PHP.load('7.4', {
|
|
1923
|
-
* requestHandler: {
|
|
1924
|
-
* documentRoot: "/www"
|
|
1925
|
-
* }
|
|
1926
|
-
* })
|
|
1927
|
-
* php.writeFile("/www/index.php", `<?php echo file_get_contents("php://input");`);
|
|
1928
|
-
* const result = await php.request({
|
|
1929
|
-
* method: "GET",
|
|
1930
|
-
* headers: {
|
|
1931
|
-
* "Content-Type": "text/plain"
|
|
1932
|
-
* },
|
|
1933
|
-
* body: "Hello world!",
|
|
1934
|
-
* path: "/www/index.php"
|
|
1935
|
-
* });
|
|
1936
|
-
* // result.text === "Hello world!"
|
|
1937
|
-
* ```
|
|
1938
|
-
*
|
|
1939
|
-
* The `request()` method cannot be used in conjunction with `cli()`.
|
|
1940
|
-
*
|
|
1941
|
-
* @example
|
|
1942
|
-
* ```js
|
|
1943
|
-
* const output = await php.request({
|
|
1944
|
-
* method: 'GET',
|
|
1945
|
-
* url: '/index.php',
|
|
1946
|
-
* headers: {
|
|
1947
|
-
* 'X-foo': 'bar',
|
|
1948
|
-
* },
|
|
1949
|
-
* body: {
|
|
1950
|
-
* foo: 'bar',
|
|
1951
|
-
* },
|
|
1952
|
-
* });
|
|
1953
|
-
* console.log(output.stdout); // "Hello world!"
|
|
1954
|
-
* ```
|
|
1955
|
-
*
|
|
1956
|
-
* @param request - PHP Request data.
|
|
1957
|
-
*/
|
|
1958
|
-
async request(t) {
|
|
1959
|
-
const r = t.url.startsWith("http://") || t.url.startsWith("https://"), n = new URL(
|
|
1960
|
-
// Remove the hash part of the URL as it's not meant for the server.
|
|
1961
|
-
t.url.split("#")[0],
|
|
1962
|
-
r ? void 0 : DEFAULT_BASE_URL
|
|
1963
|
-
), s = applyRewriteRules(
|
|
1964
|
-
removePathPrefix(
|
|
1965
|
-
decodeURIComponent(n.pathname),
|
|
1966
|
-
H(this, ve)
|
|
1967
|
-
),
|
|
1968
|
-
this.rewriteRules
|
|
1969
|
-
), i = joinPaths(H(this, Pe), s);
|
|
1970
|
-
return seemsLikeAPHPRequestHandlerPath(i) ? await ce(this, ht, Bt).call(this, t, n) : ce(this, ft, Wt).call(this, i);
|
|
1971
|
-
}
|
|
1972
|
-
}
|
|
1973
|
-
Pe = new WeakMap(), We = new WeakMap(), ct = new WeakMap(), je = new WeakMap(), Be = new WeakMap(), ve = new WeakMap(), Ge = new WeakMap(), Ae = new WeakMap(), Ke = new WeakMap(), ft = new WeakSet(), Wt = function(t) {
|
|
1974
|
-
if (!this.php.fileExists(t))
|
|
1975
|
-
return new PHPResponse(
|
|
1976
|
-
404,
|
|
1977
|
-
// Let the service worker know that no static file was found
|
|
1978
|
-
// and that it's okay to issue a real fetch() to the server.
|
|
1979
|
-
{
|
|
1980
|
-
"x-file-type": ["static"]
|
|
1981
|
-
},
|
|
1982
|
-
new TextEncoder().encode("404 File not found")
|
|
1983
|
-
);
|
|
1984
|
-
const r = this.php.readFileAsBuffer(t);
|
|
1985
|
-
return new PHPResponse(
|
|
1986
|
-
200,
|
|
1987
|
-
{
|
|
1988
|
-
"content-length": [`${r.byteLength}`],
|
|
1989
|
-
// @TODO: Infer the content-type from the arrayBuffer instead of the file path.
|
|
1990
|
-
// The code below won't return the correct mime-type if the extension
|
|
1991
|
-
// was tampered with.
|
|
1992
|
-
"content-type": [inferMimeType(t)],
|
|
1993
|
-
"accept-ranges": ["bytes"],
|
|
1994
|
-
"cache-control": ["public, max-age=0"]
|
|
1995
|
-
},
|
|
1996
|
-
r
|
|
1997
|
-
);
|
|
1998
|
-
}, ht = new WeakSet(), Bt = async function(t, r) {
|
|
1999
|
-
var s;
|
|
2000
|
-
if (H(this, Ae).running > 0 && ((s = t.headers) == null ? void 0 : s["x-request-issuer"]) === "php")
|
|
2001
|
-
return console.warn(
|
|
2002
|
-
"Possible deadlock: Called request() before the previous request() have finished. PHP likely issued an HTTP call to itself. Normally this would lead to infinite waiting as Request 1 holds the lock that the Request 2 is waiting to acquire. That's not useful, so PHPRequestHandler will return error 502 instead."
|
|
2003
|
-
), new PHPResponse(
|
|
2004
|
-
502,
|
|
2005
|
-
{},
|
|
2006
|
-
new TextEncoder().encode("502 Bad Gateway")
|
|
2007
|
-
);
|
|
2008
|
-
const n = await H(this, Ae).acquire();
|
|
2009
|
-
try {
|
|
2010
|
-
let i = "GET";
|
|
2011
|
-
const o = {
|
|
2012
|
-
host: H(this, Be),
|
|
2013
|
-
...normalizeHeaders(t.headers || {}),
|
|
2014
|
-
cookie: H(this, Ke).getCookieRequestHeader()
|
|
2015
|
-
};
|
|
2016
|
-
let l = t.body;
|
|
2017
|
-
if (typeof l == "object" && !(l instanceof Uint8Array)) {
|
|
2018
|
-
i = "POST";
|
|
2019
|
-
const { bytes: u, contentType: p } = await encodeAsMultipart(l);
|
|
2020
|
-
l = u, o["content-type"] = p;
|
|
2021
|
-
}
|
|
2022
|
-
let d;
|
|
2023
|
-
try {
|
|
2024
|
-
d = ce(this, mt, Gt).call(this, decodeURIComponent(r.pathname));
|
|
2025
|
-
} catch {
|
|
2026
|
-
return new PHPResponse(
|
|
2027
|
-
404,
|
|
2028
|
-
{},
|
|
2029
|
-
new TextEncoder().encode("404 File not found")
|
|
2030
|
-
);
|
|
2031
|
-
}
|
|
2032
|
-
try {
|
|
2033
|
-
const u = await this.php.run({
|
|
2034
|
-
relativeUri: ensurePathPrefix(
|
|
2035
|
-
toRelativeUrl(r),
|
|
2036
|
-
H(this, ve)
|
|
2037
|
-
),
|
|
2038
|
-
protocol: H(this, We),
|
|
2039
|
-
method: t.method || i,
|
|
2040
|
-
$_SERVER: {
|
|
2041
|
-
REMOTE_ADDR: "127.0.0.1",
|
|
2042
|
-
DOCUMENT_ROOT: H(this, Pe),
|
|
2043
|
-
HTTPS: H(this, Ge).startsWith("https://") ? "on" : ""
|
|
2044
|
-
},
|
|
2045
|
-
body: l,
|
|
2046
|
-
scriptPath: d,
|
|
2047
|
-
headers: o
|
|
2048
|
-
});
|
|
2049
|
-
return H(this, Ke).rememberCookiesFromResponseHeaders(
|
|
2050
|
-
u.headers
|
|
2051
|
-
), u;
|
|
2052
|
-
} catch (u) {
|
|
2053
|
-
const p = u;
|
|
2054
|
-
if (p != null && p.response)
|
|
2055
|
-
return p.response;
|
|
2056
|
-
throw u;
|
|
2057
|
-
}
|
|
2058
|
-
} finally {
|
|
2059
|
-
n();
|
|
2060
|
-
}
|
|
2061
|
-
}, mt = new WeakSet(), Gt = function(t) {
|
|
2062
|
-
let r = removePathPrefix(t, H(this, ve));
|
|
2063
|
-
r = applyRewriteRules(r, this.rewriteRules), r.includes(".php") ? r = r.split(".php")[0] + ".php" : this.php.isDir(`${H(this, Pe)}${r}`) ? (r.endsWith("/") || (r = `${r}/`), r = `${r}index.php`) : r = "/index.php";
|
|
2064
|
-
const n = `${H(this, Pe)}${r}`;
|
|
2065
|
-
if (this.php.fileExists(n))
|
|
2066
|
-
return n;
|
|
2067
|
-
throw new Error(`File not found: ${n}`);
|
|
2068
|
-
};
|
|
2069
|
-
function inferMimeType(e) {
|
|
2070
|
-
switch (e.split(".").pop()) {
|
|
2071
|
-
case "css":
|
|
2072
|
-
return "text/css";
|
|
2073
|
-
case "js":
|
|
2074
|
-
return "application/javascript";
|
|
2075
|
-
case "png":
|
|
2076
|
-
return "image/png";
|
|
2077
|
-
case "jpg":
|
|
2078
|
-
case "jpeg":
|
|
2079
|
-
return "image/jpeg";
|
|
2080
|
-
case "gif":
|
|
2081
|
-
return "image/gif";
|
|
2082
|
-
case "svg":
|
|
2083
|
-
return "image/svg+xml";
|
|
2084
|
-
case "woff":
|
|
2085
|
-
return "font/woff";
|
|
2086
|
-
case "woff2":
|
|
2087
|
-
return "font/woff2";
|
|
2088
|
-
case "ttf":
|
|
2089
|
-
return "font/ttf";
|
|
2090
|
-
case "otf":
|
|
2091
|
-
return "font/otf";
|
|
2092
|
-
case "eot":
|
|
2093
|
-
return "font/eot";
|
|
2094
|
-
case "ico":
|
|
2095
|
-
return "image/x-icon";
|
|
2096
|
-
case "html":
|
|
2097
|
-
return "text/html";
|
|
2098
|
-
case "json":
|
|
2099
|
-
return "application/json";
|
|
2100
|
-
case "xml":
|
|
2101
|
-
return "application/xml";
|
|
2102
|
-
case "txt":
|
|
2103
|
-
case "md":
|
|
2104
|
-
return "text/plain";
|
|
2105
|
-
case "pdf":
|
|
2106
|
-
return "application/pdf";
|
|
2107
|
-
case "webp":
|
|
2108
|
-
return "image/webp";
|
|
2109
|
-
case "mp3":
|
|
2110
|
-
return "audio/mpeg";
|
|
2111
|
-
case "mp4":
|
|
2112
|
-
return "video/mp4";
|
|
2113
|
-
case "csv":
|
|
2114
|
-
return "text/csv";
|
|
2115
|
-
case "xls":
|
|
2116
|
-
return "application/vnd.ms-excel";
|
|
2117
|
-
case "xlsx":
|
|
2118
|
-
return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
2119
|
-
case "doc":
|
|
2120
|
-
return "application/msword";
|
|
2121
|
-
case "docx":
|
|
2122
|
-
return "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
|
2123
|
-
case "ppt":
|
|
2124
|
-
return "application/vnd.ms-powerpoint";
|
|
2125
|
-
case "pptx":
|
|
2126
|
-
return "application/vnd.openxmlformats-officedocument.presentationml.presentation";
|
|
2127
|
-
case "zip":
|
|
2128
|
-
return "application/zip";
|
|
2129
|
-
case "rar":
|
|
2130
|
-
return "application/x-rar-compressed";
|
|
2131
|
-
case "tar":
|
|
2132
|
-
return "application/x-tar";
|
|
2133
|
-
case "gz":
|
|
2134
|
-
return "application/gzip";
|
|
2135
|
-
case "7z":
|
|
2136
|
-
return "application/x-7z-compressed";
|
|
2137
|
-
default:
|
|
2138
|
-
return "application-octet-stream";
|
|
2139
|
-
}
|
|
2140
|
-
}
|
|
2141
|
-
function seemsLikeAPHPRequestHandlerPath(e) {
|
|
2142
|
-
return seemsLikeAPHPFile(e) || seemsLikeADirectoryRoot(e);
|
|
2143
|
-
}
|
|
2144
|
-
function seemsLikeAPHPFile(e) {
|
|
2145
|
-
return e.endsWith(".php") || e.includes(".php/");
|
|
2146
|
-
}
|
|
2147
|
-
function seemsLikeADirectoryRoot(e) {
|
|
2148
|
-
return !e.split("/").pop().includes(".");
|
|
2149
|
-
}
|
|
2150
|
-
function applyRewriteRules(e, t) {
|
|
2151
|
-
for (const r of t)
|
|
2152
|
-
if (new RegExp(r.match).test(e))
|
|
2153
|
-
return e.replace(r.match, r.replacement);
|
|
2154
|
-
return e;
|
|
2155
|
-
}
|
|
2156
|
-
const FileErrorCodes = {
|
|
1948
|
+
}, FileErrorCodes = {
|
|
2157
1949
|
0: "No error occurred. System call completed successfully.",
|
|
2158
1950
|
1: "Argument list too long.",
|
|
2159
1951
|
2: "Permission denied.",
|
|
@@ -2246,7 +2038,7 @@ function rethrowFileSystemError(e = "") {
|
|
|
2246
2038
|
} catch (l) {
|
|
2247
2039
|
const d = typeof l == "object" ? l == null ? void 0 : l.errno : null;
|
|
2248
2040
|
if (d in FileErrorCodes) {
|
|
2249
|
-
const u = FileErrorCodes[d],
|
|
2041
|
+
const u = FileErrorCodes[d], f = typeof o[0] == "string" ? o[0] : null, g = f !== null ? e.replaceAll("{path}", f) : e;
|
|
2250
2042
|
throw new Error(`${g}: ${u}`, {
|
|
2251
2043
|
cause: l
|
|
2252
2044
|
});
|
|
@@ -2275,16 +2067,16 @@ class PHPExecutionFailureError extends Error {
|
|
|
2275
2067
|
super(t), this.response = r, this.source = n;
|
|
2276
2068
|
}
|
|
2277
2069
|
}
|
|
2278
|
-
var
|
|
2070
|
+
var Ne, Ve, ze, ve, Ee, be, He, st, jt, it, Dt, ot, At, at, Ft, ct, Mt, lt, qt, dt, Lt, ut, Ut, pt, Vt, ft, zt, ht, Ht, mt, xt, _t, Bt, gt, Wt, $t, Gt;
|
|
2279
2071
|
class BasePHP {
|
|
2280
2072
|
/**
|
|
2281
2073
|
* Initializes a PHP runtime.
|
|
2282
2074
|
*
|
|
2283
2075
|
* @internal
|
|
2284
2076
|
* @param PHPRuntime - Optional. PHP Runtime ID as initialized by loadPHPRuntime.
|
|
2285
|
-
* @param
|
|
2077
|
+
* @param requestHandlerOptions - Optional. Options for the PHPRequestHandler. If undefined, no request handler will be initialized.
|
|
2286
2078
|
*/
|
|
2287
|
-
constructor(e
|
|
2079
|
+
constructor(e) {
|
|
2288
2080
|
/**
|
|
2289
2081
|
* Prepares the $_SERVER entries for the PHP runtime.
|
|
2290
2082
|
*
|
|
@@ -2294,46 +2086,46 @@ class BasePHP {
|
|
|
2294
2086
|
* was provided.
|
|
2295
2087
|
* @returns Computed $_SERVER entries.
|
|
2296
2088
|
*/
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2089
|
+
ee(this, st);
|
|
2090
|
+
ee(this, it);
|
|
2091
|
+
ee(this, ot);
|
|
2092
|
+
ee(this, at);
|
|
2093
|
+
ee(this, ct);
|
|
2094
|
+
ee(this, lt);
|
|
2095
|
+
ee(this, dt);
|
|
2096
|
+
ee(this, ut);
|
|
2097
|
+
ee(this, pt);
|
|
2098
|
+
ee(this, ft);
|
|
2099
|
+
ee(this, ht);
|
|
2100
|
+
ee(this, mt);
|
|
2101
|
+
ee(this, _t);
|
|
2102
|
+
ee(this, gt);
|
|
2103
|
+
ee(this, $t);
|
|
2104
|
+
ee(this, Ne, void 0);
|
|
2105
|
+
ee(this, Ve, void 0);
|
|
2106
|
+
ee(this, ze, void 0);
|
|
2107
|
+
ee(this, ve, void 0);
|
|
2108
|
+
ee(this, Ee, void 0);
|
|
2109
|
+
ee(this, be, void 0);
|
|
2110
|
+
ee(this, He, void 0);
|
|
2111
|
+
fe(this, Ne, []), fe(this, ve, !1), fe(this, Ee, null), fe(this, be, /* @__PURE__ */ new Map()), fe(this, He, []), this.semaphore = new Semaphore({ concurrency: 1 }), e !== void 0 && this.initializeRuntime(e);
|
|
2320
2112
|
}
|
|
2321
2113
|
addEventListener(e, t) {
|
|
2322
|
-
|
|
2114
|
+
se(this, be).has(e) || se(this, be).set(e, /* @__PURE__ */ new Set()), se(this, be).get(e).add(t);
|
|
2323
2115
|
}
|
|
2324
2116
|
removeEventListener(e, t) {
|
|
2325
2117
|
var r;
|
|
2326
|
-
(r =
|
|
2118
|
+
(r = se(this, be).get(e)) == null || r.delete(t);
|
|
2327
2119
|
}
|
|
2328
2120
|
dispatchEvent(e) {
|
|
2329
|
-
const t =
|
|
2121
|
+
const t = se(this, be).get(e.type);
|
|
2330
2122
|
if (t)
|
|
2331
2123
|
for (const r of t)
|
|
2332
2124
|
r(e);
|
|
2333
2125
|
}
|
|
2334
2126
|
/** @inheritDoc */
|
|
2335
2127
|
async onMessage(e) {
|
|
2336
|
-
|
|
2128
|
+
se(this, He).push(e);
|
|
2337
2129
|
}
|
|
2338
2130
|
/** @inheritDoc */
|
|
2339
2131
|
async setSpawnHandler(handler) {
|
|
@@ -2362,13 +2154,13 @@ class BasePHP {
|
|
|
2362
2154
|
if (!t)
|
|
2363
2155
|
throw new Error("Invalid PHP runtime id.");
|
|
2364
2156
|
this[__private__dont__use] = t, t.onMessage = async (r) => {
|
|
2365
|
-
for (const n of
|
|
2157
|
+
for (const n of se(this, He)) {
|
|
2366
2158
|
const s = await n(r);
|
|
2367
2159
|
if (s)
|
|
2368
2160
|
return s;
|
|
2369
2161
|
}
|
|
2370
2162
|
return "";
|
|
2371
|
-
},
|
|
2163
|
+
}, fe(this, Ee, improveWASMErrorReporting(t)), this.dispatchEvent({
|
|
2372
2164
|
type: "runtime.initialized"
|
|
2373
2165
|
});
|
|
2374
2166
|
}
|
|
@@ -2383,13 +2175,13 @@ class BasePHP {
|
|
|
2383
2175
|
throw new Error(
|
|
2384
2176
|
"Could not set SAPI name. This can only be done before the PHP WASM module is initialized.Did you already dispatch any requests?"
|
|
2385
2177
|
);
|
|
2386
|
-
|
|
2178
|
+
fe(this, ze, e);
|
|
2387
2179
|
}
|
|
2388
2180
|
/** @inheritDoc */
|
|
2389
2181
|
setPhpIniPath(e) {
|
|
2390
|
-
if (
|
|
2182
|
+
if (se(this, ve))
|
|
2391
2183
|
throw new Error("Cannot set PHP ini path after calling run().");
|
|
2392
|
-
|
|
2184
|
+
fe(this, Ve, e), this[__private__dont__use].ccall(
|
|
2393
2185
|
"wasm_set_phpini_path",
|
|
2394
2186
|
null,
|
|
2395
2187
|
["string"],
|
|
@@ -2398,17 +2190,22 @@ class BasePHP {
|
|
|
2398
2190
|
}
|
|
2399
2191
|
/** @inheritDoc */
|
|
2400
2192
|
setPhpIniEntry(e, t) {
|
|
2401
|
-
if (
|
|
2193
|
+
if (se(this, ve))
|
|
2402
2194
|
throw new Error("Cannot set PHP ini entries after calling run().");
|
|
2403
|
-
|
|
2195
|
+
se(this, Ne).push([e, t]);
|
|
2404
2196
|
}
|
|
2405
2197
|
/** @inheritDoc */
|
|
2406
2198
|
chdir(e) {
|
|
2407
2199
|
this[__private__dont__use].FS.chdir(e);
|
|
2408
2200
|
}
|
|
2409
|
-
/**
|
|
2201
|
+
/**
|
|
2202
|
+
* Do not use. Use new PHPRequestHandler() instead.
|
|
2203
|
+
* @deprecated
|
|
2204
|
+
*/
|
|
2410
2205
|
async request(e) {
|
|
2411
|
-
if (
|
|
2206
|
+
if (logger.warn(
|
|
2207
|
+
"PHP.request() is deprecated. Please use new PHPRequestHandler() instead."
|
|
2208
|
+
), !this.requestHandler)
|
|
2412
2209
|
throw new Error("No request handler available.");
|
|
2413
2210
|
return this.requestHandler.request(e);
|
|
2414
2211
|
}
|
|
@@ -2417,28 +2214,28 @@ class BasePHP {
|
|
|
2417
2214
|
const t = await this.semaphore.acquire();
|
|
2418
2215
|
let r;
|
|
2419
2216
|
try {
|
|
2420
|
-
if (
|
|
2217
|
+
if (se(this, ve) || (ae(this, it, Dt).call(this), fe(this, ve, !0)), e.scriptPath && !this.fileExists(e.scriptPath))
|
|
2421
2218
|
throw new Error(
|
|
2422
2219
|
`The script path "${e.scriptPath}" does not exist.`
|
|
2423
2220
|
);
|
|
2424
|
-
|
|
2425
|
-
const n = normalizeHeaders(e.headers || {}), s = n.host || "example.com:443", i =
|
|
2426
|
-
|
|
2427
|
-
const o =
|
|
2221
|
+
ae(this, ht, Ht).call(this, e.scriptPath || ""), ae(this, at, Ft).call(this, e.relativeUri || ""), ae(this, ut, Ut).call(this, e.method || "GET");
|
|
2222
|
+
const n = normalizeHeaders(e.headers || {}), s = n.host || "example.com:443", i = ae(this, dt, Lt).call(this, s, e.protocol || "http");
|
|
2223
|
+
ae(this, ct, Mt).call(this, s), ae(this, lt, qt).call(this, i), ae(this, pt, Vt).call(this, n), e.body && (r = ae(this, ft, zt).call(this, e.body)), typeof e.code == "string" && ae(this, gt, Wt).call(this, " ?>" + e.code);
|
|
2224
|
+
const o = ae(this, st, jt).call(this, e.$_SERVER, n, i);
|
|
2428
2225
|
for (const u in o)
|
|
2429
|
-
|
|
2226
|
+
ae(this, mt, xt).call(this, u, o[u]);
|
|
2430
2227
|
const l = e.env || {};
|
|
2431
2228
|
for (const u in l)
|
|
2432
|
-
|
|
2433
|
-
const d = await
|
|
2229
|
+
ae(this, _t, Bt).call(this, u, l[u]);
|
|
2230
|
+
const d = await ae(this, $t, Gt).call(this);
|
|
2434
2231
|
if (d.exitCode !== 0) {
|
|
2435
|
-
|
|
2232
|
+
logger.warn("PHP.run() output was:", d.text);
|
|
2436
2233
|
const u = new PHPExecutionFailureError(
|
|
2437
2234
|
`PHP.run() failed with exit code ${d.exitCode} and the following output: ` + d.errors,
|
|
2438
2235
|
d,
|
|
2439
2236
|
"request"
|
|
2440
2237
|
);
|
|
2441
|
-
throw
|
|
2238
|
+
throw logger.error(u), u;
|
|
2442
2239
|
}
|
|
2443
2240
|
return d;
|
|
2444
2241
|
} catch (n) {
|
|
@@ -2525,7 +2322,7 @@ class BasePHP {
|
|
|
2525
2322
|
}
|
|
2526
2323
|
return r;
|
|
2527
2324
|
} catch (r) {
|
|
2528
|
-
return
|
|
2325
|
+
return logger.error(r, { path: e }), [];
|
|
2529
2326
|
}
|
|
2530
2327
|
}
|
|
2531
2328
|
isDir(e) {
|
|
@@ -2556,7 +2353,7 @@ class BasePHP {
|
|
|
2556
2353
|
this.exit();
|
|
2557
2354
|
} catch {
|
|
2558
2355
|
}
|
|
2559
|
-
this.initializeRuntime(e),
|
|
2356
|
+
this.initializeRuntime(e), se(this, Ve) && this.setPhpIniPath(se(this, Ve)), se(this, ze) && this.setSapiName(se(this, ze)), t && copyFS(r, this[__private__dont__use].FS, t);
|
|
2560
2357
|
}
|
|
2561
2358
|
exit(e = 0) {
|
|
2562
2359
|
this.dispatchEvent({
|
|
@@ -2566,10 +2363,13 @@ class BasePHP {
|
|
|
2566
2363
|
this[__private__dont__use]._exit(e);
|
|
2567
2364
|
} catch {
|
|
2568
2365
|
}
|
|
2569
|
-
|
|
2366
|
+
fe(this, ve, !1), fe(this, Ee, null), delete this[__private__dont__use].onMessage, delete this[__private__dont__use];
|
|
2367
|
+
}
|
|
2368
|
+
[Symbol.dispose]() {
|
|
2369
|
+
se(this, ve) && this.exit(0);
|
|
2570
2370
|
}
|
|
2571
2371
|
}
|
|
2572
|
-
|
|
2372
|
+
Ne = new WeakMap(), Ve = new WeakMap(), ze = new WeakMap(), ve = new WeakMap(), Ee = new WeakMap(), be = new WeakMap(), He = new WeakMap(), st = new WeakSet(), jt = function(e, t, r) {
|
|
2573
2373
|
const n = {
|
|
2574
2374
|
...e || {}
|
|
2575
2375
|
};
|
|
@@ -2579,7 +2379,7 @@ De = new WeakMap(), Je = new WeakMap(), Qe = new WeakMap(), be = new WeakMap(),
|
|
|
2579
2379
|
["content-type", "content-length"].includes(s.toLowerCase()) && (i = ""), n[`${i}${s.toUpperCase().replace(/-/g, "_")}`] = t[s];
|
|
2580
2380
|
}
|
|
2581
2381
|
return n;
|
|
2582
|
-
},
|
|
2382
|
+
}, it = new WeakSet(), Dt = function() {
|
|
2583
2383
|
if (this.setPhpIniEntry("auto_prepend_file", "/internal/consts.php"), this.fileExists("/internal/consts.php") || this.writeFile(
|
|
2584
2384
|
"/internal/consts.php",
|
|
2585
2385
|
`<?php
|
|
@@ -2591,8 +2391,8 @@ De = new WeakMap(), Je = new WeakMap(), Qe = new WeakMap(), be = new WeakMap(),
|
|
|
2591
2391
|
}
|
|
2592
2392
|
}
|
|
2593
2393
|
}`
|
|
2594
|
-
),
|
|
2595
|
-
const e =
|
|
2394
|
+
), se(this, Ne).length > 0) {
|
|
2395
|
+
const e = se(this, Ne).map(([t, r]) => `${t}=${r}`).join(`
|
|
2596
2396
|
`) + `
|
|
2597
2397
|
|
|
2598
2398
|
`;
|
|
@@ -2604,7 +2404,7 @@ De = new WeakMap(), Je = new WeakMap(), Qe = new WeakMap(), be = new WeakMap(),
|
|
|
2604
2404
|
);
|
|
2605
2405
|
}
|
|
2606
2406
|
this[__private__dont__use].ccall("php_wasm_init", null, [], []);
|
|
2607
|
-
},
|
|
2407
|
+
}, ot = new WeakSet(), At = function() {
|
|
2608
2408
|
const e = "/internal/headers.json";
|
|
2609
2409
|
if (!this.fileExists(e))
|
|
2610
2410
|
throw new Error(
|
|
@@ -2621,7 +2421,7 @@ De = new WeakMap(), Je = new WeakMap(), Qe = new WeakMap(), be = new WeakMap(),
|
|
|
2621
2421
|
headers: r,
|
|
2622
2422
|
httpStatusCode: t.status
|
|
2623
2423
|
};
|
|
2624
|
-
},
|
|
2424
|
+
}, at = new WeakSet(), Ft = function(e) {
|
|
2625
2425
|
if (this[__private__dont__use].ccall(
|
|
2626
2426
|
"wasm_set_request_uri",
|
|
2627
2427
|
null,
|
|
@@ -2636,35 +2436,35 @@ De = new WeakMap(), Je = new WeakMap(), Qe = new WeakMap(), be = new WeakMap(),
|
|
|
2636
2436
|
[t]
|
|
2637
2437
|
);
|
|
2638
2438
|
}
|
|
2639
|
-
},
|
|
2439
|
+
}, ct = new WeakSet(), Mt = function(e) {
|
|
2640
2440
|
this[__private__dont__use].ccall(
|
|
2641
2441
|
"wasm_set_request_host",
|
|
2642
2442
|
null,
|
|
2643
2443
|
[STRING],
|
|
2644
2444
|
[e]
|
|
2645
2445
|
);
|
|
2646
|
-
},
|
|
2446
|
+
}, lt = new WeakSet(), qt = function(e) {
|
|
2647
2447
|
this[__private__dont__use].ccall(
|
|
2648
2448
|
"wasm_set_request_port",
|
|
2649
2449
|
null,
|
|
2650
2450
|
[NUMBER],
|
|
2651
2451
|
[e]
|
|
2652
2452
|
);
|
|
2653
|
-
},
|
|
2453
|
+
}, dt = new WeakSet(), Lt = function(e, t) {
|
|
2654
2454
|
let r;
|
|
2655
2455
|
try {
|
|
2656
2456
|
r = parseInt(new URL(e).port, 10);
|
|
2657
2457
|
} catch {
|
|
2658
2458
|
}
|
|
2659
2459
|
return (!r || isNaN(r) || r === 80) && (r = t === "https" ? 443 : 80), r;
|
|
2660
|
-
},
|
|
2460
|
+
}, ut = new WeakSet(), Ut = function(e) {
|
|
2661
2461
|
this[__private__dont__use].ccall(
|
|
2662
2462
|
"wasm_set_request_method",
|
|
2663
2463
|
null,
|
|
2664
2464
|
[STRING],
|
|
2665
2465
|
[e]
|
|
2666
2466
|
);
|
|
2667
|
-
},
|
|
2467
|
+
}, pt = new WeakSet(), Vt = function(e) {
|
|
2668
2468
|
e.cookie && this[__private__dont__use].ccall(
|
|
2669
2469
|
"wasm_set_cookies",
|
|
2670
2470
|
null,
|
|
@@ -2681,9 +2481,9 @@ De = new WeakMap(), Je = new WeakMap(), Qe = new WeakMap(), be = new WeakMap(),
|
|
|
2681
2481
|
[NUMBER],
|
|
2682
2482
|
[parseInt(e["content-length"], 10)]
|
|
2683
2483
|
);
|
|
2684
|
-
},
|
|
2484
|
+
}, ft = new WeakSet(), zt = function(e) {
|
|
2685
2485
|
let t, r;
|
|
2686
|
-
typeof e == "string" ? (
|
|
2486
|
+
typeof e == "string" ? (logger.warn(
|
|
2687
2487
|
"Passing a string as the request body is deprecated. Please use a Uint8Array instead. See https://github.com/WordPress/wordpress-playground/issues/997 for more details"
|
|
2688
2488
|
), r = this[__private__dont__use].lengthBytesUTF8(e), t = r + 1) : (r = e.byteLength, t = e.byteLength);
|
|
2689
2489
|
const n = this[__private__dont__use].malloc(t);
|
|
@@ -2704,45 +2504,45 @@ De = new WeakMap(), Je = new WeakMap(), Qe = new WeakMap(), be = new WeakMap(),
|
|
|
2704
2504
|
[NUMBER],
|
|
2705
2505
|
[r]
|
|
2706
2506
|
), n;
|
|
2707
|
-
},
|
|
2507
|
+
}, ht = new WeakSet(), Ht = function(e) {
|
|
2708
2508
|
this[__private__dont__use].ccall(
|
|
2709
2509
|
"wasm_set_path_translated",
|
|
2710
2510
|
null,
|
|
2711
2511
|
[STRING],
|
|
2712
2512
|
[e]
|
|
2713
2513
|
);
|
|
2714
|
-
},
|
|
2514
|
+
}, mt = new WeakSet(), xt = function(e, t) {
|
|
2715
2515
|
this[__private__dont__use].ccall(
|
|
2716
2516
|
"wasm_add_SERVER_entry",
|
|
2717
2517
|
null,
|
|
2718
2518
|
[STRING, STRING],
|
|
2719
2519
|
[e, t]
|
|
2720
2520
|
);
|
|
2721
|
-
},
|
|
2521
|
+
}, _t = new WeakSet(), Bt = function(e, t) {
|
|
2722
2522
|
this[__private__dont__use].ccall(
|
|
2723
2523
|
"wasm_add_ENV_entry",
|
|
2724
2524
|
null,
|
|
2725
2525
|
[STRING, STRING],
|
|
2726
2526
|
[e, t]
|
|
2727
2527
|
);
|
|
2728
|
-
},
|
|
2528
|
+
}, gt = new WeakSet(), Wt = function(e) {
|
|
2729
2529
|
this[__private__dont__use].ccall(
|
|
2730
2530
|
"wasm_set_php_code",
|
|
2731
2531
|
null,
|
|
2732
2532
|
[STRING],
|
|
2733
2533
|
[e]
|
|
2734
2534
|
);
|
|
2735
|
-
},
|
|
2535
|
+
}, $t = new WeakSet(), Gt = async function() {
|
|
2736
2536
|
var s;
|
|
2737
2537
|
let e, t;
|
|
2738
2538
|
try {
|
|
2739
2539
|
e = await new Promise((i, o) => {
|
|
2740
2540
|
var d;
|
|
2741
2541
|
t = (u) => {
|
|
2742
|
-
|
|
2743
|
-
const
|
|
2744
|
-
|
|
2745
|
-
}, (d =
|
|
2542
|
+
logger.error(u), logger.error(u.error);
|
|
2543
|
+
const f = new Error("Rethrown");
|
|
2544
|
+
f.cause = u.error, f.betterMessage = u.message, o(f);
|
|
2545
|
+
}, (d = se(this, Ee)) == null || d.addEventListener(
|
|
2746
2546
|
"error",
|
|
2747
2547
|
t
|
|
2748
2548
|
);
|
|
@@ -2764,11 +2564,11 @@ De = new WeakMap(), Je = new WeakMap(), Qe = new WeakMap(), be = new WeakMap(),
|
|
|
2764
2564
|
});
|
|
2765
2565
|
this.functionsMaybeMissingFromAsyncify = getFunctionsMaybeMissingFromAsyncify();
|
|
2766
2566
|
const o = i, l = "betterMessage" in o ? o.betterMessage : o.message, d = new Error(l);
|
|
2767
|
-
throw d.cause = o,
|
|
2567
|
+
throw d.cause = o, logger.error(d), d;
|
|
2768
2568
|
} finally {
|
|
2769
|
-
(s =
|
|
2569
|
+
(s = se(this, Ee)) == null || s.removeEventListener("error", t);
|
|
2770
2570
|
}
|
|
2771
|
-
const { headers: r, httpStatusCode: n } =
|
|
2571
|
+
const { headers: r, httpStatusCode: n } = ae(this, ot, At).call(this);
|
|
2772
2572
|
return new PHPResponse(
|
|
2773
2573
|
e === 0 ? n : 500,
|
|
2774
2574
|
r,
|
|
@@ -3132,29 +2932,29 @@ var ajv$1 = { exports: {} }, core$2 = {}, validate = {}, boolSchema = {}, errors
|
|
|
3132
2932
|
}
|
|
3133
2933
|
get str() {
|
|
3134
2934
|
var $;
|
|
3135
|
-
return ($ = this._str) !== null && $ !== void 0 ? $ : this._str = this._items.reduce((
|
|
2935
|
+
return ($ = this._str) !== null && $ !== void 0 ? $ : this._str = this._items.reduce((b, I) => `${b}${I}`, "");
|
|
3136
2936
|
}
|
|
3137
2937
|
get names() {
|
|
3138
2938
|
var $;
|
|
3139
|
-
return ($ = this._names) !== null && $ !== void 0 ? $ : this._names = this._items.reduce((
|
|
2939
|
+
return ($ = this._names) !== null && $ !== void 0 ? $ : this._names = this._items.reduce((b, I) => (I instanceof r && (b[I.str] = (b[I.str] || 0) + 1), b), {});
|
|
3140
2940
|
}
|
|
3141
2941
|
}
|
|
3142
2942
|
e._Code = n, e.nil = new n("");
|
|
3143
2943
|
function s(_, ...$) {
|
|
3144
|
-
const
|
|
2944
|
+
const b = [_[0]];
|
|
3145
2945
|
let I = 0;
|
|
3146
2946
|
for (; I < $.length; )
|
|
3147
|
-
l(
|
|
3148
|
-
return new n(
|
|
2947
|
+
l(b, $[I]), b.push(_[++I]);
|
|
2948
|
+
return new n(b);
|
|
3149
2949
|
}
|
|
3150
2950
|
e._ = s;
|
|
3151
2951
|
const i = new n("+");
|
|
3152
2952
|
function o(_, ...$) {
|
|
3153
|
-
const
|
|
2953
|
+
const b = [C(_[0])];
|
|
3154
2954
|
let I = 0;
|
|
3155
2955
|
for (; I < $.length; )
|
|
3156
|
-
|
|
3157
|
-
return d(
|
|
2956
|
+
b.push(i), l(b, $[I]), b.push(i, C(_[++I]));
|
|
2957
|
+
return d(b), new n(b);
|
|
3158
2958
|
}
|
|
3159
2959
|
e.str = o;
|
|
3160
2960
|
function l(_, $) {
|
|
@@ -3165,9 +2965,9 @@ var ajv$1 = { exports: {} }, core$2 = {}, validate = {}, boolSchema = {}, errors
|
|
|
3165
2965
|
let $ = 1;
|
|
3166
2966
|
for (; $ < _.length - 1; ) {
|
|
3167
2967
|
if (_[$] === i) {
|
|
3168
|
-
const
|
|
3169
|
-
if (
|
|
3170
|
-
_.splice($ - 1, 3,
|
|
2968
|
+
const b = u(_[$ - 1], _[$ + 1]);
|
|
2969
|
+
if (b !== void 0) {
|
|
2970
|
+
_.splice($ - 1, 3, b);
|
|
3171
2971
|
continue;
|
|
3172
2972
|
}
|
|
3173
2973
|
_[$++] = "+";
|
|
@@ -3185,10 +2985,10 @@ var ajv$1 = { exports: {} }, core$2 = {}, validate = {}, boolSchema = {}, errors
|
|
|
3185
2985
|
if (typeof $ == "string" && $[0] === '"' && !(_ instanceof r))
|
|
3186
2986
|
return `"${_}${$.slice(1)}`;
|
|
3187
2987
|
}
|
|
3188
|
-
function
|
|
2988
|
+
function f(_, $) {
|
|
3189
2989
|
return $.emptyStr() ? _ : _.emptyStr() ? $ : o`${_}${$}`;
|
|
3190
2990
|
}
|
|
3191
|
-
e.strConcat =
|
|
2991
|
+
e.strConcat = f;
|
|
3192
2992
|
function g(_) {
|
|
3193
2993
|
return typeof _ == "number" || typeof _ == "boolean" || _ === null ? _ : C(Array.isArray(_) ? _.join(",") : _);
|
|
3194
2994
|
}
|
|
@@ -3204,12 +3004,12 @@ var ajv$1 = { exports: {} }, core$2 = {}, validate = {}, boolSchema = {}, errors
|
|
|
3204
3004
|
return typeof _ == "string" && e.IDENTIFIER.test(_) ? new n(`.${_}`) : s`[${_}]`;
|
|
3205
3005
|
}
|
|
3206
3006
|
e.getProperty = S;
|
|
3207
|
-
function
|
|
3007
|
+
function R(_) {
|
|
3208
3008
|
if (typeof _ == "string" && e.IDENTIFIER.test(_))
|
|
3209
3009
|
return new n(`${_}`);
|
|
3210
3010
|
throw new Error(`CodeGen: invalid export name: ${_}, use explicit $id name mapping`);
|
|
3211
3011
|
}
|
|
3212
|
-
e.getEsmExportName =
|
|
3012
|
+
e.getEsmExportName = R;
|
|
3213
3013
|
function y(_) {
|
|
3214
3014
|
return new n(_.toString());
|
|
3215
3015
|
}
|
|
@@ -3233,8 +3033,8 @@ var scope = {};
|
|
|
3233
3033
|
var: new t.Name("var")
|
|
3234
3034
|
};
|
|
3235
3035
|
class s {
|
|
3236
|
-
constructor({ prefixes: u, parent:
|
|
3237
|
-
this._names = {}, this._prefixes = u, this._parent =
|
|
3036
|
+
constructor({ prefixes: u, parent: f } = {}) {
|
|
3037
|
+
this._names = {}, this._prefixes = u, this._parent = f;
|
|
3238
3038
|
}
|
|
3239
3039
|
toName(u) {
|
|
3240
3040
|
return u instanceof t.Name ? u : this.name(u);
|
|
@@ -3243,23 +3043,23 @@ var scope = {};
|
|
|
3243
3043
|
return new t.Name(this._newName(u));
|
|
3244
3044
|
}
|
|
3245
3045
|
_newName(u) {
|
|
3246
|
-
const
|
|
3247
|
-
return `${u}${
|
|
3046
|
+
const f = this._names[u] || this._nameGroup(u);
|
|
3047
|
+
return `${u}${f.index++}`;
|
|
3248
3048
|
}
|
|
3249
3049
|
_nameGroup(u) {
|
|
3250
|
-
var
|
|
3251
|
-
if (!((g = (
|
|
3050
|
+
var f, g;
|
|
3051
|
+
if (!((g = (f = this._parent) === null || f === void 0 ? void 0 : f._prefixes) === null || g === void 0) && g.has(u) || this._prefixes && !this._prefixes.has(u))
|
|
3252
3052
|
throw new Error(`CodeGen: prefix "${u}" is not allowed in this scope`);
|
|
3253
3053
|
return this._names[u] = { prefix: u, index: 0 };
|
|
3254
3054
|
}
|
|
3255
3055
|
}
|
|
3256
3056
|
e.Scope = s;
|
|
3257
3057
|
class i extends t.Name {
|
|
3258
|
-
constructor(u,
|
|
3259
|
-
super(
|
|
3058
|
+
constructor(u, f) {
|
|
3059
|
+
super(f), this.prefix = u;
|
|
3260
3060
|
}
|
|
3261
|
-
setValue(u, { property:
|
|
3262
|
-
this.value = u, this.scopePath = (0, t._)`.${new t.Name(
|
|
3061
|
+
setValue(u, { property: f, itemIndex: g }) {
|
|
3062
|
+
this.value = u, this.scopePath = (0, t._)`.${new t.Name(f)}[${g}]`;
|
|
3263
3063
|
}
|
|
3264
3064
|
}
|
|
3265
3065
|
e.ValueScopeName = i;
|
|
@@ -3274,56 +3074,56 @@ var scope = {};
|
|
|
3274
3074
|
name(u) {
|
|
3275
3075
|
return new i(u, this._newName(u));
|
|
3276
3076
|
}
|
|
3277
|
-
value(u,
|
|
3077
|
+
value(u, f) {
|
|
3278
3078
|
var g;
|
|
3279
|
-
if (
|
|
3079
|
+
if (f.ref === void 0)
|
|
3280
3080
|
throw new Error("CodeGen: ref must be passed in value");
|
|
3281
|
-
const O = this.toName(u), { prefix: C } = O, S = (g =
|
|
3282
|
-
let
|
|
3283
|
-
if (
|
|
3284
|
-
const $ =
|
|
3081
|
+
const O = this.toName(u), { prefix: C } = O, S = (g = f.key) !== null && g !== void 0 ? g : f.ref;
|
|
3082
|
+
let R = this._values[C];
|
|
3083
|
+
if (R) {
|
|
3084
|
+
const $ = R.get(S);
|
|
3285
3085
|
if ($)
|
|
3286
3086
|
return $;
|
|
3287
3087
|
} else
|
|
3288
|
-
|
|
3289
|
-
|
|
3088
|
+
R = this._values[C] = /* @__PURE__ */ new Map();
|
|
3089
|
+
R.set(S, O);
|
|
3290
3090
|
const y = this._scope[C] || (this._scope[C] = []), _ = y.length;
|
|
3291
|
-
return y[_] =
|
|
3091
|
+
return y[_] = f.ref, O.setValue(f, { property: C, itemIndex: _ }), O;
|
|
3292
3092
|
}
|
|
3293
|
-
getValue(u,
|
|
3093
|
+
getValue(u, f) {
|
|
3294
3094
|
const g = this._values[u];
|
|
3295
3095
|
if (g)
|
|
3296
|
-
return g.get(
|
|
3096
|
+
return g.get(f);
|
|
3297
3097
|
}
|
|
3298
|
-
scopeRefs(u,
|
|
3299
|
-
return this._reduceValues(
|
|
3098
|
+
scopeRefs(u, f = this._values) {
|
|
3099
|
+
return this._reduceValues(f, (g) => {
|
|
3300
3100
|
if (g.scopePath === void 0)
|
|
3301
3101
|
throw new Error(`CodeGen: name "${g}" has no value`);
|
|
3302
3102
|
return (0, t._)`${u}${g.scopePath}`;
|
|
3303
3103
|
});
|
|
3304
3104
|
}
|
|
3305
|
-
scopeCode(u = this._values,
|
|
3105
|
+
scopeCode(u = this._values, f, g) {
|
|
3306
3106
|
return this._reduceValues(u, (O) => {
|
|
3307
3107
|
if (O.value === void 0)
|
|
3308
3108
|
throw new Error(`CodeGen: name "${O}" has no value`);
|
|
3309
3109
|
return O.value.code;
|
|
3310
|
-
},
|
|
3110
|
+
}, f, g);
|
|
3311
3111
|
}
|
|
3312
|
-
_reduceValues(u,
|
|
3112
|
+
_reduceValues(u, f, g = {}, O) {
|
|
3313
3113
|
let C = t.nil;
|
|
3314
3114
|
for (const S in u) {
|
|
3315
|
-
const
|
|
3316
|
-
if (!
|
|
3115
|
+
const R = u[S];
|
|
3116
|
+
if (!R)
|
|
3317
3117
|
continue;
|
|
3318
3118
|
const y = g[S] = g[S] || /* @__PURE__ */ new Map();
|
|
3319
|
-
|
|
3119
|
+
R.forEach((_) => {
|
|
3320
3120
|
if (y.has(_))
|
|
3321
3121
|
return;
|
|
3322
3122
|
y.set(_, n.Started);
|
|
3323
|
-
let $ =
|
|
3123
|
+
let $ = f(_);
|
|
3324
3124
|
if ($) {
|
|
3325
|
-
const
|
|
3326
|
-
C = (0, t._)`${C}${
|
|
3125
|
+
const b = this.opts.es5 ? e.varKinds.var : e.varKinds.const;
|
|
3126
|
+
C = (0, t._)`${C}${b} ${_} = ${$};${this.opts._n}`;
|
|
3327
3127
|
} else if ($ = O == null ? void 0 : O(_))
|
|
3328
3128
|
C = (0, t._)`${C}${$}${this.opts._n}`;
|
|
3329
3129
|
else
|
|
@@ -3396,7 +3196,7 @@ var scope = {};
|
|
|
3396
3196
|
}
|
|
3397
3197
|
optimizeNames(a, h) {
|
|
3398
3198
|
if (a[this.name.str])
|
|
3399
|
-
return this.rhs && (this.rhs =
|
|
3199
|
+
return this.rhs && (this.rhs = ie(this.rhs, a, h)), this;
|
|
3400
3200
|
}
|
|
3401
3201
|
get names() {
|
|
3402
3202
|
return this.rhs instanceof t._CodeOrName ? this.rhs.names : {};
|
|
@@ -3411,11 +3211,11 @@ var scope = {};
|
|
|
3411
3211
|
}
|
|
3412
3212
|
optimizeNames(a, h) {
|
|
3413
3213
|
if (!(this.lhs instanceof t.Name && !a[this.lhs.str] && !this.sideEffects))
|
|
3414
|
-
return this.rhs =
|
|
3214
|
+
return this.rhs = ie(this.rhs, a, h), this;
|
|
3415
3215
|
}
|
|
3416
3216
|
get names() {
|
|
3417
3217
|
const a = this.lhs instanceof t.Name ? {} : { ...this.lhs.names };
|
|
3418
|
-
return
|
|
3218
|
+
return de(a, this.rhs);
|
|
3419
3219
|
}
|
|
3420
3220
|
}
|
|
3421
3221
|
class d extends l {
|
|
@@ -3434,7 +3234,7 @@ var scope = {};
|
|
|
3434
3234
|
return `${this.label}:` + a;
|
|
3435
3235
|
}
|
|
3436
3236
|
}
|
|
3437
|
-
class
|
|
3237
|
+
class f extends i {
|
|
3438
3238
|
constructor(a) {
|
|
3439
3239
|
super(), this.label = a, this.names = {};
|
|
3440
3240
|
}
|
|
@@ -3464,7 +3264,7 @@ var scope = {};
|
|
|
3464
3264
|
return `${this.code}` ? this : void 0;
|
|
3465
3265
|
}
|
|
3466
3266
|
optimizeNames(a, h) {
|
|
3467
|
-
return this.code =
|
|
3267
|
+
return this.code = ie(this.code, a, h), this;
|
|
3468
3268
|
}
|
|
3469
3269
|
get names() {
|
|
3470
3270
|
return this.code instanceof t._CodeOrName ? this.code.names : {};
|
|
@@ -3491,12 +3291,12 @@ var scope = {};
|
|
|
3491
3291
|
let M = N.length;
|
|
3492
3292
|
for (; M--; ) {
|
|
3493
3293
|
const q = N[M];
|
|
3494
|
-
q.optimizeNames(a, h) || (
|
|
3294
|
+
q.optimizeNames(a, h) || (Se(a, q.names), N.splice(M, 1));
|
|
3495
3295
|
}
|
|
3496
3296
|
return N.length > 0 ? this : void 0;
|
|
3497
3297
|
}
|
|
3498
3298
|
get names() {
|
|
3499
|
-
return this.nodes.reduce((a, h) =>
|
|
3299
|
+
return this.nodes.reduce((a, h) => G(a, h.names), {});
|
|
3500
3300
|
}
|
|
3501
3301
|
}
|
|
3502
3302
|
class S extends C {
|
|
@@ -3504,7 +3304,7 @@ var scope = {};
|
|
|
3504
3304
|
return "{" + a._n + super.render(a) + "}" + a._n;
|
|
3505
3305
|
}
|
|
3506
3306
|
}
|
|
3507
|
-
class
|
|
3307
|
+
class R extends C {
|
|
3508
3308
|
}
|
|
3509
3309
|
class y extends S {
|
|
3510
3310
|
}
|
|
@@ -3528,25 +3328,25 @@ var scope = {};
|
|
|
3528
3328
|
h = this.else = Array.isArray(N) ? new y(N) : N;
|
|
3529
3329
|
}
|
|
3530
3330
|
if (h)
|
|
3531
|
-
return a === !1 ? h instanceof _ ? h : h.nodes : this.nodes.length ? this : new _(
|
|
3331
|
+
return a === !1 ? h instanceof _ ? h : h.nodes : this.nodes.length ? this : new _(Te(a), h instanceof _ ? [h] : h.nodes);
|
|
3532
3332
|
if (!(a === !1 || !this.nodes.length))
|
|
3533
3333
|
return this;
|
|
3534
3334
|
}
|
|
3535
3335
|
optimizeNames(a, h) {
|
|
3536
3336
|
var N;
|
|
3537
3337
|
if (this.else = (N = this.else) === null || N === void 0 ? void 0 : N.optimizeNames(a, h), !!(super.optimizeNames(a, h) || this.else))
|
|
3538
|
-
return this.condition =
|
|
3338
|
+
return this.condition = ie(this.condition, a, h), this;
|
|
3539
3339
|
}
|
|
3540
3340
|
get names() {
|
|
3541
3341
|
const a = super.names;
|
|
3542
|
-
return
|
|
3342
|
+
return de(a, this.condition), this.else && G(a, this.else.names), a;
|
|
3543
3343
|
}
|
|
3544
3344
|
}
|
|
3545
3345
|
_.kind = "if";
|
|
3546
3346
|
class $ extends S {
|
|
3547
3347
|
}
|
|
3548
3348
|
$.kind = "for";
|
|
3549
|
-
class
|
|
3349
|
+
class b extends $ {
|
|
3550
3350
|
constructor(a) {
|
|
3551
3351
|
super(), this.iteration = a;
|
|
3552
3352
|
}
|
|
@@ -3555,10 +3355,10 @@ var scope = {};
|
|
|
3555
3355
|
}
|
|
3556
3356
|
optimizeNames(a, h) {
|
|
3557
3357
|
if (super.optimizeNames(a, h))
|
|
3558
|
-
return this.iteration =
|
|
3358
|
+
return this.iteration = ie(this.iteration, a, h), this;
|
|
3559
3359
|
}
|
|
3560
3360
|
get names() {
|
|
3561
|
-
return
|
|
3361
|
+
return G(super.names, this.iteration.names);
|
|
3562
3362
|
}
|
|
3563
3363
|
}
|
|
3564
3364
|
class I extends $ {
|
|
@@ -3570,11 +3370,11 @@ var scope = {};
|
|
|
3570
3370
|
return `for(${h} ${N}=${M}; ${N}<${q}; ${N}++)` + super.render(a);
|
|
3571
3371
|
}
|
|
3572
3372
|
get names() {
|
|
3573
|
-
const a =
|
|
3574
|
-
return
|
|
3373
|
+
const a = de(super.names, this.from);
|
|
3374
|
+
return de(a, this.to);
|
|
3575
3375
|
}
|
|
3576
3376
|
}
|
|
3577
|
-
class
|
|
3377
|
+
class A extends $ {
|
|
3578
3378
|
constructor(a, h, N, M) {
|
|
3579
3379
|
super(), this.loop = a, this.varKind = h, this.name = N, this.iterable = M;
|
|
3580
3380
|
}
|
|
@@ -3583,10 +3383,10 @@ var scope = {};
|
|
|
3583
3383
|
}
|
|
3584
3384
|
optimizeNames(a, h) {
|
|
3585
3385
|
if (super.optimizeNames(a, h))
|
|
3586
|
-
return this.iterable =
|
|
3386
|
+
return this.iterable = ie(this.iterable, a, h), this;
|
|
3587
3387
|
}
|
|
3588
3388
|
get names() {
|
|
3589
|
-
return
|
|
3389
|
+
return G(super.names, this.iterable.names);
|
|
3590
3390
|
}
|
|
3591
3391
|
}
|
|
3592
3392
|
class w extends S {
|
|
@@ -3604,7 +3404,7 @@ var scope = {};
|
|
|
3604
3404
|
}
|
|
3605
3405
|
}
|
|
3606
3406
|
k.kind = "return";
|
|
3607
|
-
class
|
|
3407
|
+
class D extends S {
|
|
3608
3408
|
render(a) {
|
|
3609
3409
|
let h = "try" + super.render(a);
|
|
3610
3410
|
return this.catch && (h += this.catch.render(a)), this.finally && (h += this.finally.render(a)), h;
|
|
@@ -3619,7 +3419,7 @@ var scope = {};
|
|
|
3619
3419
|
}
|
|
3620
3420
|
get names() {
|
|
3621
3421
|
const a = super.names;
|
|
3622
|
-
return this.catch &&
|
|
3422
|
+
return this.catch && G(a, this.catch.names), this.finally && G(a, this.finally.names), a;
|
|
3623
3423
|
}
|
|
3624
3424
|
}
|
|
3625
3425
|
class V extends S {
|
|
@@ -3631,16 +3431,16 @@ var scope = {};
|
|
|
3631
3431
|
}
|
|
3632
3432
|
}
|
|
3633
3433
|
V.kind = "catch";
|
|
3634
|
-
class
|
|
3434
|
+
class H extends S {
|
|
3635
3435
|
render(a) {
|
|
3636
3436
|
return "finally" + super.render(a);
|
|
3637
3437
|
}
|
|
3638
3438
|
}
|
|
3639
|
-
|
|
3640
|
-
class
|
|
3439
|
+
H.kind = "finally";
|
|
3440
|
+
class X {
|
|
3641
3441
|
constructor(a, h = {}) {
|
|
3642
3442
|
this._values = {}, this._blockStarts = [], this._constants = {}, this.opts = { ...h, _n: h.lines ? `
|
|
3643
|
-
` : "" }, this._extScope = a, this._scope = new r.Scope({ parent: a }), this._nodes = [new
|
|
3443
|
+
` : "" }, this._extScope = a, this._scope = new r.Scope({ parent: a }), this._nodes = [new R()];
|
|
3644
3444
|
}
|
|
3645
3445
|
toString() {
|
|
3646
3446
|
return this._root.render(this.opts);
|
|
@@ -3731,23 +3531,23 @@ var scope = {};
|
|
|
3731
3531
|
}
|
|
3732
3532
|
// a generic `for` clause (or statement if `forBody` is passed)
|
|
3733
3533
|
for(a, h) {
|
|
3734
|
-
return this._for(new
|
|
3534
|
+
return this._for(new b(a), h);
|
|
3735
3535
|
}
|
|
3736
3536
|
// `for` statement for a range of values
|
|
3737
3537
|
forRange(a, h, N, M, q = this.opts.es5 ? r.varKinds.var : r.varKinds.let) {
|
|
3738
|
-
const
|
|
3739
|
-
return this._for(new I(q,
|
|
3538
|
+
const x = this._scope.toName(a);
|
|
3539
|
+
return this._for(new I(q, x, h, N), () => M(x));
|
|
3740
3540
|
}
|
|
3741
3541
|
// `for-of` statement (in es5 mode replace with a normal for loop)
|
|
3742
3542
|
forOf(a, h, N, M = r.varKinds.const) {
|
|
3743
3543
|
const q = this._scope.toName(a);
|
|
3744
3544
|
if (this.opts.es5) {
|
|
3745
|
-
const
|
|
3746
|
-
return this.forRange("_i", 0, (0, t._)`${
|
|
3747
|
-
this.var(q, (0, t._)`${
|
|
3545
|
+
const x = h instanceof t.Name ? h : this.var("_arr", h);
|
|
3546
|
+
return this.forRange("_i", 0, (0, t._)`${x}.length`, (W) => {
|
|
3547
|
+
this.var(q, (0, t._)`${x}[${W}]`), N(q);
|
|
3748
3548
|
});
|
|
3749
3549
|
}
|
|
3750
|
-
return this._for(new
|
|
3550
|
+
return this._for(new A("of", M, q, h), () => N(q));
|
|
3751
3551
|
}
|
|
3752
3552
|
// `for-in` statement.
|
|
3753
3553
|
// With option `ownProperties` replaced with a `for-of` loop for object keys
|
|
@@ -3755,7 +3555,7 @@ var scope = {};
|
|
|
3755
3555
|
if (this.opts.ownProperties)
|
|
3756
3556
|
return this.forOf(a, (0, t._)`Object.keys(${h})`, N);
|
|
3757
3557
|
const q = this._scope.toName(a);
|
|
3758
|
-
return this._for(new
|
|
3558
|
+
return this._for(new A("in", M, q, h), () => N(q));
|
|
3759
3559
|
}
|
|
3760
3560
|
// end `for` loop
|
|
3761
3561
|
endFor() {
|
|
@@ -3767,7 +3567,7 @@ var scope = {};
|
|
|
3767
3567
|
}
|
|
3768
3568
|
// `break` statement
|
|
3769
3569
|
break(a) {
|
|
3770
|
-
return this._leafNode(new
|
|
3570
|
+
return this._leafNode(new f(a));
|
|
3771
3571
|
}
|
|
3772
3572
|
// `return` statement
|
|
3773
3573
|
return(a) {
|
|
@@ -3780,12 +3580,12 @@ var scope = {};
|
|
|
3780
3580
|
try(a, h, N) {
|
|
3781
3581
|
if (!h && !N)
|
|
3782
3582
|
throw new Error('CodeGen: "try" without "catch" and "finally"');
|
|
3783
|
-
const M = new
|
|
3583
|
+
const M = new D();
|
|
3784
3584
|
if (this._blockNode(M), this.code(a), h) {
|
|
3785
3585
|
const q = this.name("e");
|
|
3786
3586
|
this._currNode = M.catch = new V(q), h(q);
|
|
3787
3587
|
}
|
|
3788
|
-
return N && (this._currNode = M.finally = new
|
|
3588
|
+
return N && (this._currNode = M.finally = new H(), this.code(N)), this._endBlockNode(V, H);
|
|
3789
3589
|
}
|
|
3790
3590
|
// `throw` statement
|
|
3791
3591
|
throw(a) {
|
|
@@ -3847,52 +3647,52 @@ var scope = {};
|
|
|
3847
3647
|
h[h.length - 1] = a;
|
|
3848
3648
|
}
|
|
3849
3649
|
}
|
|
3850
|
-
e.CodeGen =
|
|
3851
|
-
function
|
|
3650
|
+
e.CodeGen = X;
|
|
3651
|
+
function G(P, a) {
|
|
3852
3652
|
for (const h in a)
|
|
3853
|
-
|
|
3854
|
-
return
|
|
3855
|
-
}
|
|
3856
|
-
function
|
|
3857
|
-
return a instanceof t._CodeOrName ?
|
|
3858
|
-
}
|
|
3859
|
-
function
|
|
3860
|
-
if (
|
|
3861
|
-
return N(
|
|
3862
|
-
if (!M(
|
|
3863
|
-
return
|
|
3864
|
-
return new t._Code(
|
|
3653
|
+
P[h] = (P[h] || 0) + (a[h] || 0);
|
|
3654
|
+
return P;
|
|
3655
|
+
}
|
|
3656
|
+
function de(P, a) {
|
|
3657
|
+
return a instanceof t._CodeOrName ? G(P, a.names) : P;
|
|
3658
|
+
}
|
|
3659
|
+
function ie(P, a, h) {
|
|
3660
|
+
if (P instanceof t.Name)
|
|
3661
|
+
return N(P);
|
|
3662
|
+
if (!M(P))
|
|
3663
|
+
return P;
|
|
3664
|
+
return new t._Code(P._items.reduce((q, x) => (x instanceof t.Name && (x = N(x)), x instanceof t._Code ? q.push(...x._items) : q.push(x), q), []));
|
|
3865
3665
|
function N(q) {
|
|
3866
|
-
const
|
|
3867
|
-
return
|
|
3666
|
+
const x = h[q.str];
|
|
3667
|
+
return x === void 0 || a[q.str] !== 1 ? q : (delete a[q.str], x);
|
|
3868
3668
|
}
|
|
3869
3669
|
function M(q) {
|
|
3870
|
-
return q instanceof t._Code && q._items.some((
|
|
3670
|
+
return q instanceof t._Code && q._items.some((x) => x instanceof t.Name && a[x.str] === 1 && h[x.str] !== void 0);
|
|
3871
3671
|
}
|
|
3872
3672
|
}
|
|
3873
|
-
function
|
|
3673
|
+
function Se(P, a) {
|
|
3874
3674
|
for (const h in a)
|
|
3875
|
-
|
|
3675
|
+
P[h] = (P[h] || 0) - (a[h] || 0);
|
|
3876
3676
|
}
|
|
3877
|
-
function
|
|
3878
|
-
return typeof
|
|
3677
|
+
function Te(P) {
|
|
3678
|
+
return typeof P == "boolean" || typeof P == "number" || P === null ? !P : (0, t._)`!${j(P)}`;
|
|
3879
3679
|
}
|
|
3880
|
-
e.not =
|
|
3881
|
-
const
|
|
3882
|
-
function
|
|
3883
|
-
return
|
|
3680
|
+
e.not = Te;
|
|
3681
|
+
const Ie = v(e.operators.AND);
|
|
3682
|
+
function xe(...P) {
|
|
3683
|
+
return P.reduce(Ie);
|
|
3884
3684
|
}
|
|
3885
|
-
e.and =
|
|
3886
|
-
const
|
|
3887
|
-
function F(...
|
|
3888
|
-
return
|
|
3685
|
+
e.and = xe;
|
|
3686
|
+
const je = v(e.operators.OR);
|
|
3687
|
+
function F(...P) {
|
|
3688
|
+
return P.reduce(je);
|
|
3889
3689
|
}
|
|
3890
3690
|
e.or = F;
|
|
3891
|
-
function v(
|
|
3892
|
-
return (a, h) => a === t.nil ? h : h === t.nil ? a : (0, t._)`${j(a)} ${
|
|
3691
|
+
function v(P) {
|
|
3692
|
+
return (a, h) => a === t.nil ? h : h === t.nil ? a : (0, t._)`${j(a)} ${P} ${j(h)}`;
|
|
3893
3693
|
}
|
|
3894
|
-
function j(
|
|
3895
|
-
return
|
|
3694
|
+
function j(P) {
|
|
3695
|
+
return P instanceof t.Name ? P : (0, t._)`(${P})`;
|
|
3896
3696
|
}
|
|
3897
3697
|
})(codegen);
|
|
3898
3698
|
var util = {};
|
|
@@ -3901,8 +3701,8 @@ var util = {};
|
|
|
3901
3701
|
const t = codegen, r = code$1;
|
|
3902
3702
|
function n(w) {
|
|
3903
3703
|
const k = {};
|
|
3904
|
-
for (const
|
|
3905
|
-
k[
|
|
3704
|
+
for (const D of w)
|
|
3705
|
+
k[D] = !0;
|
|
3906
3706
|
return k;
|
|
3907
3707
|
}
|
|
3908
3708
|
e.toHash = n;
|
|
@@ -3911,19 +3711,19 @@ var util = {};
|
|
|
3911
3711
|
}
|
|
3912
3712
|
e.alwaysValidSchema = s;
|
|
3913
3713
|
function i(w, k = w.schema) {
|
|
3914
|
-
const { opts:
|
|
3915
|
-
if (!
|
|
3714
|
+
const { opts: D, self: V } = w;
|
|
3715
|
+
if (!D.strictSchema || typeof k == "boolean")
|
|
3916
3716
|
return;
|
|
3917
|
-
const
|
|
3918
|
-
for (const
|
|
3919
|
-
|
|
3717
|
+
const H = V.RULES.keywords;
|
|
3718
|
+
for (const X in k)
|
|
3719
|
+
H[X] || A(w, `unknown keyword: "${X}"`);
|
|
3920
3720
|
}
|
|
3921
3721
|
e.checkUnknownRules = i;
|
|
3922
3722
|
function o(w, k) {
|
|
3923
3723
|
if (typeof w == "boolean")
|
|
3924
3724
|
return !w;
|
|
3925
|
-
for (const
|
|
3926
|
-
if (k[
|
|
3725
|
+
for (const D in w)
|
|
3726
|
+
if (k[D])
|
|
3927
3727
|
return !0;
|
|
3928
3728
|
return !1;
|
|
3929
3729
|
}
|
|
@@ -3931,18 +3731,18 @@ var util = {};
|
|
|
3931
3731
|
function l(w, k) {
|
|
3932
3732
|
if (typeof w == "boolean")
|
|
3933
3733
|
return !w;
|
|
3934
|
-
for (const
|
|
3935
|
-
if (
|
|
3734
|
+
for (const D in w)
|
|
3735
|
+
if (D !== "$ref" && k.all[D])
|
|
3936
3736
|
return !0;
|
|
3937
3737
|
return !1;
|
|
3938
3738
|
}
|
|
3939
3739
|
e.schemaHasRulesButRef = l;
|
|
3940
|
-
function d({ topSchemaRef: w, schemaPath: k },
|
|
3941
|
-
if (!
|
|
3942
|
-
if (typeof
|
|
3943
|
-
return
|
|
3944
|
-
if (typeof
|
|
3945
|
-
return (0, t._)`${
|
|
3740
|
+
function d({ topSchemaRef: w, schemaPath: k }, D, V, H) {
|
|
3741
|
+
if (!H) {
|
|
3742
|
+
if (typeof D == "number" || typeof D == "boolean")
|
|
3743
|
+
return D;
|
|
3744
|
+
if (typeof D == "string")
|
|
3745
|
+
return (0, t._)`${D}`;
|
|
3946
3746
|
}
|
|
3947
3747
|
return (0, t._)`${w}${k}${(0, t.getProperty)(V)}`;
|
|
3948
3748
|
}
|
|
@@ -3951,10 +3751,10 @@ var util = {};
|
|
|
3951
3751
|
return O(decodeURIComponent(w));
|
|
3952
3752
|
}
|
|
3953
3753
|
e.unescapeFragment = u;
|
|
3954
|
-
function
|
|
3754
|
+
function f(w) {
|
|
3955
3755
|
return encodeURIComponent(g(w));
|
|
3956
3756
|
}
|
|
3957
|
-
e.escapeFragment =
|
|
3757
|
+
e.escapeFragment = f;
|
|
3958
3758
|
function g(w) {
|
|
3959
3759
|
return typeof w == "number" ? `${w}` : w.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
3960
3760
|
}
|
|
@@ -3965,45 +3765,45 @@ var util = {};
|
|
|
3965
3765
|
e.unescapeJsonPointer = O;
|
|
3966
3766
|
function C(w, k) {
|
|
3967
3767
|
if (Array.isArray(w))
|
|
3968
|
-
for (const
|
|
3969
|
-
k(
|
|
3768
|
+
for (const D of w)
|
|
3769
|
+
k(D);
|
|
3970
3770
|
else
|
|
3971
3771
|
k(w);
|
|
3972
3772
|
}
|
|
3973
3773
|
e.eachItem = C;
|
|
3974
|
-
function S({ mergeNames: w, mergeToName: k, mergeValues:
|
|
3975
|
-
return (
|
|
3976
|
-
const
|
|
3977
|
-
return
|
|
3774
|
+
function S({ mergeNames: w, mergeToName: k, mergeValues: D, resultToName: V }) {
|
|
3775
|
+
return (H, X, G, de) => {
|
|
3776
|
+
const ie = G === void 0 ? X : G instanceof t.Name ? (X instanceof t.Name ? w(H, X, G) : k(H, X, G), G) : X instanceof t.Name ? (k(H, G, X), X) : D(X, G);
|
|
3777
|
+
return de === t.Name && !(ie instanceof t.Name) ? V(H, ie) : ie;
|
|
3978
3778
|
};
|
|
3979
3779
|
}
|
|
3980
3780
|
e.mergeEvaluated = {
|
|
3981
3781
|
props: S({
|
|
3982
|
-
mergeNames: (w, k,
|
|
3983
|
-
w.if((0, t._)`${k} === true`, () => w.assign(
|
|
3782
|
+
mergeNames: (w, k, D) => w.if((0, t._)`${D} !== true && ${k} !== undefined`, () => {
|
|
3783
|
+
w.if((0, t._)`${k} === true`, () => w.assign(D, !0), () => w.assign(D, (0, t._)`${D} || {}`).code((0, t._)`Object.assign(${D}, ${k})`));
|
|
3984
3784
|
}),
|
|
3985
|
-
mergeToName: (w, k,
|
|
3986
|
-
k === !0 ? w.assign(
|
|
3785
|
+
mergeToName: (w, k, D) => w.if((0, t._)`${D} !== true`, () => {
|
|
3786
|
+
k === !0 ? w.assign(D, !0) : (w.assign(D, (0, t._)`${D} || {}`), y(w, D, k));
|
|
3987
3787
|
}),
|
|
3988
3788
|
mergeValues: (w, k) => w === !0 ? !0 : { ...w, ...k },
|
|
3989
|
-
resultToName:
|
|
3789
|
+
resultToName: R
|
|
3990
3790
|
}),
|
|
3991
3791
|
items: S({
|
|
3992
|
-
mergeNames: (w, k,
|
|
3993
|
-
mergeToName: (w, k,
|
|
3792
|
+
mergeNames: (w, k, D) => w.if((0, t._)`${D} !== true && ${k} !== undefined`, () => w.assign(D, (0, t._)`${k} === true ? true : ${D} > ${k} ? ${D} : ${k}`)),
|
|
3793
|
+
mergeToName: (w, k, D) => w.if((0, t._)`${D} !== true`, () => w.assign(D, k === !0 ? !0 : (0, t._)`${D} > ${k} ? ${D} : ${k}`)),
|
|
3994
3794
|
mergeValues: (w, k) => w === !0 ? !0 : Math.max(w, k),
|
|
3995
3795
|
resultToName: (w, k) => w.var("items", k)
|
|
3996
3796
|
})
|
|
3997
3797
|
};
|
|
3998
|
-
function
|
|
3798
|
+
function R(w, k) {
|
|
3999
3799
|
if (k === !0)
|
|
4000
3800
|
return w.var("props", !0);
|
|
4001
|
-
const
|
|
4002
|
-
return k !== void 0 && y(w,
|
|
3801
|
+
const D = w.var("props", (0, t._)`{}`);
|
|
3802
|
+
return k !== void 0 && y(w, D, k), D;
|
|
4003
3803
|
}
|
|
4004
|
-
e.evaluatedPropsToName =
|
|
4005
|
-
function y(w, k,
|
|
4006
|
-
Object.keys(
|
|
3804
|
+
e.evaluatedPropsToName = R;
|
|
3805
|
+
function y(w, k, D) {
|
|
3806
|
+
Object.keys(D).forEach((V) => w.assign((0, t._)`${k}${(0, t.getProperty)(V)}`, !0));
|
|
4007
3807
|
}
|
|
4008
3808
|
e.setEvaluated = y;
|
|
4009
3809
|
const _ = {};
|
|
@@ -4014,26 +3814,26 @@ var util = {};
|
|
|
4014
3814
|
});
|
|
4015
3815
|
}
|
|
4016
3816
|
e.useFunc = $;
|
|
4017
|
-
var
|
|
3817
|
+
var b;
|
|
4018
3818
|
(function(w) {
|
|
4019
3819
|
w[w.Num = 0] = "Num", w[w.Str = 1] = "Str";
|
|
4020
|
-
})(
|
|
4021
|
-
function I(w, k,
|
|
3820
|
+
})(b = e.Type || (e.Type = {}));
|
|
3821
|
+
function I(w, k, D) {
|
|
4022
3822
|
if (w instanceof t.Name) {
|
|
4023
|
-
const V = k ===
|
|
4024
|
-
return
|
|
3823
|
+
const V = k === b.Num;
|
|
3824
|
+
return D ? V ? (0, t._)`"[" + ${w} + "]"` : (0, t._)`"['" + ${w} + "']"` : V ? (0, t._)`"/" + ${w}` : (0, t._)`"/" + ${w}.replace(/~/g, "~0").replace(/\\//g, "~1")`;
|
|
4025
3825
|
}
|
|
4026
|
-
return
|
|
3826
|
+
return D ? (0, t.getProperty)(w).toString() : "/" + g(w);
|
|
4027
3827
|
}
|
|
4028
3828
|
e.getErrorPath = I;
|
|
4029
|
-
function
|
|
4030
|
-
if (
|
|
4031
|
-
if (k = `strict mode: ${k}`,
|
|
3829
|
+
function A(w, k, D = w.opts.strictSchema) {
|
|
3830
|
+
if (D) {
|
|
3831
|
+
if (k = `strict mode: ${k}`, D === !0)
|
|
4032
3832
|
throw new Error(k);
|
|
4033
3833
|
w.self.logger.warn(k);
|
|
4034
3834
|
}
|
|
4035
3835
|
}
|
|
4036
|
-
e.checkStrictMode =
|
|
3836
|
+
e.checkStrictMode = A;
|
|
4037
3837
|
})(util);
|
|
4038
3838
|
var names$1 = {};
|
|
4039
3839
|
Object.defineProperty(names$1, "__esModule", { value: !0 });
|
|
@@ -4069,26 +3869,26 @@ names$1.default = names;
|
|
|
4069
3869
|
}, e.keyword$DataError = {
|
|
4070
3870
|
message: ({ keyword: y, schemaType: _ }) => _ ? (0, t.str)`"${y}" keyword must be ${_} ($data)` : (0, t.str)`"${y}" keyword is invalid ($data)`
|
|
4071
3871
|
};
|
|
4072
|
-
function s(y, _ = e.keywordError, $,
|
|
4073
|
-
const { it: I } = y, { gen:
|
|
4074
|
-
|
|
3872
|
+
function s(y, _ = e.keywordError, $, b) {
|
|
3873
|
+
const { it: I } = y, { gen: A, compositeRule: w, allErrors: k } = I, D = g(y, _, $);
|
|
3874
|
+
b ?? (w || k) ? d(A, D) : u(I, (0, t._)`[${D}]`);
|
|
4075
3875
|
}
|
|
4076
3876
|
e.reportError = s;
|
|
4077
3877
|
function i(y, _ = e.keywordError, $) {
|
|
4078
|
-
const { it:
|
|
4079
|
-
d(I, k),
|
|
3878
|
+
const { it: b } = y, { gen: I, compositeRule: A, allErrors: w } = b, k = g(y, _, $);
|
|
3879
|
+
d(I, k), A || w || u(b, n.default.vErrors);
|
|
4080
3880
|
}
|
|
4081
3881
|
e.reportExtraError = i;
|
|
4082
3882
|
function o(y, _) {
|
|
4083
3883
|
y.assign(n.default.errors, _), y.if((0, t._)`${n.default.vErrors} !== null`, () => y.if(_, () => y.assign((0, t._)`${n.default.vErrors}.length`, _), () => y.assign(n.default.vErrors, null)));
|
|
4084
3884
|
}
|
|
4085
3885
|
e.resetErrorsCount = o;
|
|
4086
|
-
function l({ gen: y, keyword: _, schemaValue: $, data:
|
|
3886
|
+
function l({ gen: y, keyword: _, schemaValue: $, data: b, errsCount: I, it: A }) {
|
|
4087
3887
|
if (I === void 0)
|
|
4088
3888
|
throw new Error("ajv implementation error");
|
|
4089
3889
|
const w = y.name("err");
|
|
4090
3890
|
y.forRange("i", I, n.default.errors, (k) => {
|
|
4091
|
-
y.const(w, (0, t._)`${n.default.vErrors}[${k}]`), y.if((0, t._)`${w}.instancePath === undefined`, () => y.assign((0, t._)`${w}.instancePath`, (0, t.strConcat)(n.default.instancePath,
|
|
3891
|
+
y.const(w, (0, t._)`${n.default.vErrors}[${k}]`), y.if((0, t._)`${w}.instancePath === undefined`, () => y.assign((0, t._)`${w}.instancePath`, (0, t.strConcat)(n.default.instancePath, A.errorPath))), y.assign((0, t._)`${w}.schemaPath`, (0, t.str)`${A.errSchemaPath}/${_}`), A.opts.verbose && (y.assign((0, t._)`${w}.schema`, $), y.assign((0, t._)`${w}.data`, b));
|
|
4092
3892
|
});
|
|
4093
3893
|
}
|
|
4094
3894
|
e.extendErrors = l;
|
|
@@ -4097,10 +3897,10 @@ names$1.default = names;
|
|
|
4097
3897
|
y.if((0, t._)`${n.default.vErrors} === null`, () => y.assign(n.default.vErrors, (0, t._)`[${$}]`), (0, t._)`${n.default.vErrors}.push(${$})`), y.code((0, t._)`${n.default.errors}++`);
|
|
4098
3898
|
}
|
|
4099
3899
|
function u(y, _) {
|
|
4100
|
-
const { gen: $, validateName:
|
|
4101
|
-
I.$async ? $.throw((0, t._)`new ${y.ValidationError}(${_})`) : ($.assign((0, t._)`${
|
|
3900
|
+
const { gen: $, validateName: b, schemaEnv: I } = y;
|
|
3901
|
+
I.$async ? $.throw((0, t._)`new ${y.ValidationError}(${_})`) : ($.assign((0, t._)`${b}.errors`, _), $.return(!1));
|
|
4102
3902
|
}
|
|
4103
|
-
const
|
|
3903
|
+
const f = {
|
|
4104
3904
|
keyword: new t.Name("keyword"),
|
|
4105
3905
|
schemaPath: new t.Name("schemaPath"),
|
|
4106
3906
|
params: new t.Name("params"),
|
|
@@ -4110,27 +3910,27 @@ names$1.default = names;
|
|
|
4110
3910
|
parentSchema: new t.Name("parentSchema")
|
|
4111
3911
|
};
|
|
4112
3912
|
function g(y, _, $) {
|
|
4113
|
-
const { createErrors:
|
|
4114
|
-
return
|
|
3913
|
+
const { createErrors: b } = y.it;
|
|
3914
|
+
return b === !1 ? (0, t._)`{}` : O(y, _, $);
|
|
4115
3915
|
}
|
|
4116
3916
|
function O(y, _, $ = {}) {
|
|
4117
|
-
const { gen:
|
|
3917
|
+
const { gen: b, it: I } = y, A = [
|
|
4118
3918
|
C(I, $),
|
|
4119
3919
|
S(y, $)
|
|
4120
3920
|
];
|
|
4121
|
-
return
|
|
3921
|
+
return R(y, _, A), b.object(...A);
|
|
4122
3922
|
}
|
|
4123
3923
|
function C({ errorPath: y }, { instancePath: _ }) {
|
|
4124
3924
|
const $ = _ ? (0, t.str)`${y}${(0, r.getErrorPath)(_, r.Type.Str)}` : y;
|
|
4125
3925
|
return [n.default.instancePath, (0, t.strConcat)(n.default.instancePath, $)];
|
|
4126
3926
|
}
|
|
4127
|
-
function S({ keyword: y, it: { errSchemaPath: _ } }, { schemaPath: $, parentSchema:
|
|
4128
|
-
let I =
|
|
4129
|
-
return $ && (I = (0, t.str)`${I}${(0, r.getErrorPath)($, r.Type.Str)}`), [
|
|
3927
|
+
function S({ keyword: y, it: { errSchemaPath: _ } }, { schemaPath: $, parentSchema: b }) {
|
|
3928
|
+
let I = b ? _ : (0, t.str)`${_}/${y}`;
|
|
3929
|
+
return $ && (I = (0, t.str)`${I}${(0, r.getErrorPath)($, r.Type.Str)}`), [f.schemaPath, I];
|
|
4130
3930
|
}
|
|
4131
|
-
function
|
|
4132
|
-
const { keyword: I, data:
|
|
4133
|
-
|
|
3931
|
+
function R(y, { params: _, message: $ }, b) {
|
|
3932
|
+
const { keyword: I, data: A, schemaValue: w, it: k } = y, { opts: D, propertyName: V, topSchemaRef: H, schemaPath: X } = k;
|
|
3933
|
+
b.push([f.keyword, I], [f.params, typeof _ == "function" ? _(y) : _ || (0, t._)`{}`]), D.messages && b.push([f.message, typeof $ == "function" ? $(y) : $]), D.verbose && b.push([f.schema, w], [f.parentSchema, (0, t._)`${H}${X}`], [n.default.data, A]), V && b.push([f.propertyName, V]);
|
|
4134
3934
|
}
|
|
4135
3935
|
})(errors);
|
|
4136
3936
|
Object.defineProperty(boolSchema, "__esModule", { value: !0 });
|
|
@@ -4206,144 +4006,144 @@ applicability.shouldUseRule = shouldUseRule;
|
|
|
4206
4006
|
Object.defineProperty(e, "__esModule", { value: !0 }), e.reportTypeError = e.checkDataTypes = e.checkDataType = e.coerceAndCheckDataType = e.getJSONTypes = e.getSchemaTypes = e.DataType = void 0;
|
|
4207
4007
|
const t = rules, r = applicability, n = errors, s = codegen, i = util;
|
|
4208
4008
|
var o;
|
|
4209
|
-
(function(
|
|
4210
|
-
|
|
4009
|
+
(function(b) {
|
|
4010
|
+
b[b.Correct = 0] = "Correct", b[b.Wrong = 1] = "Wrong";
|
|
4211
4011
|
})(o = e.DataType || (e.DataType = {}));
|
|
4212
|
-
function l(
|
|
4213
|
-
const I = d(
|
|
4012
|
+
function l(b) {
|
|
4013
|
+
const I = d(b.type);
|
|
4214
4014
|
if (I.includes("null")) {
|
|
4215
|
-
if (
|
|
4015
|
+
if (b.nullable === !1)
|
|
4216
4016
|
throw new Error("type: null contradicts nullable: false");
|
|
4217
4017
|
} else {
|
|
4218
|
-
if (!I.length &&
|
|
4018
|
+
if (!I.length && b.nullable !== void 0)
|
|
4219
4019
|
throw new Error('"nullable" cannot be used without "type"');
|
|
4220
|
-
|
|
4020
|
+
b.nullable === !0 && I.push("null");
|
|
4221
4021
|
}
|
|
4222
4022
|
return I;
|
|
4223
4023
|
}
|
|
4224
4024
|
e.getSchemaTypes = l;
|
|
4225
|
-
function d(
|
|
4226
|
-
const I = Array.isArray(
|
|
4025
|
+
function d(b) {
|
|
4026
|
+
const I = Array.isArray(b) ? b : b ? [b] : [];
|
|
4227
4027
|
if (I.every(t.isJSONType))
|
|
4228
4028
|
return I;
|
|
4229
4029
|
throw new Error("type must be JSONType or JSONType[]: " + I.join(","));
|
|
4230
4030
|
}
|
|
4231
4031
|
e.getJSONTypes = d;
|
|
4232
|
-
function u(
|
|
4233
|
-
const { gen:
|
|
4032
|
+
function u(b, I) {
|
|
4033
|
+
const { gen: A, data: w, opts: k } = b, D = g(I, k.coerceTypes), V = I.length > 0 && !(D.length === 0 && I.length === 1 && (0, r.schemaHasRulesForType)(b, I[0]));
|
|
4234
4034
|
if (V) {
|
|
4235
|
-
const
|
|
4236
|
-
|
|
4237
|
-
|
|
4035
|
+
const H = R(I, w, k.strictNumbers, o.Wrong);
|
|
4036
|
+
A.if(H, () => {
|
|
4037
|
+
D.length ? O(b, I, D) : _(b);
|
|
4238
4038
|
});
|
|
4239
4039
|
}
|
|
4240
4040
|
return V;
|
|
4241
4041
|
}
|
|
4242
4042
|
e.coerceAndCheckDataType = u;
|
|
4243
|
-
const
|
|
4244
|
-
function g(
|
|
4245
|
-
return I ?
|
|
4246
|
-
}
|
|
4247
|
-
function O(
|
|
4248
|
-
const { gen: w, data: k, opts:
|
|
4249
|
-
|
|
4250
|
-
for (const
|
|
4251
|
-
(
|
|
4252
|
-
w.else(), _(
|
|
4253
|
-
w.assign(k,
|
|
4043
|
+
const f = /* @__PURE__ */ new Set(["string", "number", "integer", "boolean", "null"]);
|
|
4044
|
+
function g(b, I) {
|
|
4045
|
+
return I ? b.filter((A) => f.has(A) || I === "array" && A === "array") : [];
|
|
4046
|
+
}
|
|
4047
|
+
function O(b, I, A) {
|
|
4048
|
+
const { gen: w, data: k, opts: D } = b, V = w.let("dataType", (0, s._)`typeof ${k}`), H = w.let("coerced", (0, s._)`undefined`);
|
|
4049
|
+
D.coerceTypes === "array" && w.if((0, s._)`${V} == 'object' && Array.isArray(${k}) && ${k}.length == 1`, () => w.assign(k, (0, s._)`${k}[0]`).assign(V, (0, s._)`typeof ${k}`).if(R(I, k, D.strictNumbers), () => w.assign(H, k))), w.if((0, s._)`${H} !== undefined`);
|
|
4050
|
+
for (const G of A)
|
|
4051
|
+
(f.has(G) || G === "array" && D.coerceTypes === "array") && X(G);
|
|
4052
|
+
w.else(), _(b), w.endIf(), w.if((0, s._)`${H} !== undefined`, () => {
|
|
4053
|
+
w.assign(k, H), C(b, H);
|
|
4254
4054
|
});
|
|
4255
|
-
function
|
|
4256
|
-
switch (
|
|
4055
|
+
function X(G) {
|
|
4056
|
+
switch (G) {
|
|
4257
4057
|
case "string":
|
|
4258
|
-
w.elseIf((0, s._)`${V} == "number" || ${V} == "boolean"`).assign(
|
|
4058
|
+
w.elseIf((0, s._)`${V} == "number" || ${V} == "boolean"`).assign(H, (0, s._)`"" + ${k}`).elseIf((0, s._)`${k} === null`).assign(H, (0, s._)`""`);
|
|
4259
4059
|
return;
|
|
4260
4060
|
case "number":
|
|
4261
4061
|
w.elseIf((0, s._)`${V} == "boolean" || ${k} === null
|
|
4262
|
-
|| (${V} == "string" && ${k} && ${k} == +${k})`).assign(
|
|
4062
|
+
|| (${V} == "string" && ${k} && ${k} == +${k})`).assign(H, (0, s._)`+${k}`);
|
|
4263
4063
|
return;
|
|
4264
4064
|
case "integer":
|
|
4265
4065
|
w.elseIf((0, s._)`${V} === "boolean" || ${k} === null
|
|
4266
|
-
|| (${V} === "string" && ${k} && ${k} == +${k} && !(${k} % 1))`).assign(
|
|
4066
|
+
|| (${V} === "string" && ${k} && ${k} == +${k} && !(${k} % 1))`).assign(H, (0, s._)`+${k}`);
|
|
4267
4067
|
return;
|
|
4268
4068
|
case "boolean":
|
|
4269
|
-
w.elseIf((0, s._)`${k} === "false" || ${k} === 0 || ${k} === null`).assign(
|
|
4069
|
+
w.elseIf((0, s._)`${k} === "false" || ${k} === 0 || ${k} === null`).assign(H, !1).elseIf((0, s._)`${k} === "true" || ${k} === 1`).assign(H, !0);
|
|
4270
4070
|
return;
|
|
4271
4071
|
case "null":
|
|
4272
|
-
w.elseIf((0, s._)`${k} === "" || ${k} === 0 || ${k} === false`), w.assign(
|
|
4072
|
+
w.elseIf((0, s._)`${k} === "" || ${k} === 0 || ${k} === false`), w.assign(H, null);
|
|
4273
4073
|
return;
|
|
4274
4074
|
case "array":
|
|
4275
4075
|
w.elseIf((0, s._)`${V} === "string" || ${V} === "number"
|
|
4276
|
-
|| ${V} === "boolean" || ${k} === null`).assign(
|
|
4076
|
+
|| ${V} === "boolean" || ${k} === null`).assign(H, (0, s._)`[${k}]`);
|
|
4277
4077
|
}
|
|
4278
4078
|
}
|
|
4279
4079
|
}
|
|
4280
|
-
function C({ gen:
|
|
4281
|
-
|
|
4080
|
+
function C({ gen: b, parentData: I, parentDataProperty: A }, w) {
|
|
4081
|
+
b.if((0, s._)`${I} !== undefined`, () => b.assign((0, s._)`${I}[${A}]`, w));
|
|
4282
4082
|
}
|
|
4283
|
-
function S(
|
|
4083
|
+
function S(b, I, A, w = o.Correct) {
|
|
4284
4084
|
const k = w === o.Correct ? s.operators.EQ : s.operators.NEQ;
|
|
4285
|
-
let
|
|
4286
|
-
switch (
|
|
4085
|
+
let D;
|
|
4086
|
+
switch (b) {
|
|
4287
4087
|
case "null":
|
|
4288
4088
|
return (0, s._)`${I} ${k} null`;
|
|
4289
4089
|
case "array":
|
|
4290
|
-
|
|
4090
|
+
D = (0, s._)`Array.isArray(${I})`;
|
|
4291
4091
|
break;
|
|
4292
4092
|
case "object":
|
|
4293
|
-
|
|
4093
|
+
D = (0, s._)`${I} && typeof ${I} == "object" && !Array.isArray(${I})`;
|
|
4294
4094
|
break;
|
|
4295
4095
|
case "integer":
|
|
4296
|
-
|
|
4096
|
+
D = V((0, s._)`!(${I} % 1) && !isNaN(${I})`);
|
|
4297
4097
|
break;
|
|
4298
4098
|
case "number":
|
|
4299
|
-
|
|
4099
|
+
D = V();
|
|
4300
4100
|
break;
|
|
4301
4101
|
default:
|
|
4302
|
-
return (0, s._)`typeof ${I} ${k} ${
|
|
4102
|
+
return (0, s._)`typeof ${I} ${k} ${b}`;
|
|
4303
4103
|
}
|
|
4304
|
-
return w === o.Correct ?
|
|
4305
|
-
function V(
|
|
4306
|
-
return (0, s.and)((0, s._)`typeof ${I} == "number"`,
|
|
4104
|
+
return w === o.Correct ? D : (0, s.not)(D);
|
|
4105
|
+
function V(H = s.nil) {
|
|
4106
|
+
return (0, s.and)((0, s._)`typeof ${I} == "number"`, H, A ? (0, s._)`isFinite(${I})` : s.nil);
|
|
4307
4107
|
}
|
|
4308
4108
|
}
|
|
4309
4109
|
e.checkDataType = S;
|
|
4310
|
-
function
|
|
4311
|
-
if (
|
|
4312
|
-
return S(
|
|
4110
|
+
function R(b, I, A, w) {
|
|
4111
|
+
if (b.length === 1)
|
|
4112
|
+
return S(b[0], I, A, w);
|
|
4313
4113
|
let k;
|
|
4314
|
-
const
|
|
4315
|
-
if (
|
|
4114
|
+
const D = (0, i.toHash)(b);
|
|
4115
|
+
if (D.array && D.object) {
|
|
4316
4116
|
const V = (0, s._)`typeof ${I} != "object"`;
|
|
4317
|
-
k =
|
|
4117
|
+
k = D.null ? V : (0, s._)`!${I} || ${V}`, delete D.null, delete D.array, delete D.object;
|
|
4318
4118
|
} else
|
|
4319
4119
|
k = s.nil;
|
|
4320
|
-
|
|
4321
|
-
for (const V in
|
|
4322
|
-
k = (0, s.and)(k, S(V, I,
|
|
4120
|
+
D.number && delete D.integer;
|
|
4121
|
+
for (const V in D)
|
|
4122
|
+
k = (0, s.and)(k, S(V, I, A, w));
|
|
4323
4123
|
return k;
|
|
4324
4124
|
}
|
|
4325
|
-
e.checkDataTypes =
|
|
4125
|
+
e.checkDataTypes = R;
|
|
4326
4126
|
const y = {
|
|
4327
|
-
message: ({ schema:
|
|
4328
|
-
params: ({ schema:
|
|
4127
|
+
message: ({ schema: b }) => `must be ${b}`,
|
|
4128
|
+
params: ({ schema: b, schemaValue: I }) => typeof b == "string" ? (0, s._)`{type: ${b}}` : (0, s._)`{type: ${I}}`
|
|
4329
4129
|
};
|
|
4330
|
-
function _(
|
|
4331
|
-
const I = $(
|
|
4130
|
+
function _(b) {
|
|
4131
|
+
const I = $(b);
|
|
4332
4132
|
(0, n.reportError)(I, y);
|
|
4333
4133
|
}
|
|
4334
4134
|
e.reportTypeError = _;
|
|
4335
|
-
function $(
|
|
4336
|
-
const { gen: I, data:
|
|
4135
|
+
function $(b) {
|
|
4136
|
+
const { gen: I, data: A, schema: w } = b, k = (0, i.schemaRefOrVal)(b, w, "type");
|
|
4337
4137
|
return {
|
|
4338
4138
|
gen: I,
|
|
4339
4139
|
keyword: "type",
|
|
4340
|
-
data:
|
|
4140
|
+
data: A,
|
|
4341
4141
|
schema: w.type,
|
|
4342
4142
|
schemaCode: k,
|
|
4343
4143
|
schemaValue: k,
|
|
4344
4144
|
parentSchema: w,
|
|
4345
4145
|
params: {},
|
|
4346
|
-
it:
|
|
4146
|
+
it: b
|
|
4347
4147
|
};
|
|
4348
4148
|
}
|
|
4349
4149
|
})(dataType);
|
|
@@ -4422,14 +4222,14 @@ function schemaProperties(e, t) {
|
|
|
4422
4222
|
}
|
|
4423
4223
|
code.schemaProperties = schemaProperties;
|
|
4424
4224
|
function callValidateCode({ schemaCode: e, data: t, it: { gen: r, topSchemaRef: n, schemaPath: s, errorPath: i }, it: o }, l, d, u) {
|
|
4425
|
-
const
|
|
4225
|
+
const f = u ? (0, codegen_1$q._)`${e}, ${t}, ${n}${s}` : t, g = [
|
|
4426
4226
|
[names_1$5.default.instancePath, (0, codegen_1$q.strConcat)(names_1$5.default.instancePath, i)],
|
|
4427
4227
|
[names_1$5.default.parentData, o.parentData],
|
|
4428
4228
|
[names_1$5.default.parentDataProperty, o.parentDataProperty],
|
|
4429
4229
|
[names_1$5.default.rootData, names_1$5.default.rootData]
|
|
4430
4230
|
];
|
|
4431
4231
|
o.opts.dynamicRef && g.push([names_1$5.default.dynamicAnchors, names_1$5.default.dynamicAnchors]);
|
|
4432
|
-
const O = (0, codegen_1$q._)`${
|
|
4232
|
+
const O = (0, codegen_1$q._)`${f}, ${r.object(...g)}`;
|
|
4433
4233
|
return d !== codegen_1$q.nil ? (0, codegen_1$q._)`${l}.call(${d}, ${O})` : (0, codegen_1$q._)`${l}(${O})`;
|
|
4434
4234
|
}
|
|
4435
4235
|
code.callValidateCode = callValidateCode;
|
|
@@ -4470,12 +4270,12 @@ function validateUnion(e) {
|
|
|
4470
4270
|
return;
|
|
4471
4271
|
const o = t.let("valid", !1), l = t.name("_valid");
|
|
4472
4272
|
t.block(() => r.forEach((d, u) => {
|
|
4473
|
-
const
|
|
4273
|
+
const f = e.subschema({
|
|
4474
4274
|
keyword: n,
|
|
4475
4275
|
schemaProp: u,
|
|
4476
4276
|
compositeRule: !0
|
|
4477
4277
|
}, l);
|
|
4478
|
-
t.assign(o, (0, codegen_1$q._)`${o} || ${l}`), e.mergeValidEvaluated(
|
|
4278
|
+
t.assign(o, (0, codegen_1$q._)`${o} || ${l}`), e.mergeValidEvaluated(f, l) || t.if((0, codegen_1$q.not)(o));
|
|
4479
4279
|
})), e.result(o, () => e.reset(), () => e.error(!0));
|
|
4480
4280
|
}
|
|
4481
4281
|
code.validateUnion = validateUnion;
|
|
@@ -4499,11 +4299,11 @@ function funcKeywordCode(e, t) {
|
|
|
4499
4299
|
var r;
|
|
4500
4300
|
const { gen: n, keyword: s, schema: i, parentSchema: o, $data: l, it: d } = e;
|
|
4501
4301
|
checkAsyncKeyword(d, t);
|
|
4502
|
-
const u = !l && t.compile ? t.compile.call(d.self, i, o, d) : t.validate,
|
|
4302
|
+
const u = !l && t.compile ? t.compile.call(d.self, i, o, d) : t.validate, f = useKeyword(n, s, u), g = n.let("valid");
|
|
4503
4303
|
e.block$data(g, O), e.ok((r = t.valid) !== null && r !== void 0 ? r : g);
|
|
4504
4304
|
function O() {
|
|
4505
4305
|
if (t.errors === !1)
|
|
4506
|
-
|
|
4306
|
+
R(), t.modifying && modifyData(e), y(() => e.error());
|
|
4507
4307
|
else {
|
|
4508
4308
|
const _ = t.async ? C() : S();
|
|
4509
4309
|
t.modifying && modifyData(e), y(() => addErrs(e, _));
|
|
@@ -4511,15 +4311,15 @@ function funcKeywordCode(e, t) {
|
|
|
4511
4311
|
}
|
|
4512
4312
|
function C() {
|
|
4513
4313
|
const _ = n.let("ruleErrs", null);
|
|
4514
|
-
return n.try(() =>
|
|
4314
|
+
return n.try(() => R((0, codegen_1$p._)`await `), ($) => n.assign(g, !1).if((0, codegen_1$p._)`${$} instanceof ${d.ValidationError}`, () => n.assign(_, (0, codegen_1$p._)`${$}.errors`), () => n.throw($))), _;
|
|
4515
4315
|
}
|
|
4516
4316
|
function S() {
|
|
4517
|
-
const _ = (0, codegen_1$p._)`${
|
|
4518
|
-
return n.assign(_, null),
|
|
4317
|
+
const _ = (0, codegen_1$p._)`${f}.errors`;
|
|
4318
|
+
return n.assign(_, null), R(codegen_1$p.nil), _;
|
|
4519
4319
|
}
|
|
4520
|
-
function
|
|
4521
|
-
const $ = d.opts.passContext ? names_1$4.default.this : names_1$4.default.self,
|
|
4522
|
-
n.assign(g, (0, codegen_1$p._)`${_}${(0, code_1$9.callValidateCode)(e,
|
|
4320
|
+
function R(_ = t.async ? (0, codegen_1$p._)`await ` : codegen_1$p.nil) {
|
|
4321
|
+
const $ = d.opts.passContext ? names_1$4.default.this : names_1$4.default.self, b = !("compile" in t && !l || t.schema === !1);
|
|
4322
|
+
n.assign(g, (0, codegen_1$p._)`${_}${(0, code_1$9.callValidateCode)(e, f, $, b)}`, t.modifying);
|
|
4523
4323
|
}
|
|
4524
4324
|
function y(_) {
|
|
4525
4325
|
var $;
|
|
@@ -4602,8 +4402,8 @@ function extendSubschemaData(e, t, { dataProp: r, dataPropType: n, data: s, data
|
|
|
4602
4402
|
throw new Error('both "data" and "dataProp" passed, only one allowed');
|
|
4603
4403
|
const { gen: l } = t;
|
|
4604
4404
|
if (r !== void 0) {
|
|
4605
|
-
const { errorPath: u, dataPathArr:
|
|
4606
|
-
d(O), e.errorPath = (0, codegen_1$o.str)`${u}${(0, util_1$n.getErrorPath)(r, n, g.jsPropertySyntax)}`, e.parentDataProperty = (0, codegen_1$o._)`${r}`, e.dataPathArr = [...
|
|
4405
|
+
const { errorPath: u, dataPathArr: f, opts: g } = t, O = l.let("data", (0, codegen_1$o._)`${t.data}${(0, codegen_1$o.getProperty)(r)}`, !0);
|
|
4406
|
+
d(O), e.errorPath = (0, codegen_1$o.str)`${u}${(0, util_1$n.getErrorPath)(r, n, g.jsPropertySyntax)}`, e.parentDataProperty = (0, codegen_1$o._)`${r}`, e.dataPathArr = [...f, e.parentDataProperty];
|
|
4607
4407
|
}
|
|
4608
4408
|
if (s !== void 0) {
|
|
4609
4409
|
const u = s instanceof codegen_1$o.Name ? s : l.let("data", s, !0);
|
|
@@ -4707,18 +4507,18 @@ traverse$1.skipKeywords = {
|
|
|
4707
4507
|
function _traverse(e, t, r, n, s, i, o, l, d, u) {
|
|
4708
4508
|
if (n && typeof n == "object" && !Array.isArray(n)) {
|
|
4709
4509
|
t(n, s, i, o, l, d, u);
|
|
4710
|
-
for (var
|
|
4711
|
-
var g = n[
|
|
4510
|
+
for (var f in n) {
|
|
4511
|
+
var g = n[f];
|
|
4712
4512
|
if (Array.isArray(g)) {
|
|
4713
|
-
if (
|
|
4513
|
+
if (f in traverse$1.arrayKeywords)
|
|
4714
4514
|
for (var O = 0; O < g.length; O++)
|
|
4715
|
-
_traverse(e, t, r, g[O], s + "/" +
|
|
4716
|
-
} else if (
|
|
4515
|
+
_traverse(e, t, r, g[O], s + "/" + f + "/" + O, i, s, f, n, O);
|
|
4516
|
+
} else if (f in traverse$1.propsKeywords) {
|
|
4717
4517
|
if (g && typeof g == "object")
|
|
4718
4518
|
for (var C in g)
|
|
4719
|
-
_traverse(e, t, r, g[C], s + "/" +
|
|
4519
|
+
_traverse(e, t, r, g[C], s + "/" + f + "/" + escapeJsonPtr(C), i, s, f, n, C);
|
|
4720
4520
|
} else
|
|
4721
|
-
(
|
|
4521
|
+
(f in traverse$1.keywords || e.allKeys && !(f in traverse$1.skipKeywords)) && _traverse(e, t, r, g, s + "/" + f, i, s, f, n);
|
|
4722
4522
|
}
|
|
4723
4523
|
r(n, s, i, o, l, d, u);
|
|
4724
4524
|
}
|
|
@@ -4805,30 +4605,30 @@ function getSchemaRefs(e, t) {
|
|
|
4805
4605
|
return traverse(e, { allKeys: !0 }, (g, O, C, S) => {
|
|
4806
4606
|
if (S === void 0)
|
|
4807
4607
|
return;
|
|
4808
|
-
const
|
|
4608
|
+
const R = o + O;
|
|
4809
4609
|
let y = i[S];
|
|
4810
4610
|
typeof g[r] == "string" && (y = _.call(this, g[r])), $.call(this, g.$anchor), $.call(this, g.$dynamicAnchor), i[O] = y;
|
|
4811
|
-
function _(
|
|
4611
|
+
function _(b) {
|
|
4812
4612
|
const I = this.opts.uriResolver.resolve;
|
|
4813
|
-
if (
|
|
4814
|
-
throw
|
|
4815
|
-
d.add(
|
|
4816
|
-
let
|
|
4817
|
-
return typeof
|
|
4818
|
-
}
|
|
4819
|
-
function $(
|
|
4820
|
-
if (typeof
|
|
4821
|
-
if (!ANCHOR.test(
|
|
4822
|
-
throw new Error(`invalid anchor "${
|
|
4823
|
-
_.call(this, `#${
|
|
4613
|
+
if (b = normalizeId(y ? I(y, b) : b), d.has(b))
|
|
4614
|
+
throw f(b);
|
|
4615
|
+
d.add(b);
|
|
4616
|
+
let A = this.refs[b];
|
|
4617
|
+
return typeof A == "string" && (A = this.refs[A]), typeof A == "object" ? u(g, A.schema, b) : b !== normalizeId(R) && (b[0] === "#" ? (u(g, l[b], b), l[b] = g) : this.refs[b] = R), b;
|
|
4618
|
+
}
|
|
4619
|
+
function $(b) {
|
|
4620
|
+
if (typeof b == "string") {
|
|
4621
|
+
if (!ANCHOR.test(b))
|
|
4622
|
+
throw new Error(`invalid anchor "${b}"`);
|
|
4623
|
+
_.call(this, `#${b}`);
|
|
4824
4624
|
}
|
|
4825
4625
|
}
|
|
4826
4626
|
}), l;
|
|
4827
4627
|
function u(g, O, C) {
|
|
4828
4628
|
if (O !== void 0 && !equal$2(g, O))
|
|
4829
|
-
throw
|
|
4629
|
+
throw f(C);
|
|
4830
4630
|
}
|
|
4831
|
-
function
|
|
4631
|
+
function f(g) {
|
|
4832
4632
|
return new Error(`reference "${g}" resolves to more than one schema`);
|
|
4833
4633
|
}
|
|
4834
4634
|
}
|
|
@@ -4939,15 +4739,15 @@ function assignEvaluated({ gen: e, evaluated: t, props: r, items: n }) {
|
|
|
4939
4739
|
r instanceof codegen_1$n.Name && e.assign((0, codegen_1$n._)`${t}.props`, r), n instanceof codegen_1$n.Name && e.assign((0, codegen_1$n._)`${t}.items`, n);
|
|
4940
4740
|
}
|
|
4941
4741
|
function schemaKeywords(e, t, r, n) {
|
|
4942
|
-
const { gen: s, schema: i, data: o, allErrors: l, opts: d, self: u } = e, { RULES:
|
|
4943
|
-
if (i.$ref && (d.ignoreKeywordsWithRef || !(0, util_1$l.schemaHasRulesButRef)(i,
|
|
4944
|
-
s.block(() => keywordCode(e, "$ref",
|
|
4742
|
+
const { gen: s, schema: i, data: o, allErrors: l, opts: d, self: u } = e, { RULES: f } = u;
|
|
4743
|
+
if (i.$ref && (d.ignoreKeywordsWithRef || !(0, util_1$l.schemaHasRulesButRef)(i, f))) {
|
|
4744
|
+
s.block(() => keywordCode(e, "$ref", f.all.$ref.definition));
|
|
4945
4745
|
return;
|
|
4946
4746
|
}
|
|
4947
4747
|
d.jtd || checkStrictTypes(e, t), s.block(() => {
|
|
4948
|
-
for (const O of
|
|
4748
|
+
for (const O of f.rules)
|
|
4949
4749
|
g(O);
|
|
4950
|
-
g(
|
|
4750
|
+
g(f.post);
|
|
4951
4751
|
});
|
|
4952
4752
|
function g(O) {
|
|
4953
4753
|
(0, applicability_1.shouldUseGroup)(i, O) && (O.type ? (s.if((0, dataType_2.checkDataType)(O.type, o, d.strictNumbers)), iterateKeywords(e, O), t.length === 1 && t[0] === O.type && r && (s.else(), (0, dataType_2.reportTypeError)(e)), s.endIf()) : iterateKeywords(e, O), l || s.if((0, codegen_1$n._)`${names_1$3.default.errors} === ${n || 0}`));
|
|
@@ -5122,15 +4922,15 @@ function getData(e, { dataLevel: t, dataNames: r, dataPathArr: n }) {
|
|
|
5122
4922
|
const u = RELATIVE_JSON_POINTER.exec(e);
|
|
5123
4923
|
if (!u)
|
|
5124
4924
|
throw new Error(`Invalid JSON-pointer: ${e}`);
|
|
5125
|
-
const
|
|
4925
|
+
const f = +u[1];
|
|
5126
4926
|
if (s = u[2], s === "#") {
|
|
5127
|
-
if (
|
|
5128
|
-
throw new Error(d("property/index",
|
|
5129
|
-
return n[t -
|
|
4927
|
+
if (f >= t)
|
|
4928
|
+
throw new Error(d("property/index", f));
|
|
4929
|
+
return n[t - f];
|
|
5130
4930
|
}
|
|
5131
|
-
if (
|
|
5132
|
-
throw new Error(d("data",
|
|
5133
|
-
if (i = r[t -
|
|
4931
|
+
if (f > t)
|
|
4932
|
+
throw new Error(d("data", f));
|
|
4933
|
+
if (i = r[t - f], !s)
|
|
5134
4934
|
return i;
|
|
5135
4935
|
}
|
|
5136
4936
|
let o = i;
|
|
@@ -5138,8 +4938,8 @@ function getData(e, { dataLevel: t, dataNames: r, dataPathArr: n }) {
|
|
|
5138
4938
|
for (const u of l)
|
|
5139
4939
|
u && (i = (0, codegen_1$n._)`${i}${(0, codegen_1$n.getProperty)((0, util_1$l.unescapeJsonPointer)(u))}`, o = (0, codegen_1$n._)`${o} && ${i}`);
|
|
5140
4940
|
return o;
|
|
5141
|
-
function d(u,
|
|
5142
|
-
return `Cannot access ${u} ${
|
|
4941
|
+
function d(u, f) {
|
|
4942
|
+
return `Cannot access ${u} ${f} levels up, current level is ${t}`;
|
|
5143
4943
|
}
|
|
5144
4944
|
}
|
|
5145
4945
|
validate.getData = getData;
|
|
@@ -5209,24 +5009,24 @@ function compileSchema(e) {
|
|
|
5209
5009
|
opts: this.opts,
|
|
5210
5010
|
self: this
|
|
5211
5011
|
};
|
|
5212
|
-
let
|
|
5012
|
+
let f;
|
|
5213
5013
|
try {
|
|
5214
5014
|
this._compilations.add(e), (0, validate_1$1.validateFunctionCode)(u), o.optimize(this.opts.code.optimize);
|
|
5215
5015
|
const g = o.toString();
|
|
5216
|
-
|
|
5217
|
-
const C = new Function(`${names_1$2.default.self}`, `${names_1$2.default.scope}`,
|
|
5016
|
+
f = `${o.scopeRefs(names_1$2.default.scope)}return ${g}`, this.opts.code.process && (f = this.opts.code.process(f, e));
|
|
5017
|
+
const C = new Function(`${names_1$2.default.self}`, `${names_1$2.default.scope}`, f)(this, this.scope.get());
|
|
5218
5018
|
if (this.scope.value(d, { ref: C }), C.errors = null, C.schema = e.schema, C.schemaEnv = e, e.$async && (C.$async = !0), this.opts.code.source === !0 && (C.source = { validateName: d, validateCode: g, scopeValues: o._values }), this.opts.unevaluated) {
|
|
5219
|
-
const { props: S, items:
|
|
5019
|
+
const { props: S, items: R } = u;
|
|
5220
5020
|
C.evaluated = {
|
|
5221
5021
|
props: S instanceof codegen_1$m.Name ? void 0 : S,
|
|
5222
|
-
items:
|
|
5022
|
+
items: R instanceof codegen_1$m.Name ? void 0 : R,
|
|
5223
5023
|
dynamicProps: S instanceof codegen_1$m.Name,
|
|
5224
|
-
dynamicItems:
|
|
5024
|
+
dynamicItems: R instanceof codegen_1$m.Name
|
|
5225
5025
|
}, C.source && (C.source.evaluated = (0, codegen_1$m.stringify)(C.evaluated));
|
|
5226
5026
|
}
|
|
5227
5027
|
return e.validate = C, e;
|
|
5228
5028
|
} catch (g) {
|
|
5229
|
-
throw delete e.validate, delete e.validateName,
|
|
5029
|
+
throw delete e.validate, delete e.validateName, f && this.logger.error("Error compiling schema, function code:", f), g;
|
|
5230
5030
|
} finally {
|
|
5231
5031
|
this._compilations.delete(e);
|
|
5232
5032
|
}
|
|
@@ -5343,240 +5143,240 @@ var uri$1 = {}, uri_all = { exports: {} };
|
|
|
5343
5143
|
n(t);
|
|
5344
5144
|
})(commonjsGlobal, function(r) {
|
|
5345
5145
|
function n() {
|
|
5346
|
-
for (var
|
|
5146
|
+
for (var p = arguments.length, c = Array(p), m = 0; m < p; m++)
|
|
5347
5147
|
c[m] = arguments[m];
|
|
5348
5148
|
if (c.length > 1) {
|
|
5349
5149
|
c[0] = c[0].slice(0, -1);
|
|
5350
|
-
for (var
|
|
5150
|
+
for (var T = c.length - 1, E = 1; E < T; ++E)
|
|
5351
5151
|
c[E] = c[E].slice(1, -1);
|
|
5352
|
-
return c[
|
|
5152
|
+
return c[T] = c[T].slice(1), c.join("");
|
|
5353
5153
|
} else
|
|
5354
5154
|
return c[0];
|
|
5355
5155
|
}
|
|
5356
|
-
function s(
|
|
5357
|
-
return "(?:" +
|
|
5156
|
+
function s(p) {
|
|
5157
|
+
return "(?:" + p + ")";
|
|
5358
5158
|
}
|
|
5359
|
-
function i(
|
|
5360
|
-
return
|
|
5159
|
+
function i(p) {
|
|
5160
|
+
return p === void 0 ? "undefined" : p === null ? "null" : Object.prototype.toString.call(p).split(" ").pop().split("]").shift().toLowerCase();
|
|
5361
5161
|
}
|
|
5362
|
-
function o(
|
|
5363
|
-
return
|
|
5162
|
+
function o(p) {
|
|
5163
|
+
return p.toUpperCase();
|
|
5364
5164
|
}
|
|
5365
|
-
function l(
|
|
5366
|
-
return
|
|
5165
|
+
function l(p) {
|
|
5166
|
+
return p != null ? p instanceof Array ? p : typeof p.length != "number" || p.split || p.setInterval || p.call ? [p] : Array.prototype.slice.call(p) : [];
|
|
5367
5167
|
}
|
|
5368
|
-
function d(
|
|
5369
|
-
var m =
|
|
5168
|
+
function d(p, c) {
|
|
5169
|
+
var m = p;
|
|
5370
5170
|
if (c)
|
|
5371
|
-
for (var
|
|
5372
|
-
m[
|
|
5171
|
+
for (var T in c)
|
|
5172
|
+
m[T] = c[T];
|
|
5373
5173
|
return m;
|
|
5374
5174
|
}
|
|
5375
|
-
function u(
|
|
5376
|
-
var c = "[A-Za-z]", m = "[0-9]",
|
|
5377
|
-
s(c + n(c, m, "[\\+\\-\\.]") + "*"), s(s(E + "|" + n(B,
|
|
5378
|
-
var
|
|
5379
|
-
s("[vV]" +
|
|
5380
|
-
var
|
|
5381
|
-
return s(s(E + "|" + n(B,
|
|
5175
|
+
function u(p) {
|
|
5176
|
+
var c = "[A-Za-z]", m = "[0-9]", T = n(m, "[A-Fa-f]"), E = s(s("%[EFef]" + T + "%" + T + T + "%" + T + T) + "|" + s("%[89A-Fa-f]" + T + "%" + T + T) + "|" + s("%" + T + T)), L = "[\\:\\/\\?\\#\\[\\]\\@]", U = "[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]", K = n(L, U), Q = p ? "[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]" : "[]", re = p ? "[\\uE000-\\uF8FF]" : "[]", B = n(c, m, "[\\-\\.\\_\\~]", Q);
|
|
5177
|
+
s(c + n(c, m, "[\\+\\-\\.]") + "*"), s(s(E + "|" + n(B, U, "[\\:]")) + "*");
|
|
5178
|
+
var J = s(s("25[0-5]") + "|" + s("2[0-4]" + m) + "|" + s("1" + m + m) + "|" + s("0?[1-9]" + m) + "|0?0?" + m), ne = s(J + "\\." + J + "\\." + J + "\\." + J), z = s(T + "{1,4}"), Z = s(s(z + "\\:" + z) + "|" + ne), oe = s(s(z + "\\:") + "{6}" + Z), Y = s("\\:\\:" + s(z + "\\:") + "{5}" + Z), Pe = s(s(z) + "?\\:\\:" + s(z + "\\:") + "{4}" + Z), ge = s(s(s(z + "\\:") + "{0,1}" + z) + "?\\:\\:" + s(z + "\\:") + "{3}" + Z), $e = s(s(s(z + "\\:") + "{0,2}" + z) + "?\\:\\:" + s(z + "\\:") + "{2}" + Z), Ue = s(s(s(z + "\\:") + "{0,3}" + z) + "?\\:\\:" + z + "\\:" + Z), Ce = s(s(s(z + "\\:") + "{0,4}" + z) + "?\\:\\:" + Z), pe = s(s(s(z + "\\:") + "{0,5}" + z) + "?\\:\\:" + z), ye = s(s(s(z + "\\:") + "{0,6}" + z) + "?\\:\\:"), Oe = s([oe, Y, Pe, ge, $e, Ue, Ce, pe, ye].join("|")), we = s(s(B + "|" + E) + "+");
|
|
5179
|
+
s("[vV]" + T + "+\\." + n(B, U, "[\\:]") + "+"), s(s(E + "|" + n(B, U)) + "*");
|
|
5180
|
+
var Ye = s(E + "|" + n(B, U, "[\\:\\@]"));
|
|
5181
|
+
return s(s(E + "|" + n(B, U, "[\\@]")) + "+"), s(s(Ye + "|" + n("[\\/\\?]", re)) + "*"), {
|
|
5382
5182
|
NOT_SCHEME: new RegExp(n("[^]", c, m, "[\\+\\-\\.]"), "g"),
|
|
5383
|
-
NOT_USERINFO: new RegExp(n("[^\\%\\:]", B,
|
|
5384
|
-
NOT_HOST: new RegExp(n("[^\\%\\[\\]\\:]", B,
|
|
5385
|
-
NOT_PATH: new RegExp(n("[^\\%\\/\\:\\@]", B,
|
|
5386
|
-
NOT_PATH_NOSCHEME: new RegExp(n("[^\\%\\/\\@]", B,
|
|
5387
|
-
NOT_QUERY: new RegExp(n("[^\\%]", B,
|
|
5388
|
-
NOT_FRAGMENT: new RegExp(n("[^\\%]", B,
|
|
5389
|
-
ESCAPE: new RegExp(n("[^]", B,
|
|
5183
|
+
NOT_USERINFO: new RegExp(n("[^\\%\\:]", B, U), "g"),
|
|
5184
|
+
NOT_HOST: new RegExp(n("[^\\%\\[\\]\\:]", B, U), "g"),
|
|
5185
|
+
NOT_PATH: new RegExp(n("[^\\%\\/\\:\\@]", B, U), "g"),
|
|
5186
|
+
NOT_PATH_NOSCHEME: new RegExp(n("[^\\%\\/\\@]", B, U), "g"),
|
|
5187
|
+
NOT_QUERY: new RegExp(n("[^\\%]", B, U, "[\\:\\@\\/\\?]", re), "g"),
|
|
5188
|
+
NOT_FRAGMENT: new RegExp(n("[^\\%]", B, U, "[\\:\\@\\/\\?]"), "g"),
|
|
5189
|
+
ESCAPE: new RegExp(n("[^]", B, U), "g"),
|
|
5390
5190
|
UNRESERVED: new RegExp(B, "g"),
|
|
5391
|
-
OTHER_CHARS: new RegExp(n("[^\\%]", B,
|
|
5191
|
+
OTHER_CHARS: new RegExp(n("[^\\%]", B, K), "g"),
|
|
5392
5192
|
PCT_ENCODED: new RegExp(E, "g"),
|
|
5393
|
-
IPV4ADDRESS: new RegExp("^(" +
|
|
5394
|
-
IPV6ADDRESS: new RegExp("^\\[?(" +
|
|
5193
|
+
IPV4ADDRESS: new RegExp("^(" + ne + ")$"),
|
|
5194
|
+
IPV6ADDRESS: new RegExp("^\\[?(" + Oe + ")" + s(s("\\%25|\\%(?!" + T + "{2})") + "(" + we + ")") + "?\\]?$")
|
|
5395
5195
|
//RFC 6874, with relaxed parsing rules
|
|
5396
5196
|
};
|
|
5397
5197
|
}
|
|
5398
|
-
var
|
|
5399
|
-
function
|
|
5400
|
-
var
|
|
5198
|
+
var f = u(!1), g = u(!0), O = function() {
|
|
5199
|
+
function p(c, m) {
|
|
5200
|
+
var T = [], E = !0, L = !1, U = void 0;
|
|
5401
5201
|
try {
|
|
5402
|
-
for (var
|
|
5202
|
+
for (var K = c[Symbol.iterator](), Q; !(E = (Q = K.next()).done) && (T.push(Q.value), !(m && T.length === m)); E = !0)
|
|
5403
5203
|
;
|
|
5404
|
-
} catch (
|
|
5405
|
-
|
|
5204
|
+
} catch (re) {
|
|
5205
|
+
L = !0, U = re;
|
|
5406
5206
|
} finally {
|
|
5407
5207
|
try {
|
|
5408
|
-
!E &&
|
|
5208
|
+
!E && K.return && K.return();
|
|
5409
5209
|
} finally {
|
|
5410
|
-
if (
|
|
5411
|
-
throw
|
|
5210
|
+
if (L)
|
|
5211
|
+
throw U;
|
|
5412
5212
|
}
|
|
5413
5213
|
}
|
|
5414
|
-
return
|
|
5214
|
+
return T;
|
|
5415
5215
|
}
|
|
5416
5216
|
return function(c, m) {
|
|
5417
5217
|
if (Array.isArray(c))
|
|
5418
5218
|
return c;
|
|
5419
5219
|
if (Symbol.iterator in Object(c))
|
|
5420
|
-
return
|
|
5220
|
+
return p(c, m);
|
|
5421
5221
|
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
|
5422
5222
|
};
|
|
5423
|
-
}(), C = function(
|
|
5424
|
-
if (Array.isArray(
|
|
5425
|
-
for (var c = 0, m = Array(
|
|
5426
|
-
m[c] =
|
|
5223
|
+
}(), C = function(p) {
|
|
5224
|
+
if (Array.isArray(p)) {
|
|
5225
|
+
for (var c = 0, m = Array(p.length); c < p.length; c++)
|
|
5226
|
+
m[c] = p[c];
|
|
5427
5227
|
return m;
|
|
5428
5228
|
} else
|
|
5429
|
-
return Array.from(
|
|
5430
|
-
}, S = 2147483647,
|
|
5229
|
+
return Array.from(p);
|
|
5230
|
+
}, S = 2147483647, R = 36, y = 1, _ = 26, $ = 38, b = 700, I = 72, A = 128, w = "-", k = /^xn--/, D = /[^\0-\x7E]/, V = /[\x2E\u3002\uFF0E\uFF61]/g, H = {
|
|
5431
5231
|
overflow: "Overflow: input needs wider integers to process",
|
|
5432
5232
|
"not-basic": "Illegal input >= 0x80 (not a basic code point)",
|
|
5433
5233
|
"invalid-input": "Invalid input"
|
|
5434
|
-
},
|
|
5435
|
-
function
|
|
5436
|
-
throw new RangeError(
|
|
5234
|
+
}, X = R - y, G = Math.floor, de = String.fromCharCode;
|
|
5235
|
+
function ie(p) {
|
|
5236
|
+
throw new RangeError(H[p]);
|
|
5437
5237
|
}
|
|
5438
|
-
function
|
|
5439
|
-
for (var m = [],
|
|
5440
|
-
m[
|
|
5238
|
+
function Se(p, c) {
|
|
5239
|
+
for (var m = [], T = p.length; T--; )
|
|
5240
|
+
m[T] = c(p[T]);
|
|
5441
5241
|
return m;
|
|
5442
5242
|
}
|
|
5443
|
-
function
|
|
5444
|
-
var m =
|
|
5445
|
-
m.length > 1 && (
|
|
5446
|
-
var E =
|
|
5447
|
-
return
|
|
5448
|
-
}
|
|
5449
|
-
function
|
|
5450
|
-
for (var c = [], m = 0,
|
|
5451
|
-
var E =
|
|
5452
|
-
if (E >= 55296 && E <= 56319 && m <
|
|
5453
|
-
var
|
|
5454
|
-
(
|
|
5243
|
+
function Te(p, c) {
|
|
5244
|
+
var m = p.split("@"), T = "";
|
|
5245
|
+
m.length > 1 && (T = m[0] + "@", p = m[1]), p = p.replace(V, ".");
|
|
5246
|
+
var E = p.split("."), L = Se(E, c).join(".");
|
|
5247
|
+
return T + L;
|
|
5248
|
+
}
|
|
5249
|
+
function Ie(p) {
|
|
5250
|
+
for (var c = [], m = 0, T = p.length; m < T; ) {
|
|
5251
|
+
var E = p.charCodeAt(m++);
|
|
5252
|
+
if (E >= 55296 && E <= 56319 && m < T) {
|
|
5253
|
+
var L = p.charCodeAt(m++);
|
|
5254
|
+
(L & 64512) == 56320 ? c.push(((E & 1023) << 10) + (L & 1023) + 65536) : (c.push(E), m--);
|
|
5455
5255
|
} else
|
|
5456
5256
|
c.push(E);
|
|
5457
5257
|
}
|
|
5458
5258
|
return c;
|
|
5459
5259
|
}
|
|
5460
|
-
var
|
|
5260
|
+
var xe = function(c) {
|
|
5461
5261
|
return String.fromCodePoint.apply(String, C(c));
|
|
5462
|
-
},
|
|
5463
|
-
return c - 48 < 10 ? c - 22 : c - 65 < 26 ? c - 65 : c - 97 < 26 ? c - 97 :
|
|
5262
|
+
}, je = function(c) {
|
|
5263
|
+
return c - 48 < 10 ? c - 22 : c - 65 < 26 ? c - 65 : c - 97 < 26 ? c - 97 : R;
|
|
5464
5264
|
}, F = function(c, m) {
|
|
5465
5265
|
return c + 22 + 75 * (c < 26) - ((m != 0) << 5);
|
|
5466
|
-
}, v = function(c, m,
|
|
5266
|
+
}, v = function(c, m, T) {
|
|
5467
5267
|
var E = 0;
|
|
5468
5268
|
for (
|
|
5469
|
-
c =
|
|
5269
|
+
c = T ? G(c / b) : c >> 1, c += G(c / m);
|
|
5470
5270
|
/* no initialization */
|
|
5471
|
-
c >
|
|
5472
|
-
E +=
|
|
5271
|
+
c > X * _ >> 1;
|
|
5272
|
+
E += R
|
|
5473
5273
|
)
|
|
5474
|
-
c =
|
|
5475
|
-
return
|
|
5274
|
+
c = G(c / X);
|
|
5275
|
+
return G(E + (X + 1) * c / (c + $));
|
|
5476
5276
|
}, j = function(c) {
|
|
5477
|
-
var m = [],
|
|
5478
|
-
|
|
5479
|
-
for (var
|
|
5480
|
-
c.charCodeAt(
|
|
5481
|
-
for (var
|
|
5277
|
+
var m = [], T = c.length, E = 0, L = A, U = I, K = c.lastIndexOf(w);
|
|
5278
|
+
K < 0 && (K = 0);
|
|
5279
|
+
for (var Q = 0; Q < K; ++Q)
|
|
5280
|
+
c.charCodeAt(Q) >= 128 && ie("not-basic"), m.push(c.charCodeAt(Q));
|
|
5281
|
+
for (var re = K > 0 ? K + 1 : 0; re < T; ) {
|
|
5482
5282
|
for (
|
|
5483
|
-
var B = E,
|
|
5283
|
+
var B = E, J = 1, ne = R;
|
|
5484
5284
|
;
|
|
5485
5285
|
/* no condition */
|
|
5486
|
-
|
|
5286
|
+
ne += R
|
|
5487
5287
|
) {
|
|
5488
|
-
|
|
5489
|
-
var z =
|
|
5490
|
-
(z >=
|
|
5491
|
-
var
|
|
5492
|
-
if (z <
|
|
5288
|
+
re >= T && ie("invalid-input");
|
|
5289
|
+
var z = je(c.charCodeAt(re++));
|
|
5290
|
+
(z >= R || z > G((S - E) / J)) && ie("overflow"), E += z * J;
|
|
5291
|
+
var Z = ne <= U ? y : ne >= U + _ ? _ : ne - U;
|
|
5292
|
+
if (z < Z)
|
|
5493
5293
|
break;
|
|
5494
|
-
var
|
|
5495
|
-
|
|
5294
|
+
var oe = R - Z;
|
|
5295
|
+
J > G(S / oe) && ie("overflow"), J *= oe;
|
|
5496
5296
|
}
|
|
5497
|
-
var
|
|
5498
|
-
|
|
5297
|
+
var Y = m.length + 1;
|
|
5298
|
+
U = v(E - B, Y, B == 0), G(E / Y) > S - L && ie("overflow"), L += G(E / Y), E %= Y, m.splice(E++, 0, L);
|
|
5499
5299
|
}
|
|
5500
5300
|
return String.fromCodePoint.apply(String, m);
|
|
5501
|
-
},
|
|
5301
|
+
}, P = function(c) {
|
|
5502
5302
|
var m = [];
|
|
5503
|
-
c =
|
|
5504
|
-
var
|
|
5303
|
+
c = Ie(c);
|
|
5304
|
+
var T = c.length, E = A, L = 0, U = I, K = !0, Q = !1, re = void 0;
|
|
5505
5305
|
try {
|
|
5506
|
-
for (var B = c[Symbol.iterator](),
|
|
5507
|
-
var
|
|
5508
|
-
|
|
5306
|
+
for (var B = c[Symbol.iterator](), J; !(K = (J = B.next()).done); K = !0) {
|
|
5307
|
+
var ne = J.value;
|
|
5308
|
+
ne < 128 && m.push(de(ne));
|
|
5509
5309
|
}
|
|
5510
|
-
} catch (
|
|
5511
|
-
|
|
5310
|
+
} catch (Xe) {
|
|
5311
|
+
Q = !0, re = Xe;
|
|
5512
5312
|
} finally {
|
|
5513
5313
|
try {
|
|
5514
|
-
!
|
|
5314
|
+
!K && B.return && B.return();
|
|
5515
5315
|
} finally {
|
|
5516
|
-
if (
|
|
5517
|
-
throw
|
|
5316
|
+
if (Q)
|
|
5317
|
+
throw re;
|
|
5518
5318
|
}
|
|
5519
5319
|
}
|
|
5520
|
-
var z = m.length,
|
|
5521
|
-
for (z && m.push(w);
|
|
5522
|
-
var
|
|
5320
|
+
var z = m.length, Z = z;
|
|
5321
|
+
for (z && m.push(w); Z < T; ) {
|
|
5322
|
+
var oe = S, Y = !0, Pe = !1, ge = void 0;
|
|
5523
5323
|
try {
|
|
5524
|
-
for (var $e = c[Symbol.iterator](),
|
|
5525
|
-
var
|
|
5526
|
-
|
|
5324
|
+
for (var $e = c[Symbol.iterator](), Ue; !(Y = (Ue = $e.next()).done); Y = !0) {
|
|
5325
|
+
var Ce = Ue.value;
|
|
5326
|
+
Ce >= E && Ce < oe && (oe = Ce);
|
|
5527
5327
|
}
|
|
5528
|
-
} catch (
|
|
5529
|
-
|
|
5328
|
+
} catch (Xe) {
|
|
5329
|
+
Pe = !0, ge = Xe;
|
|
5530
5330
|
} finally {
|
|
5531
5331
|
try {
|
|
5532
|
-
!
|
|
5332
|
+
!Y && $e.return && $e.return();
|
|
5533
5333
|
} finally {
|
|
5534
|
-
if (
|
|
5334
|
+
if (Pe)
|
|
5535
5335
|
throw ge;
|
|
5536
5336
|
}
|
|
5537
5337
|
}
|
|
5538
|
-
var
|
|
5539
|
-
|
|
5540
|
-
var ye = !0,
|
|
5338
|
+
var pe = Z + 1;
|
|
5339
|
+
oe - E > G((S - L) / pe) && ie("overflow"), L += (oe - E) * pe, E = oe;
|
|
5340
|
+
var ye = !0, Oe = !1, we = void 0;
|
|
5541
5341
|
try {
|
|
5542
|
-
for (var
|
|
5543
|
-
var
|
|
5544
|
-
if (
|
|
5342
|
+
for (var Ye = c[Symbol.iterator](), Ct; !(ye = (Ct = Ye.next()).done); ye = !0) {
|
|
5343
|
+
var Ot = Ct.value;
|
|
5344
|
+
if (Ot < E && ++L > S && ie("overflow"), Ot == E) {
|
|
5545
5345
|
for (
|
|
5546
|
-
var
|
|
5346
|
+
var tt = L, rt = R;
|
|
5547
5347
|
;
|
|
5548
5348
|
/* no condition */
|
|
5549
|
-
|
|
5349
|
+
rt += R
|
|
5550
5350
|
) {
|
|
5551
|
-
var
|
|
5552
|
-
if (
|
|
5351
|
+
var nt = rt <= U ? y : rt >= U + _ ? _ : rt - U;
|
|
5352
|
+
if (tt < nt)
|
|
5553
5353
|
break;
|
|
5554
|
-
var
|
|
5555
|
-
m.push(
|
|
5354
|
+
var Nt = tt - nt, It = R - nt;
|
|
5355
|
+
m.push(de(F(nt + Nt % It, 0))), tt = G(Nt / It);
|
|
5556
5356
|
}
|
|
5557
|
-
m.push(
|
|
5357
|
+
m.push(de(F(tt, 0))), U = v(L, pe, Z == z), L = 0, ++Z;
|
|
5558
5358
|
}
|
|
5559
5359
|
}
|
|
5560
|
-
} catch (
|
|
5561
|
-
|
|
5360
|
+
} catch (Xe) {
|
|
5361
|
+
Oe = !0, we = Xe;
|
|
5562
5362
|
} finally {
|
|
5563
5363
|
try {
|
|
5564
|
-
!ye &&
|
|
5364
|
+
!ye && Ye.return && Ye.return();
|
|
5565
5365
|
} finally {
|
|
5566
|
-
if (
|
|
5366
|
+
if (Oe)
|
|
5567
5367
|
throw we;
|
|
5568
5368
|
}
|
|
5569
5369
|
}
|
|
5570
|
-
++
|
|
5370
|
+
++L, ++E;
|
|
5571
5371
|
}
|
|
5572
5372
|
return m.join("");
|
|
5573
5373
|
}, a = function(c) {
|
|
5574
|
-
return
|
|
5374
|
+
return Te(c, function(m) {
|
|
5575
5375
|
return k.test(m) ? j(m.slice(4).toLowerCase()) : m;
|
|
5576
5376
|
});
|
|
5577
5377
|
}, h = function(c) {
|
|
5578
|
-
return
|
|
5579
|
-
return
|
|
5378
|
+
return Te(c, function(m) {
|
|
5379
|
+
return D.test(m) ? "xn--" + P(m) : m;
|
|
5580
5380
|
});
|
|
5581
5381
|
}, N = {
|
|
5582
5382
|
/**
|
|
@@ -5593,301 +5393,301 @@ var uri$1 = {}, uri_all = { exports: {} };
|
|
|
5593
5393
|
* @type Object
|
|
5594
5394
|
*/
|
|
5595
5395
|
ucs2: {
|
|
5596
|
-
decode:
|
|
5597
|
-
encode:
|
|
5396
|
+
decode: Ie,
|
|
5397
|
+
encode: xe
|
|
5598
5398
|
},
|
|
5599
5399
|
decode: j,
|
|
5600
|
-
encode:
|
|
5400
|
+
encode: P,
|
|
5601
5401
|
toASCII: h,
|
|
5602
5402
|
toUnicode: a
|
|
5603
5403
|
}, M = {};
|
|
5604
|
-
function q(
|
|
5605
|
-
var c =
|
|
5404
|
+
function q(p) {
|
|
5405
|
+
var c = p.charCodeAt(0), m = void 0;
|
|
5606
5406
|
return c < 16 ? m = "%0" + c.toString(16).toUpperCase() : c < 128 ? m = "%" + c.toString(16).toUpperCase() : c < 2048 ? m = "%" + (c >> 6 | 192).toString(16).toUpperCase() + "%" + (c & 63 | 128).toString(16).toUpperCase() : m = "%" + (c >> 12 | 224).toString(16).toUpperCase() + "%" + (c >> 6 & 63 | 128).toString(16).toUpperCase() + "%" + (c & 63 | 128).toString(16).toUpperCase(), m;
|
|
5607
5407
|
}
|
|
5608
|
-
function
|
|
5609
|
-
for (var c = "", m = 0,
|
|
5610
|
-
var E = parseInt(
|
|
5408
|
+
function x(p) {
|
|
5409
|
+
for (var c = "", m = 0, T = p.length; m < T; ) {
|
|
5410
|
+
var E = parseInt(p.substr(m + 1, 2), 16);
|
|
5611
5411
|
if (E < 128)
|
|
5612
5412
|
c += String.fromCharCode(E), m += 3;
|
|
5613
5413
|
else if (E >= 194 && E < 224) {
|
|
5614
|
-
if (
|
|
5615
|
-
var
|
|
5616
|
-
c += String.fromCharCode((E & 31) << 6 |
|
|
5414
|
+
if (T - m >= 6) {
|
|
5415
|
+
var L = parseInt(p.substr(m + 4, 2), 16);
|
|
5416
|
+
c += String.fromCharCode((E & 31) << 6 | L & 63);
|
|
5617
5417
|
} else
|
|
5618
|
-
c +=
|
|
5418
|
+
c += p.substr(m, 6);
|
|
5619
5419
|
m += 6;
|
|
5620
5420
|
} else if (E >= 224) {
|
|
5621
|
-
if (
|
|
5622
|
-
var
|
|
5623
|
-
c += String.fromCharCode((E & 15) << 12 | (
|
|
5421
|
+
if (T - m >= 9) {
|
|
5422
|
+
var U = parseInt(p.substr(m + 4, 2), 16), K = parseInt(p.substr(m + 7, 2), 16);
|
|
5423
|
+
c += String.fromCharCode((E & 15) << 12 | (U & 63) << 6 | K & 63);
|
|
5624
5424
|
} else
|
|
5625
|
-
c +=
|
|
5425
|
+
c += p.substr(m, 9);
|
|
5626
5426
|
m += 9;
|
|
5627
5427
|
} else
|
|
5628
|
-
c +=
|
|
5428
|
+
c += p.substr(m, 3), m += 3;
|
|
5629
5429
|
}
|
|
5630
5430
|
return c;
|
|
5631
5431
|
}
|
|
5632
|
-
function
|
|
5633
|
-
function m(
|
|
5634
|
-
var E =
|
|
5635
|
-
return E.match(c.UNRESERVED) ? E :
|
|
5432
|
+
function W(p, c) {
|
|
5433
|
+
function m(T) {
|
|
5434
|
+
var E = x(T);
|
|
5435
|
+
return E.match(c.UNRESERVED) ? E : T;
|
|
5636
5436
|
}
|
|
5637
|
-
return
|
|
5437
|
+
return p.scheme && (p.scheme = String(p.scheme).replace(c.PCT_ENCODED, m).toLowerCase().replace(c.NOT_SCHEME, "")), p.userinfo !== void 0 && (p.userinfo = String(p.userinfo).replace(c.PCT_ENCODED, m).replace(c.NOT_USERINFO, q).replace(c.PCT_ENCODED, o)), p.host !== void 0 && (p.host = String(p.host).replace(c.PCT_ENCODED, m).toLowerCase().replace(c.NOT_HOST, q).replace(c.PCT_ENCODED, o)), p.path !== void 0 && (p.path = String(p.path).replace(c.PCT_ENCODED, m).replace(p.scheme ? c.NOT_PATH : c.NOT_PATH_NOSCHEME, q).replace(c.PCT_ENCODED, o)), p.query !== void 0 && (p.query = String(p.query).replace(c.PCT_ENCODED, m).replace(c.NOT_QUERY, q).replace(c.PCT_ENCODED, o)), p.fragment !== void 0 && (p.fragment = String(p.fragment).replace(c.PCT_ENCODED, m).replace(c.NOT_FRAGMENT, q).replace(c.PCT_ENCODED, o)), p;
|
|
5638
5438
|
}
|
|
5639
|
-
function
|
|
5640
|
-
return
|
|
5439
|
+
function te(p) {
|
|
5440
|
+
return p.replace(/^0*(.*)/, "$1") || "0";
|
|
5641
5441
|
}
|
|
5642
|
-
function he(
|
|
5643
|
-
var m =
|
|
5644
|
-
return E ? E.split(".").map(
|
|
5442
|
+
function he(p, c) {
|
|
5443
|
+
var m = p.match(c.IPV4ADDRESS) || [], T = O(m, 2), E = T[1];
|
|
5444
|
+
return E ? E.split(".").map(te).join(".") : p;
|
|
5645
5445
|
}
|
|
5646
|
-
function
|
|
5647
|
-
var m =
|
|
5446
|
+
function De(p, c) {
|
|
5447
|
+
var m = p.match(c.IPV6ADDRESS) || [], T = O(m, 3), E = T[1], L = T[2];
|
|
5648
5448
|
if (E) {
|
|
5649
|
-
for (var
|
|
5650
|
-
|
|
5651
|
-
|
|
5652
|
-
var
|
|
5449
|
+
for (var U = E.toLowerCase().split("::").reverse(), K = O(U, 2), Q = K[0], re = K[1], B = re ? re.split(":").map(te) : [], J = Q.split(":").map(te), ne = c.IPV4ADDRESS.test(J[J.length - 1]), z = ne ? 7 : 8, Z = J.length - z, oe = Array(z), Y = 0; Y < z; ++Y)
|
|
5450
|
+
oe[Y] = B[Y] || J[Z + Y] || "";
|
|
5451
|
+
ne && (oe[z - 1] = he(oe[z - 1], c));
|
|
5452
|
+
var Pe = oe.reduce(function(pe, ye, Oe) {
|
|
5653
5453
|
if (!ye || ye === "0") {
|
|
5654
|
-
var we =
|
|
5655
|
-
we && we.index + we.length ===
|
|
5454
|
+
var we = pe[pe.length - 1];
|
|
5455
|
+
we && we.index + we.length === Oe ? we.length++ : pe.push({ index: Oe, length: 1 });
|
|
5656
5456
|
}
|
|
5657
|
-
return
|
|
5658
|
-
}, []), ge =
|
|
5659
|
-
return ye.length -
|
|
5457
|
+
return pe;
|
|
5458
|
+
}, []), ge = Pe.sort(function(pe, ye) {
|
|
5459
|
+
return ye.length - pe.length;
|
|
5660
5460
|
})[0], $e = void 0;
|
|
5661
5461
|
if (ge && ge.length > 1) {
|
|
5662
|
-
var
|
|
5663
|
-
$e =
|
|
5462
|
+
var Ue = oe.slice(0, ge.index), Ce = oe.slice(ge.index + ge.length);
|
|
5463
|
+
$e = Ue.join(":") + "::" + Ce.join(":");
|
|
5664
5464
|
} else
|
|
5665
|
-
$e =
|
|
5666
|
-
return
|
|
5465
|
+
$e = oe.join(":");
|
|
5466
|
+
return L && ($e += "%" + L), $e;
|
|
5667
5467
|
} else
|
|
5668
|
-
return
|
|
5468
|
+
return p;
|
|
5669
5469
|
}
|
|
5670
|
-
var
|
|
5671
|
-
function
|
|
5672
|
-
var c = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, m = {},
|
|
5673
|
-
c.reference === "suffix" && (
|
|
5674
|
-
var E =
|
|
5470
|
+
var Be = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i, We = "".match(/(){0}/)[1] === void 0;
|
|
5471
|
+
function le(p) {
|
|
5472
|
+
var c = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, m = {}, T = c.iri !== !1 ? g : f;
|
|
5473
|
+
c.reference === "suffix" && (p = (c.scheme ? c.scheme + ":" : "") + "//" + p);
|
|
5474
|
+
var E = p.match(Be);
|
|
5675
5475
|
if (E) {
|
|
5676
|
-
|
|
5677
|
-
var
|
|
5678
|
-
if (!c.unicodeSupport && (!
|
|
5679
|
-
if (m.host && (c.domainHost ||
|
|
5476
|
+
We ? (m.scheme = E[1], m.userinfo = E[3], m.host = E[4], m.port = parseInt(E[5], 10), m.path = E[6] || "", m.query = E[7], m.fragment = E[8], isNaN(m.port) && (m.port = E[5])) : (m.scheme = E[1] || void 0, m.userinfo = p.indexOf("@") !== -1 ? E[3] : void 0, m.host = p.indexOf("//") !== -1 ? E[4] : void 0, m.port = parseInt(E[5], 10), m.path = E[6] || "", m.query = p.indexOf("?") !== -1 ? E[7] : void 0, m.fragment = p.indexOf("#") !== -1 ? E[8] : void 0, isNaN(m.port) && (m.port = p.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/) ? E[4] : void 0)), m.host && (m.host = De(he(m.host, T), T)), m.scheme === void 0 && m.userinfo === void 0 && m.host === void 0 && m.port === void 0 && !m.path && m.query === void 0 ? m.reference = "same-document" : m.scheme === void 0 ? m.reference = "relative" : m.fragment === void 0 ? m.reference = "absolute" : m.reference = "uri", c.reference && c.reference !== "suffix" && c.reference !== m.reference && (m.error = m.error || "URI is not a " + c.reference + " reference.");
|
|
5477
|
+
var L = M[(c.scheme || m.scheme || "").toLowerCase()];
|
|
5478
|
+
if (!c.unicodeSupport && (!L || !L.unicodeSupport)) {
|
|
5479
|
+
if (m.host && (c.domainHost || L && L.domainHost))
|
|
5680
5480
|
try {
|
|
5681
|
-
m.host = N.toASCII(m.host.replace(
|
|
5682
|
-
} catch (
|
|
5683
|
-
m.error = m.error || "Host's domain name can not be converted to ASCII via punycode: " +
|
|
5481
|
+
m.host = N.toASCII(m.host.replace(T.PCT_ENCODED, x).toLowerCase());
|
|
5482
|
+
} catch (U) {
|
|
5483
|
+
m.error = m.error || "Host's domain name can not be converted to ASCII via punycode: " + U;
|
|
5684
5484
|
}
|
|
5685
|
-
|
|
5485
|
+
W(m, f);
|
|
5686
5486
|
} else
|
|
5687
|
-
|
|
5688
|
-
|
|
5487
|
+
W(m, T);
|
|
5488
|
+
L && L.parse && L.parse(m, c);
|
|
5689
5489
|
} else
|
|
5690
5490
|
m.error = m.error || "URI can not be parsed.";
|
|
5691
5491
|
return m;
|
|
5692
5492
|
}
|
|
5693
|
-
function
|
|
5694
|
-
var m = c.iri !== !1 ? g :
|
|
5695
|
-
return
|
|
5696
|
-
return "[" +
|
|
5697
|
-
})), (typeof
|
|
5698
|
-
}
|
|
5699
|
-
var
|
|
5700
|
-
function me(
|
|
5701
|
-
for (var c = [];
|
|
5702
|
-
if (
|
|
5703
|
-
|
|
5704
|
-
else if (
|
|
5705
|
-
|
|
5706
|
-
else if (
|
|
5707
|
-
|
|
5708
|
-
else if (
|
|
5709
|
-
|
|
5493
|
+
function Ge(p, c) {
|
|
5494
|
+
var m = c.iri !== !1 ? g : f, T = [];
|
|
5495
|
+
return p.userinfo !== void 0 && (T.push(p.userinfo), T.push("@")), p.host !== void 0 && T.push(De(he(String(p.host), m), m).replace(m.IPV6ADDRESS, function(E, L, U) {
|
|
5496
|
+
return "[" + L + (U ? "%25" + U : "") + "]";
|
|
5497
|
+
})), (typeof p.port == "number" || typeof p.port == "string") && (T.push(":"), T.push(String(p.port))), T.length ? T.join("") : void 0;
|
|
5498
|
+
}
|
|
5499
|
+
var Ae = /^\.\.?\//, Fe = /^\/\.(\/|$)/, Me = /^\/\.\.(\/|$)/, Ke = /^\/?(?:.|\n)*?(?=\/|$)/;
|
|
5500
|
+
function me(p) {
|
|
5501
|
+
for (var c = []; p.length; )
|
|
5502
|
+
if (p.match(Ae))
|
|
5503
|
+
p = p.replace(Ae, "");
|
|
5504
|
+
else if (p.match(Fe))
|
|
5505
|
+
p = p.replace(Fe, "/");
|
|
5506
|
+
else if (p.match(Me))
|
|
5507
|
+
p = p.replace(Me, "/"), c.pop();
|
|
5508
|
+
else if (p === "." || p === "..")
|
|
5509
|
+
p = "";
|
|
5710
5510
|
else {
|
|
5711
|
-
var m =
|
|
5511
|
+
var m = p.match(Ke);
|
|
5712
5512
|
if (m) {
|
|
5713
|
-
var
|
|
5714
|
-
|
|
5513
|
+
var T = m[0];
|
|
5514
|
+
p = p.slice(T.length), c.push(T);
|
|
5715
5515
|
} else
|
|
5716
5516
|
throw new Error("Unexpected dot segment condition");
|
|
5717
5517
|
}
|
|
5718
5518
|
return c.join("");
|
|
5719
5519
|
}
|
|
5720
|
-
function
|
|
5721
|
-
var c = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, m = c.iri ? g :
|
|
5722
|
-
if (E && E.serialize && E.serialize(
|
|
5520
|
+
function ce(p) {
|
|
5521
|
+
var c = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, m = c.iri ? g : f, T = [], E = M[(c.scheme || p.scheme || "").toLowerCase()];
|
|
5522
|
+
if (E && E.serialize && E.serialize(p, c), p.host && !m.IPV6ADDRESS.test(p.host)) {
|
|
5723
5523
|
if (c.domainHost || E && E.domainHost)
|
|
5724
5524
|
try {
|
|
5725
|
-
|
|
5726
|
-
} catch (
|
|
5727
|
-
|
|
5525
|
+
p.host = c.iri ? N.toUnicode(p.host) : N.toASCII(p.host.replace(m.PCT_ENCODED, x).toLowerCase());
|
|
5526
|
+
} catch (K) {
|
|
5527
|
+
p.error = p.error || "Host's domain name can not be converted to " + (c.iri ? "Unicode" : "ASCII") + " via punycode: " + K;
|
|
5728
5528
|
}
|
|
5729
5529
|
}
|
|
5730
|
-
|
|
5731
|
-
var
|
|
5732
|
-
if (
|
|
5733
|
-
var
|
|
5734
|
-
!c.absolutePath && (!E || !E.absolutePath) && (
|
|
5530
|
+
W(p, m), c.reference !== "suffix" && p.scheme && (T.push(p.scheme), T.push(":"));
|
|
5531
|
+
var L = Ge(p, c);
|
|
5532
|
+
if (L !== void 0 && (c.reference !== "suffix" && T.push("//"), T.push(L), p.path && p.path.charAt(0) !== "/" && T.push("/")), p.path !== void 0) {
|
|
5533
|
+
var U = p.path;
|
|
5534
|
+
!c.absolutePath && (!E || !E.absolutePath) && (U = me(U)), L === void 0 && (U = U.replace(/^\/\//, "/%2F")), T.push(U);
|
|
5735
5535
|
}
|
|
5736
|
-
return
|
|
5536
|
+
return p.query !== void 0 && (T.push("?"), T.push(p.query)), p.fragment !== void 0 && (T.push("#"), T.push(p.fragment)), T.join("");
|
|
5737
5537
|
}
|
|
5738
|
-
function
|
|
5739
|
-
var m = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {},
|
|
5740
|
-
return
|
|
5538
|
+
function qe(p, c) {
|
|
5539
|
+
var m = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}, T = arguments[3], E = {};
|
|
5540
|
+
return T || (p = le(ce(p, m), m), c = le(ce(c, m), m)), m = m || {}, !m.tolerant && c.scheme ? (E.scheme = c.scheme, E.userinfo = c.userinfo, E.host = c.host, E.port = c.port, E.path = me(c.path || ""), E.query = c.query) : (c.userinfo !== void 0 || c.host !== void 0 || c.port !== void 0 ? (E.userinfo = c.userinfo, E.host = c.host, E.port = c.port, E.path = me(c.path || ""), E.query = c.query) : (c.path ? (c.path.charAt(0) === "/" ? E.path = me(c.path) : ((p.userinfo !== void 0 || p.host !== void 0 || p.port !== void 0) && !p.path ? E.path = "/" + c.path : p.path ? E.path = p.path.slice(0, p.path.lastIndexOf("/") + 1) + c.path : E.path = c.path, E.path = me(E.path)), E.query = c.query) : (E.path = p.path, c.query !== void 0 ? E.query = c.query : E.query = p.query), E.userinfo = p.userinfo, E.host = p.host, E.port = p.port), E.scheme = p.scheme), E.fragment = c.fragment, E;
|
|
5741
5541
|
}
|
|
5742
|
-
function
|
|
5743
|
-
var
|
|
5744
|
-
return
|
|
5542
|
+
function Je(p, c, m) {
|
|
5543
|
+
var T = d({ scheme: "null" }, m);
|
|
5544
|
+
return ce(qe(le(p, T), le(c, T), T, !0), T);
|
|
5745
5545
|
}
|
|
5746
|
-
function
|
|
5747
|
-
return typeof
|
|
5546
|
+
function Re(p, c) {
|
|
5547
|
+
return typeof p == "string" ? p = ce(le(p, c), c) : i(p) === "object" && (p = le(ce(p, c), c)), p;
|
|
5748
5548
|
}
|
|
5749
|
-
function
|
|
5750
|
-
return typeof
|
|
5549
|
+
function Qe(p, c, m) {
|
|
5550
|
+
return typeof p == "string" ? p = ce(le(p, m), m) : i(p) === "object" && (p = ce(p, m)), typeof c == "string" ? c = ce(le(c, m), m) : i(c) === "object" && (c = ce(c, m)), p === c;
|
|
5751
5551
|
}
|
|
5752
|
-
function
|
|
5753
|
-
return
|
|
5552
|
+
function et(p, c) {
|
|
5553
|
+
return p && p.toString().replace(!c || !c.iri ? f.ESCAPE : g.ESCAPE, q);
|
|
5754
5554
|
}
|
|
5755
|
-
function
|
|
5756
|
-
return
|
|
5555
|
+
function ue(p, c) {
|
|
5556
|
+
return p && p.toString().replace(!c || !c.iri ? f.PCT_ENCODED : g.PCT_ENCODED, x);
|
|
5757
5557
|
}
|
|
5758
|
-
var
|
|
5558
|
+
var ke = {
|
|
5759
5559
|
scheme: "http",
|
|
5760
5560
|
domainHost: !0,
|
|
5761
5561
|
parse: function(c, m) {
|
|
5762
5562
|
return c.host || (c.error = c.error || "HTTP URIs must have a host."), c;
|
|
5763
5563
|
},
|
|
5764
5564
|
serialize: function(c, m) {
|
|
5765
|
-
var
|
|
5766
|
-
return (c.port === (
|
|
5565
|
+
var T = String(c.scheme).toLowerCase() === "https";
|
|
5566
|
+
return (c.port === (T ? 443 : 80) || c.port === "") && (c.port = void 0), c.path || (c.path = "/"), c;
|
|
5767
5567
|
}
|
|
5768
|
-
},
|
|
5568
|
+
}, wt = {
|
|
5769
5569
|
scheme: "https",
|
|
5770
|
-
domainHost:
|
|
5771
|
-
parse:
|
|
5772
|
-
serialize:
|
|
5570
|
+
domainHost: ke.domainHost,
|
|
5571
|
+
parse: ke.parse,
|
|
5572
|
+
serialize: ke.serialize
|
|
5773
5573
|
};
|
|
5774
|
-
function
|
|
5775
|
-
return typeof
|
|
5574
|
+
function bt(p) {
|
|
5575
|
+
return typeof p.secure == "boolean" ? p.secure : String(p.scheme).toLowerCase() === "wss";
|
|
5776
5576
|
}
|
|
5777
|
-
var
|
|
5577
|
+
var Ze = {
|
|
5778
5578
|
scheme: "ws",
|
|
5779
5579
|
domainHost: !0,
|
|
5780
5580
|
parse: function(c, m) {
|
|
5781
|
-
var
|
|
5782
|
-
return
|
|
5581
|
+
var T = c;
|
|
5582
|
+
return T.secure = bt(T), T.resourceName = (T.path || "/") + (T.query ? "?" + T.query : ""), T.path = void 0, T.query = void 0, T;
|
|
5783
5583
|
},
|
|
5784
5584
|
serialize: function(c, m) {
|
|
5785
|
-
if ((c.port === (
|
|
5786
|
-
var
|
|
5787
|
-
c.path =
|
|
5585
|
+
if ((c.port === (bt(c) ? 443 : 80) || c.port === "") && (c.port = void 0), typeof c.secure == "boolean" && (c.scheme = c.secure ? "wss" : "ws", c.secure = void 0), c.resourceName) {
|
|
5586
|
+
var T = c.resourceName.split("?"), E = O(T, 2), L = E[0], U = E[1];
|
|
5587
|
+
c.path = L && L !== "/" ? L : void 0, c.query = U, c.resourceName = void 0;
|
|
5788
5588
|
}
|
|
5789
5589
|
return c.fragment = void 0, c;
|
|
5790
5590
|
}
|
|
5791
|
-
},
|
|
5591
|
+
}, Pt = {
|
|
5792
5592
|
scheme: "wss",
|
|
5793
|
-
domainHost:
|
|
5794
|
-
parse:
|
|
5795
|
-
serialize:
|
|
5796
|
-
},
|
|
5797
|
-
function
|
|
5798
|
-
var c =
|
|
5799
|
-
return c.match(
|
|
5800
|
-
}
|
|
5801
|
-
var
|
|
5593
|
+
domainHost: Ze.domainHost,
|
|
5594
|
+
parse: Ze.parse,
|
|
5595
|
+
serialize: Ze.serialize
|
|
5596
|
+
}, Kt = {}, Et = "[A-Za-z0-9\\-\\.\\_\\~\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]", _e = "[0-9A-Fa-f]", Jt = s(s("%[EFef]" + _e + "%" + _e + _e + "%" + _e + _e) + "|" + s("%[89A-Fa-f]" + _e + "%" + _e + _e) + "|" + s("%" + _e + _e)), Qt = "[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]", Zt = "[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]", Yt = n(Zt, '[\\"\\\\]'), Xt = "[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]", er = new RegExp(Et, "g"), Le = new RegExp(Jt, "g"), tr = new RegExp(n("[^]", Qt, "[\\.]", '[\\"]', Yt), "g"), St = new RegExp(n("[^]", Et, Xt), "g"), rr = St;
|
|
5597
|
+
function yt(p) {
|
|
5598
|
+
var c = x(p);
|
|
5599
|
+
return c.match(er) ? c : p;
|
|
5600
|
+
}
|
|
5601
|
+
var Tt = {
|
|
5802
5602
|
scheme: "mailto",
|
|
5803
5603
|
parse: function(c, m) {
|
|
5804
|
-
var
|
|
5805
|
-
if (
|
|
5806
|
-
for (var
|
|
5807
|
-
var B = Q
|
|
5604
|
+
var T = c, E = T.to = T.path ? T.path.split(",") : [];
|
|
5605
|
+
if (T.path = void 0, T.query) {
|
|
5606
|
+
for (var L = !1, U = {}, K = T.query.split("&"), Q = 0, re = K.length; Q < re; ++Q) {
|
|
5607
|
+
var B = K[Q].split("=");
|
|
5808
5608
|
switch (B[0]) {
|
|
5809
5609
|
case "to":
|
|
5810
|
-
for (var
|
|
5811
|
-
E.push(
|
|
5610
|
+
for (var J = B[1].split(","), ne = 0, z = J.length; ne < z; ++ne)
|
|
5611
|
+
E.push(J[ne]);
|
|
5812
5612
|
break;
|
|
5813
5613
|
case "subject":
|
|
5814
|
-
|
|
5614
|
+
T.subject = ue(B[1], m);
|
|
5815
5615
|
break;
|
|
5816
5616
|
case "body":
|
|
5817
|
-
|
|
5617
|
+
T.body = ue(B[1], m);
|
|
5818
5618
|
break;
|
|
5819
5619
|
default:
|
|
5820
|
-
|
|
5620
|
+
L = !0, U[ue(B[0], m)] = ue(B[1], m);
|
|
5821
5621
|
break;
|
|
5822
5622
|
}
|
|
5823
5623
|
}
|
|
5824
|
-
|
|
5624
|
+
L && (T.headers = U);
|
|
5825
5625
|
}
|
|
5826
|
-
|
|
5827
|
-
for (var
|
|
5828
|
-
var
|
|
5829
|
-
if (
|
|
5830
|
-
|
|
5626
|
+
T.query = void 0;
|
|
5627
|
+
for (var Z = 0, oe = E.length; Z < oe; ++Z) {
|
|
5628
|
+
var Y = E[Z].split("@");
|
|
5629
|
+
if (Y[0] = ue(Y[0]), m.unicodeSupport)
|
|
5630
|
+
Y[1] = ue(Y[1], m).toLowerCase();
|
|
5831
5631
|
else
|
|
5832
5632
|
try {
|
|
5833
|
-
|
|
5834
|
-
} catch (
|
|
5835
|
-
|
|
5633
|
+
Y[1] = N.toASCII(ue(Y[1], m).toLowerCase());
|
|
5634
|
+
} catch (Pe) {
|
|
5635
|
+
T.error = T.error || "Email address's domain name can not be converted to ASCII via punycode: " + Pe;
|
|
5836
5636
|
}
|
|
5837
|
-
E[
|
|
5637
|
+
E[Z] = Y.join("@");
|
|
5838
5638
|
}
|
|
5839
|
-
return
|
|
5639
|
+
return T;
|
|
5840
5640
|
},
|
|
5841
5641
|
serialize: function(c, m) {
|
|
5842
|
-
var
|
|
5642
|
+
var T = c, E = l(c.to);
|
|
5843
5643
|
if (E) {
|
|
5844
|
-
for (var
|
|
5845
|
-
var
|
|
5644
|
+
for (var L = 0, U = E.length; L < U; ++L) {
|
|
5645
|
+
var K = String(E[L]), Q = K.lastIndexOf("@"), re = K.slice(0, Q).replace(Le, yt).replace(Le, o).replace(tr, q), B = K.slice(Q + 1);
|
|
5846
5646
|
try {
|
|
5847
|
-
B = m.iri ? N.toUnicode(B) : N.toASCII(
|
|
5848
|
-
} catch (
|
|
5849
|
-
|
|
5647
|
+
B = m.iri ? N.toUnicode(B) : N.toASCII(ue(B, m).toLowerCase());
|
|
5648
|
+
} catch (Z) {
|
|
5649
|
+
T.error = T.error || "Email address's domain name can not be converted to " + (m.iri ? "Unicode" : "ASCII") + " via punycode: " + Z;
|
|
5850
5650
|
}
|
|
5851
|
-
E[
|
|
5651
|
+
E[L] = re + "@" + B;
|
|
5852
5652
|
}
|
|
5853
|
-
|
|
5653
|
+
T.path = E.join(",");
|
|
5854
5654
|
}
|
|
5855
|
-
var
|
|
5856
|
-
c.subject && (
|
|
5857
|
-
var
|
|
5858
|
-
for (var z in
|
|
5859
|
-
|
|
5860
|
-
return
|
|
5655
|
+
var J = c.headers = c.headers || {};
|
|
5656
|
+
c.subject && (J.subject = c.subject), c.body && (J.body = c.body);
|
|
5657
|
+
var ne = [];
|
|
5658
|
+
for (var z in J)
|
|
5659
|
+
J[z] !== Kt[z] && ne.push(z.replace(Le, yt).replace(Le, o).replace(St, q) + "=" + J[z].replace(Le, yt).replace(Le, o).replace(rr, q));
|
|
5660
|
+
return ne.length && (T.query = ne.join("&")), T;
|
|
5861
5661
|
}
|
|
5862
|
-
},
|
|
5662
|
+
}, nr = /^([^\:]+)\:(.*)/, Rt = {
|
|
5863
5663
|
scheme: "urn",
|
|
5864
5664
|
parse: function(c, m) {
|
|
5865
|
-
var
|
|
5866
|
-
if (
|
|
5867
|
-
var
|
|
5868
|
-
E.nid =
|
|
5665
|
+
var T = c.path && c.path.match(nr), E = c;
|
|
5666
|
+
if (T) {
|
|
5667
|
+
var L = m.scheme || E.scheme || "urn", U = T[1].toLowerCase(), K = T[2], Q = L + ":" + (m.nid || U), re = M[Q];
|
|
5668
|
+
E.nid = U, E.nss = K, E.path = void 0, re && (E = re.parse(E, m));
|
|
5869
5669
|
} else
|
|
5870
5670
|
E.error = E.error || "URN can not be parsed.";
|
|
5871
5671
|
return E;
|
|
5872
5672
|
},
|
|
5873
5673
|
serialize: function(c, m) {
|
|
5874
|
-
var
|
|
5875
|
-
|
|
5876
|
-
var
|
|
5877
|
-
return
|
|
5674
|
+
var T = m.scheme || c.scheme || "urn", E = c.nid, L = T + ":" + (m.nid || E), U = M[L];
|
|
5675
|
+
U && (c = U.serialize(c, m));
|
|
5676
|
+
var K = c, Q = c.nss;
|
|
5677
|
+
return K.path = (E || m.nid) + ":" + Q, K;
|
|
5878
5678
|
}
|
|
5879
|
-
},
|
|
5679
|
+
}, sr = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/, kt = {
|
|
5880
5680
|
scheme: "urn:uuid",
|
|
5881
5681
|
parse: function(c, m) {
|
|
5882
|
-
var
|
|
5883
|
-
return
|
|
5682
|
+
var T = c;
|
|
5683
|
+
return T.uuid = T.nss, T.nss = void 0, !m.tolerant && (!T.uuid || !T.uuid.match(sr)) && (T.error = T.error || "UUID is not valid."), T;
|
|
5884
5684
|
},
|
|
5885
5685
|
serialize: function(c, m) {
|
|
5886
|
-
var
|
|
5887
|
-
return
|
|
5686
|
+
var T = c;
|
|
5687
|
+
return T.nss = (c.uuid || "").toLowerCase(), T;
|
|
5888
5688
|
}
|
|
5889
5689
|
};
|
|
5890
|
-
M[
|
|
5690
|
+
M[ke.scheme] = ke, M[wt.scheme] = wt, M[Ze.scheme] = Ze, M[Pt.scheme] = Pt, M[Tt.scheme] = Tt, M[Rt.scheme] = Rt, M[kt.scheme] = kt, r.SCHEMES = M, r.pctEncChar = q, r.pctDecChars = x, r.parse = le, r.removeDotSegments = me, r.serialize = ce, r.resolveComponents = qe, r.resolve = Je, r.normalize = Re, r.equal = Qe, r.escapeComponent = et, r.unescapeComponent = ue, Object.defineProperty(r, "__esModule", { value: !0 });
|
|
5891
5691
|
});
|
|
5892
5692
|
})(uri_all, uri_all.exports);
|
|
5893
5693
|
var uri_allExports = uri_all.exports;
|
|
@@ -5915,9 +5715,9 @@ uri$1.default = uri;
|
|
|
5915
5715
|
} }), Object.defineProperty(e, "CodeGen", { enumerable: !0, get: function() {
|
|
5916
5716
|
return r.CodeGen;
|
|
5917
5717
|
} });
|
|
5918
|
-
const n = validation_error, s = ref_error, i = rules, o = compile, l = codegen, d = resolve$1, u = dataType,
|
|
5718
|
+
const n = validation_error, s = ref_error, i = rules, o = compile, l = codegen, d = resolve$1, u = dataType, f = util, g = require$$9, O = uri$1, C = (F, v) => new RegExp(F, v);
|
|
5919
5719
|
C.code = "new RegExp";
|
|
5920
|
-
const S = ["removeAdditional", "useDefaults", "coerceTypes"],
|
|
5720
|
+
const S = ["removeAdditional", "useDefaults", "coerceTypes"], R = /* @__PURE__ */ new Set([
|
|
5921
5721
|
"validate",
|
|
5922
5722
|
"serialize",
|
|
5923
5723
|
"parse",
|
|
@@ -5952,110 +5752,110 @@ uri$1.default = uri;
|
|
|
5952
5752
|
jsPropertySyntax: "",
|
|
5953
5753
|
unicode: '"minLength"/"maxLength" account for unicode characters by default.'
|
|
5954
5754
|
}, $ = 200;
|
|
5955
|
-
function
|
|
5956
|
-
var v, j,
|
|
5957
|
-
const
|
|
5755
|
+
function b(F) {
|
|
5756
|
+
var v, j, P, a, h, N, M, q, x, W, te, he, De, Be, We, le, Ge, Ae, Fe, Me, Ke, me, ce, qe, Je;
|
|
5757
|
+
const Re = F.strict, Qe = (v = F.code) === null || v === void 0 ? void 0 : v.optimize, et = Qe === !0 || Qe === void 0 ? 1 : Qe || 0, ue = (P = (j = F.code) === null || j === void 0 ? void 0 : j.regExp) !== null && P !== void 0 ? P : C, ke = (a = F.uriResolver) !== null && a !== void 0 ? a : O.default;
|
|
5958
5758
|
return {
|
|
5959
|
-
strictSchema: (N = (h = F.strictSchema) !== null && h !== void 0 ? h :
|
|
5960
|
-
strictNumbers: (q = (M = F.strictNumbers) !== null && M !== void 0 ? M :
|
|
5961
|
-
strictTypes: (
|
|
5962
|
-
strictTuples: (he = (
|
|
5963
|
-
strictRequired: (
|
|
5964
|
-
code: F.code ? { ...F.code, optimize:
|
|
5965
|
-
loopRequired: (
|
|
5966
|
-
loopEnum: (
|
|
5967
|
-
meta: (
|
|
5968
|
-
messages: (
|
|
5969
|
-
inlineRefs: (
|
|
5970
|
-
schemaId: (
|
|
5971
|
-
addUsedSchema: (
|
|
5759
|
+
strictSchema: (N = (h = F.strictSchema) !== null && h !== void 0 ? h : Re) !== null && N !== void 0 ? N : !0,
|
|
5760
|
+
strictNumbers: (q = (M = F.strictNumbers) !== null && M !== void 0 ? M : Re) !== null && q !== void 0 ? q : !0,
|
|
5761
|
+
strictTypes: (W = (x = F.strictTypes) !== null && x !== void 0 ? x : Re) !== null && W !== void 0 ? W : "log",
|
|
5762
|
+
strictTuples: (he = (te = F.strictTuples) !== null && te !== void 0 ? te : Re) !== null && he !== void 0 ? he : "log",
|
|
5763
|
+
strictRequired: (Be = (De = F.strictRequired) !== null && De !== void 0 ? De : Re) !== null && Be !== void 0 ? Be : !1,
|
|
5764
|
+
code: F.code ? { ...F.code, optimize: et, regExp: ue } : { optimize: et, regExp: ue },
|
|
5765
|
+
loopRequired: (We = F.loopRequired) !== null && We !== void 0 ? We : $,
|
|
5766
|
+
loopEnum: (le = F.loopEnum) !== null && le !== void 0 ? le : $,
|
|
5767
|
+
meta: (Ge = F.meta) !== null && Ge !== void 0 ? Ge : !0,
|
|
5768
|
+
messages: (Ae = F.messages) !== null && Ae !== void 0 ? Ae : !0,
|
|
5769
|
+
inlineRefs: (Fe = F.inlineRefs) !== null && Fe !== void 0 ? Fe : !0,
|
|
5770
|
+
schemaId: (Me = F.schemaId) !== null && Me !== void 0 ? Me : "$id",
|
|
5771
|
+
addUsedSchema: (Ke = F.addUsedSchema) !== null && Ke !== void 0 ? Ke : !0,
|
|
5972
5772
|
validateSchema: (me = F.validateSchema) !== null && me !== void 0 ? me : !0,
|
|
5973
|
-
validateFormats: (
|
|
5974
|
-
unicodeRegExp: (
|
|
5975
|
-
int32range: (
|
|
5976
|
-
uriResolver:
|
|
5773
|
+
validateFormats: (ce = F.validateFormats) !== null && ce !== void 0 ? ce : !0,
|
|
5774
|
+
unicodeRegExp: (qe = F.unicodeRegExp) !== null && qe !== void 0 ? qe : !0,
|
|
5775
|
+
int32range: (Je = F.int32range) !== null && Je !== void 0 ? Je : !0,
|
|
5776
|
+
uriResolver: ke
|
|
5977
5777
|
};
|
|
5978
5778
|
}
|
|
5979
5779
|
class I {
|
|
5980
5780
|
constructor(v = {}) {
|
|
5981
|
-
this.schemas = {}, this.refs = {}, this.formats = {}, this._compilations = /* @__PURE__ */ new Set(), this._loading = {}, this._cache = /* @__PURE__ */ new Map(), v = this.opts = { ...v, ...
|
|
5982
|
-
const { es5: j, lines:
|
|
5983
|
-
this.scope = new l.ValueScope({ scope: {}, prefixes:
|
|
5781
|
+
this.schemas = {}, this.refs = {}, this.formats = {}, this._compilations = /* @__PURE__ */ new Set(), this._loading = {}, this._cache = /* @__PURE__ */ new Map(), v = this.opts = { ...v, ...b(v) };
|
|
5782
|
+
const { es5: j, lines: P } = this.opts.code;
|
|
5783
|
+
this.scope = new l.ValueScope({ scope: {}, prefixes: R, es5: j, lines: P }), this.logger = G(v.logger);
|
|
5984
5784
|
const a = v.validateFormats;
|
|
5985
|
-
v.validateFormats = !1, this.RULES = (0, i.getRules)(),
|
|
5785
|
+
v.validateFormats = !1, this.RULES = (0, i.getRules)(), A.call(this, y, v, "NOT SUPPORTED"), A.call(this, _, v, "DEPRECATED", "warn"), this._metaOpts = H.call(this), v.formats && D.call(this), this._addVocabularies(), this._addDefaultMetaSchema(), v.keywords && V.call(this, v.keywords), typeof v.meta == "object" && this.addMetaSchema(v.meta), k.call(this), v.validateFormats = a;
|
|
5986
5786
|
}
|
|
5987
5787
|
_addVocabularies() {
|
|
5988
5788
|
this.addKeyword("$async");
|
|
5989
5789
|
}
|
|
5990
5790
|
_addDefaultMetaSchema() {
|
|
5991
|
-
const { $data: v, meta: j, schemaId:
|
|
5791
|
+
const { $data: v, meta: j, schemaId: P } = this.opts;
|
|
5992
5792
|
let a = g;
|
|
5993
|
-
|
|
5793
|
+
P === "id" && (a = { ...g }, a.id = a.$id, delete a.$id), j && v && this.addMetaSchema(a, a[P], !1);
|
|
5994
5794
|
}
|
|
5995
5795
|
defaultMeta() {
|
|
5996
5796
|
const { meta: v, schemaId: j } = this.opts;
|
|
5997
5797
|
return this.opts.defaultMeta = typeof v == "object" ? v[j] || v : void 0;
|
|
5998
5798
|
}
|
|
5999
5799
|
validate(v, j) {
|
|
6000
|
-
let
|
|
5800
|
+
let P;
|
|
6001
5801
|
if (typeof v == "string") {
|
|
6002
|
-
if (
|
|
5802
|
+
if (P = this.getSchema(v), !P)
|
|
6003
5803
|
throw new Error(`no schema with key or ref "${v}"`);
|
|
6004
5804
|
} else
|
|
6005
|
-
|
|
6006
|
-
const a =
|
|
6007
|
-
return "$async" in
|
|
5805
|
+
P = this.compile(v);
|
|
5806
|
+
const a = P(j);
|
|
5807
|
+
return "$async" in P || (this.errors = P.errors), a;
|
|
6008
5808
|
}
|
|
6009
5809
|
compile(v, j) {
|
|
6010
|
-
const
|
|
6011
|
-
return
|
|
5810
|
+
const P = this._addSchema(v, j);
|
|
5811
|
+
return P.validate || this._compileSchemaEnv(P);
|
|
6012
5812
|
}
|
|
6013
5813
|
compileAsync(v, j) {
|
|
6014
5814
|
if (typeof this.opts.loadSchema != "function")
|
|
6015
5815
|
throw new Error("options.loadSchema should be a function");
|
|
6016
|
-
const { loadSchema:
|
|
5816
|
+
const { loadSchema: P } = this.opts;
|
|
6017
5817
|
return a.call(this, v, j);
|
|
6018
|
-
async function a(
|
|
6019
|
-
await h.call(this,
|
|
6020
|
-
const he = this._addSchema(
|
|
5818
|
+
async function a(W, te) {
|
|
5819
|
+
await h.call(this, W.$schema);
|
|
5820
|
+
const he = this._addSchema(W, te);
|
|
6021
5821
|
return he.validate || N.call(this, he);
|
|
6022
5822
|
}
|
|
6023
|
-
async function h(
|
|
6024
|
-
|
|
5823
|
+
async function h(W) {
|
|
5824
|
+
W && !this.getSchema(W) && await a.call(this, { $ref: W }, !0);
|
|
6025
5825
|
}
|
|
6026
|
-
async function N(
|
|
5826
|
+
async function N(W) {
|
|
6027
5827
|
try {
|
|
6028
|
-
return this._compileSchemaEnv(
|
|
6029
|
-
} catch (
|
|
6030
|
-
if (!(
|
|
6031
|
-
throw
|
|
6032
|
-
return M.call(this,
|
|
5828
|
+
return this._compileSchemaEnv(W);
|
|
5829
|
+
} catch (te) {
|
|
5830
|
+
if (!(te instanceof s.default))
|
|
5831
|
+
throw te;
|
|
5832
|
+
return M.call(this, te), await q.call(this, te.missingSchema), N.call(this, W);
|
|
6033
5833
|
}
|
|
6034
5834
|
}
|
|
6035
|
-
function M({ missingSchema:
|
|
6036
|
-
if (this.refs[
|
|
6037
|
-
throw new Error(`AnySchema ${
|
|
5835
|
+
function M({ missingSchema: W, missingRef: te }) {
|
|
5836
|
+
if (this.refs[W])
|
|
5837
|
+
throw new Error(`AnySchema ${W} is loaded but ${te} cannot be resolved`);
|
|
6038
5838
|
}
|
|
6039
|
-
async function q(
|
|
6040
|
-
const
|
|
6041
|
-
this.refs[
|
|
5839
|
+
async function q(W) {
|
|
5840
|
+
const te = await x.call(this, W);
|
|
5841
|
+
this.refs[W] || await h.call(this, te.$schema), this.refs[W] || this.addSchema(te, W, j);
|
|
6042
5842
|
}
|
|
6043
|
-
async function W
|
|
6044
|
-
const
|
|
6045
|
-
if (
|
|
6046
|
-
return
|
|
5843
|
+
async function x(W) {
|
|
5844
|
+
const te = this._loading[W];
|
|
5845
|
+
if (te)
|
|
5846
|
+
return te;
|
|
6047
5847
|
try {
|
|
6048
|
-
return await (this._loading[
|
|
5848
|
+
return await (this._loading[W] = P(W));
|
|
6049
5849
|
} finally {
|
|
6050
|
-
delete this._loading[
|
|
5850
|
+
delete this._loading[W];
|
|
6051
5851
|
}
|
|
6052
5852
|
}
|
|
6053
5853
|
}
|
|
6054
5854
|
// Adds schema to the instance
|
|
6055
|
-
addSchema(v, j,
|
|
5855
|
+
addSchema(v, j, P, a = this.opts.validateSchema) {
|
|
6056
5856
|
if (Array.isArray(v)) {
|
|
6057
5857
|
for (const N of v)
|
|
6058
|
-
this.addSchema(N, void 0,
|
|
5858
|
+
this.addSchema(N, void 0, P, a);
|
|
6059
5859
|
return this;
|
|
6060
5860
|
}
|
|
6061
5861
|
let h;
|
|
@@ -6064,23 +5864,23 @@ uri$1.default = uri;
|
|
|
6064
5864
|
if (h = v[N], h !== void 0 && typeof h != "string")
|
|
6065
5865
|
throw new Error(`schema ${N} must be string`);
|
|
6066
5866
|
}
|
|
6067
|
-
return j = (0, d.normalizeId)(j || h), this._checkUnique(j), this.schemas[j] = this._addSchema(v,
|
|
5867
|
+
return j = (0, d.normalizeId)(j || h), this._checkUnique(j), this.schemas[j] = this._addSchema(v, P, j, a, !0), this;
|
|
6068
5868
|
}
|
|
6069
5869
|
// Add schema that will be used to validate other schemas
|
|
6070
5870
|
// options in META_IGNORE_OPTIONS are alway set to false
|
|
6071
|
-
addMetaSchema(v, j,
|
|
6072
|
-
return this.addSchema(v, j, !0,
|
|
5871
|
+
addMetaSchema(v, j, P = this.opts.validateSchema) {
|
|
5872
|
+
return this.addSchema(v, j, !0, P), this;
|
|
6073
5873
|
}
|
|
6074
5874
|
// Validate schema against its meta-schema
|
|
6075
5875
|
validateSchema(v, j) {
|
|
6076
5876
|
if (typeof v == "boolean")
|
|
6077
5877
|
return !0;
|
|
6078
|
-
let
|
|
6079
|
-
if (
|
|
5878
|
+
let P;
|
|
5879
|
+
if (P = v.$schema, P !== void 0 && typeof P != "string")
|
|
6080
5880
|
throw new Error("$schema must be a string");
|
|
6081
|
-
if (
|
|
5881
|
+
if (P = P || this.opts.defaultMeta || this.defaultMeta(), !P)
|
|
6082
5882
|
return this.logger.warn("meta-schema not available"), this.errors = null, !0;
|
|
6083
|
-
const a = this.validate(
|
|
5883
|
+
const a = this.validate(P, v);
|
|
6084
5884
|
if (!a && j) {
|
|
6085
5885
|
const h = "schema is invalid: " + this.errorsText();
|
|
6086
5886
|
if (this.opts.validateSchema === "log")
|
|
@@ -6097,7 +5897,7 @@ uri$1.default = uri;
|
|
|
6097
5897
|
for (; typeof (j = w.call(this, v)) == "string"; )
|
|
6098
5898
|
v = j;
|
|
6099
5899
|
if (j === void 0) {
|
|
6100
|
-
const { schemaId:
|
|
5900
|
+
const { schemaId: P } = this.opts, a = new o.SchemaEnv({ schema: {}, schemaId: P });
|
|
6101
5901
|
if (j = o.resolveSchema.call(this, a, v), !j)
|
|
6102
5902
|
return;
|
|
6103
5903
|
this.refs[v] = j;
|
|
@@ -6121,8 +5921,8 @@ uri$1.default = uri;
|
|
|
6121
5921
|
case "object": {
|
|
6122
5922
|
const j = v;
|
|
6123
5923
|
this._cache.delete(j);
|
|
6124
|
-
let
|
|
6125
|
-
return
|
|
5924
|
+
let P = v[this.opts.schemaId];
|
|
5925
|
+
return P && (P = (0, d.normalizeId)(P), delete this.schemas[P], delete this.refs[P]), this;
|
|
6126
5926
|
}
|
|
6127
5927
|
default:
|
|
6128
5928
|
throw new Error("ajv.removeSchema: invalid parameter");
|
|
@@ -6135,23 +5935,23 @@ uri$1.default = uri;
|
|
|
6135
5935
|
return this;
|
|
6136
5936
|
}
|
|
6137
5937
|
addKeyword(v, j) {
|
|
6138
|
-
let
|
|
5938
|
+
let P;
|
|
6139
5939
|
if (typeof v == "string")
|
|
6140
|
-
|
|
5940
|
+
P = v, typeof j == "object" && (this.logger.warn("these parameters are deprecated, see docs for addKeyword"), j.keyword = P);
|
|
6141
5941
|
else if (typeof v == "object" && j === void 0) {
|
|
6142
|
-
if (j = v,
|
|
5942
|
+
if (j = v, P = j.keyword, Array.isArray(P) && !P.length)
|
|
6143
5943
|
throw new Error("addKeywords: keyword must be string or non-empty array");
|
|
6144
5944
|
} else
|
|
6145
5945
|
throw new Error("invalid addKeywords parameters");
|
|
6146
|
-
if (
|
|
6147
|
-
return (0,
|
|
6148
|
-
|
|
5946
|
+
if (ie.call(this, P, j), !j)
|
|
5947
|
+
return (0, f.eachItem)(P, (h) => Se.call(this, h)), this;
|
|
5948
|
+
Ie.call(this, j);
|
|
6149
5949
|
const a = {
|
|
6150
5950
|
...j,
|
|
6151
5951
|
type: (0, u.getJSONTypes)(j.type),
|
|
6152
5952
|
schemaType: (0, u.getJSONTypes)(j.schemaType)
|
|
6153
5953
|
};
|
|
6154
|
-
return (0,
|
|
5954
|
+
return (0, f.eachItem)(P, a.type.length === 0 ? (h) => Se.call(this, h, a) : (h) => a.type.forEach((N) => Se.call(this, h, a, N))), this;
|
|
6155
5955
|
}
|
|
6156
5956
|
getKeyword(v) {
|
|
6157
5957
|
const j = this.RULES.all[v];
|
|
@@ -6161,9 +5961,9 @@ uri$1.default = uri;
|
|
|
6161
5961
|
removeKeyword(v) {
|
|
6162
5962
|
const { RULES: j } = this;
|
|
6163
5963
|
delete j.keywords[v], delete j.all[v];
|
|
6164
|
-
for (const
|
|
6165
|
-
const a =
|
|
6166
|
-
a >= 0 &&
|
|
5964
|
+
for (const P of j.rules) {
|
|
5965
|
+
const a = P.rules.findIndex((h) => h.keyword === v);
|
|
5966
|
+
a >= 0 && P.rules.splice(a, 1);
|
|
6167
5967
|
}
|
|
6168
5968
|
return this;
|
|
6169
5969
|
}
|
|
@@ -6171,34 +5971,34 @@ uri$1.default = uri;
|
|
|
6171
5971
|
addFormat(v, j) {
|
|
6172
5972
|
return typeof j == "string" && (j = new RegExp(j)), this.formats[v] = j, this;
|
|
6173
5973
|
}
|
|
6174
|
-
errorsText(v = this.errors, { separator: j = ", ", dataVar:
|
|
6175
|
-
return !v || v.length === 0 ? "No errors" : v.map((a) => `${
|
|
5974
|
+
errorsText(v = this.errors, { separator: j = ", ", dataVar: P = "data" } = {}) {
|
|
5975
|
+
return !v || v.length === 0 ? "No errors" : v.map((a) => `${P}${a.instancePath} ${a.message}`).reduce((a, h) => a + j + h);
|
|
6176
5976
|
}
|
|
6177
5977
|
$dataMetaSchema(v, j) {
|
|
6178
|
-
const
|
|
5978
|
+
const P = this.RULES.all;
|
|
6179
5979
|
v = JSON.parse(JSON.stringify(v));
|
|
6180
5980
|
for (const a of j) {
|
|
6181
5981
|
const h = a.split("/").slice(1);
|
|
6182
5982
|
let N = v;
|
|
6183
5983
|
for (const M of h)
|
|
6184
5984
|
N = N[M];
|
|
6185
|
-
for (const M in
|
|
6186
|
-
const q =
|
|
5985
|
+
for (const M in P) {
|
|
5986
|
+
const q = P[M];
|
|
6187
5987
|
if (typeof q != "object")
|
|
6188
5988
|
continue;
|
|
6189
|
-
const { $data:
|
|
6190
|
-
|
|
5989
|
+
const { $data: x } = q.definition, W = N[M];
|
|
5990
|
+
x && W && (N[M] = je(W));
|
|
6191
5991
|
}
|
|
6192
5992
|
}
|
|
6193
5993
|
return v;
|
|
6194
5994
|
}
|
|
6195
5995
|
_removeAllSchemas(v, j) {
|
|
6196
|
-
for (const
|
|
6197
|
-
const a = v[
|
|
6198
|
-
(!j || j.test(
|
|
5996
|
+
for (const P in v) {
|
|
5997
|
+
const a = v[P];
|
|
5998
|
+
(!j || j.test(P)) && (typeof a == "string" ? delete v[P] : a && !a.meta && (this._cache.delete(a.schema), delete v[P]));
|
|
6199
5999
|
}
|
|
6200
6000
|
}
|
|
6201
|
-
_addSchema(v, j,
|
|
6001
|
+
_addSchema(v, j, P, a = this.opts.validateSchema, h = this.opts.addUsedSchema) {
|
|
6202
6002
|
let N;
|
|
6203
6003
|
const { schemaId: M } = this.opts;
|
|
6204
6004
|
if (typeof v == "object")
|
|
@@ -6212,9 +6012,9 @@ uri$1.default = uri;
|
|
|
6212
6012
|
let q = this._cache.get(v);
|
|
6213
6013
|
if (q !== void 0)
|
|
6214
6014
|
return q;
|
|
6215
|
-
|
|
6216
|
-
const
|
|
6217
|
-
return q = new o.SchemaEnv({ schema: v, schemaId: M, meta: j, baseId:
|
|
6015
|
+
P = (0, d.normalizeId)(N || P);
|
|
6016
|
+
const x = d.getSchemaRefs.call(this, v, P);
|
|
6017
|
+
return q = new o.SchemaEnv({ schema: v, schemaId: M, meta: j, baseId: P, localRefs: x }), this._cache.set(q.schema, q), h && !P.startsWith("#") && (P && this._checkUnique(P), this.refs[P] = q), a && this.validateSchema(v, !0), q;
|
|
6218
6018
|
}
|
|
6219
6019
|
_checkUnique(v) {
|
|
6220
6020
|
if (this.schemas[v] || this.refs[v])
|
|
@@ -6236,10 +6036,10 @@ uri$1.default = uri;
|
|
|
6236
6036
|
}
|
|
6237
6037
|
}
|
|
6238
6038
|
e.default = I, I.ValidationError = n.default, I.MissingRefError = s.default;
|
|
6239
|
-
function
|
|
6039
|
+
function A(F, v, j, P = "error") {
|
|
6240
6040
|
for (const a in F) {
|
|
6241
6041
|
const h = a;
|
|
6242
|
-
h in v && this.logger[
|
|
6042
|
+
h in v && this.logger[P](`${j}: option ${a}. ${F[h]}`);
|
|
6243
6043
|
}
|
|
6244
6044
|
}
|
|
6245
6045
|
function w(F) {
|
|
@@ -6254,7 +6054,7 @@ uri$1.default = uri;
|
|
|
6254
6054
|
for (const v in F)
|
|
6255
6055
|
this.addSchema(F[v], v);
|
|
6256
6056
|
}
|
|
6257
|
-
function
|
|
6057
|
+
function D() {
|
|
6258
6058
|
for (const F in this.opts.formats) {
|
|
6259
6059
|
const v = this.opts.formats[F];
|
|
6260
6060
|
v && this.addFormat(F, v);
|
|
@@ -6271,38 +6071,38 @@ uri$1.default = uri;
|
|
|
6271
6071
|
j.keyword || (j.keyword = v), this.addKeyword(j);
|
|
6272
6072
|
}
|
|
6273
6073
|
}
|
|
6274
|
-
function
|
|
6074
|
+
function H() {
|
|
6275
6075
|
const F = { ...this.opts };
|
|
6276
6076
|
for (const v of S)
|
|
6277
6077
|
delete F[v];
|
|
6278
6078
|
return F;
|
|
6279
6079
|
}
|
|
6280
|
-
const
|
|
6080
|
+
const X = { log() {
|
|
6281
6081
|
}, warn() {
|
|
6282
6082
|
}, error() {
|
|
6283
6083
|
} };
|
|
6284
|
-
function
|
|
6084
|
+
function G(F) {
|
|
6285
6085
|
if (F === !1)
|
|
6286
|
-
return
|
|
6086
|
+
return X;
|
|
6287
6087
|
if (F === void 0)
|
|
6288
6088
|
return console;
|
|
6289
6089
|
if (F.log && F.warn && F.error)
|
|
6290
6090
|
return F;
|
|
6291
6091
|
throw new Error("logger must implement log, warn and error methods");
|
|
6292
6092
|
}
|
|
6293
|
-
const
|
|
6294
|
-
function
|
|
6093
|
+
const de = /^[a-z_$][a-z0-9_$:-]*$/i;
|
|
6094
|
+
function ie(F, v) {
|
|
6295
6095
|
const { RULES: j } = this;
|
|
6296
|
-
if ((0,
|
|
6297
|
-
if (j.keywords[
|
|
6298
|
-
throw new Error(`Keyword ${
|
|
6299
|
-
if (!
|
|
6300
|
-
throw new Error(`Keyword ${
|
|
6096
|
+
if ((0, f.eachItem)(F, (P) => {
|
|
6097
|
+
if (j.keywords[P])
|
|
6098
|
+
throw new Error(`Keyword ${P} is already defined`);
|
|
6099
|
+
if (!de.test(P))
|
|
6100
|
+
throw new Error(`Keyword ${P} has invalid name`);
|
|
6301
6101
|
}), !!v && v.$data && !("code" in v || "validate" in v))
|
|
6302
6102
|
throw new Error('$data keyword must have "code" or "validate" function');
|
|
6303
6103
|
}
|
|
6304
|
-
function
|
|
6305
|
-
var
|
|
6104
|
+
function Se(F, v, j) {
|
|
6105
|
+
var P;
|
|
6306
6106
|
const a = v == null ? void 0 : v.post;
|
|
6307
6107
|
if (j && a)
|
|
6308
6108
|
throw new Error('keyword with "post" flag cannot have "type"');
|
|
@@ -6318,21 +6118,21 @@ uri$1.default = uri;
|
|
|
6318
6118
|
schemaType: (0, u.getJSONTypes)(v.schemaType)
|
|
6319
6119
|
}
|
|
6320
6120
|
};
|
|
6321
|
-
v.before ?
|
|
6121
|
+
v.before ? Te.call(this, N, M, v.before) : N.rules.push(M), h.all[F] = M, (P = v.implements) === null || P === void 0 || P.forEach((q) => this.addKeyword(q));
|
|
6322
6122
|
}
|
|
6323
|
-
function
|
|
6324
|
-
const
|
|
6325
|
-
|
|
6123
|
+
function Te(F, v, j) {
|
|
6124
|
+
const P = F.rules.findIndex((a) => a.keyword === j);
|
|
6125
|
+
P >= 0 ? F.rules.splice(P, 0, v) : (F.rules.push(v), this.logger.warn(`rule ${j} is not defined`));
|
|
6326
6126
|
}
|
|
6327
|
-
function
|
|
6127
|
+
function Ie(F) {
|
|
6328
6128
|
let { metaSchema: v } = F;
|
|
6329
|
-
v !== void 0 && (F.$data && this.opts.$data && (v =
|
|
6129
|
+
v !== void 0 && (F.$data && this.opts.$data && (v = je(v)), F.validateSchema = this.compile(v, !0));
|
|
6330
6130
|
}
|
|
6331
|
-
const
|
|
6131
|
+
const xe = {
|
|
6332
6132
|
$ref: "https://raw.githubusercontent.com/ajv-validator/ajv/master/lib/refs/data.json#"
|
|
6333
6133
|
};
|
|
6334
|
-
function
|
|
6335
|
-
return { anyOf: [F,
|
|
6134
|
+
function je(F) {
|
|
6135
|
+
return { anyOf: [F, xe] };
|
|
6336
6136
|
}
|
|
6337
6137
|
})(core$2);
|
|
6338
6138
|
var draft7 = {}, core$1 = {}, id = {};
|
|
@@ -6354,12 +6154,12 @@ const ref_error_1 = ref_error, code_1$8 = code, codegen_1$l = codegen, names_1$1
|
|
|
6354
6154
|
const { gen: t, schema: r, it: n } = e, { baseId: s, schemaEnv: i, validateName: o, opts: l, self: d } = n, { root: u } = i;
|
|
6355
6155
|
if ((r === "#" || r === "#/") && s === u.baseId)
|
|
6356
6156
|
return g();
|
|
6357
|
-
const
|
|
6358
|
-
if (
|
|
6157
|
+
const f = compile_1$1.resolveRef.call(d, u, s, r);
|
|
6158
|
+
if (f === void 0)
|
|
6359
6159
|
throw new ref_error_1.default(n.opts.uriResolver, s, r);
|
|
6360
|
-
if (
|
|
6361
|
-
return O(
|
|
6362
|
-
return C(
|
|
6160
|
+
if (f instanceof compile_1$1.SchemaEnv)
|
|
6161
|
+
return O(f);
|
|
6162
|
+
return C(f);
|
|
6363
6163
|
function g() {
|
|
6364
6164
|
if (i === u)
|
|
6365
6165
|
return callRef(e, o, i, i.$async);
|
|
@@ -6367,15 +6167,15 @@ const ref_error_1 = ref_error, code_1$8 = code, codegen_1$l = codegen, names_1$1
|
|
|
6367
6167
|
return callRef(e, (0, codegen_1$l._)`${S}.validate`, u, u.$async);
|
|
6368
6168
|
}
|
|
6369
6169
|
function O(S) {
|
|
6370
|
-
const
|
|
6371
|
-
callRef(e,
|
|
6170
|
+
const R = getValidate(e, S);
|
|
6171
|
+
callRef(e, R, S, S.$async);
|
|
6372
6172
|
}
|
|
6373
6173
|
function C(S) {
|
|
6374
|
-
const
|
|
6174
|
+
const R = t.scopeValue("schema", l.code.source === !0 ? { ref: S, code: (0, codegen_1$l.stringify)(S) } : { ref: S }), y = t.name("valid"), _ = e.subschema({
|
|
6375
6175
|
schema: S,
|
|
6376
6176
|
dataTypes: [],
|
|
6377
6177
|
schemaPath: codegen_1$l.nil,
|
|
6378
|
-
topSchemaRef:
|
|
6178
|
+
topSchemaRef: R,
|
|
6379
6179
|
errSchemaPath: r
|
|
6380
6180
|
}, y);
|
|
6381
6181
|
e.mergeEvaluated(_), e.ok(y);
|
|
@@ -6389,29 +6189,29 @@ function getValidate(e, t) {
|
|
|
6389
6189
|
ref.getValidate = getValidate;
|
|
6390
6190
|
function callRef(e, t, r, n) {
|
|
6391
6191
|
const { gen: s, it: i } = e, { allErrors: o, schemaEnv: l, opts: d } = i, u = d.passContext ? names_1$1.default.this : codegen_1$l.nil;
|
|
6392
|
-
n ?
|
|
6393
|
-
function
|
|
6192
|
+
n ? f() : g();
|
|
6193
|
+
function f() {
|
|
6394
6194
|
if (!l.$async)
|
|
6395
6195
|
throw new Error("async schema referenced by sync schema");
|
|
6396
6196
|
const S = s.let("valid");
|
|
6397
6197
|
s.try(() => {
|
|
6398
6198
|
s.code((0, codegen_1$l._)`await ${(0, code_1$8.callValidateCode)(e, t, u)}`), C(t), o || s.assign(S, !0);
|
|
6399
|
-
}, (
|
|
6400
|
-
s.if((0, codegen_1$l._)`!(${
|
|
6199
|
+
}, (R) => {
|
|
6200
|
+
s.if((0, codegen_1$l._)`!(${R} instanceof ${i.ValidationError})`, () => s.throw(R)), O(R), o || s.assign(S, !1);
|
|
6401
6201
|
}), e.ok(S);
|
|
6402
6202
|
}
|
|
6403
6203
|
function g() {
|
|
6404
6204
|
e.result((0, code_1$8.callValidateCode)(e, t, u), () => C(t), () => O(t));
|
|
6405
6205
|
}
|
|
6406
6206
|
function O(S) {
|
|
6407
|
-
const
|
|
6408
|
-
s.assign(names_1$1.default.vErrors, (0, codegen_1$l._)`${names_1$1.default.vErrors} === null ? ${
|
|
6207
|
+
const R = (0, codegen_1$l._)`${S}.errors`;
|
|
6208
|
+
s.assign(names_1$1.default.vErrors, (0, codegen_1$l._)`${names_1$1.default.vErrors} === null ? ${R} : ${names_1$1.default.vErrors}.concat(${R})`), s.assign(names_1$1.default.errors, (0, codegen_1$l._)`${names_1$1.default.vErrors}.length`);
|
|
6409
6209
|
}
|
|
6410
6210
|
function C(S) {
|
|
6411
|
-
var
|
|
6211
|
+
var R;
|
|
6412
6212
|
if (!i.opts.unevaluated)
|
|
6413
6213
|
return;
|
|
6414
|
-
const y = (
|
|
6214
|
+
const y = (R = r == null ? void 0 : r.validate) === null || R === void 0 ? void 0 : R.evaluated;
|
|
6415
6215
|
if (i.props !== !0)
|
|
6416
6216
|
if (y && !y.dynamicProps)
|
|
6417
6217
|
y.props !== void 0 && (i.props = util_1$j.mergeEvaluated.props(s, y.props, i.props));
|
|
@@ -6564,11 +6364,11 @@ const code_1$6 = code, codegen_1$f = codegen, util_1$h = util, error$d = {
|
|
|
6564
6364
|
if (!i && r.length === 0)
|
|
6565
6365
|
return;
|
|
6566
6366
|
const d = r.length >= l.loopRequired;
|
|
6567
|
-
if (o.allErrors ? u() :
|
|
6367
|
+
if (o.allErrors ? u() : f(), l.strictRequired) {
|
|
6568
6368
|
const C = e.parentSchema.properties, { definedProperties: S } = e.it;
|
|
6569
|
-
for (const
|
|
6570
|
-
if ((C == null ? void 0 : C[
|
|
6571
|
-
const y = o.schemaEnv.baseId + o.errSchemaPath, _ = `required property "${
|
|
6369
|
+
for (const R of r)
|
|
6370
|
+
if ((C == null ? void 0 : C[R]) === void 0 && !S.has(R)) {
|
|
6371
|
+
const y = o.schemaEnv.baseId + o.errSchemaPath, _ = `required property "${R}" is not defined at "${y}" (strictRequired)`;
|
|
6572
6372
|
(0, util_1$h.checkStrictMode)(o, _, o.opts.strictRequired);
|
|
6573
6373
|
}
|
|
6574
6374
|
}
|
|
@@ -6579,7 +6379,7 @@ const code_1$6 = code, codegen_1$f = codegen, util_1$h = util, error$d = {
|
|
|
6579
6379
|
for (const C of r)
|
|
6580
6380
|
(0, code_1$6.checkReportMissingProp)(e, C);
|
|
6581
6381
|
}
|
|
6582
|
-
function
|
|
6382
|
+
function f() {
|
|
6583
6383
|
const C = t.let("missing");
|
|
6584
6384
|
if (d || i) {
|
|
6585
6385
|
const S = t.let("valid", !0);
|
|
@@ -6642,25 +6442,25 @@ const dataType_1 = dataType, codegen_1$d = codegen, util_1$g = util, equal_1$2 =
|
|
|
6642
6442
|
if (!n && !s)
|
|
6643
6443
|
return;
|
|
6644
6444
|
const d = t.let("valid"), u = i.items ? (0, dataType_1.getSchemaTypes)(i.items) : [];
|
|
6645
|
-
e.block$data(d,
|
|
6646
|
-
function
|
|
6647
|
-
const S = t.let("i", (0, codegen_1$d._)`${r}.length`),
|
|
6648
|
-
e.setParams({ i: S, j:
|
|
6445
|
+
e.block$data(d, f, (0, codegen_1$d._)`${o} === false`), e.ok(d);
|
|
6446
|
+
function f() {
|
|
6447
|
+
const S = t.let("i", (0, codegen_1$d._)`${r}.length`), R = t.let("j");
|
|
6448
|
+
e.setParams({ i: S, j: R }), t.assign(d, !0), t.if((0, codegen_1$d._)`${S} > 1`, () => (g() ? O : C)(S, R));
|
|
6649
6449
|
}
|
|
6650
6450
|
function g() {
|
|
6651
6451
|
return u.length > 0 && !u.some((S) => S === "object" || S === "array");
|
|
6652
6452
|
}
|
|
6653
|
-
function O(S,
|
|
6453
|
+
function O(S, R) {
|
|
6654
6454
|
const y = t.name("item"), _ = (0, dataType_1.checkDataTypes)(u, y, l.opts.strictNumbers, dataType_1.DataType.Wrong), $ = t.const("indices", (0, codegen_1$d._)`{}`);
|
|
6655
6455
|
t.for((0, codegen_1$d._)`;${S}--;`, () => {
|
|
6656
6456
|
t.let(y, (0, codegen_1$d._)`${r}[${S}]`), t.if(_, (0, codegen_1$d._)`continue`), u.length > 1 && t.if((0, codegen_1$d._)`typeof ${y} == "string"`, (0, codegen_1$d._)`${y} += "_"`), t.if((0, codegen_1$d._)`typeof ${$}[${y}] == "number"`, () => {
|
|
6657
|
-
t.assign(
|
|
6457
|
+
t.assign(R, (0, codegen_1$d._)`${$}[${y}]`), e.error(), t.assign(d, !1).break();
|
|
6658
6458
|
}).code((0, codegen_1$d._)`${$}[${y}] = ${S}`);
|
|
6659
6459
|
});
|
|
6660
6460
|
}
|
|
6661
|
-
function C(S,
|
|
6461
|
+
function C(S, R) {
|
|
6662
6462
|
const y = (0, util_1$g.useFunc)(t, equal_1$2.default), _ = t.name("outer");
|
|
6663
|
-
t.label(_).for((0, codegen_1$d._)`;${S}--;`, () => t.for((0, codegen_1$d._)`${
|
|
6463
|
+
t.label(_).for((0, codegen_1$d._)`;${S}--;`, () => t.for((0, codegen_1$d._)`${R} = ${S}; ${R}--;`, () => t.if((0, codegen_1$d._)`${y}(${r}[${S}], ${r}[${R}])`, () => {
|
|
6664
6464
|
e.error(), t.assign(d, !1).break(_);
|
|
6665
6465
|
})));
|
|
6666
6466
|
}
|
|
@@ -6699,22 +6499,22 @@ const codegen_1$b = codegen, util_1$e = util, equal_1 = equal$1, error$9 = {
|
|
|
6699
6499
|
const l = s.length >= o.opts.loopEnum;
|
|
6700
6500
|
let d;
|
|
6701
6501
|
const u = () => d ?? (d = (0, util_1$e.useFunc)(t, equal_1.default));
|
|
6702
|
-
let
|
|
6502
|
+
let f;
|
|
6703
6503
|
if (l || n)
|
|
6704
|
-
|
|
6504
|
+
f = t.let("valid"), e.block$data(f, g);
|
|
6705
6505
|
else {
|
|
6706
6506
|
if (!Array.isArray(s))
|
|
6707
6507
|
throw new Error("ajv implementation error");
|
|
6708
6508
|
const C = t.const("vSchema", i);
|
|
6709
|
-
|
|
6509
|
+
f = (0, codegen_1$b.or)(...s.map((S, R) => O(C, R)));
|
|
6710
6510
|
}
|
|
6711
|
-
e.pass(
|
|
6511
|
+
e.pass(f);
|
|
6712
6512
|
function g() {
|
|
6713
|
-
t.assign(
|
|
6513
|
+
t.assign(f, !1), t.forOf("v", i, (C) => t.if((0, codegen_1$b._)`${u()}(${r}, ${C})`, () => t.assign(f, !0).break()));
|
|
6714
6514
|
}
|
|
6715
6515
|
function O(C, S) {
|
|
6716
|
-
const
|
|
6717
|
-
return typeof
|
|
6516
|
+
const R = s[S];
|
|
6517
|
+
return typeof R == "object" && R !== null ? (0, codegen_1$b._)`${u()}(${r}, ${C}[${S}])` : (0, codegen_1$b._)`${r} === ${R}`;
|
|
6718
6518
|
}
|
|
6719
6519
|
}
|
|
6720
6520
|
};
|
|
@@ -6772,8 +6572,8 @@ function validateAdditionalItems(e, t) {
|
|
|
6772
6572
|
r.if((0, codegen_1$a.not)(u), () => d(u)), e.ok(u);
|
|
6773
6573
|
}
|
|
6774
6574
|
function d(u) {
|
|
6775
|
-
r.forRange("i", t.length, l, (
|
|
6776
|
-
e.subschema({ keyword: i, dataProp:
|
|
6575
|
+
r.forRange("i", t.length, l, (f) => {
|
|
6576
|
+
e.subschema({ keyword: i, dataProp: f, dataPropType: util_1$d.Type.Num }, u), o.allErrors || r.if((0, codegen_1$a.not)(u), () => r.break());
|
|
6777
6577
|
});
|
|
6778
6578
|
}
|
|
6779
6579
|
}
|
|
@@ -6796,7 +6596,7 @@ const codegen_1$9 = codegen, util_1$c = util, code_1$5 = code, def$f = {
|
|
|
6796
6596
|
};
|
|
6797
6597
|
function validateTuple(e, t, r = e.schema) {
|
|
6798
6598
|
const { gen: n, parentSchema: s, data: i, keyword: o, it: l } = e;
|
|
6799
|
-
|
|
6599
|
+
f(s), l.opts.unevaluated && r.length && l.items !== !0 && (l.items = util_1$c.mergeEvaluated.items(n, r.length, l.items));
|
|
6800
6600
|
const d = n.name("valid"), u = n.const("len", (0, codegen_1$9._)`${i}.length`);
|
|
6801
6601
|
r.forEach((g, O) => {
|
|
6802
6602
|
(0, util_1$c.alwaysValidSchema)(l, g) || (n.if((0, codegen_1$9._)`${u} > ${O}`, () => e.subschema({
|
|
@@ -6805,9 +6605,9 @@ function validateTuple(e, t, r = e.schema) {
|
|
|
6805
6605
|
dataProp: O
|
|
6806
6606
|
}, d)), e.ok(d));
|
|
6807
6607
|
});
|
|
6808
|
-
function
|
|
6809
|
-
const { opts: O, errSchemaPath: C } = l, S = r.length,
|
|
6810
|
-
if (O.strictTuples && !
|
|
6608
|
+
function f(g) {
|
|
6609
|
+
const { opts: O, errSchemaPath: C } = l, S = r.length, R = S === g.minItems && (S === g.maxItems || g[t] === !1);
|
|
6610
|
+
if (O.strictTuples && !R) {
|
|
6811
6611
|
const y = `"${o}" is ${S}-tuple, but minItems or maxItems/${t} are not specified or different at path "${C}"`;
|
|
6812
6612
|
(0, util_1$c.checkStrictMode)(l, y, O.strictTuples);
|
|
6813
6613
|
}
|
|
@@ -6858,7 +6658,7 @@ const codegen_1$7 = codegen, util_1$a = util, error$6 = {
|
|
|
6858
6658
|
let o, l;
|
|
6859
6659
|
const { minContains: d, maxContains: u } = n;
|
|
6860
6660
|
i.opts.next ? (o = d === void 0 ? 1 : d, l = u) : o = 1;
|
|
6861
|
-
const
|
|
6661
|
+
const f = t.const("len", (0, codegen_1$7._)`${s}.length`);
|
|
6862
6662
|
if (e.setParams({ min: o, max: l }), l === void 0 && o === 0) {
|
|
6863
6663
|
(0, util_1$a.checkStrictMode)(i, '"minContains" == 0 without "maxContains": "contains" keyword ignored');
|
|
6864
6664
|
return;
|
|
@@ -6868,29 +6668,29 @@ const codegen_1$7 = codegen, util_1$a = util, error$6 = {
|
|
|
6868
6668
|
return;
|
|
6869
6669
|
}
|
|
6870
6670
|
if ((0, util_1$a.alwaysValidSchema)(i, r)) {
|
|
6871
|
-
let
|
|
6872
|
-
l !== void 0 && (
|
|
6671
|
+
let R = (0, codegen_1$7._)`${f} >= ${o}`;
|
|
6672
|
+
l !== void 0 && (R = (0, codegen_1$7._)`${R} && ${f} <= ${l}`), e.pass(R);
|
|
6873
6673
|
return;
|
|
6874
6674
|
}
|
|
6875
6675
|
i.items = !0;
|
|
6876
6676
|
const g = t.name("valid");
|
|
6877
6677
|
l === void 0 && o === 1 ? C(g, () => t.if(g, () => t.break())) : o === 0 ? (t.let(g, !0), l !== void 0 && t.if((0, codegen_1$7._)`${s}.length > 0`, O)) : (t.let(g, !1), O()), e.result(g, () => e.reset());
|
|
6878
6678
|
function O() {
|
|
6879
|
-
const
|
|
6880
|
-
C(
|
|
6679
|
+
const R = t.name("_valid"), y = t.let("count", 0);
|
|
6680
|
+
C(R, () => t.if(R, () => S(y)));
|
|
6881
6681
|
}
|
|
6882
|
-
function C(
|
|
6883
|
-
t.forRange("i", 0,
|
|
6682
|
+
function C(R, y) {
|
|
6683
|
+
t.forRange("i", 0, f, (_) => {
|
|
6884
6684
|
e.subschema({
|
|
6885
6685
|
keyword: "contains",
|
|
6886
6686
|
dataProp: _,
|
|
6887
6687
|
dataPropType: util_1$a.Type.Num,
|
|
6888
6688
|
compositeRule: !0
|
|
6889
|
-
},
|
|
6689
|
+
}, R), y();
|
|
6890
6690
|
});
|
|
6891
6691
|
}
|
|
6892
|
-
function S(
|
|
6893
|
-
t.code((0, codegen_1$7._)`${
|
|
6692
|
+
function S(R) {
|
|
6693
|
+
t.code((0, codegen_1$7._)`${R}++`), l === void 0 ? t.if((0, codegen_1$7._)`${R} >= ${o}`, () => t.assign(g, !0).break()) : (t.if((0, codegen_1$7._)`${R} > ${l}`, () => t.assign(g, !1).break()), o === 1 ? t.assign(g, !0) : t.if((0, codegen_1$7._)`${R} >= ${o}`, () => t.assign(g, !0)));
|
|
6894
6694
|
}
|
|
6895
6695
|
}
|
|
6896
6696
|
};
|
|
@@ -6900,14 +6700,14 @@ var dependencies = {};
|
|
|
6900
6700
|
Object.defineProperty(e, "__esModule", { value: !0 }), e.validateSchemaDeps = e.validatePropertyDeps = e.error = void 0;
|
|
6901
6701
|
const t = codegen, r = util, n = code;
|
|
6902
6702
|
e.error = {
|
|
6903
|
-
message: ({ params: { property: d, depsCount: u, deps:
|
|
6703
|
+
message: ({ params: { property: d, depsCount: u, deps: f } }) => {
|
|
6904
6704
|
const g = u === 1 ? "property" : "properties";
|
|
6905
|
-
return (0, t.str)`must have ${g} ${
|
|
6705
|
+
return (0, t.str)`must have ${g} ${f} when property ${d} is present`;
|
|
6906
6706
|
},
|
|
6907
|
-
params: ({ params: { property: d, depsCount: u, deps:
|
|
6707
|
+
params: ({ params: { property: d, depsCount: u, deps: f, missingProperty: g } }) => (0, t._)`{property: ${d},
|
|
6908
6708
|
missingProperty: ${g},
|
|
6909
6709
|
depsCount: ${u},
|
|
6910
|
-
deps: ${
|
|
6710
|
+
deps: ${f}}`
|
|
6911
6711
|
// TODO change to reference
|
|
6912
6712
|
};
|
|
6913
6713
|
const s = {
|
|
@@ -6916,51 +6716,51 @@ var dependencies = {};
|
|
|
6916
6716
|
schemaType: "object",
|
|
6917
6717
|
error: e.error,
|
|
6918
6718
|
code(d) {
|
|
6919
|
-
const [u,
|
|
6920
|
-
o(d, u), l(d,
|
|
6719
|
+
const [u, f] = i(d);
|
|
6720
|
+
o(d, u), l(d, f);
|
|
6921
6721
|
}
|
|
6922
6722
|
};
|
|
6923
6723
|
function i({ schema: d }) {
|
|
6924
|
-
const u = {},
|
|
6724
|
+
const u = {}, f = {};
|
|
6925
6725
|
for (const g in d) {
|
|
6926
6726
|
if (g === "__proto__")
|
|
6927
6727
|
continue;
|
|
6928
|
-
const O = Array.isArray(d[g]) ? u :
|
|
6728
|
+
const O = Array.isArray(d[g]) ? u : f;
|
|
6929
6729
|
O[g] = d[g];
|
|
6930
6730
|
}
|
|
6931
|
-
return [u,
|
|
6731
|
+
return [u, f];
|
|
6932
6732
|
}
|
|
6933
6733
|
function o(d, u = d.schema) {
|
|
6934
|
-
const { gen:
|
|
6734
|
+
const { gen: f, data: g, it: O } = d;
|
|
6935
6735
|
if (Object.keys(u).length === 0)
|
|
6936
6736
|
return;
|
|
6937
|
-
const C =
|
|
6737
|
+
const C = f.let("missing");
|
|
6938
6738
|
for (const S in u) {
|
|
6939
|
-
const
|
|
6940
|
-
if (
|
|
6739
|
+
const R = u[S];
|
|
6740
|
+
if (R.length === 0)
|
|
6941
6741
|
continue;
|
|
6942
|
-
const y = (0, n.propertyInData)(
|
|
6742
|
+
const y = (0, n.propertyInData)(f, g, S, O.opts.ownProperties);
|
|
6943
6743
|
d.setParams({
|
|
6944
6744
|
property: S,
|
|
6945
|
-
depsCount:
|
|
6946
|
-
deps:
|
|
6947
|
-
}), O.allErrors ?
|
|
6948
|
-
for (const _ of
|
|
6745
|
+
depsCount: R.length,
|
|
6746
|
+
deps: R.join(", ")
|
|
6747
|
+
}), O.allErrors ? f.if(y, () => {
|
|
6748
|
+
for (const _ of R)
|
|
6949
6749
|
(0, n.checkReportMissingProp)(d, _);
|
|
6950
|
-
}) : (
|
|
6750
|
+
}) : (f.if((0, t._)`${y} && (${(0, n.checkMissingProp)(d, R, C)})`), (0, n.reportMissingProp)(d, C), f.else());
|
|
6951
6751
|
}
|
|
6952
6752
|
}
|
|
6953
6753
|
e.validatePropertyDeps = o;
|
|
6954
6754
|
function l(d, u = d.schema) {
|
|
6955
|
-
const { gen:
|
|
6956
|
-
for (const
|
|
6957
|
-
(0, r.alwaysValidSchema)(C, u[
|
|
6958
|
-
(0, n.propertyInData)(
|
|
6755
|
+
const { gen: f, data: g, keyword: O, it: C } = d, S = f.name("valid");
|
|
6756
|
+
for (const R in u)
|
|
6757
|
+
(0, r.alwaysValidSchema)(C, u[R]) || (f.if(
|
|
6758
|
+
(0, n.propertyInData)(f, g, R, C.opts.ownProperties),
|
|
6959
6759
|
() => {
|
|
6960
|
-
const y = d.subschema({ keyword: O, schemaProp:
|
|
6760
|
+
const y = d.subschema({ keyword: O, schemaProp: R }, S);
|
|
6961
6761
|
d.mergeValidEvaluated(y, S);
|
|
6962
6762
|
},
|
|
6963
|
-
() =>
|
|
6763
|
+
() => f.var(S, !0)
|
|
6964
6764
|
// TODO var
|
|
6965
6765
|
), d.ok(S));
|
|
6966
6766
|
}
|
|
@@ -7014,11 +6814,11 @@ const code_1$3 = code, codegen_1$5 = codegen, names_1 = names$1, util_1$8 = util
|
|
|
7014
6814
|
const { allErrors: l, opts: d } = o;
|
|
7015
6815
|
if (o.props = !0, d.removeAdditional !== "all" && (0, util_1$8.alwaysValidSchema)(o, r))
|
|
7016
6816
|
return;
|
|
7017
|
-
const u = (0, code_1$3.allSchemaProperties)(n.properties),
|
|
6817
|
+
const u = (0, code_1$3.allSchemaProperties)(n.properties), f = (0, code_1$3.allSchemaProperties)(n.patternProperties);
|
|
7018
6818
|
g(), e.ok((0, codegen_1$5._)`${i} === ${names_1.default.errors}`);
|
|
7019
6819
|
function g() {
|
|
7020
6820
|
t.forIn("key", s, (y) => {
|
|
7021
|
-
!u.length && !
|
|
6821
|
+
!u.length && !f.length ? S(y) : t.if(O(y), () => S(y));
|
|
7022
6822
|
});
|
|
7023
6823
|
}
|
|
7024
6824
|
function O(y) {
|
|
@@ -7028,7 +6828,7 @@ const code_1$3 = code, codegen_1$5 = codegen, names_1 = names$1, util_1$8 = util
|
|
|
7028
6828
|
_ = (0, code_1$3.isOwnProperty)(t, $, y);
|
|
7029
6829
|
} else
|
|
7030
6830
|
u.length ? _ = (0, codegen_1$5.or)(...u.map(($) => (0, codegen_1$5._)`${y} === ${$}`)) : _ = codegen_1$5.nil;
|
|
7031
|
-
return
|
|
6831
|
+
return f.length && (_ = (0, codegen_1$5.or)(_, ...f.map(($) => (0, codegen_1$5._)`${(0, code_1$3.usePattern)(e, $)}.test(${y})`))), (0, codegen_1$5.not)(_);
|
|
7032
6832
|
}
|
|
7033
6833
|
function C(y) {
|
|
7034
6834
|
t.code((0, codegen_1$5._)`delete ${s}[${y}]`);
|
|
@@ -7044,22 +6844,22 @@ const code_1$3 = code, codegen_1$5 = codegen, names_1 = names$1, util_1$8 = util
|
|
|
7044
6844
|
}
|
|
7045
6845
|
if (typeof r == "object" && !(0, util_1$8.alwaysValidSchema)(o, r)) {
|
|
7046
6846
|
const _ = t.name("valid");
|
|
7047
|
-
d.removeAdditional === "failing" ? (
|
|
6847
|
+
d.removeAdditional === "failing" ? (R(y, _, !1), t.if((0, codegen_1$5.not)(_), () => {
|
|
7048
6848
|
e.reset(), C(y);
|
|
7049
|
-
})) : (
|
|
6849
|
+
})) : (R(y, _), l || t.if((0, codegen_1$5.not)(_), () => t.break()));
|
|
7050
6850
|
}
|
|
7051
6851
|
}
|
|
7052
|
-
function
|
|
7053
|
-
const
|
|
6852
|
+
function R(y, _, $) {
|
|
6853
|
+
const b = {
|
|
7054
6854
|
keyword: "additionalProperties",
|
|
7055
6855
|
dataProp: y,
|
|
7056
6856
|
dataPropType: util_1$8.Type.Str
|
|
7057
6857
|
};
|
|
7058
|
-
$ === !1 && Object.assign(
|
|
6858
|
+
$ === !1 && Object.assign(b, {
|
|
7059
6859
|
compositeRule: !0,
|
|
7060
6860
|
createErrors: !1,
|
|
7061
6861
|
allErrors: !1
|
|
7062
|
-
}), e.subschema(
|
|
6862
|
+
}), e.subschema(b, _);
|
|
7063
6863
|
}
|
|
7064
6864
|
}
|
|
7065
6865
|
};
|
|
@@ -7082,11 +6882,11 @@ const validate_1 = validate, code_1$2 = code, util_1$7 = util, additionalPropert
|
|
|
7082
6882
|
return;
|
|
7083
6883
|
const d = t.name("valid");
|
|
7084
6884
|
for (const g of l)
|
|
7085
|
-
u(g) ?
|
|
6885
|
+
u(g) ? f(g) : (t.if((0, code_1$2.propertyInData)(t, s, g, i.opts.ownProperties)), f(g), i.allErrors || t.else().var(d, !0), t.endIf()), e.it.definedProperties.add(g), e.ok(d);
|
|
7086
6886
|
function u(g) {
|
|
7087
6887
|
return i.opts.useDefaults && !i.compositeRule && r[g].default !== void 0;
|
|
7088
6888
|
}
|
|
7089
|
-
function
|
|
6889
|
+
function f(g) {
|
|
7090
6890
|
e.subschema({
|
|
7091
6891
|
keyword: "properties",
|
|
7092
6892
|
schemaProp: g,
|
|
@@ -7103,31 +6903,31 @@ const code_1$1 = code, codegen_1$4 = codegen, util_1$6 = util, util_2 = util, de
|
|
|
7103
6903
|
type: "object",
|
|
7104
6904
|
schemaType: "object",
|
|
7105
6905
|
code(e) {
|
|
7106
|
-
const { gen: t, schema: r, data: n, parentSchema: s, it: i } = e, { opts: o } = i, l = (0, code_1$1.allSchemaProperties)(r), d = l.filter((
|
|
6906
|
+
const { gen: t, schema: r, data: n, parentSchema: s, it: i } = e, { opts: o } = i, l = (0, code_1$1.allSchemaProperties)(r), d = l.filter((R) => (0, util_1$6.alwaysValidSchema)(i, r[R]));
|
|
7107
6907
|
if (l.length === 0 || d.length === l.length && (!i.opts.unevaluated || i.props === !0))
|
|
7108
6908
|
return;
|
|
7109
|
-
const u = o.strictSchema && !o.allowMatchingProperties && s.properties,
|
|
6909
|
+
const u = o.strictSchema && !o.allowMatchingProperties && s.properties, f = t.name("valid");
|
|
7110
6910
|
i.props !== !0 && !(i.props instanceof codegen_1$4.Name) && (i.props = (0, util_2.evaluatedPropsToName)(t, i.props));
|
|
7111
6911
|
const { props: g } = i;
|
|
7112
6912
|
O();
|
|
7113
6913
|
function O() {
|
|
7114
|
-
for (const
|
|
7115
|
-
u && C(
|
|
6914
|
+
for (const R of l)
|
|
6915
|
+
u && C(R), i.allErrors ? S(R) : (t.var(f, !0), S(R), t.if(f));
|
|
7116
6916
|
}
|
|
7117
|
-
function C(
|
|
6917
|
+
function C(R) {
|
|
7118
6918
|
for (const y in u)
|
|
7119
|
-
new RegExp(
|
|
6919
|
+
new RegExp(R).test(y) && (0, util_1$6.checkStrictMode)(i, `property ${y} matches pattern ${R} (use allowMatchingProperties)`);
|
|
7120
6920
|
}
|
|
7121
|
-
function S(
|
|
6921
|
+
function S(R) {
|
|
7122
6922
|
t.forIn("key", n, (y) => {
|
|
7123
|
-
t.if((0, codegen_1$4._)`${(0, code_1$1.usePattern)(e,
|
|
7124
|
-
const _ = d.includes(
|
|
6923
|
+
t.if((0, codegen_1$4._)`${(0, code_1$1.usePattern)(e, R)}.test(${y})`, () => {
|
|
6924
|
+
const _ = d.includes(R);
|
|
7125
6925
|
_ || e.subschema({
|
|
7126
6926
|
keyword: "patternProperties",
|
|
7127
|
-
schemaProp:
|
|
6927
|
+
schemaProp: R,
|
|
7128
6928
|
dataProp: y,
|
|
7129
6929
|
dataPropType: util_2.Type.Str
|
|
7130
|
-
},
|
|
6930
|
+
}, f), i.opts.unevaluated && g !== !0 ? t.assign((0, codegen_1$4._)`${g}[${y}]`, !0) : !_ && !i.allErrors && t.if((0, codegen_1$4.not)(f), () => t.break());
|
|
7131
6931
|
});
|
|
7132
6932
|
});
|
|
7133
6933
|
}
|
|
@@ -7186,9 +6986,9 @@ const codegen_1$3 = codegen, util_1$4 = util, error$3 = {
|
|
|
7186
6986
|
const i = r, o = t.let("valid", !1), l = t.let("passing", null), d = t.name("_valid");
|
|
7187
6987
|
e.setParams({ passing: l }), t.block(u), e.result(o, () => e.reset(), () => e.error(!0));
|
|
7188
6988
|
function u() {
|
|
7189
|
-
i.forEach((
|
|
6989
|
+
i.forEach((f, g) => {
|
|
7190
6990
|
let O;
|
|
7191
|
-
(0, util_1$4.alwaysValidSchema)(s,
|
|
6991
|
+
(0, util_1$4.alwaysValidSchema)(s, f) ? t.var(d, !0) : O = e.subschema({
|
|
7192
6992
|
keyword: "oneOf",
|
|
7193
6993
|
schemaProp: g,
|
|
7194
6994
|
compositeRule: !0
|
|
@@ -7237,24 +7037,24 @@ const codegen_1$2 = codegen, util_1$2 = util, error$2 = {
|
|
|
7237
7037
|
return;
|
|
7238
7038
|
const o = t.let("valid", !0), l = t.name("_valid");
|
|
7239
7039
|
if (d(), e.reset(), s && i) {
|
|
7240
|
-
const
|
|
7241
|
-
e.setParams({ ifClause:
|
|
7040
|
+
const f = t.let("ifClause");
|
|
7041
|
+
e.setParams({ ifClause: f }), t.if(l, u("then", f), u("else", f));
|
|
7242
7042
|
} else
|
|
7243
7043
|
s ? t.if(l, u("then")) : t.if((0, codegen_1$2.not)(l), u("else"));
|
|
7244
7044
|
e.pass(o, () => e.error(!0));
|
|
7245
7045
|
function d() {
|
|
7246
|
-
const
|
|
7046
|
+
const f = e.subschema({
|
|
7247
7047
|
keyword: "if",
|
|
7248
7048
|
compositeRule: !0,
|
|
7249
7049
|
createErrors: !1,
|
|
7250
7050
|
allErrors: !1
|
|
7251
7051
|
}, l);
|
|
7252
|
-
e.mergeEvaluated(
|
|
7052
|
+
e.mergeEvaluated(f);
|
|
7253
7053
|
}
|
|
7254
|
-
function u(
|
|
7054
|
+
function u(f, g) {
|
|
7255
7055
|
return () => {
|
|
7256
|
-
const O = e.subschema({ keyword:
|
|
7257
|
-
t.assign(o, l), e.mergeValidEvaluated(O, o), g ? t.assign(g, (0, codegen_1$2._)`${
|
|
7056
|
+
const O = e.subschema({ keyword: f }, l);
|
|
7057
|
+
t.assign(o, l), e.mergeValidEvaluated(O, o), g ? t.assign(g, (0, codegen_1$2._)`${f}`) : e.setParams({ ifClause: f });
|
|
7258
7058
|
};
|
|
7259
7059
|
}
|
|
7260
7060
|
}
|
|
@@ -7307,7 +7107,7 @@ const codegen_1$1 = codegen, error$1 = {
|
|
|
7307
7107
|
$data: !0,
|
|
7308
7108
|
error: error$1,
|
|
7309
7109
|
code(e, t) {
|
|
7310
|
-
const { gen: r, data: n, $data: s, schema: i, schemaCode: o, it: l } = e, { opts: d, errSchemaPath: u, schemaEnv:
|
|
7110
|
+
const { gen: r, data: n, $data: s, schema: i, schemaCode: o, it: l } = e, { opts: d, errSchemaPath: u, schemaEnv: f, self: g } = l;
|
|
7311
7111
|
if (!d.validateFormats)
|
|
7312
7112
|
return;
|
|
7313
7113
|
s ? O() : C();
|
|
@@ -7315,14 +7115,14 @@ const codegen_1$1 = codegen, error$1 = {
|
|
|
7315
7115
|
const S = r.scopeValue("formats", {
|
|
7316
7116
|
ref: g.formats,
|
|
7317
7117
|
code: d.code.formats
|
|
7318
|
-
}),
|
|
7319
|
-
r.if((0, codegen_1$1._)`typeof ${
|
|
7118
|
+
}), R = r.const("fDef", (0, codegen_1$1._)`${S}[${o}]`), y = r.let("fType"), _ = r.let("format");
|
|
7119
|
+
r.if((0, codegen_1$1._)`typeof ${R} == "object" && !(${R} instanceof RegExp)`, () => r.assign(y, (0, codegen_1$1._)`${R}.type || "string"`).assign(_, (0, codegen_1$1._)`${R}.validate`), () => r.assign(y, (0, codegen_1$1._)`"string"`).assign(_, R)), e.fail$data((0, codegen_1$1.or)($(), b()));
|
|
7320
7120
|
function $() {
|
|
7321
7121
|
return d.strictSchema === !1 ? codegen_1$1.nil : (0, codegen_1$1._)`${o} && !${_}`;
|
|
7322
7122
|
}
|
|
7323
|
-
function
|
|
7324
|
-
const I =
|
|
7325
|
-
return (0, codegen_1$1._)`${_} && ${_} !== true && ${y} === ${t} && !${
|
|
7123
|
+
function b() {
|
|
7124
|
+
const I = f.$async ? (0, codegen_1$1._)`(${R}.async ? await ${_}(${n}) : ${_}(${n}))` : (0, codegen_1$1._)`${_}(${n})`, A = (0, codegen_1$1._)`(typeof ${_} == "function" ? ${I} : ${_}.test(${n}))`;
|
|
7125
|
+
return (0, codegen_1$1._)`${_} && ${_} !== true && ${y} === ${t} && !${A}`;
|
|
7326
7126
|
}
|
|
7327
7127
|
}
|
|
7328
7128
|
function C() {
|
|
@@ -7333,25 +7133,25 @@ const codegen_1$1 = codegen, error$1 = {
|
|
|
7333
7133
|
}
|
|
7334
7134
|
if (S === !0)
|
|
7335
7135
|
return;
|
|
7336
|
-
const [
|
|
7337
|
-
|
|
7136
|
+
const [R, y, _] = b(S);
|
|
7137
|
+
R === t && e.pass(I());
|
|
7338
7138
|
function $() {
|
|
7339
7139
|
if (d.strictSchema === !1) {
|
|
7340
|
-
g.logger.warn(
|
|
7140
|
+
g.logger.warn(A());
|
|
7341
7141
|
return;
|
|
7342
7142
|
}
|
|
7343
|
-
throw new Error(
|
|
7344
|
-
function
|
|
7143
|
+
throw new Error(A());
|
|
7144
|
+
function A() {
|
|
7345
7145
|
return `unknown format "${i}" ignored in schema at path "${u}"`;
|
|
7346
7146
|
}
|
|
7347
7147
|
}
|
|
7348
|
-
function
|
|
7349
|
-
const w =
|
|
7350
|
-
return typeof
|
|
7148
|
+
function b(A) {
|
|
7149
|
+
const w = A instanceof RegExp ? (0, codegen_1$1.regexpCode)(A) : d.code.formats ? (0, codegen_1$1._)`${d.code.formats}${(0, codegen_1$1.getProperty)(i)}` : void 0, k = r.scopeValue("formats", { key: i, ref: A, code: w });
|
|
7150
|
+
return typeof A == "object" && !(A instanceof RegExp) ? [A.type || "string", A.validate, (0, codegen_1$1._)`${k}.validate`] : ["string", A, k];
|
|
7351
7151
|
}
|
|
7352
7152
|
function I() {
|
|
7353
7153
|
if (typeof S == "object" && !(S instanceof RegExp) && S.async) {
|
|
7354
|
-
if (!
|
|
7154
|
+
if (!f.$async)
|
|
7355
7155
|
throw new Error("async format in sync schema");
|
|
7356
7156
|
return (0, codegen_1$1._)`await ${_}(${n})`;
|
|
7357
7157
|
}
|
|
@@ -7418,8 +7218,8 @@ const codegen_1 = codegen, types_1 = types, compile_1 = compile, util_1 = util,
|
|
|
7418
7218
|
if (!o)
|
|
7419
7219
|
throw new Error("discriminator: requires oneOf keyword");
|
|
7420
7220
|
const d = t.let("valid", !1), u = t.const("tag", (0, codegen_1._)`${r}${(0, codegen_1.getProperty)(l)}`);
|
|
7421
|
-
t.if((0, codegen_1._)`typeof ${u} == "string"`, () =>
|
|
7422
|
-
function
|
|
7221
|
+
t.if((0, codegen_1._)`typeof ${u} == "string"`, () => f(), () => e.error(!1, { discrError: types_1.DiscrError.Tag, tag: u, tagName: l })), e.ok(d);
|
|
7222
|
+
function f() {
|
|
7423
7223
|
const C = O();
|
|
7424
7224
|
t.if(!1);
|
|
7425
7225
|
for (const S in C)
|
|
@@ -7427,20 +7227,20 @@ const codegen_1 = codegen, types_1 = types, compile_1 = compile, util_1 = util,
|
|
|
7427
7227
|
t.else(), e.error(!1, { discrError: types_1.DiscrError.Mapping, tag: u, tagName: l }), t.endIf();
|
|
7428
7228
|
}
|
|
7429
7229
|
function g(C) {
|
|
7430
|
-
const S = t.name("valid"),
|
|
7431
|
-
return e.mergeEvaluated(
|
|
7230
|
+
const S = t.name("valid"), R = e.subschema({ keyword: "oneOf", schemaProp: C }, S);
|
|
7231
|
+
return e.mergeEvaluated(R, codegen_1.Name), S;
|
|
7432
7232
|
}
|
|
7433
7233
|
function O() {
|
|
7434
7234
|
var C;
|
|
7435
|
-
const S = {},
|
|
7235
|
+
const S = {}, R = _(s);
|
|
7436
7236
|
let y = !0;
|
|
7437
7237
|
for (let I = 0; I < o.length; I++) {
|
|
7438
|
-
let
|
|
7439
|
-
|
|
7440
|
-
const w = (C =
|
|
7238
|
+
let A = o[I];
|
|
7239
|
+
A != null && A.$ref && !(0, util_1.schemaHasRulesButRef)(A, i.self.RULES) && (A = compile_1.resolveRef.call(i.self, i.schemaEnv.root, i.baseId, A == null ? void 0 : A.$ref), A instanceof compile_1.SchemaEnv && (A = A.schema));
|
|
7240
|
+
const w = (C = A == null ? void 0 : A.properties) === null || C === void 0 ? void 0 : C[l];
|
|
7441
7241
|
if (typeof w != "object")
|
|
7442
7242
|
throw new Error(`discriminator: oneOf subschemas (or referenced schemas) must have "properties/${l}"`);
|
|
7443
|
-
y = y && (
|
|
7243
|
+
y = y && (R || _(A)), $(w, I);
|
|
7444
7244
|
}
|
|
7445
7245
|
if (!y)
|
|
7446
7246
|
throw new Error(`discriminator: "${l}" must be required`);
|
|
@@ -7448,19 +7248,19 @@ const codegen_1 = codegen, types_1 = types, compile_1 = compile, util_1 = util,
|
|
|
7448
7248
|
function _({ required: I }) {
|
|
7449
7249
|
return Array.isArray(I) && I.includes(l);
|
|
7450
7250
|
}
|
|
7451
|
-
function $(I,
|
|
7251
|
+
function $(I, A) {
|
|
7452
7252
|
if (I.const)
|
|
7453
|
-
|
|
7253
|
+
b(I.const, A);
|
|
7454
7254
|
else if (I.enum)
|
|
7455
7255
|
for (const w of I.enum)
|
|
7456
|
-
|
|
7256
|
+
b(w, A);
|
|
7457
7257
|
else
|
|
7458
7258
|
throw new Error(`discriminator: "properties/${l}" must have "const" or "enum"`);
|
|
7459
7259
|
}
|
|
7460
|
-
function
|
|
7260
|
+
function b(I, A) {
|
|
7461
7261
|
if (typeof I != "string" || I in S)
|
|
7462
7262
|
throw new Error(`discriminator: "${l}" values must be unique strings`);
|
|
7463
|
-
S[I] =
|
|
7263
|
+
S[I] = A;
|
|
7464
7264
|
}
|
|
7465
7265
|
}
|
|
7466
7266
|
}
|
|
@@ -7729,19 +7529,19 @@ const $schema$1 = "http://json-schema.org/draft-07/schema#", $id = "http://json-
|
|
|
7729
7529
|
Object.defineProperty(t, "KeywordCxt", { enumerable: !0, get: function() {
|
|
7730
7530
|
return u.KeywordCxt;
|
|
7731
7531
|
} });
|
|
7732
|
-
var
|
|
7532
|
+
var f = codegen;
|
|
7733
7533
|
Object.defineProperty(t, "_", { enumerable: !0, get: function() {
|
|
7734
|
-
return
|
|
7534
|
+
return f._;
|
|
7735
7535
|
} }), Object.defineProperty(t, "str", { enumerable: !0, get: function() {
|
|
7736
|
-
return
|
|
7536
|
+
return f.str;
|
|
7737
7537
|
} }), Object.defineProperty(t, "stringify", { enumerable: !0, get: function() {
|
|
7738
|
-
return
|
|
7538
|
+
return f.stringify;
|
|
7739
7539
|
} }), Object.defineProperty(t, "nil", { enumerable: !0, get: function() {
|
|
7740
|
-
return
|
|
7540
|
+
return f.nil;
|
|
7741
7541
|
} }), Object.defineProperty(t, "Name", { enumerable: !0, get: function() {
|
|
7742
|
-
return
|
|
7542
|
+
return f.Name;
|
|
7743
7543
|
} }), Object.defineProperty(t, "CodeGen", { enumerable: !0, get: function() {
|
|
7744
|
-
return
|
|
7544
|
+
return f.CodeGen;
|
|
7745
7545
|
} });
|
|
7746
7546
|
var g = validation_error;
|
|
7747
7547
|
Object.defineProperty(t, "ValidationError", { enumerable: !0, get: function() {
|
|
@@ -9351,13 +9151,13 @@ function compileBlueprint(e, {
|
|
|
9351
9151
|
onStepCompleted: n = () => {
|
|
9352
9152
|
}
|
|
9353
9153
|
} = {}) {
|
|
9354
|
-
var g, O, C, S,
|
|
9154
|
+
var g, O, C, S, R, y, _;
|
|
9355
9155
|
e = {
|
|
9356
9156
|
...e,
|
|
9357
9157
|
steps: (e.steps || []).filter(isStepDefinition).filter(isStepStillSupported)
|
|
9358
9158
|
};
|
|
9359
9159
|
for (const $ of e.steps)
|
|
9360
|
-
typeof $ == "object" && $.step === "importFile" && ($.step = "importWxr",
|
|
9160
|
+
typeof $ == "object" && $.step === "importFile" && ($.step = "importWxr", logger.warn(
|
|
9361
9161
|
'The "importFile" step is deprecated. Use "importWxr" instead.'
|
|
9362
9162
|
));
|
|
9363
9163
|
if (e.constants && e.steps.unshift({
|
|
@@ -9367,15 +9167,15 @@ function compileBlueprint(e, {
|
|
|
9367
9167
|
step: "setSiteOptions",
|
|
9368
9168
|
options: e.siteOptions
|
|
9369
9169
|
}), e.plugins) {
|
|
9370
|
-
const $ = e.plugins.map((
|
|
9170
|
+
const $ = e.plugins.map((b) => typeof b == "string" ? b.startsWith("https://") ? {
|
|
9371
9171
|
resource: "url",
|
|
9372
|
-
url:
|
|
9172
|
+
url: b
|
|
9373
9173
|
} : {
|
|
9374
9174
|
resource: "wordpress.org/plugins",
|
|
9375
|
-
slug:
|
|
9376
|
-
} :
|
|
9175
|
+
slug: b
|
|
9176
|
+
} : b).map((b) => ({
|
|
9377
9177
|
step: "installPlugin",
|
|
9378
|
-
pluginZipFile:
|
|
9178
|
+
pluginZipFile: b
|
|
9379
9179
|
}));
|
|
9380
9180
|
e.steps.unshift(...$);
|
|
9381
9181
|
}
|
|
@@ -9388,7 +9188,7 @@ function compileBlueprint(e, {
|
|
|
9388
9188
|
);
|
|
9389
9189
|
s !== void 0 && s > -1 && (e.phpExtensionBundles.includes("light") && (e.phpExtensionBundles = e.phpExtensionBundles.filter(
|
|
9390
9190
|
($) => $ !== "light"
|
|
9391
|
-
),
|
|
9191
|
+
), logger.warn(
|
|
9392
9192
|
"The wpCli step used in your Blueprint requires the iconv and mbstring PHP extensions. However, you did not specify the kitchen-sink extension bundle. Playground will override your choice and load the kitchen-sink PHP extensions bundle to prevent the WP-CLI step from failing. "
|
|
9393
9193
|
)), (O = e.steps) == null || O.splice(s, 0, {
|
|
9394
9194
|
step: "writeFile",
|
|
@@ -9413,7 +9213,7 @@ function compileBlueprint(e, {
|
|
|
9413
9213
|
);
|
|
9414
9214
|
i !== void 0 && i > -1 && (e.phpExtensionBundles.includes("light") && (e.phpExtensionBundles = e.phpExtensionBundles.filter(
|
|
9415
9215
|
($) => $ !== "light"
|
|
9416
|
-
),
|
|
9216
|
+
), logger.warn(
|
|
9417
9217
|
"The importWxr step used in your Blueprint requires the iconv and mbstring PHP extensions. However, you did not specify the kitchen-sink extension bundle. Playground will override your choice and load the kitchen-sink PHP extensions bundle to prevent the WP-CLI step from failing. "
|
|
9418
9218
|
)), (S = e.steps) == null || S.splice(i, 0, {
|
|
9419
9219
|
step: "installPlugin",
|
|
@@ -9431,12 +9231,12 @@ function compileBlueprint(e, {
|
|
|
9431
9231
|
throw $.errors = l, $;
|
|
9432
9232
|
}
|
|
9433
9233
|
const d = e.steps || [], u = d.reduce(
|
|
9434
|
-
($,
|
|
9234
|
+
($, b) => {
|
|
9435
9235
|
var I;
|
|
9436
|
-
return $ + (((I =
|
|
9236
|
+
return $ + (((I = b.progress) == null ? void 0 : I.weight) || 1);
|
|
9437
9237
|
},
|
|
9438
9238
|
0
|
|
9439
|
-
),
|
|
9239
|
+
), f = d.map(
|
|
9440
9240
|
($) => compileStep($, {
|
|
9441
9241
|
semaphore: r,
|
|
9442
9242
|
rootProgressTracker: t,
|
|
@@ -9446,7 +9246,7 @@ function compileBlueprint(e, {
|
|
|
9446
9246
|
return {
|
|
9447
9247
|
versions: {
|
|
9448
9248
|
php: compileVersion(
|
|
9449
|
-
(
|
|
9249
|
+
(R = e.preferredVersions) == null ? void 0 : R.php,
|
|
9450
9250
|
SupportedPHPVersions,
|
|
9451
9251
|
LatestSupportedPHPVersion
|
|
9452
9252
|
),
|
|
@@ -9462,17 +9262,17 @@ function compileBlueprint(e, {
|
|
|
9462
9262
|
},
|
|
9463
9263
|
run: async ($) => {
|
|
9464
9264
|
try {
|
|
9465
|
-
for (const { resources:
|
|
9466
|
-
for (const I of
|
|
9265
|
+
for (const { resources: b } of f)
|
|
9266
|
+
for (const I of b)
|
|
9467
9267
|
I.setPlayground($), I.isAsync && I.resolve();
|
|
9468
|
-
for (const [
|
|
9268
|
+
for (const [b, { run: I, step: A }] of Object.entries(f))
|
|
9469
9269
|
try {
|
|
9470
9270
|
const w = await I($);
|
|
9471
|
-
n(w,
|
|
9271
|
+
n(w, A);
|
|
9472
9272
|
} catch (w) {
|
|
9473
|
-
throw
|
|
9474
|
-
`Error when executing the blueprint step #${
|
|
9475
|
-
|
|
9273
|
+
throw logger.error(w), new Error(
|
|
9274
|
+
`Error when executing the blueprint step #${b} (${JSON.stringify(
|
|
9275
|
+
A
|
|
9476
9276
|
)}) ${w instanceof Error ? `: ${w.message}` : w}`,
|
|
9477
9277
|
{ cause: w }
|
|
9478
9278
|
);
|
|
@@ -9523,7 +9323,7 @@ function isStepDefinition(e) {
|
|
|
9523
9323
|
return !!(typeof e == "object" && e);
|
|
9524
9324
|
}
|
|
9525
9325
|
function isStepStillSupported(e) {
|
|
9526
|
-
return e.step === "setPhpIniEntry" ? (
|
|
9326
|
+
return e.step === "setPhpIniEntry" ? (logger.warn(
|
|
9527
9327
|
'The "setPhpIniEntry" Blueprint is no longer supported and you can remove it from your Blueprint.'
|
|
9528
9328
|
), !1) : !0;
|
|
9529
9329
|
}
|
|
@@ -9532,9 +9332,9 @@ function compileStep(e, {
|
|
|
9532
9332
|
rootProgressTracker: r,
|
|
9533
9333
|
totalProgressWeight: n
|
|
9534
9334
|
}) {
|
|
9535
|
-
var
|
|
9335
|
+
var f;
|
|
9536
9336
|
const s = r.stage(
|
|
9537
|
-
(((
|
|
9337
|
+
(((f = e.progress) == null ? void 0 : f.weight) || 1) / n
|
|
9538
9338
|
), i = {};
|
|
9539
9339
|
for (const g of Object.keys(e)) {
|
|
9540
9340
|
let O = e[g];
|