diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md index 5abfbb4..5263696 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ b/.github/ISSUE_TEMPLATE/bug-report.md @@ -36,7 +36,7 @@ If applicable, add screenshots to help explain your problem. **Bug occurs on official PairDrop instance https://pairdrop.net/** No | Yes -Version: v1.11.2 +Version: v1.11.0 **Bug occurs on self-hosted PairDrop instance** No | Yes @@ -44,7 +44,7 @@ No | Yes **Self-Hosted Setup** Proxy: Nginx | Apache2 Deployment: docker run | docker compose | npm run start:prod -Version: v1.11.2 +Version: v1.11.0 **Additional context** Add any other context about the problem here. diff --git a/docs/how-to.md b/docs/how-to.md index df6d3a1..fcad02f 100644 --- a/docs/how-to.md +++ b/docs/how-to.md @@ -45,11 +45,11 @@ This pairdrop-cli version was released alongside v1.10.4 #### Linux / Mac 1. Download the latest _pairdrop-cli.zip_ from the [releases page](https://github.com/schlagmichdoch/PairDrop/releases) ```shell - wget "https://github.com/schlagmichdoch/PairDrop/releases/download/v1.11.2/pairdrop-cli.zip" + wget "https://github.com/schlagmichdoch/PairDrop/releases/download/v1.11.0/pairdrop-cli.zip" ``` or ```shell - curl -LO "https://github.com/schlagmichdoch/PairDrop/releases/download/v1.11.2/pairdrop-cli.zip" + curl -LO "https://github.com/schlagmichdoch/PairDrop/releases/download/v1.11.0/pairdrop-cli.zip" ``` 2. Unzip the archive to a folder of your choice e.g. `/usr/share/pairdrop-cli/` ```shell diff --git a/package-lock.json b/package-lock.json index be60a08..bdc9acd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "pairdrop", - "version": "1.11.2", + "version": "1.11.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "pairdrop", - "version": "1.11.2", + "version": "1.11.0", "license": "ISC", "dependencies": { "express": "^4.18.2", @@ -318,16 +318,16 @@ } }, "node_modules/get-intrinsic": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", - "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.7.tgz", + "integrity": "sha512-VW6Pxhsrk0KAOqs3WEd0klDiF/+V7gQOpAvY1jVU/LHmaD/kQO4523aiJuikX/QAKYiW6x8Jh+RJej1almdtCA==", "dependencies": { - "call-bind-apply-helpers": "^1.0.2", + "call-bind-apply-helpers": "^1.0.1", "es-define-property": "^1.0.1", "es-errors": "^1.3.0", - "es-object-atoms": "^1.1.1", + "es-object-atoms": "^1.0.0", "function-bind": "^1.1.2", - "get-proto": "^1.0.1", + "get-proto": "^1.0.0", "gopd": "^1.2.0", "has-symbols": "^1.1.0", "hasown": "^2.0.2", @@ -815,9 +815,9 @@ } }, "node_modules/ws": { - "version": "8.18.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.1.tgz", - "integrity": "sha512-RKW2aJZMXeMxVpnZ6bck+RswznaxmzdULiBr6KY7XkTnW8uvt0iT9H5DkHUChXrc+uurzwa0rVI16n/Xzjdz1w==", + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", "engines": { "node": ">=10.0.0" }, diff --git a/package.json b/package.json index e4032f6..b36e5d7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pairdrop", - "version": "1.11.2", + "version": "1.11.0", "type": "module", "description": "", "main": "server/index.js", diff --git a/public/index.html b/public/index.html index 70eda5b..45df0e4 100644 --- a/public/index.html +++ b/public/index.html @@ -668,7 +668,7 @@

PairDrop

