evotars 0.0.9 → 0.0.11

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.
Files changed (61) hide show
  1. package/dist/evotars.js +26284 -0
  2. package/dist/evotars.umd.cjs +1147 -0
  3. package/dist/index.d.ts +175 -0
  4. package/package.json +22 -2
  5. package/.editorconfig +0 -13
  6. package/.prettierrc.json +0 -3
  7. package/index.html +0 -13
  8. package/playground/main.ts +0 -48
  9. package/playground/styles.css +0 -17
  10. package/public/evotars/agent/data.json +0 -18
  11. package/public/evotars/agent/sprite.json +0 -166
  12. package/public/evotars/agent/sprite.png +0 -0
  13. package/public/evotars/cat/data.json +0 -18
  14. package/public/evotars/cat/sprite.json +0 -231
  15. package/public/evotars/cat/sprite.png +0 -0
  16. package/public/evotars/dude/data.json +0 -18
  17. package/public/evotars/dude/sprite.json +0 -231
  18. package/public/evotars/dude/sprite.png +0 -0
  19. package/public/evotars/girl/data.json +0 -18
  20. package/public/evotars/girl/sprite.json +0 -231
  21. package/public/evotars/girl/sprite.png +0 -0
  22. package/public/evotars/nerd/data.json +0 -18
  23. package/public/evotars/nerd/sprite.json +0 -231
  24. package/public/evotars/nerd/sprite.png +0 -0
  25. package/public/evotars/senior/data.json +0 -18
  26. package/public/evotars/senior/sprite.json +0 -231
  27. package/public/evotars/senior/sprite.png +0 -0
  28. package/public/evotars/set.json +0 -10
  29. package/public/evotars/sith/data.json +0 -18
  30. package/public/evotars/sith/sprite.json +0 -166
  31. package/public/evotars/sith/sprite.png +0 -0
  32. package/public/evotars/sponge/data.json +0 -18
  33. package/public/evotars/sponge/sprite.json +0 -231
  34. package/public/evotars/sponge/sprite.png +0 -0
  35. package/public/fonts/Rubik.ttf +0 -0
  36. package/public/sounds/jump.mp3 +0 -0
  37. package/src/app.ts +0 -71
  38. package/src/config/constants.ts +0 -1
  39. package/src/entities/EmoteSpitter.ts +0 -102
  40. package/src/entities/Evotar.ts +0 -468
  41. package/src/entities/Message.ts +0 -164
  42. package/src/entities/Name.ts +0 -33
  43. package/src/entities/SpriteContainer.ts +0 -65
  44. package/src/entities/TrailEffect.ts +0 -73
  45. package/src/evotars.ts +0 -75
  46. package/src/evotarsManager.ts +0 -313
  47. package/src/helpers/timer.ts +0 -43
  48. package/src/helpers/types.ts +0 -4
  49. package/src/index.ts +0 -1
  50. package/src/services/soundService.ts +0 -30
  51. package/src/services/spriteService.ts +0 -167
  52. package/src/types/dto/action.ts +0 -79
  53. package/src/types/dto/chatter.ts +0 -4
  54. package/src/types/dto/event.ts +0 -9
  55. package/src/types/dto/index.ts +0 -6
  56. package/src/types/dto/message.ts +0 -8
  57. package/src/types/dto/settings.ts +0 -5
  58. package/src/types/dto/user.ts +0 -13
  59. package/src/types/index.ts +0 -1
  60. package/tsconfig.json +0 -23
  61. package/vite.config.js +0 -26
@@ -0,0 +1,175 @@
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.9",
2
+ "version": "0.0.11",
3
3
  "name": "evotars",
4
4
  "description": "Show animated characters on stream",
5
5
  "author": "Mikhail Morozov",
@@ -19,8 +19,28 @@
19
19
  "preview": "vite preview",
20
20
  "lint": "tsc --noEmit"
21
21
  },
22
+ "files": [
23
+ "dist",
24
+ "LICENSE",
25
+ "README.md"
26
+ ],
22
27
  "source": "./src/index.ts",
