@midscene/cli 0.8.17 → 0.8.18-beta-20250107062545.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 (3) hide show
  1. package/dist/es/index.js +187 -3060
  2. package/dist/lib/index.js +337 -3198
  3. package/package.json +3 -3
package/dist/lib/index.js CHANGED
@@ -494,40 +494,40 @@ var require_balanced_match = __commonJS({
494
494
  "../../node_modules/.pnpm/balanced-match@1.0.2/node_modules/balanced-match/index.js"(exports2, module2) {
495
495
  "use strict";
496
496
  module2.exports = balanced;
497
- function balanced(a, b, str2) {
497
+ function balanced(a, b, str) {
498
498
  if (a instanceof RegExp)
499
- a = maybeMatch(a, str2);
499
+ a = maybeMatch(a, str);
500
500
  if (b instanceof RegExp)
501
- b = maybeMatch(b, str2);
502
- var r = range(a, b, str2);
501
+ b = maybeMatch(b, str);
502
+ var r = range(a, b, str);
503
503
  return r && {
504
504
  start: r[0],
505
505
  end: r[1],
506
- pre: str2.slice(0, r[0]),
507
- body: str2.slice(r[0] + a.length, r[1]),
508
- post: str2.slice(r[1] + b.length)
506
+ pre: str.slice(0, r[0]),
507
+ body: str.slice(r[0] + a.length, r[1]),
508
+ post: str.slice(r[1] + b.length)
509
509
  };
510
510
  }
511
- function maybeMatch(reg, str2) {
512
- var m = str2.match(reg);
511
+ function maybeMatch(reg, str) {
512
+ var m = str.match(reg);
513
513
  return m ? m[0] : null;
514
514
  }
515
515
  balanced.range = range;
516
- function range(a, b, str2) {
516
+ function range(a, b, str) {
517
517
  var begs, beg, left, right, result;
518
- var ai = str2.indexOf(a);
519
- var bi = str2.indexOf(b, ai + 1);
518
+ var ai = str.indexOf(a);
519
+ var bi = str.indexOf(b, ai + 1);
520
520
  var i = ai;
521
521
  if (ai >= 0 && bi > 0) {
522
522
  if (a === b) {
523
523
  return [ai, bi];
524
524
  }
525
525
  begs = [];
526
- left = str2.length;
526
+ left = str.length;
527
527
  while (i >= 0 && !result) {
528
528
  if (i == ai) {
529
529
  begs.push(i);
530
- ai = str2.indexOf(a, i + 1);
530
+ ai = str.indexOf(a, i + 1);
531
531
  } else if (begs.length == 1) {
532
532
  result = [begs.pop(), bi];
533
533
  } else {
@@ -536,7 +536,7 @@ var require_balanced_match = __commonJS({
536
536
  left = beg;
537
537
  right = bi;
538
538
  }
539
- bi = str2.indexOf(b, i + 1);
539
+ bi = str.indexOf(b, i + 1);
540
540
  }
541
541
  i = ai < bi && ai >= 0 ? ai : bi;
542
542
  }
@@ -560,22 +560,22 @@ var require_brace_expansion = __commonJS({
560
560
  var escClose = "\0CLOSE" + Math.random() + "\0";
561
561
  var escComma = "\0COMMA" + Math.random() + "\0";
562
562
  var escPeriod = "\0PERIOD" + Math.random() + "\0";
563
- function numeric(str2) {
564
- return parseInt(str2, 10) == str2 ? parseInt(str2, 10) : str2.charCodeAt(0);
563
+ function numeric(str) {
564
+ return parseInt(str, 10) == str ? parseInt(str, 10) : str.charCodeAt(0);
565
565
  }
566
- function escapeBraces(str2) {
567
- return str2.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod);
566
+ function escapeBraces(str) {
567
+ return str.split("\\\\").join(escSlash).split("\\{").join(escOpen).split("\\}").join(escClose).split("\\,").join(escComma).split("\\.").join(escPeriod);
568
568
  }
569
- function unescapeBraces(str2) {
570
- return str2.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".");
569
+ function unescapeBraces(str) {
570
+ return str.split(escSlash).join("\\").split(escOpen).join("{").split(escClose).join("}").split(escComma).join(",").split(escPeriod).join(".");
571
571
  }
572
- function parseCommaParts(str2) {
573
- if (!str2)
572
+ function parseCommaParts(str) {
573
+ if (!str)
574
574
  return [""];
575
575
  var parts = [];
576
- var m = balanced("{", "}", str2);
576
+ var m = balanced("{", "}", str);
577
577
  if (!m)
578
- return str2.split(",");
578
+ return str.split(",");
579
579
  var pre = m.pre;
580
580
  var body = m.body;
581
581
  var post = m.post;
@@ -589,16 +589,16 @@ var require_brace_expansion = __commonJS({
589
589
  parts.push.apply(parts, p);
590
590
  return parts;
591
591
  }
592
- function expandTop(str2) {
593
- if (!str2)
592
+ function expandTop(str) {
593
+ if (!str)
594
594
  return [];
595
- if (str2.substr(0, 2) === "{}") {
596
- str2 = "\\{\\}" + str2.substr(2);
595
+ if (str.substr(0, 2) === "{}") {
596
+ str = "\\{\\}" + str.substr(2);
597
597
  }
598
- return expand2(escapeBraces(str2), true).map(unescapeBraces);
598
+ return expand2(escapeBraces(str), true).map(unescapeBraces);
599
599
  }
600
- function embrace(str2) {
601
- return "{" + str2 + "}";
600
+ function embrace(str) {
601
+ return "{" + str + "}";
602
602
  }
603
603
  function isPadded(el) {
604
604
  return /^-?0\d/.test(el);
@@ -609,11 +609,11 @@ var require_brace_expansion = __commonJS({
609
609
  function gte(i, y) {
610
610
  return i >= y;
611
611
  }
612
- function expand2(str2, isTop) {
612
+ function expand2(str, isTop) {
613
613
  var expansions = [];
614
- var m = balanced("{", "}", str2);
614
+ var m = balanced("{", "}", str);
615
615
  if (!m)
616
- return [str2];
616
+ return [str];
617
617
  var pre = m.pre;
618
618
  var post = m.post.length ? expand2(m.post, false) : [""];
619
619
  if (/\$$/.test(m.pre)) {
@@ -628,10 +628,10 @@ var require_brace_expansion = __commonJS({
628
628
  var isOptions = m.body.indexOf(",") >= 0;
629
629
  if (!isSequence && !isOptions) {
630
630
  if (m.post.match(/,.*\}/)) {
631
- str2 = m.pre + "{" + m.body + escClose + m.post;
632
- return expand2(str2);
631
+ str = m.pre + "{" + m.body + escClose + m.post;
632
+ return expand2(str);
633
633
  }
634
- return [str2];
634
+ return [str];
635
635
  }
636
636
  var n;
637
637
  if (isSequence) {
@@ -701,211 +701,6 @@ var require_brace_expansion = __commonJS({
701
701
  }
702
702
  });
703
703
 
704
- // ../../node_modules/.pnpm/minimist@1.2.5/node_modules/minimist/index.js
705
- var require_minimist = __commonJS({
706
- "../../node_modules/.pnpm/minimist@1.2.5/node_modules/minimist/index.js"(exports2, module2) {
707
- "use strict";
708
- module2.exports = function(args, opts) {
709
- if (!opts)
710
- opts = {};
711
- var flags = { bools: {}, strings: {}, unknownFn: null };
712
- if (typeof opts["unknown"] === "function") {
713
- flags.unknownFn = opts["unknown"];
714
- }
715
- if (typeof opts["boolean"] === "boolean" && opts["boolean"]) {
716
- flags.allBools = true;
717
- } else {
718
- [].concat(opts["boolean"]).filter(Boolean).forEach(function(key2) {
719
- flags.bools[key2] = true;
720
- });
721
- }
722
- var aliases = {};
723
- Object.keys(opts.alias || {}).forEach(function(key2) {
724
- aliases[key2] = [].concat(opts.alias[key2]);
725
- aliases[key2].forEach(function(x) {
726
- aliases[x] = [key2].concat(aliases[key2].filter(function(y) {
727
- return x !== y;
728
- }));
729
- });
730
- });
731
- [].concat(opts.string).filter(Boolean).forEach(function(key2) {
732
- flags.strings[key2] = true;
733
- if (aliases[key2]) {
734
- flags.strings[aliases[key2]] = true;
735
- }
736
- });
737
- var defaults2 = opts["default"] || {};
738
- var argv = { _: [] };
739
- Object.keys(flags.bools).forEach(function(key2) {
740
- setArg(key2, defaults2[key2] === void 0 ? false : defaults2[key2]);
741
- });
742
- var notFlags = [];
743
- if (args.indexOf("--") !== -1) {
744
- notFlags = args.slice(args.indexOf("--") + 1);
745
- args = args.slice(0, args.indexOf("--"));
746
- }
747
- function argDefined(key2, arg2) {
748
- return flags.allBools && /^--[^=]+$/.test(arg2) || flags.strings[key2] || flags.bools[key2] || aliases[key2];
749
- }
750
- function setArg(key2, val, arg2) {
751
- if (arg2 && flags.unknownFn && !argDefined(key2, arg2)) {
752
- if (flags.unknownFn(arg2) === false)
753
- return;
754
- }
755
- var value2 = !flags.strings[key2] && isNumber(val) ? Number(val) : val;
756
- setKey(argv, key2.split("."), value2);
757
- (aliases[key2] || []).forEach(function(x) {
758
- setKey(argv, x.split("."), value2);
759
- });
760
- }
761
- function setKey(obj, keys, value2) {
762
- var o = obj;
763
- for (var i2 = 0; i2 < keys.length - 1; i2++) {
764
- var key2 = keys[i2];
765
- if (key2 === "__proto__")
766
- return;
767
- if (o[key2] === void 0)
768
- o[key2] = {};
769
- if (o[key2] === Object.prototype || o[key2] === Number.prototype || o[key2] === String.prototype)
770
- o[key2] = {};
771
- if (o[key2] === Array.prototype)
772
- o[key2] = [];
773
- o = o[key2];
774
- }
775
- var key2 = keys[keys.length - 1];
776
- if (key2 === "__proto__")
777
- return;
778
- if (o === Object.prototype || o === Number.prototype || o === String.prototype)
779
- o = {};
780
- if (o === Array.prototype)
781
- o = [];
782
- if (o[key2] === void 0 || flags.bools[key2] || typeof o[key2] === "boolean") {
783
- o[key2] = value2;
784
- } else if (Array.isArray(o[key2])) {
785
- o[key2].push(value2);
786
- } else {
787
- o[key2] = [o[key2], value2];
788
- }
789
- }
790
- function aliasIsBoolean(key2) {
791
- return aliases[key2].some(function(x) {
792
- return flags.bools[x];
793
- });
794
- }
795
- for (var i = 0; i < args.length; i++) {
796
- var arg = args[i];
797
- if (/^--.+=/.test(arg)) {
798
- var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
799
- var key = m[1];
800
- var value = m[2];
801
- if (flags.bools[key]) {
802
- value = value !== "false";
803
- }
804
- setArg(key, value, arg);
805
- } else if (/^--no-.+/.test(arg)) {
806
- var key = arg.match(/^--no-(.+)/)[1];
807
- setArg(key, false, arg);
808
- } else if (/^--.+/.test(arg)) {
809
- var key = arg.match(/^--(.+)/)[1];
810
- var next = args[i + 1];
811
- if (next !== void 0 && !/^-/.test(next) && !flags.bools[key] && !flags.allBools && (aliases[key] ? !aliasIsBoolean(key) : true)) {
812
- setArg(key, next, arg);
813
- i++;
814
- } else if (/^(true|false)$/.test(next)) {
815
- setArg(key, next === "true", arg);
816
- i++;
817
- } else {
818
- setArg(key, flags.strings[key] ? "" : true, arg);
819
- }
820
- } else if (/^-[^-]+/.test(arg)) {
821
- var letters = arg.slice(1, -1).split("");
822
- var broken = false;
823
- for (var j = 0; j < letters.length; j++) {
824
- var next = arg.slice(j + 2);
825
- if (next === "-") {
826
- setArg(letters[j], next, arg);
827
- continue;
828
- }
829
- if (/[A-Za-z]/.test(letters[j]) && /=/.test(next)) {
830
- setArg(letters[j], next.split("=")[1], arg);
831
- broken = true;
832
- break;
833
- }
834
- if (/[A-Za-z]/.test(letters[j]) && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
835
- setArg(letters[j], next, arg);
836
- broken = true;
837
- break;
838
- }
839
- if (letters[j + 1] && letters[j + 1].match(/\W/)) {
840
- setArg(letters[j], arg.slice(j + 2), arg);
841
- broken = true;
842
- break;
843
- } else {
844
- setArg(letters[j], flags.strings[letters[j]] ? "" : true, arg);
845
- }
846
- }
847
- var key = arg.slice(-1)[0];
848
- if (!broken && key !== "-") {
849
- if (args[i + 1] && !/^(-|--)[^-]/.test(args[i + 1]) && !flags.bools[key] && (aliases[key] ? !aliasIsBoolean(key) : true)) {
850
- setArg(key, args[i + 1], arg);
851
- i++;
852
- } else if (args[i + 1] && /^(true|false)$/.test(args[i + 1])) {
853
- setArg(key, args[i + 1] === "true", arg);
854
- i++;
855
- } else {
856
- setArg(key, flags.strings[key] ? "" : true, arg);
857
- }
858
- }
859
- } else {
860
- if (!flags.unknownFn || flags.unknownFn(arg) !== false) {
861
- argv._.push(
862
- flags.strings["_"] || !isNumber(arg) ? arg : Number(arg)
863
- );
864
- }
865
- if (opts.stopEarly) {
866
- argv._.push.apply(argv._, args.slice(i + 1));
867
- break;
868
- }
869
- }
870
- }
871
- Object.keys(defaults2).forEach(function(key2) {
872
- if (!hasKey(argv, key2.split("."))) {
873
- setKey(argv, key2.split("."), defaults2[key2]);
874
- (aliases[key2] || []).forEach(function(x) {
875
- setKey(argv, x.split("."), defaults2[key2]);
876
- });
877
- }
878
- });
879
- if (opts["--"]) {
880
- argv["--"] = new Array();
881
- notFlags.forEach(function(key2) {
882
- argv["--"].push(key2);
883
- });
884
- } else {
885
- notFlags.forEach(function(key2) {
886
- argv._.push(key2);
887
- });
888
- }
889
- return argv;
890
- };
891
- function hasKey(obj, keys) {
892
- var o = obj;
893
- keys.slice(0, -1).forEach(function(key2) {
894
- o = o[key2] || {};
895
- });
896
- var key = keys[keys.length - 1];
897
- return key in o;
898
- }
899
- function isNumber(x) {
900
- if (typeof x === "number")
901
- return true;
902
- if (/^0x[0-9a-f]+$/i.test(x))
903
- return true;
904
- return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
905
- }
906
- }
907
- });
908
-
909
704
  // ../../node_modules/.pnpm/y18n@5.0.8/node_modules/y18n/build/index.cjs
910
705
  var require_build = __commonJS({
911
706
  "../../node_modules/.pnpm/y18n@5.0.8/node_modules/y18n/build/index.cjs"(exports2, module2) {
@@ -928,7 +723,7 @@ var require_build = __commonJS({
928
723
  if (typeof arguments[0] !== "string") {
929
724
  return this._taggedLiteral(arguments[0], ...arguments);
930
725
  }
931
- const str2 = args.shift();
726
+ const str = args.shift();
932
727
  let cb = function() {
933
728
  };
934
729
  if (typeof args[args.length - 1] === "function")
@@ -937,8 +732,8 @@ var require_build = __commonJS({
937
732
  };
938
733
  if (!this.cache[this.locale])
939
734
  this._readLocaleFile();
940
- if (!this.cache[this.locale][str2] && this.updateFiles) {
941
- this.cache[this.locale][str2] = str2;
735
+ if (!this.cache[this.locale][str] && this.updateFiles) {
736
+ this.cache[this.locale][str] = str;
942
737
  this._enqueueWrite({
943
738
  directory: this.directory,
944
739
  locale: this.locale,
@@ -947,7 +742,7 @@ var require_build = __commonJS({
947
742
  } else {
948
743
  cb();
949
744
  }
950
- return shim.format.apply(shim.format, [this.cache[this.locale][str2] || str2].concat(args));
745
+ return shim.format.apply(shim.format, [this.cache[this.locale][str] || str].concat(args));
951
746
  }
952
747
  __n() {
953
748
  const args = Array.prototype.slice.call(arguments);
@@ -960,10 +755,10 @@ var require_build = __commonJS({
960
755
  cb = args.pop();
961
756
  if (!this.cache[this.locale])
962
757
  this._readLocaleFile();
963
- let str2 = quantity === 1 ? singular : plural;
758
+ let str = quantity === 1 ? singular : plural;
964
759
  if (this.cache[this.locale][singular]) {
965
760
  const entry = this.cache[this.locale][singular];
966
- str2 = entry[quantity === 1 ? "one" : "other"];
761
+ str = entry[quantity === 1 ? "one" : "other"];
967
762
  }
968
763
  if (!this.cache[this.locale][singular] && this.updateFiles) {
969
764
  this.cache[this.locale][singular] = {
@@ -978,8 +773,8 @@ var require_build = __commonJS({
978
773
  } else {
979
774
  cb();
980
775
  }
981
- const values = [str2];
982
- if (~str2.indexOf("%d"))
776
+ const values = [str];
777
+ if (~str.indexOf("%d"))
983
778
  values.push(quantity);
984
779
  return shim.format.apply(shim.format, values.concat(args));
985
780
  }
@@ -999,15 +794,15 @@ var require_build = __commonJS({
999
794
  }
1000
795
  }
1001
796
  _taggedLiteral(parts, ...args) {
1002
- let str2 = "";
797
+ let str = "";
1003
798
  parts.forEach(function(part, i) {
1004
799
  const arg = args[i + 1];
1005
- str2 += part;
800
+ str += part;
1006
801
  if (typeof arg !== "undefined") {
1007
- str2 += "%s";
802
+ str += "%s";
1008
803
  }
1009
804
  });
1010
- return this.__.apply(this, [str2].concat([].slice.call(args, 1)));
805
+ return this.__.apply(this, [str].concat([].slice.call(args, 1)));
1011
806
  }
1012
807
  _enqueueWrite(work) {
1013
808
  this.writeQueue.push(work);
@@ -1101,19 +896,19 @@ var require_build2 = __commonJS({
1101
896
  var util = require("util");
1102
897
  var path2 = require("path");
1103
898
  var fs = require("fs");
1104
- function camelCase(str2) {
1105
- const isCamelCase = str2 !== str2.toLowerCase() && str2 !== str2.toUpperCase();
899
+ function camelCase(str) {
900
+ const isCamelCase = str !== str.toLowerCase() && str !== str.toUpperCase();
1106
901
  if (!isCamelCase) {
1107
- str2 = str2.toLowerCase();
902
+ str = str.toLowerCase();
1108
903
  }
1109
- if (str2.indexOf("-") === -1 && str2.indexOf("_") === -1) {
1110
- return str2;
904
+ if (str.indexOf("-") === -1 && str.indexOf("_") === -1) {
905
+ return str;
1111
906
  } else {
1112
907
  let camelcase = "";
1113
908
  let nextChrUpper = false;
1114
- const leadingHyphens = str2.match(/^-+/);
1115
- for (let i = leadingHyphens ? leadingHyphens[0].length : 0; i < str2.length; i++) {
1116
- let chr = str2.charAt(i);
909
+ const leadingHyphens = str.match(/^-+/);
910
+ for (let i = leadingHyphens ? leadingHyphens[0].length : 0; i < str.length; i++) {
911
+ let chr = str.charAt(i);
1117
912
  if (nextChrUpper) {
1118
913
  nextChrUpper = false;
1119
914
  chr = chr.toUpperCase();
@@ -1127,13 +922,13 @@ var require_build2 = __commonJS({
1127
922
  return camelcase;
1128
923
  }
1129
924
  }
1130
- function decamelize(str2, joinString) {
1131
- const lowercase = str2.toLowerCase();
925
+ function decamelize(str, joinString) {
926
+ const lowercase = str.toLowerCase();
1132
927
  joinString = joinString || "-";
1133
928
  let notCamelcase = "";
1134
- for (let i = 0; i < str2.length; i++) {
929
+ for (let i = 0; i < str.length; i++) {
1135
930
  const chrLower = lowercase.charAt(i);
1136
- const chrString = str2.charAt(i);
931
+ const chrString = str.charAt(i);
1137
932
  if (chrLower !== chrString && i > 0) {
1138
933
  notCamelcase += `${joinString}${lowercase.charAt(i)}`;
1139
934
  } else {
@@ -1934,26 +1729,26 @@ var require_build2 = __commonJS({
1934
1729
  return defaultForType(guessType(key));
1935
1730
  }
1936
1731
  }
1937
- function defaultForType(type2) {
1732
+ function defaultForType(type) {
1938
1733
  const def = {
1939
1734
  [DefaultValuesForTypeKey.BOOLEAN]: true,
1940
1735
  [DefaultValuesForTypeKey.STRING]: "",
1941
1736
  [DefaultValuesForTypeKey.NUMBER]: void 0,
1942
1737
  [DefaultValuesForTypeKey.ARRAY]: []
1943
1738
  };
1944
- return def[type2];
1739
+ return def[type];
1945
1740
  }
1946
1741
  function guessType(key) {
1947
- let type2 = DefaultValuesForTypeKey.BOOLEAN;
1742
+ let type = DefaultValuesForTypeKey.BOOLEAN;
1948
1743
  if (checkAllAliases(key, flags.strings))
1949
- type2 = DefaultValuesForTypeKey.STRING;
1744
+ type = DefaultValuesForTypeKey.STRING;
1950
1745
  else if (checkAllAliases(key, flags.numbers))
1951
- type2 = DefaultValuesForTypeKey.NUMBER;
1746
+ type = DefaultValuesForTypeKey.NUMBER;
1952
1747
  else if (checkAllAliases(key, flags.bools))
1953
- type2 = DefaultValuesForTypeKey.BOOLEAN;
1748
+ type = DefaultValuesForTypeKey.BOOLEAN;
1954
1749
  else if (checkAllAliases(key, flags.arrays))
1955
- type2 = DefaultValuesForTypeKey.ARRAY;
1956
- return type2;
1750
+ type = DefaultValuesForTypeKey.ARRAY;
1751
+ return type;
1957
1752
  }
1958
1753
  function isUndefined(num) {
1959
1754
  return num === void 0;
@@ -3480,8 +3275,8 @@ var require_build3 = __commonJS({
3480
3275
  shouldApplyLayoutDSL(...args) {
3481
3276
  return args.length === 1 && typeof args[0] === "string" && /[\t\n]/.test(args[0]);
3482
3277
  }
3483
- applyLayoutDSL(str2) {
3484
- const rows = str2.split("\n").map((row) => row.split(" "));
3278
+ applyLayoutDSL(str) {
3279
+ const rows = str.split("\n").map((row) => row.split(" "));
3485
3280
  let leftColumnWidth = 0;
3486
3281
  rows.forEach((columns) => {
3487
3282
  if (columns.length > 1 && mixin.stringWidth(columns[0]) > leftColumnWidth) {
@@ -3505,8 +3300,8 @@ var require_build3 = __commonJS({
3505
3300
  padding: this.measurePadding(text)
3506
3301
  };
3507
3302
  }
3508
- measurePadding(str2) {
3509
- const noAnsi = mixin.stripAnsi(str2);
3303
+ measurePadding(str) {
3304
+ const noAnsi = mixin.stripAnsi(str);
3510
3305
  return [0, noAnsi.match(/\s*$/)[0].length, 0, noAnsi.match(/^\s*/)[0].length];
3511
3306
  }
3512
3307
  toString() {
@@ -3518,7 +3313,7 @@ var require_build3 = __commonJS({
3518
3313
  }
3519
3314
  rowToString(row, lines) {
3520
3315
  this.rasterize(row).forEach((rrow, r) => {
3521
- let str2 = "";
3316
+ let str = "";
3522
3317
  rrow.forEach((col, c) => {
3523
3318
  const { width } = row[c];
3524
3319
  const wrapWidth = this.negatePadding(row[c]);
@@ -3535,20 +3330,20 @@ var require_build3 = __commonJS({
3535
3330
  }
3536
3331
  const padding = row[c].padding || [0, 0, 0, 0];
3537
3332
  if (padding[left]) {
3538
- str2 += " ".repeat(padding[left]);
3333
+ str += " ".repeat(padding[left]);
3539
3334
  }
3540
- str2 += addBorder(row[c], ts, "| ");
3541
- str2 += ts;
3542
- str2 += addBorder(row[c], ts, " |");
3335
+ str += addBorder(row[c], ts, "| ");
3336
+ str += ts;
3337
+ str += addBorder(row[c], ts, " |");
3543
3338
  if (padding[right]) {
3544
- str2 += " ".repeat(padding[right]);
3339
+ str += " ".repeat(padding[right]);
3545
3340
  }
3546
3341
  if (r === 0 && lines.length > 0) {
3547
- str2 = this.renderInline(str2, lines[lines.length - 1]);
3342
+ str = this.renderInline(str, lines[lines.length - 1]);
3548
3343
  }
3549
3344
  });
3550
3345
  lines.push({
3551
- text: str2.replace(/ +$/, ""),
3346
+ text: str.replace(/ +$/, ""),
3552
3347
  span: row.span
3553
3348
  });
3554
3349
  });
@@ -3593,7 +3388,7 @@ var require_build3 = __commonJS({
3593
3388
  wrapped.unshift(...new Array(col.padding[top] || 0).fill(""));
3594
3389
  wrapped.push(...new Array(col.padding[bottom] || 0).fill(""));
3595
3390
  }
3596
- wrapped.forEach((str2, r) => {
3391
+ wrapped.forEach((str, r) => {
3597
3392
  if (!rrows[r]) {
3598
3393
  rrows.push([]);
3599
3394
  }
@@ -3603,7 +3398,7 @@ var require_build3 = __commonJS({
3603
3398
  rrow.push("");
3604
3399
  }
3605
3400
  }
3606
- rrow.push(str2);
3401
+ rrow.push(str);
3607
3402
  });
3608
3403
  });
3609
3404
  return rrows;
@@ -3669,21 +3464,21 @@ var require_build3 = __commonJS({
3669
3464
  }
3670
3465
  return 80;
3671
3466
  }
3672
- function alignRight(str2, width) {
3673
- str2 = str2.trim();
3674
- const strWidth = mixin.stringWidth(str2);
3467
+ function alignRight(str, width) {
3468
+ str = str.trim();
3469
+ const strWidth = mixin.stringWidth(str);
3675
3470
  if (strWidth < width) {
3676
- return " ".repeat(width - strWidth) + str2;
3471
+ return " ".repeat(width - strWidth) + str;
3677
3472
  }
3678
- return str2;
3473
+ return str;
3679
3474
  }
3680
- function alignCenter(str2, width) {
3681
- str2 = str2.trim();
3682
- const strWidth = mixin.stringWidth(str2);
3475
+ function alignCenter(str, width) {
3476
+ str = str.trim();
3477
+ const strWidth = mixin.stringWidth(str);
3683
3478
  if (strWidth >= width) {
3684
- return str2;
3479
+ return str;
3685
3480
  }
3686
- return " ".repeat(width - strWidth >> 1) + str2;
3481
+ return " ".repeat(width - strWidth >> 1) + str;
3687
3482
  }
3688
3483
  var mixin;
3689
3484
  function cliui(opts, _mixin) {
@@ -5556,7 +5351,7 @@ var require_package2 = __commonJS({
5556
5351
  module2.exports = {
5557
5352
  name: "@midscene/cli",
5558
5353
  description: "An AI-powered automation SDK can control the page, perform assertions, and extract data in JSON format using natural language. See https://midscenejs.com/ for details.",
5559
- version: "0.8.17",
5354
+ version: "0.8.18-beta-20250107062545.0",
5560
5355
  repository: "https://github.com/web-infra-dev/midscene",
5561
5356
  homepage: "https://midscenejs.com/",
5562
5357
  "jsnext:source": "./src/index.ts",
@@ -6086,9 +5881,6 @@ var require_source = __commonJS({
6086
5881
  );
6087
5882
  })();
6088
5883
 
6089
- // src/cli-utils.ts
6090
- var import_node_assert = __toESM(require("assert"));
6091
-
6092
5884
  // ../../node_modules/.pnpm/minimatch@10.0.1/node_modules/minimatch/dist/esm/index.js
6093
5885
  var import_brace_expansion = __toESM(require_brace_expansion());
6094
5886
 
@@ -6232,7 +6024,7 @@ var star = qmark + "*?";
6232
6024
  var starNoEmpty = qmark + "+?";
6233
6025
  var _root, _hasMagic, _uflag, _parts, _parent, _parentIndex, _negs, _filledNegs, _options, _toString, _emptyExt, _fillNegs, fillNegs_fn, _parseAST, parseAST_fn, _partsToRegExp, partsToRegExp_fn, _parseGlob, parseGlob_fn;
6234
6026
  var _AST = class _AST {
6235
- constructor(type2, parent, options = {}) {
6027
+ constructor(type, parent, options = {}) {
6236
6028
  __privateAdd(this, _fillNegs);
6237
6029
  __privateAdd(this, _partsToRegExp);
6238
6030
  __publicField(this, "type");
@@ -6249,14 +6041,14 @@ var _AST = class _AST {
6249
6041
  // set to true if it's an extglob with no children
6250
6042
  // (which really means one child of '')
6251
6043
  __privateAdd(this, _emptyExt, false);
6252
- this.type = type2;
6253
- if (type2)
6044
+ this.type = type;
6045
+ if (type)
6254
6046
  __privateSet(this, _hasMagic, true);
6255
6047
  __privateSet(this, _parent, parent);
6256
6048
  __privateSet(this, _root, __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _root) : this);
6257
6049
  __privateSet(this, _options, __privateGet(this, _root) === this ? options : __privateGet(__privateGet(this, _root), _options));
6258
6050
  __privateSet(this, _negs, __privateGet(this, _root) === this ? [] : __privateGet(__privateGet(this, _root), _negs));
6259
- if (type2 === "!" && !__privateGet(__privateGet(this, _root), _filledNegs))
6051
+ if (type === "!" && !__privateGet(__privateGet(this, _root), _filledNegs))
6260
6052
  __privateGet(this, _negs).push(this);
6261
6053
  __privateSet(this, _parentIndex, __privateGet(this, _parent) ? __privateGet(__privateGet(this, _parent), _parts).length : 0);
6262
6054
  }
@@ -6558,7 +6350,7 @@ fillNegs_fn = function() {
6558
6350
  return this;
6559
6351
  };
6560
6352
  _parseAST = new WeakSet();
6561
- parseAST_fn = function(str2, ast, pos, opt) {
6353
+ parseAST_fn = function(str, ast, pos, opt) {
6562
6354
  var _a4, _b2;
6563
6355
  let escaping = false;
6564
6356
  let inBrace = false;
@@ -6567,8 +6359,8 @@ parseAST_fn = function(str2, ast, pos, opt) {
6567
6359
  if (ast.type === null) {
6568
6360
  let i2 = pos;
6569
6361
  let acc2 = "";
6570
- while (i2 < str2.length) {
6571
- const c = str2.charAt(i2++);
6362
+ while (i2 < str.length) {
6363
+ const c = str.charAt(i2++);
6572
6364
  if (escaping || c === "\\") {
6573
6365
  escaping = !escaping;
6574
6366
  acc2 += c;
@@ -6591,11 +6383,11 @@ parseAST_fn = function(str2, ast, pos, opt) {
6591
6383
  acc2 += c;
6592
6384
  continue;
6593
6385
  }
6594
- if (!opt.noext && isExtglobType(c) && str2.charAt(i2) === "(") {
6386
+ if (!opt.noext && isExtglobType(c) && str.charAt(i2) === "(") {
6595
6387
  ast.push(acc2);
6596
6388
  acc2 = "";
6597
6389
  const ext2 = new _AST(c, ast);
6598
- i2 = __privateMethod(_a4 = _AST, _parseAST, parseAST_fn).call(_a4, str2, ext2, i2, opt);
6390
+ i2 = __privateMethod(_a4 = _AST, _parseAST, parseAST_fn).call(_a4, str, ext2, i2, opt);
6599
6391
  ast.push(ext2);
6600
6392
  continue;
6601
6393
  }
@@ -6608,8 +6400,8 @@ parseAST_fn = function(str2, ast, pos, opt) {
6608
6400
  let part = new _AST(null, ast);
6609
6401
  const parts = [];
6610
6402
  let acc = "";
6611
- while (i < str2.length) {
6612
- const c = str2.charAt(i++);
6403
+ while (i < str.length) {
6404
+ const c = str.charAt(i++);
6613
6405
  if (escaping || c === "\\") {
6614
6406
  escaping = !escaping;
6615
6407
  acc += c;
@@ -6632,12 +6424,12 @@ parseAST_fn = function(str2, ast, pos, opt) {
6632
6424
  acc += c;
6633
6425
  continue;
6634
6426
  }
6635
- if (isExtglobType(c) && str2.charAt(i) === "(") {
6427
+ if (isExtglobType(c) && str.charAt(i) === "(") {
6636
6428
  part.push(acc);
6637
6429
  acc = "";
6638
6430
  const ext2 = new _AST(c, part);
6639
6431
  part.push(ext2);
6640
- i = __privateMethod(_b2 = _AST, _parseAST, parseAST_fn).call(_b2, str2, ext2, i, opt);
6432
+ i = __privateMethod(_b2 = _AST, _parseAST, parseAST_fn).call(_b2, str, ext2, i, opt);
6641
6433
  continue;
6642
6434
  }
6643
6435
  if (c === "|") {
@@ -6660,7 +6452,7 @@ parseAST_fn = function(str2, ast, pos, opt) {
6660
6452
  }
6661
6453
  ast.type = null;
6662
6454
  __privateSet(ast, _hasMagic, void 0);
6663
- __privateSet(ast, _parts, [str2.substring(pos - 1)]);
6455
+ __privateSet(ast, _parts, [str.substring(pos - 1)]);
6664
6456
  return i;
6665
6457
  };
6666
6458
  _partsToRegExp = new WeakSet();
@@ -6821,8 +6613,8 @@ var defaults = (def) => {
6821
6613
  },
6822
6614
  AST: class AST extends orig.AST {
6823
6615
  /* c8 ignore start */
6824
- constructor(type2, parent, options = {}) {
6825
- super(type2, parent, ext(def, options));
6616
+ constructor(type, parent, options = {}) {
6617
+ super(type, parent, ext(def, options));
6826
6618
  }
6827
6619
  /* c8 ignore stop */
6828
6620
  static fromGlob(pattern, options = {}) {
@@ -6939,7 +6731,7 @@ var Minimatch = class {
6939
6731
  const rawGlobParts = this.globSet.map((s) => this.slashSplit(s));
6940
6732
  this.globParts = this.preprocess(rawGlobParts);
6941
6733
  this.debug(this.pattern, this.globParts);
6942
- let set2 = this.globParts.map((s, _, __) => {
6734
+ let set = this.globParts.map((s, _, __) => {
6943
6735
  if (this.isWindows && this.windowsNoMagicRoot) {
6944
6736
  const isUNC = s[0] === "" && s[1] === "" && (s[2] === "?" || !globMagic.test(s[2])) && !globMagic.test(s[3]);
6945
6737
  const isDrive = /^[a-z]:/i.test(s[0]);
@@ -6951,8 +6743,8 @@ var Minimatch = class {
6951
6743
  }
6952
6744
  return s.map((ss) => this.parse(ss));
6953
6745
  });
6954
- this.debug(this.pattern, set2);
6955
- this.set = set2.filter((s) => s.indexOf(false) === -1);
6746
+ this.debug(this.pattern, set);
6747
+ this.set = set.filter((s) => s.indexOf(false) === -1);
6956
6748
  if (this.isWindows) {
6957
6749
  for (let i = 0; i < this.set.length; i++) {
6958
6750
  const p = this.set[i];
@@ -7008,19 +6800,19 @@ var Minimatch = class {
7008
6800
  // get rid of adjascent ** and resolve .. portions
7009
6801
  levelOneOptimize(globParts) {
7010
6802
  return globParts.map((parts) => {
7011
- parts = parts.reduce((set2, part) => {
7012
- const prev = set2[set2.length - 1];
6803
+ parts = parts.reduce((set, part) => {
6804
+ const prev = set[set.length - 1];
7013
6805
  if (part === "**" && prev === "**") {
7014
- return set2;
6806
+ return set;
7015
6807
  }
7016
6808
  if (part === "..") {
7017
6809
  if (prev && prev !== ".." && prev !== "." && prev !== "**") {
7018
- set2.pop();
7019
- return set2;
6810
+ set.pop();
6811
+ return set;
7020
6812
  }
7021
6813
  }
7022
- set2.push(part);
7023
- return set2;
6814
+ set.push(part);
6815
+ return set;
7024
6816
  }, []);
7025
6817
  return parts.length === 0 ? [""] : parts;
7026
6818
  });
@@ -7338,15 +7130,15 @@ var Minimatch = class {
7338
7130
  makeRe() {
7339
7131
  if (this.regexp || this.regexp === false)
7340
7132
  return this.regexp;
7341
- const set2 = this.set;
7342
- if (!set2.length) {
7133
+ const set = this.set;
7134
+ if (!set.length) {
7343
7135
  this.regexp = false;
7344
7136
  return this.regexp;
7345
7137
  }
7346
7138
  const options = this.options;
7347
7139
  const twoStar = options.noglobstar ? star2 : options.dot ? twoStarDot : twoStarNoDot;
7348
7140
  const flags = new Set(options.nocase ? ["i"] : []);
7349
- let re = set2.map((pattern) => {
7141
+ let re = set.map((pattern) => {
7350
7142
  const pp = pattern.map((p) => {
7351
7143
  if (p instanceof RegExp) {
7352
7144
  for (const f of p.flags.split(""))
@@ -7375,7 +7167,7 @@ var Minimatch = class {
7375
7167
  });
7376
7168
  return pp.filter((p) => p !== GLOBSTAR).join("/");
7377
7169
  }).join("|");
7378
- const [open, close] = set2.length > 1 ? ["(?:", ")"] : ["", ""];
7170
+ const [open, close] = set.length > 1 ? ["(?:", ")"] : ["", ""];
7379
7171
  re = "^" + open + re + close + "$";
7380
7172
  if (this.negate)
7381
7173
  re = "^(?!" + re + ").+$";
@@ -7412,16 +7204,16 @@ var Minimatch = class {
7412
7204
  }
7413
7205
  const ff = this.slashSplit(f);
7414
7206
  this.debug(this.pattern, "split", ff);
7415
- const set2 = this.set;
7416
- this.debug(this.pattern, "set", set2);
7207
+ const set = this.set;
7208
+ this.debug(this.pattern, "set", set);
7417
7209
  let filename = ff[ff.length - 1];
7418
7210
  if (!filename) {
7419
7211
  for (let i = ff.length - 2; !filename && i >= 0; i--) {
7420
7212
  filename = ff[i];
7421
7213
  }
7422
7214
  }
7423
- for (let i = 0; i < set2.length; i++) {
7424
- const pattern = set2[i];
7215
+ for (let i = 0; i < set.length; i++) {
7216
+ const pattern = set[i];
7425
7217
  let file = ff;
7426
7218
  if (options.matchBase && pattern.length === 1) {
7427
7219
  file = [filename];
@@ -7455,8 +7247,8 @@ var import_node_url2 = require("url");
7455
7247
  var perf = typeof performance === "object" && performance && typeof performance.now === "function" ? performance : Date;
7456
7248
  var warned = /* @__PURE__ */ new Set();
7457
7249
  var PROCESS = typeof process === "object" && !!process ? process : {};
7458
- var emitWarning = (msg, type2, code, fn) => {
7459
- typeof PROCESS.emitWarning === "function" ? PROCESS.emitWarning(msg, type2, code, fn) : console.error(`[${code}] ${type2}: ${msg}`);
7250
+ var emitWarning = (msg, type, code, fn) => {
7251
+ typeof PROCESS.emitWarning === "function" ? PROCESS.emitWarning(msg, type, code, fn) : console.error(`[${code}] ${type}: ${msg}`);
7460
7252
  };
7461
7253
  var AC = globalThis.AbortController;
7462
7254
  var AS = globalThis.AbortSignal;
@@ -9887,7 +9679,7 @@ var PathBase = class {
9887
9679
  *
9888
9680
  * @internal
9889
9681
  */
9890
- constructor(name, type2 = UNKNOWN, root, roots, nocase, children, opts) {
9682
+ constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
9891
9683
  __privateAdd(this, _resolveParts);
9892
9684
  __privateAdd(this, _readdirSuccess);
9893
9685
  __privateAdd(this, _markENOENT);
@@ -9978,7 +9770,7 @@ var PathBase = class {
9978
9770
  __privateAdd(this, _asyncReaddirInFlight, void 0);
9979
9771
  this.name = name;
9980
9772
  __privateSet(this, _matchName, nocase ? normalizeNocase(name) : normalize(name));
9981
- __privateSet(this, _type, type2 & TYPEMASK);
9773
+ __privateSet(this, _type, type & TYPEMASK);
9982
9774
  this.nocase = nocase;
9983
9775
  this.roots = roots;
9984
9776
  this.root = root || this;
@@ -10243,8 +10035,8 @@ var PathBase = class {
10243
10035
  isUnknown() {
10244
10036
  return (__privateGet(this, _type) & IFMT) === UNKNOWN;
10245
10037
  }
10246
- isType(type2) {
10247
- return this[`is${type2}`]();
10038
+ isType(type) {
10039
+ return this[`is${type}`]();
10248
10040
  }
10249
10041
  getType() {
10250
10042
  return this.isUnknown() ? "Unknown" : this.isDirectory() ? "Directory" : this.isFile() ? "File" : this.isSymbolicLink() ? "SymbolicLink" : this.isFIFO() ? "FIFO" : this.isCharacterDevice() ? "CharacterDevice" : this.isBlockDevice() ? "BlockDevice" : (
@@ -10799,8 +10591,8 @@ readdirAddChild_fn = function(e, c) {
10799
10591
  };
10800
10592
  _readdirAddNewChild = new WeakSet();
10801
10593
  readdirAddNewChild_fn = function(e, c) {
10802
- const type2 = entToType(e);
10803
- const child = this.newChild(e.name, type2, { parent: this });
10594
+ const type = entToType(e);
10595
+ const child = this.newChild(e.name, type, { parent: this });
10804
10596
  const ifmt = __privateGet(child, _type) & IFMT;
10805
10597
  if (ifmt !== IFDIR && ifmt !== IFLNK && ifmt !== UNKNOWN) {
10806
10598
  __privateSet(child, _type, __privateGet(child, _type) | ENOTDIR);
@@ -10880,8 +10672,8 @@ var PathWin32 = class _PathWin32 extends PathBase {
10880
10672
  *
10881
10673
  * @internal
10882
10674
  */
10883
- constructor(name, type2 = UNKNOWN, root, roots, nocase, children, opts) {
10884
- super(name, type2, root, roots, nocase, children, opts);
10675
+ constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
10676
+ super(name, type, root, roots, nocase, children, opts);
10885
10677
  /**
10886
10678
  * Separator for generating path strings.
10887
10679
  */
@@ -10894,8 +10686,8 @@ var PathWin32 = class _PathWin32 extends PathBase {
10894
10686
  /**
10895
10687
  * @internal
10896
10688
  */
10897
- newChild(name, type2 = UNKNOWN, opts = {}) {
10898
- return new _PathWin32(name, type2, this.root, this.roots, this.nocase, this.childrenCache(), opts);
10689
+ newChild(name, type = UNKNOWN, opts = {}) {
10690
+ return new _PathWin32(name, type, this.root, this.roots, this.nocase, this.childrenCache(), opts);
10899
10691
  }
10900
10692
  /**
10901
10693
  * @internal
@@ -10933,8 +10725,8 @@ var PathPosix = class _PathPosix extends PathBase {
10933
10725
  *
10934
10726
  * @internal
10935
10727
  */
10936
- constructor(name, type2 = UNKNOWN, root, roots, nocase, children, opts) {
10937
- super(name, type2, root, roots, nocase, children, opts);
10728
+ constructor(name, type = UNKNOWN, root, roots, nocase, children, opts) {
10729
+ super(name, type, root, roots, nocase, children, opts);
10938
10730
  /**
10939
10731
  * separator for parsing path strings
10940
10732
  */
@@ -10959,8 +10751,8 @@ var PathPosix = class _PathPosix extends PathBase {
10959
10751
  /**
10960
10752
  * @internal
10961
10753
  */
10962
- newChild(name, type2 = UNKNOWN, opts = {}) {
10963
- return new _PathPosix(name, type2, this.root, this.roots, this.nocase, this.childrenCache(), opts);
10754
+ newChild(name, type = UNKNOWN, opts = {}) {
10755
+ return new _PathPosix(name, type, this.root, this.roots, this.nocase, this.childrenCache(), opts);
10964
10756
  }
10965
10757
  };
10966
10758
  var _resolveCache, _resolvePosixCache, _children2, _fs2;
@@ -12589,16 +12381,16 @@ var Glob = class {
12589
12381
  debug: !!this.opts.debug
12590
12382
  });
12591
12383
  const mms = this.pattern.map((p) => new Minimatch(p, mmo));
12592
- const [matchSet, globParts] = mms.reduce((set2, m) => {
12593
- set2[0].push(...m.set);
12594
- set2[1].push(...m.globParts);
12595
- return set2;
12384
+ const [matchSet, globParts] = mms.reduce((set, m) => {
12385
+ set[0].push(...m.set);
12386
+ set[1].push(...m.globParts);
12387
+ return set;
12596
12388
  }, [[], []]);
12597
- this.patterns = matchSet.map((set2, i) => {
12389
+ this.patterns = matchSet.map((set, i) => {
12598
12390
  const g = globParts[i];
12599
12391
  if (!g)
12600
12392
  throw new Error("invalid pattern object");
12601
- return new Pattern(set2, g, 0, this.platform);
12393
+ return new Pattern(set, g, 0, this.platform);
12602
12394
  });
12603
12395
  }
12604
12396
  walk() {
@@ -12724,2849 +12516,198 @@ var glob = Object.assign(glob_, {
12724
12516
  glob.glob = glob;
12725
12517
 
12726
12518
  // src/cli-utils.ts
12727
- var import_minimist = __toESM(require_minimist());
12728
12519
  var import_node_fs = require("fs");
12729
12520
  var import_node_fs2 = require("fs");
12730
12521
  var import_node_path2 = require("path");
12731
12522
 
12732
- // ../../node_modules/.pnpm/js-yaml@4.1.0/node_modules/js-yaml/dist/js-yaml.mjs
12733
- function isNothing(subject) {
12734
- return typeof subject === "undefined" || subject === null;
12735
- }
12736
- function isObject(subject) {
12737
- return typeof subject === "object" && subject !== null;
12738
- }
12739
- function toArray(sequence) {
12740
- if (Array.isArray(sequence))
12741
- return sequence;
12742
- else if (isNothing(sequence))
12743
- return [];
12744
- return [sequence];
12745
- }
12746
- function extend(target, source) {
12747
- var index, length, key, sourceKeys;
12748
- if (source) {
12749
- sourceKeys = Object.keys(source);
12750
- for (index = 0, length = sourceKeys.length; index < length; index += 1) {
12751
- key = sourceKeys[index];
12752
- target[key] = source[key];
12523
+ // ../../node_modules/.pnpm/yargs@17.7.2/node_modules/yargs/yargs.mjs
12524
+ var import_build = __toESM(require_build4(), 1);
12525
+ var { applyExtends, cjsPlatformShim, Parser, processArgv, Yargs } = import_build.default;
12526
+ Yargs.applyExtends = (config, cwd, mergeExtends) => {
12527
+ return applyExtends(config, cwd, mergeExtends, cjsPlatformShim);
12528
+ };
12529
+ Yargs.hideBin = processArgv.hideBin;
12530
+ Yargs.Parser = Parser;
12531
+ var yargs_default = Yargs;
12532
+
12533
+ // src/cli-utils.ts
12534
+ var parseProcessArgs = () => __async(void 0, null, function* () {
12535
+ const versionFromPkgJson = require_package2().version;
12536
+ const { hideBin } = require_helpers();
12537
+ const args = yargs_default(hideBin(process.argv)).usage(
12538
+ `Midscene.js helps you automate browser actions, assertions, and data extraction by AI.
12539
+ Homepage: https://midscenejs.com/
12540
+ Github: https://github.com/web-infra-dev/midscene
12541
+
12542
+ Usage: $0 [options] <path-to-yaml-script-file-or-directory>`
12543
+ ).options({
12544
+ headed: {
12545
+ type: "boolean",
12546
+ default: false,
12547
+ description: "Run the browser in headed mode to see the browser UI"
12548
+ },
12549
+ "keep-window": {
12550
+ type: "boolean",
12551
+ default: false,
12552
+ description: "Keep the browser window open after the script finishes. This is useful when debugging, but will consume more resources"
12753
12553
  }
12754
- }
12755
- return target;
12756
- }
12757
- function repeat(string, count) {
12758
- var result = "", cycle;
12759
- for (cycle = 0; cycle < count; cycle += 1) {
12760
- result += string;
12761
- }
12762
- return result;
12763
- }
12764
- function isNegativeZero(number) {
12765
- return number === 0 && Number.NEGATIVE_INFINITY === 1 / number;
12554
+ }).version("version", "Show version number", versionFromPkgJson).help().wrap(yargs_default().terminalWidth());
12555
+ const argv = yield args.argv;
12556
+ return {
12557
+ path: argv._[0],
12558
+ options: argv
12559
+ };
12560
+ });
12561
+ function matchYamlFiles(fileGlob) {
12562
+ return __async(this, null, function* () {
12563
+ if ((0, import_node_fs2.existsSync)(fileGlob) && (0, import_node_fs.statSync)(fileGlob).isDirectory()) {
12564
+ fileGlob = (0, import_node_path2.join)(fileGlob, "**/*.{yml,yaml}");
12565
+ }
12566
+ const files = yield glob(fileGlob, {
12567
+ nodir: true,
12568
+ windowsPathsNoEscape: true
12569
+ });
12570
+ return files.filter((file) => file.endsWith(".yml") || file.endsWith(".yaml")).sort();
12571
+ });
12766
12572
  }
12767
- var isNothing_1 = isNothing;
12768
- var isObject_1 = isObject;
12769
- var toArray_1 = toArray;
12770
- var repeat_1 = repeat;
12771
- var isNegativeZero_1 = isNegativeZero;
12772
- var extend_1 = extend;
12773
- var common = {
12774
- isNothing: isNothing_1,
12775
- isObject: isObject_1,
12776
- toArray: toArray_1,
12777
- repeat: repeat_1,
12778
- isNegativeZero: isNegativeZero_1,
12779
- extend: extend_1
12573
+
12574
+ // src/yaml-runner.ts
12575
+ var import_node_fs3 = require("fs");
12576
+ var import_node_path4 = require("path");
12577
+ var import_yaml2 = require("@midscene/web/yaml");
12578
+ var import_http_server = require("http-server");
12579
+
12580
+ // src/printer.ts
12581
+ var import_node_path3 = require("path");
12582
+ var import_yaml = require("@midscene/web/yaml");
12583
+ var import_chalk = __toESM(require_source());
12584
+ var isTTY = process.env.MIDSCENE_CLI_LOG_ON_NON_TTY ? false : process.stdout.isTTY;
12585
+ var indent = " ";
12586
+ var spinnerInterval = 80;
12587
+ var spinnerFrames = ["◰", "◳", "◲", "◱"];
12588
+ var currentSpinningFrame = () => {
12589
+ return spinnerFrames[Math.floor(Date.now() / spinnerInterval) % spinnerFrames.length];
12780
12590
  };
12781
- function formatError(exception2, compact) {
12782
- var where = "", message = exception2.reason || "(unknown reason)";
12783
- if (!exception2.mark)
12784
- return message;
12785
- if (exception2.mark.name) {
12786
- where += 'in "' + exception2.mark.name + '" ';
12787
- }
12788
- where += "(" + (exception2.mark.line + 1) + ":" + (exception2.mark.column + 1) + ")";
12789
- if (!compact && exception2.mark.snippet) {
12790
- where += "\n\n" + exception2.mark.snippet;
12791
- }
12792
- return message + " " + where;
12793
- }
12794
- function YAMLException$1(reason, mark) {
12795
- Error.call(this);
12796
- this.name = "YAMLException";
12797
- this.reason = reason;
12798
- this.mark = mark;
12799
- this.message = formatError(this, false);
12800
- if (Error.captureStackTrace) {
12801
- Error.captureStackTrace(this, this.constructor);
12802
- } else {
12803
- this.stack = new Error().stack || "";
12591
+ function indicatorForStatus(status) {
12592
+ if (status === "init") {
12593
+ return import_chalk.default.gray("◌");
12804
12594
  }
12805
- }
12806
- YAMLException$1.prototype = Object.create(Error.prototype);
12807
- YAMLException$1.prototype.constructor = YAMLException$1;
12808
- YAMLException$1.prototype.toString = function toString(compact) {
12809
- return this.name + ": " + formatError(this, compact);
12810
- };
12811
- var exception = YAMLException$1;
12812
- function getLine(buffer, lineStart, lineEnd, position, maxLineLength) {
12813
- var head = "";
12814
- var tail = "";
12815
- var maxHalfLength = Math.floor(maxLineLength / 2) - 1;
12816
- if (position - lineStart > maxHalfLength) {
12817
- head = " ... ";
12818
- lineStart = position - maxHalfLength + head.length;
12819
- }
12820
- if (lineEnd - position > maxHalfLength) {
12821
- tail = " ...";
12822
- lineEnd = position + maxHalfLength - tail.length;
12595
+ if (status === "running") {
12596
+ return import_chalk.default.yellowBright(currentSpinningFrame());
12823
12597
  }
12824
- return {
12825
- str: head + buffer.slice(lineStart, lineEnd).replace(/\t/g, "") + tail,
12826
- pos: position - lineStart + head.length
12827
- // relative position
12828
- };
12829
- }
12830
- function padStart(string, max) {
12831
- return common.repeat(" ", max - string.length) + string;
12832
- }
12833
- function makeSnippet(mark, options) {
12834
- options = Object.create(options || null);
12835
- if (!mark.buffer)
12836
- return null;
12837
- if (!options.maxLength)
12838
- options.maxLength = 79;
12839
- if (typeof options.indent !== "number")
12840
- options.indent = 1;
12841
- if (typeof options.linesBefore !== "number")
12842
- options.linesBefore = 3;
12843
- if (typeof options.linesAfter !== "number")
12844
- options.linesAfter = 2;
12845
- var re = /\r?\n|\r|\0/g;
12846
- var lineStarts = [0];
12847
- var lineEnds = [];
12848
- var match2;
12849
- var foundLineNo = -1;
12850
- while (match2 = re.exec(mark.buffer)) {
12851
- lineEnds.push(match2.index);
12852
- lineStarts.push(match2.index + match2[0].length);
12853
- if (mark.position <= match2.index && foundLineNo < 0) {
12854
- foundLineNo = lineStarts.length - 2;
12855
- }
12856
- }
12857
- if (foundLineNo < 0)
12858
- foundLineNo = lineStarts.length - 1;
12859
- var result = "", i, line;
12860
- var lineNoLength = Math.min(mark.line + options.linesAfter, lineEnds.length).toString().length;
12861
- var maxLineLength = options.maxLength - (options.indent + lineNoLength + 3);
12862
- for (i = 1; i <= options.linesBefore; i++) {
12863
- if (foundLineNo - i < 0)
12864
- break;
12865
- line = getLine(
12866
- mark.buffer,
12867
- lineStarts[foundLineNo - i],
12868
- lineEnds[foundLineNo - i],
12869
- mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo - i]),
12870
- maxLineLength
12871
- );
12872
- result = common.repeat(" ", options.indent) + padStart((mark.line - i + 1).toString(), lineNoLength) + " | " + line.str + "\n" + result;
12873
- }
12874
- line = getLine(mark.buffer, lineStarts[foundLineNo], lineEnds[foundLineNo], mark.position, maxLineLength);
12875
- result += common.repeat(" ", options.indent) + padStart((mark.line + 1).toString(), lineNoLength) + " | " + line.str + "\n";
12876
- result += common.repeat("-", options.indent + lineNoLength + 3 + line.pos) + "^\n";
12877
- for (i = 1; i <= options.linesAfter; i++) {
12878
- if (foundLineNo + i >= lineEnds.length)
12879
- break;
12880
- line = getLine(
12881
- mark.buffer,
12882
- lineStarts[foundLineNo + i],
12883
- lineEnds[foundLineNo + i],
12884
- mark.position - (lineStarts[foundLineNo] - lineStarts[foundLineNo + i]),
12885
- maxLineLength
12886
- );
12887
- result += common.repeat(" ", options.indent) + padStart((mark.line + i + 1).toString(), lineNoLength) + " | " + line.str + "\n";
12598
+ if (status === "done") {
12599
+ return import_chalk.default.green("✔︎");
12888
12600
  }
12889
- return result.replace(/\n$/, "");
12890
- }
12891
- var snippet = makeSnippet;
12892
- var TYPE_CONSTRUCTOR_OPTIONS = [
12893
- "kind",
12894
- "multi",
12895
- "resolve",
12896
- "construct",
12897
- "instanceOf",
12898
- "predicate",
12899
- "represent",
12900
- "representName",
12901
- "defaultStyle",
12902
- "styleAliases"
12903
- ];
12904
- var YAML_NODE_KINDS = [
12905
- "scalar",
12906
- "sequence",
12907
- "mapping"
12908
- ];
12909
- function compileStyleAliases(map2) {
12910
- var result = {};
12911
- if (map2 !== null) {
12912
- Object.keys(map2).forEach(function(style) {
12913
- map2[style].forEach(function(alias) {
12914
- result[String(alias)] = style;
12915
- });
12916
- });
12601
+ if (status === "error") {
12602
+ return import_chalk.default.red("✘");
12917
12603
  }
12918
- return result;
12919
12604
  }
12920
- function Type$1(tag, options) {
12921
- options = options || {};
12922
- Object.keys(options).forEach(function(name) {
12923
- if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
12924
- throw new exception('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.');
12925
- }
12926
- });
12927
- this.options = options;
12928
- this.tag = tag;
12929
- this.kind = options["kind"] || null;
12930
- this.resolve = options["resolve"] || function() {
12931
- return true;
12932
- };
12933
- this.construct = options["construct"] || function(data) {
12934
- return data;
12605
+ var contextInfo = (context) => {
12606
+ var _a4, _b2;
12607
+ const filePath = context.file;
12608
+ const fileName = (0, import_node_path3.basename)(filePath);
12609
+ const fileDir = (0, import_node_path3.dirname)(filePath);
12610
+ const fileNameToPrint = `${import_chalk.default.gray(`${fileDir}/`)}${fileName}`;
12611
+ const fileStatusText = indicatorForStatus(context.player.status);
12612
+ const contextActionText = typeof context.player.currentTaskIndex === "undefined" && context.player.status === "running" ? import_chalk.default.gray("(navigating)") : "";
12613
+ const errorText = context.player.errorInSetup ? `
12614
+ ${indent}${import_chalk.default.red("error:")} ${(_a4 = context.player.errorInSetup) == null ? void 0 : _a4.message}
12615
+ ${indent}${indent}${(_b2 = context.player.errorInSetup) == null ? void 0 : _b2.stack}` : "";
12616
+ const outputFile = context.player.output;
12617
+ const outputText = outputFile && Object.keys(context.player.result || {}).length > 0 ? `
12618
+ ${indent}${import_chalk.default.gray(`output: ${outputFile}`)}` : "";
12619
+ const reportFile = context.player.reportFile;
12620
+ const reportFileToShow = (0, import_node_path3.relative)(process.cwd(), reportFile || "");
12621
+ const reportText = reportFile ? `
12622
+ ${indent}${import_chalk.default.gray(`report: ./${reportFileToShow}`)}` : "";
12623
+ const mergedText = `${fileStatusText} ${fileNameToPrint} ${contextActionText}${outputText}${reportText}${errorText}`.trim();
12624
+ return {
12625
+ fileNameToPrint,
12626
+ fileStatusText,
12627
+ contextActionText,
12628
+ outputText,
12629
+ reportText,
12630
+ mergedText
12935
12631
  };
12936
- this.instanceOf = options["instanceOf"] || null;
12937
- this.predicate = options["predicate"] || null;
12938
- this.represent = options["represent"] || null;
12939
- this.representName = options["representName"] || null;
12940
- this.defaultStyle = options["defaultStyle"] || null;
12941
- this.multi = options["multi"] || false;
12942
- this.styleAliases = compileStyleAliases(options["styleAliases"] || null);
12943
- if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
12944
- throw new exception('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.');
12632
+ };
12633
+ var singleTaskInfo = (task) => {
12634
+ var _a4;
12635
+ let stepText = "";
12636
+ if (task.status === "init") {
12637
+ stepText = "";
12638
+ } else if (task.status === "running" || task.status === "error") {
12639
+ if (typeof task.currentStep === "undefined") {
12640
+ stepText = import_chalk.default.gray("(navigating)");
12641
+ } else if (typeof task.currentStep === "number") {
12642
+ const currentFlowItem = task.flow[task.currentStep];
12643
+ const taskBrief = currentFlowItem && (0, import_yaml.flowItemBrief)(currentFlowItem);
12644
+ const actionText = taskBrief ? `, ${taskBrief}` : "";
12645
+ stepText = import_chalk.default.gray(
12646
+ `(step ${task.currentStep + 1}/${task.totalSteps}${actionText})`.trim()
12647
+ );
12648
+ } else {
12649
+ stepText = import_chalk.default.gray("(unknown step)");
12650
+ }
12945
12651
  }
12946
- }
12947
- var type = Type$1;
12948
- function compileList(schema2, name) {
12949
- var result = [];
12950
- schema2[name].forEach(function(currentType) {
12951
- var newIndex = result.length;
12952
- result.forEach(function(previousType, previousIndex) {
12953
- if (previousType.tag === currentType.tag && previousType.kind === currentType.kind && previousType.multi === currentType.multi) {
12954
- newIndex = previousIndex;
12955
- }
12956
- });
12957
- result[newIndex] = currentType;
12652
+ const errorText = task.status === "error" ? `
12653
+ ${indent}${import_chalk.default.gray("error:")}
12654
+ ${indent}${indent}${(_a4 = task.error) == null ? void 0 : _a4.message}` : "";
12655
+ const statusText = indicatorForStatus(task.status);
12656
+ const mergedLine = `${statusText} ${task.name} ${stepText}${errorText}`;
12657
+ return {
12658
+ nameText: task.name,
12659
+ stepText,
12660
+ errorText,
12661
+ itemStatusText: statusText,
12662
+ mergedLine
12663
+ };
12664
+ };
12665
+ function paddingLines(lines) {
12666
+ return lines.map((line) => {
12667
+ return `${indent}${line}`;
12958
12668
  });
12959
- return result;
12960
12669
  }
12961
- function compileMap() {
12962
- var result = {
12963
- scalar: {},
12964
- sequence: {},
12965
- mapping: {},
12966
- fallback: {},
12967
- multi: {
12968
- scalar: [],
12969
- sequence: [],
12970
- mapping: [],
12971
- fallback: []
12972
- }
12973
- }, index, length;
12974
- function collectType(type2) {
12975
- if (type2.multi) {
12976
- result.multi[type2.kind].push(type2);
12977
- result.multi["fallback"].push(type2);
12978
- } else {
12979
- result[type2.kind][type2.tag] = result["fallback"][type2.tag] = type2;
12670
+ var contextTaskListSummary = (taskStatusArray, context) => {
12671
+ const prefixLines = [];
12672
+ const currentLine = [];
12673
+ const suffixText = [];
12674
+ const { mergedText: fileInfo } = contextInfo(context);
12675
+ if (!context.player.errorInSetup) {
12676
+ for (const task of taskStatusArray) {
12677
+ const { mergedLine } = singleTaskInfo(task);
12678
+ if (context.player.status === "init") {
12679
+ suffixText.push(mergedLine);
12680
+ } else if (context.player.status === "running") {
12681
+ currentLine.push(mergedLine);
12682
+ } else if (context.player.status === "done") {
12683
+ prefixLines.push(mergedLine);
12684
+ } else if (context.player.status === "error") {
12685
+ prefixLines.push(mergedLine);
12686
+ }
12980
12687
  }
12981
12688
  }
12982
- for (index = 0, length = arguments.length; index < length; index += 1) {
12983
- arguments[index].forEach(collectType);
12689
+ const currentLineText = currentLine.length > 0 ? `
12690
+ ${paddingLines(currentLine).join("\n")}` : "";
12691
+ const prefix = prefixLines.length > 0 ? `
12692
+ ${paddingLines(prefixLines).join("\n")}` : "";
12693
+ const suffix = suffixText.length > 0 ? `
12694
+ ${paddingLines(suffixText).join("\n")}` : "";
12695
+ return `${fileInfo}${prefix}${currentLineText}${suffix}`;
12696
+ };
12697
+
12698
+ // src/tty-renderer.ts
12699
+ var import_node_util = require("util");
12700
+
12701
+ // ../../node_modules/.pnpm/restore-cursor@5.1.0/node_modules/restore-cursor/index.js
12702
+ var import_node_process = __toESM(require("process"));
12703
+
12704
+ // ../../node_modules/.pnpm/mimic-function@5.0.1/node_modules/mimic-function/index.js
12705
+ var copyProperty = (to, from, property, ignoreNonConfigurable) => {
12706
+ if (property === "length" || property === "prototype") {
12707
+ return;
12984
12708
  }
12985
- return result;
12986
- }
12987
- function Schema$1(definition) {
12988
- return this.extend(definition);
12989
- }
12990
- Schema$1.prototype.extend = function extend2(definition) {
12991
- var implicit = [];
12992
- var explicit = [];
12993
- if (definition instanceof type) {
12994
- explicit.push(definition);
12995
- } else if (Array.isArray(definition)) {
12996
- explicit = explicit.concat(definition);
12997
- } else if (definition && (Array.isArray(definition.implicit) || Array.isArray(definition.explicit))) {
12998
- if (definition.implicit)
12999
- implicit = implicit.concat(definition.implicit);
13000
- if (definition.explicit)
13001
- explicit = explicit.concat(definition.explicit);
13002
- } else {
13003
- throw new exception("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");
13004
- }
13005
- implicit.forEach(function(type$1) {
13006
- if (!(type$1 instanceof type)) {
13007
- throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
13008
- }
13009
- if (type$1.loadKind && type$1.loadKind !== "scalar") {
13010
- throw new exception("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");
13011
- }
13012
- if (type$1.multi) {
13013
- throw new exception("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.");
13014
- }
13015
- });
13016
- explicit.forEach(function(type$1) {
13017
- if (!(type$1 instanceof type)) {
13018
- throw new exception("Specified list of YAML types (or a single Type object) contains a non-Type object.");
13019
- }
13020
- });
13021
- var result = Object.create(Schema$1.prototype);
13022
- result.implicit = (this.implicit || []).concat(implicit);
13023
- result.explicit = (this.explicit || []).concat(explicit);
13024
- result.compiledImplicit = compileList(result, "implicit");
13025
- result.compiledExplicit = compileList(result, "explicit");
13026
- result.compiledTypeMap = compileMap(result.compiledImplicit, result.compiledExplicit);
13027
- return result;
13028
- };
13029
- var schema = Schema$1;
13030
- var str = new type("tag:yaml.org,2002:str", {
13031
- kind: "scalar",
13032
- construct: function(data) {
13033
- return data !== null ? data : "";
13034
- }
13035
- });
13036
- var seq = new type("tag:yaml.org,2002:seq", {
13037
- kind: "sequence",
13038
- construct: function(data) {
13039
- return data !== null ? data : [];
13040
- }
13041
- });
13042
- var map = new type("tag:yaml.org,2002:map", {
13043
- kind: "mapping",
13044
- construct: function(data) {
13045
- return data !== null ? data : {};
13046
- }
13047
- });
13048
- var failsafe = new schema({
13049
- explicit: [
13050
- str,
13051
- seq,
13052
- map
13053
- ]
13054
- });
13055
- function resolveYamlNull(data) {
13056
- if (data === null)
13057
- return true;
13058
- var max = data.length;
13059
- return max === 1 && data === "~" || max === 4 && (data === "null" || data === "Null" || data === "NULL");
13060
- }
13061
- function constructYamlNull() {
13062
- return null;
13063
- }
13064
- function isNull(object) {
13065
- return object === null;
13066
- }
13067
- var _null = new type("tag:yaml.org,2002:null", {
13068
- kind: "scalar",
13069
- resolve: resolveYamlNull,
13070
- construct: constructYamlNull,
13071
- predicate: isNull,
13072
- represent: {
13073
- canonical: function() {
13074
- return "~";
13075
- },
13076
- lowercase: function() {
13077
- return "null";
13078
- },
13079
- uppercase: function() {
13080
- return "NULL";
13081
- },
13082
- camelcase: function() {
13083
- return "Null";
13084
- },
13085
- empty: function() {
13086
- return "";
13087
- }
13088
- },
13089
- defaultStyle: "lowercase"
13090
- });
13091
- function resolveYamlBoolean(data) {
13092
- if (data === null)
13093
- return false;
13094
- var max = data.length;
13095
- return max === 4 && (data === "true" || data === "True" || data === "TRUE") || max === 5 && (data === "false" || data === "False" || data === "FALSE");
13096
- }
13097
- function constructYamlBoolean(data) {
13098
- return data === "true" || data === "True" || data === "TRUE";
13099
- }
13100
- function isBoolean(object) {
13101
- return Object.prototype.toString.call(object) === "[object Boolean]";
13102
- }
13103
- var bool = new type("tag:yaml.org,2002:bool", {
13104
- kind: "scalar",
13105
- resolve: resolveYamlBoolean,
13106
- construct: constructYamlBoolean,
13107
- predicate: isBoolean,
13108
- represent: {
13109
- lowercase: function(object) {
13110
- return object ? "true" : "false";
13111
- },
13112
- uppercase: function(object) {
13113
- return object ? "TRUE" : "FALSE";
13114
- },
13115
- camelcase: function(object) {
13116
- return object ? "True" : "False";
13117
- }
13118
- },
13119
- defaultStyle: "lowercase"
13120
- });
13121
- function isHexCode(c) {
13122
- return 48 <= c && c <= 57 || 65 <= c && c <= 70 || 97 <= c && c <= 102;
13123
- }
13124
- function isOctCode(c) {
13125
- return 48 <= c && c <= 55;
13126
- }
13127
- function isDecCode(c) {
13128
- return 48 <= c && c <= 57;
13129
- }
13130
- function resolveYamlInteger(data) {
13131
- if (data === null)
13132
- return false;
13133
- var max = data.length, index = 0, hasDigits = false, ch;
13134
- if (!max)
13135
- return false;
13136
- ch = data[index];
13137
- if (ch === "-" || ch === "+") {
13138
- ch = data[++index];
13139
- }
13140
- if (ch === "0") {
13141
- if (index + 1 === max)
13142
- return true;
13143
- ch = data[++index];
13144
- if (ch === "b") {
13145
- index++;
13146
- for (; index < max; index++) {
13147
- ch = data[index];
13148
- if (ch === "_")
13149
- continue;
13150
- if (ch !== "0" && ch !== "1")
13151
- return false;
13152
- hasDigits = true;
13153
- }
13154
- return hasDigits && ch !== "_";
13155
- }
13156
- if (ch === "x") {
13157
- index++;
13158
- for (; index < max; index++) {
13159
- ch = data[index];
13160
- if (ch === "_")
13161
- continue;
13162
- if (!isHexCode(data.charCodeAt(index)))
13163
- return false;
13164
- hasDigits = true;
13165
- }
13166
- return hasDigits && ch !== "_";
13167
- }
13168
- if (ch === "o") {
13169
- index++;
13170
- for (; index < max; index++) {
13171
- ch = data[index];
13172
- if (ch === "_")
13173
- continue;
13174
- if (!isOctCode(data.charCodeAt(index)))
13175
- return false;
13176
- hasDigits = true;
13177
- }
13178
- return hasDigits && ch !== "_";
13179
- }
13180
- }
13181
- if (ch === "_")
13182
- return false;
13183
- for (; index < max; index++) {
13184
- ch = data[index];
13185
- if (ch === "_")
13186
- continue;
13187
- if (!isDecCode(data.charCodeAt(index))) {
13188
- return false;
13189
- }
13190
- hasDigits = true;
13191
- }
13192
- if (!hasDigits || ch === "_")
13193
- return false;
13194
- return true;
13195
- }
13196
- function constructYamlInteger(data) {
13197
- var value = data, sign = 1, ch;
13198
- if (value.indexOf("_") !== -1) {
13199
- value = value.replace(/_/g, "");
13200
- }
13201
- ch = value[0];
13202
- if (ch === "-" || ch === "+") {
13203
- if (ch === "-")
13204
- sign = -1;
13205
- value = value.slice(1);
13206
- ch = value[0];
13207
- }
13208
- if (value === "0")
13209
- return 0;
13210
- if (ch === "0") {
13211
- if (value[1] === "b")
13212
- return sign * parseInt(value.slice(2), 2);
13213
- if (value[1] === "x")
13214
- return sign * parseInt(value.slice(2), 16);
13215
- if (value[1] === "o")
13216
- return sign * parseInt(value.slice(2), 8);
13217
- }
13218
- return sign * parseInt(value, 10);
13219
- }
13220
- function isInteger(object) {
13221
- return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 === 0 && !common.isNegativeZero(object));
13222
- }
13223
- var int = new type("tag:yaml.org,2002:int", {
13224
- kind: "scalar",
13225
- resolve: resolveYamlInteger,
13226
- construct: constructYamlInteger,
13227
- predicate: isInteger,
13228
- represent: {
13229
- binary: function(obj) {
13230
- return obj >= 0 ? "0b" + obj.toString(2) : "-0b" + obj.toString(2).slice(1);
13231
- },
13232
- octal: function(obj) {
13233
- return obj >= 0 ? "0o" + obj.toString(8) : "-0o" + obj.toString(8).slice(1);
13234
- },
13235
- decimal: function(obj) {
13236
- return obj.toString(10);
13237
- },
13238
- /* eslint-disable max-len */
13239
- hexadecimal: function(obj) {
13240
- return obj >= 0 ? "0x" + obj.toString(16).toUpperCase() : "-0x" + obj.toString(16).toUpperCase().slice(1);
13241
- }
13242
- },
13243
- defaultStyle: "decimal",
13244
- styleAliases: {
13245
- binary: [2, "bin"],
13246
- octal: [8, "oct"],
13247
- decimal: [10, "dec"],
13248
- hexadecimal: [16, "hex"]
13249
- }
13250
- });
13251
- var YAML_FLOAT_PATTERN = new RegExp(
13252
- // 2.5e4, 2.5 and integers
13253
- "^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$"
13254
- );
13255
- function resolveYamlFloat(data) {
13256
- if (data === null)
13257
- return false;
13258
- if (!YAML_FLOAT_PATTERN.test(data) || // Quick hack to not allow integers end with `_`
13259
- // Probably should update regexp & check speed
13260
- data[data.length - 1] === "_") {
13261
- return false;
13262
- }
13263
- return true;
13264
- }
13265
- function constructYamlFloat(data) {
13266
- var value, sign;
13267
- value = data.replace(/_/g, "").toLowerCase();
13268
- sign = value[0] === "-" ? -1 : 1;
13269
- if ("+-".indexOf(value[0]) >= 0) {
13270
- value = value.slice(1);
13271
- }
13272
- if (value === ".inf") {
13273
- return sign === 1 ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY;
13274
- } else if (value === ".nan") {
13275
- return NaN;
13276
- }
13277
- return sign * parseFloat(value, 10);
13278
- }
13279
- var SCIENTIFIC_WITHOUT_DOT = /^[-+]?[0-9]+e/;
13280
- function representYamlFloat(object, style) {
13281
- var res;
13282
- if (isNaN(object)) {
13283
- switch (style) {
13284
- case "lowercase":
13285
- return ".nan";
13286
- case "uppercase":
13287
- return ".NAN";
13288
- case "camelcase":
13289
- return ".NaN";
13290
- }
13291
- } else if (Number.POSITIVE_INFINITY === object) {
13292
- switch (style) {
13293
- case "lowercase":
13294
- return ".inf";
13295
- case "uppercase":
13296
- return ".INF";
13297
- case "camelcase":
13298
- return ".Inf";
13299
- }
13300
- } else if (Number.NEGATIVE_INFINITY === object) {
13301
- switch (style) {
13302
- case "lowercase":
13303
- return "-.inf";
13304
- case "uppercase":
13305
- return "-.INF";
13306
- case "camelcase":
13307
- return "-.Inf";
13308
- }
13309
- } else if (common.isNegativeZero(object)) {
13310
- return "-0.0";
13311
- }
13312
- res = object.toString(10);
13313
- return SCIENTIFIC_WITHOUT_DOT.test(res) ? res.replace("e", ".e") : res;
13314
- }
13315
- function isFloat(object) {
13316
- return Object.prototype.toString.call(object) === "[object Number]" && (object % 1 !== 0 || common.isNegativeZero(object));
13317
- }
13318
- var float = new type("tag:yaml.org,2002:float", {
13319
- kind: "scalar",
13320
- resolve: resolveYamlFloat,
13321
- construct: constructYamlFloat,
13322
- predicate: isFloat,
13323
- represent: representYamlFloat,
13324
- defaultStyle: "lowercase"
13325
- });
13326
- var json = failsafe.extend({
13327
- implicit: [
13328
- _null,
13329
- bool,
13330
- int,
13331
- float
13332
- ]
13333
- });
13334
- var core = json;
13335
- var YAML_DATE_REGEXP = new RegExp(
13336
- "^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"
13337
- );
13338
- var YAML_TIMESTAMP_REGEXP = new RegExp(
13339
- "^([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]))?))?$"
13340
- );
13341
- function resolveYamlTimestamp(data) {
13342
- if (data === null)
13343
- return false;
13344
- if (YAML_DATE_REGEXP.exec(data) !== null)
13345
- return true;
13346
- if (YAML_TIMESTAMP_REGEXP.exec(data) !== null)
13347
- return true;
13348
- return false;
13349
- }
13350
- function constructYamlTimestamp(data) {
13351
- var match2, year, month, day, hour, minute, second, fraction = 0, delta = null, tz_hour, tz_minute, date;
13352
- match2 = YAML_DATE_REGEXP.exec(data);
13353
- if (match2 === null)
13354
- match2 = YAML_TIMESTAMP_REGEXP.exec(data);
13355
- if (match2 === null)
13356
- throw new Error("Date resolve error");
13357
- year = +match2[1];
13358
- month = +match2[2] - 1;
13359
- day = +match2[3];
13360
- if (!match2[4]) {
13361
- return new Date(Date.UTC(year, month, day));
13362
- }
13363
- hour = +match2[4];
13364
- minute = +match2[5];
13365
- second = +match2[6];
13366
- if (match2[7]) {
13367
- fraction = match2[7].slice(0, 3);
13368
- while (fraction.length < 3) {
13369
- fraction += "0";
13370
- }
13371
- fraction = +fraction;
13372
- }
13373
- if (match2[9]) {
13374
- tz_hour = +match2[10];
13375
- tz_minute = +(match2[11] || 0);
13376
- delta = (tz_hour * 60 + tz_minute) * 6e4;
13377
- if (match2[9] === "-")
13378
- delta = -delta;
13379
- }
13380
- date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction));
13381
- if (delta)
13382
- date.setTime(date.getTime() - delta);
13383
- return date;
13384
- }
13385
- function representYamlTimestamp(object) {
13386
- return object.toISOString();
13387
- }
13388
- var timestamp = new type("tag:yaml.org,2002:timestamp", {
13389
- kind: "scalar",
13390
- resolve: resolveYamlTimestamp,
13391
- construct: constructYamlTimestamp,
13392
- instanceOf: Date,
13393
- represent: representYamlTimestamp
13394
- });
13395
- function resolveYamlMerge(data) {
13396
- return data === "<<" || data === null;
13397
- }
13398
- var merge = new type("tag:yaml.org,2002:merge", {
13399
- kind: "scalar",
13400
- resolve: resolveYamlMerge
13401
- });
13402
- var BASE64_MAP = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\n\r";
13403
- function resolveYamlBinary(data) {
13404
- if (data === null)
13405
- return false;
13406
- var code, idx, bitlen = 0, max = data.length, map2 = BASE64_MAP;
13407
- for (idx = 0; idx < max; idx++) {
13408
- code = map2.indexOf(data.charAt(idx));
13409
- if (code > 64)
13410
- continue;
13411
- if (code < 0)
13412
- return false;
13413
- bitlen += 6;
13414
- }
13415
- return bitlen % 8 === 0;
13416
- }
13417
- function constructYamlBinary(data) {
13418
- var idx, tailbits, input = data.replace(/[\r\n=]/g, ""), max = input.length, map2 = BASE64_MAP, bits = 0, result = [];
13419
- for (idx = 0; idx < max; idx++) {
13420
- if (idx % 4 === 0 && idx) {
13421
- result.push(bits >> 16 & 255);
13422
- result.push(bits >> 8 & 255);
13423
- result.push(bits & 255);
13424
- }
13425
- bits = bits << 6 | map2.indexOf(input.charAt(idx));
13426
- }
13427
- tailbits = max % 4 * 6;
13428
- if (tailbits === 0) {
13429
- result.push(bits >> 16 & 255);
13430
- result.push(bits >> 8 & 255);
13431
- result.push(bits & 255);
13432
- } else if (tailbits === 18) {
13433
- result.push(bits >> 10 & 255);
13434
- result.push(bits >> 2 & 255);
13435
- } else if (tailbits === 12) {
13436
- result.push(bits >> 4 & 255);
13437
- }
13438
- return new Uint8Array(result);
13439
- }
13440
- function representYamlBinary(object) {
13441
- var result = "", bits = 0, idx, tail, max = object.length, map2 = BASE64_MAP;
13442
- for (idx = 0; idx < max; idx++) {
13443
- if (idx % 3 === 0 && idx) {
13444
- result += map2[bits >> 18 & 63];
13445
- result += map2[bits >> 12 & 63];
13446
- result += map2[bits >> 6 & 63];
13447
- result += map2[bits & 63];
13448
- }
13449
- bits = (bits << 8) + object[idx];
13450
- }
13451
- tail = max % 3;
13452
- if (tail === 0) {
13453
- result += map2[bits >> 18 & 63];
13454
- result += map2[bits >> 12 & 63];
13455
- result += map2[bits >> 6 & 63];
13456
- result += map2[bits & 63];
13457
- } else if (tail === 2) {
13458
- result += map2[bits >> 10 & 63];
13459
- result += map2[bits >> 4 & 63];
13460
- result += map2[bits << 2 & 63];
13461
- result += map2[64];
13462
- } else if (tail === 1) {
13463
- result += map2[bits >> 2 & 63];
13464
- result += map2[bits << 4 & 63];
13465
- result += map2[64];
13466
- result += map2[64];
13467
- }
13468
- return result;
13469
- }
13470
- function isBinary(obj) {
13471
- return Object.prototype.toString.call(obj) === "[object Uint8Array]";
13472
- }
13473
- var binary = new type("tag:yaml.org,2002:binary", {
13474
- kind: "scalar",
13475
- resolve: resolveYamlBinary,
13476
- construct: constructYamlBinary,
13477
- predicate: isBinary,
13478
- represent: representYamlBinary
13479
- });
13480
- var _hasOwnProperty$3 = Object.prototype.hasOwnProperty;
13481
- var _toString$2 = Object.prototype.toString;
13482
- function resolveYamlOmap(data) {
13483
- if (data === null)
13484
- return true;
13485
- var objectKeys = [], index, length, pair, pairKey, pairHasKey, object = data;
13486
- for (index = 0, length = object.length; index < length; index += 1) {
13487
- pair = object[index];
13488
- pairHasKey = false;
13489
- if (_toString$2.call(pair) !== "[object Object]")
13490
- return false;
13491
- for (pairKey in pair) {
13492
- if (_hasOwnProperty$3.call(pair, pairKey)) {
13493
- if (!pairHasKey)
13494
- pairHasKey = true;
13495
- else
13496
- return false;
13497
- }
13498
- }
13499
- if (!pairHasKey)
13500
- return false;
13501
- if (objectKeys.indexOf(pairKey) === -1)
13502
- objectKeys.push(pairKey);
13503
- else
13504
- return false;
13505
- }
13506
- return true;
13507
- }
13508
- function constructYamlOmap(data) {
13509
- return data !== null ? data : [];
13510
- }
13511
- var omap = new type("tag:yaml.org,2002:omap", {
13512
- kind: "sequence",
13513
- resolve: resolveYamlOmap,
13514
- construct: constructYamlOmap
13515
- });
13516
- var _toString$1 = Object.prototype.toString;
13517
- function resolveYamlPairs(data) {
13518
- if (data === null)
13519
- return true;
13520
- var index, length, pair, keys, result, object = data;
13521
- result = new Array(object.length);
13522
- for (index = 0, length = object.length; index < length; index += 1) {
13523
- pair = object[index];
13524
- if (_toString$1.call(pair) !== "[object Object]")
13525
- return false;
13526
- keys = Object.keys(pair);
13527
- if (keys.length !== 1)
13528
- return false;
13529
- result[index] = [keys[0], pair[keys[0]]];
13530
- }
13531
- return true;
13532
- }
13533
- function constructYamlPairs(data) {
13534
- if (data === null)
13535
- return [];
13536
- var index, length, pair, keys, result, object = data;
13537
- result = new Array(object.length);
13538
- for (index = 0, length = object.length; index < length; index += 1) {
13539
- pair = object[index];
13540
- keys = Object.keys(pair);
13541
- result[index] = [keys[0], pair[keys[0]]];
13542
- }
13543
- return result;
13544
- }
13545
- var pairs = new type("tag:yaml.org,2002:pairs", {
13546
- kind: "sequence",
13547
- resolve: resolveYamlPairs,
13548
- construct: constructYamlPairs
13549
- });
13550
- var _hasOwnProperty$2 = Object.prototype.hasOwnProperty;
13551
- function resolveYamlSet(data) {
13552
- if (data === null)
13553
- return true;
13554
- var key, object = data;
13555
- for (key in object) {
13556
- if (_hasOwnProperty$2.call(object, key)) {
13557
- if (object[key] !== null)
13558
- return false;
13559
- }
13560
- }
13561
- return true;
13562
- }
13563
- function constructYamlSet(data) {
13564
- return data !== null ? data : {};
13565
- }
13566
- var set = new type("tag:yaml.org,2002:set", {
13567
- kind: "mapping",
13568
- resolve: resolveYamlSet,
13569
- construct: constructYamlSet
13570
- });
13571
- var _default = core.extend({
13572
- implicit: [
13573
- timestamp,
13574
- merge
13575
- ],
13576
- explicit: [
13577
- binary,
13578
- omap,
13579
- pairs,
13580
- set
13581
- ]
13582
- });
13583
- var _hasOwnProperty$1 = Object.prototype.hasOwnProperty;
13584
- var CONTEXT_FLOW_IN = 1;
13585
- var CONTEXT_FLOW_OUT = 2;
13586
- var CONTEXT_BLOCK_IN = 3;
13587
- var CONTEXT_BLOCK_OUT = 4;
13588
- var CHOMPING_CLIP = 1;
13589
- var CHOMPING_STRIP = 2;
13590
- var CHOMPING_KEEP = 3;
13591
- var PATTERN_NON_PRINTABLE = /[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/;
13592
- var PATTERN_NON_ASCII_LINE_BREAKS = /[\x85\u2028\u2029]/;
13593
- var PATTERN_FLOW_INDICATORS = /[,\[\]\{\}]/;
13594
- var PATTERN_TAG_HANDLE = /^(?:!|!!|![a-z\-]+!)$/i;
13595
- var PATTERN_TAG_URI = /^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;
13596
- function _class(obj) {
13597
- return Object.prototype.toString.call(obj);
13598
- }
13599
- function is_EOL(c) {
13600
- return c === 10 || c === 13;
13601
- }
13602
- function is_WHITE_SPACE(c) {
13603
- return c === 9 || c === 32;
13604
- }
13605
- function is_WS_OR_EOL(c) {
13606
- return c === 9 || c === 32 || c === 10 || c === 13;
13607
- }
13608
- function is_FLOW_INDICATOR(c) {
13609
- return c === 44 || c === 91 || c === 93 || c === 123 || c === 125;
13610
- }
13611
- function fromHexCode(c) {
13612
- var lc;
13613
- if (48 <= c && c <= 57) {
13614
- return c - 48;
13615
- }
13616
- lc = c | 32;
13617
- if (97 <= lc && lc <= 102) {
13618
- return lc - 97 + 10;
13619
- }
13620
- return -1;
13621
- }
13622
- function escapedHexLen(c) {
13623
- if (c === 120) {
13624
- return 2;
13625
- }
13626
- if (c === 117) {
13627
- return 4;
13628
- }
13629
- if (c === 85) {
13630
- return 8;
13631
- }
13632
- return 0;
13633
- }
13634
- function fromDecimalCode(c) {
13635
- if (48 <= c && c <= 57) {
13636
- return c - 48;
13637
- }
13638
- return -1;
13639
- }
13640
- function simpleEscapeSequence(c) {
13641
- 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 ? "…" : c === 95 ? " " : c === 76 ? "\u2028" : c === 80 ? "\u2029" : "";
13642
- }
13643
- function charFromCodepoint(c) {
13644
- if (c <= 65535) {
13645
- return String.fromCharCode(c);
13646
- }
13647
- return String.fromCharCode(
13648
- (c - 65536 >> 10) + 55296,
13649
- (c - 65536 & 1023) + 56320
13650
- );
13651
- }
13652
- var simpleEscapeCheck = new Array(256);
13653
- var simpleEscapeMap = new Array(256);
13654
- for (i = 0; i < 256; i++) {
13655
- simpleEscapeCheck[i] = simpleEscapeSequence(i) ? 1 : 0;
13656
- simpleEscapeMap[i] = simpleEscapeSequence(i);
13657
- }
13658
- var i;
13659
- function State$1(input, options) {
13660
- this.input = input;
13661
- this.filename = options["filename"] || null;
13662
- this.schema = options["schema"] || _default;
13663
- this.onWarning = options["onWarning"] || null;
13664
- this.legacy = options["legacy"] || false;
13665
- this.json = options["json"] || false;
13666
- this.listener = options["listener"] || null;
13667
- this.implicitTypes = this.schema.compiledImplicit;
13668
- this.typeMap = this.schema.compiledTypeMap;
13669
- this.length = input.length;
13670
- this.position = 0;
13671
- this.line = 0;
13672
- this.lineStart = 0;
13673
- this.lineIndent = 0;
13674
- this.firstTabInLine = -1;
13675
- this.documents = [];
13676
- }
13677
- function generateError(state, message) {
13678
- var mark = {
13679
- name: state.filename,
13680
- buffer: state.input.slice(0, -1),
13681
- // omit trailing \0
13682
- position: state.position,
13683
- line: state.line,
13684
- column: state.position - state.lineStart
13685
- };
13686
- mark.snippet = snippet(mark);
13687
- return new exception(message, mark);
13688
- }
13689
- function throwError(state, message) {
13690
- throw generateError(state, message);
13691
- }
13692
- function throwWarning(state, message) {
13693
- if (state.onWarning) {
13694
- state.onWarning.call(null, generateError(state, message));
13695
- }
13696
- }
13697
- var directiveHandlers = {
13698
- YAML: function handleYamlDirective(state, name, args) {
13699
- var match2, major, minor;
13700
- if (state.version !== null) {
13701
- throwError(state, "duplication of %YAML directive");
13702
- }
13703
- if (args.length !== 1) {
13704
- throwError(state, "YAML directive accepts exactly one argument");
13705
- }
13706
- match2 = /^([0-9]+)\.([0-9]+)$/.exec(args[0]);
13707
- if (match2 === null) {
13708
- throwError(state, "ill-formed argument of the YAML directive");
13709
- }
13710
- major = parseInt(match2[1], 10);
13711
- minor = parseInt(match2[2], 10);
13712
- if (major !== 1) {
13713
- throwError(state, "unacceptable YAML version of the document");
13714
- }
13715
- state.version = args[0];
13716
- state.checkLineBreaks = minor < 2;
13717
- if (minor !== 1 && minor !== 2) {
13718
- throwWarning(state, "unsupported YAML version of the document");
13719
- }
13720
- },
13721
- TAG: function handleTagDirective(state, name, args) {
13722
- var handle, prefix;
13723
- if (args.length !== 2) {
13724
- throwError(state, "TAG directive accepts exactly two arguments");
13725
- }
13726
- handle = args[0];
13727
- prefix = args[1];
13728
- if (!PATTERN_TAG_HANDLE.test(handle)) {
13729
- throwError(state, "ill-formed tag handle (first argument) of the TAG directive");
13730
- }
13731
- if (_hasOwnProperty$1.call(state.tagMap, handle)) {
13732
- throwError(state, 'there is a previously declared suffix for "' + handle + '" tag handle');
13733
- }
13734
- if (!PATTERN_TAG_URI.test(prefix)) {
13735
- throwError(state, "ill-formed tag prefix (second argument) of the TAG directive");
13736
- }
13737
- try {
13738
- prefix = decodeURIComponent(prefix);
13739
- } catch (err) {
13740
- throwError(state, "tag prefix is malformed: " + prefix);
13741
- }
13742
- state.tagMap[handle] = prefix;
13743
- }
13744
- };
13745
- function captureSegment(state, start, end, checkJson) {
13746
- var _position, _length, _character, _result;
13747
- if (start < end) {
13748
- _result = state.input.slice(start, end);
13749
- if (checkJson) {
13750
- for (_position = 0, _length = _result.length; _position < _length; _position += 1) {
13751
- _character = _result.charCodeAt(_position);
13752
- if (!(_character === 9 || 32 <= _character && _character <= 1114111)) {
13753
- throwError(state, "expected valid JSON character");
13754
- }
13755
- }
13756
- } else if (PATTERN_NON_PRINTABLE.test(_result)) {
13757
- throwError(state, "the stream contains non-printable characters");
13758
- }
13759
- state.result += _result;
13760
- }
13761
- }
13762
- function mergeMappings(state, destination, source, overridableKeys) {
13763
- var sourceKeys, key, index, quantity;
13764
- if (!common.isObject(source)) {
13765
- throwError(state, "cannot merge mappings; the provided source object is unacceptable");
13766
- }
13767
- sourceKeys = Object.keys(source);
13768
- for (index = 0, quantity = sourceKeys.length; index < quantity; index += 1) {
13769
- key = sourceKeys[index];
13770
- if (!_hasOwnProperty$1.call(destination, key)) {
13771
- destination[key] = source[key];
13772
- overridableKeys[key] = true;
13773
- }
13774
- }
13775
- }
13776
- function storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, startLine, startLineStart, startPos) {
13777
- var index, quantity;
13778
- if (Array.isArray(keyNode)) {
13779
- keyNode = Array.prototype.slice.call(keyNode);
13780
- for (index = 0, quantity = keyNode.length; index < quantity; index += 1) {
13781
- if (Array.isArray(keyNode[index])) {
13782
- throwError(state, "nested arrays are not supported inside keys");
13783
- }
13784
- if (typeof keyNode === "object" && _class(keyNode[index]) === "[object Object]") {
13785
- keyNode[index] = "[object Object]";
13786
- }
13787
- }
13788
- }
13789
- if (typeof keyNode === "object" && _class(keyNode) === "[object Object]") {
13790
- keyNode = "[object Object]";
13791
- }
13792
- keyNode = String(keyNode);
13793
- if (_result === null) {
13794
- _result = {};
13795
- }
13796
- if (keyTag === "tag:yaml.org,2002:merge") {
13797
- if (Array.isArray(valueNode)) {
13798
- for (index = 0, quantity = valueNode.length; index < quantity; index += 1) {
13799
- mergeMappings(state, _result, valueNode[index], overridableKeys);
13800
- }
13801
- } else {
13802
- mergeMappings(state, _result, valueNode, overridableKeys);
13803
- }
13804
- } else {
13805
- if (!state.json && !_hasOwnProperty$1.call(overridableKeys, keyNode) && _hasOwnProperty$1.call(_result, keyNode)) {
13806
- state.line = startLine || state.line;
13807
- state.lineStart = startLineStart || state.lineStart;
13808
- state.position = startPos || state.position;
13809
- throwError(state, "duplicated mapping key");
13810
- }
13811
- if (keyNode === "__proto__") {
13812
- Object.defineProperty(_result, keyNode, {
13813
- configurable: true,
13814
- enumerable: true,
13815
- writable: true,
13816
- value: valueNode
13817
- });
13818
- } else {
13819
- _result[keyNode] = valueNode;
13820
- }
13821
- delete overridableKeys[keyNode];
13822
- }
13823
- return _result;
13824
- }
13825
- function readLineBreak(state) {
13826
- var ch;
13827
- ch = state.input.charCodeAt(state.position);
13828
- if (ch === 10) {
13829
- state.position++;
13830
- } else if (ch === 13) {
13831
- state.position++;
13832
- if (state.input.charCodeAt(state.position) === 10) {
13833
- state.position++;
13834
- }
13835
- } else {
13836
- throwError(state, "a line break is expected");
13837
- }
13838
- state.line += 1;
13839
- state.lineStart = state.position;
13840
- state.firstTabInLine = -1;
13841
- }
13842
- function skipSeparationSpace(state, allowComments, checkIndent) {
13843
- var lineBreaks = 0, ch = state.input.charCodeAt(state.position);
13844
- while (ch !== 0) {
13845
- while (is_WHITE_SPACE(ch)) {
13846
- if (ch === 9 && state.firstTabInLine === -1) {
13847
- state.firstTabInLine = state.position;
13848
- }
13849
- ch = state.input.charCodeAt(++state.position);
13850
- }
13851
- if (allowComments && ch === 35) {
13852
- do {
13853
- ch = state.input.charCodeAt(++state.position);
13854
- } while (ch !== 10 && ch !== 13 && ch !== 0);
13855
- }
13856
- if (is_EOL(ch)) {
13857
- readLineBreak(state);
13858
- ch = state.input.charCodeAt(state.position);
13859
- lineBreaks++;
13860
- state.lineIndent = 0;
13861
- while (ch === 32) {
13862
- state.lineIndent++;
13863
- ch = state.input.charCodeAt(++state.position);
13864
- }
13865
- } else {
13866
- break;
13867
- }
13868
- }
13869
- if (checkIndent !== -1 && lineBreaks !== 0 && state.lineIndent < checkIndent) {
13870
- throwWarning(state, "deficient indentation");
13871
- }
13872
- return lineBreaks;
13873
- }
13874
- function testDocumentSeparator(state) {
13875
- var _position = state.position, ch;
13876
- ch = state.input.charCodeAt(_position);
13877
- if ((ch === 45 || ch === 46) && ch === state.input.charCodeAt(_position + 1) && ch === state.input.charCodeAt(_position + 2)) {
13878
- _position += 3;
13879
- ch = state.input.charCodeAt(_position);
13880
- if (ch === 0 || is_WS_OR_EOL(ch)) {
13881
- return true;
13882
- }
13883
- }
13884
- return false;
13885
- }
13886
- function writeFoldedLines(state, count) {
13887
- if (count === 1) {
13888
- state.result += " ";
13889
- } else if (count > 1) {
13890
- state.result += common.repeat("\n", count - 1);
13891
- }
13892
- }
13893
- function readPlainScalar(state, nodeIndent, withinFlowCollection) {
13894
- var preceding, following, captureStart, captureEnd, hasPendingContent, _line, _lineStart, _lineIndent, _kind = state.kind, _result = state.result, ch;
13895
- ch = state.input.charCodeAt(state.position);
13896
- 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) {
13897
- return false;
13898
- }
13899
- if (ch === 63 || ch === 45) {
13900
- following = state.input.charCodeAt(state.position + 1);
13901
- if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
13902
- return false;
13903
- }
13904
- }
13905
- state.kind = "scalar";
13906
- state.result = "";
13907
- captureStart = captureEnd = state.position;
13908
- hasPendingContent = false;
13909
- while (ch !== 0) {
13910
- if (ch === 58) {
13911
- following = state.input.charCodeAt(state.position + 1);
13912
- if (is_WS_OR_EOL(following) || withinFlowCollection && is_FLOW_INDICATOR(following)) {
13913
- break;
13914
- }
13915
- } else if (ch === 35) {
13916
- preceding = state.input.charCodeAt(state.position - 1);
13917
- if (is_WS_OR_EOL(preceding)) {
13918
- break;
13919
- }
13920
- } else if (state.position === state.lineStart && testDocumentSeparator(state) || withinFlowCollection && is_FLOW_INDICATOR(ch)) {
13921
- break;
13922
- } else if (is_EOL(ch)) {
13923
- _line = state.line;
13924
- _lineStart = state.lineStart;
13925
- _lineIndent = state.lineIndent;
13926
- skipSeparationSpace(state, false, -1);
13927
- if (state.lineIndent >= nodeIndent) {
13928
- hasPendingContent = true;
13929
- ch = state.input.charCodeAt(state.position);
13930
- continue;
13931
- } else {
13932
- state.position = captureEnd;
13933
- state.line = _line;
13934
- state.lineStart = _lineStart;
13935
- state.lineIndent = _lineIndent;
13936
- break;
13937
- }
13938
- }
13939
- if (hasPendingContent) {
13940
- captureSegment(state, captureStart, captureEnd, false);
13941
- writeFoldedLines(state, state.line - _line);
13942
- captureStart = captureEnd = state.position;
13943
- hasPendingContent = false;
13944
- }
13945
- if (!is_WHITE_SPACE(ch)) {
13946
- captureEnd = state.position + 1;
13947
- }
13948
- ch = state.input.charCodeAt(++state.position);
13949
- }
13950
- captureSegment(state, captureStart, captureEnd, false);
13951
- if (state.result) {
13952
- return true;
13953
- }
13954
- state.kind = _kind;
13955
- state.result = _result;
13956
- return false;
13957
- }
13958
- function readSingleQuotedScalar(state, nodeIndent) {
13959
- var ch, captureStart, captureEnd;
13960
- ch = state.input.charCodeAt(state.position);
13961
- if (ch !== 39) {
13962
- return false;
13963
- }
13964
- state.kind = "scalar";
13965
- state.result = "";
13966
- state.position++;
13967
- captureStart = captureEnd = state.position;
13968
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
13969
- if (ch === 39) {
13970
- captureSegment(state, captureStart, state.position, true);
13971
- ch = state.input.charCodeAt(++state.position);
13972
- if (ch === 39) {
13973
- captureStart = state.position;
13974
- state.position++;
13975
- captureEnd = state.position;
13976
- } else {
13977
- return true;
13978
- }
13979
- } else if (is_EOL(ch)) {
13980
- captureSegment(state, captureStart, captureEnd, true);
13981
- writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
13982
- captureStart = captureEnd = state.position;
13983
- } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
13984
- throwError(state, "unexpected end of the document within a single quoted scalar");
13985
- } else {
13986
- state.position++;
13987
- captureEnd = state.position;
13988
- }
13989
- }
13990
- throwError(state, "unexpected end of the stream within a single quoted scalar");
13991
- }
13992
- function readDoubleQuotedScalar(state, nodeIndent) {
13993
- var captureStart, captureEnd, hexLength, hexResult, tmp, ch;
13994
- ch = state.input.charCodeAt(state.position);
13995
- if (ch !== 34) {
13996
- return false;
13997
- }
13998
- state.kind = "scalar";
13999
- state.result = "";
14000
- state.position++;
14001
- captureStart = captureEnd = state.position;
14002
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
14003
- if (ch === 34) {
14004
- captureSegment(state, captureStart, state.position, true);
14005
- state.position++;
14006
- return true;
14007
- } else if (ch === 92) {
14008
- captureSegment(state, captureStart, state.position, true);
14009
- ch = state.input.charCodeAt(++state.position);
14010
- if (is_EOL(ch)) {
14011
- skipSeparationSpace(state, false, nodeIndent);
14012
- } else if (ch < 256 && simpleEscapeCheck[ch]) {
14013
- state.result += simpleEscapeMap[ch];
14014
- state.position++;
14015
- } else if ((tmp = escapedHexLen(ch)) > 0) {
14016
- hexLength = tmp;
14017
- hexResult = 0;
14018
- for (; hexLength > 0; hexLength--) {
14019
- ch = state.input.charCodeAt(++state.position);
14020
- if ((tmp = fromHexCode(ch)) >= 0) {
14021
- hexResult = (hexResult << 4) + tmp;
14022
- } else {
14023
- throwError(state, "expected hexadecimal character");
14024
- }
14025
- }
14026
- state.result += charFromCodepoint(hexResult);
14027
- state.position++;
14028
- } else {
14029
- throwError(state, "unknown escape sequence");
14030
- }
14031
- captureStart = captureEnd = state.position;
14032
- } else if (is_EOL(ch)) {
14033
- captureSegment(state, captureStart, captureEnd, true);
14034
- writeFoldedLines(state, skipSeparationSpace(state, false, nodeIndent));
14035
- captureStart = captureEnd = state.position;
14036
- } else if (state.position === state.lineStart && testDocumentSeparator(state)) {
14037
- throwError(state, "unexpected end of the document within a double quoted scalar");
14038
- } else {
14039
- state.position++;
14040
- captureEnd = state.position;
14041
- }
14042
- }
14043
- throwError(state, "unexpected end of the stream within a double quoted scalar");
14044
- }
14045
- function readFlowCollection(state, nodeIndent) {
14046
- 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;
14047
- ch = state.input.charCodeAt(state.position);
14048
- if (ch === 91) {
14049
- terminator = 93;
14050
- isMapping = false;
14051
- _result = [];
14052
- } else if (ch === 123) {
14053
- terminator = 125;
14054
- isMapping = true;
14055
- _result = {};
14056
- } else {
14057
- return false;
14058
- }
14059
- if (state.anchor !== null) {
14060
- state.anchorMap[state.anchor] = _result;
14061
- }
14062
- ch = state.input.charCodeAt(++state.position);
14063
- while (ch !== 0) {
14064
- skipSeparationSpace(state, true, nodeIndent);
14065
- ch = state.input.charCodeAt(state.position);
14066
- if (ch === terminator) {
14067
- state.position++;
14068
- state.tag = _tag;
14069
- state.anchor = _anchor;
14070
- state.kind = isMapping ? "mapping" : "sequence";
14071
- state.result = _result;
14072
- return true;
14073
- } else if (!readNext) {
14074
- throwError(state, "missed comma between flow collection entries");
14075
- } else if (ch === 44) {
14076
- throwError(state, "expected the node content, but found ','");
14077
- }
14078
- keyTag = keyNode = valueNode = null;
14079
- isPair = isExplicitPair = false;
14080
- if (ch === 63) {
14081
- following = state.input.charCodeAt(state.position + 1);
14082
- if (is_WS_OR_EOL(following)) {
14083
- isPair = isExplicitPair = true;
14084
- state.position++;
14085
- skipSeparationSpace(state, true, nodeIndent);
14086
- }
14087
- }
14088
- _line = state.line;
14089
- _lineStart = state.lineStart;
14090
- _pos = state.position;
14091
- composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
14092
- keyTag = state.tag;
14093
- keyNode = state.result;
14094
- skipSeparationSpace(state, true, nodeIndent);
14095
- ch = state.input.charCodeAt(state.position);
14096
- if ((isExplicitPair || state.line === _line) && ch === 58) {
14097
- isPair = true;
14098
- ch = state.input.charCodeAt(++state.position);
14099
- skipSeparationSpace(state, true, nodeIndent);
14100
- composeNode(state, nodeIndent, CONTEXT_FLOW_IN, false, true);
14101
- valueNode = state.result;
14102
- }
14103
- if (isMapping) {
14104
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos);
14105
- } else if (isPair) {
14106
- _result.push(storeMappingPair(state, null, overridableKeys, keyTag, keyNode, valueNode, _line, _lineStart, _pos));
14107
- } else {
14108
- _result.push(keyNode);
14109
- }
14110
- skipSeparationSpace(state, true, nodeIndent);
14111
- ch = state.input.charCodeAt(state.position);
14112
- if (ch === 44) {
14113
- readNext = true;
14114
- ch = state.input.charCodeAt(++state.position);
14115
- } else {
14116
- readNext = false;
14117
- }
14118
- }
14119
- throwError(state, "unexpected end of the stream within a flow collection");
14120
- }
14121
- function readBlockScalar(state, nodeIndent) {
14122
- var captureStart, folding, chomping = CHOMPING_CLIP, didReadContent = false, detectedIndent = false, textIndent = nodeIndent, emptyLines = 0, atMoreIndented = false, tmp, ch;
14123
- ch = state.input.charCodeAt(state.position);
14124
- if (ch === 124) {
14125
- folding = false;
14126
- } else if (ch === 62) {
14127
- folding = true;
14128
- } else {
14129
- return false;
14130
- }
14131
- state.kind = "scalar";
14132
- state.result = "";
14133
- while (ch !== 0) {
14134
- ch = state.input.charCodeAt(++state.position);
14135
- if (ch === 43 || ch === 45) {
14136
- if (CHOMPING_CLIP === chomping) {
14137
- chomping = ch === 43 ? CHOMPING_KEEP : CHOMPING_STRIP;
14138
- } else {
14139
- throwError(state, "repeat of a chomping mode identifier");
14140
- }
14141
- } else if ((tmp = fromDecimalCode(ch)) >= 0) {
14142
- if (tmp === 0) {
14143
- throwError(state, "bad explicit indentation width of a block scalar; it cannot be less than one");
14144
- } else if (!detectedIndent) {
14145
- textIndent = nodeIndent + tmp - 1;
14146
- detectedIndent = true;
14147
- } else {
14148
- throwError(state, "repeat of an indentation width identifier");
14149
- }
14150
- } else {
14151
- break;
14152
- }
14153
- }
14154
- if (is_WHITE_SPACE(ch)) {
14155
- do {
14156
- ch = state.input.charCodeAt(++state.position);
14157
- } while (is_WHITE_SPACE(ch));
14158
- if (ch === 35) {
14159
- do {
14160
- ch = state.input.charCodeAt(++state.position);
14161
- } while (!is_EOL(ch) && ch !== 0);
14162
- }
14163
- }
14164
- while (ch !== 0) {
14165
- readLineBreak(state);
14166
- state.lineIndent = 0;
14167
- ch = state.input.charCodeAt(state.position);
14168
- while ((!detectedIndent || state.lineIndent < textIndent) && ch === 32) {
14169
- state.lineIndent++;
14170
- ch = state.input.charCodeAt(++state.position);
14171
- }
14172
- if (!detectedIndent && state.lineIndent > textIndent) {
14173
- textIndent = state.lineIndent;
14174
- }
14175
- if (is_EOL(ch)) {
14176
- emptyLines++;
14177
- continue;
14178
- }
14179
- if (state.lineIndent < textIndent) {
14180
- if (chomping === CHOMPING_KEEP) {
14181
- state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
14182
- } else if (chomping === CHOMPING_CLIP) {
14183
- if (didReadContent) {
14184
- state.result += "\n";
14185
- }
14186
- }
14187
- break;
14188
- }
14189
- if (folding) {
14190
- if (is_WHITE_SPACE(ch)) {
14191
- atMoreIndented = true;
14192
- state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
14193
- } else if (atMoreIndented) {
14194
- atMoreIndented = false;
14195
- state.result += common.repeat("\n", emptyLines + 1);
14196
- } else if (emptyLines === 0) {
14197
- if (didReadContent) {
14198
- state.result += " ";
14199
- }
14200
- } else {
14201
- state.result += common.repeat("\n", emptyLines);
14202
- }
14203
- } else {
14204
- state.result += common.repeat("\n", didReadContent ? 1 + emptyLines : emptyLines);
14205
- }
14206
- didReadContent = true;
14207
- detectedIndent = true;
14208
- emptyLines = 0;
14209
- captureStart = state.position;
14210
- while (!is_EOL(ch) && ch !== 0) {
14211
- ch = state.input.charCodeAt(++state.position);
14212
- }
14213
- captureSegment(state, captureStart, state.position, false);
14214
- }
14215
- return true;
14216
- }
14217
- function readBlockSequence(state, nodeIndent) {
14218
- var _line, _tag = state.tag, _anchor = state.anchor, _result = [], following, detected = false, ch;
14219
- if (state.firstTabInLine !== -1)
14220
- return false;
14221
- if (state.anchor !== null) {
14222
- state.anchorMap[state.anchor] = _result;
14223
- }
14224
- ch = state.input.charCodeAt(state.position);
14225
- while (ch !== 0) {
14226
- if (state.firstTabInLine !== -1) {
14227
- state.position = state.firstTabInLine;
14228
- throwError(state, "tab characters must not be used in indentation");
14229
- }
14230
- if (ch !== 45) {
14231
- break;
14232
- }
14233
- following = state.input.charCodeAt(state.position + 1);
14234
- if (!is_WS_OR_EOL(following)) {
14235
- break;
14236
- }
14237
- detected = true;
14238
- state.position++;
14239
- if (skipSeparationSpace(state, true, -1)) {
14240
- if (state.lineIndent <= nodeIndent) {
14241
- _result.push(null);
14242
- ch = state.input.charCodeAt(state.position);
14243
- continue;
14244
- }
14245
- }
14246
- _line = state.line;
14247
- composeNode(state, nodeIndent, CONTEXT_BLOCK_IN, false, true);
14248
- _result.push(state.result);
14249
- skipSeparationSpace(state, true, -1);
14250
- ch = state.input.charCodeAt(state.position);
14251
- if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
14252
- throwError(state, "bad indentation of a sequence entry");
14253
- } else if (state.lineIndent < nodeIndent) {
14254
- break;
14255
- }
14256
- }
14257
- if (detected) {
14258
- state.tag = _tag;
14259
- state.anchor = _anchor;
14260
- state.kind = "sequence";
14261
- state.result = _result;
14262
- return true;
14263
- }
14264
- return false;
14265
- }
14266
- function readBlockMapping(state, nodeIndent, flowIndent) {
14267
- 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;
14268
- if (state.firstTabInLine !== -1)
14269
- return false;
14270
- if (state.anchor !== null) {
14271
- state.anchorMap[state.anchor] = _result;
14272
- }
14273
- ch = state.input.charCodeAt(state.position);
14274
- while (ch !== 0) {
14275
- if (!atExplicitKey && state.firstTabInLine !== -1) {
14276
- state.position = state.firstTabInLine;
14277
- throwError(state, "tab characters must not be used in indentation");
14278
- }
14279
- following = state.input.charCodeAt(state.position + 1);
14280
- _line = state.line;
14281
- if ((ch === 63 || ch === 58) && is_WS_OR_EOL(following)) {
14282
- if (ch === 63) {
14283
- if (atExplicitKey) {
14284
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
14285
- keyTag = keyNode = valueNode = null;
14286
- }
14287
- detected = true;
14288
- atExplicitKey = true;
14289
- allowCompact = true;
14290
- } else if (atExplicitKey) {
14291
- atExplicitKey = false;
14292
- allowCompact = true;
14293
- } else {
14294
- throwError(state, "incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line");
14295
- }
14296
- state.position += 1;
14297
- ch = following;
14298
- } else {
14299
- _keyLine = state.line;
14300
- _keyLineStart = state.lineStart;
14301
- _keyPos = state.position;
14302
- if (!composeNode(state, flowIndent, CONTEXT_FLOW_OUT, false, true)) {
14303
- break;
14304
- }
14305
- if (state.line === _line) {
14306
- ch = state.input.charCodeAt(state.position);
14307
- while (is_WHITE_SPACE(ch)) {
14308
- ch = state.input.charCodeAt(++state.position);
14309
- }
14310
- if (ch === 58) {
14311
- ch = state.input.charCodeAt(++state.position);
14312
- if (!is_WS_OR_EOL(ch)) {
14313
- throwError(state, "a whitespace character is expected after the key-value separator within a block mapping");
14314
- }
14315
- if (atExplicitKey) {
14316
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
14317
- keyTag = keyNode = valueNode = null;
14318
- }
14319
- detected = true;
14320
- atExplicitKey = false;
14321
- allowCompact = false;
14322
- keyTag = state.tag;
14323
- keyNode = state.result;
14324
- } else if (detected) {
14325
- throwError(state, "can not read an implicit mapping pair; a colon is missed");
14326
- } else {
14327
- state.tag = _tag;
14328
- state.anchor = _anchor;
14329
- return true;
14330
- }
14331
- } else if (detected) {
14332
- throwError(state, "can not read a block mapping entry; a multiline key may not be an implicit key");
14333
- } else {
14334
- state.tag = _tag;
14335
- state.anchor = _anchor;
14336
- return true;
14337
- }
14338
- }
14339
- if (state.line === _line || state.lineIndent > nodeIndent) {
14340
- if (atExplicitKey) {
14341
- _keyLine = state.line;
14342
- _keyLineStart = state.lineStart;
14343
- _keyPos = state.position;
14344
- }
14345
- if (composeNode(state, nodeIndent, CONTEXT_BLOCK_OUT, true, allowCompact)) {
14346
- if (atExplicitKey) {
14347
- keyNode = state.result;
14348
- } else {
14349
- valueNode = state.result;
14350
- }
14351
- }
14352
- if (!atExplicitKey) {
14353
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, valueNode, _keyLine, _keyLineStart, _keyPos);
14354
- keyTag = keyNode = valueNode = null;
14355
- }
14356
- skipSeparationSpace(state, true, -1);
14357
- ch = state.input.charCodeAt(state.position);
14358
- }
14359
- if ((state.line === _line || state.lineIndent > nodeIndent) && ch !== 0) {
14360
- throwError(state, "bad indentation of a mapping entry");
14361
- } else if (state.lineIndent < nodeIndent) {
14362
- break;
14363
- }
14364
- }
14365
- if (atExplicitKey) {
14366
- storeMappingPair(state, _result, overridableKeys, keyTag, keyNode, null, _keyLine, _keyLineStart, _keyPos);
14367
- }
14368
- if (detected) {
14369
- state.tag = _tag;
14370
- state.anchor = _anchor;
14371
- state.kind = "mapping";
14372
- state.result = _result;
14373
- }
14374
- return detected;
14375
- }
14376
- function readTagProperty(state) {
14377
- var _position, isVerbatim = false, isNamed = false, tagHandle, tagName, ch;
14378
- ch = state.input.charCodeAt(state.position);
14379
- if (ch !== 33)
14380
- return false;
14381
- if (state.tag !== null) {
14382
- throwError(state, "duplication of a tag property");
14383
- }
14384
- ch = state.input.charCodeAt(++state.position);
14385
- if (ch === 60) {
14386
- isVerbatim = true;
14387
- ch = state.input.charCodeAt(++state.position);
14388
- } else if (ch === 33) {
14389
- isNamed = true;
14390
- tagHandle = "!!";
14391
- ch = state.input.charCodeAt(++state.position);
14392
- } else {
14393
- tagHandle = "!";
14394
- }
14395
- _position = state.position;
14396
- if (isVerbatim) {
14397
- do {
14398
- ch = state.input.charCodeAt(++state.position);
14399
- } while (ch !== 0 && ch !== 62);
14400
- if (state.position < state.length) {
14401
- tagName = state.input.slice(_position, state.position);
14402
- ch = state.input.charCodeAt(++state.position);
14403
- } else {
14404
- throwError(state, "unexpected end of the stream within a verbatim tag");
14405
- }
14406
- } else {
14407
- while (ch !== 0 && !is_WS_OR_EOL(ch)) {
14408
- if (ch === 33) {
14409
- if (!isNamed) {
14410
- tagHandle = state.input.slice(_position - 1, state.position + 1);
14411
- if (!PATTERN_TAG_HANDLE.test(tagHandle)) {
14412
- throwError(state, "named tag handle cannot contain such characters");
14413
- }
14414
- isNamed = true;
14415
- _position = state.position + 1;
14416
- } else {
14417
- throwError(state, "tag suffix cannot contain exclamation marks");
14418
- }
14419
- }
14420
- ch = state.input.charCodeAt(++state.position);
14421
- }
14422
- tagName = state.input.slice(_position, state.position);
14423
- if (PATTERN_FLOW_INDICATORS.test(tagName)) {
14424
- throwError(state, "tag suffix cannot contain flow indicator characters");
14425
- }
14426
- }
14427
- if (tagName && !PATTERN_TAG_URI.test(tagName)) {
14428
- throwError(state, "tag name cannot contain such characters: " + tagName);
14429
- }
14430
- try {
14431
- tagName = decodeURIComponent(tagName);
14432
- } catch (err) {
14433
- throwError(state, "tag name is malformed: " + tagName);
14434
- }
14435
- if (isVerbatim) {
14436
- state.tag = tagName;
14437
- } else if (_hasOwnProperty$1.call(state.tagMap, tagHandle)) {
14438
- state.tag = state.tagMap[tagHandle] + tagName;
14439
- } else if (tagHandle === "!") {
14440
- state.tag = "!" + tagName;
14441
- } else if (tagHandle === "!!") {
14442
- state.tag = "tag:yaml.org,2002:" + tagName;
14443
- } else {
14444
- throwError(state, 'undeclared tag handle "' + tagHandle + '"');
14445
- }
14446
- return true;
14447
- }
14448
- function readAnchorProperty(state) {
14449
- var _position, ch;
14450
- ch = state.input.charCodeAt(state.position);
14451
- if (ch !== 38)
14452
- return false;
14453
- if (state.anchor !== null) {
14454
- throwError(state, "duplication of an anchor property");
14455
- }
14456
- ch = state.input.charCodeAt(++state.position);
14457
- _position = state.position;
14458
- while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
14459
- ch = state.input.charCodeAt(++state.position);
14460
- }
14461
- if (state.position === _position) {
14462
- throwError(state, "name of an anchor node must contain at least one character");
14463
- }
14464
- state.anchor = state.input.slice(_position, state.position);
14465
- return true;
14466
- }
14467
- function readAlias(state) {
14468
- var _position, alias, ch;
14469
- ch = state.input.charCodeAt(state.position);
14470
- if (ch !== 42)
14471
- return false;
14472
- ch = state.input.charCodeAt(++state.position);
14473
- _position = state.position;
14474
- while (ch !== 0 && !is_WS_OR_EOL(ch) && !is_FLOW_INDICATOR(ch)) {
14475
- ch = state.input.charCodeAt(++state.position);
14476
- }
14477
- if (state.position === _position) {
14478
- throwError(state, "name of an alias node must contain at least one character");
14479
- }
14480
- alias = state.input.slice(_position, state.position);
14481
- if (!_hasOwnProperty$1.call(state.anchorMap, alias)) {
14482
- throwError(state, 'unidentified alias "' + alias + '"');
14483
- }
14484
- state.result = state.anchorMap[alias];
14485
- skipSeparationSpace(state, true, -1);
14486
- return true;
14487
- }
14488
- function composeNode(state, parentIndent, nodeContext, allowToSeek, allowCompact) {
14489
- var allowBlockStyles, allowBlockScalars, allowBlockCollections, indentStatus = 1, atNewLine = false, hasContent = false, typeIndex, typeQuantity, typeList, type2, flowIndent, blockIndent;
14490
- if (state.listener !== null) {
14491
- state.listener("open", state);
14492
- }
14493
- state.tag = null;
14494
- state.anchor = null;
14495
- state.kind = null;
14496
- state.result = null;
14497
- allowBlockStyles = allowBlockScalars = allowBlockCollections = CONTEXT_BLOCK_OUT === nodeContext || CONTEXT_BLOCK_IN === nodeContext;
14498
- if (allowToSeek) {
14499
- if (skipSeparationSpace(state, true, -1)) {
14500
- atNewLine = true;
14501
- if (state.lineIndent > parentIndent) {
14502
- indentStatus = 1;
14503
- } else if (state.lineIndent === parentIndent) {
14504
- indentStatus = 0;
14505
- } else if (state.lineIndent < parentIndent) {
14506
- indentStatus = -1;
14507
- }
14508
- }
14509
- }
14510
- if (indentStatus === 1) {
14511
- while (readTagProperty(state) || readAnchorProperty(state)) {
14512
- if (skipSeparationSpace(state, true, -1)) {
14513
- atNewLine = true;
14514
- allowBlockCollections = allowBlockStyles;
14515
- if (state.lineIndent > parentIndent) {
14516
- indentStatus = 1;
14517
- } else if (state.lineIndent === parentIndent) {
14518
- indentStatus = 0;
14519
- } else if (state.lineIndent < parentIndent) {
14520
- indentStatus = -1;
14521
- }
14522
- } else {
14523
- allowBlockCollections = false;
14524
- }
14525
- }
14526
- }
14527
- if (allowBlockCollections) {
14528
- allowBlockCollections = atNewLine || allowCompact;
14529
- }
14530
- if (indentStatus === 1 || CONTEXT_BLOCK_OUT === nodeContext) {
14531
- if (CONTEXT_FLOW_IN === nodeContext || CONTEXT_FLOW_OUT === nodeContext) {
14532
- flowIndent = parentIndent;
14533
- } else {
14534
- flowIndent = parentIndent + 1;
14535
- }
14536
- blockIndent = state.position - state.lineStart;
14537
- if (indentStatus === 1) {
14538
- if (allowBlockCollections && (readBlockSequence(state, blockIndent) || readBlockMapping(state, blockIndent, flowIndent)) || readFlowCollection(state, flowIndent)) {
14539
- hasContent = true;
14540
- } else {
14541
- if (allowBlockScalars && readBlockScalar(state, flowIndent) || readSingleQuotedScalar(state, flowIndent) || readDoubleQuotedScalar(state, flowIndent)) {
14542
- hasContent = true;
14543
- } else if (readAlias(state)) {
14544
- hasContent = true;
14545
- if (state.tag !== null || state.anchor !== null) {
14546
- throwError(state, "alias node should not have any properties");
14547
- }
14548
- } else if (readPlainScalar(state, flowIndent, CONTEXT_FLOW_IN === nodeContext)) {
14549
- hasContent = true;
14550
- if (state.tag === null) {
14551
- state.tag = "?";
14552
- }
14553
- }
14554
- if (state.anchor !== null) {
14555
- state.anchorMap[state.anchor] = state.result;
14556
- }
14557
- }
14558
- } else if (indentStatus === 0) {
14559
- hasContent = allowBlockCollections && readBlockSequence(state, blockIndent);
14560
- }
14561
- }
14562
- if (state.tag === null) {
14563
- if (state.anchor !== null) {
14564
- state.anchorMap[state.anchor] = state.result;
14565
- }
14566
- } else if (state.tag === "?") {
14567
- if (state.result !== null && state.kind !== "scalar") {
14568
- throwError(state, 'unacceptable node kind for !<?> tag; it should be "scalar", not "' + state.kind + '"');
14569
- }
14570
- for (typeIndex = 0, typeQuantity = state.implicitTypes.length; typeIndex < typeQuantity; typeIndex += 1) {
14571
- type2 = state.implicitTypes[typeIndex];
14572
- if (type2.resolve(state.result)) {
14573
- state.result = type2.construct(state.result);
14574
- state.tag = type2.tag;
14575
- if (state.anchor !== null) {
14576
- state.anchorMap[state.anchor] = state.result;
14577
- }
14578
- break;
14579
- }
14580
- }
14581
- } else if (state.tag !== "!") {
14582
- if (_hasOwnProperty$1.call(state.typeMap[state.kind || "fallback"], state.tag)) {
14583
- type2 = state.typeMap[state.kind || "fallback"][state.tag];
14584
- } else {
14585
- type2 = null;
14586
- typeList = state.typeMap.multi[state.kind || "fallback"];
14587
- for (typeIndex = 0, typeQuantity = typeList.length; typeIndex < typeQuantity; typeIndex += 1) {
14588
- if (state.tag.slice(0, typeList[typeIndex].tag.length) === typeList[typeIndex].tag) {
14589
- type2 = typeList[typeIndex];
14590
- break;
14591
- }
14592
- }
14593
- }
14594
- if (!type2) {
14595
- throwError(state, "unknown tag !<" + state.tag + ">");
14596
- }
14597
- if (state.result !== null && type2.kind !== state.kind) {
14598
- throwError(state, "unacceptable node kind for !<" + state.tag + '> tag; it should be "' + type2.kind + '", not "' + state.kind + '"');
14599
- }
14600
- if (!type2.resolve(state.result, state.tag)) {
14601
- throwError(state, "cannot resolve a node with !<" + state.tag + "> explicit tag");
14602
- } else {
14603
- state.result = type2.construct(state.result, state.tag);
14604
- if (state.anchor !== null) {
14605
- state.anchorMap[state.anchor] = state.result;
14606
- }
14607
- }
14608
- }
14609
- if (state.listener !== null) {
14610
- state.listener("close", state);
14611
- }
14612
- return state.tag !== null || state.anchor !== null || hasContent;
14613
- }
14614
- function readDocument(state) {
14615
- var documentStart = state.position, _position, directiveName, directiveArgs, hasDirectives = false, ch;
14616
- state.version = null;
14617
- state.checkLineBreaks = state.legacy;
14618
- state.tagMap = /* @__PURE__ */ Object.create(null);
14619
- state.anchorMap = /* @__PURE__ */ Object.create(null);
14620
- while ((ch = state.input.charCodeAt(state.position)) !== 0) {
14621
- skipSeparationSpace(state, true, -1);
14622
- ch = state.input.charCodeAt(state.position);
14623
- if (state.lineIndent > 0 || ch !== 37) {
14624
- break;
14625
- }
14626
- hasDirectives = true;
14627
- ch = state.input.charCodeAt(++state.position);
14628
- _position = state.position;
14629
- while (ch !== 0 && !is_WS_OR_EOL(ch)) {
14630
- ch = state.input.charCodeAt(++state.position);
14631
- }
14632
- directiveName = state.input.slice(_position, state.position);
14633
- directiveArgs = [];
14634
- if (directiveName.length < 1) {
14635
- throwError(state, "directive name must not be less than one character in length");
14636
- }
14637
- while (ch !== 0) {
14638
- while (is_WHITE_SPACE(ch)) {
14639
- ch = state.input.charCodeAt(++state.position);
14640
- }
14641
- if (ch === 35) {
14642
- do {
14643
- ch = state.input.charCodeAt(++state.position);
14644
- } while (ch !== 0 && !is_EOL(ch));
14645
- break;
14646
- }
14647
- if (is_EOL(ch))
14648
- break;
14649
- _position = state.position;
14650
- while (ch !== 0 && !is_WS_OR_EOL(ch)) {
14651
- ch = state.input.charCodeAt(++state.position);
14652
- }
14653
- directiveArgs.push(state.input.slice(_position, state.position));
14654
- }
14655
- if (ch !== 0)
14656
- readLineBreak(state);
14657
- if (_hasOwnProperty$1.call(directiveHandlers, directiveName)) {
14658
- directiveHandlers[directiveName](state, directiveName, directiveArgs);
14659
- } else {
14660
- throwWarning(state, 'unknown document directive "' + directiveName + '"');
14661
- }
14662
- }
14663
- skipSeparationSpace(state, true, -1);
14664
- if (state.lineIndent === 0 && state.input.charCodeAt(state.position) === 45 && state.input.charCodeAt(state.position + 1) === 45 && state.input.charCodeAt(state.position + 2) === 45) {
14665
- state.position += 3;
14666
- skipSeparationSpace(state, true, -1);
14667
- } else if (hasDirectives) {
14668
- throwError(state, "directives end mark is expected");
14669
- }
14670
- composeNode(state, state.lineIndent - 1, CONTEXT_BLOCK_OUT, false, true);
14671
- skipSeparationSpace(state, true, -1);
14672
- if (state.checkLineBreaks && PATTERN_NON_ASCII_LINE_BREAKS.test(state.input.slice(documentStart, state.position))) {
14673
- throwWarning(state, "non-ASCII line breaks are interpreted as content");
14674
- }
14675
- state.documents.push(state.result);
14676
- if (state.position === state.lineStart && testDocumentSeparator(state)) {
14677
- if (state.input.charCodeAt(state.position) === 46) {
14678
- state.position += 3;
14679
- skipSeparationSpace(state, true, -1);
14680
- }
14681
- return;
14682
- }
14683
- if (state.position < state.length - 1) {
14684
- throwError(state, "end of the stream or a document separator is expected");
14685
- } else {
14686
- return;
14687
- }
14688
- }
14689
- function loadDocuments(input, options) {
14690
- input = String(input);
14691
- options = options || {};
14692
- if (input.length !== 0) {
14693
- if (input.charCodeAt(input.length - 1) !== 10 && input.charCodeAt(input.length - 1) !== 13) {
14694
- input += "\n";
14695
- }
14696
- if (input.charCodeAt(0) === 65279) {
14697
- input = input.slice(1);
14698
- }
14699
- }
14700
- var state = new State$1(input, options);
14701
- var nullpos = input.indexOf("\0");
14702
- if (nullpos !== -1) {
14703
- state.position = nullpos;
14704
- throwError(state, "null byte is not allowed in input");
14705
- }
14706
- state.input += "\0";
14707
- while (state.input.charCodeAt(state.position) === 32) {
14708
- state.lineIndent += 1;
14709
- state.position += 1;
14710
- }
14711
- while (state.position < state.length - 1) {
14712
- readDocument(state);
14713
- }
14714
- return state.documents;
14715
- }
14716
- function loadAll$1(input, iterator, options) {
14717
- if (iterator !== null && typeof iterator === "object" && typeof options === "undefined") {
14718
- options = iterator;
14719
- iterator = null;
14720
- }
14721
- var documents = loadDocuments(input, options);
14722
- if (typeof iterator !== "function") {
14723
- return documents;
14724
- }
14725
- for (var index = 0, length = documents.length; index < length; index += 1) {
14726
- iterator(documents[index]);
14727
- }
14728
- }
14729
- function load$1(input, options) {
14730
- var documents = loadDocuments(input, options);
14731
- if (documents.length === 0) {
14732
- return void 0;
14733
- } else if (documents.length === 1) {
14734
- return documents[0];
14735
- }
14736
- throw new exception("expected a single document in the stream, but found more");
14737
- }
14738
- var loadAll_1 = loadAll$1;
14739
- var load_1 = load$1;
14740
- var loader = {
14741
- loadAll: loadAll_1,
14742
- load: load_1
14743
- };
14744
- var _toString2 = Object.prototype.toString;
14745
- var _hasOwnProperty = Object.prototype.hasOwnProperty;
14746
- var CHAR_BOM = 65279;
14747
- var CHAR_TAB = 9;
14748
- var CHAR_LINE_FEED = 10;
14749
- var CHAR_CARRIAGE_RETURN = 13;
14750
- var CHAR_SPACE = 32;
14751
- var CHAR_EXCLAMATION = 33;
14752
- var CHAR_DOUBLE_QUOTE = 34;
14753
- var CHAR_SHARP = 35;
14754
- var CHAR_PERCENT = 37;
14755
- var CHAR_AMPERSAND = 38;
14756
- var CHAR_SINGLE_QUOTE = 39;
14757
- var CHAR_ASTERISK = 42;
14758
- var CHAR_COMMA = 44;
14759
- var CHAR_MINUS = 45;
14760
- var CHAR_COLON = 58;
14761
- var CHAR_EQUALS = 61;
14762
- var CHAR_GREATER_THAN = 62;
14763
- var CHAR_QUESTION = 63;
14764
- var CHAR_COMMERCIAL_AT = 64;
14765
- var CHAR_LEFT_SQUARE_BRACKET = 91;
14766
- var CHAR_RIGHT_SQUARE_BRACKET = 93;
14767
- var CHAR_GRAVE_ACCENT = 96;
14768
- var CHAR_LEFT_CURLY_BRACKET = 123;
14769
- var CHAR_VERTICAL_LINE = 124;
14770
- var CHAR_RIGHT_CURLY_BRACKET = 125;
14771
- var ESCAPE_SEQUENCES = {};
14772
- ESCAPE_SEQUENCES[0] = "\\0";
14773
- ESCAPE_SEQUENCES[7] = "\\a";
14774
- ESCAPE_SEQUENCES[8] = "\\b";
14775
- ESCAPE_SEQUENCES[9] = "\\t";
14776
- ESCAPE_SEQUENCES[10] = "\\n";
14777
- ESCAPE_SEQUENCES[11] = "\\v";
14778
- ESCAPE_SEQUENCES[12] = "\\f";
14779
- ESCAPE_SEQUENCES[13] = "\\r";
14780
- ESCAPE_SEQUENCES[27] = "\\e";
14781
- ESCAPE_SEQUENCES[34] = '\\"';
14782
- ESCAPE_SEQUENCES[92] = "\\\\";
14783
- ESCAPE_SEQUENCES[133] = "\\N";
14784
- ESCAPE_SEQUENCES[160] = "\\_";
14785
- ESCAPE_SEQUENCES[8232] = "\\L";
14786
- ESCAPE_SEQUENCES[8233] = "\\P";
14787
- var DEPRECATED_BOOLEANS_SYNTAX = [
14788
- "y",
14789
- "Y",
14790
- "yes",
14791
- "Yes",
14792
- "YES",
14793
- "on",
14794
- "On",
14795
- "ON",
14796
- "n",
14797
- "N",
14798
- "no",
14799
- "No",
14800
- "NO",
14801
- "off",
14802
- "Off",
14803
- "OFF"
14804
- ];
14805
- var DEPRECATED_BASE60_SYNTAX = /^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;
14806
- function compileStyleMap(schema2, map2) {
14807
- var result, keys, index, length, tag, style, type2;
14808
- if (map2 === null)
14809
- return {};
14810
- result = {};
14811
- keys = Object.keys(map2);
14812
- for (index = 0, length = keys.length; index < length; index += 1) {
14813
- tag = keys[index];
14814
- style = String(map2[tag]);
14815
- if (tag.slice(0, 2) === "!!") {
14816
- tag = "tag:yaml.org,2002:" + tag.slice(2);
14817
- }
14818
- type2 = schema2.compiledTypeMap["fallback"][tag];
14819
- if (type2 && _hasOwnProperty.call(type2.styleAliases, style)) {
14820
- style = type2.styleAliases[style];
14821
- }
14822
- result[tag] = style;
14823
- }
14824
- return result;
14825
- }
14826
- function encodeHex(character) {
14827
- var string, handle, length;
14828
- string = character.toString(16).toUpperCase();
14829
- if (character <= 255) {
14830
- handle = "x";
14831
- length = 2;
14832
- } else if (character <= 65535) {
14833
- handle = "u";
14834
- length = 4;
14835
- } else if (character <= 4294967295) {
14836
- handle = "U";
14837
- length = 8;
14838
- } else {
14839
- throw new exception("code point within a string may not be greater than 0xFFFFFFFF");
14840
- }
14841
- return "\\" + handle + common.repeat("0", length - string.length) + string;
14842
- }
14843
- var QUOTING_TYPE_SINGLE = 1;
14844
- var QUOTING_TYPE_DOUBLE = 2;
14845
- function State(options) {
14846
- this.schema = options["schema"] || _default;
14847
- this.indent = Math.max(1, options["indent"] || 2);
14848
- this.noArrayIndent = options["noArrayIndent"] || false;
14849
- this.skipInvalid = options["skipInvalid"] || false;
14850
- this.flowLevel = common.isNothing(options["flowLevel"]) ? -1 : options["flowLevel"];
14851
- this.styleMap = compileStyleMap(this.schema, options["styles"] || null);
14852
- this.sortKeys = options["sortKeys"] || false;
14853
- this.lineWidth = options["lineWidth"] || 80;
14854
- this.noRefs = options["noRefs"] || false;
14855
- this.noCompatMode = options["noCompatMode"] || false;
14856
- this.condenseFlow = options["condenseFlow"] || false;
14857
- this.quotingType = options["quotingType"] === '"' ? QUOTING_TYPE_DOUBLE : QUOTING_TYPE_SINGLE;
14858
- this.forceQuotes = options["forceQuotes"] || false;
14859
- this.replacer = typeof options["replacer"] === "function" ? options["replacer"] : null;
14860
- this.implicitTypes = this.schema.compiledImplicit;
14861
- this.explicitTypes = this.schema.compiledExplicit;
14862
- this.tag = null;
14863
- this.result = "";
14864
- this.duplicates = [];
14865
- this.usedDuplicates = null;
14866
- }
14867
- function indentString(string, spaces) {
14868
- var ind = common.repeat(" ", spaces), position = 0, next = -1, result = "", line, length = string.length;
14869
- while (position < length) {
14870
- next = string.indexOf("\n", position);
14871
- if (next === -1) {
14872
- line = string.slice(position);
14873
- position = length;
14874
- } else {
14875
- line = string.slice(position, next + 1);
14876
- position = next + 1;
14877
- }
14878
- if (line.length && line !== "\n")
14879
- result += ind;
14880
- result += line;
14881
- }
14882
- return result;
14883
- }
14884
- function generateNextLine(state, level) {
14885
- return "\n" + common.repeat(" ", state.indent * level);
14886
- }
14887
- function testImplicitResolving(state, str2) {
14888
- var index, length, type2;
14889
- for (index = 0, length = state.implicitTypes.length; index < length; index += 1) {
14890
- type2 = state.implicitTypes[index];
14891
- if (type2.resolve(str2)) {
14892
- return true;
14893
- }
14894
- }
14895
- return false;
14896
- }
14897
- function isWhitespace(c) {
14898
- return c === CHAR_SPACE || c === CHAR_TAB;
14899
- }
14900
- function isPrintable(c) {
14901
- return 32 <= c && c <= 126 || 161 <= c && c <= 55295 && c !== 8232 && c !== 8233 || 57344 <= c && c <= 65533 && c !== CHAR_BOM || 65536 <= c && c <= 1114111;
14902
- }
14903
- function isNsCharOrWhitespace(c) {
14904
- return isPrintable(c) && c !== CHAR_BOM && c !== CHAR_CARRIAGE_RETURN && c !== CHAR_LINE_FEED;
14905
- }
14906
- function isPlainSafe(c, prev, inblock) {
14907
- var cIsNsCharOrWhitespace = isNsCharOrWhitespace(c);
14908
- var cIsNsChar = cIsNsCharOrWhitespace && !isWhitespace(c);
14909
- return (
14910
- // ns-plain-safe
14911
- (inblock ? (
14912
- // c = flow-in
14913
- cIsNsCharOrWhitespace
14914
- ) : 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
14915
- );
14916
- }
14917
- function isPlainSafeFirst(c) {
14918
- 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;
14919
- }
14920
- function isPlainSafeLast(c) {
14921
- return !isWhitespace(c) && c !== CHAR_COLON;
14922
- }
14923
- function codePointAt(string, pos) {
14924
- var first = string.charCodeAt(pos), second;
14925
- if (first >= 55296 && first <= 56319 && pos + 1 < string.length) {
14926
- second = string.charCodeAt(pos + 1);
14927
- if (second >= 56320 && second <= 57343) {
14928
- return (first - 55296) * 1024 + second - 56320 + 65536;
14929
- }
14930
- }
14931
- return first;
14932
- }
14933
- function needIndentIndicator(string) {
14934
- var leadingSpaceRe = /^\n* /;
14935
- return leadingSpaceRe.test(string);
14936
- }
14937
- var STYLE_PLAIN = 1;
14938
- var STYLE_SINGLE = 2;
14939
- var STYLE_LITERAL = 3;
14940
- var STYLE_FOLDED = 4;
14941
- var STYLE_DOUBLE = 5;
14942
- function chooseScalarStyle(string, singleLineOnly, indentPerLevel, lineWidth, testAmbiguousType, quotingType, forceQuotes, inblock) {
14943
- var i;
14944
- var char = 0;
14945
- var prevChar = null;
14946
- var hasLineBreak = false;
14947
- var hasFoldableLine = false;
14948
- var shouldTrackWidth = lineWidth !== -1;
14949
- var previousLineBreak = -1;
14950
- var plain = isPlainSafeFirst(codePointAt(string, 0)) && isPlainSafeLast(codePointAt(string, string.length - 1));
14951
- if (singleLineOnly || forceQuotes) {
14952
- for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
14953
- char = codePointAt(string, i);
14954
- if (!isPrintable(char)) {
14955
- return STYLE_DOUBLE;
14956
- }
14957
- plain = plain && isPlainSafe(char, prevChar, inblock);
14958
- prevChar = char;
14959
- }
14960
- } else {
14961
- for (i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
14962
- char = codePointAt(string, i);
14963
- if (char === CHAR_LINE_FEED) {
14964
- hasLineBreak = true;
14965
- if (shouldTrackWidth) {
14966
- hasFoldableLine = hasFoldableLine || // Foldable line = too long, and not more-indented.
14967
- i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ";
14968
- previousLineBreak = i;
14969
- }
14970
- } else if (!isPrintable(char)) {
14971
- return STYLE_DOUBLE;
14972
- }
14973
- plain = plain && isPlainSafe(char, prevChar, inblock);
14974
- prevChar = char;
14975
- }
14976
- hasFoldableLine = hasFoldableLine || shouldTrackWidth && (i - previousLineBreak - 1 > lineWidth && string[previousLineBreak + 1] !== " ");
14977
- }
14978
- if (!hasLineBreak && !hasFoldableLine) {
14979
- if (plain && !forceQuotes && !testAmbiguousType(string)) {
14980
- return STYLE_PLAIN;
14981
- }
14982
- return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
14983
- }
14984
- if (indentPerLevel > 9 && needIndentIndicator(string)) {
14985
- return STYLE_DOUBLE;
14986
- }
14987
- if (!forceQuotes) {
14988
- return hasFoldableLine ? STYLE_FOLDED : STYLE_LITERAL;
14989
- }
14990
- return quotingType === QUOTING_TYPE_DOUBLE ? STYLE_DOUBLE : STYLE_SINGLE;
14991
- }
14992
- function writeScalar(state, string, level, iskey, inblock) {
14993
- state.dump = function() {
14994
- if (string.length === 0) {
14995
- return state.quotingType === QUOTING_TYPE_DOUBLE ? '""' : "''";
14996
- }
14997
- if (!state.noCompatMode) {
14998
- if (DEPRECATED_BOOLEANS_SYNTAX.indexOf(string) !== -1 || DEPRECATED_BASE60_SYNTAX.test(string)) {
14999
- return state.quotingType === QUOTING_TYPE_DOUBLE ? '"' + string + '"' : "'" + string + "'";
15000
- }
15001
- }
15002
- var indent2 = state.indent * Math.max(1, level);
15003
- var lineWidth = state.lineWidth === -1 ? -1 : Math.max(Math.min(state.lineWidth, 40), state.lineWidth - indent2);
15004
- var singleLineOnly = iskey || state.flowLevel > -1 && level >= state.flowLevel;
15005
- function testAmbiguity(string2) {
15006
- return testImplicitResolving(state, string2);
15007
- }
15008
- switch (chooseScalarStyle(
15009
- string,
15010
- singleLineOnly,
15011
- state.indent,
15012
- lineWidth,
15013
- testAmbiguity,
15014
- state.quotingType,
15015
- state.forceQuotes && !iskey,
15016
- inblock
15017
- )) {
15018
- case STYLE_PLAIN:
15019
- return string;
15020
- case STYLE_SINGLE:
15021
- return "'" + string.replace(/'/g, "''") + "'";
15022
- case STYLE_LITERAL:
15023
- return "|" + blockHeader(string, state.indent) + dropEndingNewline(indentString(string, indent2));
15024
- case STYLE_FOLDED:
15025
- return ">" + blockHeader(string, state.indent) + dropEndingNewline(indentString(foldString(string, lineWidth), indent2));
15026
- case STYLE_DOUBLE:
15027
- return '"' + escapeString(string) + '"';
15028
- default:
15029
- throw new exception("impossible error: invalid scalar style");
15030
- }
15031
- }();
15032
- }
15033
- function blockHeader(string, indentPerLevel) {
15034
- var indentIndicator = needIndentIndicator(string) ? String(indentPerLevel) : "";
15035
- var clip = string[string.length - 1] === "\n";
15036
- var keep = clip && (string[string.length - 2] === "\n" || string === "\n");
15037
- var chomp = keep ? "+" : clip ? "" : "-";
15038
- return indentIndicator + chomp + "\n";
15039
- }
15040
- function dropEndingNewline(string) {
15041
- return string[string.length - 1] === "\n" ? string.slice(0, -1) : string;
15042
- }
15043
- function foldString(string, width) {
15044
- var lineRe = /(\n+)([^\n]*)/g;
15045
- var result = function() {
15046
- var nextLF = string.indexOf("\n");
15047
- nextLF = nextLF !== -1 ? nextLF : string.length;
15048
- lineRe.lastIndex = nextLF;
15049
- return foldLine(string.slice(0, nextLF), width);
15050
- }();
15051
- var prevMoreIndented = string[0] === "\n" || string[0] === " ";
15052
- var moreIndented;
15053
- var match2;
15054
- while (match2 = lineRe.exec(string)) {
15055
- var prefix = match2[1], line = match2[2];
15056
- moreIndented = line[0] === " ";
15057
- result += prefix + (!prevMoreIndented && !moreIndented && line !== "" ? "\n" : "") + foldLine(line, width);
15058
- prevMoreIndented = moreIndented;
15059
- }
15060
- return result;
15061
- }
15062
- function foldLine(line, width) {
15063
- if (line === "" || line[0] === " ")
15064
- return line;
15065
- var breakRe = / [^ ]/g;
15066
- var match2;
15067
- var start = 0, end, curr = 0, next = 0;
15068
- var result = "";
15069
- while (match2 = breakRe.exec(line)) {
15070
- next = match2.index;
15071
- if (next - start > width) {
15072
- end = curr > start ? curr : next;
15073
- result += "\n" + line.slice(start, end);
15074
- start = end + 1;
15075
- }
15076
- curr = next;
15077
- }
15078
- result += "\n";
15079
- if (line.length - start > width && curr > start) {
15080
- result += line.slice(start, curr) + "\n" + line.slice(curr + 1);
15081
- } else {
15082
- result += line.slice(start);
15083
- }
15084
- return result.slice(1);
15085
- }
15086
- function escapeString(string) {
15087
- var result = "";
15088
- var char = 0;
15089
- var escapeSeq;
15090
- for (var i = 0; i < string.length; char >= 65536 ? i += 2 : i++) {
15091
- char = codePointAt(string, i);
15092
- escapeSeq = ESCAPE_SEQUENCES[char];
15093
- if (!escapeSeq && isPrintable(char)) {
15094
- result += string[i];
15095
- if (char >= 65536)
15096
- result += string[i + 1];
15097
- } else {
15098
- result += escapeSeq || encodeHex(char);
15099
- }
15100
- }
15101
- return result;
15102
- }
15103
- function writeFlowSequence(state, level, object) {
15104
- var _result = "", _tag = state.tag, index, length, value;
15105
- for (index = 0, length = object.length; index < length; index += 1) {
15106
- value = object[index];
15107
- if (state.replacer) {
15108
- value = state.replacer.call(object, String(index), value);
15109
- }
15110
- if (writeNode(state, level, value, false, false) || typeof value === "undefined" && writeNode(state, level, null, false, false)) {
15111
- if (_result !== "")
15112
- _result += "," + (!state.condenseFlow ? " " : "");
15113
- _result += state.dump;
15114
- }
15115
- }
15116
- state.tag = _tag;
15117
- state.dump = "[" + _result + "]";
15118
- }
15119
- function writeBlockSequence(state, level, object, compact) {
15120
- var _result = "", _tag = state.tag, index, length, value;
15121
- for (index = 0, length = object.length; index < length; index += 1) {
15122
- value = object[index];
15123
- if (state.replacer) {
15124
- value = state.replacer.call(object, String(index), value);
15125
- }
15126
- if (writeNode(state, level + 1, value, true, true, false, true) || typeof value === "undefined" && writeNode(state, level + 1, null, true, true, false, true)) {
15127
- if (!compact || _result !== "") {
15128
- _result += generateNextLine(state, level);
15129
- }
15130
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
15131
- _result += "-";
15132
- } else {
15133
- _result += "- ";
15134
- }
15135
- _result += state.dump;
15136
- }
15137
- }
15138
- state.tag = _tag;
15139
- state.dump = _result || "[]";
15140
- }
15141
- function writeFlowMapping(state, level, object) {
15142
- var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, pairBuffer;
15143
- for (index = 0, length = objectKeyList.length; index < length; index += 1) {
15144
- pairBuffer = "";
15145
- if (_result !== "")
15146
- pairBuffer += ", ";
15147
- if (state.condenseFlow)
15148
- pairBuffer += '"';
15149
- objectKey = objectKeyList[index];
15150
- objectValue = object[objectKey];
15151
- if (state.replacer) {
15152
- objectValue = state.replacer.call(object, objectKey, objectValue);
15153
- }
15154
- if (!writeNode(state, level, objectKey, false, false)) {
15155
- continue;
15156
- }
15157
- if (state.dump.length > 1024)
15158
- pairBuffer += "? ";
15159
- pairBuffer += state.dump + (state.condenseFlow ? '"' : "") + ":" + (state.condenseFlow ? "" : " ");
15160
- if (!writeNode(state, level, objectValue, false, false)) {
15161
- continue;
15162
- }
15163
- pairBuffer += state.dump;
15164
- _result += pairBuffer;
15165
- }
15166
- state.tag = _tag;
15167
- state.dump = "{" + _result + "}";
15168
- }
15169
- function writeBlockMapping(state, level, object, compact) {
15170
- var _result = "", _tag = state.tag, objectKeyList = Object.keys(object), index, length, objectKey, objectValue, explicitPair, pairBuffer;
15171
- if (state.sortKeys === true) {
15172
- objectKeyList.sort();
15173
- } else if (typeof state.sortKeys === "function") {
15174
- objectKeyList.sort(state.sortKeys);
15175
- } else if (state.sortKeys) {
15176
- throw new exception("sortKeys must be a boolean or a function");
15177
- }
15178
- for (index = 0, length = objectKeyList.length; index < length; index += 1) {
15179
- pairBuffer = "";
15180
- if (!compact || _result !== "") {
15181
- pairBuffer += generateNextLine(state, level);
15182
- }
15183
- objectKey = objectKeyList[index];
15184
- objectValue = object[objectKey];
15185
- if (state.replacer) {
15186
- objectValue = state.replacer.call(object, objectKey, objectValue);
15187
- }
15188
- if (!writeNode(state, level + 1, objectKey, true, true, true)) {
15189
- continue;
15190
- }
15191
- explicitPair = state.tag !== null && state.tag !== "?" || state.dump && state.dump.length > 1024;
15192
- if (explicitPair) {
15193
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
15194
- pairBuffer += "?";
15195
- } else {
15196
- pairBuffer += "? ";
15197
- }
15198
- }
15199
- pairBuffer += state.dump;
15200
- if (explicitPair) {
15201
- pairBuffer += generateNextLine(state, level);
15202
- }
15203
- if (!writeNode(state, level + 1, objectValue, true, explicitPair)) {
15204
- continue;
15205
- }
15206
- if (state.dump && CHAR_LINE_FEED === state.dump.charCodeAt(0)) {
15207
- pairBuffer += ":";
15208
- } else {
15209
- pairBuffer += ": ";
15210
- }
15211
- pairBuffer += state.dump;
15212
- _result += pairBuffer;
15213
- }
15214
- state.tag = _tag;
15215
- state.dump = _result || "{}";
15216
- }
15217
- function detectType(state, object, explicit) {
15218
- var _result, typeList, index, length, type2, style;
15219
- typeList = explicit ? state.explicitTypes : state.implicitTypes;
15220
- for (index = 0, length = typeList.length; index < length; index += 1) {
15221
- type2 = typeList[index];
15222
- if ((type2.instanceOf || type2.predicate) && (!type2.instanceOf || typeof object === "object" && object instanceof type2.instanceOf) && (!type2.predicate || type2.predicate(object))) {
15223
- if (explicit) {
15224
- if (type2.multi && type2.representName) {
15225
- state.tag = type2.representName(object);
15226
- } else {
15227
- state.tag = type2.tag;
15228
- }
15229
- } else {
15230
- state.tag = "?";
15231
- }
15232
- if (type2.represent) {
15233
- style = state.styleMap[type2.tag] || type2.defaultStyle;
15234
- if (_toString2.call(type2.represent) === "[object Function]") {
15235
- _result = type2.represent(object, style);
15236
- } else if (_hasOwnProperty.call(type2.represent, style)) {
15237
- _result = type2.represent[style](object, style);
15238
- } else {
15239
- throw new exception("!<" + type2.tag + '> tag resolver accepts not "' + style + '" style');
15240
- }
15241
- state.dump = _result;
15242
- }
15243
- return true;
15244
- }
15245
- }
15246
- return false;
15247
- }
15248
- function writeNode(state, level, object, block, compact, iskey, isblockseq) {
15249
- state.tag = null;
15250
- state.dump = object;
15251
- if (!detectType(state, object, false)) {
15252
- detectType(state, object, true);
15253
- }
15254
- var type2 = _toString2.call(state.dump);
15255
- var inblock = block;
15256
- var tagStr;
15257
- if (block) {
15258
- block = state.flowLevel < 0 || state.flowLevel > level;
15259
- }
15260
- var objectOrArray = type2 === "[object Object]" || type2 === "[object Array]", duplicateIndex, duplicate;
15261
- if (objectOrArray) {
15262
- duplicateIndex = state.duplicates.indexOf(object);
15263
- duplicate = duplicateIndex !== -1;
15264
- }
15265
- if (state.tag !== null && state.tag !== "?" || duplicate || state.indent !== 2 && level > 0) {
15266
- compact = false;
15267
- }
15268
- if (duplicate && state.usedDuplicates[duplicateIndex]) {
15269
- state.dump = "*ref_" + duplicateIndex;
15270
- } else {
15271
- if (objectOrArray && duplicate && !state.usedDuplicates[duplicateIndex]) {
15272
- state.usedDuplicates[duplicateIndex] = true;
15273
- }
15274
- if (type2 === "[object Object]") {
15275
- if (block && Object.keys(state.dump).length !== 0) {
15276
- writeBlockMapping(state, level, state.dump, compact);
15277
- if (duplicate) {
15278
- state.dump = "&ref_" + duplicateIndex + state.dump;
15279
- }
15280
- } else {
15281
- writeFlowMapping(state, level, state.dump);
15282
- if (duplicate) {
15283
- state.dump = "&ref_" + duplicateIndex + " " + state.dump;
15284
- }
15285
- }
15286
- } else if (type2 === "[object Array]") {
15287
- if (block && state.dump.length !== 0) {
15288
- if (state.noArrayIndent && !isblockseq && level > 0) {
15289
- writeBlockSequence(state, level - 1, state.dump, compact);
15290
- } else {
15291
- writeBlockSequence(state, level, state.dump, compact);
15292
- }
15293
- if (duplicate) {
15294
- state.dump = "&ref_" + duplicateIndex + state.dump;
15295
- }
15296
- } else {
15297
- writeFlowSequence(state, level, state.dump);
15298
- if (duplicate) {
15299
- state.dump = "&ref_" + duplicateIndex + " " + state.dump;
15300
- }
15301
- }
15302
- } else if (type2 === "[object String]") {
15303
- if (state.tag !== "?") {
15304
- writeScalar(state, state.dump, level, iskey, inblock);
15305
- }
15306
- } else if (type2 === "[object Undefined]") {
15307
- return false;
15308
- } else {
15309
- if (state.skipInvalid)
15310
- return false;
15311
- throw new exception("unacceptable kind of an object to dump " + type2);
15312
- }
15313
- if (state.tag !== null && state.tag !== "?") {
15314
- tagStr = encodeURI(
15315
- state.tag[0] === "!" ? state.tag.slice(1) : state.tag
15316
- ).replace(/!/g, "%21");
15317
- if (state.tag[0] === "!") {
15318
- tagStr = "!" + tagStr;
15319
- } else if (tagStr.slice(0, 18) === "tag:yaml.org,2002:") {
15320
- tagStr = "!!" + tagStr.slice(18);
15321
- } else {
15322
- tagStr = "!<" + tagStr + ">";
15323
- }
15324
- state.dump = tagStr + " " + state.dump;
15325
- }
15326
- }
15327
- return true;
15328
- }
15329
- function getDuplicateReferences(object, state) {
15330
- var objects = [], duplicatesIndexes = [], index, length;
15331
- inspectNode(object, objects, duplicatesIndexes);
15332
- for (index = 0, length = duplicatesIndexes.length; index < length; index += 1) {
15333
- state.duplicates.push(objects[duplicatesIndexes[index]]);
15334
- }
15335
- state.usedDuplicates = new Array(length);
15336
- }
15337
- function inspectNode(object, objects, duplicatesIndexes) {
15338
- var objectKeyList, index, length;
15339
- if (object !== null && typeof object === "object") {
15340
- index = objects.indexOf(object);
15341
- if (index !== -1) {
15342
- if (duplicatesIndexes.indexOf(index) === -1) {
15343
- duplicatesIndexes.push(index);
15344
- }
15345
- } else {
15346
- objects.push(object);
15347
- if (Array.isArray(object)) {
15348
- for (index = 0, length = object.length; index < length; index += 1) {
15349
- inspectNode(object[index], objects, duplicatesIndexes);
15350
- }
15351
- } else {
15352
- objectKeyList = Object.keys(object);
15353
- for (index = 0, length = objectKeyList.length; index < length; index += 1) {
15354
- inspectNode(object[objectKeyList[index]], objects, duplicatesIndexes);
15355
- }
15356
- }
15357
- }
15358
- }
15359
- }
15360
- function dump$1(input, options) {
15361
- options = options || {};
15362
- var state = new State(options);
15363
- if (!state.noRefs)
15364
- getDuplicateReferences(input, state);
15365
- var value = input;
15366
- if (state.replacer) {
15367
- value = state.replacer.call({ "": value }, "", value);
15368
- }
15369
- if (writeNode(state, 0, value, true, true))
15370
- return state.dump + "\n";
15371
- return "";
15372
- }
15373
- var dump_1 = dump$1;
15374
- var dumper = {
15375
- dump: dump_1
15376
- };
15377
- function renamed(from, to) {
15378
- return function() {
15379
- throw new Error("Function yaml." + from + " is removed in js-yaml 4. Use yaml." + to + " instead, which is now safe by default.");
15380
- };
15381
- }
15382
- var load = loader.load;
15383
- var loadAll = loader.loadAll;
15384
- var dump = dumper.dump;
15385
- var safeLoad = renamed("safeLoad", "load");
15386
- var safeLoadAll = renamed("safeLoadAll", "loadAll");
15387
- var safeDump = renamed("safeDump", "dump");
15388
-
15389
- // ../../node_modules/.pnpm/yargs@17.7.2/node_modules/yargs/yargs.mjs
15390
- var import_build = __toESM(require_build4(), 1);
15391
- var { applyExtends, cjsPlatformShim, Parser, processArgv, Yargs } = import_build.default;
15392
- Yargs.applyExtends = (config, cwd, mergeExtends) => {
15393
- return applyExtends(config, cwd, mergeExtends, cjsPlatformShim);
15394
- };
15395
- Yargs.hideBin = processArgv.hideBin;
15396
- Yargs.Parser = Parser;
15397
- var yargs_default = Yargs;
15398
-
15399
- // src/cli-utils.ts
15400
- var parseProcessArgs = () => __async(void 0, null, function* () {
15401
- const versionFromPkgJson = require_package2().version;
15402
- const { hideBin } = require_helpers();
15403
- const args = yargs_default(hideBin(process.argv)).usage(
15404
- `Midscene.js helps you automate browser actions, assertions, and data extraction by AI.
15405
- Homepage: https://midscenejs.com/
15406
- Github: https://github.com/web-infra-dev/midscene
15407
-
15408
- Usage: $0 [options] <path-to-yaml-script-file-or-directory>`
15409
- ).options({
15410
- headed: {
15411
- type: "boolean",
15412
- default: false,
15413
- description: "Run the browser in headed mode to see the browser UI"
15414
- },
15415
- "keep-window": {
15416
- type: "boolean",
15417
- default: false,
15418
- description: "Keep the browser window open after the script finishes. This is useful when debugging, but will consume more resources"
15419
- }
15420
- }).version("version", "Show version number", versionFromPkgJson).help().wrap(yargs_default().terminalWidth());
15421
- const argv = yield args.argv;
15422
- return {
15423
- path: argv._[0],
15424
- options: argv
15425
- };
15426
- });
15427
- function matchYamlFiles(fileGlob) {
15428
- return __async(this, null, function* () {
15429
- if ((0, import_node_fs2.existsSync)(fileGlob) && (0, import_node_fs.statSync)(fileGlob).isDirectory()) {
15430
- fileGlob = (0, import_node_path2.join)(fileGlob, "**/*.{yml,yaml}");
15431
- }
15432
- const files = yield glob(fileGlob, {
15433
- nodir: true
15434
- });
15435
- return files.filter((file) => file.endsWith(".yml") || file.endsWith(".yaml")).sort();
15436
- });
15437
- }
15438
-
15439
- // src/yaml-runner.ts
15440
- var import_node_fs3 = require("fs");
15441
- var import_node_path4 = require("path");
15442
- var import_yaml2 = require("@midscene/web/yaml");
15443
- var import_http_server = require("http-server");
15444
-
15445
- // src/printer.ts
15446
- var import_node_path3 = require("path");
15447
- var import_yaml = require("@midscene/web/yaml");
15448
- var import_chalk = __toESM(require_source());
15449
- var isTTY = process.env.MIDSCENE_CLI_LOG_ON_NON_TTY ? false : process.stdout.isTTY;
15450
- var indent = " ";
15451
- var spinnerInterval = 80;
15452
- var spinnerFrames = ["◰", "◳", "◲", "◱"];
15453
- var currentSpinningFrame = () => {
15454
- return spinnerFrames[Math.floor(Date.now() / spinnerInterval) % spinnerFrames.length];
15455
- };
15456
- function indicatorForStatus(status) {
15457
- if (status === "init") {
15458
- return import_chalk.default.gray("◌");
15459
- }
15460
- if (status === "running") {
15461
- return import_chalk.default.yellowBright(currentSpinningFrame());
15462
- }
15463
- if (status === "done") {
15464
- return import_chalk.default.green("✔︎");
15465
- }
15466
- if (status === "error") {
15467
- return import_chalk.default.red("✘");
15468
- }
15469
- }
15470
- var contextInfo = (context) => {
15471
- const filePath = context.file;
15472
- const fileName = (0, import_node_path3.basename)(filePath);
15473
- const fileDir = (0, import_node_path3.dirname)(filePath);
15474
- const fileNameToPrint = `${import_chalk.default.gray(`${fileDir}/`)}${fileName}`;
15475
- const fileStatusText = indicatorForStatus(context.player.status);
15476
- const contextActionText = typeof context.player.currentTaskIndex === "undefined" && context.player.status === "running" ? import_chalk.default.gray("(navigating)") : "";
15477
- const outputFile = context.player.output;
15478
- const outputText = outputFile && Object.keys(context.player.result || {}).length > 0 ? `
15479
- ${indent}${import_chalk.default.gray(`output: ${outputFile}`)}` : "";
15480
- const reportFile = context.player.reportFile;
15481
- const reportFileToShow = (0, import_node_path3.relative)(process.cwd(), reportFile || "");
15482
- const reportText = reportFile ? `
15483
- ${indent}${import_chalk.default.gray(`report: ./${reportFileToShow}`)}` : "";
15484
- const mergedText = `${fileStatusText} ${fileNameToPrint} ${contextActionText}${outputText}${reportText}`.trim();
15485
- return {
15486
- fileNameToPrint,
15487
- fileStatusText,
15488
- contextActionText,
15489
- outputText,
15490
- reportText,
15491
- mergedText
15492
- };
15493
- };
15494
- var singleTaskInfo = (task) => {
15495
- var _a4;
15496
- let stepText = "";
15497
- if (task.status === "init") {
15498
- stepText = "";
15499
- } else if (task.status === "running" || task.status === "error") {
15500
- if (typeof task.currentStep === "undefined") {
15501
- stepText = import_chalk.default.gray("(navigating)");
15502
- } else if (typeof task.currentStep === "number") {
15503
- const currentFlowItem = task.flow[task.currentStep];
15504
- const taskBrief = currentFlowItem && (0, import_yaml.flowItemBrief)(currentFlowItem);
15505
- const actionText = taskBrief ? `, ${taskBrief}` : "";
15506
- stepText = import_chalk.default.gray(
15507
- `(step ${task.currentStep + 1}/${task.totalSteps}${actionText})`.trim()
15508
- );
15509
- } else {
15510
- stepText = import_chalk.default.gray("(unknown step)");
15511
- }
15512
- }
15513
- const errorText = task.status === "error" ? `
15514
- ${indent}${import_chalk.default.gray("error:")}
15515
- ${indent}${indent}${(_a4 = task.error) == null ? void 0 : _a4.message}` : "";
15516
- const statusText = indicatorForStatus(task.status);
15517
- const mergedLine = `${statusText} ${task.name} ${stepText}${errorText}`;
15518
- return {
15519
- nameText: task.name,
15520
- stepText,
15521
- errorText,
15522
- itemStatusText: statusText,
15523
- mergedLine
15524
- };
15525
- };
15526
- function paddingLines(lines) {
15527
- return lines.map((line) => {
15528
- return `${indent}${line}`;
15529
- });
15530
- }
15531
- var contextTaskListSummary = (taskStatusArray, context) => {
15532
- const prefixLines = [];
15533
- const currentLine = [];
15534
- const suffixText = [];
15535
- const { mergedText: fileInfo } = contextInfo(context);
15536
- for (const task of taskStatusArray) {
15537
- const { mergedLine } = singleTaskInfo(task);
15538
- if (context.player.status === "init") {
15539
- suffixText.push(mergedLine);
15540
- } else if (context.player.status === "running") {
15541
- currentLine.push(mergedLine);
15542
- } else if (context.player.status === "done") {
15543
- prefixLines.push(mergedLine);
15544
- } else if (context.player.status === "error") {
15545
- prefixLines.push(mergedLine);
15546
- }
15547
- }
15548
- const currentLineText = currentLine.length > 0 ? `
15549
- ${paddingLines(currentLine).join("\n")}` : "";
15550
- const prefix = prefixLines.length > 0 ? `
15551
- ${paddingLines(prefixLines).join("\n")}` : "";
15552
- const suffix = suffixText.length > 0 ? `
15553
- ${paddingLines(suffixText).join("\n")}` : "";
15554
- return `${fileInfo}${prefix}${currentLineText}${suffix}`;
15555
- };
15556
-
15557
- // src/tty-renderer.ts
15558
- var import_node_util = require("util");
15559
-
15560
- // ../../node_modules/.pnpm/restore-cursor@5.1.0/node_modules/restore-cursor/index.js
15561
- var import_node_process = __toESM(require("process"));
15562
-
15563
- // ../../node_modules/.pnpm/mimic-function@5.0.1/node_modules/mimic-function/index.js
15564
- var copyProperty = (to, from, property, ignoreNonConfigurable) => {
15565
- if (property === "length" || property === "prototype") {
15566
- return;
15567
- }
15568
- if (property === "arguments" || property === "caller") {
15569
- return;
12709
+ if (property === "arguments" || property === "caller") {
12710
+ return;
15570
12711
  }
15571
12712
  const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
15572
12713
  const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
@@ -15889,7 +13030,7 @@ var {
15889
13030
  *
15890
13031
  * @internal
15891
13032
  */
15892
- load: load2,
13033
+ load,
15893
13034
  /**
15894
13035
  * Unload the listeners. Likely you never need to call this, unless
15895
13036
  * doing a rather deep integration with signal-exit functionality.
@@ -15986,10 +13127,10 @@ var TTYWindowRenderer = class {
15986
13127
  this.render(current == null ? void 0 : current.message, current == null ? void 0 : current.type);
15987
13128
  }
15988
13129
  }
15989
- render(message, type2 = "output") {
13130
+ render(message, type = "output") {
15990
13131
  if (this.finished) {
15991
13132
  this.clearWindow();
15992
- return this.write(message || "", type2);
13133
+ return this.write(message || "", type);
15993
13134
  }
15994
13135
  const windowContent = this.options.getWindow();
15995
13136
  const rowCount = getRenderedRowCount(
@@ -16003,7 +13144,7 @@ var TTYWindowRenderer = class {
16003
13144
  this.write(SYNC_START);
16004
13145
  this.clearWindow();
16005
13146
  if (message) {
16006
- this.write(message, type2);
13147
+ this.write(message, type);
16007
13148
  }
16008
13149
  if (padding > 0) {
16009
13150
  this.write("\n".repeat(padding));
@@ -16022,14 +13163,14 @@ var TTYWindowRenderer = class {
16022
13163
  }
16023
13164
  this.windowHeight = 0;
16024
13165
  }
16025
- interceptStream(stream2, type2) {
13166
+ interceptStream(stream2, type) {
16026
13167
  const original = stream2.write;
16027
13168
  stream2.write = (chunk, _, callback) => {
16028
13169
  if (chunk) {
16029
13170
  if (this.finished) {
16030
- this.write(chunk.toString(), type2);
13171
+ this.write(chunk.toString(), type);
16031
13172
  } else {
16032
- this.buffer.push({ type: type2, message: chunk.toString() });
13173
+ this.buffer.push({ type, message: chunk.toString() });
16033
13174
  }
16034
13175
  }
16035
13176
  callback == null ? void 0 : callback();
@@ -16038,8 +13179,8 @@ var TTYWindowRenderer = class {
16038
13179
  stream2.write = original;
16039
13180
  };
16040
13181
  }
16041
- write(message, type2 = "output") {
16042
- this.streams[type2](message);
13182
+ write(message, type = "output") {
13183
+ this.streams[type](message);
16043
13184
  }
16044
13185
  };
16045
13186
  function getRenderedRowCount(contents, stream2) {
@@ -16182,10 +13323,8 @@ Promise.resolve(
16182
13323
  process.exit(1);
16183
13324
  }
16184
13325
  process.exit(0);
16185
- }))()
13326
+ }))().catch((e) => {
13327
+ console.error(e);
13328
+ process.exit(1);
13329
+ })
16186
13330
  );
16187
- /*! Bundled license information:
16188
-
16189
- js-yaml/dist/js-yaml.mjs:
16190
- (*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT *)
16191
- */