-
v1.11.2
+
v1.11.0
@@ -811,9 +811,9 @@ - - - + + + diff --git a/public/lang/bn.json b/public/lang/bn.json index 1795d97..4f3f52a 100644 --- a/public/lang/bn.json +++ b/public/lang/bn.json @@ -1,35 +1,6 @@ { "header": { "about_title": "পেয়ার ড্রপ সম্পর্কে", - "install_title": "পেয়ার ড্রপ ইন্সটল করুন", - "pair-device_title": "ডিভাইস স্থায়ী ভাবে যুক্ত করুন", - "cancel-share-mode": "বাতিল", - "theme-light_title": "সবসময় সাদা থিম ব্যাবহার", - "language-selector_title": "ভাষা সেট করুন", - "about_aria-label": "পেয়ারড্রপ সম্পর্কে", - "theme-auto_title": "থিমের ধরন ডিভাইস অনুযায়ী", - "theme-dark_title": "সবসময় কালো থিব ব্যাবহার", - "notification_title": "নোটিফিকেশন চালু করুন", - "edit-paired-devices_title": "যুক্ত ডিভাইস সম্পাদনা করুন", - "join-public-room_title": "সাময়িক ভাবে পাবলিক রুমে জয়েন করুন", - "edit-share-mode": "সম্পাদনা", - "expand_title": "হেডার বোতামের সারিটি বড় করুন" - }, - "instructions": { - "activate-share-mode-and-other-file": "আর একটি ফাইল যোগ করুন", - "activate-share-mode-shared-file": "পাঠানো ফাইল", - "no-peers-subtitle": "ডিভাইস প্রদর্শিত হতে নতুন ডিভাইস যুক্ত করুন অথবা পাবলিক রুমে জয়েন দিন", - "no-peers-title": "ফাইল পাঠানোর জন্য অন্যান্য ডিভাইসে পেয়ারড্রপ খুলুন", - "x-instructions_data-drop-bg": "প্রাপক নির্বাচন করতে ছেড়ে দিন", - "no-peers_data-drop-bg": "প্রাপক নির্বাচন ছেড়ে দিন", - "x-instructions_desktop": "ফাইল পাঠাতে ক্লিক করুন অথবা মেসেজ পাঠাতে ডানে চাপুন", - "x-instructions_mobile": "ফাইল পাঠাতে ক্লিক করুন অথবা বেশি চেপে মেসেজ পাঠান", - "x-instructions_data-drop-peer": "পিয়ারকে পাঠানোর জন্য রিলিজ করুন", - "x-instructions-share-mode_desktop": "পাঠাতে ক্লিক করুন", - "x-instructions-share-mode_mobile": "পাঠাতে ক্লিক করুন", - "activate-share-mode-base": "অন্য ডিভাইসে পাঠাতে পেয়ারড্রপ খুলুন", - "activate-share-mode-and-other-files-plural": "অন্য ফাইল যোগ করুন", - "activate-share-mode-shared-text": "পাঠানো টেক্সট", - "activate-share-mode-shared-files-plural": "পাঠানো ফাইল গুলো" + "install_title": "পেয়ার ড্রপ ইন্সটল করুন" } } diff --git a/public/lang/ja.json b/public/lang/ja.json index 949621a..6184de8 100644 --- a/public/lang/ja.json +++ b/public/lang/ja.json @@ -1,18 +1,18 @@ { "footer": { "webrtc": "(WebRTCが無効なため)", - "public-room-devices_title": "公開ルーム内のデバイスは、別のネットワークからもアクセスできます。", + "public-room-devices_title": "公開ルーム内のデバイスは、接続中のネットワークと関係なくアクセスできます。", "display-name_data-placeholder": "読み込み中…", "display-name_title": "デバイス名を変更する", "traffic": "この通信は", - "paired-devices_title": "ペアリング済みデバイスは、別のネットワークからもアクセスできます。", + "paired-devices_title": "ペアリング済みデバイスであれば、接続中のネットワークに関わらずアクセスできます。", "public-room-devices": "ルーム{{roomId}}", "paired-devices": "ペアリング済みデバイス", - "on-this-network": "このネットワーク内", + "on-this-network": "このネットワーク上", "routed": "サーバーを経由します", "discovery": "このデバイスを検出可能なネットワーク:", - "on-this-network_title": "このネットワーク内のすべてのデバイスからアクセスできます。", - "known-as": "このデバイスの名前:" + "on-this-network_title": "このネットワーク上のすべてのデバイスからアクセスできます。", + "known-as": "他のデバイスに表示される名前:" }, "notifications": { "request-title": "{{name}}は{{count}}個の{{descriptor}}を共有しようとしています", @@ -20,12 +20,12 @@ "message-received": "{{name}}から受信したメッセージ(クリックしてコピー)", "rate-limit-join-key": "レート制限に到達しました。10秒待ってから再度お試しください。", "connecting": "接続中…", - "pairing-key-invalidated": "コード{{key}}は無効になりました", + "pairing-key-invalidated": "コード{{key}}が失効しました", "pairing-key-invalid": "無効なコード", - "connected": "接続済み", + "connected": "接続しました", "pairing-not-persistent": "このデバイスとのペアリングは解除される可能性があります", "text-content-incorrect": "無効なテキスト内容です", - "message-transfer-completed": "メッセージを送信しました", + "message-transfer-completed": "メッセージの送信が完了しました", "file-transfer-completed": "ファイル転送が完了しました", "file-content-incorrect": "無効なファイル内容です", "files-incorrect": "ファイルが間違っています", @@ -39,7 +39,7 @@ "copied-to-clipboard-error": "コピーできませんでした。手動でコピーしてください。", "pairing-success": "ペアリングしました", "clipboard-content-incorrect": "無効なクリップボード内容です", - "display-name-changed-temporarily": "この接続でのみデバイス名が変更されました", + "display-name-changed-temporarily": "この接続のみデバイス名が変更されました", "copied-to-clipboard": "クリップボードにコピーしました", "offline": "オフラインです", "pairing-tabs-error": "同じWebブラウザーで開いたタブ同士でペアリングすることはできません", @@ -59,7 +59,7 @@ }, "header": { "cancel-share-mode": "キャンセル", - "theme-auto_title": "システムのテーマに合わせる", + "theme-auto_title": "システムテーマに合わせる", "install_title": "PairDropをインストール", "theme-dark_title": "常にダークテーマを使用する", "pair-device_title": "他のデバイスとペアリングする", @@ -74,15 +74,15 @@ "expand_title": "ヘッダーボタン列を拡大する" }, "instructions": { - "x-instructions_mobile": "タップでファイル送信、長押しでメッセージ送信", + "x-instructions_mobile": "タップでファイルを送信、長押しでメッセージを送信します", "x-instructions-share-mode_desktop": "クリックして{{descriptor}}を送信", "activate-share-mode-and-other-files-plural": "とその他{{count}}個のファイル", "x-instructions-share-mode_mobile": "タップして{{descriptor}}を送信", "activate-share-mode-base": "他のデバイスでPairDropを開いて送信します", - "no-peers-subtitle": "ペアリングや公開ルームを使うと、別のネットワークにあるデバイスと共有できます", + "no-peers-subtitle": "ペアリングや公開ルームを使用すると、他のネットワーク上のデバイスと共有できます", "activate-share-mode-shared-text": "共有されたテキスト", - "x-instructions_desktop": "左クリックでファイル送信、右クリックでメッセージ送信", - "no-peers-title": "ファイル共有するには他のデバイスでPairDropを開きます", + "x-instructions_desktop": "左クリックでファイルを送信、右クリックでメッセージを送信します", + "no-peers-title": "ファイルを共有するには他のデバイスでPairDropを開いてください", "x-instructions_data-drop-peer": "ドロップするとこのデバイスに送信します", "x-instructions_data-drop-bg": "送信したいデバイスの上でドロップしてください", "no-peers_data-drop-bg": "送信したいデバイスの上でドロップしてください", @@ -94,7 +94,7 @@ "peer-ui": { "processing": "処理中…", "click-to-send-share-mode": "クリックして{{descriptor}}を送信", - "click-to-send": "左クリックでファイル送信、右クリックでメッセージ送信", + "click-to-send": "左クリックでファイルを送信、右クリックでメッセージを送信します", "waiting": "待機中…", "connection-hash": "エンドツーエンド暗号化のセキュリティを確認するには、両方のデバイスのセキュリティナンバーを確認してください", "preparing": "準備中…", @@ -102,8 +102,8 @@ }, "dialogs": { "base64-paste-to-send": "ここをタップして{{type}}を送信", - "auto-accept-instructions-2": "」が有効なら、そのデバイスが送信したすべてのファイルを自動で受け入れます。", - "receive-text-title": "メッセージを受信", + "auto-accept-instructions-2": "」を有効にすると、そのデバイスから送信されたすべてのファイルを自動的に受け入れます。", + "receive-text-title": "メッセージを受信しました", "edit-paired-devices-title": "ペアリング設定", "cancel": "キャンセル", "auto-accept-instructions-1": "「", @@ -123,19 +123,19 @@ "file-other-description-image": "とその他1個の画像", "temporary-public-room-title": "公開ルーム", "base64-files": "ファイル", - "has-sent": "が送信:", + "has-sent": "が送信しました:", "file-other-description-file": "とその他1個のファイル", "close": "閉じる", - "system-language": "システムの言語", + "system-language": "システム言語", "unpair": "ペアリング解除", "title-image": "画像", "file-other-description-file-plural": "とその他{{count}}個のファイル", - "would-like-to-share": "がこれを共有しています", + "would-like-to-share": "が以下のファイルを共有しようとしています", "send-message-to": "このデバイスにメッセージを送信:", "language-selector-title": "言語設定", "pair": "ペアリング", "hr-or": "または", - "scan-qr-code": "QRコードをスキャンしてください。", + "scan-qr-code": "もしくはQRコードをスキャンしてください。", "input-key-on-this-device": "このコードを他のデバイスに入力するか", "download-again": "もう一度ダウンロードする", "accept": "承諾", @@ -162,20 +162,20 @@ "share-text-title": "テキストメッセージを共有します" }, "about": { - "claim": "デバイス間でかんたんファイル共有", - "tweet_title": "PairDropについてポスト", + "claim": "デバイス間のファイル共有を手軽に実現します", + "tweet_title": "PairDropのことをポストする", "close-about_aria-label": "PairDropについてを閉じる", "buy-me-a-coffee_title": "コーヒーを一杯おごってください!", - "github_title": "GitHub上のPairDropプロジェクト", + "github_title": "PairDrop on GitHub", "faq_title": "FAQ", - "mastodon_title": "MastodonでPairDropについてトゥート", + "mastodon_title": "MastodonにPairDropのことをトゥートする", "bluesky_title": "BlueSkyでフォロー", "custom_title": "フォロー", "privacypolicy_title": "プライバシーポリシーを開く" }, "document-titles": { - "file-transfer-requested": "ファイル転送の要求があります", - "image-transfer-requested": "画像の転送の要求があります", + "file-transfer-requested": "ファイルの転送がリクエストされました", + "image-transfer-requested": "画像の転送がリクエストされました", "message-received-plural": "{{count}}個のメッセージを受信しました", "message-received": "メッセージを受信しました", "file-received": "ファイルを受信しました", diff --git a/public/manifest.json b/public/manifest.json index 3cced84..edcf69a 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -26,7 +26,6 @@ } ], "background_color": "#efefef", - "start_url": "./", "display": "standalone", "theme_color": "#3367d6", "screenshots" : [ diff --git a/public/scripts/localization.js b/public/scripts/localization.js index 5121d0c..ec915a5 100644 --- a/public/scripts/localization.js +++ b/public/scripts/localization.js @@ -5,7 +5,7 @@ class Localization { Localization.defaultLocale = "en"; Localization.supportedLocales = [ "ar", "be", "bg", "ca", "cs", "da", "de", "en", "es", "et", "eu", "fa", "fr", "he", "hu", "id", "it", "ja", - "kn", "ko", "nb", "nl", "nn", "pl", "pt-BR", "ro", "ru", "sk", "ta", "tr", "uk", "zh-CN", "zh-HK", "zh-TW" + "kn", "ko", "nb", "nn", "nl", "pl", "pt-BR", "ro", "ru", "sk", "ta", "tr", "uk", "zh-CN", "zh-HK", "zh-TW" ]; Localization.supportedLocalesRtl = ["ar", "he"]; diff --git a/public/scripts/network.js b/public/scripts/network.js index 4382597..c92befc 100644 --- a/public/scripts/network.js +++ b/public/scripts/network.js @@ -1082,7 +1082,7 @@ class PeersManager { } async _onFilesSelected(message) { - let files = mime.addMissingMimeTypesToFiles([...message.files]); + let files = mime.addMissingMimeTypesToFiles(message.files); await this.peers[message.to].requestFileTransfer(files); } @@ -1306,8 +1306,9 @@ class FileDigester { const blob = new Blob(this._buffer) this._buffer = null; this._callback(new File([blob], this._name, { - type: this._mime || "application/octet-stream", + type: this._mime, lastModified: new Date().getTime() })); } + } diff --git a/public/scripts/ui.js b/public/scripts/ui.js index 42da3bc..cf4d014 100644 --- a/public/scripts/ui.js +++ b/public/scripts/ui.js @@ -873,9 +873,7 @@ class ReceiveDialog extends Dialog { const fileName = files[0].name; const fileNameSplit = fileName.split('.'); - const fileExtension = fileNameSplit.length > 1 - ? '.' + fileNameSplit[fileNameSplit.length - 1] - : ''; + const fileExtension = '.' + fileNameSplit[fileNameSplit.length - 1]; this.$fileStem.innerText = fileName.substring(0, fileName.length - fileExtension.length); this.$fileExtension.innerText = fileExtension; this.$fileSize.innerText = this._formatFileSize(totalSize); @@ -2404,7 +2402,7 @@ class Base64Dialog extends Dialog { class AboutUI { constructor() { this.$donationBtn = $('donation-btn'); - this.$twitterBtn = $('x-twitter-btn'); + this.$twitterBtn = $('twitter-btn'); this.$mastodonBtn = $('mastodon-btn'); this.$blueskyBtn = $('bluesky-btn'); this.$customBtn = $('custom-btn'); diff --git a/public/scripts/util.js b/public/scripts/util.js index 24e2626..1dcc388 100644 --- a/public/scripts/util.js +++ b/public/scripts/util.js @@ -392,8 +392,7 @@ const mime = (() => { "vob": "video/x-ms-vob", "wmv": "video/x-ms-wmv", "avi": "video/x-msvideo", - "*": "video/x-sgi-movie", - "kdbx": "application/x-keepass2" + "*": "video/x-sgi-movie" } return { @@ -410,7 +409,7 @@ const mime = (() => { // if filetype is empty guess via suffix otherwise leave unchanged for (let i = 0; i < files.length; i++) { if (!files[i].type) { - files[i] = new File([files[i]], files[i].name, {type: mime.guessMimeByFilename(files[i].name) || "application/octet-stream"}); + files[i] = new File([files[i]], files[i].name, {type: mime.guessMimeByFilename(files[i].name) || ""}); } } return files; diff --git a/public/service-worker.js b/public/service-worker.js index e1f4f45..551f25e 100644 --- a/public/service-worker.js +++ b/public/service-worker.js @@ -1,12 +1,12 @@ -const cacheVersion = 'v1.11.2'; +const cacheVersion = 'v1.11.0'; const cacheTitle = `pairdrop-cache-${cacheVersion}`; +const forceFetch = false; // FOR DEVELOPMENT: Set to true to always update assets instead of using cached versions const relativePathsToCache = [ './', 'index.html', 'manifest.json', 'styles/styles-main.css', 'styles/styles-deferred.css', - 'scripts/browser-tabs-connector.js', 'scripts/localization.js', 'scripts/main.js', 'scripts/network.js', @@ -28,19 +28,14 @@ const relativePathsToCache = [ 'images/android-chrome-512x512.png', 'images/android-chrome-512x512-maskable.png', 'images/apple-touch-icon.png', - 'fonts/OpenSans/static/OpenSans-Medium.ttf', 'lang/ar.json', 'lang/be.json', - 'lang/bg.json', 'lang/ca.json', 'lang/cs.json', 'lang/da.json', 'lang/de.json', 'lang/en.json', 'lang/es.json', - 'lang/et.json', - 'lang/eu.json', - 'lang/fa.json', 'lang/fr.json', 'lang/he.json', 'lang/hu.json', @@ -48,20 +43,15 @@ const relativePathsToCache = [ 'lang/it.json', 'lang/ja.json', 'lang/kn.json', - 'lang/ko.json', 'lang/nb.json', 'lang/nl.json', - 'lang/nn.json', 'lang/pl.json', 'lang/pt-BR.json', 'lang/ro.json', 'lang/ru.json', - 'lang/sk.json', - 'lang/ta.json', 'lang/tr.json', 'lang/uk.json', 'lang/zh-CN.json', - 'lang/zh-HK.json', 'lang/zh-TW.json' ]; const relativePathsNotToCache = [ @@ -69,16 +59,14 @@ const relativePathsNotToCache = [ ] self.addEventListener('install', function(event) { - // Perform install steps - console.log("Cache files for sw:", cacheVersion); + // Perform install steps event.waitUntil( caches.open(cacheTitle) .then(function(cache) { return cache .addAll(relativePathsToCache) .then(_ => { - console.log('All files cached for sw:', cacheVersion); - self.skipWaiting(); + console.log('All files cached.'); }); }) ); @@ -88,25 +76,20 @@ self.addEventListener('install', function(event) { const fromNetwork = (request, timeout) => new Promise((resolve, reject) => { const timeoutId = setTimeout(reject, timeout); - fetch(request, {cache: "no-store"}) + fetch(request) .then(response => { - if (response.redirected) { - throw new Error("Fetch is redirect. Abort usage and cache!"); - } - clearTimeout(timeoutId); resolve(response); - // Prevent requests that are in relativePathsNotToCache from being cached if (doNotCacheRequest(request)) return; - updateCache(request) + update(request) .then(() => console.log("Cache successfully updated for", request.url)) - .catch(err => console.log("Cache could not be updated for", request.url, err)); + .catch(reason => console.log("Cache could not be updated for", request.url, "Reason:", reason)); }) .catch(error => { // Handle any errors that occurred during the fetch - console.error(`Could not fetch ${request.url}.`); + console.error(`Could not fetch ${request.url}. Are you online?`); reject(error); }); }); @@ -128,16 +111,16 @@ const doNotCacheRequest = request => { }; // cache the current page to make it available for offline -const updateCache = request => new Promise((resolve, reject) => { +const update = request => new Promise((resolve, reject) => { + if (doNotCacheRequest(request)) { + reject("Url is specifically prevented from being cached in the serviceworker."); + return; + } caches .open(cacheTitle) .then(cache => fetch(request, {cache: "no-store"}) .then(response => { - if (response.redirected) { - throw new Error("Fetch is redirect. Abort usage and cache!"); - } - cache .put(request, response) .then(() => resolve()); @@ -146,19 +129,11 @@ const updateCache = request => new Promise((resolve, reject) => { ); }); -// general strategy when making a request: -// 1. Try to retrieve file from cache -// 2. If cache is not available: Fetch from network and update cache. -// This way, cached files are only updated if the cacheVersion is changed +// general strategy when making a request (eg if online try to fetch it +// from cache, if something fails fetch from network. Update cache everytime files are fetched. +// This way files should only be fetched if cacheVersion is changed self.addEventListener('fetch', function(event) { - const swOrigin = new URL(self.location.href).origin; - const requestOrigin = new URL(event.request.url).origin; - - if (swOrigin !== requestOrigin) { - // Do not handle requests from other origin - event.respondWith(fetch(event.request)); - } - else if (event.request.method === "POST") { + if (event.request.method === "POST") { // Requests related to Web Share Target. event.respondWith((async () => { const share_url = await evaluateRequestData(event.request); @@ -166,48 +141,39 @@ self.addEventListener('fetch', function(event) { })()); } else { - // Regular requests not related to Web Share Target: - // If request is excluded from cache -> respondWith fromNetwork - // else -> try fromCache first - event.respondWith( - doNotCacheRequest(event.request) - ? fromNetwork(event.request, 10000) - : fromCache(event.request) + // Regular requests not related to Web Share Target. + if (forceFetch) { + event.respondWith(fromNetwork(event.request, 10000)); + } + else { + event.respondWith( + fromCache(event.request) .then(rsp => { // if fromCache resolves to undefined fetch from network instead - if (!rsp) { - throw new Error("No match found."); - } - return rsp; + return rsp || fromNetwork(event.request, 10000); }) - .catch(error => { - console.error("Could not retrieve request from cache:", event.request.url, error); - return fromNetwork(event.request, 10000); - }) - ); + ); + } } }); // on activation, we clean up the previously registered service workers self.addEventListener('activate', evt => { - console.log("Activate sw:", cacheVersion); - evt.waitUntil(clients.claim()); - return evt.waitUntil( - caches - .keys() - .then(cacheNames => { - return Promise.all( - cacheNames.map(cacheName => { - if (cacheName !== cacheTitle) { - console.log("Delete cache:", cacheName); - return caches.delete(cacheName); - } - }) - ); - }) - ) -}); + return evt.waitUntil( + caches.keys() + .then(cacheNames => { + return Promise.all( + cacheNames.map(cacheName => { + if (cacheName !== cacheTitle) { + return caches.delete(cacheName); + } + }) + ); + }) + ) + } +); const evaluateRequestData = function (request) { return new Promise(async (resolve) => {