diff --git a/Makefile b/Makefile index 8348231bb..3fecc48b5 100644 --- a/Makefile +++ b/Makefile @@ -30,14 +30,7 @@ love: build/hawkthorne.love love.js: build/hawkthorne.love mkdir -p build/web npm install - npx love.js -t "Journey to the Center of Hawkthorne" -m 77594624 -c build/hawkthorne.love build/web - ######## Temporary LÖVE v11.5 until new version is published on NPM ######## - $(WGET) https://github.com/Davidobot/love.js/raw/refs/heads/master/src/compat/love.js - $(WGET) https://github.com/Davidobot/love.js/raw/refs/heads/master/src/compat/love.wasm - mv love.js build/web/ - mv love.wasm build/web/ - ################################### END #################################### - cp templates/web/* build/web/ + npx love.js -m 77594624 -c build/hawkthorne.love build/web build/hawkthorne.love: $(TILEMAPS) src/* mkdir -p build diff --git a/package-lock.json b/package-lock.json index ad983ef64..8d3d4f786 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,7 @@ "packages": { "": { "dependencies": { - "love.js": "^11.4.1" + "love.js": "github:hawkthorne/love.js" } }, "node_modules/commander": { @@ -14,6 +14,12 @@ "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", "license": "MIT" }, + "node_modules/core-util-is": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", + "integrity": "sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==", + "license": "MIT" + }, "node_modules/fs-extra": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-3.0.1.tgz", @@ -31,6 +37,24 @@ "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", "license": "ISC" }, + "node_modules/immediate": { + "version": "3.0.6", + "resolved": "https://registry.npmjs.org/immediate/-/immediate-3.0.6.tgz", + "integrity": "sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ==", + "license": "MIT" + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", + "license": "ISC" + }, + "node_modules/isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==", + "license": "MIT" + }, "node_modules/jsonfile": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-3.0.1.tgz", @@ -40,26 +64,36 @@ "graceful-fs": "^4.1.6" } }, - "node_modules/klaw-sync": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/klaw-sync/-/klaw-sync-2.1.0.tgz", - "integrity": "sha512-lIxVCUMQIF7hfygFfdZgv4Z+e1smLroaYNQMUcf1TcJ5oqxj9m8qk19iIuMVl+tXQPr3CSE4V+4XjGEqmsth0Q==", + "node_modules/jszip": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/jszip/-/jszip-3.10.1.tgz", + "integrity": "sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g==", + "license": "(MIT OR GPL-3.0-or-later)", + "dependencies": { + "lie": "~3.3.0", + "pako": "~1.0.2", + "readable-stream": "~2.3.6", + "setimmediate": "^1.0.5" + } + }, + "node_modules/lie": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/lie/-/lie-3.3.0.tgz", + "integrity": "sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==", "license": "MIT", - "optionalDependencies": { - "graceful-fs": "^4.1.11" + "dependencies": { + "immediate": "~3.0.5" } }, "node_modules/love.js": { - "version": "11.4.1", - "resolved": "https://registry.npmjs.org/love.js/-/love.js-11.4.1.tgz", - "integrity": "sha512-NLMD2GpIHOCsflgulr18p4+Crizfixgo5ZMbJmDrqVuR7jdketbUDL7X+LCR2o2uMkVU8ZwXnRwT86S7A75yhA==", + "version": "11.5.1", + "resolved": "git+ssh://git@github.com/hawkthorne/love.js.git#2d9f2ccf363a53252259937321685ac04996d612", "license": "MIT", "dependencies": { "commander": "^2.9.0", "fs-extra": "^3.0.1", - "klaw-sync": "^2.1.0", - "mustache": "^2.3.0", - "uuid": "^3.0.1" + "jszip": "^3.10.1", + "mustache": "^2.3.0" }, "bin": { "love.js": "index.js" @@ -81,6 +115,54 @@ "npm": ">=1.4.0" } }, + "node_modules/pako": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", + "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==", + "license": "(MIT AND Zlib)" + }, + "node_modules/process-nextick-args": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", + "integrity": "sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==", + "license": "MIT" + }, + "node_modules/readable-stream": { + "version": "2.3.8", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.8.tgz", + "integrity": "sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==", + "license": "MIT", + "dependencies": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "license": "MIT" + }, + "node_modules/setimmediate": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", + "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==", + "license": "MIT" + }, + "node_modules/string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "license": "MIT", + "dependencies": { + "safe-buffer": "~5.1.0" + } + }, "node_modules/universalify": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", @@ -90,15 +172,11 @@ "node": ">= 4.0.0" } }, - "node_modules/uuid": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", - "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", - "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", - "license": "MIT", - "bin": { - "uuid": "bin/uuid" - } + "node_modules/util-deprecate": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", + "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==", + "license": "MIT" } } } diff --git a/package.json b/package.json index d0a8643cc..472f7820b 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { "dependencies": { - "love.js": "^11.4.1" + "love.js": "github:hawkthorne/love.js" } } diff --git a/templates/web/index.html b/templates/web/index.html deleted file mode 100644 index 81e3221b1..000000000 --- a/templates/web/index.html +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - Journey to the Center of Hawkthorne - - - - - - - - - - - - diff --git a/templates/web/love-game.css b/templates/web/love-game.css deleted file mode 100644 index 71ea0414f..000000000 --- a/templates/web/love-game.css +++ /dev/null @@ -1,69 +0,0 @@ -love-game { - display: block; - position: relative; - background: #000; - margin-inline: auto; - color: #FFF; - margin-block: 1rem; - - /* the canvas *must not* have any border or padding, or mouse coords will be wrong */ - & canvas { - padding: 0; - border: none; - display: block; - background: #000; - height: auto; - max-width: 100%; - } - - &:has(noscript) { - & canvas { - width: min(100dvw, 1056px); - } - } - - & .pregame, - & noscript { - width: 100%; - height: 100%; - } - - & .pregame { - position: absolute; - top: 0; - left: 0; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - padding: 2rem; - - & input[type="submit"] { - cursor: pointer; - width: 200px; - height: 110px; - border: none; - background: #FFF; - font-size: 2rem; - text-transform: uppercase; - color: #000; - transition: 0.125s ease-in-out scale; - - &:hover { - scale: 1.2; - } - } - } - - & noscript { - position: absolute; - top: 0; - left: 0; - display: flex; - flex-direction: column; - justify-content: center; - text-align: center; - font-size: 2rem; - padding: 2rem; - } -} diff --git a/templates/web/love-game.js b/templates/web/love-game.js deleted file mode 100644 index cf40fbdb2..000000000 --- a/templates/web/love-game.js +++ /dev/null @@ -1,136 +0,0 @@ -"use strict"; - -class LoveGame extends HTMLElement { - constructor() { - super(); - - this.LIBRARIES = [ - new URL("game.js", import.meta.url), - new URL("love.js", import.meta.url) - ]; - } - - connectedCallback() { - this.querySelector("noscript").remove(); - - const submit = document.createElement("input"); - submit.type = "submit"; - submit.value = "Play"; - - const form = document.createElement("form"); - form.addEventListener("submit", (_e) => { - this.init(); - form.remove(); - }); - - this.pregameContainer = document.createElement("div"); - this.pregameContainer.className = "pregame"; - - form.appendChild(submit); - this.pregameContainer.appendChild(form); - - this.appendChild(this.pregameContainer); - } - - init() { - this.Module = { - arguments: ["./game.love"], - filePackagePrefixURL: new URL("game.data", import.meta.url).href.replace(/game.data$/, ""), - INITIAL_MEMORY: parseInt(this.dataset.memory), - printErr: console.error.bind(console), - canvas: (() => { - const canvas = this.querySelector("#canvas"); - - // As a default initial behavior, pop up an alert when webgl context is lost. To make your - // application robust, you may want to override this behavior before shipping! - // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2 - canvas.addEventListener("webglcontextlost", function(e) { - alert("WebGL context lost. You will need to reload the page."); - e.preventDefault(); - }, false); - - canvas.addEventListener("contextmenu", function(e) { - e.preventDefault(); - }, false); - - return canvas; - })(), - setStatus: (text) => { - if (text) { - this.pregameContainer.innerText = text; - } - }, - totalDependencies: 0, - remainingDependencies: 0, - monitorRunDependencies: (left) => { - this.Module.remainingDependencies = left; - this.Module.totalDependencies = Math.max(this.Module.totalDependencies, left); - if (left) { - this.Module.setStatus("Preparing... (" + (this.Module.totalDependencies - left) + "/" + this.Module.totalDependencies + ")"); - } else { - this.Module.setStatus("All downloads complete."); - this.pregameContainer.remove(); - } - } - }; - // Unfortunately, game.js needs the Module on the global object - globalThis.Module = this.Module; - - Promise.all( - this.LIBRARIES.map((url) => { - return this.loadLib(url); - }) - ).then( - success => { - window.addEventListener("keydown", function(e) { - // space and arrow keys - if([32, 37, 38, 39, 40].indexOf(e.keyCode) > -1) { - e.preventDefault(); - } - }, false); - - window.onerror = (event) => { - // TODO: do not warn on ok events like simulating an infinite loop or exitStatus - this.Module.setStatus("Exception thrown, see JavaScript console"); - this.Module.setStatus = function(text) { - if (text) Module.printErr("[post-exception status] " + text); - }; - }; - - this.Module.setStatus("Downloading..."); - Love(this.Module); - }, - err => {throw new Error("Unable to load necessary libraries", { cause: err })} - ); - } - - loadLib(url) { - return new Promise((resolve, reject) => { - const existingScript = document.head.querySelector("script[src='" + url + "']"); - if (existingScript) { - existingScript.addEventListener("load", function () { - resolve(url); - }); - existingScript.addEventListener("error", function (error) { - reject(error); - }); - return; - } - let script = document.createElement("script"); - script.type = "text/javascript"; - script.async = true; - script.src = url; - - script.onload = function () { - resolve(url); - } - script.onerror = function (error) { - reject(error); - } - - document.head.appendChild(script); - }); - } -} - -customElements.define("love-game", LoveGame);