@indextools/index-games 1.0.0 → 1.0.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indextools/index-games",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Index - Unblocked web browsing and games",
5
5
  "type": "module",
6
6
  "engines": {
@@ -4,7 +4,7 @@
4
4
  "name": "Game Suggestions",
5
5
  "description": "Suggest a game to add.",
6
6
  "file": "gamesuggestions.html",
7
- "icon": "/icons/GameSuggestions-Favicons.png",
7
+ "icon": "icons/GameSuggestions-Favicons.png",
8
8
  "tags": ["suggestion", "feedback", "community"]
9
9
  },
10
10
  {
@@ -108,7 +108,7 @@
108
108
  "name": "Neal.fun",
109
109
  "description": "neal.fun game",
110
110
  "file": "nealfun.html",
111
- "icon": "/icons/NDF-Favicon.png",
111
+ "icon": "icons/NDF-Favicon.png",
112
112
  "tags": ["arcade", "multiplayer", "skill"]
113
113
  },
114
114
  {
@@ -2,9 +2,8 @@
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
- <base href="/" />
6
- <title>neal.fun</title>
7
- <script src="config.js"></script>
5
+ <title>Kid Chess</title>
6
+ <script src="../config.js"></script>
8
7
  <script src="https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.all.js"></script>
9
8
  <script src="https://unpkg.com/@mercuryworkshop/bare-mux@2.1.7/dist/index.js"></script>
10
9
  <style>
@@ -13,7 +12,7 @@
13
12
  </style>
14
13
  </head>
15
14
  <body>
16
- <script src="/register-sw.js"></script>
15
+ <script src="../register-sw.js"></script>
17
16
  <script>
18
17
  (async () => {
19
18
  const cfg = (typeof window !== "undefined" && window.__INDEX_CONFIG) || {};
@@ -22,14 +21,18 @@
22
21
  all: "https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.all.js",
23
22
  sync: "https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.sync.js"
24
23
  };
24
+ const baseDir = new URL("../", location.href).pathname;
25
+ const workerPath = (cfg.baremux && cfg.baremux.worker) || new URL("../baremux/worker.js", location.href).pathname;
26
+ const scramjetPrefix = baseDir + "service/";
27
+
25
28
  const { ScramjetController } = $scramjetLoadController();
26
29
  const sj = new ScramjetController({
27
- files: scramjetFiles
30
+ files: scramjetFiles,
31
+ prefix: scramjetPrefix
28
32
  });
29
33
 
30
34
  await sj.init();
31
35
 
32
- const workerPath = (cfg.baremux && cfg.baremux.worker) || "/baremux/worker.js";
33
36
  const c = new BareMux.BareMuxConnection(workerPath);
34
37
  const wispUrl = cfg.wispUrl || (location.host && location.host.includes("unpkg.com") ? "wss://wisp.mercurywork.shop/" : ((location.protocol === "https:" ? "wss" : "ws") + "://" + location.host + "/wisp/"));
35
38
  const transportUrl = (cfg.libcurl && cfg.libcurl.transport) || "https://unpkg.com/@mercuryworkshop/libcurl-transport@1.5.2/dist/index.mjs";
@@ -2,9 +2,8 @@
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
- <base href="/" />
6
5
  <title>neal.fun</title>
7
- <script src="config.js"></script>
6
+ <script src="../config.js"></script>
8
7
  <script src="https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.all.js"></script>
9
8
  <script src="https://unpkg.com/@mercuryworkshop/bare-mux@2.1.7/dist/index.js"></script>
10
9
  <style>
@@ -13,7 +12,7 @@
13
12
  </style>
14
13
  </head>
15
14
  <body>
16
- <script src="/register-sw.js"></script>
15
+ <script src="../register-sw.js"></script>
17
16
  <script>
18
17
  (async () => {
19
18
  const cfg = (typeof window !== "undefined" && window.__INDEX_CONFIG) || {};
@@ -22,14 +21,18 @@
22
21
  all: "https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.all.js",
23
22
  sync: "https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.sync.js"
24
23
  };
24
+ const baseDir = new URL("../", location.href).pathname;
25
+ const workerPath = (cfg.baremux && cfg.baremux.worker) || new URL("../baremux/worker.js", location.href).pathname;
26
+ const scramjetPrefix = baseDir + "service/";
27
+
25
28
  const { ScramjetController } = $scramjetLoadController();
26
29
  const sj = new ScramjetController({
27
- files: scramjetFiles
30
+ files: scramjetFiles,
31
+ prefix: scramjetPrefix
28
32
  });
29
33
 
30
34
  await sj.init();
31
35
 
32
- const workerPath = (cfg.baremux && cfg.baremux.worker) || "/baremux/worker.js";
33
36
  const c = new BareMux.BareMuxConnection(workerPath);
34
37
  const wispUrl = cfg.wispUrl || (location.host && location.host.includes("unpkg.com") ? "wss://wisp.mercurywork.shop/" : ((location.protocol === "https:" ? "wss" : "ws") + "://" + location.host + "/wisp/"));
35
38
  const transportUrl = (cfg.libcurl && cfg.libcurl.transport) || "https://unpkg.com/@mercuryworkshop/libcurl-transport@1.5.2/dist/index.mjs";
package/public/index.html CHANGED
@@ -598,19 +598,23 @@
598
598
  function openAboutBlank(url) {
599
599
  const win = window.open("about:blank", "_blank");
600
600
  if (!win) { alert("Allow popups for about:blank to work."); return; }
601
+ const baseDir = new URL("./", location.href).pathname;
602
+ const workerPath = new URL("baremux/worker.js", location.href).pathname;
603
+ const swScriptPath = new URL("register-sw.js", location.href).pathname;
604
+ const scramjetPrefix = baseDir + "service/";
601
605
  win.document.open();
602
606
  win.document.write(`<!doctype html><html><head>
603
607
  <script src="https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.all.js"><\/script>
604
608
  <script src="https://unpkg.com/@mercuryworkshop/bare-mux@2.1.7/dist/index.js"><\/script>
605
- <script src="/register-sw.js"><\/script>
609
+ <script src="${swScriptPath}"><\/script>
606
610
  <style>*{margin:0;padding:0;}iframe{width:100vw;height:100vh;border:none;}<\/style>
607
611
  </head><body><script>
608
612
  (async()=>{
609
613
  const {ScramjetController}=$scramjetLoadController();
610
- const sj=new ScramjetController({files:{wasm:"https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.wasm.wasm",all:"https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.all.js",sync:"https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.sync.js"}});
614
+ const sj=new ScramjetController({prefix:"${scramjetPrefix}",files:{wasm:"https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.wasm.wasm",all:"https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.all.js",sync:"https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.sync.js"}});
611
615
  sj.init();
612
616
  await registerSW();
613
- const c=new BareMux.BareMuxConnection("/baremux/worker.js");
617
+ const c=new BareMux.BareMuxConnection("${workerPath}");
614
618
  const wispUrl=(location.host && location.host.includes("unpkg.com")) ? "wss://wisp.mercurywork.shop/" : ((location.protocol==="https:"?"wss":"ws")+"://"+location.host+"/wisp/");
615
619
  const transportUrl="https://unpkg.com/@mercuryworkshop/libcurl-transport@1.5.2/dist/index.mjs";
616
620
  if((await c.getTransport())!==transportUrl)await c.setTransport(transportUrl,[{websocket:wispUrl}]);
@@ -707,36 +711,36 @@
707
711
  QUICK APPS / APPS REGISTRY (unchanged)
708
712
  ══════════════════════════════════════════ */
709
713
  const QUICK_APPS = [
710
- { name: "duckduckgo", url: "https://www.duckduckgo.com", icon: `<img src="/icons/DDG-Favicon.png" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
711
- { name: "youtube", url: "https://www.youtube.com", icon: `<img src="/icons/YT-Favicon.png" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
712
- { name: "tiktok", url: "https://www.tiktok.com", icon: `<img src="/icons/TT-Favicon.png" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
713
- { name: "discord", url: "https://www.discord.com", icon: `<img src="/icons/DC-Favicon.png" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
714
- { name: "Cool Math Games", url: "https://www.coolmathgames.com", icon: `<img src="/icons/CMG-Favicon.jpg" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
715
- { name: "x [twitter]", url: "https://www.x.com", icon: `<img src="/icons/X-Favicon.jpg" width="25" height="24" style="border-radius:2px;object-fit:contain;" />` },
716
- { name: "chatgpt", url: "https://chat.openai.com", icon: `<img src="/icons/CGPT-Favicon.png" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
717
- { name: "music", url: "https://freefy.app/", icon: `<img src="/icons/MCTF-Favicon.png" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
718
- { name: "movies", url: "https://www.justwatch.com/ca/provider/free-all/", icon: `<img src="/icons/MP4-Favicon.webp" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
714
+ { name: "duckduckgo", url: "https://www.duckduckgo.com", icon: `<img src="icons/DDG-Favicon.png" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
715
+ { name: "youtube", url: "https://www.youtube.com", icon: `<img src="icons/YT-Favicon.png" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
716
+ { name: "tiktok", url: "https://www.tiktok.com", icon: `<img src="icons/TT-Favicon.png" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
717
+ { name: "discord", url: "https://www.discord.com", icon: `<img src="icons/DC-Favicon.png" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
718
+ { name: "Cool Math Games", url: "https://www.coolmathgames.com", icon: `<img src="icons/CMG-Favicon.jpg" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
719
+ { name: "x [twitter]", url: "https://www.x.com", icon: `<img src="icons/X-Favicon.jpg" width="25" height="24" style="border-radius:2px;object-fit:contain;" />` },
720
+ { name: "chatgpt", url: "https://chat.openai.com", icon: `<img src="icons/CGPT-Favicon.png" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
721
+ { name: "music", url: "https://freefy.app/", icon: `<img src="icons/MCTF-Favicon.png" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
722
+ { name: "movies", url: "https://www.justwatch.com/ca/provider/free-all/", icon: `<img src="icons/MP4-Favicon.webp" width="25" height="25" style="border-radius:2px;object-fit:contain;" />` },
719
723
  ];
720
724
 
721
725
  const APPS_REGISTRY = [
722
- { name: "Google", url: "https://www.google.com", icon: `<img src="/icons/G-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Search the web", tags: ["search","google"] },
723
- { name: "YouTube", url: "https://www.youtube.com", icon: `<img src="/icons/YT-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Watch videos", tags: ["video","media"] },
724
- { name: "Discord", url: "https://discord.com/app", icon: `<img src="/icons/DC-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Chat with friends", tags: ["social","chat"] },
725
- { name: "Spotify", url: "https://open.spotify.com", icon: `<img src="/icons/S-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Stream music", tags: ["music","media"] },
726
- { name: "Monochrome.tf", url: "https://monochrome.tf", icon: `<img src="/icons/MCTF-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Stream music", tags: ["music","media"] },
727
- { name: "Reddit", url: "https://www.reddit.com", icon: `<img src="/icons/RDT-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Browse communities", tags: ["social","news"] },
728
- { name: "X / Twitter", url: "https://www.x.com", icon: `<img src="/icons/X-Favicon.jpg" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Trending topics & posts", tags: ["social","news"] },
729
- { name: "TikTok", url: "https://www.tiktok.com", icon: `<img src="/icons/TT-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Short-form videos", tags: ["video","social"] },
730
- { name: "ChatGPT", url: "https://chat.openai.com", icon: `<img src="/icons/CGPT-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "AI assistant by OpenAI", tags: ["ai","tools"] },
731
- { name: "Now.gg", url: "https://www.now.gg/", icon: `<img src="/icons/NGG-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Online games for all.", tags: ["games","dev"] },
732
- { name: "Crazy Games", url: "https://www.crazygames.com/", icon: `<img src="/icons/CZG-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Online games for all.", tags: ["games","dev"] },
726
+ { name: "Google", url: "https://www.google.com", icon: `<img src="icons/G-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Search the web", tags: ["search","google"] },
727
+ { name: "YouTube", url: "https://www.youtube.com", icon: `<img src="icons/YT-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Watch videos", tags: ["video","media"] },
728
+ { name: "Discord", url: "https://discord.com/app", icon: `<img src="icons/DC-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Chat with friends", tags: ["social","chat"] },
729
+ { name: "Spotify", url: "https://open.spotify.com", icon: `<img src="icons/S-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Stream music", tags: ["music","media"] },
730
+ { name: "Monochrome.tf", url: "https://monochrome.tf", icon: `<img src="icons/MCTF-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Stream music", tags: ["music","media"] },
731
+ { name: "Reddit", url: "https://www.reddit.com", icon: `<img src="icons/RDT-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Browse communities", tags: ["social","news"] },
732
+ { name: "X / Twitter", url: "https://www.x.com", icon: `<img src="icons/X-Favicon.jpg" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Trending topics & posts", tags: ["social","news"] },
733
+ { name: "TikTok", url: "https://www.tiktok.com", icon: `<img src="icons/TT-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Short-form videos", tags: ["video","social"] },
734
+ { name: "ChatGPT", url: "https://chat.openai.com", icon: `<img src="icons/CGPT-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "AI assistant by OpenAI", tags: ["ai","tools"] },
735
+ { name: "Now.gg", url: "https://www.now.gg/", icon: `<img src="icons/NGG-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Online games for all.", tags: ["games","dev"] },
736
+ { name: "Crazy Games", url: "https://www.crazygames.com/", icon: `<img src="icons/CZG-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Online games for all.", tags: ["games","dev"] },
733
737
  { name: "Gmail", url: "https://mail.google.com", icon: `<img src="https://ssl.gstatic.com/ui/v1/icons/mail/rfr/gmail.ico" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Email by Google", tags: ["productivity","google"] },
734
- { name: "DuckDuckGo", url: "https://www.duckduckgo.com", icon: `<img src="/icons/DDG-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Private search", tags: ["search"] },
735
- { name: "Bing", url: "https://www.bing.com", icon: `<img src="/icons/BNG-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Microsoft search", tags: ["search"] },
736
- { name: "GitHub", url: "https://github.com", icon: `<img src="/icons/GH-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Code & collaboration", tags: ["tools","dev"] },
737
- { name: "Replit", url: "https://replit.com", icon: `<img src="/icons/RPT-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Code in the browser", tags: ["tools","dev"] },
738
- { name: "Neal.fun", url: "https://www.neal.fun", icon: `<img src="/icons/NDF-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Many fun games.", tags: ["games","education"] },
739
- { name: "Cool Math Games", url: "https://www.coolmathgames.com", icon: `<img src="/icons/CMG-Favicon.jpg" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Math-based browser games", tags: ["games","education"] },
738
+ { name: "DuckDuckGo", url: "https://www.duckduckgo.com", icon: `<img src="icons/DDG-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Private search", tags: ["search"] },
739
+ { name: "Bing", url: "https://www.bing.com", icon: `<img src="icons/BNG-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Microsoft search", tags: ["search"] },
740
+ { name: "GitHub", url: "https://github.com", icon: `<img src="icons/GH-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Code & collaboration", tags: ["tools","dev"] },
741
+ { name: "Replit", url: "https://replit.com", icon: `<img src="icons/RPT-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Code in the browser", tags: ["tools","dev"] },
742
+ { name: "Neal.fun", url: "https://www.neal.fun", icon: `<img src="icons/NDF-Favicon.png" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Many fun games.", tags: ["games","education"] },
743
+ { name: "Cool Math Games", url: "https://www.coolmathgames.com", icon: `<img src="icons/CMG-Favicon.jpg" width="32" height="32" style="border-radius:6px;object-fit:contain;" />`, description: "Math-based browser games", tags: ["games","education"] },
740
744
  ];
741
745
 
742
746
  const cfg = (typeof window !== "undefined" && window.__INDEX_CONFIG) || {};
@@ -745,13 +749,17 @@
745
749
  all: "https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.all.js",
746
750
  sync: "https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.sync.js"
747
751
  };
752
+ const baseDir = new URL("./", location.href).pathname;
753
+ const workerPath = (cfg.baremux && cfg.baremux.worker) || new URL("baremux/worker.js", location.href).pathname;
754
+ const scramjetPrefix = baseDir + "service/";
755
+
748
756
  const { ScramjetController } = $scramjetLoadController();
749
757
  const scramjet = new ScramjetController({
750
- files: scramjetFiles
758
+ files: scramjetFiles,
759
+ prefix: scramjetPrefix
751
760
  });
752
761
  scramjet.init();
753
762
 
754
- const workerPath = (cfg.baremux && cfg.baremux.worker) || "/baremux/worker.js";
755
763
  const connection = new BareMux.BareMuxConnection(workerPath);
756
764
  let transportReady = false;
757
765
 
@@ -935,7 +943,7 @@
935
943
 
936
944
  async function loadGamesRegistry() {
937
945
  try {
938
- const res = await fetch("/games/games.json");
946
+ const res = await fetch("games/games.json");
939
947
  if (!res.ok) throw new Error();
940
948
  gamesRegistry = await res.json();
941
949
  } catch(_) { gamesRegistry = []; }
@@ -1003,9 +1011,10 @@
1003
1011
  if (list.length === 0) { grid.innerHTML = '<div class="games-noresults">no games match your search.<br><span style="opacity:0.5">try a different keyword or tag</span></div>'; return; }
1004
1012
  grid.innerHTML = list.map(g => {
1005
1013
  const tagsHTML = (g.tags||[]).length ? `<div class="game-card-tags">${(g.tags).map(t=>`<span class="game-card-tag">${t}</span>`).join("")}</div>` : "";
1006
- const iconHTML = (g.icon && g.icon.startsWith("/"))
1007
- ? `<img src="${g.icon}" style="width:2em;height:2em;object-fit:contain;border-radius:4px;" />`
1008
- : (g.icon || "🎮");
1014
+ const iconSrc = g.icon && g.icon.startsWith("/") ? g.icon.replace(/^\/+/, '') : g.icon;
1015
+ const iconHTML = (iconSrc && (iconSrc.includes("/") || iconSrc.includes(".")))
1016
+ ? `<img src="${iconSrc}" style="width:2em;height:2em;object-fit:contain;border-radius:4px;" onerror="this.outerHTML='🎮'" />`
1017
+ : (iconSrc || "🎮");
1009
1018
  return `<div class="game-card" data-file="${g.file}" data-name="${g.name}"><div class="game-card-icon">${iconHTML}</div><div class="game-card-name">${g.name}</div>${g.description?`<div class="game-card-desc">${g.description}</div>`:""}${tagsHTML}</div>`;
1010
1019
  }).join("");
1011
1020
  grid.querySelectorAll(".game-card").forEach(card => { card.addEventListener("click", () => openGameModal(card.dataset.file, card.dataset.name)); });
@@ -1023,7 +1032,7 @@
1023
1032
  return;
1024
1033
  }
1025
1034
  gmName.textContent = name; gmFile.textContent = file;
1026
- gmIframe.src = `/games/${file}`;
1035
+ gmIframe.src = "games/" + file;
1027
1036
  gameModal.classList.add("open");
1028
1037
  }
1029
1038
  function closeGameModal() { gameModal.classList.remove("open"); gmIframe.src="about:blank"; }
package/public/index.js CHANGED
@@ -27,15 +27,19 @@ const scramjetFiles = cfg.scramjet || {
27
27
  sync: "https://unpkg.com/@mercuryworkshop/scramjet@2.0.0-alpha/dist/scramjet.sync.js",
28
28
  };
29
29
 
30
+ const baseDir = new URL("./", location.href).pathname;
31
+ const workerPath = (cfg.baremux && cfg.baremux.worker) || new URL("baremux/worker.js", location.href).pathname;
32
+ const scramjetPrefix = baseDir + "service/";
33
+
30
34
  const { ScramjetController } = $scramjetLoadController();
31
35
 
32
36
  const scramjet = new ScramjetController({
33
37
  files: scramjetFiles,
38
+ prefix: scramjetPrefix,
34
39
  });
35
40
 
36
41
  scramjet.init();
37
42
 
38
- const workerPath = (cfg.baremux && cfg.baremux.worker) || "/baremux/worker.js";
39
43
  const connection = new BareMux.BareMuxConnection(workerPath);
40
44
 
41
45
  form.addEventListener("submit", async (event) => {
@@ -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 index.html
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
- await navigator.serviceWorker.register(stockSW);
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
  }