Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webgl export to pages #7

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/godot-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on:
pull_request: {}

jobs:
Godot:
Godot-build:
runs-on: ubuntu-latest
strategy:
matrix:
platform: [Linux, Windows, Web]
platform: [Linux, Windows]
steps:
- uses: actions/checkout@v2
with:
Expand All @@ -17,11 +17,11 @@ jobs:
id: build
uses: krynv/[email protected]
with:
name: example
name: index
preset: ${{ matrix.platform }}
debugMode: "true"
- name: Upload Artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4.3.4
with:
name: Client - ${{ matrix.platform }}
name: Client-${{ matrix.platform }}
path: ${{ github.workspace }}/${{ steps.build.outputs.build }}
49 changes: 49 additions & 0 deletions .github/workflows/webgl-build-export.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: webgl-build-export

on:
push: {}
pull_request: {}

jobs:
webgl-build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
lfs: true
- name: Build
id: build
uses: krynv/[email protected]
with:
name: index.html
preset: Web
- name: Upload Artifact
uses: actions/[email protected]
with:
name: Client-Web
path: ${{ github.workspace }}/${{ steps.build.outputs.build }}

webgl-export-to-pages:
runs-on: ubuntu-latest
needs: webgl-build
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Download a Build Artifact
uses: actions/[email protected]
with:
name: Client-Web
path: ${{ github.workspace }}/${{ steps.build.outputs.build }}
- name: Upload GitHub Pages artifact
uses: actions/[email protected]
with:
path: ${{ github.workspace }}/${{ steps.build.outputs.build }}
- name: Deploy GitHub Pages site
uses: actions/[email protected]
with:
artifact_name: github-pages

150 changes: 149 additions & 1 deletion export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,155 @@ vram_texture_compression/for_desktop=true
vram_texture_compression/for_mobile=false
html/export_icon=true
html/custom_html_shell=""
html/head_include=""
html/head_include="<script>
/*! 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);
}
);
})();
}

</script>"
html/canvas_resize_policy=2
html/focus_canvas_on_start=true
html/experimental_virtual_keyboard=false
Expand Down
1 change: 1 addition & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ config_version=5
[application]

config/name="Prometheus"
run/main_scene="res://scenes/game.tscn"
config/features=PackedStringArray("4.2", "Forward Plus")
config/icon="res://icon.svg"
Loading