ovr 6.0.1 → 6.2.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 (50) hide show
  1. package/dist/LICENSE.md +2 -0
  2. package/dist/app/index.d.ts +1 -1
  3. package/dist/app/index.d.ts.map +1 -1
  4. package/dist/app/index.js +17 -11
  5. package/dist/context/index.d.ts +37 -13
  6. package/dist/context/index.d.ts.map +1 -1
  7. package/dist/context/index.js +70 -29
  8. package/dist/cookie/index.d.ts +1 -1
  9. package/dist/cookie/index.d.ts.map +1 -1
  10. package/dist/cookie/index.js +2 -2
  11. package/dist/index.d.ts +4 -3
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +3 -2
  14. package/dist/jsx/elements.d.ts +194 -2
  15. package/dist/jsx/elements.d.ts.map +1 -1
  16. package/dist/jsx/index.d.ts.map +1 -1
  17. package/dist/jsx/index.js +18 -8
  18. package/dist/middleware/index.d.ts +12 -3
  19. package/dist/middleware/index.d.ts.map +1 -1
  20. package/dist/multipart/index.d.ts +5 -0
  21. package/dist/multipart/index.d.ts.map +1 -1
  22. package/dist/multipart/index.js +22 -24
  23. package/dist/render/index.d.ts +1 -0
  24. package/dist/render/index.d.ts.map +1 -1
  25. package/dist/render/index.js +6 -4
  26. package/dist/route/index.d.ts +143 -42
  27. package/dist/route/index.d.ts.map +1 -1
  28. package/dist/route/index.js +95 -43
  29. package/dist/schema/index.d.ts +1286 -0
  30. package/dist/schema/index.d.ts.map +1 -0
  31. package/dist/schema/index.js +1321 -0
  32. package/dist/trie/index.d.ts.map +1 -1
  33. package/dist/trie/index.js +8 -2
  34. package/dist/util/index.d.ts +138 -9
  35. package/dist/util/index.d.ts.map +1 -1
  36. package/dist/util/index.js +152 -19
  37. package/package.json +4 -1
  38. package/src/app/index.ts +17 -15
  39. package/src/context/index.ts +116 -40
  40. package/src/cookie/index.ts +5 -5
  41. package/src/index.ts +4 -3
  42. package/src/jsx/elements.ts +320 -64
  43. package/src/jsx/index.ts +16 -8
  44. package/src/middleware/index.ts +19 -8
  45. package/src/multipart/index.ts +25 -27
  46. package/src/render/index.ts +7 -4
  47. package/src/route/index.ts +338 -94
  48. package/src/schema/index.ts +2794 -0
  49. package/src/trie/index.ts +12 -2
  50. package/src/util/index.ts +193 -19
@@ -469,69 +469,66 @@ type LabelAttributes = Attributes<{ for: string }>;
469
469
 
470
470
  type LiAttributes = Attributes<{ value: string | number }>;
471
471
 
