@valbuild/core 0.33.0 → 0.35.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.
- package/dist/declarations/src/ValApi.d.ts +7 -3
- package/dist/declarations/src/index.d.ts +4 -11
- package/dist/declarations/src/initVal.d.ts +6 -0
- package/dist/{index-425d164d.cjs.prod.js → index-216627d7.cjs.prod.js} +3 -4
- package/dist/{index-f0475164.esm.js → index-4f821892.esm.js} +3 -4
- package/dist/{index-30eee5ec.cjs.prod.js → index-5bdaa229.cjs.prod.js} +27 -28
- package/dist/{index-a0f36fe3.cjs.dev.js → index-6deb169d.cjs.dev.js} +3 -4
- package/dist/{index-43369070.cjs.dev.js → index-a5295001.cjs.dev.js} +27 -28
- package/dist/{index-499b9e87.esm.js → index-c83918b8.esm.js} +28 -29
- package/dist/{ops-b263963e.cjs.prod.js → ops-6489efeb.cjs.prod.js} +102 -103
- package/dist/{ops-558f07b7.cjs.dev.js → ops-bec039cc.cjs.dev.js} +102 -103
- package/dist/{ops-1225f750.esm.js → ops-ce47df64.esm.js} +102 -103
- package/dist/valbuild-core.cjs.dev.js +69 -47
- package/dist/valbuild-core.cjs.prod.js +69 -47
- package/dist/valbuild-core.esm.js +70 -48
- package/expr/dist/valbuild-core-expr.cjs.dev.js +2 -2
- package/expr/dist/valbuild-core-expr.cjs.prod.js +2 -2
- package/expr/dist/valbuild-core-expr.esm.js +2 -2
- package/package.json +1 -1
- package/patch/dist/valbuild-core-patch.cjs.dev.js +2 -2
- package/patch/dist/valbuild-core-patch.cjs.prod.js +2 -2
- package/patch/dist/valbuild-core-patch.esm.js +3 -3
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var
|
6
|
-
var
|
7
|
-
var expr_dist_valbuildCoreExpr = require('./index-
|
5
|
+
var ops = require('./ops-bec039cc.cjs.dev.js');
|
6
|
+
var index = require('./index-a5295001.cjs.dev.js');
|
7
|
+
var expr_dist_valbuildCoreExpr = require('./index-6deb169d.cjs.dev.js');
|
8
8
|
var result = require('./result-48320acd.cjs.dev.js');
|
9
9
|
|
10
10
|
var NumberSchema = /*#__PURE__*/function (_Schema) {
|
@@ -350,7 +350,7 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
350
350
|
value: function serialize() {
|
351
351
|
var path = index.getValPath(this.selector);
|
352
352
|
if (!path) {
|
353
|
-
throw new Error("Cannot serialize
|
353
|
+
throw new Error("Cannot serialize keyOf schema with empty selector. TIP: keyOf must be used with a Val Module.");
|
354
354
|
}
|
355
355
|
return {
|
356
356
|
type: "keyOf",
|
@@ -417,19 +417,18 @@ function initSchema() {
|
|
417
417
|
* Internally it is a Selector
|
418
418
|
**/
|
419
419
|
function richtext(templateStrings) {
|
420
|
-
var _ref;
|
421
420
|
for (var _len = arguments.length, nodes = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
422
421
|
nodes[_key - 1] = arguments[_key];
|
423
422
|
}
|
424
|
-
return
|
423
|
+
return index._defineProperty(index._defineProperty(index._defineProperty({}, index.VAL_EXTENSION, "richtext"), "templateStrings", templateStrings), "exprs", nodes);
|
425
424
|
}
|
426
425
|
|
427
426
|
function link(text, _ref) {
|
428
|
-
var _ref2;
|
429
427
|
var href = _ref.href;
|
430
|
-
return
|
428
|
+
return index._defineProperty(index._defineProperty(index._defineProperty({}, index.VAL_EXTENSION, "link"), "href", href), "children", [text]);
|
431
429
|
}
|
432
430
|
|
431
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
433
432
|
// import { i18n, I18n } from "./source/future/i18n";
|
434
433
|
// import { remote } from "./source/future/remote";
|
435
434
|
// type NarrowStrings<A> =
|
@@ -454,6 +453,7 @@ var initVal = function initVal() {
|
|
454
453
|
// richtext,
|
455
454
|
// },
|
456
455
|
// s,
|
456
|
+
// config: {},
|
457
457
|
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
458
458
|
// } as any;
|
459
459
|
// }
|
@@ -466,7 +466,8 @@ var initVal = function initVal() {
|
|
466
466
|
richtext: richtext,
|
467
467
|
link: link
|
468
468
|
},
|
469
|
-
s:
|
469
|
+
s: s,
|
470
|
+
config: {}
|
470
471
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
471
472
|
};
|
472
473
|
};
|
@@ -595,7 +596,7 @@ function getVal(selector) {
|
|
595
596
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
596
597
|
function isArrayOrArraySelector(child) {
|
597
598
|
if (ops.isSelector(child)) {
|
598
|
-
return index._typeof(child[index.GetSource]) === "object" &&
|
599
|
+
return index._typeof(child[index.GetSource]) === "object" && child[index.GetSource] !== null && Array.isArray(child[index.GetSource]);
|
599
600
|
}
|
600
601
|
return Array.isArray(child);
|
601
602
|
}
|
@@ -603,7 +604,7 @@ function isArrayOrArraySelector(child) {
|
|
603
604
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
604
605
|
function isObjectOrObjectSelector(child) {
|
605
606
|
if (ops.isSelector(child)) {
|
606
|
-
return index._typeof(child[index.GetSource]) === "object" &&
|
607
|
+
return index._typeof(child[index.GetSource]) === "object" && child[index.GetSource] !== null && !Array.isArray(child[index.GetSource]);
|
607
608
|
}
|
608
609
|
return index._typeof(child) === "object";
|
609
610
|
}
|
@@ -673,7 +674,6 @@ function strip(value) {
|
|
673
674
|
}
|
674
675
|
}
|
675
676
|
function newValProxy(val) {
|
676
|
-
var _ref5;
|
677
677
|
var source = val.val;
|
678
678
|
switch (index._typeof(source)) {
|
679
679
|
case "function":
|
@@ -716,7 +716,7 @@ function newValProxy(val) {
|
|
716
716
|
// intentional fallthrough
|
717
717
|
// eslint-disable-next-line no-fallthrough
|
718
718
|
default:
|
719
|
-
return
|
719
|
+
return index._defineProperty(index._defineProperty({}, index.Path, val.valPath), "val", val.val);
|
720
720
|
}
|
721
721
|
}
|
722
722
|
function hasOwn(obj, prop) {
|
@@ -1090,8 +1090,8 @@ var ValApi = /*#__PURE__*/function () {
|
|
1090
1090
|
}
|
1091
1091
|
index._createClass(ValApi, [{
|
1092
1092
|
key: "getDisableUrl",
|
1093
|
-
value: function getDisableUrl() {
|
1094
|
-
return "".concat(this.host, "/disable");
|
1093
|
+
value: function getDisableUrl(redirectTo) {
|
1094
|
+
return "".concat(this.host, "/disable?redirect_to=").concat(encodeURIComponent(redirectTo));
|
1095
1095
|
}
|
1096
1096
|
}, {
|
1097
1097
|
key: "getEditUrl",
|
@@ -1103,6 +1103,11 @@ var ValApi = /*#__PURE__*/function () {
|
|
1103
1103
|
value: function getLoginUrl(redirectTo) {
|
1104
1104
|
return "".concat(this.host, "/authorize?redirect_to=").concat(encodeURIComponent(redirectTo));
|
1105
1105
|
}
|
1106
|
+
}, {
|
1107
|
+
key: "getEnableUrl",
|
1108
|
+
value: function getEnableUrl(redirectTo) {
|
1109
|
+
return "".concat(this.host, "/enable?redirect_to=").concat(encodeURIComponent(redirectTo));
|
1110
|
+
}
|
1106
1111
|
}, {
|
1107
1112
|
key: "getPatches",
|
1108
1113
|
value: function () {
|
@@ -1121,7 +1126,7 @@ var ValApi = /*#__PURE__*/function () {
|
|
1121
1126
|
}
|
1122
1127
|
}).then(function (res) {
|
1123
1128
|
return parse(res);
|
1124
|
-
}));
|
1129
|
+
})["catch"](createError));
|
1125
1130
|
case 3:
|
1126
1131
|
case "end":
|
1127
1132
|
return _context.stop();
|
@@ -1144,18 +1149,18 @@ var ValApi = /*#__PURE__*/function () {
|
|
1144
1149
|
body: JSON.stringify(index._defineProperty({}, moduleId, patches))
|
1145
1150
|
}).then(function (res) {
|
1146
1151
|
return parse(res);
|
1147
|
-
});
|
1152
|
+
})["catch"](createError);
|
1148
1153
|
}
|
1149
1154
|
}, {
|
1150
1155
|
key: "getSession",
|
1151
1156
|
value: function getSession() {
|
1152
1157
|
return fetch("".concat(this.host, "/session")).then(function (res) {
|
1153
|
-
return parse(res);
|
1158
|
+
return parse(res)["catch"](createError);
|
1154
1159
|
});
|
1155
1160
|
}
|
1156
1161
|
}, {
|
1157
|
-
key: "
|
1158
|
-
value: function
|
1162
|
+
key: "getTree",
|
1163
|
+
value: function getTree(_ref2) {
|
1159
1164
|
var _ref2$patch = _ref2.patch,
|
1160
1165
|
patch = _ref2$patch === void 0 ? false : _ref2$patch,
|
1161
1166
|
_ref2$includeSchema = _ref2.includeSchema,
|
@@ -1173,11 +1178,17 @@ var ValApi = /*#__PURE__*/function () {
|
|
1173
1178
|
headers: headers
|
1174
1179
|
}).then(function (res) {
|
1175
1180
|
return parse(res);
|
1176
|
-
});
|
1181
|
+
})["catch"](createError);
|
1177
1182
|
}
|
1178
1183
|
}]);
|
1179
1184
|
return ValApi;
|
1180
1185
|
}();
|
1186
|
+
function createError(err) {
|
1187
|
+
return result.err({
|
1188
|
+
statusCode: 500,
|
1189
|
+
message: err instanceof Error ? err.message : "Unknown error"
|
1190
|
+
});
|
1191
|
+
}
|
1181
1192
|
|
1182
1193
|
// TODO: validate
|
1183
1194
|
function parse(_x2) {
|
@@ -1185,6 +1196,7 @@ function parse(_x2) {
|
|
1185
1196
|
}
|
1186
1197
|
function _parse() {
|
1187
1198
|
_parse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(res) {
|
1199
|
+
var json;
|
1188
1200
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
1189
1201
|
while (1) switch (_context2.prev = _context2.next) {
|
1190
1202
|
case 0:
|
@@ -1200,31 +1212,41 @@ function _parse() {
|
|
1200
1212
|
_context2.t1 = _context2.sent;
|
1201
1213
|
return _context2.abrupt("return", _context2.t0.ok.call(_context2.t0, _context2.t1));
|
1202
1214
|
case 9:
|
1203
|
-
_context2.
|
1204
|
-
_context2.
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
_context2.
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1215
|
+
_context2.prev = 9;
|
1216
|
+
_context2.next = 12;
|
1217
|
+
return res.json();
|
1218
|
+
case 12:
|
1219
|
+
json = _context2.sent;
|
1220
|
+
return _context2.abrupt("return", result.err({
|
1221
|
+
statusCode: res.status,
|
1222
|
+
message: json.message || res.statusText,
|
1223
|
+
details: json.details || Object.fromEntries(Object.entries(json).filter(function (_ref3) {
|
1224
|
+
var _ref4 = index._slicedToArray(_ref3, 1),
|
1225
|
+
key = _ref4[0];
|
1226
|
+
return key !== "message";
|
1227
|
+
}))
|
1228
|
+
}));
|
1214
1229
|
case 16:
|
1215
|
-
_context2.
|
1216
|
-
|
1217
|
-
case 18:
|
1218
|
-
_context2.prev = 18;
|
1219
|
-
_context2.t6 = _context2["catch"](0);
|
1230
|
+
_context2.prev = 16;
|
1231
|
+
_context2.t2 = _context2["catch"](9);
|
1220
1232
|
return _context2.abrupt("return", result.err({
|
1221
|
-
|
1233
|
+
statusCode: res.status,
|
1234
|
+
message: res.statusText
|
1222
1235
|
}));
|
1236
|
+
case 19:
|
1237
|
+
_context2.next = 24;
|
1238
|
+
break;
|
1223
1239
|
case 21:
|
1240
|
+
_context2.prev = 21;
|
1241
|
+
_context2.t3 = _context2["catch"](0);
|
1242
|
+
return _context2.abrupt("return", result.err({
|
1243
|
+
message: _context2.t3 instanceof Error ? _context2.t3.message : "Unknown error"
|
1244
|
+
}));
|
1245
|
+
case 24:
|
1224
1246
|
case "end":
|
1225
1247
|
return _context2.stop();
|
1226
1248
|
}
|
1227
|
-
}, _callee2, null, [[0,
|
1249
|
+
}, _callee2, null, [[0, 21], [9, 16]]);
|
1228
1250
|
}));
|
1229
1251
|
return _parse.apply(this, arguments);
|
1230
1252
|
}
|
@@ -1242,20 +1264,20 @@ var Internal = {
|
|
1242
1264
|
getSHA256Hash: getSHA256Hash,
|
1243
1265
|
createPatchJSONPath: function createPatchJSONPath(modulePath) {
|
1244
1266
|
return "/".concat(modulePath.split(".").map(function (segment) {
|
1245
|
-
return
|
1267
|
+
return segment && tryJsonParse(segment);
|
1246
1268
|
}).join("/"));
|
1247
1269
|
},
|
1248
|
-
/**
|
1249
|
-
* Enables draft mode: updates all Val modules with patches
|
1250
|
-
*/
|
1251
|
-
VAL_DRAFT_MODE_COOKIE: "val_draft_mode",
|
1252
|
-
/**
|
1253
|
-
* Enables Val: show the overlay / menu
|
1254
|
-
*/
|
1255
1270
|
VAL_ENABLE_COOKIE_NAME: "val_enable",
|
1256
1271
|
VAL_STATE_COOKIE: "val_state",
|
1257
1272
|
VAL_SESSION_COOKIE: "val_session"
|
1258
1273
|
};
|
1274
|
+
function tryJsonParse(str) {
|
1275
|
+
try {
|
1276
|
+
return JSON.parse(str);
|
1277
|
+
} catch (err) {
|
1278
|
+
return str;
|
1279
|
+
}
|
1280
|
+
}
|
1259
1281
|
|
1260
1282
|
exports.FILE_REF_PROP = index.FILE_REF_PROP;
|
1261
1283
|
exports.GenericSelector = index.GenericSelector;
|
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var
|
6
|
-
var
|
7
|
-
var expr_dist_valbuildCoreExpr = require('./index-
|
5
|
+
var ops = require('./ops-6489efeb.cjs.prod.js');
|
6
|
+
var index = require('./index-5bdaa229.cjs.prod.js');
|
7
|
+
var expr_dist_valbuildCoreExpr = require('./index-216627d7.cjs.prod.js');
|
8
8
|
var result = require('./result-26f67b40.cjs.prod.js');
|
9
9
|
|
10
10
|
var NumberSchema = /*#__PURE__*/function (_Schema) {
|
@@ -350,7 +350,7 @@ var KeyOfSchema = /*#__PURE__*/function (_Schema) {
|
|
350
350
|
value: function serialize() {
|
351
351
|
var path = index.getValPath(this.selector);
|
352
352
|
if (!path) {
|
353
|
-
throw new Error("Cannot serialize
|
353
|
+
throw new Error("Cannot serialize keyOf schema with empty selector. TIP: keyOf must be used with a Val Module.");
|
354
354
|
}
|
355
355
|
return {
|
356
356
|
type: "keyOf",
|
@@ -417,19 +417,18 @@ function initSchema() {
|
|
417
417
|
* Internally it is a Selector
|
418
418
|
**/
|
419
419
|
function richtext(templateStrings) {
|
420
|
-
var _ref;
|
421
420
|
for (var _len = arguments.length, nodes = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
422
421
|
nodes[_key - 1] = arguments[_key];
|
423
422
|
}
|
424
|
-
return
|
423
|
+
return index._defineProperty(index._defineProperty(index._defineProperty({}, index.VAL_EXTENSION, "richtext"), "templateStrings", templateStrings), "exprs", nodes);
|
425
424
|
}
|
426
425
|
|
427
426
|
function link(text, _ref) {
|
428
|
-
var _ref2;
|
429
427
|
var href = _ref.href;
|
430
|
-
return
|
428
|
+
return index._defineProperty(index._defineProperty(index._defineProperty({}, index.VAL_EXTENSION, "link"), "href", href), "children", [text]);
|
431
429
|
}
|
432
430
|
|
431
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
433
432
|
// import { i18n, I18n } from "./source/future/i18n";
|
434
433
|
// import { remote } from "./source/future/remote";
|
435
434
|
// type NarrowStrings<A> =
|
@@ -454,6 +453,7 @@ var initVal = function initVal() {
|
|
454
453
|
// richtext,
|
455
454
|
// },
|
456
455
|
// s,
|
456
|
+
// config: {},
|
457
457
|
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
458
458
|
// } as any;
|
459
459
|
// }
|
@@ -466,7 +466,8 @@ var initVal = function initVal() {
|
|
466
466
|
richtext: richtext,
|
467
467
|
link: link
|
468
468
|
},
|
469
|
-
s:
|
469
|
+
s: s,
|
470
|
+
config: {}
|
470
471
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
471
472
|
};
|
472
473
|
};
|
@@ -595,7 +596,7 @@ function getVal(selector) {
|
|
595
596
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
596
597
|
function isArrayOrArraySelector(child) {
|
597
598
|
if (ops.isSelector(child)) {
|
598
|
-
return index._typeof(child[index.GetSource]) === "object" &&
|
599
|
+
return index._typeof(child[index.GetSource]) === "object" && child[index.GetSource] !== null && Array.isArray(child[index.GetSource]);
|
599
600
|
}
|
600
601
|
return Array.isArray(child);
|
601
602
|
}
|
@@ -603,7 +604,7 @@ function isArrayOrArraySelector(child) {
|
|
603
604
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
604
605
|
function isObjectOrObjectSelector(child) {
|
605
606
|
if (ops.isSelector(child)) {
|
606
|
-
return index._typeof(child[index.GetSource]) === "object" &&
|
607
|
+
return index._typeof(child[index.GetSource]) === "object" && child[index.GetSource] !== null && !Array.isArray(child[index.GetSource]);
|
607
608
|
}
|
608
609
|
return index._typeof(child) === "object";
|
609
610
|
}
|
@@ -673,7 +674,6 @@ function strip(value) {
|
|
673
674
|
}
|
674
675
|
}
|
675
676
|
function newValProxy(val) {
|
676
|
-
var _ref5;
|
677
677
|
var source = val.val;
|
678
678
|
switch (index._typeof(source)) {
|
679
679
|
case "function":
|
@@ -716,7 +716,7 @@ function newValProxy(val) {
|
|
716
716
|
// intentional fallthrough
|
717
717
|
// eslint-disable-next-line no-fallthrough
|
718
718
|
default:
|
719
|
-
return
|
719
|
+
return index._defineProperty(index._defineProperty({}, index.Path, val.valPath), "val", val.val);
|
720
720
|
}
|
721
721
|
}
|
722
722
|
function hasOwn(obj, prop) {
|
@@ -1090,8 +1090,8 @@ var ValApi = /*#__PURE__*/function () {
|
|
1090
1090
|
}
|
1091
1091
|
index._createClass(ValApi, [{
|
1092
1092
|
key: "getDisableUrl",
|
1093
|
-
value: function getDisableUrl() {
|
1094
|
-
return "".concat(this.host, "/disable");
|
1093
|
+
value: function getDisableUrl(redirectTo) {
|
1094
|
+
return "".concat(this.host, "/disable?redirect_to=").concat(encodeURIComponent(redirectTo));
|
1095
1095
|
}
|
1096
1096
|
}, {
|
1097
1097
|
key: "getEditUrl",
|
@@ -1103,6 +1103,11 @@ var ValApi = /*#__PURE__*/function () {
|
|
1103
1103
|
value: function getLoginUrl(redirectTo) {
|
1104
1104
|
return "".concat(this.host, "/authorize?redirect_to=").concat(encodeURIComponent(redirectTo));
|
1105
1105
|
}
|
1106
|
+
}, {
|
1107
|
+
key: "getEnableUrl",
|
1108
|
+
value: function getEnableUrl(redirectTo) {
|
1109
|
+
return "".concat(this.host, "/enable?redirect_to=").concat(encodeURIComponent(redirectTo));
|
1110
|
+
}
|
1106
1111
|
}, {
|
1107
1112
|
key: "getPatches",
|
1108
1113
|
value: function () {
|
@@ -1121,7 +1126,7 @@ var ValApi = /*#__PURE__*/function () {
|
|
1121
1126
|
}
|
1122
1127
|
}).then(function (res) {
|
1123
1128
|
return parse(res);
|
1124
|
-
}));
|
1129
|
+
})["catch"](createError));
|
1125
1130
|
case 3:
|
1126
1131
|
case "end":
|
1127
1132
|
return _context.stop();
|
@@ -1144,18 +1149,18 @@ var ValApi = /*#__PURE__*/function () {
|
|
1144
1149
|
body: JSON.stringify(index._defineProperty({}, moduleId, patches))
|
1145
1150
|
}).then(function (res) {
|
1146
1151
|
return parse(res);
|
1147
|
-
});
|
1152
|
+
})["catch"](createError);
|
1148
1153
|
}
|
1149
1154
|
}, {
|
1150
1155
|
key: "getSession",
|
1151
1156
|
value: function getSession() {
|
1152
1157
|
return fetch("".concat(this.host, "/session")).then(function (res) {
|
1153
|
-
return parse(res);
|
1158
|
+
return parse(res)["catch"](createError);
|
1154
1159
|
});
|
1155
1160
|
}
|
1156
1161
|
}, {
|
1157
|
-
key: "
|
1158
|
-
value: function
|
1162
|
+
key: "getTree",
|
1163
|
+
value: function getTree(_ref2) {
|
1159
1164
|
var _ref2$patch = _ref2.patch,
|
1160
1165
|
patch = _ref2$patch === void 0 ? false : _ref2$patch,
|
1161
1166
|
_ref2$includeSchema = _ref2.includeSchema,
|
@@ -1173,11 +1178,17 @@ var ValApi = /*#__PURE__*/function () {
|
|
1173
1178
|
headers: headers
|
1174
1179
|
}).then(function (res) {
|
1175
1180
|
return parse(res);
|
1176
|
-
});
|
1181
|
+
})["catch"](createError);
|
1177
1182
|
}
|
1178
1183
|
}]);
|
1179
1184
|
return ValApi;
|
1180
1185
|
}();
|
1186
|
+
function createError(err) {
|
1187
|
+
return result.err({
|
1188
|
+
statusCode: 500,
|
1189
|
+
message: err instanceof Error ? err.message : "Unknown error"
|
1190
|
+
});
|
1191
|
+
}
|
1181
1192
|
|
1182
1193
|
// TODO: validate
|
1183
1194
|
function parse(_x2) {
|
@@ -1185,6 +1196,7 @@ function parse(_x2) {
|
|
1185
1196
|
}
|
1186
1197
|
function _parse() {
|
1187
1198
|
_parse = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(res) {
|
1199
|
+
var json;
|
1188
1200
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
1189
1201
|
while (1) switch (_context2.prev = _context2.next) {
|
1190
1202
|
case 0:
|
@@ -1200,31 +1212,41 @@ function _parse() {
|
|
1200
1212
|
_context2.t1 = _context2.sent;
|
1201
1213
|
return _context2.abrupt("return", _context2.t0.ok.call(_context2.t0, _context2.t1));
|
1202
1214
|
case 9:
|
1203
|
-
_context2.
|
1204
|
-
_context2.
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
_context2.
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1215
|
+
_context2.prev = 9;
|
1216
|
+
_context2.next = 12;
|
1217
|
+
return res.json();
|
1218
|
+
case 12:
|
1219
|
+
json = _context2.sent;
|
1220
|
+
return _context2.abrupt("return", result.err({
|
1221
|
+
statusCode: res.status,
|
1222
|
+
message: json.message || res.statusText,
|
1223
|
+
details: json.details || Object.fromEntries(Object.entries(json).filter(function (_ref3) {
|
1224
|
+
var _ref4 = index._slicedToArray(_ref3, 1),
|
1225
|
+
key = _ref4[0];
|
1226
|
+
return key !== "message";
|
1227
|
+
}))
|
1228
|
+
}));
|
1214
1229
|
case 16:
|
1215
|
-
_context2.
|
1216
|
-
|
1217
|
-
case 18:
|
1218
|
-
_context2.prev = 18;
|
1219
|
-
_context2.t6 = _context2["catch"](0);
|
1230
|
+
_context2.prev = 16;
|
1231
|
+
_context2.t2 = _context2["catch"](9);
|
1220
1232
|
return _context2.abrupt("return", result.err({
|
1221
|
-
|
1233
|
+
statusCode: res.status,
|
1234
|
+
message: res.statusText
|
1222
1235
|
}));
|
1236
|
+
case 19:
|
1237
|
+
_context2.next = 24;
|
1238
|
+
break;
|
1223
1239
|
case 21:
|
1240
|
+
_context2.prev = 21;
|
1241
|
+
_context2.t3 = _context2["catch"](0);
|
1242
|
+
return _context2.abrupt("return", result.err({
|
1243
|
+
message: _context2.t3 instanceof Error ? _context2.t3.message : "Unknown error"
|
1244
|
+
}));
|
1245
|
+
case 24:
|
1224
1246
|
case "end":
|
1225
1247
|
return _context2.stop();
|
1226
1248
|
}
|
1227
|
-
}, _callee2, null, [[0,
|
1249
|
+
}, _callee2, null, [[0, 21], [9, 16]]);
|
1228
1250
|
}));
|
1229
1251
|
return _parse.apply(this, arguments);
|
1230
1252
|
}
|
@@ -1242,20 +1264,20 @@ var Internal = {
|
|
1242
1264
|
getSHA256Hash: getSHA256Hash,
|
1243
1265
|
createPatchJSONPath: function createPatchJSONPath(modulePath) {
|
1244
1266
|
return "/".concat(modulePath.split(".").map(function (segment) {
|
1245
|
-
return
|
1267
|
+
return segment && tryJsonParse(segment);
|
1246
1268
|
}).join("/"));
|
1247
1269
|
},
|
1248
|
-
/**
|
1249
|
-
* Enables draft mode: updates all Val modules with patches
|
1250
|
-
*/
|
1251
|
-
VAL_DRAFT_MODE_COOKIE: "val_draft_mode",
|
1252
|
-
/**
|
1253
|
-
* Enables Val: show the overlay / menu
|
1254
|
-
*/
|
1255
1270
|
VAL_ENABLE_COOKIE_NAME: "val_enable",
|
1256
1271
|
VAL_STATE_COOKIE: "val_state",
|
1257
1272
|
VAL_SESSION_COOKIE: "val_session"
|
1258
1273
|
};
|
1274
|
+
function tryJsonParse(str) {
|
1275
|
+
try {
|
1276
|
+
return JSON.parse(str);
|
1277
|
+
} catch (err) {
|
1278
|
+
return str;
|
1279
|
+
}
|
1280
|
+
}
|
1259
1281
|
|
1260
1282
|
exports.FILE_REF_PROP = index.FILE_REF_PROP;
|
1261
1283
|
exports.GenericSelector = index.GenericSelector;
|