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