Skip to content

Commit

Permalink
Release (#1622)
Browse files Browse the repository at this point in the history
* fix: disable memoize during interpolation #1618 (#1620)

* fix: disable memoize during interpolation #1618

* chore: commit changeset

* chore(release): bump version (#1621)

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

---------

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
3 people authored Jan 10, 2024
1 parent f9512fe commit 76b373f
Show file tree
Hide file tree
Showing 115 changed files with 712 additions and 81 deletions.
28 changes: 28 additions & 0 deletions __tests__/demos/2d/circles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Circle, runtime } from '../../../packages/g';

export async function circles(context) {
runtime.enableCSSParsing = false;

const { canvas } = context;
await canvas.ready;

for (let i = 0; i < 50000; i++) {
const circle = new Circle({
style: {
cx: Math.random() * 500,
cy: Math.random() * 500,
r: 5,
fill: 'red',
stroke: 'blue',
},
});
canvas.appendChild(circle);

circle.addEventListener('mouseenter', () => {
circle.style.fill = 'green';
});
circle.addEventListener('mouseleave', () => {
circle.style.fill = 'red';
});
}
}
1 change: 1 addition & 0 deletions __tests__/demos/lottie/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { spring } from './spring';
14 changes: 14 additions & 0 deletions __tests__/demos/lottie/spring.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { runtime } from '../../../packages/g';
import { loadAnimation } from '../../../packages/g-lottie-player';
import * as d3 from 'd3';

export async function spring(context) {
runtime.enableCSSParsing = true;

const { canvas } = context;
await canvas.ready;

const data = await d3.json('/lottie/spring.json');
const animation = loadAnimation(data, { loop: true, autoplay: true });
const wrapper = animation.render(canvas);
}
2 changes: 2 additions & 0 deletions __tests__/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import * as animation from './demos/animation';
import * as d3 from './demos/d3';
import * as plugin from './demos/plugin';
import * as hammerjs from './demos/hammerjs';
import * as lottie from './demos/lottie';
import * as bugfix from './demos/bugfix';

const tests = {
Expand All @@ -21,6 +22,7 @@ const tests = {
...createSpecRender(namespace(d3, 'd3')),
...createSpecRender(namespace(plugin, 'plugin')),
...createSpecRender(namespace(hammerjs, 'hammerjs')),
...createSpecRender(namespace(lottie, 'lottie')),
...createSpecRender(namespace(bugfix, 'bugfix')),
};

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

## 1.2.22

### Patch Changes

- Updated dependencies [5f5cf270]
- @antv/g-lite@1.2.21

## 1.2.21

### 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": "1.2.21",
"version": "1.2.22",
"description": "A simple implementation of Camera API.",
"keywords": [
"antv",
Expand Down
13 changes: 13 additions & 0 deletions packages/g-canvas/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# @antv/g-canvas

## 1.11.26

### Patch Changes

- Updated dependencies [5f5cf270]
- @antv/g-lite@1.2.21
- @antv/g-plugin-canvas-path-generator@1.3.21
- @antv/g-plugin-canvas-picker@1.10.23
- @antv/g-plugin-canvas-renderer@1.9.23
- @antv/g-plugin-dom-interaction@1.9.21
- @antv/g-plugin-html-renderer@1.9.24
- @antv/g-plugin-image-loader@1.3.21

## 1.11.25

### 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": "1.11.25",
"version": "1.11.26",
"description": "A renderer implemented by Canvas 2D API",
"keywords": [
"antv",
Expand Down
13 changes: 13 additions & 0 deletions packages/g-canvaskit/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# @antv/g-canvaskit

## 0.10.26

### Patch Changes

- Updated dependencies [5f5cf270]
- @antv/g-lite@1.2.21
- @antv/g-plugin-canvas-path-generator@1.3.21
- @antv/g-plugin-canvas-picker@1.10.23
- @antv/g-plugin-canvaskit-renderer@1.3.22
- @antv/g-plugin-dom-interaction@1.9.21
- @antv/g-plugin-html-renderer@1.9.24
- @antv/g-plugin-image-loader@1.3.21

## 0.10.25

### 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": "0.10.25",
"version": "0.10.26",
"description": "A renderer implemented by CanvasKit",
"keywords": [
"antv",
Expand Down
7 changes: 7 additions & 0 deletions packages/g-components/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @antv/g-components

## 1.9.21

### Patch Changes

- Updated dependencies [5f5cf270]
- @antv/g-lite@1.2.21

## 1.9.20

### 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": "1.9.20",
"version": "1.9.21",
"description": "Components for g",
"keywords": [
"antv",
Expand Down
7 changes: 7 additions & 0 deletions packages/g-dom-mutation-observer-api/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @antv/g-dom-mutation-observer-api

## 1.2.21

### Patch Changes

- Updated dependencies [5f5cf270]
- @antv/g-lite@1.2.21

## 1.2.20

### 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": "1.2.20",
"version": "1.2.21",
"description": "A simple implementation of DOM MutationObserver API.",
"keywords": [
"antv",
Expand Down
7 changes: 7 additions & 0 deletions packages/g-gesture/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @antv/g-gesture

## 2.2.24

### Patch Changes

- Updated dependencies [5f5cf270]
- @antv/g-lite@1.2.21

## 2.2.23

### 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": "2.2.23",
"version": "2.2.24",
"description": "G Gesture",
"keywords": [
"antv",
Expand Down
7 changes: 7 additions & 0 deletions packages/g-image-exporter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# @antv/g-image-exporter

## 0.7.21

### Patch Changes

- Updated dependencies [5f5cf270]
- @antv/g-lite@1.2.21

## 0.7.20

### 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": "0.7.20",
"version": "0.7.21",
"description": "A image exporter for G using DOM API",
"keywords": [
"antv",
Expand Down
6 changes: 6 additions & 0 deletions packages/g-lite/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @antv/g-lite

## 1.2.21

### Patch Changes

- 5f5cf270: Disable memoize during interpolation to avoid OOM.

## 1.2.20

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/g-lite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@antv/g-lite",
"version": "1.2.20",
"version": "1.2.21",
"description": "A core module for rendering engine implements DOM API.",
"keywords": [
"antv",
Expand Down
9 changes: 9 additions & 0 deletions packages/g-lite/src/css/CSSProperty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ export interface CSSProperty<Parsed, Used> {
* '180deg' -> CSS.deg(180)
*/
parser: CSSPropertyParser<Parsed>;

/**
* Don't use memoize, eg. during animation.
*/
parserUnmemoize: CSSPropertyParser<Parsed>;

/**
* Ignore CSS syntax.
*/
parserWithCSSDisabled: CSSPropertyParser<Parsed>;

/**
Expand Down
17 changes: 14 additions & 3 deletions packages/g-lite/src/css/StyleValueRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,7 @@ export class DefaultStyleValueRegistry implements StyleValueRegistry {
skipParse: false,
forceUpdateGeometry: false,
usedAttributes: [],
memoize: true,
},
) {
if (!this.runtime.enableCSSParsing) {
Expand Down Expand Up @@ -932,6 +933,7 @@ export class DefaultStyleValueRegistry implements StyleValueRegistry {
skipParse,
forceUpdateGeometry,
usedAttributes,
memoize,
} = options;

let needUpdateGeometry = forceUpdateGeometry;
Expand All @@ -953,6 +955,7 @@ export class DefaultStyleValueRegistry implements StyleValueRegistry {
name as string,
object.attributes[name],
object,
memoize,
);
});
}
Expand Down Expand Up @@ -997,6 +1000,7 @@ export class DefaultStyleValueRegistry implements StyleValueRegistry {
name as string,
object.computedStyle[name],
object,
memoize,
);
}
});
Expand Down Expand Up @@ -1041,6 +1045,7 @@ export class DefaultStyleValueRegistry implements StyleValueRegistry {
name: string,
value: any,
object: DisplayObject,
memoized: boolean,
): CSSStyleValue {
const metadata = propertyMetadataCache[name];

Expand All @@ -1061,9 +1066,13 @@ export class DefaultStyleValueRegistry implements StyleValueRegistry {
if (keywords && keywords.indexOf(value) > -1) {
// computed = new CSSKeywordValue(value);
computed = getOrCreateKeyword(value);
} else if (handler && handler.parser) {
// try to parse it to CSSStyleValue, eg. '10px' -> CSS.px(10)
computed = handler.parser(value, object);
} else if (handler) {
if (!memoized && handler.parserUnmemoize) {
computed = handler.parserUnmemoize(value, object);
} else if (handler.parser) {
// try to parse it to CSSStyleValue, eg. '10px' -> CSS.px(10)
computed = handler.parser(value, object);
}
}
}
}
Expand All @@ -1078,6 +1087,7 @@ export class DefaultStyleValueRegistry implements StyleValueRegistry {
name: string,
computed: CSSStyleValue,
object: DisplayObject,
memoized: boolean,
) {
const metadata = propertyMetadataCache[name];
const isDocumentElement = object.id === 'g-root';
Expand Down Expand Up @@ -1110,6 +1120,7 @@ export class DefaultStyleValueRegistry implements StyleValueRegistry {
? defaultValue(object.nodeName)
: defaultValue,
object,
memoized,
);
}
} else if (value === 'inherit') {
Expand Down
3 changes: 3 additions & 0 deletions packages/g-lite/src/css/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export interface PropertyParseOptions {
skipParse: boolean;
forceUpdateGeometry: boolean;
usedAttributes: string[];
memoize: boolean;
}

export interface StyleValueRegistry {
Expand All @@ -150,11 +151,13 @@ export interface StyleValueRegistry {
name: string,
value: any,
object: DisplayObject,
memoized: boolean,
) => CSSStyleValue;
computeProperty: (
name: string,
computed: CSSStyleValue,
object: DisplayObject,
memoized: boolean,
) => any;
}

Expand Down
Loading

0 comments on commit 76b373f

Please sign in to comment.