-
Notifications
You must be signed in to change notification settings - Fork 325
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
feat: MV3 boilerplate #1044
feat: MV3 boilerplate #1044
Conversation
- adds mv3/ directory - setup fast builds with esbuild - setup prettier for formatting - setup eslint - setup typescript - adds BASIC handling of ipfs.io & dweb.link URLs to local node via declarativeNetRequest api (manifest v3) - adds BASIC handling of DNSLink requests by parsing, talking to local node via ipfs-http-client, and adding rule to declarativeNetRequest ruleset - adds boilerplate for popup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Small asks before we merge (inline)
@lidel Comments addressed 👍 |
@lidel Could I get yours 👀 on this again? Thanks! |
- adds mv3/ directory - setup fast builds with esbuild - setup prettier for formatting - setup eslint - setup typescript - adds BASIC handling of ipfs.io & dweb.link URLs to local node via declarativeNetRequest api (manifest v3) - adds BASIC handling of DNSLink requests by parsing, talking to local node via ipfs-http-client, and adding rule to declarativeNetRequest ruleset - adds boilerplate for popup
- add welcome page - add options page - add clipboard functionality - add status updates to popup - add basic UI styling to popup
- on installed checks - on uninstalled checks - runtime checks - options/state cleanup - add firefox request handling for when they support mv3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @meandavejustice, and apologies for late review.
Dynamic rules are pretty powerful, and I think we should be able to live with them as long we add proper cache around their creation.
Left some feedback below:
⚠️ important things we should fix- lmk if you prefer to do them in this PR or merge as-is and track them in separate issues
- 💭 lower priority thoughts on style and nice-to-haves
mv3/addon/background.ts
Outdated
return url.includes("chrome://"); | ||
} | ||
|
||
async function resolveDNSAndAddRule(domain) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔧 can we make resolveDNSAndAddRule
return boolean to indicate if companion added a new rule or not?
That way, we could act on that hint in places like retryOnTabUpdate
and reload impacted tabs immediately (find all tabs with URL matching the added rule and reload them fast enough that the user does not even see the original URL).
mv3/addon/background.ts
Outdated
priority: 1, | ||
action: { | ||
type: "redirect", | ||
redirect: { url: `https://dweb.link${contentPath}` }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/ipns/
namespace (we don't want users to be redirected to status snapshot and lose future updates).
Assuming example.com
has a valid dnslink pointing at /ipfs/{cid}
Opening https://example.com/foo/bar?arg=a#buzz
should redirect to
https://dweb.link/ipns/example.com/foo/bar?arg=a#buzz
.
(We want to preserve all params, simply replace https?://
with https://dweb.link/ipns/
prefix)
mv3/addon/background.ts
Outdated
} | ||
|
||
async function resolveDNSAndAddRule(domain) { | ||
const contentPath = await client.resolve(`/ipns/${domain}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized this is an out of date file. I will push the updates shortly with the updated branch I've been working in 🤦. Luckily for me there was some things you caught that I wasn't doing in the new branch! so it was NOT a wasted effort :)
mv3/addon/background.ts
Outdated
}); | ||
} | ||
|
||
async function retryOnTabUpdate(tabId, info) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IsIpfs.url
test
For example, https://cloudflare-ipfs.com/ipfs/QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
does not get redirected to a local node because there is dynamic no rule for https://cloudflare-ipfs.com/ipfs/*
– but it could with a few additional lines :)
We should detect when IsIpfs.url(info.url)
returns true and then domain
is different from the default public gateway (URL.host.endsWith('dweb.link')
) and local one (URLhost.endsWith(localhost:8080')
). In such case, we would add dynamic rule, just like we do for DNSLink. 👌
mv3/addon/rules.json
Outdated
"action": { | ||
"type": "redirect", | ||
"redirect": { | ||
"transform": { "scheme": "http", "host": "localhost", "port": "8080" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 given that port will be something that can be changed by the user, we will most likely end up adding these as dynamic rules during startup.
.github/workflows/ci-mv3.yml
Outdated
- name: Restore .cache | ||
uses: actions/cache@v3 | ||
id: cache | ||
with: | ||
path: ${{ github.workspace }}/.cache | ||
key: ${{ runner.os }}-${{ hashFiles('package*json', 'yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-${{ hashFiles('package*json', 'yarn.lock') }} | ||
${{ runner.os }}- | ||
|
||
- name: Restore node_modules | ||
id: yarn-cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: node_modules | ||
key: ${{ runner.os }}-${{ hashFiles('package*json', 'yarn.lock') }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yarn.lock
and this cache – npm ci
uses package-lock.json
and ignores yarn.lock
anyway (which is good, we want to try using package-lock.json
and remove yarn
dependency)
id expects and integer
@lidel Thanks again for the review, I apologize for the branching mixup. I've got it working now correctly in this branch and addressed most of your comments. (I have two of them added to my todo list for the week). I'm going to go ahead and close this pr and open up a fresh one later on in the week. I need to add an updated list of features, and screenshots and clean up the git history. |
This is the starting point for Manifest v3 extension.
What currently works?
ipfs.io
anddweb
links.All of this is in
/mv3
cc/ @lidel