@@ -73,6 +73,7 @@ function createLinkedPair(options?: {
7373 name : 'devframes:test' ,
7474 ...noHandshake ,
7575 transport : port2 ,
76+ functions : defaultPanelFunctions ,
7677 ...options ?. panel ,
7778 } )
7879 return {
@@ -167,6 +168,7 @@ describe('in-page channel over bring-your-own ports', () => {
167168 name : 'devframes:test' ,
168169 ...noHandshake ,
169170 transport : port2 ,
171+ functions : defaultPanelFunctions ,
170172 } )
171173 try {
172174 await expect ( panel . call ( 'note' , 'fine' ) ) . resolves . toBeUndefined ( )
@@ -185,6 +187,7 @@ describe('in-page channel over bring-your-own ports', () => {
185187 const pageScript = createPageScriptChannel < TestProtocol > ( {
186188 name : 'devframes:test' ,
187189 ...noHandshake ,
190+ functions : defaultPageScriptFunctions ,
188191 } )
189192 pageScript . addPanelPort ( a . port1 )
190193 pageScript . addPanelPort ( b . port1 )
@@ -200,11 +203,12 @@ describe('in-page channel over bring-your-own ports', () => {
200203 } } ,
201204 } ,
202205 } )
203- // Panel B deliberately implements nothing .
204- const panelB = connectPanelChannel < TestProtocol > ( {
206+ // Panel B deliberately has no local functions in its protocol .
207+ const panelB = connectPanelChannel < InPageChannelProtocol > ( {
205208 name : 'devframes:test' ,
206209 ...noHandshake ,
207210 transport : b . port2 ,
211+ functions : { } ,
208212 } )
209213 try {
210214 expect ( pageScript . panels ) . toHaveLength ( 2 )
@@ -224,6 +228,7 @@ describe('in-page channel over bring-your-own ports', () => {
224228 const pageScript = createPageScriptChannel < TestProtocol > ( {
225229 name : 'devframes:test' ,
226230 ...noHandshake ,
231+ functions : defaultPageScriptFunctions ,
227232 } )
228233 pageScript . addPanelPort ( port1 )
229234 const panel = connectPanelChannel < TestProtocol > ( {
@@ -254,6 +259,7 @@ describe('in-page channel over bring-your-own ports', () => {
254259 name : 'devframes:test' ,
255260 ...noHandshake ,
256261 transport : port2 ,
262+ functions : defaultPanelFunctions ,
257263 // Unwrap a fake reactivity wrapper on the way out, tag on the way in.
258264 serialize : value => ( value && typeof value === 'object' && '__wrapped' in ( value as any ) )
259265 ? ( value as any ) . __wrapped
@@ -274,6 +280,7 @@ describe('in-page channel over bring-your-own ports', () => {
274280 const pageScript = createPageScriptChannel < TestProtocol > ( {
275281 name : 'devframes:test' ,
276282 ...noHandshake ,
283+ functions : defaultPageScriptFunctions ,
277284 } )
278285 const connected : string [ ] = [ ]
279286 const disconnected : string [ ] = [ ]
@@ -284,6 +291,7 @@ describe('in-page channel over bring-your-own ports', () => {
284291 name : 'devframes:test' ,
285292 ...noHandshake ,
286293 transport : port2 ,
294+ functions : defaultPanelFunctions ,
287295 } )
288296 try {
289297 expect ( connected ) . toHaveLength ( 1 )
@@ -324,11 +332,12 @@ describe('in-page channel shared state', () => {
324332 const pageScript = createPageScriptChannel < TestProtocol > ( {
325333 name : 'devframes:test' ,
326334 ...noHandshake ,
335+ functions : defaultPageScriptFunctions ,
327336 } )
328337 pageScript . addPanelPort ( a . port1 )
329338 pageScript . addPanelPort ( b . port1 )
330- const panelA = connectPanelChannel < TestProtocol > ( { name : 'devframes:test' , ...noHandshake , transport : a . port2 } )
331- const panelB = connectPanelChannel < TestProtocol > ( { name : 'devframes:test' , ...noHandshake , transport : b . port2 } )
339+ const panelA = connectPanelChannel < TestProtocol > ( { name : 'devframes:test' , ...noHandshake , transport : a . port2 , functions : defaultPanelFunctions } )
340+ const panelB = connectPanelChannel < TestProtocol > ( { name : 'devframes:test' , ...noHandshake , transport : b . port2 , functions : defaultPanelFunctions } )
332341 try {
333342 const authority = await pageScript . sharedState . get ( 'doc' , { initialValue : { count : 0 } } )
334343 const mirrorA = await panelA . sharedState . get ( 'doc' )
@@ -349,7 +358,7 @@ describe('in-page channel shared state', () => {
349358
350359 it ( 'seeds a late-joining panel with the current value' , async ( ) => {
351360 const { port1, port2 } = new MessageChannel ( )
352- const pageScript = createPageScriptChannel < TestProtocol > ( { name : 'devframes:test' , ...noHandshake } )
361+ const pageScript = createPageScriptChannel < TestProtocol > ( { name : 'devframes:test' , ...noHandshake , functions : defaultPageScriptFunctions } )
353362 const authority = await pageScript . sharedState . get ( 'doc' , { initialValue : { count : 0 } } )
354363 authority . mutate ( ( draft ) => {
355364 draft . count = 41
@@ -359,7 +368,7 @@ describe('in-page channel shared state', () => {
359368 } )
360369
361370 pageScript . addPanelPort ( port1 )
362- const panel = connectPanelChannel < TestProtocol > ( { name : 'devframes:test' , ...noHandshake , transport : port2 } )
371+ const panel = connectPanelChannel < TestProtocol > ( { name : 'devframes:test' , ...noHandshake , transport : port2 , functions : defaultPanelFunctions } )
363372 try {
364373 const mirror = await panel . sharedState . get ( 'doc' )
365374 expect ( mirror . value ( ) ) . toEqual ( { count : 42 } )
@@ -458,6 +467,7 @@ describe('in-page channel handshake', () => {
458467 window : panelWin as unknown as Window ,
459468 targets : [ hostWin as unknown as Window ] ,
460469 ...fastHello ,
470+ functions : defaultPanelFunctions ,
461471 } )
462472 try {
463473 await panel . whenConnected ( 2000 )
@@ -500,6 +510,7 @@ describe('in-page channel handshake', () => {
500510 window : panelWin as unknown as Window ,
501511 targets : [ hostWin as unknown as Window ] ,
502512 ...fastHello ,
513+ functions : defaultPanelFunctions ,
503514 } )
504515 const early = panel . call ( 'echo' , 'early' )
505516 panel . callEvent ( 'note' , 'buffered' )
@@ -533,6 +544,7 @@ describe('in-page channel handshake', () => {
533544 name : 'devframes:test-origin' ,
534545 window : hostWin as unknown as Window ,
535546 heartbeat : false ,
547+ functions : defaultPageScriptFunctions ,
536548 } )
537549 try {
538550 hostWin . __dispatch ( {
@@ -563,6 +575,7 @@ describe('in-page channel handshake', () => {
563575 name : 'devframes:test-version' ,
564576 window : hostWin as unknown as Window ,
565577 heartbeat : false ,
578+ functions : defaultPageScriptFunctions ,
566579 } )
567580 try {
568581 hostWin . __dispatch ( {
@@ -592,13 +605,15 @@ describe('in-page channel handshake', () => {
592605 name : 'devframes:test' ,
593606 window : hostWin as unknown as Window ,
594607 heartbeat : false ,
608+ functions : defaultPageScriptFunctions ,
595609 } )
596610 const pinnedElsewhere = connectPanelChannel < TestProtocol > ( {
597611 name : 'devframes:test' ,
598612 window : panelWin as unknown as Window ,
599613 targets : [ hostWin as unknown as Window ] ,
600614 instanceId : 'some-other-tab' ,
601615 ...fastHello ,
616+ functions : defaultPanelFunctions ,
602617 } )
603618 try {
604619 await expect ( pinnedElsewhere . whenConnected ( 100 ) ) . rejects . toMatchObject ( { code : 'timeout' } )
@@ -609,6 +624,7 @@ describe('in-page channel handshake', () => {
609624 targets : [ hostWin as unknown as Window ] ,
610625 instanceId : pageScript . instanceId ,
611626 ...fastHello ,
627+ functions : defaultPanelFunctions ,
612628 } )
613629 try {
614630 await pinnedHere . whenConnected ( 2000 )
@@ -629,6 +645,7 @@ describe('in-page channel handshake', () => {
629645 name : `devframes:test-lonely-${ Math . random ( ) } ` ,
630646 window : false ,
631647 heartbeat : false ,
648+ functions : defaultPanelFunctions ,
632649 } )
633650 try {
634651 expect ( lonely . status ) . toBe ( 'connecting' )
@@ -647,6 +664,7 @@ describe('in-page channel handshake', () => {
647664 window : false ,
648665 heartbeat : false ,
649666 callTimeoutMs : 50 ,
667+ functions : defaultPanelFunctions ,
650668 } )
651669 try {
652670 const rejection = await lonely . call ( 'echo' , 'nobody' ) . catch ( error => error )
@@ -664,6 +682,7 @@ describe('in-page channel handshake', () => {
664682 name : `devframes:test-lonely-${ Math . random ( ) } ` ,
665683 window : false ,
666684 heartbeat : false ,
685+ functions : defaultPanelFunctions ,
667686 } )
668687 const pending = lonely . call ( 'echo' , 'never' )
669688 const waiting = lonely . whenConnected ( )
0 commit comments