@azrico/webobject 1.2.16 → 1.2.18
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 +1 -18
- package/dist/src/WebObjects/ParentWebObject.js +13 -94
- package/dist/src/WebObjects/WebObject.js +220 -740
- package/dist/src/WebObjects/WebObjectManager.js +74 -351
- package/dist/src/index.js +8 -109
- package/dist/src/structs/DummyObject.js +8 -54
- package/dist/src/structs/MapableObject.js +72 -141
- package/dist/src/structs/MetaObject.js +35 -171
- package/dist/src/structs/ObjectArray.js +43 -84
- package/dist/src/structs/ObjectManager.d.ts +1 -0
- package/dist/src/structs/ObjectManager.js +202 -652
- package/dist/src/structs/SimpleObject.d.ts +2 -0
- package/dist/src/structs/SimpleObject.js +580 -989
- package/package.json +1 -1
|
@@ -1,67 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = exports.WebObjectManager = void 0;
|
|
7
|
-
|
|
8
|
-
var _ObjectManager2 = _interopRequireDefault(require("../structs/ObjectManager"));
|
|
9
|
-
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
-
|
|
12
|
-
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); }
|
|
13
|
-
|
|
14
|
-
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; }
|
|
15
|
-
|
|
16
|
-
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); } }
|
|
17
|
-
|
|
18
|
-
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); }); }; }
|
|
19
|
-
|
|
20
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
21
|
-
|
|
22
|
-
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); } }
|
|
23
|
-
|
|
24
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
25
|
-
|
|
26
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
27
|
-
|
|
28
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
29
|
-
|
|
30
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
31
|
-
|
|
32
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
33
|
-
|
|
34
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
35
|
-
|
|
36
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
37
|
-
|
|
38
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
39
|
-
|
|
1
|
+
import ObjectManager from "../structs/ObjectManager";
|
|
40
2
|
/**
|
|
41
3
|
* This class manages the events of an Simple Object
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
function WebObjectManager() {
|
|
49
|
-
_classCallCheck(this, WebObjectManager);
|
|
50
|
-
|
|
51
|
-
return _super.apply(this, arguments);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
_createClass(WebObjectManager, [{
|
|
55
|
-
key: "setMetaValue",
|
|
56
|
-
value:
|
|
57
|
-
/* -------------------------------------------------------------------------- */
|
|
58
|
-
|
|
59
|
-
/* -------------------------------------------------------------------------- */
|
|
60
|
-
|
|
61
|
-
/* Meta data */
|
|
62
|
-
|
|
63
|
-
/* -------------------------------------------------------------------------- */
|
|
64
|
-
|
|
4
|
+
*/
|
|
5
|
+
export class WebObjectManager extends ObjectManager {
|
|
6
|
+
/* -------------------------------------------------------------------------- */
|
|
7
|
+
/* -------------------------------------------------------------------------- */
|
|
8
|
+
/* Meta data */
|
|
9
|
+
/* -------------------------------------------------------------------------- */
|
|
65
10
|
/**
|
|
66
11
|
* Update meta value of this object , meta data is stored in meta_data variable
|
|
67
12
|
* @param key
|
|
@@ -69,304 +14,82 @@ var WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
|
|
|
69
14
|
* @param createIfNotExists should we create a new meta if key does not exist
|
|
70
15
|
* @param sendChange
|
|
71
16
|
* @returns
|
|
72
|
-
*/
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
/*
|
|
95
|
-
|
|
96
|
-
}, {
|
|
97
|
-
key: "get_deltaObject",
|
|
98
|
-
value: function () {
|
|
99
|
-
var _get_deltaObject = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
100
|
-
var _this$obj4;
|
|
101
|
-
|
|
102
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
103
|
-
while (1) {
|
|
104
|
-
switch (_context.prev = _context.next) {
|
|
105
|
-
case 0:
|
|
106
|
-
_context.next = 2;
|
|
107
|
-
return (_this$obj4 = this.obj) === null || _this$obj4 === void 0 ? void 0 : _this$obj4.get_deltaObject();
|
|
108
|
-
|
|
109
|
-
case 2:
|
|
110
|
-
_context.t0 = _context.sent;
|
|
111
|
-
|
|
112
|
-
if (_context.t0) {
|
|
113
|
-
_context.next = 5;
|
|
114
|
-
break;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
_context.t0 = {};
|
|
118
|
-
|
|
119
|
-
case 5:
|
|
120
|
-
return _context.abrupt("return", _context.t0);
|
|
121
|
-
|
|
122
|
-
case 6:
|
|
123
|
-
case "end":
|
|
124
|
-
return _context.stop();
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}, _callee, this);
|
|
128
|
-
}));
|
|
129
|
-
|
|
130
|
-
function get_deltaObject() {
|
|
131
|
-
return _get_deltaObject.apply(this, arguments);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
return get_deltaObject;
|
|
135
|
-
}()
|
|
136
|
-
/* ------------------------------ save and load ----------------------------- */
|
|
137
|
-
|
|
138
|
-
}, {
|
|
139
|
-
key: "Save",
|
|
140
|
-
value: function () {
|
|
141
|
-
var _Save = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
142
|
-
var _this$obj5;
|
|
143
|
-
|
|
144
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
145
|
-
while (1) {
|
|
146
|
-
switch (_context2.prev = _context2.next) {
|
|
147
|
-
case 0:
|
|
148
|
-
_context2.next = 2;
|
|
149
|
-
return (_this$obj5 = this.obj) === null || _this$obj5 === void 0 ? void 0 : _this$obj5.Save();
|
|
150
|
-
|
|
151
|
-
case 2:
|
|
152
|
-
_context2.t0 = _context2.sent;
|
|
153
|
-
|
|
154
|
-
if (_context2.t0) {
|
|
155
|
-
_context2.next = 5;
|
|
156
|
-
break;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
_context2.t0 = false;
|
|
160
|
-
|
|
161
|
-
case 5:
|
|
162
|
-
return _context2.abrupt("return", _context2.t0);
|
|
163
|
-
|
|
164
|
-
case 6:
|
|
165
|
-
case "end":
|
|
166
|
-
return _context2.stop();
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}, _callee2, this);
|
|
170
|
-
}));
|
|
171
|
-
|
|
172
|
-
function Save() {
|
|
173
|
-
return _Save.apply(this, arguments);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
return Save;
|
|
177
|
-
}()
|
|
178
|
-
}, {
|
|
179
|
-
key: "Load",
|
|
180
|
-
value: function () {
|
|
181
|
-
var _Load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(search) {
|
|
182
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
183
|
-
while (1) {
|
|
184
|
-
switch (_context3.prev = _context3.next) {
|
|
185
|
-
case 0:
|
|
186
|
-
throw Error("load not implented");
|
|
187
|
-
|
|
188
|
-
case 1:
|
|
189
|
-
case "end":
|
|
190
|
-
return _context3.stop();
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}, _callee3);
|
|
194
|
-
}));
|
|
195
|
-
|
|
196
|
-
function Load(_x) {
|
|
197
|
-
return _Load.apply(this, arguments);
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
return Load;
|
|
201
|
-
}()
|
|
202
|
-
/* -------------------------------------------------------------------------- */
|
|
203
|
-
|
|
204
|
-
/* Default Events */
|
|
205
|
-
|
|
206
|
-
/* -------------------------------------------------------------------------- */
|
|
207
|
-
|
|
17
|
+
*/
|
|
18
|
+
setMetaValue(key, value, createIfNotExists = true, sendChange = "auto") {
|
|
19
|
+
return this.obj?.setMetaValue(key, value, createIfNotExists, sendChange);
|
|
20
|
+
}
|
|
21
|
+
getMeta(key) {
|
|
22
|
+
return this.obj?.getMeta(key);
|
|
23
|
+
}
|
|
24
|
+
getMetaValue(key) {
|
|
25
|
+
return this.obj?.getMetaValue(key);
|
|
26
|
+
}
|
|
27
|
+
/* -------------------------------------------------------------------------- */
|
|
28
|
+
async get_deltaObject() {
|
|
29
|
+
return (await this.obj?.get_deltaObject()) || {};
|
|
30
|
+
}
|
|
31
|
+
/* ------------------------------ save and load ----------------------------- */
|
|
32
|
+
async Save() {
|
|
33
|
+
return (await this.obj?.Save()) || false;
|
|
34
|
+
}
|
|
35
|
+
async Load(search, ...p) {
|
|
36
|
+
throw Error("load not implented");
|
|
37
|
+
}
|
|
38
|
+
/* -------------------------------------------------------------------------- */
|
|
39
|
+
/* Default Events */
|
|
40
|
+
/* -------------------------------------------------------------------------- */
|
|
208
41
|
/**
|
|
209
42
|
* Use this when you load new Object
|
|
210
43
|
* @param p
|
|
211
44
|
* @returns
|
|
212
|
-
*/
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
while (1) {
|
|
222
|
-
switch (_context4.prev = _context4.next) {
|
|
223
|
-
case 0:
|
|
224
|
-
if (this.canModify) {
|
|
225
|
-
(_this$obj6 = this.obj) === null || _this$obj6 === void 0 ? void 0 : _this$obj6.setOriginal();
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
_context4.next = 3;
|
|
229
|
-
return this.event_run("on_new");
|
|
230
|
-
|
|
231
|
-
case 3:
|
|
232
|
-
_context4.next = 5;
|
|
233
|
-
return this.event_run("on_change", true);
|
|
234
|
-
|
|
235
|
-
case 5:
|
|
236
|
-
_context4.next = 7;
|
|
237
|
-
return Promise.resolve(true);
|
|
238
|
-
|
|
239
|
-
case 7:
|
|
240
|
-
return _context4.abrupt("return", _context4.sent);
|
|
241
|
-
|
|
242
|
-
case 8:
|
|
243
|
-
case "end":
|
|
244
|
-
return _context4.stop();
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}, _callee4, this);
|
|
248
|
-
}));
|
|
249
|
-
|
|
250
|
-
function onNew() {
|
|
251
|
-
return _onNew.apply(this, arguments);
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
return onNew;
|
|
255
|
-
}()
|
|
45
|
+
*/
|
|
46
|
+
async onNew(...p) {
|
|
47
|
+
if (this.canModify) {
|
|
48
|
+
this.obj?.setOriginal();
|
|
49
|
+
}
|
|
50
|
+
await this.event_run("on_new");
|
|
51
|
+
await this.event_run("on_change", true);
|
|
52
|
+
return await Promise.resolve(true);
|
|
53
|
+
}
|
|
256
54
|
/**
|
|
257
55
|
* Use this when you load data to the object
|
|
258
56
|
* @param p
|
|
259
57
|
* @returns
|
|
260
|
-
*/
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
while (1) {
|
|
270
|
-
switch (_context5.prev = _context5.next) {
|
|
271
|
-
case 0:
|
|
272
|
-
if (this.canModify) {
|
|
273
|
-
(_this$obj7 = this.obj) === null || _this$obj7 === void 0 ? void 0 : _this$obj7.setOriginal();
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
_context5.next = 3;
|
|
277
|
-
return this.event_run("on_load");
|
|
278
|
-
|
|
279
|
-
case 3:
|
|
280
|
-
_context5.next = 5;
|
|
281
|
-
return this.event_run("on_change", true);
|
|
282
|
-
|
|
283
|
-
case 5:
|
|
284
|
-
_context5.next = 7;
|
|
285
|
-
return Promise.resolve(true);
|
|
286
|
-
|
|
287
|
-
case 7:
|
|
288
|
-
return _context5.abrupt("return", _context5.sent);
|
|
289
|
-
|
|
290
|
-
case 8:
|
|
291
|
-
case "end":
|
|
292
|
-
return _context5.stop();
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
}, _callee5, this);
|
|
296
|
-
}));
|
|
297
|
-
|
|
298
|
-
function onLoad() {
|
|
299
|
-
return _onLoad.apply(this, arguments);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
return onLoad;
|
|
303
|
-
}()
|
|
58
|
+
*/
|
|
59
|
+
async onLoad(...p) {
|
|
60
|
+
if (this.canModify) {
|
|
61
|
+
this.obj?.setOriginal();
|
|
62
|
+
}
|
|
63
|
+
await this.event_run("on_load");
|
|
64
|
+
await this.event_run("on_change", true);
|
|
65
|
+
return await Promise.resolve(true);
|
|
66
|
+
}
|
|
304
67
|
/**
|
|
305
68
|
* Use this after succesful save to Database
|
|
306
69
|
* @param p
|
|
307
70
|
* @returns
|
|
308
|
-
*/
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
} //this.loadValues(srObject);
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
_context6.next = 3;
|
|
338
|
-
return this.event_run("on_save");
|
|
339
|
-
|
|
340
|
-
case 3:
|
|
341
|
-
_context6.next = 5;
|
|
342
|
-
return this.event_run("on_change", true);
|
|
343
|
-
|
|
344
|
-
case 5:
|
|
345
|
-
_context6.next = 7;
|
|
346
|
-
return Promise.resolve(true);
|
|
347
|
-
|
|
348
|
-
case 7:
|
|
349
|
-
return _context6.abrupt("return", _context6.sent);
|
|
350
|
-
|
|
351
|
-
case 8:
|
|
352
|
-
case "end":
|
|
353
|
-
return _context6.stop();
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
}, _callee6, this);
|
|
357
|
-
}));
|
|
358
|
-
|
|
359
|
-
function onSave() {
|
|
360
|
-
return _onSave.apply(this, arguments);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
return onSave;
|
|
364
|
-
}()
|
|
365
|
-
}]);
|
|
366
|
-
|
|
367
|
-
return WebObjectManager;
|
|
368
|
-
}(_ObjectManager2["default"]);
|
|
369
|
-
|
|
370
|
-
exports.WebObjectManager = WebObjectManager;
|
|
371
|
-
var _default = WebObjectManager;
|
|
372
|
-
exports["default"] = _default;
|
|
71
|
+
*/
|
|
72
|
+
async onSave(...p) {
|
|
73
|
+
if (this.isSaved && this.obj) {
|
|
74
|
+
this.apply_changes();
|
|
75
|
+
var srObject = this.obj.getSaveResult();
|
|
76
|
+
if (srObject != null && typeof srObject === "object") {
|
|
77
|
+
if (srObject.insertedId) {
|
|
78
|
+
this.obj._id = srObject.insertedId;
|
|
79
|
+
}
|
|
80
|
+
else if (srObject._id) {
|
|
81
|
+
this.obj._id = srObject._id;
|
|
82
|
+
}
|
|
83
|
+
if (srObject._index_value &&
|
|
84
|
+
!Number.isNaN(srObject._index_value)) {
|
|
85
|
+
this.obj._index_value = Number(srObject._index_value);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//this.loadValues(srObject);
|
|
89
|
+
}
|
|
90
|
+
await this.event_run("on_save");
|
|
91
|
+
await this.event_run("on_change", true);
|
|
92
|
+
return await Promise.resolve(true);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
export default WebObjectManager;
|
package/dist/src/index.js
CHANGED
|
@@ -1,109 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Object.keys(_SimpleObject).forEach(function (key) {
|
|
10
|
-
if (key === "default" || key === "__esModule") return;
|
|
11
|
-
if (key in exports && exports[key] === _SimpleObject[key]) return;
|
|
12
|
-
Object.defineProperty(exports, key, {
|
|
13
|
-
enumerable: true,
|
|
14
|
-
get: function get() {
|
|
15
|
-
return _SimpleObject[key];
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
var _ObjectArray = require("./structs/ObjectArray");
|
|
21
|
-
|
|
22
|
-
Object.keys(_ObjectArray).forEach(function (key) {
|
|
23
|
-
if (key === "default" || key === "__esModule") return;
|
|
24
|
-
if (key in exports && exports[key] === _ObjectArray[key]) return;
|
|
25
|
-
Object.defineProperty(exports, key, {
|
|
26
|
-
enumerable: true,
|
|
27
|
-
get: function get() {
|
|
28
|
-
return _ObjectArray[key];
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
var _MapableObject = require("./structs/MapableObject");
|
|
34
|
-
|
|
35
|
-
Object.keys(_MapableObject).forEach(function (key) {
|
|
36
|
-
if (key === "default" || key === "__esModule") return;
|
|
37
|
-
if (key in exports && exports[key] === _MapableObject[key]) return;
|
|
38
|
-
Object.defineProperty(exports, key, {
|
|
39
|
-
enumerable: true,
|
|
40
|
-
get: function get() {
|
|
41
|
-
return _MapableObject[key];
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
var _MetaObject = require("./structs/MetaObject");
|
|
47
|
-
|
|
48
|
-
Object.keys(_MetaObject).forEach(function (key) {
|
|
49
|
-
if (key === "default" || key === "__esModule") return;
|
|
50
|
-
if (key in exports && exports[key] === _MetaObject[key]) return;
|
|
51
|
-
Object.defineProperty(exports, key, {
|
|
52
|
-
enumerable: true,
|
|
53
|
-
get: function get() {
|
|
54
|
-
return _MetaObject[key];
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
var _DummyObject = require("./structs/DummyObject");
|
|
60
|
-
|
|
61
|
-
Object.keys(_DummyObject).forEach(function (key) {
|
|
62
|
-
if (key === "default" || key === "__esModule") return;
|
|
63
|
-
if (key in exports && exports[key] === _DummyObject[key]) return;
|
|
64
|
-
Object.defineProperty(exports, key, {
|
|
65
|
-
enumerable: true,
|
|
66
|
-
get: function get() {
|
|
67
|
-
return _DummyObject[key];
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
var _ObjectManager = require("./structs/ObjectManager");
|
|
73
|
-
|
|
74
|
-
Object.keys(_ObjectManager).forEach(function (key) {
|
|
75
|
-
if (key === "default" || key === "__esModule") return;
|
|
76
|
-
if (key in exports && exports[key] === _ObjectManager[key]) return;
|
|
77
|
-
Object.defineProperty(exports, key, {
|
|
78
|
-
enumerable: true,
|
|
79
|
-
get: function get() {
|
|
80
|
-
return _ObjectManager[key];
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
var _WebObjectManager = require("./WebObjects/WebObjectManager");
|
|
86
|
-
|
|
87
|
-
Object.keys(_WebObjectManager).forEach(function (key) {
|
|
88
|
-
if (key === "default" || key === "__esModule") return;
|
|
89
|
-
if (key in exports && exports[key] === _WebObjectManager[key]) return;
|
|
90
|
-
Object.defineProperty(exports, key, {
|
|
91
|
-
enumerable: true,
|
|
92
|
-
get: function get() {
|
|
93
|
-
return _WebObjectManager[key];
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
var _WebObject = require("./WebObjects/WebObject");
|
|
99
|
-
|
|
100
|
-
Object.keys(_WebObject).forEach(function (key) {
|
|
101
|
-
if (key === "default" || key === "__esModule") return;
|
|
102
|
-
if (key in exports && exports[key] === _WebObject[key]) return;
|
|
103
|
-
Object.defineProperty(exports, key, {
|
|
104
|
-
enumerable: true,
|
|
105
|
-
get: function get() {
|
|
106
|
-
return _WebObject[key];
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
});
|
|
1
|
+
export * from "./structs/SimpleObject";
|
|
2
|
+
export * from "./structs/ObjectArray";
|
|
3
|
+
export * from "./structs/MapableObject";
|
|
4
|
+
export * from "./structs/MetaObject";
|
|
5
|
+
export * from "./structs/DummyObject";
|
|
6
|
+
export * from "./structs/ObjectManager";
|
|
7
|
+
export * from "./WebObjects/WebObjectManager";
|
|
8
|
+
export * from "./WebObjects/WebObject";
|
|
@@ -1,54 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _SimpleObject2 = require("./SimpleObject");
|
|
11
|
-
|
|
12
|
-
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); } }
|
|
13
|
-
|
|
14
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
15
|
-
|
|
16
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
|
-
|
|
18
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
19
|
-
|
|
20
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
21
|
-
|
|
22
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
23
|
-
|
|
24
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
25
|
-
|
|
26
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
27
|
-
|
|
28
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
29
|
-
|
|
30
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
31
|
-
|
|
32
|
-
var DummyObject = /*#__PURE__*/function (_SimpleObject) {
|
|
33
|
-
_inherits(DummyObject, _SimpleObject);
|
|
34
|
-
|
|
35
|
-
var _super = _createSuper(DummyObject);
|
|
36
|
-
|
|
37
|
-
function DummyObject(initObject) {
|
|
38
|
-
var _this;
|
|
39
|
-
|
|
40
|
-
_classCallCheck(this, DummyObject);
|
|
41
|
-
|
|
42
|
-
_this = _super.call(this, false);
|
|
43
|
-
|
|
44
|
-
_this.loadValues(initObject, true);
|
|
45
|
-
|
|
46
|
-
return _this;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return _createClass(DummyObject);
|
|
50
|
-
}(_SimpleObject2.SimpleObject);
|
|
51
|
-
|
|
52
|
-
exports.DummyObject = DummyObject;
|
|
53
|
-
var _default = DummyObject;
|
|
54
|
-
exports["default"] = _default;
|
|
1
|
+
import { SimpleObject } from "./SimpleObject";
|
|
2
|
+
export class DummyObject extends SimpleObject {
|
|
3
|
+
constructor(initObject) {
|
|
4
|
+
super(false);
|
|
5
|
+
this.loadValues(initObject, true);
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export default DummyObject;
|