diff --git a/.gitignore b/.gitignore index f597cf72..48fb3ad3 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ node_modules /packs Build -/build \ No newline at end of file +/build +foundry \ No newline at end of file diff --git a/daggerheart.d.ts b/daggerheart.d.ts new file mode 100644 index 00000000..3b753baf --- /dev/null +++ b/daggerheart.d.ts @@ -0,0 +1,21 @@ +import './module/_types'; +import '@client/global.mjs'; +import Canvas from '@client/canvas/board.mjs'; + +// Foundry's use of `Object.assign(globalThis) means many globally available objects are not read as such +// This declare global hopefully fixes that +declare global { + /** + * A simple event framework used throughout Foundry Virtual Tabletop. + * When key actions or events occur, a "hook" is defined where user-defined callback functions can execute. + * This class manages the registration and execution of hooked callback functions. + */ + class Hooks extends foundry.helpers.Hooks {} + const fromUuid = foundry.utils.fromUuid; + const fromUuidSync = foundry.utils.fromUuidSync; + + /** + * The singleton game canvas + */ + const canvas: Canvas; +} diff --git a/jsconfig.json b/jsconfig.json new file mode 100644 index 00000000..00bab1f5 --- /dev/null +++ b/jsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "module": "ES6", + "target": "ES6", + "paths": { + "@client/*": ["./foundry/client/*"], + "@common/*": ["./foundry/common/*"] + } + }, + "exclude": ["node_modules", "**/node_modules/*"], + "include": ["daggerheart.mjs", "foundry/client/client.mjs", "daggerheart.d.ts"], + "typeAcquisition": { + "include": ["jquery"] + } +} diff --git a/module/_types.d.ts b/module/_types.d.ts new file mode 100644 index 00000000..e69de29b diff --git a/package.json b/package.json index 7e76b5e7..f8be74b9 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "start": "concurrently \"rollup -c --watch\" \"node ../../../../FoundryDev/main.js --dataPath=../../../ --noupnp\" \"gulp\"", "start-test": "node ./resources/app/main.js --dataPath=./ && rollup -c --watch && gulp", "pushLDBtoYML": "node ./tools/pushLDBtoYML.mjs", - "pullYMLtoLDB": "node ./tools/pullYMLtoLDB.mjs" + "pullYMLtoLDB": "node ./tools/pullYMLtoLDB.mjs", + "createSymlink": "node ./tools/create-symlink.mjs" }, "devDependencies": { "@foundryvtt/foundryvtt-cli": "^1.0.2", diff --git a/tools/create-symlink.mjs b/tools/create-symlink.mjs new file mode 100644 index 00000000..19c29814 --- /dev/null +++ b/tools/create-symlink.mjs @@ -0,0 +1,52 @@ +import fs from "fs"; +import path from "path"; +import readline from "readline"; + +console.log("Reforging Symlinks"); + +const askQuestion = (question) => { + const rl = readline.createInterface({ + input: process.stdin, + output: process.stdout + }); + + return new Promise((resolve) => + rl.question(question, (answer) => { + rl.close(); + resolve(answer); + }) + ); +}; + +const installPath = await askQuestion("Enter your Foundry install path: "); + +// Determine if it's an Electron install (nested structure) +const nested = fs.existsSync(path.join(installPath, "resources", "app")); +const fileRoot = nested + ? path.join(installPath, "resources", "app") + : installPath; + +try { + await fs.promises.mkdir("foundry"); +} catch (e) { + if (e.code !== "EEXIST") throw e; +} + +// JavaScript files +for (const p of ["client", "common", "tsconfig.json"]) { + try { + await fs.promises.symlink(path.join(fileRoot, p), path.join("foundry", p)); + } catch (e) { + if (e.code !== "EEXIST") throw e; + } +} + +// Language files +try { + await fs.promises.symlink( + path.join(fileRoot, "public", "lang"), + path.join("foundry", "lang") + ); +} catch (e) { + if (e.code !== "EEXIST") throw e; +}