@valbuild/core 0.21.1 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/declarations/src/ValApi.d.ts +2 -1
  2. package/dist/declarations/src/index.d.ts +21 -3
  3. package/dist/declarations/src/module.d.ts +11 -5
  4. package/dist/declarations/src/patch/deref.d.ts +0 -3
  5. package/dist/declarations/src/patch/operation.d.ts +2 -0
  6. package/dist/declarations/src/schema/string.d.ts +5 -1
  7. package/dist/{index-75b79c89.cjs.prod.js → index-30eee5ec.cjs.prod.js} +47 -43
  8. package/dist/{index-067cff4a.cjs.prod.js → index-425d164d.cjs.prod.js} +1 -1
  9. package/dist/{index-31991dd7.cjs.dev.js → index-43369070.cjs.dev.js} +47 -43
  10. package/dist/{index-4bb14a92.esm.js → index-499b9e87.esm.js} +47 -43
  11. package/dist/{index-d17f9503.cjs.dev.js → index-a0f36fe3.cjs.dev.js} +1 -1
  12. package/dist/{index-870205b5.esm.js → index-f0475164.esm.js} +1 -1
  13. package/dist/{ops-9b396073.esm.js → ops-1225f750.esm.js} +5 -2
  14. package/dist/{ops-0f7617a0.cjs.dev.js → ops-558f07b7.cjs.dev.js} +5 -2
  15. package/dist/{ops-451ffb3f.cjs.prod.js → ops-b263963e.cjs.prod.js} +5 -2
  16. package/dist/valbuild-core.cjs.dev.js +251 -240
  17. package/dist/valbuild-core.cjs.prod.js +251 -240
  18. package/dist/valbuild-core.esm.js +252 -241
  19. package/expr/dist/valbuild-core-expr.cjs.dev.js +2 -2
  20. package/expr/dist/valbuild-core-expr.cjs.prod.js +2 -2
  21. package/expr/dist/valbuild-core-expr.esm.js +2 -2
  22. package/package.json +1 -1
  23. package/patch/dist/valbuild-core-patch.cjs.dev.js +13 -3
  24. package/patch/dist/valbuild-core-patch.cjs.prod.js +13 -3
  25. package/patch/dist/valbuild-core-patch.esm.js +14 -4
  26. package/src/ValApi.ts +9 -13
  27. package/src/index.ts +23 -3
  28. package/src/module.ts +40 -14
  29. package/src/patch/deref.test.ts +130 -132
  30. package/src/patch/deref.ts +12 -17
  31. package/src/patch/operation.ts +2 -0
  32. package/src/patch/parse.ts +15 -1
  33. package/src/schema/image.ts +5 -3
  34. package/src/schema/string.ts +27 -2
@@ -2,9 +2,9 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var index = require('./index-31991dd7.cjs.dev.js');
6
- var ops = require('./ops-0f7617a0.cjs.dev.js');
7
- var expr_dist_valbuildCoreExpr = require('./index-d17f9503.cjs.dev.js');
5
+ var index = require('./index-43369070.cjs.dev.js');
6
+ var ops = require('./ops-558f07b7.cjs.dev.js');
7
+ var expr_dist_valbuildCoreExpr = require('./index-a0f36fe3.cjs.dev.js');
8
8
  var result = require('./result-48320acd.cjs.dev.js');
9
9
 
