@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
@@ -27,8 +27,7 @@ function () {
27
27
  * enable dirty rectangle rendering by default
28
28
  */
29
29
  enableDirtyRectangleRendering: true,
30
- enableDirtyRectangleRenderingDebug: false,
31
- enableTAA: false
30
+ enableDirtyRectangleRenderingDebug: false
32
31
  }, config);
33
32
  }
34
33
 
@@ -36,10 +35,26 @@ function () {
36
35
  this.plugins.push(plugin);
37
36
  };
38
37
 
38
+ AbstractRenderer.prototype.unregisterPlugin = function (plugin) {
39
+ var index = this.plugins.findIndex(function (p) {
40
+ return p === plugin;
41
+ });
42
+
43
+ if (index > -1) {
44
+ this.plugins.splice(index, 1);
45
+ }
46
+ };
47
+
39
48
  AbstractRenderer.prototype.getPlugins = function () {
40
49
  return this.plugins;
41
50
  };
42
51
 
52
+ AbstractRenderer.prototype.getPlugin = function (name) {
53
+ return this.plugins.find(function (plugin) {
54
+ return plugin.name === name;
55
+ });
56
+ };
57
+
43
58
  AbstractRenderer.prototype.getConfig = function () {
44
59
  return this.config;
45
60
  };
package/lib/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/lib/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/lib/css/CSS.js CHANGED
@@ -9,7 +9,9 @@ var _manaSyringe = require("mana-syringe");
9
9
 
10
10
  var _cssom = require("./cssom");
11
11
 
12
- var _StyleValueRegistry = require("./StyleValueRegistry");
12
+ var _interfaces = require("./interfaces");
13
+
14
+ var _layout = require("./layout");
13
15
 
14
16
  /**
15
17
  * holds useful CSS-related methods.
@@ -104,7 +106,7 @@ var CSS = {
104
106
  inherits = definition.inherits,
105
107
  initialValue = definition.initialValue;
106
108
 
107
- var registry = _manaSyringe.GlobalContainer.get(_StyleValueRegistry.StyleValueRegistry);
109
+ var registry = _manaSyringe.GlobalContainer.get(_interfaces.StyleValueRegistry);
108
110
 
109
111
  registry.registerMetadata({
110
112
  name: name,
@@ -120,6 +122,10 @@ var CSS = {
120
122
  * @see https://github.com/w3c/css-houdini-drafts/blob/main/css-layout-api/EXPLAINER.md
121
123
  * @see https://developer.mozilla.org/en-US/docs/Web/Guide/Houdini#css_layout_api
122
124
  */
123
- registerLayout: function registerLayout(name) {}
125
+ registerLayout: function registerLayout(name, clazz) {
126
+ var layoutRegistry = _manaSyringe.GlobalContainer.get(_layout.LayoutRegistry);
127
+
128
+ layoutRegistry.registerLayout(name, clazz);
129
+ }
124
130
  };
125
131
  exports.CSS = CSS;
@@ -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
  */
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.StyleValueRegistry = exports.PropertySyntax = exports.BUILT_IN_PROPERTIES = void 0;
6
+ exports.PropertySyntax = exports.DefaultStyleValueRegistry = exports.BUILT_IN_PROPERTIES = void 0;
7
7
 
8
8
  var _tslib = require("tslib");
9
9
 
@@ -11,7 +11,9 @@ var _manaSyringe = require("mana-syringe");
11
11
 
12
12
  var _glMatrix = require("gl-matrix");
13
13
 
14
- var _services = require("../services");
14
+ var _interfaces = require("../services/aabb/interfaces");
15
+
16
+ var _SceneGraphService = require("../services/SceneGraphService");
15
17
 
16
18
  var _dom = require("../dom");
17
19
 
@@ -27,6 +29,8 @@ var _utils = require("../utils");
27
29
 
28
30
  var _shapes = require("../shapes");
29
31
 
