chrome-extension-tools
chrome-extension-tools copied to clipboard
Add offscreen permission
Build tool
Rollup
Where do you see the problem?
- [ ] In the browser
- [X] In the terminal
Describe the bug
I need to use a new permission named "offscreen" but manifest input validation fails with:
[!] Error: There were problems with the extension manifest.
- "offscreen" at "/permissions/3" must be equal to one of the allowed values
Reproduction
Set offscreen in permissions array.
Logs
[!] Error: There were problems with the extension manifest.
- "offscreen" at "/permissions/3" must be equal to one of the allowed values
System Info
Windows, rollup-plugin
Severity
blocking all usage of RPCE
I tried to fix it but I cannot find a manual on build process. Here is my pr untested. https://github.com/crxjs/chrome-extension-tools/pull/711
This needs more work because offscreen document needs to be bundled and information about its path is not in manifest. I need help about building the rollup extension. After this I may submit a pull request.
This needs more work because offscreen document needs to be bundled and information about its path is not in manifest. I need help about building the rollup extension. After this I may submit a pull request.
Hello, I also need permission offscreen, do you have any way?
I temporarily use this method:
offscreen.html, offscreen.js
Use the plugin: rollup-plugin-copy to copy these 2 files to the dist folder or add offscreen.html to web_accessible_resources for them to be automatically copied to the dist folder.
Create a rollup-plugin to merge permissions in the dist/manifest.json file as follows.
import { readFile, writeFile } from 'fs/promises';
const mergePermissions = (options = {}) => {
const {src = 'dist/manifest.json', dest = 'dist/manifest.json', permissions = []} = options;
const hook = 'writeBundle';
return {
name: 'merge-permissions',
[hook]: async () => {
if(permissions.length > 0) {
let manifest = await readFile(src, 'utf8');
manifest = JSON.parse(manifest);
manifest['permissions'] = manifest['permissions'].concat(permissions);
await writeFile(dest, JSON.stringify(manifest, null, 2));
}
}
}
}
export default mergePermissions;
plugins: [
...,
mergePermissions({
permissions: ["offscreen"]
})