@molecule/app-angular 3.3.0 → 3.5.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 (115) hide show
  1. package/README.md +3889 -1267
  2. package/dist/hooks/external-store.d.ts +32 -0
  3. package/dist/hooks/external-store.d.ts.map +1 -0
  4. package/dist/hooks/external-store.js +62 -0
  5. package/dist/hooks/external-store.js.map +1 -0
  6. package/dist/hooks/index.d.ts +24 -0
  7. package/dist/hooks/index.d.ts.map +1 -0
  8. package/dist/hooks/index.js +24 -0
  9. package/dist/hooks/index.js.map +1 -0
  10. package/dist/hooks/use-ai-models.d.ts +46 -0
  11. package/dist/hooks/use-ai-models.d.ts.map +1 -0
  12. package/dist/hooks/use-ai-models.js +142 -0
  13. package/dist/hooks/use-ai-models.js.map +1 -0
  14. package/dist/hooks/use-async.d.ts +125 -0
  15. package/dist/hooks/use-async.d.ts.map +1 -0
  16. package/dist/hooks/use-async.js +189 -0
  17. package/dist/hooks/use-async.js.map +1 -0
  18. package/dist/hooks/use-auth-flows.d.ts +207 -0
  19. package/dist/hooks/use-auth-flows.d.ts.map +1 -0
  20. package/dist/hooks/use-auth-flows.js +460 -0
  21. package/dist/hooks/use-auth-flows.js.map +1 -0
  22. package/dist/hooks/use-auth.d.ts +80 -0
  23. package/dist/hooks/use-auth.d.ts.map +1 -0
  24. package/dist/hooks/use-auth.js +89 -0
  25. package/dist/hooks/use-auth.js.map +1 -0
  26. package/dist/hooks/use-forms.d.ts +177 -0
  27. package/dist/hooks/use-forms.d.ts.map +1 -0
  28. package/dist/hooks/use-forms.js +185 -0
  29. package/dist/hooks/use-forms.js.map +1 -0
  30. package/dist/hooks/use-http.d.ts +155 -0
  31. package/dist/hooks/use-http.d.ts.map +1 -0
  32. package/dist/hooks/use-http.js +212 -0
  33. package/dist/hooks/use-http.js.map +1 -0
  34. package/dist/hooks/use-ide.d.ts +208 -0
  35. package/dist/hooks/use-ide.d.ts.map +1 -0
  36. package/dist/hooks/use-ide.js +217 -0
  37. package/dist/hooks/use-ide.js.map +1 -0
  38. package/dist/hooks/use-logger.d.ts +40 -0
  39. package/dist/hooks/use-logger.d.ts.map +1 -0
  40. package/dist/hooks/use-logger.js +56 -0
  41. package/dist/hooks/use-logger.js.map +1 -0
  42. package/dist/hooks/use-native.d.ts +213 -0
  43. package/dist/hooks/use-native.d.ts.map +1 -0
  44. package/dist/hooks/use-native.js +158 -0
  45. package/dist/hooks/use-native.js.map +1 -0
  46. package/dist/hooks/use-profile-form.d.ts +113 -0
  47. package/dist/hooks/use-profile-form.d.ts.map +1 -0
  48. package/dist/hooks/use-profile-form.js +253 -0
  49. package/dist/hooks/use-profile-form.js.map +1 -0
  50. package/dist/hooks/use-router.d.ts +212 -0
  51. package/dist/hooks/use-router.d.ts.map +1 -0
  52. package/dist/hooks/use-router.js +251 -0
  53. package/dist/hooks/use-router.js.map +1 -0
  54. package/dist/hooks/use-storage.d.ts +128 -0
  55. package/dist/hooks/use-storage.d.ts.map +1 -0
  56. package/dist/hooks/use-storage.js +217 -0
  57. package/dist/hooks/use-storage.js.map +1 -0
  58. package/dist/hooks/use-store.d.ts +74 -0
  59. package/dist/hooks/use-store.d.ts.map +1 -0
  60. package/dist/hooks/use-store.js +103 -0
  61. package/dist/hooks/use-store.js.map +1 -0
  62. package/dist/hooks/use-theme.d.ts +59 -0
  63. package/dist/hooks/use-theme.d.ts.map +1 -0
  64. package/dist/hooks/use-theme.js +117 -0
  65. package/dist/hooks/use-theme.js.map +1 -0
  66. package/dist/hooks/use-translation.d.ts +86 -0
  67. package/dist/hooks/use-translation.d.ts.map +1 -0
  68. package/dist/hooks/use-translation.js +146 -0
  69. package/dist/hooks/use-translation.js.map +1 -0
  70. package/dist/hooks/use-verify-payment-return.d.ts +86 -0
  71. package/dist/hooks/use-verify-payment-return.d.ts.map +1 -0
  72. package/dist/hooks/use-verify-payment-return.js +167 -0
  73. package/dist/hooks/use-verify-payment-return.js.map +1 -0
  74. package/dist/hooks/use-version.d.ts +49 -0
  75. package/dist/hooks/use-version.d.ts.map +1 -0
  76. package/dist/hooks/use-version.js +70 -0
  77. package/dist/hooks/use-version.js.map +1 -0
  78. package/dist/i18n-reactive.d.ts +2 -5
  79. package/dist/i18n-reactive.d.ts.map +1 -1
  80. package/dist/i18n-reactive.js.map +1 -1
  81. package/dist/index.d.ts +2 -0
  82. package/dist/index.d.ts.map +1 -1
  83. package/dist/index.js +2 -0
  84. package/dist/index.js.map +1 -1
  85. package/dist/inject.d.ts +24 -0
  86. package/dist/inject.d.ts.map +1 -0
  87. package/dist/inject.js +33 -0
  88. package/dist/inject.js.map +1 -0
  89. package/dist/providers.d.ts +24 -0
  90. package/dist/providers.d.ts.map +1 -1
  91. package/dist/providers.js +44 -3
  92. package/dist/providers.js.map +1 -1
  93. package/dist/services/change-password.service.d.ts +4 -1
  94. package/dist/services/change-password.service.d.ts.map +1 -1
  95. package/dist/services/change-password.service.js +3 -0
  96. package/dist/services/change-password.service.js.map +1 -1
  97. package/dist/services/password-reset.service.d.ts +4 -1
  98. package/dist/services/password-reset.service.d.ts.map +1 -1
  99. package/dist/services/password-reset.service.js +3 -0
  100. package/dist/services/password-reset.service.js.map +1 -1
  101. package/dist/session-ready.d.ts +41 -0
  102. package/dist/session-ready.d.ts.map +1 -0
  103. package/dist/session-ready.js +79 -0
  104. package/dist/session-ready.js.map +1 -0
  105. package/dist/site.d.ts +51 -0
  106. package/dist/site.d.ts.map +1 -0
  107. package/dist/site.js +69 -0
  108. package/dist/site.js.map +1 -0
  109. package/dist/tokens.d.ts +15 -0
  110. package/dist/tokens.d.ts.map +1 -1
  111. package/dist/tokens.js +12 -0
  112. package/dist/tokens.js.map +1 -1
  113. package/dist/types.d.ts +14 -1
  114. package/dist/types.d.ts.map +1 -1
  115. package/package.json +6 -6
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Post-checkout return verification, mirroring `useVerifyPaymentReturn` from
3
+ * `@molecule/app-react`.
4
+ *
5
+ * @module
6
+ */
7
+ import { type Signal } from '@angular/core';
8
+ /** How far the return-page verification has got. */
9
+ export type VerifyPaymentReturnStatus = 'idle' | 'verifying' | 'verified' | 'failed';
10
+ /** Options for {@link useVerifyPaymentReturn}. */
11
+ export interface UseVerifyPaymentReturnOptions {
12
+ /**
13
+ * Provider name to verify with, when the return URL carries no `provider`
14
+ * query parameter. Leave unset to verify only what the URL names.
15
+ */
16
+ provider?: string;
17
+ /** Set `false` to skip verification entirely (e.g. behind a feature flag). */
18
+ enabled?: boolean;
19
+ /**
20
+ * Remove the provider's query parameters from the address bar once the
21
+ * purchase is verified, so a reload (or a shared link) cannot replay the
22
+ * verification. Defaults to `true`.
23
+ */
24
+ cleanUrl?: boolean;
25
+ /** Called once, after the purchase verifies. */
26
+ onVerified?: () => void;
27
+ /**
28
+ * Called when verification fails.
29
+ *
30
+ * @param error - The failure.
31
+ */
32
+ onError?: (error: Error) => void;
33
+ }
34
+ /** Result of {@link useVerifyPaymentReturn}: the state fields as signals. */
35
+ export interface UseVerifyPaymentReturnResult {
36
+ /**
37
+ * `idle` when this page load is not a checkout return (no transaction id in
38
+ * the URL) or auth is still hydrating; `verifying` while the API call is in
39
+ * flight; then `verified` or `failed`.
40
+ */
41
+ readonly status: Signal<VerifyPaymentReturnStatus>;
42
+ /**
43
+ * `true` when the URL identifies a purchase to verify. A `cleanUrl` rewrite
44
+ * after a verified purchase clears it, as React's per-render URL read does.
45
+ */
46
+ readonly isReturn: Signal<boolean>;
47
+ /** The provider named by the URL (or the `provider` option). */
48
+ readonly provider: Signal<string | null>;
49
+ /** The provider transaction/session id read from the URL. */
50
+ readonly transactionId: Signal<string | null>;
51
+ /** Why verification failed, when it did. */
52
+ readonly error: Signal<Error | null>;
53
+ /** Re-runs the verification — wire this to a retry button. */
54
+ retry: () => void;
55
+ }
56
+ /**
57
+ * Reads the payment id a provider put in the return URL and confirms the
58
+ * purchase server-side with `POST /users/:id/verify-payment/:provider`. Call
59
+ * it in an injection context (a component field initializer or constructor).
60
+ *
61
+ * **This is why a hosted checkout returns the buyer to the APP and not the
62
+ * API.** Session cookies are host-only on the app's origin, so a top-level
63
+ * redirect from the provider straight to an authenticated API callback on a
64
+ * different host arrives with NO credentials — it answers 401 and the paid
65
+ * plan is never granted. The request this hook makes is a same-origin call
66
+ * from a loaded app page, so the credentials apply. It waits for auth to
67
+ * hydrate first: after the redirect the page is a cold load, and the session
68
+ * is restored from the httpOnly cookie via `GET /users/me`.
69
+ *
70
+ * Verification is idempotent server-side (first-claim-wins on the
71
+ * transaction), and this hook additionally runs at most once per transaction
72
+ * id per page. Safe on pages that are also reached normally: with no id in the
73
+ * URL it stays `idle` and issues no request.
74
+ *
75
+ * If the component unmounts while the request is in flight, a verified
76
+ * purchase still refreshes the cached profile (the plan is paid for), but the
77
+ * hook calls neither `onVerified` nor `onError` and leaves the URL alone: by
78
+ * then the address may belong to another page. A failure after unmount is
79
+ * logged instead.
80
+ *
81
+ * @param options - Provider fallback + lifecycle callbacks (see
82
+ * {@link UseVerifyPaymentReturnOptions}).
83
+ * @returns The verification state as signals.
84
+ */
85
+ export declare function useVerifyPaymentReturn(options?: UseVerifyPaymentReturnOptions): UseVerifyPaymentReturnResult;
86
+ //# sourceMappingURL=use-verify-payment-return.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-verify-payment-return.d.ts","sourceRoot":"","sources":["../../src/hooks/use-verify-payment-return.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAwC,KAAK,MAAM,EAAU,MAAM,eAAe,CAAA;AAoBzF,oDAAoD;AACpD,MAAM,MAAM,yBAAyB,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAA;AAEpF,kDAAkD;AAClD,MAAM,WAAW,6BAA6B;IAC5C;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB,8EAA8E;IAC9E,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB,gDAAgD;IAChD,UAAU,CAAC,EAAE,MAAM,IAAI,CAAA;IAEvB;;;;OAIG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;CACjC;AAYD,6EAA6E;AAC7E,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,yBAAyB,CAAC,CAAA;IAElD;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;IAElC,gEAAgE;IAChE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IAExC,6DAA6D;IAC7D,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,CAAA;IAE7C,4CAA4C;IAC5C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,GAAG,IAAI,CAAC,CAAA;IAEpC,8DAA8D;IAC9D,KAAK,EAAE,MAAM,IAAI,CAAA;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,GAAE,6BAAkC,GAC1C,4BAA4B,CA2H9B"}
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Post-checkout return verification, mirroring `useVerifyPaymentReturn` from
3
+ * `@molecule/app-react`.
4
+ *
5
+ * @module
6
+ */
7
+ import { computed, DestroyRef, effect, inject, signal } from '@angular/core';
8
+ import { getLogger } from '@molecule/app-logger';
9
+ import { useAuth } from './use-auth.js';
10
+ import { useHttpClient } from './use-http.js';
11
+ /** Query parameters a payment provider may use for its transaction id. */
12
+ const TRANSACTION_ID_PARAMS = [
13
+ // What `resolveCheckoutRedirectUrls` (@molecule/api-payments) asks providers
14
+ // to substitute — Stripe's `{CHECKOUT_SESSION_ID}`.
15
+ 'sessionId',
16
+ 'session_id',
17
+ 'subscriptionId',
18
+ // PayPal appends its OWN names to the return URL after buyer approval.
19
+ 'subscription_id',
20
+ 'token',
21
+ ];
22
+ /**
23
+ * Reads the payment id a provider put in the return URL and confirms the
24
+ * purchase server-side with `POST /users/:id/verify-payment/:provider`. Call
25
+ * it in an injection context (a component field initializer or constructor).
26
+ *
27
+ * **This is why a hosted checkout returns the buyer to the APP and not the
28
+ * API.** Session cookies are host-only on the app's origin, so a top-level
29
+ * redirect from the provider straight to an authenticated API callback on a
30
+ * different host arrives with NO credentials — it answers 401 and the paid
31
+ * plan is never granted. The request this hook makes is a same-origin call
32
+ * from a loaded app page, so the credentials apply. It waits for auth to
33
+ * hydrate first: after the redirect the page is a cold load, and the session
34
+ * is restored from the httpOnly cookie via `GET /users/me`.
35
+ *
36
+ * Verification is idempotent server-side (first-claim-wins on the
37
+ * transaction), and this hook additionally runs at most once per transaction
38
+ * id per page. Safe on pages that are also reached normally: with no id in the
39
+ * URL it stays `idle` and issues no request.
40
+ *
41
+ * If the component unmounts while the request is in flight, a verified
42
+ * purchase still refreshes the cached profile (the plan is paid for), but the
43
+ * hook calls neither `onVerified` nor `onError` and leaves the URL alone: by
44
+ * then the address may belong to another page. A failure after unmount is
45
+ * logged instead.
46
+ *
47
+ * @param options - Provider fallback + lifecycle callbacks (see
48
+ * {@link UseVerifyPaymentReturnOptions}).
49
+ * @returns The verification state as signals.
50
+ */
51
+ export function useVerifyPaymentReturn(options = {}) {
52
+ const { provider: providerOption, enabled = true, cleanUrl = true, onVerified, onError } = options;
53
+ const http = useHttpClient();
54
+ const { state, refresh } = useAuth();
55
+ const destroyRef = inject(DestroyRef);
56
+ const search = typeof window === 'undefined' ? '' : window.location.search;
57
+ const params = new URLSearchParams(search);
58
+ const transactionId = TRANSACTION_ID_PARAMS.map((name) => params.get(name)).find((value) => !!value) ?? null;
59
+ const provider = params.get('provider') || providerOption || null;
60
+ const isReturn = Boolean(enabled && transactionId && provider);
61
+ const status = signal('idle', /* @ts-ignore */
62
+ ...(ngDevMode ? [{ debugName: "status" }] : /* istanbul ignore next */ []));
63
+ const error = signal(null, /* @ts-ignore */
64
+ ...(ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []));
65
+ // React derives these from `window.location.search` on every render, so the
66
+ // cleanUrl rewrite below makes them read as absent. A signal reproduces that
67
+ // observable behavior after the rewrite.
68
+ const returnState = signal({
69
+ transactionId,
70
+ provider,
71
+ isReturn,
72
+ }, /* @ts-ignore */
73
+ ...(ngDevMode ? [{ debugName: "returnState" }] : /* istanbul ignore next */ []));
74
+ // One attempt per transaction id per page — an effect that re-fires (auth
75
+ // refresh, strict-mode double-invoke) must not re-POST a purchase.
76
+ let attempted = null;
77
+ // Whether the component is mounted when a verification settles.
78
+ let mounted = true;
79
+ destroyRef.onDestroy(() => {
80
+ mounted = false;
81
+ });
82
+ const verify = async () => {
83
+ const { transactionId: pendingId, provider: pendingProvider } = returnState();
84
+ const userId = state().user?.id;
85
+ if (!pendingId || !pendingProvider || !userId)
86
+ return;
87
+ status.set('verifying');
88
+ error.set(null);
89
+ try {
90
+ await http.post(`/users/${userId}/verify-payment/${pendingProvider}`, {
91
+ subscriptionId: pendingId,
92
+ });
93
+ // The plan on the cached profile is now stale — re-read it so the UI
94
+ // (plan badges, gated features) reflects what was just paid for.
95
+ await refresh().catch((refreshError) => {
96
+ // The payment is verified either way; only the cached plan may lag until the next refresh.
97
+ getLogger('useVerifyPaymentReturn').warn('Refreshing the profile after payment failed', {
98
+ error: refreshError,
99
+ });
100
+ });
101
+ if (!mounted)
102
+ return;
103
+ status.set('verified');
104
+ onVerified?.();
105
+ if (cleanUrl && typeof window !== 'undefined' && window.history?.replaceState) {
106
+ const url = new URL(window.location.href);
107
+ for (const name of TRANSACTION_ID_PARAMS)
108
+ url.searchParams.delete(name);
109
+ url.searchParams.delete('provider');
110
+ window.history.replaceState({}, '', `${url.pathname}${url.search}${url.hash}`);
111
+ // React re-reads the address bar when it re-renders for the `verified`
112
+ // status, so the cleaned URL's missing parameters are what it reports.
113
+ const cleaned = typeof window === 'undefined' ? '' : window.location.search;
114
+ const cleanedParams = new URLSearchParams(cleaned);
115
+ const cleanedId = TRANSACTION_ID_PARAMS.map((name) => cleanedParams.get(name)).find((value) => !!value) ??
116
+ null;
117
+ const cleanedProvider = cleanedParams.get('provider') || providerOption || null;
118
+ returnState.set({
119
+ transactionId: cleanedId,
120
+ provider: cleanedProvider,
121
+ isReturn: Boolean(enabled && cleanedId && cleanedProvider),
122
+ });
123
+ }
124
+ }
125
+ catch (caught) {
126
+ const failure = caught instanceof Error ? caught : new Error(String(caught));
127
+ if (!mounted) {
128
+ getLogger('useVerifyPaymentReturn').warn('Verifying the payment failed after the page unmounted', { error: failure, provider: pendingProvider });
129
+ return;
130
+ }
131
+ status.set('failed');
132
+ error.set(failure);
133
+ onError?.(failure);
134
+ }
135
+ };
136
+ // The attempt effect: React's effect over [isReturn, state.initialized,
137
+ // transactionId, userId, verify]. In Angular the auth state arrives through
138
+ // the state signal, so the effect re-runs when hydration lands.
139
+ effect(() => {
140
+ const current = state();
141
+ const currentReturn = returnState();
142
+ const userId = current.user?.id ?? null;
143
+ if (!currentReturn.isReturn || !currentReturn.transactionId)
144
+ return;
145
+ // Auth is still hydrating from the httpOnly cookie — verifying now would
146
+ // send the request unauthenticated.
147
+ if (!current.initialized || !userId)
148
+ return;
149
+ if (attempted === currentReturn.transactionId)
150
+ return;
151
+ attempted = currentReturn.transactionId;
152
+ void verify();
153
+ });
154
+ const retry = () => {
155
+ attempted = returnState().transactionId;
156
+ void verify();
157
+ };
158
+ return {
159
+ status: status.asReadonly(),
160
+ isReturn: computed(() => returnState().isReturn),
161
+ provider: computed(() => returnState().provider),
162
+ transactionId: computed(() => returnState().transactionId),
163
+ error: error.asReadonly(),
164
+ retry,
165
+ };
166
+ }
167
+ //# sourceMappingURL=use-verify-payment-return.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-verify-payment-return.js","sourceRoot":"","sources":["../../src/hooks/use-verify-payment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AS,KAAK,aAAa,CAAC,aAAa;YAAE,OAAM;QAErD,SAAS,GAAG,aAAa,CAAC,aAAa,CAAA;QACvC,KAAK,MAAM,EAAE,CAAA;IACf,CAAC,CAAC,CAAA;IAEF,MAAM,KAAK,GAAG,GAAS,EAAE;QACvB,SAAS,GAAG,WAAW,EAAE,CAAC,aAAa,CAAA;QACvC,KAAK,MAAM,EAAE,CAAA;IACf,CAAC,CAAA;IAED,OAAO;QACL,MAAM,EAAE,MAAM,CAAC,UAAU,EAAE;QAC3B,QAAQ,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC;QAChD,QAAQ,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC;QAChD,aAAa,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,aAAa,CAAC;QAC1D,KAAK,EAAE,KAAK,CAAC,UAAU,EAAE;QACzB,KAAK;KACN,CAAA;AACH,CAAC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Angular function for version and update management, mirroring `useVersion`
3
+ * from `@molecule/app-react`.
4
+ *
5
+ * @module
6
+ */
7
+ import { type Signal } from '@angular/core';
8
+ import type { UpdateCheckOptions, VersionState } from '@molecule/app-version';
9
+ /**
10
+ * What {@link useVersion} returns: every state field as a signal and every
11
+ * update action as a plain function.
12
+ */
13
+ export interface UseVersionResult {
14
+ /** The full version state. */
15
+ readonly state: Signal<VersionState>;
16
+ /** Whether an update is available. */
17
+ readonly isUpdateAvailable: Signal<boolean>;
18
+ /** Whether an update check is running. */
19
+ readonly isChecking: Signal<boolean>;
20
+ /** Whether a service worker waits to activate. */
21
+ readonly isServiceWorkerWaiting: Signal<boolean>;
22
+ /** The version an available update reports. */
23
+ readonly newVersion: Signal<string | undefined>;
24
+ /** Runs one update check; resolves with whether one was found. */
25
+ checkForUpdates: () => Promise<boolean>;
26
+ /** Applies the update (the provider reloads the page). */
27
+ applyUpdate: (options?: {
28
+ force?: boolean;
29
+ }) => void;
30
+ /** Hides the update notice until the next check finds one. */
31
+ dismissUpdate: () => void;
32
+ /** Starts periodic update checks. */
33
+ startPeriodicChecks: (options?: UpdateCheckOptions) => void;
34
+ /** Stops periodic update checks. */
35
+ stopPeriodicChecks: () => void;
36
+ }
37
+ /**
38
+ * Version state and update actions. Call it in an injection context (a
39
+ * component field initializer or constructor).
40
+ *
41
+ * Uses module-level `getProvider()` — version is a singleton, not
42
+ * registration-provided. The state snapshot is cached field-wise (like React's
43
+ * hook), so a provider that builds a fresh object per read keeps the snapshot
44
+ * stable between notifications.
45
+ *
46
+ * @returns Version state as signals and the update actions.
47
+ */
48
+ export declare function useVersion(): UseVersionResult;
49
+ //# sourceMappingURL=use-version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-version.d.ts","sourceRoot":"","sources":["../../src/hooks/use-version.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAY,KAAK,MAAM,EAAE,MAAM,eAAe,CAAA;AAErD,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAK7E;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAC/B,8BAA8B;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC,YAAY,CAAC,CAAA;IACpC,sCAAsC;IACtC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;IAC3C,0CAA0C;IAC1C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;IACpC,kDAAkD;IAClD,QAAQ,CAAC,sBAAsB,EAAE,MAAM,CAAC,OAAO,CAAC,CAAA;IAChD,+CAA+C;IAC/C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAC/C,kEAAkE;IAClE,eAAe,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;IACvC,0DAA0D;IAC1D,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,KAAK,IAAI,CAAA;IACpD,8DAA8D;IAC9D,aAAa,EAAE,MAAM,IAAI,CAAA;IACzB,qCAAqC;IACrC,mBAAmB,EAAE,CAAC,OAAO,CAAC,EAAE,kBAAkB,KAAK,IAAI,CAAA;IAC3D,oCAAoC;IACpC,kBAAkB,EAAE,MAAM,IAAI,CAAA;CAC/B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,IAAI,gBAAgB,CAwD7C"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Angular function for version and update management, mirroring `useVersion`
3
+ * from `@molecule/app-react`.
4
+ *
5
+ * @module
6
+ */
7
+ import { computed } from '@angular/core';
8
+ import { getProvider } from '@molecule/app-version';
9
+ import { useExternalStore } from './external-store.js';
10
+ /**
11
+ * Version state and update actions. Call it in an injection context (a
12
+ * component field initializer or constructor).
13
+ *
14
+ * Uses module-level `getProvider()` — version is a singleton, not
15
+ * registration-provided. The state snapshot is cached field-wise (like React's
16
+ * hook), so a provider that builds a fresh object per read keeps the snapshot
17
+ * stable between notifications.
18
+ *
19
+ * @returns Version state as signals and the update actions.
20
+ */
21
+ export function useVersion() {
22
+ const provider = getProvider();
23
+ // Cached snapshot for stability: a provider may build a fresh object per
24
+ // getState() call; the fields decide whether anything changed.
25
+ let cachedState = null;
26
+ const read = () => {
27
+ const next = provider.getState();
28
+ const prev = cachedState;
29
+ if (prev !== null &&
30
+ prev.isUpdateAvailable === next.isUpdateAvailable &&
31
+ prev.isChecking === next.isChecking &&
32
+ prev.isServiceWorkerWaiting === next.isServiceWorkerWaiting &&
33
+ prev.newVersion === next.newVersion &&
34
+ prev.buildId === next.buildId &&
35
+ prev.version === next.version) {
36
+ return prev;
37
+ }
38
+ cachedState = next;
39
+ return next;
40
+ };
41
+ const state = useExternalStore(read, (onStateChange) => {
42
+ const unsubs = [
43
+ provider.on('update-available', onStateChange),
44
+ provider.on('service-worker-waiting', onStateChange),
45
+ provider.on('service-worker-activated', onStateChange),
46
+ provider.on('check-start', onStateChange),
47
+ provider.on('check-complete', onStateChange),
48
+ provider.on('check-error', onStateChange),
49
+ ];
50
+ return () => unsubs.forEach((unsub) => unsub());
51
+ });
52
+ const checkForUpdates = () => provider.checkForUpdates();
53
+ const applyUpdate = (options) => provider.applyUpdate(options);
54
+ const dismissUpdate = () => provider.dismissUpdate();
55
+ const startPeriodicChecks = (options) => provider.startPeriodicChecks(options);
56
+ const stopPeriodicChecks = () => provider.stopPeriodicChecks();
57
+ return {
58
+ state,
59
+ isUpdateAvailable: computed(() => state().isUpdateAvailable),
60
+ isChecking: computed(() => state().isChecking),
61
+ isServiceWorkerWaiting: computed(() => state().isServiceWorkerWaiting),
62
+ newVersion: computed(() => state().newVersion),
63
+ checkForUpdates,
64
+ applyUpdate,
65
+ dismissUpdate,
66
+ startPeriodicChecks,
67
+ stopPeriodicChecks,
68
+ };
69
+ }
70
+ //# sourceMappingURL=use-version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-version.js","sourceRoot":"","sources":["../../src/hooks/use-version.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAe,MAAM,eAAe,CAAA;AAGrD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAA;AAEnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AA6BtD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU;IACxB,MAAM,QAAQ,GAAG,WAAW,EAAE,CAAA;IAE9B,yEAAyE;IACzE,+DAA+D;IAC/D,IAAI,WAAW,GAAwB,IAAI,CAAA;IAE3C,MAAM,IAAI,GAAG,GAAiB,EAAE;QAC9B,MAAM,IAAI,GAAG,QAAQ,CAAC,QAAQ,EAAE,CAAA;QAChC,MAAM,IAAI,GAAG,WAAW,CAAA;QACxB,IACE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,CAAC,QAAQ,CAAC,aAAa,EAAE,CAAA;IAC1D,MAAM,mBAAmB,GAAG,CAAC,OAA4B,EAAQ,EAAE,CACjE,QAAQ,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAA;IACvC,MAAM,kBAAkB,GAAG,GAAS,EAAE,CAAC,QAAQ,CAAC,kBAAkB,EAAE,CAAA;IAEpE,OAAO;QACL,KAAK;QACL,iBAAiB,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,iBAAiB,CAAC;QAC5D,UAAU,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,UAAU,CAAC;QAC9C,sBAAsB,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,sBAAsB,CAAC;QACtE,UAAU,EAAE,QAAQ,CAAC,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,UAAU,CAAC;QAC9C,eAAe;QACf,WAAW;QACX,aAAa;QACb,mBAAmB;QACnB,kBAAkB;KACnB,CAAA;AACH,CAAC"}
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * @module
13
13
  */
