@saykit/react 0.0.0-beta-20260330102339 → 0.0.0-beta-20260418203312

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/client.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import * as react from "react";
1
+ import * as _$react from "react";
2
2
  import { PropsWithChildren } from "react";
3
3
  import { ReadonlySay, Say } from "saykit";
4
4
 
@@ -20,7 +20,7 @@ declare function SayProvider({
20
20
  }: PropsWithChildren<{
21
21
  locale: string;
22
22
  messages: Say.Messages;
23
- }>): react.FunctionComponentElement<react.ProviderProps<SayRef>>;
23
+ }>): _$react.FunctionComponentElement<_$react.ProviderProps<SayRef>>;
24
24
  /**
25
25
  * Get the current {@link Say} **client** instance.
26
26
  * Must be called within a {@link SayProvider}.
@@ -30,5 +30,4 @@ declare function SayProvider({
30
30
  */
31
31
  declare function useSay(): any;
32
32
  //#endregion
33
- export { SayProvider, useSay };
34
- //# sourceMappingURL=client.d.mts.map
33
+ export { SayProvider, useSay };
package/dist/client.mjs CHANGED
@@ -1,8 +1,6 @@
1
- 'use client';
2
-
1
+ "use client";
3
2
  import { createContext, createElement, useContext, useState } from "react";
4
3
  import { Say } from "saykit";
5
-
6
4
  //#region src/runtime/client.ts
7
5
  const SayContext = createContext({ current: null });
8
6
  SayContext.displayName = "SayContext";
@@ -37,7 +35,5 @@ function useSay() {
37
35
  if (!ref.current) throw new Error("'useSay' must be used within a 'SayProvider'");
38
36
  return ref.current;
39
37
  }
40
-
41
38
  //#endregion
42
39
  export { SayProvider, useSay };
43
- //# sourceMappingURL=client.mjs.map
@@ -1,5 +1,4 @@
1
1
  "use client"; import { useSay as GET_SAY } from "./client.mjs";import { Fragment, cloneElement, createElement, isValidElement } from "react";
2
-
3
2
  //#region src/components/renderer.ts
4
3
  function Renderer({ html, components }) {
5
4
  function getComponent(tag) {
@@ -44,7 +43,6 @@ function Renderer({ html, components }) {
44
43
  }
45
44
  return createElement(Fragment, void 0, ...parseNode(html));
46
45
  }
47
-
48
46
  //#endregion
49
47
  //#region src/types.ts
50
48
  function resolveJsxSafePropKeys(props) {
@@ -53,7 +51,6 @@ function resolveJsxSafePropKeys(props) {
53
51
  else result[key] = props[key];
54
52
  return result;
55
53
  }
56
-
57
54
  //#endregion
58
55
  //#region src/runtime/index.ts
59
56
  function Say(props) {
@@ -87,7 +84,5 @@ function Say(props) {
87
84
  }
88
85
  _Say.Select = Select;
89
86
  })(Say || (Say = {}));
90
-
91
87
  //#endregion
92
88
  export { Say };
93
- //# sourceMappingURL=index.mjs.map
package/dist/index.d.mts CHANGED
@@ -81,5 +81,4 @@ declare namespace Say {
81
81
  } & PropsWithJSXSafeKeys<Disallow<SelectOptions, 'id' | 'context'>>): ReactNode;
82
82
  }
83
83
  //#endregion
84
- export { Say };
85
- //# sourceMappingURL=index.d.mts.map
84
+ export { Say };
@@ -1,5 +1,4 @@
1
1
  import { getSay as GET_SAY } from "./server.mjs";import { Fragment, cloneElement, createElement, isValidElement } from "react";
2
-
3
2
  //#region src/components/renderer.ts
