Add ServiceWorker Check

This commit is contained in:
ingalls
2025-12-01 15:49:56 -07:00
parent 380e5a9d3b
commit ce0d348591
2 changed files with 31 additions and 43 deletions

View File

@@ -1,12 +1,12 @@
{
"name": "@tak-ps/CloudTAK.web",
"version": "12.13.0",
"version": "12.17.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@tak-ps/CloudTAK.web",
"version": "12.13.0",
"version": "12.17.0",
"dependencies": {
"@react-hookz/deep-equal": "^3.0.3",
"@tabler/core": "^1.4.0",
@@ -1132,9 +1132,9 @@
}
},
"node_modules/@maplibre/mlt": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/@maplibre/mlt/-/mlt-1.1.0.tgz",
"integrity": "sha512-anR8WxKIgZUJQLlZtID0v06wd9Q//9K/6lLLU3dOzmeO/xLEzAwmEqP24jEnEUBcnZGkM4vidz9H6Q4guNAAlw==",
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/@maplibre/mlt/-/mlt-1.1.1.tgz",
"integrity": "sha512-RHgSxN9lqV8rsnZXPjgxT6YFFYqB2SeyDZ63wTpu9Rv1M9pUkPHT6BfvhS5fBA67GeAZJuddhc4mFGIix7o5Ng==",
"license": "(MIT OR Apache-2.0)",
"dependencies": {
"@mapbox/point-geometry": "^1.1.0"
@@ -2695,14 +2695,14 @@
"license": "MIT"
},
"node_modules/@types/express": {
"version": "5.0.5",
"resolved": "https://registry.npmjs.org/@types/express/-/express-5.0.5.tgz",
"integrity": "sha512-LuIQOcb6UmnF7C1PCFmEU1u2hmiHL43fgFQX67sN3H4Z+0Yk0Neo++mFsBjhOAuLzvlQeqAAkeDOZrJs9rzumQ==",
"version": "5.0.6",
"resolved": "https://registry.npmjs.org/@types/express/-/express-5.0.6.tgz",
"integrity": "sha512-sKYVuV7Sv9fbPIt/442koC7+IIwK5olP1KWeD88e/idgoJqDm3JV/YUiPwkoKK92ylff2MGxSz1CSjsXelx0YA==",
"license": "MIT",
"dependencies": {
"@types/body-parser": "*",
"@types/express-serve-static-core": "^5.0.0",
"@types/serve-static": "^1"
"@types/serve-static": "^2"
}
},
"node_modules/@types/express-serve-static-core": {
@@ -2744,12 +2744,6 @@
"integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==",
"license": "MIT"
},
"node_modules/@types/mime": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/@types/mime/-/mime-1.3.5.tgz",
"integrity": "sha512-/pyBZWSLD2n0dcHE3hq8s8ZvcETHtEuF+3E7XVt0Ig2nvsVQXdghHVcEkIWjy9A0wKfTn97a/PSDYohKIlnP/w==",
"license": "MIT"
},
"node_modules/@types/node": {
"version": "24.10.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.10.1.tgz",
@@ -2790,23 +2784,12 @@
}
},
"node_modules/@types/serve-static": {
"version": "1.15.10",
"resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-1.15.10.tgz",
"integrity": "sha512-tRs1dB+g8Itk72rlSI2ZrW6vZg0YrLI81iQSTkMmOqnqCaNr/8Ek4VwWcN5vZgCYWbg/JJSGBlUaYGAOP73qBw==",
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/@types/serve-static/-/serve-static-2.2.0.tgz",
"integrity": "sha512-8mam4H1NHLtu7nmtalF7eyBH14QyOASmcxHhSfEoRyr0nP/YdoesEtU+uSRvMe96TW/HPTtkoKqQLl53N7UXMQ==",
"license": "MIT",
"dependencies": {
"@types/http-errors": "*",
"@types/node": "*",
"@types/send": "<1"
}
},
"node_modules/@types/serve-static/node_modules/@types/send": {
"version": "0.17.6",
"resolved": "https://registry.npmjs.org/@types/send/-/send-0.17.6.tgz",
"integrity": "sha512-Uqt8rPBE8SY0RK8JB1EzVOIZ32uqy8HwdxCnoCOsYrvnswqmFZ/k+9Ikidlk/ImhsdvBsloHbAlewb2IEBV/Og==",
"license": "MIT",
"dependencies": {
"@types/mime": "^1",
"@types/node": "*"
}
},
@@ -6180,10 +6163,10 @@
"license": "Apache-2.0"
},
"node_modules/lru-cache": {
"version": "11.2.2",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.2.tgz",
"integrity": "sha512-F9ODfyqML2coTIsQpSkRHnLSZMtkU8Q+mSfcaIyKwy58u+8k5nvAYeiNhsyMARvzNcXJ9QfWVrcPsC9e9rAxtg==",
"license": "ISC",
"version": "11.2.4",
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.2.4.tgz",
"integrity": "sha512-B5Y16Jr9LB9dHVkh6ZevG+vAbOsNOYCX+sXvFWFu7B3Iz5mijW3zdbMyhsh8ANd2mSWBYdJgnqi+mL7/LrOPYg==",
"license": "BlueOak-1.0.0",
"engines": {
"node": "20 || >=22"
}
@@ -8151,9 +8134,9 @@
"peer": true
},
"node_modules/terra-draw-maplibre-gl-adapter": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/terra-draw-maplibre-gl-adapter/-/terra-draw-maplibre-gl-adapter-1.2.2.tgz",
"integrity": "sha512-Q5OtRWHbqrx6wSQDJOT/UiMh+dT3834e3dU7KalC33pUa8YT0VQ4XYE8OsoJOeIFUdKig/5bk3w0TvNuYMl+3Q==",
"version": "1.2.3",
"resolved": "https://registry.npmjs.org/terra-draw-maplibre-gl-adapter/-/terra-draw-maplibre-gl-adapter-1.2.3.tgz",
"integrity": "sha512-sJr5ylw7RDBrLU6ida15n5ijZzJBAqXRlUCk7EnXyvQwH4BYZvoDNoUFXVY8N+ZWVqS13cHrd6in53ivkE3zEQ==",
"license": "MIT",
"peerDependencies": {
"maplibre-gl": ">=4",
@@ -8443,9 +8426,9 @@
"license": "MIT"
},
"node_modules/vite": {
"version": "7.2.4",
"resolved": "https://registry.npmjs.org/vite/-/vite-7.2.4.tgz",
"integrity": "sha512-NL8jTlbo0Tn4dUEXEsUg8KeyG/Lkmc4Fnzb8JXN/Ykm9G4HNImjtABMJgkQoVjOBN/j2WAwDTRytdqJbZsah7w==",
"version": "7.2.6",
"resolved": "https://registry.npmjs.org/vite/-/vite-7.2.6.tgz",
"integrity": "sha512-tI2l/nFHC5rLh7+5+o7QjKjSR04ivXDF4jcgV0f/bTQ+OJiITy5S6gaynVsEM+7RqzufMnVbIon6Sr5x1SDYaQ==",
"dev": true,
"license": "MIT",
"peer": true,

View File

@@ -166,14 +166,19 @@ export default class AtlasConnection {
} else if (body.type === 'status') {
const status = body.data as { version: string };
if (!this.version) {
this.version = status.version;
} else if (this.version !== status.version) {
if (this.version !== status.version) {
console.log(`Version change detected: ${this.version} -> ${status.version}`);
const registration = await self.navigator.serviceWorker.ready;
registration.update();
this.version = status.version;
} else {
const regs = await self.navigator.serviceWorker.getRegistrations()
if (!regs.some(reg => reg.active?.scriptURL.includes(`version=${status.version}`))) {
console.log(`Service Worker out of date, updating to version ${status.version}`);
const registration = await self.navigator.serviceWorker.ready;
registration.update();
}
}
} else {
console.log('UNKNOWN', body.data);