14
- import type { InterpolationValues } from '@molecule/app-i18n';
14
+ import type { InterpolationValues, TranslateOptions } from '@molecule/app-i18n';
15
15
  /**
16
16
  * Bump the locale version signal, causing all template bindings that use
17
17
  * the reactive `t()` to re-evaluate on the next change detection cycle.
@@ -34,8 +34,5 @@ export declare function bumpLocaleVersion(): void;
34
34
  * @param options.count - Pluralization count.
35
35
  * @returns Translated string
36
36
  */
37
- export declare const t: (key: string, values?: InterpolationValues, options?: {
38
- defaultValue?: string;
39
- count?: number;
40
- }) => string;
37
+ export declare const t: (key: string, values?: InterpolationValues, options?: TranslateOptions) => string;
41
38
  //# sourceMappingURL=i18n-reactive.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"i18n-reactive.d.ts","sourceRoot":"","sources":["../src/i18n-reactive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAK/E;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAExC;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,CAAC,GACZ,KAAK,MAAM,EACX,SAAS,mBAAmB,EAC5B,UAAU,gBAAgB,KACzB,MAGF,CAAA"}
@@ -1 +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"}
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,OAA0B,EAClB,EAAE;IACV,aAAa,EAAE,CAAA,CAAC,uDAAuD;IACvE,OAAO,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;AACxC,CAAC,CAAA"}
package/dist/index.d.ts CHANGED
@@ -78,9 +78,11 @@
78
78
  */
