RC-4 | Repo initialization

This commit is contained in:
Oliver-Akins 2024-12-10 01:01:12 -07:00
parent 0787446c8d
commit a48071b29a
11 changed files with 2419 additions and 0 deletions

View file

@ -0,0 +1,17 @@
const loaders = {
svg(data) {
const iconName = data.path.split(`/`).slice(-1)[0].slice(0, -4);
Logger.debug(`hot-reloading icon: ${iconName}`);
Hooks.call(`${game.system.id}-hmr:svg`, iconName, data);
},
mjs() {window.location.reload()},
css(data) {
Logger.debug(`Hot-reloading CSS: ${data.path}`);
Hooks.call(`${game.system.id}-hmr:css`, data);
},
};
Hooks.on(`hotReload`, async (data) => {
if (!loaders[data.extension]) {return}
return loaders[data.extension](data);
});

5
module/hooks/init.mjs Normal file
View file

@ -0,0 +1,5 @@
import { Logger } from "../utils/Logger.mjs";
Hooks.once(`init`, () => {
Logger.log(`Initializing`);
});

5
module/hooks/ready.mjs Normal file
View file

@ -0,0 +1,5 @@
import { Logger } from "../utils/Logger.mjs";
Hooks.once(`ready`, () => {
Logger.log(`Ready`);
});

0
module/main.mjs Normal file
View file

22
module/utils/Logger.mjs Normal file
View file

@ -0,0 +1,22 @@
const augmentedProps = new Set([
`debug`,
`log`,
`error`,
`info`,
`warn`,
`group`,
`time`,
`timeEnd`,
`timeLog`,
`timeStamp`,
]);
/** @type {Console} */
export const Logger = new Proxy(console, {
get(target, prop, _receiver) {
if (augmentedProps.has(prop)) {
return (...args) => target[prop](game.system.id, `|`, ...args);
};
return target[prop];
},
});