@solidjs/web 2.0.0-rc.4 → 2.0.0-rc.6

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 (61) hide show
  1. package/dist/dev.cjs +163 -36
  2. package/dist/dev.js +161 -37
  3. package/dist/server.cjs +178 -37
  4. package/dist/server.js +177 -38
  5. package/dist/web.cjs +143 -36
  6. package/dist/web.js +141 -37
  7. package/frames/dist/client.cjs +41 -8
  8. package/frames/dist/client.dev.cjs +41 -8
  9. package/frames/dist/client.dev.js +41 -8
  10. package/frames/dist/client.js +41 -8
  11. package/frames/dist/server.cjs +497 -44
  12. package/frames/dist/server.js +497 -44
  13. package/package.json +2 -2
  14. package/serialization/dist/decode.cjs +4 -2
  15. package/serialization/dist/decode.js +4 -2
  16. package/serialization/dist/serialization.cjs +12 -8
  17. package/serialization/dist/serialization.js +12 -8
  18. package/serialization/types/index.d.ts +7 -0
  19. package/serialization/types/serializer-decode.d.ts +14 -1
  20. package/serialization/types/serializer.d.ts +7 -0
  21. package/serialization/types-cjs/index.d.cts +7 -0
  22. package/serialization/types-cjs/serializer-decode.d.cts +14 -1
  23. package/serialization/types-cjs/serializer.d.cts +7 -0
  24. package/server-functions/dist/client.cjs +164 -35
  25. package/server-functions/dist/client.js +161 -36
  26. package/server-functions/dist/server.cjs +899 -136
  27. package/server-functions/dist/server.dev.cjs +919 -136
  28. package/server-functions/dist/server.dev.js +915 -137
  29. package/server-functions/dist/server.js +895 -137
  30. package/types/client.d.ts +2 -1
  31. package/types/constants.d.ts +3 -1
  32. package/types/cookies.d.ts +6 -14
  33. package/types/frames/frame-client.d.ts +4 -0
  34. package/types/frames/serializer-decode.d.ts +14 -1
  35. package/types/frames/serializer.d.ts +7 -0
  36. package/types/jsx.d.ts +11 -16
  37. package/types/response.d.ts +11 -0
  38. package/types/serializer-decode.d.ts +14 -1
  39. package/types/serializer.d.ts +7 -0
  40. package/types/server-functions/client.d.ts +22 -2
  41. package/types/server-functions/flash.d.ts +9 -0
  42. package/types/server-functions/server.d.ts +131 -11
  43. package/types/server-functions/shared.d.ts +77 -14
  44. package/types/server-mock.d.ts +17 -2
  45. package/types/server.d.ts +16 -2
  46. package/types-cjs/client.d.cts +2 -1
  47. package/types-cjs/constants.d.cts +3 -1
  48. package/types-cjs/cookies.d.cts +6 -14
  49. package/types-cjs/frames/frame-client.d.cts +4 -0
  50. package/types-cjs/frames/serializer-decode.d.cts +14 -1
  51. package/types-cjs/frames/serializer.d.cts +7 -0
  52. package/types-cjs/jsx.d.cts +11 -16
  53. package/types-cjs/response.d.cts +11 -0
  54. package/types-cjs/serializer-decode.d.cts +14 -1
  55. package/types-cjs/serializer.d.cts +7 -0
  56. package/types-cjs/server-functions/client.d.cts +22 -2
  57. package/types-cjs/server-functions/flash.d.cts +9 -0
  58. package/types-cjs/server-functions/server.d.cts +131 -11
  59. package/types-cjs/server-functions/shared.d.cts +77 -14
  60. package/types-cjs/server-mock.d.cts +17 -2
  61. package/types-cjs/server.d.cts +16 -2
@@ -175,7 +175,18 @@ function createFrameHost(options = {}) {
175
175
  store.version = version;
176
176
  clearStreamRecords(store.records);
177
177
  }
