From 17c7b560f2cd292d94d88ab68c5a5ed0a23f8d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=A6=82=E6=80=80=E5=BF=B5=EF=BC=88=E4=BA=91?= =?UTF-8?q?=E8=B0=8C=EF=BC=89?= Date: Thu, 22 Aug 2024 14:03:24 +0800 Subject: [PATCH] Release (#1759) * fix: fix g-react re-render (#1757) * fix: render cache target to avoid rerender * refactor: fix typo of reconciler * fix: the logic boundary condition judgment of text element attribute update is missing (#1755) (#1756) * chore: update changeset * Version Packages (#1758) Co-authored-by: github-actions[bot] --------- Co-authored-by: Aaron Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] --- packages/g-mobile-webgl/CHANGELOG.md | 7 +++++++ packages/g-mobile-webgl/package.json | 2 +- packages/g-plugin-3d/CHANGELOG.md | 7 +++++++ packages/g-plugin-3d/package.json | 2 +- packages/g-plugin-device-renderer/CHANGELOG.md | 6 ++++++ packages/g-plugin-device-renderer/package.json | 2 +- .../src/drawcalls/Text.ts | 5 +++++ packages/g-web-components/CHANGELOG.md | 6 ++++++ packages/g-web-components/package.json | 2 +- packages/g-webgl/CHANGELOG.md | 7 +++++++ packages/g-webgl/package.json | 2 +- packages/g-webgpu/CHANGELOG.md | 7 +++++++ packages/g-webgpu/package.json | 2 +- packages/react-g/CHANGELOG.md | 6 ++++++ packages/react-g/package.json | 2 +- packages/react-g/src/canvas.tsx | 8 ++++---- packages/react-g/src/reconciler.ts | 16 ++++++++++------ .../docs/guide/advanced-topics/use-react-g.zh.md | 2 +- 18 files changed, 73 insertions(+), 18 deletions(-) diff --git a/packages/g-mobile-webgl/CHANGELOG.md b/packages/g-mobile-webgl/CHANGELOG.md index 21fee0e11..4c67e0d04 100644 --- a/packages/g-mobile-webgl/CHANGELOG.md +++ b/packages/g-mobile-webgl/CHANGELOG.md @@ -1,5 +1,12 @@ # @antv/g-mobile-webgl +## 1.0.15 + +### Patch Changes + +- Updated dependencies [3fb2553d] + - @antv/g-plugin-device-renderer@2.0.13 + ## 1.0.14 ### Patch Changes diff --git a/packages/g-mobile-webgl/package.json b/packages/g-mobile-webgl/package.json index 8ff6d71dd..7fc6e61ec 100644 --- a/packages/g-mobile-webgl/package.json +++ b/packages/g-mobile-webgl/package.json @@ -1,6 +1,6 @@ { "name": "@antv/g-mobile-webgl", - "version": "1.0.14", + "version": "1.0.15", "description": "A renderer implemented by WebGL1/2 in mobile environment", "keywords": [ "antv", diff --git a/packages/g-plugin-3d/CHANGELOG.md b/packages/g-plugin-3d/CHANGELOG.md index f84ae922a..c5029b4e9 100644 --- a/packages/g-plugin-3d/CHANGELOG.md +++ b/packages/g-plugin-3d/CHANGELOG.md @@ -1,5 +1,12 @@ # @antv/g-plugin-3d +## 2.0.13 + +### Patch Changes + +- Updated dependencies [3fb2553d] + - @antv/g-plugin-device-renderer@2.0.13 + ## 2.0.12 ### Patch Changes diff --git a/packages/g-plugin-3d/package.json b/packages/g-plugin-3d/package.json index 70cf096ed..0e8bf3c7b 100644 --- a/packages/g-plugin-3d/package.json +++ b/packages/g-plugin-3d/package.json @@ -1,6 +1,6 @@ { "name": "@antv/g-plugin-3d", - "version": "2.0.12", + "version": "2.0.13", "description": "Provide 3D extension for G", "keywords": [ "antv", diff --git a/packages/g-plugin-device-renderer/CHANGELOG.md b/packages/g-plugin-device-renderer/CHANGELOG.md index 79c15cbca..f764c98de 100644 --- a/packages/g-plugin-device-renderer/CHANGELOG.md +++ b/packages/g-plugin-device-renderer/CHANGELOG.md @@ -1,5 +1,11 @@ # @antv/g-plugin-device-renderer +## 2.0.13 + +### Patch Changes + +- 3fb2553d: fix: the logic boundary condition judgment of text element attribute update is missing (#1755) + ## 2.0.12 ### Patch Changes diff --git a/packages/g-plugin-device-renderer/package.json b/packages/g-plugin-device-renderer/package.json index 71de58e72..b1ec8f973 100644 --- a/packages/g-plugin-device-renderer/package.json +++ b/packages/g-plugin-device-renderer/package.json @@ -1,6 +1,6 @@ { "name": "@antv/g-plugin-device-renderer", - "version": "2.0.12", + "version": "2.0.13", "description": "A G plugin of renderer implementation with GPUDevice", "keywords": [ "antv", diff --git a/packages/g-plugin-device-renderer/src/drawcalls/Text.ts b/packages/g-plugin-device-renderer/src/drawcalls/Text.ts index 51e5c498d..cde1f54c6 100644 --- a/packages/g-plugin-device-renderer/src/drawcalls/Text.ts +++ b/packages/g-plugin-device-renderer/src/drawcalls/Text.ts @@ -342,6 +342,11 @@ export class TextDrawcall extends Instanced { name: string, value: any, ): void { + // fix https://github.com/antvis/G/issues/1755 + if (objects.length === 0) { + return; + } + if ( name === 'text' || name === 'fontFamily' || diff --git a/packages/g-web-components/CHANGELOG.md b/packages/g-web-components/CHANGELOG.md index 31c16f9f8..9a4460587 100644 --- a/packages/g-web-components/CHANGELOG.md +++ b/packages/g-web-components/CHANGELOG.md @@ -1,5 +1,11 @@ # @antv/g-web-components +## 2.0.16 + +### Patch Changes + +- @antv/g-webgl@2.0.15 + ## 2.0.15 ### Patch Changes diff --git a/packages/g-web-components/package.json b/packages/g-web-components/package.json index 4ff21a034..9cc0cfd14 100644 --- a/packages/g-web-components/package.json +++ b/packages/g-web-components/package.json @@ -1,6 +1,6 @@ { "name": "@antv/g-web-components", - "version": "2.0.15", + "version": "2.0.16", "description": "A declarative usage for G implemented with WebComponents", "keywords": [ "antv", diff --git a/packages/g-webgl/CHANGELOG.md b/packages/g-webgl/CHANGELOG.md index 050f9538c..4cead6e26 100644 --- a/packages/g-webgl/CHANGELOG.md +++ b/packages/g-webgl/CHANGELOG.md @@ -1,5 +1,12 @@ # @antv/g-webgl +## 2.0.15 + +### Patch Changes + +- Updated dependencies [3fb2553d] + - @antv/g-plugin-device-renderer@2.0.13 + ## 2.0.14 ### Patch Changes diff --git a/packages/g-webgl/package.json b/packages/g-webgl/package.json index 3f0056a04..f3aa85cd7 100644 --- a/packages/g-webgl/package.json +++ b/packages/g-webgl/package.json @@ -1,6 +1,6 @@ { "name": "@antv/g-webgl", - "version": "2.0.14", + "version": "2.0.15", "description": "A renderer implemented by WebGL1/2", "keywords": [ "antv", diff --git a/packages/g-webgpu/CHANGELOG.md b/packages/g-webgpu/CHANGELOG.md index acc1cfdbb..b9ad8bbfd 100644 --- a/packages/g-webgpu/CHANGELOG.md +++ b/packages/g-webgpu/CHANGELOG.md @@ -1,5 +1,12 @@ # @antv/g-webgpu +## 2.0.15 + +### Patch Changes + +- Updated dependencies [3fb2553d] + - @antv/g-plugin-device-renderer@2.0.13 + ## 2.0.14 ### Patch Changes diff --git a/packages/g-webgpu/package.json b/packages/g-webgpu/package.json index 51e39c57f..20f746a68 100644 --- a/packages/g-webgpu/package.json +++ b/packages/g-webgpu/package.json @@ -1,6 +1,6 @@ { "name": "@antv/g-webgpu", - "version": "2.0.14", + "version": "2.0.15", "description": "A renderer implemented by WebGPU", "keywords": [ "antv", diff --git a/packages/react-g/CHANGELOG.md b/packages/react-g/CHANGELOG.md index f9cc056e8..986b7f7b6 100644 --- a/packages/react-g/CHANGELOG.md +++ b/packages/react-g/CHANGELOG.md @@ -1,5 +1,11 @@ # @antv/react-g +## 2.0.13 + +### Patch Changes + +- 950db94d: fix: react-g rerender (#1757) + ## 2.0.12 ### Patch Changes diff --git a/packages/react-g/package.json b/packages/react-g/package.json index a48398594..541172683 100644 --- a/packages/react-g/package.json +++ b/packages/react-g/package.json @@ -1,6 +1,6 @@ { "name": "@antv/react-g", - "version": "2.0.12", + "version": "2.0.13", "description": "react render for @antv/g", "keywords": [ "react", diff --git a/packages/react-g/src/canvas.tsx b/packages/react-g/src/canvas.tsx index d61e8a09d..95d2f0a11 100644 --- a/packages/react-g/src/canvas.tsx +++ b/packages/react-g/src/canvas.tsx @@ -2,7 +2,7 @@ import type { CanvasConfig } from '@antv/g'; import { Canvas as GCanvas } from '@antv/g'; import React, { forwardRef, useLayoutEffect, useRef } from 'react'; import type { FiberRoot } from 'react-reconciler'; -import { reconcilor } from './reconciler'; +import { reconciler } from './reconciler'; import { assertRef } from './util'; export interface CanvasProps extends CanvasConfig { @@ -52,7 +52,7 @@ export const Canvas = forwardRef( canvasRef.current = canvas; // @ts-ignore - container.current = reconcilor.createContainer( + container.current = reconciler.createContainer( canvas as any, 1, false, @@ -61,14 +61,14 @@ export const Canvas = forwardRef( return () => { // @ts-ignore - reconcilor.updateContainer(null, container.current, null); + reconciler.updateContainer(null, container.current, null); }; }, []); useLayoutEffect(() => { if (container.current) { // @ts-ignore - reconcilor.updateContainer(children, container.current, null); + reconciler.updateContainer(children, container.current, null); } }, [children]); diff --git a/packages/react-g/src/reconciler.ts b/packages/react-g/src/reconciler.ts index 222837c37..4ac24da18 100644 --- a/packages/react-g/src/reconciler.ts +++ b/packages/react-g/src/reconciler.ts @@ -1,6 +1,6 @@ import type { Canvas, Element } from '@antv/g'; import React from 'react'; -import type { OpaqueHandle } from 'react-reconciler'; +import type { OpaqueHandle, OpaqueRoot } from 'react-reconciler'; import ReactReconciler from 'react-reconciler'; import { unstable_now as now } from 'scheduler'; import { bindShapeEvent, updateProps } from './processProps'; @@ -20,7 +20,7 @@ import type { UpdatePayload, } from './types'; -export const reconcilor = ReactReconciler< +export const reconciler = ReactReconciler< Type, Props, Container, @@ -346,7 +346,7 @@ export const reconcilor = ReactReconciler< ): void {}, }); -reconcilor.injectIntoDevTools({ +reconciler.injectIntoDevTools({ // findFiberByHostInstance: () => {}, // @ts-ignore bundleType: process.env.NODE_ENV !== 'production' ? 1 : 0, @@ -359,6 +359,8 @@ reconcilor.injectIntoDevTools({ }, }); +const TargetContainerWeakMap = new WeakMap(); + /** * render react-g component to target g element * 将react-g组件渲染到任意的g实例(Canvas/Group/Shape)中 @@ -372,7 +374,9 @@ export const render = ( target: Element | Canvas, callback?: (() => void) | null, ) => { - // @ts-ignore - const container = reconcilor.createContainer(target as any, 1, false, null); - reconcilor.updateContainer(component, container, null, callback); + const container = + TargetContainerWeakMap.get(target) || + reconciler.createContainer(target as any, 1, false, null); + TargetContainerWeakMap.set(target, container); + reconciler.updateContainer(component, container, null, callback); }; diff --git a/site/docs/guide/advanced-topics/use-react-g.zh.md b/site/docs/guide/advanced-topics/use-react-g.zh.md index f0abdb541..34e97346c 100644 --- a/site/docs/guide/advanced-topics/use-react-g.zh.md +++ b/site/docs/guide/advanced-topics/use-react-g.zh.md @@ -3,7 +3,7 @@ title: 使用 React 定义图形 order: 5 --- -react 通过 `react-reconcilor` 提供了自定义 render 的能力,`react-g` 便是一个 react 到 g 的 render。 +react 通过 `react-reconciler` 提供了自定义 render 的能力,`react-g` 便是一个 react 到 g 的 render。 `react-g` 目前处于实验状态,欢迎试用和反馈。