Is your feature request related to a problem, e.g. with a module? Please describe.
lib-wrapper currently assumes that what you're wrapping can be found in the global scope. This can be a problem for two reasons:
- The reason I'm actually filing this issue for which is that it makes TypeScript types a bit clunkier. One quirk of TypeScript is that
typeof globalThis doesn't intrinsically include all globals and so GetProperty<typeof globalThis, "some-key"> is difficult to make work nicely.
- In general I've seen some annoyance that it can be difficult to patch non-global objects or objects with special characters. lib-wrapper does have a "DSL" mentioned in the documentation to make this somewhat more possible like
"CONFIG.Actor.sheetClasses.character["dnd5e.ActorSheet5eCharacter"].cls.prototype._onLongRest" (scare quotes over "DSL" since it really is meant to be as close to 1:1 to JS as reasonable) but this isn't an entirely perfect solution.
Describe the solution you'd like
It would be nice to be able to do something like this:
const api = game.settings.get("other-package").api;
libWrapper.register("some-package", { target: api, key: "some-method" }, fn, type, options);
Describe alternatives you've considered
Continue allowing only the current calls of register. The fact that only globals can be overriden may be an intentional design decision of lib-wrapper.
Additional context
N/A
Is your feature request related to a problem, e.g. with a module? Please describe.
lib-wrapper currently assumes that what you're wrapping can be found in the global scope. This can be a problem for two reasons:
typeof globalThisdoesn't intrinsically include all globals and soGetProperty<typeof globalThis, "some-key">is difficult to make work nicely."CONFIG.Actor.sheetClasses.character["dnd5e.ActorSheet5eCharacter"].cls.prototype._onLongRest"(scare quotes over "DSL" since it really is meant to be as close to 1:1 to JS as reasonable) but this isn't an entirely perfect solution.Describe the solution you'd like
It would be nice to be able to do something like this:
Describe alternatives you've considered
Continue allowing only the current calls of
register. The fact that only globals can be overriden may be an intentional design decision of lib-wrapper.Additional context
N/A