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(ecs): the editor's field setter is a producer, and now it says so
esenginecc013be6bcdd
diff --git a/sdk/tests/world-transform-authority.test.ts b/sdk/tests/world-transform-authority.test.tsindex d43743cb0..4c509c77a 100644--- a/sdk/tests/world-transform-authority.test.ts+++ b/sdk/tests/world-transform-authority.test.ts@@ -9,7 +9,7 @@*/import { describe, it, expect, beforeAll } from 'vitest';import { App } from '../src/app/app';-import { Transform } from '../src/ecs/component';+import { Sprite, Transform } from '../src/ecs/component';import type { CppRegistry, ESEngineModule } from '../src/wasm';import { loadWasmModule, HAS_WASM } from './helpers/loadWasm';@@ -170,3 +170,91 @@ describe('a compiled system that moves transforms', () => {world.disconnectCpp();});});++/**+ * The editor's generated field setter writes the same bytes every other producer+ * writes, and until now said nothing. It got away with it because an editor+ * always has a renderer — so these run without one, which is the only way to tell+ * "it announced" apart from "something else was drawing anyway".+ */+describe.skipIf(!HAS_WASM)('the editor writes through the same authority', () => {+ let module: ESEngineModule;+ beforeAll(async () => { module = await loadWasmModule(); });++ interface EditorApi {+ editor_setFloat(reg: CppRegistry, e: number, comp: string, field: string, v: number): boolean;+ editor_addComponent(reg: CppRegistry, e: number, name: string): boolean;+ }+ const editor = (): EditorApi => module as unknown as EditorApi;+ const worldPosX = (reg: CppRegistry, e: number): number =>+ (reg as unknown as { getTransform(e: number): { worldPosition: { x: number } } })+ .getTransform(e).worldPosition.x;++ /** A parent at 100 and a child 5 to its right, with no renderer installed. */+ function parented() {+ const app = App.new();+ const registry = new module.Registry() as unknown as CppRegistry;+ app.connectCpp(registry, module);+ const world = app.world;+ const parent = world.spawn('parent');+ world.insert(parent, Transform, { position: { x: 100, y: 0, z: 0 } });+ const child = world.spawn('child');+ world.insert(child, Transform, { position: { x: 5, y: 0, z: 0 } });+ world.setParent(child, parent);+ world.ensureTransformsComposed();+ return { app, world, registry, parent, child };+ }++ it('a generated field setter recomposes a world that has no renderer', () => {+ const { world, registry, parent, child } = parented();+ expect(worldPosX(registry, child)).toBe(105);++ const before = world.transformEpoch();+ expect(editor().editor_setFloat(registry, parent, 'Transform', 'position.x', 300)).toBe(true);+ expect(world.transformEpoch()).not.toBe(before);++ world.ensureTransformsComposed();+ expect(worldPosX(registry, child)).toBe(305);+ world.disconnectCpp();+ });++ it('the euler path announces too, not just the vector fields', () => {+ const { world, registry, parent } = parented();+ const before = world.transformEpoch();+ expect(editor().editor_setFloat(registry, parent, 'Transform', 'rotation.z', 90)).toBe(true);+ expect(world.transformEpoch()).not.toBe(before);+ world.disconnectCpp();+ });++ it('a setter for any other component announces nothing', () => {+ const { world, registry, parent } = parented();+ world.insert(parent, Sprite, {});+ const before = world.transformEpoch();++ // Staleness is about the composition's inputs. A generated setter that+ // bumped the epoch for every component would recompose the whole world on+ // any editor edit, and no test of the composition would catch it.+ expect(editor().editor_setFloat(registry, parent, 'Sprite', 'size.x', 42)).toBe(true);+ expect(world.transformEpoch()).toBe(before);+ world.disconnectCpp();+ });++ it('adding a Transform under a parent composes it into place', () => {+ const app = App.new();+ const registry = new module.Registry() as unknown as CppRegistry;+ app.connectCpp(registry, module);+ const world = app.world;+ const parent = world.spawn('parent');+ world.insert(parent, Transform, { position: { x: 100, y: 0, z: 0 } });+ // Parented, but carrying no Transform: nothing composes it, and nothing+ // should — it has no world position to have.+ const child = world.spawn('child');+ world.setParent(child, parent);+ world.ensureTransformsComposed();++ expect(editor().editor_addComponent(registry, child, 'Transform')).toBe(true);+ world.ensureTransformsComposed();+ expect(worldPosX(registry, child)).toBe(100);+ world.disconnectCpp();+ });+});diff --git a/src/esengine/bindings/EditorAPI.generated.cpp b/src/esengine/bindings/EditorAPI.generated.cppindex f58064be2..5ab7adb18 100644--- a/src/esengine/bindings/EditorAPI.generated.cpp+++ b/src/esengine/bindings/EditorAPI.generated.cpp@@ -807,7 +807,7 @@ bool editor_addComponent(Registry& reg, u32 e, const std::string& name) {if (!reg.has<esengine::ecs::TrailRenderer>(entity)) reg.emplace<esengine::ecs::TrailRenderer>(entity);return true;} else if (name == "Transform") {- if (!reg.has<esengine::ecs::Transform>(entity)) reg.emplace<esengine::ecs::Transform>(entity);+ if (!reg.has<esengine::ecs::Transform>(entity)) { reg.emplace<esengine::ecs::Transform>(entity); esengine::ecs::invalidateTransformComposition(); }return true;} else if (name == "UIInteraction") {if (!reg.has<esengine::ecs::UIInteraction>(entity)) reg.emplace<esengine::ecs::UIInteraction>(entity);@@ -1417,6 +1417,7 @@ bool editor_setFloat(Registry& reg, u32 e, const std::string& comp, const std::sc.rotation = eulerDegToQuat(euler);}else { return false; }+ esengine::ecs::invalidateTransformComposition();return true;} else if (comp == "UIMask") {if (!reg.has<esengine::ecs::UIMask>(entity)) return false;diff --git a/tools/check-generated-fresh.mjs b/tools/check-generated-fresh.mjsnew file mode 100644index 000000000..3de6bf94f--- /dev/null+++ b/tools/check-generated-fresh.mjs@@ -0,0 +1,109 @@+#!/usr/bin/env node+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file check-generated-fresh.mjs — the committed *.generated.* files are what+ * the generator produces today.+ *+ * EHT's outputs are checked in, because the SDK and the editor build without+ * running it. That is a cache with no invalidation: edit the generator, forget to+ * regenerate, and the authority says one thing while the artifact everyone+ * compiles says the older one, with nothing between them to notice.+ *+ * So a whole set is generated into a scratch tree and compared. Nothing is+ * written into the repo, which is what lets this run on a dirty checkout and+ * report on the generator rather than on the working directory.+ *+ * The artifact list is EHT's own stdout ("Generating: <path>"), not a table here:+ * a new generated file is covered the day it exists.+ *+ * node tools/check-generated-fresh.mjs (exit 1 on drift, 2 if unanswerable)+ */+import { execFileSync } from 'node:child_process';+import { existsSync, mkdtempSync, readFileSync, rmSync } from 'node:fs';+import { tmpdir } from 'node:os';+import path from 'node:path';+import { fileURLToPath } from 'node:url';++const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');+const { resolvePython } = await import('../build-tools/utils/emscripten.js');+const { ENGINE_BINDING_HEADERS } = await import('../build-tools/tasks/native.js');++const python = await resolvePython();+if (!python) {+ // Not a pass and not a failure: this machine cannot answer the question.+ console.log('check-generated-fresh: no Python 3 on PATH — cannot run EHT, so nothing was checked.');+ process.exit(2);+}++const out = mkdtempSync(path.join(tmpdir(), 'estella-eht-'));+const eht = path.join(ROOT, 'tools', 'eht.py');+const run = (args) => execFileSync(python, [eht, ...args], { cwd: ROOT, stdio: 'pipe' }).toString();++/** Where a scratch output root maps back to in the repo. */+const ROOTS = [+ [path.join(out, 'bindings'), 'src/esengine/bindings'],+ [path.join(out, 'aot'), 'src/esengine/aot'],+ [path.join(out, 'ts'), 'sdk'],+];++let stdout;+try {+ stdout = run([+ '--input', path.join(ROOT, 'src/esengine/ecs/components'),+ '--entity-header', path.join(ROOT, 'src/esengine/core/Types.hpp'),+ '--const-root', path.join(ROOT, 'src/esengine'),+ '--output', path.join(out, 'bindings'),+ '--ts-output', path.join(out, 'ts'),+ '--aot-output', path.join(out, 'aot'),+ ]);+ // The TS half of the native entry-point surface is committed too, and only a+ // native build refreshes it — the one generated file with no local reason to+ // be regenerated, which is the one most able to rot.+ const nativeTs = path.join(out, 'nativeEngineApi.generated.ts');+ run([+ '--native-functions', ...ENGINE_BINDING_HEADERS.map((h) => path.join(ROOT, 'src/esengine/bindings', h)),+ '--native-functions-ts', nativeTs,+ '--native-shim', 'esn_shim.hpp',+ ]);+ stdout += `Generating: ${nativeTs}\n`;+ ROOTS.push([out, 'sdk/src/ecs/bridge']);+} catch (e) {+ console.error('EHT failed:\n' + String(e.stderr || e.stdout || e.message));+ rmSync(out, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 });+ process.exit(1);+}++const emitted = [...stdout.matchAll(/^Generating: (.+)$/gm)].map((m) => m[1].trim())+ .filter((p) => p.startsWith(out));+const stale = [];+const unmapped = [];+for (const file of emitted) {+ const root = ROOTS.find(([scratch]) => file.startsWith(scratch + path.sep));+ if (!root) { unmapped.push(file); continue; }+ const rel = path.join(root[1], path.relative(root[0], file));+ const committed = path.join(ROOT, rel);+ if (!existsSync(committed)) { stale.push([rel, 'not committed at all']); continue; }+ if (readFileSync(committed).equals(readFileSync(file))) continue;+ stale.push([rel, 'differs from what the generator produces now']);+}+rmSync(out, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 });++if (emitted.length === 0) {+ console.error('check-generated-fresh: EHT emitted nothing — the run said no file was generated.');+ process.exit(1);+}+if (unmapped.length) {+ console.error('check-generated-fresh: EHT emitted a file this gate cannot map back to the repo:');+ for (const p of unmapped) console.error(` ${p}`);+ console.error('\nAdd its output root to ROOTS — an unmapped artifact is an unchecked one.');+ process.exit(1);+}+if (stale.length) {+ console.error('Committed generated files are not what the generator produces:\n');+ for (const [rel, why] of stale) console.error(` ${rel} — ${why}`);+ console.error('\nRegenerate: node build-tools/cli.js eht --no-cache');+ console.error('(the native TS surface, if listed, comes from a native build — see build-tools/tasks/native.js)');+ process.exit(1);+}+console.log(`generated files fresh: ${emitted.length} artifact(s) match the generator.`);diff --git a/tools/check-native-bindings.mjs b/tools/check-native-bindings.mjsindex e280d3f30..fd173f6dd 100644--- a/tools/check-native-bindings.mjs+++ b/tools/check-native-bindings.mjs@@ -46,7 +46,16 @@ if (failed) {// 2. The generator runs.const out = mkdtempSync(path.join(tmpdir(), 'estella-nfb-'));const generated = path.join(out, 'NativeFunctionBindings.generated.cpp');-const python = process.env.PYTHON || 'python';+// `python` is not a command macOS ships; `python3` is. Asking the same resolver+// the build asks is why this gate can run on a developer's machine at all — it+// was CI-only on the belief that it could not.+const { resolvePython } = await import('../build-tools/utils/emscripten.js');+const python = await resolvePython();+if (!python) {+ console.log('check-native-bindings: no Python 3 on PATH — cannot run EHT, so nothing was checked.');+ rmSync(out, { recursive: true, force: true, maxRetries: 10, retryDelay: 50 });+ process.exit(2);+}try {execFileSync(python, [path.join(ROOT, 'tools', 'eht.py'),diff --git a/tools/check-transform-seam.mjs b/tools/check-transform-seam.mjsnew file mode 100644index 000000000..bb846cb03--- /dev/null+++ b/tools/check-transform-seam.mjs@@ -0,0 +1,160 @@+#!/usr/bin/env node+// SPDX-License-Identifier: Apache-2.0+// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team+/**+ * @file check-transform-seam.mjs — the generated editor API announces exactly+ * the writes that make a composed world transform stale.+ *+ * Composition is scheduled by a staleness epoch, so a producer that writes a+ * Transform's inputs and says nothing is invisible: the world composes once and+ * answers every later question with the first answer. The editor's generated+ * setter was that producer, and nobody saw it — an editor always has a renderer,+ * and something else bumped the epoch every frame.+ *+ * EHT rewrites that file wholesale, so the seam cannot be defended by reviewing a+ * hand edit. Three grounds are compared instead: `Transform.hpp` says which+ * fields are composition INPUT (writable) and which are its OUTPUT (`readonly`),+ * `tools/eht/data.py` says which component announces and with what call, and+ * EditorAPI.generated.cpp says what was emitted.+ *+ * Under-announcing is a false negative. OVER-announcing is the opposite failure+ * and just as real — a hook on every component recomposes the whole world on any+ * edit, and no test of the composition can tell. Both are refused.+ *+ * node tools/check-transform-seam.mjs (exit 1 on either)+ */+import { readdirSync, 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 COMPONENTS_DIR = path.join(ROOT, 'src', 'esengine', 'ecs', 'components');+const GENERATED = path.join(ROOT, 'src', 'esengine', 'bindings', 'EditorAPI.generated.cpp');+const DATA_PY = path.join(ROOT, 'tools', 'eht', 'data.py');++const errors = [];+const fail = (msg) => errors.push(msg);+const read = (p) => readFileSync(p, 'utf8');++// ── What the generator declares ──+// Parsed from the literal rather than restated here: a second table would be a+// second authority, and the one that drifted would be this one.+const hooksBlock = /WRITE_HOOKS\s*:\s*Dict\[str,\s*str\]\s*=\s*\{([^}]*)\}/.exec(read(DATA_PY));+if (!hooksBlock) {+ console.error('check-transform-seam: no WRITE_HOOKS literal in tools/eht/data.py — the generator\'s declaration moved.');+ process.exit(1);+}+const HOOKS = new Map([...hooksBlock[1].matchAll(/'([^']+)'\s*:\s*'([^']+)'/g)].map((m) => [m[1], m[2]]));+if (HOOKS.size === 0) {+ console.error('check-transform-seam: WRITE_HOOKS is empty — nothing announces that a composition went stale.');+ process.exit(1);+}++// ── What the component header says each field IS ──+/** The struct body of `name`, brace-matched from its ES_COMPONENT declaration. */+function structBody(name) {+ for (const file of readdirSync(COMPONENTS_DIR).filter((f) => f.endsWith('.hpp'))) {+ const text = read(path.join(COMPONENTS_DIR, file));+ const decl = new RegExp(String.raw`ES_COMPONENT\s*\([^)]*\)\s*struct\s+${name}\s*\{`).exec(text);+ if (!decl) continue;+ let depth = 0;+ for (let i = decl.index + decl[0].length - 1; i < text.length; i++) {+ if (text[i] === '{') depth++;+ else if (text[i] === '}' && --depth === 0) {+ return { file: path.relative(ROOT, path.join(COMPONENTS_DIR, file)), body: text.slice(decl.index, i) };+ }+ }+ }+ return null;+}++// Same annotation grammar as the parser EHT itself uses: runs of non-paren chars+// OR whole quoted strings, so a `)` inside a tooltip does not end the list.+const PROPERTY = /ES_PROPERTY\s*\(\s*((?:[^)"]|"[^"]*")*?)\s*\)\s*([^;{=]+?)\s+(\w+)\s*(?:\{|=|;)/g;++/** A component's fields, split the way the composition splits them. */+function classify(name) {+ const found = structBody(name);+ if (!found) return null;+ const inputs = new Set();+ const outputs = new Set();+ for (const m of found.body.matchAll(PROPERTY)) {+ // Quoted values are stripped before looking for a bare key, so a tooltip+ // that happens to contain the word does not annotate anything.+ const keys = m[1].replace(/"[^"]*"/g, '');+ (/\breadonly\b/.test(keys) ? outputs : inputs).add(m[3]);+ }+ return { ...found, inputs, outputs };+}++// ── What the generator emitted ──+const generated = read(GENERATED).split('\n');+const FUNCTION = /^[A-Za-z_][\w:<>&*\s]*\s(editor_\w+)\s*\(/;+const BRANCH = /^\s{4}(?:\}\s*else\s*)?if\s*\((?:comp|name)\s*==\s*"(\w+)"\)/;+const ASSIGN = /\bc\.(\w+)(?:\.\w+)*\s*=[^=]/;+const EMPLACE = /\bemplace<[\w:]*\b(\w+)>/;++/** Every `comp == "X"` arm of every editor_* function, with what it does. */+const branches = [];+let fn = null;+let current = null;+for (const [i, line] of generated.entries()) {+ const f = FUNCTION.exec(line);+ if (f) { fn = f[1]; current = null; continue; }+ if (!fn) continue;+ const b = BRANCH.exec(line);+ if (b) {+ current = { fn, comp: b[1], line: i + 1, assigns: new Set(), emplaces: false, hooks: [] };+ branches.push(current);+ continue;+ }+ if (!current) continue;+ const a = ASSIGN.exec(line);+ if (a) current.assigns.add(a[1]);+ const e = EMPLACE.exec(line);+ if (e && e[1] === current.comp) current.emplaces = true;+ for (const [comp, hook] of HOOKS) if (line.includes(hook.trim())) current.hooks.push(comp);+}++// ── The three, against each other ──+for (const [comp, hook] of HOOKS) {+ const fields = classify(comp);+ if (!fields) { fail(`WRITE_HOOKS names "${comp}", which declares no ES_COMPONENT struct under ${path.relative(ROOT, COMPONENTS_DIR)}.`); continue; }+ if (fields.inputs.size === 0) fail(`${comp} has no writable field, so a write hook on it announces nothing (${fields.file}).`);+ if (fields.outputs.size === 0) fail(`${comp} has no readonly field, so it composes nothing a hook could make stale (${fields.file}).`);++ // The call has to BE something. A renamed seam leaves a hook string that+ // matches every branch equally well and defends nothing.+ const called = /(\w+)\s*\(\s*\)\s*;/.exec(hook);+ if (!called) fail(`the hook for ${comp} is not a call: ${hook}`);+ else if (!new RegExp(String.raw`\b${called[1]}\s*\(`).test(read(path.join(ROOT, 'src', 'esengine', 'ecs', 'TransformSystem.hpp')))) {+ fail(`the hook for ${comp} calls ${called[1]}(), which src/esengine/ecs/TransformSystem.hpp does not declare.`);+ }++ for (const b of branches) {+ const writes = b.comp === comp && (b.assigns.size > 0 || b.emplaces);+ const announces = b.hooks.includes(comp);+ if (writes && !announces) {+ fail(`${b.fn} writes ${comp} at EditorAPI.generated.cpp:${b.line} and does not announce it.`);+ }+ if (!writes && announces) {+ fail(`${b.fn}'s "${b.comp}" arm announces ${comp} at EditorAPI.generated.cpp:${b.line} without writing it.`);+ }+ if (b.comp !== comp) continue;+ for (const field of b.assigns) {+ if (fields.outputs.has(field)) fail(`${b.fn} assigns ${comp}.${field}, which is the composition's OUTPUT (EditorAPI.generated.cpp:${b.line}).`);+ else if (!fields.inputs.has(field)) fail(`${b.fn} assigns ${comp}.${field}, which ${fields.file} does not declare as a property (EditorAPI.generated.cpp:${b.line}).`);+ }+ }+}++if (errors.length) {+ console.error('The generated editor API and the composition authority disagree:\n');+ for (const e of errors) console.error(` ${e}`);+ console.error('\nThe seam is emitted by tools/eht/generators/editor_api.py from WRITE_HOOKS in tools/eht/data.py.');+ console.error('Regenerate with `node build-tools/cli.js eht --no-cache` — the file is never edited by hand.');+ process.exit(1);+}++const announcing = branches.filter((b) => b.hooks.length > 0);+console.log(`transform seam OK: ${HOOKS.size} hooked component(s), ${announcing.length} announcing arm(s) of ${branches.length}.`);diff --git a/tools/eht/__main__.py b/tools/eht/__main__.pyindex 5b6be8bb7..eaccc141f 100644--- a/tools/eht/__main__.py+++ b/tools/eht/__main__.py@@ -79,6 +79,11 @@ def main() -> int:help='Output directory for C++ bindings')parser.add_argument('--ts-output', type=Path, default=Path('sdk'),help='Output directory for TypeScript')+ # Addressable like the other two outputs, so a freshness check can generate a+ # whole set into a scratch tree and compare — rather than writing over the+ # committed files it is trying to judge.+ parser.add_argument('--aot-output', type=Path, default=Path('src/esengine/aot'),+ help='Output directory for the AOT component resolvers')parser.add_argument('--entity-header', type=Path,default=Path('src/esengine/core/Types.hpp'),help='Header declaring Entity::Layout = PackedId<index, gen>')@@ -190,13 +195,15 @@ def main() -> int:print(f"ABI layout hash: {abi_hash}")# ── C++ Editor API ──+ # Before the first write, not between the two: the editor API landed in a+ # directory nobody had created yet whenever the output root was fresh.+ args.output.mkdir(parents=True, exist_ok=True)editor_api_path = args.output / 'EditorAPI.generated.cpp'print(f"Generating: {editor_api_path}")editor_gen = EditorAPIGenerator(cpp_parser.components, cpp_parser.enums)editor_api_path.write_text(editor_gen.generate(), encoding='utf-8')# ── C++ Embind Bindings ──- args.output.mkdir(parents=True, exist_ok=True)embind_path = args.output / 'WebBindings.generated.cpp'print(f"Generating: {embind_path}")embind_gen = EmbindGenerator(@@ -209,7 +216,7 @@ def main() -> int:# ── Component resolvers for compiled systems ──# Committed like the two above: a host that dispatches a compiled system# needs the type half of the contract, and it must not be a second table.- aot_dir = Path('src/esengine/aot')+ aot_dir = args.aot_outputaot_dir.mkdir(parents=True, exist_ok=True)aot_gen = AotComponentsGenerator(cpp_parser.components, cpp_parser.enums)for name, text in (('AotComponents.generated.hpp', aot_gen.generate_header()),diff --git a/tools/eht/data.py b/tools/eht/data.pyindex 9c1c5fd99..48fcfc60a 100644--- a/tools/eht/data.py+++ b/tools/eht/data.py@@ -40,6 +40,15 @@ READ_HOOKS: Dict[str, str] = {'Transform': 'ensureDecomposed'}HIERARCHY_COMPONENTS: Set[str] = {'Parent', 'Children'}+# The write-side twin of READ_HOOKS. A composed world transform is a function of+# Transform's WRITABLE fields, so a generated setter for one of them has to say the+# composition went stale: a world composes on that epoch alone, and a headless one+# has no frame to schedule it instead. Keyed by component, never by field name —+# the readonly fields are the composition's OUTPUT and no setter is generated for+# them at all, which is what keeps this from invalidating on its own result.+WRITE_HOOKS: Dict[str, str] = {'Transform': 'esengine::ecs::invalidateTransformComposition();'}++@dataclassclass Enum:"""An ES_ENUM enum class."""diff --git a/tools/eht/generators/editor_api.py b/tools/eht/generators/editor_api.pyindex 94b724292..58f630e52 100644--- a/tools/eht/generators/editor_api.py+++ b/tools/eht/generators/editor_api.py@@ -8,7 +8,7 @@ Generates EditorAPI.generated.cpp with:import hashlibfrom typing import List, Set-from ..data import Component, Enum, HIERARCHY_COMPONENTS+from ..data import Component, Enum, HIERARCHY_COMPONENTS, WRITE_HOOKSfrom ..type_system import TypeSystemfrom ..field_utils import get_sub_components, get_editor_type, is_color_field@@ -172,6 +172,16 @@ class EditorAPIGenerator:def _is_readonly(self, prop) -> bool:return 'readonly' in prop.annotations+ def _write_hook(self, comp: Component) -> List[str]:+ """What a successful set on this component has to announce, if anything.++ Emitted once per branch rather than per field: every field that reaches a+ setter is writable (readonly ones are filtered out above), so reaching the+ end of the chain already means a real write happened.+ """+ hook = WRITE_HOOKS.get(comp.name)+ return [f' {hook}'] if hook else []+def _get_all_fields(self, comp: Component) -> list:"""Get all editable fields as (key, editor_type, group, enum_values) tuples."""fields = []@@ -225,6 +235,12 @@ class EditorAPIGenerator:# A bare Parent names no one, and TransformSystem skips anything that# has one — the link is made by naming a parent, not by adding this.lines.append(f' return false;')+ elif WRITE_HOOKS.get(comp.name):+ # Structural, and still a composition input: a Transform added+ # under a parent is at the origin until something composes it.+ hook = WRITE_HOOKS[comp.name]+ lines.append(f' if (!reg.has<{full}>(entity)) {{ reg.emplace<{full}>(entity); {hook} }}')+ lines.append(f' return true;')else:lines.append(f' if (!reg.has<{full}>(entity)) reg.emplace<{full}>(entity);')lines.append(f' return true;')@@ -379,6 +395,7 @@ class EditorAPIGenerator:idx += 1lines.append(' else { return false; }')+ lines.extend(self._write_hook(comp))lines.append(' return true;')if not first_comp:@@ -499,6 +516,7 @@ class EditorAPIGenerator:lines.append(f' {prefix} (field == "{key}") {{ c.{cpp_path} = static_cast<{cpp_type}>(value); }}')lines.append(' else { return false; }')+ lines.extend(self._write_hook(comp))lines.append(' return true;')if not first_comp:@@ -599,6 +617,7 @@ class EditorAPIGenerator:lines.append(f' {prefix} (field == "{key}") {{ c.{cpp_path} = value; }}')lines.append(' else { return false; }')+ lines.extend(self._write_hook(comp))lines.append(' return true;')if not first_comp:@@ -695,6 +714,7 @@ class EditorAPIGenerator:side_effect = _STRING_SET_SIDE_EFFECTS.get(comp.name)if side_effect:lines.append(f' {side_effect}')+ lines.extend(self._write_hook(comp))lines.append(' return true;')if not first_comp:diff --git a/tools/gates.mjs b/tools/gates.mjsindex cb5775262..dd5ec853b 100644--- a/tools/gates.mjs+++ b/tools/gates.mjs@@ -51,12 +51,11 @@ export const GATES = [{ id: 'fixture-scenes', run: 'node tools/check-fixture-scenes.mjs' },{ id: 'doc-imports', run: 'node tools/check-doc-imports.mjs' },{ id: 'architecture-doc', run: 'node tools/check-architecture-doc.mjs' },- {- id: 'native-bindings',- run: 'node tools/check-native-bindings.mjs',- where: 'ci',- why: 'the EHT generator shells out to `python`, which macOS does not ship a runnable one of; run it by hand where you have one',- },+ { id: 'native-bindings', run: 'node tools/check-native-bindings.mjs' },+ // The generator's output is checked in, so its authority and its artifact can+ // disagree with nothing between them to notice.+ { id: 'generated-fresh', run: 'node tools/check-generated-fresh.mjs' },+ { id: 'transform-seam', run: 'node tools/check-transform-seam.mjs' },{ id: 'api-surface', run: 'node tools/api-surface.mjs --check' },// Reads the snapshot the gate above just proved current, against the one the// last release tag shipped — drift says the surface moved, this says a promise did.