evotars 0.0.8 → 0.0.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 CHANGED
@@ -1 +1,175 @@
1
- export * from './evotars';
1
+ import { ISpritesheetData } from 'pixi.js';
2
+ import { ISpritesheetFrameData } from 'pixi.js';
3
+
4
+ export declare type ActionableData = {
5
+ arguments: string[];
6
+ action: ActionData;
7
+ };
8
+
9
+ export declare type ActionData = Record<string, string | number | undefined>;
10
+
11
+ export declare type ActionEntity = {
12
+ id: number;
13
+ name: string;
14
+ title: string;
15
+ description: string;
16
+ data: ActionData;
17
+ };
18
+
19
+ declare type AppOptions = {
20
+ font?: string;
21
+ sounds?: SoundOptions;
22
+ spriteLoaderFn: SpriteLoaderFn;
23
+ };
24
+
25
+ declare type Collider = {
26
+ x: number;
27
+ y: number;
28
+ w: number;
29
+ h: number;
30
+ };
31
+
32
+ export declare type ColorUserActionEntity = {
33
+ name: 'color';
34
+ data: {
35
+ color: string;
36
+ };
37
+ } & UserActionEntity;
38
+
39
+ export declare type DashUserActionEntity = {
40
+ name: 'dash';
41
+ data: {
42
+ force: number;
43
+ };
44
+ } & UserActionEntity;
45
+
46
+ export declare class Evotars {
47
+ private readonly root;
48
+ private readonly options;
49
+ private isRendered;
50
+ constructor(root: HTMLElement, options: AppOptions);
51
+ processMessage: (data: MessageEntity) => Promise<void>;
52
+ processAction: (data: UserActionEntity) => Promise<void>;
53
+ processChatters: (data: TwitchChatterEntity[]) => Promise<void>;
54
+ processRaid: (data: RaidEntity) => void;
55
+ updateSettings(data: SettingsEntity): void;
56
+ run(): Promise<void>;
57
+ }
58
+
59
+ declare type EvotarSpriteData = {
60
+ name: string;
61
+ collider: Collider;
62
+ size: SpriteSize;
63
+ scale: number;
64
+ flip: boolean;
65
+ colored: string[];
66
+ };
67
+
68
+ export declare type GrowUserActionEntity = {
69
+ name: 'grow';
70
+ data: {
71
+ duration: number;
72
+ scale: number;
73
+ };
74
+ } & UserActionEntity;
75
+
76
+ export declare const isColorUserActionEntity: (entity: ActionEntity) => entity is ColorUserActionEntity;
77
+
78
+ export declare const isDashUserActionEntity: (entity: ActionEntity) => entity is DashUserActionEntity;
79
+
80
+ export declare const isGrowUserActionEntity: (entity: ActionEntity) => entity is GrowUserActionEntity;
81
+
82
+ export declare const isJumpUserActionEntity: (entity: ActionEntity) => entity is JumpUserActionEntity;
83
+
84
+ export declare const isSpriteUserActionEntity: (entity: ActionEntity) => entity is SpriteUserActionEntity;
85
+
86
+ export declare type JumpUserActionEntity = {
87
+ name: 'jump';
88
+ data: {
89
+ velocityX: number;
90
+ velocityY: number;
91
+ };
92
+ } & UserActionEntity;
93
+
94
+ export declare type MessageEntity = {
95
+ userId: string;
96
+ message: string;
97
+ emotes: string[];
98
+ info: UserInfo;
99
+ };
100
+
101
+ export declare type RaidEntity = {
102
+ broadcaster: {
103
+ id: string;
104
+ info: UserInfo;
105
+ };
106
+ viewers: {
107
+ count: number;
108
+ sprite: string;
109
+ };
110
+ };
111
+
112
+ export declare type SettingsEntity = {
113
+ showAnonymousEvotars?: boolean;
114
+ fallingEvotars?: boolean;
115
+ fallingRaiders?: boolean;
116
+ };
117
+
118
+ declare type SoundOptions = {
119
+ jump?: {
120
+ src: string;
121
+ };
122
+ };
123
+
124
+ declare type SpriteLoaderFn = (name: string) => Promise<{
125
+ sprite: SpritesheetData;
126
+ data: EvotarSpriteData;
127
+ image: string;
128
+ } | undefined>;
129
+
130
+ declare interface SpritesheetData extends ISpritesheetData {
131
+ frames: Record<string, SpritesheetFrameData>;
132
+ }
133
+
134
+ declare interface SpritesheetFrameData extends ISpritesheetFrameData {
135
+ duration: number;
136
+ }
137
+
138
+ declare type SpriteSize = {
139
+ w: number;
140
+ h: number;
141
+ };
142
+
143
+ export declare type SpriteUserActionEntity = {
144
+ name: 'sprite';
145
+ data: {
146
+ sprite: string;
147
+ };
148
+ } & UserActionEntity;
149
+
150
+ export declare type TwitchChatterEntity = {
151
+ userId: string;
152
+ name: string;
153
+ };
154
+
155
+ export declare type UserActionEntity = {
156
+ userId: string;
157
+ cooldown: number;
158
+ info: UserInfo;
159
+ } & ActionEntity;
160
+
161
+ export declare type UserEntity = {
162
+ userId: number;
163
+ guid: string;
164
+ displayName: string;
165
+ profileImageUrl: string;
166
+ previewUrl: string;
167
+ };
168
+
169
+ export declare type UserInfo = {
170
+ displayName: string;
171
+ sprite: string;
172
+ color?: string;
173
+ };
174
+
175
+ export { }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.8",
2
+ "version": "0.0.10",
3
3
  "name": "evotars",
