solid-js 2.0.0-experimental.10 → 2.0.0-experimental.12

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
@@ -3,9 +3,6 @@
3
3
  var signals = require('@solidjs/signals');
4
4
 
5
5
  const $DEVCOMP = Symbol("COMPONENT_DEV" );
6
- function onMount(fn) {
7
- signals.createEffect(() => null, fn);
8
- }
9
6
  function createContext(defaultValue, options) {
10
7
  const id = Symbol(options && options.name || "");
11
8
  function provider(props) {
@@ -74,50 +71,6 @@ function reducer(source, reducerFn) {
74
71
  }];
75
72
  }
76
73
 
77
- function observable(input) {
78
- return {
79
- subscribe(observer) {
80
- if (!(observer instanceof Object) || observer == null) {
81
- throw new TypeError("Expected the observer to be an object.");
82
- }
83
- const handler = typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
84
- if (!handler) {
85
- return {
86
- unsubscribe() {}
87
- };
88
- }
89
- const dispose = signals.createRoot(disposer => {
90
- signals.createEffect(() => input(), v => {
91
- handler(v);
92
- });
93
- return disposer;
94
- });
95
- if (signals.getOwner()) signals.onCleanup(dispose);
96
- return {
97
- unsubscribe() {
98
- dispose();
99
- }
100
- };
101
- },
102
- [Symbol.observable || "@@observable"]() {
103
- return this;
104
- }
105
- };
106
- }
107
- function from(producer, initialValue = undefined) {
108
- const [s, set] = signals.createSignal(() => initialValue, initialValue, {
109
- equals: false
110
- });
111
- if ("subscribe" in producer) {
112
- const unsub = producer.subscribe(v => set(() => v));
113
- signals.onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
114
- } else {
115
- const clean = producer(set);
116
- signals.onCleanup(clean);
117
- }
118
- return s;
119
- }
120
-
121
74
  const sharedConfig = {
122
75
  hydrating: false,
123
76
  registry: undefined,
@@ -125,11 +78,11 @@ const sharedConfig = {
125
78
  getNextContextId() {
126
79
  const o = signals.getOwner();
127
80
  if (!o) throw new Error(`getNextContextId cannot be used under non-hydrating context`);
128
- return o.getNextChildId();
81
+ return signals.getNextChildId(o);
129
82
  }
130
83
  };
131
- function Suspense(props) {
132
- if (!sharedConfig.hydrating) return signals.createSuspense(() => props.children, () => props.fallback);
84
+ function Loading(props) {
85
+ if (!sharedConfig.hydrating) return signals.createLoadBoundary(() => props.children, () => props.fallback);
133
86
  return signals.createMemo(() => {
134
87
  const o = signals.getOwner();
135
88
  const id = o.id;
@@ -158,61 +111,9 @@ function Suspense(props) {
158
111
  return props.fallback;
159
112
  }
160
113
  }
161
- return signals.createSuspense(() => props.children, () => props.fallback);
114
+ return signals.createLoadBoundary(() => props.children, () => props.fallback);
162
115
  });
163
116
  }
164
- function createAsync(compute, value, options) {
165
- if (!sharedConfig.hydrating) return signals.createAsync(compute, value, options);
166
- return signals.createAsync(prev => {
167
- if (!sharedConfig.hydrating) return compute(prev);
168
- const o = signals.getOwner();
169
- let initP;
170
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
171
- const init = initP?.value || initP;
172
- return init ? (subFetch(compute, prev), init) : compute(prev);
173
- }, value, options);
174
- }
175
- class MockPromise {
176
- static all() {
177
- return new MockPromise();
178
- }
179
- static allSettled() {
180
- return new MockPromise();
181
- }
182
- static any() {
183
- return new MockPromise();
184
- }
185
- static race() {
186
- return new MockPromise();
187
- }
188
- static reject() {
189
- return new MockPromise();
190
- }
191
- static resolve() {
192
- return new MockPromise();
193
- }
194
- catch() {
195
- return new MockPromise();
196
- }
197
- then() {
198
- return new MockPromise();
199
- }
200
- finally() {
201
- return new MockPromise();
202
- }
203
- }
204
- function subFetch(fn, prev) {
205
- const ogFetch = fetch;
206
- const ogPromise = Promise;
207
- try {
208
- window.fetch = () => new MockPromise();
209
- Promise = MockPromise;
210
- return fn(prev);
211
- } finally {
212
- window.fetch = ogFetch;
213
- Promise = ogPromise;
214
- }
215
- }
216
117
 
217
118
  function enableHydration() {
218
119
  }
@@ -223,10 +124,7 @@ function lazy(fn) {
223
124
  let comp;
224
125
  let p;
225
126
  const wrap = props => {
226
- if (!comp) {
227
- const s = signals.createAsync(() => (p || (p = fn())).then(mod => mod.default));
228
- comp = s;
229
- }
127
+ comp = signals.createMemo(() => (p || (p = fn())).then(mod => mod.default));
230
128
  let Comp;
231
129
  return signals.createMemo(() => (Comp = comp()) ? signals.untrack(() => {
232
130
  Object.assign(Comp, {
@@ -251,18 +149,14 @@ function For(props) {
251
149
  } : {
252
150
  keyed: props.keyed
253
151
  };
254
- return signals.createMemo(signals.mapArray(() => props.each, props.children, options), undefined, {
255
- name: "value"
256
- }) ;
152
+ return signals.mapArray(() => props.each, props.children, options);
257
153
  }
258
154
  function Repeat(props) {
259
155
  const options = "fallback" in props ? {
260
156
  fallback: () => props.fallback
261
157
  } : {};
262
158
  options.from = () => props.from;
263
- return signals.createMemo(signals.repeat(() => props.count, index => typeof props.children === "function" ? props.children(index) : props.children, options), undefined, {
264
- name: "value"
265
- }) ;
159
+ return signals.repeat(() => props.count, index => typeof props.children === "function" ? props.children(index) : props.children, options);
266
160
  }
267
161
  function Show(props) {
268
162
  const keyed = props.keyed;
@@ -291,8 +185,7 @@ function Show(props) {
291
185
  function Switch(props) {
292
186
  const chs = children(() => props.children);
293
187
  const switchFunc = signals.createMemo(() => {
294
- const ch = chs();
295
- const mps = Array.isArray(ch) ? ch : [ch];
188
+ const mps = chs.toArray();
296
189
  let func = () => undefined;
297
190
  for (let i = 0; i < mps.length; i++) {
298
191
  const index = i;
@@ -326,7 +219,7 @@ function Switch(props) {
326
219
  function Match(props) {
327
220
  return props;
328
221
  }
329
- function ErrorBoundary(props) {
222
+ function Errored(props) {
330
223
  return signals.createErrorBoundary(() => props.children, (err, reset) => {
331
224
  const f = props.fallback;
332
225
  if ((typeof f !== "function" || f.length == 0)) console.error(err);
@@ -428,13 +321,13 @@ Object.defineProperty(exports, "isPending", {
428
321
  enumerable: true,
429
322
  get: function () { return signals.isPending; }
430
323
  });
431
- Object.defineProperty(exports, "isWrappable", {
324
+ Object.defineProperty(exports, "isRefreshing", {
432
325
  enumerable: true,
433
- get: function () { return signals.isWrappable; }
326
+ get: function () { return signals.isRefreshing; }
434
327
  });
435
- Object.defineProperty(exports, "latest", {
328
+ Object.defineProperty(exports, "isWrappable", {
436
329
  enumerable: true,
437
- get: function () { return signals.latest; }
330
+ get: function () { return signals.isWrappable; }
438
331
  });
439
332
  Object.defineProperty(exports, "mapArray", {
440
333
  enumerable: true,
@@ -452,10 +345,22 @@ Object.defineProperty(exports, "onCleanup", {
452
345
  enumerable: true,
453
346
  get: function () { return signals.onCleanup; }
454
347
  });
348
+ Object.defineProperty(exports, "onSettled", {
349
+ enumerable: true,
350
+ get: function () { return signals.onSettled; }
351
+ });
352
+ Object.defineProperty(exports, "pending", {
353
+ enumerable: true,
354
+ get: function () { return signals.pending; }
355
+ });
455
356
  Object.defineProperty(exports, "reconcile", {
456
357
  enumerable: true,
457
358
  get: function () { return signals.reconcile; }
458
359
  });
360
+ Object.defineProperty(exports, "refresh", {
361
+ enumerable: true,
362
+ get: function () { return signals.refresh; }
363
+ });
459
364
  Object.defineProperty(exports, "repeat", {
460
365
  enumerable: true,
461
366
  get: function () { return signals.repeat; }
@@ -472,38 +377,26 @@ Object.defineProperty(exports, "snapshot", {
472
377
  enumerable: true,
473
378
  get: function () { return signals.snapshot; }
474
379
  });
475
- Object.defineProperty(exports, "transition", {
476
- enumerable: true,
477
- get: function () { return signals.transition; }
478
- });
479
380
  Object.defineProperty(exports, "untrack", {
480
381
  enumerable: true,
481
382
  get: function () { return signals.untrack; }
482
383
  });
483
- Object.defineProperty(exports, "useTransition", {
484
- enumerable: true,
485
- get: function () { return signals.useTransition; }
486
- });
487
384
  exports.$DEVCOMP = $DEVCOMP;
488
385
  exports.Boundary = Boundary;
489
386
  exports.DEV = DEV;
490
- exports.ErrorBoundary = ErrorBoundary;
387
+ exports.Errored = Errored;
491
388
  exports.For = For;
389
+ exports.Loading = Loading;
492
390
  exports.Match = Match;
493
391
  exports.Repeat = Repeat;
494
392
  exports.Show = Show;
495
- exports.Suspense = Suspense;
496
393
  exports.Switch = Switch;
497
394
  exports.children = children;
498
- exports.createAsync = createAsync;
499
395
  exports.createComponent = createComponent;
500
396
  exports.createContext = createContext;
501
397
  exports.createUniqueId = createUniqueId;
502
398
  exports.enableHydration = enableHydration;
503
- exports.from = from;
504
399
  exports.lazy = lazy;
505
- exports.observable = observable;
506
- exports.onMount = onMount;
507
400
  exports.reducer = reducer;
508
401
  exports.sharedConfig = sharedConfig;
509
402
  exports.ssrHandleError = ssrHandleError;
package/dist/dev.js CHANGED
@@ -1,10 +1,7 @@
1
- import { createEffect, getContext, createMemo, flatten, createRoot, setContext, getOwner, untrack, NotReadyError, onCleanup, createSignal, createSuspense, flush, runWithOwner, createAsync as createAsync$1, mapArray, repeat, createErrorBoundary, createBoundary } from '@solidjs/signals';
2
- export { $PROXY, $TRACK, createEffect, createMemo, createOptimistic, createOptimisticStore, createProjection, createReaction, createRenderEffect, createRoot, createSignal, createStore, createTrackedEffect, deep, flatten, flush, getObserver, getOwner, isEqual, isPending, isWrappable, latest, mapArray, merge, omit, onCleanup, reconcile, repeat, resolve, runWithOwner, snapshot, transition, untrack, useTransition } from '@solidjs/signals';
1
+ import { getContext, createMemo, flatten, createRoot, setContext, getOwner, untrack, NotReadyError, getNextChildId, createLoadBoundary, createSignal, flush, runWithOwner, mapArray, repeat, createErrorBoundary, createBoundary } from '@solidjs/signals';
2
+ export { $PROXY, $TRACK, createEffect, createMemo, createOptimistic, createOptimisticStore, createProjection, createReaction, createRenderEffect, createRoot, createSignal, createStore, createTrackedEffect, deep, flatten, flush, getObserver, getOwner, isEqual, isPending, isRefreshing, isWrappable, mapArray, merge, omit, onCleanup, onSettled, pending, reconcile, refresh, repeat, resolve, runWithOwner, snapshot, untrack } from '@solidjs/signals';
3
3
 
4
4
  const $DEVCOMP = Symbol("COMPONENT_DEV" );
5
- function onMount(fn) {
6
- createEffect(() => null, fn);
7
- }
8
5
  function createContext(defaultValue, options) {
9
6
  const id = Symbol(options && options.name || "");
10
7
  function provider(props) {
@@ -73,50 +70,6 @@ function reducer(source, reducerFn) {
73
70
  }];
74
71
  }
75
72
 
76
- function observable(input) {
77
- return {
78
- subscribe(observer) {
79
- if (!(observer instanceof Object) || observer == null) {
80
- throw new TypeError("Expected the observer to be an object.");
81
- }
82
- const handler = typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
83
- if (!handler) {
84
- return {
85
- unsubscribe() {}
86
- };
87
- }
88
- const dispose = createRoot(disposer => {
89
- createEffect(() => input(), v => {
90
- handler(v);
91
- });
92
- return disposer;
93
- });
94
- if (getOwner()) onCleanup(dispose);
95
- return {
96
- unsubscribe() {
97
- dispose();
98
- }
99
- };
100
- },
101
- [Symbol.observable || "@@observable"]() {
102
- return this;
103
- }
104
- };
105
- }
106
- function from(producer, initialValue = undefined) {
107
- const [s, set] = createSignal(() => initialValue, initialValue, {
108
- equals: false
109
- });
110
- if ("subscribe" in producer) {
111
- const unsub = producer.subscribe(v => set(() => v));
112
- onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
113
- } else {
114
- const clean = producer(set);
115
- onCleanup(clean);
116
- }
117
- return s;
118
- }
119
-
120
73
  const sharedConfig = {
121
74
  hydrating: false,
122
75
  registry: undefined,
@@ -124,11 +77,11 @@ const sharedConfig = {
124
77
  getNextContextId() {
125
78
  const o = getOwner();
126
79
  if (!o) throw new Error(`getNextContextId cannot be used under non-hydrating context`);
127
- return o.getNextChildId();
80
+ return getNextChildId(o);
128
81
  }
129
82
  };
130
- function Suspense(props) {
131
- if (!sharedConfig.hydrating) return createSuspense(() => props.children, () => props.fallback);
83
+ function Loading(props) {
84
+ if (!sharedConfig.hydrating) return createLoadBoundary(() => props.children, () => props.fallback);
132
85
  return createMemo(() => {
133
86
  const o = getOwner();
134
87
  const id = o.id;
@@ -157,61 +110,9 @@ function Suspense(props) {
157
110
  return props.fallback;
158
111
  }
159
112
  }
160
- return createSuspense(() => props.children, () => props.fallback);
113
+ return createLoadBoundary(() => props.children, () => props.fallback);
161
114
  });
162
115
  }
163
- function createAsync(compute, value, options) {
164
- if (!sharedConfig.hydrating) return createAsync$1(compute, value, options);
165
- return createAsync$1(prev => {
166
- if (!sharedConfig.hydrating) return compute(prev);
167
- const o = getOwner();
168
- let initP;
169
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
170
- const init = initP?.value || initP;
171
- return init ? (subFetch(compute, prev), init) : compute(prev);
172
- }, value, options);
173
- }
174
- class MockPromise {
175
- static all() {
176
- return new MockPromise();
177
- }
178
- static allSettled() {
179
- return new MockPromise();
180
- }
181
- static any() {
182
- return new MockPromise();
183
- }
184
- static race() {
185
- return new MockPromise();
186
- }
187
- static reject() {
188
- return new MockPromise();
189
- }
190
- static resolve() {
191
- return new MockPromise();
192
- }
193
- catch() {
194
- return new MockPromise();
195
- }
196
- then() {
197
- return new MockPromise();
198
- }
199
- finally() {
200
- return new MockPromise();
201
- }
202
- }
203
- function subFetch(fn, prev) {
204
- const ogFetch = fetch;
205
- const ogPromise = Promise;
206
- try {
207
- window.fetch = () => new MockPromise();
208
- Promise = MockPromise;
209
- return fn(prev);
210
- } finally {
211
- window.fetch = ogFetch;
212
- Promise = ogPromise;
213
- }
214
- }
215
116
 
216
117
  function enableHydration() {
217
118
  }
@@ -222,10 +123,7 @@ function lazy(fn) {
222
123
  let comp;
223
124
  let p;
224
125
  const wrap = props => {
225
- if (!comp) {
226
- const s = createAsync$1(() => (p || (p = fn())).then(mod => mod.default));
227
- comp = s;
228
- }
126
+ comp = createMemo(() => (p || (p = fn())).then(mod => mod.default));
229
127
  let Comp;
230
128
  return createMemo(() => (Comp = comp()) ? untrack(() => {
231
129
  Object.assign(Comp, {
@@ -250,18 +148,14 @@ function For(props) {
250
148
  } : {
251
149
  keyed: props.keyed
252
150
  };
253
- return createMemo(mapArray(() => props.each, props.children, options), undefined, {
254
- name: "value"
255
- }) ;
151
+ return mapArray(() => props.each, props.children, options);
256
152
  }
257
153
  function Repeat(props) {
258
154
  const options = "fallback" in props ? {
259
155
  fallback: () => props.fallback
260
156
  } : {};
261
157
  options.from = () => props.from;
262
- return createMemo(repeat(() => props.count, index => typeof props.children === "function" ? props.children(index) : props.children, options), undefined, {
263
- name: "value"
264
- }) ;
158
+ return repeat(() => props.count, index => typeof props.children === "function" ? props.children(index) : props.children, options);
265
159
  }
266
160
  function Show(props) {
267
161
  const keyed = props.keyed;
@@ -290,8 +184,7 @@ function Show(props) {
290
184
  function Switch(props) {
291
185
  const chs = children(() => props.children);
292
186
  const switchFunc = createMemo(() => {
293
- const ch = chs();
294
- const mps = Array.isArray(ch) ? ch : [ch];
187
+ const mps = chs.toArray();
295
188
  let func = () => undefined;
296
189
  for (let i = 0; i < mps.length; i++) {
297
190
  const index = i;
@@ -325,7 +218,7 @@ function Switch(props) {
325
218
  function Match(props) {
326
219
  return props;
327
220
  }
328
- function ErrorBoundary(props) {
221
+ function Errored(props) {
329
222
  return createErrorBoundary(() => props.children, (err, reset) => {
330
223
  const f = props.fallback;
331
224
  if ((typeof f !== "function" || f.length == 0)) console.error(err);
@@ -347,4 +240,4 @@ if (globalThis) {
347
240
  if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
348
241
  }
349
242
 
350
- export { $DEVCOMP, Boundary, DEV, ErrorBoundary, For, Match, Repeat, Show, Suspense, Switch, children, createAsync, createComponent, createContext, createUniqueId, enableHydration, from, lazy, observable, onMount, reducer, sharedConfig, ssrHandleError, ssrRunInScope, tryCatch, useContext };
243
+ export { $DEVCOMP, Boundary, DEV, Errored, For, Loading, Match, Repeat, Show, Switch, children, createComponent, createContext, createUniqueId, enableHydration, lazy, reducer, sharedConfig, ssrHandleError, ssrRunInScope, tryCatch, useContext };