asyncapi-viewer 2.0.0 → 2.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.
Files changed (39) hide show
  1. package/README.md +13 -3
  2. package/dist/asyncapi-viewer.iife.js +22 -22
  3. package/dist/asyncapi-viewer.iife.js.map +1 -1
  4. package/dist/asyncapi-viewer.js +179 -132
  5. package/dist/asyncapi-viewer.js.map +1 -1
  6. package/dist/types/element.d.ts +33 -0
  7. package/dist/types/events.d.ts +99 -0
  8. package/dist/types/index.d.ts +12 -0
  9. package/dist/types/load/loader.d.ts +46 -0
  10. package/dist/types/load/refs.d.ts +62 -0
  11. package/dist/types/model/avro.d.ts +14 -0
  12. package/dist/types/model/context.d.ts +75 -0
  13. package/dist/types/model/invariants.d.ts +7 -0
  14. package/dist/types/model/normalize.d.ts +16 -0
  15. package/dist/types/model/schema.d.ts +16 -0
  16. package/dist/types/model/types.d.ts +324 -0
  17. package/dist/types/model/v2.d.ts +8 -0
  18. package/dist/types/model/v3.d.ts +8 -0
  19. package/dist/types/options.d.ts +56 -0
  20. package/dist/types/render/details.d.ts +23 -0
  21. package/dist/types/render/example.d.ts +36 -0
  22. package/dist/types/render/format.d.ts +2 -0
  23. package/dist/types/render/header.d.ts +19 -0
  24. package/dist/types/render/info.d.ts +4 -0
  25. package/dist/types/render/markdown.d.ts +4 -0
  26. package/dist/types/render/nav.d.ts +69 -0
  27. package/dist/types/render/operation.d.ts +18 -0
  28. package/dist/types/render/sections.d.ts +17 -0
  29. package/dist/types/render/sidebar.d.ts +30 -0
  30. package/dist/types/render/tag.d.ts +7 -0
  31. package/dist/types/render/tree.d.ts +36 -0
  32. package/dist/types/styles/base.d.ts +2 -0
  33. package/dist/types/styles/tokens.d.ts +7 -0
  34. package/dist/types/theme/theme.d.ts +26 -0
  35. package/dist/types/util/color.d.ts +22 -0
  36. package/dist/types/util/example.d.ts +8 -0
  37. package/package.json +12 -3
  38. package/types/react.d.ts +28 -0
  39. package/types/react.js +2 -0