4
3
  function Renderer({ html, components }) {
5
4
  function getComponent(tag) {
@@ -44,7 +43,6 @@ function Renderer({ html, components }) {
44
43
  }
45
44
  return createElement(Fragment, void 0, ...parseNode(html));
46
45
  }
47
-
48
46
  //#endregion
49
47
  //#region src/types.ts
50
48
  function resolveJsxSafePropKeys(props) {
@@ -53,7 +51,6 @@ function resolveJsxSafePropKeys(props) {
53
51
  else result[key] = props[key];
54
52
  return result;
55
53
  }
56
-
57
54
  //#endregion
58
55
  //#region src/runtime/index.ts
59
56
  function Say(props) {
@@ -87,7 +84,5 @@ function Say(props) {
87
84
  }
88
85
  _Say.Select = Select;
89
86
  })(Say || (Say = {}));
90
-
91
87
  //#endregion
92
88
  export { Say };
93
- //# sourceMappingURL=index.mjs.map
package/dist/server.d.mts CHANGED
@@ -1,8 +1,6 @@
1
- import * as react from "react";
1
+ import * as _$react from "react";
2
2
  import { ReactNode } from "react";
3
3
  import { ReadonlySay, Say } from "saykit";
4
- import "server-only";
5
-
6
4
  //#region src/runtime/server.d.ts
7
5
  /**
8
6
  * Set the current {@link Say} **server** instance.
@@ -26,13 +24,10 @@ declare function getSay(): ReadonlySay;
26
24
  *
27
25
  * @returns A {@link withSay} higher-order component factory
28
26
  */
29
- declare function unstable_createWithSay(say: Say): <P extends object>(Component: (props: P & {
27
+ declare function unstable_createWithSay(say: Say): <P = unknown>(Component: (props: PropsWithSay<P>) => ReactNode, getLocale: (props: P) => string | Promise<string>) => (props: P) => Promise<_$react.FunctionComponentElement<PropsWithSay<P>>>;
28
+ type PropsWithSay<P = unknown> = P & {
30
29
  locale: string;
31
30
  messages: Say.Messages;
32
- }) => ReactNode, getLocale: (props: P) => string | Promise<string>) => (props: P) => Promise<react.FunctionComponentElement<P & {
33
- locale: string;
34
- messages: Say.Messages;
35
- }>>;
31
+ };
36
32
  //#endregion
37
- export { getSay, setSay, unstable_createWithSay };
38
- //# sourceMappingURL=server.d.mts.map
33
+ export { PropsWithSay, getSay, setSay, unstable_createWithSay };
package/dist/server.mjs CHANGED
@@ -1,7 +1,6 @@
1
1
  import { cache, createElement } from "react";
2
2
  import { Say } from "saykit";
3
3
  import "server-only";
4
-
5
4
  //#region src/runtime/server.ts
6
5
  const serverContext = cache(() => ({ current: null }));
7
6
  /**
@@ -12,8 +11,8 @@ const serverContext = cache(() => ({ current: null }));
12
11
  */
13
12
  function setSay(say) {
14
13
  const ref = serverContext();
15
- if (say instanceof Say) ref.current = say;
16
- else ref.current = say();
14
+ if (say instanceof Say) ref.current = say.clone().freeze();
15
+ else ref.current = say().clone().freeze();
17
16
  }
18
17
  /**
19
18
  * Get the current {@link Say} **server** instance.
@@ -40,7 +39,8 @@ function unstable_createWithSay(say) {
40
39
  */
41
40
  return function withSay(Component, getLocale) {
42
41
  return async function WithSay(props) {
43
- const locale = await getLocale(props);
42
+ const guess = await getLocale(props);
43
+ const locale = say.match(guess);
44
44
  await say.load(locale);
45
45
  say.activate(locale);
46
46
  setSay(say);
@@ -52,7 +52,5 @@ function unstable_createWithSay(say) {
52
52
  };
53
53
  };
54
54
  }
55
-
56
55
  //#endregion
57
56
  export { getSay, setSay, unstable_createWithSay };
58
- //# sourceMappingURL=server.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saykit/react",
3
- "version": "0.0.0-beta-20260330102339",
3
+ "version": "0.0.0-beta-20260418203312",
4
4
  "description": "React integration for saykit, i18n hooks and components",
5
5
  "keywords": [
6
6
  "i18n",
@@ -46,13 +46,13 @@
46
46
  "server-only": "^0.0.1"
47
47
  },
48
48
  "devDependencies": {
49
- "@types/react": "^19.2.13",
50
- "react": "^19.2.4",
51
- "saykit": "^0.0.0-beta-20260330102339"
49
+ "@types/react": "^19.2.14",
50
+ "react": "^19.2.5",
51
+ "saykit": "^0.0.0-beta-20260418203312"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "react": "*",
55
- "saykit": "0.0.0-beta-20260330102339"
55
+ "saykit": "0.0.0-beta-20260418203312"
56
56
  },
57
57
  "scripts": {
58
58
  "check": "tsc --noEmit",