472
- type LinkAttributes = Attributes<
473
- {
474
- as:
475
- | "audio"
476
- | "document"
477
- | "embed"
478
- | "fetch"
479
- | "font"
480
- | "image"
481
- | "object"
482
- | "script"
483
- | "style"
484
- | "track"
485
- | "video"
486
- | "worker";
487
- blocking: SharedAttributes["blocking"];
488
- crossorigin: SharedAttributes["crossorigin"];
489
- disabled: boolean;
490
- fetchpriority: SharedAttributes["fetchpriority"];
491
- href: string;
492
- hreflang: string;
493
- imagesizes: string;
494
- imagesrcset: string;
495
- integrity: string;
496
- media: string;
497
- // not all the same options as others
498
- referrerpolicy:
499
- | "no-referrer"
500
- | "no-referrer-when-downgrade"
501
- | "origin"
502
- | "origin-when-cross-origin"
503
- | "unsafe-url";
504
- // not all the same options as others
505
- rel:
506
- | "alternate"
507
- | "author"
508
- | "canonical"
509
- | "dns-prefetch"
510
- | "expect"
511
- | "help"
512
- | "icon"
513
- | "license"
514
- | "manifest"
515
- | "me"
516
- | "modulepreload"
517
- | "next"
518
- | "pingback"
519
- | "preconnect"
520
- | "prefetch"
521
- | "preload"
522
- | "prerender"
523
- | "prev"
524
- | "privacy-policy"
525
- | "search"
526
- | "stylesheet"
527
- | "terms-of-service"
528
- // allows multiple
529
- | (string & {});
530
- sizes: string;
531
- type: string;
532
- },
533
- undefined
534
- >;
472
+ type LinkAttributes = Attributes<{
473
+ as:
474
+ | "audio"
475
+ | "document"
476
+ | "embed"
477
+ | "fetch"
478
+ | "font"
479
+ | "image"
480
+ | "object"
481
+ | "script"
482
+ | "style"
483
+ | "track"
484
+ | "video"
485
+ | "worker";
486
+ blocking: SharedAttributes["blocking"];
487
+ crossorigin: SharedAttributes["crossorigin"];
488
+ disabled: boolean;
489
+ fetchpriority: SharedAttributes["fetchpriority"];
490
+ href: string;
491
+ hreflang: string;
492
+ imagesizes: string;
493
+ imagesrcset: string;
494
+ integrity: string;
495
+ media: string;
496
+ // not all the same options as others
497
+ referrerpolicy:
498
+ | "no-referrer"
499
+ | "no-referrer-when-downgrade"
500
+ | "origin"
501
+ | "origin-when-cross-origin"
502
+ | "unsafe-url";
503
+ // not all the same options as others
504
+ rel:
505
+ | "alternate"
506
+ | "author"
507
+ | "canonical"
508
+ | "dns-prefetch"
509
+ | "expect"
510
+ | "help"
511
+ | "icon"
512
+ | "license"
513
+ | "manifest"
514
+ | "me"
515
+ | "modulepreload"
516
+ | "next"
517
+ | "pingback"
518
+ | "preconnect"
519
+ | "prefetch"
520
+ | "preload"
521
+ | "prerender"
522
+ | "prev"
523
+ | "privacy-policy"
524
+ | "search"
525
+ | "stylesheet"
526
+ | "terms-of-service"
527
+ // allows multiple
528
+ | (string & {});
529
+ sizes: string;
530
+ type: string;
531
+ }>; // not strictly a void element since it can have children in XML
535
532
 
536
533
  type MapAttributes = Attributes<{ name: string }>;
537
534
 
@@ -713,7 +710,234 @@ type VideoAttributes = Attributes<{
713
710
  width: string | number;
714
711
  }>;
715
712
 
