solid-js 1.7.0-beta.1 → 1.7.0-beta.2
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 +3 -2
- package/web/dist/dev.cjs +11 -4
- package/web/dist/dev.js +11 -4
- package/web/dist/server.cjs +22 -276
- package/web/dist/server.js +22 -276
- package/web/dist/web.cjs +11 -4
- package/web/dist/web.js +11 -4
- package/web/types/client.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solid-js",
|
|
3
3
|
"description": "A declarative JavaScript library for building user interfaces.",
|
|
4
|
-
"version": "1.7.0-beta.
|
|
4
|
+
"version": "1.7.0-beta.2",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -259,7 +259,8 @@
|
|
|
259
259
|
"performance"
|
|
260
260
|
],
|
|
261
261
|
"dependencies": {
|
|
262
|
-
"csstype": "^3.1.0"
|
|
262
|
+
"csstype": "^3.1.0",
|
|
263
|
+
"seroval": "^0.5.0"
|
|
263
264
|
},
|
|
264
265
|
"scripts": {
|
|
265
266
|
"build": "npm-run-all -nl build:*",
|
package/web/dist/dev.cjs
CHANGED
|
@@ -392,7 +392,15 @@ function eventHandler(e) {
|
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
394
|
function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
395
|
-
if (solidJs.sharedConfig.context
|
|
395
|
+
if (solidJs.sharedConfig.context) {
|
|
396
|
+
!current && (current = [...parent.childNodes]);
|
|
397
|
+
let cleaned = [];
|
|
398
|
+
for (let i = 0; i < current.length; i++) {
|
|
399
|
+
const node = current[i];
|
|
400
|
+
if (node.nodeType === 8 && node.data === "!") node.remove();else cleaned.push(node);
|
|
401
|
+
}
|
|
402
|
+
current = cleaned;
|
|
403
|
+
}
|
|
396
404
|
while (typeof current === "function") current = current();
|
|
397
405
|
if (value === current) return current;
|
|
398
406
|
const t = typeof value,
|
|
@@ -478,9 +486,8 @@ function normalizeIncomingArray(normalized, array, current, unwrap) {
|
|
|
478
486
|
}
|
|
479
487
|
} else {
|
|
480
488
|
const value = String(item);
|
|
481
|
-
if (
|
|
482
|
-
|
|
483
|
-
} else if (prev && prev.nodeType === 3 && prev.data === value) {
|
|
489
|
+
if (prev && prev.nodeType === 3) {
|
|
490
|
+
prev.data = value;
|
|
484
491
|
normalized.push(prev);
|
|
485
492
|
} else normalized.push(document.createTextNode(value));
|
|
486
493
|
}
|
package/web/dist/dev.js
CHANGED
|
@@ -391,7 +391,15 @@ function eventHandler(e) {
|
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
393
|
function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
394
|
-
if (sharedConfig.context
|
|
394
|
+
if (sharedConfig.context) {
|
|
395
|
+
!current && (current = [...parent.childNodes]);
|
|
396
|
+
let cleaned = [];
|
|
397
|
+
for (let i = 0; i < current.length; i++) {
|
|
398
|
+
const node = current[i];
|
|
399
|
+
if (node.nodeType === 8 && node.data === "!") node.remove();else cleaned.push(node);
|
|
400
|
+
}
|
|
401
|
+
current = cleaned;
|
|
402
|
+
}
|
|
395
403
|
while (typeof current === "function") current = current();
|
|
396
404
|
if (value === current) return current;
|
|
397
405
|
const t = typeof value,
|
|
@@ -477,9 +485,8 @@ function normalizeIncomingArray(normalized, array, current, unwrap) {
|
|
|
477
485
|
}
|
|
478
486
|
} else {
|
|
479
487
|
const value = String(item);
|
|
480
|
-
if (
|
|
481
|
-
|
|
482
|
-
} else if (prev && prev.nodeType === 3 && prev.data === value) {
|
|
488
|
+
if (prev && prev.nodeType === 3) {
|
|
489
|
+
prev.data = value;
|
|
483
490
|
normalized.push(prev);
|
|
484
491
|
} else normalized.push(document.createTextNode(value));
|
|
485
492
|
}
|
package/web/dist/server.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var solidJs = require('solid-js');
|
|
4
|
+
var seroval = require('seroval');
|
|
4
5
|
|
|
5
6
|
const booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
|
|
6
7
|
const BooleanAttributes = /*#__PURE__*/new Set(booleans);
|
|
@@ -11,254 +12,13 @@ const Aliases = /*#__PURE__*/Object.assign(Object.create(null), {
|
|
|
11
12
|
htmlFor: "for"
|
|
12
13
|
});
|
|
13
14
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const STACK = [];
|
|
22
|
-
const BUFFER = [""];
|
|
23
|
-
let ASSIGNMENTS = new Map();
|
|
24
|
-
let INDEX_OR_REF = new WeakMap();
|
|
25
|
-
let REF_COUNT = 0;
|
|
26
|
-
BUFFER.pop();
|
|
27
|
-
function stringify(root) {
|
|
28
|
-
if (writeProp(root, "")) {
|
|
29
|
-
let result = BUFFER[0];
|
|
30
|
-
for (let i = 1, len = BUFFER.length; i < len; i++) {
|
|
31
|
-
result += BUFFER[i];
|
|
32
|
-
}
|
|
33
|
-
if (REF_COUNT) {
|
|
34
|
-
if (ASSIGNMENTS.size) {
|
|
35
|
-
let ref = INDEX_OR_REF.get(root);
|
|
36
|
-
if (typeof ref === "number") {
|
|
37
|
-
ref = toRefParam(REF_COUNT++);
|
|
38
|
-
result = ref + "=" + result;
|
|
39
|
-
}
|
|
40
|
-
for (const [assignmentRef, assignments] of ASSIGNMENTS) {
|
|
41
|
-
result += ";" + assignments + assignmentRef;
|
|
42
|
-
}
|
|
43
|
-
result += ";return " + ref;
|
|
44
|
-
ASSIGNMENTS = new Map();
|
|
45
|
-
} else {
|
|
46
|
-
result = "return " + result;
|
|
47
|
-
}
|
|
48
|
-
result = "(function(" + refParamsString() + "){" + result + "}())";
|
|
49
|
-
} else if (root && root.constructor === Object) {
|
|
50
|
-
result = "(" + result + ")";
|
|
51
|
-
}
|
|
52
|
-
BUFFER.length = 0;
|
|
53
|
-
INDEX_OR_REF = new WeakMap();
|
|
54
|
-
return result;
|
|
55
|
-
}
|
|
56
|
-
return "void 0";
|
|
57
|
-
}
|
|
58
|
-
function writeProp(cur, accessor) {
|
|
59
|
-
switch (typeof cur) {
|
|
60
|
-
case "string":
|
|
61
|
-
BUFFER.push(quote(cur, 0));
|
|
62
|
-
break;
|
|
63
|
-
case "number":
|
|
64
|
-
BUFFER.push(cur + "");
|
|
65
|
-
break;
|
|
66
|
-
case "boolean":
|
|
67
|
-
BUFFER.push(cur ? "!0" : "!1");
|
|
68
|
-
break;
|
|
69
|
-
case "object":
|
|
70
|
-
if (cur === null) {
|
|
71
|
-
BUFFER.push("null");
|
|
72
|
-
} else {
|
|
73
|
-
const ref = getRef(cur, accessor);
|
|
74
|
-
switch (ref) {
|
|
75
|
-
case true:
|
|
76
|
-
return false;
|
|
77
|
-
case false:
|
|
78
|
-
switch (cur.constructor) {
|
|
79
|
-
case Object:
|
|
80
|
-
writeObject(cur);
|
|
81
|
-
break;
|
|
82
|
-
case Array:
|
|
83
|
-
writeArray(cur);
|
|
84
|
-
break;
|
|
85
|
-
case Date:
|
|
86
|
-
BUFFER.push('new Date("' + cur.toISOString() + '")');
|
|
87
|
-
break;
|
|
88
|
-
case RegExp:
|
|
89
|
-
BUFFER.push(cur + "");
|
|
90
|
-
break;
|
|
91
|
-
case Map:
|
|
92
|
-
BUFFER.push("new Map(");
|
|
93
|
-
writeArray(Array.from(cur));
|
|
94
|
-
BUFFER.push(")");
|
|
95
|
-
break;
|
|
96
|
-
case Set:
|
|
97
|
-
BUFFER.push("new Set(");
|
|
98
|
-
writeArray(Array.from(cur));
|
|
99
|
-
BUFFER.push(")");
|
|
100
|
-
break;
|
|
101
|
-
case undefined:
|
|
102
|
-
BUFFER.push("Object.assign(Object.create(null),");
|
|
103
|
-
writeObject(cur);
|
|
104
|
-
BUFFER.push(")");
|
|
105
|
-
break;
|
|
106
|
-
default:
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
break;
|
|
110
|
-
default:
|
|
111
|
-
BUFFER.push(ref);
|
|
112
|
-
break;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
break;
|
|
116
|
-
default:
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
function writeObject(obj) {
|
|
122
|
-
let sep = "{";
|
|
123
|
-
STACK.push(obj);
|
|
124
|
-
for (const key in obj) {
|
|
125
|
-
if (hasOwnProperty.call(obj, key)) {
|
|
126
|
-
const val = obj[key];
|
|
127
|
-
const escapedKey = toObjectKey(key);
|
|
128
|
-
BUFFER.push(sep + escapedKey + ":");
|
|
129
|
-
if (writeProp(val, escapedKey)) {
|
|
130
|
-
sep = ",";
|
|
131
|
-
} else {
|
|
132
|
-
BUFFER.pop();
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
if (sep === "{") {
|
|
137
|
-
BUFFER.push("{}");
|
|
138
|
-
} else {
|
|
139
|
-
BUFFER.push("}");
|
|
140
|
-
}
|
|
141
|
-
STACK.pop();
|
|
142
|
-
}
|
|
143
|
-
function writeArray(arr) {
|
|
144
|
-
BUFFER.push("[");
|
|
145
|
-
STACK.push(arr);
|
|
146
|
-
writeProp(arr[0], 0);
|
|
147
|
-
for (let i = 1, len = arr.length; i < len; i++) {
|
|
148
|
-
BUFFER.push(",");
|
|
149
|
-
writeProp(arr[i], i);
|
|
150
|
-
}
|
|
151
|
-
STACK.pop();
|
|
152
|
-
BUFFER.push("]");
|
|
153
|
-
}
|
|
154
|
-
function getRef(cur, accessor) {
|
|
155
|
-
let ref = INDEX_OR_REF.get(cur);
|
|
156
|
-
if (ref === undefined) {
|
|
157
|
-
INDEX_OR_REF.set(cur, BUFFER.length);
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
if (typeof ref === "number") {
|
|
161
|
-
ref = insertAndGetRef(cur, ref);
|
|
162
|
-
}
|
|
163
|
-
if (STACK.includes(cur)) {
|
|
164
|
-
const parent = STACK[STACK.length - 1];
|
|
165
|
-
let parentRef = INDEX_OR_REF.get(parent);
|
|
166
|
-
if (typeof parentRef === "number") {
|
|
167
|
-
parentRef = insertAndGetRef(parent, parentRef);
|
|
168
|
-
}
|
|
169
|
-
ASSIGNMENTS.set(ref, (ASSIGNMENTS.get(ref) || "") + toAssignment(parentRef, accessor) + "=");
|
|
170
|
-
return true;
|
|
171
|
-
}
|
|
172
|
-
return ref;
|
|
173
|
-
}
|
|
174
|
-
function toObjectKey(name) {
|
|
175
|
-
const invalidIdentifierPos = getInvalidIdentifierPos(name);
|
|
176
|
-
return invalidIdentifierPos === -1 ? name : quote(name, invalidIdentifierPos);
|
|
177
|
-
}
|
|
178
|
-
function toAssignment(parent, key) {
|
|
179
|
-
return parent + (typeof key === "number" || key[0] === '"' ? "[" + key + "]" : "." + key);
|
|
180
|
-
}
|
|
181
|
-
function getInvalidIdentifierPos(name) {
|
|
182
|
-
let char = name[0];
|
|
183
|
-
if (!(char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char === "$" || char === "_")) {
|
|
184
|
-
return 0;
|
|
185
|
-
}
|
|
186
|
-
for (let i = 1, len = name.length; i < len; i++) {
|
|
187
|
-
char = name[i];
|
|
188
|
-
if (!(char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char >= "0" && char <= "9" || char === "$" || char === "_")) {
|
|
189
|
-
return i;
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return -1;
|
|
193
|
-
}
|
|
194
|
-
function quote(str, startPos) {
|
|
195
|
-
let result = "";
|
|
196
|
-
let lastPos = 0;
|
|
197
|
-
for (let i = startPos, len = str.length; i < len; i++) {
|
|
198
|
-
let replacement;
|
|
199
|
-
switch (str[i]) {
|
|
200
|
-
case '"':
|
|
201
|
-
replacement = '\\"';
|
|
202
|
-
break;
|
|
203
|
-
case "\\":
|
|
204
|
-
replacement = "\\\\";
|
|
205
|
-
break;
|
|
206
|
-
case "<":
|
|
207
|
-
replacement = "\\x3C";
|
|
208
|
-
break;
|
|
209
|
-
case "\n":
|
|
210
|
-
replacement = "\\n";
|
|
211
|
-
break;
|
|
212
|
-
case "\r":
|
|
213
|
-
replacement = "\\r";
|
|
214
|
-
break;
|
|
215
|
-
case "\u2028":
|
|
216
|
-
replacement = "\\u2028";
|
|
217
|
-
break;
|
|
218
|
-
case "\u2029":
|
|
219
|
-
replacement = "\\u2029";
|
|
220
|
-
break;
|
|
221
|
-
default:
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
result += str.slice(lastPos, i) + replacement;
|
|
225
|
-
lastPos = i + 1;
|
|
226
|
-
}
|
|
227
|
-
if (lastPos === startPos) {
|
|
228
|
-
result = str;
|
|
229
|
-
} else {
|
|
230
|
-
result += str.slice(lastPos);
|
|
231
|
-
}
|
|
232
|
-
return '"' + result + '"';
|
|
233
|
-
}
|
|
234
|
-
function insertAndGetRef(obj, pos) {
|
|
235
|
-
const ref = toRefParam(REF_COUNT++);
|
|
236
|
-
INDEX_OR_REF.set(obj, ref);
|
|
237
|
-
if (pos) {
|
|
238
|
-
BUFFER[pos - 1] += ref + "=";
|
|
239
|
-
} else {
|
|
240
|
-
BUFFER[pos] = ref + "=" + BUFFER[pos];
|
|
241
|
-
}
|
|
242
|
-
return ref;
|
|
243
|
-
}
|
|
244
|
-
function refParamsString() {
|
|
245
|
-
let result = REF_START_CHARS[0];
|
|
246
|
-
for (let i = 1; i < REF_COUNT; i++) {
|
|
247
|
-
result += "," + toRefParam(i);
|
|
248
|
-
}
|
|
249
|
-
REF_COUNT = 0;
|
|
250
|
-
return result;
|
|
251
|
-
}
|
|
252
|
-
function toRefParam(index) {
|
|
253
|
-
let mod = index % REF_START_CHARS_LEN;
|
|
254
|
-
let ref = REF_START_CHARS[mod];
|
|
255
|
-
index = (index - mod) / REF_START_CHARS_LEN;
|
|
256
|
-
while (index > 0) {
|
|
257
|
-
mod = index % REF_CHARS_LEN;
|
|
258
|
-
ref += REF_CHARS[mod];
|
|
259
|
-
index = (index - mod) / REF_CHARS_LEN;
|
|
260
|
-
}
|
|
261
|
-
return ref;
|
|
15
|
+
const ES2017FLAG = seroval.Feature.AggregateError
|
|
16
|
+
| seroval.Feature.BigInt
|
|
17
|
+
| seroval.Feature.BigIntTypedArray;
|
|
18
|
+
function stringify(data) {
|
|
19
|
+
return seroval.serialize(data, {
|
|
20
|
+
disabledFeatures: ES2017FLAG
|
|
21
|
+
});
|
|
262
22
|
}
|
|
263
23
|
|
|
264
24
|
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
@@ -274,7 +34,7 @@ function renderToString(code, options = {}) {
|
|
|
274
34
|
nonce: options.nonce,
|
|
275
35
|
writeResource(id, p, error) {
|
|
276
36
|
if (solidJs.sharedConfig.context.noHydrate) return;
|
|
277
|
-
if (error) return scripts += `_$HY.set("${id}", ${
|
|
37
|
+
if (error) return scripts += `_$HY.set("${id}", ${stringify(p)});`;
|
|
278
38
|
scripts += `_$HY.set("${id}", ${stringify(p)});`;
|
|
279
39
|
}
|
|
280
40
|
};
|
|
@@ -373,7 +133,7 @@ function renderToStream(code, options = {}) {
|
|
|
373
133
|
},
|
|
374
134
|
writeResource(id, p, error, wait) {
|
|
375
135
|
const serverOnly = solidJs.sharedConfig.context.noHydrate;
|
|
376
|
-
if (error) return !serverOnly && pushTask(serializeSet(dedupe, id, p
|
|
136
|
+
if (error) return !serverOnly && pushTask(serializeSet(dedupe, id, p));
|
|
377
137
|
if (!p || typeof p !== "object" || !("then" in p)) return !serverOnly && pushTask(serializeSet(dedupe, id, p));
|
|
378
138
|
if (!firstFlushed) wait && blockingResources.push(p);else !serverOnly && pushTask(`_$HY.init("${id}")`);
|
|
379
139
|
if (serverOnly) return;
|
|
@@ -396,10 +156,10 @@ function renderToStream(code, options = {}) {
|
|
|
396
156
|
if ((value !== undefined || error) && !completed) {
|
|
397
157
|
if (!firstFlushed) {
|
|
398
158
|
Promise.resolve().then(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
|
|
399
|
-
error && pushTask(serializeSet(dedupe, key, error
|
|
159
|
+
error && pushTask(serializeSet(dedupe, key, error));
|
|
400
160
|
} else {
|
|
401
161
|
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
402
|
-
pushTask(`${keys.length ? keys.map(k => `_$HY.unset("${k}")`).join(";") + ";" : ""}$df("${key}"${error ? "," +
|
|
162
|
+
pushTask(`${keys.length ? keys.map(k => `_$HY.unset("${k}")`).join(";") + ";" : ""}$df("${key}"${error ? "," + stringify(error) : ""})${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
|
|
403
163
|
scriptFlushed = true;
|
|
404
164
|
}
|
|
405
165
|
}
|
|
@@ -577,13 +337,10 @@ function ssrHydrationKey() {
|
|
|
577
337
|
function escape(s, attr) {
|
|
578
338
|
const t = typeof s;
|
|
579
339
|
if (t !== "string") {
|
|
580
|
-
if (!attr && t === "function") return escape(s()
|
|
340
|
+
if (!attr && t === "function") return escape(s());
|
|
581
341
|
if (!attr && Array.isArray(s)) {
|
|
582
|
-
let
|
|
583
|
-
|
|
584
|
-
return {
|
|
585
|
-
t: r
|
|
586
|
-
};
|
|
342
|
+
for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
|
|
343
|
+
return s;
|
|
587
344
|
}
|
|
588
345
|
if (attr && t === "boolean") return String(s);
|
|
589
346
|
return s;
|
|
@@ -628,8 +385,12 @@ function resolveSSRNode(node) {
|
|
|
628
385
|
if (t === "string") return node;
|
|
629
386
|
if (node == null || t === "boolean") return "";
|
|
630
387
|
if (Array.isArray(node)) {
|
|
388
|
+
let prev = {};
|
|
631
389
|
let mapped = "";
|
|
632
|
-
for (let i = 0, len = node.length; i < len; i++)
|
|
390
|
+
for (let i = 0, len = node.length; i < len; i++) {
|
|
391
|
+
if (typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!-->`;
|
|
392
|
+
mapped += resolveSSRNode(prev = node[i]);
|
|
393
|
+
}
|
|
633
394
|
return mapped;
|
|
634
395
|
}
|
|
635
396
|
if (t === "object") return node.t;
|
|
@@ -686,21 +447,6 @@ function injectScripts(html, scripts, nonce) {
|
|
|
686
447
|
}
|
|
687
448
|
return html + tag;
|
|
688
449
|
}
|
|
689
|
-
function serializeError(error) {
|
|
690
|
-
if (error.message) {
|
|
691
|
-
const fields = {};
|
|
692
|
-
const keys = Object.getOwnPropertyNames(error);
|
|
693
|
-
for (let i = 0; i < keys.length; i++) {
|
|
694
|
-
const key = keys[i];
|
|
695
|
-
const value = error[key];
|
|
696
|
-
if (!value || key !== "message" && typeof value !== "function") {
|
|
697
|
-
fields[key] = value;
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
return `Object.assign(new Error(${stringify(error.message)}), ${stringify(fields)})`;
|
|
701
|
-
}
|
|
702
|
-
return stringify(error);
|
|
703
|
-
}
|
|
704
450
|
function waitForFragments(registry, key) {
|
|
705
451
|
for (const k of [...registry.keys()].reverse()) {
|
|
706
452
|
if (key.startsWith(k)) {
|
|
@@ -710,11 +456,11 @@ function waitForFragments(registry, key) {
|
|
|
710
456
|
}
|
|
711
457
|
return false;
|
|
712
458
|
}
|
|
713
|
-
function serializeSet(registry, key, value
|
|
459
|
+
function serializeSet(registry, key, value) {
|
|
714
460
|
const exist = registry.get(value);
|
|
715
461
|
if (exist) return `_$HY.set("${key}", _$HY.r["${exist}"][0])`;
|
|
716
462
|
value !== null && typeof value === "object" && registry.set(value, key);
|
|
717
|
-
return `_$HY.set("${key}", ${
|
|
463
|
+
return `_$HY.set("${key}", ${stringify(value)})`;
|
|
718
464
|
}
|
|
719
465
|
function replacePlaceholder(html, key, value) {
|
|
720
466
|
const marker = `<template id="pl-${key}">`;
|
package/web/dist/server.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { sharedConfig, createRoot, splitProps } from 'solid-js';
|
|
2
2
|
export { ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, createComponent, mergeProps } from 'solid-js';
|
|
3
|
+
import { serialize, Feature } from 'seroval';
|
|
3
4
|
|
|
4
5
|
const booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
|
|
5
6
|
const BooleanAttributes = /*#__PURE__*/new Set(booleans);
|
|
@@ -10,254 +11,13 @@ const Aliases = /*#__PURE__*/Object.assign(Object.create(null), {
|
|
|
10
11
|
htmlFor: "for"
|
|
11
12
|
});
|
|
12
13
|
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const STACK = [];
|
|
21
|
-
const BUFFER = [""];
|
|
22
|
-
let ASSIGNMENTS = new Map();
|
|
23
|
-
let INDEX_OR_REF = new WeakMap();
|
|
24
|
-
let REF_COUNT = 0;
|
|
25
|
-
BUFFER.pop();
|
|
26
|
-
function stringify(root) {
|
|
27
|
-
if (writeProp(root, "")) {
|
|
28
|
-
let result = BUFFER[0];
|
|
29
|
-
for (let i = 1, len = BUFFER.length; i < len; i++) {
|
|
30
|
-
result += BUFFER[i];
|
|
31
|
-
}
|
|
32
|
-
if (REF_COUNT) {
|
|
33
|
-
if (ASSIGNMENTS.size) {
|
|
34
|
-
let ref = INDEX_OR_REF.get(root);
|
|
35
|
-
if (typeof ref === "number") {
|
|
36
|
-
ref = toRefParam(REF_COUNT++);
|
|
37
|
-
result = ref + "=" + result;
|
|
38
|
-
}
|
|
39
|
-
for (const [assignmentRef, assignments] of ASSIGNMENTS) {
|
|
40
|
-
result += ";" + assignments + assignmentRef;
|
|
41
|
-
}
|
|
42
|
-
result += ";return " + ref;
|
|
43
|
-
ASSIGNMENTS = new Map();
|
|
44
|
-
} else {
|
|
45
|
-
result = "return " + result;
|
|
46
|
-
}
|
|
47
|
-
result = "(function(" + refParamsString() + "){" + result + "}())";
|
|
48
|
-
} else if (root && root.constructor === Object) {
|
|
49
|
-
result = "(" + result + ")";
|
|
50
|
-
}
|
|
51
|
-
BUFFER.length = 0;
|
|
52
|
-
INDEX_OR_REF = new WeakMap();
|
|
53
|
-
return result;
|
|
54
|
-
}
|
|
55
|
-
return "void 0";
|
|
56
|
-
}
|
|
57
|
-
function writeProp(cur, accessor) {
|
|
58
|
-
switch (typeof cur) {
|
|
59
|
-
case "string":
|
|
60
|
-
BUFFER.push(quote(cur, 0));
|
|
61
|
-
break;
|
|
62
|
-
case "number":
|
|
63
|
-
BUFFER.push(cur + "");
|
|
64
|
-
break;
|
|
65
|
-
case "boolean":
|
|
66
|
-
BUFFER.push(cur ? "!0" : "!1");
|
|
67
|
-
break;
|
|
68
|
-
case "object":
|
|
69
|
-
if (cur === null) {
|
|
70
|
-
BUFFER.push("null");
|
|
71
|
-
} else {
|
|
72
|
-
const ref = getRef(cur, accessor);
|
|
73
|
-
switch (ref) {
|
|
74
|
-
case true:
|
|
75
|
-
return false;
|
|
76
|
-
case false:
|
|
77
|
-
switch (cur.constructor) {
|
|
78
|
-
case Object:
|
|
79
|
-
writeObject(cur);
|
|
80
|
-
break;
|
|
81
|
-
case Array:
|
|
82
|
-
writeArray(cur);
|
|
83
|
-
break;
|
|
84
|
-
case Date:
|
|
85
|
-
BUFFER.push('new Date("' + cur.toISOString() + '")');
|
|
86
|
-
break;
|
|
87
|
-
case RegExp:
|
|
88
|
-
BUFFER.push(cur + "");
|
|
89
|
-
break;
|
|
90
|
-
case Map:
|
|
91
|
-
BUFFER.push("new Map(");
|
|
92
|
-
writeArray(Array.from(cur));
|
|
93
|
-
BUFFER.push(")");
|
|
94
|
-
break;
|
|
95
|
-
case Set:
|
|
96
|
-
BUFFER.push("new Set(");
|
|
97
|
-
writeArray(Array.from(cur));
|
|
98
|
-
BUFFER.push(")");
|
|
99
|
-
break;
|
|
100
|
-
case undefined:
|
|
101
|
-
BUFFER.push("Object.assign(Object.create(null),");
|
|
102
|
-
writeObject(cur);
|
|
103
|
-
BUFFER.push(")");
|
|
104
|
-
break;
|
|
105
|
-
default:
|
|
106
|
-
return false;
|
|
107
|
-
}
|
|
108
|
-
break;
|
|
109
|
-
default:
|
|
110
|
-
BUFFER.push(ref);
|
|
111
|
-
break;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
break;
|
|
115
|
-
default:
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
return true;
|
|
119
|
-
}
|
|
120
|
-
function writeObject(obj) {
|
|
121
|
-
let sep = "{";
|
|
122
|
-
STACK.push(obj);
|
|
123
|
-
for (const key in obj) {
|
|
124
|
-
if (hasOwnProperty.call(obj, key)) {
|
|
125
|
-
const val = obj[key];
|
|
126
|
-
const escapedKey = toObjectKey(key);
|
|
127
|
-
BUFFER.push(sep + escapedKey + ":");
|
|
128
|
-
if (writeProp(val, escapedKey)) {
|
|
129
|
-
sep = ",";
|
|
130
|
-
} else {
|
|
131
|
-
BUFFER.pop();
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
if (sep === "{") {
|
|
136
|
-
BUFFER.push("{}");
|
|
137
|
-
} else {
|
|
138
|
-
BUFFER.push("}");
|
|
139
|
-
}
|
|
140
|
-
STACK.pop();
|
|
141
|
-
}
|
|
142
|
-
function writeArray(arr) {
|
|
143
|
-
BUFFER.push("[");
|
|
144
|
-
STACK.push(arr);
|
|
145
|
-
writeProp(arr[0], 0);
|
|
146
|
-
for (let i = 1, len = arr.length; i < len; i++) {
|
|
147
|
-
BUFFER.push(",");
|
|
148
|
-
writeProp(arr[i], i);
|
|
149
|
-
}
|
|
150
|
-
STACK.pop();
|
|
151
|
-
BUFFER.push("]");
|
|
152
|
-
}
|
|
153
|
-
function getRef(cur, accessor) {
|
|
154
|
-
let ref = INDEX_OR_REF.get(cur);
|
|
155
|
-
if (ref === undefined) {
|
|
156
|
-
INDEX_OR_REF.set(cur, BUFFER.length);
|
|
157
|
-
return false;
|
|
158
|
-
}
|
|
159
|
-
if (typeof ref === "number") {
|
|
160
|
-
ref = insertAndGetRef(cur, ref);
|
|
161
|
-
}
|
|
162
|
-
if (STACK.includes(cur)) {
|
|
163
|
-
const parent = STACK[STACK.length - 1];
|
|
164
|
-
let parentRef = INDEX_OR_REF.get(parent);
|
|
165
|
-
if (typeof parentRef === "number") {
|
|
166
|
-
parentRef = insertAndGetRef(parent, parentRef);
|
|
167
|
-
}
|
|
168
|
-
ASSIGNMENTS.set(ref, (ASSIGNMENTS.get(ref) || "") + toAssignment(parentRef, accessor) + "=");
|
|
169
|
-
return true;
|
|
170
|
-
}
|
|
171
|
-
return ref;
|
|
172
|
-
}
|
|
173
|
-
function toObjectKey(name) {
|
|
174
|
-
const invalidIdentifierPos = getInvalidIdentifierPos(name);
|
|
175
|
-
return invalidIdentifierPos === -1 ? name : quote(name, invalidIdentifierPos);
|
|
176
|
-
}
|
|
177
|
-
function toAssignment(parent, key) {
|
|
178
|
-
return parent + (typeof key === "number" || key[0] === '"' ? "[" + key + "]" : "." + key);
|
|
179
|
-
}
|
|
180
|
-
function getInvalidIdentifierPos(name) {
|
|
181
|
-
let char = name[0];
|
|
182
|
-
if (!(char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char === "$" || char === "_")) {
|
|
183
|
-
return 0;
|
|
184
|
-
}
|
|
185
|
-
for (let i = 1, len = name.length; i < len; i++) {
|
|
186
|
-
char = name[i];
|
|
187
|
-
if (!(char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char >= "0" && char <= "9" || char === "$" || char === "_")) {
|
|
188
|
-
return i;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
return -1;
|
|
192
|
-
}
|
|
193
|
-
function quote(str, startPos) {
|
|
194
|
-
let result = "";
|
|
195
|
-
let lastPos = 0;
|
|
196
|
-
for (let i = startPos, len = str.length; i < len; i++) {
|
|
197
|
-
let replacement;
|
|
198
|
-
switch (str[i]) {
|
|
199
|
-
case '"':
|
|
200
|
-
replacement = '\\"';
|
|
201
|
-
break;
|
|
202
|
-
case "\\":
|
|
203
|
-
replacement = "\\\\";
|
|
204
|
-
break;
|
|
205
|
-
case "<":
|
|
206
|
-
replacement = "\\x3C";
|
|
207
|
-
break;
|
|
208
|
-
case "\n":
|
|
209
|
-
replacement = "\\n";
|
|
210
|
-
break;
|
|
211
|
-
case "\r":
|
|
212
|
-
replacement = "\\r";
|
|
213
|
-
break;
|
|
214
|
-
case "\u2028":
|
|
215
|
-
replacement = "\\u2028";
|
|
216
|
-
break;
|
|
217
|
-
case "\u2029":
|
|
218
|
-
replacement = "\\u2029";
|
|
219
|
-
break;
|
|
220
|
-
default:
|
|
221
|
-
continue;
|
|
222
|
-
}
|
|
223
|
-
result += str.slice(lastPos, i) + replacement;
|
|
224
|
-
lastPos = i + 1;
|
|
225
|
-
}
|
|
226
|
-
if (lastPos === startPos) {
|
|
227
|
-
result = str;
|
|
228
|
-
} else {
|
|
229
|
-
result += str.slice(lastPos);
|
|
230
|
-
}
|
|
231
|
-
return '"' + result + '"';
|
|
232
|
-
}
|
|
233
|
-
function insertAndGetRef(obj, pos) {
|
|
234
|
-
const ref = toRefParam(REF_COUNT++);
|
|
235
|
-
INDEX_OR_REF.set(obj, ref);
|
|
236
|
-
if (pos) {
|
|
237
|
-
BUFFER[pos - 1] += ref + "=";
|
|
238
|
-
} else {
|
|
239
|
-
BUFFER[pos] = ref + "=" + BUFFER[pos];
|
|
240
|
-
}
|
|
241
|
-
return ref;
|
|
242
|
-
}
|
|
243
|
-
function refParamsString() {
|
|
244
|
-
let result = REF_START_CHARS[0];
|
|
245
|
-
for (let i = 1; i < REF_COUNT; i++) {
|
|
246
|
-
result += "," + toRefParam(i);
|
|
247
|
-
}
|
|
248
|
-
REF_COUNT = 0;
|
|
249
|
-
return result;
|
|
250
|
-
}
|
|
251
|
-
function toRefParam(index) {
|
|
252
|
-
let mod = index % REF_START_CHARS_LEN;
|
|
253
|
-
let ref = REF_START_CHARS[mod];
|
|
254
|
-
index = (index - mod) / REF_START_CHARS_LEN;
|
|
255
|
-
while (index > 0) {
|
|
256
|
-
mod = index % REF_CHARS_LEN;
|
|
257
|
-
ref += REF_CHARS[mod];
|
|
258
|
-
index = (index - mod) / REF_CHARS_LEN;
|
|
259
|
-
}
|
|
260
|
-
return ref;
|
|
14
|
+
const ES2017FLAG = Feature.AggregateError
|
|
15
|
+
| Feature.BigInt
|
|
16
|
+
| Feature.BigIntTypedArray;
|
|
17
|
+
function stringify(data) {
|
|
18
|
+
return serialize(data, {
|
|
19
|
+
disabledFeatures: ES2017FLAG
|
|
20
|
+
});
|
|
261
21
|
}
|
|
262
22
|
|
|
263
23
|
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
@@ -273,7 +33,7 @@ function renderToString(code, options = {}) {
|
|
|
273
33
|
nonce: options.nonce,
|
|
274
34
|
writeResource(id, p, error) {
|
|
275
35
|
if (sharedConfig.context.noHydrate) return;
|
|
276
|
-
if (error) return scripts += `_$HY.set("${id}", ${
|
|
36
|
+
if (error) return scripts += `_$HY.set("${id}", ${stringify(p)});`;
|
|
277
37
|
scripts += `_$HY.set("${id}", ${stringify(p)});`;
|
|
278
38
|
}
|
|
279
39
|
};
|
|
@@ -372,7 +132,7 @@ function renderToStream(code, options = {}) {
|
|
|
372
132
|
},
|
|
373
133
|
writeResource(id, p, error, wait) {
|
|
374
134
|
const serverOnly = sharedConfig.context.noHydrate;
|
|
375
|
-
if (error) return !serverOnly && pushTask(serializeSet(dedupe, id, p
|
|
135
|
+
if (error) return !serverOnly && pushTask(serializeSet(dedupe, id, p));
|
|
376
136
|
if (!p || typeof p !== "object" || !("then" in p)) return !serverOnly && pushTask(serializeSet(dedupe, id, p));
|
|
377
137
|
if (!firstFlushed) wait && blockingResources.push(p);else !serverOnly && pushTask(`_$HY.init("${id}")`);
|
|
378
138
|
if (serverOnly) return;
|
|
@@ -395,10 +155,10 @@ function renderToStream(code, options = {}) {
|
|
|
395
155
|
if ((value !== undefined || error) && !completed) {
|
|
396
156
|
if (!firstFlushed) {
|
|
397
157
|
Promise.resolve().then(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
|
|
398
|
-
error && pushTask(serializeSet(dedupe, key, error
|
|
158
|
+
error && pushTask(serializeSet(dedupe, key, error));
|
|
399
159
|
} else {
|
|
400
160
|
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
401
|
-
pushTask(`${keys.length ? keys.map(k => `_$HY.unset("${k}")`).join(";") + ";" : ""}$df("${key}"${error ? "," +
|
|
161
|
+
pushTask(`${keys.length ? keys.map(k => `_$HY.unset("${k}")`).join(";") + ";" : ""}$df("${key}"${error ? "," + stringify(error) : ""})${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
|
|
402
162
|
scriptFlushed = true;
|
|
403
163
|
}
|
|
404
164
|
}
|
|
@@ -576,13 +336,10 @@ function ssrHydrationKey() {
|
|
|
576
336
|
function escape(s, attr) {
|
|
577
337
|
const t = typeof s;
|
|
578
338
|
if (t !== "string") {
|
|
579
|
-
if (!attr && t === "function") return escape(s()
|
|
339
|
+
if (!attr && t === "function") return escape(s());
|
|
580
340
|
if (!attr && Array.isArray(s)) {
|
|
581
|
-
let
|
|
582
|
-
|
|
583
|
-
return {
|
|
584
|
-
t: r
|
|
585
|
-
};
|
|
341
|
+
for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
|
|
342
|
+
return s;
|
|
586
343
|
}
|
|
587
344
|
if (attr && t === "boolean") return String(s);
|
|
588
345
|
return s;
|
|
@@ -627,8 +384,12 @@ function resolveSSRNode(node) {
|
|
|
627
384
|
if (t === "string") return node;
|
|
628
385
|
if (node == null || t === "boolean") return "";
|
|
629
386
|
if (Array.isArray(node)) {
|
|
387
|
+
let prev = {};
|
|
630
388
|
let mapped = "";
|
|
631
|
-
for (let i = 0, len = node.length; i < len; i++)
|
|
389
|
+
for (let i = 0, len = node.length; i < len; i++) {
|
|
390
|
+
if (typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!-->`;
|
|
391
|
+
mapped += resolveSSRNode(prev = node[i]);
|
|
392
|
+
}
|
|
632
393
|
return mapped;
|
|
633
394
|
}
|
|
634
395
|
if (t === "object") return node.t;
|
|
@@ -685,21 +446,6 @@ function injectScripts(html, scripts, nonce) {
|
|
|
685
446
|
}
|
|
686
447
|
return html + tag;
|
|
687
448
|
}
|
|
688
|
-
function serializeError(error) {
|
|
689
|
-
if (error.message) {
|
|
690
|
-
const fields = {};
|
|
691
|
-
const keys = Object.getOwnPropertyNames(error);
|
|
692
|
-
for (let i = 0; i < keys.length; i++) {
|
|
693
|
-
const key = keys[i];
|
|
694
|
-
const value = error[key];
|
|
695
|
-
if (!value || key !== "message" && typeof value !== "function") {
|
|
696
|
-
fields[key] = value;
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
return `Object.assign(new Error(${stringify(error.message)}), ${stringify(fields)})`;
|
|
700
|
-
}
|
|
701
|
-
return stringify(error);
|
|
702
|
-
}
|
|
703
449
|
function waitForFragments(registry, key) {
|
|
704
450
|
for (const k of [...registry.keys()].reverse()) {
|
|
705
451
|
if (key.startsWith(k)) {
|
|
@@ -709,11 +455,11 @@ function waitForFragments(registry, key) {
|
|
|
709
455
|
}
|
|
710
456
|
return false;
|
|
711
457
|
}
|
|
712
|
-
function serializeSet(registry, key, value
|
|
458
|
+
function serializeSet(registry, key, value) {
|
|
713
459
|
const exist = registry.get(value);
|
|
714
460
|
if (exist) return `_$HY.set("${key}", _$HY.r["${exist}"][0])`;
|
|
715
461
|
value !== null && typeof value === "object" && registry.set(value, key);
|
|
716
|
-
return `_$HY.set("${key}", ${
|
|
462
|
+
return `_$HY.set("${key}", ${stringify(value)})`;
|
|
717
463
|
}
|
|
718
464
|
function replacePlaceholder(html, key, value) {
|
|
719
465
|
const marker = `<template id="pl-${key}">`;
|
package/web/dist/web.cjs
CHANGED
|
@@ -392,7 +392,15 @@ function eventHandler(e) {
|
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
394
|
function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
395
|
-
if (solidJs.sharedConfig.context
|
|
395
|
+
if (solidJs.sharedConfig.context) {
|
|
396
|
+
!current && (current = [...parent.childNodes]);
|
|
397
|
+
let cleaned = [];
|
|
398
|
+
for (let i = 0; i < current.length; i++) {
|
|
399
|
+
const node = current[i];
|
|
400
|
+
if (node.nodeType === 8 && node.data === "!") node.remove();else cleaned.push(node);
|
|
401
|
+
}
|
|
402
|
+
current = cleaned;
|
|
403
|
+
}
|
|
396
404
|
while (typeof current === "function") current = current();
|
|
397
405
|
if (value === current) return current;
|
|
398
406
|
const t = typeof value,
|
|
@@ -478,9 +486,8 @@ function normalizeIncomingArray(normalized, array, current, unwrap) {
|
|
|
478
486
|
}
|
|
479
487
|
} else {
|
|
480
488
|
const value = String(item);
|
|
481
|
-
if (
|
|
482
|
-
|
|
483
|
-
} else if (prev && prev.nodeType === 3 && prev.data === value) {
|
|
489
|
+
if (prev && prev.nodeType === 3) {
|
|
490
|
+
prev.data = value;
|
|
484
491
|
normalized.push(prev);
|
|
485
492
|
} else normalized.push(document.createTextNode(value));
|
|
486
493
|
}
|
package/web/dist/web.js
CHANGED
|
@@ -391,7 +391,15 @@ function eventHandler(e) {
|
|
|
391
391
|
}
|
|
392
392
|
}
|
|
393
393
|
function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
394
|
-
if (sharedConfig.context
|
|
394
|
+
if (sharedConfig.context) {
|
|
395
|
+
!current && (current = [...parent.childNodes]);
|
|
396
|
+
let cleaned = [];
|
|
397
|
+
for (let i = 0; i < current.length; i++) {
|
|
398
|
+
const node = current[i];
|
|
399
|
+
if (node.nodeType === 8 && node.data === "!") node.remove();else cleaned.push(node);
|
|
400
|
+
}
|
|
401
|
+
current = cleaned;
|
|
402
|
+
}
|
|
395
403
|
while (typeof current === "function") current = current();
|
|
396
404
|
if (value === current) return current;
|
|
397
405
|
const t = typeof value,
|
|
@@ -477,9 +485,8 @@ function normalizeIncomingArray(normalized, array, current, unwrap) {
|
|
|
477
485
|
}
|
|
478
486
|
} else {
|
|
479
487
|
const value = String(item);
|
|
480
|
-
if (
|
|
481
|
-
|
|
482
|
-
} else if (prev && prev.nodeType === 3 && prev.data === value) {
|
|
488
|
+
if (prev && prev.nodeType === 3) {
|
|
489
|
+
prev.data = value;
|
|
483
490
|
normalized.push(prev);
|
|
484
491
|
} else normalized.push(document.createTextNode(value));
|
|
485
492
|
}
|
package/web/types/client.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export function getPropAlias(prop: string, tagName: string): string | undefined;
|
|
|
10
10
|
|
|
11
11
|
type MountableElement = Element | Document | ShadowRoot | DocumentFragment | Node;
|
|
12
12
|
export function render(code: () => JSX.Element, element: MountableElement): () => void;
|
|
13
|
-
export function template(html: string,
|
|
13
|
+
export function template(html: string, isSVG?: boolean, isCE?: boolean): () => Element;
|
|
14
14
|
export function effect<T>(fn: (prev?: T) => T, init?: T): void;
|
|
15
15
|
export function memo<T>(fn: () => T, equal: boolean): () => T;
|
|
16
16
|
export function untrack<T>(fn: () => T): T;
|