79
79
  export * from './agent-identity.js';
80
80
  export * from './chat.js';
81
+ export * from './hooks/index.js';
81
82
  export * from './i18n-reactive.js';
82
83
  export * from './providers.js';
83
84
  export * from './services/index.js';
85
+ export * from './session-ready.js';
84
86
  export * from './tokens.js';
85
87
  export * from './types.js';
86
88
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AAEH,cAAc,qBAAqB,CAAA;AACnC,cAAc,WAAW,CAAA;AACzB,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AAEH,cAAc,qBAAqB,CAAA;AACnC,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
package/dist/index.js CHANGED
@@ -78,9 +78,11 @@
78
78
  */
79
79
  export * from './agent-identity.js';
80
80
  export * from './chat.js';
81
+ export * from './hooks/index.js';
81
82
  export * from './i18n-reactive.js';
82
83
  export * from './providers.js';
83
84
  export * from './services/index.js';
85
+ export * from './session-ready.js';
84
86
  export * from './tokens.js';
85
87
  export * from './types.js';
86
88
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AAEH,cAAc,qBAAqB,CAAA;AACnC,cAAc,WAAW,CAAA;AACzB,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AAEH,cAAc,qBAAqB,CAAA;AACnC,cAAc,WAAW,CAAA;AACzB,cAAc,kBAAkB,CAAA;AAChC,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,qBAAqB,CAAA;AACnC,cAAc,oBAAoB,CAAA;AAClC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Shared injection helpers for the React-parity hook functions.
3
+ *
4
+ * @module
5
+ */
6
+ import { type InjectionToken } from '@angular/core';
7
+ /**
8
+ * Reads a service token registered by `provideMolecule` (or a `provide*`
9
+ * helper), throwing React's provider-missing error when it is absent.
10
+ *
11
+ * Angular's own missing-token failure is a `NullInjectorError`; React's hooks
12
+ * throw a plain `Error` whose message goes through i18n, so this reproduces
13
+ * React's contract under this package's error-key namespace
14
+ * (`react.error.useAuthOutsideProvider` becomes
15
+ * `angular.error.useAuthOutsideProvider`).
16
+ *
17
+ * @param token - The injection token (`AUTH_CLIENT`, `THEME_PROVIDER`, …).
18
+ * @param key - The error key's suffix after `angular.error.` (React's suffix).
19
+ * @param defaultValue - React's English error text.
20
+ * @returns The service.
21
+ * @throws {Error} When no provider registered the token.
22
+ */
23
+ export declare function injectProvider<T>(token: InjectionToken<T>, key: string, defaultValue: string): T;
24
+ //# sourceMappingURL=inject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inject.d.ts","sourceRoot":"","sources":["../src/inject.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAU,KAAK,cAAc,EAAE,MAAM,eAAe,CAAA;AAI3D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,CAAC,CAUhG"}
package/dist/inject.js ADDED
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Shared injection helpers for the React-parity hook functions.
3
+ *
4
+ * @module
5
+ */
6
+ import { inject } from '@angular/core';
7
+ import { t } from '@molecule/app-i18n';
8
+ /**
9
+ * Reads a service token registered by `provideMolecule` (or a `provide*`
10
+ * helper), throwing React's provider-missing error when it is absent.
11
+ *
12
+ * Angular's own missing-token failure is a `NullInjectorError`; React's hooks
13
+ * throw a plain `Error` whose message goes through i18n, so this reproduces
14
+ * React's contract under this package's error-key namespace
15
+ * (`react.error.useAuthOutsideProvider` becomes
16
+ * `angular.error.useAuthOutsideProvider`).
17
+ *
18
+ * @param token - The injection token (`AUTH_CLIENT`, `THEME_PROVIDER`, …).
19
+ * @param key - The error key's suffix after `angular.error.` (React's suffix).
20
+ * @param defaultValue - React's English error text.
21
+ * @returns The service.
22
+ * @throws {Error} When no provider registered the token.
23
+ */
24
+ export function injectProvider(token, key, defaultValue) {
25
+ const provider = inject(token, { optional: true });
26
+ if (!provider) {
27
+ throw new Error(t(`angular.error.${key}`, undefined, {
28
+ defaultValue,
29
+ }));
30
+ }
31
+ return provider;
32
+ }
33
+ //# sourceMappingURL=inject.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inject.js","sourceRoot":"","sources":["../src/inject.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAuB,MAAM,eAAe,CAAA;AAE3D,OAAO,EAAE,CAAC,EAAE,MAAM,oBAAoB,CAAA;AAEtC;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,cAAc,CAAI,KAAwB,EAAE,GAAW,EAAE,YAAoB;IAC3F,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IAClD,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CACb,CAAC,CAAC,iBAAiB,GAAG,EAAE,EAAE,SAAS,EAAE;YACnC,YAAY;SACb,CAAC,CACH,CAAA;IACH,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC"}
@@ -6,8 +6,11 @@
6
6
  import type { EnvironmentProviders } from '@angular/core';
