Some checks failed
Bindings Tests (Go) / ubuntu-22 (push) Failing after 31s
CI (sycl) / ubuntu-22-cmake-sycl (linux/arm/v7, icx, icpx, ON) (push) Failing after 3s
CI (sycl) / ubuntu-22-cmake-sycl (linux/ppc64le, icx, icpx, ON) (push) Failing after 2s
CI (sycl) / ubuntu-22-cmake-sycl-fp16 (linux/amd64, icx, icpx, ON) (push) Failing after 3s
CI (sycl) / ubuntu-22-cmake-sycl-fp16 (linux/arm/v7, icx, icpx, ON) (push) Failing after 3s
CI (sycl) / ubuntu-22-cmake-sycl-fp16 (linux/arm64, icx, icpx, ON) (push) Failing after 3s
CI (sycl) / ubuntu-22-cmake-sycl-fp16 (linux/ppc64le, icx, icpx, ON) (push) Failing after 3s
CI (vad) / vad (push) Failing after 3s
CI (wasm) / emscripten (Release) (push) Failing after 4s
Bindings Tests (Ruby) / ubuntu-22 (push) Failing after 37s
CI (android) / android (push) Failing after 16s
CI (android) / android_java (push) Failing after 3s
CI (clang) / ubuntu-22-clang (linux/amd64, Debug) (push) Failing after 3s
CI (clang) / ubuntu-22-clang (linux/amd64, Release) (push) Failing after 2s
CI (clang) / ubuntu-22-clang (linux/ppc64le, Debug) (push) Failing after 3s
CI (clang) / ubuntu-22-clang (linux/ppc64le, Release) (push) Failing after 3s
CI (cpu) / ggml-ci-x64-cpu-low-perf (push) Failing after 3s
CI (cpu) / ggml-ci-x64-cpu-high-perf (push) Failing after 2s
CI (gcc) / ubuntu-22-gcc (linux/amd64, Debug) (push) Failing after 3s
CI (gcc) / ubuntu-22-gcc (linux/amd64, Release) (push) Failing after 3s
CI (gcc) / ubuntu-22-gcc (linux/ppc64le, Debug) (push) Failing after 3s
CI (gcc) / ubuntu-22-gcc (linux/ppc64le, Release) (push) Failing after 4s
CI (gcc) / ubuntu-22-gcc-arm-v7 (linux/arm/v7, Debug) (push) Failing after 3s
CI (gcc) / ubuntu-22-gcc-arm-v7 (linux/arm/v7, Release) (push) Failing after 3s
CI (quantize) / quantize (push) Failing after 3s
CI (sanitize) / ubuntu-22-gcc-sanitized (ADDRESS) (push) Failing after 3s
CI (sanitize) / ubuntu-22-gcc-sanitized (THREAD) (push) Failing after 3s
CI (sanitize) / ubuntu-22-gcc-sanitized (UNDEFINED) (push) Failing after 2s
CI (sycl) / ubuntu-22-cmake-sycl (linux/amd64, icx, icpx, ON) (push) Failing after 3s
CI (sycl) / ubuntu-22-cmake-sycl (linux/arm64, icx, icpx, ON) (push) Failing after 3s
Examples WASM / deploy-wasm-github-pages (push) Failing after 3s
Examples Tests / addon_node-ubuntu-22 (20.x) (push) Failing after 3s
Examples Tests / addon_node-ubuntu-22 (22.x) (push) Failing after 2s
CI (coreml) / coreml-base-en (push) Has been cancelled
CI (self-hosted) / gpu-vulkan (push) Has been cancelled
CI (self-hosted) / npu-amd-windows (push) Has been cancelled
CI (self-hosted) / gpu-vulkan-nvidia-cm2 (push) Has been cancelled
CI (clang) / ubuntu-22-clang-arm64 (Debug) (push) Has been cancelled
CI (clang) / ubuntu-22-clang-arm64 (Release) (push) Has been cancelled
CI (self-hosted) / gpu-cuda (push) Has been cancelled
CI (self-hosted) / gpu-vulkan-nvidia-cm (push) Has been cancelled
CI (cpu) / ggml-ci-arm64-cpu-low-perf (push) Has been cancelled
CI (cpu) / ggml-ci-arm64-cpu-high-perf (push) Has been cancelled
CI (cpu) / ggml-ci-arm64-cpu-high-perf-sve (push) Has been cancelled
CI (freebsd) / freeBSD-latest (push) Has been cancelled
CI (self-hosted) / gpu-metal (push) Has been cancelled
CI (gcc) / ubuntu-22-gcc-arm64 (Debug) (push) Has been cancelled
CI (gcc) / ubuntu-22-gcc-arm64 (Release) (push) Has been cancelled
CI (macOS) / macOS-latest (generic/platform=iOS) (push) Has been cancelled
CI (macOS) / macOS-latest (generic/platform=macOS) (push) Has been cancelled
CI (macOS) / macOS-latest (generic/platform=tvOS) (push) Has been cancelled
CI (self-hosted) / npu-amd-linux (push) Has been cancelled
CI (windows) / windows-msys2 (Release, clang, clang-x86_64, CLANG64) (push) Has been cancelled
CI (windows) / windows-msys2 (Release, gcc, ucrt-x86_64, UCRT64) (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main-cuda.Dockerfile platform:linux/amd64 runs_on:ubuntu-24.04 tag:main-cuda]) (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main-intel.Dockerfile platform:linux/amd64 runs_on:ubuntu-24.04 tag:main-intel]) (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main-musa.Dockerfile platform:linux/amd64 runs_on:ubuntu-24.04 tag:main-musa]) (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main-vulkan.Dockerfile platform:linux/amd64 runs_on:ubuntu-24.04 tag:main-vulkan]) (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main-vulkan.Dockerfile platform:linux/arm64 runs_on:ubuntu-24.04-arm tag:main-vulkan-arm64]) (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main.Dockerfile platform:linux/amd64 runs_on:ubuntu-24.04 tag:main]) (push) Has been cancelled
Publish Docker image / Push Docker image to Docker Hub (map[dockerfile:.devops/main.Dockerfile platform:linux/arm64 runs_on:ubuntu-24.04-arm tag:main-arm64]) (push) Has been cancelled
Mark inactive issues stale / mark-issues (push) Failing after 1s
147 lines
5.9 KiB
JavaScript
147 lines
5.9 KiB
JavaScript
/*! coi-serviceworker v0.1.7 - Guido Zuidhof and contributors, licensed under MIT */
|
|
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",
|
|
})
|
|
: 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 {
|
|
(() => {
|
|
const reloadedBySelf = window.sessionStorage.getItem("coiReloadedBySelf");
|
|
window.sessionStorage.removeItem("coiReloadedBySelf");
|
|
const coepDegrading = (reloadedBySelf == "coepdegrade");
|
|
|
|
// You can customize the behavior of this script through a global `coi` variable.
|
|
const coi = {
|
|
shouldRegister: () => !reloadedBySelf,
|
|
shouldDeregister: () => false,
|
|
coepCredentialless: () => true,
|
|
coepDegrade: () => true,
|
|
doReload: () => window.location.reload(),
|
|
quiet: false,
|
|
...window.coi
|
|
};
|
|
|
|
const n = navigator;
|
|
const controlling = n.serviceWorker && n.serviceWorker.controller;
|
|
|
|
// Record the failure if the page is served by serviceWorker.
|
|
if (controlling && !window.crossOriginIsolated) {
|
|
window.sessionStorage.setItem("coiCoepHasFailed", "true");
|
|
}
|
|
const coepHasFailed = window.sessionStorage.getItem("coiCoepHasFailed");
|
|
|
|
if (controlling) {
|
|
// Reload only on the first failure.
|
|
const reloadToDegrade = coi.coepDegrade() && !(
|
|
coepDegrading || window.crossOriginIsolated
|
|
);
|
|
n.serviceWorker.controller.postMessage({
|
|
type: "coepCredentialless",
|
|
value: (reloadToDegrade || coepHasFailed && coi.coepDegrade())
|
|
? false
|
|
: coi.coepCredentialless(),
|
|
});
|
|
if (reloadToDegrade) {
|
|
!coi.quiet && console.log("Reloading page to degrade COEP.");
|
|
window.sessionStorage.setItem("coiReloadedBySelf", "coepdegrade");
|
|
coi.doReload("coepdegrade");
|
|
}
|
|
|
|
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. Firefox private mode) this won't be available
|
|
if (!n.serviceWorker) {
|
|
!coi.quiet && console.error("COOP/COEP Service Worker not registered, perhaps due to private mode.");
|
|
return;
|
|
}
|
|
|
|
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("Reloading page to make use of updated COOP/COEP Service Worker.");
|
|
window.sessionStorage.setItem("coiReloadedBySelf", "updatefound");
|
|
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.");
|
|
window.sessionStorage.setItem("coiReloadedBySelf", "notcontrolling");
|
|
coi.doReload();
|
|
}
|
|
},
|
|
(err) => {
|
|
!coi.quiet && console.error("COOP/COEP Service Worker failed to register:", err);
|
|
}
|
|
);
|
|
})();
|
|
}
|