@solidjs/web 2.0.0-rc.15 → 2.0.0-rc.16
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/README.md +1 -1
- package/dist/server.dev.js +358 -479
- package/dist/server.js +343 -387
- package/dist/server.observe.js +343 -387
- package/dist/web.dev.js +57 -54
- package/dist/web.js +47 -49
- package/dist/web.observe.js +57 -54
- package/frames/dist/client.dev.js +610 -621
- package/frames/dist/client.js +540 -566
- package/frames/dist/client.observe.js +571 -573
- package/frames/dist/regions.js +43 -2
- package/frames/dist/server.dev.js +514 -423
- package/frames/dist/server.js +514 -370
- package/frames/dist/server.observe.js +514 -370
- package/frames/dist/wire.js +371 -6
- package/package.json +11 -11
- package/serialization/dist/decode.js +9 -7
- package/serialization/dist/serialization.js +9 -7
- package/serialization/types/serializer-decode.d.ts +2 -2
- package/server-functions/dist/client.dev.js +3 -1
- package/server-functions/dist/client.js +1 -1
- package/server-functions/dist/client.observe.js +3 -1
- package/server-functions/dist/rich-args.js +33 -1
- package/server-functions/dist/server.dev.js +127 -18
- package/server-functions/dist/server.js +127 -18
- package/server-functions/dist/server.observe.js +127 -18
- package/skills/server-components/SKILL.md +74 -185
- package/types/client.d.ts +15 -5
- package/types/frames/assets-tier.d.ts +2 -2
- package/types/frames/client.d.ts +8 -3
- package/types/frames/frame-client.d.ts +121 -157
- package/types/frames/frame-morph.d.ts +28 -0
- package/types/frames/frame-sink.d.ts +13 -9
- package/types/frames/frame-transport.d.ts +30 -1
- package/types/frames/regions-tier.d.ts +15 -0
- package/types/frames/serializer-decode.d.ts +2 -2
- package/types/frames/server.d.ts +0 -52
- package/types/frames/wire-tier.d.ts +54 -1
- package/types/index.d.ts +2 -2
- package/types/jsx.d.ts +11 -5
- package/types/observe.d.ts +14 -7
- package/types/render.d.ts +3 -1
- package/types/response.d.ts +5 -4
- package/types/serializer-decode.d.ts +2 -2
- package/types/server-functions/argument-codec.d.ts +21 -0
- package/types/server-functions/client.d.ts +14 -5
- package/types/server-functions/server.d.ts +6 -2
- package/types/server-functions/shared.d.ts +19 -0
- package/types/server-observe.d.ts +3 -2
- package/types/server.d.ts +57 -76
- package/frames/dist/bind.dev.js +0 -326
- package/frames/dist/bind.js +0 -295
- package/types/frames/bind-tier.d.ts +0 -60
package/frames/dist/wire.js
CHANGED
|
@@ -1,8 +1,269 @@
|
|
|
1
1
|
import { applyFrameResponse } from '@solidjs/web/frames';
|
|
2
|
-
import {
|
|
2
|
+
import { isEventStream, ChunkReader, LIVE_WIRE, frameAddress } from '@solidjs/web/server-functions/client';
|
|
3
|
+
import 'solid-js';
|
|
4
|
+
|
|
5
|
+
const ELEMENT_NODE$1 = 1;
|
|
6
|
+
const COMMENT_NODE$1 = 8;
|
|
7
|
+
const CLAIMED_ELEMENTS = "a[href], form[action]";
|
|
8
|
+
const claimedAttr = name => name === "href" || name === "action";
|
|
9
|
+
const SLOT_START = /^slot:(.+):start$/;
|
|
10
|
+
const SLOT_END = /^slot:(.+):end$/;
|
|
11
|
+
const slotEnd = id => `slot:${id}:end`;
|
|
12
|
+
const FRAME_ID_ATTR = "data-fid";
|
|
13
|
+
function isFrameElement(node) {
|
|
14
|
+
return node.nodeType === ELEMENT_NODE$1 && node.hasAttribute(FRAME_ID_ATTR);
|
|
15
|
+
}
|
|
16
|
+
function parseFragment(html) {
|
|
17
|
+
const template = document.createElement("template");
|
|
18
|
+
template.innerHTML = html;
|
|
19
|
+
return template.content;
|
|
20
|
+
}
|
|
21
|
+
function rangeClose(start, id) {
|
|
22
|
+
let n = start.nextSibling;
|
|
23
|
+
while (n) {
|
|
24
|
+
if (n.nodeType === COMMENT_NODE$1 && n.data === id) return n;
|
|
25
|
+
n = n.nextSibling;
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
function slotStartId(node) {
|
|
30
|
+
if (node.nodeType !== COMMENT_NODE$1) return null;
|
|
31
|
+
const m = SLOT_START.exec(node.data);
|
|
32
|
+
return m ? m[1] : null;
|
|
33
|
+
}
|
|
34
|
+
function preservesOpen(el) {
|
|
35
|
+
const t = el.tagName;
|
|
36
|
+
return t === "DETAILS" || t === "DIALOG";
|
|
37
|
+
}
|
|
38
|
+
const afterRange = (start, id) => findMarker(start, slotEnd(id))?.nextSibling;
|
|
39
|
+
function findMarker(start, end) {
|
|
40
|
+
let n = start.nextSibling;
|
|
41
|
+
while (n) {
|
|
42
|
+
if (n.nodeType === COMMENT_NODE$1 && n.data === end) return n;
|
|
43
|
+
n = n.nextSibling;
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
3
47
|
|
|
4
48
|
const FRAME_HAVE_HEADER = "X-Frame-Have";
|
|
5
49
|
const FRAME_HAVE_BUDGET = 4096;
|
|
50
|
+
const ends = msg => !!msg.r && (":complete" in msg.r || ":error" in msg.r);
|
|
51
|
+
|
|
52
|
+
const ELEMENT_NODE = 1;
|
|
53
|
+
const TEXT_NODE = 3;
|
|
54
|
+
const COMMENT_NODE = 8;
|
|
55
|
+
function morph(parent, fragment, claim, ranges) {
|
|
56
|
+
const grafts = [];
|
|
57
|
+
reconcileChildren(parent, fragment, null, null, claim, ranges, grafts);
|
|
58
|
+
if (ranges.size) graft(grafts, ranges);
|
|
59
|
+
}
|
|
60
|
+
function graft(roots, ranges) {
|
|
61
|
+
for (const root of roots) flushGrafts(root, ranges);
|
|
62
|
+
}
|
|
63
|
+
function isSlotMarker(node) {
|
|
64
|
+
if (node.nodeType !== COMMENT_NODE) return false;
|
|
65
|
+
const data = node.data;
|
|
66
|
+
return SLOT_START.test(data) || SLOT_END.test(data);
|
|
67
|
+
}
|
|
68
|
+
function compatible(a, b) {
|
|
69
|
+
if (a.nodeType !== b.nodeType) return false;
|
|
70
|
+
if (a.nodeType === ELEMENT_NODE) return a.nodeName === b.nodeName && a.getAttribute("_key") === b.getAttribute("_key");
|
|
71
|
+
return a.nodeType === TEXT_NODE || a.nodeType === COMMENT_NODE;
|
|
72
|
+
}
|
|
73
|
+
function morphAttributes(oldEl, newEl, claim) {
|
|
74
|
+
let reclaim = false;
|
|
75
|
+
let changed = false;
|
|
76
|
+
const keepOpen = preservesOpen(oldEl);
|
|
77
|
+
const oldAttrs = oldEl.attributes;
|
|
78
|
+
for (let i = oldAttrs.length - 1; i >= 0; i--) {
|
|
79
|
+
const name = oldAttrs[i].name;
|
|
80
|
+
if (keepOpen && name === "open") continue;
|
|
81
|
+
if (!newEl.hasAttribute(name)) {
|
|
82
|
+
oldEl.removeAttribute(name);
|
|
83
|
+
changed = true;
|
|
84
|
+
reclaim ||= claimedAttr(name);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const newAttrs = newEl.attributes;
|
|
88
|
+
for (let i = 0; i < newAttrs.length; i++) {
|
|
89
|
+
const attr = newAttrs[i];
|
|
90
|
+
const name = attr.name;
|
|
91
|
+
if (keepOpen && name === "open") continue;
|
|
92
|
+
if (oldEl.getAttribute(name) !== attr.value) {
|
|
93
|
+
oldEl.setAttribute(name, attr.value);
|
|
94
|
+
changed = true;
|
|
95
|
+
reclaim ||= claimedAttr(name);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
if (claim && (reclaim || changed && oldEl.matches(CLAIMED_ELEMENTS))) claim(oldEl, true);
|
|
99
|
+
}
|
|
100
|
+
function morphNode(oldNode, newNode, claim, ranges, grafts) {
|
|
101
|
+
if (oldNode.nodeType === ELEMENT_NODE) {
|
|
102
|
+
if (oldNode.hasAttribute("data-preserve")) return;
|
|
103
|
+
if (!ranges?.size && oldNode.isEqualNode(newNode)) return;
|
|
104
|
+
morphAttributes(oldNode, newNode, claim);
|
|
105
|
+
reconcileChildren(oldNode, newNode, null, null, claim, ranges, grafts);
|
|
106
|
+
} else if (oldNode.data !== newNode.data) {
|
|
107
|
+
oldNode.data = newNode.data;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function findRangeStart(from, id, bound) {
|
|
111
|
+
const target = `slot:${id}:start`;
|
|
112
|
+
let n = from;
|
|
113
|
+
while (n && n !== bound) {
|
|
114
|
+
if (n.nodeType === COMMENT_NODE && n.data === target) return n;
|
|
115
|
+
n = n.nextSibling;
|
|
116
|
+
}
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
function moveRangeBefore(parent, start, id, ref) {
|
|
120
|
+
const end = slotEnd(id);
|
|
121
|
+
let n = start;
|
|
122
|
+
while (n) {
|
|
123
|
+
const next = n.nextSibling;
|
|
124
|
+
const isEnd = n.nodeType === COMMENT_NODE && n.data === end;
|
|
125
|
+
parent.insertBefore(n, ref);
|
|
126
|
+
if (isEnd) break;
|
|
127
|
+
n = next;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function placeRange(parent, range, id, ref) {
|
|
131
|
+
if (range.nodeType === 11 ) {
|
|
132
|
+
parent.insertBefore(range, ref);
|
|
133
|
+
} else {
|
|
134
|
+
moveRangeBefore(parent, range, id, ref);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
function adoptRange(parent, start, id, ref, claim) {
|
|
138
|
+
const end = slotEnd(id);
|
|
139
|
+
let n = start;
|
|
140
|
+
let after = null;
|
|
141
|
+
while (n) {
|
|
142
|
+
const next = n.nextSibling;
|
|
143
|
+
const isEnd = n.nodeType === COMMENT_NODE && n.data === end;
|
|
144
|
+
parent.insertBefore(n, ref);
|
|
145
|
+
if (claim) claim(n);
|
|
146
|
+
if (isEnd) {
|
|
147
|
+
after = next;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
n = next;
|
|
151
|
+
}
|
|
152
|
+
return after;
|
|
153
|
+
}
|
|
154
|
+
function reconcileChildren(parent, source, boundStart = null, boundEnd = null, claim = null, ranges = null, grafts = null) {
|
|
155
|
+
let oldChild = boundStart ? boundStart.nextSibling : parent.firstChild;
|
|
156
|
+
let newChild = source.firstChild;
|
|
157
|
+
while (newChild) {
|
|
158
|
+
const nextNew = newChild.nextSibling;
|
|
159
|
+
const pid = slotStartId(newChild);
|
|
160
|
+
const old = oldChild === boundEnd ? null : oldChild;
|
|
161
|
+
if (pid !== null) {
|
|
162
|
+
if (old && slotStartId(old) === pid) {
|
|
163
|
+
oldChild = afterRange(old, pid);
|
|
164
|
+
newChild = afterRange(newChild, pid);
|
|
165
|
+
} else {
|
|
166
|
+
const displaced = ranges && ranges.get(pid);
|
|
167
|
+
const existing = displaced || findRangeStart(old, pid, boundEnd);
|
|
168
|
+
if (existing) {
|
|
169
|
+
if (ranges) ranges.delete(pid);
|
|
170
|
+
placeRange(parent, existing, pid, old ?? boundEnd);
|
|
171
|
+
newChild = afterRange(newChild, pid);
|
|
172
|
+
} else {
|
|
173
|
+
newChild = adoptRange(parent, newChild, pid, old ?? boundEnd, claim);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
if (!old) {
|
|
179
|
+
parent.insertBefore(newChild, boundEnd);
|
|
180
|
+
if (claim) claim(newChild);
|
|
181
|
+
if (grafts) grafts.push(newChild);
|
|
182
|
+
newChild = nextNew;
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
if (isSlotMarker(old)) {
|
|
186
|
+
parent.insertBefore(newChild, old);
|
|
187
|
+
if (claim) claim(newChild);
|
|
188
|
+
if (grafts) grafts.push(newChild);
|
|
189
|
+
newChild = nextNew;
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
if (compatible(old, newChild)) {
|
|
193
|
+
morphNode(old, newChild, claim, ranges, grafts);
|
|
194
|
+
oldChild = old.nextSibling;
|
|
195
|
+
newChild = nextNew;
|
|
196
|
+
continue;
|
|
197
|
+
}
|
|
198
|
+
if (old.nodeType === TEXT_NODE && newChild.nodeType !== TEXT_NODE) {
|
|
199
|
+
oldChild = old.nextSibling;
|
|
200
|
+
old.remove();
|
|
201
|
+
continue;
|
|
202
|
+
}
|
|
203
|
+
if (newChild.nodeType === 1) {
|
|
204
|
+
let ahead = old.nextSibling;
|
|
205
|
+
while (ahead && ahead !== boundEnd && !compatible(ahead, newChild)) {
|
|
206
|
+
const aheadPid = slotStartId(ahead);
|
|
207
|
+
ahead = aheadPid !== null ? afterRange(ahead, aheadPid) : ahead.nextSibling;
|
|
208
|
+
}
|
|
209
|
+
if (ahead && ahead !== boundEnd) {
|
|
210
|
+
parent.insertBefore(ahead, old);
|
|
211
|
+
morphNode(ahead, newChild, claim, ranges, grafts);
|
|
212
|
+
newChild = nextNew;
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
parent.insertBefore(newChild, old);
|
|
217
|
+
if (claim) claim(newChild);
|
|
218
|
+
if (grafts) grafts.push(newChild);
|
|
219
|
+
newChild = nextNew;
|
|
220
|
+
}
|
|
221
|
+
while (oldChild && oldChild !== boundEnd) {
|
|
222
|
+
const next = oldChild.nextSibling;
|
|
223
|
+
const pid = ranges ? slotStartId(oldChild) : null;
|
|
224
|
+
if (pid !== null && ranges.get(pid) === oldChild) {
|
|
225
|
+
const frag = document.createDocumentFragment();
|
|
226
|
+
const after = stashRange(frag, oldChild, pid);
|
|
227
|
+
ranges.set(pid, frag);
|
|
228
|
+
oldChild = after;
|
|
229
|
+
continue;
|
|
230
|
+
}
|
|
231
|
+
parent.removeChild(oldChild);
|
|
232
|
+
oldChild = next;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function flushGrafts(node, ranges) {
|
|
236
|
+
if (node.nodeType !== ELEMENT_NODE || isFrameElement(node)) return;
|
|
237
|
+
let n = node.firstChild;
|
|
238
|
+
while (n) {
|
|
239
|
+
const id = slotStartId(n);
|
|
240
|
+
if (id !== null) {
|
|
241
|
+
const next = afterRange(n, id);
|
|
242
|
+
const displaced = ranges.get(id);
|
|
243
|
+
if (displaced) {
|
|
244
|
+
ranges.delete(id);
|
|
245
|
+
placeRange(node, displaced, id, n);
|
|
246
|
+
stashRange(document.createDocumentFragment(), n, id);
|
|
247
|
+
}
|
|
248
|
+
n = next;
|
|
249
|
+
continue;
|
|
250
|
+
}
|
|
251
|
+
flushGrafts(n, ranges);
|
|
252
|
+
n = n.nextSibling;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
function stashRange(frag, start, id) {
|
|
256
|
+
const end = slotEnd(id);
|
|
257
|
+
let n = start;
|
|
258
|
+
while (n) {
|
|
259
|
+
const next = n.nextSibling;
|
|
260
|
+
const isEnd = n.nodeType === COMMENT_NODE && n.data === end;
|
|
261
|
+
frag.appendChild(n);
|
|
262
|
+
if (isEnd) return next;
|
|
263
|
+
n = next;
|
|
264
|
+
}
|
|
265
|
+
return null;
|
|
266
|
+
}
|
|
6
267
|
|
|
7
268
|
const connections = new WeakMap();
|
|
8
269
|
const connectionsOf = host => {
|
|
@@ -85,7 +346,7 @@ function connect(response, wire, address, binding, host, bump, begin) {
|
|
|
85
346
|
prepareData: host.prepareData,
|
|
86
347
|
apply(chunk) {
|
|
87
348
|
if (drained) return;
|
|
88
|
-
if (chunk.type === "start") open.set(chunk.id, chunk.version);else if (chunk
|
|
349
|
+
if (chunk.type === "start") open.set(chunk.id, chunk.version);else if (ends(chunk)) open.delete(chunk.id);
|
|
89
350
|
host.apply(chunk);
|
|
90
351
|
}
|
|
91
352
|
};
|
|
@@ -107,11 +368,12 @@ function connect(response, wire, address, binding, host, bump, begin) {
|
|
|
107
368
|
error: dead,
|
|
108
369
|
sweep: () => {
|
|
109
370
|
for (const [id, version] of open) host.apply({
|
|
110
|
-
type: "error",
|
|
111
371
|
id,
|
|
112
372
|
version,
|
|
113
|
-
|
|
114
|
-
|
|
373
|
+
r: {
|
|
374
|
+
":error": {
|
|
375
|
+
message: String(dead && dead.message)
|
|
376
|
+
}
|
|
115
377
|
}
|
|
116
378
|
});
|
|
117
379
|
},
|
|
@@ -129,5 +391,108 @@ function connect(response, wire, address, binding, host, bump, begin) {
|
|
|
129
391
|
});
|
|
130
392
|
return binding;
|
|
131
393
|
}
|
|
394
|
+
function rows(open, close, ops, parse, morph) {
|
|
395
|
+
const isRow = n => n.nodeType === 8 && n.data === "lr";
|
|
396
|
+
const starts = [];
|
|
397
|
+
for (let n = open.nextSibling; n && n !== close; n = n.nextSibling) {
|
|
398
|
+
if (isRow(n)) starts.push(n);else if (n.nodeType === 8 && /^lh:\d+$/.test(n.data)) {
|
|
399
|
+
const end = "lh:/" + n.data.slice(3);
|
|
400
|
+
while (n.nextSibling && !(n.nodeType === 8 && n.data === end)) n = n.nextSibling;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
const had = starts.length;
|
|
404
|
+
const n = ops.n;
|
|
405
|
+
let appended = 0;
|
|
406
|
+
for (const [i] of ops.r) if (i >= had) appended++;
|
|
407
|
+
if (!had || appended !== Math.max(0, n - had)) return false;
|
|
408
|
+
const fragment = parse(ops.r.map(op => "<!--lr-->" + op[1]).join(""));
|
|
409
|
+
const parsed = [];
|
|
410
|
+
for (let c = fragment.firstChild; c;) {
|
|
411
|
+
const next = c.nextSibling;
|
|
412
|
+
if (isRow(c)) parsed.push(document.createDocumentFragment());else parsed[parsed.length - 1].appendChild(c);
|
|
413
|
+
c = next;
|
|
414
|
+
}
|
|
415
|
+
if (parsed.length !== ops.r.length) return false;
|
|
416
|
+
const parent = open.parentNode;
|
|
417
|
+
if (n < had) while (starts[n].nextSibling !== close) parent.removeChild(close.previousSibling);
|
|
418
|
+
if (n < had) parent.removeChild(starts[n]);
|
|
419
|
+
ops.r.forEach(([i], k) => {
|
|
420
|
+
if (i < had) {
|
|
421
|
+
const end = i + 1 < Math.min(n, had) ? starts[i + 1] : close;
|
|
422
|
+
morph(starts[i], end, parsed[k]);
|
|
423
|
+
} else {
|
|
424
|
+
const marker = document.createComment("lr");
|
|
425
|
+
parent.insertBefore(marker, close);
|
|
426
|
+
parent.insertBefore(parsed[k], close);
|
|
427
|
+
}
|
|
428
|
+
});
|
|
429
|
+
return true;
|
|
430
|
+
}
|
|
431
|
+
function hole(f, marker, record, index) {
|
|
432
|
+
const open = target(f, "hole:" + marker, n => n.nodeType === 8 && n.data === marker);
|
|
433
|
+
if (!open) return false;
|
|
434
|
+
const close = rangeClose(open, "lh:/" + marker.slice(3));
|
|
435
|
+
if (!close) {
|
|
436
|
+
f.w && f.w(marker, open);
|
|
437
|
+
return false;
|
|
438
|
+
}
|
|
439
|
+
if (record.rows) {
|
|
440
|
+
if (f.s()[marker] !== record.base || !rows(open, close, record.rows, parseFragment, (start, end, fragment) => reconcileChildren(start.parentNode, fragment, start, end, f.c))) {
|
|
441
|
+
f.x("hole:" + marker, record);
|
|
442
|
+
return false;
|
|
443
|
+
}
|
|
444
|
+
} else {
|
|
445
|
+
if (!index.r) f.k(index.r = new Map()), index.g = [];
|
|
446
|
+
reconcileChildren(open.parentNode, parseFragment(record.value), open, close, f.c, index.r.size ? index.r : null, index.g);
|
|
447
|
+
}
|
|
448
|
+
return true;
|
|
449
|
+
}
|
|
450
|
+
function attrs(f, addr, record) {
|
|
451
|
+
const el = target(f, "attr:" + addr, n => n.nodeType === 1 && n.getAttribute("data-lha") === addr);
|
|
452
|
+
if (!el) return false;
|
|
453
|
+
const parsed = parseFragment(`<i${record.value}></i>`).firstChild;
|
|
454
|
+
const keepOpen = preservesOpen(el);
|
|
455
|
+
const current = el.attributes;
|
|
456
|
+
for (let i = current.length - 1; i >= 0; i--) {
|
|
457
|
+
const name = current[i].name;
|
|
458
|
+
if (name === "data-lha" || keepOpen && name === "open") continue;
|
|
459
|
+
if (!parsed || !parsed.hasAttribute(name)) el.removeAttribute(name);
|
|
460
|
+
}
|
|
461
|
+
if (parsed) {
|
|
462
|
+
for (let i = 0; i < parsed.attributes.length; i++) {
|
|
463
|
+
const {
|
|
464
|
+
name,
|
|
465
|
+
value
|
|
466
|
+
} = parsed.attributes[i];
|
|
467
|
+
if (keepOpen && name === "open") continue;
|
|
468
|
+
if (el.getAttribute(name) !== value) el.setAttribute(name, value);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
if (record.removed) for (const name of record.removed) {
|
|
472
|
+
if (keepOpen && name === "open") continue;
|
|
473
|
+
el.removeAttribute(name);
|
|
474
|
+
}
|
|
475
|
+
return true;
|
|
476
|
+
}
|
|
477
|
+
function target(f, key, test) {
|
|
478
|
+
let n = f.t.get(key);
|
|
479
|
+
if (n && test(n) && f.e.contains(n)) return n;
|
|
480
|
+
n = findTarget(f.e.firstChild, test);
|
|
481
|
+
n && f.t.set(key, n);
|
|
482
|
+
return n;
|
|
483
|
+
}
|
|
484
|
+
function findTarget(n, test) {
|
|
485
|
+
for (; n; n = n.nextSibling) {
|
|
486
|
+
if (n.nodeType === 1) {
|
|
487
|
+
const fid = isFrameElement(n) ? n.getAttribute(FRAME_ID_ATTR) : null;
|
|
488
|
+
if (fid === null || fid.includes(".")) {
|
|
489
|
+
if (test(n)) return n;
|
|
490
|
+
const found = findTarget(n.firstChild, test);
|
|
491
|
+
if (found) return found;
|
|
492
|
+
}
|
|
493
|
+
} else if (test(n)) return n;
|
|
494
|
+
}
|
|
495
|
+
return null;
|
|
496
|
+
}
|
|
132
497
|
|
|
133
|
-
export { cancel, connect, encodeHaveList, have, haveOf, resume };
|
|
498
|
+
export { attrs, cancel, connect, encodeHaveList, graft, have, haveOf, hole, morph, resume };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidjs/web",
|
|
3
3
|
"description": "Solid's web runtime: client rendering, hydration, SSR, and DOM-specific control flow (Portal, Dynamic).",
|
|
4
|
-
"version": "2.0.0-rc.
|
|
4
|
+
"version": "2.0.0-rc.16",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -345,14 +345,6 @@
|
|
|
345
345
|
"types": "./types/frames/assets-tier.d.ts",
|
|
346
346
|
"default": "./frames/dist/assets.js"
|
|
347
347
|
},
|
|
348
|
-
"./frames/bind": {
|
|
349
|
-
"development": {
|
|
350
|
-
"types": "./types/frames/bind-tier.d.ts",
|
|
351
|
-
"default": "./frames/dist/bind.dev.js"
|
|
352
|
-
},
|
|
353
|
-
"types": "./types/frames/bind-tier.d.ts",
|
|
354
|
-
"default": "./frames/dist/bind.js"
|
|
355
|
-
},
|
|
356
348
|
"./frames/wire": {
|
|
357
349
|
"types": "./types/frames/wire-tier.d.ts",
|
|
358
350
|
"default": "./frames/dist/wire.js"
|
|
@@ -385,12 +377,20 @@
|
|
|
385
377
|
"seroval-plugins": "1.6.7"
|
|
386
378
|
},
|
|
387
379
|
"peerDependencies": {
|
|
388
|
-
"solid-js": "^2.0.0-rc.
|
|
380
|
+
"solid-js": "^2.0.0-rc.16"
|
|
389
381
|
},
|
|
390
382
|
"devDependencies": {
|
|
391
383
|
"@codspeed/vitest-plugin": "^5.4.0",
|
|
392
384
|
"@solidjs/signals": "workspace:*",
|
|
393
385
|
"fast-check": "3.23.2",
|
|
394
386
|
"solid-js": "workspace:*"
|
|
395
|
-
}
|
|
387
|
+
},
|
|
388
|
+
"keywords": [
|
|
389
|
+
"solid",
|
|
390
|
+
"solidjs",
|
|
391
|
+
"dom",
|
|
392
|
+
"ssr",
|
|
393
|
+
"hydration",
|
|
394
|
+
"tanstack-intent"
|
|
395
|
+
]
|
|
396
396
|
}
|
|
@@ -80,14 +80,16 @@ function resolveSerializerPlugins(customPlugins) {
|
|
|
80
80
|
}
|
|
81
81
|
const jsonCodecDisabledFeatures = () => Feature.RegExp;
|
|
82
82
|
const JSON_CODEC_DEPTH_LIMIT = 64;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
const RESOLVED_PLUGINS = Symbol.for("solid.codec.resolvedPlugins");
|
|
84
|
+
function resolveCodecOptions(options = {}) {
|
|
85
|
+
const {
|
|
86
|
+
plugins,
|
|
87
|
+
disabledFeatures,
|
|
88
|
+
depthLimit,
|
|
89
|
+
serializeErrorStacks
|
|
90
|
+
} = options;
|
|
89
91
|
return {
|
|
90
|
-
plugins: resolveSerializerPlugins(plugins),
|
|
92
|
+
plugins: options[RESOLVED_PLUGINS] || resolveSerializerPlugins(plugins),
|
|
91
93
|
disabledFeatures: disabledFeatures === undefined ? jsonCodecDisabledFeatures() : disabledFeatures,
|
|
92
94
|
depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit,
|
|
93
95
|
serializeErrorStacks
|
|
@@ -80,14 +80,16 @@ function resolveSerializerPlugins(customPlugins) {
|
|
|
80
80
|
}
|
|
81
81
|
const jsonCodecDisabledFeatures = () => Feature.RegExp;
|
|
82
82
|
const JSON_CODEC_DEPTH_LIMIT = 64;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
83
|
+
const RESOLVED_PLUGINS = Symbol.for("solid.codec.resolvedPlugins");
|
|
84
|
+
function resolveCodecOptions(options = {}) {
|
|
85
|
+
const {
|
|
86
|
+
plugins,
|
|
87
|
+
disabledFeatures,
|
|
88
|
+
depthLimit,
|
|
89
|
+
serializeErrorStacks
|
|
90
|
+
} = options;
|
|
89
91
|
return {
|
|
90
|
-
plugins: resolveSerializerPlugins(plugins),
|
|
92
|
+
plugins: options[RESOLVED_PLUGINS] || resolveSerializerPlugins(plugins),
|
|
91
93
|
disabledFeatures: disabledFeatures === undefined ? jsonCodecDisabledFeatures() : disabledFeatures,
|
|
92
94
|
depthLimit: depthLimit === undefined ? JSON_CODEC_DEPTH_LIMIT : depthLimit,
|
|
93
95
|
serializeErrorStacks
|
|
@@ -223,8 +223,8 @@ export declare const DEFAULT_WEB_PLUGINS: readonly ({
|
|
|
223
223
|
* Integration-facing; may change (see the entry banner).
|
|
224
224
|
*/
|
|
225
225
|
export declare function resolveSerializerPlugins(customPlugins?: SerializerPlugin[]): SerializerPlugin[];
|
|
226
|
-
export declare function resolveCodecOptions(
|
|
227
|
-
plugins:
|
|
226
|
+
export declare function resolveCodecOptions(options?: JSONCodecOptions): {
|
|
227
|
+
plugins: any;
|
|
228
228
|
disabledFeatures: number;
|
|
229
229
|
depthLimit: number;
|
|
230
230
|
serializeErrorStacks: boolean;
|
|
@@ -965,7 +965,7 @@ async function createRequest(base, id, options, meta) {
|
|
|
965
965
|
}
|
|
966
966
|
if (observation) observation.request(base, init);
|
|
967
967
|
const send = config.fetch || fetch;
|
|
968
|
-
return send(base, init);
|
|
968
|
+
return (meta.fetch || send)(base, init, send);
|
|
969
969
|
}
|
|
970
970
|
async function initializeResponse(base, id, options, args, meta) {
|
|
971
971
|
if (args.length === 0) {
|
|
@@ -1057,6 +1057,7 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
|
|
|
1057
1057
|
...options,
|
|
1058
1058
|
[CALL_OBSERVATION]: observation
|
|
1059
1059
|
};
|
|
1060
|
+
const startedAt = handler ? performance.now() : undefined;
|
|
1060
1061
|
const response = await initializeResponse(base, id, options, args, meta);
|
|
1061
1062
|
if (observation) observation.response(response);
|
|
1062
1063
|
if (handler) {
|
|
@@ -1067,6 +1068,7 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
|
|
|
1067
1068
|
context,
|
|
1068
1069
|
retry: () => fetchServerFunction(base, id, sent, args, meta, callArgs)
|
|
1069
1070
|
};
|
|
1071
|
+
ctx.startedAt = startedAt;
|
|
1070
1072
|
if (options[LIVE_WIRE]) ctx[LIVE_WIRE] = options[LIVE_WIRE];
|
|
1071
1073
|
const handled = handler.handle(response, ctx);
|
|
1072
1074
|
if (handled !== undefined) return handled;
|
|
@@ -849,7 +849,7 @@ async function createRequest(base, id, options, meta) {
|
|
|
849
849
|
init = prepared || init;
|
|
850
850
|
}
|
|
851
851
|
const send = config.fetch || fetch;
|
|
852
|
-
return send(base, init);
|
|
852
|
+
return (meta.fetch || send)(base, init, send);
|
|
853
853
|
}
|
|
854
854
|
async function initializeResponse(base, id, options, args, meta) {
|
|
855
855
|
if (args.length === 0) {
|
|
@@ -965,7 +965,7 @@ async function createRequest(base, id, options, meta) {
|
|
|
965
965
|
}
|
|
966
966
|
if (observation) observation.request(base, init);
|
|
967
967
|
const send = config.fetch || fetch;
|
|
968
|
-
return send(base, init);
|
|
968
|
+
return (meta.fetch || send)(base, init, send);
|
|
969
969
|
}
|
|
970
970
|
async function initializeResponse(base, id, options, args, meta) {
|
|
971
971
|
if (args.length === 0) {
|
|
@@ -1057,6 +1057,7 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
|
|
|
1057
1057
|
...options,
|
|
1058
1058
|
[CALL_OBSERVATION]: observation
|
|
1059
1059
|
};
|
|
1060
|
+
const startedAt = handler ? performance.now() : undefined;
|
|
1060
1061
|
const response = await initializeResponse(base, id, options, args, meta);
|
|
1061
1062
|
if (observation) observation.response(response);
|
|
1062
1063
|
if (handler) {
|
|
@@ -1067,6 +1068,7 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
|
|
|
1067
1068
|
context,
|
|
1068
1069
|
retry: () => fetchServerFunction(base, id, sent, args, meta, callArgs)
|
|
1069
1070
|
};
|
|
1071
|
+
ctx.startedAt = startedAt;
|
|
1070
1072
|
if (options[LIVE_WIRE]) ctx[LIVE_WIRE] = options[LIVE_WIRE];
|
|
1071
1073
|
const handled = handler.handle(response, ctx);
|
|
1072
1074
|
if (handled !== undefined) return handled;
|
|
@@ -1,8 +1,40 @@
|
|
|
1
1
|
import { configureServerFunctionsClient, serializeString, getServerFunctionsCodec } from '@solidjs/web/server-functions/client';
|
|
2
2
|
|
|
3
|
+
const REFUSED_ARGUMENT = Symbol("solid.serverFunction.refusedArgument");
|
|
4
|
+
function refusedArgumentError(name = "Response or Request") {
|
|
5
|
+
const error = new TypeError(`Server function arguments cannot carry Response or Request values (got a ${name}). ` + "Pass the data it holds — its body, headers or url — instead.");
|
|
6
|
+
error[REFUSED_ARGUMENT] = true;
|
|
7
|
+
return error;
|
|
8
|
+
}
|
|
9
|
+
function encodeRefusal(name) {
|
|
10
|
+
const refuse = () => {
|
|
11
|
+
throw refusedArgumentError(name);
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
tag: `seroval-plugins/web/${name}`,
|
|
15
|
+
test: value => typeof globalThis[name] === "function" && value instanceof globalThis[name],
|
|
16
|
+
parse: {
|
|
17
|
+
sync: refuse,
|
|
18
|
+
async: refuse,
|
|
19
|
+
stream: refuse
|
|
20
|
+
},
|
|
21
|
+
serialize: refuse,
|
|
22
|
+
deserialize: refuse
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
let encodeRefusals;
|
|
26
|
+
function argumentEncodeCodec(codec) {
|
|
27
|
+
if (!encodeRefusals) encodeRefusals = [encodeRefusal("Response"), encodeRefusal("Request")];
|
|
28
|
+
const refusals = encodeRefusals;
|
|
29
|
+
return {
|
|
30
|
+
...codec,
|
|
31
|
+
plugins: codec && codec.plugins ? [...refusals, ...codec.plugins] : refusals
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
3
35
|
function enableRichArguments() {
|
|
4
36
|
configureServerFunctionsClient({
|
|
5
|
-
serializeArgs: args => serializeString(args, getServerFunctionsCodec())
|
|
37
|
+
serializeArgs: args => serializeString(args, argumentEncodeCodec(getServerFunctionsCodec()))
|
|
6
38
|
});
|
|
7
39
|
}
|
|
8
40
|
|