dom-expressions 0.37.8 → 0.37.10
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 +5 -5
- package/src/constants.js +1 -0
- package/src/jsx-h.d.ts +12 -5
- package/src/jsx.d.ts +11 -5
- package/src/serializer.js +2 -6
- package/src/server.js +33 -11
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.
|
|
4
|
+
"version": "0.37.10",
|
|
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.
|
|
23
|
+
"seroval": "^0.15.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"babel-plugin-jsx-dom-expressions": "^0.37.
|
|
26
|
+
"babel-plugin-jsx-dom-expressions": "^0.37.9",
|
|
27
27
|
"csstype": "^3.1",
|
|
28
|
-
"seroval": "^0.
|
|
28
|
+
"seroval": "^0.15.1"
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "d2d7f3d9057ed79b2bc404ccad53582427f6b4a2"
|
|
31
31
|
}
|
package/src/constants.js
CHANGED
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,
|
|
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
|
-
return getCrossReferenceHeader(id);
|
|
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,
|
|
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,7 +30,11 @@ 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
|
-
}
|
|
33
|
+
},
|
|
34
|
+
roots: 0,
|
|
35
|
+
nextRoot() {
|
|
36
|
+
return this.renderId + "i-" + this.roots++;
|
|
37
|
+
},
|
|
34
38
|
};
|
|
35
39
|
let html = root(d => {
|
|
36
40
|
setTimeout(d);
|
|
@@ -158,11 +162,19 @@ export function renderToStream(code, options = {}) {
|
|
|
158
162
|
});
|
|
159
163
|
} else if (!serverOnly) serializer.write(id, p);
|
|
160
164
|
},
|
|
165
|
+
roots: 0,
|
|
166
|
+
nextRoot() {
|
|
167
|
+
return this.renderId + "i-" + this.roots++;
|
|
168
|
+
},
|
|
161
169
|
registerFragment(key) {
|
|
162
170
|
if (!registry.has(key)) {
|
|
163
171
|
let resolve, reject;
|
|
164
172
|
const p = new Promise((r, rej) => ((resolve = r), (reject = rej)));
|
|
165
|
-
|
|
173
|
+
// double queue to ensure that Suspense is last but in same flush
|
|
174
|
+
registry.set(key, {
|
|
175
|
+
resolve: v => queue(() => queue(() => resolve(v))),
|
|
176
|
+
reject: e => queue(() => queue(() => reject(e)))
|
|
177
|
+
});
|
|
166
178
|
serializer.write(key, p);
|
|
167
179
|
}
|
|
168
180
|
return (value, error) => {
|
|
@@ -175,9 +187,7 @@ export function renderToStream(code, options = {}) {
|
|
|
175
187
|
}
|
|
176
188
|
if ((value !== undefined || error) && !completed) {
|
|
177
189
|
if (!firstFlushed) {
|
|
178
|
-
|
|
179
|
-
() => (html = replacePlaceholder(html, key, value !== undefined ? value : ""))
|
|
180
|
-
);
|
|
190
|
+
queue(() => (html = replacePlaceholder(html, key, value !== undefined ? value : "")));
|
|
181
191
|
error ? reject(error) : resolve(true);
|
|
182
192
|
} else {
|
|
183
193
|
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
@@ -187,7 +197,7 @@ export function renderToStream(code, options = {}) {
|
|
|
187
197
|
}
|
|
188
198
|
}
|
|
189
199
|
}
|
|
190
|
-
if (!registry.size)
|
|
200
|
+
if (!registry.size) queue(flushEnd);
|
|
191
201
|
return firstFlushed;
|
|
192
202
|
};
|
|
193
203
|
}
|
|
@@ -225,10 +235,10 @@ export function renderToStream(code, options = {}) {
|
|
|
225
235
|
complete();
|
|
226
236
|
};
|
|
227
237
|
} else onCompleteAll = complete;
|
|
228
|
-
if (!registry.size)
|
|
238
|
+
if (!registry.size) queue(flushEnd);
|
|
229
239
|
},
|
|
230
240
|
pipe(w) {
|
|
231
|
-
|
|
241
|
+
allSettled(blockingPromises).then(() => {
|
|
232
242
|
doShell();
|
|
233
243
|
buffer = writable = w;
|
|
234
244
|
buffer.write(tmp);
|
|
@@ -238,7 +248,7 @@ export function renderToStream(code, options = {}) {
|
|
|
238
248
|
});
|
|
239
249
|
},
|
|
240
250
|
pipeTo(w) {
|
|
241
|
-
return
|
|
251
|
+
return allSettled(blockingPromises).then(() => {
|
|
242
252
|
doShell();
|
|
243
253
|
const encoder = new TextEncoder();
|
|
244
254
|
const writer = w.getWriter();
|
|
@@ -485,7 +495,7 @@ export function generateHydrationScript({ eventNames = ["click", "input"], nonce
|
|
|
485
495
|
nonce ? ` nonce="${nonce}"` : ""
|
|
486
496
|
}>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
497
|
'", "'
|
|
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(){}})
|
|
498
|
+
)}"].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
499
|
}
|
|
490
500
|
|
|
491
501
|
export function Hydration(props) {
|
|
@@ -507,6 +517,18 @@ export function NoHydration(props) {
|
|
|
507
517
|
return props.children;
|
|
508
518
|
}
|
|
509
519
|
|
|
520
|
+
function queue(fn) {
|
|
521
|
+
return Promise.resolve().then(fn);
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
function allSettled(promises) {
|
|
525
|
+
let length = promises.length;
|
|
526
|
+
return Promise.allSettled(promises).then(() => {
|
|
527
|
+
if (promises.length !== length) return allSettled(promises);
|
|
528
|
+
return;
|
|
529
|
+
})
|
|
530
|
+
}
|
|
531
|
+
|
|
510
532
|
function injectAssets(assets, html) {
|
|
511
533
|
if (!assets || !assets.length) return html;
|
|
512
534
|
let out = "";
|