@canonical/react-ssr 0.22.0 → 0.24.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/dist/esm/bin/serve-express.js +86 -0
- package/dist/esm/bin/serve-express.js.map +1 -0
- package/dist/esm/index.js +3 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/adapter/index.js +2 -0
- package/dist/esm/lib/adapter/index.js.map +1 -0
- package/dist/esm/lib/adapter/mime.js +85 -0
- package/dist/esm/lib/adapter/mime.js.map +1 -0
- package/dist/esm/lib/adapter/types.js +10 -0
- package/dist/esm/lib/adapter/types.js.map +1 -0
- package/dist/esm/lib/index.js +4 -0
- package/dist/esm/lib/index.js.map +1 -0
- package/dist/esm/lib/renderer/Extractor.js +172 -0
- package/dist/esm/lib/renderer/Extractor.js.map +1 -0
- package/dist/esm/lib/renderer/JSXRenderer.js +283 -0
- package/dist/esm/lib/renderer/JSXRenderer.js.map +1 -0
- package/dist/esm/lib/renderer/SitemapRenderer.js +241 -0
- package/dist/esm/lib/renderer/SitemapRenderer.js.map +1 -0
- package/dist/esm/lib/renderer/TextRenderer.js +124 -0
- package/dist/esm/lib/renderer/TextRenderer.js.map +1 -0
- package/dist/esm/lib/renderer/constants.js.map +1 -0
- package/dist/esm/lib/renderer/index.js +6 -0
- package/dist/esm/lib/renderer/index.js.map +1 -0
- package/dist/esm/lib/renderer/types.js +10 -0
- package/dist/esm/lib/renderer/types.js.map +1 -0
- package/dist/esm/lib/server/index.js +3 -0
- package/dist/esm/lib/server/index.js.map +1 -0
- package/dist/esm/lib/server/serveStream.js +53 -0
- package/dist/esm/lib/server/serveStream.js.map +1 -0
- package/dist/esm/lib/server/serveString.js +49 -0
- package/dist/esm/lib/server/serveString.js.map +1 -0
- package/dist/types/bin/serve-express.d.ts +24 -0
- package/dist/types/bin/serve-express.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/adapter/index.d.ts +3 -0
- package/dist/types/lib/adapter/index.d.ts.map +1 -0
- package/dist/types/lib/adapter/mime.d.ts +43 -0
- package/dist/types/lib/adapter/mime.d.ts.map +1 -0
- package/dist/types/lib/adapter/types.d.ts +85 -0
- package/dist/types/lib/adapter/types.d.ts.map +1 -0
- package/dist/types/lib/index.d.ts +4 -0
- package/dist/types/lib/index.d.ts.map +1 -0
- package/dist/types/lib/renderer/Extractor.d.ts +93 -0
- package/dist/types/lib/renderer/Extractor.d.ts.map +1 -0
- package/dist/types/lib/renderer/JSXRenderer.d.ts +163 -0
- package/dist/types/lib/renderer/JSXRenderer.d.ts.map +1 -0
- package/dist/types/lib/renderer/SitemapRenderer.d.ts +153 -0
- package/dist/types/lib/renderer/SitemapRenderer.d.ts.map +1 -0
- package/dist/types/lib/renderer/TextRenderer.d.ts +83 -0
- package/dist/types/lib/renderer/TextRenderer.d.ts.map +1 -0
- package/dist/types/lib/renderer/constants.d.ts.map +1 -0
- package/dist/types/lib/renderer/index.d.ts +7 -0
- package/dist/types/lib/renderer/index.d.ts.map +1 -0
- package/dist/types/lib/renderer/types.d.ts +161 -0
- package/dist/types/lib/renderer/types.d.ts.map +1 -0
- package/dist/types/lib/server/index.d.ts +3 -0
- package/dist/types/lib/server/index.d.ts.map +1 -0
- package/dist/types/lib/server/serveStream.d.ts +41 -0
- package/dist/types/lib/server/serveStream.d.ts.map +1 -0
- package/dist/types/lib/server/serveString.d.ts +37 -0
- package/dist/types/lib/server/serveString.d.ts.map +1 -0
- package/package.json +37 -17
- package/dist/esm/renderer/Extractor.js +0 -127
- package/dist/esm/renderer/Extractor.js.map +0 -1
- package/dist/esm/renderer/JSXRenderer.js +0 -168
- package/dist/esm/renderer/JSXRenderer.js.map +0 -1
- package/dist/esm/renderer/constants.js.map +0 -1
- package/dist/esm/renderer/index.js +0 -4
- package/dist/esm/renderer/index.js.map +0 -1
- package/dist/esm/renderer/types.js +0 -2
- package/dist/esm/renderer/types.js.map +0 -1
- package/dist/esm/server/index.js +0 -2
- package/dist/esm/server/index.js.map +0 -1
- package/dist/esm/server/serve-express.js +0 -58
- package/dist/esm/server/serve-express.js.map +0 -1
- package/dist/esm/server/serve.js +0 -41
- package/dist/esm/server/serve.js.map +0 -1
- package/dist/types/renderer/Extractor.d.ts +0 -68
- package/dist/types/renderer/Extractor.d.ts.map +0 -1
- package/dist/types/renderer/JSXRenderer.d.ts +0 -71
- package/dist/types/renderer/JSXRenderer.d.ts.map +0 -1
- package/dist/types/renderer/constants.d.ts.map +0 -1
- package/dist/types/renderer/index.d.ts +0 -5
- package/dist/types/renderer/index.d.ts.map +0 -1
- package/dist/types/renderer/types.d.ts +0 -35
- package/dist/types/renderer/types.d.ts.map +0 -1
- package/dist/types/server/index.d.ts +0 -2
- package/dist/types/server/index.d.ts.map +0 -1
- package/dist/types/server/serve-express.d.ts +0 -3
- package/dist/types/server/serve-express.d.ts.map +0 -1
- package/dist/types/server/serve.d.ts +0 -30
- package/dist/types/server/serve.d.ts.map +0 -1
- /package/dist/esm/{renderer → lib/renderer}/constants.js +0 -0
- /package/dist/types/{renderer → lib/renderer}/constants.d.ts +0 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import type { PipeableStreamResult, SitemapConfig, SitemapGetter, SitemapItem } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Renders an XML sitemap from a set of async data sources.
|
|
4
|
+
*
|
|
5
|
+
* Unlike `JSXRenderer`, this renderer produces XML (not HTML) and does not use
|
|
6
|
+
* React. The render pipeline is functional: each stage returns data rather than
|
|
7
|
+
* mutating instance state, so calling render methods multiple times produces
|
|
8
|
+
* identical results for the same underlying data.
|
|
9
|
+
*
|
|
10
|
+
* Implements the same three render methods as `JSXRenderer` — `renderToReadableStream`,
|
|
11
|
+
* `renderToPipeableStream`, and `renderToString` — with the same `statusCode` /
|
|
12
|
+
* `statusReady` metadata contract. This allows consumers to use either renderer
|
|
13
|
+
* interchangeably.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* const renderer = new SitemapRenderer(
|
|
18
|
+
* [() => fetchPages(), () => fetchPosts()],
|
|
19
|
+
* { baseUrl: "https://example.com", defaultChangefreq: "weekly" },
|
|
20
|
+
* );
|
|
21
|
+
*
|
|
22
|
+
* const stream = await renderer.renderToReadableStream();
|
|
23
|
+
* return new Response(stream, {
|
|
24
|
+
* status: renderer.statusCode,
|
|
25
|
+
* headers: { "Content-Type": "application/xml; charset=utf-8" },
|
|
26
|
+
* });
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export default class SitemapRenderer {
|
|
30
|
+
protected readonly getters: readonly SitemapGetter[];
|
|
31
|
+
protected readonly config: SitemapConfig;
|
|
32
|
+
/**
|
|
33
|
+
* HTTP status code determined during rendering.
|
|
34
|
+
*
|
|
35
|
+
* Set to 200 on successful render. Errors from getters propagate as
|
|
36
|
+
* thrown exceptions rather than setting this to 500 — the consumer's
|
|
37
|
+
* error handler decides the status code for unexpected failures.
|
|
38
|
+
*/
|
|
39
|
+
statusCode: number;
|
|
40
|
+
/**
|
|
41
|
+
* Resolves when `statusCode` is determined.
|
|
42
|
+
*
|
|
43
|
+
* For all three render methods on `SitemapRenderer`, this resolves by
|
|
44
|
+
* the time the method's returned Promise settles (or synchronously for
|
|
45
|
+
* the portions that are sync).
|
|
46
|
+
*/
|
|
47
|
+
statusReady: Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Create a sitemap renderer.
|
|
50
|
+
*
|
|
51
|
+
* @param getters - Async functions that each return a batch of sitemap items.
|
|
52
|
+
* Called concurrently via `Promise.all` during rendering.
|
|
53
|
+
* @param config - Base URL and optional defaults for changefreq / priority.
|
|
54
|
+
*/
|
|
55
|
+
constructor(getters: readonly SitemapGetter[], config: SitemapConfig);
|
|
56
|
+
/**
|
|
57
|
+
* Load sitemap items from all configured getters.
|
|
58
|
+
*
|
|
59
|
+
* Calls every getter concurrently and flattens the results into a single
|
|
60
|
+
* array. This is the only async step in the pipeline.
|
|
61
|
+
*
|
|
62
|
+
* @note This method is impure — it calls external async data sources.
|
|
63
|
+
* @returns A flat array of raw sitemap items from all getters.
|
|
64
|
+
*/
|
|
65
|
+
protected loadItems(): Promise<SitemapItem[]>;
|
|
66
|
+
/**
|
|
67
|
+
* Resolve URLs and apply defaults to raw sitemap items.
|
|
68
|
+
*
|
|
69
|
+
* For each item:
|
|
70
|
+
* - Relative `loc` values are resolved against `config.baseUrl`. An empty
|
|
71
|
+
* `loc` resolves to the base URL itself.
|
|
72
|
+
* - `lastmod` dates are formatted to `YYYY-MM-DD` (ISO 8601 date-only).
|
|
73
|
+
* - Missing `changefreq` and `priority` are filled from `config` defaults.
|
|
74
|
+
*
|
|
75
|
+
* @param items - Raw items as returned by `loadItems`.
|
|
76
|
+
* @returns A new array of items with resolved URLs and applied defaults.
|
|
77
|
+
*/
|
|
78
|
+
protected formatItems(items: readonly SitemapItem[]): SitemapItem[];
|
|
79
|
+
/**
|
|
80
|
+
* Format a `Date` object or ISO string to a `YYYY-MM-DD` date string.
|
|
81
|
+
*
|
|
82
|
+
* The Sitemaps protocol specifies W3C Datetime format; the date-only
|
|
83
|
+
* variant (`YYYY-MM-DD`) is the most common form used in practice.
|
|
84
|
+
*
|
|
85
|
+
* @param date - A `Date` instance or an ISO 8601 date/datetime string.
|
|
86
|
+
* @returns The date formatted as `YYYY-MM-DD`.
|
|
87
|
+
*/
|
|
88
|
+
protected static formatDate(date: Date | string): string;
|
|
89
|
+
/**
|
|
90
|
+
* Escape the five XML special characters in a string.
|
|
91
|
+
*
|
|
92
|
+
* Prevents malformed XML when interpolating user-supplied URLs that may
|
|
93
|
+
* contain `&` (common in query strings), `<`, `>`, `"`, or `'`.
|
|
94
|
+
*
|
|
95
|
+
* @param value - The raw string to escape.
|
|
96
|
+
* @returns The string with `&`, `<`, `>`, `"`, and `'` replaced by their XML entities.
|
|
97
|
+
*/
|
|
98
|
+
protected static escapeXml(value: string): string;
|
|
99
|
+
/**
|
|
100
|
+
* Serialise a list of formatted sitemap items into an XML sitemap string.
|
|
101
|
+
*
|
|
102
|
+
* Produces a complete `<?xml>` document with a `<urlset>` root element
|
|
103
|
+
* conforming to the Sitemaps 0.9 schema. Only non-null optional fields
|
|
104
|
+
* (`lastmod`, `changefreq`, `priority`) are included in the output.
|
|
105
|
+
*
|
|
106
|
+
* @param items - Formatted items (URLs resolved, dates formatted).
|
|
107
|
+
* @returns The complete XML sitemap as a string.
|
|
108
|
+
*/
|
|
109
|
+
protected toXml(items: readonly SitemapItem[]): string;
|
|
110
|
+
/**
|
|
111
|
+
* Build the full XML string by loading items, applying formatting, and
|
|
112
|
+
* serialising to XML.
|
|
113
|
+
*/
|
|
114
|
+
protected buildXml(): Promise<string>;
|
|
115
|
+
/**
|
|
116
|
+
* Render the sitemap to a web `ReadableStream`.
|
|
117
|
+
*
|
|
118
|
+
* Loads items from all getters, formats them, serialises to XML, and
|
|
119
|
+
* wraps the result in a `ReadableStream`. Sets `statusCode` to 200.
|
|
120
|
+
*
|
|
121
|
+
* @note This method is impure — it calls external data sources and mutates `statusCode`.
|
|
122
|
+
*
|
|
123
|
+
* @param _signal - Accepted for API compatibility with `JSXRenderer`. Not used.
|
|
124
|
+
* @returns A `ReadableStream` of the XML sitemap.
|
|
125
|
+
*/
|
|
126
|
+
renderToReadableStream: (_signal?: AbortSignal) => Promise<ReadableStream>;
|
|
127
|
+
/**
|
|
128
|
+
* Render the sitemap to a Node.js pipeable stream.
|
|
129
|
+
*
|
|
130
|
+
* Returns `{ pipe, abort }` synchronously. The actual XML generation is
|
|
131
|
+
* async (getters are called), so data is pushed to the stream when ready.
|
|
132
|
+
* `statusReady` resolves when the XML is built and `statusCode` is set.
|
|
133
|
+
*
|
|
134
|
+
* @note This method is impure — it calls external data sources and mutates `statusCode`.
|
|
135
|
+
*
|
|
136
|
+
* @returns The pipe/abort handles for the XML stream.
|
|
137
|
+
*/
|
|
138
|
+
renderToPipeableStream: () => PipeableStreamResult;
|
|
139
|
+
/**
|
|
140
|
+
* Render the sitemap to a complete XML string.
|
|
141
|
+
*
|
|
142
|
+
* Loads items from all getters, formats them, and returns the serialised
|
|
143
|
+
* XML. Sets `statusCode` to 200.
|
|
144
|
+
*
|
|
145
|
+
* Async because the getters are async.
|
|
146
|
+
*
|
|
147
|
+
* @note This method is impure — it calls external data sources and mutates `statusCode`.
|
|
148
|
+
*
|
|
149
|
+
* @returns The complete XML sitemap string.
|
|
150
|
+
*/
|
|
151
|
+
renderToString: () => Promise<string>;
|
|
152
|
+
}
|
|
153
|
+
//# sourceMappingURL=SitemapRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SitemapRenderer.d.ts","sourceRoot":"","sources":["../../../../src/lib/renderer/SitemapRenderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,oBAAoB,EACpB,aAAa,EACb,aAAa,EACb,WAAW,EACZ,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;IA2BhC,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,aAAa,EAAE;IACpD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,aAAa;IA3B1C;;;;;;OAMG;IACI,UAAU,SAAO;IAExB;;;;;;OAMG;IACI,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,CAAqB;IAEtD;;;;;;OAMG;gBAEkB,OAAO,EAAE,SAAS,aAAa,EAAE,EACjC,MAAM,EAAE,aAAa;IAG1C;;;;;;;;OAQG;cACa,SAAS,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAKnD;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,GAAG,WAAW,EAAE;IAcnE;;;;;;;;OAQG;IACH,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM;IAKxD;;;;;;;;OAQG;IACH,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IASjD;;;;;;;;;OASG;IACH,SAAS,CAAC,KAAK,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,GAAG,MAAM;IA6BtD;;;OAGG;cACa,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;IAM3C;;;;;;;;;;OAUG;IACH,sBAAsB,GACpB,UAAU,WAAW,KACpB,OAAO,CAAC,cAAc,CAAC,CAWxB;IAEF;;;;;;;;;;OAUG;IACH,sBAAsB,QAAO,oBAAoB,CAqB/C;IAEF;;;;;;;;;;;OAWG;IACH,cAAc,QAAa,OAAO,CAAC,MAAM,CAAC,CAKxC;CACH"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { PipeableStreamResult, TextGetter } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Renders a plain-text document from async data sources.
|
|
4
|
+
*
|
|
5
|
+
* Produces output suitable for `llms.txt`, `humans.txt`, `security.txt`, or
|
|
6
|
+
* any text file that requires dynamic data (e.g. fetching page descriptions
|
|
7
|
+
* from a CMS for an LLM context file).
|
|
8
|
+
*
|
|
9
|
+
* The renderer is intentionally minimal — it accepts an array of async getters,
|
|
10
|
+
* each returning a string, and concatenates the results. No structure is imposed.
|
|
11
|
+
* The consumer controls formatting entirely.
|
|
12
|
+
*
|
|
13
|
+
* Implements the same three render methods and `statusCode` / `statusReady`
|
|
14
|
+
* contract as `JSXRenderer` and `SitemapRenderer`.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const renderer = new TextRenderer([
|
|
19
|
+
* async () => "# My App\n\nContext for LLMs about this application.\n",
|
|
20
|
+
* async () => {
|
|
21
|
+
* const pages = await fetchPages();
|
|
22
|
+
* return pages.map(p => `- ${p.title}: ${p.url}`).join("\n");
|
|
23
|
+
* },
|
|
24
|
+
* ]);
|
|
25
|
+
*
|
|
26
|
+
* const stream = await renderer.renderToReadableStream();
|
|
27
|
+
* return new Response(stream, {
|
|
28
|
+
* status: renderer.statusCode,
|
|
29
|
+
* headers: { "Content-Type": "text/plain; charset=utf-8" },
|
|
30
|
+
* });
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export default class TextRenderer {
|
|
34
|
+
protected readonly getters: readonly TextGetter[];
|
|
35
|
+
/**
|
|
36
|
+
* HTTP status code determined during rendering.
|
|
37
|
+
*
|
|
38
|
+
* Set to 200 on successful render. Errors from getters propagate as
|
|
39
|
+
* thrown exceptions — the consumer's error handler decides the status code.
|
|
40
|
+
*/
|
|
41
|
+
statusCode: number;
|
|
42
|
+
/**
|
|
43
|
+
* Resolves when `statusCode` is determined.
|
|
44
|
+
*/
|
|
45
|
+
statusReady: Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Create a text renderer.
|
|
48
|
+
*
|
|
49
|
+
* @param getters - Async functions that each return a string. Called
|
|
50
|
+
* sequentially (order matters) and concatenated into the final document.
|
|
51
|
+
*/
|
|
52
|
+
constructor(getters: readonly TextGetter[]);
|
|
53
|
+
/**
|
|
54
|
+
* Build the full text by calling all getters sequentially and concatenating.
|
|
55
|
+
*/
|
|
56
|
+
protected buildText(): Promise<string>;
|
|
57
|
+
/**
|
|
58
|
+
* Render to a web `ReadableStream`.
|
|
59
|
+
*
|
|
60
|
+
* @note This method is impure — it calls external data sources and mutates `statusCode`.
|
|
61
|
+
*
|
|
62
|
+
* @param _signal - Accepted for API compatibility. Not used.
|
|
63
|
+
* @returns A `ReadableStream` of the plain-text document.
|
|
64
|
+
*/
|
|
65
|
+
renderToReadableStream: (_signal?: AbortSignal) => Promise<ReadableStream>;
|
|
66
|
+
/**
|
|
67
|
+
* Render to a Node.js pipeable stream.
|
|
68
|
+
*
|
|
69
|
+
* Returns `{ pipe, abort }` synchronously. Data is pushed when ready.
|
|
70
|
+
*
|
|
71
|
+
* @note This method is impure — it calls external data sources and mutates `statusCode`.
|
|
72
|
+
*/
|
|
73
|
+
renderToPipeableStream: () => PipeableStreamResult;
|
|
74
|
+
/**
|
|
75
|
+
* Render to a complete string.
|
|
76
|
+
*
|
|
77
|
+
* Async because the getters are async.
|
|
78
|
+
*
|
|
79
|
+
* @note This method is impure — it calls external data sources and mutates `statusCode`.
|
|
80
|
+
*/
|
|
81
|
+
renderToString: () => Promise<string>;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=TextRenderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TextRenderer.d.ts","sourceRoot":"","sources":["../../../../src/lib/renderer/TextRenderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEnE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,OAAO,OAAO,YAAY;IAoBnB,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,UAAU,EAAE;IAnB7D;;;;;OAKG;IACI,UAAU,SAAO;IAExB;;OAEG;IACI,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,CAAqB;IAEtD;;;;;OAKG;gBAC4B,OAAO,EAAE,SAAS,UAAU,EAAE;IAE7D;;OAEG;cACa,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAQ5C;;;;;;;OAOG;IACH,sBAAsB,GACpB,UAAU,WAAW,KACpB,OAAO,CAAC,cAAc,CAAC,CAWxB;IAEF;;;;;;OAMG;IACH,sBAAsB,QAAO,oBAAoB,CAqB/C;IAEF;;;;;;OAMG;IACH,cAAc,QAAa,OAAO,CAAC,MAAM,CAAC,CAKxC;CACH"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/lib/renderer/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./constants.js";
|
|
2
|
+
export { default as Extractor } from "./Extractor.js";
|
|
3
|
+
export { default as JSXRenderer } from "./JSXRenderer.js";
|
|
4
|
+
export { default as SitemapRenderer } from "./SitemapRenderer.js";
|
|
5
|
+
export { default as TextRenderer } from "./TextRenderer.js";
|
|
6
|
+
export type { PipeableStreamResult, RendererOptions, ServerEntrypoint, ServerEntrypointProps, SitemapConfig, SitemapGetter, SitemapItem, TextGetter, } from "./types.js";
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/renderer/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAC5D,YAAY,EACV,oBAAoB,EACpB,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,aAAa,EACb,aAAa,EACb,WAAW,EACX,UAAU,GACX,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared type contracts for the SSR renderer domain.
|
|
3
|
+
*
|
|
4
|
+
* These types define the interface between renderers (which produce HTML or XML
|
|
5
|
+
* content and record metadata like status codes) and server adapters (which
|
|
6
|
+
* deliver that content over HTTP). Renderers are transport-agnostic — they
|
|
7
|
+
* never write to a response object.
|
|
8
|
+
*/
|
|
9
|
+
import type * as React from "react";
|
|
10
|
+
import type { RenderToPipeableStreamOptions, RenderToReadableStreamOptions } from "react-dom/server";
|
|
11
|
+
/**
|
|
12
|
+
* The pipe/abort handles returned by `renderToPipeableStream`.
|
|
13
|
+
*
|
|
14
|
+
* Mirrors the shape of React's `PipeableStream` but decoupled from the
|
|
15
|
+
* `react-dom/server` import so consumers don't need to depend on it directly.
|
|
16
|
+
*/
|
|
17
|
+
export interface PipeableStreamResult {
|
|
18
|
+
/** Pipe the rendered HTML to a Node.js writable stream (e.g. `ServerResponse`). */
|
|
19
|
+
pipe: <W extends NodeJS.WritableStream>(destination: W) => W;
|
|
20
|
+
/** Abort the in-progress render. */
|
|
21
|
+
abort: (reason?: unknown) => void;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Configuration for a `JSXRenderer` instance.
|
|
25
|
+
*
|
|
26
|
+
* Controls locale, HTML shell extraction, and options forwarded to
|
|
27
|
+
* React's streaming APIs.
|
|
28
|
+
*/
|
|
29
|
+
export interface RendererOptions {
|
|
30
|
+
/**
|
|
31
|
+
* Locale for the rendered page, passed as the `lang` prop to the server
|
|
32
|
+
* entrypoint component. Defaults to `"en"` when omitted.
|
|
33
|
+
*/
|
|
34
|
+
defaultLocale?: string;
|
|
35
|
+
/**
|
|
36
|
+
* A full HTML string (typically from a Vite build) whose `<head>` tags
|
|
37
|
+
* are extracted and injected into the rendered output. When omitted,
|
|
38
|
+
* the renderer produces output without extracted head elements.
|
|
39
|
+
*/
|
|
40
|
+
htmlString?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Options forwarded to `react-dom/server.renderToPipeableStream`.
|
|
43
|
+
*
|
|
44
|
+
* The renderer merges its own `bootstrapScriptContent`, `bootstrapScripts`,
|
|
45
|
+
* and `bootstrapModules` into these options, but user-provided values take
|
|
46
|
+
* priority and are never overwritten.
|
|
47
|
+
*/
|
|
48
|
+
renderToPipeableStreamOptions?: RenderToPipeableStreamOptions;
|
|
49
|
+
/**
|
|
50
|
+
* Options forwarded to `react-dom/server.renderToReadableStream`.
|
|
51
|
+
*
|
|
52
|
+
* Same merge semantics as `renderToPipeableStreamOptions`. When omitted,
|
|
53
|
+
* the shared bootstrap options from `renderToPipeableStreamOptions` are
|
|
54
|
+
* used as a fallback (the bootstrap fields are structurally identical
|
|
55
|
+
* between the two option types).
|
|
56
|
+
*/
|
|
57
|
+
renderToReadableStreamOptions?: RenderToReadableStreamOptions;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Props received by the server entrypoint component during SSR.
|
|
61
|
+
*
|
|
62
|
+
* The renderer assembles these from the locale, the extracted HTML head elements
|
|
63
|
+
* (when an HTML shell is provided), and the initial data for hydration.
|
|
64
|
+
*
|
|
65
|
+
* @typeParam InitialData - Shape of the hydration data embedded in the page.
|
|
66
|
+
*/
|
|
67
|
+
export interface ServerEntrypointProps<InitialData extends Record<string, unknown>> {
|
|
68
|
+
/** BCP 47 language tag for the page (e.g. `"en"`, `"fr-CA"`). */
|
|
69
|
+
lang?: string;
|
|
70
|
+
/**
|
|
71
|
+
* `<script>` elements extracted from the HTML shell, as React elements.
|
|
72
|
+
* Undefined when no HTML shell was provided.
|
|
73
|
+
*/
|
|
74
|
+
scriptElements?: React.ReactElement[];
|
|
75
|
+
/**
|
|
76
|
+
* `<link>` elements extracted from the HTML shell, as React elements.
|
|
77
|
+
* Undefined when no HTML shell was provided.
|
|
78
|
+
*/
|
|
79
|
+
linkElements?: React.ReactElement[];
|
|
80
|
+
/**
|
|
81
|
+
* `<title>`, `<meta>`, `<style>`, and `<base>` elements from the HTML shell,
|
|
82
|
+
* as React elements. Undefined when no HTML shell was provided.
|
|
83
|
+
*/
|
|
84
|
+
otherHeadElements?: React.ReactElement[];
|
|
85
|
+
/**
|
|
86
|
+
* Data to embed in `window.__INITIAL_DATA__` for client hydration.
|
|
87
|
+
*
|
|
88
|
+
* The renderer serialises this object as JSON in a `<script>` tag so that the
|
|
89
|
+
* client can read it during hydration without a second network request. The
|
|
90
|
+
* JSON is escaped to prevent `</script>` injection.
|
|
91
|
+
*/
|
|
92
|
+
initialData?: InitialData;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* A React component used as the server-side rendering entry point.
|
|
96
|
+
*
|
|
97
|
+
* Receives `ServerEntrypointProps` and is expected to render the full `<html>`
|
|
98
|
+
* document, including the extracted head elements and initial data.
|
|
99
|
+
*
|
|
100
|
+
* @typeParam InitialData - Shape of the hydration data embedded in the page.
|
|
101
|
+
*/
|
|
102
|
+
export type ServerEntrypoint<InitialData extends Record<string, unknown>> = React.ComponentType<ServerEntrypointProps<InitialData>>;
|
|
103
|
+
/**
|
|
104
|
+
* A single URL entry in an XML sitemap.
|
|
105
|
+
*
|
|
106
|
+
* Follows the Sitemaps XML protocol: https://www.sitemaps.org/protocol.html.
|
|
107
|
+
* All fields except `loc` are optional — the renderer applies defaults from
|
|
108
|
+
* `SitemapConfig` for `changefreq` and `priority`.
|
|
109
|
+
*/
|
|
110
|
+
export interface SitemapItem {
|
|
111
|
+
/**
|
|
112
|
+
* URL of the page. Can be absolute (`https://example.com/about`) or relative
|
|
113
|
+
* (`/about`). Relative URLs are resolved against `SitemapConfig.baseUrl`.
|
|
114
|
+
* An empty string resolves to the base URL itself.
|
|
115
|
+
*/
|
|
116
|
+
loc: string;
|
|
117
|
+
/**
|
|
118
|
+
* Date of last modification. Accepts a `Date` object or an ISO 8601 string.
|
|
119
|
+
* Formatted to `YYYY-MM-DD` in the output XML.
|
|
120
|
+
*/
|
|
121
|
+
lastmod?: Date | string;
|
|
122
|
+
/** How frequently the page is likely to change. */
|
|
123
|
+
changefreq?: "always" | "hourly" | "daily" | "weekly" | "monthly" | "yearly" | "never";
|
|
124
|
+
/**
|
|
125
|
+
* Priority of this URL relative to other URLs on the site.
|
|
126
|
+
* Valid range is `0.0` to `1.0`. Default is `0.5` per the protocol.
|
|
127
|
+
*/
|
|
128
|
+
priority?: number;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* An async function that produces a batch of sitemap items.
|
|
132
|
+
*
|
|
133
|
+
* The `SitemapRenderer` accepts an array of getters, calls them concurrently
|
|
134
|
+
* via `Promise.all`, and flattens the results into a single item list.
|
|
135
|
+
*/
|
|
136
|
+
export type SitemapGetter = () => Promise<SitemapItem[]>;
|
|
137
|
+
/**
|
|
138
|
+
* Configuration for the `SitemapRenderer`.
|
|
139
|
+
*
|
|
140
|
+
* Defines the canonical base URL used to resolve relative `loc` values,
|
|
141
|
+
* and optional defaults applied to items that omit `changefreq` or `priority`.
|
|
142
|
+
*/
|
|
143
|
+
export interface SitemapConfig {
|
|
144
|
+
/**
|
|
145
|
+
* The canonical base URL for the site (e.g. `"https://example.com"`).
|
|
146
|
+
* Used to resolve relative `loc` values in sitemap items.
|
|
147
|
+
*/
|
|
148
|
+
baseUrl: string;
|
|
149
|
+
/** Default `changefreq` applied to items that do not specify one. */
|
|
150
|
+
defaultChangefreq?: SitemapItem["changefreq"];
|
|
151
|
+
/** Default `priority` applied to items that do not specify one (0.0 to 1.0). */
|
|
152
|
+
defaultPriority?: number;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* An async function that produces a string of text content.
|
|
156
|
+
*
|
|
157
|
+
* The `TextRenderer` accepts an array of getters, calls them sequentially
|
|
158
|
+
* (order matters for document structure), and concatenates the results.
|
|
159
|
+
*/
|
|
160
|
+
export type TextGetter = () => Promise<string>;
|
|
161
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/renderer/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,KAAK,KAAK,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EACV,6BAA6B,EAC7B,6BAA6B,EAC9B,MAAM,kBAAkB,CAAC;AAI1B;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC,mFAAmF;IACnF,IAAI,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,cAAc,EAAE,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC;IAC7D,oCAAoC;IACpC,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACnC;AAID;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;;;OAMG;IACH,6BAA6B,CAAC,EAAE,6BAA6B,CAAC;IAE9D;;;;;;;OAOG;IACH,6BAA6B,CAAC,EAAE,6BAA6B,CAAC;CAC/D;AAID;;;;;;;GAOG;AACH,MAAM,WAAW,qBAAqB,CACpC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAE3C,iEAAiE;IACjE,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;;OAGG;IACH,cAAc,CAAC,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC;IAEtC;;;OAGG;IACH,YAAY,CAAC,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC;IAEpC;;;OAGG;IACH,iBAAiB,CAAC,EAAE,KAAK,CAAC,YAAY,EAAE,CAAC;IAEzC;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,gBAAgB,CAAC,WAAW,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IACtE,KAAK,CAAC,aAAa,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC,CAAC;AAI1D;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;OAGG;IACH,OAAO,CAAC,EAAE,IAAI,GAAG,MAAM,CAAC;IAExB,mDAAmD;IACnD,UAAU,CAAC,EACP,QAAQ,GACR,QAAQ,GACR,OAAO,GACP,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,OAAO,CAAC;IAEZ;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB,qEAAqE;IACrE,iBAAiB,CAAC,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;IAE9C,gFAAgF;IAChF,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAID;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,MAAM,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
/**
|
|
3
|
+
* Convenience wrapper that adapts a renderer factory into a Node.js `(req, res)` handler
|
|
4
|
+
* for pipeable stream rendering.
|
|
5
|
+
*
|
|
6
|
+
* Calls the factory with each incoming request. The factory is expected to construct
|
|
7
|
+
* a renderer (with per-request context like locale, auth, theme) and call
|
|
8
|
+
* `renderToPipeableStream()` on it. This wrapper then awaits `statusReady`, writes
|
|
9
|
+
* headers with the renderer's `statusCode`, and pipes the stream to the response.
|
|
10
|
+
*
|
|
11
|
+
* Does not set `Content-Type` — the consumer controls headers through the factory
|
|
12
|
+
* or by wrapping this handler. Defaults to `text/html; charset=utf-8`.
|
|
13
|
+
*
|
|
14
|
+
* @note This function is impure — it writes to the HTTP response.
|
|
15
|
+
*
|
|
16
|
+
* @param factory - A function that receives the request and returns a renderer.
|
|
17
|
+
* The renderer must have `renderToPipeableStream()`, `statusCode`, and `statusReady`.
|
|
18
|
+
* @returns A Node.js request handler suitable for `app.use()` or `http.createServer()`.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { JSXRenderer } from "@canonical/react-ssr/renderer";
|
|
23
|
+
* import { serveStream } from "@canonical/react-ssr/server";
|
|
24
|
+
*
|
|
25
|
+
* app.use(serveStream((req) => {
|
|
26
|
+
* return new JSXRenderer(
|
|
27
|
+
* EntryServer,
|
|
28
|
+
* { locale: getLocale(req), user: getUser(req) },
|
|
29
|
+
* { htmlString },
|
|
30
|
+
* );
|
|
31
|
+
* }));
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function serveStream(factory: (req: IncomingMessage) => {
|
|
35
|
+
renderToPipeableStream: () => {
|
|
36
|
+
pipe: <W extends NodeJS.WritableStream>(destination: W) => W;
|
|
37
|
+
};
|
|
38
|
+
statusCode: number;
|
|
39
|
+
statusReady: Promise<void>;
|
|
40
|
+
}): (req: IncomingMessage, res: ServerResponse) => Promise<void>;
|
|
41
|
+
//# sourceMappingURL=serveStream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serveStream.d.ts","sourceRoot":"","sources":["../../../../src/lib/server/serveStream.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK;IACjC,sBAAsB,EAAE,MAAM;QAC5B,IAAI,EAAE,CAAC,CAAC,SAAS,MAAM,CAAC,cAAc,EAAE,WAAW,EAAE,CAAC,KAAK,CAAC,CAAC;KAC9D,CAAC;IACF,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B,IAEa,KAAK,eAAe,EAAE,KAAK,cAAc,mBAiBxD"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
/**
|
|
3
|
+
* Convenience wrapper that adapts a renderer factory into a Node.js `(req, res)` handler
|
|
4
|
+
* for string rendering.
|
|
5
|
+
*
|
|
6
|
+
* Calls the factory with each incoming request. The factory is expected to construct
|
|
7
|
+
* a renderer (with per-request context like locale, auth, theme) and call
|
|
8
|
+
* `renderToString()` on it. This wrapper then writes headers with the renderer's
|
|
9
|
+
* `statusCode` and sends the HTML string as the response body.
|
|
10
|
+
*
|
|
11
|
+
* Does not set `Content-Type` — defaults to `text/html; charset=utf-8`.
|
|
12
|
+
*
|
|
13
|
+
* @note This function is impure — it writes to the HTTP response.
|
|
14
|
+
*
|
|
15
|
+
* @param factory - A function that receives the request and returns a renderer.
|
|
16
|
+
* The renderer must have `renderToString()` and `statusCode`.
|
|
17
|
+
* @returns A Node.js request handler suitable for `app.use()` or `http.createServer()`.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { JSXRenderer } from "@canonical/react-ssr/renderer";
|
|
22
|
+
* import { serveString } from "@canonical/react-ssr/server";
|
|
23
|
+
*
|
|
24
|
+
* app.use(serveString((req) => {
|
|
25
|
+
* return new JSXRenderer(
|
|
26
|
+
* EntryServer,
|
|
27
|
+
* { locale: getLocale(req), user: getUser(req) },
|
|
28
|
+
* { htmlString },
|
|
29
|
+
* );
|
|
30
|
+
* }));
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare function serveString(factory: (req: IncomingMessage) => {
|
|
34
|
+
renderToString: () => string;
|
|
35
|
+
statusCode: number;
|
|
36
|
+
}): (req: IncomingMessage, res: ServerResponse) => void;
|
|
37
|
+
//# sourceMappingURL=serveString.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serveString.d.ts","sourceRoot":"","sources":["../../../../src/lib/server/serveString.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK;IACjC,cAAc,EAAE,MAAM,MAAM,CAAC;IAC7B,UAAU,EAAE,MAAM,CAAC;CACpB,IAEO,KAAK,eAAe,EAAE,KAAK,cAAc,UAclD"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/react-ssr",
|
|
3
3
|
"description": "TBD",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.24.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/types/index.d.ts",
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
"name": "Canonical Webteam"
|
|
14
14
|
},
|
|
15
15
|
"bin": {
|
|
16
|
-
"serve-express": "./dist/esm/
|
|
16
|
+
"serve-express": "./dist/esm/bin/serve-express.js",
|
|
17
|
+
"serve-bun": "./dist/esm/bin/serve-bun.js"
|
|
17
18
|
},
|
|
18
19
|
"repository": {
|
|
19
20
|
"type": "git",
|
|
@@ -24,6 +25,11 @@
|
|
|
24
25
|
"url": "https://github.com/canonical/pragma/issues"
|
|
25
26
|
},
|
|
26
27
|
"homepage": "https://github.com/canonical/pragma#readme",
|
|
28
|
+
"imports": {
|
|
29
|
+
"#adapter": "./src/lib/adapter/index.ts",
|
|
30
|
+
"#renderer": "./src/lib/renderer/index.ts",
|
|
31
|
+
"#server": "./src/lib/server/index.ts"
|
|
32
|
+
},
|
|
27
33
|
"scripts": {
|
|
28
34
|
"build": "tsc -p tsconfig.build.json",
|
|
29
35
|
"build:all": "tsc -p tsconfig.build.json",
|
|
@@ -33,7 +39,9 @@
|
|
|
33
39
|
"check:biome": "biome check",
|
|
34
40
|
"check:biome:fix": "biome check --write",
|
|
35
41
|
"check:ts": "tsc --noEmit",
|
|
36
|
-
"test": "
|
|
42
|
+
"test": "vitest run",
|
|
43
|
+
"test:watch": "vitest",
|
|
44
|
+
"test:coverage": "vitest run --coverage"
|
|
37
45
|
},
|
|
38
46
|
"exports": {
|
|
39
47
|
".": {
|
|
@@ -41,36 +49,48 @@
|
|
|
41
49
|
"types": "./dist/types/index.d.ts"
|
|
42
50
|
},
|
|
43
51
|
"./renderer": {
|
|
44
|
-
"import": "./dist/esm/renderer/index.js",
|
|
45
|
-
"types": "./dist/types/renderer/index.d.ts"
|
|
52
|
+
"import": "./dist/esm/lib/renderer/index.js",
|
|
53
|
+
"types": "./dist/types/lib/renderer/index.d.ts"
|
|
46
54
|
},
|
|
47
55
|
"./renderer/constants": {
|
|
48
|
-
"import": "./dist/esm/renderer/constants.js",
|
|
49
|
-
"types": "./dist/types/renderer/constants.d.ts"
|
|
56
|
+
"import": "./dist/esm/lib/renderer/constants.js",
|
|
57
|
+
"types": "./dist/types/lib/renderer/constants.d.ts"
|
|
50
58
|
},
|
|
51
59
|
"./server": {
|
|
52
|
-
"import": "./dist/esm/server/index.js",
|
|
53
|
-
"types": "./dist/types/server/index.d.ts"
|
|
60
|
+
"import": "./dist/esm/lib/server/index.js",
|
|
61
|
+
"types": "./dist/types/lib/server/index.d.ts"
|
|
62
|
+
},
|
|
63
|
+
"./adapter": {
|
|
64
|
+
"import": "./dist/esm/lib/adapter/index.js",
|
|
65
|
+
"types": "./dist/types/lib/adapter/index.d.ts"
|
|
54
66
|
}
|
|
55
67
|
},
|
|
56
68
|
"devDependencies": {
|
|
57
69
|
"@biomejs/biome": "2.4.9",
|
|
58
|
-
"@canonical/biome-config": "^0.
|
|
59
|
-
"@canonical/typescript-config-react": "^0.
|
|
60
|
-
"@canonical/webarchitect": "^0.
|
|
70
|
+
"@canonical/biome-config": "^0.24.0",
|
|
71
|
+
"@canonical/typescript-config-react": "^0.24.0",
|
|
72
|
+
"@canonical/webarchitect": "^0.24.0",
|
|
61
73
|
"@types/express": "^5.0.6",
|
|
62
74
|
"@types/node": "^24.12.0",
|
|
63
75
|
"@types/react": "^19.2.14",
|
|
64
76
|
"@types/react-dom": "^19.2.3",
|
|
65
|
-
"
|
|
77
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
78
|
+
"typescript": "^5.9.3",
|
|
79
|
+
"vitest": "^4.0.18"
|
|
66
80
|
},
|
|
67
81
|
"dependencies": {
|
|
68
|
-
"@canonical/utils": "^0.
|
|
69
|
-
"domhandler": "^6.0.0",
|
|
70
|
-
"express": "^5.2.1",
|
|
82
|
+
"@canonical/utils": "^0.24.0",
|
|
71
83
|
"htmlparser2": "^10.1.0",
|
|
72
84
|
"react": "^19.2.4",
|
|
73
85
|
"react-dom": "^19.2.4"
|
|
74
86
|
},
|
|
75
|
-
"
|
|
87
|
+
"peerDependencies": {
|
|
88
|
+
"express": "^5.2.1"
|
|
89
|
+
},
|
|
90
|
+
"peerDependenciesMeta": {
|
|
91
|
+
"express": {
|
|
92
|
+
"optional": true
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
"gitHead": "28565e3591ad80525b62bd7be6343d1f12ebf4d0"
|
|
76
96
|
}
|