web-manager 4.1.40 → 4.1.42

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/CHANGELOG.md CHANGED
@@ -14,6 +14,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
14
14
  - `Fixed` for any bug fixes.
15
15
  - `Security` in case of vulnerabilities.
16
16
 
17
+ ---
18
+ ## [4.1.42] - 2026-05-11
19
+ ### Changed
20
+ - **Firebase config: presence-driven + flat shape canonical.** Firebase now initializes when a `firebaseConfig` blob is present in config (matching BEM/BXM/EM/OMEGA shape) — no separate `firebase.app.enabled` flag needed. Removes the `enabled` redundancy where consumers had to set both a credentials blob AND flip a flag.
21
+ - New internal helper `_resolveFirebaseConfig()` reads flat `config.firebaseConfig` first (canonical), falls back to nested `config.firebase.app.config` (UJM legacy yaml). Used by `_initializeFirebase`, `getFunctionsUrl`, `getApiUrl`, `service-worker.js`, and `auth.js#listen` (Firebase-not-configured short-circuit).
22
+ - `_initializeFirebase` now reuses an existing `[DEFAULT]` Firebase app if present (via `getApps()` / `getApp()`) instead of throwing `app/duplicate-app` on re-init (live reload, test re-runs).
23
+ - No backwards-compat shim needed for UJM: both shapes resolve. UJM can migrate to the flat `firebaseConfig` shape on its own schedule; until then, its `firebase.app.config` keeps working.
24
+
25
+ ---
26
+ ## [4.1.41] - 2026-05-10
27
+ ### Changed
28
+ - Bumped dependencies: `@sentry/browser` ^10.47.0 → ^10.52.0, `firebase` ^12.11.0 → ^12.13.0, `prepare-package` ^2.0.7 → ^2.1.0.
29
+ - Added empty `hooks: {}` to `preparePackage` config to align with prepare-package 2.1.0 schema.
30
+
17
31
  ---
18
32
  ## [4.1.40] - 2026-05-10
19
33
  ### Changed
