@antv/g 5.0.23-alpha.8 → 5.0.24

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.
Files changed (150) hide show
  1. package/dist/index.umd.min.js +4 -3
  2. package/es/AbstractRenderer.d.ts +11 -0
  3. package/es/AbstractRenderer.js +17 -2
  4. package/es/Canvas.d.ts +1 -1
  5. package/es/css/CSS.d.ts +2 -1
  6. package/es/css/CSS.js +6 -2
  7. package/es/css/CSSProperty.d.ts +1 -1
  8. package/es/css/StyleValueRegistry.d.ts +2 -1
  9. package/es/css/StyleValueRegistry.js +34 -25
  10. package/es/css/cssom/CSSNumericValue.js +1 -1
  11. package/es/css/index.d.ts +2 -1
  12. package/es/css/index.js +2 -1
  13. package/es/css/interfaces.d.ts +6 -0
  14. package/es/css/interfaces.js +2 -0
  15. package/es/css/layout/FragmentResult.d.ts +32 -0
  16. package/es/css/layout/FragmentResult.js +32 -0
  17. package/es/css/layout/LayoutChildren.d.ts +23 -0
  18. package/es/css/layout/LayoutChildren.js +55 -0
  19. package/es/css/layout/LayoutContext.d.ts +35 -0
  20. package/es/css/layout/LayoutContext.js +35 -0
  21. package/es/css/layout/LayoutDefinition.d.ts +20 -0
  22. package/es/css/layout/LayoutDefinition.js +9 -0
  23. package/es/css/layout/LayoutEdges.d.ts +24 -0
  24. package/es/css/layout/LayoutEdges.js +41 -0
  25. package/es/css/layout/LayoutEngine.d.ts +41 -0
  26. package/es/css/layout/LayoutEngine.js +332 -0
  27. package/es/css/layout/LayoutFragment.d.ts +26 -0
  28. package/es/css/layout/LayoutFragment.js +28 -0
  29. package/es/css/layout/LayoutObject.d.ts +46 -0
  30. package/es/css/layout/LayoutObject.js +172 -0
  31. package/es/css/layout/LayoutRegistry.d.ts +16 -0
  32. package/es/css/layout/LayoutRegistry.js +78 -0
  33. package/es/css/layout/LayoutWorkTask.d.ts +14 -0
  34. package/es/css/layout/LayoutWorkTask.js +1 -0
  35. package/es/css/layout/index.d.ts +11 -0
  36. package/es/css/layout/index.js +11 -0
  37. package/es/css/layout/types.d.ts +104 -0
  38. package/es/css/layout/types.js +66 -0
  39. package/es/css/parser/numeric.d.ts +1 -1
  40. package/es/css/parser/numeric.js +1 -1
  41. package/es/css/parser/transform.js +5 -4
  42. package/es/css/properties/CSSPropertyColor.d.ts +1 -1
  43. package/es/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -1
  44. package/es/display-objects/DisplayObject.d.ts +1 -2
  45. package/es/display-objects/DisplayObject.js +2 -1
  46. package/es/dom/Document.js +2 -2
  47. package/es/global-module.js +91 -8
  48. package/es/index.d.ts +3 -0
  49. package/es/index.js +3 -0
  50. package/es/plugins/CullingPlugin.d.ts +1 -0
  51. package/es/plugins/CullingPlugin.js +8 -3
  52. package/es/plugins/DirtyCheckPlugin.d.ts +1 -0
  53. package/es/plugins/DirtyCheckPlugin.js +7 -2
  54. package/es/plugins/EventPlugin.d.ts +1 -0
  55. package/es/plugins/EventPlugin.js +14 -9
  56. package/es/plugins/PrepareRendererPlugin.d.ts +1 -0
  57. package/es/plugins/PrepareRendererPlugin.js +10 -5
  58. package/es/services/EventService.js +4 -8
  59. package/es/services/OffscreenCanvasCreator.d.ts +1 -1
  60. package/es/services/OffscreenCanvasCreator.js +1 -1
  61. package/es/services/RenderingService.d.ts +18 -18
  62. package/es/services/RenderingService.js +26 -23
  63. package/es/services/SceneGraphService.js +3 -1
  64. package/es/types.d.ts +7 -5
  65. package/es/utils/deferred.d.ts +43 -0
  66. package/es/utils/deferred.js +117 -0
  67. package/es/utils/dom.d.ts +2 -0
  68. package/es/utils/dom.js +8 -0
  69. package/es/utils/index.d.ts +2 -1
  70. package/es/utils/index.js +2 -1
  71. package/es/utils/interpolation.js +1 -1
  72. package/lib/AbstractRenderer.d.ts +11 -0
  73. package/lib/AbstractRenderer.js +17 -2
  74. package/lib/Canvas.d.ts +1 -1
  75. package/lib/css/CSS.d.ts +2 -1
  76. package/lib/css/CSS.js +9 -3
  77. package/lib/css/CSSProperty.d.ts +1 -1
  78. package/lib/css/StyleValueRegistry.d.ts +2 -1
  79. package/lib/css/StyleValueRegistry.js +39 -27
  80. package/lib/css/cssom/CSSNumericValue.js +17 -17
  81. package/lib/css/index.d.ts +2 -1
  82. package/lib/css/index.js +25 -12
  83. package/lib/css/interfaces.d.ts +6 -0
  84. package/lib/css/interfaces.js +12 -0
  85. package/lib/css/layout/FragmentResult.d.ts +32 -0
  86. package/lib/css/layout/FragmentResult.js +51 -0
  87. package/lib/css/layout/LayoutChildren.d.ts +23 -0
  88. package/lib/css/layout/LayoutChildren.js +72 -0
  89. package/lib/css/layout/LayoutContext.d.ts +35 -0
  90. package/lib/css/layout/LayoutContext.js +49 -0
  91. package/lib/css/layout/LayoutDefinition.d.ts +20 -0
  92. package/lib/css/layout/LayoutDefinition.js +16 -0
  93. package/lib/css/layout/LayoutEdges.d.ts +24 -0
  94. package/lib/css/layout/LayoutEdges.js +56 -0
  95. package/lib/css/layout/LayoutEngine.d.ts +41 -0
  96. package/lib/css/layout/LayoutEngine.js +345 -0
  97. package/lib/css/layout/LayoutFragment.d.ts +26 -0
  98. package/lib/css/layout/LayoutFragment.js +44 -0
  99. package/lib/css/layout/LayoutObject.d.ts +46 -0
  100. package/lib/css/layout/LayoutObject.js +182 -0
  101. package/lib/css/layout/LayoutRegistry.d.ts +16 -0
  102. package/lib/css/layout/LayoutRegistry.js +87 -0
  103. package/lib/css/layout/LayoutWorkTask.d.ts +14 -0
  104. package/lib/css/layout/LayoutWorkTask.js +5 -0
  105. package/lib/css/layout/index.d.ts +11 -0
  106. package/lib/css/layout/index.js +148 -0
  107. package/lib/css/layout/types.d.ts +104 -0
  108. package/lib/css/layout/types.js +74 -0
  109. package/lib/css/parser/numeric.d.ts +1 -1
  110. package/lib/css/parser/numeric.js +4 -4
  111. package/lib/css/parser/transform.js +6 -4
  112. package/lib/css/properties/CSSPropertyColor.d.ts +1 -1
  113. package/lib/css/properties/CSSPropertyLengthOrPercentage.d.ts +1 -1
  114. package/lib/display-objects/DisplayObject.d.ts +1 -2
  115. package/lib/display-objects/DisplayObject.js +3 -2
  116. package/lib/dom/Document.js +2 -2
  117. package/lib/global-module.js +91 -6
  118. package/lib/index.d.ts +3 -0
  119. package/lib/index.js +7 -2
  120. package/lib/plugins/CullingPlugin.d.ts +1 -0
  121. package/lib/plugins/CullingPlugin.js +7 -3
  122. package/lib/plugins/DirtyCheckPlugin.d.ts +1 -0
  123. package/lib/plugins/DirtyCheckPlugin.js +6 -2
  124. package/lib/plugins/EventPlugin.d.ts +1 -0
  125. package/lib/plugins/EventPlugin.js +13 -9
  126. package/lib/plugins/PrepareRendererPlugin.d.ts +1 -0
  127. package/lib/plugins/PrepareRendererPlugin.js +9 -5
  128. package/lib/services/EventService.js +4 -8
  129. package/lib/services/OffscreenCanvasCreator.d.ts +1 -1
  130. package/lib/services/OffscreenCanvasCreator.js +1 -1
  131. package/lib/services/RenderingService.d.ts +18 -18
  132. package/lib/services/RenderingService.js +26 -23
  133. package/lib/services/SceneGraphService.js +3 -1
  134. package/lib/types.d.ts +7 -5
  135. package/lib/utils/deferred.d.ts +43 -0
  136. package/lib/utils/deferred.js +131 -0
  137. package/lib/utils/dom.d.ts +2 -0
  138. package/lib/utils/dom.js +17 -0
  139. package/lib/utils/index.d.ts +2 -1
  140. package/lib/utils/index.js +17 -4
  141. package/lib/utils/interpolation.js +2 -2
  142. package/package.json +4 -3
  143. package/es/css/LayoutRegistry.d.ts +0 -11
  144. package/es/css/LayoutRegistry.js +0 -22
  145. package/es/utils/hooks.d.ts +0 -280
  146. package/es/utils/hooks.js +0 -753
  147. package/lib/css/LayoutRegistry.d.ts +0 -11
  148. package/lib/css/LayoutRegistry.js +0 -30
  149. package/lib/utils/hooks.d.ts +0 -280
  150. package/lib/utils/hooks.js +0 -759