178
- Object.assign(store.records, records);
178
+ const assets = records["seg::assets"];
179
+ const previous = assets && store.records["seg::assets"];
180
+ if (!previous || previous === assets) {
181
+ Object.assign(store.records, records);
182
+ } else {
183
+ for (const name in assets) {
184
+ const values = assets[name];
185
+ if (Array.isArray(values)) {
186
+ previous[name] ? previous[name].push(...values) : previous[name] = values;
187
+ }
188
+ }
189
+ }
179
190
  return true;
180
191
  };
181
192
  return {
@@ -267,7 +278,7 @@ class FrameImpl {
267
278
  #slotRegions = new Map();
268
279
  #slotResolvedRefs = new Map();
269
280
  #slotNodes = new Map();
270
- #processedAssets = new Set();
281
+ #processedAssets = new WeakSet();
271
282
  #recordRefresh = null;
272
283
  #disposed = false;
273
284
  #styleFlush = () => {
@@ -368,6 +379,7 @@ class FrameImpl {
368
379
  this.#revealed.clear();
369
380
  this.#fallbackShown.clear();
370
381
  this.#appliedHoles.clear();
382
+ this.#processedAssets = new WeakSet();
371
383
  this.#errorNotified = false;
372
384
  clearStreamRecords(this.#store, root);
373
385
  }
@@ -427,12 +439,17 @@ class FrameImpl {
427
439
  }
428
440
  }
429
441
  for (const key in this.#store) {
430
- if (this.#processedAssets.has(key) || !key.endsWith(":assets")) continue;
431
- this.#processedAssets.add(key);
432
442
  const record = this.#store[key];
433
- if (record && record.modules) {
443
+ if (!key.endsWith(":assets") || !record || this.#processedAssets.has(record)) {
444
+ continue;
445
+ }
446
+ this.#processedAssets.add(record);
447
+ if (record.modules) {
434
448
  for (const href of record.modules) ensureModulePreload(href);
435
449
  }
450
+ if (record.preloads) {
451
+ for (const entry of record.preloads) ensurePreload(entry);
452
+ }
436
453
  }
437
454
  this.#syncSlots();
438
455
  }
@@ -900,12 +917,28 @@ function parseFragment(html) {
900
917
  template.innerHTML = html;
901
918
  return template.content;
902
919
  }
903
- function findHeadElement(selector, attr, value) {
904
- for (const node of document.head.querySelectorAll(selector)) {
905
- if (node.getAttribute(attr) === value) return node;
920
+ const PRELOAD_QUALIFIERS = ["as", "crossorigin", "type", "media", "imagesrcset", "imagesizes"];
921
+ function findHeadElement(selector, attr, value, qualifiers) {
922
+ candidate: for (const node of document.head.querySelectorAll(selector)) {
923
+ if (node.getAttribute(attr) !== value) continue;
924
+ if (!qualifiers) return node;
925
+ for (let i = 0; i < PRELOAD_QUALIFIERS.length; i++) {
926
+ const name = PRELOAD_QUALIFIERS[i];
927
+ if (node.getAttribute(name) !== (qualifiers[name] ?? null)) continue candidate;
928
+ }
929
+ return node;
906
930
  }
907
931
  return null;
908
932
  }
933
+ function ensurePreload(entry) {
934
+ const attrs = entry.attrs;
935
+ if (findHeadElement('link[rel="preload"]', "href", entry.href, attrs)) return;
936
+ const link = document.createElement("link");
937
+ link.rel = "preload";
938
+ for (const name in attrs) link.setAttribute(name, attrs[name]);
939
+ link.setAttribute("href", entry.href);
940
+ document.head.appendChild(link);
941
+ }
909
942
  function ensureStylesheet(entry, onSettle) {
910
943
  const href = typeof entry === "string" ? entry : entry.href;
911
944
  let link = findHeadElement('link[rel="stylesheet"]', "href", href);