solid-js 1.3.17 → 1.4.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/dist/dev.cjs CHANGED
@@ -131,6 +131,7 @@ function nextHydrateContext() {
131
131
 
132
132
  const equalFn = (a, b) => a === b;
133
133
  const $PROXY = Symbol("solid-proxy");
134
+ const $TRACK = Symbol("solid-track");
134
135
  const $DEVCOMP = Symbol("solid-dev-component");
135
136
  const signalOptions = {
136
137
  equals: equalFn
@@ -208,7 +209,7 @@ function createEffect(fn, value, options) {
208
209
  s = SuspenseContext && lookup(Owner, SuspenseContext.id);
209
210
  if (s) c.suspense = s;
210
211
  c.user = true;
211
- Effects ? Effects.push(c) : queueMicrotask(() => updateComputation(c));
212
+ Effects ? Effects.push(c) : updateComputation(c);
212
213
  }
213
214
  function createReaction(onInvalidate, options) {
214
215
  let fn;
@@ -249,13 +250,8 @@ function createResource(source, fetcher, options) {
249
250
  source = true;
250
251
  }
251
252
  options || (options = {});
252
- if (options.globalRefetch !== false) {
253
- Resources || (Resources = new Set());
254
- Resources.add(load);
255
- Owner && onCleanup(() => Resources.delete(load));
256
- }
257
253
  const contexts = new Set(),
258
- [s, set] = createSignal(options.initialValue),
254
+ [value, setValue] = createSignal(options.initialValue),
259
255
  [track, trigger] = createSignal(undefined, {
260
256
  equals: false
261
257
  }),
@@ -267,7 +263,8 @@ function createResource(source, fetcher, options) {
267
263
  id = null,
268
264
  loadedUnderTransition = false,
269
265
  scheduled = false,
270
- dynamic = typeof source === "function";
266
+ resolved = ("initialValue" in options),
267
+ dynamic = typeof source === "function" && createMemo(source);
271
268
  if (sharedConfig.context) {
272
269
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
273
270
  if (sharedConfig.load) initP = sharedConfig.load(id);
@@ -275,6 +272,7 @@ function createResource(source, fetcher, options) {
275
272
  function loadEnd(p, v, e, key) {
276
273
  if (pr === p) {
277
274
  pr = null;
275
+ resolved = true;
278
276
  if (initP && p === initP && options.onHydrated) options.onHydrated(key, {
279
277
  value: v
280
278
  });
@@ -297,7 +295,7 @@ function createResource(source, fetcher, options) {
297
295
  }
298
296
  function completeLoad(v) {
299
297
  batch(() => {
300
- set(() => v);
298
+ setValue(() => v);
301
299
  setLoading(false);
302
300
  for (const c of contexts.keys()) c.decrement();
303
301
  contexts.clear();
@@ -305,7 +303,7 @@ function createResource(source, fetcher, options) {
305
303
  }
306
304
  function read() {
307
305
  const c = SuspenseContext && lookup(Owner, SuspenseContext.id),
308
- v = s();
306
+ v = value();
309
307
  if (err) throw err;
310
308
  if (Listener && !Listener.user && c) {
311
309
  createComputed(() => {
@@ -324,15 +322,15 @@ function createResource(source, fetcher, options) {
324
322
  if (refetching && scheduled) return;
325
323
  scheduled = false;
326
324
  setError(err = undefined);
327
- const lookup = dynamic ? source() : source;
325
+ const lookup = dynamic ? dynamic() : source;
328
326
  loadedUnderTransition = Transition && Transition.running;
329
327
  if (lookup == null || lookup === false) {
330
- loadEnd(pr, untrack(s));
328
+ loadEnd(pr, untrack(value));
331
329
  return;
332
330
  }
333
331
  if (Transition && pr) Transition.promises.delete(pr);
334
332
  const p = initP || untrack(() => fetcher(lookup, {
335
- value: s(),
333
+ value: value(),
336
334
  refetching
337
335
  }));
338
336
  if (typeof p !== "object" || !("then" in p)) {
@@ -358,18 +356,21 @@ function createResource(source, fetcher, options) {
358
356
  get() {
359
357
  return error();
360
358
  }
359
+ },
360
+ latest: {
361
+ get() {
362
+ if (!resolved) return read();
363
+ if (err) throw err;
364
+ return value();
365
+ }
361
366
  }
362
367
  });
363
368
  if (dynamic) createComputed(() => load(false));else load(false);
364
369
  return [read, {
365
370
  refetch: load,
366
- mutate: set
371
+ mutate: setValue
367
372
  }];
368
373
  }
369
- let Resources;
370
- function refetchResources(info) {
371
- return Resources && Promise.all([...Resources].map(fn => fn(info)));
372
- }
373
374
  function createDeferred(source, options) {
374
375
  let t,
375
376
  timeout = options ? options.timeoutMs : undefined;
@@ -797,11 +798,14 @@ function runUpdates(fn, init) {
797
798
  if (Effects) wait = true;else Effects = [];
798
799
  ExecCount++;
799
800
  try {
800
- return fn();
801
+ const res = fn();
802
+ completeUpdates(wait);
803
+ return res;
801
804
  } catch (err) {
802
805
  handleError(err);
803
806
  } finally {
804
- completeUpdates(wait);
807
+ Updates = null;
808
+ if (!wait) Effects = null;
805
809
  }
806
810
  }
807
811
  function completeUpdates(wait) {
@@ -1066,6 +1070,7 @@ function mapArray(list, mapFn, options = {}) {
1066
1070
  let newItems = list() || [],
1067
1071
  i,
1068
1072
  j;
1073
+ newItems[$TRACK];
1069
1074
  return untrack(() => {
1070
1075
  let newLen = newItems.length,
1071
1076
  newIndices,
@@ -1167,6 +1172,7 @@ function indexArray(list, mapFn, options = {}) {
1167
1172
  onCleanup(() => dispose(disposers));
1168
1173
  return () => {
1169
1174
  const newItems = list() || [];
1175
+ newItems[$TRACK];
1170
1176
  return untrack(() => {
1171
1177
  if (newItems.length === 0) {
1172
1178
  if (len !== 0) {
@@ -1226,12 +1232,12 @@ function createComponent(Comp, props) {
1226
1232
  if (sharedConfig.context) {
1227
1233
  const c = sharedConfig.context;
1228
1234
  setHydrateContext(nextHydrateContext());
1229
- const r = devComponent(Comp, props) ;
1235
+ const r = devComponent(Comp, props || {}) ;
1230
1236
  setHydrateContext(c);
1231
1237
  return r;
1232
1238
  }
1233
1239
  }
1234
- return devComponent(Comp, props);
1240
+ return devComponent(Comp, props || {});
1235
1241
  }
1236
1242
  function trueFn() {
1237
1243
  return true;
@@ -1262,7 +1268,7 @@ const propTraps = {
1262
1268
  }
1263
1269
  };
1264
1270
  function resolveSource(s) {
1265
- return typeof s === "function" ? s() : s;
1271
+ return (s = typeof s === "function" ? s() : s) == null ? {} : s;
1266
1272
  }
1267
1273
  function mergeProps(...sources) {
1268
1274
  return new Proxy({
@@ -1330,9 +1336,7 @@ function lazy(fn) {
1330
1336
  });
1331
1337
  comp = s;
1332
1338
  } else if (!comp) {
1333
- const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default), {
1334
- globalRefetch: false
1335
- });
1339
+ const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
1336
1340
  comp = s;
1337
1341
  } else {
1338
1342
  const c = comp();
@@ -1601,6 +1605,7 @@ if (globalThis) {
1601
1605
 
1602
1606
  exports.$DEVCOMP = $DEVCOMP;
1603
1607
  exports.$PROXY = $PROXY;
1608
+ exports.$TRACK = $TRACK;
1604
1609
  exports.ErrorBoundary = ErrorBoundary;
1605
1610
  exports.For = For;
1606
1611
  exports.Index = Index;
@@ -1641,7 +1646,6 @@ exports.on = on;
1641
1646
  exports.onCleanup = onCleanup;
1642
1647
  exports.onError = onError;
1643
1648
  exports.onMount = onMount;
1644
- exports.refetchResources = refetchResources;
1645
1649
  exports.requestCallback = requestCallback;
1646
1650
  exports.resetErrorBoundaries = resetErrorBoundaries;
1647
1651
  exports.runWithOwner = runWithOwner;
package/dist/dev.js CHANGED
@@ -127,6 +127,7 @@ function nextHydrateContext() {
127
127
 
128
128
  const equalFn = (a, b) => a === b;
129
129
  const $PROXY = Symbol("solid-proxy");
130
+ const $TRACK = Symbol("solid-track");
130
131
  const $DEVCOMP = Symbol("solid-dev-component");
131
132
  const signalOptions = {
132
133
  equals: equalFn
@@ -204,7 +205,7 @@ function createEffect(fn, value, options) {
204
205
  s = SuspenseContext && lookup(Owner, SuspenseContext.id);
205
206
  if (s) c.suspense = s;
206
207
  c.user = true;
207
- Effects ? Effects.push(c) : queueMicrotask(() => updateComputation(c));
208
+ Effects ? Effects.push(c) : updateComputation(c);
208
209
  }
209
210
  function createReaction(onInvalidate, options) {
210
211
  let fn;
@@ -245,13 +246,8 @@ function createResource(source, fetcher, options) {
245
246
  source = true;
246
247
  }
247
248
  options || (options = {});
248
- if (options.globalRefetch !== false) {
249
- Resources || (Resources = new Set());
250
- Resources.add(load);
251
- Owner && onCleanup(() => Resources.delete(load));
252
- }
253
249
  const contexts = new Set(),
254
- [s, set] = createSignal(options.initialValue),
250
+ [value, setValue] = createSignal(options.initialValue),
255
251
  [track, trigger] = createSignal(undefined, {
256
252
  equals: false
257
253
  }),
@@ -263,7 +259,8 @@ function createResource(source, fetcher, options) {
263
259
  id = null,
264
260
  loadedUnderTransition = false,
265
261
  scheduled = false,
266
- dynamic = typeof source === "function";
262
+ resolved = ("initialValue" in options),
263
+ dynamic = typeof source === "function" && createMemo(source);
267
264
  if (sharedConfig.context) {
268
265
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
269
266
  if (sharedConfig.load) initP = sharedConfig.load(id);
@@ -271,6 +268,7 @@ function createResource(source, fetcher, options) {
271
268
  function loadEnd(p, v, e, key) {
272
269
  if (pr === p) {
273
270
  pr = null;
271
+ resolved = true;
274
272
  if (initP && p === initP && options.onHydrated) options.onHydrated(key, {
275
273
  value: v
276
274
  });
@@ -293,7 +291,7 @@ function createResource(source, fetcher, options) {
293
291
  }
294
292
  function completeLoad(v) {
295
293
  batch(() => {
296
- set(() => v);
294
+ setValue(() => v);
297
295
  setLoading(false);
298
296
  for (const c of contexts.keys()) c.decrement();
299
297
  contexts.clear();
@@ -301,7 +299,7 @@ function createResource(source, fetcher, options) {
301
299
  }
302
300
  function read() {
303
301
  const c = SuspenseContext && lookup(Owner, SuspenseContext.id),
304
- v = s();
302
+ v = value();
305
303
  if (err) throw err;
306
304
  if (Listener && !Listener.user && c) {
307
305
  createComputed(() => {
@@ -320,15 +318,15 @@ function createResource(source, fetcher, options) {
320
318
  if (refetching && scheduled) return;
321
319
  scheduled = false;
322
320
  setError(err = undefined);
323
- const lookup = dynamic ? source() : source;
321
+ const lookup = dynamic ? dynamic() : source;
324
322
  loadedUnderTransition = Transition && Transition.running;
325
323
  if (lookup == null || lookup === false) {
326
- loadEnd(pr, untrack(s));
324
+ loadEnd(pr, untrack(value));
327
325
  return;
328
326
  }
329
327
  if (Transition && pr) Transition.promises.delete(pr);
330
328
  const p = initP || untrack(() => fetcher(lookup, {
331
- value: s(),
329
+ value: value(),
332
330
  refetching
333
331
  }));
334
332
  if (typeof p !== "object" || !("then" in p)) {
@@ -354,18 +352,21 @@ function createResource(source, fetcher, options) {
354
352
  get() {
355
353
  return error();
356
354
  }
355
+ },
356
+ latest: {
357
+ get() {
358
+ if (!resolved) return read();
359
+ if (err) throw err;
360
+ return value();
361
+ }
357
362
  }
358
363
  });
359
364
  if (dynamic) createComputed(() => load(false));else load(false);
360
365
  return [read, {
361
366
  refetch: load,
362
- mutate: set
367
+ mutate: setValue
363
368
  }];
364
369
  }
365
- let Resources;
366
- function refetchResources(info) {
367
- return Resources && Promise.all([...Resources].map(fn => fn(info)));
368
- }
369
370
  function createDeferred(source, options) {
370
371
  let t,
371
372
  timeout = options ? options.timeoutMs : undefined;
@@ -793,11 +794,14 @@ function runUpdates(fn, init) {
793
794
  if (Effects) wait = true;else Effects = [];
794
795
  ExecCount++;
795
796
  try {
796
- return fn();
797
+ const res = fn();
798
+ completeUpdates(wait);
799
+ return res;
797
800
  } catch (err) {
798
801
  handleError(err);
799
802
  } finally {
800
- completeUpdates(wait);
803
+ Updates = null;
804
+ if (!wait) Effects = null;
801
805
  }
802
806
  }
803
807
  function completeUpdates(wait) {
@@ -1062,6 +1066,7 @@ function mapArray(list, mapFn, options = {}) {
1062
1066
  let newItems = list() || [],
1063
1067
  i,
1064
1068
  j;
1069
+ newItems[$TRACK];
1065
1070
  return untrack(() => {
1066
1071
  let newLen = newItems.length,
1067
1072
  newIndices,
@@ -1163,6 +1168,7 @@ function indexArray(list, mapFn, options = {}) {
1163
1168
  onCleanup(() => dispose(disposers));
1164
1169
  return () => {
1165
1170
  const newItems = list() || [];
1171
+ newItems[$TRACK];
1166
1172
  return untrack(() => {
1167
1173
  if (newItems.length === 0) {
1168
1174
  if (len !== 0) {
@@ -1222,12 +1228,12 @@ function createComponent(Comp, props) {
1222
1228
  if (sharedConfig.context) {
1223
1229
  const c = sharedConfig.context;
1224
1230
  setHydrateContext(nextHydrateContext());
1225
- const r = devComponent(Comp, props) ;
1231
+ const r = devComponent(Comp, props || {}) ;
1226
1232
  setHydrateContext(c);
1227
1233
  return r;
1228
1234
  }
1229
1235
  }
1230
- return devComponent(Comp, props);
1236
+ return devComponent(Comp, props || {});
1231
1237
  }
1232
1238
  function trueFn() {
1233
1239
  return true;
@@ -1258,7 +1264,7 @@ const propTraps = {
1258
1264
  }
1259
1265
  };
1260
1266
  function resolveSource(s) {
1261
- return typeof s === "function" ? s() : s;
1267
+ return (s = typeof s === "function" ? s() : s) == null ? {} : s;
1262
1268
  }
1263
1269
  function mergeProps(...sources) {
1264
1270
  return new Proxy({
@@ -1326,9 +1332,7 @@ function lazy(fn) {
1326
1332
  });
1327
1333
  comp = s;
1328
1334
  } else if (!comp) {
1329
- const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default), {
1330
- globalRefetch: false
1331
- });
1335
+ const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
1332
1336
  comp = s;
1333
1337
  } else {
1334
1338
  const c = comp();
@@ -1595,4 +1599,4 @@ if (globalThis) {
1595
1599
  if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
1596
1600
  }
1597
1601
 
1598
- export { $DEVCOMP, $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, refetchResources, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
1602
+ export { $DEVCOMP, $PROXY, $TRACK, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
package/dist/server.cjs CHANGED
@@ -249,11 +249,11 @@ function createComponent(Comp, props) {
249
249
  if (sharedConfig.context && !sharedConfig.context.noHydrate) {
250
250
  const c = sharedConfig.context;
251
251
  setHydrateContext(nextHydrateContext());
252
- const r = Comp(props);
252
+ const r = Comp(props || {});
253
253
  setHydrateContext(c);
254
254
  return r;
255
255
  }
256
- return Comp(props);
256
+ return Comp(props || {});
257
257
  }
258
258
  function mergeProps(...sources) {
259
259
  const target = {};
@@ -372,6 +372,11 @@ function createResource(source, fetcher, options = {}) {
372
372
  };
373
373
  read.loading = false;
374
374
  read.error = undefined;
375
+ Object.defineProperty(read, "latest", {
376
+ get() {
377
+ return read();
378
+ }
379
+ });
375
380
  function load() {
376
381
  const ctx = sharedConfig.context;
377
382
  if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
@@ -395,7 +400,7 @@ function createResource(source, fetcher, options = {}) {
395
400
  }
396
401
  if (p && "then" in p) {
397
402
  read.loading = true;
398
- if (ctx.writeResource) ctx.writeResource(id, p);
403
+ if (ctx.writeResource) ctx.writeResource(id, p, undefined, options.deferStream);
399
404
  return p.then(res => {
400
405
  read.loading = false;
401
406
  ctx.resources[id].data = res;
@@ -419,7 +424,6 @@ function createResource(source, fetcher, options = {}) {
419
424
  mutate: v => value = v
420
425
  }];
421
426
  }
422
- function refetchResources(info) {}
423
427
  function lazy(fn) {
424
428
  let resolved;
425
429
  const p = fn();
@@ -567,7 +571,6 @@ exports.on = on;
567
571
  exports.onCleanup = onCleanup;
568
572
  exports.onError = onError;
569
573
  exports.onMount = onMount;
570
- exports.refetchResources = refetchResources;
571
574
  exports.requestCallback = requestCallback;
572
575
  exports.resetErrorBoundaries = resetErrorBoundaries;
573
576
  exports.runWithOwner = runWithOwner;
package/dist/server.js CHANGED
@@ -245,11 +245,11 @@ function createComponent(Comp, props) {
245
245
  if (sharedConfig.context && !sharedConfig.context.noHydrate) {
246
246
  const c = sharedConfig.context;
247
247
  setHydrateContext(nextHydrateContext());
248
- const r = Comp(props);
248
+ const r = Comp(props || {});
249
249
  setHydrateContext(c);
250
250
  return r;
251
251
  }
252
- return Comp(props);
252
+ return Comp(props || {});
253
253
  }
254
254
  function mergeProps(...sources) {
255
255
  const target = {};
@@ -368,6 +368,11 @@ function createResource(source, fetcher, options = {}) {
368
368
  };
369
369
  read.loading = false;
370
370
  read.error = undefined;
371
+ Object.defineProperty(read, "latest", {
372
+ get() {
373
+ return read();
374
+ }
375
+ });
371
376
  function load() {
372
377
  const ctx = sharedConfig.context;
373
378
  if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
@@ -391,7 +396,7 @@ function createResource(source, fetcher, options = {}) {
391
396
  }
392
397
  if (p && "then" in p) {
393
398
  read.loading = true;
394
- if (ctx.writeResource) ctx.writeResource(id, p);
399
+ if (ctx.writeResource) ctx.writeResource(id, p, undefined, options.deferStream);
395
400
  return p.then(res => {
396
401
  read.loading = false;
397
402
  ctx.resources[id].data = res;
@@ -415,7 +420,6 @@ function createResource(source, fetcher, options = {}) {
415
420
  mutate: v => value = v
416
421
  }];
417
422
  }
418
- function refetchResources(info) {}
419
423
  function lazy(fn) {
420
424
  let resolved;
421
425
  const p = fn();
@@ -522,4 +526,4 @@ function Suspense(props) {
522
526
  return props.fallback;
523
527
  }
524
528
 
525
- export { $DEVCOMP, $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, refetchResources, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
529
+ export { $DEVCOMP, $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
package/dist/solid.cjs CHANGED
@@ -131,6 +131,7 @@ function nextHydrateContext() {
131
131
 
132
132
  const equalFn = (a, b) => a === b;
133
133
  const $PROXY = Symbol("solid-proxy");
134
+ const $TRACK = Symbol("solid-track");
134
135
  const $DEVCOMP = Symbol("solid-dev-component");
135
136
  const signalOptions = {
136
137
  equals: equalFn
@@ -205,7 +206,7 @@ function createEffect(fn, value, options) {
205
206
  s = SuspenseContext && lookup(Owner, SuspenseContext.id);
206
207
  if (s) c.suspense = s;
207
208
  c.user = true;
208
- Effects ? Effects.push(c) : queueMicrotask(() => updateComputation(c));
209
+ Effects ? Effects.push(c) : updateComputation(c);
209
210
  }
210
211
  function createReaction(onInvalidate, options) {
211
212
  let fn;
@@ -246,13 +247,8 @@ function createResource(source, fetcher, options) {
246
247
  source = true;
247
248
  }
248
249
  options || (options = {});
249
- if (options.globalRefetch !== false) {
250
- Resources || (Resources = new Set());
251
- Resources.add(load);
252
- Owner && onCleanup(() => Resources.delete(load));
253
- }
254
250
  const contexts = new Set(),
255
- [s, set] = createSignal(options.initialValue),
251
+ [value, setValue] = createSignal(options.initialValue),
256
252
  [track, trigger] = createSignal(undefined, {
257
253
  equals: false
258
254
  }),
@@ -264,7 +260,8 @@ function createResource(source, fetcher, options) {
264
260
  id = null,
265
261
  loadedUnderTransition = false,
266
262
  scheduled = false,
267
- dynamic = typeof source === "function";
263
+ resolved = ("initialValue" in options),
264
+ dynamic = typeof source === "function" && createMemo(source);
268
265
  if (sharedConfig.context) {
269
266
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
270
267
  if (sharedConfig.load) initP = sharedConfig.load(id);
@@ -272,6 +269,7 @@ function createResource(source, fetcher, options) {
272
269
  function loadEnd(p, v, e, key) {
273
270
  if (pr === p) {
274
271
  pr = null;
272
+ resolved = true;
275
273
  if (initP && p === initP && options.onHydrated) options.onHydrated(key, {
276
274
  value: v
277
275
  });
@@ -294,7 +292,7 @@ function createResource(source, fetcher, options) {
294
292
  }
295
293
  function completeLoad(v) {
296
294
  batch(() => {
297
- set(() => v);
295
+ setValue(() => v);
298
296
  setLoading(false);
299
297
  for (const c of contexts.keys()) c.decrement();
300
298
  contexts.clear();
@@ -302,7 +300,7 @@ function createResource(source, fetcher, options) {
302
300
  }
303
301
  function read() {
304
302
  const c = SuspenseContext && lookup(Owner, SuspenseContext.id),
305
- v = s();
303
+ v = value();
306
304
  if (err) throw err;
307
305
  if (Listener && !Listener.user && c) {
308
306
  createComputed(() => {
@@ -321,15 +319,15 @@ function createResource(source, fetcher, options) {
321
319
  if (refetching && scheduled) return;
322
320
  scheduled = false;
323
321
  setError(err = undefined);
324
- const lookup = dynamic ? source() : source;
322
+ const lookup = dynamic ? dynamic() : source;
325
323
  loadedUnderTransition = Transition && Transition.running;
326
324
  if (lookup == null || lookup === false) {
327
- loadEnd(pr, untrack(s));
325
+ loadEnd(pr, untrack(value));
328
326
  return;
329
327
  }
330
328
  if (Transition && pr) Transition.promises.delete(pr);
331
329
  const p = initP || untrack(() => fetcher(lookup, {
332
- value: s(),
330
+ value: value(),
333
331
  refetching
334
332
  }));
335
333
  if (typeof p !== "object" || !("then" in p)) {
@@ -355,18 +353,21 @@ function createResource(source, fetcher, options) {
355
353
  get() {
356
354
  return error();
357
355
  }
356
+ },
357
+ latest: {
358
+ get() {
359
+ if (!resolved) return read();
360
+ if (err) throw err;
361
+ return value();
362
+ }
358
363
  }
359
364
  });
360
365
  if (dynamic) createComputed(() => load(false));else load(false);
361
366
  return [read, {
362
367
  refetch: load,
363
- mutate: set
368
+ mutate: setValue
364
369
  }];
365
370
  }
366
- let Resources;
367
- function refetchResources(info) {
368
- return Resources && Promise.all([...Resources].map(fn => fn(info)));
369
- }
370
371
  function createDeferred(source, options) {
371
372
  let t,
372
373
  timeout = options ? options.timeoutMs : undefined;
@@ -740,11 +741,14 @@ function runUpdates(fn, init) {
740
741
  if (Effects) wait = true;else Effects = [];
741
742
  ExecCount++;
742
743
  try {
743
- return fn();
744
+ const res = fn();
745
+ completeUpdates(wait);
746
+ return res;
744
747
  } catch (err) {
745
748
  handleError(err);
746
749
  } finally {
747
- completeUpdates(wait);
750
+ Updates = null;
751
+ if (!wait) Effects = null;
748
752
  }
749
753
  }
750
754
  function completeUpdates(wait) {
@@ -985,6 +989,7 @@ function mapArray(list, mapFn, options = {}) {
985
989
  let newItems = list() || [],
986
990
  i,
987
991
  j;
992
+ newItems[$TRACK];
988
993
  return untrack(() => {
989
994
  let newLen = newItems.length,
990
995
  newIndices,
@@ -1086,6 +1091,7 @@ function indexArray(list, mapFn, options = {}) {
1086
1091
  onCleanup(() => dispose(disposers));
1087
1092
  return () => {
1088
1093
  const newItems = list() || [];
1094
+ newItems[$TRACK];
1089
1095
  return untrack(() => {
1090
1096
  if (newItems.length === 0) {
1091
1097
  if (len !== 0) {
@@ -1145,12 +1151,12 @@ function createComponent(Comp, props) {
1145
1151
  if (sharedConfig.context) {
1146
1152
  const c = sharedConfig.context;
1147
1153
  setHydrateContext(nextHydrateContext());
1148
- const r = untrack(() => Comp(props));
1154
+ const r = untrack(() => Comp(props || {}));
1149
1155
  setHydrateContext(c);
1150
1156
  return r;
1151
1157
  }
1152
1158
  }
1153
- return untrack(() => Comp(props));
1159
+ return untrack(() => Comp(props || {}));
1154
1160
  }
1155
1161
  function trueFn() {
1156
1162
  return true;
@@ -1181,7 +1187,7 @@ const propTraps = {
1181
1187
  }
1182
1188
  };
1183
1189
  function resolveSource(s) {
1184
- return typeof s === "function" ? s() : s;
1190
+ return (s = typeof s === "function" ? s() : s) == null ? {} : s;
1185
1191
  }
1186
1192
  function mergeProps(...sources) {
1187
1193
  return new Proxy({
@@ -1249,9 +1255,7 @@ function lazy(fn) {
1249
1255
  });
1250
1256
  comp = s;
1251
1257
  } else if (!comp) {
1252
- const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default), {
1253
- globalRefetch: false
1254
- });
1258
+ const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
1255
1259
  comp = s;
1256
1260
  } else {
1257
1261
  const c = comp();
@@ -1505,6 +1509,7 @@ let DEV;
1505
1509
 
1506
1510
  exports.$DEVCOMP = $DEVCOMP;
1507
1511
  exports.$PROXY = $PROXY;
1512
+ exports.$TRACK = $TRACK;
1508
1513
  exports.DEV = DEV;
1509
1514
  exports.ErrorBoundary = ErrorBoundary;
1510
1515
  exports.For = For;
@@ -1546,7 +1551,6 @@ exports.on = on;
1546
1551
  exports.onCleanup = onCleanup;
1547
1552
  exports.onError = onError;
1548
1553
  exports.onMount = onMount;
1549
- exports.refetchResources = refetchResources;
1550
1554
  exports.requestCallback = requestCallback;
1551
1555
  exports.resetErrorBoundaries = resetErrorBoundaries;
1552
1556
  exports.runWithOwner = runWithOwner;