@bloopjs/web 0.0.107 → 0.0.109
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/debugui/DebugUi.d.ts.map +1 -1
- package/dist/debugui/components/Root.d.ts +2 -1
- package/dist/debugui/components/Root.d.ts.map +1 -1
- package/dist/mod.js +27 -13
- package/dist/mod.js.map +6 -6
- package/package.json +3 -3
- package/src/debugui/DebugUi.ts +1 -4
- package/src/debugui/components/Root.tsx +19 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bloopjs/web",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.109",
|
|
4
4
|
"author": "Neil Sarkar",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"typescript": "^5"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@bloopjs/bloop": "0.0.
|
|
41
|
-
"@bloopjs/engine": "0.0.
|
|
40
|
+
"@bloopjs/bloop": "0.0.109",
|
|
41
|
+
"@bloopjs/engine": "0.0.109",
|
|
42
42
|
"@preact/signals": "^1.3.1",
|
|
43
43
|
"partysocket": "^1.1.6",
|
|
44
44
|
"preact": "^10.25.4"
|
package/src/debugui/DebugUi.ts
CHANGED
|
@@ -54,9 +54,6 @@ export class DebugUi {
|
|
|
54
54
|
// Use provided canvas or create new one
|
|
55
55
|
this.#canvas = options.canvas ?? document.createElement("canvas");
|
|
56
56
|
|
|
57
|
-
// Append canvas to host element (light DOM) for slot projection
|
|
58
|
-
this.#host.appendChild(this.#canvas);
|
|
59
|
-
|
|
60
57
|
// Render Preact app
|
|
61
58
|
this.#render();
|
|
62
59
|
|
|
@@ -73,7 +70,7 @@ export class DebugUi {
|
|
|
73
70
|
}
|
|
74
71
|
|
|
75
72
|
#render(): void {
|
|
76
|
-
render(Root({ hotkey: this.#hotkey }), this.#mountPoint);
|
|
73
|
+
render(Root({ canvas: this.#canvas, hotkey: this.#hotkey }), this.#mountPoint);
|
|
77
74
|
}
|
|
78
75
|
|
|
79
76
|
#setupHotkey(): () => void {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useRef, useEffect } from "preact/hooks";
|
|
1
2
|
import { debugState } from "../state.ts";
|
|
2
3
|
import { Stats } from "./Stats.tsx";
|
|
3
4
|
import { Logs } from "./Logs.tsx";
|
|
@@ -7,17 +8,18 @@ import { VerticalBar } from "./VerticalBar.tsx";
|
|
|
7
8
|
import { BottomBar } from "./BottomBar.tsx";
|
|
8
9
|
|
|
9
10
|
type RootProps = {
|
|
11
|
+
canvas: HTMLCanvasElement;
|
|
10
12
|
hotkey?: string;
|
|
11
13
|
};
|
|
12
14
|
|
|
13
|
-
export function Root({ hotkey = "Escape" }: RootProps) {
|
|
15
|
+
export function Root({ canvas, hotkey = "Escape" }: RootProps) {
|
|
14
16
|
const layoutMode = debugState.layoutMode.value;
|
|
15
17
|
|
|
16
18
|
if (layoutMode === "off") {
|
|
17
19
|
return (
|
|
18
20
|
<>
|
|
19
21
|
<main className="fullscreen">
|
|
20
|
-
<
|
|
22
|
+
<GameCanvas canvas={canvas} />
|
|
21
23
|
</main>
|
|
22
24
|
<DebugToggle hotkey={hotkey} />
|
|
23
25
|
</>
|
|
@@ -27,7 +29,7 @@ export function Root({ hotkey = "Escape" }: RootProps) {
|
|
|
27
29
|
if (layoutMode === "letterboxed") {
|
|
28
30
|
return (
|
|
29
31
|
<>
|
|
30
|
-
<LetterboxedLayout />
|
|
32
|
+
<LetterboxedLayout canvas={canvas} />
|
|
31
33
|
<DebugToggle hotkey={hotkey} />
|
|
32
34
|
</>
|
|
33
35
|
);
|
|
@@ -38,7 +40,7 @@ export function Root({ hotkey = "Escape" }: RootProps) {
|
|
|
38
40
|
<>
|
|
39
41
|
<main className="layout">
|
|
40
42
|
<section className="game">
|
|
41
|
-
<
|
|
43
|
+
<GameCanvas canvas={canvas} />
|
|
42
44
|
</section>
|
|
43
45
|
<section className="stats">
|
|
44
46
|
<Stats />
|
|
@@ -52,7 +54,7 @@ export function Root({ hotkey = "Escape" }: RootProps) {
|
|
|
52
54
|
);
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
function LetterboxedLayout() {
|
|
57
|
+
function LetterboxedLayout({ canvas }: { canvas: HTMLCanvasElement }) {
|
|
56
58
|
const isOnline = debugState.netStatus.value.peers.length > 0;
|
|
57
59
|
const advantage = debugState.advantage.value ?? 0;
|
|
58
60
|
const frameTime = debugState.frameTime.value;
|
|
@@ -98,7 +100,7 @@ function LetterboxedLayout() {
|
|
|
98
100
|
displayValue={leftDisplayValue}
|
|
99
101
|
/>
|
|
100
102
|
<div className={gameClassName}>
|
|
101
|
-
<
|
|
103
|
+
<GameCanvas canvas={canvas} />
|
|
102
104
|
</div>
|
|
103
105
|
<VerticalBar
|
|
104
106
|
value={rightValue}
|
|
@@ -111,10 +113,15 @@ function LetterboxedLayout() {
|
|
|
111
113
|
);
|
|
112
114
|
}
|
|
113
115
|
|
|
114
|
-
function
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
function GameCanvas({ canvas }: { canvas: HTMLCanvasElement }) {
|
|
117
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
118
|
+
|
|
119
|
+
useEffect(() => {
|
|
120
|
+
const container = containerRef.current;
|
|
121
|
+
if (container && !container.contains(canvas)) {
|
|
122
|
+
container.appendChild(canvas);
|
|
123
|
+
}
|
|
124
|
+
}, [canvas]);
|
|
125
|
+
|
|
126
|
+
return <div className="canvas-container" ref={containerRef} />;
|
|
120
127
|
}
|