canvasengine 2.0.0-beta.1 → 2.0.0-beta.10
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/index.d.ts +322 -31
- package/dist/index.js +525 -643
- package/dist/index.js.map +1 -1
- package/index.d.ts +4 -0
- package/package.json +9 -53
- package/src/components/DisplayObject.ts +3 -3
- package/src/components/Graphic.ts +1 -1
- package/src/components/Sprite.ts +24 -3
- package/src/components/Text.ts +2 -2
- package/src/components/Video.ts +110 -0
- package/src/components/index.ts +3 -3
- package/src/components/types/DisplayObject.ts +2 -0
- package/src/directives/KeyboardControls.ts +1 -1
- package/src/directives/Scheduler.ts +0 -11
- package/src/engine/animation.ts +41 -5
- package/src/engine/reactive.ts +250 -149
- package/src/engine/trigger.ts +65 -9
- package/src/engine/utils.ts +84 -8
- package/src/index.ts +5 -4
- package/src/utils/RadialGradient.ts +29 -0
- package/testing/index.ts +11 -0
- package/.cursorrules +0 -0
- package/README.md +0 -71
- package/dist/compiler/vite.js +0 -119
- package/dist/compiler/vite.js.map +0 -1
- package/logo.png +0 -0
- package/src/compiler/grammar.pegjs +0 -180
- package/src/compiler/vite.ts +0 -166
- package/src/components/DrawMap/index.ts +0 -65
- package/src/components/Tilemap/Tile.ts +0 -79
- package/src/components/Tilemap/TileGroup.ts +0 -207
- package/src/components/Tilemap/TileLayer.ts +0 -163
- package/src/components/Tilemap/TileSet.ts +0 -41
- package/src/components/Tilemap/index.ts +0 -80
- package/src/presets/Bar.ts +0 -89
- package/src/presets/Button.ts +0 -0
- package/src/presets/Joystick.ts +0 -286
- package/src/presets/NightAmbiant.ts +0 -122
- package/src/presets/Particle.ts +0 -53
- package/starter/assets/logo.png +0 -0
- package/starter/components/app.ce +0 -18
- package/starter/components/hello.ce +0 -34
- package/starter/index.html +0 -21
- package/starter/main.ts +0 -4
- package/starter/package.json +0 -16
- package/starter/vite.config.ts +0 -12
- package/tsconfig.json +0 -32
- package/tsconfig.node.json +0 -10
- package/tsup.config.ts +0 -28
- package/vitest.config.ts +0 -12
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as _signe_reactive from '@signe/reactive';
|
|
2
|
+
import { WritableSignal, Signal, WritableArraySignal, WritableObjectSignal } from '@signe/reactive';
|
|
2
3
|
export * from '@signe/reactive';
|
|
3
4
|
import { Subscription, Subject, Observable } from 'rxjs';
|
|
4
|
-
export {
|
|
5
|
+
export { isObservable } from 'rxjs';
|
|
6
|
+
import { Node } from 'yoga-layout';
|
|
5
7
|
import * as PIXI from 'pixi.js';
|
|
6
|
-
import { Graphics as Graphics$1, TextStyle,
|
|
8
|
+
import { ObservablePoint, Graphics as Graphics$1, Texture, TextStyle, Matrix } from 'pixi.js';
|
|
9
|
+
export { Howler } from 'howler';
|
|
7
10
|
import * as popmotion from 'popmotion';
|
|
8
11
|
|
|
9
12
|
interface AnimateOptions<T> {
|
|
10
13
|
duration?: number;
|
|
11
14
|
ease?: (t: number) => number;
|
|
12
15
|
onUpdate?: (value: T) => void;
|
|
16
|
+
onComplete?: () => void;
|
|
13
17
|
}
|
|
14
18
|
interface AnimatedState<T> {
|
|
15
19
|
current: T;
|
|
@@ -18,7 +22,7 @@ interface AnimatedState<T> {
|
|
|
18
22
|
}
|
|
19
23
|
interface AnimatedSignal<T> extends Omit<WritableSignal<T>, 'set'> {
|
|
20
24
|
(): T;
|
|
21
|
-
set: (newValue: T) => void
|
|
25
|
+
set: (newValue: T, options?: AnimateOptions<T>) => Promise<void>;
|
|
22
26
|
animatedState: WritableSignal<AnimatedState<T>>;
|
|
23
27
|
update: (updater: (value: T) => T) => void;
|
|
24
28
|
}
|
|
@@ -42,14 +46,35 @@ declare function isAnimatedSignal(signal: WritableSignal<any>): boolean;
|
|
|
42
46
|
* animatedValue.animatedState() // { current: 10, start: 10, end: 11 }
|
|
43
47
|
*/
|
|
44
48
|
declare function animatedSignal<T>(initialValue: T, options?: AnimateOptions<T>): AnimatedSignal<T>;
|
|
49
|
+
/**
|
|
50
|
+
* Executes a sequence of animations. If an array is provided as an element in the sequence,
|
|
51
|
+
* those animations will be executed in parallel.
|
|
52
|
+
*
|
|
53
|
+
* @param sequence Array of animation functions or arrays of animation functions for parallel execution
|
|
54
|
+
* @returns Promise that resolves when all animations are complete
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* await animatedSequence([
|
|
58
|
+
* () => value1.set(10),
|
|
59
|
+
* [
|
|
60
|
+
* () => value2.set(20),
|
|
61
|
+
* () => value3.set(30)
|
|
62
|
+
* ],
|
|
63
|
+
* () => value1.set(0)
|
|
64
|
+
* ])
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
declare function animatedSequence(sequence: ((() => Promise<void>) | (() => Promise<void>)[])[]): Promise<void>;
|
|
45
68
|
|
|
46
69
|
type SignalOrPrimitive<T> = T | Signal<T> | AnimatedSignal<T>;
|
|
47
70
|
|
|
48
71
|
type FlexDirection = 'row' | 'column' | 'row-reverse' | 'column-reverse';
|
|
49
72
|
type JustifyContent = 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around';
|
|
73
|
+
type AlignContent = 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around';
|
|
50
74
|
type Size = number | `${number}%`;
|
|
51
75
|
type EdgeSize = SignalOrPrimitive<Size | [Size, Size] | [Size, Size, Size, Size]>;
|
|
52
76
|
interface DisplayObjectProps {
|
|
77
|
+
attach?: any;
|
|
53
78
|
ref?: string;
|
|
54
79
|
x?: SignalOrPrimitive<number>;
|
|
55
80
|
y?: SignalOrPrimitive<number>;
|
|
@@ -88,6 +113,7 @@ interface DisplayObjectProps {
|
|
|
88
113
|
}>;
|
|
89
114
|
filters?: any[];
|
|
90
115
|
blendMode?: SignalOrPrimitive<PIXI.BLEND_MODES>;
|
|
116
|
+
blur?: SignalOrPrimitive<number>;
|
|
91
117
|
click?: PIXI.FederatedEventHandler;
|
|
92
118
|
mousedown?: PIXI.FederatedEventHandler;
|
|
93
119
|
mouseenter?: PIXI.FederatedEventHandler;
|
|
@@ -130,6 +156,65 @@ interface ComponentInstance extends PixiMixins.ContainerOptions {
|
|
|
130
156
|
setWidth(width: number): void;
|
|
131
157
|
setHeight(height: number): void;
|
|
132
158
|
}
|
|
159
|
+
declare const EVENTS: string[];
|
|
160
|
+
declare function DisplayObject(extendClass: any): {
|
|
161
|
+
new (): {
|
|
162
|
+
[x: string]: any;
|
|
163
|
+
"__#1@#canvasContext": {
|
|
164
|
+
[key: string]: any;
|
|
165
|
+
} | null;
|
|
166
|
+
isFlex: boolean;
|
|
167
|
+
fullProps: Props;
|
|
168
|
+
isMounted: boolean;
|
|
169
|
+
_anchorPoints: ObservablePoint;
|
|
170
|
+
isCustomAnchor: boolean;
|
|
171
|
+
displayWidth: _signe_reactive.WritableSignal<number>;
|
|
172
|
+
displayHeight: _signe_reactive.WritableSignal<number>;
|
|
173
|
+
overrideProps: string[];
|
|
174
|
+
node: Node;
|
|
175
|
+
readonly yoga: any;
|
|
176
|
+
readonly deltaRatio: any;
|
|
177
|
+
onInit(props: any): void;
|
|
178
|
+
onMount({ parent, props }: Element</*elided*/ any>, index?: number): void;
|
|
179
|
+
effectSize(width: Size, height: Size): void;
|
|
180
|
+
applyFlexLayout(): void;
|
|
181
|
+
"__#1@#flexRender"(props: any): void;
|
|
182
|
+
onUpdate(props: any): void;
|
|
183
|
+
onDestroy(): void;
|
|
184
|
+
getComputedLayout(): {
|
|
185
|
+
left: number;
|
|
186
|
+
right: number;
|
|
187
|
+
top: number;
|
|
188
|
+
bottom: number;
|
|
189
|
+
width: number;
|
|
190
|
+
height: number;
|
|
191
|
+
};
|
|
192
|
+
applyComputedLayout(): void;
|
|
193
|
+
calculateLayout(): void;
|
|
194
|
+
setFlexDirection(direction: FlexDirection): void;
|
|
195
|
+
setFlexWrap(wrap: "wrap" | "nowrap" | "wrap-reverse"): void;
|
|
196
|
+
"__#1@#setAlign"(methodName: string, align: AlignContent): void;
|
|
197
|
+
setAlignContent(align: AlignContent): void;
|
|
198
|
+
setAlignSelf(align: AlignContent): void;
|
|
199
|
+
setAlignItems(align: AlignContent): void;
|
|
200
|
+
setJustifyContent(justifyContent: "flex-start" | "flex-end" | "center" | "space-between" | "space-around"): void;
|
|
201
|
+
"__#1@#setEdgeSize"(methodName: string, size: EdgeSize): void;
|
|
202
|
+
setPosition(position: EdgeSize): void;
|
|
203
|
+
setX(x: number): void;
|
|
204
|
+
setY(y: number): void;
|
|
205
|
+
setPadding(padding: EdgeSize): void;
|
|
206
|
+
setMargin(margin: EdgeSize): void;
|
|
207
|
+
setGap(gap: EdgeSize): void;
|
|
208
|
+
setBorder(border: EdgeSize): void;
|
|
209
|
+
setPositionType(positionType: "relative" | "absolute"): void;
|
|
210
|
+
calculateBounds(): void;
|
|
211
|
+
setWidth(width: number): void;
|
|
212
|
+
setHeight(height: number): void;
|
|
213
|
+
getWidth(): number;
|
|
214
|
+
getHeight(): number;
|
|
215
|
+
};
|
|
216
|
+
[x: string]: any;
|
|
217
|
+
};
|
|
133
218
|
|
|
134
219
|
interface Props {
|
|
135
220
|
[key: string]: any;
|
|
@@ -139,6 +224,12 @@ type ArrayChange<T> = {
|
|
|
139
224
|
index?: number;
|
|
140
225
|
items: T[];
|
|
141
226
|
};
|
|
227
|
+
type ObjectChange<T> = {
|
|
228
|
+
type: "add" | "remove" | "update" | "init" | "reset";
|
|
229
|
+
key?: string;
|
|
230
|
+
value?: T;
|
|
231
|
+
items: T[];
|
|
232
|
+
};
|
|
142
233
|
type NestedSignalObjects = {
|
|
143
234
|
[Key in string]: NestedSignalObjects | Signal<any>;
|
|
144
235
|
};
|
|
@@ -161,10 +252,12 @@ interface Element<T = ComponentInstance> {
|
|
|
161
252
|
destroy: () => void;
|
|
162
253
|
allElements: Subject<void>;
|
|
163
254
|
}
|
|
164
|
-
type
|
|
255
|
+
type FlowResult = {
|
|
165
256
|
elements: Element[];
|
|
166
257
|
prev?: Element;
|
|
167
|
-
|
|
258
|
+
fullElements?: Element[];
|
|
259
|
+
};
|
|
260
|
+
type FlowObservable = Observable<FlowResult>;
|
|
168
261
|
declare const isElement: (value: any) => value is Element;
|
|
169
262
|
declare const isPrimitive: (value: any) => boolean;
|
|
170
263
|
declare function registerComponent(name: any, component: any): void;
|
|
@@ -180,14 +273,21 @@ declare function registerComponent(name: any, component: any): void;
|
|
|
180
273
|
*/
|
|
181
274
|
declare function createComponent(tag: string, props?: Props): Element;
|
|
182
275
|
/**
|
|
183
|
-
* Observes a BehaviorSubject containing an array of items and dynamically creates child elements for each item.
|
|
276
|
+
* Observes a BehaviorSubject containing an array or object of items and dynamically creates child elements for each item.
|
|
184
277
|
*
|
|
185
|
-
* @param {
|
|
278
|
+
* @param {WritableArraySignal<T> | WritableObjectSignal<T>} itemsSubject - A signal that emits an array or object of items.
|
|
186
279
|
* @param {Function} createElementFn - A function that takes an item and returns an element representation.
|
|
187
280
|
* @returns {Observable} An observable that emits the list of created child elements.
|
|
188
281
|
*/
|
|
189
|
-
declare function loop<T
|
|
190
|
-
|
|
282
|
+
declare function loop<T>(itemsSubject: WritableArraySignal<T[]> | WritableObjectSignal<T>, createElementFn: (item: T, index: number | string) => Element | null): FlowObservable;
|
|
283
|
+
/**
|
|
284
|
+
* Conditionally creates and destroys elements based on a condition signal.
|
|
285
|
+
*
|
|
286
|
+
* @param {Signal<boolean> | boolean} condition - A signal or boolean that determines whether to create an element.
|
|
287
|
+
* @param {Function} createElementFn - A function that returns an element or a promise that resolves to an element.
|
|
288
|
+
* @returns {Observable} An observable that emits the created or destroyed element.
|
|
289
|
+
*/
|
|
290
|
+
declare function cond(condition: Signal<boolean> | boolean, createElementFn: () => Element | Promise<Element>): FlowObservable;
|
|
191
291
|
|
|
192
292
|
declare abstract class Directive {
|
|
193
293
|
abstract onDestroy(): any;
|
|
@@ -685,10 +785,26 @@ interface SpritePropsWithSheet extends Omit<SpriteProps, "image" | "rectangle">
|
|
|
685
785
|
params?: any;
|
|
686
786
|
onFinish?: () => void;
|
|
687
787
|
};
|
|
788
|
+
loader?: {
|
|
789
|
+
onProgress?: (progress: number) => void;
|
|
790
|
+
onComplete?: (texture: Texture) => void;
|
|
791
|
+
};
|
|
688
792
|
}
|
|
689
793
|
type SpritePropTypes = SpritePropsWithImage | SpritePropsWithSheet;
|
|
690
794
|
declare const Sprite: ComponentFunction<SpritePropTypes>;
|
|
691
795
|
|
|
796
|
+
interface VideoProps {
|
|
797
|
+
src: string;
|
|
798
|
+
paused?: boolean;
|
|
799
|
+
loop?: boolean;
|
|
800
|
+
muted?: boolean;
|
|
801
|
+
loader?: {
|
|
802
|
+
onComplete?: (texture: Texture) => void;
|
|
803
|
+
onProgress?: (progress: number) => void;
|
|
804
|
+
};
|
|
805
|
+
}
|
|
806
|
+
declare function Video(props: VideoProps): Element<ComponentInstance> | Promise<Element<ComponentInstance>>;
|
|
807
|
+
|
|
692
808
|
interface TextProps extends DisplayObjectProps {
|
|
693
809
|
text?: string;
|
|
694
810
|
style?: Partial<TextStyle>;
|
|
@@ -704,8 +820,6 @@ interface TextProps extends DisplayObjectProps {
|
|
|
704
820
|
}
|
|
705
821
|
declare function Text(props: TextProps): Element<ComponentInstance>;
|
|
706
822
|
|
|
707
|
-
declare function TiledMap(props: any): any;
|
|
708
|
-
|
|
709
823
|
interface TilingSpriteProps extends DisplayObjectProps {
|
|
710
824
|
image?: string;
|
|
711
825
|
tileScale?: {
|
|
@@ -736,8 +850,6 @@ interface ViewportProps {
|
|
|
736
850
|
}
|
|
737
851
|
declare function Viewport(props: ViewportProps): Element<ComponentInstance>;
|
|
738
852
|
|
|
739
|
-
declare function ImageMap(props: any): Element<ComponentInstance> | Promise<Element<ComponentInstance>>;
|
|
740
|
-
|
|
741
853
|
interface NineSliceSpriteProps extends DisplayObjectProps {
|
|
742
854
|
image?: string;
|
|
743
855
|
texture?: Texture;
|
|
@@ -753,15 +865,53 @@ declare function NineSliceSprite(props: NineSliceSpriteProps): Element<Component
|
|
|
753
865
|
|
|
754
866
|
interface Listen<T = any> {
|
|
755
867
|
config: T | undefined;
|
|
756
|
-
seed:
|
|
868
|
+
seed: {
|
|
869
|
+
config: T | undefined;
|
|
870
|
+
value: number;
|
|
871
|
+
resolve: (value: any) => void;
|
|
872
|
+
};
|
|
757
873
|
}
|
|
758
874
|
interface Trigger<T = any> {
|
|
759
|
-
start: () => void
|
|
875
|
+
start: () => Promise<void>;
|
|
760
876
|
listen: () => Listen<T> | undefined;
|
|
761
877
|
}
|
|
878
|
+
/**
|
|
879
|
+
* Checks if the given argument is a Trigger object
|
|
880
|
+
* @param arg - The value to check
|
|
881
|
+
* @returns True if the argument is a Trigger object
|
|
882
|
+
*/
|
|
762
883
|
declare function isTrigger(arg: any): arg is Trigger<any>;
|
|
763
|
-
|
|
764
|
-
|
|
884
|
+
/**
|
|
885
|
+
* Creates a new trigger that can be used to pass data between components
|
|
886
|
+
* @param globalConfig - Optional configuration data to be passed when the trigger is activated
|
|
887
|
+
* @returns A Trigger object with start and listen methods
|
|
888
|
+
* @example
|
|
889
|
+
* ```ts
|
|
890
|
+
* const myTrigger = trigger()
|
|
891
|
+
*
|
|
892
|
+
* on(myTrigger, (data) => {
|
|
893
|
+
* console.log('Triggered with data:', data)
|
|
894
|
+
* })
|
|
895
|
+
*
|
|
896
|
+
* myTrigger.start({ message: 'Hello' })
|
|
897
|
+
* ```
|
|
898
|
+
*/
|
|
899
|
+
declare function trigger<T = any>(globalConfig?: T): Trigger<T>;
|
|
900
|
+
/**
|
|
901
|
+
* Subscribes to a trigger and executes a callback when the trigger is activated
|
|
902
|
+
* @param triggerSignal - The trigger to subscribe to
|
|
903
|
+
* @param callback - Function to execute when the trigger is activated
|
|
904
|
+
* @throws Error if triggerSignal is not a valid trigger
|
|
905
|
+
* @example
|
|
906
|
+
* ```ts
|
|
907
|
+
* const click = trigger()
|
|
908
|
+
*
|
|
909
|
+
* on(click, () => {
|
|
910
|
+
* console.log('Click triggered')
|
|
911
|
+
* })
|
|
912
|
+
* ```
|
|
913
|
+
*/
|
|
914
|
+
declare function on(triggerSignal: any, callback: (config: any) => void | Promise<void>): void;
|
|
765
915
|
|
|
766
916
|
/**
|
|
767
917
|
* Bootstraps a canvas element and renders it to the DOM.
|
|
@@ -814,18 +964,6 @@ type PropSchema = {
|
|
|
814
964
|
*/
|
|
815
965
|
declare const useDefineProps: (props: any) => (schema?: PropSchema) => any;
|
|
816
966
|
|
|
817
|
-
interface BarProps {
|
|
818
|
-
backgroundColor?: string;
|
|
819
|
-
foregroundColor?: string;
|
|
820
|
-
value: number;
|
|
821
|
-
maxValue: number;
|
|
822
|
-
width: number;
|
|
823
|
-
height: number;
|
|
824
|
-
}
|
|
825
|
-
declare function Bar(opts: BarProps): Element<ComponentInstance>;
|
|
826
|
-
|
|
827
|
-
declare function Particle(options: any): Element<ComponentInstance> | Promise<Element<ComponentInstance>>;
|
|
828
|
-
|
|
829
967
|
declare const Easing: {
|
|
830
968
|
linear: popmotion.Easing;
|
|
831
969
|
easeIn: popmotion.Easing;
|
|
@@ -843,4 +981,157 @@ declare const Easing: {
|
|
|
843
981
|
bounceOut: (p: number) => number;
|
|
844
982
|
};
|
|
845
983
|
|
|
846
|
-
|
|
984
|
+
/**
|
|
985
|
+
* Creates a radial gradient texture that can be used in PixiJS.
|
|
986
|
+
* @example
|
|
987
|
+
* const gradient = new RadialGradient(size, size, 0, size, size, 0);
|
|
988
|
+
* gradient.addColorStop(0, "rgba(255, 255, 0, 1)");
|
|
989
|
+
* gradient.addColorStop(0.5, "rgba(255, 255, 0, 0.3)");
|
|
990
|
+
* gradient.addColorStop(0.8, "rgba(255, 255, 0, 0)");
|
|
991
|
+
*/
|
|
992
|
+
declare class RadialGradient {
|
|
993
|
+
private x0;
|
|
994
|
+
private y0;
|
|
995
|
+
private x1;
|
|
996
|
+
private y1;
|
|
997
|
+
private x2;
|
|
998
|
+
private y2;
|
|
999
|
+
private focalPoint;
|
|
1000
|
+
private canvas;
|
|
1001
|
+
private ctx;
|
|
1002
|
+
private gradient;
|
|
1003
|
+
private texture;
|
|
1004
|
+
transform: Matrix;
|
|
1005
|
+
size: number;
|
|
1006
|
+
/**
|
|
1007
|
+
* Creates a new RadialGradient instance
|
|
1008
|
+
* @param x0 - The x-coordinate of the starting circle
|
|
1009
|
+
* @param y0 - The y-coordinate of the starting circle
|
|
1010
|
+
* @param x1 - The x-coordinate of the ending circle
|
|
1011
|
+
* @param y1 - The y-coordinate of the ending circle
|
|
1012
|
+
* @param x2 - The x-coordinate for gradient transformation
|
|
1013
|
+
* @param y2 - The y-coordinate for gradient transformation
|
|
1014
|
+
* @param focalPoint - The focal point of the gradient (0-1), defaults to 0
|
|
1015
|
+
*/
|
|
1016
|
+
constructor(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number, focalPoint?: number);
|
|
1017
|
+
/**
|
|
1018
|
+
* Adds a color stop to the gradient
|
|
1019
|
+
* @param offset - The position of the color stop (0-1)
|
|
1020
|
+
* @param color - The color value (any valid CSS color string)
|
|
1021
|
+
*/
|
|
1022
|
+
addColorStop(offset: number, color: string): void;
|
|
1023
|
+
/**
|
|
1024
|
+
* Renders the gradient and returns the texture with its transformation matrix
|
|
1025
|
+
* @param options - Render options
|
|
1026
|
+
* @param options.translate - Optional translation coordinates
|
|
1027
|
+
* @returns Object containing the texture and transformation matrix
|
|
1028
|
+
*/
|
|
1029
|
+
render({ translate }?: {
|
|
1030
|
+
translate?: {
|
|
1031
|
+
x: number;
|
|
1032
|
+
y: number;
|
|
1033
|
+
};
|
|
1034
|
+
}): {
|
|
1035
|
+
texture: Texture<PIXI.TextureSource<any>>;
|
|
1036
|
+
matrix: Matrix;
|
|
1037
|
+
};
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
/**
|
|
1041
|
+
* Checks if code is running in a browser environment
|
|
1042
|
+
* @returns {boolean} True if running in browser, false otherwise
|
|
1043
|
+
*/
|
|
1044
|
+
declare function isBrowser(): boolean;
|
|
1045
|
+
/**
|
|
1046
|
+
* Returns current high-resolution timestamp
|
|
1047
|
+
* @returns {number} Current time in milliseconds
|
|
1048
|
+
*/
|
|
1049
|
+
declare function preciseNow(): number;
|
|
1050
|
+
/**
|
|
1051
|
+
* Converts frames per second to milliseconds
|
|
1052
|
+
* @param {number} fps - Frames per second
|
|
1053
|
+
* @returns {number} Milliseconds per frame
|
|
1054
|
+
*/
|
|
1055
|
+
declare function fps2ms(fps: number): number;
|
|
1056
|
+
/**
|
|
1057
|
+
* Checks if a value is a Promise
|
|
1058
|
+
* @param {any} value - Value to check
|
|
1059
|
+
* @returns {boolean} True if value is a Promise, false otherwise
|
|
1060
|
+
*/
|
|
1061
|
+
declare function isPromise(value: any): boolean;
|
|
1062
|
+
declare function arrayEquals(a: any[], b: any[]): boolean;
|
|
1063
|
+
/**
|
|
1064
|
+
* Checks if a value is a function
|
|
1065
|
+
* @param {unknown} val - Value to check
|
|
1066
|
+
* @returns {boolean} True if value is a function, false otherwise
|
|
1067
|
+
*/
|
|
1068
|
+
declare function isFunction(val: unknown): boolean;
|
|
1069
|
+
/**
|
|
1070
|
+
* Checks if a value is a plain object
|
|
1071
|
+
* @param {unknown} val - Value to check
|
|
1072
|
+
* @returns {boolean} True if value is an object (not null and not array), false otherwise
|
|
1073
|
+
*/
|
|
1074
|
+
declare function isObject(val: unknown): boolean;
|
|
1075
|
+
/**
|
|
1076
|
+
* Sets a value in an object using a dot notation path
|
|
1077
|
+
* @param {Record<string, any>} obj - Target object
|
|
1078
|
+
* @param {string | string[]} path - Path to set value at (e.g., 'a.b.c' or ['a', 'b', 'c'])
|
|
1079
|
+
* @param {any} value - Value to set
|
|
1080
|
+
* @param {boolean} onlyPlainObject - If true, only creates plain objects in path
|
|
1081
|
+
* @returns {Record<string, any>} Modified object
|
|
1082
|
+
*/
|
|
1083
|
+
declare function set(obj: Record<string, any>, path: string | string[], value: any, onlyPlainObject?: boolean): Record<string, any>;
|
|
1084
|
+
/**
|
|
1085
|
+
* Gets a value from an object using a dot notation path
|
|
1086
|
+
* @param {Record<string, any>} obj - Source object
|
|
1087
|
+
* @param {string} path - Path to get value from (e.g., 'a.b.c')
|
|
1088
|
+
* @returns {any} Value at path or undefined if not found
|
|
1089
|
+
*/
|
|
1090
|
+
declare function get(obj: Record<string, any>, path: string): any;
|
|
1091
|
+
/**
|
|
1092
|
+
* Logs a message to console
|
|
1093
|
+
* @param {any} text - Message to log
|
|
1094
|
+
*/
|
|
1095
|
+
declare function log(text: any): void;
|
|
1096
|
+
/**
|
|
1097
|
+
* Logs an error message to console
|
|
1098
|
+
* @param {any} text - Error message to log
|
|
1099
|
+
*/
|
|
1100
|
+
declare function error(text: any): void;
|
|
1101
|
+
/**
|
|
1102
|
+
* Sets the position of an ObservablePoint using various input formats
|
|
1103
|
+
* @param {ObservablePoint} observablePoint - The point to modify
|
|
1104
|
+
* @param {Object | number | [number, number]} point - New position value
|
|
1105
|
+
*/
|
|
1106
|
+
declare function setObservablePoint(observablePoint: ObservablePoint, point: {
|
|
1107
|
+
x: number;
|
|
1108
|
+
y: number;
|
|
1109
|
+
} | number | [number, number]): void;
|
|
1110
|
+
/**
|
|
1111
|
+
* Calculates the Euclidean distance between two points
|
|
1112
|
+
* @param {number} x1 - X coordinate of first point
|
|
1113
|
+
* @param {number} y1 - Y coordinate of first point
|
|
1114
|
+
* @param {number} x2 - X coordinate of second point
|
|
1115
|
+
* @param {number} y2 - Y coordinate of second point
|
|
1116
|
+
* @returns {number} Distance between the points
|
|
1117
|
+
*/
|
|
1118
|
+
declare function calculateDistance(x1: number, y1: number, x2: number, y2: number): number;
|
|
1119
|
+
|
|
1120
|
+
declare const utils_arrayEquals: typeof arrayEquals;
|
|
1121
|
+
declare const utils_calculateDistance: typeof calculateDistance;
|
|
1122
|
+
declare const utils_error: typeof error;
|
|
1123
|
+
declare const utils_fps2ms: typeof fps2ms;
|
|
1124
|
+
declare const utils_get: typeof get;
|
|
1125
|
+
declare const utils_isBrowser: typeof isBrowser;
|
|
1126
|
+
declare const utils_isFunction: typeof isFunction;
|
|
1127
|
+
declare const utils_isObject: typeof isObject;
|
|
1128
|
+
declare const utils_isPromise: typeof isPromise;
|
|
1129
|
+
declare const utils_log: typeof log;
|
|
1130
|
+
declare const utils_preciseNow: typeof preciseNow;
|
|
1131
|
+
declare const utils_set: typeof set;
|
|
1132
|
+
declare const utils_setObservablePoint: typeof setObservablePoint;
|
|
1133
|
+
declare namespace utils {
|
|
1134
|
+
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_isPromise as isPromise, utils_log as log, utils_preciseNow as preciseNow, utils_set as set, utils_setObservablePoint as setObservablePoint };
|
|
1135
|
+
}
|
|
1136
|
+
|
|
1137
|
+
export { type AnimateOptions, type AnimatedSignal, type AnimatedState, type ArrayChange, Canvas, Circle, type ComponentFunction, type ComponentInstance, Container, DisplayObject, EVENTS, Easing, type Element, Ellipse, Graphics, NineSliceSprite, type ObjectChange, ParticlesEmitter, type Props, RadialGradient, Rect, Scene, Sprite, Text, TilingSprite, Triangle, utils as Utils, Video, Viewport, animatedSequence, animatedSignal, bootstrapCanvas, cond, createComponent, currentSubscriptionsTracker, h, isAnimatedSignal, isElement, isPrimitive, isTrigger, loop, mount, mountTracker, on, registerComponent, Svg as svg, tick, trigger, useDefineProps, useProps };
|