solid-js 1.3.0-beta.2 → 1.3.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/dist/server.js CHANGED
@@ -37,8 +37,15 @@ function createComputed(fn, value) {
37
37
  owner: Owner,
38
38
  context: null
39
39
  };
40
- fn(value);
41
- Owner = Owner.owner;
40
+ try {
41
+ fn(value);
42
+ } catch (err) {
43
+ const fns = lookup(Owner, ERROR);
44
+ if (!fns) throw err;
45
+ fns.forEach(f => f(err));
46
+ } finally {
47
+ Owner = Owner.owner;
48
+ }
42
49
  }
43
50
  const createRenderEffect = createComputed;
44
51
  function createEffect(fn, value) {}
@@ -47,8 +54,16 @@ function createMemo(fn, value) {
47
54
  owner: Owner,
48
55
  context: null
49
56
  };
50
- const v = fn(value);
51
- Owner = Owner.owner;
57
+ let v;
58
+ try {
59
+ v = fn(value);
60
+ } catch (err) {
61
+ const fns = lookup(Owner, ERROR);
62
+ if (!fns) throw err;
63
+ fns.forEach(f => f(err));
64
+ } finally {
65
+ Owner = Owner.owner;
66
+ }
52
67
  return () => v;
53
68
  }
54
69
  function createDeferred(source) {
@@ -189,6 +204,7 @@ function from(producer) {
189
204
  }
190
205
  return s;
191
206
  }
207
+ function enableExternalSource(factory) {}
192
208
 
