@leo-studio/leo-markup 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 +9 -0
- package/README.md +18 -2
- package/dist/agent-support.d.ts +10 -0
- package/dist/agent-support.d.ts.map +1 -0
- package/dist/agent-support.js +27 -0
- package/dist/agent-support.js.map +1 -0
- package/dist/ast-json.d.ts +104 -0
- package/dist/ast-json.d.ts.map +1 -0
- package/dist/ast-json.js +203 -0
- package/dist/ast-json.js.map +1 -0
- package/dist/authoring-lints.d.ts +79 -0
- package/dist/authoring-lints.d.ts.map +1 -0
- package/dist/authoring-lints.js +145 -0
- package/dist/authoring-lints.js.map +1 -0
- package/dist/block-inline.d.ts +74 -0
- package/dist/block-inline.d.ts.map +1 -0
- package/dist/block-inline.js +171 -0
- package/dist/block-inline.js.map +1 -0
- package/dist/fence.d.ts +14 -0
- package/dist/fence.d.ts.map +1 -0
- package/dist/fence.js +55 -0
- package/dist/fence.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/parity.d.ts +44 -0
- package/dist/parity.d.ts.map +1 -0
- package/dist/parity.js +80 -0
- package/dist/parity.js.map +1 -0
- package/dist/product-spec.d.ts +164 -0
- package/dist/product-spec.d.ts.map +1 -0
- package/dist/product-spec.js +240 -0
- package/dist/product-spec.js.map +1 -0
- package/dist/registry.d.ts +53 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +483 -0
- package/dist/registry.js.map +1 -0
- package/dist/scanner.d.ts +40 -0
- package/dist/scanner.d.ts.map +1 -0
- package/dist/scanner.js +291 -0
- package/dist/scanner.js.map +1 -0
- package/dist/schema/leo-markup-ast.schema.json +217 -0
- package/dist/schema/vocabulary.json +382 -0
- package/dist/tree-text.d.ts +16 -0
- package/dist/tree-text.d.ts.map +1 -0
- package/dist/tree-text.js +320 -0
- package/dist/tree-text.js.map +1 -0
- package/dist/types.d.ts +211 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +34 -0
- package/dist/types.js.map +1 -0
- package/dist/vocabulary.d.ts +293 -0
- package/dist/vocabulary.d.ts.map +1 -0
- package/dist/vocabulary.js +226 -0
- package/dist/vocabulary.js.map +1 -0
- package/package.json +43 -3
package/dist/registry.js
ADDED
|
@@ -0,0 +1,483 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `leo` registry — the allow-list.
|
|
3
|
+
*
|
|
4
|
+
* A single object keyed by the LOWERCASE authored name (`leo.callout` resolves
|
|
5
|
+
* `registry['callout']`). Each entry declares its `targets`, its canonical
|
|
6
|
+
* `PropSchema` (the one contract both the ANSI and web emitters adapt to), its
|
|
7
|
+
* Markdown flow placement,
|
|
8
|
+
* and a `degrade` strategy for any surface it does not target.
|
|
9
|
+
*
|
|
10
|
+
* EMITTERS ARE NOT WIRED HERE. This module declares the vocabulary, targets,
|
|
11
|
+
* placement, and prop schemas; the concrete `ansi` emitters are attached by
|
|
12
|
+
* leo-pty-renderer and the `web` emitters by leo-doc-web.
|
|
13
|
+
* The parity harness (src/parity.ts) checks the contract against whatever
|
|
14
|
+
* registry it is given; the FULLY-WIRED registry only satisfies the `both`
|
|
15
|
+
* entries once those emitters are attached.
|
|
16
|
+
*
|
|
17
|
+
* Prop-schema conflicts: where leo's ANSI attrs and Glottodoc's web props
|
|
18
|
+
* disagree, leo's ANSI attrs WIN (the smaller, stable subset). Each such
|
|
19
|
+
* choice is recorded inline as a `note` on the prop so the canonical decision is
|
|
20
|
+
* auditable.
|
|
21
|
+
*/
|
|
22
|
+
import { AGENT_SUPPORT_AGENTS, AGENT_SUPPORT_QUALIFIERS, AGENT_SUPPORT_STATES, } from './agent-support.js';
|
|
23
|
+
// ── Canonical prop schemas (grounded in the leo-pty-renderer ANSI signatures) ─
|
|
24
|
+
const calloutProps = {
|
|
25
|
+
// leo ANSI CalloutType is the canonical enum (info|warning|success|danger);
|
|
26
|
+
// Glottodoc's web Callout adapts its richer type list onto these.
|
|
27
|
+
type: {
|
|
28
|
+
kind: 'enum',
|
|
29
|
+
values: ['info', 'warning', 'success', 'danger'],
|
|
30
|
+
default: 'info',
|
|
31
|
+
note: 'ANSI-wins: canonical enum is leo CalloutType; web maps note/tip/error/danger onto these.',
|
|
32
|
+
},
|
|
33
|
+
title: { kind: 'string' },
|
|
34
|
+
};
|
|
35
|
+
const badgeProps = {
|
|
36
|
+
// ANSI renderBadge(value): the value may also come from the body; the schema
|
|
37
|
+
// declares the attr form.
|
|
38
|
+
value: { kind: 'string' },
|
|
39
|
+
};
|
|
40
|
+
// StatusBadge ↔ leo `capsule`/`status`. Canonical authored name is `statusbadge`
|
|
41
|
+
// (lowercase of the vocabulary entry); the ANSI side is renderCapsule(value).
|
|
42
|
+
const statusBadgeProps = {
|
|
43
|
+
value: {
|
|
44
|
+
kind: 'string',
|
|
45
|
+
note: 'ANSI-wins: leo capsule/status takes a single `value`; web StatusBadge label maps to it.',
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
const agentSupportProps = {
|
|
49
|
+
agent: { kind: 'enum', values: AGENT_SUPPORT_AGENTS, required: true },
|
|
50
|
+
support: { kind: 'enum', values: AGENT_SUPPORT_STATES, required: true },
|
|
51
|
+
qualifier: { kind: 'enum', values: AGENT_SUPPORT_QUALIFIERS },
|
|
52
|
+
};
|
|
53
|
+
const stepsProps = {
|
|
54
|
+
// Container; steps are nested <leo.step> islands (auto-numbered both sides).
|
|
55
|
+
};
|
|
56
|
+
const stepProps = {
|
|
57
|
+
title: { kind: 'string' },
|
|
58
|
+
};
|
|
59
|
+
const treeProps = {
|
|
60
|
+
// Container; nodes are nested <leo.folder>/<leo.file> islands.
|
|
61
|
+
};
|
|
62
|
+
const treeNodeProps = {
|
|
63
|
+
name: { kind: 'string', required: true },
|
|
64
|
+
comment: { kind: 'string' },
|
|
65
|
+
highlight: { kind: 'boolean', default: false },
|
|
66
|
+
plainIcon: { kind: 'string' },
|
|
67
|
+
};
|
|
68
|
+
const comparisonTableProps = {
|
|
69
|
+
// Body is a markdown table; these are ANSI-only presentation hints (web
|
|
70
|
+
// ignores them) — ANSI-wins by definition.
|
|
71
|
+
highlight: {
|
|
72
|
+
kind: 'string',
|
|
73
|
+
note: 'ANSI-only presentation hint (row label to highlight); web has no equivalent.',
|
|
74
|
+
},
|
|
75
|
+
wrap: {
|
|
76
|
+
kind: 'number',
|
|
77
|
+
note: 'ANSI-only column-wrap width; web has no equivalent.',
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
const mermaidProps = {
|
|
81
|
+
// Body is full mermaid source (flowchart, state, class, ER, sequence,
|
|
82
|
+
// pie, mindmap, timeline, gitGraph); web target is a mermaid fence. No attrs.
|
|
83
|
+
};
|
|
84
|
+
const heatmapProps = {
|
|
85
|
+
// Body is a markdown table on terminal; the web chart reads the same cells.
|
|
86
|
+
// `data` may also arrive JSON-encoded as an attribute.
|
|
87
|
+
data: {
|
|
88
|
+
kind: 'json',
|
|
89
|
+
note: 'Same data, different form: ANSI table ⟷ web chart. JSON-coerced when given as an attr.',
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
const gitStatusProps = {
|
|
93
|
+
// terminal-only: reads live git state; no web equivalent.
|
|
94
|
+
};
|
|
95
|
+
const questionProps = {
|
|
96
|
+
// Container; options are nested <leo.option> islands, notes is a nested
|
|
97
|
+
// <leo.notes> island. Terminal-only — a chat question has no web analogue.
|
|
98
|
+
prompt: { kind: 'string', required: true },
|
|
99
|
+
label: { kind: 'string' },
|
|
100
|
+
type: {
|
|
101
|
+
kind: 'enum',
|
|
102
|
+
values: ['architecture'],
|
|
103
|
+
note: 'Prefixes the headline with the resolved leo-adr glyph (patched font, 🏛️ emoji fallback) — flags a decision that would set precedent across surfaces (new package, third-party dep, cross-package contract), same signal as the 🏛 marker in the spec-author skill.',
|
|
104
|
+
},
|
|
105
|
+
urgency: { kind: 'enum', values: ['low', 'normal', 'blocker'], default: 'normal' },
|
|
106
|
+
multiSelect: { kind: 'boolean', default: false },
|
|
107
|
+
freeText: { kind: 'boolean', default: false },
|
|
108
|
+
recommendation: { kind: 'string', note: 'the recommended <leo.option key=...> value' },
|
|
109
|
+
hint: {
|
|
110
|
+
kind: 'boolean',
|
|
111
|
+
default: true,
|
|
112
|
+
note: 'Shows the trailing "how to answer" callout once per batch/message; set false on any question in the batch to suppress it (e.g. once the user already knows the convention).',
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
const optionProps = {
|
|
116
|
+
key: { kind: 'string', required: true },
|
|
117
|
+
label: { kind: 'string', required: true },
|
|
118
|
+
recommendation: { kind: 'enum', values: ['high', 'medium', 'low', 'not-recommended'] },
|
|
119
|
+
freeText: { kind: 'boolean', default: false },
|
|
120
|
+
};
|
|
121
|
+
const notesProps = {
|
|
122
|
+
// Container; body is markdown (rendered via renderMarkdown, fence-aware).
|
|
123
|
+
};
|
|
124
|
+
// ── Port-backs (flipped to `both`) ───────────────────────────────────────────
|
|
125
|
+
const progressProps = {
|
|
126
|
+
// ANSI renderProgress(value, total, label, width). `width` is an ANSI-only
|
|
127
|
+
// bar-width hint; web derives its own width from layout (ANSI-wins).
|
|
128
|
+
value: { kind: 'number', default: 0 },
|
|
129
|
+
total: { kind: 'number', default: 100 },
|
|
130
|
+
label: { kind: 'string' },
|
|
131
|
+
width: {
|
|
132
|
+
kind: 'number',
|
|
133
|
+
default: 20,
|
|
134
|
+
note: 'ANSI-only bar width; web sizes from layout.',
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
const cardProps = {
|
|
138
|
+
// The card resolver dispatches on `type` (plan/issue/review-dash/doc) on the
|
|
139
|
+
// live ANSI path; `ref`/`path` carry the data-source. The web side maps onto
|
|
140
|
+
// RichLink/MdxCard. Title/description are the generic fallback both surfaces
|
|
141
|
+
// can render without a data source.
|
|
142
|
+
type: {
|
|
143
|
+
kind: 'enum',
|
|
144
|
+
values: ['plan', 'issue', 'review-dash', 'doc'],
|
|
145
|
+
note: 'ANSI-wins: the leo card-resolver dispatches on these types; web maps them onto RichLink/MdxCard.',
|
|
146
|
+
},
|
|
147
|
+
ref: { kind: 'string' },
|
|
148
|
+
path: { kind: 'string' },
|
|
149
|
+
title: { kind: 'string' },
|
|
150
|
+
description: { kind: 'string' },
|
|
151
|
+
href: { kind: 'string' },
|
|
152
|
+
};
|
|
153
|
+
const metricProps = {
|
|
154
|
+
// web Metric (KPI) is the origin; the ANSI emitter renders label+value+trend.
|
|
155
|
+
label: { kind: 'string' },
|
|
156
|
+
value: { kind: 'string' },
|
|
157
|
+
trend: {
|
|
158
|
+
kind: 'enum',
|
|
159
|
+
values: ['up', 'down', 'flat'],
|
|
160
|
+
note: 'ANSI-wins: canonical trend enum (up|down|flat); the ANSI glyph + web arrow both map to it.',
|
|
161
|
+
},
|
|
162
|
+
change: { kind: 'string' },
|
|
163
|
+
};
|
|
164
|
+
const iconProps = {
|
|
165
|
+
// web Icon (lucide) is the origin; the ANSI emitter resolves a leo glyph/emoji.
|
|
166
|
+
icon: { kind: 'string' },
|
|
167
|
+
color: { kind: 'string' },
|
|
168
|
+
size: {
|
|
169
|
+
kind: 'string',
|
|
170
|
+
note: 'web-only sizing hint (px); the ANSI glyph is single-cell.',
|
|
171
|
+
},
|
|
172
|
+
};
|
|
173
|
+
// web-only props are intentionally permissive for now — the absorbed React
|
|
174
|
+
// components carry their own prop handling; the canonical schema is
|
|
175
|
+
// filled in as those components are absorbed. Empty schemas here keep the
|
|
176
|
+
// allow-list complete without over-specifying ahead of the absorb.
|
|
177
|
+
const emptyProps = {};
|
|
178
|
+
// ── degrade strategies ────────────────────────────────────────────────────────
|
|
179
|
+
const inlineDegrade = { kind: 'inline' };
|
|
180
|
+
const stackDegrade = { kind: 'inline' };
|
|
181
|
+
const flatListDegrade = { kind: 'inline' };
|
|
182
|
+
const omitDegrade = { kind: 'omit' };
|
|
183
|
+
const noteDegrade = { kind: 'note', text: 'see terminal' };
|
|
184
|
+
// ── entry helpers ─────────────────────────────────────────────────────────────
|
|
185
|
+
function entry(c) {
|
|
186
|
+
return { flow: 'block', ...c };
|
|
187
|
+
}
|
|
188
|
+
// ── The registry ──────────────────────────────────────────────────────────────
|
|
189
|
+
//
|
|
190
|
+
// Keys are the LOWERCASE authored names. Emitters (`ansi`/`web`) are attached by
|
|
191
|
+
// leo-pty-renderer and leo-doc-web; here only `targets`, `props`, and
|
|
192
|
+
// (off-surface) `degrade` are set.
|
|
193
|
+
/** Shared `targets: both` entries (parity-enforced once emitters land). */
|
|
194
|
+
const sharedBoth = {
|
|
195
|
+
callout: entry({ name: 'callout', targets: 'both', props: calloutProps }),
|
|
196
|
+
badge: entry({ name: 'badge', flow: 'inline', targets: 'both', props: badgeProps }),
|
|
197
|
+
statusbadge: entry({
|
|
198
|
+
name: 'statusbadge',
|
|
199
|
+
flow: 'inline',
|
|
200
|
+
targets: 'both',
|
|
201
|
+
props: statusBadgeProps,
|
|
202
|
+
}),
|
|
203
|
+
agentsupport: entry({
|
|
204
|
+
name: 'agentsupport',
|
|
205
|
+
flow: 'inline',
|
|
206
|
+
targets: 'both',
|
|
207
|
+
props: agentSupportProps,
|
|
208
|
+
}),
|
|
209
|
+
steps: entry({ name: 'steps', targets: 'both', props: stepsProps }),
|
|
210
|
+
tree: entry({ name: 'tree', targets: 'both', props: treeProps }),
|
|
211
|
+
comparisontable: entry({
|
|
212
|
+
name: 'comparisontable',
|
|
213
|
+
targets: 'both',
|
|
214
|
+
props: comparisonTableProps,
|
|
215
|
+
}),
|
|
216
|
+
mermaid: entry({ name: 'mermaid', targets: 'both', props: mermaidProps }),
|
|
217
|
+
heatmap: entry({ name: 'heatmap', targets: 'both', props: heatmapProps }),
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* Port-backs — now `targets: 'both'`. Each gained its second-surface
|
|
221
|
+
* emitter (progress/card → web; metric/icon → terminal), so they
|
|
222
|
+
* render to both surfaces and the parity harness enforces both emitters.
|
|
223
|
+
*/
|
|
224
|
+
const portBacks = {
|
|
225
|
+
progress: entry({ name: 'progress', targets: 'both', props: progressProps }),
|
|
226
|
+
card: entry({ name: 'card', targets: 'both', props: cardProps }),
|
|
227
|
+
metric: entry({ name: 'metric', targets: 'both', props: metricProps }),
|
|
228
|
+
icon: entry({ name: 'icon', flow: 'inline', targets: 'both', props: iconProps }),
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Sub-components nested inside container `both` entries. `step`, `folder`, `file`
|
|
232
|
+
* are resolved by the scanner within a parent body, not standalone — they ride
|
|
233
|
+
* their parent's parity, so they are declared `both` with the parent and carry
|
|
234
|
+
* no independent degrade.
|
|
235
|
+
*/
|
|
236
|
+
const subComponents = {
|
|
237
|
+
step: entry({ name: 'step', targets: 'both', props: stepProps }),
|
|
238
|
+
folder: entry({ name: 'folder', targets: 'both', props: treeNodeProps }),
|
|
239
|
+
file: entry({ name: 'file', targets: 'both', props: treeNodeProps }),
|
|
240
|
+
// Abstract IA node (not a file/folder) — same tree container semantics as
|
|
241
|
+
// folder (parseTreeNodeList treats folder/node identically as containers).
|
|
242
|
+
node: entry({ name: 'node', targets: 'both', props: treeNodeProps }),
|
|
243
|
+
// question/option/notes are terminal-only (see terminalOnly below), so
|
|
244
|
+
// their sub-components ride THAT parity, not `both`.
|
|
245
|
+
option: entry({
|
|
246
|
+
name: 'option',
|
|
247
|
+
targets: 'terminal-only',
|
|
248
|
+
props: optionProps,
|
|
249
|
+
degrade: noteDegrade,
|
|
250
|
+
}),
|
|
251
|
+
notes: entry({
|
|
252
|
+
name: 'notes',
|
|
253
|
+
targets: 'terminal-only',
|
|
254
|
+
props: notesProps,
|
|
255
|
+
degrade: noteDegrade,
|
|
256
|
+
}),
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* terminal-only (2): git-status reads live git state; question is a chat/CLI
|
|
260
|
+
* question prompt (option/notes above are its nested sub-components). Neither
|
|
261
|
+
* has a web equivalent — both degrade to a static note.
|
|
262
|
+
*/
|
|
263
|
+
const terminalOnly = {
|
|
264
|
+
'git-status': entry({
|
|
265
|
+
name: 'git-status',
|
|
266
|
+
targets: 'terminal-only',
|
|
267
|
+
props: gitStatusProps,
|
|
268
|
+
degrade: noteDegrade,
|
|
269
|
+
}),
|
|
270
|
+
question: entry({
|
|
271
|
+
name: 'question',
|
|
272
|
+
targets: 'terminal-only',
|
|
273
|
+
props: questionProps,
|
|
274
|
+
degrade: noteDegrade,
|
|
275
|
+
}),
|
|
276
|
+
};
|
|
277
|
+
/**
|
|
278
|
+
* web-only entries that DEGRADE TO INLINE on terminal. Declared
|
|
279
|
+
* so authored docs don't error on terminal — they degrade per strategy. The web
|
|
280
|
+
* emitters are wired by leo-doc-web; here only targets + degrade are pinned.
|
|
281
|
+
*/
|
|
282
|
+
const webOnlyInline = {
|
|
283
|
+
accordion: entry({
|
|
284
|
+
name: 'accordion',
|
|
285
|
+
targets: 'web-only',
|
|
286
|
+
props: emptyProps,
|
|
287
|
+
degrade: inlineDegrade,
|
|
288
|
+
}),
|
|
289
|
+
expandable: entry({
|
|
290
|
+
name: 'expandable',
|
|
291
|
+
targets: 'web-only',
|
|
292
|
+
props: emptyProps,
|
|
293
|
+
degrade: inlineDegrade,
|
|
294
|
+
}),
|
|
295
|
+
tabs: entry({ name: 'tabs', targets: 'web-only', props: emptyProps, degrade: inlineDegrade }),
|
|
296
|
+
tooltip: entry({
|
|
297
|
+
name: 'tooltip',
|
|
298
|
+
flow: 'inline',
|
|
299
|
+
targets: 'web-only',
|
|
300
|
+
props: emptyProps,
|
|
301
|
+
degrade: inlineDegrade,
|
|
302
|
+
}),
|
|
303
|
+
columns: entry({
|
|
304
|
+
name: 'columns',
|
|
305
|
+
targets: 'web-only',
|
|
306
|
+
props: emptyProps,
|
|
307
|
+
degrade: stackDegrade,
|
|
308
|
+
}),
|
|
309
|
+
tiles: entry({ name: 'tiles', targets: 'web-only', props: emptyProps, degrade: stackDegrade }),
|
|
310
|
+
toc: entry({ name: 'toc', targets: 'web-only', props: emptyProps, degrade: flatListDegrade }),
|
|
311
|
+
};
|
|
312
|
+
/**
|
|
313
|
+
* web-only entries with NO terminal meaning — they
|
|
314
|
+
* omit on terminal. Charts/images/embeds/nav-context + ProfileCard/ReadingGuide.
|
|
315
|
+
*/
|
|
316
|
+
const webOnlyOmit = {
|
|
317
|
+
scoreradar: entry({
|
|
318
|
+
name: 'scoreradar',
|
|
319
|
+
targets: 'web-only',
|
|
320
|
+
props: emptyProps,
|
|
321
|
+
degrade: omitDegrade,
|
|
322
|
+
}),
|
|
323
|
+
starchart: entry({
|
|
324
|
+
name: 'starchart',
|
|
325
|
+
targets: 'web-only',
|
|
326
|
+
props: emptyProps,
|
|
327
|
+
degrade: omitDegrade,
|
|
328
|
+
}),
|
|
329
|
+
imagegallery: entry({
|
|
330
|
+
name: 'imagegallery',
|
|
331
|
+
targets: 'web-only',
|
|
332
|
+
props: emptyProps,
|
|
333
|
+
degrade: omitDegrade,
|
|
334
|
+
}),
|
|
335
|
+
imagelightbox: entry({
|
|
336
|
+
name: 'imagelightbox',
|
|
337
|
+
targets: 'web-only',
|
|
338
|
+
props: emptyProps,
|
|
339
|
+
degrade: omitDegrade,
|
|
340
|
+
}),
|
|
341
|
+
clickableimage: entry({
|
|
342
|
+
name: 'clickableimage',
|
|
343
|
+
targets: 'web-only',
|
|
344
|
+
props: emptyProps,
|
|
345
|
+
degrade: omitDegrade,
|
|
346
|
+
}),
|
|
347
|
+
frame: entry({ name: 'frame', targets: 'web-only', props: emptyProps, degrade: omitDegrade }),
|
|
348
|
+
subpagelist: entry({
|
|
349
|
+
name: 'subpagelist',
|
|
350
|
+
targets: 'web-only',
|
|
351
|
+
props: emptyProps,
|
|
352
|
+
degrade: omitDegrade,
|
|
353
|
+
}),
|
|
354
|
+
subpagegrid: entry({
|
|
355
|
+
name: 'subpagegrid',
|
|
356
|
+
targets: 'web-only',
|
|
357
|
+
props: emptyProps,
|
|
358
|
+
degrade: omitDegrade,
|
|
359
|
+
}),
|
|
360
|
+
pagetable: entry({
|
|
361
|
+
name: 'pagetable',
|
|
362
|
+
targets: 'web-only',
|
|
363
|
+
props: emptyProps,
|
|
364
|
+
degrade: omitDegrade,
|
|
365
|
+
}),
|
|
366
|
+
pagecards: entry({
|
|
367
|
+
name: 'pagecards',
|
|
368
|
+
targets: 'web-only',
|
|
369
|
+
props: emptyProps,
|
|
370
|
+
degrade: omitDegrade,
|
|
371
|
+
}),
|
|
372
|
+
profilecard: entry({
|
|
373
|
+
name: 'profilecard',
|
|
374
|
+
targets: 'web-only',
|
|
375
|
+
props: emptyProps,
|
|
376
|
+
degrade: omitDegrade,
|
|
377
|
+
}),
|
|
378
|
+
readingguide: entry({
|
|
379
|
+
name: 'readingguide',
|
|
380
|
+
targets: 'web-only',
|
|
381
|
+
props: emptyProps,
|
|
382
|
+
degrade: omitDegrade,
|
|
383
|
+
}),
|
|
384
|
+
};
|
|
385
|
+
/**
|
|
386
|
+
* The canonical leo registry. Frozen so callers cannot mutate the allow-list at
|
|
387
|
+
* runtime. The port-backs (progress, card, metric, icon) are now `both`
|
|
388
|
+
* (their second-surface emitters have landed).
|
|
389
|
+
*/
|
|
390
|
+
export const leoRegistry = Object.freeze({
|
|
391
|
+
...sharedBoth,
|
|
392
|
+
...portBacks,
|
|
393
|
+
...subComponents,
|
|
394
|
+
...terminalOnly,
|
|
395
|
+
...webOnlyInline,
|
|
396
|
+
...webOnlyOmit,
|
|
397
|
+
});
|
|
398
|
+
// ── Resolution ────────────────────────────────────────────────────────────────
|
|
399
|
+
/**
|
|
400
|
+
* Resolve a lowercase authored name (`callout`) to its registry entry, against
|
|
401
|
+
* the provided registry root (the renderer always provides one — a missing root
|
|
402
|
+
* is a programmer error). Returns `undefined` for an unknown name; the
|
|
403
|
+
* caller treats unknown `<leo.X>` as an authoring error (a lint surfaces it —
|
|
404
|
+
* never silently rendered).
|
|
405
|
+
*/
|
|
406
|
+
export function resolve(name, registry = leoRegistry) {
|
|
407
|
+
// Guard with hasOwn so an inherited member (`toString`, `constructor`) never
|
|
408
|
+
// resolves as a fake island — `<leo.toString>` must be unknown, not a fn.
|
|
409
|
+
return Object.hasOwn(registry, name) ? registry[name] : undefined;
|
|
410
|
+
}
|
|
411
|
+
/** True iff `name` is in the allow-list. */
|
|
412
|
+
export function isKnown(name, registry = leoRegistry) {
|
|
413
|
+
return Object.hasOwn(registry, name);
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Coerce/validate raw (string) scanned attrs against a component's PropSchema.
|
|
417
|
+
* Attributes arrive as strings; per-prop the schema converts to the
|
|
418
|
+
* declared kind, applies defaults, and validates enums / required / JSON. An
|
|
419
|
+
* unknown attr (not in the schema) is dropped with a recorded error — the schema
|
|
420
|
+
* is the contract.
|
|
421
|
+
*/
|
|
422
|
+
export function coerceProps(schema, attrs) {
|
|
423
|
+
const props = {};
|
|
424
|
+
const errors = [];
|
|
425
|
+
for (const [key, decl] of Object.entries(schema)) {
|
|
426
|
+
const raw = attrs[key];
|
|
427
|
+
if (raw === undefined) {
|
|
428
|
+
if (decl.required) {
|
|
429
|
+
errors.push(`missing required prop "${key}"`);
|
|
430
|
+
}
|
|
431
|
+
else if (decl.default !== undefined) {
|
|
432
|
+
props[key] = decl.default;
|
|
433
|
+
}
|
|
434
|
+
continue;
|
|
435
|
+
}
|
|
436
|
+
const coerced = coerceOne(key, decl, raw, errors);
|
|
437
|
+
if (coerced !== undefined) {
|
|
438
|
+
props[key] = coerced;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
for (const key of Object.keys(attrs)) {
|
|
442
|
+
if (!Object.hasOwn(schema, key)) {
|
|
443
|
+
errors.push(`unknown prop "${key}"`);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
return { props, errors };
|
|
447
|
+
}
|
|
448
|
+
function coerceOne(key, decl, raw, errors) {
|
|
449
|
+
switch (decl.kind) {
|
|
450
|
+
case 'string':
|
|
451
|
+
return raw;
|
|
452
|
+
case 'number': {
|
|
453
|
+
const n = Number(raw);
|
|
454
|
+
if (Number.isNaN(n)) {
|
|
455
|
+
errors.push(`prop "${key}" is not a number: ${JSON.stringify(raw)}`);
|
|
456
|
+
return undefined;
|
|
457
|
+
}
|
|
458
|
+
return n;
|
|
459
|
+
}
|
|
460
|
+
case 'boolean':
|
|
461
|
+
// Bare attr (`highlight`) arrives as "" → true; `="false"` → false.
|
|
462
|
+
return raw === '' || raw === 'true';
|
|
463
|
+
case 'enum': {
|
|
464
|
+
if (decl.values && !decl.values.includes(raw)) {
|
|
465
|
+
errors.push(`prop "${key}" must be one of ${decl.values.join('|')}, got ${JSON.stringify(raw)}`);
|
|
466
|
+
return decl.default;
|
|
467
|
+
}
|
|
468
|
+
return raw;
|
|
469
|
+
}
|
|
470
|
+
case 'json': {
|
|
471
|
+
try {
|
|
472
|
+
return JSON.parse(raw);
|
|
473
|
+
}
|
|
474
|
+
catch {
|
|
475
|
+
errors.push(`prop "${key}" is not valid JSON`);
|
|
476
|
+
return undefined;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
default:
|
|
480
|
+
return raw;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACH,oBAAoB,EACpB,wBAAwB,EACxB,oBAAoB,GACvB,MAAM,oBAAoB,CAAC;AAG5B,iFAAiF;AAEjF,MAAM,YAAY,GAAe;IAC7B,4EAA4E;IAC5E,kEAAkE;IAClE,IAAI,EAAE;QACF,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,CAAC;QAChD,OAAO,EAAE,MAAM;QACf,IAAI,EAAE,0FAA0F;KACnG;IACD,KAAK,EAAE,EAAE,IAAI,EAAE,Q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K,QAAQ,EAAE,CAAC;YACZ,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;YACtB,IAAI,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;gBAClB,MAAM,CAAC,IAAI,CAAC,SAAS,GAAG,sBAAsB,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACrE,OAAO,SAAS,CAAC;YACrB,CAAC;YACD,OAAO,CAAC,CAAC;QACb,CAAC;QACD,KAAK,SAAS;YACV,oEAAoE;YACpE,OAAO,GAAG,KAAK,EAAE,IAAI,GAAG,KAAK,MAAM,CAAC;QACxC,KAAK,MAAM,EAAE,CAAC;YACV,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBAC5C,MAAM,CAAC,IAAI,CACP,SAAS,GAAG,oBAAoB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,CACtF,CAAC;gBACF,OAAO,IAAI,CAAC,OAAO,CAAC;YACxB,CAAC;YACD,OAAO,GAAG,CAAC;QACf,CAAC;QACD,KAAK,MAAM,EAAE,CAAC;YACV,IAAI,CAAC;gBACD,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC3B,CAAC;YAAC,MAAM,CAAC;gBACL,MAAM,CAAC,IAAI,CAAC,SAAS,GAAG,qBAAqB,CAAC,CAAC;gBAC/C,OAAO,SAAS,CAAC;YACrB,CAAC;QACL,CAAC;QACD;YACI,OAAO,GAAG,CAAC;IACnB,CAAC;AACL,CAAC","sourcesContent":["/**\n * The `leo` registry — the allow-list.\n *\n * A single object keyed by the LOWERCASE authored name (`leo.callout` resolves\n * `registry['callout']`). Each entry declares its `targets`, its canonical\n * `PropSchema` (the one contract both the ANSI and web emitters adapt to), its\n * Markdown flow placement,\n * and a `degrade` strategy for any surface it does not target.\n *\n * EMITTERS ARE NOT WIRED HERE. This module declares the vocabulary, targets,\n * placement, and prop schemas; the concrete `ansi` emitters are attached by\n * leo-pty-renderer and the `web` emitters by leo-doc-web.\n * The parity harness (src/parity.ts) checks the contract against whatever\n * registry it is given; the FULLY-WIRED registry only satisfies the `both`\n * entries once those emitters are attached.\n *\n * Prop-schema conflicts: where leo's ANSI attrs and Glottodoc's web props\n * disagree, leo's ANSI attrs WIN (the smaller, stable subset). Each such\n * choice is recorded inline as a `note` on the prop so the canonical decision is\n * auditable.\n */\n\nimport {\n AGENT_SUPPORT_AGENTS,\n AGENT_SUPPORT_QUALIFIERS,\n AGENT_SUPPORT_STATES,\n} from './agent-support.js';\nimport type { IslandFlow, LeoComponent, LeoRegistry, PropDecl, PropSchema } from './types.js';\n\n// ── Canonical prop schemas (grounded in the leo-pty-renderer ANSI signatures) ─\n\nconst calloutProps: PropSchema = {\n // leo ANSI CalloutType is the canonical enum (info|warning|success|danger);\n // Glottodoc's web Callout adapts its richer type list onto these.\n type: {\n kind: 'enum',\n values: ['info', 'warning', 'success', 'danger'],\n default: 'info',\n note: 'ANSI-wins: canonical enum is leo CalloutType; web maps note/tip/error/danger onto these.',\n },\n title: { kind: 'string' },\n};\n\nconst badgeProps: PropSchema = {\n // ANSI renderBadge(value): the value may also come from the body; the schema\n // declares the attr form.\n value: { kind: 'string' },\n};\n\n// StatusBadge ↔ leo `capsule`/`status`. Canonical authored name is `statusbadge`\n// (lowercase of the vocabulary entry); the ANSI side is renderCapsule(value).\nconst statusBadgeProps: PropSchema = {\n value: {\n kind: 'string',\n note: 'ANSI-wins: leo capsule/status takes a single `value`; web StatusBadge label maps to it.',\n },\n};\n\nconst agentSupportProps: PropSchema = {\n agent: { kind: 'enum', values: AGENT_SUPPORT_AGENTS, required: true },\n support: { kind: 'enum', values: AGENT_SUPPORT_STATES, required: true },\n qualifier: { kind: 'enum', values: AGENT_SUPPORT_QUALIFIERS },\n};\n\nconst stepsProps: PropSchema = {\n // Container; steps are nested <leo.step> islands (auto-numbered both sides).\n};\n\nconst stepProps: PropSchema = {\n title: { kind: 'string' },\n};\n\nconst treeProps: PropSchema = {\n // Container; nodes are nested <leo.folder>/<leo.file> islands.\n};\n\nconst treeNodeProps: PropSchema = {\n name: { kind: 'string', required: true },\n comment: { kind: 'string' },\n highlight: { kind: 'boolean', default: false },\n plainIcon: { kind: 'string' },\n};\n\nconst comparisonTableProps: PropSchema = {\n // Body is a markdown table; these are ANSI-only presentation hints (web\n // ignores them) — ANSI-wins by definition.\n highlight: {\n kind: 'string',\n note: 'ANSI-only presentation hint (row label to highlight); web has no equivalent.',\n },\n wrap: {\n kind: 'number',\n note: 'ANSI-only column-wrap width; web has no equivalent.',\n },\n};\n\nconst mermaidProps: PropSchema = {\n // Body is full mermaid source (flowchart, state, class, ER, sequence,\n // pie, mindmap, timeline, gitGraph); web target is a mermaid fence. No attrs.\n};\n\nconst heatmapProps: PropSchema = {\n // Body is a markdown table on terminal; the web chart reads the same cells.\n // `data` may also arrive JSON-encoded as an attribute.\n data: {\n kind: 'json',\n note: 'Same data, different form: ANSI table ⟷ web chart. JSON-coerced when given as an attr.',\n },\n};\n\nconst gitStatusProps: PropSchema = {\n // terminal-only: reads live git state; no web equivalent.\n};\n\nconst questionProps: PropSchema = {\n // Container; options are nested <leo.option> islands, notes is a nested\n // <leo.notes> island. Terminal-only — a chat question has no web analogue.\n prompt: { kind: 'string', required: true },\n label: { kind: 'string' },\n type: {\n kind: 'enum',\n values: ['architecture'],\n note: 'Prefixes the headline with the resolved leo-adr glyph (patched font, 🏛️ emoji fallback) — flags a decision that would set precedent across surfaces (new package, third-party dep, cross-package contract), same signal as the 🏛 marker in the spec-author skill.',\n },\n urgency: { kind: 'enum', values: ['low', 'normal', 'blocker'], default: 'normal' },\n multiSelect: { kind: 'boolean', default: false },\n freeText: { kind: 'boolean', default: false },\n recommendation: { kind: 'string', note: 'the recommended <leo.option key=...> value' },\n hint: {\n kind: 'boolean',\n default: true,\n note: 'Shows the trailing \"how to answer\" callout once per batch/message; set false on any question in the batch to suppress it (e.g. once the user already knows the convention).',\n },\n};\n\nconst optionProps: PropSchema = {\n key: { kind: 'string', required: true },\n label: { kind: 'string', required: true },\n recommendation: { kind: 'enum', values: ['high', 'medium', 'low', 'not-recommended'] },\n freeText: { kind: 'boolean', default: false },\n};\n\nconst notesProps: PropSchema = {\n // Container; body is markdown (rendered via renderMarkdown, fence-aware).\n};\n\n// ── Port-backs (flipped to `both`) ───────────────────────────────────────────\n\nconst progressProps: PropSchema = {\n // ANSI renderProgress(value, total, label, width). `width` is an ANSI-only\n // bar-width hint; web derives its own width from layout (ANSI-wins).\n value: { kind: 'number', default: 0 },\n total: { kind: 'number', default: 100 },\n label: { kind: 'string' },\n width: {\n kind: 'number',\n default: 20,\n note: 'ANSI-only bar width; web sizes from layout.',\n },\n};\n\nconst cardProps: PropSchema = {\n // The card resolver dispatches on `type` (plan/issue/review-dash/doc) on the\n // live ANSI path; `ref`/`path` carry the data-source. The web side maps onto\n // RichLink/MdxCard. Title/description are the generic fallback both surfaces\n // can render without a data source.\n type: {\n kind: 'enum',\n values: ['plan', 'issue', 'review-dash', 'doc'],\n note: 'ANSI-wins: the leo card-resolver dispatches on these types; web maps them onto RichLink/MdxCard.',\n },\n ref: { kind: 'string' },\n path: { kind: 'string' },\n title: { kind: 'string' },\n description: { kind: 'string' },\n href: { kind: 'string' },\n};\n\nconst metricProps: PropSchema = {\n // web Metric (KPI) is the origin; the ANSI emitter renders label+value+trend.\n label: { kind: 'string' },\n value: { kind: 'string' },\n trend: {\n kind: 'enum',\n values: ['up', 'down', 'flat'],\n note: 'ANSI-wins: canonical trend enum (up|down|flat); the ANSI glyph + web arrow both map to it.',\n },\n change: { kind: 'string' },\n};\n\nconst iconProps: PropSchema = {\n // web Icon (lucide) is the origin; the ANSI emitter resolves a leo glyph/emoji.\n icon: { kind: 'string' },\n color: { kind: 'string' },\n size: {\n kind: 'string',\n note: 'web-only sizing hint (px); the ANSI glyph is single-cell.',\n },\n};\n\n// web-only props are intentionally permissive for now — the absorbed React\n// components carry their own prop handling; the canonical schema is\n// filled in as those components are absorbed. Empty schemas here keep the\n// allow-list complete without over-specifying ahead of the absorb.\nconst emptyProps: PropSchema = {};\n\n// ── degrade strategies ────────────────────────────────────────────────────────\n\nconst inlineDegrade = { kind: 'inline' } as const;\nconst stackDegrade = { kind: 'inline' } as const;\nconst flatListDegrade = { kind: 'inline' } as const;\nconst omitDegrade = { kind: 'omit' } as const;\nconst noteDegrade = { kind: 'note', text: 'see terminal' } as const;\n\n// ── entry helpers ─────────────────────────────────────────────────────────────\n\nfunction entry(c: Omit<LeoComponent, 'flow'> & { readonly flow?: IslandFlow }): LeoComponent {\n return { flow: 'block', ...c };\n}\n\n// ── The registry ──────────────────────────────────────────────────────────────\n//\n// Keys are the LOWERCASE authored names. Emitters (`ansi`/`web`) are attached by\n// leo-pty-renderer and leo-doc-web; here only `targets`, `props`, and\n// (off-surface) `degrade` are set.\n\n/** Shared `targets: both` entries (parity-enforced once emitters land). */\nconst sharedBoth: Record<string, LeoComponent> = {\n callout: entry({ name: 'callout', targets: 'both', props: calloutProps }),\n badge: entry({ name: 'badge', flow: 'inline', targets: 'both', props: badgeProps }),\n statusbadge: entry({\n name: 'statusbadge',\n flow: 'inline',\n targets: 'both',\n props: statusBadgeProps,\n }),\n agentsupport: entry({\n name: 'agentsupport',\n flow: 'inline',\n targets: 'both',\n props: agentSupportProps,\n }),\n steps: entry({ name: 'steps', targets: 'both', props: stepsProps }),\n tree: entry({ name: 'tree', targets: 'both', props: treeProps }),\n comparisontable: entry({\n name: 'comparisontable',\n targets: 'both',\n props: comparisonTableProps,\n }),\n mermaid: entry({ name: 'mermaid', targets: 'both', props: mermaidProps }),\n heatmap: entry({ name: 'heatmap', targets: 'both', props: heatmapProps }),\n};\n\n/**\n * Port-backs — now `targets: 'both'`. Each gained its second-surface\n * emitter (progress/card → web; metric/icon → terminal), so they\n * render to both surfaces and the parity harness enforces both emitters.\n */\nconst portBacks: Record<string, LeoComponent> = {\n progress: entry({ name: 'progress', targets: 'both', props: progressProps }),\n card: entry({ name: 'card', targets: 'both', props: cardProps }),\n metric: entry({ name: 'metric', targets: 'both', props: metricProps }),\n icon: entry({ name: 'icon', flow: 'inline', targets: 'both', props: iconProps }),\n};\n\n/**\n * Sub-components nested inside container `both` entries. `step`, `folder`, `file`\n * are resolved by the scanner within a parent body, not standalone — they ride\n * their parent's parity, so they are declared `both` with the parent and carry\n * no independent degrade.\n */\nconst subComponents: Record<string, LeoComponent> = {\n step: entry({ name: 'step', targets: 'both', props: stepProps }),\n folder: entry({ name: 'folder', targets: 'both', props: treeNodeProps }),\n file: entry({ name: 'file', targets: 'both', props: treeNodeProps }),\n // Abstract IA node (not a file/folder) — same tree container semantics as\n // folder (parseTreeNodeList treats folder/node identically as containers).\n node: entry({ name: 'node', targets: 'both', props: treeNodeProps }),\n // question/option/notes are terminal-only (see terminalOnly below), so\n // their sub-components ride THAT parity, not `both`.\n option: entry({\n name: 'option',\n targets: 'terminal-only',\n props: optionProps,\n degrade: noteDegrade,\n }),\n notes: entry({\n name: 'notes',\n targets: 'terminal-only',\n props: notesProps,\n degrade: noteDegrade,\n }),\n};\n\n/**\n * terminal-only (2): git-status reads live git state; question is a chat/CLI\n * question prompt (option/notes above are its nested sub-components). Neither\n * has a web equivalent — both degrade to a static note.\n */\nconst terminalOnly: Record<string, LeoComponent> = {\n 'git-status': entry({\n name: 'git-status',\n targets: 'terminal-only',\n props: gitStatusProps,\n degrade: noteDegrade,\n }),\n question: entry({\n name: 'question',\n targets: 'terminal-only',\n props: questionProps,\n degrade: noteDegrade,\n }),\n};\n\n/**\n * web-only entries that DEGRADE TO INLINE on terminal. Declared\n * so authored docs don't error on terminal — they degrade per strategy. The web\n * emitters are wired by leo-doc-web; here only targets + degrade are pinned.\n */\nconst webOnlyInline: Record<string, LeoComponent> = {\n accordion: entry({\n name: 'accordion',\n targets: 'web-only',\n props: emptyProps,\n degrade: inlineDegrade,\n }),\n expandable: entry({\n name: 'expandable',\n targets: 'web-only',\n props: emptyProps,\n degrade: inlineDegrade,\n }),\n tabs: entry({ name: 'tabs', targets: 'web-only', props: emptyProps, degrade: inlineDegrade }),\n tooltip: entry({\n name: 'tooltip',\n flow: 'inline',\n targets: 'web-only',\n props: emptyProps,\n degrade: inlineDegrade,\n }),\n columns: entry({\n name: 'columns',\n targets: 'web-only',\n props: emptyProps,\n degrade: stackDegrade,\n }),\n tiles: entry({ name: 'tiles', targets: 'web-only', props: emptyProps, degrade: stackDegrade }),\n toc: entry({ name: 'toc', targets: 'web-only', props: emptyProps, degrade: flatListDegrade }),\n};\n\n/**\n * web-only entries with NO terminal meaning — they\n * omit on terminal. Charts/images/embeds/nav-context + ProfileCard/ReadingGuide.\n */\nconst webOnlyOmit: Record<string, LeoComponent> = {\n scoreradar: entry({\n name: 'scoreradar',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n starchart: entry({\n name: 'starchart',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n imagegallery: entry({\n name: 'imagegallery',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n imagelightbox: entry({\n name: 'imagelightbox',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n clickableimage: entry({\n name: 'clickableimage',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n frame: entry({ name: 'frame', targets: 'web-only', props: emptyProps, degrade: omitDegrade }),\n subpagelist: entry({\n name: 'subpagelist',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n subpagegrid: entry({\n name: 'subpagegrid',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n pagetable: entry({\n name: 'pagetable',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n pagecards: entry({\n name: 'pagecards',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n profilecard: entry({\n name: 'profilecard',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n readingguide: entry({\n name: 'readingguide',\n targets: 'web-only',\n props: emptyProps,\n degrade: omitDegrade,\n }),\n};\n\n/**\n * The canonical leo registry. Frozen so callers cannot mutate the allow-list at\n * runtime. The port-backs (progress, card, metric, icon) are now `both`\n * (their second-surface emitters have landed).\n */\nexport const leoRegistry: LeoRegistry = Object.freeze({\n ...sharedBoth,\n ...portBacks,\n ...subComponents,\n ...terminalOnly,\n ...webOnlyInline,\n ...webOnlyOmit,\n});\n\n// ── Resolution ────────────────────────────────────────────────────────────────\n\n/**\n * Resolve a lowercase authored name (`callout`) to its registry entry, against\n * the provided registry root (the renderer always provides one — a missing root\n * is a programmer error). Returns `undefined` for an unknown name; the\n * caller treats unknown `<leo.X>` as an authoring error (a lint surfaces it —\n * never silently rendered).\n */\nexport function resolve(\n name: string,\n registry: LeoRegistry = leoRegistry\n): LeoComponent | undefined {\n // Guard with hasOwn so an inherited member (`toString`, `constructor`) never\n // resolves as a fake island — `<leo.toString>` must be unknown, not a fn.\n return Object.hasOwn(registry, name) ? registry[name] : undefined;\n}\n\n/** True iff `name` is in the allow-list. */\nexport function isKnown(name: string, registry: LeoRegistry = leoRegistry): boolean {\n return Object.hasOwn(registry, name);\n}\n\n// ── Prop coercion ─────────────────────────────────────────────────────────────\n\nexport interface CoerceResult {\n /** Coerced props (defaults applied, types converted). */\n readonly props: Record<string, unknown>;\n /** Validation errors (unknown enum value, missing required, bad JSON). */\n readonly errors: readonly string[];\n}\n\n/**\n * Coerce/validate raw (string) scanned attrs against a component's PropSchema.\n * Attributes arrive as strings; per-prop the schema converts to the\n * declared kind, applies defaults, and validates enums / required / JSON. An\n * unknown attr (not in the schema) is dropped with a recorded error — the schema\n * is the contract.\n */\nexport function coerceProps(\n schema: PropSchema,\n attrs: Readonly<Record<string, string>>\n): CoerceResult {\n const props: Record<string, unknown> = {};\n const errors: string[] = [];\n\n for (const [key, decl] of Object.entries(schema)) {\n const raw = attrs[key];\n if (raw === undefined) {\n if (decl.required) {\n errors.push(`missing required prop \"${key}\"`);\n } else if (decl.default !== undefined) {\n props[key] = decl.default;\n }\n continue;\n }\n const coerced = coerceOne(key, decl, raw, errors);\n if (coerced !== undefined) {\n props[key] = coerced;\n }\n }\n\n for (const key of Object.keys(attrs)) {\n if (!Object.hasOwn(schema, key)) {\n errors.push(`unknown prop \"${key}\"`);\n }\n }\n\n return { props, errors };\n}\n\nfunction coerceOne(key: string, decl: PropDecl, raw: string, errors: string[]): unknown {\n switch (decl.kind) {\n case 'string':\n return raw;\n case 'number': {\n const n = Number(raw);\n if (Number.isNaN(n)) {\n errors.push(`prop \"${key}\" is not a number: ${JSON.stringify(raw)}`);\n return undefined;\n }\n return n;\n }\n case 'boolean':\n // Bare attr (`highlight`) arrives as \"\" → true; `=\"false\"` → false.\n return raw === '' || raw === 'true';\n case 'enum': {\n if (decl.values && !decl.values.includes(raw)) {\n errors.push(\n `prop \"${key}\" must be one of ${decl.values.join('|')}, got ${JSON.stringify(raw)}`\n );\n return decl.default;\n }\n return raw;\n }\n case 'json': {\n try {\n return JSON.parse(raw);\n } catch {\n errors.push(`prop \"${key}\" is not valid JSON`);\n return undefined;\n }\n }\n default:\n return raw;\n }\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `<leo.*>` island scanner (ADR-D-01KVQHTWH8MQ).
|
|
3
|
+
*
|
|
4
|
+
* A single-pass, quote-aware, balanced-nesting scanner that finds `<leo.*>`
|
|
5
|
+
* islands in a source string and returns the document as an ordered list of
|
|
6
|
+
* spans — prose passes through VERBATIM; each island is extracted with its raw
|
|
7
|
+
* attrs and balanced body; a `<leo.` opener that cannot be parsed DEGRADES to a
|
|
8
|
+
* malformed span (preserved as text) rather than stalling or dropping the rest.
|
|
9
|
+
*
|
|
10
|
+
* It is the SOLE resolution path on both surfaces (terminal + web), so the two
|
|
11
|
+
* cannot diverge. It claims ONLY `<leo.*>` (the namespace allow-list); every
|
|
12
|
+
* other angle bracket — `<div>`, `<Callout>`, autolinks, code spans, `a < b` —
|
|
13
|
+
* passes through untouched.
|
|
14
|
+
*
|
|
15
|
+
* Fixes the three silent-mangle cases the PoC proved in the old regex/nextLeoTag
|
|
16
|
+
* parser:
|
|
17
|
+
* 1. `value="a > b"` — quote-aware attr scan; `>` inside quotes is not the end.
|
|
18
|
+
* 2. callout-in-callout — depth-counted body scan over the SAME tag name.
|
|
19
|
+
* 3. unterminated opener — degrades to a malformed span; surrounding prose kept.
|
|
20
|
+
*
|
|
21
|
+
* Tag names are LOWERCASE-ONLY. `<leo.Callout>` (PascalCase) is NOT a
|
|
22
|
+
* leo island — the scanner does not claim it (a lint rejects the authoring form
|
|
23
|
+
* separately). The dot is a literal character in the name, not a namespace
|
|
24
|
+
* lookup.
|
|
25
|
+
*/
|
|
26
|
+
import type { DocSpan } from './types.js';
|
|
27
|
+
/**
|
|
28
|
+
* Scan a source string into ordered spans. Prose between islands is preserved
|
|
29
|
+
* verbatim; islands carry raw (pre-coercion) attrs + balanced body; an
|
|
30
|
+
* unparseable `<leo.` opener becomes a malformed span.
|
|
31
|
+
*/
|
|
32
|
+
export declare function scan(source: string): DocSpan[];
|
|
33
|
+
/**
|
|
34
|
+
* Parse `key="value"` / `key='value'` (and bare `key`) attribute pairs from an
|
|
35
|
+
* opening tag's attribute string. Quote-aware so a `>` inside a value is part of
|
|
36
|
+
* the value (the scanner already kept it inside `attrsRaw`). A bare attribute
|
|
37
|
+
* with no `=` becomes `key -> ""` (the schema coerces a boolean from presence).
|
|
38
|
+
*/
|
|
39
|
+
export declare function parseAttrs(attrsRaw: string): Record<string, string>;
|
|
40
|
+
//# sourceMappingURL=scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAwC,MAAM,YAAY,CAAC;AAYhF;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,EAAE,CAuD9C;AA4MD;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAiBnE"}
|