// SPDX-FileCopyrightText: 2021 Johannes Loher // // SPDX-License-Identifier: MIT import { packageName } from '../config'; import registerHandlebarsPartials from '../handlebars-partials'; import logger from '../logger'; import registerSettings from '../setiings'; import { libWrapper } from '../shims/libWrapperShim'; import { getBrightRadius, getDimRadius, updateVisionSource } from '../wrappers/token'; export default function registerForInitHook() { Hooks.on('init', onInit); } async 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.brightRadius'; try { libWrapper.register(packageName, brightRadiusTarget, getBrightRadius, 'OVERRIDE'); } catch (e) { logger.warn(`Failed to override ${brightRadiusTarget}, some things might not work correctly:`, e); } const updateVisionSourceTarget = 'Token.prototype.updateVisionSource'; try { libWrapper.register(packageName, updateVisionSourceTarget, updateVisionSource, 'OVERRIDE'); } catch (e) { logger.warn(`Failed to override ${updateVisionSourceTarget}, some things might not work correctly:`, e); } registerSettings(); await registerHandlebarsPartials(); }