@solidjs/web 2.0.0-rc.15 → 2.0.0-rc.17

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 (55) hide show
  1. package/README.md +1 -1
  2. package/dist/server.dev.js +361 -483
  3. package/dist/server.js +346 -391
  4. package/dist/server.observe.js +346 -391
  5. package/dist/web.dev.js +110 -55
  6. package/dist/web.js +51 -50
  7. package/dist/web.observe.js +61 -55
  8. package/frames/dist/client.dev.js +610 -621
  9. package/frames/dist/client.js +540 -566
  10. package/frames/dist/client.observe.js +571 -573
  11. package/frames/dist/regions.js +43 -2
  12. package/frames/dist/server.dev.js +793 -424
  13. package/frames/dist/server.js +792 -371
  14. package/frames/dist/server.observe.js +792 -371
  15. package/frames/dist/wire.js +371 -6
  16. package/package.json +11 -11
  17. package/serialization/dist/decode.js +9 -7
  18. package/serialization/dist/serialization.js +9 -7
  19. package/serialization/types/serializer-decode.d.ts +2 -2
  20. package/server-functions/dist/client.dev.js +13 -22
  21. package/server-functions/dist/client.js +11 -22
  22. package/server-functions/dist/client.observe.js +13 -22
  23. package/server-functions/dist/rich-args.js +84 -1
  24. package/server-functions/dist/server.dev.js +194 -20
  25. package/server-functions/dist/server.js +194 -20
  26. package/server-functions/dist/server.observe.js +194 -20
  27. package/skills/server-components/SKILL.md +74 -185
  28. package/types/client.d.ts +27 -5
  29. package/types/diagnostics.d.ts +16 -0
  30. package/types/frames/assets-tier.d.ts +2 -2
  31. package/types/frames/client.d.ts +8 -3
  32. package/types/frames/frame-client.d.ts +121 -157
  33. package/types/frames/frame-morph.d.ts +28 -0
  34. package/types/frames/frame-sink.d.ts +13 -9
  35. package/types/frames/frame-transport.d.ts +30 -1
  36. package/types/frames/regions-tier.d.ts +15 -0
  37. package/types/frames/serializer-decode.d.ts +2 -2
  38. package/types/frames/server.d.ts +0 -52
  39. package/types/frames/wire-tier.d.ts +54 -1
  40. package/types/index.d.ts +2 -2
  41. package/types/jsx.d.ts +11 -5
  42. package/types/observe.d.ts +14 -7
  43. package/types/render.d.ts +3 -1
  44. package/types/response.d.ts +5 -4
  45. package/types/serializer-decode.d.ts +2 -2
  46. package/types/server-functions/argument-codec.d.ts +30 -0
  47. package/types/server-functions/client.d.ts +27 -9
  48. package/types/server-functions/server.d.ts +23 -2
  49. package/types/server-functions/shared.d.ts +19 -0
  50. package/types/server-functions/uploads.d.ts +50 -0
  51. package/types/server-observe.d.ts +3 -2
  52. package/types/server.d.ts +58 -77
  53. package/frames/dist/bind.dev.js +0 -326
  54. package/frames/dist/bind.js +0 -295
  55. package/types/frames/bind-tier.d.ts +0 -60
package/dist/web.dev.js CHANGED
@@ -56,8 +56,10 @@ const transparentOptions = {
56
56
  sync: true
57
57
  };
58
58
  let spreadName;
