@molecule/app-angular 1.0.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.
Files changed (110) hide show
  1. package/LICENSE +115 -0
  2. package/dist/i18n-reactive.d.ts +41 -0
  3. package/dist/i18n-reactive.d.ts.map +1 -0
  4. package/dist/i18n-reactive.js +46 -0
  5. package/dist/i18n-reactive.js.map +1 -0
  6. package/dist/index.d.ts +84 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +84 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/providers.d.ts +96 -0
  11. package/dist/providers.d.ts.map +1 -0
  12. package/dist/providers.js +144 -0
  13. package/dist/providers.js.map +1 -0
  14. package/dist/services/async-state.service.d.ts +50 -0
  15. package/dist/services/async-state.service.d.ts.map +1 -0
  16. package/dist/services/async-state.service.js +109 -0
  17. package/dist/services/async-state.service.js.map +1 -0
  18. package/dist/services/auth.service.d.ts +105 -0
  19. package/dist/services/auth.service.d.ts.map +1 -0
  20. package/dist/services/auth.service.js +124 -0
  21. package/dist/services/auth.service.js.map +1 -0
  22. package/dist/services/capacitor-app.service.d.ts +46 -0
  23. package/dist/services/capacitor-app.service.d.ts.map +1 -0
  24. package/dist/services/capacitor-app.service.js +53 -0
  25. package/dist/services/capacitor-app.service.js.map +1 -0
  26. package/dist/services/change-password.service.d.ts +37 -0
  27. package/dist/services/change-password.service.d.ts.map +1 -0
  28. package/dist/services/change-password.service.js +34 -0
  29. package/dist/services/change-password.service.js.map +1 -0
  30. package/dist/services/device.service.d.ts +35 -0
  31. package/dist/services/device.service.d.ts.map +1 -0
  32. package/dist/services/device.service.js +29 -0
  33. package/dist/services/device.service.js.map +1 -0
  34. package/dist/services/forms.service.d.ts +237 -0
  35. package/dist/services/forms.service.d.ts.map +1 -0
  36. package/dist/services/forms.service.js +280 -0
  37. package/dist/services/forms.service.js.map +1 -0
  38. package/dist/services/http.service.d.ts +118 -0
  39. package/dist/services/http.service.d.ts.map +1 -0
  40. package/dist/services/http.service.js +171 -0
  41. package/dist/services/http.service.js.map +1 -0
  42. package/dist/services/i18n.service.d.ts +111 -0
  43. package/dist/services/i18n.service.d.ts.map +1 -0
  44. package/dist/services/i18n.service.js +135 -0
  45. package/dist/services/i18n.service.js.map +1 -0
  46. package/dist/services/index.d.ts +27 -0
  47. package/dist/services/index.d.ts.map +1 -0
  48. package/dist/services/index.js +27 -0
  49. package/dist/services/index.js.map +1 -0
  50. package/dist/services/logger.service.d.ts +79 -0
  51. package/dist/services/logger.service.d.ts.map +1 -0
  52. package/dist/services/logger.service.js +110 -0
  53. package/dist/services/logger.service.js.map +1 -0
  54. package/dist/services/login.service.d.ts +37 -0
  55. package/dist/services/login.service.d.ts.map +1 -0
  56. package/dist/services/login.service.js +34 -0
  57. package/dist/services/login.service.js.map +1 -0
  58. package/dist/services/oauth.service.d.ts +110 -0
  59. package/dist/services/oauth.service.d.ts.map +1 -0
  60. package/dist/services/oauth.service.js +214 -0
  61. package/dist/services/oauth.service.js.map +1 -0
  62. package/dist/services/password-reset.service.d.ts +41 -0
  63. package/dist/services/password-reset.service.d.ts.map +1 -0
  64. package/dist/services/password-reset.service.js +45 -0
  65. package/dist/services/password-reset.service.js.map +1 -0
  66. package/dist/services/platform.service.d.ts +39 -0
  67. package/dist/services/platform.service.d.ts.map +1 -0
  68. package/dist/services/platform.service.js +33 -0
  69. package/dist/services/platform.service.js.map +1 -0
  70. package/dist/services/promise.service.d.ts +40 -0
  71. package/dist/services/promise.service.d.ts.map +1 -0
  72. package/dist/services/promise.service.js +85 -0
  73. package/dist/services/promise.service.js.map +1 -0
  74. package/dist/services/push.service.d.ts +45 -0
  75. package/dist/services/push.service.d.ts.map +1 -0
  76. package/dist/services/push.service.js +64 -0
  77. package/dist/services/push.service.js.map +1 -0
  78. package/dist/services/router.service.d.ts +114 -0
  79. package/dist/services/router.service.d.ts.map +1 -0
  80. package/dist/services/router.service.js +142 -0
  81. package/dist/services/router.service.js.map +1 -0
  82. package/dist/services/signup.service.d.ts +37 -0
  83. package/dist/services/signup.service.d.ts.map +1 -0
  84. package/dist/services/signup.service.js +34 -0
  85. package/dist/services/signup.service.js.map +1 -0
  86. package/dist/services/state.service.d.ts +82 -0
  87. package/dist/services/state.service.d.ts.map +1 -0
  88. package/dist/services/state.service.js +122 -0
  89. package/dist/services/state.service.js.map +1 -0
  90. package/dist/services/storage.service.d.ts +111 -0
  91. package/dist/services/storage.service.d.ts.map +1 -0
  92. package/dist/services/storage.service.js +167 -0
  93. package/dist/services/storage.service.js.map +1 -0
  94. package/dist/services/theme.service.d.ts +89 -0
  95. package/dist/services/theme.service.d.ts.map +1 -0
  96. package/dist/services/theme.service.js +116 -0
  97. package/dist/services/theme.service.js.map +1 -0
  98. package/dist/services/version.service.d.ts +44 -0
  99. package/dist/services/version.service.d.ts.map +1 -0
  100. package/dist/services/version.service.js +63 -0
  101. package/dist/services/version.service.js.map +1 -0
  102. package/dist/tokens.d.ts +47 -0
  103. package/dist/tokens.d.ts.map +1 -0
  104. package/dist/tokens.js +39 -0
  105. package/dist/tokens.js.map +1 -0
  106. package/dist/types.d.ts +42 -0
  107. package/dist/types.d.ts.map +1 -0
  108. package/dist/types.js +7 -0
  109. package/dist/types.js.map +1 -0
  110. package/package.json +61 -0
