@molecule/app-angular 3.1.0 → 3.2.1

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
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-10-31T13:49:31.073Z
6
+ Generated: 2026-11-04T14:09:03.868Z
7
7
  -->
8
8
 
9
9
  # @molecule/app-angular
@@ -133,165 +133,65 @@ Provides login/logout/register flows, token management, profile
133
133
  updates, and auth state subscription.
134
134
 
135
135
  ```typescript
136
- interface AuthClient<T = UserProfile, TRegister extends RegisterExtraShape<TRegister> = Record<never, never>> {
137
- /**
138
- * Returns the current authentication state snapshot.
139
- *
140
- * READING the state starts the client's one session restore when nobody has called
141
- * {@link initialize} yet — lazily and exactly once, sharing the promise an explicit
142
- * `initialize()` returns. A hook (`useAuth()`), a subscriber, `isAuthenticated()` and
143
- * `getUser()` are reads too, so a client whose entry file dropped the template's
144
- * `authClient.initialize()` line still restores instead of reporting `'loading'`
145
- * forever.
146
- */
147
- getState(): AuthState<T>;
148
- /**
149
- * Returns whether the user is currently authenticated.
150
- */
151
- isAuthenticated(): boolean;
152
- /**
153
- * Gets the current user.
154
- */
155
- getUser(): T | null;
156
- /**
157
- * Optional ownership marker for the current session. Compare values only within
158
- * this client: replacing or ending a session changes it, including re-adopting
159
- * the same token and user. Profile updates and same-session refreshes keep it.
160
- * Consumers can use it to discard stale async work without treating editable
161
- * user fields as an immutable account identifier. Providers without this
162
- * capability require the consumer's own stable identity check.
163
- */
164
- getSessionRevision?(): number;
165
- /**
166
- * Updates the cached user object (state + persistent storage) without
167
- * hitting the network. Intended for local refreshes after a per-app
168
- * mutation (e.g., the user just PATCHed their own profile and the
169
- * server returned the canonical row). A non-null profile does NOT change
170
- * tokens or sign the client in: `authenticated` and `status` are unchanged,
171
- * so an anonymous client stays anonymous. Use {@link login} /
172
- * {@link register} for a credential exchange, or {@link setSession} when
173
- * the token was issued outside the client.
174
- *
175
- * Passing `null` on a signed-in client, or while any session operation is
176
- * pending, ends the local session: it clears the access token, refresh token
177
- * and cached user, stops automatic refresh, and settles `authenticated: false`
178
- * with `status: 'unauthenticated'` in one notification. Every older operation
179
- * loses session ownership, and a persistent sign-out marker prevents a reload
180
- * from restoring its credentials or a late cookie. A late credential exchange
181
- * is revoked best-effort when a logout endpoint is configured, without blocking
182
- * the caller. This method does not otherwise call the server for a settled
183
- * session; use {@link logout} for explicit server revocation. On a settled
184
- * anonymous client, `null` only clears the cached profile and leaves tokens
185
- * and auth state unchanged.
186
- */
187
- setUser(user: T | null): void;
188
- /**
189
- * Gets the current access token.
190
- */
191
- getAccessToken(): string | null;
192
- /**
193
- * Stores the access token in the configured token storage adapter (in a
194
- * browser, Web Storage; `'memory'` where no browser store exists). Use this
195
- * to seed the token after an out-of-band exchange (e.g. the OAuth
196
- * code→token redirect) instead of writing to `localStorage` directly,
197
- * which would violate the storage contract and make a stored bearer token
198
- * JS-readable (XSS-exfiltratable). Pass `null` to clear it.
199
- *
200
- * This changes token storage only: passing `null` does not by itself sign a
201
- * signed-in client out, and a non-null token does not sign an anonymous
202
- * client in (`authenticated` and `status` are unchanged). Use {@link logout}
203
- * to end a session, or {@link setUser} with `null` for local-only sign-out.
204
- * Use {@link login} / {@link register} for a credential exchange, or call
205
- * {@link setSession} with the token and user to establish an already-issued
206
- * session.
207
- */
208
- setAccessToken(token: string | null): void;
209
- /**
210
- * Adopts a session an out-of-band exchange already established: stores the
211
- * access token (and the refresh token when given), caches the user, and
212
- * sets the COMPLETE state — `initialized`, `authenticated`, `status:
213
- * 'authenticated'`, no error — in one update, with one subscriber
214
- * notification. Every hook reading the shared client sees the user as
215
- * signed in immediately.
216
- *
217
- * This is the way to seed an OAuth/custom sign-in. Calling
218
- * {@link setAccessToken} and {@link setUser} instead does NOT sign the
219
- * client in.
220
- */
221
- setSession(session: AuthSessionSeed<T>): void;
222
- /**
223
- * Gets the refresh token.
224
- */
225
- getRefreshToken(): string | null;
226
- /**
227
- * Logs in with credentials.
228
- */
229
- login(credentials: LoginCredentials): Promise<AuthResult<T>>;
230
- /**
231
- * Logs out the current user. The server request is best-effort: a missing
232
- * logout route (404), any other HTTP failure, or a network error never makes
233
- * this method reject. It always clears the access token, refresh token and
234
- * cached user, stops automatic refresh, and publishes one settled
235
- * `authenticated: false`, `status: 'unauthenticated'` transition. Every pending
236
- * session operation loses ownership; a persistent marker prevents reload from
237
- * restoring an older session, and late credentials are revoked best-effort.
238
- *
239
- * When the API has no logout route, set {@link AuthClientConfigOptions.logoutEndpoint}
240
- * to `null` (or `''`) to skip the request. Local sign-out still happens.
241
- */
242
- logout(): Promise<void>;
243
- /**
244
- * Registers a new user. Accepts the base fields plus the app's own fields
245
- * (`TRegister`) at the top level — see {@link RegisterData}.
246
- */
247
- register(data: RegisterData<TRegister>): Promise<AuthResult<T>>;
248
- /**
249
- * Refreshes the access token.
250
- */
251
- refresh(): Promise<AuthResult<T>>;
252
- /**
253
- * Requests a password reset.
254
- */
255
- requestPasswordReset(data: PasswordResetRequest): Promise<void>;
256
- /**
257
- * Confirms a password reset.
258
- */
259
- confirmPasswordReset(data: PasswordResetConfirm): Promise<void>;
260
- /**
261
- * Updates the current user's profile.
262
- * Returns the saved profile: the answer applied onto the signed-in user field
263
- * by field, with or without an `id` — a field it carries replaces the value
264
- * (`null` clears it), one it omits or leaves `undefined` is kept, so a field
265
- * cleared by omission must arrive as `null`. A non-object answer is returned
266
- * as it came. An answer for a replaced or ended session leaves the current one
267
- * untouched.
268
- */
269
- updateProfile(data: Partial<T>): Promise<T>;
270
- /**
271
- * Changes the current user's password.
272
- */
273
- changePassword(oldPassword: string, newPassword: string): Promise<void>;
274
- /**
275
- * Initializes auth state (e.g., from stored tokens).
276
- *
277
- * LAZY and IDEMPOTENT: the first read of the state ({@link getState},
278
- * {@link subscribe}, `useAuth()`) starts this same restore when nobody has called
279
- * `initialize()`, and every later call shares the one promise instead of sending a
280
- * second request. An app that keeps the template's explicit call behaves exactly as
281
- * before; an app that loses that line still restores its session.
282
- *
283
- * With a stored token AND a stored user it marks the session `'authenticated'`
284
- * SYNCHRONOUSLY — before its first `await` — so the first render is the
285
- * signed-in UI and no page waits on a verification round trip. Any check
286
- * (a refresh, the cookie-restore probe) settles behind that render, and only an
287
- * explicit 401/403 ends the session; a network/5xx/404 failure keeps it and
288
- * reports `'unavailable'`. With no stored user the client stays `'loading'`
289
- * until the cookie restore decides.
290
- *
291
- * Do not put this call (or a `/me` request of your own) in front of the first
292
- // … truncated — the full declaration is in node_modules/@molecule/app-angular/dist
136
+ interface AuthClient<
137
+ T = UserProfile,
138
+ TRegister extends RegisterExtraShape<TRegister> = Record<never, never>,
139
+ > {
140
+ /** Returns the current authentication state snapshot. */
141
+ getState(): AuthState<T>
142
+ /** Returns whether the user is currently authenticated. */
143
+ isAuthenticated(): boolean
144
+ /** Gets the current user. */
145
+ getUser(): T | null
146
+ /** Optional ownership marker for the current session. */
147
+ getSessionRevision?(): number
148
+ /** Updates the cached user object (state + persistent storage) without hitting the network. */
149
+ setUser(user: T | null): void
150
+ /** Gets the current access token. */
151
+ getAccessToken(): string | null
152
+ /** Stores the access token in the configured token storage adapter (in a browser, Web Storage; `'memory'` where no browser store exists). */
153
+ setAccessToken(token: string | null): void
154
+ /** Adopts a session an out-of-band exchange already established: stores the access token (and the refresh token when given), caches the user, and sets the COMPLET… */
155
+ setSession(session: AuthSessionSeed<T>): void
156
+ /** Gets the refresh token. */
157
+ getRefreshToken(): string | null
158
+ /** Logs in with credentials. */
159
+ login(credentials: LoginCredentials): Promise<AuthResult<T>>
160
+ /** Logs out the current user. */
161
+ logout(): Promise<void>
162
+ /** Registers a new user. */
163
+ register(data: RegisterData<TRegister>): Promise<AuthResult<T>>
164
+ /** Refreshes the access token. */
165
+ refresh(): Promise<AuthResult<T>>
166
+ /** Requests a password reset. */
167
+ requestPasswordReset(data: PasswordResetRequest): Promise<void>
168
+ /** Confirms a password reset. */
169
+ confirmPasswordReset(data: PasswordResetConfirm): Promise<void>
170
+ /** Updates the current user's profile. */
171
+ updateProfile(data: Partial<T>): Promise<T>
172
+ /** Changes the current user's password. */
173
+ changePassword(oldPassword: string, newPassword: string): Promise<void>
174
+ /** Initializes auth state (e.g., from stored tokens). */
175
+ initialize(): Promise<void>
176
+ /** Re-checks a restored session against the server, in the background — the boot-time validation an app with a stored token needs when a revoked or expired token… */
177
+ validateSession?(): Promise<void>
178
+ /** Resolves when the session restore started by `initialize()` has settled — the point after which the client knows whether this visitor is signed in. */
179
+ whenRestored?(): Promise<void>
180
+ /** Subscribes to auth state changes. */
181
+ subscribe(callback: (state: AuthState<T>) => void): () => void
182
+ /** Subscribes to auth state changes (alias for subscribe). */
183
+ onAuthChange(callback: (state: AuthState<T>) => void): () => void
184
+ /** Gets the current access token (alias for getAccessToken). */
185
+ getToken?(): string | null
186
+ /** Adds an auth event listener. */
187
+ addEventListener(listener: AuthEventListener<T>): () => void
188
+ /** Destroys the auth client. */
189
+ destroy(): void
190
+ }
293
191
  ```
