Skip to content

Consider allowing registering a wrapper on any object #96

Description

@LukeAbby

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:

  1. 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.
  2. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions