laymur 0.11.4 → 0.12.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.
Files changed (55) hide show
  1. package/README.md +33 -29
  2. package/dist/constraints/{UIAspectConstraint.Internal.d.ts → UIAspectConstraint/UIAspectConstraint.Internal.d.ts} +1 -1
  3. package/dist/constraints/{UIAspectConstraint.d.ts → UIAspectConstraint/UIAspectConstraint.d.ts} +2 -2
  4. package/dist/constraints/UIConstraint.d.ts +2 -2
  5. package/dist/constraints/UICustomConstraint.d.ts +3 -3
  6. package/dist/constraints/{UIHeightConstraint.Internal.d.ts → UIHeightConstraint/UIHeightConstraint.Internal.d.ts} +1 -1
  7. package/dist/constraints/{UIHeightConstraint.d.ts → UIHeightConstraint/UIHeightConstraint.d.ts} +2 -2
  8. package/dist/constraints/{UIHorizontalDistanceConstraint.Internal.d.ts → UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.Internal.d.ts} +1 -1
  9. package/dist/constraints/{UIHorizontalDistanceConstraint.d.ts → UIHorizontalDistanceConstraint/UIHorizontalDistanceConstraint.d.ts} +2 -2
  10. package/dist/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.Internal.d.ts +14 -0
  11. package/dist/constraints/UIHorizontalInterpolationConstraint/UIHorizontalInterpolationConstraint.d.ts +44 -0
  12. package/dist/constraints/{UIHorizontalProportionConstraint.Internal.d.ts → UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.Internal.d.ts} +1 -1
  13. package/dist/constraints/{UIHorizontalProportionConstraint.d.ts → UIHorizontalProportionConstraint/UIHorizontalProportionConstraint.d.ts} +2 -2
  14. package/dist/constraints/{UISingleParameterConstraint.Internal.d.ts → UISingleParameterConstraint/UISingleParameterConstraint.Internal.d.ts} +5 -3
  15. package/dist/constraints/{UISingleParameterConstraint.d.ts → UISingleParameterConstraint/UISingleParameterConstraint.d.ts} +5 -5
  16. package/dist/constraints/{UIVerticalDistanceConstraint.Internal.d.ts → UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.Internal.d.ts} +1 -1
  17. package/dist/constraints/{UIVerticalDistanceConstraint.d.ts → UIVerticalDistanceConstraint/UIVerticalDistanceConstraint.d.ts} +2 -2
  18. package/dist/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.Internal.d.ts +14 -0
  19. package/dist/constraints/UIVerticalInterpolationConstraint/UIVerticalInterpolationConstraint.d.ts +44 -0
  20. package/dist/constraints/{UIVerticalProportionConstraint.Internal.d.ts → UIVerticalProportionConstraint/UIVerticalProportionConstraint.Internal.d.ts} +1 -1
  21. package/dist/constraints/{UIVerticalProportionConstraint.d.ts → UIVerticalProportionConstraint/UIVerticalProportionConstraint.d.ts} +2 -2
  22. package/dist/constraints/{UIWidthConstraint.Internal.d.ts → UIWidthConstraint/UIWidthConstraint.Internal.d.ts} +1 -1
  23. package/dist/constraints/{UIWidthConstraint.d.ts → UIWidthConstraint/UIWidthConstraint.d.ts} +2 -2
  24. package/dist/constraints/builders/UIConstraint2DBuilder.Internal.d.ts +21 -2
  25. package/dist/constraints/builders/UIConstraint2DBuilder.d.ts +19 -8
  26. package/dist/constraints/builders/UICoverConstraintBuilder.d.ts +6 -6
  27. package/dist/constraints/builders/UIFitConstraintBuilder.d.ts +6 -6
  28. package/dist/elements/UIAnchor/UIAnchor.d.ts +2 -2
  29. package/dist/elements/UIAnimatedImage/UIAnimatedImage.Internal.d.ts +15 -3
  30. package/dist/elements/UIAnimatedImage/UIAnimatedImage.d.ts +12 -6
  31. package/dist/elements/UIElement/UIElement.d.ts +1 -1
  32. package/dist/elements/UIGraphics/UIGraphics.Internal.d.ts +0 -2
  33. package/dist/elements/UIGraphics/UIGraphics.d.ts +2 -2
  34. package/dist/elements/UIImage/UIImage.Internal.d.ts +0 -2
  35. package/dist/elements/UIImage/UIImage.d.ts +2 -2
  36. package/dist/elements/UIInputDummy/UIInputDummy.d.ts +2 -2
  37. package/dist/elements/UINineSlice/UINineSlice.d.ts +10 -6
  38. package/dist/elements/UIProgress/UIProgress.Internal.d.ts +0 -2
  39. package/dist/elements/UIProgress/UIProgress.d.ts +3 -3
  40. package/dist/elements/UIScene/UIScene.d.ts +1 -1
  41. package/dist/elements/UIText/UIText.d.ts +2 -2
  42. package/dist/index.d.ts +12 -9
  43. package/dist/index.js +851 -277
  44. package/dist/index.js.map +1 -1
  45. package/dist/index.min.js +1 -1
  46. package/dist/index.min.js.map +1 -1
  47. package/dist/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.d.ts +9 -0
  48. package/dist/layers/{UIFullscreenLayer.d.ts → UIFullscreenLayer/UIFullscreenLayer.d.ts} +4 -8
  49. package/dist/layers/UILayer/UILayer.Internal.d.ts +29 -0
  50. package/dist/layers/{UILayer.d.ts → UILayer/UILayer.d.ts} +4 -9
  51. package/dist/miscellaneous/asserts.d.ts +22 -55
  52. package/dist/miscellaneous/color/UIColor.d.ts +1 -0
  53. package/dist/miscellaneous/shared.d.ts +46 -0
  54. package/package.json +6 -3
  55. package/dist/layers/UILayer.Internal.d.ts +0 -15
