Skip to content

Commit

Permalink
feat: side_panel manifest property (#121)
Browse files Browse the repository at this point in the history
* feat: support side panel

* add test
  • Loading branch information
maltoze authored Jul 20, 2023
1 parent 600cb8b commit ebe613f
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/manifestParser/manifestV3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default class ManifestV3 extends ManifestParser<Manifest> {
manifest.chrome_url_overrides?.newtab,
manifest.chrome_url_overrides?.history,
manifest.chrome_url_overrides?.bookmarks,
manifest.side_panel?.default_path,
]
.filter((fileName): fileName is string => typeof fileName === "string")
.map((fileName) => fileName.split(/[\?\#]/)[0]);
Expand Down
87 changes: 87 additions & 0 deletions test/manifest/__snapshots__/sidePanelHtml.v3.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`sidePanelHtml - Manifest V3 1`] = `
[
{
"code": "function log(message) {
console.log(message);
}
log(\\"sidepanel\\");
",
"dynamicImports": [],
"exports": [],
"facadeModuleId": "vite-plugin-web-extension/test/manifest/resources/sidePanelHtml/sidepanel.html",
"fileName": "assets/test/manifest/resources/sidePanelHtml/sidepanel.js",
"implicitlyLoadedBefore": [],
"importedBindings": {},
"imports": [],
"isDynamicEntry": false,
"isEntry": true,
"isImplicitEntry": false,
"map": null,
"modules": {
"vite-plugin-web-extension/test/manifest/resources/shared/log.js": {
"code": "function log(message) {
console.log(message);
}",
"originalLength": 65,
"removedExports": [],
"renderedExports": [
"default",
],
"renderedLength": 49,
},
"vite-plugin-web-extension/test/manifest/resources/sidePanelHtml/sidepanel.html": {
"code": null,
"originalLength": 228,
"removedExports": [],
"renderedExports": [],
"renderedLength": 0,
},
"vite-plugin-web-extension/test/manifest/resources/sidePanelHtml/sidepanel.js": {
"code": "log(\\"sidepanel\\");",
"originalLength": 54,
"removedExports": [],
"renderedExports": [],
"renderedLength": 17,
},
},
"name": "test/manifest/resources/sidePanelHtml/sidepanel",
"referencedFiles": [],
"type": "chunk",
"viteMetadata": {
"importedAssets": Set {},
"importedCss": Set {},
},
},
{
"fileName": "manifest.json",
"name": undefined,
"source": "{
\\"version\\": \\"1.0.0\\",
\\"name\\": \\"Manifest Name\\",
\\"manifest_version\\": 3,
\\"side_panel\\": {
\\"default_path\\": \\"test/manifest/resources/sidePanelHtml/sidepanel.html\\"
}
}",
"type": "asset",
},
{
"fileName": "test/manifest/resources/sidePanelHtml/sidepanel.html",
"name": undefined,
"source": "<!DOCTYPE html>
<html lang=\\"en\\">
<head>
<meta charset=\\"UTF-8\\" />
<script type=\\"module\\" src=\\"http://example.com/httpModuleScript.js\\"></script>
<script type=\\"module\\" crossorigin src=\\"/assets/test/manifest/resources/sidePanelHtml/sidepanel.js\\"></script>
</head>
</html>
",
"type": "asset",
},
]
`;
9 changes: 9 additions & 0 deletions test/manifest/resources/sidePanelHtml/sidepanel.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<script type="module" src="./sidepanel.js"></script>

<script type="module" src="http://example.com/httpModuleScript.js"></script>
</head>
</html>
3 changes: 3 additions & 0 deletions test/manifest/resources/sidePanelHtml/sidepanel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import log from "./../shared/log";

log("sidepanel");
9 changes: 9 additions & 0 deletions test/manifest/sidePanelHtml.v3.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { getResourceDir, runManifestV3Test } from "./manifestTestUtils";

const resourceDir = getResourceDir("sidePanelHtml");

runManifestV3Test("sidePanelHtml", () => ({
side_panel: {
default_path: `${resourceDir}/sidepanel.html`,
},
}));

0 comments on commit ebe613f

Please sign in to comment.