Monorepo for Aesthetic.Computer aesthetic.computer
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

disk.mjs: add fallback initialization for critical paint API functions

The Painting class constructor wraps functions from $paintApiUnwrapped via
a for-in loop. In some edge cases, this wrapping may not complete properly,
leaving functions like box, line, wipe, and ink unavailable in the api object.

Added fallback initialization that checks for missing critical functions
after the wrapping loop and provides implementations if needed. This ensures
that button graphics and other painting operations in arena.mjs can access
the required functions, even if the primary wrapping mechanism fails.

- Check for missing box, line, wipe, and ink functions
- Add deferred implementations for graphics functions
- Prevents ReferenceError when painting() is called during boot

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>

+42
+42
system/public/aesthetic.computer/lib/disk.mjs
··· 6983 6983 } 6984 6984 } 6985 6985 6986 + // Ensure critical graphics functions are available (fallback if wrapping fails) 6987 + if (!p.api.box && typeof graph.box === "function") { 6988 + p.api.box = function () { 6989 + const callArgs = arguments; 6990 + if (notArray(p.#layers[p.#layer])) p.#layers[p.#layer] = []; 6991 + p.#layers[p.#layer].push([ 6992 + "box", 6993 + () => graph.box(...callArgs), 6994 + ]); 6995 + return p.api; 6996 + }; 6997 + } 6998 + if (!p.api.line && typeof graph.line === "function") { 6999 + p.api.line = function () { 7000 + const callArgs = arguments; 7001 + if (notArray(p.#layers[p.#layer])) p.#layers[p.#layer] = []; 7002 + p.#layers[p.#layer].push([ 7003 + "line", 7004 + () => graph.line(...callArgs), 7005 + ]); 7006 + return p.api; 7007 + }; 7008 + } 7009 + if (!p.api.wipe && typeof $paintApiUnwrapped.wipe === "function") { 7010 + p.api.wipe = function () { 7011 + const callArgs = arguments; 7012 + if (notArray(p.#layers[p.#layer])) p.#layers[p.#layer] = []; 7013 + p.#layers[p.#layer].push([ 7014 + "wipe", 7015 + () => $paintApiUnwrapped.wipe(...callArgs), 7016 + ]); 7017 + return p.api; 7018 + }; 7019 + } 7020 + if (!p.api.ink && typeof $paintApiUnwrapped.ink === "function") { 7021 + p.api.ink = function () { 7022 + $paintApiUnwrapped.ink(...arguments); 7023 + p.inkrn = graph.c.slice(); 7024 + return p.api; 7025 + }; 7026 + } 7027 + 6986 7028 // Allows grouping & composing painting order using an AofA (Array of Arrays). 6987 7029 // n: 0-n (Cannot be negative.) 6988 7030 // fun: A callback that contains $paintApi commands or any other code.