1"use strict";(self.webpackChunkelectronjs=self.webpackChunkelectronjs||[]).push([["34581"],{9998(e,n,t){t.r(n),t.d(n,{metadata:()=>s,default:()=>u,frontMatter:()=>l,contentTitle:()=>c,toc:()=>d,assets:()=>a});var s=JSON.parse('{"id":"latest/api/service-workers","title":"Class: ServiceWorkers","description":"Query and receive events from a sessions active service workers.","source":"@site/docs/latest/api/service-workers.md","sourceDirName":"latest/api","slug":"/latest/api/service-workers","permalink":"/docs/latest/api/service-workers","draft":false,"unlisted":false,"editUrl":"https://github.com/electron/electron/edit/main/docs/api/service-workers.md","tags":[],"version":"current","frontMatter":{"title":"Class: ServiceWorkers","description":"Query and receive events from a sessions active service workers.","slug":"service-workers","hide_title":false},"sidebar":"api","previous":{"title":"Class: ServiceWorkerMain","permalink":"/docs/latest/api/service-worker-main"},"next":{"title":"Class: TouchBarButton","permalink":"/docs/latest/api/touch-bar-button"}}'),r=t(74848),o=t(28453),i=t(40329);let l={title:"Class: ServiceWorkers",description:"Query and receive events from a sessions active service workers.",slug:"service-workers",hide_title:!1},c,a={},d=[{value:"Class: ServiceWorkers",id:"class-serviceworkers",level:2},{value:"Instance Events",id:"instance-events",level:3},{value:"Event: 'console-message'",id:"event-console-message",level:4},{value:"Event: 'registration-completed'",id:"event-registration-completed",level:4},{value:"Event: 'running-status-changed' <em>Experimental</em>",id:"event-running-status-changed-experimental",level:4},{value:"Instance Methods",id:"instance-methods",level:3},{value:"<code>serviceWorkers.getAllRunning()</code>",id:"serviceworkersgetallrunning",level:4},{value:"<code>serviceWorkers.getInfoFromVersionID(versionId)</code>",id:"serviceworkersgetinfofromversionidversionid",level:4},{value:"<code>serviceWorkers.getFromVersionID(versionId)</code> <em>Deprecated</em>",id:"serviceworkersgetfromversionidversionid-deprecated",level:4},{value:"<code>serviceWorkers.getWorkerFromVersionID(versionId)</code> <em>Experimental</em>",id:"serviceworkersgetworkerfromversionidversionid-experimental",level:4},{value:"<code>serviceWorkers.startWorkerForScope(scope)</code> <em>Experimental</em>",id:"serviceworkersstartworkerforscopescope-experimental",level:4}];function f(e){let n={a:"a",blockquote:"blockquote",code:"code",em:"em",h2:"h2",h3:"h3",h4:"h4",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,o.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.h2,{id:"class-serviceworkers",children:"Class: ServiceWorkers"}),"\n",(0,r.jsxs)(n.blockquote,{children:["\n",(0,r.jsx)(n.p,{children:"Query and receive events from a sessions active service workers."}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["Process: ",(0,r.jsx)(n.a,{href:"/docs/latest/glossary#main-process",children:"Main"}),(0,r.jsx)("br",{}),"\n",(0,r.jsxs)(n.em,{children:["This class is not exported from the ",(0,r.jsx)(n.code,{children:"'electron'"})," module. It is only available as a return value of other methods in the Electron API."]})]}),"\n",(0,r.jsxs)(n.p,{children:["Instances of the ",(0,r.jsx)(n.code,{children:"ServiceWorkers"})," class are accessed by using ",(0,r.jsx)(n.code,{children:"serviceWorkers"})," property of\na ",(0,r.jsx)(n.code,{children:"Session"}),"."]}),"\n",(0,r.jsx)(n.p,{children:"For example:"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-js",children:"const { session } = require('electron')\n\n// Get all service workers.\nconsole.log(session.defaultSession.serviceWorkers.getAllRunning())\n\n// Handle logs and get service worker info\nsession.defaultSession.serviceWorkers.on('console-message', (event, messageDetails) => {\n console.log(\n 'Got service worker message',\n messageDetails,\n 'from',\n session.defaultSession.serviceWorkers.getFromVersionID(messageDetails.versionId)\n )\n})\n"})}),"\n",(0,r.jsx)(n.h3,{id:"instance-events",children:"Instance Events"}),"\n",(0,r.jsxs)(n.p,{children:["The following events are available on instances of ",(0,r.jsx)(n.code,{children:"ServiceWorkers"}),":"]}),"\n",(0,r.jsx)(n.h4,{id:"event-console-message",children:"Event: 'console-message'"}),"\n",(0,r.jsx)(n.p,{children:"Returns:"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"event"})," Event"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"messageDetails"})," Object - Information about the console message","\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"message"})," string - The actual console message"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"versionId"})," number - The version ID of the service worker that sent the log message"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"source"})," string - The type of source for this message. Can be ",(0,r.jsx)(n.code,{children:"javascript"}),", ",(0,r.jsx)(n.code,{children:"xml"}),", ",(0,r.jsx)(n.code,{children:"network"}),", ",(0,r.jsx)(n.code,{children:"console-api"}),", ",(0,r.jsx)(n.code,{children:"storage"}),", ",(0,r.jsx)(n.code,{children:"rendering"}),", ",(0,r.jsx)(n.code,{children:"security"}),", ",(0,r.jsx)(n.code,{children:"deprecation"}),", ",(0,r.jsx)(n.code,{children:"worker"}),", ",(0,r.jsx)(n.code,{children:"violation"}),", ",(0,r.jsx)(n.code,{children:"intervention"}),", ",(0,r.jsx)(n.code,{children:"recommendation"})," or ",(0,r.jsx)(n.code,{children:"other"}),"."]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"level"})," number - The log level, from 0 to 3. In order it matches ",(0,r.jsx)(n.code,{children:"verbose"}),", ",(0,r.jsx)(n.code,{children:"info"}),", ",(0,r.jsx)(n.code,{children:"warning"})," and ",(0,r.jsx)(n.code,{children:"error"}),"."]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"sourceUrl"})," string - The URL the message came from"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"lineNumber"})," number - The line number of the source that triggered this console message"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"Emitted when a service worker logs something to the console."}),"\n",(0,r.jsx)(n.h4,{id:"event-registration-completed",children:"Event: 'registration-completed'"}),"\n",(0,r.jsx)(n.p,{children:"Returns:"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"event"})," Event"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"details"})," Object - Information about the registered service worker","\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"scope"})," string - The base URL that a service worker is registered for"]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["Emitted when a service worker has been registered. Can occur after a call to ",(0,r.jsx)(n.a,{href:"https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register",children:(0,r.jsx)(n.code,{children:"navigator.serviceWorker.register('/sw.js')"})})," successfully resolves or when a Chrome extension is loaded."]}),"\n",(0,r.jsxs)(n.h4,{id:"event-running-status-changed-experimental",children:["Event: 'running-status-changed' ",(0,r.jsx)(n.em,{className:"badge badge--warning",children:"Experimental"})]}),"\n",(0,r.jsx)(n.p,{children:"Returns:"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"details"})," Event<>","\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"versionId"})," number - ID of the updated service worker version"]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"runningStatus"})," string - Running status.\nPossible values include ",(0,r.jsx)(n.code,{children:"starting"}),", ",(0,r.jsx)(n.code,{children:"running"}),", ",(0,r.jsx)(n.code,{children:"stopping"}),", or ",(0,r.jsx)(n.code,{children:"stopped"}),"."]}),"\n"]}),"\n"]}),"\n"]}),"\n",(0,r.jsx)(n.p,{children:"Emitted when a service worker's running status has changed."}),"\n",(0,r.jsx)(n.h3,{id:"instance-methods",children:"Instance Methods"}),"\n",(0,r.jsxs)(n.p,{children:["The following methods are available on instances of ",(0,r.jsx)(n.code,{children:"ServiceWorkers"}),":"]}),"\n",(0,r.jsx)(n.h4,{id:"serviceworkersgetallrunning",children:(0,r.jsx)(n.code,{children:"serviceWorkers.getAllRunning()"})}),"\n",(0,r.jsxs)(n.p,{children:["Returns ",(0,r.jsx)(n.code,{children:"Record<number, ServiceWorkerInfo>"})," - A ",(0,r.jsx)(i.A,{url:"/docs/latest/api/structures/service-worker-info",title:"ServiceWorkerInfo",content:'{"type":"root","children":[{"type":"element","tagName":"h1","properties":{},"children":[{"type":"text","value":"ServiceWorkerInfo Object"}]},{"type":"text","value":"\\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"scriptUrl","position":{"start":{"line":10,"column":3,"offset":133},"end":{"line":10,"column":14,"offset":144}}}],"position":{"start":{"line":10,"column":3,"offset":133},"end":{"line":10,"column":14,"offset":144}}},{"type":"text","value":" string - The full URL to the script that this service worker runs","position":{"start":{"line":10,"column":14,"offset":144},"end":{"line":10,"column":80,"offset":210}}}],"position":{"start":{"line":10,"column":1,"offset":131},"end":{"line":10,"column":80,"offset":210}}},{"type":"text","value":"\\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"scope","position":{"start":{"line":11,"column":3,"offset":213},"end":{"line":11,"column":10,"offset":220}}}],"position":{"start":{"line":11,"column":3,"offset":213},"end":{"line":11,"column":10,"offset":220}}},{"type":"text","value":" string - The base URL that this service worker is active for.","position":{"start":{"line":11,"column":10,"offset":220},"end":{"line":11,"column":72,"offset":282}}}],"position":{"start":{"line":11,"column":1,"offset":211},"end":{"line":11,"column":72,"offset":282}}},{"type":"text","value":"\\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"renderProcessId","position":{"start":{"line":12,"column":3,"offset":285},"end":{"line":12,"column":20,"offset":302}}}],"position":{"start":{"line":12,"column":3,"offset":285},"end":{"line":12,"column":20,"offset":302}}},{"type":"text","value":" number - The virtual ID of the process that this service worker is running in. This is not an OS level PID. This aligns with the ID set used for ","position":{"start":{"line":12,"column":20,"offset":302},"end":{"line":12,"column":168,"offset":450}}},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"webContents.getProcessId()","position":{"start":{"line":12,"column":168,"offset":450},"end":{"line":12,"column":196,"offset":478}}}],"position":{"start":{"line":12,"column":168,"offset":450},"end":{"line":12,"column":196,"offset":478}}},{"type":"text","value":".","position":{"start":{"line":12,"column":196,"offset":478},"end":{"line":12,"column":197,"offset":479}}}],"position":{"start":{"line":12,"column":1,"offset":283},"end":{"line":12,"column":197,"offset":479}}},{"type":"text","value":"\\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"versionId","position":{"start":{"line":13,"column":3,"offset":482},"end":{"line":13,"column":14,"offset":493}}}],"position":{"start":{"line":13,"column":3,"offset":482},"end":{"line":13,"column":14,"offset":493}}},{"type":"text","value":" number - ID of the service worker version","position":{"start":{"line":13,"column":14,"offset":493},"end":{"line":13,"column":56,"offset":535}}}],"position":{"start":{"line":13,"column":1,"offset":480},"end":{"line":13,"column":56,"offset":535}}},{"type":"text","value":"\\n"}],"position":{"start":{"line":10,"column":1,"offset":131},"end":{"line":13,"column":56,"offset":535}}}],"position":{"start":{"line":1,"column":1,"offset":0},"end":{"line":14,"column":1,"offset":536}}}'})," object where the keys are the service worker version ID and the values are the information about that service worker."]}),"\n",(0,r.jsx)(n.h4,{id:"serviceworkersgetinfofromversionidversionid",children:(0,r.jsx)(n.code,{children:"serviceWorkers.getInfoFromVersionID(versionId)"})}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"versionId"})," number - ID of the service worker version"]}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["Returns ",(0,r.jsx)(i.A,{url:"/docs/latest/api/structures/service-worker-info",title:"ServiceWorkerInfo",content:'{"type":"root","children":[{"type":"element","tagName":"h1","properties":{},"children":[{"type":"text","value":"ServiceWorkerInfo Object"}]},{"type":"text","value":"\\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"scriptUrl","position":{"start":{"line":10,"column":3,"offset":133},"end":{"line":10,"column":14,"offset":144}}}],"position":{"start":{"line":10,"column":3,"offset":133},"end":{"line":10,"column":14,"offset":144}}},{"type":"text","value":" string - The full URL to the script that this service worker runs","position":{"start":{"line":10,"column":14,"offset":144},"end":{"line":10,"column":80,"offset":210}}}],"position":{"start":{"line":10,"column":1,"offset":131},"end":{"line":10,"column":80,"offset":210}}},{"type":"text","value":"\\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"scope","position":{"start":{"line":11,"column":3,"offset":213},"end":{"line":11,"column":10,"offset":220}}}],"position":{"start":{"line":11,"column":3,"offset":213},"end":{"line":11,"column":10,"offset":220}}},{"type":"text","value":" string - The base URL that this service worker is active for.","position":{"start":{"line":11,"column":10,"offset":220},"end":{"line":11,"column":72,"offset":282}}}],"position":{"start":{"line":11,"column":1,"offset":211},"end":{"line":11,"column":72,"offset":282}}},{"type":"text","value":"\\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"renderProcessId","position":{"start":{"line":12,"column":3,"offset":285},"end":{"line":12,"column":20,"offset":302}}}],"position":{"start":{"line":12,"column":3,"offset":285},"end":{"line":12,"column":20,"offset":302}}},{"type":"text","value":" number - The virtual ID of the process that this service worker is running in. This is not an OS level PID. This aligns with the ID set used for ","position":{"start":{"line":12,"column":20,"offset":302},"end":{"line":12,"column":168,"offset":450}}},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"webContents.getProcessId()","position":{"start":{"line":12,"column":168,"offset":450},"end":{"line":12,"column":196,"offset":478}}}],"position":{"start":{"line":12,"column":168,"offset":450},"end":{"line":12,"column":196,"offset":478}}},{"type":"text","value":".","position":{"start":{"line":12,"column":196,"offset":478},"end":{"line":12,"column":197,"offset":479}}}],"position":{"start":{"line":12,"column":1,"offset":283},"end":{"line":12,"column":197,"offset":479}}},{"type":"text","value":"\\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"versionId","position":{"start":{"line":13,"column":3,"offset":482},"end":{"line":13,"column":14,"offset":493}}}],"position":{"start":{"line":13,"column":3,"offset":482},"end":{"line":13,"column":14,"offset":493}}},{"type":"text","value":" number - ID of the service worker v
1ersion","position":{"start":{"line":13,"column":14,"offset":493},"end":{"line":13,"column":56,"offset":535}}}],"position":{"start":{"line":13,"column":1,"offset":480},"end":{"line":13,"column":56,"offset":535}}},{"type":"text","value":"\\n"}],"position":{"start":{"line":10,"column":1,"offset":131},"end":{"line":13,"column":56,"offset":535}}}],"position":{"start":{"line":1,"column":1,"offset":0},"end":{"line":14,"column":1,"offset":536}}}'})," - Information about this service worker"]}),"\n",(0,r.jsx)(n.p,{children:"If the service worker does not exist or is not running this method will throw an exception."}),"\n",(0,r.jsxs)(n.h4,{id:"serviceworkersgetfromversionidversionid-deprecated",children:[(0,r.jsx)(n.code,{children:"serviceWorkers.getFromVersionID(versionId)"})," ",(0,r.jsx)(n.em,{className:"badge badge--danger",children:"Deprecated"})]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"versionId"})," number - ID of the service worker version"]}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["Returns ",(0,r.jsx)(i.A,{url:"/docs/latest/api/structures/service-worker-info",title:"ServiceWorkerInfo",content:'{"type":"root","children":[{"type":"element","tagName":"h1","properties":{},"children":[{"type":"text","value":"ServiceWorkerInfo Object"}]},{"type":"text","value":"\\n"},{"type":"element","tagName":"ul","properties":{},"children":[{"type":"text","value":"\\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"scriptUrl","position":{"start":{"line":10,"column":3,"offset":133},"end":{"line":10,"column":14,"offset":144}}}],"position":{"start":{"line":10,"column":3,"offset":133},"end":{"line":10,"column":14,"offset":144}}},{"type":"text","value":" string - The full URL to the script that this service worker runs","position":{"start":{"line":10,"column":14,"offset":144},"end":{"line":10,"column":80,"offset":210}}}],"position":{"start":{"line":10,"column":1,"offset":131},"end":{"line":10,"column":80,"offset":210}}},{"type":"text","value":"\\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"scope","position":{"start":{"line":11,"column":3,"offset":213},"end":{"line":11,"column":10,"offset":220}}}],"position":{"start":{"line":11,"column":3,"offset":213},"end":{"line":11,"column":10,"offset":220}}},{"type":"text","value":" string - The base URL that this service worker is active for.","position":{"start":{"line":11,"column":10,"offset":220},"end":{"line":11,"column":72,"offset":282}}}],"position":{"start":{"line":11,"column":1,"offset":211},"end":{"line":11,"column":72,"offset":282}}},{"type":"text","value":"\\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"renderProcessId","position":{"start":{"line":12,"column":3,"offset":285},"end":{"line":12,"column":20,"offset":302}}}],"position":{"start":{"line":12,"column":3,"offset":285},"end":{"line":12,"column":20,"offset":302}}},{"type":"text","value":" number - The virtual ID of the process that this service worker is running in. This is not an OS level PID. This aligns with the ID set used for ","position":{"start":{"line":12,"column":20,"offset":302},"end":{"line":12,"column":168,"offset":450}}},{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"webContents.getProcessId()","position":{"start":{"line":12,"column":168,"offset":450},"end":{"line":12,"column":196,"offset":478}}}],"position":{"start":{"line":12,"column":168,"offset":450},"end":{"line":12,"column":196,"offset":478}}},{"type":"text","value":".","position":{"start":{"line":12,"column":196,"offset":478},"end":{"line":12,"column":197,"offset":479}}}],"position":{"start":{"line":12,"column":1,"offset":283},"end":{"line":12,"column":197,"offset":479}}},{"type":"text","value":"\\n"},{"type":"element","tagName":"li","properties":{},"children":[{"type":"element","tagName":"code","properties":{},"children":[{"type":"text","value":"versionId","position":{"start":{"line":13,"column":3,"offset":482},"end":{"line":13,"column":14,"offset":493}}}],"position":{"start":{"line":13,"column":3,"offset":482},"end":{"line":13,"column":14,"offset":493}}},{"type":"text","value":" number - ID of the service worker version","position":{"start":{"line":13,"column":14,"offset":493},"end":{"line":13,"column":56,"offset":535}}}],"position":{"start":{"line":13,"column":1,"offset":480},"end":{"line":13,"column":56,"offset":535}}},{"type":"text","value":"\\n"}],"position":{"start":{"line":10,"column":1,"offset":131},"end":{"line":13,"column":56,"offset":535}}}],"position":{"start":{"line":1,"column":1,"offset":0},"end":{"line":14,"column":1,"offset":536}}}'})," - Information about this service worker"]}),"\n",(0,r.jsx)(n.p,{children:"If the service worker does not exist or is not running this method will throw an exception."}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.strong,{children:"Deprecated:"})," Use the new ",(0,r.jsx)(n.code,{children:"serviceWorkers.getInfoFromVersionID"})," API."]}),"\n",(0,r.jsxs)(n.h4,{id:"serviceworkersgetworkerfromversionidversionid-experimental",children:[(0,r.jsx)(n.code,{children:"serviceWorkers.getWorkerFromVersionID(versionId)"})," ",(0,r.jsx)(n.em,{className:"badge badge--warning",children:"Experimental"})]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"versionId"})," number - ID of the service worker version"]}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["Returns ",(0,r.jsx)(n.a,{href:"/docs/latest/api/service-worker-main",children:(0,r.jsx)(n.code,{children:"ServiceWorkerMain | undefined"})})," - Instance of the service worker associated with the given version ID. If there's no associated version, or its running status has changed to 'stopped', this will return ",(0,r.jsx)(n.code,{children:"undefined"}),"."]}),"\n",(0,r.jsxs)(n.h4,{id:"serviceworkersstartworkerforscopescope-experimental",children:[(0,r.jsx)(n.code,{children:"serviceWorkers.startWorkerForScope(scope)"})," ",(0,r.jsx)(n.em,{className:"badge badge--warning",children:"Experimental"})]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.code,{children:"scope"})," string - The scope of the service worker to start."]}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["Returns ",(0,r.jsx)(n.code,{children:"Promise<ServiceWorkerMain>"})," - Resolves with the service worker when it's started."]}),"\n",(0,r.jsx)(n.p,{children:"Starts the service worker or does nothing if already running."}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-js",children:"const { app, session } = require('electron')\n\nconst { serviceWorkers } = session.defaultSession\n\n// Collect service workers scopes\nconst workerScopes = Object.values(serviceWorkers.getAllRunning()).map((info) => info.scope)\n\napp.on('browser-window-created', async (event, window) =>
1 {\n for (const scope of workerScopes) {\n try {\n // Ensure worker is started\n const serviceWorker = await serviceWorkers.startWorkerForScope(scope)\n serviceWorker.send('window-created', { windowId: window.id })\n } catch (error) {\n console.error(`Failed to start service worker for ${scope}`)\n console.error(error)\n }\n }\n})\n"})})]})}function u(e={}){let{wrapper:n}={...(0,o.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(f,{...e})}):f(e)}},40329(e,n,t){t.d(n,{A:()=>d});var s=t(74848),r=t(20053),o=t(96540),i=t(75392),l=t.n(i),c=t(83561);let a=e=>(0,s.jsx)("article",{ref:e.innerRef,id:"structures-tooltip",role:"tooltip",className:(0,r.A)("alert","alert--info","shadow--md","card_ZoSr"),style:e.position,children:(0,s.jsx)("div",{className:"card__body",dangerouslySetInnerHTML:{__html:(0,c.V)(JSON.parse(e.content))}})}),d=function(e){let{Portal:n}=l()(),t=(0,o.useRef)(null),r=(0,o.useRef)(null),[i,c]=(0,o.useState)(!1),[d,f]=(0,o.useState)(void 0);(0,o.useEffect)(()=>{if(i){let e={x:0,y:0},n=t.current.getBoundingClientRect(),s=window.innerHeight/2<n.y,o=window.innerWidth/2<n.x;s?e.y=r.current.clientHeight+-2:e.y=-n.height- -2,o?e.x=r.current.clientWidth:e.x=0,f({top:t.current.offsetTop-e.y,left:t.current.offsetLeft-e.x})}},[i]);let u=(0,o.useCallback)(()=>{c(!0)},[]),p=(0,o.useCallback)(()=>{c(!1)},[]);return(0,s.jsxs)("a",{"aria-describedby":"structures-tooltip",href:e.url,ref:t,className:"link_nCrB",onMouseEnter:u,onMouseLeave:p,children:[e.title,!!i&&(0,s.jsx)(n,{children:(0,s.jsx)(a,{innerRef:r,position:d,...e})})]})}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.