solid-js 2.0.0-beta.1 → 2.0.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 +131 -79
- package/dist/dev.js +125 -81
- package/dist/server.cjs +71 -75
- package/dist/server.js +64 -76
- package/dist/solid.cjs +129 -65
- package/dist/solid.js +122 -66
- package/package.json +2 -2
- package/types/client/hydration.d.ts +10 -4
- package/types/index.d.ts +1 -1
- package/types/server/index.d.ts +1 -1
- package/types/server/signals.d.ts +2 -2
package/dist/solid.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { getContext, createMemo as createMemo$1, flatten, createRoot, setContext, createLoadBoundary, 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, $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';
|
|
2
|
+
export { $PROXY, $REFRESH, $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, setOnUnhandledAsync, 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,24 +183,6 @@ function applyPatches(target, patches) {
|
|
|
152
183
|
}
|
|
153
184
|
}
|
|
154
185
|
}
|
|
155
|
-
function scheduleIteratorConsumption(iter, apply) {
|
|
156
|
-
const consume = () => {
|
|
157
|
-
while (true) {
|
|
158
|
-
const n = iter.next();
|
|
159
|
-
if (n instanceof Promise) {
|
|
160
|
-
n.then(r => {
|
|
161
|
-
if (r.done) return;
|
|
162
|
-
apply(r.value);
|
|
163
|
-
consume();
|
|
164
|
-
});
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
if (n.done) break;
|
|
168
|
-
apply(n.value);
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
consume();
|
|
172
|
-
}
|
|
173
186
|
function isAsyncIterable(v) {
|
|
174
187
|
return v != null && typeof v[Symbol.asyncIterator] === "function";
|
|
175
188
|
}
|
|
@@ -177,34 +190,85 @@ function hydrateSignalFromAsyncIterable(coreFn, compute, value, options) {
|
|
|
177
190
|
const parent = getOwner();
|
|
178
191
|
const expectedId = peekNextChildId(parent);
|
|
179
192
|
if (!sharedConfig.has(expectedId)) return null;
|
|
180
|
-
const
|
|
181
|
-
if (!isAsyncIterable(
|
|
182
|
-
const
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
return result;
|
|
193
|
+
const loaded = sharedConfig.load(expectedId);
|
|
194
|
+
if (!isAsyncIterable(loaded)) return null;
|
|
195
|
+
const it = normalizeIterator(loaded[Symbol.asyncIterator]());
|
|
196
|
+
const iterable = {
|
|
197
|
+
[Symbol.asyncIterator]() {
|
|
198
|
+
return it;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
return coreFn(() => iterable, value, options);
|
|
190
202
|
}
|
|
191
203
|
function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
|
|
192
204
|
const parent = getOwner();
|
|
193
205
|
const expectedId = peekNextChildId(parent);
|
|
194
206
|
if (!sharedConfig.has(expectedId)) return null;
|
|
195
|
-
const
|
|
196
|
-
if (!isAsyncIterable(
|
|
197
|
-
const
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
207
|
+
const loaded = sharedConfig.load(expectedId);
|
|
208
|
+
if (!isAsyncIterable(loaded)) return null;
|
|
209
|
+
const srcIt = loaded[Symbol.asyncIterator]();
|
|
210
|
+
let isFirst = true;
|
|
211
|
+
let buffered = null;
|
|
212
|
+
return coreFn(draft => {
|
|
213
|
+
const process = res => {
|
|
214
|
+
if (res.done) return {
|
|
215
|
+
done: true,
|
|
216
|
+
value: undefined
|
|
217
|
+
};
|
|
218
|
+
if (isFirst) {
|
|
219
|
+
isFirst = false;
|
|
220
|
+
if (Array.isArray(res.value)) {
|
|
221
|
+
for (let i = 0; i < res.value.length; i++) draft[i] = res.value[i];
|
|
222
|
+
draft.length = res.value.length;
|
|
223
|
+
} else {
|
|
224
|
+
Object.assign(draft, res.value);
|
|
225
|
+
}
|
|
226
|
+
} else {
|
|
227
|
+
applyPatches(draft, res.value);
|
|
228
|
+
}
|
|
229
|
+
return {
|
|
230
|
+
done: false,
|
|
231
|
+
value: undefined
|
|
232
|
+
};
|
|
233
|
+
};
|
|
234
|
+
return {
|
|
235
|
+
[Symbol.asyncIterator]() {
|
|
236
|
+
return {
|
|
237
|
+
next() {
|
|
238
|
+
if (isFirst) {
|
|
239
|
+
const r = srcIt.next();
|
|
240
|
+
return r && typeof r.then === "function" ? r.then(process) : syncThenable(process(r));
|
|
241
|
+
}
|
|
242
|
+
if (buffered) {
|
|
243
|
+
const b = buffered;
|
|
244
|
+
buffered = null;
|
|
245
|
+
return b.then(process);
|
|
246
|
+
}
|
|
247
|
+
let r = srcIt.next();
|
|
248
|
+
if (r && typeof r.then === "function") {
|
|
249
|
+
return r.then(process);
|
|
250
|
+
}
|
|
251
|
+
let result = process(r);
|
|
252
|
+
while (!r.done) {
|
|
253
|
+
const peek = srcIt.next();
|
|
254
|
+
if (peek && typeof peek.then === "function") {
|
|
255
|
+
buffered = peek;
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
r = peek;
|
|
259
|
+
if (!r.done) result = process(r);
|
|
260
|
+
}
|
|
261
|
+
return Promise.resolve(result);
|
|
262
|
+
}
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
}, initialValue, options);
|
|
205
267
|
}
|
|
206
268
|
function hydratedCreateMemo(compute, value, options) {
|
|
207
|
-
if (!sharedConfig.hydrating)
|
|
269
|
+
if (!sharedConfig.hydrating) {
|
|
270
|
+
return createMemo$1(compute, value, options);
|
|
271
|
+
}
|
|
208
272
|
markTopLevelSnapshotScope();
|
|
209
273
|
const ssrSource = options?.ssrSource;
|
|
210
274
|
if (ssrSource === "client") {
|
|
@@ -356,14 +420,16 @@ function hydratedCreateOptimisticStore(first, second, third) {
|
|
|
356
420
|
return createOptimisticStore$1(wrapStoreFn(first, ssrSource), second, third);
|
|
357
421
|
}
|
|
358
422
|
function hydratedCreateProjection(fn, initialValue, options) {
|
|
359
|
-
if (!sharedConfig.hydrating)
|
|
423
|
+
if (!sharedConfig.hydrating) {
|
|
424
|
+
return createProjection$1(fn, initialValue, options);
|
|
425
|
+
}
|
|
360
426
|
markTopLevelSnapshotScope();
|
|
361
427
|
const ssrSource = options?.ssrSource;
|
|
362
428
|
if (ssrSource === "client" || ssrSource === "initial") {
|
|
363
429
|
return createProjection$1(draft => draft, initialValue, options);
|
|
364
430
|
}
|
|
365
|
-
const aiResult = hydrateStoreFromAsyncIterable(
|
|
366
|
-
if (aiResult !== null) return aiResult
|
|
431
|
+
const aiResult = hydrateStoreFromAsyncIterable(createProjection$1, initialValue, options);
|
|
432
|
+
if (aiResult !== null) return aiResult;
|
|
367
433
|
return createProjection$1(wrapStoreFn(fn, ssrSource), initialValue, options);
|
|
368
434
|
}
|
|
369
435
|
function hydratedEffect(coreFn, compute, effectFn, value, options) {
|
|
@@ -636,15 +702,10 @@ function Show(props) {
|
|
|
636
702
|
if (c) {
|
|
637
703
|
const child = props.children;
|
|
638
704
|
const fn = typeof child === "function" && child.length > 0;
|
|
639
|
-
return fn ? untrack(() => {
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
return conditionValue();
|
|
644
|
-
});
|
|
645
|
-
} finally {
|
|
646
|
-
}
|
|
647
|
-
}) : child;
|
|
705
|
+
return fn ? untrack(() => child(() => {
|
|
706
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
707
|
+
return conditionValue();
|
|
708
|
+
}), IS_DEV) : child;
|
|
648
709
|
}
|
|
649
710
|
return props.fallback;
|
|
650
711
|
}, undefined, undefined);
|
|
@@ -672,15 +733,10 @@ function Switch(props) {
|
|
|
672
733
|
const [index, conditionValue, mp] = sel;
|
|
673
734
|
const child = mp.children;
|
|
674
735
|
const fn = typeof child === "function" && child.length > 0;
|
|
675
|
-
return fn ? untrack(() => {
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
return conditionValue();
|
|
680
|
-
});
|
|
681
|
-
} finally {
|
|
682
|
-
}
|
|
683
|
-
}) : child;
|
|
736
|
+
return fn ? untrack(() => child(() => {
|
|
737
|
+
if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
|
|
738
|
+
return conditionValue();
|
|
739
|
+
}), IS_DEV) : child;
|
|
684
740
|
}, undefined, undefined);
|
|
685
741
|
}
|
|
686
742
|
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.2",
|
|
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.12.0",
|
|
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;
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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";
|
|
1
|
+
export { $PROXY, $REFRESH, $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, setOnUnhandledAsync, snapshot, storePath, untrack } from "@solidjs/signals";
|
|
2
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";
|
|
3
3
|
export { $DEVCOMP, children, createContext, useContext } from "./client/core.js";
|
|
4
4
|
export type { ChildrenReturn, Context, ContextProviderComponent, ResolvedChildren, ResolvedJSXElement } from "./client/core.js";
|
package/types/server/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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";
|
|
1
|
+
export { $PROXY, $REFRESH, $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, setOnUnhandledAsync, untrack } from "./signals.js";
|
|
2
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";
|
|
3
3
|
export { $DEVCOMP, children, createContext, useContext, ssrRunInScope } from "./core.js";
|
|
4
4
|
export type { ChildrenReturn, Context, ContextProviderComponent, ResolvedChildren, ResolvedJSXElement } from "./core.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
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, setOnUnhandledAsync } from "@solidjs/signals";
|
|
2
2
|
export { flatten } from "@solidjs/signals";
|
|
3
|
-
export { snapshot, merge, omit, storePath, $PROXY, $TRACK } from "@solidjs/signals";
|
|
3
|
+
export { snapshot, merge, omit, storePath, $PROXY, $REFRESH, $TRACK } from "@solidjs/signals";
|
|
4
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";
|
|
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";
|