@@ -211,6 +211,52 @@ describe('processVnodeData', () => {
211
211
} ) ;
212
212
} ) ;
213
213
214
+ describe ( 'emitVNodeSeparators' , ( ) => {
215
+ it ( 'should encode binary correctly' , ( ) => {
216
+ expect ( emitVNodeSeparators ( 0 , 1 ) ) . toBe ( VNodeDataSeparator . ADVANCE_1_CH ) ;
217
+ expect ( emitVNodeSeparators ( 0 , 2 ) ) . toBe ( VNodeDataSeparator . ADVANCE_2_CH ) ;
218
+ expect ( emitVNodeSeparators ( 0 , 4 ) ) . toBe ( VNodeDataSeparator . ADVANCE_4_CH ) ;
219
+ expect ( emitVNodeSeparators ( 0 , 8 ) ) . toBe ( VNodeDataSeparator . ADVANCE_8_CH ) ;
220
+ expect ( emitVNodeSeparators ( 0 , 16 ) ) . toBe ( VNodeDataSeparator . ADVANCE_16_CH ) ;
221
+ expect ( emitVNodeSeparators ( 0 , 32 ) ) . toBe ( VNodeDataSeparator . ADVANCE_32_CH ) ;
222
+ expect ( emitVNodeSeparators ( 0 , 64 ) ) . toBe ( VNodeDataSeparator . ADVANCE_64_CH ) ;
223
+ expect ( emitVNodeSeparators ( 0 , 128 ) ) . toBe ( VNodeDataSeparator . ADVANCE_128_CH ) ;
224
+ expect ( emitVNodeSeparators ( 0 , 256 ) ) . toBe ( VNodeDataSeparator . ADVANCE_256_CH ) ;
225
+ expect ( emitVNodeSeparators ( 0 , 512 ) ) . toBe ( VNodeDataSeparator . ADVANCE_512_CH ) ;
226
+ expect ( emitVNodeSeparators ( 0 , 1024 ) ) . toBe ( VNodeDataSeparator . ADVANCE_1024_CH ) ;
227
+ expect ( emitVNodeSeparators ( 0 , 2048 ) ) . toBe ( VNodeDataSeparator . ADVANCE_2048_CH ) ;
228
+ expect ( emitVNodeSeparators ( 0 , 4096 ) ) . toBe ( VNodeDataSeparator . ADVANCE_4096_CH ) ;
229
+ expect ( emitVNodeSeparators ( 0 , 8192 ) ) . toBe ( VNodeDataSeparator . ADVANCE_8192_CH ) ;
230
+ } ) ;
231
+ it ( 'should encode combinations correctly' , ( ) => {
232
+ expect ( emitVNodeSeparators ( 0 , 3 ) ) . toBe (
233
+ VNodeDataSeparator . ADVANCE_2_CH + VNodeDataSeparator . ADVANCE_1_CH
234
+ ) ;
235
+ expect ( emitVNodeSeparators ( 0 , 7 ) ) . toBe (
236
+ VNodeDataSeparator . ADVANCE_4_CH +
237
+ VNodeDataSeparator . ADVANCE_2_CH +
238
+ VNodeDataSeparator . ADVANCE_1_CH
239
+ ) ;
240
+ expect ( emitVNodeSeparators ( 0 , 15 ) ) . toBe (
241
+ VNodeDataSeparator . ADVANCE_8_CH +
242
+ VNodeDataSeparator . ADVANCE_4_CH +
243
+ VNodeDataSeparator . ADVANCE_2_CH +
244
+ VNodeDataSeparator . ADVANCE_1_CH
245
+ ) ;
246
+ expect ( emitVNodeSeparators ( 0 , 4097 ) ) . toBe (
247
+ VNodeDataSeparator . ADVANCE_4096_CH + VNodeDataSeparator . ADVANCE_1_CH
248
+ ) ;
249
+ expect ( emitVNodeSeparators ( 0 , 8193 ) ) . toBe (
250
+ VNodeDataSeparator . ADVANCE_8192_CH + VNodeDataSeparator . ADVANCE_1_CH
251
+ ) ;
252
+ expect ( emitVNodeSeparators ( 0 , 16385 ) ) . toBe (
253
+ VNodeDataSeparator . ADVANCE_8192_CH +
254
+ VNodeDataSeparator . ADVANCE_8192_CH +
255
+ VNodeDataSeparator . ADVANCE_1_CH
256
+ ) ;
257
+ } ) ;
258
+ } ) ;
259
+
214
260
const qContainerPaused = { [ QContainerAttr ] : QContainerValue . RESUMED } ;
215
261
const qContainerHtml = { [ QContainerAttr ] : QContainerValue . HTML } ;
216
262
function process ( html : string ) : ClientContainer [ ] {
@@ -261,12 +307,13 @@ function encodeVNode(data: Record<number, string> = {}) {
261
307
return `<script type="qwik/vnode">${ result } </script>` ;
262
308
}
263
309
310
+ // Keep in sync with ssr-container.ts
264
311
function emitVNodeSeparators ( lastSerializedIdx : number , elementIdx : number ) : string {
265
312
let result = '' ;
266
313
let skipCount = elementIdx - lastSerializedIdx ;
267
314
// console.log('emitVNodeSeparators', lastSerializedIdx, elementIdx, skipCount);
268
315
while ( skipCount != 0 ) {
269
- if ( skipCount > 4096 ) {
316
+ if ( skipCount >= 8192 ) {
270
317
result += VNodeDataSeparator . ADVANCE_8192_CH ;
271
318
skipCount -= 8192 ;
272
319
} else {
0 commit comments