solid-js 1.8.8 → 1.8.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/dist/dev.cjs +17 -21
- package/dist/dev.js +554 -321
- package/dist/server.js +170 -75
- package/dist/solid.cjs +17 -21
- package/dist/solid.js +481 -279
- package/h/dist/h.js +34 -8
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +11 -8
- package/h/jsx-runtime/types/jsx.d.ts +2 -1
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +216 -94
- package/html/types/lit.d.ts +47 -33
- package/package.json +3 -2
- package/store/dist/dev.cjs +1 -1
- package/store/dist/dev.js +117 -42
- package/store/dist/server.js +19 -8
- package/store/dist/store.cjs +1 -1
- package/store/dist/store.js +108 -39
- package/store/types/index.d.ts +21 -7
- package/store/types/modifiers.d.ts +6 -3
- package/store/types/mutable.d.ts +5 -2
- package/store/types/server.d.ts +12 -4
- package/store/types/store.d.ts +218 -61
- package/types/index.d.ts +75 -10
- package/types/jsx.d.ts +2 -1
- package/types/reactive/array.d.ts +12 -4
- package/types/reactive/observable.d.ts +25 -17
- package/types/reactive/scheduler.d.ts +9 -6
- package/types/reactive/signal.d.ts +233 -142
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +64 -33
- package/types/render/flow.d.ts +43 -31
- package/types/render/hydration.d.ts +13 -13
- package/types/server/index.d.ts +57 -2
- package/types/server/reactive.d.ts +73 -42
- package/types/server/rendering.d.ts +167 -96
- package/universal/dist/dev.js +28 -12
- package/universal/dist/universal.js +28 -12
- package/universal/types/index.d.ts +3 -1
- package/universal/types/universal.d.ts +0 -1
- package/web/dist/dev.cjs +1 -1
- package/web/dist/dev.js +621 -82
- package/web/dist/server.cjs +30 -27
- package/web/dist/server.js +232 -121
- package/web/dist/storage.js +3 -3
- package/web/dist/web.cjs +1 -1
- package/web/dist/web.js +615 -81
- package/web/types/client.d.ts +2 -2
- package/web/types/core.d.ts +10 -1
- package/web/types/index.d.ts +27 -10
- package/web/types/server-mock.d.ts +47 -32
package/web/dist/server.cjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var solidJs = require('solid-js');
|
|
4
4
|
var seroval = require('seroval');
|
|
5
|
+
var web = require('seroval-plugins/web');
|
|
5
6
|
|
|
6
7
|
const booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "inert", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
|
|
7
8
|
const BooleanAttributes = /*#__PURE__*/new Set(booleans);
|
|
@@ -11,8 +12,6 @@ const Aliases = /*#__PURE__*/Object.assign(Object.create(null), {
|
|
|
11
12
|
htmlFor: "for"
|
|
12
13
|
});
|
|
13
14
|
|
|
14
|
-
seroval.createPlugin({tag:"seroval-plugins/web/Blob",test(e){return typeof Blob=="undefined"?!1:e instanceof Blob},parse:{async async(e,r){return {type:await r.parse(e.type),buffer:await r.parse(await e.arrayBuffer())}}},serialize(e,r){return "new Blob(["+r.serialize(e.buffer)+"],{type:"+r.serialize(e.type)+"})"},deserialize(e,r){return new Blob([r.deserialize(e.buffer)],{type:r.deserialize(e.type)})}});function p(e){return {detail:e.detail,bubbles:e.bubbles,cancelable:e.cancelable,composed:e.composed}}var E=seroval.createPlugin({tag:"seroval-plugins/web/CustomEvent",test(e){return typeof CustomEvent=="undefined"?!1:e instanceof CustomEvent},parse:{sync(e,r){return {type:r.parse(e.type),options:r.parse(p(e))}},async async(e,r){return {type:await r.parse(e.type),options:await r.parse(p(e))}},stream(e,r){return {type:r.parse(e.type),options:r.parse(p(e))}}},serialize(e,r){return "new CustomEvent("+r.serialize(e.type)+","+r.serialize(e.options)+")"},deserialize(e,r){return new CustomEvent(r.deserialize(e.type),r.deserialize(e.options))}}),F=E;var I=seroval.createPlugin({tag:"seroval-plugins/web/DOMException",test(e){return typeof DOMException=="undefined"?!1:e instanceof DOMException},parse:{sync(e,r){return {name:r.parse(e.name),message:r.parse(e.message)}},async async(e,r){return {name:await r.parse(e.name),message:await r.parse(e.message)}},stream(e,r){return {name:r.parse(e.name),message:r.parse(e.message)}}},serialize(e,r){return "new DOMException("+r.serialize(e.message)+","+r.serialize(e.name)+")"},deserialize(e,r){return new DOMException(r.deserialize(e.message),r.deserialize(e.name))}}),B=I;function u(e){return {bubbles:e.bubbles,cancelable:e.cancelable,composed:e.composed}}var L=seroval.createPlugin({tag:"seroval-plugins/web/Event",test(e){return typeof Event=="undefined"?!1:e instanceof Event},parse:{sync(e,r){return {type:r.parse(e.type),options:r.parse(u(e))}},async async(e,r){return {type:await r.parse(e.type),options:await r.parse(u(e))}},stream(e,r){return {type:r.parse(e.type),options:r.parse(u(e))}}},serialize(e,r){return "new Event("+r.serialize(e.type)+","+r.serialize(e.options)+")"},deserialize(e,r){return new Event(r.deserialize(e.type),r.deserialize(e.options))}}),O=L;var q=seroval.createPlugin({tag:"seroval-plugins/web/File",test(e){return typeof File=="undefined"?!1:e instanceof File},parse:{async async(e,r){return {name:await r.parse(e.name),options:await r.parse({type:e.type,lastModified:e.lastModified}),buffer:await r.parse(await e.arrayBuffer())}}},serialize(e,r){return "new File(["+r.serialize(e.buffer)+"],"+r.serialize(e.name)+","+r.serialize(e.options)+")"},deserialize(e,r){return new File([r.deserialize(e.buffer)],r.deserialize(e.name),r.deserialize(e.options))}}),d=q;function f(e){let r=[];return e.forEach((s,a)=>{r.push([a,s]);}),r}var n={},H=seroval.createPlugin({tag:"seroval-plugins/web/FormDataFactory",test(e){return e===n},parse:{sync(){},async async(){return await Promise.resolve(void 0)},stream(){}},serialize(e,r){return r.createEffectfulFunction(["e","f","i","s","t"],"f=new FormData;for(i=0,s=e.length;i<s;i++)f.append((t=e[i])[0],t[1]);return f")},deserialize(){return n}}),M=seroval.createPlugin({tag:"seroval-plugins/web/FormData",extends:[d,H],test(e){return typeof FormData=="undefined"?!1:e instanceof FormData},parse:{sync(e,r){return {factory:r.parse(n),entries:r.parse(f(e))}},async async(e,r){return {factory:await r.parse(n),entries:await r.parse(f(e))}},stream(e,r){return {factory:r.parse(n),entries:r.parse(f(e))}}},serialize(e,r){return "("+r.serialize(e.factory)+")("+r.serialize(e.entries)+")"},deserialize(e,r){let s=new FormData,a=r.deserialize(e.entries);for(let t=0,b=a.length;t<b;t++){let c=a[t];s.append(c[0],c[1]);}return s}}),A=M;function m(e){let r=[];return e.forEach((s,a)=>{r.push([a,s]);}),r}var _=seroval.createPlugin({tag:"seroval-plugins/web/Headers",test(e){return typeof Headers=="undefined"?!1:e instanceof Headers},parse:{sync(e,r){return r.parse(m(e))},async async(e,r){return await r.parse(m(e))},stream(e,r){return r.parse(m(e))}},serialize(e,r){return "new Headers("+r.serialize(e)+")"},deserialize(e,r){return new Headers(r.deserialize(e))}}),i=_;seroval.createPlugin({tag:"seroval-plugins/web/ImageData",test(e){return typeof ImageData=="undefined"?!1:e instanceof ImageData},parse:{sync(e,r){return {data:r.parse(e.data),width:r.parse(e.width),height:r.parse(e.height),options:r.parse({colorSpace:e.colorSpace})}},async async(e,r){return {data:await r.parse(e.data),width:await r.parse(e.width),height:await r.parse(e.height),options:await r.parse({colorSpace:e.colorSpace})}},stream(e,r){return {data:r.parse(e.data),width:r.parse(e.width),height:r.parse(e.height),options:r.parse({colorSpace:e.colorSpace})}}},serialize(e,r){return "new ImageData("+r.serialize(e.data)+","+r.serialize(e.width)+","+r.serialize(e.height)+","+r.serialize(e.options)+")"},deserialize(e,r){return new ImageData(r.deserialize(e.data),r.deserialize(e.width),r.deserialize(e.height),r.deserialize(e.options))}});var o={},V=seroval.createPlugin({tag:"seroval-plugins/web/ReadableStreamFactory",test(e){return e===o},parse:{sync(){},async async(){return await Promise.resolve(void 0)},stream(){}},serialize(e,r){return r.createFunction(["d"],"new ReadableStream({start:"+r.createEffectfulFunction(["c"],"d.on({next:"+r.createEffectfulFunction(["v"],"c.enqueue(v)")+",throw:"+r.createEffectfulFunction(["v"],"c.error(v)")+",return:"+r.createEffectfulFunction([],"c.close()")+"})")+"})")},deserialize(){return o}});function g(e){let r=seroval.createStream(),s=e.getReader();async function a(){try{let t=await s.read();t.done?r.return(t.value):(r.next(t.value),await a());}catch(t){r.throw(t);}}return a().catch(()=>{}),r}var G=seroval.createPlugin({tag:"seroval/plugins/web/ReadableStream",extends:[V],test(e){return typeof ReadableStream=="undefined"?!1:e instanceof ReadableStream},parse:{sync(e,r){return {factory:r.parse(o),stream:r.parse(seroval.createStream())}},async async(e,r){return {factory:await r.parse(o),stream:await r.parse(g(e))}},stream(e,r){return {factory:r.parse(o),stream:r.parse(g(e))}}},serialize(e,r){return "("+r.serialize(e.factory)+")("+r.serialize(e.stream)+")"},deserialize(e,r){let s=r.deserialize(e.stream);return new ReadableStream({start(a){s.on({next(t){a.enqueue(t);},throw(t){a.error(t);},return(){a.close();}});}})}}),l=G;function z(e,r){return {body:r,cache:e.cache,credentials:e.credentials,headers:e.headers,integrity:e.integrity,keepalive:e.keepalive,method:e.method,mode:e.mode,redirect:e.redirect,referrer:e.referrer,referrerPolicy:e.referrerPolicy}}var K=seroval.createPlugin({tag:"seroval-plugins/web/Request",extends:[l,i],test(e){return typeof Request=="undefined"?!1:e instanceof Request},parse:{async async(e,r){return {url:await r.parse(e.url),options:await r.parse(z(e,e.body?await e.clone().arrayBuffer():null))}},stream(e,r){return {url:r.parse(e.url),options:r.parse(z(e,e.clone().body))}}},serialize(e,r){return "new Request("+r.serialize(e.url)+","+r.serialize(e.options)+")"},deserialize(e,r){return new Request(r.deserialize(e.url),r.deserialize(e.options))}}),Q=K;function S(e){return {headers:e.headers,status:e.status,statusText:e.statusText}}var X=seroval.createPlugin({tag:"seroval-plugins/web/Response",extends:[l,i],test(e){return typeof Response=="undefined"?!1:e instanceof Response},parse:{async async(e,r){return {body:await r.parse(e.body?await e.clone().arrayBuffer():null),options:await r.parse(S(e))}},stream(e,r){return {body:r.parse(e.clone().body),options:r.parse(S(e))}}},serialize(e,r){return "new Response("+r.serialize(e.body)+","+r.serialize(e.options)+")"},deserialize(e,r){return new Response(r.deserialize(e.body),r.deserialize(e.options))}}),Z=X;var x=seroval.createPlugin({tag:"seroval-plugins/web/URLSearchParams",test(e){return typeof URLSearchParams=="undefined"?!1:e instanceof URLSearchParams},parse:{sync(e,r){return r.parse(e.toString())},async async(e,r){return await r.parse(e.toString())},stream(e,r){return r.parse(e.toString())}},serialize(e,r){return "new URLSearchParams("+r.serialize(e)+")"},deserialize(e,r){return new URLSearchParams(r.deserialize(e))}}),ee=x;var ae=seroval.createPlugin({tag:"seroval-plugins/web/URL",test(e){return typeof URL=="undefined"?!1:e instanceof URL},parse:{sync(e,r){return r.parse(e.href)},async async(e,r){return await r.parse(e.href)},stream(e,r){return r.parse(e.href)}},serialize(e,r){return "new URL("+r.serialize(e)+")"},deserialize(e,r){return new URL(r.deserialize(e))}}),te=ae;
|
|
15
|
-
|
|
16
15
|
const ES2017FLAG = seroval.Feature.AggregateError
|
|
17
16
|
| seroval.Feature.BigInt
|
|
18
17
|
| seroval.Feature.BigIntTypedArray;
|
|
@@ -26,8 +25,8 @@ function createSerializer({
|
|
|
26
25
|
return new seroval.Serializer({
|
|
27
26
|
scopeId,
|
|
28
27
|
plugins: [
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
web.CustomEventPlugin, web.DOMExceptionPlugin, web.EventPlugin,
|
|
29
|
+
web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin],
|
|
31
30
|
globalIdentifier: GLOBAL_IDENTIFIER,
|
|
32
31
|
disabledFeatures: ES2017FLAG,
|
|
33
32
|
onData,
|
|
@@ -267,35 +266,39 @@ function renderToStream(code, options = {}) {
|
|
|
267
266
|
},
|
|
268
267
|
pipe(w) {
|
|
269
268
|
allSettled(blockingPromises).then(() => {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
269
|
+
setTimeout(() => {
|
|
270
|
+
doShell();
|
|
271
|
+
buffer = writable = w;
|
|
272
|
+
buffer.write(tmp);
|
|
273
|
+
firstFlushed = true;
|
|
274
|
+
if (completed) writable.end();else queue(flushEnd);
|
|
275
|
+
});
|
|
275
276
|
});
|
|
276
277
|
},
|
|
277
278
|
pipeTo(w) {
|
|
278
279
|
return allSettled(blockingPromises).then(() => {
|
|
279
|
-
doShell();
|
|
280
|
-
const encoder = new TextEncoder();
|
|
281
|
-
const writer = w.getWriter();
|
|
282
280
|
let resolve;
|
|
283
281
|
const p = new Promise(r => resolve = r);
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
282
|
+
setTimeout(() => {
|
|
283
|
+
doShell();
|
|
284
|
+
const encoder = new TextEncoder();
|
|
285
|
+
const writer = w.getWriter();
|
|
286
|
+
writable = {
|
|
287
|
+
end() {
|
|
288
|
+
writer.releaseLock();
|
|
289
|
+
w.close();
|
|
290
|
+
resolve();
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
buffer = {
|
|
294
|
+
write(payload) {
|
|
295
|
+
writer.write(encoder.encode(payload));
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
buffer.write(tmp);
|
|
299
|
+
firstFlushed = true;
|
|
300
|
+
if (completed) writable.end();else queue(flushEnd);
|
|
301
|
+
});
|
|
299
302
|
return p;
|
|
300
303
|
});
|
|
301
304
|
}
|
package/web/dist/server.js
CHANGED
|
@@ -1,32 +1,86 @@
|
|
|
1
|
-
import { sharedConfig, createRoot, splitProps } from
|
|
2
|
-
export {
|
|
3
|
-
|
|
1
|
+
import { sharedConfig, createRoot, splitProps } from "solid-js";
|
|
2
|
+
export {
|
|
3
|
+
ErrorBoundary,
|
|
4
|
+
For,
|
|
5
|
+
Index,
|
|
6
|
+
Match,
|
|
7
|
+
Show,
|
|
8
|
+
Suspense,
|
|
9
|
+
SuspenseList,
|
|
10
|
+
Switch,
|
|
11
|
+
createComponent,
|
|
12
|
+
mergeProps
|
|
13
|
+
} from "solid-js";
|
|
14
|
+
import { Feature, Serializer, getCrossReferenceHeader } from "seroval";
|
|
15
|
+
import {
|
|
16
|
+
CustomEventPlugin,
|
|
17
|
+
DOMExceptionPlugin,
|
|
18
|
+
EventPlugin,
|
|
19
|
+
FormDataPlugin,
|
|
20
|
+
HeadersPlugin,
|
|
21
|
+
ReadableStreamPlugin,
|
|
22
|
+
RequestPlugin,
|
|
23
|
+
ResponsePlugin,
|
|
24
|
+
URLSearchParamsPlugin,
|
|
25
|
+
URLPlugin
|
|
26
|
+
} from "seroval-plugins/web";
|
|
4
27
|
|
|
5
|
-
const booleans = [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
28
|
+
const booleans = [
|
|
29
|
+
"allowfullscreen",
|
|
30
|
+
"async",
|
|
31
|
+
"autofocus",
|
|
32
|
+
"autoplay",
|
|
33
|
+
"checked",
|
|
34
|
+
"controls",
|
|
35
|
+
"default",
|
|
36
|
+
"disabled",
|
|
37
|
+
"formnovalidate",
|
|
38
|
+
"hidden",
|
|
39
|
+
"indeterminate",
|
|
40
|
+
"inert",
|
|
41
|
+
"ismap",
|
|
42
|
+
"loop",
|
|
43
|
+
"multiple",
|
|
44
|
+
"muted",
|
|
45
|
+
"nomodule",
|
|
46
|
+
"novalidate",
|
|
47
|
+
"open",
|
|
48
|
+
"playsinline",
|
|
49
|
+
"readonly",
|
|
50
|
+
"required",
|
|
51
|
+
"reversed",
|
|
52
|
+
"seamless",
|
|
53
|
+
"selected"
|
|
54
|
+
];
|
|
55
|
+
const BooleanAttributes = /*#__PURE__*/ new Set(booleans);
|
|
56
|
+
const ChildProperties = /*#__PURE__*/ new Set([
|
|
57
|
+
"innerHTML",
|
|
58
|
+
"textContent",
|
|
59
|
+
"innerText",
|
|
60
|
+
"children"
|
|
61
|
+
]);
|
|
62
|
+
const Aliases = /*#__PURE__*/ Object.assign(Object.create(null), {
|
|
9
63
|
className: "class",
|
|
10
64
|
htmlFor: "for"
|
|
11
65
|
});
|
|
12
66
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
| Feature.BigInt
|
|
17
|
-
| Feature.BigIntTypedArray;
|
|
18
|
-
const GLOBAL_IDENTIFIER = '_$HY.r';
|
|
19
|
-
function createSerializer({
|
|
20
|
-
onData,
|
|
21
|
-
onDone,
|
|
22
|
-
scopeId,
|
|
23
|
-
onError
|
|
24
|
-
}) {
|
|
67
|
+
const ES2017FLAG = Feature.AggregateError | Feature.BigInt | Feature.BigIntTypedArray;
|
|
68
|
+
const GLOBAL_IDENTIFIER = "_$HY.r";
|
|
69
|
+
function createSerializer({ onData, onDone, scopeId, onError }) {
|
|
25
70
|
return new Serializer({
|
|
26
71
|
scopeId,
|
|
27
72
|
plugins: [
|
|
28
|
-
|
|
29
|
-
|
|
73
|
+
CustomEventPlugin,
|
|
74
|
+
DOMExceptionPlugin,
|
|
75
|
+
EventPlugin,
|
|
76
|
+
FormDataPlugin,
|
|
77
|
+
HeadersPlugin,
|
|
78
|
+
ReadableStreamPlugin,
|
|
79
|
+
RequestPlugin,
|
|
80
|
+
ResponsePlugin,
|
|
81
|
+
URLSearchParamsPlugin,
|
|
82
|
+
URLPlugin
|
|
83
|
+
],
|
|
30
84
|
globalIdentifier: GLOBAL_IDENTIFIER,
|
|
31
85
|
disabledFeatures: ES2017FLAG,
|
|
32
86
|
onData,
|
|
@@ -35,15 +89,14 @@ function createSerializer({
|
|
|
35
89
|
});
|
|
36
90
|
}
|
|
37
91
|
function getLocalHeaderScript(id) {
|
|
38
|
-
return getCrossReferenceHeader(id) +
|
|
92
|
+
return getCrossReferenceHeader(id) + ";";
|
|
39
93
|
}
|
|
40
94
|
|
|
41
|
-
const VOID_ELEMENTS =
|
|
95
|
+
const VOID_ELEMENTS =
|
|
96
|
+
/^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
42
97
|
const REPLACE_SCRIPT = `function $df(e,n,o,t){if(n=document.getElementById(e),o=document.getElementById("pl-"+e)){for(;o&&8!==o.nodeType&&o.nodeValue!=="pl-"+e;)t=o.nextSibling,o.remove(),o=t;_$HY.done?o.remove():o.replaceWith(n.content)}n.remove(),_$HY.fe(e)}`;
|
|
43
98
|
function renderToString(code, options = {}) {
|
|
44
|
-
const {
|
|
45
|
-
renderId
|
|
46
|
-
} = options;
|
|
99
|
+
const { renderId } = options;
|
|
47
100
|
let scripts = "";
|
|
48
101
|
const serializer = createSerializer({
|
|
49
102
|
scopeId: renderId,
|
|
@@ -81,9 +134,7 @@ function renderToString(code, options = {}) {
|
|
|
81
134
|
return html;
|
|
82
135
|
}
|
|
83
136
|
function renderToStringAsync(code, options = {}) {
|
|
84
|
-
const {
|
|
85
|
-
timeoutMs = 30000
|
|
86
|
-
} = options;
|
|
137
|
+
const { timeoutMs = 30000 } = options;
|
|
87
138
|
let timeoutHandle;
|
|
88
139
|
const timeout = new Promise((_, reject) => {
|
|
89
140
|
timeoutHandle = setTimeout(() => reject("renderToString timed out"), timeoutMs);
|
|
@@ -94,13 +145,7 @@ function renderToStringAsync(code, options = {}) {
|
|
|
94
145
|
});
|
|
95
146
|
}
|
|
96
147
|
function renderToStream(code, options = {}) {
|
|
97
|
-
let {
|
|
98
|
-
nonce,
|
|
99
|
-
onCompleteShell,
|
|
100
|
-
onCompleteAll,
|
|
101
|
-
renderId,
|
|
102
|
-
noScripts
|
|
103
|
-
} = options;
|
|
148
|
+
let { nonce, onCompleteShell, onCompleteAll, renderId, noScripts } = options;
|
|
104
149
|
let dispose;
|
|
105
150
|
const blockingPromises = [];
|
|
106
151
|
const pushTask = task => {
|
|
@@ -116,11 +161,12 @@ function renderToStream(code, options = {}) {
|
|
|
116
161
|
const checkEnd = () => {
|
|
117
162
|
if (!registry.size && !completed) {
|
|
118
163
|
writeTasks();
|
|
119
|
-
onCompleteAll &&
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
164
|
+
onCompleteAll &&
|
|
165
|
+
onCompleteAll({
|
|
166
|
+
write(v) {
|
|
167
|
+
!completed && buffer.write(v);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
124
170
|
writable && writable.end();
|
|
125
171
|
completed = true;
|
|
126
172
|
setTimeout(dispose);
|
|
@@ -177,17 +223,23 @@ function renderToStream(code, options = {}) {
|
|
|
177
223
|
const first = html.indexOf(placeholder);
|
|
178
224
|
if (first === -1) return;
|
|
179
225
|
const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
|
|
180
|
-
html = html.replace(
|
|
226
|
+
html = html.replace(
|
|
227
|
+
html.slice(first, last + placeholder.length + 1),
|
|
228
|
+
resolveSSRNode(payloadFn())
|
|
229
|
+
);
|
|
181
230
|
},
|
|
182
231
|
serialize(id, p, wait) {
|
|
183
232
|
const serverOnly = sharedConfig.context.noHydrate;
|
|
184
233
|
if (!firstFlushed && wait && typeof p === "object" && "then" in p) {
|
|
185
234
|
blockingPromises.push(p);
|
|
186
|
-
!serverOnly &&
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
235
|
+
!serverOnly &&
|
|
236
|
+
p
|
|
237
|
+
.then(d => {
|
|
238
|
+
serializer.write(id, d);
|
|
239
|
+
})
|
|
240
|
+
.catch(e => {
|
|
241
|
+
serializer.write(id, e);
|
|
242
|
+
});
|
|
191
243
|
} else if (!serverOnly) serializer.write(id, p);
|
|
192
244
|
},
|
|
193
245
|
roots: 0,
|
|
@@ -197,7 +249,7 @@ function renderToStream(code, options = {}) {
|
|
|
197
249
|
registerFragment(key) {
|
|
198
250
|
if (!registry.has(key)) {
|
|
199
251
|
let resolve, reject;
|
|
200
|
-
const p = new Promise((r, rej) => (resolve = r, reject = rej));
|
|
252
|
+
const p = new Promise((r, rej) => ((resolve = r), (reject = rej)));
|
|
201
253
|
registry.set(key, {
|
|
202
254
|
resolve: v => queue(() => queue(() => resolve(v))),
|
|
203
255
|
reject: e => queue(() => queue(() => reject(e)))
|
|
@@ -206,10 +258,7 @@ function renderToStream(code, options = {}) {
|
|
|
206
258
|
}
|
|
207
259
|
return (value, error) => {
|
|
208
260
|
if (registry.has(key)) {
|
|
209
|
-
const {
|
|
210
|
-
resolve,
|
|
211
|
-
reject
|
|
212
|
-
} = registry.get(key);
|
|
261
|
+
const { resolve, reject } = registry.get(key);
|
|
213
262
|
registry.delete(key);
|
|
214
263
|
if (waitForFragments(registry, key)) {
|
|
215
264
|
resolve(true);
|
|
@@ -217,7 +266,7 @@ function renderToStream(code, options = {}) {
|
|
|
217
266
|
}
|
|
218
267
|
if ((value !== undefined || error) && !completed) {
|
|
219
268
|
if (!firstFlushed) {
|
|
220
|
-
queue(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
|
|
269
|
+
queue(() => (html = replacePlaceholder(html, key, value !== undefined ? value : "")));
|
|
221
270
|
error ? reject(error) : resolve(true);
|
|
222
271
|
} else {
|
|
223
272
|
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
@@ -243,11 +292,12 @@ function renderToStream(code, options = {}) {
|
|
|
243
292
|
if (tasks.length) html = injectScripts(html, tasks, nonce);
|
|
244
293
|
buffer.write(html);
|
|
245
294
|
tasks = "";
|
|
246
|
-
onCompleteShell &&
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
295
|
+
onCompleteShell &&
|
|
296
|
+
onCompleteShell({
|
|
297
|
+
write(v) {
|
|
298
|
+
!completed && buffer.write(v);
|
|
299
|
+
}
|
|
300
|
+
});
|
|
251
301
|
}
|
|
252
302
|
return {
|
|
253
303
|
then(fn) {
|
|
@@ -266,48 +316,54 @@ function renderToStream(code, options = {}) {
|
|
|
266
316
|
},
|
|
267
317
|
pipe(w) {
|
|
268
318
|
allSettled(blockingPromises).then(() => {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
319
|
+
setTimeout(() => {
|
|
320
|
+
doShell();
|
|
321
|
+
buffer = writable = w;
|
|
322
|
+
buffer.write(tmp);
|
|
323
|
+
firstFlushed = true;
|
|
324
|
+
if (completed) writable.end();
|
|
325
|
+
else queue(flushEnd);
|
|
326
|
+
});
|
|
274
327
|
});
|
|
275
328
|
},
|
|
276
329
|
pipeTo(w) {
|
|
277
330
|
return allSettled(blockingPromises).then(() => {
|
|
278
|
-
doShell();
|
|
279
|
-
const encoder = new TextEncoder();
|
|
280
|
-
const writer = w.getWriter();
|
|
281
331
|
let resolve;
|
|
282
|
-
const p = new Promise(r => resolve = r);
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
332
|
+
const p = new Promise(r => (resolve = r));
|
|
333
|
+
setTimeout(() => {
|
|
334
|
+
doShell();
|
|
335
|
+
const encoder = new TextEncoder();
|
|
336
|
+
const writer = w.getWriter();
|
|
337
|
+
writable = {
|
|
338
|
+
end() {
|
|
339
|
+
writer.releaseLock();
|
|
340
|
+
w.close();
|
|
341
|
+
resolve();
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
buffer = {
|
|
345
|
+
write(payload) {
|
|
346
|
+
writer.write(encoder.encode(payload));
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
buffer.write(tmp);
|
|
350
|
+
firstFlushed = true;
|
|
351
|
+
if (completed) writable.end();
|
|
352
|
+
else queue(flushEnd);
|
|
353
|
+
});
|
|
298
354
|
return p;
|
|
299
355
|
});
|
|
300
356
|
}
|
|
301
357
|
};
|
|
302
358
|
}
|
|
303
359
|
function HydrationScript(props) {
|
|
304
|
-
const {
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
360
|
+
const { nonce } = sharedConfig.context;
|
|
361
|
+
return ssr(
|
|
362
|
+
generateHydrationScript({
|
|
363
|
+
nonce,
|
|
364
|
+
...props
|
|
365
|
+
})
|
|
366
|
+
);
|
|
311
367
|
}
|
|
312
368
|
function ssr(t, ...nodes) {
|
|
313
369
|
if (nodes.length) {
|
|
@@ -352,7 +408,8 @@ function ssrStyle(value) {
|
|
|
352
408
|
return result;
|
|
353
409
|
}
|
|
354
410
|
function ssrElement(tag, props, children, needsId) {
|
|
355
|
-
if (props == null) props = {};
|
|
411
|
+
if (props == null) props = {};
|
|
412
|
+
else if (typeof props === "function") props = props();
|
|
356
413
|
const skipChildren = VOID_ELEMENTS.test(tag);
|
|
357
414
|
const keys = Object.keys(props);
|
|
358
415
|
let result = `<${tag}${needsId ? ssrHydrationKey() : ""} `;
|
|
@@ -360,7 +417,8 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
360
417
|
for (let i = 0; i < keys.length; i++) {
|
|
361
418
|
const prop = keys[i];
|
|
362
419
|
if (ChildProperties.has(prop)) {
|
|
363
|
-
if (children === undefined && !skipChildren)
|
|
420
|
+
if (children === undefined && !skipChildren)
|
|
421
|
+
children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
364
422
|
continue;
|
|
365
423
|
}
|
|
366
424
|
const value = props[prop];
|
|
@@ -369,10 +427,14 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
369
427
|
} else if (prop === "class" || prop === "className" || prop === "classList") {
|
|
370
428
|
if (classResolved) continue;
|
|
371
429
|
let n;
|
|
372
|
-
result += `class="${
|
|
430
|
+
result += `class="${
|
|
431
|
+
escape(((n = props.class) ? n + " " : "") + ((n = props.className) ? n + " " : ""), true) +
|
|
432
|
+
ssrClassList(props.classList)
|
|
433
|
+
}"`;
|
|
373
434
|
classResolved = true;
|
|
374
435
|
} else if (BooleanAttributes.has(prop)) {
|
|
375
|
-
if (value) result += prop;
|
|
436
|
+
if (value) result += prop;
|
|
437
|
+
else continue;
|
|
376
438
|
} else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on") {
|
|
377
439
|
continue;
|
|
378
440
|
} else {
|
|
@@ -380,16 +442,17 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
380
442
|
}
|
|
381
443
|
if (i !== keys.length - 1) result += " ";
|
|
382
444
|
}
|
|
383
|
-
if (skipChildren)
|
|
384
|
-
|
|
385
|
-
|
|
445
|
+
if (skipChildren)
|
|
446
|
+
return {
|
|
447
|
+
t: result + "/>"
|
|
448
|
+
};
|
|
386
449
|
if (typeof children === "function") children = children();
|
|
387
450
|
return {
|
|
388
451
|
t: result + `>${resolveSSRNode(children, true)}</${tag}>`
|
|
389
452
|
};
|
|
390
453
|
}
|
|
391
454
|
function ssrAttribute(key, value, isBoolean) {
|
|
392
|
-
return isBoolean ? value ? " " + key : "" : value != null ? ` ${key}="${value}"` : "";
|
|
455
|
+
return isBoolean ? (value ? " " + key : "") : value != null ? ` ${key}="${value}"` : "";
|
|
393
456
|
}
|
|
394
457
|
function ssrHydrationKey() {
|
|
395
458
|
const hk = getHydrationKey();
|
|
@@ -433,12 +496,13 @@ function escape(s, attr) {
|
|
|
433
496
|
left = iDelim + 1;
|
|
434
497
|
iDelim = s.indexOf(delim, left);
|
|
435
498
|
} while (iDelim >= 0);
|
|
436
|
-
} else
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
499
|
+
} else
|
|
500
|
+
while (iAmp >= 0) {
|
|
501
|
+
if (left < iAmp) out += s.substring(left, iAmp);
|
|
502
|
+
out += "&";
|
|
503
|
+
left = iAmp + 1;
|
|
504
|
+
iAmp = s.indexOf("&", left);
|
|
505
|
+
}
|
|
442
506
|
return left < s.length ? out + s.substring(left) : out;
|
|
443
507
|
}
|
|
444
508
|
function resolveSSRNode(node, top) {
|
|
@@ -450,7 +514,7 @@ function resolveSSRNode(node, top) {
|
|
|
450
514
|
let mapped = "";
|
|
451
515
|
for (let i = 0, len = node.length; i < len; i++) {
|
|
452
516
|
if (!top && typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
|
|
453
|
-
mapped += resolveSSRNode(prev = node[i]);
|
|
517
|
+
mapped += resolveSSRNode((prev = node[i]));
|
|
454
518
|
}
|
|
455
519
|
return mapped;
|
|
456
520
|
}
|
|
@@ -471,11 +535,12 @@ function getAssets() {
|
|
|
471
535
|
for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
|
|
472
536
|
return out;
|
|
473
537
|
}
|
|
474
|
-
function generateHydrationScript({
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
} =
|
|
478
|
-
|
|
538
|
+
function generateHydrationScript({ eventNames = ["click", "input"], nonce } = {}) {
|
|
539
|
+
return `<script${
|
|
540
|
+
nonce ? ` nonce="${nonce}"` : ""
|
|
541
|
+
}>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(
|
|
542
|
+
'", "'
|
|
543
|
+
)}"].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-->`;
|
|
479
544
|
}
|
|
480
545
|
function Hydration(props) {
|
|
481
546
|
if (!sharedConfig.context.noHydrate) return props.children;
|
|
@@ -534,16 +599,20 @@ function replacePlaceholder(html, key, value) {
|
|
|
534
599
|
}
|
|
535
600
|
const RequestContext = Symbol();
|
|
536
601
|
function getRequestEvent() {
|
|
537
|
-
return globalThis[RequestContext]
|
|
602
|
+
return globalThis[RequestContext]
|
|
603
|
+
? globalThis[RequestContext].getStore() ||
|
|
604
|
+
(sharedConfig.context && sharedConfig.context.event) ||
|
|
605
|
+
console.log(
|
|
606
|
+
"RequestEvent is missing. This is most likely due to accessing `getRequestEvent` non-managed async scope in a partially polyfilled environment. Try moving it above all `await` calls."
|
|
607
|
+
)
|
|
608
|
+
: undefined;
|
|
538
609
|
}
|
|
539
610
|
function Assets(props) {
|
|
540
611
|
useAssets(() => props.children);
|
|
541
612
|
}
|
|
542
613
|
function pipeToNodeWritable(code, writable, options = {}) {
|
|
543
614
|
if (options.onReady) {
|
|
544
|
-
options.onCompleteShell = ({
|
|
545
|
-
write
|
|
546
|
-
}) => {
|
|
615
|
+
options.onCompleteShell = ({ write }) => {
|
|
547
616
|
options.onReady({
|
|
548
617
|
write,
|
|
549
618
|
startWriting() {
|
|
@@ -557,9 +626,7 @@ function pipeToNodeWritable(code, writable, options = {}) {
|
|
|
557
626
|
}
|
|
558
627
|
function pipeToWritable(code, writable, options = {}) {
|
|
559
628
|
if (options.onReady) {
|
|
560
|
-
options.onCompleteShell = ({
|
|
561
|
-
write
|
|
562
|
-
}) => {
|
|
629
|
+
options.onCompleteShell = ({ write }) => {
|
|
563
630
|
options.onReady({
|
|
564
631
|
write,
|
|
565
632
|
startWriting() {
|
|
@@ -589,11 +656,19 @@ function ssrSpread(props, isSVG, skipChildren) {
|
|
|
589
656
|
} else if (prop === "class" || prop === "className" || prop === "classList") {
|
|
590
657
|
if (classResolved) continue;
|
|
591
658
|
let n;
|
|
592
|
-
result += `class="${(n = props.class) ? n + " " : ""}${
|
|
659
|
+
result += `class="${(n = props.class) ? n + " " : ""}${
|
|
660
|
+
(n = props.className) ? n + " " : ""
|
|
661
|
+
}${ssrClassList(props.classList)}"`;
|
|
593
662
|
classResolved = true;
|
|
594
663
|
} else if (BooleanAttributes.has(prop)) {
|
|
595
|
-
if (value) result += prop;
|
|
596
|
-
|
|
664
|
+
if (value) result += prop;
|
|
665
|
+
else continue;
|
|
666
|
+
} else if (
|
|
667
|
+
value == undefined ||
|
|
668
|
+
prop === "ref" ||
|
|
669
|
+
prop.slice(0, 2) === "on" ||
|
|
670
|
+
prop.slice(0, 5) === "prop:"
|
|
671
|
+
) {
|
|
597
672
|
continue;
|
|
598
673
|
} else {
|
|
599
674
|
if (prop.slice(0, 5) === "attr:") prop = prop.slice(5);
|
|
@@ -617,7 +692,8 @@ function Dynamic(props) {
|
|
|
617
692
|
const comp = p.component,
|
|
618
693
|
t = typeof comp;
|
|
619
694
|
if (comp) {
|
|
620
|
-
if (t === "function") return comp(others);
|
|
695
|
+
if (t === "function") return comp(others);
|
|
696
|
+
else if (t === "string") {
|
|
621
697
|
return ssrElement(comp, others, undefined, true);
|
|
622
698
|
}
|
|
623
699
|
}
|
|
@@ -626,4 +702,39 @@ function Portal(props) {
|
|
|
626
702
|
return "";
|
|
627
703
|
}
|
|
628
704
|
|
|
629
|
-
export {
|
|
705
|
+
export {
|
|
706
|
+
Assets,
|
|
707
|
+
Dynamic,
|
|
708
|
+
Hydration,
|
|
709
|
+
HydrationScript,
|
|
710
|
+
NoHydration,
|
|
711
|
+
Portal,
|
|
712
|
+
RequestContext,
|
|
713
|
+
addEventListener,
|
|
714
|
+
delegateEvents,
|
|
715
|
+
escape,
|
|
716
|
+
generateHydrationScript,
|
|
717
|
+
getAssets,
|
|
718
|
+
getHydrationKey,
|
|
719
|
+
getRequestEvent,
|
|
720
|
+
hydrate,
|
|
721
|
+
insert,
|
|
722
|
+
isDev,
|
|
723
|
+
isServer,
|
|
724
|
+
pipeToNodeWritable,
|
|
725
|
+
pipeToWritable,
|
|
726
|
+
render,
|
|
727
|
+
renderToStream,
|
|
728
|
+
renderToString,
|
|
729
|
+
renderToStringAsync,
|
|
730
|
+
resolveSSRNode,
|
|
731
|
+
spread,
|
|
732
|
+
ssr,
|
|
733
|
+
ssrAttribute,
|
|
734
|
+
ssrClassList,
|
|
735
|
+
ssrElement,
|
|
736
|
+
ssrHydrationKey,
|
|
737
|
+
ssrSpread,
|
|
738
|
+
ssrStyle,
|
|
739
|
+
useAssets
|
|
740
|
+
};
|