@json-editor/json-editor 2.8.0 → 2.9.0-beta.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/CHANGELOG.md +5 -1
- package/README.md +14 -2
- package/dist/jsoneditor.js +2 -2
- package/dist/nonmin/jsoneditor.js +267 -44
- package/dist/nonmin/jsoneditor.js.map +1 -1
- package/package.json +1 -1
- package/src/schemaloader.js +112 -19
- package/tests/codeceptjs/core_test.js +21 -0
- package/tests/pages/references.html +6 -0
- package/tests/unit/schemaloader.spec.js +108 -2
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* * @name JSON Editor
|
|
4
4
|
* * @description JSON Schema Based Editor
|
|
5
5
|
* * This library is the continuation of jdorn's great work (see also https://github.com/jdorn/json-editor/issues/800)
|
|
6
|
-
* * @version "2.
|
|
6
|
+
* * @version "2.9.0-beta.0"
|
|
7
7
|
* * @author Jeremy Dorn
|
|
8
8
|
* * @see https://github.com/jdorn/json-editor/
|
|
9
9
|
* * @see https://github.com/json-editor/json-editor
|
|
@@ -849,6 +849,49 @@ module.exports = function (object, key, value) {
|
|
|
849
849
|
};
|
|
850
850
|
|
|
851
851
|
|
|
852
|
+
/***/ }),
|
|
853
|
+
|
|
854
|
+
/***/ "./node_modules/core-js/internals/date-to-iso-string.js":
|
|
855
|
+
/*!**************************************************************!*\
|
|
856
|
+
!*** ./node_modules/core-js/internals/date-to-iso-string.js ***!
|
|
857
|
+
\**************************************************************/
|
|
858
|
+
/*! no static exports found */
|
|
859
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
860
|
+
|
|
861
|
+
"use strict";
|
|
862
|
+
|
|
863
|
+
var fails = __webpack_require__(/*! ../internals/fails */ "./node_modules/core-js/internals/fails.js");
|
|
864
|
+
var padStart = __webpack_require__(/*! ../internals/string-pad */ "./node_modules/core-js/internals/string-pad.js").start;
|
|
865
|
+
|
|
866
|
+
var abs = Math.abs;
|
|
867
|
+
var DatePrototype = Date.prototype;
|
|
868
|
+
var getTime = DatePrototype.getTime;
|
|
869
|
+
var nativeDateToISOString = DatePrototype.toISOString;
|
|
870
|
+
|
|
871
|
+
// `Date.prototype.toISOString` method implementation
|
|
872
|
+
// https://tc39.es/ecma262/#sec-date.prototype.toisostring
|
|
873
|
+
// PhantomJS / old WebKit fails here:
|
|
874
|
+
module.exports = (fails(function () {
|
|
875
|
+
return nativeDateToISOString.call(new Date(-5e13 - 1)) != '0385-07-25T07:06:39.999Z';
|
|
876
|
+
}) || !fails(function () {
|
|
877
|
+
nativeDateToISOString.call(new Date(NaN));
|
|
878
|
+
})) ? function toISOString() {
|
|
879
|
+
if (!isFinite(getTime.call(this))) throw RangeError('Invalid time value');
|
|
880
|
+
var date = this;
|
|
881
|
+
var year = date.getUTCFullYear();
|
|
882
|
+
var milliseconds = date.getUTCMilliseconds();
|
|
883
|
+
var sign = year < 0 ? '-' : year > 9999 ? '+' : '';
|
|
884
|
+
return sign + padStart(abs(year), sign ? 6 : 4, 0) +
|
|
885
|
+
'-' + padStart(date.getUTCMonth() + 1, 2, 0) +
|
|
886
|
+
'-' + padStart(date.getUTCDate(), 2, 0) +
|
|
887
|
+
'T' + padStart(date.getUTCHours(), 2, 0) +
|
|
888
|
+
':' + padStart(date.getUTCMinutes(), 2, 0) +
|
|
889
|
+
':' + padStart(date.getUTCSeconds(), 2, 0) +
|
|
890
|
+
'.' + padStart(milliseconds, 3, 0) +
|
|
891
|
+
'Z';
|
|
892
|
+
} : nativeDateToISOString;
|
|
893
|
+
|
|
894
|
+
|
|
852
895
|
/***/ }),
|
|
853
896
|
|
|
854
897
|
/***/ "./node_modules/core-js/internals/define-iterator.js":
|
|
@@ -3429,6 +3472,48 @@ module.exports = {
|
|
|
3429
3472
|
};
|
|
3430
3473
|
|
|
3431
3474
|
|
|
3475
|
+
/***/ }),
|
|
3476
|
+
|
|
3477
|
+
/***/ "./node_modules/core-js/internals/string-pad.js":
|
|
3478
|
+
/*!******************************************************!*\
|
|
3479
|
+
!*** ./node_modules/core-js/internals/string-pad.js ***!
|
|
3480
|
+
\******************************************************/
|
|
3481
|
+
/*! no static exports found */
|
|
3482
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
3483
|
+
|
|
3484
|
+
// https://github.com/tc39/proposal-string-pad-start-end
|
|
3485
|
+
var toLength = __webpack_require__(/*! ../internals/to-length */ "./node_modules/core-js/internals/to-length.js");
|
|
3486
|
+
var repeat = __webpack_require__(/*! ../internals/string-repeat */ "./node_modules/core-js/internals/string-repeat.js");
|
|
3487
|
+
var requireObjectCoercible = __webpack_require__(/*! ../internals/require-object-coercible */ "./node_modules/core-js/internals/require-object-coercible.js");
|
|
3488
|
+
|
|
3489
|
+
var ceil = Math.ceil;
|
|
3490
|
+
|
|
3491
|
+
// `String.prototype.{ padStart, padEnd }` methods implementation
|
|
3492
|
+
var createMethod = function (IS_END) {
|
|
3493
|
+
return function ($this, maxLength, fillString) {
|
|
3494
|
+
var S = String(requireObjectCoercible($this));
|
|
3495
|
+
var stringLength = S.length;
|
|
3496
|
+
var fillStr = fillString === undefined ? ' ' : String(fillString);
|
|
3497
|
+
var intMaxLength = toLength(maxLength);
|
|
3498
|
+
var fillLen, stringFiller;
|
|
3499
|
+
if (intMaxLength <= stringLength || fillStr == '') return S;
|
|
3500
|
+
fillLen = intMaxLength - stringLength;
|
|
3501
|
+
stringFiller = repeat.call(fillStr, ceil(fillLen / fillStr.length));
|
|
3502
|
+
if (stringFiller.length > fillLen) stringFiller = stringFiller.slice(0, fillLen);
|
|
3503
|
+
return IS_END ? S + stringFiller : stringFiller + S;
|
|
3504
|
+
};
|
|
3505
|
+
};
|
|
3506
|
+
|
|
3507
|
+
module.exports = {
|
|
3508
|
+
// `String.prototype.padStart` method
|
|
3509
|
+
// https://tc39.es/ecma262/#sec-string.prototype.padstart
|
|
3510
|
+
start: createMethod(false),
|
|
3511
|
+
// `String.prototype.padEnd` method
|
|
3512
|
+
// https://tc39.es/ecma262/#sec-string.prototype.padend
|
|
3513
|
+
end: createMethod(true)
|
|
3514
|
+
};
|
|
3515
|
+
|
|
3516
|
+
|
|
3432
3517
|
/***/ }),
|
|
3433
3518
|
|
|
3434
3519
|
/***/ "./node_modules/core-js/internals/string-repeat.js":
|
|
@@ -4558,6 +4643,26 @@ $({ target: 'Date', stat: true }, {
|
|
|
4558
4643
|
});
|
|
4559
4644
|
|
|
4560
4645
|
|
|
4646
|
+
/***/ }),
|
|
4647
|
+
|
|
4648
|
+
/***/ "./node_modules/core-js/modules/es.date.to-iso-string.js":
|
|
4649
|
+
/*!***************************************************************!*\
|
|
4650
|
+
!*** ./node_modules/core-js/modules/es.date.to-iso-string.js ***!
|
|
4651
|
+
\***************************************************************/
|
|
4652
|
+
/*! no static exports found */
|
|
4653
|
+
/***/ (function(module, exports, __webpack_require__) {
|
|
4654
|
+
|
|
4655
|
+
var $ = __webpack_require__(/*! ../internals/export */ "./node_modules/core-js/internals/export.js");
|
|
4656
|
+
var toISOString = __webpack_require__(/*! ../internals/date-to-iso-string */ "./node_modules/core-js/internals/date-to-iso-string.js");
|
|
4657
|
+
|
|
4658
|
+
// `Date.prototype.toISOString` method
|
|
4659
|
+
// https://tc39.es/ecma262/#sec-date.prototype.toisostring
|
|
4660
|
+
// PhantomJS / old WebKit has a broken implementations
|
|
4661
|
+
$({ target: 'Date', proto: true, forced: Date.prototype.toISOString !== toISOString }, {
|
|
4662
|
+
toISOString: toISOString
|
|
4663
|
+
});
|
|
4664
|
+
|
|
4665
|
+
|
|
4561
4666
|
/***/ }),
|
|
4562
4667
|
|
|
4563
4668
|
/***/ "./node_modules/core-js/modules/es.date.to-string.js":
|
|
@@ -23080,19 +23185,23 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
23080
23185
|
/* harmony import */ var core_js_modules_es_string_includes_js__WEBPACK_IMPORTED_MODULE_22___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_string_includes_js__WEBPACK_IMPORTED_MODULE_22__);
|
|
23081
23186
|
/* harmony import */ var core_js_modules_es_array_filter_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! core-js/modules/es.array.filter.js */ "./node_modules/core-js/modules/es.array.filter.js");
|
|
23082
23187
|
/* harmony import */ var core_js_modules_es_array_filter_js__WEBPACK_IMPORTED_MODULE_23___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_filter_js__WEBPACK_IMPORTED_MODULE_23__);
|
|
23083
|
-
/* harmony import */ var
|
|
23084
|
-
/* harmony import */ var
|
|
23085
|
-
/* harmony import */ var
|
|
23086
|
-
/* harmony import */ var
|
|
23087
|
-
/* harmony import */ var
|
|
23088
|
-
/* harmony import */ var
|
|
23089
|
-
/* harmony import */ var
|
|
23090
|
-
/* harmony import */ var
|
|
23091
|
-
/* harmony import */ var
|
|
23092
|
-
/* harmony import */ var
|
|
23093
|
-
/* harmony import */ var
|
|
23094
|
-
/* harmony import */ var
|
|
23095
|
-
/* harmony import */ var
|
|
23188
|
+
/* harmony import */ var core_js_modules_es_date_to_iso_string_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! core-js/modules/es.date.to-iso-string.js */ "./node_modules/core-js/modules/es.date.to-iso-string.js");
|
|
23189
|
+
/* harmony import */ var core_js_modules_es_date_to_iso_string_js__WEBPACK_IMPORTED_MODULE_24___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_date_to_iso_string_js__WEBPACK_IMPORTED_MODULE_24__);
|
|
23190
|
+
/* harmony import */ var core_js_modules_es_date_to_string_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! core-js/modules/es.date.to-string.js */ "./node_modules/core-js/modules/es.date.to-string.js");
|
|
23191
|
+
/* harmony import */ var core_js_modules_es_date_to_string_js__WEBPACK_IMPORTED_MODULE_25___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_date_to_string_js__WEBPACK_IMPORTED_MODULE_25__);
|
|
23192
|
+
/* harmony import */ var core_js_modules_es_object_define_property_js__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! core-js/modules/es.object.define-property.js */ "./node_modules/core-js/modules/es.object.define-property.js");
|
|
23193
|
+
/* harmony import */ var core_js_modules_es_object_define_property_js__WEBPACK_IMPORTED_MODULE_26___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_object_define_property_js__WEBPACK_IMPORTED_MODULE_26__);
|
|
23194
|
+
/* harmony import */ var core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! core-js/modules/es.symbol.js */ "./node_modules/core-js/modules/es.symbol.js");
|
|
23195
|
+
/* harmony import */ var core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_27___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_js__WEBPACK_IMPORTED_MODULE_27__);
|
|
23196
|
+
/* harmony import */ var core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! core-js/modules/es.symbol.description.js */ "./node_modules/core-js/modules/es.symbol.description.js");
|
|
23197
|
+
/* harmony import */ var core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_28___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_description_js__WEBPACK_IMPORTED_MODULE_28__);
|
|
23198
|
+
/* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! core-js/modules/es.symbol.iterator.js */ "./node_modules/core-js/modules/es.symbol.iterator.js");
|
|
23199
|
+
/* harmony import */ var core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_29___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_symbol_iterator_js__WEBPACK_IMPORTED_MODULE_29__);
|
|
23200
|
+
/* harmony import */ var core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! core-js/modules/es.function.name.js */ "./node_modules/core-js/modules/es.function.name.js");
|
|
23201
|
+
/* harmony import */ var core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_30___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_function_name_js__WEBPACK_IMPORTED_MODULE_30__);
|
|
23202
|
+
/* harmony import */ var core_js_modules_es_array_from_js__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! core-js/modules/es.array.from.js */ "./node_modules/core-js/modules/es.array.from.js");
|
|
23203
|
+
/* harmony import */ var core_js_modules_es_array_from_js__WEBPACK_IMPORTED_MODULE_31___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_from_js__WEBPACK_IMPORTED_MODULE_31__);
|
|
23204
|
+
/* harmony import */ var _utilities_js__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./utilities.js */ "./src/utilities.js");
|
|
23096
23205
|
|
|
23097
23206
|
|
|
23098
23207
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
@@ -23138,6 +23247,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
23138
23247
|
|
|
23139
23248
|
|
|
23140
23249
|
|
|
23250
|
+
|
|
23251
|
+
|
|
23141
23252
|
|
|
23142
23253
|
|
|
23143
23254
|
|
|
@@ -23254,7 +23365,7 @@ var SchemaLoader = /*#__PURE__*/function () {
|
|
|
23254
23365
|
allOf: function allOf(schema, extended) {
|
|
23255
23366
|
var _this3 = this;
|
|
23256
23367
|
|
|
23257
|
-
var _extended = Object(
|
|
23368
|
+
var _extended = Object(_utilities_js__WEBPACK_IMPORTED_MODULE_32__["extend"])({}, extended);
|
|
23258
23369
|
|
|
23259
23370
|
Object.entries(schema.allOf).forEach(function (_ref5) {
|
|
23260
23371
|
var _ref6 = _slicedToArray(_ref5, 2),
|
|
@@ -23293,7 +23404,7 @@ var SchemaLoader = /*#__PURE__*/function () {
|
|
|
23293
23404
|
oneOf: function oneOf(schema, extended) {
|
|
23294
23405
|
var _this5 = this;
|
|
23295
23406
|
|
|
23296
|
-
var tmp = Object(
|
|
23407
|
+
var tmp = Object(_utilities_js__WEBPACK_IMPORTED_MODULE_32__["extend"])({}, extended);
|
|
23297
23408
|
delete tmp.oneOf;
|
|
23298
23409
|
schema.oneOf.reduce(function (e, s, i) {
|
|
23299
23410
|
e.oneOf[i] = _this5.extendSchemas(_this5.expandSchema(s), tmp);
|
|
@@ -23359,7 +23470,7 @@ var SchemaLoader = /*#__PURE__*/function () {
|
|
|
23359
23470
|
value: function expandRefs(schema, recurseAllOf) {
|
|
23360
23471
|
var _this6 = this;
|
|
23361
23472
|
|
|
23362
|
-
var _schema = Object(
|
|
23473
|
+
var _schema = Object(_utilities_js__WEBPACK_IMPORTED_MODULE_32__["extend"])({}, schema);
|
|
23363
23474
|
|
|
23364
23475
|
if (!_schema.$ref) return _schema; // This split the ref to get the Json point if it exists
|
|
23365
23476
|
// exemple #/counter/1#/definition/address +
|
|
@@ -23384,7 +23495,7 @@ var SchemaLoader = /*#__PURE__*/function () {
|
|
|
23384
23495
|
/* if reference not found */
|
|
23385
23496
|
// eslint-disable-next-line no-console
|
|
23386
23497
|
console.warn("reference:'".concat(ref, "' not found!"));
|
|
23387
|
-
} else if (recurseAllOf && Object(
|
|
23498
|
+
} else if (recurseAllOf && Object(_utilities_js__WEBPACK_IMPORTED_MODULE_32__["hasOwnProperty"])(this.refs[ref], 'allOf')) {
|
|
23388
23499
|
var allOf = this.refs[ref].allOf;
|
|
23389
23500
|
Object.keys(allOf).forEach(function (key) {
|
|
23390
23501
|
allOf[key] = _this6.expandRefs(allOf[key], true);
|
|
@@ -23442,7 +23553,7 @@ var SchemaLoader = /*#__PURE__*/function () {
|
|
|
23442
23553
|
func.call(_this7, schema);
|
|
23443
23554
|
}
|
|
23444
23555
|
});
|
|
23445
|
-
var extended = Object(
|
|
23556
|
+
var extended = Object(_utilities_js__WEBPACK_IMPORTED_MODULE_32__["extend"])({}, schema);
|
|
23446
23557
|
Object.entries(this._subSchema2).forEach(function (_ref9) {
|
|
23447
23558
|
var _ref10 = _slicedToArray(_ref9, 2),
|
|
23448
23559
|
key = _ref10[0],
|
|
@@ -23638,7 +23749,7 @@ var SchemaLoader = /*#__PURE__*/function () {
|
|
|
23638
23749
|
waiting = 0; // Loop into all schema references
|
|
23639
23750
|
|
|
23640
23751
|
_loop = /*#__PURE__*/regeneratorRuntime.mark(function _loop() {
|
|
23641
|
-
var uri, urnResolver, urn,
|
|
23752
|
+
var uri, urnResolver, urn, response, _externalSchema, url, externalSchema, schemaFromCache, _response, newfileBase, pathItems;
|
|
23642
23753
|
|
|
23643
23754
|
return regeneratorRuntime.wrap(function _loop$(_context2) {
|
|
23644
23755
|
while (1) {
|
|
@@ -23689,9 +23800,9 @@ var SchemaLoader = /*#__PURE__*/function () {
|
|
|
23689
23800
|
return urnResolver(urn);
|
|
23690
23801
|
|
|
23691
23802
|
case 17:
|
|
23692
|
-
|
|
23803
|
+
response = _context2.sent;
|
|
23693
23804
|
_context2.prev = 18;
|
|
23694
|
-
_externalSchema = JSON.parse(
|
|
23805
|
+
_externalSchema = JSON.parse(response);
|
|
23695
23806
|
_context2.next = 26;
|
|
23696
23807
|
break;
|
|
23697
23808
|
|
|
@@ -23727,7 +23838,7 @@ var SchemaLoader = /*#__PURE__*/function () {
|
|
|
23727
23838
|
throw new Error("Failed to parse external ref ".concat(urn));
|
|
23728
23839
|
|
|
23729
23840
|
case 37:
|
|
23730
|
-
if (!(typeof
|
|
23841
|
+
if (!(typeof response === 'boolean')) {
|
|
23731
23842
|
_context2.next = 39;
|
|
23732
23843
|
break;
|
|
23733
23844
|
}
|
|
@@ -23748,7 +23859,22 @@ var SchemaLoader = /*#__PURE__*/function () {
|
|
|
23748
23859
|
case 42:
|
|
23749
23860
|
waiting++;
|
|
23750
23861
|
url = _this10._joinUrl(uri, fileBase);
|
|
23751
|
-
|
|
23862
|
+
externalSchema = void 0;
|
|
23863
|
+
|
|
23864
|
+
if (_this10.options.ajax_cache_responses) {
|
|
23865
|
+
schemaFromCache = _this10.cacheGet(url);
|
|
23866
|
+
|
|
23867
|
+
if (schemaFromCache) {
|
|
23868
|
+
externalSchema = schemaFromCache;
|
|
23869
|
+
}
|
|
23870
|
+
}
|
|
23871
|
+
|
|
23872
|
+
if (externalSchema) {
|
|
23873
|
+
_context2.next = 61;
|
|
23874
|
+
break;
|
|
23875
|
+
}
|
|
23876
|
+
|
|
23877
|
+
_context2.next = 49;
|
|
23752
23878
|
return new Promise(function (resolve) {
|
|
23753
23879
|
var r = new XMLHttpRequest();
|
|
23754
23880
|
if (_this10.options.ajaxCredentials) r.withCredentials = _this10.options.ajaxCredentials;
|
|
@@ -23766,39 +23892,43 @@ var SchemaLoader = /*#__PURE__*/function () {
|
|
|
23766
23892
|
r.send();
|
|
23767
23893
|
});
|
|
23768
23894
|
|
|
23769
|
-
case
|
|
23770
|
-
|
|
23895
|
+
case 49:
|
|
23896
|
+
_response = _context2.sent;
|
|
23771
23897
|
|
|
23772
|
-
if (!(typeof
|
|
23773
|
-
_context2.next =
|
|
23898
|
+
if (!(typeof _response === 'undefined')) {
|
|
23899
|
+
_context2.next = 52;
|
|
23774
23900
|
break;
|
|
23775
23901
|
}
|
|
23776
23902
|
|
|
23777
23903
|
throw new Error("Failed to fetch ref via ajax - ".concat(uri));
|
|
23778
23904
|
|
|
23779
|
-
case
|
|
23780
|
-
|
|
23781
|
-
|
|
23782
|
-
|
|
23783
|
-
|
|
23905
|
+
case 52:
|
|
23906
|
+
_context2.prev = 52;
|
|
23907
|
+
externalSchema = JSON.parse(_response.responseText);
|
|
23908
|
+
|
|
23909
|
+
if (_this10.options.ajax_cache_responses) {
|
|
23910
|
+
_this10.cacheSet(url, externalSchema);
|
|
23911
|
+
}
|
|
23912
|
+
|
|
23913
|
+
_context2.next = 61;
|
|
23784
23914
|
break;
|
|
23785
23915
|
|
|
23786
|
-
case
|
|
23787
|
-
_context2.prev =
|
|
23788
|
-
_context2.t2 = _context2["catch"](
|
|
23916
|
+
case 57:
|
|
23917
|
+
_context2.prev = 57;
|
|
23918
|
+
_context2.t2 = _context2["catch"](52);
|
|
23789
23919
|
// eslint-disable-next-line no-console
|
|
23790
23920
|
console.log(_context2.t2);
|
|
23791
23921
|
throw new Error("Failed to parse external ref ".concat(url));
|
|
23792
23922
|
|
|
23793
|
-
case
|
|
23923
|
+
case 61:
|
|
23794
23924
|
if (!(!(typeof externalSchema === 'boolean' || _typeof(externalSchema) === 'object') || externalSchema === null || Array.isArray(externalSchema))) {
|
|
23795
|
-
_context2.next =
|
|
23925
|
+
_context2.next = 63;
|
|
23796
23926
|
break;
|
|
23797
23927
|
}
|
|
23798
23928
|
|
|
23799
23929
|
throw new Error("External ref does not contain a valid schema - ".concat(url));
|
|
23800
23930
|
|
|
23801
|
-
case
|
|
23931
|
+
case 63:
|
|
23802
23932
|
_this10.refs[uri] = externalSchema;
|
|
23803
23933
|
newfileBase = _this10._getFileBaseFromFileLocation(url); // Add leading slash.
|
|
23804
23934
|
|
|
@@ -23807,15 +23937,15 @@ var SchemaLoader = /*#__PURE__*/function () {
|
|
|
23807
23937
|
url = (uri.substr(0, 1) === '/' ? '/' : '') + pathItems.pop();
|
|
23808
23938
|
}
|
|
23809
23939
|
|
|
23810
|
-
_context2.next =
|
|
23940
|
+
_context2.next = 68;
|
|
23811
23941
|
return _this10._asyncloadExternalRefs(externalSchema, url, newfileBase);
|
|
23812
23942
|
|
|
23813
|
-
case
|
|
23943
|
+
case 68:
|
|
23814
23944
|
case "end":
|
|
23815
23945
|
return _context2.stop();
|
|
23816
23946
|
}
|
|
23817
23947
|
}
|
|
23818
|
-
}, _loop, null, [[14, 33], [18, 22], [
|
|
23948
|
+
}, _loop, null, [[14, 33], [18, 22], [52, 57]]);
|
|
23819
23949
|
});
|
|
23820
23950
|
_i2 = 0, _Object$keys = Object.keys(refs);
|
|
23821
23951
|
|
|
@@ -23869,8 +23999,8 @@ var SchemaLoader = /*#__PURE__*/function () {
|
|
|
23869
23999
|
value: function extendSchemas(obj1, obj2) {
|
|
23870
24000
|
var _this11 = this;
|
|
23871
24001
|
|
|
23872
|
-
obj1 = Object(
|
|
23873
|
-
obj2 = Object(
|
|
24002
|
+
obj1 = Object(_utilities_js__WEBPACK_IMPORTED_MODULE_32__["extend"])({}, obj1);
|
|
24003
|
+
obj2 = Object(_utilities_js__WEBPACK_IMPORTED_MODULE_32__["extend"])({}, obj2);
|
|
23874
24004
|
var extended = {};
|
|
23875
24005
|
|
|
23876
24006
|
var isRequiredOrDefaultProperties = function isRequiredOrDefaultProperties(prop, val) {
|
|
@@ -23949,6 +24079,99 @@ var SchemaLoader = /*#__PURE__*/function () {
|
|
|
23949
24079
|
});
|
|
23950
24080
|
return extended;
|
|
23951
24081
|
}
|
|
24082
|
+
/**
|
|
24083
|
+
* Gets a cache key namespaced for JSON Editor.
|
|
24084
|
+
*
|
|
24085
|
+
* @param {*} key
|
|
24086
|
+
* The schema's key, e.g., URL.
|
|
24087
|
+
* @returns {string}
|
|
24088
|
+
* A namespaced cache key, by prefixing "je-cache::".
|
|
24089
|
+
*/
|
|
24090
|
+
|
|
24091
|
+
}, {
|
|
24092
|
+
key: "getCacheKey",
|
|
24093
|
+
value: function getCacheKey(key) {
|
|
24094
|
+
return ['je-cache', key].join('::');
|
|
24095
|
+
}
|
|
24096
|
+
/**
|
|
24097
|
+
* Returns the schema cache buster from JSON Editor settings.
|
|
24098
|
+
*
|
|
24099
|
+
* @returns {string}
|
|
24100
|
+
* The configured cache buster, if any. Otherwise, returns the current date
|
|
24101
|
+
* in ISO 8601 simplified format (e.g., 2011-10-05 for October 5, 2011).
|
|
24102
|
+
*/
|
|
24103
|
+
|
|
24104
|
+
}, {
|
|
24105
|
+
key: "getCacheBuster",
|
|
24106
|
+
value: function getCacheBuster() {
|
|
24107
|
+
return this.options.ajax_cache_buster || new Date().toISOString().slice(0, 10);
|
|
24108
|
+
}
|
|
24109
|
+
/**
|
|
24110
|
+
* Sets a schema into localStorage cache.
|
|
24111
|
+
*
|
|
24112
|
+
* @param {string} key
|
|
24113
|
+
* The schema's key, e.g., URL.
|
|
24114
|
+
* @param {mixed} data
|
|
24115
|
+
* The schema to store. Can be any data type.
|
|
24116
|
+
*/
|
|
24117
|
+
|
|
24118
|
+
}, {
|
|
24119
|
+
key: "cacheSet",
|
|
24120
|
+
value: function cacheSet(key, data) {
|
|
24121
|
+
try {
|
|
24122
|
+
window.localStorage.setItem(this.getCacheKey(key), JSON.stringify({
|
|
24123
|
+
cacheBuster: this.getCacheBuster(),
|
|
24124
|
+
schema: data
|
|
24125
|
+
}));
|
|
24126
|
+
} catch (e) {
|
|
24127
|
+
// eslint-disable-next-line no-console
|
|
24128
|
+
console.error(e);
|
|
24129
|
+
}
|
|
24130
|
+
}
|
|
24131
|
+
/**
|
|
24132
|
+
* Fetches a schema from localStorage cache.
|
|
24133
|
+
*
|
|
24134
|
+
* @param {string} key
|
|
24135
|
+
* The schema's key, e.g., URL.
|
|
24136
|
+
*
|
|
24137
|
+
* @returns {mixed}
|
|
24138
|
+
* If found, returns the schema.
|
|
24139
|
+
*/
|
|
24140
|
+
|
|
24141
|
+
}, {
|
|
24142
|
+
key: "cacheGet",
|
|
24143
|
+
value: function cacheGet(key) {
|
|
24144
|
+
try {
|
|
24145
|
+
var resultRaw = window.localStorage.getItem(this.getCacheKey(key));
|
|
24146
|
+
|
|
24147
|
+
if (resultRaw) {
|
|
24148
|
+
var resultDecoded = JSON.parse(resultRaw);
|
|
24149
|
+
|
|
24150
|
+
if (resultDecoded.cacheBuster && resultDecoded.schema) {
|
|
24151
|
+
if (resultDecoded.cacheBuster === this.getCacheBuster()) {
|
|
24152
|
+
return resultDecoded.schema;
|
|
24153
|
+
}
|
|
24154
|
+
}
|
|
24155
|
+
|
|
24156
|
+
this.cacheDelete(key);
|
|
24157
|
+
}
|
|
24158
|
+
} catch (e) {
|
|
24159
|
+
// eslint-disable-next-line no-console
|
|
24160
|
+
console.error(e);
|
|
24161
|
+
}
|
|
24162
|
+
}
|
|
24163
|
+
/**
|
|
24164
|
+
* Deletes a schema from localStorage cache.
|
|
24165
|
+
*
|
|
24166
|
+
* @param {string} key
|
|
24167
|
+
* The schema's key, e.g., URL.
|
|
24168
|
+
*/
|
|
24169
|
+
|
|
24170
|
+
}, {
|
|
24171
|
+
key: "cacheDelete",
|
|
24172
|
+
value: function cacheDelete(key) {
|
|
24173
|
+
window.localStorage.removeItem(this.getCacheKey(key));
|
|
24174
|
+
}
|
|
23952
24175
|
}]);
|
|
23953
24176
|
|
|
23954
24177
|
return SchemaLoader;
|