@applitools/mcp 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +57 -0
- package/dist/index.js +1064 -1043
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -13655,1016 +13655,1037 @@ var codegen = {};
|
|
|
13655
13655
|
|
|
13656
13656
|
var code$1 = {};
|
|
13657
13657
|
|
|
13658
|
-
|
|
13659
|
-
|
|
13660
|
-
|
|
13661
|
-
|
|
13662
|
-
|
|
13663
|
-
|
|
13664
|
-
|
|
13665
|
-
|
|
13666
|
-
|
|
13667
|
-
|
|
13668
|
-
|
|
13669
|
-
|
|
13670
|
-
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
13674
|
-
|
|
13675
|
-
|
|
13676
|
-
|
|
13677
|
-
|
|
13678
|
-
|
|
13679
|
-
|
|
13680
|
-
|
|
13681
|
-
|
|
13682
|
-
|
|
13683
|
-
|
|
13684
|
-
|
|
13685
|
-
|
|
13686
|
-
|
|
13687
|
-
|
|
13688
|
-
|
|
13689
|
-
|
|
13690
|
-
|
|
13691
|
-
|
|
13692
|
-
|
|
13693
|
-
|
|
13694
|
-
|
|
13695
|
-
|
|
13696
|
-
|
|
13697
|
-
|
|
13698
|
-
|
|
13699
|
-
|
|
13700
|
-
|
|
13701
|
-
|
|
13702
|
-
|
|
13703
|
-
|
|
13704
|
-
|
|
13705
|
-
|
|
13706
|
-
|
|
13707
|
-
|
|
13708
|
-
|
|
13709
|
-
|
|
13710
|
-
|
|
13711
|
-
|
|
13712
|
-
|
|
13713
|
-
|
|
13714
|
-
|
|
13715
|
-
|
|
13716
|
-
|
|
13717
|
-
|
|
13718
|
-
|
|
13719
|
-
|
|
13720
|
-
|
|
13721
|
-
|
|
13722
|
-
|
|
13723
|
-
|
|
13724
|
-
|
|
13725
|
-
|
|
13726
|
-
|
|
13727
|
-
|
|
13728
|
-
|
|
13729
|
-
|
|
13730
|
-
|
|
13731
|
-
|
|
13732
|
-
|
|
13733
|
-
|
|
13734
|
-
|
|
13735
|
-
|
|
13736
|
-
|
|
13737
|
-
|
|
13738
|
-
|
|
13739
|
-
|
|
13740
|
-
|
|
13741
|
-
|
|
13742
|
-
|
|
13743
|
-
|
|
13744
|
-
|
|
13745
|
-
|
|
13746
|
-
|
|
13747
|
-
|
|
13748
|
-
|
|
13749
|
-
|
|
13750
|
-
|
|
13751
|
-
|
|
13752
|
-
|
|
13753
|
-
|
|
13754
|
-
|
|
13755
|
-
|
|
13756
|
-
|
|
13757
|
-
|
|
13758
|
-
|
|
13759
|
-
|
|
13760
|
-
|
|
13761
|
-
|
|
13762
|
-
|
|
13763
|
-
|
|
13764
|
-
|
|
13765
|
-
|
|
13766
|
-
|
|
13767
|
-
|
|
13768
|
-
|
|
13769
|
-
|
|
13770
|
-
|
|
13771
|
-
|
|
13772
|
-
|
|
13773
|
-
|
|
13774
|
-
|
|
13775
|
-
|
|
13776
|
-
|
|
13777
|
-
|
|
13778
|
-
|
|
13779
|
-
|
|
13780
|
-
|
|
13781
|
-
|
|
13782
|
-
|
|
13783
|
-
|
|
13784
|
-
|
|
13785
|
-
|
|
13786
|
-
|
|
13787
|
-
|
|
13788
|
-
|
|
13789
|
-
|
|
13790
|
-
|
|
13791
|
-
|
|
13792
|
-
|
|
13793
|
-
|
|
13794
|
-
|
|
13795
|
-
|
|
13796
|
-
|
|
13797
|
-
|
|
13798
|
-
|
|
13799
|
-
|
|
13800
|
-
|
|
13801
|
-
|
|
13802
|
-
|
|
13803
|
-
|
|
13804
|
-
|
|
13805
|
-
|
|
13806
|
-
|
|
13807
|
-
|
|
13808
|
-
|
|
13809
|
-
|
|
13810
|
-
|
|
13811
|
-
|
|
13812
|
-
|
|
13813
|
-
|
|
13814
|
-
|
|
13658
|
+
var hasRequiredCode$1;
|
|
13659
|
+
|
|
13660
|
+
function requireCode$1 () {
|
|
13661
|
+
if (hasRequiredCode$1) return code$1;
|
|
13662
|
+
hasRequiredCode$1 = 1;
|
|
13663
|
+
(function (exports$1) {
|
|
13664
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
13665
|
+
exports$1.regexpCode = exports$1.getEsmExportName = exports$1.getProperty = exports$1.safeStringify = exports$1.stringify = exports$1.strConcat = exports$1.addCodeArg = exports$1.str = exports$1._ = exports$1.nil = exports$1._Code = exports$1.Name = exports$1.IDENTIFIER = exports$1._CodeOrName = void 0;
|
|
13666
|
+
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
13667
|
+
class _CodeOrName {
|
|
13668
|
+
}
|
|
13669
|
+
exports$1._CodeOrName = _CodeOrName;
|
|
13670
|
+
exports$1.IDENTIFIER = /^[a-z$_][a-z$_0-9]*$/i;
|
|
13671
|
+
class Name extends _CodeOrName {
|
|
13672
|
+
constructor(s) {
|
|
13673
|
+
super();
|
|
13674
|
+
if (!exports$1.IDENTIFIER.test(s))
|
|
13675
|
+
throw new Error("CodeGen: name must be a valid identifier");
|
|
13676
|
+
this.str = s;
|
|
13677
|
+
}
|
|
13678
|
+
toString() {
|
|
13679
|
+
return this.str;
|
|
13680
|
+
}
|
|
13681
|
+
emptyStr() {
|
|
13682
|
+
return false;
|
|
13683
|
+
}
|
|
13684
|
+
get names() {
|
|
13685
|
+
return { [this.str]: 1 };
|
|
13686
|
+
}
|
|
13687
|
+
}
|
|
13688
|
+
exports$1.Name = Name;
|
|
13689
|
+
class _Code extends _CodeOrName {
|
|
13690
|
+
constructor(code) {
|
|
13691
|
+
super();
|
|
13692
|
+
this._items = typeof code === "string" ? [code] : code;
|
|
13693
|
+
}
|
|
13694
|
+
toString() {
|
|
13695
|
+
return this.str;
|
|
13696
|
+
}
|
|
13697
|
+
emptyStr() {
|
|
13698
|
+
if (this._items.length > 1)
|
|
13699
|
+
return false;
|
|
13700
|
+
const item = this._items[0];
|
|
13701
|
+
return item === "" || item === '""';
|
|
13702
|
+
}
|
|
13703
|
+
get str() {
|
|
13704
|
+
var _a;
|
|
13705
|
+
return ((_a = this._str) !== null && _a !== void 0 ? _a : (this._str = this._items.reduce((s, c) => `${s}${c}`, "")));
|
|
13706
|
+
}
|
|
13707
|
+
get names() {
|
|
13708
|
+
var _a;
|
|
13709
|
+
return ((_a = this._names) !== null && _a !== void 0 ? _a : (this._names = this._items.reduce((names, c) => {
|
|
13710
|
+
if (c instanceof Name)
|
|
13711
|
+
names[c.str] = (names[c.str] || 0) + 1;
|
|
13712
|
+
return names;
|
|
13713
|
+
}, {})));
|
|
13714
|
+
}
|
|
13715
|
+
}
|
|
13716
|
+
exports$1._Code = _Code;
|
|
13717
|
+
exports$1.nil = new _Code("");
|
|
13718
|
+
function _(strs, ...args) {
|
|
13719
|
+
const code = [strs[0]];
|
|
13720
|
+
let i = 0;
|
|
13721
|
+
while (i < args.length) {
|
|
13722
|
+
addCodeArg(code, args[i]);
|
|
13723
|
+
code.push(strs[++i]);
|
|
13724
|
+
}
|
|
13725
|
+
return new _Code(code);
|
|
13726
|
+
}
|
|
13727
|
+
exports$1._ = _;
|
|
13728
|
+
const plus = new _Code("+");
|
|
13729
|
+
function str(strs, ...args) {
|
|
13730
|
+
const expr = [safeStringify(strs[0])];
|
|
13731
|
+
let i = 0;
|
|
13732
|
+
while (i < args.length) {
|
|
13733
|
+
expr.push(plus);
|
|
13734
|
+
addCodeArg(expr, args[i]);
|
|
13735
|
+
expr.push(plus, safeStringify(strs[++i]));
|
|
13736
|
+
}
|
|
13737
|
+
optimize(expr);
|
|
13738
|
+
return new _Code(expr);
|
|
13739
|
+
}
|
|
13740
|
+
exports$1.str = str;
|
|
13741
|
+
function addCodeArg(code, arg) {
|
|
13742
|
+
if (arg instanceof _Code)
|
|
13743
|
+
code.push(...arg._items);
|
|
13744
|
+
else if (arg instanceof Name)
|
|
13745
|
+
code.push(arg);
|
|
13746
|
+
else
|
|
13747
|
+
code.push(interpolate(arg));
|
|
13748
|
+
}
|
|
13749
|
+
exports$1.addCodeArg = addCodeArg;
|
|
13750
|
+
function optimize(expr) {
|
|
13751
|
+
let i = 1;
|
|
13752
|
+
while (i < expr.length - 1) {
|
|
13753
|
+
if (expr[i] === plus) {
|
|
13754
|
+
const res = mergeExprItems(expr[i - 1], expr[i + 1]);
|
|
13755
|
+
if (res !== undefined) {
|
|
13756
|
+
expr.splice(i - 1, 3, res);
|
|
13757
|
+
continue;
|
|
13758
|
+
}
|
|
13759
|
+
expr[i++] = "+";
|
|
13760
|
+
}
|
|
13761
|
+
i++;
|
|
13762
|
+
}
|
|
13763
|
+
}
|
|
13764
|
+
function mergeExprItems(a, b) {
|
|
13765
|
+
if (b === '""')
|
|
13766
|
+
return a;
|
|
13767
|
+
if (a === '""')
|
|
13768
|
+
return b;
|
|
13769
|
+
if (typeof a == "string") {
|
|
13770
|
+
if (b instanceof Name || a[a.length - 1] !== '"')
|
|
13771
|
+
return;
|
|
13772
|
+
if (typeof b != "string")
|
|
13773
|
+
return `${a.slice(0, -1)}${b}"`;
|
|
13774
|
+
if (b[0] === '"')
|
|
13775
|
+
return a.slice(0, -1) + b.slice(1);
|
|
13776
|
+
return;
|
|
13777
|
+
}
|
|
13778
|
+
if (typeof b == "string" && b[0] === '"' && !(a instanceof Name))
|
|
13779
|
+
return `"${a}${b.slice(1)}`;
|
|
13780
|
+
return;
|
|
13781
|
+
}
|
|
13782
|
+
function strConcat(c1, c2) {
|
|
13783
|
+
return c2.emptyStr() ? c1 : c1.emptyStr() ? c2 : str `${c1}${c2}`;
|
|
13784
|
+
}
|
|
13785
|
+
exports$1.strConcat = strConcat;
|
|
13786
|
+
// TODO do not allow arrays here
|
|
13787
|
+
function interpolate(x) {
|
|
13788
|
+
return typeof x == "number" || typeof x == "boolean" || x === null
|
|
13789
|
+
? x
|
|
13790
|
+
: safeStringify(Array.isArray(x) ? x.join(",") : x);
|
|
13791
|
+
}
|
|
13792
|
+
function stringify(x) {
|
|
13793
|
+
return new _Code(safeStringify(x));
|
|
13794
|
+
}
|
|
13795
|
+
exports$1.stringify = stringify;
|
|
13796
|
+
function safeStringify(x) {
|
|
13797
|
+
return JSON.stringify(x)
|
|
13798
|
+
.replace(/\u2028/g, "\\u2028")
|
|
13799
|
+
.replace(/\u2029/g, "\\u2029");
|
|
13800
|
+
}
|
|
13801
|
+
exports$1.safeStringify = safeStringify;
|
|
13802
|
+
function getProperty(key) {
|
|
13803
|
+
return typeof key == "string" && exports$1.IDENTIFIER.test(key) ? new _Code(`.${key}`) : _ `[${key}]`;
|
|
13804
|
+
}
|
|
13805
|
+
exports$1.getProperty = getProperty;
|
|
13806
|
+
//Does best effort to format the name properly
|
|
13807
|
+
function getEsmExportName(key) {
|
|
13808
|
+
if (typeof key == "string" && exports$1.IDENTIFIER.test(key)) {
|
|
13809
|
+
return new _Code(`${key}`);
|
|
13810
|
+
}
|
|
13811
|
+
throw new Error(`CodeGen: invalid export name: ${key}, use explicit $id name mapping`);
|
|
13812
|
+
}
|
|
13813
|
+
exports$1.getEsmExportName = getEsmExportName;
|
|
13814
|
+
function regexpCode(rx) {
|
|
13815
|
+
return new _Code(rx.toString());
|
|
13816
|
+
}
|
|
13817
|
+
exports$1.regexpCode = regexpCode;
|
|
13818
|
+
|
|
13819
|
+
} (code$1));
|
|
13820
|
+
return code$1;
|
|
13821
|
+
}
|
|
13815
13822
|
|
|
13816
13823
|
var scope = {};
|
|
13817
13824
|
|
|
13818
|
-
|
|
13819
|
-
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
13820
|
-
exports$1.ValueScope = exports$1.ValueScopeName = exports$1.Scope = exports$1.varKinds = exports$1.UsedValueState = void 0;
|
|
13821
|
-
const code_1 = code$1;
|
|
13822
|
-
class ValueError extends Error {
|
|
13823
|
-
constructor(name) {
|
|
13824
|
-
super(`CodeGen: "code" for ${name} not defined`);
|
|
13825
|
-
this.value = name.value;
|
|
13826
|
-
}
|
|
13827
|
-
}
|
|
13828
|
-
var UsedValueState;
|
|
13829
|
-
(function (UsedValueState) {
|
|
13830
|
-
UsedValueState[UsedValueState["Started"] = 0] = "Started";
|
|
13831
|
-
UsedValueState[UsedValueState["Completed"] = 1] = "Completed";
|
|
13832
|
-
})(UsedValueState || (exports$1.UsedValueState = UsedValueState = {}));
|
|
13833
|
-
exports$1.varKinds = {
|
|
13834
|
-
const: new code_1.Name("const"),
|
|
13835
|
-
let: new code_1.Name("let"),
|
|
13836
|
-
var: new code_1.Name("var"),
|
|
13837
|
-
};
|
|
13838
|
-
class Scope {
|
|
13839
|
-
constructor({ prefixes, parent } = {}) {
|
|
13840
|
-
this._names = {};
|
|
13841
|
-
this._prefixes = prefixes;
|
|
13842
|
-
this._parent = parent;
|
|
13843
|
-
}
|
|
13844
|
-
toName(nameOrPrefix) {
|
|
13845
|
-
return nameOrPrefix instanceof code_1.Name ? nameOrPrefix : this.name(nameOrPrefix);
|
|
13846
|
-
}
|
|
13847
|
-
name(prefix) {
|
|
13848
|
-
return new code_1.Name(this._newName(prefix));
|
|
13849
|
-
}
|
|
13850
|
-
_newName(prefix) {
|
|
13851
|
-
const ng = this._names[prefix] || this._nameGroup(prefix);
|
|
13852
|
-
return `${prefix}${ng.index++}`;
|
|
13853
|
-
}
|
|
13854
|
-
_nameGroup(prefix) {
|
|
13855
|
-
var _a, _b;
|
|
13856
|
-
if (((_b = (_a = this._parent) === null || _a === void 0 ? void 0 : _a._prefixes) === null || _b === void 0 ? void 0 : _b.has(prefix)) || (this._prefixes && !this._prefixes.has(prefix))) {
|
|
13857
|
-
throw new Error(`CodeGen: prefix "${prefix}" is not allowed in this scope`);
|
|
13858
|
-
}
|
|
13859
|
-
return (this._names[prefix] = { prefix, index: 0 });
|
|
13860
|
-
}
|
|
13861
|
-
}
|
|
13862
|
-
exports$1.Scope = Scope;
|
|
13863
|
-
class ValueScopeName extends code_1.Name {
|
|
13864
|
-
constructor(prefix, nameStr) {
|
|
13865
|
-
super(nameStr);
|
|
13866
|
-
this.prefix = prefix;
|
|
13867
|
-
}
|
|
13868
|
-
setValue(value, { property, itemIndex }) {
|
|
13869
|
-
this.value = value;
|
|
13870
|
-
this.scopePath = (0, code_1._) `.${new code_1.Name(property)}[${itemIndex}]`;
|
|
13871
|
-
}
|
|
13872
|
-
}
|
|
13873
|
-
exports$1.ValueScopeName = ValueScopeName;
|
|
13874
|
-
const line = (0, code_1._) `\n`;
|
|
13875
|
-
class ValueScope extends Scope {
|
|
13876
|
-
constructor(opts) {
|
|
13877
|
-
super(opts);
|
|
13878
|
-
this._values = {};
|
|
13879
|
-
this._scope = opts.scope;
|
|
13880
|
-
this.opts = { ...opts, _n: opts.lines ? line : code_1.nil };
|
|
13881
|
-
}
|
|
13882
|
-
get() {
|
|
13883
|
-
return this._scope;
|
|
13884
|
-
}
|
|
13885
|
-
name(prefix) {
|
|
13886
|
-
return new ValueScopeName(prefix, this._newName(prefix));
|
|
13887
|
-
}
|
|
13888
|
-
value(nameOrPrefix, value) {
|
|
13889
|
-
var _a;
|
|
13890
|
-
if (value.ref === undefined)
|
|
13891
|
-
throw new Error("CodeGen: ref must be passed in value");
|
|
13892
|
-
const name = this.toName(nameOrPrefix);
|
|
13893
|
-
const { prefix } = name;
|
|
13894
|
-
const valueKey = (_a = value.key) !== null && _a !== void 0 ? _a : value.ref;
|
|
13895
|
-
let vs = this._values[prefix];
|
|
13896
|
-
if (vs) {
|
|
13897
|
-
const _name = vs.get(valueKey);
|
|
13898
|
-
if (_name)
|
|
13899
|
-
return _name;
|
|
13900
|
-
}
|
|
13901
|
-
else {
|
|
13902
|
-
vs = this._values[prefix] = new Map();
|
|
13903
|
-
}
|
|
13904
|
-
vs.set(valueKey, name);
|
|
13905
|
-
const s = this._scope[prefix] || (this._scope[prefix] = []);
|
|
13906
|
-
const itemIndex = s.length;
|
|
13907
|
-
s[itemIndex] = value.ref;
|
|
13908
|
-
name.setValue(value, { property: prefix, itemIndex });
|
|
13909
|
-
return name;
|
|
13910
|
-
}
|
|
13911
|
-
getValue(prefix, keyOrRef) {
|
|
13912
|
-
const vs = this._values[prefix];
|
|
13913
|
-
if (!vs)
|
|
13914
|
-
return;
|
|
13915
|
-
return vs.get(keyOrRef);
|
|
13916
|
-
}
|
|
13917
|
-
scopeRefs(scopeName, values = this._values) {
|
|
13918
|
-
return this._reduceValues(values, (name) => {
|
|
13919
|
-
if (name.scopePath === undefined)
|
|
13920
|
-
throw new Error(`CodeGen: name "${name}" has no value`);
|
|
13921
|
-
return (0, code_1._) `${scopeName}${name.scopePath}`;
|
|
13922
|
-
});
|
|
13923
|
-
}
|
|
13924
|
-
scopeCode(values = this._values, usedValues, getCode) {
|
|
13925
|
-
return this._reduceValues(values, (name) => {
|
|
13926
|
-
if (name.value === undefined)
|
|
13927
|
-
throw new Error(`CodeGen: name "${name}" has no value`);
|
|
13928
|
-
return name.value.code;
|
|
13929
|
-
}, usedValues, getCode);
|
|
13930
|
-
}
|
|
13931
|
-
_reduceValues(values, valueCode, usedValues = {}, getCode) {
|
|
13932
|
-
let code = code_1.nil;
|
|
13933
|
-
for (const prefix in values) {
|
|
13934
|
-
const vs = values[prefix];
|
|
13935
|
-
if (!vs)
|
|
13936
|
-
continue;
|
|
13937
|
-
const nameSet = (usedValues[prefix] = usedValues[prefix] || new Map());
|
|
13938
|
-
vs.forEach((name) => {
|
|
13939
|
-
if (nameSet.has(name))
|
|
13940
|
-
return;
|
|
13941
|
-
nameSet.set(name, UsedValueState.Started);
|
|
13942
|
-
let c = valueCode(name);
|
|
13943
|
-
if (c) {
|
|
13944
|
-
const def = this.opts.es5 ? exports$1.varKinds.var : exports$1.varKinds.const;
|
|
13945
|
-
code = (0, code_1._) `${code}${def} ${name} = ${c};${this.opts._n}`;
|
|
13946
|
-
}
|
|
13947
|
-
else if ((c = getCode === null || getCode === void 0 ? void 0 : getCode(name))) {
|
|
13948
|
-
code = (0, code_1._) `${code}${c}${this.opts._n}`;
|
|
13949
|
-
}
|
|
13950
|
-
else {
|
|
13951
|
-
throw new ValueError(name);
|
|
13952
|
-
}
|
|
13953
|
-
nameSet.set(name, UsedValueState.Completed);
|
|
13954
|
-
});
|
|
13955
|
-
}
|
|
13956
|
-
return code;
|
|
13957
|
-
}
|
|
13958
|
-
}
|
|
13959
|
-
exports$1.ValueScope = ValueScope;
|
|
13960
|
-
|
|
13961
|
-
} (scope));
|
|
13825
|
+
var hasRequiredScope;
|
|
13962
13826
|
|
|
13963
|
-
|
|
13964
|
-
|
|
13965
|
-
|
|
13966
|
-
|
|
13967
|
-
|
|
13968
|
-
|
|
13969
|
-
|
|
13970
|
-
|
|
13971
|
-
|
|
13972
|
-
|
|
13973
|
-
|
|
13974
|
-
|
|
13975
|
-
|
|
13976
|
-
|
|
13977
|
-
|
|
13978
|
-
|
|
13979
|
-
|
|
13980
|
-
|
|
13981
|
-
|
|
13982
|
-
|
|
13983
|
-
|
|
13984
|
-
|
|
13985
|
-
|
|
13986
|
-
|
|
13987
|
-
|
|
13988
|
-
|
|
13989
|
-
|
|
13990
|
-
|
|
13991
|
-
|
|
13992
|
-
|
|
13993
|
-
|
|
13994
|
-
|
|
13995
|
-
|
|
13996
|
-
|
|
13997
|
-
|
|
13998
|
-
|
|
13999
|
-
|
|
14000
|
-
|
|
14001
|
-
|
|
14002
|
-
|
|
14003
|
-
|
|
14004
|
-
|
|
14005
|
-
|
|
14006
|
-
|
|
14007
|
-
|
|
14008
|
-
|
|
14009
|
-
|
|
14010
|
-
|
|
14011
|
-
|
|
14012
|
-
|
|
14013
|
-
|
|
14014
|
-
|
|
14015
|
-
|
|
14016
|
-
|
|
14017
|
-
|
|
14018
|
-
|
|
14019
|
-
|
|
14020
|
-
|
|
14021
|
-
|
|
14022
|
-
|
|
14023
|
-
|
|
14024
|
-
|
|
14025
|
-
|
|
14026
|
-
|
|
14027
|
-
|
|
14028
|
-
|
|
14029
|
-
|
|
14030
|
-
|
|
14031
|
-
|
|
14032
|
-
|
|
14033
|
-
|
|
14034
|
-
|
|
14035
|
-
|
|
14036
|
-
|
|
14037
|
-
|
|
14038
|
-
|
|
14039
|
-
|
|
14040
|
-
|
|
14041
|
-
|
|
14042
|
-
|
|
14043
|
-
|
|
14044
|
-
|
|
14045
|
-
|
|
14046
|
-
|
|
14047
|
-
|
|
14048
|
-
|
|
14049
|
-
|
|
14050
|
-
|
|
14051
|
-
|
|
14052
|
-
|
|
14053
|
-
|
|
14054
|
-
|
|
14055
|
-
|
|
14056
|
-
|
|
14057
|
-
|
|
14058
|
-
|
|
14059
|
-
|
|
14060
|
-
|
|
14061
|
-
|
|
14062
|
-
|
|
14063
|
-
|
|
14064
|
-
|
|
14065
|
-
|
|
14066
|
-
|
|
14067
|
-
|
|
14068
|
-
|
|
14069
|
-
|
|
14070
|
-
|
|
14071
|
-
|
|
14072
|
-
|
|
14073
|
-
|
|
14074
|
-
|
|
14075
|
-
|
|
14076
|
-
|
|
14077
|
-
|
|
14078
|
-
|
|
14079
|
-
|
|
14080
|
-
|
|
14081
|
-
|
|
14082
|
-
|
|
14083
|
-
|
|
14084
|
-
|
|
14085
|
-
|
|
14086
|
-
|
|
14087
|
-
|
|
14088
|
-
|
|
14089
|
-
|
|
14090
|
-
|
|
14091
|
-
|
|
14092
|
-
|
|
14093
|
-
|
|
14094
|
-
|
|
14095
|
-
|
|
14096
|
-
|
|
14097
|
-
|
|
14098
|
-
|
|
14099
|
-
|
|
14100
|
-
|
|
14101
|
-
|
|
14102
|
-
|
|
14103
|
-
|
|
14104
|
-
|
|
14105
|
-
|
|
14106
|
-
|
|
14107
|
-
|
|
14108
|
-
|
|
14109
|
-
|
|
14110
|
-
|
|
14111
|
-
|
|
14112
|
-
|
|
14113
|
-
|
|
14114
|
-
|
|
14115
|
-
|
|
14116
|
-
|
|
14117
|
-
|
|
14118
|
-
|
|
14119
|
-
|
|
14120
|
-
|
|
14121
|
-
|
|
14122
|
-
|
|
14123
|
-
|
|
14124
|
-
|
|
14125
|
-
|
|
14126
|
-
|
|
14127
|
-
|
|
14128
|
-
|
|
14129
|
-
|
|
14130
|
-
|
|
14131
|
-
|
|
14132
|
-
|
|
14133
|
-
|
|
14134
|
-
|
|
14135
|
-
|
|
14136
|
-
|
|
14137
|
-
|
|
14138
|
-
|
|
14139
|
-
|
|
14140
|
-
|
|
14141
|
-
|
|
14142
|
-
|
|
14143
|
-
|
|
14144
|
-
|
|
14145
|
-
|
|
14146
|
-
|
|
14147
|
-
|
|
14148
|
-
|
|
14149
|
-
|
|
14150
|
-
|
|
14151
|
-
|
|
14152
|
-
|
|
14153
|
-
|
|
14154
|
-
|
|
14155
|
-
|
|
14156
|
-
|
|
14157
|
-
|
|
14158
|
-
|
|
14159
|
-
|
|
14160
|
-
|
|
14161
|
-
|
|
14162
|
-
|
|
14163
|
-
|
|
14164
|
-
|
|
14165
|
-
|
|
14166
|
-
|
|
14167
|
-
|
|
14168
|
-
|
|
14169
|
-
|
|
14170
|
-
|
|
14171
|
-
|
|
14172
|
-
|
|
14173
|
-
|
|
14174
|
-
|
|
14175
|
-
|
|
14176
|
-
|
|
14177
|
-
|
|
14178
|
-
|
|
14179
|
-
|
|
14180
|
-
|
|
14181
|
-
|
|
14182
|
-
|
|
14183
|
-
|
|
14184
|
-
|
|
14185
|
-
|
|
14186
|
-
|
|
14187
|
-
|
|
14188
|
-
|
|
14189
|
-
|
|
14190
|
-
|
|
14191
|
-
|
|
14192
|
-
|
|
14193
|
-
|
|
14194
|
-
|
|
14195
|
-
|
|
14196
|
-
|
|
14197
|
-
|
|
14198
|
-
|
|
14199
|
-
|
|
14200
|
-
|
|
14201
|
-
|
|
14202
|
-
|
|
14203
|
-
|
|
14204
|
-
|
|
14205
|
-
|
|
14206
|
-
|
|
14207
|
-
|
|
14208
|
-
|
|
14209
|
-
|
|
14210
|
-
|
|
14211
|
-
|
|
14212
|
-
|
|
14213
|
-
|
|
14214
|
-
|
|
14215
|
-
|
|
14216
|
-
|
|
14217
|
-
|
|
14218
|
-
|
|
14219
|
-
|
|
14220
|
-
|
|
14221
|
-
|
|
14222
|
-
|
|
14223
|
-
|
|
14224
|
-
|
|
14225
|
-
|
|
14226
|
-
|
|
14227
|
-
|
|
14228
|
-
|
|
14229
|
-
|
|
14230
|
-
|
|
14231
|
-
|
|
14232
|
-
|
|
14233
|
-
|
|
14234
|
-
|
|
14235
|
-
|
|
14236
|
-
|
|
14237
|
-
|
|
14238
|
-
|
|
14239
|
-
|
|
14240
|
-
|
|
14241
|
-
|
|
14242
|
-
|
|
14243
|
-
|
|
14244
|
-
|
|
14245
|
-
|
|
14246
|
-
|
|
14247
|
-
|
|
14248
|
-
|
|
14249
|
-
|
|
14250
|
-
|
|
14251
|
-
|
|
14252
|
-
|
|
14253
|
-
|
|
14254
|
-
|
|
14255
|
-
|
|
14256
|
-
|
|
14257
|
-
|
|
14258
|
-
|
|
14259
|
-
|
|
14260
|
-
|
|
14261
|
-
|
|
14262
|
-
|
|
14263
|
-
|
|
14264
|
-
|
|
14265
|
-
|
|
14266
|
-
|
|
14267
|
-
|
|
14268
|
-
|
|
14269
|
-
|
|
14270
|
-
|
|
14271
|
-
|
|
14272
|
-
|
|
14273
|
-
|
|
14274
|
-
|
|
14275
|
-
|
|
14276
|
-
|
|
14277
|
-
|
|
14278
|
-
|
|
14279
|
-
|
|
14280
|
-
|
|
14281
|
-
|
|
14282
|
-
|
|
14283
|
-
|
|
14284
|
-
|
|
14285
|
-
|
|
14286
|
-
|
|
14287
|
-
|
|
14288
|
-
|
|
14289
|
-
|
|
14290
|
-
|
|
14291
|
-
|
|
14292
|
-
|
|
14293
|
-
|
|
14294
|
-
|
|
14295
|
-
|
|
14296
|
-
|
|
14297
|
-
|
|
14298
|
-
|
|
14299
|
-
|
|
14300
|
-
|
|
14301
|
-
|
|
14302
|
-
|
|
14303
|
-
|
|
14304
|
-
|
|
14305
|
-
|
|
14306
|
-
|
|
14307
|
-
|
|
14308
|
-
|
|
14309
|
-
|
|
14310
|
-
|
|
14311
|
-
|
|
14312
|
-
|
|
14313
|
-
|
|
14314
|
-
|
|
14315
|
-
|
|
14316
|
-
|
|
14317
|
-
|
|
14318
|
-
|
|
14319
|
-
|
|
14320
|
-
|
|
14321
|
-
|
|
14322
|
-
|
|
14323
|
-
|
|
14324
|
-
|
|
14325
|
-
|
|
14326
|
-
|
|
14327
|
-
|
|
14328
|
-
|
|
14329
|
-
|
|
14330
|
-
|
|
14331
|
-
|
|
14332
|
-
|
|
14333
|
-
|
|
14334
|
-
|
|
14335
|
-
|
|
14336
|
-
|
|
14337
|
-
|
|
14338
|
-
|
|
14339
|
-
|
|
14340
|
-
|
|
14341
|
-
|
|
14342
|
-
|
|
14343
|
-
|
|
14344
|
-
|
|
14345
|
-
|
|
14346
|
-
|
|
14347
|
-
|
|
14348
|
-
|
|
14349
|
-
|
|
14350
|
-
|
|
14351
|
-
|
|
14352
|
-
|
|
14353
|
-
|
|
14354
|
-
|
|
14355
|
-
|
|
14356
|
-
|
|
14357
|
-
|
|
14358
|
-
|
|
14359
|
-
|
|
14360
|
-
|
|
14361
|
-
|
|
14362
|
-
|
|
14363
|
-
|
|
14364
|
-
|
|
14365
|
-
|
|
14366
|
-
|
|
14367
|
-
|
|
14368
|
-
|
|
14369
|
-
|
|
14370
|
-
|
|
14371
|
-
|
|
14372
|
-
|
|
14373
|
-
|
|
14374
|
-
|
|
14375
|
-
|
|
14376
|
-
|
|
14377
|
-
|
|
14378
|
-
|
|
14379
|
-
|
|
14380
|
-
|
|
14381
|
-
|
|
14382
|
-
|
|
14383
|
-
|
|
14384
|
-
|
|
14385
|
-
|
|
14386
|
-
|
|
14387
|
-
|
|
14388
|
-
|
|
14389
|
-
|
|
14390
|
-
|
|
14391
|
-
|
|
14392
|
-
|
|
14393
|
-
|
|
14394
|
-
|
|
14395
|
-
|
|
14396
|
-
|
|
14397
|
-
|
|
14398
|
-
|
|
14399
|
-
|
|
14400
|
-
|
|
14401
|
-
|
|
14402
|
-
|
|
14403
|
-
|
|
14404
|
-
|
|
14405
|
-
|
|
14406
|
-
|
|
14407
|
-
|
|
14408
|
-
|
|
14409
|
-
|
|
14410
|
-
|
|
14411
|
-
|
|
14412
|
-
|
|
14413
|
-
|
|
14414
|
-
|
|
14415
|
-
|
|
14416
|
-
|
|
14417
|
-
|
|
14418
|
-
|
|
14419
|
-
|
|
14420
|
-
|
|
14421
|
-
|
|
14422
|
-
|
|
14423
|
-
|
|
14424
|
-
|
|
14425
|
-
|
|
14426
|
-
|
|
14427
|
-
|
|
14428
|
-
|
|
14429
|
-
|
|
14430
|
-
|
|
14431
|
-
|
|
14432
|
-
|
|
14433
|
-
|
|
14434
|
-
|
|
14435
|
-
|
|
14436
|
-
|
|
14437
|
-
|
|
14438
|
-
|
|
14439
|
-
|
|
14440
|
-
|
|
14441
|
-
|
|
14442
|
-
|
|
14443
|
-
|
|
14444
|
-
|
|
14445
|
-
|
|
14446
|
-
|
|
14447
|
-
|
|
14448
|
-
|
|
14449
|
-
|
|
14450
|
-
|
|
14451
|
-
|
|
14452
|
-
|
|
14453
|
-
|
|
14454
|
-
|
|
14455
|
-
|
|
14456
|
-
|
|
14457
|
-
|
|
14458
|
-
|
|
14459
|
-
|
|
14460
|
-
|
|
14461
|
-
|
|
14462
|
-
|
|
14463
|
-
|
|
14464
|
-
|
|
14465
|
-
|
|
14466
|
-
|
|
14467
|
-
|
|
14468
|
-
|
|
14469
|
-
|
|
14470
|
-
|
|
14471
|
-
|
|
14472
|
-
|
|
14473
|
-
|
|
14474
|
-
|
|
14475
|
-
|
|
14476
|
-
|
|
14477
|
-
|
|
14478
|
-
|
|
14479
|
-
|
|
14480
|
-
|
|
14481
|
-
|
|
14482
|
-
|
|
14483
|
-
|
|
14484
|
-
|
|
14485
|
-
|
|
14486
|
-
|
|
14487
|
-
|
|
14488
|
-
|
|
14489
|
-
|
|
14490
|
-
|
|
14491
|
-
|
|
14492
|
-
|
|
14493
|
-
|
|
14494
|
-
|
|
14495
|
-
|
|
14496
|
-
|
|
14497
|
-
|
|
14498
|
-
|
|
14499
|
-
|
|
14500
|
-
|
|
14501
|
-
|
|
14502
|
-
|
|
14503
|
-
|
|
14504
|
-
|
|
14505
|
-
|
|
14506
|
-
|
|
14507
|
-
|
|
14508
|
-
|
|
14509
|
-
|
|
14510
|
-
|
|
14511
|
-
|
|
14512
|
-
|
|
14513
|
-
|
|
14514
|
-
|
|
14515
|
-
|
|
14516
|
-
|
|
14517
|
-
|
|
14518
|
-
|
|
14519
|
-
|
|
14520
|
-
|
|
14521
|
-
|
|
14522
|
-
|
|
14523
|
-
|
|
14524
|
-
|
|
14525
|
-
|
|
14526
|
-
|
|
14527
|
-
|
|
14528
|
-
|
|
14529
|
-
|
|
14530
|
-
|
|
14531
|
-
|
|
14532
|
-
|
|
14533
|
-
|
|
14534
|
-
|
|
14535
|
-
|
|
14536
|
-
|
|
14537
|
-
|
|
14538
|
-
|
|
14539
|
-
|
|
14540
|
-
|
|
14541
|
-
|
|
14542
|
-
|
|
14543
|
-
|
|
14544
|
-
|
|
14545
|
-
|
|
14546
|
-
|
|
14547
|
-
|
|
14548
|
-
|
|
14549
|
-
|
|
14550
|
-
|
|
14551
|
-
|
|
14552
|
-
|
|
14553
|
-
|
|
14554
|
-
|
|
14555
|
-
|
|
14556
|
-
|
|
14557
|
-
|
|
14558
|
-
|
|
14559
|
-
|
|
14560
|
-
|
|
14561
|
-
|
|
14562
|
-
|
|
14563
|
-
|
|
14564
|
-
|
|
14565
|
-
|
|
14566
|
-
|
|
14567
|
-
|
|
14568
|
-
|
|
14569
|
-
|
|
14570
|
-
|
|
14571
|
-
|
|
14572
|
-
|
|
14573
|
-
|
|
14574
|
-
|
|
14575
|
-
|
|
14576
|
-
|
|
14577
|
-
|
|
14578
|
-
|
|
14579
|
-
|
|
14580
|
-
|
|
14581
|
-
|
|
14582
|
-
|
|
14583
|
-
|
|
14584
|
-
|
|
14585
|
-
|
|
14586
|
-
|
|
14587
|
-
|
|
14588
|
-
|
|
14589
|
-
|
|
14590
|
-
|
|
14591
|
-
|
|
14592
|
-
|
|
14593
|
-
|
|
14594
|
-
|
|
14595
|
-
|
|
14596
|
-
|
|
14597
|
-
|
|
14598
|
-
|
|
14599
|
-
|
|
14600
|
-
|
|
14601
|
-
|
|
14602
|
-
|
|
14603
|
-
|
|
14604
|
-
|
|
14605
|
-
|
|
14606
|
-
|
|
14607
|
-
|
|
14608
|
-
|
|
14609
|
-
|
|
14610
|
-
|
|
14611
|
-
|
|
14612
|
-
|
|
14613
|
-
|
|
14614
|
-
|
|
14615
|
-
|
|
14616
|
-
|
|
14617
|
-
|
|
14618
|
-
|
|
14619
|
-
|
|
14620
|
-
|
|
14621
|
-
|
|
14622
|
-
|
|
14623
|
-
|
|
14624
|
-
|
|
14625
|
-
|
|
14626
|
-
|
|
14627
|
-
|
|
14628
|
-
|
|
14629
|
-
|
|
14630
|
-
|
|
14631
|
-
|
|
14632
|
-
|
|
14633
|
-
|
|
14634
|
-
|
|
14635
|
-
|
|
14636
|
-
|
|
14637
|
-
|
|
14638
|
-
|
|
14639
|
-
|
|
14640
|
-
|
|
14641
|
-
|
|
14642
|
-
|
|
14643
|
-
|
|
14644
|
-
|
|
14645
|
-
|
|
14646
|
-
|
|
14647
|
-
|
|
14648
|
-
|
|
14649
|
-
|
|
14650
|
-
|
|
14651
|
-
|
|
14652
|
-
|
|
14653
|
-
|
|
14654
|
-
|
|
14655
|
-
|
|
14656
|
-
|
|
14657
|
-
|
|
14658
|
-
|
|
14659
|
-
|
|
14660
|
-
|
|
13827
|
+
function requireScope () {
|
|
13828
|
+
if (hasRequiredScope) return scope;
|
|
13829
|
+
hasRequiredScope = 1;
|
|
13830
|
+
(function (exports$1) {
|
|
13831
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
13832
|
+
exports$1.ValueScope = exports$1.ValueScopeName = exports$1.Scope = exports$1.varKinds = exports$1.UsedValueState = void 0;
|
|
13833
|
+
const code_1 = requireCode$1();
|
|
13834
|
+
class ValueError extends Error {
|
|
13835
|
+
constructor(name) {
|
|
13836
|
+
super(`CodeGen: "code" for ${name} not defined`);
|
|
13837
|
+
this.value = name.value;
|
|
13838
|
+
}
|
|
13839
|
+
}
|
|
13840
|
+
var UsedValueState;
|
|
13841
|
+
(function (UsedValueState) {
|
|
13842
|
+
UsedValueState[UsedValueState["Started"] = 0] = "Started";
|
|
13843
|
+
UsedValueState[UsedValueState["Completed"] = 1] = "Completed";
|
|
13844
|
+
})(UsedValueState || (exports$1.UsedValueState = UsedValueState = {}));
|
|
13845
|
+
exports$1.varKinds = {
|
|
13846
|
+
const: new code_1.Name("const"),
|
|
13847
|
+
let: new code_1.Name("let"),
|
|
13848
|
+
var: new code_1.Name("var"),
|
|
13849
|
+
};
|
|
13850
|
+
class Scope {
|
|
13851
|
+
constructor({ prefixes, parent } = {}) {
|
|
13852
|
+
this._names = {};
|
|
13853
|
+
this._prefixes = prefixes;
|
|
13854
|
+
this._parent = parent;
|
|
13855
|
+
}
|
|
13856
|
+
toName(nameOrPrefix) {
|
|
13857
|
+
return nameOrPrefix instanceof code_1.Name ? nameOrPrefix : this.name(nameOrPrefix);
|
|
13858
|
+
}
|
|
13859
|
+
name(prefix) {
|
|
13860
|
+
return new code_1.Name(this._newName(prefix));
|
|
13861
|
+
}
|
|
13862
|
+
_newName(prefix) {
|
|
13863
|
+
const ng = this._names[prefix] || this._nameGroup(prefix);
|
|
13864
|
+
return `${prefix}${ng.index++}`;
|
|
13865
|
+
}
|
|
13866
|
+
_nameGroup(prefix) {
|
|
13867
|
+
var _a, _b;
|
|
13868
|
+
if (((_b = (_a = this._parent) === null || _a === void 0 ? void 0 : _a._prefixes) === null || _b === void 0 ? void 0 : _b.has(prefix)) || (this._prefixes && !this._prefixes.has(prefix))) {
|
|
13869
|
+
throw new Error(`CodeGen: prefix "${prefix}" is not allowed in this scope`);
|
|
13870
|
+
}
|
|
13871
|
+
return (this._names[prefix] = { prefix, index: 0 });
|
|
13872
|
+
}
|
|
13873
|
+
}
|
|
13874
|
+
exports$1.Scope = Scope;
|
|
13875
|
+
class ValueScopeName extends code_1.Name {
|
|
13876
|
+
constructor(prefix, nameStr) {
|
|
13877
|
+
super(nameStr);
|
|
13878
|
+
this.prefix = prefix;
|
|
13879
|
+
}
|
|
13880
|
+
setValue(value, { property, itemIndex }) {
|
|
13881
|
+
this.value = value;
|
|
13882
|
+
this.scopePath = (0, code_1._) `.${new code_1.Name(property)}[${itemIndex}]`;
|
|
13883
|
+
}
|
|
13884
|
+
}
|
|
13885
|
+
exports$1.ValueScopeName = ValueScopeName;
|
|
13886
|
+
const line = (0, code_1._) `\n`;
|
|
13887
|
+
class ValueScope extends Scope {
|
|
13888
|
+
constructor(opts) {
|
|
13889
|
+
super(opts);
|
|
13890
|
+
this._values = {};
|
|
13891
|
+
this._scope = opts.scope;
|
|
13892
|
+
this.opts = { ...opts, _n: opts.lines ? line : code_1.nil };
|
|
13893
|
+
}
|
|
13894
|
+
get() {
|
|
13895
|
+
return this._scope;
|
|
13896
|
+
}
|
|
13897
|
+
name(prefix) {
|
|
13898
|
+
return new ValueScopeName(prefix, this._newName(prefix));
|
|
13899
|
+
}
|
|
13900
|
+
value(nameOrPrefix, value) {
|
|
13901
|
+
var _a;
|
|
13902
|
+
if (value.ref === undefined)
|
|
13903
|
+
throw new Error("CodeGen: ref must be passed in value");
|
|
13904
|
+
const name = this.toName(nameOrPrefix);
|
|
13905
|
+
const { prefix } = name;
|
|
13906
|
+
const valueKey = (_a = value.key) !== null && _a !== void 0 ? _a : value.ref;
|
|
13907
|
+
let vs = this._values[prefix];
|
|
13908
|
+
if (vs) {
|
|
13909
|
+
const _name = vs.get(valueKey);
|
|
13910
|
+
if (_name)
|
|
13911
|
+
return _name;
|
|
13912
|
+
}
|
|
13913
|
+
else {
|
|
13914
|
+
vs = this._values[prefix] = new Map();
|
|
13915
|
+
}
|
|
13916
|
+
vs.set(valueKey, name);
|
|
13917
|
+
const s = this._scope[prefix] || (this._scope[prefix] = []);
|
|
13918
|
+
const itemIndex = s.length;
|
|
13919
|
+
s[itemIndex] = value.ref;
|
|
13920
|
+
name.setValue(value, { property: prefix, itemIndex });
|
|
13921
|
+
return name;
|
|
13922
|
+
}
|
|
13923
|
+
getValue(prefix, keyOrRef) {
|
|
13924
|
+
const vs = this._values[prefix];
|
|
13925
|
+
if (!vs)
|
|
13926
|
+
return;
|
|
13927
|
+
return vs.get(keyOrRef);
|
|
13928
|
+
}
|
|
13929
|
+
scopeRefs(scopeName, values = this._values) {
|
|
13930
|
+
return this._reduceValues(values, (name) => {
|
|
13931
|
+
if (name.scopePath === undefined)
|
|
13932
|
+
throw new Error(`CodeGen: name "${name}" has no value`);
|
|
13933
|
+
return (0, code_1._) `${scopeName}${name.scopePath}`;
|
|
13934
|
+
});
|
|
13935
|
+
}
|
|
13936
|
+
scopeCode(values = this._values, usedValues, getCode) {
|
|
13937
|
+
return this._reduceValues(values, (name) => {
|
|
13938
|
+
if (name.value === undefined)
|
|
13939
|
+
throw new Error(`CodeGen: name "${name}" has no value`);
|
|
13940
|
+
return name.value.code;
|
|
13941
|
+
}, usedValues, getCode);
|
|
13942
|
+
}
|
|
13943
|
+
_reduceValues(values, valueCode, usedValues = {}, getCode) {
|
|
13944
|
+
let code = code_1.nil;
|
|
13945
|
+
for (const prefix in values) {
|
|
13946
|
+
const vs = values[prefix];
|
|
13947
|
+
if (!vs)
|
|
13948
|
+
continue;
|
|
13949
|
+
const nameSet = (usedValues[prefix] = usedValues[prefix] || new Map());
|
|
13950
|
+
vs.forEach((name) => {
|
|
13951
|
+
if (nameSet.has(name))
|
|
13952
|
+
return;
|
|
13953
|
+
nameSet.set(name, UsedValueState.Started);
|
|
13954
|
+
let c = valueCode(name);
|
|
13955
|
+
if (c) {
|
|
13956
|
+
const def = this.opts.es5 ? exports$1.varKinds.var : exports$1.varKinds.const;
|
|
13957
|
+
code = (0, code_1._) `${code}${def} ${name} = ${c};${this.opts._n}`;
|
|
13958
|
+
}
|
|
13959
|
+
else if ((c = getCode === null || getCode === void 0 ? void 0 : getCode(name))) {
|
|
13960
|
+
code = (0, code_1._) `${code}${c}${this.opts._n}`;
|
|
13961
|
+
}
|
|
13962
|
+
else {
|
|
13963
|
+
throw new ValueError(name);
|
|
13964
|
+
}
|
|
13965
|
+
nameSet.set(name, UsedValueState.Completed);
|
|
13966
|
+
});
|
|
13967
|
+
}
|
|
13968
|
+
return code;
|
|
13969
|
+
}
|
|
13970
|
+
}
|
|
13971
|
+
exports$1.ValueScope = ValueScope;
|
|
13972
|
+
|
|
13973
|
+
} (scope));
|
|
13974
|
+
return scope;
|
|
13975
|
+
}
|
|
13976
|
+
|
|
13977
|
+
var hasRequiredCodegen;
|
|
13978
|
+
|
|
13979
|
+
function requireCodegen () {
|
|
13980
|
+
if (hasRequiredCodegen) return codegen;
|
|
13981
|
+
hasRequiredCodegen = 1;
|
|
13982
|
+
(function (exports$1) {
|
|
13983
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
13984
|
+
exports$1.or = exports$1.and = exports$1.not = exports$1.CodeGen = exports$1.operators = exports$1.varKinds = exports$1.ValueScopeName = exports$1.ValueScope = exports$1.Scope = exports$1.Name = exports$1.regexpCode = exports$1.stringify = exports$1.getProperty = exports$1.nil = exports$1.strConcat = exports$1.str = exports$1._ = void 0;
|
|
13985
|
+
const code_1 = requireCode$1();
|
|
13986
|
+
const scope_1 = requireScope();
|
|
13987
|
+
var code_2 = requireCode$1();
|
|
13988
|
+
Object.defineProperty(exports$1, "_", { enumerable: true, get: function () { return code_2._; } });
|
|
13989
|
+
Object.defineProperty(exports$1, "str", { enumerable: true, get: function () { return code_2.str; } });
|
|
13990
|
+
Object.defineProperty(exports$1, "strConcat", { enumerable: true, get: function () { return code_2.strConcat; } });
|
|
13991
|
+
Object.defineProperty(exports$1, "nil", { enumerable: true, get: function () { return code_2.nil; } });
|
|
13992
|
+
Object.defineProperty(exports$1, "getProperty", { enumerable: true, get: function () { return code_2.getProperty; } });
|
|
13993
|
+
Object.defineProperty(exports$1, "stringify", { enumerable: true, get: function () { return code_2.stringify; } });
|
|
13994
|
+
Object.defineProperty(exports$1, "regexpCode", { enumerable: true, get: function () { return code_2.regexpCode; } });
|
|
13995
|
+
Object.defineProperty(exports$1, "Name", { enumerable: true, get: function () { return code_2.Name; } });
|
|
13996
|
+
var scope_2 = requireScope();
|
|
13997
|
+
Object.defineProperty(exports$1, "Scope", { enumerable: true, get: function () { return scope_2.Scope; } });
|
|
13998
|
+
Object.defineProperty(exports$1, "ValueScope", { enumerable: true, get: function () { return scope_2.ValueScope; } });
|
|
13999
|
+
Object.defineProperty(exports$1, "ValueScopeName", { enumerable: true, get: function () { return scope_2.ValueScopeName; } });
|
|
14000
|
+
Object.defineProperty(exports$1, "varKinds", { enumerable: true, get: function () { return scope_2.varKinds; } });
|
|
14001
|
+
exports$1.operators = {
|
|
14002
|
+
GT: new code_1._Code(">"),
|
|
14003
|
+
GTE: new code_1._Code(">="),
|
|
14004
|
+
LT: new code_1._Code("<"),
|
|
14005
|
+
LTE: new code_1._Code("<="),
|
|
14006
|
+
EQ: new code_1._Code("==="),
|
|
14007
|
+
NEQ: new code_1._Code("!=="),
|
|
14008
|
+
NOT: new code_1._Code("!"),
|
|
14009
|
+
OR: new code_1._Code("||"),
|
|
14010
|
+
AND: new code_1._Code("&&"),
|
|
14011
|
+
ADD: new code_1._Code("+"),
|
|
14012
|
+
};
|
|
14013
|
+
class Node {
|
|
14014
|
+
optimizeNodes() {
|
|
14015
|
+
return this;
|
|
14016
|
+
}
|
|
14017
|
+
optimizeNames(_names, _constants) {
|
|
14018
|
+
return this;
|
|
14019
|
+
}
|
|
14020
|
+
}
|
|
14021
|
+
class Def extends Node {
|
|
14022
|
+
constructor(varKind, name, rhs) {
|
|
14023
|
+
super();
|
|
14024
|
+
this.varKind = varKind;
|
|
14025
|
+
this.name = name;
|
|
14026
|
+
this.rhs = rhs;
|
|
14027
|
+
}
|
|
14028
|
+
render({ es5, _n }) {
|
|
14029
|
+
const varKind = es5 ? scope_1.varKinds.var : this.varKind;
|
|
14030
|
+
const rhs = this.rhs === undefined ? "" : ` = ${this.rhs}`;
|
|
14031
|
+
return `${varKind} ${this.name}${rhs};` + _n;
|
|
14032
|
+
}
|
|
14033
|
+
optimizeNames(names, constants) {
|
|
14034
|
+
if (!names[this.name.str])
|
|
14035
|
+
return;
|
|
14036
|
+
if (this.rhs)
|
|
14037
|
+
this.rhs = optimizeExpr(this.rhs, names, constants);
|
|
14038
|
+
return this;
|
|
14039
|
+
}
|
|
14040
|
+
get names() {
|
|
14041
|
+
return this.rhs instanceof code_1._CodeOrName ? this.rhs.names : {};
|
|
14042
|
+
}
|
|
14043
|
+
}
|
|
14044
|
+
class Assign extends Node {
|
|
14045
|
+
constructor(lhs, rhs, sideEffects) {
|
|
14046
|
+
super();
|
|
14047
|
+
this.lhs = lhs;
|
|
14048
|
+
this.rhs = rhs;
|
|
14049
|
+
this.sideEffects = sideEffects;
|
|
14050
|
+
}
|
|
14051
|
+
render({ _n }) {
|
|
14052
|
+
return `${this.lhs} = ${this.rhs};` + _n;
|
|
14053
|
+
}
|
|
14054
|
+
optimizeNames(names, constants) {
|
|
14055
|
+
if (this.lhs instanceof code_1.Name && !names[this.lhs.str] && !this.sideEffects)
|
|
14056
|
+
return;
|
|
14057
|
+
this.rhs = optimizeExpr(this.rhs, names, constants);
|
|
14058
|
+
return this;
|
|
14059
|
+
}
|
|
14060
|
+
get names() {
|
|
14061
|
+
const names = this.lhs instanceof code_1.Name ? {} : { ...this.lhs.names };
|
|
14062
|
+
return addExprNames(names, this.rhs);
|
|
14063
|
+
}
|
|
14064
|
+
}
|
|
14065
|
+
class AssignOp extends Assign {
|
|
14066
|
+
constructor(lhs, op, rhs, sideEffects) {
|
|
14067
|
+
super(lhs, rhs, sideEffects);
|
|
14068
|
+
this.op = op;
|
|
14069
|
+
}
|
|
14070
|
+
render({ _n }) {
|
|
14071
|
+
return `${this.lhs} ${this.op}= ${this.rhs};` + _n;
|
|
14072
|
+
}
|
|
14073
|
+
}
|
|
14074
|
+
class Label extends Node {
|
|
14075
|
+
constructor(label) {
|
|
14076
|
+
super();
|
|
14077
|
+
this.label = label;
|
|
14078
|
+
this.names = {};
|
|
14079
|
+
}
|
|
14080
|
+
render({ _n }) {
|
|
14081
|
+
return `${this.label}:` + _n;
|
|
14082
|
+
}
|
|
14083
|
+
}
|
|
14084
|
+
class Break extends Node {
|
|
14085
|
+
constructor(label) {
|
|
14086
|
+
super();
|
|
14087
|
+
this.label = label;
|
|
14088
|
+
this.names = {};
|
|
14089
|
+
}
|
|
14090
|
+
render({ _n }) {
|
|
14091
|
+
const label = this.label ? ` ${this.label}` : "";
|
|
14092
|
+
return `break${label};` + _n;
|
|
14093
|
+
}
|
|
14094
|
+
}
|
|
14095
|
+
class Throw extends Node {
|
|
14096
|
+
constructor(error) {
|
|
14097
|
+
super();
|
|
14098
|
+
this.error = error;
|
|
14099
|
+
}
|
|
14100
|
+
render({ _n }) {
|
|
14101
|
+
return `throw ${this.error};` + _n;
|
|
14102
|
+
}
|
|
14103
|
+
get names() {
|
|
14104
|
+
return this.error.names;
|
|
14105
|
+
}
|
|
14106
|
+
}
|
|
14107
|
+
class AnyCode extends Node {
|
|
14108
|
+
constructor(code) {
|
|
14109
|
+
super();
|
|
14110
|
+
this.code = code;
|
|
14111
|
+
}
|
|
14112
|
+
render({ _n }) {
|
|
14113
|
+
return `${this.code};` + _n;
|
|
14114
|
+
}
|
|
14115
|
+
optimizeNodes() {
|
|
14116
|
+
return `${this.code}` ? this : undefined;
|
|
14117
|
+
}
|
|
14118
|
+
optimizeNames(names, constants) {
|
|
14119
|
+
this.code = optimizeExpr(this.code, names, constants);
|
|
14120
|
+
return this;
|
|
14121
|
+
}
|
|
14122
|
+
get names() {
|
|
14123
|
+
return this.code instanceof code_1._CodeOrName ? this.code.names : {};
|
|
14124
|
+
}
|
|
14125
|
+
}
|
|
14126
|
+
class ParentNode extends Node {
|
|
14127
|
+
constructor(nodes = []) {
|
|
14128
|
+
super();
|
|
14129
|
+
this.nodes = nodes;
|
|
14130
|
+
}
|
|
14131
|
+
render(opts) {
|
|
14132
|
+
return this.nodes.reduce((code, n) => code + n.render(opts), "");
|
|
14133
|
+
}
|
|
14134
|
+
optimizeNodes() {
|
|
14135
|
+
const { nodes } = this;
|
|
14136
|
+
let i = nodes.length;
|
|
14137
|
+
while (i--) {
|
|
14138
|
+
const n = nodes[i].optimizeNodes();
|
|
14139
|
+
if (Array.isArray(n))
|
|
14140
|
+
nodes.splice(i, 1, ...n);
|
|
14141
|
+
else if (n)
|
|
14142
|
+
nodes[i] = n;
|
|
14143
|
+
else
|
|
14144
|
+
nodes.splice(i, 1);
|
|
14145
|
+
}
|
|
14146
|
+
return nodes.length > 0 ? this : undefined;
|
|
14147
|
+
}
|
|
14148
|
+
optimizeNames(names, constants) {
|
|
14149
|
+
const { nodes } = this;
|
|
14150
|
+
let i = nodes.length;
|
|
14151
|
+
while (i--) {
|
|
14152
|
+
// iterating backwards improves 1-pass optimization
|
|
14153
|
+
const n = nodes[i];
|
|
14154
|
+
if (n.optimizeNames(names, constants))
|
|
14155
|
+
continue;
|
|
14156
|
+
subtractNames(names, n.names);
|
|
14157
|
+
nodes.splice(i, 1);
|
|
14158
|
+
}
|
|
14159
|
+
return nodes.length > 0 ? this : undefined;
|
|
14160
|
+
}
|
|
14161
|
+
get names() {
|
|
14162
|
+
return this.nodes.reduce((names, n) => addNames(names, n.names), {});
|
|
14163
|
+
}
|
|
14164
|
+
}
|
|
14165
|
+
class BlockNode extends ParentNode {
|
|
14166
|
+
render(opts) {
|
|
14167
|
+
return "{" + opts._n + super.render(opts) + "}" + opts._n;
|
|
14168
|
+
}
|
|
14169
|
+
}
|
|
14170
|
+
class Root extends ParentNode {
|
|
14171
|
+
}
|
|
14172
|
+
class Else extends BlockNode {
|
|
14173
|
+
}
|
|
14174
|
+
Else.kind = "else";
|
|
14175
|
+
class If extends BlockNode {
|
|
14176
|
+
constructor(condition, nodes) {
|
|
14177
|
+
super(nodes);
|
|
14178
|
+
this.condition = condition;
|
|
14179
|
+
}
|
|
14180
|
+
render(opts) {
|
|
14181
|
+
let code = `if(${this.condition})` + super.render(opts);
|
|
14182
|
+
if (this.else)
|
|
14183
|
+
code += "else " + this.else.render(opts);
|
|
14184
|
+
return code;
|
|
14185
|
+
}
|
|
14186
|
+
optimizeNodes() {
|
|
14187
|
+
super.optimizeNodes();
|
|
14188
|
+
const cond = this.condition;
|
|
14189
|
+
if (cond === true)
|
|
14190
|
+
return this.nodes; // else is ignored here
|
|
14191
|
+
let e = this.else;
|
|
14192
|
+
if (e) {
|
|
14193
|
+
const ns = e.optimizeNodes();
|
|
14194
|
+
e = this.else = Array.isArray(ns) ? new Else(ns) : ns;
|
|
14195
|
+
}
|
|
14196
|
+
if (e) {
|
|
14197
|
+
if (cond === false)
|
|
14198
|
+
return e instanceof If ? e : e.nodes;
|
|
14199
|
+
if (this.nodes.length)
|
|
14200
|
+
return this;
|
|
14201
|
+
return new If(not(cond), e instanceof If ? [e] : e.nodes);
|
|
14202
|
+
}
|
|
14203
|
+
if (cond === false || !this.nodes.length)
|
|
14204
|
+
return undefined;
|
|
14205
|
+
return this;
|
|
14206
|
+
}
|
|
14207
|
+
optimizeNames(names, constants) {
|
|
14208
|
+
var _a;
|
|
14209
|
+
this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants);
|
|
14210
|
+
if (!(super.optimizeNames(names, constants) || this.else))
|
|
14211
|
+
return;
|
|
14212
|
+
this.condition = optimizeExpr(this.condition, names, constants);
|
|
14213
|
+
return this;
|
|
14214
|
+
}
|
|
14215
|
+
get names() {
|
|
14216
|
+
const names = super.names;
|
|
14217
|
+
addExprNames(names, this.condition);
|
|
14218
|
+
if (this.else)
|
|
14219
|
+
addNames(names, this.else.names);
|
|
14220
|
+
return names;
|
|
14221
|
+
}
|
|
14222
|
+
}
|
|
14223
|
+
If.kind = "if";
|
|
14224
|
+
class For extends BlockNode {
|
|
14225
|
+
}
|
|
14226
|
+
For.kind = "for";
|
|
14227
|
+
class ForLoop extends For {
|
|
14228
|
+
constructor(iteration) {
|
|
14229
|
+
super();
|
|
14230
|
+
this.iteration = iteration;
|
|
14231
|
+
}
|
|
14232
|
+
render(opts) {
|
|
14233
|
+
return `for(${this.iteration})` + super.render(opts);
|
|
14234
|
+
}
|
|
14235
|
+
optimizeNames(names, constants) {
|
|
14236
|
+
if (!super.optimizeNames(names, constants))
|
|
14237
|
+
return;
|
|
14238
|
+
this.iteration = optimizeExpr(this.iteration, names, constants);
|
|
14239
|
+
return this;
|
|
14240
|
+
}
|
|
14241
|
+
get names() {
|
|
14242
|
+
return addNames(super.names, this.iteration.names);
|
|
14243
|
+
}
|
|
14244
|
+
}
|
|
14245
|
+
class ForRange extends For {
|
|
14246
|
+
constructor(varKind, name, from, to) {
|
|
14247
|
+
super();
|
|
14248
|
+
this.varKind = varKind;
|
|
14249
|
+
this.name = name;
|
|
14250
|
+
this.from = from;
|
|
14251
|
+
this.to = to;
|
|
14252
|
+
}
|
|
14253
|
+
render(opts) {
|
|
14254
|
+
const varKind = opts.es5 ? scope_1.varKinds.var : this.varKind;
|
|
14255
|
+
const { name, from, to } = this;
|
|
14256
|
+
return `for(${varKind} ${name}=${from}; ${name}<${to}; ${name}++)` + super.render(opts);
|
|
14257
|
+
}
|
|
14258
|
+
get names() {
|
|
14259
|
+
const names = addExprNames(super.names, this.from);
|
|
14260
|
+
return addExprNames(names, this.to);
|
|
14261
|
+
}
|
|
14262
|
+
}
|
|
14263
|
+
class ForIter extends For {
|
|
14264
|
+
constructor(loop, varKind, name, iterable) {
|
|
14265
|
+
super();
|
|
14266
|
+
this.loop = loop;
|
|
14267
|
+
this.varKind = varKind;
|
|
14268
|
+
this.name = name;
|
|
14269
|
+
this.iterable = iterable;
|
|
14270
|
+
}
|
|
14271
|
+
render(opts) {
|
|
14272
|
+
return `for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})` + super.render(opts);
|
|
14273
|
+
}
|
|
14274
|
+
optimizeNames(names, constants) {
|
|
14275
|
+
if (!super.optimizeNames(names, constants))
|
|
14276
|
+
return;
|
|
14277
|
+
this.iterable = optimizeExpr(this.iterable, names, constants);
|
|
14278
|
+
return this;
|
|
14279
|
+
}
|
|
14280
|
+
get names() {
|
|
14281
|
+
return addNames(super.names, this.iterable.names);
|
|
14282
|
+
}
|
|
14283
|
+
}
|
|
14284
|
+
class Func extends BlockNode {
|
|
14285
|
+
constructor(name, args, async) {
|
|
14286
|
+
super();
|
|
14287
|
+
this.name = name;
|
|
14288
|
+
this.args = args;
|
|
14289
|
+
this.async = async;
|
|
14290
|
+
}
|
|
14291
|
+
render(opts) {
|
|
14292
|
+
const _async = this.async ? "async " : "";
|
|
14293
|
+
return `${_async}function ${this.name}(${this.args})` + super.render(opts);
|
|
14294
|
+
}
|
|
14295
|
+
}
|
|
14296
|
+
Func.kind = "func";
|
|
14297
|
+
class Return extends ParentNode {
|
|
14298
|
+
render(opts) {
|
|
14299
|
+
return "return " + super.render(opts);
|
|
14300
|
+
}
|
|
14301
|
+
}
|
|
14302
|
+
Return.kind = "return";
|
|
14303
|
+
class Try extends BlockNode {
|
|
14304
|
+
render(opts) {
|
|
14305
|
+
let code = "try" + super.render(opts);
|
|
14306
|
+
if (this.catch)
|
|
14307
|
+
code += this.catch.render(opts);
|
|
14308
|
+
if (this.finally)
|
|
14309
|
+
code += this.finally.render(opts);
|
|
14310
|
+
return code;
|
|
14311
|
+
}
|
|
14312
|
+
optimizeNodes() {
|
|
14313
|
+
var _a, _b;
|
|
14314
|
+
super.optimizeNodes();
|
|
14315
|
+
(_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNodes();
|
|
14316
|
+
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNodes();
|
|
14317
|
+
return this;
|
|
14318
|
+
}
|
|
14319
|
+
optimizeNames(names, constants) {
|
|
14320
|
+
var _a, _b;
|
|
14321
|
+
super.optimizeNames(names, constants);
|
|
14322
|
+
(_a = this.catch) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants);
|
|
14323
|
+
(_b = this.finally) === null || _b === void 0 ? void 0 : _b.optimizeNames(names, constants);
|
|
14324
|
+
return this;
|
|
14325
|
+
}
|
|
14326
|
+
get names() {
|
|
14327
|
+
const names = super.names;
|
|
14328
|
+
if (this.catch)
|
|
14329
|
+
addNames(names, this.catch.names);
|
|
14330
|
+
if (this.finally)
|
|
14331
|
+
addNames(names, this.finally.names);
|
|
14332
|
+
return names;
|
|
14333
|
+
}
|
|
14334
|
+
}
|
|
14335
|
+
class Catch extends BlockNode {
|
|
14336
|
+
constructor(error) {
|
|
14337
|
+
super();
|
|
14338
|
+
this.error = error;
|
|
14339
|
+
}
|
|
14340
|
+
render(opts) {
|
|
14341
|
+
return `catch(${this.error})` + super.render(opts);
|
|
14342
|
+
}
|
|
14343
|
+
}
|
|
14344
|
+
Catch.kind = "catch";
|
|
14345
|
+
class Finally extends BlockNode {
|
|
14346
|
+
render(opts) {
|
|
14347
|
+
return "finally" + super.render(opts);
|
|
14348
|
+
}
|
|
14349
|
+
}
|
|
14350
|
+
Finally.kind = "finally";
|
|
14351
|
+
class CodeGen {
|
|
14352
|
+
constructor(extScope, opts = {}) {
|
|
14353
|
+
this._values = {};
|
|
14354
|
+
this._blockStarts = [];
|
|
14355
|
+
this._constants = {};
|
|
14356
|
+
this.opts = { ...opts, _n: opts.lines ? "\n" : "" };
|
|
14357
|
+
this._extScope = extScope;
|
|
14358
|
+
this._scope = new scope_1.Scope({ parent: extScope });
|
|
14359
|
+
this._nodes = [new Root()];
|
|
14360
|
+
}
|
|
14361
|
+
toString() {
|
|
14362
|
+
return this._root.render(this.opts);
|
|
14363
|
+
}
|
|
14364
|
+
// returns unique name in the internal scope
|
|
14365
|
+
name(prefix) {
|
|
14366
|
+
return this._scope.name(prefix);
|
|
14367
|
+
}
|
|
14368
|
+
// reserves unique name in the external scope
|
|
14369
|
+
scopeName(prefix) {
|
|
14370
|
+
return this._extScope.name(prefix);
|
|
14371
|
+
}
|
|
14372
|
+
// reserves unique name in the external scope and assigns value to it
|
|
14373
|
+
scopeValue(prefixOrName, value) {
|
|
14374
|
+
const name = this._extScope.value(prefixOrName, value);
|
|
14375
|
+
const vs = this._values[name.prefix] || (this._values[name.prefix] = new Set());
|
|
14376
|
+
vs.add(name);
|
|
14377
|
+
return name;
|
|
14378
|
+
}
|
|
14379
|
+
getScopeValue(prefix, keyOrRef) {
|
|
14380
|
+
return this._extScope.getValue(prefix, keyOrRef);
|
|
14381
|
+
}
|
|
14382
|
+
// return code that assigns values in the external scope to the names that are used internally
|
|
14383
|
+
// (same names that were returned by gen.scopeName or gen.scopeValue)
|
|
14384
|
+
scopeRefs(scopeName) {
|
|
14385
|
+
return this._extScope.scopeRefs(scopeName, this._values);
|
|
14386
|
+
}
|
|
14387
|
+
scopeCode() {
|
|
14388
|
+
return this._extScope.scopeCode(this._values);
|
|
14389
|
+
}
|
|
14390
|
+
_def(varKind, nameOrPrefix, rhs, constant) {
|
|
14391
|
+
const name = this._scope.toName(nameOrPrefix);
|
|
14392
|
+
if (rhs !== undefined && constant)
|
|
14393
|
+
this._constants[name.str] = rhs;
|
|
14394
|
+
this._leafNode(new Def(varKind, name, rhs));
|
|
14395
|
+
return name;
|
|
14396
|
+
}
|
|
14397
|
+
// `const` declaration (`var` in es5 mode)
|
|
14398
|
+
const(nameOrPrefix, rhs, _constant) {
|
|
14399
|
+
return this._def(scope_1.varKinds.const, nameOrPrefix, rhs, _constant);
|
|
14400
|
+
}
|
|
14401
|
+
// `let` declaration with optional assignment (`var` in es5 mode)
|
|
14402
|
+
let(nameOrPrefix, rhs, _constant) {
|
|
14403
|
+
return this._def(scope_1.varKinds.let, nameOrPrefix, rhs, _constant);
|
|
14404
|
+
}
|
|
14405
|
+
// `var` declaration with optional assignment
|
|
14406
|
+
var(nameOrPrefix, rhs, _constant) {
|
|
14407
|
+
return this._def(scope_1.varKinds.var, nameOrPrefix, rhs, _constant);
|
|
14408
|
+
}
|
|
14409
|
+
// assignment code
|
|
14410
|
+
assign(lhs, rhs, sideEffects) {
|
|
14411
|
+
return this._leafNode(new Assign(lhs, rhs, sideEffects));
|
|
14412
|
+
}
|
|
14413
|
+
// `+=` code
|
|
14414
|
+
add(lhs, rhs) {
|
|
14415
|
+
return this._leafNode(new AssignOp(lhs, exports$1.operators.ADD, rhs));
|
|
14416
|
+
}
|
|
14417
|
+
// appends passed SafeExpr to code or executes Block
|
|
14418
|
+
code(c) {
|
|
14419
|
+
if (typeof c == "function")
|
|
14420
|
+
c();
|
|
14421
|
+
else if (c !== code_1.nil)
|
|
14422
|
+
this._leafNode(new AnyCode(c));
|
|
14423
|
+
return this;
|
|
14424
|
+
}
|
|
14425
|
+
// returns code for object literal for the passed argument list of key-value pairs
|
|
14426
|
+
object(...keyValues) {
|
|
14427
|
+
const code = ["{"];
|
|
14428
|
+
for (const [key, value] of keyValues) {
|
|
14429
|
+
if (code.length > 1)
|
|
14430
|
+
code.push(",");
|
|
14431
|
+
code.push(key);
|
|
14432
|
+
if (key !== value || this.opts.es5) {
|
|
14433
|
+
code.push(":");
|
|
14434
|
+
(0, code_1.addCodeArg)(code, value);
|
|
14435
|
+
}
|
|
14436
|
+
}
|
|
14437
|
+
code.push("}");
|
|
14438
|
+
return new code_1._Code(code);
|
|
14439
|
+
}
|
|
14440
|
+
// `if` clause (or statement if `thenBody` and, optionally, `elseBody` are passed)
|
|
14441
|
+
if(condition, thenBody, elseBody) {
|
|
14442
|
+
this._blockNode(new If(condition));
|
|
14443
|
+
if (thenBody && elseBody) {
|
|
14444
|
+
this.code(thenBody).else().code(elseBody).endIf();
|
|
14445
|
+
}
|
|
14446
|
+
else if (thenBody) {
|
|
14447
|
+
this.code(thenBody).endIf();
|
|
14448
|
+
}
|
|
14449
|
+
else if (elseBody) {
|
|
14450
|
+
throw new Error('CodeGen: "else" body without "then" body');
|
|
14451
|
+
}
|
|
14452
|
+
return this;
|
|
14453
|
+
}
|
|
14454
|
+
// `else if` clause - invalid without `if` or after `else` clauses
|
|
14455
|
+
elseIf(condition) {
|
|
14456
|
+
return this._elseNode(new If(condition));
|
|
14457
|
+
}
|
|
14458
|
+
// `else` clause - only valid after `if` or `else if` clauses
|
|
14459
|
+
else() {
|
|
14460
|
+
return this._elseNode(new Else());
|
|
14461
|
+
}
|
|
14462
|
+
// end `if` statement (needed if gen.if was used only with condition)
|
|
14463
|
+
endIf() {
|
|
14464
|
+
return this._endBlockNode(If, Else);
|
|
14465
|
+
}
|
|
14466
|
+
_for(node, forBody) {
|
|
14467
|
+
this._blockNode(node);
|
|
14468
|
+
if (forBody)
|
|
14469
|
+
this.code(forBody).endFor();
|
|
14470
|
+
return this;
|
|
14471
|
+
}
|
|
14472
|
+
// a generic `for` clause (or statement if `forBody` is passed)
|
|
14473
|
+
for(iteration, forBody) {
|
|
14474
|
+
return this._for(new ForLoop(iteration), forBody);
|
|
14475
|
+
}
|
|
14476
|
+
// `for` statement for a range of values
|
|
14477
|
+
forRange(nameOrPrefix, from, to, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.let) {
|
|
14478
|
+
const name = this._scope.toName(nameOrPrefix);
|
|
14479
|
+
return this._for(new ForRange(varKind, name, from, to), () => forBody(name));
|
|
14480
|
+
}
|
|
14481
|
+
// `for-of` statement (in es5 mode replace with a normal for loop)
|
|
14482
|
+
forOf(nameOrPrefix, iterable, forBody, varKind = scope_1.varKinds.const) {
|
|
14483
|
+
const name = this._scope.toName(nameOrPrefix);
|
|
14484
|
+
if (this.opts.es5) {
|
|
14485
|
+
const arr = iterable instanceof code_1.Name ? iterable : this.var("_arr", iterable);
|
|
14486
|
+
return this.forRange("_i", 0, (0, code_1._) `${arr}.length`, (i) => {
|
|
14487
|
+
this.var(name, (0, code_1._) `${arr}[${i}]`);
|
|
14488
|
+
forBody(name);
|
|
14489
|
+
});
|
|
14490
|
+
}
|
|
14491
|
+
return this._for(new ForIter("of", varKind, name, iterable), () => forBody(name));
|
|
14492
|
+
}
|
|
14493
|
+
// `for-in` statement.
|
|
14494
|
+
// With option `ownProperties` replaced with a `for-of` loop for object keys
|
|
14495
|
+
forIn(nameOrPrefix, obj, forBody, varKind = this.opts.es5 ? scope_1.varKinds.var : scope_1.varKinds.const) {
|
|
14496
|
+
if (this.opts.ownProperties) {
|
|
14497
|
+
return this.forOf(nameOrPrefix, (0, code_1._) `Object.keys(${obj})`, forBody);
|
|
14498
|
+
}
|
|
14499
|
+
const name = this._scope.toName(nameOrPrefix);
|
|
14500
|
+
return this._for(new ForIter("in", varKind, name, obj), () => forBody(name));
|
|
14501
|
+
}
|
|
14502
|
+
// end `for` loop
|
|
14503
|
+
endFor() {
|
|
14504
|
+
return this._endBlockNode(For);
|
|
14505
|
+
}
|
|
14506
|
+
// `label` statement
|
|
14507
|
+
label(label) {
|
|
14508
|
+
return this._leafNode(new Label(label));
|
|
14509
|
+
}
|
|
14510
|
+
// `break` statement
|
|
14511
|
+
break(label) {
|
|
14512
|
+
return this._leafNode(new Break(label));
|
|
14513
|
+
}
|
|
14514
|
+
// `return` statement
|
|
14515
|
+
return(value) {
|
|
14516
|
+
const node = new Return();
|
|
14517
|
+
this._blockNode(node);
|
|
14518
|
+
this.code(value);
|
|
14519
|
+
if (node.nodes.length !== 1)
|
|
14520
|
+
throw new Error('CodeGen: "return" should have one node');
|
|
14521
|
+
return this._endBlockNode(Return);
|
|
14522
|
+
}
|
|
14523
|
+
// `try` statement
|
|
14524
|
+
try(tryBody, catchCode, finallyCode) {
|
|
14525
|
+
if (!catchCode && !finallyCode)
|
|
14526
|
+
throw new Error('CodeGen: "try" without "catch" and "finally"');
|
|
14527
|
+
const node = new Try();
|
|
14528
|
+
this._blockNode(node);
|
|
14529
|
+
this.code(tryBody);
|
|
14530
|
+
if (catchCode) {
|
|
14531
|
+
const error = this.name("e");
|
|
14532
|
+
this._currNode = node.catch = new Catch(error);
|
|
14533
|
+
catchCode(error);
|
|
14534
|
+
}
|
|
14535
|
+
if (finallyCode) {
|
|
14536
|
+
this._currNode = node.finally = new Finally();
|
|
14537
|
+
this.code(finallyCode);
|
|
14538
|
+
}
|
|
14539
|
+
return this._endBlockNode(Catch, Finally);
|
|
14540
|
+
}
|
|
14541
|
+
// `throw` statement
|
|
14542
|
+
throw(error) {
|
|
14543
|
+
return this._leafNode(new Throw(error));
|
|
14544
|
+
}
|
|
14545
|
+
// start self-balancing block
|
|
14546
|
+
block(body, nodeCount) {
|
|
14547
|
+
this._blockStarts.push(this._nodes.length);
|
|
14548
|
+
if (body)
|
|
14549
|
+
this.code(body).endBlock(nodeCount);
|
|
14550
|
+
return this;
|
|
14551
|
+
}
|
|
14552
|
+
// end the current self-balancing block
|
|
14553
|
+
endBlock(nodeCount) {
|
|
14554
|
+
const len = this._blockStarts.pop();
|
|
14555
|
+
if (len === undefined)
|
|
14556
|
+
throw new Error("CodeGen: not in self-balancing block");
|
|
14557
|
+
const toClose = this._nodes.length - len;
|
|
14558
|
+
if (toClose < 0 || (nodeCount !== undefined && toClose !== nodeCount)) {
|
|
14559
|
+
throw new Error(`CodeGen: wrong number of nodes: ${toClose} vs ${nodeCount} expected`);
|
|
14560
|
+
}
|
|
14561
|
+
this._nodes.length = len;
|
|
14562
|
+
return this;
|
|
14563
|
+
}
|
|
14564
|
+
// `function` heading (or definition if funcBody is passed)
|
|
14565
|
+
func(name, args = code_1.nil, async, funcBody) {
|
|
14566
|
+
this._blockNode(new Func(name, args, async));
|
|
14567
|
+
if (funcBody)
|
|
14568
|
+
this.code(funcBody).endFunc();
|
|
14569
|
+
return this;
|
|
14570
|
+
}
|
|
14571
|
+
// end function definition
|
|
14572
|
+
endFunc() {
|
|
14573
|
+
return this._endBlockNode(Func);
|
|
14574
|
+
}
|
|
14575
|
+
optimize(n = 1) {
|
|
14576
|
+
while (n-- > 0) {
|
|
14577
|
+
this._root.optimizeNodes();
|
|
14578
|
+
this._root.optimizeNames(this._root.names, this._constants);
|
|
14579
|
+
}
|
|
14580
|
+
}
|
|
14581
|
+
_leafNode(node) {
|
|
14582
|
+
this._currNode.nodes.push(node);
|
|
14583
|
+
return this;
|
|
14584
|
+
}
|
|
14585
|
+
_blockNode(node) {
|
|
14586
|
+
this._currNode.nodes.push(node);
|
|
14587
|
+
this._nodes.push(node);
|
|
14588
|
+
}
|
|
14589
|
+
_endBlockNode(N1, N2) {
|
|
14590
|
+
const n = this._currNode;
|
|
14591
|
+
if (n instanceof N1 || (N2 && n instanceof N2)) {
|
|
14592
|
+
this._nodes.pop();
|
|
14593
|
+
return this;
|
|
14594
|
+
}
|
|
14595
|
+
throw new Error(`CodeGen: not in block "${N2 ? `${N1.kind}/${N2.kind}` : N1.kind}"`);
|
|
14596
|
+
}
|
|
14597
|
+
_elseNode(node) {
|
|
14598
|
+
const n = this._currNode;
|
|
14599
|
+
if (!(n instanceof If)) {
|
|
14600
|
+
throw new Error('CodeGen: "else" without "if"');
|
|
14601
|
+
}
|
|
14602
|
+
this._currNode = n.else = node;
|
|
14603
|
+
return this;
|
|
14604
|
+
}
|
|
14605
|
+
get _root() {
|
|
14606
|
+
return this._nodes[0];
|
|
14607
|
+
}
|
|
14608
|
+
get _currNode() {
|
|
14609
|
+
const ns = this._nodes;
|
|
14610
|
+
return ns[ns.length - 1];
|
|
14611
|
+
}
|
|
14612
|
+
set _currNode(node) {
|
|
14613
|
+
const ns = this._nodes;
|
|
14614
|
+
ns[ns.length - 1] = node;
|
|
14615
|
+
}
|
|
14616
|
+
}
|
|
14617
|
+
exports$1.CodeGen = CodeGen;
|
|
14618
|
+
function addNames(names, from) {
|
|
14619
|
+
for (const n in from)
|
|
14620
|
+
names[n] = (names[n] || 0) + (from[n] || 0);
|
|
14621
|
+
return names;
|
|
14622
|
+
}
|
|
14623
|
+
function addExprNames(names, from) {
|
|
14624
|
+
return from instanceof code_1._CodeOrName ? addNames(names, from.names) : names;
|
|
14625
|
+
}
|
|
14626
|
+
function optimizeExpr(expr, names, constants) {
|
|
14627
|
+
if (expr instanceof code_1.Name)
|
|
14628
|
+
return replaceName(expr);
|
|
14629
|
+
if (!canOptimize(expr))
|
|
14630
|
+
return expr;
|
|
14631
|
+
return new code_1._Code(expr._items.reduce((items, c) => {
|
|
14632
|
+
if (c instanceof code_1.Name)
|
|
14633
|
+
c = replaceName(c);
|
|
14634
|
+
if (c instanceof code_1._Code)
|
|
14635
|
+
items.push(...c._items);
|
|
14636
|
+
else
|
|
14637
|
+
items.push(c);
|
|
14638
|
+
return items;
|
|
14639
|
+
}, []));
|
|
14640
|
+
function replaceName(n) {
|
|
14641
|
+
const c = constants[n.str];
|
|
14642
|
+
if (c === undefined || names[n.str] !== 1)
|
|
14643
|
+
return n;
|
|
14644
|
+
delete names[n.str];
|
|
14645
|
+
return c;
|
|
14646
|
+
}
|
|
14647
|
+
function canOptimize(e) {
|
|
14648
|
+
return (e instanceof code_1._Code &&
|
|
14649
|
+
e._items.some((c) => c instanceof code_1.Name && names[c.str] === 1 && constants[c.str] !== undefined));
|
|
14650
|
+
}
|
|
14651
|
+
}
|
|
14652
|
+
function subtractNames(names, from) {
|
|
14653
|
+
for (const n in from)
|
|
14654
|
+
names[n] = (names[n] || 0) - (from[n] || 0);
|
|
14655
|
+
}
|
|
14656
|
+
function not(x) {
|
|
14657
|
+
return typeof x == "boolean" || typeof x == "number" || x === null ? !x : (0, code_1._) `!${par(x)}`;
|
|
14658
|
+
}
|
|
14659
|
+
exports$1.not = not;
|
|
14660
|
+
const andCode = mappend(exports$1.operators.AND);
|
|
14661
|
+
// boolean AND (&&) expression with the passed arguments
|
|
14662
|
+
function and(...args) {
|
|
14663
|
+
return args.reduce(andCode);
|
|
14664
|
+
}
|
|
14665
|
+
exports$1.and = and;
|
|
14666
|
+
const orCode = mappend(exports$1.operators.OR);
|
|
14667
|
+
// boolean OR (||) expression with the passed arguments
|
|
14668
|
+
function or(...args) {
|
|
14669
|
+
return args.reduce(orCode);
|
|
14670
|
+
}
|
|
14671
|
+
exports$1.or = or;
|
|
14672
|
+
function mappend(op) {
|
|
14673
|
+
return (x, y) => (x === code_1.nil ? y : y === code_1.nil ? x : (0, code_1._) `${par(x)} ${op} ${par(y)}`);
|
|
14674
|
+
}
|
|
14675
|
+
function par(x) {
|
|
14676
|
+
return x instanceof code_1.Name ? x : (0, code_1._) `(${x})`;
|
|
14677
|
+
}
|
|
14678
|
+
|
|
14679
|
+
} (codegen));
|
|
14680
|
+
return codegen;
|
|
14681
|
+
}
|
|
14661
14682
|
|
|
14662
14683
|
var util = {};
|
|
14663
14684
|
|
|
14664
14685
|
Object.defineProperty(util, "__esModule", { value: true });
|
|
14665
14686
|
util.checkStrictMode = util.getErrorPath = util.Type = util.useFunc = util.setEvaluated = util.evaluatedPropsToName = util.mergeEvaluated = util.eachItem = util.unescapeJsonPointer = util.escapeJsonPointer = util.escapeFragment = util.unescapeFragment = util.schemaRefOrVal = util.schemaHasRulesButRef = util.schemaHasRules = util.checkUnknownRules = util.alwaysValidSchema = util.toHash = void 0;
|
|
14666
|
-
const codegen_1$o =
|
|
14667
|
-
const code_1$9 =
|
|
14687
|
+
const codegen_1$o = requireCodegen();
|
|
14688
|
+
const code_1$9 = requireCode$1();
|
|
14668
14689
|
// TODO refactor to use Set
|
|
14669
14690
|
function toHash(arr) {
|
|
14670
14691
|
const hash = {};
|
|
@@ -14846,7 +14867,7 @@ function requireNames () {
|
|
|
14846
14867
|
if (hasRequiredNames) return names;
|
|
14847
14868
|
hasRequiredNames = 1;
|
|
14848
14869
|
Object.defineProperty(names, "__esModule", { value: true });
|
|
14849
|
-
const codegen_1 =
|
|
14870
|
+
const codegen_1 = requireCodegen();
|
|
14850
14871
|
const names$1 = {
|
|
14851
14872
|
// validation function arguments
|
|
14852
14873
|
data: new codegen_1.Name("data"), // data passed to validation function
|
|
@@ -14883,7 +14904,7 @@ function requireErrors () {
|
|
|
14883
14904
|
(function (exports$1) {
|
|
14884
14905
|
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
14885
14906
|
exports$1.extendErrors = exports$1.resetErrorsCount = exports$1.reportExtraError = exports$1.reportError = exports$1.keyword$DataError = exports$1.keywordError = void 0;
|
|
14886
|
-
const codegen_1 =
|
|
14907
|
+
const codegen_1 = requireCodegen();
|
|
14887
14908
|
const util_1 = util;
|
|
14888
14909
|
const names_1 = requireNames();
|
|
14889
14910
|
exports$1.keywordError = {
|
|
@@ -15015,7 +15036,7 @@ function requireBoolSchema () {
|
|
|
15015
15036
|
Object.defineProperty(boolSchema, "__esModule", { value: true });
|
|
15016
15037
|
boolSchema.boolOrEmptySchema = boolSchema.topBoolOrEmptySchema = void 0;
|
|
15017
15038
|
const errors_1 = requireErrors();
|
|
15018
|
-
const codegen_1 =
|
|
15039
|
+
const codegen_1 = requireCodegen();
|
|
15019
15040
|
const names_1 = requireNames();
|
|
15020
15041
|
const boolError = {
|
|
15021
15042
|
message: "boolean schema is false",
|
|
@@ -15126,7 +15147,7 @@ dataType.reportTypeError = dataType.checkDataTypes = dataType.checkDataType = da
|
|
|
15126
15147
|
const rules_1 = rules;
|
|
15127
15148
|
const applicability_1 = requireApplicability();
|
|
15128
15149
|
const errors_1 = requireErrors();
|
|
15129
|
-
const codegen_1$n =
|
|
15150
|
+
const codegen_1$n = requireCodegen();
|
|
15130
15151
|
const util_1$m = util;
|
|
15131
15152
|
var DataType;
|
|
15132
15153
|
(function (DataType) {
|
|
@@ -15332,7 +15353,7 @@ function requireDefaults () {
|
|
|
15332
15353
|
hasRequiredDefaults = 1;
|
|
15333
15354
|
Object.defineProperty(defaults, "__esModule", { value: true });
|
|
15334
15355
|
defaults.assignDefaults = void 0;
|
|
15335
|
-
const codegen_1 =
|
|
15356
|
+
const codegen_1 = requireCodegen();
|
|
15336
15357
|
const util_1 = util;
|
|
15337
15358
|
function assignDefaults(it, ty) {
|
|
15338
15359
|
const { properties, items } = it.schema;
|
|
@@ -15378,7 +15399,7 @@ function requireCode () {
|
|
|
15378
15399
|
hasRequiredCode = 1;
|
|
15379
15400
|
Object.defineProperty(code, "__esModule", { value: true });
|
|
15380
15401
|
code.validateUnion = code.validateArray = code.usePattern = code.callValidateCode = code.schemaProperties = code.allSchemaProperties = code.noPropertyInData = code.propertyInData = code.isOwnProperty = code.hasPropFunc = code.reportMissingProp = code.checkMissingProp = code.checkReportMissingProp = void 0;
|
|
15381
|
-
const codegen_1 =
|
|
15402
|
+
const codegen_1 = requireCodegen();
|
|
15382
15403
|
const util_1 = util;
|
|
15383
15404
|
const names_1 = requireNames();
|
|
15384
15405
|
const util_2 = util;
|
|
@@ -15516,7 +15537,7 @@ function requireKeyword () {
|
|
|
15516
15537
|
hasRequiredKeyword = 1;
|
|
15517
15538
|
Object.defineProperty(keyword, "__esModule", { value: true });
|
|
15518
15539
|
keyword.validateKeywordUsage = keyword.validSchemaType = keyword.funcKeywordCode = keyword.macroKeywordCode = void 0;
|
|
15519
|
-
const codegen_1 =
|
|
15540
|
+
const codegen_1 = requireCodegen();
|
|
15520
15541
|
const names_1 = requireNames();
|
|
15521
15542
|
const code_1 = requireCode();
|
|
15522
15543
|
const errors_1 = requireErrors();
|
|
@@ -15649,7 +15670,7 @@ function requireSubschema () {
|
|
|
15649
15670
|
hasRequiredSubschema = 1;
|
|
15650
15671
|
Object.defineProperty(subschema, "__esModule", { value: true });
|
|
15651
15672
|
subschema.extendSubschemaMode = subschema.extendSubschemaData = subschema.getSubschema = void 0;
|
|
15652
|
-
const codegen_1 =
|
|
15673
|
+
const codegen_1 = requireCodegen();
|
|
15653
15674
|
const util_1 = util;
|
|
15654
15675
|
function getSubschema(it, { keyword, schemaProp, schema, schemaPath, errSchemaPath, topSchemaRef }) {
|
|
15655
15676
|
if (keyword !== undefined && schema !== undefined) {
|
|
@@ -16041,7 +16062,7 @@ function requireValidate () {
|
|
|
16041
16062
|
const defaults_1 = requireDefaults();
|
|
16042
16063
|
const keyword_1 = requireKeyword();
|
|
16043
16064
|
const subschema_1 = requireSubschema();
|
|
16044
|
-
const codegen_1 =
|
|
16065
|
+
const codegen_1 = requireCodegen();
|
|
16045
16066
|
const names_1 = requireNames();
|
|
16046
16067
|
const resolve_1 = resolve$2;
|
|
16047
16068
|
const util_1 = util;
|
|
@@ -16598,7 +16619,7 @@ var compile = {};
|
|
|
16598
16619
|
|
|
16599
16620
|
Object.defineProperty(compile, "__esModule", { value: true });
|
|
16600
16621
|
compile.resolveSchema = compile.getCompilingSchema = compile.resolveRef = compile.compileSchema = compile.SchemaEnv = void 0;
|
|
16601
|
-
const codegen_1$m =
|
|
16622
|
+
const codegen_1$m = requireCodegen();
|
|
16602
16623
|
const validation_error_1 = requireValidation_error();
|
|
16603
16624
|
const names_1$2 = requireNames();
|
|
16604
16625
|
const resolve_1 = resolve$2;
|
|
@@ -17644,7 +17665,7 @@ uri$1.default = uri;
|
|
|
17644
17665
|
exports$1.CodeGen = exports$1.Name = exports$1.nil = exports$1.stringify = exports$1.str = exports$1._ = exports$1.KeywordCxt = void 0;
|
|
17645
17666
|
var validate_1 = requireValidate();
|
|
17646
17667
|
Object.defineProperty(exports$1, "KeywordCxt", { enumerable: true, get: function () { return validate_1.KeywordCxt; } });
|
|
17647
|
-
var codegen_1 =
|
|
17668
|
+
var codegen_1 = requireCodegen();
|
|
17648
17669
|
Object.defineProperty(exports$1, "_", { enumerable: true, get: function () { return codegen_1._; } });
|
|
17649
17670
|
Object.defineProperty(exports$1, "str", { enumerable: true, get: function () { return codegen_1.str; } });
|
|
17650
17671
|
Object.defineProperty(exports$1, "stringify", { enumerable: true, get: function () { return codegen_1.stringify; } });
|
|
@@ -17655,7 +17676,7 @@ uri$1.default = uri;
|
|
|
17655
17676
|
const ref_error_1 = requireRef_error();
|
|
17656
17677
|
const rules_1 = rules;
|
|
17657
17678
|
const compile_1 = compile;
|
|
17658
|
-
const codegen_2 =
|
|
17679
|
+
const codegen_2 = requireCodegen();
|
|
17659
17680
|
const resolve_1 = resolve$2;
|
|
17660
17681
|
const dataType_1 = dataType;
|
|
17661
17682
|
const util_1 = util;
|
|
@@ -18280,7 +18301,7 @@ Object.defineProperty(ref, "__esModule", { value: true });
|
|
|
18280
18301
|
ref.callRef = ref.getValidate = void 0;
|
|
18281
18302
|
const ref_error_1$1 = requireRef_error();
|
|
18282
18303
|
const code_1$8 = requireCode();
|
|
18283
|
-
const codegen_1$l =
|
|
18304
|
+
const codegen_1$l = requireCodegen();
|
|
18284
18305
|
const names_1$1 = requireNames();
|
|
18285
18306
|
const compile_1$1 = compile;
|
|
18286
18307
|
const util_1$j = util;
|
|
@@ -18417,7 +18438,7 @@ var validation$1 = {};
|
|
|
18417
18438
|
var limitNumber = {};
|
|
18418
18439
|
|
|
18419
18440
|
Object.defineProperty(limitNumber, "__esModule", { value: true });
|
|
18420
|
-
const codegen_1$k =
|
|
18441
|
+
const codegen_1$k = requireCodegen();
|
|
18421
18442
|
const ops = codegen_1$k.operators;
|
|
18422
18443
|
const KWDs = {
|
|
18423
18444
|
maximum: { okStr: "<=", ok: ops.LTE, fail: ops.GT },
|
|
@@ -18445,7 +18466,7 @@ limitNumber.default = def$q;
|
|
|
18445
18466
|
var multipleOf = {};
|
|
18446
18467
|
|
|
18447
18468
|
Object.defineProperty(multipleOf, "__esModule", { value: true });
|
|
18448
|
-
const codegen_1$j =
|
|
18469
|
+
const codegen_1$j = requireCodegen();
|
|
18449
18470
|
const error$h = {
|
|
18450
18471
|
message: ({ schemaCode }) => (0, codegen_1$j.str) `must be multiple of ${schemaCode}`,
|
|
18451
18472
|
params: ({ schemaCode }) => (0, codegen_1$j._) `{multipleOf: ${schemaCode}}`,
|
|
@@ -18497,7 +18518,7 @@ ucs2length$1.default = ucs2length;
|
|
|
18497
18518
|
ucs2length.code = 'require("ajv/dist/runtime/ucs2length").default';
|
|
18498
18519
|
|
|
18499
18520
|
Object.defineProperty(limitLength, "__esModule", { value: true });
|
|
18500
|
-
const codegen_1$i =
|
|
18521
|
+
const codegen_1$i = requireCodegen();
|
|
18501
18522
|
const util_1$i = util;
|
|
18502
18523
|
const ucs2length_1 = ucs2length$1;
|
|
18503
18524
|
const error$g = {
|
|
@@ -18526,7 +18547,7 @@ var pattern = {};
|
|
|
18526
18547
|
|
|
18527
18548
|
Object.defineProperty(pattern, "__esModule", { value: true });
|
|
18528
18549
|
const code_1$7 = requireCode();
|
|
18529
|
-
const codegen_1$h =
|
|
18550
|
+
const codegen_1$h = requireCodegen();
|
|
18530
18551
|
const error$f = {
|
|
18531
18552
|
message: ({ schemaCode }) => (0, codegen_1$h.str) `must match pattern "${schemaCode}"`,
|
|
18532
18553
|
params: ({ schemaCode }) => (0, codegen_1$h._) `{pattern: ${schemaCode}}`,
|
|
@@ -18550,7 +18571,7 @@ pattern.default = def$n;
|
|
|
18550
18571
|
var limitProperties = {};
|
|
18551
18572
|
|
|
18552
18573
|
Object.defineProperty(limitProperties, "__esModule", { value: true });
|
|
18553
|
-
const codegen_1$g =
|
|
18574
|
+
const codegen_1$g = requireCodegen();
|
|
18554
18575
|
const error$e = {
|
|
18555
18576
|
message({ keyword, schemaCode }) {
|
|
18556
18577
|
const comp = keyword === "maxProperties" ? "more" : "fewer";
|
|
@@ -18576,7 +18597,7 @@ var required = {};
|
|
|
18576
18597
|
|
|
18577
18598
|
Object.defineProperty(required, "__esModule", { value: true });
|
|
18578
18599
|
const code_1$6 = requireCode();
|
|
18579
|
-
const codegen_1$f =
|
|
18600
|
+
const codegen_1$f = requireCodegen();
|
|
18580
18601
|
const util_1$h = util;
|
|
18581
18602
|
const error$d = {
|
|
18582
18603
|
message: ({ params: { missingProperty } }) => (0, codegen_1$f.str) `must have required property '${missingProperty}'`,
|
|
@@ -18655,7 +18676,7 @@ required.default = def$l;
|
|
|
18655
18676
|
var limitItems = {};
|
|
18656
18677
|
|
|
18657
18678
|
Object.defineProperty(limitItems, "__esModule", { value: true });
|
|
18658
|
-
const codegen_1$e =
|
|
18679
|
+
const codegen_1$e = requireCodegen();
|
|
18659
18680
|
const error$c = {
|
|
18660
18681
|
message({ keyword, schemaCode }) {
|
|
18661
18682
|
const comp = keyword === "maxItems" ? "more" : "fewer";
|
|
@@ -18689,7 +18710,7 @@ equal$1.default = equal;
|
|
|
18689
18710
|
|
|
18690
18711
|
Object.defineProperty(uniqueItems, "__esModule", { value: true });
|
|
18691
18712
|
const dataType_1 = dataType;
|
|
18692
|
-
const codegen_1$d =
|
|
18713
|
+
const codegen_1$d = requireCodegen();
|
|
18693
18714
|
const util_1$g = util;
|
|
18694
18715
|
const equal_1$2 = equal$1;
|
|
18695
18716
|
const error$b = {
|
|
@@ -18753,7 +18774,7 @@ uniqueItems.default = def$j;
|
|
|
18753
18774
|
var _const = {};
|
|
18754
18775
|
|
|
18755
18776
|
Object.defineProperty(_const, "__esModule", { value: true });
|
|
18756
|
-
const codegen_1$c =
|
|
18777
|
+
const codegen_1$c = requireCodegen();
|
|
18757
18778
|
const util_1$f = util;
|
|
18758
18779
|
const equal_1$1 = equal$1;
|
|
18759
18780
|
const error$a = {
|
|
@@ -18779,7 +18800,7 @@ _const.default = def$i;
|
|
|
18779
18800
|
var _enum = {};
|
|
18780
18801
|
|
|
18781
18802
|
Object.defineProperty(_enum, "__esModule", { value: true });
|
|
18782
|
-
const codegen_1$b =
|
|
18803
|
+
const codegen_1$b = requireCodegen();
|
|
18783
18804
|
const util_1$e = util;
|
|
18784
18805
|
const equal_1 = equal$1;
|
|
18785
18806
|
const error$9 = {
|
|
@@ -18863,7 +18884,7 @@ var additionalItems = {};
|
|
|
18863
18884
|
|
|
18864
18885
|
Object.defineProperty(additionalItems, "__esModule", { value: true });
|
|
18865
18886
|
additionalItems.validateAdditionalItems = void 0;
|
|
18866
|
-
const codegen_1$a =
|
|
18887
|
+
const codegen_1$a = requireCodegen();
|
|
18867
18888
|
const util_1$d = util;
|
|
18868
18889
|
const error$8 = {
|
|
18869
18890
|
message: ({ params: { len } }) => (0, codegen_1$a.str) `must NOT have more than ${len} items`,
|
|
@@ -18915,7 +18936,7 @@ var items = {};
|
|
|
18915
18936
|
|
|
18916
18937
|
Object.defineProperty(items, "__esModule", { value: true });
|
|
18917
18938
|
items.validateTuple = void 0;
|
|
18918
|
-
const codegen_1$9 =
|
|
18939
|
+
const codegen_1$9 = requireCodegen();
|
|
18919
18940
|
const util_1$c = util;
|
|
18920
18941
|
const code_1$5 = requireCode();
|
|
18921
18942
|
const def$f = {
|
|
@@ -18978,7 +18999,7 @@ prefixItems.default = def$e;
|
|
|
18978
18999
|
var items2020 = {};
|
|
18979
19000
|
|
|
18980
19001
|
Object.defineProperty(items2020, "__esModule", { value: true });
|
|
18981
|
-
const codegen_1$8 =
|
|
19002
|
+
const codegen_1$8 = requireCodegen();
|
|
18982
19003
|
const util_1$b = util;
|
|
18983
19004
|
const code_1$4 = requireCode();
|
|
18984
19005
|
const additionalItems_1$1 = additionalItems;
|
|
@@ -19009,7 +19030,7 @@ items2020.default = def$d;
|
|
|
19009
19030
|
var contains = {};
|
|
19010
19031
|
|
|
19011
19032
|
Object.defineProperty(contains, "__esModule", { value: true });
|
|
19012
|
-
const codegen_1$7 =
|
|
19033
|
+
const codegen_1$7 = requireCodegen();
|
|
19013
19034
|
const util_1$a = util;
|
|
19014
19035
|
const error$6 = {
|
|
19015
19036
|
message: ({ params: { min, max } }) => max === undefined
|
|
@@ -19107,7 +19128,7 @@ var dependencies$1 = {};
|
|
|
19107
19128
|
(function (exports$1) {
|
|
19108
19129
|
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
19109
19130
|
exports$1.validateSchemaDeps = exports$1.validatePropertyDeps = exports$1.error = void 0;
|
|
19110
|
-
const codegen_1 =
|
|
19131
|
+
const codegen_1 = requireCodegen();
|
|
19111
19132
|
const util_1 = util;
|
|
19112
19133
|
const code_1 = requireCode();
|
|
19113
19134
|
exports$1.error = {
|
|
@@ -19194,7 +19215,7 @@ var dependencies$1 = {};
|
|
|
19194
19215
|
var propertyNames = {};
|
|
19195
19216
|
|
|
19196
19217
|
Object.defineProperty(propertyNames, "__esModule", { value: true });
|
|
19197
|
-
const codegen_1$6 =
|
|
19218
|
+
const codegen_1$6 = requireCodegen();
|
|
19198
19219
|
const util_1$9 = util;
|
|
19199
19220
|
const error$5 = {
|
|
19200
19221
|
message: "property name must be valid",
|
|
@@ -19234,7 +19255,7 @@ var additionalProperties = {};
|
|
|
19234
19255
|
|
|
19235
19256
|
Object.defineProperty(additionalProperties, "__esModule", { value: true });
|
|
19236
19257
|
const code_1$3 = requireCode();
|
|
19237
|
-
const codegen_1$5 =
|
|
19258
|
+
const codegen_1$5 = requireCodegen();
|
|
19238
19259
|
const names_1 = requireNames();
|
|
19239
19260
|
const util_1$8 = util;
|
|
19240
19261
|
const error$4 = {
|
|
@@ -19396,7 +19417,7 @@ var patternProperties = {};
|
|
|
19396
19417
|
|
|
19397
19418
|
Object.defineProperty(patternProperties, "__esModule", { value: true });
|
|
19398
19419
|
const code_1$1 = requireCode();
|
|
19399
|
-
const codegen_1$4 =
|
|
19420
|
+
const codegen_1$4 = requireCodegen();
|
|
19400
19421
|
const util_1$6 = util;
|
|
19401
19422
|
const util_2 = util;
|
|
19402
19423
|
const def$8 = {
|
|
@@ -19511,7 +19532,7 @@ anyOf.default = def$6;
|
|
|
19511
19532
|
var oneOf = {};
|
|
19512
19533
|
|
|
19513
19534
|
Object.defineProperty(oneOf, "__esModule", { value: true });
|
|
19514
|
-
const codegen_1$3 =
|
|
19535
|
+
const codegen_1$3 = requireCodegen();
|
|
19515
19536
|
const util_1$4 = util;
|
|
19516
19537
|
const error$3 = {
|
|
19517
19538
|
message: "must match exactly one schema in oneOf",
|
|
@@ -19596,7 +19617,7 @@ allOf.default = def$4;
|
|
|
19596
19617
|
var _if = {};
|
|
19597
19618
|
|
|
19598
19619
|
Object.defineProperty(_if, "__esModule", { value: true });
|
|
19599
|
-
const codegen_1$2 =
|
|
19620
|
+
const codegen_1$2 = requireCodegen();
|
|
19600
19621
|
const util_1$2 = util;
|
|
19601
19622
|
const error$2 = {
|
|
19602
19623
|
message: ({ params }) => (0, codegen_1$2.str) `must match "${params.ifClause}" schema`,
|
|
@@ -19722,7 +19743,7 @@ var format$2 = {};
|
|
|
19722
19743
|
var format$1 = {};
|
|
19723
19744
|
|
|
19724
19745
|
Object.defineProperty(format$1, "__esModule", { value: true });
|
|
19725
|
-
const codegen_1$1 =
|
|
19746
|
+
const codegen_1$1 = requireCodegen();
|
|
19726
19747
|
const error$1 = {
|
|
19727
19748
|
message: ({ schemaCode }) => (0, codegen_1$1.str) `must match format "${schemaCode}"`,
|
|
19728
19749
|
params: ({ schemaCode }) => (0, codegen_1$1._) `{format: ${schemaCode}}`,
|
|
@@ -19865,7 +19886,7 @@ var DiscrError;
|
|
|
19865
19886
|
})(DiscrError || (types.DiscrError = DiscrError = {}));
|
|
19866
19887
|
|
|
19867
19888
|
Object.defineProperty(discriminator, "__esModule", { value: true });
|
|
19868
|
-
const codegen_1 =
|
|
19889
|
+
const codegen_1 = requireCodegen();
|
|
19869
19890
|
const types_1 = types;
|
|
19870
19891
|
const compile_1 = compile;
|
|
19871
19892
|
const ref_error_1 = requireRef_error();
|
|
@@ -20257,7 +20278,7 @@ var require$$3 = {
|
|
|
20257
20278
|
exports$1.default = Ajv;
|
|
20258
20279
|
var validate_1 = requireValidate();
|
|
20259
20280
|
Object.defineProperty(exports$1, "KeywordCxt", { enumerable: true, get: function () { return validate_1.KeywordCxt; } });
|
|
20260
|
-
var codegen_1 =
|
|
20281
|
+
var codegen_1 = requireCodegen();
|
|
20261
20282
|
Object.defineProperty(exports$1, "_", { enumerable: true, get: function () { return codegen_1._; } });
|
|
20262
20283
|
Object.defineProperty(exports$1, "str", { enumerable: true, get: function () { return codegen_1.str; } });
|
|
20263
20284
|
Object.defineProperty(exports$1, "stringify", { enumerable: true, get: function () { return codegen_1.stringify; } });
|
|
@@ -20494,7 +20515,7 @@ var limit = {};
|
|
|
20494
20515
|
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
20495
20516
|
exports$1.formatLimitDefinition = void 0;
|
|
20496
20517
|
const ajv_1 = ajvExports;
|
|
20497
|
-
const codegen_1 =
|
|
20518
|
+
const codegen_1 = requireCodegen();
|
|
20498
20519
|
const ops = codegen_1.operators;
|
|
20499
20520
|
const KWDs = {
|
|
20500
20521
|
formatMaximum: { okStr: "<=", ok: ops.LTE, fail: ops.GT },
|
|
@@ -20565,7 +20586,7 @@ var limit = {};
|
|
|
20565
20586
|
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
20566
20587
|
const formats_1 = formats;
|
|
20567
20588
|
const limit_1 = limit;
|
|
20568
|
-
const codegen_1 =
|
|
20589
|
+
const codegen_1 = requireCodegen();
|
|
20569
20590
|
const fullName = new codegen_1.Name("fullFormats");
|
|
20570
20591
|
const fastName = new codegen_1.Name("fastFormats");
|
|
20571
20592
|
const formatsPlugin = (ajv, opts = { keywords: true }) => {
|
|
@@ -23037,8 +23058,8 @@ function getAutomationFramework(workingDirectory, activeFile) {
|
|
|
23037
23058
|
}
|
|
23038
23059
|
|
|
23039
23060
|
var name = "@applitools/mcp";
|
|
23040
|
-
var mcpName = "io.github.
|
|
23041
|
-
var version = "0.4.
|
|
23061
|
+
var mcpName = "io.github.applitools/applitools";
|
|
23062
|
+
var version = "0.4.2";
|
|
23042
23063
|
var description = "Applitools MCP server for AI coding assistants";
|
|
23043
23064
|
var main = "./dist/index.js";
|
|
23044
23065
|
var bin = "./dist/index.js";
|
|
@@ -23287,7 +23308,7 @@ class ApiClient {
|
|
|
23287
23308
|
throw new MissingApiKeyError();
|
|
23288
23309
|
}
|
|
23289
23310
|
try {
|
|
23290
|
-
const response = await req(`${this.baseUrl}/${endpoint}`, {
|
|
23311
|
+
const response = await req.req(`${this.baseUrl}/${endpoint}`, {
|
|
23291
23312
|
method: 'GET',
|
|
23292
23313
|
headers: {
|
|
23293
23314
|
'X-Eyes-Api-Key': this.apiKey,
|
|
@@ -23389,7 +23410,7 @@ class ApiClient {
|
|
|
23389
23410
|
};
|
|
23390
23411
|
// Add API key to query for POST requests (Eyes API pattern)
|
|
23391
23412
|
const url = `${this.baseUrl}/${endpoint}${endpoint.includes('?') ? '&' : '?'}apiKey=${this.apiKey}`;
|
|
23392
|
-
const response = await req(url, reqOptions);
|
|
23413
|
+
const response = await req.req(url, reqOptions);
|
|
23393
23414
|
// Handle authentication errors
|
|
23394
23415
|
if (response.status === 401) {
|
|
23395
23416
|
throw new InvalidApiKeyError(this.apiKey);
|