Я пытаюсь понять, как Electron загружает расширения. При трассировке кода я застреваю здесь :
const contents = webContents.create({
в пределах:
const { app, webContents, BrowserWindow } = require('electron')
const startBackgroundPages = function (manifest) {
if (backgroundPages[manifest.extensionId] || !manifest.background) return
let html
let name
if (manifest.background.page) {
name = manifest.background.page
html = fs.readFileSync(path.join(manifest.srcDirectory, manifest.background.page))
} else {
name = '_generated_background_page.html'
const scripts = manifest.background.scripts.map((name) => {
return `<script src="${name}"></script>`
}).join('')
html = Buffer.from(`<html><body>${scripts}</body></html>`)
}
const contents = webContents.create({
partition: 'persist:__chrome_extension',
type: 'backgroundPage',
sandbox: true,
enableRemoteModule: false
})
backgroundPages[manifest.extensionId] = { html: html, webContents: contents, name: name }
contents.loadURL(url.format({
protocol: 'chrome-extension',
slashes: true,
hostname: manifest.extensionId,
pathname: name
}))
}
Я хотел бы просто следуйте require
, но я не нахожу в этом успеха. Мне также очень неясно, где / как заполняется содержимое модуля, так что это попытка отследить его таким образом.