@azrico/webobject 1.4.154 → 1.4.156

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.
@@ -9,7 +9,7 @@ export declare class WebObjectManager<T extends WebObject> extends ObjectManager
9
9
  static readonly __save_message: boolean;
10
10
  protected __last_web_path: string;
11
11
  protected __last_web_type: string;
12
- constructor();
12
+ constructor(defaultObject?: T);
13
13
  setObject(toObj: T | undefined): boolean;
14
14
  /**
15
15
  * Update meta value of this object , meta data is stored in meta_data variable
@@ -33,10 +33,10 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
33
33
  var WebObjectManager = exports.WebObjectManager = /*#__PURE__*/function (_ObjectManager) {
34
34
  _inherits(WebObjectManager, _ObjectManager);
35
35
  /* -------------------------------------------------------------------------- */
36
- function WebObjectManager() {
36
+ function WebObjectManager(defaultObject) {
37
37
  var _this;
38
38
  _classCallCheck(this, WebObjectManager);
39
- _this = _callSuper(this, WebObjectManager);
39
+ _this = _callSuper(this, WebObjectManager, [defaultObject]);
40
40
  /* ---------------- should we display a message after saving ? -------------- */
41
41
  _defineProperty(_assertThisInitialized(_this), "__last_web_path", "");
42
42
  _defineProperty(_assertThisInitialized(_this), "__last_web_type", "");
@@ -1,5 +1,5 @@
1
1
  import { PropOf, WriteablePropOf } from "@azrico/types";
2
- import SimpleObject from "./SimpleObject";
2
+ import SimpleObject, { WithManager } from "./SimpleObject";
3
3
  import { saveResultType, sendChangesType } from "./SimpleObject";
4
4
  import { ClassType } from "@azrico/types";
5
5
  import RawObject from "./MapableObject";
@@ -14,17 +14,18 @@ export declare class ObjectManager<ObjType extends SimpleObject> extends RawObje
14
14
  protected __currentObject?: ObjType | null;
15
15
  protected __options?: object;
16
16
  __object_nullable: boolean;
17
+ constructor(defaultObject?: ObjType);
17
18
  notifyChanged(type: string, key: PropOf<ObjType> | string, value?: any, subvalue?: string): Promise<false | any[] | undefined>;
18
19
  /**
19
20
  * Get the object this manager is managing
20
21
  * @returns the object
21
22
  */
22
- get obj(): ObjType | undefined;
23
+ get obj(): WithManager<ObjType> | undefined;
23
24
  /**
24
25
  * Get the object this manager is managing
25
26
  * @returns the object
26
27
  */
27
- getObject(): ObjType | undefined;
28
+ getObject(): WithManager<ObjType> | undefined;
28
29
  /**
29
30
  * Set the object this manager is managing
30
31
  * @param toObj
@@ -35,13 +35,10 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
35
35
  */
36
36
  var ObjectManager = exports.ObjectManager = /*#__PURE__*/function (_RawObject) {
37
37
  _inherits(ObjectManager, _RawObject);
38
- function ObjectManager() {
38
+ function ObjectManager(defaultObject) {
39
39
  var _this;
40
40
  _classCallCheck(this, ObjectManager);
41
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
42
- args[_key] = arguments[_key];
43
- }
44
- _this = _callSuper(this, ObjectManager, [].concat(args));
41
+ _this = _callSuper(this, ObjectManager);
45
42
  _defineProperty(_assertThisInitialized(_this), "__eventList", {});
46
43
  _defineProperty(_assertThisInitialized(_this), "__eventPrefix", void 0);
47
44
  _defineProperty(_assertThisInitialized(_this), "__stopEvents", void 0);
@@ -50,6 +47,7 @@ var ObjectManager = exports.ObjectManager = /*#__PURE__*/function (_RawObject) {
50
47
  //can the current object be set to null safely?
51
48
  _defineProperty(_assertThisInitialized(_this), "__object_nullable", false);
52
49
  _defineProperty(_assertThisInitialized(_this), "get", _this.getValue);
50
+ _this.setObject(defaultObject);
53
51
  return _this;
54
52
  }
55
53
  _createClass(ObjectManager, [{
@@ -453,9 +451,9 @@ var ObjectManager = exports.ObjectManager = /*#__PURE__*/function (_RawObject) {
453
451
  key: "event_run",
454
452
  value: (function () {
455
453
  var _event_run = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(eventName) {
456
- var _len2,
454
+ var _len,
457
455
  params,
458
- _key2,
456
+ _key,
459
457
  _args7 = arguments;
460
458
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
461
459
  while (1) switch (_context7.prev = _context7.next) {
@@ -466,8 +464,8 @@ var ObjectManager = exports.ObjectManager = /*#__PURE__*/function (_RawObject) {
466
464
  }
467
465
  return _context7.abrupt("return");
468
466
  case 2:
469
- for (_len2 = _args7.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
470
- params[_key2 - 1] = _args7[_key2];
467
+ for (_len = _args7.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
468
+ params[_key - 1] = _args7[_key];
471
469
  }
472
470
  _context7.next = 5;
473
471
  return _event.EventManager.run.apply(_event.EventManager, [this, eventName].concat(params));
@@ -6,6 +6,7 @@ export type saveResultType = "normal" | "nothing" | "error" | "canceled";
6
6
  export type saveType = "normal" | "quick";
7
7
  export type sendChangesType = boolean | "auto";
8
8
  export type WithManager<T extends SimpleObject> = Ensure<T, "manager">;
9
+ export type WithManagerOrNot<T extends SimpleObject> = T | WithManager<T>;
9
10
  export declare class SimpleObject extends MapableObject {
10
11
  #private;
11
12
  static readonly __cache_name?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azrico/webobject",
3
- "version": "1.4.154",
3
+ "version": "1.4.156",
4
4
  "description": "Stateful object",
5
5
  "author": "Azrideus",
6
6
  "license": "MIT",