canvasengine 2.0.0-beta.5 → 2.0.0-beta.51

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 (172) hide show
  1. package/dist/components/Button.d.ts +185 -0
  2. package/dist/components/Button.d.ts.map +1 -0
  3. package/dist/components/Canvas.d.ts +17 -0
  4. package/dist/components/Canvas.d.ts.map +1 -0
  5. package/dist/components/Container.d.ts +86 -0
  6. package/dist/components/Container.d.ts.map +1 -0
  7. package/dist/components/DOMContainer.d.ts +98 -0
  8. package/dist/components/DOMContainer.d.ts.map +1 -0
  9. package/dist/components/DOMElement.d.ts +54 -0
  10. package/dist/components/DOMElement.d.ts.map +1 -0
  11. package/dist/components/DOMSprite.d.ts +127 -0
  12. package/dist/components/DOMSprite.d.ts.map +1 -0
  13. package/dist/components/DisplayObject.d.ts +94 -0
  14. package/dist/components/DisplayObject.d.ts.map +1 -0
  15. package/dist/components/FocusContainer.d.ts +129 -0
  16. package/dist/components/FocusContainer.d.ts.map +1 -0
  17. package/dist/components/Graphic.d.ts +64 -0
  18. package/dist/components/Graphic.d.ts.map +1 -0
  19. package/dist/components/Joystick.d.ts +36 -0
  20. package/dist/components/Joystick.d.ts.map +1 -0
  21. package/dist/components/Mesh.d.ts +208 -0
  22. package/dist/components/Mesh.d.ts.map +1 -0
  23. package/dist/components/NineSliceSprite.d.ts +16 -0
  24. package/dist/components/NineSliceSprite.d.ts.map +1 -0
  25. package/dist/components/ParticleEmitter.d.ts +4 -0
  26. package/dist/components/ParticleEmitter.d.ts.map +1 -0
  27. package/dist/components/Scene.d.ts +2 -0
  28. package/dist/components/Scene.d.ts.map +1 -0
  29. package/dist/components/Sprite.d.ts +242 -0
  30. package/dist/components/Sprite.d.ts.map +1 -0
  31. package/dist/components/Text.d.ts +25 -0
  32. package/dist/components/Text.d.ts.map +1 -0
  33. package/dist/components/TilingSprite.d.ts +17 -0
  34. package/dist/components/TilingSprite.d.ts.map +1 -0
  35. package/dist/components/Video.d.ts +14 -0
  36. package/dist/components/Video.d.ts.map +1 -0
  37. package/dist/components/Viewport.d.ts +121 -0
  38. package/dist/components/Viewport.d.ts.map +1 -0
  39. package/dist/components/index.d.ts +20 -0
  40. package/dist/components/index.d.ts.map +1 -0
  41. package/dist/components/types/DisplayObject.d.ts +106 -0
  42. package/dist/components/types/DisplayObject.d.ts.map +1 -0
  43. package/dist/components/types/MouseEvent.d.ts +4 -0
  44. package/dist/components/types/MouseEvent.d.ts.map +1 -0
  45. package/dist/components/types/Spritesheet.d.ts +248 -0
  46. package/dist/components/types/Spritesheet.d.ts.map +1 -0
  47. package/dist/components/types/index.d.ts +4 -0
  48. package/dist/components/types/index.d.ts.map +1 -0
  49. package/dist/directives/Controls.d.ts +112 -0
  50. package/dist/directives/Controls.d.ts.map +1 -0
  51. package/dist/directives/ControlsBase.d.ts +199 -0
  52. package/dist/directives/ControlsBase.d.ts.map +1 -0
  53. package/dist/directives/Drag.d.ts +69 -0
  54. package/dist/directives/Drag.d.ts.map +1 -0
  55. package/dist/directives/Flash.d.ts +116 -0
  56. package/dist/directives/Flash.d.ts.map +1 -0
  57. package/dist/directives/FocusNavigation.d.ts +52 -0
  58. package/dist/directives/FocusNavigation.d.ts.map +1 -0
  59. package/dist/directives/GamepadControls.d.ts +224 -0
  60. package/dist/directives/GamepadControls.d.ts.map +1 -0
  61. package/dist/directives/JoystickControls.d.ts +171 -0
  62. package/dist/directives/JoystickControls.d.ts.map +1 -0
  63. package/dist/directives/KeyboardControls.d.ts +219 -0
  64. package/dist/directives/KeyboardControls.d.ts.map +1 -0
  65. package/dist/directives/Scheduler.d.ts +35 -0
  66. package/dist/directives/Scheduler.d.ts.map +1 -0
  67. package/dist/directives/Shake.d.ts +98 -0
  68. package/dist/directives/Shake.d.ts.map +1 -0
  69. package/dist/directives/Sound.d.ts +25 -0
  70. package/dist/directives/Sound.d.ts.map +1 -0
  71. package/dist/directives/Transition.d.ts +10 -0
  72. package/dist/directives/Transition.d.ts.map +1 -0
  73. package/dist/directives/ViewportCull.d.ts +11 -0
  74. package/dist/directives/ViewportCull.d.ts.map +1 -0
  75. package/dist/directives/ViewportFollow.d.ts +18 -0
  76. package/dist/directives/ViewportFollow.d.ts.map +1 -0
  77. package/dist/directives/index.d.ts +13 -0
  78. package/dist/directives/index.d.ts.map +1 -0
  79. package/dist/engine/FocusManager.d.ts +174 -0
  80. package/dist/engine/FocusManager.d.ts.map +1 -0
  81. package/dist/engine/animation.d.ts +72 -0
  82. package/dist/engine/animation.d.ts.map +1 -0
  83. package/dist/engine/bootstrap.d.ts +48 -0
  84. package/dist/engine/bootstrap.d.ts.map +1 -0
  85. package/dist/engine/directive.d.ts +13 -0
  86. package/dist/engine/directive.d.ts.map +1 -0
  87. package/dist/engine/reactive.d.ts +134 -0
  88. package/dist/engine/reactive.d.ts.map +1 -0
  89. package/dist/engine/signal.d.ts +71 -0
  90. package/dist/engine/signal.d.ts.map +1 -0
  91. package/dist/engine/trigger.d.ts +54 -0
  92. package/dist/engine/trigger.d.ts.map +1 -0
  93. package/dist/engine/utils.d.ts +89 -0
  94. package/dist/engine/utils.d.ts.map +1 -0
  95. package/dist/hooks/addContext.d.ts +2 -0
  96. package/dist/hooks/addContext.d.ts.map +1 -0
  97. package/dist/hooks/useFocus.d.ts +60 -0
  98. package/dist/hooks/useFocus.d.ts.map +1 -0
  99. package/dist/hooks/useProps.d.ts +42 -0
  100. package/dist/hooks/useProps.d.ts.map +1 -0
  101. package/dist/hooks/useRef.d.ts +4 -0
  102. package/dist/hooks/useRef.d.ts.map +1 -0
  103. package/dist/index-DaGekQUW.js +2218 -0
  104. package/dist/index-DaGekQUW.js.map +1 -0
  105. package/dist/index.d.ts +19 -1099
  106. package/dist/index.d.ts.map +1 -0
  107. package/dist/index.global.js +5 -0
  108. package/dist/index.global.js.map +1 -0
  109. package/dist/index.js +11749 -2901
  110. package/dist/index.js.map +1 -1
  111. package/dist/utils/Ease.d.ts +17 -0
  112. package/dist/utils/Ease.d.ts.map +1 -0
  113. package/dist/utils/GlobalAssetLoader.d.ts +141 -0
  114. package/dist/utils/GlobalAssetLoader.d.ts.map +1 -0
  115. package/dist/utils/RadialGradient.d.ts +57 -0
  116. package/dist/utils/RadialGradient.d.ts.map +1 -0
  117. package/dist/utils/functions.d.ts +2 -0
  118. package/dist/utils/functions.d.ts.map +1 -0
  119. package/dist/utils/tabindex.d.ts +16 -0
  120. package/dist/utils/tabindex.d.ts.map +1 -0
  121. package/package.json +13 -7
  122. package/src/components/Button.ts +399 -0
  123. package/src/components/Canvas.ts +62 -46
  124. package/src/components/Container.ts +21 -2
  125. package/src/components/DOMContainer.ts +379 -0
  126. package/src/components/DOMElement.ts +556 -0
  127. package/src/components/DOMSprite.ts +1040 -0
  128. package/src/components/DisplayObject.ts +392 -201
  129. package/src/components/FocusContainer.ts +368 -0
  130. package/src/components/Graphic.ts +227 -66
  131. package/src/components/Joystick.ts +363 -0
  132. package/src/components/Mesh.ts +222 -0
  133. package/src/components/NineSliceSprite.ts +4 -1
  134. package/src/components/ParticleEmitter.ts +12 -8
  135. package/src/components/Sprite.ts +297 -31
  136. package/src/components/Text.ts +125 -18
  137. package/src/components/Video.ts +2 -2
  138. package/src/components/Viewport.ts +118 -63
  139. package/src/components/index.ts +9 -2
  140. package/src/components/types/DisplayObject.ts +41 -4
  141. package/src/components/types/Spritesheet.ts +0 -118
  142. package/src/directives/Controls.ts +254 -0
  143. package/src/directives/ControlsBase.ts +267 -0
  144. package/src/directives/Drag.ts +357 -52
  145. package/src/directives/Flash.ts +419 -0
  146. package/src/directives/FocusNavigation.ts +113 -0
  147. package/src/directives/GamepadControls.ts +537 -0
  148. package/src/directives/JoystickControls.ts +396 -0
  149. package/src/directives/KeyboardControls.ts +85 -430
  150. package/src/directives/Scheduler.ts +12 -4
  151. package/src/directives/Shake.ts +298 -0
  152. package/src/directives/Sound.ts +94 -31
  153. package/src/directives/ViewportFollow.ts +40 -9
  154. package/src/directives/index.ts +12 -6
  155. package/src/engine/FocusManager.ts +510 -0
  156. package/src/engine/animation.ts +175 -21
  157. package/src/engine/bootstrap.ts +93 -3
  158. package/src/engine/directive.ts +4 -4
  159. package/src/engine/reactive.ts +901 -161
  160. package/src/engine/signal.ts +113 -25
  161. package/src/engine/trigger.ts +34 -7
  162. package/src/engine/utils.ts +19 -3
  163. package/src/hooks/useFocus.ts +91 -0
  164. package/src/hooks/useProps.ts +1 -1
  165. package/src/index.ts +8 -2
  166. package/src/types/pixi-cull.d.ts +7 -0
  167. package/src/utils/GlobalAssetLoader.ts +257 -0
  168. package/src/utils/functions.ts +7 -0
  169. package/src/utils/tabindex.ts +70 -0
  170. package/testing/index.ts +35 -4
  171. package/tsconfig.json +18 -0
  172. package/vite.config.ts +39 -0