package/LICENSE ADDED
@@ -0,0 +1,115 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship.
43
+
44
+ "Contribution" shall mean any work of authorship, including the
45
+ original version of the Work and any modifications or additions
46
+ to that Work, that is intentionally submitted to the Licensor for
47
+ inclusion in the Work by the copyright owner or by an individual or
48
+ Legal Entity authorized to submit on behalf of the copyright owner.
49
+
50
+ "Contributor" shall mean Licensor and any individual or Legal Entity
51
+ on behalf of whom a Contribution has been received by the Licensor and
52
+ subsequently incorporated within the Work.
53
+
54
+ 2. Grant of Copyright License. Subject to the terms and conditions of
55
+ this License, each Contributor hereby grants to You a perpetual,
56
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
57
+ copyright license to reproduce, prepare Derivative Works of,
58
+ publicly display, publicly perform, sublicense, and distribute the
59
+ Work and such Derivative Works in Source or Object form.
60
+
61
+ 3. Grant of Patent License. Subject to the terms and conditions of
62
+ this License, each Contributor hereby grants to You a perpetual,
63
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
64
+ patent license to make, have made, use, offer to sell, sell, import,
65
+ and otherwise transfer the Work.
66
+
67
+ 4. Redistribution. You may reproduce and distribute copies of the
68
+ Work or Derivative Works thereof in any medium, with or without
69
+ modifications, and in Source or Object form, provided that You
70
+ meet the following conditions:
71
+
72
+ (a) You must give any other recipients of the Work or
73
+ Derivative Works a copy of this License; and
74
+
75
+ (b) You must cause any modified files to carry prominent notices
76
+ stating that You changed the files; and
77
+
78
+ (c) You must retain, in the Source form of any Derivative Works
79
+ that You distribute, all copyright, patent, trademark, and
80
+ attribution notices from the Source form of the Work,
81
+ excluding those notices that do not pertain to any part of
82
+ the Derivative Works; and
83
+
84
+ (d) If the Work includes a "NOTICE" text file as part of its
85
+ distribution, then any Derivative Works that You distribute must
86
+ include a readable copy of the attribution notices contained
87
+ within such NOTICE file.
88
+
89
+ 5. Submission of Contributions.
90
+
91
+ 6. Trademarks. This License does not grant permission to use the trade
92
+ names, trademarks, service marks, or product names of the Licensor.
93
+
94
+ 7. Disclaimer of Warranty. Unless required by applicable law or
95
+ agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
96
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
97
+
98
+ 8. Limitation of Liability. In no event and under no legal theory shall
99
+ any Contributor be liable to You for damages.
100
+
101
+ 9. Accepting Warranty or Additional Liability.
102
+
103
+ Copyright 2026 Molecule Dev, Inc.
104
+
105
+ Licensed under the Apache License, Version 2.0 (the "License");
106
+ you may not use this file except in compliance with the License.
107
+ You may obtain a copy of the License at
108
+
109
+ http://www.apache.org/licenses/LICENSE-2.0
110
+
111
+ Unless required by applicable law or agreed to in writing, software
112
+ distributed under the License is distributed on an "AS IS" BASIS,
113
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
114
+ See the License for the specific language governing permissions and
115
+ limitations under the License.
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Signal-based reactive translation wrapper for Angular.
3
+ *
4
+ * Wraps `@molecule/app-i18n`'s `t()` function with an Angular signal so that
5
+ * template bindings automatically re-evaluate when the locale changes. This
6
+ * avoids NG0100 errors because the signal value is stable within a single
7
+ * change detection cycle — it only changes between cycles.
8
+ *
9
+ * Components should import `t` from `@molecule/app-angular` instead of
10
+ * `@molecule/app-i18n` to get automatic reactivity.
11
+ *
12
+ * @module
13
+ */
14
+ import type { InterpolationValues } from '@molecule/app-i18n';
15
+ /**
16
+ * Bump the locale version signal, causing all template bindings that use
17
+ * the reactive `t()` to re-evaluate on the next change detection cycle.
18
+ *
19
+ * Called automatically by the `ENVIRONMENT_INITIALIZER` in `provideMolecule`.
20
+ */
21
+ export declare function bumpLocaleVersion(): void;
22
+ /**
23
+ * Translate a key using the current locale.
24
+ *
25
+ * This is a signal-aware wrapper around `@molecule/app-i18n`'s `t()`.
26
+ * Reading the internal locale signal establishes an Angular reactivity
27
+ * dependency, so template bindings that call this function will be
28
+ * re-evaluated when the locale changes.
29
+ *
30
+ * @param key - Translation key
31
+ * @param values - Interpolation values
32
+ * @param options - Options (defaultValue, count).
33
+ * @param options.defaultValue - Fallback string when no translation is found.
34
+ * @param options.count - Pluralization count.
35
+ * @returns Translated string
36
+ */
37
+ export declare const t: (key: string, values?: InterpolationValues, options?: {
38
+ defaultValue?: string;
39
+ count?: number;
40
+ }) => string;
41
+ //# sourceMappingURL=i18n-reactive.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n-reactive.d.ts","sourceRoot":"","sources":["../src/i18n-reactive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAK7D;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,CAAC,GACZ,KAAK,MAAM,EACX,SAAS,mBAAmB,EAC5B,UAAU;IAAE,YAAY,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,KAClD,MAGF,CAAA"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Signal-based reactive translation wrapper for Angular.
3
+ *
4
+ * Wraps `@molecule/app-i18n`'s `t()` function with an Angular signal so that
5
+ * template bindings automatically re-evaluate when the locale changes. This
6
+ * avoids NG0100 errors because the signal value is stable within a single
7
+ * change detection cycle — it only changes between cycles.
8
+ *
9
+ * Components should import `t` from `@molecule/app-angular` instead of
10
+ * `@molecule/app-i18n` to get automatic reactivity.
11
+ *
12
+ * @module
13
+ */
14
+ import { signal } from '@angular/core';
15
+ import { t as originalT } from '@molecule/app-i18n';
16
+ const localeVersion = signal(0, /* @ts-ignore */
17
+ ...(ngDevMode ? [{ debugName: "localeVersion" }] : /* istanbul ignore next */ []));
18
+ /**
19
+ * Bump the locale version signal, causing all template bindings that use
20
+ * the reactive `t()` to re-evaluate on the next change detection cycle.
21
+ *
22
+ * Called automatically by the `ENVIRONMENT_INITIALIZER` in `provideMolecule`.
23
+ */
24
+ export function bumpLocaleVersion() {
25
+ localeVersion.update((v) => v + 1);
26
+ }
27
+ /**
28
+ * Translate a key using the current locale.
29
+ *
30
+ * This is a signal-aware wrapper around `@molecule/app-i18n`'s `t()`.
31
+ * Reading the internal locale signal establishes an Angular reactivity
32
+ * dependency, so template bindings that call this function will be
33
+ * re-evaluated when the locale changes.
34
+ *
35
+ * @param key - Translation key
36
+ * @param values - Interpolation values
37
+ * @param options - Options (defaultValue, count).
38
+ * @param options.defaultValue - Fallback string when no translation is found.
39
+ * @param options.count - Pluralization count.
40
+ * @returns Translated string
41
+ */
42
+ export const t = (key, values, options) => {
43
+ localeVersion(); // read signal to establish Angular reactivity tracking
44
+ return originalT(key, values, options);
45
+ };
46
+ //# sourceMappingURL=i18n-reactive.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n-reactive.js","sourceRoot":"","sources":["../src/i18n-reactive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAGtC,OAAO,EAAE,CAAC,IAAI,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAEnD,MAAM,aAAa,GAAG,MAAM,CAAC,CAAC;kFAAC,CAAA;AAE/B;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB;IAC/B,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;AACpC,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,CAAC,GAAG,CACf,GAAW,EACX,MAA4B,EAC5B,OAAmD,EAC3C,EAAE;IACV,aAAa,EAAE,CAAA,CAAC,uDAAuD;IACvE,OAAO,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;AACxC,CAAC,CAAA"}
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Angular framework bindings for molecule.dev.
3
+ *
4
+ * Provides Angular-specific services and providers for all molecule
5
+ * core interfaces. This package enables the use of molecule's framework-agnostic
6
+ * interfaces with Angular's idioms (services, DI, RxJS observables, etc.).
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // main.ts — wire concrete providers into Angular DI:
11
+ * import { bootstrapApplication } from '@angular/platform-browser'
12
+ * import { provideMolecule } from '@molecule/app-angular'
13
+ * import { createJWTAuthClient } from '@molecule/app-auth'
14
+ * import { provider as stateProvider } from '@molecule/app-state-zustand'
15
+ * import { provider as themeProvider } from '@molecule/app-theme-css-variables'
16
+ *
17
+ * const authClient = createJWTAuthClient({ baseURL: '/api' })
18
+ *
19
+ * bootstrapApplication(AppComponent, {
20
+ * providers: [
21
+ * provideMolecule({
22
+ * state: stateProvider,
23
+ * auth: authClient,
24
+ * theme: themeProvider,
25
+ * }),
26
+ * ],
27
+ * })
28
+ *
29
+ * // dashboard.component.ts — inject the Molecule services:
30
+ * import { Component, inject } from '@angular/core'
31
+ * import { MoleculeAuthService, MoleculeThemeService, t } from '@molecule/app-angular'
32
+ *
33
+ * @Component({
34
+ * selector: 'app-dashboard',
35
+ * template: `
36
+ * <div [style.background]="(theme$ | async)?.colors.background">
37
+ * <h1>{{ t('dashboard.welcome', {}, { defaultValue: 'Welcome!' }) }}</h1>
38
+ * <p>{{ (user$ | async)?.name }}</p>
39
+ * <button (click)="logout()">
40
+ * {{ t('auth.logout', {}, { defaultValue: 'Log out' }) }}
41
+ * </button>
42
+ * </div>
43
+ * `,
44
+ * })
45
+ * class DashboardComponent {
46
+ * // Expose the reactive t() so template bindings re-evaluate on locale change.
47
+ * protected readonly t = t
48
+ *
49
+ * private authService = inject(MoleculeAuthService)
50
+ * private themeService = inject(MoleculeThemeService)
51
+ *
52
+ * user$ = this.authService.user$ // Observable<UserProfile | null>
53
+ * theme$ = this.themeService.theme$ // Observable<Theme>
54
+ *
55
+ * logout(): void {
56
+ * void this.authService.logout()
57
+ * }
58
+ * }
59
+ * ```
60
+ *
61
+ * @remarks
62
+ * - Peer requirements: Angular 22 (`@angular/core` is pinned to 22.0.0) and
63
+ * rxjs 7.8+.
64
+ * - Translations: import `t` from THIS package, not from
65
+ * `@molecule/app-i18n`. The re-exported `t` reads an internal Angular
66
+ * signal, so template bindings that CALL it (expose it on the component as
67
+ * above) re-evaluate automatically when the locale changes; the plain
68
+ * app-i18n `t` — or a one-time field assignment like `title = t(...)` —
69
+ * renders once and goes stale. The signal is bumped by `provideMolecule` —
70
+ * pass your `i18n` provider there (or call `bumpLocaleVersion()` from your
71
+ * own locale-change hook) for the reactivity to fire.
72
+ * - `provideMolecule` only registers the providers you pass; injecting a
73
+ * Molecule service whose token was never provided fails at DI time.
74
+ * Per-concern helpers (`provideAuth`, `provideTheme`, ...) exist for
75
+ * piecemeal setup.
76
+ *
77
+ * @module
78
+ */
79
+ export * from './i18n-reactive.js';
80
+ export * from './providers.js';
81
+ export * from './services/index.js';
82
+ export * from './tokens.js';
83
+ export * from './types.js';
84
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,84 @@
1
+ /**
2
+ * Angular framework bindings for molecule.dev.
3
+ *
4
+ * Provides Angular-specific services and providers for all molecule
5
+ * core interfaces. This package enables the use of molecule's framework-agnostic
6
+ * interfaces with Angular's idioms (services, DI, RxJS observables, etc.).
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * // main.ts — wire concrete providers into Angular DI:
11
+ * import { bootstrapApplication } from '@angular/platform-browser'
12
+ * import { provideMolecule } from '@molecule/app-angular'
13
+ * import { createJWTAuthClient } from '@molecule/app-auth'
14
+ * import { provider as stateProvider } from '@molecule/app-state-zustand'
15
+ * import { provider as themeProvider } from '@molecule/app-theme-css-variables'
16
+ *
17
+ * const authClient = createJWTAuthClient({ baseURL: '/api' })
18
+ *
19
+ * bootstrapApplication(AppComponent, {
20
+ * providers: [
21
+ * provideMolecule({
22
+ * state: stateProvider,
23
+ * auth: authClient,
24
+ * theme: themeProvider,
25
+ * }),
26
+ * ],
27
+ * })
28
+ *
29
+ * // dashboard.component.ts — inject the Molecule services:
30
+ * import { Component, inject } from '@angular/core'
31
+ * import { MoleculeAuthService, MoleculeThemeService, t } from '@molecule/app-angular'
32
+ *
33
+ * @Component({
34
+ * selector: 'app-dashboard',
35
+ * template: `
36
+ * <div [style.background]="(theme$ | async)?.colors.background">
37
+ * <h1>{{ t('dashboard.welcome', {}, { defaultValue: 'Welcome!' }) }}</h1>
38
+ * <p>{{ (user$ | async)?.name }}</p>
39
+ * <button (click)="logout()">
40
+ * {{ t('auth.logout', {}, { defaultValue: 'Log out' }) }}
41
+ * </button>
42
+ * </div>
43
+ * `,
44
+ * })
45
+ * class DashboardComponent {
46
+ * // Expose the reactive t() so template bindings re-evaluate on locale change.
47
+ * protected readonly t = t
48
+ *
49
+ * private authService = inject(MoleculeAuthService)
50
+ * private themeService = inject(MoleculeThemeService)
51
+ *
52
+ * user$ = this.authService.user$ // Observable<UserProfile | null>
53
+ * theme$ = this.themeService.theme$ // Observable<Theme>
54
+ *
55
+ * logout(): void {
56
+ * void this.authService.logout()
57
+ * }
58
+ * }
59
+ * ```
60
+ *
61
+ * @remarks
62
+ * - Peer requirements: Angular 22 (`@angular/core` is pinned to 22.0.0) and
63
+ * rxjs 7.8+.
64
+ * - Translations: import `t` from THIS package, not from
65
+ * `@molecule/app-i18n`. The re-exported `t` reads an internal Angular
66
+ * signal, so template bindings that CALL it (expose it on the component as
67
+ * above) re-evaluate automatically when the locale changes; the plain
68
+ * app-i18n `t` — or a one-time field assignment like `title = t(...)` —
69
+ * renders once and goes stale. The signal is bumped by `provideMolecule` —
70
+ * pass your `i18n` provider there (or call `bumpLocaleVersion()` from your
71
+ * own locale-change hook) for the reactivity to fire.
72
+ * - `provideMolecule` only registers the providers you pass; injecting a
73
+ * Molecule service whose token was never provided fails at DI time.
74
+ * Per-concern helpers (`provideAuth`, `provideTheme`, ...) exist for
75
+ * piecemeal setup.
76
+ *
77
+ * @module
78
+ */
79
+ export * from './i18n-reactive.js';
80
+ export * from './providers.js';
81
+ export * from './services/index.js';
82
+ export * from './tokens.js';
83
+ export * from './types.js';
84
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AAEH,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Angular provider functions for molecule.dev.
3
+ *
4
+ * @module
5
+ */
6
+ import type { EnvironmentProviders } from '@angular/core';
7
+ import type { AuthClient } from '@molecule/app-auth';
8
+ import type { HttpClient } from '@molecule/app-http';
9
+ import type { I18nProvider } from '@molecule/app-i18n';
10
+ import type { LoggerProvider } from '@molecule/app-logger';
11
+ import type { Router } from '@molecule/app-routing';
12
+ import type { StateProvider } from '@molecule/app-state';
13
+ import type { StorageProvider } from '@molecule/app-storage';
14
+ import type { ThemeProvider } from '@molecule/app-theme';
15
+ import type { MoleculeModuleConfig } from './types.js';
16
+ /**
17
+ * Provide state management.
18
+ *
19
+ * @param provider - State provider
20
+ * @returns Environment providers
21
+ */
22
+ export declare function provideState(provider: StateProvider): EnvironmentProviders;
23
+ /**
24
+ * Registers an AuthClient as an Angular environment provider for dependency injection.
25
+ *
26
+ * @param client - Auth client
27
+ * @returns Environment providers
28
+ */
29
+ export declare function provideAuth<T>(client: AuthClient<T>): EnvironmentProviders;
30
+ /**
31
+ * Registers a ThemeProvider as an Angular environment provider for dependency injection.
32
+ *
33
+ * @param provider - Theme provider
34
+ * @returns Environment providers
35
+ */
36
+ export declare function provideTheme(provider: ThemeProvider): EnvironmentProviders;
37
+ /**
38
+ * Registers a Router as an Angular environment provider for dependency injection.
39
+ *
40
+ * @param router - Router instance
41
+ * @returns Environment providers
42
+ */
43
+ export declare function provideRouter(router: Router): EnvironmentProviders;
44
+ /**
45
+ * Registers an I18nProvider as an Angular environment provider for dependency injection.
46
+ *
47
+ * @param provider - I18n provider
48
+ * @returns Environment providers
49
+ */
50
+ export declare function provideI18n(provider: I18nProvider): EnvironmentProviders;
51
+ /**
52
+ * Provide HTTP client.
53
+ *
54
+ * @param client - HTTP client
55
+ * @returns Environment providers
56
+ */
57
+ export declare function provideHttp(client: HttpClient): EnvironmentProviders;
58
+ /**
59
+ * Registers a StorageProvider as an Angular environment provider for dependency injection.
60
+ *
61
+ * @param provider - Storage provider
62
+ * @returns Environment providers
63
+ */
64
+ export declare function provideStorage(provider: StorageProvider): EnvironmentProviders;
65
+ /**
66
+ * Registers a LoggerProvider as an Angular environment provider for dependency injection.
67
+ *
68
+ * @param provider - Logger provider
69
+ * @returns Environment providers
70
+ */
71
+ export declare function provideLogger(provider: LoggerProvider): EnvironmentProviders;
72
+ /**
73
+ * Provide all molecule services at once.
74
+ *
75
+ * @param config - Configuration with all providers
76
+ * @returns Environment providers
77
+ *
78
+ * @example
79
+ * ```typescript
80
+ * import { bootstrapApplication } from '@angular/platform-browser'
81
+ * import { provideMolecule } from '@molecule/app-angular'
82
+ * import { provider as stateProvider } from '@molecule/app-state-zustand'
83
+ *
84
+ * bootstrapApplication(AppComponent, {
85
+ * providers: [
86
+ * provideMolecule({
87
+ * state: stateProvider,
88
+ * auth: authClient,
89
+ * theme: themeProvider,
90
+ * }),
91
+ * ],
92
+ * })
93
+ * ```
94
+ */
95
+ export declare function provideMolecule(config: MoleculeModuleConfig): EnvironmentProviders;
96
+ //# sourceMappingURL=providers.d.ts.map
@@ -0,0 +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;;;;;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,CAyClF"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Angular provider functions for molecule.dev.
3
+ *
4
+ * @module
5
+ */
6
+ import { ENVIRONMENT_INITIALIZER, makeEnvironmentProviders } from '@angular/core';
7
+ import { bumpLocaleVersion } from './i18n-reactive.js';
8
+ import { AUTH_CLIENT, HTTP_CLIENT, I18N_PROVIDER, LOGGER_PROVIDER, ROUTER, STATE_PROVIDER, STORAGE_PROVIDER, THEME_PROVIDER, } from './tokens.js';
9
+ /**
10
+ * Provide state management.
11
+ *
12
+ * @param provider - State provider
13
+ * @returns Environment providers
14
+ */
15
+ export function provideState(provider) {
16
+ return makeEnvironmentProviders([{ provide: STATE_PROVIDER, useValue: provider }]);
17
+ }
18
+ /**
19
+ * Registers an AuthClient as an Angular environment provider for dependency injection.
20
+ *
21
+ * @param client - Auth client
22
+ * @returns Environment providers
23
+ */
24
+ export function provideAuth(client) {
25
+ return makeEnvironmentProviders([{ provide: AUTH_CLIENT, useValue: client }]);
26
+ }
27
+ /**
28
+ * Registers a ThemeProvider as an Angular environment provider for dependency injection.
29
+ *
30
+ * @param provider - Theme provider
31
+ * @returns Environment providers
32
+ */
33
+ export function provideTheme(provider) {
34
+ return makeEnvironmentProviders([{ provide: THEME_PROVIDER, useValue: provider }]);
35
+ }
36
+ /**
37
+ * Registers a Router as an Angular environment provider for dependency injection.
38
+ *
39
+ * @param router - Router instance
40
+ * @returns Environment providers
41
+ */
42
+ export function provideRouter(router) {
43
+ return makeEnvironmentProviders([{ provide: ROUTER, useValue: router }]);
44
+ }
45
+ /**
46
+ * Registers an I18nProvider as an Angular environment provider for dependency injection.
47
+ *
48
+ * @param provider - I18n provider
49
+ * @returns Environment providers
50
+ */
51
+ export function provideI18n(provider) {
52
+ return makeEnvironmentProviders([{ provide: I18N_PROVIDER, useValue: provider }]);
53
+ }
54
+ /**
55
+ * Provide HTTP client.
56
+ *
57
+ * @param client - HTTP client
58
+ * @returns Environment providers
59
+ */
60
+ export function provideHttp(client) {
61
+ return makeEnvironmentProviders([{ provide: HTTP_CLIENT, useValue: client }]);
62
+ }
63
+ /**
64
+ * Registers a StorageProvider as an Angular environment provider for dependency injection.
65
+ *
66
+ * @param provider - Storage provider
67
+ * @returns Environment providers
68
+ */
69
+ export function provideStorage(provider) {
70
+ return makeEnvironmentProviders([{ provide: STORAGE_PROVIDER, useValue: provider }]);
71
+ }
72
+ /**
73
+ * Registers a LoggerProvider as an Angular environment provider for dependency injection.
74
+ *
75
+ * @param provider - Logger provider
76
+ * @returns Environment providers
77
+ */
78
+ export function provideLogger(provider) {
79
+ return makeEnvironmentProviders([{ provide: LOGGER_PROVIDER, useValue: provider }]);
80
+ }
81
+ /**
82
+ * Provide all molecule services at once.
83
+ *
84
+ * @param config - Configuration with all providers
85
+ * @returns Environment providers
86
+ *
87
+ * @example
88
+ * ```typescript
89
+ * import { bootstrapApplication } from '@angular/platform-browser'
90
+ * import { provideMolecule } from '@molecule/app-angular'
91
+ * import { provider as stateProvider } from '@molecule/app-state-zustand'
92
+ *
93
+ * bootstrapApplication(AppComponent, {
94
+ * providers: [
95
+ * provideMolecule({
96
+ * state: stateProvider,
97
+ * auth: authClient,
98
+ * theme: themeProvider,
99
+ * }),
100
+ * ],
101
+ * })
102
+ * ```
103
+ */
104
+ export function provideMolecule(config) {
105
+ const providers = [];
106
+ if (config.state) {
107
+ providers.push({ provide: STATE_PROVIDER, useValue: config.state });
108
+ }
109
+ if (config.auth) {
110
+ providers.push({ provide: AUTH_CLIENT, useValue: config.auth });
111
+ }
112
+ if (config.theme) {
113
+ providers.push({ provide: THEME_PROVIDER, useValue: config.theme });
114
+ }
115
+ if (config.router) {
116
+ providers.push({ provide: ROUTER, useValue: config.router });
117
+ }
118
+ if (config.i18n) {
119
+ providers.push({ provide: I18N_PROVIDER, useValue: config.i18n });
120
+ // Bump the reactive locale signal on locale changes so that Angular
121
+ // template bindings using the signal-aware `t()` from this package
122
+ // automatically re-evaluate. No zone or tick hacks needed — signals
123
+ // handle change detection scheduling natively.
124
+ const i18nProvider = config.i18n;
125
+ providers.push({
126
+ provide: ENVIRONMENT_INITIALIZER,
127
+ multi: true,
128
+ useValue: () => {
129
+ i18nProvider.onLocaleChange(() => bumpLocaleVersion());
130
+ },
131
+ });
132
+ }
133
+ if (config.http) {
134
+ providers.push({ provide: HTTP_CLIENT, useValue: config.http });
135
+ }
136
+ if (config.storage) {
137
+ providers.push({ provide: STORAGE_PROVIDER, useValue: config.storage });
138
+ }
139
+ if (config.logger) {
140
+ providers.push({ provide: LOGGER_PROVIDER, useValue: config.logger });
141
+ }
142
+ return makeEnvironmentProviders(providers);
143
+ }
144
+ //# sourceMappingURL=providers.js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