294
192
 
193
+ _(Member comments are shortened to their first sentence to fit; the full declaration is in `node_modules/@molecule/app-angular/dist`.)_
194
+
295
195
  #### `FormController`
296
196
 
297
197
  Form controller interface.
@@ -1463,6 +1363,18 @@ Configuration for molecule Angular module.
1463
1363
  interface MoleculeModuleConfig {
1464
1364
  state?: StateProvider
1465
1365
  auth?: AuthClient<unknown>
1366
+ /**
1367
+ * Hold bootstrap (and so every page's first render) until `auth` has decided the
1368
+ * session. After a full page load a returning visitor's session is restored by one
1369
+ * request, and until it answers `MoleculeAuthService.user` is `null` everywhere — a
1370
+ * public page's signed-in action (`if (!user) return`, a redirect to `/login`) then
1371
+ * treats a signed-in visitor as signed out. With this set, Angular's app initializer
1372
+ * waits only while status is `'loading'`, so a cached session can render while its
1373
+ * verification continues in the background. `'unavailable'` also renders and may have a
1374
+ * null user. Without a session hint, an anonymous visitor settles in microtasks without
1375
+ * a request. Ignored without `auth`.
1376
+ */
1377
+ awaitSession?: boolean
1466
1378
  theme?: ThemeProvider
1467
1379
  router?: Router
1468
1380
  i18n?: I18nProvider
@@ -1 +1 @@
1
- {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAY,MAAM,eAAe,CAAA;AAGnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAC1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAaxD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAEtD;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,aAAa,GAAG,oBAAoB,CAE1E;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,oBAAoB,CAE1E;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,aAAa,GAAG,oBAAoB,CAE1E;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,CAElE;AAED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AAU,CAAC,CAAC,CAAC,GAAG,oBAAoB,CAE1E;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,aAAa,GAAG,oBAAoB,CAE1E;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,CAElE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,YAAY,GAAG,oBAAoB,CAExE;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,oBAAoB,CAEpE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,eAAe,GAAG,oBAAoB,CAE9E;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,cAAc,GAAG,oBAAoB,CAE5E;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,oBAAoB,GAAG,oBAAoB,CAsElF"}
package/dist/providers.js CHANGED
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @module
5
5
  */
6
- import { ENVIRONMENT_INITIALIZER, makeEnvironmentProviders } from '@angular/core';
6
+ import { ENVIRONMENT_INITIALIZER, makeEnvironmentProviders, provideAppInitializer, } from '@angular/core';
7
7
  import { bumpLocaleVersion } from './i18n-reactive.js';
8
8
  import { AUTH_CLIENT, HTTP_CLIENT, I18N_PROVIDER, LOGGER_PROVIDER, ROUTER, STATE_PROVIDER, STORAGE_PROVIDER, THEME_PROVIDER, } from './tokens.js';
9
9
  /**
@@ -139,6 +139,35 @@ export function provideMolecule(config) {
139
139
  if (config.logger) {
140
140
  providers.push({ provide: LOGGER_PROVIDER, useValue: config.logger });
141
141
  }
142
+ if (config.awaitSession && config.auth) {
143
+ const client = config.auth;
144
+ providers.push(
145
+ // The idiomatic hold: Angular creates no component (so no page renders) until
146
+ // app initializers settle.
147
+ provideAppInitializer(() => {
148
+ // Start or join the one restore. A stored user can already be decided
149
+ // while initialize()/whenRestored() still verify it in the background.
150
+ const joined = client.initialize().catch((_error) => {
151
+ // The client's status represents restore failure (including timeout).
152
+ // Bootstrap renders 'unavailable' rather than rejecting on that failure.
153
+ });
154
+ if (client.getState().status !== 'loading')
155
+ return;
156
+ let unsubscribe;
157
+ const ready = new Promise((resolve) => {
158
+ const check = () => {
159
+ if (client.getState().status !== 'loading')
160
+ resolve();
161
+ };
162
+ unsubscribe = client.onAuthChange(check);
163
+ // Close the read/subscribe gap and include clients that settle only
164
+ // their initialization promise rather than emitting a final change.
165
+ check();
166
+ void joined.then(check);
167
+ });
168
+ return ready.finally(() => unsubscribe?.());
169
+ }));
170
+ }
142
171
  return makeEnvironmentProviders(providers);
143
172
  }
144
173
  //# sourceMappingURL=providers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"providers.js","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA;AAWjF,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EACL,WAAW,EACX,WAAW,EACX,aAAa,EACb,eAAe,EACf,MAAM,EACN,cAAc,EACd,gBAAgB,EAChB,cAAc,GACf,MAAM,aAAa,CAAA;AAGpB;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,QAAuB;IAClD,OAAO,wBAAwB,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAA;AACpF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAI,MAAqB;IAClD,OAAO,wBAAwB,CAAC,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;AAC/E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,QAAu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QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAA;IACvE,CAAC;IACD,IAAI,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;QACvC,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAA;QAC1B,SAAS,CAAC,IAAI;QACZ,8EAA8E;QAC9E,2BAA2B;QAC3B,qBAAqB,CAAC,GAAG,EAAE;YACzB,sEAAsE;YACtE,uEAAuE;YACvE,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,MAAe,EAAE,EAAE;gBAC3D,sEAAsE;gBACtE,yEAAyE;YAC3E,CAAC,CAAC,CAAA;YACF,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC,MAAM,KAAK,SAAS;gBAAE,OAAM;YAElD,IAAI,WAAqC,CAAA;YACzC,MAAM,KAAK,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE;gBAC1C,MAAM,KAAK,GAAG,GAAS,EAAE;oBACvB,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC,MAAM,KAAK,SAAS;wBAAE,OAAO,EAAE,CAAA;gBACvD,CAAC,CAAA;gBACD,WAAW,GAAG,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;gBACxC,oEAAoE;gBACpE,oEAAoE;gBACpE,KAAK,EAAE,CAAA;gBACP,KAAK,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;YACzB,CAAC,CAAC,CAAA;YACF,OAAO,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;QAC7C,CAAC,CAAC,CACH,CAAA;IACH,CAAC;IAED,OAAO,wBAAwB,CAAC,SAAS,CAAC,CAAA;AAC5C,CAAC"}
package/dist/types.d.ts CHANGED
@@ -18,6 +18,18 @@ import type { Theme, ThemeProvider } from '@molecule/app-theme';
18
18
  export interface MoleculeModuleConfig {
19
19
  state?: StateProvider;
20
20
  auth?: AuthClient<unknown>;
21
+ /**
22
+ * Hold bootstrap (and so every page's first render) until `auth` has decided the
23
+ * session. After a full page load a returning visitor's session is restored by one
24
+ * request, and until it answers `MoleculeAuthService.user` is `null` everywhere — a
25
+ * public page's signed-in action (`if (!user) return`, a redirect to `/login`) then
26
+ * treats a signed-in visitor as signed out. With this set, Angular's app initializer
27
+ * waits only while status is `'loading'`, so a cached session can render while its
28
+ * verification continues in the background. `'unavailable'` also renders and may have a
29
+ * null user. Without a session hint, an anonymous visitor settles in microtasks without
30
+ * a request. Ignored without `auth`.
31
+ */
32
+ awaitSession?: boolean;
21
33
  theme?: ThemeProvider;
22
34
  router?: Router;
23
35
  i18n?: I18nProvider;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC5F,OAAO,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAC5E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAA;AAC5D,OAAO,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAE/D;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,KAAK,CAAC,EA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name": "@molecule/app-angular",
3
- "version": "3.1.0",
3
+ "version": "3.2.1",
4
4
  "description": "Angular framework bindings for molecule.dev",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",