Skip to content

Commit 7cf63f6

Browse files
committed
Patch types
1 parent 6b31039 commit 7cf63f6

File tree

6 files changed

+29
-14
lines changed

6 files changed

+29
-14
lines changed

.changeset/nine-elephants-poke.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"stage-js": patch
3+
---
4+
5+
Patch types

.prettierrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"printWidth": 100
2+
"printWidth": 100,
3+
"quoteProps": "preserve"
34
}

src/core/anim.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ export class Anim extends Node {
111111
return this;
112112
}
113113

114-
moveFrame(move) {
114+
moveFrame(move: number) {
115115
return this.gotoFrame(this._index + move);
116116
}
117117

118-
repeat(repeat, callback) {
118+
repeat(repeat: number, callback?: () => void) {
119119
this._repeat = repeat * this._frames.length - 1;
120120
this._callback = callback;
121121
this.play();

src/core/core.ts

+1
Original file line numberDiff line numberDiff line change
@@ -948,6 +948,7 @@ export class Node implements Pinned {
948948

949949
scale(value: Vec2Value): this;
950950
scale(x: number, y: number): this;
951+
scale(s: number): this;
951952
scale(a?: Vec2Value | number, b?: number) {
952953
// Pin shortcut, used by Transition and Node
953954
if (typeof a === "object") {

src/core/transition.ts

+1
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ export class Transition implements Pinned {
237237

238238
scale(value: Vec2Value): this;
239239
scale(x: number, y: number): this;
240+
scale(s: number): this;
240241
scale(a: number | Vec2Value, b?: number) {
241242
// Pin shortcut, used by Transition and Node
242243
if (typeof a === "object") {

src/texture/atlas.ts

+18-11
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,26 @@ export interface AtlasTextureDefinition {
1717
bottom?: number;
1818
}
1919

20-
type AtlasTextureReferenceOne = AtlasTextureDefinition | string;
21-
type AtlasTextureReferenceMap = Record<string, AtlasTextureReferenceOne>;
22-
type AtlasTextureReferenceArray = AtlasTextureReferenceOne[];
20+
type MonotypeAtlasTextureDefinition = Record<string, AtlasTextureDefinition | Texture | string>;
21+
type AnimAtlasTextureDefinition = (AtlasTextureDefinition | Texture | string)[];
2322

2423
export interface AtlasDefinition {
2524
name?: string;
26-
image?: {
27-
/** @deprecated */
28-
url: string;
29-
src: string;
30-
ratio?: number;
31-
};
25+
image?:
26+
| {
27+
src: string;
28+
ratio?: number;
29+
}
30+
| {
31+
/** @deprecated Use src instead of url */
32+
url: string;
33+
ratio?: number;
34+
};
3235

3336
ppu?: number;
3437
textures?: Record<
3538
string,
36-
AtlasTextureDefinition | AtlasTextureReferenceMap | AtlasTextureReferenceArray
39+
AtlasTextureDefinition | Texture | MonotypeAtlasTextureDefinition | AnimAtlasTextureDefinition
3740
>;
3841

3942
map?: (texture: AtlasTextureDefinition) => AtlasTextureDefinition;
@@ -72,7 +75,11 @@ export class Atlas extends ImageTexture {
7275
this._textures = def.textures;
7376

7477
if (typeof def.image === "object" && isHash(def.image)) {
75-
this._imageSrc = def.image.src || def.image.url;
78+
if ("src" in def.image) {
79+
this._imageSrc = def.image.src;
80+
} else if ("url" in def.image) {
81+
this._imageSrc = def.image.url;
82+
}
7683
if (typeof def.image.ratio === "number") {
7784
this._pixelRatio = def.image.ratio;
7885
}

0 commit comments

Comments
 (0)