How to use the @firebase/component.ComponentType.PUBLIC function in @firebase/component

To help you get started, we’ve selected a few @firebase/component examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github firebase / firebase-js-sdk / packages / storage / index.ts View on Github external
export function registerStorage(instance: _FirebaseNamespace): void {
  const namespaceExports = {
    // no-inline
    TaskState,
    TaskEvent,
    StringFormat,
    Storage: Service,
    Reference
  };
  instance.INTERNAL.registerComponent(
    new Component(STORAGE_TYPE, factory, ComponentType.PUBLIC)
      .setServiceProps(namespaceExports)
      .setMultipleInstances(true)
  );

  instance.registerVersion(name, version);
}
github firebase / firebase-js-sdk / packages / performance / index.ts View on Github external
// Register performance with firebase-app.
  (instance as _FirebaseNamespace).INTERNAL.registerComponent(
    new Component(
      'performance',
      container => {
        /* Dependencies */
        // getImmediate for FirebaseApp will always succeed
        const app = container.getProvider('app').getImmediate();
        // The following call will always succeed because perf has `import '@firebase/installations'`
        const installations = container
          .getProvider('installations')
          .getImmediate();

        return factoryMethod(app, installations);
      },
      ComponentType.PUBLIC
    )
  );

  instance.registerVersion(name, version);
}
github firebase / firebase-js-sdk / packages / messaging / index.ts View on Github external
return new SwController(firebaseServices);
    } else {
      // Assume we are in the window context.
      return new WindowController(firebaseServices);
    }
  };

  const namespaceExports = {
    isSupported
  };

  instance.INTERNAL.registerComponent(
    new Component(
      messagingName,
      factoryMethod,
      ComponentType.PUBLIC
    ).setServiceProps(namespaceExports)
  );

  instance.registerVersion(name, version);
}
github firebase / firebase-js-sdk / packages / app / src / firebaseApp.ts View on Github external
constructor(
    options: FirebaseOptions,
    config: FirebaseAppConfig,
    private readonly firebase_: _FirebaseNamespace
  ) {
    this.name_ = config.name!;
    this.automaticDataCollectionEnabled_ =
      config.automaticDataCollectionEnabled || false;
    this.options_ = deepCopy(options);
    this.container = new ComponentContainer(config.name!);

    // add itself to container
    this._addComponent(new Component('app', () => this, ComponentType.PUBLIC));
    this._addComponent(
      new Component(
        'platform-logger',
        container => new PlatformLoggerService(container),
        ComponentType.PRIVATE
      )
    );
    this._addComponent(
      new Component(
        'app-version',
        () => new VersionService('app', version),
        ComponentType.VERSION
      )
    );
    this._addComponent(
      new Component(
github firebase / firebase-js-sdk / packages / remote-config / index.ts View on Github external
export function registerRemoteConfig(
  firebaseInstance: _FirebaseNamespace
): void {
  firebaseInstance.INTERNAL.registerComponent(
    new Component(
      'remoteConfig',
      remoteConfigFactory,
      ComponentType.PUBLIC
    ).setMultipleInstances(true)
  );

  firebaseInstance.registerVersion(packageName, version);

  function remoteConfigFactory(
    container: ComponentContainer,
    namespace?: string
  ): RemoteConfig {
    /* Dependencies */
    // getImmediate for FirebaseApp will always succeed
    const app = container.getProvider('app').getImmediate();
    // The following call will always succeed because rc has `import '@firebase/installations'`
    const installations = container.getProvider('installations').getImmediate();

    // Guards against the SDK being used in non-browser environments.
github firebase / firebase-js-sdk / packages / database / index.ts View on Github external
const namespace = (instance as _FirebaseNamespace).INTERNAL.registerComponent(
    new Component(
      'database',
      (container, url) => {
        /* Dependencies */
        // getImmediate for FirebaseApp will always succeed
        const app = container.getProvider('app').getImmediate();
        const authProvider = container.getProvider('auth-internal');

        return RepoManager.getInstance().databaseFromApp(
          app,
          authProvider,
          url
        );
      },
      ComponentType.PUBLIC
    )
      .setServiceProps(
        // firebase.database namespace properties
        {
          Reference,
          Query,
          Database,
          DataSnapshot,
          enableLogging,
          INTERNAL,
          ServerValue,
          TEST_ACCESS
        }
      )
      .setMultipleInstances(true)
  );
github firebase / firebase-js-sdk / packages / installations / src / index.ts View on Github external
const appConfig = extractAppConfig(app);
        const platformLoggerProvider = container.getProvider('platform-logger');
        const dependencies: FirebaseDependencies = {
          appConfig,
          platformLoggerProvider
        };

        return {
          app,
          getId: () => getId(dependencies),
          getToken: (forceRefresh?: boolean) =>
            getToken(dependencies, forceRefresh),
          delete: () => deleteInstallation(dependencies)
        };
      },
      ComponentType.PUBLIC
    )
  );

  instance.registerVersion(name, version);
}

@firebase/component

Firebase Component Platform

Apache-2.0
Latest version published 14 days ago

Package Health Score

95 / 100
Full package analysis

Similar packages