alepha 0.11.9 → 0.11.11

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 (167) hide show
  1. package/README.md +61 -17
  2. package/dist/index.cjs +17089 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.cts +1 -0
  5. package/dist/index.d.ts +2 -0
  6. package/dist/index.js +17088 -0
  7. package/dist/index.js.map +1 -0
  8. package/package.json +42 -365
  9. package/src/assets/biomeJson.ts +33 -0
  10. package/src/assets/tsconfigJson.ts +18 -0
  11. package/src/assets/viteConfigTs.ts +14 -0
  12. package/src/commands/BiomeCommands.ts +41 -0
  13. package/src/commands/CoreCommands.ts +169 -0
  14. package/src/commands/DrizzleCommands.ts +228 -0
  15. package/src/commands/VerifyCommands.ts +44 -0
  16. package/src/commands/ViteCommands.ts +119 -0
  17. package/src/index.ts +35 -0
  18. package/src/services/ProcessRunner.ts +89 -0
  19. package/src/services/ProjectUtils.ts +508 -0
  20. package/src/version.ts +7 -0
  21. package/api/files.cjs +0 -8
  22. package/api/files.d.ts +0 -438
  23. package/api/files.js +0 -1
  24. package/api/jobs.cjs +0 -8
  25. package/api/jobs.d.ts +0 -327
  26. package/api/jobs.js +0 -1
  27. package/api/notifications.cjs +0 -8
  28. package/api/notifications.d.ts +0 -263
  29. package/api/notifications.js +0 -1
  30. package/api/users.cjs +0 -8
  31. package/api/users.d.ts +0 -923
  32. package/api/users.js +0 -1
  33. package/api/verifications.cjs +0 -8
  34. package/api/verifications.d.ts +0 -1
  35. package/api/verifications.js +0 -1
  36. package/batch.cjs +0 -8
  37. package/batch.d.ts +0 -154
  38. package/batch.js +0 -1
  39. package/bucket.cjs +0 -8
  40. package/bucket.d.ts +0 -520
  41. package/bucket.js +0 -1
  42. package/cache/redis.cjs +0 -8
  43. package/cache/redis.d.ts +0 -40
  44. package/cache/redis.js +0 -1
  45. package/cache.cjs +0 -8
  46. package/cache.d.ts +0 -288
  47. package/cache.js +0 -1
  48. package/command.cjs +0 -8
  49. package/command.d.ts +0 -269
  50. package/command.js +0 -1
  51. package/core.cjs +0 -8
  52. package/core.d.ts +0 -1904
  53. package/core.js +0 -1
  54. package/datetime.cjs +0 -8
  55. package/datetime.d.ts +0 -144
  56. package/datetime.js +0 -1
  57. package/devtools.cjs +0 -8
  58. package/devtools.d.ts +0 -252
  59. package/devtools.js +0 -1
  60. package/email.cjs +0 -8
  61. package/email.d.ts +0 -187
  62. package/email.js +0 -1
  63. package/fake.cjs +0 -8
  64. package/fake.d.ts +0 -73
  65. package/fake.js +0 -1
  66. package/file.cjs +0 -8
  67. package/file.d.ts +0 -528
  68. package/file.js +0 -1
  69. package/lock/redis.cjs +0 -8
  70. package/lock/redis.d.ts +0 -24
  71. package/lock/redis.js +0 -1
  72. package/lock.cjs +0 -8
  73. package/lock.d.ts +0 -552
  74. package/lock.js +0 -1
  75. package/logger.cjs +0 -8
  76. package/logger.d.ts +0 -287
  77. package/logger.js +0 -1
  78. package/postgres.cjs +0 -8
  79. package/postgres.d.ts +0 -2143
  80. package/postgres.js +0 -1
  81. package/queue/redis.cjs +0 -8
  82. package/queue/redis.d.ts +0 -29
  83. package/queue/redis.js +0 -1
  84. package/queue.cjs +0 -8
  85. package/queue.d.ts +0 -760
  86. package/queue.js +0 -1
  87. package/react/auth.cjs +0 -8
  88. package/react/auth.d.ts +0 -504
  89. package/react/auth.js +0 -1
  90. package/react/form.cjs +0 -8
  91. package/react/form.d.ts +0 -211
  92. package/react/form.js +0 -1
  93. package/react/head.cjs +0 -8
  94. package/react/head.d.ts +0 -120
  95. package/react/head.js +0 -1
  96. package/react/i18n.cjs +0 -8
  97. package/react/i18n.d.ts +0 -168
  98. package/react/i18n.js +0 -1
  99. package/react.cjs +0 -8
  100. package/react.d.ts +0 -1263
  101. package/react.js +0 -1
  102. package/redis.cjs +0 -8
  103. package/redis.d.ts +0 -82
  104. package/redis.js +0 -1
  105. package/retry.cjs +0 -8
  106. package/retry.d.ts +0 -162
  107. package/retry.js +0 -1
  108. package/router.cjs +0 -8
  109. package/router.d.ts +0 -45
  110. package/router.js +0 -1
  111. package/scheduler.cjs +0 -8
  112. package/scheduler.d.ts +0 -145
  113. package/scheduler.js +0 -1
  114. package/security.cjs +0 -8
  115. package/security.d.ts +0 -586
  116. package/security.js +0 -1
  117. package/server/cache.cjs +0 -8
  118. package/server/cache.d.ts +0 -163
  119. package/server/cache.js +0 -1
  120. package/server/compress.cjs +0 -8
  121. package/server/compress.d.ts +0 -38
  122. package/server/compress.js +0 -1
  123. package/server/cookies.cjs +0 -8
  124. package/server/cookies.d.ts +0 -144
  125. package/server/cookies.js +0 -1
  126. package/server/cors.cjs +0 -8
  127. package/server/cors.d.ts +0 -45
  128. package/server/cors.js +0 -1
  129. package/server/health.cjs +0 -8
  130. package/server/health.d.ts +0 -58
  131. package/server/health.js +0 -1
  132. package/server/helmet.cjs +0 -8
  133. package/server/helmet.d.ts +0 -98
  134. package/server/helmet.js +0 -1
  135. package/server/links.cjs +0 -8
  136. package/server/links.d.ts +0 -322
  137. package/server/links.js +0 -1
  138. package/server/metrics.cjs +0 -8
  139. package/server/metrics.d.ts +0 -35
  140. package/server/metrics.js +0 -1
  141. package/server/multipart.cjs +0 -8
  142. package/server/multipart.d.ts +0 -42
  143. package/server/multipart.js +0 -1
  144. package/server/proxy.cjs +0 -8
  145. package/server/proxy.d.ts +0 -234
  146. package/server/proxy.js +0 -1
  147. package/server/security.cjs +0 -8
  148. package/server/security.d.ts +0 -92
  149. package/server/security.js +0 -1
  150. package/server/static.cjs +0 -8
  151. package/server/static.d.ts +0 -119
  152. package/server/static.js +0 -1
  153. package/server/swagger.cjs +0 -8
  154. package/server/swagger.d.ts +0 -161
  155. package/server/swagger.js +0 -1
  156. package/server.cjs +0 -8
  157. package/server.d.ts +0 -849
  158. package/server.js +0 -1
  159. package/topic/redis.cjs +0 -8
  160. package/topic/redis.d.ts +0 -42
  161. package/topic/redis.js +0 -1
  162. package/topic.cjs +0 -8
  163. package/topic.d.ts +0 -819
  164. package/topic.js +0 -1
  165. package/vite.cjs +0 -8
  166. package/vite.d.ts +0 -186
  167. package/vite.js +0 -1
