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