Skip to content
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: chrome extension support #72

Merged
merged 6 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 2 additions & 0 deletions .typos.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[files]
extend-exclude = ["bun.lockb"]
Binary file added bun.lockb
Binary file not shown.
20 changes: 10 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<!DOCTYPE html>
<html>
<head>
<meta name="version" content="{{buildVersion}}">
<link data-trunk rel="tailwind-css" href="./index.css"/>
<link data-trunk rel="rust" data-wasm-opt="z"/>
<link data-trunk rel="copy-dir" href="./assets/"/>
<link data-trunk rel="copy-file" href="./service-worker.js"/>
<link data-trunk rel="copy-file" href="./manifest.json"/>
<link data-trunk rel="copy-file" href="./favicon.ico"/>
</head>
<body></body>
<head>
<meta name="version" content="{{buildVersion}}" />
<link data-trunk rel="tailwind-css" href="./index.css" />
<link data-trunk rel="rust" data-wasm-opt="z" />
<link data-trunk rel="copy-dir" href="./assets/" />
<link data-trunk rel="copy-file" href="./service-worker.js" />
<link data-trunk rel="copy-file" href="./manifest.json" />
<link data-trunk rel="copy-file" href="./favicon.ico" />
</head>
<body></body>
</html>
78 changes: 37 additions & 41 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,46 +1,42 @@
{
"name": "Webimint Fedimint Client",
"short_name": "Webimint",
"start_url": "/",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#ffffff",
"icons": [
{
"src": "\/assets\/icons\/android-icon-36x36.png",
"sizes": "36x36",
"type": "image\/png",
"density": "0.75"
"manifest_version": 3,
"__chrome__manifest_version": 3,
"name": "Webimint Fedimint Client",
"short_name": "Webimint",
"version": "0.1.0",
"description": "Webimint is an experimental Fedimint wallet using the Leptos web framework.",
"action": {
"default_popup": "index.html",
"default_icon": {
"48": "/assets/icons/android-icon-48x48.png",
"96": "/assets/icons/android-icon-96x96.png",
"192": "/assets/icons/android-icon-192x192.png"
}
},
{
"src": "\/assets\/icons\/android-icon-48x48.png",
"sizes": "48x48",
"type": "image\/png",
"density": "1.0"
"background": {
"service_worker": "service-worker.js"
},
{
"src": "\/assets\/icons\/android-icon-72x72.png",
"sizes": "72x72",
"type": "image\/png",
"density": "1.5"
"permissions": ["storage", "activeTab"],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["webimint-{{buildVersion}}.js"]
}
],
"__chrome__host_permissions": ["*://*/*"],
"content_security_policy": {
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self';"
},
{
"src": "\/assets\/icons\/android-icon-96x96.png",
"sizes": "96x96",
"type": "image\/png",
"density": "2.0"
},
{
"src": "\/assets\/icons\/android-icon-144x144.png",
"sizes": "144x144",
"type": "image\/png",
"density": "3.0"
},
{
"src": "\/assets\/icons\/android-icon-192x192.png",
"sizes": "192x192",
"type": "image\/png",
"density": "4.0"
"start_url": "/",
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#ffffff",
"icons": {
"36": "/assets/icons/android-icon-36x36.png",
"48": "/assets/icons/android-icon-48x48.png",
"72": "/assets/icons/android-icon-72x72.png",
"96": "/assets/icons/android-icon-96x96.png",
"144": "/assets/icons/android-icon-144x144.png",
"192": "/assets/icons/android-icon-192x192.png"
}
]
}
}
12 changes: 9 additions & 3 deletions post_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,21 @@ echo "Build-Version is: ${buildVersion}"
# Replace placeholder in service-worker.js
serviceWorkerJsFile=$(find ./dist/.stage -iname "service-worker.js")
echo "Replacing {{buildVersion}} placeholder in: ${serviceWorkerJsFile}"
sed "s/{{buildVersion}}/${buildVersion}/g" "${serviceWorkerJsFile}" > "${serviceWorkerJsFile}.modified"
sed "s/{{buildVersion}}/${buildVersion}/g" "${serviceWorkerJsFile}" >"${serviceWorkerJsFile}.modified"
mv -f "${serviceWorkerJsFile}.modified" "${serviceWorkerJsFile}"

# Replace placeholder in index.html
indexHtmlFile=$(find ./dist/.stage -iname "index.html")
echo "Replacing {{buildVersion}} placeholder in: ${indexHtmlFile}"
sed "s/{{buildVersion}}/${buildVersion}/g" "${indexHtmlFile}" > "${indexHtmlFile}.modified"
sed "s/{{buildVersion}}/${buildVersion}/g" "${indexHtmlFile}" >"${indexHtmlFile}.modified"
mv -f "${indexHtmlFile}.modified" "${indexHtmlFile}"

# Replace placeholder in manifest.json
manifestJsonFile=$(find ./dist/.stage -iname "manifest.json")
echo "Replacing {{buildVersion}} placeholder in: ${manifestJsonFile}"
sed "s/{{buildVersion}}/${buildVersion}/g" "${manifestJsonFile}" >"${manifestJsonFile}.modified"
mv -f "${manifestJsonFile}.modified" "${manifestJsonFile}"
Kodylow marked this conversation as resolved.
Show resolved Hide resolved

# Extract CSS build version
indexJsFile=$(find ./dist/.stage -iname "${stylePrefix}-*.${styleFormat}")
echo "Extracting style build version from file: ${indexJsFile}"
Expand All @@ -52,5 +58,5 @@ echo "CSS Build-Version is: ${cssBuildVersion}"
# Replace placeholder in service-worker.js
serviceWorkerJsFile=$(find ./dist/.stage -iname "service-worker.js")
echo "Replacing {{cssBuildVersion}} placeholder in: ${serviceWorkerJsFile}"
sed "s/{{cssBuildVersion}}/${cssBuildVersion}/g" "${serviceWorkerJsFile}" > "${serviceWorkerJsFile}.modified"
sed "s/{{cssBuildVersion}}/${cssBuildVersion}/g" "${serviceWorkerJsFile}" >"${serviceWorkerJsFile}.modified"
mv -f "${serviceWorkerJsFile}.modified" "${serviceWorkerJsFile}"