@alepha/react 0.11.11 → 0.11.12
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 +1 -183
- package/dist/auth/index.browser.js +1460 -0
- package/dist/auth/index.browser.js.map +1 -0
- package/dist/auth/index.cjs +3647 -0
- package/dist/auth/index.cjs.map +1 -0
- package/dist/auth/index.d.cts +564 -0
- package/dist/auth/index.d.cts.map +1 -0
- package/dist/auth/index.d.ts +564 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +3615 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/{index.browser.js → core/index.browser.js} +36 -35
- package/dist/core/index.browser.js.map +1 -0
- package/dist/{index.cjs → core/index.cjs} +141 -140
- package/dist/core/index.cjs.map +1 -0
- package/dist/{index.d.cts → core/index.d.cts} +68 -68
- package/dist/core/index.d.cts.map +1 -0
- package/dist/{index.d.ts → core/index.d.ts} +68 -68
- package/dist/core/index.d.ts.map +1 -0
- package/dist/{index.js → core/index.js} +39 -38
- package/dist/core/index.js.map +1 -0
- package/dist/form/index.cjs +2054 -0
- package/dist/form/index.cjs.map +1 -0
- package/dist/form/index.d.cts +211 -0
- package/dist/form/index.d.cts.map +1 -0
- package/dist/form/index.d.ts +211 -0
- package/dist/form/index.d.ts.map +1 -0
- package/dist/form/index.js +2026 -0
- package/dist/form/index.js.map +1 -0
- package/dist/head/index.browser.js +1503 -0
- package/dist/head/index.browser.js.map +1 -0
- package/dist/head/index.cjs +1908 -0
- package/dist/head/index.cjs.map +1 -0
- package/dist/head/index.d.cts +595 -0
- package/dist/head/index.d.cts.map +1 -0
- package/dist/head/index.d.ts +601 -0
- package/dist/head/index.d.ts.map +1 -0
- package/dist/head/index.js +1880 -0
- package/dist/head/index.js.map +1 -0
- package/dist/i18n/index.cjs +1886 -0
- package/dist/i18n/index.cjs.map +1 -0
- package/dist/i18n/index.d.cts +168 -0
- package/dist/i18n/index.d.cts.map +1 -0
- package/dist/i18n/index.d.ts +168 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +1857 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/websocket/index.cjs +1774 -0
- package/dist/websocket/index.cjs.map +1 -0
- package/dist/websocket/index.d.cts +118 -0
- package/dist/websocket/index.d.cts.map +1 -0
- package/dist/websocket/index.d.ts +118 -0
- package/dist/websocket/index.d.ts.map +1 -0
- package/dist/websocket/index.js +1750 -0
- package/dist/websocket/index.js.map +1 -0
- package/package.json +89 -67
- package/src/auth/descriptors/$auth.ts +436 -0
- package/src/auth/descriptors/$authApple.ts +8 -0
- package/src/auth/descriptors/$authGithub.ts +81 -0
- package/src/auth/descriptors/$authGoogle.ts +38 -0
- package/src/auth/errors/SessionExpiredError.ts +6 -0
- package/src/auth/hooks/useAuth.ts +31 -0
- package/src/auth/index.browser.ts +16 -0
- package/src/auth/index.shared.ts +3 -0
- package/src/auth/index.ts +47 -0
- package/src/auth/providers/ReactAuthProvider.ts +629 -0
- package/src/auth/schemas/tokenResponseSchema.ts +11 -0
- package/src/auth/schemas/tokensSchema.ts +21 -0
- package/src/auth/schemas/userinfoResponseSchema.ts +10 -0
- package/src/auth/services/ReactAuth.ts +124 -0
- package/src/{components → core/components}/ErrorViewer.tsx +3 -2
- package/src/{components → core/components}/NestedView.tsx +1 -1
- package/src/{contexts → core/contexts}/AlephaContext.ts +1 -1
- package/src/{descriptors → core/descriptors}/$page.ts +4 -4
- package/src/{hooks → core/hooks}/useAction.ts +1 -1
- package/src/{hooks → core/hooks}/useAlepha.ts +1 -1
- package/src/{hooks → core/hooks}/useClient.ts +1 -1
- package/src/{hooks → core/hooks}/useEvents.ts +1 -1
- package/src/{hooks → core/hooks}/useInject.ts +1 -1
- package/src/{hooks → core/hooks}/useQueryParams.ts +1 -1
- package/src/{hooks → core/hooks}/useRouterState.ts +1 -1
- package/src/{hooks → core/hooks}/useSchema.ts +3 -3
- package/src/{hooks → core/hooks}/useStore.ts +2 -2
- package/src/{index.browser.ts → core/index.browser.ts} +4 -4
- package/src/{index.ts → core/index.ts} +6 -6
- package/src/{providers → core/providers}/ReactBrowserProvider.ts +6 -6
- package/src/{providers → core/providers}/ReactBrowserRendererProvider.ts +2 -2
- package/src/{providers → core/providers}/ReactBrowserRouterProvider.ts +3 -3
- package/src/{providers → core/providers}/ReactPageProvider.ts +3 -3
- package/src/{providers → core/providers}/ReactServerProvider.ts +7 -7
- package/src/{services → core/services}/ReactPageServerService.ts +2 -2
- package/src/{services → core/services}/ReactPageService.ts +1 -1
- package/src/{services → core/services}/ReactRouter.ts +1 -1
- package/src/form/components/FormState.tsx +17 -0
- package/src/form/hooks/useForm.ts +47 -0
- package/src/form/hooks/useFormState.ts +130 -0
- package/src/form/index.ts +38 -0
- package/src/form/services/FormModel.ts +548 -0
- package/src/head/descriptors/$head.ts +25 -0
- package/src/head/hooks/useHead.ts +62 -0
- package/src/head/index.browser.ts +25 -0
- package/src/head/index.ts +47 -0
- package/src/head/interfaces/Head.ts +46 -0
- package/src/head/providers/BrowserHeadProvider.ts +105 -0
- package/src/head/providers/HeadProvider.ts +73 -0
- package/src/head/providers/ServerHeadProvider.ts +109 -0
- package/src/i18n/README.md +76 -0
- package/src/i18n/components/Localize.tsx +35 -0
- package/src/i18n/descriptors/$dictionary.ts +65 -0
- package/src/i18n/hooks/useI18n.ts +18 -0
- package/src/i18n/index.ts +34 -0
- package/src/i18n/providers/I18nProvider.ts +277 -0
- package/src/websocket/hooks/useRoom.tsx +223 -0
- package/src/websocket/index.ts +7 -0
- package/dist/index.browser.js.map +0 -1
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- /package/src/{components → core/components}/ClientOnly.tsx +0 -0
- /package/src/{components → core/components}/ErrorBoundary.tsx +0 -0
- /package/src/{components → core/components}/Link.tsx +0 -0
- /package/src/{components → core/components}/NotFound.tsx +0 -0
- /package/src/{contexts → core/contexts}/RouterLayerContext.ts +0 -0
- /package/src/{errors → core/errors}/Redirection.ts +0 -0
- /package/src/{hooks → core/hooks}/useActive.ts +0 -0
- /package/src/{hooks → core/hooks}/useRouter.ts +0 -0
- /package/src/{index.shared.ts → core/index.shared.ts} +0 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import * as alepha1 from "alepha";
|
|
2
|
+
import { Alepha, Descriptor, KIND, TypeBoxError } from "alepha";
|
|
3
|
+
import { DateTime, DateTimeProvider } from "alepha/datetime";
|
|
4
|
+
import * as alepha_logger0 from "alepha/logger";
|
|
5
|
+
import * as alepha_server_cookies0 from "alepha/server/cookies";
|
|
6
|
+
import * as typebox0 from "typebox";
|
|
7
|
+
|
|
8
|
+
//#region src/i18n/components/Localize.d.ts
|
|
9
|
+
interface LocalizeProps {
|
|
10
|
+
value: string | number | Date | DateTime | TypeBoxError;
|
|
11
|
+
/**
|
|
12
|
+
* Options for number formatting (when value is a number)
|
|
13
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat
|
|
14
|
+
*/
|
|
15
|
+
number?: Intl.NumberFormatOptions;
|
|
16
|
+
/**
|
|
17
|
+
* Options for date formatting (when value is a Date or DateTime)
|
|
18
|
+
* Can be:
|
|
19
|
+
* - A dayjs format string (e.g., "LLL", "YYYY-MM-DD", "dddd, MMMM D YYYY")
|
|
20
|
+
* - "fromNow" for relative time (e.g., "2 hours ago")
|
|
21
|
+
* - Intl.DateTimeFormatOptions for native formatting
|
|
22
|
+
* @see https://day.js.org/docs/en/display/format
|
|
23
|
+
* @see https://day.js.org/docs/en/display/from-now
|
|
24
|
+
*/
|
|
25
|
+
date?: string | "fromNow" | Intl.DateTimeFormatOptions;
|
|
26
|
+
/**
|
|
27
|
+
* Timezone to display dates in (when value is a Date or DateTime)
|
|
28
|
+
* Uses IANA timezone names (e.g., "America/New_York", "Europe/Paris", "Asia/Tokyo")
|
|
29
|
+
* @see https://day.js.org/docs/en/timezone/timezone
|
|
30
|
+
*/
|
|
31
|
+
timezone?: string;
|
|
32
|
+
}
|
|
33
|
+
declare const Localize: (props: LocalizeProps) => string;
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/i18n/hooks/useI18n.d.ts
|
|
36
|
+
/**
|
|
37
|
+
* Hook to access the i18n service.
|
|
38
|
+
*/
|
|
39
|
+
declare const useI18n: <S extends object, K$1 extends keyof ServiceDictionary<S>>() => I18nProvider<S, K$1>;
|
|
40
|
+
type ServiceDictionary<T extends object> = { [K in keyof T]: T[K] extends DictionaryDescriptor<infer U> ? U : never };
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/i18n/providers/I18nProvider.d.ts
|
|
43
|
+
declare class I18nProvider<S extends object, K$1 extends keyof ServiceDictionary<S>> {
|
|
44
|
+
protected logger: alepha_logger0.Logger;
|
|
45
|
+
protected alepha: Alepha;
|
|
46
|
+
protected dateTimeProvider: DateTimeProvider;
|
|
47
|
+
protected cookie: alepha_server_cookies0.AbstractCookieDescriptor<typebox0.TString>;
|
|
48
|
+
readonly registry: Array<{
|
|
49
|
+
name: string;
|
|
50
|
+
lang: string;
|
|
51
|
+
loader: () => Promise<Record<string, string>>;
|
|
52
|
+
translations: Record<string, string>;
|
|
53
|
+
}>;
|
|
54
|
+
options: {
|
|
55
|
+
fallbackLang: string;
|
|
56
|
+
};
|
|
57
|
+
dateFormat: {
|
|
58
|
+
format: (value: Date) => string;
|
|
59
|
+
};
|
|
60
|
+
numberFormat: {
|
|
61
|
+
format: (value: number) => string;
|
|
62
|
+
};
|
|
63
|
+
get languages(): string[];
|
|
64
|
+
constructor();
|
|
65
|
+
protected readonly onRender: alepha1.HookDescriptor<"server:onRequest">;
|
|
66
|
+
protected readonly onStart: alepha1.HookDescriptor<"start">;
|
|
67
|
+
protected refreshLocale(): void;
|
|
68
|
+
setLang: (lang: string) => Promise<void>;
|
|
69
|
+
protected readonly mutate: alepha1.HookDescriptor<"state:mutate">;
|
|
70
|
+
get lang(): string;
|
|
71
|
+
translate: (key: string, args?: string[]) => string;
|
|
72
|
+
readonly l: (value: I18nLocalizeType, options?: I18nLocalizeOptions) => string;
|
|
73
|
+
readonly tr: (key: keyof ServiceDictionary<S>[K$1], options?: {
|
|
74
|
+
args?: string[];
|
|
75
|
+
default?: string;
|
|
76
|
+
}) => string;
|
|
77
|
+
protected render(item: string, args: string[]): string;
|
|
78
|
+
}
|
|
79
|
+
type I18nLocalizeType = string | number | Date | DateTime | TypeBoxError;
|
|
80
|
+
interface I18nLocalizeOptions {
|
|
81
|
+
/**
|
|
82
|
+
* Options for number formatting (when value is a number)
|
|
83
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat
|
|
84
|
+
*/
|
|
85
|
+
number?: Intl.NumberFormatOptions;
|
|
86
|
+
/**
|
|
87
|
+
* Options for date formatting (when value is a Date or DateTime)
|
|
88
|
+
* Can be:
|
|
89
|
+
* - A dayjs format string (e.g., "LLL", "YYYY-MM-DD", "dddd, MMMM D YYYY")
|
|
90
|
+
* - "fromNow" for relative time (e.g., "2 hours ago")
|
|
91
|
+
* - Intl.DateTimeFormatOptions for native formatting
|
|
92
|
+
* @see https://day.js.org/docs/en/display/format
|
|
93
|
+
* @see https://day.js.org/docs/en/display/from-now
|
|
94
|
+
*/
|
|
95
|
+
date?: string | "fromNow" | Intl.DateTimeFormatOptions;
|
|
96
|
+
/**
|
|
97
|
+
* Timezone to display dates in (when value is a Date or DateTime)
|
|
98
|
+
* Uses IANA timezone names (e.g., "America/New_York", "Europe/Paris", "Asia/Tokyo")
|
|
99
|
+
* @see https://day.js.org/docs/en/timezone/timezone
|
|
100
|
+
*/
|
|
101
|
+
timezone?: string;
|
|
102
|
+
}
|
|
103
|
+
//#endregion
|
|
104
|
+
//#region src/i18n/descriptors/$dictionary.d.ts
|
|
105
|
+
/**
|
|
106
|
+
* Register a dictionary entry for translations.
|
|
107
|
+
*
|
|
108
|
+
* It allows you to define a set of translations for a specific language.
|
|
109
|
+
* Entry can be lazy-loaded, which is useful for large dictionaries or when translations are not needed immediately.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```ts
|
|
113
|
+
* import { $dictionary } from "@alepha/react/i18n";
|
|
114
|
+
*
|
|
115
|
+
* const Example = () => {
|
|
116
|
+
* const { tr } = useI18n<App, "en">();
|
|
117
|
+
* return <div>{tr("hello")}</div>; //
|
|
118
|
+
* }
|
|
119
|
+
*
|
|
120
|
+
* class App {
|
|
121
|
+
*
|
|
122
|
+
* en = $dictionary({
|
|
123
|
+
* // { default: { hello: "Hey" } }
|
|
124
|
+
* lazy: () => import("./translations/en.ts"),
|
|
125
|
+
* });
|
|
126
|
+
*
|
|
127
|
+
* home = $page({
|
|
128
|
+
* path: "/",
|
|
129
|
+
* component: Example,
|
|
130
|
+
* })
|
|
131
|
+
* }
|
|
132
|
+
*
|
|
133
|
+
* run(App);
|
|
134
|
+
* ```
|
|
135
|
+
*/
|
|
136
|
+
declare const $dictionary: {
|
|
137
|
+
<T extends Record<string, string>>(options: DictionaryDescriptorOptions<T>): DictionaryDescriptor<T>;
|
|
138
|
+
[KIND]: typeof DictionaryDescriptor;
|
|
139
|
+
};
|
|
140
|
+
interface DictionaryDescriptorOptions<T extends Record<string, string>> {
|
|
141
|
+
lang?: string;
|
|
142
|
+
name?: string;
|
|
143
|
+
lazy: () => Promise<{
|
|
144
|
+
default: T;
|
|
145
|
+
}>;
|
|
146
|
+
}
|
|
147
|
+
declare class DictionaryDescriptor<T extends Record<string, string>> extends Descriptor<DictionaryDescriptorOptions<T>> {
|
|
148
|
+
protected provider: I18nProvider<object, never>;
|
|
149
|
+
protected onInit(): void;
|
|
150
|
+
}
|
|
151
|
+
//#endregion
|
|
152
|
+
//#region src/i18n/index.d.ts
|
|
153
|
+
declare module "alepha" {
|
|
154
|
+
interface State {
|
|
155
|
+
"alepha.react.i18n.lang"?: string;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Add i18n support to your Alepha React application. SSR and CSR compatible.
|
|
160
|
+
*
|
|
161
|
+
* It supports lazy loading of translations and provides a context to access the current language.
|
|
162
|
+
*
|
|
163
|
+
* @module alepha.react.i18n
|
|
164
|
+
*/
|
|
165
|
+
declare const AlephaReactI18n: alepha1.Service<alepha1.Module>;
|
|
166
|
+
//#endregion
|
|
167
|
+
export { $dictionary, AlephaReactI18n, DictionaryDescriptor, DictionaryDescriptorOptions, I18nLocalizeOptions, I18nLocalizeType, I18nProvider, Localize, type LocalizeProps, ServiceDictionary, useI18n };
|
|
168
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/i18n/components/Localize.tsx","../../src/i18n/hooks/useI18n.ts","../../src/i18n/providers/I18nProvider.ts","../../src/i18n/descriptors/$dictionary.ts","../../src/i18n/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;UAIiB,aAAA;2BACU,OAAO,WAAW;;;;;EAD5B,MAAA,CAAA,EAMN,IAAA,CAAK,mBANc;EACH;;;;;;AAsB1B;;;8BAP6B,IAAA,CAAK;ECbtB;;;;;EAGR,QAAA,CAAA,EAAA,MAAA;;AAKL,cDcM,QCdM,EAAiB,CAAA,KAAA,EDcJ,aCdI,EAAA,GAAA,MAAA;;;;;;cARhB,8CAEK,kBAAkB,SAC/B,aAAa,GAAG;KAKT,oDACE,IAAI,EAAE,WAAW,gCAAgC,WDZ/D;;;cEEa,iDAEK,kBAAkB;oBAAD,cAAA,CAEjB;oBACA;8BACU;oBAEV,sBAAA,CAAA,yBAFU,QAAA,CAEV,OAAA;EFVD,SAAA,QAAa,EEeF,KFfE,CAAA;IACH,IAAA,EAAA,MAAA;IAAO,IAAA,EAAA,MAAA;IAAW,MAAA,EAAA,GAAA,GEiB3B,OFjB2B,CEiBnB,MFjBmB,CAAA,MAAA,EAAA,MAAA,CAAA,CAAA;IAK7B,YAA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