+131
-79
@@ -41,13 +41,6 @@ 'use strict'; | ||
| owner._component = Comp; | ||
| return signals.untrack(() => { | ||
| Object.assign(Comp, { | ||
| [$DEVCOMP]: true | ||
| }); | ||
| signals.setStrictRead(`<${Comp.name || "Anonymous"}>`); | ||
| try { | ||
| return Comp(props); | ||
| } finally { | ||
| signals.setStrictRead(false); | ||
| } | ||
| Object.assign(Comp, { | ||
| [$DEVCOMP]: true | ||
| }); | ||
| return signals.untrack(() => Comp(props), `<${Comp.name || "Anonymous"}>`); | ||
| }, { | ||
@@ -165,8 +158,38 @@ transparent: true | ||
| } | ||
| function consumeFirstSync(ai) { | ||
| const iter = ai[Symbol.asyncIterator](); | ||
| const r = iter.next(); | ||
| const value = !(r instanceof Promise) && !r.done ? r.value : undefined; | ||
| return [value, iter]; | ||
| function syncThenable(value) { | ||
| return { | ||
| then(fn) { | ||
| fn(value); | ||
| } | ||
| }; | ||
| } | ||
| function normalizeIterator(it) { | ||
| let first = true; | ||
| let buffered = null; | ||
| return { | ||
| next() { | ||
| if (first) { | ||
| first = false; | ||
| const r = it.next(); | ||
| return r && typeof r.then === "function" ? r : syncThenable(r); | ||
| } | ||
| if (buffered) { | ||
| const b = buffered; | ||
| buffered = null; | ||
| return b; | ||
| } | ||
| let latest = it.next(); | ||
| if (latest && typeof latest.then === "function") return latest; | ||
| while (!latest.done) { | ||
| const peek = it.next(); | ||
| if (peek && typeof peek.then === "function") { | ||
| buffered = peek; | ||
| break; | ||
| } | ||
| latest = peek; | ||
| } | ||
| return Promise.resolve(latest); | ||
| } | ||
| }; | ||
| } | ||
| function applyPatches(target, patches) { | ||
@@ -187,20 +210,2 @@ for (const patch of patches) { | ||
| } | ||
| function scheduleIteratorConsumption(iter, apply) { | ||
| const consume = () => { | ||
| while (true) { | ||
| const n = iter.next(); | ||
| if (n instanceof Promise) { | ||
| n.then(r => { | ||
| if (r.done) return; | ||
| apply(r.value); | ||
| consume(); | ||
| }); | ||
| return; | ||
| } | ||
| if (n.done) break; | ||
| apply(n.value); | ||
| } | ||
| }; | ||
| consume(); | ||
| } | ||
| function isAsyncIterable(v) { | ||
@@ -213,12 +218,11 @@ return v != null && typeof v[Symbol.asyncIterator] === "function"; | ||
| if (!sharedConfig.has(expectedId)) return null; | ||
| const initP = sharedConfig.load(expectedId); | ||
| if (!isAsyncIterable(initP)) return null; | ||
| const [firstValue, iter] = consumeFirstSync(initP); | ||
| const [get, set] = signals.createSignal(firstValue); | ||
| const result = coreFn(() => get(), firstValue, options); | ||
| scheduleIteratorConsumption(iter, v => { | ||
| set(() => v); | ||
| signals.flush(); | ||
| }); | ||
| return result; | ||
| const loaded = sharedConfig.load(expectedId); | ||
| if (!isAsyncIterable(loaded)) return null; | ||
| const it = normalizeIterator(loaded[Symbol.asyncIterator]()); | ||
| const iterable = { | ||
| [Symbol.asyncIterator]() { | ||
| return it; | ||
| } | ||
| }; | ||
| return coreFn(() => iterable, value, options); | ||
| } | ||
@@ -229,15 +233,67 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) { | ||
| if (!sharedConfig.has(expectedId)) return null; | ||
| const initP = sharedConfig.load(expectedId); | ||
| if (!isAsyncIterable(initP)) return null; | ||
| const [firstState, iter] = consumeFirstSync(initP); | ||
| const [store, setStore] = coreFn(() => {}, firstState ?? initialValue, options); | ||
| scheduleIteratorConsumption(iter, patches => { | ||
| setStore(d => { | ||
| applyPatches(d, patches); | ||
| }); | ||
| }); | ||
| return [store, setStore]; | ||
| const loaded = sharedConfig.load(expectedId); | ||
| if (!isAsyncIterable(loaded)) return null; | ||
| const srcIt = loaded[Symbol.asyncIterator](); | ||
| let isFirst = true; | ||
| let buffered = null; | ||
| return coreFn(draft => { | ||
| const process = res => { | ||
| if (res.done) return { | ||
| done: true, | ||
| value: undefined | ||
| }; | ||
| if (isFirst) { | ||
| isFirst = false; | ||
| if (Array.isArray(res.value)) { | ||
| for (let i = 0; i < res.value.length; i++) draft[i] = res.value[i]; | ||
| draft.length = res.value.length; | ||
| } else { | ||
| Object.assign(draft, res.value); | ||
| } | ||
| } else { | ||
| applyPatches(draft, res.value); | ||
| } | ||
| return { | ||
| done: false, | ||
| value: undefined | ||
| }; | ||
| }; | ||
| return { | ||
| [Symbol.asyncIterator]() { | ||
| return { | ||
| next() { | ||
| if (isFirst) { | ||
| const r = srcIt.next(); | ||
| return r && typeof r.then === "function" ? r.then(process) : syncThenable(process(r)); | ||
| } | ||
| if (buffered) { | ||
| const b = buffered; | ||
| buffered = null; | ||
| return b.then(process); | ||
| } | ||
| let r = srcIt.next(); | ||
| if (r && typeof r.then === "function") { | ||
| return r.then(process); | ||
| } | ||
| let result = process(r); | ||
| while (!r.done) { | ||
| const peek = srcIt.next(); | ||
| if (peek && typeof peek.then === "function") { | ||
| buffered = peek; | ||
| break; | ||
| } | ||
| r = peek; | ||
| if (!r.done) result = process(r); | ||
| } | ||
| return Promise.resolve(result); | ||
| } | ||
| }; | ||
| } | ||
| }; | ||
| }, initialValue, options); | ||
| } | ||
| function hydratedCreateMemo(compute, value, options) { | ||
| if (!sharedConfig.hydrating) return signals.createMemo(compute, value, options); | ||
| if (!sharedConfig.hydrating) { | ||
| return signals.createMemo(compute, value, options); | ||
| } | ||
| markTopLevelSnapshotScope(); | ||
@@ -394,3 +450,5 @@ const ssrSource = options?.ssrSource; | ||
| function hydratedCreateProjection(fn, initialValue, options) { | ||
| if (!sharedConfig.hydrating) return signals.createProjection(fn, initialValue, options); | ||
| if (!sharedConfig.hydrating) { | ||
| return signals.createProjection(fn, initialValue, options); | ||
| } | ||
| markTopLevelSnapshotScope(); | ||
@@ -401,4 +459,4 @@ const ssrSource = options?.ssrSource; | ||
| } | ||
| const aiResult = hydrateStoreFromAsyncIterable(signals.createStore, initialValue, options); | ||
| if (aiResult !== null) return aiResult[0]; | ||
| const aiResult = hydrateStoreFromAsyncIterable(signals.createProjection, initialValue, options); | ||
| if (aiResult !== null) return aiResult; | ||
| return signals.createProjection(wrapStoreFn(fn, ssrSource), initialValue, options); | ||
@@ -684,13 +742,6 @@ } | ||
| const fn = typeof child === "function" && child.length > 0; | ||
| return fn ? signals.untrack(() => { | ||
| signals.setStrictRead("<Show>"); | ||
| try { | ||
| return child(() => { | ||
| if (!signals.untrack(condition)) throw narrowedError("Show"); | ||
| return conditionValue(); | ||
| }); | ||
| } finally { | ||
| signals.setStrictRead(false); | ||
| } | ||
| }) : child; | ||
| return fn ? signals.untrack(() => child(() => { | ||
| if (!signals.untrack(condition)) throw narrowedError("Show"); | ||
| return conditionValue(); | ||
| }), "<Show>") : child; | ||
| } | ||
@@ -728,13 +779,6 @@ return props.fallback; | ||
| const fn = typeof child === "function" && child.length > 0; | ||
| return fn ? signals.untrack(() => { | ||
| signals.setStrictRead("<Match>"); | ||
| try { | ||
| return child(() => { | ||
| if (signals.untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match"); | ||
| return conditionValue(); | ||
| }); | ||
| } finally { | ||
| signals.setStrictRead(false); | ||
| } | ||
| }) : child; | ||
| return fn ? signals.untrack(() => child(() => { | ||
| if (signals.untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match"); | ||
| return conditionValue(); | ||
| }), "<Match>") : child; | ||
| }, undefined, { | ||
@@ -770,2 +814,6 @@ name: "eval conditions" | ||
| }); | ||
| Object.defineProperty(exports, "$REFRESH", { | ||
| enumerable: true, | ||
| get: function () { return signals.$REFRESH; } | ||
| }); | ||
| Object.defineProperty(exports, "$TRACK", { | ||
@@ -883,2 +931,6 @@ enumerable: true, | ||
| }); | ||
| Object.defineProperty(exports, "setOnUnhandledAsync", { | ||
| enumerable: true, | ||
| get: function () { return signals.setOnUnhandledAsync; } | ||
| }); | ||
| Object.defineProperty(exports, "snapshot", { | ||
@@ -885,0 +937,0 @@ enumerable: true, |
+125
-81
@@ -1,3 +0,3 @@ | ||
| import { getContext, createMemo as createMemo$1, flatten, getOwner, createRoot, setContext, untrack, setStrictRead, createLoadBoundary, 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, mapArray, repeat } from '@solidjs/signals'; | ||
| 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'; | ||
| import { getContext, createMemo as createMemo$1, flatten, getOwner, createRoot, setContext, untrack, createLoadBoundary, 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, mapArray, repeat } from '@solidjs/signals'; | ||
| 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'; | ||
@@ -40,13 +40,6 @@ const $DEVCOMP = Symbol("COMPONENT_DEV" ); | ||
| owner._component = Comp; | ||
| return untrack(() => { | ||
| Object.assign(Comp, { | ||
| [$DEVCOMP]: true | ||
| }); | ||
| setStrictRead(`<${Comp.name || "Anonymous"}>`); | ||
| try { | ||
| return Comp(props); | ||
| } finally { | ||
| setStrictRead(false); | ||
| } | ||
| Object.assign(Comp, { | ||
| [$DEVCOMP]: true | ||
| }); | ||
| return untrack(() => Comp(props), `<${Comp.name || "Anonymous"}>`); | ||
| }, { | ||
@@ -164,8 +157,38 @@ transparent: true | ||
| } | ||
| function consumeFirstSync(ai) { | ||
| const iter = ai[Symbol.asyncIterator](); | ||
| const r = iter.next(); | ||
| const value = !(r instanceof Promise) && !r.done ? r.value : undefined; | ||
| return [value, iter]; | ||
| function syncThenable(value) { | ||
| return { | ||
| then(fn) { | ||
| fn(value); | ||
| } | ||
| }; | ||
| } | ||
| function normalizeIterator(it) { | ||
| let first = true; | ||
| let buffered = null; | ||
| return { | ||
| next() { | ||
| if (first) { | ||
| first = false; | ||
| const r = it.next(); | ||
| return r && typeof r.then === "function" ? r : syncThenable(r); | ||
| } | ||
| if (buffered) { | ||
| const b = buffered; | ||
| buffered = null; | ||
| return b; | ||
| } | ||
| let latest = it.next(); | ||
| if (latest && typeof latest.then === "function") return latest; | ||
| while (!latest.done) { | ||
| const peek = it.next(); | ||
| if (peek && typeof peek.then === "function") { | ||
| buffered = peek; | ||
| break; | ||
| } | ||
| latest = peek; | ||
| } | ||
| return Promise.resolve(latest); | ||
| } | ||
| }; | ||
| } | ||
| function applyPatches(target, patches) { | ||
@@ -186,20 +209,2 @@ for (const patch of patches) { | ||
| } | ||
| function scheduleIteratorConsumption(iter, apply) { | ||
| const consume = () => { | ||
| while (true) { | ||
| const n = iter.next(); | ||
| if (n instanceof Promise) { | ||
| n.then(r => { | ||
| if (r.done) return; | ||
| apply(r.value); | ||
| consume(); | ||
| }); | ||
| return; | ||
| } | ||
| if (n.done) break; | ||
| apply(n.value); | ||
| } | ||
| }; | ||
| consume(); | ||
| } | ||
| function isAsyncIterable(v) { | ||
@@ -212,12 +217,11 @@ return v != null && typeof v[Symbol.asyncIterator] === "function"; | ||
| if (!sharedConfig.has(expectedId)) return null; | ||
| const initP = sharedConfig.load(expectedId); | ||
| if (!isAsyncIterable(initP)) return null; | ||
| const [firstValue, iter] = consumeFirstSync(initP); | ||
| const [get, set] = createSignal$1(firstValue); | ||
| const result = coreFn(() => get(), firstValue, options); | ||
| scheduleIteratorConsumption(iter, v => { | ||
| set(() => v); | ||
| flush(); | ||
| }); | ||
| return result; | ||
| const loaded = sharedConfig.load(expectedId); | ||
| if (!isAsyncIterable(loaded)) return null; | ||
| const it = normalizeIterator(loaded[Symbol.asyncIterator]()); | ||
| const iterable = { | ||
| [Symbol.asyncIterator]() { | ||
| return it; | ||
| } | ||
| }; | ||
| return coreFn(() => iterable, value, options); | ||
| } | ||
@@ -228,15 +232,67 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) { | ||
| if (!sharedConfig.has(expectedId)) return null; | ||
| const initP = sharedConfig.load(expectedId); | ||
| if (!isAsyncIterable(initP)) return null; | ||
| const [firstState, iter] = consumeFirstSync(initP); | ||
| const [store, setStore] = coreFn(() => {}, firstState ?? initialValue, options); | ||
| scheduleIteratorConsumption(iter, patches => { | ||
| setStore(d => { | ||
| applyPatches(d, patches); | ||
| }); | ||
| }); | ||
| return [store, setStore]; | ||
| const loaded = sharedConfig.load(expectedId); | ||
| if (!isAsyncIterable(loaded)) return null; | ||
| const srcIt = loaded[Symbol.asyncIterator](); | ||
| let isFirst = true; | ||
| let buffered = null; | ||
| return coreFn(draft => { | ||
| const process = res => { | ||
| if (res.done) return { | ||
| done: true, | ||
| value: undefined | ||
| }; | ||
| if (isFirst) { | ||
| isFirst = false; | ||
| if (Array.isArray(res.value)) { | ||
| for (let i = 0; i < res.value.length; i++) draft[i] = res.value[i]; | ||
| draft.length = res.value.length; | ||
| } else { | ||
| Object.assign(draft, res.value); | ||
| } | ||
| } else { | ||
| applyPatches(draft, res.value); | ||
| } | ||
| return { | ||
| done: false, | ||
| value: undefined | ||
| }; | ||
| }; | ||
| return { | ||
| [Symbol.asyncIterator]() { | ||
| return { | ||
| next() { | ||
| if (isFirst) { | ||
| const r = srcIt.next(); | ||
| return r && typeof r.then === "function" ? r.then(process) : syncThenable(process(r)); | ||
| } | ||
| if (buffered) { | ||
| const b = buffered; | ||
| buffered = null; | ||
| return b.then(process); | ||
| } | ||
| let r = srcIt.next(); | ||
| if (r && typeof r.then === "function") { | ||
| return r.then(process); | ||
| } | ||
| let result = process(r); | ||
| while (!r.done) { | ||
| const peek = srcIt.next(); | ||
| if (peek && typeof peek.then === "function") { | ||
| buffered = peek; | ||
| break; | ||
| } | ||
| r = peek; | ||
| if (!r.done) result = process(r); | ||
| } | ||
| return Promise.resolve(result); | ||
| } | ||
| }; | ||
| } | ||
| }; | ||
| }, initialValue, options); | ||
| } | ||
| function hydratedCreateMemo(compute, value, options) { | ||
| if (!sharedConfig.hydrating) return createMemo$1(compute, value, options); | ||
| if (!sharedConfig.hydrating) { | ||
| return createMemo$1(compute, value, options); | ||
| } | ||
| markTopLevelSnapshotScope(); | ||
@@ -393,3 +449,5 @@ const ssrSource = options?.ssrSource; | ||
| function hydratedCreateProjection(fn, initialValue, options) { | ||
| if (!sharedConfig.hydrating) return createProjection$1(fn, initialValue, options); | ||
| if (!sharedConfig.hydrating) { | ||
| return createProjection$1(fn, initialValue, options); | ||
| } | ||
| markTopLevelSnapshotScope(); | ||
@@ -400,4 +458,4 @@ const ssrSource = options?.ssrSource; | ||
| } | ||
| const aiResult = hydrateStoreFromAsyncIterable(createStore$1, initialValue, options); | ||
| if (aiResult !== null) return aiResult[0]; | ||
| const aiResult = hydrateStoreFromAsyncIterable(createProjection$1, initialValue, options); | ||
| if (aiResult !== null) return aiResult; | ||
| return createProjection$1(wrapStoreFn(fn, ssrSource), initialValue, options); | ||
@@ -683,13 +741,6 @@ } | ||
| const fn = typeof child === "function" && child.length > 0; | ||
| return fn ? untrack(() => { | ||
| setStrictRead("<Show>"); | ||
| try { | ||
| return child(() => { | ||
| if (!untrack(condition)) throw narrowedError("Show"); | ||
| return conditionValue(); | ||
| }); | ||
| } finally { | ||
| setStrictRead(false); | ||
| } | ||
| }) : child; | ||
| return fn ? untrack(() => child(() => { | ||
| if (!untrack(condition)) throw narrowedError("Show"); | ||
| return conditionValue(); | ||
| }), "<Show>") : child; | ||
| } | ||
@@ -727,13 +778,6 @@ return props.fallback; | ||
| const fn = typeof child === "function" && child.length > 0; | ||
| return fn ? untrack(() => { | ||
| setStrictRead("<Match>"); | ||
| try { | ||
| return child(() => { | ||
| if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match"); | ||
| return conditionValue(); | ||
| }); | ||
| } finally { | ||
| setStrictRead(false); | ||
| } | ||
| }) : child; | ||
| return fn ? untrack(() => child(() => { | ||
| if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match"); | ||
| return conditionValue(); | ||
| }), "<Match>") : child; | ||
| }, undefined, { | ||
@@ -740,0 +784,0 @@ name: "eval conditions" |
+71
-75
@@ -33,21 +33,8 @@ 'use strict'; | ||
| if (typeof first === "function") { | ||
| const ssrSource = third?.ssrSource; | ||
| if (ssrSource === "initial" || ssrSource === "client") { | ||
| signals.createOwner(); | ||
| let value = second; | ||
| return [() => value, v => { | ||
| return value = typeof v === "function" ? v(value) : v; | ||
| }]; | ||
| } | ||
| const memoOpts = third?.deferStream || ssrSource ? { | ||
| const opts = third?.deferStream || third?.ssrSource ? { | ||
| deferStream: third?.deferStream, | ||
| ssrSource | ||
| ssrSource: third?.ssrSource | ||
| } : undefined; | ||
| const memo = createMemo(p => { | ||
| let value = first(p ? p[0]() : second); | ||
| return [() => value, v => { | ||
| return value = typeof v === "function" ? v(value) : v; | ||
| }]; | ||
| }, undefined, memoOpts); | ||
| return [() => memo()[0](), v => memo()[1](v)]; | ||
| const memo = createMemo(prev => first(prev), second, opts); | ||
| return [memo, () => undefined]; | ||
| } | ||
@@ -189,10 +176,9 @@ return [() => first, v => { | ||
| promise.v = v.value; | ||
| if (comp.disposed) return; | ||
| if (comp.disposed) return v.value; | ||
| comp.value = v.value; | ||
| comp.error = undefined; | ||
| return v.value; | ||
| }, () => {}); | ||
| if (ctx?.async && ctx.serialize && id && !noHydrate) ctx.serialize(id, promise, deferStream); | ||
| if (uninitialized) { | ||
| comp.error = new signals.NotReadyError(promise); | ||
| } | ||
| comp.error = new signals.NotReadyError(promise); | ||
| } else { | ||
@@ -204,24 +190,22 @@ const firstNext = iter.next(); | ||
| comp.value = r.value; | ||
| comp.error = undefined; | ||
| } | ||
| comp.error = undefined; | ||
| return Promise.resolve(); | ||
| }, () => {}); | ||
| let servedFirst = false; | ||
| const tapped = { | ||
| [Symbol.asyncIterator]: () => ({ | ||
| next() { | ||
| if (!servedFirst) { | ||
| servedFirst = true; | ||
| return firstNext.then(r => { | ||
| if (!r.done && !comp.disposed) comp.value = r.value; | ||
| return r; | ||
| }); | ||
| if (ctx?.async && ctx.serialize && id && !noHydrate) { | ||
| let tappedFirst = true; | ||
| const tapped = { | ||
| [Symbol.asyncIterator]: () => ({ | ||
| next() { | ||
| if (tappedFirst) { | ||
| tappedFirst = false; | ||
| return firstNext.then(r => r); | ||
| } | ||
| return iter.next().then(r => r); | ||
| } | ||
| return iter.next().then(r => r); | ||
| } | ||
| }) | ||
| }; | ||
| if (ctx?.async && ctx.serialize && id && !noHydrate) ctx.serialize(id, tapped, deferStream); | ||
| if (uninitialized) { | ||
| comp.error = new signals.NotReadyError(firstReady); | ||
| }) | ||
| }; | ||
| ctx.serialize(id, tapped, deferStream); | ||
| } | ||
| comp.error = new signals.NotReadyError(firstReady); | ||
| } | ||
@@ -335,3 +319,3 @@ return; | ||
| promise.v = state; | ||
| return; | ||
| return state; | ||
| } | ||
@@ -343,2 +327,3 @@ if (r.value !== undefined && r.value !== state) { | ||
| markReady(); | ||
| return state; | ||
| }, () => {}); | ||
@@ -359,18 +344,41 @@ if (ctx?.async && !signals.getContext(NoHydrateContext) && owner.id) ctx.serialize(owner.id, promise, options?.deferStream); | ||
| markReady(JSON.parse(JSON.stringify(state))); | ||
| return Promise.resolve(); | ||
| }, () => { | ||
| markReady(); | ||
| }); | ||
| let servedFirst = false; | ||
| const tapped = { | ||
| [Symbol.asyncIterator]: () => ({ | ||
| next() { | ||
| if (!servedFirst) { | ||
| servedFirst = true; | ||
| return firstNext.then(r => { | ||
| if (!r.done && !disposed) return { | ||
| done: false, | ||
| value: state | ||
| if (ctx?.async && !signals.getContext(NoHydrateContext) && owner.id) { | ||
| let tappedFirst = true; | ||
| const tapped = { | ||
| [Symbol.asyncIterator]: () => ({ | ||
| next() { | ||
| if (tappedFirst) { | ||
| tappedFirst = false; | ||
| return firstNext.then(r => { | ||
| if (r.done) return { | ||
| done: true, | ||
| value: undefined | ||
| }; | ||
| return { | ||
| done: false, | ||
| value: JSON.parse(JSON.stringify(state)) | ||
| }; | ||
| }); | ||
| } | ||
| return iter.next().then(r => { | ||
| if (disposed) return { | ||
| done: true, | ||
| value: undefined | ||
| }; | ||
| const flushed = patches.splice(0); | ||
| if (!r.done) { | ||
| if (r.value !== undefined && r.value !== draft) { | ||
| Object.assign(state, r.value); | ||
| } | ||
| return { | ||
| done: false, | ||
| value: flushed | ||
| }; | ||
| } | ||
| return { | ||
| done: r.done, | ||
| done: true, | ||
| value: undefined | ||
@@ -380,26 +388,6 @@ }; | ||
| } | ||
| return iter.next().then(r => { | ||
| if (disposed) return { | ||
| done: true, | ||
| value: undefined | ||
| }; | ||
| const flushed = patches.splice(0); | ||
| if (!r.done) { | ||
| if (r.value !== undefined && r.value !== draft) { | ||
| Object.assign(state, r.value); | ||
| } | ||
| return { | ||
| done: false, | ||
| value: flushed | ||
| }; | ||
| } | ||
| return { | ||
| done: true, | ||
| value: undefined | ||
| }; | ||
| }); | ||
| } | ||
| }) | ||
| }; | ||
| if (ctx?.async && !signals.getContext(NoHydrateContext) && owner.id) ctx.serialize(owner.id, tapped, options?.deferStream); | ||
| }) | ||
| }; | ||
| ctx.serialize(owner.id, tapped, options?.deferStream); | ||
| } | ||
| const [pending, markReady] = createPendingProxy(state, firstReady); | ||
@@ -816,2 +804,6 @@ return pending; | ||
| }); | ||
| Object.defineProperty(exports, "$REFRESH", { | ||
| enumerable: true, | ||
| get: function () { return signals.$REFRESH; } | ||
| }); | ||
| Object.defineProperty(exports, "$TRACK", { | ||
@@ -869,2 +861,6 @@ enumerable: true, | ||
| }); | ||
| Object.defineProperty(exports, "setOnUnhandledAsync", { | ||
| enumerable: true, | ||
| get: function () { return signals.setOnUnhandledAsync; } | ||
| }); | ||
| Object.defineProperty(exports, "snapshot", { | ||
@@ -871,0 +867,0 @@ enumerable: true, |
+64
-76
| import { getOwner, getContext, getNextChildId, createOwner, runWithOwner, onCleanup, NotReadyError, isWrappable, setContext, flatten, createRoot } from '@solidjs/signals'; | ||
| export { $PROXY, $TRACK, NotReadyError, createOwner, createRoot, flatten, getNextChildId, getOwner, isEqual, isWrappable, merge, omit, onCleanup, runWithOwner, snapshot, storePath } from '@solidjs/signals'; | ||
| export { $PROXY, $REFRESH, $TRACK, NotReadyError, createOwner, createRoot, flatten, getNextChildId, getOwner, isEqual, isWrappable, merge, omit, onCleanup, runWithOwner, setOnUnhandledAsync, snapshot, storePath } from '@solidjs/signals'; | ||
@@ -32,21 +32,8 @@ const NoHydrateContext = { | ||
| if (typeof first === "function") { | ||
| const ssrSource = third?.ssrSource; | ||
| if (ssrSource === "initial" || ssrSource === "client") { | ||
| createOwner(); | ||
| let value = second; | ||
| return [() => value, v => { | ||
| return value = typeof v === "function" ? v(value) : v; | ||
| }]; | ||
| } | ||
| const memoOpts = third?.deferStream || ssrSource ? { | ||
| const opts = third?.deferStream || third?.ssrSource ? { | ||
| deferStream: third?.deferStream, | ||
| ssrSource | ||
| ssrSource: third?.ssrSource | ||
| } : undefined; | ||
| const memo = createMemo(p => { | ||
| let value = first(p ? p[0]() : second); | ||
| return [() => value, v => { | ||
| return value = typeof v === "function" ? v(value) : v; | ||
| }]; | ||
| }, undefined, memoOpts); | ||
| return [() => memo()[0](), v => memo()[1](v)]; | ||
| const memo = createMemo(prev => first(prev), second, opts); | ||
| return [memo, () => undefined]; | ||
| } | ||
@@ -188,10 +175,9 @@ return [() => first, v => { | ||
| promise.v = v.value; | ||
| if (comp.disposed) return; | ||
| if (comp.disposed) return v.value; | ||
| comp.value = v.value; | ||
| comp.error = undefined; | ||
| return v.value; | ||
| }, () => {}); | ||
| if (ctx?.async && ctx.serialize && id && !noHydrate) ctx.serialize(id, promise, deferStream); | ||
| if (uninitialized) { | ||
| comp.error = new NotReadyError(promise); | ||
| } | ||
| comp.error = new NotReadyError(promise); | ||
| } else { | ||
@@ -203,24 +189,22 @@ const firstNext = iter.next(); | ||
| comp.value = r.value; | ||
| comp.error = undefined; | ||
| } | ||
| comp.error = undefined; | ||
| return Promise.resolve(); | ||
| }, () => {}); | ||
| let servedFirst = false; | ||
| const tapped = { | ||
| [Symbol.asyncIterator]: () => ({ | ||
| next() { | ||
| if (!servedFirst) { | ||
| servedFirst = true; | ||
| return firstNext.then(r => { | ||
| if (!r.done && !comp.disposed) comp.value = r.value; | ||
| return r; | ||
| }); | ||
| if (ctx?.async && ctx.serialize && id && !noHydrate) { | ||
| let tappedFirst = true; | ||
| const tapped = { | ||
| [Symbol.asyncIterator]: () => ({ | ||
| next() { | ||
| if (tappedFirst) { | ||
| tappedFirst = false; | ||
| return firstNext.then(r => r); | ||
| } | ||
| return iter.next().then(r => r); | ||
| } | ||
| return iter.next().then(r => r); | ||
| } | ||
| }) | ||
| }; | ||
| if (ctx?.async && ctx.serialize && id && !noHydrate) ctx.serialize(id, tapped, deferStream); | ||
| if (uninitialized) { | ||
| comp.error = new NotReadyError(firstReady); | ||
| }) | ||
| }; | ||
| ctx.serialize(id, tapped, deferStream); | ||
| } | ||
| comp.error = new NotReadyError(firstReady); | ||
| } | ||
@@ -334,3 +318,3 @@ return; | ||
| promise.v = state; | ||
| return; | ||
| return state; | ||
| } | ||
@@ -342,2 +326,3 @@ if (r.value !== undefined && r.value !== state) { | ||
| markReady(); | ||
| return state; | ||
| }, () => {}); | ||
@@ -358,18 +343,41 @@ if (ctx?.async && !getContext(NoHydrateContext) && owner.id) ctx.serialize(owner.id, promise, options?.deferStream); | ||
| markReady(JSON.parse(JSON.stringify(state))); | ||
| return Promise.resolve(); | ||
| }, () => { | ||
| markReady(); | ||
| }); | ||
| let servedFirst = false; | ||
| const tapped = { | ||
| [Symbol.asyncIterator]: () => ({ | ||
| next() { | ||
| if (!servedFirst) { | ||
| servedFirst = true; | ||
| return firstNext.then(r => { | ||
| if (!r.done && !disposed) return { | ||
| done: false, | ||
| value: state | ||
| if (ctx?.async && !getContext(NoHydrateContext) && owner.id) { | ||
| let tappedFirst = true; | ||
| const tapped = { | ||
| [Symbol.asyncIterator]: () => ({ | ||
| next() { | ||
| if (tappedFirst) { | ||
| tappedFirst = false; | ||
| return firstNext.then(r => { | ||
| if (r.done) return { | ||
| done: true, | ||
| value: undefined | ||
| }; | ||
| return { | ||
| done: false, | ||
| value: JSON.parse(JSON.stringify(state)) | ||
| }; | ||
| }); | ||
| } | ||
| return iter.next().then(r => { | ||
| if (disposed) return { | ||
| done: true, | ||
| value: undefined | ||
| }; | ||
| const flushed = patches.splice(0); | ||
| if (!r.done) { | ||
| if (r.value !== undefined && r.value !== draft) { | ||
| Object.assign(state, r.value); | ||
| } | ||
| return { | ||
| done: false, | ||
| value: flushed | ||
| }; | ||
| } | ||
| return { | ||
| done: r.done, | ||
| done: true, | ||
| value: undefined | ||
@@ -379,26 +387,6 @@ }; | ||
| } | ||
| return iter.next().then(r => { | ||
| if (disposed) return { | ||
| done: true, | ||
| value: undefined | ||
| }; | ||
| const flushed = patches.splice(0); | ||
| if (!r.done) { | ||
| if (r.value !== undefined && r.value !== draft) { | ||
| Object.assign(state, r.value); | ||
| } | ||
| return { | ||
| done: false, | ||
| value: flushed | ||
| }; | ||
| } | ||
| return { | ||
| done: true, | ||
| value: undefined | ||
| }; | ||
| }); | ||
| } | ||
| }) | ||
| }; | ||
| if (ctx?.async && !getContext(NoHydrateContext) && owner.id) ctx.serialize(owner.id, tapped, options?.deferStream); | ||
| }) | ||
| }; | ||
| ctx.serialize(owner.id, tapped, options?.deferStream); | ||
| } | ||
| const [pending, markReady] = createPendingProxy(state, firstReady); | ||
@@ -405,0 +393,0 @@ return pending; |
+129
-65
@@ -5,2 +5,3 @@ 'use strict'; | ||
| const IS_DEV = false; | ||
| const $DEVCOMP = Symbol(0); | ||
@@ -136,8 +137,38 @@ function createContext(defaultValue, options) { | ||
| } | ||
| function consumeFirstSync(ai) { | ||
| const iter = ai[Symbol.asyncIterator](); | ||
| const r = iter.next(); | ||
| const value = !(r instanceof Promise) && !r.done ? r.value : undefined; | ||
| return [value, iter]; | ||
| function syncThenable(value) { | ||
| return { | ||
| then(fn) { | ||
| fn(value); | ||
| } | ||
| }; | ||
| } | ||
| function normalizeIterator(it) { | ||
| let first = true; | ||
| let buffered = null; | ||
| return { | ||
| next() { | ||
| if (first) { | ||
| first = false; | ||
| const r = it.next(); | ||
| return r && typeof r.then === "function" ? r : syncThenable(r); | ||
| } | ||
| if (buffered) { | ||
| const b = buffered; | ||
| buffered = null; | ||
| return b; | ||
| } | ||
| let latest = it.next(); | ||
| if (latest && typeof latest.then === "function") return latest; | ||
| while (!latest.done) { | ||
| const peek = it.next(); | ||
| if (peek && typeof peek.then === "function") { | ||
| buffered = peek; | ||
| break; | ||
| } | ||
| latest = peek; | ||
| } | ||
| return Promise.resolve(latest); | ||
| } | ||
| }; | ||
| } | ||
| function applyPatches(target, patches) { | ||
@@ -158,20 +189,2 @@ for (const patch of patches) { | ||
| } | ||
| function scheduleIteratorConsumption(iter, apply) { | ||
| const consume = () => { | ||
| while (true) { | ||
| const n = iter.next(); | ||
| if (n instanceof Promise) { | ||
| n.then(r => { | ||
| if (r.done) return; | ||
| apply(r.value); | ||
| consume(); | ||
| }); | ||
| return; | ||
| } | ||
| if (n.done) break; | ||
| apply(n.value); | ||
| } | ||
| }; | ||
| consume(); | ||
| } | ||
| function isAsyncIterable(v) { | ||
@@ -184,12 +197,11 @@ return v != null && typeof v[Symbol.asyncIterator] === "function"; | ||
| if (!sharedConfig.has(expectedId)) return null; | ||
| const initP = sharedConfig.load(expectedId); | ||
| if (!isAsyncIterable(initP)) return null; | ||
| const [firstValue, iter] = consumeFirstSync(initP); | ||
| const [get, set] = signals.createSignal(firstValue); | ||
| const result = coreFn(() => get(), firstValue, options); | ||
| scheduleIteratorConsumption(iter, v => { | ||
| set(() => v); | ||
| signals.flush(); | ||
| }); | ||
| return result; | ||
| const loaded = sharedConfig.load(expectedId); | ||
| if (!isAsyncIterable(loaded)) return null; | ||
| const it = normalizeIterator(loaded[Symbol.asyncIterator]()); | ||
| const iterable = { | ||
| [Symbol.asyncIterator]() { | ||
| return it; | ||
| } | ||
| }; | ||
| return coreFn(() => iterable, value, options); | ||
| } | ||
@@ -200,15 +212,67 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) { | ||
| if (!sharedConfig.has(expectedId)) return null; | ||
| const initP = sharedConfig.load(expectedId); | ||
| if (!isAsyncIterable(initP)) return null; | ||
| const [firstState, iter] = consumeFirstSync(initP); | ||
| const [store, setStore] = coreFn(() => {}, firstState ?? initialValue, options); | ||
| scheduleIteratorConsumption(iter, patches => { | ||
| setStore(d => { | ||
| applyPatches(d, patches); | ||
| }); | ||
| }); | ||
| return [store, setStore]; | ||
| const loaded = sharedConfig.load(expectedId); | ||
| if (!isAsyncIterable(loaded)) return null; | ||
| const srcIt = loaded[Symbol.asyncIterator](); | ||
| let isFirst = true; | ||
| let buffered = null; | ||
| return coreFn(draft => { | ||
| const process = res => { | ||
| if (res.done) return { | ||
| done: true, | ||
| value: undefined | ||
| }; | ||
| if (isFirst) { | ||
| isFirst = false; | ||
| if (Array.isArray(res.value)) { | ||
| for (let i = 0; i < res.value.length; i++) draft[i] = res.value[i]; | ||
| draft.length = res.value.length; | ||
| } else { | ||
| Object.assign(draft, res.value); | ||
| } | ||
| } else { | ||
| applyPatches(draft, res.value); | ||
| } | ||
| return { | ||
| done: false, | ||
| value: undefined | ||
| }; | ||
| }; | ||
| return { | ||
| [Symbol.asyncIterator]() { | ||
| return { | ||
| next() { | ||
| if (isFirst) { | ||
| const r = srcIt.next(); | ||
| return r && typeof r.then === "function" ? r.then(process) : syncThenable(process(r)); | ||
| } | ||
| if (buffered) { | ||
| const b = buffered; | ||
| buffered = null; | ||
| return b.then(process); | ||
| } | ||
| let r = srcIt.next(); | ||
| if (r && typeof r.then === "function") { | ||
| return r.then(process); | ||
| } | ||
| let result = process(r); | ||
| while (!r.done) { | ||
| const peek = srcIt.next(); | ||
| if (peek && typeof peek.then === "function") { | ||
| buffered = peek; | ||
| break; | ||
| } | ||
| r = peek; | ||
| if (!r.done) result = process(r); | ||
| } | ||
| return Promise.resolve(result); | ||
| } | ||
| }; | ||
| } | ||
| }; | ||
| }, initialValue, options); | ||
| } | ||
| function hydratedCreateMemo(compute, value, options) { | ||
| if (!sharedConfig.hydrating) return signals.createMemo(compute, value, options); | ||
| if (!sharedConfig.hydrating) { | ||
| return signals.createMemo(compute, value, options); | ||
| } | ||
| markTopLevelSnapshotScope(); | ||
@@ -365,3 +429,5 @@ const ssrSource = options?.ssrSource; | ||
| function hydratedCreateProjection(fn, initialValue, options) { | ||
| if (!sharedConfig.hydrating) return signals.createProjection(fn, initialValue, options); | ||
| if (!sharedConfig.hydrating) { | ||
| return signals.createProjection(fn, initialValue, options); | ||
| } | ||
| markTopLevelSnapshotScope(); | ||
@@ -372,4 +438,4 @@ const ssrSource = options?.ssrSource; | ||
| } | ||
| const aiResult = hydrateStoreFromAsyncIterable(signals.createStore, initialValue, options); | ||
| if (aiResult !== null) return aiResult[0]; | ||
| const aiResult = hydrateStoreFromAsyncIterable(signals.createProjection, initialValue, options); | ||
| if (aiResult !== null) return aiResult; | ||
| return signals.createProjection(wrapStoreFn(fn, ssrSource), initialValue, options); | ||
@@ -647,11 +713,6 @@ } | ||
| const fn = typeof child === "function" && child.length > 0; | ||
| return fn ? signals.untrack(() => { | ||
| try { | ||
| return child(() => { | ||
| if (!signals.untrack(condition)) throw narrowedError("Show"); | ||
| return conditionValue(); | ||
| }); | ||
| } finally { | ||
| } | ||
| }) : child; | ||
| return fn ? signals.untrack(() => child(() => { | ||
| if (!signals.untrack(condition)) throw narrowedError("Show"); | ||
| return conditionValue(); | ||
| }), IS_DEV) : child; | ||
| } | ||
@@ -684,11 +745,6 @@ return props.fallback; | ||
| const fn = typeof child === "function" && child.length > 0; | ||
| return fn ? signals.untrack(() => { | ||
| try { | ||
| return child(() => { | ||
| if (signals.untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match"); | ||
| return conditionValue(); | ||
| }); | ||
| } finally { | ||
| } | ||
| }) : child; | ||
| return fn ? signals.untrack(() => child(() => { | ||
| if (signals.untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match"); | ||
| return conditionValue(); | ||
| }), IS_DEV) : child; | ||
| }, undefined, undefined); | ||
@@ -714,2 +770,6 @@ } | ||
| }); | ||
| Object.defineProperty(exports, "$REFRESH", { | ||
| enumerable: true, | ||
| get: function () { return signals.$REFRESH; } | ||
| }); | ||
| Object.defineProperty(exports, "$TRACK", { | ||
@@ -827,2 +887,6 @@ enumerable: true, | ||
| }); | ||
| Object.defineProperty(exports, "setOnUnhandledAsync", { | ||
| enumerable: true, | ||
| get: function () { return signals.setOnUnhandledAsync; } | ||
| }); | ||
| Object.defineProperty(exports, "snapshot", { | ||
@@ -829,0 +893,0 @@ enumerable: true, |
+122
-66
| 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'; | ||
| 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'; | ||
| 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'; | ||
| const IS_DEV = false; | ||
| const $DEVCOMP = Symbol(0); | ||
@@ -134,8 +135,38 @@ function createContext(defaultValue, options) { | ||
| } | ||
| function consumeFirstSync(ai) { | ||
| const iter = ai[Symbol.asyncIterator](); | ||
| const r = iter.next(); | ||
| const value = !(r instanceof Promise) && !r.done ? r.value : undefined; | ||
| return [value, iter]; | ||
| function syncThenable(value) { | ||
| return { | ||
| then(fn) { | ||
| fn(value); | ||
| } | ||
| }; | ||
| } | ||
| function normalizeIterator(it) { | ||
| let first = true; | ||
| let buffered = null; | ||
| return { | ||
| next() { | ||
| if (first) { | ||
| first = false; | ||
| const r = it.next(); | ||
| return r && typeof r.then === "function" ? r : syncThenable(r); | ||
| } | ||
| if (buffered) { | ||
| const b = buffered; | ||
| buffered = null; | ||
| return b; | ||
| } | ||
| let latest = it.next(); | ||
| if (latest && typeof latest.then === "function") return latest; | ||
| while (!latest.done) { | ||
| const peek = it.next(); | ||
| if (peek && typeof peek.then === "function") { | ||
| buffered = peek; | ||
| break; | ||
| } | ||
| latest = peek; | ||
| } | ||
| return Promise.resolve(latest); | ||
| } | ||
| }; | ||
| } | ||
| function applyPatches(target, patches) { | ||
@@ -156,20 +187,2 @@ for (const patch of patches) { | ||
| } | ||
| function scheduleIteratorConsumption(iter, apply) { | ||
| const consume = () => { | ||
| while (true) { | ||
| const n = iter.next(); | ||
| if (n instanceof Promise) { | ||
| n.then(r => { | ||
| if (r.done) return; | ||
| apply(r.value); | ||
| consume(); | ||
| }); | ||
| return; | ||
| } | ||
| if (n.done) break; | ||
| apply(n.value); | ||
| } | ||
| }; | ||
| consume(); | ||
| } | ||
| function isAsyncIterable(v) { | ||
@@ -182,12 +195,11 @@ return v != null && typeof v[Symbol.asyncIterator] === "function"; | ||
| if (!sharedConfig.has(expectedId)) return null; | ||
| const initP = sharedConfig.load(expectedId); | ||
| if (!isAsyncIterable(initP)) return null; | ||
| const [firstValue, iter] = consumeFirstSync(initP); | ||
| const [get, set] = createSignal$1(firstValue); | ||
| const result = coreFn(() => get(), firstValue, options); | ||
| scheduleIteratorConsumption(iter, v => { | ||
| set(() => v); | ||
| flush(); | ||
| }); | ||
| return result; | ||
| const loaded = sharedConfig.load(expectedId); | ||
| if (!isAsyncIterable(loaded)) return null; | ||
| const it = normalizeIterator(loaded[Symbol.asyncIterator]()); | ||
| const iterable = { | ||
| [Symbol.asyncIterator]() { | ||
| return it; | ||
| } | ||
| }; | ||
| return coreFn(() => iterable, value, options); | ||
| } | ||
@@ -198,15 +210,67 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) { | ||
| if (!sharedConfig.has(expectedId)) return null; | ||
| const initP = sharedConfig.load(expectedId); | ||
| if (!isAsyncIterable(initP)) return null; | ||
| const [firstState, iter] = consumeFirstSync(initP); | ||
| const [store, setStore] = coreFn(() => {}, firstState ?? initialValue, options); | ||
| scheduleIteratorConsumption(iter, patches => { | ||
| setStore(d => { | ||
| applyPatches(d, patches); | ||
| }); | ||
| }); | ||
| return [store, setStore]; | ||
| const loaded = sharedConfig.load(expectedId); | ||
| if (!isAsyncIterable(loaded)) return null; | ||
| const srcIt = loaded[Symbol.asyncIterator](); | ||
| let isFirst = true; | ||
| let buffered = null; | ||
| return coreFn(draft => { | ||
| const process = res => { | ||
| if (res.done) return { | ||
| done: true, | ||
| value: undefined | ||
| }; | ||
| if (isFirst) { | ||
| isFirst = false; | ||
| if (Array.isArray(res.value)) { | ||
| for (let i = 0; i < res.value.length; i++) draft[i] = res.value[i]; | ||
| draft.length = res.value.length; | ||
| } else { | ||
| Object.assign(draft, res.value); | ||
| } | ||
| } else { | ||
| applyPatches(draft, res.value); | ||
| } | ||
| return { | ||
| done: false, | ||
| value: undefined | ||
| }; | ||
| }; | ||
| return { | ||
| [Symbol.asyncIterator]() { | ||
| return { | ||
| next() { | ||
| if (isFirst) { | ||
| const r = srcIt.next(); | ||
| return r && typeof r.then === "function" ? r.then(process) : syncThenable(process(r)); | ||
| } | ||
| if (buffered) { | ||
| const b = buffered; | ||
| buffered = null; | ||
| return b.then(process); | ||
| } | ||
| let r = srcIt.next(); | ||
| if (r && typeof r.then === "function") { | ||
| return r.then(process); | ||
| } | ||
| let result = process(r); | ||
| while (!r.done) { | ||
| const peek = srcIt.next(); | ||
| if (peek && typeof peek.then === "function") { | ||
| buffered = peek; | ||
| break; | ||
| } | ||
| r = peek; | ||
| if (!r.done) result = process(r); | ||
| } | ||
| return Promise.resolve(result); | ||
| } | ||
| }; | ||
| } | ||
| }; | ||
| }, initialValue, options); | ||
| } | ||
| function hydratedCreateMemo(compute, value, options) { | ||
| if (!sharedConfig.hydrating) return createMemo$1(compute, value, options); | ||
| if (!sharedConfig.hydrating) { | ||
| return createMemo$1(compute, value, options); | ||
| } | ||
| markTopLevelSnapshotScope(); | ||
@@ -363,3 +427,5 @@ const ssrSource = options?.ssrSource; | ||
| function hydratedCreateProjection(fn, initialValue, options) { | ||
| if (!sharedConfig.hydrating) return createProjection$1(fn, initialValue, options); | ||
| if (!sharedConfig.hydrating) { | ||
| return createProjection$1(fn, initialValue, options); | ||
| } | ||
| markTopLevelSnapshotScope(); | ||
@@ -370,4 +436,4 @@ const ssrSource = options?.ssrSource; | ||
| } | ||
| const aiResult = hydrateStoreFromAsyncIterable(createStore$1, initialValue, options); | ||
| if (aiResult !== null) return aiResult[0]; | ||
| const aiResult = hydrateStoreFromAsyncIterable(createProjection$1, initialValue, options); | ||
| if (aiResult !== null) return aiResult; | ||
| return createProjection$1(wrapStoreFn(fn, ssrSource), initialValue, options); | ||
@@ -645,11 +711,6 @@ } | ||
| const fn = typeof child === "function" && child.length > 0; | ||
| return fn ? untrack(() => { | ||
| try { | ||
| return child(() => { | ||
| if (!untrack(condition)) throw narrowedError("Show"); | ||
| return conditionValue(); | ||
| }); | ||
| } finally { | ||
| } | ||
| }) : child; | ||
| return fn ? untrack(() => child(() => { | ||
| if (!untrack(condition)) throw narrowedError("Show"); | ||
| return conditionValue(); | ||
| }), IS_DEV) : child; | ||
| } | ||
@@ -682,11 +743,6 @@ return props.fallback; | ||
| const fn = typeof child === "function" && child.length > 0; | ||
| return fn ? untrack(() => { | ||
| try { | ||
| return child(() => { | ||
| if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match"); | ||
| return conditionValue(); | ||
| }); | ||
| } finally { | ||
| } | ||
| }) : child; | ||
| return fn ? untrack(() => child(() => { | ||
| if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match"); | ||
| return conditionValue(); | ||
| }), IS_DEV) : child; | ||
| }, undefined, undefined); | ||
@@ -693,0 +749,0 @@ } |
+2
-2
| { | ||
| "name": "solid-js", | ||
| "description": "A declarative JavaScript library for building user interfaces.", | ||
| "version": "2.0.0-beta.1", | ||
| "version": "2.0.0-beta.2", | ||
| "author": "Ryan Carniato", | ||
@@ -82,3 +82,3 @@ "license": "MIT", | ||
| "dependencies": { | ||
| "@solidjs/signals": "^0.11.3", | ||
| "@solidjs/signals": "^0.12.0", | ||
| "csstype": "^3.1.0", | ||
@@ -85,0 +85,0 @@ "seroval": "~1.5.0", |
@@ -1,2 +0,2 @@ | ||
| 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"; | ||
| 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"; | ||
| import { JSX } from "../jsx.js"; | ||
@@ -50,11 +50,17 @@ declare module "@solidjs/signals" { | ||
| export declare const createOptimistic: typeof coreOptimistic; | ||
| export declare const createProjection: <T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue?: T, options?: HydrationProjectionOptions) => Store<T>; | ||
| export declare const createProjection: <T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue?: T, options?: HydrationProjectionOptions) => Store<T> & { | ||
| [$REFRESH]: any; | ||
| }; | ||
| type NoFn<T> = T extends Function ? never : T; | ||
| export declare const createStore: { | ||
| <T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>): [get: Store<T>, set: StoreSetter<T>]; | ||
| <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>, set: StoreSetter<T>]; | ||
| <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> & { | ||
| [$REFRESH]: any; | ||
| }, set: StoreSetter<T>]; | ||
| }; | ||
| export declare const createOptimisticStore: { | ||
| <T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>): [get: Store<T>, set: StoreSetter<T>]; | ||
| <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>, set: StoreSetter<T>]; | ||
| <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> & { | ||
| [$REFRESH]: any; | ||
| }, set: StoreSetter<T>]; | ||
| }; | ||
@@ -61,0 +67,0 @@ export declare const createRenderEffect: typeof coreRenderEffect; |
+1
-1
@@ -1,2 +0,2 @@ | ||
| 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"; | ||
| 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"; | ||
| 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,0 +3,0 @@ export { $DEVCOMP, children, createContext, useContext } from "./client/core.js"; |
@@ -1,2 +0,2 @@ | ||
| 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"; | ||
| 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"; | ||
| 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,0 +3,0 @@ export { $DEVCOMP, children, createContext, useContext, ssrRunInScope } from "./core.js"; |
@@ -1,4 +0,4 @@ | ||
| export { createRoot, createOwner, runWithOwner, getOwner, onCleanup, getNextChildId, createContext, setContext, getContext, NotReadyError, NoOwnerError, ContextNotFoundError, isEqual, isWrappable, SUPPORTS_PROXY } from "@solidjs/signals"; | ||
| export { createRoot, createOwner, runWithOwner, getOwner, onCleanup, getNextChildId, createContext, setContext, getContext, NotReadyError, NoOwnerError, ContextNotFoundError, isEqual, isWrappable, SUPPORTS_PROXY, setOnUnhandledAsync } from "@solidjs/signals"; | ||
| export { flatten } from "@solidjs/signals"; | ||
| export { snapshot, merge, omit, storePath, $PROXY, $TRACK } from "@solidjs/signals"; | ||
| export { snapshot, merge, omit, storePath, $PROXY, $REFRESH, $TRACK } from "@solidjs/signals"; | ||
| 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,0 +5,0 @@ import type { Accessor, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, MemoOptions, SignalOptions, Signal, Owner, Store, StoreSetter, Context } from "@solidjs/signals"; |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
377957
1.47%9829
2.14%+ Added
- Removed
Updated