{"version":3,"file":"rxap-ngx-bootstrap.mjs","sources":["../../../../../packages/angular/bootstrap/src/lib/application.ts","../../../../../packages/angular/bootstrap/src/lib/module-application.ts","../../../../../packages/angular/bootstrap/src/lib/setup-dynamic-mfe.ts","../../../../../packages/angular/bootstrap/src/lib/standalone-application.ts","../../../../../packages/angular/bootstrap/src/index.ts","../../../../../packages/angular/bootstrap/src/rxap-ngx-bootstrap.ts"],"sourcesContent":["import { EnvironmentInjector } from '@angular/core';\nimport {\n  ConfigLoadOptions,\n  ConfigService,\n} from '@rxap/config';\nimport {\n  Environment,\n  UpdateEnvironment,\n} from '@rxap/environment';\nimport { NGXLogger } from 'ngx-logger';\n\n/**\n * @param ...args Arbitrary arguments\n */\nexport type ApplicationBeforeFunction<Config extends object> = (\n  config: ConfigService,\n  options: Config,\n) => any | Promise<any>;\n\n/**\n * The common interface of ApplicationRef and ModuleRef\n */\nexport interface RefWithInjector {\n  readonly injector: EnvironmentInjector;\n}\n\nexport type ApplicationAfterFunction<Ref extends RefWithInjector> = (\n  app: Ref,\n  config: ConfigService,\n  logger: NGXLogger,\n) => any | Promise<any>;\n\nexport abstract class Application<Config extends object, Ref extends RefWithInjector> {\n\n  public app: Ref | null = null;\n  public logger: NGXLogger | null = null;\n  public config: ConfigService | null = null;\n  private _beforeList: ApplicationBeforeFunction<Config>[] = [];\n  private _afterList: ApplicationAfterFunction<Ref>[] = [];\n\n  constructor(\n    public readonly environment: Environment,\n    public readonly options: Config = {} as any,\n    public readonly configLoadOptions?: ConfigLoadOptions,\n  ) {}\n\n  public async bootstrap() {\n\n    await this.prepareEnvironment(this.environment);\n\n    await this.loadConfig(this.environment);\n\n    this.prepareConfig(this.options);\n\n    await this.handleBefore(new ConfigService(ConfigService.Config), this.options);\n\n    try {\n      this.app = await this.create();\n    } catch (e: any) {\n      throw new Error(`Angular app creation failed: ${ e.message }`);\n    }\n\n    if (!this.app) {\n      throw new Error('Angular app creation failed');\n    }\n\n    this.logger = this.app.injector.get(NGXLogger);\n    this.config = this.app.injector.get(ConfigService);\n\n    if (!this.logger) {\n      throw new Error('Could not inject a NGXLogger instance');\n    }\n\n    if (!this.config) {\n      throw new Error('Could not inject a ConfigService instance');\n    }\n\n    await this.handleAfter(this.app, this.logger, this.config);\n\n  }\n\n  public before(fnc: ApplicationBeforeFunction<Config>) {\n    this._beforeList.push(fnc);\n  }\n\n  public after(fnc: ApplicationAfterFunction<Ref>) {\n    this._afterList.push(fnc);\n  }\n\n  protected async handleBefore(config: ConfigService, options: Config) {\n    for (const before of this._beforeList) {\n      await before(config, options);\n    }\n  }\n\n  protected async handleAfter(app: Ref, logger: NGXLogger, config: ConfigService) {\n    for (const after of this._afterList) {\n      await after(app, config, logger);\n    }\n  }\n\n  protected async loadConfig(environment: Environment) {\n    await ConfigService.Load(this.configLoadOptions, environment);\n  }\n\n  protected async prepareEnvironment(environment: Environment) {\n    await UpdateEnvironment(environment);\n  }\n\n  protected abstract prepareConfig(config: Config): void;\n\n  protected abstract create(): Promise<Ref>;\n\n}\n","import {\n  BootstrapOptions,\n  CompilerOptions,\n  NgModuleRef,\n  StaticProvider,\n  Type,\n} from '@angular/core';\nimport { platformBrowserDynamic } from '@angular/platform-browser-dynamic';\nimport { ConfigLoadOptions } from '@rxap/config';\nimport { Environment } from '@rxap/environment';\nimport { Application } from './application';\n\nexport interface ModuleApplicationConfig {\n  extraProviders?: StaticProvider[] | undefined;\n  compilerOptions?: (CompilerOptions & BootstrapOptions) | Array<CompilerOptions & BootstrapOptions>;\n}\n\nexport class ModuleApplication<M, O extends ModuleApplicationConfig> extends Application<O, NgModuleRef<M>> {\n\n  constructor(\n    environment: Environment,\n    private readonly moduleType: Type<M>,\n    options?: O,\n    configLoadOptions?: ConfigLoadOptions,\n  ) {\n    super(environment, options, configLoadOptions);\n  }\n\n  protected create(): Promise<NgModuleRef<M>> {\n    return platformBrowserDynamic(this.options.extraProviders)\n      .bootstrapModule(this.moduleType, this.options.compilerOptions);\n  }\n\n  protected override prepareConfig(config: O) {\n    config.extraProviders ??= [];\n    config.compilerOptions ??= [];\n  }\n\n}\n","import {\n  setRemoteDefinitions,\n  setRemoteUrlResolver,\n} from '@nx/angular/mf';\nimport type { Environment } from '@rxap/environment';\n\n/**\n * @deprecated It is not possible to use the `import` statement in the `main.ts` file. This results in a runtime error.\n * @param environment\n */\nexport async function SetupDynamicMfe(environment: Environment) {\n\n  const manifest = environment.moduleFederation?.manifest;\n\n  if (!manifest) {\n    const release = environment.tag || environment.branch || 'latest';\n    setRemoteUrlResolver((remoteName: string) => `${location.origin}/__mfe/${release}/${remoteName}`);\n  } else {\n\n    let definitions: Record<string, string>;\n\n    if (typeof manifest === 'object') {\n      definitions = manifest;\n    } else {\n      definitions = await fetch(manifest).then((res) => res.json());\n    }\n\n    setRemoteDefinitions(definitions);\n\n  }\n\n}\n","import {\n  ApplicationConfig,\n  ApplicationRef,\n  importProvidersFrom,\n  ImportProvidersSource,\n  Type,\n} from '@angular/core';\nimport { bootstrapApplication } from '@angular/platform-browser';\nimport { ConfigLoadOptions } from '@rxap/config';\nimport { Environment } from '@rxap/environment';\nimport { Application } from './application';\n\nexport class StandaloneApplication<O extends ApplicationConfig> extends Application<O, ApplicationRef> {\n\n  constructor(\n    environment: Environment,\n    private readonly rootComponent: Type<unknown>,\n    options?: O,\n    configLoadOptions: ConfigLoadOptions = {\n      url: `${ environment.origin ?? location.origin }/api/configuration/${ environment.tag ??\n      'latest' }/${ environment.app }`,\n    },\n  ) {\n    super(environment, options, configLoadOptions);\n  }\n\n  public importProvidersFrom(...sources: ImportProvidersSource[]) {\n    this.options.providers ??= [];\n    this.options.providers.push(importProvidersFrom(...sources));\n  }\n\n  protected create(): Promise<ApplicationRef> {\n    return bootstrapApplication(this.rootComponent, this.options);\n  }\n\n  protected override prepareConfig(config: O) {\n    config.providers ??= [];\n  }\n\n}\n","// region \nexport * from './lib/application';\nexport * from './lib/module-application';\nexport * from './lib/setup-dynamic-mfe';\nexport * from './lib/standalone-application';\n// endregion\n","/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