ovr 7.0.0-next.35 → 7.0.0-next.37

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,17 @@
1
1
  # ovr
2
2
 
3
+ ## 7.0.0-next.37
4
+
5
+ ### Minor Changes
6
+
7
+ - c15a886: A render is made with `new Render`, which takes the element by what to render it to, as `Render.raw` and `Render.escape` take theirs: `new Render({ markup: element }, options)` and `new Render({ markdown: element }, options)`, where they were `Render.markup(element, options)` and `Render.markdown(element, options)`.
8
+
9
+ ## 7.0.0-next.36
10
+
11
+ ### Minor Changes
12
+
13
+ - 9c1bfab: `Render.raw` and `Render.escape` name markup `markup`, where it was `html`, like `Render.markup`: `Render.raw({ markup, markdown })` and `Render.escape({ markup })`.
14
+
3
15
  ## 7.0.0-next.35
4
16
 
5
17
  ### Minor Changes
@@ -29,13 +29,13 @@ export declare namespace Markdown {
29
29
  }
30
30
  /**
31
31
  * Renders an element to Markdown, as an `AsyncIterable` of blocks, a stream,
32
- * or a string, from the same elements `Markup` renders. Made with
33
- * `Render.markdown`. Each top level block is
32
+ * or a string, from the same elements `Markup` renders. Internal to ovr,
33
+ * made with `new Render`. Each top level block is
34
34
  * written as soon as it closes, and when the page has a `<main>` element, only
35
35
  * its contents are kept. Raw HTML is written as it is.
36
36
  *
37
37
  * ```tsx
38
- * const markdown = await Render.markdown(<Post post={post} />, { base: url }).string();
38
+ * const markdown = await new Render({ markdown: <Post post={post} /> }, { base: url }).string();
39
39
  * ```
40
40
  */
