A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
feat(gates): the text ramp is held to 4.5:1 on the surfaces text sits on
esengine505bca9f6abf
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 08006dbbe..fe3af176b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -16,6 +16,13 @@ published separately; it ships inside the editor.### Added+- **The editor's faintest label colour is readable.** The colour most labels in the editor+ are drawn in — file rows, legends, budget captions, hints — sat at 3.26:1 against a panel,+ below the 4.5:1 that body text needs, so a whole tier of the interface was technically+ present and practically hard to read. It is now 4.96:1 on a panel body and 4.54:1 on the+ raised strips, and a gate holds the whole text ramp there, because the visual layer was+ the one part of this project with no check of its own to drift against.+- **A build the preflight objects to can be packaged anyway.** Pressing Package with ablocker standing used to show a list and stop there, on a verdict you never agreed to — adead reference in a scene you are not shipping yet, or an entry scene you are mid-renamediff --git a/desktop b/desktopindex 91198483c..902fee8ed 160000--- a/desktop+++ b/desktop@@ -1 +1 @@-Subproject commit 91198483c4d69a879687f8b7eb98d8b8c08a71ee+Subproject commit 902fee8ed278a321225592b4feda20f969ba67fediff --git a/tools/check-theme.mjs b/tools/check-theme.mjsnew file mode 100644index 000000000..514fcd663--- /dev/null+++ b/tools/check-theme.mjs@@ -0,0 +1,84 @@+#!/usr/bin/env node+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file Whether the editor's text is readable on the surfaces it sits on.+ *+ * Every invariant in this repository has a gate except the visual layer, which+ * is why the visual layer is the one that drifted: `--text-faint` shipped at+ * 3.26:1 on a panel — under the 4.5:1 floor for body text — as the colour of+ * most labels in the editor, and nothing said so for as long as it took a person+ * to compute it by hand.+ *+ * Scope is deliberately one claim: the text ramp against the surface ramp, read+ * from the token file. Not the 963 off-grid spacings or the 74 hard-coded hexes+ * — those are real and counted in docs/local/, but a gate that reddens on a+ * thousand call sites gets switched off, and one that cannot go green teaches+ * nothing. This one is green when the ramp is right and red the moment a value+ * is darkened past the floor.+ */+import { readFileSync } from 'node:fs';+import path from 'node:path';+import { fileURLToPath } from 'node:url';++const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');+const TOKENS = 'desktop/src/theme/tokens.css';++/** WCAG 2.x relative luminance, then the contrast ratio between two sRGB hexes. */+const channel = (c) => (c / 255 <= 0.04045 ? c / 255 / 12.92 : ((c / 255 + 0.055) / 1.055) ** 2.4);+const luminance = (hex) => {+ const h = hex.replace('#', '');+ const [r, g, b] = [0, 2, 4].map((i) => parseInt(h.slice(i, i + 2), 16));+ return 0.2126 * channel(r) + 0.7152 * channel(g) + 0.0722 * channel(b);+};+const contrast = (a, b) => {+ const [x, y] = [luminance(a), luminance(b)];+ return (Math.max(x, y) + 0.05) / (Math.min(x, y) + 0.05);+};++/** Body text, per WCAG AA and Unity's own editor accessibility page. */+const FLOOR = 4.5;+/**+ * The surfaces text is READ on: the panel body and the raised strip above it.+ * `--srf-4` and up are hover and popover fills, where the ramp is lower by+ * construction — holding those to the body floor would mean one flat text+ * colour, so they are counted and reported, not enforced.+ */+const READING_SURFACES = ['--srf-2', '--srf-3'];++const css = readFileSync(path.join(ROOT, TOKENS), 'utf8');+const valueOf = (name) => {+ const hit = new RegExp(`^\\s*${name}:\\s*(#[0-9a-fA-F]{6})\\b`, 'm').exec(css);+ return hit ? hit[1] : null;+};++const textTokens = [...css.matchAll(/^\s*(--text(?:-[a-z]+)?):\s*(#[0-9a-fA-F]{6})\b/gm)]+ .map(([, name, hex]) => ({ name, hex }));++const problems = [];+if (textTokens.length === 0) problems.push(`${TOKENS}: no --text* tokens found — the ramp cannot be read`);++const reported = [];+for (const surface of READING_SURFACES) {+ const bg = valueOf(surface);+ if (!bg) { problems.push(`${TOKENS}: ${surface} is not a hex value — the ramp cannot be judged against it`); continue; }+ for (const { name, hex } of textTokens) {+ const ratio = contrast(hex, bg);+ reported.push({ surface, name, ratio });+ if (ratio < FLOOR) {+ problems.push(`${TOKENS}: ${name} (${hex}) is ${ratio.toFixed(2)}:1 on ${surface} (${bg}) — body text needs ${FLOOR}:1`);+ }+ }+}++if (problems.length > 0) {+ for (const p of problems) console.error(` ${p}`);+ console.error(`check-theme: ${problems.length} finding(s).`);+ process.exit(1);+}++const worst = reported.reduce((a, b) => (a.ratio <= b.ratio ? a : b));+console.log(+ `check-theme: ${textTokens.length} text token(s) over ${READING_SURFACES.length} reading surface(s) — `+ + `all >= ${FLOOR}:1, closest is ${worst.name} at ${worst.ratio.toFixed(2)}:1 on ${worst.surface}.`,+);diff --git a/tools/gates.mjs b/tools/gates.mjsindex 00969c147..6118ac600 100644--- a/tools/gates.mjs+++ b/tools/gates.mjs@@ -245,6 +245,7 @@ export const GATES = [{ id: 'dirty-source', run: 'node tools/check-dirty-source.mjs', needs: 'editor' },{ id: 'path-sandbox', run: 'node tools/check-path-sandbox.mjs' },{ id: 'key-codes', run: 'node tools/check-key-codes.mjs' },+ { id: 'theme', run: 'node tools/check-theme.mjs', needs: 'editor' },{ id: 'comment-style', run: 'node tools/check-comment-style.mjs' },{ id: 'silent-writes', run: 'node tools/mutation-census.mjs --gate' },{diff --git a/tools/releaseNotes.mjs b/tools/releaseNotes.mjsindex 14b7c1055..467fdc93d 100644--- a/tools/releaseNotes.mjs+++ b/tools/releaseNotes.mjs@@ -46,6 +46,12 @@ export const NOTED = {'fix(gates): the build adjudicator gate reads both halves of the decision':{ internal: 'A repository gate reading the editor source; no creator runs it.' },+ 'feat(gates): the text ramp is held to 4.5:1 on the surfaces text sits on':+ { note: "The editor's faintest label colour is readable." },++ "fix(gates): the acknowledged build's cleanup retries, as every recursive delete must":+ { internal: "An editor check's own temp-directory cleanup; no creator runs it." },+'feat(render): the WebGPU backend draws the scene and the backbuffer multisampled':{ note: 'Geometry edges are anti-aliased on WebGPU, which is every native build.' },