716
- /** Standard HTML elements */
713
+ // XML
714
+ type XMLAttributes<
715
+ P extends JSX.Props = JSX.Props,
716
+ Children = JSX.Element,
717
+ > = Partial<{ children: Children; xmlns: string }> & JSX.Props & Partial<P>;
718
+
719
+ type XMLDeclarationAttributes = {
720
+ version?: "1.0" | (string & {});
721
+ encoding?: "utf-8" | (string & {});
722
+ standalone?: "yes" | "no";
723
+ };
724
+
725
+ type RSSAttributes = XMLAttributes<{
726
+ version: "2.0" | (string & {});
727
+ "xmlns:atom": string;
728
+ }>;
729
+
730
+ type AtomLinkAttributes = {
731
+ href: string;
732
+ rel?: "alternate" | "related" | "self" | "enclosure" | "via" | (string & {});
733
+ type?:
734
+ | "application/atom+xml"
735
+ | "application/rss+xml"
736
+ | "application/xml"
737
+ | "text/xml"
738
+ | "text/html"
739
+ | (string & {});
740
+ hreflang?: string;
741
+ title?: string;
742
+ length?: string | number;
743
+ };
744
+
745
+ // SVG
746
+ // SVG
747
+ type SvgAttributes<
748
+ P extends JSX.Props = JSX.Props,
749
+ Children = JSX.Element,
750
+ > = Partial<{
751
+ children: Children;
752
+ // Core attributes
753
+ id: string;
754
+ class: string;
755
+ style: string;
756
+ // Presentation attributes
757
+ fill: string;
758
+ "fill-opacity": string | number;
759
+ "fill-rule": "nonzero" | "evenodd";
760
+ stroke: string;
761
+ "stroke-width": string | number;
762
+ "stroke-opacity": string | number;
763
+ "stroke-linecap": "butt" | "round" | "square";
764
+ "stroke-linejoin": "miter" | "round" | "bevel";
765
+ "stroke-dasharray": string;
766
+ "stroke-dashoffset": string | number;
767
+ opacity: string | number;
768
+ transform: string;
769
+ "transform-origin": string;
770
+ // Clipping / masking
771
+ "clip-path": string;
772
+ "clip-rule": "nonzero" | "evenodd";
773
+ mask: string;
774
+ }> &
775
+ JSX.Props &
776
+ Partial<P>;
777
+
778
+ type SvgRootAttributes = SvgAttributes<{
779
+ xmlns: string;
780
+ "xmlns:xlink": string;
781
+ width: string | number;
782
+ height: string | number;
783
+ viewBox: string;
784
+ preserveAspectRatio:
785
+ | "none"
786
+ | "xMinYMin"
787
+ | "xMidYMin"
788
+ | "xMaxYMin"
789
+ | "xMinYMid"
790
+ | "xMidYMid"
791
+ | "xMaxYMid"
792
+ | "xMinYMax"
793
+ | "xMidYMax"
794
+ | "xMaxYMax"
795
+ | (string & {});
796
+ }>;
797
+
798
+ type SvgPathAttributes = SvgAttributes<{ d: string }>;
799
+
800
+ type SvgCircleAttributes = SvgAttributes<{
801
+ cx: string | number;
802
+ cy: string | number;
803
+ r: string | number;
804
+ }>;
805
+
806
+ type SvgEllipseAttributes = SvgAttributes<{
807
+ cx: string | number;
808
+ cy: string | number;
809
+ rx: string | number;
810
+ ry: string | number;
811
+ }>;
812
+
813
+ type SvgRectAttributes = SvgAttributes<{
814
+ x: string | number;
815
+ y: string | number;
816
+ width: string | number;
817
+ height: string | number;
818
+ rx: string | number;
819
+ ry: string | number;
820
+ }>;
821
+
822
+ type SvgLineAttributes = SvgAttributes<{
823
+ x1: string | number;
824
+ y1: string | number;
825
+ x2: string | number;
826
+ y2: string | number;
827
+ }>;
828
+
829
+ type SvgPolylineAttributes = SvgAttributes<{ points: string }>;
830
+
831
+ type SvgPolygonAttributes = SvgAttributes<{ points: string }>;
832
+
833
+ type SvgTextAttributes = SvgAttributes<{
834
+ x: string | number;
835
+ y: string | number;
836
+ dx: string | number;
837
+ dy: string | number;
838
+ "text-anchor": "start" | "middle" | "end";
839
+ "dominant-baseline":
840
+ | "auto"
841
+ | "middle"
842
+ | "hanging"
843
+ | "mathematical"
844
+ | "text-top"
845
+ | "text-bottom"
846
+ | (string & {});
847
+ "font-family": string;
848
+ "font-size": string | number;
849
+ "font-weight": string | number;
850
+ "letter-spacing": string | number;
851
+ }>;
852
+
853
+ type SvgTspanAttributes = SvgAttributes<{
854
+ x: string | number;
855
+ y: string | number;
856
+ dx: string | number;
857
+ dy: string | number;
858
+ }>;
859
+
860
+ type SvgUseAttributes = SvgAttributes<{
861
+ href: string;
862
+ "xlink:href": string;
863
+ x: string | number;
864
+ y: string | number;
865
+ width: string | number;
866
+ height: string | number;
867
+ }>;
868
+
869
+ type SvgSymbolAttributes = SvgAttributes<{
870
+ viewBox: string;
871
+ preserveAspectRatio: SvgRootAttributes["preserveAspectRatio"];
872
+ }>;
873
+
874
+ type SvgImageAttributes = SvgAttributes<{
875
+ href: string;
876
+ "xlink:href": string;
877
+ x: string | number;
878
+ y: string | number;
879
+ width: string | number;
880
+ height: string | number;
881
+ preserveAspectRatio: SvgRootAttributes["preserveAspectRatio"];
882
+ }>;
883
+
884
+ type SvgLinearGradientAttributes = SvgAttributes<
885
+ {
886
+ x1: string | number;
887
+ y1: string | number;
888
+ x2: string | number;
889
+ y2: string | number;
890
+ gradientUnits: "userSpaceOnUse" | "objectBoundingBox";
891
+ gradientTransform: string;
892
+ spreadMethod: "pad" | "reflect" | "repeat";
893
+ },
894
+ undefined
895
+ >;
896
+
897
+ type SvgRadialGradientAttributes = SvgAttributes<
898
+ {
899
+ cx: string | number;
900
+ cy: string | number;
901
+ r: string | number;
902
+ fx: string | number;
903
+ fy: string | number;
904
+ gradientUnits: "userSpaceOnUse" | "objectBoundingBox";
905
+ gradientTransform: string;
906
+ spreadMethod: "pad" | "reflect" | "repeat";
907
+ },
908
+ undefined
909
+ >;
910
+
911
+ type SvgStopAttributes = SvgAttributes<
912
+ {
913
+ offset: string | number;
914
+ "stop-color": string;
915
+ "stop-opacity": string | number;
916
+ },
917
+ undefined
918
+ >;
919
+
920
+ type SvgClipPathAttributes = SvgAttributes<{
921
+ clipPathUnits: "userSpaceOnUse" | "objectBoundingBox";
922
+ }>;
923
+
924
+ type SvgMaskAttributes = SvgAttributes<{
925
+ x: string | number;
926
+ y: string | number;
927
+ width: string | number;
928
+ height: string | number;
929
+ maskUnits: "userSpaceOnUse" | "objectBoundingBox";
930
+ maskContentUnits: "userSpaceOnUse" | "objectBoundingBox";
931
+ }>;
932
+
933
+ type SvgForeignObjectAttributes = SvgAttributes<{
934
+ x: string | number;
935
+ y: string | number;
936
+ width: string | number;
937
+ height: string | number;
938
+ }>;
939
+
940
+ /** Standard HTML/XML elements */
717
941
  export type IntrinsicElements =
