2021-06-29 20:40:54 +02:00
|
|
|
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
|
|
|
|
import { packageName } from '../config';
|
2021-07-13 13:59:11 +02:00
|
|
|
import registerHandlebarsPartials from '../handlebars-partials';
|
2021-06-29 20:40:54 +02:00
|
|
|
import logger from '../logger';
|
2021-07-13 13:59:11 +02:00
|
|
|
import registerSettings from '../setiings';
|
2021-06-29 20:40:54 +02:00
|
|
|
import { libWrapper } from '../shims/libWrapperShim';
|
|
|
|
import { getBrightRadius, getDimRadius, updateSource } from '../wrappers/token';
|
|
|
|
|
|
|
|
export default function registerForInitHook() {
|
|
|
|
Hooks.on('init', onInit);
|
|
|
|
}
|
|
|
|
|
2021-07-13 13:59:11 +02:00
|
|
|
async function onInit() {
|
2021-06-29 20:40:54 +02:00
|
|
|
logger.info(`Initializing ${packageName}`);
|
|
|
|
|
|
|
|
const dimRadiusTarget = 'Token.prototype.dimRadius';
|
|
|
|
try {
|
|
|
|
libWrapper.register(packageName, dimRadiusTarget, getDimRadius, 'OVERRIDE');
|
|
|
|
} catch (e) {
|
|
|
|
logger.warn(`Failed to override ${dimRadiusTarget}, some things might not work correctly:`, e);
|
|
|
|
}
|
|
|
|
|
2021-06-29 22:12:03 +02:00
|
|
|
const brightRadiusTarget = 'Token.prototype.brightRadius';
|
2021-06-29 20:40:54 +02:00
|
|
|
try {
|
|
|
|
libWrapper.register(packageName, brightRadiusTarget, getBrightRadius, 'OVERRIDE');
|
|
|
|
} catch (e) {
|
|
|
|
logger.warn(`Failed to override ${brightRadiusTarget}, some things might not work correctly:`, e);
|
|
|
|
}
|
|
|
|
|
|
|
|
libWrapper.register(packageName, 'Token.prototype.updateSource', updateSource, 'WRAPPER');
|
2021-07-13 13:59:11 +02:00
|
|
|
|
|
|
|
registerSettings();
|
|
|
|
await registerHandlebarsPartials();
|
2021-06-29 20:40:54 +02:00
|
|
|
}
|