32
+ var _interfaces2 = require("./interfaces");
33
+
30
34
  var PropertySyntax = {
31
35
  COLOR: '<color>',
32
36
  PAINT: '<paint>',
@@ -154,6 +158,13 @@ var BUILT_IN_PROPERTIES = [{
154
158
  alias: ['strokeWidth'],
155
159
  syntax: PropertySyntax.LENGTH_PERCENTAGE,
156
160
  handler: _properties.CSSPropertyLengthOrPercentage
161
+ }, {
162
+ name: 'increasedLineWidthForHitTesting',
163
+ inherited: true,
164
+ defaultValue: '0',
165
+ layoutDependent: true,
166
+ syntax: PropertySyntax.LENGTH_PERCENTAGE,
167
+ handler: _properties.CSSPropertyLengthOrPercentage
157
168
  }, {
158
169
  name: 'lineJoin',
159
170
  inherited: true,
@@ -431,10 +442,10 @@ var BUILT_IN_PROPERTIES = [{
431
442
  }];
432
443
  exports.BUILT_IN_PROPERTIES = BUILT_IN_PROPERTIES;
433
444
 
434
- var StyleValueRegistry =
445
+ var DefaultStyleValueRegistry =
435
446
  /** @class */
436
447
  function () {
437
- function StyleValueRegistry() {
448
+ function DefaultStyleValueRegistry() {
438
449
  /**
439
450
  * need recalc later
440
451
  */
@@ -470,7 +481,7 @@ function () {
470
481
  // > = {};
471
482
 
472
483
 
473
- StyleValueRegistry.prototype.init = function () {
484
+ DefaultStyleValueRegistry.prototype.init = function () {
474
485
  var _this = this;
475
486
 
476
487
  BUILT_IN_PROPERTIES.forEach(function (property) {
@@ -478,7 +489,7 @@ function () {
478
489
  });
479
490
  };
480
491
 
481
- StyleValueRegistry.prototype.registerMetadata = function (metadata) {
492
+ DefaultStyleValueRegistry.prototype.registerMetadata = function (metadata) {
482
493
  var _this = this;
483
494
 
484
495
  (0, _tslib.__spreadArray)([metadata.name], (0, _tslib.__read)(metadata.alias || []), false).forEach(function (name) {
@@ -486,7 +497,7 @@ function () {
486
497
  });
487
498
  };
488
499
 
489
- StyleValueRegistry.prototype.getMetadata = function (name) {
500
+ DefaultStyleValueRegistry.prototype.getMetadata = function (name) {
490
501
  return this.cache[name];
491
502
  };
492
503
  /**
@@ -500,7 +511,7 @@ function () {
500
511
  */
501
512
 
502
513
 
503
- StyleValueRegistry.prototype.processProperties = function (object, attributes, options) {
514
+ DefaultStyleValueRegistry.prototype.processProperties = function (object, attributes, options) {
504
515
  var _this = this;
505
516
 
506
517
  if (options === void 0) {
@@ -581,7 +592,7 @@ function () {
581
592
  */
582
593
 
583
594
 
584
- StyleValueRegistry.prototype.parseProperty = function (name, value) {
595
+ DefaultStyleValueRegistry.prototype.parseProperty = function (name, value) {
585
596
  var metadata = this.getMetadata(name);
586
597
  var computed = value;
587
598
 
@@ -617,7 +628,7 @@ function () {
617
628
  */
618
629
 
619
630
 
620
- StyleValueRegistry.prototype.computeProperty = function (name, computed, object) {
631
+ DefaultStyleValueRegistry.prototype.computeProperty = function (name, computed, object) {
621
632
  var metadata = this.getMetadata(name);
622
633
  var isDocumentElement = object.id === 'g-root';
623
634
  var used = computed instanceof _cssom.CSSStyleValue ? computed.clone() : computed;
@@ -682,7 +693,7 @@ function () {
682
693
  return false;
683
694
  };
684
695
 
685
- StyleValueRegistry.prototype.postProcessProperty = function (name, object) {
696
+ DefaultStyleValueRegistry.prototype.postProcessProperty = function (name, object) {
686
697
  var metadata = this.getMetadata(name);
687
698
 
688
699
  if (metadata && metadata.handler) {
@@ -694,7 +705,7 @@ function () {
694
705
  }
695
706
  };
696
707
 
697
- StyleValueRegistry.prototype.isPropertyResolved = function (object, name) {
708
+ DefaultStyleValueRegistry.prototype.isPropertyResolved = function (object, name) {
698
709
  if (!this.unresolvedProperties[object.entity] || this.unresolvedProperties[object.entity].length === 0) {
699
710
  return true;
700
711
  }
@@ -706,7 +717,7 @@ function () {
706
717
  */
707
718
 
708
719
 
709
- StyleValueRegistry.prototype.addUnresolveProperty = function (object, name) {
720
+ DefaultStyleValueRegistry.prototype.addUnresolveProperty = function (object, name) {
710
721
  if (!this.unresolvedProperties[object.entity]) {
711
722
  this.unresolvedProperties[object.entity] = [];
712
723
  }
@@ -716,7 +727,7 @@ function () {
716
727
  }
717
728
  };
718
729
 
719
- StyleValueRegistry.prototype.tryToResolveProperty = function (object, name, options) {
730
+ DefaultStyleValueRegistry.prototype.tryToResolveProperty = function (object, name, options) {
720
731
  if (options === void 0) {
721
732
  options = {};
722
733
  }
@@ -740,7 +751,7 @@ function () {
740
751
  return false;
741
752
  };
742
753
 
743
- StyleValueRegistry.prototype.recalc = function (object) {
754
+ DefaultStyleValueRegistry.prototype.recalc = function (object) {
744
755
  var properties = this.unresolvedProperties[object.entity];
745
756
 
746
757
  if (properties && properties.length) {
@@ -758,10 +769,10 @@ function () {
758
769
  */
759
770
 
760
771
 
761
- StyleValueRegistry.prototype.updateGeometry = function (object) {
772
+ DefaultStyleValueRegistry.prototype.updateGeometry = function (object) {
762
773
  var _a;
763
774
 
764
- var geometryUpdaterFactory = _manaSyringe.GlobalContainer.get(_services.GeometryUpdaterFactory);
775
+ var geometryUpdaterFactory = _manaSyringe.GlobalContainer.get(_interfaces.GeometryUpdaterFactory);
765
776
 
766
777
  var geometryUpdater = geometryUpdaterFactory(object.nodeName);
767
778
 
@@ -814,6 +825,7 @@ function () {
814
825
 
815
826
  var _j = parsedStyle,
816
827
  lineWidth = _j.lineWidth,
828
+ increasedLineWidthForHitTesting = _j.increasedLineWidthForHitTesting,
817
829
  shadowColor = _j.shadowColor,
818
830
  _k = _j.filter,
819
831
  filter = _k === void 0 ? [] : _k,
@@ -828,11 +840,9 @@ function () {
828
840
 
829
841
 
830
842
  geometry_1.contentBounds.update(center, halfExtents);
843
+ 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
831
844
 
832
- if (lineWidth) {
833
- // append border
834
- _glMatrix.vec3.add(halfExtents, halfExtents, _glMatrix.vec3.fromValues(lineWidth.value / 2, lineWidth.value / 2, 0));
835
- }
845
+ _glMatrix.vec3.add(halfExtents, halfExtents, _glMatrix.vec3.fromValues(halfLineWidth, halfLineWidth, 0));
836
846
 
837
847
  geometry_1.renderBounds.update(center, halfExtents); // account for shadow, only support constant value now
838
848
 
@@ -892,11 +902,11 @@ function () {
892
902
  usedOriginYValue -= (anchor && anchor[1].value || 0) * geometry_1.contentBounds.halfExtents[1] * 2;
893
903
  object.setOrigin(usedOriginXValue, usedOriginYValue);
894
904
  object.emit(_dom.ElementEvent.GEOMETRY_BOUNDS_CHANGED, {});
895
- (0, _services.dirtifyToRoot)(object);
905
+ (0, _SceneGraphService.dirtifyToRoot)(object);
896
906
  }
897
907
  };
898
908
 
899
- StyleValueRegistry.prototype.isPropertyInheritable = function (name) {
909
+ DefaultStyleValueRegistry.prototype.isPropertyInheritable = function (name) {
900
910
  var metadata = this.getMetadata(name);
901
911
 
902
912
  if (!metadata) {
@@ -906,9 +916,11 @@ function () {
906
916
  return metadata.inherited;
907
917
  };
908
918
 
909
- (0, _tslib.__decorate)([(0, _manaSyringe.postConstruct)(), (0, _tslib.__metadata)("design:type", Function), (0, _tslib.__metadata)("design:paramtypes", []), (0, _tslib.__metadata)("design:returntype", void 0)], StyleValueRegistry.prototype, "init", null);
910
- StyleValueRegistry = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)()], StyleValueRegistry);
911
- return StyleValueRegistry;
919
+ (0, _tslib.__decorate)([(0, _manaSyringe.postConstruct)(), (0, _tslib.__metadata)("design:type", Function), (0, _tslib.__metadata)("design:paramtypes", []), (0, _tslib.__metadata)("design:returntype", void 0)], DefaultStyleValueRegistry.prototype, "init", null);
920
+ DefaultStyleValueRegistry = (0, _tslib.__decorate)([(0, _manaSyringe.singleton)({
921
+ token: _interfaces2.StyleValueRegistry
922
+ })], DefaultStyleValueRegistry);
923
+ return DefaultStyleValueRegistry;
912
924
  }();
913
925
 
914
- exports.StyleValueRegistry = StyleValueRegistry;
926
+ exports.DefaultStyleValueRegistry = DefaultStyleValueRegistry;
@@ -10,7 +10,7 @@ exports.unitTypeToBaseType = unitTypeToBaseType;
10
10
 
11
11
  var _tslib = require("tslib");
12
12
 
13
- var _utils = require("../../utils");
13
+ var _assert = require("../../utils/assert");
14
14
 
15
15
  var _CSSMathOperator = require("./CSSMathOperator");
16
16
 
@@ -34,7 +34,7 @@ exports.BaseType = BaseType;
34
34
  })(BaseType || (exports.BaseType = BaseType = {}));
35
35
 
36
36
  function unitTypeToBaseType(unit) {
37
- (0, _utils.DCHECK_NE)(unit, _types.UnitType.kNumber);
37
+ (0, _assert.DCHECK_NE)(unit, _types.UnitType.kNumber);
38
38
 
39
39
  switch (unit) {
40
40
  case _types.UnitType.kEms:
@@ -165,7 +165,7 @@ function () {
165
165
  }
166
166
 
167
167
  CSSNumericValueType.prototype.applyPercentHint = function (hint) {
168
- (0, _utils.DCHECK_NE)(hint, BaseType.kPercent);
168
+ (0, _assert.DCHECK_NE)(hint, BaseType.kPercent);
169
169
  this.setExponent(hint, this.exponent(hint) + this.exponent(BaseType.kPercent));
170
170
  this.setExponent(BaseType.kPercent, 0);
171
171
  this.percentHint = hint;
@@ -177,7 +177,7 @@ function () {
177
177
  };
178
178
 
179
179
  CSSNumericValueType.prototype.isOnlyNonZeroEntry = function (baseType, value) {
180
- (0, _utils.DCHECK_NE)(value, 0);
180
+ (0, _assert.DCHECK_NE)(value, 0);
181
181
  return this.numNonZeroEntries === 1 && this.exponent(baseType) === value;
182
182
  };
183
183
 
@@ -205,7 +205,7 @@ function () {
205
205
  };
206
206
 
207
207
  CSSNumericValueType.prototype.matchesBaseType = function (baseType) {
208
- (0, _utils.DCHECK_NE)(baseType, BaseType.kPercent);
208
+ (0, _assert.DCHECK_NE)(baseType, BaseType.kPercent);
209
209
  return this.isOnlyNonZeroEntry(baseType, 1) && !this.hasPercentHint;
210
210
  };
211
211
 
@@ -214,7 +214,7 @@ function () {
214
214
  };
215
215
 
216
216
  CSSNumericValueType.prototype.matchesBaseTypePercentage = function (baseType) {
217
- (0, _utils.DCHECK_NE)(baseType, BaseType.kPercent);
217
+ (0, _assert.DCHECK_NE)(baseType, BaseType.kPercent);
218
218
  return this.isOnlyNonZeroEntry(baseType, 1) || this.isOnlyNonZeroEntry(BaseType.kPercent, 1);
219
219
  };
220
220
 
@@ -233,7 +233,7 @@ function () {
233
233
  }
234
234
 
235
235
  if (type1.hasPercentHint) type2.applyPercentHint(type1.percentHint);else if (type2.hasPercentHint) type1.applyPercentHint(type2.percentHint);
236
- (0, _utils.DCHECK_EQ)(type1.percentHint, type2.percentHint); // Match up base types. Try to use the percent hint to match up any
236
+ (0, _assert.DCHECK_EQ)(type1.percentHint, type2.percentHint); // Match up base types. Try to use the percent hint to match up any
237
237
  // differences.
238
238
 
239
239
  for (var i = 0; i < BaseType.kNumBaseTypes; ++i) {
@@ -567,7 +567,7 @@ function (_super) {
567
567
  }); // We got 'values' from a sum value, so it must be a valid CSSMathSum.
568
568
 
569
569
  var result_1 = CSSMathSum.create(values);
570
- (0, _utils.DCHECK)(!!result_1);
570
+ (0, _assert.DCHECK)(!!result_1);
571
571
  return result_1;
572
572
  }
573
573
 
@@ -575,7 +575,7 @@ function (_super) {
575
575
 
576
576
  var _loop_1 = function _loop_1(unit_string) {
577
577
  var target_unit = CSSNumericValue.unitFromName(unit_string);
578
- (0, _utils.DCHECK)(CSSNumericValue.isValidUnit(target_unit)); // Collect all the terms that are compatible with this unit.
578
+ (0, _assert.DCHECK)(CSSNumericValue.isValidUnit(target_unit)); // Collect all the terms that are compatible with this unit.
579
579
  // We mark used terms as null so we don't use them again.
580
580
 
581
581
  var total_value = values.reduce(function (cur_sum, value, i) {
@@ -710,7 +710,7 @@ function cssNumberishesToNumericValues(values) {
710
710
  }
711
711
 
712
712
  function prependValueForArithmetic(type, values, value) {
713
- (0, _utils.DCHECK)(!!value);
713
+ (0, _assert.DCHECK)(!!value);
714
714
 
715
715
  if (value.getType() === type) {
716
716
  values.unshift.apply(values, (0, _tslib.__spreadArray)([], (0, _tslib.__read)(value.numericValues()), false));
@@ -732,7 +732,7 @@ function cssNumericSumValueEntryToUnitValue(term) {
732
732
  }
733
733
 
734
734
  function maybeSimplifyAsUnitValue(values, operator) {
735
- (0, _utils.DCHECK)(!!values.length);
735
+ (0, _assert.DCHECK)(!!values.length);
736
736
  var first_unit_value = values[0] instanceof CSSUnitValue ? values[0] : null;
737
737
  if (!first_unit_value) return null;
738
738
  var final_value = first_unit_value.value;
@@ -754,7 +754,7 @@ function maybeSimplifyAsUnitValue(values, operator) {
754
754
  }
755
755
 
756
756
  function maybeMultiplyAsUnitValue(values) {
757
- (0, _utils.DCHECK)(!!values.length); // We are allowed one unit value with type other than kNumber.
757
+ (0, _assert.DCHECK)(!!values.length); // We are allowed one unit value with type other than kNumber.
758
758
 
759
759
  var unit_other_than_number = _types.UnitType.kNumber;
760
760
  var final_value = 1.0;
@@ -800,7 +800,7 @@ function (_super) {
800
800
  unit = unitOrName;
801
801
  }
802
802
 
803
- (0, _utils.DCHECK)(CSSUnitValue.isValidUnit(unit));
803
+ (0, _assert.DCHECK)(CSSUnitValue.isValidUnit(unit));
804
804
  _this = _super.call(this, new CSSNumericValueType(unit)) || this;
805
805
  _this.unit = unit;
806
806
  _this.value = value;
@@ -833,7 +833,7 @@ function (_super) {
833
833
  if (!Number.isFinite(number)) {
834
834
  if (number > 0) result = 'infinity';else result = '-infinity';
835
835
  } else {
836
- (0, _utils.DCHECK)(Number.isNaN(number));
836
+ (0, _assert.DCHECK)(Number.isNaN(number));
837
837
  result = 'NaN';
838
838
  }
839
839
 
@@ -1490,7 +1490,7 @@ function (_super) {
1490
1490
  var exp = units[key];
1491
1491
  var error = false;
1492
1492
  type = CSSNumericValueType.multiply(type, new CSSNumericValueType(Number(key), exp), error);
1493
- (0, _utils.DCHECK)(!error);
1493
+ (0, _assert.DCHECK)(!error);
1494
1494
  });
1495
1495
  return type;
1496
1496
  };
@@ -1498,7 +1498,7 @@ function (_super) {
1498
1498
  CSSMathSum.canCreateNumericTypeFromSumValue = function (sum) {
1499
1499
  var _this = this;
1500
1500
 
1501
- (0, _utils.DCHECK)(!!sum.length);
1501
+ (0, _assert.DCHECK)(!!sum.length);
1502
1502
  var first_type = this.numericTypeFromUnitMap(sum[0].units);
1503
1503
  return sum.every(function (term) {
1504
1504
  var error = false;
@@ -1599,7 +1599,7 @@ function (_super) {
1599
1599
 
1600
1600
  CSSMathProduct.multiplyUnitMaps = function (a, b) {
1601
1601
  Object.keys(b).forEach(function (key) {
1602
- (0, _utils.DCHECK_NE)(b[key].value, 0);
1602
+ (0, _assert.DCHECK_NE)(b[key].value, 0);
1603
1603
  var old_value = key in a ? a[key].value : 0;
1604
1604
 
1605
1605
  if (old_value + b[key].value === 0) {
@@ -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/lib/css/index.js CHANGED
@@ -4,6 +4,19 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
 
7
+ var _interfaces = require("./interfaces");
8
+
9
+ Object.keys(_interfaces).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _interfaces[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _interfaces[key];
16
+ }
17
+ });
18
+ });
19
+
7
20
  var _cssom = require("./cssom");
8
21
 
9
22
  Object.keys(_cssom).forEach(function (key) {
@@ -43,41 +56,41 @@ Object.keys(_properties).forEach(function (key) {
43
56
  });
44
57
  });
45
58
 
46
- var _CSS = require("./CSS");
59
+ var _layout = require("./layout");
47
60
 
48
- Object.keys(_CSS).forEach(function (key) {
61
+ Object.keys(_layout).forEach(function (key) {
49
62
  if (key === "default" || key === "__esModule") return;
50
- if (key in exports && exports[key] === _CSS[key]) return;
63
+ if (key in exports && exports[key] === _layout[key]) return;
51
64
  Object.defineProperty(exports, key, {
52
65
  enumerable: true,
53
66
  get: function get() {
54
- return _CSS[key];
67
+ return _layout[key];
55
68
  }
56
69
  });
57
70
  });
58
71
 
59
- var _CSSProperty = require("./CSSProperty");
72
+ var _CSS = require("./CSS");
60
73
 
61
- Object.keys(_CSSProperty).forEach(function (key) {
74
+ Object.keys(_CSS).forEach(function (key) {
62
75
  if (key === "default" || key === "__esModule") return;
63
- if (key in exports && exports[key] === _CSSProperty[key]) return;
76
+ if (key in exports && exports[key] === _CSS[key]) return;
64
77
  Object.defineProperty(exports, key, {
65
78
  enumerable: true,
66
79
  get: function get() {
67
- return _CSSProperty[key];
80
+ return _CSS[key];
68
81
  }
69
82
  });
70
83
  });
71
84
 
72
- var _LayoutRegistry = require("./LayoutRegistry");
85
+ var _CSSProperty = require("./CSSProperty");
73
86
 
74
- Object.keys(_LayoutRegistry).forEach(function (key) {
87
+ Object.keys(_CSSProperty).forEach(function (key) {
75
88
  if (key === "default" || key === "__esModule") return;
76
- if (key in exports && exports[key] === _LayoutRegistry[key]) return;
89
+ if (key in exports && exports[key] === _CSSProperty[key]) return;
77
90
  Object.defineProperty(exports, key, {
78
91
  enumerable: true,
79
92
  get: function get() {
80
- return _LayoutRegistry[key];
93
+ return _CSSProperty[key];
81
94
  }
82
95
  });
83
96
  });
@@ -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,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.StyleValueRegistry = void 0;
7
+
8
+ var _manaSyringe = require("mana-syringe");
9
+
10
+ var StyleValueRegistry = _manaSyringe.Syringe.defineToken('StyleValueRegistry');
11
+
12
+ exports.StyleValueRegistry = 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,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.FragmentResultOptions = exports.FragmentResultFactory = exports.FragmentResult = exports.ContextNode = void 0;
7
+
8
+ var _tslib = require("tslib");
9
+
10
+ var _manaSyringe = require("mana-syringe");
11
+
12
+ var _LayoutObject = require("./LayoutObject");
13
+
14
+ var _LayoutContext = require("./LayoutContext");
15
+
16
+ var FragmentResultFactory = _manaSyringe.Syringe.defineToken('FragmentResultFactory');
17
+ /**
18
+ * The web developer defined layout method can return either a FragmentResultOptions or a FragmentResult.
19
+ */
20
+
21
+
22
+ exports.FragmentResultFactory = FragmentResultFactory;
23
+
24
+ var FragmentResultOptions = _manaSyringe.Syringe.defineToken('FragmentResultOptions');
25
+
26
+ exports.FragmentResultOptions = FragmentResultOptions;
27
+
28
+ var ContextNode = _manaSyringe.Syringe.defineToken('contextNode');
29
+
30
+ exports.ContextNode = ContextNode;
31
+
32
+ var FragmentResult =
33
+ /** @class */
34
+ function () {
35
+ function FragmentResult(_layoutContext, _node, options) {
36
+ this._layoutContext = _layoutContext;
37
+ this._node = _node;
38
+ this.options = options;
39
+ this.layoutContext = _layoutContext;
40
+ this.inlineSize = options === null || options === void 0 ? void 0 : options.inlineSize;
41
+ this.blockSize = options === null || options === void 0 ? void 0 : options.blockSize;
42
+ this.childFragments = options === null || options === void 0 ? void 0 : options.childFragments;
43
+ this.data = options.data;
44
+ this.node = _node;
45
+ }
46
+
47
+ FragmentResult = (0, _tslib.__decorate)([(0, _manaSyringe.injectable)(), (0, _tslib.__param)(0, (0, _manaSyringe.inject)(_LayoutContext.LayoutContext)), (0, _tslib.__param)(1, (0, _manaSyringe.inject)(ContextNode)), (0, _tslib.__param)(2, (0, _manaSyringe.inject)(FragmentResultOptions)), (0, _tslib.__metadata)("design:paramtypes", [_LayoutContext.LayoutContext, _LayoutObject.LayoutObject, Object])], FragmentResult);
48
+ return FragmentResult;
49
+ }();
50
+
51
+ exports.FragmentResult = FragmentResult;