Skip to content

Commit

Permalink
Deploying to gh-pages from @ e1397e2 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
spaaaacccee committed Oct 21, 2023
1 parent 693479d commit db534d5
Show file tree
Hide file tree
Showing 5 changed files with 304 additions and 270 deletions.
286 changes: 143 additions & 143 deletions assets/index-51173628.js → assets/index-7358ab39.js

Large diffs are not rendered by default.

27 changes: 27 additions & 0 deletions assets/parseTrace.worker-aa84109d.js

Large diffs are not rendered by default.

27 changes: 0 additions & 27 deletions assets/parseTrace.worker-b498921b.js

This file was deleted.

232 changes: 133 additions & 99 deletions coi.js
Original file line number Diff line number Diff line change
@@ -1,102 +1,136 @@
/*! coi-serviceworker v0.1.7 - Guido Zuidhof and contributors, licensed under MIT */
let coepCredentialless = !1;
"undefined" == typeof window
? (self.addEventListener("install", () => self.skipWaiting()),
self.addEventListener("activate", (e) => e.waitUntil(self.clients.claim())),
self.addEventListener("message", (e) => {
e.data &&
("deregister" === e.data.type
? self.registration
.unregister()
.then(() => self.clients.matchAll())
.then((e) => {
e.forEach((e) => e.navigate(e.url));
})
: "coepCredentialless" === e.data.type &&
(coepCredentialless = e.data.value));
}),
self.addEventListener("fetch", function (e) {
const r = e.request;
if ("only-if-cached" === r.cache && "same-origin" !== r.mode) return;
const s =
coepCredentialless && "no-cors" === r.mode
? new Request(r, { credentials: "omit" })
: r;
e.respondWith(
fetch(s)
.then((e) => {
if (0 === e.status) return e;
const r = new Headers(e.headers);
return (
r.set(
"Cross-Origin-Embedder-Policy",
coepCredentialless ? "credentialless" : "require-corp"
),
coepCredentialless ||
r.set("Cross-Origin-Resource-Policy", "cross-origin"),
r.set("Cross-Origin-Opener-Policy", "same-origin"),
new Response(e.body, {
status: e.status,
statusText: e.statusText,
headers: r,
})
);
let coepCredentialless = false;
if (typeof window === "undefined") {
self.addEventListener("install", () => self.skipWaiting());
self.addEventListener("activate", (event) =>
event.waitUntil(self.clients.claim())
);

self.addEventListener("message", (ev) => {
if (!ev.data) {
return;
} else if (ev.data.type === "deregister") {
self.registration
.unregister()
.then(() => {
return self.clients.matchAll();
})
.then((clients) => {
clients.forEach((client) => client.navigate(client.url));
});
} else if (ev.data.type === "coepCredentialless") {
coepCredentialless = ev.data.value;
}
});

self.addEventListener("fetch", function (event) {
const r = event.request;
if (r.cache === "only-if-cached" && r.mode !== "same-origin") {
return;
}

const request =
coepCredentialless && r.mode === "no-cors"
? new Request(r, {
credentials: "omit",
})
.catch((e) => console.error(e))
);
}))
: (() => {
const e = {
shouldRegister: () => !0,
shouldDeregister: () => !1,
coepCredentialless: () =>
window.chrome !== undefined || window.netscape !== undefined,
doReload: () => window.location.reload(),
quiet: !1,
...window.coi,
},
r = navigator;
r.serviceWorker &&
r.serviceWorker.controller &&
(r.serviceWorker.controller.postMessage({
type: "coepCredentialless",
value: e.coepCredentialless(),
}),
e.shouldDeregister() &&
r.serviceWorker.controller.postMessage({ type: "deregister" })),
!1 === window.crossOriginIsolated &&
e.shouldRegister() &&
(window.isSecureContext
? r.serviceWorker &&
r.serviceWorker.register(window.document.currentScript.src).then(
(s) => {
!e.quiet &&
console.log("COOP/COEP Service Worker registered", s.scope),
s.addEventListener("updatefound", () => {
!e.quiet &&
console.log(
"Reloading page to make use of updated COOP/COEP Service Worker."
),
e.doReload();
}),
s.active &&
!r.serviceWorker.controller &&
(!e.quiet &&
console.log(
"Reloading page to make use of COOP/COEP Service Worker."
),
e.doReload());
},
(r) => {
!e.quiet &&
console.error(
"COOP/COEP Service Worker failed to register:",
r
);
}
)
: !e.quiet &&
: r;
event.respondWith(
fetch(request)
.then((response) => {
if (response.status === 0) {
return response;
}

const newHeaders = new Headers(response.headers);
newHeaders.set(
"Cross-Origin-Embedder-Policy",
coepCredentialless ? "credentialless" : "require-corp"
);
if (!coepCredentialless) {
newHeaders.set("Cross-Origin-Resource-Policy", "cross-origin");
}
newHeaders.set("Cross-Origin-Opener-Policy", "same-origin");

return new Response(response.body, {
status: response.status,
statusText: response.statusText,
headers: newHeaders,
});
})
.catch((e) => console.error(e))
);
});
} else {
(() => {
// You can customize the behavior of this script through a global `coi` variable.
const coi = {
shouldRegister: () => true,
shouldDeregister: () => false,
coepCredentialless: () =>
window.chrome !== undefined || window.netscape !== undefined,
doReload: () => window.location.reload(),
quiet: false,
...window.coi,
};

const n = navigator;

if (n.serviceWorker && n.serviceWorker.controller) {
n.serviceWorker.controller.postMessage({
type: "coepCredentialless",
value: coi.coepCredentialless(),
});

if (coi.shouldDeregister()) {
n.serviceWorker.controller.postMessage({ type: "deregister" });
}
}

// If we're already coi: do nothing. Perhaps it's due to this script doing its job, or COOP/COEP are
// already set from the origin server. Also if the browser has no notion of crossOriginIsolated, just give up here.
if (window.crossOriginIsolated !== false || !coi.shouldRegister()) return;

if (!window.isSecureContext) {
!coi.quiet &&
console.log(
"COOP/COEP Service Worker not registered, a secure context is required."
);
return;
}

// In some environments (e.g. Chrome incognito mode) this won't be available
if (n.serviceWorker) {
n.serviceWorker.register(window.document.currentScript.src).then(
(registration) => {
!coi.quiet &&
console.log(
"COOP/COEP Service Worker registered",
registration.scope
);

registration.addEventListener("updatefound", () => {
!coi.quiet &&
console.log(
"COOP/COEP Service Worker not registered, a secure context is required."
));
})();
"Reloading page to make use of updated COOP/COEP Service Worker."
);
coi.doReload();
});

// If the registration is active, but it's not controlling the page
if (registration.active && !n.serviceWorker.controller) {
!coi.quiet &&
console.log(
"Reloading page to make use of COOP/COEP Service Worker."
);
coi.doReload();
}
},
(err) => {
!coi.quiet &&
console.error("COOP/COEP Service Worker failed to register:", err);
}
);
}
})();
}
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<meta name="theme-color" content="#edf0ef" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Inter:300,400,500,600,700&display=swap" />
<title></title>
<script type="module" crossorigin src="./assets/index-51173628.js"></script>
<script type="module" crossorigin src="./assets/index-7358ab39.js"></script>
<link rel="stylesheet" href="./assets/index-50d96cb3.css">
</head>

Expand Down

0 comments on commit db534d5

Please sign in to comment.