718
942
  // allows custom elements
719
943
  Record<string, Attributes> & {
@@ -828,4 +1052,36 @@ export type IntrinsicElements =
828
1052
  var: Attributes;
829
1053
  video: VideoAttributes;
830
1054
  wbr: Attributes<JSX.Props, undefined>;
1055
+
1056
+ // XML that have xmlns or more
1057
+ // custom are still allowed so they are covered
1058
+ xml: XMLDeclarationAttributes;
1059
+ rss: RSSAttributes;
1060
+ channel: XMLAttributes;
1061
+ item: XMLAttributes;
1062
+ urlset: XMLAttributes;
1063
+ "atom:link": AtomLinkAttributes;
1064
+
1065
+ // SVG
1066
+ svg: SvgRootAttributes;
1067
+ g: SvgAttributes;
1068
+ defs: SvgAttributes;
1069
+ path: SvgPathAttributes;
1070
+ circle: SvgCircleAttributes;
1071
+ ellipse: SvgEllipseAttributes;
1072
+ rect: SvgRectAttributes;
1073
+ line: SvgLineAttributes;
1074
+ polyline: SvgPolylineAttributes;
1075
+ polygon: SvgPolygonAttributes;
1076
+ text: SvgTextAttributes;
1077
+ tspan: SvgTspanAttributes;
1078
+ use: SvgUseAttributes;
1079
+ symbol: SvgSymbolAttributes;
1080
+ image: SvgImageAttributes;
1081
+ linearGradient: SvgLinearGradientAttributes;
1082
+ radialGradient: SvgRadialGradientAttributes;
1083
+ stop: SvgStopAttributes;
1084
+ clipPath: SvgClipPathAttributes;
1085
+ mask: SvgMaskAttributes;
1086
+ foreignObject: SvgForeignObjectAttributes;
831
1087
  };
package/src/jsx/index.ts CHANGED
@@ -49,6 +49,7 @@ export class JSX {
49
49
  "source",
50
50
  "track",
51
51
  "wbr",
52
+ "xml",
52
53
  ]);
53
54
 
