solid-js 1.3.0-beta.4 → 1.3.0-beta.8

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
@@ -251,6 +251,8 @@ function createResource(source, fetcher, options) {
251
251
  dynamic = typeof source === "function";
252
252
  if (sharedConfig.context) {
253
253
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
254
+ ({ ...sharedConfig.context
255
+ });
254
256
  if (sharedConfig.load) initP = sharedConfig.load(id);
255
257
  }
256
258
  function loadEnd(p, v, e) {
@@ -1281,7 +1283,7 @@ function lazy(fn) {
1281
1283
  (p || (p = fn())).then(mod => {
1282
1284
  setHydrateContext(ctx);
1283
1285
  set(() => mod.default);
1284
- setHydrateContext(undefined);
1286
+ setHydrateContext();
1285
1287
  });
1286
1288
  comp = s;
1287
1289
  } else if (!comp) {
@@ -1479,7 +1481,7 @@ function Suspense(props) {
1479
1481
  waitingHydration = true;
1480
1482
  setHydrateContext(ctx);
1481
1483
  set();
1482
- setHydrateContext(undefined);
1484
+ setHydrateContext();
1483
1485
  waitingHydration = false;
1484
1486
  });
1485
1487
  }
@@ -1512,7 +1514,10 @@ function Suspense(props) {
1512
1514
  if (!visibleFallback) return;
1513
1515
  return createRoot(disposer => {
1514
1516
  dispose = disposer;
1515
- if (sharedConfig.context) sharedConfig.context.count = 0;
1517
+ if (sharedConfig.context) setHydrateContext({
1518
+ id: sharedConfig.context.id + "f",
1519
+ count: 0
1520
+ });
1516
1521
  return props.fallback;
1517
1522
  }, owner);
1518
1523
  });
package/dist/dev.js CHANGED
@@ -247,6 +247,8 @@ function createResource(source, fetcher, options) {
247
247
  dynamic = typeof source === "function";
248
248
  if (sharedConfig.context) {
249
249
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
250
+ ({ ...sharedConfig.context
251
+ });
250
252
  if (sharedConfig.load) initP = sharedConfig.load(id);
251
253
  }
252
254
  function loadEnd(p, v, e) {
@@ -1277,7 +1279,7 @@ function lazy(fn) {
1277
1279
  (p || (p = fn())).then(mod => {
1278
1280
  setHydrateContext(ctx);
1279
1281
  set(() => mod.default);
1280
- setHydrateContext(undefined);
1282
+ setHydrateContext();
1281
1283
  });
1282
1284
  comp = s;
1283
1285
  } else if (!comp) {
@@ -1475,7 +1477,7 @@ function Suspense(props) {
1475
1477
  waitingHydration = true;
1476
1478
  setHydrateContext(ctx);
1477
1479
  set();
1478
- setHydrateContext(undefined);
1480
+ setHydrateContext();
1479
1481
  waitingHydration = false;
1480
1482
  });
1481
1483
  }
@@ -1508,7 +1510,10 @@ function Suspense(props) {
1508
1510
  if (!visibleFallback) return;
1509
1511
  return createRoot(disposer => {
1510
1512
  dispose = disposer;
1511
- if (sharedConfig.context) sharedConfig.context.count = 0;
1513
+ if (sharedConfig.context) setHydrateContext({
1514
+ id: sharedConfig.context.id + "f",
1515
+ count: 0
1516
+ });
1512
1517
  return props.fallback;
1513
1518
  }, owner);
1514
1519
  });