@@ -0,0 +1,324 @@
1
+ /**
2
+ * The normalised model.
3
+ *
4
+ * One shape for AsyncAPI 2 and 3. The normalisers (model/v2.ts, model/v3.ts) are the only code
5
+ * that knows spec field names; the render layer, the theme and the Python search fallback all
6
+ * work from this model. The UI may branch on `specMajor` only where specs/viewer-spec.md 3.4
7
+ * allows it: parameter `schemaType` (v2), server host display, and the header badge.
8
+ *
9
+ * Conventions:
10
+ * - Arrays are always present (possibly empty); optional scalars are absent, never null,
11
+ * with one exception: `Channel.address` is `null` when the document leaves it unset.
12
+ * - `id` is the key in the source document. `anchor` is the sanitised, document-unique slug used
13
+ * in page anchors `#<element id>--<section>--<anchor>` (ROADMAP amendment 10). The element id is
14
+ * not part of the model, so several viewers on one page can share a model.
15
+ * - Text marked "markdown" is rendered through markdown-it with HTML disabled. Nothing in the
16
+ * model is ever inserted as HTML.
17
+ * - Authored examples only. Generated examples (ROADMAP amendment 9) are produced from a
18
+ * `SchemaNode` at render time and never stored in the model, so snapshots stay stable.
19
+ */
20
+ export type SpecMajor = 2 | 3;
21
+ export type SectionId = 'info' | 'servers' | 'operations' | 'messages' | 'schemas' | 'problems';
22
+ export interface Document {
23
+ /** Exact version string from the document, e.g. "3.0.0" or "2.6.0". */
24
+ specVersion: string;
25
+ /** The only version switch the UI may use (spec 3.4). */
26
+ specMajor: SpecMajor;
27
+ title: string;
28
+ version: string;
29
+ /** markdown */
30
+ description?: string;
31
+ termsOfService?: string;
32
+ contact?: Contact;
33
+ license?: License;
34
+ externalDocs?: ExternalDocs;
35
+ /** Document-level tags: v3 `info.tags`, v2 root `tags`. Drive `bySpecTags` grouping. */
36
+ tags: Tag[];
37
+ defaultContentType?: string;
38
+ servers: Server[];
39
+ operations: Operation[];
40
+ /** `components.messages`, in document order. */
41
+ messages: Message[];
42
+ /** `components.schemas`, in document order. */
43
+ schemas: NamedSchema[];
44
+ /** Anything skipped or suspicious. Rendered by the Problems section when `errors` is on. */
45
+ problems: Problem[];
46
+ }
47
+ export interface Contact {
48
+ name?: string;
49
+ url?: string;
50
+ email?: string;
51
+ }
52
+ export interface License {
53
+ name: string;
54
+ url?: string;
55
+ }
56
+ export interface ExternalDocs {
57
+ url: string;
58
+ /** markdown */
59
+ description?: string;
60
+ }
61
+ export interface Tag {
62
+ name: string;
63
+ /** markdown */
64
+ description?: string;
65
+ externalDocs?: ExternalDocs;
66
+ }
67
+ export interface Server {
68
+ id: string;
69
+ anchor: string;
70
+ title?: string;
71
+ summary?: string;
72
+ /** markdown */
73
+ description?: string;
74
+ protocol: string;
75
+ protocolVersion?: string;
76
+ /** v3: `host` + `pathname`; v2: `url`. Shown as is. */
77
+ hostDisplay: string;
78
+ variables: ServerVariable[];
79
+ security: SecurityRequirement[];
80
+ tags: Tag[];
81
+ externalDocs?: ExternalDocs;
82
+ bindings: Binding[];
83
+ }
84
+ export interface ServerVariable {
85
+ name: string;
86
+ /** markdown */
87
+ description?: string;
88
+ enum?: string[];
89
+ default?: string;
90
+ examples?: string[];
91
+ }
92
+ /** The application's side of the channel. v2 `publish` normalises to `receive`, `subscribe` to `send`. */
93
+ export type OperationAction = 'send' | 'receive';
94
+ /** `request` and `reply` are v3 operations that carry a `reply`; the badge label follows `kind`. */
95
+ export type OperationKind = 'send' | 'receive' | 'request' | 'reply';
96
+ export interface Operation {
97
+ /** v3: the operation key. v2: `operationId`, else `<publish|subscribe>-<channel key>`. */
98
+ id: string;
99
+ anchor: string;
100
+ /** v3: `title`, else id; with `useChannelAddressAsIdentifier` the channel address. v2: id. */
101
+ heading: string;
102
+ action: OperationAction;
103
+ kind: OperationKind;
104
+ /** Resolved from the label options at normalisation time (e.g. "SEND", "PUB"). */
105
+ badgeLabel: string;
106
+ /** Small mono line above the heading. v3: operation key; v2: `channels › <key> › <publish|subscribe>`. */
107
+ locationHint: string;
108
+ channel: Channel;
109
+ summary?: string;
110
+ /** markdown */
111
+ description?: string;
112
+ tags: Tag[];
113
+ externalDocs?: ExternalDocs;
114
+ /** The messages this operation may carry. Several means a tab row in the UI. */
115
+ messages: Message[];
116
+ reply?: Reply;
117
+ security: SecurityRequirement[];
118
+ bindings: Binding[];
119
+ }
120
+ export interface Channel {
121
+ /** v3: the channel key. v2: the channel key, which is also the address. */
122
+ id: string;
123
+ /** `null` when the document does not set one (v3 only). UI shows "Address not specified". */
124
+ address: string | null;
125
+ title?: string;
126
+ summary?: string;
127
+ /** markdown */
128
+ description?: string;
129
+ parameters: Parameter[];
130
+ /** Server ids this channel is available on. Empty means all servers. */
131
+ servers: string[];
132
+ tags: Tag[];
133
+ externalDocs?: ExternalDocs;
134
+ bindings: Binding[];
135
+ }
136
+ export interface Parameter {
137
+ name: string;
138
+ /** markdown */
139
+ description?: string;
140
+ enum?: string[];
141
+ default?: string;
142
+ examples?: string[];
143
+ location?: string;
144
+ /** v2 only: the parameter schema's type (spec 3.4). */
145
+ schemaType?: string;
146
+ }
147
+ export interface Reply {
148
+ /** Static reply channel, when the document declares one. */
149
+ channel?: Channel;
150
+ /** Dynamic reply address (`address.location`), when the document declares one instead. */
151
+ addressLocation?: string;
152
+ /** markdown; description of the dynamic address */
153
+ addressDescription?: string;
154
+ /** Reply messages as compact references to their definitions. */
155
+ messages: MessageRef[];
156
+ }
157
+ export interface MessageRef {
158
+ id: string;
159
+ anchor: string;
160
+ name?: string;
161
+ title?: string;
162
+ }
163
+ export interface Message {
164
+ /** The `components.messages` key, or the channel-level message key for inline messages. */
165
+ id: string;
166
+ anchor: string;
167
+ name?: string;
168
+ title?: string;
169
+ summary?: string;
170
+ /** markdown */
171
+ description?: string;
172
+ /** Resolved: message `contentType`, else document `defaultContentType`, else "application/json". */
173
+ contentType: string;
174
+ /** Resolved: message `schemaFormat`, else the default for the spec version. */
175
+ schemaFormat: string;
176
+ payload?: Schema;
177
+ headers?: Schema;
178
+ correlationId?: CorrelationId;
179
+ /** Authored examples only (v2.2+ and v3). See the file comment on generated examples. */
180
+ examples: MessageExample[];
181
+ tags: Tag[];
182
+ externalDocs?: ExternalDocs;
183
+ bindings: Binding[];
184
+ }
185
+ export interface CorrelationId {
186
+ location: string;
187
+ /** markdown */
188
+ description?: string;
189
+ }
190
+ export interface MessageExample {
191
+ name?: string;
192
+ summary?: string;
193
+ /** Parsed value from the document, rendered as JSON. */
194
+ payload?: unknown;
195
+ headers?: unknown;
196
+ }
197
+ /** A payload or headers schema: either a tree we understand, or a raw block we only display. */
198
+ export type Schema = SchemaNode | RawSchema;
199
+ /** Non-JSON-Schema formats (Avro, Protobuf, RAML, ...): shown as a labelled code block. */
200
+ export interface RawSchema {
201
+ kind: 'raw';
202
+ schemaFormat: string;
203
+ /** The schema exactly as written, serialised to text if it was an object. */
204
+ source: string;
205
+ }
206
+ export interface SchemaNode {
207
+ kind: 'node';
208
+ /**
209
+ * Property name. Root nodes use "" (payload, headers) or the schema key (components.schemas).
210
+ * The item schema of an array is a child named "[]".
211
+ */
212
+ name: string;
213
+ /**
214
+ * Display path, one segment per level, excluding the root and this node, so a root always has
215
+ * `[]`. The item node of an array has the array's name as its last segment and contributes no
216
+ * segment of its own: its children start with `"items[]"` instead, so a node three levels under
217
+ * an array reads `["items[]", "customisation", "engraving"]` (spec 4.8 path line).
218
+ */
219
+ path: string[];
220
+ /** JSON Schema `type` as a list: `["string"]`, `["string", "null"]`; empty when untyped. */
221
+ types: string[];
222
+ format?: string;
223
+ /** From the parent's `required` array. Always false on root nodes. */
224
+ required: boolean;
225
+ title?: string;
226
+ /** markdown */
227
+ description?: string;
228
+ enum?: unknown[];
229
+ const?: unknown;
230
+ default?: unknown;
231
+ examples?: unknown[];
232
+ deprecated?: boolean;
233
+ readOnly?: boolean;
234
+ writeOnly?: boolean;
235
+ /** min/max, length, pattern and friends, in a stable display order. */
236
+ constraints: Constraint[];
237
+ /** Object properties, or the single "[]" item node for arrays. Empty for leaves. */
238
+ children: SchemaNode[];
239
+ /** `oneOf` / `anyOf` variants. `allOf` is merged into `children` and never appears here. */
240
+ composition?: Composition;
241
+ /** Set when this node is a `$ref` to a `components.schemas` entry; links to the Schemas section. */
242
+ refName?: string;
243
+ /**
244
+ * Set instead of children when the node refers back to an ancestor. Names the referenced
245
+ * schema; the UI renders "Circular reference to <name>" with a link.
246
+ */
247
+ circularRef?: string;
248
+ }
249
+ export interface Composition {
250
+ kind: 'oneOf' | 'anyOf';
251
+ variants: SchemaVariant[];
252
+ }
253
+ export interface SchemaVariant {
254
+ /** The variant schema's `title`, else "Variant N". */
255
+ title: string;
256
+ node: SchemaNode;
257
+ }
258
+ export type ConstraintKey = 'minimum' | 'exclusiveMinimum' | 'maximum' | 'exclusiveMaximum' | 'multipleOf' | 'minLength' | 'maxLength' | 'pattern' | 'minItems' | 'maxItems' | 'uniqueItems' | 'minProperties' | 'maxProperties';
259
+ export interface Constraint {
260
+ key: ConstraintKey;
261
+ value: number | string | boolean;
262
+ }
263
+ export interface NamedSchema {
264
+ /** The `components.schemas` key. */
265
+ id: string;
266
+ anchor: string;
267
+ schema: Schema;
268
+ }
269
+ export type BindingScope = 'server' | 'channel' | 'operation' | 'message';
270
+ /**
271
+ * One chip: `<scope>.<key> <value>`, e.g. `channel.partitions 12`. `bindingVersion` is emitted as
272
+ * a binding of its own so new binding fields need no code changes.
273
+ */
274
+ export interface Binding {
275
+ scope: BindingScope;
276
+ protocol: string;
277
+ key: string;
278
+ value: unknown;
279
+ }
280
+ /** A resolved security requirement: the scheme inlined, plus the scopes requested. */
281
+ export interface SecurityScope {
282
+ name: string;
283
+ description: string;
284
+ }
285
+ /** One OAuth 2 flow with the URLs a reader needs and the scopes it offers. */
286
+ export interface SecurityFlow {
287
+ /** implicit, password, clientCredentials or authorizationCode. */
288
+ kind: string;
289
+ authorizationUrl?: string;
290
+ tokenUrl?: string;
291
+ refreshUrl?: string;
292
+ scopes: SecurityScope[];
293
+ }
294
+ export interface SecurityRequirement {
295
+ /** The `components.securitySchemes` key. */
296
+ id: string;
297
+ type: string;
298
+ /** markdown */
299
+ description?: string;
300
+ /** Scopes this requirement asks for (the requirement's own list). */
301
+ scopes: string[];
302
+ /** Scheme facts worth reading: apiKey `in`, httpApiKey `name` and `in`, http `scheme` and `bearerFormat`. Only when there are any. */
303
+ facts?: Array<{
304
+ label: string;
305
+ value: string;
306
+ }>;
307
+ /** openIdConnect: the discovery URL. */
308
+ openIdConnectUrl?: string;
309
+ /** oauth2: the flows, only when the scheme defines any. */
310
+ flows?: SecurityFlow[];
311
+ /** Specification extensions (`x-` fields) on the scheme, prefix kept, in document order. Only when there are any. */
312
+ extensions?: Array<{
313
+ key: string;
314
+ value: unknown;
315
+ }>;
316
+ }
317
+ export type ProblemSeverity = 'error' | 'warning';
318
+ export interface Problem {
319
+ severity: ProblemSeverity;
320
+ /** Plain text, one sentence. */
321
+ message: string;
322
+ /** Where in the source document, as a JSON pointer such as "/channels/orders/messages/0". */
323
+ where: string;
324
+ }
@@ -0,0 +1,8 @@
1
+ /**
2
+ * AsyncAPI 2 normaliser. Direction mapping is the rule to remember: in v2, `publish` describes
3
+ * what the application receives and `subscribe` what it sends. The badge keeps the raw keyword
4
+ * (`PUB` / `SUB` by default), the location hint keeps the channel path.
5
+ */
6
+ import { Context, type Obj } from './context.js';
7
+ import type { Document } from './types.js';
8
+ export declare function normalizeV2(ctx: Context, root: Obj, specVersion: string): Document;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * AsyncAPI 3 normaliser. The only code that knows v3 field names for info, servers, channels,
3
+ * operations, messages and reply. Traits, security details and bindings edge cases are refined
4
+ * in chunk 1.7; this chunk establishes the shape.
5
+ */
6
+ import { Context, type Obj } from './context.js';
7
+ import type { Document } from './types.js';
8
+ export declare function normalizeV3(ctx: Context, root: Obj, specVersion: string): Document;
@@ -0,0 +1,56 @@
1
+ export type GroupServers = 'byDefault' | 'bySpecTags' | 'byServersTags';
2
+ export type GroupOperations = 'byDefault' | 'bySpecTags' | 'byOperationsTags';
3
+ export type ThemeMode = 'auto' | 'light' | 'dark';
4
+ export interface Options {
5
+ src?: string;
6
+ id?: string;
7
+ sidebar: boolean;
8
+ info: boolean;
9
+ servers: boolean;
10
+ operations: boolean;
11
+ messages: boolean;
12
+ schemas: boolean;
13
+ errors: boolean;
14
+ showMessageExamples: boolean;
15
+ messageExamples: boolean;
16
+ showServers: GroupServers;
17
+ showOperations: GroupOperations;
18
+ useChannelAddressAsIdentifier: boolean;
19
+ publishLabel: string;
20
+ subscribeLabel: string;
21
+ sendLabel: string;
22
+ receiveLabel: string;
23
+ requestLabel: string;
24
+ replyLabel: string;
25
+ parserOptions: {
26
+ applyTraits: boolean;
27
+ };
28
+ theme: ThemeMode;
29
+ themeToggle: boolean;
30
+ searchKeepSections: boolean;
31
+ }
32
+ export type OptionType = 'string' | 'boolean' | 'enum' | 'json';
33
+ export type OptionStatus = 'active' | 'deprecated-noop';
34
+ export interface OptionSpec {
35
+ name: string;
36
+ type: OptionType;
37
+ default?: unknown;
38
+ required?: boolean;
39
+ values?: string[];
40
+ keys?: Record<string, 'boolean' | 'string' | 'number'>;
41
+ status: OptionStatus;
42
+ specVersions: number[];
43
+ description: string;
44
+ }
45
+ export declare const OPTION_SPECS: readonly OptionSpec[];
46
+ /** Defaults derived from the schema; `src`, `id` and deprecated options have none. */
47
+ export declare const DEFAULTS: Readonly<Options>;
48
+ export declare function lookupOption(attribute: string): OptionSpec | undefined;
49
+ /** `sendLabel` -> `send-label`: the form the Python side emits. */
50
+ export declare function toAttributeName(option: string): string;
51
+ export type WarnFn = (message: string) => void;
52
+ /**
53
+ * Build Options from attributes. `attrs` is any iterable of `[name, value]`; a `null` value is a
54
+ * bare attribute. `src` and `id` pass through untouched.
55
+ */
56
+ export declare function parseOptions(attrs: Iterable<readonly [string, string | null]>, warn?: WarnFn): Options;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Shared detail blocks: the Parameters table, binding and security chips and the reply
3
+ * block (spec 4.7 items 5, 7, 8, 9). Servers reuse the chips in their split style.
4
+ */
5
+ import { nothing, type TemplateResult } from 'lit';
6
+ import type { Binding, Parameter, Reply, SecurityRequirement } from '../model/types.js';
7
+ export declare const detailStyles: import("lit").CSSResult;
8
+ export declare function renderParameters(parameters: Parameter[], anchor: string): TemplateResult | typeof nothing;
9
+ export type BindingStyle = 'pill' | 'split';
10
+ /**
11
+ * Nested binding objects become one chip per leaf value with a dotted key
12
+ * (`topicConfiguration.retention.ms 60000000`); scalar arrays are joined; schema-shaped
13
+ * values (Kafka groupId) stay one chip showing the schema's type and description.
14
+ */
15
+ export declare function flattenBinding(b: Binding): Array<{
16
+ key: string;
17
+ value: unknown;
18
+ }>;
19
+ /** Chips reading `<scope>.<key> <value>`; empty when there are none. */
20
+ export declare function renderBindings(bindings: Binding[], title?: string, style?: BindingStyle): TemplateResult | typeof nothing;
21
+ /** Security requirements as chips (spec 4.7 item 9). `serversHref` links each scheme to the Servers section. */
22
+ export declare function renderSecurity(security: SecurityRequirement[], style?: BindingStyle, serversHref?: string): TemplateResult | typeof nothing;
23
+ export declare function renderReply(reply: Reply, prefix: string): TemplateResult;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The example panel (spec 4.7): a dark column beside the operation content with the message
3
+ * name, Payload and Headers tabs, a Copy button that announces through a live region,
4
+ * line-numbered highlighted JSON, a select when there are several examples, and the correlation
5
+ * id location. When `messageExamples` is off the panel starts collapsed to a "Show example" bar.
6
+ * Messages without an authored example get one generated from the schema (amendment 9).
7
+ */
8
+ import { nothing, type TemplateResult } from 'lit';
9
+ import type { Message } from '../model/types.js';
10
+ export declare const exampleStyles: import("lit").CSSResult;
11
+ export interface ExamplePanelState {
12
+ tab: 'payload' | 'headers';
13
+ index: number;
14
+ open: boolean | undefined;
15
+ copied: 'copied' | 'failed' | undefined;
16
+ }
17
+ export interface ExampleContext {
18
+ state: ExamplePanelState;
19
+ /** Whether panels start open (`messageExamples` option). */
20
+ defaultOpen: boolean;
21
+ onChange: () => void;
22
+ }
23
+ export interface ResolvedExample {
24
+ label: string;
25
+ payload: unknown;
26
+ headers: unknown;
27
+ generated: boolean;
28
+ }
29
+ /** Authored examples, or one generated from the schemas. */
30
+ export declare function examplesFor(message: Message): ResolvedExample[];
31
+ export declare function isPanelOpen(ctx: ExampleContext): boolean;
32
+ /** The slim bar shown in the content column while the panel is collapsed. */
33
+ export declare function renderShowExample(ctx: ExampleContext): TemplateResult;
34
+ export declare function renderExamplePanel(message: Message, examples: ResolvedExample[], ctx: ExampleContext, panelId: string): TemplateResult | typeof nothing;
35
+ /** Tokenise pretty-printed JSON into spans, one grid row per line for the line numbers. */
36
+ export declare function highlight(text: string): TemplateResult[];
@@ -0,0 +1,2 @@
1
+ /** Short labels for schema formats, for the "contentType · format" line (design: "JSON Schema"). */
2
+ export declare function schemaFormatLabel(schemaFormat: string): string;
@@ -0,0 +1,19 @@
1
+ import { nothing, type TemplateResult } from 'lit';
2
+ import type { Document } from '../model/types.js';
3
+ export interface HeaderInput {
4
+ doc: Document;
5
+ /** The original document URL. */
6
+ src: string | undefined;
7
+ /** Object URL holding the document exactly as fetched, for "Download spec". */
8
+ downloadHref: string | undefined;
9
+ hasLogo: boolean;
10
+ themeToggle: boolean;
11
+ resolvedTheme: 'light' | 'dark';
12
+ onToggleTheme: () => void;
13
+ /** Rendered into the right-hand group (server selector, chunk 1.14). */
14
+ extra?: TemplateResult | typeof nothing;
15
+ /** Rendered first: the drawer menu button on narrow containers with the sidebar on. */
16
+ menu?: TemplateResult | typeof nothing;
17
+ }
18
+ export declare const headerStyles: import("lit").CSSResult;
19
+ export declare function renderHeader(input: HeaderInput): TemplateResult;
@@ -0,0 +1,4 @@
1
+ import { type TemplateResult } from 'lit';
2
+ import type { Document } from '../model/types.js';
3
+ export declare const infoStyles: import("lit").CSSResult;
4
+ export declare function renderInfo(doc: Document, anchorId: string): TemplateResult;
@@ -0,0 +1,4 @@
1
+ import { nothing, type TemplateResult } from 'lit';
2
+ export declare function renderMarkdown(text: string | undefined, className?: string): TemplateResult | typeof nothing;
3
+ /** Inline markdown (no wrapping paragraph), for summaries and short descriptions. */
4
+ export declare function renderInline(text: string | undefined): TemplateResult | typeof nothing;
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The sidebar's data (ROADMAP amendment 11): one generic list of nav items built once per
3
+ * render, which the sidebar renders and the search filters. Sections and operations today;
4
+ * messages and schemas can join later without touching search, grouping or highlighting.
5
+ */
6
+ import type { Document, Operation, OperationAction } from '../model/types.js';
7
+ import type { GroupOperations, GroupServers } from '../options.js';
8
+ export type NavKind = 'section' | 'server' | 'operation' | 'message' | 'schema';
9
+ export interface NavItem {
10
+ kind: NavKind;
11
+ label: string;
12
+ /** Full page anchor id (element id, section, item). */
13
+ anchor: string;
14
+ /** Group heading; items without one are listed flat. */
15
+ group?: string;
16
+ badge?: {
17
+ label: string;
18
+ action: OperationAction;
19
+ };
20
+ /** Second line, e.g. the channel address. */
21
+ sub?: string;
22
+ /** Right-hand count, for the Messages and Schemas links. */
23
+ count?: number;
24
+ /** Lower-cased strings the search matches against. */
25
+ search: string[];
26
+ /** Operations: the tag names they carry, for the Tags facet. */
27
+ tags?: string[];
28
+ }
29
+ /** One entry of the sidebar's Tags block: a tag and how many operations carry it. */
30
+ export interface TagFacet {
31
+ name: string;
32
+ description?: string;
33
+ count: number;
34
+ }
35
+ export interface NavOptions {
36
+ info: boolean;
37
+ servers: boolean;
38
+ messages: boolean;
39
+ schemas: boolean;
40
+ showServers: GroupServers;
41
+ showOperations: GroupOperations;
42
+ }
43
+ export declare function buildNavItems(doc: Document, operations: Operation[], prefix: string, options: NavOptions): NavItem[];
44
+ /**
45
+ * The Tags block's entries (amendment 17): the document's declared tags first, in their order,
46
+ * then any other tag an operation carries, in first-seen order. Tags no operation carries are
47
+ * left out, since selecting them could only empty the list.
48
+ */
49
+ export declare function tagFacets(doc: Document, operations: Operation[]): TagFacet[];
50
+ /** Every space-separated term must match one of the item's search strings. */
51
+ export declare function matches(item: NavItem, query: string): boolean;
52
+ export interface FilteredNav {
53
+ items: NavItem[];
54
+ /** Operations shown and total, for the live region. */
55
+ shown: number;
56
+ total: number;
57
+ active: boolean;
58
+ }
59
+ /**
60
+ * The search query and the selected tags together: an operation stays when every term matches
61
+ * and, if any tags are selected, it carries at least one of them. Section links hide while a
62
+ * query is typed unless `keepSections`; a tag selection alone keeps them.
63
+ */
64
+ export declare function filterNav(items: NavItem[], query: string, keepSections: boolean, selectedTags?: ReadonlySet<string>): FilteredNav;
65
+ /** Consecutive items with the same group form one block; `undefined` groups are flat. */
66
+ export declare function groupNav(items: NavItem[]): Array<{
67
+ group: string | undefined;
68
+ items: NavItem[];
69
+ }>;
@@ -0,0 +1,18 @@
1
+ import { nothing, type TemplateResult } from 'lit';
2
+ import type { Document, Operation } from '../model/types.js';
3
+ import { type ExampleContext } from './example.js';
4
+ import { type TreeState } from './tree.js';
5
+ export interface OperationContext {
6
+ prefix: string;
7
+ tree: (key: string) => TreeState;
8
+ example: (key: string) => ExampleContext;
9
+ /** Selected message index per operation anchor. */
10
+ messageIndex: (anchor: string) => number;
11
+ selectMessage: (anchor: string, index: number) => void;
12
+ }
13
+ export declare const operationStyles: import("lit").CSSResult;
14
+ export declare function operationAnchor(prefix: string, op: Operation): string;
15
+ /** The address; `{parameters}` are set off in the accent colour, without links. */
16
+ export declare function renderAddress(op: Operation): TemplateResult;
17
+ export declare function renderOperation(op: Operation, ctx: OperationContext): TemplateResult;
18
+ export declare function renderOperations(doc: Document, ctx: OperationContext): TemplateResult | typeof nothing;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Servers, Messages, Schemas and Problems sections (spec 4.10) and the server selector (4.6).
3
+ */
4
+ import { nothing, type TemplateResult } from 'lit';
5
+ import type { Document, Problem } from '../model/types.js';
6
+ import { type ExampleContext } from './example.js';
7
+ import { type TreeState } from './tree.js';
8
+ export declare const sectionStyles: import("lit").CSSResult;
9
+ export interface SectionContext {
10
+ prefix: string;
11
+ tree: (key: string) => TreeState;
12
+ example: (key: string) => ExampleContext;
13
+ }
14
+ export declare function renderServers(doc: Document, prefix: string): TemplateResult | typeof nothing;
15
+ export declare function renderMessages(doc: Document, ctx: SectionContext, showExamples: boolean): TemplateResult | typeof nothing;
16
+ export declare function renderSchemas(doc: Document, ctx: SectionContext): TemplateResult | typeof nothing;
17
+ export declare function renderProblems(problems: readonly Problem[], prefix: string): TemplateResult | typeof nothing;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * The sidebar (spec 4.9 and amendment 11): search, then the nav items grouped as configured,
3
+ * with the current item highlighted. On narrow containers it is a drawer behind a menu button.
4
+ */
5
+ import { type TemplateResult } from 'lit';
6
+ import { type NavItem, type TagFacet } from './nav.js';
7
+ export declare const sidebarStyles: import("lit").CSSResult;
8
+ export interface SidebarInput {
9
+ items: NavItem[];
10
+ /** The Tags block's entries; empty hides the block. */
11
+ tags: TagFacet[];
12
+ selectedTags: ReadonlySet<string>;
13
+ /** Whether the Tags block is expanded; kept by the element so a re-render never collapses it. */
14
+ tagsOpen: boolean;
15
+ onTagsToggle: (open: boolean) => void;
16
+ onToggleTag: (name: string) => void;
17
+ onClearTags: () => void;
18
+ query: string;
19
+ keepSections: boolean;
20
+ current: string | undefined;
21
+ open: boolean;
22
+ liveText: string;
23
+ onQuery: (query: string) => void;
24
+ onEscape: () => void;
25
+ onChoose: () => void;
26
+ onClose: () => void;
27
+ id: string;
28
+ }
29
+ export declare function renderSidebar(input: SidebarInput): TemplateResult;
30
+ export declare const menuIcon: TemplateResult<1>;
@@ -0,0 +1,7 @@
1
+ import { type TemplateResult } from 'lit';
2
+ import type { Tag } from '../model/types.js';
3
+ /**
4
+ * A tag chip. With a description it is focusable and shows it as a tooltip on hover and focus
5
+ * (`.chip--tip`, pure CSS); the description is also in visually hidden text for screen readers.
6
+ */
7
+ export declare function tagChip(tag: Tag): TemplateResult;