Skip to content

Support iOS polyfills #773

@KVSRoyal

Description

@KVSRoyal

Is your feature request related to a problem? Please describe.

I am frustrated when I need to add polyfills for iOS JSBasePlugins. I would like to be able to add the polyfills through a plugin just for that. However, such a plugin would be just a NativePlugin and not a JSBasePlugin. So it would be applied after the JSBasePlugins are loaded. Which means the polyfills would not exist in some contexts when I expect them to. #772 is an example of this and goes into more detail. Even if I apply such a plugin before the JSBasePlugins, player will load it after them.

For example, if I had a class ConsolePolyfillPlugin: NativePlugin that provided console.log, this is how it would work right now:

export class ReproPlugin {
  name = 'repro';

  constructor() {
    console.log('I will NOT be logged');
  }

  apply(player: Player) {
    console.log('I will NOT be logged')

    player.hooks.view.tap(this.name, () => {
      console.log('I will be logged')
    });

    console.log('I will NOT be logged')
  }

  func foo() {
    console.log('I MAY be logged depending on where I am called from.')
  }
}

Describe the solution you'd like

I would like to be able to add a plugin that applies polyfills, like setInterval or console.log, and have it actually be applied in the order I expect it to and the polyfills exist reliably.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions