Skip to content

ingenui@0.0.2

Choose a tag to compare

@github-actions github-actions released this 08 Nov 01:29
· 6 commits to master since this release
b5ad786

Patch Changes

  • ebfc21a: Add useIsElementComplete(): a hook for catalog components that returns false while the component's element is still open on the stream and true once it is settled (closing tag arrived, self-closing, or auto-closed). Each resolved component element is now wrapped in a context provider, so the flag flips without remounting. Exported from @ingenui/incremental-jsx-parser and /react, and re-exported from ingenui/react.

  • 7ea2f79: Internal refactoring: the parser's AST primitives and error events move into dependency-free modules (no more import cycles), and duplicated logic (component resolution, fence parsing, actions variable wiring) is shared. IncrementalJsxParserOptions fields now also accept an explicit undefined, and GenUiMessage extends IncrementalJsxParser. With dynamicActions: false and an empty actions map, the actions variable is no longer defined (matching the prompt).

  • b71bd59: pipeGenUi can stop a streamed message on a parse issue and recover, transport-agnostically. pipe.stop() (also passed to onIssue as its second argument) cancels the source and ends the stream normally instead of with an error. The new continuation option continues a stopped message in the same stream: it closes an open fence, then pipes the source the callback returns into the same validation state, so block indices and issues stay aligned with the client. done now resolves with a result object (status, text, issues, issueReport, cleanOffset / cleanText, stops) instead of the issues array. New formatContinuationMessage builds the Messages API "continue from where you left off" request, and the validator gains getCleanOffset() / getFenceClose().

  • e871136: Separate pure logic from side effects. Breaking (/core): createParser now takes the schema checks as one checks: SchemaChecks option (build it with the new createSchemaChecks(schema)) instead of the flat isKnownComponent / isKnownVariable / isAllowedElement / checkProp callbacks, and TreeBuilderOptions is no longer exported. The AST node types are now readonly, matching the frozen nodes the parser has always handed out. Parse errors are still reported synchronously by the write() that completes them, now once the chunk is fully parsed. validateOpeningTag and validateVariable are exported as the pure functions behind the schema errors. Streaming is faster with small chunks (the live snapshot copies less), and a streamed ingenui message renders with fewer, larger UI-block updates.

  • a60f3da: ingenui now covers the server as well as the client:

    • ingenui/schema: defineGenUiSchema declares the parse-affecting options (elements, component prop catalogs with descriptions, variable types, actions, dynamicActions, mismatchedTag) as plain data, shared by the server and the client.
    • bindGenUi(schema, bindings) (in ingenui) binds components, variable values and action handlers to a schema. The bindings are type-checked against the schema (InferSchemaType / InferComponentProps) and checked at runtime.
    • ingenui/server (React-free): pipeGenUi validates a model's stream while passing it through to the client, reporting the client's parse-time issues as soon as they are streamed. It also exports createGenUiValidator / validateGenUiMessage, resolveGenUiAction (for building the next request on the server from an action name), formatGenUiPrompt, and formatIssueReport.
    • formatGenUiPrompt accepts a schema and includes component and action descriptions. Actions may be declared as { description }.

    Parser: component specs accept a description (listed by formatPromptContract). The prompt contract now lists declared variables first, and a prop rejected by an empty prop catalog now reads "<Tag> takes no props".

  • d6c196e: Render unterminated inline Markdown optimistically while streaming: at the stream frontier, **bold, *em, and `code show as formatted text instead of raw markers, link destinations are hidden until complete, and trailing markers that could still become syntax are withheld. Emphasis now follows CommonMark flanking rules (** not bold ** stays literal). Custom renderMarkdown functions receive a { streaming } context, and the exported renderMarkdown accepts { streaming: true }.

  • 9c4002d: New wrapUiBlock option for createGenUiMessage: wraps each ui+jsx block's rendering with the app's own markup. It receives the block's blockIndex, state ("streaming" / "closed" / "unterminated"), its jsx-error / render-error issues so far, whether it crashed, and children (the default rendering, still inside the built-in error boundary), so an app can grey out, collapse, or label a broken block (e.g. above the corrected block after a stop and continuation), or show a fallback for a crashed one. It is called again only when the block's tree or status changes.

    A render crash is now final: the block's error boundary no longer retries as more of the stream arrives (props are final when an element appears; only children grow, and components can check useIsElementComplete()). UiBlockErrorBoundary drops its resetKey prop. renderUiError is deprecated in favour of wrapUiBlock (crashed ? fallback : children).

  • Updated dependencies [ebfc21a]

  • Updated dependencies [7ea2f79]

  • Updated dependencies [ff93a7e]

  • Updated dependencies [e871136]

  • Updated dependencies [a60f3da]

    • @ingenui/incremental-jsx-parser@0.0.2