@@ -1,6 +1,7 @@
1
1
  import type { Syringe } from 'mana-syringe';
2
2
  import type { RendererConfig } from './types';
3
3
  export interface RendererPlugin {
4
+ name: string;
4
5
  init: (container: Syringe.Container) => void;
5
6
  destroy: (container: Syringe.Container) => void;
6
7
  }
@@ -10,6 +11,14 @@ export interface IRenderer {
10
11
  * register plugin at runtime
11
12
  */
12
13
  registerPlugin: (plugin: RendererPlugin) => void;
14
+ /**
15
+ * unregister plugin at runtime
16
+ */
17
+ unregisterPlugin: (plugin: RendererPlugin) => void;
18
+ /**
19
+ * get plugin by name
20
+ */
21
+ getPlugin: (name: string) => RendererPlugin;
13
22
  /**
14
23
  * return all registered plugins
15
24
  */
@@ -20,7 +29,9 @@ export declare class AbstractRenderer implements IRenderer {
20
29
  private config;
21
30
  constructor(config?: Partial<RendererConfig>);
22
31
  registerPlugin(plugin: RendererPlugin): void;
32
+ unregisterPlugin(plugin: RendererPlugin): void;
23
33
  getPlugins(): RendererPlugin[];
34
+ getPlugin(name: string): RendererPlugin;
24
35
  getConfig(): RendererConfig;
25
36
  setConfig(config: Partial<RendererConfig>): void;
26
37
  }
@@ -20,8 +20,7 @@ function () {
20
20
  * enable dirty rectangle rendering by default
21
21
  */
22
22
  enableDirtyRectangleRendering: true,
23
- enableDirtyRectangleRenderingDebug: false,
24
- enableTAA: false
23
+ enableDirtyRectangleRenderingDebug: false
25
24
  }, config);
