@solidjs/web 2.0.0-rc.22 → 2.0.0-rc.23

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.
@@ -295,6 +295,24 @@ function traceMetaMarkup(record) {
295
295
  }
296
296
  return markup;
297
297
  }
298
+ function sharedCacheMayStore(cacheControl, cdnCacheControl) {
299
+ return mayStore(cacheControl, true) || mayStore(cdnCacheControl, false);
300
+ }
301
+ const DIRECTIVE = /([^\s=,]+)\s*(=\s*(?:"(?:[^"\\]|\\.)*"?|[^,]*))?/g;
302
+ function mayStore(value, asks) {
303
+ if (value === null) return false;
304
+ let shared = !asks;
305
+ for (const [, directive, argument] of value.matchAll(DIRECTIVE)) {
306
+ const name = directive.toLowerCase();
307
+ if (name === "no-store" || name === "private" && !argument) return false;
308
+ if (name === "public" || name === "s-maxage") shared = true;
309
+ }
310
+ return shared;
311
+ }
312
+ function withholdForSharedCache(record, event) {
313
+ const headers = event && event.response && event.response.headers;
314
+ if (record.emit && headers && sharedCacheMayStore(headers.get("Cache-Control"), headers.get("CDN-Cache-Control"))) record.emit = false;
315
+ }
298
316
 
299
317
  const RECORDS = Symbol.for("@solidjs/signals/observe/records");
