canvasengine 2.0.0-beta.6 → 2.0.0-beta.60

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 (164) hide show
  1. package/dist/DebugRenderer-DkjTAc48.js +1384 -0
  2. package/dist/DebugRenderer-DkjTAc48.js.map +1 -0
  3. package/dist/components/Button.d.ts +185 -0
  4. package/dist/components/Button.d.ts.map +1 -0
  5. package/dist/components/Canvas.d.ts +17 -0
  6. package/dist/components/Canvas.d.ts.map +1 -0
  7. package/dist/components/DOMElement.d.ts +54 -0
  8. package/dist/components/DOMElement.d.ts.map +1 -0
  9. package/dist/components/DOMSprite.d.ts +127 -0
  10. package/dist/components/DOMSprite.d.ts.map +1 -0
  11. package/dist/components/FocusContainer.d.ts +129 -0
  12. package/dist/components/FocusContainer.d.ts.map +1 -0
  13. package/dist/components/Graphic.d.ts +64 -0
  14. package/dist/components/Graphic.d.ts.map +1 -0
  15. package/dist/components/Joystick.d.ts +36 -0
  16. package/dist/components/Joystick.d.ts.map +1 -0
  17. package/dist/components/NineSliceSprite.d.ts +16 -0
  18. package/dist/components/NineSliceSprite.d.ts.map +1 -0
  19. package/dist/components/ParticleEmitter.d.ts +4 -0
  20. package/dist/components/ParticleEmitter.d.ts.map +1 -0
  21. package/dist/components/Scene.d.ts +2 -0
  22. package/dist/components/Scene.d.ts.map +1 -0
  23. package/dist/components/Text.d.ts +25 -0
  24. package/dist/components/Text.d.ts.map +1 -0
  25. package/dist/components/TilingSprite.d.ts +17 -0
  26. package/dist/components/TilingSprite.d.ts.map +1 -0
  27. package/dist/components/Video.d.ts +14 -0
  28. package/dist/components/Video.d.ts.map +1 -0
  29. package/dist/components/index.d.ts +20 -0
  30. package/dist/components/index.d.ts.map +1 -0
  31. package/dist/components/types/DisplayObject.d.ts +118 -0
  32. package/dist/components/types/DisplayObject.d.ts.map +1 -0
  33. package/dist/components/types/MouseEvent.d.ts +4 -0
  34. package/dist/components/types/MouseEvent.d.ts.map +1 -0
  35. package/dist/components/types/Spritesheet.d.ts +248 -0
  36. package/dist/components/types/Spritesheet.d.ts.map +1 -0
  37. package/dist/components/types/index.d.ts +4 -0
  38. package/dist/components/types/index.d.ts.map +1 -0
  39. package/dist/directives/Controls.d.ts +112 -0
  40. package/dist/directives/Controls.d.ts.map +1 -0
  41. package/dist/directives/ControlsBase.d.ts +199 -0
  42. package/dist/directives/ControlsBase.d.ts.map +1 -0
  43. package/dist/directives/Drag.d.ts +69 -0
  44. package/dist/directives/Drag.d.ts.map +1 -0
  45. package/dist/directives/Flash.d.ts +116 -0
  46. package/dist/directives/Flash.d.ts.map +1 -0
  47. package/dist/directives/FocusNavigation.d.ts +52 -0
  48. package/dist/directives/FocusNavigation.d.ts.map +1 -0
  49. package/dist/directives/FogVisibility.d.ts +47 -0
  50. package/dist/directives/FogVisibility.d.ts.map +1 -0
  51. package/dist/directives/GamepadControls.d.ts +224 -0
  52. package/dist/directives/GamepadControls.d.ts.map +1 -0
  53. package/dist/directives/JoystickControls.d.ts +171 -0
  54. package/dist/directives/JoystickControls.d.ts.map +1 -0
  55. package/dist/directives/KeyboardControls.d.ts +219 -0
  56. package/dist/directives/KeyboardControls.d.ts.map +1 -0
  57. package/dist/directives/Scheduler.d.ts +35 -0
  58. package/dist/directives/Scheduler.d.ts.map +1 -0
  59. package/dist/directives/Shake.d.ts +98 -0
  60. package/dist/directives/Shake.d.ts.map +1 -0
  61. package/dist/directives/Sound.d.ts +25 -0
  62. package/dist/directives/Sound.d.ts.map +1 -0
  63. package/dist/directives/Transition.d.ts +10 -0
  64. package/dist/directives/Transition.d.ts.map +1 -0
  65. package/dist/directives/ViewportCull.d.ts +11 -0
  66. package/dist/directives/ViewportCull.d.ts.map +1 -0
  67. package/dist/directives/ViewportFollow.d.ts +18 -0
  68. package/dist/directives/ViewportFollow.d.ts.map +1 -0
  69. package/dist/directives/index.d.ts +14 -0
  70. package/dist/directives/index.d.ts.map +1 -0
  71. package/dist/dist-BOOc43Qm.js +778 -0
  72. package/dist/dist-BOOc43Qm.js.map +1 -0
  73. package/dist/engine/FocusManager.d.ts +174 -0
  74. package/dist/engine/FocusManager.d.ts.map +1 -0
  75. package/dist/engine/animation.d.ts +72 -0
  76. package/dist/engine/animation.d.ts.map +1 -0
  77. package/dist/engine/bootstrap.d.ts +48 -0
  78. package/dist/engine/bootstrap.d.ts.map +1 -0
  79. package/dist/engine/directive.d.ts +13 -0
  80. package/dist/engine/directive.d.ts.map +1 -0
  81. package/dist/engine/reactive.d.ts +134 -0
  82. package/dist/engine/reactive.d.ts.map +1 -0
  83. package/dist/engine/signal.d.ts +71 -0
  84. package/dist/engine/signal.d.ts.map +1 -0
  85. package/dist/engine/trigger.d.ts +54 -0
  86. package/dist/engine/trigger.d.ts.map +1 -0
  87. package/dist/engine/utils.d.ts +89 -0
  88. package/dist/engine/utils.d.ts.map +1 -0
  89. package/dist/hooks/addContext.d.ts +2 -0
  90. package/dist/hooks/addContext.d.ts.map +1 -0
  91. package/dist/hooks/useFocus.d.ts +60 -0
  92. package/dist/hooks/useFocus.d.ts.map +1 -0
  93. package/dist/hooks/useProps.d.ts +42 -0
  94. package/dist/hooks/useProps.d.ts.map +1 -0
  95. package/dist/hooks/useRef.d.ts +4 -0
  96. package/dist/hooks/useRef.d.ts.map +1 -0
  97. package/dist/index.d.ts +19 -1107
  98. package/dist/index.d.ts.map +1 -0
  99. package/dist/index.global.js +5 -0
  100. package/dist/index.global.js.map +1 -0
  101. package/dist/index.js +9768 -3135
  102. package/dist/index.js.map +1 -1
  103. package/dist/utils/Ease.d.ts +17 -0
  104. package/dist/utils/Ease.d.ts.map +1 -0
  105. package/dist/utils/GlobalAssetLoader.d.ts +141 -0
  106. package/dist/utils/GlobalAssetLoader.d.ts.map +1 -0
  107. package/dist/utils/RadialGradient.d.ts +57 -0
  108. package/dist/utils/RadialGradient.d.ts.map +1 -0
  109. package/dist/utils/functions.d.ts +2 -0
  110. package/dist/utils/functions.d.ts.map +1 -0
  111. package/dist/utils/tabindex.d.ts +16 -0
  112. package/dist/utils/tabindex.d.ts.map +1 -0
  113. package/package.json +15 -9
  114. package/src/components/Button.ts +399 -0
  115. package/src/components/Canvas.ts +62 -46
  116. package/src/components/Container.ts +21 -2
  117. package/src/components/DOMContainer.ts +379 -0
  118. package/src/components/DOMElement.ts +556 -0
  119. package/src/components/DOMSprite.ts +1040 -0
  120. package/src/components/DisplayObject.ts +419 -201
  121. package/src/components/FocusContainer.ts +368 -0
  122. package/src/components/Graphic.ts +227 -66
  123. package/src/components/Joystick.ts +363 -0
  124. package/src/components/Mesh.ts +222 -0
  125. package/src/components/NineSliceSprite.ts +4 -1
  126. package/src/components/ParticleEmitter.ts +12 -8
  127. package/src/components/Sprite.ts +418 -52
  128. package/src/components/Text.ts +125 -18
  129. package/src/components/Viewport.ts +122 -63
  130. package/src/components/index.ts +9 -2
  131. package/src/components/types/DisplayObject.ts +53 -5
  132. package/src/components/types/Spritesheet.ts +0 -118
  133. package/src/directives/Controls.ts +254 -0
  134. package/src/directives/ControlsBase.ts +267 -0
  135. package/src/directives/Drag.ts +357 -52
  136. package/src/directives/Flash.ts +419 -0
  137. package/src/directives/FocusNavigation.ts +113 -0
  138. package/src/directives/FogVisibility.ts +273 -0
  139. package/src/directives/GamepadControls.ts +537 -0
  140. package/src/directives/JoystickControls.ts +396 -0
  141. package/src/directives/KeyboardControls.ts +85 -430
  142. package/src/directives/Scheduler.ts +12 -4
  143. package/src/directives/Shake.ts +298 -0
  144. package/src/directives/Sound.ts +94 -31
  145. package/src/directives/ViewportFollow.ts +40 -9
  146. package/src/directives/index.ts +13 -6
  147. package/src/engine/FocusManager.ts +510 -0
  148. package/src/engine/animation.ts +175 -21
  149. package/src/engine/bootstrap.ts +93 -3
  150. package/src/engine/directive.ts +4 -4
  151. package/src/engine/reactive.ts +979 -176
  152. package/src/engine/signal.ts +113 -25
  153. package/src/engine/trigger.ts +34 -7
  154. package/src/engine/utils.ts +19 -3
  155. package/src/hooks/useFocus.ts +91 -0
  156. package/src/hooks/useProps.ts +1 -1
  157. package/src/index.ts +8 -2
  158. package/src/types/pixi-cull.d.ts +7 -0
  159. package/src/utils/GlobalAssetLoader.ts +257 -0
  160. package/src/utils/functions.ts +7 -0
  161. package/src/utils/tabindex.ts +70 -0
  162. package/testing/index.ts +35 -4
  163. package/tsconfig.json +18 -0
  164. package/vite.config.ts +39 -0
@@ -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":"AAAA,OAAO,EAA6B,MAAM,EAAqF,MAAM,iBAAiB,CAAC;AAEvJ,OAAO,EACL,UAAU,EACV,OAAO,EACP,YAAY,EAcb,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,iBAAiB,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AAC,CAAC,CAClF,GACA,cAAc,CA4IhB"}
@@ -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"}