@alepha/react 0.13.0 → 0.13.2

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 (76) hide show
  1. package/dist/auth/index.browser.js +9 -1647
  2. package/dist/auth/index.browser.js.map +1 -1
  3. package/dist/auth/index.d.ts +330 -330
  4. package/dist/auth/index.js +11 -1649
  5. package/dist/auth/index.js.map +1 -1
  6. package/dist/core/index.browser.js +19 -18
  7. package/dist/core/index.browser.js.map +1 -1
  8. package/dist/core/index.d.ts +352 -344
  9. package/dist/core/index.js +25 -24
  10. package/dist/core/index.js.map +1 -1
  11. package/dist/core/index.native.js +381 -0
  12. package/dist/core/index.native.js.map +1 -0
  13. package/dist/form/index.d.ts +3 -3
  14. package/dist/form/index.js +3 -1642
  15. package/dist/form/index.js.map +1 -1
  16. package/dist/head/index.browser.js +9 -1660
  17. package/dist/head/index.browser.js.map +1 -1
  18. package/dist/head/index.d.ts +808 -1544
  19. package/dist/head/index.js +10 -1660
  20. package/dist/head/index.js.map +1 -1
  21. package/dist/i18n/index.d.ts +34 -34
  22. package/dist/i18n/index.js +14 -1664
  23. package/dist/i18n/index.js.map +1 -1
  24. package/dist/websocket/index.d.ts +161 -5
  25. package/dist/websocket/index.js +2 -1654
  26. package/dist/websocket/index.js.map +1 -1
  27. package/package.json +12 -9
  28. package/src/auth/index.ts +1 -1
  29. package/src/auth/providers/ReactAuthProvider.ts +1 -1
  30. package/src/auth/services/ReactAuth.ts +5 -5
  31. package/src/core/components/NestedView.tsx +1 -1
  32. package/src/core/hooks/useStore.ts +4 -4
  33. package/src/core/index.browser.ts +2 -2
  34. package/src/core/index.native.ts +1 -1
  35. package/src/core/index.shared-router.ts +1 -1
  36. package/src/core/index.ts +3 -3
  37. package/src/core/{descriptors → primitives}/$page.ts +20 -20
  38. package/src/core/providers/ReactBrowserProvider.ts +2 -2
  39. package/src/core/providers/ReactBrowserRouterProvider.ts +2 -2
  40. package/src/core/providers/ReactPageProvider.ts +25 -11
  41. package/src/core/providers/ReactServerProvider.ts +12 -12
  42. package/src/core/services/ReactPageServerService.ts +6 -6
  43. package/src/core/services/ReactPageService.ts +6 -6
  44. package/src/core/services/ReactRouter.ts +3 -3
  45. package/src/head/index.browser.ts +3 -3
  46. package/src/head/index.ts +4 -4
  47. package/src/head/{descriptors → primitives}/$head.ts +6 -6
  48. package/src/i18n/hooks/useI18n.ts +2 -2
  49. package/src/i18n/index.ts +3 -3
  50. package/src/i18n/{descriptors → primitives}/$dictionary.ts +8 -8
  51. package/src/i18n/providers/I18nProvider.ts +5 -5
  52. package/src/websocket/hooks/useRoom.tsx +3 -3
  53. package/dist/auth/chunk-DhGyd7sr.js +0 -28
  54. package/dist/auth/index.cjs +0 -1800
  55. package/dist/auth/index.cjs.map +0 -1
  56. package/dist/auth/index.d.cts +0 -1274
  57. package/dist/core/chunk-DhGyd7sr.js +0 -28
  58. package/dist/core/index.cjs +0 -2087
  59. package/dist/core/index.cjs.map +0 -1
  60. package/dist/core/index.d.cts +0 -2763
  61. package/dist/form/chunk-DhGyd7sr.js +0 -28
  62. package/dist/form/index.cjs +0 -2074
  63. package/dist/form/index.cjs.map +0 -1
  64. package/dist/form/index.d.cts +0 -419
  65. package/dist/head/chunk-DhGyd7sr.js +0 -28
  66. package/dist/head/index.cjs +0 -1912
  67. package/dist/head/index.cjs.map +0 -1
  68. package/dist/head/index.d.cts +0 -1801
  69. package/dist/i18n/chunk-DhGyd7sr.js +0 -28
  70. package/dist/i18n/index.cjs +0 -1899
  71. package/dist/i18n/index.cjs.map +0 -1
  72. package/dist/i18n/index.d.cts +0 -437
  73. package/dist/websocket/index.cjs +0 -1787
  74. package/dist/websocket/index.cjs.map +0 -1
  75. package/dist/websocket/index.d.cts +0 -118
  76. package/src/i18n/README.md +0 -76
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  $inject,
3
3
  type Async,
