@azrico/webobject 1.4.19 → 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,9 +7,10 @@ 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
|
+
__object_nullable: boolean;
|
|
13
14
|
notifyChanged(type: string, key: PropOf<ObjType> | string, value?: any, subvalue?: string): Promise<false | any[] | undefined>;
|
|
14
15
|
get obj(): ObjType | undefined;
|
|
15
16
|
/**
|
|
@@ -59,6 +60,7 @@ export declare class ObjectManager<ObjType extends SimpleObject> {
|
|
|
59
60
|
event_use(name: string, runEvent: (...inputdata: any) => any, onlyOn?: any, runOnce?: boolean): any;
|
|
60
61
|
event_remove(name: string, uname: string): boolean;
|
|
61
62
|
event_add(name: string, uname: string, runEvent: (...inputdata: any) => any, onlyOn?: any, runOnce?: boolean): Promise<void>;
|
|
63
|
+
events_start(): void;
|
|
62
64
|
events_stop(): void;
|
|
63
65
|
events_clear(): void;
|
|
64
66
|
static events_clear(obj: ObjectManager<any>): void;
|
|
@@ -28,9 +28,11 @@ 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?
|
|
35
|
+
_defineProperty(this, "__object_nullable", false);
|
|
34
36
|
_defineProperty(this, "get", this.getValue);
|
|
35
37
|
}
|
|
36
38
|
_createClass(ObjectManager, [{
|
|
@@ -92,7 +94,7 @@ var ObjectManager = /*#__PURE__*/function () {
|
|
|
92
94
|
if (this.__currentObject) {
|
|
93
95
|
this.__currentObject.set_managerClass(this);
|
|
94
96
|
}
|
|
95
|
-
if (toObj == null) {
|
|
97
|
+
if (toObj == null && !this.__object_nullable) {
|
|
96
98
|
console.warn("setObject was used to set null. try to use empty objects instead of null");
|
|
97
99
|
}
|
|
98
100
|
return true;
|
|
@@ -169,7 +171,7 @@ var ObjectManager = /*#__PURE__*/function () {
|
|
|
169
171
|
var original = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
170
172
|
var thisobj = this.obj;
|
|
171
173
|
if (thisobj == null || typeof thisobj.getValue != "function") {
|
|
172
|
-
console.error("cant use getValue when object is not defined. maybe you have to use New() ?");
|
|
174
|
+
if (!this.__object_nullable) console.error("cant use getValue when object is not defined. maybe you have to use New() ?");
|
|
173
175
|
return null;
|
|
174
176
|
}
|
|
175
177
|
return thisobj.getValue(key, original);
|
|
@@ -194,7 +196,7 @@ var ObjectManager = /*#__PURE__*/function () {
|
|
|
194
196
|
_context2.next = 4;
|
|
195
197
|
break;
|
|
196
198
|
}
|
|
197
|
-
console.error("cant use setValue when object is not defined. maybe you have to use New() ?");
|
|
199
|
+
if (!this.__object_nullable) console.error("cant use setValue when object is not defined. maybe you have to use New() ?");
|
|
198
200
|
return _context2.abrupt("return", false);
|
|
199
201
|
case 4:
|
|
200
202
|
_context2.next = 6;
|
|
@@ -318,7 +320,7 @@ var ObjectManager = /*#__PURE__*/function () {
|
|
|
318
320
|
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
319
321
|
while (1) switch (_context5.prev = _context5.next) {
|
|
320
322
|
case 0:
|
|
321
|
-
if (this.
|
|
323
|
+
if (!(this.__stopEvents === true)) {
|
|
322
324
|
_context5.next = 2;
|
|
323
325
|
break;
|
|
324
326
|
}
|
|
@@ -379,10 +381,15 @@ var ObjectManager = /*#__PURE__*/function () {
|
|
|
379
381
|
}
|
|
380
382
|
return event_add;
|
|
381
383
|
}()
|
|
384
|
+
}, {
|
|
385
|
+
key: "events_start",
|
|
386
|
+
value: function events_start() {
|
|
387
|
+
delete this.__stopEvents;
|
|
388
|
+
}
|
|
382
389
|
}, {
|
|
383
390
|
key: "events_stop",
|
|
384
391
|
value: function events_stop() {
|
|
385
|
-
this.
|
|
392
|
+
this.__stopEvents = true;
|
|
386
393
|
}
|
|
387
394
|
}, {
|
|
388
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
|
}
|