solid-js 1.5.0-beta.2 → 1.5.0-beta.3
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 +81 -58
- package/dist/dev.js +81 -58
- package/dist/server.cjs +3 -3
- package/dist/server.js +3 -3
- package/dist/solid.cjs +81 -58
- package/dist/solid.js +81 -58
- package/h/jsx-runtime/types/jsx.d.ts +1 -1
- package/package.json +1 -1
- package/types/jsx.d.ts +2 -2
- package/types/reactive/signal.d.ts +1 -0
- package/types/render/flow.d.ts +18 -1
- package/types/server/rendering.d.ts +6 -2
- package/universal/dist/dev.cjs +4 -1
- package/universal/dist/dev.js +5 -2
- package/universal/dist/universal.cjs +4 -1
- package/universal/dist/universal.js +5 -2
- package/web/dist/dev.cjs +5 -0
- package/web/dist/dev.js +6 -2
- package/web/dist/server.cjs +239 -209
- package/web/dist/server.js +239 -209
- package/web/dist/web.cjs +5 -0
- package/web/dist/web.js +6 -2
package/web/dist/dev.cjs
CHANGED
|
@@ -207,6 +207,9 @@ function dynamicProperty(props, key) {
|
|
|
207
207
|
function innerHTML(parent, content) {
|
|
208
208
|
!solidJs.sharedConfig.context && (parent.innerHTML = content);
|
|
209
209
|
}
|
|
210
|
+
function use(fn, element, arg) {
|
|
211
|
+
return solidJs.untrack(() => fn(element, arg));
|
|
212
|
+
}
|
|
210
213
|
function insert(parent, accessor, marker, initial) {
|
|
211
214
|
if (marker !== undefined && !initial) initial = [];
|
|
212
215
|
if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
|
|
@@ -414,6 +417,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
|
414
417
|
return () => current;
|
|
415
418
|
}
|
|
416
419
|
if (solidJs.sharedConfig.context) {
|
|
420
|
+
if (!array.length) return current;
|
|
417
421
|
for (let i = 0; i < array.length; i++) {
|
|
418
422
|
if (array[i].parentNode) return current = array;
|
|
419
423
|
}
|
|
@@ -690,3 +694,4 @@ exports.ssrHydrationKey = ssrHydrationKey;
|
|
|
690
694
|
exports.ssrStyle = ssrStyle;
|
|
691
695
|
exports.style = style;
|
|
692
696
|
exports.template = template;
|
|
697
|
+
exports.use = use;
|
package/web/dist/dev.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createMemo, createRoot, createRenderEffect, sharedConfig, enableHydration, createSignal, onCleanup, splitProps, $DEVCOMP
|
|
1
|
+
import { createMemo, createRoot, createRenderEffect, sharedConfig, untrack, enableHydration, createSignal, onCleanup, splitProps, $DEVCOMP } from 'solid-js';
|
|
2
2
|
export { ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, createComponent, createRenderEffect as effect, getOwner, mergeProps } from 'solid-js';
|
|
3
3
|
|
|
4
4
|
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"];
|
|
@@ -204,6 +204,9 @@ function dynamicProperty(props, key) {
|
|
|
204
204
|
function innerHTML(parent, content) {
|
|
205
205
|
!sharedConfig.context && (parent.innerHTML = content);
|
|
206
206
|
}
|
|
207
|
+
function use(fn, element, arg) {
|
|
208
|
+
return untrack(() => fn(element, arg));
|
|
209
|
+
}
|
|
207
210
|
function insert(parent, accessor, marker, initial) {
|
|
208
211
|
if (marker !== undefined && !initial) initial = [];
|
|
209
212
|
if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
|
|
@@ -411,6 +414,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
|
411
414
|
return () => current;
|
|
412
415
|
}
|
|
413
416
|
if (sharedConfig.context) {
|
|
417
|
+
if (!array.length) return current;
|
|
414
418
|
for (let i = 0; i < array.length; i++) {
|
|
415
419
|
if (array[i].parentNode) return current = array;
|
|
416
420
|
}
|
|
@@ -591,4 +595,4 @@ function Dynamic(props) {
|
|
|
591
595
|
});
|
|
592
596
|
}
|
|
593
597
|
|
|
594
|
-
export { Aliases, Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Assets as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, className, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, generateHydrationScript, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, innerHTML, insert, isServer, memo, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template };
|
|
598
|
+
export { Aliases, Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Assets as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, className, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, generateHydrationScript, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, innerHTML, insert, isServer, memo, render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrAttribute, ssrClassList, ssrElement, ssrHydrationKey, ssrStyle, style, template, use };
|
package/web/dist/server.cjs
CHANGED
|
@@ -13,225 +13,255 @@ const Aliases = {
|
|
|
13
13
|
htmlFor: "for"
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
function devalue(value) {
|
|
35
|
-
var counts = new Map();
|
|
36
|
-
function walk(thing) {
|
|
37
|
-
if (typeof thing === 'function') {
|
|
38
|
-
throw new Error("Cannot stringify a function");
|
|
16
|
+
const {
|
|
17
|
+
hasOwnProperty
|
|
18
|
+
} = Object.prototype;
|
|
19
|
+
const REF_START_CHARS = "hjkmoquxzABCDEFGHIJKLNPQRTUVWXYZ$_";
|
|
20
|
+
const REF_START_CHARS_LEN = REF_START_CHARS.length;
|
|
21
|
+
const REF_CHARS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789$_";
|
|
22
|
+
const REF_CHARS_LEN = REF_CHARS.length;
|
|
23
|
+
const STACK = [];
|
|
24
|
+
const BUFFER = [""];
|
|
25
|
+
let ASSIGNMENTS = new Map();
|
|
26
|
+
let INDEX_OR_REF = new WeakMap();
|
|
27
|
+
let REF_COUNT = 0;
|
|
28
|
+
BUFFER.pop();
|
|
29
|
+
function stringify(root) {
|
|
30
|
+
if (writeProp(root, "")) {
|
|
31
|
+
let result = BUFFER[0];
|
|
32
|
+
for (let i = 1, len = BUFFER.length; i < len; i++) {
|
|
33
|
+
result += BUFFER[i];
|
|
39
34
|
}
|
|
40
|
-
if (
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
if (REF_COUNT) {
|
|
36
|
+
if (ASSIGNMENTS.size) {
|
|
37
|
+
let ref = INDEX_OR_REF.get(root);
|
|
38
|
+
if (typeof ref === "number") {
|
|
39
|
+
ref = toRefParam(REF_COUNT++);
|
|
40
|
+
result = ref + "=" + result;
|
|
41
|
+
}
|
|
42
|
+
for (const [assignmentRef, assignments] of ASSIGNMENTS) {
|
|
43
|
+
result += ";" + assignments + assignmentRef;
|
|
44
|
+
}
|
|
45
|
+
result += ";return " + ref;
|
|
46
|
+
ASSIGNMENTS = new Map();
|
|
47
|
+
} else {
|
|
48
|
+
result = "return " + result;
|
|
49
|
+
}
|
|
50
|
+
result = "(function(" + refParamsString() + "){" + result + "}())";
|
|
51
|
+
} else if (root && root.constructor === Object) {
|
|
52
|
+
result = "(" + result + ")";
|
|
43
53
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
54
|
+
BUFFER.length = 0;
|
|
55
|
+
INDEX_OR_REF = new WeakMap();
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
return "void 0";
|
|
59
|
+
}
|
|
60
|
+
function writeProp(cur, accessor) {
|
|
61
|
+
switch (typeof cur) {
|
|
62
|
+
case "string":
|
|
63
|
+
BUFFER.push(quote(cur, 0));
|
|
64
|
+
break;
|
|
65
|
+
case "number":
|
|
66
|
+
BUFFER.push(cur + "");
|
|
67
|
+
break;
|
|
68
|
+
case "boolean":
|
|
69
|
+
BUFFER.push(cur ? "!0" : "!1");
|
|
70
|
+
break;
|
|
71
|
+
case "object":
|
|
72
|
+
if (cur === null) {
|
|
73
|
+
BUFFER.push("null");
|
|
74
|
+
} else {
|
|
75
|
+
const ref = getRef(cur, accessor);
|
|
76
|
+
switch (ref) {
|
|
77
|
+
case true:
|
|
78
|
+
return false;
|
|
79
|
+
case false:
|
|
80
|
+
switch (cur.constructor) {
|
|
81
|
+
case Object:
|
|
82
|
+
writeObject(cur);
|
|
83
|
+
break;
|
|
84
|
+
case Array:
|
|
85
|
+
writeArray(cur);
|
|
86
|
+
break;
|
|
87
|
+
case Date:
|
|
88
|
+
BUFFER.push('new Date("' + cur.toISOString() + '")');
|
|
89
|
+
break;
|
|
90
|
+
case RegExp:
|
|
91
|
+
BUFFER.push(cur + "");
|
|
92
|
+
break;
|
|
93
|
+
case Map:
|
|
94
|
+
BUFFER.push("new Map(");
|
|
95
|
+
writeArray(Array.from(cur));
|
|
96
|
+
BUFFER.push(")");
|
|
97
|
+
break;
|
|
98
|
+
case Set:
|
|
99
|
+
BUFFER.push("new Set(");
|
|
100
|
+
writeArray(Array.from(cur));
|
|
101
|
+
BUFFER.push(")");
|
|
102
|
+
break;
|
|
103
|
+
case undefined:
|
|
104
|
+
BUFFER.push("Object.assign(Object.create(null),");
|
|
105
|
+
writeObject(cur);
|
|
106
|
+
BUFFER.push("))");
|
|
107
|
+
break;
|
|
108
|
+
default:
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
break;
|
|
112
|
+
default:
|
|
113
|
+
BUFFER.push(ref);
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
break;
|
|
118
|
+
default:
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
function writeObject(obj) {
|
|
124
|
+
let sep = "{";
|
|
125
|
+
STACK.push(obj);
|
|
126
|
+
for (const key in obj) {
|
|
127
|
+
if (hasOwnProperty.call(obj, key)) {
|
|
128
|
+
const val = obj[key];
|
|
129
|
+
const escapedKey = toObjectKey(key);
|
|
130
|
+
BUFFER.push(sep + escapedKey + ":");
|
|
131
|
+
if (writeProp(val, escapedKey)) {
|
|
132
|
+
sep = ",";
|
|
133
|
+
} else {
|
|
134
|
+
BUFFER.pop();
|
|
72
135
|
}
|
|
73
136
|
}
|
|
74
137
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
138
|
+
if (sep === "{") {
|
|
139
|
+
BUFFER.push("{}");
|
|
140
|
+
} else {
|
|
141
|
+
BUFFER.push("}");
|
|
142
|
+
}
|
|
143
|
+
STACK.pop();
|
|
144
|
+
}
|
|
145
|
+
function writeArray(arr) {
|
|
146
|
+
BUFFER.push("[");
|
|
147
|
+
STACK.push(arr);
|
|
148
|
+
writeProp(arr[0], 0);
|
|
149
|
+
for (let i = 1, len = arr.length; i < len; i++) {
|
|
150
|
+
BUFFER.push(",");
|
|
151
|
+
writeProp(arr[i], i);
|
|
152
|
+
}
|
|
153
|
+
STACK.pop();
|
|
154
|
+
BUFFER.push("]");
|
|
155
|
+
}
|
|
156
|
+
function getRef(cur, accessor) {
|
|
157
|
+
let ref = INDEX_OR_REF.get(cur);
|
|
158
|
+
if (ref === undefined) {
|
|
159
|
+
INDEX_OR_REF.set(cur, BUFFER.length);
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
if (typeof ref === "number") {
|
|
163
|
+
ref = insertAndGetRef(cur, ref);
|
|
164
|
+
}
|
|
165
|
+
if (STACK.includes(cur)) {
|
|
166
|
+
const parent = STACK[STACK.length - 1];
|
|
167
|
+
let parentRef = INDEX_OR_REF.get(parent);
|
|
168
|
+
if (typeof parentRef === "number") {
|
|
169
|
+
parentRef = insertAndGetRef(parent, parentRef);
|
|
87
170
|
}
|
|
88
|
-
|
|
89
|
-
|
|
171
|
+
ASSIGNMENTS.set(ref, (ASSIGNMENTS.get(ref) || "") + toAssignment(parentRef, accessor) + "=");
|
|
172
|
+
return true;
|
|
173
|
+
}
|
|
174
|
+
return ref;
|
|
175
|
+
}
|
|
176
|
+
function toObjectKey(name) {
|
|
177
|
+
const invalidIdentifierPos = getInvalidIdentifierPos(name);
|
|
178
|
+
return invalidIdentifierPos === -1 ? name : quote(name, invalidIdentifierPos);
|
|
179
|
+
}
|
|
180
|
+
function toAssignment(parent, key) {
|
|
181
|
+
return parent + (typeof key === "number" || key[0] === '"' ? "[" + key + "]" : "." + key);
|
|
182
|
+
}
|
|
183
|
+
function getInvalidIdentifierPos(name) {
|
|
184
|
+
let char = name[0];
|
|
185
|
+
if (!(char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char === "$" || char === "_")) {
|
|
186
|
+
return 0;
|
|
187
|
+
}
|
|
188
|
+
for (let i = 1, len = name.length; i < len; i++) {
|
|
189
|
+
char = name[i];
|
|
190
|
+
if (!(char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char >= "0" && char <= "9" || char === "$" || char === "_")) {
|
|
191
|
+
return i;
|
|
90
192
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
193
|
+
}
|
|
194
|
+
return -1;
|
|
195
|
+
}
|
|
196
|
+
function quote(str, startPos) {
|
|
197
|
+
let result = "";
|
|
198
|
+
let lastPos = 0;
|
|
199
|
+
for (let i = startPos, len = str.length; i < len; i++) {
|
|
200
|
+
let replacement;
|
|
201
|
+
switch (str[i]) {
|
|
202
|
+
case '"':
|
|
203
|
+
replacement = '\\"';
|
|
204
|
+
break;
|
|
205
|
+
case "\\":
|
|
206
|
+
replacement = "\\\\";
|
|
207
|
+
break;
|
|
208
|
+
case "<":
|
|
209
|
+
replacement = "\\x3C";
|
|
210
|
+
break;
|
|
211
|
+
case "\n":
|
|
212
|
+
replacement = "\\n";
|
|
213
|
+
break;
|
|
214
|
+
case "\r":
|
|
215
|
+
replacement = "\\r";
|
|
216
|
+
break;
|
|
217
|
+
case "\u2028":
|
|
218
|
+
replacement = "\\u2028";
|
|
219
|
+
break;
|
|
220
|
+
case "\u2029":
|
|
221
|
+
replacement = "\\u2029";
|
|
222
|
+
break;
|
|
110
223
|
default:
|
|
111
|
-
|
|
112
|
-
return safeKey(key) + ":" + stringify(thing[key]);
|
|
113
|
-
}).join(',') + "}";
|
|
114
|
-
var proto = Object.getPrototypeOf(thing);
|
|
115
|
-
if (proto === null) {
|
|
116
|
-
return Object.keys(thing).length > 0 ? "Object.assign(Object.create(null)," + obj + ")" : "Object.create(null)";
|
|
117
|
-
}
|
|
118
|
-
return obj;
|
|
224
|
+
continue;
|
|
119
225
|
}
|
|
226
|
+
result += str.slice(lastPos, i) + replacement;
|
|
227
|
+
lastPos = i + 1;
|
|
120
228
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
var params_1 = [];
|
|
124
|
-
var statements_1 = [];
|
|
125
|
-
var values_1 = [];
|
|
126
|
-
names.forEach(function (name, thing) {
|
|
127
|
-
params_1.push(name);
|
|
128
|
-
if (isPrimitive(thing)) {
|
|
129
|
-
values_1.push(stringifyPrimitive(thing));
|
|
130
|
-
return;
|
|
131
|
-
}
|
|
132
|
-
var type = getType(thing);
|
|
133
|
-
switch (type) {
|
|
134
|
-
case 'Number':
|
|
135
|
-
case 'String':
|
|
136
|
-
case 'Boolean':
|
|
137
|
-
values_1.push("Object(" + stringify(thing.valueOf()) + ")");
|
|
138
|
-
break;
|
|
139
|
-
case 'RegExp':
|
|
140
|
-
values_1.push(thing.toString());
|
|
141
|
-
break;
|
|
142
|
-
case 'Date':
|
|
143
|
-
values_1.push("new Date(" + thing.getTime() + ")");
|
|
144
|
-
break;
|
|
145
|
-
case 'Array':
|
|
146
|
-
values_1.push("Array(" + thing.length + ")");
|
|
147
|
-
thing.forEach(function (v, i) {
|
|
148
|
-
statements_1.push(name + "[" + i + "]=" + stringify(v));
|
|
149
|
-
});
|
|
150
|
-
break;
|
|
151
|
-
case 'Set':
|
|
152
|
-
values_1.push("new Set");
|
|
153
|
-
statements_1.push(name + "." + Array.from(thing).map(function (v) {
|
|
154
|
-
return "add(" + stringify(v) + ")";
|
|
155
|
-
}).join('.'));
|
|
156
|
-
break;
|
|
157
|
-
case 'Map':
|
|
158
|
-
values_1.push("new Map");
|
|
159
|
-
statements_1.push(name + "." + Array.from(thing).map(function (_a) {
|
|
160
|
-
var k = _a[0],
|
|
161
|
-
v = _a[1];
|
|
162
|
-
return "set(" + stringify(k) + ", " + stringify(v) + ")";
|
|
163
|
-
}).join('.'));
|
|
164
|
-
break;
|
|
165
|
-
default:
|
|
166
|
-
values_1.push(Object.getPrototypeOf(thing) === null ? 'Object.create(null)' : '{}');
|
|
167
|
-
Object.keys(thing).forEach(function (key) {
|
|
168
|
-
statements_1.push("" + name + safeProp(key) + "=" + stringify(thing[key]));
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
});
|
|
172
|
-
statements_1.push("return " + str);
|
|
173
|
-
return "(function(" + params_1.join(',') + "){" + statements_1.join(';') + "}(" + values_1.join(',') + "))";
|
|
229
|
+
if (lastPos === startPos) {
|
|
230
|
+
result = str;
|
|
174
231
|
} else {
|
|
175
|
-
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
return
|
|
188
|
-
}
|
|
189
|
-
function
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
var str = String(thing);
|
|
194
|
-
if (typeof thing === 'number') return str.replace(/^(-)?0\./, '$1.');
|
|
195
|
-
return str;
|
|
196
|
-
}
|
|
197
|
-
function getType(thing) {
|
|
198
|
-
return Object.prototype.toString.call(thing).slice(8, -1);
|
|
199
|
-
}
|
|
200
|
-
function escapeUnsafeChar(c) {
|
|
201
|
-
return escaped[c] || c;
|
|
202
|
-
}
|
|
203
|
-
function escapeUnsafeChars(str) {
|
|
204
|
-
return str.replace(unsafeChars, escapeUnsafeChar);
|
|
205
|
-
}
|
|
206
|
-
function safeKey(key) {
|
|
207
|
-
return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? key : escapeUnsafeChars(JSON.stringify(key));
|
|
208
|
-
}
|
|
209
|
-
function safeProp(key) {
|
|
210
|
-
return /^[_$a-zA-Z][_$a-zA-Z0-9]*$/.test(key) ? "." + key : "[" + escapeUnsafeChars(JSON.stringify(key)) + "]";
|
|
211
|
-
}
|
|
212
|
-
function stringifyString(str) {
|
|
213
|
-
var result = '"';
|
|
214
|
-
for (var i = 0; i < str.length; i += 1) {
|
|
215
|
-
var char = str.charAt(i);
|
|
216
|
-
var code = char.charCodeAt(0);
|
|
217
|
-
if (char === '"') {
|
|
218
|
-
result += '\\"';
|
|
219
|
-
} else if (char in escaped) {
|
|
220
|
-
result += escaped[char];
|
|
221
|
-
} else if (code >= 0xd800 && code <= 0xdfff) {
|
|
222
|
-
var next = str.charCodeAt(i + 1);
|
|
223
|
-
if (code <= 0xdbff && next >= 0xdc00 && next <= 0xdfff) {
|
|
224
|
-
result += char + str[++i];
|
|
225
|
-
} else {
|
|
226
|
-
result += "\\u" + code.toString(16).toUpperCase();
|
|
227
|
-
}
|
|
228
|
-
} else {
|
|
229
|
-
result += char;
|
|
230
|
-
}
|
|
232
|
+
result += str.slice(lastPos);
|
|
233
|
+
}
|
|
234
|
+
return '"' + result + '"';
|
|
235
|
+
}
|
|
236
|
+
function insertAndGetRef(obj, pos) {
|
|
237
|
+
const ref = toRefParam(REF_COUNT++);
|
|
238
|
+
INDEX_OR_REF.set(obj, ref);
|
|
239
|
+
if (pos) {
|
|
240
|
+
BUFFER[pos - 1] += ref + "=";
|
|
241
|
+
} else {
|
|
242
|
+
BUFFER[pos] = ref + "=" + BUFFER[pos];
|
|
243
|
+
}
|
|
244
|
+
return ref;
|
|
245
|
+
}
|
|
246
|
+
function refParamsString() {
|
|
247
|
+
let result = REF_START_CHARS[0];
|
|
248
|
+
for (let i = 1; i < REF_COUNT; i++) {
|
|
249
|
+
result += "," + toRefParam(i);
|
|
231
250
|
}
|
|
232
|
-
|
|
251
|
+
REF_COUNT = 0;
|
|
233
252
|
return result;
|
|
234
253
|
}
|
|
254
|
+
function toRefParam(index) {
|
|
255
|
+
let mod = index % REF_START_CHARS_LEN;
|
|
256
|
+
let ref = REF_START_CHARS[mod];
|
|
257
|
+
index = (index - mod) / REF_START_CHARS_LEN;
|
|
258
|
+
while (index > 0) {
|
|
259
|
+
mod = index % REF_CHARS_LEN;
|
|
260
|
+
ref += REF_CHARS[mod];
|
|
261
|
+
index = (index - mod) / REF_CHARS_LEN;
|
|
262
|
+
}
|
|
263
|
+
return ref;
|
|
264
|
+
}
|
|
235
265
|
|
|
236
266
|
const REPLACE_SCRIPT = `function $df(e,t,d,l){d=document.getElementById(e),(l=document.getElementById("pl-"+e))&&l.replaceWith(...d.childNodes),d.remove(),_$HY.set(e,t)}`;
|
|
237
267
|
function renderToString(code, options = {}) {
|
|
@@ -244,7 +274,7 @@ function renderToString(code, options = {}) {
|
|
|
244
274
|
nonce: options.nonce,
|
|
245
275
|
writeResource(id, p, error) {
|
|
246
276
|
if (error) return scripts += `_$HY.set("${id}", ${serializeError(p)});`;
|
|
247
|
-
scripts += `_$HY.set("${id}", ${
|
|
277
|
+
scripts += `_$HY.set("${id}", ${stringify(p)});`;
|
|
248
278
|
}
|
|
249
279
|
};
|
|
250
280
|
let html = injectAssets(solidJs.sharedConfig.context.assets, resolveSSRNode(escape(code())));
|
|
@@ -622,9 +652,9 @@ function serializeError(error) {
|
|
|
622
652
|
fields[key] = value;
|
|
623
653
|
}
|
|
624
654
|
}
|
|
625
|
-
return `Object.assign(new Error(${
|
|
655
|
+
return `Object.assign(new Error(${stringify(error.message)}), ${stringify(fields)})`;
|
|
626
656
|
}
|
|
627
|
-
return
|
|
657
|
+
return stringify(error);
|
|
628
658
|
}
|
|
629
659
|
function waitForFragments(registry, key) {
|
|
630
660
|
for (const k of [...registry.keys()].reverse()) {
|
|
@@ -635,7 +665,7 @@ function waitForFragments(registry, key) {
|
|
|
635
665
|
}
|
|
636
666
|
return false;
|
|
637
667
|
}
|
|
638
|
-
function serializeSet(registry, key, value, serializer =
|
|
668
|
+
function serializeSet(registry, key, value, serializer = stringify) {
|
|
639
669
|
const exist = registry.get(value);
|
|
640
670
|
if (exist) return `_$HY.set("${key}", _$HY.r["${exist}"][0])`;
|
|
641
671
|
value !== null && typeof value === "object" && registry.set(value, key);
|