4
4
  "description": "Show animated characters on stream",
5
5
  "author": "Mikhail Morozov",
package/dist/app.d.ts DELETED
@@ -1,24 +0,0 @@
1
- import { SpriteLoaderFn } from './services/spriteService';
2
- import { SettingsEntity } from './types';
3
- import { SoundOptions } from './services/soundService';
4
- import { Evotar } from './entities/Evotar';
5
- import * as PIXI from 'pixi.js';
6
- export type AppOptions = {
7
- font?: {
8
- name: string;
9
- src?: string;
10
- };
11
- sounds?: SoundOptions;
12
- spriteLoaderFn: SpriteLoaderFn;
13
- };
14
- export declare class App {
15
- stage: PIXI.Container;
16
- evotars: Record<string, Evotar>;
17
- chatterIds: string[];
18
- settings: SettingsEntity;
19
- renderer: PIXI.Renderer;
20
- initialize(element: HTMLElement, options: AppOptions): Promise<void>;
21
- updateSettings(data: SettingsEntity): void;
22
- update(): void;
23
- }
24
- export declare const app: App;
@@ -1 +0,0 @@
1
- export declare const FIXED_DELTA_TIME: number;
@@ -1,15 +0,0 @@
1
- import { Point } from '../helpers/types';
2
- import * as PIXI from 'pixi.js';
3
- export type EvotarEmoteSpitterProps = {
4
- position: Point;
5
- };
6
- export declare class EvotarEmoteSpitter {
7
- container: PIXI.Container;
8
- private emotes;
9
- private moveSpeed;
10
- private alphaSpeed;
11
- private scaleSpeed;
12
- private timer?;
13
- add(url: string): Promise<void>;
14
- update(props: EvotarEmoteSpitterProps): void;
15
- }
@@ -1,78 +0,0 @@
1
- import { EvotarTrailEffect } from './TrailEffect';
2
- import { EvotarSpriteTags } from '../services/spriteService';
3
- import { Timer } from '../helpers/timer';
4
- import * as TWEEN from '@tweenjs/tween.js';
5
- import * as PIXI from 'pixi.js';
6
- export type EvotarProps = {
7
- name?: string;
8
- sprite?: string;
9
- color?: PIXI.Color;
10
- direction?: number;
11
- scale?: number;
12
- isAnonymous?: boolean;
13
- zIndex?: number;
14
- };
15
- export type EvotarSpawnProps = {
16
- isFalling?: boolean;
17
- positionX?: number;
18
- onComplete?: () => void;
19
- };
20
- export type EvotarDepawnProps = {
21
- onComplete?: () => void;
22
- };
23
- type UserProps = {
24
- color?: PIXI.Color;
25
- };
26
- export declare class Evotar {
27
- container: PIXI.Container;
28
- private userState;
29
- private state;
30
- private animationState;
31
- private sprite?;
32
- private spriteData;
33
- private animatedSprites?;
34
- trail: EvotarTrailEffect;
35
- private name;
36
- private message;
37
- private emoteSpitter;
38
- private velocity;
39
- private runSpeed;
40
- private gravity;
41
- private dashAcc;
42
- private isJumping;
43
- private isDashing;
44
- private isDespawned;
45
- landTimer?: Timer;
46
- stateTimer?: Timer;
47
- scaleTimer?: Timer;
48
- spawnTween?: TWEEN.Tween<PIXI.Container>;
49
- fadeTween?: TWEEN.Tween<PIXI.Container>;
50
- scaleTween?: TWEEN.Tween<Evotar>;
51
- constructor();
52
- spawn(props?: EvotarSpawnProps): void;
53
- despawn(props?: EvotarDepawnProps): void;
54
- scale(options: {
55
- value: number;
56
- duration: number;
57
- cooldown: number;
58
- }): void;
59
- jump(options: {
60
- velocityX: number;
61
- velocityY: number;
62
- cooldown: number;
63
- }): void;
64
- dash(options: {
65
- force: number;
66
- cooldown: number;
67
- }): void;
68
- setSprite(sprite: string): Promise<void>;
69
- setProps(props: EvotarProps): Promise<void>;
70
- setUserProps(props: UserProps): void;
71
- private move;
72
- update(): void;
73
- isOnGround(y: number): boolean;
74
- addMessage(message: string): void;
75
- spitEmotes(emotes: string[]): void;
76
- setAnimationState(state: EvotarSpriteTags, force?: boolean): Promise<void>;
77
- }
78
- export {};
@@ -1,27 +0,0 @@
1
- import { Point } from '../helpers/types';
2
-
3
- import * as PIXI from 'pixi.js';
4
- export type EvotarMesageProps = {
5
- position: Point;
6
- };
7
- export declare class EvotarMessage {
8
- private beforeShow;
9
- container: PIXI.Container;
10
- animated: PIXI.Container;
11
- private text;
12
- private padding;
13
- private borderRadius;
14
- private boxColor;
15
- private fadeShift;
16
- private isChecking;
17
- private messageQueue;
18
- private showTween?;
19
- private hideTween?;
20
- private timer?;
21
- constructor(beforeShow: () => void);
22
- private trim;
23
- update(props: EvotarMesageProps): void;
24
- add(message: string): void;
25
- private drawBox;
26
- private show;
27
- }
@@ -1,14 +0,0 @@
1
- import { Point, Rect } from '../helpers/types';
2
-
3
- import * as PIXI from 'pixi.js';
4
- export type EvotarNameProps = {
5
- name: string;
6
- position: Point;
7
- isVisible: boolean;
8
- };
9
- export declare class EvotarName {
10
- text: PIXI.Text;
11
- constructor();
12
- update(props: EvotarNameProps): void;
13
- rect: () => Rect;
14
- }
@@ -1,16 +0,0 @@
1
- import { EvotarLayerSprites } from '../services/spriteService';
2
- import { Point } from '../helpers/types';
3
- import * as PIXI from 'pixi.js';
4
- export type EvotarSpriteContainerProps = {
5
- color: {
6
- [key in string]?: PIXI.Color;
7
- };
8
- scale: Point;
9
- play: boolean;
10
- };
11
- export declare class EvotarSpriteContainer {
12
- container: PIXI.Container;
13
- sprites: EvotarLayerSprites;
14
- constructor(sprites: EvotarLayerSprites);
15
- update(props: EvotarSpriteContainerProps): void;
16
- }
@@ -1,15 +0,0 @@
1
- import { EvotarSpriteContainer } from './SpriteContainer';
2
- import * as PIXI from 'pixi.js';
3
- export type EvotarTrailEffectProps = {
4
- play: boolean;
5
- };
6
- export declare class EvotarTrailEffect {
7
- container: PIXI.Container;
8
- private timer?;
9
- private sprite?;
10
- private opacityStep;
11
- private shadowStep;
12
- constructor();
13
- setSprite(sprite: EvotarSpriteContainer): void;
14
- update(props: EvotarTrailEffectProps): void;
15
- }
package/dist/evotars.d.ts DELETED
@@ -1,15 +0,0 @@
1
- import { MessageEntity, RaidData, SettingsEntity, TwitchChatterEntity, UserActionEntity } from './types';
2
- import { AppOptions } from './app';
3
-
4
- export declare class Evotars {
5
- private readonly root;
6
- private readonly options;
7
- private isRendered;
8
- constructor(root: HTMLElement, options: AppOptions);
9
- processMessage: (data: MessageEntity) => Promise<void>;
10
- processAction: (data: UserActionEntity) => Promise<void>;
11
- processChatters: (data: TwitchChatterEntity[]) => Promise<void>;
12
- processRaid: (data: RaidData) => void;
13
- updateSettings(data: SettingsEntity): void;
14
- run(): Promise<void>;
15
- }
@@ -1,30 +0,0 @@
1
- import { Evotar } from './entities/Evotar';
2
- import { MessageEntity, RaidData, TwitchChatterEntity, UserActionEntity } from './types';
3
-
4
- type EvotarsManagerSubscription = {
5
- onAdd: (evotar: Evotar) => void;
6
- onDelete: (evotar: Evotar) => void;
7
- };
8
- declare class EvotarsManager {
9
- private viewers;
10
- private raiders;
11
- private lastEvotarActivity;
12
- private subscriptions;
13
- subscribe(subscription: EvotarsManagerSubscription): void;
14
- update(): void;
15
- processRaid(data: RaidData): void;
16
- processChatters(data: TwitchChatterEntity[]): Promise<void>;
17
- private hasActivity;
18
- doAction(action: UserActionEntity, evotar: Evotar): void;
19
- private prepareEvotarProps;
20
- processAction(action: UserActionEntity): Promise<void>;
21
- processMessage(data: MessageEntity): Promise<void>;
22
- addViewer(id: string, evotar: Evotar): void;
23
- deleteViewer(id: string, evotar: Evotar): void;
24
- addRaider(evotar: Evotar): void;
25
- deleteRaider(evotar: Evotar): void;
26
- zIndexEvotarMax(from: number): number;
27
- zIndexEvotarMin(from: number): number;
28
- }
29
- export declare const evotarsManager: EvotarsManager;
30
- export {};
@@ -1,14 +0,0 @@
1
- export declare class Timer {
2
- current: number;
3
- private onComplete?;
4
- isCompleted: boolean;
5
- constructor(current?: number, onComplete?: (() => void) | undefined);
6
- tick(delta?: number): void;
7
- }
8
- declare class Timers {
9
- private timers;
10
- add(current?: number, onComplete?: () => void): void;
11
- tick(delta?: number): void;
12
- }
13
- export declare const timers: Timers;
14
- export {};
@@ -1,10 +0,0 @@
1
- export type Point = {
2
- x?: number;
3
- y?: number;
4
- };
5
- export type Rect = {
6
- x: number;
7
- y: number;
8
- w: number;
9
- h: number;
10
- };
@@ -1,14 +0,0 @@
1
- export type SoundOptions = {
2
- jump?: {
3
- src: string;
4
- };
5
- };
6
- declare class SoundService {
7
- assets: {
8
- [key: string]: HTMLAudioElement;
9
- };
10
- initialize(options?: SoundOptions): Promise<void>;
11
- play(name: string): void;
12
- }
13
- export declare const soundService: SoundService;
14
- export {};
@@ -1,63 +0,0 @@
1
- import { AnimatedSprite, ISpritesheetData, ISpritesheetFrameData, Spritesheet } from 'pixi.js';
2
-
3
- export type EvotarSpriteData = {
4
- name: string;
5
- collider: Collider;
6
- size: SpriteSize;
7
- scale: number;
8
- flip: boolean;
9
- colored: string[];
10
- };
11
- export type SpriteLoaderFn = (name: string) => Promise<{
12
- sprite: SpritesheetData;
13
- data: EvotarSpriteData;
14
- image: string;
15
- } | undefined>;
16
- export type Collider = {
17
- x: number;
18
- y: number;
19
- w: number;
20
- h: number;
21
- };
22
- export interface SpritesheetFrameData extends ISpritesheetFrameData {
23
- duration: number;
24
- }
25
- export interface SpritesheetData extends ISpritesheetData {
26
- frames: Record<string, SpritesheetFrameData>;
27
- }
28
- export type EvotarLayerSprites = {
29
- [layer in string]: AnimatedSprite;
30
- };
31
- export type EvotarAnimatedSprites = {
32
- [tag in string]: EvotarLayerSprites;
33
- };
34
- export declare enum EvotarSpriteTags {
35
- Idle = "Idle",
36
- Jump = "Jump",
37
- Fall = "Fall",
38
- Land = "Land",
39
- Run = "Run",
40
- Die = "Die"
41
- }
42
- export type FrameTag = {
43
- from: number;
44
- name: string;
45
- to: number;
46
- direction: string;
47
- };
48
- export type SpriteSize = {
49
- w: number;
50
- h: number;
51
- };
52
- export type SpriteData = {
53
- sheet: Spritesheet<SpritesheetData>;
54
- data: EvotarSpriteData;
55
- };
56
- export declare class SpriteService {
57
- private spriteLoaderFn;
58
- private sprites;
59
- initialize(spriteLoaderFn: SpriteLoaderFn): void;
60
- getSpriteData(name: string): Promise<SpriteData | undefined>;
61
- getAnimatedSprites(name: string): EvotarAnimatedSprites;
62
- }
63
- export declare const spriteService: SpriteService;
@@ -1,56 +0,0 @@
1
- import { UserInfo } from './user';
2
-
3
- export type ActionData = Record<string, string | number | undefined>;
4
- export type ActionableData = {
5
- arguments: string[];
6
- action: ActionData;
7
- };
8
- export type ActionEntity = {
9
- id: number;
10
- name: string;
11
- title: string;
12
- description: string;
13
- data: ActionData;
14
- };
15
- export type UserActionEntity = {
16
- userId: string;
17
- cooldown: number;
18
- info: UserInfo;
19
- } & ActionEntity;
20
- export type JumpUserActionEntity = {
21
- name: 'jump';
22
- data: {
23
- velocityX: number;
24
- velocityY: number;
25
- };
26
- } & UserActionEntity;
27
- export type ColorUserActionEntity = {
28
- name: 'color';
29
- data: {
30
- color: string;
31
- };
32
- } & UserActionEntity;
33
- export type GrowUserActionEntity = {
34
- name: 'grow';
35
- data: {
36
- duration: number;
37
- scale: number;
38
- };
39
- } & UserActionEntity;
40
- export type DashUserActionEntity = {
41
- name: 'dash';
42
- data: {
43
- force: number;
44
- };
45
- } & UserActionEntity;
46
- export type SpriteUserActionEntity = {
47
- name: 'sprite';
48
- data: {
49
- sprite: string;
50
- };
51
- } & UserActionEntity;
52
- export declare const isJumpUserActionEntity: (entity: ActionEntity) => entity is JumpUserActionEntity;
53
- export declare const isColorUserActionEntity: (entity: ActionEntity) => entity is ColorUserActionEntity;
54
- export declare const isGrowUserActionEntity: (entity: ActionEntity) => entity is GrowUserActionEntity;
55
- export declare const isDashUserActionEntity: (entity: ActionEntity) => entity is DashUserActionEntity;
56
- export declare const isSpriteUserActionEntity: (entity: ActionEntity) => entity is SpriteUserActionEntity;
@@ -1,4 +0,0 @@
1
- export type TwitchChatterEntity = {
2
- userId: string;
3
- name: string;
4
- };
@@ -1,9 +0,0 @@
1
- import { UserInfo } from './user';
2
-
3
- export type RaidData = {
4
- broadcaster: {
5
- id: string;
6
- info: UserInfo;
7
- };
8
- viewers: number;
9
- };
@@ -1,6 +0,0 @@
1
- export * from './message';
2
- export * from './chatter';
3
- export * from './settings';
4
- export * from './user';
5
- export * from './action';
6
- export * from './event';
@@ -1,8 +0,0 @@
1
- import { UserInfo } from './user';
2
-
3
- export type MessageEntity = {
4
- userId: string;
5
- message: string;
6
- emotes: string[];
7
- info: UserInfo;
8
- };
@@ -1,5 +0,0 @@
1
- export type SettingsEntity = {
2
- showAnonymousEvotars?: boolean;
3
- fallingEvotars?: boolean;
4
- fallingRaiders?: boolean;
5
- };
@@ -1,12 +0,0 @@
1
- export type UserEntity = {
2
- userId: number;
3
- guid: string;
4
- displayName: string;
5
- profileImageUrl: string;
6
- previewUrl: string;
7
- };
8
- export type UserInfo = {
9
- displayName: string;
10
- color?: string;
11
- sprite?: string;
12
- };
@@ -1 +0,0 @@
1
- export * from './dto';