laymur 0.14.1 → 0.15.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 (26) hide show
  1. package/README.md +69 -13
  2. package/dist/elements/UIAnchor/UIAnchor.d.ts +1 -2
  3. package/dist/elements/UIAnimatedImage/UIAnimatedImage.Internal.d.ts +0 -9
  4. package/dist/elements/UIAnimatedImage/UIAnimatedImage.d.ts +10 -0
  5. package/dist/elements/UIGraphics/UIGraphics.d.ts +1 -1
  6. package/dist/elements/UIInputDummy/UIInputDummy.Internal.d.ts +12 -0
  7. package/dist/elements/UIInputDummy/UIInputDummy.d.ts +19 -3
  8. package/dist/index.d.ts +0 -1
  9. package/dist/index.js +8328 -8162
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.min.js +1 -1
  12. package/dist/index.min.js.map +1 -1
  13. package/dist/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.d.ts +12 -0
  14. package/dist/layers/UIFullscreenLayer/UIFullscreenLayer.d.ts +11 -1
  15. package/dist/layers/UILayer/UILayer.Internal.d.ts +0 -9
  16. package/dist/layers/UILayer/UILayer.d.ts +11 -2
  17. package/dist/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.d.ts +10 -1
  18. package/dist/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.d.ts +13 -9
  19. package/dist/miscellaneous/generic-plane/shared.d.ts +5 -0
  20. package/dist/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.d.ts +1 -1
  21. package/dist/miscellaneous/texture/UITextureView.Internal.d.ts +0 -5
  22. package/dist/miscellaneous/texture/UITextureView.d.ts +4 -2
  23. package/package.json +3 -6
  24. package/dist/miscellaneous/UIInputEvent.d.ts +0 -13
  25. package/dist/miscellaneous/generic-plane/UIGenericPlane/UIGenericPlane.Internal.d.ts +0 -6
  26. package/dist/miscellaneous/generic-plane/UIGenericPlane/UIGenericPlane.d.ts +0 -1
package/README.md CHANGED
@@ -9,7 +9,7 @@
9
9
  <a href="https://www.npmjs.com/package/laymur"><img src="https://img.shields.io/npm/v/laymur.svg" alt="npm version"></a>
10
10
  <a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" alt="License: MIT"></a>
11
11
  <a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-%5E5.8.0-blue" alt="TypeScript"></a>
12
- <a href="https://threejs.org/"><img src="https://img.shields.io/badge/Three.js-0.175.0--0.179.0-green" alt="Three.js"></a>
12
+ <a href="https://threejs.org/"><img src="https://img.shields.io/badge/Three.js-0.157.0--0.180.0-green" alt="Three.js"></a>
13
13
  </p>
14
14
 
15
15
  ⚠️ **Early Alpha / Work in Progress** ⚠️
@@ -144,40 +144,96 @@ element.micro.reset();
144
144
 
145
145
  ## Event Handling
146
146
 
