gesso-framework 0.6.16 → 0.6.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -86,6 +86,12 @@ declare namespace JSX {
86
86
  * signature. That looks like a functional component, so the check
87
87
  * is on the parameter: only a record of input cells is one. Anything
88
88
  * else keeps `P`, the attributes TypeScript already found.
89
+ *
90
+ * A generic component's type argument written in the tag
91
+ * (`<MenuBar<Command> />`) does not reach here: TypeScript passes the
92
+ * uninstantiated component, so its parameter is `unknown`. Name the
93
+ * instantiation first (`const CommandBar = MenuBar<Command>`) and use
94
+ * that tag.
89
95
  */
90
96
  type LibraryManagedAttributes<C, P> = C extends ClassComponent ? ComponentProps<C> : C extends ((props: infer I, ...rest: any[]) => UiChild) ? unknown extends I ? ComponentProps<C> : I extends Record<string, InputCell<any>> ? ComponentProps<C> : P : P;
91
97
  }
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-runtime.js","names":[],"sources":["../../src/jsx/jsx-runtime.ts"],"sourcesContent":["import type { Observable } from 'rxjs';\n\nimport {\n type BoxProps,\n type ButtonProps,\n type ColumnProps,\n type EditableTextProps,\n type GridProps,\n type PaintElementProps,\n type RowProps,\n type ScrollViewProps,\n type StackProps,\n type TextProps,\n type ComponentLikeElement,\n type UiChild,\n type UiElement,\n type UiProps,\n Box,\n Button,\n Column,\n EditableText,\n Grid,\n Paint,\n Row,\n ScrollView,\n Stack,\n Text,\n UiNodeType\n} from 'gesso-core';\nimport type { Component } from '../Component';\nimport type { InputCell } from '../Input';\nimport { createComponent } from '../createComponent';\nimport { Each } from '../each';\nimport { Show } from '../show';\nimport type { ClassComponent, ComponentContext, ComponentProps, ComponentType } from '../FunctionComponent';\n\n/**\n * The JSX runtime: `<row gap={8}>…</row>` compiles to\n * `jsx('row', { gap: 8, children: … })`, which calls `createElement`;\n * `<Counter label=\"x\" />` calls `createComponent`. There is no virtual\n * DOM and nothing is diffed here — the output is the same UiElement /\n * ComponentElement the factory API produces, so JSX costs nothing at\n * runtime and the two surfaces can be mixed freely.\n *\n * Enabled per project with\n *\n * \"jsx\": \"react-jsx\", \"jsxImportSource\": \"gesso\"\n *\n * in tsconfig (the repository maps `gesso/jsx-runtime` to this file).\n *\n * Intrinsic tags are the element factories in lowercase: `text`,\n * `editabletext`, `button`, `box`, `stack`, `row`, `column`,\n * `scrollview`, `grid`, `paint`.\n * A `text` or `button` with a string (or Observable string) child\n * takes it as its `text` prop. A `paint` is a box the application\n * draws into, through its `paint` or `path` prop; its children stack\n * over the picture. See `rendering/PaintSurface.ts`.\n */\n\n/** What may appear between tags: children, or nothing (for conditionals). */\nexport type JsxChild = UiChild | string | number | boolean | null | undefined;\nexport type JsxChildren = JsxChild | readonly JsxChildren[];\n\ntype WithChildren<P, C = JsxChildren> = P & { children?: C };\n\n/** A text child: a string, or an Observable of one. */\ntype TextChildren = string | number | Observable<string | number>;\n\nconst INTRINSIC_TYPES = {\n text: UiNodeType.Text,\n editabletext: UiNodeType.EditableText,\n button: UiNodeType.Button,\n box: UiNodeType.Box,\n stack: UiNodeType.Box,\n row: UiNodeType.Row,\n column: UiNodeType.Column,\n scrollview: UiNodeType.ScrollView,\n grid: UiNodeType.Grid,\n paint: UiNodeType.Paint\n} as const satisfies Record<string, UiNodeType>;\n\nexport type IntrinsicTag = keyof typeof INTRINSIC_TYPES;\n\nexport namespace JSX {\n export type Element = UiElement | ComponentLikeElement;\n\n /** Anything a tag may name. */\n export type ElementType = IntrinsicTag | ComponentType;\n\n /** A class usable as a tag; `Component` satisfies it. */\n export interface ElementClass {\n render(): UiChild;\n }\n\n /** `key` is accepted on every tag and is never a prop. */\n export interface IntrinsicAttributes {\n key?: string | number;\n }\n\n export interface ElementChildrenAttribute {\n children: {};\n }\n\n export interface IntrinsicElements {\n text: WithChildren<TextProps, TextChildren>;\n /** Editable text; takes no children — its text is `value`. */\n editabletext: EditableTextProps & { children?: never };\n button: WithChildren<ButtonProps, JsxChildren | TextChildren>;\n box: WithChildren<BoxProps>;\n stack: WithChildren<StackProps>;\n row: WithChildren<RowProps>;\n column: WithChildren<ColumnProps>;\n scrollview: WithChildren<ScrollViewProps>;\n grid: WithChildren<GridProps>;\n /** A box the application draws into; see `PaintSurface`. */\n paint: WithChildren<PaintElementProps>;\n }\n\n /**\n * The attributes a component tag takes: computed from the component\n * itself — a class's `input()` fields or a function's `Inputs<P>`\n * parameter — exactly as `createComponent` types them.\n *\n * TypeScript consults this for intrinsic tags too, handing them in\n * as a synthetic `(props: IntrinsicElements[tag]) => Element`\n * signature. That looks like a functional component, so the check\n * is on the parameter: only a record of input cells is one. Anything\n * else keeps `P`, the attributes TypeScript already found.\n */\n export type LibraryManagedAttributes<C, P> = C extends ClassComponent\n ? ComponentProps<C>\n : C extends (props: infer I, ...rest: any[]) => UiChild\n ? unknown extends I\n ? ComponentProps<C>\n : I extends Record<string, InputCell<any>>\n ? ComponentProps<C>\n : P\n : P;\n}\n\ntype JsxProps = Record<string, unknown> & { children?: JsxChildren };\n\n/**\n * Creates one element. `key` arrives separately, as the compiler\n * passes it; `children` arrives inside props.\n */\nexport function jsx(type: JSX.ElementType, props: JsxProps | null, key?: string | number): JSX.Element {\n const { children, ...rest } = props ?? {};\n if (typeof type === 'string') {\n return intrinsic(type, rest, children, key);\n }\n if (typeof type !== 'function') {\n throw new Error(`JSX tag must be an intrinsic name or a component, got ${describe(type)}.`);\n }\n if (type === (Each as unknown as JSX.ElementType) || type === (Show as unknown as JSX.ElementType)) {\n // The two structural tags. Neither mounts a component: each one\n // returns the observable list of children its parent binds, so\n // `<Show>` really does add no node and `<Each>` adds no anchor\n // beyond the one an observable child already has. They take a\n // function as their child, which is the other reason they cannot\n // go through `componentProps` below.\n return (type as unknown as (props: JsxProps) => JSX.Element)({ ...props });\n }\n return createComponent(\n type as ClassComponent,\n componentProps(type, rest, children) as ComponentProps<ClassComponent>,\n key\n );\n}\n\n/**\n * A component's props, with any JSX children folded in as `children`.\n *\n * This used to throw: components took inputs, not children, and the\n * message said to pass them as a prop instead. The advice did not\n * work. `<Card children={x} />` and `<Card>{x}</Card>` compile to the\n * same `jsx(Card, { children: x })`, so the runtime cannot tell them\n * apart and rejected both, which left every component in the library\n * that takes its content as `children` (`Card`, `Tabs`, `Toolbar`,\n * `Accordion`) unusable as a JSX tag. Since the documentation and the\n * examples are JSX, that is most of the component library.\n *\n * It is also inconsistent: no other prop is checked here. A misspelled\n * or wrongly typed prop is a compile error, and `children` already is\n * one too, because `JSX.ElementChildrenAttribute` maps nested children\n * onto the `children` prop and `LibraryManagedAttributes` types it\n * from the component. A component that does not declare `children`\n * therefore cannot be given any.\n *\n * The one rule left is arity. A component's `children` is a `UiChild`,\n * which is one child and not a list, so several children have to be\n * wrapped in a container tag. That is said here rather than left to\n * become a confusing type error at the call site.\n */\nfunction componentProps(\n type: JSX.ElementType,\n props: Record<string, unknown>,\n children: JsxChildren\n): Record<string, unknown> {\n if (children === undefined) {\n return props;\n }\n const list = flattenChildren(children);\n if (list.length === 0) {\n return props;\n }\n if (list.length > 1) {\n throw new Error(\n `Component '${componentName(type)}' was given ${list.length} children. ` +\n `A component takes one child, so wrap them in a container tag: <${componentName(type)}><column>…</column></${componentName(type)}>.`\n );\n }\n return { ...props, children: list[0] };\n}\n\nfunction componentName(type: JSX.ElementType): string {\n return typeof type === 'function' ? ((type as { name?: string }).name ?? 'anonymous') : String(type);\n}\n\n/** The compiler's variant for static child lists; identical here. */\nexport const jsxs = jsx;\n\n/**\n * Development-mode entry (`jsxDEV`), used by Vite in dev. The extra\n * arguments describe the source location and are not needed.\n */\nexport function jsxDEV(type: JSX.ElementType, props: JsxProps | null, key?: string | number): JSX.Element {\n return jsx(type, props, key);\n}\n\n/**\n * `<>…</>` has no node to become. Children of a fragment are spliced\n * into the parent, so it can only be used where a list of children is\n * accepted — which is every container tag.\n */\nexport function Fragment(_props: { children?: JsxChildren }): never {\n throw new Error('JSX fragments are not supported: return a list of elements, or wrap them in a container tag.');\n}\n\n/**\n * The element factories, by tag.\n *\n * JSX calls these rather than `createElement`, so an intrinsic tag and\n * the factory of the same name are the same code path and cannot\n * diverge. They already had: `Button()` injects `BUTTON_INTERACTION`,\n * so every button made with the factory shows hover and press, and a\n * `<button>` made here went straight to `createElement` and showed\n * neither. Nothing caught it, because nothing reads `visualState` yet.\n */\nconst INTRINSIC_FACTORIES = {\n text: Text,\n editabletext: EditableText,\n button: Button,\n box: Box,\n stack: Stack,\n row: Row,\n column: Column,\n scrollview: ScrollView,\n grid: Grid,\n paint: Paint\n} as const satisfies Record<IntrinsicTag, unknown>;\n\n/** Every factory, seen as the one shape this file calls them with. */\ntype ElementFactory = (props: UiProps, ...children: UiChild[]) => UiElement;\n\nfunction intrinsic(\n tag: string,\n props: Record<string, unknown>,\n children: JsxChildren,\n key?: string | number\n): UiElement {\n const type = (INTRINSIC_TYPES as Record<string, UiNodeType | undefined>)[tag];\n const factory = (INTRINSIC_FACTORIES as Record<string, ElementFactory | undefined>)[tag];\n if (type === undefined || factory === undefined) {\n throw new Error(\n `Unknown JSX tag '${tag}'. Intrinsic tags are ${Object.keys(INTRINSIC_TYPES)\n .map(name => `'${name}'`)\n .join(', ')}.`\n );\n }\n const elementProps: UiProps = key !== undefined ? { ...props, key } : props;\n if ((type === UiNodeType.Text || type === UiNodeType.Button) && isTextChild(children)) {\n if (elementProps.text !== undefined) {\n throw new Error(`<${tag}> has both a text prop and a text child; use one.`);\n }\n return factory({ ...elementProps, text: typeof children === 'number' ? String(children) : children });\n }\n return factory(elementProps, ...flattenChildren(children));\n}\n\n/**\n * Inside <text> and <button> a single string, number or Observable\n * child is the label. An Observable cannot be told apart from an\n * observable child list at runtime, so the rule is by tag: these two\n * take it as text, and a button whose children are observable elements\n * wraps them in a container tag.\n */\nfunction isTextChild(value: JsxChildren | TextChildren): value is TextChildren {\n return typeof value === 'string' || typeof value === 'number' || isObservableValue(value);\n}\n\nfunction isObservableValue(value: unknown): value is Observable<unknown> {\n return typeof value === 'object' && value !== null && typeof (value as Observable<unknown>).subscribe === 'function';\n}\n\n/**\n * Nested arrays are flattened and `null`, `undefined` and booleans are\n * dropped, so `{cond && <text/>}` and `{items.map(…)}` both work.\n */\nfunction flattenChildren(children: JsxChildren, out: UiChild[] = []): UiChild[] {\n if (children === null || children === undefined || typeof children === 'boolean') {\n return out;\n }\n if (Array.isArray(children)) {\n for (const child of children as readonly JsxChildren[]) {\n flattenChildren(child, out);\n }\n return out;\n }\n if (typeof children === 'string' || typeof children === 'number') {\n throw new Error(\n `A bare string child ('${String(children)}') is only allowed inside <text> or <button>. Wrap it: <text>{…}</text>.`\n );\n }\n out.push(children as UiChild);\n return out;\n}\n\nfunction describe(value: unknown): string {\n return value === null ? 'null' : typeof value === 'object' ? 'an object' : `a ${typeof value}`;\n}\n\nexport type { Component, ComponentContext };\n"],"mappings":";;;AAoEA,MAAM,kBAAkB;CACtB,MAAM,WAAW;CACjB,cAAc,WAAW;CACzB,QAAQ,WAAW;CACnB,KAAK,WAAW;CAChB,OAAO,WAAW;CAClB,KAAK,WAAW;CAChB,QAAQ,WAAW;CACnB,YAAY,WAAW;CACvB,MAAM,WAAW;CACjB,OAAO,WAAW;AACpB;;;;;AAmEA,SAAgB,IAAI,MAAuB,OAAwB,KAAoC;CACrG,MAAM,EAAE,UAAU,GAAG,SAAS,SAAS,CAAC;CACxC,IAAI,OAAO,SAAS,UAClB,OAAO,UAAU,MAAM,MAAM,UAAU,GAAG;CAE5C,IAAI,OAAO,SAAS,YAClB,MAAM,IAAI,MAAM,yDAAyD,SAAS,IAAI,EAAE,EAAE;CAE5F,IAAI,SAAU,QAAuC,SAAU,MAO7D,OAAQ,KAAqD,EAAE,GAAG,MAAM,CAAC;CAE3E,OAAO,gBACL,MACA,eAAe,MAAM,MAAM,QAAQ,GACnC,GACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAS,eACP,MACA,OACA,UACyB;CACzB,IAAI,aAAa,KAAA,GACf,OAAO;CAET,MAAM,OAAO,gBAAgB,QAAQ;CACrC,I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C;CACtG;CACA,OAAO,QAAQ,cAAc,GAAG,gBAAgB,QAAQ,CAAC;AAC3D;;;;;;;;AASA,SAAS,YAAY,OAA0D;CAC7E,OAAO,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,kBAAkB,KAAK;AAC1F;AAEA,SAAS,kBAAkB,OAA8C;CACvE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,OAAQ,MAA8B,cAAc;AAC5G;;;;;AAMA,SAAS,gBAAgB,UAAuB,MAAiB,CAAC,GAAc;CAC9E,IAAI,aAAa,QAAQ,aAAa,KAAA,KAAa,OAAO,aAAa,WACrE,OAAO;CAET,IAAI,MAAM,QAAQ,QAAQ,GAAG;EAC3B,KAAK,MAAM,SAAS,UAClB,gBAAgB,OAAO,GAAG;EAE5B,OAAO;CACT;CACA,IAAI,OAAO,aAAa,YAAY,OAAO,aAAa,UACtD,MAAM,IAAI,MACR,yBAAyB,OAAO,QAAQ,EAAE,yEAC5C;CAEF,IAAI,KAAK,QAAmB;CAC5B,OAAO;AACT;AAEA,SAAS,SAAS,OAAwB;CACxC,OAAO,UAAU,OAAO,SAAS,OAAO,UAAU,WAAW,cAAc,KAAK,OAAO;AACzF"}
1
+ {"version":3,"file":"jsx-runtime.js","names":[],"sources":["../../src/jsx/jsx-runtime.ts"],"sourcesContent":["import type { Observable } from 'rxjs';\n\nimport {\n type BoxProps,\n type ButtonProps,\n type ColumnProps,\n type EditableTextProps,\n type GridProps,\n type PaintElementProps,\n type RowProps,\n type ScrollViewProps,\n type StackProps,\n type TextProps,\n type ComponentLikeElement,\n type UiChild,\n type UiElement,\n type UiProps,\n Box,\n Button,\n Column,\n EditableText,\n Grid,\n Paint,\n Row,\n ScrollView,\n Stack,\n Text,\n UiNodeType\n} from 'gesso-core';\nimport type { Component } from '../Component';\nimport type { InputCell } from '../Input';\nimport { createComponent } from '../createComponent';\nimport { Each } from '../each';\nimport { Show } from '../show';\nimport type { ClassComponent, ComponentContext, ComponentProps, ComponentType } from '../FunctionComponent';\n\n/**\n * The JSX runtime: `<row gap={8}>…</row>` compiles to\n * `jsx('row', { gap: 8, children: … })`, which calls `createElement`;\n * `<Counter label=\"x\" />` calls `createComponent`. There is no virtual\n * DOM and nothing is diffed here — the output is the same UiElement /\n * ComponentElement the factory API produces, so JSX costs nothing at\n * runtime and the two surfaces can be mixed freely.\n *\n * Enabled per project with\n *\n * \"jsx\": \"react-jsx\", \"jsxImportSource\": \"gesso\"\n *\n * in tsconfig (the repository maps `gesso/jsx-runtime` to this file).\n *\n * Intrinsic tags are the element factories in lowercase: `text`,\n * `editabletext`, `button`, `box`, `stack`, `row`, `column`,\n * `scrollview`, `grid`, `paint`.\n * A `text` or `button` with a string (or Observable string) child\n * takes it as its `text` prop. A `paint` is a box the application\n * draws into, through its `paint` or `path` prop; its children stack\n * over the picture. See `rendering/PaintSurface.ts`.\n */\n\n/** What may appear between tags: children, or nothing (for conditionals). */\nexport type JsxChild = UiChild | string | number | boolean | null | undefined;\nexport type JsxChildren = JsxChild | readonly JsxChildren[];\n\ntype WithChildren<P, C = JsxChildren> = P & { children?: C };\n\n/** A text child: a string, or an Observable of one. */\ntype TextChildren = string | number | Observable<string | number>;\n\nconst INTRINSIC_TYPES = {\n text: UiNodeType.Text,\n editabletext: UiNodeType.EditableText,\n button: UiNodeType.Button,\n box: UiNodeType.Box,\n stack: UiNodeType.Box,\n row: UiNodeType.Row,\n column: UiNodeType.Column,\n scrollview: UiNodeType.ScrollView,\n grid: UiNodeType.Grid,\n paint: UiNodeType.Paint\n} as const satisfies Record<string, UiNodeType>;\n\nexport type IntrinsicTag = keyof typeof INTRINSIC_TYPES;\n\nexport namespace JSX {\n export type Element = UiElement | ComponentLikeElement;\n\n /** Anything a tag may name. */\n export type ElementType = IntrinsicTag | ComponentType;\n\n /** A class usable as a tag; `Component` satisfies it. */\n export interface ElementClass {\n render(): UiChild;\n }\n\n /** `key` is accepted on every tag and is never a prop. */\n export interface IntrinsicAttributes {\n key?: string | number;\n }\n\n export interface ElementChildrenAttribute {\n children: {};\n }\n\n export interface IntrinsicElements {\n text: WithChildren<TextProps, TextChildren>;\n /** Editable text; takes no children — its text is `value`. */\n editabletext: EditableTextProps & { children?: never };\n button: WithChildren<ButtonProps, JsxChildren | TextChildren>;\n box: WithChildren<BoxProps>;\n stack: WithChildren<StackProps>;\n row: WithChildren<RowProps>;\n column: WithChildren<ColumnProps>;\n scrollview: WithChildren<ScrollViewProps>;\n grid: WithChildren<GridProps>;\n /** A box the application draws into; see `PaintSurface`. */\n paint: WithChildren<PaintElementProps>;\n }\n\n /**\n * The attributes a component tag takes: computed from the component\n * itself — a class's `input()` fields or a function's `Inputs<P>`\n * parameter — exactly as `createComponent` types them.\n *\n * TypeScript consults this for intrinsic tags too, handing them in\n * as a synthetic `(props: IntrinsicElements[tag]) => Element`\n * signature. That looks like a functional component, so the check\n * is on the parameter: only a record of input cells is one. Anything\n * else keeps `P`, the attributes TypeScript already found.\n *\n * A generic component's type argument written in the tag\n * (`<MenuBar<Command> />`) does not reach here: TypeScript passes the\n * uninstantiated component, so its parameter is `unknown`. Name the\n * instantiation first (`const CommandBar = MenuBar<Command>`) and use\n * that tag.\n */\n export type LibraryManagedAttributes<C, P> = C extends ClassComponent\n ? ComponentProps<C>\n : C extends (props: infer I, ...rest: any[]) => UiChild\n ? unknown extends I\n ? ComponentProps<C>\n : I extends Record<string, InputCell<any>>\n ? ComponentProps<C>\n : P\n : P;\n}\n\ntype JsxProps = Record<string, unknown> & { children?: JsxChildren };\n\n/**\n * Creates one element. `key` arrives separately, as the compiler\n * passes it; `children` arrives inside props.\n */\nexport function jsx(type: JSX.ElementType, props: JsxProps | null, key?: string | number): JSX.Element {\n const { children, ...rest } = props ?? {};\n if (typeof type === 'string') {\n return intrinsic(type, rest, children, key);\n }\n if (typeof type !== 'function') {\n throw new Error(`JSX tag must be an intrinsic name or a component, got ${describe(type)}.`);\n }\n if (type === (Each as unknown as JSX.ElementType) || type === (Show as unknown as JSX.ElementType)) {\n // The two structural tags. Neither mounts a component: each one\n // returns the observable list of children its parent binds, so\n // `<Show>` really does add no node and `<Each>` adds no anchor\n // beyond the one an observable child already has. They take a\n // function as their child, which is the other reason they cannot\n // go through `componentProps` below.\n return (type as unknown as (props: JsxProps) => JSX.Element)({ ...props });\n }\n return createComponent(\n type as ClassComponent,\n componentProps(type, rest, children) as ComponentProps<ClassComponent>,\n key\n );\n}\n\n/**\n * A component's props, with any JSX children folded in as `children`.\n *\n * This used to throw: components took inputs, not children, and the\n * message said to pass them as a prop instead. The advice did not\n * work. `<Card children={x} />` and `<Card>{x}</Card>` compile to the\n * same `jsx(Card, { children: x })`, so the runtime cannot tell them\n * apart and rejected both, which left every component in the library\n * that takes its content as `children` (`Card`, `Tabs`, `Toolbar`,\n * `Accordion`) unusable as a JSX tag. Since the documentation and the\n * examples are JSX, that is most of the component library.\n *\n * It is also inconsistent: no other prop is checked here. A misspelled\n * or wrongly typed prop is a compile error, and `children` already is\n * one too, because `JSX.ElementChildrenAttribute` maps nested children\n * onto the `children` prop and `LibraryManagedAttributes` types it\n * from the component. A component that does not declare `children`\n * therefore cannot be given any.\n *\n * The one rule left is arity. A component's `children` is a `UiChild`,\n * which is one child and not a list, so several children have to be\n * wrapped in a container tag. That is said here rather than left to\n * become a confusing type error at the call site.\n */\nfunction componentProps(\n type: JSX.ElementType,\n props: Record<string, unknown>,\n children: JsxChildren\n): Record<string, unknown> {\n if (children === undefined) {\n return props;\n }\n const list = flattenChildren(children);\n if (list.length === 0) {\n return props;\n }\n if (list.length > 1) {\n throw new Error(\n `Component '${componentName(type)}' was given ${list.length} children. ` +\n `A component takes one child, so wrap them in a container tag: <${componentName(type)}><column>…</column></${componentName(type)}>.`\n );\n }\n return { ...props, children: list[0] };\n}\n\nfunction componentName(type: JSX.ElementType): string {\n return typeof type === 'function' ? ((type as { name?: string }).name ?? 'anonymous') : String(type);\n}\n\n/** The compiler's variant for static child lists; identical here. */\nexport const jsxs = jsx;\n\n/**\n * Development-mode entry (`jsxDEV`), used by Vite in dev. The extra\n * arguments describe the source location and are not needed.\n */\nexport function jsxDEV(type: JSX.ElementType, props: JsxProps | null, key?: string | number): JSX.Element {\n return jsx(type, props, key);\n}\n\n/**\n * `<>…</>` has no node to become. Children of a fragment are spliced\n * into the parent, so it can only be used where a list of children is\n * accepted — which is every container tag.\n */\nexport function Fragment(_props: { children?: JsxChildren }): never {\n throw new Error('JSX fragments are not supported: return a list of elements, or wrap them in a container tag.');\n}\n\n/**\n * The element factories, by tag.\n *\n * JSX calls these rather than `createElement`, so an intrinsic tag and\n * the factory of the same name are the same code path and cannot\n * diverge. They already had: `Button()` injects `BUTTON_INTERACTION`,\n * so every button made with the factory shows hover and press, and a\n * `<button>` made here went straight to `createElement` and showed\n * neither. Nothing caught it, because nothing reads `visualState` yet.\n */\nconst INTRINSIC_FACTORIES = {\n text: Text,\n editabletext: EditableText,\n button: Button,\n box: Box,\n stack: Stack,\n row: Row,\n column: Column,\n scrollview: ScrollView,\n grid: Grid,\n paint: Paint\n} as const satisfies Record<IntrinsicTag, unknown>;\n\n/** Every factory, seen as the one shape this file calls them with. */\ntype ElementFactory = (props: UiProps, ...children: UiChild[]) => UiElement;\n\nfunction intrinsic(\n tag: string,\n props: Record<string, unknown>,\n children: JsxChildren,\n key?: string | number\n): UiElement {\n const type = (INTRINSIC_TYPES as Record<string, UiNodeType | undefined>)[tag];\n const factory = (INTRINSIC_FACTORIES as Record<string, ElementFactory | undefined>)[tag];\n if (type === undefined || factory === undefined) {\n throw new Error(\n `Unknown JSX tag '${tag}'. Intrinsic tags are ${Object.keys(INTRINSIC_TYPES)\n .map(name => `'${name}'`)\n .join(', ')}.`\n );\n }\n const elementProps: UiProps = key !== undefined ? { ...props, key } : props;\n if ((type === UiNodeType.Text || type === UiNodeType.Button) && isTextChild(children)) {\n if (elementProps.text !== undefined) {\n throw new Error(`<${tag}> has both a text prop and a text child; use one.`);\n }\n return factory({ ...elementProps, text: typeof children === 'number' ? String(children) : children });\n }\n return factory(elementProps, ...flattenChildren(children));\n}\n\n/**\n * Inside <text> and <button> a single string, number or Observable\n * child is the label. An Observable cannot be told apart from an\n * observable child list at runtime, so the rule is by tag: these two\n * take it as text, and a button whose children are observable elements\n * wraps them in a container tag.\n */\nfunction isTextChild(value: JsxChildren | TextChildren): value is TextChildren {\n return typeof value === 'string' || typeof value === 'number' || isObservableValue(value);\n}\n\nfunction isObservableValue(value: unknown): value is Observable<unknown> {\n return typeof value === 'object' && value !== null && typeof (value as Observable<unknown>).subscribe === 'function';\n}\n\n/**\n * Nested arrays are flattened and `null`, `undefined` and booleans are\n * dropped, so `{cond && <text/>}` and `{items.map(…)}` both work.\n */\nfunction flattenChildren(children: JsxChildren, out: UiChild[] = []): UiChild[] {\n if (children === null || children === undefined || typeof children === 'boolean') {\n return out;\n }\n if (Array.isArray(children)) {\n for (const child of children as readonly JsxChildren[]) {\n flattenChildren(child, out);\n }\n return out;\n }\n if (typeof children === 'string' || typeof children === 'number') {\n throw new Error(\n `A bare string child ('${String(children)}') is only allowed inside <text> or <button>. Wrap it: <text>{…}</text>.`\n );\n }\n out.push(children as UiChild);\n return out;\n}\n\nfunction describe(value: unknown): string {\n return value === null ? 'null' : typeof value === 'object' ? 'an object' : `a ${typeof value}`;\n}\n\nexport type { Component, ComponentContext };\n"],"mappings":";;;AAoEA,MAAM,kBAAkB;CACtB,MAAM,WAAW;CACjB,cAAc,WAAW;CACzB,QAAQ,WAAW;CACnB,KAAK,WAAW;CAChB,OAAO,WAAW;CAClB,KAAK,WAAW;CAChB,QAAQ,WAAW;CACnB,YAAY,WAAW;CACvB,MAAM,WAAW;CACjB,OAAO,WAAW;AACpB;;;;;AAyEA,SAAgB,IAAI,MAAuB,OAAwB,KAAoC;CACrG,MAAM,EAAE,UAAU,GAAG,SAAS,SAAS,CAAC;CACxC,IAAI,OAAO,SAAS,UAClB,OAAO,UAAU,MAAM,MAAM,UAAU,GAAG;CAE5C,IAAI,OAAO,SAAS,YAClB,MAAM,IAAI,MAAM,yDA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EAChB;CAEF,MAAM,eAAwB,QAAQ,KAAA,IAAY;EAAE,GAAG;EAAO;CAAI,IAAI;CACtE,KAAK,SAAS,WAAW,QAAQ,SAAS,WAAW,WAAW,YAAY,QAAQ,GAAG;EACrF,IAAI,aAAa,SAAS,KAAA,GACxB,MAAM,IAAI,MAAM,IAAI,IAAI,kDAAkD;EAE5E,OAAO,QAAQ;GAAE,GAAG;GAAc,MAAM,OAAO,aAAa,WAAW,OAAO,QAAQ,IAAI;EAAS,CAAC;CACtG;CACA,OAAO,QAAQ,cAAc,GAAG,gBAAgB,QAAQ,CAAC;AAC3D;;;;;;;;AASA,SAAS,YAAY,OAA0D;CAC7E,OAAO,OAAO,UAAU,YAAY,OAAO,UAAU,YAAY,kBAAkB,KAAK;AAC1F;AAEA,SAAS,kBAAkB,OAA8C;CACvE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,OAAQ,MAA8B,cAAc;AAC5G;;;;;AAMA,SAAS,gBAAgB,UAAuB,MAAiB,CAAC,GAAc;CAC9E,IAAI,aAAa,QAAQ,aAAa,KAAA,KAAa,OAAO,aAAa,WACrE,OAAO;CAET,IAAI,MAAM,QAAQ,QAAQ,GAAG;EAC3B,KAAK,MAAM,SAAS,UAClB,gBAAgB,OAAO,GAAG;EAE5B,OAAO;CACT;CACA,IAAI,OAAO,aAAa,YAAY,OAAO,aAAa,UACtD,MAAM,IAAI,MACR,yBAAyB,OAAO,QAAQ,EAAE,yEAC5C;CAEF,IAAI,KAAK,QAAmB;CAC5B,OAAO;AACT;AAEA,SAAS,SAAS,OAAwB;CACxC,OAAO,UAAU,OAAO,SAAS,OAAO,UAAU,WAAW,cAAc,KAAK,OAAO;AACzF"}
@@ -1,4 +1,4 @@
1
- import { O as structurallyEqual } from "./serveChannels-DN2R2s0A.js";
1
+ import { O as structurallyEqual } from "./serveChannels-BfIXVnoE.js";
2
2
  import { BehaviorSubject, Observable, Subject, Subscription, combineLatest, debounceTime, distinctUntilChanged, map, of, skip, tap, throttleTime } from "rxjs";
3
3
  //#region src/Input.ts
4
4
  /**
@@ -1730,4 +1730,4 @@ function persisted(adapter, key, options) {
1730
1730
  //#endregion
1731
1731
  export { output as A, equalityOf as C, input as D, InputCell as E, trackRead as M, withBodyOf as N, into as O, derive as S, internalState as T, Resource as _, undoable as a, ComputedCell as b, classifyStorageError as c, storageReadValue as d, pick as f, mutate as g, throttled as h, OpfsStorage as i, outputTargetOf as j, isOutputTarget as k, storageErrorMessage as l, debounced as m, persisted as n, UndoStack as o, pickKeys as p, IndexedDbStorage as r, MemoryStorage as s, PersistedState as t, storageReadFailure as u, resource as v, InternalState as w, computed as x, select as y };
1732
1732
 
1733
- //# sourceMappingURL=persisted-m5v2fOju.js.map
1733
+ //# sourceMappingURL=persisted-SkVtTKZG.js.map