canvasengine 2.0.0-beta.15 → 2.0.0-beta.17
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 +55 -25
- package/dist/index.js +361 -238
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/src/components/Canvas.ts +53 -45
- package/src/components/Container.ts +2 -2
- package/src/components/DisplayObject.ts +232 -173
- package/src/components/Graphic.ts +18 -7
- package/src/components/NineSliceSprite.ts +4 -1
- package/src/components/ParticleEmitter.ts +12 -8
- package/src/components/Sprite.ts +7 -4
- package/src/components/Text.ts +26 -10
- package/src/components/Viewport.ts +53 -31
- package/src/components/types/DisplayObject.ts +22 -0
- package/src/directives/ViewportFollow.ts +1 -1
- package/src/engine/bootstrap.ts +14 -2
- package/src/engine/reactive.ts +5 -4
- package/src/index.ts +1 -0
- package/src/utils/functions.ts +7 -0
- package/testing/index.ts +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -3,9 +3,8 @@ import { WritableSignal, Signal } from '@signe/reactive';
|
|
|
3
3
|
export * from '@signe/reactive';
|
|
4
4
|
import { Subscription, Subject, Observable } from 'rxjs';
|
|
5
5
|
export { isObservable } from 'rxjs';
|
|
6
|
-
import { Node } from 'yoga-layout';
|
|
7
6
|
import * as PIXI from 'pixi.js';
|
|
8
|
-
import { FederatedPointerEvent, ObservablePoint, Graphics as Graphics$1, Texture, TextStyle, Matrix } from 'pixi.js';
|
|
7
|
+
import { FederatedPointerEvent, ObservablePoint, Graphics as Graphics$1, Texture, TextStyle, Application, Matrix } from 'pixi.js';
|
|
9
8
|
import * as howler from 'howler';
|
|
10
9
|
export { howler as Howl };
|
|
11
10
|
export { Howler } from 'howler';
|
|
@@ -96,6 +95,10 @@ type JustifyContent = 'flex-start' | 'flex-end' | 'center' | 'space-between' | '
|
|
|
96
95
|
type AlignContent = 'flex-start' | 'flex-end' | 'center' | 'space-between' | 'space-around';
|
|
97
96
|
type Size = number | `${number}%`;
|
|
98
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';
|
|
99
102
|
interface DisplayObjectProps {
|
|
100
103
|
attach?: any;
|
|
101
104
|
ref?: string;
|
|
@@ -103,6 +106,24 @@ interface DisplayObjectProps {
|
|
|
103
106
|
y?: SignalOrPrimitive<number>;
|
|
104
107
|
width?: SignalOrPrimitive<Size>;
|
|
105
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;
|
|
106
127
|
children?: any[];
|
|
107
128
|
flexDirection?: FlexDirection;
|
|
108
129
|
justifyContent?: JustifyContent;
|
|
@@ -176,12 +197,13 @@ interface ComponentInstance extends PixiMixins.ContainerOptions {
|
|
|
176
197
|
children?: ComponentInstance[];
|
|
177
198
|
onInit?(props: Props): void;
|
|
178
199
|
onUpdate?(props: Props): void;
|
|
179
|
-
onDestroy?(parent: Element): void;
|
|
200
|
+
onDestroy?(parent: Element, afterDestroy: () => void): void;
|
|
180
201
|
onMount?(context: Element, index?: number): void;
|
|
181
202
|
setWidth(width: number): void;
|
|
182
203
|
setHeight(height: number): void;
|
|
183
204
|
}
|
|
184
205
|
declare const EVENTS: string[];
|
|
206
|
+
type OnHook = (() => void) | (() => Promise<void> | void);
|
|
185
207
|
declare function DisplayObject(extendClass: any): {
|
|
186
208
|
new (): {
|
|
187
209
|
[x: string]: any;
|
|
@@ -196,34 +218,20 @@ declare function DisplayObject(extendClass: any): {
|
|
|
196
218
|
displayWidth: _signe_reactive.WritableSignal<number>;
|
|
197
219
|
displayHeight: _signe_reactive.WritableSignal<number>;
|
|
198
220
|
overrideProps: string[];
|
|
199
|
-
|
|
200
|
-
|
|
221
|
+
layout: any;
|
|
222
|
+
onBeforeDestroy: OnHook | null;
|
|
223
|
+
onAfterMount: OnHook | null;
|
|
201
224
|
readonly deltaRatio: any;
|
|
202
225
|
onInit(props: any): void;
|
|
203
|
-
onMount({ parent, props }: Element</*elided*/ any>, index?: number): void
|
|
204
|
-
effectSize(width: Size, height: Size): void;
|
|
205
|
-
applyFlexLayout(): void;
|
|
206
|
-
"__#1@#flexRender"(props: any): void;
|
|
226
|
+
onMount({ parent, props }: Element</*elided*/ any>, index?: number): Promise<void>;
|
|
207
227
|
onUpdate(props: any): void;
|
|
208
|
-
onDestroy(): void
|
|
209
|
-
getComputedLayout(): {
|
|
210
|
-
left: number;
|
|
211
|
-
right: number;
|
|
212
|
-
top: number;
|
|
213
|
-
bottom: number;
|
|
214
|
-
width: number;
|
|
215
|
-
height: number;
|
|
216
|
-
};
|
|
217
|
-
applyComputedLayout(): void;
|
|
218
|
-
calculateLayout(): void;
|
|
228
|
+
onDestroy(parent: Element, afterDestroy?: () => void): Promise<void>;
|
|
219
229
|
setFlexDirection(direction: FlexDirection): void;
|
|
220
230
|
setFlexWrap(wrap: "wrap" | "nowrap" | "wrap-reverse"): void;
|
|
221
|
-
"__#1@#setAlign"(methodName: string, align: AlignContent): void;
|
|
222
231
|
setAlignContent(align: AlignContent): void;
|
|
223
232
|
setAlignSelf(align: AlignContent): void;
|
|
224
233
|
setAlignItems(align: AlignContent): void;
|
|
225
234
|
setJustifyContent(justifyContent: "flex-start" | "flex-end" | "center" | "space-between" | "space-around"): void;
|
|
226
|
-
"__#1@#setEdgeSize"(methodName: string, size: EdgeSize): void;
|
|
227
235
|
setPosition(position: EdgeSize): void;
|
|
228
236
|
setX(x: number): void;
|
|
229
237
|
setY(y: number): void;
|
|
@@ -232,11 +240,27 @@ declare function DisplayObject(extendClass: any): {
|
|
|
232
240
|
setGap(gap: EdgeSize): void;
|
|
233
241
|
setBorder(border: EdgeSize): void;
|
|
234
242
|
setPositionType(positionType: "relative" | "absolute"): void;
|
|
235
|
-
calculateBounds(): void;
|
|
236
243
|
setWidth(width: number): void;
|
|
237
244
|
setHeight(height: number): void;
|
|
238
245
|
getWidth(): number;
|
|
239
246
|
getHeight(): number;
|
|
247
|
+
setMinWidth(minWidth: number | string): void;
|
|
248
|
+
setMinHeight(minHeight: number | string): void;
|
|
249
|
+
setMaxWidth(maxWidth: number | string): void;
|
|
250
|
+
setMaxHeight(maxHeight: number | string): void;
|
|
251
|
+
setAspectRatio(aspectRatio: number): void;
|
|
252
|
+
setFlexGrow(flexGrow: number): void;
|
|
253
|
+
setFlexShrink(flexShrink: number): void;
|
|
254
|
+
setFlexBasis(flexBasis: number | string): void;
|
|
255
|
+
setRowGap(rowGap: number): void;
|
|
256
|
+
setColumnGap(columnGap: number): void;
|
|
257
|
+
setTop(top: number | string): void;
|
|
258
|
+
setLeft(left: number | string): void;
|
|
259
|
+
setRight(right: number | string): void;
|
|
260
|
+
setBottom(bottom: number | string): void;
|
|
261
|
+
setObjectFit(objectFit: ObjectFit): void;
|
|
262
|
+
setObjectPosition(objectPosition: ObjectPosition): void;
|
|
263
|
+
setTransformOrigin(transformOrigin: TransformOrigin): void;
|
|
240
264
|
};
|
|
241
265
|
[x: string]: any;
|
|
242
266
|
};
|
|
@@ -393,6 +417,7 @@ interface CanvasProps extends Props {
|
|
|
393
417
|
isRoot?: boolean;
|
|
394
418
|
tick?: any;
|
|
395
419
|
class?: SignalOrPrimitive<string>;
|
|
420
|
+
background?: string;
|
|
396
421
|
}
|
|
397
422
|
declare const Canvas: ComponentFunction<CanvasProps>;
|
|
398
423
|
|
|
@@ -826,6 +851,7 @@ interface TextProps extends DisplayObjectProps {
|
|
|
826
851
|
onComplete?: () => void;
|
|
827
852
|
skip?: () => void;
|
|
828
853
|
};
|
|
854
|
+
context?: any;
|
|
829
855
|
}
|
|
830
856
|
declare function Text(props: TextProps): Element<ComponentInstance>;
|
|
831
857
|
|
|
@@ -844,7 +870,7 @@ interface TilingSpriteProps extends DisplayObjectProps {
|
|
|
844
870
|
}
|
|
845
871
|
declare function TilingSprite(props: TilingSpriteProps): Element<ComponentInstance>;
|
|
846
872
|
|
|
847
|
-
interface ViewportProps {
|
|
873
|
+
interface ViewportProps extends Props {
|
|
848
874
|
screenWidth?: number;
|
|
849
875
|
screenHeight?: number;
|
|
850
876
|
worldWidth?: number;
|
|
@@ -855,6 +881,7 @@ interface ViewportProps {
|
|
|
855
881
|
top?: number;
|
|
856
882
|
bottom?: number;
|
|
857
883
|
};
|
|
884
|
+
context?: any;
|
|
858
885
|
[key: string]: any;
|
|
859
886
|
}
|
|
860
887
|
declare function Viewport(props: ViewportProps): Element<ComponentInstance>;
|
|
@@ -930,7 +957,10 @@ declare function on(triggerSignal: any, callback: (config: any) => void | Promis
|
|
|
930
957
|
* @returns A Promise that resolves to the rendered canvas element.
|
|
931
958
|
* @throws {Error} If the provided element is not a Canvas component.
|
|
932
959
|
*/
|
|
933
|
-
declare const bootstrapCanvas: (rootElement: HTMLElement | null, canvas: ComponentFunction<any>) => Promise<
|
|
960
|
+
declare const bootstrapCanvas: (rootElement: HTMLElement | null, canvas: ComponentFunction<any>) => Promise<{
|
|
961
|
+
canvasElement: Element<ComponentInstance>;
|
|
962
|
+
app: Application<PIXI.Renderer>;
|
|
963
|
+
}>;
|
|
934
964
|
|
|
935
965
|
/**
|
|
936
966
|
* Converts props into reactive signals if they are primitive values.
|