@azrico/webobject 1.4.7 → 1.4.8

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