@indextools/index-games 1.0.1 → 1.0.3

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.
Files changed (238) hide show
  1. package/package.json +1 -1
  2. package/public/config.js +28 -22
  3. package/public/games/10fastfingers.html +12 -0
  4. package/public/games/2048.html +12 -0
  5. package/public/games/absurdle.html +12 -0
  6. package/public/games/actorle.html +12 -0
  7. package/public/games/adventurecapitalist.html +12 -0
  8. package/public/games/agario.html +12 -0
  9. package/public/games/airhockey.html +12 -0
  10. package/public/games/among.html +12 -0
  11. package/public/games/anagram.html +12 -0
  12. package/public/games/angrybirds.html +12 -0
  13. package/public/games/archery.html +12 -0
  14. package/public/games/artquiz.html +12 -0
  15. package/public/games/asteroids.html +12 -0
  16. package/public/games/backgammon.html +12 -0
  17. package/public/games/ballblast.html +12 -0
  18. package/public/games/bandle.html +12 -0
  19. package/public/games/basketballstars.html +12 -0
  20. package/public/games/battleship.html +12 -0
  21. package/public/games/betweenle.html +12 -0
  22. package/public/games/bingo.html +12 -0
  23. package/public/games/blackjack.html +12 -0
  24. package/public/games/blockpuzzle.html +12 -0
  25. package/public/games/bobbleheadbrawl.html +12 -0
  26. package/public/games/bookworm.html +12 -0
  27. package/public/games/bowlingking.html +12 -0
  28. package/public/games/brutal.html +12 -0
  29. package/public/games/bubbshooter.html +12 -0
  30. package/public/games/candycrush.html +12 -0
  31. package/public/games/capitalcities.html +12 -0
  32. package/public/games/cardgame.html +12 -0
  33. package/public/games/carparking.html +12 -0
  34. package/public/games/castlevania.html +12 -0
  35. package/public/games/checkers.html +12 -0
  36. package/public/games/chess.html +12 -0
  37. package/public/games/citybuilder.html +12 -0
  38. package/public/games/clue.html +12 -0
  39. package/public/games/cluelike.html +12 -0
  40. package/public/games/codecombat.html +12 -0
  41. package/public/games/colonist.html +12 -0
  42. package/public/games/colonists.html +12 -0
  43. package/public/games/colorfle.html +12 -0
  44. package/public/games/connectfour.html +12 -0
  45. package/public/games/connections.html +12 -0
  46. package/public/games/contexto.html +12 -0
  47. package/public/games/cookieclicker.html +12 -0
  48. package/public/games/counterblox.html +12 -0
  49. package/public/games/crazycattle.html +12 -0
  50. package/public/games/cribbage.html +12 -0
  51. package/public/games/crossword.html +12 -0
  52. package/public/games/crossyroad.html +12 -0
  53. package/public/games/curling.html +12 -0
  54. package/public/games/cutherope.html +12 -0
  55. package/public/games/darts.html +12 -0
  56. package/public/games/defly.html +12 -0
  57. package/public/games/diablo2d.html +12 -0
  58. package/public/games/dice.html +12 -0
  59. package/public/games/diepio.html +12 -0
  60. package/public/games/dinogame.html +12 -0
  61. package/public/games/doctorgame.html +12 -0
  62. package/public/games/dominoes.html +12 -0
  63. package/public/games/dordle.html +12 -0
  64. package/public/games/doublicator.html +12 -0
  65. package/public/games/driftboss.html +12 -0
  66. package/public/games/drivertest.html +12 -0
  67. package/public/games/dungeoncrawl.html +12 -0
  68. package/public/games/euchre.html +12 -0
  69. package/public/games/ev.html +12 -0
  70. package/public/games/farmidler.html +12 -0
  71. package/public/games/fencing.html +12 -0
  72. package/public/games/fibble.html +12 -0
  73. package/public/games/finalfantasy.html +12 -0
  74. package/public/games/fishdom.html +12 -0
  75. package/public/games/flagle.html +12 -0
  76. package/public/games/flappybird.html +12 -0
  77. package/public/games/foosball.html +12 -0
  78. package/public/games/fortnite2d.html +12 -0
  79. package/public/games/framed.html +12 -0
  80. package/public/games/freecell.html +12 -0
  81. package/public/games/frutninja.html +12 -0
  82. package/public/games/galaxydefense.html +12 -0
  83. package/public/games/games.json +2843 -29
  84. package/public/games/garticphone.html +12 -0
  85. package/public/games/geoguessr.html +12 -0
  86. package/public/games/geoquiz.html +12 -0
  87. package/public/games/getaway.html +12 -0
  88. package/public/games/getgoodgames.html +12 -0
  89. package/public/games/gin.html +12 -0
  90. package/public/games/golfgame.html +12 -0
  91. package/public/games/guessr.html +12 -0
  92. package/public/games/gunblood.html +12 -0
  93. package/public/games/gunfight.html +12 -0
  94. package/public/games/hackeridler.html +12 -0
  95. package/public/games/hangaroo.html +12 -0
  96. package/public/games/heardle.html +12 -0
  97. package/public/games/heartsgame.html +12 -0
  98. package/public/games/heroquest.html +12 -0
  99. package/public/games/historyquiz.html +12 -0
  100. package/public/games/hospitallife.html +12 -0
  101. package/public/games/hoteltycoon.html +12 -0
  102. package/public/games/infinitecraft.html +12 -0
  103. package/public/games/islandtrivia.html +12 -0
  104. package/public/games/jelly.html +12 -0
  105. package/public/games/jewels.html +12 -0
  106. package/public/games/kahoot.html +12 -0
  107. package/public/games/kirka.html +12 -0
  108. package/public/games/knifehit.html +12 -0
  109. package/public/games/krunker.html +12 -0
  110. package/public/games/leaguedle.html +12 -0
  111. package/public/games/letterle.html +12 -0
  112. package/public/games/life.html +12 -0
  113. package/public/games/lightbot.html +12 -0
  114. package/public/games/loldle.html +12 -0
  115. package/public/games/lordz.html +12 -0
  116. package/public/games/magicblast.html +12 -0
  117. package/public/games/mahjong.html +12 -0
  118. package/public/games/mario.html +12 -0
  119. package/public/games/matchmaster.html +12 -0
  120. package/public/games/mathblaster.html +12 -0
  121. package/public/games/mathgame.html +12 -0
  122. package/public/games/mathler.html +12 -0
  123. package/public/games/megaman.html +12 -0
  124. package/public/games/mergedragons.html +12 -0
  125. package/public/games/mergefight.html +12 -0
  126. package/public/games/minecraftclone.html +12 -0
  127. package/public/games/minesweeper.html +12 -0
  128. package/public/games/miniclip.html +12 -0
  129. package/public/games/monopoly.html +12 -0
  130. package/public/games/mope.html +12 -0
  131. package/public/games/moto3.html +12 -0
  132. package/public/games/moviedle.html +12 -0
  133. package/public/games/moviesquiz.html +12 -0
  134. package/public/games/musiquiz.html +12 -0
  135. package/public/games/nationle.html +12 -0
  136. package/public/games/nba2k.html +12 -0
  137. package/public/games/nerdle.html +12 -0
  138. package/public/games/ninjago.html +12 -0
  139. package/public/games/octordle.html +12 -0
  140. package/public/games/pacman.html +12 -0
  141. package/public/games/papergame.html +12 -0
  142. package/public/games/pilotsim.html +12 -0
  143. package/public/games/pinball.html +12 -0
  144. package/public/games/pinochle.html +12 -0
  145. package/public/games/pinturillo.html +12 -0
  146. package/public/games/pirateio.html +12 -0
  147. package/public/games/pizzamaking.html +12 -0
  148. package/public/games/pogo.html +12 -0
  149. package/public/games/pointerpointer.html +12 -0
  150. package/public/games/pokedle.html +12 -0
  151. package/public/games/pokedle2.html +12 -0
  152. package/public/games/pokemonbattle.html +12 -0
  153. package/public/games/pokerclassic.html +12 -0
  154. package/public/games/poolrush.html +12 -0
  155. package/public/games/popculturequiz.html +12 -0
  156. package/public/games/primel.html +12 -0
  157. package/public/games/prodigygame.html +12 -0
  158. package/public/games/questland.html +12 -0
  159. package/public/games/quizlet.html +12 -0
  160. package/public/games/quordle.html +12 -0
  161. package/public/games/reslife.html +12 -0
  162. package/public/games/reversi.html +12 -0
  163. package/public/games/ridleracing.html +12 -0
  164. package/public/games/risk.html +12 -0
  165. package/public/games/roadfury.html +12 -0
  166. package/public/games/rooftopsnipers.html +12 -0
  167. package/public/games/run3.html +12 -0
  168. package/public/games/schoolbus.html +12 -0
  169. package/public/games/sciencequiz.html +12 -0
  170. package/public/games/scrabble.html +12 -0
  171. package/public/games/scratch.html +12 -0
  172. package/public/games/sedecordle.html +12 -0
  173. package/public/games/semantle.html +12 -0
  174. package/public/games/shellshock.html +12 -0
  175. package/public/games/shipsim.html +12 -0
  176. package/public/games/skribbl.html +12 -0
  177. package/public/games/skyblock.html +12 -0
  178. package/public/games/slots.html +12 -0
  179. package/public/games/snakegame.html +12 -0
  180. package/public/games/snakeio.html +12 -0
  181. package/public/games/snowball.html +12 -0
  182. package/public/games/soccerskills.html +12 -0
  183. package/public/games/solitaire.html +12 -0
  184. package/public/games/sonic.html +12 -0
  185. package/public/games/spaceshipshooter.html +12 -0
  186. package/public/games/spacesurvive.html +12 -0
  187. package/public/games/spades.html +12 -0
  188. package/public/games/spellcast.html +12 -0
  189. package/public/games/spellinbee.html +12 -0
  190. package/public/games/spellingbee2.html +12 -0
  191. package/public/games/spidersolitaire.html +12 -0
  192. package/public/games/sportsquiz.html +12 -0
  193. package/public/games/squaredle.html +12 -0
  194. package/public/games/squirdle.html +12 -0
  195. package/public/games/stardew.html +12 -0
  196. package/public/games/starve.html +12 -0
  197. package/public/games/stickmanfight.html +12 -0
  198. package/public/games/stratego.html +12 -0
  199. package/public/games/strategydefense.html +12 -0
  200. package/public/games/stuntcar.html +12 -0
  201. package/public/games/sudoku.html +12 -0
  202. package/public/games/superhero.html +12 -0
  203. package/public/games/superhex.html +12 -0
  204. package/public/games/superhot.html +12 -0
  205. package/public/games/surviv.html +12 -0
  206. package/public/games/sushichef.html +12 -0
  207. package/public/games/tabletopia.html +12 -0
  208. package/public/games/tennisgame.html +12 -0
  209. package/public/games/terraria2d.html +12 -0
  210. package/public/games/tetris.html +12 -0
  211. package/public/games/theimpossiblequiz.html +12 -0
  212. package/public/games/timersniper.html +12 -0
  213. package/public/games/towerblitz.html +12 -0
  214. package/public/games/traindriver.html +12 -0
  215. package/public/games/truckgame.html +12 -0
  216. package/public/games/tunnel.html +12 -0
  217. package/public/games/typeracer.html +12 -0
  218. package/public/games/typingclub.html +12 -0
  219. package/public/games/typingtower.html +12 -0
  220. package/public/games/undergame.html +12 -0
  221. package/public/games/voxiom.html +12 -0
  222. package/public/games/wepons.html +12 -0
  223. package/public/games/wordle.html +12 -0
  224. package/public/games/worldflags.html +12 -0
  225. package/public/games/worldle.html +12 -0
  226. package/public/games/wormate.html +12 -0
  227. package/public/games/wormszone.html +12 -0
  228. package/public/games/zelda.html +12 -0
  229. package/public/games/zombiederby.html +12 -0
  230. package/public/games/zombiesurvive.html +12 -0
  231. package/public/games/zombs.html +12 -0
  232. package/public/games/zuma.html +12 -0
  233. package/public/index.css +30 -0
  234. package/public/index.html +418 -263
  235. package/public/index.svg +33 -50
  236. package/public/register-sw.js +37 -21
  237. package/public/sw.js +42 -6
  238. package/index.svg +0 -53