4
- createDescriptor,
5
- Descriptor,
4
+ createPrimitive,
5
+ Primitive,
6
6
  KIND,
7
7
  type Static,
8
8
  type TSchema,
@@ -16,9 +16,9 @@ import type { ReactRouterState } from "../providers/ReactPageProvider.ts";
16
16
  import { ReactPageService } from "../services/ReactPageService.ts";
17
17
 
18
18
  /**
19
- * Main descriptor for defining a React route in the application.
19
+ * Main primitive for defining a React route in the application.
20
20
  *
21
- * The $page descriptor is the core building block for creating type-safe, SSR-enabled React routes.
21
+ * The $page primitive is the core building block for creating type-safe, SSR-enabled React routes.
22
22
  * It provides a declarative way to define pages with powerful features:
23
23
  *
24
24
  * **Routing & Navigation**
@@ -108,17 +108,17 @@ export const $page = <
108
108
  TProps extends object = TPropsDefault,
109
109
  TPropsParent extends object = TPropsParentDefault,
110
110
  >(
111
- options: PageDescriptorOptions<TConfig, TProps, TPropsParent>,
112
- ): PageDescriptor<TConfig, TProps, TPropsParent> => {
113
- return createDescriptor(
114
- PageDescriptor<TConfig, TProps, TPropsParent>,
111
+ options: PagePrimitiveOptions<TConfig, TProps, TPropsParent>,
112
+ ): PagePrimitive<TConfig, TProps, TPropsParent> => {
113
+ return createPrimitive(
114
+ PagePrimitive<TConfig, TProps, TPropsParent>,
115
115
  options,
116
116
  );
117
117
  };
118
118
 
119
119
  // ---------------------------------------------------------------------------------------------------------------------
120
120
 
121
- export interface PageDescriptorOptions<
121
+ export interface PagePrimitiveOptions<
122
122
  TConfig extends PageConfigSchema = PageConfigSchema,
123
123
  TProps extends object = TPropsDefault,
124
124
  TPropsParent extends object = TPropsParentDefault,
@@ -126,7 +126,7 @@ export interface PageDescriptorOptions<
126
126
  /**
127
127
  * Identifier name for the page. Must be unique.
128
128
  *
129
- * @default Descriptor key
129
+ * @default Primitive key
130
130
  */
131
131
  name?: string;
132
132
 
@@ -182,12 +182,12 @@ export interface PageDescriptorOptions<
182
182
  * Attach child pages to create nested routes.
183
183
  * This will make the page a parent route.
184
184
  */
185
- children?: Array<PageDescriptor> | (() => Array<PageDescriptor>);
185
+ children?: Array<PagePrimitive> | (() => Array<PagePrimitive>);
186
186
 
187
187
  /**
188
188
  * Define a parent page for nested routing.
189
189
  */
190
- parent?: PageDescriptor<PageConfigSchema, TPropsParent, any>;
190
+ parent?: PagePrimitive<PageConfigSchema, TPropsParent, any>;
191
191
 
192
192
  can?: () => boolean;
193
193
 
@@ -312,11 +312,11 @@ export type ErrorHandler = (
312
312
  state: ReactRouterState,
313
313
  ) => ReactNode | Redirection | undefined;
314
314
 
315
- export class PageDescriptor<
315
+ export class PagePrimitive<
316
316
  TConfig extends PageConfigSchema = PageConfigSchema,
317
317
  TProps extends object = TPropsDefault,
318
318
  TPropsParent extends object = TPropsParentDefault,