193
209
  function resolveSSRNode(node) {
194
210
  const t = typeof node;
@@ -286,7 +302,20 @@ function Match(props) {
286
302
  return props;
287
303
  }
288
304
  function ErrorBoundary(props) {
289
- return props.children;
305
+ let error, res;
306
+ const ctx = sharedConfig.context;
307
+ const id = ctx.id + ctx.count;
308
+ onError(err => error = err);
309
+ createMemo(() => res = props.children);
310
+ if (error) {
311
+ ctx.writeResource(id, error, true);
312
+ setHydrateContext({ ...ctx,
313
+ count: 0
314
+ });
315
+ const f = props.fallback;
316
+ return typeof f === "function" && f.length ? f(error, () => {}) : f;
317
+ }
318
+ return res;
290
319
  }
291
320
  const SuspenseContext = createContext();
292
321
  let resourceContext = null;
@@ -306,6 +335,7 @@ function createResource(fn, fetcher, options = {}) {
306
335
  let resource = {};
307
336
  let value = options.initialValue;
308
337
  let p;
338
+ let error;
309
339
  if (sharedConfig.context.async) {
310
340
  resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
311
341
  if (resource.ref) {
@@ -314,9 +344,10 @@ function createResource(fn, fetcher, options = {}) {
314
344
  }
315
345
  }
316
346
  const read = () => {
347
+ if (error) throw error;
317
348
  if (resourceContext && p) resourceContext.push(p);
318
349
  const resolved = sharedConfig.context.async && sharedConfig.context.resources[id].data;
319
- if (!resolved) {
350
+ if (!resolved && read.loading) {
320
351
  const ctx = useContext(SuspenseContext);
321
352
  if (ctx) {
322
353
  ctx.resources.set(id, read);
@@ -328,7 +359,7 @@ function createResource(fn, fetcher, options = {}) {
328
359
  read.loading = false;
329
360
  function load() {
330
361
  const ctx = sharedConfig.context;
331
- if (!ctx.async) return read.loading = true;
362
+ if (!ctx.async) return read.loading = !!(typeof fn === "function" ? fn() : fn);
332
363
  if (ctx.resources && id in ctx.resources && ctx.resources[id].data) {
333
364
  value = ctx.resources[id].data;
334
365
  return;
@@ -352,6 +383,11 @@ function createResource(fn, fetcher, options = {}) {
352
383
  p = null;
353
384
  notifySuspense(contexts);
354
385
  return res;
386
+ }).catch(err => {
387
+ read.loading = false;
388
+ error = err;
389
+ p = null;
390
+ notifySuspense(contexts);
355
391
  });
356
392
  return;
357
393
  }
@@ -386,7 +422,7 @@ function lazy(fn) {
386
422
  });
387
423
  return "";
388
424
  };
389
- wrap.preload = () => {};
425
+ wrap.preload = () => p;
390
426
  return wrap;
391
427
  }
392
428
  function suspenseComplete(c) {
@@ -414,13 +450,14 @@ function SuspenseList(props) {
414
450
  return props.children;
415
451
  }
416
452
  function Suspense(props) {
453
+ let done;
417
454
  const ctx = sharedConfig.context;
418
455
  const id = ctx.id + ctx.count;
419
- const done = ctx.async ? ctx.registerFragment(id) : () => {};
420
456
  const o = Owner;
421
457
  const value = ctx.suspense[id] || (ctx.suspense[id] = {
422
458
  resources: new Map(),
423
459
  completed: () => {
460
+ if (ctx.dataOnly) return done();
424
461
  const res = runSuspense();
425
462
  if (suspenseComplete(value)) {
426
463
  done(resolveSSRNode(res));
@@ -441,12 +478,13 @@ function Suspense(props) {
441
478
  });
442
479
  }
443
480
  const res = runSuspense();
444
- if (suspenseComplete(value)) {
445
- done();
446
- return res;
447
- }
448
- if (sharedConfig.context.async) {
449
- if (sharedConfig.context.streaming) {
481
+ if (suspenseComplete(value)) return res;
482
+ onError(err => {
483
+ if (!done || !done(undefined, err)) throw err;
484
+ });
485
+ done = ctx.async ? ctx.registerFragment(id) : undefined;
486
+ if (ctx.streaming) {
487
+ if (!ctx.dataOnly) {
450
488
  setHydrateContext(undefined);
451
489
  const res = {
452
490
  t: `<span id="pl${id}">${resolveSSRNode(props.fallback)}</span>`
@@ -454,14 +492,16 @@ function Suspense(props) {
454
492
  setHydrateContext(ctx);
455
493
  return res;
456
494
  }
495
+ } else if (ctx.async) {
457
496
  return {
458
497
  t: `<![${id}]>`
459
498
  };
460
499
  }
461
500
  setHydrateContext({ ...ctx,
462
- count: 0
501
+ count: 0,
502
+ id: ctx.id + "0.f"
463
503
  });
464
- return createComponent(() => props.fallback, {});
504
+ return props.fallback;
465
505
  }
466
506
 
467
- 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, enableScheduling, equalFn, from, getListener, getOwner, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
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
@@ -149,6 +149,7 @@ const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
149
149
  var Owner = null;
150
150
  let Transition = null;
151
151
  let Scheduler = null;
152
+ let ExternalSourceFactory = null;
152
153
  let Listener = null;
153
154
  let Pending = null;
154
155
  let Updates = null;
@@ -503,6 +504,24 @@ let SuspenseContext;
503
504
  function getSuspenseContext() {
504
505
  return SuspenseContext || (SuspenseContext = createContext({}));
505
506
  }
507
+ function enableExternalSource(factory) {
508
+ if (ExternalSourceFactory) {
509
+ const oldFactory = ExternalSourceFactory;
510
+ ExternalSourceFactory = (fn, trigger) => {
511
+ const oldSource = oldFactory(fn, trigger);
512
+ const source = factory(x => oldSource.track(x), trigger);
513
+ return {
514
+ track: x => source.track(x),
515
+ dispose() {
516
+ source.dispose();
517
+ oldSource.dispose();
518
+ }
519
+ };
520
+ };
521
+ } else {
522
+ ExternalSourceFactory = factory;
523
+ }
524
+ }
506
525
  function readSignal() {
507
526
  const runningTransition = Transition && Transition.running;
508
527
  if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
@@ -630,6 +649,19 @@ function createComputation(fn, init, pure, state = STALE, options) {
630
649
  if (!Owner.owned) Owner.owned = [c];else Owner.owned.push(c);
631
650
  }
632
651
  }
652
+ if (ExternalSourceFactory) {
653
+ const [track, trigger] = createSignal(undefined, {
654
+ equals: false
655
+ });
656
+ const ordinary = ExternalSourceFactory(c.fn, trigger);
657
+ onCleanup(() => ordinary.dispose());
658
+ const triggerInTransition = () => startTransition(trigger, () => inTransition.dispose());
659
+ const inTransition = ExternalSourceFactory(c.fn, triggerInTransition);
660
+ c.fn = x => {
661
+ track();
662
+ return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x);
663
+ };
664
+ }
633
665
  return c;
634
666
  }
635
667
  function runTop(node) {
@@ -1063,13 +1095,19 @@ function indexArray(list, mapFn, options = {}) {
1063
1095
  };
1064
1096
  }
1065
1097
 
1098
+ let hydrationEnabled = false;
1099
+ function enableHydration() {
1100
+ hydrationEnabled = true;
1101
+ }
1066
1102
  function createComponent(Comp, props) {
1067
- if (sharedConfig.context) {
1068
- const c = sharedConfig.context;
1069
- setHydrateContext(nextHydrateContext());
1070
- const r = untrack(() => Comp(props));
1071
- setHydrateContext(c);
1072
- return r;
1103
+ if (hydrationEnabled) {
1104
+ if (sharedConfig.context) {
1105
+ const c = sharedConfig.context;
1106
+ setHydrateContext(nextHydrateContext());
1107
+ const r = untrack(() => Comp(props));
1108
+ setHydrateContext(c);
1109
+ return r;
1110
+ }
1073
1111
  }
1074
1112
  return untrack(() => Comp(props));
1075
1113
  }
@@ -1158,19 +1196,20 @@ function splitProps(props, ...keys) {
1158
1196
  }
1159
1197
  function lazy(fn) {
1160
1198
  let comp;
1199
+ let p;
1161
1200
  const wrap = props => {
1162
1201
  const ctx = sharedConfig.context;
1163
1202
  if (ctx) {
1164
1203
  ctx.count++;
1165
1204
  const [s, set] = createSignal();
1166
- fn().then(mod => {
1205
+ (p || (p = fn())).then(mod => {
1167
1206
  setHydrateContext(ctx);
1168
1207
  set(() => mod.default);
1169
1208
  setHydrateContext(undefined);
1170
1209
  });
1171
1210
  comp = s;
1172
1211
  } else if (!comp) {
1173
- const [s] = createResource(() => fn().then(mod => mod.default));
1212
+ const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
1174
1213
  comp = s;
1175
1214
  } else {
1176
1215
  const c = comp();
@@ -1186,7 +1225,7 @@ function lazy(fn) {
1186
1225
  return r;
1187
1226
  }));
1188
1227
  };
1189
- wrap.preload = () => comp || fn().then(mod => comp = () => mod.default);
1228
+ wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
1190
1229
  return wrap;
1191
1230
  }
1192
1231
  let counter = 0;
@@ -1246,7 +1285,11 @@ function Match(props) {
1246
1285
  return props;
1247
1286
  }
1248
1287
  function ErrorBoundary(props) {
1249
- const [errored, setErrored] = createSignal();
1288
+ let err = undefined;
1289
+ if (sharedConfig.context && sharedConfig.load) {
1290
+ err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
1291
+ }
1292
+ const [errored, setErrored] = createSignal(err);
1250
1293
  let e;
1251
1294
  return createMemo(() => {
1252
1295
  if ((e = errored()) != null) {
@@ -1330,7 +1373,8 @@ function Suspense(props) {
1330
1373
  showFallback,
1331
1374
  ctx,
1332
1375
  waitingHydration,
1333
- flicker;
1376
+ flicker,
1377
+ error;
1334
1378
  const [inFallback, setFallback] = createSignal(false),
1335
1379
  SuspenseContext = getSuspenseContext(),
1336
1380
  store = {
@@ -1345,7 +1389,7 @@ function Suspense(props) {
1345
1389
  resolved: false
1346
1390
  },
1347
1391
  owner = getOwner();
1348
- if (sharedConfig.context && sharedConfig.load) {
1392
+ if (sharedConfig.context) {
1349
1393
  const key = sharedConfig.context.id + sharedConfig.context.count;
1350
1394
  const p = sharedConfig.load(key);
1351
1395
  if (p) {
@@ -1353,7 +1397,8 @@ function Suspense(props) {
1353
1397
  equals: false
1354
1398
  });
1355
1399
  flicker = s;
1356
- p.then(() => {
1400
+ p.then(err => {
1401
+ if (error = err) return set();
1357
1402
  sharedConfig.gather(key);
1358
1403
  waitingHydration = true;
1359
1404
  setHydrateContext(ctx);
@@ -1371,6 +1416,7 @@ function Suspense(props) {
1371
1416
  value: store,
1372
1417
  get children() {
1373
1418
  return createMemo(() => {
1419
+ if (error) throw error;
1374
1420
  if (flicker) {
1375
1421
  ctx = sharedConfig.context;
1376
1422
  flicker();
@@ -1390,7 +1436,10 @@ function Suspense(props) {
1390
1436
  if (!visibleFallback) return;
1391
1437
  return createRoot(disposer => {
1392
1438
  dispose = disposer;
1393
- if (sharedConfig.context) sharedConfig.context.count = 0;
1439
+ if (sharedConfig.context) setHydrateContext({
1440
+ id: sharedConfig.context.id + "f",
1441
+ count: 0
1442
+ });
1394
1443
  return props.fallback;
1395
1444
  }, owner);
1396
1445
  });
@@ -1426,6 +1475,8 @@ exports.createRoot = createRoot;
1426
1475
  exports.createSelector = createSelector;
1427
1476
  exports.createSignal = createSignal;
1428
1477
  exports.createUniqueId = createUniqueId;
1478
+ exports.enableExternalSource = enableExternalSource;
1479
+ exports.enableHydration = enableHydration;
1429
1480
  exports.enableScheduling = enableScheduling;
1430
1481
  exports.equalFn = equalFn;
1431
1482
  exports.from = from;
package/dist/solid.js CHANGED
@@ -145,6 +145,7 @@ const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
145
145
  var Owner = null;
146
146
  let Transition = null;
147
147
  let Scheduler = null;
148
+ let ExternalSourceFactory = null;
148
149
  let Listener = null;
149
150
  let Pending = null;
150
151
  let Updates = null;
@@ -499,6 +500,24 @@ let SuspenseContext;
499
500
  function getSuspenseContext() {
500
501
  return SuspenseContext || (SuspenseContext = createContext({}));
501
502
  }
503
+ function enableExternalSource(factory) {
504
+ if (ExternalSourceFactory) {
505
+ const oldFactory = ExternalSourceFactory;
506
+ ExternalSourceFactory = (fn, trigger) => {
507
+ const oldSource = oldFactory(fn, trigger);
508
+ const source = factory(x => oldSource.track(x), trigger);
509
+ return {
510
+ track: x => source.track(x),
511
+ dispose() {
512
+ source.dispose();
513
+ oldSource.dispose();
514
+ }
515
+ };
516
+ };
517
+ } else {
518
+ ExternalSourceFactory = factory;
519
+ }
520
+ }
502
521
  function readSignal() {
503
522
  const runningTransition = Transition && Transition.running;
504
523
  if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
@@ -626,6 +645,19 @@ function createComputation(fn, init, pure, state = STALE, options) {
626
645
  if (!Owner.owned) Owner.owned = [c];else Owner.owned.push(c);
627
646
  }
628
647
  }
648
+ if (ExternalSourceFactory) {
649
+ const [track, trigger] = createSignal(undefined, {
650
+ equals: false
651
+ });
652
+ const ordinary = ExternalSourceFactory(c.fn, trigger);
653
+ onCleanup(() => ordinary.dispose());
654
+ const triggerInTransition = () => startTransition(trigger, () => inTransition.dispose());
655
+ const inTransition = ExternalSourceFactory(c.fn, triggerInTransition);
656
+ c.fn = x => {
657
+ track();
658
+ return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x);
659
+ };
660
+ }
629
661
  return c;
630
662
  }
631
663
  function runTop(node) {
@@ -1059,13 +1091,19 @@ function indexArray(list, mapFn, options = {}) {
1059
1091
  };
1060
1092
  }
1061
1093
 
1094
+ let hydrationEnabled = false;
1095
+ function enableHydration() {
1096
+ hydrationEnabled = true;
1097
+ }
1062
1098
  function createComponent(Comp, props) {
1063
- if (sharedConfig.context) {
1064
- const c = sharedConfig.context;
1065
- setHydrateContext(nextHydrateContext());
1066
- const r = untrack(() => Comp(props));
1067
- setHydrateContext(c);
1068
- return r;
1099
+ if (hydrationEnabled) {
1100
+ if (sharedConfig.context) {
1101
+ const c = sharedConfig.context;
1102
+ setHydrateContext(nextHydrateContext());
1103
+ const r = untrack(() => Comp(props));
1104
+ setHydrateContext(c);
1105
+ return r;
1106
+ }
1069
1107
  }
1070
1108
  return untrack(() => Comp(props));
1071
1109
  }
@@ -1154,19 +1192,20 @@ function splitProps(props, ...keys) {
1154
1192
  }
1155
1193
  function lazy(fn) {
1156
1194
  let comp;
1195
+ let p;
1157
1196
  const wrap = props => {
1158
1197
  const ctx = sharedConfig.context;
1159
1198
  if (ctx) {
1160
1199
  ctx.count++;
1161
1200
  const [s, set] = createSignal();
1162
- fn().then(mod => {
1201
+ (p || (p = fn())).then(mod => {
1163
1202
  setHydrateContext(ctx);
1164
1203
  set(() => mod.default);
1165
1204
  setHydrateContext(undefined);
1166
1205
  });
1167
1206
  comp = s;
1168
1207
  } else if (!comp) {
1169
- const [s] = createResource(() => fn().then(mod => mod.default));
1208
+ const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
1170
1209
  comp = s;
1171
1210
  } else {
1172
1211
  const c = comp();
@@ -1182,7 +1221,7 @@ function lazy(fn) {
1182
1221
  return r;
1183
1222
  }));
1184
1223
  };
1185
- wrap.preload = () => comp || fn().then(mod => comp = () => mod.default);
1224
+ wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
1186
1225
  return wrap;
1187
1226
  }
1188
1227
  let counter = 0;
@@ -1242,7 +1281,11 @@ function Match(props) {
1242
1281
  return props;
1243
1282
  }
1244
1283
  function ErrorBoundary(props) {
1245
- const [errored, setErrored] = createSignal();
1284
+ let err = undefined;
1285
+ if (sharedConfig.context && sharedConfig.load) {
1286
+ err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
1287
+ }
1288
+ const [errored, setErrored] = createSignal(err);
1246
1289
  let e;
1247
1290
  return createMemo(() => {
1248
1291
  if ((e = errored()) != null) {
@@ -1326,7 +1369,8 @@ function Suspense(props) {
1326
1369
  showFallback,
1327
1370
  ctx,
1328
1371
  waitingHydration,
1329
- flicker;
1372
+ flicker,
1373
+ error;
1330
1374
  const [inFallback, setFallback] = createSignal(false),
1331
1375
  SuspenseContext = getSuspenseContext(),
1332
1376
  store = {
@@ -1341,7 +1385,7 @@ function Suspense(props) {
1341
1385
  resolved: false
1342
1386
  },
1343
1387
  owner = getOwner();
1344
- if (sharedConfig.context && sharedConfig.load) {
1388
+ if (sharedConfig.context) {
1345
1389
  const key = sharedConfig.context.id + sharedConfig.context.count;
1346
1390
  const p = sharedConfig.load(key);
1347
1391
  if (p) {
@@ -1349,7 +1393,8 @@ function Suspense(props) {
1349
1393
  equals: false
1350
1394
  });
1351
1395
  flicker = s;
1352
- p.then(() => {
1396
+ p.then(err => {
1397
+ if (error = err) return set();
1353
1398
  sharedConfig.gather(key);
1354
1399
  waitingHydration = true;
1355
1400
  setHydrateContext(ctx);
@@ -1367,6 +1412,7 @@ function Suspense(props) {
1367
1412
  value: store,
1368
1413
  get children() {
1369
1414
  return createMemo(() => {
1415
+ if (error) throw error;
1370
1416
  if (flicker) {
1371
1417
  ctx = sharedConfig.context;
1372
1418
  flicker();
@@ -1386,7 +1432,10 @@ function Suspense(props) {
1386
1432
  if (!visibleFallback) return;
1387
1433
  return createRoot(disposer => {
1388
1434
  dispose = disposer;
1389
- if (sharedConfig.context) sharedConfig.context.count = 0;
1435
+ if (sharedConfig.context) setHydrateContext({
1436
+ id: sharedConfig.context.id + "f",
1437
+ count: 0
1438
+ });
1390
1439
  return props.fallback;
1391
1440
  }, owner);
1392
1441
  });
@@ -1397,4 +1446,4 @@ function Suspense(props) {
1397
1446
 
1398
1447
  let DEV;
1399
1448
 
1400
- export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
1449
+ export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "solid-js",
3
3
  "description": "A declarative JavaScript library for building user interfaces.",
4
- "version": "1.3.0-beta.2",
4
+ "version": "1.3.0-beta.6",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
- "homepage": "https://github.com/solidjs/solid#readme",
7
+ "homepage": "https://solidjs.com",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/solidjs/solid"
@@ -36,11 +36,11 @@
36
36
  ],
37
37
  "exports": {
38
38
  ".": {
39
- "development": {
40
- "import": "./dist/dev.js",
41
- "require": "./dist/dev.cjs"
42
- },
43
39
  "browser": {
40
+ "development": {
41
+ "import": "./dist/dev.js",
42
+ "require": "./dist/dev.cjs"
43
+ },
44
44
  "import": "./dist/solid.js",
45
45
  "require": "./dist/solid.cjs"
46
46
  },
@@ -48,16 +48,20 @@
48
48
  "import": "./dist/server.js",
49
49
  "require": "./dist/server.cjs"
50
50
  },
51
+ "development": {
52
+ "import": "./dist/dev.js",
53
+ "require": "./dist/dev.cjs"
54
+ },
51
55
  "import": "./dist/solid.js",
52
56
  "require": "./dist/solid.cjs"
53
57
  },
54
58
  "./dist/*": "./dist/*",
55
59
  "./store": {
56
- "development": {
57
- "import": "./store/dist/dev.js",
58
- "require": "./store/dist/dev.cjs"
59
- },
60
60
  "browser": {
61
+ "development": {
62
+ "import": "./store/dist/dev.js",
63
+ "require": "./store/dist/dev.cjs"
64
+ },
61
65
  "import": "./store/dist/store.js",
62
66
  "require": "./store/dist/store.cjs"
63
67
  },
@@ -65,16 +69,20 @@
65
69
  "import": "./store/dist/server.js",
66
70
  "require": "./store/dist/server.cjs"
67
71
  },
72
+ "development": {
73
+ "import": "./store/dist/dev.js",
74
+ "require": "./store/dist/dev.cjs"
75
+ },
68
76
  "import": "./store/dist/store.js",
69
77
  "require": "./store/dist/store.cjs"
70
78
  },
71
79
  "./store/dist/*": "./store/dist/*",
72
80
  "./web": {
73
- "development": {
74
- "import": "./web/dist/dev.js",
75
- "require": "./web/dist/dev.cjs"
76
- },
77
81
  "browser": {
82
+ "development": {
83
+ "import": "./web/dist/dev.js",
84
+ "require": "./web/dist/dev.cjs"
85
+ },
78
86
  "import": "./web/dist/web.js",
79
87
  "require": "./web/dist/web.cjs"
80
88
  },
@@ -82,6 +90,10 @@
82
90
  "import": "./web/dist/server.js",
83
91
  "require": "./web/dist/server.cjs"
84
92
  },
93
+ "development": {
94
+ "import": "./web/dist/dev.js",
95
+ "require": "./web/dist/dev.cjs"
96
+ },
85
97
  "import": "./web/dist/web.js",
86
98
  "require": "./web/dist/web.cjs"
87
99
  },
@@ -132,5 +144,5 @@
132
144
  "compiler",
133
145
  "performance"
134
146
  ],
135
- "gitHead": "afe407af6463d4956c2c283370895b4d02b205e8"
147
+ "gitHead": "76f31202b63d632cdef2ad2a36b158ede07597be"
136
148
  }
package/types/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { createRoot, createSignal, createEffect, createRenderEffect, createComputed, createDeferred, createSelector, createMemo, createResource, onMount, onCleanup, onError, untrack, batch, on, enableScheduling, startTransition, useTransition, createContext, useContext, children, getListener, getOwner, runWithOwner, equalFn, $PROXY } from "./reactive/signal";
1
+ export { createRoot, createSignal, createEffect, createRenderEffect, createComputed, createDeferred, createSelector, createMemo, createResource, onMount, onCleanup, onError, untrack, batch, on, enableScheduling, enableExternalSource, startTransition, useTransition, createContext, useContext, children, getListener, getOwner, runWithOwner, equalFn, $PROXY } from "./reactive/signal";
2
2
  export type { Accessor, Setter, Resource, ResourceReturn, Context, ReturnTypes } from "./reactive/signal";
3
3
  export * from "./reactive/observable";
4
4
  export * from "./reactive/scheduler";
@@ -5,6 +5,7 @@ export declare const $PROXY: unique symbol;
5
5
  export declare const NOTPENDING: {};
6
6
  export declare var Owner: Owner | null;
7
7
  export declare let Transition: TransitionState | null;
8
+ declare let ExternalSourceFactory: ExternalSourceFactory | null;
8
9
  declare global {
9
10
  var _$afterUpdate: () => void;
10
11
  }
@@ -50,6 +51,11 @@ export interface TransitionState {
50
51
  running: boolean;
51
52
  cb: (() => void)[];
52
53
  }
54
+ declare type ExternalSourceFactory = <Prev, Next extends Prev = Prev>(fn: EffectFunction<Prev, Next>, trigger: () => void) => ExternalSource;
55
+ export interface ExternalSource {
56
+ track: EffectFunction<any, any>;
57
+ dispose: () => void;
58
+ }
53
59
  export declare type RootFunction<T> = (dispose: () => void) => T;
54
60
  /**
55
61
  * Creates a new non-tracked reactive context that doesn't auto-dispose
@@ -423,6 +429,7 @@ declare type SuspenseContext = Context<SuspenseContextType> & {
423
429
  };
424
430
  declare let SuspenseContext: SuspenseContext;
425
431
  export declare function getSuspenseContext(): SuspenseContext;
432
+ export declare function enableExternalSource(factory: ExternalSourceFactory): void;
426
433
  export declare function readSignal(this: SignalState<any> | Memo<any>): any;
427
434
  export declare function writeSignal(node: SignalState<any> | Memo<any>, value: any, isComp?: boolean): any;
428
435
  export {};
@@ -1,4 +1,5 @@
1
1
  import type { JSX } from "../jsx";
2
+ export declare function enableHydration(): void;
2
3
  export declare type PropsWithChildren<P = {}> = P & {
3
4
  children?: JSX.Element;
4
5
  };
@@ -36,7 +37,9 @@ export declare function splitProps<T extends object, K1 extends keyof T, K2 exte
36
37
  export declare function lazy<T extends Component<any>>(fn: () => Promise<{
37
38
  default: T;
38
39
  }>): T & {
39
- preload: () => void;
40
+ preload: () => Promise<{
41
+ default: T;
42
+ }>;
40
43
  };
41
44
  export declare function createUniqueId(): string;
42
45
  export {};
@@ -1,3 +1,3 @@
1
- export { createRoot, createSignal, createComputed, createRenderEffect, createEffect, createDeferred, createSelector, createMemo, getListener, onMount, onCleanup, onError, untrack, batch, on, children, createContext, useContext, getOwner, runWithOwner, equalFn, requestCallback, mapArray, observable, from, $PROXY, DEV } from "./reactive";
1
+ export { createRoot, createSignal, createComputed, createRenderEffect, createEffect, createDeferred, createSelector, createMemo, getListener, onMount, onCleanup, onError, untrack, batch, on, children, createContext, useContext, getOwner, runWithOwner, equalFn, requestCallback, mapArray, observable, from, $PROXY, DEV, enableExternalSource } from "./reactive";
2
2
  export { mergeProps, splitProps, createComponent, For, Index, Show, Switch, Match, ErrorBoundary, Suspense, SuspenseList, createResource, enableScheduling, startTransition, useTransition, createUniqueId, lazy, sharedConfig } from "./rendering";
3
3
  export type { Component, Resource } from "./rendering";
@@ -70,4 +70,5 @@ export declare function from<T>(producer: ((setter: Setter<T>) => () => void) |
70
70
  unsubscribe: () => void;
71
71
  };
72
72
  }): Accessor<T>;
73
+ export declare function enableExternalSource(factory: any): void;
73
74
  export {};