package/public/index.svg CHANGED
@@ -1,53 +1,36 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 100 100">
3
- <foreignObject width="100%" height="100%">
4
- <html xmlns="http://www.w3.org/1999/xhtml" style="width:100%; height:100%; margin:0; padding:0;">
5
- <head>
6
- <title>Index</title>
7
- <style>
8
- * { margin: 0; padding: 0; box-sizing: border-box; }
9
- html, body { width: 100%; height: 100%; overflow: hidden; background: #0b0c10; }
10
- iframe { width: 100vw; height: 100vh; border: none; display: block; position: fixed; inset: 0; }
11
- .fallback-link {
12
- position: fixed;
13
- top: 10px;
14
- right: 10px;
15
- z-index: 99999;
16
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
17
- font-size: 13px;
18
- color: #45f3ff;
19
- background: rgba(11, 12, 16, 0.9);
20
- border: 1px solid #45f3ff;
21
- padding: 6px 14px;
22
- border-radius: 6px;
23
- text-decoration: none;
24
- backdrop-filter: blur(4px);
25
- }
26
- </style>
27
- </head>
28
- <body>
29
- <a id="index-link" class="fallback-link" href="index.html" target="_top">Launch Index</a>
30
- <iframe id="index-frame" src="index.html" allowfullscreen="true" sandbox="allow-scripts allow-same-origin allow-forms allow-modals allow-downloads"></iframe>
31
- </body>
32
- </html>
2
+ <svg xmlns="http://www.w3.org/2000/svg"
3
+ xmlns:xhtml="http://www.w3.org/1999/xhtml"
4
+ width="100%" height="100%"
5
+ viewBox="0 0 1920 1080">
6
+
7
+ <!--
8
+ INDEX SVG SHELL
9
+ ───────────────────────────────────────────────────────────────
10
+ The foreignObject embeds a full-window HTML iframe pointed at
11
+ index.html. This keeps the SVG wrapper as a valid disguise while
12
+ the actual proxy app runs in a proper HTML browsing context where
13
+ service workers, localStorage, and navigator APIs all work
14
+ correctly regardless of the outer SVG context.
15
+
16
+ Why iframe instead of inline HTML?
17
+ ─ Service workers can only be registered from an HTML document,
18
+ not from inside SVG foreignObject.
19
+ ─ Scripts inside foreignObject run in the SVG document's origin
20
+ context which breaks relative URL resolution.
21
+ ─ An iframe gives us a fresh HTML document with its own SW scope.
22
+ -->
23
+
24
+ <foreignObject x="0" y="0" width="1920" height="1080">
25
+ <xhtml:div style="width:100%;height:100%;margin:0;padding:0;overflow:hidden;">
26
+ <xhtml:iframe
27
+ src="index.html"
28
+ style="width:100%;height:100%;border:none;display:block;"
29
+ allow="gamepad *"
30
+ sandbox="allow-scripts allow-same-origin allow-forms allow-modals allow-popups allow-top-navigation"
31
+ title="Index"
32
+ />
33
+ </xhtml:div>
33
34
  </foreignObject>
34
- <script type="text/javascript">
35
- <![CDATA[
36
- (function() {
37
- try {
38
- var frame = document.getElementById("index-frame");
39
- var link = document.getElementById("index-link");
40
- var path = (typeof window !== "undefined" && window.location && window.location.pathname) || "";
41
- var target = "index.html";
42
- if (path && !path.includes("/public/") && !path.endsWith("/public")) {
43
- target = "public/index.html";
44
- }
45
- if (frame && !frame.getAttribute("src")) frame.src = target;
46
- if (link) link.href = target;
47
- } catch (e) {
48
- console.error(e);
49
- }
50
- })();
51
- ]]>
52
- </script>
35
+
53
36
  </svg>
@@ -1,29 +1,45 @@
1
1
  "use strict";
2
2
 
3
- /**
4
- * List of hostnames that are allowed to run serviceworkers on http://
5
- */
6
3
  const swAllowedHostnames = ["localhost", "127.0.0.1"];
7
4
 
8
- /**
9
- * Global util
10
- * Used in index.html, 404.html, and games
11
- */
12
5
  async function registerSW() {
13
- if (!navigator.serviceWorker) {
14
- if (
15
- location.protocol !== "https:" &&
16
- !swAllowedHostnames.includes(location.hostname)
17
- )
18
- throw new Error("Service workers cannot be registered without https.");
6
+ if (!navigator.serviceWorker) {
7
+ if (
8
+ location.protocol !== "https:" &&
9
+ !swAllowedHostnames.includes(location.hostname)
10
+ )
11
+ throw new Error("Service workers require https or localhost.");
12
+ throw new Error("Your browser does not support service workers.");
13
+ }
19
14
 
20
- throw new Error("Your browser doesn't support service workers.");
21
- }
15
+ // Resolve publicDir from the actual page location, handling SVG wrapper:
16
+ // If we're inside an SVG foreignObject the document.baseURI still points
17
+ // to the HTML file, but location.href points to the SVG.
18
+ // We detect this and use document.baseURI instead when available.
19
+ let base = location.href;
20
+ if (document && document.baseURI && !document.baseURI.endsWith(".svg")) {
21
+ base = document.baseURI;
22
+ }
22
23
 
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 });
24
+ let publicDir = new URL("./", base).pathname;
25
+ // If loaded from a /games/ subdirectory, back up one
26
+ if (publicDir.endsWith("/games/")) {
27
+ publicDir = new URL("../", base).pathname;
28
+ }
29
+
30
+ const swUrl = publicDir + "sw.js";
31
+ const reg = await navigator.serviceWorker.register(swUrl, { scope: publicDir });
32
+ // Wait for SW to become active immediately
33
+ if (reg.installing || reg.waiting) {
34
+ await new Promise((resolve) => {
35
+ const sw = reg.installing || reg.waiting;
36
+ sw.addEventListener("statechange", function handler() {
37
+ if (sw.state === "activated") {
38
+ sw.removeEventListener("statechange", handler);
39
+ resolve();
40
+ }
41
+ });
42
+ if (reg.active) resolve();
43
+ });
44
+ }
29
45
  }
