@reporters/web 1.2.0 → 1.3.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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.3.0](https://github.com/MoLow/reporters/compare/web-v1.2.0...web-v1.3.0) (2026-07-02)
4
+
5
+
6
+ ### Features
7
+
8
+ * pluggable viewer report sources and custom s3 viewer links ([#222](https://github.com/MoLow/reporters/issues/222)) ([e553e89](https://github.com/MoLow/reporters/commit/e553e89a6e0c9ba9323483ca52a3142c8e70f8ce))
9
+
3
10
  ## [1.2.0](https://github.com/MoLow/reporters/compare/web-v1.1.0...web-v1.2.0) (2026-07-02)
4
11
 
5
12
 
package/README.md CHANGED
@@ -60,3 +60,29 @@ The NDJSON is rendered by the tree viewer, reached three ways:
60
60
  Built on the shared [`@reporters/tree-core`](https://github.com/MoLow/reporters/tree/main/packages/tree-core)
61
61
  model (also used by [`@reporters/live`](https://github.com/MoLow/reporters/tree/main/packages/live)) —
62
62
  the same run state, rendered in the browser instead of the terminal.
63
+
64
+ ## Custom report sources (`@reporters/web/viewer`)
65
+
66
+ The hosted viewer reads `?src=<url>` with plain `fetch`. To serve reports that
67
+ need authentication (private buckets, SSO), build your own viewer page on the
68
+ same UI with a custom source resolver:
69
+
70
+ ```ts
71
+ import { startViewer } from '@reporters/web/viewer';
72
+
73
+ startViewer({
74
+ resolveSource: async (params) => {
75
+ if (params.get('src') || !params.get('key')) return null; // default handling
76
+ const credentials = await acquireCredentialsSomehow();
77
+ return { url: params.get('key')!, fetch: authenticatedFetch(credentials) };
78
+ },
79
+ });
80
+ ```
81
+
82
+ `resolveSource` runs before anything renders. Return `null`/`undefined` to fall
83
+ through to the default `?src=` handling; return `{ url, fetch?, pollMs? }` to
84
+ take over. The custom `fetch` receives the reader's `Range` header and must
85
+ return a standard `Response`; a thrown error shows the viewer's load-error
86
+ screen, and a promise that never resolves is fine while an auth redirect is in
87
+ flight. The export is a self-contained browser ESM module (React inlined) —
88
+ bundle it with your resolver into a static HTML page.
@@ -0,0 +1,24 @@
1
+ type FetchLike = (url: string, init?: {
2
+ headers?: Record<string, string>;
3
+ }) => Promise<Response>;
4
+
5
+ interface ReportSource {
6
+ /** Passed to the NDJSON reader as the URL/identifier. */
7
+ url: string;
8
+ /** Transport for reads; defaults to the global fetch. Receives the reader's
9
+ * Range header and must return a standard Response. */
10
+ fetch?: FetchLike;
11
+ /** Poll cadence override; else resolved from ?poll= as today. */
12
+ pollMs?: number;
13
+ }
14
+ interface ViewerOptions {
15
+ /** Called first with the page's query params. Return a source to use it;
16
+ * return null/undefined to fall through to the default ?src= handling.
17
+ * A never-resolving promise is legitimate (e.g. an auth redirect is in
18
+ * flight). A thrown error shows the viewer's load-error screen. */
19
+ resolveSource?: (params: URLSearchParams) => Promise<ReportSource | null | undefined>;
20
+ }
21
+
22
+ declare function startViewer(options?: ViewerOptions): Promise<void>;
23
+
24
+ export { type FetchLike, type ReportSource, type ViewerOptions, startViewer };