vercel 54.20.1 → 54.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/chunks/{add-IB7HE5S5.js → add-KZSG7SVG.js} +4 -4
  2. package/dist/chunks/{add-TF5VZLCY.js → add-UDJ45UVF.js} +5 -5
  3. package/dist/chunks/{chunk-YWLVPKNT.js → chunk-6SVPJXCO.js} +1 -1
  4. package/dist/chunks/{chunk-FVI6UYNL.js → chunk-6W7I5IOO.js} +1 -1
  5. package/dist/chunks/{chunk-JHQOIGTY.js → chunk-BEETD7P4.js} +3 -3
  6. package/dist/chunks/{chunk-JDO6BSKN.js → chunk-BLWPQEED.js} +4 -4
  7. package/dist/chunks/{chunk-7PAKWBN4.js → chunk-DBA4N3OZ.js} +2 -2
  8. package/dist/chunks/{chunk-IZOHLD5D.js → chunk-DDS5Z2MB.js} +53 -4
  9. package/dist/chunks/{chunk-3S2QGKYZ.js → chunk-DJ4JEVDI.js} +1 -1
  10. package/dist/chunks/{chunk-FZZWTDNQ.js → chunk-FCYCUCLI.js} +2 -2
  11. package/dist/chunks/{chunk-U3FBUYRS.js → chunk-HAZXLIKZ.js} +1 -1
  12. package/dist/chunks/{chunk-RB7WQKNC.js → chunk-IR674PKY.js} +5 -2
  13. package/dist/chunks/{chunk-5MVXR7B7.js → chunk-JAUGUJR3.js} +1 -1
  14. package/dist/chunks/{chunk-Q7GZMMHB.js → chunk-JIX2UI23.js} +3 -3
  15. package/dist/chunks/{chunk-ITU4COOO.js → chunk-KGPSD6TA.js} +9 -44
  16. package/dist/chunks/{chunk-T63I6OUR.js → chunk-KS5FONWU.js} +4 -4
  17. package/dist/chunks/{chunk-P726GMBL.js → chunk-LVR7QUSG.js} +1 -1
  18. package/dist/chunks/{chunk-O2QNLUYX.js → chunk-S2N7BLSM.js} +1 -1
  19. package/dist/chunks/{chunk-4BEUS7AL.js → chunk-SCQAJO6E.js} +88 -2
  20. package/dist/chunks/{chunk-Q4A2Q46Z.js → chunk-TYXSXFVM.js} +4 -4
  21. package/dist/chunks/{chunk-6ISLGUMI.js → chunk-UDIFOPZL.js} +4 -4
  22. package/dist/chunks/{chunk-TV7GKFSY.js → chunk-VDTSYCXY.js} +2 -2
  23. package/dist/chunks/{chunk-GDAO4PGA.js → chunk-VFXF4O4X.js} +3 -3
  24. package/dist/chunks/{compile-vercel-config-XEZ2TPQ4.js → compile-vercel-config-DY63NSZV.js} +2 -2
  25. package/dist/chunks/{delete-O3F4EP2W.js → delete-WVLC7FLA.js} +3 -3
  26. package/dist/chunks/{disable-SJWGUQKZ.js → disable-VLYKCAM5.js} +3 -3
  27. package/dist/chunks/{discard-EQD6ENC3.js → discard-GGNJLKTH.js} +3 -3
  28. package/dist/chunks/{edit-NAIWNSXE.js → edit-ZU5K7DM3.js} +4 -4
  29. package/dist/chunks/{enable-LXO62HU5.js → enable-G3MUGP3W.js} +3 -3
  30. package/dist/chunks/{export-EHVTYAAP.js → export-QHSB2FON.js} +3 -3
  31. package/dist/chunks/{image-2DL7JEWW.js → image-CWHCW3N5.js} +4 -4
  32. package/dist/chunks/{inspect-PL3PE5IJ.js → inspect-HFCKYQQ3.js} +4 -4
  33. package/dist/chunks/{inspect-EGXHWKY3.js → inspect-OVAC6PJK.js} +4 -4
  34. package/dist/chunks/{inspect-Z3QJOMNP.js → inspect-QJSREPM3.js} +4 -4
  35. package/dist/chunks/{inspect-6IHZTLFA.js → inspect-W6RHYESL.js} +4 -4
  36. package/dist/chunks/{list-KNRPDNQF.js → list-2XYQW3YA.js} +4 -4
  37. package/dist/chunks/{list-BB4T4KT5.js → list-R37YS5CX.js} +3 -3
  38. package/dist/chunks/{ls-EP4Q6VF4.js → ls-7JNUKRV2.js} +4 -4
  39. package/dist/chunks/{ls-IQKMDRUB.js → ls-HKVAT223.js} +4 -4
  40. package/dist/chunks/{ls-MUS72LBS.js → ls-JJXUYZU7.js} +4 -4
  41. package/dist/chunks/{ls-FTQGK4R6.js → ls-X7Y37IPT.js} +5 -5
  42. package/dist/chunks/{publish-27V2MMFS.js → publish-MYVZ4UTW.js} +3 -3
  43. package/dist/chunks/{query-C6FEOG5R.js → query-ZH2YJPAC.js} +3 -3
  44. package/dist/chunks/{reorder-DCSIJX72.js → reorder-VY53EYZJ.js} +3 -3
  45. package/dist/chunks/{restore-NRUBGNSK.js → restore-F2AEG3WO.js} +3 -3
  46. package/dist/chunks/{rm-EZFCCZFT.js → rm-IDSOMXQR.js} +4 -4
  47. package/dist/chunks/{rm-NMSG2WG6.js → rm-T6Z6WZZN.js} +4 -4
  48. package/dist/chunks/{rm-GWW57H2V.js → rm-VUL4FHMX.js} +5 -5
  49. package/dist/chunks/{rule-inspect-XPZJO3Y4.js → rule-inspect-ELB7P5YA.js} +5 -5
  50. package/dist/chunks/{rules-C6SB24UO.js → rules-XR6U5U7F.js} +7 -7
  51. package/dist/chunks/{schema-Z6L3EN6F.js → schema-WKPB25ZF.js} +3 -3
  52. package/dist/chunks/{tags-5PFVWGLK.js → tags-NSWTVGHE.js} +3 -3
  53. package/dist/chunks/{update-BCLMLJM7.js → update-H4Q24DK4.js} +5 -5
  54. package/dist/commands/build/index.js +3268 -220
  55. package/dist/commands/deploy/index.js +11 -11
  56. package/dist/commands/dev/index.js +9 -9
  57. package/dist/commands/env/index.js +5 -5
  58. package/dist/commands/link/index.js +8 -8
  59. package/dist/commands/list/index.js +10 -4
  60. package/dist/commands-bulk.js +564 -68
  61. package/dist/index.js +9 -9
  62. package/dist/version.mjs +1 -1
  63. package/package.json +20 -18
@@ -11,36 +11,36 @@ import {
11
11
  isLambda,
12
12
  staticFiles,
13
13
  writeBuildResult
14
- } from "../../chunks/chunk-ITU4COOO.js";
14
+ } from "../../chunks/chunk-KGPSD6TA.js";
15
15
  import {
16
16
  pullCommandLogic
17
- } from "../../chunks/chunk-Q4A2Q46Z.js";
17
+ } from "../../chunks/chunk-TYXSXFVM.js";
18
18
  import {
19
19
  require_semver
20
20
  } from "../../chunks/chunk-IB5L4LKZ.js";
21
21
  import {
22
22
  pickOverrides,
23
23
  readProjectSettings
24
- } from "../../chunks/chunk-5MVXR7B7.js";
24
+ } from "../../chunks/chunk-JAUGUJR3.js";
25
25
  import "../../chunks/chunk-24FCBXI4.js";
26
26
  import "../../chunks/chunk-NJUPUGOE.js";
27
27
  import {
28
28
  stamp_default
29
29
  } from "../../chunks/chunk-64IF634X.js";
30
30
  import "../../chunks/chunk-VXYGCOKL.js";
31
- import "../../chunks/chunk-Q7GZMMHB.js";
31
+ import "../../chunks/chunk-JIX2UI23.js";
32
32
  import {
33
33
  printProjectNotFoundError
34
- } from "../../chunks/chunk-6ISLGUMI.js";
34
+ } from "../../chunks/chunk-UDIFOPZL.js";
35
35
  import {
36
36
  AGENT_REASON,
37
37
  AGENT_STATUS
38
38
  } from "../../chunks/chunk-QH7WYDEP.js";
39
- import "../../chunks/chunk-YWLVPKNT.js";
39
+ import "../../chunks/chunk-6SVPJXCO.js";
40
40
  import {
41
41
  buildCommand
42
- } from "../../chunks/chunk-O2QNLUYX.js";
43
- import "../../chunks/chunk-P726GMBL.js";
42
+ } from "../../chunks/chunk-S2N7BLSM.js";
43
+ import "../../chunks/chunk-LVR7QUSG.js";
44
44
  import {
45
45
  help
46
46
  } from "../../chunks/chunk-YSIZGIDP.js";
@@ -50,7 +50,6 @@ import {
50
50
  VERCEL_DIR,
51
51
  compileVercelConfig,
52
52
  findSourceVercelConfigFile,
53
- getGitRootDirectory,
54
53
  getLinkedProject,
55
54
  getProjectLink,
56
55
  parseTarget,
@@ -67,10 +66,10 @@ import {
67
66
  resolveProjectCwd,
68
67
  ua_default,
69
68
  validateConfig
70
- } from "../../chunks/chunk-RB7WQKNC.js";
69
+ } from "../../chunks/chunk-IR674PKY.js";
71
70
  import {
72
71
  outputAgentError
73
- } from "../../chunks/chunk-IZOHLD5D.js";
72
+ } from "../../chunks/chunk-DDS5Z2MB.js";
74
73
  import {
75
74
  TelemetryClient
76
75
  } from "../../chunks/chunk-ECCWJHC6.js";
@@ -109,14 +108,14 @@ import {
109
108
  // src/commands/build/index.ts
110
109
  var import_chalk = __toESM(require_source(), 1);
111
110
  var import_dotenv = __toESM(require_main(), 1);
112
- var import_fs_extra2 = __toESM(require_lib(), 1);
113
- var import_minimatch = __toESM(require_minimatch(), 1);
111
+ var import_fs_extra3 = __toESM(require_lib(), 1);
112
+ var import_minimatch2 = __toESM(require_minimatch(), 1);
114
113
  var import_semver = __toESM(require_semver(), 1);
115
114
  var import_client = __toESM(require_dist(), 1);
116
- var import_frameworks2 = __toESM(require_frameworks(), 1);
117
- var import_fs_detectors2 = __toESM(require_dist3(), 1);
115
+ var import_frameworks3 = __toESM(require_frameworks(), 1);
116
+ var import_fs_detectors3 = __toESM(require_dist3(), 1);
118
117
  var import_routing_utils2 = __toESM(require_dist2(), 1);
119
- import { dirname as dirname2, join as join4, normalize, relative as relative3, resolve, sep } from "path";
118
+ import { dirname as dirname2, join as join5, normalize, relative as relative3, resolve, sep } from "path";
120
119
  import { readdirSync, statSync } from "fs";
121
120
  import {
122
121
  download,
@@ -255,6 +254,250 @@ async function setMonorepoDefaultSettings(cwd, workPath, projectSettings) {
255
254
  }
256
255
  }
257
256
 
257
+ // src/util/build/framework-detection.ts
258
+ var import_fs_detectors2 = __toESM(require_dist3(), 1);
259
+ var import_frameworks = __toESM(require_frameworks(), 1);
260
+ import { debug as builderDebug } from "@vercel/build-utils";
261
+ function logDebug(message) {
262
+ output_manager_default.debug(message);
263
+ builderDebug(message);
264
+ }
265
+ function isFrameworkDetectionEnabled() {
266
+ const raw = process.env.VERCEL_FRAMEWORK_DETECTION;
267
+ const enabled = raw === "1";
268
+ logDebug(
269
+ `Framework detection: VERCEL_FRAMEWORK_DETECTION=${raw === void 0 ? "<unset>" : JSON.stringify(raw)} -> ${enabled ? "enabled" : "disabled"}`
270
+ );
271
+ return enabled;
272
+ }
273
+ function isFirstDeployment() {
274
+ const raw = process.env.VERCEL_FIRST_DEPLOYMENT;
275
+ const result = raw === "1";
276
+ logDebug(
277
+ `isFirstDeployment: VERCEL_FIRST_DEPLOYMENT=${raw === void 0 ? "<unset>" : JSON.stringify(raw)} -> ${result}`
278
+ );
279
+ return result;
280
+ }
281
+ async function detectFirstDeploymentFramework(options) {
282
+ const { workPath, projectSettings } = options;
283
+ if (!isFrameworkDetectionEnabled()) {
284
+ return { status: "skipped" };
285
+ }
286
+ logDebug(
287
+ `First deployment: evaluating framework detection (workPath="${workPath}", configuredFramework=${projectSettings.framework ? `"${projectSettings.framework}"` : "<none>"})`
288
+ );
289
+ if (!isFirstDeployment()) {
290
+ logDebug(
291
+ "First deployment: skipping framework detection because this is not a first deployment"
292
+ );
293
+ return { status: "skipped" };
294
+ }
295
+ if (projectSettings.framework) {
296
+ logDebug(
297
+ `First deployment: skipping framework detection because a framework is already configured ("${projectSettings.framework}")`
298
+ );
299
+ return { status: "skipped" };
300
+ }
301
+ logDebug(
302
+ `First deployment: no framework configured; detecting from source at "${workPath}"`
303
+ );
304
+ const detected = await (0, import_fs_detectors2.detectFrameworkRecord)({
305
+ fs: new import_fs_detectors2.LocalFileSystemDetector(workPath),
306
+ frameworkList: import_frameworks.frameworkList
307
+ });
308
+ if (!detected || !detected.slug) {
309
+ logDebug("First deployment: no framework detected from source code");
310
+ return { status: "not-detected" };
311
+ }
312
+ const { slug } = detected;
313
+ projectSettings.framework = slug;
314
+ logDebug(
315
+ `First deployment: detected framework "${slug}"${detected.detectedVersion ? ` (version ${detected.detectedVersion})` : ""}; applied to project settings for this build`
316
+ );
317
+ return {
318
+ status: "detected",
319
+ slug,
320
+ ...detected.detectedVersion && { version: detected.detectedVersion }
321
+ };
322
+ }
323
+ async function detectAllFrameworks(workPath) {
324
+ logDebug(`Framework cross-check: detecting frameworks at "${workPath}"`);
325
+ const frameworks = await (0, import_fs_detectors2.detectFrameworks)({
326
+ fs: new import_fs_detectors2.LocalFileSystemDetector(workPath),
327
+ frameworkList: import_frameworks.frameworkList
328
+ });
329
+ const slugs = frameworks.map((f) => f.slug).filter((slug) => Boolean(slug));
330
+ logDebug(`Framework cross-check: detected [${slugs.join(", ") || "<none>"}]`);
331
+ return slugs;
332
+ }
333
+ function isHighConfidenceDetection(slug) {
334
+ const record = import_frameworks.frameworkList.find((f) => f.slug === slug);
335
+ return record?.detectionConfidence !== "weak";
336
+ }
337
+ function warnIfFrameworkMismatch(options) {
338
+ const {
339
+ configuredFramework,
340
+ detectedFrameworks,
341
+ usedBuilders = [],
342
+ usedFrameworks = []
343
+ } = options;
344
+ if (detectedFrameworks.length === 0) {
345
+ logDebug(
346
+ "Framework cross-check: nothing detected from source; skipping validation"
347
+ );
348
+ return "none-detected";
349
+ }
350
+ const confidentFrameworks = detectedFrameworks.filter(
351
+ isHighConfidenceDetection
352
+ );
353
+ if (configuredFramework) {
354
+ if (detectedFrameworks.includes(configuredFramework)) {
355
+ logDebug(
356
+ `Framework cross-check: configured framework "${configuredFramework}" matches detected frameworks; no mismatch`
357
+ );
358
+ return "match";
359
+ }
360
+ if (confidentFrameworks.length === 0) {
361
+ logDebug(
362
+ `Framework cross-check: configured framework "${configuredFramework}" not among detected [${detectedFrameworks.join(
363
+ ", "
364
+ )}], but all detections are low-confidence; skipping warning`
365
+ );
366
+ return "low-confidence";
367
+ }
368
+ logDebug(
369
+ `Framework cross-check: configured framework "${configuredFramework}" not among detected [${confidentFrameworks.join(
370
+ ", "
371
+ )}]; warning`
372
+ );
373
+ output_manager_default.warn(
374
+ `Your project is configured to use the "${configuredFramework}" framework, but the source code looks like it's for: ${confidentFrameworks.join(
375
+ ", "
376
+ )}. This may be a misconfiguration.`,
377
+ null,
378
+ "https://vercel.com/docs/project-configuration",
379
+ "Learn More"
380
+ );
381
+ return "configured-mismatch";
382
+ }
383
+ const buildUsedDetectedFramework = detectedFrameworks.some((slug) => {
384
+ if (usedFrameworks.includes(slug)) {
385
+ return true;
386
+ }
387
+ const record = import_frameworks.frameworkList.find((f) => f.slug === slug);
388
+ const expectedBuilder = record?.useRuntime?.use;
389
+ if (!expectedBuilder) {
390
+ return false;
391
+ }
392
+ return usedBuilders.some(
393
+ (use) => use === expectedBuilder || use.startsWith(`${expectedBuilder}@`)
394
+ );
395
+ });
396
+ if (buildUsedDetectedFramework) {
397
+ logDebug(
398
+ `Framework cross-check: no framework configured, but the build used one of the detected frameworks [${detectedFrameworks.join(
399
+ ", "
400
+ )}]; no mismatch`
401
+ );
402
+ return "match";
403
+ }
404
+ const warnableFrameworks = confidentFrameworks.filter((slug) => {
405
+ const record = import_frameworks.frameworkList.find((f) => f.slug === slug);
406
+ return Boolean(record?.useRuntime?.use);
407
+ });
408
+ if (warnableFrameworks.length === 0) {
409
+ logDebug(
410
+ `Framework cross-check: no framework configured and detections [${detectedFrameworks.join(
411
+ ", "
412
+ )}] are low-confidence or have no dedicated runtime builder; skipping warning`
413
+ );
414
+ return "low-confidence";
415
+ }
416
+ logDebug(
417
+ `Framework cross-check: no framework configured and the build did not use any of the detected frameworks [${warnableFrameworks.join(
418
+ ", "
419
+ )}] (used builders: [${usedBuilders.join(", ") || "<none>"}]); warning`
420
+ );
421
+ output_manager_default.warn(
422
+ `The source code looks like it's for: ${warnableFrameworks.join(
423
+ ", "
424
+ )}, but no framework is configured for this project and the build did not use ${warnableFrameworks.length === 1 ? "its builder" : "their builders"}. Set the framework in your Project Settings if this is unexpected.`,
425
+ null,
426
+ "https://vercel.com/docs/project-configuration",
427
+ "Learn More"
428
+ );
429
+ return "unused-mismatch";
430
+ }
431
+
432
+ // src/util/build/validate-build-output.ts
433
+ var import_fs_extra2 = __toESM(require_lib(), 1);
434
+ import { join as join2 } from "path";
435
+ import { debug as builderDebug2 } from "@vercel/build-utils";
436
+ function logDebug2(message) {
437
+ output_manager_default.debug(message);
438
+ builderDebug2(message);
439
+ }
440
+ async function validateBuildOutput(outputDir) {
441
+ const problems = [];
442
+ logDebug2(`Validating build output at "${outputDir}"`);
443
+ try {
444
+ const configPath = join2(outputDir, "config.json");
445
+ const configExists = await import_fs_extra2.default.pathExists(configPath);
446
+ if (!configExists) {
447
+ problems.push({
448
+ severity: "error",
449
+ message: "Build output is missing config.json."
450
+ });
451
+ } else {
452
+ let config;
453
+ try {
454
+ config = await import_fs_extra2.default.readJSON(configPath);
455
+ } catch (err) {
456
+ problems.push({
457
+ severity: "error",
458
+ message: `Build output config.json is not valid JSON: ${err instanceof Error ? err.message : String(err)}.`
459
+ });
460
+ }
461
+ if (config && config.version !== 3) {
462
+ problems.push({
463
+ severity: "warning",
464
+ message: `Build output config.json has unexpected version "${config.version}" (expected 3).`
465
+ });
466
+ }
467
+ }
468
+ const [hasFunctions, hasStatic] = await Promise.all([
469
+ import_fs_extra2.default.pathExists(join2(outputDir, "functions")),
470
+ import_fs_extra2.default.pathExists(join2(outputDir, "static"))
471
+ ]);
472
+ if (!hasFunctions && !hasStatic) {
473
+ problems.push({
474
+ severity: "warning",
475
+ message: 'Build output contains no "functions" or "static" directory; the build may not have produced any deployable output.'
476
+ });
477
+ }
478
+ logDebug2(
479
+ `Build output validation found ${problems.length} problem(s)` + (problems.length ? `: ${problems.map((p) => `${p.severity}: ${p.message}`).join("; ")}` : "")
480
+ );
481
+ return problems;
482
+ } catch (err) {
483
+ return [
484
+ {
485
+ severity: "error",
486
+ message: `Unexpected error while validating build output: ${err instanceof Error ? err.message : String(err)}.`
487
+ }
488
+ ];
489
+ }
490
+ }
491
+ function reportBuildOutputProblems(problems) {
492
+ for (const problem of problems) {
493
+ if (problem.severity === "error") {
494
+ output_manager_default.error(problem.message);
495
+ } else {
496
+ output_manager_default.warn(problem.message);
497
+ }
498
+ }
499
+ }
500
+
258
501
  // src/util/build/scrub-argv.ts
259
502
  function scrubArgv(argv) {
260
503
  const clonedArgv = [...argv];
@@ -307,179 +550,2868 @@ function scopeRoutesToServiceOwnership({
307
550
  };
308
551
  });
309
552
  }
