@azrico/webobject 1.5.4 → 1.5.5
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.
|
@@ -28,7 +28,6 @@ export declare class SimpleObject extends MapableObject {
|
|
|
28
28
|
_static(): Function;
|
|
29
29
|
protected __originalobject?: this;
|
|
30
30
|
protected __delta: Partial<this>;
|
|
31
|
-
protected __has_delta: boolean;
|
|
32
31
|
protected __lastChanged?: string;
|
|
33
32
|
protected __is_readonly?: boolean;
|
|
34
33
|
protected __throw_errors?: boolean;
|
|
@@ -52,7 +52,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
52
52
|
_defineProperty(_this, "__originalobject", void 0);
|
|
53
53
|
//changes are saved here
|
|
54
54
|
_defineProperty(_this, "__delta", {});
|
|
55
|
-
|
|
55
|
+
//// protected __has_delta: boolean = false;
|
|
56
56
|
//the last thing that was changed on this object
|
|
57
57
|
_defineProperty(_this, "__lastChanged", void 0);
|
|
58
58
|
//is the object read only
|
|
@@ -136,7 +136,6 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
136
136
|
old_value,
|
|
137
137
|
needsChange,
|
|
138
138
|
_this$manager,
|
|
139
|
-
__has_delta_isChanged,
|
|
140
139
|
_args = arguments;
|
|
141
140
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
142
141
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -163,15 +162,12 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
163
162
|
ignoredStartingWords: "_"
|
|
164
163
|
});
|
|
165
164
|
if (needsChange) {
|
|
166
|
-
|
|
165
|
+
_assertClassBrand(_SimpleObject_brand, this, _setProperty).call(this, key, value);
|
|
167
166
|
/**
|
|
168
167
|
* notify the manager when the state of `__has_delta` is changed
|
|
169
168
|
* managers can use this to detect if they need to save
|
|
170
169
|
*/
|
|
171
170
|
(_this$manager = this.manager) === null || _this$manager === void 0 || _this$manager.checkIsChanged();
|
|
172
|
-
////if (__has_delta_isChanged && this.manager) {
|
|
173
|
-
//// this.manager.setOption("hasDelta", this.__has_delta);
|
|
174
|
-
////}
|
|
175
171
|
}
|
|
176
172
|
/**
|
|
177
173
|
* if the field is not in delta
|
|
@@ -831,7 +827,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
831
827
|
key: "clear_changes",
|
|
832
828
|
value: function clear_changes() {
|
|
833
829
|
this.__delta = {};
|
|
834
|
-
this.__has_delta = false;
|
|
830
|
+
////this.__has_delta = false;
|
|
835
831
|
return true;
|
|
836
832
|
}
|
|
837
833
|
/**
|
|
@@ -871,11 +867,11 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
871
867
|
////if (!deltaIsBlank) return true; //delta is not blank, definitely changed
|
|
872
868
|
////if (this.__use_delta) return !deltaIsBlank; //trust the delta.
|
|
873
869
|
if (this.__use_delta) {
|
|
874
|
-
return this.__has_delta;
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
870
|
+
////return this.__has_delta;
|
|
871
|
+
for (var key in this.__delta) {
|
|
872
|
+
return true;
|
|
873
|
+
}
|
|
874
|
+
return false;
|
|
879
875
|
}
|
|
880
876
|
/* --------------------- check the properties one by one -------------------- */
|
|
881
877
|
var orig = this.getOriginal();
|
|
@@ -890,9 +886,9 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
890
886
|
}) != undefined;
|
|
891
887
|
} else {
|
|
892
888
|
/* check all fields */
|
|
893
|
-
for (var
|
|
894
|
-
if (
|
|
895
|
-
if (!(0, _object.object_equals)(this[
|
|
889
|
+
for (var _key2 in this) {
|
|
890
|
+
if (_key2.startsWith("__")) continue;
|
|
891
|
+
if (!(0, _object.object_equals)(this[_key2], orig[_key2])) return true;
|
|
896
892
|
}
|
|
897
893
|
return false;
|
|
898
894
|
}
|
|
@@ -1029,7 +1025,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1029
1025
|
var _this$manager2;
|
|
1030
1026
|
var _len2,
|
|
1031
1027
|
params,
|
|
1032
|
-
|
|
1028
|
+
_key3,
|
|
1033
1029
|
_args15 = arguments;
|
|
1034
1030
|
return _regeneratorRuntime().wrap(function _callee15$(_context15) {
|
|
1035
1031
|
while (1) switch (_context15.prev = _context15.next) {
|
|
@@ -1041,8 +1037,8 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1041
1037
|
if (this.__showErrors === true) console.error("you cant use events (".concat(eventName, ") if your object has no manager"));
|
|
1042
1038
|
return _context15.abrupt("return");
|
|
1043
1039
|
case 3:
|
|
1044
|
-
for (_len2 = _args15.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0),
|
|
1045
|
-
params[
|
|
1040
|
+
for (_len2 = _args15.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key3 = 1; _key3 < _len2; _key3++) {
|
|
1041
|
+
params[_key3 - 1] = _args15[_key3];
|
|
1046
1042
|
}
|
|
1047
1043
|
_context15.next = 6;
|
|
1048
1044
|
return (_this$manager2 = this.manager).event_run.apply(_this$manager2, [eventName].concat(params));
|
|
@@ -1240,10 +1236,10 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1240
1236
|
delete obj[key];
|
|
1241
1237
|
}
|
|
1242
1238
|
} else if (_typeof(initObject) == "object") {
|
|
1243
|
-
for (var
|
|
1244
|
-
if (
|
|
1245
|
-
if (fullUpdate || Object.prototype.hasOwnProperty.call(obj,
|
|
1246
|
-
obj[
|
|
1239
|
+
for (var _key4 in initObject) {
|
|
1240
|
+
if (_key4.startsWith("__")) continue;
|
|
1241
|
+
if (fullUpdate || Object.prototype.hasOwnProperty.call(obj, _key4)) {
|
|
1242
|
+
obj[_key4] = initObject[_key4];
|
|
1247
1243
|
}
|
|
1248
1244
|
}
|
|
1249
1245
|
}
|
|
@@ -1653,11 +1649,10 @@ function _getSubProperty(key, subkey) {
|
|
|
1653
1649
|
}
|
|
1654
1650
|
/**
|
|
1655
1651
|
* update a property on this object by updating the `__delta`
|
|
1656
|
-
* or
|
|
1652
|
+
* or update the object property directly depending on `__use_delta` setting
|
|
1657
1653
|
*
|
|
1658
1654
|
* @param key
|
|
1659
1655
|
* @param value
|
|
1660
|
-
* @returns true if state of `__has_delta` is changed, false otherwise
|
|
1661
1656
|
*/
|
|
1662
1657
|
function _setProperty(key, value) {
|
|
1663
1658
|
var checkIsChanged = false;
|
|
@@ -1668,7 +1663,7 @@ function _setProperty(key, value) {
|
|
|
1668
1663
|
* no need to save it as delta
|
|
1669
1664
|
*/
|
|
1670
1665
|
delete this.__delta[key];
|
|
1671
|
-
checkIsChanged = true; //check if we should set __has_delta to false
|
|
1666
|
+
////checkIsChanged = true; //check if we should set __has_delta to false
|
|
1672
1667
|
} else {
|
|
1673
1668
|
this.__delta[key] = value; //always update delta to keep track of changes
|
|
1674
1669
|
}
|
|
@@ -1676,24 +1671,25 @@ function _setProperty(key, value) {
|
|
|
1676
1671
|
this[key] = value; //on noDelta mode update the object itself
|
|
1677
1672
|
this.__delta[key] = value; //always update delta to keep track of changes
|
|
1678
1673
|
}
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1674
|
+
return true;
|
|
1675
|
+
//// if (checkIsChanged || this.__has_delta === false) {
|
|
1676
|
+
//// /**
|
|
1677
|
+
//// * if any key exists in the `__delta` then the object is changed
|
|
1678
|
+
//// */
|
|
1679
|
+
//// let next__has_delta = false;
|
|
1680
|
+
//// for (const key in this.__delta) {
|
|
1681
|
+
//// next__has_delta = true;
|
|
1682
|
+
//// break;
|
|
1683
|
+
//// }
|
|
1684
|
+
//// let previous__has_delta = this.__has_delta;
|
|
1685
|
+
//// this.__has_delta = next__has_delta;
|
|
1686
|
+
//// /**
|
|
1687
|
+
//// * if the state of __has_delta is changed we return true
|
|
1688
|
+
//// * so we can run the needed events
|
|
1689
|
+
//// */
|
|
1690
|
+
//// return previous__has_delta != this.__has_delta;
|
|
1691
|
+
//// }
|
|
1692
|
+
//// return false;
|
|
1697
1693
|
}
|
|
1698
1694
|
function _setSaveResultObject(toObj) {
|
|
1699
1695
|
if (toObj == null) toObj = null; //null or undefined
|