package/dist/server.cjs CHANGED
@@ -351,7 +351,7 @@ function createResource(fn, fetcher, options = {}) {
351
351
  if (error) throw error;
352
352
  if (resourceContext && p) resourceContext.push(p);
353
353
  const resolved = sharedConfig.context.async && sharedConfig.context.resources[id].data;
354
- if (!resolved) {
354
+ if (!resolved && read.loading) {
355
355
  const ctx = useContext(SuspenseContext);
356
356
  if (ctx) {
357
357
  ctx.resources.set(id, read);
@@ -363,7 +363,7 @@ function createResource(fn, fetcher, options = {}) {
363
363
  read.loading = false;
364
364
  function load() {
365
365
  const ctx = sharedConfig.context;
366
- if (!ctx.async) return read.loading = true;
366
+ if (!ctx.async) return read.loading = !!(typeof fn === "function" ? fn() : fn);
367
367
  if (ctx.resources && id in ctx.resources && ctx.resources[id].data) {
368
368
  value = ctx.resources[id].data;
369
369
  return;
@@ -502,9 +502,10 @@ function Suspense(props) {
502
502
  };
503
503
  }
504
504
  setHydrateContext({ ...ctx,
505
- count: 0
505
+ count: 0,
506
+ id: ctx.id + "0.f"
506
507
  });
507
- return createComponent(() => props.fallback, {});
508
+ return props.fallback;
508
509
  }
509
510
 
510
511
  exports.$PROXY = $PROXY;
package/dist/server.js CHANGED
@@ -347,7 +347,7 @@ function createResource(fn, fetcher, options = {}) {
347
347
  if (error) throw error;
348
348
  if (resourceContext && p) resourceContext.push(p);
349
349
  const resolved = sharedConfig.context.async && sharedConfig.context.resources[id].data;
350
- if (!resolved) {
350
+ if (!resolved && read.loading) {
351
351
  const ctx = useContext(SuspenseContext);
352
352
  if (ctx) {
353
353
  ctx.resources.set(id, read);
@@ -359,7 +359,7 @@ function createResource(fn, fetcher, options = {}) {
359
359
  read.loading = false;
360
360
  function load() {
361
361
  const ctx = sharedConfig.context;
362
- if (!ctx.async) return read.loading = true;
362
+ if (!ctx.async) return read.loading = !!(typeof fn === "function" ? fn() : fn);
363
363
  if (ctx.resources && id in ctx.resources && ctx.resources[id].data) {
364
364
  value = ctx.resources[id].data;
365
365
  return;
@@ -498,9 +498,10 @@ function Suspense(props) {
498
498
  };
499
499
  }
500
500
  setHydrateContext({ ...ctx,
501
- count: 0
501
+ count: 0,
502
+ id: ctx.id + "0.f"
502
503
  });
503
- return createComponent(() => props.fallback, {});
504
+ return props.fallback;
504
505
  }
505
506
 
506
507
  export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableScheduling, equalFn, from, getListener, getOwner, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
package/dist/solid.cjs CHANGED
@@ -248,6 +248,8 @@ function createResource(source, fetcher, options) {
248
248
  dynamic = typeof source === "function";
249
249
  if (sharedConfig.context) {
250
250
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
251
+ ({ ...sharedConfig.context
252
+ });
251
253
  if (sharedConfig.load) initP = sharedConfig.load(id);
252
254
  }
253
255
  function loadEnd(p, v, e) {
@@ -1205,7 +1207,7 @@ function lazy(fn) {
1205
1207
  (p || (p = fn())).then(mod => {
1206
1208
  setHydrateContext(ctx);
1207
1209
  set(() => mod.default);
1208
- setHydrateContext(undefined);
1210
+ setHydrateContext();
1209
1211
  });
1210
1212
  comp = s;
1211
1213
  } else if (!comp) {
@@ -1403,7 +1405,7 @@ function Suspense(props) {
1403
1405
  waitingHydration = true;
1404
1406
  setHydrateContext(ctx);
1405
1407
  set();
1406
- setHydrateContext(undefined);
1408
+ setHydrateContext();
1407
1409
  waitingHydration = false;
1408
1410
  });
1409
1411
  }
@@ -1436,7 +1438,10 @@ function Suspense(props) {
1436
1438
  if (!visibleFallback) return;
1437
1439
  return createRoot(disposer => {
1438
1440
  dispose = disposer;
1439
- if (sharedConfig.context) sharedConfig.context.count = 0;
1441
+ if (sharedConfig.context) setHydrateContext({
1442
+ id: sharedConfig.context.id + "f",
1443
+ count: 0
1444
+ });
1440
1445
  return props.fallback;
1441
1446
  }, owner);
1442
1447
  });
package/dist/solid.js CHANGED
@@ -244,6 +244,8 @@ function createResource(source, fetcher, options) {
244
244
  dynamic = typeof source === "function";
245
245
  if (sharedConfig.context) {
246
246
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
247
+ ({ ...sharedConfig.context
248
+ });
247
249
  if (sharedConfig.load) initP = sharedConfig.load(id);
248
250
  }
249
251
  function loadEnd(p, v, e) {
@@ -1201,7 +1203,7 @@ function lazy(fn) {
1201
1203
  (p || (p = fn())).then(mod => {
1202
1204
  setHydrateContext(ctx);
1203
1205
  set(() => mod.default);
1204
- setHydrateContext(undefined);
1206
+ setHydrateContext();
1205
1207
  });
1206
1208
  comp = s;
1207
1209
  } else if (!comp) {
@@ -1399,7 +1401,7 @@ function Suspense(props) {
1399
1401
  waitingHydration = true;
1400
1402
  setHydrateContext(ctx);
1401
1403
  set();
1402
- setHydrateContext(undefined);
1404
+ setHydrateContext();
1403
1405
  waitingHydration = false;
1404
1406
  });
1405
1407
  }
@@ -1432,7 +1434,10 @@ function Suspense(props) {
1432
1434
  if (!visibleFallback) return;
1433
1435
  return createRoot(disposer => {
1434
1436
  dispose = disposer;
1435
- if (sharedConfig.context) sharedConfig.context.count = 0;
1437
+ if (sharedConfig.context) setHydrateContext({
1438
+ id: sharedConfig.context.id + "f",
1439
+ count: 0
1440
+ });
1436
1441
  return props.fallback;
1437
1442
  }, owner);
1438
1443
  });
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.4",
4
+ "version": "1.3.0-beta.8",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -37,6 +37,10 @@
37
37
  "exports": {
38
38
  ".": {
39
39
  "browser": {
40
+ "development": {
41
+ "import": "./dist/dev.js",
42
+ "require": "./dist/dev.cjs"
43
+ },
40
44
  "import": "./dist/solid.js",
41
45
  "require": "./dist/solid.cjs"
42
46
  },
@@ -54,6 +58,10 @@
54
58
  "./dist/*": "./dist/*",
55
59
  "./store": {
56
60
  "browser": {
61
+ "development": {
62
+ "import": "./store/dist/dev.js",
63
+ "require": "./store/dist/dev.cjs"
64
+ },
57
65
  "import": "./store/dist/store.js",
58
66
  "require": "./store/dist/store.cjs"
59
67
  },
@@ -71,6 +79,10 @@
71
79
  "./store/dist/*": "./store/dist/*",
72
80
  "./web": {
73
81
  "browser": {
82
+ "development": {
83
+ "import": "./web/dist/dev.js",
84
+ "require": "./web/dist/dev.cjs"
85
+ },
74
86
  "import": "./web/dist/web.js",
75
87
  "require": "./web/dist/web.cjs"
76
88
  },
@@ -132,5 +144,5 @@
132
144
  "compiler",
133
145
  "performance"
134
146
  ],
135
- "gitHead": "c9307f020f33ff584f2d896c219e530d8ee97a9c"
147
+ "gitHead": "d63c43c95c224cb4c4dc4f5c8681b9be3c62f1c9"
136
148
  }
@@ -200,7 +200,7 @@ export declare type ResourceOptions<T> = T extends undefined ? {
200
200
  /**
201
201
  * Creates a resource that wraps a repeated promise in a reactive pattern:
202
202
  * ```typescript
203
- * const [resource, { mutate, refetch }] = crateResource(source, fetcher, options);
203
+ * const [resource, { mutate, refetch }] = createResource(source, fetcher, options);
204
204
  * ```
205
205
  * @param source - reactive data function to toggle the request, optional
206
206
  * @param fetcher - function that receives the source (or true) and an accessor for the last or initial value and returns a value or a Promise with the value:
package/web/dist/dev.cjs CHANGED
@@ -403,6 +403,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
403
403
  }
404
404
  current = array;
405
405
  } else if (value instanceof Node) {
406
+ if (solidJs.sharedConfig.context) return current = value.parentNode ? value : current;
406
407
  if (Array.isArray(current)) {
407
408
  if (multi) return current = cleanChildren(parent, current, marker, value);
408
409
  cleanChildren(parent, current, null, value);
package/web/dist/dev.js CHANGED
@@ -400,6 +400,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
400
400
  }
401
401
  current = array;
402
402
  } else if (value instanceof Node) {
403
+ if (sharedConfig.context) return current = value.parentNode ? value : current;
403
404
  if (Array.isArray(current)) {
404
405
  if (multi) return current = cleanChildren(parent, current, marker, value);
405
406
  cleanChildren(parent, current, null, value);
@@ -358,8 +358,8 @@ function renderToStream(code, options = {}) {
358
358
  tasks.push(`_$HY.init("${id}")`);
359
359
  p.then(d => {
360
360
  !completed && buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>_$HY.set("${id}", ${devalue(d)})</script>`);
361
- }).catch(() => {
362
- !completed && buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>_$HY.set("${id}", null)</script>`);
361
+ }).catch(err => {
362
+ !completed && buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>_$HY.set("${id}", null, ${serializeError(err)})</script>`);
363
363
  });
364
364
  },
365
365
  registerFragment(key) {
@@ -404,6 +404,7 @@ function renderToStream(code, options = {}) {
404
404
  const writer = w.getWriter();
405
405
  writable = {
406
406
  end() {
407
+ writer.releaseLock();
407
408
  w.close();
408
409
  }
409
410
  };
@@ -573,7 +574,7 @@ function generateHydrationScript({
573
574
  eventNames = ["click", "input"],
574
575
  nonce
575
576
  }) {
576
- 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.unset=(e)=>{delete o[e]},e.load=(e,t)=>{if(t=o[e])return t[0]}})(window._$HY||(_$HY={events:[],completed:new WeakSet}))</script><!xs>`;
577
+ 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 s=o.composedPath&&o.composedPath()[0]||o.target,n=t(s);n&&!e.completed.has(n)&&e.events.push([n,o])})))),e.init=(e,t,s)=>{o[e]=[new Promise(((e,o)=>(t=e,s=o))),t,s]},e.set=(e,t,s,n)=>{(n=o[e])&&(s?n[2](s):n[1](t)),o[e]=[t]},e.unset=e=>{delete o[e]},e.load=(e,t)=>{if(t=o[e])return t[0]}})(window._$HY||(_$HY={events:[],completed:new WeakSet}))</script><!xs>`;
577
578
  }
578
579
  function injectAssets(assets, html) {
579
580
  for (let i = 0; i < assets.length; i++) {
@@ -355,8 +355,8 @@ function renderToStream(code, options = {}) {
355
355
  tasks.push(`_$HY.init("${id}")`);
356
356
  p.then(d => {
357
357
  !completed && buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>_$HY.set("${id}", ${devalue(d)})</script>`);
358
- }).catch(() => {
359
- !completed && buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>_$HY.set("${id}", null)</script>`);
358
+ }).catch(err => {
359
+ !completed && buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>_$HY.set("${id}", null, ${serializeError(err)})</script>`);
360
360
  });
361
361
  },
362
362
  registerFragment(key) {
@@ -401,6 +401,7 @@ function renderToStream(code, options = {}) {
401
401
  const writer = w.getWriter();
402
402
  writable = {
403
403
  end() {
404
+ writer.releaseLock();
404
405
  w.close();
405
406
  }
406
407
  };
@@ -570,7 +571,7 @@ function generateHydrationScript({
570
571
  eventNames = ["click", "input"],
571
572
  nonce
572
573
  }) {
573
- 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.unset=(e)=>{delete o[e]},e.load=(e,t)=>{if(t=o[e])return t[0]}})(window._$HY||(_$HY={events:[],completed:new WeakSet}))</script><!xs>`;
574
+ 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 s=o.composedPath&&o.composedPath()[0]||o.target,n=t(s);n&&!e.completed.has(n)&&e.events.push([n,o])})))),e.init=(e,t,s)=>{o[e]=[new Promise(((e,o)=>(t=e,s=o))),t,s]},e.set=(e,t,s,n)=>{(n=o[e])&&(s?n[2](s):n[1](t)),o[e]=[t]},e.unset=e=>{delete o[e]},e.load=(e,t)=>{if(t=o[e])return t[0]}})(window._$HY||(_$HY={events:[],completed:new WeakSet}))</script><!xs>`;
574
575
  }
575
576
  function injectAssets(assets, html) {
576
577
  for (let i = 0; i < assets.length; i++) {
package/web/dist/web.cjs CHANGED
@@ -402,6 +402,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
402
402
  }
403
403
  current = array;
404
404
  } else if (value instanceof Node) {
405
+ if (solidJs.sharedConfig.context) return current = value.parentNode ? value : current;
405
406
  if (Array.isArray(current)) {
406
407
  if (multi) return current = cleanChildren(parent, current, marker, value);
407
408
  cleanChildren(parent, current, null, value);
package/web/dist/web.js CHANGED
@@ -399,6 +399,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
399
399
  }
400
400
  current = array;
401
401
  } else if (value instanceof Node) {
402
+ if (sharedConfig.context) return current = value.parentNode ? value : current;
402
403
  if (Array.isArray(current)) {
403
404
  if (multi) return current = cleanChildren(parent, current, marker, value);
404
405
  cleanChildren(parent, current, null, value);