package/public/sw.js CHANGED
@@ -1,16 +1,52 @@
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
+
11
+ // UV config - fix prefix so it always resolves relative to SW scope
12
+ if (self.__uv$config) {
13
+ self.__uv$config.prefix = baseDir + "uv/";
14
+ self.__uv$config.bare = baseDir + "bare/";
15
+ // Use epoxy (fastest Rust/Wasm transport) if config says so
16
+ self.__uv$config.encodeUrl = Ultraviolet.codec.xor.encode;
17
+ self.__uv$config.decodeUrl = Ultraviolet.codec.xor.decode;
18
+ }
19
+
20
+ const uv = new UVServiceWorker();
21
+
22
+ // Scramjet needs its prefix config too
23
+ scramjet.loadConfig().catch(() => {});
24
+
25
+ // Cache for routing decisions
26
+ const UV_PREFIX = baseDir + "uv/";
27
+ const SJ_PREFIX = baseDir + "service/";
28
+
6
29
  async function handleRequest(event) {
7
- await scramjet.loadConfig();
8
- if (scramjet.route(event)) {
9
- return scramjet.fetch(event);
10
- }
11
- return fetch(event.request);
30
+ const url = event.request.url;
31
+
32
+ // UV handles its prefix
33
+ if (url.includes(UV_PREFIX)) {
34
+ return uv.fetch(event);
35
+ }
36
+ // Scramjet handles its prefix
37
+ if (url.includes(SJ_PREFIX)) {
38
+ await scramjet.loadConfig();
39
+ if (scramjet.route(event)) {
40
+ return scramjet.fetch(event);
41
+ }
42
+ }
43
+ // Fallthrough
44
+ return fetch(event.request);
12
45
  }
