[{"data":1,"prerenderedAt":667},["ShallowReactive",2],{"navigation_docs":3,"-messaging-protocol-maps":133,"-messaging-protocol-maps-surround":664},[4,22,51,62,73,84,99,118],{"title":5,"path":6,"stem":7,"children":8,"page":21},"Get Started","/get-started","0.get-started",[9,13,17],{"title":10,"path":11,"stem":12},"Introduction","/get-started/introduction","0.get-started/0.introduction",{"title":14,"path":15,"stem":16},"Browser Support","/get-started/browser-support","0.get-started/1.browser-support",{"title":18,"path":19,"stem":20},"Contributing","/get-started/contributing","0.get-started/2.contributing",false,{"title":23,"path":24,"stem":25,"children":26,"page":21},"Fake Browser","/fake-browser","fake-browser",[27,31,35,39,43,47],{"title":28,"path":29,"stem":30},"Installation","/fake-browser/installation","fake-browser/0.installation",{"title":32,"path":33,"stem":34},"Testing Frameworks","/fake-browser/testing-frameworks","fake-browser/1.testing-frameworks",{"title":36,"path":37,"stem":38},"Triggering Events","/fake-browser/triggering-events","fake-browser/2.triggering-events",{"title":40,"path":41,"stem":42},"Resetting State","/fake-browser/reseting-state","fake-browser/3.reseting-state",{"title":44,"path":45,"stem":46},"Implemented Apis","/fake-browser/implemented-apis","fake-browser/4.implemented-apis",{"title":48,"path":49,"stem":50},"Api","/fake-browser/api","fake-browser/api",{"title":52,"path":53,"stem":54,"children":55,"page":21},"Isolated Element","/isolated-element","isolated-element",[56,59],{"title":28,"path":57,"stem":58},"/isolated-element/installation","isolated-element/0.installation",{"title":48,"path":60,"stem":61},"/isolated-element/api","isolated-element/api",{"title":63,"path":64,"stem":65,"children":66,"page":21},"Job Scheduler","/job-scheduler","job-scheduler",[67,70],{"title":28,"path":68,"stem":69},"/job-scheduler/installation","job-scheduler/0.installation",{"title":48,"path":71,"stem":72},"/job-scheduler/api","job-scheduler/api",{"title":74,"path":75,"stem":76,"children":77,"page":21},"Match Patterns","/match-patterns","match-patterns",[78,81],{"title":28,"path":79,"stem":80},"/match-patterns/installation","match-patterns/0.installation",{"title":48,"path":82,"stem":83},"/match-patterns/api","match-patterns/api",{"title":85,"path":86,"stem":87,"children":88,"page":21},"Messaging","/messaging","messaging",[89,92,96],{"title":28,"path":90,"stem":91},"/messaging/installation","messaging/0.installation",{"title":93,"path":94,"stem":95},"Protocol Maps","/messaging/protocol-maps","messaging/1.protocol-maps",{"title":48,"path":97,"stem":98},"/messaging/api","messaging/api",{"title":100,"path":101,"stem":102,"children":103,"page":21},"Proxy Service","/proxy-service","proxy-service",[104,107,111,115],{"title":28,"path":105,"stem":106},"/proxy-service/installation","proxy-service/0.installation",{"title":108,"path":109,"stem":110},"Defining Services","/proxy-service/defining-services","proxy-service/1.defining-services",{"title":112,"path":113,"stem":114},"Service Keys","/proxy-service/service-keys","proxy-service/2.service-keys",{"title":48,"path":116,"stem":117},"/proxy-service/api","proxy-service/api",{"title":119,"path":120,"stem":121,"children":122,"page":21},"Storage","/storage","storage",[123,126,130],{"title":28,"path":124,"stem":125},"/storage/installation","storage/0.installation",{"title":127,"path":128,"stem":129},"Typescript","/storage/typescript","storage/1.typescript",{"title":48,"path":131,"stem":132},"/storage/api","storage/api",{"id":134,"title":93,"body":135,"description":177,"extension":659,"links":660,"meta":661,"navigation":296,"path":94,"seo":662,"stem":95,"__hash__":663},"docs/messaging/1.protocol-maps.md",{"type":136,"value":137,"toc":653},"minimark",[138,142,147,160,164,171,346,355,515,519,530,562,566,575,602,649],[139,140,141],"alert",{},"Only relevant to TypeScript projects.",[143,144,146],"h2",{"id":145},"overview","Overview",[148,149,150,151,155,156,159],"p",{},"Protocol maps define types for ",[152,153,154],"code",{},"sendMessage"," and ",[152,157,158],{},"onMessage"," in a single place. You'll never need to write type parameters; the data and return types will be inferred automatically!",[143,161,163],{"id":162},"syntax","Syntax",[148,165,166,167,170],{},"Protocol maps are simple interfaces passed into ",[152,168,169],{},"defineExtensionMessaging",". They specify a list of valid message types, as well as each message's data type and return type.",[172,173,178],"pre",{"className":174,"code":175,"language":176,"meta":177,"style":177},"language-ts shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","interface ProtocolMap {\n  message1(): void;                // No data and no return type\n  message2(data: string): void;    // Only data\n  message3(): boolean;             // Only a return type\n  message4(data: string): boolean; // Data and return type\n}\n\nexport const { sendMessage, onMessage } = defineExtensionMessaging\u003CProtocolMap>();\n","ts","",[152,179,180,197,217,246,262,285,291,298],{"__ignoreMap":177},[181,182,185,189,193],"span",{"class":183,"line":184},"line",1,[181,186,188],{"class":187},"spNyl","interface",[181,190,192],{"class":191},"sBMFI"," ProtocolMap",[181,194,196],{"class":195},"sMK4o"," {\n",[181,198,200,204,207,210,213],{"class":183,"line":199},2,[181,201,203],{"class":202},"swJcz","  message1",[181,205,206],{"class":195},"():",[181,208,209],{"class":191}," void",[181,211,212],{"class":195},";",[181,214,216],{"class":215},"sHwdD","                // No data and no return type\n",[181,218,220,223,226,230,233,236,239,241,243],{"class":183,"line":219},3,[181,221,222],{"class":202},"  message2",[181,224,225],{"class":195},"(",[181,227,229],{"class":228},"sHdIc","data",[181,231,232],{"class":195},":",[181,234,235],{"class":191}," string",[181,237,238],{"class":195},"):",[181,240,209],{"class":191},[181,242,212],{"class":195},[181,244,245],{"class":215},"    // Only data\n",[181,247,249,252,254,257,259],{"class":183,"line":248},4,[181,250,251],{"class":202},"  message3",[181,253,206],{"class":195},[181,255,256],{"class":191}," boolean",[181,258,212],{"class":195},[181,260,261],{"class":215},"             // Only a return type\n",[181,263,265,268,270,272,274,276,278,280,282],{"class":183,"line":264},5,[181,266,267],{"class":202},"  message4",[181,269,225],{"class":195},[181,271,229],{"class":228},[181,273,232],{"class":195},[181,275,235],{"class":191},[181,277,238],{"class":195},[181,279,256],{"class":191},[181,281,212],{"class":195},[181,283,284],{"class":215}," // Data and return type\n",[181,286,288],{"class":183,"line":287},6,[181,289,290],{"class":195},"}\n",[181,292,294],{"class":183,"line":293},7,[181,295,297],{"emptyLinePlaceholder":296},true,"\n",[181,299,301,305,308,311,315,318,321,324,327,331,334,337,340,343],{"class":183,"line":300},8,[181,302,304],{"class":303},"s7zQu","export",[181,306,307],{"class":187}," const",[181,309,310],{"class":195}," {",[181,312,314],{"class":313},"sTEyZ"," sendMessage",[181,316,317],{"class":195},",",[181,319,320],{"class":313}," onMessage ",[181,322,323],{"class":195},"}",[181,325,326],{"class":195}," =",[181,328,330],{"class":329},"s2Zo4"," defineExtensionMessaging",[181,332,333],{"class":195},"\u003C",[181,335,336],{"class":191},"ProtocolMap",[181,338,339],{"class":195},">",[181,341,342],{"class":313},"()",[181,344,345],{"class":195},";\n",[148,347,348,349,351,352,354],{},"When calling ",[152,350,154],{}," or ",[152,353,158],{},", all the types will be inferred:",[172,356,358],{"className":174,"code":357,"language":176,"meta":177,"style":177},"onMessage('message2', ({ data /* string */ }) /* : void */ => {});\nonMessage('message3', (message) /* : boolean */ => true);\n\nconst res /* : boolean */ = await sendMessage('message3', undefined);\nconst res /* : boolean */ = await sendMessage('message4', 'text');\n",[152,359,360,409,440,444,478],{"__ignoreMap":177},[181,361,362,364,366,369,373,375,377,380,383,386,389,392,395,398,401,404,407],{"class":183,"line":184},[181,363,158],{"class":329},[181,365,225],{"class":313},[181,367,368],{"class":195},"'",[181,370,372],{"class":371},"sfazB","message2",[181,374,368],{"class":195},[181,376,317],{"class":195},[181,378,379],{"class":313}," (",[181,381,382],{"class":195},"{",[181,384,385],{"class":313}," data ",[181,387,388],{"class":215},"/* string */",[181,390,391],{"class":195}," }",[181,393,394],{"class":313},") ",[181,396,397],{"class":215},"/* : void */",[181,399,400],{"class":187}," =>",[181,402,403],{"class":195}," {}",[181,405,406],{"class":313},")",[181,408,345],{"class":195},[181,410,411,413,415,417,420,422,424,427,430,432,436,438],{"class":183,"line":199},[181,412,158],{"class":329},[181,414,225],{"class":313},[181,416,368],{"class":195},[181,418,419],{"class":371},"message3",[181,421,368],{"class":195},[181,423,317],{"class":195},[181,425,426],{"class":313}," (message) ",[181,428,429],{"class":215},"/* : boolean */",[181,431,400],{"class":187},[181,433,435],{"class":434},"sfNiH"," true",[181,437,406],{"class":313},[181,439,345],{"class":195},[181,441,442],{"class":183,"line":219},[181,443,297],{"emptyLinePlaceholder":296},[181,445,446,449,452,454,456,459,461,463,465,467,469,471,474,476],{"class":183,"line":248},[181,447,448],{"class":187},"const",[181,450,451],{"class":313}," res ",[181,453,429],{"class":215},[181,455,326],{"class":195},[181,457,458],{"class":303}," await",[181,460,314],{"class":329},[181,462,225],{"class":313},[181,464,368],{"class":195},[181,466,419],{"class":371},[181,468,368],{"class":195},[181,470,317],{"class":195},[181,472,473],{"class":195}," undefined",[181,475,406],{"class":313},[181,477,345],{"class":195},[181,479,480,482,484,486,488,490,492,494,496,499,501,503,506,509,511,513],{"class":183,"line":264},[181,481,448],{"class":187},[181,483,451],{"class":313},[181,485,429],{"class":215},[181,487,326],{"class":195},[181,489,458],{"class":303},[181,491,314],{"class":329},[181,493,225],{"class":313},[181,495,368],{"class":195},[181,497,498],{"class":371},"message4",[181,500,368],{"class":195},[181,502,317],{"class":195},[181,504,505],{"class":195}," '",[181,507,508],{"class":371},"text",[181,510,368],{"class":195},[181,512,406],{"class":313},[181,514,345],{"class":195},[143,516,518],{"id":517},"async-messages","Async Messages",[148,520,521,522,525,526,529],{},"All messages are async. In your protocol map, you don't need to make the return type ",[152,523,524],{},"Promise\u003CT>",", ",[152,527,528],{},"T"," will work just fine.",[172,531,535],{"className":532,"code":533,"language":534,"meta":177,"style":177},"language-diff shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","interface ProtocolMap {\n- someMessage(): Promise\u003Cstring>;\n+ someMessage(): string;\n}\n","diff",[152,536,537,542,550,558],{"__ignoreMap":177},[181,538,539],{"class":183,"line":184},[181,540,541],{"class":313},"interface ProtocolMap {\n",[181,543,544,547],{"class":183,"line":199},[181,545,546],{"class":195},"-",[181,548,549],{"class":202}," someMessage(): Promise\u003Cstring>;\n",[181,551,552,555],{"class":183,"line":219},[181,553,554],{"class":195},"+",[181,556,557],{"class":371}," someMessage(): string;\n",[181,559,560],{"class":183,"line":248},[181,561,290],{"class":313},[143,563,565],{"id":564},"multiple-arguments","Multiple Arguments",[148,567,568,569,571,572,574],{},"Protocol map functions should be defined with a single parameter, ",[152,570,229],{},". To pass more than one argument, make the ",[152,573,229],{}," parameter an object instead!",[172,576,578],{"className":532,"code":577,"language":534,"meta":177,"style":177},"interface ProtocolMap {\n- someMessage(arg1: string, arg2: boolean): void;\n+ someMessage(data: { arg1: string; arg2: boolean }): void;\n}\n",[152,579,580,584,591,598],{"__ignoreMap":177},[181,581,582],{"class":183,"line":184},[181,583,541],{"class":313},[181,585,586,588],{"class":183,"line":199},[181,587,546],{"class":195},[181,589,590],{"class":202}," someMessage(arg1: string, arg2: boolean): void;\n",[181,592,593,595],{"class":183,"line":219},[181,594,554],{"class":195},[181,596,597],{"class":371}," someMessage(data: { arg1: string; arg2: boolean }): void;\n",[181,599,600],{"class":183,"line":248},[181,601,290],{"class":313},[172,603,605],{"className":174,"code":604,"language":176,"meta":177,"style":177},"await sendMessage('someMessage', { arg1: ..., arg2: ... });\n",[152,606,607],{"__ignoreMap":177},[181,608,609,612,614,616,618,621,623,625,627,630,632,635,638,640,643,645,647],{"class":183,"line":184},[181,610,611],{"class":303},"await",[181,613,314],{"class":329},[181,615,225],{"class":313},[181,617,368],{"class":195},[181,619,620],{"class":371},"someMessage",[181,622,368],{"class":195},[181,624,317],{"class":195},[181,626,310],{"class":195},[181,628,629],{"class":202}," arg1",[181,631,232],{"class":195},[181,633,634],{"class":195}," ...,",[181,636,637],{"class":202}," arg2",[181,639,232],{"class":195},[181,641,642],{"class":195}," ...",[181,644,391],{"class":195},[181,646,406],{"class":313},[181,648,345],{"class":195},[650,651,652],"style",{},"html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .swJcz, html code.shiki .swJcz{--shiki-light:#E53935;--shiki-default:#F07178;--shiki-dark:#F07178}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html pre.shiki code .sHdIc, html code.shiki .sHdIc{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#EEFFFF;--shiki-default-font-style:italic;--shiki-dark:#BABED8;--shiki-dark-font-style:italic}html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}html pre.shiki code .sfNiH, html code.shiki .sfNiH{--shiki-light:#FF5370;--shiki-default:#FF9CAC;--shiki-dark:#FF9CAC}",{"title":177,"searchDepth":199,"depth":199,"links":654},[655,656,657,658],{"id":145,"depth":199,"text":146},{"id":162,"depth":199,"text":163},{"id":517,"depth":199,"text":518},{"id":564,"depth":199,"text":565},"md",null,{},{"title":93,"description":177},"MDAWUUAKa1OuqfUzJmbXec-q3lepcmySYQPqIf8atwE",[665,666],{"title":28,"path":90,"stem":91,"description":177,"children":-1},{"title":48,"path":97,"stem":98,"description":177,"children":-1},1779298649203]