33 lines
1 KiB
JavaScript
33 lines
1 KiB
JavaScript
|
// SPDX-FileCopyrightText: 2021 Johannes Loher
|
||
|
//
|
||
|
// SPDX-License-Identifier: MIT
|
||
|
|
||
|
import { packageName } from '../config';
|
||
|
import logger from '../logger';
|
||
|
import { libWrapper } from '../shims/libWrapperShim';
|
||
|
import { getBrightRadius, getDimRadius, updateSource } from '../wrappers/token';
|
||
|
|
||
|
export default function registerForInitHook() {
|
||
|
Hooks.on('init', onInit);
|
||
|
}
|
||
|
|
||
|
function onInit() {
|
||
|
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);
|
||
|
}
|
||
|
|
||
|
const brightRadiusTarget = 'Token.prototype.dimRadius';
|
||
|
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');
|
||
|
}
|