@solidjs/web 2.0.0-rc.2 → 2.0.0-rc.21

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.
Files changed (124) hide show
  1. package/README.md +1 -1
  2. package/dist/server.dev.js +5165 -0
  3. package/dist/server.js +1876 -374
  4. package/dist/{server.cjs → server.observe.js} +2070 -577
  5. package/dist/{dev.cjs → web.dev.js} +955 -567
  6. package/dist/web.js +646 -350
  7. package/dist/{dev.js → web.observe.js} +699 -421
  8. package/frames/dist/assets.js +92 -0
  9. package/frames/dist/client.dev.js +1296 -1198
  10. package/frames/dist/client.js +1128 -1191
  11. package/frames/dist/client.observe.js +2041 -0
  12. package/frames/dist/regions.js +171 -0
  13. package/frames/dist/server.dev.js +2545 -0
  14. package/frames/dist/server.js +1683 -3004
  15. package/frames/dist/server.observe.js +2544 -0
  16. package/frames/dist/trace.js +45 -0
  17. package/frames/dist/wire.js +594 -0
  18. package/frames/package.json +2 -25
  19. package/package.json +244 -256
  20. package/performance-tracks/dist/performance-tracks.dev.js +679 -0
  21. package/performance-tracks/dist/performance-tracks.js +6 -0
  22. package/performance-tracks/dist/performance-tracks.observe.js +667 -0
  23. package/performance-tracks/package.json +7 -0
  24. package/performance-tracks/types/index.d.ts +69 -0
  25. package/serialization/decode/package.json +2 -15
  26. package/serialization/dist/decode.js +121 -25
  27. package/serialization/dist/serialization.js +282 -88
  28. package/serialization/package.json +2 -15
  29. package/serialization/types/index.d.ts +115 -153
  30. package/serialization/types/serializer-decode.d.ts +173 -114
  31. package/serialization/types/serializer.d.ts +144 -0
  32. package/server-functions/dist/client.dev.js +1462 -0
  33. package/server-functions/dist/client.js +667 -165
  34. package/server-functions/dist/client.observe.js +1441 -0
  35. package/server-functions/dist/rich-args.js +102 -1
  36. package/server-functions/dist/server.dev.js +2802 -299
  37. package/server-functions/dist/server.js +2724 -314
  38. package/server-functions/dist/server.observe.js +3680 -0
  39. package/server-functions/package.json +2 -35
  40. package/server-functions/rich-args/package.json +2 -15
  41. package/skills/server-components/SKILL.md +117 -0
  42. package/storage/package.json +2 -15
  43. package/types/client.d.ts +342 -288
  44. package/types/constants.d.ts +22 -0
  45. package/types/cookies.d.ts +32 -84
  46. package/types/diagnostics.d.ts +80 -0
  47. package/types/frames/assets-tier.d.ts +78 -0
  48. package/types/frames/client.d.ts +40 -1
  49. package/types/frames/frame-client.d.ts +443 -280
  50. package/types/frames/frame-container-plugin.d.ts +64 -0
  51. package/types/frames/frame-morph.d.ts +29 -0
  52. package/types/frames/frame-sink.d.ts +141 -161
  53. package/types/frames/frame-transport.d.ts +263 -184
  54. package/types/frames/regions-tier.d.ts +60 -0
  55. package/types/frames/serializer-decode.d.ts +241 -0
  56. package/types/frames/serializer.d.ts +115 -153
  57. package/types/frames/server.d.ts +2 -2
  58. package/types/frames/trace-tier.d.ts +2 -0
  59. package/types/frames/tree-rewrite.d.ts +39 -0
  60. package/types/frames/wire-tier.d.ts +169 -0
  61. package/types/head.d.ts +20 -0
  62. package/types/index.d.ts +98 -81
  63. package/types/index.server.d.ts +159 -0
  64. package/types/jsx.d.ts +49 -44
  65. package/types/observe.d.ts +535 -0
  66. package/types/reconcile.d.ts +1 -0
  67. package/types/render.d.ts +11 -0
  68. package/types/request-error-hook.d.ts +5 -0
  69. package/types/response.d.ts +95 -147
  70. package/types/serializer-decode.d.ts +173 -114
  71. package/types/serializer.d.ts +115 -153
  72. package/types/server-functions/argument-codec.d.ts +30 -0
  73. package/types/server-functions/client.d.ts +237 -223
  74. package/types/server-functions/flash.d.ts +28 -30
  75. package/types/server-functions/registry.d.ts +105 -0
  76. package/types/server-functions/rich-args.d.ts +1 -10
  77. package/types/server-functions/server.d.ts +538 -531
  78. package/types/server-functions/shared.d.ts +398 -425
  79. package/types/server-functions/uploads.d.ts +53 -0
  80. package/types/server-mock.d.ts +154 -20
  81. package/types/server-observe.d.ts +86 -0
  82. package/types/server.d.ts +601 -422
  83. package/types/trace.d.ts +127 -0
  84. package/LICENSE +0 -21
  85. package/dist/web.cjs +0 -2033
  86. package/frames/dist/client.cjs +0 -2002
  87. package/frames/dist/client.dev.cjs +0 -2022
  88. package/frames/dist/server.cjs +0 -3877
  89. package/serialization/dist/decode.cjs +0 -139
  90. package/serialization/dist/serialization.cjs +0 -261
  91. package/serialization/types-cjs/index.d.cts +0 -182
  92. package/serialization/types-cjs/package.json +0 -3
  93. package/serialization/types-cjs/serializer-decode.d.cts +0 -182
  94. package/server-functions/dist/client.cjs +0 -834
  95. package/server-functions/dist/rich-args.cjs +0 -11
  96. package/server-functions/dist/server.cjs +0 -1242
  97. package/server-functions/dist/server.dev.cjs +0 -1242
  98. package/storage/dist/storage.cjs +0 -12
  99. package/storage/types-cjs/index.d.cts +0 -28
  100. package/storage/types-cjs/package.json +0 -3
  101. package/types/core.d.ts +0 -9
  102. package/types-cjs/client.d.cts +0 -337
  103. package/types-cjs/cookies.d.cts +0 -93
  104. package/types-cjs/core.d.cts +0 -9
  105. package/types-cjs/frames/client.d.cts +0 -36
  106. package/types-cjs/frames/frame-client.d.cts +0 -356
  107. package/types-cjs/frames/frame-sink.d.cts +0 -194
  108. package/types-cjs/frames/frame-transport.d.cts +0 -222
  109. package/types-cjs/frames/serializer.d.cts +0 -182
  110. package/types-cjs/frames/server.d.cts +0 -52
  111. package/types-cjs/index.d.cts +0 -244
  112. package/types-cjs/jsx-properties.d.cts +0 -93
  113. package/types-cjs/jsx.d.cts +0 -4159
  114. package/types-cjs/package.json +0 -3
  115. package/types-cjs/response.d.cts +0 -174
  116. package/types-cjs/serializer-decode.d.cts +0 -182
  117. package/types-cjs/serializer.d.cts +0 -182
  118. package/types-cjs/server-functions/client.d.cts +0 -262
  119. package/types-cjs/server-functions/flash.d.cts +0 -38
  120. package/types-cjs/server-functions/rich-args.d.cts +0 -10
  121. package/types-cjs/server-functions/server.d.cts +0 -681
  122. package/types-cjs/server-functions/shared.d.cts +0 -523
  123. package/types-cjs/server-mock.d.cts +0 -286
  124. package/types-cjs/server.d.cts +0 -544
