@alepha/react 0.13.7 → 0.14.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.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/head/interfaces/Head.ts","../../src/head/providers/HeadProvider.ts","../../src/head/primitives/$head.ts","../../src/head/hooks/useHead.ts","../../src/head/providers/ServerHeadProvider.ts","../../src/head/index.ts"],"sourcesContent":[],"mappings":";;;;;;UAAiB,IAAA,SAAa;;;;;;EAAb,QAAK,CAAA,EAAA,MAAA,GAAQ;IAuCb,KAAA,CAAA,EAAA,MAAU;IAGR,MAAA,CAAA,EAAA,MAAA;IACA,YAAA,CAAA,EAAA,MAAA;IACV,YAAA,CAAA,EAAA,MAAA;IACA,YAAA,CAAA,EAAA,IAAA,GAAA,KAAA,GAAA,GAAA,GAAA,GAAA;IAAK,iBAAA,CAAA,EAAA,gBAAA,GAAA,iBAAA,GAAA,kBAAA;;;;IC1CD,WAAY,CAAA,EAAA,MAAA;IACD,KAAA,CAAA,EAAA,MAAA;IAAc,GAAA,CAAA,EAAA,MAAA;IAApB,IAAA,CAAA,EAAA,MAAA;EAEO,CAAA;EAuBf,OAAA,CAAA,EAAA;IACC,IAAA,CAAA,EAAA,MAAA;IACA,KAAA,CAAA,EAAA,MAAA;IAAM,WAAA,CAAA,EAAA,MAAA;;;;ACxBjB;AAA+B,UFgCd,UAAA,CEhCc;EAAoB,KAAA,CAAA,EAAA,MAAA;;mBFmChC;mBACA;EE9BP,IAAA,CAAA,EF+BH,KE/BG,CAAA;IAIC,IAAA,EAAA,MAAc;IAAkB,OAAA,EAAA,MAAA;EAChB,CAAA,CAAA;EADM,IAAA,CAAA,EF4B1B,KE5B0B,CAAA;IAAS,GAAA,EAAA,MAAA;;;;;;cDd/B,YAAA;WACK,MAAM,cAAc;kBAEb;iCAuBf,kBACC,yBACA;AD/BX;;;;;;AAAiB,cEOJ,KFPiB,EAAA;EAuC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AA,GKfC,aLeD,EAAA,qBAAA,MAAA,GKdO,mBLcP,CAAA,CAAA;IAGR,IAAA,CAAA,EKfR,ILeQ,GAAA,CAAA,CAAA,KAAA,EKfQ,MLeR,EAAA,QAAA,CAAA,EKf2B,ILe3B,EAAA,GKfoC,ILepC,CAAA;EACA;EACV,UAAA,gBAAA,CAAA;IACA,IAAA,EKdC,ILcD;EAAK;;;;AC1Cd;;;;AAGyB,cIqCZ,eJrCY,EIqCG,OAAA,CAAA,OJrCH,CIyCvB,OAAA,CAJ0B,MAAA,CJrCH"}
@@ -1,115 +1,9 @@
1
- import * as alepha16 from "alepha";
2
- import { Alepha, Async, KIND, LogLevel, LoggerInterface, Primitive, Static, TSchema, TypeBoxError } from "alepha";
3
- import dayjsDuration from "dayjs/plugin/duration.js";
4
- import DayjsApi, { Dayjs, ManipulateType, PluginFunc } from "dayjs";
1
+ import * as alepha1 from "alepha";
2
+ import { Alepha, Async, KIND, Primitive, 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";
5
6
 
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.HookPrimitive<"start">;
19
- protected readonly onStop: alepha16.HookPrimitive<"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
7
  //#region ../../src/i18n/components/Localize.d.ts
114
8
  interface LocalizeProps {
115
9
  value: string | number | Date | DateTime | TypeBoxError;
@@ -137,169 +31,6 @@ interface LocalizeProps {
137
31
  }
138
32
  declare const Localize: (props: LocalizeProps) => string | number;
139
33
  //#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 PrettyFormatterProvider}
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/primitives/$cookie.d.ts
234
- interface CookiePrimitiveOptions<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 AbstractCookiePrimitive<T extends TSchema> {
259
- readonly name: string;
260
- readonly options: CookiePrimitiveOptions<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 primitives.
294
- *
295
- * The server-cookies module enables declarative cookie handling using the `$cookie` primitive 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
34
  //#region ../../src/i18n/hooks/useI18n.d.ts
304
35
  /**
305
36
  * Hook to access the i18n service.
@@ -309,10 +40,10 @@ type ServiceDictionary<T extends object> = { [K in keyof T]: T[K] extends Dictio
309
40
  //#endregion
310
41
  //#region ../../src/i18n/providers/I18nProvider.d.ts
311
42
  declare class I18nProvider<S extends object, K$1 extends keyof ServiceDictionary<S>> {
312
- protected log: Logger;
43
+ protected log: alepha_logger0.Logger;
313
44
  protected alepha: Alepha;
314
45
  protected dateTimeProvider: DateTimeProvider;
315
- protected cookie: AbstractCookiePrimitive<alepha16.TString>;
46
+ protected cookie: alepha_server_cookies0.AbstractCookiePrimitive<alepha1.TString>;
316
47
  readonly registry: Array<{
317
48
  target: string;
318
49
  name: string;
@@ -331,11 +62,11 @@ declare class I18nProvider<S extends object, K$1 extends keyof ServiceDictionary
331
62
  };
332
63
  get languages(): string[];
333
64
  constructor();
334
- protected readonly onRender: alepha16.HookPrimitive<"server:onRequest">;
335
- protected readonly onStart: alepha16.HookPrimitive<"start">;
65
+ protected readonly onRender: alepha1.HookPrimitive<"server:onRequest">;
66
+ protected readonly onStart: alepha1.HookPrimitive<"start">;
336
67
  protected refreshLocale(): void;
337
68
  setLang: (lang: string) => Promise<void>;
338
- protected readonly mutate: alepha16.HookPrimitive<"state:mutate">;
69
+ protected readonly mutate: alepha1.HookPrimitive<"state:mutate">;
339
70
  get lang(): string;
340
71
  translate: (key: string, args?: string[]) => string;
341
72
  readonly l: (value: I18nLocalizeType, options?: I18nLocalizeOptions) => string | number;
@@ -431,7 +162,7 @@ declare module "alepha" {
431
162
  *
432
163
  * @module alepha.react.i18n
433
164
  */
434
- declare const AlephaReactI18n: alepha16.Service<alepha16.Module>;
165
+ declare const AlephaReactI18n: alepha1.Service<alepha1.Module>;
435
166
  //#endregion
436
167
  export { $dictionary, AlephaReactI18n, DictionaryPrimitive, DictionaryPrimitiveOptions, I18nLocalizeOptions, I18nLocalizeType, I18nProvider, Localize, type LocalizeProps, ServiceDictionary, useI18n };
437
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/primitives/$dictionary.ts","../../src/i18n/index.ts"],"sourcesContent":[],"mappings":";;;;;;;UAIiB,aAAA;2BACU,OAAO,WAAW;;;;AAD7C;EAC2B,MAAA,CAAA,EAKhB,IAAA,CAAK,mBALW;EAAO;;;;;AAsBjC;;;;ECpBY,IAAA,CAAA,EAAA,MAMZ,GAAA,SAAA,GDO6B,IAAA,CAAK,qBCPlC;EAJmC;;;;;EACnB,QAAA,CAAA,EAAA,MAAA;AAKjB;cDcM,QCbQ,EAAA,CAAA,KAAA,EDaW,aCbX,EAAA,GAAA,MAAA,GAAA,MAAA;;;;;;cATD,8CAEK,kBAAkB,SAC/B,aAAa,GAAG;KAKT,8CDXK,MCYH,CDZG,GCYC,CDZY,CCYV,CDZU,CAAA,SCYC,mBDZD,CAAA,KAAA,EAAA,CAAA,GAAA,CAAA,GAAA,KAAA,EACH;;;cECd,iDAEK,kBAAkB;iBAAD,cAAA,CAEpB;oBACG;8BACU;EFRX,UAAA,MAAa,EEUZ,sBAAA,CAAA,uBFVY,CEQF,OAAA,CAEV,OAAA,CFVY;EACH,SAAA,QAAA,EEeC,KFfD,CAAA;IAAO,MAAA,EAAA,MAAA;IAAW,IAAA,EAAA,MAAA;IAK7B,IAAA,EAAA,MAAA;IAUmB,MAAA,EAAA,GAAA,GEIjB,OFJiB,CEIT,MFJS,CAAA,MAAA,EAAA,MAAA,CAAA,CAAA;IAAqB,YAAA,EEKtC,MFLsC,CAAA,MAAA,EAAA,MAAA,CAAA;EASlD,CAAA,CAAA;;;;ECtBO,UAMZ,EAAA;IAJmC,MAAA,EAAA,CAAA,KAAA,ECuBG,IDvBH,EAAA,GAAA,MAAA;EAAlB,CAAA;EACA,YAAA,EAAA;IAAG,MAAA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CAAA,OAAA,EC6Bd,0BD7Bc,CC6Ba,CD7Bb,CAAA,CAAA,EC8BtB,mBD9BsB,CC8BF,CD9BE,CAAA;EAEW,MAAA,EAAA,0BAAA;CAAlB;AAAiB,UCkClB,0BDhCF,CAAA,UCgCuC,MDhCvC,CAAA,MAAA,EAAA,MAAA,CAAA,CAAA,CAAA;EACG,IAAA,CAAA,EAAA,MAAA;EACU,IAAA,CAAA,EAAA,MAAA;EAAA,IAAA,EAEV,GAAA,GC+BJ,KD/BI,CAAA;IAAA,OAAA,EC+Ba,CD/Bb;EAUQ,CAAA,CAAA;;AACR,cCyBL,mBDzBK,CAAA,UC0BN,MD1BM,CAAA,MAAA,EAAA,MAAA,CAAA,CAAA,SC2BR,SD3BQ,CC2BE,0BD3BF,CC2B6B,CD3B7B,CAAA,CAAA,CAAA;EALU,UAAA,QAAA,ECiCR,YDjCQ,CAAA,MAAA,EAAA,KAAA,CAAA;EAYW,UAAA,MAAA,CAAA,CAAA,EAAA,IAAA;;;;;;IF5BtB,wBAAa,CAAA,EAAA,MAAA;EACH;;;;;;AAsB1B;;;cIEY,iBAAe,OAAA,CAAA,QAI1B,OAAA,CAJ0B,MAAA"}
@@ -1,164 +1,8 @@
1
- import * as alepha53 from "alepha";
2
- import { Primitive, Static, TObject, TString, TUnion } from "alepha";
1
+ import { ChannelPrimitive, TWSObject } from "alepha/websocket";
2
+ import { Static } from "alepha";
3
3
 
4
- //#region ../../../alepha/src/websocket/primitives/$channel.d.ts
5
- type TWSObject = TObject | TUnion;
6
- /**
7
- * Channel primitive options
8
- */
9
- interface ChannelPrimitiveOptions<TClient extends TWSObject, TServer extends TWSObject> {
10
- /**
11
- * WebSocket endpoint path (e.g., "/ws/chat")
12
- */
13
- path: string;
14
- /**
15
- * Optional description for documentation
16
- */
17
- description?: string;
18
- /**
19
- * Message schemas for bidirectional communication
20
- */
21
- schema: {
22
- /**
23
- * Optional room ID schema validation
24
- * Default: t.text() (any string)
25
- * Can be enforced at application level: t.uuid(), t.regex(/^[a-f0-9\-]{36}$/)
26
- */
27
- roomId?: TString;
28
- /**
29
- * Messages from server to client
30
- * This is what clients will receive
31
- */
32
- in: TClient;
33
- /**
34
- * Messages from client to server
35
- * This is what the server will receive
36
- */
37
- out: TServer;
38
- };
39
- }
40
- declare class ChannelPrimitive<TClient extends TWSObject, TServer extends TWSObject> extends Primitive<ChannelPrimitiveOptions<TClient, TServer>> {}
41
- //#endregion
42
- //#region ../../../alepha/src/logger/schemas/logEntrySchema.d.ts
43
- declare const logEntrySchema: alepha53.TObject<{
44
- level: alepha53.TUnsafe<"SILENT" | "TRACE" | "DEBUG" | "INFO" | "WARN" | "ERROR">;
45
- message: alepha53.TString;
46
- service: alepha53.TString;
47
- module: alepha53.TString;
48
- context: alepha53.TOptional<alepha53.TString>;
49
- app: alepha53.TOptional<alepha53.TString>;
50
- data: alepha53.TOptional<alepha53.TAny>;
51
- timestamp: alepha53.TNumber;
52
- }>;
53
- type LogEntry = Static<typeof logEntrySchema>;
54
- //#endregion
55
- //#region ../../../alepha/src/logger/index.d.ts
56
-
57
- declare const envSchema$2: alepha53.TObject<{
58
- /**
59
- * Default log level for the application.
60
- *
61
- * Default by environment:
62
- * - dev = info
63
- * - prod = info
64
- * - test = error
65
- *
66
- * Levels are: "trace" | "debug" | "info" | "warn" | "error" | "silent"
67
- *
68
- * Level can be set for a specific module:
69
- *
70
- * @example
71
- * LOG_LEVEL=my.module.name:debug,info # Set debug level for my.module.name and info for all other modules
72
- * LOG_LEVEL=alepha:trace, info # Set trace level for all alepha modules and info for all other modules
73
- */
74
- LOG_LEVEL: alepha53.TOptional<alepha53.TString>;
75
- /**
76
- * Built-in log formats.
77
- * - "json" - JSON format, useful for structured logging and log aggregation. {@link JsonFormatterProvider}
78
- * - "pretty" - Simple text format, human-readable, with colors. {@link PrettyFormatterProvider}
79
- * - "raw" - Raw format, no formatting, just the message. {@link RawFormatterProvider}
80
- */
81
- LOG_FORMAT: alepha53.TOptional<alepha53.TUnsafe<"json" | "pretty" | "raw">>;
82
- }>;
83
- declare module "alepha" {
84
- interface Env extends Partial<Static<typeof envSchema$2>> {}
85
- interface State {
86
- /**
87
- * Current log level for the application or specific modules.
88
- */
89
- "alepha.logger.level"?: string;
90
- }
91
- interface Hooks {
92
- log: {
93
- message?: string;
94
- entry: LogEntry;
95
- };
96
- }
97
- }
98
- //#endregion
99
- //#region ../../../alepha/src/websocket/services/WebSocketClient.d.ts
100
- declare const envSchema$1: alepha53.TObject<{
101
- WEBSOCKET_URL: alepha53.TString;
102
- WEBSOCKET_RECONNECT_INTERVAL: alepha53.TInteger;
103
- WEBSOCKET_MAX_RECONNECT_ATTEMPTS: alepha53.TInteger;
104
- }>;
105
- declare module "alepha" {
106
- interface Env extends Partial<Static<typeof envSchema$1>> {}
107
- }
108
- /**
109
- * WebSocket channel connection
110
- *
111
- * Manages a single WebSocket connection to a channel with multiple room subscriptions.
112
- * One connection can handle multiple rooms on the same channel.
113
- */
114
- //#endregion
115
- //#region ../../../alepha/src/websocket/providers/NodeWebSocketServerProvider.d.ts
116
- declare const envSchema: alepha53.TObject<{
117
- WEBSOCKET_PATH: alepha53.TString;
118
- }>;
119
- declare module "alepha" {
120
- interface Env extends Partial<Static<typeof envSchema>> {}
121
- }
122
- //#endregion
123
- //#region ../../../alepha/src/websocket/index.d.ts
124
- declare module "alepha" {
125
- interface Hooks {
126
- /**
127
- * Fires when a WebSocket connection is established
128
- */
129
- "websocket:connect": {
130
- connectionId: string;
131
- path: string;
132
- };
133
- /**
134
- * Fires when a WebSocket connection is closed
135
- */
136
- "websocket:disconnect": {
137
- connectionId: string;
138
- path: string;
139
- code?: number;
140
- reason?: string;
141
- };
142
- /**
143
- * Fires when a WebSocket message is received
144
- */
145
- "websocket:message": {
146
- connectionId: string;
147
- path: string;
148
- message: any;
149
- };
150
- /**
151
- * Fires when a WebSocket error occurs
152
- */
153
- "websocket:error": {
154
- connectionId: string;
155
- path: string;
156
- error: Error;
157
- };
158
- }
159
- }
160
- //#endregion
161
4
  //#region ../../src/websocket/hooks/useRoom.d.ts
5
+
162
6
  /**
163
7
  * UseRoom options
164
8
  */
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/websocket/hooks/useRoom.tsx"],"sourcesContent":[],"mappings":";;;;;;;AASA;AACkB,UADD,cACC,CAAA,gBAAA,SAAA,EAAA,gBACA,SADA,CAAA,CAAA;EACA;;;EAUP,MAAA,EAAA,MAAA;EAKiB;;;EAuCH,OAAA,EA5Cd,gBA4Cc,CA5CG,OA4CH,EA5CY,OA4CZ,CAAA;EAMR;;;EAIC,OAAA,EAAA,CAAA,OAAA,EAjDG,MAiDH,CAjDU,OAiDV,CAAA,EAAA,GAAA,IAAA;EAAoB;;;AA4DtC;EAAwC,GAAA,CAAA,EAAA,MAAA;EAA2B;;;;EAGlD,aAAA,CAAA,EAAA,OAAA;EAAd;;;;;;;;;;;;;;;;;;;;;oBAzEiB;;;;;UAMH,8BAA8B;;;;kBAI7B,OAAO,aAAa;;;;;;;;;;;;;;;;UAoB5B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAwCG,0BAA2B,2BAA2B,oBACxD,eAAe,SAAS,8BAEhC,cAAc"}
package/package.json CHANGED
@@ -2,38 +2,37 @@
2
2
  "name": "@alepha/react",
3
3
  "description": "React components and hooks for building Alepha applications.",
4
4
  "author": "Nicolas Foures",
5
- "version": "0.13.7",
5
+ "version": "0.14.0",
6
6
  "type": "module",
7
7
  "engines": {
8
8
  "node": ">=22.0.0"
9
9
  },
10
10
  "license": "MIT",
11
- "main": "./dist/index.js",
12
- "types": "./dist/index.d.ts",
11
+ "main": "./dist/core/index.js",
12
+ "types": "./dist/core/index.d.ts",
13
13
  "files": [
14
14
  "dist",
15
15
  "src",
16
16
  "assets"
17
17
  ],
18
- "bin": "./dist/index.js",
19
18
  "dependencies": {
20
19
  "@vitejs/plugin-react": "^5.1.2",
21
- "react-dom": "^19.2.1"
20
+ "react-dom": "^19"
22
21
  },
23
22
  "devDependencies": {
24
- "@biomejs/biome": "^2.3.8",
23
+ "@biomejs/biome": "^2.3.10",
25
24
  "@testing-library/dom": "^10.4.1",
26
- "@testing-library/react": "^16.3.0",
27
- "@types/react": "^19.2.7",
28
- "@types/react-dom": "^19.2.3",
29
- "alepha": "0.13.7",
30
- "jsdom": "^27.3.0",
31
- "react": "^19.2.1",
32
- "vitest": "^4.0.15"
25
+ "@testing-library/react": "^16.3.1",
26
+ "@types/react": "^19",
27
+ "@types/react-dom": "^19",
28
+ "alepha": "0.14.0",
29
+ "jsdom": "^27.4.0",
30
+ "react": "^19.2.3",
31
+ "vitest": "^4.0.16"
33
32
  },
34
33
  "peerDependencies": {
35
- "alepha": "0.13.7",
36
- "react": "^19.2.0"
34
+ "alepha": "0.14.0",
35
+ "react": "^19"
37
36
  },
38
37
  "scripts": {
39
38
  "lint": "alepha lint",
@@ -56,41 +55,40 @@
56
55
  ],
57
56
  "exports": {
58
57
  "./auth": {
59
- "types": "./dist/auth/index.js",
58
+ "types": "./dist/auth/index.d.ts",
60
59
  "react-native": "./dist/auth/index.browser.js",
61
60
  "browser": "./dist/auth/index.browser.js",
62
61
  "import": "./dist/auth/index.js",
63
62
  "default": "./dist/auth/index.js"
64
63
  },
65
64
  ".": {
66
- "types": "./dist/core/index.js",
65
+ "types": "./dist/core/index.d.ts",
67
66
  "react-native": "./dist/core/index.native.js",
68
67
  "browser": "./dist/core/index.browser.js",
69
68
  "import": "./dist/core/index.js",
70
69
  "default": "./dist/core/index.js"
71
70
  },
72
71
  "./form": {
73
- "types": "./dist/form/index.js",
72
+ "types": "./dist/form/index.d.ts",
74
73
  "import": "./dist/form/index.js",
75
74
  "default": "./dist/form/index.js"
76
75
  },
77
76
  "./head": {
78
- "types": "./dist/head/index.js",
77
+ "types": "./dist/head/index.d.ts",
79
78
  "react-native": "./dist/head/index.browser.js",
80
79
  "browser": "./dist/head/index.browser.js",
81
80
  "import": "./dist/head/index.js",
82
81
  "default": "./dist/head/index.js"
83
82
  },
84
83
  "./i18n": {
85
- "types": "./dist/i18n/index.js",
84
+ "types": "./dist/i18n/index.d.ts",
86
85
  "import": "./dist/i18n/index.js",
87
86
  "default": "./dist/i18n/index.js"
88
87
  },
89
88
  "./websocket": {
90
- "types": "./dist/websocket/index.js",
89
+ "types": "./dist/websocket/index.d.ts",
91
90
  "import": "./dist/websocket/index.js",
92
91
  "default": "./dist/websocket/index.js"
93
92
  }
94
- },
95
- "module": "./dist/index.js"
93
+ }
96
94
  }
@@ -0,0 +1,41 @@
1
+ import { Alepha } from "alepha";
2
+ import { type ReactNode, useEffect, useMemo, useState } from "react";
3
+ import { AlephaContext } from "./AlephaContext.ts";
4
+
5
+ export interface AlephaProviderProps {
6
+ children: ReactNode;
7
+ onError: (error: Error) => ReactNode;
8
+ onLoading: () => ReactNode;
9
+ }
10
+
11
+ /**
12
+ * AlephaProvider component to initialize and provide Alepha instance to the app.
13
+ * This isn't recommended for apps using alepha/react/router, as Router will handle this for you.
14
+ */
15
+ export const AlephaProvider = (props: AlephaProviderProps) => {
16
+ const alepha = useMemo(() => Alepha.create(), []);
17
+
18
+ const [started, setStarted] = useState(false);
19
+ const [error, setError] = useState<Error | undefined>();
20
+
21
+ useEffect(() => {
22
+ alepha
23
+ .start()
24
+ .then(() => setStarted(true))
25
+ .catch((err) => setError(err));
26
+ }, [alepha]);
27
+
28
+ if (error) {
29
+ return props.onError(error);
30
+ }
31
+
32
+ if (!started) {
33
+ return props.onLoading();
34
+ }
35
+
36
+ return (
37
+ <AlephaContext.Provider value={alepha}>
38
+ {props.children}
39
+ </AlephaContext.Provider>
40
+ );
41
+ };
@@ -1,3 +1,4 @@
1
+ export * from "./contexts/AlephaProvider.tsx";
1
2
  export * from "./contexts/AlephaContext.ts";
2
3
  export * from "./hooks/useAction.ts";
3
4
  export * from "./hooks/useAlepha.ts";