54
55
  /**
@@ -72,11 +73,9 @@ export class JSX {
72
73
  return;
73
74
  }
74
75
 
75
- if (tag === "html") yield Render.html("<!doctype html>");
76
-
77
76
  // intrinsic element
78
77
  // faster to concatenate attributes than to yield them as separate chunks
79
- let attributes = "";
78
+ let opening = tag;
80
79
 
81
80
  for (const key in props) {
82
81
  // more memory efficient to skip children instead of destructuring and using ...rest
@@ -86,18 +85,27 @@ export class JSX {
86
85
 
87
86
  if (value === true) {
88
87
  // just put the key without the value
89
- attributes += ` ${key}`;
88
+ opening += ` ${key}`;
90
89
  } else if (typeof value === "string") {
91
- attributes += ` ${key}="${Render.escape(value, true)}"`;
90
+ opening += ` ${key}="${Render.escape(value, true)}"`;
92
91
  } else if (typeof value === "number" || typeof value === "bigint") {
93
- attributes += ` ${key}="${value}"`;
92
+ opening += ` ${key}="${value}"`;
94
93
  }
95
94
  // otherwise, don't include the attribute
96
95
  }
97
96
 
98
- yield Render.html(`<${tag}${attributes}>`);
97
+ if (tag === "html") {
98
+ yield Render.html(`<!doctype html><${opening}>`);
99
+ } else if (tag === "xml") {
100
+ yield Render.html(`<?${opening}?>`);
101
+ } else {
102
+ yield Render.html(`<${opening}>`);
103
+ }
99
104
 
100
- if (JSX.#void.has(tag)) return;
105
+ // if children and a void element, render it like normal
106
+ // to account for cases like XML <link>content</link>
107
+ // assumes the user knows what they are doing
108
+ if (props.children == null && JSX.#void.has(tag)) return;
101
109
 
102
110
  yield* new Render(props.children);
103
111
 
@@ -1,15 +1,25 @@
1
- import type { Context } from "../context/index.js";
1
+ import type { Context as ContextType } from "../context/index.js";
2
+ import type { Cookie as CookieType } from "../cookie/index.js";
3
+ import type { Form } from "../schema/index.js";
2
4
  import type { Trie } from "../trie/index.js";
3
5
 
4
6
  export namespace Middleware {
7
+ export namespace Context {
8
+ export namespace Cookie {
9
+ export type Options = CookieType.Options;
10
+ }
11
+ }
12
+
5
13
  /**
6
14
  * Middleware context.
7
15
  *
8
16
  * @template Params Parameters created from a route match
17
+ * @template Shape Parsed form data shape
9
18
  */
10
- export type Context<Params extends Trie.Params = Trie.Params> = InstanceType<
11
- typeof Context<Params>
12
- >;
19
+ export type Context<
20
+ Params extends Trie.Params = Trie.Params,
21
+ Shape extends Form.Shape = Form.Shape,
22
+ > = ContextType<Params, Shape>;
13
23
 
14
24
  /** Dispatches the next middleware in the stack */
15
25
  export type Next = () => Promise<void>;
