@valbuild/core 0.13.4 → 0.13.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/declarations/src/expr/eval.d.ts +2 -1
- package/dist/declarations/src/index.d.ts +2 -1
- package/dist/declarations/src/val/index.d.ts +1 -1
- package/dist/{index-f0d4530a.cjs.dev.js → index-43176a0e.cjs.dev.js} +667 -143
- package/dist/{index-3b733a02.esm.js → index-bc255f5a.esm.js} +671 -147
- package/dist/{index-01a259ae.cjs.prod.js → index-e496913b.cjs.prod.js} +667 -143
- package/dist/valbuild-core.cjs.dev.js +5 -4
- package/dist/valbuild-core.cjs.prod.js +5 -4
- package/dist/valbuild-core.esm.js +6 -5
- package/expr/dist/valbuild-core-expr.cjs.dev.js +1 -1
- package/expr/dist/valbuild-core-expr.cjs.prod.js +1 -1
- package/expr/dist/valbuild-core-expr.esm.js +1 -1
- package/package.json +1 -1
- package/src/expr/eval.test.ts +3 -6
- package/src/expr/eval.ts +51 -39
- package/src/expr/repl.ts +23 -25
- package/src/fetchVal.ts +5 -2
- package/src/index.ts +2 -1
- package/src/selector/SelectorProxy.ts +4 -3
- package/src/selector/selector.test.ts +3 -7
- package/src/val/index.ts +1 -1
@@ -1,5 +1,5 @@
|
|
1
1
|
import { e as _toPropertyKey, a as _createClass, _ as _classCallCheck, b as _typeof, c as _slicedToArray, d as _toConsumableArray } from './createClass-012eebbf.esm.js';
|
2
|
-
import { i as isErr, e as err, o as ok, a as isOk } from './result-b96df128.esm.js';
|
2
|
+
import { i as isErr, e as err, o as ok, a as isOk, r as result } from './result-b96df128.esm.js';
|
3
3
|
|
4
4
|
function _defineProperty(obj, key, value) {
|
5
5
|
key = _toPropertyKey(key);
|
@@ -428,7 +428,8 @@ function newSelectorProxy(source, path, moduleSchema) {
|
|
428
428
|
if (isSelector(source)) {
|
429
429
|
return source;
|
430
430
|
} else if (isSerializedVal(source)) {
|
431
|
-
|
431
|
+
var _source$valPath;
|
432
|
+
return newSelectorProxy(source.val, (_source$valPath = source.valPath) !== null && _source$valPath !== void 0 ? _source$valPath : undefined);
|
432
433
|
}
|
433
434
|
}
|
434
435
|
if (source && source[FILE_REF_PROP] && source[VAL_EXTENSION] === "file") {
|
@@ -535,7 +536,7 @@ function newSelectorProxy(source, path, moduleSchema) {
|
|
535
536
|
andThen: function andThen(f) {
|
536
537
|
return _andThen(f, source === undefined ? null : source, path);
|
537
538
|
}
|
538
|
-
}, _defineProperty(_ref, SourceOrExpr, source === undefined ? null : source), _defineProperty(_ref, Path, path), _ref;
|
539
|
+
}, _defineProperty(_ref, SourceOrExpr, source === undefined ? null : source), _defineProperty(_ref, Path, path), _defineProperty(_ref, GetSchema, moduleSchema), _ref;
|
539
540
|
}
|
540
541
|
}
|
541
542
|
function createValPathOfItem(arrayPath, prop) {
|
@@ -813,6 +814,339 @@ function parse(input) {
|
|
813
814
|
return parseTokens(tokens);
|
814
815
|
}
|
815
816
|
|
817
|
+
function _regeneratorRuntime() {
|
818
|
+
_regeneratorRuntime = function () {
|
819
|
+
return exports;
|
820
|
+
};
|
821
|
+
var exports = {},
|
822
|
+
Op = Object.prototype,
|
823
|
+
hasOwn = Op.hasOwnProperty,
|
824
|
+
defineProperty = Object.defineProperty || function (obj, key, desc) {
|
825
|
+
obj[key] = desc.value;
|
826
|
+
},
|
827
|
+
$Symbol = "function" == typeof Symbol ? Symbol : {},
|
828
|
+
iteratorSymbol = $Symbol.iterator || "@@iterator",
|
829
|
+
asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
|
830
|
+
toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
|
831
|
+
function define(obj, key, value) {
|
832
|
+
return Object.defineProperty(obj, key, {
|
833
|
+
value: value,
|
834
|
+
enumerable: !0,
|
835
|
+
configurable: !0,
|
836
|
+
writable: !0
|
837
|
+
}), obj[key];
|
838
|
+
}
|
839
|
+
try {
|
840
|
+
define({}, "");
|
841
|
+
} catch (err) {
|
842
|
+
define = function (obj, key, value) {
|
843
|
+
return obj[key] = value;
|
844
|
+
};
|
845
|
+
}
|
846
|
+
function wrap(innerFn, outerFn, self, tryLocsList) {
|
847
|
+
var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
|
848
|
+
generator = Object.create(protoGenerator.prototype),
|
849
|
+
context = new Context(tryLocsList || []);
|
850
|
+
return defineProperty(generator, "_invoke", {
|
851
|
+
value: makeInvokeMethod(innerFn, self, context)
|
852
|
+
}), generator;
|
853
|
+
}
|
854
|
+
function tryCatch(fn, obj, arg) {
|
855
|
+
try {
|
856
|
+
return {
|
857
|
+
type: "normal",
|
858
|
+
arg: fn.call(obj, arg)
|
859
|
+
};
|
860
|
+
} catch (err) {
|
861
|
+
return {
|
862
|
+
type: "throw",
|
863
|
+
arg: err
|
864
|
+
};
|
865
|
+
}
|
866
|
+
}
|
867
|
+
exports.wrap = wrap;
|
868
|
+
var ContinueSentinel = {};
|
869
|
+
function Generator() {}
|
870
|
+
function GeneratorFunction() {}
|
871
|
+
function GeneratorFunctionPrototype() {}
|
872
|
+
var IteratorPrototype = {};
|
873
|
+
define(IteratorPrototype, iteratorSymbol, function () {
|
874
|
+
return this;
|
875
|
+
});
|
876
|
+
var getProto = Object.getPrototypeOf,
|
877
|
+
NativeIteratorPrototype = getProto && getProto(getProto(values([])));
|
878
|
+
NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
|
879
|
+
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
|
880
|
+
function defineIteratorMethods(prototype) {
|
881
|
+
["next", "throw", "return"].forEach(function (method) {
|
882
|
+
define(prototype, method, function (arg) {
|
883
|
+
return this._invoke(method, arg);
|
884
|
+
});
|
885
|
+
});
|
886
|
+
}
|
887
|
+
function AsyncIterator(generator, PromiseImpl) {
|
888
|
+
function invoke(method, arg, resolve, reject) {
|
889
|
+
var record = tryCatch(generator[method], generator, arg);
|
890
|
+
if ("throw" !== record.type) {
|
891
|
+
var result = record.arg,
|
892
|
+
value = result.value;
|
893
|
+
return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
|
894
|
+
invoke("next", value, resolve, reject);
|
895
|
+
}, function (err) {
|
896
|
+
invoke("throw", err, resolve, reject);
|
897
|
+
}) : PromiseImpl.resolve(value).then(function (unwrapped) {
|
898
|
+
result.value = unwrapped, resolve(result);
|
899
|
+
}, function (error) {
|
900
|
+
return invoke("throw", error, resolve, reject);
|
901
|
+
});
|
902
|
+
}
|
903
|
+
reject(record.arg);
|
904
|
+
}
|
905
|
+
var previousPromise;
|
906
|
+
defineProperty(this, "_invoke", {
|
907
|
+
value: function (method, arg) {
|
908
|
+
function callInvokeWithMethodAndArg() {
|
909
|
+
return new PromiseImpl(function (resolve, reject) {
|
910
|
+
invoke(method, arg, resolve, reject);
|
911
|
+
});
|
912
|
+
}
|
913
|
+
return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
914
|
+
}
|
915
|
+
});
|
916
|
+
}
|
917
|
+
function makeInvokeMethod(innerFn, self, context) {
|
918
|
+
var state = "suspendedStart";
|
919
|
+
return function (method, arg) {
|
920
|
+
if ("executing" === state) throw new Error("Generator is already running");
|
921
|
+
if ("completed" === state) {
|
922
|
+
if ("throw" === method) throw arg;
|
923
|
+
return doneResult();
|
924
|
+
}
|
925
|
+
for (context.method = method, context.arg = arg;;) {
|
926
|
+
var delegate = context.delegate;
|
927
|
+
if (delegate) {
|
928
|
+
var delegateResult = maybeInvokeDelegate(delegate, context);
|
929
|
+
if (delegateResult) {
|
930
|
+
if (delegateResult === ContinueSentinel) continue;
|
931
|
+
return delegateResult;
|
932
|
+
}
|
933
|
+
}
|
934
|
+
if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
|
935
|
+
if ("suspendedStart" === state) throw state = "completed", context.arg;
|
936
|
+
context.dispatchException(context.arg);
|
937
|
+
} else "return" === context.method && context.abrupt("return", context.arg);
|
938
|
+
state = "executing";
|
939
|
+
var record = tryCatch(innerFn, self, context);
|
940
|
+
if ("normal" === record.type) {
|
941
|
+
if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
|
942
|
+
return {
|
943
|
+
value: record.arg,
|
944
|
+
done: context.done
|
945
|
+
};
|
946
|
+
}
|
947
|
+
"throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
|
948
|
+
}
|
949
|
+
};
|
950
|
+
}
|
951
|
+
function maybeInvokeDelegate(delegate, context) {
|
952
|
+
var methodName = context.method,
|
953
|
+
method = delegate.iterator[methodName];
|
954
|
+
if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel;
|
955
|
+
var record = tryCatch(method, delegate.iterator, context.arg);
|
956
|
+
if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
|
957
|
+
var info = record.arg;
|
958
|
+
return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
|
959
|
+
}
|
960
|
+
function pushTryEntry(locs) {
|
961
|
+
var entry = {
|
962
|
+
tryLoc: locs[0]
|
963
|
+
};
|
964
|
+
1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
|
965
|
+
}
|
966
|
+
function resetTryEntry(entry) {
|
967
|
+
var record = entry.completion || {};
|
968
|
+
record.type = "normal", delete record.arg, entry.completion = record;
|
969
|
+
}
|
970
|
+
function Context(tryLocsList) {
|
971
|
+
this.tryEntries = [{
|
972
|
+
tryLoc: "root"
|
973
|
+
}], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
|
974
|
+
}
|
975
|
+
function values(iterable) {
|
976
|
+
if (iterable) {
|
977
|
+
var iteratorMethod = iterable[iteratorSymbol];
|
978
|
+
if (iteratorMethod) return iteratorMethod.call(iterable);
|
979
|
+
if ("function" == typeof iterable.next) return iterable;
|
980
|
+
if (!isNaN(iterable.length)) {
|
981
|
+
var i = -1,
|
982
|
+
next = function next() {
|
983
|
+
for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
|
984
|
+
return next.value = undefined, next.done = !0, next;
|
985
|
+
};
|
986
|
+
return next.next = next;
|
987
|
+
}
|
988
|
+
}
|
989
|
+
return {
|
990
|
+
next: doneResult
|
991
|
+
};
|
992
|
+
}
|
993
|
+
function doneResult() {
|
994
|
+
return {
|
995
|
+
value: undefined,
|
996
|
+
done: !0
|
997
|
+
};
|
998
|
+
}
|
999
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
|
1000
|
+
value: GeneratorFunctionPrototype,
|
1001
|
+
configurable: !0
|
1002
|
+
}), defineProperty(GeneratorFunctionPrototype, "constructor", {
|
1003
|
+
value: GeneratorFunction,
|
1004
|
+
configurable: !0
|
1005
|
+
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
|
1006
|
+
var ctor = "function" == typeof genFun && genFun.constructor;
|
1007
|
+
return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
|
1008
|
+
}, exports.mark = function (genFun) {
|
1009
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
|
1010
|
+
}, exports.awrap = function (arg) {
|
1011
|
+
return {
|
1012
|
+
__await: arg
|
1013
|
+
};
|
1014
|
+
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
|
1015
|
+
return this;
|
1016
|
+
}), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
|
1017
|
+
void 0 === PromiseImpl && (PromiseImpl = Promise);
|
1018
|
+
var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
|
1019
|
+
return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
|
1020
|
+
return result.done ? result.value : iter.next();
|
1021
|
+
});
|
1022
|
+
}, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
|
1023
|
+
return this;
|
1024
|
+
}), define(Gp, "toString", function () {
|
1025
|
+
return "[object Generator]";
|
1026
|
+
}), exports.keys = function (val) {
|
1027
|
+
var object = Object(val),
|
1028
|
+
keys = [];
|
1029
|
+
for (var key in object) keys.push(key);
|
1030
|
+
return keys.reverse(), function next() {
|
1031
|
+
for (; keys.length;) {
|
1032
|
+
var key = keys.pop();
|
1033
|
+
if (key in object) return next.value = key, next.done = !1, next;
|
1034
|
+
}
|
1035
|
+
return next.done = !0, next;
|
1036
|
+
};
|
1037
|
+
}, exports.values = values, Context.prototype = {
|
1038
|
+
constructor: Context,
|
1039
|
+
reset: function (skipTempReset) {
|
1040
|
+
if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
|
1041
|
+
},
|
1042
|
+
stop: function () {
|
1043
|
+
this.done = !0;
|
1044
|
+
var rootRecord = this.tryEntries[0].completion;
|
1045
|
+
if ("throw" === rootRecord.type) throw rootRecord.arg;
|
1046
|
+
return this.rval;
|
1047
|
+
},
|
1048
|
+
dispatchException: function (exception) {
|
1049
|
+
if (this.done) throw exception;
|
1050
|
+
var context = this;
|
1051
|
+
function handle(loc, caught) {
|
1052
|
+
return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
|
1053
|
+
}
|
1054
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
1055
|
+
var entry = this.tryEntries[i],
|
1056
|
+
record = entry.completion;
|
1057
|
+
if ("root" === entry.tryLoc) return handle("end");
|
1058
|
+
if (entry.tryLoc <= this.prev) {
|
1059
|
+
var hasCatch = hasOwn.call(entry, "catchLoc"),
|
1060
|
+
hasFinally = hasOwn.call(entry, "finallyLoc");
|
1061
|
+
if (hasCatch && hasFinally) {
|
1062
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
1063
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
1064
|
+
} else if (hasCatch) {
|
1065
|
+
if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
|
1066
|
+
} else {
|
1067
|
+
if (!hasFinally) throw new Error("try statement without catch or finally");
|
1068
|
+
if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
|
1069
|
+
}
|
1070
|
+
}
|
1071
|
+
}
|
1072
|
+
},
|
1073
|
+
abrupt: function (type, arg) {
|
1074
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
1075
|
+
var entry = this.tryEntries[i];
|
1076
|
+
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
1077
|
+
var finallyEntry = entry;
|
1078
|
+
break;
|
1079
|
+
}
|
1080
|
+
}
|
1081
|
+
finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
|
1082
|
+
var record = finallyEntry ? finallyEntry.completion : {};
|
1083
|
+
return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
|
1084
|
+
},
|
1085
|
+
complete: function (record, afterLoc) {
|
1086
|
+
if ("throw" === record.type) throw record.arg;
|
1087
|
+
return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
|
1088
|
+
},
|
1089
|
+
finish: function (finallyLoc) {
|
1090
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
1091
|
+
var entry = this.tryEntries[i];
|
1092
|
+
if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
|
1093
|
+
}
|
1094
|
+
},
|
1095
|
+
catch: function (tryLoc) {
|
1096
|
+
for (var i = this.tryEntries.length - 1; i >= 0; --i) {
|
1097
|
+
var entry = this.tryEntries[i];
|
1098
|
+
if (entry.tryLoc === tryLoc) {
|
1099
|
+
var record = entry.completion;
|
1100
|
+
if ("throw" === record.type) {
|
1101
|
+
var thrown = record.arg;
|
1102
|
+
resetTryEntry(entry);
|
1103
|
+
}
|
1104
|
+
return thrown;
|
1105
|
+
}
|
1106
|
+
}
|
1107
|
+
throw new Error("illegal catch attempt");
|
1108
|
+
},
|
1109
|
+
delegateYield: function (iterable, resultName, nextLoc) {
|
1110
|
+
return this.delegate = {
|
1111
|
+
iterator: values(iterable),
|
1112
|
+
resultName: resultName,
|
1113
|
+
nextLoc: nextLoc
|
1114
|
+
}, "next" === this.method && (this.arg = undefined), ContinueSentinel;
|
1115
|
+
}
|
1116
|
+
}, exports;
|
1117
|
+
}
|
1118
|
+
|
1119
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
1120
|
+
try {
|
1121
|
+
var info = gen[key](arg);
|
1122
|
+
var value = info.value;
|
1123
|
+
} catch (error) {
|
1124
|
+
reject(error);
|
1125
|
+
return;
|
1126
|
+
}
|
1127
|
+
if (info.done) {
|
1128
|
+
resolve(value);
|
1129
|
+
} else {
|
1130
|
+
Promise.resolve(value).then(_next, _throw);
|
1131
|
+
}
|
1132
|
+
}
|
1133
|
+
function _asyncToGenerator(fn) {
|
1134
|
+
return function () {
|
1135
|
+
var self = this,
|
1136
|
+
args = arguments;
|
1137
|
+
return new Promise(function (resolve, reject) {
|
1138
|
+
var gen = fn.apply(self, args);
|
1139
|
+
function _next(value) {
|
1140
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
1141
|
+
}
|
1142
|
+
function _throw(err) {
|
1143
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
1144
|
+
}
|
1145
|
+
_next(undefined);
|
1146
|
+
});
|
1147
|
+
};
|
1148
|
+
}
|
1149
|
+
|
816
1150
|
var EvalError = /*#__PURE__*/function () {
|
817
1151
|
function EvalError(message, expr) {
|
818
1152
|
_classCallCheck(this, EvalError);
|
@@ -828,164 +1162,354 @@ var EvalError = /*#__PURE__*/function () {
|
|
828
1162
|
return EvalError;
|
829
1163
|
}();
|
830
1164
|
var MAX_STACK_SIZE = 100; // an arbitrary semi-large number
|
831
|
-
function
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
1165
|
+
function evaluateAsync(_x, _x2, _x3) {
|
1166
|
+
return _evaluateAsync.apply(this, arguments);
|
1167
|
+
}
|
1168
|
+
function _evaluateAsync() {
|
1169
|
+
_evaluateAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(expr, getSource, stack) {
|
1170
|
+
var path, source, value, valObj, valPath, serialized, _serialized$valPath, parsedValue, res, prop, obj, maybeFunction, _path, _source, args, _maybeFunction, maybeValue, _stack$Number, _expr$value$slice$spl, _expr$value$slice$spl2, i, j, rest, stackValue;
|
1171
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
1172
|
+
while (1) switch (_context2.prev = _context2.next) {
|
1173
|
+
case 0:
|
1174
|
+
if (!(stack.length > MAX_STACK_SIZE)) {
|
1175
|
+
_context2.next = 2;
|
1176
|
+
break;
|
1177
|
+
}
|
1178
|
+
throw new EvalError("Stack overflow. Final frames: ".concat(stack.slice(-10).map(function (frame, i) {
|
1179
|
+
return frame.map(function (s, j) {
|
1180
|
+
return "@[".concat(i, ",").concat(j, "]: ").concat(JSON.stringify(s));
|
1181
|
+
}).join(", ");
|
1182
|
+
}).join(" -> ")), expr);
|
1183
|
+
case 2:
|
1184
|
+
if (!(expr instanceof Call)) {
|
1185
|
+
_context2.next = 96;
|
1186
|
+
break;
|
1187
|
+
}
|
1188
|
+
if (!(expr.children[0] instanceof Sym)) {
|
1189
|
+
_context2.next = 50;
|
1190
|
+
break;
|
1191
|
+
}
|
1192
|
+
if (!(expr.children[0].value === "val")) {
|
1193
|
+
_context2.next = 18;
|
1194
|
+
break;
|
1195
|
+
}
|
1196
|
+
if (!expr.isAnon) {
|
1197
|
+
_context2.next = 7;
|
1198
|
+
break;
|
1199
|
+
}
|
844
1200
|
throw new EvalError("cannot call 'val' as anonymous function", expr);
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
1201
|
+
case 7:
|
1202
|
+
if (!(expr.children[1] instanceof StringLiteral)) {
|
1203
|
+
_context2.next = 15;
|
1204
|
+
break;
|
1205
|
+
}
|
1206
|
+
path = expr.children[1].value;
|
1207
|
+
_context2.next = 11;
|
1208
|
+
return getSource(path);
|
1209
|
+
case 11:
|
1210
|
+
source = _context2.sent;
|
1211
|
+
return _context2.abrupt("return", newSelectorProxy(source, path));
|
1212
|
+
case 15:
|
849
1213
|
throw new EvalError("argument of 'val' must be a string literal", expr);
|
850
|
-
|
851
|
-
|
852
|
-
|
1214
|
+
case 16:
|
1215
|
+
_context2.next = 50;
|
1216
|
+
break;
|
1217
|
+
case 18:
|
1218
|
+
if (!(expr.children[0].value === "json")) {
|
1219
|
+
_context2.next = 43;
|
1220
|
+
break;
|
1221
|
+
}
|
1222
|
+
if (!(expr.children.length !== 2)) {
|
1223
|
+
_context2.next = 21;
|
1224
|
+
break;
|
1225
|
+
}
|
853
1226
|
throw new EvalError("must call 'json' with exactly one argument", expr);
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
1227
|
+
case 21:
|
1228
|
+
_context2.next = 23;
|
1229
|
+
return evaluateAsync(expr.children[1], getSource, stack);
|
1230
|
+
case 23:
|
1231
|
+
value = _context2.sent;
|
1232
|
+
valObj = value[SourceOrExpr];
|
1233
|
+
valPath = value[Path];
|
1234
|
+
if (!(typeof valObj !== "string")) {
|
1235
|
+
_context2.next = 28;
|
1236
|
+
break;
|
1237
|
+
}
|
859
1238
|
throw new EvalError("cannot parse JSON: ".concat(JSON.stringify(valObj), ", expected string"), expr.children[1]);
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
if (isSerializedVal(serialized)) {
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
return
|
868
|
-
|
869
|
-
|
870
|
-
|
871
|
-
|
872
|
-
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
1239
|
+
case 28:
|
1240
|
+
_context2.prev = 28;
|
1241
|
+
serialized = JSON.parse(valObj);
|
1242
|
+
if (!isSerializedVal(serialized)) {
|
1243
|
+
_context2.next = 32;
|
1244
|
+
break;
|
1245
|
+
}
|
1246
|
+
return _context2.abrupt("return", newSelectorProxy(serialized.val, (_serialized$valPath = serialized.valPath) !== null && _serialized$valPath !== void 0 ? _serialized$valPath : undefined));
|
1247
|
+
case 32:
|
1248
|
+
parsedValue = newSelectorProxy(JSON.parse(valObj), valPath);
|
1249
|
+
return _context2.abrupt("return", parsedValue);
|
1250
|
+
case 36:
|
1251
|
+
_context2.prev = 36;
|
1252
|
+
_context2.t0 = _context2["catch"](28);
|
1253
|
+
if (!(_context2.t0 instanceof SyntaxError)) {
|
1254
|
+
_context2.next = 40;
|
1255
|
+
break;
|
1256
|
+
}
|
1257
|
+
throw new EvalError("cannot parse JSON: ".concat(valObj, ", ").concat(_context2.t0.message, " - value: ").concat(JSON.stringify(value)), expr.children[1]);
|
1258
|
+
case 40:
|
1259
|
+
throw _context2.t0;
|
1260
|
+
case 41:
|
1261
|
+
_context2.next = 50;
|
1262
|
+
break;
|
1263
|
+
case 43:
|
1264
|
+
if (!(expr.children[0].value === "stringify")) {
|
1265
|
+
_context2.next = 50;
|
1266
|
+
break;
|
1267
|
+
}
|
1268
|
+
if (!(expr.children.length !== 2)) {
|
1269
|
+
_context2.next = 46;
|
1270
|
+
break;
|
1271
|
+
}
|
877
1272
|
throw new EvalError("must call 'stringify' with exactly one argument", expr);
|
878
|
-
|
879
|
-
|
880
|
-
|
881
|
-
|
882
|
-
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
1273
|
+
case 46:
|
1274
|
+
_context2.next = 48;
|
1275
|
+
return evaluateAsync(expr.children[1], getSource, stack);
|
1276
|
+
case 48:
|
1277
|
+
res = _context2.sent;
|
1278
|
+
return _context2.abrupt("return", newSelectorProxy(JSON.stringify(res[SourceOrExpr])));
|
1279
|
+
case 50:
|
1280
|
+
_context2.next = 52;
|
1281
|
+
return evaluateAsync(expr.children[0], getSource, stack);
|
1282
|
+
case 52:
|
1283
|
+
_context2.t1 = SourceOrExpr;
|
1284
|
+
prop = _context2.sent[_context2.t1];
|
1285
|
+
if (!(expr.children.length === 1)) {
|
1286
|
+
_context2.next = 56;
|
1287
|
+
break;
|
1288
|
+
}
|
1289
|
+
return _context2.abrupt("return", newSelectorProxy(prop));
|
1290
|
+
case 56:
|
1291
|
+
_context2.next = 58;
|
1292
|
+
return evaluateAsync(expr.children[1], getSource, stack);
|
1293
|
+
case 58:
|
1294
|
+
obj = _context2.sent;
|
1295
|
+
if (!(typeof prop !== "string" && typeof prop !== "number")) {
|
1296
|
+
_context2.next = 61;
|
1297
|
+
break;
|
1298
|
+
}
|
1299
|
+
throw new EvalError("cannot access ".concat(JSON.stringify(obj), " with property ").concat(JSON.stringify(prop), ": is not a string or number"), expr);
|
1300
|
+
case 61:
|
1301
|
+
if (!(prop in obj)) {
|
1302
|
+
_context2.next = 94;
|
1303
|
+
break;
|
1304
|
+
}
|
1305
|
+
if (!expr.isAnon) {
|
1306
|
+
_context2.next = 73;
|
1307
|
+
break;
|
1308
|
+
}
|
1309
|
+
// anon functions:
|
1310
|
+
maybeFunction = obj[prop];
|
1311
|
+
if (!(typeof maybeFunction !== "function")) {
|
1312
|
+
_context2.next = 66;
|
1313
|
+
break;
|
1314
|
+
}
|
897
1315
|
throw new EvalError("cannot access property ".concat(JSON.stringify(prop), " of ").concat(JSON.stringify(obj), ": required higher ordered function got ").concat(_typeof(obj[prop])), expr);
|
898
|
-
|
899
|
-
|
900
|
-
|
1316
|
+
case 66:
|
1317
|
+
if (!(expr.children[0] instanceof Sym)) {
|
1318
|
+
_context2.next = 70;
|
1319
|
+
break;
|
1320
|
+
}
|
1321
|
+
return _context2.abrupt("return", maybeFunction(function () {
|
901
1322
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
902
1323
|
args[_key] = arguments[_key];
|
903
1324
|
}
|
904
|
-
return
|
905
|
-
});
|
906
|
-
|
1325
|
+
return evaluateAsync(expr.children[2], getSource, stack.concat([args]));
|
1326
|
+
}));
|
1327
|
+
case 70:
|
907
1328
|
throw new EvalError("cannot call an expression that is not a symbol, got: '".concat(expr.children[0].type, "'"), expr);
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
if (expr.children[0]
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
1329
|
+
case 71:
|
1330
|
+
_context2.next = 94;
|
1331
|
+
break;
|
1332
|
+
case 73:
|
1333
|
+
if (!(expr.children[0] instanceof Sym)) {
|
1334
|
+
_context2.next = 84;
|
1335
|
+
break;
|
1336
|
+
}
|
1337
|
+
if (!(expr.children[0].value === "val")) {
|
1338
|
+
_context2.next = 84;
|
1339
|
+
break;
|
1340
|
+
}
|
1341
|
+
if (!(expr.children[1] instanceof StringLiteral)) {
|
1342
|
+
_context2.next = 83;
|
1343
|
+
break;
|
1344
|
+
}
|
1345
|
+
_path = expr.children[1].value;
|
1346
|
+
_context2.next = 79;
|
1347
|
+
return getSource(_path);
|
1348
|
+
case 79:
|
1349
|
+
_source = _context2.sent;
|
1350
|
+
return _context2.abrupt("return", newSelectorProxy(_source, _path));
|
1351
|
+
case 83:
|
1352
|
+
throw new EvalError("argument of 'val' must be a string literal", expr);
|
1353
|
+
case 84:
|
1354
|
+
args = expr.children.slice(2);
|
1355
|
+
if (!(args.length > 0)) {
|
1356
|
+
_context2.next = 90;
|
1357
|
+
break;
|
1358
|
+
}
|
1359
|
+
_maybeFunction = obj[prop];
|
1360
|
+
if (!(typeof _maybeFunction !== "function")) {
|
1361
|
+
_context2.next = 89;
|
1362
|
+
break;
|
1363
|
+
}
|
1364
|
+
throw new EvalError("cannot access property ".concat(JSON.stringify(prop), " of ").concat(JSON.stringify(obj), ": required function got ").concat(_typeof(obj[prop])), expr);
|
1365
|
+
case 89:
|
1366
|
+
return _context2.abrupt("return", _maybeFunction.apply(void 0, _toConsumableArray(args.map(function (arg) {
|
1367
|
+
return evaluateAsync(arg, getSource, stack);
|
1368
|
+
}))));
|
1369
|
+
case 90:
|
1370
|
+
maybeValue = obj[prop];
|
1371
|
+
if (!(typeof maybeValue === "function")) {
|
1372
|
+
_context2.next = 93;
|
1373
|
+
break;
|
918
1374
|
}
|
919
|
-
}
|
920
|
-
var args = expr.children.slice(2);
|
921
|
-
if (args.length > 0) {
|
922
|
-
var _maybeFunction = obj[prop];
|
923
|
-
if (typeof _maybeFunction !== "function") {
|
924
|
-
throw new EvalError("cannot access property ".concat(JSON.stringify(prop), " of ").concat(JSON.stringify(obj), ": required function got ").concat(_typeof(obj[prop])), expr);
|
925
|
-
}
|
926
|
-
return _maybeFunction.apply(void 0, _toConsumableArray(args.map(function (arg) {
|
927
|
-
return evaluateSync(arg, getSource, stack);
|
928
|
-
})));
|
929
|
-
}
|
930
|
-
var maybeValue = obj[prop];
|
931
|
-
if (typeof maybeValue === "function") {
|
932
1375
|
throw new EvalError("cannot access property ".concat(JSON.stringify(prop), " of ").concat(JSON.stringify(obj), ": required value got ").concat(_typeof(obj[prop])), expr);
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
1376
|
+
case 93:
|
1377
|
+
return _context2.abrupt("return", maybeValue);
|
1378
|
+
case 94:
|
1379
|
+
_context2.next = 122;
|
1380
|
+
break;
|
1381
|
+
case 96:
|
1382
|
+
if (!(expr instanceof Sym)) {
|
1383
|
+
_context2.next = 112;
|
1384
|
+
break;
|
1385
|
+
}
|
1386
|
+
if (!expr.value.startsWith("@")) {
|
1387
|
+
_context2.next = 107;
|
1388
|
+
break;
|
1389
|
+
}
|
1390
|
+
_expr$value$slice$spl = expr.value.slice(2, -1).split(","), _expr$value$slice$spl2 = _slicedToArray(_expr$value$slice$spl, 3), i = _expr$value$slice$spl2[0], j = _expr$value$slice$spl2[1], rest = _expr$value$slice$spl2[2];
|
1391
|
+
if (!rest) {
|
1392
|
+
_context2.next = 101;
|
1393
|
+
break;
|
1394
|
+
}
|
1395
|
+
throw new EvalError("cannot access stack: too many indices", expr);
|
1396
|
+
case 101:
|
1397
|
+
stackValue = (_stack$Number = stack[Number(i)]) === null || _stack$Number === void 0 ? void 0 : _stack$Number[Number(j)];
|
1398
|
+
if (!(stackValue === undefined)) {
|
1399
|
+
_context2.next = 104;
|
1400
|
+
break;
|
1401
|
+
}
|
1402
|
+
throw new EvalError("cannot access stack: out of bounds", expr);
|
1403
|
+
case 104:
|
1404
|
+
return _context2.abrupt("return", stackValue);
|
1405
|
+
case 107:
|
1406
|
+
if (!(expr.value === "()")) {
|
1407
|
+
_context2.next = 109;
|
1408
|
+
break;
|
1409
|
+
}
|
1410
|
+
return _context2.abrupt("return", newSelectorProxy(null));
|
1411
|
+
case 109:
|
1412
|
+
return _context2.abrupt("return", newSelectorProxy(expr.value));
|
1413
|
+
case 112:
|
1414
|
+
if (!(expr instanceof StringLiteral)) {
|
1415
|
+
_context2.next = 116;
|
1416
|
+
break;
|
1417
|
+
}
|
1418
|
+
return _context2.abrupt("return", newSelectorProxy(expr.value));
|
1419
|
+
case 116:
|
1420
|
+
if (!(expr instanceof StringTemplate)) {
|
1421
|
+
_context2.next = 122;
|
1422
|
+
break;
|
1423
|
+
}
|
1424
|
+
_context2.t2 = newSelectorProxy;
|
1425
|
+
_context2.next = 120;
|
1426
|
+
return Promise.all(expr.children.map( /*#__PURE__*/function () {
|
1427
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(child) {
|
1428
|
+
var evalRes;
|
1429
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
1430
|
+
while (1) switch (_context.prev = _context.next) {
|
1431
|
+
case 0:
|
1432
|
+
if (!(child instanceof Sym && child.value === "()")) {
|
1433
|
+
_context.next = 2;
|
1434
|
+
break;
|
1435
|
+
}
|
1436
|
+
return _context.abrupt("return", "null");
|
1437
|
+
case 2:
|
1438
|
+
_context.next = 4;
|
1439
|
+
return evaluateAsync(child, getSource, stack);
|
1440
|
+
case 4:
|
1441
|
+
evalRes = _context.sent;
|
1442
|
+
if (!(child.type === "StringLiteral" || child.type === "StringTemplate")) {
|
1443
|
+
_context.next = 7;
|
1444
|
+
break;
|
1445
|
+
}
|
1446
|
+
return _context.abrupt("return", evalRes[SourceOrExpr]);
|
1447
|
+
case 7:
|
1448
|
+
if (!(Path in evalRes)) {
|
1449
|
+
_context.next = 9;
|
1450
|
+
break;
|
1451
|
+
}
|
1452
|
+
return _context.abrupt("return", JSON.stringify({
|
1453
|
+
val: evalRes[SourceOrExpr],
|
1454
|
+
valPath: evalRes[Path]
|
1455
|
+
}));
|
1456
|
+
case 9:
|
1457
|
+
return _context.abrupt("return", JSON.stringify(evalRes[SourceOrExpr]));
|
1458
|
+
case 10:
|
1459
|
+
case "end":
|
1460
|
+
return _context.stop();
|
1461
|
+
}
|
1462
|
+
}, _callee);
|
1463
|
+
}));
|
1464
|
+
return function (_x7) {
|
1465
|
+
return _ref.apply(this, arguments);
|
1466
|
+
};
|
1467
|
+
}()).join(""));
|
1468
|
+
case 120:
|
1469
|
+
_context2.t3 = _context2.sent;
|
1470
|
+
return _context2.abrupt("return", (0, _context2.t2)(_context2.t3));
|
1471
|
+
case 122:
|
1472
|
+
throw new EvalError("could not evaluate", expr);
|
1473
|
+
case 123:
|
1474
|
+
case "end":
|
1475
|
+
return _context2.stop();
|
974
1476
|
}
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
throw new EvalError("could not evaluate", expr);
|
1477
|
+
}, _callee2, null, [[28, 36]]);
|
1478
|
+
}));
|
1479
|
+
return _evaluateAsync.apply(this, arguments);
|
979
1480
|
}
|
980
|
-
function evaluate(
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
1481
|
+
function evaluate(_x4, _x5, _x6) {
|
1482
|
+
return _evaluate.apply(this, arguments);
|
1483
|
+
}
|
1484
|
+
function _evaluate() {
|
1485
|
+
_evaluate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(expr, source, stack) {
|
1486
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
1487
|
+
while (1) switch (_context3.prev = _context3.next) {
|
1488
|
+
case 0:
|
1489
|
+
_context3.prev = 0;
|
1490
|
+
_context3.t0 = result;
|
1491
|
+
_context3.next = 4;
|
1492
|
+
return evaluateAsync(expr, source, stack);
|
1493
|
+
case 4:
|
1494
|
+
_context3.t1 = _context3.sent;
|
1495
|
+
return _context3.abrupt("return", _context3.t0.ok.call(_context3.t0, _context3.t1));
|
1496
|
+
case 8:
|
1497
|
+
_context3.prev = 8;
|
1498
|
+
_context3.t2 = _context3["catch"](0);
|
1499
|
+
if (!(_context3.t2 instanceof EvalError)) {
|
1500
|
+
_context3.next = 12;
|
1501
|
+
break;
|
1502
|
+
}
|
1503
|
+
return _context3.abrupt("return", err(_context3.t2));
|
1504
|
+
case 12:
|
1505
|
+
throw _context3.t2;
|
1506
|
+
case 13:
|
1507
|
+
case "end":
|
1508
|
+
return _context3.stop();
|
1509
|
+
}
|
1510
|
+
}, _callee3, null, [[0, 8]]);
|
1511
|
+
}));
|
1512
|
+
return _evaluate.apply(this, arguments);
|
989
1513
|
}
|
990
1514
|
|
991
1515
|
var index = /*#__PURE__*/Object.freeze({
|