Commit 7cda1ad
feat: render
* feat(components,markdown): render `element:metadata_viewer` + ```metadata doc fence (ADR-0051 P1)
The objectui half of ADR-0051 "inline metadata views in docs". A
```metadata fenced block in a doc is lifted into a live, read-only
`element:metadata_viewer` SDUI component — the same component a page
node renders, so docs and pages share one runtime.
- components: new `element:metadata_viewer` renderer (Content element,
read-only). Resolves the target live via useMetadataItem and renders
read-only projections of:
· state_machine — transition graph from a `state_machine` validation
rule (initial/final badges, field-option colors)
· flow — ordered step list; `detail: business` folds technical nodes
· permission — object-level C/R/U/D matrix
Registered in ComponentRegistry; degrades to a clear placeholder on a
missing/forbidden reference.
- plugin-markdown: dispatch ```metadata at the <pre> level (beside
```mermaid) into the SDUI component via the shared ComponentRegistry;
flat `key: value` body parser (data, not code); `metadata` added to
rehype-highlight plainText so the body is read verbatim.
Verified in browser against the app-showcase backend: task/project state
machines, a flow (technical steps folded), and a permission matrix all
render live with no console errors.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* test(adr-0051): cover element:metadata_viewer + the ```metadata fence parser
- metadata-viewer.test.tsx: renders the component via ComponentRegistry
with a mocked metadata context — asserts state_machine (option labels,
initial/final badges), flow (business-altitude folding of technical
nodes + the hidden-count note, and detail:technical revealing them),
permission (CRUD matrix), missing-rule + unknown-type degradation.
- metadata-fence.test.ts: pins the flat `key: value` body contract
(quote stripping, comments, colon-in-value, malformed-line skipping).
Exports parseMetadataFence for the unit test.
13 tests, all green.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>element:metadata_viewer + ```metadata doc fence (ADR-0051 P1) (#1774)1 parent 712cbd0 commit 7cda1ad
5 files changed
Lines changed: 619 additions & 3 deletions
File tree
- packages
- components/src
- __tests__
- renderers/basic
- plugin-markdown/src
Lines changed: 136 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
0 commit comments