@bloopjs/web 0.0.97 → 0.0.99
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/App.d.ts.map +1 -1
- package/dist/debugui/DebugUi.d.ts.map +1 -1
- package/dist/mod.js +20 -8
- package/dist/mod.js.map +6 -6
- package/package.json +3 -3
- package/src/App.ts +17 -4
- package/src/debugui/DebugUi.ts +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bloopjs/web",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.99",
|
|
4
4
|
"author": "Neil Sarkar",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
"typescript": "^5"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@bloopjs/bloop": "0.0.
|
|
37
|
-
"@bloopjs/engine": "0.0.
|
|
36
|
+
"@bloopjs/bloop": "0.0.99",
|
|
37
|
+
"@bloopjs/engine": "0.0.99",
|
|
38
38
|
"@preact/signals": "^1.3.1",
|
|
39
39
|
"partysocket": "^1.1.6",
|
|
40
40
|
"preact": "^10.25.4"
|
package/src/App.ts
CHANGED
|
@@ -221,6 +221,15 @@ export class App {
|
|
|
221
221
|
window.addEventListener("resize", emitResize);
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
+
// Convert viewport coordinates to canvas-relative coordinates
|
|
225
|
+
const toCanvasCoords = (clientX: number, clientY: number) => {
|
|
226
|
+
if (canvas) {
|
|
227
|
+
const rect = canvas.getBoundingClientRect();
|
|
228
|
+
return { x: clientX - rect.left, y: clientY - rect.top };
|
|
229
|
+
}
|
|
230
|
+
return { x: clientX, y: clientY };
|
|
231
|
+
};
|
|
232
|
+
|
|
224
233
|
// Detect devicePixelRatio changes (monitor switch, browser zoom)
|
|
225
234
|
const updatePixelRatioListener = () => {
|
|
226
235
|
const mediaQuery = window.matchMedia(
|
|
@@ -249,8 +258,10 @@ export class App {
|
|
|
249
258
|
window.addEventListener("keyup", handleKeyup);
|
|
250
259
|
|
|
251
260
|
const handleMousemove = (event: MouseEvent) => {
|
|
252
|
-
if (shouldEmitInputs())
|
|
253
|
-
|
|
261
|
+
if (shouldEmitInputs()) {
|
|
262
|
+
const { x, y } = toCanvasCoords(event.clientX, event.clientY);
|
|
263
|
+
this.sim.emit.mousemove(x, y);
|
|
264
|
+
}
|
|
254
265
|
};
|
|
255
266
|
window.addEventListener("mousemove", handleMousemove);
|
|
256
267
|
|
|
@@ -277,7 +288,8 @@ export class App {
|
|
|
277
288
|
if (!shouldEmitInputs()) return;
|
|
278
289
|
const touch = event.touches[0];
|
|
279
290
|
if (touch) {
|
|
280
|
-
|
|
291
|
+
const { x, y } = toCanvasCoords(touch.clientX, touch.clientY);
|
|
292
|
+
this.sim.emit.mousemove(x, y);
|
|
281
293
|
this.sim.emit.mousedown("Left");
|
|
282
294
|
}
|
|
283
295
|
};
|
|
@@ -292,7 +304,8 @@ export class App {
|
|
|
292
304
|
if (!shouldEmitInputs()) return;
|
|
293
305
|
const touch = event.touches[0];
|
|
294
306
|
if (touch) {
|
|
295
|
-
|
|
307
|
+
const { x, y } = toCanvasCoords(touch.clientX, touch.clientY);
|
|
308
|
+
this.sim.emit.mousemove(x, y);
|
|
296
309
|
}
|
|
297
310
|
};
|
|
298
311
|
window.addEventListener("touchmove", handleTouchmove);
|
package/src/debugui/DebugUi.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type ComponentChild, render } from "preact";
|
|
1
|
+
import { type ComponentChild, h, render } from "preact";
|
|
2
2
|
import { Root } from "./components/Root.tsx";
|
|
3
|
-
import { type DebugState,
|
|
3
|
+
import { cycleLayout, type DebugState, debugState } from "./state.ts";
|
|
4
4
|
import { styles } from "./styles.ts";
|
|
5
5
|
|
|
6
6
|
export type DebugUiOptions = {
|
|
@@ -69,7 +69,7 @@ export class DebugUi {
|
|
|
69
69
|
|
|
70
70
|
#render(): void {
|
|
71
71
|
render(
|
|
72
|
-
Root({ canvas: this.#canvas, hotkey: this.#hotkey })
|
|
72
|
+
Root({ canvas: this.#canvas, hotkey: this.#hotkey }),
|
|
73
73
|
this.#mountPoint,
|
|
74
74
|
);
|
|
75
75
|
}
|