solid-js 1.3.0-beta.1 → 1.3.0-beta.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solid-js",
3
3
  "description": "A declarative JavaScript library for building user interfaces.",
4
- "version": "1.3.0-beta.1",
4
+ "version": "1.3.0-beta.2",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/solidjs/solid#readme",
@@ -132,5 +132,5 @@
132
132
  "compiler",
133
133
  "performance"
134
134
  ],
135
- "gitHead": "148c4c7d4f55842ec606364a972ce9abeb46c324"
135
+ "gitHead": "afe407af6463d4956c2c283370895b4d02b205e8"
136
136
  }
package/web/dist/dev.cjs CHANGED
@@ -219,11 +219,6 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}) {
219
219
  }
220
220
  }
221
221
  function hydrate(code, element) {
222
- if (!globalThis._$HY.sync) {
223
- let dispose;
224
- globalThis._$HY.queue.push(() => dispose = hydrate(code, element));
225
- return () => dispose();
226
- }
227
222
  solidJs.sharedConfig.completed = globalThis._$HY.completed;
228
223
  solidJs.sharedConfig.events = globalThis._$HY.events;
229
224
  solidJs.sharedConfig.load = globalThis._$HY.load;
package/web/dist/dev.js CHANGED
@@ -216,11 +216,6 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}) {
216
216
  }
217
217
  }
