solid-js 2.0.0-beta.1 → 2.0.0-beta.3
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 +270 -107
- package/dist/dev.js +252 -109
- package/dist/server.cjs +79 -77
- package/dist/server.js +68 -80
- package/dist/solid.cjs +268 -93
- package/dist/solid.js +250 -95
- package/package.json +2 -2
- package/types/client/hydration.d.ts +11 -4
- package/types/index.d.ts +2 -2
- package/types/server/hydration.d.ts +1 -0
- package/types/server/index.d.ts +2 -2
- package/types/server/signals.d.ts +6 -4
package/dist/solid.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { getContext, createMemo as createMemo$1, flatten, createRoot, setContext,
|
|
2
|
-
export { $PROXY, $TRACK, NotReadyError, action, createOwner, createReaction, createRoot, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isEqual, isPending, isRefreshing, isWrappable, latest, mapArray, merge, omit, onCleanup, onSettled, reconcile, refresh, repeat, resolve, runWithOwner, snapshot, storePath, untrack } from '@solidjs/signals';
|
|
1
|
+
import { getContext, createMemo as createMemo$1, flatten, createRoot, setContext, createLoadingBoundary, getOwner, onCleanup, isDisposed, runWithOwner, createOwner, createEffect as createEffect$1, createOptimistic as createOptimistic$1, createOptimisticStore as createOptimisticStore$1, createProjection as createProjection$1, createRenderEffect as createRenderEffect$1, createSignal as createSignal$1, createStore as createStore$1, setSnapshotCapture, releaseSnapshotScope, getNextChildId, createErrorBoundary as createErrorBoundary$1, markSnapshotScope, flush, clearSnapshots, peekNextChildId, untrack, mapArray, repeat } from '@solidjs/signals';
|
|
2
|
+
export { $PROXY, $REFRESH, $TRACK, NotReadyError, action, createErrorBoundary, createLoadingBoundary, createOwner, createReaction, createRoot, createTrackedEffect, deep, enableExternalSource, enforceLoadingBoundary, flatten, flush, getNextChildId, getObserver, getOwner, isEqual, isPending, isRefreshing, isWrappable, latest, mapArray, merge, omit, onCleanup, onSettled, reconcile, refresh, repeat, resolve, runWithOwner, snapshot, storePath, untrack } from '@solidjs/signals';
|
|
3
3
|
|
|
4
|
+
const IS_DEV = false;
|
|
4
5
|
const $DEVCOMP = Symbol(0);
|
|
5
6
|
function createContext(defaultValue, options) {
|
|
6
7
|
const id = Symbol(options && options.name || "");
|
|
@@ -131,11 +132,41 @@ function subFetch(fn, prev) {
|
|
|
131
132
|
Promise = ogPromise;
|
|
132
133
|
}
|
|
133
134
|
}
|
|
134
|
-
function
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
135
|
+
function syncThenable(value) {
|
|
136
|
+
return {
|
|
137
|
+
then(fn) {
|
|
138
|
+
fn(value);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
function normalizeIterator(it) {
|
|
143
|
+
let first = true;
|
|
144
|
+
let buffered = null;
|
|
145
|
+
return {
|
|
146
|
+
next() {
|
|
147
|
+
if (first) {
|
|
148
|
+
first = false;
|
|
149
|
+
const r = it.next();
|
|
150
|
+
return r && typeof r.then === "function" ? r : syncThenable(r);
|
|
151
|
+
}
|
|
152
|
+
if (buffered) {
|
|
153
|
+
const b = buffered;
|
|
154
|
+
buffered = null;
|
|
155
|
+
return b;
|
|
156
|
+
}
|
|
157
|
+
let latest = it.next();
|
|
158
|
+
if (latest && typeof latest.then === "function") return latest;
|
|
159
|
+
while (!latest.done) {
|
|
160
|
+
const peek = it.next();
|
|
161
|
+
if (peek && typeof peek.then === "function") {
|
|
162
|
+
buffered = peek;
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
latest = peek;
|
|
166
|
+
}
|
|
167
|
+
return Promise.resolve(latest);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
139
170
|
}
|
|
140
171
|
function applyPatches(target, patches) {
|
|
141
172
|
for (const patch of patches) {
|
|
@@ -152,63 +183,163 @@ function applyPatches(target, patches) {
|
|
|
152
183
|
}
|
|
153
184
|
}
|
|
154
185
|
}
|
|
155
|
-
function
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
186
|
+
function isAsyncIterable(v) {
|
|
187
|
+
return v != null && typeof v[Symbol.asyncIterator] === "function";
|
|
188
|
+
}
|
|
189
|
+
function createShadowDraft(realDraft) {
|
|
190
|
+
const shadow = JSON.parse(JSON.stringify(realDraft));
|
|
191
|
+
let useShadow = true;
|
|
192
|
+
return {
|
|
193
|
+
proxy: new Proxy(shadow, {
|
|
194
|
+
get(_, prop) {
|
|
195
|
+
return useShadow ? shadow[prop] : realDraft[prop];
|
|
196
|
+
},
|
|
197
|
+
set(_, prop, value) {
|
|
198
|
+
if (useShadow) {
|
|
199
|
+
shadow[prop] = value;
|
|
200
|
+
return true;
|
|
201
|
+
}
|
|
202
|
+
return Reflect.set(realDraft, prop, value);
|
|
203
|
+
},
|
|
204
|
+
deleteProperty(_, prop) {
|
|
205
|
+
if (useShadow) {
|
|
206
|
+
delete shadow[prop];
|
|
207
|
+
return true;
|
|
208
|
+
}
|
|
209
|
+
return Reflect.deleteProperty(realDraft, prop);
|
|
210
|
+
},
|
|
211
|
+
has(_, prop) {
|
|
212
|
+
return prop in (useShadow ? shadow : realDraft);
|
|
213
|
+
},
|
|
214
|
+
ownKeys() {
|
|
215
|
+
return Reflect.ownKeys(useShadow ? shadow : realDraft);
|
|
216
|
+
},
|
|
217
|
+
getOwnPropertyDescriptor(_, prop) {
|
|
218
|
+
return Object.getOwnPropertyDescriptor(useShadow ? shadow : realDraft, prop);
|
|
166
219
|
}
|
|
167
|
-
|
|
168
|
-
|
|
220
|
+
}),
|
|
221
|
+
activate() {
|
|
222
|
+
useShadow = false;
|
|
169
223
|
}
|
|
170
224
|
};
|
|
171
|
-
consume();
|
|
172
225
|
}
|
|
173
|
-
function
|
|
174
|
-
|
|
226
|
+
function wrapFirstYield(iterable, activate) {
|
|
227
|
+
const srcIt = iterable[Symbol.asyncIterator]();
|
|
228
|
+
let first = true;
|
|
229
|
+
return {
|
|
230
|
+
[Symbol.asyncIterator]() {
|
|
231
|
+
return {
|
|
232
|
+
next() {
|
|
233
|
+
const p = srcIt.next();
|
|
234
|
+
if (first) {
|
|
235
|
+
first = false;
|
|
236
|
+
return p.then(r => {
|
|
237
|
+
activate();
|
|
238
|
+
return r.done ? r : {
|
|
239
|
+
done: false,
|
|
240
|
+
value: undefined
|
|
241
|
+
};
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
return p;
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
};
|
|
175
249
|
}
|
|
176
250
|
function hydrateSignalFromAsyncIterable(coreFn, compute, value, options) {
|
|
177
251
|
const parent = getOwner();
|
|
178
252
|
const expectedId = peekNextChildId(parent);
|
|
179
253
|
if (!sharedConfig.has(expectedId)) return null;
|
|
180
|
-
const
|
|
181
|
-
if (!isAsyncIterable(
|
|
182
|
-
const
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
return result;
|
|
254
|
+
const loaded = sharedConfig.load(expectedId);
|
|
255
|
+
if (!isAsyncIterable(loaded)) return null;
|
|
256
|
+
const it = normalizeIterator(loaded[Symbol.asyncIterator]());
|
|
257
|
+
const iterable = {
|
|
258
|
+
[Symbol.asyncIterator]() {
|
|
259
|
+
return it;
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
return coreFn(() => iterable, value, options);
|
|
190
263
|
}
|
|
191
264
|
function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
|
|
192
265
|
const parent = getOwner();
|
|
193
266
|
const expectedId = peekNextChildId(parent);
|
|
194
267
|
if (!sharedConfig.has(expectedId)) return null;
|
|
195
|
-
const
|
|
196
|
-
if (!isAsyncIterable(
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
268
|
+
const loaded = sharedConfig.load(expectedId);
|
|
269
|
+
if (!isAsyncIterable(loaded)) return null;
|
|
270
|
+
const srcIt = loaded[Symbol.asyncIterator]();
|
|
271
|
+
let isFirst = true;
|
|
272
|
+
let buffered = null;
|
|
273
|
+
return coreFn(draft => {
|
|
274
|
+
const process = res => {
|
|
275
|
+
if (res.done) return {
|
|
276
|
+
done: true,
|
|
277
|
+
value: undefined
|
|
278
|
+
};
|
|
279
|
+
if (isFirst) {
|
|
280
|
+
isFirst = false;
|
|
281
|
+
if (Array.isArray(res.value)) {
|
|
282
|
+
for (let i = 0; i < res.value.length; i++) draft[i] = res.value[i];
|
|
283
|
+
draft.length = res.value.length;
|
|
284
|
+
} else {
|
|
285
|
+
Object.assign(draft, res.value);
|
|
286
|
+
}
|
|
287
|
+
} else {
|
|
288
|
+
applyPatches(draft, res.value);
|
|
289
|
+
}
|
|
290
|
+
return {
|
|
291
|
+
done: false,
|
|
292
|
+
value: undefined
|
|
293
|
+
};
|
|
294
|
+
};
|
|
295
|
+
return {
|
|
296
|
+
[Symbol.asyncIterator]() {
|
|
297
|
+
return {
|
|
298
|
+
next() {
|
|
299
|
+
if (isFirst) {
|
|
300
|
+
const r = srcIt.next();
|
|
301
|
+
return r && typeof r.then === "function" ? {
|
|
302
|
+
then(fn, rej) {
|
|
303
|
+
r.then(v => fn(process(v)), rej);
|
|
304
|
+
}
|
|
305
|
+
} : syncThenable(process(r));
|
|
306
|
+
}
|
|
307
|
+
if (buffered) {
|
|
308
|
+
const b = buffered;
|
|
309
|
+
buffered = null;
|
|
310
|
+
return b.then(process);
|
|
311
|
+
}
|
|
312
|
+
let r = srcIt.next();
|
|
313
|
+
if (r && typeof r.then === "function") {
|
|
314
|
+
return r.then(process);
|
|
315
|
+
}
|
|
316
|
+
let result = process(r);
|
|
317
|
+
while (!r.done) {
|
|
318
|
+
const peek = srcIt.next();
|
|
319
|
+
if (peek && typeof peek.then === "function") {
|
|
320
|
+
buffered = peek;
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
323
|
+
r = peek;
|
|
324
|
+
if (!r.done) result = process(r);
|
|
325
|
+
}
|
|
326
|
+
return Promise.resolve(result);
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
}, initialValue, options);
|
|
205
332
|
}
|
|
206
333
|
function hydratedCreateMemo(compute, value, options) {
|
|
207
|
-
if (!sharedConfig.hydrating
|
|
334
|
+
if (!sharedConfig.hydrating || options?.transparent) {
|
|
335
|
+
return createMemo$1(compute, value, options);
|
|
336
|
+
}
|
|
208
337
|
markTopLevelSnapshotScope();
|
|
209
338
|
const ssrSource = options?.ssrSource;
|
|
210
339
|
if (ssrSource === "client") {
|
|
211
|
-
const [hydrated, setHydrated] = createSignal$1(false
|
|
340
|
+
const [hydrated, setHydrated] = createSignal$1(false, {
|
|
341
|
+
pureWrite: true
|
|
342
|
+
});
|
|
212
343
|
const memo = createMemo$1(prev => {
|
|
213
344
|
if (!hydrated()) return prev ?? value;
|
|
214
345
|
return compute(prev);
|
|
@@ -239,7 +370,9 @@ function hydratedCreateSignal(fn, second, third) {
|
|
|
239
370
|
markTopLevelSnapshotScope();
|
|
240
371
|
const ssrSource = third?.ssrSource;
|
|
241
372
|
if (ssrSource === "client") {
|
|
242
|
-
const [hydrated, setHydrated] = createSignal$1(false
|
|
373
|
+
const [hydrated, setHydrated] = createSignal$1(false, {
|
|
374
|
+
pureWrite: true
|
|
375
|
+
});
|
|
243
376
|
const sig = createSignal$1(prev => {
|
|
244
377
|
if (!hydrated()) return prev ?? second;
|
|
245
378
|
return fn(prev);
|
|
@@ -290,7 +423,9 @@ function hydratedCreateOptimistic(fn, second, third) {
|
|
|
290
423
|
markTopLevelSnapshotScope();
|
|
291
424
|
const ssrSource = third?.ssrSource;
|
|
292
425
|
if (ssrSource === "client") {
|
|
293
|
-
const [hydrated, setHydrated] = createSignal$1(false
|
|
426
|
+
const [hydrated, setHydrated] = createSignal$1(false, {
|
|
427
|
+
pureWrite: true
|
|
428
|
+
});
|
|
294
429
|
const sig = createOptimistic$1(prev => {
|
|
295
430
|
if (!hydrated()) return prev ?? second;
|
|
296
431
|
return fn(prev);
|
|
@@ -316,14 +451,7 @@ function hydratedCreateOptimistic(fn, second, third) {
|
|
|
316
451
|
return init != null ? (subFetch(fn, prev), init) : fn(prev);
|
|
317
452
|
}, second, third);
|
|
318
453
|
}
|
|
319
|
-
function wrapStoreFn(fn
|
|
320
|
-
if (ssrSource === "initial") {
|
|
321
|
-
return draft => {
|
|
322
|
-
if (!sharedConfig.hydrating) return fn(draft);
|
|
323
|
-
subFetch(fn, draft);
|
|
324
|
-
return undefined;
|
|
325
|
-
};
|
|
326
|
-
}
|
|
454
|
+
function wrapStoreFn(fn) {
|
|
327
455
|
return draft => {
|
|
328
456
|
const o = getOwner();
|
|
329
457
|
if (!sharedConfig.hydrating) return fn(draft);
|
|
@@ -333,44 +461,77 @@ function wrapStoreFn(fn, ssrSource) {
|
|
|
333
461
|
return init != null ? (subFetch(fn, draft), init) : fn(draft);
|
|
334
462
|
};
|
|
335
463
|
}
|
|
464
|
+
function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
|
|
465
|
+
if (ssrSource === "client") {
|
|
466
|
+
const [hydrated, setHydrated] = createSignal$1(false, {
|
|
467
|
+
pureWrite: true
|
|
468
|
+
});
|
|
469
|
+
const result = coreFn(draft => {
|
|
470
|
+
if (!hydrated()) return;
|
|
471
|
+
return fn(draft);
|
|
472
|
+
}, initialValue, options);
|
|
473
|
+
setHydrated(true);
|
|
474
|
+
return result;
|
|
475
|
+
}
|
|
476
|
+
if (ssrSource === "hybrid") {
|
|
477
|
+
const [hydrated, setHydrated] = createSignal$1(false, {
|
|
478
|
+
pureWrite: true
|
|
479
|
+
});
|
|
480
|
+
const result = coreFn(draft => {
|
|
481
|
+
const o = getOwner();
|
|
482
|
+
if (!hydrated()) {
|
|
483
|
+
if (sharedConfig.has(o.id)) {
|
|
484
|
+
const initP = sharedConfig.load(o.id);
|
|
485
|
+
const init = initP?.v ?? initP;
|
|
486
|
+
if (init != null) {
|
|
487
|
+
subFetch(fn, draft);
|
|
488
|
+
return init;
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
return fn(draft);
|
|
492
|
+
}
|
|
493
|
+
const {
|
|
494
|
+
proxy,
|
|
495
|
+
activate
|
|
496
|
+
} = createShadowDraft(draft);
|
|
497
|
+
const r = fn(proxy);
|
|
498
|
+
return isAsyncIterable(r) ? wrapFirstYield(r, activate) : r;
|
|
499
|
+
}, initialValue, options);
|
|
500
|
+
setHydrated(true);
|
|
501
|
+
return result;
|
|
502
|
+
}
|
|
503
|
+
const aiResult = hydrateStoreFromAsyncIterable(coreFn, initialValue, options);
|
|
504
|
+
if (aiResult !== null) return aiResult;
|
|
505
|
+
return coreFn(wrapStoreFn(fn), initialValue, options);
|
|
506
|
+
}
|
|
336
507
|
function hydratedCreateStore(first, second, third) {
|
|
337
508
|
if (typeof first !== "function" || !sharedConfig.hydrating) return createStore$1(first, second, third);
|
|
338
509
|
markTopLevelSnapshotScope();
|
|
339
510
|
const ssrSource = third?.ssrSource;
|
|
340
|
-
if (ssrSource === "
|
|
341
|
-
|
|
342
|
-
}
|
|
343
|
-
const aiResult = hydrateStoreFromAsyncIterable(createStore$1, second ?? {}, third);
|
|
344
|
-
if (aiResult !== null) return aiResult;
|
|
345
|
-
return createStore$1(wrapStoreFn(first, ssrSource), second, third);
|
|
511
|
+
if (ssrSource === "initial") return createStore$1(second ?? {}, undefined, third);
|
|
512
|
+
return hydrateStoreLikeFn(createStore$1, first, second ?? {}, third, ssrSource);
|
|
346
513
|
}
|
|
347
514
|
function hydratedCreateOptimisticStore(first, second, third) {
|
|
348
515
|
if (typeof first !== "function" || !sharedConfig.hydrating) return createOptimisticStore$1(first, second, third);
|
|
349
516
|
markTopLevelSnapshotScope();
|
|
350
517
|
const ssrSource = third?.ssrSource;
|
|
351
|
-
if (ssrSource === "
|
|
352
|
-
|
|
353
|
-
}
|
|
354
|
-
const aiResult = hydrateStoreFromAsyncIterable(createOptimisticStore$1, second ?? {}, third);
|
|
355
|
-
if (aiResult !== null) return aiResult;
|
|
356
|
-
return createOptimisticStore$1(wrapStoreFn(first, ssrSource), second, third);
|
|
518
|
+
if (ssrSource === "initial") return createOptimisticStore$1(second ?? {}, undefined, third);
|
|
519
|
+
return hydrateStoreLikeFn(createOptimisticStore$1, first, second ?? {}, third, ssrSource);
|
|
357
520
|
}
|
|
358
521
|
function hydratedCreateProjection(fn, initialValue, options) {
|
|
359
522
|
if (!sharedConfig.hydrating) return createProjection$1(fn, initialValue, options);
|
|
360
523
|
markTopLevelSnapshotScope();
|
|
361
524
|
const ssrSource = options?.ssrSource;
|
|
362
|
-
if (ssrSource === "
|
|
363
|
-
|
|
364
|
-
}
|
|
365
|
-
const aiResult = hydrateStoreFromAsyncIterable(createStore$1, initialValue, options);
|
|
366
|
-
if (aiResult !== null) return aiResult[0];
|
|
367
|
-
return createProjection$1(wrapStoreFn(fn, ssrSource), initialValue, options);
|
|
525
|
+
if (ssrSource === "initial") return createProjection$1(draft => draft, initialValue, options);
|
|
526
|
+
return hydrateStoreLikeFn(createProjection$1, fn, initialValue, options, ssrSource);
|
|
368
527
|
}
|
|
369
528
|
function hydratedEffect(coreFn, compute, effectFn, value, options) {
|
|
370
529
|
if (!sharedConfig.hydrating) return coreFn(compute, effectFn, value, options);
|
|
371
530
|
const ssrSource = options?.ssrSource;
|
|
372
531
|
if (ssrSource === "client") {
|
|
373
|
-
const [hydrated, setHydrated] = createSignal$1(false
|
|
532
|
+
const [hydrated, setHydrated] = createSignal$1(false, {
|
|
533
|
+
pureWrite: true
|
|
534
|
+
});
|
|
374
535
|
let active = false;
|
|
375
536
|
coreFn(prev => {
|
|
376
537
|
if (!hydrated()) return value;
|
|
@@ -504,13 +665,16 @@ function resumeBoundaryHydration(o, id, set) {
|
|
|
504
665
|
set();
|
|
505
666
|
flush();
|
|
506
667
|
_snapshotRootOwner = null;
|
|
507
|
-
_hydratingValue = false;
|
|
508
668
|
releaseSnapshotScope(o);
|
|
509
669
|
flush();
|
|
670
|
+
_hydratingValue = false;
|
|
510
671
|
checkHydrationComplete();
|
|
511
672
|
}
|
|
512
673
|
function Loading(props) {
|
|
513
|
-
|
|
674
|
+
const onOpt = props.on ? {
|
|
675
|
+
on: () => props.on()
|
|
676
|
+
} : undefined;
|
|
677
|
+
if (!sharedConfig.hydrating) return createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
|
|
514
678
|
return createMemo$1(() => {
|
|
515
679
|
const o = getOwner();
|
|
516
680
|
const id = o.id;
|
|
@@ -558,7 +722,8 @@ function Loading(props) {
|
|
|
558
722
|
assetPromise.then(() => resumeBoundaryHydration(o, id, set));
|
|
559
723
|
return undefined;
|
|
560
724
|
}
|
|
561
|
-
|
|
725
|
+
const boundary = createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
|
|
726
|
+
return boundary;
|
|
562
727
|
});
|
|
563
728
|
}
|
|
564
729
|
function NoHydration(props) {
|
|
@@ -636,15 +801,10 @@ function Show(props) {
|
|
|
636
801
|
if (c) {
|
|
637
802
|
const child = props.children;
|
|
638
803
|
const fn = typeof child === "function" && child.length > 0;
|
|
639
|
-
return fn ? untrack(() => {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
return conditionValue();
|
|
644
|
-
});
|
|
645
|
-
} finally {
|
|
646
|
-
}
|
|
647
|
-
}) : child;
|
|
804
|
+
return fn ? untrack(() => child(() => {
|
|
805
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
806
|
+
return conditionValue();
|
|
807
|
+
}), IS_DEV) : child;
|
|
648
808
|
}
|
|
649
809
|
return props.fallback;
|
|
650
810
|
}, undefined, undefined);
|
|
@@ -672,15 +832,10 @@ function Switch(props) {
|
|
|
672
832
|
const [index, conditionValue, mp] = sel;
|
|
673
833
|
const child = mp.children;
|
|
674
834
|
const fn = typeof child === "function" && child.length > 0;
|
|
675
|
-
return fn ? untrack(() => {
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
return conditionValue();
|
|
680
|
-
});
|
|
681
|
-
} finally {
|
|
682
|
-
}
|
|
683
|
-
}) : child;
|
|
835
|
+
return fn ? untrack(() => child(() => {
|
|
836
|
+
if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
|
|
837
|
+
return conditionValue();
|
|
838
|
+
}), IS_DEV) : child;
|
|
684
839
|
}, undefined, undefined);
|
|
685
840
|
}
|
|
686
841
|
function Match(props) {
|
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": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.3",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"performance"
|
|
80
80
|
],
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@solidjs/signals": "^0.
|
|
82
|
+
"@solidjs/signals": "^0.13.3",
|
|
83
83
|
"csstype": "^3.1.0",
|
|
84
84
|
"seroval": "~1.5.0",
|
|
85
85
|
"seroval-plugins": "~1.5.0"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createErrorBoundary as coreErrorBoundary, createMemo as coreMemo, createSignal as coreSignal, createOptimistic as coreOptimistic, createRenderEffect as coreRenderEffect, createEffect as coreEffect, type ProjectionOptions, type Store, type StoreSetter, type Context } from "@solidjs/signals";
|
|
1
|
+
import { createErrorBoundary as coreErrorBoundary, createMemo as coreMemo, createSignal as coreSignal, createOptimistic as coreOptimistic, createRenderEffect as coreRenderEffect, createEffect as coreEffect, $REFRESH, type ProjectionOptions, type Store, type StoreSetter, type Context } from "@solidjs/signals";
|
|
2
2
|
import { JSX } from "../jsx.js";
|
|
3
3
|
declare module "@solidjs/signals" {
|
|
4
4
|
interface MemoOptions<T> {
|
|
@@ -47,15 +47,21 @@ export declare const createMemo: typeof coreMemo;
|
|
|
47
47
|
export declare const createSignal: typeof coreSignal;
|
|
48
48
|
export declare const createErrorBoundary: typeof coreErrorBoundary;
|
|
49
49
|
export declare const createOptimistic: typeof coreOptimistic;
|
|
50
|
-
export declare const createProjection: <T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue?: T, options?: HydrationProjectionOptions) => Store<T
|
|
50
|
+
export declare const createProjection: <T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue?: T, options?: HydrationProjectionOptions) => Store<T> & {
|
|
51
|
+
[$REFRESH]: any;
|
|
52
|
+
};
|
|
51
53
|
type NoFn<T> = T extends Function ? never : T;
|
|
52
54
|
export declare const createStore: {
|
|
53
55
|
<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>): [get: Store<T>, set: StoreSetter<T>];
|
|
54
|
-
<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store?: NoFn<T> | Store<NoFn<T>>, options?: HydrationProjectionOptions): [get: Store<T
|
|
56
|
+
<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store?: NoFn<T> | Store<NoFn<T>>, options?: HydrationProjectionOptions): [get: Store<T> & {
|
|
57
|
+
[$REFRESH]: any;
|
|
58
|
+
}, set: StoreSetter<T>];
|
|
55
59
|
};
|
|
56
60
|
export declare const createOptimisticStore: {
|
|
57
61
|
<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>): [get: Store<T>, set: StoreSetter<T>];
|
|
58
|
-
<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store?: NoFn<T> | Store<NoFn<T>>, options?: HydrationProjectionOptions): [get: Store<T
|
|
62
|
+
<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store?: NoFn<T> | Store<NoFn<T>>, options?: HydrationProjectionOptions): [get: Store<T> & {
|
|
63
|
+
[$REFRESH]: any;
|
|
64
|
+
}, set: StoreSetter<T>];
|
|
59
65
|
};
|
|
60
66
|
export declare const createRenderEffect: typeof coreRenderEffect;
|
|
61
67
|
export declare const createEffect: typeof coreEffect;
|
|
@@ -72,6 +78,7 @@ export declare const createEffect: typeof coreEffect;
|
|
|
72
78
|
*/
|
|
73
79
|
export declare function Loading(props: {
|
|
74
80
|
fallback?: JSX.Element;
|
|
81
|
+
on?: () => any;
|
|
75
82
|
children: JSX.Element;
|
|
76
83
|
}): JSX.Element;
|
|
77
84
|
/**
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { $PROXY, $TRACK, action, createOwner, createReaction, createRoot, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isEqual, isRefreshing, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, snapshot, storePath, untrack } from "@solidjs/signals";
|
|
2
|
-
export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, Merge, NoInfer, NotWrappable, Omit, Owner, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter } from "@solidjs/signals";
|
|
1
|
+
export { $PROXY, $REFRESH, $TRACK, action, createErrorBoundary, createLoadingBoundary, createOwner, createReaction, createRoot, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isEqual, isRefreshing, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, enableExternalSource, enforceLoadingBoundary, snapshot, storePath, untrack } from "@solidjs/signals";
|
|
2
|
+
export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, ExternalSource, ExternalSourceConfig, ExternalSourceFactory, Merge, NoInfer, NotWrappable, Omit, Owner, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter } from "@solidjs/signals";
|
|
3
3
|
export { $DEVCOMP, children, createContext, useContext } from "./client/core.js";
|
|
4
4
|
export type { ChildrenReturn, Context, ContextProviderComponent, ResolvedChildren, ResolvedJSXElement } from "./client/core.js";
|
|
5
5
|
export * from "./client/component.js";
|
package/types/server/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { $PROXY, $TRACK, action, createEffect, createMemo, createOptimistic, createOptimisticStore, createOwner, createProjection, createReaction, createRenderEffect, createRoot, createSignal, createStore, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isEqual, isRefreshing, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, snapshot, storePath, createDeepProxy, untrack } from "./signals.js";
|
|
2
|
-
export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, Merge, NoInfer, NotWrappable, Omit, Owner, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter, PatchOp } from "./signals.js";
|
|
1
|
+
export { $PROXY, $REFRESH, $TRACK, action, createEffect, createMemo, createOptimistic, createOptimisticStore, createErrorBoundary, createLoadingBoundary, createOwner, createProjection, createReaction, createRenderEffect, createRoot, createSignal, createStore, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isEqual, isRefreshing, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, snapshot, storePath, createDeepProxy, enableExternalSource, enforceLoadingBoundary, untrack } from "./signals.js";
|
|
2
|
+
export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, ExternalSource, ExternalSourceConfig, ExternalSourceFactory, Merge, NoInfer, NotWrappable, Omit, Owner, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter, PatchOp } from "./signals.js";
|
|
3
3
|
export { $DEVCOMP, children, createContext, useContext, ssrRunInScope } from "./core.js";
|
|
4
4
|
export type { ChildrenReturn, Context, ContextProviderComponent, ResolvedChildren, ResolvedJSXElement } from "./core.js";
|
|
5
5
|
export * from "./component.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export { createRoot, createOwner, runWithOwner, getOwner, onCleanup, getNextChildId, createContext, setContext, getContext, NotReadyError, NoOwnerError, ContextNotFoundError, isEqual, isWrappable, SUPPORTS_PROXY } from "@solidjs/signals";
|
|
1
|
+
export { createRoot, createOwner, runWithOwner, getOwner, onCleanup, getNextChildId, createContext, setContext, getContext, NotReadyError, NoOwnerError, ContextNotFoundError, isEqual, isWrappable, SUPPORTS_PROXY, enableExternalSource, enforceLoadingBoundary } from "@solidjs/signals";
|
|
2
2
|
export { flatten } from "@solidjs/signals";
|
|
3
|
-
export { snapshot, merge, omit, storePath, $PROXY, $TRACK } from "@solidjs/signals";
|
|
4
|
-
export type { Accessor, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, MemoOptions, NoInfer, SignalOptions, Setter, Signal, Owner, Maybe, Store, StoreSetter, StoreNode, NotWrappable, SolidStore, Merge, Omit, Context, ContextRecord, IQueue, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter } from "@solidjs/signals";
|
|
3
|
+
export { snapshot, merge, omit, storePath, $PROXY, $REFRESH, $TRACK } from "@solidjs/signals";
|
|
4
|
+
export type { Accessor, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, ExternalSource, ExternalSourceConfig, ExternalSourceFactory, MemoOptions, NoInfer, SignalOptions, Setter, Signal, Owner, Maybe, Store, StoreSetter, StoreNode, NotWrappable, SolidStore, Merge, Omit, Context, ContextRecord, IQueue, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter } from "@solidjs/signals";
|
|
5
5
|
import type { Accessor, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, MemoOptions, SignalOptions, Signal, Owner, Store, StoreSetter, Context } from "@solidjs/signals";
|
|
6
6
|
import { NoHydrateContext } from "./shared.js";
|
|
7
7
|
interface ServerComputation<T = any> {
|
|
@@ -49,7 +49,9 @@ declare const ErrorContext: Context<((err: any) => void) | null>;
|
|
|
49
49
|
export { ErrorContext };
|
|
50
50
|
export { NoHydrateContext };
|
|
51
51
|
export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown, reset: () => void) => U): () => unknown;
|
|
52
|
-
export declare function
|
|
52
|
+
export declare function createLoadingBoundary(fn: () => any, fallback: () => any, options?: {
|
|
53
|
+
on?: () => any;
|
|
54
|
+
}): () => unknown;
|
|
53
55
|
export declare function untrack<T>(fn: () => T): T;
|
|
54
56
|
export declare function flush(): void;
|
|
55
57
|
export declare function resolve<T>(fn: () => T): Promise<T>;
|