canvasengine 2.0.0-beta.2 → 2.0.0-beta.21

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 (41) hide show
  1. package/dist/index.d.ts +1289 -0
  2. package/dist/index.js +4248 -0
  3. package/dist/index.js.map +1 -0
  4. package/index.d.ts +4 -0
  5. package/package.json +5 -12
  6. package/src/components/Canvas.ts +53 -45
  7. package/src/components/Container.ts +2 -2
  8. package/src/components/DOMContainer.ts +123 -0
  9. package/src/components/DOMElement.ts +421 -0
  10. package/src/components/DisplayObject.ts +263 -189
  11. package/src/components/Graphic.ts +213 -36
  12. package/src/components/Mesh.ts +222 -0
  13. package/src/components/NineSliceSprite.ts +4 -1
  14. package/src/components/ParticleEmitter.ts +12 -8
  15. package/src/components/Sprite.ts +77 -14
  16. package/src/components/Text.ts +34 -14
  17. package/src/components/Video.ts +110 -0
  18. package/src/components/Viewport.ts +59 -43
  19. package/src/components/index.ts +6 -4
  20. package/src/components/types/DisplayObject.ts +30 -0
  21. package/src/directives/Drag.ts +357 -52
  22. package/src/directives/KeyboardControls.ts +3 -1
  23. package/src/directives/Sound.ts +94 -31
  24. package/src/directives/ViewportFollow.ts +35 -7
  25. package/src/engine/animation.ts +41 -5
  26. package/src/engine/bootstrap.ts +22 -3
  27. package/src/engine/directive.ts +2 -2
  28. package/src/engine/reactive.ts +337 -168
  29. package/src/engine/trigger.ts +65 -9
  30. package/src/engine/utils.ts +97 -9
  31. package/src/hooks/useProps.ts +1 -1
  32. package/src/index.ts +5 -1
  33. package/src/utils/RadialGradient.ts +29 -0
  34. package/src/utils/functions.ts +7 -0
  35. package/testing/index.ts +12 -0
  36. package/src/components/DrawMap/index.ts +0 -65
  37. package/src/components/Tilemap/Tile.ts +0 -79
  38. package/src/components/Tilemap/TileGroup.ts +0 -207
  39. package/src/components/Tilemap/TileLayer.ts +0 -163
  40. package/src/components/Tilemap/TileSet.ts +0 -41
  41. package/src/components/Tilemap/index.ts +0 -80
