web-manager 4.0.1 → 4.0.3

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 CHANGED
@@ -270,10 +270,10 @@ Web Manager includes a powerful data binding system that automatically updates y
270
270
  #### Basic Text Binding
271
271
  ```html
272
272
  <!-- Display user email -->
273
- <span data-wm-bind="user.email"></span>
273
+ <span data-wm-bind="auth.user.email"></span>
274
274
 
275
275
  <!-- Display nested properties -->
276
- <div data-wm-bind="account.subscription.plan"></div>
276
+ <div data-wm-bind="auth.account.subscription.plan"></div>
277
277
 
278
278
  <!-- Works with inputs too -->
279
279
  <input data-wm-bind="settings.theme" />
@@ -282,14 +282,14 @@ Web Manager includes a powerful data binding system that automatically updates y
282
282
  #### Conditional Visibility
283
283
  ```html
284
284
  <!-- Show element when condition is true -->
285
- <div data-wm-bind="@show user">Welcome!</div>
286
- <div data-wm-bind="@show user.emailVerified">Email is verified</div>
285
+ <div data-wm-bind="@show auth.user">Welcome!</div>
286
+ <div data-wm-bind="@show auth.user.emailVerified">Email is verified</div>
287
287
 
288
288
  <!-- Hide element when condition is true -->
289
- <div data-wm-bind="@hide user">Please log in</div>
289
+ <div data-wm-bind="@hide auth.user">Please log in</div>
290
290
 
291
291
  <!-- Comparisons -->
292
- <div data-wm-bind="@show subscription.plan === 'premium'">Premium features</div>
292
+ <div data-wm-bind="@show auth.account.subscription.plan === 'premium'">Premium features</div>
293
293
  <div data-wm-bind="@hide settings.notifications === false">Notifications enabled</div>
294
294
  ```
295
295
 
@@ -297,7 +297,7 @@ Web Manager includes a powerful data binding system that automatically updates y
297
297
  ```javascript
298
298
  // Auth data is automatically bound when using auth().listen()
299
299
  Manager.auth().listen({ account: true }, (result) => {
300
- // user and account data are automatically bound to the DOM
300
+ // auth.user and auth.account data are automatically bound to the DOM
301
301
  });
302
302
 
303
303
  // Update bindings with custom data
@@ -5,7 +5,7 @@ class Auth {
5
5
  this.manager = manager;
6
6
  this._authStateCallbacks = [];
7
7
  this._readyCallbacks = [];
8
- this._hasUpdatedBindings = false;
8
+ this._hasProcessedStateChange = false;
9
9
  }
10
10
 
11
11
  // Check if user is authenticated
@@ -100,19 +100,18 @@ class Auth {
100
100
  // Always ensure account is at least a default resolved object
101
101
  state.account = state.account || resolveAccount({}, { uid: user?.uid });
102
102
 
103
- // Update bindings with auth data (only once across all callbacks)
104
- // Now ONLY the first listener will update bindings until the next auth state change
105
- if (!this._hasUpdatedBindings) {
106
- // Run update
107
- this.manager.bindings().update(state);
103
+ // Process state change (update bindings and storage) only once across all callbacks
104
+ // Now ONLY the first listener will process the state change until the next auth state change
105
+ if (!this._hasProcessedStateChange) {
106
+ // Run update - nest state under 'auth' key for consistent access
107
+ this.manager.bindings().update({ auth: state });
108
108
 
109
109
  // Save to storage
110
110
  const storage = this.manager.storage();
111
- storage.set('user.auth', state.user || null);
112
- storage.set('user.account', state.account || {});
111
+ storage.set('auth', state);
113
112
 
114
- // Mark that we've updated bindings
115
- this._hasUpdatedBindings = true;
113
+ // Mark that we've processed this state change
114
+ this._hasProcessedStateChange = true;
116
115
  }
117
116
 
118
117
  // Call the provided callback with the state
@@ -165,8 +164,8 @@ class Auth {
165
164
 
166
165
  // Internal method to handle auth state changes
167
166
  _handleAuthStateChange(user) {
168
- // Reset bindings flag for new auth state
169
- this._hasUpdatedBindings = false;
167
+ // Reset state processing flag for new auth state
168
+ this._hasProcessedStateChange = false;
170
169
 
171
170
  // Call all registered callbacks
172
171
  this._authStateCallbacks.forEach(callback => {
@@ -121,7 +121,7 @@ class Bindings {
121
121
  _evaluateCondition(condition, context) {
122
122
  try {
123
123
  // Replace context references with actual values
124
- // Support: user.field, account.field, simple comparisons
124
+ // Support: auth.user.field, auth.account.field, simple comparisons
125
125
 
126
126
  // Check for negation operator at the start
127
127
  if (condition.trim().startsWith('!')) {
@@ -169,7 +169,7 @@ class Bindings {
169
169
  default: return false;
170
170
  }
171
171
  } else {
172
- // Simple truthy check (e.g., "user.emailVerified" or "account")
172
+ // Simple truthy check (e.g., "auth.user.emailVerified" or "auth.account")
173
173
  const value = this._resolvePath(context, condition.trim());
174
174
  return !!value;
175
175
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
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",
@@ -27,21 +27,13 @@
27
27
  "url": "https://github.com/itw-creative-works/web-manager/issues"
28
28
  },
29
29
  "homepage": "https://itwcreativeworks.com",
30
- "backup": {
31
- "dependencies": {
32
- "@sentry/browser": "^6.19.7",
33
- "cookieconsent": "^3.1.1",
34
- "firebase": "^8.10.1",
35
- "lazysizes": "^5.3.2"
36
- }
37
- },
38
30
  "preparePackage": {
39
31
  "input": "./src",
40
32
  "output": "./dist",
41
33
  "replace": {}
42
34
  },
43
35
  "dependencies": {
44
- "@sentry/browser": "^10.15.0",
36
+ "@sentry/browser": "10.8.0",
45
37
  "firebase": "^12.3.0",
46
38
  "itwcw-package-analytics": "^1.0.6",
47
39
  "lodash": "^4.17.21",