package/dist/index.js CHANGED
@@ -95,8 +95,11 @@ class Manager {
95
95
  // Set platform and runtime on HTML element
96
96
  this._setHtmlDataAttributes();
97
97
 
98
- // Initialize Firebase if enabled
99
- if (this.config.firebase?.app?.enabled) {
98
+ // Initialize Firebase if a config blob is present (presence-driven — matches BEM
99
+ // convention). Reads flat `firebaseConfig` (BEM/BXM/EM canonical shape) and falls
100
+ // back to nested `firebase.app.config` (UJM's current `_config.yml` shape).
101
+ // Once UJM migrates to the flat shape this fallback can be dropped.
102
+ if (this._resolveFirebaseConfig()) {
100
103
  await this._initializeFirebase();
101
104
  }
102
105
 
@@ -389,8 +392,23 @@ class Manager {
389
392
  $html.dataset.device = this._utilities.getDevice();
390
393
  }
391
394
 
395
+ // Resolve the Firebase web SDK config blob. Flat `firebaseConfig` first (canonical
396
+ // shape — BEM/BXM/EM), then nested `firebase.app.config` (UJM legacy yaml shape).
397
+ // Returns the blob when it has at least one own key, otherwise null.
398
+ _resolveFirebaseConfig() {
399
+ const flat = this.config.firebaseConfig;
400
+ if (flat && typeof flat === 'object' && Object.keys(flat).length > 0) {
401
+ return flat;
402
+ }
403
+ const nested = this.config.firebase?.app?.config;
404
+ if (nested && typeof nested === 'object' && Object.keys(nested).length > 0) {
405
+ return nested;
406
+ }
407
+ return null;
408
+ }
409
+
392
410
  async _initializeFirebase() {
393
- const firebaseConfig = this.config.firebase.app.config;
411
+ const firebaseConfig = this._resolveFirebaseConfig();
394
412
 
395
413
  // Dynamically import Firebase v12
396
414
  const { initializeApp } = await import('firebase/app');
@@ -403,8 +421,11 @@ class Manager {
403
421
  // firebaseConfig.authDomain = window.location.hostname;
404
422
  // }
405
423
 
406
- // Initialize Firebase
407
- const app = initializeApp(firebaseConfig);
424
+ // Initialize Firebase. Re-init guards: if there's already a [DEFAULT] app
425
+ // (live reload, re-init in tests), get the existing one rather than throwing
426
+ // `app/duplicate-app`.
427
+ const { getApp, getApps } = await import('firebase/app');
428
+ const app = getApps().length > 0 ? getApp() : initializeApp(firebaseConfig);
408
429
 
409
430
  // Store Firebase references
410
431
  this._firebaseApp = app;
@@ -463,7 +484,7 @@ class Manager {
463
484
 
464
485
  getFunctionsUrl(environment) {
465
486
  const env = environment || this.config.environment;
466
- const projectId = this.config.firebase?.app?.config?.projectId;
487
+ const projectId = this._resolveFirebaseConfig()?.projectId;
467
488
 
468
489
  if (!projectId) {
469
490
  throw new Error('Firebase project ID not configured');
@@ -488,7 +509,7 @@ class Manager {
488
509
  return 'http://localhost:5002';
489
510
  }
490
511
 
491
- const apiDomain = this.config.firebase.app.config.authDomain; // Has to be this since some projects like Clockii use ITW Universal Auth
512
+ const apiDomain = this._resolveFirebaseConfig()?.authDomain; // Has to be this since some projects like Clockii use ITW Universal Auth
492
513
  // const apiDomain = this.config.brand.url;
493
514
  const baseUrl = url || (apiDomain ? `https://${apiDomain}` : window.location.origin);
494
515
  const urlObj = new URL(baseUrl);
@@ -133,8 +133,8 @@ class Auth {
133
133
  options = {};
134
134
  }
135
135
 
136
- // If Firebase is not enabled, call callback immediately with null
137
- if (!this.manager.config.firebase?.app?.enabled) {
136
+ // If Firebase isn't configured (no firebaseConfig blob), call callback immediately with null.
137
+ if (!this.manager._resolveFirebaseConfig()) {
138
138
  callback({
139
139
  user: null,
140
140
  account: resolveAccount({}, {}),
@@ -42,7 +42,7 @@ class ServiceWorker {
42
42
  brand: this.manager.config.brand?.id,
43
43
  environment: this.manager.config.environment,
44
44
  buildTime: this.manager.config.buildTime,
45
- firebase: this.manager.config.firebase?.app?.config || null
45
+ firebase: this.manager._resolveFirebaseConfig()
46
46
  };
47
47
 
48
48
  // Register service worker
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "4.1.40",
3
+ "version": "4.1.42",
4
4
  "description": "Easily access important variables such as the query string, current domain, and current page in a single object.",
5
5
  "main": "dist/index.js",
6
6
  "module": "src/index.js",
@@ -36,20 +36,21 @@
36
36
  "input": "./src",
37
37
  "output": "./dist",
38
38
  "replace": {},
39
- "type": "copy"
39
+ "type": "copy",
40
+ "hooks": {}
40
41
  },
41
42
  "notes": {
42
43
  "@sentry/browser": "Resolved by using OVERRIDES in web-manager (lighthouse is the issue"
43
44
  },
44
45
  "dependencies": {
45
- "@sentry/browser": "^10.47.0",
46
+ "@sentry/browser": "^10.52.0",
46
47
  "chatsy": "^2.0.14",
47
- "firebase": "^12.11.0",
48
+ "firebase": "^12.13.0",
48
49
  "itwcw-package-analytics": "^1.0.8",
49
50
  "lodash": "^4.18.1"
50
51
  },
51
52
  "devDependencies": {
52
53
  "mocha": "^11.7.5",
53
- "prepare-package": "^2.0.7"
54
+ "prepare-package": "^2.1.0"
54
55
  }
55
56
  }