@@ -0,0 +1,1289 @@
1
+ import * as _signe_reactive from '@signe/reactive';
2
+ import { WritableSignal, Signal } from '@signe/reactive';
3
+ export * from '@signe/reactive';
4
+ import { BehaviorSubject, Subscription, Subject, Observable } from 'rxjs';
5
+ export { isObservable } from 'rxjs';
6
+ import * as PIXI from 'pixi.js';
7
+ import { FederatedPointerEvent, ObservablePoint, Graphics as Graphics$1, Geometry, Shader, Texture, TextStyle, ApplicationOptions, Application, Matrix } from 'pixi.js';
8
+ import * as howler from 'howler';
9
+ export { howler as Howl };
10
+ export { Howler } from 'howler';
11
+ import * as popmotion from 'popmotion';
12
+
13
+ interface AnimateOptions<T> {
14
+ duration?: number;
15
+ ease?: (t: number) => number;
16
+ onUpdate?: (value: T) => void;
17
+ onComplete?: () => void;
18
+ }
19
+ interface AnimatedState<T> {
20
+ current: T;
21
+ start: T;
22
+ end: T;
23
+ }
24
+ interface AnimatedSignal<T> extends Omit<WritableSignal<T>, 'set'> {
25
+ (): T;
26
+ set: (newValue: T, options?: AnimateOptions<T>) => Promise<void>;
27
+ animatedState: WritableSignal<AnimatedState<T>>;
28
+ update: (updater: (value: T) => T) => void;
29
+ }
30
+ declare function isAnimatedSignal(signal: WritableSignal<any>): boolean;
31
+ /**
32
+ * Creates an animated signal with the given initial value and animation options.
33
+ * It's a writable signal that can be animated using popmotion. Properties of the animated signal are:
34
+ * - current: the current value of the signal.
35
+ * - start: the start value of the animation.
36
+ * - end: the end value of the animation.
37
+ *
38
+ * @param initialValue The initial value of the signal.
39
+ * @param options The animation options.
40
+ * @returns The animated signal.
41
+ * @example
42
+ * const animatedValue = animatedSignal(0, { duration: 1000 });
43
+ * animatedValue.set(10);
44
+ * animatedValue.update((value) => value + 1);
45
+ * console.log(animatedValue()); // 11
46
+ *
47
+ * animatedValue.animatedState() // { current: 10, start: 10, end: 11 }
48
+ */
49
+ declare function animatedSignal<T>(initialValue: T, options?: AnimateOptions<T>): AnimatedSignal<T>;
50
+ /**
51
+ * Executes a sequence of animations. If an array is provided as an element in the sequence,
52
+ * those animations will be executed in parallel.
53
+ *
54
+ * @param sequence Array of animation functions or arrays of animation functions for parallel execution
55
+ * @returns Promise that resolves when all animations are complete
56
+ * @example
57
+ * ```ts
58
+ * await animatedSequence([
59
+ * () => value1.set(10),
60
+ * [
61
+ * () => value2.set(20),
62
+ * () => value3.set(30)
63
+ * ],
64
+ * () => value1.set(0)
65
+ * ])
66
+ * ```
67
+ */
68
+ declare function animatedSequence(sequence: ((() => Promise<void>) | (() => Promise<void>)[])[]): Promise<void>;
69
+
70
+ type SignalOrPrimitive<T> = T | Signal<T> | AnimatedSignal<T>;
71
+
72
+ type DragProps = {
73
+ move?: (event: FederatedPointerEvent) => void;
74
+ start?: () => void;
75
+ end?: () => void;
76
+ snap?: SignalOrPrimitive<number>;
77
+ direction?: SignalOrPrimitive<'x' | 'y' | 'all'>;
78
+ keyToPress?: SignalOrPrimitive<string[]>;
79
+ viewport?: {
80
+ edgeThreshold?: SignalOrPrimitive<number>;
81
+ maxSpeed?: SignalOrPrimitive<number>;
82
+ };
83
+ };
84
+
85
+ type ViewportFollowProps = {
86
+ viewportFollow?: boolean | {
87
+ speed?: SignalOrPrimitive<number>;
88
+ acceleration?: SignalOrPrimitive<number>;
89
+ radius?: SignalOrPrimitive<number>;
90
+ };
91
+ };
92
+
93
+ type FlexDirection = 'row' | 'column' | 'row-reverse' | 'column-reverse';
94
+ type JustifyContent = 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around';
95
+ type AlignContent = 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around';
96
+ type Size = number | `${number}%`;
97
+ type EdgeSize = SignalOrPrimitive<Size | [Size, Size] | [Size, Size, Size, Size]>;
98
+ type ObjectFit = 'contain' | 'cover' | 'fill' | 'none' | 'scale-down';
99
+ type ObjectPosition = string;
100
+ type TransformOrigin = string;
101
+ type PositionType = 'relative' | 'absolute' | 'static';
102
+ interface DisplayObjectProps {
103
+ attach?: any;
104
+ ref?: string;
105
+ x?: SignalOrPrimitive<number>;
106
+ y?: SignalOrPrimitive<number>;
107
+ width?: SignalOrPrimitive<Size>;
108
+ height?: SignalOrPrimitive<Size>;
109
+ minWidth?: SignalOrPrimitive<Size>;
110
+ minHeight?: SignalOrPrimitive<Size>;
111
+ maxWidth?: SignalOrPrimitive<Size>;
112
+ maxHeight?: SignalOrPrimitive<Size>;
113
+ aspectRatio?: SignalOrPrimitive<number>;
114
+ flexGrow?: SignalOrPrimitive<number>;
115
+ flexShrink?: SignalOrPrimitive<number>;
116
+ flexBasis?: SignalOrPrimitive<Size>;
117
+ rowGap?: SignalOrPrimitive<number>;
118
+ columnGap?: SignalOrPrimitive<number>;
119
+ positionType?: PositionType;
120
+ top?: SignalOrPrimitive<Size>;
121
+ right?: SignalOrPrimitive<Size>;
122
+ bottom?: SignalOrPrimitive<Size>;
123
+ left?: SignalOrPrimitive<Size>;
124
+ objectFit?: ObjectFit;
125
+ objectPosition?: ObjectPosition;
126
+ transformOrigin?: TransformOrigin;
127
+ children?: any[];
128
+ flexDirection?: FlexDirection;
129
+ justifyContent?: JustifyContent;
130
+ alpha?: SignalOrPrimitive<number>;
131
+ margin?: EdgeSize;
132
+ padding?: EdgeSize;
133
+ border?: EdgeSize;
134
+ absolute?: SignalOrPrimitive<boolean>;
135
+ scale?: SignalOrPrimitive<{
136
+ x: number;
137
+ y: number;
138
+ } | number>;
139
+ anchor?: SignalOrPrimitive<{
140
+ x: number;
141
+ y: number;
142
+ }>;
143
+ skew?: SignalOrPrimitive<{
144
+ x: number;
145
+ y: number;
146
+ }>;
147
+ tint?: SignalOrPrimitive<number>;
148
+ rotation?: SignalOrPrimitive<number>;
149
+ angle?: SignalOrPrimitive<number>;
150
+ zIndex?: SignalOrPrimitive<number>;
151
+ roundPixels?: SignalOrPrimitive<boolean>;
152
+ cursor?: SignalOrPrimitive<string>;
153
+ visible?: SignalOrPrimitive<boolean>;
154
+ pivot?: SignalOrPrimitive<{
155
+ x: number;
156
+ y: number;
157
+ }>;
158
+ filters?: any[];
159
+ blendMode?: SignalOrPrimitive<PIXI.BLEND_MODES>;
160
+ blur?: SignalOrPrimitive<number>;
161
+ drag?: DragProps;
162
+ viewportFollow?: ViewportFollowProps;
163
+ click?: PIXI.FederatedEventHandler;
164
+ mousedown?: PIXI.FederatedEventHandler;
165
+ mouseenter?: PIXI.FederatedEventHandler;
166
+ mouseleave?: PIXI.FederatedEventHandler;
167
+ mousemove?: PIXI.FederatedEventHandler;
168
+ mouseout?: PIXI.FederatedEventHandler;
169
+ mouseover?: PIXI.FederatedEventHandler;
170
+ mouseup?: PIXI.FederatedEventHandler;
171
+ mouseupoutside?: PIXI.FederatedEventHandler;
172
+ pointercancel?: PIXI.FederatedEventHandler;
173
+ pointerdown?: PIXI.FederatedEventHandler;
174
+ pointerenter?: PIXI.FederatedEventHandler;
175
+ pointerleave?: PIXI.FederatedEventHandler;
176
+ pointermove?: PIXI.FederatedEventHandler;
177
+ pointerout?: PIXI.FederatedEventHandler;
178
+ pointerover?: PIXI.FederatedEventHandler;
179
+ pointertap?: PIXI.FederatedEventHandler;
180
+ pointerup?: PIXI.FederatedEventHandler;
181
+ pointerupoutside?: PIXI.FederatedEventHandler;
182
+ rightclick?: PIXI.FederatedEventHandler;
183
+ rightdown?: PIXI.FederatedEventHandler;
184
+ rightup?: PIXI.FederatedEventHandler;
185
+ rightupoutside?: PIXI.FederatedEventHandler;
186
+ tap?: PIXI.FederatedEventHandler;
187
+ touchcancel?: PIXI.FederatedEventHandler;
188
+ touchend?: PIXI.FederatedEventHandler;
189
+ touchendoutside?: PIXI.FederatedEventHandler;
190
+ touchmove?: PIXI.FederatedEventHandler;
191
+ touchstart?: PIXI.FederatedEventHandler;
192
+ wheel?: PIXI.FederatedEventHandler<PIXI.FederatedWheelEvent>;
193
+ }
194
+
195
+ interface ComponentInstance extends PixiMixins.ContainerOptions {
196
+ id?: string;
197
+ children?: ComponentInstance[];
198
+ onInit?(props: Props): void;
199
+ onUpdate?(props: Props): void;
200
+ onDestroy?(parent: Element, afterDestroy: () => void): void;
201
+ onMount?(context: Element, index?: number): void;
202
+ setWidth(width: number): void;
203
+ setHeight(height: number): void;
204
+ }
205
+ declare const EVENTS: string[];
206
+ type OnHook = (() => void) | (() => Promise<void> | void);
207
+ declare function DisplayObject(extendClass: any): {
208
+ new (): {
209
+ [x: string]: any;
210
+ "__#1@#canvasContext": {
211
+ [key: string]: any;
212
+ } | null;
213
+ isFlex: boolean;
214
+ fullProps: Props;
215
+ isMounted: boolean;
216
+ _anchorPoints: ObservablePoint;
217
+ isCustomAnchor: boolean;
218
+ displayWidth: _signe_reactive.WritableSignal<number>;
219
+ displayHeight: _signe_reactive.WritableSignal<number>;
220
+ overrideProps: string[];
221
+ layout: any;
222
+ onBeforeDestroy: OnHook | null;
223
+ onAfterMount: OnHook | null;
224
+ subjectInit: BehaviorSubject<any>;
225
+ disableLayout: boolean;
226
+ readonly deltaRatio: any;
227
+ readonly parentIsFlex: any;
228
+ onInit(props: Props): void;
229
+ onMount({ parent, props }: Element</*elided*/ any>, index?: number): Promise<void>;
230
+ onUpdate(props: Props): void;
231
+ onDestroy(parent: Element, afterDestroy?: () => void): Promise<void>;
232
+ setFlexDirection(direction: FlexDirection): void;
233
+ setFlexWrap(wrap: "wrap" | "nowrap" | "wrap-reverse"): void;
234
+ setAlignContent(align: AlignContent): void;
235
+ setAlignSelf(align: AlignContent): void;
236
+ setAlignItems(align: AlignContent): void;
237
+ setJustifyContent(justifyContent: "flex-start" | "flex-end" | "center" | "space-between" | "space-around"): void;
238
+ setPosition(position: EdgeSize): void;
239
+ setX(x: number): void;
240
+ setY(y: number): void;
241
+ setPadding(padding: EdgeSize): void;
242
+ setMargin(margin: EdgeSize): void;
243
+ setGap(gap: EdgeSize): void;
244
+ setBorder(border: EdgeSize): void;
245
+ setPositionType(positionType: "relative" | "absolute"): void;
246
+ setWidth(width: number): void;
247
+ setHeight(height: number): void;
248
+ getWidth(): number;
249
+ getHeight(): number;
250
+ setMinWidth(minWidth: number | string): void;
251
+ setMinHeight(minHeight: number | string): void;
252
+ setMaxWidth(maxWidth: number | string): void;
253
+ setMaxHeight(maxHeight: number | string): void;
254
+ setAspectRatio(aspectRatio: number): void;
255
+ setFlexGrow(flexGrow: number): void;
256
+ setFlexShrink(flexShrink: number): void;
257
+ setFlexBasis(flexBasis: number | string): void;
258
+ setRowGap(rowGap: number): void;
259
+ setColumnGap(columnGap: number): void;
260
+ setTop(top: number | string): void;
261
+ setLeft(left: number | string): void;
262
+ setRight(right: number | string): void;
263
+ setBottom(bottom: number | string): void;
264
+ setObjectFit(objectFit: ObjectFit): void;
265
+ setObjectPosition(objectPosition: ObjectPosition): void;
266
+ setTransformOrigin(transformOrigin: TransformOrigin): void;
267
+ };
268
+ [x: string]: any;
269
+ };
270
+
271
+ interface Props {
272
+ [key: string]: any;
273
+ }
274
+ type NestedSignalObjects = {
275
+ [Key in string]: NestedSignalObjects | Signal<any>;
276
+ };
277
+ interface Element<T = ComponentInstance> {
278
+ tag: string;
279
+ props: Props;
280
+ componentInstance: T;
281
+ propSubscriptions: Subscription[];
282
+ effectSubscriptions: Subscription[];
283
+ effectMounts: (() => void)[];
284
+ effectUnmounts: ((element?: Element) => void)[];
285
+ propObservables: NestedSignalObjects | undefined;
286
+ parent: Element | null;
287
+ context?: {
288
+ [key: string]: any;
289
+ };
290
+ directives: {
291
+ [key: string]: Directive;
292
+ };
293
+ destroy: () => void;
294
+ allElements: Subject<void>;
295
+ }
296
+ type FlowResult = {
297
+ elements: Element[];
298
+ prev?: Element;
299
+ fullElements?: Element[];
300
+ };
301
+ type FlowObservable = Observable<FlowResult>;
302
+ declare const isElement: (value: any) => value is Element;
303
+ declare const isPrimitive: (value: any) => boolean;
304
+ declare function registerComponent(name: any, component: any): void;
305
+ /**
306
+ * Creates a virtual element or a representation thereof, with properties that can be dynamically updated based on BehaviorSubjects.
307
+ *
308
+ * @param {string} tag - The tag name of the element to create.
309
+ * @param {Object} props - An object containing properties for the element. Each property can either be a direct value
310
+ * or an array where the first element is a function that returns a value based on input parameters,
311
+ * and the second element is an array of BehaviorSubjects. The property is updated dynamically
312
+ * using the combineLatest RxJS operator to wait for all BehaviorSubjects to emit.
313
+ * @returns {Object} An object representing the created element, including tag name and dynamic properties.
314
+ */
315
+ declare function createComponent(tag: string, props?: Props): Element;
316
+ /**
317
+ * Observes a BehaviorSubject containing an array or object of items and dynamically creates child elements for each item.
318
+ *
319
+ * @param {WritableArraySignal<T> | WritableObjectSignal<T>} itemsSubject - A signal that emits an array or object of items.
320
+ * @param {Function} createElementFn - A function that takes an item and returns an element representation.
321
+ * @returns {Observable} An observable that emits the list of created child elements.
322
+ */
323
+ declare function loop<T>(itemsSubject: any, createElementFn: (item: T, index: number | string) => Element | null): FlowObservable;
324
+ /**
325
+ * Conditionally creates and destroys elements based on a condition signal.
326
+ *
327
+ * @param {Signal<boolean> | boolean} condition - A signal or boolean that determines whether to create an element.
328
+ * @param {Function} createElementFn - A function that returns an element or a promise that resolves to an element.
329
+ * @returns {Observable} An observable that emits the created or destroyed element.
330
+ */
331
+ declare function cond(condition: Signal<boolean> | boolean, createElementFn: () => Element | Promise<Element>): FlowObservable;
332
+
333
+ declare abstract class Directive {
334
+ abstract onDestroy(element: Element<any>): any;
335
+ abstract onInit(element: Element<any>): any;
336
+ abstract onMount(element: Element<any>): any;
337
+ abstract onUpdate(props: any, element: Element<any>): any;
338
+ }
339
+
340
+ interface Tick {
341
+ timestamp: number;
342
+ deltaTime: number;
343
+ frame: number;
344
+ deltaRatio: number;
345
+ }
346
+
347
+ type MountFunction = (fn: (element: Element) => void) => void;
348
+ type ComponentFunction<P = {}> = (props: P) => Element | Promise<Element>;
349
+ declare let currentSubscriptionsTracker: ((subscription: Subscription) => void) | null;
350
+ declare let mountTracker: MountFunction | null;
351
+ /**
352
+ * Registers a mount function to be called when the component is mounted.
353
+ * To unmount the component, the function must return a function that will be called by the engine.
354
+ *
355
+ * @param {(element: Element) => void} fn - The function to be called on mount.
356
+ * @example
357
+ * ```ts
358
+ * mount((el) => {
359
+ * console.log('mounted', el);
360
+ * });
361
+ * ```
362
+ * Unmount the component by returning a function:
363
+ * ```ts
364
+ * mount((el) => {
365
+ * console.log('mounted', el);
366
+ * return () => {
367
+ * console.log('unmounted', el);
368
+ * }
369
+ * });
370
+ * ```
371
+ */
372
+ declare function mount(fn: (element: Element) => void): void;
373
+ /**
374
+ * Registers a tick function to be called on each tick of the component's context.
375
+ * @param {(tickValue: Tick, element: Element) => void} fn - The function to be called on each tick.
376
+ * @example
377
+ * ```ts
378
+ * tick((tickValue, el) => {
379
+ * console.log('tick', tickValue, el);
380
+ * });
381
+ * ```
382
+ */
383
+ declare function tick(fn: (tickValue: Tick, element: Element) => void): void;
384
+ /**
385
+ * Add tracking for subscriptions and mounts, then create an element from a component function.
386
+ * @template C
387
+ * @param {C} componentFunction - The component function to create an element from.
388
+ * @param {Parameters<C>[0]} [props={}] - The props to pass to the component function.
389
+ * @param {...any[]} children - The children elements of the component.
390
+ * @returns {ReturnType<C>}
391
+ * @example
392
+ * ```ts
393
+ * const el = h(MyComponent, {
394
+ * x: 100,
395
+ * y: 100,
396
+ * });
397
+ * ```
398
+ *
399
+ * with children:
400
+ * ```ts
401
+ * const el = h(MyComponent, {
402
+ * x: 100,
403
+ * y: 100,
404
+ * },
405
+ * h(MyChildComponent, {
406
+ * x: 50,
407
+ * y: 50,
408
+ * }),
409
+ * );
410
+ * ```
411
+ */
412
+ declare function h<C extends ComponentFunction<any>>(componentFunction: C, props?: Parameters<C>[0], ...children: any[]): ReturnType<C>;
413
+
414
+ interface CanvasProps extends Props {
415
+ cursorStyles?: () => any;
416
+ width?: SignalOrPrimitive<Size>;
417
+ height?: SignalOrPrimitive<Size>;
418
+ canvasEl?: HTMLElement;
419
+ selector?: string;
420
+ isRoot?: boolean;
421
+ tick?: any;
422
+ class?: SignalOrPrimitive<string>;
423
+ background?: string;
424
+ }
425
+ declare const Canvas: ComponentFunction<CanvasProps>;
426
+
427
+ interface ContainerProps extends DisplayObjectProps {
428
+ sortableChildren?: boolean;
429
+ }
430
+ declare const Container: ComponentFunction<ContainerProps>;
431
+
432
+ interface GraphicsProps extends DisplayObjectProps {
433
+ draw?: (graphics: Graphics$1, width: number, height: number) => void;
434
+ }
435
+ interface RectProps extends DisplayObjectProps {
436
+ color: SignalOrPrimitive<string>;
437
+ }
438
+ interface CircleProps extends DisplayObjectProps {
439
+ radius: SignalOrPrimitive<number>;
440
+ color: SignalOrPrimitive<string>;
441
+ }
442
+ interface EllipseProps extends DisplayObjectProps {
443
+ color: SignalOrPrimitive<string>;
444
+ }
445
+ interface TriangleProps extends DisplayObjectProps {
446
+ base: SignalOrPrimitive<number>;
447
+ color: SignalOrPrimitive<string>;
448
+ }
449
+ interface SvgProps extends DisplayObjectProps {
450
+ /** SVG content as string (legacy prop) */
451
+ svg?: string;
452
+ /** URL source of the SVG file to load */
453
+ src?: string;
454
+ /** Direct SVG content as string */
455
+ content?: string;
456
+ }
457
+ declare function Graphics(props: GraphicsProps): Element<ComponentInstance>;
458
+ declare function Rect(props: RectProps): Element<ComponentInstance>;
459
+ declare function Circle(props: CircleProps): Element<ComponentInstance>;
460
+ declare function Ellipse(props: EllipseProps): Element<ComponentInstance>;
461
+ declare function Triangle(props: TriangleProps): Element<ComponentInstance>;
462
+ /**
463
+ * Creates an SVG component that can render SVG graphics from URL, content, or legacy svg prop.
464
+ *
465
+ * This component provides three ways to display SVG graphics:
466
+ * - **src**: Load SVG from a URL using Assets.load with parseAsGraphicsContext option
467
+ * - **content**: Render SVG directly from string content using Graphics.svg() method
468
+ * - **svg**: Legacy prop for SVG content (for backward compatibility)
469
+ *
470
+ * @param props - Component properties including src, content, or svg
471
+ * @returns A reactive SVG component
472
+ * @example
473
+ * ```typescript
474
+ * // Load from URL
475
+ * const svgFromUrl = Svg({ src: "/assets/logo.svg" });
476
+ *
477
+ * // Direct content
478
+ * const svgFromContent = Svg({
479
+ * content: `<svg viewBox="0 0 100 100">
480
+ * <circle cx="50" cy="50" r="40" fill="blue"/>
481
+ * </svg>`
482
+ * });
483
+ *
484
+ * // Legacy usage
485
+ * const svgLegacy = Svg({ svg: "<svg>...</svg>" });
486
+ * ```
487
+ */
488
+ declare function Svg(props: SvgProps): Element<ComponentInstance>;
489
+
490
+ /**
491
+ * Interface defining the properties for a Mesh component.
492
+ * Extends DisplayObjectProps to inherit common display object properties.
493
+ */
494
+ interface MeshProps extends DisplayObjectProps {
495
+ /** The geometry defining the mesh structure (vertices, indices, UVs, etc.) */
496
+ geometry?: Geometry;
497
+ /** The shader to render the mesh with */
498
+ shader?: Shader;
499
+ /** The texture to apply to the mesh */
500
+ texture?: Texture | string;
501
+ /** The image URL to load as texture */
502
+ image?: string;
503
+ /** The tint color to apply to the mesh */
504
+ tint?: SignalOrPrimitive<number>;
505
+ /** Whether to round pixels for sharper rendering */
506
+ roundPixels?: SignalOrPrimitive<boolean>;
507
+ }
508
+ /**
509
+ * Creates a Mesh component with the specified properties.
510
+ * This is the main function used to create mesh instances in your application.
511
+ *
512
+ * @param props - The properties for the mesh component
513
+ * @returns A mesh component element
514
+ * @example
515
+ * ```typescript
516
+ * import { Mesh } from 'canvasengine';
517
+ *
518
+ * // Create a basic textured mesh
519
+ * const myMesh = Mesh({
520
+ * geometry: triangleGeometry,
521
+ * texture: "assets/texture.png",
522
+ * x: 100,
523
+ * y: 100,
524
+ * tint: 0xff0000
525
+ * });
526
+ *
527
+ * // Create a mesh with custom shader
528
+ * const shaderMesh = Mesh({
529
+ * geometry: planeGeometry,
530
+ * shader: customShader,
531
+ * draw: (mesh) => {
532
+ * mesh.rotation += 0.01;
533
+ * }
534
+ * });
535
+ * ```
536
+ */
537
+ declare const Mesh: ComponentFunction<MeshProps>;
538
+
539
+ declare function Scene(props: any): Element<ComponentInstance> | Promise<Element<ComponentInstance>>;
540
+
541
+ declare function ParticlesEmitter(props: any): Element<ComponentInstance>;
542
+
543
+ interface TransformOptions {
544
+ /**
545
+ * The global value of opacity (between 0 and 1)
546
+ *
547
+ * @prop {number} [opacity]
548
+ * @memberof Spritesheet
549
+ * */
550
+ opacity?: number;
551
+ /**
552
+ * The global value of pivot.
553
+ *
554
+ * Invariant under rotation, scaling, and skewing. The projection of into the parent's space of the pivot is equal to position, regardless of the other three transformations. In other words, It is the center of rotation, scaling, and skewing.
555
+ *
556
+ * The array has two elements: [x, y]. If y is omitted, both x and y will be set to x.
557
+ *
558
+ * ```ts
559
+ * pivot: [0.5, 0.8]
560
+ * ```
561
+ *
562
+ * @prop {Array<number>} [pivot]
563
+ * @memberof Spritesheet
564
+ * */
565
+ pivot?: number[];
566
+ /**
567
+ * The global value of anchor.
568
+ *
569
+ * Position of the origin point
570
+ *
571
+ * The array has two elements: [x, y]. If y is omitted, both x and y will be set to x.
572
+ *
573
+ * ```ts
574
+ * anchor: [0.5, 0.8]
575
+ * ```
576
+ *
577
+ * @prop {Array<number>} [anchor]
578
+ * @memberof Spritesheet
579
+ * */
580
+ anchor?: number[];
581
+ /**
582
+ * Defines the actual size of the sprite that is inside a larger rectangle.
583
+ * For example, if the texture rectangle is 192x192 while the character, which is in the center, is only 64x64 then set `spriteRealSize: 64`. This way the character will be well positioned in relation to the animations that have a different rectangle
584
+ *
585
+ * > You can also put `spriteRealSize: { width: 64, height: 64 }` but be aware that the width is not concerned because it will always be centered while the height depends on the hitbox
586
+ *
587
+ * @prop {{ width: number, height: number } | number} [spriteRealSize]
588
+ * @since 3.2.0
589
+ * @memberof Spritesheet
590
+ * */
591
+ spriteRealSize?: {
592
+ width: number;
593
+ height: number;
594
+ } | number;
595
+ /**
596
+ * The global value of rotation
597
+ *
598
+ * Rotation. This will rotate the display object's projection by this angle (in radians).
599
+ *
600
+ * @prop {number} [angle]
601
+ * @memberof Spritesheet
602
+ * */
603
+ angle?: number;
604
+ /**
605
+ * The global value of rotation
606
+ *
607
+ * Rotation. This is an alias for rotation, but in degrees.
608
+ *
609
+ * @prop {number} [rotation]
610
+ * @memberof Spritesheet
611
+ * */
612
+ rotation?: number;
613
+ /**
614
+ * The global value of scale.
615
+ *
616
+ * Scaling. This will stretch (or compress) the display object's projection. The scale factors are along the local coordinate axes. In other words, the display object is scaled before rotated or skewed. The center of scaling is the pivot.
617
+ *
618
+ * The array has two elements: [x, y]. If y is omitted, both x and y will be set to x.
619
+ *
620
+ * ```ts
621
+ * scale: [0.5, 0.8]
622
+ * ```
623
+ *
624
+ * @prop {Array<number>} [scale]
625
+ * @memberof Spritesheet
626
+ * */
627
+ scale?: number[];
628
+ /**
629
+ * The global value of skew.
630
+ *
631
+ * Skewing. This can be used to deform a rectangular display object into a parallelogram.
632
+ *
633
+ * In PixiJS, skew has a slightly different behaviour than the conventional meaning. It can be thought of the net rotation applied to the coordinate axes (separately). For example, if "skew.x" is ⍺ and "skew.y" is β, then the line x = 0 will be rotated by ⍺ (y = -x*cot⍺) and the line y = 0 will be rotated by β (y = x*tanβ). A line y = x*tanϴ (i.e. a line at angle ϴ to the x-axis in local-space) will be rotated by an angle between ⍺ and β.
634
+ *
635
+ * It can be observed that if skew is applied equally to both axes, then it will be equivalent to applying a rotation. Indeed, if "skew.x" = -ϴ and "skew.y" = ϴ, it will produce an equivalent of "rotation" = ϴ.
636
+ *
637
+ * Another quite interesting observation is that "skew.x", "skew.y", rotation are communtative operations. Indeed, because rotation is essentially a careful combination of the two.
638
+ *
639
+ * The array has two elements: [x, y]. If y is omitted, both x and y will be set to x.
640
+ *
641
+ * @prop {Array<number>} [skew]
642
+ * @memberof Spritesheet
643
+ * */
644
+ skew?: number[];
645
+ /**
646
+ * The global value of X translation
647
+ *
648
+ * @prop {number} [x]
649
+ * @memberof Spritesheet
650
+ * */
651
+ x?: number;
652
+ /**
653
+ * The global value of Y translation
654
+ *
655
+ * @prop {number} [y]
656
+ * @memberof Spritesheet
657
+ * */
658
+ y?: number;
659
+ /**
660
+ * The global value of visible
661
+ *
662
+ * @prop {boolean} [visible]
663
+ * @memberof Spritesheet
664
+ * */
665
+ visible?: boolean;
666
+ /**
667
+ * Define the sound that will be played for all animations in the spritesheet. Remember to create the sound before with the @Sound decorator
668
+ *
669
+ * @prop {string} [sound]
670
+ * @memberof Spritesheet
671
+ * */
672
+ sound?: string;
673
+ }
674
+ interface FrameOptions extends TransformOptions {
675
+ time: number;
676
+ frameX?: number;
677
+ frameY?: number;
678
+ }
679
+ interface TextureOptions {
680
+ /**
681
+ * The number of frames on the width
682
+ *
683
+ * @prop {number} framesWidth
684
+ * @memberof Spritesheet
685
+ * */
686
+ framesWidth?: number;
687
+ /**
688
+ * The number of frames on the height
689
+ *
690
+ * @prop {number} framesHeight
691
+ * @memberof Spritesheet
692
+ * */
693
+ framesHeight?: number;
694
+ /**
695
+ * The width of the image (in pixels)
696
+ *
697
+ * @prop {number} width
698
+ * @memberof Spritesheet
699
+ * */
700
+ width?: number;
701
+ /**
702
+ * The height of the image (in pixels)
703
+ *
704
+ * @prop {number} height
705
+ * @memberof Spritesheet
706
+ * */
707
+ height?: number;
708
+ /**
709
+ * Takes a width of a rectangle in the image. Equivalent to `width / framesWidth`
710
+ *
711
+ * @prop {number} [rectWidth]
712
+ * @memberof Spritesheet
713
+ * */
714
+ rectWidth?: number;
715
+ /**
716
+ * Takes a height of a rectangle in the image. Equivalent to `height / framesHeight`
717
+ *
718
+ * @prop {number} [rectHeight]
719
+ * @memberof Spritesheet
720
+ * */
721
+ rectHeight?: number;
722
+ /**
723
+ * To take the texture, start at a well defined X and Y position. Otherwise, it starts at 0,0
724
+ *
725
+ * @prop {number} [offset]
726
+ * @memberof Spritesheet
727
+ * */
728
+ offset?: {
729
+ x: number;
730
+ y: number;
731
+ };
732
+ }
733
+ type AnimationFrames = FrameOptions[][] | ((...args: any) => FrameOptions[][]);
734
+ interface TexturesOptions extends TextureOptions, TransformOptions {
735
+ animations: AnimationFrames;
736
+ }
737
+ interface SpritesheetOptions extends TransformOptions, TextureOptions {
738
+ /**
739
+ * Object containing all animations.
740
+ * The key to the object is the name of the animation. The value is a two-dimensional array
741
+ *
742
+ * ```ts
743
+ * textures: {
744
+ * myanim: {
745
+ * animations: [
746
+ * [ { time: 0, frameX: 0, frameY: 0 } ]
747
+ * ]
748
+ * }
749
+ * }
750
+ * ```
751
+ *
752
+ * The first array represents an animation group. You can put several of them together to create an animation cluster. For example, several explosions with the same spritesheet
753
+ * The second array represents the animation itself which will animate over time. The object indicates, over a period of time (in frame), which part of the spritesheet will be taken (`frameX`, `frameY`)
754
+ *
755
+ * Here are the properties:
756
+ *
757
+ * * `time`: Time in frame
758
+ * * `frameX`: Retrieve a frame from the spritesheet on the X-axis
759
+ * * `frameY`: Retrieve a frame from the spritesheet on the Y-axis
760
+ * * `opacity`
761
+ * * `pivot`
762
+ * * `anchor`
763
+ * * `rotation`
764
+ * * `angle`
765
+ * * `scale`
766
+ * * `skew`
767
+ * * `x`
768
+ * * `y`
769
+ * * `visible`
770
+ * * `sound`: The sound that will be played during the frame
771
+ *
772
+ * ---
773
+ * **Extract Animation of Spritesheet**
774
+ *
775
+ * Sometimes the animation is part of the image
776
+ *
777
+ * ```ts
778
+ * textures: {
779
+ * myanim: {
780
+ * rectWidth: 64,
781
+ * rectHeight: 64,
782
+ * framesWidth: 10,
783
+ * framesHeight: 2,
784
+ * offset: {x: 0, y: 230},
785
+ * sound: 'my-sound-id', // You can put a sound just for the animation
786
+ * animations: [
787
+ * [ { time: 0, frameX: 0, frameY: 0 } ]
788
+ * ]
789
+ * }
790
+ * }
791
+ * ```
792
+ *
793
+ * Above, we can specify which part we want to recover
794
+ *
795
+ * 1. We go to the position {0, 230} of the image (`offset`)
796
+ * 2. We recover cells of 64px (`rectWidth` and `rectHeight`)
797
+ * 3. And we get 20 cells (10 on the width, 2 on the height) (`frameX` and `frameY`)
798
+ *
799
+ * ---
800
+ *
801
+ * **Advanced**
802
+ *
803
+ * You can create an animation that will be linked to a data. For example, different animation according to a direction of the character.
804
+ *
805
+ * Full example:
806
+ *
807
+ * ```ts
808
+ * import { Spritesheet, Animation, Direction } from '@rpgjs/client'
809
+ *
810
+ * @Spritesheet({
811
+ * id: 'chest',
812
+ * image: require('./assets/chest.png'),
813
+ * width: 124,
814
+ * height: 61,
815
+ * framesHeight: 2,
816
+ * framesWidth: 4,
817
+ * textures: {
818
+ * [Animation.Stand]: {
819
+ * animations: direction => [[ {time: 0, frameX: 3, frameY: direction == Direction.Up ? 0 : 1 } ]]
820
+ * }
821
+ * })
822
+ * })
823
+ * export class Chest { }
824
+ * ```
825
+ *
826
+ * > It is important to know that `Animation.Stand` animation is called if it exists. it only works in the case of an event that doesn't move. The direction is then sent
827
+ *
828
+ * As you can see, the property contains a function that returns the array for the animation. Here, it is the direction but the parameters depend on the call of the animation. Example:
829
+ *
830
+ * ```ts
831
+ * import { Spritesheet, Animation, Direction, RpgSprite, ISpriteCharacter } from '@rpgjs/client'
832
+ *
833
+ * @Spritesheet({
834
+ * id: 'chest',
835
+ * image: require('./assets/chest.png'),
836
+ * width: 124,
837
+ * height: 61,
838
+ * framesHeight: 2,
839
+ * framesWidth: 4,
840
+ * textures: {
841
+ * [Animation.Stand]: {
842
+ * animations: str => [[ {time: 0, frameX: 3, frameY: str == 'hello' ? 0 : 1 } ]]
843
+ * }
844
+ * }
845
+ * })
846
+ * export class Chest implements ISpriteCharacter {
847
+ * onCharacterStand(sprite: RpgSprite) {
848
+ * sprite.animation.play(Animation.Stand, ['hello'])
849
+ * }
850
+ * }
851
+ * ```
852
+ *
853
+ * @prop { { [animName: string]: { animations: Array<Array<FrameOptions>> | Function, ...other } } } [textures]
854
+ * @memberof Spritesheet
855
+ * */
856
+ textures?: {
857
+ [animationName: string]: Partial<TexturesOptions> & Pick<TexturesOptions, 'animations'>;
858
+ };
859
+ }
860
+
861
+ type Image = {
862
+ image: string;
863
+ };
864
+ type TextureOptionsMerging = TextureOptions & {
865
+ spriteWidth: number;
866
+ spriteHeight: number;
867
+ sound?: string;
868
+ } & Image & TransformOptions;
869
+ type SpritesheetOptionsMerging = TextureOptionsMerging & SpritesheetOptions;
870
+ interface SpriteProps extends DisplayObjectProps {
871
+ sheet?: {
872
+ definition?: SpritesheetOptionsMerging;
873
+ playing?: string;
874
+ params?: any;
875
+ onFinish?: () => void;
876
+ };
877
+ scaleMode?: number;
878
+ image?: string;
879
+ rectangle?: {
880
+ x: number;
881
+ y: number;
882
+ width: number;
883
+ height: number;
884
+ };
885
+ context?: {
886
+ tick: Signal;
887
+ };
888
+ }
889
+ interface SpritePropsWithImage extends Omit<SpriteProps, "sheet"> {
890
+ image: string;
891
+ rectangle?: {
892
+ x: number;
893
+ y: number;
894
+ width: number;
895
+ height: number;
896
+ };
897
+ }
898
+ interface SpritePropsWithSheet extends Omit<SpriteProps, "image" | "rectangle"> {
899
+ sheet: {
900
+ definition: SpritesheetOptionsMerging;
901
+ playing?: string;
902
+ params?: any;
903
+ onFinish?: () => void;
904
+ };
905
+ loader?: {
906
+ onProgress?: (progress: number) => void;
907
+ onComplete?: (texture: Texture) => void;
908
+ };
909
+ }
910
+ type SpritePropTypes = SpritePropsWithImage | SpritePropsWithSheet;
911
+ declare const Sprite: ComponentFunction<SpritePropTypes>;
912
+
913
+ interface VideoProps {
914
+ src: string;
915
+ paused?: boolean;
916
+ loop?: boolean;
917
+ muted?: boolean;
918
+ loader?: {
919
+ onComplete?: (texture: Texture) => void;
920
+ onProgress?: (progress: number) => void;
921
+ };
922
+ }
923
+ declare function Video(props: VideoProps): Element<ComponentInstance> | Promise<Element<ComponentInstance>>;
924
+
925
+ interface TextProps extends DisplayObjectProps {
926
+ text?: string;
927
+ style?: Partial<TextStyle>;
928
+ color?: string;
929
+ size?: string;
930
+ fontFamily?: string;
931
+ typewriter?: {
932
+ speed?: number;
933
+ start?: () => void;
934
+ onComplete?: () => void;
935
+ skip?: () => void;
936
+ };
937
+ context?: any;
938
+ }
939
+ declare function Text(props: TextProps): Element<ComponentInstance>;
940
+
941
+ interface TilingSpriteProps extends DisplayObjectProps {
942
+ image?: string;
943
+ tileScale?: {
944
+ x: number;
945
+ y: number;
946
+ };
947
+ tilePosition?: {
948
+ x: number;
949
+ y: number;
950
+ };
951
+ width?: number;
952
+ height?: number;
953
+ }
954
+ declare function TilingSprite(props: TilingSpriteProps): Element<ComponentInstance>;
955
+
956
+ interface ViewportProps extends Props {
957
+ screenWidth?: number;
958
+ screenHeight?: number;
959
+ worldWidth?: number;
960
+ worldHeight?: number;
961
+ clamp?: boolean | {
962
+ left?: number;
963
+ right?: number;
964
+ top?: number;
965
+ bottom?: number;
966
+ };
967
+ context?: any;
968
+ [key: string]: any;
969
+ }
970
+ declare function Viewport(props: ViewportProps): Element<ComponentInstance>;
971
+
972
+ interface NineSliceSpriteProps extends DisplayObjectProps {
973
+ image?: string;
974
+ texture?: Texture;
975
+ width?: number;
976
+ height?: number;
977
+ leftWidth?: number;
978
+ rightWidth?: number;
979
+ topHeight?: number;
980
+ bottomHeight?: number;
981
+ roundPixels?: boolean;
982
+ }
983
+ declare function NineSliceSprite(props: NineSliceSpriteProps): Element<ComponentInstance>;
984
+
985
+ declare const DOMContainer: ComponentFunction<any>;
986
+
987
+ interface DOMContainerProps extends DisplayObjectProps {
988
+ element: string | {
989
+ value: HTMLElement;
990
+ };
991
+ textContent?: string;
992
+ attrs?: Record<string, any> & {
993
+ class?: string | string[] | Record<string, boolean> | {
994
+ items?: string[];
995
+ } | {
996
+ value?: string | string[] | Record<string, boolean>;
997
+ };
998
+ style?: string | Record<string, string | number> | {
999
+ value?: string | Record<string, string | number>;
1000
+ };
1001
+ };
1002
+ onBeforeDestroy?: OnHook;
1003
+ }
1004
+ declare const DOMElement: ComponentFunction<DOMContainerProps>;
1005
+
1006
+ interface Listen<T = any> {
1007
+ config: T | undefined;
1008
+ seed: {
1009
+ config: T | undefined;
1010
+ value: number;
1011
+ resolve: (value: any) => void;
1012
+ };
1013
+ }
1014
+ interface Trigger<T = any> {
1015
+ start: () => Promise<void>;
1016
+ listen: () => Listen<T> | undefined;
1017
+ }
1018
+ /**
1019
+ * Checks if the given argument is a Trigger object
1020
+ * @param arg - The value to check
1021
+ * @returns True if the argument is a Trigger object
1022
+ */
1023
+ declare function isTrigger(arg: any): arg is Trigger<any>;
1024
+ /**
1025
+ * Creates a new trigger that can be used to pass data between components
1026
+ * @param globalConfig - Optional configuration data to be passed when the trigger is activated
1027
+ * @returns A Trigger object with start and listen methods
1028
+ * @example
1029
+ * ```ts
1030
+ * const myTrigger = trigger()
1031
+ *
1032
+ * on(myTrigger, (data) => {
1033
+ * console.log('Triggered with data:', data)
1034
+ * })
1035
+ *
1036
+ * myTrigger.start({ message: 'Hello' })
1037
+ * ```
1038
+ */
1039
+ declare function trigger<T = any>(globalConfig?: T): Trigger<T>;
1040
+ /**
1041
+ * Subscribes to a trigger and executes a callback when the trigger is activated
1042
+ * @param triggerSignal - The trigger to subscribe to
1043
+ * @param callback - Function to execute when the trigger is activated
1044
+ * @throws Error if triggerSignal is not a valid trigger
1045
+ * @example
1046
+ * ```ts
1047
+ * const click = trigger()
1048
+ *
1049
+ * on(click, () => {
1050
+ * console.log('Click triggered')
1051
+ * })
1052
+ * ```
1053
+ */
1054
+ declare function on(triggerSignal: any, callback: (config: any) => void | Promise<void>): void;
1055
+
1056
+ /**
1057
+ * Bootstraps a canvas element and renders it to the DOM.
1058
+ *
1059
+ * @param rootElement - The HTML element where the canvas will be rendered. Can be null.
1060
+ * @param canvas - A Promise that resolves to an Element representing the canvas component.
1061
+ * @returns A Promise that resolves to the rendered canvas element.
1062
+ * @throws {Error} If the provided element is not a Canvas component.
1063
+ */
1064
+ declare const bootstrapCanvas: (rootElement: HTMLElement | null, canvas: ComponentFunction<any>, options?: ApplicationOptions) => Promise<{
1065
+ canvasElement: Element<ComponentInstance>;
1066
+ app: Application<PIXI.Renderer>;
1067
+ }>;
1068
+
1069
+ /**
1070
+ * Converts props into reactive signals if they are primitive values.
1071
+ *
1072
+ * @param {object} props - The properties to convert.
1073
+ * @param {object} [defaults={}] - Default values for properties.
1074
+ * @returns {object} An object with reactive signals.
1075
+ *
1076
+ * @example
1077
+ * const props = useProps({ count: 0, name: "John" });
1078
+ * console.log(props.count()); // 0
1079
+ * props.count.set(1);
1080
+ * console.log(props.count()); // 1
1081
+ */
1082
+ declare const useProps: (props: any, defaults?: {}) => any;
1083
+ type PropType = NumberConstructor | StringConstructor | BooleanConstructor | FunctionConstructor | ObjectConstructor | ArrayConstructor | null | (new (...args: any[]) => any);
1084
+ interface PropConfig {
1085
+ type?: PropType | PropType[];
1086
+ required?: boolean;
1087
+ default?: any | ((props: any) => any);
1088
+ validator?: (value: any, props: any) => boolean;
1089
+ }
1090
+ type PropSchema = {
1091
+ [key: string]: PropType | PropType[] | PropConfig;
1092
+ };
1093
+ /**
1094
+ * Validates and defines properties based on a schema.
1095
+ *
1096
+ * @param {object} props - The properties to validate.
1097
+ * @returns {function} A function that takes a schema and returns validated properties.
1098
+ *
1099
+ * @example
1100
+ * const schema = {
1101
+ * age: { type: Number, required: true },
1102
+ * name: { type: String, default: "Anonymous" }
1103
+ * };
1104
+ * const validatedProps = useDefineProps({ age: 25 })(schema);
1105
+ * console.log(validatedProps.age()); // 25
1106
+ * console.log(validatedProps.name()); // "Anonymous"
1107
+ */
1108
+ declare const useDefineProps: (props: any) => (schema?: PropSchema) => any;
1109
+
1110
+ declare const Easing: {
1111
+ linear: popmotion.Easing;
1112
+ easeIn: popmotion.Easing;
1113
+ easeInOut: popmotion.Easing;
1114
+ easeOut: popmotion.Easing;
1115
+ circIn: popmotion.Easing;
1116
+ circInOut: popmotion.Easing;
1117
+ circOut: popmotion.Easing;
1118
+ backIn: popmotion.Easing;
1119
+ backInOut: popmotion.Easing;
1120
+ backOut: popmotion.Easing;
1121
+ anticipate: popmotion.Easing;
1122
+ bounceIn: popmotion.Easing;
1123
+ bounceInOut: (p: number) => number;
1124
+ bounceOut: (p: number) => number;
1125
+ };
1126
+
1127
+ /**
1128
+ * Creates a radial gradient texture that can be used in PixiJS.
1129
+ * @example
1130
+ * const gradient = new RadialGradient(size, size, 0, size, size, 0);
1131
+ * gradient.addColorStop(0, "rgba(255, 255, 0, 1)");
1132
+ * gradient.addColorStop(0.5, "rgba(255, 255, 0, 0.3)");
1133
+ * gradient.addColorStop(0.8, "rgba(255, 255, 0, 0)");
1134
+ */
1135
+ declare class RadialGradient {
1136
+ private x0;
1137
+ private y0;
1138
+ private x1;
1139
+ private y1;
1140
+ private x2;
1141
+ private y2;
1142
+ private focalPoint;
1143
+ private canvas;
1144
+ private ctx;
1145
+ private gradient;
1146
+ private texture;
1147
+ transform: Matrix;
1148
+ size: number;
1149
+ /**
1150
+ * Creates a new RadialGradient instance
1151
+ * @param x0 - The x-coordinate of the starting circle
1152
+ * @param y0 - The y-coordinate of the starting circle
1153
+ * @param x1 - The x-coordinate of the ending circle
1154
+ * @param y1 - The y-coordinate of the ending circle
1155
+ * @param x2 - The x-coordinate for gradient transformation
1156
+ * @param y2 - The y-coordinate for gradient transformation
1157
+ * @param focalPoint - The focal point of the gradient (0-1), defaults to 0
1158
+ */
1159
+ constructor(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, focalPoint?: number);
1160
+ /**
1161
+ * Adds a color stop to the gradient
1162
+ * @param offset - The position of the color stop (0-1)
1163
+ * @param color - The color value (any valid CSS color string)
1164
+ */
1165
+ addColorStop(offset: number, color: string): void;
1166
+ /**
1167
+ * Renders the gradient and returns the texture with its transformation matrix
1168
+ * @param options - Render options
1169
+ * @param options.translate - Optional translation coordinates
1170
+ * @returns Object containing the texture and transformation matrix
1171
+ */
1172
+ render({ translate }?: {
1173
+ translate?: {
1174
+ x: number;
1175
+ y: number;
1176
+ };
1177
+ }): {
1178
+ texture: Texture<PIXI.TextureSource<any>>;
1179
+ matrix: Matrix;
1180
+ };
1181
+ }
1182
+
1183
+ /**
1184
+ * Checks if code is running in a browser environment
1185
+ * @returns {boolean} True if running in browser, false otherwise
1186
+ */
1187
+ declare function isBrowser(): boolean;
1188
+ /**
1189
+ * Returns current high-resolution timestamp
1190
+ * @returns {number} Current time in milliseconds
1191
+ */
1192
+ declare function preciseNow(): number;
1193
+ /**
1194
+ * Converts frames per second to milliseconds
1195
+ * @param {number} fps - Frames per second
1196
+ * @returns {number} Milliseconds per frame
1197
+ */
1198
+ declare function fps2ms(fps: number): number;
1199
+ /**
1200
+ * Checks if a value is a Promise
1201
+ * @param {any} value - Value to check
1202
+ * @returns {boolean} True if value is a Promise, false otherwise
1203
+ */
1204
+ declare function isPromise(value: any): boolean;
1205
+ declare function arrayEquals(a: any[], b: any[]): boolean;
1206
+ /**
1207
+ * Checks if a value is a function
1208
+ * @param {unknown} val - Value to check
1209
+ * @returns {boolean} True if value is a function, false otherwise
1210
+ */
1211
+ declare function isFunction(val: unknown): boolean;
1212
+ /**
1213
+ * Checks if a value is a plain object (not an instance of a class)
1214
+ * @param {unknown} val - Value to check
1215
+ * @returns {boolean} True if value is a plain object (not null, not array, not instance), false otherwise
1216
+ * @example
1217
+ * ```ts
1218
+ * isObject({}) // true
1219
+ * isObject(new Date()) // false
1220
+ * isObject([]) // false
1221
+ * isObject(null) // false
1222
+ * ```
1223
+ */
1224
+ declare function isObject(val: unknown): boolean;
1225
+ declare function isObservable(val: unknown): boolean;
1226
+ /**
1227
+ * Sets a value in an object using a dot notation path
1228
+ * @param {Record<string, any>} obj - Target object
1229
+ * @param {string | string[]} path - Path to set value at (e.g., 'a.b.c' or ['a', 'b', 'c'])
1230
+ * @param {any} value - Value to set
1231
+ * @param {boolean} onlyPlainObject - If true, only creates plain objects in path
1232
+ * @returns {Record<string, any>} Modified object
1233
+ */
1234
+ declare function set(obj: Record<string, any>, path: string | string[], value: any, onlyPlainObject?: boolean): Record<string, any>;
1235
+ /**
1236
+ * Gets a value from an object using a dot notation path
1237
+ * @param {Record<string, any>} obj - Source object
1238
+ * @param {string} path - Path to get value from (e.g., 'a.b.c')
1239
+ * @returns {any} Value at path or undefined if not found
1240
+ */
1241
+ declare function get(obj: Record<string, any>, path: string): any;
1242
+ /**
1243
+ * Logs a message to console
1244
+ * @param {any} text - Message to log
1245
+ */
1246
+ declare function log(text: any): void;
1247
+ /**
1248
+ * Logs an error message to console
1249
+ * @param {any} text - Error message to log
1250
+ */
1251
+ declare function error(text: any): void;
1252
+ /**
1253
+ * Sets the position of an ObservablePoint using various input formats
1254
+ * @param {ObservablePoint} observablePoint - The point to modify
1255
+ * @param {Object | number | [number, number]} point - New position value
1256
+ */
1257
+ declare function setObservablePoint(observablePoint: ObservablePoint, point: {
1258
+ x: number;
1259
+ y: number;
1260
+ } | number | [number, number]): void;
1261
+ /**
1262
+ * Calculates the Euclidean distance between two points
1263
+ * @param {number} x1 - X coordinate of first point
1264
+ * @param {number} y1 - Y coordinate of first point
1265
+ * @param {number} x2 - X coordinate of second point
1266
+ * @param {number} y2 - Y coordinate of second point
1267
+ * @returns {number} Distance between the points
1268
+ */
1269
+ declare function calculateDistance(x1: number, y1: number, x2: number, y2: number): number;
1270
+
1271
+ declare const utils_arrayEquals: typeof arrayEquals;
1272
+ declare const utils_calculateDistance: typeof calculateDistance;
1273
+ declare const utils_error: typeof error;
1274
+ declare const utils_fps2ms: typeof fps2ms;
1275
+ declare const utils_get: typeof get;
1276
+ declare const utils_isBrowser: typeof isBrowser;
1277
+ declare const utils_isFunction: typeof isFunction;
1278
+ declare const utils_isObject: typeof isObject;
1279
+ declare const utils_isObservable: typeof isObservable;
1280
+ declare const utils_isPromise: typeof isPromise;
1281
+ declare const utils_log: typeof log;
1282
+ declare const utils_preciseNow: typeof preciseNow;
1283
+ declare const utils_set: typeof set;
1284
+ declare const utils_setObservablePoint: typeof setObservablePoint;
1285
+ declare namespace utils {
1286
+ export { utils_arrayEquals as arrayEquals, utils_calculateDistance as calculateDistance, utils_error as error, utils_fps2ms as fps2ms, utils_get as get, utils_isBrowser as isBrowser, utils_isFunction as isFunction, utils_isObject as isObject, utils_isObservable as isObservable, utils_isPromise as isPromise, utils_log as log, utils_preciseNow as preciseNow, utils_set as set, utils_setObservablePoint as setObservablePoint };
1287
+ }
1288
+
1289
+ export { type AnimateOptions, type AnimatedSignal, type AnimatedState, Canvas, Circle, type ComponentFunction, type ComponentInstance, Container, DOMContainer, DOMElement, DisplayObject, EVENTS, Easing, type Element, Ellipse, Graphics, Mesh, NineSliceSprite, type OnHook, ParticlesEmitter, type Props, RadialGradient, Rect, Scene, Sprite, Svg, Text, TilingSprite, Triangle, utils as Utils, Video, Viewport, animatedSequence, animatedSignal, bootstrapCanvas, cond, createComponent, currentSubscriptionsTracker, h, isAnimatedSignal, isElement, isPrimitive, isTrigger, loop, mount, mountTracker, on, registerComponent, tick, trigger, useDefineProps, useProps };