@azrico/webobject 1.3.18 → 1.3.20
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.
|
@@ -88,12 +88,9 @@ var ObjectManager = /*#__PURE__*/function () {
|
|
|
88
88
|
}, {
|
|
89
89
|
key: "setObject",
|
|
90
90
|
value: function setObject(toObj) {
|
|
91
|
-
var _this = this;
|
|
92
91
|
this.__currentObject = toObj;
|
|
93
92
|
if (this.__currentObject) {
|
|
94
|
-
this.__currentObject.
|
|
95
|
-
return _this;
|
|
96
|
-
};
|
|
93
|
+
this.__currentObject.set_managerClass(this);
|
|
97
94
|
}
|
|
98
95
|
if (toObj == null) {
|
|
99
96
|
console.warn("setObject was used to set null. try to use empty objects instead of null");
|
|
@@ -139,6 +139,7 @@ export declare class SimpleObject extends MapableObject {
|
|
|
139
139
|
get lastChanged(): string;
|
|
140
140
|
get manager(): ObjectManager<any> | null;
|
|
141
141
|
get_managerClass: () => ObjectManager<any> | null;
|
|
142
|
+
set_managerClass(mng: ObjectManager<any> | any): void;
|
|
142
143
|
static isDeleted<T extends SimpleObject>(obj: T): boolean;
|
|
143
144
|
getIndexOrID(): number | string;
|
|
144
145
|
getIndex(): number;
|
|
@@ -146,6 +147,10 @@ export declare class SimpleObject extends MapableObject {
|
|
|
146
147
|
static getIndexOrID(o: any): number;
|
|
147
148
|
static getIndex(o: any): number;
|
|
148
149
|
static getID(o: any): string;
|
|
150
|
+
event_run(eventName: string, ...params: any): Promise<any[] | undefined>;
|
|
151
|
+
event_use(name: string, runEvent: (...inputdata: any) => any, onlyOn?: any, runOnce?: boolean): any;
|
|
152
|
+
event_remove(name: string, uname: string): boolean | undefined;
|
|
153
|
+
event_add(name: string, uname: string, runEvent: (...inputdata: any) => any, onlyOn?: any, runOnce?: boolean): Promise<void>;
|
|
149
154
|
getOriginal(): this | undefined;
|
|
150
155
|
setOriginal(toObj?: null | 0 | any): this | undefined;
|
|
151
156
|
static setOriginal<T>(obj: T, toObj?: null | 0 | any): T | undefined;
|
|
@@ -634,6 +634,13 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
|
|
|
634
634
|
get: function get() {
|
|
635
635
|
return this.get_managerClass();
|
|
636
636
|
}
|
|
637
|
+
}, {
|
|
638
|
+
key: "set_managerClass",
|
|
639
|
+
value: function set_managerClass(mng) {
|
|
640
|
+
this.get_managerClass = function () {
|
|
641
|
+
return mng;
|
|
642
|
+
};
|
|
643
|
+
}
|
|
637
644
|
}, {
|
|
638
645
|
key: "getIndexOrID",
|
|
639
646
|
value: function getIndexOrID() {
|
|
@@ -650,11 +657,107 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
|
|
|
650
657
|
return SimpleObject.getID(this);
|
|
651
658
|
}
|
|
652
659
|
}, {
|
|
653
|
-
key: "
|
|
654
|
-
value:
|
|
660
|
+
key: "event_run",
|
|
661
|
+
value:
|
|
662
|
+
/* -------------------------------------------------------------------------- */
|
|
663
|
+
/* Events */
|
|
664
|
+
/* -------------------------------------------------------------------------- */
|
|
665
|
+
/* -------------------------------------------------------------------------- */
|
|
666
|
+
/* Events */
|
|
667
|
+
/* -------------------------------------------------------------------------- */
|
|
668
|
+
function () {
|
|
669
|
+
var _event_run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(eventName) {
|
|
670
|
+
var _this$manager;
|
|
671
|
+
var _len,
|
|
672
|
+
params,
|
|
673
|
+
_key,
|
|
674
|
+
_args7 = arguments;
|
|
675
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
676
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
677
|
+
case 0:
|
|
678
|
+
if (this.manager) {
|
|
679
|
+
_context7.next = 3;
|
|
680
|
+
break;
|
|
681
|
+
}
|
|
682
|
+
console.error("you cant use events if your object has no manager");
|
|
683
|
+
return _context7.abrupt("return");
|
|
684
|
+
case 3:
|
|
685
|
+
for (_len = _args7.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
686
|
+
params[_key - 1] = _args7[_key];
|
|
687
|
+
}
|
|
688
|
+
_context7.next = 6;
|
|
689
|
+
return (_this$manager = this.manager).event_run.apply(_this$manager, [eventName].concat(params));
|
|
690
|
+
case 6:
|
|
691
|
+
return _context7.abrupt("return", _context7.sent);
|
|
692
|
+
case 7:
|
|
693
|
+
case "end":
|
|
694
|
+
return _context7.stop();
|
|
695
|
+
}
|
|
696
|
+
}, _callee7, this);
|
|
697
|
+
}));
|
|
698
|
+
function event_run(_x13) {
|
|
699
|
+
return _event_run.apply(this, arguments);
|
|
700
|
+
}
|
|
701
|
+
return event_run;
|
|
702
|
+
}()
|
|
703
|
+
}, {
|
|
704
|
+
key: "event_use",
|
|
705
|
+
value: function event_use(name, runEvent) {
|
|
706
|
+
var onlyOn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
707
|
+
var runOnce = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
708
|
+
if (!this.manager) {
|
|
709
|
+
console.error("you cant use events if your object has no manager");
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
return this.manager.event_use(name, runEvent, onlyOn, runOnce);
|
|
713
|
+
}
|
|
714
|
+
}, {
|
|
715
|
+
key: "event_remove",
|
|
716
|
+
value: function event_remove(name, uname) {
|
|
717
|
+
if (!this.manager) {
|
|
718
|
+
console.error("you cant use events if your object has no manager");
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
return this.manager.event_remove(name, uname);
|
|
722
|
+
}
|
|
723
|
+
}, {
|
|
724
|
+
key: "event_add",
|
|
725
|
+
value: function () {
|
|
726
|
+
var _event_add = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(name, uname, runEvent) {
|
|
727
|
+
var onlyOn,
|
|
728
|
+
runOnce,
|
|
729
|
+
_args8 = arguments;
|
|
730
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
731
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
732
|
+
case 0:
|
|
733
|
+
onlyOn = _args8.length > 3 && _args8[3] !== undefined ? _args8[3] : null;
|
|
734
|
+
runOnce = _args8.length > 4 && _args8[4] !== undefined ? _args8[4] : false;
|
|
735
|
+
if (this.manager) {
|
|
736
|
+
_context8.next = 5;
|
|
737
|
+
break;
|
|
738
|
+
}
|
|
739
|
+
console.error("you cant use events if your object has no manager");
|
|
740
|
+
return _context8.abrupt("return");
|
|
741
|
+
case 5:
|
|
742
|
+
_context8.next = 7;
|
|
743
|
+
return this.manager.event_add(name, uname, runEvent, onlyOn, runOnce);
|
|
744
|
+
case 7:
|
|
745
|
+
case "end":
|
|
746
|
+
return _context8.stop();
|
|
747
|
+
}
|
|
748
|
+
}, _callee8, this);
|
|
749
|
+
}));
|
|
750
|
+
function event_add(_x14, _x15, _x16) {
|
|
751
|
+
return _event_add.apply(this, arguments);
|
|
752
|
+
}
|
|
753
|
+
return event_add;
|
|
754
|
+
}()
|
|
755
|
+
/* -------------------------------------------------------------------------- */
|
|
655
756
|
/* Original */
|
|
656
757
|
/* -------------------------------------------------------------------------- */
|
|
657
|
-
|
|
758
|
+
}, {
|
|
759
|
+
key: "getOriginal",
|
|
760
|
+
value: function getOriginal() {
|
|
658
761
|
return this.__originalobject || undefined;
|
|
659
762
|
}
|
|
660
763
|
}, {
|
|
@@ -726,10 +829,10 @@ var SimpleObject = /*#__PURE__*/function (_MapableObject) {
|
|
|
726
829
|
delete obj[key];
|
|
727
830
|
}
|
|
728
831
|
} else if (_typeof(initObject) == "object") {
|
|
729
|
-
for (var
|
|
730
|
-
if (
|
|
731
|
-
if (fullUpdate || Object.prototype.hasOwnProperty.call(obj,
|
|
732
|
-
obj[
|
|
832
|
+
for (var _key2 in initObject) {
|
|
833
|
+
if (_key2.startsWith("__")) continue;
|
|
834
|
+
if (fullUpdate || Object.prototype.hasOwnProperty.call(obj, _key2)) {
|
|
835
|
+
obj[_key2] = initObject[_key2];
|
|
733
836
|
}
|
|
734
837
|
}
|
|
735
838
|
}
|