41
41
  export declare class Markdown {
@@ -1286,13 +1286,13 @@ class Blocks {
1286
1286
  }
1287
1287
  /**
1288
1288
  * Renders an element to Markdown, as an `AsyncIterable` of blocks, a stream,
1289
- * or a string, from the same elements `Markup` renders. Made with
1290
- * `Render.markdown`. Each top level block is
1289
+ * or a string, from the same elements `Markup` renders. Internal to ovr,
1290
+ * made with `new Render`. Each top level block is
1291
1291
  * written as soon as it closes, and when the page has a `<main>` element, only
1292
1292
  * its contents are kept. Raw HTML is written as it is.
1293
1293
  *
1294
1294
  * ```tsx
1295
- * const markdown = await Render.markdown(<Post post={post} />, { base: url }).string();
1295
+ * const markdown = await new Render({ markdown: <Post post={post} /> }, { base: url }).string();
1296
1296
  * ```
1297
1297
  */
1298
1298
  export class Markdown {
@@ -86,8 +86,8 @@ export declare class Element implements AsyncGenerator<Chunk, void, unknown> {
86
86
  [Symbol.asyncIterator](): this;
87
87
  [Symbol.asyncDispose](): Promise<void>;
88
88
  }
89
- /** Internal protocol for a render, to read the element a `Markup` renders. */
90
- declare const source: unique symbol;
89
+ /** Internal protocol for a render, to read the element it renders. */
90
+ export declare const source: unique symbol;
91
91
  /** One step of a render: a chunk, a wait before the next step, or nothing once it is done */
92
92
  export type Step = Chunk | Promise<unknown> | undefined;
93
93
  /**
@@ -139,7 +139,7 @@ export declare namespace Markup {
139
139
  /**
140
140
  * Renders an element to markup, such as HTML, SVG, or XML, as an
141
141
  * `AsyncIterable` of strings, a stream, or a string. `Markdown` renders the
142
- * same elements to Markdown. Made with `Render.markup`.
142
+ * same elements to Markdown. Internal to ovr, made with `new Render`.
143
143
  */
144
144
  export declare class Markup {
145
145
  #private;
@@ -150,7 +150,7 @@ export declare class Markup {
150
150
  * @param options Markup options
151
151
  */
152
152
  constructor(element: JSX.Element, options?: Markup.Options);
153
- /** @returns The element, rendered in place where a `Markup` is a child */
153
+ /** @returns The element, rendered in place where a render is a child */
154
154
  get [source](): JSX.Element;
155
155
  /** @yields Markup as the `Element` resolves */
156
156
  [Symbol.asyncIterator](): AsyncGenerator<string, void, unknown>;
@@ -180,5 +180,4 @@ export declare class Markup {
180
180
  */
181
181
  static escape(html: string, attr?: boolean): string;
182
182
  }
183
- export {};
184
183
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/markup/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE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OAAO,CAAC,CAWrE;IAED;;;;;OAKG;IACH,MAAM,gDAEL;IAED;;;;;;;;OAQG;IACG,MAAM,oBAeX;IAED;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,UAOzC;CACD"}
@@ -197,8 +197,8 @@ export class Element {
197
197
  await this.return();
198
198
  }
199
199
  }
200
- /** Internal protocol for a render, to read the element a `Markup` renders. */
201
- const source = Symbol("source");
200
+ /** Internal protocol for a render, to read the element it renders. */
201
+ export const source = Symbol("source");
202
202
  /**
203
203
  * Renders an element one chunk at a time, internal to ovr. A step is
204
204
  * synchronous unless the element has to be waited for, so nested elements cost
@@ -286,8 +286,9 @@ export class Renderer {
286
286
  }
287
287
  return new Tag(tag, props, closed);
288
288
  }
289
- if (element instanceof Markup) {
290
- // its element, which its strings would be escaped as text
289
+ if (source in element) {
290
+ // a render as a child: its element, which its strings would
291
+ // be escaped as text
291
292
  this.#element = element[source];
292
293
  this.#next = 1;
293
294
  continue;
@@ -628,7 +629,7 @@ export const readable = (render) => {
628
629
  /**
629
630
  * Renders an element to markup, such as HTML, SVG, or XML, as an
630
631
  * `AsyncIterable` of strings, a stream, or a string. `Markdown` renders the
631
- * same elements to Markdown. Made with `Render.markup`.
632
+ * same elements to Markdown. Internal to ovr, made with `new Render`.
632
633
  */
633
634
  export class Markup {
634
635
  /** Regex to find escape character for attributes */
@@ -651,7 +652,7 @@ export class Markup {
651
652
  this.#element = element;
652
653
  this.#options = options;
653
654
  }
654
- /** @returns The element, rendered in place where a `Markup` is a child */
655
+ /** @returns The element, rendered in place where a render is a child */
655
656
  get [source]() {
656
657
  return this.#element;
657
658
  }
@@ -1,20 +1,14 @@
1
1
  import type { JSX } from "../jsx/index.js";
2
2
  import { Markdown as MarkdownRender } from "../markdown/index.js";
3
- import { Chunk as ChunkClass, Markup as MarkupRender } from "../markup/index.js";
3
+ import { Chunk as ChunkClass, Markup as MarkupRender, source } from "../markup/index.js";
4
4
  export declare namespace Render {
5
5
  /** A piece of a render, an interface so declaration files name it */
6
6
  interface Chunk extends ChunkClass {
7
7
  }
8
- /** A render of markup: an `AsyncIterable` of strings, a stream, or a string */
9
- interface Markup extends MarkupRender {
10
- }
11
8
  namespace Markup {
12
9
  /** Markup options */
13
10
  type Options = MarkupRender.Options;
14
11
  }
15
- /** A render of Markdown: an `AsyncIterable` of strings, a stream, or a string */
16
- interface Markdown extends MarkdownRender {
17
- }
18
12
  namespace Markdown {
19
13
  /** Markdown options */
20
14
  type Options = MarkdownRender.Options;
@@ -22,55 +16,97 @@ export declare namespace Render {
22
16
  /** Text to escape, by where it goes: one of them */
23
17
  type Escape = {
24
18
  /** Text for an element's content */
25
- readonly html: string;
19
+ readonly markup: string;
26
20
  readonly attr?: never;
27
21
  readonly markdown?: never;
28
22
  } | {
29
23
  /** Text for an attribute's value */
30
24
  readonly attr: string;
31
- readonly html?: never;
25
+ readonly markup?: never;
32
26
  readonly markdown?: never;
33
27
  } | {
34
28
  /** Text for Markdown */
35
29
  readonly markdown: string;
36
- readonly html?: never;
30
+ readonly markup?: never;
37
31
  readonly attr?: never;
38
32
  };
39
33
  /**
40
34
  * What is written as it is, for people, agents, or both. With only
41
- * `html`, agents get the HTML too, which Markdown can contain.
35
+ * `markup`, agents get the markup too, which Markdown can contain.
42
36
  */
43
37
  type Raw = {
44
38
  /** Safe markup the page shows */
45
- readonly html: unknown;
39
+ readonly markup: unknown;
46
40
  /** What agents reading the page as Markdown get in its place, empty for nothing */
47
41
  readonly markdown?: unknown;
48
42
  } | {
49
43
  /** Safe markup the page shows, nothing when left out */
50
- readonly html?: unknown;
44
+ readonly markup?: unknown;
51
45
  /** What agents reading the page as Markdown get */
52
46
  readonly markdown: unknown;
53
47
  };
54
48
  }
55
49
  /**
56
- * Renders elements, to markup such as HTML for browsers and to Markdown for
57
- * agents, and writes what is already rendered as it is.
50
+ * A render of an element, to markup such as HTML for browsers or to Markdown
51
+ * for agents: an `AsyncIterable` of strings, a stream, or a string. Its
52
+ * static methods write what is already rendered as it is.
58
53
  *
59
54
  * ```tsx
60
- * const html = await Render.markup(<Page />).string();
61
- * const markdown = await Render.markdown(<Page />).string();
55
+ * const html = await new Render({ markup: <Page /> }).string();
56
+ * const markdown = await new Render({ markdown: <Page /> }).string();
57
+ *
58
+ * for await (const chunk of new Render({ markup: <Page /> })) {
59
+ * // each string as the element resolves
60
+ * }
62
61
  * ```
63
62
  */
64
63
  export declare class Render {
64
+ #private;
65
+ /**
66
+ * @param element The element, by what to render it to: `markup`, such as
67
+ * HTML, SVG, or XML
68
+ * @param options Markup options
69
+ */
70
+ constructor(element: {
71
+ readonly markup: JSX.Element;
72
+ }, options?: Render.Markup.Options);
73
+ /**
74
+ * @param element The element, by what to render it to: `markdown`, as
75
+ * agents that ask for it read a page. Each top level block is written as
76
+ * soon as it closes, and when the page has a `<main>` element, only its
77
+ * contents are kept
78
+ * @param options Markdown options
79
+ */
80
+ constructor(element: {
81
+ readonly markdown: JSX.Element;
82
+ }, options?: Render.Markdown.Options);
83
+ /** @returns The element, rendered in place where a render is a child */
84
+ get [source](): JSX.Element;
85
+ /** @returns Strings of the render, as the element resolves */
86
+ [Symbol.asyncIterator](): AsyncGenerator<string, void, unknown>;
87
+ /**
88
+ * The render piped into a `ReadableStream`. Iterate it when possible, to
89
+ * avoid the overhead of the stream.
90
+ *
91
+ * @returns `ReadableStream` of the render
92
+ */
93
+ stream(): ReadableStream<Uint8Array<ArrayBufferLike>>;
94
+ /**
95
+ * The whole render as one string, which buffers it and gives up the
96
+ * benefits of streaming.
97
+ *
98
+ * @returns The render, concatenated
99
+ */
100
+ string(): Promise<string>;
65
101
  /**
66
102
  * Writes markup, Markdown, or both as they are, dangerously bypassing
67
103
  * escaping, so both must be safe.
68
104
  *
69
105
  * ```tsx
70
- * Render.raw({ html: icon }); // the page and agents get the markup
71
- * Render.raw({ html: render(steps), markdown: steps }); // each its own
106
+ * Render.raw({ markup: icon }); // the page and agents get the markup
107
+ * Render.raw({ markup: render(steps), markdown: steps }); // each its own
72
108
  * Render.raw({ markdown: " · " }); // only agents
73
- * Render.raw({ html: button, markdown: "" }); // only the page
109
+ * Render.raw({ markup: button, markdown: "" }); // only the page
74
110
  * ```
75
111
  *
76
112
  * @param raw Safe markup for the page, and what agents get in its place
@@ -82,39 +118,15 @@ export declare class Render {
82
118
  * yourself, such as what `Render.raw` is given.
83
119
  *
84
120
  * ```ts
85
- * Render.escape({ html: "a < b" }); // "a &lt; b"
121
+ * Render.escape({ markup: "a < b" }); // "a &lt; b"
86
122
  * Render.escape({ attr: 'say "hi"' }); // "say &quot;hi&quot;"
87
123
  * Render.escape({ markdown: "2 * 3" }); // "2 \\* 3"
88
124
  * ```
89
125
  *
90
- * @param text Text to escape, by where it goes: `html` for an element's
126
+ * @param text Text to escape, by where it goes: `markup` for an element's
91
127
  * content, `attr` for an attribute's value, or `markdown`
92
128
  * @returns Escaped text
93
129
  */
94
130
  static escape(text: Render.Escape): string;
95
- /**
96
- * Renders an element to markup, such as HTML, SVG, or XML.
97
- *
98
- * ```tsx
99
- * for await (const chunk of Render.markup(<Page />)) {
100
- * // each string as the element resolves
101
- * }
102
- * ```
103
- *
104
- * @param element Element to render
105
- * @param options Markup options
106
- * @returns The render, to iterate, `stream()`, or `string()`
107
- */
108
- static markup(element: JSX.Element, options?: Render.Markup.Options): Render.Markup;
109
- /**
110
- * Renders an element to Markdown, as agents that ask for it read a page.
111
- * Each top level block is written as soon as it closes, and when the page
112
- * has a `<main>` element, only its contents are kept.
113
- *
114
- * @param element Element to render
115
- * @param options Markdown options
116
- * @returns The render, to iterate, `stream()`, or `string()`
117
- */
118
- static markdown(element: JSX.Element, options?: Render.Markdown.Options): Render.Markdown;
119
131
  }
120
132
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE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AO,CAAA;KAAE,EAC3C,OAAO,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,OAAO,EAChC;IAeF,wEAAwE;IACxE,IAAI,CAAC,MAAM,CAAC,gBAEX;IAED,8DAA8D;IAC9D,CAAC,MAAM,CAAC,aAAa,CAAC,0CAErB;IAED;;;;;OAKG;IACH,MAAM,gDAEL;IAED;;;;;OAKG;IACH,MAAM,oBAEL;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,KAAK,CAIxC;IAED;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,UAMhC;CACD"}
@@ -1,24 +1,69 @@
1
1
  import { Markdown as MarkdownRender } from "../markdown/index.js";
2
- import { Chunk as ChunkClass, Markup as MarkupRender, Source, } from "../markup/index.js";
2
+ import { Chunk as ChunkClass, Markup as MarkupRender, Source, source, } from "../markup/index.js";
3
3
  /**
4
- * Renders elements, to markup such as HTML for browsers and to Markdown for
5
- * agents, and writes what is already rendered as it is.
4
+ * A render of an element, to markup such as HTML for browsers or to Markdown
5
+ * for agents: an `AsyncIterable` of strings, a stream, or a string. Its
6
+ * static methods write what is already rendered as it is.
6
7
  *
7
8
  * ```tsx
8
- * const html = await Render.markup(<Page />).string();
9
- * const markdown = await Render.markdown(<Page />).string();
9
+ * const html = await new Render({ markup: <Page /> }).string();
10
+ * const markdown = await new Render({ markdown: <Page /> }).string();
11
+ *
12
+ * for await (const chunk of new Render({ markup: <Page /> })) {
13
+ * // each string as the element resolves
14
+ * }
10
15
  * ```
11
16
  */
12
17
  export class Render {
18
+ /** Element to render */
19
+ #element;
20
+ /** What renders it */
21
+ #render;
22
+ constructor(element, options) {
23
+ if ("markdown" in element) {
24
+ this.#element = element.markdown;
25
+ this.#render = new MarkdownRender(this.#element, options);
26
+ }
27
+ else {
28
+ this.#element = element.markup;
29
+ this.#render = new MarkupRender(this.#element, options);
30
+ }
31
+ }
32
+ /** @returns The element, rendered in place where a render is a child */
33
+ get [source]() {
34
+ return this.#element;
35
+ }
36
+ /** @returns Strings of the render, as the element resolves */
37
+ [Symbol.asyncIterator]() {
38
+ return this.#render[Symbol.asyncIterator]();
39
+ }
40
+ /**
41
+ * The render piped into a `ReadableStream`. Iterate it when possible, to
42
+ * avoid the overhead of the stream.
43
+ *
44
+ * @returns `ReadableStream` of the render
45
+ */
46
+ stream() {
47
+ return this.#render.stream();
48
+ }
49
+ /**
50
+ * The whole render as one string, which buffers it and gives up the
51
+ * benefits of streaming.
52
+ *
53
+ * @returns The render, concatenated
54
+ */
55
+ string() {
56
+ return this.#render.string();
57
+ }
13
58
  /**
14
59
  * Writes markup, Markdown, or both as they are, dangerously bypassing
15
60
  * escaping, so both must be safe.
16
61
  *
17
62
  * ```tsx
18
- * Render.raw({ html: icon }); // the page and agents get the markup
19
- * Render.raw({ html: render(steps), markdown: steps }); // each its own
63
+ * Render.raw({ markup: icon }); // the page and agents get the markup
64
+ * Render.raw({ markup: render(steps), markdown: steps }); // each its own
20
65
  * Render.raw({ markdown: " · " }); // only agents
21
- * Render.raw({ html: button, markdown: "" }); // only the page
66
+ * Render.raw({ markup: button, markdown: "" }); // only the page
22
67
  * ```
23
68
  *
24
69
  * @param raw Safe markup for the page, and what agents get in its place
@@ -26,20 +71,20 @@ export class Render {
26
71
  */
27
72
  static raw(raw) {
28
73
  return raw.markdown === undefined
29
- ? new ChunkClass(raw.html, true)
30
- : new Source(raw.markdown, raw.html);
74
+ ? new ChunkClass(raw.markup, true)
75
+ : new Source(raw.markdown, raw.markup);
31
76
  }
32
77
  /**
33
78
  * Escapes text, as a render does, to put in markup or Markdown you write
34
79
  * yourself, such as what `Render.raw` is given.
35
80
  *
36
81
  * ```ts
37
- * Render.escape({ html: "a < b" }); // "a &lt; b"
82
+ * Render.escape({ markup: "a < b" }); // "a &lt; b"
38
83
  * Render.escape({ attr: 'say "hi"' }); // "say &quot;hi&quot;"
39
84
  * Render.escape({ markdown: "2 * 3" }); // "2 \\* 3"
40
85
  * ```
41
86
  *
42
- * @param text Text to escape, by where it goes: `html` for an element's
87
+ * @param text Text to escape, by where it goes: `markup` for an element's
43
88
  * content, `attr` for an attribute's value, or `markdown`
44
89
  * @returns Escaped text
45
90
  */
@@ -48,34 +93,6 @@ export class Render {
48
93
  ? MarkdownRender.escape(text.markdown)
49
94
  : text.attr !== undefined
50
95
  ? MarkupRender.escape(text.attr, true)
51
- : MarkupRender.escape(text.html);
52
- }
53
- /**
54
- * Renders an element to markup, such as HTML, SVG, or XML.
55
- *
56
- * ```tsx
57
- * for await (const chunk of Render.markup(<Page />)) {
58
- * // each string as the element resolves
59
- * }
60
- * ```
61
- *
62
- * @param element Element to render
63
- * @param options Markup options
64
- * @returns The render, to iterate, `stream()`, or `string()`
65
- */
66
- static markup(element, options) {
67
- return new MarkupRender(element, options);
68
- }
69
- /**
70
- * Renders an element to Markdown, as agents that ask for it read a page.
71
- * Each top level block is written as soon as it closes, and when the page
72
- * has a `<main>` element, only its contents are kept.
73
- *
74
- * @param element Element to render
75
- * @param options Markdown options
76
- * @returns The render, to iterate, `stream()`, or `string()`
77
- */
78
- static markdown(element, options) {
79
- return new MarkdownRender(element, options);
96
+ : MarkupRender.escape(text.markup);
80
97
  }
81
98
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "ovr",
3
3
  "description": "Web apps anyone can use. Each route serves people a page and agents Markdown and MCP tools, with forms, Postgres, and passkey sign-in built in.",
4
- "version": "7.0.0-next.35",
4
+ "version": "7.0.0-next.37",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -1477,13 +1477,13 @@ class Blocks {
1477
1477
 
1478
1478
  /**
1479
1479
  * Renders an element to Markdown, as an `AsyncIterable` of blocks, a stream,
1480
- * or a string, from the same elements `Markup` renders. Made with
1481
- * `Render.markdown`. Each top level block is
1480
+ * or a string, from the same elements `Markup` renders. Internal to ovr,
1481
+ * made with `new Render`. Each top level block is
1482
1482
  * written as soon as it closes, and when the page has a `<main>` element, only
1483
1483
  * its contents are kept. Raw HTML is written as it is.
1484
1484
  *
1485
1485
  * ```tsx
1486
- * const markdown = await Render.markdown(<Post post={post} />, { base: url }).string();
1486
+ * const markdown = await new Render({ markdown: <Post post={post} /> }, { base: url }).string();
1487
1487
  * ```
1488
1488
  */
1489
1489
  export class Markdown {
@@ -224,8 +224,8 @@ export class Element implements AsyncGenerator<Chunk, void, unknown> {
224
224
  }
225
225
  }
226
226
 
227
- /** Internal protocol for a render, to read the element a `Markup` renders. */
228
- const source = Symbol("source");
227
+ /** Internal protocol for a render, to read the element it renders. */
228
+ export const source = Symbol("source");
229
229
 
230
230
  /** One step of a render: a chunk, a wait before the next step, or nothing once it is done */
231
231
  export type Step = Chunk | Promise<unknown> | undefined;
@@ -343,9 +343,10 @@ export class Renderer {
343
343
  return new Tag(tag, props, closed);
344
344
  }
345
345
 
346
- if (element instanceof Markup) {
347
- // its element, which its strings would be escaped as text
348
- this.#element = element[source];
346
+ if (source in element) {
347
+ // a render as a child: its element, which its strings would
348
+ // be escaped as text
349
+ this.#element = (element as { [source]: unknown })[source];
349
350
  this.#next = 1;
350
351
  continue;
351
352
  }
@@ -748,7 +749,7 @@ export namespace Markup {
748
749
  /**
749
750
  * Renders an element to markup, such as HTML, SVG, or XML, as an
750
751
  * `AsyncIterable` of strings, a stream, or a string. `Markdown` renders the
751
- * same elements to Markdown. Made with `Render.markup`.
752
+ * same elements to Markdown. Internal to ovr, made with `new Render`.
752
753
  */
753
754
  export class Markup {
754
755
  /** Regex to find escape character for attributes */
@@ -777,7 +778,7 @@ export class Markup {
777
778
  this.#options = options;
778
779
  }
779
780
 
780
- /** @returns The element, rendered in place where a `Markup` is a child */
781
+ /** @returns The element, rendered in place where a render is a child */
781
782
  get [source]() {
782
783
  return this.#element;
783
784
  }
@@ -4,23 +4,18 @@ import {
4
4
  Chunk as ChunkClass,
5
5
  Markup as MarkupRender,
6
6
  Source,
7
+ source,
7
8
  } from "../markup/index.js";
8
9
 
9
10
  export namespace Render {
10
11
  /** A piece of a render, an interface so declaration files name it */
11
12
  export interface Chunk extends ChunkClass {}
12
13
 
13
- /** A render of markup: an `AsyncIterable` of strings, a stream, or a string */
14
- export interface Markup extends MarkupRender {}
15
-
16
14
  export namespace Markup {
17
15
  /** Markup options */
18
16
  export type Options = MarkupRender.Options;
19
17
  }
20
18
 
21
- /** A render of Markdown: an `AsyncIterable` of strings, a stream, or a string */
22
- export interface Markdown extends MarkdownRender {}
23
-
24
19
  export namespace Markdown {
25
20
  /** Markdown options */
26
21
  export type Options = MarkdownRender.Options;
@@ -30,61 +25,136 @@ export namespace Render {
30
25
  export type Escape =
31
26
  | {
32
27
  /** Text for an element's content */
33
- readonly html: string;
28
+ readonly markup: string;
34
29
  readonly attr?: never;
35
30
  readonly markdown?: never;
36
31
  }
37
32
  | {
38
33
  /** Text for an attribute's value */
39
34
  readonly attr: string;
40
- readonly html?: never;
35
+ readonly markup?: never;
41
36
  readonly markdown?: never;
42
37
  }
43
38
  | {
44
39
  /** Text for Markdown */
45
40
  readonly markdown: string;
46
- readonly html?: never;
41
+ readonly markup?: never;
47
42
  readonly attr?: never;
48
43
  };
49
44
 
50
45
  /**
51
46
  * What is written as it is, for people, agents, or both. With only
52
- * `html`, agents get the HTML too, which Markdown can contain.
47
+ * `markup`, agents get the markup too, which Markdown can contain.
53
48
  */
54
49
  export type Raw =
55
50
  | {
56
51
  /** Safe markup the page shows */
57
- readonly html: unknown;
52
+ readonly markup: unknown;
58
53
  /** What agents reading the page as Markdown get in its place, empty for nothing */
59
54
  readonly markdown?: unknown;
60
55
  }
61
56
  | {
62
57
  /** Safe markup the page shows, nothing when left out */
63
- readonly html?: unknown;
58
+ readonly markup?: unknown;
64
59
  /** What agents reading the page as Markdown get */
65
60
  readonly markdown: unknown;
66
61
  };
67
62
  }
68
63
 
69
64
  /**
70
- * Renders elements, to markup such as HTML for browsers and to Markdown for
71
- * agents, and writes what is already rendered as it is.
65
+ * A render of an element, to markup such as HTML for browsers or to Markdown
66
+ * for agents: an `AsyncIterable` of strings, a stream, or a string. Its
67
+ * static methods write what is already rendered as it is.
72
68
  *
73
69
  * ```tsx
74
- * const html = await Render.markup(<Page />).string();
75
- * const markdown = await Render.markdown(<Page />).string();
70
+ * const html = await new Render({ markup: <Page /> }).string();
71
+ * const markdown = await new Render({ markdown: <Page /> }).string();
72
+ *
73
+ * for await (const chunk of new Render({ markup: <Page /> })) {
74
+ * // each string as the element resolves
75
+ * }
76
76
  * ```
77
77
  */
78
78
  export class Render {
79
+ /** Element to render */
80
+ readonly #element: JSX.Element;
81
+
82
+ /** What renders it */
83
+ readonly #render: MarkupRender | MarkdownRender;
84
+
85
+ /**
86
+ * @param element The element, by what to render it to: `markup`, such as
87
+ * HTML, SVG, or XML
88
+ * @param options Markup options
89
+ */
90
+ constructor(
91
+ element: { readonly markup: JSX.Element },
92
+ options?: Render.Markup.Options,
93
+ );
94
+ /**
95
+ * @param element The element, by what to render it to: `markdown`, as
96
+ * agents that ask for it read a page. Each top level block is written as
97
+ * soon as it closes, and when the page has a `<main>` element, only its
98
+ * contents are kept
99
+ * @param options Markdown options
100
+ */
101
+ constructor(
102
+ element: { readonly markdown: JSX.Element },
103
+ options?: Render.Markdown.Options,
104
+ );
105
+ constructor(
106
+ element:
107
+ { readonly markup: JSX.Element } | { readonly markdown: JSX.Element },
108
+ options?: Render.Markup.Options & Render.Markdown.Options,
109
+ ) {
110
+ if ("markdown" in element) {
111
+ this.#element = element.markdown;
112
+ this.#render = new MarkdownRender(this.#element, options);
113
+ } else {
114
+ this.#element = element.markup;
115
+ this.#render = new MarkupRender(this.#element, options);
116
+ }
117
+ }
118
+
119
+ /** @returns The element, rendered in place where a render is a child */
120
+ get [source]() {
121
+ return this.#element;
122
+ }
123
+
124
+ /** @returns Strings of the render, as the element resolves */
125
+ [Symbol.asyncIterator]() {
126
+ return this.#render[Symbol.asyncIterator]();
127
+ }
128
+
129
+ /**
130
+ * The render piped into a `ReadableStream`. Iterate it when possible, to
131
+ * avoid the overhead of the stream.
132
+ *
133
+ * @returns `ReadableStream` of the render
134
+ */
135
+ stream() {
136
+ return this.#render.stream();
137
+ }
138
+
139
+ /**
140
+ * The whole render as one string, which buffers it and gives up the
141
+ * benefits of streaming.
142
+ *
143
+ * @returns The render, concatenated
144
+ */
145
+ string() {
146
+ return this.#render.string();
147
+ }
148
+
79
149
  /**
80
150
  * Writes markup, Markdown, or both as they are, dangerously bypassing
81
151
  * escaping, so both must be safe.
82
152
  *
83
153
  * ```tsx
84
- * Render.raw({ html: icon }); // the page and agents get the markup
85
- * Render.raw({ html: render(steps), markdown: steps }); // each its own
154
+ * Render.raw({ markup: icon }); // the page and agents get the markup
155
+ * Render.raw({ markup: render(steps), markdown: steps }); // each its own
86
156
  * Render.raw({ markdown: " · " }); // only agents
87
- * Render.raw({ html: button, markdown: "" }); // only the page
157
+ * Render.raw({ markup: button, markdown: "" }); // only the page
88
158
  * ```
89
159
  *
90
160
  * @param raw Safe markup for the page, and what agents get in its place
@@ -92,8 +162,8 @@ export class Render {
92
162
  */
93
163
  static raw(raw: Render.Raw): Render.Chunk {
94
164
  return raw.markdown === undefined
95
- ? new ChunkClass(raw.html, true)
96
- : new Source(raw.markdown, raw.html);
165
+ ? new ChunkClass(raw.markup, true)
166
+ : new Source(raw.markdown, raw.markup);
97
167
  }
98
168
 
99
169
  /**
@@ -101,12 +171,12 @@ export class Render {
101
171
  * yourself, such as what `Render.raw` is given.
102
172
  *
103
173
  * ```ts
104
- * Render.escape({ html: "a < b" }); // "a &lt; b"
174
+ * Render.escape({ markup: "a < b" }); // "a &lt; b"
105
175
  * Render.escape({ attr: 'say "hi"' }); // "say &quot;hi&quot;"
106
176
  * Render.escape({ markdown: "2 * 3" }); // "2 \\* 3"
107
177
  * ```
108
178
  *
109
- * @param text Text to escape, by where it goes: `html` for an element's
179
+ * @param text Text to escape, by where it goes: `markup` for an element's
110
180
  * content, `attr` for an attribute's value, or `markdown`
111
181
  * @returns Escaped text
112
182
  */
@@ -115,42 +185,6 @@ export class Render {
115
185
  ? MarkdownRender.escape(text.markdown)
116
186
  : text.attr !== undefined
117
187
  ? MarkupRender.escape(text.attr, true)
118
- : MarkupRender.escape(text.html);
119
- }
120
-
121
- /**
122
- * Renders an element to markup, such as HTML, SVG, or XML.
123
- *
124
- * ```tsx
125
- * for await (const chunk of Render.markup(<Page />)) {
126
- * // each string as the element resolves
127
- * }
128
- * ```
129
- *
130
- * @param element Element to render
131
- * @param options Markup options
132
- * @returns The render, to iterate, `stream()`, or `string()`
133
- */
134
- static markup(
135
- element: JSX.Element,
136
- options?: Render.Markup.Options,
137
- ): Render.Markup {
138
- return new MarkupRender(element, options);
139
- }
140
-
141
- /**
142
- * Renders an element to Markdown, as agents that ask for it read a page.
143
- * Each top level block is written as soon as it closes, and when the page
144
- * has a `<main>` element, only its contents are kept.
145
- *
146
- * @param element Element to render
147
- * @param options Markdown options
148
- * @returns The render, to iterate, `stream()`, or `string()`
149
- */
150
- static markdown(
151
- element: JSX.Element,
152
- options?: Render.Markdown.Options,
153
- ): Render.Markdown {
154
- return new MarkdownRender(element, options);
188
+ : MarkupRender.escape(text.markup);
155
189
  }
156
190
  }