web-manager 4.3.4 → 4.3.5
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/dist/index.js +13 -4
- package/docs/architecture.md +7 -0
- package/package.json +1 -1
- package/src/index.js +13 -4
package/dist/index.js
CHANGED
|
@@ -99,7 +99,10 @@ class Manager {
|
|
|
99
99
|
// convention). Reads flat `firebaseConfig` (BEM/BXM/EM canonical shape) and falls
|
|
100
100
|
// back to nested `firebase.app.config` (UJM's current `_config.yml` shape).
|
|
101
101
|
// Once UJM migrates to the flat shape this fallback can be dropped.
|
|
102
|
-
|
|
102
|
+
// Initialize Firebase only when the resolved config can actually boot the
|
|
103
|
+
// SDK — apiKey is mandatory (init without one crashes with auth/invalid-api-key).
|
|
104
|
+
// Configs carrying only projectId/authDomain still resolve for URL derivation.
|
|
105
|
+
if (this._resolveFirebaseConfig()?.apiKey) {
|
|
103
106
|
await this._initializeFirebase();
|
|
104
107
|
}
|
|
105
108
|
|
|
@@ -394,14 +397,20 @@ class Manager {
|
|
|
394
397
|
|
|
395
398
|
// Resolve the Firebase web SDK config blob. Flat `firebaseConfig` first (canonical
|
|
396
399
|
// shape — BEM/BXM/EM), then nested `firebase.app.config` (UJM legacy yaml shape).
|
|
397
|
-
//
|
|
400
|
+
// A blob only counts when at least one value is non-empty — framework config merges
|
|
401
|
+
// (e.g. UJM's Jekyll chain) inject all-empty-string blobs into Firebase-less sites,
|
|
402
|
+
// and those must resolve to null (no init, no URL derivation).
|
|
398
403
|
_resolveFirebaseConfig() {
|
|
404
|
+
const hasValues = (blob) => !!blob
|
|
405
|
+
&& typeof blob === 'object'
|
|
406
|
+
&& Object.values(blob).some((value) => value);
|
|
407
|
+
|
|
399
408
|
const flat = this.config.firebaseConfig;
|
|
400
|
-
if (
|
|
409
|
+
if (hasValues(flat)) {
|
|
401
410
|
return flat;
|
|
402
411
|
}
|
|
403
412
|
const nested = this.config.firebase?.app?.config;
|
|
404
|
-
if (
|
|
413
|
+
if (hasValues(nested)) {
|
|
405
414
|
return nested;
|
|
406
415
|
}
|
|
407
416
|
return null;
|
package/docs/architecture.md
CHANGED
|
@@ -50,3 +50,10 @@ Manager (index.js)
|
|
|
50
50
|
├── DOM utilities (standalone)
|
|
51
51
|
└── Utilities (standalone)
|
|
52
52
|
```
|
|
53
|
+
|
|
54
|
+
## Firebase Initialization
|
|
55
|
+
|
|
56
|
+
`initialize(config)` boots Firebase only when a usable web SDK config resolves:
|
|
57
|
+
|
|
58
|
+
- `_resolveFirebaseConfig()` checks the flat `firebaseConfig` blob first (canonical shape — BEM/BXM/EM), then the nested `firebase.app.config` (UJM yaml shape). A blob only counts when **at least one value is non-empty** — framework config merges (e.g. UJM's Jekyll chain) inject all-empty-string blobs into Firebase-less sites, and those resolve to `null` (no init, no URL derivation).
|
|
59
|
+
- Initialization additionally requires a **non-empty `apiKey`** — the SDK cannot boot without one (it crashes the page with `auth/invalid-api-key`). Configs carrying only `projectId`/`authDomain` still resolve so `getFunctionsUrl()`/`getApiUrl()` can derive URLs, but Firebase itself stays uninitialized.
|
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -99,7 +99,10 @@ class Manager {
|
|
|
99
99
|
// convention). Reads flat `firebaseConfig` (BEM/BXM/EM canonical shape) and falls
|
|
100
100
|
// back to nested `firebase.app.config` (UJM's current `_config.yml` shape).
|
|
101
101
|
// Once UJM migrates to the flat shape this fallback can be dropped.
|
|
102
|
-
|
|
102
|
+
// Initialize Firebase only when the resolved config can actually boot the
|
|
103
|
+
// SDK — apiKey is mandatory (init without one crashes with auth/invalid-api-key).
|
|
104
|
+
// Configs carrying only projectId/authDomain still resolve for URL derivation.
|
|
105
|
+
if (this._resolveFirebaseConfig()?.apiKey) {
|
|
103
106
|
await this._initializeFirebase();
|
|
104
107
|
}
|
|
105
108
|
|
|
@@ -394,14 +397,20 @@ class Manager {
|
|
|
394
397
|
|
|
395
398
|
// Resolve the Firebase web SDK config blob. Flat `firebaseConfig` first (canonical
|
|
396
399
|
// shape — BEM/BXM/EM), then nested `firebase.app.config` (UJM legacy yaml shape).
|
|
397
|
-
//
|
|
400
|
+
// A blob only counts when at least one value is non-empty — framework config merges
|
|
401
|
+
// (e.g. UJM's Jekyll chain) inject all-empty-string blobs into Firebase-less sites,
|
|
402
|
+
// and those must resolve to null (no init, no URL derivation).
|
|
398
403
|
_resolveFirebaseConfig() {
|
|
404
|
+
const hasValues = (blob) => !!blob
|
|
405
|
+
&& typeof blob === 'object'
|
|
406
|
+
&& Object.values(blob).some((value) => value);
|
|
407
|
+
|
|
399
408
|
const flat = this.config.firebaseConfig;
|
|
400
|
-
if (
|
|
409
|
+
if (hasValues(flat)) {
|
|
401
410
|
return flat;
|
|
402
411
|
}
|
|
403
412
|
const nested = this.config.firebase?.app?.config;
|
|
404
|
-
if (
|
|
413
|
+
if (hasValues(nested)) {
|
|
405
414
|
return nested;
|
|
406
415
|
}
|
|
407
416
|
return null;
|