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