@@ -56,12 +56,12 @@ export type CachedFunction<T extends (...args: any) => any> = T extends (
5656 ...args : infer A
5757) => infer R
5858 ? ( [ ] extends { [ K in keyof A ] -?: A [ K ] } // A tuple full of optional values is equivalent to an empty tuple
59- ? (
60- ...args : never [ ]
61- ) => R extends Promise < infer P > ? Promise < NarrowResponse < P > > : NarrowResponse < R >
62- : (
63- ...args : A
64- ) => R extends Promise < infer P > ? Promise < NarrowResponse < P > > : NarrowResponse < R > ) & {
59+ ? (
60+ ...args : never [ ]
61+ ) => R extends Promise < infer P > ? Promise < NarrowResponse < P > > : NarrowResponse < R >
62+ : (
63+ ...args : A
64+ ) => R extends Promise < infer P > ? Promise < NarrowResponse < P > > : NarrowResponse < R > ) & {
6565 keyFor : ( ...args : A ) => string ;
6666 key : string ;
6767 }
@@ -122,7 +122,7 @@ export function query<T extends (...args: any) => any>(fn: T, name: string): Cac
122122 : handleResponse ( false ) ( cached [ 1 ] ) ;
123123 ! isServer && intent === "navigate" && cached [ 4 ] [ 1 ] ( cached [ 0 ] ) ; // update version
124124 }
125- inPreloadFn && "then" in res && res . catch ( ( ) => { } ) ;
125+ inPreloadFn && "then" in res && res . catch ( ( ) => { } ) ;
126126 return res ;
127127 }
128128 let res ;
@@ -140,7 +140,7 @@ export function query<T extends (...args: any) => any>(fn: T, name: string): Cac
140140 } else {
141141 cache . set (
142142 key ,
143- ( cached = [ now , res , , intent , createSignal ( now ) as Signal < number > & { count : number } ] )
143+ ( cached = [ now , res , , intent , createSignal ( now , { ownedWrite : true } ) as Signal < number > & { count : number } ] )
144144 ) ;
145145 cached [ 4 ] . count = 0 ;
146146 }
@@ -158,7 +158,7 @@ export function query<T extends (...args: any) => any>(fn: T, name: string): Cac
158158 ? res . then ( handleResponse ( false ) , handleResponse ( true ) )
159159 : handleResponse ( false ) ( res ) ;
160160 }
161- inPreloadFn && "then" in res && res . catch ( ( ) => { } ) ;
161+ inPreloadFn && "then" in res && res . catch ( ( ) => { } ) ;
162162 // serialize on server
163163 if (
164164 isServer &&
@@ -175,16 +175,16 @@ export function query<T extends (...args: any) => any>(fn: T, name: string): Cac
175175 return async ( v : any | Response ) => {
176176 if ( v instanceof Response ) {
177177 const e = getRequestEvent ( ) ;
178-
178+
179179 if ( e ) {
180- for ( const [ key , value ] of v . headers ) {
180+ for ( const [ key , value ] of v . headers ) {
181181 if ( key == "set-cookie" )
182182 e . response . headers . append ( "set-cookie" , value ) ;
183183 else
184184 e . response . headers . set ( key , value ) ;
185185 }
186186 }
187-
187+
188188 const url = v . headers . get ( LocationHeader ) ;
189189
190190 if ( url !== null ) {
@@ -227,7 +227,7 @@ query.set = <T>(key: string, value: T extends Promise<any> ? never : T) => {
227227 } else {
228228 cache . set (
229229 key ,
230- ( cached = [ now , Promise . resolve ( value ) , value , "preload" , createSignal ( now ) as Signal < number > & { count : number } ] )
230+ ( cached = [ now , Promise . resolve ( value ) , value , "preload" , createSignal ( now , { ownedWrite : true } ) as Signal < number > & { count : number } ] )
231231 ) ;
232232 cached [ 4 ] . count = 0 ;
233233 }
@@ -250,11 +250,11 @@ export function hashKey<T extends Array<any>>(args: T): string {
250250 return JSON . stringify ( args , ( _ , val ) =>
251251 isPlainObject ( val )
252252 ? Object . keys ( val )
253- . sort ( )
254- . reduce ( ( result , key ) => {
255- result [ key ] = val [ key ] ;
256- return result ;
257- } , { } as any )
253+ . sort ( )
254+ . reduce ( ( result , key ) => {
255+ result [ key ] = val [ key ] ;
256+ return result ;
257+ } , { } as any )
258258 : val
259259 ) ;
260260}
0 commit comments