@duet3d/objectmodel 3.4.0-b14 → 3.4.0-b17
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/ModelCollection.js +8 -1
- package/dist/ModelObject.js +21 -1
- package/dist/move/DriverId.js +1 -0
- package/package.json +32 -30
package/dist/ModelCollection.js
CHANGED
|
@@ -72,7 +72,14 @@ class ModelCollection extends Array {
|
|
|
72
72
|
}
|
|
73
73
|
// Add new items
|
|
74
74
|
for (let i = this.length; i < jsonElement.length; i++) {
|
|
75
|
-
|
|
75
|
+
const itemToAdd = jsonElement[i];
|
|
76
|
+
if (itemToAdd === null) {
|
|
77
|
+
super.push(itemToAdd);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
const newItem = new this.itemConstructor();
|
|
81
|
+
super.push(newItem.update(itemToAdd));
|
|
82
|
+
}
|
|
76
83
|
}
|
|
77
84
|
return this;
|
|
78
85
|
}
|
package/dist/ModelObject.js
CHANGED
|
@@ -43,6 +43,9 @@ class ModelObject {
|
|
|
43
43
|
console.warn(`Model object ${key} changed but it could not be set due to missing setter`);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
+
else if (process.env.NODE_ENV !== "production") {
|
|
47
|
+
console.warn(`Model object ${key} changed but it lacks the property descriptor`);
|
|
48
|
+
}
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
else if (prop instanceof Array) {
|
|
@@ -184,7 +187,24 @@ function initObject(itemType, data) {
|
|
|
184
187
|
for (let key in data) {
|
|
185
188
|
const resultKey = result[key];
|
|
186
189
|
if (isModelObject(resultKey)) {
|
|
187
|
-
resultKey.update(data[key]);
|
|
190
|
+
const updatedObject = resultKey.update(data[key]);
|
|
191
|
+
if (resultKey !== updatedObject) {
|
|
192
|
+
const propDescriptor = Object.getOwnPropertyDescriptor(result, key);
|
|
193
|
+
if (propDescriptor !== undefined) {
|
|
194
|
+
if (propDescriptor.writable) {
|
|
195
|
+
result[key] = updatedObject;
|
|
196
|
+
}
|
|
197
|
+
else if (propDescriptor.set !== undefined) {
|
|
198
|
+
propDescriptor.set(updatedObject);
|
|
199
|
+
}
|
|
200
|
+
else if (process.env.NODE_ENV !== "production") {
|
|
201
|
+
console.warn(`Model object ${key} changed but it could not be set due to missing setter`);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
else if (process.env.NODE_ENV !== "production") {
|
|
205
|
+
console.warn(`Model object ${key} changed but it lacks the property descriptor`);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
188
208
|
}
|
|
189
209
|
else {
|
|
190
210
|
result[key] = data[key];
|
package/dist/move/DriverId.js
CHANGED
|
@@ -19,6 +19,7 @@ class DriverId extends ModelObject_1.default {
|
|
|
19
19
|
if (isDriverId(jsonElement)) {
|
|
20
20
|
this.board = jsonElement.board;
|
|
21
21
|
this.driver = jsonElement.driver;
|
|
22
|
+
return this;
|
|
22
23
|
}
|
|
23
24
|
if (typeof jsonElement === "string") {
|
|
24
25
|
const matches = /(\d+)\.(\d+)/.exec(jsonElement);
|
package/package.json
CHANGED
|
@@ -1,30 +1,32 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@duet3d/objectmodel",
|
|
3
|
-
"version": "3.4.0-
|
|
4
|
-
"description": "TypeScript implementation of the Duet3D Object Model",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"test": "jest --config jestconfig.json",
|
|
9
|
-
"build": "tsc",
|
|
10
|
-
"prepare"
|
|
11
|
-
"prepublishOnly"
|
|
12
|
-
},
|
|
13
|
-
"repository": {
|
|
14
|
-
"type": "git",
|
|
15
|
-
"url": "git+https://github.com/Duet3D/ObjectModel.git"
|
|
16
|
-
},
|
|
17
|
-
"author": "Christian Hammacher",
|
|
18
|
-
"license": "LGPL-2.1",
|
|
19
|
-
"bugs": {
|
|
20
|
-
"url": "https://github.com/Duet3D/ObjectModel/issues"
|
|
21
|
-
},
|
|
22
|
-
"homepage": "https://github.com/Duet3D/ObjectModel#readme",
|
|
23
|
-
"devDependencies": {
|
|
24
|
-
"@types/jest": "^27.0
|
|
25
|
-
"jest": "^27.
|
|
26
|
-
"ts-jest": "^27.1.
|
|
27
|
-
"typescript": "^4.
|
|
28
|
-
},
|
|
29
|
-
"files": [
|
|
30
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@duet3d/objectmodel",
|
|
3
|
+
"version": "3.4.0-b17",
|
|
4
|
+
"description": "TypeScript implementation of the Duet3D Object Model",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "jest --config jestconfig.json",
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"prepare": "npm run build",
|
|
11
|
+
"prepublishOnly": "npm test"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/Duet3D/ObjectModel.git"
|
|
16
|
+
},
|
|
17
|
+
"author": "Christian Hammacher",
|
|
18
|
+
"license": "LGPL-2.1",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/Duet3D/ObjectModel/issues"
|
|
21
|
+
},
|
|
22
|
+
"homepage": "https://github.com/Duet3D/ObjectModel#readme",
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/jest": "^27.5.0",
|
|
25
|
+
"jest": "^27.5.1",
|
|
26
|
+
"ts-jest": "^27.1.4",
|
|
27
|
+
"typescript": "^4.6.4"
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"/dist"
|
|
31
|
+
]
|
|
32
|
+
}
|