@azrico/webobject 1.2.10 → 1.2.12
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.
- package/dist/index.js +18 -1
- package/dist/src/WebObjects/ParentWebObject.js +96 -1
- package/dist/src/WebObjects/WebObject.js +742 -15
- package/dist/src/WebObjects/WebObjectManager.js +356 -6
- package/dist/src/index.js +109 -1
- package/dist/src/structs/DummyObject.js +54 -1
- package/dist/src/structs/MapableObject.d.ts +2 -0
- package/dist/src/structs/MapableObject.js +142 -2
- package/dist/src/structs/MetaObject.js +171 -1
- package/dist/src/structs/ObjectArray.js +84 -1
- package/dist/src/structs/ObjectManager.js +659 -9
- package/dist/src/structs/SimpleObject.js +970 -8
- package/package.json +2 -2
- package/dist/index.js.map +0 -1
- package/dist/src/WebObjects/ParentWebObject.js.map +0 -1
- package/dist/src/WebObjects/WebObject.js.map +0 -1
- package/dist/src/WebObjects/WebObjectManager.js.map +0 -1
- package/dist/src/index.js.map +0 -1
- package/dist/src/structs/DummyObject.js.map +0 -1
- package/dist/src/structs/MapableObject.js.map +0 -1
- package/dist/src/structs/MetaObject.js.map +0 -1
- package/dist/src/structs/ObjectArray.js.map +0 -1
- package/dist/src/structs/ObjectManager.js.map +0 -1
- package/dist/src/structs/SimpleObject.js.map +0 -1
|
@@ -1,34 +1,684 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = exports.ObjectManager = void 0;
|
|
9
|
+
|
|
10
|
+
var _event = require("@azrico/event");
|
|
11
|
+
|
|
12
|
+
var _SimpleObject = _interopRequireDefault(require("./SimpleObject"));
|
|
13
|
+
|
|
14
|
+
var _string = require("@azrico/string");
|
|
15
|
+
|
|
16
|
+
var _global = require("@azrico/global");
|
|
17
|
+
|
|
18
|
+
var _object = require("@azrico/object");
|
|
19
|
+
|
|
20
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
|
+
|
|
22
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
23
|
+
|
|
24
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
25
|
+
|
|
26
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
27
|
+
|
|
28
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
29
|
+
|
|
30
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
|
31
|
+
|
|
32
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
33
|
+
|
|
34
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
35
|
+
|
|
36
|
+
/**
|
|
2
37
|
* This class manages the events of an Simple Object
|
|
3
|
-
*/
|
|
38
|
+
*/
|
|
39
|
+
var ObjectManager = /*#__PURE__*/function () {
|
|
40
|
+
function ObjectManager() {
|
|
41
|
+
_classCallCheck(this, ObjectManager);
|
|
42
|
+
|
|
43
|
+
_defineProperty(this, "__eventList", void 0);
|
|
44
|
+
|
|
45
|
+
_defineProperty(this, "__eventPrefix", void 0);
|
|
46
|
+
|
|
47
|
+
_defineProperty(this, "__sendEvents", true);
|
|
48
|
+
|
|
49
|
+
_defineProperty(this, "__currentObject", void 0);
|
|
50
|
+
|
|
51
|
+
_defineProperty(this, "__options", void 0);
|
|
52
|
+
|
|
53
|
+
_defineProperty(this, "get", this.getValue);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
_createClass(ObjectManager, [{
|
|
57
|
+
key: "notifyChanged",
|
|
58
|
+
value: function () {
|
|
59
|
+
var _notifyChanged = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(type, key, value, subvalue) {
|
|
60
|
+
var obj, typestr;
|
|
61
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
62
|
+
while (1) {
|
|
63
|
+
switch (_context.prev = _context.next) {
|
|
64
|
+
case 0:
|
|
65
|
+
obj = this.getObject();
|
|
66
|
+
|
|
67
|
+
if (obj) {
|
|
68
|
+
_context.next = 3;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return _context.abrupt("return", false);
|
|
73
|
+
|
|
74
|
+
case 3:
|
|
75
|
+
if (value === undefined && type != "meta") value = obj.getValue(key);
|
|
76
|
+
typestr = (type ? "$".concat(type, "$") : "") + String(key);
|
|
77
|
+
_context.next = 7;
|
|
78
|
+
return this.event_run("on_change", typestr, value);
|
|
79
|
+
|
|
80
|
+
case 7:
|
|
81
|
+
return _context.abrupt("return", _context.sent);
|
|
82
|
+
|
|
83
|
+
case 8:
|
|
84
|
+
case "end":
|
|
85
|
+
return _context.stop();
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}, _callee, this);
|
|
89
|
+
}));
|
|
90
|
+
|
|
91
|
+
function notifyChanged(_x, _x2, _x3, _x4) {
|
|
92
|
+
return _notifyChanged.apply(this, arguments);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return notifyChanged;
|
|
96
|
+
}()
|
|
97
|
+
/* -------------------------------------------------------------------------- */
|
|
98
|
+
|
|
99
|
+
}, {
|
|
100
|
+
key: "obj",
|
|
101
|
+
get: function get() {
|
|
102
|
+
return this.getObject();
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
4
105
|
* Get the object this manager is managing
|
|
5
106
|
* @returns the object
|
|
6
|
-
*/
|
|
107
|
+
*/
|
|
108
|
+
|
|
109
|
+
}, {
|
|
110
|
+
key: "getObject",
|
|
111
|
+
value: function getObject() {
|
|
112
|
+
var _this$__currentObject;
|
|
113
|
+
|
|
114
|
+
return (_this$__currentObject = this.__currentObject) !== null && _this$__currentObject !== void 0 ? _this$__currentObject : undefined;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
7
117
|
* Set the object this manager is managing
|
|
8
118
|
* @param toObj
|
|
9
119
|
* @returns
|
|
10
|
-
*/
|
|
120
|
+
*/
|
|
121
|
+
|
|
122
|
+
}, {
|
|
123
|
+
key: "setObject",
|
|
124
|
+
value: function setObject(toObj) {
|
|
125
|
+
var _this = this;
|
|
126
|
+
|
|
127
|
+
this.__currentObject = toObj;
|
|
128
|
+
|
|
129
|
+
if (this.__currentObject) {
|
|
130
|
+
this.__currentObject.get_managerClass = function () {
|
|
131
|
+
return _this;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
/* -------------------------------------------------------------------------- */
|
|
138
|
+
|
|
139
|
+
/* Child functions */
|
|
140
|
+
|
|
141
|
+
/* -------------------------------------------------------------------------- */
|
|
142
|
+
|
|
143
|
+
}, {
|
|
144
|
+
key: "isChanged",
|
|
145
|
+
get: function get() {
|
|
146
|
+
return this.obj != null && this.obj.isChanged;
|
|
147
|
+
}
|
|
148
|
+
}, {
|
|
149
|
+
key: "isDeleted",
|
|
150
|
+
get: function get() {
|
|
151
|
+
return this.obj == null || this.obj.isDeleted;
|
|
152
|
+
}
|
|
153
|
+
}, {
|
|
154
|
+
key: "d",
|
|
155
|
+
get: function get() {
|
|
156
|
+
var _this$obj;
|
|
157
|
+
|
|
158
|
+
return (_this$obj = this.obj) === null || _this$obj === void 0 ? void 0 : _this$obj.d;
|
|
159
|
+
}
|
|
160
|
+
}, {
|
|
161
|
+
key: "canModify",
|
|
162
|
+
get: function get() {
|
|
163
|
+
var _this$obj2;
|
|
164
|
+
|
|
165
|
+
return !((_this$obj2 = this.obj) !== null && _this$obj2 !== void 0 && _this$obj2.canModify);
|
|
166
|
+
}
|
|
167
|
+
}, {
|
|
168
|
+
key: "isNew",
|
|
169
|
+
get: function get() {
|
|
170
|
+
return this.obj == null || this.obj.isNew;
|
|
171
|
+
}
|
|
172
|
+
}, {
|
|
173
|
+
key: "isSaved",
|
|
174
|
+
get: function get() {
|
|
175
|
+
var _this$obj3;
|
|
176
|
+
|
|
177
|
+
return ((_this$obj3 = this.obj) === null || _this$obj3 === void 0 ? void 0 : _this$obj3.isSaved) || false;
|
|
178
|
+
}
|
|
179
|
+
}, {
|
|
180
|
+
key: "__cache_name",
|
|
181
|
+
get: function get() {
|
|
182
|
+
return this.constructor["__cache_name"];
|
|
183
|
+
}
|
|
184
|
+
}, {
|
|
185
|
+
key: "getSaveResult",
|
|
186
|
+
value: function getSaveResult() {
|
|
187
|
+
var _this$getObject;
|
|
188
|
+
|
|
189
|
+
return ((_this$getObject = this.getObject()) === null || _this$getObject === void 0 ? void 0 : _this$getObject.getSaveResult()) || undefined;
|
|
190
|
+
}
|
|
191
|
+
}, {
|
|
192
|
+
key: "getSaveResultType",
|
|
193
|
+
value: function getSaveResultType() {
|
|
194
|
+
var _this$getObject2;
|
|
195
|
+
|
|
196
|
+
return ((_this$getObject2 = this.getObject()) === null || _this$getObject2 === void 0 ? void 0 : _this$getObject2.getSaveResultType()) || null;
|
|
197
|
+
}
|
|
198
|
+
}, {
|
|
199
|
+
key: "setSaveResult",
|
|
200
|
+
value: function setSaveResult(toObj, type) {
|
|
201
|
+
return this.setSaveResult(toObj, type);
|
|
202
|
+
}
|
|
203
|
+
}, {
|
|
204
|
+
key: "apply_changes",
|
|
205
|
+
value: function apply_changes() {
|
|
206
|
+
var _this$obj4;
|
|
207
|
+
|
|
208
|
+
return (_this$obj4 = this.obj) === null || _this$obj4 === void 0 ? void 0 : _this$obj4.apply_changes();
|
|
209
|
+
}
|
|
210
|
+
}, {
|
|
211
|
+
key: "getValue",
|
|
212
|
+
value: function getValue(key) {
|
|
213
|
+
var _this$obj5;
|
|
214
|
+
|
|
215
|
+
var original = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
216
|
+
return (_this$obj5 = this.obj) === null || _this$obj5 === void 0 ? void 0 : _this$obj5.getValue(key, original);
|
|
217
|
+
}
|
|
218
|
+
}, {
|
|
219
|
+
key: "setValue",
|
|
220
|
+
value:
|
|
221
|
+
/**
|
|
11
222
|
* set value
|
|
12
223
|
* @param key
|
|
13
224
|
* @param value
|
|
14
225
|
* @return true if changed , false otherwise
|
|
15
|
-
*/
|
|
226
|
+
*/
|
|
227
|
+
function () {
|
|
228
|
+
var _setValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(key, value) {
|
|
229
|
+
var _this$obj6;
|
|
230
|
+
|
|
231
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
232
|
+
while (1) {
|
|
233
|
+
switch (_context2.prev = _context2.next) {
|
|
234
|
+
case 0:
|
|
235
|
+
_context2.next = 2;
|
|
236
|
+
return (_this$obj6 = this.obj) === null || _this$obj6 === void 0 ? void 0 : _this$obj6.setValue(key, value);
|
|
237
|
+
|
|
238
|
+
case 2:
|
|
239
|
+
_context2.t0 = _context2.sent;
|
|
240
|
+
|
|
241
|
+
if (_context2.t0) {
|
|
242
|
+
_context2.next = 5;
|
|
243
|
+
break;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
_context2.t0 = false;
|
|
247
|
+
|
|
248
|
+
case 5:
|
|
249
|
+
return _context2.abrupt("return", _context2.t0);
|
|
250
|
+
|
|
251
|
+
case 6:
|
|
252
|
+
case "end":
|
|
253
|
+
return _context2.stop();
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}, _callee2, this);
|
|
257
|
+
}));
|
|
258
|
+
|
|
259
|
+
function setValue(_x5, _x6) {
|
|
260
|
+
return _setValue.apply(this, arguments);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
return setValue;
|
|
264
|
+
}()
|
|
265
|
+
/**
|
|
16
266
|
* set key of subObject
|
|
17
267
|
* @param key
|
|
18
268
|
* @param value
|
|
19
269
|
* @param subvalue
|
|
20
270
|
* @return true if changed , false otherwise
|
|
21
|
-
*/
|
|
22
|
-
|
|
271
|
+
*/
|
|
272
|
+
|
|
273
|
+
}, {
|
|
274
|
+
key: "setSubValue",
|
|
275
|
+
value: function () {
|
|
276
|
+
var _setSubValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(key, objKey, subvalue) {
|
|
277
|
+
var _this$obj7;
|
|
278
|
+
|
|
279
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
280
|
+
while (1) {
|
|
281
|
+
switch (_context3.prev = _context3.next) {
|
|
282
|
+
case 0:
|
|
283
|
+
_context3.next = 2;
|
|
284
|
+
return (_this$obj7 = this.obj) === null || _this$obj7 === void 0 ? void 0 : _this$obj7.setSubValue(key, objKey, subvalue);
|
|
285
|
+
|
|
286
|
+
case 2:
|
|
287
|
+
_context3.t0 = _context3.sent;
|
|
288
|
+
|
|
289
|
+
if (_context3.t0) {
|
|
290
|
+
_context3.next = 5;
|
|
291
|
+
break;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
_context3.t0 = false;
|
|
295
|
+
|
|
296
|
+
case 5:
|
|
297
|
+
return _context3.abrupt("return", _context3.t0);
|
|
298
|
+
|
|
299
|
+
case 6:
|
|
300
|
+
case "end":
|
|
301
|
+
return _context3.stop();
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
}, _callee3, this);
|
|
305
|
+
}));
|
|
306
|
+
|
|
307
|
+
function setSubValue(_x7, _x8, _x9) {
|
|
308
|
+
return _setSubValue.apply(this, arguments);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
return setSubValue;
|
|
312
|
+
}() //Push value on array
|
|
313
|
+
|
|
314
|
+
}, {
|
|
315
|
+
key: "pushValue",
|
|
316
|
+
value: function () {
|
|
317
|
+
var _pushValue = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(key, value) {
|
|
318
|
+
var _this$obj8;
|
|
319
|
+
|
|
320
|
+
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
321
|
+
while (1) {
|
|
322
|
+
switch (_context4.prev = _context4.next) {
|
|
323
|
+
case 0:
|
|
324
|
+
_context4.next = 2;
|
|
325
|
+
return (_this$obj8 = this.obj) === null || _this$obj8 === void 0 ? void 0 : _this$obj8.pushValue(key, value);
|
|
326
|
+
|
|
327
|
+
case 2:
|
|
328
|
+
_context4.t0 = _context4.sent;
|
|
329
|
+
|
|
330
|
+
if (_context4.t0) {
|
|
331
|
+
_context4.next = 5;
|
|
332
|
+
break;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
_context4.t0 = false;
|
|
336
|
+
|
|
337
|
+
case 5:
|
|
338
|
+
return _context4.abrupt("return", _context4.t0);
|
|
339
|
+
|
|
340
|
+
case 6:
|
|
341
|
+
case "end":
|
|
342
|
+
return _context4.stop();
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}, _callee4, this);
|
|
346
|
+
}));
|
|
347
|
+
|
|
348
|
+
function pushValue(_x10, _x11) {
|
|
349
|
+
return _pushValue.apply(this, arguments);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
return pushValue;
|
|
353
|
+
}()
|
|
354
|
+
/* -------------------------------------------------------------------------- */
|
|
355
|
+
|
|
356
|
+
}, {
|
|
357
|
+
key: "getIndexOrID",
|
|
358
|
+
value: function getIndexOrID() {
|
|
359
|
+
var _this$obj9;
|
|
360
|
+
|
|
361
|
+
return ((_this$obj9 = this.obj) === null || _this$obj9 === void 0 ? void 0 : _this$obj9.getIndexOrID()) || -1;
|
|
362
|
+
}
|
|
363
|
+
}, {
|
|
364
|
+
key: "getIndex",
|
|
365
|
+
value: function getIndex() {
|
|
366
|
+
var _this$obj10;
|
|
367
|
+
|
|
368
|
+
return ((_this$obj10 = this.obj) === null || _this$obj10 === void 0 ? void 0 : _this$obj10.getIndex()) || -1;
|
|
369
|
+
}
|
|
370
|
+
}, {
|
|
371
|
+
key: "getID",
|
|
372
|
+
value: function getID() {
|
|
373
|
+
var _this$obj11;
|
|
374
|
+
|
|
375
|
+
return ((_this$obj11 = this.obj) === null || _this$obj11 === void 0 ? void 0 : _this$obj11.getID()) || "";
|
|
376
|
+
}
|
|
377
|
+
/* -------------------------------------------------------------------------- */
|
|
378
|
+
|
|
379
|
+
/* Getters */
|
|
380
|
+
|
|
381
|
+
/* -------------------------------------------------------------------------- */
|
|
382
|
+
|
|
383
|
+
/* -------------------------------------------------------------------------- */
|
|
384
|
+
|
|
385
|
+
/* Events */
|
|
386
|
+
|
|
387
|
+
/* -------------------------------------------------------------------------- */
|
|
388
|
+
|
|
389
|
+
}, {
|
|
390
|
+
key: "event_run",
|
|
391
|
+
value: function () {
|
|
392
|
+
var _event_run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(eventName) {
|
|
393
|
+
var _len,
|
|
394
|
+
params,
|
|
395
|
+
_key,
|
|
396
|
+
_args5 = arguments;
|
|
397
|
+
|
|
398
|
+
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
399
|
+
while (1) {
|
|
400
|
+
switch (_context5.prev = _context5.next) {
|
|
401
|
+
case 0:
|
|
402
|
+
if (this.__sendEvents) {
|
|
403
|
+
_context5.next = 2;
|
|
404
|
+
break;
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
return _context5.abrupt("return");
|
|
408
|
+
|
|
409
|
+
case 2:
|
|
410
|
+
for (_len = _args5.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
411
|
+
params[_key - 1] = _args5[_key];
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
_context5.next = 5;
|
|
415
|
+
return _event.EventManager.run.apply(_event.EventManager, [this, eventName].concat(params));
|
|
416
|
+
|
|
417
|
+
case 5:
|
|
418
|
+
case "end":
|
|
419
|
+
return _context5.stop();
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}, _callee5, this);
|
|
423
|
+
}));
|
|
424
|
+
|
|
425
|
+
function event_run(_x12) {
|
|
426
|
+
return _event_run.apply(this, arguments);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
return event_run;
|
|
430
|
+
}()
|
|
431
|
+
}, {
|
|
432
|
+
key: "event_use",
|
|
433
|
+
value: function event_use(name, runEvent) {
|
|
434
|
+
var onlyOn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
|
435
|
+
var runOnce = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
436
|
+
return _event.EventManager.use(this, name, runEvent, onlyOn, runOnce);
|
|
437
|
+
}
|
|
438
|
+
}, {
|
|
439
|
+
key: "event_add",
|
|
440
|
+
value: function () {
|
|
441
|
+
var _event_add = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(name, uname, runEvent) {
|
|
442
|
+
var onlyOn,
|
|
443
|
+
runOnce,
|
|
444
|
+
_args6 = arguments;
|
|
445
|
+
return _regeneratorRuntime().wrap(function _callee6$(_context6) {
|
|
446
|
+
while (1) {
|
|
447
|
+
switch (_context6.prev = _context6.next) {
|
|
448
|
+
case 0:
|
|
449
|
+
onlyOn = _args6.length > 3 && _args6[3] !== undefined ? _args6[3] : null;
|
|
450
|
+
runOnce = _args6.length > 4 && _args6[4] !== undefined ? _args6[4] : false;
|
|
451
|
+
_context6.next = 4;
|
|
452
|
+
return _event.EventManager.add(this, name, uname, runEvent, onlyOn, runOnce);
|
|
453
|
+
|
|
454
|
+
case 4:
|
|
455
|
+
case "end":
|
|
456
|
+
return _context6.stop();
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
}, _callee6, this);
|
|
460
|
+
}));
|
|
461
|
+
|
|
462
|
+
function event_add(_x13, _x14, _x15) {
|
|
463
|
+
return _event_add.apply(this, arguments);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
return event_add;
|
|
467
|
+
}()
|
|
468
|
+
}, {
|
|
469
|
+
key: "events_stop",
|
|
470
|
+
value: function events_stop() {
|
|
471
|
+
this.__sendEvents = false;
|
|
472
|
+
}
|
|
473
|
+
}, {
|
|
474
|
+
key: "events_clear",
|
|
475
|
+
value: function events_clear() {
|
|
476
|
+
ObjectManager.events_clear(this);
|
|
477
|
+
}
|
|
478
|
+
}, {
|
|
479
|
+
key: "toggleOption",
|
|
480
|
+
value:
|
|
481
|
+
/* -------------------------------------------------------------------------- */
|
|
482
|
+
|
|
483
|
+
/* Options */
|
|
484
|
+
|
|
485
|
+
/* -------------------------------------------------------------------------- */
|
|
486
|
+
|
|
487
|
+
/**
|
|
23
488
|
* Set an option to some value, if its already equal to the value it will be deleted instead
|
|
24
489
|
* @param key
|
|
25
490
|
* @param value
|
|
26
491
|
* @returns
|
|
27
|
-
*/
|
|
492
|
+
*/
|
|
493
|
+
function () {
|
|
494
|
+
var _toggleOption = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(key, value) {
|
|
495
|
+
var oldval;
|
|
496
|
+
return _regeneratorRuntime().wrap(function _callee7$(_context7) {
|
|
497
|
+
while (1) {
|
|
498
|
+
switch (_context7.prev = _context7.next) {
|
|
499
|
+
case 0:
|
|
500
|
+
oldval = this.getOption(key);
|
|
501
|
+
|
|
502
|
+
if (!(0, _object.object_equals_loose)(oldval, value)) {
|
|
503
|
+
_context7.next = 6;
|
|
504
|
+
break;
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
_context7.next = 4;
|
|
508
|
+
return this.setOption(key, null);
|
|
509
|
+
|
|
510
|
+
case 4:
|
|
511
|
+
_context7.next = 8;
|
|
512
|
+
break;
|
|
513
|
+
|
|
514
|
+
case 6:
|
|
515
|
+
_context7.next = 8;
|
|
516
|
+
return this.setOption(key, value);
|
|
517
|
+
|
|
518
|
+
case 8:
|
|
519
|
+
case "end":
|
|
520
|
+
return _context7.stop();
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}, _callee7, this);
|
|
524
|
+
}));
|
|
525
|
+
|
|
526
|
+
function toggleOption(_x16, _x17) {
|
|
527
|
+
return _toggleOption.apply(this, arguments);
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
return toggleOption;
|
|
531
|
+
}()
|
|
532
|
+
}, {
|
|
533
|
+
key: "setOption",
|
|
534
|
+
value: function () {
|
|
535
|
+
var _setOption = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(key, value) {
|
|
536
|
+
return _regeneratorRuntime().wrap(function _callee8$(_context8) {
|
|
537
|
+
while (1) {
|
|
538
|
+
switch (_context8.prev = _context8.next) {
|
|
539
|
+
case 0:
|
|
540
|
+
if (this.__options == null) this.__options = {};
|
|
541
|
+
|
|
542
|
+
if (value == null) {
|
|
543
|
+
delete this.__options[key];
|
|
544
|
+
} else {
|
|
545
|
+
this.__options[key] = value;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
_context8.next = 4;
|
|
549
|
+
return this.event_run("on_option_change", key, value);
|
|
550
|
+
|
|
551
|
+
case 4:
|
|
552
|
+
return _context8.abrupt("return", _context8.sent);
|
|
553
|
+
|
|
554
|
+
case 5:
|
|
555
|
+
case "end":
|
|
556
|
+
return _context8.stop();
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}, _callee8, this);
|
|
560
|
+
}));
|
|
561
|
+
|
|
562
|
+
function setOption(_x18, _x19) {
|
|
563
|
+
return _setOption.apply(this, arguments);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
return setOption;
|
|
567
|
+
}()
|
|
568
|
+
/**
|
|
28
569
|
* Sets an option then does an action,
|
|
29
570
|
* after the action is run, updates the option again
|
|
30
571
|
* @param key
|
|
31
572
|
* @param value
|
|
32
573
|
* @param nextvalue
|
|
33
574
|
* @param action
|
|
34
|
-
*/
|
|
575
|
+
*/
|
|
576
|
+
|
|
577
|
+
}, {
|
|
578
|
+
key: "holdOption",
|
|
579
|
+
value: function () {
|
|
580
|
+
var _holdOption = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(key, value, nextvalue, action) {
|
|
581
|
+
return _regeneratorRuntime().wrap(function _callee9$(_context9) {
|
|
582
|
+
while (1) {
|
|
583
|
+
switch (_context9.prev = _context9.next) {
|
|
584
|
+
case 0:
|
|
585
|
+
_context9.prev = 0;
|
|
586
|
+
this.setOption(key, value);
|
|
587
|
+
|
|
588
|
+
if (!(typeof action === "function")) {
|
|
589
|
+
_context9.next = 5;
|
|
590
|
+
break;
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
_context9.next = 5;
|
|
594
|
+
return action();
|
|
595
|
+
|
|
596
|
+
case 5:
|
|
597
|
+
_context9.prev = 5;
|
|
598
|
+
this.setOption(key, nextvalue);
|
|
599
|
+
return _context9.finish(5);
|
|
600
|
+
|
|
601
|
+
case 8:
|
|
602
|
+
case "end":
|
|
603
|
+
return _context9.stop();
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
}, _callee9, this, [[0,, 5, 8]]);
|
|
607
|
+
}));
|
|
608
|
+
|
|
609
|
+
function holdOption(_x20, _x21, _x22, _x23) {
|
|
610
|
+
return _holdOption.apply(this, arguments);
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
return holdOption;
|
|
614
|
+
}()
|
|
615
|
+
}, {
|
|
616
|
+
key: "getOption",
|
|
617
|
+
value: function getOption(key) {
|
|
618
|
+
if (this.__options == null) return undefined;
|
|
619
|
+
return this.__options[key];
|
|
620
|
+
}
|
|
621
|
+
/* -------------------------------------------------------------------------- */
|
|
622
|
+
|
|
623
|
+
/* Errors */
|
|
624
|
+
|
|
625
|
+
/* -------------------------------------------------------------------------- */
|
|
626
|
+
|
|
627
|
+
}, {
|
|
628
|
+
key: "addError",
|
|
629
|
+
value: function addError(title, message) {
|
|
630
|
+
var sendToRegister = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "auto";
|
|
631
|
+
return ObjectManager.addError(this, title, message, sendToRegister);
|
|
632
|
+
}
|
|
633
|
+
}, {
|
|
634
|
+
key: "getErrors",
|
|
635
|
+
value: function getErrors() {
|
|
636
|
+
return ObjectManager.getErrors(this);
|
|
637
|
+
}
|
|
638
|
+
}, {
|
|
639
|
+
key: "clearErrors",
|
|
640
|
+
value: function clearErrors() {
|
|
641
|
+
return ObjectManager.clearErrors(this);
|
|
642
|
+
}
|
|
643
|
+
}], [{
|
|
644
|
+
key: "events_clear",
|
|
645
|
+
value: function events_clear(obj) {
|
|
646
|
+
_event.EventManager.removeAll(obj);
|
|
647
|
+
}
|
|
648
|
+
}, {
|
|
649
|
+
key: "addError",
|
|
650
|
+
value: function addError(o, title, message) {
|
|
651
|
+
var sendToRegister = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "auto";
|
|
652
|
+
|
|
653
|
+
if (o && o.obj) {
|
|
654
|
+
return _SimpleObject["default"].addError(o.obj, title, message, sendToRegister);
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
var errStr = (0, _string.combine_if_not_blank)(title, " : ", message);
|
|
658
|
+
console.error("[REGISTER-ERROR]", errStr);
|
|
659
|
+
|
|
660
|
+
_global.gfunc.run_action("add_error", {
|
|
661
|
+
title: title,
|
|
662
|
+
message: message,
|
|
663
|
+
type: "error"
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
}, {
|
|
667
|
+
key: "getErrors",
|
|
668
|
+
value: function getErrors(o) {
|
|
669
|
+
var obj = o.obj;
|
|
670
|
+
return obj != null ? _SimpleObject["default"].getErrors(o.obj) : [];
|
|
671
|
+
}
|
|
672
|
+
}, {
|
|
673
|
+
key: "clearErrors",
|
|
674
|
+
value: function clearErrors(o) {
|
|
675
|
+
return _SimpleObject["default"].clearErrors(o.obj);
|
|
676
|
+
}
|
|
677
|
+
}]);
|
|
678
|
+
|
|
679
|
+
return ObjectManager;
|
|
680
|
+
}();
|
|
681
|
+
|
|
682
|
+
exports.ObjectManager = ObjectManager;
|
|
683
|
+
var _default = ObjectManager;
|
|
684
|
+
exports["default"] = _default;
|