dom-expressions 0.37.7 → 0.37.9

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dom-expressions",
3
3
  "description": "A Fine-Grained Runtime for Performant DOM Rendering",
4
- "version": "0.37.7",
4
+ "version": "0.37.9",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -20,12 +20,12 @@
20
20
  },
21
21
  "peerDependencies": {
22
22
  "csstype": "^3.0",
23
- "seroval": "^0.12.0"
23
+ "seroval": "^0.14.1"
24
24
  },
25
25
  "devDependencies": {
26
- "babel-plugin-jsx-dom-expressions": "^0.37.7",
26
+ "babel-plugin-jsx-dom-expressions": "^0.37.9",
27
27
  "csstype": "^3.1",
28
- "seroval": "^0.12.0"
28
+ "seroval": "^0.14.1"
29
29
  },
30
- "gitHead": "5a6904fe67f815157f00496c23a538f4b8218ad0"
30
+ "gitHead": "2079bbeb5908166253370dd02ba1ce99afb2a2d4"
31
31
  }
package/src/constants.js CHANGED
@@ -10,6 +10,7 @@ const booleans = [
10
10
  "formnovalidate",
11
11
  "hidden",
12
12
  "indeterminate",
13
+ "inert",
13
14
  "ismap",
14
15
  "loop",
15
16
  "multiple",
package/src/jsx-h.d.ts CHANGED
@@ -51,6 +51,13 @@ export namespace JSX {
51
51
  1: any;
52
52
  }
53
53
  type EventHandlerUnion<T, E extends Event> = EventHandler<T, E> | BoundEventHandler<T, E>;
54
+
55
+ const SERIALIZABLE: unique symbol;
56
+ interface SerializableAttributeValue {
57
+ toString(): string;
58
+ [SERIALIZABLE]: never;
59
+ }
60
+
54
61
  interface IntrinsicAttributes {
55
62
  ref?: unknown | ((e: unknown) => void);
56
63
  }
@@ -718,7 +725,7 @@ export namespace JSX {
718
725
  autofocus?: FunctionMaybe<boolean>;
719
726
  disabled?: FunctionMaybe<boolean>;
720
727
  form?: FunctionMaybe<string>;
721
- formaction?: FunctionMaybe<string>;
728
+ formaction?: FunctionMaybe<string | SerializableAttributeValue>;
722
729
  formenctype?: FunctionMaybe<HTMLFormEncType>;
723
730
  formmethod?: FunctionMaybe<HTMLFormMethod>;
724
731
  formnovalidate?: FunctionMaybe<boolean>;
@@ -726,7 +733,7 @@ export namespace JSX {
726
733
  name?: FunctionMaybe<string>;
727
734
  type?: FunctionMaybe<"submit" | "reset" | "button">;
728
735
  value?: FunctionMaybe<string>;
729
- formAction?: FunctionMaybe<string>;
736
+ formAction?: FunctionMaybe<string | SerializableAttributeValue>;
730
737
  formEnctype?: FunctionMaybe<HTMLFormEncType>;
731
738
  formMethod?: FunctionMaybe<HTMLFormMethod>;
732
739
  formNoValidate?: FunctionMaybe<boolean>;
@@ -767,7 +774,7 @@ export namespace JSX {
767
774
  }
768
775
  interface FormHTMLAttributes<T> extends HTMLAttributes<T> {
769
776
  "accept-charset"?: FunctionMaybe<string>;
770
- action?: FunctionMaybe<string>;
777
+ action?: FunctionMaybe<string | SerializableAttributeValue>;
771
778
  autocomplete?: FunctionMaybe<string>;
772
779
  encoding?: FunctionMaybe<HTMLFormEncType>;
773
780
  enctype?: FunctionMaybe<HTMLFormEncType>;
@@ -819,7 +826,7 @@ export namespace JSX {
819
826
  crossorigin?: FunctionMaybe<HTMLCrossorigin>;
820
827
  disabled?: FunctionMaybe<boolean>;
821
828
  form?: FunctionMaybe<string>;
822
- formaction?: FunctionMaybe<string>;
829
+ formaction?: FunctionMaybe<string | SerializableAttributeValue>;
823
830
  formenctype?: FunctionMaybe<HTMLFormEncType>;
824
831
  formmethod?: FunctionMaybe<HTMLFormMethod>;
825
832
  formnovalidate?: FunctionMaybe<boolean>;
@@ -843,7 +850,7 @@ export namespace JSX {
843
850
  value?: FunctionMaybe<string | string[] | number>;
844
851
  width?: FunctionMaybe<number | string>;
845
852
  crossOrigin?: FunctionMaybe<HTMLCrossorigin>;
846
- formAction?: FunctionMaybe<string>;
853
+ formAction?: FunctionMaybe<string | SerializableAttributeValue>;
847
854
  formEnctype?: FunctionMaybe<HTMLFormEncType>;
848
855
  formMethod?: FunctionMaybe<HTMLFormMethod>;
849
856
  formNoValidate?: FunctionMaybe<boolean>;
package/src/jsx.d.ts CHANGED
@@ -118,6 +118,12 @@ export namespace JSX {
118
118
  | FocusEventHandler<T, E>
119
119
  | BoundFocusEventHandler<T, E>;
120
120
 
121
+ const SERIALIZABLE: unique symbol;
122
+ interface SerializableAttributeValue {
123
+ toString(): string;
124
+ [SERIALIZABLE]: never;
125
+ }
126
+
121
127
  interface IntrinsicAttributes {
122
128
  ref?: unknown | ((e: unknown) => void);
123
129
  }
@@ -791,7 +797,7 @@ export namespace JSX {
791
797
  autofocus?: boolean;
792
798
  disabled?: boolean;
793
799
  form?: string;
794
- formaction?: string;
800
+ formaction?: string | SerializableAttributeValue;
795
801
  formenctype?: HTMLFormEncType;
796
802
  formmethod?: HTMLFormMethod;
797
803
  formnovalidate?: boolean;
@@ -799,7 +805,7 @@ export namespace JSX {
799
805
  name?: string;
800
806
  type?: "submit" | "reset" | "button";
801
807
  value?: string;
802
- formAction?: string;
808
+ formAction?: string | SerializableAttributeValue;
803
809
  formEnctype?: HTMLFormEncType;
804
810
  formMethod?: HTMLFormMethod;
805
811
  formNoValidate?: boolean;
@@ -842,7 +848,7 @@ export namespace JSX {
842
848
  }
843
849
  interface FormHTMLAttributes<T> extends HTMLAttributes<T> {
844
850
  "accept-charset"?: string;
845
- action?: string;
851
+ action?: string | SerializableAttributeValue;
846
852
  autocomplete?: string;
847
853
  encoding?: HTMLFormEncType;
848
854
  enctype?: HTMLFormEncType;
@@ -898,7 +904,7 @@ export namespace JSX {
898
904
  disabled?: boolean;
899
905
  enterkeyhint?: "enter" | "done" | "go" | "next" | "previous" | "search" | "send";
900
906
  form?: string;
901
- formaction?: string;
907
+ formaction?: string | SerializableAttributeValue;
902
908
  formenctype?: HTMLFormEncType;
903
909
  formmethod?: HTMLFormMethod;
904
910
  formnovalidate?: boolean;
@@ -924,7 +930,7 @@ export namespace JSX {
924
930
  value?: string | string[] | number;
925
931
  width?: number | string;
926
932
  crossOrigin?: HTMLCrossorigin;
927
- formAction?: string;
933
+ formAction?: string | SerializableAttributeValue;
928
934
  formEnctype?: HTMLFormEncType;
929
935
  formMethod?: HTMLFormMethod;
930
936
  formNoValidate?: boolean;
package/src/serializer.js CHANGED
@@ -1,4 +1,4 @@
1
- import { Feature, GLOBAL_CONTEXT_API_SCRIPT, Serializer, getCrossReferenceHeader } from "seroval"
1
+ import { Feature, Serializer, getCrossReferenceHeader } from "seroval"
2
2
 
3
3
  const ES2017FLAG =
4
4
  Feature.AggregateError // ES2021
@@ -18,10 +18,6 @@ export function createSerializer({ onData, onDone, scopeId, onError }) {
18
18
  });
19
19
  }
20
20
 
21
- export function getGlobalHeaderScript() {
22
- return GLOBAL_CONTEXT_API_SCRIPT;
23
- }
24
-
25
21
  export function getLocalHeaderScript(id) {
26
22
  return getCrossReferenceHeader(id);
27
23
  }
package/src/server.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Aliases, BooleanAttributes, ChildProperties } from "./constants";
2
2
  import { sharedConfig, root } from "rxcore";
3
- import { createSerializer, getGlobalHeaderScript, getLocalHeaderScript } from "./serializer";
3
+ import { createSerializer, getLocalHeaderScript } from "./serializer";
4
4
  export { createComponent } from "rxcore";
5
5
 
6
6
  // Based on https://github.com/WebReflection/domtagger/blob/master/esm/sanitizer.js
@@ -30,6 +30,12 @@ export function renderToString(code, options = {}) {
30
30
  nonce: options.nonce,
31
31
  serialize(id, p) {
32
32
  !sharedConfig.context.noHydrate && serializer.write(id, p);
33
+ },
34
+ pushed: 0,
35
+ push(p) {
36
+ const id = this.renderId + "i-" + this.pushed++;
37
+ this.serialize(id, p);
38
+ return id;
33
39
  }
34
40
  };
35
41
  let html = root(d => {
@@ -158,11 +164,21 @@ export function renderToStream(code, options = {}) {
158
164
  });
159
165
  } else if (!serverOnly) serializer.write(id, p);
160
166
  },
167
+ pushed: 0,
168
+ push(p) {
169
+ const id = this.renderId + "i-" + this.pushed++;
170
+ this.serialize(id, p);
171
+ return id;
172
+ },
161
173
  registerFragment(key) {
162
174
  if (!registry.has(key)) {
163
175
  let resolve, reject;
164
176
  const p = new Promise((r, rej) => ((resolve = r), (reject = rej)));
165
- registry.set(key, { resolve, reject });
177
+ // double queue to ensure that Suspense is last but in same flush
178
+ registry.set(key, {
179
+ resolve: v => queue(() => queue(() => resolve(v))),
180
+ reject: e => queue(() => queue(() => reject(e)))
181
+ });
166
182
  serializer.write(key, p);
167
183
  }
168
184
  return (value, error) => {
@@ -175,9 +191,7 @@ export function renderToStream(code, options = {}) {
175
191
  }
176
192
  if ((value !== undefined || error) && !completed) {
177
193
  if (!firstFlushed) {
178
- Promise.resolve().then(
179
- () => (html = replacePlaceholder(html, key, value !== undefined ? value : ""))
180
- );
194
+ queue(() => (html = replacePlaceholder(html, key, value !== undefined ? value : "")));
181
195
  error ? reject(error) : resolve(true);
182
196
  } else {
183
197
  buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
@@ -187,7 +201,7 @@ export function renderToStream(code, options = {}) {
187
201
  }
188
202
  }
189
203
  }
190
- if (!registry.size) Promise.resolve().then(flushEnd);
204
+ if (!registry.size) queue(flushEnd);
191
205
  return firstFlushed;
192
206
  };
193
207
  }
@@ -225,7 +239,7 @@ export function renderToStream(code, options = {}) {
225
239
  complete();
226
240
  };
227
241
  } else onCompleteAll = complete;
228
- if (!registry.size) Promise.resolve().then(flushEnd);
242
+ if (!registry.size) queue(flushEnd);
229
243
  },
230
244
  pipe(w) {
231
245
  Promise.allSettled(blockingPromises).then(() => {
@@ -485,7 +499,7 @@ export function generateHydrationScript({ eventNames = ["click", "input"], nonce
485
499
  nonce ? ` nonce="${nonce}"` : ""
486
500
  }>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join(
487
501
  '", "'
488
- )}"].forEach((o=>document.addEventListener(o,(o=>{let a=o.composedPath&&o.composedPath()[0]||o.target,s=t(a);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});${getGlobalHeaderScript()}</script><!--xs-->`;
502
+ )}"].forEach((o=>document.addEventListener(o,(o=>{let a=o.composedPath&&o.composedPath()[0]||o.target,s=t(a);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});</script><!--xs-->`;
489
503
  }
490
504
 
491
505
  export function Hydration(props) {
@@ -507,6 +521,10 @@ export function NoHydration(props) {
507
521
  return props.children;
508
522
  }
509
523
 
524
+ function queue(fn) {
525
+ return Promise.resolve().then(fn);
526
+ }
527
+
510
528
  function injectAssets(assets, html) {
511
529
  if (!assets || !assets.length) return html;
512
530
  let out = "";