@antv/g 5.0.23-alpha.9 → 5.1.0
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/index.umd.min.js +4 -3
- package/es/AbstractRenderer.d.ts +11 -0
- package/es/AbstractRenderer.js +17 -2
- package/es/Canvas.d.ts +1 -1
- package/es/Canvas.js +2 -0
- package/es/css/CSS.d.ts +2 -1
- package/es/css/CSS.js +6 -2
- package/es/css/CSSProperty.d.ts +3 -2
- package/es/css/StyleValueRegistry.d.ts +4 -2
- package/es/css/StyleValueRegistry.js +100 -95
- package/es/css/cssom/CSSNumericValue.js +1 -1
- package/es/css/index.d.ts +2 -1
- package/es/css/index.js +2 -1
- package/es/css/interfaces.d.ts +6 -0
- package/es/css/interfaces.js +2 -0
- package/es/css/layout/FragmentResult.d.ts +32 -0
- package/es/css/layout/FragmentResult.js +32 -0
- package/es/css/layout/LayoutChildren.d.ts +23 -0
- package/es/css/layout/LayoutChildren.js +55 -0
- package/es/css/layout/LayoutContext.d.ts +35 -0
- package/es/css/layout/LayoutContext.js +35 -0
- package/es/css/layout/LayoutDefinition.d.ts +20 -0
- package/es/css/layout/LayoutDefinition.js +9 -0
- package/es/css/layout/LayoutEdges.d.ts +24 -0
- package/es/css/layout/LayoutEdges.js +41 -0
- package/es/css/layout/LayoutEngine.d.ts +41 -0
- package/es/css/layout/LayoutEngine.js +332 -0
- package/es/css/layout/LayoutFragment.d.ts +26 -0
- package/es/css/layout/LayoutFragment.js +28 -0
- package/es/css/layout/LayoutObject.d.ts +46 -0
- package/es/css/layout/LayoutObject.js +172 -0
- package/es/css/layout/LayoutRegistry.d.ts +16 -0
- package/es/css/layout/LayoutRegistry.js +78 -0
- package/es/css/layout/LayoutWorkTask.d.ts +14 -0
- package/es/css/layout/LayoutWorkTask.js +1 -0
- package/es/css/layout/index.d.ts +11 -0
- package/es/css/layout/index.js +11 -0
- package/es/css/layout/types.d.ts +104 -0
- package/es/css/layout/types.js +66 -0
- package/es/css/parser/color.d.ts +1 -1
- package/es/css/parser/color.js +2 -2
- package/es/css/parser/dimension.js +5 -1
- package/es/css/parser/path.d.ts +2 -2
- package/es/css/parser/path.js +9 -2
- package/es/css/parser/points.d.ts +8 -1
- package/es/css/parser/points.js +33 -3
- package/es/css/parser/transform.js +1 -1
- package/es/css/properties/CSSPropertyClipPath.js +7 -1
- package/es/css/properties/CSSPropertyColor.d.ts +1 -1
- package/es/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -1
- package/es/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
- package/es/css/properties/CSSPropertyLocalPosition.js +64 -20
- package/es/css/properties/CSSPropertyPath.d.ts +2 -2
- package/es/css/properties/CSSPropertyPath.js +7 -5
- package/es/css/properties/CSSPropertyPoints.js +3 -4
- package/es/css/properties/CSSPropertyTransform.d.ts +1 -1
- package/es/css/properties/CSSPropertyTransform.js +76 -104
- package/es/display-objects/Circle.d.ts +4 -0
- package/es/display-objects/Circle.js +2 -0
- package/es/display-objects/DisplayObject.d.ts +2 -9
- package/es/display-objects/DisplayObject.js +8 -27
- package/es/display-objects/Ellipse.d.ts +4 -0
- package/es/display-objects/Ellipse.js +2 -0
- package/es/display-objects/Group.d.ts +4 -0
- package/es/display-objects/Group.js +2 -0
- package/es/display-objects/HTML.d.ts +4 -4
- package/es/display-objects/HTML.js +5 -3
- package/es/display-objects/Image.d.ts +4 -0
- package/es/display-objects/Image.js +2 -0
- package/es/display-objects/Line.js +2 -0
- package/es/display-objects/Path.d.ts +2 -2
- package/es/display-objects/Polygon.js +1 -1
- package/es/display-objects/Polyline.js +1 -1
- package/es/display-objects/Rect.d.ts +6 -2
- package/es/display-objects/Rect.js +2 -0
- package/es/display-objects/Text.d.ts +4 -0
- package/es/display-objects/Text.js +2 -0
- package/es/dom/Document.js +2 -2
- package/es/dom/Element.js +1 -0
- package/es/global-module.js +91 -8
- package/es/index.d.ts +3 -0
- package/es/index.js +3 -0
- package/es/plugins/CullingPlugin.d.ts +1 -0
- package/es/plugins/CullingPlugin.js +8 -3
- package/es/plugins/DirtyCheckPlugin.d.ts +1 -0
- package/es/plugins/DirtyCheckPlugin.js +7 -2
- package/es/plugins/EventPlugin.d.ts +1 -0
- package/es/plugins/EventPlugin.js +14 -9
- package/es/plugins/PrepareRendererPlugin.d.ts +1 -0
- package/es/plugins/PrepareRendererPlugin.js +10 -5
- package/es/services/EventService.js +14 -10
- package/es/services/OffscreenCanvasCreator.d.ts +1 -1
- package/es/services/OffscreenCanvasCreator.js +1 -1
- package/es/services/RenderingService.d.ts +18 -18
- package/es/services/RenderingService.js +26 -23
- package/es/services/SceneGraphService.d.ts +2 -0
- package/es/services/SceneGraphService.js +12 -1
- package/es/services/aabb/CircleUpdater.d.ts +0 -2
- package/es/services/aabb/CircleUpdater.js +2 -6
- package/es/services/aabb/EllipseUpdater.d.ts +0 -2
- package/es/services/aabb/EllipseUpdater.js +2 -6
- package/es/services/aabb/LineUpdater.d.ts +0 -2
- package/es/services/aabb/LineUpdater.js +1 -3
- package/es/services/aabb/PathUpdater.d.ts +0 -2
- package/es/services/aabb/PathUpdater.js +1 -5
- package/es/services/aabb/PolylineUpdater.d.ts +0 -2
- package/es/services/aabb/PolylineUpdater.js +1 -3
- package/es/services/aabb/RectUpdater.d.ts +0 -2
- package/es/services/aabb/RectUpdater.js +1 -5
- package/es/services/aabb/TextUpdater.d.ts +7 -0
- package/es/services/aabb/TextUpdater.js +0 -4
- package/es/services/aabb/interfaces.d.ts +0 -3
- package/es/types.d.ts +12 -23
- package/es/types.js +1 -0
- package/es/utils/deferred.d.ts +43 -0
- package/es/utils/deferred.js +117 -0
- package/es/utils/dom.d.ts +2 -0
- package/es/utils/dom.js +8 -0
- package/es/utils/index.d.ts +2 -1
- package/es/utils/index.js +2 -1
- package/es/utils/interpolation.js +3 -9
- package/es/utils/math.js +4 -3
- package/es/utils/path.d.ts +2 -2
- package/es/utils/path.js +61 -24
- package/lib/AbstractRenderer.d.ts +11 -0
- package/lib/AbstractRenderer.js +17 -2
- package/lib/Canvas.d.ts +1 -1
- package/lib/Canvas.js +2 -0
- package/lib/css/CSS.d.ts +2 -1
- package/lib/css/CSS.js +9 -3
- package/lib/css/CSSProperty.d.ts +3 -2
- package/lib/css/StyleValueRegistry.d.ts +4 -2
- package/lib/css/StyleValueRegistry.js +104 -96
- package/lib/css/cssom/CSSNumericValue.js +17 -17
- package/lib/css/index.d.ts +2 -1
- package/lib/css/index.js +25 -12
- package/lib/css/interfaces.d.ts +6 -0
- package/lib/css/interfaces.js +12 -0
- package/lib/css/layout/FragmentResult.d.ts +32 -0
- package/lib/css/layout/FragmentResult.js +51 -0
- package/lib/css/layout/LayoutChildren.d.ts +23 -0
- package/lib/css/layout/LayoutChildren.js +72 -0
- package/lib/css/layout/LayoutContext.d.ts +35 -0
- package/lib/css/layout/LayoutContext.js +49 -0
- package/lib/css/layout/LayoutDefinition.d.ts +20 -0
- package/lib/css/layout/LayoutDefinition.js +16 -0
- package/lib/css/layout/LayoutEdges.d.ts +24 -0
- package/lib/css/layout/LayoutEdges.js +56 -0
- package/lib/css/layout/LayoutEngine.d.ts +41 -0
- package/lib/css/layout/LayoutEngine.js +345 -0
- package/lib/css/layout/LayoutFragment.d.ts +26 -0
- package/lib/css/layout/LayoutFragment.js +44 -0
- package/lib/css/layout/LayoutObject.d.ts +46 -0
- package/lib/css/layout/LayoutObject.js +182 -0
- package/lib/css/layout/LayoutRegistry.d.ts +16 -0
- package/lib/css/layout/LayoutRegistry.js +87 -0
- package/lib/css/layout/LayoutWorkTask.d.ts +14 -0
- package/lib/css/layout/LayoutWorkTask.js +5 -0
- package/lib/css/layout/index.d.ts +11 -0
- package/lib/css/layout/index.js +148 -0
- package/lib/css/layout/types.d.ts +104 -0
- package/lib/css/layout/types.js +74 -0
- package/lib/css/parser/color.d.ts +1 -1
- package/lib/css/parser/color.js +1 -1
- package/lib/css/parser/dimension.js +4 -0
- package/lib/css/parser/path.d.ts +2 -2
- package/lib/css/parser/path.js +9 -2
- package/lib/css/parser/points.d.ts +8 -1
- package/lib/css/parser/points.js +33 -3
- package/lib/css/parser/transform.js +1 -1
- package/lib/css/properties/CSSPropertyClipPath.js +8 -1
- package/lib/css/properties/CSSPropertyColor.d.ts +1 -1
- package/lib/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -1
- package/lib/css/properties/CSSPropertyLocalPosition.d.ts +0 -9
- package/lib/css/properties/CSSPropertyLocalPosition.js +65 -20
- package/lib/css/properties/CSSPropertyPath.d.ts +2 -2
- package/lib/css/properties/CSSPropertyPath.js +7 -5
- package/lib/css/properties/CSSPropertyPoints.js +3 -4
- package/lib/css/properties/CSSPropertyTransform.d.ts +1 -1
- package/lib/css/properties/CSSPropertyTransform.js +75 -103
- package/lib/display-objects/Circle.d.ts +4 -0
- package/lib/display-objects/Circle.js +2 -0
- package/lib/display-objects/DisplayObject.d.ts +2 -9
- package/lib/display-objects/DisplayObject.js +9 -29
- package/lib/display-objects/Ellipse.d.ts +4 -0
- package/lib/display-objects/Ellipse.js +2 -0
- package/lib/display-objects/Group.d.ts +4 -0
- package/lib/display-objects/Group.js +2 -0
- package/lib/display-objects/HTML.d.ts +4 -4
- package/lib/display-objects/HTML.js +5 -3
- package/lib/display-objects/Image.d.ts +4 -0
- package/lib/display-objects/Image.js +2 -0
- package/lib/display-objects/Line.js +2 -0
- package/lib/display-objects/Path.d.ts +2 -2
- package/lib/display-objects/Polygon.js +1 -1
- package/lib/display-objects/Polyline.js +1 -1
- package/lib/display-objects/Rect.d.ts +6 -2
- package/lib/display-objects/Rect.js +2 -0
- package/lib/display-objects/Text.d.ts +4 -0
- package/lib/display-objects/Text.js +2 -0
- package/lib/dom/Document.js +2 -2
- package/lib/dom/Element.js +1 -0
- package/lib/global-module.js +91 -6
- package/lib/index.d.ts +3 -0
- package/lib/index.js +7 -2
- package/lib/plugins/CullingPlugin.d.ts +1 -0
- package/lib/plugins/CullingPlugin.js +7 -3
- package/lib/plugins/DirtyCheckPlugin.d.ts +1 -0
- package/lib/plugins/DirtyCheckPlugin.js +6 -2
- package/lib/plugins/EventPlugin.d.ts +1 -0
- package/lib/plugins/EventPlugin.js +13 -9
- package/lib/plugins/PrepareRendererPlugin.d.ts +1 -0
- package/lib/plugins/PrepareRendererPlugin.js +9 -5
- package/lib/services/EventService.js +14 -10
- package/lib/services/OffscreenCanvasCreator.d.ts +1 -1
- package/lib/services/OffscreenCanvasCreator.js +1 -1
- package/lib/services/RenderingService.d.ts +18 -18
- package/lib/services/RenderingService.js +26 -23
- package/lib/services/SceneGraphService.d.ts +2 -0
- package/lib/services/SceneGraphService.js +15 -1
- package/lib/services/aabb/CircleUpdater.d.ts +0 -2
- package/lib/services/aabb/CircleUpdater.js +2 -6
- package/lib/services/aabb/EllipseUpdater.d.ts +0 -2
- package/lib/services/aabb/EllipseUpdater.js +2 -6
- package/lib/services/aabb/LineUpdater.d.ts +0 -2
- package/lib/services/aabb/LineUpdater.js +1 -3
- package/lib/services/aabb/PathUpdater.d.ts +0 -2
- package/lib/services/aabb/PathUpdater.js +1 -5
- package/lib/services/aabb/PolylineUpdater.d.ts +0 -2
- package/lib/services/aabb/PolylineUpdater.js +1 -3
- package/lib/services/aabb/RectUpdater.d.ts +0 -2
- package/lib/services/aabb/RectUpdater.js +1 -5
- package/lib/services/aabb/TextUpdater.d.ts +7 -0
- package/lib/services/aabb/TextUpdater.js +0 -4
- package/lib/services/aabb/interfaces.d.ts +0 -3
- package/lib/types.d.ts +12 -23
- package/lib/types.js +1 -0
- package/lib/utils/deferred.d.ts +43 -0
- package/lib/utils/deferred.js +131 -0
- package/lib/utils/dom.d.ts +2 -0
- package/lib/utils/dom.js +17 -0
- package/lib/utils/index.d.ts +2 -1
- package/lib/utils/index.js +17 -4
- package/lib/utils/interpolation.js +4 -10
- package/lib/utils/math.js +4 -3
- package/lib/utils/path.d.ts +2 -2
- package/lib/utils/path.js +55 -24
- package/package.json +4 -3
- package/es/css/LayoutRegistry.d.ts +0 -11
- package/es/css/LayoutRegistry.js +0 -22
- package/es/utils/hooks.d.ts +0 -280
- package/es/utils/hooks.js +0 -753
- package/lib/css/LayoutRegistry.d.ts +0 -11
- package/lib/css/LayoutRegistry.js +0 -30
- package/lib/utils/hooks.d.ts +0 -280
- package/lib/utils/hooks.js +0 -759
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Syringe } from 'mana-syringe';
|
|
2
|
+
import { LayoutContext } from './LayoutContext';
|
|
3
|
+
export declare const LayoutFragmentFactory: Syringe.DefinedToken;
|
|
4
|
+
export interface LayoutFragmentFactory<T = void> {
|
|
5
|
+
(options: LayoutFragmentOptions<T>): LayoutFragment<T>;
|
|
6
|
+
}
|
|
7
|
+
export declare const LayoutFragmentOptions: Syringe.DefinedToken;
|
|
8
|
+
export interface LayoutFragmentOptions<T = void> {
|
|
9
|
+
inlineSize: number;
|
|
10
|
+
blockSize: number;
|
|
11
|
+
data: T;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* 布局的结果
|
|
15
|
+
*/
|
|
16
|
+
export declare class LayoutFragment<T = void> {
|
|
17
|
+
protected readonly _layoutContext: LayoutContext;
|
|
18
|
+
protected readonly options: LayoutFragmentOptions<T>;
|
|
19
|
+
layoutContext: LayoutContext;
|
|
20
|
+
readonly inlineSize: number;
|
|
21
|
+
readonly blockSize: number;
|
|
22
|
+
inlineOffset: number;
|
|
23
|
+
blockOffset: number;
|
|
24
|
+
data: T;
|
|
25
|
+
constructor(_layoutContext: LayoutContext, options: LayoutFragmentOptions<T>);
|
|
26
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { __decorate, __metadata, __param } from "tslib";
|
|
2
|
+
import { inject, injectable, Syringe } from 'mana-syringe';
|
|
3
|
+
import { LayoutContext } from './LayoutContext';
|
|
4
|
+
export var LayoutFragmentFactory = Syringe.defineToken('LayoutFragmentFactory');
|
|
5
|
+
export var LayoutFragmentOptions = Syringe.defineToken('LayoutFragmentOptions');
|
|
6
|
+
/**
|
|
7
|
+
* 布局的结果
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
var LayoutFragment =
|
|
11
|
+
/** @class */
|
|
12
|
+
function () {
|
|
13
|
+
function LayoutFragment(_layoutContext, options) {
|
|
14
|
+
this._layoutContext = _layoutContext;
|
|
15
|
+
this.options = options;
|
|
16
|
+
this.layoutContext = _layoutContext;
|
|
17
|
+
this.inlineSize = options.inlineSize;
|
|
18
|
+
this.blockSize = options.blockSize;
|
|
19
|
+
this.inlineOffset = 0;
|
|
20
|
+
this.blockOffset = 0;
|
|
21
|
+
this.data = options.data;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
LayoutFragment = __decorate([injectable(), __param(0, inject(LayoutContext)), __param(1, inject(LayoutFragmentOptions)), __metadata("design:paramtypes", [LayoutContext, Object])], LayoutFragment);
|
|
25
|
+
return LayoutFragment;
|
|
26
|
+
}();
|
|
27
|
+
|
|
28
|
+
export { LayoutFragment };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { ParsedBaseStyleProps } from '../../types';
|
|
2
|
+
import type { LayoutFragment } from './LayoutFragment';
|
|
3
|
+
import type { MeasureFn, IntrinsicSizes } from './types';
|
|
4
|
+
import type { CSSStyleValue } from '../cssom';
|
|
5
|
+
interface LayoutObjectIntrinsicSizes {
|
|
6
|
+
minContentInlineSize: number;
|
|
7
|
+
minContentBlockSize: number;
|
|
8
|
+
maxContentInlineSize: number;
|
|
9
|
+
maxContentBlockSize: number;
|
|
10
|
+
}
|
|
11
|
+
export declare class LayoutObject {
|
|
12
|
+
private id;
|
|
13
|
+
private style;
|
|
14
|
+
private dirty;
|
|
15
|
+
parent?: LayoutObject;
|
|
16
|
+
children: LayoutObject[];
|
|
17
|
+
private internalIntrisicSizes?;
|
|
18
|
+
private computedLayout?;
|
|
19
|
+
get intrisicSizes(): LayoutObjectIntrinsicSizes;
|
|
20
|
+
get childCount(): number;
|
|
21
|
+
private measureFn?;
|
|
22
|
+
constructor(style?: Map<string, any>);
|
|
23
|
+
/**
|
|
24
|
+
* set the intrinsic size of leaf node, different basic shape has different size, compsed shape has
|
|
25
|
+
* @param measure measure function
|
|
26
|
+
*/
|
|
27
|
+
setMeasure(measure: MeasureFn): void;
|
|
28
|
+
setIntrisicSizes(intrisicSizes: IntrinsicSizes): void;
|
|
29
|
+
addChild(child: LayoutObject): void;
|
|
30
|
+
insertChild(index: number, child: LayoutObject): void;
|
|
31
|
+
removeChild(child: LayoutObject): void;
|
|
32
|
+
removeChildAtIndex(index: number): void;
|
|
33
|
+
replaceChildAtIndex(index: number, child: LayoutObject): void;
|
|
34
|
+
setStyle(property: keyof ParsedBaseStyleProps, value: CSSStyleValue): void;
|
|
35
|
+
getStyle(...properties: string[]): Map<any, any>;
|
|
36
|
+
getAllStyle(): Map<string, any>;
|
|
37
|
+
markDirty(): void;
|
|
38
|
+
idDirty(): boolean;
|
|
39
|
+
private getSize;
|
|
40
|
+
computeLayout(): Promise<void>;
|
|
41
|
+
setComputedLayout(computedLayout: LayoutFragment): void;
|
|
42
|
+
getComputedLayout(): LayoutFragment<void>;
|
|
43
|
+
getAllComputedLayout(): void;
|
|
44
|
+
toString(): string;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { __awaiter, __generator } from "tslib";
|
|
2
|
+
import { PropertyName } from './types';
|
|
3
|
+
import { layoutEngine } from '../..';
|
|
4
|
+
var id = 1;
|
|
5
|
+
|
|
6
|
+
var LayoutObject =
|
|
7
|
+
/** @class */
|
|
8
|
+
function () {
|
|
9
|
+
function LayoutObject(style) {
|
|
10
|
+
if (style === void 0) {
|
|
11
|
+
style = new Map();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
this.id = id++;
|
|
15
|
+
this.style = style;
|
|
16
|
+
this.parent = undefined;
|
|
17
|
+
this.children = [];
|
|
18
|
+
this.dirty = false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Object.defineProperty(LayoutObject.prototype, "intrisicSizes", {
|
|
22
|
+
get: function get() {
|
|
23
|
+
return this.internalIntrisicSizes;
|
|
24
|
+
},
|
|
25
|
+
enumerable: false,
|
|
26
|
+
configurable: true
|
|
27
|
+
});
|
|
28
|
+
Object.defineProperty(LayoutObject.prototype, "childCount", {
|
|
29
|
+
get: function get() {
|
|
30
|
+
return this.children.length;
|
|
31
|
+
},
|
|
32
|
+
enumerable: false,
|
|
33
|
+
configurable: true
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* set the intrinsic size of leaf node, different basic shape has different size, compsed shape has
|
|
37
|
+
* @param measure measure function
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
LayoutObject.prototype.setMeasure = function (measure) {
|
|
41
|
+
this.measureFn = measure;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
LayoutObject.prototype.setIntrisicSizes = function (intrisicSizes) {
|
|
45
|
+
this.internalIntrisicSizes = intrisicSizes;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
LayoutObject.prototype.addChild = function (child) {
|
|
49
|
+
var _a;
|
|
50
|
+
|
|
51
|
+
(_a = this.children) === null || _a === void 0 ? void 0 : _a.push(child);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
LayoutObject.prototype.insertChild = function (index, child) {
|
|
55
|
+
this.children.splice(index, 0, child);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
LayoutObject.prototype.removeChild = function (child) {
|
|
59
|
+
var _a;
|
|
60
|
+
|
|
61
|
+
var index = (_a = this.children) === null || _a === void 0 ? void 0 : _a.findIndex(function (node) {
|
|
62
|
+
return node.id === child.id;
|
|
63
|
+
});
|
|
64
|
+
this.removeChildAtIndex(index);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
LayoutObject.prototype.removeChildAtIndex = function (index) {
|
|
68
|
+
this.children.splice(index, 1);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
LayoutObject.prototype.replaceChildAtIndex = function (index, child) {
|
|
72
|
+
this.children.splice(index, 1, child);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
LayoutObject.prototype.setStyle = function (property, value) {
|
|
76
|
+
this.style.set(property, value);
|
|
77
|
+
}; // setStyles(styles: Record<StyleProperty, StyleInputValue>) {
|
|
78
|
+
// this.style = StylePropertyMap.create({ styles }).styles;
|
|
79
|
+
// }
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
LayoutObject.prototype.getStyle = function () {
|
|
83
|
+
var _this = this;
|
|
84
|
+
|
|
85
|
+
var properties = [];
|
|
86
|
+
|
|
87
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
88
|
+
properties[_i] = arguments[_i];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
var returnStyle = new Map();
|
|
92
|
+
properties.forEach(function (prop) {
|
|
93
|
+
var propertyValue = _this.style.get(prop);
|
|
94
|
+
|
|
95
|
+
if (propertyValue) {
|
|
96
|
+
returnStyle.set(prop, propertyValue);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
return returnStyle;
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
LayoutObject.prototype.getAllStyle = function () {
|
|
103
|
+
return this.style;
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
LayoutObject.prototype.markDirty = function () {
|
|
107
|
+
this.dirty = true;
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
LayoutObject.prototype.idDirty = function () {
|
|
111
|
+
return this.dirty;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
LayoutObject.prototype.getSize = function () {
|
|
115
|
+
var _a, _b, _c, _d;
|
|
116
|
+
|
|
117
|
+
var width = (_b = (_a = this.style.get(PropertyName.WIDTH)) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0;
|
|
118
|
+
var height = (_d = (_c = this.style.get(PropertyName.HEIGHT)) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : 0;
|
|
119
|
+
return {
|
|
120
|
+
width: width,
|
|
121
|
+
height: height
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
LayoutObject.prototype.computeLayout = function () {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
127
|
+
var size;
|
|
128
|
+
return __generator(this, function (_a) {
|
|
129
|
+
switch (_a.label) {
|
|
130
|
+
case 0:
|
|
131
|
+
size = this.getSize();
|
|
132
|
+
return [4
|
|
133
|
+
/*yield*/
|
|
134
|
+
, layoutEngine.computeLayout(this, {
|
|
135
|
+
availableInlineSize: size.width,
|
|
136
|
+
availableBlockSize: size.height,
|
|
137
|
+
fixedInlineSize: size.width,
|
|
138
|
+
fixedBlockSize: size.height,
|
|
139
|
+
percentageInlineSize: size.width,
|
|
140
|
+
percentageBlockSize: size.height,
|
|
141
|
+
data: undefined
|
|
142
|
+
})];
|
|
143
|
+
|
|
144
|
+
case 1:
|
|
145
|
+
_a.sent();
|
|
146
|
+
|
|
147
|
+
return [2
|
|
148
|
+
/*return*/
|
|
149
|
+
];
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
LayoutObject.prototype.setComputedLayout = function (computedLayout) {
|
|
156
|
+
this.computedLayout = computedLayout;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
LayoutObject.prototype.getComputedLayout = function () {
|
|
160
|
+
return this.computedLayout;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
LayoutObject.prototype.getAllComputedLayout = function () {};
|
|
164
|
+
|
|
165
|
+
LayoutObject.prototype.toString = function () {
|
|
166
|
+
return "LayoutObject ".concat(this.id);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
return LayoutObject;
|
|
170
|
+
}();
|
|
171
|
+
|
|
172
|
+
export { LayoutObject };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { LayoutDefinitionCtor } from './LayoutDefinition';
|
|
2
|
+
export declare class LayoutRegistry {
|
|
3
|
+
private static reservedLayout;
|
|
4
|
+
registry: Map<string, LayoutDefinitionCtor>;
|
|
5
|
+
get size(): number;
|
|
6
|
+
hasLayout(name: string): boolean;
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param name layout name, default to 'absolute'
|
|
10
|
+
* @returns layout object
|
|
11
|
+
*/
|
|
12
|
+
getLayout(name?: string): LayoutDefinitionCtor;
|
|
13
|
+
updateLayout(name: string, layout: LayoutDefinitionCtor): void;
|
|
14
|
+
registerLayout(name: string, layout: LayoutDefinitionCtor): void;
|
|
15
|
+
deleteLayout(name: string): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { singleton } from 'mana-syringe'; // export const LayoutContribution = Syringe.defineToken('LayoutContribution');
|
|
3
|
+
// // eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
4
|
+
// export interface LayoutContribution {
|
|
5
|
+
// registerLayout: (layoutRegistry: LayoutRegistry) => void;
|
|
6
|
+
// }
|
|
7
|
+
|
|
8
|
+
var LayoutRegistry =
|
|
9
|
+
/** @class */
|
|
10
|
+
function () {
|
|
11
|
+
function LayoutRegistry() {
|
|
12
|
+
this.registry = new Map();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
LayoutRegistry_1 = LayoutRegistry;
|
|
16
|
+
Object.defineProperty(LayoutRegistry.prototype, "size", {
|
|
17
|
+
get: function get() {
|
|
18
|
+
return this.registry.size;
|
|
19
|
+
},
|
|
20
|
+
enumerable: false,
|
|
21
|
+
configurable: true
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
LayoutRegistry.prototype.hasLayout = function (name) {
|
|
25
|
+
return this.registry.has(name);
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @param name layout name, default to 'absolute'
|
|
30
|
+
* @returns layout object
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
LayoutRegistry.prototype.getLayout = function (name) {
|
|
35
|
+
if (name === void 0) {
|
|
36
|
+
name = 'absolute';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (!this.hasLayout(name)) {
|
|
40
|
+
throw new Error("invalid layout property: ".concat(name));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return this.registry.get(name);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
LayoutRegistry.prototype.updateLayout = function (name, layout) {
|
|
47
|
+
this.registry.set(name, layout);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
LayoutRegistry.prototype.registerLayout = function (name, layout) {
|
|
51
|
+
if (name === '') {
|
|
52
|
+
throw new TypeError("layout name cant't be empty");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (LayoutRegistry_1.reservedLayout.includes(name)) {
|
|
56
|
+
throw new Error("layout name '".concat(name, "' is a system reserved layout name, please use another name"));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (this.hasLayout(name)) {
|
|
60
|
+
throw new Error("layout '".concat(name, "' already exist."));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
this.registry.set(name, layout);
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
LayoutRegistry.prototype.deleteLayout = function (name) {
|
|
67
|
+
this.registry.delete(name);
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
var LayoutRegistry_1; // 系统保留的布局名称,外部用户不能使用
|
|
71
|
+
// private static reservedLayout = ['relative', 'absolute', 'fixed', 'flex', 'dagre', 'autolayout'];
|
|
72
|
+
|
|
73
|
+
LayoutRegistry.reservedLayout = [];
|
|
74
|
+
LayoutRegistry = LayoutRegistry_1 = __decorate([singleton()], LayoutRegistry);
|
|
75
|
+
return LayoutRegistry;
|
|
76
|
+
}();
|
|
77
|
+
|
|
78
|
+
export { LayoutRegistry };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Deferred } from '../../utils';
|
|
2
|
+
import type { LayoutChildren } from './LayoutChildren';
|
|
3
|
+
import type { LayoutFragment } from './LayoutFragment';
|
|
4
|
+
import type { IntrinsicSizes, LayoutConstraints, LayoutTaskType } from './types';
|
|
5
|
+
export declare type LayoutWorkTask = {
|
|
6
|
+
layoutConstraints: LayoutConstraints;
|
|
7
|
+
layoutChild: LayoutChildren;
|
|
8
|
+
taskType: LayoutTaskType.Layout;
|
|
9
|
+
deferred: Deferred<LayoutFragment>;
|
|
10
|
+
} | {
|
|
11
|
+
layoutChild: LayoutChildren;
|
|
12
|
+
taskType: LayoutTaskType.IntrinsicSizes;
|
|
13
|
+
deferred: Deferred<IntrinsicSizes>;
|
|
14
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './FragmentResult';
|
|
2
|
+
export * from './LayoutChildren';
|
|
3
|
+
export * from './LayoutContext';
|
|
4
|
+
export * from './LayoutDefinition';
|
|
5
|
+
export * from './LayoutEdges';
|
|
6
|
+
export * from './LayoutEngine';
|
|
7
|
+
export * from './LayoutFragment';
|
|
8
|
+
export * from './LayoutRegistry';
|
|
9
|
+
export * from './LayoutWorkTask';
|
|
10
|
+
export * from './LayoutObject';
|
|
11
|
+
export * from './types';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from './FragmentResult';
|
|
2
|
+
export * from './LayoutChildren';
|
|
3
|
+
export * from './LayoutContext';
|
|
4
|
+
export * from './LayoutDefinition';
|
|
5
|
+
export * from './LayoutEdges';
|
|
6
|
+
export * from './LayoutEngine';
|
|
7
|
+
export * from './LayoutFragment';
|
|
8
|
+
export * from './LayoutRegistry';
|
|
9
|
+
export * from './LayoutWorkTask';
|
|
10
|
+
export * from './LayoutObject';
|
|
11
|
+
export * from './types';
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
export declare type ContextId = string;
|
|
2
|
+
export declare enum LayoutTaskType {
|
|
3
|
+
Layout = "layout",
|
|
4
|
+
IntrinsicSizes = "intrinsic-sizes"
|
|
5
|
+
}
|
|
6
|
+
export interface LayoutOptions {
|
|
7
|
+
/**
|
|
8
|
+
* = "block"
|
|
9
|
+
*/
|
|
10
|
+
childDisplay: ChildDisplayType;
|
|
11
|
+
/**
|
|
12
|
+
* = "block-like
|
|
13
|
+
*/
|
|
14
|
+
sizing: LayoutSizingMode;
|
|
15
|
+
}
|
|
16
|
+
declare enum ChildDisplayType {
|
|
17
|
+
'block' = 0,
|
|
18
|
+
'normal' = 1
|
|
19
|
+
}
|
|
20
|
+
declare enum LayoutSizingMode {
|
|
21
|
+
'block-like' = 0,
|
|
22
|
+
'manual' = 1
|
|
23
|
+
}
|
|
24
|
+
export interface IntrinsicSizes {
|
|
25
|
+
readonly minContentInlineSize: number;
|
|
26
|
+
readonly minContentBlockSize: number;
|
|
27
|
+
readonly maxContentInlineSize: number;
|
|
28
|
+
readonly maxContentBlockSize: number;
|
|
29
|
+
}
|
|
30
|
+
export interface LayoutConstraints<T = void> {
|
|
31
|
+
/**
|
|
32
|
+
* the available space the current layout must respect
|
|
33
|
+
*/
|
|
34
|
+
readonly availableInlineSize: number;
|
|
35
|
+
readonly availableBlockSize: number;
|
|
36
|
+
/**
|
|
37
|
+
* require current layout must to be exact size
|
|
38
|
+
*/
|
|
39
|
+
readonly fixedInlineSize?: number;
|
|
40
|
+
readonly fixedBlockSize?: number;
|
|
41
|
+
/**
|
|
42
|
+
* used to resolve percentage value
|
|
43
|
+
* Web developers should resolve any percentages against the percentage sizes.
|
|
44
|
+
* eg. `const value = constraints.percentageInlineSize * 0.5;`
|
|
45
|
+
*/
|
|
46
|
+
readonly percentageInlineSize: number;
|
|
47
|
+
readonly percentageBlockSize: number;
|
|
48
|
+
readonly data: T;
|
|
49
|
+
}
|
|
50
|
+
export declare enum PropertyName {
|
|
51
|
+
LAYOUT = "display",
|
|
52
|
+
LEFT = "left",
|
|
53
|
+
TOP = "top",
|
|
54
|
+
BOTTOM = "bottom",
|
|
55
|
+
RIGHT = "right",
|
|
56
|
+
WIDTH = "width",
|
|
57
|
+
HEIGHT = "height",
|
|
58
|
+
MIN_WIDTH = "minWidth",
|
|
59
|
+
MAX_WIDTH = "maxWidth",
|
|
60
|
+
MIN_HEIGHT = "minHeight",
|
|
61
|
+
MAX_HEIGHT = "maxHeight",
|
|
62
|
+
BOX_SIZING = "boxSizing",
|
|
63
|
+
PADDING = "padding",
|
|
64
|
+
PADDING_TOP = "paddingTop",
|
|
65
|
+
PADDING_BOTTOM = "paddingBottom",
|
|
66
|
+
PADDING_START = "paddingLeft",
|
|
67
|
+
PADDING_END = "paddingRight",
|
|
68
|
+
MARGIN = "margin",
|
|
69
|
+
MARGIN_TOP = "marginTop",
|
|
70
|
+
MARGIN_BOTTOM = "marginBottom",
|
|
71
|
+
MARGIN_START = "marginLeft",
|
|
72
|
+
MARGIN_END = "marginRight",
|
|
73
|
+
BORDER = "border",
|
|
74
|
+
BORDER_TOP = "borderTop",
|
|
75
|
+
BORDER_BOTTOM = "borderBottom",
|
|
76
|
+
BORDER_START = "borderLeft",
|
|
77
|
+
BORDER_END = "borderRight",
|
|
78
|
+
FLEX_DIRECTION = "flexDirection",
|
|
79
|
+
FLEX_WRAP = "flexWrap",
|
|
80
|
+
FLEX_FLOW = "flexFlow",
|
|
81
|
+
ALIGN_ITEMS = "alignItems",
|
|
82
|
+
ALIGN_CONTENT = "alignContent",
|
|
83
|
+
JUSTIFY_CONTENT = "justifyContent",
|
|
84
|
+
FLEX = "flex",
|
|
85
|
+
ALIGN_SELF = "alignSelf",
|
|
86
|
+
FLEX_SHRINK = "flexShrink",
|
|
87
|
+
FLEX_BASIS = "flexBasis",
|
|
88
|
+
FLEX_GROW = "flexGrow",
|
|
89
|
+
OFFSET_WIDTH = "offsetWidth",
|
|
90
|
+
OFFSET_HEIGHT = "offsetHeight",
|
|
91
|
+
ORDER = "order"
|
|
92
|
+
}
|
|
93
|
+
export declare type MeasureFn = (width?: number, height?: number) => {
|
|
94
|
+
width: number;
|
|
95
|
+
height: number;
|
|
96
|
+
};
|
|
97
|
+
export interface ComputedLayout {
|
|
98
|
+
readonly width: number;
|
|
99
|
+
readonly height: number;
|
|
100
|
+
readonly x: number;
|
|
101
|
+
readonly y: number;
|
|
102
|
+
readonly children: ComputedLayout[];
|
|
103
|
+
}
|
|
104
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export var LayoutTaskType;
|
|
2
|
+
|
|
3
|
+
(function (LayoutTaskType) {
|
|
4
|
+
LayoutTaskType["Layout"] = "layout";
|
|
5
|
+
LayoutTaskType["IntrinsicSizes"] = "intrinsic-sizes";
|
|
6
|
+
})(LayoutTaskType || (LayoutTaskType = {}));
|
|
7
|
+
|
|
8
|
+
var ChildDisplayType;
|
|
9
|
+
|
|
10
|
+
(function (ChildDisplayType) {
|
|
11
|
+
ChildDisplayType[ChildDisplayType["block"] = 0] = "block";
|
|
12
|
+
ChildDisplayType[ChildDisplayType["normal"] = 1] = "normal";
|
|
13
|
+
})(ChildDisplayType || (ChildDisplayType = {}));
|
|
14
|
+
|
|
15
|
+
var LayoutSizingMode;
|
|
16
|
+
|
|
17
|
+
(function (LayoutSizingMode) {
|
|
18
|
+
LayoutSizingMode[LayoutSizingMode["block-like"] = 0] = "block-like";
|
|
19
|
+
LayoutSizingMode[LayoutSizingMode["manual"] = 1] = "manual";
|
|
20
|
+
})(LayoutSizingMode || (LayoutSizingMode = {}));
|
|
21
|
+
|
|
22
|
+
export var PropertyName;
|
|
23
|
+
|
|
24
|
+
(function (PropertyName) {
|
|
25
|
+
PropertyName["LAYOUT"] = "display";
|
|
26
|
+
PropertyName["LEFT"] = "left";
|
|
27
|
+
PropertyName["TOP"] = "top";
|
|
28
|
+
PropertyName["BOTTOM"] = "bottom";
|
|
29
|
+
PropertyName["RIGHT"] = "right";
|
|
30
|
+
PropertyName["WIDTH"] = "width";
|
|
31
|
+
PropertyName["HEIGHT"] = "height";
|
|
32
|
+
PropertyName["MIN_WIDTH"] = "minWidth";
|
|
33
|
+
PropertyName["MAX_WIDTH"] = "maxWidth";
|
|
34
|
+
PropertyName["MIN_HEIGHT"] = "minHeight";
|
|
35
|
+
PropertyName["MAX_HEIGHT"] = "maxHeight";
|
|
36
|
+
PropertyName["BOX_SIZING"] = "boxSizing";
|
|
37
|
+
PropertyName["PADDING"] = "padding";
|
|
38
|
+
PropertyName["PADDING_TOP"] = "paddingTop";
|
|
39
|
+
PropertyName["PADDING_BOTTOM"] = "paddingBottom";
|
|
40
|
+
PropertyName["PADDING_START"] = "paddingLeft";
|
|
41
|
+
PropertyName["PADDING_END"] = "paddingRight";
|
|
42
|
+
PropertyName["MARGIN"] = "margin";
|
|
43
|
+
PropertyName["MARGIN_TOP"] = "marginTop";
|
|
44
|
+
PropertyName["MARGIN_BOTTOM"] = "marginBottom";
|
|
45
|
+
PropertyName["MARGIN_START"] = "marginLeft";
|
|
46
|
+
PropertyName["MARGIN_END"] = "marginRight";
|
|
47
|
+
PropertyName["BORDER"] = "border";
|
|
48
|
+
PropertyName["BORDER_TOP"] = "borderTop";
|
|
49
|
+
PropertyName["BORDER_BOTTOM"] = "borderBottom";
|
|
50
|
+
PropertyName["BORDER_START"] = "borderLeft";
|
|
51
|
+
PropertyName["BORDER_END"] = "borderRight";
|
|
52
|
+
PropertyName["FLEX_DIRECTION"] = "flexDirection";
|
|
53
|
+
PropertyName["FLEX_WRAP"] = "flexWrap";
|
|
54
|
+
PropertyName["FLEX_FLOW"] = "flexFlow";
|
|
55
|
+
PropertyName["ALIGN_ITEMS"] = "alignItems";
|
|
56
|
+
PropertyName["ALIGN_CONTENT"] = "alignContent";
|
|
57
|
+
PropertyName["JUSTIFY_CONTENT"] = "justifyContent";
|
|
58
|
+
PropertyName["FLEX"] = "flex";
|
|
59
|
+
PropertyName["ALIGN_SELF"] = "alignSelf";
|
|
60
|
+
PropertyName["FLEX_SHRINK"] = "flexShrink";
|
|
61
|
+
PropertyName["FLEX_BASIS"] = "flexBasis";
|
|
62
|
+
PropertyName["FLEX_GROW"] = "flexGrow";
|
|
63
|
+
PropertyName["OFFSET_WIDTH"] = "offsetWidth";
|
|
64
|
+
PropertyName["OFFSET_HEIGHT"] = "offsetHeight";
|
|
65
|
+
PropertyName["ORDER"] = "order";
|
|
66
|
+
})(PropertyName || (PropertyName = {}));
|
package/es/css/parser/color.d.ts
CHANGED
|
@@ -2,5 +2,5 @@ import { CSSRGB, CSSGradientValue } from '../cssom';
|
|
|
2
2
|
/**
|
|
3
3
|
* @see https://github.com/WebKit/WebKit/blob/main/Source/WebCore/css/parser/CSSParser.cpp#L97
|
|
4
4
|
*/
|
|
5
|
-
export declare function parseColor(colorStr
|
|
5
|
+
export declare function parseColor(colorStr: string): CSSRGB | CSSGradientValue;
|
|
6
6
|
export declare function mergeColors(left: CSSRGB | CSSGradientValue, right: CSSRGB | CSSGradientValue): [number[], number[], (color: number[]) => string] | undefined;
|
package/es/css/parser/color.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __read, __spreadArray } from "tslib";
|
|
2
2
|
import * as d3 from 'd3-color';
|
|
3
3
|
import { CSSRGB, CSSGradientValue, GradientPatternType } from '../cssom';
|
|
4
|
-
import { clamp, isString } from '../../utils';
|
|
4
|
+
import { clamp, isNil, isString } from '../../utils';
|
|
5
5
|
var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
|
|
6
6
|
var regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;
|
|
7
7
|
var regexPR = /^p\s*\(\s*([axyn])\s*\)\s*(.*)/i;
|
|
@@ -11,7 +11,7 @@ var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/gi;
|
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
13
|
export function parseColor(colorStr) {
|
|
14
|
-
if (colorStr
|
|
14
|
+
if (isNil(colorStr)) {
|
|
15
15
|
colorStr = '';
|
|
16
16
|
}
|
|
17
17
|
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { AABB } from '../../shapes';
|
|
2
|
-
import { isString, rad2deg, turn2deg } from '../../utils';
|
|
2
|
+
import { isNil, isString, rad2deg, turn2deg } from '../../utils';
|
|
3
3
|
import { UnitType } from '../cssom';
|
|
4
4
|
import { CSSUnitValue } from '../cssom';
|
|
5
5
|
export function parseDimension(unitRegExp, string) {
|
|
6
|
+
if (isNil(string)) {
|
|
7
|
+
return new CSSUnitValue(0, 'px');
|
|
8
|
+
}
|
|
9
|
+
|
|
6
10
|
string = "".concat(string).trim().toLowerCase();
|
|
7
11
|
|
|
8
12
|
if (isFinite(Number(string))) {
|
package/es/css/parser/path.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PathCommand } from '../../types';
|
|
2
|
-
import type { ParsedPathStyleProps } from '../../display-objects';
|
|
2
|
+
import type { ParsedPathStyleProps, DisplayObject } from '../../display-objects';
|
|
3
3
|
import type { IElement } from '../../dom';
|
|
4
|
-
export declare function parsePath(path: string): ParsedPathStyleProps['path'];
|
|
4
|
+
export declare function parsePath(path: string, object: DisplayObject): ParsedPathStyleProps['path'];
|
|
5
5
|
export declare function mergePaths(left: ParsedPathStyleProps['path'], right: ParsedPathStyleProps['path'], object: IElement): [PathCommand[], PathCommand[], (b: PathCommand[]) => PathCommand[]];
|
package/es/css/parser/path.js
CHANGED
|
@@ -3,7 +3,7 @@ import { path2Absolute, path2Segments, path2Curve } from '@antv/util';
|
|
|
3
3
|
import { Cubic as CubicUtil } from '@antv/g-math';
|
|
4
4
|
import { clonePath, equalizeSegments, getDrawDirection, getRotatedCurve, reverseCurve } from '../../utils/path';
|
|
5
5
|
import { Rectangle } from '../../shapes/Rectangle';
|
|
6
|
-
export function parsePath(path) {
|
|
6
|
+
export function parsePath(path, object) {
|
|
7
7
|
var absolutePath = path2Absolute(path);
|
|
8
8
|
var hasArc = hasArcOrBezier(absolutePath);
|
|
9
9
|
var clonedAbsolutePath = absolutePath.slice();
|
|
@@ -24,6 +24,13 @@ export function parsePath(path) {
|
|
|
24
24
|
totalLength = _c.totalLength,
|
|
25
25
|
curveSegments = _c.curveSegments;
|
|
26
26
|
|
|
27
|
+
var rect = getPathBBox(curve);
|
|
28
|
+
|
|
29
|
+
if (object) {
|
|
30
|
+
object.parsedStyle.defX = rect.x;
|
|
31
|
+
object.parsedStyle.defY = rect.y;
|
|
32
|
+
}
|
|
33
|
+
|
|
27
34
|
return {
|
|
28
35
|
absolutePath: absolutePath,
|
|
29
36
|
hasArc: hasArc,
|
|
@@ -34,7 +41,7 @@ export function parsePath(path) {
|
|
|
34
41
|
totalLength: totalLength,
|
|
35
42
|
curveSegments: curveSegments,
|
|
36
43
|
zCommandIndexes: zCommandIndexes,
|
|
37
|
-
rect:
|
|
44
|
+
rect: rect
|
|
38
45
|
};
|
|
39
46
|
}
|
|
40
47
|
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import type { DisplayObject } from '../..';
|
|
2
|
+
/**
|
|
3
|
+
* @see https://developer.mozilla.org/zh-CN/docs/Web/SVG/Attribute/points
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* points="100,10 250,150 200,110"
|
|
7
|
+
*/
|
|
8
|
+
export declare function parsePoints(pointsOrStr: string | [number, number][], object: DisplayObject): {
|
|
2
9
|
points: [number, number][];
|
|
3
10
|
totalLength: number;
|
|
4
11
|
segments: [number, number][];
|