23
- "main": "./src/index.ts",
28
+ "main": "./dist/evotars.umd.cjs",
29
+ "module": "./dist/evotars.js",
30
+ "exports": {
31
+ ".": {
32
+ "types": {
33
+ "default": "./dist/index.d.ts"
34
+ },
35
+ "default": {
36
+ "import": "./dist/evotars.js",
37
+ "require": "./dist/evotars.umd.cjs"
38
+ }
39
+ }
40
+ },
41
+ "type": "module",
42
+ "types": "./dist/index.d.ts",
43
+ "typings": "./dist/index.d.ts",
24
44
  "devDependencies": {
25
45
  "@types/tinycolor2": "^1.4.6",
26
46
  "typescript": "^5.0.2",
package/.editorconfig DELETED
@@ -1,13 +0,0 @@
1
- # Editor configuration, see http://editorconfig.org
2
- root = true
3
-
4
- [*]
5
- charset = utf-8
6
- indent_style = space
7
- indent_size = 2
8
- insert_final_newline = true
9
- trim_trailing_whitespace = true
10
-
11
- [*.md]
12
- max_line_length = off
13
- trim_trailing_whitespace = false
package/.prettierrc.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "singleQuote": true
3
- }
package/index.html DELETED
@@ -1,13 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <title>Evotars</title>
7
- <link rel="preload" rel="stylesheet" href="https://fonts.googleapis.com/css?family=Rubik">
8
- </head>
9
- <body>
10
- <script type="module" src="/playground/main.ts"></script>
11
- </body>
12
- </html>
13
-
@@ -1,48 +0,0 @@
1
- import { Evotars } from '../src/evotars';
2
- import { SettingsEntity } from '../src/types';
3
- import './styles.css';
4
-
5
- const sounds = { jump: { src: '/sounds/jump.mp3' } };
6
- const settings: SettingsEntity = {
7
- fallingEvotars: true,
8
- };
9
-
10
- const root = document.body;
11
-
12
- if (root) {
13
- const evotars = new Evotars(root, {
14
- font: 'Rubik',
15
- sounds,
16
- spriteLoaderFn: async (name: string) => {
17
- const path = '/evotars/' + name + '/';
18
- const sprite = await fetch(path + 'sprite.json');
19
- const spriteJson = await sprite.json();
20
- const data = await fetch(path + 'data.json');
21
- const dataJson = await data.json();
22
-
23
- return {
24
- data: dataJson,
25
- image: path + 'sprite.png',
26
- sprite: spriteJson,
27
- };
28
- },
29
- });
30
-
31
- await evotars.run();
32
- evotars.updateSettings(settings);
33
-
34
- setTimeout(() => {
35
- evotars.processMessage({
36
- message: 'Hello!',
37
- userId: '1',
38
- emotes: [
39
- 'https://static-cdn.jtvnw.net/emoticons/v2/emotesv2_a3c4578cf38c4c668553ead85b899d70/default/dark/3.0',
40
- ],
41
- info: {
42
- color: 'pink',
43
- displayName: 'Evotar',
44
- sprite: 'dude',
45
- },
46
- });
47
- }, 500);
48
- }
@@ -1,17 +0,0 @@
1
- :root {
2
- margin: 0;
3
- padding: 0;
4
- }
5
-
6
- html {
7
- height: 100%;
8
- }
9
-
10
- body {
11
- margin: 0;
12
- padding: 0;
13
- width: 100%;
14
- height: 100%;
15
- min-height: 100%;
16
- overflow: hidden;
17
- }
@@ -1,18 +0,0 @@
1
- {
2
- "name": "agent",
3
- "collider": {
4
- "x": 8,
5
- "y": 7,
6
- "w": 16,
7
- "h": 18
8
- },
9
- "size": {
10
- "w": 32,
11
- "h": 32
12
- },
13
- "scale": 4,
14
- "flip": true,
15
- "colored": [
16
- "Body"
17
- ]
18
- }
@@ -1,166 +0,0 @@
1
- { "frames": {
2
- "agent_Body_0": {
3
- "frame": { "x": 0, "y": 0, "w": 32, "h": 32 },
4
- "rotated": false,
5
- "trimmed": false,
6
- "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
7
- "sourceSize": { "w": 32, "h": 32 },
8
- "duration": 300
9
- },
10
- "agent_Body_1": {
11
- "frame": { "x": 32, "y": 0, "w": 32, "h": 32 },
12
- "rotated": false,
13
- "trimmed": false,
14
- "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
15
- "sourceSize": { "w": 32, "h": 32 },
16
- "duration": 300
17
- },
18
- "agent_Body_2": {
19
- "frame": { "x": 64, "y": 0, "w": 32, "h": 32 },
20
- "rotated": false,
21
- "trimmed": false,
22
- "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
23
- "sourceSize": { "w": 32, "h": 32 },
24
- "duration": 300
25
- },
26
- "agent_Body_3": {
27
- "frame": { "x": 96, "y": 0, "w": 32, "h": 32 },
28
- "rotated": false,
29
- "trimmed": false,
30
- "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
31
- "sourceSize": { "w": 32, "h": 32 },
32
- "duration": 100
33
- },
34
- "agent_Body_4": {
35
- "frame": { "x": 128, "y": 0, "w": 32, "h": 32 },
36
- "rotated": false,
37
- "trimmed": false,
38
- "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
39
- "sourceSize": { "w": 32, "h": 32 },
40
- "duration": 100
41
- },
42
- "agent_Body_5": {
43
- "frame": { "x": 160, "y": 0, "w": 32, "h": 32 },
44
- "rotated": false,
45
- "trimmed": false,
46
- "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
47
- "sourceSize": { "w": 32, "h": 32 },
48
- "duration": 100
49
- },
50
- "agent_Body_6": {
51
- "frame": { "x": 192, "y": 0, "w": 32, "h": 32 },
52
- "rotated": false,
53
- "trimmed": false,
54
- "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
55
- "sourceSize": { "w": 32, "h": 32 },
56
- "duration": 100
57
- },
58
- "agent_Body_7": {
59
- "frame": { "x": 224, "y": 0, "w": 32, "h": 32 },
60
- "rotated": false,
61
- "trimmed": false,
62
- "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
63
- "sourceSize": { "w": 32, "h": 32 },
64
- "duration": 100
65
- },
66
- "agent_Body_8": {
67
- "frame": { "x": 256, "y": 0, "w": 32, "h": 32 },
68
- "rotated": false,
69
- "trimmed": false,
70
- "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
71
- "sourceSize": { "w": 32, "h": 32 },
72
- "duration": 100
73
- },
74
- "agent_Eyes_0": {
75
- "frame": { "x": 0, "y": 32, "w": 32, "h": 32 },
76
- "rotated": false,
77
- "trimmed": false,
78
- "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
79
- "sourceSize": { "w": 32, "h": 32 },
80
- "duration": 300
81
- },
82
- "agent_Eyes_1": {
83
- "frame": { "x": 32, "y": 32, "w": 32, "h": 32 },
84
- "rotated": false,
85
- "trimmed": false,
86
- "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
87
- "sourceSize": { "w": 32, "h": 32 },
88
- "duration": 300
89
- },
90
- "agent_Eyes_2": {
91
- "frame": { "x": 64, "y": 32, "w": 32, "h": 32 },
92
- "rotated": false,
93
- "trimmed": false,
94
- "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
95
- "sourceSize": { "w": 32, "h": 32 },
96
- "duration": 300
97
- },
98
- "agent_Eyes_3": {
99
- "frame": { "x": 96, "y": 32, "w": 32, "h": 32 },
100
- "rotated": false,
101
- "trimmed": false,
102
- "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
103
- "sourceSize": { "w": 32, "h": 32 },
104
- "duration": 100
105
- },
106
- "agent_Eyes_4": {
107
- "frame": { "x": 128, "y": 32, "w": 32, "h": 32 },
108
- "rotated": false,
109
- "trimmed": false,
110
- "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
111
- "sourceSize": { "w": 32, "h": 32 },
112
- "duration": 100
113
- },
114
- "agent_Eyes_5": {
115
- "frame": { "x": 160, "y": 32, "w": 32, "h": 32 },
116
- "rotated": false,
117
- "trimmed": false,
118
- "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
119
- "sourceSize": { "w": 32, "h": 32 },
120
- "duration": 100
121
- },
122
- "agent_Eyes_6": {
123
- "frame": { "x": 192, "y": 32, "w": 32, "h": 32 },
124
- "rotated": false,
125
- "trimmed": false,
126
- "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
127
- "sourceSize": { "w": 32, "h": 32 },
128
- "duration": 100
129
- },
130
- "agent_Eyes_7": {
131
- "frame": { "x": 224, "y": 32, "w": 32, "h": 32 },
132
- "rotated": false,
133
- "trimmed": false,
134
- "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
135
- "sourceSize": { "w": 32, "h": 32 },
136
- "duration": 100
137
- },
138
- "agent_Eyes_8": {
139
- "frame": { "x": 256, "y": 32, "w": 32, "h": 32 },
140
- "rotated": false,
141
- "trimmed": false,
142
- "spriteSourceSize": { "x": 0, "y": 0, "w": 32, "h": 32 },
143
- "sourceSize": { "w": 32, "h": 32 },
144
- "duration": 100
145
- }
146
- },
147
- "meta": {
148
- "app": "https://www.aseprite.org/",
149
- "version": "1.x-dev",
150
- "image": "agent.png",
151
- "format": "RGBA8888",
152
- "size": { "w": 288, "h": 64 },
153
- "scale": "1",
154
- "frameTags": [
155
- { "name": "Idle", "from": 0, "to": 2, "direction": "forward", "color": "#000000ff" },
156
- { "name": "Jump", "from": 3, "to": 3, "direction": "forward", "color": "#000000ff" },
157
- { "name": "Fall", "from": 4, "to": 4, "direction": "forward", "color": "#000000ff" },
158
- { "name": "Land", "from": 5, "to": 5, "direction": "forward", "color": "#000000ff" },
159
- { "name": "Run", "from": 6, "to": 8, "direction": "forward", "color": "#000000ff" }
160
- ],
161
- "layers": [
162
- { "name": "Body", "opacity": 255, "blendMode": "normal" },
163
- { "name": "Eyes", "opacity": 255, "blendMode": "normal" }
164
- ]
165
- }
166
- }
Binary file
@@ -1,18 +0,0 @@
1
- {
2
- "name": "cat",
3
- "collider": {
4
- "x": 8,
5
- "y": 4,
6
- "w": 16,
7
- "h": 11
8
- },
9
- "size": {
10
- "w": 32,
11
- "h": 32
12
- },
13
- "scale": 4,
14
- "flip": true,
15
- "colored": [
16
- "Body"
17
- ]
18
- }