Repository navigation
feat(universal): support Children and descriptorChildren in universal renderers - #2207
Conversation
… renderers Shared .tsrx components that enumerate their children failed to compile for universal renderers: the universal compiler's runtime-import allowlist lacked Children and descriptorChildren, and the universal runtime had no Children. Add Children.toArray/map to universal-core. They flatten transparent child groups, ranges, slots and arrays without rendering components, keep keys scoped to the collection, and leave structural owners opaque. Export descriptorChildren as a no-op marker, since universal children are already inspectable, and accept both imports in universal modules.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 3 potential issues.
Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.
Reviewed by Cursor Bugbot for commit 3c091d4. Configure here.
Benchmark report
Compares js-framework: 1k/10k row operationsAll 20 timed operations (20 without a verdict)
All 64 work counters are unchanged. Application bundle size (bytes)No changes across 93 measured values. Public-import reachability bundles (bytes)No changes across 123 measured values. Lynx dual-thread render (report only)All 13 timed operations (13 without a verdict)
Deterministic counters:
55 other measured values are unchanged. |
…en renderer Share the universal children collector as octane/internal/universal-children so @octanejs/lynx/main-renderer satisfies the compiler's runtime allowlist without duplicating the normalization logic.
…s positional JSON.stringify path encoding threw on bigint keys and collapsed distinct symbol keys; replace it with an injective per-segment encoder. An unkeyed single-child range no longer adopts its inner child's key, and Children.map returns nullish input unchanged. The Lynx first-screen test now maps real children through a wrapper.
@octanejs/lynx is private, so changesets ignores it and rejects a changeset that mixes it with octane. The main-thread source graph now includes octane/internal/universal-children; assert that it stays dependency-free.

Summary
A shared
.tsrxcomponent that enumerates its children could not compile for universal (native) renderers:Once
Childrenwas removed, the same error appeared fordescriptorChildren. There were two causes. The universal compiler only allows imports from a fixed list (UNIVERSAL_RUNTIME_IMPORTS), and that list had neither name. Anduniversal-corehad noChildrenimplementation at all.This PR adds both to the universal runtime:
Children.toArrayandChildren.mapinuniversal-core.mapgives each wrapper the key of the child it wraps, so host identity survives a reorder.descriptorChildren, exported as a no-op marker. Universal children can already be inspected throughChildren, so the marker does nothing there. This lets one shared file mark a component withdescriptorChildren(Impl)for the DOM target and still compile for universal targets.__runtimeImportRoutes.@octanejs/lynx/main-renderer, Lynx's one-shot first-screen runtime, implements its own copy of the universal value protocol and must export every name the compiler can import. CI'scompiled-runtime-linktest caught that it lacked both names. Rather than duplicate the collector, it lives insrc/universal-children.tsascreateUniversalChildren(runtime).universal-coreand the Lynx main renderer each pass in their ownuniversalKey/universalPlan/universalValue/props normalizer and renderer check. Lynx imports it through a newoctane/internal/universal-childrenentry.The behavior is ported from a patch that octane-xplat carries downstream, where it has been in use on its universal and native renderers. The downstream case is a shared demo that does
const List = descriptorChildren(ListImpl)and callsChildren.toArray(props.children). Before this change it compiled for web but not for NativeScript.Validation
pnpm format:check(I ranpnpm format:fileson the changed files only)pnpm typecheck:fileson the changed filespnpm test(not run in full)packages/octane/tests/universal-children.test.tspasses 14/14 across the octane and octane-prod projects. Each case failed before the fix.universal-renderer.test.ts, 272/272 pass..mapchildren keeping their keys and host identity across a reorder;Children.mapwrapper keys; an@ifscope staying opaque; null and boolean children being dropped; and rendering throughdescriptorChildren.Duplicate universal child key);Children.map(null | undefined)returns its input like DOMChildren.map.packages/lynx/tests/compiled-runtime-link.test.ts: the main renderer exports every compiler-importable name, and a wrapper thatChildren.maps real children renders the same first-screen batch on the main and background threads (3viewcreates).universal-children.test.ts+ this file: 29/29.pnpm sync: regenerateddocs/packages.mdfor the new internal entry.concise-code: the first commit added src +162 −0 (runtime +160 −0) touniversal-core; the Lynx commit moved that collector intosrc/universal-children.ts(one new src module plus a 5-lineinternal/re-export). The new exportsChildrenanddescriptorChildrenare called by user and compiled code. I considered pasting the downstream dist code and rejected it in favor of the existing internals (renderableKey,universalKey,universalPlan,normalizePropsValue). Bytes, measured on the first commit: theuniversalentry grew by 2,263 B raw / 697 B gzip (117,810 → 118,507 gzip). The DOM entries are unchanged. CI's bundle-size and benchmark checks report the current head.Risk / follow-ups
universalChildEntriesdepends on the current plan node kinds (range,slot,text,host,component). A new transparent node kind would need to be added there. Unknown structural nodes stay opaque, which is the safe default.Childrenonly does work when it is called, so render and reconcile hot paths are not touched.Provenance
agent-authored)Need help on this PR? Tag
@codesmith-botwith what you need.Note
Medium Risk
Touches universal child flattening and key encoding used at compile/runtime boundaries; mistakes could affect reconciliation identity or Lynx first-screen output, though behavior is opt-in via explicit Children calls.
Overview
Shared
.tsrxcomponents that useChildren.toArray/Children.mapordescriptorChildrencan now compile and run on universal and Lynx first-screen targets, which previously failed the universal compiler’s runtime import allowlist and had no runtime implementation.A new dependency-free
createUniversalChildrenmodule flattens transparent child groups (arrays, plan ranges, slots, child renderables) into keyed entries without mounting components, while scoped control flow and structural nodes stay opaque.descriptorChildrenis a universal no-op marker so the same component can be annotated for DOM.universal-coreand@octanejs/lynx/main-rendererwire upChildrenvia that factory; Lynx consumes it throughoctane/internal/universal-children. The universal compiler adds both names toUNIVERSAL_RUNTIME_IMPORTS, with docs and regression tests (including Lynx main/background parity forChildren.map).Reviewed by Cursor Bugbot for commit 99fe3d5. Bugbot is set up for automated code reviews on this repo. Configure here.