13
46
 
14
47
  self.addEventListener("fetch", (event) => {
15
- event.respondWith(handleRequest(event));
48
+ event.respondWith(handleRequest(event));
16
49
  });
50
+
51
+ self.addEventListener("install", () => self.skipWaiting());
52
+ self.addEventListener("activate", (e) => e.waitUntil(clients.claim()));
package/index.svg DELETED
@@ -1,53 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 100 100">
3
- <foreignObject width="100%" height="100%">
4
- <html xmlns="http://www.w3.org/1999/xhtml" style="width:100%; height:100%; margin:0; padding:0;">
5
- <head>
6
- <title>Index</title>
7
- <style>
8
- * { margin: 0; padding: 0; box-sizing: border-box; }
9
- html, body { width: 100%; height: 100%; overflow: hidden; background: #0b0c10; }
10
- iframe { width: 100vw; height: 100vh; border: none; display: block; position: fixed; inset: 0; }
11
- .fallback-link {
12
- position: fixed;
13
- top: 10px;
14
- right: 10px;
15
- z-index: 99999;
16
- font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
17
- font-size: 13px;
18
- color: #45f3ff;
19
- background: rgba(11, 12, 16, 0.9);
20
- border: 1px solid #45f3ff;
21
- padding: 6px 14px;
22
- border-radius: 6px;
23
- text-decoration: none;
24
- backdrop-filter: blur(4px);
25
- }
26
- </style>
27
- </head>
28
- <body>
29
- <a id="index-link" class="fallback-link" href="public/index.html" target="_top">Launch Index</a>
30
- <iframe id="index-frame" src="public/index.html" allowfullscreen="true" sandbox="allow-scripts allow-same-origin allow-forms allow-modals allow-downloads"></iframe>
31
- </body>
32
- </html>
33
- </foreignObject>
34
- <script type="text/javascript">
35
- <![CDATA[
36
- (function() {
37
- try {
38
- var frame = document.getElementById("index-frame");
39
- var link = document.getElementById("index-link");
40
- var path = (typeof window !== "undefined" && window.location && window.location.pathname) || "";
41
- var target = "public/index.html";
42
- if (path && (path.includes("/public/") || path.endsWith("/public"))) {
43
- target = "index.html";
44
- }
45
- if (frame) frame.src = target;
46
- if (link) link.href = target;
47
- } catch (e) {
48
- console.error(e);
49
- }
50
- })();
51
- ]]>
52
- </script>
53
- </svg>