function __cfHardenFn(fn: Function) { Object.freeze(fn); const prototype = fn.prototype; if (prototype && typeof prototype === "object") { Object.freeze(prototype); } return fn; } import { __cfHelpers } from "commonfabric"; /** * TRANSFORM REPRO: helper-owned JSX IIFE final map callback captures reactive state * * The decomposed helper-owned IIFE path currently leaves the final `visible.map(...)` * as a plain map call. That is only safe when the callback depends only on the mapped * element. If it captures outer reactive state, it must lower through mapWithPattern. */ import { Default, pattern, UI, VNode, Writable, } from "commonfabric"; const define = undefined; const runtimeDeps = undefined; const __cfAmdHooks = undefined; interface Entry { name: string; } interface Input { entries: Writable>; } 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)); } __cfHardenFn(visibleEntries); const __cfLift_1 = __cfHelpers.lift<{ path: __cfHelpers.Cell; }, readonly string[]>(({ path }) => path.get(), { type: "object", properties: { path: { type: "array", items: { type: "string" }, asCell: ["readonly"] } }, required: ["path"] } as const satisfies __cfHelpers.JSONSchema, { type: "array", items: { type: "string" } } as const satisfies __cfHelpers.JSONSchema); const __cfLift_2 = __cfHelpers.lift<{ entries: Writable>; p: readonly string[]; }, Entry[]>(({ entries, p }) => visibleEntries(entries, p[0] || ""), { type: "object", properties: { entries: { type: "array", items: { $ref: "#/$defs/Entry" }, "default": [], asCell: ["readonly"] }, p: { type: "array", items: { type: "string" } } }, required: ["entries", "p"], $defs: { Entry: { type: "object", properties: { name: { type: "string" } }, required: ["name"] } } } as const satisfies __cfHelpers.JSONSchema, { type: "array", items: { $ref: "#/$defs/Entry" }, $defs: { Entry: { type: "object", properties: { name: { type: "string" } }, required: ["name"] } } } as const satisfies __cfHelpers.JSONSchema); const __cfPattern_1 = __cfHelpers.pattern(__cf_pattern_input => { const entry = __cf_pattern_input.key("element"); const labelPrefix = __cf_pattern_input.key("params", "labelPrefix"); return (); }, { type: "object", properties: { element: { $ref: "#/$defs/Entry" }, params: { type: "object", properties: { labelPrefix: { type: "string", asCell: ["readonly"] } }, required: ["labelPrefix"] } }, required: ["element", "params"], $defs: { Entry: { type: "object", properties: { name: { type: "string" } }, required: ["name"] } } } as const satisfies __cfHelpers.JSONSchema, { anyOf: [{ $ref: "https://commonfabric.org/schemas/vnode.json" }, { $ref: "#/$defs/UIRenderable" }, { type: "object", properties: {} }], $defs: { UIRenderable: { type: "object", properties: { $UI: { $ref: "https://commonfabric.org/schemas/vnode.json" } }, required: ["$UI"] } } } as const satisfies __cfHelpers.JSONSchema); export default pattern((__cf_pattern_input) => { const entries = __cf_pattern_input.key("entries"); const path = new Writable([], { type: "array", items: { type: "string" } } as const satisfies __cfHelpers.JSONSchema).for("path", true); const labelPrefix = new Writable("prefix:", { type: "string" } as const satisfies __cfHelpers.JSONSchema).for("labelPrefix", true); return { [UI]: (
{(() => { const p = __cfHelpers.unless({ type: "array", items: { type: "string" } } as const satisfies __cfHelpers.JSONSchema, { type: "array", items: false } as const satisfies __cfHelpers.JSONSchema, { type: "array", items: { type: "string" } } as const satisfies __cfHelpers.JSONSchema, __cfLift_1({ path: path }).for(["p", 3], true), []).for("p", true); const visible = __cfLift_2({ entries: entries, p: p }).for("visible", true); return visible.mapWithPattern(__cfPattern_1, { labelPrefix: labelPrefix }); })()}
) }; }, { type: "object", properties: { entries: { type: "array", items: { $ref: "#/$defs/Entry" }, "default": [], asCell: ["cell"] } }, required: ["entries"], $defs: { Entry: { type: "object", properties: { name: { type: "string" } }, required: ["name"] } } } as const satisfies __cfHelpers.JSONSchema, { type: "object", properties: { $UI: { $ref: "https://commonfabric.org/schemas/vnode.json" } }, required: ["$UI"] } as const satisfies __cfHelpers.JSONSchema); // @ts-ignore: Internals function h(...args: any[]) { return __cfHelpers.h.apply(null, args); } __cfHardenFn(h); __cfReg({ __cfLift_1, __cfLift_2, __cfPattern_1 });