solid-js 1.5.0-beta.5 → 1.5.0-beta.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.
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.5.0-beta.5",
4
+ "version": "1.5.0-beta.6",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -266,7 +266,8 @@ function toRefParam(index) {
266
266
  const REPLACE_SCRIPT = `function $df(e,t,d,l){d=document.getElementById(e),(l=document.getElementById("pl-"+e))&&l.replaceWith(...d.childNodes),d.remove(),_$HY.set(e,t)}`;
267
267
  function renderToString(code, options = {}) {
268
268
  let scripts = "";
269
- solidJs.sharedConfig.context = {
269
+ let context;
270
+ solidJs.sharedConfig.context = context = {
270
271
  id: options.renderId || "",
271
272
  count: 0,
272
273
  suspense: {},
@@ -277,7 +278,9 @@ function renderToString(code, options = {}) {
277
278
  scripts += `_$HY.set("${id}", ${stringify(p)});`;
278
279
  }
279
280
  };
280
- let html = injectAssets(solidJs.sharedConfig.context.assets, resolveSSRNode(escape(code())));
281
+ let html = resolveSSRNode(escape(code()));
282
+ solidJs.sharedConfig.context = undefined;
283
+ html = injectAssets(context.assets, html);
281
284
  if (scripts.length) html = injectScripts(html, scripts, options.nonce);
282
285
  return html;
283
286
  }
@@ -397,6 +400,7 @@ function renderToStream(code, options = {}) {
397
400
  };
398
401
  let html = resolveSSRNode(escape(code()));
399
402
  function doShell() {
403
+ solidJs.sharedConfig.context = undefined;
400
404
  html = injectAssets(context.assets, html);
401
405
  for (const key in context.resources) {
402
406
  if (!("data" in context.resources[key] || context.resources[key].ref[0].error)) pushTask(`_$HY.init("${key}")`);
@@ -634,7 +638,7 @@ function injectAssets(assets, html) {
634
638
  if (!assets || !assets.length) return html;
635
639
  let out = "";
636
640
  for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
637
- return html.replace(`<head>`, `<head>` + out);
641
+ return html.replace(`</head>`, out + `</head>`);
638
642
  }
639
643
  function injectScripts(html, scripts, nonce) {
640
644
  const tag = `<script${nonce ? ` nonce="${nonce}"` : ""}>${scripts}</script>`;
@@ -725,7 +729,7 @@ function pipeToWritable(code, writable, options = {}) {
725
729
  }
726
730
  function ssrSpread(props, isSVG, skipChildren) {
727
731
  let result = "";
728
- if (props == null) return results;
732
+ if (props == null) return result;
729
733
  if (typeof props === "function") props = props();
730
734
  const keys = Object.keys(props);
731
735
  let classResolved;
@@ -263,7 +263,8 @@ function toRefParam(index) {
263
263
  const REPLACE_SCRIPT = `function $df(e,t,d,l){d=document.getElementById(e),(l=document.getElementById("pl-"+e))&&l.replaceWith(...d.childNodes),d.remove(),_$HY.set(e,t)}`;
264
264
  function renderToString(code, options = {}) {
265
265
  let scripts = "";
266
- sharedConfig.context = {
266
+ let context;
267
+ sharedConfig.context = context = {
267
268
  id: options.renderId || "",
268
269
  count: 0,
269
270
  suspense: {},
@@ -274,7 +275,9 @@ function renderToString(code, options = {}) {
274
275
  scripts += `_$HY.set("${id}", ${stringify(p)});`;
275
276
  }
276
277
  };
277
- let html = injectAssets(sharedConfig.context.assets, resolveSSRNode(escape(code())));
278
+ let html = resolveSSRNode(escape(code()));
279
+ sharedConfig.context = undefined;
280
+ html = injectAssets(context.assets, html);
278
281
  if (scripts.length) html = injectScripts(html, scripts, options.nonce);
279
282
  return html;
280
283
  }
@@ -394,6 +397,7 @@ function renderToStream(code, options = {}) {
394
397
  };
395
398
  let html = resolveSSRNode(escape(code()));
396
399
  function doShell() {
400
+ sharedConfig.context = undefined;
397
401
  html = injectAssets(context.assets, html);
398
402
  for (const key in context.resources) {
399
403
  if (!("data" in context.resources[key] || context.resources[key].ref[0].error)) pushTask(`_$HY.init("${key}")`);
@@ -631,7 +635,7 @@ function injectAssets(assets, html) {
631
635
  if (!assets || !assets.length) return html;
632
636
  let out = "";
633
637
  for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
634
- return html.replace(`<head>`, `<head>` + out);
638
+ return html.replace(`</head>`, out + `</head>`);
635
639
  }
636
640
  function injectScripts(html, scripts, nonce) {
637
641
  const tag = `<script${nonce ? ` nonce="${nonce}"` : ""}>${scripts}</script>`;
@@ -722,7 +726,7 @@ function pipeToWritable(code, writable, options = {}) {
722
726
  }
723
727
  function ssrSpread(props, isSVG, skipChildren) {
724
728
  let result = "";
725
- if (props == null) return results;
729
+ if (props == null) return result;
726
730
  if (typeof props === "function") props = props();
727
731
  const keys = Object.keys(props);
728
732
  let classResolved;
@@ -62,7 +62,7 @@ export function getHydrationKey(): string;
62
62
  export function getNextElement(template?: HTMLTemplateElement): Element;
63
63
  export function getNextMatch(start: Node, elementName: string): Element;
64
64
  export function getNextMarker(start: Node): [Node, Array<Node>];
65
- export function useAsset(fn: () => string): void;
65
+ export function useAssets(fn: () => string): void;
66
66
  export function getAssets(): string;
67
67
  export function Assets(props: { children?: JSX.Element }): JSX.Element;
68
68
  export function HydrationScript(): JSX.Element;
@@ -37,7 +37,7 @@ export function ssrAttribute(key: string, value: any, isBoolean: boolean): strin
37
37
  export function ssrHydrationKey(): string;
38
38
  export function resolveSSRNode(node: any): string;
39
39
  export function escape(html: string): string;
40
- export function useAsset(fn: () => string): void;
40
+ export function useAssets(fn: () => string): void;
41
41
  export function getAssets(): string;
42
42
  export function getHydrationKey(): string;
43
43
  export function effect<T>(fn: (prev?: T) => T, init?: T): void;