@koine/i18n 2.0.0-beta.192 → 2.0.0-beta.193

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 (56) hide show
  1. package/adapter-js/generators/config.cjs.js +1 -1
  2. package/adapter-js/generators/config.esm.js +1 -1
  3. package/adapter-js/generators/t.cjs.js +9 -9
  4. package/adapter-js/generators/t.esm.js +9 -9
  5. package/adapter-js/generators/to.cjs.js +16 -16
  6. package/adapter-js/generators/to.esm.js +16 -16
  7. package/adapter-js/index.cjs.js +1 -0
  8. package/adapter-js/index.d.ts +2 -0
  9. package/adapter-js/index.esm.js +1 -0
  10. package/adapter-next/generators/next-redirects.cjs.js +2 -2
  11. package/adapter-next/generators/next-redirects.esm.js +2 -2
  12. package/adapter-next/generators/next-rewrites.cjs.js +2 -2
  13. package/adapter-next/generators/next-rewrites.esm.js +2 -2
  14. package/adapter-next/generators/router-app/I18nLayout.cjs.js +42 -35
  15. package/adapter-next/generators/router-app/I18nLayout.esm.js +42 -35
  16. package/adapter-next/generators/router-app/I18nLayoutRoot.cjs.js +2 -2
  17. package/adapter-next/generators/router-app/I18nLayoutRoot.esm.js +2 -2
  18. package/adapter-next/generators/router-app/I18nPage.cjs.js +40 -30
  19. package/adapter-next/generators/router-app/I18nPage.esm.js +40 -30
  20. package/adapter-next/generators/router-app/i18nServer.cjs.js +50 -38
  21. package/adapter-next/generators/router-app/i18nServer.esm.js +50 -38
  22. package/adapter-next/generators/router-pages/I18nApp.cjs.js +2 -2
  23. package/adapter-next/generators/router-pages/I18nApp.esm.js +2 -2
  24. package/adapter-next/generators/router-pages/I18nDocument.cjs.js +2 -2
  25. package/adapter-next/generators/router-pages/I18nDocument.esm.js +2 -2
  26. package/adapter-next/generators/router-pages/I18nHead.cjs.js +2 -2
  27. package/adapter-next/generators/router-pages/I18nHead.esm.js +2 -2
  28. package/adapter-next/generators/router-pages/I18nSetter.cjs.js +2 -2
  29. package/adapter-next/generators/router-pages/I18nSetter.esm.js +2 -2
  30. package/adapter-next/generators/router-pages/i18nGet.cjs.js +2 -2
  31. package/adapter-next/generators/router-pages/i18nGet.esm.js +2 -2
  32. package/adapter-next/generators/useRouteId.cjs.js +1 -1
  33. package/adapter-next/generators/useRouteId.esm.js +1 -1
  34. package/adapter-next/generators/webpack-define.cjs.js +3 -3
  35. package/adapter-next/generators/webpack-define.esm.js +3 -3
  36. package/adapter-next/index.cjs.js +18 -10
  37. package/adapter-next/index.d.ts +9 -2
  38. package/adapter-next/index.esm.js +36 -28
  39. package/adapter-react/generators/I18nEffects.cjs.js +2 -2
  40. package/adapter-react/generators/I18nEffects.esm.js +2 -2
  41. package/adapter-react/generators/I18nHeadTags.cjs.js +2 -2
  42. package/adapter-react/generators/I18nHeadTags.esm.js +2 -2
  43. package/adapter-react/generators/Trans.cjs.js +2 -2
  44. package/adapter-react/generators/Trans.esm.js +2 -2
  45. package/adapter-react/generators/getT.cjs.js +2 -2
  46. package/adapter-react/generators/getT.esm.js +2 -2
  47. package/adapter-react/index.cjs.js +3 -0
  48. package/adapter-react/index.d.ts +4 -2
  49. package/adapter-react/index.esm.js +9 -6
  50. package/compiler/code/adapters.cjs.js +5 -4
  51. package/compiler/code/adapters.esm.js +5 -4
  52. package/compiler/createAdapter.cjs.js +1 -1
  53. package/compiler/createAdapter.d.ts +2 -0
  54. package/compiler/createAdapter.esm.js +1 -1
  55. package/compiler/types.d.ts +18 -6
  56. package/package.json +3 -3
@@ -72,7 +72,7 @@ module.exports = config;
72
72
  name: "i18nSwcTransforms",