@@ -0,0 +1,72 @@
1
+ import { WritableSignal, Signal } from '@signe/reactive';
2
+ import { Tick } from '../directives/Scheduler';
3
+ export interface AnimateOptions<T> {
4
+ duration?: number;
5
+ ease?: (t: number) => number;
6
+ onUpdate?: (value: T) => void;
7
+ onComplete?: () => void;
8
+ tick?: Signal<Tick>;
9
+ }
10
+ export interface AnimatedState<T> {
11
+ current: T;
12
+ start: T;
13
+ end: T;
14
+ }
15
+ export interface AnimatedSignal<T> extends Omit<WritableSignal<T>, 'set'> {
16
+ (): T;
17
+ set: (newValue: T, options?: AnimateOptions<T>) => Promise<void>;
18
+ animatedState: WritableSignal<AnimatedState<T>>;
19
+ update: (updater: (value: T) => T) => void;
20
+ pause: () => void;
21
+ resume: () => void;
22
+ }
23
+ export declare function isAnimatedSignal(signal: WritableSignal<any>): boolean;
24
+ /**
25
+ * Creates an animated signal with the given initial value and animation options.
26
+ * It's a writable signal that can be animated using popmotion. Properties of the animated signal are:
27
+ * - current: the current value of the signal.
28
+ * - start: the start value of the animation.
29
+ * - end: the end value of the animation.
30
+ *
31
+ * If a tick signal is provided in options, the animation will use the engine's tick system.
32
+ * Otherwise, it will automatically use the global tick signal from the Canvas context if available.
33
+ * If no tick signal is available, it will use requestAnimationFrame by default.
34
+ *
35
+ * @param initialValue The initial value of the signal.
36
+ * @param options The animation options. Can include a `tick` signal to use a specific tick system.
37
+ * @returns The animated signal.
38
+ * @example
39
+ * ```ts
40
+ * // Automatically uses the Canvas tick system if available, otherwise requestAnimationFrame
41
+ * const animatedValue = animatedSignal(0, { duration: 1000 });
42
+ * animatedValue.set(10);
43
+ *
44
+ * // Explicitly using a specific tick signal
45
+ * mount((element) => {
46
+ * const tickSignal = element.props.context.tick;
47
+ * const animatedValue = animatedSignal(0, { duration: 1000, tick: tickSignal });
48
+ * animatedValue.set(10);
49
+ * });
50
+ * ```
51
+ */
52
+ export declare function animatedSignal<T>(initialValue: T, options?: AnimateOptions<T>): AnimatedSignal<T>;
53
+ /**
54
+ * Executes a sequence of animations. If an array is provided as an element in the sequence,
55
+ * those animations will be executed in parallel.
56
+ *
57
+ * @param sequence Array of animation functions or arrays of animation functions for parallel execution
58
+ * @returns Promise that resolves when all animations are complete
59
+ * @example
60
+ * ```ts
61
+ * await animatedSequence([
62
+ * () => value1.set(10),
63
+ * [
64
+ * () => value2.set(20),
65
+ * () => value3.set(30)
66
+ * ],
67
+ * () => value1.set(0)
68
+ * ])
69
+ * ```
70
+ */
71
+ export declare function animatedSequence(sequence: ((() => Promise<void>) | (() => Promise<void>)[])[]): Promise<void>;
72
+ //# sourceMappingURL=animation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"animation.d.ts","sourceRoot":"","sources":["../../src/engine/animation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,cAAc,EAAE,KAAK,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEnF,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAa/C,MAAM,WAAW,cAAc,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;IAC7B,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;CACrB;AAED,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,OAAO,EAAE,CAAC,CAAC;IACX,KAAK,EAAE,CAAC,CAAC;IACT,GAAG,EAAE,CAAC,CAAC;CACR;AAED,MAAM,WAAW,cAAc,CAAC,CAAC,CAAE,SAAQ,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC;IACvE,IAAI,CAAC,CAAC;IACN,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,aAAa,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,MAAM,EAAE,CAAC,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC;IAC3C,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,CAAC,GAAG,OAAO,CAErE;AAkDD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,OAAO,GAAE,cAAc,CAAC,CAAC,CAAM,GAAG,cAAc,CAAC,CAAC,CAAC,CAwHrG;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,gBAAgB,CAAC,QAAQ,EAAE,CAAC,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,iBAQnG"}
@@ -0,0 +1,48 @@
1
+ import { Application, ApplicationOptions } from 'pixi.js';
2
+ import { ComponentFunction } from './signal';
3
+ /**
4
+ * Extended options for bootstrapCanvas that includes component registration configuration.
5
+ *
6
+ * @property components - Optional mapping of component names to their classes (can include mocks for testing)
7
+ * @property autoRegister - If true (default), registers all default components before applying custom components. If false, only registers the specified components.
8
+ */
9
+ export interface BootstrapOptions extends ApplicationOptions {
10
+ components?: {
11
+ [name: string]: any;
12
+ };
13
+ autoRegister?: boolean;
14
+ enableLayout?: boolean;
15
+ }
16
+ /**
17
+ * Bootstraps a canvas element and renders it to the DOM.
18
+ *
19
+ * @param rootElement - The HTML element where the canvas will be rendered. Can be null.
20
+ * @param canvas - A Promise that resolves to an Element representing the canvas component.
21
+ * @param options - Optional bootstrap options including ApplicationOptions and component registration configuration.
22
+ * @returns A Promise that resolves to the rendered canvas element.
23
+ * @throws {Error} If the provided element is not a Canvas component.
24
+ *
25
+ * @example
26
+ * ```typescript
27
+ * // Default: all components registered automatically
28
+ * await bootstrapCanvas(rootElement, MyComponent, {
29
+ * width: 800,
30
+ * height: 600
31
+ * });
32
+ * ```
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * // With mocks for testing
37
+ * import { mockComponents } from '@canvasengine/testing';
38
+ * await bootstrapCanvas(rootElement, MyComponent, {
39
+ * components: mockComponents,
40
+ * autoRegister: false
41
+ * });
42
+ * ```
43
+ */
44
+ export declare const bootstrapCanvas: (rootElement: HTMLElement | null, canvas: ComponentFunction<any>, options?: BootstrapOptions) => Promise<{
45
+ canvasElement: import('./reactive').Element<import('..').ComponentInstance>;
46
+ app: Application<import('pixi.js').Renderer>;
47
+ }>;
48
+ //# sourceMappingURL=bootstrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../../src/engine/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAK,MAAM,UAAU,CAAC;AAOhD,OAAO,sBAAsB,CAAC;AAC9B,OAAO,yBAAyB,CAAC;AACjC,OAAO,sBAAsB,CAAC;AAC9B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,oBAAoB,CAAC;AAC5B,OAAO,wBAAwB,CAAC;AAChC,OAAO,4BAA4B,CAAC;AACpC,OAAO,+BAA+B,CAAC;AACvC,OAAO,4BAA4B,CAAC;AACpC,OAAO,0BAA0B,CAAC;AAClC,OAAO,+BAA+B,CAAC;AAEvC;;;;;GAKG;AACH,MAAM,WAAW,gBAAiB,SAAQ,kBAAkB;IAC1D,UAAU,CAAC,EAAE;QACX,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC;KACrB,CAAC;IACF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,eAAe,GAAU,aAAa,WAAW,GAAG,IAAI,EAAE,QAAQ,iBAAiB,CAAC,GAAG,CAAC,EAAE,UAAU,gBAAgB;;;EA6ChI,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { Element } from './reactive';
2
+ export declare const directives: {
3
+ [key: string]: any;
4
+ };
5
+ export declare abstract class Directive {
6
+ abstract onDestroy(element: Element<any>): any;
7
+ abstract onInit(element: Element<any>): any;
8
+ abstract onMount(element: Element<any>): any;
9
+ abstract onUpdate(props: any, element: Element<any>): any;
10
+ }
11
+ export declare function registerDirective(name: string, directive: any): void;
12
+ export declare function applyDirective(element: Element<any>, directiveName: string): any;
13
+ //# sourceMappingURL=directive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"directive.d.ts","sourceRoot":"","sources":["../../src/engine/directive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AAEpC,eAAO,MAAM,UAAU,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAO,CAAA;AAEpD,8BAAsB,SAAS;IAC3B,QAAQ,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC;IACxC,QAAQ,CAAC,MAAM,CAAC,OAAO,EAAG,OAAO,CAAC,GAAG,CAAC;IACtC,QAAQ,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC;IACtC,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC;CACtD;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,QAE7D;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,EAAE,aAAa,EAAE,MAAM,OAO1E"}
@@ -0,0 +1,134 @@
1
+ import { Signal } from '@signe/reactive';
2
+ import { Observable, Subject, Subscription } from 'rxjs';
3
+ import { ComponentInstance } from '../components/DisplayObject';
4
+ import { Directive } from './directive';
5
+ export interface Props {
6
+ [key: string]: any;
7
+ }
8
+ type NestedSignalObjects = {
9
+ [Key in string]: NestedSignalObjects | Signal<any>;
10
+ };
11
+ export interface Element<T = ComponentInstance> {
12
+ tag: string;
13
+ props: Props;
14
+ componentInstance: T;
15
+ propSubscriptions: Subscription[];
16
+ effectSubscriptions: Subscription[];
17
+ effectMounts: (() => void)[];
18
+ effectUnmounts: ((element?: Element) => void)[];
19
+ propObservables: NestedSignalObjects | undefined;
20
+ parent: Element | null;
21
+ context?: {
22
+ [key: string]: any;
23
+ };
24
+ directives: {
25
+ [key: string]: Directive;
26
+ };
27
+ destroy: () => void;
28
+ allElements: Subject<void>;
29
+ isFrozen: boolean;
30
+ }
31
+ type FlowResult = {
32
+ elements: Element[];
33
+ prev?: Element;
34
+ fullElements?: Element[];
35
+ };
36
+ type FlowObservable = Observable<FlowResult>;
37
+ export declare const isElement: (value: any) => value is Element;
38
+ export declare const isPrimitive: (value: any) => boolean;
39
+ export declare function registerComponent(name: any, component: any): void;
40
+ /**
41
+ * Registers all default CanvasEngine components.
42
+ *
43
+ * This function imports and registers all core components that are available by default.
44
+ * It's called automatically by bootstrapCanvas() if no custom component configuration is provided.
45
+ *
46
+ * Components register themselves when their modules are imported, so this function ensures
47
+ * all component modules are loaded. Since components call registerComponent() at module load time,
48
+ * importing them will automatically register them synchronously.
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * // Register all default components manually
53
+ * registerAllComponents();
54
+ *
55
+ * // Now you can use any component
56
+ * const sprite = createComponent('Sprite', { image: 'hero.png' });
57
+ * ```
58
+ */
59
+ export declare function registerAllComponents(): void;
60
+ /**
61
+ * Checks if all dependencies are ready (not undefined).
62
+ * Handles signals synchronously and promises asynchronously.
63
+ * For reactive signals, sets up subscriptions to mount when all become ready.
64
+ *
65
+ * @param deps - Array of signals, promises, or direct values
66
+ * @returns Promise<boolean> - true if all dependencies are ready
67
+ */
68
+ export declare function checkDependencies(deps: any[]): Promise<boolean>;
69
+ export declare function waitForDependencies(deps: any[]): Promise<void>;
70
+ /**
71
+ * Checks if an element is currently frozen.
72
+ * An element is frozen when the `freeze` prop is set to `true` (either as a boolean or Signal<boolean>),
73
+ * or when any of its parent elements are frozen (recursive freeze propagation).
74
+ *
75
+ * @param element - The element to check
76
+ * @returns `true` if the element is frozen, `false` otherwise
77
+ */
78
+ export declare function isElementFrozen(element: Element): boolean;
79
+ /**
80
+ * Creates a virtual element or a representation thereof, with properties that can be dynamically updated based on BehaviorSubjects.
81
+ *
82
+ * @param {string} tag - The tag name of the element to create.
83
+ * @param {Object} props - An object containing properties for the element. Each property can either be a direct value
84
+ * or an array where the first element is a function that returns a value based on input parameters,
85
+ * and the second element is an array of BehaviorSubjects. The property is updated dynamically
86
+ * using the combineLatest RxJS operator to wait for all BehaviorSubjects to emit.
87
+ * @returns {Object} An object representing the created element, including tag name and dynamic properties.
88
+ */
89
+ export declare function createComponent(tag: string, props?: Props): Element;
90
+ /**
91
+ * Observes a BehaviorSubject containing an array or object of items and dynamically creates child elements for each item.
92
+ *
93
+ * @param {WritableArraySignal<T> | WritableObjectSignal<T>} itemsSubject - A signal that emits an array or object of items.
94
+ * @param {Function} createElementFn - A function that takes an item and returns an element representation.
95
+ * @returns {Observable} An observable that emits the list of created child elements.
96
+ */
97
+ export declare function loop<T>(itemsSubject: any, createElementFn: (item: T, index: number | string) => Element | null): FlowObservable;
98
+ /**
99
+ * Conditionally creates and destroys elements based on condition signals with support for else if and else.
100
+ *
101
+ * @description This function creates conditional rendering with support for multiple conditions (if/else if/else pattern).
102
+ * It evaluates conditions in order and renders the first matching condition's element.
103
+ * The function maintains full reactivity with signals and ensures proper cleanup of elements.
104
+ *
105
+ * @param {Signal<boolean> | boolean | (() => boolean)} condition - A signal, boolean, or function that determines whether to create an element.
106
+ * @param {Function} createElementFn - A function that returns an element or a promise that resolves to an element.
107
+ * @param {...Array} additionalConditions - Additional conditions for else if and else cases.
108
+ * Can be:
109
+ * - A function for else case: `() => Element | Promise<Element>`
110
+ * - An array for else if case: `[Signal<boolean> | boolean | (() => boolean), () => Element | Promise<Element>]`
111
+ * @returns {Observable} An observable that emits the created element based on the matching condition.
112
+ *
113
+ * @example
114
+ * ```typescript
115
+ * // Simple if/else
116
+ * cond(
117
+ * signal(isVisible),
118
+ * () => h(Container),
119
+ * () => h(Text, { text: 'Hidden' }) // else
120
+ * );
121
+ *
122
+ * // Multiple else if + else
123
+ * cond(
124
+ * signal(status === 'loading'),
125
+ * () => h(LoadingSpinner),
126
+ * [signal(status === 'error'), () => h(ErrorMessage)], // else if
127
+ * [signal(status === 'success'), () => h(SuccessMessage)], // else if
128
+ * () => h(DefaultMessage) // else
129
+ * );
130
+ * ```
131
+ */
132
+ export declare function cond(condition: Signal<boolean> | boolean | (() => boolean), createElementFn: () => Element | Promise<Element>, ...additionalConditions: Array<(() => Element | Promise<Element>) | [Signal<boolean> | boolean | (() => boolean), () => Element | Promise<Element>]>): FlowObservable;
133
+ export {};
134
+ //# sourceMappingURL=reactive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactive.d.ts","sourceRoot":"","sources":["../../src/engine/reactive.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,71 @@
1
+ import { Subscription } from 'rxjs';
2
+ import { Element } from './reactive';
3
+ import { Tick } from '../directives/Scheduler';
4
+ type MountFunction = (fn: (element: Element) => void) => void;
5
+ export type ComponentFunction<P = {}> = (props: P) => Element | Promise<Element>;
6
+ export declare let currentSubscriptionsTracker: ((subscription: Subscription) => void) | null;
7
+ export declare let mountTracker: MountFunction | null;
8
+ /**
9
+ * Registers a mount function to be called when the component is mounted.
10
+ * To unmount the component, the function must return a function that will be called by the engine.
11
+ *
12
+ * @param {(element: Element) => void} fn - The function to be called on mount.
13
+ * @example
14
+ * ```ts
15
+ * mount((el) => {
16
+ * console.log('mounted', el);
17
+ * });
18
+ * ```
19
+ * Unmount the component by returning a function:
20
+ * ```ts
21
+ * mount((el) => {
22
+ * console.log('mounted', el);
23
+ * return () => {
24
+ * console.log('unmounted', el);
25
+ * }
26
+ * });
27
+ * ```
28
+ */
29
+ export declare function mount(fn: (element: Element) => void): void;
30
+ /**
31
+ * Registers a tick function to be called on each tick of the component's context.
32
+ * @param {(tickValue: Tick, element: Element) => void} fn - The function to be called on each tick.
33
+ * @example
34
+ * ```ts
35
+ * tick((tickValue, el) => {
36
+ * console.log('tick', tickValue, el);
37
+ * });
38
+ * ```
39
+ */
40
+ export declare function tick(fn: (tickValue: Tick, element: Element) => void): void;
41
+ /**
42
+ * Add tracking for subscriptions and mounts, then create an element from a component function.
43
+ * @template C
44
+ * @param {C} componentFunction - The component function to create an element from.
45
+ * @param {Parameters<C>[0]} [props={}] - The props to pass to the component function.
46
+ * @param {...any[]} children - The children elements of the component.
47
+ * @returns {ReturnType<C>}
48
+ * @example
49
+ * ```ts
50
+ * const el = h(MyComponent, {
51
+ * x: 100,
52
+ * y: 100,
53
+ * });
54
+ * ```
55
+ *
56
+ * with children:
57
+ * ```ts
58
+ * const el = h(MyComponent, {
59
+ * x: 100,
60
+ * y: 100,
61
+ * },
62
+ * h(MyChildComponent, {
63
+ * x: 50,
64
+ * y: 50,
65
+ * }),
66
+ * );
67
+ * ```
68
+ */
69
+ export declare function h<C extends ComponentFunction<any>>(componentFunction: C | Element, props?: Parameters<C>[0], ...children: any[]): ReturnType<C>;
70
+ export {};
71
+ //# sourceMappingURL=signal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signal.d.ts","sourceRoot":"","sources":["../../src/engine/signal.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,YAAY,EACb,MAAM,MAAM,CAAC;AAEd,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAG1C,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAG/C,KAAK,aAAa,GAAG,CAAC,EAAE,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,KAAK,IAAI,CAAC;AAG9D,MAAM,MAAM,iBAAiB,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAEjF,eAAO,IAAI,2BAA2B,EAAE,CAAC,CAAC,YAAY,EAAE,YAAY,KAAK,IAAI,CAAC,GAAG,IAAW,CAAC;AAC7F,eAAO,IAAI,YAAY,EAAE,aAAa,GAAG,IAAW,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,KAAK,CAAC,EAAE,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,QAEnD;AAED;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAAC,EAAE,EAAE,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,QAiBnE;AAqGD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,CAAC,CAAC,CAAC,SAAS,iBAAiB,CAAC,GAAG,CAAC,EAChD,iBAAiB,EAAE,CAAC,GAAG,OAAO,EAC9B,KAAK,GAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAA0B,EAChD,GAAG,QAAQ,EAAE,GAAG,EAAE,GACjB,UAAU,CAAC,CAAC,CAAC,CAqBf"}
@@ -0,0 +1,54 @@
1
+ export interface Listen<T = any> {
2
+ config: T | undefined;
3
+ seed: {
4
+ config: T | undefined;
5
+ value: number;
6
+ resolve: (value: any) => void;
7
+ };
8
+ }
9
+ export interface Trigger<T = any> {
10
+ start: () => Promise<void>;
11
+ listen: () => Listen<T> | undefined;
12
+ }
13
+ /**
14
+ * Checks if the given argument is a Trigger object
15
+ * @param arg - The value to check
16
+ * @returns True if the argument is a Trigger object
17
+ */
18
+ export declare function isTrigger(arg: any): arg is Trigger<any>;
19
+ /**
20
+ * Creates a new trigger that can be used to pass data between components
21
+ * @param globalConfig - Optional configuration data to be passed when the trigger is activated
22
+ * @returns A Trigger object with start and listen methods
23
+ * @example
24
+ * ```ts
25
+ * const myTrigger = trigger()
26
+ *
27
+ * on(myTrigger, (data) => {
28
+ * console.log('Triggered with data:', data)
29
+ * })
30
+ *
31
+ * myTrigger.start({ message: 'Hello' })
32
+ * ```
33
+ */
34
+ export declare function trigger<T = any>(globalConfig?: T): Trigger<T>;
35
+ /**
36
+ * Subscribes to a trigger and executes a callback when the trigger is activated
37
+ * @param triggerSignal - The trigger to subscribe to
38
+ * @param callback - Function to execute when the trigger is activated
39
+ * @returns Subscription that can be unsubscribed to stop listening
40
+ * @throws Error if triggerSignal is not a valid trigger
41
+ * @example
42
+ * ```ts
43
+ * const click = trigger()
44
+ *
45
+ * const subscription = on(click, () => {
46
+ * console.log('Click triggered')
47
+ * })
48
+ *
49
+ * // Later, to stop listening:
50
+ * subscription.unsubscribe()
51
+ * ```
52
+ */
53
+ export declare function on(triggerSignal: any, callback: (config: any) => void | Promise<void>): import('rxjs').Subscription;
54
+ //# sourceMappingURL=trigger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trigger.d.ts","sourceRoot":"","sources":["../../src/engine/trigger.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,MAAM,CAAC,CAAC,GAAG,GAAG;IAC7B,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC;IACtB,IAAI,EAAE;QACJ,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC;QACtB,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;KAC/B,CAAC;CACH;AAED,MAAM,WAAW,OAAO,CAAC,CAAC,GAAG,GAAG;IAC9B,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,MAAM,EAAE,MAAM,MAAM,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;CACrC;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,CAEvD;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,YAAY,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CA2B7D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,EAAE,CAAC,aAAa,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,+BAmCrF"}
@@ -0,0 +1,89 @@
1
+ import { ObservablePoint } from 'pixi.js';
2
+ /**
3
+ * Checks if code is running in a browser environment
4
+ * @returns {boolean} True if running in browser, false otherwise
5
+ */
6
+ export declare function isBrowser(): boolean;
7
+ /**
8
+ * Returns current high-resolution timestamp
9
+ * @returns {number} Current time in milliseconds
10
+ */
11
+ export declare function preciseNow(): number;
12
+ /**
13
+ * Converts frames per second to milliseconds
14
+ * @param {number} fps - Frames per second
15
+ * @returns {number} Milliseconds per frame
16
+ */
17
+ export declare function fps2ms(fps: number): number;
18
+ /**
19
+ * Checks if a value is a Promise
20
+ * @param {any} value - Value to check
21
+ * @returns {boolean} True if value is a Promise, false otherwise
22
+ */
23
+ export declare function isPromise(value: any): boolean;
24
+ export declare function arrayEquals(a: any[], b: any[]): boolean;
25
+ /**
26
+ * Checks if a value is a function
27
+ * @param {unknown} val - Value to check
28
+ * @returns {boolean} True if value is a function, false otherwise
29
+ */
30
+ export declare function isFunction(val: unknown): boolean;
31
+ /**
32
+ * Checks if a value is a plain object (not an instance of a class)
33
+ * @param {unknown} val - Value to check
34
+ * @returns {boolean} True if value is a plain object (not null, not array, not instance), false otherwise
35
+ * @example
36
+ * ```ts
37
+ * isObject({}) // true
38
+ * isObject(new Date()) // false
39
+ * isObject([]) // false
40
+ * isObject(null) // false
41
+ * ```
42
+ */
43
+ export declare function isObject(val: unknown): boolean;
44
+ export declare function isObservable(val: unknown): boolean;
45
+ /**
46
+ * Sets a value in an object using a dot notation path
47
+ * @param {Record<string, any>} obj - Target object
48
+ * @param {string | string[]} path - Path to set value at (e.g., 'a.b.c' or ['a', 'b', 'c'])
49
+ * @param {any} value - Value to set
50
+ * @param {boolean} onlyPlainObject - If true, only creates plain objects in path
51
+ * @returns {Record<string, any>} Modified object
52
+ */
53
+ export declare function set(obj: Record<string, any>, path: string | string[], value: any, onlyPlainObject?: boolean): Record<string, any>;
54
+ /**
55
+ * Gets a value from an object using a dot notation path
56
+ * @param {Record<string, any>} obj - Source object
57
+ * @param {string} path - Path to get value from (e.g., 'a.b.c')
58
+ * @returns {any} Value at path or undefined if not found
59
+ */
60
+ export declare function get(obj: Record<string, any>, path: string): any;
61
+ /**
62
+ * Logs a message to console
63
+ * @param {any} text - Message to log
64
+ */
65
+ export declare function log(text: any): void;
66
+ /**
67
+ * Logs an error message to console
68
+ * @param {any} text - Error message to log
69
+ */
70
+ export declare function error(text: any): void;
71
+ /**
72
+ * Sets the position of an ObservablePoint using various input formats
73
+ * @param {ObservablePoint} observablePoint - The point to modify
74
+ * @param {Object | number | [number, number]} point - New position value
75
+ */
76
+ export declare function setObservablePoint(observablePoint: ObservablePoint, point: {
77
+ x: number;
78
+ y: number;
79
+ } | number | [number, number]): void;
80
+ /**
81
+ * Calculates the Euclidean distance between two points
82
+ * @param {number} x1 - X coordinate of first point
83
+ * @param {number} y1 - Y coordinate of first point
84
+ * @param {number} x2 - X coordinate of second point
85
+ * @param {number} y2 - Y coordinate of second point
86
+ * @returns {number} Distance between the points
87
+ */
88
+ export declare function calculateDistance(x1: number, y1: number, x2: number, y2: number): number;
89
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/engine/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAGzC;;;GAGG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAED;;;GAGG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAE1C;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,GAAG,GAAG,OAAO,CAE7C;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,OAAO,CAiBvD;AAyBD;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAEhD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAE9C;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAElD;AAED;;;;;;;GAOG;AACH,wBAAgB,GAAG,CACf,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACxB,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,EACvB,KAAK,EAAE,GAAG,EACV,eAAe,UAAQ,GACxB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CA0BrB;AAED;;;;;GAKG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,CAY/D;AAED;;;GAGG;AACH,wBAAgB,GAAG,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,CAEnC;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI,CAErC;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAC9B,eAAe,EAAE,eAAe,EAChC,KAAK,EAAE;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAC5D,IAAI,CAaN;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC7B,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,GACX,MAAM,CAIR"}
@@ -0,0 +1,2 @@
1
+ export declare const addContext: (element: any, key: any, value: any) => void;
2
+ //# sourceMappingURL=addContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addContext.d.ts","sourceRoot":"","sources":["../../src/hooks/addContext.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,GAAI,YAAO,EAAE,QAAG,EAAE,UAAK,SAK7C,CAAA"}
@@ -0,0 +1,60 @@
1
+ import { Signal } from '@signe/reactive';
2
+ import { Element } from '../engine/reactive';
3
+ /**
4
+ * Get the current focus index signal for a container
5
+ *
6
+ * Returns a reactive signal that updates when the focus index changes.
7
+ *
8
+ * @param containerId - Container identifier
9
+ * @returns Signal for current focus index, or null if container not found
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const focusIndex = useFocusIndex('myContainer');
14
+ * effect(() => {
15
+ * console.log('Current focus index:', focusIndex?.());
16
+ * });
17
+ * ```
18
+ */
19
+ export declare function useFocusIndex(containerId: string): Signal<number | null> | null;
20
+ /**
21
+ * Get the current focused element signal for a container
22
+ *
23
+ * Returns a reactive signal that updates when the focused element changes.
24
+ *
25
+ * @param containerId - Container identifier
26
+ * @returns Signal for current focused element, or null if container not found
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * const focusedElement = useFocusedElement('myContainer');
31
+ * effect(() => {
32
+ * const element = focusedElement?.();
33
+ * if (element) {
34
+ * console.log('Focused element:', element);
35
+ * }
36
+ * });
37
+ * ```
38
+ */
39
+ export declare function useFocusedElement(containerId: string): Signal<Element | null> | null;
40
+ /**
41
+ * Hook to react to focus changes
42
+ *
43
+ * Sets up a reactive effect that calls the callback whenever the focus changes.
44
+ *
45
+ * @param containerId - Container identifier
46
+ * @param callback - Function to call when focus changes
47
+ * @returns Cleanup function to unsubscribe
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * useFocusChange('myContainer', (index, element) => {
52
+ * console.log('Focus changed to index', index);
53
+ * if (element) {
54
+ * console.log('Focused element:', element);
55
+ * }
56
+ * });
57
+ * ```
58
+ */
59
+ export declare function useFocusChange(containerId: string, callback: (index: number | null, element: Element | null) => void): () => void;
60
+ //# sourceMappingURL=useFocus.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFocus.d.ts","sourceRoot":"","sources":["../../src/hooks/useFocus.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAI7C;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,IAAI,CAE/E;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,IAAI,CAEpF;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,cAAc,CAC5B,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,GAChE,MAAM,IAAI,CAoBZ"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Converts props into reactive signals if they are primitive values.
3
+ *
4
+ * @param {object} props - The properties to convert.
5
+ * @param {object} [defaults={}] - Default values for properties.
6
+ * @returns {object} An object with reactive signals.
7
+ *
8
+ * @example
9
+ * const props = useProps({ count: 0, name: "John" });
10
+ * console.log(props.count()); // 0
11
+ * props.count.set(1);
12
+ * console.log(props.count()); // 1
13
+ */
14
+ export declare const useProps: (props: any, defaults?: {}) => any;
15
+ type PropType = NumberConstructor | StringConstructor | BooleanConstructor | FunctionConstructor | ObjectConstructor | ArrayConstructor | null | (new (...args: any[]) => any);
16
+ interface PropConfig {
17
+ type?: PropType | PropType[];
18
+ required?: boolean;
19
+ default?: any | ((props: any) => any);
20
+ validator?: (value: any, props: any) => boolean;
21
+ }
22
+ type PropSchema = {
23
+ [key: string]: PropType | PropType[] | PropConfig;
24
+ };
25
+ /**
26
+ * Validates and defines properties based on a schema.
27
+ *
28
+ * @param {object} props - The properties to validate.
29
+ * @returns {function} A function that takes a schema and returns validated properties.
30
+ *
31
+ * @example
32
+ * const schema = {
33
+ * age: { type: Number, required: true },
34
+ * name: { type: String, default: "Anonymous" }
35
+ * };
36
+ * const validatedProps = useDefineProps({ age: 25 })(schema);
37
+ * console.log(validatedProps.age()); // 25
38
+ * console.log(validatedProps.name()); // "Anonymous"
39
+ */
40
+ export declare const useDefineProps: (props: any) => (schema?: PropSchema) => any;
41
+ export {};
42
+ //# sourceMappingURL=useProps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useProps.d.ts","sourceRoot":"","sources":["../../src/hooks/useProps.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,QAAQ,GAAI,UAAK,EAAE,aAAa,KAAG,GAe/C,CAAA;AAED,KAAK,QAAQ,GAAG,iBAAiB,GAAG,iBAAiB,GAAG,kBAAkB,GAC1D,mBAAmB,GAAG,iBAAiB,GAAG,gBAAgB,GAC1D,IAAI,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,CAAC;AAErD,UAAU,UAAU;IAChB,IAAI,CAAC,EAAE,QAAQ,GAAG,QAAQ,EAAE,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC,CAAC;IACtC,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,KAAK,OAAO,CAAC;CACnD;AAED,KAAK,UAAU,GAAG;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,GAAG,QAAQ,EAAE,GAAG,UAAU,CAAC;CACrD,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,cAAc,GAAI,OAAO,GAAG,MAC7B,SAAS,UAAU,QAyD9B,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { Element } from '../engine/reactive';
2
+ import { ComponentInstance } from '../components/DisplayObject';
3
+ export declare function useRef(element: Element<ComponentInstance>, ref: string): Element<ComponentInstance> | null;
4
+ //# sourceMappingURL=useRef.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRef.d.ts","sourceRoot":"","sources":["../../src/hooks/useRef.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAEhE,wBAAgB,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,GAAG,IAAI,CAiB1G"}