@azrico/webobject 1.5.5 → 1.5.7
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.
|
@@ -125,10 +125,10 @@ var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
125
125
|
return _context.abrupt("return", false);
|
|
126
126
|
case 16:
|
|
127
127
|
//same value, no changes
|
|
128
|
-
new_metalist = _objectSpread({}, this.
|
|
128
|
+
new_metalist = _objectSpread({}, this.get("meta_data"));
|
|
129
129
|
new_metalist[key] = value;
|
|
130
130
|
_context.next = 20;
|
|
131
|
-
return this.
|
|
131
|
+
return this.set("meta_data", new_metalist);
|
|
132
132
|
case 20:
|
|
133
133
|
if (!(sendChange !== false)) {
|
|
134
134
|
_context.next = 23;
|
|
@@ -1105,7 +1105,7 @@ var WebObject = exports.WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
1105
1105
|
if (!key || typeof key != "string") return undefined;
|
|
1106
1106
|
var metalist = {};
|
|
1107
1107
|
if (_typeof(o) === "object") {
|
|
1108
|
-
metalist = typeof o.
|
|
1108
|
+
metalist = typeof o.get === "function" ? o.get("meta_data") : o.meta_data;
|
|
1109
1109
|
}
|
|
1110
1110
|
return metalist[key];
|
|
1111
1111
|
}
|
|
@@ -47,15 +47,14 @@ export declare class ObjectManager<ObjType extends SimpleObject> extends RawObje
|
|
|
47
47
|
getSaveResultType(): saveResultType | null;
|
|
48
48
|
setSaveResult(toObj: any, type: saveResultType): saveResultType | undefined;
|
|
49
49
|
apply_changes(): boolean;
|
|
50
|
-
|
|
51
|
-
get: (key: PropOf<ObjType>, original?: boolean) => import("@azrico/types").PropType<ObjType, any> | null;
|
|
50
|
+
get(key: PropOf<ObjType>, original?: boolean): import("@azrico/types").PropType<ObjType, any> | null;
|
|
52
51
|
/**
|
|
53
52
|
* set value
|
|
54
53
|
* @param key
|
|
55
54
|
* @param value
|
|
56
55
|
* @return true if changed , false otherwise
|
|
57
56
|
*/
|
|
58
|
-
|
|
57
|
+
set(key: WriteablePropOf<ObjType>, value: any): Promise<boolean>;
|
|
59
58
|
/**
|
|
60
59
|
* set key of subObject
|
|
61
60
|
* @param key
|
|
@@ -46,7 +46,6 @@ var ObjectManager = exports.ObjectManager = /*#__PURE__*/function (_RawObject) {
|
|
|
46
46
|
_defineProperty(_this, "__options", void 0);
|
|
47
47
|
//can the current object be set to null safely?
|
|
48
48
|
_defineProperty(_this, "__object_nullable", false);
|
|
49
|
-
_defineProperty(_this, "get", _this.getValue);
|
|
50
49
|
_this.setObject(defaultObject);
|
|
51
50
|
return _this;
|
|
52
51
|
}
|
|
@@ -66,7 +65,7 @@ var ObjectManager = exports.ObjectManager = /*#__PURE__*/function (_RawObject) {
|
|
|
66
65
|
}
|
|
67
66
|
return _context.abrupt("return", false);
|
|
68
67
|
case 3:
|
|
69
|
-
if (value === undefined && type != "meta") value = obj.
|
|
68
|
+
if (value === undefined && type != "meta") value = obj.get(key);
|
|
70
69
|
typestr = (type ? "$".concat(type, "$") : "") + String(key);
|
|
71
70
|
_context.next = 7;
|
|
72
71
|
return this.event_run("on_change", typestr, value);
|
|
@@ -196,41 +195,40 @@ var ObjectManager = exports.ObjectManager = /*#__PURE__*/function (_RawObject) {
|
|
|
196
195
|
return ((_this$obj7 = this.obj) === null || _this$obj7 === void 0 ? void 0 : _this$obj7.apply_changes()) || false;
|
|
197
196
|
}
|
|
198
197
|
}, {
|
|
199
|
-
key: "
|
|
200
|
-
value: function
|
|
198
|
+
key: "get",
|
|
199
|
+
value: function get(key) {
|
|
201
200
|
var original = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
202
201
|
var thisobj = this.obj;
|
|
203
|
-
if (thisobj == null || typeof thisobj.
|
|
204
|
-
if (!this.__object_nullable) console.error("cant use
|
|
202
|
+
if (thisobj == null || typeof thisobj.get != "function") {
|
|
203
|
+
if (!this.__object_nullable) console.error("cant use get when object is not defined. maybe you have to use New() ?");
|
|
205
204
|
return null;
|
|
206
205
|
}
|
|
207
|
-
return thisobj.
|
|
206
|
+
return thisobj.get(key, original);
|
|
208
207
|
}
|
|
209
|
-
}, {
|
|
210
|
-
key: "setValue",
|
|
211
|
-
value: (
|
|
212
208
|
/**
|
|
213
209
|
* set value
|
|
214
210
|
* @param key
|
|
215
211
|
* @param value
|
|
216
212
|
* @return true if changed , false otherwise
|
|
217
213
|
*/
|
|
218
|
-
|
|
219
|
-
|
|
214
|
+
}, {
|
|
215
|
+
key: "set",
|
|
216
|
+
value: (function () {
|
|
217
|
+
var _set = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key, value) {
|
|
220
218
|
var thisobj;
|
|
221
219
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
222
220
|
while (1) switch (_context2.prev = _context2.next) {
|
|
223
221
|
case 0:
|
|
224
222
|
thisobj = this.obj;
|
|
225
|
-
if (!(thisobj == null || typeof thisobj.
|
|
223
|
+
if (!(thisobj == null || typeof thisobj.set != "function")) {
|
|
226
224
|
_context2.next = 4;
|
|
227
225
|
break;
|
|
228
226
|
}
|
|
229
|
-
if (!this.__object_nullable) console.error("cant use
|
|
227
|
+
if (!this.__object_nullable) console.error("cant use set when object is not defined. maybe you have to use New() ?");
|
|
230
228
|
return _context2.abrupt("return", false);
|
|
231
229
|
case 4:
|
|
232
230
|
_context2.next = 6;
|
|
233
|
-
return thisobj.
|
|
231
|
+
return thisobj.set(key, value);
|
|
234
232
|
case 6:
|
|
235
233
|
_context2.t0 = _context2.sent;
|
|
236
234
|
if (_context2.t0) {
|
|
@@ -246,10 +244,10 @@ var ObjectManager = exports.ObjectManager = /*#__PURE__*/function (_RawObject) {
|
|
|
246
244
|
}
|
|
247
245
|
}, _callee2, this);
|
|
248
246
|
}));
|
|
249
|
-
function
|
|
250
|
-
return
|
|
247
|
+
function set(_x5, _x6) {
|
|
248
|
+
return _set.apply(this, arguments);
|
|
251
249
|
}
|
|
252
|
-
return
|
|
250
|
+
return set;
|
|
253
251
|
}()
|
|
254
252
|
/**
|
|
255
253
|
* set key of subObject
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PropType, WriteablePropOf, PropOf, Ensure } from "@azrico/types";
|
|
1
|
+
import { PropType, WriteablePropOf, PropOf, Ensure, PropOnlyPrefixedOf } from "@azrico/types";
|
|
2
2
|
import { formatObject } from "@azrico/convert";
|
|
3
3
|
import { MapableObject } from "./MapableObject";
|
|
4
4
|
import ObjectManager from "./ObjectManager";
|
|
@@ -47,9 +47,17 @@ export declare class SimpleObject extends MapableObject {
|
|
|
47
47
|
_index_key: string;
|
|
48
48
|
_index_value: number;
|
|
49
49
|
constructor(is_readonly?: boolean);
|
|
50
|
-
|
|
51
|
-
get
|
|
52
|
-
|
|
50
|
+
get<MKey extends PropOf<this>>(key: MKey, original?: boolean): PropType<this, MKey>;
|
|
51
|
+
get<MKey extends PropOnlyPrefixedOf<this>>(key: MKey, original?: boolean): any;
|
|
52
|
+
/**
|
|
53
|
+
* static get method for SimpleObject
|
|
54
|
+
* @param obj
|
|
55
|
+
* @param key
|
|
56
|
+
* @param original
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
static get<T extends SimpleObject, MKey extends PropOf<T>>(obj: T, key: MKey, original?: boolean): PropType<T, MKey> | undefined;
|
|
60
|
+
getSubValue: (key: PropOf<this>, subkey: string, original?: boolean) => any;
|
|
53
61
|
/**
|
|
54
62
|
* set value and run the event handlers if needed
|
|
55
63
|
* @param key
|
|
@@ -58,7 +66,13 @@ export declare class SimpleObject extends MapableObject {
|
|
|
58
66
|
* @param autoApply if the field is not in delta, instantly calls the `apply` function to remove from delta
|
|
59
67
|
* @returns
|
|
60
68
|
*/
|
|
61
|
-
|
|
69
|
+
set(key: WriteablePropOf<this>, value: any, shouldNotify?: sendChangesType, autoApply?: boolean): Promise<boolean>;
|
|
70
|
+
/**
|
|
71
|
+
* @deprecated use `set`
|
|
72
|
+
* set value and run the event handlers if needed
|
|
73
|
+
* @return true if changed , false otherwise
|
|
74
|
+
*/
|
|
75
|
+
setValue: (key: WriteablePropOf<this>, value: any, shouldNotify?: sendChangesType, autoApply?: boolean) => Promise<boolean>;
|
|
62
76
|
/**
|
|
63
77
|
* set value and run the event handlers if needed
|
|
64
78
|
*
|
|
@@ -67,11 +81,7 @@ export declare class SimpleObject extends MapableObject {
|
|
|
67
81
|
* @param value
|
|
68
82
|
*/
|
|
69
83
|
setPreferApply(key: WriteablePropOf<this>, value: any, shouldNotify?: sendChangesType): Promise<boolean>;
|
|
70
|
-
|
|
71
|
-
* set value and run the event handlers if needed
|
|
72
|
-
* @return true if changed , false otherwise
|
|
73
|
-
*/
|
|
74
|
-
set: (key: WriteablePropOf<this>, value: any, shouldNotify?: sendChangesType, autoApply?: boolean) => Promise<boolean>;
|
|
84
|
+
setTemp(key: string, value: any, sendChanges?: sendChangesType): Promise<boolean>;
|
|
75
85
|
/**
|
|
76
86
|
* load all properties in `initObject` into the current object
|
|
77
87
|
* @param initObject
|
|
@@ -80,13 +90,12 @@ export declare class SimpleObject extends MapableObject {
|
|
|
80
90
|
*/
|
|
81
91
|
loadValues(initObject: any, fullUpdate?: boolean): boolean;
|
|
82
92
|
static loadValues(obj: SimpleObject, initObject: any, fullUpdate?: boolean): boolean;
|
|
83
|
-
setTemp(key: string, value: any, sendChanges?: sendChangesType): Promise<boolean>;
|
|
84
93
|
clearRefreshFunction(): Promise<void>;
|
|
85
94
|
setRefreshFunction(new_fnc: any): Promise<any>;
|
|
86
95
|
addRefreshFunction(new_fnc: any): any;
|
|
87
96
|
runRefreshFunction(...params: any): Promise<void>;
|
|
88
97
|
/**
|
|
89
|
-
* calls `
|
|
98
|
+
* calls `set` function for all props of `setObj`
|
|
90
99
|
* @param setObj
|
|
91
100
|
* @param changeablesOnly only updates the `__changeables` fields
|
|
92
101
|
* @returns
|
|
@@ -120,10 +129,10 @@ export declare class SimpleObject extends MapableObject {
|
|
|
120
129
|
* @param key
|
|
121
130
|
* @param value
|
|
122
131
|
* @param subvalue
|
|
132
|
+
* @param sendChanges
|
|
123
133
|
* @return true if changed , false otherwise
|
|
124
134
|
*/
|
|
125
135
|
setSubValue<MKey extends PropOf<this>>(key: MKey, objKey: string, subvalue: any, sendChanges?: sendChangesType): Promise<boolean>;
|
|
126
|
-
getSubValue: (key: PropOf<this>, subkey: string, original?: boolean) => any;
|
|
127
136
|
/**
|
|
128
137
|
* Push a single value to array property
|
|
129
138
|
* @param key
|
|
@@ -81,13 +81,13 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
81
81
|
_defineProperty(_this, "_index_key", "");
|
|
82
82
|
//sequence value , used to index the object with increasing numbers
|
|
83
83
|
_defineProperty(_this, "_index_value", -1);
|
|
84
|
-
_defineProperty(_this, "
|
|
85
|
-
_defineProperty(_this, "get", _assertClassBrand(_SimpleObject_brand, _this, _getProperty));
|
|
84
|
+
_defineProperty(_this, "getSubValue", _assertClassBrand(_SimpleObject_brand, _this, _getSubProperty));
|
|
86
85
|
/**
|
|
86
|
+
* @deprecated use `set`
|
|
87
87
|
* set value and run the event handlers if needed
|
|
88
88
|
* @return true if changed , false otherwise
|
|
89
89
|
*/
|
|
90
|
-
_defineProperty(_this, "
|
|
90
|
+
_defineProperty(_this, "setValue", _this.set);
|
|
91
91
|
/**
|
|
92
92
|
* set value of a key to now date time
|
|
93
93
|
* @param key
|
|
@@ -102,7 +102,6 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
102
102
|
* @returns
|
|
103
103
|
*/
|
|
104
104
|
_defineProperty(_this, "setDefault", _this.setDefaultValue);
|
|
105
|
-
_defineProperty(_this, "getSubValue", _assertClassBrand(_SimpleObject_brand, _this, _getSubProperty));
|
|
106
105
|
_defineProperty(_this, "get_managerClass", function () {
|
|
107
106
|
return undefined;
|
|
108
107
|
});
|
|
@@ -118,7 +117,36 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
118
117
|
return this.constructor;
|
|
119
118
|
}
|
|
120
119
|
}, {
|
|
121
|
-
key: "
|
|
120
|
+
key: "get",
|
|
121
|
+
value: function get(key) {
|
|
122
|
+
var original = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
123
|
+
//check if we should treat the prop as a function
|
|
124
|
+
var is_fnc = this.constructor["__functionProperties"] != null && this.constructor["__functionProperties"].includes(key);
|
|
125
|
+
//check if we should use delta version or normal version for this property
|
|
126
|
+
var used_value;
|
|
127
|
+
if (typeof key === "string" && key.includes(".")) {
|
|
128
|
+
/* ----------------------------- using sub value ---------------------------- */
|
|
129
|
+
var keysp = key.split(".");
|
|
130
|
+
var key_part = keysp.shift();
|
|
131
|
+
var subkey_part = keysp.shift();
|
|
132
|
+
used_value = _assertClassBrand(_SimpleObject_brand, this, _getSubProperty).call(this, key_part, subkey_part);
|
|
133
|
+
} else {
|
|
134
|
+
/* --------------------------- using this or delta -------------------------- */
|
|
135
|
+
var self_key = key;
|
|
136
|
+
var use_orig = original || !this.__use_delta || !(self_key in this.__delta);
|
|
137
|
+
used_value = use_orig ? this[self_key] : this.__delta[self_key];
|
|
138
|
+
}
|
|
139
|
+
return is_fnc ? (0, _object.fn_eval_this)(this, used_value) : used_value;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* static get method for SimpleObject
|
|
143
|
+
* @param obj
|
|
144
|
+
* @param key
|
|
145
|
+
* @param original
|
|
146
|
+
* @returns
|
|
147
|
+
*/
|
|
148
|
+
}, {
|
|
149
|
+
key: "set",
|
|
122
150
|
value: (
|
|
123
151
|
/**
|
|
124
152
|
* set value and run the event handlers if needed
|
|
@@ -129,9 +157,12 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
129
157
|
* @returns
|
|
130
158
|
*/
|
|
131
159
|
function () {
|
|
132
|
-
var
|
|
160
|
+
var _set = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(key, value) {
|
|
133
161
|
var shouldNotify,
|
|
134
162
|
autoApply,
|
|
163
|
+
keysp,
|
|
164
|
+
key_part,
|
|
165
|
+
subkey_part,
|
|
135
166
|
keyExists,
|
|
136
167
|
old_value,
|
|
137
168
|
needsChange,
|
|
@@ -150,13 +181,22 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
150
181
|
_context.next = 7;
|
|
151
182
|
break;
|
|
152
183
|
}
|
|
153
|
-
throw Error("Cant use
|
|
184
|
+
throw Error("Cant use set (".concat(String(key), ") when on readonly mode"));
|
|
154
185
|
case 7:
|
|
155
186
|
return _context.abrupt("return", false);
|
|
156
187
|
case 8:
|
|
188
|
+
if (!(typeof key === "string" && key.includes("."))) {
|
|
189
|
+
_context.next = 13;
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
keysp = key.split(".");
|
|
193
|
+
key_part = keysp.shift();
|
|
194
|
+
subkey_part = keysp.shift();
|
|
195
|
+
return _context.abrupt("return", this.setSubValue(key_part, subkey_part, value));
|
|
196
|
+
case 13:
|
|
157
197
|
/* --------------------------- set if not changed --------------------------- */
|
|
158
198
|
keyExists = key in this.__delta;
|
|
159
|
-
old_value = this.
|
|
199
|
+
old_value = this.get(key);
|
|
160
200
|
needsChange = !(0, _object.object_equals)(old_value, value, {
|
|
161
201
|
strictArrayCheck: true,
|
|
162
202
|
ignoredStartingWords: "_"
|
|
@@ -179,24 +219,27 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
179
219
|
}
|
|
180
220
|
/* --------------------------------- notify --------------------------------- */
|
|
181
221
|
if (!(shouldNotify === true || shouldNotify === "auto" && needsChange)) {
|
|
182
|
-
_context.next =
|
|
222
|
+
_context.next = 21;
|
|
183
223
|
break;
|
|
184
224
|
}
|
|
185
|
-
_context.next =
|
|
225
|
+
_context.next = 21;
|
|
186
226
|
return this.notifyChanged("", key, value);
|
|
187
|
-
case
|
|
227
|
+
case 21:
|
|
188
228
|
return _context.abrupt("return", needsChange);
|
|
189
|
-
case
|
|
229
|
+
case 22:
|
|
190
230
|
case "end":
|
|
191
231
|
return _context.stop();
|
|
192
232
|
}
|
|
193
233
|
}, _callee, this);
|
|
194
234
|
}));
|
|
195
|
-
function
|
|
196
|
-
return
|
|
235
|
+
function set(_x, _x2) {
|
|
236
|
+
return _set.apply(this, arguments);
|
|
197
237
|
}
|
|
198
|
-
return
|
|
199
|
-
}()
|
|
238
|
+
return set;
|
|
239
|
+
}())
|
|
240
|
+
}, {
|
|
241
|
+
key: "setPreferApply",
|
|
242
|
+
value: (
|
|
200
243
|
/**
|
|
201
244
|
* set value and run the event handlers if needed
|
|
202
245
|
*
|
|
@@ -204,10 +247,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
204
247
|
* @param key
|
|
205
248
|
* @param value
|
|
206
249
|
*/
|
|
207
|
-
)
|
|
208
|
-
}, {
|
|
209
|
-
key: "setPreferApply",
|
|
210
|
-
value: (function () {
|
|
250
|
+
function () {
|
|
211
251
|
var _setPreferApply = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key, value) {
|
|
212
252
|
var shouldNotify,
|
|
213
253
|
_args2 = arguments;
|
|
@@ -229,25 +269,14 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
229
269
|
return _setPreferApply.apply(this, arguments);
|
|
230
270
|
}
|
|
231
271
|
return setPreferApply;
|
|
232
|
-
}()
|
|
233
|
-
|
|
234
|
-
key: "loadValues",
|
|
235
|
-
value: /* -------------------------------------------------------------------------- */
|
|
272
|
+
}()
|
|
273
|
+
/* -------------------------------------------------------------------------- */
|
|
236
274
|
/* Load */
|
|
237
275
|
/* -------------------------------------------------------------------------- */
|
|
238
|
-
|
|
239
|
-
* load all properties in `initObject` into the current object
|
|
240
|
-
* @param initObject
|
|
241
|
-
* @param fullUpdate
|
|
242
|
-
* @returns
|
|
243
|
-
*/
|
|
244
|
-
function loadValues(initObject) {
|
|
245
|
-
var fullUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
246
|
-
return SimpleObject.loadValues(this, initObject, fullUpdate);
|
|
247
|
-
}
|
|
276
|
+
)
|
|
248
277
|
}, {
|
|
249
278
|
key: "setTemp",
|
|
250
|
-
value: function () {
|
|
279
|
+
value: (function () {
|
|
251
280
|
var _setTemp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key, value) {
|
|
252
281
|
var sendChanges,
|
|
253
282
|
isValueChanged,
|
|
@@ -278,10 +307,24 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
278
307
|
return _setTemp.apply(this, arguments);
|
|
279
308
|
}
|
|
280
309
|
return setTemp;
|
|
281
|
-
}()
|
|
310
|
+
}()
|
|
311
|
+
/* -------------------------------------------------------------------------- */
|
|
312
|
+
/**
|
|
313
|
+
* load all properties in `initObject` into the current object
|
|
314
|
+
* @param initObject
|
|
315
|
+
* @param fullUpdate
|
|
316
|
+
* @returns
|
|
317
|
+
*/
|
|
318
|
+
)
|
|
319
|
+
}, {
|
|
320
|
+
key: "loadValues",
|
|
321
|
+
value: function loadValues(initObject) {
|
|
322
|
+
var fullUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
323
|
+
return SimpleObject.loadValues(this, initObject, fullUpdate);
|
|
324
|
+
}
|
|
282
325
|
}, {
|
|
283
326
|
key: "clearRefreshFunction",
|
|
284
|
-
value: (function () {
|
|
327
|
+
value: ( /* ---------------------------- refresh functions --------------------------- */function () {
|
|
285
328
|
var _clearRefreshFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
286
329
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
287
330
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -400,7 +443,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
400
443
|
}()
|
|
401
444
|
/* -------------------------------------------------------------------------- */
|
|
402
445
|
/**
|
|
403
|
-
* calls `
|
|
446
|
+
* calls `set` function for all props of `setObj`
|
|
404
447
|
* @param setObj
|
|
405
448
|
* @param changeablesOnly only updates the `__changeables` fields
|
|
406
449
|
* @returns
|
|
@@ -429,7 +472,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
429
472
|
}
|
|
430
473
|
key = checkKeys[index];
|
|
431
474
|
_context8.next = 8;
|
|
432
|
-
return this.
|
|
475
|
+
return this.set(key, setObj[key]);
|
|
433
476
|
case 8:
|
|
434
477
|
if (_context8.sent) {
|
|
435
478
|
_context8.next = 10;
|
|
@@ -473,6 +516,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
473
516
|
* @param key
|
|
474
517
|
* @param value
|
|
475
518
|
* @param subvalue
|
|
519
|
+
* @param sendChanges
|
|
476
520
|
* @return true if changed , false otherwise
|
|
477
521
|
*/
|
|
478
522
|
function () {
|
|
@@ -530,10 +574,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
530
574
|
return _setSubValue.apply(this, arguments);
|
|
531
575
|
}
|
|
532
576
|
return setSubValue;
|
|
533
|
-
}()
|
|
534
|
-
}, {
|
|
535
|
-
key: "pushValue",
|
|
536
|
-
value: (
|
|
577
|
+
}()
|
|
537
578
|
/**
|
|
538
579
|
* Push a single value to array property
|
|
539
580
|
* @param key
|
|
@@ -541,7 +582,10 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
541
582
|
* @param sendChanges
|
|
542
583
|
* @returns
|
|
543
584
|
*/
|
|
544
|
-
|
|
585
|
+
)
|
|
586
|
+
}, {
|
|
587
|
+
key: "pushValue",
|
|
588
|
+
value: (function () {
|
|
545
589
|
var _pushValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(key, value) {
|
|
546
590
|
var sendChanges,
|
|
547
591
|
_args10 = arguments;
|
|
@@ -601,8 +645,8 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
601
645
|
case 8:
|
|
602
646
|
return _context11.abrupt("return", false);
|
|
603
647
|
case 9:
|
|
604
|
-
if (
|
|
605
|
-
tempArray =
|
|
648
|
+
if (this.get(key) == null) _assertClassBrand(_SimpleObject_brand, this, _setProperty).call(this, key, []);
|
|
649
|
+
tempArray = this.get(key);
|
|
606
650
|
if (Array.isArray(tempArray)) {
|
|
607
651
|
_context11.next = 17;
|
|
608
652
|
break;
|
|
@@ -652,7 +696,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
652
696
|
return _regeneratorRuntime().wrap(function _callee12$(_context12) {
|
|
653
697
|
while (1) switch (_context12.prev = _context12.next) {
|
|
654
698
|
case 0:
|
|
655
|
-
if (value === undefined && type == "") value = this.
|
|
699
|
+
if (value === undefined && type == "") value = this.get(key);
|
|
656
700
|
lc = "";
|
|
657
701
|
if (type) lc += "$".concat(String(type), "$");
|
|
658
702
|
if (subvalue) {
|
|
@@ -751,7 +795,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
751
795
|
case 0:
|
|
752
796
|
shouldNotify = _args13.length > 1 && _args13[1] !== undefined ? _args13[1] : "auto";
|
|
753
797
|
_context13.next = 3;
|
|
754
|
-
return this.
|
|
798
|
+
return this.set(key, this[key], shouldNotify);
|
|
755
799
|
case 3:
|
|
756
800
|
return _context13.abrupt("return", _context13.sent);
|
|
757
801
|
case 4:
|
|
@@ -1205,19 +1249,20 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1205
1249
|
/* statics */
|
|
1206
1250
|
/* -------------------------------------------------------------------------- */
|
|
1207
1251
|
}], [{
|
|
1208
|
-
key: "
|
|
1209
|
-
value: function
|
|
1252
|
+
key: "get",
|
|
1253
|
+
value: function get(obj, key) {
|
|
1210
1254
|
var original = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1211
|
-
if (
|
|
1212
|
-
if (
|
|
1213
|
-
|
|
1255
|
+
if (obj == null) return undefined;
|
|
1256
|
+
if (obj instanceof SimpleObject && typeof obj.get === "function") return obj.get(key, original);
|
|
1257
|
+
/* ------------------------------- manual get ------------------------------- */
|
|
1258
|
+
if (!original && obj.__use_delta != false && _typeof(obj.__delta) === "object" && key in obj.__delta) {
|
|
1214
1259
|
//@ts-ignore
|
|
1215
|
-
return
|
|
1260
|
+
return obj.__delta[key];
|
|
1216
1261
|
}
|
|
1217
|
-
return
|
|
1262
|
+
return obj[key];
|
|
1218
1263
|
}
|
|
1219
1264
|
/* -------------------------------------------------------------------------- */
|
|
1220
|
-
/*
|
|
1265
|
+
/* set */
|
|
1221
1266
|
/* -------------------------------------------------------------------------- */
|
|
1222
1267
|
}, {
|
|
1223
1268
|
key: "loadValues",
|
|
@@ -1618,24 +1663,8 @@ function _setDefaultPropertyNow(key) {
|
|
|
1618
1663
|
}
|
|
1619
1664
|
return false;
|
|
1620
1665
|
}
|
|
1621
|
-
/* -------------------------------------------------------------------------- */
|
|
1622
|
-
/* getProperty */
|
|
1623
|
-
/* -------------------------------------------------------------------------- */
|
|
1624
|
-
function _getProperty(key) {
|
|
1625
|
-
var original = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1626
|
-
//check if we should treat the prop as a function
|
|
1627
|
-
var is_fnc = this.constructor["__functionProperties"] != null && this.constructor["__functionProperties"].includes(key);
|
|
1628
|
-
//check if we should use delta version or normal version for this property
|
|
1629
|
-
var use_orig = original || !this.__use_delta || !(key in this.__delta);
|
|
1630
|
-
if (is_fnc) {
|
|
1631
|
-
if (use_orig) return (0, _object.fn_eval_this)(this, this[key]);
|
|
1632
|
-
return (0, _object.fn_eval_this)(this, this.__delta[key]);
|
|
1633
|
-
}
|
|
1634
|
-
if (use_orig) return this[key];
|
|
1635
|
-
return this.__delta[key];
|
|
1636
|
-
}
|
|
1637
1666
|
function _setSubProperty(key, subkey, value) {
|
|
1638
|
-
var subobj =
|
|
1667
|
+
var subobj = this.get(key);
|
|
1639
1668
|
//@ts-ignore
|
|
1640
1669
|
if (subobj == null || _typeof(subobj) !== "object") subobj = {};else subobj = _objectSpread({}, subobj); //make a clone so we dont update the original
|
|
1641
1670
|
subobj[subkey] = value;
|
|
@@ -1643,7 +1672,7 @@ function _setSubProperty(key, subkey, value) {
|
|
|
1643
1672
|
}
|
|
1644
1673
|
function _getSubProperty(key, subkey) {
|
|
1645
1674
|
var original = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1646
|
-
var subobj =
|
|
1675
|
+
var subobj = this.get(key, original);
|
|
1647
1676
|
if (subobj == null || _typeof(subobj) !== "object") return undefined;
|
|
1648
1677
|
return subobj[subkey];
|
|
1649
1678
|
}
|
|
@@ -1672,24 +1701,6 @@ function _setProperty(key, value) {
|
|
|
1672
1701
|
this.__delta[key] = value; //always update delta to keep track of changes
|
|
1673
1702
|
}
|
|
1674
1703
|
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;
|
|
1693
1704
|
}
|
|
1694
1705
|
function _setSaveResultObject(toObj) {
|
|
1695
1706
|
if (toObj == null) toObj = null; //null or undefined
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azrico/webobject",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.7",
|
|
4
4
|
"description": "Stateful object",
|
|
5
5
|
"author": "Azrideus",
|
|
6
6
|
"license": "MIT",
|
|
@@ -69,13 +69,13 @@
|
|
|
69
69
|
"@azrico/uid": "*"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@azrico/convert": "^1.0.
|
|
73
|
-
"@azrico/event": "^1.2.
|
|
74
|
-
"@azrico/global": "^1.3.
|
|
72
|
+
"@azrico/convert": "^1.0.13",
|
|
73
|
+
"@azrico/event": "^1.2.52",
|
|
74
|
+
"@azrico/global": "^1.3.85",
|
|
75
75
|
"@azrico/math": "^1.0.5",
|
|
76
|
-
"@azrico/object": "^1.4.
|
|
77
|
-
"@azrico/string": "^1.2.
|
|
78
|
-
"@azrico/types": "^1.0.
|
|
76
|
+
"@azrico/object": "^1.4.112",
|
|
77
|
+
"@azrico/string": "^1.2.115",
|
|
78
|
+
"@azrico/types": "^1.0.11",
|
|
79
79
|
"@azrico/uid": "^1.0.8"
|
|
80
80
|
},
|
|
81
81
|
"packageManager": "yarn@3.5.0"
|