-
Notifications
You must be signed in to change notification settings - Fork 45
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
PWA Support #68
base: master
Are you sure you want to change the base?
PWA Support #68
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,3 +43,4 @@ Thumbs.db | |
.classpath | ||
*.launch | ||
.settings/ | ||
dev-dist/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"singleQuote": true, | ||
"semi": false, | ||
"trailingComma": "all" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,23 @@ | ||
<!doctype html> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no" /> | ||
<meta name="theme-color" content="#1B1B1F" /> | ||
<meta name="description" content="manage your openpilot experience" /> | ||
|
||
<title>connect</title> | ||
|
||
<link rel="manifest" href="/manifest.json" /> | ||
<link | ||
href="/images/favicon-16x16.png" | ||
rel="icon" | ||
type="image/png" | ||
sizes="16x16" | ||
/> | ||
<link | ||
href="/images/favicon-32x32.png" | ||
rel="icon" | ||
type="image/png" | ||
sizes="32x32" | ||
<meta name="color-scheme" content="light dark" /> | ||
<meta | ||
name="viewport" | ||
content="viewport-fit=cover, width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" | ||
/> | ||
<meta name="format-detection" content="telephone=no" /> | ||
<meta name="msapplication-tap-highlight" content="no" /> | ||
|
||
<link rel="icon" type="image/png" href="assets/icon/favicon.png" /> | ||
|
||
<meta name="apple-mobile-web-app-capable" content="yes" /> | ||
<meta name="apple-mobile-web-app-status-bar-style" content="black" /> | ||
|
||
<link | ||
rel="stylesheet" | ||
href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,[email protected],400,0..1,0&display=block" | ||
|
@@ -29,7 +27,10 @@ | |
href="https://fonts.googleapis.com/css2?family=Inter:[email protected]&family=JetBrains+Mono:wght@400;500&display=swap" | ||
/> | ||
</head> | ||
<body data-theme="dark" class="overflow-x-hidden bg-background text-on-background"> | ||
<body | ||
data-theme="dark" | ||
class="overflow-x-hidden bg-background text-on-background" | ||
> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<div id="root"></div> | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,11 @@ | |
"type": "module", | ||
"devDependencies": { | ||
"@solidjs/testing-library": "^0.8.8", | ||
"@vite-pwa/assets-generator": "^0.2.4", | ||
"vite-plugin-pwa": "^0.20.0", | ||
"sharp": "0.32.6", | ||
"sharp-ico": "0.1.5", | ||
"workbox-window": "^7.1.0", | ||
Comment on lines
+24
to
+28
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what do these 5 new dependencies do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are required for the minimal config vite-pwa plugin. They are used generate the assets like splash screens, icons, etc. at build time and are not included in the applications bundle. There's an alternative way to use "resolutions" in package.json for the sharp and sharp-ico libs but I couldn't get them to work in this repo. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a declarative plugin instead of an imperative config. |
||
"@stylistic/eslint-plugin": "^2.1.0", | ||
"@testing-library/jest-dom": "^6.4.6", | ||
"@testing-library/user-event": "^14.5.2", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { | ||
AllAppleDeviceNames, | ||
combinePresetAndAppleSplashScreens, | ||
defineConfig, | ||
minimal2023Preset, | ||
} from '@vite-pwa/assets-generator/config' | ||
|
||
import { readFile } from 'node:fs/promises' | ||
|
||
export default defineConfig({ | ||
headLinkOptions: { | ||
preset: '2023', | ||
}, | ||
preset: combinePresetAndAppleSplashScreens( | ||
minimal2023Preset, | ||
{ | ||
// dark splash screens using black background (the default) | ||
darkResizeOptions: { background: 'black', fit: 'contain' }, | ||
// or using a custom background color | ||
// darkResizeOptions: { background: '#1f1f1f' }, | ||
async darkImageResolver(imageName) { | ||
return imageName === 'public/logo-connect-light.svg' | ||
? await readFile('public/logo-connect-dark.svg') | ||
: undefined | ||
}, | ||
}, | ||
|
||
AllAppleDeviceNames, | ||
), | ||
images: ['public/logo-connect-light.svg'], | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { ParentProps, createSignal, onCleanup } from 'solid-js' | ||
|
||
const OfflineIndicator = (props: ParentProps) => { | ||
const [isOffline, setIsOffline] = createSignal(!navigator.onLine) | ||
|
||
const updateOnlineStatus = () => { | ||
setIsOffline(!navigator.onLine) | ||
} | ||
|
||
window.addEventListener('online', updateOnlineStatus) | ||
window.addEventListener('offline', updateOnlineStatus) | ||
|
||
onCleanup(() => { | ||
window.removeEventListener('online', updateOnlineStatus) | ||
window.removeEventListener('offline', updateOnlineStatus) | ||
}) | ||
|
||
return ( | ||
<div> | ||
{isOffline() ? ( | ||
<div style={{ background: 'red', color: 'white', padding: '10px' }}> | ||
You are currently offline | ||
</div> | ||
) : ( | ||
props.children | ||
)} | ||
</div> | ||
) | ||
} | ||
|
||
export default OfflineIndicator |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also unrelated? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will remove - was just for my testing on vercel |
||
"rewrites": [{ "source": "/(.*)", "destination": "/" }] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,44 @@ | ||
import devtools from 'solid-devtools/vite' | ||
import { defineConfig } from 'vite' | ||
import { VitePWA } from 'vite-plugin-pwa' | ||
import solid from 'vite-plugin-solid' | ||
import devtools from 'solid-devtools/vite' | ||
|
||
export default defineConfig({ | ||
plugins: [ | ||
devtools(), | ||
solid({ | ||
ssr: false, | ||
}), | ||
VitePWA({ | ||
registerType: 'autoUpdate', | ||
injectRegister: 'auto', | ||
|
||
pwaAssets: { | ||
disabled: false, | ||
config: true, | ||
}, | ||
|
||
manifest: { | ||
name: 'connect', | ||
short_name: 'conect', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. misspelled |
||
description: 'manage your openpilot experience', | ||
theme_color: '#1B1B1F', | ||
background_color: '#1B1B1F', | ||
}, | ||
|
||
workbox: { | ||
globPatterns: ['**/*.{js,css,html,svg,png,ico}'], | ||
cleanupOutdatedCaches: true, | ||
clientsClaim: true, | ||
}, | ||
|
||
devOptions: { | ||
enabled: true, | ||
navigateFallback: 'index.html', | ||
suppressWarnings: true, | ||
type: 'module', | ||
}, | ||
}), | ||
], | ||
server: { | ||
port: 3000, | ||
|
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.
not related to PWAs