PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.12
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.12
1.1.12 1.1.11 1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 All 36 releases
← All changes | assets/js/sw.min.js +1 -1 0.9.2 → 1.1.12 View file →
@@ -1 +1 @@
1 -(function(){"use strict";const a=globalThis,r="0.8.0-pwa-5",o=`desktop-mode-static-${r}`,h=`desktop-mode-runtime-${r}`,l="/desktop-mode/?offline=1",d=["assets/css/desktop.css","assets/css/variables.css","assets/css/dock.css","assets/css/windows.css","assets/js/desktop.min.js","assets/js/window-system.min.js","assets/js/shell-overlays.min.js","assets/images/wp-logo.png"];a.addEventListener("install",t=>{t.waitUntil(u()),a.skipWaiting()}),a.addEventListener("activate",t=>{t.waitUntil((async()=>{const e=await caches.keys();await Promise.all(e.filter(s=>!s.endsWith(r)).map(s=>caches.delete(s))),await a.clients.claim()})())}),a.addEventListener("fetch",t=>{const e=t.request;if(e.method!=="GET")return;const s=new URL(e.url);if(s.origin!==a.location.origin)return;const c=s.pathname.startsWith("/desktop-mode/"),n=s.pathname.startsWith("/wp-admin/"),i=s.pathname.includes("/wp-content/plugins/desktop-mode/");if(!(!c&&!n&&!i)){if(i&&w(s.pathname)){t.respondWith(m(e));return}if(i&&f(s.pathname)){t.respondWith(g(e));return}e.mode==="navigate"&&e.destination==="document"&&t.respondWith(k(e))}}),a.addEventListener("push",t=>{t.waitUntil(Promise.resolve())}),a.addEventListener("notificationclick",t=>{t.notification.close(),t.waitUntil((async()=>{const e=t.notification.data?.url??"/desktop-mode/",c=(await a.clients.matchAll({type:"window",includeUncontrolled:!0})).find(n=>n.url.includes("/desktop-mode/"));if(c){typeof c.focus=="function"&&await c.focus();return}a.clients.openWindow&&await a.clients.openWindow(e)})())});async function u(){try{const t=await caches.open(o),e=p();await t.addAll(d.map(s=>e+s))}catch{}}function p(){return a.location.origin+"/wp-content/plugins/desktop-mode/"}function f(t){return/\.(css|png|jpg|jpeg|svg|webp|woff2?|ttf|gif|ico)$/i.test(t)}function w(t){return/\.js$/i.test(t)}async function m(t){const e=await caches.open(h);try{const s=await fetch(t.url,{cache:"reload"});return s&&s.status===200&&e.put(t,s.clone()).catch(()=>{}),s}catch{const s=await e.match(t);if(s)return s;const n=await(await caches.open(o)).match(t,{ignoreSearch:!0});return n||new Response("",{status:504})}}async function g(t){const e=await caches.open(h);let s=await e.match(t);s||(s=await(await caches.open(o)).match(t,{ignoreSearch:!0}));const c=fetch(t).then(i=>(i&&i.status===200&&e.put(t,i.clone()).catch(()=>{}),i)).catch(()=>{});if(s)return s;const n=await c;return n||new Response("",{status:504})}async function k(t){try{return await fetch(t)}catch{const s=await(await caches.open(o)).match(l);return s||new Response('<!doctype html><meta charset="utf-8"><title>Offline</title><p>You appear to be offline. The app will work again as soon as the connection returns.</p>',{status:503,headers:{"Content-Type":"text/html; charset=utf-8"}})}}})();
1 +(function(){"use strict";const v=["action","action2","_wpnonce","nonce","delete_all"];function W(e){const n=e.slice(e.lastIndexOf("/")+1);return/-new\.php$/.test(n)}function O(e){if(W(e.pathname))return!0;for(const n of v)if(e.searchParams.has(n))return!0;return!1}const j="openstation";function $(e,n){let t;if(typeof e=="string")try{t=new URL(e,n??(typeof window<"u"?window.location.href:void 0))}catch{return!1}else t=e;return t.pathname.slice(t.pathname.lastIndexOf("/")+1)==="admin.php"&&t.searchParams.get("page")===j}const H=/^[a-f0-9]{8,64}$/,F=/\.(css|js|png|jpg|jpeg|svg|webp|woff2?|ttf|gif|ico)$/i,M=/\/wp-admin\/load-(scripts|styles)\.php$/;function B(e,n){const t={adminAssetCache:!1,windowPrewarm:!1,pluginUrl:n,shellBuild:""};if(!e||typeof e!="object")return t;const s=e;if(t.adminAssetCache=s.adminAssetCache===!0,t.windowPrewarm=s.windowPrewarm===!0,typeof s.shellBuild=="string"&&H.test(s.shellBuild)&&(t.shellBuild=s.shellBuild),typeof s.pluginUrl=="string"&&s.pluginUrl.startsWith("http"))try{new URL(s.pluginUrl),t.pluginUrl=s.pluginUrl.endsWith("/")?s.pluginUrl:s.pluginUrl+"/"}catch{}return t}function D(e,n){const t=e.pathname;return t.includes(n)?"own-plugin":M.test(t)&&e.searchParams.has("ver")?"core-cache-first":!F.test(t)||!e.searchParams.has("ver")||t.includes("/wp-content/uploads/")?"bypass":t.includes("/wp-admin/")||t.includes("/wp-includes/")?"core-cache-first":t.includes("/wp-content/plugins/")||t.includes("/wp-content/themes/")?"content-swr":"bypass"}function C(e){return!e.pathname.includes("/wp-admin/")||!e.searchParams.has("openstation_chromeless")||$(e)?!1:!O(e)}function E(e,n,t,s){if(e!==200||t||n!=="basic"&&n!=="default")return!1;if(s){const i=s.toLowerCase();if(i.includes("no-store")||i.includes("private"))return!1}return!0}const S=3e4,y=6;class G{constructor(n=()=>Date.now()){this.entries=new Map,this.now=n}has(n){return this.entries.has(n)}get size(){return this.entries.size}put(n,t){this.entries.set(n,{at:this.now(),res:t}),this.prune()}take(n){const t=this.entries.get(n);return!t||(this.entries.delete(n),this.now()-t.at>S)?null:t.res}prune(){const n=this.now();for(const[t,s]of this.entries)n-s.at>S&&this.entries.delete(t);for(;this.entries.size>y;){const t=this.entries.keys().next().value;if(t===void 0)break;this.entries.delete(t)}}clear(){this.entries.clear()}}function x(e,n){if(!e||typeof e!="object")return null;const t=e;if(t.type==="os-sw-set-prewarm"){const s=t.enabled===!0;return{flags:{...n,windowPrewarm:s},clearSpeculative:!s,dropSessionCache:!s}}if(t.type==="os-sw-config"){const s={...n};typeof t.adminAssetCache=="boolean"&&(s.adminAssetCache=t.adminAssetCache);let i=!1;return typeof t.windowPrewarm=="boolean"&&(s.windowPrewarm=t.windowPrewarm,i=!s.windowPrewarm),{flags:s,clearSpeculative:i,dropSessionCache:!1}}return null}const a=globalThis,l="0.8.0-pwa-6",w=`os-static-${l}`,U=`os-runtime-${l}`,m=`os-admin-${l}`,u=(()=>{try{const e=new URL(a.registration.scope).pathname;return e.endsWith("/")?e:`${e}/`}catch{return"/"}})(),Y=`${u}openstation/?offline=1`,z=a.location.origin+"/wp-content/plugins/desktop-mode/",h=B(a.__OS_SW_CONFIG,z),P=new URL(h.pluginUrl).pathname;let f=h.windowPrewarm,A=h.adminAssetCache;const V=["assets/css/desktop.css","assets/css/variables.css","assets/css/dock.css","assets/css/windows.css","assets/js/desktop.min.js","assets/js/window-system.min.js","assets/js/shell-overlays.min.js","assets/images/wp-logo.png"];a.addEventListener("install",e=>{e.waitUntil(J())}),a.addEventListener("activate",e=>{e.waitUntil((async()=>{const n=await caches.keys();await Promise.all(n.filter(t=>!t.endsWith(l)).map(t=>caches.delete(t))),await N(),await a.clients.claim()})())}),a.addEventListener("fetch",e=>{const n=e.request;if(n.method!=="GET")return;const t=new URL(n.url);if(t.origin!==a.location.origin)return;if(t.pathname.endsWith("/wp-login.php")){o.clear(),e.waitUntil(caches.delete(g));return}const s=t.pathname.startsWith(`${u}openstation/`),i=t.pathname.startsWith(`${u}wp-admin/`),c=t.pathname.includes(P),p=A&&!n.headers.has("range")?D(t,P):"bypass";if(!(!s&&!i&&!c&&p==="bypass")){if(c&&q(t.pathname)){e.respondWith(tt(n));return}if(c&&Z(t.pathname)){e.respondWith(T(n,U));return}if(p==="core-cache-first"){e.respondWith(et(n));return}if(p==="content-swr"){e.respondWith(T(n,m));return}if(n.mode==="navigate"&&n.cache==="reload")o.take(t.toString());else if(n.mode==="navigate"&&o.size>0){const d=o.take(t.toString());if(d){e.respondWith(d.then(r=>r||fetch(n)));return}}n.mode==="navigate"&&n.destination==="document"&&(e.waitUntil(X()),e.respondWith(it(n)))}});const o=new G,g=`os-session-${l}`,L="/__openstation_restore_targets__";let R=0;const K=3e3;async function X(){const e=Date.now();if(!(!f||e-R<K)){R=e;try{const t=await(await caches.open(g)).match(L);if(!t)return;const s=await t.json();if(!Array.isArray(s))return;for(const i of s.slice(0,y))if(typeof i=="string")try{const c=new URL(i);c.origin===a.location.origin&&C(c)&&b(c.toString())}catch{}}catch{}}}a.addEventListener("message",e=>{const n=e.data;if(n&&n.type==="os-sw-get-build"){try{e.source?.postMessage({type:"os-sw-build",shellBuild:h.shellBuild})}catch{}return}if(n&&n.type==="os-sw-skip-waiting"){a.skipWaiting();return}const t=x(n,{windowPrewarm:f,adminAssetCache:A});if(t){f=t.flags.windowPrewarm,A=t.flags.adminAssetCache,t.clearSpeculative&&o.clear(),t.dropSessionCache&&e.waitUntil(caches.delete(g));return}if(n&&n.type==="os-remember-session"){if(!f)return;const c=Array.isArray(n.urls)?n.urls:[];e.waitUntil((async()=>{try{await(await caches.open(g)).put(L,new Response(JSON.stringify(c.slice(0,y)),{headers:{"Content-Type":"application/json"}}))}catch{}})());return}if(!n||n.type!=="os-speculate-doc"||!n.url||!f)return;let s;try{s=new URL(n.url)}catch{return}if(s.origin!==a.location.origin||!C(s))return;const i=b(s.toString());i&&e.waitUntil(i)});function b(e){if(o.has(e))return null;const n=(async()=>{try{const t=await fetch(e,{credentials:"same-origin",redirect:"follow"});return t.status!==200||t.redirected?null:t}catch{return null}})();return o.put(e,n),n}a.addEventListener("push",e=>{e.waitUntil(Promise.resolve())}),a.addEventListener("notificationclick",e=>{e.notification.close(),e.waitUntil((async()=>{const n=e.notification.data?.url??`${u}openstation/`,s=(await a.clients.matchAll({type:"window",includeUncontrolled:!0})).find(i=>i.url.includes(`${u}openstation/`));if(s){typeof s.focus=="function"&&await s.focus();return}a.clients.openWindow&&await a.clients.openWindow(n)})())});async function J(){try{const e=await caches.open(w),n=Q();await e.addAll(V.map(t=>n+t))}catch{}}function Q(){return h.pluginUrl}function Z(e){return/\.(css|png|jpg|jpeg|svg|webp|woff2?|ttf|gif|ico)$/i.test(e)}function q(e){return/\.js$/i.test(e)}async function tt(e){const n=await caches.open(U);try{const t=await fetch(e.url,{cache:"reload"});return t&&t.status===200&&n.put(e,t.clone()).catch(()=>{}),t}catch{const t=await n.match(e);if(t)return t;const i=await(await caches.open(w)).match(e,{ignoreSearch:!0});return i||new Response("",{status:504})}}async function T(e,n){const t=await caches.open(n),s=await t.match(e),i=fetch(e).then(r=>(r&&E(r.status,r.type,r.redirected,r.headers.get("cache-control"))&&(t.put(e,r.clone()).catch(()=>{}),n===m&&k()),r)).catch(()=>{});if(s)return s;const c=await i;if(c)return c;const d=await(await caches.open(w)).match(e,{ignoreSearch:!0});return d||new Response("",{status:504})}async function et(e){const n=await caches.open(m),t=await n.match(e);if(t)return t;const s=await fetch(e);return E(s.status,s.type,s.redirected,s.headers.get("cache-control"))&&(n.put(e,s.clone()).catch(()=>{}),k()),s}const I=500,nt=50,st=20;let _=0;async function k(){_+=1,!(_<st)&&(_=0,await N())}async function N(){try{const e=await caches.open(m),n=await e.keys();if(n.length<=I)return;const t=n.slice(0,n.length-I+nt);await Promise.all(t.map(s=>e.delete(s)))}catch{}}async function it(e){try{return await fetch(e)}catch{const t=await(await caches.open(w)).match(Y);return t||new Response('<!doctype html><meta charset="utf-8"><title>Offline</title><p>You appear to be offline. The app will work again as soon as the connection returns.</p>',{status:503,headers:{"Content-Type":"text/html; charset=utf-8"}})}}})();