Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·originates fromworld 07158574-5…

component_proxy

Computed-property registry shared by every component proxy. The proxy ITSELF is installed in Rust (`crates/zero_scripting/src/world_context.rs::setup_public_dirty_tracking`) — this module owns only the cross-VM-instance bookkeeping for `public.X = computed(fn)` declarations: the…

byzero-proxy @ DESKTOP-DB3UJOJ·posted 2mo ago
What it does

component_proxy

Computed-property registry shared by every component proxy. The proxy ITSELF is installed in Rust (crates/zero_scripting/src/world_context.rs::setup_public_dirty_tracking) — this module owns only the cross-VM-instance bookkeeping for public.X = computed(fn) declarations: the global registry table and the sentinel-string protocol that lets dispatch survive any serialization the engine performs on the public table. Installs computed as a _G global via M.installGlobal().

Exports

  • M.computed(fn: (any) -> any) -> string — stash fn keyed by a deterministic sentinel and return the sentinel string. Errors if fn is not a function.
  • M.installGlobal() — install computed as a _G.computed so component modules can write public.X = computed(fn) without an explicit require. Prelude calls this once.

Usage

local CP = require("@builtin::modules.component_proxy")

-- Once, at boot (prelude does this):
CP.installGlobal()

-- In a component module's top-level body:
public.area = computed(function(self) return self.w * self.h end)

Notes

  • The sentinel prefix (__zero_computed__) and registry global name (__zero_computed_registry__) are duplicated in crates/zero_scripting/src/world_context.rs (COMPUTED_SENTINEL_PREFIX). Renaming either side requires the matching rename on the other.
  • The registry is a _G table; it survives module hot-reload but every call to computed(fn) registers a fresh sentinel (sentinel includes tostring(fn)), so re-running a component module replaces its computed entries rather than leaking old ones — provided fn is a fresh closure each time.
  • installGlobal is idempotent. Re-running it just overwrites the global with the same function.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

ComponentProxy Module Computed-property registry shared by every component proxy. The proxy ITSELF is installed in Rust (see crates/zero_scripting/src/world_context.rs::setup_public_dirty_tracking) — this module owns only the bookkeeping for `public.X = computed(fn)` declarations: the registry table and the sentinel-string protocol that lets dispatch survive any serialization the engine performs on the public table. The registry table is a MODULE-LOCAL upvalue (`computedRegistry`), never on `_G`. At boot `M.installGlobal()` hands it to the engine ONCE via the internal `__bind_computed_registry` primitive, which stashes it in the Lua C registry (LUA_REGISTRYINDEX) — unreachable from Luau and untouched by the `_G` seal (`luaL_sandbox`). The Rust-side public_index C closure reads it back from the C registry on every computed-field read. The protocol: 1. `computed(fn)` stores `fn` in the module-local `computedRegistry` keyed by a deterministic sentinel string and returns the sentinel. 2. Component module top-level writes `public.X = computed(fn)` — the sentinel string lands in the proxy's backing table. 3. Reading `proxy.X` triggers public_index, which sees the sentinel value, looks the getter up in the C-registry-stashed table, calls `fn(proxy)`, and returns the result. The sentinel prefix (`__zero_computed__`) and the C-registry key (`__zero_computed_registry__`) are mirrored verbatim in crates/zero_scripting/src/world_context.rs (constant COMPUTED_SENTINEL_PREFIX + the LUA_REGISTRYINDEX field read) and crates/zero_scripting/src/ffi_callbacks.rs (`__bind_computed_registry`). Renaming any side requires the matching change on the others. Consumers: local CP = require("modules.component_proxy") CP.installGlobal() -- prelude does this once public.area = computed(function(self) return self.w * self.h end)

registry( ) → void

Internal: the module-local registry table.

computed(fn: (any) →

Mark a function as a computed property. The function takes `self` (the proxy) and returns the computed value. Returns a string sentinel that the Rust-side public_index dispatches through the registry on every read.

argtypedescription
fn(anyThe getter — receives the proxy and returns the computed value.

examples

public.area = computed(function(self) return self.w * self.h end)

installGlobal( ) → void

Install `computed` as a global so component modules can write `public.X = computed(fn)` without an explicit require. Called by the prelude.

examples

require("modules.component_proxy").installGlobal()

isComputedSentinel(v: any) → boolean

True iff `v` is a computed-property sentinel — the string a `computed(fn)` declaration stores in a proxy's `public` table. Reads of the property resolve the sentinel to the getter's value, but a raw `pairs()` over the backing table yields the sentinel itself. Serializers call this to skip computed (derived) fields, which are re-derived on load.

argtypedescription
vanyThe value to test.

Sub-parts

Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.

6items
·
other · born here
▤file
▲ 0↑ born
▣
module · born here
❒asset
# engine_records The engine's own records: the tables a subsystem keeps as its account of what stands in the running engine, and the classes whose every instance is one. The input maps activated, a signal's handlers and connections, the entity and asset event registries and the renderer's registry of live features are records; each follows whoever holds the thing it records. `declare(t)` makes a table a record, `declareClass(mt)` makes every table carrying that metatable one, and `holds(v)` answers whether a value is a record. `engine.snapshotModuleState` carries a record by reference without walking it, and `engine.restoreModuleState` leaves it as it stands, so what went away since a reading stays away and what arrived stays in place. A leaf with no requires, so a module that loads before the `engine` global exists declares its records as it loads.
▲ 0↑ born

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported. This asset, its contents, and its direct deps are clean as of the latest commit.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.