From bdd319f2f07b2c21870328b6bc53720e2c1b81ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomek=20Wytr=C4=99bowicz?= Date: Thu, 8 Aug 2019 15:41:44 +0200 Subject: [PATCH] Revert typescript to 2.2.0, the version that was not adding `Object.defineProperty(exports, "__esModule", { value: true });` Therefore, resulting in module transpilable to one with unintended default export. Fixes backward compatibility and https://github.com/Starcounter-Jack/JSON-Patch/issues/233 --- dist/fast-json-patch.js | 32 ++++++++++--------------- dist/fast-json-patch.min.js | 2 +- package-lock.json | 47 ++++++++++++++++++++++++++----------- package.json | 2 +- 4 files changed, 48 insertions(+), 35 deletions(-) diff --git a/dist/fast-json-patch.js b/dist/fast-json-patch.js index d911a67b..45e2628b 100644 --- a/dist/fast-json-patch.js +++ b/dist/fast-json-patch.js @@ -96,19 +96,15 @@ var jsonpatch = * MIT license */ var __extends = (this && this.__extends) || (function () { - var extendStatics = function (d, b) { - extendStatics = Object.setPrototypeOf || - ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || - function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; - return extendStatics(d, b); - }; + var extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -Object.defineProperty(exports, "__esModule", { value: true }); var _hasOwnProperty = Object.prototype.hasOwnProperty; function hasOwnProperty(obj, key) { return _hasOwnProperty.call(obj, key); @@ -255,7 +251,7 @@ function patchErrorMessageFormatter(message, args) { } return messageParts.join('\n'); } -var PatchError = /** @class */ (function (_super) { +var PatchError = (function (_super) { __extends(PatchError, _super); function PatchError(message, name, index, operation, tree) { var _newTarget = this.constructor; @@ -277,7 +273,6 @@ exports.PatchError = PatchError; /* 1 */ /***/ (function(module, exports, __webpack_require__) { -Object.defineProperty(exports, "__esModule", { value: true }); var areEquals = __webpack_require__(3); var helpers_1 = __webpack_require__(0); exports.JsonPatchError = helpers_1.PatchError; @@ -336,7 +331,7 @@ var arrOps = { if (helpers_1.isInteger(i)) { arr.splice(i, 0, this.value); } - else { // array props + else { arr[i] = this.value; } // this may be needed when using '-' in an array @@ -412,9 +407,9 @@ function applyOperation(document, operation, validateOperation, mutateDocument, returnValue.removed = document; //document we removed return returnValue; } - else if (operation.op === 'move' || operation.op === 'copy') { // it's a move or copy to root + else if (operation.op === 'move' || operation.op === 'copy') { returnValue.newDocument = getValueByPointer(document, operation.from); // get the value by json-pointer in `from` field - if (operation.op === 'move') { // report removed item + if (operation.op === 'move') { returnValue.removed = document; } return returnValue; @@ -427,7 +422,7 @@ function applyOperation(document, operation, validateOperation, mutateDocument, returnValue.newDocument = document; return returnValue; } - else if (operation.op === 'remove') { // a remove on root + else if (operation.op === 'remove') { returnValue.removed = document; returnValue.newDocument = null; return returnValue; @@ -436,7 +431,7 @@ function applyOperation(document, operation, validateOperation, mutateDocument, operation.value = document; return returnValue; } - else { /* bad operation */ + else { if (validateOperation) { throw new exports.JsonPatchError('Operation `op` property is not one of operations defined in RFC-6902', 'OPERATION_OP_INVALID', index, operation, document); } @@ -568,7 +563,7 @@ exports.applyPatch = applyPatch; */ function applyReducer(document, operation, index) { var operationResult = applyOperation(document, operation); - if (operationResult.test === false) { // failed test + if (operationResult.test === false) { throw new exports.JsonPatchError("Test operation failed", 'TEST_OPERATION_FAILED', index, operation, document); } return operationResult.newDocument; @@ -666,7 +661,6 @@ exports.validate = validate; /* 2 */ /***/ (function(module, exports, __webpack_require__) { -Object.defineProperty(exports, "__esModule", { value: true }); /*! * https://github.com/Starcounter-Jack/JSON-Patch * (c) 2017 Joachim Wester @@ -689,14 +683,14 @@ exports.deepClone = helpers_2._deepClone; exports.escapePathComponent = helpers_2.escapePathComponent; exports.unescapePathComponent = helpers_2.unescapePathComponent; var beforeDict = new WeakMap(); -var Mirror = /** @class */ (function () { +var Mirror = (function () { function Mirror(obj) { this.observers = new Map(); this.obj = obj; } return Mirror; }()); -var ObserverInfo = /** @class */ (function () { +var ObserverInfo = (function () { function ObserverInfo(callback, observer) { this.callback = callback; this.observer = observer; @@ -749,7 +743,7 @@ function observe(obj, callback) { clearTimeout(observer.next); observer.next = setTimeout(dirtyCheck); }; - if (typeof window !== 'undefined') { //not Node + if (typeof window !== 'undefined') { window.addEventListener('mouseup', fastCheck); window.addEventListener('keyup', fastCheck); window.addEventListener('mousedown', fastCheck); diff --git a/dist/fast-json-patch.min.js b/dist/fast-json-patch.min.js index 72b2ccae..8816d75e 100644 --- a/dist/fast-json-patch.min.js +++ b/dist/fast-json-patch.min.js @@ -5,7 +5,7 @@ var jsonpatch=function(e){var t={};function r(n){if(t[n])return t[n].exports;var * (c) 2017 Joachim Wester * MIT license */ -var r,n=this&&this.__extends||(r=function(e,t){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])})(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)});Object.defineProperty(t,"__esModule",{value:!0});var o=Object.prototype.hasOwnProperty;function a(e,t){return o.call(e,t)}function i(e){if(Array.isArray(e)){for(var t=new Array(e.length),r=0;r=48&&t<=57))return!1;r++}return!0},t.escapePathComponent=p,t.unescapePathComponent=function(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")},t._getPathRecursive=u,t.getPath=function(e,t){if(e===t)return"/";var r=u(e,t);if(""===r)throw new Error("Object not found in root");return"/"+r},t.hasUndefined=function e(t){if(void 0===t)return!0;if(t)if(Array.isArray(t)){for(var r=0,n=t.length;r=w){if(u&&"add"===r.op&&O>v.length)throw new t.JsonPatchError("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",l,r,e);if(!1===(h=i[r.op].call(r,v,O,e)).test)throw new t.JsonPatchError("Test operation failed","TEST_OPERATION_FAILED",l,r,e);return h}}else if(O&&-1!=O.indexOf("~")&&(O=o.unescapePathComponent(O)),y>=w){if(!1===(h=a[r.op].call(r,v,O,e)).test)throw new t.JsonPatchError("Test operation failed","TEST_OPERATION_FAILED",l,r,e);return h}v=v[O]}}function s(e,r,n,a,i){if(void 0===a&&(a=!0),void 0===i&&(i=!0),n&&!Array.isArray(r))throw new t.JsonPatchError("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");a||(e=o._deepClone(e));for(var p=new Array(r.length),s=0,c=r.length;s0)throw new t.JsonPatchError('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",r,e,n);if(("move"===e.op||"copy"===e.op)&&"string"!=typeof e.from)throw new t.JsonPatchError("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",r,e,n);if(("add"===e.op||"replace"===e.op||"test"===e.op)&&void 0===e.value)throw new t.JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",r,e,n);if(("add"===e.op||"replace"===e.op||"test"===e.op)&&o.hasUndefined(e.value))throw new t.JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",r,e,n);if(n)if("add"==e.op){var p=e.path.split("/").length,u=i.split("/").length;if(p!==u+1&&p!==u)throw new t.JsonPatchError("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",r,e,n)}else if("replace"===e.op||"remove"===e.op||"_get"===e.op){if(e.path!==i)throw new t.JsonPatchError("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",r,e,n)}else if("move"===e.op||"copy"===e.op){var s=f([{op:"_get",path:e.from,value:void 0}],n);if(s&&"OPERATION_PATH_UNRESOLVABLE"===s.name)throw new t.JsonPatchError("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",r,e,n)}}function f(e,r,n){try{if(!Array.isArray(e))throw new t.JsonPatchError("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(r)s(o._deepClone(r),o._deepClone(e),n||!0);else{n=n||c;for(var a=0;a=48&&t<=57))return!1;r++}return!0},t.escapePathComponent=p,t.unescapePathComponent=function(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")},t._getPathRecursive=u,t.getPath=function(e,t){if(e===t)return"/";var r=u(e,t);if(""===r)throw new Error("Object not found in root");return"/"+r},t.hasUndefined=function e(t){if(void 0===t)return!0;if(t)if(Array.isArray(t)){for(var r=0,n=t.length;r=w){if(u&&"add"===r.op&&O>v.length)throw new t.JsonPatchError("The specified index MUST NOT be greater than the number of elements in the array","OPERATION_VALUE_OUT_OF_BOUNDS",l,r,e);if(!1===(h=i[r.op].call(r,v,O,e)).test)throw new t.JsonPatchError("Test operation failed","TEST_OPERATION_FAILED",l,r,e);return h}}else if(O&&-1!=O.indexOf("~")&&(O=o.unescapePathComponent(O)),y>=w){if(!1===(h=a[r.op].call(r,v,O,e)).test)throw new t.JsonPatchError("Test operation failed","TEST_OPERATION_FAILED",l,r,e);return h}v=v[O]}}function s(e,r,n,a,i){if(void 0===a&&(a=!0),void 0===i&&(i=!0),n&&!Array.isArray(r))throw new t.JsonPatchError("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");a||(e=o._deepClone(e));for(var p=new Array(r.length),s=0,c=r.length;s0)throw new t.JsonPatchError('Operation `path` property must start with "/"',"OPERATION_PATH_INVALID",r,e,n);if(("move"===e.op||"copy"===e.op)&&"string"!=typeof e.from)throw new t.JsonPatchError("Operation `from` property is not present (applicable in `move` and `copy` operations)","OPERATION_FROM_REQUIRED",r,e,n);if(("add"===e.op||"replace"===e.op||"test"===e.op)&&void 0===e.value)throw new t.JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_REQUIRED",r,e,n);if(("add"===e.op||"replace"===e.op||"test"===e.op)&&o.hasUndefined(e.value))throw new t.JsonPatchError("Operation `value` property is not present (applicable in `add`, `replace` and `test` operations)","OPERATION_VALUE_CANNOT_CONTAIN_UNDEFINED",r,e,n);if(n)if("add"==e.op){var p=e.path.split("/").length,u=i.split("/").length;if(p!==u+1&&p!==u)throw new t.JsonPatchError("Cannot perform an `add` operation at the desired path","OPERATION_PATH_CANNOT_ADD",r,e,n)}else if("replace"===e.op||"remove"===e.op||"_get"===e.op){if(e.path!==i)throw new t.JsonPatchError("Cannot perform the operation at a path that does not exist","OPERATION_PATH_UNRESOLVABLE",r,e,n)}else if("move"===e.op||"copy"===e.op){var s=f([{op:"_get",path:e.from,value:void 0}],n);if(s&&"OPERATION_PATH_UNRESOLVABLE"===s.name)throw new t.JsonPatchError("Cannot perform the operation from a path that does not exist","OPERATION_FROM_UNRESOLVABLE",r,e,n)}}function f(e,r,n){try{if(!Array.isArray(e))throw new t.JsonPatchError("Patch sequence must be an array","SEQUENCE_NOT_AN_ARRAY");if(r)s(o._deepClone(r),o._deepClone(e),n||!0);else{n=n||c;for(var a=0;a