/** * TRANSFORM REPRO: helper-owned JSX IIFE drops captured reactive inputs * * Compare on main vs transformer branch: * deno task cf check packages/patterns/gideon-tests/test-helper-owned-jsx-iife-captures.tsx --show-transformed --no-run * * Expected main shape: * - the second helper-owned JSX closure captures `path`, `entries`, and * `pushPath` in its generated derive params * * Current branch bug: * - the branch rewrites the closure into a different shape that only derives * `path`, leaving `entries` and `pushPath` outside the generated param * bundle even though they are still used in the closure body */ import { action, Default, pattern, UI, VNode, Writable } from "commonfabric"; interface Entry { name: string; } interface Input { entries: Writable>; } export interface Output { [UI]: VNode; } function visibleEntries( entries: Writable>, prefix: string, ): Entry[] { const list = entries.get(); return list.filter((entry) => prefix.length === 0 || entry.name.startsWith(prefix) ); } export default pattern(({ entries }) => { const path = new Writable([]); const pushPath = action(({ name }: { name: string }) => { path.push(name); }); return { [UI]: (
{(() => { const p = path.get() || []; if (p.length === 0) return null; return
{p[p.length - 1]}
; })()} {(() => { const p = path.get() || []; const visible = visibleEntries(entries, p[0] || ""); return visible.map((entry) => ( )); })()}
), }; });