310
-
311
- // src/util/build/sort-builders.ts
312
- var import_frameworks = __toESM(require_frameworks(), 1);
313
- function sortBuilders(builds) {
314
- const frontendRuntimeSet = new Set(
315
- import_frameworks.frameworkList.map((f) => f.useRuntime?.use || "@vercel/static-build")
553
+
554
+ // src/util/build/sort-builders.ts
555
+ var import_frameworks2 = __toESM(require_frameworks(), 1);
556
+ function sortBuilders(builds) {
557
+ const frontendRuntimeSet = new Set(
558
+ import_frameworks2.frameworkList.map((f) => f.useRuntime?.use || "@vercel/static-build")
559
+ );
560
+ frontendRuntimeSet.delete("@vercel/python");
561
+ frontendRuntimeSet.delete("@vercel/ruby");
562
+ frontendRuntimeSet.delete("@vercel/rust");
563
+ const toNumber = (build) => build.use === "@vercel/python" || build.use === "@vercel/ruby" || build.use === "@vercel/rust" ? 1 : frontendRuntimeSet.has(build.use) ? 0 : 2;
564
+ return builds.sort((build1, build2) => {
565
+ return toNumber(build1) - toNumber(build2);
566
+ });
567
+ }
568
+
569
+ // src/util/telemetry/commands/build/index.ts
570
+ var BuildTelemetryClient = class extends TelemetryClient {
571
+ trackCliOptionOutput(path) {
572
+ if (path) {
573
+ this.trackCliOption({
574
+ option: "output",
575
+ value: this.redactedValue
576
+ });
577
+ }
578
+ }
579
+ trackCliOptionTarget(option) {
580
+ if (option) {
581
+ this.trackCliOption({
582
+ option: "target",
583
+ value: this.redactedTargetName(option)
584
+ });
585
+ }
586
+ }
587
+ trackCliFlagProd(flag) {
588
+ if (flag) {
589
+ this.trackCliFlag("prod");
590
+ }
591
+ }
592
+ trackCliFlagYes(flag) {
593
+ if (flag) {
594
+ this.trackCliFlag("yes");
595
+ }
596
+ }
597
+ trackCliFlagStandalone(flag) {
598
+ if (flag) {
599
+ this.trackCliFlag("standalone");
600
+ }
601
+ }
602
+ trackCliOptionId(id) {
603
+ if (id) {
604
+ this.trackCliOption({
605
+ option: "id",
606
+ value: this.redactedValue
607
+ });
608
+ }
609
+ }
610
+ };
611
+
612
+ // src/util/validate-cron-secret.ts
613
+ import { NowBuildError } from "@vercel/build-utils";
614
+ function validateCronSecret(cronSecret) {
615
+ if (!cronSecret) {
616
+ return null;
617
+ }
618
+ if (cronSecret !== cronSecret.trim()) {
619
+ return new NowBuildError({
620
+ code: "INVALID_CRON_SECRET",
621
+ message: "The `CRON_SECRET` environment variable contains leading or trailing whitespace, which is not allowed in HTTP header values.",
622
+ link: "https://vercel.link/securing-cron-jobs",
623
+ action: "Learn More"
624
+ });
625
+ }
626
+ const invalidChars = [];
627
+ for (let i = 0; i < cronSecret.length; i++) {
628
+ const code = cronSecret.charCodeAt(i);
629
+ const isValidChar = code === 9 || // HTAB
630
+ code >= 32 && code <= 126;
631
+ if (!isValidChar) {
632
+ invalidChars.push({
633
+ char: cronSecret[i],
634
+ index: i,
635
+ code
636
+ });
637
+ }
638
+ }
639
+ if (invalidChars.length > 0) {
640
+ const descriptions = invalidChars.slice(0, 3).map(({ code, index }) => {
641
+ if (code < 32) {
642
+ return `control character (0x${code.toString(16).padStart(2, "0")}) at position ${index}`;
643
+ } else if (code === 127) {
644
+ return `DEL character at position ${index}`;
645
+ } else {
646
+ return `non-ASCII character (0x${code.toString(16).padStart(2, "0")}) at position ${index}`;
647
+ }
648
+ });
649
+ const moreCount = invalidChars.length - 3;
650
+ const moreText = moreCount > 0 ? `, and ${moreCount} more` : "";
651
+ return new NowBuildError({
652
+ code: "INVALID_CRON_SECRET",
653
+ message: `The \`CRON_SECRET\` environment variable contains characters that are not valid in HTTP headers: ${descriptions.join(", ")}${moreText}. Only visible ASCII characters (letters, digits, symbols), spaces, and tabs are allowed.`,
654
+ link: "https://vercel.link/securing-cron-jobs",
655
+ action: "Learn More"
656
+ });
657
+ }
658
+ return null;
659
+ }
660
+
661
+ // src/util/validate-package-manifest.ts
662
+ var import_ajv = __toESM(require_ajv(), 1);
663
+ import { packageManifestSchema } from "@vercel/build-utils";
664
+ var ajv = new import_ajv.default();
665
+ var validate = ajv.compile(packageManifestSchema);
666
+ function validatePackageManifest(data) {
667
+ if (validate(data)) {
668
+ return null;
669
+ }
670
+ const errors = validate.errors ?? [];
671
+ return errors.map((e) => `${e.dataPath || "(root)"} ${e.message}`).join("; ");
672
+ }
673
+
674
+ // src/util/flags/build-embedding.ts
675
+ import { isPackageInstalled } from "@vercel/build-utils";
676
+ function isFlagsEmbedOption(input) {
677
+ return input === "force-on" || input === "force-off";
678
+ }
679
+ var SDK_KEY_REGEX = /^vf_(?:server|client)_/;
680
+ function envHasSdkKey() {
681
+ for (const value of Object.values(process.env)) {
682
+ if (typeof value === "string" && SDK_KEY_REGEX.test(value)) {
683
+ return true;
684
+ }
685
+ }
686
+ }
687
+ async function shouldEmbedFlagsDefinitions(cwd) {
688
+ if (process.env.VERCEL_FLAGS_DISABLE_DEFINITION_EMBEDDING === "1") {
689
+ return false;
690
+ }
691
+ if (isFlagsEmbedOption(process.env.VERCEL_FLAGS_EMBED_DEFINITIONS)) {
692
+ return process.env.VERCEL_FLAGS_EMBED_DEFINITIONS === "force-on";
693
+ }
694
+ if (envHasSdkKey()) {
695
+ return true;
696
+ }
697
+ const hasVercelFlags = await isPackageInstalled("@flags-sdk/vercel", cwd);
698
+ const hasFlagsCore = await isPackageInstalled("@vercel/flags-core", cwd);
699
+ if (hasVercelFlags || hasFlagsCore) {
700
+ return true;
701
+ }
702
+ return false;
703
+ }
704
+
705
+ // src/util/build/repo-root.ts
706
+ import { existsSync, readFileSync } from "fs";
707
+ import { dirname, join as join3, parse, relative as relative2 } from "path";
708
+
709
+ // ../../node_modules/.pnpm/js-yaml@4.1.0/node_modules/js-yaml/dist/js-yaml.mjs
710
+ function isNothing(subject) {
711
+ return typeof subject === "undefined" || subject === null;
712
+ }
713
+ function isObject(subject) {
714
+ return typeof subject === "object" && subject !== null;
715
+ }
716
+ function toArray(sequence) {
717
+ if (Array.isArray(sequence))
718
+ return sequence;
719
+ else if (isNothing(sequence))
720
+ return [];
721
+ return [sequence];
722
+ }
723
+ function extend(target, source) {
724
+ var index, length, key, sourceKeys;
725
+ if (source) {
726
+ sourceKeys = Object.keys(source);
727
+ for (index = 0, length = sourceKeys.length; index < length; index += 1) {
728
+ key = sourceKeys[index];
729
+ target[key] = source[key];
730
+ }
731
+ }
732
+ return target;
733
+ }
734
+ function repeat(string, count) {
735
+ var result = "", cycle;
736
+ for (cycle = 0; cycle < count; cycle += 1) {
737
+ result += string;
738
+ }
739
+ return result;
740
+ }
741
+ function isNegativeZero(number) {
742
+ return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
743
+ }
744
+ var isNothing_1 = isNothing;
745
+ var isObject_1 = isObject;
746
+ var toArray_1 = toArray;
747
+ var repeat_1 = repeat;
748
+ var isNegativeZero_1 = isNegativeZero;
749
+ var extend_1 = extend;
750
+ var common = {
751
+ isNothing: isNothing_1,
752
+ isObject: isObject_1,
753
+ toArray: toArray_1,
754
+ repeat: repeat_1,
755
+ isNegativeZero: isNegativeZero_1,
756
+ extend: extend_1
757
+ };
758
+ function formatError(exception2, compact) {
759
+ var where = "", message = exception2.reason || "(unknown reason)";
760
+ if (!exception2.mark)
761
+ return message;
762
+ if (exception2.mark.name) {
763
+ where += 'in "' + exception2.mark.name + '" ';
764
+ }
765
+ where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")";
766
+ if (!compact && exception2.mark.snippet) {
767
+ where += "\n\n" + exception2.mark.snippet;
768
+ }
769
+ return message + " " + where;
770
+ }
771
+ function YAMLException$1(reason, mark) {
772
+ Error.call(this);
773
+ this.name = "YAMLException";
774
+ this.reason = reason;
775
+ this.mark = mark;
776
+ this.message = formatError(this, false);
777
+ if (Error.captureStackTrace) {
778
+ Error.captureStackTrace(this, this.constructor);
779
+ } else {
780
+ this.stack = new Error().stack || "";
781
+ }
782
+ }
783
+ YAMLException$1.prototype = Object.create(Error.prototype);
784
+ YAMLException$1.prototype.constructor = YAMLException$1;
785
+ YAMLException$1.prototype.toString = function toString(compact) {
786
+ return this.name + ": " + formatError(this, compact);
787
+ };
788
+ var exception = YAMLException$1;
789
+ function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
790
+ var head = "";
791
+ var tail = "";
792
+ var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
793
+ if (position - lineStart > maxHalfLength) {
794
+ head = " ... ";
795
+ lineStart = position - maxHalfLength + head.length;
796
+ }
797
+ if (lineEnd - position > maxHalfLength) {
798
+ tail = " ...";
799
+ lineEnd = position + maxHalfLength - tail.length;
800
+ }
801
+ return {
802
+ str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "\u2192") + tail,
803
+ pos: position - lineStart + head.length
804
+ // relative position
805
+ };
806
+ }
807
+ function padStart(string, max) {
808
+ return common.repeat(" ", max - string.length) + string;
809
+ }
810
+ function makeSnippet(mark, options) {
811
+ options = Object.create(options || null);
812
+ if (!mark.buffer)
813
+ return null;
814
+ if (!options.maxLength)
815
+ options.maxLength = 79;
816
+ if (typeof options.indent !== "number")
817
+ options.indent = 1;
818
+ if (typeof options.linesBefore !== "number")
819
+ options.linesBefore = 3;
820
+ if (typeof options.linesAfter !== "number")
821
+ options.linesAfter = 2;
822
+ var re = /\r?\n|\r|\0/g;
823
+ var lineStarts = [0];
824
+ var lineEnds = [];
825
+ var match;
826
+ var foundLineNo = -1;
827
+ while (match = re.exec(mark.buffer)) {
828
+ lineEnds.push(match.index);
829
+ lineStarts.push(match.index + match[0].length);
830
+ if (mark.position <= match.index && foundLineNo < 0) {
831
+ foundLineNo = lineStarts.length - 2;
832
+ }
833
+ }
834
+ if (foundLineNo < 0)
835
+ foundLineNo = lineStarts.length - 1;
836
+ var result = "", i, line;
837
+ var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
838
+ var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
839
+ for (i = 1; i <= options.linesBefore; i++) {
840
+ if (foundLineNo - i < 0)
841
+ break;
842
+ line = getLine(
843
+ mark.buffer,
844
+ lineStarts[foundLineNo - i],
845
+ lineEnds[foundLineNo - i],
846
+ mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),
847
+ maxLineLength
848
+ );
849
+ result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
850
+ }
851
+ line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
852
+ result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
853
+ result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
854
+ for (i = 1; i <= options.linesAfter; i++) {
855
+ if (foundLineNo + i >= lineEnds.length)
856
+ break;
857
+ line = getLine(
858
+ mark.buffer,
859
+ lineStarts[foundLineNo + i],
860
+ lineEnds[foundLineNo + i],
861
+ mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),
862
+ maxLineLength
863
+ );
864
+ result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n";
865
+ }
866
+ return result.replace(/\n$/, "");
867
+ }
868
+ var snippet = makeSnippet;
869
+ var TYPE_CONSTRUCTOR_OPTIONS = [
870
+ "kind",
871
+ "multi",
872
+ "resolve",
873
+ "construct",
874
+ "instanceOf",
875
+ "predicate",
876
+ "represent",
877
+ "representName",
878
+ "defaultStyle",
879
+ "styleAliases"
880
+ ];
881
+ var YAML_NODE_KINDS = [
882
+ "scalar",
883
+ "sequence",
884
+ "mapping"
885
+ ];
886
+ function compileStyleAliases(map2) {
887
+ var result = {};
888
+ if (map2 !== null) {
889
+ Object.keys(map2).forEach(function(style) {
890
+ map2[style].forEach(function(alias) {
891
+ result[String(alias)] = style;
892
+ });
893
+ });
894
+ }
895
+ return result;
896
+ }
897
+ function Type$1(tag, options) {
898
+ options = options || {};
899
+ Object.keys(options).forEach(function(name) {
900
+ if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
901
+ throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
902
+ }
903
+ });
904
+ this.options = options;
905
+ this.tag = tag;
906
+ this.kind = options["kind"] || null;
907
+ this.resolve = options["resolve"] || function() {
908
+ return true;
909
+ };
910
+ this.construct = options["construct"] || function(data) {
911
+ return data;
912
+ };
913
+ this.instanceOf = options["instanceOf"] || null;
914
+ this.predicate = options["predicate"] || null;
915
+ this.represent = options["represent"] || null;
916
+ this.representName = options["representName"] || null;
917
+ this.defaultStyle = options["defaultStyle"] || null;
918
+ this.multi = options["multi"] || false;
919
+ this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
920
+ if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
921
+ throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
922
+ }
923
+ }
924
+ var type = Type$1;
925
+ function compileList(schema2, name) {
926
+ var result = [];
927
+ schema2[name].forEach(function(currentType) {
928
+ var newIndex = result.length;
929
+ result.forEach(function(previousType, previousIndex) {
930
+ if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
931
+ newIndex = previousIndex;
932
+ }
933
+ });
934
+ result[newIndex] = currentType;
935
+ });
936
+ return result;
937
+ }
938
+ function compileMap() {
939
+ var result = {
940
+ scalar: {},
941
+ sequence: {},
942
+ mapping: {},
943
+ fallback: {},
944
+ multi: {
945
+ scalar: [],
946
+ sequence: [],
947
+ mapping: [],
948
+ fallback: []
949
+ }
950
+ }, index, length;
951
+ function collectType(type2) {
952
+ if (type2.multi) {
953
+ result.multi[type2.kind].push(type2);
954
+ result.multi["fallback"].push(type2);
955
+ } else {
956
+ result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
957
+ }
958
+ }
959
+ for (index = 0, length = arguments.length; index < length; index += 1) {
960
+ arguments[index].forEach(collectType);
961
+ }
962
+ return result;
963
+ }
964
+ function Schema$1(definition) {
965
+ return this.extend(definition);
966
+ }
967
+ Schema$1.prototype.extend = function extend2(definition) {
968
+ var implicit = [];
969
+ var explicit = [];
970
+ if (definition instanceof type) {
971
+ explicit.push(definition);
972
+ } else if (Array.isArray(definition)) {
973
+ explicit = explicit.concat(definition);
974
+ } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
975
+ if (definition.implicit)
976
+ implicit = implicit.concat(definition.implicit);
977
+ if (definition.explicit)
978
+ explicit = explicit.concat(definition.explicit);
979
+ } else {
980
+ throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
981
+ }
982
+ implicit.forEach(function(type$1) {
983
+ if (!(type$1 instanceof type)) {
984
+ throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
985
+ }
986
+ if (type$1.loadKind && type$1.loadKind !== "scalar") {
987
+ throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
988
+ }
989
+ if (type$1.multi) {
990
+ throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
991
+ }
992
+ });
993
+ explicit.forEach(function(type$1) {
994
+ if (!(type$1 instanceof type)) {
995
+ throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
996
+ }
997
+ });
998
+ var result = Object.create(Schema$1.prototype);
999
+ result.implicit = (this.implicit || []).concat(implicit);
1000
+ result.explicit = (this.explicit || []).concat(explicit);
1001
+ result.compiledImplicit = compileList(result, "implicit");
1002
+ result.compiledExplicit = compileList(result, "explicit");
1003
+ result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
1004
+ return result;
1005
+ };
1006
+ var schema = Schema$1;
1007
+ var str = new type("tag:yaml.org,2002:str", {
1008
+ kind: "scalar",
1009
+ construct: function(data) {
1010
+ return data !== null ? data : "";
1011
+ }
1012
+ });
1013
+ var seq = new type("tag:yaml.org,2002:seq", {
1014
+ kind: "sequence",
1015
+ construct: function(data) {
1016
+ return data !== null ? data : [];
1017
+ }
1018
+ });
1019
+ var map = new type("tag:yaml.org,2002:map", {
1020
+ kind: "mapping",
1021
+ construct: function(data) {
1022
+ return data !== null ? data : {};
1023
+ }
1024
+ });
1025
+ var failsafe = new schema({
1026
+ explicit: [
1027
+ str,
1028
+ seq,
1029
+ map
1030
+ ]
1031
+ });
1032
+ function resolveYamlNull(data) {
1033
+ if (data === null)
1034
+ return true;
1035
+ var max = data.length;
1036
+ return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
1037
+ }
1038
+ function constructYamlNull() {
1039
+ return null;
1040
+ }
1041
+ function isNull(object) {
1042
+ return object === null;
1043
+ }
1044
+ var _null = new type("tag:yaml.org,2002:null", {
1045
+ kind: "scalar",
1046
+ resolve: resolveYamlNull,
1047
+ construct: constructYamlNull,
1048
+ predicate: isNull,
1049
+ represent: {
1050
+ canonical: function() {
1051
+ return "~";
1052
+ },
1053
+ lowercase: function() {
1054
+ return "null";
1055
+ },
1056
+ uppercase: function() {
1057
+ return "NULL";
1058
+ },
1059
+ camelcase: function() {
1060
+ return "Null";
1061
+ },
1062
+ empty: function() {
1063
+ return "";
1064
+ }
1065
+ },
1066
+ defaultStyle: "lowercase"
1067
+ });
1068
+ function resolveYamlBoolean(data) {
1069
+ if (data === null)
1070
+ return false;
1071
+ var max = data.length;
1072
+ return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
1073
+ }
1074
+ function constructYamlBoolean(data) {
1075
+ return data === "true" || data === "True" || data === "TRUE";
1076
+ }
1077
+ function isBoolean(object) {
1078
+ return Object.prototype.toString.call(object) === "[object Boolean]";
1079
+ }
1080
+ var bool = new type("tag:yaml.org,2002:bool", {
1081
+ kind: "scalar",
1082
+ resolve: resolveYamlBoolean,
1083
+ construct: constructYamlBoolean,
1084
+ predicate: isBoolean,
1085
+ represent: {
1086
+ lowercase: function(object) {
1087
+ return object ? "true" : "false";
1088
+ },
1089
+ uppercase: function(object) {
1090
+ return object ? "TRUE" : "FALSE";
1091
+ },
1092
+ camelcase: function(object) {
1093
+ return object ? "True" : "False";
1094
+ }
1095
+ },
1096
+ defaultStyle: "lowercase"
1097
+ });
1098
+ function isHexCode(c) {
1099
+ return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
1100
+ }
1101
+ function isOctCode(c) {
1102
+ return 48 <= c && c <= 55;
1103
+ }
1104
+ function isDecCode(c) {
1105
+ return 48 <= c && c <= 57;
1106
+ }
1107
+ function resolveYamlInteger(data) {
1108
+ if (data === null)
1109
+ return false;
1110
+ var max = data.length, index = 0, hasDigits = false, ch;
1111
+ if (!max)
1112
+ return false;
1113
+ ch = data[index];
1114
+ if (ch === "-" || ch === "+") {
1115
+ ch = data[++index];
1116
+ }
1117
+ if (ch === "0") {
1118
+ if (index + 1 === max)
1119
+ return true;
1120
+ ch = data[++index];
1121
+ if (ch === "b") {
1122
+ index++;
1123
+ for (; index < max; index++) {
1124
+ ch = data[index];
1125
+ if (ch === "_")
1126
+ continue;
1127
+ if (ch !== "0" && ch !== "1")
1128
+ return false;
1129
+ hasDigits = true;
1130
+ }
1131
+ return hasDigits && ch !== "_";
1132
+ }
1133
+ if (ch === "x") {
1134
+ index++;
1135
+ for (; index < max; index++) {
1136
+ ch = data[index];
1137
+ if (ch === "_")
1138
+ continue;
1139
+ if (!isHexCode(data.charCodeAt(index)))
1140
+ return false;
1141
+ hasDigits = true;
1142
+ }
1143
+ return hasDigits && ch !== "_";
1144
+ }
1145
+ if (ch === "o") {
1146
+ index++;
1147
+ for (; index < max; index++) {
1148
+ ch = data[index];
1149
+ if (ch === "_")
1150
+ continue;
1151
+ if (!isOctCode(data.charCodeAt(index)))
1152
+ return false;
1153
+ hasDigits = true;
1154
+ }
1155
+ return hasDigits && ch !== "_";
1156
+ }
1157
+ }
1158
+ if (ch === "_")
1159
+ return false;
1160
+ for (; index < max; index++) {
1161
+ ch = data[index];
1162
+ if (ch === "_")
1163
+ continue;
1164
+ if (!isDecCode(data.charCodeAt(index))) {
1165
+ return false;
1166
+ }
1167
+ hasDigits = true;
1168
+ }
1169
+ if (!hasDigits || ch === "_")
1170
+ return false;
1171
+ return true;
1172
+ }
1173
+ function constructYamlInteger(data) {
1174
+ var value = data, sign = 1, ch;
1175
+ if (value.indexOf("_") !== -1) {
1176
+ value = value.replace(/_/g, "");
1177
+ }
1178
+ ch = value[0];
1179
+ if (ch === "-" || ch === "+") {
1180
+ if (ch === "-")
1181
+ sign = -1;
1182
+ value = value.slice(1);
1183
+ ch = value[0];
1184
+ }
1185
+ if (value === "0")
1186
+ return 0;
1187
+ if (ch === "0") {
1188
+ if (value[1] === "b")
1189
+ return sign * parseInt(value.slice(2), 2);
1190
+ if (value[1] === "x")
1191
+ return sign * parseInt(value.slice(2), 16);
1192
+ if (value[1] === "o")
1193
+ return sign * parseInt(value.slice(2), 8);
1194
+ }
1195
+ return sign * parseInt(value, 10);
1196
+ }
1197
+ function isInteger(object) {
1198
+ return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
1199
+ }
1200
+ var int = new type("tag:yaml.org,2002:int", {
1201
+ kind: "scalar",
1202
+ resolve: resolveYamlInteger,
1203
+ construct: constructYamlInteger,
1204
+ predicate: isInteger,
1205
+ represent: {
1206
+ binary: function(obj) {
1207
+ return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
1208
+ },
1209
+ octal: function(obj) {
1210
+ return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
1211
+ },
1212
+ decimal: function(obj) {
1213
+ return obj.toString(10);
1214
+ },
1215
+ /* eslint-disable max-len */
1216
+ hexadecimal: function(obj) {
1217
+ return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
1218
+ }
1219
+ },
1220
+ defaultStyle: "decimal",
1221
+ styleAliases: {
1222
+ binary: [2, "bin"],
1223
+ octal: [8, "oct"],
1224
+ decimal: [10, "dec"],
1225
+ hexadecimal: [16, "hex"]
1226
+ }
1227
+ });
1228
+ var YAML_FLOAT_PATTERN = new RegExp(
1229
+ // 2.5e4, 2.5 and integers
1230
+ "^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
1231
+ );
1232
+ function resolveYamlFloat(data) {
1233
+ if (data === null)
1234
+ return false;
1235
+ if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
1236
+ // Probably should update regexp & check speed
1237
+ data[data.length - 1] === "_") {
1238
+ return false;
1239
+ }
1240
+ return true;
1241
+ }
1242
+ function constructYamlFloat(data) {
1243
+ var value, sign;
1244
+ value = data.replace(/_/g, "").toLowerCase();
1245
+ sign = value[0] === "-" ? -1 : 1;
1246
+ if ("+-".indexOf(value[0]) >= 0) {
1247
+ value = value.slice(1);
1248
+ }
1249
+ if (value === ".inf") {
1250
+ return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
1251
+ } else if (value === ".nan") {
1252
+ return NaN;
1253
+ }
1254
+ return sign * parseFloat(value, 10);
1255
+ }
1256
+ var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
1257
+ function representYamlFloat(object, style) {
1258
+ var res;
1259
+ if (isNaN(object)) {
1260
+ switch (style) {
1261
+ case "lowercase":
1262
+ return ".nan";
1263
+ case "uppercase":
1264
+ return ".NAN";
1265
+ case "camelcase":
1266
+ return ".NaN";
1267
+ }
1268
+ } else if (Number.POSITIVE_INFINITY === object) {
1269
+ switch (style) {
1270
+ case "lowercase":
1271
+ return ".inf";
1272
+ case "uppercase":
1273
+ return ".INF";
1274
+ case "camelcase":
1275
+ return ".Inf";
1276
+ }
1277
+ } else if (Number.NEGATIVE_INFINITY === object) {
1278
+ switch (style) {
1279
+ case "lowercase":
1280
+ return "-.inf";
1281
+ case "uppercase":
1282
+ return "-.INF";
1283
+ case "camelcase":
1284
+ return "-.Inf";
1285
+ }
1286
+ } else if (common.isNegativeZero(object)) {
1287
+ return "-0.0";
1288
+ }
1289
+ res = object.toString(10);
1290
+ return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
1291
+ }
1292
+ function isFloat(object) {
1293
+ return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
1294
+ }
1295
+ var float = new type("tag:yaml.org,2002:float", {
1296
+ kind: "scalar",
1297
+ resolve: resolveYamlFloat,
1298
+ construct: constructYamlFloat,
1299
+ predicate: isFloat,
1300
+ represent: representYamlFloat,
1301
+ defaultStyle: "lowercase"
1302
+ });
1303
+ var json = failsafe.extend({
1304
+ implicit: [
1305
+ _null,
1306
+ bool,
1307
+ int,
1308
+ float
1309
+ ]
1310
+ });
1311
+ var core = json;
1312
+ var YAML_DATE_REGEXP = new RegExp(
1313
+ "^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
1314
+ );
1315
+ var YAML_TIMESTAMP_REGEXP = new RegExp(
1316
+ "^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$"
1317
+ );
1318
+ function resolveYamlTimestamp(data) {
1319
+ if (data === null)
1320
+ return false;
1321
+ if (YAML_DATE_REGEXP.exec(data) !== null)
1322
+ return true;
1323
+ if (YAML_TIMESTAMP_REGEXP.exec(data) !== null)
1324
+ return true;
1325
+ return false;
1326
+ }
1327
+ function constructYamlTimestamp(data) {
1328
+ var match, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
1329
+ match = YAML_DATE_REGEXP.exec(data);
1330
+ if (match === null)
1331
+ match = YAML_TIMESTAMP_REGEXP.exec(data);
1332
+ if (match === null)
1333
+ throw new Error("Date resolve error");
1334
+ year = +match[1];
1335
+ month = +match[2] - 1;
1336
+ day = +match[3];
1337
+ if (!match[4]) {
1338
+ return new Date(Date.UTC(year, month, day));
1339
+ }
1340
+ hour = +match[4];
1341
+ minute = +match[5];
1342
+ second = +match[6];
1343
+ if (match[7]) {
1344
+ fraction = match[7].slice(0, 3);
1345
+ while (fraction.length < 3) {
1346
+ fraction += "0";
1347
+ }
1348
+ fraction = +fraction;
1349
+ }
1350
+ if (match[9]) {
1351
+ tz_hour = +match[10];
1352
+ tz_minute = +(match[11] || 0);
1353
+ delta = (tz_hour * 60 + tz_minute) * 6e4;
1354
+ if (match[9] === "-")
1355
+ delta = -delta;
1356
+ }
1357
+ date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
1358
+ if (delta)
1359
+ date.setTime(date.getTime() - delta);
1360
+ return date;
1361
+ }
1362
+ function representYamlTimestamp(object) {
1363
+ return object.toISOString();
1364
+ }
1365
+ var timestamp = new type("tag:yaml.org,2002:timestamp", {
1366
+ kind: "scalar",
1367
+ resolve: resolveYamlTimestamp,
1368
+ construct: constructYamlTimestamp,
1369
+ instanceOf: Date,
1370
+ represent: representYamlTimestamp
1371
+ });
1372
+ function resolveYamlMerge(data) {
1373
+ return data === "<<" || data === null;
1374
+ }
1375
+ var merge = new type("tag:yaml.org,2002:merge", {
1376
+ kind: "scalar",
1377
+ resolve: resolveYamlMerge
1378
+ });
1379
+ var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
1380
+ function resolveYamlBinary(data) {
1381
+ if (data === null)
1382
+ return false;
1383
+ var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
1384
+ for (idx = 0; idx < max; idx++) {
1385
+ code = map2.indexOf(data.charAt(idx));
1386
+ if (code > 64)
1387
+ continue;
1388
+ if (code < 0)
1389
+ return false;
1390
+ bitlen += 6;
1391
+ }
1392
+ return bitlen % 8 === 0;
1393
+ }
1394
+ function constructYamlBinary(data) {
1395
+ var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = [];
1396
+ for (idx = 0; idx < max; idx++) {
1397
+ if (idx % 4 === 0 && idx) {
1398
+ result.push(bits >> 16 & 255);
1399
+ result.push(bits >> 8 & 255);
1400
+ result.push(bits & 255);
1401
+ }
1402
+ bits = bits << 6 | map2.indexOf(input.charAt(idx));
1403
+ }
1404
+ tailbits = max % 4 * 6;
1405
+ if (tailbits === 0) {
1406
+ result.push(bits >> 16 & 255);
1407
+ result.push(bits >> 8 & 255);
1408
+ result.push(bits & 255);
1409
+ } else if (tailbits === 18) {
1410
+ result.push(bits >> 10 & 255);
1411
+ result.push(bits >> 2 & 255);
1412
+ } else if (tailbits === 12) {
1413
+ result.push(bits >> 4 & 255);
1414
+ }
1415
+ return new Uint8Array(result);
1416
+ }
1417
+ function representYamlBinary(object) {
1418
+ var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP;
1419
+ for (idx = 0; idx < max; idx++) {
1420
+ if (idx % 3 === 0 && idx) {
1421
+ result += map2[bits >> 18 & 63];
1422
+ result += map2[bits >> 12 & 63];
1423
+ result += map2[bits >> 6 & 63];
1424
+ result += map2[bits & 63];
1425
+ }
1426
+ bits = (bits << 8) + object[idx];
1427
+ }
1428
+ tail = max % 3;
1429
+ if (tail === 0) {
1430
+ result += map2[bits >> 18 & 63];
1431
+ result += map2[bits >> 12 & 63];
1432
+ result += map2[bits >> 6 & 63];
1433
+ result += map2[bits & 63];
1434
+ } else if (tail === 2) {
1435
+ result += map2[bits >> 10 & 63];
1436
+ result += map2[bits >> 4 & 63];
1437
+ result += map2[bits << 2 & 63];
1438
+ result += map2[64];
1439
+ } else if (tail === 1) {
1440
+ result += map2[bits >> 2 & 63];
1441
+ result += map2[bits << 4 & 63];
1442
+ result += map2[64];
1443
+ result += map2[64];
1444
+ }
1445
+ return result;
1446
+ }
1447
+ function isBinary(obj) {
1448
+ return Object.prototype.toString.call(obj) === "[object Uint8Array]";
1449
+ }
1450
+ var binary = new type("tag:yaml.org,2002:binary", {
1451
+ kind: "scalar",
1452
+ resolve: resolveYamlBinary,
1453
+ construct: constructYamlBinary,
1454
+ predicate: isBinary,
1455
+ represent: representYamlBinary
1456
+ });
1457
+ var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
1458
+ var _toString$2 = Object.prototype.toString;
1459
+ function resolveYamlOmap(data) {
1460
+ if (data === null)
1461
+ return true;
1462
+ var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
1463
+ for (index = 0, length = object.length; index < length; index += 1) {
1464
+ pair = object[index];
1465
+ pairHasKey = false;
1466
+ if (_toString$2.call(pair) !== "[object Object]")
1467
+ return false;
1468
+ for (pairKey in pair) {
1469
+ if (_hasOwnProperty$3.call(pair, pairKey)) {
1470
+ if (!pairHasKey)
1471
+ pairHasKey = true;
1472
+ else
1473
+ return false;
1474
+ }
1475
+ }
1476
+ if (!pairHasKey)
1477
+ return false;
1478
+ if (objectKeys.indexOf(pairKey) === -1)
1479
+ objectKeys.push(pairKey);
1480
+ else
1481
+ return false;
1482
+ }
1483
+ return true;
1484
+ }
1485
+ function constructYamlOmap(data) {
1486
+ return data !== null ? data : [];
1487
+ }
1488
+ var omap = new type("tag:yaml.org,2002:omap", {
1489
+ kind: "sequence",
1490
+ resolve: resolveYamlOmap,
1491
+ construct: constructYamlOmap
1492
+ });
1493
+ var _toString$1 = Object.prototype.toString;
1494
+ function resolveYamlPairs(data) {
1495
+ if (data === null)
1496
+ return true;
1497
+ var index, length, pair, keys, result, object = data;
1498
+ result = new Array(object.length);
1499
+ for (index = 0, length = object.length; index < length; index += 1) {
1500
+ pair = object[index];
1501
+ if (_toString$1.call(pair) !== "[object Object]")
1502
+ return false;
1503
+ keys = Object.keys(pair);
1504
+ if (keys.length !== 1)
1505
+ return false;
1506
+ result[index] = [keys[0], pair[keys[0]]];
1507
+ }
1508
+ return true;
1509
+ }
1510
+ function constructYamlPairs(data) {
1511
+ if (data === null)
1512
+ return [];
1513
+ var index, length, pair, keys, result, object = data;
1514
+ result = new Array(object.length);
1515
+ for (index = 0, length = object.length; index < length; index += 1) {
1516
+ pair = object[index];
1517
+ keys = Object.keys(pair);
1518
+ result[index] = [keys[0], pair[keys[0]]];
1519
+ }
1520
+ return result;
1521
+ }
1522
+ var pairs = new type("tag:yaml.org,2002:pairs", {
1523
+ kind: "sequence",
1524
+ resolve: resolveYamlPairs,
1525
+ construct: constructYamlPairs
1526
+ });
1527
+ var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
1528
+ function resolveYamlSet(data) {
1529
+ if (data === null)
1530
+ return true;
1531
+ var key, object = data;
1532
+ for (key in object) {
1533
+ if (_hasOwnProperty$2.call(object, key)) {
1534
+ if (object[key] !== null)
1535
+ return false;
1536
+ }
1537
+ }
1538
+ return true;
1539
+ }
1540
+ function constructYamlSet(data) {
1541
+ return data !== null ? data : {};
1542
+ }
1543
+ var set = new type("tag:yaml.org,2002:set", {
1544
+ kind: "mapping",
1545
+ resolve: resolveYamlSet,
1546
+ construct: constructYamlSet
1547
+ });
1548
+ var _default = core.extend({
1549
+ implicit: [
1550
+ timestamp,
1551
+ merge
1552
+ ],
1553
+ explicit: [
1554
+ binary,
1555
+ omap,
1556
+ pairs,
1557
+ set
1558
+ ]
1559
+ });
1560
+ var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
1561
+ var CONTEXT_FLOW_IN = 1;
1562
+ var CONTEXT_FLOW_OUT = 2;
1563
+ var CONTEXT_BLOCK_IN = 3;
1564
+ var CONTEXT_BLOCK_OUT = 4;
1565
+ var CHOMPING_CLIP = 1;
1566
+ var CHOMPING_STRIP = 2;
1567
+ var CHOMPING_KEEP = 3;
1568
+ var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
1569
+ var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
1570
+ var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
1571
+ var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
1572
+ var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
1573
+ function _class(obj) {
1574
+ return Object.prototype.toString.call(obj);
1575
+ }
1576
+ function is_EOL(c) {
1577
+ return c === 10 || c === 13;
1578
+ }
1579
+ function is_WHITE_SPACE(c) {
1580
+ return c === 9 || c === 32;
1581
+ }
1582
+ function is_WS_OR_EOL(c) {
1583
+ return c === 9 || c === 32 || c === 10 || c === 13;
1584
+ }
1585
+ function is_FLOW_INDICATOR(c) {
1586
+ return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
1587
+ }
1588
+ function fromHexCode(c) {
1589
+ var lc;
1590
+ if (48 <= c && c <= 57) {
1591
+ return c - 48;
1592
+ }
1593
+ lc = c | 32;
1594
+ if (97 <= lc && lc <= 102) {
1595
+ return lc - 97 + 10;
1596
+ }
1597
+ return -1;
1598
+ }
1599
+ function escapedHexLen(c) {
1600
+ if (c === 120) {
1601
+ return 2;
1602
+ }
1603
+ if (c === 117) {
1604
+ return 4;
1605
+ }
1606
+ if (c === 85) {
1607
+ return 8;
1608
+ }
1609
+ return 0;
1610
+ }
1611
+ function fromDecimalCode(c) {
1612
+ if (48 <= c && c <= 57) {
1613
+ return c - 48;
1614
+ }
1615
+ return -1;
1616
+ }
1617
+ function simpleEscapeSequence(c) {
1618
+ return c === 48 ? "\0" : c === 97 ? "\x07" : c === 98 ? "\b" : c === 116 ? " " : c === 9 ? " " : c === 110 ? "\n" : c === 118 ? "\v" : c === 102 ? "\f" : c === 114 ? "\r" : c === 101 ? "\x1B" : c === 32 ? " " : c === 34 ? '"' : c === 47 ? "/" : c === 92 ? "\\" : c === 78 ? "\x85" : c === 95 ? "\xA0" : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
1619
+ }
1620
+ function charFromCodepoint(c) {
1621
+ if (c <= 65535) {
1622
+ return String.fromCharCode(c);
1623
+ }
1624
+ return String.fromCharCode(
1625
+ (c - 65536 >> 10) + 55296,
1626
+ (c - 65536 & 1023) + 56320
1627
+ );
1628
+ }
1629
+ var simpleEscapeCheck = new Array(256);
1630
+ var simpleEscapeMap = new Array(256);
1631
+ for (i = 0; i < 256; i++) {
1632
+ simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
1633
+ simpleEscapeMap[i] = simpleEscapeSequence(i);
1634
+ }
1635
+ var i;
1636
+ function State$1(input, options) {
1637
+ this.input = input;
1638
+ this.filename = options["filename"] || null;
1639
+ this.schema = options["schema"] || _default;
1640
+ this.onWarning = options["onWarning"] || null;
1641
+ this.legacy = options["legacy"] || false;
1642
+ this.json = options["json"] || false;
1643
+ this.listener = options["listener"] || null;
1644
+ this.implicitTypes = this.schema.compiledImplicit;
1645
+ this.typeMap = this.schema.compiledTypeMap;
1646
+ this.length = input.length;
1647
+ this.position = 0;
1648
+ this.line = 0;
1649
+ this.lineStart = 0;
1650
+ this.lineIndent = 0;
1651
+ this.firstTabInLine = -1;
1652
+ this.documents = [];
1653
+ }
1654
+ function generateError(state, message) {
1655
+ var mark = {
1656
+ name: state.filename,
1657
+ buffer: state.input.slice(0, -1),
1658
+ // omit trailing \0
1659
+ position: state.position,
1660
+ line: state.line,
1661
+ column: state.position - state.lineStart
1662
+ };
1663
+ mark.snippet = snippet(mark);
1664
+ return new exception(message, mark);
1665
+ }
1666
+ function throwError(state, message) {
1667
+ throw generateError(state, message);
1668
+ }
1669
+ function throwWarning(state, message) {
1670
+ if (state.onWarning) {
1671
+ state.onWarning.call(null, generateError(state, message));
1672
+ }
1673
+ }
1674
+ var directiveHandlers = {
1675
+ YAML: function handleYamlDirective(state, name, args) {
1676
+ var match, major, minor;
1677
+ if (state.version !== null) {
1678
+ throwError(state, "duplication of %YAML directive");
1679
+ }
1680
+ if (args.length !== 1) {
1681
+ throwError(state, "YAML directive accepts exactly one argument");
1682
+ }
1683
+ match = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
1684
+ if (match === null) {
1685
+ throwError(state, "ill-formed argument of the YAML directive");
1686
+ }
1687
+ major = parseInt(match[1], 10);
1688
+ minor = parseInt(match[2], 10);
1689
+ if (major !== 1) {
1690
+ throwError(state, "unacceptable YAML version of the document");
1691
+ }
1692
+ state.version = args[0];
1693
+ state.checkLineBreaks = minor < 2;
1694
+ if (minor !== 1 && minor !== 2) {
1695
+ throwWarning(state, "unsupported YAML version of the document");
1696
+ }
1697
+ },
1698
+ TAG: function handleTagDirective(state, name, args) {
1699
+ var handle, prefix;
1700
+ if (args.length !== 2) {
1701
+ throwError(state, "TAG directive accepts exactly two arguments");
1702
+ }
1703
+ handle = args[0];
1704
+ prefix = args[1];
1705
+ if (!PATTERN_TAG_HANDLE.test(handle)) {
1706
+ throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
1707
+ }
1708
+ if (_hasOwnProperty$1.call(state.tagMap, handle)) {
1709
+ throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
1710
+ }
1711
+ if (!PATTERN_TAG_URI.test(prefix)) {
1712
+ throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
1713
+ }
1714
+ try {
1715
+ prefix = decodeURIComponent(prefix);
1716
+ } catch (err) {
1717
+ throwError(state, "tag prefix is malformed: " + prefix);
1718
+ }
1719
+ state.tagMap[handle] = prefix;
1720
+ }
1721
+ };
1722
+ function captureSegment(state, start, end, checkJson) {
1723
+ var _position, _length, _character, _result;
1724
+ if (start < end) {
1725
+ _result = state.input.slice(start, end);
1726
+ if (checkJson) {
1727
+ for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
1728
+ _character = _result.charCodeAt(_position);
1729
+ if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
1730
+ throwError(state, "expected valid JSON character");
1731
+ }
1732
+ }
1733
+ } else if (PATTERN_NON_PRINTABLE.test(_result)) {
1734
+ throwError(state, "the stream contains non-printable characters");
1735
+ }
1736
+ state.result += _result;
1737
+ }
1738
+ }
1739
+ function mergeMappings(state, destination, source, overridableKeys) {
1740
+ var sourceKeys, key, index, quantity;
1741
+ if (!common.isObject(source)) {
1742
+ throwError(state, "cannot merge mappings; the provided source object is unacceptable");
1743
+ }
1744
+ sourceKeys = Object.keys(source);
1745
+ for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
1746
+ key = sourceKeys[index];
1747
+ if (!_hasOwnProperty$1.call(destination, key)) {
1748
+ destination[key] = source[key];
1749
+ overridableKeys[key] = true;
1750
+ }
1751
+ }
1752
+ }
1753
+ function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
1754
+ var index, quantity;
1755
+ if (Array.isArray(keyNode)) {
1756
+ keyNode = Array.prototype.slice.call(keyNode);
1757
+ for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
1758
+ if (Array.isArray(keyNode[index])) {
1759
+ throwError(state, "nested arrays are not supported inside keys");
1760
+ }
1761
+ if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
1762
+ keyNode[index] = "[object Object]";
1763
+ }
1764
+ }
1765
+ }
1766
+ if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
1767
+ keyNode = "[object Object]";
1768
+ }
1769
+ keyNode = String(keyNode);
1770
+ if (_result === null) {
1771
+ _result = {};
1772
+ }
1773
+ if (keyTag === "tag:yaml.org,2002:merge") {
1774
+ if (Array.isArray(valueNode)) {
1775
+ for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
1776
+ mergeMappings(state, _result, valueNode[index], overridableKeys);
1777
+ }
1778
+ } else {
1779
+ mergeMappings(state, _result, valueNode, overridableKeys);
1780
+ }
1781
+ } else {
1782
+ if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) {
1783
+ state.line = startLine || state.line;
1784
+ state.lineStart = startLineStart || state.lineStart;
1785
+ state.position = startPos || state.position;
1786
+ throwError(state, "duplicated mapping key");
1787
+ }
1788
+ if (keyNode === "__proto__") {
1789
+ Object.defineProperty(_result, keyNode, {
1790
+ configurable: true,
1791
+ enumerable: true,
1792
+ writable: true,
1793
+ value: valueNode
1794
+ });
1795
+ } else {
1796
+ _result[keyNode] = valueNode;
1797
+ }
1798
+ delete overridableKeys[keyNode];
1799
+ }
1800
+ return _result;
1801
+ }
1802
+ function readLineBreak(state) {
1803
+ var ch;
1804
+ ch = state.input.charCodeAt(state.position);
1805
+ if (ch === 10) {
1806
+ state.position++;
1807
+ } else if (ch === 13) {
1808
+ state.position++;
1809
+ if (state.input.charCodeAt(state.position) === 10) {
1810
+ state.position++;
1811
+ }
1812
+ } else {
1813
+ throwError(state, "a line break is expected");
1814
+ }
1815
+ state.line += 1;
1816
+ state.lineStart = state.position;
1817
+ state.firstTabInLine = -1;
1818
+ }
1819
+ function skipSeparationSpace(state, allowComments, checkIndent) {
1820
+ var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
1821
+ while (ch !== 0) {
1822
+ while (is_WHITE_SPACE(ch)) {
1823
+ if (ch === 9 && state.firstTabInLine === -1) {
1824
+ state.firstTabInLine = state.position;
1825
+ }
1826
+ ch = state.input.charCodeAt(++state.position);
1827
+ }
1828
+ if (allowComments && ch === 35) {
1829
+ do {
1830
+ ch = state.input.charCodeAt(++state.position);
1831
+ } while (ch !== 10 && ch !== 13 && ch !== 0);
1832
+ }
1833
+ if (is_EOL(ch)) {
1834
+ readLineBreak(state);
1835
+ ch = state.input.charCodeAt(state.position);
1836
+ lineBreaks++;
1837
+ state.lineIndent = 0;
1838
+ while (ch === 32) {
1839
+ state.lineIndent++;
1840
+ ch = state.input.charCodeAt(++state.position);
1841
+ }
1842
+ } else {
1843
+ break;
1844
+ }
1845
+ }
1846
+ if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
1847
+ throwWarning(state, "deficient indentation");
1848
+ }
1849
+ return lineBreaks;
1850
+ }
1851
+ function testDocumentSeparator(state) {
1852
+ var _position = state.position, ch;
1853
+ ch = state.input.charCodeAt(_position);
1854
+ if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
1855
+ _position += 3;
1856
+ ch = state.input.charCodeAt(_position);
1857
+ if (ch === 0 || is_WS_OR_EOL(ch)) {
1858
+ return true;
1859
+ }
1860
+ }
1861
+ return false;
1862
+ }
1863
+ function writeFoldedLines(state, count) {
1864
+ if (count === 1) {
1865
+ state.result += " ";
1866
+ } else if (count > 1) {
1867
+ state.result += common.repeat("\n", count - 1);
1868
+ }
1869
+ }
1870
+ function readPlainScalar(state, nodeIndent, withinFlowCollection) {
1871
+ var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
1872
+ ch = state.input.charCodeAt(state.position);
1873
+ if (is_WS_OR_EOL(ch) || is_FLOW_INDICATOR(ch) || ch === 35 || ch === 38 || ch === 42 || ch === 33 || ch === 124 || ch === 62 || ch === 39 || ch === 34 || ch === 37 || ch === 64 || ch === 96) {
1874
+ return false;
1875
+ }
1876
+ if (ch === 63 || ch === 45) {
1877
+ following = state.input.charCodeAt(state.position + 1);
1878
+ if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
1879
+ return false;
1880
+ }
1881
+ }
1882
+ state.kind = "scalar";
1883
+ state.result = "";
1884
+ captureStart = captureEnd = state.position;
1885
+ hasPendingContent = false;
1886
+ while (ch !== 0) {
1887
+ if (ch === 58) {
1888
+ following = state.input.charCodeAt(state.position + 1);
1889
+ if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
1890
+ break;
1891
+ }
1892
+ } else if (ch === 35) {
1893
+ preceding = state.input.charCodeAt(state.position - 1);
1894
+ if (is_WS_OR_EOL(preceding)) {
1895
+ break;
1896
+ }
1897
+ } else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
1898
+ break;
1899
+ } else if (is_EOL(ch)) {
1900
+ _line = state.line;
1901
+ _lineStart = state.lineStart;
1902
+ _lineIndent = state.lineIndent;
1903
+ skipSeparationSpace(state, false, -1);
1904
+ if (state.lineIndent >= nodeIndent) {
1905
+ hasPendingContent = true;
1906
+ ch = state.input.charCodeAt(state.position);
1907
+ continue;
1908
+ } else {
1909
+ state.position = captureEnd;
1910
+ state.line = _line;
1911
+ state.lineStart = _lineStart;
1912
+ state.lineIndent = _lineIndent;
1913
+ break;
1914
+ }
1915
+ }
1916
+ if (hasPendingContent) {
1917
+ captureSegment(state, captureStart, captureEnd, false);
1918
+ writeFoldedLines(state, state.line - _line);
1919
+ captureStart = captureEnd = state.position;
1920
+ hasPendingContent = false;
1921
+ }
1922
+ if (!is_WHITE_SPACE(ch)) {
1923
+ captureEnd = state.position + 1;
1924
+ }
1925
+ ch = state.input.charCodeAt(++state.position);
1926
+ }
1927
+ captureSegment(state, captureStart, captureEnd, false);
1928
+ if (state.result) {
1929
+ return true;
1930
+ }
1931
+ state.kind = _kind;
1932
+ state.result = _result;
1933
+ return false;
1934
+ }
1935
+ function readSingleQuotedScalar(state, nodeIndent) {
1936
+ var ch, captureStart, captureEnd;
1937
+ ch = state.input.charCodeAt(state.position);
1938
+ if (ch !== 39) {
1939
+ return false;
1940
+ }
1941
+ state.kind = "scalar";
1942
+ state.result = "";
1943
+ state.position++;
1944
+ captureStart = captureEnd = state.position;
1945
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1946
+ if (ch === 39) {
1947
+ captureSegment(state, captureStart, state.position, true);
1948
+ ch = state.input.charCodeAt(++state.position);
1949
+ if (ch === 39) {
1950
+ captureStart = state.position;
1951
+ state.position++;
1952
+ captureEnd = state.position;
1953
+ } else {
1954
+ return true;
1955
+ }
1956
+ } else if (is_EOL(ch)) {
1957
+ captureSegment(state, captureStart, captureEnd, true);
1958
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
1959
+ captureStart = captureEnd = state.position;
1960
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
1961
+ throwError(state, "unexpected end of the document within a single quoted scalar");
1962
+ } else {
1963
+ state.position++;
1964
+ captureEnd = state.position;
1965
+ }
1966
+ }
1967
+ throwError(state, "unexpected end of the stream within a single quoted scalar");
1968
+ }
1969
+ function readDoubleQuotedScalar(state, nodeIndent) {
1970
+ var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
1971
+ ch = state.input.charCodeAt(state.position);
1972
+ if (ch !== 34) {
1973
+ return false;
1974
+ }
1975
+ state.kind = "scalar";
1976
+ state.result = "";
1977
+ state.position++;
1978
+ captureStart = captureEnd = state.position;
1979
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
1980
+ if (ch === 34) {
1981
+ captureSegment(state, captureStart, state.position, true);
1982
+ state.position++;
1983
+ return true;
1984
+ } else if (ch === 92) {
1985
+ captureSegment(state, captureStart, state.position, true);
1986
+ ch = state.input.charCodeAt(++state.position);
1987
+ if (is_EOL(ch)) {
1988
+ skipSeparationSpace(state, false, nodeIndent);
1989
+ } else if (ch < 256 && simpleEscapeCheck[ch]) {
1990
+ state.result += simpleEscapeMap[ch];
1991
+ state.position++;
1992
+ } else if ((tmp = escapedHexLen(ch)) > 0) {
1993
+ hexLength = tmp;
1994
+ hexResult = 0;
1995
+ for (; hexLength > 0; hexLength--) {
1996
+ ch = state.input.charCodeAt(++state.position);
1997
+ if ((tmp = fromHexCode(ch)) >= 0) {
1998
+ hexResult = (hexResult << 4) + tmp;
1999
+ } else {
2000
+ throwError(state, "expected hexadecimal character");
2001
+ }
2002
+ }
2003
+ state.result += charFromCodepoint(hexResult);
2004
+ state.position++;
2005
+ } else {
2006
+ throwError(state, "unknown escape sequence");
2007
+ }
2008
+ captureStart = captureEnd = state.position;
2009
+ } else if (is_EOL(ch)) {
2010
+ captureSegment(state, captureStart, captureEnd, true);
2011
+ writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
2012
+ captureStart = captureEnd = state.position;
2013
+ } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
2014
+ throwError(state, "unexpected end of the document within a double quoted scalar");
2015
+ } else {
2016
+ state.position++;
2017
+ captureEnd = state.position;
2018
+ }
2019
+ }
2020
+ throwError(state, "unexpected end of the stream within a double quoted scalar");
2021
+ }
2022
+ function readFlowCollection(state, nodeIndent) {
2023
+ var readNext = true, _line, _lineStart, _pos, _tag = state.tag, _result, _anchor = state.anchor, following, terminator, isPair, isExplicitPair, isMapping, overridableKeys = /* @__PURE__ */ Object.create(null), keyNode, keyTag, valueNode, ch;
2024
+ ch = state.input.charCodeAt(state.position);
2025
+ if (ch === 91) {
2026
+ terminator = 93;
2027
+ isMapping = false;
2028
+ _result = [];
2029
+ } else if (ch === 123) {
2030
+ terminator = 125;
2031
+ isMapping = true;
2032
+ _result = {};
2033
+ } else {
2034
+ return false;
2035
+ }
2036
+ if (state.anchor !== null) {
2037
+ state.anchorMap[state.anchor] = _result;
2038
+ }
2039
+ ch = state.input.charCodeAt(++state.position);
2040
+ while (ch !== 0) {
2041
+ skipSeparationSpace(state, true, nodeIndent);
2042
+ ch = state.input.charCodeAt(state.position);
2043
+ if (ch === terminator) {
2044
+ state.position++;
2045
+ state.tag = _tag;
2046
+ state.anchor = _anchor;
2047
+ state.kind = isMapping ? "mapping" : "sequence";
2048
+ state.result = _result;
2049
+ return true;
2050
+ } else if (!readNext) {
2051
+ throwError(state, "missed comma between flow collection entries");
2052
+ } else if (ch === 44) {
2053
+ throwError(state, "expected the node content, but found ','");
2054
+ }
2055
+ keyTag = keyNode = valueNode = null;
2056
+ isPair = isExplicitPair = false;
2057
+ if (ch === 63) {
2058
+ following = state.input.charCodeAt(state.position + 1);
2059
+ if (is_WS_OR_EOL(following)) {
2060
+ isPair = isExplicitPair = true;
2061
+ state.position++;
2062
+ skipSeparationSpace(state, true, nodeIndent);
2063
+ }
2064
+ }
2065
+ _line = state.line;
2066
+ _lineStart = state.lineStart;
2067
+ _pos = state.position;
2068
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
2069
+ keyTag = state.tag;
2070
+ keyNode = state.result;
2071
+ skipSeparationSpace(state, true, nodeIndent);
2072
+ ch = state.input.charCodeAt(state.position);
2073
+ if ((isExplicitPair || state.line === _line) && ch === 58) {
2074
+ isPair = true;
2075
+ ch = state.input.charCodeAt(++state.position);
2076
+ skipSeparationSpace(state, true, nodeIndent);
2077
+ composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
2078
+ valueNode = state.result;
2079
+ }
2080
+ if (isMapping) {
2081
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
2082
+ } else if (isPair) {
2083
+ _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
2084
+ } else {
2085
+ _result.push(keyNode);
2086
+ }
2087
+ skipSeparationSpace(state, true, nodeIndent);
2088
+ ch = state.input.charCodeAt(state.position);
2089
+ if (ch === 44) {
2090
+ readNext = true;
2091
+ ch = state.input.charCodeAt(++state.position);
2092
+ } else {
2093
+ readNext = false;
2094
+ }
2095
+ }
2096
+ throwError(state, "unexpected end of the stream within a flow collection");
2097
+ }
2098
+ function readBlockScalar(state, nodeIndent) {
2099
+ var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
2100
+ ch = state.input.charCodeAt(state.position);
2101
+ if (ch === 124) {
2102
+ folding = false;
2103
+ } else if (ch === 62) {
2104
+ folding = true;
2105
+ } else {
2106
+ return false;
2107
+ }
2108
+ state.kind = "scalar";
2109
+ state.result = "";
2110
+ while (ch !== 0) {
2111
+ ch = state.input.charCodeAt(++state.position);
2112
+ if (ch === 43 || ch === 45) {
2113
+ if (CHOMPING_CLIP === chomping) {
2114
+ chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
2115
+ } else {
2116
+ throwError(state, "repeat of a chomping mode identifier");
2117
+ }
2118
+ } else if ((tmp = fromDecimalCode(ch)) >= 0) {
2119
+ if (tmp === 0) {
2120
+ throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
2121
+ } else if (!detectedIndent) {
2122
+ textIndent = nodeIndent + tmp - 1;
2123
+ detectedIndent = true;
2124
+ } else {
2125
+ throwError(state, "repeat of an indentation width identifier");
2126
+ }
2127
+ } else {
2128
+ break;
2129
+ }
2130
+ }
2131
+ if (is_WHITE_SPACE(ch)) {
2132
+ do {
2133
+ ch = state.input.charCodeAt(++state.position);
2134
+ } while (is_WHITE_SPACE(ch));
2135
+ if (ch === 35) {
2136
+ do {
2137
+ ch = state.input.charCodeAt(++state.position);
2138
+ } while (!is_EOL(ch) && ch !== 0);
2139
+ }
2140
+ }
2141
+ while (ch !== 0) {
2142
+ readLineBreak(state);
2143
+ state.lineIndent = 0;
2144
+ ch = state.input.charCodeAt(state.position);
2145
+ while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
2146
+ state.lineIndent++;
2147
+ ch = state.input.charCodeAt(++state.position);
2148
+ }
2149
+ if (!detectedIndent && state.lineIndent > textIndent) {
2150
+ textIndent = state.lineIndent;
2151
+ }
2152
+ if (is_EOL(ch)) {
2153
+ emptyLines++;
2154
+ continue;
2155
+ }
2156
+ if (state.lineIndent < textIndent) {
2157
+ if (chomping === CHOMPING_KEEP) {
2158
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
2159
+ } else if (chomping === CHOMPING_CLIP) {
2160
+ if (didReadContent) {
2161
+ state.result += "\n";
2162
+ }
2163
+ }
2164
+ break;
2165
+ }
2166
+ if (folding) {
2167
+ if (is_WHITE_SPACE(ch)) {
2168
+ atMoreIndented = true;
2169
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
2170
+ } else if (atMoreIndented) {
2171
+ atMoreIndented = false;
2172
+ state.result += common.repeat("\n", emptyLines + 1);
2173
+ } else if (emptyLines === 0) {
2174
+ if (didReadContent) {
2175
+ state.result += " ";
2176
+ }
2177
+ } else {
2178
+ state.result += common.repeat("\n", emptyLines);
2179
+ }
2180
+ } else {
2181
+ state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
2182
+ }
2183
+ didReadContent = true;
2184
+ detectedIndent = true;
2185
+ emptyLines = 0;
2186
+ captureStart = state.position;
2187
+ while (!is_EOL(ch) && ch !== 0) {
2188
+ ch = state.input.charCodeAt(++state.position);
2189
+ }
2190
+ captureSegment(state, captureStart, state.position, false);
2191
+ }
2192
+ return true;
2193
+ }
2194
+ function readBlockSequence(state, nodeIndent) {
2195
+ var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
2196
+ if (state.firstTabInLine !== -1)
2197
+ return false;
2198
+ if (state.anchor !== null) {
2199
+ state.anchorMap[state.anchor] = _result;
2200
+ }
2201
+ ch = state.input.charCodeAt(state.position);
2202
+ while (ch !== 0) {
2203
+ if (state.firstTabInLine !== -1) {
2204
+ state.position = state.firstTabInLine;
2205
+ throwError(state, "tab characters must not be used in indentation");
2206
+ }
2207
+ if (ch !== 45) {
2208
+ break;
2209
+ }
2210
+ following = state.input.charCodeAt(state.position + 1);
2211
+ if (!is_WS_OR_EOL(following)) {
2212
+ break;
2213
+ }
2214
+ detected = true;
2215
+ state.position++;
2216
+ if (skipSeparationSpace(state, true, -1)) {
2217
+ if (state.lineIndent <= nodeIndent) {
2218
+ _result.push(null);
2219
+ ch = state.input.charCodeAt(state.position);
2220
+ continue;
2221
+ }
2222
+ }
2223
+ _line = state.line;
2224
+ composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
2225
+ _result.push(state.result);
2226
+ skipSeparationSpace(state, true, -1);
2227
+ ch = state.input.charCodeAt(state.position);
2228
+ if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
2229
+ throwError(state, "bad indentation of a sequence entry");
2230
+ } else if (state.lineIndent < nodeIndent) {
2231
+ break;
2232
+ }
2233
+ }
2234
+ if (detected) {
2235
+ state.tag = _tag;
2236
+ state.anchor = _anchor;
2237
+ state.kind = "sequence";
2238
+ state.result = _result;
2239
+ return true;
2240
+ }
2241
+ return false;
2242
+ }
2243
+ function readBlockMapping(state, nodeIndent, flowIndent) {
2244
+ var following, allowCompact, _line, _keyLine, _keyLineStart, _keyPos, _tag = state.tag, _anchor = state.anchor, _result = {}, overridableKeys = /* @__PURE__ */ Object.create(null), keyTag = null, keyNode = null, valueNode = null, atExplicitKey = false, detected = false, ch;
2245
+ if (state.firstTabInLine !== -1)
2246
+ return false;
2247
+ if (state.anchor !== null) {
2248
+ state.anchorMap[state.anchor] = _result;
2249
+ }
2250
+ ch = state.input.charCodeAt(state.position);
2251
+ while (ch !== 0) {
2252
+ if (!atExplicitKey && state.firstTabInLine !== -1) {
2253
+ state.position = state.firstTabInLine;
2254
+ throwError(state, "tab characters must not be used in indentation");
2255
+ }
2256
+ following = state.input.charCodeAt(state.position + 1);
2257
+ _line = state.line;
2258
+ if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
2259
+ if (ch === 63) {
2260
+ if (atExplicitKey) {
2261
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
2262
+ keyTag = keyNode = valueNode = null;
2263
+ }
2264
+ detected = true;
2265
+ atExplicitKey = true;
2266
+ allowCompact = true;
2267
+ } else if (atExplicitKey) {
2268
+ atExplicitKey = false;
2269
+ allowCompact = true;
2270
+ } else {
2271
+ throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
2272
+ }
2273
+ state.position += 1;
2274
+ ch = following;
2275
+ } else {
2276
+ _keyLine = state.line;
2277
+ _keyLineStart = state.lineStart;
2278
+ _keyPos = state.position;
2279
+ if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
2280
+ break;
2281
+ }
2282
+ if (state.line === _line) {
2283
+ ch = state.input.charCodeAt(state.position);
2284
+ while (is_WHITE_SPACE(ch)) {
2285
+ ch = state.input.charCodeAt(++state.position);
2286
+ }
2287
+ if (ch === 58) {
2288
+ ch = state.input.charCodeAt(++state.position);
2289
+ if (!is_WS_OR_EOL(ch)) {
2290
+ throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
2291
+ }
2292
+ if (atExplicitKey) {
2293
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
2294
+ keyTag = keyNode = valueNode = null;
2295
+ }
2296
+ detected = true;
2297
+ atExplicitKey = false;
2298
+ allowCompact = false;
2299
+ keyTag = state.tag;
2300
+ keyNode = state.result;
2301
+ } else if (detected) {
2302
+ throwError(state, "can not read an implicit mapping pair; a colon is missed");
2303
+ } else {
2304
+ state.tag = _tag;
2305
+ state.anchor = _anchor;
2306
+ return true;
2307
+ }
2308
+ } else if (detected) {
2309
+ throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
2310
+ } else {
2311
+ state.tag = _tag;
2312
+ state.anchor = _anchor;
2313
+ return true;
2314
+ }
2315
+ }
2316
+ if (state.line === _line || state.lineIndent > nodeIndent) {
2317
+ if (atExplicitKey) {
2318
+ _keyLine = state.line;
2319
+ _keyLineStart = state.lineStart;
2320
+ _keyPos = state.position;
2321
+ }
2322
+ if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
2323
+ if (atExplicitKey) {
2324
+ keyNode = state.result;
2325
+ } else {
2326
+ valueNode = state.result;
2327
+ }
2328
+ }
2329
+ if (!atExplicitKey) {
2330
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
2331
+ keyTag = keyNode = valueNode = null;
2332
+ }
2333
+ skipSeparationSpace(state, true, -1);
2334
+ ch = state.input.charCodeAt(state.position);
2335
+ }
2336
+ if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
2337
+ throwError(state, "bad indentation of a mapping entry");
2338
+ } else if (state.lineIndent < nodeIndent) {
2339
+ break;
2340
+ }
2341
+ }
2342
+ if (atExplicitKey) {
2343
+ storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
2344
+ }
2345
+ if (detected) {
2346
+ state.tag = _tag;
2347
+ state.anchor = _anchor;
2348
+ state.kind = "mapping";
2349
+ state.result = _result;
2350
+ }
2351
+ return detected;
2352
+ }
2353
+ function readTagProperty(state) {
2354
+ var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
2355
+ ch = state.input.charCodeAt(state.position);
2356
+ if (ch !== 33)
2357
+ return false;
2358
+ if (state.tag !== null) {
2359
+ throwError(state, "duplication of a tag property");
2360
+ }
2361
+ ch = state.input.charCodeAt(++state.position);
2362
+ if (ch === 60) {
2363
+ isVerbatim = true;
2364
+ ch = state.input.charCodeAt(++state.position);
2365
+ } else if (ch === 33) {
2366
+ isNamed = true;
2367
+ tagHandle = "!!";
2368
+ ch = state.input.charCodeAt(++state.position);
2369
+ } else {
2370
+ tagHandle = "!";
2371
+ }
2372
+ _position = state.position;
2373
+ if (isVerbatim) {
2374
+ do {
2375
+ ch = state.input.charCodeAt(++state.position);
2376
+ } while (ch !== 0 && ch !== 62);
2377
+ if (state.position < state.length) {
2378
+ tagName = state.input.slice(_position, state.position);
2379
+ ch = state.input.charCodeAt(++state.position);
2380
+ } else {
2381
+ throwError(state, "unexpected end of the stream within a verbatim tag");
2382
+ }
2383
+ } else {
2384
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2385
+ if (ch === 33) {
2386
+ if (!isNamed) {
2387
+ tagHandle = state.input.slice(_position - 1, state.position + 1);
2388
+ if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
2389
+ throwError(state, "named tag handle cannot contain such characters");
2390
+ }
2391
+ isNamed = true;
2392
+ _position = state.position + 1;
2393
+ } else {
2394
+ throwError(state, "tag suffix cannot contain exclamation marks");
2395
+ }
2396
+ }
2397
+ ch = state.input.charCodeAt(++state.position);
2398
+ }
2399
+ tagName = state.input.slice(_position, state.position);
2400
+ if (PATTERN_FLOW_INDICATORS.test(tagName)) {
2401
+ throwError(state, "tag suffix cannot contain flow indicator characters");
2402
+ }
2403
+ }
2404
+ if (tagName && !PATTERN_TAG_URI.test(tagName)) {
2405
+ throwError(state, "tag name cannot contain such characters: " + tagName);
2406
+ }
2407
+ try {
2408
+ tagName = decodeURIComponent(tagName);
2409
+ } catch (err) {
2410
+ throwError(state, "tag name is malformed: " + tagName);
2411
+ }
2412
+ if (isVerbatim) {
2413
+ state.tag = tagName;
2414
+ } else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
2415
+ state.tag = state.tagMap[tagHandle] + tagName;
2416
+ } else if (tagHandle === "!") {
2417
+ state.tag = "!" + tagName;
2418
+ } else if (tagHandle === "!!") {
2419
+ state.tag = "tag:yaml.org,2002:" + tagName;
2420
+ } else {
2421
+ throwError(state, 'undeclared tag handle "' + tagHandle + '"');
2422
+ }
2423
+ return true;
2424
+ }
2425
+ function readAnchorProperty(state) {
2426
+ var _position, ch;
2427
+ ch = state.input.charCodeAt(state.position);
2428
+ if (ch !== 38)
2429
+ return false;
2430
+ if (state.anchor !== null) {
2431
+ throwError(state, "duplication of an anchor property");
2432
+ }
2433
+ ch = state.input.charCodeAt(++state.position);
2434
+ _position = state.position;
2435
+ while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
2436
+ ch = state.input.charCodeAt(++state.position);
2437
+ }
2438
+ if (state.position === _position) {
2439
+ throwError(state, "name of an anchor node must contain at least one character");
2440
+ }
2441
+ state.anchor = state.input.slice(_position, state.position);
2442
+ return true;
2443
+ }
2444
+ function readAlias(state) {
2445
+ var _position, alias, ch;
2446
+ ch = state.input.charCodeAt(state.position);
2447
+ if (ch !== 42)
2448
+ return false;
2449
+ ch = state.input.charCodeAt(++state.position);
2450
+ _position = state.position;
2451
+ while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
2452
+ ch = state.input.charCodeAt(++state.position);
2453
+ }
2454
+ if (state.position === _position) {
2455
+ throwError(state, "name of an alias node must contain at least one character");
2456
+ }
2457
+ alias = state.input.slice(_position, state.position);
2458
+ if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
2459
+ throwError(state, 'unidentified alias "' + alias + '"');
2460
+ }
2461
+ state.result = state.anchorMap[alias];
2462
+ skipSeparationSpace(state, true, -1);
2463
+ return true;
2464
+ }
2465
+ function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
2466
+ var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent;
2467
+ if (state.listener !== null) {
2468
+ state.listener("open", state);
2469
+ }
2470
+ state.tag = null;
2471
+ state.anchor = null;
2472
+ state.kind = null;
2473
+ state.result = null;
2474
+ allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
2475
+ if (allowToSeek) {
2476
+ if (skipSeparationSpace(state, true, -1)) {
2477
+ atNewLine = true;
2478
+ if (state.lineIndent > parentIndent) {
2479
+ indentStatus = 1;
2480
+ } else if (state.lineIndent === parentIndent) {
2481
+ indentStatus = 0;
2482
+ } else if (state.lineIndent < parentIndent) {
2483
+ indentStatus = -1;
2484
+ }
2485
+ }
2486
+ }
2487
+ if (indentStatus === 1) {
2488
+ while (readTagProperty(state) || readAnchorProperty(state)) {
2489
+ if (skipSeparationSpace(state, true, -1)) {
2490
+ atNewLine = true;
2491
+ allowBlockCollections = allowBlockStyles;
2492
+ if (state.lineIndent > parentIndent) {
2493
+ indentStatus = 1;
2494
+ } else if (state.lineIndent === parentIndent) {
2495
+ indentStatus = 0;
2496
+ } else if (state.lineIndent < parentIndent) {
2497
+ indentStatus = -1;
2498
+ }
2499
+ } else {
2500
+ allowBlockCollections = false;
2501
+ }
2502
+ }
2503
+ }
2504
+ if (allowBlockCollections) {
2505
+ allowBlockCollections = atNewLine || allowCompact;
2506
+ }
2507
+ if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
2508
+ if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
2509
+ flowIndent = parentIndent;
2510
+ } else {
2511
+ flowIndent = parentIndent + 1;
2512
+ }
2513
+ blockIndent = state.position - state.lineStart;
2514
+ if (indentStatus === 1) {
2515
+ if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
2516
+ hasContent = true;
2517
+ } else {
2518
+ if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
2519
+ hasContent = true;
2520
+ } else if (readAlias(state)) {
2521
+ hasContent = true;
2522
+ if (state.tag !== null || state.anchor !== null) {
2523
+ throwError(state, "alias node should not have any properties");
2524
+ }
2525
+ } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
2526
+ hasContent = true;
2527
+ if (state.tag === null) {
2528
+ state.tag = "?";
2529
+ }
2530
+ }
2531
+ if (state.anchor !== null) {
2532
+ state.anchorMap[state.anchor] = state.result;
2533
+ }
2534
+ }
2535
+ } else if (indentStatus === 0) {
2536
+ hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
2537
+ }
2538
+ }
2539
+ if (state.tag === null) {
2540
+ if (state.anchor !== null) {
2541
+ state.anchorMap[state.anchor] = state.result;
2542
+ }
2543
+ } else if (state.tag === "?") {
2544
+ if (state.result !== null && state.kind !== "scalar") {
2545
+ throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
2546
+ }
2547
+ for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
2548
+ type2 = state.implicitTypes[typeIndex];
2549
+ if (type2.resolve(state.result)) {
2550
+ state.result = type2.construct(state.result);
2551
+ state.tag = type2.tag;
2552
+ if (state.anchor !== null) {
2553
+ state.anchorMap[state.anchor] = state.result;
2554
+ }
2555
+ break;
2556
+ }
2557
+ }
2558
+ } else if (state.tag !== "!") {
2559
+ if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) {
2560
+ type2 = state.typeMap[state.kind || "fallback"][state.tag];
2561
+ } else {
2562
+ type2 = null;
2563
+ typeList = state.typeMap.multi[state.kind || "fallback"];
2564
+ for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
2565
+ if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
2566
+ type2 = typeList[typeIndex];
2567
+ break;
2568
+ }
2569
+ }
2570
+ }
2571
+ if (!type2) {
2572
+ throwError(state, "unknown tag !<" + state.tag + ">");
2573
+ }
2574
+ if (state.result !== null && type2.kind !== state.kind) {
2575
+ throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
2576
+ }
2577
+ if (!type2.resolve(state.result, state.tag)) {
2578
+ throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
2579
+ } else {
2580
+ state.result = type2.construct(state.result, state.tag);
2581
+ if (state.anchor !== null) {
2582
+ state.anchorMap[state.anchor] = state.result;
2583
+ }
2584
+ }
2585
+ }
2586
+ if (state.listener !== null) {
2587
+ state.listener("close", state);
2588
+ }
2589
+ return state.tag !== null || state.anchor !== null || hasContent;
2590
+ }
2591
+ function readDocument(state) {
2592
+ var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
2593
+ state.version = null;
2594
+ state.checkLineBreaks = state.legacy;
2595
+ state.tagMap = /* @__PURE__ */ Object.create(null);
2596
+ state.anchorMap = /* @__PURE__ */ Object.create(null);
2597
+ while ((ch = state.input.charCodeAt(state.position)) !== 0) {
2598
+ skipSeparationSpace(state, true, -1);
2599
+ ch = state.input.charCodeAt(state.position);
2600
+ if (state.lineIndent > 0 || ch !== 37) {
2601
+ break;
2602
+ }
2603
+ hasDirectives = true;
2604
+ ch = state.input.charCodeAt(++state.position);
2605
+ _position = state.position;
2606
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2607
+ ch = state.input.charCodeAt(++state.position);
2608
+ }
2609
+ directiveName = state.input.slice(_position, state.position);
2610
+ directiveArgs = [];
2611
+ if (directiveName.length < 1) {
2612
+ throwError(state, "directive name must not be less than one character in length");
2613
+ }
2614
+ while (ch !== 0) {
2615
+ while (is_WHITE_SPACE(ch)) {
2616
+ ch = state.input.charCodeAt(++state.position);
2617
+ }
2618
+ if (ch === 35) {
2619
+ do {
2620
+ ch = state.input.charCodeAt(++state.position);
2621
+ } while (ch !== 0 && !is_EOL(ch));
2622
+ break;
2623
+ }
2624
+ if (is_EOL(ch))
2625
+ break;
2626
+ _position = state.position;
2627
+ while (ch !== 0 && !is_WS_OR_EOL(ch)) {
2628
+ ch = state.input.charCodeAt(++state.position);
2629
+ }
2630
+ directiveArgs.push(state.input.slice(_position, state.position));
2631
+ }
2632
+ if (ch !== 0)
2633
+ readLineBreak(state);
2634
+ if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
2635
+ directiveHandlers[directiveName](state, directiveName, directiveArgs);
2636
+ } else {
2637
+ throwWarning(state, 'unknown document directive "' + directiveName + '"');
2638
+ }
2639
+ }
2640
+ skipSeparationSpace(state, true, -1);
2641
+ if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
2642
+ state.position += 3;
2643
+ skipSeparationSpace(state, true, -1);
2644
+ } else if (hasDirectives) {
2645
+ throwError(state, "directives end mark is expected");
2646
+ }
2647
+ composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
2648
+ skipSeparationSpace(state, true, -1);
2649
+ if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
2650
+ throwWarning(state, "non-ASCII line breaks are interpreted as content");
2651
+ }
2652
+ state.documents.push(state.result);
2653
+ if (state.position === state.lineStart && testDocumentSeparator(state)) {
2654
+ if (state.input.charCodeAt(state.position) === 46) {
2655
+ state.position += 3;
2656
+ skipSeparationSpace(state, true, -1);
2657
+ }
2658
+ return;
2659
+ }
2660
+ if (state.position < state.length - 1) {
2661
+ throwError(state, "end of the stream or a document separator is expected");
2662
+ } else {
2663
+ return;
2664
+ }
2665
+ }
2666
+ function loadDocuments(input, options) {
2667
+ input = String(input);
2668
+ options = options || {};
2669
+ if (input.length !== 0) {
2670
+ if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
2671
+ input += "\n";
2672
+ }
2673
+ if (input.charCodeAt(0) === 65279) {
2674
+ input = input.slice(1);
2675
+ }
2676
+ }
2677
+ var state = new State$1(input, options);
2678
+ var nullpos = input.indexOf("\0");
2679
+ if (nullpos !== -1) {
2680
+ state.position = nullpos;
2681
+ throwError(state, "null byte is not allowed in input");
2682
+ }
2683
+ state.input += "\0";
2684
+ while (state.input.charCodeAt(state.position) === 32) {
2685
+ state.lineIndent += 1;
2686
+ state.position += 1;
2687
+ }
2688
+ while (state.position < state.length - 1) {
2689
+ readDocument(state);
2690
+ }
2691
+ return state.documents;
2692
+ }
2693
+ function loadAll$1(input, iterator, options) {
2694
+ if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
2695
+ options = iterator;
2696
+ iterator = null;
2697
+ }
2698
+ var documents = loadDocuments(input, options);
2699
+ if (typeof iterator !== "function") {
2700
+ return documents;
2701
+ }
2702
+ for (var index = 0, length = documents.length; index < length; index += 1) {
2703
+ iterator(documents[index]);
2704
+ }
2705
+ }
2706
+ function load$1(input, options) {
2707
+ var documents = loadDocuments(input, options);
2708
+ if (documents.length === 0) {
2709
+ return void 0;
2710
+ } else if (documents.length === 1) {
2711
+ return documents[0];
2712
+ }
2713
+ throw new exception("expected a single document in the stream, but found more");
2714
+ }
2715
+ var loadAll_1 = loadAll$1;
2716
+ var load_1 = load$1;
2717
+ var loader = {
2718
+ loadAll: loadAll_1,
2719
+ load: load_1
2720
+ };
2721
+ var _toString = Object.prototype.toString;
2722
+ var _hasOwnProperty = Object.prototype.hasOwnProperty;
2723
+ var CHAR_BOM = 65279;
2724
+ var CHAR_TAB = 9;
2725
+ var CHAR_LINE_FEED = 10;
2726
+ var CHAR_CARRIAGE_RETURN = 13;
2727
+ var CHAR_SPACE = 32;
2728
+ var CHAR_EXCLAMATION = 33;
2729
+ var CHAR_DOUBLE_QUOTE = 34;
2730
+ var CHAR_SHARP = 35;
2731
+ var CHAR_PERCENT = 37;
2732
+ var CHAR_AMPERSAND = 38;
2733
+ var CHAR_SINGLE_QUOTE = 39;
2734
+ var CHAR_ASTERISK = 42;
2735
+ var CHAR_COMMA = 44;
2736
+ var CHAR_MINUS = 45;
2737
+ var CHAR_COLON = 58;
2738
+ var CHAR_EQUALS = 61;
2739
+ var CHAR_GREATER_THAN = 62;
2740
+ var CHAR_QUESTION = 63;
2741
+ var CHAR_COMMERCIAL_AT = 64;
2742
+ var CHAR_LEFT_SQUARE_BRACKET = 91;
2743
+ var CHAR_RIGHT_SQUARE_BRACKET = 93;
2744
+ var CHAR_GRAVE_ACCENT = 96;
2745
+ var CHAR_LEFT_CURLY_BRACKET = 123;
2746
+ var CHAR_VERTICAL_LINE = 124;
2747
+ var CHAR_RIGHT_CURLY_BRACKET = 125;
2748
+ var ESCAPE_SEQUENCES = {};
2749
+ ESCAPE_SEQUENCES[0] = "\\0";
2750
+ ESCAPE_SEQUENCES[7] = "\\a";
2751
+ ESCAPE_SEQUENCES[8] = "\\b";
2752
+ ESCAPE_SEQUENCES[9] = "\\t";
2753
+ ESCAPE_SEQUENCES[10] = "\\n";
2754
+ ESCAPE_SEQUENCES[11] = "\\v";
2755
+ ESCAPE_SEQUENCES[12] = "\\f";
2756
+ ESCAPE_SEQUENCES[13] = "\\r";
2757
+ ESCAPE_SEQUENCES[27] = "\\e";
2758
+ ESCAPE_SEQUENCES[34] = '\\"';
2759
+ ESCAPE_SEQUENCES[92] = "\\\\";
2760
+ ESCAPE_SEQUENCES[133] = "\\N";
2761
+ ESCAPE_SEQUENCES[160] = "\\_";
2762
+ ESCAPE_SEQUENCES[8232] = "\\L";
2763
+ ESCAPE_SEQUENCES[8233] = "\\P";
2764
+ var DEPRECATED_BOOLEANS_SYNTAX = [
2765
+ "y",
2766
+ "Y",
2767
+ "yes",
2768
+ "Yes",
2769
+ "YES",
2770
+ "on",
2771
+ "On",
2772
+ "ON",
2773
+ "n",
2774
+ "N",
2775
+ "no",
2776
+ "No",
2777
+ "NO",
2778
+ "off",
2779
+ "Off",
2780
+ "OFF"
2781
+ ];
2782
+ var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
2783
+ function compileStyleMap(schema2, map2) {
2784
+ var result, keys, index, length, tag, style, type2;
2785
+ if (map2 === null)
2786
+ return {};
2787
+ result = {};
2788
+ keys = Object.keys(map2);
2789
+ for (index = 0, length = keys.length; index < length; index += 1) {
2790
+ tag = keys[index];
2791
+ style = String(map2[tag]);
2792
+ if (tag.slice(0, 2) === "!!") {
2793
+ tag = "tag:yaml.org,2002:" + tag.slice(2);
2794
+ }
2795
+ type2 = schema2.compiledTypeMap["fallback"][tag];
2796
+ if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
2797
+ style = type2.styleAliases[style];
2798
+ }
2799
+ result[tag] = style;
2800
+ }
2801
+ return result;
2802
+ }
2803
+ function encodeHex(character) {
2804
+ var string, handle, length;
2805
+ string = character.toString(16).toUpperCase();
2806
+ if (character <= 255) {
2807
+ handle = "x";
2808
+ length = 2;
2809
+ } else if (character <= 65535) {
2810
+ handle = "u";
2811
+ length = 4;
2812
+ } else if (character <= 4294967295) {
2813
+ handle = "U";
2814
+ length = 8;
2815
+ } else {
2816
+ throw new exception("code point within a string may not be greater than 0xFFFFFFFF");
2817
+ }
2818
+ return "\\" + handle + common.repeat("0", length - string.length) + string;
2819
+ }
2820
+ var QUOTING_TYPE_SINGLE = 1;
2821
+ var QUOTING_TYPE_DOUBLE = 2;
2822
+ function State(options) {
2823
+ this.schema = options["schema"] || _default;
2824
+ this.indent = Math.max(1, options["indent"] || 2);
2825
+ this.noArrayIndent = options["noArrayIndent"] || false;
2826
+ this.skipInvalid = options["skipInvalid"] || false;
2827
+ this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
2828
+ this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
2829
+ this.sortKeys = options["sortKeys"] || false;
2830
+ this.lineWidth = options["lineWidth"] || 80;
2831
+ this.noRefs = options["noRefs"] || false;
2832
+ this.noCompatMode = options["noCompatMode"] || false;
2833
+ this.condenseFlow = options["condenseFlow"] || false;
2834
+ this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
2835
+ this.forceQuotes = options["forceQuotes"] || false;
2836
+ this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
2837
+ this.implicitTypes = this.schema.compiledImplicit;
2838
+ this.explicitTypes = this.schema.compiledExplicit;
2839
+ this.tag = null;
2840
+ this.result = "";
2841
+ this.duplicates = [];
2842
+ this.usedDuplicates = null;
2843
+ }
2844
+ function indentString(string, spaces) {
2845
+ var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
2846
+ while (position < length) {
2847
+ next = string.indexOf("\n", position);
2848
+ if (next === -1) {
2849
+ line = string.slice(position);
2850
+ position = length;
2851
+ } else {
2852
+ line = string.slice(position, next + 1);
2853
+ position = next + 1;
2854
+ }
2855
+ if (line.length && line !== "\n")
2856
+ result += ind;
2857
+ result += line;
2858
+ }
2859
+ return result;
2860
+ }
2861
+ function generateNextLine(state, level) {
2862
+ return "\n" + common.repeat(" ", state.indent * level);
2863
+ }
2864
+ function testImplicitResolving(state, str2) {
2865
+ var index, length, type2;
2866
+ for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
2867
+ type2 = state.implicitTypes[index];
2868
+ if (type2.resolve(str2)) {
2869
+ return true;
2870
+ }
2871
+ }
2872
+ return false;
2873
+ }
2874
+ function isWhitespace(c) {
2875
+ return c === CHAR_SPACE || c === CHAR_TAB;
2876
+ }
2877
+ function isPrintable(c) {
2878
+ return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
2879
+ }
2880
+ function isNsCharOrWhitespace(c) {
2881
+ return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
2882
+ }
2883
+ function isPlainSafe(c, prev, inblock) {
2884
+ var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
2885
+ var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
2886
+ return (
2887
+ // ns-plain-safe
2888
+ (inblock ? (
2889
+ // c = flow-in
2890
+ cIsNsCharOrWhitespace
2891
+ ) : cIsNsCharOrWhitespace && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET) && c !== CHAR_SHARP && !(prev === CHAR_COLON && !cIsNsChar) || isNsCharOrWhitespace(prev) && !isWhitespace(prev) && c === CHAR_SHARP || prev === CHAR_COLON && cIsNsChar
316
2892
  );
317
- frontendRuntimeSet.delete("@vercel/python");
318
- frontendRuntimeSet.delete("@vercel/ruby");
319
- frontendRuntimeSet.delete("@vercel/rust");
320
- const toNumber = (build) => build.use === "@vercel/python" || build.use === "@vercel/ruby" || build.use === "@vercel/rust" ? 1 : frontendRuntimeSet.has(build.use) ? 0 : 2;
321
- return builds.sort((build1, build2) => {
322
- return toNumber(build1) - toNumber(build2);
323
- });
324
2893
  }