package/react/form.d.ts DELETED
@@ -1,211 +0,0 @@
1
- import * as _alepha_core0 from "alepha";
2
- import { Alepha, Static, TObject, TSchema } from "alepha";
3
- import { InputHTMLAttributes, ReactNode } from "react";
4
- import * as _alepha_logger0 from "alepha/logger";
5
-
6
- //#region src/services/FormModel.d.ts
7
-
8
- /**
9
- * FormModel is a dynamic form handler that generates form inputs based on a provided TypeBox schema.
10
- * It manages form state, handles input changes, and processes form submissions with validation.
11
- *
12
- * It means to be injected and used within React components to provide a structured way to create and manage forms.
13
- *
14
- * @see {@link useForm}
15
- */
16
- declare class FormModel<T extends TObject> {
17
- readonly id: string;
18
- readonly options: FormCtrlOptions<T>;
19
- protected readonly log: _alepha_logger0.Logger;
20
- protected readonly alepha: Alepha;
21
- protected readonly values: Record<string, any>;
22
- protected submitInProgress: boolean;
23
- input: SchemaToInput<T>;
24
- get submitting(): boolean;
25
- constructor(id: string, options: FormCtrlOptions<T>);
26
- get element(): HTMLFormElement;
27
- get currentValues(): Record<string, any>;
28
- get props(): {
29
- id: string;
30
- noValidate: boolean;
31
- onSubmit: (ev?: FormEventLike) => void;
32
- onReset: (event: FormEventLike) => Promise<void>;
33
- };
34
- readonly reset: (event: FormEventLike) => Promise<void>;
35
- readonly submit: () => Promise<void>;
36
- /**
37
- * Restructures flat keys like "address.city" into nested objects like { address: { city: ... } }
38
- * Values are already typed from onChange, so no conversion is needed.
39
- */
40
- protected restructureValues(store: Record<string, any>): Record<string, any>;
41
- /**
42
- * Helper to restructure a flat key like "address.city" into nested object structure.
43
- * The value is already typed, so we just assign it to the nested path.
44
- */
45
- protected restructureNestedValue(values: Record<string, any>, key: string, value: any): void;
46
- protected createProxyFromSchema<T extends TObject>(options: FormCtrlOptions<T>, schema: TSchema, context: {
47
- parent: string;
48
- store: Record<string, any>;
49
- }): SchemaToInput<T>;
50
- protected createInputFromSchema<T extends TObject>(name: keyof Static<T> & string, options: FormCtrlOptions<T>, schema: TObject, required: boolean, context: {
51
- parent: string;
52
- store: Record<string, any>;
53
- }): InputField;
54
- /**
55
- * Convert an input value to the correct type based on the schema.
56
- * Handles raw DOM values (strings, booleans from checkboxes, Files, etc.)
57
- */
58
- protected getValueFromInput(input: any, schema: TSchema): any;
59
- protected valueToInputEntry(value: any): string | number | boolean;
60
- }
61
- type SchemaToInput<T extends TObject> = { [K in keyof T["properties"]]: T["properties"][K] extends TObject ? SchemaToInput<T["properties"][K]> : InputField };
62
- interface FormEventLike {
63
- preventDefault?: () => void;
64
- stopPropagation?: () => void;
65
- }
66
- interface InputField {
67
- path: string;
68
- required: boolean;
69
- props: InputHTMLAttributesLike;
70
- schema: TSchema;
71
- set: (value: any) => void;
72
- form: FormModel<any>;
73
- }
74
- type InputHTMLAttributesLike = Pick<InputHTMLAttributes<unknown>, "id" | "name" | "type" | "value" | "defaultValue" | "required" | "maxLength" | "minLength" | "aria-label" | "autoComplete"> & {
75
- value?: any;
76
- defaultValue?: any;
77
- onChange?: (event: any) => void;
78
- };
79
- type FormCtrlOptions<T extends TObject> = {
80
- /**
81
- * The schema defining the structure and validation rules for the form.
82
- * This should be a TypeBox schema object.
83
- */
84
- schema: T;
85
- /**
86
- * Callback function to handle form submission.
87
- * This function will receive the parsed and validated form values.
88
- */
89
- handler: (values: Static<T>, args: {
90
- form: HTMLFormElement;
91
- }) => unknown;
92
- /**
93
- * Optional initial values for the form fields.
94
- * This can be used to pre-populate the form with existing data.
95
- */
96
- initialValues?: Partial<Static<T>>;
97
- /**
98
- * Optional function to create custom field attributes.
99
- * This can be used to add custom validation, styles, or other attributes.
100
- */
101
- onCreateField?: (name: keyof Static<T> & string, schema: TSchema) => InputHTMLAttributes<unknown>;
102
- /**
103
- * If defined, this will generate a unique ID for each field, prefixed with this string.
104
- *
105
- * > "username" with id="form-123" will become "form-123-username".
106
- *
107
- * If omitted, IDs will not be generated.
108
- */
109
- id?: string;
110
- onError?: (error: Error, args: {
111
- form: HTMLFormElement;
112
- }) => void;
113
- onChange?: (key: string, value: any, store: Record<string, any>) => void;
114
- onReset?: () => void;
115
- };
116
- //#endregion
117
- //#region src/components/FormState.d.ts
118
- declare const FormState: <T extends TObject>(props: {
119
- form: FormModel<T>;
120
- children: (state: {
121
- loading: boolean;
122
- dirty: boolean;
123
- }) => ReactNode;
124
- }) => ReactNode;
125
- //#endregion
126
- //#region src/hooks/useForm.d.ts
127
- /**
128
- * Custom hook to create a form with validation and field management.
129
- * This hook uses TypeBox schemas to define the structure and validation rules for the form.
130
- * It provides a way to handle form submission, field creation, and value management.
131
- *
132
- * @example
133
- * ```tsx
134
- * import { t } from "alepha";
135
- *
136
- * const form = useForm({
137
- * schema: t.object({
138
- * username: t.text(),
139
- * password: t.text(),
140
- * }),
141
- * handler: (values) => {
142
- * console.log("Form submitted with values:", values);
143
- * },
144
- * });
145
- *
146
- * return (
147
- * <form {...form.props}>
148
- * <input {...form.input.username.props} />
149
- * <input {...form.input.password.props} />
150
- * <button type="submit">Submit</button>
151
- * </form>
152
- * );
153
- * ```
154
- */
155
- declare const useForm: <T extends TObject>(options: FormCtrlOptions<T>, deps?: any[]) => FormModel<T>;
156
- //#endregion
157
- //#region src/hooks/useFormState.d.ts
158
- interface UseFormStateReturn {
159
- loading: boolean;
160
- dirty: boolean;
161
- values?: Record<string, any>;
162
- error?: Error;
163
- }
164
- declare const useFormState: <T extends TObject, Keys extends keyof UseFormStateReturn>(target: FormModel<T> | {
165
- form: FormModel<T>;
166
- path: string;
167
- }, _events?: Keys[]) => Pick<UseFormStateReturn, Keys>;
168
- //#endregion
169
- //#region src/index.d.ts
170
- declare module "alepha" {
171
- interface Hooks {
172
- "form:change": {
173
- id: string;
174
- path: string;
175
- value: any;
176
- };
177
- "form:reset": {
178
- id: string;
179
- values: Record<string, any>;
180
- };
181
- "form:submit:begin": {
182
- id: string;
183
- };
184
- "form:submit:success": {
185
- id: string;
186
- values: Record<string, any>;
187
- };
188
- "form:submit:error": {
189
- id: string;
190
- error: Error;
191
- };
192
- "form:submit:end": {
193
- id: string;
194
- };
195
- }
196
- }
197
- /**
198
- * React hooks for managing forms in Alepha applications.
199
- *
200
- * This module provides a set of hooks to simplify form handling, validation, and submission in React applications built with Alepha.
201
- *
202
- * It includes:
203
- * - `useForm`: A hook for managing form state, validation, and submission.
204
- *
205
- * @see {@link useForm}
206
- * @module alepha.react.form
207
- */
208
- declare const AlephaReactForm: _alepha_core0.Service<_alepha_core0.Module>;
209
- //#endregion
210
- export { AlephaReactForm, FormCtrlOptions, FormEventLike, FormModel, FormState, InputField, InputHTMLAttributesLike, SchemaToInput, UseFormStateReturn, useForm, useFormState };
211
- //# sourceMappingURL=index.d.ts.map
package/react/form.js DELETED
@@ -1 +0,0 @@
1
- export * from '@alepha/react-form'
package/react/head.cjs DELETED
@@ -1,8 +0,0 @@
1
- 'use strict';
2
- var m = require('@alepha/react-head');
3
- Object.keys(m).forEach(function (k) {
4
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
5
- enumerable: true,
6
- get: function () { return m[k]; }
7
- });
8
- });
package/react/head.d.ts DELETED
@@ -1,120 +0,0 @@
1
- import * as _alepha_core1 from "alepha";
2
- import { Descriptor, KIND } from "alepha";
3
- import { PageConfigSchema, PageRoute, ReactRouterState, TPropsDefault, TPropsParentDefault } from "alepha/react";
4
- import { ServerTimingProvider } from "alepha/server";
5
-
6
- //#region src/interfaces/Head.d.ts
7
- interface Head extends SimpleHead {
8
- description?: string;
9
- keywords?: string[];
10
- author?: string;
11
- robots?: string;
12
- themeColor?: string;
13
- viewport?: string | {
14
- width?: string;
15
- height?: string;
16
- initialScale?: string;
17
- maximumScale?: string;
18
- userScalable?: "no" | "yes" | "0" | "1";
19
- interactiveWidget?: "resizes-visual" | "resizes-content" | "overlays-content";
20
- };
21
- og?: {
22
- title?: string;
23
- description?: string;
24
- image?: string;
25
- url?: string;
26
- type?: string;
27
- };
28
- twitter?: {
29
- card?: string;
30
- title?: string;
31
- description?: string;
32
- image?: string;
33
- site?: string;
34
- };
35
- }
36
- interface SimpleHead {
37
- title?: string;
38
- titleSeparator?: string;
39
- htmlAttributes?: Record<string, string>;
40
- bodyAttributes?: Record<string, string>;
41
- meta?: Array<{
42
- name: string;
43
- content: string;
44
- }>;
45
- }
46
- //#endregion
47
- //#region src/providers/HeadProvider.d.ts
48
- declare class HeadProvider {
49
- global?: Head | (() => Head);
50
- protected getGlobalHead(): Head | undefined;
51
- fillHead(state: ReactRouterState): void;
52
- protected fillHeadByPage(page: PageRoute, state: ReactRouterState, props: Record<string, any>): void;
53
- }
54
- //#endregion
55
- //#region src/descriptors/$head.d.ts
56
- /**
57
- * Set global `<head>` options for the application.
58
- */
59
- declare const $head: {
60
- (options: HeadDescriptorOptions): HeadDescriptor;
61
- [KIND]: typeof HeadDescriptor;
62
- };
63
- type HeadDescriptorOptions = Head | (() => Head);
64
- declare class HeadDescriptor extends Descriptor<HeadDescriptorOptions> {
65
- protected readonly provider: HeadProvider;
66
- protected onInit(): void;
67
- }
68
- //#endregion
69
- //#region src/hooks/useHead.d.ts
70
- /**
71
- * ```tsx
72
- * const App = () => {
73
- * const [head, setHead] = useHead({
74
- * // will set the document title on the first render
75
- * title: "My App",
76
- * });
77
- *
78
- * return (
79
- * // This will update the document title when the button is clicked
80
- * <button onClick={() => setHead({ title: "Change Title" })}>
81
- * Change Title {head.title}
82
- * </button>
83
- * );
84
- * }
85
- * ```
86
- */
87
- declare const useHead: (options?: UseHeadOptions) => UseHeadReturn;
88
- type UseHeadOptions = Head | ((previous?: Head) => Head);
89
- type UseHeadReturn = [Head, (head?: Head | ((previous?: Head) => Head)) => void];
90
- //#endregion
91
- //#region src/providers/ServerHeadProvider.d.ts
92
- declare class ServerHeadProvider {
93
- protected readonly headProvider: HeadProvider;
94
- protected readonly serverTimingProvider: ServerTimingProvider;
95
- protected readonly onServerRenderEnd: _alepha_core1.HookDescriptor<"react:server:render:end">;
96
- renderHead(template: string, head: SimpleHead): string;
97
- protected mergeAttributes(existing: string, attrs: Record<string, string>): string;
98
- protected parseAttributes(attrStr: string): Record<string, string>;
99
- protected escapeHtml(str: string): string;
100
- }
101
- //#endregion
102
- //#region src/index.d.ts
103
- declare module "alepha/react" {
104
- interface PageDescriptorOptions<TConfig extends PageConfigSchema = PageConfigSchema, TProps extends object = TPropsDefault, TPropsParent extends object = TPropsParentDefault> {
105
- head?: Head | ((props: TProps, previous?: Head) => Head);
106
- }
107
- interface ReactRouterState {
108
- head: Head;
109
- }
110
- }
111
- /**
112
- * Fill `<head>` server & client side.
113
- *
114
- * @see {@link ServerHeadProvider}
115
- * @module alepha.react.head
116
- */
117
- declare const AlephaReactHead: _alepha_core1.Service<_alepha_core1.Module>;
118
- //#endregion
119
- export { $head, AlephaReactHead, Head, HeadDescriptor, HeadDescriptorOptions, ServerHeadProvider, SimpleHead, UseHeadOptions, UseHeadReturn, useHead };
120
- //# sourceMappingURL=index.d.ts.map
package/react/head.js DELETED
@@ -1 +0,0 @@
1
- export * from '@alepha/react-head'
package/react/i18n.cjs DELETED
@@ -1,8 +0,0 @@
1
- 'use strict';
2
- var m = require('@alepha/react-i18n');
3
- Object.keys(m).forEach(function (k) {
4
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
5
- enumerable: true,
6
- get: function () { return m[k]; }
7
- });
8
- });
package/react/i18n.d.ts DELETED
@@ -1,168 +0,0 @@
1
- import * as _alepha_core1 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/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/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/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: _alepha_core1.HookDescriptor<"server:onRequest">;
66
- protected readonly onStart: _alepha_core1.HookDescriptor<"start">;
67
- protected refreshLocale(): void;
68
- setLang: (lang: string) => Promise<void>;
69
- protected readonly mutate: _alepha_core1.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/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/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: _alepha_core1.Service<_alepha_core1.Module>;
166
- //#endregion
167
- export { $dictionary, AlephaReactI18n, DictionaryDescriptor, DictionaryDescriptorOptions, I18nLocalizeOptions, I18nLocalizeType, I18nProvider, Localize, type LocalizeProps, ServiceDictionary, useI18n };
168
- //# sourceMappingURL=index.d.ts.map
package/react/i18n.js DELETED
@@ -1 +0,0 @@
1
- export * from '@alepha/react-i18n'
package/react.cjs DELETED
@@ -1,8 +0,0 @@
1
- 'use strict';
2
- var m = require('@alepha/react');
3
- Object.keys(m).forEach(function (k) {
4
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
5
- enumerable: true,
6
- get: function () { return m[k]; }
7
- });
8
- });