@indextools/index-games 1.0.2 → 1.0.4

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 (237) hide show
  1. package/package.json +1 -1
  2. package/public/config.js +28 -33
  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.html +416 -263
  234. package/public/index.svg +31 -1154
  235. package/public/register-sw.js +37 -21
  236. package/public/sw.js +35 -11
  237. package/index.svg +0 -1159
@@ -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
@@ -7,22 +7,46 @@ const { ScramjetServiceWorker } = $scramjetLoadWorker();
7
7
  const scramjet = new ScramjetServiceWorker();
8
8
 
9
9
  const baseDir = new URL("./", location.href).pathname;
10
+
11
+ // UV config - fix prefix so it always resolves relative to SW scope
10
12
  if (self.__uv$config) {
11
- self.__uv$config.prefix = baseDir + "uv/";
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;
12
18
  }
13
- const uv = new self.UVServiceWorker(self.__uv$config);
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/";
14
28
 
15
29
  async function handleRequest(event) {
16
- if (uv.route(event)) {
17
- return uv.fetch(event);
18
- }
19
- await scramjet.loadConfig();
20
- if (scramjet.route(event)) {
21
- return scramjet.fetch(event);
22
- }
23
- 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);
24
45
  }
25
46
 
26
47
  self.addEventListener("fetch", (event) => {
27
- event.respondWith(handleRequest(event));
48
+ event.respondWith(handleRequest(event));
28
49
  });
50
+
51
+ self.addEventListener("install", () => self.skipWaiting());
52
+ self.addEventListener("activate", (e) => e.waitUntil(clients.claim()));