laymur 0.22.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -246,12 +246,12 @@ class UIAnimatedImage extends UIElement {
246
246
  }
247
247
  _private_subscribeSequenceEvents() {
248
248
  for (const frame of this._private_sequenceInternal) {
249
- frame.signalDiminsionsChanged.on(this._private_onTextureDimensionsChanged);
249
+ frame.signalDimensionsChanged.on(this._private_onTextureDimensionsChanged);
250
250
  }
251
251
  }
252
252
  _private_unsubscribeSequenceEvents() {
253
253
  for (const frame of this._private_sequenceInternal) {
254
- frame.signalDiminsionsChanged.off(this._private_onTextureDimensionsChanged);
254
+ frame.signalDimensionsChanged.off(this._private_onTextureDimensionsChanged);
255
255
  }
256
256
  }
257
257
  }
@@ -37,22 +37,30 @@ export declare abstract class UIElement extends UIDummy {
37
37
  get transparencyMode(): UITransparencyMode;
38
38
  /** Color blending mode (only affects BLEND transparency) */
39
39
  get blendMode(): UIBlendMode;
40
+ /** Hue shift in degrees */
41
+ get hue(): number;
42
+ /** Saturation multiplier (1 = unchanged, 0 = grayscale) */
43
+ get saturation(): number;
44
+ /** Lightness offset (0 = unchanged) */
45
+ get lightness(): number;
46
+ /**
47
+ * Controls visibility and interactivity.
48
+ *
49
+ * Redeclared here because declaring only a setter would shadow the accessor
50
+ * pair inherited from {@link UIDummy}, making reads return undefined.
51
+ */
52
+ get mode(): UIMode;
40
53
  /** Alpha blending mode */
41
54
  set transparencyMode(value: UITransparencyMode);
42
55
  /** Color blending mode (only affects BLEND transparency) */
43
56
  set blendMode(value: UIBlendMode);
44
57
  /** Hue shift in degrees */
45
- get hue(): number;
46
- /** Hue shift in degrees */
47
58
  set hue(value: number);
48
59
  /** Saturation multiplier (1 = unchanged, 0 = grayscale) */
49
- get saturation(): number;
50
- /** Saturation multiplier (1 = unchanged, 0 = grayscale) */
51
60
  set saturation(value: number);
52
61
  /** Lightness offset (0 = unchanged) */
53
- get lightness(): number;
54
- /** Lightness offset (0 = unchanged) */
55
62
  set lightness(value: number);
63
+ /** Controls visibility and interactivity */
56
64
  set mode(value: UIMode);
57
65
  /** Removes element and frees resources */
58
66
  destroy(): void;
@@ -43,6 +43,27 @@ class UIElement extends UIDummy {
43
43
  get blendMode() {
44
44
  return this._private_blendModeInternal;
45
45
  }
46
+ /** Hue shift in degrees */
47
+ get hue() {
48
+ return this._private_hueInternal;
49
+ }
50
+ /** Saturation multiplier (1 = unchanged, 0 = grayscale) */
51
+ get saturation() {
52
+ return this._private_saturationInternal;
53
+ }
54
+ /** Lightness offset (0 = unchanged) */
55
+ get lightness() {
56
+ return this._private_lightnessInternal;
57
+ }
58
+ /**
59
+ * Controls visibility and interactivity.
60
+ *
61
+ * Redeclared here because declaring only a setter would shadow the accessor
62
+ * pair inherited from {@link UIDummy}, making reads return undefined.
63
+ */
64
+ get mode() {
65
+ return this.modeInternal;
66
+ }
46
67
  /** Alpha blending mode */
47
68
  set transparencyMode(value) {
48
69
  if (this._private_transparencyModeInternal !== value) {
@@ -58,10 +79,6 @@ class UIElement extends UIDummy {
58
79
  }
59
80
  }
60
81
  /** Hue shift in degrees */
61
- get hue() {
62
- return this._private_hueInternal;
63
- }
64
- /** Hue shift in degrees */
65
82
  set hue(value) {
66
83
  if (this._private_hueInternal !== value) {
67
84
  this._private_hueInternal = value;
@@ -69,10 +86,6 @@ class UIElement extends UIDummy {
69
86
  }
70
87
  }
71
88
  /** Saturation multiplier (1 = unchanged, 0 = grayscale) */
72
- get saturation() {
73
- return this._private_saturationInternal;
74
- }
75
- /** Saturation multiplier (1 = unchanged, 0 = grayscale) */
76
89
  set saturation(value) {
77
90
  if (this._private_saturationInternal !== value) {
78
91
  this._private_saturationInternal = value;
@@ -80,16 +93,13 @@ class UIElement extends UIDummy {
80
93
  }
81
94
  }
82
95
  /** Lightness offset (0 = unchanged) */
83
- get lightness() {
84
- return this._private_lightnessInternal;
85
- }
86
- /** Lightness offset (0 = unchanged) */
87
96
  set lightness(value) {
88
97
  if (this._private_lightnessInternal !== value) {
89
98
  this._private_lightnessInternal = value;
90
99
  this._private_hslDirty = true;
91
100
  }
92
101
  }
102
+ /** Controls visibility and interactivity */
93
103
  set mode(value) {
94
104
  if (this.modeInternal !== value) {
95
105
  this._private_visibilityDirty = isUIModeVisible(this.modeInternal) !== isUIModeVisible(value);
@@ -33,7 +33,7 @@ class UIImage extends UIElement {
33
33
  this.texture = textureView;
34
34
  this._private_textureTransform = textureTransform;
35
35
  this._private_colorInternal = color;
36
- this.texture.signalDiminsionsChanged.on(this._private_onTextureDimensionsChanged);
36
+ this.texture.signalDimensionsChanged.on(this._private_onTextureDimensionsChanged);
37
37
  }
38
38
  /** Multiplicative tint. Alpha channel controls opacity. */
39
39
  get color() {
@@ -45,7 +45,7 @@ class UIImage extends UIElement {
45
45
  }
46
46
  /** Removes image and frees resources */
47
47
  destroy() {
48
- this.texture.signalDiminsionsChanged.off(this._private_onTextureDimensionsChanged);
48
+ this.texture.signalDimensionsChanged.off(this._private_onTextureDimensionsChanged);
49
49
  super.destroy();
50
50
  }
51
51
  setPlaneTransform() {
@@ -53,7 +53,7 @@ class UINineSlice extends UIElement {
53
53
  this._private_sliceRegionsVector = sliceRegionsVector;
54
54
  this._private_lastElementWidth = this.width;
55
55
  this._private_lastElementHeight = this.height;
56
- this.texture.signalDiminsionsChanged.on(this._private_onTextureDimensionsChanged);
56
+ this.texture.signalDimensionsChanged.on(this._private_onTextureDimensionsChanged);
57
57
  }
58
58
  /** Multiplicative tint. Alpha channel controls opacity. */
59
59
  get color() {
@@ -92,7 +92,7 @@ class UINineSlice extends UIElement {
92
92
  }
93
93
  /** Removes nine slice and frees resources */
94
94
  destroy() {
95
- this.texture.signalDiminsionsChanged.off(this._private_onTextureDimensionsChanged);
95
+ this.texture.signalDimensionsChanged.off(this._private_onTextureDimensionsChanged);
96
96
  super.destroy();
97
97
  }
98
98
  setPlaneTransform() {
@@ -39,6 +39,8 @@ export declare class UIProgress extends UIElement {
39
39
  set maskFunction(value: UIProgressMaskFunction);
40
40
  /** Progress from 0 (empty) to 1 (full). Clamped. */
41
41
  set progress(value: number);
42
+ /** Removes element and frees resources */
43
+ destroy(): void;
42
44
  protected setPlaneTransform(): void;
43
45
  private readonly onTextureDimensionsChanged;
44
46
  private rebuildPlane;
@@ -56,7 +56,7 @@ class UIProgress extends UIElement {
56
56
  this._private_colorInternal = color;
57
57
  this._private_progressInternal = progress;
58
58
  this._private_maskFunctionInternal = maskFunction;
59
- this.texture.signalDiminsionsChanged.on(this._private_onTextureDimensionsChanged);
59
+ this.texture.signalDimensionsChanged.on(this._private_onTextureDimensionsChanged);
60
60
  }
61
61
  /** Multiplicative tint. Alpha channel controls opacity. */
62
62
  get color() {
@@ -90,6 +90,11 @@ class UIProgress extends UIElement {
90
90
  this._private_progressDirty = true;
91
91
  }
92
92
  }
93
+ /** Removes element and frees resources */
94
+ destroy() {
95
+ this.texture.signalDimensionsChanged.off(this._private_onTextureDimensionsChanged);
96
+ super.destroy();
97
+ }
93
98
  setPlaneTransform() {
94
99
  let properties;
95
100
  if (this._private_colorInternal.dirty) {
@@ -40,7 +40,7 @@ class UIProgressMaskFunctionDirectional extends UIProgressMaskFunction {
40
40
  this.direction.set(1, 0);
41
41
  }
42
42
  else if (Math.abs(squaredLength - 1) > EPSILON) {
43
- this.direction.divideScalar(squaredLength);
43
+ this.direction.divideScalar(Math.sqrt(squaredLength));
44
44
  }
45
45
  }
46
46
  }
@@ -19,7 +19,7 @@ export declare class UITextureView {
19
19
  private textureDirtyInternal;
20
20
  private uvTransformDirtyInternal;
21
21
  private trimDirtyInternal;
22
- private readonly signalDiminsionsChangedInternal;
22
+ private readonly signalDimensionsChangedInternal;
23
23
  /** @param config Texture or atlas configuration */
24
24
  constructor(config?: UITextureConfig);
25
25
  /** Original width before trimming in world units */
@@ -43,7 +43,7 @@ export declare class UITextureView {
43
43
  get uvTransformDirty(): boolean;
44
44
  /** Whether trim values changed since last check */
45
45
  get trimDirty(): boolean;
46
- get signalDiminsionsChanged(): FerrsignView3<number, number, UITextureView>;
46
+ get signalDimensionsChanged(): FerrsignView3<number, number, UITextureView>;
47
47
  setTextureDirtyFalse(): void;
48
48
  /**
49
49
  * Calculates UV transform matrix for shader sampling.
@@ -23,7 +23,7 @@ class UITextureView {
23
23
  this._private_textureDirtyInternal = false;
24
24
  this._private_uvTransformDirtyInternal = false;
25
25
  this._private_trimDirtyInternal = false;
26
- this._private_signalDiminsionsChangedInternal = new Ferrsign3();
26
+ this._private_signalDimensionsChangedInternal = new Ferrsign3();
27
27
  if (config !== undefined) {
28
28
  this.set(config);
29
29
  }
@@ -79,8 +79,8 @@ class UITextureView {
79
79
  get trimDirty() {
80
80
  return this._private_trimDirtyInternal;
81
81
  }
82
- get signalDiminsionsChanged() {
83
- return this._private_signalDiminsionsChangedInternal;
82
+ get signalDimensionsChanged() {
83
+ return this._private_signalDimensionsChangedInternal;
84
84
  }
85
85
  setTextureDirtyFalse() {
86
86
  this._private_textureDirtyInternal = false;
@@ -141,7 +141,7 @@ class UITextureView {
141
141
  this._private_setFromAtlasConfig(config);
142
142
  }
143
143
  if (this.width !== lastWidth || this.height !== lastHeight) {
144
- this._private_signalDiminsionsChangedInternal.emit(this.width, this.height, this);
144
+ this._private_signalDimensionsChangedInternal.emit(this.width, this.height, this);
145
145
  }
146
146
  }
147
147
  _private_setFromTexture(texture) {
@@ -210,6 +210,13 @@ export declare class UISolverWrapper implements UISolverWrapperView {
210
210
  *
211
211
  * Re-adds all variables and constraints to a fresh solver instance.
212
212
  * Used for recovery when the solver enters an invalid state.
213
+ *
214
+ * The solver is normally dropped because some constraint was rejected by kiwi,
215
+ * and that same constraint is still registered here. Replaying it would throw
216
+ * again, so every replay is guarded individually: a constraint kiwi refuses is
217
+ * skipped and stays registered but unapplied, which is exactly the state it was
218
+ * already in. The fresh solver is only published once the replay is complete,
219
+ * so a rejection can never leave a half-built solver in place.
213
220
  */
214
221
  private rebuildSolver;
215
222
  }
@@ -477,26 +477,44 @@ class UISolverWrapper {
477
477
  *
478
478
  * Re-adds all variables and constraints to a fresh solver instance.
479
479
  * Used for recovery when the solver enters an invalid state.
480
+ *
481
+ * The solver is normally dropped because some constraint was rejected by kiwi,
482
+ * and that same constraint is still registered here. Replaying it would throw
483
+ * again, so every replay is guarded individually: a constraint kiwi refuses is
484
+ * skipped and stays registered but unapplied, which is exactly the state it was
485
+ * already in. The fresh solver is only published once the replay is complete,
486
+ * so a rejection can never leave a half-built solver in place.
480
487
  */
481
488
  _private_rebuildSolver() {
482
489
  if (this._private_solver) {
483
490
  throw new Error("UISolverWrapper.rebuildSolver: solver already exists");
484
491
  }
485
- this._private_solver = new Solver();
492
+ const solver = new Solver();
486
493
  for (const description of this._private_variables.values()) {
487
- if (description.constraint) {
488
- this._private_solver.addConstraint(description.constraint);
494
+ try {
495
+ if (description.constraint) {
496
+ solver.addConstraint(description.constraint);
497
+ }
498
+ else {
499
+ solver.addEditVariable(description.variable, convertPriority(description.priority));
500
+ solver.suggestValue(description.variable, description.value);
501
+ }
489
502
  }
490
- else {
491
- this._private_solver.addEditVariable(description.variable, convertPriority(description.priority));
492
- this._private_solver.suggestValue(description.variable, description.value);
503
+ catch {
504
+ continue;
493
505
  }
494
506
  }
495
507
  for (const description of this._private_constraints.values()) {
496
508
  if (description.enabled) {
497
- this._private_solver.addConstraint(description.constraint);
509
+ try {
510
+ solver.addConstraint(description.constraint);
511
+ }
512
+ catch {
513
+ continue;
514
+ }
498
515
  }
499
516
  }
517
+ this._private_solver = solver;
500
518
  this._private_recalculationRequired = true;
501
519
  this.dirty = true;
502
520
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "laymur",
3
- "version": "0.22.0",
3
+ "version": "0.23.0",
4
4
  "description": "Constraint-based UI library for Three.js mobile advertisements",
5
5
  "keywords": [
6
6
  "ui",