@@ -0,0 +1,9 @@
1
+ import type { UIResizePolicy } from "../../miscellaneous/resize-policy/UIResizePolicy";
2
+ import { UIResizePolicyNone } from "../../miscellaneous/resize-policy/UIResizePolicyNone";
3
+ import type { UILayerOptions } from "../UILayer/UILayer.Internal";
4
+ /** Configuration for fullscreen layer */
5
+ export interface UIFullscreenLayerOptions extends Omit<UILayerOptions, "width" | "height"> {
6
+ /** Strategy for handling window resize */
7
+ resizePolicy: UIResizePolicy;
8
+ }
9
+ export declare const FULLSCREEN_LAYER_DEFAULT_RESIZE_POLICY: UIResizePolicyNone;
@@ -1,17 +1,13 @@
1
1
  import type { Camera, Vector2, WebGLRenderer } from "three";
2
2
  import { Ray, Vector3 } from "three";
3
- import type { UIResizePolicy } from "../miscellaneous/resize-policy/UIResizePolicy";
4
- import { UILayer } from "./UILayer";
5
- import type { UILayerMode } from "./UILayer.Internal";
3
+ import type { UIResizePolicy } from "../../miscellaneous/resize-policy/UIResizePolicy";
4
+ import { UILayer } from "../UILayer/UILayer";
5
+ import { type UIFullscreenLayerOptions } from "./UIFullscreenLayer.Internal";
6
6
  /** Layer that automatically handles browser window resizing and input events */
