laymur 0.18.1 → 0.19.1

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 (68) hide show
  1. package/README.md +44 -17
  2. package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.d.ts +1 -1
  3. package/dist/core/constraints/UIAspectConstraint/UIAspectConstraint.js +6 -6
  4. package/dist/core/constraints/UIConstraint.d.ts +1 -0
  5. package/dist/core/constraints/UIConstraint.js +4 -0
  6. package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.d.ts +1 -1
  7. package/dist/core/constraints/UIHeightConstraint/UIHeightConstraint.js +5 -5
  8. package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.d.ts +2 -2
  9. package/dist/core/constraints/UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.js +14 -14
  10. package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.d.ts +3 -3
  11. package/dist/core/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.js +20 -20
  12. package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.d.ts +2 -2
  13. package/dist/core/constraints/UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.js +5 -5
  14. package/dist/core/constraints/UISingleParameterConstraint/UISingleParameterConstraint.js +1 -0
  15. package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.d.ts +2 -2
  16. package/dist/core/constraints/UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.js +14 -14
  17. package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.d.ts +3 -3
  18. package/dist/core/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.js +20 -20
  19. package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.d.ts +2 -2
  20. package/dist/core/constraints/UIVerticalProportionConstraint/UIVerticalProportionConstraint.js +5 -5
  21. package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.d.ts +1 -1
  22. package/dist/core/constraints/UIWidthConstraint/UIWidthConstraint.js +5 -5
  23. package/dist/core/layers/UILayer/UILayer.d.ts +18 -0
  24. package/dist/core/layers/UILayer/UILayer.js +48 -0
  25. package/dist/core/miscellaneous/color/UIColor.js +4 -4
  26. package/dist/core/miscellaneous/shared.d.ts +8 -0
  27. package/dist/debug/UIAspectDebug.d.ts +26 -0
  28. package/dist/debug/UIAspectDebug.js +118 -0
  29. package/dist/debug/UIConstraintDebug.d.ts +7 -0
  30. package/dist/debug/UIHeightDebug.d.ts +26 -0
  31. package/dist/debug/UIHeightDebug.js +111 -0
  32. package/dist/debug/UIHorizontalDistanceDebug.d.ts +29 -0
  33. package/dist/debug/UIHorizontalDistanceDebug.js +158 -0
  34. package/dist/debug/UIHorizontalInterpolationDebug.d.ts +29 -0
  35. package/dist/debug/UIHorizontalInterpolationDebug.js +145 -0
  36. package/dist/debug/UILayerDebug.d.ts +34 -0
  37. package/dist/debug/UILayerDebug.js +124 -0
  38. package/dist/debug/UIVerticalDistanceDebug.d.ts +29 -0
  39. package/dist/debug/UIVerticalDistanceDebug.js +158 -0
  40. package/dist/debug/UIVerticalInterpolationDebug.d.ts +29 -0
  41. package/dist/debug/UIVerticalInterpolationDebug.js +145 -0
  42. package/dist/debug/UIWidthDebug.d.ts +26 -0
  43. package/dist/debug/UIWidthDebug.js +111 -0
  44. package/dist/debug/index.d.ts +8 -0
  45. package/dist/debug/index.js +8 -0
  46. package/dist/debug/miscellaneous.d.ts +8 -0
  47. package/dist/debug/miscellaneous.js +11 -0
  48. package/dist/node_modules/three/examples/jsm/lines/Line2.js +56 -0
  49. package/dist/node_modules/three/examples/jsm/lines/LineGeometry.js +157 -0
  50. package/dist/node_modules/three/examples/jsm/lines/LineMaterial.js +691 -0
  51. package/dist/node_modules/three/examples/jsm/lines/LineSegments2.js +415 -0
  52. package/dist/node_modules/three/examples/jsm/lines/LineSegmentsGeometry.js +289 -0
  53. package/dist/particles/behaviorModules/UIBehaviorDirectionalGravity.d.ts +1 -1
  54. package/dist/particles/behaviorModules/UIBehaviorScaleOverLife.d.ts +1 -1
  55. package/dist/particles/behaviorModules/UIBehaviorTorqueDamping.d.ts +1 -1
  56. package/dist/particles/behaviorModules/UIBehaviorTorqueNoise.d.ts +1 -1
  57. package/dist/particles/behaviorModules/UIBehaviorVelocityDamping.d.ts +1 -1
  58. package/dist/particles/elements/UIEmitter.d.ts +1 -1
  59. package/dist/particles/instancedParticle/UIInstancedParticle.Internal.d.ts +1 -2
  60. package/dist/particles/instancedParticle/UIInstancedParticle.d.ts +1 -1
  61. package/dist/particles/miscellaneous/miscellaneous.d.ts +2 -1
  62. package/dist/particles/spawnModules/UISpawnOffset.d.ts +1 -1
  63. package/dist/particles/spawnModules/UISpawnRandomRotation.d.ts +1 -1
  64. package/dist/particles/spawnModules/UISpawnRandomScale.d.ts +1 -1
  65. package/dist/particles/spawnModules/UISpawnRandomTorque.d.ts +1 -1
  66. package/dist/particles/spawnModules/UISpawnRandomVelocity.d.ts +1 -1
  67. package/dist/particles/spawnModules/UISpawnRectangle.d.ts +1 -1
  68. package/package.json +5 -1
