@@ -31,7 +31,12 @@ export { snapshot, omit, storePath, $PROXY, $TRACK } from "@solidjs/signals";
3131
3232// === Type re-exports ===
3333
34- import type { Accessor as SignalAccessor , Refreshable } from "@solidjs/signals" ;
34+ import type {
35+ Accessor as SignalAccessor ,
36+ ProjectionOptions ,
37+ Refreshable ,
38+ StoreOptions
39+ } from "@solidjs/signals" ;
3540
3641export type SourceAccessor < T > = Refreshable < SignalAccessor < T > > ;
3742
@@ -472,17 +477,10 @@ interface ServerComputation<T = any> {
472477const LIVE_SOURCE = Symbol . for ( "solid.LiveSource" ) ;
473478
474479type SsrSourceMode = "server" | "hybrid" | "client" ;
475- type ServerSsrOptions = {
480+ interface ServerProjectionOptions extends ProjectionOptions {
476481 deferStream ?: boolean ;
477482 ssrSource ?: SsrSourceMode ;
478- /**
479- * Commit #0 for derived stores: serve the seed instead of suspending. The
480- * markup flushes with the seed (locked for the whole response — the
481- * first-value lock at commit #0) and the landing streams as data for the
482- * client, whose store is born committed with the same seed.
483- */
484- seedLoadingValue ?: boolean ;
485- } ;
483+ }
486484type ServerMemoOptions < T > = MemoOptions < T > & {
487485 /**
488486 * Keep this value out of the hydration payload. The subtree still hydrates;
@@ -494,7 +492,6 @@ type ServerMemoOptions<T> = MemoOptions<T> & {
494492 serialize ?: false ;
495493} ;
496494type ServerSignalOptions < T > = SignalOptions < T > ;
497- type ServerStoreOptions = ServerSsrOptions ;
498495type NoFn < T > = T extends Function ? never : T ;
499496
500497/**
@@ -1778,19 +1775,19 @@ function setProperty(state: any, property: PropertyKey, value: any) {
17781775 } else state [ property ] = value ;
17791776}
17801777
1781- export function createStore < T extends object > (
1782- store : NoFn < T > | Store < NoFn < T > > ,
1783- options ?: { name ?: string ; shallow ?: boolean }
1784- ) : [ get : Store < T > , set : StoreSetter < T > ] ;
1785- export function createStore < T extends object > (
1786- fn : ( store : T ) => void | T | Promise < void | T > ,
1787- store : NoFn < T > | Store < NoFn < T > > ,
1788- options ?: ServerStoreOptions & { name ?: string ; shallow ?: boolean }
1778+ export function createStore < T extends object = { } > (
1779+ initialValue : NoFn < T > | Store < NoFn < T > > ,
1780+ options ?: StoreOptions
17891781) : [ get : Store < T > , set : StoreSetter < T > ] ;
1790- export function createStore < T extends object > (
1791- first : T | Store < T > | ( ( store : T ) => void | T | Promise < void | T > ) ,
1782+ export function createStore < T extends object = { } > (
1783+ fn : ( draft : T ) => void | T | Promise < void | T > | AsyncIterable < void | T > ,
1784+ seed : NoFn < T > | Store < NoFn < T > > ,
1785+ options ?: ServerProjectionOptions
1786+ ) : [ get : Refreshable < Store < T > > , set : StoreSetter < T > ] ;
1787+ export function createStore < T extends object = { } > (
1788+ first : T | Store < T > | ( ( store : T ) => void | T | Promise < void | T > | AsyncIterable < void | T > ) ,
17921789 second ?: T | Store < T > ,
1793- options ?: ServerSsrOptions & { name ?: string ; shallow ?: boolean }
1790+ third ?: ServerProjectionOptions
17941791) : [ get : Store < T > , set : StoreSetter < T > ] {
17951792 if ( typeof first === "function" ) {
17961793 // Forward options: dropping them made ssrSource inert for derived stores —
@@ -1799,7 +1796,7 @@ export function createStore<T extends object>(
17991796 // The impl signature stays loose; the public overload above enforces the
18001797 // client/seedLoadingValue pairing, and createProjection re-checks at
18011798 // runtime.
1802- const store = createProjection ( first as any , second as NoFn < T > , options as any ) ;
1799+ const store = createProjection ( first as any , second as NoFn < T > , third as any ) ;
18031800 return [ store as Store < T > , storeSetter ( store as T ) ] ;
18041801 }
18051802 const state = first as T ;
@@ -1823,25 +1820,25 @@ function storeSetter<T extends object>(state: T): StoreSetter<T> {
18231820 } ) as StoreSetter < T > ;
18241821}
18251822
1826- export function createOptimisticStore < T extends object > (
1827- store : NoFn < T > | Store < NoFn < T > > ,
1828- options ?: { name ?: string ; shallow ?: boolean }
1829- ) : [ get : Store < T > , set : StoreSetter < T > ] ;
1830- export function createOptimisticStore < T extends object > (
1831- fn : ( store : T ) => void | T | Promise < void | T > ,
1832- store : NoFn < T > | Store < NoFn < T > > ,
1833- options ?: ServerStoreOptions & { name ?: string ; shallow ?: boolean }
1823+ export function createOptimisticStore < T extends object = { } > (
1824+ initialValue : NoFn < T > | Store < NoFn < T > > ,
1825+ options ?: StoreOptions
18341826) : [ get : Store < T > , set : StoreSetter < T > ] ;
1835- export function createOptimisticStore < T extends object > (
1836- first : T | Store < T > | ( ( store : T ) => void | T | Promise < void | T > ) ,
1827+ export function createOptimisticStore < T extends object = { } > (
1828+ fn : ( draft : T ) => void | T | Promise < void | T > | AsyncIterable < void | T > ,
1829+ seed : NoFn < T > | Store < NoFn < T > > ,
1830+ options ?: ServerProjectionOptions
1831+ ) : [ get : Refreshable < Store < T > > , set : StoreSetter < T > ] ;
1832+ export function createOptimisticStore < T extends object = { } > (
1833+ first : T | Store < T > | ( ( store : T ) => void | T | Promise < void | T > | AsyncIterable < void | T > ) ,
18371834 second ?: T | Store < T > ,
1838- options ?: ServerSsrOptions & { name ?: string ; shallow ?: boolean }
1835+ third ?: ServerProjectionOptions
18391836) : [ get : Store < T > , set : StoreSetter < T > ] {
18401837 // Same no-op rationale as createOptimistic above: optimistic writes are
18411838 // masks that revert at settle, and server output is settled state. The
18421839 // setter never invokes its function — a draft mutation here would be a
18431840 // literal (permanent) mutation, the opposite of optimistic.
1844- const [ store ] = ( createStore as Function ) ( first , second , options ) as [ Store < T > , StoreSetter < T > ] ;
1841+ const [ store ] = ( createStore as Function ) ( first , second , third ) as [ Store < T > , StoreSetter < T > ] ;
18451842 return [ store , ( ( ) => warnServerWrite ( "optimistic" ) ) as StoreSetter < T > ] ;
18461843}
18471844
@@ -1968,10 +1965,15 @@ function replaceState<T extends object>(target: T, next: T): void {
19681965 Object . assign ( target , next ) ;
19691966}
19701967
1971- export function createProjection < T extends object > (
1968+ export function createProjection < T extends object = { } > (
19721969 fn : ( draft : T ) => void | T | Promise < void | T > | AsyncIterable < void | T > ,
1973- initialValue : NoFn < T > | Store < NoFn < T > > ,
1974- options ?: ServerStoreOptions
1970+ seed : NoFn < T > | Store < NoFn < T > > ,
1971+ options ?: ServerProjectionOptions
1972+ ) : Refreshable < Store < T > > ;
1973+ export function createProjection < T extends object = { } > (
1974+ fn : ( draft : T ) => void | T | Promise < void | T > | AsyncIterable < void | T > ,
1975+ seed : NoFn < T > | Store < NoFn < T > > ,
1976+ options ?: ServerProjectionOptions
19751977) : Store < T > {
19761978 const ctx = sharedConfig . context ;
19771979 const owner = createOwner ( ) ;
@@ -2000,7 +2002,7 @@ export function createProjection<T extends object>(
20002002 if ( slots ) slots [ slotId ! ] = proxy ;
20012003 return proxy ;
20022004 } ;
2003- const [ state ] = createStore ( initialValue as NoFn < T > ) ;
2005+ const [ state ] = createStore ( seed as NoFn < T > ) ;
20042006
20052007 if ( options ?. ssrSource === "client" ) {
20062008 // seedLoadingValue = declared commit #0: the seed renders. Bare = the
0 commit comments