@nardole/firebase-core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # @nardole/firebase-core
2
+
3
+ A tiny, framework-agnostic wrapper to initialize a single Firebase App once and reuse it everywhere — React, Node, plain JS, or Micro‑Frontends.
4
+
5
+ [![npm version](https://img.shields.io/npm/v/%40nardole%2Ffirebase-core.svg?logo=npm)](https://www.npmjs.com/package/@nardole/firebase-core)
6
+ ![types](https://img.shields.io/badge/types-TypeScript-blue?logo=typescript)
7
+ [![license: MIT](https://img.shields.io/badge/license-MIT-green.svg)](#license)
8
+ [![firebase](https://img.shields.io/badge/firebase-%5E12-orange?logo=firebase)](https://firebase.google.com/)
9
+
10
+ - Why
11
+ - Features
12
+ - Installation
13
+ - Quick Start
14
+ - Usage (Vanilla)
15
+ - Micro‑Frontend (MFE)
16
+ - TypeScript
17
+ - API
18
+ - Compatibility
19
+ - FAQ
20
+ - License
21
+
22
+ ## Why
23
+ Firebase initialization is often duplicated across apps and MFEs. This package centralizes it behind a shared singleton to avoid multiple initializations in the same page/process.
24
+
25
+ ## Features
26
+ - Single entry point to initialize Firebase with FirebaseOptions and optional app name
27
+ - Stable, typed access to the current FirebaseApp instance
28
+ - Explicit errors if used before initialization
29
+ - Works with or without React — ideal for MFE architectures
30
+
31
+ ## Installation
32
+ - pnpm add @nardole/firebase-core firebase
33
+ - npm install @nardole/firebase-core firebase
34
+ - yarn add @nardole/firebase-core firebase
35
+
36
+ ## Quick Start
37
+ 1. Grab your Firebase config from the Console.
38
+ 2. Initialize once during app bootstrap.
39
+ 3. Consume the shared instance from any module.
40
+
41
+ ## Usage (Vanilla)
42
+ ```ts
43
+ import { firebaseService } from '@nardole/firebase-core';
44
+
45
+ firebaseService.init({
46
+ apiKey: 'YOUR_API_KEY',
47
+ authDomain: 'YOUR_AUTH_DOMAIN',
48
+ projectId: 'YOUR_PROJECT_ID',
49
+ appId: 'YOUR_APP_ID',
50
+ });
51
+
52
+ // Later in any module/file (even outside React)
53
+ const app = firebaseService.app;
54
+ ```
55
+
56
+ ## Micro‑Frontend (MFE)
57
+ Initialize in the shell (or any federated module) and reuse in other MFEs. Prevents duplicate initialization and keeps state consistent.
58
+ ```ts
59
+ // shell
60
+ import { firebaseService } from '@nardole/firebase-core';
61
+ firebaseService.init({ /* options */ });
62
+
63
+ // any mfe
64
+ import { firebaseService } from '@nardole/firebase-core';
65
+ const app = firebaseService.app;
66
+ ```
67
+
68
+ ## TypeScript
69
+ - First‑class support. Import types from `firebase/app` as usual.
70
+
71
+ ## API
72
+
73
+ | Item | Signature | Parameters | Returns | Errors/Notes |
74
+ | --- | --- | --- | --- | --- |
75
+ | initialize | firebaseService.init(options: FirebaseOptions, name?: string, override?: boolean): void | - options: FirebaseOptions (required) <br> - name: string (optional) <br> - override: boolean (optional) | void | Initializes the app. If an app already exists and `override` is not true, throws "Firebase app already initialized". |
76
+ | current app | firebaseService.app | — | FirebaseApp | Getter. If not initialized, throws "Firebase app not initialized". |
77
+ | analytics | firebaseService.analytics | — | Analytics | Lazy getter; creates Analytics tied to the current app on first access. |
78
+ | performance | firebaseService.performance | — | FirebasePerformance | Lazy getter; creates Performance tied to the current app on first access. |
79
+ | remote config | firebaseService.remoteConfig | — | RemoteConfig | Lazy getter; creates Remote Config for the current app on first access. |
80
+ | storage | firebaseService.storage | — | FirebaseStorage | Lazy getter; creates Storage for the current app on first access. |
81
+ | auth | firebaseService.auth | — | Auth | Lazy getter; creates Auth for the current app on first access. |
82
+ | database | firebaseService.database | — | Database | Lazy getter; creates Realtime Database for the current app on first access. |
83
+ | firestore | firebaseService.firestore | — | Firestore | Lazy getter; creates Firestore for the current app on first access. |
84
+
85
+ ## Compatibility
86
+ - Peer: firebase ^12
87
+ - Runtime: Node 16+ or modern browsers
88
+
89
+ ## FAQ
90
+ - Q: Can I call init more than once?
91
+ - A: Repeated calls without `override` will throw for safety. In controlled scenarios (e.g., the React Provider), the package may call `init(..., ..., true)` to overwrite.
92
+ - Q: Can I use it without React?
93
+ - A: Yes. The package is framework‑agnostic.
94
+
95
+ ## License
96
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1,80 @@
1
+ 'use strict';
2
+
3
+ var app = require('firebase/app');
4
+ var analytics = require('firebase/analytics');
5
+ var performance = require('firebase/performance');
6
+ var storage = require('firebase/storage');
7
+ var remoteConfig = require('firebase/remote-config');
8
+ var auth = require('firebase/auth');
9
+ var database = require('firebase/database');
10
+ var firestore = require('firebase/firestore');
11
+
12
+ // src/index.ts
13
+ var FirebaseAppCore = class _FirebaseAppCore {
14
+ constructor() {
15
+ if (!_FirebaseAppCore.instance) {
16
+ _FirebaseAppCore.instance = this;
17
+ }
18
+ return _FirebaseAppCore.instance;
19
+ }
20
+ init(options, name, override) {
21
+ if (!this._app || override) {
22
+ this._app = app.initializeApp(options, name);
23
+ return;
24
+ }
25
+ throw new Error("Firebase app already initialized");
26
+ }
27
+ get app() {
28
+ if (!this._app) {
29
+ throw new Error("Firebase app not initialized");
30
+ }
31
+ return this._app;
32
+ }
33
+ get analytics() {
34
+ if (!this._analytics) {
35
+ this._analytics = analytics.getAnalytics(this.app);
36
+ }
37
+ return this._analytics;
38
+ }
39
+ get performance() {
40
+ if (!this._performance) {
41
+ this._performance = performance.getPerformance(this.app);
42
+ }
43
+ return this._performance;
44
+ }
45
+ get remoteConfig() {
46
+ if (!this._remoteConfig) {
47
+ this._remoteConfig = remoteConfig.getRemoteConfig(this.app);
48
+ }
49
+ return this._remoteConfig;
50
+ }
51
+ get storage() {
52
+ if (!this._storage) {
53
+ this._storage = storage.getStorage(this.app);
54
+ }
55
+ return this._storage;
56
+ }
57
+ get auth() {
58
+ if (!this._auth) {
59
+ this._auth = auth.getAuth(this.app);
60
+ }
61
+ return this._auth;
62
+ }
63
+ get database() {
64
+ if (!this._database) {
65
+ this._database = database.getDatabase(this.app);
66
+ }
67
+ return this._database;
68
+ }
69
+ get firestore() {
70
+ if (!this._firestore) {
71
+ this._firestore = firestore.getFirestore(this.app);
72
+ }
73
+ return this._firestore;
74
+ }
75
+ };
76
+ var firebaseService = new FirebaseAppCore();
77
+
78
+ exports.firebaseService = firebaseService;
79
+ //# sourceMappingURL=index.cjs.map
80
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":["initializeApp","getAnalytics","getPerformance","getRemoteConfig","getStorage","getAuth","getDatabase","getFirestore"],"mappings":";;;;;;;;;;;;AASA,IAAM,eAAA,GAAN,MAAM,gBAAA,CAAgB;AAAA,EAWpB,WAAA,GAAc;AACZ,IAAA,IAAI,CAAC,iBAAgB,QAAA,EAAU;AAC7B,MAAA,gBAAA,CAAgB,QAAA,GAAW,IAAA;AAAA,IAC7B;AAEA,IAAA,OAAO,gBAAA,CAAgB,QAAA;AAAA,EACzB;AAAA,EAEA,IAAA,CAAK,OAAA,EAA0B,IAAA,EAAe,QAAA,EAAoB;AAChE,IAAA,IAAI,CAAC,IAAA,CAAK,IAAA,IAAQ,QAAA,EAAU;AAC1B,MAAA,IAAA,CAAK,IAAA,GAAOA,iBAAA,CAAc,OAAA,EAAS,IAAI,CAAA;AACvC,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,IAAI,MAAM,kCAAkC,CAAA;AAAA,EACpD;AAAA,EAEA,IAAI,GAAA,GAAM;AACR,IAAA,IAAI,CAAC,KAAK,IAAA,EAAM;AACd,MAAA,MAAM,IAAI,MAAM,8BAA8B,CAAA;AAAA,IAChD;AAEA,IAAA,OAAO,IAAA,CAAK,IAAA;AAAA,EACd;AAAA,EAEA,IAAI,SAAA,GAAY;AACd,IAAA,IAAI,CAAC,KAAK,UAAA,EAAY;AACpB,MAAA,IAAA,CAAK,UAAA,GAAaC,sBAAA,CAAa,IAAA,CAAK,GAAG,CAAA;AAAA,IACzC;AAEA,IAAA,OAAO,IAAA,CAAK,UAAA;AAAA,EACd;AAAA,EAEA,IAAI,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O,IAAM,eAAA,GAAkB,IAAI,eAAA","file":"index.cjs","sourcesContent":["import { FirebaseApp, FirebaseOptions, initializeApp } from \"firebase/app\";\nimport { Analytics, getAnalytics } from \"firebase/analytics\";\nimport { FirebasePerformance, getPerformance } from \"firebase/performance\";\nimport { FirebaseStorage, getStorage } from \"firebase/storage\";\nimport { RemoteConfig, getRemoteConfig } from \"firebase/remote-config\";\nimport { Auth, getAuth } from \"firebase/auth\";\nimport { Database, getDatabase } from \"firebase/database\";\nimport { Firestore, getFirestore } from \"firebase/firestore\";\n\nclass FirebaseAppCore {\n static instance: FirebaseAppCore;\n private _app?: FirebaseApp;\n private _analytics?: Analytics;\n private _performance?: FirebasePerformance;\n private _remoteConfig?: RemoteConfig;\n private _storage?: FirebaseStorage;\n private _auth?: Auth;\n private _database?: Database;\n private _firestore?: Firestore;\n\n constructor() {\n if (!FirebaseAppCore.instance) {\n FirebaseAppCore.instance = this;\n }\n\n return FirebaseAppCore.instance;\n }\n\n init(options: FirebaseOptions, name?: string, override?: boolean) {\n if (!this._app || override) {\n this._app = initializeApp(options, name);\n return;\n }\n\n throw new Error(\"Firebase app already initialized\");\n }\n\n get app() {\n if (!this._app) {\n throw new Error(\"Firebase app not initialized\");\n }\n\n return this._app;\n }\n\n get analytics() {\n if (!this._analytics) {\n this._analytics = getAnalytics(this.app);\n }\n\n return this._analytics;\n }\n\n get performance() {\n if (!this._performance) {\n this._performance = getPerformance(this.app);\n }\n\n return this._performance;\n }\n\n get remoteConfig() {\n if (!this._remoteConfig) {\n this._remoteConfig = getRemoteConfig(this.app);\n }\n\n return this._remoteConfig;\n }\n\n get storage() {\n if (!this._storage) {\n this._storage = getStorage(this.app);\n }\n\n return this._storage;\n }\n\n get auth() {\n if (!this._auth) {\n this._auth = getAuth(this.app);\n }\n\n return this._auth;\n }\n\n get database() {\n if (!this._database) {\n this._database = getDatabase(this.app);\n }\n\n return this._database;\n }\n\n get firestore() {\n if (!this._firestore) {\n this._firestore = getFirestore(this.app);\n }\n\n return this._firestore;\n }\n}\n\nexport const firebaseService = new FirebaseAppCore();\n"]}
@@ -0,0 +1,33 @@
1
+ import { FirebaseOptions, FirebaseApp } from 'firebase/app';
2
+ import { Analytics } from 'firebase/analytics';
3
+ import { FirebasePerformance } from 'firebase/performance';
4
+ import { FirebaseStorage } from 'firebase/storage';
5
+ import { RemoteConfig } from 'firebase/remote-config';
6
+ import { Auth } from 'firebase/auth';
7
+ import { Database } from 'firebase/database';
8
+ import { Firestore } from 'firebase/firestore';
9
+
10
+ declare class FirebaseAppCore {
11
+ static instance: FirebaseAppCore;
12
+ private _app?;
13
+ private _analytics?;
14
+ private _performance?;
15
+ private _remoteConfig?;
16
+ private _storage?;
17
+ private _auth?;
18
+ private _database?;
19
+ private _firestore?;
20
+ constructor();
21
+ init(options: FirebaseOptions, name?: string, override?: boolean): void;
22
+ get app(): FirebaseApp;
23
+ get analytics(): Analytics;
24
+ get performance(): FirebasePerformance;
25
+ get remoteConfig(): RemoteConfig;
26
+ get storage(): FirebaseStorage;
27
+ get auth(): Auth;
28
+ get database(): Database;
29
+ get firestore(): Firestore;
30
+ }
31
+ declare const firebaseService: FirebaseAppCore;
32
+
33
+ export { firebaseService };
@@ -0,0 +1,33 @@
1
+ import { FirebaseOptions, FirebaseApp } from 'firebase/app';
2
+ import { Analytics } from 'firebase/analytics';
3
+ import { FirebasePerformance } from 'firebase/performance';
4
+ import { FirebaseStorage } from 'firebase/storage';
5
+ import { RemoteConfig } from 'firebase/remote-config';
6
+ import { Auth } from 'firebase/auth';
7
+ import { Database } from 'firebase/database';
8
+ import { Firestore } from 'firebase/firestore';
9
+
10
+ declare class FirebaseAppCore {
11
+ static instance: FirebaseAppCore;
12
+ private _app?;
13
+ private _analytics?;
14
+ private _performance?;
15
+ private _remoteConfig?;
16
+ private _storage?;
17
+ private _auth?;
18
+ private _database?;
19
+ private _firestore?;
20
+ constructor();
21
+ init(options: FirebaseOptions, name?: string, override?: boolean): void;
22
+ get app(): FirebaseApp;
23
+ get analytics(): Analytics;
24
+ get performance(): FirebasePerformance;
25
+ get remoteConfig(): RemoteConfig;
26
+ get storage(): FirebaseStorage;
27
+ get auth(): Auth;
28
+ get database(): Database;
29
+ get firestore(): Firestore;
30
+ }
31
+ declare const firebaseService: FirebaseAppCore;
32
+
33
+ export { firebaseService };
package/dist/index.js ADDED
@@ -0,0 +1,78 @@
1
+ import { initializeApp } from 'firebase/app';
2
+ import { getAnalytics } from 'firebase/analytics';
3
+ import { getPerformance } from 'firebase/performance';
4
+ import { getStorage } from 'firebase/storage';
5
+ import { getRemoteConfig } from 'firebase/remote-config';
6
+ import { getAuth } from 'firebase/auth';
7
+ import { getDatabase } from 'firebase/database';
8
+ import { getFirestore } from 'firebase/firestore';
9
+
10
+ // src/index.ts
11
+ var FirebaseAppCore = class _FirebaseAppCore {
12
+ constructor() {
13
+ if (!_FirebaseAppCore.instance) {
14
+ _FirebaseAppCore.instance = this;
15
+ }
16
+ return _FirebaseAppCore.instance;
17
+ }
18
+ init(options, name, override) {
19
+ if (!this._app || override) {
20
+ this._app = initializeApp(options, name);
21
+ return;
22
+ }
23
+ throw new Error("Firebase app already initialized");
24
+ }
25
+ get app() {
26
+ if (!this._app) {
27
+ throw new Error("Firebase app not initialized");
28
+ }
29
+ return this._app;
30
+ }
31
+ get analytics() {
32
+ if (!this._analytics) {
33
+ this._analytics = getAnalytics(this.app);
34
+ }
35
+ return this._analytics;
36
+ }
37
+ get performance() {
38
+ if (!this._performance) {
39
+ this._performance = getPerformance(this.app);
40
+ }
41
+ return this._performance;
42
+ }
43
+ get remoteConfig() {
44
+ if (!this._remoteConfig) {
45
+ this._remoteConfig = getRemoteConfig(this.app);
46
+ }
47
+ return this._remoteConfig;
48
+ }
49
+ get storage() {
50
+ if (!this._storage) {
51
+ this._storage = getStorage(this.app);
52
+ }
53
+ return this._storage;
54
+ }
55
+ get auth() {
56
+ if (!this._auth) {
57
+ this._auth = getAuth(this.app);
58
+ }
59
+ return this._auth;
60
+ }
61
+ get database() {
62
+ if (!this._database) {
63
+ this._database = getDatabase(this.app);
64
+ }
65
+ return this._database;
66
+ }
67
+ get firestore() {
68
+ if (!this._firestore) {
69
+ this._firestore = getFirestore(this.app);
70
+ }
71
+ return this._firestore;
72
+ }
73
+ };
74
+ var firebaseService = new FirebaseAppCore();
75
+
76
+ export { firebaseService };
77
+ //# sourceMappingURL=index.js.map
78
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;AASA,IAAM,eAAA,GAAN,MAAM,gBAAA,CAAgB;AAAA,EAWpB,WAAA,GAAc;AACZ,IAAA,IAAI,CAAC,iBAAgB,QAAA,EAAU;AAC7B,MAAA,gBAAA,CAAgB,QAAA,GAAW,IAAA;AAAA,IAC7B;AAEA,IAAA,OAAO,gBAAA,CAAgB,QAAA;AAAA,EACzB;AAAA,EAEA,IAAA,CAAK,OAAA,EAA0B,IAAA,EAAe,QAAA,EAAoB;AAChE,IAAA,IAAI,CAAC,IAAA,CAAK,IAAA,IAAQ,QAAA,EAAU;AAC1B,MAAA,IAAA,CAAK,IAAA,GAAO,aAAA,CAAc,OAAA,EAAS,IAAI,CAAA;AACvC,MAAA;AAAA,IACF;AAEA,IAAA,MAAM,IAAI,MAAM,kCAAkC,CAAA;AAAA,EACpD;AAAA,EAEA,IAAI,GAAA,GAAM;AACR,IAAA,IAAI,CAAC,KAAK,IAAA,EAAM;AACd,MAAA,MAAM,IAAI,MAAM,8BAA8B,CAAA;AAAA,IAChD;AAEA,IAAA,OAAO,IAAA,CAAK,IAAA;AAAA,EACd;AAAA,EAEA,IAAI,SAAA,GAAY;AACd,IAAA,IAAI,CAAC,KAAK,UAAA,EAAY;AACpB,MAAA,IAAA,CAAK,UAAA,GAAa,YAAA,CAAa,IAAA,CAAK,GAAG,CAAA;AAAA,IACzC;AAEA,IAAA,OAAO,IAAA,CAAK,UAAA;AAAA,EACd;AAAA,EAEA,IAAI,WAAA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AkB,IAAI,eAAA","file":"index.js","sourcesContent":["import { FirebaseApp, FirebaseOptions, initializeApp } from \"firebase/app\";\nimport { Analytics, getAnalytics } from \"firebase/analytics\";\nimport { FirebasePerformance, getPerformance } from \"firebase/performance\";\nimport { FirebaseStorage, getStorage } from \"firebase/storage\";\nimport { RemoteConfig, getRemoteConfig } from \"firebase/remote-config\";\nimport { Auth, getAuth } from \"firebase/auth\";\nimport { Database, getDatabase } from \"firebase/database\";\nimport { Firestore, getFirestore } from \"firebase/firestore\";\n\nclass FirebaseAppCore {\n static instance: FirebaseAppCore;\n private _app?: FirebaseApp;\n private _analytics?: Analytics;\n private _performance?: FirebasePerformance;\n private _remoteConfig?: RemoteConfig;\n private _storage?: FirebaseStorage;\n private _auth?: Auth;\n private _database?: Database;\n private _firestore?: Firestore;\n\n constructor() {\n if (!FirebaseAppCore.instance) {\n FirebaseAppCore.instance = this;\n }\n\n return FirebaseAppCore.instance;\n }\n\n init(options: FirebaseOptions, name?: string, override?: boolean) {\n if (!this._app || override) {\n this._app = initializeApp(options, name);\n return;\n }\n\n throw new Error(\"Firebase app already initialized\");\n }\n\n get app() {\n if (!this._app) {\n throw new Error(\"Firebase app not initialized\");\n }\n\n return this._app;\n }\n\n get analytics() {\n if (!this._analytics) {\n this._analytics = getAnalytics(this.app);\n }\n\n return this._analytics;\n }\n\n get performance() {\n if (!this._performance) {\n this._performance = getPerformance(this.app);\n }\n\n return this._performance;\n }\n\n get remoteConfig() {\n if (!this._remoteConfig) {\n this._remoteConfig = getRemoteConfig(this.app);\n }\n\n return this._remoteConfig;\n }\n\n get storage() {\n if (!this._storage) {\n this._storage = getStorage(this.app);\n }\n\n return this._storage;\n }\n\n get auth() {\n if (!this._auth) {\n this._auth = getAuth(this.app);\n }\n\n return this._auth;\n }\n\n get database() {\n if (!this._database) {\n this._database = getDatabase(this.app);\n }\n\n return this._database;\n }\n\n get firestore() {\n if (!this._firestore) {\n this._firestore = getFirestore(this.app);\n }\n\n return this._firestore;\n }\n}\n\nexport const firebaseService = new FirebaseAppCore();\n"]}
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@nardole/firebase-core",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "author": {
9
+ "name": "Luiz Braga",
10
+ "email": "me@nardole.dev"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "https://github.com/btmluiz/nardole-firebase",
15
+ "directory": "packages/core"
16
+ },
17
+ "exports": {
18
+ ".": {
19
+ "types": "./dist/index.d.ts",
20
+ "default": "./dist/index.js"
21
+ }
22
+ },
23
+ "devDependencies": {
24
+ "firebase": "^12.2.1",
25
+ "tsup": "^8.5.0",
26
+ "typescript": "^5.9.2"
27
+ },
28
+ "peerDependencies": {
29
+ "firebase": "^12.2.1"
30
+ },
31
+ "scripts": {
32
+ "build": "tsup",
33
+ "typecheck": "tsc"
34
+ },
35
+ "license": "MIT",
36
+ "keywords": [
37
+ "firebase",
38
+ "firebase-core",
39
+ "typescript",
40
+ "singleton",
41
+ "analytics",
42
+ "performance",
43
+ "remote-config",
44
+ "storage",
45
+ "auth",
46
+ "database",
47
+ "firestore",
48
+ "micro-frontend",
49
+ "mfe"
50
+ ],
51
+ "files": [
52
+ "dist",
53
+ "README.md",
54
+ "LICENSE*"
55
+ ]
56
+ }