From 788245fd0751e0698d7b628f38b8cfef3cd520bf 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: Fri, 16 Aug 2024 14:57:43 +0800 Subject: [PATCH] Release (#1754) * refactor: fix dev tools (#1750) * chore: fix build env * refactor: fix typo and lint * chore: update webpack config * fix: HTML canvas does not match the canvas range after the camera is applied (#1702) (#1752) * Version Packages (#1753) 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-canvas/CHANGELOG.md | 7 ++ packages/g-canvas/package.json | 2 +- packages/g-canvaskit/CHANGELOG.md | 7 ++ packages/g-canvaskit/package.json | 2 +- packages/g-devtool/devtools/manifest.json | 8 +- packages/g-devtool/devtools/script/panel.js | 74 +++++++++---------- packages/g-devtool/package.json | 14 ++-- packages/g-devtool/webpack.config.js | 34 +++++++++ packages/g-mobile-webgl/CHANGELOG.md | 7 ++ packages/g-mobile-webgl/package.json | 2 +- packages/g-plugin-html-renderer/CHANGELOG.md | 6 ++ packages/g-plugin-html-renderer/package.json | 2 +- .../src/HTMLRenderingPlugin.ts | 20 +++-- .../CHANGELOG.md | 6 ++ .../package.json | 2 +- .../CHANGELOG.md | 6 ++ .../package.json | 2 +- packages/g-web-components/CHANGELOG.md | 7 ++ 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 +- 23 files changed, 165 insertions(+), 63 deletions(-) create mode 100644 packages/g-devtool/webpack.config.js diff --git a/packages/g-canvas/CHANGELOG.md b/packages/g-canvas/CHANGELOG.md index 9b91013fa..00cf03806 100644 --- a/packages/g-canvas/CHANGELOG.md +++ b/packages/g-canvas/CHANGELOG.md @@ -1,5 +1,12 @@ # @antv/g-canvas +## 2.0.11 + +### Patch Changes + +- Updated dependencies [bc655835] + - @antv/g-plugin-html-renderer@2.0.10 + ## 2.0.10 ### Patch Changes diff --git a/packages/g-canvas/package.json b/packages/g-canvas/package.json index ff2f228bb..d4ea3ab89 100644 --- a/packages/g-canvas/package.json +++ b/packages/g-canvas/package.json @@ -1,6 +1,6 @@ { "name": "@antv/g-canvas", - "version": "2.0.10", + "version": "2.0.11", "description": "A renderer implemented by Canvas 2D API", "keywords": [ "antv", diff --git a/packages/g-canvaskit/CHANGELOG.md b/packages/g-canvaskit/CHANGELOG.md index a7f7a9c92..869031181 100644 --- a/packages/g-canvaskit/CHANGELOG.md +++ b/packages/g-canvaskit/CHANGELOG.md @@ -1,5 +1,12 @@ # @antv/g-canvaskit +## 1.0.11 + +### Patch Changes + +- Updated dependencies [bc655835] + - @antv/g-plugin-html-renderer@2.0.10 + ## 1.0.10 ### Patch Changes diff --git a/packages/g-canvaskit/package.json b/packages/g-canvaskit/package.json index 42e444445..f310ac311 100644 --- a/packages/g-canvaskit/package.json +++ b/packages/g-canvaskit/package.json @@ -1,6 +1,6 @@ { "name": "@antv/g-canvaskit", - "version": "1.0.10", + "version": "1.0.11", "description": "A renderer implemented by CanvasKit", "keywords": [ "antv", diff --git a/packages/g-devtool/devtools/manifest.json b/packages/g-devtool/devtools/manifest.json index f81294855..d73db44e4 100644 --- a/packages/g-devtool/devtools/manifest.json +++ b/packages/g-devtool/devtools/manifest.json @@ -5,11 +5,7 @@ "devtools_page": "g_devtools.html", "minimum_chrome_version": "49", "manifest_version": 2, - "permissions": [ - "file:///*", - "http://*/*", - "https://*/*" - ], + "permissions": ["file:///*", "http://*/*", "https://*/*"], "icons": { "16": "icons/16.png", "32": "icons/32.png", @@ -18,6 +14,6 @@ }, "content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'", - "web_accessible_resources": [ "main.html", "panel.html", "script/backend.js"], + "web_accessible_resources": ["main.html", "panel.html", "script/backend.js"], "browser_action": {} } diff --git a/packages/g-devtool/devtools/script/panel.js b/packages/g-devtool/devtools/script/panel.js index 49d9dcf29..7f00ec42c 100644 --- a/packages/g-devtool/devtools/script/panel.js +++ b/packages/g-devtool/devtools/script/panel.js @@ -15,10 +15,10 @@ var executeScriptInInspectWindow = function (script) { }); }; -// execute function in anynomous code block -var executeFuntionInInspectWindow = function (func, args) { +// execute function in anonymous code block +var executeFunctionInInspectWindow = function (func, args) { return executeScriptInInspectWindow( - `(${func.toString()}).apply(window, ${JSON.stringify(args)})` + `(${func.toString()}).apply(window, ${JSON.stringify(args)})`, ); }; @@ -81,9 +81,9 @@ function getGlobalInstances() { } gmap[ga.hash] = instance; - ga.id = instance.id || instance.get("id"); - ga.name = instance.name || instance.get("name"); - ga.type = instance.get("type") || instance.nodeName || "group"; + ga.id = instance.id || instance.get('id'); + ga.name = instance.name || instance.get('name'); + ga.type = instance.get('type') || instance.nodeName || 'group'; return ga; } @@ -91,13 +91,13 @@ function getGlobalInstances() { gInfo = instances.map(function (instance) { var hash = instance.hash || Math.random().toString(16).slice(-8); var ga = { - type: "renderer", - name: "renderer", - nodeName: "renderer", + type: 'renderer', + name: 'renderer', + nodeName: 'renderer', hash: hash, children: getCanvasRootGroup(instance).map((e) => getGInstance(e)), memory: window.performance.memory.usedJSHeapSize, - fps: window.__g_fps_value + fps: window.__g_fps_value, }; instance.hash = ga.hash; gmap[ga.hash] = instance; @@ -115,18 +115,18 @@ function checkCanvasByHash(hash) { } function createBoxUsingId(bbox, id, color) { - var el = document.createElement("div"); + var el = document.createElement('div'); window[id] = el; - el.classList.add("g_devtool_rect"); + el.classList.add('g_devtool_rect'); document.body.appendChild(el); - el.style.position = "absolute"; + el.style.position = 'absolute'; el.style.width = `${bbox.width}px`; el.style.height = `${bbox.height}px`; el.style.top = `${bbox.top}px`; el.style.left = `${bbox.left}px`; - el.style.background = color || "rgba(135, 59, 244, 0.5)"; - el.style.border = "2px dashed rgb(135, 59, 244)"; - el.style.boxSizing = "border-box"; + el.style.background = color || 'rgba(135, 59, 244, 0.5)'; + el.style.border = '2px dashed rgb(135, 59, 244)'; + el.style.boxSizing = 'border-box'; } function removeBoxUsingId(id) { @@ -136,7 +136,7 @@ function removeBoxUsingId(id) { } function removeAllBox() { - var elements = document.getElementsByClassName("g_devtool_rect"); + var elements = document.getElementsByClassName('g_devtool_rect'); [].forEach.apply(elements, [ function (e) { e.remove(); @@ -144,7 +144,7 @@ function removeAllBox() { ]); } -function getElemetBBoxByHash(hash) { +function getElementBBoxByHash(hash) { var targetEl = window.__g_instances__.globalMap[hash]; if (targetEl.getBoundingClientRect) { return targetEl.getBoundingClientRect(); @@ -172,8 +172,8 @@ function setGElementByHash(hash) { function consoleElementByHash(hash, desc) { window.console.log( - desc || "", - window.__g_instances__.globalMap[hash] + desc || '', + window.__g_instances__.globalMap[hash], ); } @@ -182,35 +182,35 @@ function consoleElementByHash(hash, desc) { // function setRect(bbox, id, color) { - executeFuntionInInspectWindow(removeBoxUsingId, [id]).finally(() => { - executeFuntionInInspectWindow(createBoxUsingId, [bbox, id, color]); + executeFunctionInInspectWindow(removeBoxUsingId, [id]).finally(() => { + executeFunctionInInspectWindow(createBoxUsingId, [bbox, id, color]); }); } function cleanRect(id) { - executeFuntionInInspectWindow(removeBoxUsingId, [id]); + executeFunctionInInspectWindow(removeBoxUsingId, [id]); } function showRect(hash, id, color) { - executeFuntionInInspectWindow(getElemetBBoxByHash, [hash]).then((bbox) => { + executeFunctionInInspectWindow(getElementBBoxByHash, [hash]).then((bbox) => { setRect(bbox, id, color); }); } function cleanAllRect() { - executeFuntionInInspectWindow(removeAllBox); + executeFunctionInInspectWindow(removeAllBox); } function getAttrs(hash) { if (hash) { - executeFuntionInInspectWindow(setGElementByHash, [hash]); - return executeFuntionInInspectWindow(getElementAttrByHash, [hash]); + executeFunctionInInspectWindow(setGElementByHash, [hash]); + return executeFunctionInInspectWindow(getElementAttrByHash, [hash]); } - return executeFuntionInInspectWindow(setGElementByHash, []); + return executeFunctionInInspectWindow(setGElementByHash, []); } function updateAttrs(hash, name, attrs) { - return executeFuntionInInspectWindow(setElementAttrByHash, [ + return executeFunctionInInspectWindow(setElementAttrByHash, [ hash, name, attrs, @@ -218,30 +218,30 @@ function updateAttrs(hash, name, attrs) { } function consoleEl(hash, desc) { - return executeFuntionInInspectWindow(consoleElementByHash, [hash, desc]); + return executeFunctionInInspectWindow(consoleElementByHash, [hash, desc]); } function checkCanvasAlive(hash) { - return executeFuntionInInspectWindow(checkCanvasByHash, [hash]).then( + return executeFunctionInInspectWindow(checkCanvasByHash, [hash]).then( (res) => { if (res) { return true; } else { return false; } - } + }, ); } function getNowCanvasData() { - return executeFuntionInInspectWindow(getGlobalInstances); + return executeFunctionInInspectWindow(getGlobalInstances); } function startFPSMonitor() { - return executeFuntionInInspectWindow(doFPSThings); + return executeFunctionInInspectWindow(doFPSThings); } getNowCanvasData().then(function (data) { - const container = document.getElementById("container"); + const container = document.getElementById('container'); mount(data, container, { showRect, getAttrs, @@ -251,8 +251,8 @@ getNowCanvasData().then(function (data) { checkCanvasAlive, getNowCanvasData, cleanAllRect, - startFPSMonitor + startFPSMonitor, }); }); -startFPSMonitor() +startFPSMonitor(); diff --git a/packages/g-devtool/package.json b/packages/g-devtool/package.json index 3102e9c8f..2b9f0778c 100644 --- a/packages/g-devtool/package.json +++ b/packages/g-devtool/package.json @@ -6,6 +6,7 @@ "license": "MIT", "main": "index.js", "scripts": { + "build": "webpack --config webpack.config.js", "start": "webpack -w", "sync": "tnpm sync" }, @@ -17,13 +18,14 @@ }, "devDependencies": { "@babel/core": "^7.16.7", - "@babel/preset-env": "^7.16.8", - "@babel/preset-react": "^7.16.7", - "babel-loader": "^8.2.3", - "css-loader": "^6.5.1", - "style-loader": "^3.3.1", + "@babel/preset-env": "^7.25.3", + "@babel/preset-react": "^7.24.7", + "babel-loader": "^8.3.0", + "css-loader": "^6.11.0", + "style-loader": "^3.3.4", "webpack": "^5.66.0", "webpack-cli": "^4.9.1" }, - "gitHead": "39c05f77bced16f75a3a14fff5bf958c1bf9fa7c" + "gitHead": "39c05f77bced16f75a3a14fff5bf958c1bf9fa7c", + "repository": "git@github.com:antvis/G.git" } diff --git a/packages/g-devtool/webpack.config.js b/packages/g-devtool/webpack.config.js new file mode 100644 index 000000000..cf135694d --- /dev/null +++ b/packages/g-devtool/webpack.config.js @@ -0,0 +1,34 @@ +const path = require('path'); + +module.exports = { + entry: { + index: './ui/index.js', + }, + mode: 'development', + output: { + path: path.resolve(__dirname, 'devtools/ui'), + filename: 'ui.js', + }, + resolve: { + extensions: ['.js', '.jsx'], + }, + module: { + rules: [ + { + test: /\.js$|jsx/, + exclude: /node_modules/, + use: { + loader: 'babel-loader', + options: { + presets: ['@babel/preset-env', '@babel/preset-react'], + }, + }, + }, + { + test: /\.css$/i, + use: ['style-loader', 'css-loader'], + }, + ], + }, + plugins: [], +}; diff --git a/packages/g-mobile-webgl/CHANGELOG.md b/packages/g-mobile-webgl/CHANGELOG.md index 8b5143c44..21fee0e11 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.14 + +### Patch Changes + +- Updated dependencies [bc655835] + - @antv/g-plugin-html-renderer@2.0.10 + ## 1.0.13 ### Patch Changes diff --git a/packages/g-mobile-webgl/package.json b/packages/g-mobile-webgl/package.json index c18c99db1..8ff6d71dd 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.13", + "version": "1.0.14", "description": "A renderer implemented by WebGL1/2 in mobile environment", "keywords": [ "antv", diff --git a/packages/g-plugin-html-renderer/CHANGELOG.md b/packages/g-plugin-html-renderer/CHANGELOG.md index 1fea63a55..e58aa6cf4 100644 --- a/packages/g-plugin-html-renderer/CHANGELOG.md +++ b/packages/g-plugin-html-renderer/CHANGELOG.md @@ -1,5 +1,11 @@ # @antv/g-plugin-html-renderer +## 2.0.10 + +### Patch Changes + +- bc655835: fix: HTML canvas does not match the canvas range after the camera is applied (#1702) + ## 2.0.9 ### Patch Changes diff --git a/packages/g-plugin-html-renderer/package.json b/packages/g-plugin-html-renderer/package.json index e8c176b4f..35df5ec7c 100644 --- a/packages/g-plugin-html-renderer/package.json +++ b/packages/g-plugin-html-renderer/package.json @@ -1,6 +1,6 @@ { "name": "@antv/g-plugin-html-renderer", - "version": "2.0.9", + "version": "2.0.10", "description": "A G plugin for rendering HTML", "keywords": [ "antv", diff --git a/packages/g-plugin-html-renderer/src/HTMLRenderingPlugin.ts b/packages/g-plugin-html-renderer/src/HTMLRenderingPlugin.ts index 4d6b7595d..eecc0e7a0 100644 --- a/packages/g-plugin-html-renderer/src/HTMLRenderingPlugin.ts +++ b/packages/g-plugin-html-renderer/src/HTMLRenderingPlugin.ts @@ -176,6 +176,17 @@ export class HTMLRenderingPlugin implements RenderingPlugin { '#' + cameraId, ); if (!$existedCamera) { + // fix @see https://github.com/antvis/G/issues/1702 + const $cameraContainer = (doc || document).createElement('div'); + // HTML elements should not overflow with canvas @see https://github.com/antvis/G/issues/1163 + $cameraContainer.style.overflow = 'hidden'; + $cameraContainer.style.pointerEvents = 'none'; + $cameraContainer.style.position = 'absolute'; + $cameraContainer.style.left = `0px`; + $cameraContainer.style.top = `0px`; + $cameraContainer.style.width = `${width || 0}px`; + $cameraContainer.style.height = `${height || 0}px`; + const $camera = (doc || document).createElement('div'); $existedCamera = $camera; $camera.id = cameraId; @@ -188,13 +199,12 @@ export class HTMLRenderingPlugin implements RenderingPlugin { $camera.style.transform = this.joinTransformMatrix( camera.getOrthoMatrix(), ); - // HTML elements should not overflow with canvas @see https://github.com/antvis/G/issues/1163 - $camera.style.overflow = 'hidden'; $camera.style.pointerEvents = 'none'; - $camera.style.width = `${width || 0}px`; - $camera.style.height = `${height || 0}px`; + $camera.style.width = `100%`; + $camera.style.height = `100%`; - $container.appendChild($camera); + $cameraContainer.appendChild($camera); + $container.appendChild($cameraContainer); } return $existedCamera; diff --git a/packages/g-plugin-rough-canvas-renderer/CHANGELOG.md b/packages/g-plugin-rough-canvas-renderer/CHANGELOG.md index 87cd963f4..464649587 100644 --- a/packages/g-plugin-rough-canvas-renderer/CHANGELOG.md +++ b/packages/g-plugin-rough-canvas-renderer/CHANGELOG.md @@ -1,5 +1,11 @@ # @antv/g-plugin-rough-canvas-renderer +## 2.0.12 + +### Patch Changes + +- @antv/g-canvas@2.0.11 + ## 2.0.11 ### Patch Changes diff --git a/packages/g-plugin-rough-canvas-renderer/package.json b/packages/g-plugin-rough-canvas-renderer/package.json index 9459f22ee..4aa8a40e8 100644 --- a/packages/g-plugin-rough-canvas-renderer/package.json +++ b/packages/g-plugin-rough-canvas-renderer/package.json @@ -1,6 +1,6 @@ { "name": "@antv/g-plugin-rough-canvas-renderer", - "version": "2.0.11", + "version": "2.0.12", "description": "A G plugin of renderer implementation with rough.js", "keywords": [ "antv", diff --git a/packages/g-plugin-zdog-canvas-renderer/CHANGELOG.md b/packages/g-plugin-zdog-canvas-renderer/CHANGELOG.md index d8d7978e5..fbe66c0c6 100644 --- a/packages/g-plugin-zdog-canvas-renderer/CHANGELOG.md +++ b/packages/g-plugin-zdog-canvas-renderer/CHANGELOG.md @@ -1,5 +1,11 @@ # @antv/g-plugin-zdog-canvas-renderer +## 2.0.11 + +### Patch Changes + +- @antv/g-canvas@2.0.11 + ## 2.0.10 ### Patch Changes diff --git a/packages/g-plugin-zdog-canvas-renderer/package.json b/packages/g-plugin-zdog-canvas-renderer/package.json index 8112a8eb6..46118a66a 100644 --- a/packages/g-plugin-zdog-canvas-renderer/package.json +++ b/packages/g-plugin-zdog-canvas-renderer/package.json @@ -1,6 +1,6 @@ { "name": "@antv/g-plugin-zdog-canvas-renderer", - "version": "2.0.10", + "version": "2.0.11", "description": "A G plugin of renderer implementation with Zdog", "keywords": [ "antv", diff --git a/packages/g-web-components/CHANGELOG.md b/packages/g-web-components/CHANGELOG.md index a39dc9c12..31c16f9f8 100644 --- a/packages/g-web-components/CHANGELOG.md +++ b/packages/g-web-components/CHANGELOG.md @@ -1,5 +1,12 @@ # @antv/g-web-components +## 2.0.15 + +### Patch Changes + +- @antv/g-canvas@2.0.11 +- @antv/g-webgl@2.0.14 + ## 2.0.14 ### Patch Changes diff --git a/packages/g-web-components/package.json b/packages/g-web-components/package.json index 0101a59d6..4ff21a034 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.14", + "version": "2.0.15", "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 397c1802b..050f9538c 100644 --- a/packages/g-webgl/CHANGELOG.md +++ b/packages/g-webgl/CHANGELOG.md @@ -1,5 +1,12 @@ # @antv/g-webgl +## 2.0.14 + +### Patch Changes + +- Updated dependencies [bc655835] + - @antv/g-plugin-html-renderer@2.0.10 + ## 2.0.13 ### Patch Changes diff --git a/packages/g-webgl/package.json b/packages/g-webgl/package.json index ae2930c21..3f0056a04 100644 --- a/packages/g-webgl/package.json +++ b/packages/g-webgl/package.json @@ -1,6 +1,6 @@ { "name": "@antv/g-webgl", - "version": "2.0.13", + "version": "2.0.14", "description": "A renderer implemented by WebGL1/2", "keywords": [ "antv", diff --git a/packages/g-webgpu/CHANGELOG.md b/packages/g-webgpu/CHANGELOG.md index 63f97a72e..acc1cfdbb 100644 --- a/packages/g-webgpu/CHANGELOG.md +++ b/packages/g-webgpu/CHANGELOG.md @@ -1,5 +1,12 @@ # @antv/g-webgpu +## 2.0.14 + +### Patch Changes + +- Updated dependencies [bc655835] + - @antv/g-plugin-html-renderer@2.0.10 + ## 2.0.13 ### Patch Changes diff --git a/packages/g-webgpu/package.json b/packages/g-webgpu/package.json index 5546bac5a..51e39c57f 100644 --- a/packages/g-webgpu/package.json +++ b/packages/g-webgpu/package.json @@ -1,6 +1,6 @@ { "name": "@antv/g-webgpu", - "version": "2.0.13", + "version": "2.0.14", "description": "A renderer implemented by WebGPU", "keywords": [ "antv",