@indextools/index-games 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.svg +1158 -52
- package/package.json +1 -1
- package/public/config.js +12 -1
- package/public/games/games.json +2 -2
- package/public/games/kidchess.html +9 -6
- package/public/games/nealfun.html +8 -5
- package/public/index.css +30 -0
- package/public/index.html +47 -36
- package/public/index.js +5 -1
- package/public/index.svg +1158 -52
- package/public/register-sw.js +7 -3
- package/public/sw.js +12 -0
package/public/register-sw.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
const stockSW = "./sw.js";
|
|
3
2
|
|
|
4
3
|
/**
|
|
5
4
|
* List of hostnames that are allowed to run serviceworkers on http://
|
|
@@ -8,7 +7,7 @@ const swAllowedHostnames = ["localhost", "127.0.0.1"];
|
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Global util
|
|
11
|
-
* Used in 404.html and
|
|
10
|
+
* Used in index.html, 404.html, and games
|
|
12
11
|
*/
|
|
13
12
|
async function registerSW() {
|
|
14
13
|
if (!navigator.serviceWorker) {
|
|
@@ -21,5 +20,10 @@ async function registerSW() {
|
|
|
21
20
|
throw new Error("Your browser doesn't support service workers.");
|
|
22
21
|
}
|
|
23
22
|
|
|
24
|
-
|
|
23
|
+
let publicDir = new URL("./", location.href).pathname;
|
|
24
|
+
if (publicDir.endsWith("/games/")) {
|
|
25
|
+
publicDir = new URL("../", location.href).pathname;
|
|
26
|
+
}
|
|
27
|
+
const swUrl = publicDir + "sw.js";
|
|
28
|
+
await navigator.serviceWorker.register(swUrl, { scope: publicDir });
|
|
25
29
|
}
|
package/public/sw.js
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
importScripts("https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.all.js");
|
|
2
|
+
importScripts("https://unpkg.com/@titaniumnetwork-dev/ultraviolet@3.2.10/dist/uv.bundle.js");
|
|
3
|
+
importScripts("https://unpkg.com/@titaniumnetwork-dev/ultraviolet@3.2.10/dist/uv.config.js");
|
|
4
|
+
importScripts("https://unpkg.com/@titaniumnetwork-dev/ultraviolet@3.2.10/dist/uv.sw.js");
|
|
2
5
|
|
|
3
6
|
const { ScramjetServiceWorker } = $scramjetLoadWorker();
|
|
4
7
|
const scramjet = new ScramjetServiceWorker();
|
|
5
8
|
|
|
9
|
+
const baseDir = new URL("./", location.href).pathname;
|
|
10
|
+
if (self.__uv$config) {
|
|
11
|
+
self.__uv$config.prefix = baseDir + "uv/";
|
|
12
|
+
}
|
|
13
|
+
const uv = new self.UVServiceWorker(self.__uv$config);
|
|
14
|
+
|
|
6
15
|
async function handleRequest(event) {
|
|
16
|
+
if (uv.route(event)) {
|
|
17
|
+
return uv.fetch(event);
|
|
18
|
+
}
|
|
7
19
|
await scramjet.loadConfig();
|
|
8
20
|
if (scramjet.route(event)) {
|
|
9
21
|
return scramjet.fetch(event);
|