canvasengine 2.0.0-beta.24 → 2.0.0-beta.26

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 (98) hide show
  1. package/dist/DebugRenderer-C8qYAVLT.js +172 -0
  2. package/dist/DebugRenderer-C8qYAVLT.js.map +1 -0
  3. package/dist/components/Canvas.d.ts +18 -0
  4. package/dist/components/Canvas.d.ts.map +1 -0
  5. package/dist/components/Container.d.ts +79 -0
  6. package/dist/components/Container.d.ts.map +1 -0
  7. package/dist/components/DOMContainer.d.ts +76 -0
  8. package/dist/components/DOMContainer.d.ts.map +1 -0
  9. package/dist/components/DOMElement.d.ts +44 -0
  10. package/dist/components/DOMElement.d.ts.map +1 -0
  11. package/dist/components/DisplayObject.d.ts +81 -0
  12. package/dist/components/DisplayObject.d.ts.map +1 -0
  13. package/dist/components/Graphic.d.ts +65 -0
  14. package/dist/components/Graphic.d.ts.map +1 -0
  15. package/dist/components/Mesh.d.ts +201 -0
  16. package/dist/components/Mesh.d.ts.map +1 -0
  17. package/dist/components/NineSliceSprite.d.ts +17 -0
  18. package/dist/components/NineSliceSprite.d.ts.map +1 -0
  19. package/dist/components/ParticleEmitter.d.ts +5 -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/Sprite.d.ts +173 -0
  24. package/dist/components/Sprite.d.ts.map +1 -0
  25. package/dist/components/Text.d.ts +21 -0
  26. package/dist/components/Text.d.ts.map +1 -0
  27. package/dist/components/TilingSprite.d.ts +18 -0
  28. package/dist/components/TilingSprite.d.ts.map +1 -0
  29. package/dist/components/Video.d.ts +15 -0
  30. package/dist/components/Video.d.ts.map +1 -0
  31. package/dist/components/Viewport.d.ts +105 -0
  32. package/dist/components/Viewport.d.ts.map +1 -0
  33. package/dist/components/index.d.ts +16 -0
  34. package/dist/components/index.d.ts.map +1 -0
  35. package/dist/components/types/DisplayObject.d.ts +106 -0
  36. package/dist/components/types/DisplayObject.d.ts.map +1 -0
  37. package/dist/components/types/MouseEvent.d.ts +4 -0
  38. package/dist/components/types/MouseEvent.d.ts.map +1 -0
  39. package/dist/components/types/Spritesheet.d.ts +366 -0
  40. package/dist/components/types/Spritesheet.d.ts.map +1 -0
  41. package/dist/components/types/index.d.ts +5 -0
  42. package/dist/components/types/index.d.ts.map +1 -0
  43. package/dist/directives/Drag.d.ts +70 -0
  44. package/dist/directives/Drag.d.ts.map +1 -0
  45. package/dist/directives/KeyboardControls.d.ts +530 -0
  46. package/dist/directives/KeyboardControls.d.ts.map +1 -0
  47. package/dist/directives/Scheduler.d.ts +36 -0
  48. package/dist/directives/Scheduler.d.ts.map +1 -0
  49. package/dist/directives/Sound.d.ts +26 -0
  50. package/dist/directives/Sound.d.ts.map +1 -0
  51. package/dist/directives/Transition.d.ts +11 -0
  52. package/dist/directives/Transition.d.ts.map +1 -0
  53. package/dist/directives/ViewportCull.d.ts +12 -0
  54. package/dist/directives/ViewportCull.d.ts.map +1 -0
  55. package/dist/directives/ViewportFollow.d.ts +19 -0
  56. package/dist/directives/ViewportFollow.d.ts.map +1 -0
  57. package/dist/directives/index.d.ts +2 -0
  58. package/dist/directives/index.d.ts.map +1 -0
  59. package/dist/engine/animation.d.ts +59 -0
  60. package/dist/engine/animation.d.ts.map +1 -0
  61. package/dist/engine/bootstrap.d.ts +16 -0
  62. package/dist/engine/bootstrap.d.ts.map +1 -0
  63. package/dist/engine/directive.d.ts +14 -0
  64. package/dist/engine/directive.d.ts.map +1 -0
  65. package/dist/engine/reactive.d.ts +68 -0
  66. package/dist/engine/reactive.d.ts.map +1 -0
  67. package/dist/engine/signal.d.ts +72 -0
  68. package/dist/engine/signal.d.ts.map +1 -0
  69. package/dist/engine/trigger.d.ts +51 -0
  70. package/dist/engine/trigger.d.ts.map +1 -0
  71. package/dist/engine/utils.d.ts +90 -0
  72. package/dist/engine/utils.d.ts.map +1 -0
  73. package/dist/hooks/addContext.d.ts +2 -0
  74. package/dist/hooks/addContext.d.ts.map +1 -0
  75. package/dist/hooks/useProps.d.ts +42 -0
  76. package/dist/hooks/useProps.d.ts.map +1 -0
  77. package/dist/hooks/useRef.d.ts +5 -0
  78. package/dist/hooks/useRef.d.ts.map +1 -0
  79. package/dist/index-6NvvNj5_.js +10932 -0
  80. package/dist/index-6NvvNj5_.js.map +1 -0
  81. package/dist/index.d.ts +15 -1287
  82. package/dist/index.d.ts.map +1 -0
  83. package/dist/index.global.js +28 -1442
  84. package/dist/index.global.js.map +1 -1
  85. package/dist/index.js +62 -2
  86. package/dist/index.js.map +1 -1
  87. package/dist/utils/Ease.d.ts +17 -0
  88. package/dist/utils/Ease.d.ts.map +1 -0
  89. package/dist/utils/RadialGradient.d.ts +58 -0
  90. package/dist/utils/RadialGradient.d.ts.map +1 -0
  91. package/dist/utils/functions.d.ts +2 -0
  92. package/dist/utils/functions.d.ts.map +1 -0
  93. package/package.json +6 -4
  94. package/src/components/Graphic.ts +0 -3
  95. package/src/engine/bootstrap.ts +1 -0
  96. package/tsconfig.json +17 -0
  97. package/vite.config.ts +39 -0
  98. package/tsup.config.ts +0 -18