73
73
  ext: "js",
74
74
  index: !1,
75
- disabled: !o.options.adapter.modularize,
75
+ disabled: !o.options.adapter.options.modularize,
76
76
  content: ()=>{
77
77
  let { tsconfig: a } = o.options.write || {};
78
78
  if (!a) return "";
@@ -70,7 +70,7 @@ module.exports = config;
70
70
  name: "i18nSwcTransforms",
71
71
  ext: "js",
72
72
  index: !1,
73
- disabled: !o.options.adapter.modularize,
73
+ disabled: !o.options.adapter.options.modularize,
74
74
  content: ()=>{
75
75
  let { tsconfig: a } = o.options.write || {};
76
76
  if (!a) return "";
@@ -11,11 +11,11 @@ var types = require('./types.cjs.js');
11
11
 
12
12
  let c = "count";
13
13
  function getTFunction(t, n) {
14
- let { params: r, plural: o } = t, { single: i } = n, { body: l, imports: m } = function(t, n) {
15
- let { values: r, params: o, plural: i, typeValue: l, equalValues: p } = t, { defaultLocale: m, single: u } = n, y = !u && !p, h = [
14
+ let { params: r, plural: o } = t, { single: i } = n, { body: s, imports: m } = function(t, n) {
15
+ let { values: r, params: o, plural: i, typeValue: s, equalValues: p } = t, { defaultLocale: m, single: u } = n, y = !u && !p, h = [
16
16
  d.types
17
17
  ];
18
- return i && h.push(d.i18nPluralise), o && ("Primitive" === l ? h.push(d.i18nInterpolateParams) : ("Array" === l || "Object" === l) && h.push(d.i18nInterpolateParamsDeep)), {
18
+ return i && h.push(d.i18nPluralise), o && ("Primitive" === s ? h.push(d.i18nInterpolateParams) : ("Array" === s || "Object" === s) && h.push(d.i18nInterpolateParamsDeep)), {
19
19
  imports: h,
20
20
  body: (t)=>{
21
21
  let n = y ? "locale = locale || globalThis." + helpers.GLOBAL_I18N_IDENTIFIER + "; " : "";
@@ -28,7 +28,7 @@ function getTFunction(t, n) {
28
28
  r === t || utils.areEqual(i, n[t]) || (o += `locale === "${r}" ? ${f(i, a)} : `);
29
29
  }
30
30
  return o + f(n[t], a);
31
- }(m, r, y, t), i && (p = `i18nPluralise(${p}, params.${c})`), o && ("Primitive" === l ? p = `i18nInterpolateParams(${p}, params)` : ("Array" === l || "Object" === l) && (p = `i18nInterpolateParamsDeep(${p}, params)`)), n + p;
31
+ }(m, r, y, t), i && (p = `i18nPluralise(${p}, params.${c})`), o && ("Primitive" === s ? p = `i18nInterpolateParams(${p}, params)` : ("Array" === s || "Object" === s) && (p = `i18nInterpolateParamsDeep(${p}, params)`)), n + p;
32
32
  }
33
33
  };
34
34
  }(t, n), u = [], y = r ? o ? {
@@ -49,7 +49,7 @@ function getTFunction(t, n) {
49
49
  description: "Use this to override the current locale" + (i ? " (in case you add other locales to your project)" : ""),
50
50
  defaults: "current locale"
51
51
  }), {
52
- body: l,
52
+ body: s,
53
53
  args: u,
54
54
  imports: m
55
55
  };
@@ -87,11 +87,11 @@ let d = {
87
87
  }, y = (e, t)=>{
88
88
  let n = [], r = new Set();
89
89
  for(let a in r.add(d.types), e){
90
- let o = e[a], { imports: i, args: s, body: p } = getTFunction(o, t);
90
+ let o = e[a], { imports: i, args: l, body: p } = getTFunction(o, t);
91
91
  i.forEach((e)=>r.add(e)), n.push(new functions.FunctionsCompiler({
92
92
  imports: i,
93
93
  name: o.fnName,
94
- args: s,
94
+ args: l,
95
95
  body: p,
96
96
  comment: {
97
97
  tags: [
@@ -109,7 +109,7 @@ let d = {
109
109
  };
110
110
  };
111
111
  var u = createAdapter.createGenerator("js", (e)=>{
112
- let { config: t, options: { translations: n, adapter: { modularize: r } }, translations: a } = e, { dir: o } = n.functions, { functions: i, allImports: s } = y(a, t);
112
+ let { config: t, options: { translations: n, adapter: { options: { modularize: r } } }, translations: a } = e, { dir: o } = n.functions, { functions: i, allImports: l } = y(a, t);
113
113
  return r ? i.reduce((e, t)=>(e[t.name] = {
114
114
  dir: o,
115
115
  name: t.name,
@@ -129,7 +129,7 @@ var u = createAdapter.createGenerator("js", (e)=>{
129
129
  name: o,
130
130
  ext: "ts",
131
131
  index: !1,
132
- content: ()=>"" + (imports.ImportsCompiler.outMany("ts", s) + functions.FunctionsCompiler.outMany("ts", i, {
132
+ content: ()=>"" + (imports.ImportsCompiler.outMany("ts", l) + functions.FunctionsCompiler.outMany("ts", i, {
133
133
  imports: !1,
134
134
  exports: "named",
135
135
  style: "function",
@@ -7,11 +7,11 @@ import { getImportTypes } from './types.esm.js';
7
7
 
8
8
  let c = "count";
9
9
  function getTFunction(t, n) {
10
- let { params: r, plural: o } = t, { single: i } = n, { body: l, imports: m } = function(t, n) {
11
- let { values: r, params: o, plural: i, typeValue: l, equalValues: p } = t, { defaultLocale: m, single: u } = n, y = !u && !p, h = [
10
+ let { params: r, plural: o } = t, { single: i } = n, { body: s, imports: m } = function(t, n) {
11
+ let { values: r, params: o, plural: i, typeValue: s, equalValues: p } = t, { defaultLocale: m, single: u } = n, y = !u && !p, h = [
12
12
  d.types
13
13
  ];
14
- return i && h.push(d.i18nPluralise), o && ("Primitive" === l ? h.push(d.i18nInterpolateParams) : ("Array" === l || "Object" === l) && h.push(d.i18nInterpolateParamsDeep)), {
14
+ return i && h.push(d.i18nPluralise), o && ("Primitive" === s ? h.push(d.i18nInterpolateParams) : ("Array" === s || "Object" === s) && h.push(d.i18nInterpolateParamsDeep)), {
15
15
  imports: h,
16
16
  body: (t)=>{
17
17
  let n = y ? "locale = locale || globalThis." + GLOBAL_I18N_IDENTIFIER + "; " : "";
@@ -24,7 +24,7 @@ function getTFunction(t, n) {
24
24
  r === t || areEqual(i, n[t]) || (o += `locale === "${r}" ? ${f(i, a)} : `);
25
25
  }
26
26
  return o + f(n[t], a);
27
- }(m, r, y, t), i && (p = `i18nPluralise(${p}, params.${c})`), o && ("Primitive" === l ? p = `i18nInterpolateParams(${p}, params)` : ("Array" === l || "Object" === l) && (p = `i18nInterpolateParamsDeep(${p}, params)`)), n + p;
27
+ }(m, r, y, t), i && (p = `i18nPluralise(${p}, params.${c})`), o && ("Primitive" === s ? p = `i18nInterpolateParams(${p}, params)` : ("Array" === s || "Object" === s) && (p = `i18nInterpolateParamsDeep(${p}, params)`)), n + p;
28
28
  }
29
29
  };
30
30
  }(t, n), u = [], y = r ? o ? {
@@ -45,7 +45,7 @@ function getTFunction(t, n) {
45
45
  description: "Use this to override the current locale" + (i ? " (in case you add other locales to your project)" : ""),
46
46
  defaults: "current locale"
47
47
  }), {
48
- body: l,
48
+ body: s,
49
49
  args: u,
50
50
  imports: m
51
51
  };
@@ -83,11 +83,11 @@ let d = {
83
83
  }, y = (e, t)=>{
84
84
  let n = [], r = new Set();
85
85
  for(let a in r.add(d.types), e){
86
- let o = e[a], { imports: i, args: s, body: p } = getTFunction(o, t);
86
+ let o = e[a], { imports: i, args: l, body: p } = getTFunction(o, t);
87
87
  i.forEach((e)=>r.add(e)), n.push(new FunctionsCompiler({
88
88
  imports: i,
89
89
  name: o.fnName,
90
- args: s,
90
+ args: l,
91
91
  body: p,
92
92
  comment: {
93
93
  tags: [
@@ -105,7 +105,7 @@ let d = {
105
105
  };
106
106
  };
107
107
  var u = createGenerator("js", (e)=>{
108
- let { config: t, options: { translations: n, adapter: { modularize: r } }, translations: a } = e, { dir: o } = n.functions, { functions: i, allImports: s } = y(a, t);
108
+ let { config: t, options: { translations: n, adapter: { options: { modularize: r } } }, translations: a } = e, { dir: o } = n.functions, { functions: i, allImports: l } = y(a, t);
109
109
  return r ? i.reduce((e, t)=>(e[t.name] = {
110
110
  dir: o,
111
111
  name: t.name,
@@ -125,7 +125,7 @@ var u = createGenerator("js", (e)=>{
125
125
  name: o,
126
126
  ext: "ts",
127
127
  index: !1,
128
- content: ()=>"" + (ImportsCompiler.outMany("ts", s) + FunctionsCompiler.outMany("ts", i, {
128
+ content: ()=>"" + (ImportsCompiler.outMany("ts", l) + FunctionsCompiler.outMany("ts", i, {
129
129
  imports: !1,
130
130
  exports: "named",
131
131
  style: "function",
@@ -10,8 +10,8 @@ var imports = require('../../compiler/imports.cjs.js');
10
10
  var types = require('./types.cjs.js');
11
11
 
12
12
  function getToFunction(e, o) {
13
- let { id: r, params: n } = e, l = function(e, o) {
14
- let { params: r, pathnames: n, equalValues: l } = e, { defaultLocale: s, single: i } = o, u = !i && !l, d = i ? '""' : "locale", m = r ? ", params" : "";
13
+ let { id: r, params: n } = e, s = function(e, o) {
14
+ let { params: r, pathnames: n, equalValues: s } = e, { defaultLocale: l, single: i } = o, u = !i && !s, d = i ? '""' : "locale", m = r ? ", params" : "";
15
15
  return (e)=>{
16
16
  let o = u ? "locale = locale || globalThis." + helpers.GLOBAL_I18N_IDENTIFIER + "; " : "";
17
17
  o += "return ";
@@ -23,26 +23,26 @@ function getToFunction(e, o) {
23
23
  o !== t && n !== e[t] && (r += `locale === "${o}" ? "${n}"${a} : `);
24
24
  }
25
25
  return r + ('"' + e[t] + '"') + a;
26
- }(s, n, e)}${m})`, o + r;
26
+ }(l, n, e)}${m})`, o + r;
27
27
  };
28
- }(e, o), s = [];
29
- return n && s.push({
28
+ }(e, o), l = [];
29
+ return n && l.push({
30
30
  name: "params",
31
31
  type: `I18n.RouteParams["${r}"]`,
32
32
  optional: !1,
33
33
  description: "Dynamic values to interpolate in the output URL pathname"
34
- }), s.push({
34
+ }), l.push({
35
35
  name: "locale",
36
36
  type: "I18n.Locale",
37
37
  optional: !0,
38
38
  description: "Use this to override the current locale",
39
39
  defaults: "current locale"
40
40
  }), {
41
- body: l,
42
- args: s
41
+ body: s,
42
+ args: l
43
43
  };
44
44
  }
45
- let l = {
45
+ let s = {
46
46
  formatTo: new imports.ImportsCompiler({
47
47
  path: "internal/formatTo",
48
48
  named: [
@@ -57,17 +57,17 @@ var I = createAdapter.createGenerator("js", (t)=>{
57
57
  let { options: { routes: { tokens: { idDelimiter: e } } }, routes: { dynamicRoutes: a, staticRoutes: n } } = t;
58
58
  return {
59
59
  ...function(t) {
60
- let { config: e, routes: a, options: { routes: n, adapter: { modularize: s } } } = t, { dir: i } = n.functions, { functions: u, allImports: d } = function(t, e) {
60
+ let { config: e, routes: a, options: { routes: n, adapter: { options: { modularize: l } } } } = t, { dir: i } = n.functions, { functions: u, allImports: d } = function(t, e) {
61
61
  let a = [], r = new Set();
62
- for(let n in r.add(l.formatTo), r.add(l.types), t.byId){
63
- let r = t.byId[n], { args: s, body: i } = getToFunction(r, e);
62
+ for(let n in r.add(s.formatTo), r.add(s.types), t.byId){
63
+ let r = t.byId[n], { args: l, body: i } = getToFunction(r, e);
64
64
  a.push(new functions.FunctionsCompiler({
65
65
  imports: [
66
- l.formatTo,
67
- l.types
66
+ s.formatTo,
67
+ s.types
68
68
  ],
69
69
  name: r.fnName,
70
- args: s,
70
+ args: l,
71
71
  body: i,
72
72
  comment: {
73
73
  tags: [
@@ -84,7 +84,7 @@ var I = createAdapter.createGenerator("js", (t)=>{
84
84
  allImports: r
85
85
  };
86
86
  }(a, e);
87
- return s ? u.reduce((t, e)=>(t[e.name] = {
87
+ return l ? u.reduce((t, e)=>(t[e.name] = {
88
88
  dir: i,
89
89
  name: e.name,
90
90
  ext: "ts",
@@ -6,8 +6,8 @@ import { ImportsCompiler } from '../../compiler/imports.esm.js';
6
6
  import { getImportTypes } from './types.esm.js';
7
7
 
8
8
  function getToFunction(e, o) {
9
- let { id: r, params: n } = e, l = function(e, o) {
10
- let { params: r, pathnames: n, equalValues: l } = e, { defaultLocale: s, single: i } = o, u = !i && !l, d = i ? '""' : "locale", m = r ? ", params" : "";
9
+ let { id: r, params: n } = e, s = function(e, o) {
10
+ let { params: r, pathnames: n, equalValues: s } = e, { defaultLocale: l, single: i } = o, u = !i && !s, d = i ? '""' : "locale", m = r ? ", params" : "";
11
11
  return (e)=>{
12
12
  let o = u ? "locale = locale || globalThis." + GLOBAL_I18N_IDENTIFIER + "; " : "";
13
13
  o += "return ";
@@ -19,26 +19,26 @@ function getToFunction(e, o) {
19
19
  o !== t && n !== e[t] && (r += `locale === "${o}" ? "${n}"${a} : `);
20
20
  }
21
21
  return r + ('"' + e[t] + '"') + a;
22
- }(s, n, e)}${m})`, o + r;
22
+ }(l, n, e)}${m})`, o + r;
23
23
  };
24
- }(e, o), s = [];
25
- return n && s.push({
24
+ }(e, o), l = [];
25
+ return n && l.push({
26
26
  name: "params",
27
27
  type: `I18n.RouteParams["${r}"]`,
28
28
  optional: !1,
29
29
  description: "Dynamic values to interpolate in the output URL pathname"
30
- }), s.push({
30
+ }), l.push({
31
31
  name: "locale",
32
32
  type: "I18n.Locale",
33
33
  optional: !0,
34
34
  description: "Use this to override the current locale",
35
35
  defaults: "current locale"
36
36
  }), {
37
- body: l,
38
- args: s
37
+ body: s,
38
+ args: l
39
39
  };
40
40
  }
41
- let l = {
41
+ let s = {
42
42
  formatTo: new ImportsCompiler({
43
43
  path: "internal/formatTo",
44
44
  named: [
@@ -53,17 +53,17 @@ var I = createGenerator("js", (t)=>{
53
53
  let { options: { routes: { tokens: { idDelimiter: e } } }, routes: { dynamicRoutes: a, staticRoutes: n } } = t;
54
54
  return {
55
55
  ...function(t) {
56
- let { config: e, routes: a, options: { routes: n, adapter: { modularize: s } } } = t, { dir: i } = n.functions, { functions: u, allImports: d } = function(t, e) {
56
+ let { config: e, routes: a, options: { routes: n, adapter: { options: { modularize: l } } } } = t, { dir: i } = n.functions, { functions: u, allImports: d } = function(t, e) {
57
57
  let a = [], r = new Set();
58
- for(let n in r.add(l.formatTo), r.add(l.types), t.byId){
59
- let r = t.byId[n], { args: s, body: i } = getToFunction(r, e);
58
+ for(let n in r.add(s.formatTo), r.add(s.types), t.byId){
59
+ let r = t.byId[n], { args: l, body: i } = getToFunction(r, e);
60
60
  a.push(new FunctionsCompiler({
61
61
  imports: [
62
- l.formatTo,
63
- l.types
62
+ s.formatTo,
63
+ s.types
64
64
  ],
65
65
  name: r.fnName,
66
- args: s,
66
+ args: l,
67
67
  body: i,
68
68
  comment: {
69
69
  tags: [
@@ -80,7 +80,7 @@ var I = createGenerator("js", (t)=>{
80
80
  allImports: r
81
81
  };
82
82
  }(a, e);
83
- return s ? u.reduce((t, e)=>(t[e.name] = {
83
+ return l ? u.reduce((t, e)=>(t[e.name] = {
84
84
  dir: i,
85
85
  name: e.name,
86
86
  ext: "ts",
@@ -27,6 +27,7 @@ const adapterJs = createAdapter.createAdapter({
27
27
  defaultOptions: {
28
28
  modularize: !0
29
29
  },
30
+ getMeta: (r)=>({}),
30
31
  getGenerators: (r)=>[
31
32
  config,
32
33
  createT,
@@ -33,6 +33,7 @@ export type Options = {
33
33
  */
34
34
  modularize: boolean;
35
35
  };
36
+ export type Meta = {};
36
37
  export declare const adapterJs: {
37
38
  (data: import("../compiler").I18nCompiler.DataCode<"js">): {
38
39
  generators: import("../compiler").I18nCompiler.AdapterGenerator<import("../compiler").I18nCompiler.AdapterName>[];
@@ -230,6 +231,7 @@ export declare const adapterJs: {
230
231
  }>;
231
232
  };
232
233
  getGenerators: <TAdapterName extends import("../compiler").I18nCompiler.AdapterName>(data: import("../compiler").I18nCompiler.DataCode<TAdapterName>) => import("../compiler").I18nCompiler.AdapterGenerator<import("../compiler").I18nCompiler.AdapterName>[];
234
+ getMeta: <TAdapterName extends import("../compiler").I18nCompiler.AdapterName>(options: import("../compiler").I18nCompiler.AdapterConfigurationResolved<TAdapterName>["options"]) => import("../compiler").I18nCompiler.AdapterConfigurationResolved<import("../compiler").I18nCompiler.AdapterName>["meta"];
233
235
  defaultOptions: {
234
236
  modularize: true;
235
237
  };
@@ -23,6 +23,7 @@ const adapterJs = createAdapter({
23
23
  defaultOptions: {
24
24
  modularize: !0
25
25
  },
26
+ getMeta: (r)=>({}),
26
27
  getGenerators: (r)=>[
27
28
  o,
28
29
  t,
@@ -3,7 +3,7 @@
3
3
  var createAdapter = require('../../compiler/createAdapter.cjs.js');
4
4
  var redirects = require('../plugin/redirects.cjs.js');
5
5
 
6
- var t = createAdapter.createGenerator("next", (r)=>{
6
+ var o = createAdapter.createGenerator("next", (r)=>{
7
7
  let { config: i, options: n, routes: d } = r, o = JSON.stringify(redirects.generateRedirects(i, n.routes, d.byId), null, 2);
8
8
  return {
9
9
  nextRedirects: {
@@ -22,4 +22,4 @@ module.exports = ${o}
22
22
  };
23
23
  });
24
24
 
25
- module.exports = t;
25
+ module.exports = o;
@@ -1,7 +1,7 @@
1
1
  import { createGenerator } from '../../compiler/createAdapter.esm.js';
2
2
  import { generateRedirects } from '../plugin/redirects.esm.js';
3
3
 
4
- var t = createGenerator("next", (r)=>{
4
+ var o = createGenerator("next", (r)=>{
5
5
  let { config: i, options: n, routes: d } = r, o = JSON.stringify(generateRedirects(i, n.routes, d.byId), null, 2);
6
6
  return {
7
7
  nextRedirects: {
@@ -20,4 +20,4 @@ module.exports = ${o}
20
20
  };
21
21
  });
22
22
 
23
- export { t as default };
23
+ export { o as default };
@@ -3,7 +3,7 @@
3
3
  var createAdapter = require('../../compiler/createAdapter.cjs.js');
4
4
  var rewrites = require('../plugin/rewrites.cjs.js');
5
5
 
6
- var o = createAdapter.createGenerator("next", (r)=>{
6
+ var a = createAdapter.createGenerator("next", (r)=>{
7
7
  let { config: i, routes: n, options: o } = r, d = JSON.stringify(rewrites.generateRewrites(i, o.routes, n.byId), null, 2);
8
8
  return {
9
9
  nextRewrites: {
@@ -22,4 +22,4 @@ module.exports = ${d}
22
22
  };
23
23
  });
24
24
 
25
- module.exports = o;
25
+ module.exports = a;
@@ -1,7 +1,7 @@
1
1
  import { createGenerator } from '../../compiler/createAdapter.esm.js';
2
2
  import { generateRewrites } from '../plugin/rewrites.esm.js';
3
3
 
4
- var o = createGenerator("next", (r)=>{
4
+ var a = createGenerator("next", (r)=>{
5
5
  let { config: i, routes: n, options: o } = r, d = JSON.stringify(generateRewrites(i, o.routes, n.byId), null, 2);
6
6
  return {
7
7
  nextRewrites: {
@@ -20,4 +20,4 @@ module.exports = ${d}
20
20
  };
21
21
  });
22
22
 
23
- export { o as default };
23
+ export { a as default };
@@ -3,8 +3,8 @@
3
3
  var createAdapter = require('../../../compiler/createAdapter.cjs.js');
4
4
  var helpers = require('../../../compiler/helpers.cjs.js');
5
5
 
6
- var a = createAdapter.createGenerator("next", (e)=>{
7
- let { options: { routes: { localeParamName: a } } } = e;
6
+ var p = createAdapter.createGenerator("next", (a)=>{
7
+ let { options: { routes: { localeParamName: e } } } = a;
8
8
  return {
9
9
  I18nLayout: {
10
10
  dir: createAdapter.createGenerator.dirs.server,
@@ -22,9 +22,10 @@ import type { I18n } from "../types";
22
22
  import { I18nLayoutRoot } from "./I18nLayoutRoot";
23
23
  import {
24
24
  type NextProps,
25
+ type I18nNextPropsLayout,
25
26
  type I18nProps,
26
27
  type I18nServerConfigurator,
27
- resolveConfigurator
28
+ resolveConfigurator,
28
29
  } from "./i18nServerHelpers";
29
30
 
30
31
  type Config = {
@@ -58,7 +59,9 @@ export const I18nLayout = async ({
58
59
  // }
59
60
 
60
61
  // locale = locale || getLocale();
61
- const dictionaries = namespaces.length ? (await getI18nDictionaries({ locale, namespaces })) : {};
62
+ const dictionaries = namespaces.length
63
+ ? await getI18nDictionaries({ locale, namespaces })
64
+ : {};
62
65
 
63
66
  return (
64
67
  <I18nTranslateProvider
@@ -91,7 +94,7 @@ export const I18nLayout = async ({
91
94
  * };
92
95
  * });
93
96
  *
94
- * // 2) export the metadata (maybe only in /app/[${a}]/layout.tsx)
97
+ * // 2) export the metadata (maybe only in /app/[${e}]/layout.tsx)
95
98
  *
96
99
  * // with a sync function
97
100
  * export const generateMetadata = layout.generateMetadata((props) => {
@@ -105,7 +108,7 @@ export const I18nLayout = async ({
105
108
  *
106
109
  * // 3) export the default component
107
110
  *
108
- * // 3a) in /app/[${a}]/layout.tsx and /app/not-found.tsx
111
+ * // 3a) in /app/[${e}]/layout.tsx and /app/not-found.tsx
109
112
  *
110
113
  * // first spread the i18nHtmlAttrs prop on the <html> element, then render
111
114
  * // the {I18nScript} node in the <body>
@@ -123,7 +126,7 @@ export const I18nLayout = async ({
123
126
  * );
124
127
  * });
125
128
  *
126
- * // 3b) in /app/[${a}]/ ...folders... /layout.tsx)
129
+ * // 3b) in /app/[${e}]/ ...folders... /layout.tsx)
127
130
  *
128
131
  * // with a sync function (if you do not need to await)
129
132
  * export default layout.default((props) => {
@@ -138,42 +141,44 @@ export const I18nLayout = async ({
138
141
  * \`\`\`
139
142
  */
140
143
  export const createI18nLayout =
141
- <TProps extends NextProps>() =>
144
+ <TProps extends I18nNextPropsLayout>() =>
142
145
  <TConfigurator extends I18nServerConfigurator<Config, TProps>>(
143
146
  configurator?: TConfigurator,
144
147
  ) => ({
145
- generateStaticParams: () => locales.map((l) => ({ ${a}: l })),
148
+ generateStaticParams: () => locales.map((l) => ({ ${e}: l })),
146
149
  generateMetadata: (
147
- impl: <TRawProps extends NextProps>(
148
- props: I18nProps<TProps, TRawProps, Config, TConfigurator>,
150
+ impl: (
151
+ props: I18nProps<TProps, Config, TConfigurator>,
149
152
  ) => Metadata | Promise<Metadata>,
150
153
  ) => {
151
- return async <TRawProps extends NextProps>(rawProps: TRawProps) => {
152
- const { namespaces, ...restConfig } = await resolveConfigurator<
153
- TProps,
154
- TRawProps,
155
- Config,
156
- TConfigurator
157
- >(rawProps, configurator);
158
- const metadata = await impl(
159
- restConfig as I18nProps<TProps, TRawProps, Config, TConfigurator>
154
+ return async (rawProps: NextProps<TProps>) => {
155
+ const { params: _rawParams, ...rawPropsWithoutParams } = rawProps;
156
+ const config = await resolveConfigurator<TProps, Config, TConfigurator>(
157
+ rawProps as unknown as TProps,
158
+ configurator,
160
159
  );
160
+ const { locale, params } = config;
161
+ const metadata = await impl({
162
+ ...rawPropsWithoutParams,
163
+ locale,
164
+ params,
165
+ } as unknown as I18nProps<TProps, Config, TConfigurator>);
161
166
  return metadata;
162
167
  };
163
168
  },
164
169
  default: (
165
- impl: <TRawProps extends NextProps>(
166
- props: I18nProps<TProps, TRawProps, Config, TConfigurator> &
170
+ impl: (
171
+ props: I18nProps<TProps, Config, TConfigurator> &
167
172
  React.PropsWithChildren<{
168
173
  /**
169
174
  * Render this in
170
- * - \`/app/[${a}]/layout.tsx\`
175
+ * - \`/app/[${e}]/layout.tsx\`
171
176
  * - \`/app/not-found.tsx\`
172
177
  */
173
178
  I18nScript: React.ReactNode;
174
179
  /**
175
180
  * Spread this prop on the \`<html {...i18nHtmlAttrs}>\` element in:
176
- * - \`app/[${a}]/layout.tsx\`
181
+ * - \`app/[${e}]/layout.tsx\`
177
182
  * - \`app/not-found.tsx\`
178
183
  */
179
184
  i18nHtmlAttrs: Pick<
@@ -183,26 +188,28 @@ export const createI18nLayout =
183
188
  }>,
184
189
  ) => React.ReactNode | Promise<React.ReactNode>,
185
190
  ) => {
186
- return async <TRawProps extends NextProps>(rawProps: TRawProps) => {
191
+ return async (rawProps: NextProps<TProps>) => {
187
192
  const { params: _rawParams, ...rawPropsWithoutParams } = rawProps;
188
- const config = await resolveConfigurator<
189
- TProps,
190
- TRawProps,
191
- Config,
192
- TConfigurator
193
- >(rawProps, configurator);
194
- const { locale, namespaces, params } = config;${createAdapter.createGenerator.log(e, "layout.default", "resolveConfigurator", "locale")}
193
+ const config = await resolveConfigurator<TProps, Config, TConfigurator>(
194
+ rawProps as unknown as TProps,
195
+ configurator,
196
+ );
197
+ const { locale, namespaces, params } = config;${createAdapter.createGenerator.log(a, "layout.default", "resolveConfigurator", "locale")}
195
198
  const dir = i18nRtlLocales.includes(locale) ? "rtl" : "ltr";
196
199
  const i18nHtmlAttrs = { lang: locale, dir };
197
200
  const I18nScript = (
198
- <script dangerouslySetInnerHTML={{ __html: \`globalThis.${helpers.GLOBAL_I18N_IDENTIFIER} = "\${locale}";\`}}></script>
201
+ <script
202
+ dangerouslySetInnerHTML={{
203
+ __html: \`globalThis.${helpers.GLOBAL_I18N_IDENTIFIER} = "\${locale}";\`
204
+ }}
205
+ ></script>
199
206
  );
200
207
  const render = await impl({
201
208
  ...({
202
209
  ...rawPropsWithoutParams,
203
210
  locale,
204
211
  params,
205
- } as I18nProps<TProps, TRawProps, Config, TConfigurator>),
212
+ } as unknown as I18nProps<TProps, Config, TConfigurator>),
206
213
  I18nScript,
207
214
  i18nHtmlAttrs,
208
215
  });
@@ -224,4 +231,4 @@ createI18nLayout.Root = I18nLayoutRoot;
224
231
  };
225
232
  });
226
233
 
227
- module.exports = a;
234
+ module.exports = p;