mirror of
https://gitlab.com/lecarore/breakout71.git
synced 2025-04-20 04:05:06 -04:00
Added sw
This commit is contained in:
parent
cdfe6a4978
commit
934670b2a7
11 changed files with 84 additions and 3 deletions
|
@ -33,6 +33,11 @@ sed -i -e "s/^[[:space:]]*versionCode = .*/ versionCode = $versionCode/"
|
|||
|
||||
echo "\"$versionCode\"" > src/version.json
|
||||
|
||||
# Update service worker
|
||||
sed -i -e "s/VERSION = .*/ VERSION = '$versionCode'/" ./public/sw-b71.js
|
||||
|
||||
|
||||
|
||||
# remove all exif metadata from pictures, because i think fdroid doesn't like that. odd
|
||||
find -name '*.jp*g' -o -name '*.png' | xargs exiftool -all=
|
||||
|
||||
|
|
15
package-lock.json
generated
15
package-lock.json
generated
|
@ -9,6 +9,7 @@
|
|||
"version": "1.0.0",
|
||||
"license": "GNU AGPLv3",
|
||||
"dependencies": {
|
||||
"@parcel/service-worker": "^2.13.3",
|
||||
"@parcel/transformer-less": "^2.13.3",
|
||||
"@types/react": "^19.0.10",
|
||||
"@types/react-dom": "^19.0.4",
|
||||
|
@ -1922,6 +1923,20 @@
|
|||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/service-worker": {
|
||||
"version": "2.13.3",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/service-worker/-/service-worker-2.13.3.tgz",
|
||||
"integrity": "sha512-b/wbbQPusfPsXvHx4mgI/hSQYIk6B5pkEL2ubNrtedjdzLPvjveZ161MxuF3XLvpDWINl7y8qPbmFZrf+pa8lg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 16.0.0",
|
||||
"parcel": "^2.13.3"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/parcel"
|
||||
}
|
||||
},
|
||||
"node_modules/@parcel/source-map": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/@parcel/source-map/-/source-map-2.1.1.tgz",
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
"author": "Renan LE CARO",
|
||||
"license": "GNU AGPLv3",
|
||||
"dependencies": {
|
||||
"@parcel/service-worker": "^2.13.3",
|
||||
"@parcel/transformer-less": "^2.13.3",
|
||||
"@types/react": "^19.0.10",
|
||||
"@types/react-dom": "^19.0.4",
|
||||
|
|
BIN
public/icon-128.png
Normal file
BIN
public/icon-128.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 749 B |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
BIN
public/icon-64.png
Normal file
BIN
public/icon-64.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 479 B |
|
@ -3,12 +3,22 @@
|
|||
"name": "Breakout 71",
|
||||
"icons": [
|
||||
{
|
||||
"src": "/icon.png",
|
||||
"src": "/icon-512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "/icon-128.png",
|
||||
"sizes": "128x128",
|
||||
"type": "image/png"
|
||||
},
|
||||
{
|
||||
"src": "/icon-64.png",
|
||||
"sizes": "64x64",
|
||||
"type": "image/png"
|
||||
}
|
||||
],
|
||||
"start_url": ".",
|
||||
"start_url": "/index.html?isPWA=true",
|
||||
"display": "fullscreen",
|
||||
"theme_color": "#5DA3EA",
|
||||
"background_color": "#ffffff"
|
||||
|
|
44
public/sw-b71.js
Normal file
44
public/sw-b71.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
// The version of the cache.
|
||||
const VERSION = '29032991'
|
||||
|
||||
// The name of the cache
|
||||
const CACHE_NAME = `breakout-71-${VERSION}`;
|
||||
|
||||
// The static resources that the app needs to function.
|
||||
const APP_STATIC_RESOURCES = [
|
||||
"/"
|
||||
];
|
||||
|
||||
// On install, cache the static resources
|
||||
self.addEventListener("install", (event) => {
|
||||
event.waitUntil(
|
||||
(async () => {
|
||||
const cache = await caches.open(CACHE_NAME);
|
||||
cache.addAll(APP_STATIC_RESOURCES);
|
||||
})(),
|
||||
);
|
||||
});
|
||||
|
||||
// delete old caches on activate
|
||||
self.addEventListener("activate", (event) => {
|
||||
event.waitUntil(
|
||||
(async () => {
|
||||
const names = await caches.keys();
|
||||
await Promise.all(
|
||||
names.map((name) => {
|
||||
if (name !== CACHE_NAME) {
|
||||
return caches.delete(name);
|
||||
}
|
||||
}),
|
||||
);
|
||||
await clients.claim();
|
||||
})(),
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener("fetch", (event) => {
|
||||
if (event.request.mode === "navigate" && event.request.url.endsWith('/index.html?isPWA=true')) {
|
||||
event.respondWith(caches.match("/"));
|
||||
return;
|
||||
}
|
||||
});
|
|
@ -17,6 +17,7 @@ import {putBallsAtPuck, resetBalls} from "./resetBalls";
|
|||
import {makeEmptyPerksMap, sumOfKeys} from "./game_utils";
|
||||
import {baseCombo, decreaseCombo, resetCombo} from "./combo";
|
||||
|
||||
import './sw_loader'
|
||||
|
||||
const gameCanvas = document.getElementById("game") as HTMLCanvasElement;
|
||||
const ctx = gameCanvas.getContext("2d", {
|
||||
|
@ -2382,6 +2383,7 @@ async function openSettingsPanel() {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
actions.push({
|
||||
text: "Sandbox mode",
|
||||
help:
|
||||
|
|
|
@ -46,7 +46,7 @@ export const options = {
|
|||
disabled() {
|
||||
return window.location.search.includes("isInWebView=true");
|
||||
},
|
||||
},
|
||||
}
|
||||
} as const satisfies { [k: string]: OptionDef };
|
||||
|
||||
export type OptionDef = {
|
||||
|
|
4
src/sw_loader.ts
Normal file
4
src/sw_loader.ts
Normal file
|
@ -0,0 +1,4 @@
|
|||
if ("serviceWorker" in navigator &&
|
||||
window.location.search.includes("isPWA=true")) {
|
||||
navigator.serviceWorker.register("sw-b71.js");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue