@alepha/react 0.13.1 → 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.
- package/dist/auth/index.browser.js +5 -5
- package/dist/auth/index.browser.js.map +1 -1
- package/dist/auth/index.d.ts +330 -330
- package/dist/auth/index.js +7 -7
- package/dist/auth/index.js.map +1 -1
- package/dist/core/index.browser.js +19 -18
- package/dist/core/index.browser.js.map +1 -1
- package/dist/core/index.d.ts +352 -344
- package/dist/core/index.js +25 -24
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.native.js +381 -0
- package/dist/core/index.native.js.map +1 -0
- package/dist/form/index.d.ts +2 -2
- package/dist/head/index.browser.js +7 -7
- package/dist/head/index.browser.js.map +1 -1
- package/dist/head/index.d.ts +265 -265
- package/dist/head/index.js +7 -7
- package/dist/head/index.js.map +1 -1
- package/dist/i18n/index.d.ts +20 -20
- package/dist/i18n/index.js +12 -12
- package/dist/i18n/index.js.map +1 -1
- package/dist/websocket/index.d.ts +7 -7
- package/dist/websocket/index.js.map +1 -1
- package/package.json +18 -9
- package/src/auth/index.ts +1 -1
- package/src/auth/providers/ReactAuthProvider.ts +1 -1
- package/src/auth/services/ReactAuth.ts +5 -5
- package/src/core/components/NestedView.tsx +1 -1
- package/src/core/hooks/useStore.ts +4 -4
- package/src/core/index.browser.ts +2 -2
- package/src/core/index.native.ts +1 -1
- package/src/core/index.shared-router.ts +1 -1
- package/src/core/index.ts +3 -3
- package/src/core/{descriptors → primitives}/$page.ts +20 -20
- package/src/core/providers/ReactBrowserProvider.ts +2 -2
- package/src/core/providers/ReactBrowserRouterProvider.ts +2 -2
- package/src/core/providers/ReactPageProvider.ts +25 -11
- package/src/core/providers/ReactServerProvider.ts +12 -12
- package/src/core/services/ReactPageServerService.ts +6 -6
- package/src/core/services/ReactPageService.ts +6 -6
- package/src/core/services/ReactRouter.ts +3 -3
- package/src/head/index.browser.ts +3 -3
- package/src/head/index.ts +4 -4
- package/src/head/{descriptors → primitives}/$head.ts +6 -6
- package/src/i18n/hooks/useI18n.ts +2 -2
- package/src/i18n/index.ts +3 -3
- package/src/i18n/{descriptors → primitives}/$dictionary.ts +8 -8
- package/src/i18n/providers/I18nProvider.ts +5 -5
- package/src/websocket/hooks/useRoom.tsx +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $inject, type Async,
|
|
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:
|
|
37
|
-
):
|
|
38
|
-
return
|
|
36
|
+
options: DictionaryPrimitiveOptions<T>,
|
|
37
|
+
): DictionaryPrimitive<T> => {
|
|
38
|
+
return createPrimitive(DictionaryPrimitive<T>, options);
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
// ---------------------------------------------------------------------------------------------------------------------
|
|
42
42
|
|
|
43
|
-
export interface
|
|
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
|
|
51
|
+
export class DictionaryPrimitive<
|
|
52
52
|
T extends Record<string, string>,
|
|
53
|
-
> extends
|
|
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] =
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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 {
|
|
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
|
|
20
|
+
* Channel primitive defining the schemas
|
|
21
21
|
*/
|
|
22
|
-
channel:
|
|
22
|
+
channel: ChannelPrimitive<TClient, TServer>;
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Handler for incoming messages from the server
|