@duet3d/objectmodel 3.5.0-beta.20 → 3.5.0-beta.22

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.
@@ -24,15 +24,6 @@ export declare abstract class ModelObject implements IModelObject {
24
24
  * @returns Updated instance (may not equal the original instance)
25
25
  */
26
26
  update(jsonElement: any): IModelObject | null;
27
- /**
28
- * Called to check if a diverging property type may be set.
29
- * Note that this is not applicable to null values; null is always legit
30
- * @param key Property key
31
- * @param oldValue Old member value
32
- * @param newValue New member value
33
- * @returns True if the value can be set by the update call
34
- */
35
- protected checkDivergingDataType<K extends keyof this>(key: K, oldValue: typeof this[K], newValue: any): boolean;
36
27
  /**
37
28
  * Wrap a nullable model object property so that type checks can be performed
38
29
  * @param key Property key of the derived class
@@ -113,7 +113,7 @@ class ModelObject {
113
113
  if (typeof value === "boolean") {
114
114
  this[ownKey] = value;
115
115
  }
116
- else if (typeof value === "number" || this.checkDivergingDataType(ownKey, prop, value)) {
116
+ else if (typeof value === "number") {
117
117
  // RRF used to report booleans as integers so convert them if necessary
118
118
  this[ownKey] = Boolean(value);
119
119
  }
@@ -122,7 +122,7 @@ class ModelObject {
122
122
  }
123
123
  }
124
124
  else if (propType === "number") {
125
- if (typeof value === "number" || typeof value === "bigint" || this.checkDivergingDataType(ownKey, prop, value)) {
125
+ if (typeof value === "number" || typeof value === "bigint") {
126
126
  this[ownKey] = value;
127
127
  }
128
128
  else if (process.env.NODE_ENV !== "production") {
@@ -130,7 +130,7 @@ class ModelObject {
130
130
  }
131
131
  }
132
132
  else if (propType === "bigint") {
133
- if (typeof value === "number" || typeof value === "bigint" || this.checkDivergingDataType(ownKey, prop, value)) {
133
+ if (typeof value === "number" || typeof value === "bigint") {
134
134
  this[ownKey] = value;
135
135
  }
136
136
  else if (process.env.NODE_ENV !== "production") {
@@ -138,7 +138,7 @@ class ModelObject {
138
138
  }
139
139
  }
140
140
  else if (propType === "string") {
141
- if (typeof value === "string" || this.checkDivergingDataType(ownKey, prop, value)) {
141
+ if (typeof value === "string") {
142
142
  this[ownKey] = value;
143
143
  }
144
144
  else if (process.env.NODE_ENV !== "production") {
@@ -146,7 +146,7 @@ class ModelObject {
146
146
  }
147
147
  }
148
148
  else if (propType === "function") {
149
- if (typeof value === "function" || this.checkDivergingDataType(ownKey, prop, value)) {
149
+ if (typeof value === "function") {
150
150
  this[ownKey] = value;
151
151
  }
152
152
  else if (process.env.NODE_ENV !== "production") {
@@ -154,7 +154,7 @@ class ModelObject {
154
154
  }
155
155
  }
156
156
  else if (propType === "object") {
157
- if (typeof value === "object" || this.checkDivergingDataType(ownKey, prop, value)) {
157
+ if (typeof value === "object") {
158
158
  this[ownKey] = value;
159
159
  }
160
160
  else if (process.env.NODE_ENV !== "production") {
@@ -169,17 +169,6 @@ class ModelObject {
169
169
  }
170
170
  return this;
171
171
  }
172
- /**
173
- * Called to check if a diverging property type may be set.
174
- * Note that this is not applicable to null values; null is always legit
175
- * @param key Property key
176
- * @param oldValue Old member value
177
- * @param newValue New member value
178
- * @returns True if the value can be set by the update call
179
- */
180
- checkDivergingDataType(key, oldValue, newValue) {
181
- return false;
182
- }
183
172
  /**
184
173
  * Wrap a nullable model object property so that type checks can be performed
185
174
  * @param key Property key of the derived class
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * Wrapper around a standard set to make sure it serializes to an array
3
3
  */
4
- export default class ModelSet<T> extends Set<T> {
4
+ export declare class ModelSet<T> extends Set<T> {
5
5
  /**
6
6
  * Convert this object to JSON
7
7
  * @returns JSON object
8
8
  */
9
9
  toJSON(): T[];
10
10
  }
11
+ export default ModelSet;
package/dist/ModelSet.js CHANGED
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ModelSet = void 0;
3
4
  /**
4
5
  * Wrapper around a standard set to make sure it serializes to an array
5
6
  */
@@ -10,4 +11,5 @@ class ModelSet extends Set {
10
11
  */
11
12
  toJSON() { return Array.from(this); }
12
13
  }
14
+ exports.ModelSet = ModelSet;
13
15
  exports.default = ModelSet;
@@ -1,4 +1,4 @@
1
- import ModelObject from "../ModelObject";
1
+ import ModelObject, { IModelObject } from "../ModelObject";
2
2
  export declare enum MessageBoxMode {
3
3
  noButtons = 0,
4
4
  closeOnly = 1,
@@ -21,6 +21,6 @@ export declare class MessageBox extends ModelObject {
21
21
  seq: number;
22
22
  timeout: number;
23
23
  title: string;
24
- protected checkDivergingDataType<K extends keyof this>(key: K, oldValue: this[K], newValue: any): boolean;
24
+ update(jsonElement: any): IModelObject | null;
25
25
  }
26
26
  export default MessageBox;
@@ -28,8 +28,11 @@ class MessageBox extends ModelObject_1.default {
28
28
  this.timeout = 0;
29
29
  this.title = "";
30
30
  }
31
- checkDivergingDataType(key, oldValue, newValue) {
32
- return key === "default" && (typeof newValue === "number" || typeof newValue === "string");
31
+ update(jsonElement) {
32
+ if (jsonElement instanceof Object && (typeof jsonElement.default === "number" || typeof jsonElement.default === "string")) {
33
+ this.default = jsonElement;
34
+ }
35
+ return super.update(jsonElement);
33
36
  }
34
37
  }
35
38
  exports.MessageBox = MessageBox;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@duet3d/objectmodel",
3
- "version": "3.5.0-beta.20",
3
+ "version": "3.5.0-beta.22",
4
4
  "description": "TypeScript implementation of the Duet3D Object Model",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",