@solidjs/web 2.0.0-beta.6 → 2.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.cjs CHANGED
@@ -5,39 +5,6 @@ var seroval = require('seroval');
5
5
  var web = require('seroval-plugins/web');
6
6
  var signals = require('@solidjs/signals');
7
7
 
8
- const DOMWithState = {
9
- INPUT: {
10
- value: 1,
11
- defaultValue: 1,
12
- checked: 1,
13
- defaultChecked: 1
14
- },
15
- SELECT: {
16
- value: 1
17
- },
18
- OPTION: {
19
- value: 1,
20
- selected: 1,
21
- defaultSelected: 1
22
- },
23
- TEXTAREA: {
24
- value: 1,
25
- defaultValue: 1
26
- },
27
- VIDEO: {
28
- muted: 1,
29
- defaultMuted: 1
30
- },
31
- AUDIO: {
32
- muted: 1,
33
- defaultMuted: 1
34
- }
35
- };
36
- for (const tagName in DOMWithState) {
37
- for (const propName in DOMWithState[tagName]) {
38
- DOMWithState[tagName]["prop:" + propName] = 1;
39
- }
40
- }
41
8
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
42
9
  const DelegatedEvents = /*#__PURE__*/new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
43
10
  const SVGElements = /*#__PURE__*/new Set([
@@ -56,10 +23,10 @@ const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta"
56
23
  "webview",
57
24
  "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
58
25
 
59
- const effect = (fn, effectFn, initial) => solidJs.createRenderEffect(fn, effectFn, initial, {
26
+ const effect = (fn, effectFn) => solidJs.createRenderEffect(fn, effectFn, {
60
27
  transparent: true
61
28
  });
62
- const memo = (fn, transparent) => transparent ? fn.$r ? fn : signals.createMemo(() => fn(), undefined, {
29
+ const memo = (fn, transparent) => transparent ? fn.$r ? fn : signals.createMemo(() => fn(), {
63
30
  transparent: true
64
31
  }) : solidJs.createMemo(() => fn());
65
32
 
@@ -144,11 +111,11 @@ function createAssetTracking() {
144
111
  currentBoundaryId = v;
145
112
  },
146
113
  registerModule(moduleUrl, entryUrl) {
147
- if (!currentBoundaryId) return;
148
- let map = boundaryModules.get(currentBoundaryId);
114
+ const id = currentBoundaryId || "";
115
+ let map = boundaryModules.get(id);
149
116
  if (!map) {
150
117
  map = {};
151
- boundaryModules.set(currentBoundaryId, map);
118
+ boundaryModules.set(id, map);
152
119
  }
153
120
  map[moduleUrl] = entryUrl;
154
121
  },
@@ -231,6 +198,7 @@ function renderToString(code, options = {}) {
231
198
  }, {
232
199
  id: renderId
233
200
  });
201
+ serializeFragmentAssets("", tracking.boundaryModules, solidJs.sharedConfig.context);
234
202
  solidJs.sharedConfig.context.noHydrate = true;
235
203
  serializer.close();
236
204
  html = injectAssets(solidJs.sharedConfig.context.assets, html);
@@ -249,10 +217,12 @@ function renderToStream(code, options = {}) {
249
217
  } = options;
250
218
  let dispose;
251
219
  const blockingPromises = new Set();
220
+ let headerEmitted = false;
252
221
  const pushTask = task => {
253
222
  if (noScripts) return;
254
- if (!tasks && !firstFlushed) {
255
- tasks = getLocalHeaderScript(renderId);
223
+ if (!headerEmitted) {
224
+ headerEmitted = true;
225
+ tasks += getLocalHeaderScript(renderId);
256
226
  }
257
227
  tasks += task + ";";
258
228
  if (!timer && firstFlushed) {
@@ -487,13 +457,32 @@ function renderToStream(code, options = {}) {
487
457
  function doShell() {
488
458
  if (shellCompleted) return;
489
459
  if (rootHoles) {
460
+ const pending = [];
490
461
  for (const {
491
462
  id,
492
463
  fn
493
464
  } of rootHoles) {
494
465
  const marker = `<!--rh${id}-->`;
495
466
  const res = resolveSSRNode(fn);
496
- html = html.replace(marker, !res.h.length ? res.t[0] : "");
467
+ if (!res.h.length) {
468
+ html = html.replace(marker, res.t[0]);
469
+ } else {
470
+ let out = res.t[0];
471
+ for (let j = 0; j < res.h.length; j++) {
472
+ const newId = nextHoleId++;
473
+ pending.push({
474
+ id: newId,
475
+ fn: res.h[j]
476
+ });
477
+ out += `<!--rh${newId}-->` + res.t[j + 1];
478
+ }
479
+ html = html.replace(marker, out);
480
+ for (const p of res.p) blockingPromises.add(p);
481
+ }
482
+ }
483
+ if (pending.length) {
484
+ rootHoles = pending;
485
+ return;
497
486
  }
498
487
  rootHoles = null;
499
488
  }
@@ -504,6 +493,7 @@ function renderToStream(code, options = {}) {
504
493
  if (url.endsWith(".css")) headStyles.add(url);
505
494
  }
506
495
  html = injectPreloadLinks(tracking.emittedAssets, html);
496
+ serializeFragmentAssets("", tracking.boundaryModules, context);
507
497
  if (tasks.length) html = injectScripts(html, tasks, nonce);
508
498
  buffer.write(html);
509
499
  tasks = "";
@@ -530,48 +520,56 @@ function renderToStream(code, options = {}) {
530
520
  queue(flushEnd);
531
521
  },
532
522
  pipe(w) {
533
- allSettled(blockingPromises).then(() => {
534
- setTimeout(() => {
535
- doShell();
536
- buffer = writable = w;
537
- buffer.write(tmp);
538
- firstFlushed = true;
539
- if (completed) {
540
- dispose();
541
- writable.end();
542
- } else flushEnd();
523
+ function flush() {
524
+ allSettled(blockingPromises).then(() => {
525
+ setTimeout(() => {
526
+ doShell();
527
+ if (!shellCompleted) return flush();
528
+ buffer = writable = w;
529
+ buffer.write(tmp);
530
+ firstFlushed = true;
531
+ if (completed) {
532
+ dispose();
533
+ writable.end();
534
+ } else flushEnd();
535
+ });
543
536
  });
544
- });
537
+ }
538
+ flush();
545
539
  },
546
540
  pipeTo(w) {
547
- return allSettled(blockingPromises).then(() => {
548
- let resolve;
549
- const p = new Promise(r => resolve = r);
550
- setTimeout(() => {
551
- doShell();
552
- const encoder = new TextEncoder();
553
- const writer = w.getWriter();
554
- writable = {
555
- end() {
556
- writer.releaseLock();
557
- w.close().catch(() => {});
558
- resolve();
559
- }
560
- };
561
- buffer = {
562
- write(payload) {
563
- writer.write(encoder.encode(payload)).catch(() => {});
564
- }
565
- };
566
- buffer.write(tmp);
567
- firstFlushed = true;
568
- if (completed) {
569
- dispose();
570
- writable.end();
571
- } else flushEnd();
541
+ let resolve;
542
+ const p = new Promise(r => resolve = r);
543
+ function flush() {
544
+ allSettled(blockingPromises).then(() => {
545
+ setTimeout(() => {
546
+ doShell();
547
+ if (!shellCompleted) return flush();
548
+ const encoder = new TextEncoder();
549
+ const writer = w.getWriter();
550
+ writable = {
551
+ end() {
552
+ writer.releaseLock();
553
+ w.close().catch(() => {});
554
+ resolve();
555
+ }
556
+ };
557
+ buffer = {
558
+ write(payload) {
559
+ writer.write(encoder.encode(payload)).catch(() => {});
560
+ }
561
+ };
562
+ buffer.write(tmp);
563
+ firstFlushed = true;
564
+ if (completed) {
565
+ dispose();
566
+ writable.end();
567
+ } else flushEnd();
568
+ });
572
569
  });
573
- return p;
574
- });
570
+ }
571
+ flush();
572
+ return p;
575
573
  }
576
574
  };
577
575
  }
package/dist/server.js CHANGED
@@ -4,39 +4,6 @@ import { Serializer, Feature, getCrossReferenceHeader } from 'seroval';
4
4
  import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
5
5
  import { createMemo } from '@solidjs/signals';
6
6
 
7
- const DOMWithState = {
8
- INPUT: {
9
- value: 1,
10
- defaultValue: 1,
11
- checked: 1,
12
- defaultChecked: 1
13
- },
14
- SELECT: {
15
- value: 1
16
- },
17
- OPTION: {
18
- value: 1,
19
- selected: 1,
20
- defaultSelected: 1
21
- },
22
- TEXTAREA: {
23
- value: 1,
24
- defaultValue: 1
25
- },
26
- VIDEO: {
27
- muted: 1,
28
- defaultMuted: 1
29
- },
30
- AUDIO: {
31
- muted: 1,
32
- defaultMuted: 1
33
- }
34
- };
35
- for (const tagName in DOMWithState) {
36
- for (const propName in DOMWithState[tagName]) {
37
- DOMWithState[tagName]["prop:" + propName] = 1;
38
- }
39
- }
40
7
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
41
8
  const DelegatedEvents = /*#__PURE__*/new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
42
9
  const SVGElements = /*#__PURE__*/new Set([
@@ -55,10 +22,10 @@ const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta"
55
22
  "webview",
56
23
  "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
57
24
 
58
- const effect = (fn, effectFn, initial) => createRenderEffect(fn, effectFn, initial, {
25
+ const effect = (fn, effectFn) => createRenderEffect(fn, effectFn, {
59
26
  transparent: true
60
27
  });
61
- const memo = (fn, transparent) => transparent ? fn.$r ? fn : createMemo(() => fn(), undefined, {
28
+ const memo = (fn, transparent) => transparent ? fn.$r ? fn : createMemo(() => fn(), {
62
29
  transparent: true
63
30
  }) : createMemo$1(() => fn());
64
31
 
@@ -143,11 +110,11 @@ function createAssetTracking() {
143
110
  currentBoundaryId = v;
144
111
  },
145
112
  registerModule(moduleUrl, entryUrl) {
146
- if (!currentBoundaryId) return;
147
- let map = boundaryModules.get(currentBoundaryId);
113
+ const id = currentBoundaryId || "";
114
+ let map = boundaryModules.get(id);
148
115
  if (!map) {
149
116
  map = {};
150
- boundaryModules.set(currentBoundaryId, map);
117
+ boundaryModules.set(id, map);
151
118
  }
152
119
  map[moduleUrl] = entryUrl;
153
120
  },
@@ -230,6 +197,7 @@ function renderToString(code, options = {}) {
230
197
  }, {
231
198
  id: renderId
232
199
  });
200
+ serializeFragmentAssets("", tracking.boundaryModules, sharedConfig.context);
233
201
  sharedConfig.context.noHydrate = true;
234
202
  serializer.close();
235
203
  html = injectAssets(sharedConfig.context.assets, html);
@@ -248,10 +216,12 @@ function renderToStream(code, options = {}) {
248
216
  } = options;
249
217
  let dispose;
250
218
  const blockingPromises = new Set();
219
+ let headerEmitted = false;
251
220
  const pushTask = task => {
252
221
  if (noScripts) return;
253
- if (!tasks && !firstFlushed) {
254
- tasks = getLocalHeaderScript(renderId);
222
+ if (!headerEmitted) {
223
+ headerEmitted = true;
224
+ tasks += getLocalHeaderScript(renderId);
255
225
  }
256
226
  tasks += task + ";";
257
227
  if (!timer && firstFlushed) {
@@ -486,13 +456,32 @@ function renderToStream(code, options = {}) {
486
456
  function doShell() {
487
457
  if (shellCompleted) return;
488
458
  if (rootHoles) {
459
+ const pending = [];
489
460
  for (const {
490
461
  id,
491
462
  fn
492
463
  } of rootHoles) {
493
464
  const marker = `<!--rh${id}-->`;
494
465
  const res = resolveSSRNode(fn);
495
- html = html.replace(marker, !res.h.length ? res.t[0] : "");
466
+ if (!res.h.length) {
467
+ html = html.replace(marker, res.t[0]);
468
+ } else {
469
+ let out = res.t[0];
470
+ for (let j = 0; j < res.h.length; j++) {
471
+ const newId = nextHoleId++;
472
+ pending.push({
473
+ id: newId,
474
+ fn: res.h[j]
475
+ });
476
+ out += `<!--rh${newId}-->` + res.t[j + 1];
477
+ }
478
+ html = html.replace(marker, out);
479
+ for (const p of res.p) blockingPromises.add(p);
480
+ }
481
+ }
482
+ if (pending.length) {
483
+ rootHoles = pending;
484
+ return;
496
485
  }
497
486
  rootHoles = null;
498
487
  }
@@ -503,6 +492,7 @@ function renderToStream(code, options = {}) {
503
492
  if (url.endsWith(".css")) headStyles.add(url);
504
493
  }
505
494
  html = injectPreloadLinks(tracking.emittedAssets, html);
495
+ serializeFragmentAssets("", tracking.boundaryModules, context);
506
496
  if (tasks.length) html = injectScripts(html, tasks, nonce);
507
497
  buffer.write(html);
508
498
  tasks = "";
@@ -529,48 +519,56 @@ function renderToStream(code, options = {}) {
529
519
  queue(flushEnd);
530
520
  },
531
521
  pipe(w) {
532
- allSettled(blockingPromises).then(() => {
533
- setTimeout(() => {
534
- doShell();
535
- buffer = writable = w;
536
- buffer.write(tmp);
537
- firstFlushed = true;
538
- if (completed) {
539
- dispose();
540
- writable.end();
541
- } else flushEnd();
522
+ function flush() {
523
+ allSettled(blockingPromises).then(() => {
524
+ setTimeout(() => {
525
+ doShell();
526
+ if (!shellCompleted) return flush();
527
+ buffer = writable = w;
528
+ buffer.write(tmp);
529
+ firstFlushed = true;
530
+ if (completed) {
531
+ dispose();
532
+ writable.end();
533
+ } else flushEnd();
534
+ });
542
535
  });
543
- });
536
+ }
537
+ flush();
544
538
  },
545
539
  pipeTo(w) {
546
- return allSettled(blockingPromises).then(() => {
547
- let resolve;
548
- const p = new Promise(r => resolve = r);
549
- setTimeout(() => {
550
- doShell();
551
- const encoder = new TextEncoder();
552
- const writer = w.getWriter();
553
- writable = {
554
- end() {
555
- writer.releaseLock();
556
- w.close().catch(() => {});
557
- resolve();
558
- }
559
- };
560
- buffer = {
561
- write(payload) {
562
- writer.write(encoder.encode(payload)).catch(() => {});
563
- }
564
- };
565
- buffer.write(tmp);
566
- firstFlushed = true;
567
- if (completed) {
568
- dispose();
569
- writable.end();
570
- } else flushEnd();
540
+ let resolve;
541
+ const p = new Promise(r => resolve = r);
542
+ function flush() {
543
+ allSettled(blockingPromises).then(() => {
544
+ setTimeout(() => {
545
+ doShell();
546
+ if (!shellCompleted) return flush();
547
+ const encoder = new TextEncoder();
548
+ const writer = w.getWriter();
549
+ writable = {
550
+ end() {
551
+ writer.releaseLock();
552
+ w.close().catch(() => {});
553
+ resolve();
554
+ }
555
+ };
556
+ buffer = {
557
+ write(payload) {
558
+ writer.write(encoder.encode(payload)).catch(() => {});
559
+ }
560
+ };
561
+ buffer.write(tmp);
562
+ firstFlushed = true;
563
+ if (completed) {
564
+ dispose();
565
+ writable.end();
566
+ } else flushEnd();
567
+ });
571
568
  });
572
- return p;
573
- });
569
+ }
570
+ flush();
571
+ return p;
574
572
  }
575
573
  };
576
574
  }