evotars 0.0.12 → 0.0.14

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 CHANGED
@@ -1,5 +1,8 @@
1
+ import { AnimatedSprite } from 'pixi.js';
2
+ import * as PIXI from 'pixi.js';
1
3
  import { SpritesheetData as SpritesheetData_2 } from 'pixi.js';
2
4
  import { SpritesheetFrameData as SpritesheetFrameData_2 } from 'pixi.js';
5
+ import * as TWEEN from '@tweenjs/tween.js';
3
6
 
4
7
  export declare type ActionableData = {
5
8
  arguments: string[];
@@ -16,6 +19,13 @@ export declare type ActionEntity = {
16
19
  data: ActionData;
17
20
  };
18
21
 
22
+ export declare type AddJumpHitsUserActionEntity = {
23
+ name: 'add_jump_hits';
24
+ data: {
25
+ count: number;
26
+ };
27
+ } & UserActionEntity;
28
+
19
29
  declare type AppOptions = {
20
30
  font?: string;
21
31
  sounds?: SoundOptions;
@@ -29,6 +39,13 @@ declare type Collider = {
29
39
  h: number;
30
40
  };
31
41
 
42
+ export declare type ColorUserActionEntity = {
43
+ name: 'color';
44
+ data: {
45
+ color: string;
46
+ };
47
+ } & UserActionEntity;
48
+
32
49
  export declare type DashUserActionEntity = {
33
50
  name: 'dash';
34
51
  data: {
@@ -36,6 +53,95 @@ export declare type DashUserActionEntity = {
36
53
  };
37
54
  } & UserActionEntity;
38
55
 
56
+ declare class Evotar {
57
+ container: PIXI.Container;
58
+ private userState;
59
+ state: EvotarState;
60
+ private animationState;
61
+ private sprite?;
62
+ trail: EvotarTrailEffect;
63
+ private name;
64
+ private info;
65
+ private message;
66
+ private emoteSpitter;
67
+ private velocity;
68
+ private runSpeed;
69
+ private gravity;
70
+ private dashAcc;
71
+ private isJumping;
72
+ private isHitJumping;
73
+ private isDashing;
74
+ private isDespawned;
75
+ isDead: boolean;
76
+ deathTimer?: Timer;
77
+ landTimer?: Timer;
78
+ stateTimer?: Timer;
79
+ scaleTimer?: Timer;
80
+ spawnTween?: TWEEN.Tween<PIXI.Container>;
81
+ fadeTween?: TWEEN.Tween<PIXI.Container>;
82
+ scaleTween?: TWEEN.Tween<Evotar>;
83
+ private offset;
84
+ private screenBounds;
85
+ getCenterOffsetY(): number;
86
+ getCenterPosition(): PIXI.PointData;
87
+ setPosition(position: PIXI.PointData): void;
88
+ getScale(): number;
89
+ getCollider(): Collider;
90
+ constructor();
91
+ resurrect(): Promise<void>;
92
+ die(): Promise<void>;
93
+ spawn(props?: EvotarSpawnProps): void;
94
+ despawn(props?: EvotarDepawnProps): void;
95
+ scale(options: {
96
+ value: number;
97
+ duration: number;
98
+ }): void;
99
+ addJumpHit(count: number): void;
100
+ canDoAction(): boolean;
101
+ jump(options?: EvotarJumpProps): Promise<void>;
102
+ dash(options: {
103
+ force: number;
104
+ }): void;
105
+ setSprite(sprite: string): Promise<void>;
106
+ setProps(props: EvotarProps): Promise<void>;
107
+ setUserProps(props: UserProps): void;
108
+ private move;
109
+ jumpHit(): void;
110
+ update(): void;
111
+ isOnGround(y: number): boolean;
112
+ addMessage(message: string): void;
113
+ spitEmotes(emotes: string[]): Promise<void>;
114
+ setAnimationState(state: EvotarSpriteTags, force?: boolean): Promise<void>;
115
+ }
116
+
117
+ declare type EvotarAnimatedSprites = {
118
+ [tag in string]: EvotarLayerSprites;
119
+ };
120
+
121
+ declare type EvotarDepawnProps = {
122
+ onComplete?: () => void;
123
+ };
124
+
125
+ declare type EvotarJumpProps = {
126
+ velocityX?: number;
127
+ velocityY?: number;
128
+ };
129
+
130
+ declare type EvotarLayerSprites = {
131
+ [layer in string]: AnimatedSprite;
132
+ };
133
+
134
+ declare type EvotarProps = {
135
+ name?: string;
136
+ sprite?: string;
137
+ color?: PIXI.Color;
138
+ direction?: number;
139
+ scale?: number;
140
+ isAnonymous?: boolean;
141
+ isImmortal?: boolean;
142
+ zIndex?: number;
143
+ };
144
+
39
145
  export declare class Evotars {
40
146
  private readonly root;
41
147
  private readonly options;
@@ -44,11 +150,73 @@ export declare class Evotars {
44
150
  processMessage: (data: MessageEntity) => Promise<void>;
45
151
  processAction: (data: UserActionEntity) => Promise<void>;
46
152
  processChatters: (data: TwitchChatterEntity[]) => Promise<void>;
47
- processRaid: (data: RaidEntity) => void;
153
+ processRaid: (data: RaidEntity) => Promise<void>;
154
+ get manager(): {
155
+ viewers: Record<string, Evotar | undefined>;
156
+ tombstones: TombStone[];
157
+ raiders: Evotar[];
158
+ recentEvotarActivity: Record<string, number | undefined>;
159
+ subscriptions: {
160
+ onAdd: (evotar: Evotar) => void;
161
+ onDelete: (evotar: Evotar) => void;
162
+ }[];
163
+ subscribe(subscription: {
164
+ onAdd: (evotar: Evotar) => void;
165
+ onDelete: (evotar: Evotar) => void;
166
+ }): void;
167
+ update(): void;
168
+ getEvotars(): (Evotar | undefined)[];
169
+ spawnViewerEvotar(userId: string, props: EvotarProps, spawnProps: EvotarSpawnProps): Promise<Evotar>;
170
+ processRaid(data: RaidEntity): Promise<void>;
171
+ despawnTombStone(evotar: Evotar): void;
172
+ despawnRaider(evotar: Evotar): void;
173
+ despawnViewer(id: string, evotar: Evotar): void;
174
+ processChatters(data: TwitchChatterEntity[]): Promise<void>;
175
+ hasActivity: (userId: string) => boolean;
176
+ doAction(action: UserActionEntity, evotar: Evotar): void;
177
+ prepareEvotarProps(name: string, color?: string | undefined, sprite?: string | undefined): EvotarProps;
178
+ processAction(action: UserActionEntity): Promise<void>;
179
+ processMessage(data: MessageEntity): Promise<void>;
180
+ resurrect(evotar: Evotar): void;
181
+ kill(evotar: Evotar): void;
182
+ addTombStone(object: TombStone): void;
183
+ deleteTombStone(object: TombStone): void;
184
+ addViewer(id: string, evotar: Evotar): void;
185
+ deleteViewer(id: string, evotar: Evotar): void;
186
+ addRaider(evotar: Evotar): void;
187
+ deleteRaider(evotar: Evotar): void;
188
+ zIndexEvotarMax(from: number): number;
189
+ zIndexEvotarMin(from: number): number;
190
+ };
48
191
  updateSettings(data: SettingsEntity): void;
49
192
  run(): Promise<void>;
50
193
  }
51
194
 
195
+ declare type EvotarSpawnProps = {
196
+ isFalling?: boolean;
197
+ positionX?: number;
198
+ onComplete?: () => void;
199
+ };
200
+
201
+ declare class EvotarSpriteContainer {
202
+ private sprites;
203
+ data: EvotarSpriteData;
204
+ container: PIXI.Container;
205
+ private currentTag;
206
+ constructor(sprites: EvotarAnimatedSprites, data: EvotarSpriteData);
207
+ getLayersByTag(tag: EvotarSpriteTags): EvotarLayerSprites;
208
+ setTag(tag?: EvotarSpriteTags): void;
209
+ update(props: EvotarSpriteContainerProps): void;
210
+ }
211
+
212
+ declare type EvotarSpriteContainerProps = {
213
+ color: {
214
+ [key in string]?: PIXI.Color;
215
+ };
216
+ scale: Point;
217
+ play: boolean;
218
+ };
219
+
52
220
  declare type EvotarSpriteData = {
53
221
  name: string;
54
222
  collider: Collider;
@@ -58,6 +226,32 @@ declare type EvotarSpriteData = {
58
226
  colored: string[];
59
227
  };
60
228
 
229
+ declare enum EvotarSpriteTags {
230
+ Idle = "Idle",
231
+ Jump = "Jump",
232
+ Fall = "Fall",
233
+ Land = "Land",
234
+ Run = "Run",
235
+ Die = "Die"
236
+ }
237
+
238
+ declare type EvotarState = Required<EvotarProps>;
239
+
240
+ declare class EvotarTrailEffect {
241
+ container: PIXI.Container;
242
+ private timer?;
243
+ private sprite?;
244
+ private opacityStep;
245
+ private shadowStep;
246
+ constructor();
247
+ setSprite(sprite: EvotarSpriteContainer): void;
248
+ update(props: EvotarTrailEffectProps): void;
249
+ }
250
+
251
+ declare type EvotarTrailEffectProps = {
252
+ play: boolean;
253
+ };
254
+
61
255
  export declare type GrowUserActionEntity = {
62
256
  name: 'grow';
63
257
  data: {
@@ -66,18 +260,20 @@ export declare type GrowUserActionEntity = {
66
260
  };
67
261
  } & UserActionEntity;
68
262
 
69
- export declare type InfoUserActionEntity = {
70
- name: 'info';
71
- } & UserActionEntity;
263
+ export declare const isAddJumpHitsUserActionEntity: (entity: ActionEntity) => entity is AddJumpHitsUserActionEntity;
264
+
265
+ export declare const isColorUserActionEntity: (entity: ActionEntity) => entity is ColorUserActionEntity;
72
266
 
73
267
  export declare const isDashUserActionEntity: (entity: ActionEntity) => entity is DashUserActionEntity;
74
268
 
75
269
  export declare const isGrowUserActionEntity: (entity: ActionEntity) => entity is GrowUserActionEntity;
76
270
 
77
- export declare const isInfoUserActionEntity: (entity: ActionEntity) => entity is InfoUserActionEntity;
78
-
79
271
  export declare const isJumpUserActionEntity: (entity: ActionEntity) => entity is JumpUserActionEntity;
80
272
 
273
+ export declare const isResurrectUserActionEntity: (entity: ActionEntity) => entity is ResurrectUserActionEntity;
274
+
275
+ export declare const isSpriteUserActionEntity: (entity: ActionEntity) => entity is SpriteUserActionEntity;
276
+
81
277
  export declare type JumpUserActionEntity = {
82
278
  name: 'jump';
83
279
  data: {
@@ -93,6 +289,11 @@ export declare type MessageEntity = {
93
289
  info: UserInfo;
94
290
  };
95
291
 
292
+ declare type Point = {
293
+ x?: number;
294
+ y?: number;
295
+ };
296
+
96
297
  export declare type RaidEntity = {
97
298
  broadcaster: {
98
299
  id: string;
@@ -104,6 +305,11 @@ export declare type RaidEntity = {
104
305
  };
105
306
  };
106
307
 
308
+ export declare type ResurrectUserActionEntity = {
309
+ name: 'resurrect';
310
+ data: {};
311
+ } & UserActionEntity;
312
+
107
313
  export declare type SettingsEntity = {
108
314
  showAnonymousEvotars?: boolean;
109
315
  fallingEvotars?: boolean;
@@ -135,6 +341,36 @@ declare type SpriteSize = {
135
341
  h: number;
136
342
  };
137
343
 
344
+ export declare type SpriteUserActionEntity = {
345
+ name: 'sprite';
346
+ data: {
347
+ sprite: string;
348
+ };
349
+ } & UserActionEntity;
350
+
351
+ declare class Timer {
352
+ current: number;
353
+ private onComplete?;
354
+ isCompleted: boolean;
355
+ constructor(current?: number, onComplete?: (() => void) | undefined);
356
+ tick(delta?: number): void;
357
+ complete(): void;
358
+ }
359
+
360
+ declare class TombStone {
361
+ readonly evotar: Evotar;
362
+ container: PIXI.Container;
363
+ private sprite;
364
+ private gravity;
365
+ private velocity;
366
+ fadeTween?: TWEEN.Tween<PIXI.Container>;
367
+ constructor(evotar: Evotar);
368
+ isOnGround(y: number): boolean;
369
+ update(): void;
370
+ despawn(smooth?: boolean, onComplete?: () => void): void;
371
+ spawn(): void;
372
+ }
373
+
138
374
  export declare type TwitchChatterEntity = {
139
375
  userId: string;
140
376
  name: string;
@@ -142,7 +378,6 @@ export declare type TwitchChatterEntity = {
142
378
 
143
379
  export declare type UserActionEntity = {
144
380
  userId: string;
145
- cooldown: number;
146
381
  info: UserInfo;
147
382
  } & ActionEntity;
148
383
 
@@ -160,4 +395,8 @@ export declare type UserInfo = {
160
395
  color?: string;
161
396
  };
162
397
 
398
+ declare type UserProps = {
399
+ color?: PIXI.Color;
400
+ };
401
+
163
402
  export { }
@@ -1,7 +1,7 @@
1
- import { E as b, U as pt, T as pe, O as q, M as U, N as Fe, c as Me, w as L, j as R, P as gt, t as Re, K as k, L as H, b as Q, B as D, I, Q as mt, V as xt, a as _t, W as re, X as z, R as V, Y as bt, Z as M, _ as E, $ as yt, q as B, a0 as Tt, D as $, a1 as wt, a2 as Z, a3 as vt, m as St, a4 as Ct, a5 as se, n as ge, e as P, a6 as Bt } from "./index-B5GUB2He.js";
2
- import { U as Y, T as A, R as ne, S as Ae, i as ae, b as ke, c as Ue, j as Ge, e as Pt, r as ze, o as Ft, n as He, a as Mt, g as Rt, k as At, m as kt, B as Ie } from "./colorToUniform-Cp4M-zOy.js";
3
- import { C as W } from "./CanvasPool-5ekdWScU.js";
4
- import { g as Ut } from "./getBatchSamplersUniformGroup-CIYh8OT7.js";
1
+ import { E as b, U as pt, T as pe, O as q, M as U, N as Fe, c as Me, w as L, j as R, P as gt, t as Re, K as k, L as H, b as Q, B as D, I, Q as mt, V as xt, a as _t, W as re, X as z, R as V, Y as bt, Z as M, _ as E, $ as yt, q as B, a0 as Tt, D as $, a1 as wt, a2 as Z, a3 as vt, m as St, a4 as Ct, a5 as se, n as ge, e as P, a6 as Bt } from "./index-B90O-olH.js";
2
+ import { U as Y, T as A, R as ne, S as Ae, i as ae, b as ke, c as Ue, j as Ge, e as Pt, r as ze, o as Ft, n as He, a as Mt, g as Rt, k as At, m as kt, B as Ie } from "./colorToUniform-B386n34M.js";
3
+ import { C as W } from "./CanvasPool-CVUDTUp2.js";
4
+ import { g as Ut } from "./getBatchSamplersUniformGroup-DAYmfPu3.js";
5
5
  class We {
6
6
  /**
7
7
  * Initialize the plugin with scope of application instance
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.12",
2
+ "version": "0.0.14",
3
3
  "name": "evotars",
4
4
  "description": "Show animated characters on stream",
5
5
  "author": "Mikhail Morozov",