Skip to content

Commit

Permalink
Merge pull request #37 from pyscript/ntoll-coi
Browse files Browse the repository at this point in the history
Add COI to head.
  • Loading branch information
ntoll committed Oct 25, 2023
2 parents c4a592d + 07732a2 commit fe3ea7a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
6 changes: 3 additions & 3 deletions docs/developers.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ compassion wins every time.
* If you need help with anything, get involved - _we welcome questions asked
in good faith, and will move mountains to help_.
* If you're unsure where to start, get involved - _we have [many ways to
contribute](/contributing)_.
contribute](contributing.md)_.

All contributors are expected to follow our [code of conduct](/conduct/).
All contributors are expected to follow our [code of conduct](conduct.md).

## Setup

Expand Down Expand Up @@ -242,7 +242,7 @@ is through this environment that you contribute to PyScript.
## Contributing
* We have [suggestions for how to contribute to PyScript](/contributing). Take
* We have [suggestions for how to contribute to PyScript](contributing.md). Take
a read and dive in.
* Please make sure you discuss potential contributions *before* you put in
Expand Down
28 changes: 28 additions & 0 deletions docs/javascripts/mini-coi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*! coi-serviceworker v0.1.7 - Guido Zuidhof and contributors, licensed under MIT */
/*! mini-coi - Andrea Giammarchi and contributors, licensed under MIT */
(({ document: d, navigator: { serviceWorker: s } }) => {
if (d) {
const { currentScript: c } = d;
s.register(c.src, { scope: c.getAttribute('scope') || '.' }).then(r => {
r.addEventListener('updatefound', () => location.reload());
if (r.active && !s.controller) location.reload();
});
}
else {
addEventListener('install', () => skipWaiting());
addEventListener('activate', e => e.waitUntil(clients.claim()));
addEventListener('fetch', e => {
const { request: r } = e;
if (r.cache === 'only-if-cached' && r.mode !== 'same-origin') return;
e.respondWith(fetch(r).then(r => {
const { body, status, statusText } = r;
if (!status || status > 399) return r;
const h = new Headers(r.headers);
h.set('Cross-Origin-Opener-Policy', 'same-origin');
h.set('Cross-Origin-Embedder-Policy', 'require-corp');
h.set('Cross-Origin-Resource-Policy', 'cross-origin');
return new Response(body, { status, statusText, headers: h });
}));
});
}
})(self);
2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ theme:

logo: assets/images/pyscript-black.svg

custom_dir: overrides

palette:
# Palette toggle for automatic mode
- media: "(prefers-color-scheme)"
Expand Down
6 changes: 6 additions & 0 deletions overrides/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{% extends "base.html" %}

{% block libs %}
<script src="./javascripts/mini-coi.js"></script>
{{ super() }}
{% endblock %}

0 comments on commit fe3ea7a

Please sign in to comment.