From 900b11c3d0be4dcf88fb8a8aaff7c2234930b0ca Mon Sep 17 00:00:00 2001 From: Guillermo Puente Date: Wed, 28 Aug 2024 10:50:50 -0400 Subject: [PATCH 1/2] fix: moved service-worker script to assets folder --- package-lock.json | 244 ++++++++++++++++++++++++++++- package.json | 1 + src/utils/registerServiceWorker.ts | 2 +- vite.renderer.config.mts | 9 ++ 4 files changed, 252 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index a1835aa3..e16d8c06 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@powerhousedao/connect", - "version": "1.0.0-dev.66", + "version": "1.0.0-dev.74", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@powerhousedao/connect", - "version": "1.0.0-dev.66", + "version": "1.0.0-dev.74", "license": "AGPL-3.0-only", "dependencies": { "@powerhousedao/design-system": "1.0.0-alpha.160", @@ -85,6 +85,7 @@ "typescript": "^5.3.3", "vite": "^5.2.6", "vite-plugin-html": "^3.2.2", + "vite-plugin-static-copy": "^1.0.6", "vite-plugin-svgr": "^4.2.0", "vite-tsconfig-paths": "^4.2.0", "xvfb-maybe": "^0.2.1" @@ -24314,6 +24315,7 @@ }, "node_modules/npm/node_modules/@isaacs/cliui": { "version": "8.0.2", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -24330,6 +24332,7 @@ }, "node_modules/npm/node_modules/@isaacs/cliui/node_modules/ansi-regex": { "version": "6.0.1", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -24341,11 +24344,13 @@ }, "node_modules/npm/node_modules/@isaacs/cliui/node_modules/emoji-regex": { "version": "9.2.2", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/@isaacs/cliui/node_modules/string-width": { "version": "5.1.2", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -24362,6 +24367,7 @@ }, "node_modules/npm/node_modules/@isaacs/cliui/node_modules/strip-ansi": { "version": "7.1.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -24376,11 +24382,13 @@ }, "node_modules/npm/node_modules/@isaacs/string-locale-compare": { "version": "1.1.0", + "dev": true, "inBundle": true, "license": "ISC" }, "node_modules/npm/node_modules/@npmcli/agent": { "version": "2.2.2", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -24396,6 +24404,7 @@ }, "node_modules/npm/node_modules/@npmcli/arborist": { "version": "7.5.4", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -24444,6 +24453,7 @@ }, "node_modules/npm/node_modules/@npmcli/config": { "version": "8.3.4", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -24462,6 +24472,7 @@ }, "node_modules/npm/node_modules/@npmcli/fs": { "version": "3.1.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -24473,6 +24484,7 @@ }, "node_modules/npm/node_modules/@npmcli/git": { "version": "5.0.8", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -24492,6 +24504,7 @@ }, "node_modules/npm/node_modules/@npmcli/installed-package-contents": { "version": "2.1.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -24507,6 +24520,7 @@ }, "node_modules/npm/node_modules/@npmcli/map-workspaces": { "version": "3.0.6", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -24521,6 +24535,7 @@ }, "node_modules/npm/node_modules/@npmcli/metavuln-calculator": { "version": "7.1.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -24536,6 +24551,7 @@ }, "node_modules/npm/node_modules/@npmcli/name-from-folder": { "version": "2.0.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -24544,6 +24560,7 @@ }, "node_modules/npm/node_modules/@npmcli/node-gyp": { "version": "3.0.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -24552,6 +24569,7 @@ }, "node_modules/npm/node_modules/@npmcli/package-json": { "version": "5.2.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -24569,6 +24587,7 @@ }, "node_modules/npm/node_modules/@npmcli/promise-spawn": { "version": "7.0.2", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -24580,6 +24599,7 @@ }, "node_modules/npm/node_modules/@npmcli/query": { "version": "3.1.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -24591,6 +24611,7 @@ }, "node_modules/npm/node_modules/@npmcli/redact": { "version": "2.0.1", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -24599,6 +24620,7 @@ }, "node_modules/npm/node_modules/@npmcli/run-script": { "version": "8.1.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -24615,14 +24637,17 @@ }, "node_modules/npm/node_modules/@pkgjs/parseargs": { "version": "0.11.0", + "dev": true, "inBundle": true, "license": "MIT", + "optional": true, "engines": { "node": ">=14" } }, "node_modules/npm/node_modules/@sigstore/bundle": { "version": "2.3.2", + "dev": true, "inBundle": true, "license": "Apache-2.0", "dependencies": { @@ -24634,6 +24659,7 @@ }, "node_modules/npm/node_modules/@sigstore/core": { "version": "1.1.0", + "dev": true, "inBundle": true, "license": "Apache-2.0", "engines": { @@ -24642,6 +24668,7 @@ }, "node_modules/npm/node_modules/@sigstore/protobuf-specs": { "version": "0.3.2", + "dev": true, "inBundle": true, "license": "Apache-2.0", "engines": { @@ -24650,6 +24677,7 @@ }, "node_modules/npm/node_modules/@sigstore/sign": { "version": "2.3.2", + "dev": true, "inBundle": true, "license": "Apache-2.0", "dependencies": { @@ -24666,6 +24694,7 @@ }, "node_modules/npm/node_modules/@sigstore/tuf": { "version": "2.3.4", + "dev": true, "inBundle": true, "license": "Apache-2.0", "dependencies": { @@ -24678,6 +24707,7 @@ }, "node_modules/npm/node_modules/@sigstore/verify": { "version": "1.2.1", + "dev": true, "inBundle": true, "license": "Apache-2.0", "dependencies": { @@ -24691,6 +24721,7 @@ }, "node_modules/npm/node_modules/@tufjs/canonical-json": { "version": "2.0.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -24699,6 +24730,7 @@ }, "node_modules/npm/node_modules/@tufjs/models": { "version": "2.0.1", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -24711,6 +24743,7 @@ }, "node_modules/npm/node_modules/abbrev": { "version": "2.0.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -24719,6 +24752,7 @@ }, "node_modules/npm/node_modules/agent-base": { "version": "7.1.1", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -24730,6 +24764,7 @@ }, "node_modules/npm/node_modules/aggregate-error": { "version": "3.1.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -24742,6 +24777,7 @@ }, "node_modules/npm/node_modules/ansi-regex": { "version": "5.0.1", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -24750,6 +24786,7 @@ }, "node_modules/npm/node_modules/ansi-styles": { "version": "6.2.1", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -24761,21 +24798,25 @@ }, "node_modules/npm/node_modules/aproba": { "version": "2.0.0", + "dev": true, "inBundle": true, "license": "ISC" }, "node_modules/npm/node_modules/archy": { "version": "1.0.0", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/balanced-match": { "version": "1.0.2", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/bin-links": { "version": "4.0.4", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -24790,6 +24831,7 @@ }, "node_modules/npm/node_modules/binary-extensions": { "version": "2.3.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -24801,6 +24843,7 @@ }, "node_modules/npm/node_modules/brace-expansion": { "version": "2.0.1", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -24809,6 +24852,7 @@ }, "node_modules/npm/node_modules/cacache": { "version": "18.0.3", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -24831,6 +24875,7 @@ }, "node_modules/npm/node_modules/chalk": { "version": "5.3.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -24842,6 +24887,7 @@ }, "node_modules/npm/node_modules/chownr": { "version": "2.0.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -24850,6 +24896,7 @@ }, "node_modules/npm/node_modules/ci-info": { "version": "4.0.0", + "dev": true, "funding": [ { "type": "github", @@ -24864,6 +24911,7 @@ }, "node_modules/npm/node_modules/cidr-regex": { "version": "4.1.1", + "dev": true, "inBundle": true, "license": "BSD-2-Clause", "dependencies": { @@ -24875,6 +24923,7 @@ }, "node_modules/npm/node_modules/clean-stack": { "version": "2.2.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -24883,6 +24932,7 @@ }, "node_modules/npm/node_modules/cli-columns": { "version": "4.0.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -24895,6 +24945,7 @@ }, "node_modules/npm/node_modules/cmd-shim": { "version": "6.0.3", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -24903,6 +24954,7 @@ }, "node_modules/npm/node_modules/color-convert": { "version": "2.0.1", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -24914,16 +24966,19 @@ }, "node_modules/npm/node_modules/color-name": { "version": "1.1.4", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/common-ancestor-path": { "version": "1.0.1", + "dev": true, "inBundle": true, "license": "ISC" }, "node_modules/npm/node_modules/cross-spawn": { "version": "7.0.3", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -24937,6 +24992,7 @@ }, "node_modules/npm/node_modules/cross-spawn/node_modules/which": { "version": "2.0.2", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -24951,6 +25007,7 @@ }, "node_modules/npm/node_modules/cssesc": { "version": "3.0.0", + "dev": true, "inBundle": true, "license": "MIT", "bin": { @@ -24962,6 +25019,7 @@ }, "node_modules/npm/node_modules/debug": { "version": "4.3.5", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -24978,11 +25036,13 @@ }, "node_modules/npm/node_modules/debug/node_modules/ms": { "version": "2.1.2", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/diff": { "version": "5.2.0", + "dev": true, "inBundle": true, "license": "BSD-3-Clause", "engines": { @@ -24991,24 +25051,29 @@ }, "node_modules/npm/node_modules/eastasianwidth": { "version": "0.2.0", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/emoji-regex": { "version": "8.0.0", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/encoding": { "version": "0.1.13", + "dev": true, "inBundle": true, "license": "MIT", + "optional": true, "dependencies": { "iconv-lite": "^0.6.2" } }, "node_modules/npm/node_modules/env-paths": { "version": "2.2.1", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -25017,16 +25082,19 @@ }, "node_modules/npm/node_modules/err-code": { "version": "2.0.3", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/exponential-backoff": { "version": "3.1.1", + "dev": true, "inBundle": true, "license": "Apache-2.0" }, "node_modules/npm/node_modules/fastest-levenshtein": { "version": "1.0.16", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -25035,6 +25103,7 @@ }, "node_modules/npm/node_modules/foreground-child": { "version": "3.2.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25050,6 +25119,7 @@ }, "node_modules/npm/node_modules/fs-minipass": { "version": "3.0.3", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25061,6 +25131,7 @@ }, "node_modules/npm/node_modules/glob": { "version": "10.4.2", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25083,11 +25154,13 @@ }, "node_modules/npm/node_modules/graceful-fs": { "version": "4.2.11", + "dev": true, "inBundle": true, "license": "ISC" }, "node_modules/npm/node_modules/hosted-git-info": { "version": "7.0.2", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25099,11 +25172,13 @@ }, "node_modules/npm/node_modules/http-cache-semantics": { "version": "4.1.1", + "dev": true, "inBundle": true, "license": "BSD-2-Clause" }, "node_modules/npm/node_modules/http-proxy-agent": { "version": "7.0.2", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -25116,6 +25191,7 @@ }, "node_modules/npm/node_modules/https-proxy-agent": { "version": "7.0.5", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -25128,8 +25204,10 @@ }, "node_modules/npm/node_modules/iconv-lite": { "version": "0.6.3", + "dev": true, "inBundle": true, "license": "MIT", + "optional": true, "dependencies": { "safer-buffer": ">= 2.1.2 < 3.0.0" }, @@ -25139,6 +25217,7 @@ }, "node_modules/npm/node_modules/ignore-walk": { "version": "6.0.5", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25150,6 +25229,7 @@ }, "node_modules/npm/node_modules/imurmurhash": { "version": "0.1.4", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -25158,6 +25238,7 @@ }, "node_modules/npm/node_modules/indent-string": { "version": "4.0.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -25166,6 +25247,7 @@ }, "node_modules/npm/node_modules/ini": { "version": "4.1.3", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -25174,6 +25256,7 @@ }, "node_modules/npm/node_modules/init-package-json": { "version": "6.0.3", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25191,6 +25274,7 @@ }, "node_modules/npm/node_modules/ip-address": { "version": "9.0.5", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -25203,6 +25287,7 @@ }, "node_modules/npm/node_modules/ip-regex": { "version": "5.0.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -25214,6 +25299,7 @@ }, "node_modules/npm/node_modules/is-cidr": { "version": "5.1.0", + "dev": true, "inBundle": true, "license": "BSD-2-Clause", "dependencies": { @@ -25225,6 +25311,7 @@ }, "node_modules/npm/node_modules/is-fullwidth-code-point": { "version": "3.0.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -25233,16 +25320,19 @@ }, "node_modules/npm/node_modules/is-lambda": { "version": "1.0.1", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/isexe": { "version": "2.0.0", + "dev": true, "inBundle": true, "license": "ISC" }, "node_modules/npm/node_modules/jackspeak": { "version": "3.4.0", + "dev": true, "inBundle": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -25260,11 +25350,13 @@ }, "node_modules/npm/node_modules/jsbn": { "version": "1.1.0", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/json-parse-even-better-errors": { "version": "3.0.2", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -25273,6 +25365,7 @@ }, "node_modules/npm/node_modules/json-stringify-nice": { "version": "1.1.4", + "dev": true, "inBundle": true, "license": "ISC", "funding": { @@ -25281,6 +25374,7 @@ }, "node_modules/npm/node_modules/jsonparse": { "version": "1.3.1", + "dev": true, "engines": [ "node >= 0.2.0" ], @@ -25289,16 +25383,19 @@ }, "node_modules/npm/node_modules/just-diff": { "version": "6.0.2", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/just-diff-apply": { "version": "5.5.0", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/libnpmaccess": { "version": "8.0.6", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25311,6 +25408,7 @@ }, "node_modules/npm/node_modules/libnpmdiff": { "version": "6.1.4", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25329,6 +25427,7 @@ }, "node_modules/npm/node_modules/libnpmexec": { "version": "8.1.3", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25349,6 +25448,7 @@ }, "node_modules/npm/node_modules/libnpmfund": { "version": "5.0.12", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25360,6 +25460,7 @@ }, "node_modules/npm/node_modules/libnpmhook": { "version": "10.0.5", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25372,6 +25473,7 @@ }, "node_modules/npm/node_modules/libnpmorg": { "version": "6.0.6", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25384,6 +25486,7 @@ }, "node_modules/npm/node_modules/libnpmpack": { "version": "7.0.4", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25398,6 +25501,7 @@ }, "node_modules/npm/node_modules/libnpmpublish": { "version": "9.0.9", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25416,6 +25520,7 @@ }, "node_modules/npm/node_modules/libnpmsearch": { "version": "7.0.6", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25427,6 +25532,7 @@ }, "node_modules/npm/node_modules/libnpmteam": { "version": "6.0.5", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25439,6 +25545,7 @@ }, "node_modules/npm/node_modules/libnpmversion": { "version": "6.0.3", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25454,6 +25561,7 @@ }, "node_modules/npm/node_modules/lru-cache": { "version": "10.2.2", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -25462,6 +25570,7 @@ }, "node_modules/npm/node_modules/make-fetch-happen": { "version": "13.0.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25484,6 +25593,7 @@ }, "node_modules/npm/node_modules/minimatch": { "version": "9.0.5", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25498,6 +25608,7 @@ }, "node_modules/npm/node_modules/minipass": { "version": "7.1.2", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -25506,6 +25617,7 @@ }, "node_modules/npm/node_modules/minipass-collect": { "version": "2.0.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25517,6 +25629,7 @@ }, "node_modules/npm/node_modules/minipass-fetch": { "version": "3.0.5", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -25533,6 +25646,7 @@ }, "node_modules/npm/node_modules/minipass-flush": { "version": "1.0.5", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25544,6 +25658,7 @@ }, "node_modules/npm/node_modules/minipass-flush/node_modules/minipass": { "version": "3.3.6", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25555,6 +25670,7 @@ }, "node_modules/npm/node_modules/minipass-pipeline": { "version": "1.2.4", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25566,6 +25682,7 @@ }, "node_modules/npm/node_modules/minipass-pipeline/node_modules/minipass": { "version": "3.3.6", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25577,6 +25694,7 @@ }, "node_modules/npm/node_modules/minipass-sized": { "version": "1.0.3", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25588,6 +25706,7 @@ }, "node_modules/npm/node_modules/minipass-sized/node_modules/minipass": { "version": "3.3.6", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25599,6 +25718,7 @@ }, "node_modules/npm/node_modules/minizlib": { "version": "2.1.2", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -25611,6 +25731,7 @@ }, "node_modules/npm/node_modules/minizlib/node_modules/minipass": { "version": "3.3.6", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25622,6 +25743,7 @@ }, "node_modules/npm/node_modules/mkdirp": { "version": "1.0.4", + "dev": true, "inBundle": true, "license": "MIT", "bin": { @@ -25633,11 +25755,13 @@ }, "node_modules/npm/node_modules/ms": { "version": "2.1.3", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/mute-stream": { "version": "1.0.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -25646,6 +25770,7 @@ }, "node_modules/npm/node_modules/negotiator": { "version": "0.6.3", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -25654,6 +25779,7 @@ }, "node_modules/npm/node_modules/node-gyp": { "version": "10.1.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -25677,6 +25803,7 @@ }, "node_modules/npm/node_modules/node-gyp/node_modules/proc-log": { "version": "3.0.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -25685,6 +25812,7 @@ }, "node_modules/npm/node_modules/nopt": { "version": "7.2.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25699,6 +25827,7 @@ }, "node_modules/npm/node_modules/normalize-package-data": { "version": "6.0.2", + "dev": true, "inBundle": true, "license": "BSD-2-Clause", "dependencies": { @@ -25712,6 +25841,7 @@ }, "node_modules/npm/node_modules/npm-audit-report": { "version": "5.0.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -25720,6 +25850,7 @@ }, "node_modules/npm/node_modules/npm-bundled": { "version": "3.0.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25731,6 +25862,7 @@ }, "node_modules/npm/node_modules/npm-install-checks": { "version": "6.3.0", + "dev": true, "inBundle": true, "license": "BSD-2-Clause", "dependencies": { @@ -25742,6 +25874,7 @@ }, "node_modules/npm/node_modules/npm-normalize-package-bin": { "version": "3.0.1", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -25750,6 +25883,7 @@ }, "node_modules/npm/node_modules/npm-package-arg": { "version": "11.0.2", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25764,6 +25898,7 @@ }, "node_modules/npm/node_modules/npm-packlist": { "version": "8.0.2", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25775,6 +25910,7 @@ }, "node_modules/npm/node_modules/npm-pick-manifest": { "version": "9.1.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25789,6 +25925,7 @@ }, "node_modules/npm/node_modules/npm-profile": { "version": "10.0.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25801,6 +25938,7 @@ }, "node_modules/npm/node_modules/npm-registry-fetch": { "version": "17.1.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25819,6 +25957,7 @@ }, "node_modules/npm/node_modules/npm-user-validate": { "version": "2.0.1", + "dev": true, "inBundle": true, "license": "BSD-2-Clause", "engines": { @@ -25827,6 +25966,7 @@ }, "node_modules/npm/node_modules/p-map": { "version": "4.0.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -25841,11 +25981,13 @@ }, "node_modules/npm/node_modules/package-json-from-dist": { "version": "1.0.0", + "dev": true, "inBundle": true, "license": "BlueOak-1.0.0" }, "node_modules/npm/node_modules/pacote": { "version": "18.0.6", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25876,6 +26018,7 @@ }, "node_modules/npm/node_modules/parse-conflict-json": { "version": "3.0.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25889,6 +26032,7 @@ }, "node_modules/npm/node_modules/path-key": { "version": "3.1.1", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -25897,6 +26041,7 @@ }, "node_modules/npm/node_modules/path-scurry": { "version": "1.11.1", + "dev": true, "inBundle": true, "license": "BlueOak-1.0.0", "dependencies": { @@ -25912,6 +26057,7 @@ }, "node_modules/npm/node_modules/postcss-selector-parser": { "version": "6.1.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -25924,6 +26070,7 @@ }, "node_modules/npm/node_modules/proc-log": { "version": "4.2.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -25932,6 +26079,7 @@ }, "node_modules/npm/node_modules/proggy": { "version": "2.0.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -25940,6 +26088,7 @@ }, "node_modules/npm/node_modules/promise-all-reject-late": { "version": "1.0.1", + "dev": true, "inBundle": true, "license": "ISC", "funding": { @@ -25948,6 +26097,7 @@ }, "node_modules/npm/node_modules/promise-call-limit": { "version": "3.0.1", + "dev": true, "inBundle": true, "license": "ISC", "funding": { @@ -25956,11 +26106,13 @@ }, "node_modules/npm/node_modules/promise-inflight": { "version": "1.0.1", + "dev": true, "inBundle": true, "license": "ISC" }, "node_modules/npm/node_modules/promise-retry": { "version": "2.0.1", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -25973,6 +26125,7 @@ }, "node_modules/npm/node_modules/promzard": { "version": "1.0.2", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -25984,6 +26137,7 @@ }, "node_modules/npm/node_modules/qrcode-terminal": { "version": "0.12.0", + "dev": true, "inBundle": true, "bin": { "qrcode-terminal": "bin/qrcode-terminal.js" @@ -25991,6 +26145,7 @@ }, "node_modules/npm/node_modules/read": { "version": "3.0.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -26002,6 +26157,7 @@ }, "node_modules/npm/node_modules/read-cmd-shim": { "version": "4.0.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -26010,6 +26166,7 @@ }, "node_modules/npm/node_modules/read-package-json-fast": { "version": "3.0.2", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -26022,6 +26179,7 @@ }, "node_modules/npm/node_modules/retry": { "version": "0.12.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -26030,11 +26188,14 @@ }, "node_modules/npm/node_modules/safer-buffer": { "version": "2.1.2", + "dev": true, "inBundle": true, - "license": "MIT" + "license": "MIT", + "optional": true }, "node_modules/npm/node_modules/semver": { "version": "7.6.2", + "dev": true, "inBundle": true, "license": "ISC", "bin": { @@ -26046,6 +26207,7 @@ }, "node_modules/npm/node_modules/shebang-command": { "version": "2.0.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -26057,6 +26219,7 @@ }, "node_modules/npm/node_modules/shebang-regex": { "version": "3.0.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -26065,6 +26228,7 @@ }, "node_modules/npm/node_modules/signal-exit": { "version": "4.1.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -26076,6 +26240,7 @@ }, "node_modules/npm/node_modules/sigstore": { "version": "2.3.1", + "dev": true, "inBundle": true, "license": "Apache-2.0", "dependencies": { @@ -26092,6 +26257,7 @@ }, "node_modules/npm/node_modules/smart-buffer": { "version": "4.2.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -26101,6 +26267,7 @@ }, "node_modules/npm/node_modules/socks": { "version": "2.8.3", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -26114,6 +26281,7 @@ }, "node_modules/npm/node_modules/socks-proxy-agent": { "version": "8.0.4", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -26127,6 +26295,7 @@ }, "node_modules/npm/node_modules/spdx-correct": { "version": "3.2.0", + "dev": true, "inBundle": true, "license": "Apache-2.0", "dependencies": { @@ -26136,6 +26305,7 @@ }, "node_modules/npm/node_modules/spdx-correct/node_modules/spdx-expression-parse": { "version": "3.0.1", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -26145,11 +26315,13 @@ }, "node_modules/npm/node_modules/spdx-exceptions": { "version": "2.5.0", + "dev": true, "inBundle": true, "license": "CC-BY-3.0" }, "node_modules/npm/node_modules/spdx-expression-parse": { "version": "4.0.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -26159,16 +26331,19 @@ }, "node_modules/npm/node_modules/spdx-license-ids": { "version": "3.0.18", + "dev": true, "inBundle": true, "license": "CC0-1.0" }, "node_modules/npm/node_modules/sprintf-js": { "version": "1.1.3", + "dev": true, "inBundle": true, "license": "BSD-3-Clause" }, "node_modules/npm/node_modules/ssri": { "version": "10.0.6", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -26180,6 +26355,7 @@ }, "node_modules/npm/node_modules/string-width": { "version": "4.2.3", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -26194,6 +26370,7 @@ "node_modules/npm/node_modules/string-width-cjs": { "name": "string-width", "version": "4.2.3", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -26207,6 +26384,7 @@ }, "node_modules/npm/node_modules/strip-ansi": { "version": "6.0.1", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -26219,6 +26397,7 @@ "node_modules/npm/node_modules/strip-ansi-cjs": { "name": "strip-ansi", "version": "6.0.1", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -26230,6 +26409,7 @@ }, "node_modules/npm/node_modules/supports-color": { "version": "9.4.0", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -26241,6 +26421,7 @@ }, "node_modules/npm/node_modules/tar": { "version": "6.2.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -26257,6 +26438,7 @@ }, "node_modules/npm/node_modules/tar/node_modules/fs-minipass": { "version": "2.1.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -26268,6 +26450,7 @@ }, "node_modules/npm/node_modules/tar/node_modules/fs-minipass/node_modules/minipass": { "version": "3.3.6", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -26279,6 +26462,7 @@ }, "node_modules/npm/node_modules/tar/node_modules/minipass": { "version": "5.0.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -26287,16 +26471,19 @@ }, "node_modules/npm/node_modules/text-table": { "version": "0.2.0", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/tiny-relative-date": { "version": "1.3.0", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/treeverse": { "version": "3.0.0", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -26305,6 +26492,7 @@ }, "node_modules/npm/node_modules/tuf-js": { "version": "2.2.1", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -26318,6 +26506,7 @@ }, "node_modules/npm/node_modules/unique-filename": { "version": "3.0.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -26329,6 +26518,7 @@ }, "node_modules/npm/node_modules/unique-slug": { "version": "4.0.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -26340,11 +26530,13 @@ }, "node_modules/npm/node_modules/util-deprecate": { "version": "1.0.2", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/validate-npm-package-license": { "version": "3.0.4", + "dev": true, "inBundle": true, "license": "Apache-2.0", "dependencies": { @@ -26354,6 +26546,7 @@ }, "node_modules/npm/node_modules/validate-npm-package-license/node_modules/spdx-expression-parse": { "version": "3.0.1", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -26363,6 +26556,7 @@ }, "node_modules/npm/node_modules/validate-npm-package-name": { "version": "5.0.1", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -26371,11 +26565,13 @@ }, "node_modules/npm/node_modules/walk-up-path": { "version": "3.0.1", + "dev": true, "inBundle": true, "license": "ISC" }, "node_modules/npm/node_modules/which": { "version": "4.0.0", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -26390,6 +26586,7 @@ }, "node_modules/npm/node_modules/which/node_modules/isexe": { "version": "3.1.1", + "dev": true, "inBundle": true, "license": "ISC", "engines": { @@ -26398,6 +26595,7 @@ }, "node_modules/npm/node_modules/wrap-ansi": { "version": "8.1.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -26415,6 +26613,7 @@ "node_modules/npm/node_modules/wrap-ansi-cjs": { "name": "wrap-ansi", "version": "7.0.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -26431,6 +26630,7 @@ }, "node_modules/npm/node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { "version": "4.3.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -26445,6 +26645,7 @@ }, "node_modules/npm/node_modules/wrap-ansi/node_modules/ansi-regex": { "version": "6.0.1", + "dev": true, "inBundle": true, "license": "MIT", "engines": { @@ -26456,11 +26657,13 @@ }, "node_modules/npm/node_modules/wrap-ansi/node_modules/emoji-regex": { "version": "9.2.2", + "dev": true, "inBundle": true, "license": "MIT" }, "node_modules/npm/node_modules/wrap-ansi/node_modules/string-width": { "version": "5.1.2", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -26477,6 +26680,7 @@ }, "node_modules/npm/node_modules/wrap-ansi/node_modules/strip-ansi": { "version": "7.1.0", + "dev": true, "inBundle": true, "license": "MIT", "dependencies": { @@ -26491,6 +26695,7 @@ }, "node_modules/npm/node_modules/write-file-atomic": { "version": "5.0.1", + "dev": true, "inBundle": true, "license": "ISC", "dependencies": { @@ -26503,6 +26708,7 @@ }, "node_modules/npm/node_modules/yallist": { "version": "4.0.0", + "dev": true, "inBundle": true, "license": "ISC" }, @@ -33121,6 +33327,38 @@ "integrity": "sha512-sTitTPYnn23esFR3RlqYBWn4c45WGeLcsKzQiUpXJAyfcWkolvlYpV8FLo7JishK946oQwMFUCHXQ9AjGPKExw==", "dev": true }, + "node_modules/vite-plugin-static-copy": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/vite-plugin-static-copy/-/vite-plugin-static-copy-1.0.6.tgz", + "integrity": "sha512-3uSvsMwDVFZRitqoWHj0t4137Kz7UynnJeq1EZlRW7e25h2068fyIZX4ORCCOAkfp1FklGxJNVJBkBOD+PZIew==", + "dev": true, + "dependencies": { + "chokidar": "^3.5.3", + "fast-glob": "^3.2.11", + "fs-extra": "^11.1.0", + "picocolors": "^1.0.0" + }, + "engines": { + "node": "^18.0.0 || >=20.0.0" + }, + "peerDependencies": { + "vite": "^5.0.0" + } + }, + "node_modules/vite-plugin-static-copy/node_modules/fs-extra": { + "version": "11.2.0", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.2.0.tgz", + "integrity": "sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.0", + "jsonfile": "^6.0.1", + "universalify": "^2.0.0" + }, + "engines": { + "node": ">=14.14" + } + }, "node_modules/vite-plugin-svgr": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/vite-plugin-svgr/-/vite-plugin-svgr-4.2.0.tgz", diff --git a/package.json b/package.json index ba7a54e1..8ac6aae9 100644 --- a/package.json +++ b/package.json @@ -84,6 +84,7 @@ "typescript": "^5.3.3", "vite": "^5.2.6", "vite-plugin-html": "^3.2.2", + "vite-plugin-static-copy": "^1.0.6", "vite-plugin-svgr": "^4.2.0", "vite-tsconfig-paths": "^4.2.0", "xvfb-maybe": "^0.2.1" diff --git a/src/utils/registerServiceWorker.ts b/src/utils/registerServiceWorker.ts index dbafb700..fc8f975c 100644 --- a/src/utils/registerServiceWorker.ts +++ b/src/utils/registerServiceWorker.ts @@ -3,7 +3,7 @@ import connectConfig from 'connect-config'; const serviceWorkerScriptPath = [ connectConfig.routerBasename, - 'service-worker.js', + 'assets/service-worker.js', ] .join('/') .replace(/\/{2,}/gm, '/'); diff --git a/vite.renderer.config.mts b/vite.renderer.config.mts index 4b061fde..cdac9c4c 100644 --- a/vite.renderer.config.mts +++ b/vite.renderer.config.mts @@ -6,6 +6,7 @@ import jotaiReactRefresh from 'jotai/babel/plugin-react-refresh'; import path from 'path'; import { HtmlTagDescriptor, PluginOption, defineConfig, loadEnv } from 'vite'; import { createHtmlPlugin } from 'vite-plugin-html'; +import { viteStaticCopy } from 'vite-plugin-static-copy'; import svgr from 'vite-plugin-svgr'; import pkg from './package.json'; @@ -56,6 +57,14 @@ export default defineConfig(({ mode }) => { }, }), generateVersionPlugin(isProd ? requiresHardRefresh : false), + viteStaticCopy({ + targets: [ + { + src: 'public/service-worker.js', + dest: 'assets', + }, + ], + }), ]; const authToken = process.env.SENTRY_AUTH_TOKEN; From fa9709256a7e89f6d090ae671138f08473994838 Mon Sep 17 00:00:00 2001 From: Guillermo Puente Date: Wed, 28 Aug 2024 17:15:24 -0400 Subject: [PATCH 2/2] feat: added service-worker.ts --- nginx.conf | 7 ++++ package-lock.json | 33 --------------- package.json | 6 +-- .../service-worker.ts | 40 ++++++++++++++----- src/utils/registerServiceWorker.ts | 2 +- tsconfig.sw.json | 15 +++++++ vite.renderer.config.mts | 9 ----- 7 files changed, 55 insertions(+), 57 deletions(-) rename public/service-worker.js => src/service-worker.ts (58%) create mode 100644 tsconfig.sw.json diff --git a/nginx.conf b/nginx.conf index 68e7f60e..dce80dfa 100644 --- a/nginx.conf +++ b/nginx.conf @@ -42,6 +42,13 @@ server { add_header Cache-Control "public"; } + location ${BASE_PATH}/service-worker.js { + alias /usr/share/nginx/html/service-worker.js; + expires -1; + access_log off; + add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0"; + } + location ${BASE_PATH} { root /usr/share/nginx/html; index index.html; diff --git a/package-lock.json b/package-lock.json index e16d8c06..8f9f0f57 100644 --- a/package-lock.json +++ b/package-lock.json @@ -85,7 +85,6 @@ "typescript": "^5.3.3", "vite": "^5.2.6", "vite-plugin-html": "^3.2.2", - "vite-plugin-static-copy": "^1.0.6", "vite-plugin-svgr": "^4.2.0", "vite-tsconfig-paths": "^4.2.0", "xvfb-maybe": "^0.2.1" @@ -33327,38 +33326,6 @@ "integrity": "sha512-sTitTPYnn23esFR3RlqYBWn4c45WGeLcsKzQiUpXJAyfcWkolvlYpV8FLo7JishK946oQwMFUCHXQ9AjGPKExw==", "dev": true }, - "node_modules/vite-plugin-static-copy": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/vite-plugin-static-copy/-/vite-plugin-static-copy-1.0.6.tgz", - "integrity": "sha512-3uSvsMwDVFZRitqoWHj0t4137Kz7UynnJeq1EZlRW7e25h2068fyIZX4ORCCOAkfp1FklGxJNVJBkBOD+PZIew==", - "dev": true, - "dependencies": { - "chokidar": "^3.5.3", - "fast-glob": "^3.2.11", - "fs-extra": "^11.1.0", - "picocolors": "^1.0.0" - }, - "engines": { - "node": "^18.0.0 || >=20.0.0" - }, - "peerDependencies": { - "vite": "^5.0.0" - } - }, - "node_modules/vite-plugin-static-copy/node_modules/fs-extra": { - "version": "11.2.0", - "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.2.0.tgz", - "integrity": "sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==", - "dev": true, - "dependencies": { - "graceful-fs": "^4.2.0", - "jsonfile": "^6.0.1", - "universalify": "^2.0.0" - }, - "engines": { - "node": ">=14.14" - } - }, "node_modules/vite-plugin-svgr": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/vite-plugin-svgr/-/vite-plugin-svgr-4.2.0.tgz", diff --git a/package.json b/package.json index 8ac6aae9..e39cf335 100644 --- a/package.json +++ b/package.json @@ -26,11 +26,12 @@ "format": "prettier --write \"**/*.+(js|ts|jsx|tsx|json)\"", "dev:web": "vite -c vite.renderer.config.mts", "dev:nocache": "rm -rf node_modules/.vite && rm -rf node_modules/.cache && npm run dev:web", - "build:web": "NODE_OPTIONS=--max-old-space-size=6144 vite build -c vite.renderer.config.mts", + "build:web": "NODE_OPTIONS=--max-old-space-size=6144 vite build -c vite.renderer.config.mts && npm run build:service-worker", "preview:web": "vite preview -c vite.renderer.config.mts", "release": "semantic-release", "e2e": "playwright test", - "cy:open": "cypress open" + "cy:open": "cypress open", + "build:service-worker": "tsc --build ./tsconfig.sw.json" }, "devDependencies": { "@commitlint/cli": "^18.4.3", @@ -84,7 +85,6 @@ "typescript": "^5.3.3", "vite": "^5.2.6", "vite-plugin-html": "^3.2.2", - "vite-plugin-static-copy": "^1.0.6", "vite-plugin-svgr": "^4.2.0", "vite-tsconfig-paths": "^4.2.0", "xvfb-maybe": "^0.2.1" diff --git a/public/service-worker.js b/src/service-worker.ts similarity index 58% rename from public/service-worker.js rename to src/service-worker.ts index 97b1e910..4e0e2ad7 100644 --- a/public/service-worker.js +++ b/src/service-worker.ts @@ -1,26 +1,41 @@ +/// + +const _self = self as unknown as ServiceWorkerGlobalScope; + const VERSION_CACHE = 'version-cache'; const VERSION_KEY = 'app-version'; -self.addEventListener('install', event => { - self.skipWaiting(); +_self.addEventListener('install', () => { + _self.skipWaiting().catch(console.error); }); -self.addEventListener('activate', event => { - event.waitUntil(self.clients.claim()); +_self.addEventListener('activate', (event: ExtendableEvent) => { + event.waitUntil(_self.clients.claim()); }); +interface SeriveWorkerMessage extends ExtendableMessageEvent { + data: { + type: string; + version: string; + }; +} -self.addEventListener('message', async event => { +interface VersionResponse { + version: string; + requiresHardRefresh: boolean; +} + +_self.addEventListener('message', async (event: SeriveWorkerMessage) => { if (event.data && event.data.type === 'SET_APP_VERSION') { const cache = await caches.open(VERSION_CACHE); await cache.put(VERSION_KEY, new Response(event.data.version)); } - }); +}); async function checkForUpdates() { try { const response = await fetch('/version.json', { cache: 'no-store' }); - const newVersion = await response.json(); + const newVersion = (await response.json()) as VersionResponse; const cache = await caches.open(VERSION_CACHE); const cachedResponse = await cache.match(VERSION_KEY); @@ -29,7 +44,7 @@ async function checkForUpdates() { if (cachedResponse) { currentVersion = await cachedResponse.text(); } - + if (currentVersion === '') { // Initial cache await cache.put(VERSION_KEY, new Response(newVersion.version)); @@ -38,9 +53,12 @@ async function checkForUpdates() { console.log('Current version:', currentVersion); console.log('New version:', newVersion.version); - const clients = await self.clients.matchAll(); + const clients = await _self.clients.matchAll(); clients.forEach(client => { - client.postMessage({ type: 'NEW_VERSION_AVAILABLE', requiresHardRefresh: newVersion.requiresHardRefresh }); + client.postMessage({ + type: 'NEW_VERSION_AVAILABLE', + requiresHardRefresh: newVersion.requiresHardRefresh, + }); }); // Update the stored version @@ -52,4 +70,4 @@ async function checkForUpdates() { } // Check for updates every minute -setInterval(checkForUpdates, 60 * 1000); // 60 seconds +setInterval(checkForUpdates, 5 * 1000); // 60 seconds diff --git a/src/utils/registerServiceWorker.ts b/src/utils/registerServiceWorker.ts index fc8f975c..dbafb700 100644 --- a/src/utils/registerServiceWorker.ts +++ b/src/utils/registerServiceWorker.ts @@ -3,7 +3,7 @@ import connectConfig from 'connect-config'; const serviceWorkerScriptPath = [ connectConfig.routerBasename, - 'assets/service-worker.js', + 'service-worker.js', ] .join('/') .replace(/\/{2,}/gm, '/'); diff --git a/tsconfig.sw.json b/tsconfig.sw.json new file mode 100644 index 00000000..a9339f9d --- /dev/null +++ b/tsconfig.sw.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "isolatedModules": false, + "strict": true, + "module": "ESNext", + "target": "ESNext", + "lib": ["es2019", "es6", "dom", "webworker"], + "noEmit": false, + "moduleResolution": "node", + "skipLibCheck": true, + "outDir": "./dist" + }, + "files": ["./src/service-worker.ts"] +} diff --git a/vite.renderer.config.mts b/vite.renderer.config.mts index cdac9c4c..4b061fde 100644 --- a/vite.renderer.config.mts +++ b/vite.renderer.config.mts @@ -6,7 +6,6 @@ import jotaiReactRefresh from 'jotai/babel/plugin-react-refresh'; import path from 'path'; import { HtmlTagDescriptor, PluginOption, defineConfig, loadEnv } from 'vite'; import { createHtmlPlugin } from 'vite-plugin-html'; -import { viteStaticCopy } from 'vite-plugin-static-copy'; import svgr from 'vite-plugin-svgr'; import pkg from './package.json'; @@ -57,14 +56,6 @@ export default defineConfig(({ mode }) => { }, }), generateVersionPlugin(isProd ? requiresHardRefresh : false), - viteStaticCopy({ - targets: [ - { - src: 'public/service-worker.js', - dest: 'assets', - }, - ], - }), ]; const authToken = process.env.SENTRY_AUTH_TOKEN;