@antv/g-lite 1.2.20 → 1.2.21
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/dist/css/CSSProperty.d.ts +7 -0
- package/dist/css/StyleValueRegistry.d.ts +2 -2
- package/dist/css/interfaces.d.ts +3 -2
- package/dist/css/parser/dimension.d.ts +9 -1
- package/dist/css/parser/numeric.d.ts +3 -0
- package/dist/css/parser/transform-origin.d.ts +2 -0
- package/dist/css/parser/transform.d.ts +1 -0
- package/dist/css/properties/CSSPropertyAngle.d.ts +1 -0
- package/dist/css/properties/CSSPropertyLengthOrPercentage.d.ts +5 -1
- package/dist/css/properties/CSSPropertyNumber.d.ts +1 -0
- package/dist/css/properties/CSSPropertyOffsetDistance.d.ts +1 -0
- package/dist/css/properties/CSSPropertyOpacity.d.ts +1 -0
- package/dist/css/properties/CSSPropertyTransform.d.ts +3 -2
- package/dist/css/properties/CSSPropertyTransformOrigin.d.ts +1 -0
- package/dist/css/properties/CSSPropertyZIndex.d.ts +1 -0
- package/dist/display-objects/DisplayObject.d.ts +1 -1
- package/dist/index.esm.js +136 -32
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +136 -32
- package/dist/index.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -22,6 +22,13 @@ export interface CSSProperty<Parsed, Used> {
|
|
|
22
22
|
* '180deg' -> CSS.deg(180)
|
|
23
23
|
*/
|
|
24
24
|
parser: CSSPropertyParser<Parsed>;
|
|
25
|
+
/**
|
|
26
|
+
* Don't use memoize, eg. during animation.
|
|
27
|
+
*/
|
|
28
|
+
parserUnmemoize: CSSPropertyParser<Parsed>;
|
|
29
|
+
/**
|
|
30
|
+
* Ignore CSS syntax.
|
|
31
|
+
*/
|
|
25
32
|
parserWithCSSDisabled: CSSPropertyParser<Parsed>;
|
|
26
33
|
/**
|
|
27
34
|
* convert parsed value to used value.
|
|
@@ -31,11 +31,11 @@ export declare class DefaultStyleValueRegistry implements StyleValueRegistry {
|
|
|
31
31
|
/**
|
|
32
32
|
* string -> parsed value
|
|
33
33
|
*/
|
|
34
|
-
parseProperty(name: string, value: any, object: DisplayObject): CSSStyleValue;
|
|
34
|
+
parseProperty(name: string, value: any, object: DisplayObject, memoized: boolean): CSSStyleValue;
|
|
35
35
|
/**
|
|
36
36
|
* computed value -> used value
|
|
37
37
|
*/
|
|
38
|
-
computeProperty(name: string, computed: CSSStyleValue, object: DisplayObject): any;
|
|
38
|
+
computeProperty(name: string, computed: CSSStyleValue, object: DisplayObject, memoized: boolean): any;
|
|
39
39
|
postProcessProperty(name: string, object: DisplayObject, attributes: string[]): void;
|
|
40
40
|
/**
|
|
41
41
|
* resolve later
|
package/dist/css/interfaces.d.ts
CHANGED
|
@@ -118,6 +118,7 @@ export interface PropertyParseOptions {
|
|
|
118
118
|
skipParse: boolean;
|
|
119
119
|
forceUpdateGeometry: boolean;
|
|
120
120
|
usedAttributes: string[];
|
|
121
|
+
memoize: boolean;
|
|
121
122
|
}
|
|
122
123
|
export interface StyleValueRegistry {
|
|
123
124
|
recalc: (displayObject: DisplayObject) => void;
|
|
@@ -126,8 +127,8 @@ export interface StyleValueRegistry {
|
|
|
126
127
|
getPropertySyntax: (syntax: string) => CSSProperty<any, any>;
|
|
127
128
|
addUnresolveProperty: (object: DisplayObject, name: string) => void;
|
|
128
129
|
processProperties: (object: DisplayObject, attributes: BaseStyleProps, options?: Partial<PropertyParseOptions>) => void;
|
|
129
|
-
parseProperty: (name: string, value: any, object: DisplayObject) => CSSStyleValue;
|
|
130
|
-
computeProperty: (name: string, computed: CSSStyleValue, object: DisplayObject) => any;
|
|
130
|
+
parseProperty: (name: string, value: any, object: DisplayObject, memoized: boolean) => CSSStyleValue;
|
|
131
|
+
computeProperty: (name: string, computed: CSSStyleValue, object: DisplayObject, memoized: boolean) => any;
|
|
131
132
|
}
|
|
132
133
|
export interface LayoutRegistry {
|
|
133
134
|
registerLayout: (name: string, ctor: any) => void;
|
|
@@ -8,6 +8,7 @@ export declare function parseDimension(unitRegExp: RegExp, string: string): CSSS
|
|
|
8
8
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length
|
|
9
9
|
* length with only absolute unit, eg. 1px
|
|
10
10
|
*/
|
|
11
|
+
export declare const parseLengthUnmemoize: (css: string) => CSSStyleValue;
|
|
11
12
|
export declare const parseLength: {
|
|
12
13
|
(...args: any[]): any;
|
|
13
14
|
cache: Map<any, any>;
|
|
@@ -16,6 +17,7 @@ export declare const parseLength: {
|
|
|
16
17
|
* <percentage>
|
|
17
18
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/percentage
|
|
18
19
|
*/
|
|
20
|
+
export declare const parserPercentageUnmemoize: (css: string) => CSSStyleValue;
|
|
19
21
|
export declare const parserPercentage: {
|
|
20
22
|
(...args: any[]): any;
|
|
21
23
|
cache: Map<any, any>;
|
|
@@ -26,7 +28,12 @@ export declare const parserPercentage: {
|
|
|
26
28
|
*
|
|
27
29
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length-percentage
|
|
28
30
|
*/
|
|
29
|
-
export declare const
|
|
31
|
+
export declare const parseLengthOrPercentageUnmemoize: (css: string) => CSSUnitValue;
|
|
32
|
+
export declare const parseLengthOrPercentage: {
|
|
33
|
+
(...args: any[]): any;
|
|
34
|
+
cache: Map<any, any>;
|
|
35
|
+
};
|
|
36
|
+
export declare const parseAngleUnmemoize: (css: string) => CSSUnitValue;
|
|
30
37
|
export declare const parseAngle: {
|
|
31
38
|
(...args: any[]): any;
|
|
32
39
|
cache: Map<any, any>;
|
|
@@ -43,4 +50,5 @@ export declare function mergeDimensions(left: CSSUnitValue, right: CSSUnitValue,
|
|
|
43
50
|
export declare function convertAngleUnit(value: CSSUnitValue): number;
|
|
44
51
|
export declare function parseDimensionArrayFormat(string: string | number | (string | number)[], size: number): number[];
|
|
45
52
|
export declare function parseDimensionArray(string: string | (string | number)[]): CSSUnitValue[];
|
|
53
|
+
export declare function parseDimensionArrayUnmemoize(string: string | (string | number)[]): CSSUnitValue[];
|
|
46
54
|
export declare function convertPercentUnit(valueWithUnit: CSSUnitValue, vec3Index: number, target: DisplayObject): number;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CSSUnitValue } from '../cssom';
|
|
1
2
|
export declare function numberToString(x: number): string;
|
|
2
3
|
/**
|
|
3
4
|
* parse string or number to CSSUnitValue(numeric)
|
|
@@ -6,6 +7,7 @@ export declare function numberToString(x: number): string;
|
|
|
6
7
|
* * 0 -> CSSUnitValue(0)
|
|
7
8
|
* * '2' -> CSSUnitValue(2)
|
|
8
9
|
*/
|
|
10
|
+
export declare const parseNumberUnmemoize: (string: string | number) => CSSUnitValue;
|
|
9
11
|
export declare const parseNumber: {
|
|
10
12
|
(...args: any[]): any;
|
|
11
13
|
cache: Map<any, any>;
|
|
@@ -15,6 +17,7 @@ export declare const parseNumber: {
|
|
|
15
17
|
* eg.
|
|
16
18
|
* * [0.5, 0.5] -> [CSSUnitValue, CSSUnitValue]
|
|
17
19
|
*/
|
|
20
|
+
export declare const parseNumberListUnmemoize: (string: string | number[]) => CSSUnitValue[];
|
|
18
21
|
export declare const parseNumberList: {
|
|
19
22
|
(...args: any[]): any;
|
|
20
23
|
cache: Map<any, any>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CSSUnitValue } from '../cssom';
|
|
1
2
|
/**
|
|
2
3
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/transform-origin
|
|
3
4
|
* eg. 'center' 'top left' '50px 50px'
|
|
@@ -6,3 +7,4 @@ export declare const parseTransformOrigin: {
|
|
|
6
7
|
(...args: any[]): any;
|
|
7
8
|
cache: Map<any, any>;
|
|
8
9
|
};
|
|
10
|
+
export declare const parseTransformOriginUnmemoize: (value: string | number[]) => [CSSUnitValue, CSSUnitValue];
|
|
@@ -10,6 +10,7 @@ export interface ParsedTransform {
|
|
|
10
10
|
* scaleX(1)
|
|
11
11
|
*/
|
|
12
12
|
export declare function parseTransform(string: string): ParsedTransform[];
|
|
13
|
+
export declare function parseTransformUnmemoize(string: string): ParsedTransform[];
|
|
13
14
|
export declare function convertItemToMatrix(item: ParsedTransform): number[];
|
|
14
15
|
export declare const composeMatrix: (translate: any, scale: any, skew: any, quat: any, perspective: any) => number[];
|
|
15
16
|
export declare function mergeTransforms(left: ParsedTransform[], right: ParsedTransform[], target: DisplayObject | null): [number[][], number[][], (d: number[][]) => string];
|
|
@@ -7,6 +7,7 @@ export declare class CSSPropertyAngle implements Partial<CSSProperty<CSSUnitValu
|
|
|
7
7
|
(...args: any[]): any;
|
|
8
8
|
cache: Map<any, any>;
|
|
9
9
|
};
|
|
10
|
+
parserUnmemoize: (css: string) => CSSUnitValue;
|
|
10
11
|
parserWithCSSDisabled: any;
|
|
11
12
|
mixer: typeof mergeNumbers;
|
|
12
13
|
calculator(name: string, oldParsed: CSSUnitValue, parsed: CSSUnitValue, object: DisplayObject): number;
|
|
@@ -7,7 +7,11 @@ import { mergeNumbers } from '../parser';
|
|
|
7
7
|
* <length> & <percentage>
|
|
8
8
|
*/
|
|
9
9
|
export declare class CSSPropertyLengthOrPercentage implements Partial<CSSProperty<CSSUnitValue, number>> {
|
|
10
|
-
parser:
|
|
10
|
+
parser: {
|
|
11
|
+
(...args: any[]): any;
|
|
12
|
+
cache: Map<any, any>;
|
|
13
|
+
};
|
|
14
|
+
parserUnmemoize: (css: string) => CSSUnitValue;
|
|
11
15
|
parserWithCSSDisabled: any;
|
|
12
16
|
mixer: typeof mergeNumbers;
|
|
13
17
|
/**
|
|
@@ -7,6 +7,7 @@ export declare class CSSPropertyNumber implements Partial<CSSProperty<CSSUnitVal
|
|
|
7
7
|
(...args: any[]): any;
|
|
8
8
|
cache: Map<any, any>;
|
|
9
9
|
};
|
|
10
|
+
parserUnmemoize: (string: string | number) => CSSUnitValue;
|
|
10
11
|
parserWithCSSDisabled: any;
|
|
11
12
|
calculator(name: string, oldParsed: CSSUnitValue, computed: CSSUnitValue): number;
|
|
12
13
|
}
|
|
@@ -6,6 +6,7 @@ export declare class CSSPropertyOffsetDistance implements Partial<CSSProperty<CS
|
|
|
6
6
|
(...args: any[]): any;
|
|
7
7
|
cache: Map<any, any>;
|
|
8
8
|
};
|
|
9
|
+
parserUnmemoize: (string: string | number) => CSSUnitValue;
|
|
9
10
|
parserWithCSSDisabled: any;
|
|
10
11
|
calculator(name: string, oldParsed: CSSUnitValue, computed: CSSUnitValue): number;
|
|
11
12
|
mixer: (left: number, right: number) => [number, number, (i: number) => string];
|
|
@@ -8,6 +8,7 @@ export declare class CSSPropertyOpacity implements Partial<CSSProperty<CSSUnitVa
|
|
|
8
8
|
(...args: any[]): any;
|
|
9
9
|
cache: Map<any, any>;
|
|
10
10
|
};
|
|
11
|
+
parserUnmemoize: (string: string | number) => CSSUnitValue;
|
|
11
12
|
parserWithCSSDisabled: any;
|
|
12
13
|
calculator(name: string, oldParsed: CSSUnitValue, computed: CSSUnitValue): number;
|
|
13
14
|
mixer: (left: number, right: number) => [number, number, (i: number) => string];
|
|
@@ -2,7 +2,7 @@ import type { DisplayObject } from '../../display-objects';
|
|
|
2
2
|
import { CSSKeywordValue } from '../cssom';
|
|
3
3
|
import type { CSSProperty } from '../CSSProperty';
|
|
4
4
|
import type { ParsedTransform } from '../parser/transform';
|
|
5
|
-
import { mergeTransforms, parseTransform } from '../parser/transform';
|
|
5
|
+
import { mergeTransforms, parseTransform, parseTransformUnmemoize } from '../parser/transform';
|
|
6
6
|
/**
|
|
7
7
|
* @see /zh/docs/api/animation#支持变换的属性
|
|
8
8
|
*
|
|
@@ -35,7 +35,8 @@ import { mergeTransforms, parseTransform } from '../parser/transform';
|
|
|
35
35
|
*/
|
|
36
36
|
export declare class CSSPropertyTransform implements Partial<CSSProperty<CSSKeywordValue | ParsedTransform[], ParsedTransform[]>> {
|
|
37
37
|
parser: typeof parseTransform;
|
|
38
|
-
|
|
38
|
+
parserUnmemoize: typeof parseTransformUnmemoize;
|
|
39
|
+
parserWithCSSDisabled: typeof parseTransformUnmemoize;
|
|
39
40
|
calculator(name: string, oldParsed: CSSKeywordValue | ParsedTransform[], parsed: CSSKeywordValue | ParsedTransform[], object: DisplayObject): ParsedTransform[];
|
|
40
41
|
mixer: typeof mergeTransforms;
|
|
41
42
|
postProcessor(object: DisplayObject): void;
|
|
@@ -6,6 +6,7 @@ export declare class CSSPropertyZIndex implements Partial<CSSProperty<CSSUnitVal
|
|
|
6
6
|
(...args: any[]): any;
|
|
7
7
|
cache: Map<any, any>;
|
|
8
8
|
};
|
|
9
|
+
parserUnmemoize: (string: string | number) => CSSUnitValue;
|
|
9
10
|
calculator(name: string, oldParsed: CSSUnitValue, computed: CSSUnitValue, object: DisplayObject): number;
|
|
10
11
|
postProcessor(object: DisplayObject): void;
|
|
11
12
|
}
|
|
@@ -46,7 +46,7 @@ export declare class DisplayObject<StyleProps extends BaseStyleProps = any, Pars
|
|
|
46
46
|
destroy(): void;
|
|
47
47
|
cloneNode(deep?: boolean, customCloneFunc?: (name: string, attribute: any) => any): this;
|
|
48
48
|
private initAttributes;
|
|
49
|
-
setAttribute<Key extends keyof StyleProps>(name: Key, value: StyleProps[Key], force?: boolean): void;
|
|
49
|
+
setAttribute<Key extends keyof StyleProps>(name: Key, value: StyleProps[Key], force?: boolean, memoize?: boolean): void;
|
|
50
50
|
/**
|
|
51
51
|
* called when attributes get changed or initialized
|
|
52
52
|
*/
|
package/dist/index.esm.js
CHANGED
|
@@ -3955,29 +3955,25 @@ function parseDimension(unitRegExp, string) {
|
|
|
3955
3955
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length
|
|
3956
3956
|
* length with only absolute unit, eg. 1px
|
|
3957
3957
|
*/
|
|
3958
|
-
var
|
|
3958
|
+
var parseLengthUnmemoize = function (css) {
|
|
3959
3959
|
return parseDimension(new RegExp('px', 'g'), css);
|
|
3960
|
-
}
|
|
3960
|
+
};
|
|
3961
|
+
var parseLength = memoize(parseLengthUnmemoize);
|
|
3961
3962
|
/**
|
|
3962
3963
|
* <percentage>
|
|
3963
3964
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/percentage
|
|
3964
3965
|
*/
|
|
3965
|
-
|
|
3966
|
+
var parserPercentageUnmemoize = function (css) {
|
|
3966
3967
|
return parseDimension(new RegExp('%', 'g'), css);
|
|
3967
|
-
}
|
|
3968
|
+
};
|
|
3969
|
+
memoize(parserPercentageUnmemoize);
|
|
3968
3970
|
/**
|
|
3969
3971
|
* length with absolute or relative unit,
|
|
3970
3972
|
* eg. 1px, 0.7em, 50%, calc(100% - 200px);
|
|
3971
3973
|
*
|
|
3972
3974
|
* @see https://developer.mozilla.org/zh-CN/docs/Web/CSS/length-percentage
|
|
3973
3975
|
*/
|
|
3974
|
-
|
|
3975
|
-
// if (isNumber(css) || isFinite(Number(css))) {
|
|
3976
|
-
// return getOrCreateUnitValue(Number(css), 'px');
|
|
3977
|
-
// }
|
|
3978
|
-
// return parseDimension(new RegExp('px|%|em|rem', 'g'), css) as CSSUnitValue;
|
|
3979
|
-
// });
|
|
3980
|
-
var parseLengthOrPercentage = function (css) {
|
|
3976
|
+
var parseLengthOrPercentageUnmemoize = function (css) {
|
|
3981
3977
|
if (isNumber(css) || isFinite(Number(css))) {
|
|
3982
3978
|
// Number(css) is NaN
|
|
3983
3979
|
return getOrCreateUnitValue(Number(css) || 0, 'px');
|
|
@@ -3985,9 +3981,11 @@ var parseLengthOrPercentage = function (css) {
|
|
|
3985
3981
|
}
|
|
3986
3982
|
return parseDimension(new RegExp('px|%|em|rem', 'g'), css);
|
|
3987
3983
|
};
|
|
3988
|
-
var
|
|
3984
|
+
var parseLengthOrPercentage = memoize(parseLengthOrPercentageUnmemoize);
|
|
3985
|
+
var parseAngleUnmemoize = function (css) {
|
|
3989
3986
|
return parseDimension(new RegExp('deg|rad|grad|turn', 'g'), css);
|
|
3990
|
-
}
|
|
3987
|
+
};
|
|
3988
|
+
var parseAngle = memoize(parseAngleUnmemoize);
|
|
3991
3989
|
/**
|
|
3992
3990
|
* merge CSSUnitValue
|
|
3993
3991
|
*
|
|
@@ -4180,7 +4178,7 @@ function numberToString(x) {
|
|
|
4180
4178
|
* * 0 -> CSSUnitValue(0)
|
|
4181
4179
|
* * '2' -> CSSUnitValue(2)
|
|
4182
4180
|
*/
|
|
4183
|
-
var
|
|
4181
|
+
var parseNumberUnmemoize = function (string) {
|
|
4184
4182
|
if (typeof string === 'number') {
|
|
4185
4183
|
return getOrCreateUnitValue(string);
|
|
4186
4184
|
}
|
|
@@ -4190,12 +4188,8 @@ var parseNumber = memoize(function (string) {
|
|
|
4190
4188
|
else {
|
|
4191
4189
|
return getOrCreateUnitValue(0);
|
|
4192
4190
|
}
|
|
4193
|
-
}
|
|
4194
|
-
|
|
4195
|
-
* separate string to array
|
|
4196
|
-
* eg.
|
|
4197
|
-
* * [0.5, 0.5] -> [CSSUnitValue, CSSUnitValue]
|
|
4198
|
-
*/
|
|
4191
|
+
};
|
|
4192
|
+
var parseNumber = memoize(parseNumberUnmemoize);
|
|
4199
4193
|
memoize(function (string) {
|
|
4200
4194
|
if (isString(string)) {
|
|
4201
4195
|
return string.split(' ').map(parseNumber);
|
|
@@ -5255,6 +5249,68 @@ function parseTransform(string) {
|
|
|
5255
5249
|
}
|
|
5256
5250
|
return [];
|
|
5257
5251
|
}
|
|
5252
|
+
function parseTransformUnmemoize(string) {
|
|
5253
|
+
string = (string || 'none').toLowerCase().trim();
|
|
5254
|
+
if (string === 'none') {
|
|
5255
|
+
return [];
|
|
5256
|
+
}
|
|
5257
|
+
var transformRegExp = /\s*(\w+)\(([^)]*)\)/g;
|
|
5258
|
+
var result = [];
|
|
5259
|
+
var match;
|
|
5260
|
+
var prevLastIndex = 0;
|
|
5261
|
+
while ((match = transformRegExp.exec(string))) {
|
|
5262
|
+
if (match.index !== prevLastIndex) {
|
|
5263
|
+
return [];
|
|
5264
|
+
}
|
|
5265
|
+
prevLastIndex = match.index + match[0].length;
|
|
5266
|
+
var functionName = match[1]; // scale
|
|
5267
|
+
var functionData = transformFunctions[functionName]; // scale(1, 2)
|
|
5268
|
+
if (!functionData) {
|
|
5269
|
+
// invalid, eg. scale()
|
|
5270
|
+
return [];
|
|
5271
|
+
}
|
|
5272
|
+
var args = match[2].split(','); // 1,2
|
|
5273
|
+
var argTypes = functionData[0]; // Nn
|
|
5274
|
+
if (argTypes.length < args.length) {
|
|
5275
|
+
// scale(N, n)
|
|
5276
|
+
return [];
|
|
5277
|
+
}
|
|
5278
|
+
var parsedArgs = [];
|
|
5279
|
+
for (var i = 0; i < argTypes.length; i++) {
|
|
5280
|
+
var arg = args[i];
|
|
5281
|
+
var type = argTypes[i];
|
|
5282
|
+
var parsedArg = void 0;
|
|
5283
|
+
if (!arg) {
|
|
5284
|
+
// @ts-ignore
|
|
5285
|
+
parsedArg = {
|
|
5286
|
+
a: Odeg,
|
|
5287
|
+
n: parsedArgs[0],
|
|
5288
|
+
t: Opx,
|
|
5289
|
+
}[type];
|
|
5290
|
+
}
|
|
5291
|
+
else {
|
|
5292
|
+
// @ts-ignore
|
|
5293
|
+
parsedArg = {
|
|
5294
|
+
A: function (s) {
|
|
5295
|
+
return s.trim() === '0' ? Odeg : parseAngleUnmemoize(s);
|
|
5296
|
+
},
|
|
5297
|
+
N: parseNumberUnmemoize,
|
|
5298
|
+
T: parseLengthOrPercentageUnmemoize,
|
|
5299
|
+
L: parseLengthUnmemoize,
|
|
5300
|
+
}[type.toUpperCase()](arg);
|
|
5301
|
+
}
|
|
5302
|
+
if (parsedArg === undefined) {
|
|
5303
|
+
return [];
|
|
5304
|
+
}
|
|
5305
|
+
parsedArgs.push(parsedArg);
|
|
5306
|
+
}
|
|
5307
|
+
result.push({ t: functionName, d: parsedArgs }); // { t: scale, d: [1, 2] }
|
|
5308
|
+
if (transformRegExp.lastIndex === string.length) {
|
|
5309
|
+
return result;
|
|
5310
|
+
}
|
|
5311
|
+
}
|
|
5312
|
+
return [];
|
|
5313
|
+
}
|
|
5258
5314
|
function convertItemToMatrix(item) {
|
|
5259
5315
|
var x;
|
|
5260
5316
|
var y;
|
|
@@ -5870,6 +5926,39 @@ var parseTransformOrigin = memoize(function (value) {
|
|
|
5870
5926
|
];
|
|
5871
5927
|
}
|
|
5872
5928
|
});
|
|
5929
|
+
var parseTransformOriginUnmemoize = function (value) {
|
|
5930
|
+
if (isString(value)) {
|
|
5931
|
+
if (value === 'text-anchor') {
|
|
5932
|
+
return [getOrCreateUnitValue(0, 'px'), getOrCreateUnitValue(0, 'px')];
|
|
5933
|
+
}
|
|
5934
|
+
var values = value.split(' ');
|
|
5935
|
+
if (values.length === 1) {
|
|
5936
|
+
if (values[0] === 'top' || values[0] === 'bottom') {
|
|
5937
|
+
// 'top' -> 'center top'
|
|
5938
|
+
values[1] = values[0];
|
|
5939
|
+
values[0] = 'center';
|
|
5940
|
+
}
|
|
5941
|
+
else {
|
|
5942
|
+
// '50px' -> '50px center'
|
|
5943
|
+
values[1] = 'center';
|
|
5944
|
+
}
|
|
5945
|
+
}
|
|
5946
|
+
if (values.length !== 2) {
|
|
5947
|
+
return null;
|
|
5948
|
+
}
|
|
5949
|
+
// eg. center bottom
|
|
5950
|
+
return [
|
|
5951
|
+
parseLengthOrPercentageUnmemoize(convertKeyword2Percent(values[0])),
|
|
5952
|
+
parseLengthOrPercentageUnmemoize(convertKeyword2Percent(values[1])),
|
|
5953
|
+
];
|
|
5954
|
+
}
|
|
5955
|
+
else {
|
|
5956
|
+
return [
|
|
5957
|
+
getOrCreateUnitValue(value[0] || 0, 'px'),
|
|
5958
|
+
getOrCreateUnitValue(value[1] || 0, 'px'),
|
|
5959
|
+
];
|
|
5960
|
+
}
|
|
5961
|
+
};
|
|
5873
5962
|
function convertKeyword2Percent(keyword) {
|
|
5874
5963
|
if (keyword === 'center') {
|
|
5875
5964
|
return '50%';
|
|
@@ -6522,6 +6611,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
6522
6611
|
skipParse: false,
|
|
6523
6612
|
forceUpdateGeometry: false,
|
|
6524
6613
|
usedAttributes: [],
|
|
6614
|
+
memoize: true,
|
|
6525
6615
|
}; }
|
|
6526
6616
|
if (!this.runtime.enableCSSParsing) {
|
|
6527
6617
|
Object.assign(object.attributes, attributes);
|
|
@@ -6685,7 +6775,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
6685
6775
|
}
|
|
6686
6776
|
return;
|
|
6687
6777
|
}
|
|
6688
|
-
var skipUpdateAttribute = options.skipUpdateAttribute, skipParse = options.skipParse, forceUpdateGeometry = options.forceUpdateGeometry, usedAttributes = options.usedAttributes;
|
|
6778
|
+
var skipUpdateAttribute = options.skipUpdateAttribute, skipParse = options.skipParse, forceUpdateGeometry = options.forceUpdateGeometry, usedAttributes = options.usedAttributes, memoize = options.memoize;
|
|
6689
6779
|
var needUpdateGeometry = forceUpdateGeometry;
|
|
6690
6780
|
var attributeNames = Object.keys(attributes);
|
|
6691
6781
|
attributeNames.forEach(function (attributeName) {
|
|
@@ -6699,7 +6789,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
6699
6789
|
});
|
|
6700
6790
|
if (!skipParse) {
|
|
6701
6791
|
attributeNames.forEach(function (name) {
|
|
6702
|
-
object.computedStyle[name] = _this.parseProperty(name, object.attributes[name], object);
|
|
6792
|
+
object.computedStyle[name] = _this.parseProperty(name, object.attributes[name], object, memoize);
|
|
6703
6793
|
});
|
|
6704
6794
|
}
|
|
6705
6795
|
// let hasUnresolvedProperties = false;
|
|
@@ -6733,7 +6823,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
6733
6823
|
attributeNames.forEach(function (name) {
|
|
6734
6824
|
// some style props maybe deleted after parsing such as `anchor` in Text
|
|
6735
6825
|
if (name in object.computedStyle) {
|
|
6736
|
-
object.parsedStyle[name] = _this.computeProperty(name, object.computedStyle[name], object);
|
|
6826
|
+
object.parsedStyle[name] = _this.computeProperty(name, object.computedStyle[name], object, memoize);
|
|
6737
6827
|
}
|
|
6738
6828
|
});
|
|
6739
6829
|
// if (hasUnresolvedProperties) {
|
|
@@ -6768,7 +6858,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
6768
6858
|
/**
|
|
6769
6859
|
* string -> parsed value
|
|
6770
6860
|
*/
|
|
6771
|
-
DefaultStyleValueRegistry.prototype.parseProperty = function (name, value, object) {
|
|
6861
|
+
DefaultStyleValueRegistry.prototype.parseProperty = function (name, value, object, memoized) {
|
|
6772
6862
|
var metadata = propertyMetadataCache[name];
|
|
6773
6863
|
var computed = value;
|
|
6774
6864
|
if (value === '' || isNil(value)) {
|
|
@@ -6787,9 +6877,14 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
6787
6877
|
// computed = new CSSKeywordValue(value);
|
|
6788
6878
|
computed = getOrCreateKeyword(value);
|
|
6789
6879
|
}
|
|
6790
|
-
else if (handler
|
|
6791
|
-
|
|
6792
|
-
|
|
6880
|
+
else if (handler) {
|
|
6881
|
+
if (!memoized && handler.parserUnmemoize) {
|
|
6882
|
+
computed = handler.parserUnmemoize(value, object);
|
|
6883
|
+
}
|
|
6884
|
+
else if (handler.parser) {
|
|
6885
|
+
// try to parse it to CSSStyleValue, eg. '10px' -> CSS.px(10)
|
|
6886
|
+
computed = handler.parser(value, object);
|
|
6887
|
+
}
|
|
6793
6888
|
}
|
|
6794
6889
|
}
|
|
6795
6890
|
}
|
|
@@ -6798,7 +6893,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
6798
6893
|
/**
|
|
6799
6894
|
* computed value -> used value
|
|
6800
6895
|
*/
|
|
6801
|
-
DefaultStyleValueRegistry.prototype.computeProperty = function (name, computed, object) {
|
|
6896
|
+
DefaultStyleValueRegistry.prototype.computeProperty = function (name, computed, object, memoized) {
|
|
6802
6897
|
var metadata = propertyMetadataCache[name];
|
|
6803
6898
|
var isDocumentElement = object.id === 'g-root';
|
|
6804
6899
|
// let used: CSSStyleValue = computed instanceof CSSStyleValue ? computed.clone() : computed;
|
|
@@ -6823,7 +6918,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
6823
6918
|
if (!isNil(defaultValue)) {
|
|
6824
6919
|
computed = this.parseProperty(name, isFunction(defaultValue)
|
|
6825
6920
|
? defaultValue(object.nodeName)
|
|
6826
|
-
: defaultValue, object);
|
|
6921
|
+
: defaultValue, object, memoized);
|
|
6827
6922
|
}
|
|
6828
6923
|
}
|
|
6829
6924
|
else if (value === 'inherit') {
|
|
@@ -7091,6 +7186,7 @@ var DefaultStyleValueRegistry = /** @class */ (function () {
|
|
|
7091
7186
|
var CSSPropertyAngle = /** @class */ (function () {
|
|
7092
7187
|
function CSSPropertyAngle() {
|
|
7093
7188
|
this.parser = parseAngle;
|
|
7189
|
+
this.parserUnmemoize = parseAngleUnmemoize;
|
|
7094
7190
|
this.parserWithCSSDisabled = null;
|
|
7095
7191
|
this.mixer = mergeNumbers;
|
|
7096
7192
|
}
|
|
@@ -7165,6 +7261,7 @@ function getFontSize(object) {
|
|
|
7165
7261
|
var CSSPropertyLengthOrPercentage = /** @class */ (function () {
|
|
7166
7262
|
function CSSPropertyLengthOrPercentage() {
|
|
7167
7263
|
this.parser = parseLengthOrPercentage;
|
|
7264
|
+
this.parserUnmemoize = parseLengthOrPercentageUnmemoize;
|
|
7168
7265
|
this.parserWithCSSDisabled = null;
|
|
7169
7266
|
this.mixer = mergeNumbers;
|
|
7170
7267
|
}
|
|
@@ -7486,6 +7583,7 @@ var CSSPropertyNumber = /** @class */ (function () {
|
|
|
7486
7583
|
function CSSPropertyNumber() {
|
|
7487
7584
|
this.mixer = mergeNumbers;
|
|
7488
7585
|
this.parser = parseNumber;
|
|
7586
|
+
this.parserUnmemoize = parseNumberUnmemoize;
|
|
7489
7587
|
this.parserWithCSSDisabled = null;
|
|
7490
7588
|
}
|
|
7491
7589
|
CSSPropertyNumber.prototype.calculator = function (name, oldParsed, computed) {
|
|
@@ -7497,6 +7595,7 @@ var CSSPropertyNumber = /** @class */ (function () {
|
|
|
7497
7595
|
var CSSPropertyOffsetDistance = /** @class */ (function () {
|
|
7498
7596
|
function CSSPropertyOffsetDistance() {
|
|
7499
7597
|
this.parser = parseNumber;
|
|
7598
|
+
this.parserUnmemoize = parseNumberUnmemoize;
|
|
7500
7599
|
this.parserWithCSSDisabled = null;
|
|
7501
7600
|
this.mixer = clampedMergeNumbers(0, 1);
|
|
7502
7601
|
}
|
|
@@ -7530,6 +7629,7 @@ var CSSPropertyOffsetDistance = /** @class */ (function () {
|
|
|
7530
7629
|
var CSSPropertyOpacity = /** @class */ (function () {
|
|
7531
7630
|
function CSSPropertyOpacity() {
|
|
7532
7631
|
this.parser = parseNumber;
|
|
7632
|
+
this.parserUnmemoize = parseNumberUnmemoize;
|
|
7533
7633
|
this.parserWithCSSDisabled = null;
|
|
7534
7634
|
this.mixer = clampedMergeNumbers(0, 1);
|
|
7535
7635
|
}
|
|
@@ -8036,7 +8136,8 @@ function toFontString(attributes) {
|
|
|
8036
8136
|
var CSSPropertyTransform = /** @class */ (function () {
|
|
8037
8137
|
function CSSPropertyTransform() {
|
|
8038
8138
|
this.parser = parseTransform;
|
|
8039
|
-
this.
|
|
8139
|
+
this.parserUnmemoize = parseTransformUnmemoize;
|
|
8140
|
+
this.parserWithCSSDisabled = parseTransformUnmemoize;
|
|
8040
8141
|
this.mixer = mergeTransforms;
|
|
8041
8142
|
}
|
|
8042
8143
|
CSSPropertyTransform.prototype.calculator = function (name, oldParsed, parsed, object) {
|
|
@@ -8061,6 +8162,7 @@ var CSSPropertyTransform = /** @class */ (function () {
|
|
|
8061
8162
|
var CSSPropertyTransformOrigin = /** @class */ (function () {
|
|
8062
8163
|
function CSSPropertyTransformOrigin() {
|
|
8063
8164
|
this.parser = parseTransformOrigin;
|
|
8165
|
+
this.parserUnmemoize = parseTransformOriginUnmemoize;
|
|
8064
8166
|
// calculator(
|
|
8065
8167
|
// name: string,
|
|
8066
8168
|
// oldParsed: [CSSUnitValue, CSSUnitValue],
|
|
@@ -8078,6 +8180,7 @@ var CSSPropertyTransformOrigin = /** @class */ (function () {
|
|
|
8078
8180
|
var CSSPropertyZIndex = /** @class */ (function () {
|
|
8079
8181
|
function CSSPropertyZIndex() {
|
|
8080
8182
|
this.parser = parseNumber;
|
|
8183
|
+
this.parserUnmemoize = parseNumberUnmemoize;
|
|
8081
8184
|
}
|
|
8082
8185
|
CSSPropertyZIndex.prototype.calculator = function (name, oldParsed, computed, object) {
|
|
8083
8186
|
return computed.value;
|
|
@@ -12486,15 +12589,16 @@ var DisplayObject = /** @class */ (function (_super) {
|
|
|
12486
12589
|
// redraw at next frame
|
|
12487
12590
|
renderable.dirty = true;
|
|
12488
12591
|
};
|
|
12489
|
-
DisplayObject.prototype.setAttribute = function (name, value, force) {
|
|
12592
|
+
DisplayObject.prototype.setAttribute = function (name, value, force, memoize) {
|
|
12490
12593
|
if (force === void 0) { force = false; }
|
|
12594
|
+
if (memoize === void 0) { memoize = true; }
|
|
12491
12595
|
var attributeName = formatAttributeName(name);
|
|
12492
12596
|
// ignore undefined value
|
|
12493
12597
|
if (isUndefined(value)) {
|
|
12494
12598
|
return;
|
|
12495
12599
|
}
|
|
12496
12600
|
if (force || value !== this.attributes[attributeName]) {
|
|
12497
|
-
this.internalSetAttribute(attributeName, value);
|
|
12601
|
+
this.internalSetAttribute(attributeName, value, { memoize: memoize });
|
|
12498
12602
|
_super.prototype.setAttribute.call(this, attributeName, value);
|
|
12499
12603
|
}
|
|
12500
12604
|
};
|