@bloopjs/engine 0.0.0 → 0.0.17

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/mod.js DELETED
@@ -1,1115 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __export = (target, all) => {
3
- for (var name in all)
4
- __defProp(target, name, {
5
- get: all[name],
6
- enumerable: true,
7
- configurable: true,
8
- set: (newValue) => all[name] = () => newValue
9
- });
10
- };
11
-
12
- // js/events.ts
13
- var exports_events = {};
14
- __export(exports_events, {
15
- encodeEvent: () => encodeEvent,
16
- decodeEvent: () => decodeEvent
17
- });
18
-
19
- // js/inputs.ts
20
- var exports_inputs = {};
21
- __export(exports_inputs, {
22
- mouseButtonToMouseButtonCode: () => mouseButtonToMouseButtonCode,
23
- keyToKeyCode: () => keyToKeyCode,
24
- MouseSnapshot: () => MouseSnapshot,
25
- MouseButtonCode: () => MouseButtonCode,
26
- KeyboardSnapshot: () => KeyboardSnapshot,
27
- KeyCode: () => KeyCode,
28
- InputSnapshot: () => InputSnapshot
29
- });
30
- var KeyCode;
31
- ((KeyCode2) => {
32
- KeyCode2[KeyCode2["Backquote"] = 0] = "Backquote";
33
- KeyCode2[KeyCode2["Backslash"] = 1] = "Backslash";
34
- KeyCode2[KeyCode2["BracketLeft"] = 2] = "BracketLeft";
35
- KeyCode2[KeyCode2["BracketRight"] = 3] = "BracketRight";
36
- KeyCode2[KeyCode2["Comma"] = 4] = "Comma";
37
- KeyCode2[KeyCode2["Digit0"] = 5] = "Digit0";
38
- KeyCode2[KeyCode2["Digit1"] = 6] = "Digit1";
39
- KeyCode2[KeyCode2["Digit2"] = 7] = "Digit2";
40
- KeyCode2[KeyCode2["Digit3"] = 8] = "Digit3";
41
- KeyCode2[KeyCode2["Digit4"] = 9] = "Digit4";
42
- KeyCode2[KeyCode2["Digit5"] = 10] = "Digit5";
43
- KeyCode2[KeyCode2["Digit6"] = 11] = "Digit6";
44
- KeyCode2[KeyCode2["Digit7"] = 12] = "Digit7";
45
- KeyCode2[KeyCode2["Digit8"] = 13] = "Digit8";
46
- KeyCode2[KeyCode2["Digit9"] = 14] = "Digit9";
47
- KeyCode2[KeyCode2["Equal"] = 15] = "Equal";
48
- KeyCode2[KeyCode2["IntlBackslash"] = 16] = "IntlBackslash";
49
- KeyCode2[KeyCode2["IntlRo"] = 17] = "IntlRo";
50
- KeyCode2[KeyCode2["IntlYen"] = 18] = "IntlYen";
51
- KeyCode2[KeyCode2["KeyA"] = 19] = "KeyA";
52
- KeyCode2[KeyCode2["KeyB"] = 20] = "KeyB";
53
- KeyCode2[KeyCode2["KeyC"] = 21] = "KeyC";
54
- KeyCode2[KeyCode2["KeyD"] = 22] = "KeyD";
55
- KeyCode2[KeyCode2["KeyE"] = 23] = "KeyE";
56
- KeyCode2[KeyCode2["KeyF"] = 24] = "KeyF";
57
- KeyCode2[KeyCode2["KeyG"] = 25] = "KeyG";
58
- KeyCode2[KeyCode2["KeyH"] = 26] = "KeyH";
59
- KeyCode2[KeyCode2["KeyI"] = 27] = "KeyI";
60
- KeyCode2[KeyCode2["KeyJ"] = 28] = "KeyJ";
61
- KeyCode2[KeyCode2["KeyK"] = 29] = "KeyK";
62
- KeyCode2[KeyCode2["KeyL"] = 30] = "KeyL";
63
- KeyCode2[KeyCode2["KeyM"] = 31] = "KeyM";
64
- KeyCode2[KeyCode2["KeyN"] = 32] = "KeyN";
65
- KeyCode2[KeyCode2["KeyO"] = 33] = "KeyO";
66
- KeyCode2[KeyCode2["KeyP"] = 34] = "KeyP";
67
- KeyCode2[KeyCode2["KeyQ"] = 35] = "KeyQ";
68
- KeyCode2[KeyCode2["KeyR"] = 36] = "KeyR";
69
- KeyCode2[KeyCode2["KeyS"] = 37] = "KeyS";
70
- KeyCode2[KeyCode2["KeyT"] = 38] = "KeyT";
71
- KeyCode2[KeyCode2["KeyU"] = 39] = "KeyU";
72
- KeyCode2[KeyCode2["KeyV"] = 40] = "KeyV";
73
- KeyCode2[KeyCode2["KeyW"] = 41] = "KeyW";
74
- KeyCode2[KeyCode2["KeyX"] = 42] = "KeyX";
75
- KeyCode2[KeyCode2["KeyY"] = 43] = "KeyY";
76
- KeyCode2[KeyCode2["KeyZ"] = 44] = "KeyZ";
77
- KeyCode2[KeyCode2["Minus"] = 45] = "Minus";
78
- KeyCode2[KeyCode2["Period"] = 46] = "Period";
79
- KeyCode2[KeyCode2["Quote"] = 47] = "Quote";
80
- KeyCode2[KeyCode2["Semicolon"] = 48] = "Semicolon";
81
- KeyCode2[KeyCode2["Slash"] = 49] = "Slash";
82
- KeyCode2[KeyCode2["AltLeft"] = 50] = "AltLeft";
83
- KeyCode2[KeyCode2["AltRight"] = 51] = "AltRight";
84
- KeyCode2[KeyCode2["Backspace"] = 52] = "Backspace";
85
- KeyCode2[KeyCode2["CapsLock"] = 53] = "CapsLock";
86
- KeyCode2[KeyCode2["ContextMenu"] = 54] = "ContextMenu";
87
- KeyCode2[KeyCode2["ControlLeft"] = 55] = "ControlLeft";
88
- KeyCode2[KeyCode2["ControlRight"] = 56] = "ControlRight";
89
- KeyCode2[KeyCode2["Enter"] = 57] = "Enter";
90
- KeyCode2[KeyCode2["MetaLeft"] = 58] = "MetaLeft";
91
- KeyCode2[KeyCode2["MetaRight"] = 59] = "MetaRight";
92
- KeyCode2[KeyCode2["ShiftLeft"] = 60] = "ShiftLeft";
93
- KeyCode2[KeyCode2["ShiftRight"] = 61] = "ShiftRight";
94
- KeyCode2[KeyCode2["Space"] = 62] = "Space";
95
- KeyCode2[KeyCode2["Tab"] = 63] = "Tab";
96
- KeyCode2[KeyCode2["Convert"] = 64] = "Convert";
97
- KeyCode2[KeyCode2["KanaMode"] = 65] = "KanaMode";
98
- KeyCode2[KeyCode2["Lang1"] = 66] = "Lang1";
99
- KeyCode2[KeyCode2["Lang2"] = 67] = "Lang2";
100
- KeyCode2[KeyCode2["Lang3"] = 68] = "Lang3";
101
- KeyCode2[KeyCode2["Lang4"] = 69] = "Lang4";
102
- KeyCode2[KeyCode2["Lang5"] = 70] = "Lang5";
103
- KeyCode2[KeyCode2["NonConvert"] = 71] = "NonConvert";
104
- KeyCode2[KeyCode2["Delete"] = 72] = "Delete";
105
- KeyCode2[KeyCode2["End"] = 73] = "End";
106
- KeyCode2[KeyCode2["Help"] = 74] = "Help";
107
- KeyCode2[KeyCode2["Home"] = 75] = "Home";
108
- KeyCode2[KeyCode2["Insert"] = 76] = "Insert";
109
- KeyCode2[KeyCode2["PageDown"] = 77] = "PageDown";
110
- KeyCode2[KeyCode2["PageUp"] = 78] = "PageUp";
111
- KeyCode2[KeyCode2["ArrowDown"] = 79] = "ArrowDown";
112
- KeyCode2[KeyCode2["ArrowLeft"] = 80] = "ArrowLeft";
113
- KeyCode2[KeyCode2["ArrowRight"] = 81] = "ArrowRight";
114
- KeyCode2[KeyCode2["ArrowUp"] = 82] = "ArrowUp";
115
- KeyCode2[KeyCode2["NumLock"] = 83] = "NumLock";
116
- KeyCode2[KeyCode2["Numpad0"] = 84] = "Numpad0";
117
- KeyCode2[KeyCode2["Numpad1"] = 85] = "Numpad1";
118
- KeyCode2[KeyCode2["Numpad2"] = 86] = "Numpad2";
119
- KeyCode2[KeyCode2["Numpad3"] = 87] = "Numpad3";
120
- KeyCode2[KeyCode2["Numpad4"] = 88] = "Numpad4";
121
- KeyCode2[KeyCode2["Numpad5"] = 89] = "Numpad5";
122
- KeyCode2[KeyCode2["Numpad6"] = 90] = "Numpad6";
123
- KeyCode2[KeyCode2["Numpad7"] = 91] = "Numpad7";
124
- KeyCode2[KeyCode2["Numpad8"] = 92] = "Numpad8";
125
- KeyCode2[KeyCode2["Numpad9"] = 93] = "Numpad9";
126
- KeyCode2[KeyCode2["NumpadAdd"] = 94] = "NumpadAdd";
127
- KeyCode2[KeyCode2["NumpadBackspace"] = 95] = "NumpadBackspace";
128
- KeyCode2[KeyCode2["NumpadClear"] = 96] = "NumpadClear";
129
- KeyCode2[KeyCode2["NumpadClearEntry"] = 97] = "NumpadClearEntry";
130
- KeyCode2[KeyCode2["NumpadComma"] = 98] = "NumpadComma";
131
- KeyCode2[KeyCode2["NumpadDecimal"] = 99] = "NumpadDecimal";
132
- KeyCode2[KeyCode2["NumpadDivide"] = 100] = "NumpadDivide";
133
- KeyCode2[KeyCode2["NumpadEnter"] = 101] = "NumpadEnter";
134
- KeyCode2[KeyCode2["NumpadEqual"] = 102] = "NumpadEqual";
135
- KeyCode2[KeyCode2["NumpadHash"] = 103] = "NumpadHash";
136
- KeyCode2[KeyCode2["NumpadMemoryAdd"] = 104] = "NumpadMemoryAdd";
137
- KeyCode2[KeyCode2["NumpadMemoryClear"] = 105] = "NumpadMemoryClear";
138
- KeyCode2[KeyCode2["NumpadMemoryRecall"] = 106] = "NumpadMemoryRecall";
139
- KeyCode2[KeyCode2["NumpadMemoryStore"] = 107] = "NumpadMemoryStore";
140
- KeyCode2[KeyCode2["NumpadMemorySubtract"] = 108] = "NumpadMemorySubtract";
141
- KeyCode2[KeyCode2["NumpadMultiply"] = 109] = "NumpadMultiply";
142
- KeyCode2[KeyCode2["NumpadParenLeft"] = 110] = "NumpadParenLeft";
143
- KeyCode2[KeyCode2["NumpadParenRight"] = 111] = "NumpadParenRight";
144
- KeyCode2[KeyCode2["NumpadStar"] = 112] = "NumpadStar";
145
- KeyCode2[KeyCode2["NumpadSubtract"] = 113] = "NumpadSubtract";
146
- KeyCode2[KeyCode2["Escape"] = 114] = "Escape";
147
- KeyCode2[KeyCode2["Fn"] = 115] = "Fn";
148
- KeyCode2[KeyCode2["FnLock"] = 116] = "FnLock";
149
- KeyCode2[KeyCode2["PrintScreen"] = 117] = "PrintScreen";
150
- KeyCode2[KeyCode2["ScrollLock"] = 118] = "ScrollLock";
151
- KeyCode2[KeyCode2["Pause"] = 119] = "Pause";
152
- KeyCode2[KeyCode2["BrowserBack"] = 120] = "BrowserBack";
153
- KeyCode2[KeyCode2["BrowserFavorites"] = 121] = "BrowserFavorites";
154
- KeyCode2[KeyCode2["BrowserForward"] = 122] = "BrowserForward";
155
- KeyCode2[KeyCode2["BrowserHome"] = 123] = "BrowserHome";
156
- KeyCode2[KeyCode2["BrowserRefresh"] = 124] = "BrowserRefresh";
157
- KeyCode2[KeyCode2["BrowserSearch"] = 125] = "BrowserSearch";
158
- KeyCode2[KeyCode2["BrowserStop"] = 126] = "BrowserStop";
159
- KeyCode2[KeyCode2["Eject"] = 127] = "Eject";
160
- KeyCode2[KeyCode2["LaunchApp1"] = 128] = "LaunchApp1";
161
- KeyCode2[KeyCode2["LaunchApp2"] = 129] = "LaunchApp2";
162
- KeyCode2[KeyCode2["LaunchMail"] = 130] = "LaunchMail";
163
- KeyCode2[KeyCode2["MediaPlayPause"] = 131] = "MediaPlayPause";
164
- KeyCode2[KeyCode2["MediaSelect"] = 132] = "MediaSelect";
165
- KeyCode2[KeyCode2["MediaStop"] = 133] = "MediaStop";
166
- KeyCode2[KeyCode2["MediaTrackNext"] = 134] = "MediaTrackNext";
167
- KeyCode2[KeyCode2["MediaTrackPrevious"] = 135] = "MediaTrackPrevious";
168
- KeyCode2[KeyCode2["Power"] = 136] = "Power";
169
- KeyCode2[KeyCode2["Sleep"] = 137] = "Sleep";
170
- KeyCode2[KeyCode2["AudioVolumeDown"] = 138] = "AudioVolumeDown";
171
- KeyCode2[KeyCode2["AudioVolumeMute"] = 139] = "AudioVolumeMute";
172
- KeyCode2[KeyCode2["AudioVolumeUp"] = 140] = "AudioVolumeUp";
173
- KeyCode2[KeyCode2["WakeUp"] = 141] = "WakeUp";
174
- KeyCode2[KeyCode2["Hyper"] = 142] = "Hyper";
175
- KeyCode2[KeyCode2["Super"] = 143] = "Super";
176
- KeyCode2[KeyCode2["Turbo"] = 144] = "Turbo";
177
- KeyCode2[KeyCode2["Abort"] = 145] = "Abort";
178
- KeyCode2[KeyCode2["Resume"] = 146] = "Resume";
179
- KeyCode2[KeyCode2["Suspend"] = 147] = "Suspend";
180
- KeyCode2[KeyCode2["Again"] = 148] = "Again";
181
- KeyCode2[KeyCode2["Copy"] = 149] = "Copy";
182
- KeyCode2[KeyCode2["Cut"] = 150] = "Cut";
183
- KeyCode2[KeyCode2["Find"] = 151] = "Find";
184
- KeyCode2[KeyCode2["Open"] = 152] = "Open";
185
- KeyCode2[KeyCode2["Paste"] = 153] = "Paste";
186
- KeyCode2[KeyCode2["Props"] = 154] = "Props";
187
- KeyCode2[KeyCode2["Select"] = 155] = "Select";
188
- KeyCode2[KeyCode2["Undo"] = 156] = "Undo";
189
- KeyCode2[KeyCode2["Hiragana"] = 157] = "Hiragana";
190
- KeyCode2[KeyCode2["Katakana"] = 158] = "Katakana";
191
- KeyCode2[KeyCode2["F1"] = 159] = "F1";
192
- KeyCode2[KeyCode2["F2"] = 160] = "F2";
193
- KeyCode2[KeyCode2["F3"] = 161] = "F3";
194
- KeyCode2[KeyCode2["F4"] = 162] = "F4";
195
- KeyCode2[KeyCode2["F5"] = 163] = "F5";
196
- KeyCode2[KeyCode2["F6"] = 164] = "F6";
197
- KeyCode2[KeyCode2["F7"] = 165] = "F7";
198
- KeyCode2[KeyCode2["F8"] = 166] = "F8";
199
- KeyCode2[KeyCode2["F9"] = 167] = "F9";
200
- KeyCode2[KeyCode2["F10"] = 168] = "F10";
201
- KeyCode2[KeyCode2["F11"] = 169] = "F11";
202
- KeyCode2[KeyCode2["F12"] = 170] = "F12";
203
- KeyCode2[KeyCode2["F13"] = 171] = "F13";
204
- KeyCode2[KeyCode2["F14"] = 172] = "F14";
205
- KeyCode2[KeyCode2["F15"] = 173] = "F15";
206
- KeyCode2[KeyCode2["F16"] = 174] = "F16";
207
- KeyCode2[KeyCode2["F17"] = 175] = "F17";
208
- KeyCode2[KeyCode2["F18"] = 176] = "F18";
209
- KeyCode2[KeyCode2["F19"] = 177] = "F19";
210
- KeyCode2[KeyCode2["F20"] = 178] = "F20";
211
- KeyCode2[KeyCode2["F21"] = 179] = "F21";
212
- KeyCode2[KeyCode2["F22"] = 180] = "F22";
213
- KeyCode2[KeyCode2["F23"] = 181] = "F23";
214
- KeyCode2[KeyCode2["F24"] = 182] = "F24";
215
- KeyCode2[KeyCode2["F25"] = 183] = "F25";
216
- KeyCode2[KeyCode2["F26"] = 184] = "F26";
217
- KeyCode2[KeyCode2["F27"] = 185] = "F27";
218
- KeyCode2[KeyCode2["F28"] = 186] = "F28";
219
- KeyCode2[KeyCode2["F29"] = 187] = "F29";
220
- KeyCode2[KeyCode2["F30"] = 188] = "F30";
221
- KeyCode2[KeyCode2["F31"] = 189] = "F31";
222
- KeyCode2[KeyCode2["F32"] = 190] = "F32";
223
- KeyCode2[KeyCode2["F33"] = 191] = "F33";
224
- KeyCode2[KeyCode2["F34"] = 192] = "F34";
225
- KeyCode2[KeyCode2["F35"] = 193] = "F35";
226
- })(KeyCode ||= {});
227
- var MouseButtonCode;
228
- ((MouseButtonCode2) => {
229
- MouseButtonCode2[MouseButtonCode2["Left"] = 0] = "Left";
230
- MouseButtonCode2[MouseButtonCode2["Middle"] = 1] = "Middle";
231
- MouseButtonCode2[MouseButtonCode2["Right"] = 2] = "Right";
232
- MouseButtonCode2[MouseButtonCode2["X1"] = 3] = "X1";
233
- MouseButtonCode2[MouseButtonCode2["X2"] = 4] = "X2";
234
- MouseButtonCode2[MouseButtonCode2["X3"] = 5] = "X3";
235
- MouseButtonCode2[MouseButtonCode2["X4"] = 6] = "X4";
236
- MouseButtonCode2[MouseButtonCode2["X5"] = 7] = "X5";
237
- })(MouseButtonCode ||= {});
238
- function keyToKeyCode(key) {
239
- return KeyCode[key];
240
- }
241
- function mouseButtonToMouseButtonCode(button) {
242
- return MouseButtonCode[button];
243
- }
244
- var keysLength = Object.keys(KeyCode).length / 2;
245
-
246
- class InputSnapshot {
247
- #dataView;
248
- keys;
249
- mouse;
250
- constructor(dataView) {
251
- this.#dataView = dataView;
252
- this.keys = new KeyboardSnapshot(this.#dataView);
253
- const paddingBytes = (4 - keysLength % 4) % 4;
254
- this.mouse = new MouseSnapshot(this.#dataView, keysLength + paddingBytes);
255
- }
256
- update(events) {
257
- for (const event of events) {
258
- switch (event.type) {
259
- case "keydown":
260
- case "keyup":
261
- this.keys.update(event);
262
- break;
263
- case "mousemove":
264
- case "mousedown":
265
- case "mouseup":
266
- case "mousewheel":
267
- this.mouse.update(event);
268
- break;
269
- }
270
- }
271
- }
272
- flush() {
273
- this.keys.flush();
274
- this.mouse.flush();
275
- }
276
- }
277
-
278
- class MouseSnapshot {
279
- x = 0;
280
- y = 0;
281
- wheel = { x: 0, y: 0 };
282
- left = { down: false, held: false, up: false };
283
- middle = { down: false, held: false, up: false };
284
- right = { down: false, held: false, up: false };
285
- #dataView;
286
- #offset;
287
- constructor(dataView, offset) {
288
- this.#dataView = dataView;
289
- this.#offset = offset;
290
- }
291
- update(event) {
292
- switch (event.type) {
293
- case "mousemove":
294
- this.x = event.x;
295
- this.y = event.y;
296
- break;
297
- case "mousedown":
298
- if (event.button === "Left") {
299
- this.left.down = true;
300
- this.left.held = true;
301
- this.left.up = false;
302
- }
303
- if (event.button === "Middle") {
304
- this.middle.down = true;
305
- this.middle.held = true;
306
- this.middle.up = false;
307
- }
308
- if (event.button === "Right") {
309
- this.right.down = true;
310
- this.right.held = true;
311
- this.right.up = false;
312
- }
313
- break;
314
- case "mouseup":
315
- if (event.button === "Left") {
316
- this.left.down = false;
317
- this.left.held = false;
318
- this.left.up = true;
319
- }
320
- if (event.button === "Middle") {
321
- this.middle.down = false;
322
- this.middle.held = false;
323
- this.middle.up = true;
324
- }
325
- if (event.button === "Right") {
326
- this.right.down = false;
327
- this.right.held = false;
328
- this.right.up = true;
329
- }
330
- break;
331
- case "mousewheel":
332
- this.wheel.x = event.x;
333
- this.wheel.y = event.y;
334
- break;
335
- }
336
- }
337
- flush() {
338
- this.left.down = this.right.down = this.middle.down = false;
339
- this.left.up = this.right.up = this.middle.up = false;
340
- }
341
- }
342
-
343
- class KeyboardSnapshot {
344
- #dataView;
345
- #offset;
346
- #keystates = new Map;
347
- constructor(dataView) {
348
- this.#dataView = dataView;
349
- this.#offset = 0;
350
- }
351
- update(event) {
352
- switch (event.type) {
353
- case "keyup": {
354
- const keyCode = keyToKeyCode(event.key);
355
- const keystate = this.#keystate(keyCode);
356
- keystate.down = false;
357
- keystate.held = false;
358
- keystate.up = true;
359
- break;
360
- }
361
- case "keydown": {
362
- const keyCode = keyToKeyCode(event.key);
363
- const keystate = this.#keystate(keyCode);
364
- keystate.down = true;
365
- keystate.held = true;
366
- keystate.up = false;
367
- break;
368
- }
369
- }
370
- }
371
- flush() {
372
- for (const [, state] of this.#keystates) {
373
- state.down = false;
374
- state.up = false;
375
- }
376
- }
377
- get shift() {
378
- return this.shiftLeft || this.shiftRight;
379
- }
380
- get alt() {
381
- return this.altLeft || this.altRight;
382
- }
383
- get control() {
384
- return this.controlLeft || this.controlRight;
385
- }
386
- get meta() {
387
- return this.metaLeft || this.metaRight;
388
- }
389
- get backquote() {
390
- return this.#keystate(0 /* Backquote */);
391
- }
392
- get backslash() {
393
- return this.#keystate(1 /* Backslash */);
394
- }
395
- get bracketLeft() {
396
- return this.#keystate(2 /* BracketLeft */);
397
- }
398
- get bracketRight() {
399
- return this.#keystate(3 /* BracketRight */);
400
- }
401
- get comma() {
402
- return this.#keystate(4 /* Comma */);
403
- }
404
- get digit0() {
405
- return this.#keystate(5 /* Digit0 */);
406
- }
407
- get digit1() {
408
- return this.#keystate(6 /* Digit1 */);
409
- }
410
- get digit2() {
411
- return this.#keystate(7 /* Digit2 */);
412
- }
413
- get digit3() {
414
- return this.#keystate(8 /* Digit3 */);
415
- }
416
- get digit4() {
417
- return this.#keystate(9 /* Digit4 */);
418
- }
419
- get digit5() {
420
- return this.#keystate(10 /* Digit5 */);
421
- }
422
- get digit6() {
423
- return this.#keystate(11 /* Digit6 */);
424
- }
425
- get digit7() {
426
- return this.#keystate(12 /* Digit7 */);
427
- }
428
- get digit8() {
429
- return this.#keystate(13 /* Digit8 */);
430
- }
431
- get digit9() {
432
- return this.#keystate(14 /* Digit9 */);
433
- }
434
- get equal() {
435
- return this.#keystate(15 /* Equal */);
436
- }
437
- get intlBackslash() {
438
- return this.#keystate(16 /* IntlBackslash */);
439
- }
440
- get intlRo() {
441
- return this.#keystate(17 /* IntlRo */);
442
- }
443
- get intlYen() {
444
- return this.#keystate(18 /* IntlYen */);
445
- }
446
- get a() {
447
- return this.#keystate(19 /* KeyA */);
448
- }
449
- get b() {
450
- return this.#keystate(20 /* KeyB */);
451
- }
452
- get c() {
453
- return this.#keystate(21 /* KeyC */);
454
- }
455
- get d() {
456
- return this.#keystate(22 /* KeyD */);
457
- }
458
- get e() {
459
- return this.#keystate(23 /* KeyE */);
460
- }
461
- get f() {
462
- return this.#keystate(24 /* KeyF */);
463
- }
464
- get g() {
465
- return this.#keystate(25 /* KeyG */);
466
- }
467
- get h() {
468
- return this.#keystate(26 /* KeyH */);
469
- }
470
- get i() {
471
- return this.#keystate(27 /* KeyI */);
472
- }
473
- get j() {
474
- return this.#keystate(28 /* KeyJ */);
475
- }
476
- get k() {
477
- return this.#keystate(29 /* KeyK */);
478
- }
479
- get l() {
480
- return this.#keystate(30 /* KeyL */);
481
- }
482
- get m() {
483
- return this.#keystate(31 /* KeyM */);
484
- }
485
- get n() {
486
- return this.#keystate(32 /* KeyN */);
487
- }
488
- get o() {
489
- return this.#keystate(33 /* KeyO */);
490
- }
491
- get p() {
492
- return this.#keystate(34 /* KeyP */);
493
- }
494
- get q() {
495
- return this.#keystate(35 /* KeyQ */);
496
- }
497
- get r() {
498
- return this.#keystate(36 /* KeyR */);
499
- }
500
- get s() {
501
- return this.#keystate(37 /* KeyS */);
502
- }
503
- get t() {
504
- return this.#keystate(38 /* KeyT */);
505
- }
506
- get u() {
507
- return this.#keystate(39 /* KeyU */);
508
- }
509
- get v() {
510
- return this.#keystate(40 /* KeyV */);
511
- }
512
- get w() {
513
- return this.#keystate(41 /* KeyW */);
514
- }
515
- get x() {
516
- return this.#keystate(42 /* KeyX */);
517
- }
518
- get y() {
519
- return this.#keystate(43 /* KeyY */);
520
- }
521
- get z() {
522
- return this.#keystate(44 /* KeyZ */);
523
- }
524
- get minus() {
525
- return this.#keystate(45 /* Minus */);
526
- }
527
- get period() {
528
- return this.#keystate(46 /* Period */);
529
- }
530
- get quote() {
531
- return this.#keystate(47 /* Quote */);
532
- }
533
- get semicolon() {
534
- return this.#keystate(48 /* Semicolon */);
535
- }
536
- get slash() {
537
- return this.#keystate(49 /* Slash */);
538
- }
539
- get altLeft() {
540
- return this.#keystate(50 /* AltLeft */);
541
- }
542
- get altRight() {
543
- return this.#keystate(51 /* AltRight */);
544
- }
545
- get backspace() {
546
- return this.#keystate(52 /* Backspace */);
547
- }
548
- get capsLock() {
549
- return this.#keystate(53 /* CapsLock */);
550
- }
551
- get contextMenu() {
552
- return this.#keystate(54 /* ContextMenu */);
553
- }
554
- get controlLeft() {
555
- return this.#keystate(55 /* ControlLeft */);
556
- }
557
- get controlRight() {
558
- return this.#keystate(56 /* ControlRight */);
559
- }
560
- get enter() {
561
- return this.#keystate(57 /* Enter */);
562
- }
563
- get metaLeft() {
564
- return this.#keystate(58 /* MetaLeft */);
565
- }
566
- get metaRight() {
567
- return this.#keystate(59 /* MetaRight */);
568
- }
569
- get shiftLeft() {
570
- return this.#keystate(60 /* ShiftLeft */);
571
- }
572
- get shiftRight() {
573
- return this.#keystate(61 /* ShiftRight */);
574
- }
575
- get space() {
576
- return this.#keystate(62 /* Space */);
577
- }
578
- get tab() {
579
- return this.#keystate(63 /* Tab */);
580
- }
581
- get convert() {
582
- return this.#keystate(64 /* Convert */);
583
- }
584
- get kanaMode() {
585
- return this.#keystate(65 /* KanaMode */);
586
- }
587
- get lang1() {
588
- return this.#keystate(66 /* Lang1 */);
589
- }
590
- get lang2() {
591
- return this.#keystate(67 /* Lang2 */);
592
- }
593
- get lang3() {
594
- return this.#keystate(68 /* Lang3 */);
595
- }
596
- get lang4() {
597
- return this.#keystate(69 /* Lang4 */);
598
- }
599
- get lang5() {
600
- return this.#keystate(70 /* Lang5 */);
601
- }
602
- get nonConvert() {
603
- return this.#keystate(71 /* NonConvert */);
604
- }
605
- get delete() {
606
- return this.#keystate(72 /* Delete */);
607
- }
608
- get end() {
609
- return this.#keystate(73 /* End */);
610
- }
611
- get help() {
612
- return this.#keystate(74 /* Help */);
613
- }
614
- get home() {
615
- return this.#keystate(75 /* Home */);
616
- }
617
- get insert() {
618
- return this.#keystate(76 /* Insert */);
619
- }
620
- get pageDown() {
621
- return this.#keystate(77 /* PageDown */);
622
- }
623
- get pageUp() {
624
- return this.#keystate(78 /* PageUp */);
625
- }
626
- get arrowDown() {
627
- return this.#keystate(79 /* ArrowDown */);
628
- }
629
- get arrowLeft() {
630
- return this.#keystate(80 /* ArrowLeft */);
631
- }
632
- get arrowRight() {
633
- return this.#keystate(81 /* ArrowRight */);
634
- }
635
- get arrowUp() {
636
- return this.#keystate(82 /* ArrowUp */);
637
- }
638
- get numLock() {
639
- return this.#keystate(83 /* NumLock */);
640
- }
641
- get numpad0() {
642
- return this.#keystate(84 /* Numpad0 */);
643
- }
644
- get numpad1() {
645
- return this.#keystate(85 /* Numpad1 */);
646
- }
647
- get numpad2() {
648
- return this.#keystate(86 /* Numpad2 */);
649
- }
650
- get numpad3() {
651
- return this.#keystate(87 /* Numpad3 */);
652
- }
653
- get numpad4() {
654
- return this.#keystate(88 /* Numpad4 */);
655
- }
656
- get numpad5() {
657
- return this.#keystate(89 /* Numpad5 */);
658
- }
659
- get numpad6() {
660
- return this.#keystate(90 /* Numpad6 */);
661
- }
662
- get numpad7() {
663
- return this.#keystate(91 /* Numpad7 */);
664
- }
665
- get numpad8() {
666
- return this.#keystate(92 /* Numpad8 */);
667
- }
668
- get numpad9() {
669
- return this.#keystate(93 /* Numpad9 */);
670
- }
671
- get numpadAdd() {
672
- return this.#keystate(94 /* NumpadAdd */);
673
- }
674
- get numpadBackspace() {
675
- return this.#keystate(95 /* NumpadBackspace */);
676
- }
677
- get numpadClear() {
678
- return this.#keystate(96 /* NumpadClear */);
679
- }
680
- get numpadClearEntry() {
681
- return this.#keystate(97 /* NumpadClearEntry */);
682
- }
683
- get numpadComma() {
684
- return this.#keystate(98 /* NumpadComma */);
685
- }
686
- get numpadDecimal() {
687
- return this.#keystate(99 /* NumpadDecimal */);
688
- }
689
- get numpadDivide() {
690
- return this.#keystate(100 /* NumpadDivide */);
691
- }
692
- get numpadEnter() {
693
- return this.#keystate(101 /* NumpadEnter */);
694
- }
695
- get numpadEqual() {
696
- return this.#keystate(102 /* NumpadEqual */);
697
- }
698
- get numpadHash() {
699
- return this.#keystate(103 /* NumpadHash */);
700
- }
701
- get numpadMemoryAdd() {
702
- return this.#keystate(104 /* NumpadMemoryAdd */);
703
- }
704
- get numpadMemoryClear() {
705
- return this.#keystate(105 /* NumpadMemoryClear */);
706
- }
707
- get numpadMemoryRecall() {
708
- return this.#keystate(106 /* NumpadMemoryRecall */);
709
- }
710
- get numpadMemoryStore() {
711
- return this.#keystate(107 /* NumpadMemoryStore */);
712
- }
713
- get numpadMemorySubtract() {
714
- return this.#keystate(108 /* NumpadMemorySubtract */);
715
- }
716
- get numpadMultiply() {
717
- return this.#keystate(109 /* NumpadMultiply */);
718
- }
719
- get numpadParenLeft() {
720
- return this.#keystate(110 /* NumpadParenLeft */);
721
- }
722
- get numpadParenRight() {
723
- return this.#keystate(111 /* NumpadParenRight */);
724
- }
725
- get numpadStar() {
726
- return this.#keystate(112 /* NumpadStar */);
727
- }
728
- get numpadSubtract() {
729
- return this.#keystate(113 /* NumpadSubtract */);
730
- }
731
- get escape() {
732
- return this.#keystate(114 /* Escape */);
733
- }
734
- get fn() {
735
- return this.#keystate(115 /* Fn */);
736
- }
737
- get fnLock() {
738
- return this.#keystate(116 /* FnLock */);
739
- }
740
- get printScreen() {
741
- return this.#keystate(117 /* PrintScreen */);
742
- }
743
- get scrollLock() {
744
- return this.#keystate(118 /* ScrollLock */);
745
- }
746
- get pause() {
747
- return this.#keystate(119 /* Pause */);
748
- }
749
- get browserBack() {
750
- return this.#keystate(120 /* BrowserBack */);
751
- }
752
- get browserFavorites() {
753
- return this.#keystate(121 /* BrowserFavorites */);
754
- }
755
- get browserForward() {
756
- return this.#keystate(122 /* BrowserForward */);
757
- }
758
- get browserHome() {
759
- return this.#keystate(123 /* BrowserHome */);
760
- }
761
- get browserRefresh() {
762
- return this.#keystate(124 /* BrowserRefresh */);
763
- }
764
- get browserSearch() {
765
- return this.#keystate(125 /* BrowserSearch */);
766
- }
767
- get browserStop() {
768
- return this.#keystate(126 /* BrowserStop */);
769
- }
770
- get eject() {
771
- return this.#keystate(127 /* Eject */);
772
- }
773
- get launchApp1() {
774
- return this.#keystate(128 /* LaunchApp1 */);
775
- }
776
- get launchApp2() {
777
- return this.#keystate(129 /* LaunchApp2 */);
778
- }
779
- get launchMail() {
780
- return this.#keystate(130 /* LaunchMail */);
781
- }
782
- get mediaPlayPause() {
783
- return this.#keystate(131 /* MediaPlayPause */);
784
- }
785
- get mediaSelect() {
786
- return this.#keystate(132 /* MediaSelect */);
787
- }
788
- get mediaStop() {
789
- return this.#keystate(133 /* MediaStop */);
790
- }
791
- get mediaTrackNext() {
792
- return this.#keystate(134 /* MediaTrackNext */);
793
- }
794
- get mediaTrackPrevious() {
795
- return this.#keystate(135 /* MediaTrackPrevious */);
796
- }
797
- get power() {
798
- return this.#keystate(136 /* Power */);
799
- }
800
- get sleep() {
801
- return this.#keystate(137 /* Sleep */);
802
- }
803
- get audioVolumeDown() {
804
- return this.#keystate(138 /* AudioVolumeDown */);
805
- }
806
- get audioVolumeMute() {
807
- return this.#keystate(139 /* AudioVolumeMute */);
808
- }
809
- get audioVolumeUp() {
810
- return this.#keystate(140 /* AudioVolumeUp */);
811
- }
812
- get wakeUp() {
813
- return this.#keystate(141 /* WakeUp */);
814
- }
815
- get hyper() {
816
- return this.#keystate(142 /* Hyper */);
817
- }
818
- get super() {
819
- return this.#keystate(143 /* Super */);
820
- }
821
- get turbo() {
822
- return this.#keystate(144 /* Turbo */);
823
- }
824
- get abort() {
825
- return this.#keystate(145 /* Abort */);
826
- }
827
- get resume() {
828
- return this.#keystate(146 /* Resume */);
829
- }
830
- get suspend() {
831
- return this.#keystate(147 /* Suspend */);
832
- }
833
- get again() {
834
- return this.#keystate(148 /* Again */);
835
- }
836
- get copy() {
837
- return this.#keystate(149 /* Copy */);
838
- }
839
- get cut() {
840
- return this.#keystate(150 /* Cut */);
841
- }
842
- get find() {
843
- return this.#keystate(151 /* Find */);
844
- }
845
- get open() {
846
- return this.#keystate(152 /* Open */);
847
- }
848
- get paste() {
849
- return this.#keystate(153 /* Paste */);
850
- }
851
- get props() {
852
- return this.#keystate(154 /* Props */);
853
- }
854
- get select() {
855
- return this.#keystate(155 /* Select */);
856
- }
857
- get undo() {
858
- return this.#keystate(156 /* Undo */);
859
- }
860
- get hiragana() {
861
- return this.#keystate(157 /* Hiragana */);
862
- }
863
- get katakana() {
864
- return this.#keystate(158 /* Katakana */);
865
- }
866
- get f1() {
867
- return this.#keystate(159 /* F1 */);
868
- }
869
- get f2() {
870
- return this.#keystate(160 /* F2 */);
871
- }
872
- get f3() {
873
- return this.#keystate(161 /* F3 */);
874
- }
875
- get f4() {
876
- return this.#keystate(162 /* F4 */);
877
- }
878
- get f5() {
879
- return this.#keystate(163 /* F5 */);
880
- }
881
- get f6() {
882
- return this.#keystate(164 /* F6 */);
883
- }
884
- get f7() {
885
- return this.#keystate(165 /* F7 */);
886
- }
887
- get f8() {
888
- return this.#keystate(166 /* F8 */);
889
- }
890
- get f9() {
891
- return this.#keystate(167 /* F9 */);
892
- }
893
- get f10() {
894
- return this.#keystate(168 /* F10 */);
895
- }
896
- get f11() {
897
- return this.#keystate(169 /* F11 */);
898
- }
899
- get f12() {
900
- return this.#keystate(170 /* F12 */);
901
- }
902
- get f13() {
903
- return this.#keystate(171 /* F13 */);
904
- }
905
- get f14() {
906
- return this.#keystate(172 /* F14 */);
907
- }
908
- get f15() {
909
- return this.#keystate(173 /* F15 */);
910
- }
911
- get f16() {
912
- return this.#keystate(174 /* F16 */);
913
- }
914
- get f17() {
915
- return this.#keystate(175 /* F17 */);
916
- }
917
- get f18() {
918
- return this.#keystate(176 /* F18 */);
919
- }
920
- get f19() {
921
- return this.#keystate(177 /* F19 */);
922
- }
923
- get f20() {
924
- return this.#keystate(178 /* F20 */);
925
- }
926
- get f21() {
927
- return this.#keystate(179 /* F21 */);
928
- }
929
- get f22() {
930
- return this.#keystate(180 /* F22 */);
931
- }
932
- get f23() {
933
- return this.#keystate(181 /* F23 */);
934
- }
935
- get f24() {
936
- return this.#keystate(182 /* F24 */);
937
- }
938
- get f25() {
939
- return this.#keystate(183 /* F25 */);
940
- }
941
- get f26() {
942
- return this.#keystate(184 /* F26 */);
943
- }
944
- get f27() {
945
- return this.#keystate(185 /* F27 */);
946
- }
947
- get f28() {
948
- return this.#keystate(186 /* F28 */);
949
- }
950
- get f29() {
951
- return this.#keystate(187 /* F29 */);
952
- }
953
- get f30() {
954
- return this.#keystate(188 /* F30 */);
955
- }
956
- get f31() {
957
- return this.#keystate(189 /* F31 */);
958
- }
959
- get f32() {
960
- return this.#keystate(190 /* F32 */);
961
- }
962
- get f33() {
963
- return this.#keystate(191 /* F33 */);
964
- }
965
- get f34() {
966
- return this.#keystate(192 /* F34 */);
967
- }
968
- get f35() {
969
- return this.#keystate(193 /* F35 */);
970
- }
971
- #keystate(code) {
972
- let state;
973
- if (this.#keystates.has(code)) {
974
- state = this.#keystates.get(code);
975
- } else {
976
- state = {
977
- down: false,
978
- held: false,
979
- up: false
980
- };
981
- this.#keystates.set(code, state);
982
- }
983
- return state;
984
- }
985
- }
986
-
987
- // js/events.ts
988
- function encodeEvent(event, target) {
989
- const size = eventSize(event);
990
- const buffer = target ?? new Uint8Array(size);
991
- if (buffer.byteLength !== size) {
992
- throw new Error(`Buffer size mismatch: expected ${size}, got ${buffer.byteLength}`);
993
- }
994
- const dataView = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
995
- switch (event.type) {
996
- case "keydown":
997
- case "keyup": {
998
- dataView.setUint8(0, keyToKeyCode(event.key));
999
- break;
1000
- }
1001
- case "mousemove":
1002
- case "mousewheel": {
1003
- dataView.setFloat32(0, event.x, true);
1004
- dataView.setFloat32(Float32Array.BYTES_PER_ELEMENT, event.y, true);
1005
- break;
1006
- }
1007
- case "mousedown":
1008
- case "mouseup": {
1009
- dataView.setUint8(0, mouseButtonToMouseButtonCode(event.button));
1010
- }
1011
- }
1012
- return buffer;
1013
- }
1014
- function decodeEvent(buffer) {
1015
- const dataView = new DataView(buffer.buffer, buffer.byteOffset, buffer.byteLength);
1016
- const typeByte = dataView.getUint8(0);
1017
- switch (typeByte) {
1018
- case 0: {
1019
- const keyCode = dataView.getUint8(1);
1020
- return {
1021
- type: "keydown",
1022
- key: KeyCode[keyCode]
1023
- };
1024
- }
1025
- case 1: {
1026
- const x = dataView.getFloat32(1, true);
1027
- const y = dataView.getFloat32(Float32Array.BYTES_PER_ELEMENT + 1, true);
1028
- return {
1029
- type: "mousemove",
1030
- x,
1031
- y
1032
- };
1033
- }
1034
- case 2: {
1035
- const buttonCode = dataView.getUint8(1);
1036
- return {
1037
- type: "mousedown",
1038
- button: MouseButtonCode[buttonCode]
1039
- };
1040
- }
1041
- default:
1042
- throw new Error(`Unknown event type byte: ${typeByte}`);
1043
- }
1044
- }
1045
- function eventSize(event) {
1046
- return 1 + payloadSize(event);
1047
- }
1048
- function payloadSize(event) {
1049
- switch (event.type) {
1050
- case "keydown":
1051
- case "keyheld":
1052
- case "keyup":
1053
- case "mousedown":
1054
- case "mouseup":
1055
- return Uint8Array.BYTES_PER_ELEMENT * 1;
1056
- case "mousemove":
1057
- case "mousewheel":
1058
- case "mouseheld":
1059
- return Float32Array.BYTES_PER_ELEMENT * 2;
1060
- }
1061
- }
1062
-
1063
- // js/mod.ts
1064
- var DEFAULT_WASM_URL = new URL("../wasm/bloop.wasm", import.meta.url);
1065
- async function mount(opts) {
1066
- const bytes = await Bun.file(opts.wasmUrl ?? DEFAULT_WASM_URL).arrayBuffer();
1067
- const platformEvents = [];
1068
- const wasmInstantiatedSource = await WebAssembly.instantiate(bytes, {
1069
- env: {
1070
- __cb: function(a) {
1071
- opts.systemsCallback(platformEvents);
1072
- platformEvents.splice(0, platformEvents.length);
1073
- },
1074
- console_log: function(ptr, len) {}
1075
- }
1076
- });
1077
- const wasm = wasmInstantiatedSource.instance.exports;
1078
- return {
1079
- runtime: {
1080
- step(ms) {
1081
- wasm.step(ms || Math.floor(1000 / 60));
1082
- }
1083
- },
1084
- wasm,
1085
- emitter: {
1086
- keydown(key) {
1087
- platformEvents.push({ type: "keydown", key });
1088
- },
1089
- keyup(key) {
1090
- platformEvents.push({ type: "keyup", key });
1091
- },
1092
- mousemove(x, y) {
1093
- platformEvents.push({ type: "mousemove", x, y });
1094
- },
1095
- mousedown(button) {
1096
- platformEvents.push({ type: "mousedown", button, pressure: 1 });
1097
- },
1098
- mouseup(button) {
1099
- platformEvents.push({ type: "mouseup", button, pressure: 0 });
1100
- },
1101
- mousewheel(x, y) {
1102
- platformEvents.push({ type: "mousewheel", x, y });
1103
- }
1104
- }
1105
- };
1106
- }
1107
- export {
1108
- mount,
1109
- exports_inputs as EngineInputs,
1110
- exports_events as EngineEvents,
1111
- DEFAULT_WASM_URL
1112
- };
1113
-
1114
- //# debugId=00789BC353ABD1CB64756E2164756E21
1115
- //# sourceMappingURL=mod.js.map