package/README.md CHANGED
@@ -15,11 +15,12 @@
15
15
 
16
16
  ## Features
17
17
 
18
- * **Cassowary solver** — constraint-based layouts via `@lume/kiwi`
19
- * **Orientation-aware** — define portrait and landscape rules in one layout, solver toggles automatically
20
- * **Micro-transforms** — visual-only transforms (scale, rotation, offset) that bypass the solver
21
- * **Resize policies** — Cover, Fit, FixedHeight, FixedWidth, Cross strategies
22
- * **Modular particles** — separate `laymur/particles` entry point, import only if needed
18
+ * **Cassowary solver** - constraint-based layouts via `@lume/kiwi`
19
+ * **Orientation-aware** - define portrait and landscape rules in one layout, solver toggles automatically
20
+ * **Micro-transforms** - visual-only transforms (scale, rotation, offset) that bypass the solver
21
+ * **Resize policies** - Cover, Fit, FixedHeight, FixedWidth, Cross strategies
22
+ * **Modular particles** - separate `laymur/particles` entry point, import only if needed
23
+ * **Debug overlay** - separate `laymur/debug` entry point, constraint visualization
23
24
 
24
25
  ## Installation
25
26
 
@@ -33,10 +34,14 @@ Peer Dependencies:
33
34
  * `@lume/kiwi` (^0.4.4)
34
35
  * `ferrsign` (^0.0.4)
35
36
 
