@@ -57,8 +57,9 @@ export type ResponseState = {
57
57
placeholderPrefix : PrecomputedChunk ,
58
58
segmentPrefix : PrecomputedChunk ,
59
59
boundaryPrefix : string ,
60
- opaqueIdentifierPrefix : PrecomputedChunk ,
60
+ opaqueIdentifierPrefix : string ,
61
61
nextSuspenseID : number ,
62
+ nextOpaqueID : number ,
62
63
sentCompleteSegmentFunction : boolean ,
63
64
sentCompleteBoundaryFunction : boolean ,
64
65
sentClientRenderFunction : boolean ,
@@ -72,8 +73,9 @@ export function createResponseState(
72
73
placeholderPrefix : stringToPrecomputedChunk ( identifierPrefix + 'P:' ) ,
73
74
segmentPrefix : stringToPrecomputedChunk ( identifierPrefix + 'S:' ) ,
74
75
boundaryPrefix : identifierPrefix + 'B:' ,
75
- opaqueIdentifierPrefix : stringToPrecomputedChunk ( identifierPrefix + 'R:' ) ,
76
+ opaqueIdentifierPrefix : identifierPrefix + 'R:' ,
76
77
nextSuspenseID : 0 ,
78
+ nextOpaqueID : 0 ,
77
79
sentCompleteSegmentFunction : false ,
78
80
sentCompleteBoundaryFunction : false ,
79
81
sentClientRenderFunction : false ,
@@ -172,6 +174,21 @@ export function createSuspenseBoundaryID(
172
174
return { formattedID : null } ;
173
175
}
174
176
177
+ export type OpaqueIDType = string ;
178
+
179
+ export function makeServerID (
180
+ responseState : null | ResponseState ,
181
+ ) : OpaqueIDType {
182
+ invariant (
183
+ responseState !== null ,
184
+ 'Invalid hook call. Hooks can only be called inside of the body of a function component.' ,
185
+ ) ;
186
+ return (
187
+ responseState . opaqueIdentifierPrefix +
188
+ ( responseState . nextOpaqueID ++ ) . toString ( 36 )
189
+ ) ;
190
+ }
191
+
175
192
function encodeHTMLTextNode ( text : string ) : string {
176
193
return escapeTextForBrowser ( text ) ;
177
194
}
0 commit comments