@visactor/vrender-core 0.19.17 → 0.19.19-alpha.0
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/cjs/graphic/graphic-service/graphic-service.js +4 -4
- package/cjs/graphic/graphic-service/graphic-service.js.map +1 -1
- package/cjs/plugins/builtin-plugin/react-attribute-plugin.d.ts +2 -1
- package/cjs/plugins/builtin-plugin/react-attribute-plugin.js +15 -7
- package/cjs/plugins/builtin-plugin/react-attribute-plugin.js.map +1 -1
- package/dist/index.es.js +36 -10
- package/es/graphic/graphic-service/graphic-service.js +4 -4
- package/es/graphic/graphic-service/graphic-service.js.map +1 -1
- package/es/plugins/builtin-plugin/react-attribute-plugin.d.ts +2 -1
- package/es/plugins/builtin-plugin/react-attribute-plugin.js +15 -7
- package/es/plugins/builtin-plugin/react-attribute-plugin.js.map +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugins/builtin-plugin/react-attribute-plugin.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AAEnD,mDAAgD;AAChD,mEAA8D;AAC9D,6CAAyC;AAEzC,MAAa,oBAAqB,SAAQ,2CAAmB;IAA7D;;QACE,SAAI,GAA2B,sBAAsB,CAAC;QACtD,gBAAW,GAAiB,YAAY,CAAC;QAEzC,SAAI,GAAW,qBAAS,CAAC,kBAAkB,EAAE,CAAC;QAC9C,QAAG,GAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAEpC,YAAO,
|
|
1
|
+
{"version":3,"sources":["../src/plugins/builtin-plugin/react-attribute-plugin.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AAEnD,mDAAgD;AAChD,mEAA8D;AAC9D,6CAAyC;AAEzC,MAAa,oBAAqB,SAAQ,2CAAmB;IAA7D;;QACE,SAAI,GAA2B,sBAAsB,CAAC;QACtD,gBAAW,GAAiB,YAAY,CAAC;QAEzC,SAAI,GAAW,q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QAAQ;wBACvB,OAAO,EAAE,GAAG,EAAE;4BACZ,QAAQ,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC;wBACjD,CAAC;qBACF,CAAC;iBACH;aACF;SACF;aAAM;YAEL,IAAI,QAAQ,CAAC,UAAU,EAAE;gBACvB,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;aACvC;iBAAM;gBACL,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC;aAC1D;SACF;QAED,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE;YACtC,OAAO;SACR;QAED,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAE5D,IAAI,CAAC,0BAA0B,CAAC,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,KAAK,CAAC,CAAC;QACvF,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAC5C,CAAC;CACF;AAzGD,oDAyGC","file":"react-attribute-plugin.js","sourcesContent":["import { Generator } from '../../common/generator';\nimport type { IGraphic, IPlugin, IPluginService } from '../../interface';\nimport { application } from '../../application';\nimport { HtmlAttributePlugin } from './html-attribute-plugin';\nimport { isNil } from '@visactor/vutils';\n\nexport class ReactAttributePlugin extends HtmlAttributePlugin implements IPlugin {\n name: 'ReactAttributePlugin' = 'ReactAttributePlugin';\n activeEvent: 'onRegister' = 'onRegister';\n declare pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n\n htmlMap: Record<\n string,\n {\n root?: any;\n unmount?: () => void;\n wrapContainer: HTMLElement;\n nativeContainer: HTMLElement;\n container: string | HTMLElement | null;\n renderId: number;\n }\n > = {};\n\n removeElement(id: string) {\n if (!this.htmlMap || !this.htmlMap[id]) {\n return;\n }\n\n const { root, wrapContainer, unmount } = this.htmlMap[id];\n\n if (root) {\n const raf = application.global.getRequestAnimationFrame();\n raf(() => {\n root.unmount();\n });\n } else if (unmount) {\n unmount();\n }\n\n wrapContainer && application.global.removeDom(wrapContainer);\n\n this.htmlMap[id] = null;\n }\n\n renderGraphicHTML(graphic: IGraphic) {\n const { react } = graphic.attribute;\n if (!react) {\n return;\n }\n const stage = graphic.stage;\n if (!stage) {\n return;\n }\n const ReactDOM = stage.params.ReactDOM;\n const { element, container } = react;\n if (!(element && ReactDOM && (ReactDOM.createRoot || ReactDOM.render))) {\n return;\n }\n const id = isNil(react.id) ? `${graphic.id ?? graphic._uid}_react` : react.id;\n\n if (this.htmlMap && this.htmlMap[id] && container && container !== this.htmlMap[id].container) {\n this.removeElement(id);\n }\n\n if (!this.htmlMap || !this.htmlMap[id]) {\n // createa a wrapper contianer to be the root of react element\n const { wrapContainer, nativeContainer } = this.getWrapContainer(stage, container);\n\n if (wrapContainer) {\n if (!this.htmlMap) {\n this.htmlMap = {};\n }\n if (ReactDOM.createRoot) {\n const root = ReactDOM.createRoot(wrapContainer);\n root.render(element);\n\n this.htmlMap[id] = { root, wrapContainer, nativeContainer, container, renderId: this.renderId };\n } else {\n ReactDOM.render(element, wrapContainer);\n\n this.htmlMap[id] = {\n wrapContainer,\n nativeContainer,\n container,\n renderId: this.renderId,\n unmount: () => {\n ReactDOM.unmountComponentAtNode(wrapContainer);\n }\n };\n }\n }\n } else {\n // update react element\n if (ReactDOM.createRoot) {\n this.htmlMap[id].root.render(element);\n } else {\n ReactDOM.render(element, this.htmlMap[id].wrapContainer);\n }\n }\n\n if (!this.htmlMap || !this.htmlMap[id]) {\n return;\n }\n\n const { wrapContainer, nativeContainer } = this.htmlMap[id];\n\n this.updateStyleOfWrapContainer(graphic, stage, wrapContainer, nativeContainer, react);\n this.htmlMap[id].renderId = this.renderId;\n }\n}\n"]}
|
package/dist/index.es.js
CHANGED
|
@@ -18621,19 +18621,23 @@ let DefaultGraphicService = class DefaultGraphicService {
|
|
|
18621
18621
|
return aabbBounds;
|
|
18622
18622
|
}
|
|
18623
18623
|
updateLineAABBBoundsByPoints(attribute, lineTheme, aabbBounds, graphic) {
|
|
18624
|
-
const { points = lineTheme.points } = attribute;
|
|
18624
|
+
const { points = lineTheme.points, connectedType } = attribute;
|
|
18625
18625
|
const b = aabbBounds;
|
|
18626
18626
|
points.forEach(p => {
|
|
18627
|
-
|
|
18627
|
+
if (p.defined !== false || connectedType === 'zero') {
|
|
18628
|
+
b.add(p.x, p.y);
|
|
18629
|
+
}
|
|
18628
18630
|
});
|
|
18629
18631
|
return b;
|
|
18630
18632
|
}
|
|
18631
18633
|
updateLineAABBBoundsBySegments(attribute, lineTheme, aabbBounds, graphic) {
|
|
18632
|
-
const { segments = lineTheme.segments } = attribute;
|
|
18634
|
+
const { segments = lineTheme.segments, connectedType } = attribute;
|
|
18633
18635
|
const b = aabbBounds;
|
|
18634
18636
|
segments.forEach(s => {
|
|
18635
18637
|
s.points.forEach(p => {
|
|
18636
|
-
|
|
18638
|
+
if (p.defined !== false || connectedType === 'zero') {
|
|
18639
|
+
b.add(p.x, p.y);
|
|
18640
|
+
}
|
|
18637
18641
|
});
|
|
18638
18642
|
});
|
|
18639
18643
|
return b;
|
|
@@ -25954,13 +25958,16 @@ class ReactAttributePlugin extends HtmlAttributePlugin {
|
|
|
25954
25958
|
if (!this.htmlMap || !this.htmlMap[id]) {
|
|
25955
25959
|
return;
|
|
25956
25960
|
}
|
|
25957
|
-
const { root, wrapContainer } = this.htmlMap[id];
|
|
25961
|
+
const { root, wrapContainer, unmount } = this.htmlMap[id];
|
|
25958
25962
|
if (root) {
|
|
25959
25963
|
const raf = application.global.getRequestAnimationFrame();
|
|
25960
25964
|
raf(() => {
|
|
25961
25965
|
root.unmount();
|
|
25962
25966
|
});
|
|
25963
25967
|
}
|
|
25968
|
+
else if (unmount) {
|
|
25969
|
+
unmount();
|
|
25970
|
+
}
|
|
25964
25971
|
wrapContainer && application.global.removeDom(wrapContainer);
|
|
25965
25972
|
this.htmlMap[id] = null;
|
|
25966
25973
|
}
|
|
@@ -25976,7 +25983,7 @@ class ReactAttributePlugin extends HtmlAttributePlugin {
|
|
|
25976
25983
|
}
|
|
25977
25984
|
const ReactDOM = stage.params.ReactDOM;
|
|
25978
25985
|
const { element, container } = react;
|
|
25979
|
-
if (!(element && ReactDOM && ReactDOM.createRoot)) {
|
|
25986
|
+
if (!(element && ReactDOM && (ReactDOM.createRoot || ReactDOM.render))) {
|
|
25980
25987
|
return;
|
|
25981
25988
|
}
|
|
25982
25989
|
const id = isNil(react.id) ? `${(_a = graphic.id) !== null && _a !== void 0 ? _a : graphic._uid}_react` : react.id;
|
|
@@ -25986,16 +25993,35 @@ class ReactAttributePlugin extends HtmlAttributePlugin {
|
|
|
25986
25993
|
if (!this.htmlMap || !this.htmlMap[id]) {
|
|
25987
25994
|
const { wrapContainer, nativeContainer } = this.getWrapContainer(stage, container);
|
|
25988
25995
|
if (wrapContainer) {
|
|
25989
|
-
const root = ReactDOM.createRoot(wrapContainer);
|
|
25990
|
-
root.render(element);
|
|
25991
25996
|
if (!this.htmlMap) {
|
|
25992
25997
|
this.htmlMap = {};
|
|
25993
25998
|
}
|
|
25994
|
-
|
|
25999
|
+
if (ReactDOM.createRoot) {
|
|
26000
|
+
const root = ReactDOM.createRoot(wrapContainer);
|
|
26001
|
+
root.render(element);
|
|
26002
|
+
this.htmlMap[id] = { root, wrapContainer, nativeContainer, container, renderId: this.renderId };
|
|
26003
|
+
}
|
|
26004
|
+
else {
|
|
26005
|
+
ReactDOM.render(element, wrapContainer);
|
|
26006
|
+
this.htmlMap[id] = {
|
|
26007
|
+
wrapContainer,
|
|
26008
|
+
nativeContainer,
|
|
26009
|
+
container,
|
|
26010
|
+
renderId: this.renderId,
|
|
26011
|
+
unmount: () => {
|
|
26012
|
+
ReactDOM.unmountComponentAtNode(wrapContainer);
|
|
26013
|
+
}
|
|
26014
|
+
};
|
|
26015
|
+
}
|
|
25995
26016
|
}
|
|
25996
26017
|
}
|
|
25997
26018
|
else {
|
|
25998
|
-
|
|
26019
|
+
if (ReactDOM.createRoot) {
|
|
26020
|
+
this.htmlMap[id].root.render(element);
|
|
26021
|
+
}
|
|
26022
|
+
else {
|
|
26023
|
+
ReactDOM.render(element, this.htmlMap[id].wrapContainer);
|
|
26024
|
+
}
|
|
25999
26025
|
}
|
|
26000
26026
|
if (!this.htmlMap || !this.htmlMap[id]) {
|
|
26001
26027
|
return;
|
|
@@ -402,16 +402,16 @@ let DefaultGraphicService = class {
|
|
|
402
402
|
aabbBounds;
|
|
403
403
|
}
|
|
404
404
|
updateLineAABBBoundsByPoints(attribute, lineTheme, aabbBounds, graphic) {
|
|
405
|
-
const {points: points = lineTheme.points} = attribute, b = aabbBounds;
|
|
405
|
+
const {points: points = lineTheme.points, connectedType: connectedType} = attribute, b = aabbBounds;
|
|
406
406
|
return points.forEach((p => {
|
|
407
|
-
b.add(p.x, p.y);
|
|
407
|
+
!1 === p.defined && "zero" !== connectedType || b.add(p.x, p.y);
|
|
408
408
|
})), b;
|
|
409
409
|
}
|
|
410
410
|
updateLineAABBBoundsBySegments(attribute, lineTheme, aabbBounds, graphic) {
|
|
411
|
-
const {segments: segments = lineTheme.segments} = attribute, b = aabbBounds;
|
|
411
|
+
const {segments: segments = lineTheme.segments, connectedType: connectedType} = attribute, b = aabbBounds;
|
|
412
412
|
return segments.forEach((s => {
|
|
413
413
|
s.points.forEach((p => {
|
|
414
|
-
b.add(p.x, p.y);
|
|
414
|
+
!1 === p.defined && "zero" !== connectedType || b.add(p.x, p.y);
|
|
415
415
|
}));
|
|
416
416
|
})), b;
|
|
417
417
|
}
|