@@ -19,11 +29,12 @@ export namespace Middleware {
19
29
  * App middleware.
20
30
  *
21
31
  * @template Params Parameters created from a route match
32
+ * @template Shape Parsed form data shape
22
33
  * @param context Request context
23
34
  * @param next Dispatches the next middleware in the stack
24
35
  * @returns `Response` or element(s) to stream as HTML
25
36
  */
26
- export type Middleware<Params extends Trie.Params = Trie.Params> = (
27
- context: Middleware.Context<Params>,
28
- next: Middleware.Next,
29
- ) => any;
37
+ export type Middleware<
38
+ Params extends Trie.Params = Trie.Params,
39
+ Shape extends Form.Shape = Form.Shape,
40
+ > = (context: ContextType<Params, Shape>, next: Middleware.Next) => any;
@@ -1,4 +1,4 @@
1
- import { Codec, Header } from "../util/index.js";
1
+ import { Codec, Header, Mime, Size } from "../util/index.js";
2
2
 
3
3
  /** Sequence of bytes to find within the stream */
4
4
  class Needle extends Uint8Array {
@@ -50,6 +50,7 @@ class Part extends Request {
50
50
  */
51
51
  readonly filename: string | null;
52
52
 
53
+ // this is named `type` instead of `mime` to align with `Blob.type`
53
54
  /**
54
55
  * Media type of the part
55
56
  *
@@ -91,12 +92,26 @@ class Part extends Request {
91
92
  duplex: "half",
92
93
  });
93
94
 
94
- [this.type] = Header.shift(this.headers.get(Header.contentType));
95
+ [this.type] = Header.shift(this.headers.get(Header.name.type));
95
96
 
96
97
  ({ name: this.name = null, filename: this.filename = null } = Header.params(
97
- this.headers.get("content-disposition"),
98
+ this.headers.get(Header.name.disp),
98
99
  ));
99
100
  }
101
+
102
+ /**
103
+ *
104
+ * @returns Buffered FormDataEntryValue
105
+ */
106
+ async value(): Promise<FormDataEntryValue> {
107
+ if (this.filename || this.type === Mime.type.stream) {
108
+ const blob = await this.blob();
109
+
110
+ return new File([blob], this.filename ?? "blob", { type: blob.type });
111
+ }
112
+
113
+ return this.text();
114
+ }
100
115
  }
101
116
 
102
117
  export namespace Multipart {
@@ -159,16 +174,13 @@ export namespace Multipart {
159
174
 
160
175
  /** Multipart request */
161
176
  export class Multipart extends Request {
162
- static readonly #kb = 1024;
163
- static readonly #mb = 1024 ** 2;
164
-
165
177
  /** New line needle to share across requests and parts */
166
178
  static readonly #newLine = new Needle("\r\n\r\n");
167
179
 
168
180
  /** Parser options */
169
181
  readonly #options: Required<Multipart.Options> = {
170
- memory: 4 * Multipart.#mb,
171
- payload: 16 * Multipart.#mb,
182
+ memory: 4 * Size.mb,
183
+ payload: 16 * Size.mb,
172
184
  parts: Infinity,
173
185
  };
174
186
 
@@ -214,11 +226,9 @@ export class Multipart extends Request {
214
226
  constructor(req: Request, options?: Multipart.Options) {
215
227
  super(req);
216
228
 
217
- const [type, params] = Header.shift(this.headers.get(Header.contentType));
229
+ const [mime, params] = Header.shift(this.headers.get(Header.name.type));
218
230
 
219
- if (!type?.startsWith("multipart/")) {
220
- throw new TypeError("Unsupported Media Type");
221
- }
231
+ if (!Mime.multipart(mime)) throw new TypeError("Unsupported Media Type");
222
232
 
223
233
  const { boundary } = Header.params(params);
224
234
 
@@ -234,7 +244,7 @@ export class Multipart extends Request {
234
244
  new ArrayBuffer(
235
245
  // slightly larger than common chunk size/high water mark 64kb for leftover boundary
236
246
  // prevents having to resize memory for most requests
237
- 65 * Multipart.#kb,
247
+ 65 * Size.kb,
238
248
  // cap max chunk size + leftover
239
249
  { maxByteLength: this.#options.memory },
240
250
  ),
@@ -427,6 +437,7 @@ export class Multipart extends Request {
427
437
  // cannot cancel, chunks would be in the next header
428
438
  if (part.body && !part.bodyUsed) {
429
439
  const partReader = part.body.getReader();
440
+
430
441
  try {
431
442
  while (!(await partReader.read()).done);
432
443
  } finally {
@@ -464,20 +475,7 @@ export class Multipart extends Request {
464
475
  const data = new FormData();
465
476
 
466
477
  for await (const part of this) {
467
- if (part.name) {
468
- let value: string | File;
469
-
470
- if (part.filename || part.type === "application/octet-stream") {
471
- const blob = await part.blob();
472
- value = new File([blob], part.filename ?? "blob", {
473
- type: blob.type,
474
- });
475
- } else {
476
- value = await part.text();
477
- }
478
-
479
- data.append(part.name, value);
480
- }
478
+ if (part.name) data.append(part.name, await part.value());
481
479
  }
482
480
 
483
481
  return data;
@@ -1,5 +1,5 @@
1
1
  import type { JSX } from "../jsx/index.js";
2
- import { Codec } from "../util/index.js";
2
+ import { Codec, Size } from "../util/index.js";
3
3
 
4
4
  type Next = { i: number; result: IteratorResult<Chunk, void> };
5
5
 
@@ -83,9 +83,11 @@ export class Render {
83
83
  if (element instanceof Promise) element = await element;
84
84
 
85
85
  // resolve based on type
86
- // should not render
87
- if (element == null || typeof element === "boolean" || element === "")
86
+
87
+ if (element == null || typeof element === "boolean" || element === "") {
88
+ // should not render
88
89
  return;
90
+ }
89
91
 
90
92
  if (element instanceof Chunk) {
91
93
  // already escaped or safe
@@ -201,7 +203,7 @@ export class Render {
201
203
  // https://blog.cloudflare.com/unpacking-cloudflare-workers-cpu-performance-benchmarks/#inefficient-streams-adapters
202
204
  // in Node, the default is 16kb, so this stacks another 2kb in front
203
205
  // https://nodejs.org/api/http.html#outgoingmessagewritablehighwatermark
204
- highWaterMark: 2048,
206
+ highWaterMark: 2 * Size.kb,
205
207
  },
206
208
  );
207
209
  }
@@ -212,6 +214,7 @@ export class Render {
212
214
  * ### WARNING
213
215
  *
214
216
  * This negates streaming benefits and buffers the result into a string.
217
+ *
215
218
  * @param element Element to render
216
219
  * @param options Render options
217
220
  * @returns Concatenated HTML