1
- import { TypeIds , _constants , type Constants , parseQRL , resolvers } from './index' ;
2
1
import type { DomContainer } from '../../client/dom-container' ;
2
+ import { ensureMaterialized , vnode_getNode , vnode_isVNode , vnode_locate } from '../../client/vnode' ;
3
3
import type { ElementVNode , VNode } from '../../client/vnode-impl' ;
4
- import { vnode_isVNode , ensureMaterialized , vnode_getNode , vnode_locate } from '../../client/vnode' ;
5
4
import { AsyncComputedSignalImpl } from '../../reactive-primitives/impl/async-computed-signal-impl' ;
6
5
import { ComputedSignalImpl } from '../../reactive-primitives/impl/computed-signal-impl' ;
7
6
import { SerializerSignalImpl } from '../../reactive-primitives/impl/serializer-signal-impl' ;
@@ -14,12 +13,15 @@ import { createResourceReturn } from '../../use/use-resource';
14
13
import { Task } from '../../use/use-task' ;
15
14
import { componentQrl } from '../component.public' ;
16
15
import { qError , QError } from '../error/error' ;
17
- import { JSXNodeImpl , createPropsProxy } from '../jsx/jsx-runtime' ;
16
+ import { createPropsProxy , JSXNodeImpl } from '../jsx/jsx-runtime' ;
18
17
import type { DeserializeContainer } from '../types' ;
19
18
import { _UNINITIALIZED } from '../utils/constants' ;
19
+ import { _constants , TypeIds , type Constants } from './constants' ;
20
20
import { needsInflation } from './deser-proxy' ;
21
+ import { createQRLWithBackChannel } from './qrl-to-string' ;
21
22
22
- export const pendingStoreTargents = new Map < object , { t : TypeIds ; v : unknown } > ( ) ;
23
+ export const resolvers = new WeakMap < Promise < any > , [ Function , Function ] > ( ) ;
24
+ export const pendingStoreTargets = new Map < object , { t : TypeIds ; v : unknown } > ( ) ;
23
25
24
26
export const allocate = ( container : DeserializeContainer , typeId : number , value : unknown ) : any => {
25
27
switch ( typeId ) {
@@ -46,13 +48,17 @@ export const allocate = (container: DeserializeContainer, typeId: number, value:
46
48
case TypeIds . Object :
47
49
return { } ;
48
50
case TypeIds . QRL :
49
- case TypeIds . PreloadQRL :
50
- const qrl =
51
- typeof value === 'number'
52
- ? // root reference
53
- container . $getObjectById$ ( value )
54
- : value ;
55
- return parseQRL ( qrl as string ) ;
51
+ case TypeIds . PreloadQRL : {
52
+ if ( typeof value === 'string' ) {
53
+ const data = value . split ( ' ' ) . map ( Number ) ;
54
+ const chunk = container . $getObjectById$ ( data [ 0 ] ) as string ;
55
+ const symbol = container . $getObjectById$ ( data [ 1 ] ) as string ;
56
+ const captureIds = data . length > 2 ? data . slice ( 2 ) : null ;
57
+ return createQRLWithBackChannel ( chunk , symbol , captureIds ) ;
58
+ } else {
59
+ return createQRLWithBackChannel ( '' , String ( value ) ) ;
60
+ }
61
+ }
56
62
case TypeIds . Task :
57
63
return new Task ( - 1 , - 1 , null ! , null ! , null ! , null ) ;
58
64
case TypeIds . Resource : {
@@ -96,7 +102,7 @@ export const allocate = (container: DeserializeContainer, typeId: number, value:
96
102
const storeValue = allocate ( container , t , v ) ;
97
103
const store = getOrCreateStore ( storeValue , StoreFlags . NONE , container as DomContainer ) ;
98
104
if ( needsInflation ( t ) ) {
99
- pendingStoreTargents . set ( store , { t, v } ) ;
105
+ pendingStoreTargets . set ( store , { t, v } ) ;
100
106
}
101
107
// We must store the reference so it doesn't get deserialized again in inflate()
102
108
data [ 0 ] = TypeIds . Plain ;
0 commit comments