7
7
  export declare class UIFullscreenLayer extends UILayer {
8
8
  private resizePolicyInternal;
9
9
  private resizePolicyDirty;
10
- /**
11
- * @param resizePolicy Strategy for handling window resize
12
- * @param mode Initial visibility and interactivity mode
13
- */
14
- constructor(resizePolicy?: UIResizePolicy, mode?: UILayerMode);
10
+ constructor(options?: Partial<UIFullscreenLayerOptions>);
15
11
  /** Current resize policy */
16
12
  get resizePolicy(): UIResizePolicy;
17
13
  /** Updates resize policy */
@@ -0,0 +1,29 @@
1
+ import { UIMode } from "../../miscellaneous/UIMode";
2
+ import type { UIOrientation } from "../../miscellaneous/UIOrientation";
3
+ /** Layer lifecycle and state events */
4
+ export declare enum UILayerEvent {
5
+ /** Fired when orientation changes */
6
+ ORIENTATION_CHANGED = "orientation_changed",
7
+ /** Fired when mode changes */
8
+ MODE_CHANGED = "mode_changed",
9
+ /** Fired during rendering */
10
+ RENDERING = "rendering"
11
+ }
12
+ /** Layer visibility and interactivity state */
13
+ export type UILayerMode = UIMode.HIDDEN | UIMode.VISIBLE | UIMode.INTERACTIVE;
14
+ /** Layer orientation state */
15
+ export type UILayerOrientation = UIOrientation.VERTICAL | UIOrientation.HORIZONTAL;
16
+ /** Configuration options for UILayer */
17
+ export interface UILayerOptions {
18
+ /** Initial width */
19
+ width: number;
20
+ /** Initial height */
21
+ height: number;
22
+ /** Optional layer name */
23
+ name: string;
24
+ /** Initial visibility and interactivity mode */
25
+ mode: UILayerMode;
26
+ }
27
+ export declare const LAYER_DEFAULT_SIZE = 1024;
28
+ export declare const LAYER_DEFAULT_NAME = "";
29
+ export declare const LAYER_DEFAULT_MODE: UILayerMode;
@@ -1,8 +1,8 @@
1
1
  import { Eventail } from "eventail";
2
2
  import type { WebGLRenderer } from "three";
3
- import type { UIPlaneElement } from "../miscellaneous/asserts";
4
- import { UIInputWrapper } from "../wrappers/UIInputWrapper";
5
- import type { UILayerMode, UILayerOrientation } from "./UILayer.Internal";
3
+ import type { UIPlaneElement } from "../../miscellaneous/shared";
4
+ import { UIInputWrapper } from "../../wrappers/UIInputWrapper";
5
+ import type { UILayerMode, UILayerOptions, UILayerOrientation } from "./UILayer.Internal";
6
6
  /** Base layer for UI rendering and layout management */
7
7
  export declare abstract class UILayer extends Eventail implements UIPlaneElement {
8
8
  /** Optional layer name */
@@ -20,12 +20,7 @@ export declare abstract class UILayer extends Eventail implements UIPlaneElement
20
20
  private readonly sceneWrapperInternal;
21
21
  private modeInternal;
22
22
  private orientationInternal;
23
- /**
24
- * @param w Initial width in world units
25
- * @param h Initial height in world units
26
- * @param mode Initial visibility and interactivity mode
27
- */
28
- constructor(w: number, h: number, mode: UILayerMode);
23
+ constructor(options: Partial<UILayerOptions>);
29
24
  /** X coordinate in world units (always 0 for layers) */
30
25
  get x(): number;
31
26
  /** Y coordinate in world units (always 0 for layers) */
@@ -1,59 +1,5 @@
1
- import { UILayer } from "../layers/UILayer";
1
+ import { UILayer } from "../layers/UILayer/UILayer";
2
2
  export declare const EPSILON = 0.000001;
3
- /** Objects that belong to a UI layer */
4
- export interface UILayerElement {
5
- /** The UI layer containing this element */
6
- readonly layer: UILayer;
7
- }
8
- /** UI elements with position in 2D space */
9
- export interface UIPointElement {
10
- /** Solver variable for x coordinate */
11
- readonly xVariable: number;
12
- /** Solver variable for y coordinate */
13
- readonly yVariable: number;
14
- /** X coordinate in world units */
15
- readonly x: number;
16
- /** Y coordinate in world units */
17
- readonly y: number;
18
- }
19
- /** UI elements with position and dimensions */
20
- export interface UIPlaneElement extends UIPointElement {
21
- /** Solver variable for width */
22
- readonly wVariable: number;
23
- /** Solver variable for height */
24
- readonly hVariable: number;
25
- /** Width in world units */
26
- readonly width: number;
27
- /** Height in world units */
28
- readonly height: number;
29
- }
30
- /**
31
- * Checks if object implements UILayerElement.
32
- * @param obj Object to check
33
- * @returns True if object has valid layer property
34
- */
35
- export declare function isUILayerElement(obj: unknown): obj is UILayerElement;
36
- /**
37
- * Checks if object implements UIPointElement.
38
- * @param obj Object to check
39
- * @returns True if object has valid position variables
40
- */
41
- export declare function isUIPointElement(obj: unknown): obj is UIPointElement;
42
- /**
43
- * Checks if object implements UIPlaneElement.
44
- * @param obj Object to check
45
- * @returns True if object has valid dimension variables
46
- */
47
- export declare function isUIPlaneElement(obj: unknown): obj is UIPlaneElement;
48
- /**
49
- * Validates constraint subjects are from same layer.
50
- * @param a First constraint subject
51
- * @param b Second constraint subject
52
- * @param subject Constraint name for error messages
53
- * @returns Common layer for both subjects
54
- * @throws If subjects are invalid or from different layers
55
- */
56
- export declare function assertValidConstraintSubjects(a: unknown, b: unknown, subject: string): UILayer;
57
3
  /**
58
4
  * Validates value is finite number within safe range.
59
5
  * @param value Number to validate
@@ -75,3 +21,24 @@ export declare function assertValidPositiveNumber(value: number, subject: string
75
21
  * @throws If value is invalid or negative
76
22
  */
77
23
  export declare function assertValidNonNegativeNumber(value: number, subject: string): void;
24
+ /**
25
+ * Validates constraint arguments are from same layer.
26
+ * @param a First constraint subject
27
+ * @param b Second constraint subject
28
+ * @param subject Constraint name for error messages
29
+ * @returns Common layer for both subjects
30
+ * @throws If subjects are invalid or from different layers
31
+ */
32
+ export declare function assertValidConstraintArguments(a: unknown, b: unknown, subject: string): UILayer;
33
+ /**
34
+ * Validates interpolation constraint subjects.
35
+ * @param subject Constraint name for error messages
36
+ * @param a First element
37
+ * @param b Second element
38
+ * @param c Element to interpolate
39
+ * @param anchorA Anchor on element A
40
+ * @param anchorB Anchor on element B
41
+ * @returns Common layer for all subjects
42
+ * @throws If subjects violate interpolation constraints
43
+ */
44
+ export declare function assertValidInterpolationConstraintArguments(subject: string, a: unknown, b: unknown, c: unknown, anchorA: number, anchorB: number): UILayer;
@@ -194,4 +194,5 @@ export declare class UIColor {
194
194
  copy(color: UIColor | Color): this;
195
195
  /** Returns copy of this color */
196
196
  clone(): UIColor;
197
+ private ensureHSLUpdatedFromRGB;
197
198
  }
@@ -0,0 +1,46 @@
1
+ import { UILayer } from "../layers/UILayer/UILayer";
2
+ /** Objects that belong to a UI layer */
3
+ export interface UILayerElement {
4
+ /** The UI layer containing this element */
5
+ readonly layer: UILayer;
6
+ }
7
+ /** UI elements with position in 2D space */
8
+ export interface UIPointElement {
9
+ /** Solver variable for x coordinate */
10
+ readonly xVariable: number;
11
+ /** Solver variable for y coordinate */
12
+ readonly yVariable: number;
13
+ /** X coordinate in world units */
14
+ readonly x: number;
15
+ /** Y coordinate in world units */
16
+ readonly y: number;
17
+ }
18
+ /** UI elements with position and dimensions */
19
+ export interface UIPlaneElement extends UIPointElement {
20
+ /** Solver variable for width */
21
+ readonly wVariable: number;
22
+ /** Solver variable for height */
23
+ readonly hVariable: number;
24
+ /** Width in world units */
25
+ readonly width: number;
26
+ /** Height in world units */
27
+ readonly height: number;
28
+ }
29
+ /**
30
+ * Checks if object implements UILayerElement.
31
+ * @param obj Object to check
32
+ * @returns True if object has valid layer property
33
+ */
34
+ export declare function isUILayerElement(obj: unknown): obj is UILayerElement;
35
+ /**
36
+ * Checks if object implements UIPointElement.
37
+ * @param obj Object to check
38
+ * @returns True if object has valid position variables
39
+ */
40
+ export declare function isUIPointElement(obj: unknown): obj is UIPointElement;
41
+ /**
42
+ * Checks if object implements UIPlaneElement.
43
+ * @param obj Object to check
44
+ * @returns True if object has valid dimension variables
45
+ */
46
+ export declare function isUIPlaneElement(obj: unknown): obj is UIPlaneElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "laymur",
3
- "version": "0.11.4",
3
+ "version": "0.12.0",
4
4
  "description": "Constraint-based UI library for Three.js mobile advertisements",
5
5
  "scripts": {
6
6
  "clean": "rm -rf dist",
@@ -13,13 +13,16 @@
13
13
  "types": "dist/index.d.ts",
14
14
  "exports": {
15
15
  ".": {
16
- "types": "./dist/index.d.ts",
17
16
  "import": {
17
+ "types": "./dist/index.d.ts",
18
18
  "development": "./dist/index.js",
19
19
  "production": "./dist/index.min.js",
20
20
  "default": "./dist/index.min.js"
21
21
  },
22
- "require": "./dist/index.min.js"
22
+ "require": {
23
+ "types": "./dist/index.d.ts",
24
+ "default": "./dist/index.min.js"
25
+ }
23
26
  },
24
27
  "./package.json": "./package.json"
25
28
  },
@@ -1,15 +0,0 @@
1
- import type { UIMode } from "../miscellaneous/UIMode";
2
- import type { UIOrientation } from "../miscellaneous/UIOrientation";
3
- /** Layer lifecycle and state events */
4
- export declare enum UILayerEvent {
5
- /** Fired when orientation changes */
6
- ORIENTATION_CHANGED = "orientation_changed",
7
- /** Fired when mode changes */
8
- MODE_CHANGED = "mode_changed",
9
- /** Fired during rendering */
10
- RENDERING = "rendering"
11
- }
12
- /** Layer visibility and interactivity state */
13
- export type UILayerMode = UIMode.HIDDEN | UIMode.VISIBLE | UIMode.INTERACTIVE;
14
- /** Layer orientation state */
15
- export type UILayerOrientation = UIOrientation.VERTICAL | UIOrientation.HORIZONTAL;