@@ -0,0 +1,59 @@
1
+ import { WritableSignal } from '@signe/reactive';
2
+
3
+ export interface AnimateOptions<T> {
4
+ duration?: number;
5
+ ease?: (t: number) => number;
6
+ onUpdate?: (value: T) => void;
7
+ onComplete?: () => void;
8
+ }
9
+ export interface AnimatedState<T> {
10
+ current: T;
11
+ start: T;
12
+ end: T;
13
+ }
14
+ export interface AnimatedSignal<T> extends Omit<WritableSignal<T>, 'set'> {
15
+ (): T;
16
+ set: (newValue: T, options?: AnimateOptions<T>) => Promise<void>;
17
+ animatedState: WritableSignal<AnimatedState<T>>;
18
+ update: (updater: (value: T) => T) => void;
19
+ }
20
+ export declare function isAnimatedSignal(signal: WritableSignal<any>): boolean;
21
+ /**
22
+ * Creates an animated signal with the given initial value and animation options.
23
+ * It's a writable signal that can be animated using popmotion. Properties of the animated signal are:
24
+ * - current: the current value of the signal.
25
+ * - start: the start value of the animation.
26
+ * - end: the end value of the animation.
27
+ *
28
+ * @param initialValue The initial value of the signal.
29
+ * @param options The animation options.
30
+ * @returns The animated signal.
31
+ * @example
32
+ * const animatedValue = animatedSignal(0, { duration: 1000 });
33
+ * animatedValue.set(10);
34
+ * animatedValue.update((value) => value + 1);
35
+ * console.log(animatedValue()); // 11
36
+ *
37
+ * animatedValue.animatedState() // { current: 10, start: 10, end: 11 }
38
+ */
39
+ export declare function animatedSignal<T>(initialValue: T, options?: AnimateOptions<T>): AnimatedSignal<T>;
40
+ /**
41
+ * Executes a sequence of animations. If an array is provided as an element in the sequence,
42
+ * those animations will be executed in parallel.
43
+ *
44
+ * @param sequence Array of animation functions or arrays of animation functions for parallel execution
45
+ * @returns Promise that resolves when all animations are complete
46
+ * @example
47
+ * ```ts
48
+ * await animatedSequence([
49
+ * () => value1.set(10),
50
+ * [
51
+ * () => value2.set(20),
52
+ * () => value3.set(30)
53
+ * ],
54
+ * () => value1.set(0)
55
+ * ])
56
+ * ```
57
+ */
58
+ export declare function animatedSequence(sequence: ((() => Promise<void>) | (() => Promise<void>)[])[]): Promise<void>;
59
+ //# 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,MAAM,iBAAiB,CAAC;AAGtE,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;CACzB;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;CAC5C;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,CAAC,GAAG,OAAO,CAErE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,OAAO,GAAE,cAAc,CAAC,CAAC,CAAM,GAAG,cAAc,CAAC,CAAC,CAAC,CA2ErG;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,16 @@
1
+ import { Application, ApplicationOptions } from 'pixi.js';
2
+ import { ComponentFunction } from './signal';
3
+
4
+ /**
5
+ * Bootstraps a canvas element and renders it to the DOM.
6
+ *
7
+ * @param rootElement - The HTML element where the canvas will be rendered. Can be null.
8
+ * @param canvas - A Promise that resolves to an Element representing the canvas component.
9
+ * @returns A Promise that resolves to the rendered canvas element.
10
+ * @throws {Error} If the provided element is not a Canvas component.
11
+ */
12
+ export declare const bootstrapCanvas: (rootElement: HTMLElement | null, canvas: ComponentFunction<any>, options?: ApplicationOptions) => Promise<{
13
+ canvasElement: import('./reactive').Element<import('..').ComponentInstance>;
14
+ app: Application<import('pixi.js').Renderer>;
15
+ }>;
16
+ //# 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,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAK,MAAM,UAAU,CAAC;AAGhD;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,GAAU,aAAa,WAAW,GAAG,IAAI,EAAE,QAAQ,iBAAiB,CAAC,GAAG,CAAC,EAAE,UAAU,kBAAkB;;;EAyBlI,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { Element } from './reactive';
2
+
3
+ export declare const directives: {
4
+ [key: string]: any;
5
+ };
6
+ export declare abstract class Directive {
7
+ abstract onDestroy(element: Element<any>): any;
8
+ abstract onInit(element: Element<any>): any;
9
+ abstract onMount(element: Element<any>): any;
10
+ abstract onUpdate(props: any, element: Element<any>): any;
11
+ }
12
+ export declare function registerDirective(name: string, directive: any): void;
13
+ export declare function applyDirective(element: Element, directiveName: string): any;
14
+ //# 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,EAAE,aAAa,EAAE,MAAM,OAOrE"}
@@ -0,0 +1,68 @@
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
+
6
+ export interface Props {
7
+ [key: string]: any;
8
+ }
9
+ type NestedSignalObjects = {
10
+ [Key in string]: NestedSignalObjects | Signal<any>;
11
+ };
12
+ export interface Element<T = ComponentInstance> {
13
+ tag: string;
14
+ props: Props;
15
+ componentInstance: T;
16
+ propSubscriptions: Subscription[];
17
+ effectSubscriptions: Subscription[];
18
+ effectMounts: (() => void)[];
19
+ effectUnmounts: ((element?: Element) => void)[];
20
+ propObservables: NestedSignalObjects | undefined;
21
+ parent: Element | null;
22
+ context?: {
23
+ [key: string]: any;
24
+ };
25
+ directives: {
26
+ [key: string]: Directive;
27
+ };
28
+ destroy: () => void;
29
+ allElements: Subject<void>;
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
+ * Creates a virtual element or a representation thereof, with properties that can be dynamically updated based on BehaviorSubjects.
42
+ *
43
+ * @param {string} tag - The tag name of the element to create.
44
+ * @param {Object} props - An object containing properties for the element. Each property can either be a direct value
45
+ * or an array where the first element is a function that returns a value based on input parameters,
46
+ * and the second element is an array of BehaviorSubjects. The property is updated dynamically
47
+ * using the combineLatest RxJS operator to wait for all BehaviorSubjects to emit.
48
+ * @returns {Object} An object representing the created element, including tag name and dynamic properties.
49
+ */
50
+ export declare function createComponent(tag: string, props?: Props): Element;
51
+ /**
52
+ * Observes a BehaviorSubject containing an array or object of items and dynamically creates child elements for each item.
53
+ *
54
+ * @param {WritableArraySignal<T> | WritableObjectSignal<T>} itemsSubject - A signal that emits an array or object of items.
55
+ * @param {Function} createElementFn - A function that takes an item and returns an element representation.
56
+ * @returns {Observable} An observable that emits the list of created child elements.
57
+ */
58
+ export declare function loop<T>(itemsSubject: any, createElementFn: (item: T, index: number | string) => Element | null): FlowObservable;
59
+ /**
60
+ * Conditionally creates and destroys elements based on a condition signal.
61
+ *
62
+ * @param {Signal<boolean> | boolean} condition - A signal or boolean that determines whether to create an element.
63
+ * @param {Function} createElementFn - A function that returns an element or a promise that resolves to an element.
64
+ * @returns {Observable} An observable that emits the created or destroyed element.
65
+ */
66
+ export declare function cond(condition: Signal<boolean> | boolean, createElementFn: () => Element | Promise<Element>): FlowObservable;
67
+ export {};
68
+ //# 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,EAA2E,MAAM,iBAAiB,CAAC;AAC7I,OAAO,EACL,UAAU,EACV,OAAO,EACP,YAAY,EAOb,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAkB,MAAM,aAAa,CAAC;AAGxD,MAAM,WAAW,KAAK;IACpB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,KAAK,mBAAmB,GAAG;KACxB,GAAG,IAAI,MAAM,GAAG,mBAAmB,GAAG,MAAM,CAAC,GAAG,CAAC;CACnD,CAAC;AAEF,MAAM,WAAW,OAAO,CAAC,CAAC,GAAG,iBAAiB;IAC5C,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,KAAK,CAAC;IACb,iBAAiB,EAAE,CAAC,CAAC;IACrB,iBAAiB,EAAE,YAAY,EAAE,CAAC;IAClC,mBAAmB,EAAE,YAAY,EAAE,CAAC;IACpC,YAAY,EAAE,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;IAC7B,cAAc,EAAE,CAAC,CAAC,OAAO,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC,EAAE,CAAC;IAChD,eAAe,EAAE,mBAAmB,GAAG,SAAS,CAAC;IACjD,MAAM,EAAE,OAAO,GAAG,IAAI,CAAC;IACvB,OAAO,CAAC,EAAE;QACR,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;IACF,UAAU,EAAE;QACV,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;KAC1B,CAAC;IACF,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B;AAED,KAAK,UAAU,GAAG;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,EAAE,CAAC;CAC1B,CAAC;AAEF,KAAK,cAAc,GAAG,UAAU,CAAC,UAAU,CAAC,CAAC;AAI7C,eAAO,MAAM,SAAS,GAAI,OAAO,GAAG,KAAG,KAAK,IAAI,OAQ/C,CAAC;AAEF,eAAO,MAAM,WAAW,GAAI,UAAK,YAQhC,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,IAAI,KAAA,EAAE,SAAS,KAAA,QAEhD;AAgCD;;;;;;;;;GASG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,KAAK,GAAG,OAAO,CAkLnE;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,CAAC,EACpB,YAAY,EAAE,GAAG,EACjB,eAAe,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,KAAK,OAAO,GAAG,IAAI,GACnE,cAAc,CAsLhB;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAClB,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,OAAO,EACpC,eAAe,EAAE,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,GAChD,cAAc,CAyDhB"}
@@ -0,0 +1,72 @@
1
+ import { Subscription } from 'rxjs';
2
+ import { Element } from './reactive';
3
+ import { Tick } from '../directives/Scheduler';
4
+
5
+ type MountFunction = (fn: (element: Element) => void) => void;
6
+ export type ComponentFunction<P = {}> = (props: P) => Element | Promise<Element>;
7
+ export declare let currentSubscriptionsTracker: ((subscription: Subscription) => void) | null;
8
+ export declare let mountTracker: MountFunction | null;
9
+ /**
10
+ * Registers a mount function to be called when the component is mounted.
11
+ * To unmount the component, the function must return a function that will be called by the engine.
12
+ *
13
+ * @param {(element: Element) => void} fn - The function to be called on mount.
14
+ * @example
15
+ * ```ts
16
+ * mount((el) => {
17
+ * console.log('mounted', el);
18
+ * });
19
+ * ```
20
+ * Unmount the component by returning a function:
21
+ * ```ts
22
+ * mount((el) => {
23
+ * console.log('mounted', el);
24
+ * return () => {
25
+ * console.log('unmounted', el);
26
+ * }
27
+ * });
28
+ * ```
29
+ */
30
+ export declare function mount(fn: (element: Element) => void): void;
31
+ /**
32
+ * Registers a tick function to be called on each tick of the component's context.
33
+ * @param {(tickValue: Tick, element: Element) => void} fn - The function to be called on each tick.
34
+ * @example
35
+ * ```ts
36
+ * tick((tickValue, el) => {
37
+ * console.log('tick', tickValue, el);
38
+ * });
39
+ * ```
40
+ */
41
+ export declare function tick(fn: (tickValue: Tick, element: Element) => void): void;
42
+ /**
43
+ * Add tracking for subscriptions and mounts, then create an element from a component function.
44
+ * @template C
45
+ * @param {C} componentFunction - The component function to create an element from.
46
+ * @param {Parameters<C>[0]} [props={}] - The props to pass to the component function.
47
+ * @param {...any[]} children - The children elements of the component.
48
+ * @returns {ReturnType<C>}
49
+ * @example
50
+ * ```ts
51
+ * const el = h(MyComponent, {
52
+ * x: 100,
53
+ * y: 100,
54
+ * });
55
+ * ```
56
+ *
57
+ * with children:
58
+ * ```ts
59
+ * const el = h(MyComponent, {
60
+ * x: 100,
61
+ * y: 100,
62
+ * },
63
+ * h(MyChildComponent, {
64
+ * x: 50,
65
+ * y: 50,
66
+ * }),
67
+ * );
68
+ * ```
69
+ */
70
+ export declare function h<C extends ComponentFunction<any>>(componentFunction: C, props?: Parameters<C>[0], ...children: any[]): ReturnType<C>;
71
+ export {};
72
+ //# 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,EACH,YAAY,EACf,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAE/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,QAanE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,CAAC,CAAC,CAAC,SAAS,iBAAiB,CAAC,GAAG,CAAC,EAChD,iBAAiB,EAAE,CAAC,EACpB,KAAK,GAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAA0B,EAChD,GAAG,QAAQ,EAAE,GAAG,EAAE,GACjB,UAAU,CAAC,CAAC,CAAC,CAyCf"}
@@ -0,0 +1,51 @@
1
+ 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
+ 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
+ * @throws Error if triggerSignal is not a valid trigger
40
+ * @example
41
+ * ```ts
42
+ * const click = trigger()
43
+ *
44
+ * on(click, () => {
45
+ * console.log('Click triggered')
46
+ * })
47
+ * ```
48
+ */
49
+ export declare function on(triggerSignal: any, callback: (config: any) => void | Promise<void>): void;
50
+ export {};
51
+ //# sourceMappingURL=trigger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trigger.d.ts","sourceRoot":"","sources":["../../src/engine/trigger.ts"],"names":[],"mappings":"AAEA,UAAU,MAAM,CAAC,CAAC,GAAG,GAAG;IACtB,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,UAAU,OAAO,CAAC,CAAC,GAAG,GAAG;IACvB,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,CA0B7D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,EAAE,CAAC,aAAa,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,QAarF"}
@@ -0,0 +1,90 @@
1
+ import { ObservablePoint } from 'pixi.js';
2
+
3
+ /**
4
+ * Checks if code is running in a browser environment
5
+ * @returns {boolean} True if running in browser, false otherwise
6
+ */
7
+ export declare function isBrowser(): boolean;
8
+ /**
9
+ * Returns current high-resolution timestamp
10
+ * @returns {number} Current time in milliseconds
11
+ */
12
+ export declare function preciseNow(): number;
13
+ /**
14
+ * Converts frames per second to milliseconds
15
+ * @param {number} fps - Frames per second
16
+ * @returns {number} Milliseconds per frame
17
+ */
18
+ export declare function fps2ms(fps: number): number;
19
+ /**
20
+ * Checks if a value is a Promise
21
+ * @param {any} value - Value to check
22
+ * @returns {boolean} True if value is a Promise, false otherwise
23
+ */
24
+ export declare function isPromise(value: any): boolean;
25
+ export declare function arrayEquals(a: any[], b: any[]): boolean;
26
+ /**
27
+ * Checks if a value is a function
28
+ * @param {unknown} val - Value to check
29
+ * @returns {boolean} True if value is a function, false otherwise
30
+ */
31
+ export declare function isFunction(val: unknown): boolean;
32
+ /**
33
+ * Checks if a value is a plain object (not an instance of a class)
34
+ * @param {unknown} val - Value to check
35
+ * @returns {boolean} True if value is a plain object (not null, not array, not instance), false otherwise
36
+ * @example
37
+ * ```ts
38
+ * isObject({}) // true
39
+ * isObject(new Date()) // false
40
+ * isObject([]) // false
41
+ * isObject(null) // false
42
+ * ```
43
+ */
44
+ export declare function isObject(val: unknown): boolean;
45
+ export declare function isObservable(val: unknown): boolean;
46
+ /**
47
+ * Sets a value in an object using a dot notation path
48
+ * @param {Record<string, any>} obj - Target object
49
+ * @param {string | string[]} path - Path to set value at (e.g., 'a.b.c' or ['a', 'b', 'c'])
50
+ * @param {any} value - Value to set
51
+ * @param {boolean} onlyPlainObject - If true, only creates plain objects in path
52
+ * @returns {Record<string, any>} Modified object
53
+ */
54
+ export declare function set(obj: Record<string, any>, path: string | string[], value: any, onlyPlainObject?: boolean): Record<string, any>;
55
+ /**
56
+ * Gets a value from an object using a dot notation path
57
+ * @param {Record<string, any>} obj - Source object
58
+ * @param {string} path - Path to get value from (e.g., 'a.b.c')
59
+ * @returns {any} Value at path or undefined if not found
60
+ */
61
+ export declare function get(obj: Record<string, any>, path: string): any;
62
+ /**
63
+ * Logs a message to console
64
+ * @param {any} text - Message to log
65
+ */
66
+ export declare function log(text: any): void;
67
+ /**
68
+ * Logs an error message to console
69
+ * @param {any} text - Error message to log
70
+ */
71
+ export declare function error(text: any): void;
72
+ /**
73
+ * Sets the position of an ObservablePoint using various input formats
74
+ * @param {ObservablePoint} observablePoint - The point to modify
75
+ * @param {Object | number | [number, number]} point - New position value
76
+ */
77
+ export declare function setObservablePoint(observablePoint: ObservablePoint, point: {
78
+ x: number;
79
+ y: number;
80
+ } | number | [number, number]): void;
81
+ /**
82
+ * Calculates the Euclidean distance between two points
83
+ * @param {number} x1 - X coordinate of first point
84
+ * @param {number} y1 - Y coordinate of first point
85
+ * @param {number} x2 - X coordinate of second point
86
+ * @param {number} y2 - Y coordinate of second point
87
+ * @returns {number} Distance between the points
88
+ */
89
+ export declare function calculateDistance(x1: number, y1: number, x2: number, y2: number): number;
90
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/engine/utils.ts"],"names":[],"mappings":"AAAA,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,CAUN;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,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,5 @@
1
+ import { Element } from '../engine/reactive';
2
+ import { ComponentInstance } from '../components/DisplayObject';
3
+
4
+ export declare function useRef(element: Element<ComponentInstance>, ref: string): Element<ComponentInstance> | null;
5
+ //# 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"}