36
- ## Live Examples
37
+ ## Visual Editor & Live Examples
38
+
39
+ Check out visual editor and interactive examples at:
40
+
41
+ **[EDITOR](https://jango-git.github.io/laymur-docs/editor/index.html)**
42
+
43
+ **[EXAMPLES](https://jango-git.github.io/laymur/examples/index.html)**
37
44
 
38
- Check out interactive examples and demos at:
39
- **[https://jango-git.github.io/laymur/](https://jango-git.github.io/laymur/)**
40
45
 
41
46
  ## Core Concepts
42
47
 
@@ -93,7 +98,7 @@ new UIHorizontalProportionConstraint(layer, element, {
93
98
 
94
99
  ### 3. Micro-transforms
95
100
 
96
- For animations, use `.micro` — updates visual matrix without triggering the solver.
101
+ For animations, use `.micro` - updates visual matrix without triggering the solver.
97
102
 
98
103
  ```typescript
99
104
  element.micro.scaleX = Math.sin(Date.now() * 0.001) + 1;
@@ -118,6 +123,34 @@ const emitter = new UIEmitter(
118
123
  emitter.play(60); // particles/sec
119
124
  ```
120
125
 
126
+ ### 5. Debug Overlay
127
+
128
+ `laymur/debug` renders visual overlays for constraints - useful during development to inspect layout relationships.
129
+
130
+ `UILayerDebug` automatically tracks all constraints on a layer and creates the corresponding overlays. Individual constraint types can be toggled on/off.
131
+
132
+ ```typescript
133
+ import { UILayerDebug } from 'laymur/debug';
134
+
135
+ const debug = new UILayerDebug(layer, {
136
+ showAspect: true,
137
+ showWidth: true,
138
+ showHeight: true,
139
+ showHorizontalDistance: true,
140
+ showVerticalDistance: true,
141
+ showHorizontalInterpolation: false,
142
+ showVerticalInterpolation: false,
143
+ });
144
+
145
+ // Toggle a category at runtime
146
+ debug.showAspect = false;
147
+
148
+ // Clean up
149
+ debug.destroy();
150
+ ```
151
+
152
+ Overlays respect orientation - they hide automatically when their constraint's orientation is inactive.
153
+
121
154
  ## API Overview
122
155
 
123
156
  Most commonly used exports (not exhaustive):
@@ -134,15 +167,9 @@ UIAspectConstraint, UIHorizontalDistanceConstraint, UIVerticalDistanceConstraint
134
167
 
135
168
  UIEmitter, UISpawnRectangle, UISpawnRandomLifetime, UIBehaviorDirectionalGravity, UIBehaviorVelocityDamping, UIRenderingTexture, UIRenderingColorOverLife
136
169
 
137
- ## Entry Points
170
+ ### Debug (laymur/debug)
138
171
 
139
- ```json
140
- // package.json
141
- "exports": {
142
- ".": "./dist/index.js",
143
- "./particles": "./dist/particles/index.js"
144
- }
145
- ```
172
+ UILayerDebug, UIAspectDebug, UIHeightDebug, UIWidthDebug, UIHorizontalDistanceDebug, UIVerticalDistanceDebug, UIHorizontalInterpolationDebug, UIVerticalInterpolationDebug
146
173
 
147
174
  ## License
148
175
 
@@ -3,7 +3,7 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
3
3
  import type { UIAspectConstraintOptions } from "./UIAspectConstraint.Internal";
4
4
  /** Maintains element aspect ratio (width = height * aspect) */
5
5
  export declare class UIAspectConstraint extends UISingleParameterConstraint {
6
- private readonly element;
6
+ readonly element: UIPlaneElement & UILayerElement;
7
7
  /** Solver constraint descriptor */
8
8
  protected readonly constraint: number;
9
9
  /** Current aspect ratio */
@@ -8,13 +8,13 @@ class UIAspectConstraint extends UISingleParameterConstraint {
8
8
  * @param element Element to constrain
9
9
  * @param options Aspect configuration. Defaults to element's current ratio.
10
10
  */
11
- constructor(_private_element, options = {}) {
11
+ constructor(element, options = {}) {
12
12
  if (options.aspect !== undefined) {
13
13
  assertValidPositiveNumber(options.aspect, "UIAspectConstraint.constructor.options.aspect");
14
14
  }
15
- super(_private_element.layer, options);
16
- this._private_element = _private_element;
17
- this._private_aspectInternal = options.aspect ?? _private_element.width / _private_element.height;
15
+ super(element.layer, options);
16
+ this.element = element;
17
+ this._private_aspectInternal = options.aspect ?? element.width / element.height;
18
18
  this.constraint = this.solverWrapper.createConstraint(this._private_buildLHS(), new UIExpression(0), this.relation, this.priority, this.isConstraintEnabled());
19
19
  }
20
20
  /** Current aspect ratio (width/height) */
@@ -32,8 +32,8 @@ class UIAspectConstraint extends UISingleParameterConstraint {
32
32
  /** Builds constraint expression: width - (height * aspect) = 0 */
33
33
  _private_buildLHS() {
34
34
  return new UIExpression(0, [
35
- [this._private_element.wVariable, 1],
36
- [this._private_element.hVariable, -this._private_aspectInternal],
35
+ [this.element.wVariable, 1],
36
+ [this.element.hVariable, -this._private_aspectInternal],
37
37
  ]);
38
38
  }
39
39
  }
@@ -9,4 +9,5 @@ export declare abstract class UIConstraint {
9
9
  protected readonly solverWrapper: UISolverWrapperView;
10
10
  /** @param layer Layer containing this constraint */
11
11
  constructor(layer: UILayer, name?: string);
12
+ destroy(): void;
12
13
  }
@@ -5,6 +5,10 @@ class UIConstraint {
5
5
  this.layer = layer;
6
6
  this.solverWrapper = this.layer.solverWrapper;
7
7
  this.name = name ?? "";
8
+ this.layer.addConstraint(this);
9
+ }
10
+ destroy() {
11
+ this.layer.removeConstraint(this);
8
12
  }
9
13
  }
10
14
 
@@ -3,7 +3,7 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
3
3
  import type { UIHeightConstraintOptions } from "./UIHeightConstraint.Internal";
4
4
  /** Fixes element height to constant value */
5
5
  export declare class UIHeightConstraint extends UISingleParameterConstraint {
6
- private readonly element;
6
+ readonly element: UIPlaneElement & UILayerElement;
7
7
  /** Solver constraint descriptor */
8
8
  protected readonly constraint: number;
9
9
  /** Current height value */
@@ -8,14 +8,14 @@ class UIHeightConstraint extends UISingleParameterConstraint {
8
8
  * @param element Element to constrain
9
9
  * @param options Height configuration. Defaults to element's current height.
10
10
  */
11
- constructor(_private_element, options = {}) {
11
+ constructor(element, options = {}) {
12
12
  if (options.height !== undefined) {
13
13
  assertValidPositiveNumber(options.height, "UIHeightConstraint.constructor.options.height");
14
14
  }
15
- super(_private_element.layer, options);
16
- this._private_element = _private_element;
17
- this._private_heightInternal = options.height ?? _private_element.height;
18
- this.constraint = this.solverWrapper.createConstraint(new UIExpression(0, [[this._private_element.hVariable, 1]]), new UIExpression(this._private_heightInternal), this.relation, this.priority, this.isConstraintEnabled());
15
+ super(element.layer, options);
16
+ this.element = element;
17
+ this._private_heightInternal = options.height ?? element.height;
18
+ this.constraint = this.solverWrapper.createConstraint(new UIExpression(0, [[this.element.hVariable, 1]]), new UIExpression(this._private_heightInternal), this.relation, this.priority, this.isConstraintEnabled());
19
19
  }
20
20
  /** Current height in world units */
21
21
  get height() {
@@ -3,8 +3,8 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
3
3
  import type { UIHorizontalDistanceConstraintOptions } from "./UIHorizontalDistanceConstraint.Internal";
4
4
  /** Maintains horizontal distance between elements with configurable anchors */
5
5
  export declare class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
6
- private readonly a;
7
- private readonly b;
6
+ readonly a: UIPointElement | UIPlaneElement;
7
+ readonly b: UIPointElement | UIPlaneElement;
8
8
  /** Solver constraint descriptor */
9
9
  protected readonly constraint: number;
10
10
  /** Anchor on element A */
@@ -11,7 +11,7 @@ class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
11
11
  * @param b Second element
12
12
  * @param options Distance configuration
13
13
  */
14
- constructor(_private_a, _private_b, options = {}) {
14
+ constructor(a, b, options = {}) {
15
15
  if (options.anchorA !== undefined) {
16
16
  assertValidNumber(options.anchorA, "UIHorizontalDistanceConstraint.constructor.options.anchorA");
17
17
  }
@@ -21,9 +21,9 @@ class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
21
21
  if (options.distance !== undefined) {
22
22
  assertValidNumber(options.distance, "UIHorizontalDistanceConstraint.constructor.options.distance");
23
23
  }
24
- super(assertValidConstraintArguments(_private_a, _private_b, "UIHorizontalDistanceConstraint.constructor"), options);
25
- this._private_a = _private_a;
26
- this._private_b = _private_b;
24
+ super(assertValidConstraintArguments(a, b, "UIHorizontalDistanceConstraint.constructor"), options);
25
+ this.a = a;
26
+ this.b = b;
27
27
  this._private_anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR;
28
28
  this._private_anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR;
29
29
  this._private_distanceInternal = options.distance ?? 0;
@@ -69,26 +69,26 @@ class UIHorizontalDistanceConstraint extends UISingleParameterConstraint {
69
69
  _private_buildLHS() {
70
70
  let aExpression;
71
71
  let bExpression;
72
- if (isUIPlaneElement(this._private_a)) {
72
+ if (isUIPlaneElement(this.a)) {
73
73
  aExpression = new UIExpression(0, [
74
- [this._private_a.xVariable, 1],
75
- [this._private_a.wVariable, this._private_anchorAInternal],
74
+ [this.a.xVariable, 1],
75
+ [this.a.wVariable, this._private_anchorAInternal],
76
76
  ]);
77
77
  }
78
- else if (isUIPointElement(this._private_a)) {
79
- aExpression = new UIExpression().plus(this._private_a.xVariable, 1);
78
+ else if (isUIPointElement(this.a)) {
79
+ aExpression = new UIExpression().plus(this.a.xVariable, 1);
80
80
  }
81
81
  else {
82
82
  throw new Error("UIHorizontalDistanceConstraint.buildLHS.a: invalid element type");
83
83
  }
84
- if (isUIPlaneElement(this._private_b)) {
84
+ if (isUIPlaneElement(this.b)) {
85
85
  bExpression = new UIExpression(0, [
86
- [this._private_b.xVariable, 1],
87
- [this._private_b.wVariable, this._private_anchorBInternal],
86
+ [this.b.xVariable, 1],
87
+ [this.b.wVariable, this._private_anchorBInternal],
88
88
  ]);
89
89
  }
90
- else if (isUIPointElement(this._private_b)) {
91
- bExpression = new UIExpression().plus(this._private_b.xVariable, 1);
90
+ else if (isUIPointElement(this.b)) {
91
+ bExpression = new UIExpression().plus(this.b.xVariable, 1);
92
92
  }
93
93
  else {
94
94
  throw new Error("UIHorizontalDistanceConstraint.buildLHS.b: invalid element type");
@@ -3,9 +3,9 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
3
3
  import type { UIHorizontalInterpolationConstraintOptions } from "./UIHorizontalInterpolationConstraint.Internal";
4
4
  /** Positions element C horizontally between A and B based on interpolation factor */
5
5
  export declare class UIHorizontalInterpolationConstraint extends UISingleParameterConstraint {
6
- private readonly a;
7
- private readonly b;
8
- private readonly c;
6
+ readonly a: UIPointElement | UIPlaneElement;
7
+ readonly b: UIPointElement | UIPlaneElement;
8
+ readonly c: UIPointElement | UIPlaneElement;
9
9
  /** Solver constraint descriptor */
10
10
  protected readonly constraint: number;
11
11
  /** Anchor on element A */
@@ -12,7 +12,7 @@ class UIHorizontalInterpolationConstraint extends UISingleParameterConstraint {
12
12
  * @param c Element to position between A and B
13
13
  * @param options Interpolation configuration
14
14
  */
15
- constructor(_private_a, _private_b, _private_c, options = {}) {
15
+ constructor(a, b, c, options = {}) {
16
16
  if (options.anchorA !== undefined) {
17
17
  assertValidNumber(options.anchorA, "UIHorizontalInterpolationConstraint.constructor.options.anchorA");
18
18
  }
@@ -27,10 +27,10 @@ class UIHorizontalInterpolationConstraint extends UISingleParameterConstraint {
27
27
  }
28
28
  const anchorA = options.anchorA ?? DEFAULT_ANCHOR;
29
29
  const anchorB = options.anchorB ?? DEFAULT_ANCHOR;
30
- super(assertValidInterpolationConstraintArguments("UIHorizontalInterpolationConstraint.constructor", _private_a, _private_b, _private_c, anchorA, anchorB), options);
31
- this._private_a = _private_a;
32
- this._private_b = _private_b;
33
- this._private_c = _private_c;
30
+ super(assertValidInterpolationConstraintArguments("UIHorizontalInterpolationConstraint.constructor", a, b, c, anchorA, anchorB), options);
31
+ this.a = a;
32
+ this.b = b;
33
+ this.c = c;
34
34
  this._private_anchorAInternal = anchorA;
35
35
  this._private_anchorBInternal = anchorA;
36
36
  this._private_anchorCInternal = options.anchorC ?? DEFAULT_ANCHOR;
@@ -90,38 +90,38 @@ class UIHorizontalInterpolationConstraint extends UISingleParameterConstraint {
90
90
  let aExpression;
91
91
  let bExpression;
92
92
  let cExpression;
93
- if (isUIPlaneElement(this._private_a)) {
93
+ if (isUIPlaneElement(this.a)) {
94
94
  aExpression = new UIExpression(0, [
95
- [this._private_a.xVariable, 1],
96
- [this._private_a.wVariable, this._private_anchorAInternal],
95
+ [this.a.xVariable, 1],
96
+ [this.a.wVariable, this._private_anchorAInternal],
97
97
  ]);
98
98
  }
99
- else if (isUIPointElement(this._private_a)) {
100
- aExpression = new UIExpression().plus(this._private_a.xVariable, 1);
99
+ else if (isUIPointElement(this.a)) {
100
+ aExpression = new UIExpression().plus(this.a.xVariable, 1);
101
101
  }
102
102
  else {
103
103
  throw new Error("UIHorizontalInterpolationConstraint.buildLHS.a: invalid element type");
104
104
  }
105
- if (isUIPlaneElement(this._private_b)) {
105
+ if (isUIPlaneElement(this.b)) {
106
106
  bExpression = new UIExpression(0, [
107
- [this._private_b.xVariable, 1],
108
- [this._private_b.wVariable, this._private_anchorBInternal],
107
+ [this.b.xVariable, 1],
108
+ [this.b.wVariable, this._private_anchorBInternal],
109
109
  ]);
110
110
  }
111
- else if (isUIPointElement(this._private_b)) {
112
- bExpression = new UIExpression().plus(this._private_b.xVariable, 1);
111
+ else if (isUIPointElement(this.b)) {
112
+ bExpression = new UIExpression().plus(this.b.xVariable, 1);
113
113
  }
114
114
  else {
115
115
  throw new Error("UIHorizontalInterpolationConstraint.buildLHS.b: invalid element type");
116
116
  }
117
- if (isUIPlaneElement(this._private_c)) {
117
+ if (isUIPlaneElement(this.c)) {
118
118
  cExpression = new UIExpression(0, [
119
- [this._private_c.xVariable, 1],
120
- [this._private_c.wVariable, this._private_anchorCInternal],
119
+ [this.c.xVariable, 1],
120
+ [this.c.wVariable, this._private_anchorCInternal],
121
121
  ]);
122
122
  }
123
- else if (isUIPointElement(this._private_c)) {
124
- cExpression = new UIExpression().plus(this._private_c.xVariable, 1);
123
+ else if (isUIPointElement(this.c)) {
124
+ cExpression = new UIExpression().plus(this.c.xVariable, 1);
125
125
  }
126
126
  else {
127
127
  throw new Error("UIHorizontalInterpolationConstraint.buildLHS.c: invalid element type");
@@ -3,8 +3,8 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
3
3
  import type { UIHorizontalProportionConstraintOptions } from "./UIHorizontalProportionConstraint.Internal";
4
4
  /** Maintains proportional width relationship (A.width * proportion = B.width) */
5
5
  export declare class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
6
- private readonly a;
7
- private readonly b;
6
+ readonly a: UIPlaneElement;
7
+ readonly b: UIPlaneElement;
8
8
  protected readonly constraint: number;
9
9
  private proportionInternal;
10
10
  /**
@@ -9,13 +9,13 @@ class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
9
9
  * @param b Second element
10
10
  * @param options Proportion configuration
11
11
  */
12
- constructor(_private_a, _private_b, options = {}) {
12
+ constructor(a, b, options = {}) {
13
13
  if (options.proportion !== undefined) {
14
14
  assertValidPositiveNumber(options.proportion, "UIHorizontalProportionConstraint.constructor.options.proportion");
15
15
  }
16
- super(assertValidConstraintArguments(_private_a, _private_b, "UIHorizontalProportionConstraint.constructor"), options);
17
- this._private_a = _private_a;
18
- this._private_b = _private_b;
16
+ super(assertValidConstraintArguments(a, b, "UIHorizontalProportionConstraint.constructor"), options);
17
+ this.a = a;
18
+ this.b = b;
19
19
  this._private_proportionInternal = options.proportion ?? 1;
20
20
  this.constraint = this.solverWrapper.createConstraint(new UIExpression(0), this._private_buildRHS(), this.relation, this.priority, this.isConstraintEnabled());
21
21
  }
@@ -33,7 +33,7 @@ class UIHorizontalProportionConstraint extends UISingleParameterConstraint {
33
33
  }
34
34
  /** Builds constraint expression for proportional relationship */
35
35
  _private_buildRHS() {
36
- return UIExpression.minus(new UIExpression(0, [[this._private_a.wVariable, this._private_proportionInternal]]), new UIExpression(0, [[this._private_b.wVariable, 1]]));
36
+ return UIExpression.minus(new UIExpression(0, [[this.a.wVariable, this._private_proportionInternal]]), new UIExpression(0, [[this.b.wVariable, 1]]));
37
37
  }
38
38
  }
39
39
 
@@ -57,6 +57,7 @@ class UISingleParameterConstraint extends UIConstraint {
57
57
  destroy() {
58
58
  this.layer.signalOrientationChanged.off(this._private_onOrientationChange);
59
59
  this.solverWrapper.removeConstraint(this.constraint);
60
+ super.destroy();
60
61
  }
61
62
  /**
62
63
  * Checks if constraint should be active for current orientation.
@@ -3,8 +3,8 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
3
3
  import type { UIVerticalDistanceConstraintOptions } from "./UIVerticalDistanceConstraint.Internal";
4
4
  /** Maintains vertical distance between elements with configurable anchors */
5
5
  export declare class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
6
- private readonly a;
7
- private readonly b;
6
+ readonly a: UIPointElement | UIPlaneElement;
7
+ readonly b: UIPointElement | UIPlaneElement;
8
8
  protected readonly constraint: number;
9
9
  private anchorAInternal;
10
10
  private anchorBInternal;
@@ -11,7 +11,7 @@ class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
11
11
  * @param b Second element
12
12
  * @param options Distance configuration
13
13
  */
14
- constructor(_private_a, _private_b, options = {}) {
14
+ constructor(a, b, options = {}) {
15
15
  if (options.anchorA !== undefined) {
16
16
  assertValidNumber(options.anchorA, "UIVerticalDistanceConstraint.constructor.options.anchorA");
17
17
  }
@@ -21,9 +21,9 @@ class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
21
21
  if (options.distance !== undefined) {
22
22
  assertValidNumber(options.distance, "UIVerticalDistanceConstraint.constructor.options.distance");
23
23
  }
24
- super(assertValidConstraintArguments(_private_a, _private_b, "UIVerticalDistanceConstraint.constructor"), options);
25
- this._private_a = _private_a;
26
- this._private_b = _private_b;
24
+ super(assertValidConstraintArguments(a, b, "UIVerticalDistanceConstraint.constructor"), options);
25
+ this.a = a;
26
+ this.b = b;
27
27
  this._private_anchorAInternal = options.anchorA ?? DEFAULT_ANCHOR;
28
28
  this._private_anchorBInternal = options.anchorB ?? DEFAULT_ANCHOR;
29
29
  this._private_distanceInternal = options.distance ?? 0;
@@ -69,26 +69,26 @@ class UIVerticalDistanceConstraint extends UISingleParameterConstraint {
69
69
  _private_buildLHS() {
70
70
  let aExpression;
71
71
  let bExpression;
72
- if (isUIPlaneElement(this._private_a)) {
72
+ if (isUIPlaneElement(this.a)) {
73
73
  aExpression = new UIExpression(0, [
74
- [this._private_a.yVariable, 1],
75
- [this._private_a.hVariable, this._private_anchorAInternal],
74
+ [this.a.yVariable, 1],
75
+ [this.a.hVariable, this._private_anchorAInternal],
76
76
  ]);
77
77
  }
78
- else if (isUIPointElement(this._private_a)) {
79
- aExpression = new UIExpression().plus(this._private_a.yVariable, 1);
78
+ else if (isUIPointElement(this.a)) {
79
+ aExpression = new UIExpression().plus(this.a.yVariable, 1);
80
80
  }
81
81
  else {
82
82
  throw new Error("UIVerticalDistanceConstraint.buildLHS.a: invalid element type");
83
83
  }
84
- if (isUIPlaneElement(this._private_b)) {
84
+ if (isUIPlaneElement(this.b)) {
85
85
  bExpression = new UIExpression(0, [
86
- [this._private_b.yVariable, 1],
87
- [this._private_b.hVariable, this._private_anchorBInternal],
86
+ [this.b.yVariable, 1],
87
+ [this.b.hVariable, this._private_anchorBInternal],
88
88
  ]);
89
89
  }
90
- else if (isUIPointElement(this._private_b)) {
91
- bExpression = new UIExpression().plus(this._private_b.yVariable, 1);
90
+ else if (isUIPointElement(this.b)) {
91
+ bExpression = new UIExpression().plus(this.b.yVariable, 1);
92
92
  }
93
93
  else {
94
94
  throw new Error("UIVerticalDistanceConstraint.buildLHS.b: invalid element type");
@@ -3,9 +3,9 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
3
3
  import type { UIVerticalInterpolationConstraintOptions } from "./UIVerticalInterpolationConstraint.Internal";
4
4
  /** Positions element C vertically between A and B based on interpolation factor */
5
5
  export declare class UIVerticalInterpolationConstraint extends UISingleParameterConstraint {
6
- private readonly a;
7
- private readonly b;
8
- private readonly c;
6
+ readonly a: UIPointElement | UIPlaneElement;
7
+ readonly b: UIPointElement | UIPlaneElement;
8
+ readonly c: UIPointElement | UIPlaneElement;
9
9
  /** Solver constraint descriptor */
10
10
  protected readonly constraint: number;
11
11
  /** Anchor on element A */
@@ -12,7 +12,7 @@ class UIVerticalInterpolationConstraint extends UISingleParameterConstraint {
12
12
  * @param c Element to position between A and B
13
13
  * @param options Interpolation configuration
14
14
  */
15
- constructor(_private_a, _private_b, _private_c, options = {}) {
15
+ constructor(a, b, c, options = {}) {
16
16
  if (options.anchorA !== undefined) {
17
17
  assertValidNumber(options.anchorA, "UIVerticalInterpolationConstraint.constructor.options.anchorA");
18
18
  }
@@ -27,10 +27,10 @@ class UIVerticalInterpolationConstraint extends UISingleParameterConstraint {
27
27
  }
28
28
  const anchorA = options.anchorA ?? DEFAULT_ANCHOR;
29
29
  const anchorB = options.anchorB ?? DEFAULT_ANCHOR;
30
- super(assertValidInterpolationConstraintArguments("UIVerticalInterpolationConstraint.constructor", _private_a, _private_b, _private_c, anchorA, anchorB), options);
31
- this._private_a = _private_a;
32
- this._private_b = _private_b;
33
- this._private_c = _private_c;
30
+ super(assertValidInterpolationConstraintArguments("UIVerticalInterpolationConstraint.constructor", a, b, c, anchorA, anchorB), options);
31
+ this.a = a;
32
+ this.b = b;
33
+ this.c = c;
34
34
  this._private_anchorAInternal = anchorA;
35
35
  this._private_anchorBInternal = anchorA;
36
36
  this._private_anchorCInternal = options.anchorC ?? DEFAULT_ANCHOR;
@@ -90,38 +90,38 @@ class UIVerticalInterpolationConstraint extends UISingleParameterConstraint {
90
90
  let aExpression;
91
91
  let bExpression;
92
92
  let cExpression;
93
- if (isUIPlaneElement(this._private_a)) {
93
+ if (isUIPlaneElement(this.a)) {
94
94
  aExpression = new UIExpression(0, [
95
- [this._private_a.yVariable, 1],
96
- [this._private_a.hVariable, this._private_anchorAInternal],
95
+ [this.a.yVariable, 1],
96
+ [this.a.hVariable, this._private_anchorAInternal],
97
97
  ]);
98
98
  }
99
- else if (isUIPointElement(this._private_a)) {
100
- aExpression = new UIExpression().plus(this._private_a.yVariable, 1);
99
+ else if (isUIPointElement(this.a)) {
100
+ aExpression = new UIExpression().plus(this.a.yVariable, 1);
101
101
  }
102
102
  else {
103
103
  throw new Error("UIVerticalInterpolationConstraint.buildLHS.a: invalid element type");
104
104
  }
105
- if (isUIPlaneElement(this._private_b)) {
105
+ if (isUIPlaneElement(this.b)) {
106
106
  bExpression = new UIExpression(0, [
107
- [this._private_b.yVariable, 1],
108
- [this._private_b.hVariable, this._private_anchorBInternal],
107
+ [this.b.yVariable, 1],
108
+ [this.b.hVariable, this._private_anchorBInternal],
109
109
  ]);
110
110
  }
111
- else if (isUIPointElement(this._private_b)) {
112
- bExpression = new UIExpression().plus(this._private_b.yVariable, 1);
111
+ else if (isUIPointElement(this.b)) {
112
+ bExpression = new UIExpression().plus(this.b.yVariable, 1);
113
113
  }
114
114
  else {
115
115
  throw new Error("UIVerticalInterpolationConstraint.buildLHS.b: invalid element type");
116
116
  }
117
- if (isUIPlaneElement(this._private_c)) {
117
+ if (isUIPlaneElement(this.c)) {
118
118
  cExpression = new UIExpression(0, [
119
- [this._private_c.yVariable, 1],
120
- [this._private_c.hVariable, this._private_anchorCInternal],
119
+ [this.c.yVariable, 1],
120
+ [this.c.hVariable, this._private_anchorCInternal],
121
121
  ]);
122
122
  }
123
- else if (isUIPointElement(this._private_c)) {
124
- cExpression = new UIExpression().plus(this._private_c.yVariable, 1);
123
+ else if (isUIPointElement(this.c)) {
124
+ cExpression = new UIExpression().plus(this.c.yVariable, 1);
125
125
  }
126
126
  else {
127
127
  throw new Error("UIVerticalInterpolationConstraint.buildLHS.c: invalid element type");
@@ -3,8 +3,8 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
3
3
  import type { UIVerticalProportionConstraintOptions } from "./UIVerticalProportionConstraint.Internal";
4
4
  /** Maintains proportional height relationship (A.height * proportion = B.height) */
5
5
  export declare class UIVerticalProportionConstraint extends UISingleParameterConstraint {
6
- private readonly a;
7
- private readonly b;
6
+ readonly a: UIPlaneElement;
7
+ readonly b: UIPlaneElement;
8
8
  protected readonly constraint: number;
9
9
  private proportionInternal;
10
10
  /**
@@ -9,13 +9,13 @@ class UIVerticalProportionConstraint extends UISingleParameterConstraint {
9
9
  * @param b Second element
10
10
  * @param options Proportion configuration
11
11
  */
12
- constructor(_private_a, _private_b, options = {}) {
12
+ constructor(a, b, options = {}) {
13
13
  if (options.proportion !== undefined) {
14
14
  assertValidPositiveNumber(options.proportion, "UIVerticalProportionConstraint.constructor.options.proportion");
15
15
  }
16
- super(assertValidConstraintArguments(_private_a, _private_b, "UIVerticalProportionConstraint.constructor"), options);
17
- this._private_a = _private_a;
18
- this._private_b = _private_b;
16
+ super(assertValidConstraintArguments(a, b, "UIVerticalProportionConstraint.constructor"), options);
17
+ this.a = a;
18
+ this.b = b;
19
19
  this._private_proportionInternal = options.proportion ?? 1;
20
20
  this.constraint = this.solverWrapper.createConstraint(new UIExpression(0), this._private_buildRHS(), this.relation, this.priority, this.isConstraintEnabled());
21
21
  }
@@ -33,7 +33,7 @@ class UIVerticalProportionConstraint extends UISingleParameterConstraint {
33
33
  }
34
34
  /** Builds constraint expression for proportional relationship */
35
35
  _private_buildRHS() {
36
- return UIExpression.minus(new UIExpression(0, [[this._private_a.hVariable, this._private_proportionInternal]]), new UIExpression(0, [[this._private_b.hVariable, 1]]));
36
+ return UIExpression.minus(new UIExpression(0, [[this.a.hVariable, this._private_proportionInternal]]), new UIExpression(0, [[this.b.hVariable, 1]]));
37
37
  }
38
38
  }
39
39
 
@@ -3,7 +3,7 @@ import { UISingleParameterConstraint } from "../UISingleParameterConstraint/UISi
3
3
  import type { UIWidthConstraintOptions } from "./UIWidthConstraint.Internal";
4
4
  /** Fixes element width to constant value */
5
5
  export declare class UIWidthConstraint extends UISingleParameterConstraint {
6
- private readonly element;
6
+ readonly element: UIPlaneElement & UILayerElement;
7
7
  /** Solver constraint descriptor */
8
8
  protected readonly constraint: number;
9
9
  /** Current width value */
@@ -8,14 +8,14 @@ class UIWidthConstraint extends UISingleParameterConstraint {
8
8
  * @param element Element to constrain
9
9
  * @param options Width configuration. Defaults to element's current width.
10
10
  */
11
- constructor(_private_element, options = {}) {
11
+ constructor(element, options = {}) {
12
12
  if (options.width !== undefined) {
13
13
  assertValidPositiveNumber(options.width, "UIWidthConstraint.constructor.options.width");
14
14
  }
15
- super(_private_element.layer, options);
16
- this._private_element = _private_element;
17
- this._private_widthInternal = options.width ?? _private_element.width;
18
- this.constraint = this.solverWrapper.createConstraint(new UIExpression(0, [[this._private_element.wVariable, 1]]), new UIExpression(this._private_widthInternal), this.relation, this.priority, this.isConstraintEnabled());
15
+ super(element.layer, options);
16
+ this.element = element;
17
+ this._private_widthInternal = options.width ?? element.width;
18
+ this.constraint = this.solverWrapper.createConstraint(new UIExpression(0, [[this.element.wVariable, 1]]), new UIExpression(this._private_widthInternal), this.relation, this.priority, this.isConstraintEnabled());
19
19
  }
20
20
  /** Current width in world units */
21
21
  get width() {