325
-
326
- // src/util/telemetry/commands/build/index.ts
327
- var BuildTelemetryClient = class extends TelemetryClient {
328
- trackCliOptionOutput(path) {
329
- if (path) {
330
- this.trackCliOption({
331
- option: "output",
332
- value: this.redactedValue
333
- });
2894
+ function isPlainSafeFirst(c) {
2895
+ return isPrintable(c) && c !== CHAR_BOM && !isWhitespace(c) && c !== CHAR_MINUS && c !== CHAR_QUESTION && c !== CHAR_COLON && c !== CHAR_COMMA && c !== CHAR_LEFT_SQUARE_BRACKET && c !== CHAR_RIGHT_SQUARE_BRACKET && c !== CHAR_LEFT_CURLY_BRACKET && c !== CHAR_RIGHT_CURLY_BRACKET && c !== CHAR_SHARP && c !== CHAR_AMPERSAND && c !== CHAR_ASTERISK && c !== CHAR_EXCLAMATION && c !== CHAR_VERTICAL_LINE && c !== CHAR_EQUALS && c !== CHAR_GREATER_THAN && c !== CHAR_SINGLE_QUOTE && c !== CHAR_DOUBLE_QUOTE && c !== CHAR_PERCENT && c !== CHAR_COMMERCIAL_AT && c !== CHAR_GRAVE_ACCENT;
2896
+ }
2897
+ function isPlainSafeLast(c) {
2898
+ return !isWhitespace(c) && c !== CHAR_COLON;
2899
+ }
2900
+ function codePointAt(string, pos) {
2901
+ var first = string.charCodeAt(pos), second;
2902
+ if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
2903
+ second = string.charCodeAt(pos + 1);
2904
+ if (second >= 56320 && second <= 57343) {
2905
+ return (first - 55296) * 1024 + second - 56320 + 65536;
334
2906
  }
335
2907
  }
336
- trackCliOptionTarget(option) {
337
- if (option) {
338
- this.trackCliOption({
339
- option: "target",
340
- value: this.redactedTargetName(option)
341
- });
2908
+ return first;
2909
+ }
2910
+ function needIndentIndicator(string) {
2911
+ var leadingSpaceRe = /^\n* /;
2912
+ return leadingSpaceRe.test(string);
2913
+ }
2914
+ var STYLE_PLAIN = 1;
2915
+ var STYLE_SINGLE = 2;
2916
+ var STYLE_LITERAL = 3;
2917
+ var STYLE_FOLDED = 4;
2918
+ var STYLE_DOUBLE = 5;
2919
+ function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
2920
+ var i;
2921
+ var char = 0;
2922
+ var prevChar = null;
2923
+ var hasLineBreak = false;
2924
+ var hasFoldableLine = false;
2925
+ var shouldTrackWidth = lineWidth !== -1;
2926
+ var previousLineBreak = -1;
2927
+ var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
2928
+ if (singleLineOnly || forceQuotes) {
2929
+ for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
2930
+ char = codePointAt(string, i);
2931
+ if (!isPrintable(char)) {
2932
+ return STYLE_DOUBLE;
2933
+ }
2934
+ plain = plain && isPlainSafe(char, prevChar, inblock);
2935
+ prevChar = char;
342
2936
  }
343
- }
344
- trackCliFlagProd(flag) {
345
- if (flag) {
346
- this.trackCliFlag("prod");
2937
+ } else {
2938
+ for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
2939
+ char = codePointAt(string, i);
2940
+ if (char === CHAR_LINE_FEED) {
2941
+ hasLineBreak = true;
2942
+ if (shouldTrackWidth) {
2943
+ hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
2944
+ i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
2945
+ previousLineBreak = i;
2946
+ }
2947
+ } else if (!isPrintable(char)) {
2948
+ return STYLE_DOUBLE;
2949
+ }
2950
+ plain = plain && isPlainSafe(char, prevChar, inblock);
2951
+ prevChar = char;
347
2952
  }
2953
+ hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
348
2954
  }
349
- trackCliFlagYes(flag) {
350
- if (flag) {
351
- this.trackCliFlag("yes");
2955
+ if (!hasLineBreak && !hasFoldableLine) {
2956
+ if (plain && !forceQuotes && !testAmbiguousType(string)) {
2957
+ return STYLE_PLAIN;
352
2958
  }
2959
+ return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
353
2960
  }
354
- trackCliFlagStandalone(flag) {
355
- if (flag) {
356
- this.trackCliFlag("standalone");
2961
+ if (indentPerLevel > 9 && needIndentIndicator(string)) {
2962
+ return STYLE_DOUBLE;
2963
+ }
2964
+ if (!forceQuotes) {
2965
+ return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
2966
+ }
2967
+ return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
2968
+ }
2969
+ function writeScalar(state, string, level, iskey, inblock) {
2970
+ state.dump = function() {
2971
+ if (string.length === 0) {
2972
+ return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
2973
+ }
2974
+ if (!state.noCompatMode) {
2975
+ if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
2976
+ return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
2977
+ }
357
2978
  }
2979
+ var indent = state.indent * Math.max(1, level);
2980
+ var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent);
2981
+ var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
2982
+ function testAmbiguity(string2) {
2983
+ return testImplicitResolving(state, string2);
2984
+ }
2985
+ switch (chooseScalarStyle(
2986
+ string,
2987
+ singleLineOnly,
2988
+ state.indent,
2989
+ lineWidth,
2990
+ testAmbiguity,
2991
+ state.quotingType,
2992
+ state.forceQuotes && !iskey,
2993
+ inblock
2994
+ )) {
2995
+ case STYLE_PLAIN:
2996
+ return string;
2997
+ case STYLE_SINGLE:
2998
+ return "'" + string.replace(/'/g, "''") + "'";
2999
+ case STYLE_LITERAL:
3000
+ return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent));
3001
+ case STYLE_FOLDED:
3002
+ return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent));
3003
+ case STYLE_DOUBLE:
3004
+ return '"' + escapeString(string) + '"';
3005
+ default:
3006
+ throw new exception("impossible error: invalid scalar style");
3007
+ }
3008
+ }();
3009
+ }
3010
+ function blockHeader(string, indentPerLevel) {
3011
+ var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
3012
+ var clip = string[string.length - 1] === "\n";
3013
+ var keep = clip && (string[string.length - 2] === "\n" || string === "\n");
3014
+ var chomp = keep ? "+" : clip ? "" : "-";
3015
+ return indentIndicator + chomp + "\n";
3016
+ }
3017
+ function dropEndingNewline(string) {
3018
+ return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
3019
+ }
3020
+ function foldString(string, width) {
3021
+ var lineRe = /(\n+)([^\n]*)/g;
3022
+ var result = function() {
3023
+ var nextLF = string.indexOf("\n");
3024
+ nextLF = nextLF !== -1 ? nextLF : string.length;
3025
+ lineRe.lastIndex = nextLF;
3026
+ return foldLine(string.slice(0, nextLF), width);
3027
+ }();
3028
+ var prevMoreIndented = string[0] === "\n" || string[0] === " ";
3029
+ var moreIndented;
3030
+ var match;
3031
+ while (match = lineRe.exec(string)) {
3032
+ var prefix = match[1], line = match[2];
3033
+ moreIndented = line[0] === " ";
3034
+ result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
3035
+ prevMoreIndented = moreIndented;
358
3036
  }
359
- trackCliOptionId(id) {
360
- if (id) {
361
- this.trackCliOption({
362
- option: "id",
363
- value: this.redactedValue
364
- });
3037
+ return result;
3038
+ }
3039
+ function foldLine(line, width) {
3040
+ if (line === "" || line[0] === " ")
3041
+ return line;
3042
+ var breakRe = / [^ ]/g;
3043
+ var match;
3044
+ var start = 0, end, curr = 0, next = 0;
3045
+ var result = "";
3046
+ while (match = breakRe.exec(line)) {
3047
+ next = match.index;
3048
+ if (next - start > width) {
3049
+ end = curr > start ? curr : next;
3050
+ result += "\n" + line.slice(start, end);
3051
+ start = end + 1;
365
3052
  }
3053
+ curr = next;
366
3054
  }
367
- };
368
-
369
- // src/util/validate-cron-secret.ts
370
- import { NowBuildError } from "@vercel/build-utils";
371
- function validateCronSecret(cronSecret) {
372
- if (!cronSecret) {
373
- return null;
3055
+ result += "\n";
3056
+ if (line.length - start > width && curr > start) {
3057
+ result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
3058
+ } else {
3059
+ result += line.slice(start);
374
3060
  }
375
- if (cronSecret !== cronSecret.trim()) {
376
- return new NowBuildError({
377
- code: "INVALID_CRON_SECRET",
378
- message: "The `CRON_SECRET` environment variable contains leading or trailing whitespace, which is not allowed in HTTP header values.",
379
- link: "https://vercel.link/securing-cron-jobs",
380
- action: "Learn More"
381
- });
3061
+ return result.slice(1);
3062
+ }
3063
+ function escapeString(string) {
3064
+ var result = "";
3065
+ var char = 0;
3066
+ var escapeSeq;
3067
+ for (var i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
3068
+ char = codePointAt(string, i);
3069
+ escapeSeq = ESCAPE_SEQUENCES[char];
3070
+ if (!escapeSeq && isPrintable(char)) {
3071
+ result += string[i];
3072
+ if (char >= 65536)
3073
+ result += string[i + 1];
3074
+ } else {
3075
+ result += escapeSeq || encodeHex(char);
3076
+ }
382
3077
  }
383
- const invalidChars = [];
384
- for (let i = 0; i < cronSecret.length; i++) {
385
- const code = cronSecret.charCodeAt(i);
386
- const isValidChar = code === 9 || // HTAB
387
- code >= 32 && code <= 126;
388
- if (!isValidChar) {
389
- invalidChars.push({
390
- char: cronSecret[i],
391
- index: i,
392
- code
393
- });
3078
+ return result;
3079
+ }
3080
+ function writeFlowSequence(state, level, object) {
3081
+ var _result = "", _tag = state.tag, index, length, value;
3082
+ for (index = 0, length = object.length; index < length; index += 1) {
3083
+ value = object[index];
3084
+ if (state.replacer) {
3085
+ value = state.replacer.call(object, String(index), value);
3086
+ }
3087
+ if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
3088
+ if (_result !== "")
3089
+ _result += "," + (!state.condenseFlow ? " " : "");
3090
+ _result += state.dump;
394
3091
  }
395
3092
  }
396
- if (invalidChars.length > 0) {
397
- const descriptions = invalidChars.slice(0, 3).map(({ code, index }) => {
398
- if (code < 32) {
399
- return `control character (0x${code.toString(16).padStart(2, "0")}) at position ${index}`;
400
- } else if (code === 127) {
401
- return `DEL character at position ${index}`;
3093
+ state.tag = _tag;
3094
+ state.dump = "[" + _result + "]";
3095
+ }
3096
+ function writeBlockSequence(state, level, object, compact) {
3097
+ var _result = "", _tag = state.tag, index, length, value;
3098
+ for (index = 0, length = object.length; index < length; index += 1) {
3099
+ value = object[index];
3100
+ if (state.replacer) {
3101
+ value = state.replacer.call(object, String(index), value);
3102
+ }
3103
+ if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
3104
+ if (!compact || _result !== "") {
3105
+ _result += generateNextLine(state, level);
3106
+ }
3107
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
3108
+ _result += "-";
402
3109
  } else {
403
- return `non-ASCII character (0x${code.toString(16).padStart(2, "0")}) at position ${index}`;
3110
+ _result += "- ";
404
3111
  }
405
- });
406
- const moreCount = invalidChars.length - 3;
407
- const moreText = moreCount > 0 ? `, and ${moreCount} more` : "";
408
- return new NowBuildError({
409
- code: "INVALID_CRON_SECRET",
410
- message: `The \`CRON_SECRET\` environment variable contains characters that are not valid in HTTP headers: ${descriptions.join(", ")}${moreText}. Only visible ASCII characters (letters, digits, symbols), spaces, and tabs are allowed.`,
411
- link: "https://vercel.link/securing-cron-jobs",
412
- action: "Learn More"
413
- });
3112
+ _result += state.dump;
3113
+ }
414
3114
  }
415
- return null;
3115
+ state.tag = _tag;
3116
+ state.dump = _result || "[]";
416
3117
  }
417
-
418
- // src/util/validate-package-manifest.ts
419
- var import_ajv = __toESM(require_ajv(), 1);
420
- import { packageManifestSchema } from "@vercel/build-utils";
421
- var ajv = new import_ajv.default();
422
- var validate = ajv.compile(packageManifestSchema);
423
- function validatePackageManifest(data) {
424
- if (validate(data)) {
425
- return null;
3118
+ function writeFlowMapping(state, level, object) {
3119
+ var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
3120
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
3121
+ pairBuffer = "";
3122
+ if (_result !== "")
3123
+ pairBuffer += ", ";
3124
+ if (state.condenseFlow)
3125
+ pairBuffer += '"';
3126
+ objectKey = objectKeyList[index];
3127
+ objectValue = object[objectKey];
3128
+ if (state.replacer) {
3129
+ objectValue = state.replacer.call(object, objectKey, objectValue);
3130
+ }
3131
+ if (!writeNode(state, level, objectKey, false, false)) {
3132
+ continue;
3133
+ }
3134
+ if (state.dump.length > 1024)
3135
+ pairBuffer += "? ";
3136
+ pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
3137
+ if (!writeNode(state, level, objectValue, false, false)) {
3138
+ continue;
3139
+ }
3140
+ pairBuffer += state.dump;
3141
+ _result += pairBuffer;
426
3142
  }
427
- const errors = validate.errors ?? [];
428
- return errors.map((e) => `${e.dataPath || "(root)"} ${e.message}`).join("; ");
3143
+ state.tag = _tag;
3144
+ state.dump = "{" + _result + "}";
429
3145
  }
430
-
431
- // src/util/flags/build-embedding.ts
432
- import { isPackageInstalled } from "@vercel/build-utils";
433
- function isFlagsEmbedOption(input) {
434
- return input === "force-on" || input === "force-off";
3146
+ function writeBlockMapping(state, level, object, compact) {
3147
+ var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
3148
+ if (state.sortKeys === true) {
3149
+ objectKeyList.sort();
3150
+ } else if (typeof state.sortKeys === "function") {
3151
+ objectKeyList.sort(state.sortKeys);
3152
+ } else if (state.sortKeys) {
3153
+ throw new exception("sortKeys must be a boolean or a function");
3154
+ }
3155
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
3156
+ pairBuffer = "";
3157
+ if (!compact || _result !== "") {
3158
+ pairBuffer += generateNextLine(state, level);
3159
+ }
3160
+ objectKey = objectKeyList[index];
3161
+ objectValue = object[objectKey];
3162
+ if (state.replacer) {
3163
+ objectValue = state.replacer.call(object, objectKey, objectValue);
3164
+ }
3165
+ if (!writeNode(state, level + 1, objectKey, true, true, true)) {
3166
+ continue;
3167
+ }
3168
+ explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
3169
+ if (explicitPair) {
3170
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
3171
+ pairBuffer += "?";
3172
+ } else {
3173
+ pairBuffer += "? ";
3174
+ }
3175
+ }
3176
+ pairBuffer += state.dump;
3177
+ if (explicitPair) {
3178
+ pairBuffer += generateNextLine(state, level);
3179
+ }
3180
+ if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
3181
+ continue;
3182
+ }
3183
+ if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
3184
+ pairBuffer += ":";
3185
+ } else {
3186
+ pairBuffer += ": ";
3187
+ }
3188
+ pairBuffer += state.dump;
3189
+ _result += pairBuffer;
3190
+ }
3191
+ state.tag = _tag;
3192
+ state.dump = _result || "{}";
435
3193
  }
436
- var SDK_KEY_REGEX = /^vf_(?:server|client)_/;
437
- function envHasSdkKey() {
438
- for (const value of Object.values(process.env)) {
439
- if (typeof value === "string" && SDK_KEY_REGEX.test(value)) {
3194
+ function detectType(state, object, explicit) {
3195
+ var _result, typeList, index, length, type2, style;
3196
+ typeList = explicit ? state.explicitTypes : state.implicitTypes;
3197
+ for (index = 0, length = typeList.length; index < length; index += 1) {
3198
+ type2 = typeList[index];
3199
+ if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object === "object" && object instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object))) {
3200
+ if (explicit) {
3201
+ if (type2.multi && type2.representName) {
3202
+ state.tag = type2.representName(object);
3203
+ } else {
3204
+ state.tag = type2.tag;
3205
+ }
3206
+ } else {
3207
+ state.tag = "?";
3208
+ }
3209
+ if (type2.represent) {
3210
+ style = state.styleMap[type2.tag] || type2.defaultStyle;
3211
+ if (_toString.call(type2.represent) === "[object Function]") {
3212
+ _result = type2.represent(object, style);
3213
+ } else if (_hasOwnProperty.call(type2.represent, style)) {
3214
+ _result = type2.represent[style](object, style);
3215
+ } else {
3216
+ throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
3217
+ }
3218
+ state.dump = _result;
3219
+ }
440
3220
  return true;
441
3221
  }
442
3222
  }
3223
+ return false;
443
3224
  }
444
- async function shouldEmbedFlagsDefinitions(cwd) {
445
- if (process.env.VERCEL_FLAGS_DISABLE_DEFINITION_EMBEDDING === "1") {
446
- return false;
3225
+ function writeNode(state, level, object, block, compact, iskey, isblockseq) {
3226
+ state.tag = null;
3227
+ state.dump = object;
3228
+ if (!detectType(state, object, false)) {
3229
+ detectType(state, object, true);
447
3230
  }
448
- if (isFlagsEmbedOption(process.env.VERCEL_FLAGS_EMBED_DEFINITIONS)) {
449
- return process.env.VERCEL_FLAGS_EMBED_DEFINITIONS === "force-on";
3231
+ var type2 = _toString.call(state.dump);
3232
+ var inblock = block;
3233
+ var tagStr;
3234
+ if (block) {
3235
+ block = state.flowLevel < 0 || state.flowLevel > level;
450
3236
  }
451
- if (envHasSdkKey()) {
452
- return true;
3237
+ var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate;
3238
+ if (objectOrArray) {
3239
+ duplicateIndex = state.duplicates.indexOf(object);
3240
+ duplicate = duplicateIndex !== -1;
453
3241
  }
454
- const hasVercelFlags = await isPackageInstalled("@flags-sdk/vercel", cwd);
455
- const hasFlagsCore = await isPackageInstalled("@vercel/flags-core", cwd);
456
- if (hasVercelFlags || hasFlagsCore) {
457
- return true;
3242
+ if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
3243
+ compact = false;
458
3244
  }
459
- return false;
3245
+ if (duplicate && state.usedDuplicates[duplicateIndex]) {
3246
+ state.dump = "*ref_" + duplicateIndex;
3247
+ } else {
3248
+ if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
3249
+ state.usedDuplicates[duplicateIndex] = true;
3250
+ }
3251
+ if (type2 === "[object Object]") {
3252
+ if (block && Object.keys(state.dump).length !== 0) {
3253
+ writeBlockMapping(state, level, state.dump, compact);
3254
+ if (duplicate) {
3255
+ state.dump = "&ref_" + duplicateIndex + state.dump;
3256
+ }
3257
+ } else {
3258
+ writeFlowMapping(state, level, state.dump);
3259
+ if (duplicate) {
3260
+ state.dump = "&ref_" + duplicateIndex + " " + state.dump;
3261
+ }
3262
+ }
3263
+ } else if (type2 === "[object Array]") {
3264
+ if (block && state.dump.length !== 0) {
3265
+ if (state.noArrayIndent && !isblockseq && level > 0) {
3266
+ writeBlockSequence(state, level - 1, state.dump, compact);
3267
+ } else {
3268
+ writeBlockSequence(state, level, state.dump, compact);
3269
+ }
3270
+ if (duplicate) {
3271
+ state.dump = "&ref_" + duplicateIndex + state.dump;
3272
+ }
3273
+ } else {
3274
+ writeFlowSequence(state, level, state.dump);
3275
+ if (duplicate) {
3276
+ state.dump = "&ref_" + duplicateIndex + " " + state.dump;
3277
+ }
3278
+ }
3279
+ } else if (type2 === "[object String]") {
3280
+ if (state.tag !== "?") {
3281
+ writeScalar(state, state.dump, level, iskey, inblock);
3282
+ }
3283
+ } else if (type2 === "[object Undefined]") {
3284
+ return false;
3285
+ } else {
3286
+ if (state.skipInvalid)
3287
+ return false;
3288
+ throw new exception("unacceptable kind of an object to dump " + type2);
3289
+ }
3290
+ if (state.tag !== null && state.tag !== "?") {
3291
+ tagStr = encodeURI(
3292
+ state.tag[0] === "!" ? state.tag.slice(1) : state.tag
3293
+ ).replace(/!/g, "%21");
3294
+ if (state.tag[0] === "!") {
3295
+ tagStr = "!" + tagStr;
3296
+ } else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
3297
+ tagStr = "!!" + tagStr.slice(18);
3298
+ } else {
3299
+ tagStr = "!<" + tagStr + ">";
3300
+ }
3301
+ state.dump = tagStr + " " + state.dump;
3302
+ }
3303
+ }
3304
+ return true;
460
3305
  }
461
-
462
- // src/util/build/repo-root.ts
463
- import { existsSync, readFileSync } from "fs";
464
- import { dirname, join as join2, parse, relative as relative2 } from "path";
465
- function resolveRepoRoot({ cwd }) {
466
- const workspaceRoot = findWorkspaceRoot(cwd);
467
- if (workspaceRoot) {
468
- return workspaceRoot;
3306
+ function getDuplicateReferences(object, state) {
3307
+ var objects = [], duplicatesIndexes = [], index, length;
3308
+ inspectNode(object, objects, duplicatesIndexes);
3309
+ for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
3310
+ state.duplicates.push(objects[duplicatesIndexes[index]]);
3311
+ }
3312
+ state.usedDuplicates = new Array(length);
3313
+ }
3314
+ function inspectNode(object, objects, duplicatesIndexes) {
3315
+ var objectKeyList, index, length;
3316
+ if (object !== null && typeof object === "object") {
3317
+ index = objects.indexOf(object);
3318
+ if (index !== -1) {
3319
+ if (duplicatesIndexes.indexOf(index) === -1) {
3320
+ duplicatesIndexes.push(index);
3321
+ }
3322
+ } else {
3323
+ objects.push(object);
3324
+ if (Array.isArray(object)) {
3325
+ for (index = 0, length = object.length; index < length; index += 1) {
3326
+ inspectNode(object[index], objects, duplicatesIndexes);
3327
+ }
3328
+ } else {
3329
+ objectKeyList = Object.keys(object);
3330
+ for (index = 0, length = objectKeyList.length; index < length; index += 1) {
3331
+ inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
3332
+ }
3333
+ }
3334
+ }
469
3335
  }
470
- const gitRoot = getGitRootDirectory({ cwd });
471
- if (gitRoot) {
472
- return gitRoot;
3336
+ }
3337
+ function dump$1(input, options) {
3338
+ options = options || {};
3339
+ var state = new State(options);
3340
+ if (!state.noRefs)
3341
+ getDuplicateReferences(input, state);
3342
+ var value = input;
3343
+ if (state.replacer) {
3344
+ value = state.replacer.call({ "": value }, "", value);
473
3345
  }
474
- return cwd;
3346
+ if (writeNode(state, 0, value, true, true))
3347
+ return state.dump + "\n";
3348
+ return "";
3349
+ }
3350
+ var dump_1 = dump$1;
3351
+ var dumper = {
3352
+ dump: dump_1
3353
+ };
3354
+ function renamed(from, to) {
3355
+ return function() {
3356
+ throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
3357
+ };
475
3358
  }
476
- function findWorkspaceRoot(startDir) {
3359
+ var Type = type;
3360
+ var Schema = schema;
3361
+ var FAILSAFE_SCHEMA = failsafe;
3362
+ var JSON_SCHEMA = json;
3363
+ var CORE_SCHEMA = core;
3364
+ var DEFAULT_SCHEMA = _default;
3365
+ var load = loader.load;
3366
+ var loadAll = loader.loadAll;
3367
+ var dump = dumper.dump;
3368
+ var YAMLException = exception;
3369
+ var types = {
3370
+ binary,
3371
+ float,
3372
+ map,
3373
+ null: _null,
3374
+ pairs,
3375
+ set,
3376
+ timestamp,
3377
+ bool,
3378
+ int,
3379
+ merge,
3380
+ omap,
3381
+ seq,
3382
+ str
3383
+ };
3384
+ var safeLoad = renamed("safeLoad", "load");
3385
+ var safeLoadAll = renamed("safeLoadAll", "loadAll");
3386
+ var safeDump = renamed("safeDump", "dump");
3387
+ var jsYaml = {
3388
+ Type,
3389
+ Schema,
3390
+ FAILSAFE_SCHEMA,
3391
+ JSON_SCHEMA,
3392
+ CORE_SCHEMA,
3393
+ DEFAULT_SCHEMA,
3394
+ load,
3395
+ loadAll,
3396
+ dump,
3397
+ YAMLException,
3398
+ types,
3399
+ safeLoad,
3400
+ safeLoadAll,
3401
+ safeDump
3402
+ };
3403
+ var js_yaml_default = jsYaml;
3404
+
3405
+ // src/util/build/repo-root.ts
3406
+ var import_minimatch = __toESM(require_minimatch(), 1);
3407
+ function findWorkspaceRootCandidates(startDir) {
477
3408
  const { root } = parse(startDir);
3409
+ const candidates = [];
478
3410
  let dir = startDir;
479
- let highestMatch = null;
480
3411
  for (let i = 0; i < 64; i++) {
481
- if (isWorkspaceRoot(dir)) {
482
- highestMatch = dir;
3412
+ const type2 = workspaceTypeOf(dir);
3413
+ if (type2) {
3414
+ candidates.unshift({ dir, type: type2 });
483
3415
  }
484
3416
  if (dir === root)
485
3417
  break;
@@ -488,27 +3420,76 @@ function findWorkspaceRoot(startDir) {
488
3420
  break;
489
3421
  dir = parent;
490
3422
  }
491
- return highestMatch;
3423
+ return candidates;
492
3424
  }
493
- function isWorkspaceRoot(dir) {
494
- if (existsSync(join2(dir, "pnpm-workspace.yaml")) || existsSync(join2(dir, "lerna.json")) || existsSync(join2(dir, "rush.json"))) {
495
- return true;
3425
+ function workspaceTypeOf(dir) {
3426
+ if (existsSync(join3(dir, "pnpm-workspace.yaml"))) {
3427
+ return "pnpm";
496
3428
  }
497
- const pkgPath = join2(dir, "package.json");
3429
+ const pkgPath = join3(dir, "package.json");
498
3430
  if (existsSync(pkgPath)) {
499
3431
  try {
500
3432
  const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
501
3433
  const { workspaces } = pkg;
502
3434
  if (Array.isArray(workspaces) && workspaces.length > 0 || workspaces && typeof workspaces === "object" && Array.isArray(workspaces.packages) && workspaces.packages.length > 0) {
503
- return true;
3435
+ return "npm";
504
3436
  }
505
3437
  } catch {
506
3438
  }
507
3439
  }
508
- return false;
3440
+ return null;
3441
+ }
3442
+ function readWorkspacePatterns(candidate) {
3443
+ try {
3444
+ if (candidate.type === "pnpm") {
3445
+ const doc = js_yaml_default.load(
3446
+ readFileSync(join3(candidate.dir, "pnpm-workspace.yaml"), "utf8")
3447
+ );
3448
+ const packages2 = doc?.packages;
3449
+ return Array.isArray(packages2) ? packages2.filter((p) => typeof p === "string") : null;
3450
+ }
3451
+ const pkg = JSON.parse(
3452
+ readFileSync(join3(candidate.dir, "package.json"), "utf8")
3453
+ );
3454
+ const { workspaces } = pkg;
3455
+ const packages = Array.isArray(workspaces) ? workspaces : workspaces?.packages;
3456
+ return Array.isArray(packages) ? packages.filter((p) => typeof p === "string") : null;
3457
+ } catch {
3458
+ return null;
3459
+ }
3460
+ }
3461
+ function workspaceClaims(candidate, memberDir) {
3462
+ const rel = normalizeRelative(relative2(candidate.dir, memberDir));
3463
+ if (rel === "") {
3464
+ return false;
3465
+ }
3466
+ const patterns = readWorkspacePatterns(candidate);
3467
+ if (!patterns || patterns.length === 0) {
3468
+ return false;
3469
+ }
3470
+ const positives = [];
3471
+ const negatives = [];
3472
+ for (const pattern of patterns) {
3473
+ if (pattern.startsWith("!")) {
3474
+ negatives.push(normalizeRelative(pattern.slice(1)));
3475
+ } else {
3476
+ positives.push(normalizeRelative(pattern));
3477
+ }
3478
+ }
3479
+ const matches = (pattern) => (0, import_minimatch.default)(rel, pattern, { dot: false });
3480
+ if (!positives.some(matches) || negatives.some(matches)) {
3481
+ return false;
3482
+ }
3483
+ return existsSync(join3(memberDir, "package.json"));
509
3484
  }
510
3485
  function resolvePerDirectoryLinkRoot(anchorDir, rootDirectorySetting) {
511
- const repoRoot = resolveRepoRoot({ cwd: anchorDir });
3486
+ let repoRoot = anchorDir;
3487
+ for (const candidate of findWorkspaceRootCandidates(anchorDir)) {
3488
+ if (workspaceClaims(candidate, anchorDir)) {
3489
+ repoRoot = candidate.dir;
3490
+ break;
3491
+ }
3492
+ }
512
3493
  const linkLocation = normalizeRelative(relative2(repoRoot, anchorDir));
513
3494
  if (linkLocation === "") {
514
3495
  return { repoRoot, resolvedRootDirectory: "" };
@@ -517,27 +3498,27 @@ function resolvePerDirectoryLinkRoot(anchorDir, rootDirectorySetting) {
517
3498
  if (setting === "") {
518
3499
  return { repoRoot, resolvedRootDirectory: linkLocation };
519
3500
  }
520
- if (existsSync(join2(anchorDir, setting))) {
3501
+ if (existsSync(join3(anchorDir, setting))) {
521
3502
  return {
522
3503
  repoRoot,
523
3504
  resolvedRootDirectory: normalizeRelative(
524
- relative2(repoRoot, join2(anchorDir, setting))
3505
+ relative2(repoRoot, join3(anchorDir, setting))
525
3506
  )
526
3507
  };
527
3508
  }
528
3509
  return {
529
3510
  repoRoot,
530
3511
  resolvedRootDirectory: linkLocation,
531
- advisory: `Ignoring "rootDirectory" setting "${setting}" for the project linked in "${anchorDir}": "${join2(anchorDir, setting)}" does not exist, so the build will use the linked directory "${linkLocation}" instead. Remove the "rootDirectory" setting, or configure it at the repository root.`
3512
+ advisory: `Ignoring "rootDirectory" setting "${setting}" for the project linked in "${anchorDir}": "${join3(anchorDir, setting)}" does not exist, so the build will use the linked directory "${linkLocation}" instead. Remove the "rootDirectory" setting, or configure it at the repository root.`
532
3513
  };
533
3514
  }
534
3515
  function normalizeRelative(p) {
535
- const normalized = p.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+$/, "");
3516
+ const normalized = p.replace(/\\/g, "/").replace(/^\.\//, "").replace(/^\/+/, "").replace(/\/+$/, "");
536
3517
  return normalized === "." ? "" : normalized;
537
3518
  }
538
3519
 
539
3520
  // src/commands/build/manifest.ts
540
- import { join as join3 } from "path";
3521
+ import { join as join4 } from "path";
541
3522
  import {
542
3523
  FileBlob,
543
3524
  downloadFile,
@@ -580,7 +3561,7 @@ async function writeManifests(packageManifests, diagnostics, ops, outputDir) {
580
3561
  ops.push(
581
3562
  downloadFile(
582
3563
  projectManifestBlob,
583
- join3(outputDir, "diagnostics", "project-manifest.json")
3564
+ join4(outputDir, "diagnostics", "project-manifest.json")
584
3565
  ).then(
585
3566
  () => void 0,
586
3567
  (err) => err
@@ -596,7 +3577,7 @@ async function writeManifests(packageManifests, diagnostics, ops, outputDir) {
596
3577
  ops.push(
597
3578
  downloadFile(
598
3579
  deployManifestBlob,
599
- join3(outputDir, "diagnostics", "deploy-manifest.json")
3580
+ join4(outputDir, "diagnostics", "deploy-manifest.json")
600
3581
  ).then(
601
3582
  () => void 0,
602
3583
  (err) => err
@@ -721,7 +3702,7 @@ async function main(client) {
721
3702
  if (link?.repoRoot) {
722
3703
  cwd = client.cwd = link.repoRoot;
723
3704
  }
724
- const vercelDir = join4(cwd, projectRootDirectory, VERCEL_DIR);
3705
+ const vercelDir = join5(cwd, projectRootDirectory, VERCEL_DIR);
725
3706
  let project = await rootSpan.child("vc.readProjectSettings").trace(() => readProjectSettings(vercelDir));
726
3707
  const isTTY = process.stdin.isTTY;
727
3708
  while (!project?.settings) {
@@ -777,7 +3758,7 @@ async function main(client) {
777
3758
  return 0;
778
3759
  }
779
3760
  const { argv: originalArgv } = client;
780
- client.cwd = join4(cwd, projectRootDirectory);
3761
+ client.cwd = join5(cwd, projectRootDirectory);
781
3762
  client.setArgv([
782
3763
  ...originalArgv.slice(0, 2),
783
3764
  "pull",
@@ -799,7 +3780,7 @@ async function main(client) {
799
3780
  client.setArgv(originalArgv);
800
3781
  project = await readProjectSettings(vercelDir);
801
3782
  }
802
- if (!hasRepoLevelLink && link && project?.settings && process.env.VERCEL_RESOLVE_ROOT_DIRECTORY === "1") {
3783
+ if (!hasRepoLevelLink && link && project?.settings) {
803
3784
  const resolved = resolvePerDirectoryLinkRoot(
804
3785
  invokedCwd,
805
3786
  project.settings.rootDirectory
@@ -813,17 +3794,17 @@ async function main(client) {
813
3794
  cwd = client.cwd = resolved.repoRoot;
814
3795
  }
815
3796
  }
816
- const defaultOutputDir = join4(cwd, projectRootDirectory, OUTPUT_DIR);
3797
+ const defaultOutputDir = join5(cwd, projectRootDirectory, OUTPUT_DIR);
817
3798
  const outputDir = parsedArgs.flags["--output"] ? resolve(parsedArgs.flags["--output"]) : defaultOutputDir;
818
- client.traceDiagnosticsPath = join4(
3799
+ client.traceDiagnosticsPath = join5(
819
3800
  outputDir,
820
3801
  "diagnostics",
821
3802
  "cli_traces.json"
822
3803
  );
823
3804
  await Promise.all([
824
- import_fs_extra2.default.remove(outputDir),
3805
+ import_fs_extra3.default.remove(outputDir),
825
3806
  // Also delete `.vercel/output`, in case the script is targeting Build Output API directly
826
- outputDir !== defaultOutputDir ? import_fs_extra2.default.remove(defaultOutputDir) : void 0
3807
+ outputDir !== defaultOutputDir ? import_fs_extra3.default.remove(defaultOutputDir) : void 0
827
3808
  ]);
828
3809
  const buildsJson = {
829
3810
  "//": "This file was generated by the `vercel build` command. It is not part of the Build Output API.",
@@ -860,7 +3841,7 @@ async function main(client) {
860
3841
  `Loaded ${Object.keys(buildEnv).length} environment variables from deployment ${deploymentId}`
861
3842
  );
862
3843
  } else {
863
- const envPath = join4(
3844
+ const envPath = join5(
864
3845
  cwd,
865
3846
  projectRootDirectory,
866
3847
  VERCEL_DIR,
@@ -951,12 +3932,12 @@ async function main(client) {
951
3932
  }
952
3933
  output_manager_default.prettyError(err);
953
3934
  buildsJson.error = toEnumerableError(err);
954
- const buildsJsonPath = join4(outputDir, "builds.json");
955
- const configJsonPath = join4(outputDir, "config.json");
956
- await import_fs_extra2.default.outputJSON(buildsJsonPath, buildsJson, {
3935
+ const buildsJsonPath = join5(outputDir, "builds.json");
3936
+ const configJsonPath = join5(outputDir, "config.json");
3937
+ await import_fs_extra3.default.outputJSON(buildsJsonPath, buildsJson, {
957
3938
  spaces: 2
958
3939
  });
959
- await import_fs_extra2.default.writeJSON(configJsonPath, { version: 3 }, { spaces: 2 });
3940
+ await import_fs_extra3.default.writeJSON(configJsonPath, { version: 3 }, { spaces: 2 });
960
3941
  return 1;
961
3942
  } finally {
962
3943
  for (const key of envToUnset) {
@@ -969,7 +3950,7 @@ async function main(client) {
969
3950
  async function doBuild(client, project, buildsJson, cwd, outputDir, span, standalone = false) {
970
3951
  const { localConfigPath } = client;
971
3952
  const VALID_DEPLOYMENT_ID_PATTERN = /^[a-zA-Z0-9_-]+$/;
972
- const workPath = join4(cwd, project.settings.rootDirectory || ".");
3953
+ const workPath = join5(cwd, project.settings.rootDirectory || ".");
973
3954
  const repoRootPath = cwd;
974
3955
  const sourceConfigFile = await findSourceVercelConfigFile(workPath);
975
3956
  let corepackShimDir;
@@ -1006,11 +3987,11 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1006
3987
  process.env.VERCEL_INSTALL_COMPLETED = "1";
1007
3988
  }
1008
3989
  const compileResult = await span.child("vc.compileVercelConfig").trace(() => compileVercelConfig(workPath));
1009
- const vercelConfigPath = localConfigPath || compileResult.configPath || join4(workPath, "vercel.json");
3990
+ const vercelConfigPath = localConfigPath || compileResult.configPath || join5(workPath, "vercel.json");
1010
3991
  const [pkg, vercelConfig, hasInstrumentation] = await Promise.all([
1011
- readJSONFile(join4(workPath, "package.json")),
3992
+ readJSONFile(join5(workPath, "package.json")),
1012
3993
  readJSONFile(vercelConfigPath),
1013
- (0, import_fs_detectors2.detectInstrumentation)(new import_fs_detectors2.LocalFileSystemDetector(workPath))
3994
+ (0, import_fs_detectors3.detectInstrumentation)(new import_fs_detectors3.LocalFileSystemDetector(workPath))
1014
3995
  ]);
1015
3996
  if (pkg instanceof CantParseJSONFile)
1016
3997
  throw pkg;
@@ -1040,6 +4021,22 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1040
4021
  ...project.settings,
1041
4022
  ...pickOverrides(localConfig)
1042
4023
  };
4024
+ buildsJson.detectedFramework = await span.child("vc.detectFirstDeploymentFramework", {
4025
+ enabled: String(isFrameworkDetectionEnabled()),
4026
+ firstDeployment: String(process.env.VERCEL_FIRST_DEPLOYMENT === "1"),
4027
+ configuredFramework: projectSettings.framework ?? void 0
4028
+ }).trace(async (s) => {
4029
+ const result = await detectFirstDeploymentFramework({
4030
+ workPath,
4031
+ projectSettings
4032
+ });
4033
+ s.setAttributes({
4034
+ detectionStatus: result.status,
4035
+ detectedFramework: result.slug,
4036
+ detectedFrameworkVersion: result.version
4037
+ });
4038
+ return result;
4039
+ });
1043
4040
  if (process.env.VERCEL_BUILD_MONOREPO_SUPPORT === "1" && pkg?.scripts?.["vercel-build"] === void 0 && projectSettings.rootDirectory !== null && projectSettings.rootDirectory !== ".") {
1044
4041
  await setMonorepoDefaultSettings(cwd, workPath, projectSettings);
1045
4042
  }
@@ -1055,6 +4052,27 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1055
4052
  const files = (await staticFiles(workPath, {})).map(
1056
4053
  (f) => normalizePath(relative3(workPath, f))
1057
4054
  );
4055
+ const detectedFrameworksPromise = span.child("vc.detectAllFrameworks", {
4056
+ enabled: String(isFrameworkDetectionEnabled())
4057
+ }).trace(async (s) => {
4058
+ if (!isFrameworkDetectionEnabled()) {
4059
+ return [];
4060
+ }
4061
+ try {
4062
+ const slugs = await detectAllFrameworks(workPath);
4063
+ s.setAttributes({
4064
+ detectedFrameworks: slugs.join(",") || void 0,
4065
+ detectedFrameworkCount: String(slugs.length)
4066
+ });
4067
+ return slugs;
4068
+ } catch (err) {
4069
+ output_manager_default.debug(`Framework cross-check detection failed: ${err}`);
4070
+ s.setAttributes({
4071
+ error: err instanceof Error ? err.message : String(err)
4072
+ });
4073
+ return [];
4074
+ }
4075
+ });
1058
4076
  const routesResult = (0, import_routing_utils2.getTransformedRoutes)(localConfig);
1059
4077
  if (routesResult.error) {
1060
4078
  throw routesResult.error;
@@ -1092,7 +4110,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1092
4110
  } else {
1093
4111
  isZeroConfig = true;
1094
4112
  const detectedBuilders = await span.child("vc.detectBuilders").trace(
1095
- () => (0, import_fs_detectors2.detectBuilders)(files, pkg, {
4113
+ () => (0, import_fs_detectors3.detectBuilders)(files, pkg, {
1096
4114
  ...localConfig,
1097
4115
  services: void 0,
1098
4116
  experimentalServicesV2: configuredExperimentalServicesV2,
@@ -1124,7 +4142,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1124
4142
  if (detectedBuilders.useImplicitEnvInjection && detectedServices && detectedServices.length > 0) {
1125
4143
  const serviceUrlEnvVars = getExperimentalServiceUrlEnvVars({
1126
4144
  services: detectedServices,
1127
- frameworkList: import_frameworks2.frameworkList,
4145
+ frameworkList: import_frameworks3.frameworkList,
1128
4146
  currentEnv: process.env,
1129
4147
  deploymentUrl: process.env.VERCEL_URL
1130
4148
  });
@@ -1167,12 +4185,12 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1167
4185
  let buildersWithPkgs = await span.child("vc.importBuilders").trace(() => importBuilders(builderSpecs, cwd, span));
1168
4186
  const filesMap = {};
1169
4187
  for (const path of files) {
1170
- const fsPath = join4(workPath, path);
1171
- const { mode } = await import_fs_extra2.default.stat(fsPath);
4188
+ const fsPath = join5(workPath, path);
4189
+ const { mode } = await import_fs_extra3.default.stat(fsPath);
1172
4190
  filesMap[path] = new FileFsRef({ mode, fsPath });
1173
4191
  }
1174
4192
  const buildStamp = stamp_default();
1175
- await import_fs_extra2.default.mkdirp(outputDir);
4193
+ await import_fs_extra3.default.mkdirp(outputDir);
1176
4194
  const ops = [];
1177
4195
  const buildsJsonBuilds = /* @__PURE__ */ new Map();
1178
4196
  const ensureBuildersImported = async (buildsToImport) => {
@@ -1250,7 +4268,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1250
4268
  let buildFiles = filesMap;
1251
4269
  if (service && serviceWorkspace && serviceWorkspace !== ".") {
1252
4270
  const wsPrefix = serviceWorkspace + "/";
1253
- buildWorkPath = join4(workPath, serviceWorkspace);
4271
+ buildWorkPath = join5(workPath, serviceWorkspace);
1254
4272
  buildEntrypoint = build.src.startsWith(wsPrefix) ? build.src.slice(wsPrefix.length) : build.src;
1255
4273
  buildFiles = {};
1256
4274
  for (const [filePath, file] of Object.entries(filesMap)) {
@@ -1379,7 +4397,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1379
4397
  requestedEnv: legacyExperimentalService.env,
1380
4398
  consumerService: legacyExperimentalService,
1381
4399
  services: detectedServices,
1382
- frameworkList: import_frameworks2.frameworkList,
4400
+ frameworkList: import_frameworks3.frameworkList,
1383
4401
  currentEnv: process.env,
1384
4402
  deploymentUrl: process.env.VERCEL_URL
1385
4403
  });
@@ -1405,7 +4423,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1405
4423
  buildResult = rawBuildResult;
1406
4424
  }
1407
4425
  if (!getHasDetectedServices() && buildConfig.zeroConfig && isFrontendBuilder && "output" in buildResult && !buildResult.routes) {
1408
- const framework2 = import_frameworks2.frameworkList.find(
4426
+ const framework2 = import_frameworks3.frameworkList.find(
1409
4427
  (f) => f.slug === buildConfig.framework
1410
4428
  );
1411
4429
  if (framework2) {
@@ -1483,8 +4501,8 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1483
4501
  }
1484
4502
  }
1485
4503
  if ("output" in buildResult && buildResult.output && (isBackendBuilder(build) || build.use === "@vercel/python")) {
1486
- const routesJsonPath = join4(buildWorkPath, ".vercel", "routes.json");
1487
- if ((0, import_fs_extra2.existsSync)(routesJsonPath)) {
4504
+ const routesJsonPath = join5(buildWorkPath, ".vercel", "routes.json");
4505
+ if ((0, import_fs_extra3.existsSync)(routesJsonPath)) {
1488
4506
  try {
1489
4507
  const routesJson = await readJSONFile(routesJsonPath);
1490
4508
  if (routesJson && typeof routesJson === "object" && "routes" in routesJson && Array.isArray(routesJson.routes)) {
@@ -1563,7 +4581,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1563
4581
  }
1564
4582
  let mergedBuildResult = buildResult;
1565
4583
  if ("buildOutputPath" in buildResult) {
1566
- const buildOutputConfigPath = join4(
4584
+ const buildOutputConfigPath = join5(
1567
4585
  buildResult.buildOutputPath,
1568
4586
  "config.json"
1569
4587
  );
@@ -1575,7 +4593,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1575
4593
  }
1576
4594
  if (buildOutputConfig) {
1577
4595
  if (!hasExperimentalServicesV1ConfiguredInVercelConfig && !hasExperimentalServicesV2ConfiguredInVercelConfig) {
1578
- const outputConfigPath = join4(outputDir, "config.json");
4596
+ const outputConfigPath = join5(outputDir, "config.json");
1579
4597
  const outputConfig = await readJSONFile(outputConfigPath);
1580
4598
  if (outputConfig instanceof CantParseJSONFile) {
1581
4599
  throw outputConfig;
@@ -1590,7 +4608,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1590
4608
  buildOutputConfig.services = outputConfig.services;
1591
4609
  }
1592
4610
  if (hasNonEmptyObject(buildOutputConfig.experimentalServices) || hasNonEmptyObject(buildOutputConfig.experimentalServicesV2) || hasGeneratedServicesConfig(buildOutputConfig)) {
1593
- await import_fs_extra2.default.writeJSON(buildOutputConfigPath, buildOutputConfig, {
4611
+ await import_fs_extra3.default.writeJSON(buildOutputConfigPath, buildOutputConfig, {
1594
4612
  spaces: 2
1595
4613
  });
1596
4614
  }
@@ -1652,7 +4670,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1652
4670
  throw err;
1653
4671
  } finally {
1654
4672
  ops.push(
1655
- download(diagnostics, join4(outputDir, "diagnostics")).then(
4673
+ download(diagnostics, join5(outputDir, "diagnostics")).then(
1656
4674
  () => void 0,
1657
4675
  (err) => err
1658
4676
  )
@@ -1682,7 +4700,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1682
4700
  );
1683
4701
  };
1684
4702
  const appendExperimentalServicesV1Routes = (services) => {
1685
- const serviceRoutes = (0, import_fs_detectors2.generateServicesRoutes)(services);
4703
+ const serviceRoutes = (0, import_fs_detectors3.generateServicesRoutes)(services);
1686
4704
  zeroConfigRoutes = (0, import_routing_utils2.appendRoutesToPhase)({
1687
4705
  routes: zeroConfigRoutes,
1688
4706
  newRoutes: serviceRoutes.hostRewrites.length ? serviceRoutes.hostRewrites : null,
@@ -1708,16 +4726,16 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1708
4726
  await runBuilders(builds);
1709
4727
  await flushOps();
1710
4728
  if (!hasExperimentalServicesV1ConfiguredInVercelConfig && !hasExperimentalServicesV2ConfiguredInVercelConfig) {
1711
- const generatedConfigPath = join4(outputDir, "config.json");
4729
+ const generatedConfigPath = join5(outputDir, "config.json");
1712
4730
  const generatedConfig = await readJSONFile(generatedConfigPath);
1713
4731
  if (generatedConfig instanceof CantParseJSONFile) {
1714
4732
  throw generatedConfig;
1715
4733
  }
1716
- const defaultGeneratedOutputDir = join4(workPath, OUTPUT_DIR);
4734
+ const defaultGeneratedOutputDir = join5(workPath, OUTPUT_DIR);
1717
4735
  const generatedConfigs = [generatedConfig];
1718
4736
  if (resolve(outputDir) !== resolve(defaultGeneratedOutputDir)) {
1719
4737
  const defaultGeneratedConfig = await readJSONFile(
1720
- join4(defaultGeneratedOutputDir, "config.json")
4738
+ join5(defaultGeneratedOutputDir, "config.json")
1721
4739
  );
1722
4740
  if (defaultGeneratedConfig instanceof CantParseJSONFile) {
1723
4741
  throw defaultGeneratedConfig;
@@ -1742,7 +4760,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1742
4760
  (config2) => (hasGeneratedServicesConfig(config2) || hasNonEmptyObject(config2?.experimentalServicesV2)) && Array.isArray(config2?.routes)
1743
4761
  )?.routes : void 0;
1744
4762
  const generatedBuilders = await span.child("vc.detectGeneratedServices").trace(
1745
- () => (0, import_fs_detectors2.detectBuilders)(files, pkg, {
4763
+ () => (0, import_fs_detectors3.detectBuilders)(files, pkg, {
1746
4764
  ...localConfig,
1747
4765
  ...generatedServicesConfig ? {
1748
4766
  services: generatedServicesConfig,
@@ -1778,7 +4796,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1778
4796
  if (detectedServices && detectedServices.length > 0 && generatedBuilders.useImplicitEnvInjection) {
1779
4797
  const serviceUrlEnvVars = getExperimentalServiceUrlEnvVars({
1780
4798
  services: detectedServices,
1781
- frameworkList: import_frameworks2.frameworkList,
4799
+ frameworkList: import_frameworks3.frameworkList,
1782
4800
  currentEnv: process.env,
1783
4801
  deploymentUrl: process.env.VERCEL_URL
1784
4802
  });
@@ -1852,7 +4870,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1852
4870
  if (needBuildsJsonOverride) {
1853
4871
  await writeBuildJson(buildsJson, outputDir);
1854
4872
  }
1855
- const configPath = join4(outputDir, "config.json");
4873
+ const configPath = join5(outputDir, "config.json");
1856
4874
  const existingConfig = await readJSONFile(configPath);
1857
4875
  if (existingConfig instanceof CantParseJSONFile) {
1858
4876
  throw existingConfig;
@@ -1980,7 +4998,7 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1980
4998
  },
1981
4999
  ...mergedDeploymentId && { deploymentId: mergedDeploymentId }
1982
5000
  };
1983
- await import_fs_extra2.default.writeJSON(join4(outputDir, "config.json"), config, { spaces: 2 });
5001
+ await import_fs_extra3.default.writeJSON(join5(outputDir, "config.json"), config, { spaces: 2 });
1984
5002
  if (nestExperimentalServicesV2Output) {
1985
5003
  await writeServiceConfigs(
1986
5004
  outputDir,
@@ -1991,6 +5009,31 @@ async function doBuild(client, project, buildsJson, cwd, outputDir, span, standa
1991
5009
  );
1992
5010
  }
1993
5011
  await writeFlagsJSON(buildResults.values(), outputDir);
5012
+ await span.child("vc.frameworkCrossCheck").trace(async (s) => {
5013
+ const detectedFrameworks = await detectedFrameworksPromise;
5014
+ const executedBuilders = Array.from(buildResults.keys());
5015
+ const usedBuilders = executedBuilders.map((b) => b.use).filter((use) => Boolean(use));
5016
+ const mismatchResult = warnIfFrameworkMismatch({
5017
+ configuredFramework: projectSettings.framework,
5018
+ detectedFrameworks,
5019
+ usedBuilders,
5020
+ usedFrameworks: executedBuilders.map((b) => b.config?.framework)
5021
+ });
5022
+ s.setAttributes({
5023
+ result: mismatchResult,
5024
+ configuredFramework: projectSettings.framework ?? void 0,
5025
+ detectedFrameworks: detectedFrameworks.join(",") || void 0,
5026
+ usedBuilders: usedBuilders.join(",") || void 0
5027
+ });
5028
+ });
5029
+ await span.child("vc.validateBuildOutput").trace(async (s) => {
5030
+ const outputProblems = await validateBuildOutput(outputDir);
5031
+ s.setAttributes({
5032
+ problemCount: String(outputProblems.length),
5033
+ problems: outputProblems.map((p) => `${p.severity}: ${p.message}`).join("; ") || void 0
5034
+ });
5035
+ reportBuildOutputProblems(outputProblems);
5036
+ });
1994
5037
  collectSpan.stop();
1995
5038
  const relOutputDir = relative3(cwd, outputDir);
1996
5039
  if (!client.nonInteractive) {
@@ -2038,7 +5081,7 @@ async function analyzeVcConfigFiles(cwd, outputDir) {
2038
5081
  const filesObject = await glob("**/.vc-config.json", {
2039
5082
  cwd: outputDir
2040
5083
  });
2041
- const vcConfigFiles = Object.keys(filesObject).filter((relativePath) => !relativePath.includes(".rsc.func")).map((relativePath) => join4(outputDir, relativePath));
5084
+ const vcConfigFiles = Object.keys(filesObject).filter((relativePath) => !relativePath.includes(".rsc.func")).map((relativePath) => join5(outputDir, relativePath));
2042
5085
  if (vcConfigFiles.length === 0) {
2043
5086
  output_manager_default.print("No functions to analyze.\n");
2044
5087
  return;
@@ -2098,7 +5141,7 @@ ${import_chalk.default.cyan("Size :")} ${import_chalk.default.cyan.bold(resu
2098
5141
  }
2099
5142
  async function analyzeSingleFunction(file, cwd, outputDir) {
2100
5143
  try {
2101
- const content = await import_fs_extra2.default.readFile(file, "utf8");
5144
+ const content = await import_fs_extra3.default.readFile(file, "utf8");
2102
5145
  const parsed = JSON.parse(content);
2103
5146
  const funcDir = dirname2(file);
2104
5147
  const funcDirStats = getDirectorySizeInMB(funcDir);
@@ -2106,7 +5149,7 @@ async function analyzeSingleFunction(file, cwd, outputDir) {
2106
5149
  (entry) => typeof entry[1] === "string"
2107
5150
  ).map(([bundlePath, sourcePath]) => ({
2108
5151
  bundlePath,
2109
- sourcePath: join4(cwd, sourcePath)
5152
+ sourcePath: join5(cwd, sourcePath)
2110
5153
  })) : [];
2111
5154
  const fsRefStats = getTotalFileSizeInMB(filePathMap);
2112
5155
  const totalSize = funcDirStats.size + fsRefStats.size;
@@ -2145,7 +5188,7 @@ function getDirectorySizeInMB(dir) {
2145
5188
  const entries = readdirSync(dir, { recursive: true });
2146
5189
  for (const entry of entries) {
2147
5190
  const entryPath = typeof entry === "string" ? entry : entry.toString();
2148
- const fullPath = join4(dir, entryPath);
5191
+ const fullPath = join5(dir, entryPath);
2149
5192
  try {
2150
5193
  const stats = statSync(fullPath);
2151
5194
  if (stats.isFile()) {
@@ -2161,9 +5204,9 @@ function getDirectorySizeInMB(dir) {
2161
5204
  return { size, files: filesSizeMap };
2162
5205
  }
2163
5206
  async function getFramework(cwd, buildResults) {
2164
- const detectedFramework = await (0, import_fs_detectors2.detectFrameworkRecord)({
2165
- fs: new import_fs_detectors2.LocalFileSystemDetector(cwd),
2166
- frameworkList: import_frameworks2.frameworkList
5207
+ const detectedFramework = await (0, import_fs_detectors3.detectFrameworkRecord)({
5208
+ fs: new import_fs_detectors3.LocalFileSystemDetector(cwd),
5209
+ frameworkList: import_frameworks3.frameworkList
2167
5210
  });
2168
5211
  if (!detectedFramework) {
2169
5212
  return;
@@ -2185,7 +5228,7 @@ async function getFramework(cwd, buildResults) {
2185
5228
  version: detectedFramework.detectedVersion
2186
5229
  };
2187
5230
  }
2188
- const frameworkVersion = (0, import_fs_detectors2.detectFrameworkVersion)(detectedFramework);
5231
+ const frameworkVersion = (0, import_fs_detectors3.detectFrameworkVersion)(detectedFramework);
2189
5232
  if (frameworkVersion) {
2190
5233
  return {
2191
5234
  slug: detectedFramework.slug,
@@ -2216,7 +5259,7 @@ function expandBuild(files, build) {
2216
5259
  src = src.substring(1);
2217
5260
  }
2218
5261
  const matches = files.filter(
2219
- (name) => name === src || (0, import_minimatch.default)(name, src, { dot: true })
5262
+ (name) => name === src || (0, import_minimatch2.default)(name, src, { dot: true })
2220
5263
  );
2221
5264
  return matches.map((m) => {
2222
5265
  return {
@@ -2300,7 +5343,7 @@ async function writeServiceConfigs(outputDir, buildResults, serviceByBuilder, se
2300
5343
  }
2301
5344
  await Promise.all(
2302
5345
  Array.from(serviceResults.entries()).map(async ([serviceName, results]) => {
2303
- const configPath = join4(
5346
+ const configPath = join5(
2304
5347
  outputDir,
2305
5348
  "services",
2306
5349
  serviceName,
@@ -2341,7 +5384,7 @@ async function writeServiceConfigs(outputDir, buildResults, serviceByBuilder, se
2341
5384
  experimentalServices: void 0,
2342
5385
  experimentalServicesV2: void 0
2343
5386
  };
2344
- await import_fs_extra2.default.writeJSON(configPath, config, { spaces: 2 });
5387
+ await import_fs_extra3.default.writeJSON(configPath, config, { spaces: 2 });
2345
5388
  })
2346
5389
  );
2347
5390
  }
@@ -2391,8 +5434,8 @@ async function mergeDeploymentId(existingDeploymentId, buildResults, workPath) {
2391
5434
  }
2392
5435
  }
2393
5436
  try {
2394
- const routesManifestPath = join4(workPath, ".next", "routes-manifest.json");
2395
- if (await import_fs_extra2.default.pathExists(routesManifestPath)) {
5437
+ const routesManifestPath = join5(workPath, ".next", "routes-manifest.json");
5438
+ if (await import_fs_extra3.default.pathExists(routesManifestPath)) {
2396
5439
  const routesManifest = await readJSONFile(
2397
5440
  routesManifestPath
2398
5441
  );
@@ -2407,9 +5450,9 @@ async function mergeDeploymentId(existingDeploymentId, buildResults, workPath) {
2407
5450
  return void 0;
2408
5451
  }
2409
5452
  async function writeFlagsJSON(buildResults, outputDir) {
2410
- const flagsFilePath = join4(outputDir, "flags.json");
5453
+ const flagsFilePath = join5(outputDir, "flags.json");
2411
5454
  let hasFlags = true;
2412
- const flags = await import_fs_extra2.default.readJSON(flagsFilePath).catch((error) => {
5455
+ const flags = await import_fs_extra3.default.readJSON(flagsFilePath).catch((error) => {
2413
5456
  if (error.code === "ENOENT") {
2414
5457
  hasFlags = false;
2415
5458
  return { definitions: {} };
@@ -2431,11 +5474,11 @@ async function writeFlagsJSON(buildResults, outputDir) {
2431
5474
  }
2432
5475
  }
2433
5476
  if (hasFlags) {
2434
- await import_fs_extra2.default.writeJSON(flagsFilePath, flags, { spaces: 2 });
5477
+ await import_fs_extra3.default.writeJSON(flagsFilePath, flags, { spaces: 2 });
2435
5478
  }
2436
5479
  }
2437
5480
  async function writeBuildJson(buildsJson, outputDir) {
2438
- await import_fs_extra2.default.writeJSON(join4(outputDir, "builds.json"), buildsJson, { spaces: 2 });
5481
+ await import_fs_extra3.default.writeJSON(join5(outputDir, "builds.json"), buildsJson, { spaces: 2 });
2439
5482
  }
2440
5483
  async function getFrameworkRoutes(framework, dirPrefix) {
2441
5484
  let routes = [];
@@ -2540,3 +5583,8 @@ async function fetchDeploymentBuildEnv(client, deploymentId) {
2540
5583
  export {
2541
5584
  main as default
2542
5585
  };
5586
+ /*! Bundled license information:
5587
+
5588
+ js-yaml/dist/js-yaml.mjs:
5589
+ (*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT *)
5590
+ */