26
25
  }
27
26
 
@@ -29,10 +28,26 @@ function () {
29
28
  this.plugins.push(plugin);
30
29
  };
31
30
 
31
+ AbstractRenderer.prototype.unregisterPlugin = function (plugin) {
32
+ var index = this.plugins.findIndex(function (p) {
33
+ return p === plugin;
34
+ });
35
+
36
+ if (index > -1) {
37
+ this.plugins.splice(index, 1);
38
+ }
39
+ };
40
+
32
41
  AbstractRenderer.prototype.getPlugins = function () {
33
42
  return this.plugins;
34
43
  };
35
44
 
45
+ AbstractRenderer.prototype.getPlugin = function (name) {
46
+ return this.plugins.find(function (plugin) {
47
+ return plugin.name === name;
48
+ });
49
+ };
50
+
36
51
  AbstractRenderer.prototype.getConfig = function () {
37
52
  return this.config;
38
53
  };
package/es/Canvas.d.ts CHANGED
@@ -96,7 +96,7 @@ export declare class Canvas extends EventTarget implements ICanvas {
96
96
  * get the root displayObject in scenegraph
97
97
  * @alias this.document.documentElement
98
98
  */
99
- getRoot(): import("./display-objects").Group;
99
+ getRoot(): import(".").Group;
100
100
  /**
101
101
  * get the camera of canvas
102
102
  */
package/es/css/CSS.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { CSSUnitValue } from './cssom';
2
+ import type { LayoutDefinitionCtor } from './layout';
2
3
  /**
3
4
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CSS/RegisterProperty#parameters
4
5
  */
@@ -80,5 +81,5 @@ export declare const CSS: {
80
81
  * @see https://github.com/w3c/css-houdini-drafts/blob/main/css-layout-api/EXPLAINER.md
81
82
  * @see https://developer.mozilla.org/en-US/docs/Web/Guide/Houdini#css_layout_api
82
83
  */
83
- registerLayout: (name: string) => void;
84
+ registerLayout: (name: string, clazz: LayoutDefinitionCtor) => void;
84
85
  };
package/es/css/CSS.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import { GlobalContainer } from 'mana-syringe';
2
2
  import { CSSUnitValue } from './cssom';
3
- import { StyleValueRegistry } from './StyleValueRegistry';
3
+ import { StyleValueRegistry } from './interfaces';
4
+ import { LayoutRegistry } from './layout';
4
5
  /**
5
6
  * holds useful CSS-related methods.
6
7
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CSS
@@ -109,5 +110,8 @@ export var CSS = {
109
110
  * @see https://github.com/w3c/css-houdini-drafts/blob/main/css-layout-api/EXPLAINER.md
110
111
  * @see https://developer.mozilla.org/en-US/docs/Web/Guide/Houdini#css_layout_api
111
112
  */
112
- registerLayout: function registerLayout(name) {}
113
+ registerLayout: function registerLayout(name, clazz) {
114
+ var layoutRegistry = GlobalContainer.get(LayoutRegistry);
115
+ layoutRegistry.registerLayout(name, clazz);
116
+ }
113
117
  };
@@ -1,5 +1,5 @@
1
1
  import type { IElement } from '../dom';
2
- import type { StyleValueRegistry } from './StyleValueRegistry';
2
+ import type { StyleValueRegistry } from './interfaces';
3
3
  export declare type Interpolatable = number | boolean | number[] | boolean[];
4
4
  declare type CSSPropertyMixer<Parsed = any, T extends Interpolatable = any> = (left: Parsed, right: Parsed, displayObject: IElement | null) => [T, T, (i: T) => string | any] | undefined;
5
5
  declare type CSSPropertyParser<Parsed> = (value: string | any) => Parsed;
@@ -1,6 +1,7 @@
1
1
  import type { DisplayObject } from '../display-objects';
2
2
  import type { BaseStyleProps } from '../types';
3
3
  import { CSSStyleValue } from './cssom';
4
+ import { StyleValueRegistry } from './interfaces';
4
5
  export declare type CSSGlobalKeywords = 'unset' | 'initial' | 'inherit' | '';
