@azrico/webobject 1.4.20 → 1.4.21
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.
|
@@ -193,7 +193,7 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
193
193
|
function () {
|
|
194
194
|
var _get_deltaObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(p) {
|
|
195
195
|
var _this2 = this;
|
|
196
|
-
var final_object, isChild, useDelta, allProperties, chkChangables, useExtraProps, dlt, allkeys, changableKeys, parseObj, _parseObj, _iterator, _step, key;
|
|
196
|
+
var final_object, isChild, useDelta, allProperties, chkChangables, useExtraProps, dlt, allkeys, changableKeys, parseObj, _parseObj, functionProps, index, fp, _iterator, _step, key;
|
|
197
197
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
198
198
|
while (1) switch (_context5.prev = _context5.next) {
|
|
199
199
|
case 0:
|
|
@@ -281,46 +281,53 @@ var WebObject = /*#__PURE__*/function (_SimpleObject) {
|
|
|
281
281
|
ignoreProtected: allProperties
|
|
282
282
|
});
|
|
283
283
|
}) : allkeys;
|
|
284
|
+
functionProps = (0, _object.object_getStatic)(this, "__functionProperties");
|
|
285
|
+
if (Array.isArray(functionProps)) {
|
|
286
|
+
for (index = 0; index < functionProps.length; index++) {
|
|
287
|
+
fp = functionProps[index];
|
|
288
|
+
if (dlt[fp]) dlt[fp] = (0, _object.fn_eval_this)(this, dlt[fp]);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
284
291
|
_iterator = _createForOfIteratorHelper(changableKeys);
|
|
285
|
-
_context5.prev =
|
|
292
|
+
_context5.prev = 15;
|
|
286
293
|
_iterator.s();
|
|
287
|
-
case
|
|
294
|
+
case 17:
|
|
288
295
|
if ((_step = _iterator.n()).done) {
|
|
289
|
-
_context5.next =
|
|
296
|
+
_context5.next = 24;
|
|
290
297
|
break;
|
|
291
298
|
}
|
|
292
299
|
key = _step.value;
|
|
293
|
-
_context5.next =
|
|
300
|
+
_context5.next = 21;
|
|
294
301
|
return parseObj(dlt[key]);
|
|
295
|
-
case
|
|
302
|
+
case 21:
|
|
296
303
|
final_object[key] = _context5.sent;
|
|
297
|
-
case 20:
|
|
298
|
-
_context5.next = 15;
|
|
299
|
-
break;
|
|
300
304
|
case 22:
|
|
301
|
-
_context5.next =
|
|
305
|
+
_context5.next = 17;
|
|
302
306
|
break;
|
|
303
307
|
case 24:
|
|
304
|
-
_context5.
|
|
305
|
-
|
|
308
|
+
_context5.next = 29;
|
|
309
|
+
break;
|
|
310
|
+
case 26:
|
|
311
|
+
_context5.prev = 26;
|
|
312
|
+
_context5.t0 = _context5["catch"](15);
|
|
306
313
|
_iterator.e(_context5.t0);
|
|
307
|
-
case
|
|
308
|
-
_context5.prev =
|
|
314
|
+
case 29:
|
|
315
|
+
_context5.prev = 29;
|
|
309
316
|
_iterator.f();
|
|
310
|
-
return _context5.finish(
|
|
311
|
-
case
|
|
317
|
+
return _context5.finish(29);
|
|
318
|
+
case 32:
|
|
312
319
|
if (allProperties) {
|
|
313
320
|
final_object["_id"] = this.getID();
|
|
314
|
-
final_object["_index_value"] = this.getIndex();
|
|
315
321
|
final_object["_index_key"] = this["_index_key"];
|
|
322
|
+
final_object["_index_value"] = this.getIndex();
|
|
316
323
|
final_object["_created_date"] = this["_created_date"];
|
|
317
324
|
}
|
|
318
325
|
return _context5.abrupt("return", final_object);
|
|
319
|
-
case
|
|
326
|
+
case 34:
|
|
320
327
|
case "end":
|
|
321
328
|
return _context5.stop();
|
|
322
329
|
}
|
|
323
|
-
}, _callee5, this, [[
|
|
330
|
+
}, _callee5, this, [[15, 26, 29, 32]]);
|
|
324
331
|
}));
|
|
325
332
|
function get_deltaObject(_x) {
|
|
326
333
|
return _get_deltaObject.apply(this, arguments);
|
|
@@ -7,7 +7,7 @@ import { saveResultType } from "./SimpleObject";
|
|
|
7
7
|
export declare class ObjectManager<ObjType extends SimpleObject> {
|
|
8
8
|
__eventList: any;
|
|
9
9
|
__eventPrefix?: string;
|
|
10
|
-
|
|
10
|
+
__stopEvents?: boolean;
|
|
11
11
|
__currentObject?: ObjType | null;
|
|
12
12
|
__options?: object;
|
|
13
13
|
__object_nullable: boolean;
|
|
@@ -60,6 +60,7 @@ export declare class ObjectManager<ObjType extends SimpleObject> {
|
|
|
60
60
|
event_use(name: string, runEvent: (...inputdata: any) => any, onlyOn?: any, runOnce?: boolean): any;
|
|
61
61
|
event_remove(name: string, uname: string): boolean;
|
|
62
62
|
event_add(name: string, uname: string, runEvent: (...inputdata: any) => any, onlyOn?: any, runOnce?: boolean): Promise<void>;
|
|
63
|
+
events_start(): void;
|
|
63
64
|
events_stop(): void;
|
|
64
65
|
events_clear(): void;
|
|
65
66
|
static events_clear(obj: ObjectManager<any>): void;
|
|
@@ -28,9 +28,10 @@ var ObjectManager = /*#__PURE__*/function () {
|
|
|
28
28
|
_classCallCheck(this, ObjectManager);
|
|
29
29
|
_defineProperty(this, "__eventList", void 0);
|
|
30
30
|
_defineProperty(this, "__eventPrefix", void 0);
|
|
31
|
-
_defineProperty(this, "
|
|
31
|
+
_defineProperty(this, "__stopEvents", void 0);
|
|
32
32
|
_defineProperty(this, "__currentObject", void 0);
|
|
33
33
|
_defineProperty(this, "__options", void 0);
|
|
34
|
+
//can the current object be set to null safely?
|
|
34
35
|
_defineProperty(this, "__object_nullable", false);
|
|
35
36
|
_defineProperty(this, "get", this.getValue);
|
|
36
37
|
}
|
|
@@ -319,7 +320,7 @@ var ObjectManager = /*#__PURE__*/function () {
|
|
|
319
320
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
320
321
|
while (1) switch (_context5.prev = _context5.next) {
|
|
321
322
|
case 0:
|
|
322
|
-
if (this.
|
|
323
|
+
if (!(this.__stopEvents === true)) {
|
|
323
324
|
_context5.next = 2;
|
|
324
325
|
break;
|
|
325
326
|
}
|
|
@@ -380,10 +381,15 @@ var ObjectManager = /*#__PURE__*/function () {
|
|
|
380
381
|
}
|
|
381
382
|
return event_add;
|
|
382
383
|
}()
|
|
384
|
+
}, {
|
|
385
|
+
key: "events_start",
|
|
386
|
+
value: function events_start() {
|
|
387
|
+
delete this.__stopEvents;
|
|
388
|
+
}
|
|
383
389
|
}, {
|
|
384
390
|
key: "events_stop",
|
|
385
391
|
value: function events_stop() {
|
|
386
|
-
this.
|
|
392
|
+
this.__stopEvents = true;
|
|
387
393
|
}
|
|
388
394
|
}, {
|
|
389
395
|
key: "events_clear",
|
|
@@ -12,6 +12,7 @@ export declare class SimpleObject extends MapableObject {
|
|
|
12
12
|
static readonly __unchangeables?: string[];
|
|
13
13
|
static readonly __changeables?: string[];
|
|
14
14
|
static readonly __protectedProperties?: string[];
|
|
15
|
+
static readonly __functionProperties?: string[];
|
|
15
16
|
static readonly __extraProperties?: string[];
|
|
16
17
|
static readonly __use_delta: boolean;
|
|
17
18
|
_static(): Function;
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = exports.SimpleObject = void 0;
|
|
7
|
-
var _global = require("@azrico/global");
|
|
8
7
|
var _object = require("@azrico/object");
|
|
8
|
+
var _global = require("@azrico/global");
|
|
9
9
|
var _MapableObject2 = require("./MapableObject");
|
|
10
10
|
var _ObjectManager = _interopRequireDefault(require("./ObjectManager"));
|
|
11
11
|
var _string = require("@azrico/string");
|
|
@@ -1108,9 +1108,15 @@ function _setDefaultProperty2(key, value) {
|
|
|
1108
1108
|
}
|
|
1109
1109
|
function _getProperty2(key) {
|
|
1110
1110
|
var original = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
1111
|
+
//check if we should treat the prop as a function
|
|
1112
|
+
var is_fnc = this.constructor["__functionProperties"] != null && this.constructor["__functionProperties"].includes(key);
|
|
1111
1113
|
//check if we should use delta version or normal version for this property
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
+
var use_orig = original || !this.__use_delta || !(key in this.__delta);
|
|
1115
|
+
if (is_fnc) {
|
|
1116
|
+
if (use_orig) return (0, _object.fn_eval_this)(this, this[key]);
|
|
1117
|
+
return (0, _object.fn_eval_this)(this, this.__delta[key]);
|
|
1118
|
+
}
|
|
1119
|
+
if (use_orig) return this[key];
|
|
1114
1120
|
return this.__delta[key];
|
|
1115
1121
|
}
|
|
1116
1122
|
function _getTempProperty2(key) {
|
|
@@ -1131,6 +1137,8 @@ _defineProperty(SimpleObject, "__unchangeables", void 0);
|
|
|
1131
1137
|
_defineProperty(SimpleObject, "__changeables", void 0);
|
|
1132
1138
|
//these properties can only be changed by the _creator
|
|
1133
1139
|
_defineProperty(SimpleObject, "__protectedProperties", void 0);
|
|
1140
|
+
//these properties will be evaluated when needed
|
|
1141
|
+
_defineProperty(SimpleObject, "__functionProperties", void 0);
|
|
1134
1142
|
//these properties usually are not directly changed and sometimes are included in deltaObject
|
|
1135
1143
|
_defineProperty(SimpleObject, "__extraProperties", void 0);
|
|
1136
1144
|
_defineProperty(SimpleObject, "__use_delta", true);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azrico/webobject",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.21",
|
|
4
4
|
"description": "Stateful object",
|
|
5
5
|
"author": "Azrideus",
|
|
6
6
|
"license": "MIT",
|
|
@@ -71,8 +71,8 @@
|
|
|
71
71
|
"dependencies": {
|
|
72
72
|
"@azrico/event": "^1.2.15",
|
|
73
73
|
"@azrico/global": "^1.3.22",
|
|
74
|
-
"@azrico/object": "^1.4.
|
|
75
|
-
"@azrico/string": "^1.2.
|
|
74
|
+
"@azrico/object": "^1.4.41",
|
|
75
|
+
"@azrico/string": "^1.2.32",
|
|
76
76
|
"@azrico/uid": "^1.0.5"
|
|
77
77
|
}
|
|
78
78
|
}
|