asyncapi-viewer 2.0.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/README.md +93 -0
- package/dist/asyncapi-viewer.iife.js +2477 -0
- package/dist/asyncapi-viewer.iife.js.map +1 -0
- package/dist/asyncapi-viewer.js +12484 -0
- package/dist/asyncapi-viewer.js.map +1 -0
- package/package.json +72 -0
- package/theme/asyncapi-theme.css +53 -0
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# asyncapi-viewer (web component)
|
|
2
|
+
|
|
3
|
+
A web component that renders [AsyncAPI](https://www.asyncapi.com/) 2 and 3 documents, JSON or
|
|
4
|
+
YAML, in the browser: `<asyncapi-viewer src="asyncapi.yaml"></asyncapi-viewer>`. Operations with
|
|
5
|
+
payload trees and example panels, servers, messages and schemas, a searchable sidebar with tag
|
|
6
|
+
filters, light and dark themes that follow the page, a container-based layout for documentation
|
|
7
|
+
columns, and no inline script or style, so `script-src 'self'; style-src 'self'` is enough.
|
|
8
|
+
|
|
9
|
+
It is the browser side of the [`asyncapi-viewer`](https://pypi.org/project/asyncapi-viewer/)
|
|
10
|
+
Python-Markdown extension and MkDocs plugin, and ships inside that package; this npm package is
|
|
11
|
+
the same build for any other page. Documentation, attributes and theming:
|
|
12
|
+
https://weesho-lapara.github.io/asyncapi-viewer/
|
|
13
|
+
|
|
14
|
+
## Use
|
|
15
|
+
|
|
16
|
+
```html
|
|
17
|
+
<script type="module" src="https://cdn.jsdelivr.net/npm/asyncapi-viewer@2.0.0/dist/asyncapi-viewer.js"></script>
|
|
18
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/asyncapi-viewer@2.0.0/theme/asyncapi-theme.css">
|
|
19
|
+
|
|
20
|
+
<asyncapi-viewer src="asyncapi.yaml" sidebar></asyncapi-viewer>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Or `npm install asyncapi-viewer` and import `asyncapi-viewer` (an ES module that defines the
|
|
24
|
+
element) or load `asyncapi-viewer/iife` with a plain script tag. The theme file is optional: copy
|
|
25
|
+
it to change the two accent colours, or set any `--asyncapi-*` custom property on the element.
|
|
26
|
+
Fonts are never loaded by the component; the page opts in (see the theme file).
|
|
27
|
+
|
|
28
|
+
## Development
|
|
29
|
+
|
|
30
|
+
The component knows nothing about MkDocs or Python. Its only interfaces are the element and its
|
|
31
|
+
attributes, `options.schema.json`, and the CSS custom properties in `theme/asyncapi-theme.css`.
|
|
32
|
+
See [ROADMAP.md](../ROADMAP.md) for the design decisions and
|
|
33
|
+
[specs/viewer-spec.md](../specs/viewer-spec.md) for the original specification.
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
npm ci
|
|
37
|
+
npm run check # tsc + eslint
|
|
38
|
+
npm test # vitest: options, loader, resolver, normalisers, schema builder, generator
|
|
39
|
+
npm run build # dist/asyncapi-viewer.js (ESM) and dist/asyncapi-viewer.iife.js
|
|
40
|
+
npm run coverage # normaliser over the AsyncAPI example corpus -> test/coverage/REPORT.md
|
|
41
|
+
npm run e2e:install # Playwright browsers (once)
|
|
42
|
+
npm run e2e # Playwright: axe-core accessibility, CSP page, screenshot capture
|
|
43
|
+
npm run sync-examples # refresh demo/spec-examples/ from the coverage corpus (after npm run coverage)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The demo at `demo/index.html` is a visual test bench: one viewer, a dropdown of every
|
|
47
|
+
asyncapi/spec example (a verbatim copy under `demo/spec-examples/`, listed by its
|
|
48
|
+
`index.json`), the docs examples and every test fixture, option checkboxes and a width switch.
|
|
49
|
+
Serve the repository root (`node scripts/serve.mjs`, or any static server) and open
|
|
50
|
+
`/viewer/demo/`; `?doc=<path>` selects a document.
|
|
51
|
+
|
|
52
|
+
## Browser suite (Playwright)
|
|
53
|
+
|
|
54
|
+
- `test/e2e/a11y.spec.ts`: axe-core over the demo at 1280 and 380px in light and dark, with
|
|
55
|
+
the drawer open on the narrow width; fails on serious or critical violations. Plus a keyboard
|
|
56
|
+
walk through the drawer and a tree toggle.
|
|
57
|
+
- `test/e2e/csp.spec.ts`: `test/e2e/csp/` is served with
|
|
58
|
+
`default-src 'none'; script-src 'self'; style-src 'self'; connect-src 'self'` and must render
|
|
59
|
+
fully with no CSP console errors. Result on 2026-09-26: Chromium and WebKit pass locally,
|
|
60
|
+
Firefox passes in CI (Playwright's Firefox build does not launch on this macOS version).
|
|
61
|
+
Lit's constructed stylesheets and the CSSOM writes for derived colours are allowed under a
|
|
62
|
+
strict `style-src`; a `style` attribute binding was not, and was removed.
|
|
63
|
+
- `test/e2e/instant.spec.ts`: a Material for MkDocs fixture site with `navigation.instant`
|
|
64
|
+
(`test/e2e/mkdocs/`, built by `build.py`, ignored): viewers render on every page reached
|
|
65
|
+
through instant navigation and through history, with no full load. Skipped until built.
|
|
66
|
+
- `test/e2e/sidebar.spec.ts`: the resizable sidebar (drag, keyboard, clamping, double-click reset,
|
|
67
|
+
no handle in the drawer layout).
|
|
68
|
+
- `test/e2e/screenshots.spec.ts`: captures every example document at 1280, 820 and 380px in
|
|
69
|
+
both themes into `test/e2e/screenshots/<browser>/` (ignored by git, uploaded as a CI
|
|
70
|
+
artifact) and asserts no horizontal overflow. Pixel comparison across platforms is not
|
|
71
|
+
attempted.
|
|
72
|
+
|
|
73
|
+
`dist/` is never committed. The Python package copies the built files at build time.
|
|
74
|
+
|
|
75
|
+
## Bundle size log (gzipped IIFE)
|
|
76
|
+
|
|
77
|
+
| Date | Chunk | Size |
|
|
78
|
+
|---|---|---|
|
|
79
|
+
| 2026-09-26 | 0.2 skeleton (Lit only) | 6.0 kB |
|
|
80
|
+
| 2026-09-26 | 1.2 loader (`yaml` added) | 38.6 kB |
|
|
81
|
+
| 2026-09-26 | 1.4 v3 normaliser and schema builder | 45.1 kB |
|
|
82
|
+
| 2026-09-26 | 1.5 v2 normaliser | 46.3 kB |
|
|
83
|
+
| 2026-09-26 | 1.6 schema tree builder complete | 46.9 kB |
|
|
84
|
+
| 2026-09-26 | 1.7 traits and problems | 47.2 kB |
|
|
85
|
+
| 2026-09-26 | 1.9 UI foundation (markdown-it added) | 93.8 kB |
|
|
86
|
+
| 2026-09-26 | 1.10 operation block, part 1 | 94.7 kB |
|
|
87
|
+
| 2026-09-26 | 1.11 payload tree | 97.4 kB |
|
|
88
|
+
| 2026-09-26 | 1.12 example panel and generator | 100.9 kB |
|
|
89
|
+
| 2026-09-26 | 1.13 operation block, part 2 | 102.5 kB |
|
|
90
|
+
| 2026-09-26 | 1.14 remaining sections | 104.3 kB |
|
|
91
|
+
| 2026-09-26 | 1.15 sidebar and drawer | 107.0 kB |
|
|
92
|
+
| 2026-09-26 | 1.16 breakpoints verified | 107.1 kB |
|
|
93
|
+
| 2026-09-26 | 1.17/1.18 review round, Avro, Playwright | 109.5 kB |
|