capacitor-community / electron

Deploy your Capacitor apps to Linux, Mac, and Windows desktops, with the Electron platform! 🖥️
https://capacitor-community.github.io/electron/
MIT License
319 stars 58 forks source link

Expose config to plugins #168

Closed jdgjsag67251 closed 2 years ago

jdgjsag67251 commented 2 years ago

In order for a plugin to replicate the App.getLaunchUrl function for Electron it needs to have access to the config. This pull-request adds the config to the constructor of a plugin. It can access it like so:

export default class App {
  private config?: Record<string, any>;

  constructor(config?: Record<string, any>) {
    this.config = config;
  }

  getLaunchUrl(): string | undefined {
    const url = this.config?.server?.url;

    return url ? { url } : undefined;
  }
}