canvasengine 2.0.0-beta.4 → 2.0.0-beta.40
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.
- package/dist/DebugRenderer-DgECR3yZ.js +172 -0
- package/dist/DebugRenderer-DgECR3yZ.js.map +1 -0
- package/dist/components/Button.d.ts +183 -0
- package/dist/components/Button.d.ts.map +1 -0
- package/dist/components/Canvas.d.ts +18 -0
- package/dist/components/Canvas.d.ts.map +1 -0
- package/dist/components/DOMElement.d.ts +44 -0
- package/dist/components/DOMElement.d.ts.map +1 -0
- package/dist/components/Graphic.d.ts +65 -0
- package/dist/components/Graphic.d.ts.map +1 -0
- package/dist/components/Joystick.d.ts +36 -0
- package/dist/components/Joystick.d.ts.map +1 -0
- package/dist/components/NineSliceSprite.d.ts +17 -0
- package/dist/components/NineSliceSprite.d.ts.map +1 -0
- package/dist/components/ParticleEmitter.d.ts +5 -0
- package/dist/components/ParticleEmitter.d.ts.map +1 -0
- package/dist/components/Scene.d.ts +2 -0
- package/dist/components/Scene.d.ts.map +1 -0
- package/dist/components/Text.d.ts +26 -0
- package/dist/components/Text.d.ts.map +1 -0
- package/dist/components/TilingSprite.d.ts +18 -0
- package/dist/components/TilingSprite.d.ts.map +1 -0
- package/dist/components/Video.d.ts +15 -0
- package/dist/components/Video.d.ts.map +1 -0
- package/dist/components/index.d.ts +18 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/types/DisplayObject.d.ts +110 -0
- package/dist/components/types/DisplayObject.d.ts.map +1 -0
- package/dist/components/types/MouseEvent.d.ts +4 -0
- package/dist/components/types/MouseEvent.d.ts.map +1 -0
- package/dist/components/types/Spritesheet.d.ts +248 -0
- package/dist/components/types/Spritesheet.d.ts.map +1 -0
- package/dist/components/types/index.d.ts +5 -0
- package/dist/components/types/index.d.ts.map +1 -0
- package/dist/directives/Controls.d.ts +113 -0
- package/dist/directives/Controls.d.ts.map +1 -0
- package/dist/directives/ControlsBase.d.ts +198 -0
- package/dist/directives/ControlsBase.d.ts.map +1 -0
- package/dist/directives/Drag.d.ts +70 -0
- package/dist/directives/Drag.d.ts.map +1 -0
- package/dist/directives/Flash.d.ts +117 -0
- package/dist/directives/Flash.d.ts.map +1 -0
- package/dist/directives/GamepadControls.d.ts +225 -0
- package/dist/directives/GamepadControls.d.ts.map +1 -0
- package/dist/directives/JoystickControls.d.ts +172 -0
- package/dist/directives/JoystickControls.d.ts.map +1 -0
- package/dist/directives/KeyboardControls.d.ts +219 -0
- package/dist/directives/KeyboardControls.d.ts.map +1 -0
- package/dist/directives/Scheduler.d.ts +36 -0
- package/dist/directives/Scheduler.d.ts.map +1 -0
- package/dist/directives/Shake.d.ts +98 -0
- package/dist/directives/Shake.d.ts.map +1 -0
- package/dist/directives/Sound.d.ts +26 -0
- package/dist/directives/Sound.d.ts.map +1 -0
- package/dist/directives/Transition.d.ts +11 -0
- package/dist/directives/Transition.d.ts.map +1 -0
- package/dist/directives/ViewportCull.d.ts +12 -0
- package/dist/directives/ViewportCull.d.ts.map +1 -0
- package/dist/directives/ViewportFollow.d.ts +19 -0
- package/dist/directives/ViewportFollow.d.ts.map +1 -0
- package/dist/directives/index.d.ts +13 -0
- package/dist/directives/index.d.ts.map +1 -0
- package/dist/engine/animation.d.ts +73 -0
- package/dist/engine/animation.d.ts.map +1 -0
- package/dist/engine/bootstrap.d.ts +16 -0
- package/dist/engine/bootstrap.d.ts.map +1 -0
- package/dist/engine/directive.d.ts +14 -0
- package/dist/engine/directive.d.ts.map +1 -0
- package/dist/engine/reactive.d.ts +105 -0
- package/dist/engine/reactive.d.ts.map +1 -0
- package/dist/engine/signal.d.ts +72 -0
- package/dist/engine/signal.d.ts.map +1 -0
- package/dist/engine/trigger.d.ts +50 -0
- package/dist/engine/trigger.d.ts.map +1 -0
- package/dist/engine/utils.d.ts +90 -0
- package/dist/engine/utils.d.ts.map +1 -0
- package/dist/hooks/addContext.d.ts +2 -0
- package/dist/hooks/addContext.d.ts.map +1 -0
- package/dist/hooks/useProps.d.ts +42 -0
- package/dist/hooks/useProps.d.ts.map +1 -0
- package/dist/hooks/useRef.d.ts +5 -0
- package/dist/hooks/useRef.d.ts.map +1 -0
- package/dist/index-gb763Hyx.js +12560 -0
- package/dist/index-gb763Hyx.js.map +1 -0
- package/dist/index.d.ts +15 -1083
- package/dist/index.d.ts.map +1 -0
- package/dist/index.global.js +29 -0
- package/dist/index.global.js.map +1 -0
- package/dist/index.js +81 -3041
- package/dist/index.js.map +1 -1
- package/dist/utils/Ease.d.ts +17 -0
- package/dist/utils/Ease.d.ts.map +1 -0
- package/dist/utils/GlobalAssetLoader.d.ts +141 -0
- package/dist/utils/GlobalAssetLoader.d.ts.map +1 -0
- package/dist/utils/RadialGradient.d.ts +58 -0
- package/dist/utils/RadialGradient.d.ts.map +1 -0
- package/dist/utils/functions.d.ts +2 -0
- package/dist/utils/functions.d.ts.map +1 -0
- package/package.json +13 -7
- package/src/components/Button.ts +396 -0
- package/src/components/Canvas.ts +61 -45
- package/src/components/Container.ts +21 -2
- package/src/components/DOMContainer.ts +123 -0
- package/src/components/DOMElement.ts +421 -0
- package/src/components/DisplayObject.ts +350 -197
- package/src/components/Graphic.ts +200 -34
- package/src/components/Joystick.ts +361 -0
- package/src/components/Mesh.ts +222 -0
- package/src/components/NineSliceSprite.ts +4 -1
- package/src/components/ParticleEmitter.ts +12 -8
- package/src/components/Sprite.ts +306 -30
- package/src/components/Text.ts +125 -18
- package/src/components/Video.ts +110 -0
- package/src/components/Viewport.ts +59 -43
- package/src/components/index.ts +8 -2
- package/src/components/types/DisplayObject.ts +34 -0
- package/src/components/types/Spritesheet.ts +0 -118
- package/src/directives/Controls.ts +254 -0
- package/src/directives/ControlsBase.ts +266 -0
- package/src/directives/Drag.ts +357 -52
- package/src/directives/Flash.ts +409 -0
- package/src/directives/GamepadControls.ts +537 -0
- package/src/directives/JoystickControls.ts +396 -0
- package/src/directives/KeyboardControls.ts +66 -424
- package/src/directives/Shake.ts +282 -0
- package/src/directives/Sound.ts +94 -31
- package/src/directives/ViewportFollow.ts +35 -7
- package/src/directives/index.ts +12 -6
- package/src/engine/animation.ts +175 -21
- package/src/engine/bootstrap.ts +23 -3
- package/src/engine/directive.ts +2 -2
- package/src/engine/reactive.ts +780 -177
- package/src/engine/signal.ts +35 -4
- package/src/engine/trigger.ts +21 -4
- package/src/engine/utils.ts +19 -3
- package/src/hooks/useProps.ts +1 -1
- package/src/index.ts +4 -2
- package/src/utils/GlobalAssetLoader.ts +257 -0
- package/src/utils/functions.ts +7 -0
- package/testing/index.ts +12 -0
- package/tsconfig.json +17 -0
- package/vite.config.ts +39 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { WritableSignal, Signal } from '@signe/reactive';
|
|
2
|
+
import { Tick } from '../directives/Scheduler';
|
|
3
|
+
|
|
4
|
+
export interface AnimateOptions<T> {
|
|
5
|
+
duration?: number;
|
|
6
|
+
ease?: (t: number) => number;
|
|
7
|
+
onUpdate?: (value: T) => void;
|
|
8
|
+
onComplete?: () => void;
|
|
9
|
+
tick?: Signal<Tick>;
|
|
10
|
+
}
|
|
11
|
+
export interface AnimatedState<T> {
|
|
12
|
+
current: T;
|
|
13
|
+
start: T;
|
|
14
|
+
end: T;
|
|
15
|
+
}
|
|
16
|
+
export interface AnimatedSignal<T> extends Omit<WritableSignal<T>, 'set'> {
|
|
17
|
+
(): T;
|
|
18
|
+
set: (newValue: T, options?: AnimateOptions<T>) => Promise<void>;
|
|
19
|
+
animatedState: WritableSignal<AnimatedState<T>>;
|
|
20
|
+
update: (updater: (value: T) => T) => void;
|
|
21
|
+
pause: () => void;
|
|
22
|
+
resume: () => void;
|
|
23
|
+
}
|
|
24
|
+
export declare function isAnimatedSignal(signal: WritableSignal<any>): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Creates an animated signal with the given initial value and animation options.
|
|
27
|
+
* It's a writable signal that can be animated using popmotion. Properties of the animated signal are:
|
|
28
|
+
* - current: the current value of the signal.
|
|
29
|
+
* - start: the start value of the animation.
|
|
30
|
+
* - end: the end value of the animation.
|
|
31
|
+
*
|
|
32
|
+
* If a tick signal is provided in options, the animation will use the engine's tick system.
|
|
33
|
+
* Otherwise, it will automatically use the global tick signal from the Canvas context if available.
|
|
34
|
+
* If no tick signal is available, it will use requestAnimationFrame by default.
|
|
35
|
+
*
|
|
36
|
+
* @param initialValue The initial value of the signal.
|
|
37
|
+
* @param options The animation options. Can include a `tick` signal to use a specific tick system.
|
|
38
|
+
* @returns The animated signal.
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* // Automatically uses the Canvas tick system if available, otherwise requestAnimationFrame
|
|
42
|
+
* const animatedValue = animatedSignal(0, { duration: 1000 });
|
|
43
|
+
* animatedValue.set(10);
|
|
44
|
+
*
|
|
45
|
+
* // Explicitly using a specific tick signal
|
|
46
|
+
* mount((element) => {
|
|
47
|
+
* const tickSignal = element.props.context.tick;
|
|
48
|
+
* const animatedValue = animatedSignal(0, { duration: 1000, tick: tickSignal });
|
|
49
|
+
* animatedValue.set(10);
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export declare function animatedSignal<T>(initialValue: T, options?: AnimateOptions<T>): AnimatedSignal<T>;
|
|
54
|
+
/**
|
|
55
|
+
* Executes a sequence of animations. If an array is provided as an element in the sequence,
|
|
56
|
+
* those animations will be executed in parallel.
|
|
57
|
+
*
|
|
58
|
+
* @param sequence Array of animation functions or arrays of animation functions for parallel execution
|
|
59
|
+
* @returns Promise that resolves when all animations are complete
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* await animatedSequence([
|
|
63
|
+
* () => value1.set(10),
|
|
64
|
+
* [
|
|
65
|
+
* () => value2.set(20),
|
|
66
|
+
* () => value3.set(30)
|
|
67
|
+
* ],
|
|
68
|
+
* () => value1.set(0)
|
|
69
|
+
* ])
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare function animatedSequence(sequence: ((() => Promise<void>) | (() => Promise<void>)[])[]): Promise<void>;
|
|
73
|
+
//# 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,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,105 @@
|
|
|
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
|
+
isFrozen: boolean;
|
|
31
|
+
}
|
|
32
|
+
type FlowResult = {
|
|
33
|
+
elements: Element[];
|
|
34
|
+
prev?: Element;
|
|
35
|
+
fullElements?: Element[];
|
|
36
|
+
};
|
|
37
|
+
type FlowObservable = Observable<FlowResult>;
|
|
38
|
+
export declare const isElement: (value: any) => value is Element;
|
|
39
|
+
export declare const isPrimitive: (value: any) => boolean;
|
|
40
|
+
export declare function registerComponent(name: any, component: any): void;
|
|
41
|
+
/**
|
|
42
|
+
* Checks if an element is currently frozen.
|
|
43
|
+
* An element is frozen when the `freeze` prop is set to `true` (either as a boolean or Signal<boolean>),
|
|
44
|
+
* or when any of its parent elements are frozen (recursive freeze propagation).
|
|
45
|
+
*
|
|
46
|
+
* @param element - The element to check
|
|
47
|
+
* @returns `true` if the element is frozen, `false` otherwise
|
|
48
|
+
*/
|
|
49
|
+
export declare function isElementFrozen(element: Element): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Creates a virtual element or a representation thereof, with properties that can be dynamically updated based on BehaviorSubjects.
|
|
52
|
+
*
|
|
53
|
+
* @param {string} tag - The tag name of the element to create.
|
|
54
|
+
* @param {Object} props - An object containing properties for the element. Each property can either be a direct value
|
|
55
|
+
* or an array where the first element is a function that returns a value based on input parameters,
|
|
56
|
+
* and the second element is an array of BehaviorSubjects. The property is updated dynamically
|
|
57
|
+
* using the combineLatest RxJS operator to wait for all BehaviorSubjects to emit.
|
|
58
|
+
* @returns {Object} An object representing the created element, including tag name and dynamic properties.
|
|
59
|
+
*/
|
|
60
|
+
export declare function createComponent(tag: string, props?: Props): Element;
|
|
61
|
+
/**
|
|
62
|
+
* Observes a BehaviorSubject containing an array or object of items and dynamically creates child elements for each item.
|
|
63
|
+
*
|
|
64
|
+
* @param {WritableArraySignal<T> | WritableObjectSignal<T>} itemsSubject - A signal that emits an array or object of items.
|
|
65
|
+
* @param {Function} createElementFn - A function that takes an item and returns an element representation.
|
|
66
|
+
* @returns {Observable} An observable that emits the list of created child elements.
|
|
67
|
+
*/
|
|
68
|
+
export declare function loop<T>(itemsSubject: any, createElementFn: (item: T, index: number | string) => Element | null): FlowObservable;
|
|
69
|
+
/**
|
|
70
|
+
* Conditionally creates and destroys elements based on condition signals with support for else if and else.
|
|
71
|
+
*
|
|
72
|
+
* @description This function creates conditional rendering with support for multiple conditions (if/else if/else pattern).
|
|
73
|
+
* It evaluates conditions in order and renders the first matching condition's element.
|
|
74
|
+
* The function maintains full reactivity with signals and ensures proper cleanup of elements.
|
|
75
|
+
*
|
|
76
|
+
* @param {Signal<boolean> | boolean | (() => boolean)} condition - A signal, boolean, or function that determines whether to create an element.
|
|
77
|
+
* @param {Function} createElementFn - A function that returns an element or a promise that resolves to an element.
|
|
78
|
+
* @param {...Array} additionalConditions - Additional conditions for else if and else cases.
|
|
79
|
+
* Can be:
|
|
80
|
+
* - A function for else case: `() => Element | Promise<Element>`
|
|
81
|
+
* - An array for else if case: `[Signal<boolean> | boolean | (() => boolean), () => Element | Promise<Element>]`
|
|
82
|
+
* @returns {Observable} An observable that emits the created element based on the matching condition.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* // Simple if/else
|
|
87
|
+
* cond(
|
|
88
|
+
* signal(isVisible),
|
|
89
|
+
* () => h(Container),
|
|
90
|
+
* () => h(Text, { text: 'Hidden' }) // else
|
|
91
|
+
* );
|
|
92
|
+
*
|
|
93
|
+
* // Multiple else if + else
|
|
94
|
+
* cond(
|
|
95
|
+
* signal(status === 'loading'),
|
|
96
|
+
* () => h(LoadingSpinner),
|
|
97
|
+
* [signal(status === 'error'), () => h(ErrorMessage)], // else if
|
|
98
|
+
* [signal(status === 'success'), () => h(SuccessMessage)], // else if
|
|
99
|
+
* () => h(DefaultMessage) // else
|
|
100
|
+
* );
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
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;
|
|
104
|
+
export {};
|
|
105
|
+
//# 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,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 | Element, 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,EAEL,YAAY,EACb,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE1C,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;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAiEf"}
|
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
* @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
|
+
//# 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,CA0B7D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,EAAE,CAAC,aAAa,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,QA8BrF"}
|
|
@@ -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":"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 @@
|
|
|
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"}
|