10
10
  var NumberSchema = /*#__PURE__*/function (_Schema) {
@@ -79,6 +79,7 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
79
79
  index._createClass(StringSchema, [{
80
80
  key: "validate",
81
81
  value: function validate(path, src) {
82
+ var _this$options, _this$options2;
82
83
  if (this.opt && (src === null || src === undefined)) {
83
84
  return false;
84
85
  }
@@ -88,6 +89,22 @@ var StringSchema = /*#__PURE__*/function (_Schema) {
88
89
  value: src
89
90
  }]);
90
91
  }
92
+ var errors = [];
93
+ if ((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.maxLength && src.length > this.options.maxLength) {
94
+ errors.push({
95
+ message: "Expected string to be at most ".concat(this.options.maxLength, " characters long, got ").concat(src.length),
96
+ value: src
97
+ });
98
+ }
99
+ if ((_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.minLength && src.length < this.options.minLength) {
100
+ errors.push({
101
+ message: "Expected string to be at least ".concat(this.options.minLength, " characters long, got ").concat(src.length),
102
+ value: src
103
+ });
104
+ }
105
+ if (errors.length > 0) {
106
+ return index._defineProperty({}, path, errors);
107
+ }
91
108
  return false;
92
109
  }
93
110
  }, {
@@ -454,15 +471,6 @@ var initVal = function initVal() {
454
471
  };
455
472
  };
456
473
 
457
- /**
458
- * Remote sources cannot include other remote sources.
459
- */
460
-
461
- var REMOTE_REF_PROP = "_ref"; // TODO: same as FILE_REF_PROP so use same prop?
462
- function isRemote(obj) {
463
- return index._typeof(obj) === "object" && obj !== null && index.VAL_EXTENSION in obj && obj[index.VAL_EXTENSION] === "remote" && REMOTE_REF_PROP in obj && typeof obj[REMOTE_REF_PROP] === "string";
464
- }
465
-
466
474
  function derefPath(path) {
467
475
  var dereffedPath = [];
468
476
  var referencedPath = null;
@@ -503,7 +511,6 @@ function derefPath(path) {
503
511
  return result.ok([dereffedPath, referencedPath]);
504
512
  }
505
513
  function derefPatch(patch, document, ops$1) {
506
- var remotePatches = {};
507
514
  var fileUpdates = {};
508
515
  var dereferencedPatch = [];
509
516
  var _iterator3 = result._createForOfIteratorHelper(patch),
@@ -531,15 +538,15 @@ function derefPatch(patch, document, ops$1) {
531
538
  return result.err(new ops.PatchError("Expected base64 encoded string value for file reference, got ".concat(JSON.stringify(op.value))));
532
539
  }
533
540
  fileUpdates[value[index.FILE_REF_PROP]] = op.value;
534
- } else if (isRemote(value)) {
535
- if (!remotePatches[value[REMOTE_REF_PROP]]) {
536
- remotePatches[value[REMOTE_REF_PROP]] = [];
537
- }
538
- remotePatches[value[REMOTE_REF_PROP]].push({
539
- op: "replace",
540
- path: referencedPath,
541
- value: op.value
542
- });
541
+ // } else if (isRemote(value)) {
542
+ // if (!remotePatches[value[REMOTE_REF_PROP]]) {
543
+ // remotePatches[value[REMOTE_REF_PROP]] = [];
544
+ // }
545
+ // remotePatches[value[REMOTE_REF_PROP]].push({
546
+ // op: "replace",
547
+ // path: referencedPath,
548
+ // value: op.value,
549
+ // });
543
550
  } else {
544
551
  return result.err(new ops.PatchError("Unknown reference: ".concat(JSON.stringify(op), " at path: ").concat(dereffedPath.join("/"))));
545
552
  }
@@ -550,13 +557,13 @@ function derefPatch(patch, document, ops$1) {
550
557
  dereferencedPatch.push(op);
551
558
  }
552
559
  } else if (op.op === "file") {
553
- if (op.path[0] !== "public") {
554
- return result.err(new ops.PatchError("Path must start with public"));
560
+ if (!op.filePath.startsWith("/public")) {
561
+ return result.err(new ops.PatchError("Path must start with /public"));
555
562
  }
556
563
  if (typeof op.value !== "string") {
557
564
  return result.err(new ops.PatchError("File operation must have a value that is typeof string. Found: ".concat(index._typeof(op.value))));
558
565
  }
559
- fileUpdates["/".concat(op.path.join("/"))] = op.value;
566
+ fileUpdates[op.filePath] = op.value;
560
567
  } else {
561
568
  var _maybeDerefRes = derefPath(op.path);
562
569
  if (result.isErr(_maybeDerefRes)) {
@@ -576,7 +583,6 @@ function derefPatch(patch, document, ops$1) {
576
583
  _iterator3.f();
577
584
  }
578
585
  return result.ok({
579
- remotePatches: remotePatches,
580
586
  fileUpdates: fileUpdates,
581
587
  dereferencedPatch: dereferencedPatch
582
588
  });
@@ -719,304 +725,304 @@ function hasOwn(obj, prop) {
719
725
 
720
726
  function _regeneratorRuntime() {
721
727
  _regeneratorRuntime = function () {
722
- return exports;
728
+ return e;
723
729
  };
724
- var exports = {},
725
- Op = Object.prototype,
726
- hasOwn = Op.hasOwnProperty,
727
- defineProperty = Object.defineProperty || function (obj, key, desc) {
728
- obj[key] = desc.value;
730
+ var t,
731
+ e = {},
732
+ r = Object.prototype,
733
+ n = r.hasOwnProperty,
734
+ o = Object.defineProperty || function (t, e, r) {
735
+ t[e] = r.value;
729
736
  },
730
- $Symbol = "function" == typeof Symbol ? Symbol : {},
731
- iteratorSymbol = $Symbol.iterator || "@@iterator",
732
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
733
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
734
- function define(obj, key, value) {
735
- return Object.defineProperty(obj, key, {
736
- value: value,
737
+ i = "function" == typeof Symbol ? Symbol : {},
738
+ a = i.iterator || "@@iterator",
739
+ c = i.asyncIterator || "@@asyncIterator",
740
+ u = i.toStringTag || "@@toStringTag";
741
+ function define(t, e, r) {
742
+ return Object.defineProperty(t, e, {
743
+ value: r,
737
744
  enumerable: !0,
738
745
  configurable: !0,
739
746
  writable: !0
740
- }), obj[key];
747
+ }), t[e];
741
748
  }
742
749
  try {
743
750
  define({}, "");
744
- } catch (err) {
745
- define = function (obj, key, value) {
746
- return obj[key] = value;
751
+ } catch (t) {
752
+ define = function (t, e, r) {
753
+ return t[e] = r;
747
754
  };
748
755
  }
749
- function wrap(innerFn, outerFn, self, tryLocsList) {
750
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
751
- generator = Object.create(protoGenerator.prototype),
752
- context = new Context(tryLocsList || []);
753
- return defineProperty(generator, "_invoke", {
754
- value: makeInvokeMethod(innerFn, self, context)
755
- }), generator;
756
+ function wrap(t, e, r, n) {
757
+ var i = e && e.prototype instanceof Generator ? e : Generator,
758
+ a = Object.create(i.prototype),
759
+ c = new Context(n || []);
760
+ return o(a, "_invoke", {
761
+ value: makeInvokeMethod(t, r, c)
762
+ }), a;
756
763
  }
757
- function tryCatch(fn, obj, arg) {
764
+ function tryCatch(t, e, r) {
758
765
  try {
759
766
  return {
760
767
  type: "normal",
761
- arg: fn.call(obj, arg)
768
+ arg: t.call(e, r)
762
769
  };
763
- } catch (err) {
770
+ } catch (t) {
764
771
  return {
765
772
  type: "throw",
766
- arg: err
773
+ arg: t
767
774
  };
768
775
  }
769
776
  }
770
- exports.wrap = wrap;
771
- var ContinueSentinel = {};
777
+ e.wrap = wrap;
778
+ var h = "suspendedStart",
779
+ l = "suspendedYield",
780
+ f = "executing",
781
+ s = "completed",
782
+ y = {};
772
783
  function Generator() {}
773
784
  function GeneratorFunction() {}
774
785
  function GeneratorFunctionPrototype() {}
775
- var IteratorPrototype = {};
776
- define(IteratorPrototype, iteratorSymbol, function () {
786
+ var p = {};
787
+ define(p, a, function () {
777
788
  return this;
778
789
  });
779
- var getProto = Object.getPrototypeOf,
780
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
781
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
782
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
783
- function defineIteratorMethods(prototype) {
784
- ["next", "throw", "return"].forEach(function (method) {
785
- define(prototype, method, function (arg) {
786
- return this._invoke(method, arg);
790
+ var d = Object.getPrototypeOf,
791
+ v = d && d(d(values([])));
792
+ v && v !== r && n.call(v, a) && (p = v);
793
+ var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
794
+ function defineIteratorMethods(t) {
795
+ ["next", "throw", "return"].forEach(function (e) {
796
+ define(t, e, function (t) {
797
+ return this._invoke(e, t);
787
798
  });
788
799
  });
789
800
  }
790
- function AsyncIterator(generator, PromiseImpl) {
791
- function invoke(method, arg, resolve, reject) {
792
- var record = tryCatch(generator[method], generator, arg);
793
- if ("throw" !== record.type) {
794
- var result = record.arg,
795
- value = result.value;
796
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
797
- invoke("next", value, resolve, reject);
798
- }, function (err) {
799
- invoke("throw", err, resolve, reject);
800
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
801
- result.value = unwrapped, resolve(result);
802
- }, function (error) {
803
- return invoke("throw", error, resolve, reject);
801
+ function AsyncIterator(t, e) {
802
+ function invoke(r, o, i, a) {
803
+ var c = tryCatch(t[r], t, o);
804
+ if ("throw" !== c.type) {
805
+ var u = c.arg,
806
+ h = u.value;
807
+ return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
808
+ invoke("next", t, i, a);
809
+ }, function (t) {
810
+ invoke("throw", t, i, a);
811
+ }) : e.resolve(h).then(function (t) {
812
+ u.value = t, i(u);
813
+ }, function (t) {
814
+ return invoke("throw", t, i, a);
804
815
  });
805
816
  }
806
- reject(record.arg);
817
+ a(c.arg);
807
818
  }
808
- var previousPromise;
809
- defineProperty(this, "_invoke", {
810
- value: function (method, arg) {
819
+ var r;
820
+ o(this, "_invoke", {
821
+ value: function (t, n) {
811
822
  function callInvokeWithMethodAndArg() {
812
- return new PromiseImpl(function (resolve, reject) {
813
- invoke(method, arg, resolve, reject);
823
+ return new e(function (e, r) {
824
+ invoke(t, n, e, r);
814
825
  });
815
826
  }
816
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
827
+ return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
817
828
  }
818
829
  });
819
830
  }
820
- function makeInvokeMethod(innerFn, self, context) {
821
- var state = "suspendedStart";
822
- return function (method, arg) {
823
- if ("executing" === state) throw new Error("Generator is already running");
824
- if ("completed" === state) {
825
- if ("throw" === method) throw arg;
826
- return doneResult();
831
+ function makeInvokeMethod(e, r, n) {
832
+ var o = h;
833
+ return function (i, a) {
834
+ if (o === f) throw new Error("Generator is already running");
835
+ if (o === s) {
836
+ if ("throw" === i) throw a;
837
+ return {
838
+ value: t,
839
+ done: !0
840
+ };
827
841
  }
828
- for (context.method = method, context.arg = arg;;) {
829
- var delegate = context.delegate;
830
- if (delegate) {
831
- var delegateResult = maybeInvokeDelegate(delegate, context);
832
- if (delegateResult) {
833
- if (delegateResult === ContinueSentinel) continue;
834
- return delegateResult;
842
+ for (n.method = i, n.arg = a;;) {
843
+ var c = n.delegate;
844
+ if (c) {
845
+ var u = maybeInvokeDelegate(c, n);
846
+ if (u) {
847
+ if (u === y) continue;
848
+ return u;
835
849
  }
836
850
  }
837
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
838
- if ("suspendedStart" === state) throw state = "completed", context.arg;
839
- context.dispatchException(context.arg);
840
- } else "return" === context.method && context.abrupt("return", context.arg);
841
- state = "executing";
842
- var record = tryCatch(innerFn, self, context);
843
- if ("normal" === record.type) {
844
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
851
+ if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
852
+ if (o === h) throw o = s, n.arg;
853
+ n.dispatchException(n.arg);
854
+ } else "return" === n.method && n.abrupt("return", n.arg);
855
+ o = f;
856
+ var p = tryCatch(e, r, n);
857
+ if ("normal" === p.type) {
858
+ if (o = n.done ? s : l, p.arg === y) continue;
845
859
  return {
846
- value: record.arg,
847
- done: context.done
860
+ value: p.arg,
861
+ done: n.done
848
862
  };
849
863
  }
850
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
864
+ "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
851
865
  }
852
866
  };
853
867
  }
854
- function maybeInvokeDelegate(delegate, context) {
855
- var methodName = context.method,
856
- method = delegate.iterator[methodName];
857
- 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;
858
- var record = tryCatch(method, delegate.iterator, context.arg);
859
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
860
- var info = record.arg;
861
- 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);
868
+ function maybeInvokeDelegate(e, r) {
869
+ var n = r.method,
870
+ o = e.iterator[n];
871
+ if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
872
+ var i = tryCatch(o, e.iterator, r.arg);
873
+ if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
874
+ var a = i.arg;
875
+ return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
862
876
  }
863
- function pushTryEntry(locs) {
864
- var entry = {
865
- tryLoc: locs[0]
877
+ function pushTryEntry(t) {
878
+ var e = {
879
+ tryLoc: t[0]
866
880
  };
867
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
881
+ 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
868
882
  }
869
- function resetTryEntry(entry) {
870
- var record = entry.completion || {};
871
- record.type = "normal", delete record.arg, entry.completion = record;
883
+ function resetTryEntry(t) {
884
+ var e = t.completion || {};
885
+ e.type = "normal", delete e.arg, t.completion = e;
872
886
  }
873
- function Context(tryLocsList) {
887
+ function Context(t) {
874
888
  this.tryEntries = [{
875
889
  tryLoc: "root"
876
- }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
890
+ }], t.forEach(pushTryEntry, this), this.reset(!0);
877
891
  }
878
- function values(iterable) {
879
- if (iterable) {
880
- var iteratorMethod = iterable[iteratorSymbol];
881
- if (iteratorMethod) return iteratorMethod.call(iterable);
882
- if ("function" == typeof iterable.next) return iterable;
883
- if (!isNaN(iterable.length)) {
884
- var i = -1,
885
- next = function next() {
886
- for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
887
- return next.value = undefined, next.done = !0, next;
892
+ function values(e) {
893
+ if (e || "" === e) {
894
+ var r = e[a];
895
+ if (r) return r.call(e);
896
+ if ("function" == typeof e.next) return e;
897
+ if (!isNaN(e.length)) {
898
+ var o = -1,
899
+ i = function next() {
900
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
901
+ return next.value = t, next.done = !0, next;
888
902
  };
889
- return next.next = next;
903
+ return i.next = i;
890
904
  }
891
905
  }
892
- return {
893
- next: doneResult
894
- };
895
- }
896
- function doneResult() {
897
- return {
898
- value: undefined,
899
- done: !0
900
- };
906
+ throw new TypeError(typeof e + " is not iterable");
901
907
  }
902
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", {
908
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
903
909
  value: GeneratorFunctionPrototype,
904
910
  configurable: !0
905
- }), defineProperty(GeneratorFunctionPrototype, "constructor", {
911
+ }), o(GeneratorFunctionPrototype, "constructor", {
906
912
  value: GeneratorFunction,
907
913
  configurable: !0
908
- }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
909
- var ctor = "function" == typeof genFun && genFun.constructor;
910
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
911
- }, exports.mark = function (genFun) {
912
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
913
- }, exports.awrap = function (arg) {
914
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
915
+ var e = "function" == typeof t && t.constructor;
916
+ return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
917
+ }, e.mark = function (t) {
918
+ return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
919
+ }, e.awrap = function (t) {
914
920
  return {
915
- __await: arg
921
+ __await: t
916
922
  };
917
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
923
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
918
924
  return this;
919
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
920
- void 0 === PromiseImpl && (PromiseImpl = Promise);
921
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
922
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
923
- return result.done ? result.value : iter.next();
925
+ }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
926
+ void 0 === i && (i = Promise);
927
+ var a = new AsyncIterator(wrap(t, r, n, o), i);
928
+ return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
929
+ return t.done ? t.value : a.next();
924
930
  });
925
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
931
+ }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
926
932
  return this;
927
- }), define(Gp, "toString", function () {
933
+ }), define(g, "toString", function () {
928
934
  return "[object Generator]";
929
- }), exports.keys = function (val) {
930
- var object = Object(val),
931
- keys = [];
932
- for (var key in object) keys.push(key);
933
- return keys.reverse(), function next() {
934
- for (; keys.length;) {
935
- var key = keys.pop();
936
- if (key in object) return next.value = key, next.done = !1, next;
935
+ }), e.keys = function (t) {
936
+ var e = Object(t),
937
+ r = [];
938
+ for (var n in e) r.push(n);
939
+ return r.reverse(), function next() {
940
+ for (; r.length;) {
941
+ var t = r.pop();
942
+ if (t in e) return next.value = t, next.done = !1, next;
937
943
  }
938
944
  return next.done = !0, next;
939
945
  };
940
- }, exports.values = values, Context.prototype = {
946
+ }, e.values = values, Context.prototype = {
941
947
  constructor: Context,
942
- reset: function (skipTempReset) {
943
- 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);
948
+ reset: function (e) {
949
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
944
950
  },
945
951
  stop: function () {
946
952
  this.done = !0;
947
- var rootRecord = this.tryEntries[0].completion;
948
- if ("throw" === rootRecord.type) throw rootRecord.arg;
953
+ var t = this.tryEntries[0].completion;
954
+ if ("throw" === t.type) throw t.arg;
949
955
  return this.rval;
950
956
  },
951
- dispatchException: function (exception) {
952
- if (this.done) throw exception;
953
- var context = this;
954
- function handle(loc, caught) {
955
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
957
+ dispatchException: function (e) {
958
+ if (this.done) throw e;
959
+ var r = this;
960
+ function handle(n, o) {
961
+ return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
956
962
  }
957
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
958
- var entry = this.tryEntries[i],
959
- record = entry.completion;
960
- if ("root" === entry.tryLoc) return handle("end");
961
- if (entry.tryLoc <= this.prev) {
962
- var hasCatch = hasOwn.call(entry, "catchLoc"),
963
- hasFinally = hasOwn.call(entry, "finallyLoc");
964
- if (hasCatch && hasFinally) {
965
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
966
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
967
- } else if (hasCatch) {
968
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
963
+ for (var o = this.tryEntries.length - 1; o >= 0; --o) {
964
+ var i = this.tryEntries[o],
965
+ a = i.completion;
966
+ if ("root" === i.tryLoc) return handle("end");
967
+ if (i.tryLoc <= this.prev) {
968
+ var c = n.call(i, "catchLoc"),
969
+ u = n.call(i, "finallyLoc");
970
+ if (c && u) {
971
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
972
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
973
+ } else if (c) {
974
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
969
975
  } else {
970
- if (!hasFinally) throw new Error("try statement without catch or finally");
971
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
976
+ if (!u) throw new Error("try statement without catch or finally");
977
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
972
978
  }
973
979
  }
974
980
  }
975
981
  },
976
- abrupt: function (type, arg) {
977
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
978
- var entry = this.tryEntries[i];
979
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
980
- var finallyEntry = entry;
982
+ abrupt: function (t, e) {
983
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
984
+ var o = this.tryEntries[r];
985
+ if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
986
+ var i = o;
981
987
  break;
982
988
  }
983
989
  }
984
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
985
- var record = finallyEntry ? finallyEntry.completion : {};
986
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
990
+ i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
991
+ var a = i ? i.completion : {};
992
+ return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
987
993
  },
988
- complete: function (record, afterLoc) {
989
- if ("throw" === record.type) throw record.arg;
990
- 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;
994
+ complete: function (t, e) {
995
+ if ("throw" === t.type) throw t.arg;
996
+ return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
991
997
  },
992
- finish: function (finallyLoc) {
993
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
994
- var entry = this.tryEntries[i];
995
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
998
+ finish: function (t) {
999
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
1000
+ var r = this.tryEntries[e];
1001
+ if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
996
1002
  }
997
1003
  },
998
- catch: function (tryLoc) {
999
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
1000
- var entry = this.tryEntries[i];
1001
- if (entry.tryLoc === tryLoc) {
1002
- var record = entry.completion;
1003
- if ("throw" === record.type) {
1004
- var thrown = record.arg;
1005
- resetTryEntry(entry);
1004
+ catch: function (t) {
1005
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
1006
+ var r = this.tryEntries[e];
1007
+ if (r.tryLoc === t) {
1008
+ var n = r.completion;
1009
+ if ("throw" === n.type) {
1010
+ var o = n.arg;
1011
+ resetTryEntry(r);
1006
1012
  }
1007
- return thrown;
1013
+ return o;
1008
1014
  }
1009
1015
  }
1010
1016
  throw new Error("illegal catch attempt");
1011
1017
  },
1012
- delegateYield: function (iterable, resultName, nextLoc) {
1018
+ delegateYield: function (e, r, n) {
1013
1019
  return this.delegate = {
1014
- iterator: values(iterable),
1015
- resultName: resultName,
1016
- nextLoc: nextLoc
1017
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
1020
+ iterator: values(e),
1021
+ resultName: r,
1022
+ nextLoc: n
1023
+ }, "next" === this.method && (this.arg = t), y;
1018
1024
  }
1019
- }, exports;
1025
+ }, e;
1020
1026
  }
1021
1027
 
1022
1028
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -1087,27 +1093,30 @@ var ValApi = /*#__PURE__*/function () {
1087
1093
  value: function getDisableUrl() {
1088
1094
  return "".concat(this.host, "/disable");
1089
1095
  }
1096
+ }, {
1097
+ key: "getEditUrl",
1098
+ value: function getEditUrl() {
1099
+ return "".concat(this.host, "/static/edit");
1100
+ }
1090
1101
  }, {
1091
1102
  key: "postPatches",
1092
- value: function postPatches(moduleId, patches, commit, headers) {
1093
- var params = "";
1094
- if (commit) {
1095
- var p = new URLSearchParams();
1096
- p.set("commit", commit);
1097
- params = "?".concat(p.toString());
1098
- }
1099
- return fetch("".concat(this.host, "/patches/~").concat(moduleId).concat(params), {
1103
+ value: function postPatches(moduleId, patches, headers) {
1104
+ return fetch("".concat(this.host, "/patches/~"), {
1100
1105
  headers: headers || {
1101
1106
  "Content-Type": "application/json"
1102
1107
  },
1103
1108
  method: "POST",
1104
- body: JSON.stringify(patches)
1105
- }).then(parse);
1109
+ body: JSON.stringify(index._defineProperty({}, moduleId, patches))
1110
+ }).then(function (res) {
1111
+ return parse(res);
1112
+ });
1106
1113
  }
1107
1114
  }, {
1108
1115
  key: "getSession",
1109
1116
  value: function getSession() {
1110
- return fetch("".concat(this.host, "/session")).then(parse);
1117
+ return fetch("".concat(this.host, "/session")).then(function (res) {
1118
+ return parse(res);
1119
+ });
1111
1120
  }
1112
1121
  }, {
1113
1122
  key: "getModules",
@@ -1127,7 +1136,9 @@ var ValApi = /*#__PURE__*/function () {
1127
1136
  params.set("source", includeSource.toString());
1128
1137
  return fetch("".concat(this.host, "/tree/~").concat(treePath, "?").concat(params.toString()), {
1129
1138
  headers: headers
1130
- }).then(parse);
1139
+ }).then(function (res) {
1140
+ return parse(res);
1141
+ });
1131
1142
  }
1132
1143
  }]);
1133
1144
  return ValApi;