From 1bca279ec49c0a1997c57f137262a93934858990 Mon Sep 17 00:00:00 2001 From: Kostiantyn Dvornik Date: Tue, 23 Jun 2026 02:02:10 +0300 Subject: [PATCH] chore: adapt wave.js to made getBasis/getLattice API (SOF-7926) Pin @mat3ra/made and @mat3ra/code to git archive tarballs from the constraints refactor branch and replace removed Material.Basis/Lattice accessors with getBasis()/getLattice(). Co-authored-by: Cursor --- dist/components/ThreeDEditor.js | 10 +-- dist/mixins/atoms.d.ts | 5 +- dist/mixins/atoms.js | 2 +- dist/utils.js | 6 +- package-lock.json | 112 +++-------------------------- package.json | 4 +- src/components/ThreeDEditor.jsx | 10 +-- src/mixins/atoms.ts | 7 +- src/utils.js | 6 +- tests/__tests__/mixins/boundary.js | 2 +- tests/enums.js | 4 +- tests/fixtures/FeO.json | 4 +- tests/fixtures/material.json | 4 +- 13 files changed, 44 insertions(+), 132 deletions(-) diff --git a/dist/components/ThreeDEditor.js b/dist/components/ThreeDEditor.js index f59c5b73..1fae1815 100644 --- a/dist/components/ThreeDEditor.js +++ b/dist/components/ThreeDEditor.js @@ -542,7 +542,7 @@ export class ThreeDEditor extends React.Component { const isDrawBondsEnabled = this._getWaveProperty("isDrawBondsEnabled") || false; return (_jsx(WaveComponent, { ref: (el) => { this.WaveComponent = el; - }, triggerHandleResize: viewerTriggerResize, isConventionalCellShown: isConventionalCellShown, isDrawBondsEnabled: isDrawBondsEnabled, isViewAdjustable: viewerSettings.isViewAdjustable, structure: materialCopy, boundaryConditions: boundaryConditions, cell: materialCopy.Lattice.unitCell, name: materialCopy.name, settings: viewerSettings })); + }, triggerHandleResize: viewerTriggerResize, isConventionalCellShown: isConventionalCellShown, isDrawBondsEnabled: isDrawBondsEnabled, isViewAdjustable: viewerSettings.isViewAdjustable, structure: materialCopy, boundaryConditions: boundaryConditions, cell: materialCopy.getLattice().unitCell, name: materialCopy.name, settings: viewerSettings })); } // TODO: move in the toolbar component when it's created // eslint-disable-next-line class-methods-use-this @@ -613,10 +613,10 @@ export class ThreeDEditor extends React.Component { const { originalMaterial } = this.state; const { onUpdate } = this.props; // preserve lattice type - material.lattice = { - ...material.Lattice.toJSON(), - type: originalMaterial.Lattice.type, - }; + material.setLattice({ + ...material.getLattice().toJSON(), + type: originalMaterial.getLattice().type, + }); this.setState({ originalMaterial: material, material: material.clone(), diff --git a/dist/mixins/atoms.d.ts b/dist/mixins/atoms.d.ts index 4d65dbc0..287f1933 100644 --- a/dist/mixins/atoms.d.ts +++ b/dist/mixins/atoms.d.ts @@ -1,11 +1,12 @@ -import { Basis, MaterialInMemoryEntity } from "@mat3ra/made"; +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; +import { Basis, Material } from "@mat3ra/made"; import * as THREE from "three"; import { Object3D } from "three"; export declare const AtomsMixin: (superclass: any) => { new (config: any): { [x: string]: any; readonly structure: any; - setStructure(material: MaterialInMemoryEntity): void; + setStructure(material: Material & InMemoryEntity): void; readonly basis: any; initSphereParameters(): void; /** diff --git a/dist/mixins/atoms.js b/dist/mixins/atoms.js index 952e6936..7941891d 100644 --- a/dist/mixins/atoms.js +++ b/dist/mixins/atoms.js @@ -20,7 +20,7 @@ export const AtomsMixin = (superclass) => class extends superclass { } setStructure(material) { this._structure = material.clone(); // clone original structure to assert that any updates are propagated to parents - this._basis = material.Basis; + this._basis = material.getBasis(); this._basis.originalUnits = this._basis.units; this._basis.toCartesian(); this.verticesHashMap = this.createAtomVerticesHashMap(); diff --git a/dist/utils.js b/dist/utils.js index 3b992aa8..cd06920e 100644 --- a/dist/utils.js +++ b/dist/utils.js @@ -74,7 +74,7 @@ export function ThreeDSceneDataToMaterial(scene) { export function materialsToThreeDSceneData(materials, shift = [2, 0, 0]) { const wave = new Wave({ structure: materials[0], - cell: materials[0].Lattice.unitCell, + cell: materials[0].getLattice().unitCell, DOMElement: document.createElement("div"), }); if (materials.length > 1) { @@ -83,9 +83,9 @@ export function materialsToThreeDSceneData(materials, shift = [2, 0, 0]) { material.toCartesian(); const structureGroup = new THREE.Group(); structureGroup.name = material.name || material.formula; - const atomsGroup = wave.createAtomsGroup(material.Basis); + const atomsGroup = wave.createAtomsGroup(material.getBasis()); structureGroup.add(atomsGroup); - const unitCellObject = wave.getUnitCellObject(material.Lattice.unitCell); + const unitCellObject = wave.getUnitCellObject(material.getLattice().unitCell); unitCellObject.visible = false; structureGroup.add(unitCellObject); structureGroup.position.set(...shift); // slightly shift along x axis diff --git a/package-lock.json b/package-lock.json index 5cc5f9d0..e409329d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -33,9 +33,9 @@ "devDependencies": { "@exabyte-io/cove.js": "2025.2.22-0", "@exabyte-io/eslint-config": "^2025.1.15-0", - "@mat3ra/code": "2025.4.27-0", + "@mat3ra/code": "https://github.com/Exabyte-io/code/archive/62fa688445923bcb412b362e8a41b365bdbbad29.tar.gz", "@mat3ra/esse": "2025.4.22-0", - "@mat3ra/made": "2025.6.25-1", + "@mat3ra/made": "https://github.com/Exabyte-io/made/archive/bd4309ae3ea20cb5026658b6c0a8ab7b965ab076.tar.gz", "@mat3ra/tsconfig": "^2024.6.3-0", "@mat3ra/utils": "2026.5.28-4", "@types/react": "^18.2.8", @@ -2207,25 +2207,6 @@ "node": ">=6.9.0" } }, - "node_modules/@babel/runtime-corejs2": { - "version": "7.16.7", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs2/-/runtime-corejs2-7.16.7.tgz", - "integrity": "sha512-ec0BM0J/9M5Cncha++AlgvvDlk+uM+m6f7K0t74ClcYzsE8LgX4RstRreksMSCI82o3LJS//UswmA0pUWkJpqg==", - "dev": true, - "dependencies": { - "core-js": "^2.6.5", - "regenerator-runtime": "^0.13.4" - }, - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/runtime-corejs2/node_modules/regenerator-runtime": { - "version": "0.13.11", - "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz", - "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==", - "dev": true - }, "node_modules/@babel/runtime-corejs3": { "version": "7.27.0", "resolved": "https://registry.npmjs.org/@babel/runtime-corejs3/-/runtime-corejs3-7.27.0.tgz", @@ -4004,10 +3985,11 @@ "license": "MIT" }, "node_modules/@mat3ra/code": { - "version": "2025.4.27-0", - "resolved": "https://registry.npmjs.org/@mat3ra/code/-/code-2025.4.27-0.tgz", - "integrity": "sha512-v4fewXJEImCBh716z/hmI9GqU2JVl1XUYjUbvgZ3pYwxph1g1nU+H7DgRHu415t8ByJsjdLVkgkBlYU4+m/HSw==", + "version": "0.0.0", + "resolved": "https://github.com/Exabyte-io/code/archive/62fa688445923bcb412b362e8a41b365bdbbad29.tar.gz", + "integrity": "sha512-9EYHv81whrIGBiduVUrewliSgbES9dGILi9Ype77oWmPnJYNRkEIalO9bu493jsz09I0FveHCWzhFYpvkc3v5w==", "dev": true, + "license": "Apache-2.0", "dependencies": { "@types/mathjs": "^5.0.1", "crypto-js": "^4.2.0", @@ -4017,7 +3999,6 @@ "mathjs": "^5.10.3", "mixwith": "^0.1.1", "nunjucks": "^3.2.4", - "react-jsonschema-form": "^1.8.1", "semver": "^7.6.3", "underscore": "^1.13.7", "underscore.string": "^3.3.6", @@ -4412,9 +4393,9 @@ } }, "node_modules/@mat3ra/made": { - "version": "2025.6.25-1", - "resolved": "https://registry.npmjs.org/@mat3ra/made/-/made-2025.6.25-1.tgz", - "integrity": "sha512-TwBkzAuJk5MTfgEGylIMY6MFbc659mh+pTB2sDhl/QKoWebY1zLwfD091qq2k//HQ682wGGiZbgWwbsu5hnq3w==", + "version": "0.0.0", + "resolved": "https://github.com/Exabyte-io/made/archive/bd4309ae3ea20cb5026658b6c0a8ab7b965ab076.tar.gz", + "integrity": "sha512-oQanFKQEKkpX1odgxxlSj2C7I9LUYCTGukidsqNmApQ7eTJ3D9LW/qAS7J4vxxtlvlTWhB4QdIahLlRxb0obSQ==", "dev": true, "license": "Apache-2.0", "dependencies": { @@ -4437,7 +4418,8 @@ }, "peerDependencies": { "@mat3ra/code": "*", - "@mat3ra/esse": "*" + "@mat3ra/esse": "*", + "@mat3ra/utils": "*" } }, "node_modules/@mat3ra/made/node_modules/@babel/core": { @@ -9162,14 +9144,6 @@ "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.9.0.tgz", "integrity": "sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==" }, - "node_modules/core-js": { - "version": "2.6.12", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", - "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==", - "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.", - "dev": true, - "hasInstallScript": true - }, "node_modules/core-js-compat": { "version": "3.40.0", "resolved": "https://registry.npmjs.org/core-js-compat/-/core-js-compat-3.40.0.tgz", @@ -18509,54 +18483,6 @@ "react-dom": "^17.0.0 || ^16.3.0 || ^15.5.4" } }, - "node_modules/react-jsonschema-form": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/react-jsonschema-form/-/react-jsonschema-form-1.8.1.tgz", - "integrity": "sha512-aaDloxNAcGXOOOcdKOxxqEEn5oDlPUZgWcs8unXXB9vjBRgCF8rCm/wVSv1u2G5ih0j/BX6Ewd/WjI2g00lPdg==", - "deprecated": "react-jsonschema-form has been moved to @rjsf/core", - "dev": true, - "dependencies": { - "@babel/runtime-corejs2": "^7.4.5", - "ajv": "^6.7.0", - "core-js": "^2.5.7", - "lodash": "^4.17.15", - "prop-types": "^15.5.8", - "react-is": "^16.8.4", - "react-lifecycles-compat": "^3.0.4", - "shortid": "^2.2.14" - }, - "engines": { - "node": ">=6", - "npm": ">=2.14.7" - }, - "peerDependencies": { - "react": ">=15" - } - }, - "node_modules/react-jsonschema-form/node_modules/ajv": { - "version": "6.12.6", - "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", - "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", - "dev": true, - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.1", - "fast-json-stable-stringify": "^2.0.0", - "json-schema-traverse": "^0.4.1", - "uri-js": "^4.2.2" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/epoberezkin" - } - }, - "node_modules/react-jsonschema-form/node_modules/json-schema-traverse": { - "version": "0.4.1", - "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", - "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", - "dev": true, - "license": "MIT" - }, "node_modules/react-lifecycles-compat": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz", @@ -19441,22 +19367,6 @@ "node": ">=8" } }, - "node_modules/shortid": { - "version": "2.2.16", - "resolved": "https://registry.npmjs.org/shortid/-/shortid-2.2.16.tgz", - "integrity": "sha512-Ugt+GIZqvGXCIItnsL+lvFJOiN7RYqlGy7QE41O3YC1xbNSeDGIRO7xg2JJXIAj1cAGnOeC1r7/T9pgrtQbv4g==", - "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.", - "dev": true, - "dependencies": { - "nanoid": "^2.1.0" - } - }, - "node_modules/shortid/node_modules/nanoid": { - "version": "2.1.11", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-2.1.11.tgz", - "integrity": "sha512-s/snB+WGm6uwi0WjsZdaVcuf3KJXlfGl2LcxgwkEwJF0D/BWzVWAZW/XY4bFaiR7s0Jk3FPvlnepg1H1b1UwlA==", - "dev": true - }, "node_modules/side-channel": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", diff --git a/package.json b/package.json index f9a52c3b..898f80b8 100644 --- a/package.json +++ b/package.json @@ -63,9 +63,9 @@ "devDependencies": { "@exabyte-io/cove.js": "2025.2.22-0", "@exabyte-io/eslint-config": "^2025.1.15-0", - "@mat3ra/code": "2025.4.27-0", + "@mat3ra/code": "https://github.com/Exabyte-io/code/archive/62fa688445923bcb412b362e8a41b365bdbbad29.tar.gz", "@mat3ra/esse": "2025.4.22-0", - "@mat3ra/made": "2025.6.25-1", + "@mat3ra/made": "https://github.com/Exabyte-io/made/archive/bd4309ae3ea20cb5026658b6c0a8ab7b965ab076.tar.gz", "@mat3ra/tsconfig": "^2024.6.3-0", "@mat3ra/utils": "2026.5.28-4", "@types/react": "^18.2.8", diff --git a/src/components/ThreeDEditor.jsx b/src/components/ThreeDEditor.jsx index 17153cda..d449da96 100644 --- a/src/components/ThreeDEditor.jsx +++ b/src/components/ThreeDEditor.jsx @@ -431,7 +431,7 @@ export class ThreeDEditor extends React.Component { isViewAdjustable={viewerSettings.isViewAdjustable} structure={materialCopy} boundaryConditions={boundaryConditions} - cell={materialCopy.Lattice.unitCell} + cell={materialCopy.getLattice().unitCell} name={materialCopy.name} settings={viewerSettings} /> @@ -733,10 +733,10 @@ export class ThreeDEditor extends React.Component { const { originalMaterial } = this.state; const { onUpdate } = this.props; // preserve lattice type - material.lattice = { - ...material.Lattice.toJSON(), - type: originalMaterial.Lattice.type, - }; + material.setLattice({ + ...material.getLattice().toJSON(), + type: originalMaterial.getLattice().type, + }); this.setState({ originalMaterial: material, material: material.clone(), diff --git a/src/mixins/atoms.ts b/src/mixins/atoms.ts index cf4bf92c..1a75e108 100644 --- a/src/mixins/atoms.ts +++ b/src/mixins/atoms.ts @@ -1,5 +1,6 @@ +import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity"; import { AtomicCoordinateSchema } from "@mat3ra/esse/dist/js/types"; -import { Basis, MaterialInMemoryEntity } from "@mat3ra/made"; +import { Basis, Material } from "@mat3ra/made"; import * as THREE from "three"; import { Object3D } from "three"; @@ -29,9 +30,9 @@ export const AtomsMixin = (superclass: any) => return this._structure; } - setStructure(material: MaterialInMemoryEntity) { + setStructure(material: Material & InMemoryEntity) { this._structure = material.clone(); // clone original structure to assert that any updates are propagated to parents - this._basis = material.Basis; + this._basis = material.getBasis(); this._basis.originalUnits = this._basis.units; this._basis.toCartesian(); this.verticesHashMap = this.createAtomVerticesHashMap(); diff --git a/src/utils.js b/src/utils.js index 260ae806..d9f92e3a 100644 --- a/src/utils.js +++ b/src/utils.js @@ -84,7 +84,7 @@ export function ThreeDSceneDataToMaterial(scene) { export function materialsToThreeDSceneData(materials, shift = [2, 0, 0]) { const wave = new Wave({ structure: materials[0], - cell: materials[0].Lattice.unitCell, + cell: materials[0].getLattice().unitCell, DOMElement: document.createElement("div"), }); if (materials.length > 1) { @@ -93,9 +93,9 @@ export function materialsToThreeDSceneData(materials, shift = [2, 0, 0]) { material.toCartesian(); const structureGroup = new THREE.Group(); structureGroup.name = material.name || material.formula; - const atomsGroup = wave.createAtomsGroup(material.Basis); + const atomsGroup = wave.createAtomsGroup(material.getBasis()); structureGroup.add(atomsGroup); - const unitCellObject = wave.getUnitCellObject(material.Lattice.unitCell); + const unitCellObject = wave.getUnitCellObject(material.getLattice().unitCell); unitCellObject.visible = false; structureGroup.add(unitCellObject); structureGroup.position.set(...shift); // slightly shift along x axis diff --git a/tests/__tests__/mixins/boundary.js b/tests/__tests__/mixins/boundary.js index 34d76871..8a380d1f 100644 --- a/tests/__tests__/mixins/boundary.js +++ b/tests/__tests__/mixins/boundary.js @@ -9,7 +9,7 @@ class BoundaryMixinTestBase { constructor(config) { this.boundaryConditions = config.boundaryConditions || {}; const material = new Made.Material(MATERIAL_CONFIG); - this.basis = material.Basis; + this.basis = material.getBasis(); } } diff --git a/tests/enums.js b/tests/enums.js index 99bfd41d..873fbcb5 100644 --- a/tests/enums.js +++ b/tests/enums.js @@ -32,7 +32,7 @@ export function getWaveInstance(settings, material = new Made.Material(MATERIAL_ return new Wave({ DOMElement: createElement("div", ELEMENT_PROPERTIES), structure: material, - cell: material.Lattice.unitCell, + cell: material.getLattice().unitCell, settings: settings || WAVE_SETTINGS, }); } @@ -41,7 +41,7 @@ export function getFeOWaveInstance(settings, material = new Made.Material(FeO_CO return new Wave({ DOMElement: createElement("div", ELEMENT_PROPERTIES), structure: material, - cell: material.Lattice.unitCell, + cell: material.getLattice().unitCell, settings: settings || WAVE_SETTINGS, }); } diff --git a/tests/fixtures/FeO.json b/tests/fixtures/FeO.json index 675e398b..66e173e0 100644 --- a/tests/fixtures/FeO.json +++ b/tests/fixtures/FeO.json @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b79fba6f0f40957225817e45ad0a9a86eaa60bdd2155e2fc1d115ac3259569f8 -size 1737 +oid sha256:b1aee2569da267d4803f655e87bf7e59709e3d45ca873af4645c2a9da6d18fe0 +size 1785 diff --git a/tests/fixtures/material.json b/tests/fixtures/material.json index d586af35..d8f47fe7 100644 --- a/tests/fixtures/material.json +++ b/tests/fixtures/material.json @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3b6350bd9576ef522c2b879db2eceff36c7ce43b4d13ba5a1425713b74850f21 -size 769 +oid sha256:7ad56cab981da286f4ee754a851ce520c89aabcb0cb7912b9cdfc81db0a11074 +size 817