@@ -0,0 +1,45 @@
1
+ import { materializeContainerTrace } from 'solid-js/internal/container-trace';
2
+ import { getFrameHost } from '@solidjs/web/frames';
3
+
4
+ const STATE = Symbol.for("solid.container-trace-state");
5
+ const state = globalThis[STATE] || (globalThis[STATE] = {
6
+ materialized: new WeakMap(),
7
+ materializedValues: new WeakSet()
8
+ });
9
+ function setContainerTraceMaterializer(fn) {
10
+ state.materializeTrace = fn;
11
+ }
12
+ function isSerovalStream(value) {
13
+ return value.__SEROVAL_STREAM__ === true || typeof value.on === "function" && typeof value[Symbol.asyncIterator] !== "function";
14
+ }
15
+ function materialize(marker, claiming) {
16
+ let value = state.materialized.get(marker.$tr);
17
+ if (value === undefined) {
18
+ value = state.materializeTrace(marker, claiming);
19
+ state.materialized.set(marker.$tr, value);
20
+ if (value !== null && typeof value === "object") state.materializedValues.add(value);
21
+ }
22
+ return value;
23
+ }
24
+ function isContainerTraceMarker(value) {
25
+ if (value == null || typeof value !== "object" || value.$tr == null) return false;
26
+ const tr = value.$tr;
27
+ return isSerovalStream(tr) || typeof tr[Symbol.asyncIterator] === "function";
28
+ }
29
+ function reviveContainerTraces(value, claiming) {
30
+ if (!state.materializeTrace || value == null || typeof value !== "object") return value;
31
+ if (isContainerTraceMarker(value)) return materialize(value, claiming);
32
+ if (Array.isArray(value)) {
33
+ for (let i = 0; i < value.length; i++) value[i] = reviveContainerTraces(value[i], claiming);
34
+ } else if (Object.getPrototypeOf(value) === Object.prototype) {
35
+ for (const key of Object.keys(value)) value[key] = reviveContainerTraces(value[key], claiming);
36
+ }
37
+ return value;
38
+ }
39
+
40
+ function install() {
41
+ setContainerTraceMaterializer(materializeContainerTrace);
42
+ getFrameHost().revive = reviveContainerTraces;
43
+ }
44
+
45
+ export { install };
@@ -0,0 +1,594 @@
1
+ import { applyFrameResponse } from '@solidjs/web/frames';
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
+ }
47
+
48
+ const FRAME_HAVE_HEADER = "X-Frame-Have";
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
+ }
267
+
268
+ const connections = new WeakMap();
269
+ const connectionsOf = host => {
270
+ let map = connections.get(host);
271
+ if (!map) connections.set(host, map = new Map());
272
+ return map;
273
+ };
274
+ const ledgers = new WeakMap();
275
+ function have(frame, key, record) {
276
+ if (key === "") {
277
+ ledgers.set(frame, record.digest === undefined ? undefined : {
278
+ "": record.digest,
279
+ ...record.holes
280
+ });
281
+ return;
282
+ }
283
+ const ledger = ledgers.get(frame);
284
+ if (!ledger || !record || record.digest === undefined) return;
285
+ ledger[key] = record.digest;
286
+ if (record.holes) Object.assign(ledger, record.holes);
287
+ }
288
+ function haveOf(frame) {
289
+ return ledgers.get(frame);
290
+ }
291
+ function encodeHaveList(have) {
292
+ let out = "";
293
+ for (const key in have) {
294
+ const digest = have[key];
295
+ if (typeof digest !== "string") continue;
296
+ out += (out ? "," : "") + key + "=" + digest;
297
+ if (out.length > FRAME_HAVE_BUDGET) return undefined;
298
+ }
299
+ return out || undefined;
300
+ }
301
+ function resume(host, info, versions) {
302
+ const address = frameAddress(info.id, info.args);
303
+ const version = versions.get(address);
304
+ const frame = host.get(address);
305
+ const list = frame && ledgers.get(frame);
306
+ if (version === undefined && !list) return undefined;
307
+ const encoded = list && encodeHaveList(list);
308
+ return {
309
+ position: String(version || 0),
310
+ headers: encoded ? {
311
+ [FRAME_HAVE_HEADER]: encoded
312
+ } : undefined
313
+ };
314
+ }
315
+ function cancel(host, address) {
316
+ const map = connections.get(host);
317
+ const connection = map && map.get(address);
318
+ if (connection) {
319
+ map.delete(address);
320
+ connection.cancel(new Error("Superseded by a newer response for the address."));
321
+ }
322
+ }
323
+ function connect(response, wire, address, binding, host, bump, begin) {
324
+ const connection = wire.connection;
325
+ const map = connectionsOf(host);
326
+ const current = map.get(address);
327
+ if (current && !current.done) {
328
+ connection.ended = current.ended;
329
+ const body = response.body;
330
+ if (body) body.cancel().catch(() => {});
331
+ return binding;
332
+ }
333
+ const version = bump(address);
334
+ begin(address, version);
335
+ const inner = isEventStream(response) ? wire.open(response.body) : new ChunkReader(response.body);
336
+ let drained = false;
337
+ let cancelled;
338
+ const reader = {
339
+ next: () => inner.next().then(result => {
340
+ if (result.done) drained = true;
341
+ return result;
342
+ })
343
+ };
344
+ const open = new Map();
345
+ const target = {
346
+ prepareData: host.prepareData,
347
+ apply(chunk) {
348
+ if (drained) return;
349
+ if (chunk.type === "start") open.set(chunk.id, chunk.version);else if (ends(chunk)) open.delete(chunk.id);
350
+ host.apply(chunk);
351
+ }
352
+ };
353
+ let resolveEnd;
354
+ connection.ended = new Promise(resolve => resolveEnd = resolve);
355
+ connection.cancel = reason => {
356
+ if (cancelled !== undefined) return;
357
+ cancelled = reason;
358
+ try {
359
+ const r = inner.cancel && inner.cancel(reason);
360
+ if (r && typeof r.then === "function") r.then(undefined, () => {});
361
+ } catch {}
362
+ };
363
+ const end = error => {
364
+ const dead = error || cancelled || new Error("Frame stream ended before the frame completed.");
365
+ connection.done = true;
366
+ resolveEnd({
367
+ open: open.size,
368
+ error: dead,
369
+ sweep: () => {
370
+ for (const [id, version] of open) host.apply({
371
+ id,
372
+ version,
373
+ r: {
374
+ ":error": {
375
+ message: String(dead && dead.message)
376
+ }
377
+ }
378
+ });
379
+ },
380
+ close: () => {}
381
+ });
382
+ };
383
+ applyFrameResponse(response, target, {
384
+ as: address,
385
+ version,
386
+ [LIVE_WIRE]: reader
387
+ }).then(() => end(), end);
388
+ map.set(address, connection);
389
+ connection.ended.then(() => {
390
+ if (map.get(address) === connection) map.delete(address);
391
+ });
392
+ return binding;
393
+ }
394
+ function rows(open, close, ops, parse, morph, claim) {
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 rowEnd = i => i + 1 < Math.min(n, had) ? starts[i + 1] : close;
409
+ const patched = [];
410
+ let html = "";
411
+ let whole = 0;
412
+ for (const op of ops.r) {
413
+ if (typeof op[1] === "string") {
414
+ html += "<!--lr-->" + op[1];
415
+ whole++;
416
+ patched.push(null);
417
+ continue;
418
+ }
419
+ if (op[0] >= had) return false;
420
+ const els = rowElements(starts[op[0]], rowEnd(op[0]), op[2]);
421
+ if (!els) return false;
422
+ for (const edit of op[1]) if (edit[0] >= els.length) return false;
423
+ patched.push(els);
424
+ }
425
+ const parsed = [];
426
+ if (whole) {
427
+ const fragment = parse(html);
428
+ for (let c = fragment.firstChild; c;) {
429
+ const next = c.nextSibling;
430
+ if (isRow(c)) parsed.push(document.createDocumentFragment());else parsed[parsed.length - 1].appendChild(c);
431
+ c = next;
432
+ }
433
+ if (parsed.length !== whole) return false;
434
+ }
435
+ const parent = open.parentNode;
436
+ if (n < had) while (starts[n].nextSibling !== close) parent.removeChild(close.previousSibling);
437
+ if (n < had) parent.removeChild(starts[n]);
438
+ let k = 0;
439
+ ops.r.forEach((op, j) => {
440
+ const i = op[0];
441
+ const els = patched[j];
442
+ if (els) return patchRow(starts[i], rowEnd(i), els, op[1], claim);
443
+ const fragment = parsed[k++];
444
+ if (i < had) morph(starts[i], rowEnd(i), fragment);else {
445
+ const marker = document.createComment("lr");
446
+ parent.insertBefore(marker, close);
447
+ parent.insertBefore(fragment, close);
448
+ }
449
+ });
450
+ return true;
451
+ }
452
+ function rowElements(start, end, shape) {
453
+ const els = [];
454
+ let h = 0x811c9dc5;
455
+ const walk = (n, stop, parent) => {
456
+ for (; n && n !== stop; n = n.nextSibling) {
457
+ if (n.nodeType === 8 && /^lh:/.test(n.data)) return false;
458
+ if (n.nodeType !== 1) continue;
459
+ const el = els.length;
460
+ if (shape !== undefined) {
461
+ const tag = n.localName;
462
+ for (let i = 0; i < tag.length; i++) h = Math.imul(h ^ (tag.charCodeAt(i) | 32), 16777619);
463
+ h = Math.imul(h ^ parent + 2, 16777619);
464
+ }
465
+ els.push(n);
466
+ if (!walk(n.firstChild, null, el)) return false;
467
+ }
468
+ return true;
469
+ };
470
+ if (!walk(start.nextSibling, end, -1)) return null;
471
+ if (shape !== undefined && h >>> 0 !== shape) {
472
+ console.error("A live row's markup doesn't parse to the elements the server rendered (invalid HTML nesting?); the row was re-sent whole.", start.nextSibling);
473
+ return null;
474
+ }
475
+ return els;
476
+ }
477
+ const ATTR = /\s([^\s=/>"']+)(?:="([^"]*)")?/g;
478
+ const ATTR_ENTITY = /&(?:amp|lt|gt|quot|#39);/g;
479
+ const ATTR_ENTITIES = {
480
+ "&amp;": "&",
481
+ "&lt;": "<",
482
+ "&gt;": ">",
483
+ "&quot;": '"',
484
+ "&#39;": "'"
485
+ };
486
+ function attrArea(text) {
487
+ if (/=[^"]/.test(text) || text.replace(ATTR_ENTITY, "").includes("&")) return parseFragment(`<i${text}></i>`).firstChild;
488
+ const attributes = [];
489
+ const names = new Set();
490
+ for (const m of text.matchAll(ATTR)) {
491
+ const value = m[2] === undefined ? "" : m[2].replace(ATTR_ENTITY, e => ATTR_ENTITIES[e]);
492
+ const name = m[1].toLowerCase();
493
+ attributes.push({
494
+ name,
495
+ value
496
+ });
497
+ names.add(name);
498
+ }
499
+ return {
500
+ attributes,
501
+ hasAttribute: name => names.has(name)
502
+ };
503
+ }
504
+ function patchRow(start, end, els, patch, claim) {
505
+ for (const op of patch) {
506
+ const el = op[0] < 0 ? null : els[op[0]];
507
+ if (el && el.closest("[data-preserve]")) continue;
508
+ if (op.length === 2) {
509
+ morphAttributes(el, attrArea(op[1]), claim);
510
+ continue;
511
+ }
512
+ let seen = 0;
513
+ let at = el ? el.firstChild : start.nextSibling;
514
+ const stop = el ? null : end;
515
+ let text = null;
516
+ for (; at && at !== stop; at = at.nextSibling) {
517
+ if (at.nodeType === 3) {
518
+ if (seen === op[1]) {
519
+ text = at;
520
+ break;
521
+ }
522
+ } else if (seen++ === op[1]) break;
523
+ }
524
+ if (text) text.data = op[2];else if (op[2]) (el || start.parentNode).insertBefore(document.createTextNode(op[2]), at);
525
+ }
526
+ }
527
+ function hole(f, marker, record, index) {
528
+ const open = target(f, "hole:" + marker, n => n.nodeType === 8 && n.data === marker);
529
+ if (!open) return false;
530
+ const close = rangeClose(open, "lh:/" + marker.slice(3));
531
+ if (!close) {
532
+ f.w && f.w(marker, open);
533
+ return false;
534
+ }
535
+ if (record.rows) {
536
+ if (f.s()[marker] !== record.base || !rows(open, close, record.rows, parseFragment, (start, end, fragment) => reconcileChildren(start.parentNode, fragment, start, end, f.c), f.c)) {
537
+ f.x("hole:" + marker, record);
538
+ return false;
539
+ }
540
+ } else {
541
+ if (!index.r) f.k(index.r = new Map()), index.g = [];
542
+ reconcileChildren(open.parentNode, parseFragment(record.value), open, close, f.c, index.r.size ? index.r : null, index.g);
543
+ }
544
+ return true;
545
+ }
546
+ function attrs(f, addr, record) {
547
+ const el = target(f, "attr:" + addr, n => n.nodeType === 1 && n.getAttribute("data-lha") === addr);
548
+ if (!el) return false;
549
+ const parsed = parseFragment(`<i${record.value}></i>`).firstChild;
550
+ const keepOpen = preservesOpen(el);
551
+ const current = el.attributes;
552
+ for (let i = current.length - 1; i >= 0; i--) {
553
+ const name = current[i].name;
554
+ if (name === "data-lha" || keepOpen && name === "open") continue;
555
+ if (!parsed || !parsed.hasAttribute(name)) el.removeAttribute(name);
556
+ }
557
+ if (parsed) {
558
+ for (let i = 0; i < parsed.attributes.length; i++) {
559
+ const {
560
+ name,
561
+ value
562
+ } = parsed.attributes[i];
563
+ if (keepOpen && name === "open") continue;
564
+ if (el.getAttribute(name) !== value) el.setAttribute(name, value);
565
+ }
566
+ }
567
+ if (record.removed) for (const name of record.removed) {
568
+ if (keepOpen && name === "open") continue;
569
+ el.removeAttribute(name);
570
+ }
571
+ return true;
572
+ }
573
+ function target(f, key, test) {
574
+ let n = f.t.get(key);
575
+ if (n && test(n) && f.e.contains(n)) return n;
576
+ n = findTarget(f.e.firstChild, test);
577
+ n && f.t.set(key, n);
578
+ return n;
579
+ }
580
+ function findTarget(n, test) {
581
+ for (; n; n = n.nextSibling) {
582
+ if (n.nodeType === 1) {
583
+ const fid = isFrameElement(n) ? n.getAttribute(FRAME_ID_ATTR) : null;
584
+ if (fid === null || fid.includes(".")) {
585
+ if (test(n)) return n;
586
+ const found = findTarget(n.firstChild, test);
587
+ if (found) return found;
588
+ }
589
+ } else if (test(n)) return n;
590
+ }
591
+ return null;
592
+ }
593
+
594
+ export { attrs, cancel, connect, encodeHaveList, graft, have, haveOf, hole, morph, resume };
@@ -1,30 +1,7 @@
1
1
  {
2
- "name": "@solidjs/web/frames",
3
- "main": "./dist/server.cjs",
2
+ "main": "./dist/server.js",
4
3
  "module": "./dist/server.js",
5
4
  "types": "../types/frames/server.d.ts",
6
5
  "type": "module",
7
- "sideEffects": false,
8
- "exports": {
9
- ".": {
10
- "browser": {
11
- "import": {
12
- "types": "../types/frames/client.d.ts",
13
- "default": "./dist/client.js"
14
- },
15
- "require": {
16
- "types": "../types-cjs/frames/client.d.cts",
17
- "default": "./dist/client.cjs"
18
- }
19
- },
20
- "import": {
21
- "types": "../types/frames/server.d.ts",
22
- "default": "./dist/server.js"
23
- },
24
- "require": {
25
- "types": "../types-cjs/frames/server.d.cts",
26
- "default": "./dist/server.cjs"
27
- }
28
- }
29
- }
6
+ "sideEffects": false
30
7
  }