@valbuild/core 0.40.0 → 0.41.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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var ops = require('./ops-6489efeb.cjs.prod.js');
5
+ var ops = require('./ops-d88e99cd.cjs.prod.js');
6
6
  var index = require('./index-5bdaa229.cjs.prod.js');
7
7
  var expr_dist_valbuildCoreExpr = require('./index-216627d7.cjs.prod.js');
8
8
  var result = require('./result-26f67b40.cjs.prod.js');
@@ -348,14 +348,34 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
348
348
  }, {
349
349
  key: "serialize",
350
350
  value: function serialize() {
351
+ var _this$selector$GetSch;
351
352
  var path = index.getValPath(this.selector);
352
353
  if (!path) {
353
354
  throw new Error("Cannot serialize keyOf schema with empty selector. TIP: keyOf must be used with a Val Module.");
354
355
  }
356
+ var serializedSubSchema = (_this$selector$GetSch = this.selector[index.GetSchema]) === null || _this$selector$GetSch === void 0 ? void 0 : _this$selector$GetSch.serialize();
357
+ if (!serializedSubSchema) {
358
+ throw new Error("Cannot serialize oneOf schema with empty selector.");
359
+ }
360
+ var values;
361
+ switch (serializedSubSchema.type) {
362
+ case "array":
363
+ values = "number";
364
+ break;
365
+ case "record":
366
+ values = "string";
367
+ break;
368
+ case "object":
369
+ values = Object.keys(serializedSubSchema.items);
370
+ break;
371
+ default:
372
+ throw new Error("Cannot serialize oneOf schema with selector of type '".concat(serializedSubSchema.type, "'. keyOf must be used with a Val Module."));
373
+ }
355
374
  return {
356
375
  type: "keyOf",
357
376
  selector: path,
358
- opt: this.opt
377
+ opt: this.opt,
378
+ values: values
359
379
  };
360
380
  }
361
381
  }]);
@@ -723,6 +743,339 @@ function hasOwn(obj, prop) {
723
743
  return Object.prototype.hasOwnProperty.call(obj, prop);
724
744
  }
725
745
 
