@azrico/webobject 1.5.6 → 1.5.8
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.
|
@@ -49,7 +49,15 @@ export declare class SimpleObject extends MapableObject {
|
|
|
49
49
|
constructor(is_readonly?: boolean);
|
|
50
50
|
get<MKey extends PropOf<this>>(key: MKey, original?: boolean): PropType<this, MKey>;
|
|
51
51
|
get<MKey extends PropOnlyPrefixedOf<this>>(key: MKey, original?: boolean): any;
|
|
52
|
-
|
|
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
|
|
@@ -59,6 +67,12 @@ export declare class SimpleObject extends MapableObject {
|
|
|
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
|
-
setValue: (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,7 +90,6 @@ 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;
|
|
@@ -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,7 +81,9 @@ 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, "getSubValue", _assertClassBrand(_SimpleObject_brand, _this, _getSubProperty));
|
|
84
85
|
/**
|
|
86
|
+
* @deprecated use `set`
|
|
85
87
|
* set value and run the event handlers if needed
|
|
86
88
|
* @return true if changed , false otherwise
|
|
87
89
|
*/
|
|
@@ -100,7 +102,6 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
100
102
|
* @returns
|
|
101
103
|
*/
|
|
102
104
|
_defineProperty(_this, "setDefault", _this.setDefaultValue);
|
|
103
|
-
_defineProperty(_this, "getSubValue", _assertClassBrand(_SimpleObject_brand, _this, _getSubProperty));
|
|
104
105
|
_defineProperty(_this, "get_managerClass", function () {
|
|
105
106
|
return undefined;
|
|
106
107
|
});
|
|
@@ -126,8 +127,8 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
126
127
|
if (typeof key === "string" && key.includes(".")) {
|
|
127
128
|
/* ----------------------------- using sub value ---------------------------- */
|
|
128
129
|
var keysp = key.split(".");
|
|
129
|
-
var
|
|
130
|
-
var
|
|
130
|
+
var key_part = keysp.shift();
|
|
131
|
+
var subkey_part = keysp.shift();
|
|
131
132
|
used_value = _assertClassBrand(_SimpleObject_brand, this, _getSubProperty).call(this, key_part, subkey_part);
|
|
132
133
|
} else {
|
|
133
134
|
/* --------------------------- using this or delta -------------------------- */
|
|
@@ -137,6 +138,13 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
137
138
|
}
|
|
138
139
|
return is_fnc ? (0, _object.fn_eval_this)(this, used_value) : used_value;
|
|
139
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* static get method for SimpleObject
|
|
143
|
+
* @param obj
|
|
144
|
+
* @param key
|
|
145
|
+
* @param original
|
|
146
|
+
* @returns
|
|
147
|
+
*/
|
|
140
148
|
}, {
|
|
141
149
|
key: "set",
|
|
142
150
|
value: (
|
|
@@ -152,6 +160,9 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
152
160
|
var _set = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(key, value) {
|
|
153
161
|
var shouldNotify,
|
|
154
162
|
autoApply,
|
|
163
|
+
keysp,
|
|
164
|
+
key_part,
|
|
165
|
+
subkey_part,
|
|
155
166
|
keyExists,
|
|
156
167
|
old_value,
|
|
157
168
|
needsChange,
|
|
@@ -174,6 +185,18 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
174
185
|
case 7:
|
|
175
186
|
return _context.abrupt("return", false);
|
|
176
187
|
case 8:
|
|
188
|
+
if (!(typeof key === "string" && key.includes("."))) {
|
|
189
|
+
_context.next = 15;
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
keysp = key.split(".");
|
|
193
|
+
key_part = keysp.shift();
|
|
194
|
+
subkey_part = keysp.shift();
|
|
195
|
+
_context.next = 14;
|
|
196
|
+
return this.setSubValue(key_part, subkey_part, value, shouldNotify);
|
|
197
|
+
case 14:
|
|
198
|
+
return _context.abrupt("return", _context.sent);
|
|
199
|
+
case 15:
|
|
177
200
|
/* --------------------------- set if not changed --------------------------- */
|
|
178
201
|
keyExists = key in this.__delta;
|
|
179
202
|
old_value = this.get(key);
|
|
@@ -199,14 +222,14 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
199
222
|
}
|
|
200
223
|
/* --------------------------------- notify --------------------------------- */
|
|
201
224
|
if (!(shouldNotify === true || shouldNotify === "auto" && needsChange)) {
|
|
202
|
-
_context.next =
|
|
225
|
+
_context.next = 23;
|
|
203
226
|
break;
|
|
204
227
|
}
|
|
205
|
-
_context.next =
|
|
228
|
+
_context.next = 23;
|
|
206
229
|
return this.notifyChanged("", key, value);
|
|
207
|
-
case
|
|
230
|
+
case 23:
|
|
208
231
|
return _context.abrupt("return", needsChange);
|
|
209
|
-
case
|
|
232
|
+
case 24:
|
|
210
233
|
case "end":
|
|
211
234
|
return _context.stop();
|
|
212
235
|
}
|
|
@@ -216,7 +239,10 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
216
239
|
return _set.apply(this, arguments);
|
|
217
240
|
}
|
|
218
241
|
return set;
|
|
219
|
-
}()
|
|
242
|
+
}())
|
|
243
|
+
}, {
|
|
244
|
+
key: "setPreferApply",
|
|
245
|
+
value: (
|
|
220
246
|
/**
|
|
221
247
|
* set value and run the event handlers if needed
|
|
222
248
|
*
|
|
@@ -224,10 +250,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
224
250
|
* @param key
|
|
225
251
|
* @param value
|
|
226
252
|
*/
|
|
227
|
-
)
|
|
228
|
-
}, {
|
|
229
|
-
key: "setPreferApply",
|
|
230
|
-
value: (function () {
|
|
253
|
+
function () {
|
|
231
254
|
var _setPreferApply = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key, value) {
|
|
232
255
|
var shouldNotify,
|
|
233
256
|
_args2 = arguments;
|
|
@@ -249,25 +272,14 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
249
272
|
return _setPreferApply.apply(this, arguments);
|
|
250
273
|
}
|
|
251
274
|
return setPreferApply;
|
|
252
|
-
}()
|
|
253
|
-
|
|
254
|
-
key: "loadValues",
|
|
255
|
-
value: /* -------------------------------------------------------------------------- */
|
|
275
|
+
}()
|
|
276
|
+
/* -------------------------------------------------------------------------- */
|
|
256
277
|
/* Load */
|
|
257
278
|
/* -------------------------------------------------------------------------- */
|
|
258
|
-
|
|
259
|
-
* load all properties in `initObject` into the current object
|
|
260
|
-
* @param initObject
|
|
261
|
-
* @param fullUpdate
|
|
262
|
-
* @returns
|
|
263
|
-
*/
|
|
264
|
-
function loadValues(initObject) {
|
|
265
|
-
var fullUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
266
|
-
return SimpleObject.loadValues(this, initObject, fullUpdate);
|
|
267
|
-
}
|
|
279
|
+
)
|
|
268
280
|
}, {
|
|
269
281
|
key: "setTemp",
|
|
270
|
-
value: function () {
|
|
282
|
+
value: (function () {
|
|
271
283
|
var _setTemp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key, value) {
|
|
272
284
|
var sendChanges,
|
|
273
285
|
isValueChanged,
|
|
@@ -298,10 +310,24 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
298
310
|
return _setTemp.apply(this, arguments);
|
|
299
311
|
}
|
|
300
312
|
return setTemp;
|
|
301
|
-
}()
|
|
313
|
+
}()
|
|
314
|
+
/* -------------------------------------------------------------------------- */
|
|
315
|
+
/**
|
|
316
|
+
* load all properties in `initObject` into the current object
|
|
317
|
+
* @param initObject
|
|
318
|
+
* @param fullUpdate
|
|
319
|
+
* @returns
|
|
320
|
+
*/
|
|
321
|
+
)
|
|
322
|
+
}, {
|
|
323
|
+
key: "loadValues",
|
|
324
|
+
value: function loadValues(initObject) {
|
|
325
|
+
var fullUpdate = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
326
|
+
return SimpleObject.loadValues(this, initObject, fullUpdate);
|
|
327
|
+
}
|
|
302
328
|
}, {
|
|
303
329
|
key: "clearRefreshFunction",
|
|
304
|
-
value: (function () {
|
|
330
|
+
value: ( /* ---------------------------- refresh functions --------------------------- */function () {
|
|
305
331
|
var _clearRefreshFunction = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4() {
|
|
306
332
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
307
333
|
while (1) switch (_context4.prev = _context4.next) {
|
|
@@ -493,6 +519,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
493
519
|
* @param key
|
|
494
520
|
* @param value
|
|
495
521
|
* @param subvalue
|
|
522
|
+
* @param sendChanges
|
|
496
523
|
* @return true if changed , false otherwise
|
|
497
524
|
*/
|
|
498
525
|
function () {
|
|
@@ -550,10 +577,7 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
550
577
|
return _setSubValue.apply(this, arguments);
|
|
551
578
|
}
|
|
552
579
|
return setSubValue;
|
|
553
|
-
}()
|
|
554
|
-
}, {
|
|
555
|
-
key: "pushValue",
|
|
556
|
-
value: (
|
|
580
|
+
}()
|
|
557
581
|
/**
|
|
558
582
|
* Push a single value to array property
|
|
559
583
|
* @param key
|
|
@@ -561,7 +585,10 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
561
585
|
* @param sendChanges
|
|
562
586
|
* @returns
|
|
563
587
|
*/
|
|
564
|
-
|
|
588
|
+
)
|
|
589
|
+
}, {
|
|
590
|
+
key: "pushValue",
|
|
591
|
+
value: (function () {
|
|
565
592
|
var _pushValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(key, value) {
|
|
566
593
|
var sendChanges,
|
|
567
594
|
_args10 = arguments;
|
|
@@ -1226,16 +1253,16 @@ var SimpleObject = exports.SimpleObject = /*#__PURE__*/function (_MapableObject)
|
|
|
1226
1253
|
/* -------------------------------------------------------------------------- */
|
|
1227
1254
|
}], [{
|
|
1228
1255
|
key: "get",
|
|
1229
|
-
value: function get(
|
|
1256
|
+
value: function get(obj, key) {
|
|
1230
1257
|
var original = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
1231
|
-
if (
|
|
1232
|
-
if (
|
|
1258
|
+
if (obj == null) return undefined;
|
|
1259
|
+
if (obj instanceof SimpleObject && typeof obj.get === "function") return obj.get(key, original);
|
|
1233
1260
|
/* ------------------------------- manual get ------------------------------- */
|
|
1234
|
-
if (!original &&
|
|
1261
|
+
if (!original && obj.__use_delta != false && _typeof(obj.__delta) === "object" && key in obj.__delta) {
|
|
1235
1262
|
//@ts-ignore
|
|
1236
|
-
return
|
|
1263
|
+
return obj.__delta[key];
|
|
1237
1264
|
}
|
|
1238
|
-
return
|
|
1265
|
+
return obj[key];
|
|
1239
1266
|
}
|
|
1240
1267
|
/* -------------------------------------------------------------------------- */
|
|
1241
1268
|
/* set */
|
|
@@ -1677,24 +1704,6 @@ function _setProperty(key, value) {
|
|
|
1677
1704
|
this.__delta[key] = value; //always update delta to keep track of changes
|
|
1678
1705
|
}
|
|
1679
1706
|
return true;
|
|
1680
|
-
//// if (checkIsChanged || this.__has_delta === false) {
|
|
1681
|
-
//// /**
|
|
1682
|
-
//// * if any key exists in the `__delta` then the object is changed
|
|
1683
|
-
//// */
|
|
1684
|
-
//// let next__has_delta = false;
|
|
1685
|
-
//// for (const key in this.__delta) {
|
|
1686
|
-
//// next__has_delta = true;
|
|
1687
|
-
//// break;
|
|
1688
|
-
//// }
|
|
1689
|
-
//// let previous__has_delta = this.__has_delta;
|
|
1690
|
-
//// this.__has_delta = next__has_delta;
|
|
1691
|
-
//// /**
|
|
1692
|
-
//// * if the state of __has_delta is changed we return true
|
|
1693
|
-
//// * so we can run the needed events
|
|
1694
|
-
//// */
|
|
1695
|
-
//// return previous__has_delta != this.__has_delta;
|
|
1696
|
-
//// }
|
|
1697
|
-
//// return false;
|
|
1698
1707
|
}
|
|
1699
1708
|
function _setSaveResultObject(toObj) {
|
|
1700
1709
|
if (toObj == null) toObj = null; //null or undefined
|