7
7
  import type { ChatProvider } from '@molecule/app-ai-chat';
8
8
  import type { AuthClient } from '@molecule/app-auth';
9
+ import type { EditorProvider } from '@molecule/app-code-editor';
9
10
  import type { HttpClient } from '@molecule/app-http';
10
11
  import type { I18nProvider } from '@molecule/app-i18n';
12
+ import type { WorkspaceProvider } from '@molecule/app-ide';
13
+ import type { PreviewProvider } from '@molecule/app-live-preview';
11
14
  import type { LoggerProvider } from '@molecule/app-logger';
12
15
  import type { Router } from '@molecule/app-routing';
13
16
  import type { StateProvider } from '@molecule/app-state';
@@ -77,6 +80,27 @@ export declare function provideLogger(provider: LoggerProvider): EnvironmentProv
77
80
  * @returns Environment providers
78
81
  */
79
82
  export declare function provideChat(provider: ChatProvider): EnvironmentProviders;
83
+ /**
84
+ * Registers the IDE workspace provider useWorkspace and useWorkspaceProvider use.
85
+ *
86
+ * @param provider - Workspace provider
87
+ * @returns Environment providers
88
+ */
89
+ export declare function provideWorkspace(provider: WorkspaceProvider): EnvironmentProviders;
90
+ /**
91
+ * Registers the code editor provider useEditor and useEditorProvider use.
92
+ *
93
+ * @param provider - Editor provider
94
+ * @returns Environment providers
95
+ */
96
+ export declare function provideEditor(provider: EditorProvider): EnvironmentProviders;
97
+ /**
98
+ * Registers the live preview provider usePreview and usePreviewProvider use.
99
+ *
100
+ * @param provider - Preview provider
101
+ * @returns Environment providers
102
+ */
103
+ export declare function providePreview(provider: PreviewProvider): EnvironmentProviders;
80
104
  /**
81
105
  * Provide all molecule services at once.
82
106
  *
@@ -1 +1 @@
1
- {"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA;;;;GAI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