Skip to content

Commit df5b074

Browse files
committed
Version 3.7.0-beta.6
Removed the Vue 2 compatibility work-arounds and the exported setArrayItem function
1 parent 037e3a9 commit df5b074

5 files changed

Lines changed: 9 additions & 27 deletions

File tree

README.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,7 @@ TypeScript implementation of the Duet3D Object Model.
44

55
## Installation
66

7-
Install via `npm install @duet3d/objectmodel`. Users of Vue 2 must also run this command after the first import:
8-
9-
```
10-
globalThis._duetModelSetArray = (array, index, value) => Vue.set(array, index, value);
11-
```
12-
13-
This is required to make sure that change events for arrays are correctly fired.
7+
Install via `npm install @duet3d/objectmodel`.
148

159
## Bug reports
1610

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@duet3d/objectmodel",
3-
"version": "3.7.0-beta.5",
3+
"version": "3.7.0-beta.6",
44
"description": "TypeScript implementation of the Duet3D Object Model",
55
"type": "module",
66
"main": "dist/index.js",

src/ModelCollection.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { isModelObject } from "./ModelObject";
22
import type { IModelObject } from "./ModelObject";
3-
import { setArrayItem } from "./index";
43

54
/**
65
* Internal interface for the model collection class
@@ -67,20 +66,20 @@ export class ModelCollection<T extends IModelObject | null> extends Array<T> imp
6766
if (currentItem === null) {
6867
const newItem = jsonElement[i];
6968
if (newItem instanceof that.$itemConstructor) {
70-
setArrayItem(this, i, jsonElement[i]);
69+
this[i] = jsonElement[i];
7170
} else {
7271
const refItem = new that.$itemConstructor();
73-
setArrayItem(this, i, refItem!.update(newItem));
72+
this[i] = refItem!.update(newItem) as T;
7473
}
7574
} else if (isModelObject(currentItem)) {
7675
const newItem = currentItem.update(jsonElement[i]);
7776
if (currentItem !== newItem) {
78-
setArrayItem(this, i, newItem);
77+
this[i] = newItem as T;
7978
}
8079
} else {
8180
const newItem = jsonElement[i];
8281
if (currentItem !== newItem) {
83-
setArrayItem(this, i, newItem);
82+
this[i] = newItem;
8483
}
8584
}
8685
}

src/ModelObject.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ModelCollection, setArrayItem } from "./index";
1+
import { ModelCollection } from "./index";
22

33
/**
44
* Interface for updating model objects using JSON data
@@ -63,11 +63,11 @@ export abstract class ModelObject implements IModelObject {
6363
for (let i = 0; i < Math.min(prop.length, value.length); i++) {
6464
const propItem = prop[i];
6565
if (propItem === null) {
66-
setArrayItem(prop, i, value[i]);
66+
prop[i] = value[i];
6767
} else {
6868
const newItem = value[i];
6969
if (propItem !== newItem) {
70-
setArrayItem(prop, i, newItem);
70+
prop[i] = newItem;
7171
}
7272
}
7373
}

src/index.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,3 @@ export * from "./ObjectModel";
2828
// Expose ObjectModel as default export
2929
import ObjectModel from "./ObjectModel";
3030
export default ObjectModel;
31-
32-
// Unfortunately we need to define a way to update arrays to remain compatible with Vue 2 (due to IE11).
33-
// This will become obsolete as soon as DWC is upgraded to Vue 3, but that isn't going to happen anytime soon.
34-
// Until then a Vue 2 user would have to call something like this on initialization to work around this limitation:
35-
// globalThis._duetModelSetArray = (array, index, value) => Vue.set(array, index, value);
36-
// or in TypeScript
37-
// (globalThis as any)._duetModelSetArray = (array: object, index: string | number, value: any) => Vue.set(array, index, value);
38-
(globalThis as any)._duetModelSetArray = (array: Array<any>, index: number, value: any) => array[index] = value;
39-
export function setArrayItem(array: Array<any>, index: number, value: any) {
40-
(globalThis as any)._duetModelSetArray(array, index, value);
41-
}

0 commit comments

Comments
 (0)