59
- function setSpreadName(name) {
59
+ let spreadLoc;
60
+ function setSpreadName(name, loc) {
60
61
  spreadName = name;
62
+ spreadLoc = loc;
61
63
  }
62
64
  const syncOptions = {
63
65
  sync: true
@@ -69,7 +71,8 @@ function tagElement(node) {
69
71
  function effect(fn, effectFn, options) {
70
72
  if (spreadName !== undefined && (options === undefined || options.name === undefined)) options = {
71
73
  ...options,
72
- name: spreadName + ".spread"
74
+ name: spreadName + ".spread",
75
+ loc: spreadLoc
73
76
  };
74
77
  const nodeOptions = options ? {
75
78
  sync: true,
@@ -98,40 +101,39 @@ function memo(fn) {
98
101
  }
99
102
 
100
103
  function reconcileArrays(parentNode, a, b, marker) {
104
+ const isLive = n => {
105
+ if (!n) return false;
106
+ const tag = n[$$SLOT];
107
+ return n.parentNode === parentNode && (!tag || tag === marker);
108
+ };
101
109
  let bLength = b.length,
102
110
  aEnd = a.length,
103
111
  bEnd = bLength,
104
112
  aStart = 0,
105
113
  bStart = 0,
106
114
  tail = a[aEnd - 1],
107
- tailTag = tail[$$SLOT],
108
- after = tail.parentNode === parentNode && (!tailTag || tailTag === marker) ? tail.nextSibling : marker || null,
115
+ after = isLive(tail) ? tail.nextSibling : marker || null,
109
116
  map = null,
110
117
  anchor,
111
118
  anchorTag;
112
- const isLive = n => {
113
- if (!n) return false;
114
- const tag = n[$$SLOT];
115
- return n.parentNode === parentNode && (!tag || tag === marker);
116
- };
117
119
  while (aStart < aEnd || bStart < bEnd) {
118
- if (a[aStart] === b[bStart] && isLive(a[aStart])) {
120
+ if (a[aStart] === b[bStart]) {
119
121
  aStart++;
120
122
  bStart++;
121
123
  continue;
122
124
  }
123
- while (a[aEnd - 1] === b[bEnd - 1] && isLive(a[aEnd - 1])) {
125
+ while (aEnd > aStart && bEnd > bStart && a[aEnd - 1] === b[bEnd - 1]) {
124
126
  aEnd--;
125
127
  bEnd--;
126
128
  }
127
129
  if (aEnd === aStart) {
128
130
  let node;
129
131
  if (bEnd < bLength) {
130
- if (bStart) {
131
- const prev = b[bStart - 1];
132
- const prevTag = prev[$$SLOT];
133
- node = prev.parentNode === parentNode && (!prevTag || prevTag === marker) ? prev.nextSibling : after;
134
- } else node = b[bEnd - bStart];
132
+ if (bStart && isLive(node = b[bStart - 1])) node = node.nextSibling;else {
133
+ let k = bEnd;
134
+ while (k < bLength && !isLive(b[k])) k++;
135
+ node = k < bLength ? b[k] : after;
136
+ }
135
137
  } else node = after;
136
138
  while (bStart < bEnd) {
137
139
  const n = b[bStart++];
@@ -141,10 +143,7 @@ function reconcileArrays(parentNode, a, b, marker) {
141
143
  } else if (bEnd === bStart) {
142
144
  while (aStart < aEnd) {
143
145
  const n = a[aStart++];
144
- if (!map || !map.has(n)) {
145
- const tag = n[$$SLOT];
146
- if (n.parentNode === parentNode && (!tag || tag === marker)) n.remove();
147
- }
146
+ if ((!map || !map.has(n)) && isLive(n)) n.remove();
148
147
  }
149
148
  } else if ((anchor = a[aStart]) === b[bEnd - 1] && b[bStart] === a[aEnd - 1] && anchor.parentNode === parentNode && (!(anchorTag = anchor[$$SLOT]) || anchorTag === marker)) {
150
149
  if (marker) {
@@ -163,6 +162,10 @@ function reconcileArrays(parentNode, a, b, marker) {
163
162
  } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
164
163
  }
165
164
  } else {
165
+ if (!isLive(a[aStart])) {
166
+ aStart++;
167
+ continue;
168
+ }
166
169
  if (!map) {
167
170
  map = new Map();
168
171
  let i = bStart;
@@ -179,31 +182,19 @@ function reconcileArrays(parentNode, a, b, marker) {
179
182
  sequence++;
180
183
  }
181
184
  if (sequence > index - bStart) {
182
- const head = a[aStart];
183
- const headTag = head[$$SLOT];
184
- const node = head.parentNode === parentNode && (!headTag || headTag === marker) ? head : after;
185
+ const node = a[aStart];
185
186
  while (bStart < index) {
186
187
  const n = b[bStart++];
187
188
  parentNode.insertBefore(n, node);
188
189
  if (marker) n[$$SLOT] = marker;
189
190
  }
190
191
  } else {
191
- const oldNode = a[aStart++];
192
192
  const newNode = b[bStart++];
193
- const oldTag = oldNode[$$SLOT];
194
- if (oldNode.parentNode === parentNode && (!oldTag || oldTag === marker)) {
195
- parentNode.replaceChild(newNode, oldNode);
196
- } else {
197
- parentNode.insertBefore(newNode, after);
198
- }
193
+ parentNode.replaceChild(newNode, a[aStart++]);
199
194
  if (marker) newNode[$$SLOT] = marker;
200
195
  }
201
196
  } else aStart++;
202
- } else {
203
- const n = a[aStart++];
204
- const nTag = n[$$SLOT];
205
- if (n.parentNode === parentNode && (!nTag || nTag === marker)) n.remove();
206
- }
197
+ } else a[aStart++].remove();
207
198
  }
208
199
  }
209
200
  }
@@ -249,6 +240,49 @@ function lowercaseEventAttribute(name, node) {
249
240
  }
250
241
  });
251
242
  }
243
+ const statefulWrites = /*#__PURE__*/new WeakMap();
244
+ function statefulRecord(node, prop) {
245
+ if (DOMWithState[node.nodeName]?.[prop] !== 1 || node.nodeName === "SELECT") return;
246
+ let records = statefulWrites.get(node);
247
+ if (!records) statefulWrites.set(node, records = {});
248
+ return records;
249
+ }
250
+ function checkStatefulWrite(node, prop, value) {
251
+ const record = statefulRecord(node, prop)?.[prop];
252
+ if (!record || record.w || value !== record.v || node[prop] === record.d) return;
253
+ record.w = 1;
254
+ const tag = node.localName;
255
+ const type = tag === "input" ? node.type : undefined;
256
+ const name = node.getAttribute("name") || undefined,
257
+ id = node.id || undefined;
258
+ let element = `<${tag}`;
259
+ if (type) element += ` type="${type}"`;
260
+ if (name) element += ` name="${name}"`;else if (id) element += ` id="${id}"`;
261
+ element += `>.${prop}`;
262
+ const handler = prop === "muted" ? "onVolumeChange" : prop === "value" ? "onInput" : "onChange";
263
+ const defaultProp = "default" + prop.charAt(0).toUpperCase() + prop.slice(1);
264
+ devCheck({
265
+ code: "UNCOMMITTED_INPUT_OVERWRITTEN",
266
+ kind: "render",
267
+ severity: "warn",
268
+ message: `[UNCOMMITTED_INPUT_OVERWRITTEN] ${element} was changed by the user, but the change was ` + `never committed to the signal bound to \`${prop}\`, and Solid is writing the bound value ` + `back over it: the user's input is lost. A compiled \`${prop}\` binding re-applies the ` + `bound value whenever its effect runs — here with the value unchanged, because another ` + `binding in the same template changed, a spread re-ran, or the source fired with an equal ` + `value — and the signal is the source of truth. Write the signal on every edit ` + `(\`${handler}={e => setValue(e.currentTarget.${prop})}\`, a draft signal you commit ` + `later), use \`${defaultProp}\` for an uncontrolled element, or write a rejected edit back ` + `explicitly (\`e.currentTarget.${prop} = next\`).`,
269
+ data: {
270
+ tag,
271
+ prop,
272
+ type,
273
+ name,
274
+ id
275
+ }
276
+ });
277
+ }
278
+ function recordStatefulWrite(node, prop, value) {
279
+ const records = statefulRecord(node, prop);
280
+ if (records) records[prop] = {
281
+ v: value,
282
+ d: node[prop],
283
+ w: records[prop]?.w
284
+ };
285
+ }
252
286
 
253
287
  const HEAD_ELIGIBLE_TAGS = new Set(["title", "meta", "link", "style", "script", "base"]);
254
288
  const HEAD_ATTR_NAME = /^[a-zA-Z_][a-zA-Z0-9_:.-]*$/;
@@ -646,11 +680,18 @@ function setProperty(node, name, value) {
646
680
  tagElement(node);
647
681
  if (isHydrating(node)) return;
648
682
  const nodeName = node.nodeName;
683
+ checkStatefulWrite(node, name, value);
649
684
  if (name === "value" && nodeName === "SELECT") writeSelectValue(node, value);else if ((name === "value" || name === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA")) {
650
685
  if (value == null && /^(checkbox|radio)$/.test(node.type)) node.removeAttribute("value");else node[name] = value ?? "";
651
686
  } else node[name] = value;
687
+ recordStatefulWrite(node, name, value);
652
688
  reclaimAttribute(node, name);
653
689
  }
690
+ function setStatefulProperty(node, name, value) {
691
+ checkStatefulWrite(node, name, value);
692
+ node[name] = value;
693
+ recordStatefulWrite(node, name, value);
694
+ }
654
695
  let claimHandlers = null;
655
696
  const claimAttributeSets = [];
656
697
  const CLAIM_SEAM = Symbol.for("solid.element-claims");
@@ -846,14 +887,15 @@ function setStyleProperty(node, name, value) {
846
887
  if (isHydrating(node)) return;
847
888
  value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
848
889
  }
849
- function spread(node, props, skipChildren, skip, name) {
890
+ function spread(node, props, skipChildren, skip, name, loc) {
850
891
  if (name !== undefined) {
851
892
  const outer = spreadName;
852
- setSpreadName(name);
893
+ const outerLoc = spreadLoc;
894
+ setSpreadName(name, loc);
853
895
  try {
854
896
  return spread(node, props, skipChildren, skip);
855
897
  } finally {
856
- setSpreadName(outer);
898
+ setSpreadName(outer, outerLoc);
857
899
  }
858
900
  }
859
901
  const prevProps = {};
@@ -1008,6 +1050,7 @@ function checkUnscopedHole(snapshot, accessor, parent) {
1008
1050
  } : {});
1009
1051
  }
1010
1052
  let hydrationRt = null;
1053
+ let selectInsert = null;
1011
1054
  function installHydrationRuntime() {
1012
1055
  hydrationRt = {
1013
1056
  claimInitial(parent, multi, initial) {
@@ -1082,7 +1125,8 @@ function isPlaceholderScaffolding(node, t) {
1082
1125
  function insert(parent, accessor, marker, initial, options) {
1083
1126
  if (spreadName !== undefined && (options === undefined || options.name === undefined)) options = {
1084
1127
  ...options,
1085
- name: spreadName + ".children"
1128
+ name: spreadName + ".children",
1129
+ loc: spreadLoc
1086
1130
  };
1087
1131
  const multi = marker !== undefined;
1088
1132
  const host = options && options.host;
@@ -1102,13 +1146,16 @@ function insert(parent, accessor, marker, initial, options) {
1102
1146
  initial = [placeholder];
1103
1147
  }
1104
1148
  let current = initial;
1105
- effect(prev => {
1149
+ let ran = false;
1150
+ effect(() => {
1106
1151
  if (hydrationRt !== null) current = hydrationRt.reclaimRegion(current, parent, marker);
1107
1152
  const devNext = unscopedHoleSnapshot(accessor, parent) ;
1108
1153
  const value = normalize(accessor(), current, multi, true);
1109
1154
  checkUnscopedHole(devNext, accessor, parent);
1155
+ const again = ran;
1156
+ ran = true;
1110
1157
  if (typeof value !== "function") return value;
1111
- const innerOptions = prev !== undefined && !(options && options.schedule) ? {
1158
+ const innerOptions = again && !(options && options.schedule) ? {
1112
1159
  ...options,
1113
1160
  schedule: true
1114
1161
  } : options;
@@ -1907,9 +1954,11 @@ function assignProp(node, prop, value, prev, skipRef, nodeName) {
1907
1954
  }
1908
1955
  } else if (hasNamespace && prop.slice(0, 5) === "prop:" || ChildProperties.has(prop) || DOMWithState[nodeName]?.[prop]) {
1909
1956
  if (hasNamespace) prop = prop.slice(5);else if (isHydrating(node)) return value;
1957
+ checkStatefulWrite(node, prop, value);
1910
1958
  if (prop === "value" && nodeName === "SELECT") writeSelectValue(node, value);else if ((prop === "value" || prop === "defaultValue") && (nodeName === "INPUT" || nodeName === "TEXTAREA")) {
1911
1959
  if (value == null && /^(checkbox|radio)$/.test(node.type)) node.removeAttribute("value");else node[prop] = value ?? "";
1912
1960
  } else node[prop] = value;
1961
+ recordStatefulWrite(node, prop, value);
1913
1962
  reclaimAttribute(node, prop);
1914
1963
  } else {
1915
1964
  const ns = hasNamespace && Namespaces[prop.split(":")[0]];
@@ -1925,14 +1974,13 @@ function eventHandler(e, container, state) {
1925
1974
  if (prev === true || prev === container || !container.contains(prev)) return;
1926
1975
  resumeNode = prev;
1927
1976
  }
1928
- const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
1929
- if (state && !owner) return;
1930
- if (owner && owner === resumeNode) return;
1931
- e[$$EVENT_OWNER] = owner || true;
1977
+ const owner = state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner;
1978
+ if (!owner) return;
1979
+ if (owner === resumeNode) return;
1980
+ e[$$EVENT_OWNER] = owner;
1932
1981
  let node = resumeNode || e.target;
1933
1982
  const key = EVENT_KEY + e.type;
1934
1983
  const oriTarget = e.target;
1935
- const boundary = owner || container || e.currentTarget;
1936
1984
  const retarget = value => Object.defineProperty(e, "target", {
1937
1985
  configurable: true,
1938
1986
  value
@@ -1949,19 +1997,19 @@ function eventHandler(e, container, state) {
1949
1997
  };
1950
1998
  const walkUpTree = () => {
1951
1999
  while (node && handleNode()) {
1952
- if (node === boundary || node.parentNode === boundary) break;
2000
+ if (node === owner || node.parentNode === owner) break;
1953
2001
  node = node._$host || node.parentNode || node.host;
1954
2002
  }
1955
2003
  };
1956
2004
  Object.defineProperty(e, "currentTarget", {
1957
2005
  configurable: true,
1958
2006
  get() {
1959
- return node || boundary || document;
2007
+ return node || owner;
1960
2008
  }
1961
2009
  });
1962
2010
  if (resumeNode) {
1963
2011
  if (resumeNode === e.target) node = resumeNode._$host || resumeNode.parentNode || resumeNode.host;
1964
- if (node && node !== boundary) walkUpTree();
2012
+ if (node && node !== owner) walkUpTree();
1965
2013
  } else if (e.composedPath) {
1966
2014
  const path = e.composedPath();
1967
2015
  if (path.length) {
@@ -1974,7 +2022,7 @@ function eventHandler(e, container, state) {
1974
2022
  walkUpTree();
1975
2023
  break;
1976
2024
  }
1977
- if (node === boundary || node.parentNode === boundary) {
2025
+ if (node === owner || node.parentNode === owner) {
1978
2026
  break;
1979
2027
  }
1980
2028
  }
@@ -1999,7 +2047,10 @@ function insertExpression(parent, value, current, marker) {
1999
2047
  return value;
2000
2048
  }
2001
2049
  if (value === current) return value;
2002
- if (hydrationRt !== null && sharedConfig.hydrating && current == null && value && [].concat(value).every(n => n?.parentNode === parent) && value.length !== 0) return value;
2050
+ if (hydrationRt !== null && sharedConfig.hydrating && value && value.length !== 0) {
2051
+ const tracked = [].concat(current ?? []);
2052
+ if ([].concat(value).every(n => (n === tracked[0] && tracked.shift(), n?.parentNode === parent)) && !tracked.length) return value;
2053
+ }
2003
2054
  const t = typeof value,
2004
2055
  multi = marker !== undefined;
2005
2056
  if (t === "string" || t === "number") {
@@ -2061,7 +2112,6 @@ function insertExpression(parent, value, current, marker) {
2061
2112
  selectInsert && selectInsert(parent);
2062
2113
  return value;
2063
2114
  }
2064
- let selectInsert;
2065
2115
  function selectChange(e) {
2066
2116
  (e = e.currentTarget || e)._$v = null;
2067
2117
  e.removeEventListener("change", selectChange, true);
@@ -2094,7 +2144,7 @@ function normalize(value, current, multi, doNotUnwrap) {
2094
2144
  });
2095
2145
  if (doNotUnwrap && typeof value === "function") return value;
2096
2146
  if (multi && !Array.isArray(value)) value = [value != null ? value : ""];
2097
- if (sharedConfig.hydrating && Array.isArray(value)) {
2147
+ if (hydrationRt !== null && sharedConfig.hydrating && Array.isArray(value)) {
2098
2148
  for (let i = 0, len = value.length; i < len; i++) {
2099
2149
  const item = value[i],
2100
2150
  prev = current && current[i],
@@ -2348,7 +2398,12 @@ function respond(value, init = {}) {
2348
2398
  }), value);
2349
2399
  }
2350
2400
  headers.set("Content-Type", "application/json");
2351
- return new ResponseEnvelope(new Response(JSON.stringify(value), {
2401
+ return new ResponseEnvelope(new Response(new ReadableStream({
2402
+ pull(controller) {
2403
+ controller.enqueue(new TextEncoder().encode(JSON.stringify(value)));
2404
+ controller.close();
2405
+ }
2406
+ }), {
2352
2407
  ...responseInit,
2353
2408
  headers
2354
2409
  }), value);
@@ -2457,4 +2512,4 @@ _moduleUrl) {
2457
2512
  function httpStatus(_code, _text) {}
2458
2513
  function httpHeader(_name, _value, _options) {}
2459
2514
 
2460
- export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clearFlashCookie, clientOnly, commitEventResponse, composeMiddleware, configureServerErrors, createRequestEvent, createResponseStub, createSSRResponse, delegateEvents, dispatchAsInteraction, dynamic, dynamicProperty, effect, escape, generateHydrationScript, getDelegatedRoot, getExpectedRedirectStatus, getFirstChild, getHydrationKey, getHydrationWriter, getNextElement, getNextMarker, getNextMatch, getNextSibling, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, hasServerLinkState, httpHeader, httpStatus, hydrate, insert, installHydrationRuntime, installServerComponentHydration, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, parseCookieHeader, readShallow, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, registerElementClaim, reload, render, renderToStream, renderToString, reportRequestFailure, resolveSSRNode, respond, runHydrationEvents, scope, serializeCookie, setAttribute, setAttributeNS, setLinkClaim, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrLinkClaim, ssrStyle, ssrStyleProperties, ssrStyleProperty, style, takeHydrationValue, template, unregisterDelegatedContainer, unregisterDelegatedRoot, useHead, waitAsset, warmAsset };
2515
+ export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clearFlashCookie, clientOnly, commitEventResponse, composeMiddleware, configureServerErrors, createRequestEvent, createResponseStub, createSSRResponse, delegateEvents, dispatchAsInteraction, dynamic, dynamicProperty, effect, escape, generateHydrationScript, getDelegatedRoot, getExpectedRedirectStatus, getFirstChild, getHydrationKey, getHydrationWriter, getNextElement, getNextMarker, getNextMatch, getNextSibling, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, hasServerLinkState, httpHeader, httpStatus, hydrate, insert, installHydrationRuntime, installServerComponentHydration, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, parseCookieHeader, readShallow, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, registerElementClaim, reload, render, renderToStream, renderToString, reportRequestFailure, resolveSSRNode, respond, runHydrationEvents, scope, serializeCookie, setAttribute, setAttributeNS, setLinkClaim, setProperty, setStatefulProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrLinkClaim, ssrStyle, ssrStyleProperties, ssrStyleProperty, style, takeHydrationValue, template, unregisterDelegatedContainer, unregisterDelegatedRoot, useHead, waitAsset, warmAsset };
package/dist/web.js CHANGED
@@ -71,40 +71,39 @@ function memo(fn) {
71
71
  }
72
72
 
73
73
  function reconcileArrays(parentNode, a, b, marker) {
74
+ const isLive = n => {
75
+ if (!n) return false;
76
+ const tag = n[$$SLOT];
77
+ return n.parentNode === parentNode && (!tag || tag === marker);
78
+ };
74
79
  let bLength = b.length,
75
80
  aEnd = a.length,
76
81
  bEnd = bLength,
77
82
  aStart = 0,
78
83
  bStart = 0,
79
84
  tail = a[aEnd - 1],
80
- tailTag = tail[$$SLOT],
81
- after = tail.parentNode === parentNode && (!tailTag || tailTag === marker) ? tail.nextSibling : marker || null,
85
+ after = isLive(tail) ? tail.nextSibling : marker || null,
82
86
  map = null,
83
87
  anchor,
84
88
  anchorTag;
85
- const isLive = n => {
86
- if (!n) return false;
87
- const tag = n[$$SLOT];
88
- return n.parentNode === parentNode && (!tag || tag === marker);
89
- };
90
89
  while (aStart < aEnd || bStart < bEnd) {
91
- if (a[aStart] === b[bStart] && isLive(a[aStart])) {
90
+ if (a[aStart] === b[bStart]) {
92
91
  aStart++;
93
92
  bStart++;
94
93
  continue;
95
94
  }
96
- while (a[aEnd - 1] === b[bEnd - 1] && isLive(a[aEnd - 1])) {
95
+ while (aEnd > aStart && bEnd > bStart && a[aEnd - 1] === b[bEnd - 1]) {
97
96
  aEnd--;
98
97
  bEnd--;
99
98
  }
100
99
  if (aEnd === aStart) {
101
100
  let node;
102
101
  if (bEnd < bLength) {
103
- if (bStart) {
104
- const prev = b[bStart - 1];
105
- const prevTag = prev[$$SLOT];
106
- node = prev.parentNode === parentNode && (!prevTag || prevTag === marker) ? prev.nextSibling : after;
107
- } else node = b[bEnd - bStart];
102
+ if (bStart && isLive(node = b[bStart - 1])) node = node.nextSibling;else {
103
+ let k = bEnd;
104
+ while (k < bLength && !isLive(b[k])) k++;
105
+ node = k < bLength ? b[k] : after;
106
+ }
108
107
  } else node = after;
109
108
  while (bStart < bEnd) {
110
109
  const n = b[bStart++];
@@ -114,10 +113,7 @@ function reconcileArrays(parentNode, a, b, marker) {
114
113
  } else if (bEnd === bStart) {
115
114
  while (aStart < aEnd) {
116
115
  const n = a[aStart++];
117
- if (!map || !map.has(n)) {
118
- const tag = n[$$SLOT];
119
- if (n.parentNode === parentNode && (!tag || tag === marker)) n.remove();
120
- }
116
+ if ((!map || !map.has(n)) && isLive(n)) n.remove();
121
117
  }
122
118
  } else if ((anchor = a[aStart]) === b[bEnd - 1] && b[bStart] === a[aEnd - 1] && anchor.parentNode === parentNode && (!(anchorTag = anchor[$$SLOT]) || anchorTag === marker)) {
123
119
  if (marker) {
@@ -136,6 +132,10 @@ function reconcileArrays(parentNode, a, b, marker) {
136
132
  } while (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]);
137
133
  }
138
134
  } else {
135
+ if (!isLive(a[aStart])) {
136
+ aStart++;
137
+ continue;
138
+ }
139
139
  if (!map) {
140
140
  map = new Map();
141
141
  let i = bStart;
@@ -152,31 +152,19 @@ function reconcileArrays(parentNode, a, b, marker) {
152
152
  sequence++;
153
153
  }
154
154
  if (sequence > index - bStart) {
155
- const head = a[aStart];
156
- const headTag = head[$$SLOT];
157
- const node = head.parentNode === parentNode && (!headTag || headTag === marker) ? head : after;
155
+ const node = a[aStart];
158
156
  while (bStart < index) {
159
157
  const n = b[bStart++];
160
158
  parentNode.insertBefore(n, node);
161
159
  if (marker) n[$$SLOT] = marker;
162
160
  }
163
161
  } else {
164
- const oldNode = a[aStart++];
165
162
  const newNode = b[bStart++];
166
- const oldTag = oldNode[$$SLOT];
167
- if (oldNode.parentNode === parentNode && (!oldTag || oldTag === marker)) {
168
- parentNode.replaceChild(newNode, oldNode);
169
- } else {
170
- parentNode.insertBefore(newNode, after);
171
- }
163
+ parentNode.replaceChild(newNode, a[aStart++]);
172
164
  if (marker) newNode[$$SLOT] = marker;
173
165
  }
174
166
  } else aStart++;
175
- } else {
176
- const n = a[aStart++];
177
- const nTag = n[$$SLOT];
178
- if (n.parentNode === parentNode && (!nTag || nTag === marker)) n.remove();
179
- }
167
+ } else a[aStart++].remove();
180
168
  }
181
169
  }
182
170
  }
@@ -522,6 +510,9 @@ function setProperty(node, name, value) {
522
510
  } else node[name] = value;
523
511
  reclaimAttribute(node, name);
524
512
  }
513
+ function setStatefulProperty(node, name, value) {
514
+ node[name] = value;
515
+ }
525
516
  let claimHandlers = null;
526
517
  const claimAttributeSets = [];
527
518
  const CLAIM_SEAM = Symbol.for("solid.element-claims");
@@ -704,7 +695,7 @@ function setStyleProperty(node, name, value) {
704
695
  if (isHydrating(node)) return;
705
696
  value != null ? node.style.setProperty(name, value) : node.style.removeProperty(name);
706
697
  }
707
- function spread(node, props, skipChildren, skip, name) {
698
+ function spread(node, props, skipChildren, skip, name, loc) {
708
699
  const prevProps = {};
709
700
  const owner = claimHandlers !== null && (node.localName === "a" || node.localName === "form") ? getOwner() : undefined;
710
701
  const apply = newProps => {
@@ -831,6 +822,7 @@ const SCOPE_OPTIONS = {
831
822
  scope: true
832
823
  };
833
824
  let hydrationRt = null;
825
+ let selectInsert = null;
834
826
  function installHydrationRuntime() {
835
827
  hydrationRt = {
836
828
  claimInitial(parent, multi, initial) {
@@ -921,11 +913,14 @@ function insert(parent, accessor, marker, initial, options) {
921
913
  initial = [placeholder];
922
914
  }
923
915
  let current = initial;
924
- effect(prev => {
916
+ let ran = false;
917
+ effect(() => {
925
918
  if (hydrationRt !== null) current = hydrationRt.reclaimRegion(current, parent, marker);
926
919
  const value = normalize(accessor(), current, multi, true);
920
+ const again = ran;
921
+ ran = true;
927
922
  if (typeof value !== "function") return value;
928
- const innerOptions = prev !== undefined && !(options && options.schedule) ? {
923
+ const innerOptions = again && !(options && options.schedule) ? {
929
924
  ...options,
930
925
  schedule: true
931
926
  } : options;
@@ -1677,14 +1672,13 @@ function eventHandler(e, container, state) {
1677
1672
  if (prev === true || prev === container || !container.contains(prev)) return;
1678
1673
  resumeNode = prev;
1679
1674
  }
1680
- const owner = state && (state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner);
1681
- if (state && !owner) return;
1682
- if (owner && owner === resumeNode) return;
1683
- e[$$EVENT_OWNER] = owner || true;
1675
+ const owner = state.owners.size === 1 && state.owners.has(container) ? container : findOwner(e.target, state)?.owner;
1676
+ if (!owner) return;
1677
+ if (owner === resumeNode) return;
1678
+ e[$$EVENT_OWNER] = owner;
1684
1679
  let node = resumeNode || e.target;
1685
1680
  const key = EVENT_KEY + e.type;
1686
1681
  const oriTarget = e.target;
1687
- const boundary = owner || container || e.currentTarget;
1688
1682
  const retarget = value => Object.defineProperty(e, "target", {
1689
1683
  configurable: true,
1690
1684
  value
@@ -1701,19 +1695,19 @@ function eventHandler(e, container, state) {
1701
1695
  };
1702
1696
  const walkUpTree = () => {
1703
1697
  while (node && handleNode()) {
1704
- if (node === boundary || node.parentNode === boundary) break;
1698
+ if (node === owner || node.parentNode === owner) break;
1705
1699
  node = node._$host || node.parentNode || node.host;
1706
1700
  }
1707
1701
  };
1708
1702
  Object.defineProperty(e, "currentTarget", {
1709
1703
  configurable: true,
1710
1704
  get() {
1711
- return node || boundary || document;
1705
+ return node || owner;
1712
1706
  }
1713
1707
  });
1714
1708
  if (resumeNode) {
1715
1709
  if (resumeNode === e.target) node = resumeNode._$host || resumeNode.parentNode || resumeNode.host;
1716
- if (node && node !== boundary) walkUpTree();
1710
+ if (node && node !== owner) walkUpTree();
1717
1711
  } else if (e.composedPath) {
1718
1712
  const path = e.composedPath();
1719
1713
  if (path.length) {
@@ -1726,7 +1720,7 @@ function eventHandler(e, container, state) {
1726
1720
  walkUpTree();
1727
1721
  break;
1728
1722
  }
1729
- if (node === boundary || node.parentNode === boundary) {
1723
+ if (node === owner || node.parentNode === owner) {
1730
1724
  break;
1731
1725
  }
1732
1726
  }
@@ -1750,7 +1744,10 @@ function insertExpression(parent, value, current, marker) {
1750
1744
  return value;
1751
1745
  }
1752
1746
  if (value === current) return value;
1753
- if (hydrationRt !== null && sharedConfig.hydrating && current == null && value && [].concat(value).every(n => n?.parentNode === parent) && value.length !== 0) return value;
1747
+ if (hydrationRt !== null && sharedConfig.hydrating && value && value.length !== 0) {
1748
+ const tracked = [].concat(current ?? []);
1749
+ if ([].concat(value).every(n => (n === tracked[0] && tracked.shift(), n?.parentNode === parent)) && !tracked.length) return value;
1750
+ }
1754
1751
  const t = typeof value,
1755
1752
  multi = marker !== undefined;
1756
1753
  if (t === "string" || t === "number") {
@@ -1803,7 +1800,6 @@ function insertExpression(parent, value, current, marker) {
1803
1800
  selectInsert && selectInsert(parent);
1804
1801
  return value;
1805
1802
  }
1806
- let selectInsert;
1807
1803
  function selectChange(e) {
1808
1804
  (e = e.currentTarget || e)._$v = null;
1809
1805
  e.removeEventListener("change", selectChange, true);
@@ -1836,7 +1832,7 @@ function normalize(value, current, multi, doNotUnwrap) {
1836
1832
  });
1837
1833
  if (doNotUnwrap && typeof value === "function") return value;
1838
1834
  if (multi && !Array.isArray(value)) value = [value != null ? value : ""];
1839
- if (sharedConfig.hydrating && Array.isArray(value)) {
1835
+ if (hydrationRt !== null && sharedConfig.hydrating && Array.isArray(value)) {
1840
1836
  for (let i = 0, len = value.length; i < len; i++) {
1841
1837
  const item = value[i],
1842
1838
  prev = current && current[i],
@@ -2090,7 +2086,12 @@ function respond(value, init = {}) {
2090
2086
  }), value);
2091
2087
  }
2092
2088
  headers.set("Content-Type", "application/json");
2093
- return new ResponseEnvelope(new Response(JSON.stringify(value), {
2089
+ return new ResponseEnvelope(new Response(new ReadableStream({
2090
+ pull(controller) {
2091
+ controller.enqueue(new TextEncoder().encode(JSON.stringify(value)));
2092
+ controller.close();
2093
+ }
2094
+ }), {
2094
2095
  ...responseInit,
2095
2096
  headers
2096
2097
  }), value);
@@ -2199,4 +2200,4 @@ _moduleUrl) {
2199
2200
  function httpStatus(_code, _text) {}
2200
2201
  function httpHeader(_name, _value, _options) {}
2201
2202
 
2202
- export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clearFlashCookie, clientOnly, commitEventResponse, composeMiddleware, configureServerErrors, createRequestEvent, createResponseStub, createSSRResponse, delegateEvents, dispatchAsInteraction, dynamic, dynamicProperty, effect, escape, generateHydrationScript, getDelegatedRoot, getExpectedRedirectStatus, getFirstChild, getHydrationKey, getHydrationWriter, getNextElement, getNextMarker, getNextMatch, getNextSibling, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, hasServerLinkState, httpHeader, httpStatus, hydrate, insert, installHydrationRuntime, installServerComponentHydration, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, parseCookieHeader, readShallow, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, registerElementClaim, reload, render, renderToStream, renderToString, reportRequestFailure, resolveSSRNode, respond, runHydrationEvents, scope, serializeCookie, setAttribute, setAttributeNS, setLinkClaim, setProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrLinkClaim, ssrStyle, ssrStyleProperties, ssrStyleProperty, style, takeHydrationValue, template, unregisterDelegatedContainer, unregisterDelegatedRoot, useHead, waitAsset, warmAsset };
2203
+ export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, acquireAsset, addEvent, applyRef, assign, claimElement, claimElementTree, className, clearFlashCookie, clientOnly, commitEventResponse, composeMiddleware, configureServerErrors, createRequestEvent, createResponseStub, createSSRResponse, delegateEvents, dispatchAsInteraction, dynamic, dynamicProperty, effect, escape, generateHydrationScript, getDelegatedRoot, getExpectedRedirectStatus, getFirstChild, getHydrationKey, getHydrationWriter, getNextElement, getNextMarker, getNextMatch, getNextSibling, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, hasServerLinkState, httpHeader, httpStatus, hydrate, insert, installHydrationRuntime, installServerComponentHydration, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, parseCookieHeader, readShallow, redirect, ref, registerDelegatedContainer, registerDelegatedRoot, registerElementClaim, reload, render, renderToStream, renderToString, reportRequestFailure, resolveSSRNode, respond, runHydrationEvents, scope, serializeCookie, setAttribute, setAttributeNS, setLinkClaim, setProperty, setStatefulProperty, setStyleProperty, spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrLinkClaim, ssrStyle, ssrStyleProperties, ssrStyleProperty, style, takeHydrationValue, template, unregisterDelegatedContainer, unregisterDelegatedRoot, useHead, waitAsset, warmAsset };