@azrico/webobject 1.5.66 → 1.5.68

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.
@@ -1,667 +1,273 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = exports.ObjectManager = void 0;
7
- var _event = require("@azrico/event");
8
- var _SimpleObject = _interopRequireDefault(require("./SimpleObject"));
9
- var _string = require("@azrico/string");
10
- var _global = require("@azrico/global");
11
- var _object = require("@azrico/object");
12
- var _MapableObject = _interopRequireDefault(require("./MapableObject"));
13
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
14
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
15
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return r; }; var t, r = {}, e = Object.prototype, n = e.hasOwnProperty, o = "function" == typeof Symbol ? Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", u = o.toStringTag || "@@toStringTag"; function c(t, r, e, n) { return Object.defineProperty(t, r, { value: e, enumerable: !n, configurable: !n, writable: !n }); } try { c({}, ""); } catch (t) { c = function c(t, r, e) { return t[r] = e; }; } function h(r, e, n, o) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype); return c(a, "_invoke", function (r, e, n) { var o = 1; return function (i, a) { if (3 === o) throw Error("Generator is already running"); if (4 === o) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var u = n.delegate; if (u) { var c = d(u, n); if (c) { if (c === f) continue; return c; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (1 === o) throw o = 4, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = 3; var h = s(r, e, n); if ("normal" === h.type) { if (o = n.done ? 4 : 2, h.arg === f) continue; return { value: h.arg, done: n.done }; } "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg); } }; }(r, n, new Context(o || [])), !0), a; } function s(t, r, e) { try { return { type: "normal", arg: t.call(r, e) }; } catch (t) { return { type: "throw", arg: t }; } } r.wrap = h; var f = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var l = {}; c(l, i, function () { return this; }); var p = Object.getPrototypeOf, y = p && p(p(x([]))); y && y !== e && n.call(y, i) && (l = y); var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l); function g(t) { ["next", "throw", "return"].forEach(function (r) { c(t, r, function (t) { return this._invoke(r, t); }); }); } function AsyncIterator(t, r) { function e(o, i, a, u) { var c = s(t[o], t, i); if ("throw" !== c.type) { var h = c.arg, f = h.value; return f && "object" == _typeof(f) && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) { e("next", t, a, u); }, function (t) { e("throw", t, a, u); }) : r.resolve(f).then(function (t) { h.value = t, a(h); }, function (t) { return e("throw", t, a, u); }); } u(c.arg); } var o; c(this, "_invoke", function (t, n) { function i() { return new r(function (r, o) { e(t, n, r, o); }); } return o = o ? o.then(i, i) : i(); }, !0); } function d(r, e) { var n = e.method, o = r.i[n]; if (o === t) return e.delegate = null, "throw" === n && r.i["return"] && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f; var i = s(o, r.i, e.arg); if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f; var a = i.arg; return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f); } function w(t) { this.tryEntries.push(t); } function m(r) { var e = r[4] || {}; e.type = "normal", e.arg = t, r[4] = e; } function Context(t) { this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0); } function x(r) { if (null != r) { var e = r[i]; if (e) return e.call(r); if ("function" == typeof r.next) return r; if (!isNaN(r.length)) { var o = -1, a = function e() { for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e; return e.value = t, e.done = !0, e; }; return a.next = a; } } throw new TypeError(_typeof(r) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) { var r = "function" == typeof t && t.constructor; return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name)); }, r.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t; }, r.awrap = function (t) { return { __await: t }; }, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () { return this; }), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(h(t, e, n, o), i); return r.isGeneratorFunction(e) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, g(v), c(v, u, "Generator"), c(v, i, function () { return this; }), c(v, "toString", function () { return "[object Generator]"; }), r.keys = function (t) { var r = Object(t), e = []; for (var n in r) e.unshift(n); return function t() { for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t; return t.done = !0, t; }; }, r.values = x, Context.prototype = { constructor: Context, reset: function reset(r) { if (this.prev = this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(m), !r) for (var e in this) "t" === e.charAt(0) && n.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0][4]; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(r) { if (this.done) throw r; var e = this; function n(t) { a.type = "throw", a.arg = r, e.next = t; } for (var o = e.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i[4], u = this.prev, c = i[1], h = i[2]; if (-1 === i[0]) return n("end"), !1; if (!c && !h) throw Error("try statement without catch or finally"); if (null != i[0] && i[0] <= u) { if (u < c) return this.method = "next", this.arg = t, n(c), !0; if (u < h) return n(h), !1; } } }, abrupt: function abrupt(t, r) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var n = this.tryEntries[e]; if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) { var o = n; break; } } o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null); var i = o ? o[4] : {}; return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i); }, complete: function complete(t, r) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && r && (this.next = r), f; }, finish: function finish(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[2] === t) return this.complete(e[4], e[3]), m(e), f; } }, "catch": function _catch(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[0] === t) { var n = e[4]; if ("throw" === n.type) { var o = n.arg; m(e); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(r, e, n) { return this.delegate = { i: x(r), r: e, n: n }, "next" === this.method && (this.arg = t), f; } }, r; }
16
- function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
17
- function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
18
- function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
19
- function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
20
- function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
21
- function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
22
- function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
23
- function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
24
- function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
25
- function _superPropGet(t, o, e, r) { var p = _get(_getPrototypeOf(1 & r ? t.prototype : t), o, e); return 2 & r && "function" == typeof p ? function (t) { return p.apply(e, t); } : p; }
26
- function _get() { return _get = "undefined" != typeof Reflect && Reflect.get ? Reflect.get.bind() : function (e, t, r) { var p = _superPropBase(e, t); if (p) { var n = Object.getOwnPropertyDescriptor(p, t); return n.get ? n.get.call(arguments.length < 3 ? e : r) : n.value; } }, _get.apply(null, arguments); }
27
- function _superPropBase(t, o) { for (; !{}.hasOwnProperty.call(t, o) && null !== (t = _getPrototypeOf(t));); return t; }
28
- function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
29
- function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
30
- function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
31
- function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
32
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
33
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
1
+ import EventContext, { EventManager, useProperty } from "@azrico/event";
2
+ import SimpleObject from "./SimpleObject";
3
+ import { combine_if_not_blank } from "@azrico/string";
4
+ import { gfunc } from "@azrico/global";
5
+ import { fn_eval, object_equals_loose, } from "@azrico/object";
6
+ import RawObject from "./MapableObject";
7
+ import useGetter from "@azrico/event/dist/src/hooks/useGetter";
8
+ import { useEvent } from "@azrico/event";
34
9
  /**
35
10
  * This class manages the events of an Simple Object
36
- */
37
- var ObjectManager = exports.ObjectManager = /*#__PURE__*/function (_RawObject) {
38
- function ObjectManager(defaultObject) {
39
- var _this;
40
- _classCallCheck(this, ObjectManager);
41
- _this = _callSuper(this, ObjectManager);
42
- _defineProperty(_this, "__eventList", {});
43
- _defineProperty(_this, "__eventPrefix", void 0);
44
- _defineProperty(_this, "__stopEvents", void 0);
45
- _defineProperty(_this, "__last_object_data", {});
46
- _defineProperty(_this, "__currentObject", void 0);
47
- _defineProperty(_this, "__options", void 0);
48
- //can the current object be set to null safely?
49
- _defineProperty(_this, "__object_nullable", false);
50
- _this.setObject(defaultObject);
51
- return _this;
52
- }
53
- _inherits(ObjectManager, _RawObject);
54
- return _createClass(ObjectManager, [{
55
- key: "notifyChanged",
56
- value: function () {
57
- var _notifyChanged = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(type, key, value, subvalue) {
58
- var obj, typestr;
59
- return _regeneratorRuntime().wrap(function _callee$(_context) {
60
- while (1) switch (_context.prev = _context.next) {
61
- case 0:
62
- obj = this.getObject();
63
- if (obj) {
64
- _context.next = 3;
65
- break;
66
- }
67
- return _context.abrupt("return", false);
68
- case 3:
69
- if (value === undefined && type != "meta") value = obj.get(key);
70
- typestr = (type ? "$".concat(type, "$") : "") + String(key);
71
- _context.next = 7;
72
- return this.event_run("on_change", typestr, value);
73
- case 7:
74
- return _context.abrupt("return", _context.sent);
75
- case 8:
76
- case "end":
77
- return _context.stop();
78
- }
79
- }, _callee, this);
80
- }));
81
- function notifyChanged(_x, _x2, _x3, _x4) {
82
- return _notifyChanged.apply(this, arguments);
83
- }
84
- return notifyChanged;
85
- }()
86
- /* -------------------------------------------------------------------------- */
11
+ */
12
+ export class ObjectManager extends RawObject {
13
+ __eventContext = {};
14
+ static __object_type;
15
+ __last_object_data = {};
16
+ __currentObject;
17
+ __options;
18
+ //can the current object be set to null safely?
19
+ __object_nullable = false;
20
+ constructor(defaultObject) {
21
+ super();
22
+ this.setObject(defaultObject);
23
+ }
24
+ async notifyChanged(type, key, value, subvalue) {
25
+ const obj = this.getObject();
26
+ if (!obj)
27
+ return false;
28
+ if (value === undefined && type != "meta")
29
+ value = obj.get(key);
30
+ const typestr = (type ? `$${type}$` : "") + String(key);
31
+ return await this.event_run("on_change", typestr, value);
32
+ }
33
+ /* -------------------------------------------------------------------------- */
87
34
  /**
88
35
  * Get the object this manager is managing
89
36
  * @returns the object
90
- */
91
- }, {
92
- key: "obj",
93
- get: function get() {
94
- var _this$__currentObject;
95
- return (_this$__currentObject = this.__currentObject) !== null && _this$__currentObject !== void 0 ? _this$__currentObject : undefined;
96
- }
37
+ */
38
+ get obj() {
39
+ return this.__currentObject ?? undefined;
40
+ }
97
41
  /**
98
42
  * Get the object this manager is managing
99
43
  * @returns the object
100
- */
101
- }, {
102
- key: "getObject",
103
- value: function getObject() {
104
- var _this$__currentObject2;
105
- return (_this$__currentObject2 = this.__currentObject) !== null && _this$__currentObject2 !== void 0 ? _this$__currentObject2 : undefined;
106
- }
44
+ */
45
+ getObject() {
46
+ return this.__currentObject ?? undefined;
47
+ }
107
48
  /**
108
49
  * Set the object this manager is managing
109
50
  * @param toObj
110
51
  * @returns
111
- */
112
- }, {
113
- key: "setObject",
114
- value: function setObject(toObj) {
115
- var _this2 = this;
116
- this.__currentObject = toObj;
117
- if (this.obj) {
118
- this.obj.get_managerClass = function () {
119
- return _this2;
120
- };
121
- // this.obj.set_managerClass(this);
122
- }
123
- if (toObj == null && !this.__object_nullable) {
124
- console.warn("setObject was used to set null. try to use empty objects instead of null");
125
- }
126
- return true;
127
- }
128
- /* -------------------------------------------------------------------------- */
129
- /* Child functions */
130
- /* -------------------------------------------------------------------------- */
131
- }, {
132
- key: "d",
133
- get: function get() {
134
- var _this$obj;
135
- return ((_this$obj = this.obj) === null || _this$obj === void 0 ? void 0 : _this$obj.d) || {};
136
- }
137
- }, {
138
- key: "isChanged",
139
- get: function get() {
140
- return this.obj != null && this.obj.isChanged;
141
- }
142
- }, {
143
- key: "isDeleted",
144
- get: function get() {
145
- return this.obj == null || this.obj.isDeleted;
146
- }
147
- }, {
148
- key: "isArchived",
149
- get: function get() {
150
- return this.obj == null || this.obj.isArchived;
151
- }
152
- }, {
153
- key: "isLocked",
154
- get: function get() {
155
- return this.obj == null || this.obj.isLocked;
156
- }
157
- }, {
158
- key: "canModify",
159
- get: function get() {
160
- var _this$obj2;
161
- return !((_this$obj2 = this.obj) !== null && _this$obj2 !== void 0 && _this$obj2.canModify);
162
- }
163
- }, {
164
- key: "isNew",
165
- get: function get() {
166
- return this.obj == null || this.obj.isNew;
167
- }
168
- }, {
169
- key: "isSaved",
170
- get: function get() {
171
- var _this$obj3;
172
- return ((_this$obj3 = this.obj) === null || _this$obj3 === void 0 ? void 0 : _this$obj3.isSaved) || false;
173
- }
174
- }, {
175
- key: "getSaveResult",
176
- value: function getSaveResult() {
177
- var _this$obj4;
178
- return ((_this$obj4 = this.obj) === null || _this$obj4 === void 0 ? void 0 : _this$obj4.getSaveResult()) || null;
179
- }
180
- }, {
181
- key: "getSaveResultType",
182
- value: function getSaveResultType() {
183
- var _this$obj5;
184
- return ((_this$obj5 = this.obj) === null || _this$obj5 === void 0 ? void 0 : _this$obj5.getSaveResultType()) || null;
185
- }
186
- }, {
187
- key: "setSaveResult",
188
- value: function setSaveResult(toObj, type) {
189
- var _this$obj6;
190
- return (_this$obj6 = this.obj) === null || _this$obj6 === void 0 ? void 0 : _this$obj6.setSaveResult(toObj, type);
191
- }
192
- }, {
193
- key: "apply_changes",
194
- value: function apply_changes() {
195
- var _this$obj7;
196
- return ((_this$obj7 = this.obj) === null || _this$obj7 === void 0 ? void 0 : _this$obj7.apply_changes()) || false;
197
- }
198
- }, {
199
- key: "get",
200
- value: function get(key) {
201
- var original = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
202
- var thisobj = this.obj;
203
- if (thisobj == null || typeof thisobj.get != "function") {
204
- if (!this.__object_nullable) console.error("cant use get when object is not defined. maybe you have to use New() ?");
205
- return null;
206
- }
207
- return thisobj.get(key, original);
208
- }
52
+ */
53
+ setObject(toObj) {
54
+ this.__currentObject = toObj;
55
+ if (this.obj) {
56
+ this.obj.get_managerClass = () => this;
57
+ // this.obj.set_managerClass(this);
58
+ }
59
+ if (toObj == null && !this.__object_nullable) {
60
+ console.warn("setObject was used to set null. try to use empty objects instead of null");
61
+ }
62
+ return true;
63
+ }
64
+ /* -------------------------------------------------------------------------- */
65
+ /* Child functions */
66
+ /* -------------------------------------------------------------------------- */
67
+ get d() {
68
+ return this.obj?.d || {};
69
+ }
70
+ get isChanged() {
71
+ return this.obj != null && this.obj.isChanged;
72
+ }
73
+ get isDeleted() {
74
+ return this.obj == null || this.obj.isDeleted;
75
+ }
76
+ get isArchived() {
77
+ return this.obj == null || this.obj.isArchived;
78
+ }
79
+ get isLocked() {
80
+ return this.obj == null || this.obj.isLocked;
81
+ }
82
+ get canModify() {
83
+ return !this.obj?.canModify;
84
+ }
85
+ get isNew() {
86
+ return this.obj == null || this.obj.isNew;
87
+ }
88
+ get isSaved() {
89
+ return this.obj?.isSaved || false;
90
+ }
91
+ getSaveResult() {
92
+ return this.obj?.getSaveResult() || null;
93
+ }
94
+ getSaveResultType() {
95
+ return this.obj?.getSaveResultType() || null;
96
+ }
97
+ setSaveResult(toObj, type) {
98
+ return this.obj?.setSaveResult(toObj, type);
99
+ }
100
+ apply_changes() {
101
+ return this.obj?.apply_changes() || false;
102
+ }
103
+ get(key, original = false) {
104
+ const thisobj = this.obj;
105
+ if (thisobj == null || typeof thisobj.get != "function") {
106
+ if (!this.__object_nullable)
107
+ console.error("cant use get when object is not defined. maybe you have to use New() ?");
108
+ return null;
109
+ }
110
+ return thisobj.get(key, original);
111
+ }
209
112
  /**
210
113
  * use a property from the object, this will return latest value of the property
211
114
  * uses `EventManager` to detect changes
212
- */
213
- }, {
214
- key: "use",
215
- value: function use(key) {
216
- return _event.EventManager.useProperty(this, key);
217
- }
115
+ */
116
+ use(key) {
117
+ return useProperty(this, key);
118
+ }
218
119
  /**
219
120
  * set value
220
121
  * @param key
221
122
  * @param value
222
123
  * @return true if changed , false otherwise
223
- */
224
- }, {
225
- key: "set",
226
- value: (function () {
227
- var _set = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key, value) {
228
- var thisobj;
229
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
230
- while (1) switch (_context2.prev = _context2.next) {
231
- case 0:
232
- thisobj = this.obj;
233
- if (!(thisobj == null || typeof thisobj.set != "function")) {
234
- _context2.next = 4;
235
- break;
236
- }
237
- if (!this.__object_nullable) console.error("cant use set when object is not defined. maybe you have to use New() ?");
238
- return _context2.abrupt("return", false);
239
- case 4:
240
- _context2.next = 6;
241
- return thisobj.set(key, value);
242
- case 6:
243
- _context2.t0 = _context2.sent;
244
- if (_context2.t0) {
245
- _context2.next = 9;
246
- break;
247
- }
248
- _context2.t0 = false;
249
- case 9:
250
- return _context2.abrupt("return", _context2.t0);
251
- case 10:
252
- case "end":
253
- return _context2.stop();
254
- }
255
- }, _callee2, this);
256
- }));
257
- function set(_x5, _x6) {
258
- return _set.apply(this, arguments);
259
- }
260
- return set;
261
- }()
124
+ */
125
+ async set(key, value) {
126
+ const thisobj = this.obj;
127
+ if (thisobj == null || typeof thisobj.set != "function") {
128
+ if (!this.__object_nullable)
129
+ console.error("cant use set when object is not defined. maybe you have to use New() ?");
130
+ return false;
131
+ }
132
+ return (await thisobj.set(key, value)) || false;
133
+ }
262
134
  /**
263
135
  * set key of subObject
264
136
  * @param key
265
137
  * @param value
266
138
  * @param subvalue
267
139
  * @return true if changed , false otherwise
268
- */
269
- )
270
- }, {
271
- key: "setSubValue",
272
- value: (function () {
273
- var _setSubValue = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key, objKey, subvalue) {
274
- var _yield$this$obj$setSu, _this$obj8;
275
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
276
- while (1) switch (_context3.prev = _context3.next) {
277
- case 0:
278
- _context3.next = 2;
279
- return (_this$obj8 = this.obj) === null || _this$obj8 === void 0 ? void 0 : _this$obj8.setSubValue(key, objKey, subvalue);
280
- case 2:
281
- _context3.t1 = _yield$this$obj$setSu = _context3.sent;
282
- _context3.t0 = _context3.t1 !== null;
283
- if (!_context3.t0) {
284
- _context3.next = 6;
285
- break;
286
- }
287
- _context3.t0 = _yield$this$obj$setSu !== void 0;
288
- case 6:
289
- if (!_context3.t0) {
290
- _context3.next = 10;
291
- break;
292
- }
293
- _context3.t2 = _yield$this$obj$setSu;
294
- _context3.next = 11;
295
- break;
296
- case 10:
297
- _context3.t2 = false;
298
- case 11:
299
- return _context3.abrupt("return", _context3.t2);
300
- case 12:
301
- case "end":
302
- return _context3.stop();
303
- }
304
- }, _callee3, this);
305
- }));
306
- function setSubValue(_x7, _x8, _x9) {
307
- return _setSubValue.apply(this, arguments);
308
- }
309
- return setSubValue;
310
- }() //Push value on array
311
- )
312
- }, {
313
- key: "pushValue",
314
- value: function () {
315
- var _pushValue = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(key, value) {
316
- var _yield$this$obj$pushV, _this$obj9;
317
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
318
- while (1) switch (_context4.prev = _context4.next) {
319
- case 0:
320
- _context4.next = 2;
321
- return (_this$obj9 = this.obj) === null || _this$obj9 === void 0 ? void 0 : _this$obj9.pushValue(key, value);
322
- case 2:
323
- _context4.t1 = _yield$this$obj$pushV = _context4.sent;
324
- _context4.t0 = _context4.t1 !== null;
325
- if (!_context4.t0) {
326
- _context4.next = 6;
327
- break;
328
- }
329
- _context4.t0 = _yield$this$obj$pushV !== void 0;
330
- case 6:
331
- if (!_context4.t0) {
332
- _context4.next = 10;
333
- break;
334
- }
335
- _context4.t2 = _yield$this$obj$pushV;
336
- _context4.next = 11;
337
- break;
338
- case 10:
339
- _context4.t2 = false;
340
- case 11:
341
- return _context4.abrupt("return", _context4.t2);
342
- case 12:
343
- case "end":
344
- return _context4.stop();
345
- }
346
- }, _callee4, this);
347
- }));
348
- function pushValue(_x0, _x1) {
349
- return _pushValue.apply(this, arguments);
350
- }
351
- return pushValue;
352
- }() //set temp value of object
353
- }, {
354
- key: "setTemp",
355
- value: function () {
356
- var _setTemp = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(key, value) {
357
- var sendChanges,
358
- _args5 = arguments;
359
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
360
- while (1) switch (_context5.prev = _context5.next) {
361
- case 0:
362
- sendChanges = _args5.length > 2 && _args5[2] !== undefined ? _args5[2] : false;
363
- _context5.next = 3;
364
- return this.setObjectTemp(key, value, sendChanges);
365
- case 3:
366
- _context5.next = 5;
367
- return _superPropGet(ObjectManager, "setTemp", this, 3)([key, value]);
368
- case 5:
369
- return _context5.abrupt("return", _context5.sent);
370
- case 6:
371
- case "end":
372
- return _context5.stop();
373
- }
374
- }, _callee5, this);
375
- }));
376
- function setTemp(_x10, _x11) {
377
- return _setTemp.apply(this, arguments);
378
- }
379
- return setTemp;
380
- }() //set temp value of object
381
- }, {
382
- key: "setObjectTemp",
383
- value: function () {
384
- var _setObjectTemp = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(key, value) {
385
- var _yield$this$obj$setTe, _this$obj0;
386
- var sendChanges,
387
- _args6 = arguments;
388
- return _regeneratorRuntime().wrap(function _callee6$(_context6) {
389
- while (1) switch (_context6.prev = _context6.next) {
390
- case 0:
391
- sendChanges = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : false;
392
- _context6.next = 3;
393
- return (_this$obj0 = this.obj) === null || _this$obj0 === void 0 ? void 0 : _this$obj0.setTemp(key, value, sendChanges);
394
- case 3:
395
- _context6.t1 = _yield$this$obj$setTe = _context6.sent;
396
- _context6.t0 = _context6.t1 !== null;
397
- if (!_context6.t0) {
398
- _context6.next = 7;
399
- break;
400
- }
401
- _context6.t0 = _yield$this$obj$setTe !== void 0;
402
- case 7:
403
- if (!_context6.t0) {
404
- _context6.next = 11;
405
- break;
406
- }
407
- _context6.t2 = _yield$this$obj$setTe;
408
- _context6.next = 12;
409
- break;
410
- case 11:
411
- _context6.t2 = false;
412
- case 12:
413
- return _context6.abrupt("return", _context6.t2);
414
- case 13:
415
- case "end":
416
- return _context6.stop();
417
- }
418
- }, _callee6, this);
419
- }));
420
- function setObjectTemp(_x12, _x13) {
421
- return _setObjectTemp.apply(this, arguments);
422
- }
423
- return setObjectTemp;
424
- }() //get temp value of object
425
- }, {
426
- key: "getObjectTemp",
427
- value: function getObjectTemp(key) {
428
- var _this$obj$getTemp, _this$obj1;
429
- return (_this$obj$getTemp = (_this$obj1 = this.obj) === null || _this$obj1 === void 0 ? void 0 : _this$obj1.getTemp(key)) !== null && _this$obj$getTemp !== void 0 ? _this$obj$getTemp : undefined;
430
- }
431
- /* -------------------------------------------------------------------------- */
432
- }, {
433
- key: "getIndexOrID",
434
- value: function getIndexOrID() {
435
- var _this$obj10;
436
- return ((_this$obj10 = this.obj) === null || _this$obj10 === void 0 ? void 0 : _this$obj10.getIndexOrID()) || -1;
437
- }
438
- }, {
439
- key: "getIndex",
440
- value: function getIndex() {
441
- var _this$obj11;
442
- return ((_this$obj11 = this.obj) === null || _this$obj11 === void 0 ? void 0 : _this$obj11.getIndex()) || -1;
443
- }
444
- }, {
445
- key: "getID",
446
- value: function getID() {
447
- var _this$obj12;
448
- return ((_this$obj12 = this.obj) === null || _this$obj12 === void 0 ? void 0 : _this$obj12.getID()) || "";
449
- }
450
- /* -------------------------------------------------------------------------- */
451
- /* Events */
452
- /* -------------------------------------------------------------------------- */
453
- }, {
454
- key: "event_run",
455
- value: (function () {
456
- var _event_run = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee7(eventName) {
457
- var _len,
458
- params,
459
- _key,
460
- _args7 = arguments;
461
- return _regeneratorRuntime().wrap(function _callee7$(_context7) {
462
- while (1) switch (_context7.prev = _context7.next) {
463
- case 0:
464
- if (!(this.__stopEvents === true)) {
465
- _context7.next = 2;
466
- break;
467
- }
468
- return _context7.abrupt("return");
469
- case 2:
470
- for (_len = _args7.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
471
- params[_key - 1] = _args7[_key];
472
- }
473
- _context7.next = 5;
474
- return _event.EventManager.run.apply(_event.EventManager, [this, eventName].concat(params));
475
- case 5:
476
- return _context7.abrupt("return", _context7.sent);
477
- case 6:
478
- case "end":
479
- return _context7.stop();
480
- }
481
- }, _callee7, this);
482
- }));
483
- function event_run(_x14) {
484
- return _event_run.apply(this, arguments);
485
- }
486
- return event_run;
487
- }())
488
- }, {
489
- key: "event_use",
490
- value: function event_use(name, runEvent) {
491
- var onlyOn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
492
- var runOnce = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
493
- return _event.EventManager.use(this, name, runEvent, onlyOn, runOnce);
494
- }
140
+ */
141
+ async setSubValue(key, objKey, subvalue) {
142
+ return ((await this.obj?.setSubValue(key, objKey, subvalue)) ?? false);
143
+ }
144
+ //Push value on array
145
+ async pushValue(key, value) {
146
+ return (await this.obj?.pushValue(key, value)) ?? false;
147
+ }
148
+ //set temp value of object
149
+ async setTemp(key, value, sendChanges = false) {
150
+ await this.setObjectTemp(key, value, sendChanges);
151
+ return await super.setTemp(key, value);
152
+ }
153
+ //set temp value of object
154
+ async setObjectTemp(key, value, sendChanges = false) {
155
+ return (await this.obj?.setTemp(key, value, sendChanges)) ?? false;
156
+ }
157
+ //get temp value of object
158
+ getObjectTemp(key) {
159
+ return this.obj?.getTemp(key) ?? undefined;
160
+ }
161
+ /* -------------------------------------------------------------------------- */
162
+ getIndexOrID() {
163
+ return this.obj?.getIndexOrID() || -1;
164
+ }
165
+ getIndex() {
166
+ return this.obj?.getIndex() || -1;
167
+ }
168
+ getID() {
169
+ return this.obj?.getID() || "";
170
+ }
171
+ /* -------------------------------------------------------------------------- */
172
+ /* Events */
173
+ /* -------------------------------------------------------------------------- */
174
+ async event_run(eventName, ...params) {
175
+ return await EventContext.run(this, eventName, ...params);
176
+ }
177
+ event_use(name, runEvent, onlyOn = null, runOnce = false) {
178
+ return useEvent(this, name, runEvent, onlyOn, runOnce);
179
+ }
495
180
  /**
496
181
  * only useful for getter functions that dont rely on states
497
182
  * @param name
498
183
  * @param runEvent
499
184
  * @param onlyOn
500
185
  * @returns
501
- */
502
- }, {
503
- key: "event_use_getter",
504
- value: function event_use_getter(name, runEvent) {
505
- var onlyOn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
506
- return _event.EventManager.use_getter(this, name, runEvent, onlyOn);
507
- }
508
- }, {
509
- key: "event_remove",
510
- value: function event_remove(name, uname) {
511
- return _event.EventManager.remove(this, name, uname);
512
- }
513
- }, {
514
- key: "event_add",
515
- value: function () {
516
- var _event_add = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee8(name, uname, runEvent) {
517
- var onlyOn,
518
- runOnce,
519
- _args8 = arguments;
520
- return _regeneratorRuntime().wrap(function _callee8$(_context8) {
521
- while (1) switch (_context8.prev = _context8.next) {
522
- case 0:
523
- onlyOn = _args8.length > 3 && _args8[3] !== undefined ? _args8[3] : null;
524
- runOnce = _args8.length > 4 && _args8[4] !== undefined ? _args8[4] : false;
525
- _context8.next = 4;
526
- return _event.EventManager.add(this, name, uname, runEvent, onlyOn, runOnce);
527
- case 4:
528
- case "end":
529
- return _context8.stop();
530
- }
531
- }, _callee8, this);
532
- }));
533
- function event_add(_x15, _x16, _x17) {
534
- return _event_add.apply(this, arguments);
535
- }
536
- return event_add;
537
- }()
538
- }, {
539
- key: "events_start",
540
- value: function events_start() {
541
- delete this.__stopEvents;
542
- }
543
- }, {
544
- key: "events_stop",
545
- value: function events_stop() {
546
- this.__stopEvents = true;
547
- }
548
- }, {
549
- key: "events_clear",
550
- value: function events_clear() {
551
- ObjectManager.events_clear(this);
552
- }
553
- }, {
554
- key: "clear_changes",
555
- value: function clear_changes() {
556
- var _this$obj$clear_chang, _this$obj13;
557
- return (_this$obj$clear_chang = (_this$obj13 = this.obj) === null || _this$obj13 === void 0 ? void 0 : _this$obj13.clear_changes()) !== null && _this$obj$clear_chang !== void 0 ? _this$obj$clear_chang : false;
558
- }
559
- }, {
560
- key: "clear_cache",
561
- value: function clear_cache() {
562
- var _this$obj$clear_cache, _this$obj14;
563
- return (_this$obj$clear_cache = (_this$obj14 = this.obj) === null || _this$obj14 === void 0 ? void 0 : _this$obj14.clear_cache()) !== null && _this$obj$clear_cache !== void 0 ? _this$obj$clear_cache : false;
564
- }
565
- }, {
566
- key: "toggleOption",
567
- value: (
568
- /* -------------------------------------------------------------------------- */
569
- /* Options */
570
- /* -------------------------------------------------------------------------- */
186
+ */
187
+ event_use_getter(name, runEvent, onlyOn = null) {
188
+ return useGetter(this, name, runEvent, onlyOn);
189
+ }
190
+ event_remove(name, uname) {
191
+ return EventContext.remove(this, name, uname);
192
+ }
193
+ async event_add(eventName, uniqueName, eventFunction, eventChecker = null, runOnRegister = false) {
194
+ await EventManager.add(this, {
195
+ eventName,
196
+ uniqueName,
197
+ eventFunction,
198
+ eventChecker,
199
+ runOnRegister,
200
+ });
201
+ }
202
+ events_start() {
203
+ // delete this.__stopEvents;
204
+ }
205
+ events_stop() {
206
+ // this.__setopEvents = true;
207
+ }
208
+ events_clear() {
209
+ ObjectManager.events_clear(this);
210
+ }
211
+ clear_changes() {
212
+ return this.obj?.clear_changes() ?? false;
213
+ }
214
+ clear_cache() {
215
+ return this.obj?.clear_cache() ?? false;
216
+ }
217
+ static events_clear(obj) {
218
+ EventContext.removeAll(obj);
219
+ }
220
+ /* -------------------------------------------------------------------------- */
221
+ /* Options */
222
+ /* -------------------------------------------------------------------------- */
571
223
  /**
572
224
  * Set an option to some value, if its already equal to the value it will be deleted instead
573
225
  * @param key
574
226
  * @param value
575
227
  * @returns
576
- */
577
- function () {
578
- var _toggleOption = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee9(key, value) {
579
- var oldval;
580
- return _regeneratorRuntime().wrap(function _callee9$(_context9) {
581
- while (1) switch (_context9.prev = _context9.next) {
582
- case 0:
583
- oldval = this.getOption(key);
584
- if (!(0, _object.object_equals_loose)(oldval, value)) {
585
- _context9.next = 6;
586
- break;
587
- }
588
- _context9.next = 4;
589
- return this.setOption(key, null);
590
- case 4:
591
- _context9.next = 8;
592
- break;
593
- case 6:
594
- _context9.next = 8;
595
- return this.setOption(key, value);
596
- case 8:
597
- case "end":
598
- return _context9.stop();
599
- }
600
- }, _callee9, this);
601
- }));
602
- function toggleOption(_x18, _x19) {
603
- return _toggleOption.apply(this, arguments);
604
- }
605
- return toggleOption;
606
- }())
607
- }, {
608
- key: "getOption",
609
- value: function getOption(key) {
610
- if (this.__options == null) return undefined;
611
- key = key.toLowerCase();
612
- return this.__options[key];
613
- }
228
+ */
229
+ async toggleOption(key, value) {
230
+ var oldval = this.getOption(key);
231
+ if (object_equals_loose(oldval, value)) {
232
+ await this.setOption(key, null);
233
+ }
234
+ else
235
+ await this.setOption(key, value);
236
+ }
237
+ getOption(key) {
238
+ if (this.__options == null)
239
+ return undefined;
240
+ key = key.toLowerCase();
241
+ return this.__options[key];
242
+ }
614
243
  /**
615
244
  * updates `__options` and runs the `event_run`
616
245
  * @param key
617
246
  * @param value
618
247
  * @returns true if changed, false otherwise
619
- */
620
- }, {
621
- key: "setOption",
622
- value: (function () {
623
- var _setOption = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee0(key, value) {
624
- var isChanged;
625
- return _regeneratorRuntime().wrap(function _callee0$(_context0) {
626
- while (1) switch (_context0.prev = _context0.next) {
627
- case 0:
628
- if (this.__options == null) this.__options = {};
629
- key = key.toLowerCase();
630
- isChanged = this.__options[key] !== value;
631
- if (value == null) {
632
- delete this.__options[key];
633
- } else {
634
- this.__options[key] = value;
635
- }
636
- _context0.next = 6;
637
- return this.event_run("on_option_change", key, value);
638
- case 6:
639
- return _context0.abrupt("return", isChanged);
640
- case 7:
641
- case "end":
642
- return _context0.stop();
643
- }
644
- }, _callee0, this);
645
- }));
646
- function setOption(_x20, _x21) {
647
- return _setOption.apply(this, arguments);
648
- }
649
- return setOption;
650
- }()
248
+ */
249
+ async setOption(key, value) {
250
+ if (this.__options == null)
251
+ this.__options = {};
252
+ key = key.toLowerCase();
253
+ const isChanged = this.__options[key] !== value;
254
+ if (value == null) {
255
+ delete this.__options[key];
256
+ }
257
+ else {
258
+ this.__options[key] = value;
259
+ }
260
+ await this.event_run("on_option_change", key, value);
261
+ return isChanged;
262
+ }
651
263
  /**
652
264
  * use an option and detect its changes in real time. similar to React state
653
265
  * @param key name of the option
654
266
  * @returns value of the option
655
- */
656
- )
657
- }, {
658
- key: "useOption",
659
- value: function useOption(key) {
660
- var _this3 = this;
661
- return this.event_use_getter("on_option_change", function () {
662
- return _this3.getOption(key);
663
- }, [key]);
664
- }
267
+ */
268
+ useOption(key) {
269
+ return this.event_use_getter("on_option_change", () => this.getOption(key), [key]);
270
+ }
665
271
  /**
666
272
  * Sets an option then does an action,
667
273
  * after the action is run, updates the option again
@@ -669,131 +275,66 @@ var ObjectManager = exports.ObjectManager = /*#__PURE__*/function (_RawObject) {
669
275
  * @param value
670
276
  * @param nextvalue
671
277
  * @param action
672
- */
673
- }, {
674
- key: "holdOption",
675
- value: (function () {
676
- var _holdOption = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee1(key, value, nextvalue, action) {
677
- return _regeneratorRuntime().wrap(function _callee1$(_context1) {
678
- while (1) switch (_context1.prev = _context1.next) {
679
- case 0:
680
- _context1.prev = 0;
681
- this.setOption(key, value);
682
- if (!(typeof action === "function")) {
683
- _context1.next = 5;
684
- break;
685
- }
686
- _context1.next = 5;
687
- return action();
688
- case 5:
689
- _context1.prev = 5;
690
- this.setOption(key, nextvalue);
691
- return _context1.finish(5);
692
- case 8:
693
- case "end":
694
- return _context1.stop();
695
- }
696
- }, _callee1, this, [[0,, 5, 8]]);
697
- }));
698
- function holdOption(_x22, _x23, _x24, _x25) {
699
- return _holdOption.apply(this, arguments);
700
- }
701
- return holdOption;
702
- }()
703
- /* ------------------------------ useIsChanged; ----------------------------- */
278
+ */
279
+ async holdOption(key, value, nextvalue, action) {
280
+ try {
281
+ this.setOption(key, value);
282
+ if (typeof action === "function")
283
+ await action();
284
+ }
285
+ finally {
286
+ this.setOption(key, nextvalue);
287
+ }
288
+ }
289
+ /* ------------------------------ useIsChanged; ----------------------------- */
704
290
  /**
705
291
  * @returns isChanged
706
- */
707
- )
708
- }, {
709
- key: "useIsChanged",
710
- value: function useIsChanged() {
711
- return this.useOption("ischanged");
712
- }
713
- }, {
714
- key: "checkIsChanged",
715
- value: function () {
716
- var _checkIsChanged = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
717
- return _regeneratorRuntime().wrap(function _callee10$(_context10) {
718
- while (1) switch (_context10.prev = _context10.next) {
719
- case 0:
720
- _context10.next = 2;
721
- return this.setOption("ischanged", this.isChanged);
722
- case 2:
723
- case "end":
724
- return _context10.stop();
725
- }
726
- }, _callee10, this);
727
- }));
728
- function checkIsChanged() {
729
- return _checkIsChanged.apply(this, arguments);
730
- }
731
- return checkIsChanged;
732
- }()
733
- /* -------------------------------------------------------------------------- */
734
- /* Errors */
735
- /* -------------------------------------------------------------------------- */
736
- }, {
737
- key: "addError",
738
- value: function addError(title, message) {
739
- var sendToRegister = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "auto";
740
- return ObjectManager.addError(this, title, message, sendToRegister);
741
- }
742
- }, {
743
- key: "getErrors",
744
- value: function getErrors() {
745
- return ObjectManager.getErrors(this);
746
- }
747
- }, {
748
- key: "clearErrors",
749
- value: function clearErrors() {
750
- return ObjectManager.clearErrors(this);
751
- }
752
- }, {
753
- key: "getObjectType",
754
- value: /* -------------------------------------------------------------------------- */
755
- /* get __object_type */
756
- /* -------------------------------------------------------------------------- */
757
- function getObjectType() {
758
- return this.constructor["getObjectType"]();
759
- }
760
- }], [{
761
- key: "events_clear",
762
- value: function events_clear(obj) {
763
- _event.EventManager.removeAll(obj);
764
- }
765
- }, {
766
- key: "addError",
767
- value: function addError(o, title, message) {
768
- var sendToRegister = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "auto";
769
- if (o && o.obj) {
770
- return _SimpleObject["default"].addError(o.obj, title, message, sendToRegister);
771
- }
772
- var errStr = (0, _string.combine_if_not_blank)(title, " : ", message);
773
- console.error("[REGISTER-ERROR]", errStr);
774
- _global.gfunc.run_action("add_error", {
775
- title: title,
776
- message: message,
777
- type: "error"
778
- });
779
- }
780
- }, {
781
- key: "getErrors",
782
- value: function getErrors(o) {
783
- var obj = o.obj;
784
- return obj != null ? _SimpleObject["default"].getErrors(o.obj) : [];
785
- }
786
- }, {
787
- key: "clearErrors",
788
- value: function clearErrors(o) {
789
- return _SimpleObject["default"].clearErrors(o.obj);
790
- }
791
- }, {
792
- key: "getObjectType",
793
- value: function getObjectType() {
794
- return (0, _object.fn_eval)(this.__object_type);
795
- }
796
- }]);
797
- }(_MapableObject["default"]);
798
- _defineProperty(ObjectManager, "__object_type", void 0);
799
- var _default = exports["default"] = ObjectManager;
292
+ */
293
+ useIsChanged() {
294
+ return this.useOption("ischanged");
295
+ }
296
+ async checkIsChanged() {
297
+ await this.setOption("ischanged", this.isChanged);
298
+ }
299
+ /* -------------------------------------------------------------------------- */
300
+ /* Errors */
301
+ /* -------------------------------------------------------------------------- */
302
+ addError(title, message, sendToRegister = "auto") {
303
+ return ObjectManager.addError(this, title, message, sendToRegister);
304
+ }
305
+ getErrors() {
306
+ return ObjectManager.getErrors(this);
307
+ }
308
+ clearErrors() {
309
+ return ObjectManager.clearErrors(this);
310
+ }
311
+ static addError(o, title, message, sendToRegister = "auto") {
312
+ if (o && o.obj) {
313
+ return SimpleObject.addError(o.obj, title, message, sendToRegister);
314
+ }
315
+ const errStr = combine_if_not_blank(title, " : ", message);
316
+ console.error("[REGISTER-ERROR]", errStr);
317
+ gfunc.run_action("add_error", {
318
+ title: title,
319
+ message: message,
320
+ type: "error",
321
+ });
322
+ }
323
+ static getErrors(o) {
324
+ const obj = o.obj;
325
+ return obj != null ? SimpleObject.getErrors(o.obj) : [];
326
+ }
327
+ static clearErrors(o) {
328
+ return SimpleObject.clearErrors(o.obj);
329
+ }
330
+ /* -------------------------------------------------------------------------- */
331
+ /* get __object_type */
332
+ /* -------------------------------------------------------------------------- */
333
+ getObjectType() {
334
+ return this.constructor["getObjectType"]();
335
+ }
336
+ static getObjectType() {
337
+ return fn_eval(this.__object_type);
338
+ }
339
+ }
340
+ export default ObjectManager;