746
+ /**
747
+ * From: https://github.com/kawanet/sha256-uint8array/commit/a035f83824c319d01ca1e7559fdcf1632c0cd6c4
748
+ *
749
+ * LICENSE:
750
+ *
751
+ * MIT License
752
+ * Copyright (c) 2020-2023 Yusuke Kawasaki
753
+ *
754
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
755
+ * of this software and associated documentation files (the "Software"), to deal
756
+ * in the Software without restriction, including without limitation the rights
757
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
758
+ * copies of the Software, and to permit persons to whom the Software is
759
+ * furnished to do so, subject to the following conditions:
760
+ *
761
+ * The above copyright notice and this permission notice shall be included in all
762
+ * copies or substantial portions of the Software.
763
+ *
764
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
765
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
766
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
767
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
768
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
769
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
770
+ * SOFTWARE.
771
+ *
772
+ * sha256-uint8array.ts
773
+ */
774
+
775
+ // first 32 bits of the fractional parts of the cube roots of the first 64 primes 2..311
776
+ var K = [0x428a2f98 | 0, 0x71374491 | 0, 0xb5c0fbcf | 0, 0xe9b5dba5 | 0, 0x3956c25b | 0, 0x59f111f1 | 0, 0x923f82a4 | 0, 0xab1c5ed5 | 0, 0xd807aa98 | 0, 0x12835b01 | 0, 0x243185be | 0, 0x550c7dc3 | 0, 0x72be5d74 | 0, 0x80deb1fe | 0, 0x9bdc06a7 | 0, 0xc19bf174 | 0, 0xe49b69c1 | 0, 0xefbe4786 | 0, 0x0fc19dc6 | 0, 0x240ca1cc | 0, 0x2de92c6f | 0, 0x4a7484aa | 0, 0x5cb0a9dc | 0, 0x76f988da | 0, 0x983e5152 | 0, 0xa831c66d | 0, 0xb00327c8 | 0, 0xbf597fc7 | 0, 0xc6e00bf3 | 0, 0xd5a79147 | 0, 0x06ca6351 | 0, 0x14292967 | 0, 0x27b70a85 | 0, 0x2e1b2138 | 0, 0x4d2c6dfc | 0, 0x53380d13 | 0, 0x650a7354 | 0, 0x766a0abb | 0, 0x81c2c92e | 0, 0x92722c85 | 0, 0xa2bfe8a1 | 0, 0xa81a664b | 0, 0xc24b8b70 | 0, 0xc76c51a3 | 0, 0xd192e819 | 0, 0xd6990624 | 0, 0xf40e3585 | 0, 0x106aa070 | 0, 0x19a4c116 | 0, 0x1e376c08 | 0, 0x2748774c | 0, 0x34b0bcb5 | 0, 0x391c0cb3 | 0, 0x4ed8aa4a | 0, 0x5b9cca4f | 0, 0x682e6ff3 | 0, 0x748f82ee | 0, 0x78a5636f | 0, 0x84c87814 | 0, 0x8cc70208 | 0, 0x90befffa | 0, 0xa4506ceb | 0, 0xbef9a3f7 | 0, 0xc67178f2 | 0];
777
+ var N = /*#__PURE__*/function (N) {
778
+ N[N["inputBytes"] = 64] = "inputBytes";
779
+ N[N["inputWords"] = 16] = "inputWords";
780
+ N[N["highIndex"] = 14] = "highIndex";
781
+ N[N["lowIndex"] = 15] = "lowIndex";
782
+ N[N["workWords"] = 64] = "workWords";
783
+ N[N["allocBytes"] = 80] = "allocBytes";
784
+ N[N["allocWords"] = 20] = "allocWords";
785
+ N[N["allocTotal"] = 8000] = "allocTotal";
786
+ return N;
787
+ }(N || {});
788
+ var algorithms = {
789
+ sha256: 1
790
+ };
791
+ function createHash(algorithm) {
792
+ if (algorithm && !algorithms[algorithm] && !algorithms[algorithm.toLowerCase()]) {
793
+ throw new Error("Digest method not supported");
794
+ }
795
+ return new Hash();
796
+ }
797
+ var Hash = /*#__PURE__*/function () {
798
+ // surrogate pair
799
+
800
+ function Hash() {
801
+ index._classCallCheck(this, Hash);
802
+ // first 32 bits of the fractional parts of the square roots of the first 8 primes 2..19
803
+ index._defineProperty(this, "A", 0x6a09e667 | 0);
804
+ index._defineProperty(this, "B", 0xbb67ae85 | 0);
805
+ index._defineProperty(this, "C", 0x3c6ef372 | 0);
806
+ index._defineProperty(this, "D", 0xa54ff53a | 0);
807
+ index._defineProperty(this, "E", 0x510e527f | 0);
808
+ index._defineProperty(this, "F", 0x9b05688c | 0);
809
+ index._defineProperty(this, "G", 0x1f83d9ab | 0);
810
+ index._defineProperty(this, "H", 0x5be0cd19 | 0);
811
+ index._defineProperty(this, "_size", 0);
812
+ index._defineProperty(this, "_sp", 0);
813
+ if (!sharedBuffer || sharedOffset >= N.allocTotal) {
814
+ sharedBuffer = new ArrayBuffer(N.allocTotal);
815
+ sharedOffset = 0;
816
+ }
817
+ this._byte = new Uint8Array(sharedBuffer, sharedOffset, N.allocBytes);
818
+ this._word = new Int32Array(sharedBuffer, sharedOffset, N.allocWords);
819
+ sharedOffset += N.allocBytes;
820
+ }
821
+ index._createClass(Hash, [{
822
+ key: "update",
823
+ value: function update(data) {
824
+ // data: string
825
+ if ("string" === typeof data) {
826
+ return this._utf8(data);
827
+ }
828
+
829
+ // data: undefined
830
+ if (data == null) {
831
+ throw new TypeError("Invalid type: " + index._typeof(data));
832
+ }
833
+ var byteOffset = data.byteOffset;
834
+ var length = data.byteLength;
835
+ var blocks = length / N.inputBytes | 0;
836
+ var offset = 0;
837
+
838
+ // longer than 1 block
839
+ if (blocks && !(byteOffset & 3) && !(this._size % N.inputBytes)) {
840
+ var block = new Int32Array(data.buffer, byteOffset, blocks * N.inputWords);
841
+ while (blocks--) {
842
+ this._int32(block, offset >> 2);
843
+ offset += N.inputBytes;
844
+ }
845
+ this._size += offset;
846
+ }
847
+
848
+ // data: TypedArray | DataView
849
+ var BYTES_PER_ELEMENT = data.BYTES_PER_ELEMENT;
850
+ if (BYTES_PER_ELEMENT !== 1 && data.buffer) {
851
+ var rest = new Uint8Array(data.buffer, byteOffset + offset, length - offset);
852
+ return this._uint8(rest);
853
+ }
854
+
855
+ // no more bytes
856
+ if (offset === length) return this;
857
+
858
+ // data: Uint8Array | Int8Array
859
+ return this._uint8(data, offset);
860
+ }
861
+ }, {
862
+ key: "_uint8",
863
+ value: function _uint8(data, offset) {
864
+ var _byte = this._byte,
865
+ _word = this._word;
866
+ var length = data.length;
867
+ offset = offset | 0;
868
+ while (offset < length) {
869
+ var start = this._size % N.inputBytes;
870
+ var index = start;
871
+ while (offset < length && index < N.inputBytes) {
872
+ _byte[index++] = data[offset++];
873
+ }
874
+ if (index >= N.inputBytes) {
875
+ this._int32(_word);
876
+ }
877
+ this._size += index - start;
878
+ }
879
+ return this;
880
+ }
881
+ }, {
882
+ key: "_utf8",
883
+ value: function _utf8(text) {
884
+ var _byte = this._byte,
885
+ _word = this._word;
886
+ var length = text.length;
887
+ var surrogate = this._sp;
888
+ for (var offset = 0; offset < length;) {
889
+ var start = this._size % N.inputBytes;
890
+ var index = start;
891
+ while (offset < length && index < N.inputBytes) {
892
+ var code = text.charCodeAt(offset++) | 0;
893
+ if (code < 0x80) {
894
+ // ASCII characters
895
+ _byte[index++] = code;
896
+ } else if (code < 0x800) {
897
+ // 2 bytes
898
+ _byte[index++] = 0xc0 | code >>> 6;
899
+ _byte[index++] = 0x80 | code & 0x3f;
900
+ } else if (code < 0xd800 || code > 0xdfff) {
901
+ // 3 bytes
902
+ _byte[index++] = 0xe0 | code >>> 12;
903
+ _byte[index++] = 0x80 | code >>> 6 & 0x3f;
904
+ _byte[index++] = 0x80 | code & 0x3f;
905
+ } else if (surrogate) {
906
+ // 4 bytes - surrogate pair
907
+ code = ((surrogate & 0x3ff) << 10) + (code & 0x3ff) + 0x10000;
908
+ _byte[index++] = 0xf0 | code >>> 18;
909
+ _byte[index++] = 0x80 | code >>> 12 & 0x3f;
910
+ _byte[index++] = 0x80 | code >>> 6 & 0x3f;
911
+ _byte[index++] = 0x80 | code & 0x3f;
912
+ surrogate = 0;
913
+ } else {
914
+ surrogate = code;
915
+ }
916
+ }
917
+ if (index >= N.inputBytes) {
918
+ this._int32(_word);
919
+ _word[0] = _word[N.inputWords];
920
+ }
921
+ this._size += index - start;
922
+ }
923
+ this._sp = surrogate;
924
+ return this;
925
+ }
926
+ }, {
927
+ key: "_int32",
928
+ value: function _int32(data, offset) {
929
+ var A = this.A,
930
+ B = this.B,
931
+ C = this.C,
932
+ D = this.D,
933
+ E = this.E,
934
+ F = this.F,
935
+ G = this.G,
936
+ H = this.H;
937
+ var i = 0;
938
+ offset = offset | 0;
939
+ while (i < N.inputWords) {
940
+ W[i++] = swap32(data[offset++]);
941
+ }
942
+ for (i = N.inputWords; i < N.workWords; i++) {
943
+ W[i] = gamma1(W[i - 2]) + W[i - 7] + gamma0(W[i - 15]) + W[i - 16] | 0;
944
+ }
945
+ for (i = 0; i < N.workWords; i++) {
946
+ var T1 = H + sigma1(E) + ch(E, F, G) + K[i] + W[i] | 0;
947
+ var T2 = sigma0(A) + maj(A, B, C) | 0;
948
+ H = G;
949
+ G = F;
950
+ F = E;
951
+ E = D + T1 | 0;
952
+ D = C;
953
+ C = B;
954
+ B = A;
955
+ A = T1 + T2 | 0;
956
+ }
957
+ this.A = A + this.A | 0;
958
+ this.B = B + this.B | 0;
959
+ this.C = C + this.C | 0;
960
+ this.D = D + this.D | 0;
961
+ this.E = E + this.E | 0;
962
+ this.F = F + this.F | 0;
963
+ this.G = G + this.G | 0;
964
+ this.H = H + this.H | 0;
965
+ }
966
+ }, {
967
+ key: "digest",
968
+ value: function digest(encoding) {
969
+ var _byte = this._byte,
970
+ _word = this._word;
971
+ var i = this._size % N.inputBytes | 0;
972
+ _byte[i++] = 0x80;
973
+
974
+ // pad 0 for current word
975
+ while (i & 3) {
976
+ _byte[i++] = 0;
977
+ }
978
+ i >>= 2;
979
+ if (i > N.highIndex) {
980
+ while (i < N.inputWords) {
981
+ _word[i++] = 0;
982
+ }
983
+ i = 0;
984
+ this._int32(_word);
985
+ }
986
+
987
+ // pad 0 for rest words
988
+ while (i < N.inputWords) {
989
+ _word[i++] = 0;
990
+ }
991
+
992
+ // input size
993
+ var bits64 = this._size * 8;
994
+ var low32 = (bits64 & 0xffffffff) >>> 0;
995
+ var high32 = (bits64 - low32) / 0x100000000;
996
+ if (high32) _word[N.highIndex] = swap32(high32);
997
+ if (low32) _word[N.lowIndex] = swap32(low32);
998
+ this._int32(_word);
999
+ return encoding === "hex" ? this._hex() : this._bin();
1000
+ }
1001
+ }, {
1002
+ key: "_hex",
1003
+ value: function _hex() {
1004
+ var A = this.A,
1005
+ B = this.B,
1006
+ C = this.C,
1007
+ D = this.D,
1008
+ E = this.E,
1009
+ F = this.F,
1010
+ G = this.G,
1011
+ H = this.H;
1012
+ return hex32(A) + hex32(B) + hex32(C) + hex32(D) + hex32(E) + hex32(F) + hex32(G) + hex32(H);
1013
+ }
1014
+ }, {
1015
+ key: "_bin",
1016
+ value: function _bin() {
1017
+ var A = this.A,
1018
+ B = this.B,
1019
+ C = this.C,
1020
+ D = this.D,
1021
+ E = this.E,
1022
+ F = this.F,
1023
+ G = this.G,
1024
+ H = this.H,
1025
+ _byte = this._byte,
1026
+ _word = this._word;
1027
+ _word[0] = swap32(A);
1028
+ _word[1] = swap32(B);
1029
+ _word[2] = swap32(C);
1030
+ _word[3] = swap32(D);
1031
+ _word[4] = swap32(E);
1032
+ _word[5] = swap32(F);
1033
+ _word[6] = swap32(G);
1034
+ _word[7] = swap32(H);
1035
+ return _byte.slice(0, 32);
1036
+ }
1037
+ }]);
1038
+ return Hash;
1039
+ }();
1040
+ var W = new Int32Array(N.workWords);
1041
+ var sharedBuffer;
1042
+ var sharedOffset = 0;
1043
+ var hex32 = function hex32(num) {
1044
+ return (num + 0x100000000).toString(16).substr(-8);
1045
+ };
1046
+ var swapLE = function swapLE(c) {
1047
+ return c << 24 & 0xff000000 | c << 8 & 0xff0000 | c >> 8 & 0xff00 | c >> 24 & 0xff;
1048
+ };
1049
+ var swapBE = function swapBE(c) {
1050
+ return c;
1051
+ };
1052
+ var swap32 = isBE() ? swapBE : swapLE;
1053
+ var ch = function ch(x, y, z) {
1054
+ return z ^ x & (y ^ z);
1055
+ };
1056
+ var maj = function maj(x, y, z) {
1057
+ return x & y | z & (x | y);
1058
+ };
1059
+ var sigma0 = function sigma0(x) {
1060
+ return (x >>> 2 | x << 30) ^ (x >>> 13 | x << 19) ^ (x >>> 22 | x << 10);
1061
+ };
1062
+ var sigma1 = function sigma1(x) {
1063
+ return (x >>> 6 | x << 26) ^ (x >>> 11 | x << 21) ^ (x >>> 25 | x << 7);
1064
+ };
1065
+ var gamma0 = function gamma0(x) {
1066
+ return (x >>> 7 | x << 25) ^ (x >>> 18 | x << 14) ^ x >>> 3;
1067
+ };
1068
+ var gamma1 = function gamma1(x) {
1069
+ return (x >>> 17 | x << 15) ^ (x >>> 19 | x << 13) ^ x >>> 10;
1070
+ };
1071
+ function isBE() {
1072
+ var buf = new Uint8Array(new Uint16Array([0xfeff]).buffer); // BOM
1073
+ return buf[0] === 0xfe;
1074
+ }
1075
+ var getSHA256Hash = function getSHA256Hash(bits) {
1076
+ return createHash().update(bits).digest("hex");
1077
+ };
1078
+
726
1079
  function _regeneratorRuntime() {
727
1080
  _regeneratorRuntime = function () {
728
1081
  return e;
@@ -1056,32 +1409,6 @@ function _asyncToGenerator(fn) {
1056
1409
  };
1057
1410
  }
1058
1411
 
1059
- var getSHA256Hash = /*#__PURE__*/function () {
1060
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(bits) {
1061
- var hashBuffer, hashArray, hash;
1062
- return _regeneratorRuntime().wrap(function _callee$(_context) {
1063
- while (1) switch (_context.prev = _context.next) {
1064
- case 0:
1065
- _context.next = 2;
1066
- return crypto.subtle.digest("SHA-256", bits);
1067
- case 2:
1068
- hashBuffer = _context.sent;
1069
- hashArray = Array.from(new Uint8Array(hashBuffer));
1070
- hash = hashArray.map(function (item) {
1071
- return item.toString(16).padStart(2, "0");
1072
- }).join("");
1073
- return _context.abrupt("return", hash);
1074
- case 6:
1075
- case "end":
1076
- return _context.stop();
1077
- }
1078
- }, _callee);
1079
- }));
1080
- return function getSHA256Hash(_x) {
1081
- return _ref.apply(this, arguments);
1082
- };
1083
- }();
1084
-
1085
1412
  // TODO: move this to internal, only reason this is here is that react, ui and server all depend on it
1086
1413
  var ValApi = /*#__PURE__*/function () {
1087
1414
  function ValApi(host) {
@@ -1093,11 +1420,6 @@ var ValApi = /*#__PURE__*/function () {
1093
1420
  value: function getDisableUrl(redirectTo) {
1094
1421
  return "".concat(this.host, "/disable?redirect_to=").concat(encodeURIComponent(redirectTo));
1095
1422
  }
1096
- }, {
1097
- key: "getEditUrl",
1098
- value: function getEditUrl() {
1099
- return "".concat(this.host, "/static/edit");
1100
- }
1101
1423
  }, {
1102
1424
  key: "getLoginUrl",
1103
1425
  value: function getLoginUrl(redirectTo) {
@@ -1138,6 +1460,11 @@ var ValApi = /*#__PURE__*/function () {
1138
1460
  }
1139
1461
  return getPatches;
1140
1462
  }()
1463
+ }, {
1464
+ key: "getEditUrl",
1465
+ value: function getEditUrl() {
1466
+ return "".concat(this.host, "/static/edit");
1467
+ }
1141
1468
  }, {
1142
1469
  key: "postPatches",
1143
1470
  value: function postPatches(moduleId, patches, headers) {