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";
import { pattern, UI } from "commonfabric";
const define = undefined;
const runtimeDeps = undefined;
const __cfAmdHooks = undefined;
interface Item {
id: number;
tags: string[];
}
interface State {
items: Item[];
}
const __cfPattern_1 = __cfHelpers.pattern(__cf_pattern_input => {
const item = __cf_pattern_input.key("element");
return (
Item #{item.key("id")}
);
}, {
type: "object",
properties: {
element: {
$ref: "#/$defs/Item"
}
},
required: ["element"],
$defs: {
Item: {
type: "object",
properties: {
id: {
type: "number"
},
tags: {
type: "array",
items: {
type: "string"
}
}
},
required: ["id", "tags"]
}
}
} 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);
// FIXTURE: flatmap-basic
// Verifies: .flatMap() on a reactive array is transformed
// .flatMap(fn) → .flatMapWithPattern(pattern(...), {})
// Context: flatMap renders each item as JSX. No captured outer variables.
export default pattern((state) => {
return {
[UI]: (
{state.key("items").flatMapWithPattern(__cfPattern_1, {})}
),
};
}, {
type: "object",
properties: {
items: {
type: "array",
items: {
$ref: "#/$defs/Item"
}
}
},
required: ["items"],
$defs: {
Item: {
type: "object",
properties: {
id: {
type: "number"
},
tags: {
type: "array",
items: {
type: "string"
}
}
},
required: ["id", "tags"]
}
}
} as const satisfies __cfHelpers.JSONSchema, {
type: "object",
properties: {
$UI: {
$ref: "#/$defs/JSXElement"
}
},
required: ["$UI"],
$defs: {
JSXElement: {
anyOf: [{
$ref: "https://commonfabric.org/schemas/vnode.json"
}, {
$ref: "#/$defs/UIRenderable"
}, {
type: "object",
properties: {}
}]
},
UIRenderable: {
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({
__cfPattern_1
});