+73
-16
@@ -22,9 +22,12 @@ 'use strict'; | ||
| function children(fn) { | ||
| const children = signals.createMemo(fn); | ||
| const memo = signals.createMemo(() => signals.flatten(children()), undefined, { | ||
| name: "children" | ||
| }) ; | ||
| const c = signals.createMemo(fn, undefined, { | ||
| lazy: true | ||
| }); | ||
| const memo = signals.createMemo(() => signals.flatten(c()), undefined, { | ||
| name: "children", | ||
| lazy: true | ||
| } ); | ||
| memo.toArray = () => { | ||
| const c = memo(); | ||
| return Array.isArray(c) ? c : c != null ? [c] : []; | ||
| const v = memo(); | ||
| return Array.isArray(v) ? v : v != null ? [v] : []; | ||
| }; | ||
@@ -94,2 +97,3 @@ return memo; | ||
| setTimeout(() => { | ||
| if (sharedConfig.verifyHydration) sharedConfig.verifyHydration(); | ||
| if (globalThis._$HY) globalThis._$HY.done = true; | ||
@@ -110,2 +114,4 @@ }); | ||
| let _createOptimisticStore; | ||
| let _createRenderEffect; | ||
| let _createEffect; | ||
| class MockPromise { | ||
@@ -391,2 +397,43 @@ static all() { | ||
| } | ||
| function hydratedEffect(coreFn, compute, effectFn, value, options) { | ||
| if (!sharedConfig.hydrating) return coreFn(compute, effectFn, value, options); | ||
| const ssrSource = options?.ssrSource; | ||
| if (ssrSource === "client") { | ||
| const [hydrated, setHydrated] = signals.createSignal(false); | ||
| let active = false; | ||
| coreFn(prev => { | ||
| if (!hydrated()) return value; | ||
| active = true; | ||
| return compute(prev); | ||
| }, (next, prev) => { | ||
| if (!active) return; | ||
| return effectFn(next, prev); | ||
| }, value, options); | ||
| setHydrated(true); | ||
| return; | ||
| } | ||
| if (ssrSource === "initial") { | ||
| coreFn(prev => { | ||
| if (!sharedConfig.hydrating) return compute(prev); | ||
| subFetch(compute, prev); | ||
| return prev ?? value; | ||
| }, effectFn, value, options); | ||
| return; | ||
| } | ||
| markTopLevelSnapshotScope(); | ||
| coreFn(prev => { | ||
| const o = signals.getOwner(); | ||
| if (!sharedConfig.hydrating) return compute(prev); | ||
| let initP; | ||
| if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id); | ||
| const init = initP?.v ?? initP; | ||
| return init != null ? (subFetch(compute, prev), init) : compute(prev); | ||
| }, effectFn, value, options); | ||
| } | ||
| function hydratedCreateRenderEffect(compute, effectFn, value, options) { | ||
| return hydratedEffect(signals.createRenderEffect, compute, effectFn, value, options); | ||
| } | ||
| function hydratedCreateEffect(compute, effectFn, value, options) { | ||
| return hydratedEffect(signals.createEffect, compute, effectFn, value, options); | ||
| } | ||
| function enableHydration() { | ||
@@ -400,2 +447,4 @@ _createMemo = hydratedCreateMemo; | ||
| _createOptimisticStore = hydratedCreateOptimisticStore; | ||
| _createRenderEffect = hydratedCreateRenderEffect; | ||
| _createEffect = hydratedCreateEffect; | ||
| _hydratingValue = sharedConfig.hydrating; | ||
@@ -446,2 +495,4 @@ _doneValue = sharedConfig.done; | ||
| const createOptimisticStore = (...args) => (_createOptimisticStore || signals.createOptimisticStore)(...args); | ||
| const createRenderEffect = (...args) => (_createRenderEffect || signals.createRenderEffect)(...args); | ||
| const createEffect = (...args) => (_createEffect || signals.createEffect)(...args); | ||
| function loadModuleAssets(mapping) { | ||
@@ -711,5 +762,5 @@ const hy = globalThis._$HY; | ||
| }); | ||
| Object.defineProperty(exports, "createEffect", { | ||
| Object.defineProperty(exports, "createOwner", { | ||
| enumerable: true, | ||
| get: function () { return signals.createEffect; } | ||
| get: function () { return signals.createOwner; } | ||
| }); | ||
@@ -720,6 +771,2 @@ Object.defineProperty(exports, "createReaction", { | ||
| }); | ||
| Object.defineProperty(exports, "createRenderEffect", { | ||
| enumerable: true, | ||
| get: function () { return signals.createRenderEffect; } | ||
| }); | ||
| Object.defineProperty(exports, "createRoot", { | ||
@@ -745,2 +792,6 @@ enumerable: true, | ||
| }); | ||
| Object.defineProperty(exports, "getNextChildId", { | ||
| enumerable: true, | ||
| get: function () { return signals.getNextChildId; } | ||
| }); | ||
| Object.defineProperty(exports, "getObserver", { | ||
@@ -770,2 +821,6 @@ enumerable: true, | ||
| }); | ||
| Object.defineProperty(exports, "latest", { | ||
| enumerable: true, | ||
| get: function () { return signals.latest; } | ||
| }); | ||
| Object.defineProperty(exports, "mapArray", { | ||
@@ -791,6 +846,2 @@ enumerable: true, | ||
| }); | ||
| Object.defineProperty(exports, "pending", { | ||
| enumerable: true, | ||
| get: function () { return signals.pending; } | ||
| }); | ||
| Object.defineProperty(exports, "reconcile", { | ||
@@ -820,2 +871,6 @@ enumerable: true, | ||
| }); | ||
| Object.defineProperty(exports, "storePath", { | ||
| enumerable: true, | ||
| get: function () { return signals.storePath; } | ||
| }); | ||
| Object.defineProperty(exports, "untrack", { | ||
@@ -837,2 +892,3 @@ enumerable: true, | ||
| exports.createContext = createContext; | ||
| exports.createEffect = createEffect; | ||
| exports.createMemo = createMemo; | ||
@@ -842,2 +898,3 @@ exports.createOptimistic = createOptimistic; | ||
| exports.createProjection = createProjection; | ||
| exports.createRenderEffect = createRenderEffect; | ||
| exports.createSignal = createSignal; | ||
@@ -844,0 +901,0 @@ exports.createStore = createStore; |
+60
-9
@@ -1,3 +0,3 @@ | ||
| import { getContext, createMemo as createMemo$1, flatten, getOwner, createRoot, setContext, untrack, setStrictRead, createLoadBoundary, onCleanup, isDisposed, runWithOwner, createOptimistic as createOptimistic$1, createOptimisticStore as createOptimisticStore$1, createProjection as createProjection$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, createEffect, createReaction, createRenderEffect, createRoot, createTrackedEffect, deep, flatten, flush, getObserver, getOwner, isEqual, isPending, isRefreshing, isWrappable, mapArray, merge, omit, onCleanup, onSettled, pending, reconcile, refresh, repeat, resolve, runWithOwner, snapshot, untrack } from '@solidjs/signals'; | ||
| import { getContext, createMemo as createMemo$1, flatten, getOwner, createRoot, setContext, untrack, setStrictRead, createLoadBoundary, onCleanup, isDisposed, runWithOwner, 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'; | ||
@@ -21,9 +21,12 @@ const $DEVCOMP = Symbol("COMPONENT_DEV" ); | ||
| function children(fn) { | ||
| const children = createMemo$1(fn); | ||
| const memo = createMemo$1(() => flatten(children()), undefined, { | ||
| name: "children" | ||
| }) ; | ||
| const c = createMemo$1(fn, undefined, { | ||
| lazy: true | ||
| }); | ||
| const memo = createMemo$1(() => flatten(c()), undefined, { | ||
| name: "children", | ||
| lazy: true | ||
| } ); | ||
| memo.toArray = () => { | ||
| const c = memo(); | ||
| return Array.isArray(c) ? c : c != null ? [c] : []; | ||
| const v = memo(); | ||
| return Array.isArray(v) ? v : v != null ? [v] : []; | ||
| }; | ||
@@ -93,2 +96,3 @@ return memo; | ||
| setTimeout(() => { | ||
| if (sharedConfig.verifyHydration) sharedConfig.verifyHydration(); | ||
| if (globalThis._$HY) globalThis._$HY.done = true; | ||
@@ -109,2 +113,4 @@ }); | ||
| let _createOptimisticStore; | ||
| let _createRenderEffect; | ||
| let _createEffect; | ||
| class MockPromise { | ||
@@ -390,2 +396,43 @@ static all() { | ||
| } | ||
| function hydratedEffect(coreFn, compute, effectFn, value, options) { | ||
| if (!sharedConfig.hydrating) return coreFn(compute, effectFn, value, options); | ||
| const ssrSource = options?.ssrSource; | ||
| if (ssrSource === "client") { | ||
| const [hydrated, setHydrated] = createSignal$1(false); | ||
| let active = false; | ||
| coreFn(prev => { | ||
| if (!hydrated()) return value; | ||
| active = true; | ||
| return compute(prev); | ||
| }, (next, prev) => { | ||
| if (!active) return; | ||
| return effectFn(next, prev); | ||
| }, value, options); | ||
| setHydrated(true); | ||
| return; | ||
| } | ||
| if (ssrSource === "initial") { | ||
| coreFn(prev => { | ||
| if (!sharedConfig.hydrating) return compute(prev); | ||
| subFetch(compute, prev); | ||
| return prev ?? value; | ||
| }, effectFn, value, options); | ||
| return; | ||
| } | ||
| markTopLevelSnapshotScope(); | ||
| coreFn(prev => { | ||
| const o = getOwner(); | ||
| if (!sharedConfig.hydrating) return compute(prev); | ||
| let initP; | ||
| if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id); | ||
| const init = initP?.v ?? initP; | ||
| return init != null ? (subFetch(compute, prev), init) : compute(prev); | ||
| }, effectFn, value, options); | ||
| } | ||
| function hydratedCreateRenderEffect(compute, effectFn, value, options) { | ||
| return hydratedEffect(createRenderEffect$1, compute, effectFn, value, options); | ||
| } | ||
| function hydratedCreateEffect(compute, effectFn, value, options) { | ||
| return hydratedEffect(createEffect$1, compute, effectFn, value, options); | ||
| } | ||
| function enableHydration() { | ||
@@ -399,2 +446,4 @@ _createMemo = hydratedCreateMemo; | ||
| _createOptimisticStore = hydratedCreateOptimisticStore; | ||
| _createRenderEffect = hydratedCreateRenderEffect; | ||
| _createEffect = hydratedCreateEffect; | ||
| _hydratingValue = sharedConfig.hydrating; | ||
@@ -445,2 +494,4 @@ _doneValue = sharedConfig.done; | ||
| const createOptimisticStore = (...args) => (_createOptimisticStore || createOptimisticStore$1)(...args); | ||
| const createRenderEffect = (...args) => (_createRenderEffect || createRenderEffect$1)(...args); | ||
| const createEffect = (...args) => (_createEffect || createEffect$1)(...args); | ||
| function loadModuleAssets(mapping) { | ||
@@ -694,2 +745,2 @@ const hy = globalThis._$HY; | ||
| export { $DEVCOMP, DEV, Errored, For, Loading, Match, Repeat, Show, Switch, children, createComponent, createContext, createMemo, createOptimistic, createOptimisticStore, createProjection, createSignal, createStore, createUniqueId, enableHydration, lazy, sharedConfig, ssrHandleError, ssrRunInScope, useContext }; | ||
| export { $DEVCOMP, DEV, Errored, For, Loading, Match, Repeat, Show, Switch, children, createComponent, createContext, createEffect, createMemo, createOptimistic, createOptimisticStore, createProjection, createRenderEffect, createSignal, createStore, createUniqueId, enableHydration, lazy, sharedConfig, ssrHandleError, ssrRunInScope, useContext }; |
+86
-36
@@ -223,21 +223,38 @@ 'use strict'; | ||
| } | ||
| function createEffect(compute, effect, value, options) { | ||
| const o = signals.getOwner(); | ||
| if (o?.id != null) signals.getNextChildId(o); | ||
| } | ||
| function createRenderEffect(compute, effectFn, value, options) { | ||
| function serverEffect(compute, effectFn, value, options) { | ||
| const ssrSource = options?.ssrSource; | ||
| if (ssrSource === "client" || ssrSource === "initial") { | ||
| signals.createOwner(); | ||
| return; | ||
| } | ||
| const ctx = sharedConfig.context; | ||
| const owner = signals.createOwner(); | ||
| const comp = { | ||
| owner, | ||
| value: value, | ||
| compute: compute, | ||
| error: undefined, | ||
| computed: true, | ||
| disposed: false | ||
| }; | ||
| if (ssrSource) { | ||
| signals.runWithOwner(owner, () => signals.onCleanup(() => { | ||
| comp.disposed = true; | ||
| })); | ||
| } | ||
| try { | ||
| const result = signals.runWithOwner(owner, () => runWithObserver({ | ||
| owner, | ||
| value: value, | ||
| compute: compute, | ||
| error: undefined, | ||
| computed: true, | ||
| disposed: false | ||
| }, () => compute(value))); | ||
| effectFn(result, value); | ||
| const result = signals.runWithOwner(owner, () => runWithObserver(comp, () => compute(value))); | ||
| if (ssrSource) { | ||
| processResult(comp, result, owner, ctx, options?.deferStream, ssrSource); | ||
| } | ||
| effectFn?.(ssrSource ? comp.value ?? result : result, value); | ||
| } catch (err) { | ||
| } | ||
| } | ||
| function createEffect(compute, effect, value, options) { | ||
| serverEffect(compute, undefined, value, options); | ||
| } | ||
| function createRenderEffect(compute, effectFn, value, options) { | ||
| serverEffect(compute, effectFn, value, options); | ||
| } | ||
| function createTrackedEffect(compute, options) { | ||
@@ -438,2 +455,3 @@ const o = signals.getOwner(); | ||
| function repeat(count, mapFn, options = {}) { | ||
| const owner = signals.createOwner(); | ||
| const len = count(); | ||
@@ -443,4 +461,14 @@ const offset = options.from?.() || 0; | ||
| if (len) { | ||
| for (let i = 0; i < len; i++) s.push(mapFn(i + offset)); | ||
| } else if (options.fallback) s = [options.fallback()]; | ||
| signals.runWithOwner(owner, () => { | ||
| for (let i = 0; i < len; i++) { | ||
| const itemOwner = signals.createOwner(); | ||
| s.push(signals.runWithOwner(itemOwner, () => mapFn(i + offset))); | ||
| } | ||
| }); | ||
| } else if (options.fallback) { | ||
| s = [signals.runWithOwner(owner, () => { | ||
| const fo = signals.createOwner(); | ||
| return signals.runWithOwner(fo, () => options.fallback()); | ||
| })]; | ||
| } | ||
| return () => s; | ||
@@ -455,2 +483,5 @@ } | ||
| const owner = signals.createOwner(); | ||
| const parent = signals.getOwner(); | ||
| if (parent?.id != null) signals.getNextChildId(parent); | ||
| owner.id = owner.id + "0"; | ||
| return signals.runWithOwner(owner, () => { | ||
@@ -500,3 +531,3 @@ let result; | ||
| } | ||
| function pending(fn) { | ||
| function latest(fn) { | ||
| return fn(); | ||
@@ -535,7 +566,11 @@ } | ||
| function children(fn) { | ||
| const childrenMemo = createMemo(fn); | ||
| const memo = createMemo(() => signals.flatten(childrenMemo())); | ||
| const c = createMemo(fn, undefined, { | ||
| lazy: true | ||
| }); | ||
| const memo = createMemo(() => signals.flatten(c()), undefined, { | ||
| lazy: true | ||
| }); | ||
| memo.toArray = () => { | ||
| const c = memo(); | ||
| return Array.isArray(c) ? c : c != null ? [c] : []; | ||
| const v = memo(); | ||
| return Array.isArray(v) ? v : v != null ? [v] : []; | ||
| }; | ||
@@ -545,7 +580,3 @@ return memo; | ||
| function ssrRunInScope(fn) { | ||
| if (Array.isArray(fn)) { | ||
| const o = signals.createOwner(); | ||
| return fn.map(f => signals.runWithOwner.bind(null, o, f)); | ||
| } | ||
| return signals.runWithOwner.bind(null, signals.createOwner(), fn); | ||
| return fn; | ||
| } | ||
@@ -618,11 +649,18 @@ | ||
| function Show(props) { | ||
| const when = props.when; | ||
| if (when) { | ||
| const child = props.children; | ||
| if (typeof child === "function" && child.length > 0) { | ||
| return child(() => when); | ||
| const o = signals.getOwner(); | ||
| if (o?.id != null) { | ||
| signals.getNextChildId(o); | ||
| if (!props.keyed) signals.getNextChildId(o); | ||
| } | ||
| return createMemo(() => { | ||
| const when = props.when; | ||
| if (when) { | ||
| const child = props.children; | ||
| if (typeof child === "function" && child.length > 0) { | ||
| return child(() => when); | ||
| } | ||
| return child; | ||
| } | ||
| return child; | ||
| } | ||
| return props.fallback; | ||
| return props.fallback; | ||
| }); | ||
| } | ||
@@ -632,3 +670,3 @@ function Switch(props) { | ||
| const o = signals.getOwner(); | ||
| if (o) signals.getNextChildId(o); | ||
| if (o?.id != null) signals.getNextChildId(o); | ||
| return createMemo(() => { | ||
@@ -755,2 +793,6 @@ let conds = chs(); | ||
| }); | ||
| Object.defineProperty(exports, "createOwner", { | ||
| enumerable: true, | ||
| get: function () { return signals.createOwner; } | ||
| }); | ||
| Object.defineProperty(exports, "createRoot", { | ||
@@ -764,2 +806,6 @@ enumerable: true, | ||
| }); | ||
| Object.defineProperty(exports, "getNextChildId", { | ||
| enumerable: true, | ||
| get: function () { return signals.getNextChildId; } | ||
| }); | ||
| Object.defineProperty(exports, "getOwner", { | ||
@@ -797,2 +843,6 @@ enumerable: true, | ||
| }); | ||
| Object.defineProperty(exports, "storePath", { | ||
| enumerable: true, | ||
| get: function () { return signals.storePath; } | ||
| }); | ||
| exports.$DEVCOMP = $DEVCOMP; | ||
@@ -829,6 +879,6 @@ exports.DEV = DEV; | ||
| exports.isRefreshing = isRefreshing; | ||
| exports.latest = latest; | ||
| exports.lazy = lazy; | ||
| exports.mapArray = mapArray; | ||
| exports.onSettled = onSettled; | ||
| exports.pending = pending; | ||
| exports.reconcile = reconcile; | ||
@@ -835,0 +885,0 @@ exports.refresh = refresh; |
+76
-38
@@ -1,3 +0,3 @@ | ||
| import { getOwner, getNextChildId, createOwner, runWithOwner, onCleanup, NotReadyError, isWrappable, setContext, getContext, createRoot, flatten } from '@solidjs/signals'; | ||
| export { $PROXY, $TRACK, NotReadyError, createRoot, flatten, getOwner, isEqual, isWrappable, merge, omit, onCleanup, runWithOwner, snapshot } from '@solidjs/signals'; | ||
| import { getOwner, getNextChildId, createOwner, runWithOwner, onCleanup, NotReadyError, isWrappable, setContext, getContext, 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'; | ||
@@ -222,21 +222,38 @@ const sharedConfig = { | ||
| } | ||
| function createEffect(compute, effect, value, options) { | ||
| const o = getOwner(); | ||
| if (o?.id != null) getNextChildId(o); | ||
| } | ||
| function createRenderEffect(compute, effectFn, value, options) { | ||
| function serverEffect(compute, effectFn, value, options) { | ||
| const ssrSource = options?.ssrSource; | ||
| if (ssrSource === "client" || ssrSource === "initial") { | ||
| createOwner(); | ||
| return; | ||
| } | ||
| const ctx = sharedConfig.context; | ||
| const owner = createOwner(); | ||
| const comp = { | ||
| owner, | ||
| value: value, | ||
| compute: compute, | ||
| error: undefined, | ||
| computed: true, | ||
| disposed: false | ||
| }; | ||
| if (ssrSource) { | ||
| runWithOwner(owner, () => onCleanup(() => { | ||
| comp.disposed = true; | ||
| })); | ||
| } | ||
| try { | ||
| const result = runWithOwner(owner, () => runWithObserver({ | ||
| owner, | ||
| value: value, | ||
| compute: compute, | ||
| error: undefined, | ||
| computed: true, | ||
| disposed: false | ||
| }, () => compute(value))); | ||
| effectFn(result, value); | ||
| const result = runWithOwner(owner, () => runWithObserver(comp, () => compute(value))); | ||
| if (ssrSource) { | ||
| processResult(comp, result, owner, ctx, options?.deferStream, ssrSource); | ||
| } | ||
| effectFn?.(ssrSource ? comp.value ?? result : result, value); | ||
| } catch (err) { | ||
| } | ||
| } | ||
| function createEffect(compute, effect, value, options) { | ||
| serverEffect(compute, undefined, value, options); | ||
| } | ||
| function createRenderEffect(compute, effectFn, value, options) { | ||
| serverEffect(compute, effectFn, value, options); | ||
| } | ||
| function createTrackedEffect(compute, options) { | ||
@@ -437,2 +454,3 @@ const o = getOwner(); | ||
| function repeat(count, mapFn, options = {}) { | ||
| const owner = createOwner(); | ||
| const len = count(); | ||
@@ -442,4 +460,14 @@ const offset = options.from?.() || 0; | ||
| if (len) { | ||
| for (let i = 0; i < len; i++) s.push(mapFn(i + offset)); | ||
| } else if (options.fallback) s = [options.fallback()]; | ||
| runWithOwner(owner, () => { | ||
| for (let i = 0; i < len; i++) { | ||
| const itemOwner = createOwner(); | ||
| s.push(runWithOwner(itemOwner, () => mapFn(i + offset))); | ||
| } | ||
| }); | ||
| } else if (options.fallback) { | ||
| s = [runWithOwner(owner, () => { | ||
| const fo = createOwner(); | ||
| return runWithOwner(fo, () => options.fallback()); | ||
| })]; | ||
| } | ||
| return () => s; | ||
@@ -454,2 +482,5 @@ } | ||
| const owner = createOwner(); | ||
| const parent = getOwner(); | ||
| if (parent?.id != null) getNextChildId(parent); | ||
| owner.id = owner.id + "0"; | ||
| return runWithOwner(owner, () => { | ||
@@ -499,3 +530,3 @@ let result; | ||
| } | ||
| function pending(fn) { | ||
| function latest(fn) { | ||
| return fn(); | ||
@@ -534,7 +565,11 @@ } | ||
| function children(fn) { | ||
| const childrenMemo = createMemo(fn); | ||
| const memo = createMemo(() => flatten(childrenMemo())); | ||
| const c = createMemo(fn, undefined, { | ||
| lazy: true | ||
| }); | ||
| const memo = createMemo(() => flatten(c()), undefined, { | ||
| lazy: true | ||
| }); | ||
| memo.toArray = () => { | ||
| const c = memo(); | ||
| return Array.isArray(c) ? c : c != null ? [c] : []; | ||
| const v = memo(); | ||
| return Array.isArray(v) ? v : v != null ? [v] : []; | ||
| }; | ||
@@ -544,7 +579,3 @@ return memo; | ||
| function ssrRunInScope(fn) { | ||
| if (Array.isArray(fn)) { | ||
| const o = createOwner(); | ||
| return fn.map(f => runWithOwner.bind(null, o, f)); | ||
| } | ||
| return runWithOwner.bind(null, createOwner(), fn); | ||
| return fn; | ||
| } | ||
@@ -617,11 +648,18 @@ | ||
| function Show(props) { | ||
| const when = props.when; | ||
| if (when) { | ||
| const child = props.children; | ||
| if (typeof child === "function" && child.length > 0) { | ||
| return child(() => when); | ||
| const o = getOwner(); | ||
| if (o?.id != null) { | ||
| getNextChildId(o); | ||
| if (!props.keyed) getNextChildId(o); | ||
| } | ||
| return createMemo(() => { | ||
| const when = props.when; | ||
| if (when) { | ||
| const child = props.children; | ||
| if (typeof child === "function" && child.length > 0) { | ||
| return child(() => when); | ||
| } | ||
| return child; | ||
| } | ||
| return child; | ||
| } | ||
| return props.fallback; | ||
| return props.fallback; | ||
| }); | ||
| } | ||
@@ -631,3 +669,3 @@ function Switch(props) { | ||
| const o = getOwner(); | ||
| if (o) getNextChildId(o); | ||
| if (o?.id != null) getNextChildId(o); | ||
| return createMemo(() => { | ||
@@ -742,2 +780,2 @@ let conds = chs(); | ||
| export { $DEVCOMP, DEV, Errored, For, Loading, Match, Repeat, Show, Switch, action, children, createComponent, createContext, createDeepProxy, createEffect, createMemo, createOptimistic, createOptimisticStore, createProjection, createReaction, createRenderEffect, createSignal, createStore, createTrackedEffect, createUniqueId, deep, enableHydration, flush, getObserver, isPending, isRefreshing, lazy, mapArray, onSettled, pending, reconcile, refresh, repeat, resolve, sharedConfig, ssrHandleError, ssrRunInScope, untrack, useContext }; | ||
| export { $DEVCOMP, DEV, Errored, For, Loading, Match, Repeat, Show, Switch, action, children, createComponent, createContext, createDeepProxy, createEffect, createMemo, createOptimistic, createOptimisticStore, createProjection, createReaction, createRenderEffect, createSignal, createStore, createTrackedEffect, createUniqueId, deep, enableHydration, flush, getObserver, isPending, isRefreshing, latest, lazy, mapArray, onSettled, reconcile, refresh, repeat, resolve, sharedConfig, ssrHandleError, ssrRunInScope, untrack, useContext }; |
+71
-14
@@ -22,7 +22,11 @@ 'use strict'; | ||
| function children(fn) { | ||
| const children = signals.createMemo(fn); | ||
| const memo = signals.createMemo(() => signals.flatten(children())); | ||
| const c = signals.createMemo(fn, undefined, { | ||
| lazy: true | ||
| }); | ||
| const memo = signals.createMemo(() => signals.flatten(c()), undefined, { | ||
| lazy: true | ||
| }); | ||
| memo.toArray = () => { | ||
| const c = memo(); | ||
| return Array.isArray(c) ? c : c != null ? [c] : []; | ||
| const v = memo(); | ||
| return Array.isArray(v) ? v : v != null ? [v] : []; | ||
| }; | ||
@@ -80,2 +84,4 @@ return memo; | ||
| let _createOptimisticStore; | ||
| let _createRenderEffect; | ||
| let _createEffect; | ||
| class MockPromise { | ||
@@ -361,2 +367,43 @@ static all() { | ||
| } | ||
| function hydratedEffect(coreFn, compute, effectFn, value, options) { | ||
| if (!sharedConfig.hydrating) return coreFn(compute, effectFn, value, options); | ||
| const ssrSource = options?.ssrSource; | ||
| if (ssrSource === "client") { | ||
| const [hydrated, setHydrated] = signals.createSignal(false); | ||
| let active = false; | ||
| coreFn(prev => { | ||
| if (!hydrated()) return value; | ||
| active = true; | ||
| return compute(prev); | ||
| }, (next, prev) => { | ||
| if (!active) return; | ||
| return effectFn(next, prev); | ||
| }, value, options); | ||
| setHydrated(true); | ||
| return; | ||
| } | ||
| if (ssrSource === "initial") { | ||
| coreFn(prev => { | ||
| if (!sharedConfig.hydrating) return compute(prev); | ||
| subFetch(compute, prev); | ||
| return prev ?? value; | ||
| }, effectFn, value, options); | ||
| return; | ||
| } | ||
| markTopLevelSnapshotScope(); | ||
| coreFn(prev => { | ||
| const o = signals.getOwner(); | ||
| if (!sharedConfig.hydrating) return compute(prev); | ||
| let initP; | ||
| if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id); | ||
| const init = initP?.v ?? initP; | ||
| return init != null ? (subFetch(compute, prev), init) : compute(prev); | ||
| }, effectFn, value, options); | ||
| } | ||
| function hydratedCreateRenderEffect(compute, effectFn, value, options) { | ||
| return hydratedEffect(signals.createRenderEffect, compute, effectFn, value, options); | ||
| } | ||
| function hydratedCreateEffect(compute, effectFn, value, options) { | ||
| return hydratedEffect(signals.createEffect, compute, effectFn, value, options); | ||
| } | ||
| function enableHydration() { | ||
@@ -370,2 +417,4 @@ _createMemo = hydratedCreateMemo; | ||
| _createOptimisticStore = hydratedCreateOptimisticStore; | ||
| _createRenderEffect = hydratedCreateRenderEffect; | ||
| _createEffect = hydratedCreateEffect; | ||
| _hydratingValue = sharedConfig.hydrating; | ||
@@ -416,2 +465,4 @@ _doneValue = sharedConfig.done; | ||
| const createOptimisticStore = (...args) => (_createOptimisticStore || signals.createOptimisticStore)(...args); | ||
| const createRenderEffect = (...args) => (_createRenderEffect || signals.createRenderEffect)(...args); | ||
| const createEffect = (...args) => (_createEffect || signals.createEffect)(...args); | ||
| function loadModuleAssets(mapping) { | ||
@@ -654,5 +705,5 @@ const hy = globalThis._$HY; | ||
| }); | ||
| Object.defineProperty(exports, "createEffect", { | ||
| Object.defineProperty(exports, "createOwner", { | ||
| enumerable: true, | ||
| get: function () { return signals.createEffect; } | ||
| get: function () { return signals.createOwner; } | ||
| }); | ||
@@ -663,6 +714,2 @@ Object.defineProperty(exports, "createReaction", { | ||
| }); | ||
| Object.defineProperty(exports, "createRenderEffect", { | ||
| enumerable: true, | ||
| get: function () { return signals.createRenderEffect; } | ||
| }); | ||
| Object.defineProperty(exports, "createRoot", { | ||
@@ -688,2 +735,6 @@ enumerable: true, | ||
| }); | ||
| Object.defineProperty(exports, "getNextChildId", { | ||
| enumerable: true, | ||
| get: function () { return signals.getNextChildId; } | ||
| }); | ||
| Object.defineProperty(exports, "getObserver", { | ||
@@ -713,2 +764,6 @@ enumerable: true, | ||
| }); | ||
| Object.defineProperty(exports, "latest", { | ||
| enumerable: true, | ||
| get: function () { return signals.latest; } | ||
| }); | ||
| Object.defineProperty(exports, "mapArray", { | ||
@@ -734,6 +789,2 @@ enumerable: true, | ||
| }); | ||
| Object.defineProperty(exports, "pending", { | ||
| enumerable: true, | ||
| get: function () { return signals.pending; } | ||
| }); | ||
| Object.defineProperty(exports, "reconcile", { | ||
@@ -763,2 +814,6 @@ enumerable: true, | ||
| }); | ||
| Object.defineProperty(exports, "storePath", { | ||
| enumerable: true, | ||
| get: function () { return signals.storePath; } | ||
| }); | ||
| Object.defineProperty(exports, "untrack", { | ||
@@ -780,2 +835,3 @@ enumerable: true, | ||
| exports.createContext = createContext; | ||
| exports.createEffect = createEffect; | ||
| exports.createMemo = createMemo; | ||
@@ -785,2 +841,3 @@ exports.createOptimistic = createOptimistic; | ||
| exports.createProjection = createProjection; | ||
| exports.createRenderEffect = createRenderEffect; | ||
| exports.createSignal = createSignal; | ||
@@ -787,0 +844,0 @@ exports.createStore = createStore; |
+58
-7
@@ -1,3 +0,3 @@ | ||
| import { getContext, createMemo as createMemo$1, flatten, createRoot, setContext, createLoadBoundary, getOwner, onCleanup, isDisposed, runWithOwner, createOptimistic as createOptimistic$1, createOptimisticStore as createOptimisticStore$1, createProjection as createProjection$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, createEffect, createReaction, createRenderEffect, createRoot, createTrackedEffect, deep, flatten, flush, getObserver, getOwner, isEqual, isPending, isRefreshing, isWrappable, mapArray, merge, omit, onCleanup, onSettled, pending, reconcile, refresh, repeat, resolve, runWithOwner, snapshot, untrack } from '@solidjs/signals'; | ||
| import { getContext, createMemo as createMemo$1, flatten, createRoot, setContext, createLoadBoundary, getOwner, onCleanup, isDisposed, runWithOwner, 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'; | ||
@@ -21,7 +21,11 @@ const $DEVCOMP = Symbol(0); | ||
| function children(fn) { | ||
| const children = createMemo$1(fn); | ||
| const memo = createMemo$1(() => flatten(children())); | ||
| const c = createMemo$1(fn, undefined, { | ||
| lazy: true | ||
| }); | ||
| const memo = createMemo$1(() => flatten(c()), undefined, { | ||
| lazy: true | ||
| }); | ||
| memo.toArray = () => { | ||
| const c = memo(); | ||
| return Array.isArray(c) ? c : c != null ? [c] : []; | ||
| const v = memo(); | ||
| return Array.isArray(v) ? v : v != null ? [v] : []; | ||
| }; | ||
@@ -79,2 +83,4 @@ return memo; | ||
| let _createOptimisticStore; | ||
| let _createRenderEffect; | ||
| let _createEffect; | ||
| class MockPromise { | ||
@@ -360,2 +366,43 @@ static all() { | ||
| } | ||
| function hydratedEffect(coreFn, compute, effectFn, value, options) { | ||
| if (!sharedConfig.hydrating) return coreFn(compute, effectFn, value, options); | ||
| const ssrSource = options?.ssrSource; | ||
| if (ssrSource === "client") { | ||
| const [hydrated, setHydrated] = createSignal$1(false); | ||
| let active = false; | ||
| coreFn(prev => { | ||
| if (!hydrated()) return value; | ||
| active = true; | ||
| return compute(prev); | ||
| }, (next, prev) => { | ||
| if (!active) return; | ||
| return effectFn(next, prev); | ||
| }, value, options); | ||
| setHydrated(true); | ||
| return; | ||
| } | ||
| if (ssrSource === "initial") { | ||
| coreFn(prev => { | ||
| if (!sharedConfig.hydrating) return compute(prev); | ||
| subFetch(compute, prev); | ||
| return prev ?? value; | ||
| }, effectFn, value, options); | ||
| return; | ||
| } | ||
| markTopLevelSnapshotScope(); | ||
| coreFn(prev => { | ||
| const o = getOwner(); | ||
| if (!sharedConfig.hydrating) return compute(prev); | ||
| let initP; | ||
| if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id); | ||
| const init = initP?.v ?? initP; | ||
| return init != null ? (subFetch(compute, prev), init) : compute(prev); | ||
| }, effectFn, value, options); | ||
| } | ||
| function hydratedCreateRenderEffect(compute, effectFn, value, options) { | ||
| return hydratedEffect(createRenderEffect$1, compute, effectFn, value, options); | ||
| } | ||
| function hydratedCreateEffect(compute, effectFn, value, options) { | ||
| return hydratedEffect(createEffect$1, compute, effectFn, value, options); | ||
| } | ||
| function enableHydration() { | ||
@@ -369,2 +416,4 @@ _createMemo = hydratedCreateMemo; | ||
| _createOptimisticStore = hydratedCreateOptimisticStore; | ||
| _createRenderEffect = hydratedCreateRenderEffect; | ||
| _createEffect = hydratedCreateEffect; | ||
| _hydratingValue = sharedConfig.hydrating; | ||
@@ -415,2 +464,4 @@ _doneValue = sharedConfig.done; | ||
| const createOptimisticStore = (...args) => (_createOptimisticStore || createOptimisticStore$1)(...args); | ||
| const createRenderEffect = (...args) => (_createRenderEffect || createRenderEffect$1)(...args); | ||
| const createEffect = (...args) => (_createEffect || createEffect$1)(...args); | ||
| function loadModuleAssets(mapping) { | ||
@@ -637,2 +688,2 @@ const hy = globalThis._$HY; | ||
| export { $DEVCOMP, DEV, Errored, For, Loading, Match, Repeat, Show, Switch, children, createComponent, createContext, createMemo, createOptimistic, createOptimisticStore, createProjection, createSignal, createStore, createUniqueId, enableHydration, lazy, sharedConfig, ssrHandleError, ssrRunInScope, useContext }; | ||
| export { $DEVCOMP, DEV, Errored, For, Loading, Match, Repeat, Show, Switch, children, createComponent, createContext, createEffect, createMemo, createOptimistic, createOptimisticStore, createProjection, createRenderEffect, createSignal, createStore, createUniqueId, enableHydration, lazy, sharedConfig, ssrHandleError, ssrRunInScope, useContext }; |
+2
-2
| { | ||
| "name": "solid-js", | ||
| "description": "A declarative JavaScript library for building user interfaces.", | ||
| "version": "2.0.0-experimental.15", | ||
| "version": "2.0.0-experimental.16", | ||
| "author": "Ryan Carniato", | ||
@@ -82,3 +82,3 @@ "license": "MIT", | ||
| "dependencies": { | ||
| "@solidjs/signals": "^0.10.8", | ||
| "@solidjs/signals": "^0.11.1", | ||
| "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, type ProjectionOptions, type Store, type StoreSetter } from "@solidjs/signals"; | ||
| 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 } from "@solidjs/signals"; | ||
| import { JSX } from "../jsx.js"; | ||
@@ -12,2 +12,6 @@ declare module "@solidjs/signals" { | ||
| } | ||
| interface EffectOptions { | ||
| deferStream?: boolean; | ||
| ssrSource?: "server" | "hybrid" | "initial" | "client"; | ||
| } | ||
| } | ||
@@ -28,2 +32,5 @@ export type HydrationProjectionOptions = ProjectionOptions & { | ||
| registry?: Map<string, Element>; | ||
| completed?: WeakSet<Element> | null; | ||
| events?: any[] | null; | ||
| verifyHydration?: () => void; | ||
| done: boolean; | ||
@@ -54,2 +61,4 @@ getNextContextId(): string; | ||
| }; | ||
| export declare const createRenderEffect: typeof coreRenderEffect; | ||
| export declare const createEffect: typeof coreEffect; | ||
| /** | ||
@@ -56,0 +65,0 @@ * Tracks all resources inside a component and renders a fallback until they are all resolved |
+3
-3
@@ -1,3 +0,3 @@ | ||
| export { $PROXY, $TRACK, action, createEffect, createReaction, createRenderEffect, createRoot, createTrackedEffect, deep, flatten, flush, getObserver, getOwner, isEqual, isRefreshing, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, pending, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, snapshot, untrack } from "@solidjs/signals"; | ||
| export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, Merge, NoInfer, NotWrappable, Omit, Owner, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter } from "@solidjs/signals"; | ||
| 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 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"; | ||
| export { $DEVCOMP, children, createContext, useContext } from "./client/core.js"; | ||
@@ -7,3 +7,3 @@ export type { ChildrenReturn, Context, ContextProviderComponent, ResolvedChildren, ResolvedJSXElement } from "./client/core.js"; | ||
| export * from "./client/flow.js"; | ||
| export { sharedConfig, Loading, enableHydration, createMemo, createSignal, createStore, createProjection, createOptimistic, createOptimisticStore } from "./client/hydration.js"; | ||
| export { sharedConfig, Loading, enableHydration, createMemo, createSignal, createStore, createProjection, createOptimistic, createOptimisticStore, createRenderEffect, createEffect } from "./client/hydration.js"; | ||
| export declare function ssrHandleError(): void; | ||
@@ -10,0 +10,0 @@ export declare function ssrRunInScope(): void; |
@@ -39,6 +39,7 @@ import type { Accessor, EffectOptions } from "./signals.js"; | ||
| /** | ||
| * Runs functions with an isolated owner scope for SSR. | ||
| * Used by dom-expressions to run event handlers and other code in scope. | ||
| * Pass-through for SSR dynamic expressions. | ||
| * On the client, insert() render effects are transparent (0 owner slots), | ||
| * so the server doesn't need to create owners for these either. | ||
| */ | ||
| export declare function ssrRunInScope(fn: () => any): () => any; | ||
| export declare function ssrRunInScope(array: (() => any)[]): (() => any)[]; |
@@ -1,3 +0,3 @@ | ||
| export { $PROXY, $TRACK, action, createEffect, createMemo, createOptimistic, createOptimisticStore, createProjection, createReaction, createRenderEffect, createRoot, createSignal, createStore, createTrackedEffect, deep, flatten, flush, getObserver, getOwner, isEqual, isRefreshing, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, pending, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, snapshot, createDeepProxy, untrack } from "./signals.js"; | ||
| export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, Merge, NoInfer, NotWrappable, Omit, Owner, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter, PatchOp } from "./signals.js"; | ||
| 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 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"; | ||
| export { $DEVCOMP, children, createContext, useContext, ssrRunInScope } from "./core.js"; | ||
@@ -4,0 +4,0 @@ export type { ChildrenReturn, Context, ContextProviderComponent, ResolvedChildren, ResolvedJSXElement } from "./core.js"; |
| export { createRoot, createOwner, runWithOwner, getOwner, onCleanup, getNextChildId, createContext, setContext, getContext, NotReadyError, NoOwnerError, ContextNotFoundError, isEqual, isWrappable, SUPPORTS_PROXY } from "@solidjs/signals"; | ||
| export { flatten } from "@solidjs/signals"; | ||
| export { snapshot, merge, omit, $PROXY, $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 } from "@solidjs/signals"; | ||
| export { snapshot, merge, omit, storePath, $PROXY, $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"; | ||
| import type { Accessor, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, MemoOptions, SignalOptions, Signal, Owner, Store, StoreSetter, Context } from "@solidjs/signals"; | ||
@@ -55,3 +55,3 @@ interface ServerComputation<T = any> { | ||
| export declare function isPending(fn: () => any, fallback?: boolean): boolean; | ||
| export declare function pending<T>(fn: () => T): T; | ||
| export declare function latest<T>(fn: () => T): T; | ||
| export declare function isRefreshing(): boolean; | ||
@@ -58,0 +58,0 @@ export declare function refresh<T>(fn: () => T): T; |
Sorry, the diff of this file is too big to display
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
366236
2.88%9441
3.2%16
-5.88%+ Added
- Removed
Updated