@molecule/app-angular 3.3.1 → 3.6.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.
- package/README.md +4049 -1255
- package/dist/chat.d.ts.map +1 -1
- package/dist/chat.js +3 -2
- package/dist/chat.js.map +1 -1
- package/dist/hooks/external-store.d.ts +32 -0
- package/dist/hooks/external-store.d.ts.map +1 -0
- package/dist/hooks/external-store.js +62 -0
- package/dist/hooks/external-store.js.map +1 -0
- package/dist/hooks/index.d.ts +24 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +24 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/use-ai-models.d.ts +53 -0
- package/dist/hooks/use-ai-models.d.ts.map +1 -0
- package/dist/hooks/use-ai-models.js +167 -0
- package/dist/hooks/use-ai-models.js.map +1 -0
- package/dist/hooks/use-async.d.ts +129 -0
- package/dist/hooks/use-async.d.ts.map +1 -0
- package/dist/hooks/use-async.js +194 -0
- package/dist/hooks/use-async.js.map +1 -0
- package/dist/hooks/use-auth-flows.d.ts +226 -0
- package/dist/hooks/use-auth-flows.d.ts.map +1 -0
- package/dist/hooks/use-auth-flows.js +481 -0
- package/dist/hooks/use-auth-flows.js.map +1 -0
- package/dist/hooks/use-auth.d.ts +85 -0
- package/dist/hooks/use-auth.d.ts.map +1 -0
- package/dist/hooks/use-auth.js +104 -0
- package/dist/hooks/use-auth.js.map +1 -0
- package/dist/hooks/use-forms.d.ts +174 -0
- package/dist/hooks/use-forms.d.ts.map +1 -0
- package/dist/hooks/use-forms.js +221 -0
- package/dist/hooks/use-forms.js.map +1 -0
- package/dist/hooks/use-http.d.ts +163 -0
- package/dist/hooks/use-http.d.ts.map +1 -0
- package/dist/hooks/use-http.js +198 -0
- package/dist/hooks/use-http.js.map +1 -0
- package/dist/hooks/use-ide.d.ts +208 -0
- package/dist/hooks/use-ide.d.ts.map +1 -0
- package/dist/hooks/use-ide.js +217 -0
- package/dist/hooks/use-ide.js.map +1 -0
- package/dist/hooks/use-logger.d.ts +40 -0
- package/dist/hooks/use-logger.d.ts.map +1 -0
- package/dist/hooks/use-logger.js +56 -0
- package/dist/hooks/use-logger.js.map +1 -0
- package/dist/hooks/use-native.d.ts +218 -0
- package/dist/hooks/use-native.d.ts.map +1 -0
- package/dist/hooks/use-native.js +173 -0
- package/dist/hooks/use-native.js.map +1 -0
- package/dist/hooks/use-profile-form.d.ts +113 -0
- package/dist/hooks/use-profile-form.d.ts.map +1 -0
- package/dist/hooks/use-profile-form.js +253 -0
- package/dist/hooks/use-profile-form.js.map +1 -0
- package/dist/hooks/use-router.d.ts +219 -0
- package/dist/hooks/use-router.d.ts.map +1 -0
- package/dist/hooks/use-router.js +266 -0
- package/dist/hooks/use-router.js.map +1 -0
- package/dist/hooks/use-storage.d.ts +142 -0
- package/dist/hooks/use-storage.d.ts.map +1 -0
- package/dist/hooks/use-storage.js +299 -0
- package/dist/hooks/use-storage.js.map +1 -0
- package/dist/hooks/use-store.d.ts +81 -0
- package/dist/hooks/use-store.d.ts.map +1 -0
- package/dist/hooks/use-store.js +143 -0
- package/dist/hooks/use-store.js.map +1 -0
- package/dist/hooks/use-theme.d.ts +59 -0
- package/dist/hooks/use-theme.d.ts.map +1 -0
- package/dist/hooks/use-theme.js +117 -0
- package/dist/hooks/use-theme.js.map +1 -0
- package/dist/hooks/use-translation.d.ts +91 -0
- package/dist/hooks/use-translation.d.ts.map +1 -0
- package/dist/hooks/use-translation.js +152 -0
- package/dist/hooks/use-translation.js.map +1 -0
- package/dist/hooks/use-verify-payment-return.d.ts +86 -0
- package/dist/hooks/use-verify-payment-return.d.ts.map +1 -0
- package/dist/hooks/use-verify-payment-return.js +167 -0
- package/dist/hooks/use-verify-payment-return.js.map +1 -0
- package/dist/hooks/use-version.d.ts +49 -0
- package/dist/hooks/use-version.d.ts.map +1 -0
- package/dist/hooks/use-version.js +70 -0
- package/dist/hooks/use-version.js.map +1 -0
- package/dist/i18n-reactive.d.ts +2 -5
- package/dist/i18n-reactive.d.ts.map +1 -1
- package/dist/i18n-reactive.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/inject.d.ts +24 -0
- package/dist/inject.d.ts.map +1 -0
- package/dist/inject.js +33 -0
- package/dist/inject.js.map +1 -0
- package/dist/link.d.ts +63 -0
- package/dist/link.d.ts.map +1 -0
- package/dist/link.js +82 -0
- package/dist/link.js.map +1 -0
- package/dist/maybe-signal.d.ts +26 -0
- package/dist/maybe-signal.d.ts.map +1 -0
- package/dist/maybe-signal.js +20 -0
- package/dist/maybe-signal.js.map +1 -0
- package/dist/providers.d.ts +24 -0
- package/dist/providers.d.ts.map +1 -1
- package/dist/providers.js +44 -3
- package/dist/providers.js.map +1 -1
- package/dist/session-ready.d.ts +41 -0
- package/dist/session-ready.d.ts.map +1 -0
- package/dist/session-ready.js +79 -0
- package/dist/session-ready.js.map +1 -0
- package/dist/tokens.d.ts +15 -0
- package/dist/tokens.d.ts.map +1 -1
- package/dist/tokens.js +12 -0
- package/dist/tokens.js.map +1 -1
- package/dist/types.d.ts +14 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Angular functions for theming, mirroring `useTheme`, `useThemeProvider`,
|
|
3
|
+
* `useCurrentTheme`, `useThemeMode` and `useThemeColors` from
|
|
4
|
+
* `@molecule/app-react`.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { computed, DestroyRef, inject, signal } from '@angular/core';
|
|
9
|
+
import { injectProvider } from '../inject.js';
|
|
10
|
+
import { THEME_PROVIDER } from '../tokens.js';
|
|
11
|
+
/**
|
|
12
|
+
* The theme provider registered by `provideMolecule({ theme })` or
|
|
13
|
+
* `provideTheme`. Call it in an injection context.
|
|
14
|
+
*
|
|
15
|
+
* @returns The theme provider.
|
|
16
|
+
* @throws {Error} When no theme provider is registered.
|
|
17
|
+
*/
|
|
18
|
+
export function useThemeProvider() {
|
|
19
|
+
return injectProvider(THEME_PROVIDER, 'useThemeOutsideProvider', 'useThemeProvider must be used within a ThemeProvider');
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Subscribes to a theme provider, supporting both `subscribe` and the legacy
|
|
23
|
+
* `onThemeChange` method, exactly like React's hook.
|
|
24
|
+
*
|
|
25
|
+
* @param provider - The theme provider to subscribe to.
|
|
26
|
+
* @param callback - Listener invoked whenever the active theme changes.
|
|
27
|
+
* @returns An unsubscribe function that removes the listener.
|
|
28
|
+
*/
|
|
29
|
+
function subscribeToThemeProvider(provider, callback) {
|
|
30
|
+
if (typeof provider.subscribe === 'function') {
|
|
31
|
+
return provider.subscribe(callback);
|
|
32
|
+
}
|
|
33
|
+
if (typeof provider
|
|
34
|
+
.onThemeChange === 'function') {
|
|
35
|
+
return provider.onThemeChange(callback);
|
|
36
|
+
}
|
|
37
|
+
return () => { };
|
|
38
|
+
}
|
|
39
|
+
/** Reads the provider's current theme name, `getThemeName` when it has one. */
|
|
40
|
+
const themeNameOf = (provider) => typeof provider.getThemeName ===
|
|
41
|
+
'function'
|
|
42
|
+
? provider.getThemeName()
|
|
43
|
+
: provider.getTheme().name;
|
|
44
|
+
/**
|
|
45
|
+
* Theme state and actions. Call it in an injection context (a component field
|
|
46
|
+
* initializer or constructor).
|
|
47
|
+
*
|
|
48
|
+
* @returns The theme, its name and mode as signals, and the actions.
|
|
49
|
+
*/
|
|
50
|
+
export function useTheme() {
|
|
51
|
+
const provider = useThemeProvider();
|
|
52
|
+
// The provider as an external store, read through a cache: a provider that
|
|
53
|
+
// builds a fresh theme object per call keeps the snapshot stable between
|
|
54
|
+
// notifications.
|
|
55
|
+
const theme = signal(provider.getTheme(), /* @ts-ignore */
|
|
56
|
+
...(ngDevMode ? [{ debugName: "theme" }] : /* istanbul ignore next */ []));
|
|
57
|
+
const themeName = signal(themeNameOf(provider), /* @ts-ignore */
|
|
58
|
+
...(ngDevMode ? [{ debugName: "themeName" }] : /* istanbul ignore next */ []));
|
|
59
|
+
const refresh = () => {
|
|
60
|
+
theme.set(provider.getTheme());
|
|
61
|
+
themeName.set(themeNameOf(provider));
|
|
62
|
+
};
|
|
63
|
+
const stop = subscribeToThemeProvider(provider, refresh);
|
|
64
|
+
inject(DestroyRef).onDestroy(stop);
|
|
65
|
+
const setTheme = (name) => {
|
|
66
|
+
provider.setTheme(name);
|
|
67
|
+
};
|
|
68
|
+
const toggleTheme = () => {
|
|
69
|
+
// Prefer the provider's purpose-built light/dark toggle; the index-cycle
|
|
70
|
+
// below stays only as a fallback for providers predating `toggleMode`.
|
|
71
|
+
if (typeof provider.toggleMode === 'function') {
|
|
72
|
+
provider.toggleMode();
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
const themes = provider.getThemes?.() ?? [];
|
|
76
|
+
if (themes.length === 0)
|
|
77
|
+
return;
|
|
78
|
+
const currentName = themeNameOf(provider);
|
|
79
|
+
const currentIndex = themes.findIndex((entry) => typeof entry === 'string' ? entry === currentName : entry.name === currentName);
|
|
80
|
+
const nextIndex = (currentIndex + 1) % themes.length;
|
|
81
|
+
const next = themes[nextIndex];
|
|
82
|
+
provider.setTheme(typeof next === 'string' ? next : next.name);
|
|
83
|
+
};
|
|
84
|
+
return {
|
|
85
|
+
theme: theme.asReadonly(),
|
|
86
|
+
themeName: themeName.asReadonly(),
|
|
87
|
+
mode: computed(() => theme().mode),
|
|
88
|
+
setTheme,
|
|
89
|
+
toggleTheme,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* The current theme object alone. Call it in an injection context.
|
|
94
|
+
*
|
|
95
|
+
* @returns A signal of the current theme.
|
|
96
|
+
*/
|
|
97
|
+
export function useCurrentTheme() {
|
|
98
|
+
return useTheme().theme;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* The current theme mode alone. Call it in an injection context.
|
|
102
|
+
*
|
|
103
|
+
* @returns A signal of `'light'` or `'dark'`.
|
|
104
|
+
*/
|
|
105
|
+
export function useThemeMode() {
|
|
106
|
+
return useTheme().mode;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* The current theme's color palette. Call it in an injection context.
|
|
110
|
+
*
|
|
111
|
+
* @returns A signal of the current theme's colors.
|
|
112
|
+
*/
|
|
113
|
+
export function useThemeColors() {
|
|
114
|
+
const { theme } = useTheme();
|
|
115
|
+
return computed(() => theme().colors);
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=use-theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-theme.js","sourceRoot":"","sources":["../../src/hooks/use-theme.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAe,MAAM,EAAE,MAAM,eAAe,CAAA;AAIjF,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAE7C;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB;IAC9B,OAAO,cAAc,CACnB,cAAc,EACd,yBAAyB,EACzB,sDAAsD,CACvD,CAAA;AACH,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,wBAAwB,CAAC,QAAuB,EAAE,QAAoB;IAC7E,IAAI,OAAO,QAAQ,CAAC,SAAS,KAAK,UAAU,EAAE,CAAC;QAC7C,OAAO,QAAQ,CAAC,SAAS,CAAC,QAA6C,CAAC,CAAA;IAC1E,CAAC;IACD,IACE,OAAQ,QAAuE;SAC5E,aAAa,KAAK,UAAU,EAC/B,CAAC;QACD,OACE,QACD,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;IAC3B,CAAC;IACD,OAAO,GAAG,EAAE,GAAE,CAAC,CAAA;AACjB,CAAC;AAED,+EAA+E;AAC/E,MAAM,WAA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3
|
+
* `useT`, `useLocale`, `useDirection`, `useI18nError` and `useI18nProvider`
|
|
4
|
+
* from `@molecule/app-react`.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { type Signal } from '@angular/core';
|
|
9
|
+
import type { DateFormatOptions, I18nProvider, InterpolationValues, NumberFormatOptions, TranslateOptions } from '@molecule/app-i18n';
|
|
10
|
+
import { type MaybeSignal } from '../maybe-signal.js';
|
|
11
|
+
/**
|
|
12
|
+
* The i18n provider registered by `provideMolecule({ i18n })` or
|
|
13
|
+
* `provideI18n`, otherwise the bonded `@molecule/app-i18n` provider — the one
|
|
14
|
+
* the static `t` reads. Call it in an injection context.
|
|
15
|
+
*
|
|
16
|
+
* @returns The i18n provider from the injector, or the bonded provider.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useI18nProvider(): I18nProvider;
|
|
19
|
+
/**
|
|
20
|
+
* What {@link useTranslation} returns.
|
|
21
|
+
*/
|
|
22
|
+
export interface UseTranslationResult {
|
|
23
|
+
/**
|
|
24
|
+
* The translation function. A plain function (a signal would be read as the
|
|
25
|
+
* method itself) that reads the provider on every call AND the locale
|
|
26
|
+
* notifications signal, so a template, `computed` or `effect` that calls it
|
|
27
|
+
* re-runs on a locale switch the way React re-renders on one.
|
|
28
|
+
*/
|
|
29
|
+
readonly t: I18nProvider['t'];
|
|
30
|
+
/** The active locale code. */
|
|
31
|
+
readonly locale: Signal<string>;
|
|
32
|
+
/** Switches the active locale; resolves when the provider has switched it. */
|
|
33
|
+
setLocale: I18nProvider['setLocale'];
|
|
34
|
+
/** The available locales; a fresh list once per notification. */
|
|
35
|
+
readonly locales: Signal<I18nProvider['getLocales'] extends () => infer L ? L : never>;
|
|
36
|
+
/** Formats a number for the active locale. */
|
|
37
|
+
formatNumber: (value: number, options?: NumberFormatOptions) => string;
|
|
38
|
+
/** Formats a date for the active locale. */
|
|
39
|
+
formatDate: (value: Date | number | string, options?: DateFormatOptions) => string;
|
|
40
|
+
/** The active locale's text direction. */
|
|
41
|
+
readonly direction: Signal<'ltr' | 'rtl'>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Translation, locale state and the formatters. Call it in an injection
|
|
45
|
+
* context (a component field initializer or constructor).
|
|
46
|
+
*
|
|
47
|
+
* @returns The translation function, the locale fields and the formatters.
|
|
48
|
+
*/
|
|
49
|
+
export declare function useTranslation(): UseTranslationResult;
|
|
50
|
+
/**
|
|
51
|
+
* The translation function alone. Call it in an injection context.
|
|
52
|
+
*
|
|
53
|
+
* The returned function keeps ONE identity for as long as the provider is
|
|
54
|
+
* unchanged; it reads the active locale and the locale notifications on
|
|
55
|
+
* every CALL, so its text is current and its caller re-runs on a switch.
|
|
56
|
+
*
|
|
57
|
+
* Call it in either of two compatible forms:
|
|
58
|
+
* - `t(key, values?, options?)` — the provider signature.
|
|
59
|
+
* - `t(key, fallback, options?)` — a string second argument is the
|
|
60
|
+
* `defaultValue`.
|
|
61
|
+
*
|
|
62
|
+
* @returns The translation function.
|
|
63
|
+
*/
|
|
64
|
+
export declare function useT(): (key: string, valuesOrDefault?: InterpolationValues | string, options?: TranslateOptions) => string;
|
|
65
|
+
/**
|
|
66
|
+
* The active locale code alone. Call it in an injection context.
|
|
67
|
+
*
|
|
68
|
+
* @returns A signal of the locale code.
|
|
69
|
+
*/
|
|
70
|
+
export declare function useLocale(): Signal<string>;
|
|
71
|
+
/**
|
|
72
|
+
* The active locale's text direction alone. Call it in an injection context.
|
|
73
|
+
*
|
|
74
|
+
* @returns A signal of `'ltr'` or `'rtl'`.
|
|
75
|
+
*/
|
|
76
|
+
export declare function useDirection(): Signal<'ltr' | 'rtl'>;
|
|
77
|
+
/**
|
|
78
|
+
* Translates an error at read time, so the displayed message follows locale
|
|
79
|
+
* changes. An `I18nError` is translated through its key (its own message as
|
|
80
|
+
* the default value); a plain `Error` returns its message unchanged; no error
|
|
81
|
+
* returns `null`. Call it in an injection context.
|
|
82
|
+
*
|
|
83
|
+
* The error may be a signal: the message then follows a changed error on the
|
|
84
|
+
* same component, the way React re-renders `useI18nError` with a new argument.
|
|
85
|
+
*
|
|
86
|
+
* @param error - The error to translate, or `null`/`undefined` (or a signal of
|
|
87
|
+
* it).
|
|
88
|
+
* @returns A signal of the error's display text, or `null`.
|
|
89
|
+
*/
|
|
90
|
+
export declare function useI18nError(error: MaybeSignal<Error | null | undefined>): Signal<string | null>;
|
|
91
|
+
//# sourceMappingURL=use-translation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-translation.d.ts","sourceRoot":"","sources":["../../src/hooks/use-translation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAgC,KAAK,MAAM,EAAU,MAAM,eAAe,CAAA;AAEjF,OAAO,KAAK,EACV,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,oBAAoB,CAAA;AAG3B,OAAO,EAAE,KAAK,WAAW,EAAmB,MAAM,oBAAoB,CAAA;AAGtE;;;;;;GAMG;AACH,wBAAgB,eAAe,IAAI,YAAY,CAG9C;AAiBD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;;OAKG;IACH,QAAQ,CAAC,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC,CAAA;IAC7B,8BAA8B;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;IAC/B,8EAA8E;IAC9E,SAAS,EAAE,YAAY,CAAC,WAAW,CAAC,CAAA;IACpC,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,YAAY,CAAC,YAAY,CAAC,SAAS,MAAM,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,CAAA;IACtF,8CAA8C;IAC9C,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,KAAK,MAAM,CAAA;IACtE,4CAA4C;IAC5C,UAAU,EAAE,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,KAAK,MAAM,CAAA;IAClF,0CAA0C;IAC1C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC,CAAA;CAC1C;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,IAAI,oBAAoB,CA6CrD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,IAAI,IAAI,CACtB,GAAG,EAAE,MAAM,EACX,eAAe,CAAC,EAAE,mBAAmB,GAAG,MAAM,EAC9C,OAAO,CAAC,EAAE,gBAAgB,KACvB,MAAM,CAcV;AAED;;;;GAIG;AACH,wBAAgB,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,CAE1C;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC,CAEpD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,CAchG"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Angular functions for internationalization, mirroring `useTranslation`,
|
|
3
|
+
* `useT`, `useLocale`, `useDirection`, `useI18nError` and `useI18nProvider`
|
|
4
|
+
* from `@molecule/app-react`.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { computed, DestroyRef, inject, signal } from '@angular/core';
|
|
9
|
+
import { getProvider, I18nError } from '@molecule/app-i18n';
|
|
10
|
+
import { readMaybeSignal } from '../maybe-signal.js';
|
|
11
|
+
import { I18N_PROVIDER } from '../tokens.js';
|
|
12
|
+
/**
|
|
13
|
+
* The i18n provider registered by `provideMolecule({ i18n })` or
|
|
14
|
+
* `provideI18n`, otherwise the bonded `@molecule/app-i18n` provider — the one
|
|
15
|
+
* the static `t` reads. Call it in an injection context.
|
|
16
|
+
*
|
|
17
|
+
* @returns The i18n provider from the injector, or the bonded provider.
|
|
18
|
+
*/
|
|
19
|
+
export function useI18nProvider() {
|
|
20
|
+
const provided = inject(I18N_PROVIDER, { optional: true });
|
|
21
|
+
return provided ?? getProvider();
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Subscribes to the provider's locale notifications and returns a signal that
|
|
25
|
+
* changes on every notification (a locale switch, `addTranslations` for the
|
|
26
|
+
* active locale, a revision bump).
|
|
27
|
+
*
|
|
28
|
+
* @param provider - The i18n provider.
|
|
29
|
+
* @returns A signal that changes on every locale notification.
|
|
30
|
+
*/
|
|
31
|
+
function useLocaleNotifications(provider) {
|
|
32
|
+
const notifications = signal(0, /* @ts-ignore */
|
|
33
|
+
...(ngDevMode ? [{ debugName: "notifications" }] : /* istanbul ignore next */ []));
|
|
34
|
+
const stop = provider.onLocaleChange(() => notifications.update((count) => count + 1));
|
|
35
|
+
inject(DestroyRef).onDestroy(stop);
|
|
36
|
+
return notifications.asReadonly();
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Translation, locale state and the formatters. Call it in an injection
|
|
40
|
+
* context (a component field initializer or constructor).
|
|
41
|
+
*
|
|
42
|
+
* @returns The translation function, the locale fields and the formatters.
|
|
43
|
+
*/
|
|
44
|
+
export function useTranslation() {
|
|
45
|
+
const provider = useI18nProvider();
|
|
46
|
+
const notifications = useLocaleNotifications(provider);
|
|
47
|
+
// Read from the provider on every read, never copied into state: a replaced
|
|
48
|
+
// provider shows its own values immediately.
|
|
49
|
+
const locale = computed(() => {
|
|
50
|
+
void notifications();
|
|
51
|
+
return provider.getLocale();
|
|
52
|
+
}, /* @ts-ignore */
|
|
53
|
+
...(ngDevMode ? [{ debugName: "locale" }] : /* istanbul ignore next */ []));
|
|
54
|
+
const direction = computed(() => {
|
|
55
|
+
void notifications();
|
|
56
|
+
return provider.getDirection();
|
|
57
|
+
}, /* @ts-ignore */
|
|
58
|
+
...(ngDevMode ? [{ debugName: "direction" }] : /* istanbul ignore next */ []));
|
|
59
|
+
// A new list once per notification, the same list otherwise, so a computed
|
|
60
|
+
// that depends on it stays stable.
|
|
61
|
+
const locales = computed(() => {
|
|
62
|
+
void notifications();
|
|
63
|
+
return provider.getLocales();
|
|
64
|
+
}, /* @ts-ignore */
|
|
65
|
+
...(ngDevMode ? [{ debugName: "locales" }] : /* istanbul ignore next */ []));
|
|
66
|
+
// A plain function (never a signal: the conformance kit reads a method field
|
|
67
|
+
// by calling the value itself, and an Angular signal IS a function). Reading
|
|
68
|
+
// the notifications signal inside it makes the CALLER depend on the locale, so
|
|
69
|
+
// a view that renders `t(…)` (directly or through a method) refreshes on a
|
|
70
|
+
// switch without reading `locale()` itself.
|
|
71
|
+
const t = (key, values, options) => {
|
|
72
|
+
void notifications();
|
|
73
|
+
return provider.t(key, values, options);
|
|
74
|
+
};
|
|
75
|
+
// The provider's own promise is returned (a caller may await the switch, and
|
|
76
|
+
// a rejected switch surfaces to the caller exactly like React's).
|
|
77
|
+
const setLocale = (code) => provider.setLocale(code);
|
|
78
|
+
const formatNumber = (value, options) => provider.formatNumber(value, options);
|
|
79
|
+
const formatDate = (value, options) => provider.formatDate(value, options);
|
|
80
|
+
return { t, locale, setLocale, locales, formatNumber, formatDate, direction };
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* The translation function alone. Call it in an injection context.
|
|
84
|
+
*
|
|
85
|
+
* The returned function keeps ONE identity for as long as the provider is
|
|
86
|
+
* unchanged; it reads the active locale and the locale notifications on
|
|
87
|
+
* every CALL, so its text is current and its caller re-runs on a switch.
|
|
88
|
+
*
|
|
89
|
+
* Call it in either of two compatible forms:
|
|
90
|
+
* - `t(key, values?, options?)` — the provider signature.
|
|
91
|
+
* - `t(key, fallback, options?)` — a string second argument is the
|
|
92
|
+
* `defaultValue`.
|
|
93
|
+
*
|
|
94
|
+
* @returns The translation function.
|
|
95
|
+
*/
|
|
96
|
+
export function useT() {
|
|
97
|
+
const provider = useI18nProvider();
|
|
98
|
+
const notifications = useLocaleNotifications(provider);
|
|
99
|
+
return (key, valuesOrDefault, options) => {
|
|
100
|
+
// The caller depends on the locale through this read (see useTranslation).
|
|
101
|
+
void notifications();
|
|
102
|
+
return typeof valuesOrDefault === 'string'
|
|
103
|
+
? provider.t(key, undefined, { ...options, defaultValue: valuesOrDefault })
|
|
104
|
+
: provider.t(key, valuesOrDefault, options);
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The active locale code alone. Call it in an injection context.
|
|
109
|
+
*
|
|
110
|
+
* @returns A signal of the locale code.
|
|
111
|
+
*/
|
|
112
|
+
export function useLocale() {
|
|
113
|
+
return useTranslation().locale;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The active locale's text direction alone. Call it in an injection context.
|
|
117
|
+
*
|
|
118
|
+
* @returns A signal of `'ltr'` or `'rtl'`.
|
|
119
|
+
*/
|
|
120
|
+
export function useDirection() {
|
|
121
|
+
return useTranslation().direction;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Translates an error at read time, so the displayed message follows locale
|
|
125
|
+
* changes. An `I18nError` is translated through its key (its own message as
|
|
126
|
+
* the default value); a plain `Error` returns its message unchanged; no error
|
|
127
|
+
* returns `null`. Call it in an injection context.
|
|
128
|
+
*
|
|
129
|
+
* The error may be a signal: the message then follows a changed error on the
|
|
130
|
+
* same component, the way React re-renders `useI18nError` with a new argument.
|
|
131
|
+
*
|
|
132
|
+
* @param error - The error to translate, or `null`/`undefined` (or a signal of
|
|
133
|
+
* it).
|
|
134
|
+
* @returns A signal of the error's display text, or `null`.
|
|
135
|
+
*/
|
|
136
|
+
export function useI18nError(error) {
|
|
137
|
+
const provider = useI18nProvider();
|
|
138
|
+
const notifications = useLocaleNotifications(provider);
|
|
139
|
+
return computed(() => {
|
|
140
|
+
// The notification count is the recompute key: the provider is read live
|
|
141
|
+
// inside, so the text follows locale changes like React's render-time read.
|
|
142
|
+
void notifications();
|
|
143
|
+
const current = readMaybeSignal(error);
|
|
144
|
+
if (!current)
|
|
145
|
+
return null;
|
|
146
|
+
if (current instanceof I18nError) {
|
|
147
|
+
return provider.t(current.i18nKey, current.i18nValues, { defaultValue: current.message });
|
|
148
|
+
}
|
|
149
|
+
return current.message;
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=use-translation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-translation.js","sourceRoot":"","sources":["../../src/hooks/use-translation.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAe,MAAM,EAAE,MAAM,eAAe,CAAA;AASjF,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAE3D,OAAO,EAAoB,eAAe,EAAE,MAAM,oBAAoB,CAAA;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAE5C;;;;;;GAMG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,QAAQ,GAAG,MAAM,CAAC,aAAa,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAA;IAC1D,OAAO,QAAQ,IAAI,WAAW,EAAE,CAAA;AAClC,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,sBAAsB,CAAC,QAAsB;IACpD,MAAM,aAAa,GAAG,MAAM,CAAC,CAAC;sFAAC,CAAA;IAC/B,MAAM,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAA;IACtF,MAAM,CAAC,UAAU,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IAClC,OAAO,aAAa,CAAC,U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Ae,CAAC,KAAK,CAAC,CAAA;QACtC,IAAI,CAAC,OAAO;YAAE,OAAO,IAAI,CAAA;QACzB,IAAI,OAAO,YAAY,SAAS,EAAE,CAAC;YACjC,OAAO,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,UAAU,EAAE,EAAE,YAAY,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;QAC3F,CAAC;QACD,OAAO,OAAO,CAAC,OAAO,CAAA;IACxB,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -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-return.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAe,MAAM,EAAE,MAAM,eAAe,CAAA;AAGz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