import * as __ctHelpers from "commontools"; import { Cell, derive, handler, NAME, pattern, str, UI } from "commontools"; const adder = handler(false as const satisfies __ctHelpers.JSONSchema, { type: "object", properties: { values: { type: "array", items: { type: "string" }, asCell: true } }, required: ["values"] } as const satisfies __ctHelpers.JSONSchema, (_, state: { values: Cell; }) => { state.values.push(Math.random().toString(36).substring(2, 15)); }); export default pattern(({ values }) => { derive({ type: "array", items: { type: "string" } } as const satisfies __ctHelpers.JSONSchema, true as const satisfies __ctHelpers.JSONSchema, values, (values) => { console.log("values#", values?.length); }); return { [NAME]: str `Simple Value: ${values.length || 0}`, [UI]: (
{values.mapWithPattern(__ctHelpers.recipe({ type: "object", properties: { element: { type: "string" }, index: { type: "number" }, params: { type: "object", properties: {} } }, required: ["element", "params"] } as const satisfies __ctHelpers.JSONSchema, { type: "object", properties: { type: { type: "string", "enum": ["vnode"] }, name: { type: "string" }, props: { $ref: "#/$defs/Props" }, children: { $ref: "#/$defs/RenderNode" }, $UI: { $ref: "#/$defs/VNode" } }, required: ["type", "name", "props"], $defs: { VNode: { type: "object", properties: { type: { type: "string", "enum": ["vnode"] }, name: { type: "string" }, props: { $ref: "#/$defs/Props" }, children: { $ref: "#/$defs/RenderNode" }, $UI: { $ref: "#/$defs/VNode" } }, required: ["type", "name", "props"] }, RenderNode: { anyOf: [{ type: "string" }, { type: "number" }, { type: "boolean", "enum": [false] }, { type: "boolean", "enum": [true] }, { $ref: "#/$defs/VNode" }, { type: "object", properties: {} }, { type: "array", items: { $ref: "#/$defs/RenderNode" } }] }, Props: { type: "object", properties: {}, additionalProperties: { anyOf: [{ type: "string" }, { type: "number" }, { type: "boolean", "enum": [false] }, { type: "boolean", "enum": [true] }, { type: "object", additionalProperties: true }, { type: "array", items: true }, { asCell: true }, { asStream: true }, { type: "null" }] } } } } as const satisfies __ctHelpers.JSONSchema, ({ element: value, index, params: {} }) => (
{index}: {value}
)), {})}
), values, }; }, { type: "object", properties: { values: { type: "array", items: { type: "string" } } }, required: ["values"] } as const satisfies __ctHelpers.JSONSchema, { type: "object", properties: { $NAME: { type: "string", asOpaque: true }, $UI: { $ref: "#/$defs/Element" }, values: { type: "array", items: { type: "string" }, asOpaque: true } }, required: ["$NAME", "$UI", "values"], $defs: { Element: { type: "object", properties: { type: { type: "string", "enum": ["vnode"] }, name: { type: "string" }, props: { $ref: "#/$defs/Props" }, children: { $ref: "#/$defs/RenderNode" }, $UI: { $ref: "#/$defs/VNode" } }, required: ["type", "name", "props"] }, VNode: { type: "object", properties: { type: { type: "string", "enum": ["vnode"] }, name: { type: "string" }, props: { $ref: "#/$defs/Props" }, children: { $ref: "#/$defs/RenderNode" }, $UI: { $ref: "#/$defs/VNode" } }, required: ["type", "name", "props"] }, RenderNode: { anyOf: [{ type: "string" }, { type: "number" }, { type: "boolean", "enum": [false] }, { type: "boolean", "enum": [true] }, { $ref: "#/$defs/VNode" }, { type: "object", properties: {} }, { type: "array", items: { $ref: "#/$defs/RenderNode" } }] }, Props: { type: "object", properties: {}, additionalProperties: { anyOf: [{ type: "string" }, { type: "number" }, { type: "boolean", "enum": [false] }, { type: "boolean", "enum": [true] }, { type: "object", additionalProperties: true }, { type: "array", items: true }, { asCell: true }, { asStream: true }, { type: "null" }] } } } } as const satisfies __ctHelpers.JSONSchema); // @ts-ignore: Internals function h(...args: any[]) { return __ctHelpers.h.apply(null, args); } // @ts-ignore: Internals h.fragment = __ctHelpers.h.fragment;