319
- > extends Descriptor<PageDescriptorOptions<TConfig, TProps, TPropsParent>> {
319
+ > extends Primitive<PagePrimitiveOptions<TConfig, TProps, TPropsParent>> {
320
320
  protected readonly reactPageService = $inject(ReactPageService);
321
321
 
322
322
  protected onInit() {
@@ -341,12 +341,12 @@ export class PageDescriptor<
341
341
  * Only valid for server-side rendering, it will throw an error if called on the client-side.
342
342
  */
343
343
  public async render(
344
- options?: PageDescriptorRenderOptions,
345
- ): Promise<PageDescriptorRenderResult> {
344
+ options?: PagePrimitiveRenderOptions,
345
+ ): Promise<PagePrimitiveRenderResult> {
346
346
  return this.reactPageService.render(this.name, options);
347
347
  }
348
348
 
349
- public async fetch(options?: PageDescriptorRenderOptions): Promise<{
349
+ public async fetch(options?: PagePrimitiveRenderOptions): Promise<{
350
350
  html: string;
351
351
  response: Response;
352
352
  }> {
@@ -364,7 +364,7 @@ export class PageDescriptor<
364
364
  }
365
365
  }
366
366
 
367
- $page[KIND] = PageDescriptor;
367
+ $page[KIND] = PagePrimitive;
368
368
 
369
369
  // ---------------------------------------------------------------------------------------------------------------------
370
370
 
@@ -377,7 +377,7 @@ export type TPropsDefault = any;
377
377
 
378
378
  export type TPropsParentDefault = {};
379
379
 
380
- export interface PageDescriptorRenderOptions {
380
+ export interface PagePrimitiveRenderOptions {
381
381
  params?: Record<string, string>;
382
382
  query?: Record<string, string>;
383
383
 
@@ -391,7 +391,7 @@ export interface PageDescriptorRenderOptions {
391
391
  hydration?: boolean;
392
392
  }
393
393
 
394
- export interface PageDescriptorRenderResult {
394
+ export interface PagePrimitiveRenderResult {
395
395
  html: string;
396
396
  state: ReactRouterState;
397
397
  redirect?: string;
@@ -84,7 +84,7 @@ export class ReactBrowserProvider {
84
84
  };
85
85
 
86
86
  public get state(): ReactRouterState {
87
- return this.alepha.state.get("alepha.react.router.state")!;
87
+ return this.alepha.store.get("alepha.react.router.state")!;
88
88
  }
89
89
 
90
90
  /**
@@ -262,7 +262,7 @@ export class ReactBrowserProvider {
262
262
  // low budget, but works for now
263
263
  for (const [key, value] of Object.entries(hydration)) {
264
264
  if (key !== "layers") {
265
- this.alepha.state.set(key as keyof State, value);
265
+ this.alepha.store.set(key as keyof State, value);
266
266
  }
267
267
  }
268
268
  }
@@ -63,7 +63,7 @@ export class ReactBrowserRouterProvider extends RouterProvider<BrowserRoute> {
63
63
  type: "transition",
64
64
  });
65
65
  await this.alepha.events.emit("react:transition:begin", {
66
- previous: this.alepha.state.get("alepha.react.router.state")!,
66
+ previous: this.alepha.store.get("alepha.react.router.state")!,
67
67
  state,
68
68
  });
69
69
 
@@ -135,7 +135,7 @@ export class ReactBrowserRouterProvider extends RouterProvider<BrowserRoute> {
135
135
  }
136
136
  }
137
137
 
138
- this.alepha.state.set("alepha.react.router.state", state);
138
+ this.alepha.store.set("alepha.react.router.state", state);
139
139
 
140
140
  await this.alepha.events.emit("react:action:end", {
141
141
  type: "transition",
@@ -19,9 +19,9 @@ import { RouterLayerContext } from "../contexts/RouterLayerContext.ts";
19
19
  import {
20
20
  $page,
21
21
  type ErrorHandler,
22
- type PageDescriptor,
23
- type PageDescriptorOptions,
24
- } from "../descriptors/$page.ts";
22
+ type PagePrimitive,
23
+ type PagePrimitiveOptions,
24
+ } from "../primitives/$page.ts";
25
25
  import { Redirection } from "../errors/Redirection.ts";
26
26
 
27
27
  const envSchema = t.object({
@@ -42,12 +42,14 @@ export class ReactPageProvider {
42
42
  return this.pages;
43
43
  }
44
44
 
45
- public getConcretePages(): PageRoute[] {
46
- const pages: PageRoute[] = [];
45
+ public getConcretePages(): ConcretePageRoute[] {
46
+ const pages: ConcretePageRoute[] = [];
47
47
  for (const page of this.pages) {
48
48
  if (page.children && page.children.length > 0) {
49
49
  continue;
50
50
  }
51
+
52
+ // check if the page has dynamic params
51
53
  const fullPath = this.pathname(page.name);
52
54
  if (fullPath.includes(":") || fullPath.includes("*")) {
53
55
  if (typeof page.static === "object") {
@@ -60,6 +62,7 @@ export class ReactPageProvider {
60
62
  pages.push({
61
63
  ...page,
62
64
  name: params[Object.keys(params)[0]],
65
+ staticName: page.name,
63
66
  path,
64
67
  ...entry,
65
68
  });
@@ -70,6 +73,7 @@ export class ReactPageProvider {
70
73
 
71
74
  continue;
72
75
  }
76
+
73
77
  pages.push(page);
74
78
  }
75
79
  return pages;
@@ -481,9 +485,9 @@ export class ReactPageProvider {
481
485
  on: "configure",
482
486
  handler: () => {
483
487
  let hasNotFoundHandler = false;
484
- const pages = this.alepha.descriptors($page);
488
+ const pages = this.alepha.primitives($page);
485
489
 
486
- const hasParent = (it: PageDescriptor) => {
490
+ const hasParent = (it: PagePrimitive) => {
487
491
  if (it.options.parent) {
488
492
  return true;
489
493
  }
@@ -529,8 +533,8 @@ export class ReactPageProvider {
529
533
  });
530
534
 
531
535
  protected map(
532
- pages: Array<PageDescriptor>,
533
- target: PageDescriptor,
536
+ pages: Array<PagePrimitive>,
537
+ target: PagePrimitive,
534
538
  ): PageRouteEntry {
535
539
  const children = target.options.children
536
540
  ? Array.isArray(target.options.children)
@@ -538,7 +542,7 @@ export class ReactPageProvider {
538
542
  : target.options.children()
539
543
  : [];
540
544
 
541
- const getChildrenFromParent = (it: PageDescriptor): PageDescriptor[] => {
545
+ const getChildrenFromParent = (it: PagePrimitive): PagePrimitive[] => {
542
546
  const children = [];
543
547
  for (const page of pages) {
544
548
  if (page.options.parent === it) {
@@ -613,10 +617,20 @@ export const isPageRoute = (it: any): it is PageRoute => {
613
617
  };
614
618
 
615
619
  export interface PageRouteEntry
616
- extends Omit<PageDescriptorOptions, "children" | "parent"> {
620
+ extends Omit<PagePrimitiveOptions, "children" | "parent"> {
617
621
  children?: PageRouteEntry[];
618
622
  }
619
623
 
624
+ export interface ConcretePageRoute extends PageRoute {
625
+ /**
626
+ * When exported, static routes can be split into multiple pages with different params.
627
+ * We replace 'name' by the new name for each static entry, and old 'name' becomes 'staticName'.
628
+ */
629
+ staticName?: string;
630
+
631
+ params?: Record<string, string>;
632
+ }
633
+
620
634
  export interface PageRoute extends PageRouteEntry {
621
635
  type: "page";
622
636
  name: string;
@@ -23,9 +23,9 @@ import { ServerStaticProvider } from "alepha/server/static";
23
23
  import { renderToString } from "react-dom/server";
24
24
  import {
25
25
  $page,
26
- type PageDescriptorRenderOptions,
27
- type PageDescriptorRenderResult,
28
- } from "../descriptors/$page.ts";
26
+ type PagePrimitiveRenderOptions,
27
+ type PagePrimitiveRenderResult,
28
+ } from "../primitives/$page.ts";
29
29
  import { Redirection } from "../errors/Redirection.ts";
30
30
  import type { ReactHydrationState } from "./ReactBrowserProvider.ts";
31
31
  import {
@@ -112,12 +112,12 @@ export class ReactServerProvider {
112
112
  public readonly onConfigure = $hook({
113
113
  on: "configure",
114
114
  handler: async () => {
115
- const pages = this.alepha.descriptors($page);
115
+ const pages = this.alepha.primitives($page);
116
116
 
117
117
  const ssrEnabled =
118
118
  pages.length > 0 && this.env.REACT_SSR_ENABLED !== false;
119
119
 
120
- this.alepha.state.set("alepha.react.server.ssr", ssrEnabled);
120
+ this.alepha.store.set("alepha.react.server.ssr", ssrEnabled);
121
121
 
122
122
  // development mode
123
123
  if (this.alepha.isViteDev()) {
@@ -192,7 +192,7 @@ export class ReactServerProvider {
192
192
 
193
193
  this.serverRouterProvider.createRoute({
194
194
  ...page,
195
- schema: undefined, // schema is handled by the page descriptor provider for now (shared by browser and server)
195
+ schema: undefined, // schema is handled by the page primitive provider for now (shared by browser and server)
196
196
  method: "GET",
197
197
  path: page.match,
198
198
  handler: this.createHandler(page, templateLoader),
@@ -257,8 +257,8 @@ export class ReactServerProvider {
257
257
  */
258
258
  public async render(
259
259
  name: string,
260
- options: PageDescriptorRenderOptions = {},
261
- ): Promise<PageDescriptorRenderResult> {
260
+ options: PagePrimitiveRenderOptions = {},
261
+ ): Promise<PagePrimitiveRenderResult> {
262
262
  const page = this.pageApi.page(name);
263
263
  const url = new URL(this.pageApi.url(name, options));
264
264
  const entry: Partial<ReactRouterState> = {
@@ -289,7 +289,7 @@ export class ReactServerProvider {
289
289
  }
290
290
 
291
291
  if (!options.html) {
292
- this.alepha.state.set("alepha.react.router.state", state);
292
+ this.alepha.store.set("alepha.react.router.state", state);
293
293
 
294
294
  return {
295
295
  state,
@@ -340,7 +340,7 @@ export class ReactServerProvider {
340
340
  const state = entry as ReactRouterState;
341
341
 
342
342
  if (this.alepha.has(ServerLinksProvider)) {
343
- this.alepha.state.set(
343
+ this.alepha.store.set(
344
344
  "alepha.server.request.apiLinks",
345
345
  await this.alepha.inject(ServerLinksProvider).getUserApiLinks({
346
346
  user: (serverRequest as any).user, // TODO: fix type
@@ -349,7 +349,7 @@ export class ReactServerProvider {
349
349
  );
350
350
  }
351
351
 
352
- let target: PageRoute | undefined = route; // TODO: move to PageDescriptorProvider
352
+ let target: PageRoute | undefined = route; // TODO: move to PagePrimitiveProvider
353
353
  while (target) {
354
354
  if (route.can && !route.can()) {
355
355
  // if the page is not accessible, return 403
@@ -431,7 +431,7 @@ export class ReactServerProvider {
431
431
  const element = this.pageApi.root(state);
432
432
 
433
433
  // attach react router state to the http request context
434
- this.alepha.state.set("alepha.react.router.state", state);
434
+ this.alepha.store.set("alepha.react.router.state", state);
435
435
 
436
436
  this.serverTimingProvider.beginTiming("renderToString");
437
437
  let app = "";
@@ -1,9 +1,9 @@
1
1
  import { $inject, AlephaError } from "alepha";
2
2
  import { ServerProvider } from "alepha/server";
3
3
  import type {
4
- PageDescriptorRenderOptions,
5
- PageDescriptorRenderResult,
6
- } from "../descriptors/$page.ts";
4
+ PagePrimitiveRenderOptions,
5
+ PagePrimitiveRenderResult,
6
+ } from "../primitives/$page.ts";
7
7
  import { ReactServerProvider } from "../providers/ReactServerProvider.ts";
8
8
  import { ReactPageService } from "./ReactPageService.ts";
9
9
 
@@ -13,14 +13,14 @@ export class ReactPageServerService extends ReactPageService {
13
13
 
14
14
  public async render(
15
15
  name: string,
16
- options: PageDescriptorRenderOptions = {},
17
- ): Promise<PageDescriptorRenderResult> {
16
+ options: PagePrimitiveRenderOptions = {},
17
+ ): Promise<PagePrimitiveRenderResult> {
18
18
  return this.reactServerProvider.render(name, options);
19
19
  }
20
20
 
21
21
  public async fetch(
22
22
  pathname: string,
23
- options: PageDescriptorRenderOptions = {},
23
+ options: PagePrimitiveRenderOptions = {},
24
24
  ): Promise<{
25
25
  html: string;
26
26
  response: Response;
@@ -1,13 +1,13 @@
1
1
  import { AlephaError } from "alepha";
2
2
  import type {
3
- PageDescriptorRenderOptions,
4
- PageDescriptorRenderResult,
5
- } from "../descriptors/$page.ts";
3
+ PagePrimitiveRenderOptions,
4
+ PagePrimitiveRenderResult,
5
+ } from "../primitives/$page.ts";
6
6
 
7
7
  export class ReactPageService {
8
8
  public fetch(
9
9
  pathname: string,
10
- options: PageDescriptorRenderOptions = {},
10
+ options: PagePrimitiveRenderOptions = {},
11
11
  ): Promise<{
12
12
  html: string;
13
13
  response: Response;
@@ -17,8 +17,8 @@ export class ReactPageService {
17
17
 
18
18
  public render(
19
19
  name: string,
20
- options: PageDescriptorRenderOptions = {},
21
- ): Promise<PageDescriptorRenderResult> {
20
+ options: PagePrimitiveRenderOptions = {},
21
+ ): Promise<PagePrimitiveRenderResult> {
22
22
  throw new AlephaError("Render is not available for this environment.");
23
23
  }
24
24
  }
@@ -1,5 +1,5 @@
1
1
  import { $inject, Alepha } from "alepha";
2
- import type { PageDescriptor } from "../descriptors/$page.ts";
2
+ import type { PagePrimitive } from "../primitives/$page.ts";
3
3
  import {
4
4
  ReactBrowserProvider,
5
5
  type RouterGoOptions,
@@ -15,7 +15,7 @@ export class ReactRouter<T extends object> {
15
15
  protected readonly pageApi = $inject(ReactPageProvider);
16
16
 
17
17
  public get state(): ReactRouterState {
18
- return this.alepha.state.get("alepha.react.router.state")!;
18
+ return this.alepha.store.get("alepha.react.router.state")!;
19
19
  }
20
20
 
21
21
  public get pages() {
@@ -220,5 +220,5 @@ export class ReactRouter<T extends object> {
220
220
  }
221
221
 
222
222
  export type VirtualRouter<T> = {
223
- [K in keyof T as T[K] extends PageDescriptor ? K : never]: T[K];
223
+ [K in keyof T as T[K] extends PagePrimitive ? K : never]: T[K];
224
224
  };
@@ -1,11 +1,11 @@
1
1
  import { AlephaReact } from "@alepha/react";
2
2
  import { $module } from "alepha";
3
- import { $head } from "./descriptors/$head.ts";
3
+ import { $head } from "./primitives/$head.ts";
4
4
  import { BrowserHeadProvider } from "./providers/BrowserHeadProvider.ts";
5
5
 
6
6
  // ---------------------------------------------------------------------------------------------------------------------
7
7
 
8
- export * from "./descriptors/$head.ts";
8
+ export * from "./primitives/$head.ts";
9
9
  export * from "./hooks/useHead.ts";
10
10
  export * from "./interfaces/Head.ts";
11
11
  export * from "./providers/BrowserHeadProvider.ts";
@@ -20,6 +20,6 @@ export * from "./providers/BrowserHeadProvider.ts";
20
20
  */
21
21
  export const AlephaReactHead = $module({
22
22
  name: "alepha.react.head",
23
- descriptors: [$head],
23
+ primitives: [$head],
24
24
  services: [AlephaReact, BrowserHeadProvider],
25
25
  });
package/src/head/index.ts CHANGED
@@ -5,13 +5,13 @@ import {
5
5
  type TPropsParentDefault,
6
6
  } from "@alepha/react";
7
7
  import { $module } from "alepha";
8
- import { $head } from "./descriptors/$head.ts";
8
+ import { $head } from "./primitives/$head.ts";
9
9
  import type { Head } from "./interfaces/Head.ts";
10
10
  import { ServerHeadProvider } from "./providers/ServerHeadProvider.ts";
11
11
 
12
12
  // ---------------------------------------------------------------------------------------------------------------------
13
13
 
14
- export * from "./descriptors/$head.ts";
14
+ export * from "./primitives/$head.ts";
15
15
  export * from "./hooks/useHead.ts";
16
16
  export * from "./interfaces/Head.ts";
17
17
  export * from "./providers/ServerHeadProvider.ts";
@@ -19,7 +19,7 @@ export * from "./providers/ServerHeadProvider.ts";
19
19
  // ---------------------------------------------------------------------------------------------------------------------
20
20
 
21
21
  declare module "@alepha/react" {
22
- interface PageDescriptorOptions<
22
+ interface PagePrimitiveOptions<
23
23
  TConfig extends PageConfigSchema = PageConfigSchema,
24
24
  TProps extends object = TPropsDefault,
25
25
  TPropsParent extends object = TPropsParentDefault,
@@ -42,6 +42,6 @@ declare module "@alepha/react" {
42
42
  */
43
43
  export const AlephaReactHead = $module({
44
44
  name: "alepha.react.head",
45
- descriptors: [$head],
45
+ primitives: [$head],
46
46
  services: [AlephaReact, ServerHeadProvider],
47
47
  });
@@ -1,25 +1,25 @@
1
- import { $inject, createDescriptor, Descriptor, KIND } from "alepha";
1
+ import { $inject, createPrimitive, Primitive, KIND } from "alepha";
2
2
  import type { Head } from "../interfaces/Head.ts";
3
3
  import { HeadProvider } from "../providers/HeadProvider.ts";
4
4
 
5
5
  /**
6
6
  * Set global `<head>` options for the application.
7
7
  */
8
- export const $head = (options: HeadDescriptorOptions) => {
9
- return createDescriptor(HeadDescriptor, options);
8
+ export const $head = (options: HeadPrimitiveOptions) => {
9
+ return createPrimitive(HeadPrimitive, options);
10
10
  };
11
11
 
12
12
  // ---------------------------------------------------------------------------------------------------------------------
13
13
 
14
- export type HeadDescriptorOptions = Head | (() => Head);
14
+ export type HeadPrimitiveOptions = Head | (() => Head);
15
15
 
16
16
  // ---------------------------------------------------------------------------------------------------------------------
17
17
 
18
- export class HeadDescriptor extends Descriptor<HeadDescriptorOptions> {
18
+ export class HeadPrimitive extends Primitive<HeadPrimitiveOptions> {
19
19
  protected readonly provider = $inject(HeadProvider);
20
20
  protected onInit() {
21
21
  this.provider.global = this.options;
22
22
  }
23
23
  }
24
24
 
25
- $head[KIND] = HeadDescriptor;
25
+ $head[KIND] = HeadPrimitive;
@@ -1,5 +1,5 @@
1
1
  import { useInject, useStore } from "@alepha/react";
2
- import type { DictionaryDescriptor } from "../descriptors/$dictionary.ts";
2
+ import type { DictionaryPrimitive } from "../primitives/$dictionary.ts";
3
3
  import { I18nProvider } from "../providers/I18nProvider.ts";
4
4
 
5
5
  /**
@@ -14,5 +14,5 @@ export const useI18n = <
14
14
  };
15
15
 
16
16
  export type ServiceDictionary<T extends object> = {
17
- [K in keyof T]: T[K] extends DictionaryDescriptor<infer U> ? U : never;
17
+ [K in keyof T]: T[K] extends DictionaryPrimitive<infer U> ? U : never;
18
18
  };
package/src/i18n/index.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import { $module } from "alepha";
2
- import { $dictionary } from "./descriptors/$dictionary.ts";
2
+ import { $dictionary } from "./primitives/$dictionary.ts";
3
3
  import { I18nProvider } from "./providers/I18nProvider.ts";
4
4
 
5
5
  // ---------------------------------------------------------------------------------------------------------------------
6
6
 
7
7
  export type { LocalizeProps } from "./components/Localize.tsx";
8
8
  export { default as Localize } from "./components/Localize.tsx";
9
- export * from "./descriptors/$dictionary.ts";
9
+ export * from "./primitives/$dictionary.ts";
10
10
  export * from "./hooks/useI18n.ts";
11
11
  export * from "./providers/I18nProvider.ts";
12
12
 
@@ -29,6 +29,6 @@ declare module "alepha" {
29
29
  */
30
30
  export const AlephaReactI18n = $module({
31
31
  name: "alepha.react.i18n",
32
- descriptors: [$dictionary],
32
+ primitives: [$dictionary],
33
33
  services: [I18nProvider],
34
34
  });
@@ -1,4 +1,4 @@
1
- import { $inject, type Async, createDescriptor, Descriptor, KIND } from "alepha";
1
+ import { $inject, type Async, createPrimitive, Primitive, KIND } from "alepha";
2
2
  import { I18nProvider } from "../providers/I18nProvider.ts";
3
3
 
4
4
  /**
@@ -33,14 +33,14 @@ import { I18nProvider } from "../providers/I18nProvider.ts";
33
33
  * ```
34
34
  */
35
35
  export const $dictionary = <T extends Record<string, string>>(
36
- options: DictionaryDescriptorOptions<T>,
37
- ): DictionaryDescriptor<T> => {
38
- return createDescriptor(DictionaryDescriptor<T>, options);
36
+ options: DictionaryPrimitiveOptions<T>,
37
+ ): DictionaryPrimitive<T> => {
38
+ return createPrimitive(DictionaryPrimitive<T>, options);
39
39
  };
40
40
 
41
41
  // ---------------------------------------------------------------------------------------------------------------------
42
42
 
43
- export interface DictionaryDescriptorOptions<T extends Record<string, string>> {
43
+ export interface DictionaryPrimitiveOptions<T extends Record<string, string>> {
44
44
  lang?: string;
45
45
  name?: string;
46
46
  lazy: () => Async<{ default: T }>;
@@ -48,9 +48,9 @@ export interface DictionaryDescriptorOptions<T extends Record<string, string>> {
48
48
 
49
49
  // ---------------------------------------------------------------------------------------------------------------------
50
50
 
51
- export class DictionaryDescriptor<
51
+ export class DictionaryPrimitive<
52
52
  T extends Record<string, string>,
53
- > extends Descriptor<DictionaryDescriptorOptions<T>> {
53
+ > extends Primitive<DictionaryPrimitiveOptions<T>> {
54
54
  protected provider = $inject(I18nProvider);
55
55
  protected onInit() {
56
56
  this.provider.registry.push({
@@ -66,4 +66,4 @@ export class DictionaryDescriptor<
66
66
  }
67
67
  }
68
68
 
69
- $dictionary[KIND] = DictionaryDescriptor;
69
+ $dictionary[KIND] = DictionaryPrimitive;
@@ -54,7 +54,7 @@ export class I18nProvider<
54
54
  on: "server:onRequest",
55
55
  priority: "last",
56
56
  handler: async ({ request }) => {
57
- this.alepha.state.set("alepha.react.i18n.lang", this.cookie.get(request));
57
+ this.alepha.store.set("alepha.react.i18n.lang", this.cookie.get(request));
58
58
  },
59
59
  });
60
60
 
@@ -65,7 +65,7 @@ export class I18nProvider<
65
65
  // get cookie lang
66
66
  const cookieLang = this.cookie.get();
67
67
  if (cookieLang) {
68
- this.alepha.state.set("alepha.react.i18n.lang", cookieLang);
68
+ this.alepha.store.set("alepha.react.i18n.lang", cookieLang);
69
69
  }
70
70
 
71
71
  for (const item of this.registry) {
@@ -110,7 +110,7 @@ export class I18nProvider<
110
110
  this.cookie.set(lang);
111
111
  }
112
112
 
113
- this.alepha.state.set("alepha.react.i18n.lang", lang);
113
+ this.alepha.store.set("alepha.react.i18n.lang", lang);
114
114
  this.refreshLocale();
115
115
  };
116
116
 
@@ -132,7 +132,7 @@ export class I18nProvider<
132
132
  this.refreshLocale();
133
133
 
134
134
  if (hasChanged) {
135
- this.alepha.state.set("alepha.react.i18n.lang", value);
135
+ this.alepha.store.set("alepha.react.i18n.lang", value);
136
136
  }
137
137
  }
138
138
  },
@@ -140,7 +140,7 @@ export class I18nProvider<
140
140
 
141
141
  public get lang(): string {
142
142
  return (
143
- this.alepha.state.get("alepha.react.i18n.lang") ||
143
+ this.alepha.store.get("alepha.react.i18n.lang") ||
144
144
  this.options.fallbackLang
145
145
  );
146
146
  }
@@ -1,6 +1,6 @@
1
1
  import { useAlepha, useInject } from "@alepha/react";
2
2
  import type { Static } from "alepha";
3
- import type { ChannelDescriptor, TWSObject } from "alepha/websocket";
3
+ import type { ChannelPrimitive, TWSObject } from "alepha/websocket";
4
4
  import { WebSocketClient } from "alepha/websocket";
5
5
  import { useEffect, useRef, useState } from "react";
6
6
 
@@ -17,9 +17,9 @@ export interface UseRoomOptions<
17
17
  roomId: string;
18
18
 
19
19
  /**
20
- * Channel descriptor defining the schemas
20
+ * Channel primitive defining the schemas
21
21
  */
22
- channel: ChannelDescriptor<TClient, TServer>;
22
+ channel: ChannelPrimitive<TClient, TServer>;
23
23
 
24
24
  /**
25
25
  * Handler for incoming messages from the server