@loomwork/ui-renderer-conformance 0.0.0-stage → 0.1.0

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.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
package/NOTICE ADDED
@@ -0,0 +1,8 @@
1
+ loom-ui
2
+ Copyright 2026 Sushil Chhetri
3
+
4
+ Licensed under the Apache License, Version 2.0 (the "License");
5
+ you may not use this project except in compliance with the License.
6
+ You may obtain a copy of the License at
7
+
8
+ http://www.apache.org/licenses/LICENSE-2.0
package/README.md CHANGED
@@ -1,3 +1,134 @@
1
- # Temporary Holding Version
1
+ # @loomwork/ui-renderer-conformance
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ One set of contract checks that **any** loom-ui renderer runs: `@loomwork/ui-renderer-lit`,
4
+ `@loomwork/ui-renderer-terminal`, and a third party's React / native / voice surface. A renderer is
5
+ anything that takes loom's `Blueprint` plus the values bound to it and shows them. This kit is how
6
+ you prove yours honours the contract without forking loom-ui.
7
+
8
+ ESM, like `@loomwork/ui-renderer-lit`; its consumer is a bundler or vitest, not a plain Node `import()`.
9
+
10
+ ## Install / import
11
+
12
+ ```jsonc
13
+ // package.json of a consumer checked out beside this repo (the packages are not published)
14
+ "@loomwork/ui-renderer-conformance": "link:../loom-ui/packages/renderer-conformance"
15
+ ```
16
+
17
+ Entry points: `@loomwork/ui-renderer-conformance` (the checks and report) and
18
+ `@loomwork/ui-renderer-conformance/vitest` (a vitest harness).
19
+
20
+ ## Run it
21
+
22
+ ```ts
23
+ // my-renderer/src/conformance.test.ts
24
+ import { describeRendererConformance } from "@loomwork/ui-renderer-conformance/vitest";
25
+ import { myAdapter } from "./myAdapter";
26
+
27
+ describeRendererConformance(myAdapter, { forbidSkips: true }); // one `it` per check
28
+ ```
29
+
30
+ No vitest? `checkRendererConformance(adapter)` returns a plain report
31
+ (`{ ok, results, failed, skipped }`) for any runner. A check the adapter has no capability for is a
32
+ **skip**, never a silent pass; `forbidSkips: true` makes a skip a failure, which is what a renderer
33
+ that claims the capability should use.
34
+
35
+ ## The adapter
36
+
37
+ The kit drives your renderer through `RendererAdapter` (see `src/adapter.ts`). Nothing in it names a
38
+ framework.
39
+
40
+ ```ts
41
+ interface RendererAdapter {
42
+ name: string;
43
+ surface: string; // the catalogue surface you draw: "web", "terminal", "voice"...
44
+ kinds: readonly string[]; // the Blueprint kinds you DRAW; any other must be refused visibly
45
+ capabilities?: {
46
+ update?: boolean; // update(next) is incremental
47
+ invoke?: boolean; // invoke() drives approvals / selects / multi-selects / text inputs
48
+ i18n?: boolean; // mount() honours the host's words and locale
49
+ interpretsControlCharacters?: boolean; // your surface reads ESC sequences / markup (terminal, speech)
50
+ chatMarkdown?: boolean; // you parse and draw `format: "markdown"` assistant parts
51
+ chatEntryAccessory?: boolean; // you draw host content under a transcript entry (mount's chatAccessory)
52
+ timeAxisLabels?: boolean; // you label a TimeSeries' time axis as its declared timeFormat says
53
+ references?: boolean; // your source markers are controls: invoke({kind:"ref"}) emits REF_OPEN; mount honours `unattended`
54
+ tokens?: boolean; // a Table token cell is controls: invoke({kind:"token"}) emits TABLE_TOKEN
55
+ };
56
+ mount(blueprint, { values, onAction, i18n, chatAccessory }): MountedRenderer;
57
+ }
58
+ interface MountedRenderer {
59
+ text(): string | Promise<string>; // everything a viewer can READ, settled, in reading order
60
+ set(handle, { value, state, message }): void | Promise<void>; // the hydration store's job
61
+ update?(next: Blueprint): void | Promise<void>;
62
+ invoke?(widgetId, intent): void | Promise<void>; // approve | reject | select | text | select-many | ref | token
63
+ dispose(): void;
64
+ }
65
+ ```
66
+
67
+ `values` is keyed by hydration handle; a widget's `binding.path` is `values.<handle>`
68
+ (`hydrationPath`) and its status path is `status.<handle>` (`hydrationStatusPath`). `text()` must
69
+ settle first (await your scheduler) so the kit never sleeps.
70
+
71
+ ## What it checks
72
+
73
+ | id | clause |
74
+ | --- | --- |
75
+ | `kinds` | every kind is drawn (value and title on the surface), or, if not in `adapter.kinds`, refused where a viewer can see it; never `[object Object]` / `undefined` / `NaN` |
76
+ | `unknown-kind` | a kind nobody registered is marked, never silently dropped |
77
+ | `status-matrix` | loading shows no value; ready shows it; stale keeps it; error shows the finding and no value; empty shows no value; recovery works |
78
+ | `live-update` | a delivered change replaces what is shown; `dispose` stops following the data |
79
+ | `incremental-update` | `update(next)` lands a revised Blueprint, keeps live data, drops removed widgets |
80
+ | `audience` | a widget withheld for a broadcast audience (and a forged `source.redacted` widget that still carries a title, props and a binding) shows only the constant `⊘ redacted` marker: none of its label, value, kind, type or handle on the surface, attributes included |
81
+ | `restricted` | a node compiled for a viewer who may not see it shows a bare placeholder and none of its label, value or id, even though the store holds the value (with a cleared-viewer positive control) |
82
+ | `container-roles` | an unknown container role (`tabs`, `stepper`, app-defined) is the plain titled container: every panel reachable, in order |
83
+ | `empty-states` | an empty table / chart / transcript still says what it is |
84
+ | `untrusted-text` | markup in a text is shown literally; on a surface that interprets control characters, none reach it |
85
+ | `media-refs` | a media reference is described and its address (or any prefix) is never shown |
86
+ | `chat` | complete turns in order; a restricted turn only as a placeholder; a field outside the `ChatValue` contract is not drawn |
87
+ | `diagram` | every renderer that draws `Diagram`: each node on the surface in the shared outline's order (a tree parent before its child, a flow's edges by source layer, a timeline chronological), an edge's label shown, and a value that breaks a rule (duplicate id, dangling edge, two roots, a cycle in a tree, an undated timeline node, 201 nodes, 401 edges) is the error state: the widget's title and no node. A markup-looking label is shown literally. A renderer that does not claim `Diagram` owes nothing here |
88
+ | `references` | every renderer that draws a kind that may cite sources (`Kpi`, `BarChart`, `TimeSeries`, `Table`, `StatusCard`, `Diagram`): a value with `refs` is accepted and drawn, each label on the surface (a terminal footnote counts) and a markup-looking label literal; a value with 17 refs, a bad or duplicate id or an over-long label is the error state (the title, no label). With `capabilities.references` and `invoke`: activating the nth marker emits exactly one `REF_OPEN { refId, n }` for the widget, and with `MountOptions.unattended` (no host listening) `invoke` must FAIL because a marker is then text, not a control. A surface that cannot be clicked (the terminal, speech) leaves the capability off and owes only the first two |
89
+ | `chat-markdown` | a `Chat` draws markdown in an assistant reply as text: html stays literal, only safe links keep a target, an image is its alt text, a part with no `format` is never parsed (with `capabilities.chatMarkdown`, the markdown source itself is not what a viewer reads) |
90
+ | `chat-entry-accessory` | with `capabilities.chatEntryAccessory`: host content from `chatAccessory` is drawn with its entry, after the entry's text, kept across updates, and never under a restricted entry; without it, the transcript is only checked to draw unchanged |
91
+ | `time-format` | a declared `timeFormat` labels a `TimeSeries` time axis: each period as written, once, in its zone (with `capabilities.timeAxisLabels`; otherwise the value is only checked to be accepted and drawn) |
92
+ | `table-tokens` | a `Table` token cell's labels are drawn as text, and a bad token cell is refused (the title, no label). With `capabilities.tokens` and `invoke`, activating a token emits `TABLE_TOKEN` with `{ rowKey, tokenId }` (`{ rowIndex, tokenId }` for a table without `rowKeys`) |
93
+ | `i18n` | the host's messages replace fixed words (`LU_MESSAGES` keys) and its locale formats numbers |
94
+ | `actions` | controls emit the shared `WidgetAction` shapes (`APPROVE`/`REJECT` with `payload.approved`; `SELECT` / `SELECT_MANY` (`payload.values`, in the order driven) / `SUBMIT_TEXT` with a well-formed idempotency `key`) |
95
+ | `select-current-value` | a bound `SelectInput` shows its current option as chosen; an undeclared value chooses nothing and is never echoed |
96
+ | `multi-select-current-value` | a bound `MultiSelectInput` reads differently for each chosen set and draws what is chosen |
97
+
98
+ The kit tests itself: `src/speech.test.ts` breaks one clause at a time in a conforming renderer and
99
+ requires the kit to name that clause.
100
+
101
+ ## Writing a third-party renderer
102
+
103
+ You need three things, none of them loom-ui internals:
104
+
105
+ 1. **Read the Blueprint.** It is loom's own IR (`@loomwork/blueprint-runtime`): a `layout` tree of
106
+ `grid` / `flex` / `stack` containers (a grid child is a `GridCell { node }`) and `Widget`s with a
107
+ `kind`, `title`, `props` and an optional `binding`. Walk it; look the widget's kind up in your
108
+ own table.
109
+ 2. **Honour the status matrix and the contract.** A bound widget's value and status live in the
110
+ projection state at `binding.path` / `binding.status.path`. Use `@loomwork/ui-core`'s
111
+ `checkKindValue(kind, value)` to validate a value against the kind's contract, `createSay(i18n)`
112
+ for every fixed word (never hard-code English), and `chatTranscriptLines`, `describeMedia`,
113
+ `formatSemanticNumber` and the `validate*Value` helpers so your words and numbers agree with the
114
+ other surfaces. Refuse (visibly) any kind you do not draw.
115
+ 3. **Emit `WidgetAction`s.** `{ type, widgetId, payload }`, in the shapes the `actions` check pins.
116
+ Wait for the host's answer (`ActionOutcome`) before clearing what a viewer typed.
117
+
118
+ Then write the adapter and run the kit. `src/speech.test-support.ts` is a complete, working
119
+ "voice" renderer in about 180 lines that speaks a Blueprint as sentences and passes every check,
120
+ with nothing skipped; copy it as a starting point. `@loomwork/ui-renderer-lit/src/conformance.test.ts`
121
+ and `@loomwork/ui-renderer-terminal/src/conformance.test.ts` show the same kit against a DOM and a
122
+ terminal renderer. The lit adapter must `import "@loomwork/ui-renderer-lit/register"` (inside that
123
+ package, `./register`) first: importing the renderer no longer defines its custom elements.
124
+
125
+ Container roles: a role your renderer does not know is the plain container (loom ADR 0099). If you
126
+ draw one (`tabs`), the kit still requires every panel to be reachable from `text()`.
127
+
128
+ ## See also
129
+
130
+ - [../renderer-lit/README.md](../renderer-lit/README.md) and
131
+ [../renderer-terminal/README.md](../renderer-terminal/README.md) — the shipped renderers that run
132
+ this kit.
133
+ - [../../docs/reference/rendering.md](../../docs/reference/rendering.md) — what a renderer draws.
134
+ - [../../README.md](../../README.md) — root overview.
@@ -0,0 +1,171 @@
1
+ import type { BindingState, Blueprint, WidgetAction } from "@loomwork/blueprint-runtime";
2
+ import type { LuI18n } from "@loomwork/ui-core";
3
+ /**
4
+ * What a renderer must implement for the kit to drive it. The kit hands it a loom `Blueprint` plus
5
+ * the values bound to it and asks it to show them; it reads back what a viewer could READ (text),
6
+ * and optionally drives it (update, invoke). Nothing here names a framework: a Lit element tree, a
7
+ * terminal frame, a React tree rendered to a string, or the sentences a voice assistant would speak
8
+ * all satisfy it.
9
+ */
10
+ /** The state of one hydration handle: the bound value and its delivery status. */
11
+ export interface HandleEntry {
12
+ readonly value?: unknown;
13
+ /** Absent = no status channel has landed yet (the widget is loading when there is no value). */
14
+ readonly state?: BindingState;
15
+ /** The status finding's message, for `error` / `empty` / `stale`. */
16
+ readonly message?: string;
17
+ }
18
+ export interface MountOptions {
19
+ /** Hydration handle -> its entry. The Blueprint's bindings read these through the hydration projection. */
20
+ readonly values: Readonly<Record<string, HandleEntry>>;
21
+ /** Every `WidgetAction` the renderer emits, in order. May return an `ActionOutcome`. */
22
+ readonly onAction: (action: WidgetAction) => unknown;
23
+ /** The host's words and locale. Only passed to an adapter that declares `capabilities.i18n`. */
24
+ readonly i18n?: LuI18n;
25
+ /**
26
+ * Host content under a transcript entry, as TEXT (the kit's renderer-neutral stand-in for a surface's
27
+ * own accessory seam, e.g. the web renderer's `chatAccessories`). `null` = nothing for that entry.
28
+ * Only passed to an adapter that declares `capabilities.chatEntryAccessory`.
29
+ */
30
+ /**
31
+ * Mount with NO host listening: the renderer is given no action handler (`onAction` is still passed so the kit can
32
+ * count, but the adapter must not wire it). Only passed to an adapter that declares `capabilities.references`.
33
+ */
34
+ readonly unattended?: boolean;
35
+ readonly chatAccessory?: (entry: {
36
+ readonly id: string;
37
+ readonly turn: number;
38
+ readonly role: string;
39
+ readonly status: string;
40
+ }) => string | null;
41
+ }
42
+ /** A live mounted view. */
43
+ export interface MountedRenderer {
44
+ /**
45
+ * Everything a viewer can READ right now, as one string: visible text plus accessible names. It
46
+ * SETTLES first (await any scheduled render) so the kit never sleeps. Order is reading order.
47
+ * EVERY rendered attribute a viewer or assistive tech is given counts as read — values,
48
+ * placeholders, link targets, data-* — not only visible text, so a hostile string hiding in one
49
+ * is caught like any other.
50
+ */
51
+ text(): string | Promise<string>;
52
+ /** Publish a handle's new value / status, as the hydration store would. */
53
+ set(handle: string, entry: HandleEntry): void | Promise<void>;
54
+ /** Land a revised Blueprint on the live view (incremental render). Needs `capabilities.update`. */
55
+ update?(next: Blueprint): void | Promise<void>;
56
+ /** Drive a control the way a viewer does. Needs `capabilities.invoke`. */
57
+ invoke?(widgetId: string, intent: InvokeIntent): void | Promise<void>;
58
+ /** Release subscriptions. After it, `set` must not throw and must not change what was last shown. */
59
+ dispose(): void;
60
+ }
61
+ /** What a viewer does to a control; the renderer maps it to its own gesture (click, key, utterance). */
62
+ export type InvokeIntent = {
63
+ readonly kind: "approve";
64
+ } | {
65
+ readonly kind: "reject";
66
+ } | {
67
+ readonly kind: "select";
68
+ readonly value: string;
69
+ } | {
70
+ readonly kind: "text";
71
+ readonly text: string;
72
+ }
73
+ /** Choose exactly these values of a `MultiSelectInput`, in this order, starting from an empty selection. */
74
+ | {
75
+ readonly kind: "select-many";
76
+ readonly values: readonly string[];
77
+ }
78
+ /**
79
+ * Activate the `n`th (1-based) source marker of a widget whose value carries `refs`. Needs `capabilities.references`.
80
+ * Where the widget has no such control (an unattended mount draws markers as text), the adapter must FAIL, never
81
+ * pretend: the kit relies on it to know an inert marker is not a control.
82
+ */
83
+ | {
84
+ readonly kind: "ref";
85
+ readonly n: number;
86
+ }
87
+ /** Activate the token chip with this id in a `Table` cell (the first match in the widget). Needs `capabilities.tokens`. */
88
+ | {
89
+ readonly kind: "token";
90
+ readonly tokenId: string;
91
+ };
92
+ export interface AdapterCapabilities {
93
+ /** `update(next)` is incremental and keeps the view live. */
94
+ readonly update?: boolean;
95
+ /** `invoke` drives APPROVE / REJECT / SELECT / SELECT_MANY / SUBMIT_TEXT controls. */
96
+ readonly invoke?: boolean;
97
+ /** `mount` honours `MountOptions.i18n` (the host's words and locale). */
98
+ readonly i18n?: boolean;
99
+ /**
100
+ * The surface INTERPRETS control characters (a terminal reads ESC sequences; a speech engine
101
+ * reads markup), so none of an untrusted text's may reach it. A DOM text node is inert and leaves
102
+ * this off. Whatever the surface, markup in a text is always shown as the literal characters.
103
+ */
104
+ readonly interpretsControlCharacters?: boolean;
105
+ /**
106
+ * The renderer parses a `format: "markdown"` text part (core's `parseChatMarkdown`) and draws its structure. Every
107
+ * renderer must pass the safety half of `chat-markdown` (markup literal, no unsafe link, no image address, a plain part
108
+ * never parsed); this adds the check that the markdown source itself is not what a viewer reads.
109
+ */
110
+ readonly chatMarkdown?: boolean;
111
+ /**
112
+ * The renderer draws host content under a transcript entry (`MountOptions.chatAccessory`): with its
113
+ * entry, after the entry's own text, never for a restricted entry. A surface without the seam leaves
114
+ * this off and is only checked to draw the transcript unchanged.
115
+ */
116
+ readonly chatEntryAccessory?: boolean;
117
+ /**
118
+ * The renderer draws a TimeSeries' time axis as text, and labels it as a declared
119
+ * `TimeSeriesValue.timeFormat` says (core's `formatTimeLabel`): each period as written, once. A
120
+ * surface that draws no time labels (a sparkline) leaves this off and is only checked to accept
121
+ * and draw a value that declares one.
122
+ */
123
+ readonly timeAxisLabels?: boolean;
124
+ /**
125
+ * The renderer draws a value's `refs` as numbered markers a viewer can ACTIVATE (needs `invoke`, and `mount` honours
126
+ * `MountOptions.unattended`): activating one emits `REF_OPEN { refId, n }` for the widget, and with no host listening
127
+ * the markers are not controls. A surface that cannot be clicked (the terminal, speech) leaves this off and is only
128
+ * checked to accept and draw a value with refs, label text included, and to refuse a bad list.
129
+ */
130
+ readonly references?: boolean;
131
+ /**
132
+ * The renderer draws a `Table` token cell as controls a viewer can ACTIVATE (needs `invoke`): activating one emits
133
+ * `TABLE_TOKEN { rowKey, tokenId }` (`{ rowIndex, tokenId }` for a table without `rowKeys`). A surface that cannot be
134
+ * clicked leaves this off and is only checked to draw a token cell's labels as text.
135
+ */
136
+ readonly tokens?: boolean;
137
+ }
138
+ export interface RendererAdapter {
139
+ /** Shown in reports. */
140
+ readonly name: string;
141
+ /**
142
+ * The catalogue surface this renderer draws (`"web"`, `"terminal"`, `"voice"`…): the key under
143
+ * which a semantic entry's `surfaces` names the Blueprint kind it resolves to.
144
+ */
145
+ readonly surface: string;
146
+ /**
147
+ * The Blueprint kinds this renderer DRAWS. A kind of the kit's fixtures that is not listed must be
148
+ * REFUSED visibly (its title or kind name on the surface), never silently dropped.
149
+ */
150
+ readonly kinds: readonly string[];
151
+ readonly capabilities?: AdapterCapabilities;
152
+ /** Mount `blueprint`. Each call is independent (a fresh store and host). */
153
+ mount(blueprint: Blueprint, options: MountOptions): MountedRenderer | Promise<MountedRenderer>;
154
+ }
155
+ export type CheckStatus = "pass" | "fail" | "skip";
156
+ export interface CheckResult {
157
+ readonly id: string;
158
+ readonly title: string;
159
+ readonly status: CheckStatus;
160
+ /** Why it failed, or why it was skipped. */
161
+ readonly message?: string;
162
+ }
163
+ export interface ConformanceReport {
164
+ readonly adapter: string;
165
+ readonly results: readonly CheckResult[];
166
+ /** No check failed. A skip does not fail the report; see {@link ConformanceReport.skipped}. */
167
+ readonly ok: boolean;
168
+ readonly failed: readonly CheckResult[];
169
+ readonly skipped: readonly CheckResult[];
170
+ }
171
+ //# sourceMappingURL=adapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AACzF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;GAMG;AAEH,kFAAkF;AAClF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,gGAAgG;IAChG,QAAQ,CAAC,KAAK,CAAC,EAAE,YAAY,CAAC;IAC9B,qEAAqE;IACrE,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,YAAY;IAC3B,2GAA2G;IAC3G,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC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GG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IAClC,QAAQ,CAAC,YAAY,CAAC,EAAE,mBAAmB,CAAC;IAC5C,4EAA4E;IAC5E,KAAK,CAAC,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,YAAY,GAAG,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;CAChG;AAED,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEnD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,4CAA4C;IAC5C,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,CAAC;IACzC,+FAA+F;IAC/F,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,SAAS,WAAW,EAAE,CAAC;CAC1C"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import type { RendererAdapter } from "./adapter";
2
+ /** Thrown by a check to say the renderer broke the contract. */
3
+ export declare class ConformanceFailure extends Error {
4
+ }
5
+ /** Thrown by a check to say it cannot run against this adapter (reported as a skip). */
6
+ export declare class ConformanceSkip extends Error {
7
+ }
8
+ export interface Check {
9
+ readonly id: string;
10
+ readonly title: string;
11
+ run(adapter: RendererAdapter): Promise<void>;
12
+ }
13
+ export declare const CHECKS: readonly Check[];
14
+ //# sourceMappingURL=checks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checks.d.ts","sourceRoot":"","sources":["../src/checks.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAKV,eAAe,EAChB,MAAM,WAAW,CAAC;AAWnB,gEAAgE;AAChE,qBAAa,kBAAmB,SAAQ,KAAK;CAAG;AAChD,wFAAwF;AACxF,qBAAa,eAAgB,SAAQ,KAAK;CAAG;AAE7C,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,GAAG,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C;AAghDD,eAAO,MAAM,MAAM,EAAE,SAAS,KAAK,EAAW,CAAC"}