Skip to content

Upgrade to manifest v3 #293

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/diffhtml-devtools/LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2020 Tim Branyen
Copyright (c) 2022 Tim Branyen

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
38 changes: 20 additions & 18 deletions packages/diffhtml-devtools/chrome-extension/manifest.json
Original file line number Diff line number Diff line change
@@ -4,36 +4,38 @@
"description": "Official diffHTML Chrome DevTools Extension",
"permissions": [
"tabs",
"scripting"
],
"host_permissions": [
"*://*/*",
"file://*/*",
"http://*/*",
"https://*/*"
],
"background": {
"scripts": ["js/background.js"]
"service_worker": "js/background.js"
},
"content_scripts": [{
"matches": ["<all_urls>", "*://*/*", "http://*/*", "https://*/*"],
"js": ["js/contentscript.js"],
"run_at": "document_start"
"web_accessible_resources": [{
"resources": [
"devtools.es5.js",
"scripts/*",
"scripts/**/*",
"styles/*",
"styles/**/*",
"node_modules/**/*",
"markup/*",
"markup/**/*",
"icons/*",
"icons/**/*"
],
"matches": ["<all_urls>"]
}],
"web_accessible_resources": [
"devtools.es5.js",
"scripts/*",
"scripts/**/*",
"styles/*",
"styles/**/*",
"node_modules/**/*",
"markup/*",
"markup/**/*",
"icons/*",
"icons/**/*"
],
"icons": {
"16": "icons/logo-16.png",
"48": "icons/logo-48.png",
"128": "icons/logo-128.png"
},
"devtools_page": "markup/devtools.html",
"manifest_version": 2,
"manifest_version": 3,
"default_locale": "en"
}
9 changes: 7 additions & 2 deletions packages/diffhtml-devtools/lib/scripts/background.js
Original file line number Diff line number Diff line change
@@ -13,9 +13,14 @@ chrome.runtime.onConnect.addListener(port => {
});

if (message.name === 'init') {
chrome.tabs.executeScript(message.tabId, {
file: message.scriptToInject,
chrome.scripting.executeScript({
target: {tabId: message.tabId},
files: [message.scriptToInject]
});

//chrome.tabs.executeScript(message.tabId, {
// file: message.scriptToInject,
//});
}
};

1 change: 1 addition & 0 deletions packages/diffhtml-devtools/lib/scripts/contentscript.js
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
// a better way to do this, but I haven't looked into it yet.
const path = require('path');
const fs = require('fs');
// Import these directly, use ESM
const bridgeModule = fs.readFileSync(path.join(__dirname, '/../../chrome-extension/dist/extension/js/bridge.js'), 'utf8');
const injectorModule = fs.readFileSync(path.join(__dirname, '/injector.js'), 'utf8');
const { parse } = JSON;
4 changes: 1 addition & 3 deletions packages/diffhtml-devtools/lib/scripts/index.js
Original file line number Diff line number Diff line change
@@ -167,9 +167,7 @@ const render = () => outerHTML(main, html`
</devtools-panels>
</devtools-split-view>
</main>
`).catch(ex => {
throw ex;
});
`);

const clone = x => parse(stringify(x));

5 changes: 3 additions & 2 deletions packages/diffhtml-devtools/lib/scripts/panels/mounts.js
Original file line number Diff line number Diff line change
@@ -19,7 +19,8 @@ class DevtoolsMountsPanel extends Component {
const { isExpanded, activeTab } = this.state;
const { styles, setActive } = this;

const options = mounts.map(({ selector }) => ({
// FIXME Shouldn't need to concat and filter.
const options = [].concat(mounts).filter(Boolean).map(({ selector }) => ({
text: selector,
value: selector,
}));
@@ -52,7 +53,7 @@ class DevtoolsMountsPanel extends Component {
<div class="ui attached tabular menu">
${options.map((option, i) => html`
<div class="ui item ${activeTab === i && 'active'}">
<a href="#" onClick=${setActive(i)}>&lt;${option.text.trim()}&gt;</a>
<a href="#" onClick=${setActive(i)}>&lt;${String(option.text).trim()}&gt;</a>
</div>
`)}
</div>
10 changes: 10 additions & 0 deletions packages/diffhtml-devtools/package.json
Original file line number Diff line number Diff line change
@@ -2,6 +2,9 @@
"name": "diffhtml-devtools",
"private": true,
"main": "module/devtools.es5.js",
"scripts": {
"build": "grunt"
},
"devDependencies": {
"@babel/core": "^7.17.8",
"@babel/plugin-proposal-class-properties": "^7.16.7",
@@ -44,6 +47,13 @@
"uglifyify": "^5.0.2",
"unique-selector": "^0.5.0"
},
"dependencies": {
"babel-plugin-transform-diffhtml": "^1.0.0-beta.29",
"diffhtml": "^1.0.0-beta.29",
"diffhtml-components": "^1.0.0-beta.29",
"diffhtml-react-compat": "^1.0.0-beta.29",
"diffhtml-middleware-synthetic-events": "^1.0.0-beta.29"
},
"aliasify": {
"aliases": {
"react": "diffhtml-react-compat",