218
218
  function hydrate(code, element) {
219
- if (!globalThis._$HY.sync) {
220
- let dispose;
221
- globalThis._$HY.queue.push(() => dispose = hydrate(code, element));
222
- return () => dispose();
223
- }
224
219
  sharedConfig.completed = globalThis._$HY.completed;
225
220
  sharedConfig.events = globalThis._$HY.events;
226
221
  sharedConfig.load = globalThis._$HY.load;
@@ -233,7 +233,6 @@ function stringifyString(str) {
233
233
  }
234
234
 
235
235
  const REPLACE_SCRIPT = `function $df(e,t){t=document.getElementById(e),document.getElementById("pl"+e).replaceWith(...t.childNodes),_$HY.set(e)}`;
236
- const SYNC_SCRIPT = `_$HY.sync=!0;for(let e=0;e<_$HY.queue.length;e++)_$HY.queue[e]()`;
237
236
  function renderToString(code, options = {}) {
238
237
  solidJs.sharedConfig.context = {
239
238
  id: "",
@@ -243,7 +242,7 @@ function renderToString(code, options = {}) {
243
242
  nonce: options.nonce
244
243
  };
245
244
  let html = resolveSSRNode(escape(code()));
246
- return injectAssets(solidJs.sharedConfig.context.assets, html) + `<script${options.nonce ? ` nonce="${options.nonce}"` : ""}>${SYNC_SCRIPT}</script>`;
245
+ return injectAssets(solidJs.sharedConfig.context.assets, html);
247
246
  }
248
247
  function renderToStringAsync(code, options = {}) {
249
248
  const {
@@ -263,9 +262,9 @@ function renderToStringAsync(code, options = {}) {
263
262
  solidJs.sharedConfig.context.writeResource = (id, p) => p.then(d => scripts += `_$HY.set("${id}", ${devalue(d)});`);
264
263
  const timeout = new Promise((_, reject) => setTimeout(() => reject("renderToString timed out"), timeoutMs));
265
264
  return Promise.race([asyncWrap(() => escape(code())), timeout]).then(res => {
266
- let html = resolveSSRNode(res);
267
- html += `<script${nonce ? ` nonce="${nonce}"` : ""}>${scripts.length ? scripts + ";" : ""}${SYNC_SCRIPT}</script>`;
268
- return injectAssets(context.assets, html);
265
+ let html = injectAssets(context.assets, resolveSSRNode(res));
266
+ if (scripts.length) html = injectScripts(html, scripts, nonce);
267
+ return html;
269
268
  });
270
269
  }
271
270
  function renderToPipeableStream(code, options) {
@@ -342,7 +341,8 @@ function renderToPipeableStream(code, options) {
342
341
  let html = resolveSSRNode(escape(code()));
343
342
  html = injectAssets(solidJs.sharedConfig.context.assets, html);
344
343
  Promise.resolve().then(() => {
345
- buffer.write(html + `<script${nonce ? ` nonce="${nonce}"` : ""}>${tasks.length ? tasks.join(";") + ";" : ""}${SYNC_SCRIPT}</script>`);
344
+ if (tasks.length) html = injectScripts(html, tasks.join(";"), nonce);
345
+ buffer.write(html);
346
346
  tasks.length = 0;
347
347
  scheduled = false;
348
348
  onCompleteShell && onCompleteShell();
@@ -446,7 +446,8 @@ function pipeToWritable(code, writable, options = {}) {
446
446
  let html = resolveSSRNode(escape(code()));
447
447
  html = injectAssets(solidJs.sharedConfig.context.assets, html);
448
448
  Promise.resolve().then(() => {
449
- buffer.write(encoder.encode(html + `<script${nonce ? ` nonce="${nonce}"` : ""}>${tasks.length ? tasks.join(";") + ";" : ""}${SYNC_SCRIPT}</script>`));
449
+ if (tasks.length) html = injectScripts(html, tasks.join(";"), nonce);
450
+ buffer.write(encoder.encode(html));
450
451
  tasks.length = 0;
451
452
  scheduled = false;
452
453
  onCompleteShell && onCompleteShell(result);
@@ -611,7 +612,7 @@ function generateHydrationScript({
611
612
  eventNames = ["click", "input"],
612
613
  nonce
613
614
  }) {
614
- return `<script${nonce ? ` nonce="${nonce}"` : ""}>((e,t,o={})=>{t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host instanceof Node?e.host:e.parentNode)),["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{let n=o.composedPath&&o.composedPath()[0]||o.target,s=t(n);s&&!e.completed.has(s)&&e.events.push([s,o])})))),e.init=(e,t)=>{o[e]=[new Promise((e=>t=e)),t]},e.set=(e,t,n)=>{if(!(n=o[e]))return o[e]=[t];n[1](t)},e.load=(e,t)=>{if(t=o[e])return t[0]}})(window._$HY||(_$HY={events:[],completed:new WeakSet,queue:[]}));</script>`;
615
+ return `<script${nonce ? ` nonce="${nonce}"` : ""}>((e,t,o={})=>{t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host instanceof Node?e.host:e.parentNode)),["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{let n=o.composedPath&&o.composedPath()[0]||o.target,s=t(n);s&&!e.completed.has(s)&&e.events.push([s,o])})))),e.init=(e,t)=>{o[e]=[new Promise((e=>t=e)),t]},e.set=(e,t,n)=>{if(!(n=o[e]))return o[e]=[t];n[1](t)},e.load=(e,t)=>{if(t=o[e])return t[0]}})(window._$HY||(_$HY={events:[],completed:new WeakSet}));</script><!xs>`;
615
616
  }
616
617
  function injectAssets(assets, html) {
617
618
  for (let i = 0; i < assets.length; i++) {
@@ -619,6 +620,14 @@ function injectAssets(assets, html) {
619
620
  }
620
621
  return html;
621
622
  }
623
+ function injectScripts(html, scripts, nonce) {
624
+ const tag = `<script${nonce ? ` nonce="${nonce}"` : ""}>${scripts}</script>`;
625
+ const index = html.indexOf("<!xs>");
626
+ if (index > -1) {
627
+ return html.slice(0, index) + tag + html.slice(index);
628
+ }
629
+ return html + tag;
630
+ }
622
631
  const FRAGMENT_REPLACE = /<!\[([\d.]+)\]>/;
623
632
  function asyncWrap(fn) {
624
633
  return new Promise(resolve => {
@@ -230,7 +230,6 @@ function stringifyString(str) {
230
230
  }
231
231
 
232
232
  const REPLACE_SCRIPT = `function $df(e,t){t=document.getElementById(e),document.getElementById("pl"+e).replaceWith(...t.childNodes),_$HY.set(e)}`;
233
- const SYNC_SCRIPT = `_$HY.sync=!0;for(let e=0;e<_$HY.queue.length;e++)_$HY.queue[e]()`;
234
233
  function renderToString(code, options = {}) {
235
234
  sharedConfig.context = {
236
235
  id: "",
@@ -240,7 +239,7 @@ function renderToString(code, options = {}) {
240
239
  nonce: options.nonce
241
240
  };
242
241
  let html = resolveSSRNode(escape(code()));
243
- return injectAssets(sharedConfig.context.assets, html) + `<script${options.nonce ? ` nonce="${options.nonce}"` : ""}>${SYNC_SCRIPT}</script>`;
242
+ return injectAssets(sharedConfig.context.assets, html);
244
243
  }
245
244
  function renderToStringAsync(code, options = {}) {
246
245
  const {
@@ -260,9 +259,9 @@ function renderToStringAsync(code, options = {}) {
260
259
  sharedConfig.context.writeResource = (id, p) => p.then(d => scripts += `_$HY.set("${id}", ${devalue(d)});`);
261
260
  const timeout = new Promise((_, reject) => setTimeout(() => reject("renderToString timed out"), timeoutMs));
262
261
  return Promise.race([asyncWrap(() => escape(code())), timeout]).then(res => {
263
- let html = resolveSSRNode(res);
264
- html += `<script${nonce ? ` nonce="${nonce}"` : ""}>${scripts.length ? scripts + ";" : ""}${SYNC_SCRIPT}</script>`;
265
- return injectAssets(context.assets, html);
262
+ let html = injectAssets(context.assets, resolveSSRNode(res));
263
+ if (scripts.length) html = injectScripts(html, scripts, nonce);
264
+ return html;
266
265
  });
267
266
  }
268
267
  function renderToPipeableStream(code, options) {
@@ -339,7 +338,8 @@ function renderToPipeableStream(code, options) {
339
338
  let html = resolveSSRNode(escape(code()));
340
339
  html = injectAssets(sharedConfig.context.assets, html);
341
340
  Promise.resolve().then(() => {
342
- buffer.write(html + `<script${nonce ? ` nonce="${nonce}"` : ""}>${tasks.length ? tasks.join(";") + ";" : ""}${SYNC_SCRIPT}</script>`);
341
+ if (tasks.length) html = injectScripts(html, tasks.join(";"), nonce);
342
+ buffer.write(html);
343
343
  tasks.length = 0;
344
344
  scheduled = false;
345
345
  onCompleteShell && onCompleteShell();
@@ -443,7 +443,8 @@ function pipeToWritable(code, writable, options = {}) {
443
443
  let html = resolveSSRNode(escape(code()));
444
444
  html = injectAssets(sharedConfig.context.assets, html);
445
445
  Promise.resolve().then(() => {
446
- buffer.write(encoder.encode(html + `<script${nonce ? ` nonce="${nonce}"` : ""}>${tasks.length ? tasks.join(";") + ";" : ""}${SYNC_SCRIPT}</script>`));
446
+ if (tasks.length) html = injectScripts(html, tasks.join(";"), nonce);
447
+ buffer.write(encoder.encode(html));
447
448
  tasks.length = 0;
448
449
  scheduled = false;
449
450
  onCompleteShell && onCompleteShell(result);
@@ -608,7 +609,7 @@ function generateHydrationScript({
608
609
  eventNames = ["click", "input"],
609
610
  nonce
610
611
  }) {
611
- return `<script${nonce ? ` nonce="${nonce}"` : ""}>((e,t,o={})=>{t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host instanceof Node?e.host:e.parentNode)),["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{let n=o.composedPath&&o.composedPath()[0]||o.target,s=t(n);s&&!e.completed.has(s)&&e.events.push([s,o])})))),e.init=(e,t)=>{o[e]=[new Promise((e=>t=e)),t]},e.set=(e,t,n)=>{if(!(n=o[e]))return o[e]=[t];n[1](t)},e.load=(e,t)=>{if(t=o[e])return t[0]}})(window._$HY||(_$HY={events:[],completed:new WeakSet,queue:[]}));</script>`;
612
+ return `<script${nonce ? ` nonce="${nonce}"` : ""}>((e,t,o={})=>{t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-hk")?e:t(e.host&&e.host instanceof Node?e.host:e.parentNode)),["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{let n=o.composedPath&&o.composedPath()[0]||o.target,s=t(n);s&&!e.completed.has(s)&&e.events.push([s,o])})))),e.init=(e,t)=>{o[e]=[new Promise((e=>t=e)),t]},e.set=(e,t,n)=>{if(!(n=o[e]))return o[e]=[t];n[1](t)},e.load=(e,t)=>{if(t=o[e])return t[0]}})(window._$HY||(_$HY={events:[],completed:new WeakSet}));</script><!xs>`;
612
613
  }
613
614
  function injectAssets(assets, html) {
614
615
  for (let i = 0; i < assets.length; i++) {
@@ -616,6 +617,14 @@ function injectAssets(assets, html) {
616
617
  }
617
618
  return html;
618
619
  }
620
+ function injectScripts(html, scripts, nonce) {
621
+ const tag = `<script${nonce ? ` nonce="${nonce}"` : ""}>${scripts}</script>`;
622
+ const index = html.indexOf("<!xs>");
623
+ if (index > -1) {
624
+ return html.slice(0, index) + tag + html.slice(index);
625
+ }
626
+ return html + tag;
627
+ }
619
628
  const FRAGMENT_REPLACE = /<!\[([\d.]+)\]>/;
620
629
  function asyncWrap(fn) {
621
630
  return new Promise(resolve => {
package/web/dist/web.cjs CHANGED
@@ -218,11 +218,6 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}) {
218
218
  }
219
219
  }
220
220
  function hydrate(code, element) {
221
- if (!globalThis._$HY.sync) {
222
- let dispose;
223
- globalThis._$HY.queue.push(() => dispose = hydrate(code, element));
224
- return () => dispose();
225
- }
226
221
  solidJs.sharedConfig.completed = globalThis._$HY.completed;
227
222
  solidJs.sharedConfig.events = globalThis._$HY.events;
228
223
  solidJs.sharedConfig.load = globalThis._$HY.load;
package/web/dist/web.js CHANGED
@@ -215,11 +215,6 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}) {
215
215
  }
216
216
  }
217
217
  function hydrate(code, element) {
218
- if (!globalThis._$HY.sync) {
219
- let dispose;
220
- globalThis._$HY.queue.push(() => dispose = hydrate(code, element));
221
- return () => dispose();
222
- }
223
218
  sharedConfig.completed = globalThis._$HY.completed;
224
219
  sharedConfig.events = globalThis._$HY.events;
225
220
  sharedConfig.load = globalThis._$HY.load;