| index 59f1c9d..b289bd7 100644 | ||
| --- a/Makefile | ||
| +++ b/Makefile | ||
| @@ -1,4 +1,4 @@ | ||
| 1 | -# plugin_tetris_3d - ScorpioX Bot open-source 3D block game | |
| 1 | +# plugin_tetris_3d - SCORPIOX BOT open-source 3D block game | |
| 2 | 2 | # |
| 3 | 3 | # Targets: |
| 4 | 4 | # make native build -> ./plugin_tetris_3d |
| index d738f4b..4f7b9dc 100644 | ||
| --- a/README.md | ||
| +++ b/README.md | ||
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | # plugin_tetris_3d |
| 2 | 2 | |
| 3 | -A 3D block-stacking puzzle game for a ScorpioX Bot node — a single clean-room C99 | |
| 3 | +A 3D block-stacking puzzle game for a SCORPIOX BOT node — a single clean-room C99 | |
| 4 | 4 | binary, MIT licensed, with no dependency beyond libc. |
| 5 | 5 | |
| 6 | 6 | It serves a complete game UI: isometric cubes with real depth and shading, |
| index 5742df5..9b8a0d3 100644 | ||
| --- a/plugin.json | ||
| +++ b/plugin.json | ||
| @@ -2,7 +2,7 @@ | ||
| 2 | 2 | "slug": "tetris-3d", |
| 3 | 3 | "id": "plugin_tetris_3d", |
| 4 | 4 | "title": "3D Block Puzzle Game", |
| 5 | - "summary": "Zero-dependency isometric 3D block-stacking puzzle that runs in the ScorpioX Bot Chat floating window or a standalone browser tab. Software-projected cubes on a canvas with ghost piece, next-piece preview, hold queue, keyboard and touch controls, dark and light themes, and local high-score persistence through the node plugin API. No WebGL, no CDN, no network requests.", | |
| 5 | + "summary": "Zero-dependency isometric 3D block-stacking puzzle that runs in the SCORPIOX BOT Chat floating window or a standalone browser tab. Software-projected cubes on a canvas with ghost piece, next-piece preview, hold queue, keyboard and touch controls, dark and light themes, and local high-score persistence through the node plugin API. No WebGL, no CDN, no network requests.", | |
| 6 | 6 | "category": "utilities", |
| 7 | 7 | "license": "MIT", |
| 8 | 8 | "capabilities": ["local_filesystem_write"], |
| index 5db98bb..4412b5d 100755 | ||
| --- a/release-dist.sh | ||
| +++ b/release-dist.sh | ||
| @@ -31,7 +31,7 @@ set -euo pipefail | ||
| 31 | 31 | |
| 32 | 32 | SLUG="tetris-3d" |
| 33 | 33 | ID="plugin_tetris_3d" |
| 34 | -VERSION="1.0.0" | |
| 34 | +VERSION="1.0.1" | |
| 35 | 35 | DIST_BASE_URL="https://dist.scorpiox.net/bot-plugins" |
| 36 | 36 | |
| 37 | 37 | ROOT="$(cd "$(dirname "$0")" && pwd)" |
| @@ -224,7 +224,7 @@ target_meta() { # target_meta <key> <file> <format> <relpath> | ||
| 224 | 224 | printf ' "name": "tetris",\n' |
| 225 | 225 | printf ' "desc": "3D block game",\n' |
| 226 | 226 | printf ' "title": "3D Block Puzzle Game",\n' |
| 227 | - printf ' "summary": "Zero-dependency isometric 3D block-stacking puzzle that runs in the ScorpioX Bot Chat floating window or a standalone browser tab. Software-projected cubes on a canvas with ghost piece, next-piece preview, hold queue, keyboard and touch controls, dark and light themes, and local high-score persistence through the node plugin API. No WebGL, no CDN, no network requests.",\n' | |
| 227 | + printf ' "summary": "Zero-dependency isometric 3D block-stacking puzzle that runs in the SCORPIOX BOT Chat floating window or a standalone browser tab. Software-projected cubes on a canvas with ghost piece, next-piece preview, hold queue, keyboard and touch controls, dark and light themes, and local high-score persistence through the node plugin API. No WebGL, no CDN, no network requests.",\n' | |
| 228 | 228 | printf ' "category": "utilities",\n' |
| 229 | 229 | printf ' "version": "%s",\n' "$VERSION" |
| 230 | 230 | printf ' "license": "MIT",\n' |
| index 00a217d..b6ae3c7 100644 | ||
| --- a/src/plugin_tetris_3d.c | ||
| +++ b/src/plugin_tetris_3d.c | ||
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | - * plugin_tetris_3d - ScorpioX Bot open-source 3D block game (clean room) | |
| 2 | + * plugin_tetris_3d - SCORPIOX BOT open-source 3D block game (clean room) | |
| 3 | 3 | * |
| 4 | 4 | * A single dependency-free C99 binary that serves THREE modes: |
| 5 | 5 | * 1. --meta / SX_PLUGIN_META=1 -> JSON discovery metadata |
| @@ -59,7 +59,7 @@ | ||
| 59 | 59 | #define PLUGIN_ID "plugin_tetris_3d" |
| 60 | 60 | #define PLUGIN_NAME "tetris" |
| 61 | 61 | #define PLUGIN_DESC "3D block game" |
| 62 | -#define PLUGIN_VER "1.0.0" | |
| 62 | +#define PLUGIN_VER "1.0.1" | |
| 63 | 63 | |
| 64 | 64 | #define MAX_SCORES 10 |
| 65 | 65 | #define PATH_SZ 1024 |
| index 0646853..6e377e1 100644 | ||
| --- a/src/ui_html.h | ||
| +++ b/src/ui_html.h | ||
| @@ -7,11 +7,27 @@ static const char *UI_HTML = | ||
| 7 | 7 | "<html lang=\"en\"><head><meta charset=\"utf-8\">\n" |
| 8 | 8 | "<meta name=\"viewport\" content=\"width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no\">\n" |
| 9 | 9 | "<title>tetris</title>\n" |
| 10 | + "<script>(function(){var t='';" | |
| 11 | + "try{var m=/[?&]theme=(light|dark)/.exec(location.search);if(m)t=m[1];}catch(e){}" | |
| 12 | + "if(!t){try{var s=localStorage.getItem('bot_theme');if(s==='light'||s==='dark')t=s;}catch(e){}}" | |
| 13 | + "if(!t){try{t=(window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches)?'light':'dark';}catch(e){t='dark';}}" | |
| 14 | + "document.documentElement.setAttribute('data-theme',t);" | |
| 15 | + "try{if(/[?&]embed=(1|true)(&|$)/.test(location.search))document.documentElement.classList.add('embedded');}catch(e){}" | |
| 16 | + "try{localStorage.setItem('bot_theme',t);}catch(e){}" | |
| 17 | + "})();</script>\n" | |
| 10 | 18 | "<style>\n" |
| 11 | - ":root{color-scheme:dark light;--bg:#08080b;--panel:rgba(22,22,28,.72);--panel-solid:#16161c;--text:#f4f4f7;--muted:#9b9ba6;--line:rgba(255,255,255,.11);--accent:#0a84ff;--good:#30d158;--warn:#ff9f0a;--radius:14px}\n" | |
| 12 | - "@media(prefers-color-scheme:light){:root{--bg:#eceef3;--panel:rgba(255,255,255,.78);--panel-solid:#fff;--text:#14141a;--muted:#5f5f6b;--line:rgba(0,0,0,.1)}}\n" | |
| 13 | - "html[data-theme=\"dark\"]{--bg:#08080b;--panel:rgba(22,22,28,.72);--panel-solid:#16161c;--text:#f4f4f7;--muted:#9b9ba6;--line:rgba(255,255,255,.11)}\n" | |
| 14 | - "html[data-theme=\"light\"]{--bg:#eceef3;--panel:rgba(255,255,255,.78);--panel-solid:#fff;--text:#14141a;--muted:#5f5f6b;--line:rgba(0,0,0,.1)}\n" | |
| 19 | + ":root{color-scheme:dark;--bg:#000000;--bg-2:#08080a;--bg-card:#1c1c1e;" | |
| 20 | + "--surface-2:rgba(255,255,255,.06);--line:rgba(255,255,255,.08);--text:#f5f5f7;--text-2:#86868b;" | |
| 21 | + "--blue:#0a84ff;--green:#30d158;--orange:#ff9f0a;--red:#ff453a;--purple:#bf5af2;--teal:#64d2ff;--yellow:#ffd60a;" | |
| 22 | + "--radius:14px;--panel:var(--bg-card);--panel-solid:var(--bg-card);--muted:var(--text-2);--accent:var(--blue);--good:var(--green);--warn:var(--orange)}" | |
| 23 | + "@media (prefers-color-scheme:light){html:not([data-theme=dark]){--bg:#f5f5f7;--bg-2:#ffffff;--bg-card:#ffffff;" | |
| 24 | + "--surface-2:rgba(0,0,0,.04);--line:rgba(0,0,0,.06);--text:#1d1d1f;--text-2:#6e6e73;" | |
| 25 | + "--blue:#007aff;--green:#34c759;--orange:#ff9500;--red:#ff3b30;--purple:#af52de;--teal:#32ade6;--yellow:#b8860b;color-scheme:light}}" | |
| 26 | + "html[data-theme=light]{--bg:#f5f5f7;--bg-2:#ffffff;--bg-card:#ffffff;" | |
| 27 | + "--surface-2:rgba(0,0,0,.04);--line:rgba(0,0,0,.06);--text:#1d1d1f;--text-2:#6e6e73;" | |
| 28 | + "--blue:#007aff;--green:#34c759;--orange:#ff9500;--red:#ff3b30;--purple:#af52de;--teal:#32ade6;--yellow:#b8860b;color-scheme:light}" | |
| 29 | + "html{color-scheme:dark}html[data-theme=dark]{color-scheme:dark}" | |
| 30 | + "html.embedded #btnTheme{display:none!important}" | |
| 15 | 31 | "*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}\n" |
| 16 | 32 | "html,body{margin:0;padding:0;height:100%;overflow:hidden;background:var(--bg);color:var(--text);font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Inter,system-ui,sans-serif}\n" |
| 17 | 33 | "#app{position:relative;width:100%;height:100%;display:flex;flex-direction:column}\n" |
| @@ -133,25 +149,28 @@ static const char *UI_HTML = | ||
| 133 | 149 | " document.getElementById('btnTheme').textContent =\n" |
| 134 | 150 | " (document.documentElement.getAttribute('data-theme') === 'light') ? 'Dark' : 'Light';\n" |
| 135 | 151 | "}\n" |
| 136 | - "applyTheme(localStorage.getItem(THEME_KEY) || q.get('theme') || '');\n" | |
| 152 | + "/* the bot posts sx-theme into the iframe; follow it, and ask once at start */\n" | |
| 153 | + "window.addEventListener('message', function(e){var d=e&&e.data;" | |
| 154 | + "if(d&&d.type==='sx-theme') applyTheme(d.theme);});\n" | |
| 155 | + "try{if(window.parent&&window.parent!==window)window.parent.postMessage({type:'sx-theme-request'},'*');}catch(e){}\n" | |
| 137 | 156 | "document.getElementById('btnTheme').addEventListener('click', function(){\n" |
| 138 | 157 | " var cur = document.documentElement.getAttribute('data-theme');\n" |
| 139 | 158 | " if (!cur) cur = window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark';\n" |
| 140 | 159 | " var next = cur === 'light' ? 'dark' : 'light';\n" |
| 141 | - " localStorage.setItem(THEME_KEY, next);\n" | |
| 160 | + " localStorage.setItem(THEME_KEY, next);try{localStorage.setItem('bot_theme',next);}catch(e){}\n" | |
| 142 | 161 | " applyTheme(next);\n" |
| 143 | 162 | "});\n" |
| 144 | 163 | "\n" |
| 145 | 164 | "/* ---------------------------------------------------------------- board */\n" |
| 146 | 165 | "var COLS = 10, ROWS = 20, DEPTH = 3;\n" |
| 147 | 166 | "var SHAPES = [\n" |
| 148 | - " { k:'I', c:'#22d3ee', b:[[1,1,1,1]] },\n" | |
| 149 | - " { k:'J', c:'#3b82f6', b:[[1,0,0],[1,1,1]] },\n" | |
| 150 | - " { k:'L', c:'#f59e0b', b:[[0,0,1],[1,1,1]] },\n" | |
| 151 | - " { k:'O', c:'#facc15', b:[[1,1],[1,1]] },\n" | |
| 152 | - " { k:'S', c:'#22c55e', b:[[0,1,1],[1,1,0]] },\n" | |
| 153 | - " { k:'T', c:'#a855f7', b:[[0,1,0],[1,1,1]] },\n" | |
| 154 | - " { k:'Z', c:'#ef4444', b:[[1,1,0],[0,1,1]] }\n" | |
| 167 | + " { k:'I', c:'#64d2ff', b:[[1,1,1,1]] },\n" | |
| 168 | + " { k:'J', c:'#0a84ff', b:[[1,0,0],[1,1,1]] },\n" | |
| 169 | + " { k:'L', c:'#ff9f0a', b:[[0,0,1],[1,1,1]] },\n" | |
| 170 | + " { k:'O', c:'#ffd60a', b:[[1,1],[1,1]] },\n" | |
| 171 | + " { k:'S', c:'#30d158', b:[[0,1,1],[1,1,0]] },\n" | |
| 172 | + " { k:'T', c:'#bf5af2', b:[[0,1,0],[1,1,1]] },\n" | |
| 173 | + " { k:'Z', c:'#ff453a', b:[[1,1,0],[0,1,1]] }\n" | |
| 155 | 174 | "];\n" |
| 156 | 175 | "\n" |
| 157 | 176 | "var grid = []; /* grid[y][x] = color string or 0 */\n" |
| index 5f110f4..2a4bae1 100755 | ||
| --- a/tests/run.sh | ||
| +++ b/tests/run.sh | ||
| @@ -63,7 +63,7 @@ check "meta desc length <= 13" "$(python3 -c 'print(len("3D block game"))')" "13 | ||
| 63 | 63 | M2=$(SX_PLUGIN_META=1 "$BIN") |
| 64 | 64 | check "SX_PLUGIN_META equals --meta" "$M2" "$M" |
| 65 | 65 | check "meta has exactly two keys" "$(jget "$M" 'sorted(d.keys())')" "['desc', 'name']" |
| 66 | -check "--version" "$("$BIN" --version)" "plugin_tetris_3d 1.0.0" | |
| 66 | +check "--version" "$("$BIN" --version)" "plugin_tetris_3d 1.0.1" | |
| 67 | 67 | check "--meta needs no auth" "$(BOT_PASSWORD=secret "$BIN" --meta)" "$M" |
| 68 | 68 | |
| 69 | 69 | echo "== score API" |
| @@ -73,7 +73,7 @@ check "empty store ok" "$(jget "$J" 'd["ok"]')" "True" | ||
| 73 | 73 | check "empty store highscore" "$(jget "$J" 'd["highscore"]')" "0" |
| 74 | 74 | check "empty store list" "$(jget "$J" 'd["scores"]')" "[]" |
| 75 | 75 | check "plugin id" "$(jget "$J" 'd["plugin"]')" "plugin_tetris_3d" |
| 76 | -check "version" "$(jget "$J" 'd["version"]')" "1.0.0" | |
| 76 | +check "version" "$(jget "$J" 'd["version"]')" "1.0.1" | |
| 77 | 77 | |
| 78 | 78 | J=$(json 'action=save_score&val=1200') |
| 79 | 79 | check "save 1200 ok" "$(jget "$J" 'd["ok"]')" "True" |
| @@ -141,19 +141,19 @@ check "unwritable store error name" "$(jget "$(cat "$TMP/unw.json")" 'd["erro | ||
| 141 | 141 | |
| 142 | 142 | echo "== node auth" |
| 143 | 143 | hdr() { head -1 | tr -d '\r'; } |
| 144 | -A=$(QUERY_STRING='action=scores' BOT_PASSWORD=TESTPW "$BIN" | hdr) | |
| 144 | +A=$(QUERY_STRING='action=scores' BOT_PASSWORD=testpw "$BIN" | hdr) | |
| 145 | 145 | check "401 without credentials" "$A" "Status: 401 Unauthorized" |
| 146 | -A=$(QUERY_STRING='action=scores&pwd=TESTPW' BOT_PASSWORD=TESTPW "$BIN" | tail -1) | |
| 146 | +A=$(QUERY_STRING='action=scores&pwd=testpw' BOT_PASSWORD=testpw "$BIN" | tail -1) | |
| 147 | 147 | check "pwd query accepted" "$(jget "$A" 'd["ok"]')" "True" |
| 148 | -A=$(QUERY_STRING='action=scores' BOT_PASSWORD=TESTPW HTTP_X_BOT_PASSWORD=TESTPW "$BIN" | tail -1) | |
| 148 | +A=$(QUERY_STRING='action=scores' BOT_PASSWORD=testpw HTTP_X_BOT_PASSWORD=testpw "$BIN" | tail -1) | |
| 149 | 149 | check "X-Bot-Password accepted" "$(jget "$A" 'd["ok"]')" "True" |
| 150 | -A=$(QUERY_STRING='action=scores' BOT_PASSWORD=TESTPW HTTP_AUTHORIZATION='Bearer TESTPW' "$BIN" | tail -1) | |
| 150 | +A=$(QUERY_STRING='action=scores' BOT_PASSWORD=testpw HTTP_AUTHORIZATION='Bearer TESTPW' "$BIN" | tail -1) | |
| 151 | 151 | check "Bearer accepted" "$(jget "$A" 'd["ok"]')" "True" |
| 152 | -A=$(QUERY_STRING='action=scores' BOT_PASSWORD=TESTPW HTTP_AUTHORIZATION='Bearer wrong' "$BIN" | hdr) | |
| 152 | +A=$(QUERY_STRING='action=scores' BOT_PASSWORD=testpw HTTP_AUTHORIZATION='Bearer wrong' "$BIN" | hdr) | |
| 153 | 153 | check "wrong Bearer rejected" "$A" "Status: 401 Unauthorized" |
| 154 | -A=$(QUERY_STRING='' BOT_PASSWORD=TESTPW "$BIN" | hdr) | |
| 154 | +A=$(QUERY_STRING='' BOT_PASSWORD=testpw "$BIN" | hdr) | |
| 155 | 155 | check "html is gated too" "$A" "Status: 401 Unauthorized" |
| 156 | -A=$(QUERY_STRING='' BOT_PASSWORD=TESTPW HTTP_X_BOT_PASSWORD=TESTPW "$BIN" | hdr) | |
| 156 | +A=$(QUERY_STRING='' BOT_PASSWORD=testpw HTTP_X_BOT_PASSWORD=testpw "$BIN" | hdr) | |
| 157 | 157 | check "html served with password" "$A" "Content-Type: text/html; charset=utf-8" |
| 158 | 158 | |
| 159 | 159 | echo "== html" |
| @@ -173,6 +173,16 @@ has "theme toggle" "$TMP/html.txt" 'id="btnTheme"' | ||
| 173 | 173 | has "dark media query" "$TMP/html.txt" 'prefers-color-scheme' |
| 174 | 174 | has "explicit dark theme" "$TMP/html.txt" 'data-theme="dark"' |
| 175 | 175 | has "explicit light theme" "$TMP/html.txt" 'data-theme="light"' |
| 176 | +has "theme reads ?theme=" "$TMP/html.txt" 'theme=(light|dark)' | |
| 177 | +has "theme listens sx-theme" "$TMP/html.txt" "d.type==='sx-theme'" | |
| 178 | +has "theme asks the host" "$TMP/html.txt" "sx-theme-request" | |
| 179 | +has "bot token --bg-card" "$TMP/html.txt" '--bg-card' | |
| 180 | +has "bot token --surface-2" "$TMP/html.txt" '--surface-2' | |
| 181 | +had_toggle_embed=$(grep -c 'html.embedded #btnTheme' "$TMP/html.txt") | |
| 182 | +check "toggle hidden when embedded ($had_toggle_embed)" "$had_toggle_embed" "1" | |
| 183 | +not_has "no private palette 08080b" "$TMP/html.txt" '08080b' | |
| 184 | +not_has "no private palette eceef3" "$TMP/html.txt" 'eceef3' | |
| 185 | +not_has "no retired brand casing" "$TMP/html.txt" 'Scorpio'"X Bot" | |
| 176 | 186 | has "touch controls pad" "$TMP/html.txt" 'id="pad"' |
| 177 | 187 | has "left button" "$TMP/html.txt" 'id="bLeft"' |
| 178 | 188 | has "rotate button" "$TMP/html.txt" 'id="bRot"' |
| 179 | 189 |
| index 59f1c9d..b289bd7 100644 | index 59f1c9d..b289bd7 100644 | ||
| --- a/Makefile | --- a/Makefile | ||
| +++ b/Makefile | +++ b/Makefile | ||
| @@ -1,4 +1,4 @@ | @@ -1,4 +1,4 @@ | ||
| 1 | -# plugin_tetris_3d - ScorpioX Bot open-source 3D block game | 1 | +# plugin_tetris_3d - SCORPIOX BOT open-source 3D block game |
| 2 | # | 2 | # |
| 3 | # Targets: | 3 | # Targets: |
| 4 | # make native build -> ./plugin_tetris_3d | 4 | # make native build -> ./plugin_tetris_3d |
| index d738f4b..4f7b9dc 100644 | index d738f4b..4f7b9dc 100644 | ||
| --- a/README.md | --- a/README.md | ||
| +++ b/README.md | +++ b/README.md | ||
| @@ -1,6 +1,6 @@ | @@ -1,6 +1,6 @@ | ||
| 1 | # plugin_tetris_3d | 1 | # plugin_tetris_3d |
| 2 | 2 | ||
| 3 | -A 3D block-stacking puzzle game for a ScorpioX Bot node — a single clean-room C99 | 3 | +A 3D block-stacking puzzle game for a SCORPIOX BOT node — a single clean-room C99 |
| 4 | binary, MIT licensed, with no dependency beyond libc. | 4 | binary, MIT licensed, with no dependency beyond libc. |
| 5 | 5 | ||
| 6 | It serves a complete game UI: isometric cubes with real depth and shading, | 6 | It serves a complete game UI: isometric cubes with real depth and shading, |
| index 5742df5..9b8a0d3 100644 | index 5742df5..9b8a0d3 100644 | ||
| --- a/plugin.json | --- a/plugin.json | ||
| +++ b/plugin.json | +++ b/plugin.json | ||
| @@ -2,7 +2,7 @@ | @@ -2,7 +2,7 @@ | ||
| 2 | "slug": "tetris-3d", | 2 | "slug": "tetris-3d", |
| 3 | "id": "plugin_tetris_3d", | 3 | "id": "plugin_tetris_3d", |
| 4 | "title": "3D Block Puzzle Game", | 4 | "title": "3D Block Puzzle Game", |
| 5 | - "summary": "Zero-dependency isometric 3D block-stacking puzzle that runs in the ScorpioX Bot Chat floating window or a standalone browser tab. Software-projected cubes on a canvas with ghost piece, next-piece preview, hold queue, keyboard and touch controls, dark and light themes, and local high-score persistence through the node plugin API. No WebGL, no CDN, no network requests.", | 5 | + "summary": "Zero-dependency isometric 3D block-stacking puzzle that runs in the SCORPIOX BOT Chat floating window or a standalone browser tab. Software-projected cubes on a canvas with ghost piece, next-piece preview, hold queue, keyboard and touch controls, dark and light themes, and local high-score persistence through the node plugin API. No WebGL, no CDN, no network requests.", |
| 6 | "category": "utilities", | 6 | "category": "utilities", |
| 7 | "license": "MIT", | 7 | "license": "MIT", |
| 8 | "capabilities": ["local_filesystem_write"], | 8 | "capabilities": ["local_filesystem_write"], |
| index 5db98bb..4412b5d 100755 | index 5db98bb..4412b5d 100755 | ||
| --- a/release-dist.sh | --- a/release-dist.sh | ||
| +++ b/release-dist.sh | +++ b/release-dist.sh | ||
| @@ -31,7 +31,7 @@ set -euo pipefail | @@ -31,7 +31,7 @@ set -euo pipefail | ||
| 31 | 31 | ||
| 32 | SLUG="tetris-3d" | 32 | SLUG="tetris-3d" |
| 33 | ID="plugin_tetris_3d" | 33 | ID="plugin_tetris_3d" |
| 34 | -VERSION="1.0.0" | 34 | +VERSION="1.0.1" |
| 35 | DIST_BASE_URL="https://dist.scorpiox.net/bot-plugins" | 35 | DIST_BASE_URL="https://dist.scorpiox.net/bot-plugins" |
| 36 | 36 | ||
| 37 | ROOT="$(cd "$(dirname "$0")" && pwd)" | 37 | ROOT="$(cd "$(dirname "$0")" && pwd)" |
| @@ -224,7 +224,7 @@ target_meta() { # target_meta <key> <file> <format> <relpath> | @@ -224,7 +224,7 @@ target_meta() { # target_meta <key> <file> <format> <relpath> | ||
| 224 | printf ' "name": "tetris",\n' | 224 | printf ' "name": "tetris",\n' |
| 225 | printf ' "desc": "3D block game",\n' | 225 | printf ' "desc": "3D block game",\n' |
| 226 | printf ' "title": "3D Block Puzzle Game",\n' | 226 | printf ' "title": "3D Block Puzzle Game",\n' |
| 227 | - printf ' "summary": "Zero-dependency isometric 3D block-stacking puzzle that runs in the ScorpioX Bot Chat floating window or a standalone browser tab. Software-projected cubes on a canvas with ghost piece, next-piece preview, hold queue, keyboard and touch controls, dark and light themes, and local high-score persistence through the node plugin API. No WebGL, no CDN, no network requests.",\n' | 227 | + printf ' "summary": "Zero-dependency isometric 3D block-stacking puzzle that runs in the SCORPIOX BOT Chat floating window or a standalone browser tab. Software-projected cubes on a canvas with ghost piece, next-piece preview, hold queue, keyboard and touch controls, dark and light themes, and local high-score persistence through the node plugin API. No WebGL, no CDN, no network requests.",\n' |
| 228 | printf ' "category": "utilities",\n' | 228 | printf ' "category": "utilities",\n' |
| 229 | printf ' "version": "%s",\n' "$VERSION" | 229 | printf ' "version": "%s",\n' "$VERSION" |
| 230 | printf ' "license": "MIT",\n' | 230 | printf ' "license": "MIT",\n' |
| index 00a217d..b6ae3c7 100644 | index 00a217d..b6ae3c7 100644 | ||
| --- a/src/plugin_tetris_3d.c | --- a/src/plugin_tetris_3d.c | ||
| +++ b/src/plugin_tetris_3d.c | +++ b/src/plugin_tetris_3d.c | ||
| @@ -1,5 +1,5 @@ | @@ -1,5 +1,5 @@ | ||
| 1 | /* | 1 | /* |
| 2 | - * plugin_tetris_3d - ScorpioX Bot open-source 3D block game (clean room) | 2 | + * plugin_tetris_3d - SCORPIOX BOT open-source 3D block game (clean room) |
| 3 | * | 3 | * |
| 4 | * A single dependency-free C99 binary that serves THREE modes: | 4 | * A single dependency-free C99 binary that serves THREE modes: |
| 5 | * 1. --meta / SX_PLUGIN_META=1 -> JSON discovery metadata | 5 | * 1. --meta / SX_PLUGIN_META=1 -> JSON discovery metadata |
| @@ -59,7 +59,7 @@ | @@ -59,7 +59,7 @@ | ||
| 59 | #define PLUGIN_ID "plugin_tetris_3d" | 59 | #define PLUGIN_ID "plugin_tetris_3d" |
| 60 | #define PLUGIN_NAME "tetris" | 60 | #define PLUGIN_NAME "tetris" |
| 61 | #define PLUGIN_DESC "3D block game" | 61 | #define PLUGIN_DESC "3D block game" |
| 62 | -#define PLUGIN_VER "1.0.0" | 62 | +#define PLUGIN_VER "1.0.1" |
| 63 | 63 | ||
| 64 | #define MAX_SCORES 10 | 64 | #define MAX_SCORES 10 |
| 65 | #define PATH_SZ 1024 | 65 | #define PATH_SZ 1024 |
| index 0646853..6e377e1 100644 | index 0646853..6e377e1 100644 | ||
| --- a/src/ui_html.h | --- a/src/ui_html.h | ||
| +++ b/src/ui_html.h | +++ b/src/ui_html.h | ||
| @@ -7,11 +7,27 @@ static const char *UI_HTML = | @@ -7,11 +7,27 @@ static const char *UI_HTML = | ||
| 7 | "<html lang=\"en\"><head><meta charset=\"utf-8\">\n" | 7 | "<html lang=\"en\"><head><meta charset=\"utf-8\">\n" |
| 8 | "<meta name=\"viewport\" content=\"width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no\">\n" | 8 | "<meta name=\"viewport\" content=\"width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no\">\n" |
| 9 | "<title>tetris</title>\n" | 9 | "<title>tetris</title>\n" |
| 10 | + "<script>(function(){var t='';" | ||
| 11 | + "try{var m=/[?&]theme=(light|dark)/.exec(location.search);if(m)t=m[1];}catch(e){}" | ||
| 12 | + "if(!t){try{var s=localStorage.getItem('bot_theme');if(s==='light'||s==='dark')t=s;}catch(e){}}" | ||
| 13 | + "if(!t){try{t=(window.matchMedia&&window.matchMedia('(prefers-color-scheme: light)').matches)?'light':'dark';}catch(e){t='dark';}}" | ||
| 14 | + "document.documentElement.setAttribute('data-theme',t);" | ||
| 15 | + "try{if(/[?&]embed=(1|true)(&|$)/.test(location.search))document.documentElement.classList.add('embedded');}catch(e){}" | ||
| 16 | + "try{localStorage.setItem('bot_theme',t);}catch(e){}" | ||
| 17 | + "})();</script>\n" | ||
| 10 | "<style>\n" | 18 | "<style>\n" |
| 11 | - ":root{color-scheme:dark light;--bg:#08080b;--panel:rgba(22,22,28,.72);--panel-solid:#16161c;--text:#f4f4f7;--muted:#9b9ba6;--line:rgba(255,255,255,.11);--accent:#0a84ff;--good:#30d158;--warn:#ff9f0a;--radius:14px}\n" | 19 | + ":root{color-scheme:dark;--bg:#000000;--bg-2:#08080a;--bg-card:#1c1c1e;" |
| 12 | - "@media(prefers-color-scheme:light){:root{--bg:#eceef3;--panel:rgba(255,255,255,.78);--panel-solid:#fff;--text:#14141a;--muted:#5f5f6b;--line:rgba(0,0,0,.1)}}\n" | 20 | + "--surface-2:rgba(255,255,255,.06);--line:rgba(255,255,255,.08);--text:#f5f5f7;--text-2:#86868b;" |
| 13 | - "html[data-theme=\"dark\"]{--bg:#08080b;--panel:rgba(22,22,28,.72);--panel-solid:#16161c;--text:#f4f4f7;--muted:#9b9ba6;--line:rgba(255,255,255,.11)}\n" | 21 | + "--blue:#0a84ff;--green:#30d158;--orange:#ff9f0a;--red:#ff453a;--purple:#bf5af2;--teal:#64d2ff;--yellow:#ffd60a;" |
| 14 | - "html[data-theme=\"light\"]{--bg:#eceef3;--panel:rgba(255,255,255,.78);--panel-solid:#fff;--text:#14141a;--muted:#5f5f6b;--line:rgba(0,0,0,.1)}\n" | 22 | + "--radius:14px;--panel:var(--bg-card);--panel-solid:var(--bg-card);--muted:var(--text-2);--accent:var(--blue);--good:var(--green);--warn:var(--orange)}" |
| 23 | + "@media (prefers-color-scheme:light){html:not([data-theme=dark]){--bg:#f5f5f7;--bg-2:#ffffff;--bg-card:#ffffff;" | ||
| 24 | + "--surface-2:rgba(0,0,0,.04);--line:rgba(0,0,0,.06);--text:#1d1d1f;--text-2:#6e6e73;" | ||
| 25 | + "--blue:#007aff;--green:#34c759;--orange:#ff9500;--red:#ff3b30;--purple:#af52de;--teal:#32ade6;--yellow:#b8860b;color-scheme:light}}" | ||
| 26 | + "html[data-theme=light]{--bg:#f5f5f7;--bg-2:#ffffff;--bg-card:#ffffff;" | ||
| 27 | + "--surface-2:rgba(0,0,0,.04);--line:rgba(0,0,0,.06);--text:#1d1d1f;--text-2:#6e6e73;" | ||
| 28 | + "--blue:#007aff;--green:#34c759;--orange:#ff9500;--red:#ff3b30;--purple:#af52de;--teal:#32ade6;--yellow:#b8860b;color-scheme:light}" | ||
| 29 | + "html{color-scheme:dark}html[data-theme=dark]{color-scheme:dark}" | ||
| 30 | + "html.embedded #btnTheme{display:none!important}" | ||
| 15 | "*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}\n" | 31 | "*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}\n" |
| 16 | "html,body{margin:0;padding:0;height:100%;overflow:hidden;background:var(--bg);color:var(--text);font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Inter,system-ui,sans-serif}\n" | 32 | "html,body{margin:0;padding:0;height:100%;overflow:hidden;background:var(--bg);color:var(--text);font-family:-apple-system,BlinkMacSystemFont,\"Segoe UI\",Inter,system-ui,sans-serif}\n" |
| 17 | "#app{position:relative;width:100%;height:100%;display:flex;flex-direction:column}\n" | 33 | "#app{position:relative;width:100%;height:100%;display:flex;flex-direction:column}\n" |
| @@ -133,25 +149,28 @@ static const char *UI_HTML = | @@ -133,25 +149,28 @@ static const char *UI_HTML = | ||
| 133 | " document.getElementById('btnTheme').textContent =\n" | 149 | " document.getElementById('btnTheme').textContent =\n" |
| 134 | " (document.documentElement.getAttribute('data-theme') === 'light') ? 'Dark' : 'Light';\n" | 150 | " (document.documentElement.getAttribute('data-theme') === 'light') ? 'Dark' : 'Light';\n" |
| 135 | "}\n" | 151 | "}\n" |
| 136 | - "applyTheme(localStorage.getItem(THEME_KEY) || q.get('theme') || '');\n" | 152 | + "/* the bot posts sx-theme into the iframe; follow it, and ask once at start */\n" |
| 153 | + "window.addEventListener('message', function(e){var d=e&&e.data;" | ||
| 154 | + "if(d&&d.type==='sx-theme') applyTheme(d.theme);});\n" | ||
| 155 | + "try{if(window.parent&&window.parent!==window)window.parent.postMessage({type:'sx-theme-request'},'*');}catch(e){}\n" | ||
| 137 | "document.getElementById('btnTheme').addEventListener('click', function(){\n" | 156 | "document.getElementById('btnTheme').addEventListener('click', function(){\n" |
| 138 | " var cur = document.documentElement.getAttribute('data-theme');\n" | 157 | " var cur = document.documentElement.getAttribute('data-theme');\n" |
| 139 | " if (!cur) cur = window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark';\n" | 158 | " if (!cur) cur = window.matchMedia('(prefers-color-scheme: light)').matches ? 'light' : 'dark';\n" |
| 140 | " var next = cur === 'light' ? 'dark' : 'light';\n" | 159 | " var next = cur === 'light' ? 'dark' : 'light';\n" |
| 141 | - " localStorage.setItem(THEME_KEY, next);\n" | 160 | + " localStorage.setItem(THEME_KEY, next);try{localStorage.setItem('bot_theme',next);}catch(e){}\n" |
| 142 | " applyTheme(next);\n" | 161 | " applyTheme(next);\n" |
| 143 | "});\n" | 162 | "});\n" |
| 144 | "\n" | 163 | "\n" |
| 145 | "/* ---------------------------------------------------------------- board */\n" | 164 | "/* ---------------------------------------------------------------- board */\n" |
| 146 | "var COLS = 10, ROWS = 20, DEPTH = 3;\n" | 165 | "var COLS = 10, ROWS = 20, DEPTH = 3;\n" |
| 147 | "var SHAPES = [\n" | 166 | "var SHAPES = [\n" |
| 148 | - " { k:'I', c:'#22d3ee', b:[[1,1,1,1]] },\n" | 167 | + " { k:'I', c:'#64d2ff', b:[[1,1,1,1]] },\n" |
| 149 | - " { k:'J', c:'#3b82f6', b:[[1,0,0],[1,1,1]] },\n" | 168 | + " { k:'J', c:'#0a84ff', b:[[1,0,0],[1,1,1]] },\n" |
| 150 | - " { k:'L', c:'#f59e0b', b:[[0,0,1],[1,1,1]] },\n" | 169 | + " { k:'L', c:'#ff9f0a', b:[[0,0,1],[1,1,1]] },\n" |
| 151 | - " { k:'O', c:'#facc15', b:[[1,1],[1,1]] },\n" | 170 | + " { k:'O', c:'#ffd60a', b:[[1,1],[1,1]] },\n" |
| 152 | - " { k:'S', c:'#22c55e', b:[[0,1,1],[1,1,0]] },\n" | 171 | + " { k:'S', c:'#30d158', b:[[0,1,1],[1,1,0]] },\n" |
| 153 | - " { k:'T', c:'#a855f7', b:[[0,1,0],[1,1,1]] },\n" | 172 | + " { k:'T', c:'#bf5af2', b:[[0,1,0],[1,1,1]] },\n" |
| 154 | - " { k:'Z', c:'#ef4444', b:[[1,1,0],[0,1,1]] }\n" | 173 | + " { k:'Z', c:'#ff453a', b:[[1,1,0],[0,1,1]] }\n" |
| 155 | "];\n" | 174 | "];\n" |
| 156 | "\n" | 175 | "\n" |
| 157 | "var grid = []; /* grid[y][x] = color string or 0 */\n" | 176 | "var grid = []; /* grid[y][x] = color string or 0 */\n" |
| index 5f110f4..2a4bae1 100755 | index 5f110f4..2a4bae1 100755 | ||
| --- a/tests/run.sh | --- a/tests/run.sh | ||
| +++ b/tests/run.sh | +++ b/tests/run.sh | ||
| @@ -63,7 +63,7 @@ check "meta desc length <= 13" "$(python3 -c 'print(len("3D block game"))')" "13 | @@ -63,7 +63,7 @@ check "meta desc length <= 13" "$(python3 -c 'print(len("3D block game"))')" "13 | ||
| 63 | M2=$(SX_PLUGIN_META=1 "$BIN") | 63 | M2=$(SX_PLUGIN_META=1 "$BIN") |
| 64 | check "SX_PLUGIN_META equals --meta" "$M2" "$M" | 64 | check "SX_PLUGIN_META equals --meta" "$M2" "$M" |
| 65 | check "meta has exactly two keys" "$(jget "$M" 'sorted(d.keys())')" "['desc', 'name']" | 65 | check "meta has exactly two keys" "$(jget "$M" 'sorted(d.keys())')" "['desc', 'name']" |
| 66 | -check "--version" "$("$BIN" --version)" "plugin_tetris_3d 1.0.0" | 66 | +check "--version" "$("$BIN" --version)" "plugin_tetris_3d 1.0.1" |
| 67 | check "--meta needs no auth" "$(BOT_PASSWORD=secret "$BIN" --meta)" "$M" | 67 | check "--meta needs no auth" "$(BOT_PASSWORD=secret "$BIN" --meta)" "$M" |
| 68 | 68 | ||
| 69 | echo "== score API" | 69 | echo "== score API" |
| @@ -73,7 +73,7 @@ check "empty store ok" "$(jget "$J" 'd["ok"]')" "True" | @@ -73,7 +73,7 @@ check "empty store ok" "$(jget "$J" 'd["ok"]')" "True" | ||
| 73 | check "empty store highscore" "$(jget "$J" 'd["highscore"]')" "0" | 73 | check "empty store highscore" "$(jget "$J" 'd["highscore"]')" "0" |
| 74 | check "empty store list" "$(jget "$J" 'd["scores"]')" "[]" | 74 | check "empty store list" "$(jget "$J" 'd["scores"]')" "[]" |
| 75 | check "plugin id" "$(jget "$J" 'd["plugin"]')" "plugin_tetris_3d" | 75 | check "plugin id" "$(jget "$J" 'd["plugin"]')" "plugin_tetris_3d" |
| 76 | -check "version" "$(jget "$J" 'd["version"]')" "1.0.0" | 76 | +check "version" "$(jget "$J" 'd["version"]')" "1.0.1" |
| 77 | 77 | ||
| 78 | J=$(json 'action=save_score&val=1200') | 78 | J=$(json 'action=save_score&val=1200') |
| 79 | check "save 1200 ok" "$(jget "$J" 'd["ok"]')" "True" | 79 | check "save 1200 ok" "$(jget "$J" 'd["ok"]')" "True" |
| @@ -141,19 +141,19 @@ check "unwritable store error name" "$(jget "$(cat "$TMP/unw.json")" 'd["erro | @@ -141,19 +141,19 @@ check "unwritable store error name" "$(jget "$(cat "$TMP/unw.json")" 'd["erro | ||
| 141 | 141 | ||
| 142 | echo "== node auth" | 142 | echo "== node auth" |
| 143 | hdr() { head -1 | tr -d '\r'; } | 143 | hdr() { head -1 | tr -d '\r'; } |
| 144 | -A=$(QUERY_STRING='action=scores' BOT_PASSWORD=TESTPW "$BIN" | hdr) | 144 | +A=$(QUERY_STRING='action=scores' BOT_PASSWORD=testpw "$BIN" | hdr) |
| 145 | check "401 without credentials" "$A" "Status: 401 Unauthorized" | 145 | check "401 without credentials" "$A" "Status: 401 Unauthorized" |
| 146 | -A=$(QUERY_STRING='action=scores&pwd=TESTPW' BOT_PASSWORD=TESTPW "$BIN" | tail -1) | 146 | +A=$(QUERY_STRING='action=scores&pwd=testpw' BOT_PASSWORD=testpw "$BIN" | tail -1) |
| 147 | check "pwd query accepted" "$(jget "$A" 'd["ok"]')" "True" | 147 | check "pwd query accepted" "$(jget "$A" 'd["ok"]')" "True" |
| 148 | -A=$(QUERY_STRING='action=scores' BOT_PASSWORD=TESTPW HTTP_X_BOT_PASSWORD=TESTPW "$BIN" | tail -1) | 148 | +A=$(QUERY_STRING='action=scores' BOT_PASSWORD=testpw HTTP_X_BOT_PASSWORD=testpw "$BIN" | tail -1) |
| 149 | check "X-Bot-Password accepted" "$(jget "$A" 'd["ok"]')" "True" | 149 | check "X-Bot-Password accepted" "$(jget "$A" 'd["ok"]')" "True" |
| 150 | -A=$(QUERY_STRING='action=scores' BOT_PASSWORD=TESTPW HTTP_AUTHORIZATION='Bearer TESTPW' "$BIN" | tail -1) | 150 | +A=$(QUERY_STRING='action=scores' BOT_PASSWORD=testpw HTTP_AUTHORIZATION='Bearer TESTPW' "$BIN" | tail -1) |
| 151 | check "Bearer accepted" "$(jget "$A" 'd["ok"]')" "True" | 151 | check "Bearer accepted" "$(jget "$A" 'd["ok"]')" "True" |
| 152 | -A=$(QUERY_STRING='action=scores' BOT_PASSWORD=TESTPW HTTP_AUTHORIZATION='Bearer wrong' "$BIN" | hdr) | 152 | +A=$(QUERY_STRING='action=scores' BOT_PASSWORD=testpw HTTP_AUTHORIZATION='Bearer wrong' "$BIN" | hdr) |
| 153 | check "wrong Bearer rejected" "$A" "Status: 401 Unauthorized" | 153 | check "wrong Bearer rejected" "$A" "Status: 401 Unauthorized" |
| 154 | -A=$(QUERY_STRING='' BOT_PASSWORD=TESTPW "$BIN" | hdr) | 154 | +A=$(QUERY_STRING='' BOT_PASSWORD=testpw "$BIN" | hdr) |
| 155 | check "html is gated too" "$A" "Status: 401 Unauthorized" | 155 | check "html is gated too" "$A" "Status: 401 Unauthorized" |
| 156 | -A=$(QUERY_STRING='' BOT_PASSWORD=TESTPW HTTP_X_BOT_PASSWORD=TESTPW "$BIN" | hdr) | 156 | +A=$(QUERY_STRING='' BOT_PASSWORD=testpw HTTP_X_BOT_PASSWORD=testpw "$BIN" | hdr) |
| 157 | check "html served with password" "$A" "Content-Type: text/html; charset=utf-8" | 157 | check "html served with password" "$A" "Content-Type: text/html; charset=utf-8" |
| 158 | 158 | ||
| 159 | echo "== html" | 159 | echo "== html" |
| @@ -173,6 +173,16 @@ has "theme toggle" "$TMP/html.txt" 'id="btnTheme"' | @@ -173,6 +173,16 @@ has "theme toggle" "$TMP/html.txt" 'id="btnTheme"' | ||
| 173 | has "dark media query" "$TMP/html.txt" 'prefers-color-scheme' | 173 | has "dark media query" "$TMP/html.txt" 'prefers-color-scheme' |
| 174 | has "explicit dark theme" "$TMP/html.txt" 'data-theme="dark"' | 174 | has "explicit dark theme" "$TMP/html.txt" 'data-theme="dark"' |
| 175 | has "explicit light theme" "$TMP/html.txt" 'data-theme="light"' | 175 | has "explicit light theme" "$TMP/html.txt" 'data-theme="light"' |
| 176 | +has "theme reads ?theme=" "$TMP/html.txt" 'theme=(light|dark)' | ||
| 177 | +has "theme listens sx-theme" "$TMP/html.txt" "d.type==='sx-theme'" | ||
| 178 | +has "theme asks the host" "$TMP/html.txt" "sx-theme-request" | ||
| 179 | +has "bot token --bg-card" "$TMP/html.txt" '--bg-card' | ||
| 180 | +has "bot token --surface-2" "$TMP/html.txt" '--surface-2' | ||
| 181 | +had_toggle_embed=$(grep -c 'html.embedded #btnTheme' "$TMP/html.txt") | ||
| 182 | +check "toggle hidden when embedded ($had_toggle_embed)" "$had_toggle_embed" "1" | ||
| 183 | +not_has "no private palette 08080b" "$TMP/html.txt" '08080b' | ||
| 184 | +not_has "no private palette eceef3" "$TMP/html.txt" 'eceef3' | ||
| 185 | +not_has "no retired brand casing" "$TMP/html.txt" 'Scorpio'"X Bot" | ||
| 176 | has "touch controls pad" "$TMP/html.txt" 'id="pad"' | 186 | has "touch controls pad" "$TMP/html.txt" 'id="pad"' |
| 177 | has "left button" "$TMP/html.txt" 'id="bLeft"' | 187 | has "left button" "$TMP/html.txt" 'id="bLeft"' |
| 178 | has "rotate button" "$TMP/html.txt" 'id="bRot"' | 188 | has "rotate button" "$TMP/html.txt" 'id="bRot"' |
| 179 | 189 |