147
- UI elements with area (width and height) can emit input events. Layers can also emit input events.
147
+ UI elements and layers use type-safe signals for event handling via [Ferrsign](https://github.com/jango-git/ferrsign).
148
+
149
+ ### Element Input Events
150
+
151
+ Elements with area (width and height) can emit input events:
148
152
 
149
153
  ```typescript
150
- import { UIInputEvent, UIMode } from 'laymur';
154
+ import { UIMode } from 'laymur';
155
+ import type { UIInputEventData } from 'laymur';
151
156
 
152
- // Element events
153
157
  const button = new UIImage(layer, buttonTexture, {
154
158
  x: 0,
155
159
  y: 0,
156
160
  mode: UIMode.INTERACTIVE
157
161
  });
158
162
 
159
- button.on(UIInputEvent.PRESSED, (x, y, element) => {
160
- console.log('Button pressed at', x, y);
163
+ button.signalPressed.on((data: UIInputEventData) => {
164
+ console.log('Button pressed at', data.x, data.y);
165
+ console.log('Element:', data.element);
161
166
  });
162
167
 
163
- button.on(UIInputEvent.RELEASED, (x, y, element) => {
168
+ button.signalReleased.on((data: UIInputEventData) => {
164
169
  console.log('Button released');
165
170
  });
166
171
 
167
- button.on(UIInputEvent.ENTERED, (x, y, element) => {
172
+ button.signalEntered.on((data: UIInputEventData) => {
168
173
  console.log('Pointer entered button');
169
174
  });
170
175
 
171
- // Layer events
172
- layer.on(UIInputEvent.PRESSED, (x, y) => {
173
- console.log('Layer pressed at', x, y);
176
+ button.signalLeft.on((data: UIInputEventData) => {
177
+ console.log('Pointer left button');
174
178
  });
175
179
 
176
- layer.on(UIInputEvent.MOVED, (x, y) => {
177
- console.log('Pointer moved to', x, y);
180
+ button.signalMoved.on((data: UIInputEventData) => {
181
+ console.log('Pointer moved inside button');
178
182
  });
179
183
  ```
180
184
 
185
+ ### Layer Events
186
+
187
+ Fullscreen layers emit input events:
188
+
189
+ ```typescript
190
+ import type { UIFullscreenLayerInputEventData } from 'laymur';
191
+
192
+ layer.signalPressed.on((data: UIFullscreenLayerInputEventData) => {
193
+ console.log('Layer pressed at', data.x, data.y);
194
+ console.log('Layer:', data.layer);
195
+ });
196
+
197
+ layer.signalMoved.on((data: UIFullscreenLayerInputEventData) => {
198
+ console.log('Pointer moved to', data.x, data.y);
199
+ });
200
+
201
+ layer.signalReleased.on((data: UIFullscreenLayerInputEventData) => {
202
+ console.log('Pointer released');
203
+ });
204
+ ```
205
+
206
+ ### Animation Events
207
+
208
+ Animated images emit playback events:
209
+
210
+ ```typescript
211
+ const animation = new UIAnimatedImage(layer, frames);
212
+
213
+ animation.signalPlayed.on(() => {
214
+ console.log('Animation started or resumed');
215
+ });
216
+
217
+ animation.signalPaused.on(() => {
218
+ console.log('Animation paused');
219
+ });
220
+
221
+ animation.signalStopped.on(() => {
222
+ console.log('Animation stopped and reset');
223
+ });
224
+ ```
225
+
226
+ ### Unsubscribing from Events
227
+
228
+ ```typescript
229
+ const handler = (data: UIInputEventData) => {
230
+ console.log('Pressed!');
231
+ };
232
+
233
+ button.signalPressed.on(handler);
234
+ button.signalPressed.off(handler); // Unsubscribe
235
+ ```
236
+
181
237
  ## Live Examples
182
238
 
183
239
  🎮 **[Live Examples](https://jango-git.github.io/laymur/)** - See constraint-based layouts and responsive components in action.
@@ -1,10 +1,9 @@
1
- import { Eventail } from "eventail";
2
1
  import type { UILayer } from "../../layers/UILayer/UILayer";
3
2
  import type { UILayerElement, UIPointElement } from "../../miscellaneous/shared";
4
3
  import type { UISolverWrapperInterface } from "../../wrappers/UISolverWrapper/UISolverWrapper.Internal";
5
4
  import type { UIAnchorOptions } from "./UIAnchor.Internal";
6
5
  /** Point in 2D space with constraint-based positioning */
7
- export declare class UIAnchor extends Eventail implements UILayerElement, UIPointElement {
6
+ export declare class UIAnchor implements UILayerElement, UIPointElement {
8
7
  readonly layer: UILayer;
9
8
  /** Optional identifier for debugging */
10
9
  name: string;
@@ -1,14 +1,5 @@
1
1
  import type { UIColorConfig } from "../../miscellaneous/color/UIColor.Internal";
2
2
  import type { UIElementOptions } from "../UIElement/UIElement.Internal";
3
- /** Animation playback events */
4
- export declare enum UIAnimatedImageEvent {
5
- /** Animation started or resumed */
6
- PLAYED = 0,
7
- /** Animation paused */
8
- PAUSED = 1,
9
- /** Animation stopped and reset */
10
- STOPPED = 2
11
- }
12
3
  /** Animation loop behavior */
13
4
  export declare enum UIAnimatedImageLoopMode {
14
5
  /** No looping, stops at boundary frame */
@@ -1,3 +1,4 @@
1
+ import type { FerrsignView0 } from "ferrsign";
1
2
  import type { WebGLRenderer } from "three";
2
3
  import type { UILayer } from "../../layers/UILayer/UILayer";
3
4
  import { UIColor } from "../../miscellaneous/color/UIColor";
@@ -19,6 +20,9 @@ export declare class UIAnimatedImage extends UIElement {
19
20
  private sequenceFrameIndex;
20
21
  private currentFrameIndexDirty;
21
22
  private accumulatedTime;
23
+ private readonly signalPlayedInternal;
24
+ private readonly signalPausedInternal;
25
+ private readonly signalStoppedInternal;
22
26
  /**
23
27
  * Creates a new UIAnimatedImage instance.
24
28
  *
@@ -41,6 +45,12 @@ export declare class UIAnimatedImage extends UIElement {
41
45
  get sequence(): readonly UITextureView[];
42
46
  /** Playback speed multiplier. Can be negative for reverse playback. */
43
47
  get timeScale(): number;
48
+ /** Signal fired when animation starts or resumes */
49
+ get signalPlayed(): FerrsignView0;
50
+ /** Signal fired when animation pauses */
51
+ get signalPaused(): FerrsignView0;
52
+ /** Signal fired when animation stops and resets */
53
+ get signalStopped(): FerrsignView0;
44
54
  /** Multiplicative tint. Alpha channel controls opacity. */
45
55
  set color(value: UIColorConfig);
46
56
  /** Animation speed in frames per second */
@@ -3,7 +3,7 @@ import type { UILayer } from "../../layers/UILayer/UILayer";
3
3
  import { UIColor } from "../../miscellaneous/color/UIColor";
4
4
  import type { UIColorConfig } from "../../miscellaneous/color/UIColor.Internal";
5
5
  import { UIElement } from "../UIElement/UIElement";
6
- import { type UIGraphicsOptions } from "./UIGraphics.Internal";
6
+ import type { UIGraphicsOptions } from "./UIGraphics.Internal";
7
7
  /** Canvas-based 2D drawing element */
8
8
  export declare class UIGraphics extends UIElement {
9
9
  private readonly colorInternal;
@@ -1,6 +1,18 @@
1
1
  import type { UIArea } from "../../miscellaneous/area/UIArea";
2
2
  import { UIMode } from "../../miscellaneous/UIMode";
3
3
  import type { UIAnchorOptions } from "../UIAnchor/UIAnchor.Internal";
4
+ import type { UIInputDummy } from "./UIInputDummy";
5
+ /** Input event data */
6
+ export interface UIInputEventData {
7
+ /** X coordinate */
8
+ x: number;
9
+ /** Y coordinate */
10
+ y: number;
11
+ /** Pointer identifier */
12
+ identifier: number;
13
+ /** Element that emitted the event */
14
+ element: UIInputDummy;
15
+ }
4
16
  /** Configuration options for UIInputDummy */
5
17
  export interface UIInputDummyOptions extends UIAnchorOptions {
6
18
  /** Width in world units */
@@ -1,11 +1,12 @@
1
+ import type { FerrsignView1 } from "ferrsign";
2
+ import { Ferrsign1 } from "ferrsign";
1
3
  import type { UILayer } from "../../layers/UILayer/UILayer";
2
4
  import type { UIArea } from "../../miscellaneous/area/UIArea";
3
5
  import type { UIPlaneElement } from "../../miscellaneous/shared";
4
- import { UIInputEvent } from "../../miscellaneous/UIInputEvent";
5
6
  import { UIMode } from "../../miscellaneous/UIMode";
6
7
  import type { UIInputWrapperInterface } from "../../wrappers/UIInputWrapper/UIInputWrapper.Internal";
7
8
  import { UIAnchor } from "../UIAnchor/UIAnchor";
8
- import type { UIInputDummyOptions } from "./UIInputDummy.Internal";
9
+ import type { UIInputDummyOptions, UIInputEventData } from "./UIInputDummy.Internal";
9
10
  /** Rectangular area with dimensions but no rendering */
10
11
  export declare class UIInputDummy extends UIAnchor implements UIPlaneElement {
11
12
  /** Shape defining interactive region in element-local space (0,0 = bottom-left, 1,1 = top-right) */
@@ -18,6 +19,11 @@ export declare class UIInputDummy extends UIAnchor implements UIPlaneElement {
18
19
  protected readonly inputWrapper: UIInputWrapperInterface;
19
20
  private readonly catcherHandler;
20
21
  private wasPointerInside;
22
+ private readonly signalPressedInternal;
23
+ private readonly signalMovedInternal;
24
+ private readonly signalReleasedInternal;
25
+ private readonly signalEnteredInternal;
26
+ private readonly signalLeftInternal;
21
27
  /**
22
28
  * Creates a new UIInputDummy instance.
23
29
  *
@@ -41,6 +47,16 @@ export declare class UIInputDummy extends UIAnchor implements UIPlaneElement {
41
47
  get mode(): UIMode;
42
48
  /** Rendering and input priority. Higher values on top. */
43
49
  get zIndex(): number;
50
+ /** Signal fired when pointer is pressed */
51
+ get signalPressed(): FerrsignView1<UIInputEventData>;
52
+ /** Signal fired when pointer is moved */
53
+ get signalMoved(): FerrsignView1<UIInputEventData>;
54
+ /** Signal fired when pointer is released */
55
+ get signalReleased(): FerrsignView1<UIInputEventData>;
56
+ /** Signal fired when pointer enters element */
57
+ get signalEntered(): FerrsignView1<UIInputEventData>;
58
+ /** Signal fired when pointer leaves element */
59
+ get signalLeft(): FerrsignView1<UIInputEventData>;
44
60
  /** Width in world units */
45
61
  set width(value: number);
46
62
  /** Height in world units */
@@ -62,5 +78,5 @@ export declare class UIInputDummy extends UIAnchor implements UIPlaneElement {
62
78
  protected readonly catchPointerDown: (x: number, y: number, identifier: number) => boolean;
63
79
  protected readonly catchPointerMove: (x: number, y: number, identifier: number) => boolean;
64
80
  protected readonly catchPointerUp: (x: number, y: number, identifier: number) => boolean;
65
- protected handleInputEvent(x: number, y: number, identifier: number, inputEvent: UIInputEvent): boolean;
81
+ protected handleInputEvent(x: number, y: number, identifier: number, signal: Ferrsign1<UIInputEventData>): boolean;
66
82
  }
package/dist/index.d.ts CHANGED
@@ -43,7 +43,6 @@ export { UIResizePolicyFixedHeight } from "./miscellaneous/resize-policy/UIResiz
43
43
  export { UIResizePolicyFixedWidth } from "./miscellaneous/resize-policy/UIResizePolicyFixedWidth";
44
44
  export { UIResizePolicyNone } from "./miscellaneous/resize-policy/UIResizePolicyNone";
45
45
  export { UIExpression } from "./miscellaneous/UIExpression";
46
- export { UIInputEvent } from "./miscellaneous/UIInputEvent";
47
46
  export { UIMode } from "./miscellaneous/UIMode";
48
47
  export { UIOrientation } from "./miscellaneous/UIOrientation";
49
48
  export { UIPriority } from "./miscellaneous/UIPriority";