5
6
  export interface PropertyParseOptions {
6
7
  skipUpdateAttribute: boolean;
@@ -65,7 +66,7 @@ export interface PropertyMetadata {
65
66
  * Blink used them in code generation(css_properties.json5)
66
67
  */
67
68
  export declare const BUILT_IN_PROPERTIES: PropertyMetadata[];
68
- export declare class StyleValueRegistry {
69
+ export declare class DefaultStyleValueRegistry implements StyleValueRegistry {
69
70
  /**
70
71
  * need recalc later
71
72
  */
@@ -1,7 +1,8 @@
1
1
  import { __decorate, __metadata, __read, __spreadArray } from "tslib";
2
2
  import { postConstruct, singleton, GlobalContainer } from 'mana-syringe';
3
3
  import { vec3 } from 'gl-matrix';
4
- import { dirtifyToRoot, GeometryUpdaterFactory } from '../services';
4
+ import { GeometryUpdaterFactory } from '../services/aabb/interfaces';
5
+ import { dirtifyToRoot } from '../services/SceneGraphService';
5
6
  import { ElementEvent } from '../dom';
6
7
  import { Shape } from '../types';
7
8
  import { CSSKeywordValue, CSSStyleValue, CSSUnitValue } from './cssom';
@@ -9,6 +10,7 @@ import { convertPercentUnit } from './parser';
9
10
  import { CSSPropertyLocalPosition, CSSPropertyOpacity, CSSPropertyColor, CSSPropertyFilter, CSSPropertyLengthOrPercentage, CSSPropertyLineDash, CSSPropertyShadowBlur, CSSPropertyOffsetPath, CSSPropertyOffsetDistance, CSSPropertyAnchor, CSSPropertyZIndex, CSSPropertyTransform, CSSPropertyTransformOrigin, CSSPropertyPath, CSSPropertyClipPath, CSSPropertyPoints, CSSPropertyText, CSSPropertyTextTransform } from './properties';
10
11
  import { formatAttribute } from '../utils';
11
12
  import { AABB } from '../shapes';
13
+ import { StyleValueRegistry } from './interfaces';
12
14
  export var PropertySyntax = {
13
15
  COLOR: '<color>',
14
16
  PAINT: '<paint>',
@@ -135,6 +137,13 @@ export var BUILT_IN_PROPERTIES = [{
135
137
  alias: ['strokeWidth'],
136
138
  syntax: PropertySyntax.LENGTH_PERCENTAGE,
137
139
  handler: CSSPropertyLengthOrPercentage
140
+ }, {
141
+ name: 'increasedLineWidthForHitTesting',
142
+ inherited: true,
143
+ defaultValue: '0',
144
+ layoutDependent: true,
145
+ syntax: PropertySyntax.LENGTH_PERCENTAGE,
146
+ handler: CSSPropertyLengthOrPercentage
138
147
  }, {
139
148
  name: 'lineJoin',
140
149
  inherited: true,
@@ -411,10 +420,10 @@ export var BUILT_IN_PROPERTIES = [{
411
420
  layoutDependent: true
412
421
  }];
413
422
 
414
- var StyleValueRegistry =
423
+ var DefaultStyleValueRegistry =
415
424
  /** @class */
416
425
  function () {
417
- function StyleValueRegistry() {
426
+ function DefaultStyleValueRegistry() {
418
427
  /**
419
428
  * need recalc later
420
429
  */
@@ -450,7 +459,7 @@ function () {
450
459
  // > = {};
451
460
 
452
461
 
453
- StyleValueRegistry.prototype.init = function () {
462
+ DefaultStyleValueRegistry.prototype.init = function () {
454
463
  var _this = this;
455
464
 
456
465
  BUILT_IN_PROPERTIES.forEach(function (property) {
@@ -458,7 +467,7 @@ function () {
458
467
  });
459
468
  };
460
469
 
461
- StyleValueRegistry.prototype.registerMetadata = function (metadata) {
470
+ DefaultStyleValueRegistry.prototype.registerMetadata = function (metadata) {
462
471
  var _this = this;
463
472
 
464
473
  __spreadArray([metadata.name], __read(metadata.alias || []), false).forEach(function (name) {
@@ -466,7 +475,7 @@ function () {
466
475
  });
467
476
  };
468
477
 
469
- StyleValueRegistry.prototype.getMetadata = function (name) {
478
+ DefaultStyleValueRegistry.prototype.getMetadata = function (name) {
470
479
  return this.cache[name];
471
480
  };
472
481
  /**
@@ -480,7 +489,7 @@ function () {
480
489
  */
481
490
 
482
491
 
483
- StyleValueRegistry.prototype.processProperties = function (object, attributes, options) {
492
+ DefaultStyleValueRegistry.prototype.processProperties = function (object, attributes, options) {
484
493
  var _this = this;
485
494
 
486
495
  if (options === void 0) {
@@ -561,7 +570,7 @@ function () {
561
570
  */
562
571
 
563
572
 
564
- StyleValueRegistry.prototype.parseProperty = function (name, value) {
573
+ DefaultStyleValueRegistry.prototype.parseProperty = function (name, value) {
565
574
  var metadata = this.getMetadata(name);
566
575
  var computed = value;
567
576
 
@@ -597,7 +606,7 @@ function () {
597
606
  */
598
607
 
599
608
 
600
- StyleValueRegistry.prototype.computeProperty = function (name, computed, object) {
609
+ DefaultStyleValueRegistry.prototype.computeProperty = function (name, computed, object) {
601
610
  var metadata = this.getMetadata(name);
602
611
  var isDocumentElement = object.id === 'g-root';
603
612
  var used = computed instanceof CSSStyleValue ? computed.clone() : computed;
@@ -661,7 +670,7 @@ function () {
661
670
  return false;
662
671
  };
663
672
 
664
- StyleValueRegistry.prototype.postProcessProperty = function (name, object) {
673
+ DefaultStyleValueRegistry.prototype.postProcessProperty = function (name, object) {
665
674
  var metadata = this.getMetadata(name);
666
675
 
667
676
  if (metadata && metadata.handler) {
@@ -673,7 +682,7 @@ function () {
673
682
  }
674
683
  };
675
684
 
676
- StyleValueRegistry.prototype.isPropertyResolved = function (object, name) {
685
+ DefaultStyleValueRegistry.prototype.isPropertyResolved = function (object, name) {
677
686
  if (!this.unresolvedProperties[object.entity] || this.unresolvedProperties[object.entity].length === 0) {
678
687
  return true;
679
688
  }
@@ -685,7 +694,7 @@ function () {
685
694
  */
686
695
 
687
696
 
688
- StyleValueRegistry.prototype.addUnresolveProperty = function (object, name) {
697
+ DefaultStyleValueRegistry.prototype.addUnresolveProperty = function (object, name) {
689
698
  if (!this.unresolvedProperties[object.entity]) {
690
699
  this.unresolvedProperties[object.entity] = [];
691
700
  }
@@ -695,7 +704,7 @@ function () {
695
704
  }
696
705
  };
697
706
 
698
- StyleValueRegistry.prototype.tryToResolveProperty = function (object, name, options) {
707
+ DefaultStyleValueRegistry.prototype.tryToResolveProperty = function (object, name, options) {
699
708
  if (options === void 0) {
700
709
  options = {};
701
710
  }
@@ -719,7 +728,7 @@ function () {
719
728
  return false;
720
729
  };
721
730
 
722
- StyleValueRegistry.prototype.recalc = function (object) {
731
+ DefaultStyleValueRegistry.prototype.recalc = function (object) {
723
732
  var properties = this.unresolvedProperties[object.entity];
724
733
 
725
734
  if (properties && properties.length) {
@@ -737,7 +746,7 @@ function () {
737
746
  */
738
747
 
739
748
 
740
- StyleValueRegistry.prototype.updateGeometry = function (object) {
749
+ DefaultStyleValueRegistry.prototype.updateGeometry = function (object) {
741
750
  var _a;
742
751
 
743
752
  var geometryUpdaterFactory = GlobalContainer.get(GeometryUpdaterFactory);
@@ -791,6 +800,7 @@ function () {
791
800
 
792
801
  var _j = parsedStyle,
793
802
  lineWidth = _j.lineWidth,
803
+ increasedLineWidthForHitTesting = _j.increasedLineWidthForHitTesting,
794
804
  shadowColor = _j.shadowColor,
795
805
  _k = _j.filter,
796
806
  filter = _k === void 0 ? [] : _k,
@@ -804,12 +814,9 @@ function () {
804
814
  var center = vec3.fromValues((1 - (anchor && anchor[0].value || 0) * 2) * halfExtents[0] + offsetX, (1 - (anchor && anchor[1].value || 0) * 2) * halfExtents[1] + offsetY, (1 - (anchor && ((_a = anchor[2]) === null || _a === void 0 ? void 0 : _a.value) || 0) * 2) * halfExtents[2] + offsetZ); // update geometry's AABB
805
815
 
806
816
  geometry_1.contentBounds.update(center, halfExtents);
817
+ var halfLineWidth = (((lineWidth === null || lineWidth === void 0 ? void 0 : lineWidth.value) || 0) + ((increasedLineWidthForHitTesting === null || increasedLineWidthForHitTesting === void 0 ? void 0 : increasedLineWidthForHitTesting.value) || 0)) / 2; // append border
807
818
 
808
- if (lineWidth) {
809
- // append border
810
- vec3.add(halfExtents, halfExtents, vec3.fromValues(lineWidth.value / 2, lineWidth.value / 2, 0));
811
- }
812
-
819
+ vec3.add(halfExtents, halfExtents, vec3.fromValues(halfLineWidth, halfLineWidth, 0));
813
820
  geometry_1.renderBounds.update(center, halfExtents); // account for shadow, only support constant value now
814
821
 
815
822
  if (shadowColor) {
@@ -872,7 +879,7 @@ function () {
872
879
  }
873
880
  };
874
881
 
875
- StyleValueRegistry.prototype.isPropertyInheritable = function (name) {
882
+ DefaultStyleValueRegistry.prototype.isPropertyInheritable = function (name) {
876
883
  var metadata = this.getMetadata(name);
877
884
 
878
885
  if (!metadata) {
@@ -882,10 +889,12 @@ function () {
882
889
  return metadata.inherited;
883
890
  };
884
891
 
885
- __decorate([postConstruct(), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0)], StyleValueRegistry.prototype, "init", null);
892
+ __decorate([postConstruct(), __metadata("design:type", Function), __metadata("design:paramtypes", []), __metadata("design:returntype", void 0)], DefaultStyleValueRegistry.prototype, "init", null);
886
893
 
887
- StyleValueRegistry = __decorate([singleton()], StyleValueRegistry);
888
- return StyleValueRegistry;
894
+ DefaultStyleValueRegistry = __decorate([singleton({
895
+ token: StyleValueRegistry
896
+ })], DefaultStyleValueRegistry);
897
+ return DefaultStyleValueRegistry;
889
898
  }();
890
899
 
891
- export { StyleValueRegistry };
900
+ export { DefaultStyleValueRegistry };
@@ -1,5 +1,5 @@
1
1
  import { __assign, __extends, __read, __spreadArray, __values } from "tslib";
2
- import { DCHECK, DCHECK_EQ, DCHECK_NE } from '../../utils';
2
+ import { DCHECK, DCHECK_EQ, DCHECK_NE } from '../../utils/assert';
3
3
  import { CSSMathOperator } from './CSSMathOperator';
4
4
  import { CSSStyleValue, CSSStyleValueType } from './CSSStyleValue';
5
5
  import { Nested, ParenLess, UnitType } from './types'; // https://drafts.css-houdini.org/css-typed-om/#enumdef-cssnumericbasetype
package/es/css/index.d.ts CHANGED
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CSS_Object_Model
3
3
  */
4
+ export * from './interfaces';
4
5
  export * from './cssom';
5
6
  export * from './parser';
6
7
  export * from './properties';
8
+ export * from './layout';
7
9
  export * from './CSS';
8
10
  export * from './CSSProperty';
9
- export * from './LayoutRegistry';
10
11
  export * from './StyleValueRegistry';
package/es/css/index.js CHANGED
@@ -1,10 +1,11 @@
1
1
  /**
2
2
  * @see https://developer.mozilla.org/en-US/docs/Web/API/CSS_Object_Model
3
3
  */
4
+ export * from './interfaces';
4
5
  export * from './cssom';
5
6
  export * from './parser';
6
7
  export * from './properties';
8
+ export * from './layout';
7
9
  export * from './CSS';
8
10
  export * from './CSSProperty';
9
- export * from './LayoutRegistry';
10
11
  export * from './StyleValueRegistry';
@@ -0,0 +1,6 @@
1
+ import { Syringe } from 'mana-syringe';
2
+ import type { DisplayObject } from '../display-objects';
3
+ export declare const StyleValueRegistry: Syringe.DefinedToken;
4
+ export interface StyleValueRegistry {
5
+ recalc: (displayObject: DisplayObject) => void;
6
+ }
@@ -0,0 +1,2 @@
1
+ import { Syringe } from 'mana-syringe';
2
+ export var StyleValueRegistry = Syringe.defineToken('StyleValueRegistry');
@@ -0,0 +1,32 @@
1
+ import { Syringe } from 'mana-syringe';
2
+ import { LayoutObject } from './LayoutObject';
3
+ import { LayoutContext } from './LayoutContext';
4
+ import type { LayoutFragment } from './LayoutFragment';
5
+ export declare const FragmentResultFactory: Syringe.DefinedToken;
6
+ export interface FragmentResultFactory {
7
+ (options: FragmentResultOptions): FragmentResult;
8
+ }
9
+ /**
10
+ * The web developer defined layout method can return either a FragmentResultOptions or a FragmentResult.
11
+ */
12
+ export declare const FragmentResultOptions: Syringe.DefinedToken;
13
+ export interface FragmentResultOptions<T = void> {
14
+ inlineSize: number;
15
+ blockSize: number;
16
+ autoBlockSize: number;
17
+ childFragments: LayoutFragment[];
18
+ data: T;
19
+ }
20
+ export declare const ContextNode: Syringe.DefinedToken;
21
+ export declare class FragmentResult<T = void> {
22
+ protected readonly _layoutContext: LayoutContext;
23
+ protected readonly _node: LayoutObject;
24
+ protected readonly options: FragmentResultOptions<T>;
25
+ private layoutContext;
26
+ readonly inlineSize: number;
27
+ readonly blockSize: number;
28
+ private node;
29
+ childFragments: LayoutFragment[];
30
+ data: T;
31
+ constructor(_layoutContext: LayoutContext, _node: LayoutObject, options: FragmentResultOptions<T>);
32
+ }
@@ -0,0 +1,32 @@
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { inject, injectable, Syringe } from 'mana-syringe';
3
+ import { LayoutObject } from './LayoutObject';
4
+ import { LayoutContext } from './LayoutContext';
5
+ export var FragmentResultFactory = Syringe.defineToken('FragmentResultFactory');
6
+ /**
7
+ * The web developer defined layout method can return either a FragmentResultOptions or a FragmentResult.
8
+ */
9
+
10
+ export var FragmentResultOptions = Syringe.defineToken('FragmentResultOptions');
11
+ export var ContextNode = Syringe.defineToken('contextNode');
12
+
13
+ var FragmentResult =
14
+ /** @class */
15
+ function () {
16
+ function FragmentResult(_layoutContext, _node, options) {
17
+ this._layoutContext = _layoutContext;
18
+ this._node = _node;
19
+ this.options = options;
20
+ this.layoutContext = _layoutContext;
21
+ this.inlineSize = options === null || options === void 0 ? void 0 : options.inlineSize;
22
+ this.blockSize = options === null || options === void 0 ? void 0 : options.blockSize;
23
+ this.childFragments = options === null || options === void 0 ? void 0 : options.childFragments;
24
+ this.data = options.data;
25
+ this.node = _node;
26
+ }
27
+
28
+ FragmentResult = __decorate([injectable(), __param(0, inject(LayoutContext)), __param(1, inject(ContextNode)), __param(2, inject(FragmentResultOptions)), __metadata("design:paramtypes", [LayoutContext, LayoutObject, Object])], FragmentResult);
29
+ return FragmentResult;
30
+ }();
31
+
32
+ export { FragmentResult };
@@ -0,0 +1,23 @@
1
+ import { Syringe } from 'mana-syringe';
2
+ import type { LayoutObject } from './LayoutObject';
3
+ import { LayoutContext } from './LayoutContext';
4
+ import type { LayoutFragment } from './LayoutFragment';
5
+ import type { IntrinsicSizes, LayoutConstraints } from './types';
6
+ export declare const LayoutChildrenFactory: Syringe.DefinedToken;
7
+ export interface LayoutChildrenFactory {
8
+ (options: LayoutChildrenOptions): LayoutChildren;
9
+ }
10
+ export declare const LayoutChildrenOptions: Syringe.DefinedToken;
11
+ export interface LayoutChildrenOptions {
12
+ node: LayoutObject;
13
+ }
14
+ export declare class LayoutChildren {
15
+ protected readonly _layoutContext: LayoutContext;
16
+ protected readonly options: LayoutChildrenOptions;
17
+ node: LayoutObject;
18
+ readonly styleMap: Map<string, any>;
19
+ layoutContext: LayoutContext;
20
+ constructor(_layoutContext: LayoutContext, options: LayoutChildrenOptions);
21
+ intrinsicSizes(): Promise<IntrinsicSizes>;
22
+ layoutNextFragment(constraints: LayoutConstraints): Promise<LayoutFragment>;
23
+ }
@@ -0,0 +1,55 @@
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { inject, injectable, Syringe } from 'mana-syringe';
3
+ import { Deferred } from '../../utils';
4
+ import { LayoutContext } from './LayoutContext';
5
+ import { LayoutTaskType } from './types';
6
+ export var LayoutChildrenFactory = Syringe.defineToken('LayoutChildrenFactory');
7
+ export var LayoutChildrenOptions = Syringe.defineToken('LayoutChildrenOptions');
8
+
9
+ var LayoutChildren =
10
+ /** @class */
11
+ function () {
12
+ function LayoutChildren(_layoutContext, options) {
13
+ this._layoutContext = _layoutContext;
14
+ this.options = options;
15
+ this.layoutContext = _layoutContext;
16
+ this.node = options.node;
17
+ this.styleMap = options.node.getAllStyle();
18
+ }
19
+
20
+ LayoutChildren.prototype.intrinsicSizes = function () {
21
+ // if (this.contextId !== this.layoutContext.contextId) {
22
+ // throw new Error('Invalid State: wrong layout context');
23
+ // }
24
+ var deferred = new Deferred();
25
+ this.layoutContext.appendWorkTask({
26
+ layoutChild: this,
27
+ taskType: LayoutTaskType.IntrinsicSizes,
28
+ deferred: deferred
29
+ });
30
+ return deferred.promise;
31
+ };
32
+
33
+ LayoutChildren.prototype.layoutNextFragment = function (constraints) {
34
+ // if (this.layoutContext.contextId !== this.layoutContext.contextId) {
35
+ // throw new Error('Invalid State: wrong layout context');
36
+ // }
37
+ if (this.layoutContext.mode === LayoutTaskType.IntrinsicSizes) {
38
+ throw new Error('Not Supported: cant call layoutNextFragment in intrinsicSizes');
39
+ }
40
+
41
+ var deferred = new Deferred();
42
+ this.layoutContext.appendWorkTask({
43
+ layoutConstraints: constraints,
44
+ layoutChild: this,
45
+ taskType: LayoutTaskType.Layout,
46
+ deferred: deferred
47
+ });
48
+ return deferred.promise;
49
+ };
50
+
51
+ LayoutChildren = __decorate([injectable(), __param(0, inject(LayoutContext)), __param(1, inject(LayoutChildrenOptions)), __metadata("design:paramtypes", [LayoutContext, Object])], LayoutChildren);
52
+ return LayoutChildren;
53
+ }();
54
+
55
+ export { LayoutChildren };
@@ -0,0 +1,35 @@
1
+ import { Syringe } from 'mana-syringe';
2
+ import type { LayoutWorkTask } from './LayoutWorkTask';
3
+ import type { LayoutTaskType } from './types';
4
+ import type { ContextId } from './types';
5
+ import type { FragmentResultFactory } from './FragmentResult';
6
+ import type { LayoutChildrenFactory } from './LayoutChildren';
7
+ import type { LayoutFragmentFactory } from './LayoutFragment';
8
+ export declare const LayoutContextFactory: Syringe.DefinedToken;
9
+ export interface LayoutContextFactory {
10
+ (options: {
11
+ mode: LayoutTaskType;
12
+ }): LayoutContext;
13
+ }
14
+ export declare const LayoutContextOptions: Syringe.DefinedToken;
15
+ export interface LayoutContextOptions {
16
+ mode: LayoutTaskType;
17
+ layoutChildrenFactory: LayoutChildrenFactory;
18
+ fragmentResultFactory: FragmentResultFactory;
19
+ layoutFragmentFactory: LayoutFragmentFactory;
20
+ }
21
+ /**
22
+ * 每次layout 有单独的 context
23
+ */
24
+ export declare class LayoutContext {
25
+ protected readonly options: LayoutContextOptions;
26
+ contextId: ContextId;
27
+ workQueue: LayoutWorkTask[];
28
+ mode: LayoutTaskType;
29
+ layoutChildrenFactory: LayoutChildrenFactory;
30
+ fragmentResultFactory: FragmentResultFactory;
31
+ layoutFragmentFactory: LayoutFragmentFactory;
32
+ constructor(options: LayoutContextOptions);
33
+ appendWorkTask(work: LayoutWorkTask): void;
34
+ clearWorkQueue(): void;
35
+ }
@@ -0,0 +1,35 @@
1
+ import { __decorate, __metadata, __param } from "tslib";
2
+ import { inject, singleton, Syringe } from 'mana-syringe';
3
+ export var LayoutContextFactory = Syringe.defineToken('LayoutContextFactory');
4
+ export var LayoutContextOptions = Syringe.defineToken('LayoutContextOptions');
5
+ var guid = 0;
6
+ /**
7
+ * 每次layout 有单独的 context
8
+ */
9
+
10
+ var LayoutContext =
11
+ /** @class */
12
+ function () {
13
+ function LayoutContext(options) {
14
+ this.options = options;
15
+ this.workQueue = [];
16
+ this.contextId = "".concat(guid++);
17
+ this.mode = options.mode;
18
+ this.layoutChildrenFactory = options.layoutChildrenFactory;
19
+ this.fragmentResultFactory = options.fragmentResultFactory;
20
+ this.layoutFragmentFactory = options.layoutFragmentFactory;
21
+ }
22
+
23
+ LayoutContext.prototype.appendWorkTask = function (work) {
24
+ this.workQueue.push(work);
25
+ };
26
+
27
+ LayoutContext.prototype.clearWorkQueue = function () {
28
+ this.workQueue = [];
29
+ };
30
+
31
+ LayoutContext = __decorate([singleton(), __param(0, inject(LayoutContextOptions)), __metadata("design:paramtypes", [Object])], LayoutContext);
32
+ return LayoutContext;
33
+ }();
34
+
35
+ export { LayoutContext };
@@ -0,0 +1,20 @@
1
+ import type { IntrinsicSizes, LayoutConstraints, LayoutOptions } from './types';
2
+ import type { FragmentResultOptions, FragmentResult } from './FragmentResult';
3
+ import type { LayoutChildren } from './LayoutChildren';
4
+ import type { LayoutEdges } from './LayoutEdges';
5
+ export declare abstract class AbstractLayoutDefinition {
6
+ static inputProperties: string[];
7
+ static childrenInputProperties: string[];
8
+ static layoutOptions: LayoutOptions;
9
+ abstract intrinsicSizes(children: LayoutChildren[], edges: LayoutEdges, styleMap: Map<string, any>): Promise<IntrinsicSizes>;
10
+ abstract layout(children: LayoutChildren[], edges: LayoutEdges, constraints: LayoutConstraints, styleMap: Map<string, any>): Promise<FragmentResultOptions | FragmentResult>;
11
+ }
12
+ /**
13
+ * internal use
14
+ */
15
+ export declare type LayoutDefinitionCtor = {
16
+ new (): AbstractLayoutDefinition;
17
+ inputProperties: string[];
18
+ childrenInputProperties: string[];
19
+ layoutOptions: LayoutOptions;
20
+ };
@@ -0,0 +1,9 @@
1
+ var AbstractLayoutDefinition =
2
+ /** @class */
3
+ function () {
4
+ function AbstractLayoutDefinition() {}
5
+
6
+ return AbstractLayoutDefinition;
7
+ }();
8
+
9
+ export { AbstractLayoutDefinition };
@@ -0,0 +1,24 @@
1
+ import { Syringe } from 'mana-syringe';
2
+ import type { LayoutObject } from './LayoutObject';
3
+ export declare const LayoutEdgesFactory: Syringe.DefinedToken;
4
+ export interface LayoutEdgesFactory {
5
+ (options: LayoutEdgesOptions): LayoutEdges;
6
+ }
7
+ export declare const LayoutEdgesOptions: Syringe.DefinedToken;
8
+ export interface LayoutEdgesOptions {
9
+ node: LayoutObject;
10
+ }
11
+ /**
12
+ * https://drafts.css-houdini.org/css-layout-api/#layoutedges
13
+ * the size of border, scrollbar, padding
14
+ */
15
+ export declare class LayoutEdges {
16
+ protected readonly options: LayoutEdgesOptions;
17
+ readonly inlineStart: number;
18
+ readonly inlineEnd: number;
19
+ readonly blockStart: number;
20
+ readonly blockEnd: number;
21
+ readonly inline: number;
22
+ readonly block: number;
23
+ constructor(options: LayoutEdgesOptions);
24
+ }