@azrico/webobject 1.4.41 → 1.4.43
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.
|
@@ -53,6 +53,7 @@ export declare class ObjectManager<ObjType extends SimpleObject> {
|
|
|
53
53
|
*/
|
|
54
54
|
setSubValue(key: PropOf<ObjType>, objKey: string, subvalue: any): Promise<boolean>;
|
|
55
55
|
pushValue(key: PropOf<ObjType>, value: any): Promise<false | NonNullable<Awaited<ObjType[any]>>>;
|
|
56
|
+
setTemp(key: string, value: any): Promise<any>;
|
|
56
57
|
getIndexOrID(): number | string;
|
|
57
58
|
getIndex(): number;
|
|
58
59
|
getID(): string;
|
|
@@ -71,6 +72,8 @@ export declare class ObjectManager<ObjType extends SimpleObject> {
|
|
|
71
72
|
events_start(): void;
|
|
72
73
|
events_stop(): void;
|
|
73
74
|
events_clear(): void;
|
|
75
|
+
clear_changes(): boolean | undefined;
|
|
76
|
+
clear_cache(): boolean | undefined;
|
|
74
77
|
static events_clear(obj: ObjectManager<any>): void;
|
|
75
78
|
/**
|
|
76
79
|
* Set an option to some value, if its already equal to the value it will be deleted instead
|
|
@@ -287,24 +287,54 @@ var ObjectManager = /*#__PURE__*/function () {
|
|
|
287
287
|
return _pushValue.apply(this, arguments);
|
|
288
288
|
}
|
|
289
289
|
return pushValue;
|
|
290
|
+
}() //set temp value
|
|
291
|
+
}, {
|
|
292
|
+
key: "setTemp",
|
|
293
|
+
value: function () {
|
|
294
|
+
var _setTemp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(key, value) {
|
|
295
|
+
var _this$obj8;
|
|
296
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
297
|
+
while (1) switch (_context5.prev = _context5.next) {
|
|
298
|
+
case 0:
|
|
299
|
+
_context5.next = 2;
|
|
300
|
+
return (_this$obj8 = this.obj) === null || _this$obj8 === void 0 ? void 0 : _this$obj8.setTemp(key, value);
|
|
301
|
+
case 2:
|
|
302
|
+
_context5.t0 = _context5.sent;
|
|
303
|
+
if (_context5.t0) {
|
|
304
|
+
_context5.next = 5;
|
|
305
|
+
break;
|
|
306
|
+
}
|
|
307
|
+
_context5.t0 = false;
|
|
308
|
+
case 5:
|
|
309
|
+
return _context5.abrupt("return", _context5.t0);
|
|
310
|
+
case 6:
|
|
311
|
+
case "end":
|
|
312
|
+
return _context5.stop();
|
|
313
|
+
}
|
|
314
|
+
}, _callee5, this);
|
|
315
|
+
}));
|
|
316
|
+
function setTemp(_x12, _x13) {
|
|
317
|
+
return _setTemp.apply(this, arguments);
|
|
318
|
+
}
|
|
319
|
+
return setTemp;
|
|
290
320
|
}() /* -------------------------------------------------------------------------- */
|
|
291
321
|
}, {
|
|
292
322
|
key: "getIndexOrID",
|
|
293
323
|
value: function getIndexOrID() {
|
|
294
|
-
var _this$
|
|
295
|
-
return ((_this$
|
|
324
|
+
var _this$obj9;
|
|
325
|
+
return ((_this$obj9 = this.obj) === null || _this$obj9 === void 0 ? void 0 : _this$obj9.getIndexOrID()) || -1;
|
|
296
326
|
}
|
|
297
327
|
}, {
|
|
298
328
|
key: "getIndex",
|
|
299
329
|
value: function getIndex() {
|
|
300
|
-
var _this$
|
|
301
|
-
return ((_this$
|
|
330
|
+
var _this$obj10;
|
|
331
|
+
return ((_this$obj10 = this.obj) === null || _this$obj10 === void 0 ? void 0 : _this$obj10.getIndex()) || -1;
|
|
302
332
|
}
|
|
303
333
|
}, {
|
|
304
334
|
key: "getID",
|
|
305
335
|
value: function getID() {
|
|
306
|
-
var _this$
|
|
307
|
-
return ((_this$
|
|
336
|
+
var _this$obj11;
|
|
337
|
+
return ((_this$obj11 = this.obj) === null || _this$obj11 === void 0 ? void 0 : _this$obj11.getID()) || "";
|
|
308
338
|
}
|
|
309
339
|
/* -------------------------------------------------------------------------- */
|
|
310
340
|
/* Events */
|
|
@@ -312,34 +342,34 @@ var ObjectManager = /*#__PURE__*/function () {
|
|
|
312
342
|
}, {
|
|
313
343
|
key: "event_run",
|
|
314
344
|
value: function () {
|
|
315
|
-
var _event_run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
345
|
+
var _event_run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(eventName) {
|
|
316
346
|
var _len,
|
|
317
347
|
params,
|
|
318
348
|
_key,
|
|
319
|
-
|
|
320
|
-
return _regeneratorRuntime().wrap(function
|
|
321
|
-
while (1) switch (
|
|
349
|
+
_args6 = arguments;
|
|
350
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
351
|
+
while (1) switch (_context6.prev = _context6.next) {
|
|
322
352
|
case 0:
|
|
323
353
|
if (!(this.__stopEvents === true)) {
|
|
324
|
-
|
|
354
|
+
_context6.next = 2;
|
|
325
355
|
break;
|
|
326
356
|
}
|
|
327
|
-
return
|
|
357
|
+
return _context6.abrupt("return");
|
|
328
358
|
case 2:
|
|
329
|
-
for (_len =
|
|
330
|
-
params[_key - 1] =
|
|
359
|
+
for (_len = _args6.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
360
|
+
params[_key - 1] = _args6[_key];
|
|
331
361
|
}
|
|
332
|
-
|
|
362
|
+
_context6.next = 5;
|
|
333
363
|
return _event.EventManager.run.apply(_event.EventManager, [this, eventName].concat(params));
|
|
334
364
|
case 5:
|
|
335
|
-
return
|
|
365
|
+
return _context6.abrupt("return", _context6.sent);
|
|
336
366
|
case 6:
|
|
337
367
|
case "end":
|
|
338
|
-
return
|
|
368
|
+
return _context6.stop();
|
|
339
369
|
}
|
|
340
|
-
},
|
|
370
|
+
}, _callee6, this);
|
|
341
371
|
}));
|
|
342
|
-
function event_run(
|
|
372
|
+
function event_run(_x14) {
|
|
343
373
|
return _event_run.apply(this, arguments);
|
|
344
374
|
}
|
|
345
375
|
return event_run;
|
|
@@ -372,24 +402,24 @@ var ObjectManager = /*#__PURE__*/function () {
|
|
|
372
402
|
}, {
|
|
373
403
|
key: "event_add",
|
|
374
404
|
value: function () {
|
|
375
|
-
var _event_add = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
405
|
+
var _event_add = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(name, uname, runEvent) {
|
|
376
406
|
var onlyOn,
|
|
377
407
|
runOnce,
|
|
378
|
-
|
|
379
|
-
return _regeneratorRuntime().wrap(function
|
|
380
|
-
while (1) switch (
|
|
408
|
+
_args7 = arguments;
|
|
409
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
410
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
381
411
|
case 0:
|
|
382
|
-
onlyOn =
|
|
383
|
-
runOnce =
|
|
384
|
-
|
|
412
|
+
onlyOn = _args7.length > 3 && _args7[3] !== undefined ? _args7[3] : null;
|
|
413
|
+
runOnce = _args7.length > 4 && _args7[4] !== undefined ? _args7[4] : false;
|
|
414
|
+
_context7.next = 4;
|
|
385
415
|
return _event.EventManager.add(this, name, uname, runEvent, onlyOn, runOnce);
|
|
386
416
|
case 4:
|
|
387
417
|
case "end":
|
|
388
|
-
return
|
|
418
|
+
return _context7.stop();
|
|
389
419
|
}
|
|
390
|
-
},
|
|
420
|
+
}, _callee7, this);
|
|
391
421
|
}));
|
|
392
|
-
function event_add(
|
|
422
|
+
function event_add(_x15, _x16, _x17) {
|
|
393
423
|
return _event_add.apply(this, arguments);
|
|
394
424
|
}
|
|
395
425
|
return event_add;
|
|
@@ -409,6 +439,18 @@ var ObjectManager = /*#__PURE__*/function () {
|
|
|
409
439
|
value: function events_clear() {
|
|
410
440
|
ObjectManager.events_clear(this);
|
|
411
441
|
}
|
|
442
|
+
}, {
|
|
443
|
+
key: "clear_changes",
|
|
444
|
+
value: function clear_changes() {
|
|
445
|
+
var _this$obj12;
|
|
446
|
+
return (_this$obj12 = this.obj) === null || _this$obj12 === void 0 ? void 0 : _this$obj12.clear_changes();
|
|
447
|
+
}
|
|
448
|
+
}, {
|
|
449
|
+
key: "clear_cache",
|
|
450
|
+
value: function clear_cache() {
|
|
451
|
+
var _this$obj13;
|
|
452
|
+
return (_this$obj13 = this.obj) === null || _this$obj13 === void 0 ? void 0 : _this$obj13.clear_cache();
|
|
453
|
+
}
|
|
412
454
|
}, {
|
|
413
455
|
key: "toggleOption",
|
|
414
456
|
value:
|
|
@@ -422,31 +464,31 @@ var ObjectManager = /*#__PURE__*/function () {
|
|
|
422
464
|
* @returns
|
|
423
465
|
*/
|
|
424
466
|
function () {
|
|
425
|
-
var _toggleOption = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
467
|
+
var _toggleOption = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(key, value) {
|
|
426
468
|
var oldval;
|
|
427
|
-
return _regeneratorRuntime().wrap(function
|
|
428
|
-
while (1) switch (
|
|
469
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
470
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
429
471
|
case 0:
|
|
430
472
|
oldval = this.getOption(key);
|
|
431
473
|
if (!(0, _object.object_equals_loose)(oldval, value)) {
|
|
432
|
-
|
|
474
|
+
_context8.next = 6;
|
|
433
475
|
break;
|
|
434
476
|
}
|
|
435
|
-
|
|
477
|
+
_context8.next = 4;
|
|
436
478
|
return this.setOption(key, null);
|
|
437
479
|
case 4:
|
|
438
|
-
|
|
480
|
+
_context8.next = 8;
|
|
439
481
|
break;
|
|
440
482
|
case 6:
|
|
441
|
-
|
|
483
|
+
_context8.next = 8;
|
|
442
484
|
return this.setOption(key, value);
|
|
443
485
|
case 8:
|
|
444
486
|
case "end":
|
|
445
|
-
return
|
|
487
|
+
return _context8.stop();
|
|
446
488
|
}
|
|
447
|
-
},
|
|
489
|
+
}, _callee8, this);
|
|
448
490
|
}));
|
|
449
|
-
function toggleOption(
|
|
491
|
+
function toggleOption(_x18, _x19) {
|
|
450
492
|
return _toggleOption.apply(this, arguments);
|
|
451
493
|
}
|
|
452
494
|
return toggleOption;
|
|
@@ -454,9 +496,9 @@ var ObjectManager = /*#__PURE__*/function () {
|
|
|
454
496
|
}, {
|
|
455
497
|
key: "setOption",
|
|
456
498
|
value: function () {
|
|
457
|
-
var _setOption = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
458
|
-
return _regeneratorRuntime().wrap(function
|
|
459
|
-
while (1) switch (
|
|
499
|
+
var _setOption = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(key, value) {
|
|
500
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
501
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
460
502
|
case 0:
|
|
461
503
|
if (this.__options == null) this.__options = {};
|
|
462
504
|
if (value == null) {
|
|
@@ -464,17 +506,17 @@ var ObjectManager = /*#__PURE__*/function () {
|
|
|
464
506
|
} else {
|
|
465
507
|
this.__options[key] = value;
|
|
466
508
|
}
|
|
467
|
-
|
|
509
|
+
_context9.next = 4;
|
|
468
510
|
return this.event_run("on_option_change", key, value);
|
|
469
511
|
case 4:
|
|
470
|
-
return
|
|
512
|
+
return _context9.abrupt("return", _context9.sent);
|
|
471
513
|
case 5:
|
|
472
514
|
case "end":
|
|
473
|
-
return
|
|
515
|
+
return _context9.stop();
|
|
474
516
|
}
|
|
475
|
-
},
|
|
517
|
+
}, _callee9, this);
|
|
476
518
|
}));
|
|
477
|
-
function setOption(
|
|
519
|
+
function setOption(_x20, _x21) {
|
|
478
520
|
return _setOption.apply(this, arguments);
|
|
479
521
|
}
|
|
480
522
|
return setOption;
|
|
@@ -503,29 +545,29 @@ var ObjectManager = /*#__PURE__*/function () {
|
|
|
503
545
|
}, {
|
|
504
546
|
key: "holdOption",
|
|
505
547
|
value: function () {
|
|
506
|
-
var _holdOption = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
|
507
|
-
return _regeneratorRuntime().wrap(function
|
|
508
|
-
while (1) switch (
|
|
548
|
+
var _holdOption = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10(key, value, nextvalue, action) {
|
|
549
|
+
return _regeneratorRuntime().wrap(function _callee10$(_context10) {
|
|
550
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
509
551
|
case 0:
|
|
510
|
-
|
|
552
|
+
_context10.prev = 0;
|
|
511
553
|
this.setOption(key, value);
|
|
512
554
|
if (!(typeof action === "function")) {
|
|
513
|
-
|
|
555
|
+
_context10.next = 5;
|
|
514
556
|
break;
|
|
515
557
|
}
|
|
516
|
-
|
|
558
|
+
_context10.next = 5;
|
|
517
559
|
return action();
|
|
518
560
|
case 5:
|
|
519
|
-
|
|
561
|
+
_context10.prev = 5;
|
|
520
562
|
this.setOption(key, nextvalue);
|
|
521
|
-
return
|
|
563
|
+
return _context10.finish(5);
|
|
522
564
|
case 8:
|
|
523
565
|
case "end":
|
|
524
|
-
return
|
|
566
|
+
return _context10.stop();
|
|
525
567
|
}
|
|
526
|
-
},
|
|
568
|
+
}, _callee10, this, [[0,, 5, 8]]);
|
|
527
569
|
}));
|
|
528
|
-
function holdOption(
|
|
570
|
+
function holdOption(_x22, _x23, _x24, _x25) {
|
|
529
571
|
return _holdOption.apply(this, arguments);
|
|
530
572
|
}
|
|
531
573
|
return holdOption;
|
|
@@ -83,6 +83,7 @@ export declare class SimpleObject extends MapableObject {
|
|
|
83
83
|
* @return true if changed , false otherwise
|
|
84
84
|
*/
|
|
85
85
|
setSubValue<MKey extends PropOf<this>>(key: MKey, objKey: string, subvalue: any, sendChanges?: sendChangesType): Promise<boolean>;
|
|
86
|
+
getSubValue: (key: PropOf<this>, subkey: string, original?: boolean) => any;
|
|
86
87
|
/**
|
|
87
88
|
* Push value on array
|
|
88
89
|
* @param key
|
|
@@ -105,6 +105,7 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
|
|
|
105
105
|
* @returns
|
|
106
106
|
*/
|
|
107
107
|
_defineProperty(_assertThisInitialized(_this), "setDefault", _this.setDefaultValue);
|
|
108
|
+
_defineProperty(_assertThisInitialized(_this), "getSubValue", _classPrivateMethodGet(_assertThisInitialized(_this), _getSubProperty, _getSubProperty2));
|
|
108
109
|
_defineProperty(_assertThisInitialized(_this), "get_managerClass", function () {
|
|
109
110
|
return undefined;
|
|
110
111
|
});
|
|
@@ -319,7 +320,8 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
|
|
|
319
320
|
//if accessing subval of an object, make sure the object is not null
|
|
320
321
|
subval = _classPrivateMethodGet(this, _getSubProperty, _getSubProperty2).call(this, key, objKey);
|
|
321
322
|
if (!(0, _object.object_equals)(subval, subvalue, {
|
|
322
|
-
ignoredStartingWords: "_"
|
|
323
|
+
ignoredStartingWords: "_",
|
|
324
|
+
strictArrayCheck: true
|
|
323
325
|
})) {
|
|
324
326
|
_classPrivateMethodGet(this, _setSubProperty, _setSubProperty2).call(this, key, objKey, subvalue);
|
|
325
327
|
isValueChanged = true;
|
|
@@ -347,6 +349,9 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
|
|
|
347
349
|
}
|
|
348
350
|
return setSubValue;
|
|
349
351
|
}()
|
|
352
|
+
}, {
|
|
353
|
+
key: "pushValue",
|
|
354
|
+
value:
|
|
350
355
|
/**
|
|
351
356
|
* Push value on array
|
|
352
357
|
* @param key
|
|
@@ -354,9 +359,7 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
|
|
|
354
359
|
* @param sendChanges
|
|
355
360
|
* @returns
|
|
356
361
|
*/
|
|
357
|
-
|
|
358
|
-
key: "pushValue",
|
|
359
|
-
value: function () {
|
|
362
|
+
function () {
|
|
360
363
|
var _pushValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(key, value) {
|
|
361
364
|
var sendChanges,
|
|
362
365
|
tempArray,
|
|
@@ -1094,7 +1097,7 @@ exports.SimpleObject = SimpleObject;
|
|
|
1094
1097
|
function _setSubProperty2(key, subkey, value) {
|
|
1095
1098
|
var subobj = _classPrivateMethodGet(this, _getProperty, _getProperty2).call(this, key);
|
|
1096
1099
|
//@ts-ignore
|
|
1097
|
-
if (subobj == null || _typeof(subobj) !== "object") subobj = {};
|
|
1100
|
+
if (subobj == null || _typeof(subobj) !== "object") subobj = {};else subobj = _objectSpread({}, subobj); //make a clone so we dont update the original
|
|
1098
1101
|
subobj[subkey] = value;
|
|
1099
1102
|
_classPrivateMethodGet(this, _setProperty, _setProperty2).call(this, key, subobj);
|
|
1100
1103
|
}
|