@bloopjs/bloop 0.0.21 → 0.0.23
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/bloop.d.ts +12 -13
- package/dist/bloop.d.ts.map +1 -1
- package/dist/mod.d.ts +6 -2
- package/dist/mod.d.ts.map +1 -1
- package/dist/mod.js +140 -129
- package/dist/mod.js.map +7 -6
- package/dist/mount.d.ts +17 -0
- package/dist/mount.d.ts.map +1 -0
- package/dist/runtime.d.ts +11 -21
- package/dist/runtime.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/bloop.ts +145 -129
- package/src/mod.ts +8 -3
- package/src/mount.ts +86 -0
- package/src/runtime.ts +41 -94
package/dist/bloop.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { type EnginePointer } from "@bloopjs/engine";
|
|
2
1
|
import type { Context } from "./context";
|
|
3
2
|
import type { Bag } from "./data/bag";
|
|
4
3
|
import type { BloopSchema } from "./data/schema";
|
|
5
|
-
import type {
|
|
4
|
+
import type { EngineHooks } from "./runtime";
|
|
6
5
|
import type { System } from "./system";
|
|
7
6
|
export type BloopOpts<B extends Bag> = {
|
|
8
7
|
/** defaults to "Game" */
|
|
@@ -27,26 +26,26 @@ export declare class Bloop<GS extends BloopSchema> {
|
|
|
27
26
|
* Bloop.create() is the way to create a new bloop instance.
|
|
28
27
|
*/
|
|
29
28
|
static create<B extends Bag>(opts?: BloopOpts<B>): Bloop<MakeGS<B>>;
|
|
29
|
+
/**
|
|
30
|
+
* DO NOT USE `new Bloop` - use `Bloop.create()` instead for proper type hints.
|
|
31
|
+
*/
|
|
30
32
|
constructor(opts: BloopOpts<GS["B"]> | undefined, dontCallMeDirectly: string);
|
|
31
|
-
get bag(): GS["B"];
|
|
32
|
-
get context(): Readonly<Context<GS>>;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
35
|
-
* @returns linear memory representation of the game state that the engine is unaware of
|
|
34
|
+
* Read the game singleton bag
|
|
36
35
|
*/
|
|
37
|
-
|
|
36
|
+
get bag(): GS["B"];
|
|
38
37
|
/**
|
|
39
|
-
*
|
|
40
|
-
* @returns linear memory representation of the game state that the engine is unaware of
|
|
38
|
+
* Read the game context object
|
|
41
39
|
*/
|
|
42
|
-
|
|
40
|
+
get context(): Readonly<Context<GS>>;
|
|
43
41
|
/**
|
|
44
42
|
* Register a system with the game loop.
|
|
45
|
-
*
|
|
46
43
|
*/
|
|
47
44
|
system(label: string, system: System<GS>): number;
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
/**
|
|
46
|
+
* Low level hooks to engine functionality. Editing these is for advanced use cases, defaults should usually work.
|
|
47
|
+
*/
|
|
48
|
+
hooks: EngineHooks;
|
|
50
49
|
}
|
|
51
50
|
type MakeGS<B extends Bag> = BloopSchema<B>;
|
|
52
51
|
export {};
|
package/dist/bloop.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bloop.d.ts","sourceRoot":"","sources":["../src/bloop.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bloop.d.ts","sourceRoot":"","sources":["../src/bloop.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAQjD,OAAO,KAAK,EAAiB,WAAW,EAAe,MAAM,WAAW,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEvC,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,GAAG,IAAI;IACrC,yBAAyB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;OAIG;IAEH;;OAEG;IAEH;;;OAGG;IACH,GAAG,CAAC,EAAE,CAAC,CAAC;CAET,CAAC;AAEF,qBAAa,KAAK,CAAC,EAAE,SAAS,WAAW;;IAKvC;;OAEG;IACH,MAAM,CAAC,MAAM,CAGX,CAAC,SAAS,GAAG,EAGb,IAAI,GAAE,SAAS,CAAC,CAAC,CAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAI5C;;OAEG;gBACS,IAAI,EAAE,SAAS,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,YAAK,EAAE,kBAAkB,EAAE,MAAM;IAerE;;OAEG;IACH,IAAI,GAAG,IAAI,EAAE,CAAC,GAAG,CAAC,CAEjB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAEnC;IAED;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM;IAMjD;;OAEG;IACH,KAAK,EAAE,WAAW,CAsIhB;CACH;AAUD,KAAK,MAAM,CAAC,CAAC,SAAS,GAAG,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC"}
|
package/dist/mod.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export * from "./runtime";
|
|
2
|
-
export * from "./
|
|
1
|
+
export type * as typesRuntime from "./runtime";
|
|
2
|
+
export type * as typesMount from "./mount";
|
|
3
|
+
export type * as typesBloop from "./bloop";
|
|
4
|
+
export type * as typesContext from "./context";
|
|
3
5
|
export * as Util from "./util";
|
|
6
|
+
export { mount } from "./mount";
|
|
7
|
+
export { Bloop } from "./bloop";
|
|
4
8
|
//# sourceMappingURL=mod.d.ts.map
|
package/dist/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,YAAY,KAAK,YAAY,MAAM,WAAW,CAAA;AAC9C,YAAY,KAAK,UAAU,MAAM,SAAS,CAAA;AAC1C,YAAY,KAAK,UAAU,MAAM,SAAS,CAAA;AAC1C,YAAY,KAAK,YAAY,MAAM,WAAW,CAAA;AAE9C,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA"}
|
package/dist/mod.js
CHANGED
|
@@ -9,6 +9,31 @@ var __export = (target, all) => {
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
+
// src/util.ts
|
|
13
|
+
var exports_util = {};
|
|
14
|
+
__export(exports_util, {
|
|
15
|
+
unwrap: () => unwrap,
|
|
16
|
+
toHexString: () => toHexString,
|
|
17
|
+
assert: () => assert
|
|
18
|
+
});
|
|
19
|
+
function toHexString(dataView, length) {
|
|
20
|
+
length ??= dataView.byteLength;
|
|
21
|
+
let hexString = "";
|
|
22
|
+
for (let i = 0;i < length; i++) {
|
|
23
|
+
const byte = dataView.getUint8(i);
|
|
24
|
+
hexString += `${byte.toString(16).padStart(2, "0")} `;
|
|
25
|
+
}
|
|
26
|
+
return hexString.trim();
|
|
27
|
+
}
|
|
28
|
+
function assert(condition, message) {
|
|
29
|
+
if (condition == null || condition === false) {
|
|
30
|
+
throw new Error(message ?? "Assertion failed");
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
function unwrap(value, message) {
|
|
34
|
+
assert(value != null, message ?? `Unwrap failed: value is ${value}`);
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
12
37
|
// ../engine/dist/engine.js
|
|
13
38
|
var __defProp2 = Object.defineProperty;
|
|
14
39
|
var __export2 = (target, all) => {
|
|
@@ -991,33 +1016,17 @@ var EVENTS_OFFSET = INPUT_CTX_OFFSET + 4;
|
|
|
991
1016
|
var SNAPSHOT_HEADER_USER_LEN_OFFSET = 4;
|
|
992
1017
|
var SNAPSHOT_HEADER_ENGINE_LEN_OFFSET = 8;
|
|
993
1018
|
|
|
994
|
-
// src/
|
|
995
|
-
var
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
});
|
|
1001
|
-
function toHexString(dataView, length) {
|
|
1002
|
-
length ??= dataView.byteLength;
|
|
1003
|
-
let hexString = "";
|
|
1004
|
-
for (let i = 0;i < length; i++) {
|
|
1005
|
-
const byte = dataView.getUint8(i);
|
|
1006
|
-
hexString += `${byte.toString(16).padStart(2, "0")} `;
|
|
1007
|
-
}
|
|
1008
|
-
return hexString.trim();
|
|
1009
|
-
}
|
|
1010
|
-
function assert(condition, message) {
|
|
1011
|
-
if (condition == null || condition === false) {
|
|
1012
|
-
throw new Error(message ?? "Assertion failed");
|
|
1013
|
-
}
|
|
1019
|
+
// src/runtime.ts
|
|
1020
|
+
var originalConsole = globalThis.console;
|
|
1021
|
+
var noop = () => {};
|
|
1022
|
+
var stubConsole = Object.fromEntries(Object.keys(originalConsole).map((key) => [key, noop]));
|
|
1023
|
+
function muteConsole() {
|
|
1024
|
+
globalThis.console = stubConsole;
|
|
1014
1025
|
}
|
|
1015
|
-
function
|
|
1016
|
-
|
|
1017
|
-
return value;
|
|
1026
|
+
function unmuteConsole() {
|
|
1027
|
+
globalThis.console = originalConsole;
|
|
1018
1028
|
}
|
|
1019
1029
|
|
|
1020
|
-
// src/runtime.ts
|
|
1021
1030
|
class Runtime {
|
|
1022
1031
|
wasm;
|
|
1023
1032
|
#memory;
|
|
@@ -1040,7 +1049,14 @@ class Runtime {
|
|
|
1040
1049
|
}
|
|
1041
1050
|
seek(frame) {
|
|
1042
1051
|
assert(this.hasHistory, "Not recording or playing back, can't seek to frame");
|
|
1052
|
+
const shouldMute = frame < this.time.frame;
|
|
1053
|
+
if (shouldMute) {
|
|
1054
|
+
muteConsole();
|
|
1055
|
+
}
|
|
1043
1056
|
this.wasm.seek(frame);
|
|
1057
|
+
if (shouldMute) {
|
|
1058
|
+
unmuteConsole();
|
|
1059
|
+
}
|
|
1044
1060
|
}
|
|
1045
1061
|
record() {
|
|
1046
1062
|
const serializer = this.#serialize ? this.#serialize() : null;
|
|
@@ -1109,18 +1125,20 @@ class Runtime {
|
|
|
1109
1125
|
}
|
|
1110
1126
|
};
|
|
1111
1127
|
}
|
|
1128
|
+
|
|
1129
|
+
// src/mount.ts
|
|
1112
1130
|
async function mount(opts) {
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1131
|
+
const bytes = await fetch(opts.wasmUrl ?? DEFAULT_WASM_URL).then((res) => res.arrayBuffer()).catch((e) => {
|
|
1132
|
+
console.error(`Failed to fetch wasm at ${opts.wasmUrl ?? DEFAULT_WASM_URL}`, e);
|
|
1133
|
+
throw e;
|
|
1134
|
+
});
|
|
1117
1135
|
const memory = new WebAssembly.Memory({ initial: 17, maximum: 1000 });
|
|
1118
1136
|
const wasmInstantiatedSource = await WebAssembly.instantiate(bytes, {
|
|
1119
1137
|
env: {
|
|
1120
1138
|
memory,
|
|
1121
1139
|
__cb: function(system_handle, ptr) {
|
|
1122
|
-
opts.setBuffer(memory.buffer);
|
|
1123
|
-
opts.systemsCallback(system_handle, ptr);
|
|
1140
|
+
opts.hooks.setBuffer(memory.buffer);
|
|
1141
|
+
opts.hooks.systemsCallback(system_handle, ptr);
|
|
1124
1142
|
},
|
|
1125
1143
|
console_log: function(ptr, len) {
|
|
1126
1144
|
const bytes2 = new Uint8Array(memory.buffer, ptr, len);
|
|
@@ -1128,31 +1146,23 @@ async function mount(opts) {
|
|
|
1128
1146
|
console.log(string);
|
|
1129
1147
|
},
|
|
1130
1148
|
user_data_len: function() {
|
|
1131
|
-
const serializer = opts.
|
|
1149
|
+
const serializer = opts.hooks.serialize();
|
|
1132
1150
|
return serializer ? serializer.size : 0;
|
|
1133
1151
|
},
|
|
1134
1152
|
user_data_serialize: function(ptr, len) {
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
}
|
|
1138
|
-
const serializer = opts.serialize();
|
|
1139
|
-
if (len !== serializer.size) {
|
|
1140
|
-
throw new Error(`user_data_write length mismatch, expected=${serializer.size} got=${len}`);
|
|
1141
|
-
}
|
|
1153
|
+
const serializer = opts.hooks.serialize();
|
|
1154
|
+
assert(len === serializer.size, `user_data_serialize length mismatch, expected=${serializer.size} got=${len}`);
|
|
1142
1155
|
serializer.write(memory.buffer, ptr);
|
|
1143
1156
|
},
|
|
1144
1157
|
user_data_deserialize: function(ptr, len) {
|
|
1145
|
-
|
|
1146
|
-
return;
|
|
1147
|
-
}
|
|
1148
|
-
opts.deserialize(memory.buffer, ptr, len);
|
|
1158
|
+
opts.hooks.deserialize(memory.buffer, ptr, len);
|
|
1149
1159
|
}
|
|
1150
1160
|
}
|
|
1151
1161
|
});
|
|
1152
1162
|
const wasm = wasmInstantiatedSource.instance.exports;
|
|
1153
1163
|
wasm.initialize();
|
|
1154
1164
|
const runtime = new Runtime(wasm, memory, {
|
|
1155
|
-
serialize: opts.serialize
|
|
1165
|
+
serialize: opts.hooks.serialize
|
|
1156
1166
|
});
|
|
1157
1167
|
if (opts.startRecording ?? true) {
|
|
1158
1168
|
runtime.record();
|
|
@@ -1187,99 +1197,101 @@ class Bloop {
|
|
|
1187
1197
|
get context() {
|
|
1188
1198
|
return this.#context;
|
|
1189
1199
|
}
|
|
1190
|
-
serialize = () => {
|
|
1191
|
-
const str = JSON.stringify(this.#context.bag);
|
|
1192
|
-
const encoder = new TextEncoder;
|
|
1193
|
-
const textBytes = encoder.encode(str);
|
|
1194
|
-
return {
|
|
1195
|
-
size: textBytes.byteLength,
|
|
1196
|
-
write: (buffer, ptr) => {
|
|
1197
|
-
const memoryView = new Uint8Array(buffer, ptr, textBytes.byteLength);
|
|
1198
|
-
memoryView.set(textBytes);
|
|
1199
|
-
}
|
|
1200
|
-
};
|
|
1201
|
-
};
|
|
1202
|
-
deserialize = (buffer, ptr, len) => {
|
|
1203
|
-
const bagBytes = new Uint8Array(buffer, ptr, len);
|
|
1204
|
-
const decoder = new TextDecoder;
|
|
1205
|
-
const str = decoder.decode(bagBytes);
|
|
1206
|
-
try {
|
|
1207
|
-
this.#context.bag = JSON.parse(str);
|
|
1208
|
-
} catch (e) {
|
|
1209
|
-
console.error("failed to deserialize bag", { json: str, error: e });
|
|
1210
|
-
}
|
|
1211
|
-
};
|
|
1212
1200
|
system(label, system) {
|
|
1213
1201
|
system.label ??= label;
|
|
1214
1202
|
this.#systems.push(system);
|
|
1215
1203
|
return this.#systems.length;
|
|
1216
1204
|
}
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
};
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1205
|
+
hooks = {
|
|
1206
|
+
serialize: () => {
|
|
1207
|
+
const str = JSON.stringify(this.#context.bag);
|
|
1208
|
+
const encoder = new TextEncoder;
|
|
1209
|
+
const textBytes = encoder.encode(str);
|
|
1210
|
+
return {
|
|
1211
|
+
size: textBytes.byteLength,
|
|
1212
|
+
write: (buffer, ptr) => {
|
|
1213
|
+
const memoryView = new Uint8Array(buffer, ptr, textBytes.byteLength);
|
|
1214
|
+
memoryView.set(textBytes);
|
|
1215
|
+
}
|
|
1216
|
+
};
|
|
1217
|
+
},
|
|
1218
|
+
deserialize: (buffer, ptr, len) => {
|
|
1219
|
+
const bagBytes = new Uint8Array(buffer, ptr, len);
|
|
1220
|
+
const decoder = new TextDecoder;
|
|
1221
|
+
const str = decoder.decode(bagBytes);
|
|
1222
|
+
try {
|
|
1223
|
+
this.#context.bag = JSON.parse(str);
|
|
1224
|
+
} catch (e) {
|
|
1225
|
+
console.error("failed to deserialize bag", { json: str, error: e });
|
|
1226
|
+
}
|
|
1227
|
+
},
|
|
1228
|
+
setBuffer: (buffer) => {
|
|
1229
|
+
this.#engineBuffer = buffer;
|
|
1230
|
+
},
|
|
1231
|
+
systemsCallback: (system_handle, ptr) => {
|
|
1232
|
+
const dv = new DataView(this.#engineBuffer, ptr);
|
|
1233
|
+
const timeCtxPtr = dv.getUint32(TIME_CTX_OFFSET, true);
|
|
1234
|
+
const inputCtxPtr = dv.getUint32(INPUT_CTX_OFFSET, true);
|
|
1235
|
+
const eventsPtr = dv.getUint32(EVENTS_OFFSET, true);
|
|
1236
|
+
this.#context.rawPointer = ptr;
|
|
1237
|
+
this.#context.inputs.dataView = new DataView(this.#engineBuffer, inputCtxPtr);
|
|
1238
|
+
this.#context.time.dataView = new DataView(this.#engineBuffer, timeCtxPtr);
|
|
1239
|
+
const eventsDataView = new DataView(this.#engineBuffer, eventsPtr);
|
|
1240
|
+
for (const system of this.#systems) {
|
|
1241
|
+
system.update?.(this.#context);
|
|
1242
|
+
const eventCount = eventsDataView.getUint32(0, true);
|
|
1243
|
+
let offset = Uint32Array.BYTES_PER_ELEMENT;
|
|
1244
|
+
for (let i = 0;i < eventCount; i++) {
|
|
1245
|
+
const eventType = eventsDataView.getUint8(offset);
|
|
1246
|
+
const payloadSize = EVENT_PAYLOAD_SIZE;
|
|
1247
|
+
const payloadByte = eventsDataView.getUint8(offset + EVENT_PAYLOAD_ALIGN);
|
|
1248
|
+
const payloadVec2 = {
|
|
1249
|
+
x: eventsDataView.getFloat32(offset + EVENT_PAYLOAD_ALIGN, true),
|
|
1250
|
+
y: eventsDataView.getFloat32(offset + EVENT_PAYLOAD_ALIGN + Float32Array.BYTES_PER_ELEMENT, true)
|
|
1251
|
+
};
|
|
1252
|
+
switch (eventType) {
|
|
1253
|
+
case exports_enums.EventType.KeyDown: {
|
|
1254
|
+
system.keydown?.(attachEvent(this.#context, {
|
|
1255
|
+
key: keyCodeToKey(payloadByte)
|
|
1256
|
+
}));
|
|
1257
|
+
break;
|
|
1258
|
+
}
|
|
1259
|
+
case exports_enums.EventType.KeyUp:
|
|
1260
|
+
system.keyup?.(attachEvent(this.#context, {
|
|
1261
|
+
key: keyCodeToKey(payloadByte)
|
|
1262
|
+
}));
|
|
1263
|
+
break;
|
|
1264
|
+
case exports_enums.EventType.MouseDown:
|
|
1265
|
+
system.mousedown?.(attachEvent(this.#context, {
|
|
1266
|
+
button: mouseButtonCodeToMouseButton(payloadByte)
|
|
1267
|
+
}));
|
|
1268
|
+
break;
|
|
1269
|
+
case exports_enums.EventType.MouseUp:
|
|
1270
|
+
system.mouseup?.(attachEvent(this.#context, {
|
|
1271
|
+
button: mouseButtonCodeToMouseButton(payloadByte)
|
|
1272
|
+
}));
|
|
1273
|
+
break;
|
|
1274
|
+
case exports_enums.EventType.MouseMove:
|
|
1275
|
+
system.mousemove?.(attachEvent(this.#context, {
|
|
1276
|
+
x: payloadVec2.x,
|
|
1277
|
+
y: payloadVec2.y
|
|
1278
|
+
}));
|
|
1279
|
+
break;
|
|
1280
|
+
case exports_enums.EventType.MouseWheel:
|
|
1281
|
+
system.mousewheel?.(attachEvent(this.#context, {
|
|
1282
|
+
x: payloadVec2.x,
|
|
1283
|
+
y: payloadVec2.y
|
|
1284
|
+
}));
|
|
1285
|
+
break;
|
|
1286
|
+
default:
|
|
1287
|
+
throw new Error(`Unknown event type: ${eventType}`);
|
|
1244
1288
|
}
|
|
1245
|
-
|
|
1246
|
-
system.keyup?.(attachEvent(this.#context, {
|
|
1247
|
-
key: keyCodeToKey(payloadByte)
|
|
1248
|
-
}));
|
|
1249
|
-
break;
|
|
1250
|
-
case exports_enums.EventType.MouseDown:
|
|
1251
|
-
system.mousedown?.(attachEvent(this.#context, {
|
|
1252
|
-
button: mouseButtonCodeToMouseButton(payloadByte)
|
|
1253
|
-
}));
|
|
1254
|
-
break;
|
|
1255
|
-
case exports_enums.EventType.MouseUp:
|
|
1256
|
-
system.mouseup?.(attachEvent(this.#context, {
|
|
1257
|
-
button: mouseButtonCodeToMouseButton(payloadByte)
|
|
1258
|
-
}));
|
|
1259
|
-
break;
|
|
1260
|
-
case exports_enums.EventType.MouseMove:
|
|
1261
|
-
system.mousemove?.(attachEvent(this.#context, {
|
|
1262
|
-
x: payloadVec2.x,
|
|
1263
|
-
y: payloadVec2.y
|
|
1264
|
-
}));
|
|
1265
|
-
break;
|
|
1266
|
-
case exports_enums.EventType.MouseWheel:
|
|
1267
|
-
system.mousewheel?.(attachEvent(this.#context, {
|
|
1268
|
-
x: payloadVec2.x,
|
|
1269
|
-
y: payloadVec2.y
|
|
1270
|
-
}));
|
|
1271
|
-
break;
|
|
1272
|
-
default:
|
|
1273
|
-
throw new Error(`Unknown event type: ${eventType}`);
|
|
1289
|
+
offset += EVENT_PAYLOAD_ALIGN + EVENT_PAYLOAD_SIZE;
|
|
1274
1290
|
}
|
|
1275
|
-
|
|
1291
|
+
this.#context.event = undefined;
|
|
1276
1292
|
}
|
|
1277
|
-
this.#context.event = undefined;
|
|
1278
1293
|
}
|
|
1279
|
-
}
|
|
1280
|
-
setBuffer(buffer) {
|
|
1281
|
-
this.#engineBuffer = buffer;
|
|
1282
|
-
}
|
|
1294
|
+
};
|
|
1283
1295
|
}
|
|
1284
1296
|
function attachEvent(context, event) {
|
|
1285
1297
|
context.event = event;
|
|
@@ -1288,9 +1300,8 @@ function attachEvent(context, event) {
|
|
|
1288
1300
|
export {
|
|
1289
1301
|
mount,
|
|
1290
1302
|
exports_util as Util,
|
|
1291
|
-
Runtime,
|
|
1292
1303
|
Bloop
|
|
1293
1304
|
};
|
|
1294
1305
|
|
|
1295
|
-
//# debugId=
|
|
1306
|
+
//# debugId=67817A1D7307671264756E2164756E21
|
|
1296
1307
|
//# sourceMappingURL=mod.js.map
|