solid-js 1.5.0-beta.5 → 1.5.0

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/dev.cjs CHANGED
@@ -147,7 +147,6 @@ const UNOWNED = {
147
147
  owner: null
148
148
  };
149
149
  const NO_INIT = {};
150
- const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
151
150
  var Owner = null;
152
151
  let Transition = null;
153
152
  let Scheduler = null;
@@ -157,6 +156,7 @@ let Updates = null;
157
156
  let Effects = null;
158
157
  let ExecCount = 0;
159
158
  let rootCount = 0;
159
+ const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
160
160
  function createRoot(fn, detachedOwner) {
161
161
  const listener = Listener,
162
162
  owner = Owner,
@@ -272,7 +272,7 @@ function createResource(pSource, pFetcher, pOptions) {
272
272
  if (sharedConfig.context) {
273
273
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
274
274
  let v;
275
- if (options.ssrValue === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
275
+ if (options.ssrLoadFrom === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
276
276
  }
277
277
  function loadEnd(p, v, success, key) {
278
278
  if (pr === p) {
@@ -532,7 +532,7 @@ function devComponent(Comp, props) {
532
532
  }
533
533
  function hashValue(v) {
534
534
  const s = new Set();
535
- return `s${typeof v === "string" ? hash(v) : hash(JSON.stringify(v, (k, v) => {
535
+ return `s${typeof v === "string" ? hash(v) : hash(untrack(() => JSON.stringify(v, (k, v) => {
536
536
  if (typeof v === "object" && v != null) {
537
537
  if (s.has(v)) return;
538
538
  s.add(v);
@@ -549,7 +549,7 @@ function hashValue(v) {
549
549
  return `${v.toString()}n`;
550
550
  }
551
551
  return v;
552
- }) || "")}`;
552
+ }) || ""))}`;
553
553
  }
554
554
  function registerGraph(name, value) {
555
555
  let tryName = name;
package/dist/dev.js CHANGED
@@ -143,7 +143,6 @@ const UNOWNED = {
143
143
  owner: null
144
144
  };
145
145
  const NO_INIT = {};
146
- const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
147
146
  var Owner = null;
148
147
  let Transition = null;
149
148
  let Scheduler = null;
@@ -153,6 +152,7 @@ let Updates = null;
153
152
  let Effects = null;
154
153
  let ExecCount = 0;
155
154
  let rootCount = 0;
155
+ const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
156
156
  function createRoot(fn, detachedOwner) {
157
157
  const listener = Listener,
158
158
  owner = Owner,
@@ -268,7 +268,7 @@ function createResource(pSource, pFetcher, pOptions) {
268
268
  if (sharedConfig.context) {
269
269
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
270
270
  let v;
271
- if (options.ssrValue === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
271
+ if (options.ssrLoadFrom === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
272
272
  }
273
273
  function loadEnd(p, v, success, key) {
274
274
  if (pr === p) {
@@ -528,7 +528,7 @@ function devComponent(Comp, props) {
528
528
  }
529
529
  function hashValue(v) {
530
530
  const s = new Set();
531
- return `s${typeof v === "string" ? hash(v) : hash(JSON.stringify(v, (k, v) => {
531
+ return `s${typeof v === "string" ? hash(v) : hash(untrack(() => JSON.stringify(v, (k, v) => {
532
532
  if (typeof v === "object" && v != null) {
533
533
  if (s.has(v)) return;
534
534
  s.add(v);
@@ -545,7 +545,7 @@ function hashValue(v) {
545
545
  return `${v.toString()}n`;
546
546
  }
547
547
  return v;
548
- }) || "")}`;
548
+ }) || ""))}`;
549
549
  }
550
550
  function registerGraph(name, value) {
551
551
  let tryName = name;
package/dist/server.cjs CHANGED
@@ -399,7 +399,7 @@ function createResource(source, fetcher, options = {}) {
399
399
  let value = options.storage ? options.storage(options.initialValue)[0]() : options.initialValue;
400
400
  let p;
401
401
  let error;
402
- if (sharedConfig.context.async && options.ssrValue !== "initial") {
402
+ if (sharedConfig.context.async && options.ssrLoadFrom !== "initial") {
403
403
  resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
404
404
  if (resource.ref) {
405
405
  if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
@@ -409,7 +409,7 @@ function createResource(source, fetcher, options = {}) {
409
409
  const read = () => {
410
410
  if (error) throw error;
411
411
  if (resourceContext && p) resourceContext.push(p);
412
- const resolved = options.ssrValue !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
412
+ const resolved = options.ssrLoadFrom !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
413
413
  if (!resolved && read.loading) {
414
414
  const ctx = useContext(SuspenseContext);
415
415
  if (ctx) {
@@ -472,7 +472,7 @@ function createResource(source, fetcher, options = {}) {
472
472
  p = null;
473
473
  return ctx.resources[id].data;
474
474
  }
475
- if (options.ssrValue !== "initial") load();
475
+ if (options.ssrLoadFrom !== "initial") load();
476
476
  return resource.ref = [read, {
477
477
  refetch: load,
478
478
  mutate: v => value = v
package/dist/server.js CHANGED
@@ -395,7 +395,7 @@ function createResource(source, fetcher, options = {}) {
395
395
  let value = options.storage ? options.storage(options.initialValue)[0]() : options.initialValue;
396
396
  let p;
397
397
  let error;
398
- if (sharedConfig.context.async && options.ssrValue !== "initial") {
398
+ if (sharedConfig.context.async && options.ssrLoadFrom !== "initial") {
399
399
  resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
400
400
  if (resource.ref) {
401
401
  if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
@@ -405,7 +405,7 @@ function createResource(source, fetcher, options = {}) {
405
405
  const read = () => {
406
406
  if (error) throw error;
407
407
  if (resourceContext && p) resourceContext.push(p);
408
- const resolved = options.ssrValue !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
408
+ const resolved = options.ssrLoadFrom !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
409
409
  if (!resolved && read.loading) {
410
410
  const ctx = useContext(SuspenseContext);
411
411
  if (ctx) {
@@ -468,7 +468,7 @@ function createResource(source, fetcher, options = {}) {
468
468
  p = null;
469
469
  return ctx.resources[id].data;
470
470
  }
471
- if (options.ssrValue !== "initial") load();
471
+ if (options.ssrLoadFrom !== "initial") load();
472
472
  return resource.ref = [read, {
473
473
  refetch: load,
474
474
  mutate: v => value = v
package/dist/solid.cjs CHANGED
@@ -147,7 +147,6 @@ const UNOWNED = {
147
147
  owner: null
148
148
  };
149
149
  const NO_INIT = {};
150
- const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
151
150
  var Owner = null;
152
151
  let Transition = null;
153
152
  let Scheduler = null;
@@ -156,6 +155,7 @@ let Listener = null;
156
155
  let Updates = null;
157
156
  let Effects = null;
158
157
  let ExecCount = 0;
158
+ const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
159
159
  function createRoot(fn, detachedOwner) {
160
160
  const listener = Listener,
161
161
  owner = Owner,
@@ -264,7 +264,7 @@ function createResource(pSource, pFetcher, pOptions) {
264
264
  if (sharedConfig.context) {
265
265
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
266
266
  let v;
267
- if (options.ssrValue === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
267
+ if (options.ssrLoadFrom === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
268
268
  }
269
269
  function loadEnd(p, v, success, key) {
270
270
  if (pr === p) {
package/dist/solid.js CHANGED
@@ -143,7 +143,6 @@ const UNOWNED = {
143
143
  owner: null
144
144
  };
145
145
  const NO_INIT = {};
146
- const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
147
146
  var Owner = null;
148
147
  let Transition = null;
149
148
  let Scheduler = null;
@@ -152,6 +151,7 @@ let Listener = null;
152
151
  let Updates = null;
153
152
  let Effects = null;
154
153
  let ExecCount = 0;
154
+ const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
155
155
  function createRoot(fn, detachedOwner) {
156
156
  const listener = Listener,
157
157
  owner = Owner,
@@ -260,7 +260,7 @@ function createResource(pSource, pFetcher, pOptions) {
260
260
  if (sharedConfig.context) {
261
261
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
262
262
  let v;
263
- if (options.ssrValue === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
263
+ if (options.ssrLoadFrom === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
264
264
  }
265
265
  function loadEnd(p, v, success, key) {
266
266
  if (pr === p) {
@@ -0,0 +1 @@
1
+ export * from "./types/jsx";
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",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -197,6 +197,9 @@
197
197
  "compiler",
198
198
  "performance"
199
199
  ],
200
+ "dependencies": {
201
+ "csstype": "^3.1.0"
202
+ },
200
203
  "scripts": {
201
204
  "build": "npm-run-all -nl build:*",
202
205
  "build:clean": "rimraf dist/ coverage/ store/dist/ web/dist/ h/dist/ h/jsx-runtime/dist html/dist/",
package/types/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { createRoot, createSignal, createEffect, createRenderEffect, createComputed, createReaction, createDeferred, createSelector, createMemo, createResource, onMount, onCleanup, onError, untrack, batch, on, enableScheduling, enableExternalSource, startTransition, useTransition, createContext, useContext, children, getListener, getOwner, runWithOwner, equalFn, $DEVCOMP, $PROXY, $TRACK } from "./reactive/signal.js";
2
- export type { Accessor, Setter, Signal, Resource, ResourceOptions, ResourceReturn, ResourceFetcher, ResourceFetcherInfo, ChildrenReturn, Context, ReturnTypes, Owner, InitializedResource, InitializedResourceOptions, InitializedResourceReturn } from "./reactive/signal.js";
2
+ export type { Accessor, Setter, Signal, Resource, ResourceActions, ResourceSource, ResourceOptions, ResourceReturn, ResourceFetcher, ResourceFetcherInfo, ChildrenReturn, Context, ReturnTypes, Owner, InitializedResource, InitializedResourceOptions, InitializedResourceReturn } from "./reactive/signal.js";
3
3
  export * from "./reactive/observable.js";
4
4
  export * from "./reactive/scheduler.js";
5
5
  export * from "./reactive/array.js";
package/types/jsx.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as csstype from 'csstype';
1
+ import * as csstype from 'csstype/index.js';
2
2
 
3
3
  /**
4
4
  * Based on JSX types for Surplus and Inferno and adapted for `dom-expressions`.
@@ -247,7 +247,7 @@ export declare type ResourceOptions<T, S = unknown> = {
247
247
  initialValue?: T;
248
248
  name?: string;
249
249
  deferStream?: boolean;
250
- ssrValue?: "initial" | "server";
250
+ ssrLoadFrom?: "initial" | "server";
251
251
  storage?: (init: T | undefined) => [Accessor<T | undefined>, Setter<T | undefined>];
252
252
  onHydrated?: (k: S | undefined, info: {
253
253
  value: T | undefined;
@@ -100,14 +100,14 @@ export declare type ResourceOptions<T> = undefined extends T ? {
100
100
  initialValue?: T;
101
101
  name?: string;
102
102
  deferStream?: boolean;
103
- ssrValue?: "initial" | "server";
103
+ ssrLoadFrom?: "initial" | "server";
104
104
  storage?: () => Signal<T | undefined>;
105
105
  onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
106
106
  } : {
107
107
  initialValue: T;
108
108
  name?: string;
109
109
  deferStream?: boolean;
110
- ssrValue?: "initial" | "server";
110
+ ssrLoadFrom?: "initial" | "server";
111
111
  storage?: (v?: T) => Signal<T | undefined>;
112
112
  onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
113
113
  };
@@ -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;