300
318
  function records() {
@@ -2032,6 +2050,7 @@ function renderToString(code, options = {}) {
2032
2050
  serializeFragmentAssets("", tracking.boundaryModules, sharedConfig.context, renderId);
2033
2051
  closed = true;
2034
2052
  serializer.close();
2053
+ withholdForSharedCache(context.trace, requestEvent);
2035
2054
  const head = renderShellHead(headRegistry, nonce, null, noScripts, traceMetaMarkup(context.trace));
2036
2055
  const document = withShellEnd(assembleDocument(html, tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead, tracking.lowModules), context, renderId, nonce, noScripts);
2037
2056
  if (render) render.shell();
@@ -2860,6 +2879,7 @@ function renderToStream(code, options = {}) {
2860
2879
  }
2861
2880
  serializeRootAssets();
2862
2881
  flushStubBatch();
2882
+ withholdForSharedCache(context.trace, requestEvent);
2863
2883
  const head = renderShellHead(headRegistry, nonce, k => registry.has(k), noScripts, traceMetaMarkup(context.trace));
2864
2884
  if (render) render.shell();
2865
2885
  sink.shell(html, {
@@ -4115,14 +4135,14 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
4115
4135
  let i = 0;
4116
4136
  for (; i < props.length; i++) {
4117
4137
  const s = props[i];
4118
- if (s == null || typeof s === "function" || $PROXY in s) break;
4138
+ if (!s || typeof s === "function" || $PROXY in s) break;
4119
4139
  }
4120
4140
  if (i === props.length) sources = props;else {
4121
4141
  viewKeys = [];
4122
4142
  owners = [];
4123
4143
  collectSpreadSources(props, viewKeys, owners);
4124
4144
  }
4125
- } else if (props == null) {
4145
+ } else if (!props) {
4126
4146
  props = {};
4127
4147
  } else if ($PROXY in props) {
4128
4148
  if (viewOf(props) !== undefined) {
@@ -4250,7 +4270,7 @@ function collectSpreadSources(props, viewKeys, owners) {
4250
4270
  for (let i = 0; i < props.length; i++) {
4251
4271
  let s = props[i];
4252
4272
  if (typeof s === "function") s = s();
4253
- if (s != null) sourceOwners(s, viewKeys, owners);
4273
+ if (s) sourceOwners(s, viewKeys, owners);
4254
4274
  }
4255
4275
  }
4256
4276
  function spreadFormAttribute(prop, info, keys, keysOf, skip) {
package/dist/server.js CHANGED
@@ -255,6 +255,24 @@ function traceMetaMarkup(record) {
255
255
  }
256
256
  return markup;
257
257
  }
258
+ function sharedCacheMayStore(cacheControl, cdnCacheControl) {
259
+ return mayStore(cacheControl, true) || mayStore(cdnCacheControl, false);
260
+ }
261
+ const DIRECTIVE = /([^\s=,]+)\s*(=\s*(?:"(?:[^"\\]|\\.)*"?|[^,]*))?/g;
262
+ function mayStore(value, asks) {
263
+ if (value === null) return false;
264
+ let shared = !asks;
265
+ for (const [, directive, argument] of value.matchAll(DIRECTIVE)) {
266
+ const name = directive.toLowerCase();
267
+ if (name === "no-store" || name === "private" && !argument) return false;
268
+ if (name === "public" || name === "s-maxage") shared = true;
269
+ }
270
+ return shared;
271
+ }
272
+ function withholdForSharedCache(record, event) {
273
+ const headers = event && event.response && event.response.headers;
274
+ if (record.emit && headers && sharedCacheMayStore(headers.get("Cache-Control"), headers.get("CDN-Cache-Control"))) record.emit = false;
275
+ }
258
276
 
259
277
  const DESCEND = Symbol("descend");
260
278
  const CYCLE = {};
@@ -1767,6 +1785,7 @@ function renderToString(code, options = {}) {
1767
1785
  serializeFragmentAssets("", tracking.boundaryModules, sharedConfig.context, renderId);
1768
1786
  closed = true;
1769
1787
  serializer.close();
1788
+ withholdForSharedCache(context.trace, requestEvent);
1770
1789
  const head = renderShellHead(headRegistry, nonce, null, noScripts, traceMetaMarkup(context.trace));
1771
1790
  const document = withShellEnd(assembleDocument(html, tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead, tracking.lowModules), context, renderId, nonce, noScripts);
1772
1791
  if (render) render.shell();
@@ -2558,6 +2577,7 @@ function renderToStream(code, options = {}) {
2558
2577
  }
2559
2578
  serializeRootAssets();
2560
2579
  flushStubBatch();
2580
+ withholdForSharedCache(context.trace, requestEvent);
2561
2581
  const head = renderShellHead(headRegistry, nonce, k => registry.has(k), noScripts, traceMetaMarkup(context.trace));
2562
2582
  if (render) render.shell();
2563
2583
  sink.shell(html, {
@@ -3792,14 +3812,14 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
3792
3812
  let i = 0;
3793
3813
  for (; i < props.length; i++) {
3794
3814
  const s = props[i];
3795
- if (s == null || typeof s === "function" || $PROXY in s) break;
3815
+ if (!s || typeof s === "function" || $PROXY in s) break;
3796
3816
  }
3797
3817
  if (i === props.length) sources = props;else {
3798
3818
  viewKeys = [];
3799
3819
  owners = [];
3800
3820
  collectSpreadSources(props, viewKeys, owners);
3801
3821
  }
3802
- } else if (props == null) {
3822
+ } else if (!props) {
3803
3823
  props = {};
3804
3824
  } else if ($PROXY in props) {
3805
3825
  if (viewOf(props) !== undefined) {
@@ -3927,7 +3947,7 @@ function collectSpreadSources(props, viewKeys, owners) {
3927
3947
  for (let i = 0; i < props.length; i++) {
3928
3948
  let s = props[i];
3929
3949
  if (typeof s === "function") s = s();
3930
- if (s != null) sourceOwners(s, viewKeys, owners);
3950
+ if (s) sourceOwners(s, viewKeys, owners);
3931
3951
  }
3932
3952
  }
3933
3953
  function spreadFormAttribute(prop, info, keys, keysOf, skip) {
@@ -284,6 +284,24 @@ function traceMetaMarkup(record) {
284
284
  }
285
285
  return markup;
286
286
  }
287
+ function sharedCacheMayStore(cacheControl, cdnCacheControl) {
288
+ return mayStore(cacheControl, true) || mayStore(cdnCacheControl, false);
289
+ }
290
+ const DIRECTIVE = /([^\s=,]+)\s*(=\s*(?:"(?:[^"\\]|\\.)*"?|[^,]*))?/g;
291
+ function mayStore(value, asks) {
292
+ if (value === null) return false;
293
+ let shared = !asks;
294
+ for (const [, directive, argument] of value.matchAll(DIRECTIVE)) {
295
+ const name = directive.toLowerCase();
296
+ if (name === "no-store" || name === "private" && !argument) return false;
297
+ if (name === "public" || name === "s-maxage") shared = true;
298
+ }
299
+ return shared;
300
+ }
301
+ function withholdForSharedCache(record, event) {
302
+ const headers = event && event.response && event.response.headers;
303
+ if (record.emit && headers && sharedCacheMayStore(headers.get("Cache-Control"), headers.get("CDN-Cache-Control"))) record.emit = false;
304
+ }
287
305
 
288
306
  const RECORDS = Symbol.for("@solidjs/signals/observe/records");
289
307
  function records() {
@@ -1863,6 +1881,7 @@ function renderToString(code, options = {}) {
1863
1881
  serializeFragmentAssets("", tracking.boundaryModules, sharedConfig.context, renderId);
1864
1882
  closed = true;
1865
1883
  serializer.close();
1884
+ withholdForSharedCache(context.trace, requestEvent);
1866
1885
  const head = renderShellHead(headRegistry, nonce, null, noScripts, traceMetaMarkup(context.trace));
1867
1886
  const document = withShellEnd(assembleDocument(html, tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead, tracking.lowModules), context, renderId, nonce, noScripts);
1868
1887
  if (render) render.shell();
@@ -2691,6 +2710,7 @@ function renderToStream(code, options = {}) {
2691
2710
  }
2692
2711
  serializeRootAssets();
2693
2712
  flushStubBatch();
2713
+ withholdForSharedCache(context.trace, requestEvent);
2694
2714
  const head = renderShellHead(headRegistry, nonce, k => registry.has(k), noScripts, traceMetaMarkup(context.trace));
2695
2715
  if (render) render.shell();
2696
2716
  sink.shell(html, {
@@ -3925,14 +3945,14 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
3925
3945
  let i = 0;
3926
3946
  for (; i < props.length; i++) {
3927
3947
  const s = props[i];
3928
- if (s == null || typeof s === "function" || $PROXY in s) break;
3948
+ if (!s || typeof s === "function" || $PROXY in s) break;
3929
3949
  }
3930
3950
  if (i === props.length) sources = props;else {
3931
3951
  viewKeys = [];
3932
3952
  owners = [];
3933
3953
  collectSpreadSources(props, viewKeys, owners);
3934
3954
  }
3935
- } else if (props == null) {
3955
+ } else if (!props) {
3936
3956
  props = {};
3937
3957
  } else if ($PROXY in props) {
3938
3958
  if (viewOf(props) !== undefined) {
@@ -4060,7 +4080,7 @@ function collectSpreadSources(props, viewKeys, owners) {
4060
4080
  for (let i = 0; i < props.length; i++) {
4061
4081
  let s = props[i];
4062
4082
  if (typeof s === "function") s = s();
4063
- if (s != null) sourceOwners(s, viewKeys, owners);
4083
+ if (s) sourceOwners(s, viewKeys, owners);
4064
4084
  }
4065
4085
  }
4066
4086
  function spreadFormAttribute(prop, info, keys, keysOf, skip) {
package/dist/web.dev.js CHANGED
@@ -1,6 +1,7 @@
1
- import { createRenderEffect, getOwner, createMemo, OBSERVE, DEV, enableHydration, $PROXY, untrack, runRefCallback, resetErrorHalt, enforceLoadingBoundary, createRoot, ROOT_ERROR_HOOK, flatten, flush, strictReadTracked, runWithOwner, heldRead, setSwapHook, isHidden, createComponent, omit, createOwner, createSignal, createEffect } from 'solid-js';
2
- export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, dynamicComponent, getOwner, heldRead, merge as mergeProps, untrack } from 'solid-js';
3
- import { sharedConfig, enableServerComponentHydration, hasStaticKeys, viewOf, OmitView, sourceHas, SOURCE_OMIT, sourceGet, SOURCE_MEMO, SOURCE_PROXY, SOURCE_PLAIN, sourceKeys, resolvedTable, dynamicCore } from 'solid-js/internal';
1
+ import { createRenderEffect, getOwner, createMemo, OBSERVE, DEV, enableHydration, $PROXY, untrack, runRefCallback, resetErrorHalt, enforceLoadingBoundary, createRoot, ROOT_ERROR_HOOK, flatten, flush, strictReadTracked, runWithOwner, setSwapHook, isHidden, createComponent, omit, createOwner, createSignal, createEffect } from 'solid-js';
2
+ export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, dynamicComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
+ import { sharedConfig, enableServerComponentHydration, hasStaticKeys, heldRead, viewOf, OmitView, sourceHas, SOURCE_OMIT, sourceGet, SOURCE_MEMO, SOURCE_PROXY, SOURCE_PLAIN, sourceKeys, resolvedTable, dynamicCore } from 'solid-js/internal';
4
+ export { heldRead } from 'solid-js/internal';
4
5
 
5
6
  const DOMWithState = {
6
7
  INPUT: {
@@ -575,7 +576,7 @@ function create(html, bypassGuard, flag) {
575
576
  }
576
577
  function template(html, flag) {
577
578
  let node;
578
- const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
579
+ const fn = bypassGuard => (node || (node = create(html, bypassGuard, flag)), flag === 1 ? document.importNode(node, true) : node.cloneNode(true));
579
580
  fn._html = flag === 2 ? html.replace(/^<[^>]+>/, "") : html;
580
581
  return fn;
581
582
  }
@@ -652,8 +653,7 @@ function getDelegatedRoot(node) {
652
653
  }
653
654
  }
654
655
  const parentOf = node => node._$host || node.parentNode || node.host;
655
- function findOwner(target, state) {
656
- let node = target;
656
+ function findOwner(node, state) {
657
657
  let distance = 0;
658
658
  while (node) {
659
659
  if (state.owners.has(node)) return {
@@ -911,7 +911,7 @@ function spread(node, props, skipChildren, skip, name, loc) {
911
911
  if (!skipChildren && !(skip !== undefined && skip("children"))) insert(node, () => {
912
912
  for (let i = props.length - 1; i >= 0; i--) {
913
913
  const s = resolveSource(props[i]);
914
- if (s != null && entryHas(s, "children")) return entryGet(s, "children");
914
+ if (s && entryHas(s, "children")) return entryGet(s, "children");
915
915
  }
916
916
  });
917
917
  unscopedByDesign = null;
@@ -922,7 +922,7 @@ function spread(node, props, skipChildren, skip, name, loc) {
922
922
  const newProps = {};
923
923
  const table = resolvedTable(source);
924
924
  if (table !== undefined) return collectTable(newProps, table, skip);
925
- if (source != null) {
925
+ if (source) {
926
926
  const view = viewOf(source);
927
927
  if (view instanceof OmitView) collectProps(newProps, view, SOURCE_OMIT, skip);else if (view !== undefined) collectSources(newProps, view.sources, view.kinds, skip);else collectProps(newProps, source, $PROXY in source ? SOURCE_PROXY : SOURCE_PLAIN, skip);
928
928
  }
@@ -938,7 +938,7 @@ function spread(node, props, skipChildren, skip, name, loc) {
938
938
  }
939
939
  } else insert(node, () => {
940
940
  const source = resolveSource(props);
941
- return source != null && entryHas(source, "children") ? entryGet(source, "children") : undefined;
941
+ return source && entryHas(source, "children") ? entryGet(source, "children") : undefined;
942
942
  });
943
943
  }
944
944
  unscopedByDesign = null;
@@ -978,7 +978,7 @@ function pushEntry(resolved, kinds, s, kind) {
978
978
  return;
979
979
  }
980
980
  s = resolveSource(s);
981
- if (s == null) return;
981
+ if (!s) return;
982
982
  const view = viewOf(s);
983
983
  if (view instanceof OmitView) {
984
984
  resolved.push(view);
@@ -1144,30 +1144,28 @@ function claimChildNodes(parent) {
1144
1144
  function isPlaceholderScaffolding(node, t) {
1145
1145
  return t === 8 ? node.nodeValue.startsWith("pl-") : t === 1 && node.localName === "template" && node.id.startsWith("pl-");
1146
1146
  }
1147
- function insert(parent, accessor, marker, initial, options) {
1147
+ function insert(parent, accessor, marker, current, options) {
1148
1148
  if (spreadName !== undefined && (options === undefined || options.name === undefined)) options = {
1149
1149
  ...options,
1150
1150
  name: spreadName + ".children",
1151
1151
  loc: spreadLoc
1152
1152
  };
1153
1153
  const multi = marker !== undefined;
1154
- const host = options && options.host;
1155
- if (multi && !initial) initial = [];
1156
- if (hydrationRt !== null) initial = hydrationRt.claimInitial(parent, multi, initial);
1154
+ if (multi && !current) current = [];
1155
+ if (hydrationRt !== null) current = hydrationRt.claimInitial(parent, multi, current);
1157
1156
  if (typeof accessor !== "function") {
1158
- accessor = normalize(accessor, initial, multi, true);
1157
+ accessor = normalize(accessor, current, multi, true);
1159
1158
  if (typeof accessor !== "function") {
1160
- insertExpression(parent, accessor, initial, marker);
1161
- hostRt !== null && host && hostRt(accessor, host);
1159
+ insertExpression(parent, accessor, current, marker);
1160
+ hostRt !== null && options && options.host && hostRt(accessor, options.host);
1162
1161
  return;
1163
1162
  }
1164
1163
  }
1165
- if (multi && initial.length === 0) {
1164
+ if (multi && current.length === 0) {
1166
1165
  const placeholder = document.createTextNode("");
1167
1166
  parent.insertBefore(placeholder, marker);
1168
- initial = [placeholder];
1167
+ current = [placeholder];
1169
1168
  }
1170
- let current = initial;
1171
1169
  let ran = false;
1172
1170
  effect(() => {
1173
1171
  if (hydrationRt !== null) current = hydrationRt.reclaimRegion(current, parent, marker);
@@ -1183,7 +1181,7 @@ function insert(parent, accessor, marker, initial, options) {
1183
1181
  } : options;
1184
1182
  effect(() => (hydrationRt !== null && (current = hydrationRt.reclaimRegion(current, parent, marker)), normalize(value, current, multi)), inner => {
1185
1183
  current = insertExpression(parent, inner, current, marker);
1186
- hostRt !== null && host && hostRt(current, host);
1184
+ hostRt !== null && options && options.host && hostRt(current, options.host);
1187
1185
  }, {
1188
1186
  ...innerOptions,
1189
1187
  _wide: true
@@ -1193,7 +1191,7 @@ function insert(parent, accessor, marker, initial, options) {
1193
1191
  }, value => {
1194
1192
  if (value === INNER_OWNED) return;
1195
1193
  current = insertExpression(parent, value, current, marker);
1196
- hostRt !== null && host && hostRt(current, host);
1194
+ hostRt !== null && options && options.host && hostRt(current, options.host);
1197
1195
  },
1198
1196
  accessor.$s ? options ? {
1199
1197
  ...options,
@@ -2071,8 +2069,7 @@ function insertExpression(parent, value, current, marker) {
2071
2069
  const tracked = [].concat(current ?? []);
2072
2070
  if ([].concat(value).every(n => (n === tracked[0] && tracked.shift(), n?.parentNode === parent)) && !tracked.length) return value;
2073
2071
  }
2074
- const t = typeof value,
2075
- multi = marker !== undefined;
2072
+ const t = typeof value;
2076
2073
  if (t === "string" || t === "number") {
2077
2074
  const tc = typeof current;
2078
2075
  if (tc === "string" || tc === "number") {
@@ -2087,7 +2084,7 @@ function insertExpression(parent, value, current, marker) {
2087
2084
  cleanChildren(parent, current, marker);
2088
2085
  } else if (value.nodeType) {
2089
2086
  if (Array.isArray(current)) {
2090
- cleanChildren(parent, current, multi ? marker : null, value);
2087
+ cleanChildren(parent, current, marker ?? null, value);
2091
2088
  } else if (current != null && current.nodeType) {
2092
2089
  current.parentNode === parent ? parent.replaceChild(value, current) : parent.appendChild(value);
2093
2090
  } else if (current != null && parent.firstChild) {
package/dist/web.js CHANGED
@@ -1,6 +1,7 @@
1
- import { createRenderEffect, createMemo, enableHydration, $PROXY, untrack, runRefCallback, createRoot, getOwner, ROOT_ERROR_HOOK, flatten, flush, runWithOwner, heldRead, setSwapHook, isHidden, createComponent, omit, createOwner, createSignal, createEffect } from 'solid-js';
2
- export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, dynamicComponent, getOwner, heldRead, merge as mergeProps, untrack } from 'solid-js';
3
- import { sharedConfig, enableServerComponentHydration, hasStaticKeys, viewOf, OmitView, sourceHas, SOURCE_OMIT, sourceGet, SOURCE_MEMO, SOURCE_PROXY, SOURCE_PLAIN, sourceKeys, resolvedTable, dynamicCore } from 'solid-js/internal';
1
+ import { createRenderEffect, createMemo, enableHydration, $PROXY, untrack, runRefCallback, createRoot, getOwner, ROOT_ERROR_HOOK, flatten, flush, runWithOwner, setSwapHook, isHidden, createComponent, omit, createOwner, createSignal, createEffect } from 'solid-js';
2
+ export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, dynamicComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
+ import { sharedConfig, enableServerComponentHydration, hasStaticKeys, heldRead, viewOf, OmitView, sourceHas, SOURCE_OMIT, sourceGet, SOURCE_MEMO, SOURCE_PROXY, SOURCE_PLAIN, sourceKeys, resolvedTable, dynamicCore } from 'solid-js/internal';
4
+ export { heldRead } from 'solid-js/internal';
4
5
 
5
6
  const DOMWithState = {
6
7
  INPUT: {
@@ -422,7 +423,7 @@ function create(html, bypassGuard, flag) {
422
423
  }
423
424
  function template(html, flag) {
424
425
  let node;
425
- const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
426
+ const fn = bypassGuard => (node || (node = create(html, bypassGuard, flag)), flag === 1 ? document.importNode(node, true) : node.cloneNode(true));
426
427
  return fn;
427
428
  }
428
429
  function delegateEvents(eventNames) {
@@ -478,8 +479,7 @@ function getDelegatedRoot(node) {
478
479
  }
479
480
  }
480
481
  const parentOf = node => node._$host || node.parentNode || node.host;
481
- function findOwner(target, state) {
482
- let node = target;
482
+ function findOwner(node, state) {
483
483
  let distance = 0;
484
484
  while (node) {
485
485
  if (state.owners.has(node)) return {
@@ -708,7 +708,7 @@ function spread(node, props, skipChildren, skip, name, loc) {
708
708
  if (!skipChildren && !(skip !== undefined && skip("children"))) insert(node, () => {
709
709
  for (let i = props.length - 1; i >= 0; i--) {
710
710
  const s = resolveSource(props[i]);
711
- if (s != null && entryHas(s, "children")) return entryGet(s, "children");
711
+ if (s && entryHas(s, "children")) return entryGet(s, "children");
712
712
  }
713
713
  });
714
714
  return prevProps;
@@ -718,7 +718,7 @@ function spread(node, props, skipChildren, skip, name, loc) {
718
718
  const newProps = {};
719
719
  const table = resolvedTable(source);
720
720
  if (table !== undefined) return collectTable(newProps, table, skip);
721
- if (source != null) {
721
+ if (source) {
722
722
  const view = viewOf(source);
723
723
  if (view instanceof OmitView) collectProps(newProps, view, SOURCE_OMIT, skip);else if (view !== undefined) collectSources(newProps, view.sources, view.kinds, skip);else collectProps(newProps, source, $PROXY in source ? SOURCE_PROXY : SOURCE_PLAIN, skip);
724
724
  }
@@ -733,7 +733,7 @@ function spread(node, props, skipChildren, skip, name, loc) {
733
733
  }
734
734
  } else insert(node, () => {
735
735
  const source = resolveSource(props);
736
- return source != null && entryHas(source, "children") ? entryGet(source, "children") : undefined;
736
+ return source && entryHas(source, "children") ? entryGet(source, "children") : undefined;
737
737
  });
738
738
  }
739
739
  return prevProps;
@@ -772,7 +772,7 @@ function pushEntry(resolved, kinds, s, kind) {
772
772
  return;
773
773
  }
774
774
  s = resolveSource(s);
775
- if (s == null) return;
775
+ if (!s) return;
776
776
  const view = viewOf(s);
777
777
  if (view instanceof OmitView) {
778
778
  resolved.push(view);
@@ -897,25 +897,23 @@ function claimChildNodes(parent) {
897
897
  function isPlaceholderScaffolding(node, t) {
898
898
  return t === 8 ? node.nodeValue.startsWith("pl-") : t === 1 && node.localName === "template" && node.id.startsWith("pl-");
899
899
  }
900
- function insert(parent, accessor, marker, initial, options) {
900
+ function insert(parent, accessor, marker, current, options) {
901
901
  const multi = marker !== undefined;
902
- const host = options && options.host;
903
- if (multi && !initial) initial = [];
904
- if (hydrationRt !== null) initial = hydrationRt.claimInitial(parent, multi, initial);
902
+ if (multi && !current) current = [];
903
+ if (hydrationRt !== null) current = hydrationRt.claimInitial(parent, multi, current);
905
904
  if (typeof accessor !== "function") {
906
- accessor = normalize(accessor, initial, multi, true);
905
+ accessor = normalize(accessor, current, multi, true);
907
906
  if (typeof accessor !== "function") {
908
- insertExpression(parent, accessor, initial, marker);
909
- hostRt !== null && host && hostRt(accessor, host);
907
+ insertExpression(parent, accessor, current, marker);
908
+ hostRt !== null && options && options.host && hostRt(accessor, options.host);
910
909
  return;
911
910
  }
912
911
  }
913
- if (multi && initial.length === 0) {
912
+ if (multi && current.length === 0) {
914
913
  const placeholder = document.createTextNode("");
915
914
  parent.insertBefore(placeholder, marker);
916
- initial = [placeholder];
915
+ current = [placeholder];
917
916
  }
918
- let current = initial;
919
917
  let ran = false;
920
918
  effect(() => {
921
919
  if (hydrationRt !== null) current = hydrationRt.reclaimRegion(current, parent, marker);
@@ -929,13 +927,13 @@ function insert(parent, accessor, marker, initial, options) {
929
927
  } : options;
930
928
  effect(() => (hydrationRt !== null && (current = hydrationRt.reclaimRegion(current, parent, marker)), normalize(value, current, multi)), inner => {
931
929
  current = insertExpression(parent, inner, current, marker);
932
- hostRt !== null && host && hostRt(current, host);
930
+ hostRt !== null && options && options.host && hostRt(current, options.host);
933
931
  }, innerOptions);
934
932
  return INNER_OWNED;
935
933
  }, value => {
936
934
  if (value === INNER_OWNED) return;
937
935
  current = insertExpression(parent, value, current, marker);
938
- hostRt !== null && host && hostRt(current, host);
936
+ hostRt !== null && options && options.host && hostRt(current, options.host);
939
937
  },
940
938
  accessor.$s ? options ? {
941
939
  ...options,
@@ -1747,8 +1745,7 @@ function insertExpression(parent, value, current, marker) {
1747
1745
  const tracked = [].concat(current ?? []);
1748
1746
  if ([].concat(value).every(n => (n === tracked[0] && tracked.shift(), n?.parentNode === parent)) && !tracked.length) return value;
1749
1747
  }
1750
- const t = typeof value,
1751
- multi = marker !== undefined;
1748
+ const t = typeof value;
1752
1749
  if (t === "string" || t === "number") {
1753
1750
  const tc = typeof current;
1754
1751
  if (tc === "string" || tc === "number") {
@@ -1763,7 +1760,7 @@ function insertExpression(parent, value, current, marker) {
1763
1760
  cleanChildren(parent, current, marker);
1764
1761
  } else if (value.nodeType) {
1765
1762
  if (Array.isArray(current)) {
1766
- cleanChildren(parent, current, multi ? marker : null, value);
1763
+ cleanChildren(parent, current, marker ?? null, value);
1767
1764
  } else if (current != null && current.nodeType) {
1768
1765
  current.parentNode === parent ? parent.replaceChild(value, current) : parent.appendChild(value);
1769
1766
  } else if (current != null && parent.firstChild) {
@@ -1,6 +1,7 @@
1
- import { createRenderEffect, createMemo, OBSERVE, enableHydration, $PROXY, untrack, runRefCallback, createRoot, getOwner, ROOT_ERROR_HOOK, flatten, flush, runWithOwner, heldRead, setSwapHook, isHidden, createComponent, omit, createOwner, createSignal, createEffect } from 'solid-js';
2
- export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, dynamicComponent, getOwner, heldRead, merge as mergeProps, untrack } from 'solid-js';
3
- import { sharedConfig, enableServerComponentHydration, hasStaticKeys, viewOf, OmitView, sourceHas, SOURCE_OMIT, sourceGet, SOURCE_MEMO, SOURCE_PROXY, SOURCE_PLAIN, sourceKeys, resolvedTable, dynamicCore } from 'solid-js/internal';
1
+ import { createRenderEffect, createMemo, OBSERVE, enableHydration, $PROXY, untrack, runRefCallback, createRoot, getOwner, ROOT_ERROR_HOOK, flatten, flush, runWithOwner, setSwapHook, isHidden, createComponent, omit, createOwner, createSignal, createEffect } from 'solid-js';
2
+ export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, dynamicComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
3
+ import { sharedConfig, enableServerComponentHydration, hasStaticKeys, heldRead, viewOf, OmitView, sourceHas, SOURCE_OMIT, sourceGet, SOURCE_MEMO, SOURCE_PROXY, SOURCE_PLAIN, sourceKeys, resolvedTable, dynamicCore } from 'solid-js/internal';
4
+ export { heldRead } from 'solid-js/internal';
4
5
 
5
6
  const DOMWithState = {
6
7
  INPUT: {
@@ -433,7 +434,7 @@ function create(html, bypassGuard, flag) {
433
434
  }
434
435
  function template(html, flag) {
435
436
  let node;
436
- const fn = flag === 1 ? bypassGuard => document.importNode(node || (node = create(html, bypassGuard, flag)), true) : bypassGuard => (node || (node = create(html, bypassGuard, flag))).cloneNode(true);
437
+ const fn = bypassGuard => (node || (node = create(html, bypassGuard, flag)), flag === 1 ? document.importNode(node, true) : node.cloneNode(true));
437
438
  return fn;
438
439
  }
439
440
  function delegateEvents(eventNames) {
@@ -509,8 +510,7 @@ function getDelegatedRoot(node) {
509
510
  }
510
511
  }
511
512
  const parentOf = node => node._$host || node.parentNode || node.host;
512
- function findOwner(target, state) {
513
- let node = target;
513
+ function findOwner(node, state) {
514
514
  let distance = 0;
515
515
  while (node) {
516
516
  if (state.owners.has(node)) return {
@@ -754,7 +754,7 @@ function spread(node, props, skipChildren, skip, name, loc) {
754
754
  if (!skipChildren && !(skip !== undefined && skip("children"))) insert(node, () => {
755
755
  for (let i = props.length - 1; i >= 0; i--) {
756
756
  const s = resolveSource(props[i]);
757
- if (s != null && entryHas(s, "children")) return entryGet(s, "children");
757
+ if (s && entryHas(s, "children")) return entryGet(s, "children");
758
758
  }
759
759
  });
760
760
  return prevProps;
@@ -764,7 +764,7 @@ function spread(node, props, skipChildren, skip, name, loc) {
764
764
  const newProps = {};
765
765
  const table = resolvedTable(source);
766
766
  if (table !== undefined) return collectTable(newProps, table, skip);
767
- if (source != null) {
767
+ if (source) {
768
768
  const view = viewOf(source);
769
769
  if (view instanceof OmitView) collectProps(newProps, view, SOURCE_OMIT, skip);else if (view !== undefined) collectSources(newProps, view.sources, view.kinds, skip);else collectProps(newProps, source, $PROXY in source ? SOURCE_PROXY : SOURCE_PLAIN, skip);
770
770
  }
@@ -779,7 +779,7 @@ function spread(node, props, skipChildren, skip, name, loc) {
779
779
  }
780
780
  } else insert(node, () => {
781
781
  const source = resolveSource(props);
782
- return source != null && entryHas(source, "children") ? entryGet(source, "children") : undefined;
782
+ return source && entryHas(source, "children") ? entryGet(source, "children") : undefined;
783
783
  });
784
784
  }
785
785
  return prevProps;
@@ -818,7 +818,7 @@ function pushEntry(resolved, kinds, s, kind) {
818
818
  return;
819
819
  }
820
820
  s = resolveSource(s);
821
- if (s == null) return;
821
+ if (!s) return;
822
822
  const view = viewOf(s);
823
823
  if (view instanceof OmitView) {
824
824
  resolved.push(view);
@@ -943,30 +943,28 @@ function claimChildNodes(parent) {
943
943
  function isPlaceholderScaffolding(node, t) {
944
944
  return t === 8 ? node.nodeValue.startsWith("pl-") : t === 1 && node.localName === "template" && node.id.startsWith("pl-");
945
945
  }
946
- function insert(parent, accessor, marker, initial, options) {
946
+ function insert(parent, accessor, marker, current, options) {
947
947
  if (spreadName !== undefined && (options === undefined || options.name === undefined)) options = {
948
948
  ...options,
949
949
  name: spreadName + ".children",
950
950
  loc: spreadLoc
951
951
  };
952
952
  const multi = marker !== undefined;
953
- const host = options && options.host;
954
- if (multi && !initial) initial = [];
955
- if (hydrationRt !== null) initial = hydrationRt.claimInitial(parent, multi, initial);
953
+ if (multi && !current) current = [];
954
+ if (hydrationRt !== null) current = hydrationRt.claimInitial(parent, multi, current);
956
955
  if (typeof accessor !== "function") {
957
- accessor = normalize(accessor, initial, multi, true);
956
+ accessor = normalize(accessor, current, multi, true);
958
957
  if (typeof accessor !== "function") {
959
- insertExpression(parent, accessor, initial, marker);
960
- hostRt !== null && host && hostRt(accessor, host);
958
+ insertExpression(parent, accessor, current, marker);
959
+ hostRt !== null && options && options.host && hostRt(accessor, options.host);
961
960
  return;
962
961
  }
963
962
  }
964
- if (multi && initial.length === 0) {
963
+ if (multi && current.length === 0) {
965
964
  const placeholder = document.createTextNode("");
966
965
  parent.insertBefore(placeholder, marker);
967
- initial = [placeholder];
966
+ current = [placeholder];
968
967
  }
969
- let current = initial;
970
968
  let ran = false;
971
969
  effect(() => {
972
970
  if (hydrationRt !== null) current = hydrationRt.reclaimRegion(current, parent, marker);
@@ -980,13 +978,13 @@ function insert(parent, accessor, marker, initial, options) {
980
978
  } : options;
981
979
  effect(() => (hydrationRt !== null && (current = hydrationRt.reclaimRegion(current, parent, marker)), normalize(value, current, multi)), inner => {
982
980
  current = insertExpression(parent, inner, current, marker);
983
- hostRt !== null && host && hostRt(current, host);
981
+ hostRt !== null && options && options.host && hostRt(current, options.host);
984
982
  }, innerOptions);
985
983
  return INNER_OWNED;
986
984
  }, value => {
987
985
  if (value === INNER_OWNED) return;
988
986
  current = insertExpression(parent, value, current, marker);
989
- hostRt !== null && host && hostRt(current, host);
987
+ hostRt !== null && options && options.host && hostRt(current, options.host);
990
988
  },
991
989
  accessor.$s ? options ? {
992
990
  ...options,
@@ -1798,8 +1796,7 @@ function insertExpression(parent, value, current, marker) {
1798
1796
  const tracked = [].concat(current ?? []);
1799
1797
  if ([].concat(value).every(n => (n === tracked[0] && tracked.shift(), n?.parentNode === parent)) && !tracked.length) return value;
1800
1798
  }
1801
- const t = typeof value,
1802
- multi = marker !== undefined;
1799
+ const t = typeof value;
1803
1800
  if (t === "string" || t === "number") {
1804
1801
  const tc = typeof current;
1805
1802
  if (tc === "string" || tc === "number") {
@@ -1814,7 +1811,7 @@ function insertExpression(parent, value, current, marker) {
1814
1811
  cleanChildren(parent, current, marker);
1815
1812
  } else if (value.nodeType) {
1816
1813
  if (Array.isArray(current)) {
1817
- cleanChildren(parent, current, multi ? marker : null, value);
1814
+ cleanChildren(parent, current, marker ?? null, value);
1818
1815
  } else if (current != null && current.nodeType) {
1819
1816
  current.parentNode === parent ? parent.replaceChild(value, current) : parent.appendChild(value);
1820
1817
  } else if (current != null && parent.firstChild) {
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.22",
4
+ "version": "2.0.0-rc.23",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -372,14 +372,15 @@
372
372
  "coverage": "vitest run --coverage",
373
373
  "bench": "vitest bench --run",
374
374
  "bench:server": "vitest bench --run --config vite.config.server-bench.mjs",
375
- "test-types": "tsc --project tsconfig.test.json && tsc --project tsconfig.test.augment.json"
375
+ "test-types": "tsc --project tsconfig.test.json && tsc --project tsconfig.test.augment.json && tsc --project tsconfig.test.libcheck.json"
376
376
  },
377
377
  "dependencies": {
378
- "seroval": "1.7.0",
379
- "seroval-plugins": "1.7.0"
378
+ "csstype": "^3.1.0",
379
+ "seroval": "^1.8.0",
380
+ "seroval-plugins": "^1.8.0"
380
381
  },
381
382
  "peerDependencies": {
382
- "solid-js": "^2.0.0-rc.22"
383
+ "solid-js": "^2.0.0-rc.23"
383
384
  },
384
385
  "devDependencies": {
385
386
  "@codspeed/vitest-plugin": "^5.4.0",
@@ -1,3 +1,5 @@
1
+ import { actionDepth } from 'solid-js/internal';
2
+
1
3
  const REVALIDATE_HEADER = "X-Revalidate";
2
4
 
3
5
  const RECORDS = Symbol.for("@solidjs/signals/observe/records");
@@ -936,10 +938,6 @@ async function createRequest(base, id, options, meta) {
936
938
  };
937
939
  delete options[CALL_OBSERVATION];
938
940
  }
939
- const flightSources = getFlightDataSourceIds();
940
- if (flightSources.length > 0 && !isReadCall(options)) {
941
- headers[SINGLE_FLIGHT_HEADER] = flightSources.join(",");
942
- }
943
941
  let init = {
944
942
  method: "POST",
945
943
  ...options,
@@ -1044,6 +1042,16 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
1044
1042
  id,
1045
1043
  meta
1046
1044
  }) : undefined;
1045
+ const sources = getFlightDataSourceIds();
1046
+ const mutation = !isReadCall(options) && sources.length > 0;
1047
+ const acted = mutation && actionDepth;
1048
+ if (acted) options = {
1049
+ ...options,
1050
+ headers: {
1051
+ ...options.headers,
1052
+ [SINGLE_FLIGHT_HEADER]: sources + ""
1053
+ }
1054
+ };
1047
1055
  const sent = options;
1048
1056
  const controller = options.signal ? undefined : new AbortController();
1049
1057
  if (controller) options = {
@@ -1074,7 +1082,6 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
1074
1082
  throw serverFunctionFailure(response, undefined);
1075
1083
  }
1076
1084
  const failed = response.headers.has(ERROR_HEADER);
1077
- const mutation = !isReadCall(options) && getFlightDataSourceIds().length > 0;
1078
1085
  if (mutation) {
1079
1086
  const folded = response.headers.has(SINGLE_FLIGHT_HEADER);
1080
1087
  const metadata = hasFlightMetadata(response);
@@ -1099,7 +1106,7 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
1099
1106
  if (failed) {
1100
1107
  throw serverFunctionFailure(response, result);
1101
1108
  }
1102
- if (mutation) await deliverFlightData(response);
1109
+ if (acted) await deliverFlightData(response);
1103
1110
  if (controller && result?.[Symbol.asyncIterator]) {
1104
1111
  return {
1105
1112
  [Symbol.asyncIterator]() {
@@ -1,3 +1,5 @@
1
+ import { actionDepth } from 'solid-js/internal';
2
+
1
3
  const REVALIDATE_HEADER = "X-Revalidate";
2
4
 
3
5
  const SERVER_FUNCTION_METADATA = Symbol.for("solid.ServerFunctionMetadata");
@@ -821,10 +823,6 @@ async function createRequest(base, id, options, meta) {
821
823
  if (wire.position !== undefined) headers[LAST_EVENT_ID_HEADER] = wire.position;
822
824
  if (wire.headers) Object.assign(headers, wire.headers);
823
825
  }
824
- const flightSources = getFlightDataSourceIds();
825
- if (flightSources.length > 0 && !isReadCall(options)) {
826
- headers[SINGLE_FLIGHT_HEADER] = flightSources.join(",");
827
- }
828
826
  let init = {
829
827
  method: "POST",
830
828
  ...options,
@@ -915,6 +913,16 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
915
913
  id,
916
914
  meta
917
915
  }) : undefined;
916
+ const sources = getFlightDataSourceIds();
917
+ const mutation = !isReadCall(options) && sources.length > 0;
918
+ const acted = mutation && actionDepth;
919
+ if (acted) options = {
920
+ ...options,
921
+ headers: {
922
+ ...options.headers,
923
+ [SINGLE_FLIGHT_HEADER]: sources + ""
924
+ }
925
+ };
918
926
  const sent = options;
919
927
  const controller = options.signal ? undefined : new AbortController();
920
928
  if (controller) options = {
@@ -938,7 +946,6 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
938
946
  throw serverFunctionFailure(response, undefined);
939
947
  }
940
948
  const failed = response.headers.has(ERROR_HEADER);
941
- const mutation = !isReadCall(options) && getFlightDataSourceIds().length > 0;
942
949
  if (mutation) {
943
950
  const folded = response.headers.has(SINGLE_FLIGHT_HEADER);
944
951
  const metadata = hasFlightMetadata(response);
@@ -963,7 +970,7 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
963
970
  if (failed) {
964
971
  throw serverFunctionFailure(response, result);
965
972
  }
966
- if (mutation) await deliverFlightData(response);
973
+ if (acted) await deliverFlightData(response);
967
974
  if (controller && result?.[Symbol.asyncIterator]) {
968
975
  return {
969
976
  [Symbol.asyncIterator]() {
@@ -1,3 +1,5 @@
1
+ import { actionDepth } from 'solid-js/internal';
2
+
1
3
  const REVALIDATE_HEADER = "X-Revalidate";
2
4
 
3
5
  const RECORDS = Symbol.for("@solidjs/signals/observe/records");
@@ -936,10 +938,6 @@ async function createRequest(base, id, options, meta) {
936
938
  };
937
939
  delete options[CALL_OBSERVATION];
938
940
  }
939
- const flightSources = getFlightDataSourceIds();
940
- if (flightSources.length > 0 && !isReadCall(options)) {
941
- headers[SINGLE_FLIGHT_HEADER] = flightSources.join(",");
942
- }
943
941
  let init = {
944
942
  method: "POST",
945
943
  ...options,
@@ -1044,6 +1042,16 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
1044
1042
  id,
1045
1043
  meta
1046
1044
  }) : undefined;
1045
+ const sources = getFlightDataSourceIds();
1046
+ const mutation = !isReadCall(options) && sources.length > 0;
1047
+ const acted = mutation && actionDepth;
1048
+ if (acted) options = {
1049
+ ...options,
1050
+ headers: {
1051
+ ...options.headers,
1052
+ [SINGLE_FLIGHT_HEADER]: sources + ""
1053
+ }
1054
+ };
1047
1055
  const sent = options;
1048
1056
  const controller = options.signal ? undefined : new AbortController();
1049
1057
  if (controller) options = {
@@ -1074,7 +1082,6 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
1074
1082
  throw serverFunctionFailure(response, undefined);
1075
1083
  }
1076
1084
  const failed = response.headers.has(ERROR_HEADER);
1077
- const mutation = !isReadCall(options) && getFlightDataSourceIds().length > 0;
1078
1085
  if (mutation) {
1079
1086
  const folded = response.headers.has(SINGLE_FLIGHT_HEADER);
1080
1087
  const metadata = hasFlightMetadata(response);
@@ -1099,7 +1106,7 @@ async function dispatchServerFunction(base, id, options, args, meta, callArgs =
1099
1106
  if (failed) {
1100
1107
  throw serverFunctionFailure(response, result);
1101
1108
  }
1102
- if (mutation) await deliverFlightData(response);
1109
+ if (acted) await deliverFlightData(response);
1103
1110
  if (controller && result?.[Symbol.asyncIterator]) {
1104
1111
  return {
1105
1112
  [Symbol.asyncIterator]() {
@@ -210,6 +210,20 @@ function mergeServerTiming(target, value) {
210
210
  target.append("Server-Timing", trimmed);
211
211
  }
212
212
  }
213
+ function sharedCacheMayStore(cacheControl, cdnCacheControl) {
214
+ return mayStore(cacheControl, true) || mayStore(cdnCacheControl, false);
215
+ }
216
+ const DIRECTIVE = /([^\s=,]+)\s*(=\s*(?:"(?:[^"\\]|\\.)*"?|[^,]*))?/g;
217
+ function mayStore(value, asks) {
218
+ if (value === null) return false;
219
+ let shared = !asks;
220
+ for (const [, directive, argument] of value.matchAll(DIRECTIVE)) {
221
+ const name = directive.toLowerCase();
222
+ if (name === "no-store" || name === "private" && !argument) return false;
223
+ if (name === "public" || name === "s-maxage") shared = true;
224
+ }
225
+ return shared;
226
+ }
213
227
 
214
228
  const RECORDS = Symbol.for("@solidjs/signals/observe/records");
215
229
  function records() {
@@ -2017,6 +2031,7 @@ function withBufferedBody(request, body) {
2017
2031
  });
2018
2032
  }
2019
2033
  const KNOWN_BODY_FORMATS = new Set(Object.values(BodyFormat));
2034
+ const EMPTY_BODY_FORMATS = new Set([BodyFormat.String, BodyFormat.URLSearchParams, BodyFormat.Blob, BodyFormat.ArrayBuffer, BodyFormat.Uint8Array]);
2020
2035
  const FORMAT_SKEW = Symbol("solid.serverFunction.formatSkew");
2021
2036
  function unknownFormatError(tag) {
2022
2037
  const error = new TypeError(`Server function body carries an unrecognized ${BODY_FORMAT_HEADER} tag ("${tag}"): the ` + "caller encodes a newer wire format than this build can decode (version skew), or an " + "intermediary duplicated the header. The body was refused rather than reinterpreted.");
@@ -2080,11 +2095,13 @@ async function parseArguments(request, url, scripted, codec, buffered) {
2080
2095
  } else if (!args && url.search && (request.method === "GET" || request.method === "HEAD")) {
2081
2096
  parsed.push(url.searchParams);
2082
2097
  }
2083
- if (request.method === "POST" && request.body !== null) {
2098
+ if (request.method === "POST" && (request.body !== null || EMPTY_BODY_FORMATS.has(bodyFormat))) {
2084
2099
  if (bodyFormat !== null && !KNOWN_BODY_FORMATS.has(bodyFormat)) {
2085
2100
  throw unknownFormatError(bodyFormat);
2086
2101
  }
2087
- const body = request.clone();
2102
+ const body = request.body !== null ? request.clone() : new Response(null, {
2103
+ headers: request.headers
2104
+ });
2088
2105
  let decoded;
2089
2106
  if (bodyFormat === BodyFormat.Serialized) {
2090
2107
  let argumentCodec = argumentCodecFor(codec);
@@ -3371,7 +3388,7 @@ async function handleServerFunctionRequest(request, options = {}) {
3371
3388
  return finish(protectsRequest ? withCSRFVary(response) : response);
3372
3389
  }
3373
3390
  const commitResponse = raw => {
3374
- if ((method === "GET" || method === "HEAD") && (sharedCacheMayStore(departingHeader(raw, event, "Cache-Control")) || cdnMayStore(departingHeader(raw, event, "CDN-Cache-Control")))) {
3391
+ if ((method === "GET" || method === "HEAD") && sharedCacheMayStore(departingHeader(raw, event, "Cache-Control"), departingHeader(raw, event, "CDN-Cache-Control"))) {
3375
3392
  withholdTrace(event);
3376
3393
  }
3377
3394
  return commitEventResponse(raw, event);
@@ -3614,41 +3631,6 @@ function departingHeader(response, event, name) {
3614
3631
  const stub = event.response;
3615
3632
  return stub && stub.headers && !stub.committed ? stub.headers.get(name) : null;
3616
3633
  }
3617
- function cdnMayStore(cdnCacheControl) {
3618
- return cdnCacheControl !== null && !forbidsStoring(cdnCacheControl);
3619
- }
3620
- function sharedCacheMayStore(cacheControl) {
3621
- let shared = false;
3622
- return !!cacheControl && !eachDirective(cacheControl, name => {
3623
- if (name === "public" || name === "s-maxage") shared = true;
3624
- }) && shared;
3625
- }
3626
- function forbidsStoring(value) {
3627
- return eachDirective(value, () => {});
3628
- }
3629
- function eachDirective(value, visit) {
3630
- let start = 0;
3631
- let quoted = false;
3632
- for (let i = 0; i <= value.length; i++) {
3633
- const c = value[i];
3634
- if (quoted) {
3635
- if (c === "\\") i++;else if (c === '"') quoted = false;
3636
- continue;
3637
- }
3638
- if (c === '"') {
3639
- quoted = true;
3640
- continue;
3641
- }
3642
- if (c !== "," && i < value.length) continue;
3643
- const directive = value.slice(start, i);
3644
- start = i + 1;
3645
- const eq = directive.indexOf("=");
3646
- const name = (eq === -1 ? directive : directive.slice(0, eq)).trim().toLowerCase();
3647
- if (name === "no-store" || name === "private" && eq === -1) return true;
3648
- visit(name);
3649
- }
3650
- return false;
3651
- }
3652
3634
  function withholdTrace(event) {
3653
3635
  if (event.response && event.response.committed) return;
3654
3636
  traceForEvent(event).emit = false;
@@ -181,6 +181,20 @@ function mergeServerTiming(target, value) {
181
181
  target.append("Server-Timing", trimmed);
182
182
  }
183
183
  }
184
+ function sharedCacheMayStore(cacheControl, cdnCacheControl) {
185
+ return mayStore(cacheControl, true) || mayStore(cdnCacheControl, false);
186
+ }
187
+ const DIRECTIVE = /([^\s=,]+)\s*(=\s*(?:"(?:[^"\\]|\\.)*"?|[^,]*))?/g;
188
+ function mayStore(value, asks) {
189
+ if (value === null) return false;
190
+ let shared = !asks;
191
+ for (const [, directive, argument] of value.matchAll(DIRECTIVE)) {
192
+ const name = directive.toLowerCase();
193
+ if (name === "no-store" || name === "private" && !argument) return false;
194
+ if (name === "public" || name === "s-maxage") shared = true;
195
+ }
196
+ return shared;
197
+ }
184
198
 
185
199
  function records() {
186
200
  return undefined;
@@ -1935,6 +1949,7 @@ function withBufferedBody(request, body) {
1935
1949
  });
1936
1950
  }
1937
1951
  const KNOWN_BODY_FORMATS = new Set(Object.values(BodyFormat));
1952
+ const EMPTY_BODY_FORMATS = new Set([BodyFormat.String, BodyFormat.URLSearchParams, BodyFormat.Blob, BodyFormat.ArrayBuffer, BodyFormat.Uint8Array]);
1938
1953
  const FORMAT_SKEW = Symbol("solid.serverFunction.formatSkew");
1939
1954
  function unknownFormatError(tag) {
1940
1955
  const error = new TypeError(`Server function body carries an unrecognized ${BODY_FORMAT_HEADER} tag ("${tag}"): the ` + "caller encodes a newer wire format than this build can decode (version skew), or an " + "intermediary duplicated the header. The body was refused rather than reinterpreted.");
@@ -1998,11 +2013,13 @@ async function parseArguments(request, url, scripted, codec, buffered) {
1998
2013
  } else if (!args && url.search && (request.method === "GET" || request.method === "HEAD")) {
1999
2014
  parsed.push(url.searchParams);
2000
2015
  }
2001
- if (request.method === "POST" && request.body !== null) {
2016
+ if (request.method === "POST" && (request.body !== null || EMPTY_BODY_FORMATS.has(bodyFormat))) {
2002
2017
  if (bodyFormat !== null && !KNOWN_BODY_FORMATS.has(bodyFormat)) {
2003
2018
  throw unknownFormatError(bodyFormat);
2004
2019
  }
2005
- const body = request.clone();
2020
+ const body = request.body !== null ? request.clone() : new Response(null, {
2021
+ headers: request.headers
2022
+ });
2006
2023
  let decoded;
2007
2024
  if (bodyFormat === BodyFormat.Serialized) {
2008
2025
  let argumentCodec = argumentCodecFor(codec);
@@ -3278,7 +3295,7 @@ async function handleServerFunctionRequest(request, options = {}) {
3278
3295
  return finish(protectsRequest ? withCSRFVary(response) : response);
3279
3296
  }
3280
3297
  const commitResponse = raw => {
3281
- if ((method === "GET" || method === "HEAD") && (sharedCacheMayStore(departingHeader(raw, event, "Cache-Control")) || cdnMayStore(departingHeader(raw, event, "CDN-Cache-Control")))) {
3298
+ if ((method === "GET" || method === "HEAD") && sharedCacheMayStore(departingHeader(raw, event, "Cache-Control"), departingHeader(raw, event, "CDN-Cache-Control"))) {
3282
3299
  withholdTrace(event);
3283
3300
  }
3284
3301
  return commitEventResponse(raw, event);
@@ -3521,41 +3538,6 @@ function departingHeader(response, event, name) {
3521
3538
  const stub = event.response;
3522
3539
  return stub && stub.headers && !stub.committed ? stub.headers.get(name) : null;
3523
3540
  }
3524
- function cdnMayStore(cdnCacheControl) {
3525
- return cdnCacheControl !== null && !forbidsStoring(cdnCacheControl);
3526
- }
3527
- function sharedCacheMayStore(cacheControl) {
3528
- let shared = false;
3529
- return !!cacheControl && !eachDirective(cacheControl, name => {
3530
- if (name === "public" || name === "s-maxage") shared = true;
3531
- }) && shared;
3532
- }
3533
- function forbidsStoring(value) {
3534
- return eachDirective(value, () => {});
3535
- }
3536
- function eachDirective(value, visit) {
3537
- let start = 0;
3538
- let quoted = false;
3539
- for (let i = 0; i <= value.length; i++) {
3540
- const c = value[i];
3541
- if (quoted) {
3542
- if (c === "\\") i++;else if (c === '"') quoted = false;
3543
- continue;
3544
- }
3545
- if (c === '"') {
3546
- quoted = true;
3547
- continue;
3548
- }
3549
- if (c !== "," && i < value.length) continue;
3550
- const directive = value.slice(start, i);
3551
- start = i + 1;
3552
- const eq = directive.indexOf("=");
3553
- const name = (eq === -1 ? directive : directive.slice(0, eq)).trim().toLowerCase();
3554
- if (name === "no-store" || name === "private" && eq === -1) return true;
3555
- visit(name);
3556
- }
3557
- return false;
3558
- }
3559
3541
  function withholdTrace(event) {
3560
3542
  if (event.response && event.response.committed) return;
3561
3543
  traceForEvent(event).emit = false;
@@ -210,6 +210,20 @@ function mergeServerTiming(target, value) {
210
210
  target.append("Server-Timing", trimmed);
211
211
  }
212
212
  }
213
+ function sharedCacheMayStore(cacheControl, cdnCacheControl) {
214
+ return mayStore(cacheControl, true) || mayStore(cdnCacheControl, false);
215
+ }
216
+ const DIRECTIVE = /([^\s=,]+)\s*(=\s*(?:"(?:[^"\\]|\\.)*"?|[^,]*))?/g;
217
+ function mayStore(value, asks) {
218
+ if (value === null) return false;
219
+ let shared = !asks;
220
+ for (const [, directive, argument] of value.matchAll(DIRECTIVE)) {
221
+ const name = directive.toLowerCase();
222
+ if (name === "no-store" || name === "private" && !argument) return false;
223
+ if (name === "public" || name === "s-maxage") shared = true;
224
+ }
225
+ return shared;
226
+ }
213
227
 
214
228
  const RECORDS = Symbol.for("@solidjs/signals/observe/records");
215
229
  function records() {
@@ -1987,6 +2001,7 @@ function withBufferedBody(request, body) {
1987
2001
  });
1988
2002
  }
1989
2003
  const KNOWN_BODY_FORMATS = new Set(Object.values(BodyFormat));
2004
+ const EMPTY_BODY_FORMATS = new Set([BodyFormat.String, BodyFormat.URLSearchParams, BodyFormat.Blob, BodyFormat.ArrayBuffer, BodyFormat.Uint8Array]);
1990
2005
  const FORMAT_SKEW = Symbol("solid.serverFunction.formatSkew");
1991
2006
  function unknownFormatError(tag) {
1992
2007
  const error = new TypeError(`Server function body carries an unrecognized ${BODY_FORMAT_HEADER} tag ("${tag}"): the ` + "caller encodes a newer wire format than this build can decode (version skew), or an " + "intermediary duplicated the header. The body was refused rather than reinterpreted.");
@@ -2050,11 +2065,13 @@ async function parseArguments(request, url, scripted, codec, buffered) {
2050
2065
  } else if (!args && url.search && (request.method === "GET" || request.method === "HEAD")) {
2051
2066
  parsed.push(url.searchParams);
2052
2067
  }
2053
- if (request.method === "POST" && request.body !== null) {
2068
+ if (request.method === "POST" && (request.body !== null || EMPTY_BODY_FORMATS.has(bodyFormat))) {
2054
2069
  if (bodyFormat !== null && !KNOWN_BODY_FORMATS.has(bodyFormat)) {
2055
2070
  throw unknownFormatError(bodyFormat);
2056
2071
  }
2057
- const body = request.clone();
2072
+ const body = request.body !== null ? request.clone() : new Response(null, {
2073
+ headers: request.headers
2074
+ });
2058
2075
  let decoded;
2059
2076
  if (bodyFormat === BodyFormat.Serialized) {
2060
2077
  let argumentCodec = argumentCodecFor(codec);
@@ -3341,7 +3358,7 @@ async function handleServerFunctionRequest(request, options = {}) {
3341
3358
  return finish(protectsRequest ? withCSRFVary(response) : response);
3342
3359
  }
3343
3360
  const commitResponse = raw => {
3344
- if ((method === "GET" || method === "HEAD") && (sharedCacheMayStore(departingHeader(raw, event, "Cache-Control")) || cdnMayStore(departingHeader(raw, event, "CDN-Cache-Control")))) {
3361
+ if ((method === "GET" || method === "HEAD") && sharedCacheMayStore(departingHeader(raw, event, "Cache-Control"), departingHeader(raw, event, "CDN-Cache-Control"))) {
3345
3362
  withholdTrace(event);
3346
3363
  }
3347
3364
  return commitEventResponse(raw, event);
@@ -3584,41 +3601,6 @@ function departingHeader(response, event, name) {
3584
3601
  const stub = event.response;
3585
3602
  return stub && stub.headers && !stub.committed ? stub.headers.get(name) : null;
3586
3603
  }
3587
- function cdnMayStore(cdnCacheControl) {
3588
- return cdnCacheControl !== null && !forbidsStoring(cdnCacheControl);
3589
- }
3590
- function sharedCacheMayStore(cacheControl) {
3591
- let shared = false;
3592
- return !!cacheControl && !eachDirective(cacheControl, name => {
3593
- if (name === "public" || name === "s-maxage") shared = true;
3594
- }) && shared;
3595
- }
3596
- function forbidsStoring(value) {
3597
- return eachDirective(value, () => {});
3598
- }
3599
- function eachDirective(value, visit) {
3600
- let start = 0;
3601
- let quoted = false;
3602
- for (let i = 0; i <= value.length; i++) {
3603
- const c = value[i];
3604
- if (quoted) {
3605
- if (c === "\\") i++;else if (c === '"') quoted = false;
3606
- continue;
3607
- }
3608
- if (c === '"') {
3609
- quoted = true;
3610
- continue;
3611
- }
3612
- if (c !== "," && i < value.length) continue;
3613
- const directive = value.slice(start, i);
3614
- start = i + 1;
3615
- const eq = directive.indexOf("=");
3616
- const name = (eq === -1 ? directive : directive.slice(0, eq)).trim().toLowerCase();
3617
- if (name === "no-store" || name === "private" && eq === -1) return true;
3618
- visit(name);
3619
- }
3620
- return false;
3621
- }
3622
3604
  function withholdTrace(event) {
3623
3605
  if (event.response && event.response.committed) return;
3624
3606
  traceForEvent(event).emit = false;
package/types/client.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { getOwner, createComponent, untrack, merge as mergeProps, heldRead } from "solid-js";
1
+ import { getOwner, createComponent, untrack, merge as mergeProps } from "solid-js";
2
2
  import type { ClientErrorHook, Owner } from "solid-js";
3
+ import { heldRead } from "solid-js/internal";
3
4
  import { effect, memo } from "./render.js";
4
5
  import { JSX } from "./jsx.js";
5
6
  import type { RequestEventLocals, HydrationWriter, HydrationValue, LinkClaimHandler } from "./server.js";
package/types/trace.d.ts CHANGED
@@ -125,3 +125,21 @@ export declare function mergeServerTiming(target: Headers, value: string): void;
125
125
  * prelude (after charset/base). Empty when the browser is not told.
126
126
  */
127
127
  export declare function traceMetaMarkup(record: TraceRecord): string;
128
+ export declare function sharedCacheMayStore(cacheControl: string | null, cdnCacheControl: string | null): boolean;
129
+ /**
130
+ * #4938: a document a shared cache may store, by the head it will leave with
131
+ * (the request event's response stub), tells no viewer the request's trace —
132
+ * neither `<meta>` nor `Server-Timing`. The cache replays that one response
133
+ * to every viewer, so each would parent its browser spans to the request
134
+ * that filled the cache, and per-request bytes in the body defeat ETag
135
+ * revalidation. Decided where the shell head is written, which reads the
136
+ * stub after the shell rendered (an `httpHeader("Cache-Control", …)` in the
137
+ * shell is there); the commit then reads the same record. The server-function
138
+ * road decides the same at its own commit (#4022). `getTraceContext()` is
139
+ * untouched.
140
+ */
141
+ export declare function withholdForSharedCache(record: TraceRecord, event: {
142
+ response?: {
143
+ headers?: Headers;
144
+ };
145
+ } | undefined): void;