Repository: maxGraph/maxGraph (ts)

Issue:
Older versions of mxPoint do not decode successfully
The codec registration method is compatible with mxCell, mxGeometry, and mxGraphModel, but is not compatible with mxPoint.

  // mxGraph support
        CodecRegistry.addAlias('mxGraphModel', 'GraphDataModel');
        CodecRegistry.register(new mxCellCodec(), false);
        CodecRegistry.register(new mxGeometryCodec(), false);

Does it need to add compatibility support for mxPoint?like fellows：
// decode support for mxPoint
maxgraph.CodecRegistry.addAlias('mxPoint', 'Point');

Pull request description:
fix: import mxGraph XML including mxGeometry.offset mxPoint
Also add tests to confirm that the maxGraph format correctly import/export Geometry.offset.

Closes #356

Patch:
diff --git a/package-lock.json b/package-lock.json
index eb856e2e7..37c96db2f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -12902,9 +12902,9 @@
       }
     },
     "node_modules/follow-redirects": {
-      "version": "1.15.5",
-      "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz",
-      "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==",
+      "version": "1.15.6",
+      "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz",
+      "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==",
       "funding": [
         {
           "type": "individual",
diff --git a/packages/core/src/serialization/register.ts b/packages/core/src/serialization/register.ts
index 02e88588d..9dd7b4c8a 100644
--- a/packages/core/src/serialization/register.ts
+++ b/packages/core/src/serialization/register.ts
@@ -104,6 +104,7 @@ export const registerCoreCodecs = (force = false) => {
 
     // mxGraph support
     CodecRegistry.addAlias('mxGraphModel', 'GraphDataModel');
+    CodecRegistry.addAlias('mxPoint', 'Point');
     CodecRegistry.register(new mxCellCodec(), false);
     CodecRegistry.register(new mxGeometryCodec(), false);
 


Test patch:
diff --git a/packages/core/__tests__/serialization/serialization.xml.mxGraph.test.ts b/packages/core/__tests__/serialization/serialization.xml.mxGraph.test.ts
index 4c0929780..18829e58a 100644
--- a/packages/core/__tests__/serialization/serialization.xml.mxGraph.test.ts
+++ b/packages/core/__tests__/serialization/serialization.xml.mxGraph.test.ts
@@ -34,7 +34,9 @@ describe('import mxGraph model', () => {
       <mxGeometry x="380" y="20" width="140" height="30" as="geometry"/>
     </mxCell>
     <mxCell id="3" vertex="1" parent="1" value="Vertex #3">
-      <mxGeometry x="200" y="80" width="380" height="30" as="geometry"/>
+      <mxGeometry x="200" y="80" width="380" height="30" as="geometry">
+        <mxPoint x="1" y="1" as="offset"/>
+      </mxGeometry>
     </mxCell>
     <mxCell id="7" edge="1" source="2" target="3" parent="1" value="Edge #7">
       <mxGeometry as="geometry">
@@ -59,8 +61,10 @@ describe('import mxGraph model', () => {
       geometry: new Geometry(380, 20, 140, 30),
     });
 
+    const vertex3Geometry = new Geometry(200, 80, 380, 30);
+    vertex3Geometry.offset = new Point(1, 1);
     modelChecker.expectIsVertex(model.getCell('3'), 'Vertex #3', {
-      geometry: new Geometry(200, 80, 380, 30),
+      geometry: vertex3Geometry,
     });
 
     const edgeGeometry = new Geometry();
diff --git a/packages/core/__tests__/serialization/serialization.xml.test.ts b/packages/core/__tests__/serialization/serialization.xml.test.ts
index 1667dfe8b..f2bfa0ec4 100644
--- a/packages/core/__tests__/serialization/serialization.xml.test.ts
+++ b/packages/core/__tests__/serialization/serialization.xml.test.ts
@@ -71,6 +71,9 @@ const xmlWithVerticesAndEdges = `<GraphDataModel>
       <Object fillColor="green" strokeWidth="4" as="style" />
     </Cell>
     <Cell id="v2" value="vertex 2" vertex="1" parent="1">
+      <Geometry _x="200" _y="50" _width="30" _height="100" as="geometry">
+        <Point _x="30" _y="40" as="offset" />
+      </Geometry>
       <Object bendable="0" rounded="1" fontColor="yellow" as="style" />
     </Cell>
     <Cell id="e1" edge="1" parent="1" source="v1" target="v2">
@@ -109,6 +112,8 @@ describe('import before the export (reproduce https://github.com/maxGraph/maxGra
       },
     });
 
+    const vertexGeometry = new Geometry(200, 50, 30, 100);
+    vertexGeometry.offset = new Point(30, 40);
     modelChecker.expectIsVertex(model.getCell('v2'), 'vertex 2', {
       style: {
         // @ts-ignore FIX should be false
@@ -117,6 +122,7 @@ describe('import before the export (reproduce https://github.com/maxGraph/maxGra
         // @ts-ignore FIX should be true
         rounded: 1,
       },
+      geometry: vertexGeometry,
     });
 
     const edgeGeometry = new Geometry();
@@ -183,6 +189,7 @@ describe('export', () => {
     model.add(parent, v1);
     v1.setStyle({ fillColor: 'green', strokeWidth: 4 });
     v1.geometry = new Geometry(100, 100, 100, 80);
+    v1.geometry.offset = new Point(10, 12);
     const v2 = newVertex('v2', 'vertex 2');
     v2.style = {
       bendable: false,
@@ -213,7 +220,9 @@ describe('export', () => {
       <Object as="style" />
     </Cell>
     <Cell id="v1" value="vertex 1" vertex="1" parent="1">
-      <Geometry _x="100" _y="100" _width="100" _height="80" as="geometry" />
+      <Geometry _x="100" _y="100" _width="100" _height="80" as="geometry">
+        <Point _x="10" _y="12" as="offset" />
+      </Geometry>
       <Object fillColor="green" strokeWidth="4" as="style" />
     </Cell>
     <Cell id="v2" value="vertex 2" vertex="1" parent="1">