@alepha/react 0.13.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/index.browser.js +4 -1642
- package/dist/auth/index.browser.js.map +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.js +4 -1642
- package/dist/auth/index.js.map +1 -1
- package/dist/core/index.d.ts +83 -83
- package/dist/form/index.d.ts +1 -1
- package/dist/form/index.js +3 -1642
- package/dist/form/index.js.map +1 -1
- package/dist/head/index.browser.js +3 -1654
- package/dist/head/index.browser.js.map +1 -1
- package/dist/head/index.d.ts +149 -885
- package/dist/head/index.js +4 -1654
- package/dist/head/index.js.map +1 -1
- package/dist/i18n/index.d.ts +20 -20
- package/dist/i18n/index.js +3 -1653
- package/dist/i18n/index.js.map +1 -1
- package/dist/websocket/index.d.ts +159 -3
- package/dist/websocket/index.js +2 -1654
- package/dist/websocket/index.js.map +1 -1
- package/package.json +9 -15
- package/dist/auth/chunk-DhGyd7sr.js +0 -28
- package/dist/auth/index.cjs +0 -1800
- package/dist/auth/index.cjs.map +0 -1
- package/dist/auth/index.d.cts +0 -1274
- package/dist/core/chunk-DhGyd7sr.js +0 -28
- package/dist/core/index.cjs +0 -2087
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.d.cts +0 -2763
- package/dist/form/chunk-DhGyd7sr.js +0 -28
- package/dist/form/index.cjs +0 -2074
- package/dist/form/index.cjs.map +0 -1
- package/dist/form/index.d.cts +0 -419
- package/dist/head/chunk-DhGyd7sr.js +0 -28
- package/dist/head/index.cjs +0 -1912
- package/dist/head/index.cjs.map +0 -1
- package/dist/head/index.d.cts +0 -1801
- package/dist/i18n/chunk-DhGyd7sr.js +0 -28
- package/dist/i18n/index.cjs +0 -1899
- package/dist/i18n/index.cjs.map +0 -1
- package/dist/i18n/index.d.cts +0 -437
- package/dist/websocket/index.cjs +0 -1787
- package/dist/websocket/index.cjs.map +0 -1
- package/dist/websocket/index.d.cts +0 -118
- package/src/i18n/README.md +0 -76
package/dist/i18n/index.d.cts
DELETED
|
@@ -1,437 +0,0 @@
|
|
|
1
|
-
import * as alepha16 from "alepha";
|
|
2
|
-
import { Alepha, Async, Descriptor, KIND, LogLevel, LoggerInterface, Static, TSchema, TypeBoxError } from "alepha";
|
|
3
|
-
import dayjsDuration from "dayjs/plugin/duration.js";
|
|
4
|
-
import DayjsApi, { Dayjs, ManipulateType, PluginFunc } from "dayjs";
|
|
5
|
-
|
|
6
|
-
//#region ../alepha/src/datetime/providers/DateTimeProvider.d.ts
|
|
7
|
-
|
|
8
|
-
type DateTime = DayjsApi.Dayjs;
|
|
9
|
-
type Duration = dayjsDuration.Duration;
|
|
10
|
-
type DurationLike = number | dayjsDuration.Duration | [number, ManipulateType];
|
|
11
|
-
declare class DateTimeProvider {
|
|
12
|
-
static PLUGINS: Array<PluginFunc<any>>;
|
|
13
|
-
protected alepha: Alepha;
|
|
14
|
-
protected ref: DateTime | null;
|
|
15
|
-
protected readonly timeouts: Timeout[];
|
|
16
|
-
protected readonly intervals: Interval[];
|
|
17
|
-
constructor();
|
|
18
|
-
protected readonly onStart: alepha16.HookDescriptor<"start">;
|
|
19
|
-
protected readonly onStop: alepha16.HookDescriptor<"stop">;
|
|
20
|
-
setLocale(locale: string): void;
|
|
21
|
-
isDateTime(value: unknown): value is DateTime;
|
|
22
|
-
/**
|
|
23
|
-
* Create a new UTC DateTime instance.
|
|
24
|
-
*/
|
|
25
|
-
utc(date: string | number | Date | Dayjs | null | undefined): DateTime;
|
|
26
|
-
/**
|
|
27
|
-
* Create a new DateTime instance.
|
|
28
|
-
*/
|
|
29
|
-
of(date: string | number | Date | Dayjs | null | undefined): DateTime;
|
|
30
|
-
/**
|
|
31
|
-
* Get the current date as a string.
|
|
32
|
-
*/
|
|
33
|
-
toISOString(date?: Date | string | DateTime): string;
|
|
34
|
-
/**
|
|
35
|
-
* Get the current date.
|
|
36
|
-
*/
|
|
37
|
-
now(): DateTime;
|
|
38
|
-
/**
|
|
39
|
-
* Get the current date as a string.
|
|
40
|
-
*
|
|
41
|
-
* This is much faster than `DateTimeProvider.now().toISOString()` as it avoids creating a DateTime instance.
|
|
42
|
-
*/
|
|
43
|
-
nowISOString(): string;
|
|
44
|
-
/**
|
|
45
|
-
* Get the current date as milliseconds since epoch.
|
|
46
|
-
*
|
|
47
|
-
* This is much faster than `DateTimeProvider.now().valueOf()` as it avoids creating a DateTime instance.
|
|
48
|
-
*/
|
|
49
|
-
nowMillis(): number;
|
|
50
|
-
/**
|
|
51
|
-
* Get the current date as a string.
|
|
52
|
-
*
|
|
53
|
-
* @protected
|
|
54
|
-
*/
|
|
55
|
-
protected getCurrentDate(): DateTime;
|
|
56
|
-
/**
|
|
57
|
-
* Create a new Duration instance.
|
|
58
|
-
*/
|
|
59
|
-
duration: (duration: DurationLike, unit?: ManipulateType) => Duration;
|
|
60
|
-
isDurationLike(value: unknown): value is DurationLike;
|
|
61
|
-
/**
|
|
62
|
-
* Return a promise that resolves after the next tick.
|
|
63
|
-
* It uses `setTimeout` with 0 ms delay.
|
|
64
|
-
*/
|
|
65
|
-
tick(): Promise<void>;
|
|
66
|
-
/**
|
|
67
|
-
* Wait for a certain duration.
|
|
68
|
-
*
|
|
69
|
-
* You can clear the timeout by using the `AbortSignal` API.
|
|
70
|
-
* Aborted signal will resolve the promise immediately, it does not reject it.
|
|
71
|
-
*/
|
|
72
|
-
wait(duration: DurationLike, options?: {
|
|
73
|
-
signal?: AbortSignal;
|
|
74
|
-
now?: number;
|
|
75
|
-
}): Promise<void>;
|
|
76
|
-
createInterval(run: () => unknown, duration: DurationLike, start?: boolean): Interval;
|
|
77
|
-
/**
|
|
78
|
-
* Run a callback after a certain duration.
|
|
79
|
-
*/
|
|
80
|
-
createTimeout(callback: () => void, duration: DurationLike, now?: number): Timeout;
|
|
81
|
-
clearTimeout(timeout: Timeout): void;
|
|
82
|
-
clearInterval(interval: Interval): void;
|
|
83
|
-
/**
|
|
84
|
-
* Run a function with a deadline.
|
|
85
|
-
*/
|
|
86
|
-
deadline<T>(fn: (signal: AbortSignal) => Promise<T>, duration: DurationLike): Promise<T>;
|
|
87
|
-
/**
|
|
88
|
-
* Add time to the current date.
|
|
89
|
-
*/
|
|
90
|
-
travel(duration: DurationLike, unit?: ManipulateType): Promise<void>;
|
|
91
|
-
/**
|
|
92
|
-
* Stop the time.
|
|
93
|
-
*/
|
|
94
|
-
pause(): DateTime;
|
|
95
|
-
/**
|
|
96
|
-
* Reset the reference date.
|
|
97
|
-
*/
|
|
98
|
-
reset(): void;
|
|
99
|
-
}
|
|
100
|
-
interface Interval {
|
|
101
|
-
timer?: any;
|
|
102
|
-
duration: number;
|
|
103
|
-
run: () => unknown;
|
|
104
|
-
}
|
|
105
|
-
interface Timeout {
|
|
106
|
-
now: number;
|
|
107
|
-
timer?: any;
|
|
108
|
-
duration: number;
|
|
109
|
-
callback: () => void;
|
|
110
|
-
clear: () => void;
|
|
111
|
-
}
|
|
112
|
-
//#endregion
|
|
113
|
-
//#region src/i18n/components/Localize.d.ts
|
|
114
|
-
interface LocalizeProps {
|
|
115
|
-
value: string | number | Date | DateTime | TypeBoxError;
|
|
116
|
-
/**
|
|
117
|
-
* Options for number formatting (when value is a number)
|
|
118
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat
|
|
119
|
-
*/
|
|
120
|
-
number?: Intl.NumberFormatOptions;
|
|
121
|
-
/**
|
|
122
|
-
* Options for date formatting (when value is a Date or DateTime)
|
|
123
|
-
* Can be:
|
|
124
|
-
* - A dayjs format string (e.g., "LLL", "YYYY-MM-DD", "dddd, MMMM D YYYY")
|
|
125
|
-
* - "fromNow" for relative time (e.g., "2 hours ago")
|
|
126
|
-
* - Intl.DateTimeFormatOptions for native formatting
|
|
127
|
-
* @see https://day.js.org/docs/en/display/format
|
|
128
|
-
* @see https://day.js.org/docs/en/display/from-now
|
|
129
|
-
*/
|
|
130
|
-
date?: string | "fromNow" | Intl.DateTimeFormatOptions;
|
|
131
|
-
/**
|
|
132
|
-
* Timezone to display dates in (when value is a Date or DateTime)
|
|
133
|
-
* Uses IANA timezone names (e.g., "America/New_York", "Europe/Paris", "Asia/Tokyo")
|
|
134
|
-
* @see https://day.js.org/docs/en/timezone/timezone
|
|
135
|
-
*/
|
|
136
|
-
timezone?: string;
|
|
137
|
-
}
|
|
138
|
-
declare const Localize: (props: LocalizeProps) => string;
|
|
139
|
-
//#endregion
|
|
140
|
-
//#region ../alepha/src/logger/schemas/logEntrySchema.d.ts
|
|
141
|
-
declare const logEntrySchema: alepha16.TObject<{
|
|
142
|
-
level: alepha16.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
|
|
143
|
-
message: alepha16.TString;
|
|
144
|
-
service: alepha16.TString;
|
|
145
|
-
module: alepha16.TString;
|
|
146
|
-
context: alepha16.TOptional<alepha16.TString>;
|
|
147
|
-
app: alepha16.TOptional<alepha16.TString>;
|
|
148
|
-
data: alepha16.TOptional<alepha16.TAny>;
|
|
149
|
-
timestamp: alepha16.TNumber;
|
|
150
|
-
}>;
|
|
151
|
-
type LogEntry = Static<typeof logEntrySchema>;
|
|
152
|
-
//#endregion
|
|
153
|
-
//#region ../alepha/src/logger/providers/LogDestinationProvider.d.ts
|
|
154
|
-
declare abstract class LogDestinationProvider {
|
|
155
|
-
abstract write(message: string, entry: LogEntry): void;
|
|
156
|
-
}
|
|
157
|
-
//#endregion
|
|
158
|
-
//#region ../alepha/src/logger/providers/LogFormatterProvider.d.ts
|
|
159
|
-
declare abstract class LogFormatterProvider {
|
|
160
|
-
abstract format(entry: LogEntry): string;
|
|
161
|
-
}
|
|
162
|
-
//#endregion
|
|
163
|
-
//#region ../alepha/src/logger/services/Logger.d.ts
|
|
164
|
-
declare class Logger implements LoggerInterface {
|
|
165
|
-
protected readonly alepha: Alepha;
|
|
166
|
-
protected readonly formatter: LogFormatterProvider;
|
|
167
|
-
protected readonly destination: LogDestinationProvider;
|
|
168
|
-
protected readonly dateTimeProvider: DateTimeProvider;
|
|
169
|
-
protected readonly levels: Record<string, number>;
|
|
170
|
-
protected readonly service: string;
|
|
171
|
-
protected readonly module: string;
|
|
172
|
-
protected readonly app?: string;
|
|
173
|
-
protected appLogLevel: string;
|
|
174
|
-
protected logLevel: LogLevel;
|
|
175
|
-
constructor(service: string, module: string);
|
|
176
|
-
get context(): string | undefined;
|
|
177
|
-
get level(): string;
|
|
178
|
-
parseLevel(level: string, app: string): LogLevel;
|
|
179
|
-
private matchesPattern;
|
|
180
|
-
asLogLevel(something: string): LogLevel;
|
|
181
|
-
error(message: string, data?: unknown): void;
|
|
182
|
-
warn(message: string, data?: unknown): void;
|
|
183
|
-
info(message: string, data?: unknown): void;
|
|
184
|
-
debug(message: string, data?: unknown): void;
|
|
185
|
-
trace(message: string, data?: unknown): void;
|
|
186
|
-
protected log(level: LogLevel, message: string, data?: unknown): void;
|
|
187
|
-
protected emit(entry: LogEntry, message?: string): void;
|
|
188
|
-
}
|
|
189
|
-
//#endregion
|
|
190
|
-
//#region ../alepha/src/logger/index.d.ts
|
|
191
|
-
declare const envSchema: alepha16.TObject<{
|
|
192
|
-
/**
|
|
193
|
-
* Default log level for the application.
|
|
194
|
-
*
|
|
195
|
-
* Default by environment:
|
|
196
|
-
* - dev = info
|
|
197
|
-
* - prod = info
|
|
198
|
-
* - test = error
|
|
199
|
-
*
|
|
200
|
-
* Levels are: "trace" | "debug" | "info" | "warn" | "error" | "silent"
|
|
201
|
-
*
|
|
202
|
-
* Level can be set for a specific module:
|
|
203
|
-
*
|
|
204
|
-
* @example
|
|
205
|
-
* LOG_LEVEL=my.module.name:debug,info # Set debug level for my.module.name and info for all other modules
|
|
206
|
-
* LOG_LEVEL=alepha:trace, info # Set trace level for all alepha modules and info for all other modules
|
|
207
|
-
*/
|
|
208
|
-
LOG_LEVEL: alepha16.TOptional<alepha16.TString>;
|
|
209
|
-
/**
|
|
210
|
-
* Built-in log formats.
|
|
211
|
-
* - "json" - JSON format, useful for structured logging and log aggregation. {@link JsonFormatterProvider}
|
|
212
|
-
* - "pretty" - Simple text format, human-readable, with colors. {@link SimpleFormatterProvider}
|
|
213
|
-
* - "raw" - Raw format, no formatting, just the message. {@link RawFormatterProvider}
|
|
214
|
-
*/
|
|
215
|
-
LOG_FORMAT: alepha16.TOptional<alepha16.TUnsafe<"json" | "pretty" | "raw">>;
|
|
216
|
-
}>;
|
|
217
|
-
declare module "alepha" {
|
|
218
|
-
interface Env extends Partial<Static<typeof envSchema>> {}
|
|
219
|
-
interface State {
|
|
220
|
-
/**
|
|
221
|
-
* Current log level for the application or specific modules.
|
|
222
|
-
*/
|
|
223
|
-
"alepha.logger.level"?: string;
|
|
224
|
-
}
|
|
225
|
-
interface Hooks {
|
|
226
|
-
log: {
|
|
227
|
-
message?: string;
|
|
228
|
-
entry: LogEntry;
|
|
229
|
-
};
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
//#endregion
|
|
233
|
-
//#region ../alepha/src/server-cookies/descriptors/$cookie.d.ts
|
|
234
|
-
interface CookieDescriptorOptions<T extends TSchema> {
|
|
235
|
-
/** The schema for the cookie's value, used for validation and type safety. */
|
|
236
|
-
schema: T;
|
|
237
|
-
/** The name of the cookie. */
|
|
238
|
-
name?: string;
|
|
239
|
-
/** The cookie's path. Defaults to "/". */
|
|
240
|
-
path?: string;
|
|
241
|
-
/** Time-to-live for the cookie. Maps to `Max-Age`. */
|
|
242
|
-
ttl?: DurationLike;
|
|
243
|
-
/** If true, the cookie is only sent over HTTPS. Defaults to true in production. */
|
|
244
|
-
secure?: boolean;
|
|
245
|
-
/** If true, the cookie cannot be accessed by client-side scripts. */
|
|
246
|
-
httpOnly?: boolean;
|
|
247
|
-
/** SameSite policy for the cookie. Defaults to "lax". */
|
|
248
|
-
sameSite?: "strict" | "lax" | "none";
|
|
249
|
-
/** The domain for the cookie. */
|
|
250
|
-
domain?: string;
|
|
251
|
-
/** If true, the cookie value will be compressed using zlib. */
|
|
252
|
-
compress?: boolean;
|
|
253
|
-
/** If true, the cookie value will be encrypted. Requires `COOKIE_SECRET` env var. */
|
|
254
|
-
encrypt?: boolean;
|
|
255
|
-
/** If true, the cookie will be signed to prevent tampering. Requires `COOKIE_SECRET` env var. */
|
|
256
|
-
sign?: boolean;
|
|
257
|
-
}
|
|
258
|
-
interface AbstractCookieDescriptor<T extends TSchema> {
|
|
259
|
-
readonly name: string;
|
|
260
|
-
readonly options: CookieDescriptorOptions<T>;
|
|
261
|
-
set(value: Static<T>, options?: {
|
|
262
|
-
cookies?: Cookies;
|
|
263
|
-
ttl?: DurationLike;
|
|
264
|
-
}): void;
|
|
265
|
-
get(options?: {
|
|
266
|
-
cookies?: Cookies;
|
|
267
|
-
}): Static<T> | undefined;
|
|
268
|
-
del(options?: {
|
|
269
|
-
cookies?: Cookies;
|
|
270
|
-
}): void;
|
|
271
|
-
}
|
|
272
|
-
interface Cookies {
|
|
273
|
-
req: Record<string, string>;
|
|
274
|
-
res: Record<string, Cookie | null>;
|
|
275
|
-
}
|
|
276
|
-
interface Cookie {
|
|
277
|
-
value: string;
|
|
278
|
-
path?: string;
|
|
279
|
-
maxAge?: number;
|
|
280
|
-
secure?: boolean;
|
|
281
|
-
httpOnly?: boolean;
|
|
282
|
-
sameSite?: "strict" | "lax" | "none";
|
|
283
|
-
domain?: string;
|
|
284
|
-
}
|
|
285
|
-
//#endregion
|
|
286
|
-
//#region ../alepha/src/server-cookies/index.d.ts
|
|
287
|
-
declare module "alepha/server" {
|
|
288
|
-
interface ServerRequest {
|
|
289
|
-
cookies: Cookies;
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* Provides HTTP cookie management capabilities for server requests and responses with type-safe cookie descriptors.
|
|
294
|
-
*
|
|
295
|
-
* The server-cookies module enables declarative cookie handling using the `$cookie` descriptor on class properties.
|
|
296
|
-
* It offers automatic cookie parsing, secure cookie configuration, and seamless integration with server routes
|
|
297
|
-
* for managing user sessions, preferences, and authentication tokens.
|
|
298
|
-
*
|
|
299
|
-
* @see {@link $cookie}
|
|
300
|
-
* @module alepha.server.cookies
|
|
301
|
-
*/
|
|
302
|
-
//#endregion
|
|
303
|
-
//#region src/i18n/hooks/useI18n.d.ts
|
|
304
|
-
/**
|
|
305
|
-
* Hook to access the i18n service.
|
|
306
|
-
*/
|
|
307
|
-
declare const useI18n: <S extends object, K$1 extends keyof ServiceDictionary<S>>() => I18nProvider<S, K$1>;
|
|
308
|
-
type ServiceDictionary<T extends object> = { [K in keyof T]: T[K] extends DictionaryDescriptor<infer U> ? U : never };
|
|
309
|
-
//#endregion
|
|
310
|
-
//#region src/i18n/providers/I18nProvider.d.ts
|
|
311
|
-
declare class I18nProvider<S extends object, K$1 extends keyof ServiceDictionary<S>> {
|
|
312
|
-
protected log: Logger;
|
|
313
|
-
protected alepha: Alepha;
|
|
314
|
-
protected dateTimeProvider: DateTimeProvider;
|
|
315
|
-
protected cookie: AbstractCookieDescriptor<alepha16.TString>;
|
|
316
|
-
readonly registry: Array<{
|
|
317
|
-
target: string;
|
|
318
|
-
name: string;
|
|
319
|
-
lang: string;
|
|
320
|
-
loader: () => Promise<Record<string, string>>;
|
|
321
|
-
translations: Record<string, string>;
|
|
322
|
-
}>;
|
|
323
|
-
options: {
|
|
324
|
-
fallbackLang: string;
|
|
325
|
-
};
|
|
326
|
-
dateFormat: {
|
|
327
|
-
format: (value: Date) => string;
|
|
328
|
-
};
|
|
329
|
-
numberFormat: {
|
|
330
|
-
format: (value: number) => string;
|
|
331
|
-
};
|
|
332
|
-
get languages(): string[];
|
|
333
|
-
constructor();
|
|
334
|
-
protected readonly onRender: alepha16.HookDescriptor<"server:onRequest">;
|
|
335
|
-
protected readonly onStart: alepha16.HookDescriptor<"start">;
|
|
336
|
-
protected refreshLocale(): void;
|
|
337
|
-
setLang: (lang: string) => Promise<void>;
|
|
338
|
-
protected readonly mutate: alepha16.HookDescriptor<"state:mutate">;
|
|
339
|
-
get lang(): string;
|
|
340
|
-
translate: (key: string, args?: string[]) => string;
|
|
341
|
-
readonly l: (value: I18nLocalizeType, options?: I18nLocalizeOptions) => string;
|
|
342
|
-
readonly tr: (key: keyof ServiceDictionary<S>[K$1], options?: {
|
|
343
|
-
args?: string[];
|
|
344
|
-
default?: string;
|
|
345
|
-
}) => string;
|
|
346
|
-
protected render(item: string, args: string[]): string;
|
|
347
|
-
}
|
|
348
|
-
type I18nLocalizeType = string | number | Date | DateTime | TypeBoxError;
|
|
349
|
-
interface I18nLocalizeOptions {
|
|
350
|
-
/**
|
|
351
|
-
* Options for number formatting (when value is a number)
|
|
352
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat
|
|
353
|
-
*/
|
|
354
|
-
number?: Intl.NumberFormatOptions;
|
|
355
|
-
/**
|
|
356
|
-
* Options for date formatting (when value is a Date or DateTime)
|
|
357
|
-
* Can be:
|
|
358
|
-
* - A dayjs format string (e.g., "LLL", "YYYY-MM-DD", "dddd, MMMM D YYYY")
|
|
359
|
-
* - "fromNow" for relative time (e.g., "2 hours ago")
|
|
360
|
-
* - Intl.DateTimeFormatOptions for native formatting
|
|
361
|
-
* @see https://day.js.org/docs/en/display/format
|
|
362
|
-
* @see https://day.js.org/docs/en/display/from-now
|
|
363
|
-
*/
|
|
364
|
-
date?: string | "fromNow" | Intl.DateTimeFormatOptions;
|
|
365
|
-
/**
|
|
366
|
-
* Timezone to display dates in (when value is a Date or DateTime)
|
|
367
|
-
* Uses IANA timezone names (e.g., "America/New_York", "Europe/Paris", "Asia/Tokyo")
|
|
368
|
-
* @see https://day.js.org/docs/en/timezone/timezone
|
|
369
|
-
*/
|
|
370
|
-
timezone?: string;
|
|
371
|
-
}
|
|
372
|
-
//#endregion
|
|
373
|
-
//#region src/i18n/descriptors/$dictionary.d.ts
|
|
374
|
-
/**
|
|
375
|
-
* Register a dictionary entry for translations.
|
|
376
|
-
*
|
|
377
|
-
* It allows you to define a set of translations for a specific language.
|
|
378
|
-
* Entry can be lazy-loaded, which is useful for large dictionaries or when translations are not needed immediately.
|
|
379
|
-
*
|
|
380
|
-
* @example
|
|
381
|
-
* ```ts
|
|
382
|
-
* import { $dictionary } from "@alepha/react/i18n";
|
|
383
|
-
*
|
|
384
|
-
* const Example = () => {
|
|
385
|
-
* const { tr } = useI18n<App, "en">();
|
|
386
|
-
* return <div>{tr("hello")}</div>; //
|
|
387
|
-
* }
|
|
388
|
-
*
|
|
389
|
-
* class App {
|
|
390
|
-
*
|
|
391
|
-
* en = $dictionary({
|
|
392
|
-
* // { default: { hello: "Hey" } }
|
|
393
|
-
* lazy: () => import("./translations/en.ts"),
|
|
394
|
-
* });
|
|
395
|
-
*
|
|
396
|
-
* home = $page({
|
|
397
|
-
* path: "/",
|
|
398
|
-
* component: Example,
|
|
399
|
-
* })
|
|
400
|
-
* }
|
|
401
|
-
*
|
|
402
|
-
* run(App);
|
|
403
|
-
* ```
|
|
404
|
-
*/
|
|
405
|
-
declare const $dictionary: {
|
|
406
|
-
<T extends Record<string, string>>(options: DictionaryDescriptorOptions<T>): DictionaryDescriptor<T>;
|
|
407
|
-
[KIND]: typeof DictionaryDescriptor;
|
|
408
|
-
};
|
|
409
|
-
interface DictionaryDescriptorOptions<T extends Record<string, string>> {
|
|
410
|
-
lang?: string;
|
|
411
|
-
name?: string;
|
|
412
|
-
lazy: () => Async<{
|
|
413
|
-
default: T;
|
|
414
|
-
}>;
|
|
415
|
-
}
|
|
416
|
-
declare class DictionaryDescriptor<T extends Record<string, string>> extends Descriptor<DictionaryDescriptorOptions<T>> {
|
|
417
|
-
protected provider: I18nProvider<object, never>;
|
|
418
|
-
protected onInit(): void;
|
|
419
|
-
}
|
|
420
|
-
//#endregion
|
|
421
|
-
//#region src/i18n/index.d.ts
|
|
422
|
-
declare module "alepha" {
|
|
423
|
-
interface State {
|
|
424
|
-
"alepha.react.i18n.lang"?: string;
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
/**
|
|
428
|
-
* Add i18n support to your Alepha React application. SSR and CSR compatible.
|
|
429
|
-
*
|
|
430
|
-
* It supports lazy loading of translations and provides a context to access the current language.
|
|
431
|
-
*
|
|
432
|
-
* @module alepha.react.i18n
|
|
433
|
-
*/
|
|
434
|
-
declare const AlephaReactI18n: alepha16.Service<alepha16.Module>;
|
|
435
|
-
//#endregion
|
|
436
|
-
export { $dictionary, AlephaReactI18n, DictionaryDescriptor, DictionaryDescriptorOptions, I18nLocalizeOptions, I18nLocalizeType, I18nProvider, Localize, type LocalizeProps, ServiceDictionary, useI18n };
|
|
437
|
-
//# sourceMappingURL=index.d.cts.map
|