invadrs 0.1.0 → 0.2.1

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/README.md CHANGED
@@ -3,6 +3,8 @@
3
3
  Deterministic space-invaders-style pixel avatars from any string. Zero
4
4
  dependencies. Same id in, same avatar out, forever.
5
5
 
6
+ **[🕹 Live demo & Storybook →](https://invadrs.pages.dev)**
7
+
6
8
  ![invadrs sample avatars — the invadr() and spawn() primitives, shown across every built-in palette](assets/preview.png)
7
9
 
8
10
  ```ts
@@ -20,8 +20,8 @@ var palettes = {
20
20
  ocean: { colors: ["#1d3557", "#2a9d8f", "#48cae4", "#56e39f", "#4361ee", "#7bdff2"] },
21
21
  // greens and earth — pine, leaf, lime-olive, fern, bark, tan
22
22
  forest: { colors: ["#386641", "#6a994e", "#a7c957", "#588157", "#b08968", "#dda15e"] },
23
- // grayscale
24
- mono: { colors: ["#e6e6e6", "#bdbdbd", "#9e9e9e", "#757575", "#bdbdbd", "#e6e6e6"] }
23
+ // grayscale — mid greys, 6 distinct, legible on both light and dark backgrounds
24
+ mono: { colors: ["#a8a8a8", "#969696", "#848484", "#727272", "#606060", "#545454"] }
25
25
  };
26
26
  var CSS_VARS = {
27
27
  colors: ["var(--accent)", "var(--green)", "var(--amber)", "var(--purple)", "var(--cyan)", "var(--red)"]
@@ -76,48 +76,236 @@ function dataUri(svg) {
76
76
 
77
77
  // src/invadr.ts
78
78
  var INVADR_SPRITES = [
79
- [24, 60, 126, 219, 255, 36, 90, 165],
80
- // invader
81
- [36, 126, 219, 255, 255, 102, 36, 66],
82
- // crab
83
- [60, 126, 219, 255, 255, 255, 255, 165],
84
- // ghost
85
- [60, 66, 165, 129, 165, 153, 66, 60],
86
- // smiley
87
- [24, 24, 126, 255, 255, 102, 102, 231],
88
- // mech
89
- [66, 36, 126, 219, 255, 165, 36, 66],
90
- // alien
91
- [231, 60, 126, 219, 255, 219, 126, 102],
92
- // robot
93
- [129, 195, 255, 219, 255, 255, 255, 165],
94
- // cat
95
- [60, 126, 255, 219, 255, 126, 90, 36],
96
- // skull
97
- [153, 126, 255, 219, 255, 255, 126, 165],
98
- // beetle
99
- [195, 255, 219, 255, 126, 60, 24, 36],
100
- // owl
101
- [36, 126, 255, 231, 255, 126, 24, 24],
102
- // flower
103
- [24, 60, 126, 255, 255, 126, 60, 24],
104
- // gem
105
- [102, 255, 255, 255, 126, 126, 60, 24],
106
- // heart
107
- [60, 126, 255, 255, 90, 24, 24, 60],
108
- // mushroom
109
- [36, 90, 255, 189, 255, 90, 165, 66]
110
- // amoeba
79
+ [
80
+ // squid
81
+ "...#...#...",
82
+ "....#.#....",
83
+ "...#####...",
84
+ "..#######..",
85
+ ".##.###.##.",
86
+ "###########",
87
+ "###########",
88
+ ".#.#####.#.",
89
+ "..#.....#..",
90
+ ".#..#.#..#.",
91
+ "#...#.#...#"
92
+ ],
93
+ [
94
+ // crab
95
+ "#....#....#",
96
+ ".#...#...#.",
97
+ "..#######..",
98
+ ".#########.",
99
+ "###.###.###",
100
+ "###########",
101
+ "###########",
102
+ "#.#######.#",
103
+ "#.#.....#.#",
104
+ "...#...#...",
105
+ "..##...##.."
106
+ ],
107
+ [
108
+ // octopus
109
+ "..#######..",
110
+ ".#########.",
111
+ "###########",
112
+ "##.#####.##",
113
+ "##.#####.##",
114
+ "###########",
115
+ ".#.#.#.#.#.",
116
+ ".#.#.#.#.#.",
117
+ ".#.#.#.#.#.",
118
+ "#..#.#.#..#",
119
+ "#..#.#.#..#"
120
+ ],
121
+ [
122
+ // beetle
123
+ "#..#...#..#",
124
+ ".#.#...#.#.",
125
+ "..#######..",
126
+ ".####.####.",
127
+ "###########",
128
+ "###.###.###",
129
+ "###########",
130
+ "###########",
131
+ ".#########.",
132
+ "..#.....#..",
133
+ ".#.......#."
134
+ ],
135
+ [
136
+ // bunny
137
+ "..#.....#..",
138
+ "..#.....#..",
139
+ "..#.#.#.#..",
140
+ "..#######..",
141
+ ".#########.",
142
+ ".##.###.##.",
143
+ ".#########.",
144
+ ".#########.",
145
+ "..#######..",
146
+ "..#.....#..",
147
+ ".##.....##."
148
+ ],
149
+ [
150
+ // cat
151
+ ".#.......#.",
152
+ ".##.....##.",
153
+ ".#########.",
154
+ "###.###.###",
155
+ "#####.#####",
156
+ "###########",
157
+ "###########",
158
+ "#.#######.#",
159
+ "..#######..",
160
+ "...#...#...",
161
+ "..#.....#.."
162
+ ],
163
+ [
164
+ // ghost
165
+ "...#####...",
166
+ "..#######..",
167
+ ".#########.",
168
+ ".##.###.##.",
169
+ "###########",
170
+ "###########",
171
+ "###########",
172
+ "###########",
173
+ "###########",
174
+ "#.##.#.##.#",
175
+ "#..#.#.#..#"
176
+ ],
177
+ [
178
+ // skull
179
+ "...#####...",
180
+ "..#######..",
181
+ ".#########.",
182
+ "###########",
183
+ "##..###..##",
184
+ "##..###..##",
185
+ "###########",
186
+ ".#########.",
187
+ ".#.#.#.#.#.",
188
+ ".#########.",
189
+ "..#.....#.."
190
+ ],
191
+ [
192
+ // robot
193
+ "....#.#....",
194
+ "...#####...",
195
+ "..#######..",
196
+ ".##.###.##.",
197
+ ".#########.",
198
+ ".#.#.#.#.#.",
199
+ ".#########.",
200
+ "..#######..",
201
+ "..#.....#..",
202
+ "..#.....#..",
203
+ ".##.....##."
204
+ ],
205
+ [
206
+ // horned
207
+ "#.........#",
208
+ "##.......##",
209
+ ".##.....##.",
210
+ "..#######..",
211
+ ".##.###.##.",
212
+ ".#########.",
213
+ "..#######..",
214
+ "..#######..",
215
+ "...#...#...",
216
+ "..#.....#..",
217
+ ".##.....##."
218
+ ],
219
+ [
220
+ // smiley
221
+ "..#######..",
222
+ ".#########.",
223
+ "###########",
224
+ "##.#####.##",
225
+ "###########",
226
+ "###########",
227
+ "#.#.###.#.#",
228
+ "##.#####.##",
229
+ ".#########.",
230
+ "..#######..",
231
+ "..##...##.."
232
+ ],
233
+ [
234
+ // owl
235
+ "##.......##",
236
+ ".#########.",
237
+ ".#########.",
238
+ "#...###...#",
239
+ "#.#.###.#.#",
240
+ "#...###...#",
241
+ ".#########.",
242
+ ".#########.",
243
+ "..#######..",
244
+ "...#...#...",
245
+ "..#.....#.."
246
+ ],
247
+ [
248
+ // alien
249
+ ".#.......#.",
250
+ "..#.....#..",
251
+ "...#####...",
252
+ "..#######..",
253
+ ".##.###.##.",
254
+ "..#######..",
255
+ ".#.#####.#.",
256
+ "#.#######.#",
257
+ "#.#.....#.#",
258
+ ".#.......#.",
259
+ "#..#...#..#"
260
+ ],
261
+ [
262
+ // mushroom
263
+ "...#####...",
264
+ "..#######..",
265
+ ".#########.",
266
+ "###########",
267
+ "###########",
268
+ ".##.###.##.",
269
+ "...#####...",
270
+ "...#...#...",
271
+ "...#...#...",
272
+ "...#####...",
273
+ "..#######.."
274
+ ],
275
+ [
276
+ // jellyfish
277
+ "...#####...",
278
+ "..#######..",
279
+ ".#########.",
280
+ ".##.###.##.",
281
+ "###########",
282
+ ".#########.",
283
+ "..#.#.#.#..",
284
+ ".#.#.#.#.#.",
285
+ ".#..#.#..#.",
286
+ "#...#.#...#",
287
+ "#....#....#"
288
+ ],
289
+ [
290
+ // slime
291
+ "...#####...",
292
+ "..#######..",
293
+ ".#########.",
294
+ "####...####",
295
+ "####.#.####",
296
+ "####...####",
297
+ ".#########.",
298
+ ".#########.",
299
+ "..#######..",
300
+ ".#.#.#.#.#.",
301
+ "#...#.#...#"
302
+ ]
111
303
  ];
112
- function byteRowsToGrid(rows) {
113
- return rows.map((row) => {
114
- const cells = [];
115
- for (let x = 0; x < 8; x++) cells.push((row & 128 >> x) !== 0);
116
- return cells;
117
- });
304
+ function spriteToGrid(rows) {
305
+ return rows.map((row) => [...row].map((c) => c === "#"));
118
306
  }
119
307
  function invadrGrid(seed) {
120
- return byteRowsToGrid(INVADR_SPRITES[seed % INVADR_SPRITES.length]);
308
+ return spriteToGrid(INVADR_SPRITES[seed % INVADR_SPRITES.length]);
121
309
  }
122
310
  function resolveInvadr(id, options) {
123
311
  const seed = hashStr(id);
package/dist/index.cjs CHANGED
@@ -22,8 +22,8 @@ var palettes = {
22
22
  ocean: { colors: ["#1d3557", "#2a9d8f", "#48cae4", "#56e39f", "#4361ee", "#7bdff2"] },
23
23
  // greens and earth — pine, leaf, lime-olive, fern, bark, tan
24
24
  forest: { colors: ["#386641", "#6a994e", "#a7c957", "#588157", "#b08968", "#dda15e"] },
25
- // grayscale
26
- mono: { colors: ["#e6e6e6", "#bdbdbd", "#9e9e9e", "#757575", "#bdbdbd", "#e6e6e6"] }
25
+ // grayscale — mid greys, 6 distinct, legible on both light and dark backgrounds
26
+ mono: { colors: ["#a8a8a8", "#969696", "#848484", "#727272", "#606060", "#545454"] }
27
27
  };
28
28
  var CSS_VARS = {
29
29
  colors: ["var(--accent)", "var(--green)", "var(--amber)", "var(--purple)", "var(--cyan)", "var(--red)"]
@@ -78,48 +78,236 @@ function dataUri(svg) {
78
78
 
79
79
  // src/invadr.ts
80
80
  var INVADR_SPRITES = [
81
- [24, 60, 126, 219, 255, 36, 90, 165],
82
- // invader
83
- [36, 126, 219, 255, 255, 102, 36, 66],
84
- // crab
85
- [60, 126, 219, 255, 255, 255, 255, 165],
86
- // ghost
87
- [60, 66, 165, 129, 165, 153, 66, 60],
88
- // smiley
89
- [24, 24, 126, 255, 255, 102, 102, 231],
90
- // mech
91
- [66, 36, 126, 219, 255, 165, 36, 66],
92
- // alien
93
- [231, 60, 126, 219, 255, 219, 126, 102],
94
- // robot
95
- [129, 195, 255, 219, 255, 255, 255, 165],
96
- // cat
97
- [60, 126, 255, 219, 255, 126, 90, 36],
98
- // skull
99
- [153, 126, 255, 219, 255, 255, 126, 165],
100
- // beetle
101
- [195, 255, 219, 255, 126, 60, 24, 36],
102
- // owl
103
- [36, 126, 255, 231, 255, 126, 24, 24],
104
- // flower
105
- [24, 60, 126, 255, 255, 126, 60, 24],
106
- // gem
107
- [102, 255, 255, 255, 126, 126, 60, 24],
108
- // heart
109
- [60, 126, 255, 255, 90, 24, 24, 60],
110
- // mushroom
111
- [36, 90, 255, 189, 255, 90, 165, 66]
112
- // amoeba
81
+ [
82
+ // squid
83
+ "...#...#...",
84
+ "....#.#....",
85
+ "...#####...",
86
+ "..#######..",
87
+ ".##.###.##.",
88
+ "###########",
89
+ "###########",
90
+ ".#.#####.#.",
91
+ "..#.....#..",
92
+ ".#..#.#..#.",
93
+ "#...#.#...#"
94
+ ],
95
+ [
96
+ // crab
97
+ "#....#....#",
98
+ ".#...#...#.",
99
+ "..#######..",
100
+ ".#########.",
101
+ "###.###.###",
102
+ "###########",
103
+ "###########",
104
+ "#.#######.#",
105
+ "#.#.....#.#",
106
+ "...#...#...",
107
+ "..##...##.."
108
+ ],
109
+ [
110
+ // octopus
111
+ "..#######..",
112
+ ".#########.",
113
+ "###########",
114
+ "##.#####.##",
115
+ "##.#####.##",
116
+ "###########",
117
+ ".#.#.#.#.#.",
118
+ ".#.#.#.#.#.",
119
+ ".#.#.#.#.#.",
120
+ "#..#.#.#..#",
121
+ "#..#.#.#..#"
122
+ ],
123
+ [
124
+ // beetle
125
+ "#..#...#..#",
126
+ ".#.#...#.#.",
127
+ "..#######..",
128
+ ".####.####.",
129
+ "###########",
130
+ "###.###.###",
131
+ "###########",
132
+ "###########",
133
+ ".#########.",
134
+ "..#.....#..",
135
+ ".#.......#."
136
+ ],
137
+ [
138
+ // bunny
139
+ "..#.....#..",
140
+ "..#.....#..",
141
+ "..#.#.#.#..",
142
+ "..#######..",
143
+ ".#########.",
144
+ ".##.###.##.",
145
+ ".#########.",
146
+ ".#########.",
147
+ "..#######..",
148
+ "..#.....#..",
149
+ ".##.....##."
150
+ ],
151
+ [
152
+ // cat
153
+ ".#.......#.",
154
+ ".##.....##.",
155
+ ".#########.",
156
+ "###.###.###",
157
+ "#####.#####",
158
+ "###########",
159
+ "###########",
160
+ "#.#######.#",
161
+ "..#######..",
162
+ "...#...#...",
163
+ "..#.....#.."
164
+ ],
165
+ [
166
+ // ghost
167
+ "...#####...",
168
+ "..#######..",
169
+ ".#########.",
170
+ ".##.###.##.",
171
+ "###########",
172
+ "###########",
173
+ "###########",
174
+ "###########",
175
+ "###########",
176
+ "#.##.#.##.#",
177
+ "#..#.#.#..#"
178
+ ],
179
+ [
180
+ // skull
181
+ "...#####...",
182
+ "..#######..",
183
+ ".#########.",
184
+ "###########",
185
+ "##..###..##",
186
+ "##..###..##",
187
+ "###########",
188
+ ".#########.",
189
+ ".#.#.#.#.#.",
190
+ ".#########.",
191
+ "..#.....#.."
192
+ ],
193
+ [
194
+ // robot
195
+ "....#.#....",
196
+ "...#####...",
197
+ "..#######..",
198
+ ".##.###.##.",
199
+ ".#########.",
200
+ ".#.#.#.#.#.",
201
+ ".#########.",
202
+ "..#######..",
203
+ "..#.....#..",
204
+ "..#.....#..",
205
+ ".##.....##."
206
+ ],
207
+ [
208
+ // horned
209
+ "#.........#",
210
+ "##.......##",
211
+ ".##.....##.",
212
+ "..#######..",
213
+ ".##.###.##.",
214
+ ".#########.",
215
+ "..#######..",
216
+ "..#######..",
217
+ "...#...#...",
218
+ "..#.....#..",
219
+ ".##.....##."
220
+ ],
221
+ [
222
+ // smiley
223
+ "..#######..",
224
+ ".#########.",
225
+ "###########",
226
+ "##.#####.##",
227
+ "###########",
228
+ "###########",
229
+ "#.#.###.#.#",
230
+ "##.#####.##",
231
+ ".#########.",
232
+ "..#######..",
233
+ "..##...##.."
234
+ ],
235
+ [
236
+ // owl
237
+ "##.......##",
238
+ ".#########.",
239
+ ".#########.",
240
+ "#...###...#",
241
+ "#.#.###.#.#",
242
+ "#...###...#",
243
+ ".#########.",
244
+ ".#########.",
245
+ "..#######..",
246
+ "...#...#...",
247
+ "..#.....#.."
248
+ ],
249
+ [
250
+ // alien
251
+ ".#.......#.",
252
+ "..#.....#..",
253
+ "...#####...",
254
+ "..#######..",
255
+ ".##.###.##.",
256
+ "..#######..",
257
+ ".#.#####.#.",
258
+ "#.#######.#",
259
+ "#.#.....#.#",
260
+ ".#.......#.",
261
+ "#..#...#..#"
262
+ ],
263
+ [
264
+ // mushroom
265
+ "...#####...",
266
+ "..#######..",
267
+ ".#########.",
268
+ "###########",
269
+ "###########",
270
+ ".##.###.##.",
271
+ "...#####...",
272
+ "...#...#...",
273
+ "...#...#...",
274
+ "...#####...",
275
+ "..#######.."
276
+ ],
277
+ [
278
+ // jellyfish
279
+ "...#####...",
280
+ "..#######..",
281
+ ".#########.",
282
+ ".##.###.##.",
283
+ "###########",
284
+ ".#########.",
285
+ "..#.#.#.#..",
286
+ ".#.#.#.#.#.",
287
+ ".#..#.#..#.",
288
+ "#...#.#...#",
289
+ "#....#....#"
290
+ ],
291
+ [
292
+ // slime
293
+ "...#####...",
294
+ "..#######..",
295
+ ".#########.",
296
+ "####...####",
297
+ "####.#.####",
298
+ "####...####",
299
+ ".#########.",
300
+ ".#########.",
301
+ "..#######..",
302
+ ".#.#.#.#.#.",
303
+ "#...#.#...#"
304
+ ]
113
305
  ];
114
- function byteRowsToGrid(rows) {
115
- return rows.map((row) => {
116
- const cells = [];
117
- for (let x = 0; x < 8; x++) cells.push((row & 128 >> x) !== 0);
118
- return cells;
119
- });
306
+ function spriteToGrid(rows) {
307
+ return rows.map((row) => [...row].map((c) => c === "#"));
120
308
  }
121
309
  function invadrGrid(seed) {
122
- return byteRowsToGrid(INVADR_SPRITES[seed % INVADR_SPRITES.length]);
310
+ return spriteToGrid(INVADR_SPRITES[seed % INVADR_SPRITES.length]);
123
311
  }
124
312
  function resolveInvadr(id, options) {
125
313
  const seed = hashStr(id);
package/dist/index.d.cts CHANGED
@@ -14,10 +14,12 @@ declare function renderSvg(s: ResolvedSprite): string;
14
14
  /** Wrap an SVG string as a data: URI usable in `src`/`background-image`. */
15
15
  declare function dataUri(svg: string): string;
16
16
 
17
- /** Hand-designed 8x8 creatures (one byte per row, MSB = left pixel).
18
- Curated so every id reads as a deliberate sprite; each is left-right
19
- symmetric. ORDER IS FROZEN reordering changes users' avatars. */
20
- declare const INVADR_SPRITES: number[][];
17
+ /** Hand-designed 11x11 creatures `'#'` is a filled pixel, any other char is
18
+ empty in the retro pixel-alien style: antennae/ears up top, eyes as
19
+ negative space, splayed legs below. Each is left-right symmetric. The set
20
+ and its order define the avatar mapping, so changing them changes existing
21
+ avatars: a versioned, semver-major change. */
22
+ declare const INVADR_SPRITES: string[][];
21
23
  /** Resolve a hand-drawn creature for an id (structured form). */
22
24
  declare function resolveInvadr(id: string, options?: SpriteOptions): ResolvedSprite;
23
25
  /** A hand-drawn creature for an id, as an SVG string. */
package/dist/index.d.ts CHANGED
@@ -14,10 +14,12 @@ declare function renderSvg(s: ResolvedSprite): string;
14
14
  /** Wrap an SVG string as a data: URI usable in `src`/`background-image`. */
15
15
  declare function dataUri(svg: string): string;
16
16
 
17
- /** Hand-designed 8x8 creatures (one byte per row, MSB = left pixel).
18
- Curated so every id reads as a deliberate sprite; each is left-right
19
- symmetric. ORDER IS FROZEN reordering changes users' avatars. */
20
- declare const INVADR_SPRITES: number[][];
17
+ /** Hand-designed 11x11 creatures `'#'` is a filled pixel, any other char is
18
+ empty in the retro pixel-alien style: antennae/ears up top, eyes as
19
+ negative space, splayed legs below. Each is left-right symmetric. The set
20
+ and its order define the avatar mapping, so changing them changes existing
21
+ avatars: a versioned, semver-major change. */
22
+ declare const INVADR_SPRITES: string[][];
21
23
  /** Resolve a hand-drawn creature for an id (structured form). */
22
24
  declare function resolveInvadr(id: string, options?: SpriteOptions): ResolvedSprite;
23
25
  /** A hand-drawn creature for an id, as an SVG string. */
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { CSS_VARS, INVADR_SPRITES, dataUri, hashStr, invadr, palettes, pickColor, renderSvg, resolveInvadr, resolvePalette, resolveSpawn, spawn } from './chunk-5SOVCTHT.js';
1
+ export { CSS_VARS, INVADR_SPRITES, dataUri, hashStr, invadr, palettes, pickColor, renderSvg, resolveInvadr, resolvePalette, resolveSpawn, spawn } from './chunk-PFORKP7K.js';
@@ -27,8 +27,8 @@ var palettes = {
27
27
  ocean: { colors: ["#1d3557", "#2a9d8f", "#48cae4", "#56e39f", "#4361ee", "#7bdff2"] },
28
28
  // greens and earth — pine, leaf, lime-olive, fern, bark, tan
29
29
  forest: { colors: ["#386641", "#6a994e", "#a7c957", "#588157", "#b08968", "#dda15e"] },
30
- // grayscale
31
- mono: { colors: ["#e6e6e6", "#bdbdbd", "#9e9e9e", "#757575", "#bdbdbd", "#e6e6e6"] }
30
+ // grayscale — mid greys, 6 distinct, legible on both light and dark backgrounds
31
+ mono: { colors: ["#a8a8a8", "#969696", "#848484", "#727272", "#606060", "#545454"] }
32
32
  };
33
33
  var CSS_VARS = {
34
34
  colors: ["var(--accent)", "var(--green)", "var(--amber)", "var(--purple)", "var(--cyan)", "var(--red)"]
@@ -59,48 +59,236 @@ function resolveCommon(seed, grid, options) {
59
59
 
60
60
  // src/invadr.ts
61
61
  var INVADR_SPRITES = [
62
- [24, 60, 126, 219, 255, 36, 90, 165],
63
- // invader
64
- [36, 126, 219, 255, 255, 102, 36, 66],
65
- // crab
66
- [60, 126, 219, 255, 255, 255, 255, 165],
67
- // ghost
68
- [60, 66, 165, 129, 165, 153, 66, 60],
69
- // smiley
70
- [24, 24, 126, 255, 255, 102, 102, 231],
71
- // mech
72
- [66, 36, 126, 219, 255, 165, 36, 66],
73
- // alien
74
- [231, 60, 126, 219, 255, 219, 126, 102],
75
- // robot
76
- [129, 195, 255, 219, 255, 255, 255, 165],
77
- // cat
78
- [60, 126, 255, 219, 255, 126, 90, 36],
79
- // skull
80
- [153, 126, 255, 219, 255, 255, 126, 165],
81
- // beetle
82
- [195, 255, 219, 255, 126, 60, 24, 36],
83
- // owl
84
- [36, 126, 255, 231, 255, 126, 24, 24],
85
- // flower
86
- [24, 60, 126, 255, 255, 126, 60, 24],
87
- // gem
88
- [102, 255, 255, 255, 126, 126, 60, 24],
89
- // heart
90
- [60, 126, 255, 255, 90, 24, 24, 60],
91
- // mushroom
92
- [36, 90, 255, 189, 255, 90, 165, 66]
93
- // amoeba
62
+ [
63
+ // squid
64
+ "...#...#...",
65
+ "....#.#....",
66
+ "...#####...",
67
+ "..#######..",
68
+ ".##.###.##.",
69
+ "###########",
70
+ "###########",
71
+ ".#.#####.#.",
72
+ "..#.....#..",
73
+ ".#..#.#..#.",
74
+ "#...#.#...#"
75
+ ],
76
+ [
77
+ // crab
78
+ "#....#....#",
79
+ ".#...#...#.",
80
+ "..#######..",
81
+ ".#########.",
82
+ "###.###.###",
83
+ "###########",
84
+ "###########",
85
+ "#.#######.#",
86
+ "#.#.....#.#",
87
+ "...#...#...",
88
+ "..##...##.."
89
+ ],
90
+ [
91
+ // octopus
92
+ "..#######..",
93
+ ".#########.",
94
+ "###########",
95
+ "##.#####.##",
96
+ "##.#####.##",
97
+ "###########",
98
+ ".#.#.#.#.#.",
99
+ ".#.#.#.#.#.",
100
+ ".#.#.#.#.#.",
101
+ "#..#.#.#..#",
102
+ "#..#.#.#..#"
103
+ ],
104
+ [
105
+ // beetle
106
+ "#..#...#..#",
107
+ ".#.#...#.#.",
108
+ "..#######..",
109
+ ".####.####.",
110
+ "###########",
111
+ "###.###.###",
112
+ "###########",
113
+ "###########",
114
+ ".#########.",
115
+ "..#.....#..",
116
+ ".#.......#."
117
+ ],
118
+ [
119
+ // bunny
120
+ "..#.....#..",
121
+ "..#.....#..",
122
+ "..#.#.#.#..",
123
+ "..#######..",
124
+ ".#########.",
125
+ ".##.###.##.",
126
+ ".#########.",
127
+ ".#########.",
128
+ "..#######..",
129
+ "..#.....#..",
130
+ ".##.....##."
131
+ ],
132
+ [
133
+ // cat
134
+ ".#.......#.",
135
+ ".##.....##.",
136
+ ".#########.",
137
+ "###.###.###",
138
+ "#####.#####",
139
+ "###########",
140
+ "###########",
141
+ "#.#######.#",
142
+ "..#######..",
143
+ "...#...#...",
144
+ "..#.....#.."
145
+ ],
146
+ [
147
+ // ghost
148
+ "...#####...",
149
+ "..#######..",
150
+ ".#########.",
151
+ ".##.###.##.",
152
+ "###########",
153
+ "###########",
154
+ "###########",
155
+ "###########",
156
+ "###########",
157
+ "#.##.#.##.#",
158
+ "#..#.#.#..#"
159
+ ],
160
+ [
161
+ // skull
162
+ "...#####...",
163
+ "..#######..",
164
+ ".#########.",
165
+ "###########",
166
+ "##..###..##",
167
+ "##..###..##",
168
+ "###########",
169
+ ".#########.",
170
+ ".#.#.#.#.#.",
171
+ ".#########.",
172
+ "..#.....#.."
173
+ ],
174
+ [
175
+ // robot
176
+ "....#.#....",
177
+ "...#####...",
178
+ "..#######..",
179
+ ".##.###.##.",
180
+ ".#########.",
181
+ ".#.#.#.#.#.",
182
+ ".#########.",
183
+ "..#######..",
184
+ "..#.....#..",
185
+ "..#.....#..",
186
+ ".##.....##."
187
+ ],
188
+ [
189
+ // horned
190
+ "#.........#",
191
+ "##.......##",
192
+ ".##.....##.",
193
+ "..#######..",
194
+ ".##.###.##.",
195
+ ".#########.",
196
+ "..#######..",
197
+ "..#######..",
198
+ "...#...#...",
199
+ "..#.....#..",
200
+ ".##.....##."
201
+ ],
202
+ [
203
+ // smiley
204
+ "..#######..",
205
+ ".#########.",
206
+ "###########",
207
+ "##.#####.##",
208
+ "###########",
209
+ "###########",
210
+ "#.#.###.#.#",
211
+ "##.#####.##",
212
+ ".#########.",
213
+ "..#######..",
214
+ "..##...##.."
215
+ ],
216
+ [
217
+ // owl
218
+ "##.......##",
219
+ ".#########.",
220
+ ".#########.",
221
+ "#...###...#",
222
+ "#.#.###.#.#",
223
+ "#...###...#",
224
+ ".#########.",
225
+ ".#########.",
226
+ "..#######..",
227
+ "...#...#...",
228
+ "..#.....#.."
229
+ ],
230
+ [
231
+ // alien
232
+ ".#.......#.",
233
+ "..#.....#..",
234
+ "...#####...",
235
+ "..#######..",
236
+ ".##.###.##.",
237
+ "..#######..",
238
+ ".#.#####.#.",
239
+ "#.#######.#",
240
+ "#.#.....#.#",
241
+ ".#.......#.",
242
+ "#..#...#..#"
243
+ ],
244
+ [
245
+ // mushroom
246
+ "...#####...",
247
+ "..#######..",
248
+ ".#########.",
249
+ "###########",
250
+ "###########",
251
+ ".##.###.##.",
252
+ "...#####...",
253
+ "...#...#...",
254
+ "...#...#...",
255
+ "...#####...",
256
+ "..#######.."
257
+ ],
258
+ [
259
+ // jellyfish
260
+ "...#####...",
261
+ "..#######..",
262
+ ".#########.",
263
+ ".##.###.##.",
264
+ "###########",
265
+ ".#########.",
266
+ "..#.#.#.#..",
267
+ ".#.#.#.#.#.",
268
+ ".#..#.#..#.",
269
+ "#...#.#...#",
270
+ "#....#....#"
271
+ ],
272
+ [
273
+ // slime
274
+ "...#####...",
275
+ "..#######..",
276
+ ".#########.",
277
+ "####...####",
278
+ "####.#.####",
279
+ "####...####",
280
+ ".#########.",
281
+ ".#########.",
282
+ "..#######..",
283
+ ".#.#.#.#.#.",
284
+ "#...#.#...#"
285
+ ]
94
286
  ];
95
- function byteRowsToGrid(rows) {
96
- return rows.map((row) => {
97
- const cells = [];
98
- for (let x = 0; x < 8; x++) cells.push((row & 128 >> x) !== 0);
99
- return cells;
100
- });
287
+ function spriteToGrid(rows) {
288
+ return rows.map((row) => [...row].map((c) => c === "#"));
101
289
  }
102
290
  function invadrGrid(seed) {
103
- return byteRowsToGrid(INVADR_SPRITES[seed % INVADR_SPRITES.length]);
291
+ return spriteToGrid(INVADR_SPRITES[seed % INVADR_SPRITES.length]);
104
292
  }
105
293
  function resolveInvadr(id, options) {
106
294
  const seed = hashStr(id);
@@ -1,4 +1,4 @@
1
- import { resolveInvadr, resolveSpawn } from '../chunk-5SOVCTHT.js';
1
+ import { resolveInvadr, resolveSpawn } from '../chunk-PFORKP7K.js';
2
2
  import { createContext, useContext } from 'react';
3
3
  import { jsx, jsxs } from 'react/jsx-runtime';
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "invadrs",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Deterministic space-invaders-style pixel avatars from any string.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -24,7 +24,9 @@
24
24
  "react"
25
25
  ],
26
26
  "sideEffects": false,
27
- "files": ["dist"],
27
+ "files": [
28
+ "dist"
29
+ ],
28
30
  "exports": {
29
31
  ".": {
30
32
  "types": "./dist/index.d.ts",
@@ -40,13 +42,17 @@
40
42
  "scripts": {
41
43
  "build": "tsup",
42
44
  "test": "bun test",
43
- "prepare": "tsup"
45
+ "prepare": "tsup",
46
+ "storybook": "storybook dev -p 6006",
47
+ "build-storybook": "storybook build"
44
48
  },
45
49
  "peerDependencies": {
46
50
  "react": ">=18"
47
51
  },
48
52
  "peerDependenciesMeta": {
49
- "react": { "optional": true }
53
+ "react": {
54
+ "optional": true
55
+ }
50
56
  },
51
57
  "devDependencies": {
52
58
  "@types/bun": "latest",
@@ -55,6 +61,17 @@
55
61
  "react": "^19.0.0",
56
62
  "react-dom": "^19.0.0",
57
63
  "tsup": "^8.0.0",
58
- "typescript": "^5.4.0"
64
+ "typescript": "^5.4.0",
65
+ "storybook": "^10.5.3",
66
+ "@storybook/react-vite": "^10.5.3",
67
+ "@chromatic-com/storybook": "^5.2.1",
68
+ "@storybook/addon-vitest": "^10.5.3",
69
+ "@storybook/addon-a11y": "^10.5.3",
70
+ "@storybook/addon-docs": "^10.5.3",
71
+ "@storybook/addon-mcp": "^0.7.0",
72
+ "vitest": "^4.1.10",
73
+ "playwright": "^1.61.1",
74
+ "@vitest/browser-playwright": "^4.1.10",
75
+ "@vitest/coverage-v8": "^4.1.10"
59
76
  }
60
77
  }