Skip to content

Commit

Permalink
Release (#1870)
Browse files Browse the repository at this point in the history
* fix: lineDash支持多位数组 (#1867)

* chore: add changeset

* fix: rendering error when line break appears at the beginning of text (#1871)

* docs: 修复异常示例

* refactor: reduce global redundant code (#1872)

* refactor: reduce global redundant code

* chore: add changeset

* fix: svg path element A command drawing abnormality (#1874)

* Version Packages (#1869)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

---------

Co-authored-by: HuangLiangchen <[email protected]>
Co-authored-by: wang1212 <[email protected]>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
5 people authored Dec 20, 2024
1 parent 4e0fe3c commit ae89121
Show file tree
Hide file tree
Showing 120 changed files with 938 additions and 379 deletions.
1 change: 0 additions & 1 deletion __tests__/demos/bugfix/1677.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export async function shadowroot_offset(context) {
width: 500,
height: 500,
renderer: new Renderer(),
supportsCSSTransform: true,
});

const circle = new Circle({
Expand Down
12 changes: 6 additions & 6 deletions __tests__/demos/event/dblClick.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Circle, Text } from '@antv/g';
import { Circle, Text, Canvas } from '@antv/g';

export async function dblClick(context) {
export async function dblClick(context: { canvas: Canvas }) {
const { canvas } = context;
await canvas.ready;

let DELAY = 200;
canvas.dblClickSpeed = DELAY;
canvas.getConfig().dblClickSpeed = DELAY;

const circle0 = new Circle({
style: {
Expand Down Expand Up @@ -43,7 +43,7 @@ export async function dblClick(context) {

circle0.addEventListener('mouseenter', () => {
DELAY = 200;
canvas.dblClickSpeed = DELAY;
canvas.getConfig().dblClickSpeed = DELAY;

text0.attr({ text: `current dblclick delay: ${DELAY}ms` });
text1.attr({
Expand All @@ -52,7 +52,7 @@ export async function dblClick(context) {
});
circle1.addEventListener('mouseenter', () => {
DELAY = 500;
canvas.dblClickSpeed = DELAY;
canvas.getConfig().dblClickSpeed = DELAY;

text0.attr({ text: `current dblclick delay: ${DELAY}ms` });
text1.attr({
Expand All @@ -61,7 +61,7 @@ export async function dblClick(context) {
});
circle2.addEventListener('mouseenter', () => {
DELAY = 1000;
canvas.dblClickSpeed = DELAY;
canvas.getConfig().dblClickSpeed = DELAY;

text0.attr({ text: `current dblclick delay: ${DELAY}ms` });
text1.attr({
Expand Down
93 changes: 93 additions & 0 deletions __tests__/demos/perf/event.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import {
Canvas,
ElementEvent,
Rect,
Group,
CustomEvent,
EventTarget,
} from '@antv/g';
import * as tinybench from 'tinybench';

export async function event(context: { canvas: Canvas }) {
const { canvas } = context;
console.log(canvas);

await canvas.ready;

const { width, height } = canvas.getConfig();
const root = new Group();
let count = 2e4;
let rects = [];
let eventTargets = [];

function render() {
root.destroyChildren();
rects = [];

for (let i = 0; i < count; i++) {
const x = Math.random() * width;
const y = Math.random() * height;
const size = 10 + Math.random() * 40;
const speed = 1 + Math.random();

const rect = new Rect({
style: {
x,
y,
width: size,
height: size,
fill: 'white',
stroke: '#000',
lineWidth: 1,
},
});
root.appendChild(rect);
rects[i] = { x, y, size, speed, el: rect };

// ---
const eventTarge = new EventTarget();
eventTargets.push(eventTarge);
eventTarge.addEventListener(ElementEvent.BOUNDS_CHANGED, () => {
//
});
}
}

render();
canvas.appendChild(root);

// benchmark
// ----------
const boundsChangedEvent = new CustomEvent(ElementEvent.BOUNDS_CHANGED);
boundsChangedEvent.detail = { affectChildren: true };

const bench = new tinybench.Bench({ name: 'event benchmark', time: 1e2 });

bench.add('Iterating trigger events', async () => {
root.forEach((el) => {
el.dispatchEvent(boundsChangedEvent);
});
});
bench.add('Iterating trigger events without propagate', async () => {
root.forEach((el) => {
el.dispatchEvent(boundsChangedEvent, true);
});
});
bench.add('Iterating over trigger events on empty objects', async () => {
eventTargets.forEach((el) => {
el.dispatchEvent(boundsChangedEvent);
});
});
bench.add('Batch triggering events', async () => {
canvas.dispatchEvent(boundsChangedEvent, true);
});

await bench.run();

console.log(bench.name);
console.table(bench.table());
console.log(bench.results);
console.log(bench.tasks);

// ----------
}
10 changes: 10 additions & 0 deletions packages/g-camera-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @antv/g-camera-api

## 2.0.29

### Patch Changes

- Updated dependencies [244d6dd]
- Updated dependencies [9ebc16b]
- Updated dependencies [2d71558]
- Updated dependencies [fad9325]
- @antv/g-lite@2.2.10

## 2.0.28

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-camera-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-camera-api",
"version": "2.0.28",
"version": "2.0.29",
"description": "A simple implementation of Camera API.",
"keywords": [
"antv",
Expand Down
17 changes: 17 additions & 0 deletions packages/g-canvas/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# @antv/g-canvas

## 2.0.33

### Patch Changes

- 244d6dd: refactor: reduce global redundant code
- Updated dependencies [244d6dd]
- Updated dependencies [9ebc16b]
- Updated dependencies [2d71558]
- Updated dependencies [fad9325]
- @antv/g-plugin-image-loader@2.1.12
- @antv/g-lite@2.2.10
- @antv/g-plugin-canvas-renderer@2.2.12
- @antv/g-plugin-canvas-path-generator@2.1.10
- @antv/g-plugin-canvas-picker@2.1.12
- @antv/g-plugin-dom-interaction@2.1.15
- @antv/g-plugin-html-renderer@2.1.15

## 2.0.32

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-canvas/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-canvas",
"version": "2.0.32",
"version": "2.0.33",
"description": "A renderer implemented by Canvas 2D API",
"keywords": [
"antv",
Expand Down
8 changes: 2 additions & 6 deletions packages/g-canvas/src/Canvas2DContextService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import type {
CanvasConfig,
ContextService,
} from '@antv/g-lite';
import { RenderReason, isBrowser, setDOMSize } from '@antv/g-lite';
import { RenderReason, setDOMSize } from '@antv/g-lite';
import { isString } from '@antv/util';

export class Canvas2DContextService
Expand Down Expand Up @@ -92,11 +92,7 @@ export class Canvas2DContextService
}

resize(width: number, height: number) {
const { devicePixelRatio } = this.canvasConfig;

// use user-defined dpr first
let dpr = devicePixelRatio || (isBrowser && window.devicePixelRatio) || 1;
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
const { devicePixelRatio: dpr } = this.canvasConfig;
this.dpr = dpr;

if (this.$canvas) {
Expand Down
17 changes: 17 additions & 0 deletions packages/g-canvaskit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# @antv/g-canvaskit

## 1.0.32

### Patch Changes

- 244d6dd: refactor: reduce global redundant code
- Updated dependencies [244d6dd]
- Updated dependencies [9ebc16b]
- Updated dependencies [2d71558]
- Updated dependencies [fad9325]
- @antv/g-plugin-image-loader@2.1.12
- @antv/g-lite@2.2.10
- @antv/g-plugin-canvaskit-renderer@2.1.12
- @antv/g-plugin-canvas-path-generator@2.1.10
- @antv/g-plugin-canvas-picker@2.1.12
- @antv/g-plugin-dom-interaction@2.1.15
- @antv/g-plugin-html-renderer@2.1.15

## 1.0.31

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-canvaskit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-canvaskit",
"version": "1.0.31",
"version": "1.0.32",
"description": "A renderer implemented by CanvasKit",
"keywords": [
"antv",
Expand Down
7 changes: 2 additions & 5 deletions packages/g-canvaskit/src/CanvasKitContextService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type {
CanvasConfig,
ContextService,
} from '@antv/g-lite';
import { isBrowser, setDOMSize } from '@antv/g-lite';
import { setDOMSize } from '@antv/g-lite';
import type * as CanvaskitRenderer from '@antv/g-plugin-canvaskit-renderer';
import type { CanvasKitContext } from '@antv/g-plugin-canvaskit-renderer';
import { isString } from '@antv/util';
Expand Down Expand Up @@ -40,7 +40,7 @@ export class CanvasKitContextService
}

async initAsync() {
const { container, canvas, devicePixelRatio } = this.canvasConfig;
const { container, canvas, devicePixelRatio: dpr } = this.canvasConfig;

if (canvas) {
this.$canvas = canvas;
Expand Down Expand Up @@ -71,9 +71,6 @@ export class CanvasKitContextService
}
}

// use user-defined dpr first
let dpr = devicePixelRatio || (isBrowser && window.devicePixelRatio) || 1;
dpr = dpr >= 1 ? Math.ceil(dpr) : 1;
this.dpr = dpr;
this.resize(this.canvasConfig.width, this.canvasConfig.height);

Expand Down
10 changes: 10 additions & 0 deletions packages/g-components/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @antv/g-components

## 2.0.26

### Patch Changes

- Updated dependencies [244d6dd]
- Updated dependencies [9ebc16b]
- Updated dependencies [2d71558]
- Updated dependencies [fad9325]
- @antv/g-lite@2.2.10

## 2.0.25

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-components",
"version": "2.0.25",
"version": "2.0.26",
"description": "Components for g",
"keywords": [
"antv",
Expand Down
10 changes: 10 additions & 0 deletions packages/g-dom-mutation-observer-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @antv/g-dom-mutation-observer-api

## 2.0.26

### Patch Changes

- Updated dependencies [244d6dd]
- Updated dependencies [9ebc16b]
- Updated dependencies [2d71558]
- Updated dependencies [fad9325]
- @antv/g-lite@2.2.10

## 2.0.25

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-dom-mutation-observer-api/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-dom-mutation-observer-api",
"version": "2.0.25",
"version": "2.0.26",
"description": "A simple implementation of DOM MutationObserver API.",
"keywords": [
"antv",
Expand Down
10 changes: 10 additions & 0 deletions packages/g-gesture/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# @antv/g-gesture

## 3.0.26

### Patch Changes

- Updated dependencies [244d6dd]
- Updated dependencies [9ebc16b]
- Updated dependencies [2d71558]
- Updated dependencies [fad9325]
- @antv/g-lite@2.2.10

## 3.0.25

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-gesture/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-gesture",
"version": "3.0.25",
"version": "3.0.26",
"description": "G Gesture",
"keywords": [
"antv",
Expand Down
11 changes: 11 additions & 0 deletions packages/g-image-exporter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# @antv/g-image-exporter

## 1.0.26

### Patch Changes

- 244d6dd: refactor: reduce global redundant code
- Updated dependencies [244d6dd]
- Updated dependencies [9ebc16b]
- Updated dependencies [2d71558]
- Updated dependencies [fad9325]
- @antv/g-lite@2.2.10

## 1.0.25

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-image-exporter/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-image-exporter",
"version": "1.0.25",
"version": "1.0.26",
"description": "A image exporter for G using DOM API",
"keywords": [
"antv",
Expand Down
11 changes: 2 additions & 9 deletions packages/g-image-exporter/src/ImageExporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,16 +188,9 @@ export class ImageExporter {
}

private getOrCreateImage(src: string): Promise<HTMLImageElement> {
// @see https://github.com/antvis/g/issues/938
const { createImage } = this.options.canvas.getConfig();

return new Promise((resolve, reject) => {
let image: HTMLImageElement;
if (createImage) {
image = createImage(src);
} else if (isBrowser) {
image = new window.Image();
}
// @see https://github.com/antvis/g/issues/938
const image = this.options.canvas.getConfig().createImage();

if (image) {
image.onload = () => {
Expand Down
Loading

0 comments on commit ae89121

Please sign in to comment.