@@ -621,7 +621,7 @@ type SeenRef = {
621
621
let isDomRef = ( obj : unknown ) : obj is DomRef => false ;
622
622
623
623
export interface SerializationContext {
624
- $ serialize$ : ( ) => void ;
624
+ serialize : ( ) => void ;
625
625
626
626
$symbolToChunkResolver$ : SymbolToChunkResolver ;
627
627
@@ -647,7 +647,7 @@ export interface SerializationContext {
647
647
* Returns a path string representing the path from roots through all parents to the object.
648
648
* Format: "3 2 0" where each number is the index within its parent, from root to leaf.
649
649
*/
650
- $ addRoot$ : ( obj : unknown , parent ?: unknown ) => number ;
650
+ addRoot : ( obj : unknown , parent ?: unknown ) => number ;
651
651
652
652
/**
653
653
* Get root path of the object without creating a new root.
@@ -660,7 +660,7 @@ export interface SerializationContext {
660
660
661
661
$seen$ : ( obj : unknown , parent : unknown | null , index : number ) => void ;
662
662
663
- $ roots$ : unknown [ ] ;
663
+ roots : unknown [ ] ;
664
664
$pathMap$ : Map < unknown , string | number > ;
665
665
666
666
$addSyncFn$ ( $funcStr$ : string | null , argsCount : number , fn : Function ) : number ;
@@ -671,7 +671,7 @@ export interface SerializationContext {
671
671
$writer$ : StreamWriter ;
672
672
$syncFns$ : string [ ] ;
673
673
674
- $ eventQrls$ : Set < QRL > ;
674
+ eventQrls : Set < QRL > ;
675
675
$eventNames$ : Set < string > ;
676
676
$resources$ : Set < ResourceReturnInternal < unknown > > ;
677
677
$renderSymbols$ : Set < string > ;
@@ -748,7 +748,7 @@ export const createSerializationContext = (
748
748
return pathStr ;
749
749
} ;
750
750
751
- const $ addRoot$ = ( obj : any , parent : unknown = null ) => {
751
+ const addRoot = ( obj : any , parent : unknown = null ) => {
752
752
let seen = seenObjsMap . get ( obj ) ;
753
753
if ( ! seen ) {
754
754
const rootIndex = roots . length ;
@@ -771,20 +771,20 @@ export const createSerializationContext = (
771
771
) as ( obj : unknown ) => obj is DomRef ;
772
772
773
773
return {
774
- async $ serialize$ ( ) : Promise < void > {
774
+ async serialize ( ) : Promise < void > {
775
775
return await serialize ( this ) ;
776
776
} ,
777
777
$isSsrNode$ : isSsrNode ,
778
778
$isDomRef$ : isDomRef ,
779
779
$symbolToChunkResolver$ : symbolToChunkResolver ,
780
780
$wasSeen$,
781
- $roots$ : roots ,
781
+ roots,
782
782
$seen$,
783
783
$hasRootId$ : ( obj : any ) => {
784
784
const id = seenObjsMap . get ( obj ) ;
785
785
return id ?. $parent$ === null ? id . $index$ : undefined ;
786
786
} ,
787
- $ addRoot$ ,
787
+ addRoot,
788
788
$addRootPath$,
789
789
$syncFns$ : syncFns ,
790
790
$addSyncFn$ : ( funcStr : string | null , argCount : number , fn : Function ) => {
@@ -809,7 +809,7 @@ export const createSerializationContext = (
809
809
return id ;
810
810
} ,
811
811
$writer$ : writer ,
812
- $ eventQrls$ : new Set < QRL > ( ) ,
812
+ eventQrls : new Set < QRL > ( ) ,
813
813
$eventNames$ : new Set < string > ( ) ,
814
814
$resources$ : new Set < ResourceReturnInternal < unknown > > ( ) ,
815
815
$renderSymbols$ : new Set < string > ( ) ,
@@ -827,7 +827,7 @@ function $discoverRoots$(
827
827
parent : unknown ,
828
828
index : number
829
829
) : void {
830
- const { $wasSeen$, $seen$, $addRoot$ } = serializationContext ;
830
+ const { $wasSeen$, $seen$, addRoot : $addRoot$ } = serializationContext ;
831
831
if ( ! ( shouldTrackObj ( obj ) || frameworkType ( obj ) ) ) {
832
832
return ;
833
833
}
@@ -879,8 +879,15 @@ class PromiseResult {
879
879
* - Therefore root indexes need to be doubled to get the actual index.
880
880
*/
881
881
async function serialize ( serializationContext : SerializationContext ) : Promise < void > {
882
- const { $writer$, $isSsrNode$, $isDomRef$, $storeProxyMap$, $addRoot$, $pathMap$, $wasSeen$ } =
883
- serializationContext ;
882
+ const {
883
+ $writer$,
884
+ $isSsrNode$,
885
+ $isDomRef$,
886
+ $storeProxyMap$,
887
+ addRoot : $addRoot$ ,
888
+ $pathMap$,
889
+ $wasSeen$,
890
+ } = serializationContext ;
884
891
let depth = 0 ;
885
892
const forwardRefs : number [ ] = [ ] ;
886
893
let forwardRefsId = 0 ;
@@ -930,7 +937,7 @@ async function serialize(serializationContext: SerializationContext): Promise<vo
930
937
931
938
const addPreloadQrl = ( qrl : QRLInternal ) => {
932
939
preloadQrls . add ( qrl ) ;
933
- serializationContext . $ addRoot$ ( qrl , null ) ;
940
+ serializationContext . addRoot ( qrl , null ) ;
934
941
} ;
935
942
936
943
const outputRootRef = ( value : unknown , elseCallback : ( ) => void ) => {
@@ -964,7 +971,7 @@ async function serialize(serializationContext: SerializationContext): Promise<vo
964
971
if ( isRootObject ( ) ) {
965
972
output ( type , qrl ) ;
966
973
} else {
967
- const id = serializationContext . $ addRoot$ ( qrl ) ;
974
+ const id = serializationContext . addRoot ( qrl ) ;
968
975
output ( type , id ) ;
969
976
}
970
977
} ) ;
@@ -1092,7 +1099,7 @@ async function serialize(serializationContext: SerializationContext): Promise<vo
1092
1099
if ( $storeProxyMap$ . has ( propValue ) ) {
1093
1100
const innerStore = $storeProxyMap$ . get ( propValue ) ;
1094
1101
innerStores . push ( innerStore ) ;
1095
- serializationContext . $ addRoot$ ( innerStore ) ;
1102
+ serializationContext . addRoot ( innerStore ) ;
1096
1103
}
1097
1104
}
1098
1105
@@ -1318,7 +1325,7 @@ async function serialize(serializationContext: SerializationContext): Promise<vo
1318
1325
$writer$ . write ( '[' ) ;
1319
1326
1320
1327
let lastRootsLength = 0 ;
1321
- let rootsLength = serializationContext . $ roots$ . length ;
1328
+ let rootsLength = serializationContext . roots . length ;
1322
1329
while ( lastRootsLength < rootsLength || promises . size ) {
1323
1330
if ( lastRootsLength !== 0 ) {
1324
1331
$writer$ . write ( ',' ) ;
@@ -1331,7 +1338,7 @@ async function serialize(serializationContext: SerializationContext): Promise<vo
1331
1338
} else {
1332
1339
separator = true ;
1333
1340
}
1334
- writeValue ( serializationContext . $ roots$ [ i ] ) ;
1341
+ writeValue ( serializationContext . roots [ i ] ) ;
1335
1342
}
1336
1343
1337
1344
if ( promises . size ) {
@@ -1343,7 +1350,7 @@ async function serialize(serializationContext: SerializationContext): Promise<vo
1343
1350
}
1344
1351
1345
1352
lastRootsLength = rootsLength ;
1346
- rootsLength = serializationContext . $ roots$ . length ;
1353
+ rootsLength = serializationContext . roots . length ;
1347
1354
}
1348
1355
1349
1356
if ( forwardRefs . length ) {
@@ -1462,7 +1469,7 @@ export function qrlToString(
1462
1469
serializedReferences += ' ' ;
1463
1470
}
1464
1471
// We refer by id so every capture needs to be a root
1465
- serializedReferences += serializationContext . $ addRoot$ ( value . $captureRef$ [ i ] ) ;
1472
+ serializedReferences += serializationContext . addRoot ( value . $captureRef$ [ i ] ) ;
1466
1473
}
1467
1474
qrlStringInline += `[${ serializedReferences } ]` ;
1468
1475
} else if ( value . $capture$ && value . $capture$ . length > 0 ) {
@@ -1488,9 +1495,9 @@ export async function _serialize(data: unknown[]): Promise<string> {
1488
1495
) ;
1489
1496
1490
1497
for ( const root of data ) {
1491
- serializationContext . $ addRoot$ ( root ) ;
1498
+ serializationContext . addRoot ( root ) ;
1492
1499
}
1493
- await serializationContext . $ serialize$ ( ) ;
1500
+ await serializationContext . serialize ( ) ;
1494
1501
return serializationContext . $writer$ . toString ( ) ;
1495
1502
}
1496
1503
0 commit comments