memory leak problems with tetris poop

This commit is contained in:
2025-10-26 19:51:57 -07:00
parent 4bd279798c
commit 882a416831
19 changed files with 397 additions and 80 deletions
+1 -1
View File
@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>Chat with Websockets</title>
<link rel="stylesheet" href="./default.css">
<link rel="stylesheet" href="/css/default.css">
</head>
<body>
<div class="content">
+16 -3
View File
@@ -3,15 +3,28 @@
<head>
<meta charset="utf-8">
<title>WF Compiler Demo</title>
<link rel="stylesheet" href="./default.css">
<link rel="stylesheet" href="/css/default.css">
</head>
<body>
<div class="content">
<h1 class="content-title">WFC Demo</h1>
<ul>
<li><a href="/chat.html">Websocket Chatroom</a></li>
<li><a href="/ws-test-echo.html">Websocket Echo Test</a></li>
<li>
Websocket demos that work
<ul>
<li><a href="/ws-test-echo.html">Echo</a></li>
</ul>
</li>
<li>
Don't work
<ul>
<li><a href="/chat.html">Chatroom</a></li>
<li><a href="/tetris.html">Tetris</a></li>
</ul>
</li>
</ul>
<div class="content-body">
+3 -1
View File
@@ -3,4 +3,6 @@
*
* @module
*/
export {};
export { auto_resize, auto_scroll_to_bottom };
declare function auto_resize(checkbox_element: HTMLInputElement, target_element: HTMLTextAreaElement, max_height: number): void;
declare function auto_scroll_to_bottom(checkbox_element: HTMLInputElement, target_element: HTMLTextAreaElement): void;
+18 -1
View File
@@ -3,5 +3,22 @@
*
* @module
*/
export {};
export { auto_resize, auto_scroll_to_bottom };
function auto_resize(checkbox_element, target_element, max_height) {
// if the user has manually resized their output, we do nothing
if (checkbox_element.checked) {
let target_height = target_element.scrollHeight;
// resize it automagically up to 500px
if (target_height < max_height)
target_element.style.height = String(target_height) + 'px';
else
target_element.style.height = String(max_height) + 'px';
}
}
function auto_scroll_to_bottom(checkbox_element, target_element) {
if (checkbox_element.checked) {
// scroll to bottom
target_element.scrollTop = target_element.scrollHeight;
}
}
//# sourceMappingURL=libfewd.js.map
+1 -1
View File
@@ -1 +1 @@
{"version":3,"file":"libfewd.js","sourceRoot":"","sources":["../ts/libfewd.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
{"version":3,"file":"libfewd.js","sourceRoot":"","sources":["../ts/libfewd.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACH,WAAW,EACX,qBAAqB,EACxB,CAAC;AAGF,SACA,WAAW,CACN,gBAAmC,EACnC,cAAsC,EACtC,UAAyB;IAG1B,+DAA+D;IAC/D,IAAI,gBAAgB,CAAC,OAAO,EAAE,CAAC;QAC3B,IAAI,aAAa,GAAW,cAAc,CAAC,YAAY,CAAC;QACxD,sCAAsC;QACtC,IAAI,aAAa,GAAG,UAAU;YAC1B,cAAc,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;;YAE3D,cAAc,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IAChE,CAAC;AACL,CAAC;AAGD,SACA,qBAAqB,CAChB,gBAAmC,EACnC,cAAsC;IAGvC,IAAI,gBAAgB,CAAC,OAAO,EAAE,CAAC;QAC3B,mBAAmB;QACnB,cAAc,CAAC,SAAS,GAAG,cAAc,CAAC,YAAY,CAAC;IAC3D,CAAC;AACL,CAAC"}
+6
View File
@@ -0,0 +1,6 @@
/**
* Tetris
*
* @module
*/
export {};
+30
View File
@@ -0,0 +1,30 @@
/**
* Tetris
*
* @module
*/
main();
async function main() {
let ws = new WebSocket("/ws/tetris");
let elt_tetris_state = document.getElementById('tetris-state');
ws.onmessage =
(e) => {
handle_evt(e, elt_tetris_state);
};
}
//-----------------------------------------------------
// Tetris
//-----------------------------------------------------
/**
* take the entire tetris state, render the html elements
*
* then fish out the element in the document, and replace it
*
* blitting basically
*/
async function handle_evt(e, oelt) {
let state_str = e.data;
oelt.value = state_str;
}
export {};
//# sourceMappingURL=tetris.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"tetris.js","sourceRoot":"","sources":["../ts/tetris.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAQH,IAAI,EAAE,CAAC;AAEP,KAAK,UACL,IAAI;IAIA,IAAI,EAAE,GAAuC,IAAI,SAAS,CAAC,YAAY,CAAC,CAAqC;IAC7G,IAAI,gBAAgB,GAAyB,QAAQ,CAAC,cAAc,CAAC,cAAc,CAAwB,CAAE;IAE7G,EAAE,CAAC,SAAS;QACR,CAAC,CAAe,EAAE,EAAE;YAChB,UAAU,CAAC,CAAC,EAAE,gBAAgB,CAAC,CAAC;QACpC,CAAC,CAAA;AACT,CAAC;AAED,uDAAuD;AACvD,SAAS;AACT,uDAAuD;AAGvD;;;;;;GAMG;AACH,KAAK,UACL,UAAU,CACL,CAAmB,EACnB,IAA0B;IAG3B,IAAI,SAAS,GAAY,CAAC,CAAC,IAAc,CAAC;IAC1C,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;AAC3B,CAAC"}
+33
View File
@@ -5,6 +5,39 @@
*/
export {
auto_resize,
auto_scroll_to_bottom
};
function
auto_resize
(checkbox_element : HTMLInputElement,
target_element : HTMLTextAreaElement,
max_height : number)
: void
{
// if the user has manually resized their output, we do nothing
if (checkbox_element.checked) {
let target_height: number = target_element.scrollHeight;
// resize it automagically up to 500px
if (target_height < max_height)
target_element.style.height = String(target_height) + 'px';
else
target_element.style.height = String(max_height) + 'px';
}
}
function
auto_scroll_to_bottom
(checkbox_element : HTMLInputElement,
target_element : HTMLTextAreaElement)
: void
{
if (checkbox_element.checked) {
// scroll to bottom
target_element.scrollTop = target_element.scrollHeight;
}
}
+49
View File
@@ -0,0 +1,49 @@
/**
* Tetris
*
* @module
*/
export {
};
import * as libfewd from './libfewd.js';
main();
async function
main
()
: Promise<void>
{
let ws : WebSocket = new WebSocket("/ws/tetris") ;
let elt_tetris_state : HTMLTextAreaElement = document.getElementById('tetris-state') as HTMLTextAreaElement ;
ws.onmessage =
(e: MessageEvent) => {
handle_evt(e, elt_tetris_state);
}
}
//-----------------------------------------------------
// Tetris
//-----------------------------------------------------
/**
* take the entire tetris state, render the html elements
*
* then fish out the element in the document, and replace it
*
* blitting basically
*/
async function
handle_evt
(e : MessageEvent,
oelt : HTMLTextAreaElement)
: Promise<void>
{
let state_str : string = e.data as string;
oelt.value = state_str;
}
+18
View File
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Tetris with Websockets</title>
<link rel="stylesheet" href="/css/default.css">
<link rel="stylesheet" href="/css/tetris.css">
</head>
<body>
<div class="content">
<h1 class="content-title">Tetris</h1>
<textarea id="tetris-state"></textarea>
</div>
<script type="module" src="./js/dist/tetris.js"></script>
</body>
</html>
+1 -1
View File
@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>Websockets echo test</title>
<link rel="stylesheet" href="./default.css">
<link rel="stylesheet" href="/css/default.css">
</head>
<body>
<div class="content">