@koine/i18n 2.0.0-beta.205 → 2.0.0-beta.206

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.
@@ -1,9 +1,4 @@
1
1
  export type Options = {
2
- /**
3
- * A valid JavaScript object key identifier on whc
4
- *
5
- * @default "__i18n_locale"
6
- */
7
2
  /**
8
3
  * - When `true` it outpus each function in a separate file with a `named` and a
9
4
  * `default` export in order to fully support SWC transforms optimization (see
@@ -73,6 +73,31 @@ export const I18nLayout = async ({
73
73
  );
74
74
  };
75
75
 
76
+ /**
77
+ * Props passed to the layout component created by \`createI18nLayout.default\`
78
+ */
79
+ export type I18nLayoutCreatedProps<
80
+ TProps extends I18nNextPropsLayout = I18nNextPropsLayout,
81
+ TConfigurator extends I18nServerConfigurator<Config, TProps> = I18nServerConfigurator<Config, TProps>
82
+ > = I18nProps<TProps, Config, TConfigurator> &
83
+ React.PropsWithChildren<{
84
+ /**
85
+ * Render this in
86
+ * - \`/app/[${e}]/layout.tsx\`
87
+ * - \`/app/not-found.tsx\`
88
+ */
89
+ I18nScript: React.ReactNode;
90
+ /**
91
+ * Spread this prop on the \`<html {...i18nHtmlAttrs}>\` element in:
92
+ * - \`app/[${e}]/layout.tsx\`
93
+ * - \`app/not-found.tsx\`
94
+ */
95
+ i18nHtmlAttrs: Pick<
96
+ React.ComponentPropsWithoutRef<"html">,
97
+ "lang" | "dir"
98
+ >
99
+ }>;
100
+
76
101
  /**
77
102
  * @example
78
103
  *
@@ -167,26 +192,7 @@ export const createI18nLayout =
167
192
  };
168
193
  },
169
194
  default: (
170
- impl: (
171
- props: I18nProps<TProps, Config, TConfigurator> &
172
- React.PropsWithChildren<{
173
- /**
174
- * Render this in
175
- * - \`/app/[${e}]/layout.tsx\`
176
- * - \`/app/not-found.tsx\`
177
- */
178
- I18nScript: React.ReactNode;
179
- /**
180
- * Spread this prop on the \`<html {...i18nHtmlAttrs}>\` element in:
181
- * - \`app/[${e}]/layout.tsx\`
182
- * - \`app/not-found.tsx\`
183
- */
184
- i18nHtmlAttrs: Pick<
185
- React.ComponentPropsWithoutRef<"html">,
186
- "lang" | "dir"
187
- >
188
- }>,
189
- ) => React.ReactNode | Promise<React.ReactNode>,
195
+ impl: (props: I18nLayoutCreatedProps<TProps, TConfigurator>) => React.ReactNode | Promise<React.ReactNode>,
190
196
  ) => {
191
197
  return async (rawProps: NextProps<TProps>) => {
192
198
  const { params: _rawParams, ...rawPropsWithoutParams } = rawProps;
@@ -71,6 +71,31 @@ export const I18nLayout = async ({
71
71
  );
72
72
  };
73
73
 
74
+ /**
75
+ * Props passed to the layout component created by \`createI18nLayout.default\`
76
+ */
77
+ export type I18nLayoutCreatedProps<
78
+ TProps extends I18nNextPropsLayout = I18nNextPropsLayout,
79
+ TConfigurator extends I18nServerConfigurator<Config, TProps> = I18nServerConfigurator<Config, TProps>
80
+ > = I18nProps<TProps, Config, TConfigurator> &
81
+ React.PropsWithChildren<{
82
+ /**
83
+ * Render this in
84
+ * - \`/app/[${e}]/layout.tsx\`
85
+ * - \`/app/not-found.tsx\`
86
+ */
87
+ I18nScript: React.ReactNode;
88
+ /**
89
+ * Spread this prop on the \`<html {...i18nHtmlAttrs}>\` element in:
90
+ * - \`app/[${e}]/layout.tsx\`
91
+ * - \`app/not-found.tsx\`
92
+ */
93
+ i18nHtmlAttrs: Pick<
94
+ React.ComponentPropsWithoutRef<"html">,
95
+ "lang" | "dir"
96
+ >
97
+ }>;
98
+
74
99
  /**
75
100
  * @example
76
101
  *
@@ -165,26 +190,7 @@ export const createI18nLayout =
165
190
  };
166
191
  },
167
192
  default: (
168
- impl: (
169
- props: I18nProps<TProps, Config, TConfigurator> &
170
- React.PropsWithChildren<{
171
- /**
172
- * Render this in
173
- * - \`/app/[${e}]/layout.tsx\`
174
- * - \`/app/not-found.tsx\`
175
- */
176
- I18nScript: React.ReactNode;
177
- /**
178
- * Spread this prop on the \`<html {...i18nHtmlAttrs}>\` element in:
179
- * - \`app/[${e}]/layout.tsx\`
180
- * - \`app/not-found.tsx\`
181
- */
182
- i18nHtmlAttrs: Pick<
183
- React.ComponentPropsWithoutRef<"html">,
184
- "lang" | "dir"
185
- >
186
- }>,
187
- ) => React.ReactNode | Promise<React.ReactNode>,
193
+ impl: (props: I18nLayoutCreatedProps<TProps, TConfigurator>) => React.ReactNode | Promise<React.ReactNode>,
188
194
  ) => {
189
195
  return async (rawProps: NextProps<TProps>) => {
190
196
  const { params: _rawParams, ...rawPropsWithoutParams } = rawProps;
@@ -3,7 +3,7 @@
3
3
  var createAdapter = require('../../../compiler/createAdapter.cjs.js');
4
4
 
5
5
  var s = createAdapter.createGenerator("next", (o)=>{
6
- let { options: { routes: { localeParamName: r }, adapter: { meta: { nextVersion: a } } } } = o, t = (e)=>a >= 15 ? `Promise<${e}>` : e;
6
+ let { options: { routes: { localeParamName: r }, adapter: { meta: { nextVersion: t } } } } = o, a = (e)=>t >= 15 ? `Promise<${e}>` : e;
7
7
  return {
8
8
  i18nServerHelpers: {
9
9
  dir: createAdapter.createGenerator.dirs.server,
@@ -47,10 +47,10 @@ type SegmentParams = Partial<Record<string, string | string[]>>;
47
47
  */
48
48
  export type NextProps<P> = Omit<P, "params"> &
49
49
  (P extends { params?: Promise<infer T> }
50
- ? { params: ${t("Simplify<Omit<T, keyof I18nParams>>")} }
50
+ ? { params: ${a("Simplify<Omit<T, keyof I18nParams>>")} }
51
51
  : P extends { params?: infer T }
52
- ? { params: ${t("Simplify<Omit<T, keyof I18nParams>>")} }
53
- : { params?: ${t("{}")} });
52
+ ? { params: ${a("Simplify<Omit<T, keyof I18nParams>>")} }
53
+ : { params?: ${a("{}")} });
54
54
 
55
55
  export type UnwrapParamsPromise<P> = Omit<P, "params"> &
56
56
  (P extends { params?: Promise<infer T> }
@@ -141,6 +141,7 @@ import { createI18nLayout } from "./I18nLayout";
141
141
  import { createI18nPage } from "./I18nPage";
142
142
 
143
143
  export type { I18n } from "../types";
144
+ export type { I18nLayoutCreatedProps } from "./I18nLayout";
144
145
 
145
146
  export type I18nServer = typeof i18nServer;
146
147
 
@@ -1,7 +1,7 @@
1
1
  import { createGenerator } from '../../../compiler/createAdapter.esm.js';
2
2
 
3
3
  var s = createGenerator("next", (o)=>{
4
- let { options: { routes: { localeParamName: r }, adapter: { meta: { nextVersion: a } } } } = o, t = (e)=>a >= 15 ? `Promise<${e}>` : e;
4
+ let { options: { routes: { localeParamName: r }, adapter: { meta: { nextVersion: t } } } } = o, a = (e)=>t >= 15 ? `Promise<${e}>` : e;
5
5
  return {
6
6
  i18nServerHelpers: {
7
7
  dir: createGenerator.dirs.server,
@@ -45,10 +45,10 @@ type SegmentParams = Partial<Record<string, string | string[]>>;
45
45
  */
46
46
  export type NextProps<P> = Omit<P, "params"> &
47
47
  (P extends { params?: Promise<infer T> }
48
- ? { params: ${t("Simplify<Omit<T, keyof I18nParams>>")} }
48
+ ? { params: ${a("Simplify<Omit<T, keyof I18nParams>>")} }
49
49
  : P extends { params?: infer T }
50
- ? { params: ${t("Simplify<Omit<T, keyof I18nParams>>")} }
51
- : { params?: ${t("{}")} });
50
+ ? { params: ${a("Simplify<Omit<T, keyof I18nParams>>")} }
51
+ : { params?: ${a("{}")} });
52
52
 
53
53
  export type UnwrapParamsPromise<P> = Omit<P, "params"> &
54
54
  (P extends { params?: Promise<infer T> }
@@ -139,6 +139,7 @@ import { createI18nLayout } from "./I18nLayout";
139
139
  import { createI18nPage } from "./I18nPage";
140
140
 
141
141
  export type { I18n } from "../types";
142
+ export type { I18nLayoutCreatedProps } from "./I18nLayout";
142
143
 
143
144
  export type I18nServer = typeof i18nServer;
144
145
 
@@ -38,7 +38,10 @@ const adapterNext = createAdapter.createAdapter({
38
38
  modularizeI18nImports: true,
39
39
  globalize: {
40
40
  prefix: "i18n",
41
- functions: true
41
+ functions: {
42
+ routes: false,
43
+ translations: false
44
+ }
42
45
  }
43
46
  },
44
47
  getMeta: (t)=>{
@@ -40,15 +40,19 @@ export type Options = AdapterReact.Options & {
40
40
  * You can generate all-or-nothing by passing a `boolean` or handpick which
41
41
  * categories of functions to generate.
42
42
  *
43
- * @default true
43
+ * @default { routes: false, translations: false}
44
44
  */
45
45
  functions: boolean | {
46
46
  /**
47
47
  * Configure generation of _routes_' `to` functions
48
+ *
49
+ * @default false
48
50
  */
49
51
  routes: boolean;
50
52
  /**
51
53
  * Configure generation of _translations_' `t` functions
54
+ *
55
+ * @default false
52
56
  */
53
57
  translations: boolean;
54
58
  };
@@ -71,10 +75,14 @@ export declare function resolveGlobalizeOption(globalize: Options["globalize"]):
71
75
  functions: {
72
76
  /**
73
77
  * Configure generation of _routes_' `to` functions
78
+ *
79
+ * @default false
74
80
  */
75
81
  routes: boolean;
76
82
  /**
77
83
  * Configure generation of _translations_' `t` functions
84
+ *
85
+ * @default false
78
86
  */
79
87
  translations: boolean;
80
88
  };
@@ -211,7 +219,10 @@ export declare const adapterNext: {
211
219
  modularizeI18nImports: true;
212
220
  globalize: {
213
221
  prefix: string;
214
- functions: true;
222
+ functions: {
223
+ routes: false;
224
+ translations: false;
225
+ };
215
226
  };
216
227
  modularize: true;
217
228
  };
@@ -34,7 +34,10 @@ const adapterNext = createAdapter({
34
34
  modularizeI18nImports: true,
35
35
  globalize: {
36
36
  prefix: "i18n",
37
- functions: true
37
+ functions: {
38
+ routes: false,
39
+ translations: false
40
+ }
38
41
  }
39
42
  },
40
43
  getMeta: (t)=>{
package/package.json CHANGED
@@ -5,9 +5,9 @@
5
5
  "node": ">=18.0.0"
6
6
  },
7
7
  "dependencies": {
8
- "@koine/dom": "2.0.0-beta.205",
9
- "@koine/node": "2.0.0-beta.205",
10
- "@koine/utils": "2.0.0-beta.205",
8
+ "@koine/dom": "2.0.0-beta.206",
9
+ "@koine/node": "2.0.0-beta.206",
10
+ "@koine/utils": "2.0.0-beta.206",
11
11
  "comment-json": "^4.2.4",
12
12
  "consola": "^3.2.3",
13
13
  "glob": "^11.0.0",
@@ -130,5 +130,5 @@
130
130
  "module": "./index.esm.js",
131
131
  "main": "./index.cjs.js",
132
132
  "types": "./index.d.ts",
133
- "version": "2.0.0-beta.205"
133
+ "version": "2.0.0-beta.206"
134
134
  }