@koine/i18n 2.0.0-beta.123 → 2.0.0-beta.124
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/api.cjs.js +153 -160
- package/api.esm.js +153 -160
- package/compiler/code/adapters.d.ts +1 -1
- package/compiler/code/data.d.ts +0 -3
- package/compiler/helpers.d.ts +1 -0
- package/compiler-worker.cjs.js +1 -1
- package/compiler-worker.esm.js +1 -1
- package/compiler.cjs.js +1 -1
- package/compiler.esm.js +1 -1
- package/next.cjs.js +1 -3
- package/next.esm.js +1 -3
- package/package.json +3 -3
package/api.cjs.js
CHANGED
|
@@ -7,9 +7,9 @@ var node_path = require('node:path');
|
|
|
7
7
|
var require$$0 = require('buffer');
|
|
8
8
|
var t$4 = require('typescript');
|
|
9
9
|
var node = require('@koine/node');
|
|
10
|
+
var minimatch = require('minimatch');
|
|
10
11
|
var utils = require('@koine/utils');
|
|
11
12
|
var formatRoutePathname = require('./formatRoutePathname.cjs.js');
|
|
12
|
-
var minimatch = require('minimatch');
|
|
13
13
|
var glob = require('glob');
|
|
14
14
|
var node_https = require('node:https');
|
|
15
15
|
|
|
@@ -8835,30 +8835,35 @@ var src = {
|
|
|
8835
8835
|
let getImportDir = (e = 0)=>(e ? Array(e).fill("..").join("/") : ".") + "/";
|
|
8836
8836
|
/**
|
|
8837
8837
|
* TODO: maybe make this folder name or path configurable through options
|
|
8838
|
-
*
|
|
8838
|
+
*
|
|
8839
8839
|
* @param folderUp default `0`
|
|
8840
8840
|
* @param folderName default `"translations"`
|
|
8841
|
-
*/ let getTranslationsDir = (e = 0,
|
|
8841
|
+
*/ let getTranslationsDir = (e = 0, t = "translations")=>getImportDir(e) + t;
|
|
8842
8842
|
/**
|
|
8843
8843
|
* TODO: maybe use `params` to determine the right type with some kind of special
|
|
8844
8844
|
* token used in the route id
|
|
8845
8845
|
*
|
|
8846
8846
|
* NB: wrap the output of this function, e.g. `type A = {${dataParamsToTsInterfaceBody(params)}}`
|
|
8847
|
-
*/ let dataParamsToTsInterfaceBody = (e)=>Object.keys(e).reduce((
|
|
8848
|
-
let a = e[
|
|
8847
|
+
*/ let dataParamsToTsInterfaceBody = (e)=>Object.keys(e).reduce((t, r)=>{
|
|
8848
|
+
let a = e[r], i = "";
|
|
8849
8849
|
switch(a){
|
|
8850
8850
|
case "number":
|
|
8851
|
-
|
|
8851
|
+
i = "number";
|
|
8852
8852
|
break;
|
|
8853
8853
|
case "string":
|
|
8854
|
-
|
|
8854
|
+
i = "string";
|
|
8855
8855
|
break;
|
|
8856
8856
|
default:
|
|
8857
|
-
|
|
8857
|
+
i = "string | number";
|
|
8858
8858
|
}
|
|
8859
|
-
return
|
|
8859
|
+
return t.push(`${r}: ${i};`), t;
|
|
8860
8860
|
}, []).join(" ");
|
|
8861
8861
|
let escapeEachChar = (e)=>e.split("").map((e)=>`\\${e}`).join("");
|
|
8862
|
+
/**
|
|
8863
|
+
* @param ignore List of paths to be ignored (using `minimatch`)
|
|
8864
|
+
* @param otherCondition Optionally pass another condition
|
|
8865
|
+
* @returns
|
|
8866
|
+
*/ let filterInputTranslationFiles = (t, r = [], a)=>t.filter((t)=>(!a || a && a(t)) && (!r.length || r.every((r)=>!minimatch.minimatch(t.path, r))));
|
|
8862
8867
|
|
|
8863
8868
|
function createAdapter(// TGenerators extends I18nCompiler.AdapterGenerator<TName>[],
|
|
8864
8869
|
// data: I18nCompiler.DataCode<I18nCompiler.AdapterName>
|
|
@@ -8902,7 +8907,7 @@ function createGenerator(e, r) {
|
|
|
8902
8907
|
test: "test"
|
|
8903
8908
|
};
|
|
8904
8909
|
|
|
8905
|
-
var o$
|
|
8910
|
+
var o$8 = createGenerator("js", (e)=>{
|
|
8906
8911
|
let { config: o } = e, l = `[${o.locales.map((e)=>`"${e}"`).join(", ")}]`;
|
|
8907
8912
|
return {
|
|
8908
8913
|
locales: {
|
|
@@ -9316,7 +9321,7 @@ ${i ? "export " : ""}async function getI18nDictionaries({
|
|
|
9316
9321
|
}
|
|
9317
9322
|
`;
|
|
9318
9323
|
|
|
9319
|
-
var s$
|
|
9324
|
+
var s$8 = createGenerator("js", (e)=>({
|
|
9320
9325
|
getI18nDictionaries: {
|
|
9321
9326
|
name: "getI18nDictionaries",
|
|
9322
9327
|
ext: "ts",
|
|
@@ -9425,7 +9430,7 @@ export default getT;
|
|
|
9425
9430
|
}
|
|
9426
9431
|
}));
|
|
9427
9432
|
|
|
9428
|
-
var i$
|
|
9433
|
+
var i$6 = createGenerator("js", (e)=>({
|
|
9429
9434
|
isLocale: {
|
|
9430
9435
|
name: "isLocale",
|
|
9431
9436
|
ext: "ts",
|
|
@@ -9583,11 +9588,11 @@ export default routesSpa;
|
|
|
9583
9588
|
// const getP = (dic) => {
|
|
9584
9589
|
// return
|
|
9585
9590
|
// }
|
|
9586
|
-
let m$5 = (t)=>utils.isString(t) || utils.isNumber(t) ? `"${t}"` : utils.isBoolean(t) ? `${t}` : utils.isArray(t) ? JSON.stringify(t) : `(${JSON.stringify(t)})`, s$
|
|
9591
|
+
let m$5 = (t)=>utils.isString(t) || utils.isNumber(t) ? `"${t}"` : utils.isBoolean(t) ? `${t}` : utils.isArray(t) ? JSON.stringify(t) : `(${JSON.stringify(t)})`, s$7 = (e, r)=>utils.areEqual(e, r), u$3 = (t, e)=>{
|
|
9587
9592
|
let { defaultLocale: r } = t, a = "";
|
|
9588
9593
|
for(let t in e){
|
|
9589
9594
|
let o = e[t];
|
|
9590
|
-
t === r || s$
|
|
9595
|
+
t === r || s$7(o, e[r]) || (a += `locale === "${t}" ? ${m$5(o)} : `);
|
|
9591
9596
|
}
|
|
9592
9597
|
return a + m$5(e[r]);
|
|
9593
9598
|
}, $$1 = (t = 0)=>{
|
|
@@ -9690,7 +9695,7 @@ export let tPluralise = (values: any, count: number) =>
|
|
|
9690
9695
|
}
|
|
9691
9696
|
}));
|
|
9692
9697
|
|
|
9693
|
-
let r$
|
|
9698
|
+
let r$1 = (o, t)=>{
|
|
9694
9699
|
let { defaultLocale: e } = o, a = "";
|
|
9695
9700
|
for(let o in t){
|
|
9696
9701
|
let r = t[o];
|
|
@@ -9712,7 +9717,7 @@ let r$2 = (o, t)=>{
|
|
|
9712
9717
|
c ? `params: ${f}` : "",
|
|
9713
9718
|
i ? "" : "locale?: I18n.Locale"
|
|
9714
9719
|
].filter(Boolean).join(", "), g = i ? '""' : "locale", R = c ? ", params" : "";
|
|
9715
|
-
s += `export let ${p} = (${I}) => `, utils.isString(m) ? s += `formatTo(${g}, "${m}"${R});` : s += `formatTo(${g}, ${r$
|
|
9720
|
+
s += `export let ${p} = (${I}) => `, utils.isString(m) ? s += `formatTo(${g}, "${m}"${R});` : s += `formatTo(${g}, ${r$1(e, m)}${R});`, d.push({
|
|
9716
9721
|
name: p,
|
|
9717
9722
|
declaration: s,
|
|
9718
9723
|
imports: [
|
|
@@ -9860,17 +9865,17 @@ export default toSpa;
|
|
|
9860
9865
|
|
|
9861
9866
|
/**
|
|
9862
9867
|
* @see https://github.com/aralroca/next-translate?tab=readme-ov-file#5-plurals
|
|
9863
|
-
*/ let s$
|
|
9868
|
+
*/ let s$6 = [
|
|
9864
9869
|
"zero",
|
|
9865
9870
|
"one",
|
|
9866
9871
|
"two",
|
|
9867
9872
|
"few",
|
|
9868
9873
|
"many",
|
|
9869
9874
|
"other"
|
|
9870
|
-
], i$
|
|
9875
|
+
], i$5 = "other";
|
|
9871
9876
|
/**
|
|
9872
9877
|
* Is the given string a valid plural suffix?
|
|
9873
|
-
*/ let isPluralSuffix = (e)=>s$
|
|
9878
|
+
*/ let isPluralSuffix = (e)=>s$6.includes(e) || utils.isNumericLiteral(e);
|
|
9874
9879
|
/**
|
|
9875
9880
|
* Remove plural suffix from string
|
|
9876
9881
|
*/ let removePluralSuffix = (e)=>{
|
|
@@ -9901,7 +9906,7 @@ let a$6 = (e)=>{
|
|
|
9901
9906
|
* from the generated types, e.g. the plural versions of the same string.
|
|
9902
9907
|
*/ let transformKeysForPlurals = (l)=>{
|
|
9903
9908
|
// only transform if we have the required plural suffix in the keys
|
|
9904
|
-
if (l.some(hasRequiredPluralSuffix) || l.includes(i$
|
|
9909
|
+
if (l.some(hasRequiredPluralSuffix) || l.includes(i$5)) {
|
|
9905
9910
|
let r = l.filter(isPluralKey);
|
|
9906
9911
|
if (r.length) {
|
|
9907
9912
|
let t = [
|
|
@@ -9920,12 +9925,12 @@ let a$6 = (e)=>{
|
|
|
9920
9925
|
};
|
|
9921
9926
|
/**
|
|
9922
9927
|
* Check if the given key has the required plural suffix
|
|
9923
|
-
*/ let hasRequiredPluralSuffix = (e)=>isPluralKey(e) && getPluralSuffix(e) === i$
|
|
9928
|
+
*/ let hasRequiredPluralSuffix = (e)=>isPluralKey(e) && getPluralSuffix(e) === i$5;
|
|
9924
9929
|
/**
|
|
9925
9930
|
* Does the translation value object has plurals version?
|
|
9926
9931
|
*
|
|
9927
9932
|
* NB: here we check only for the **required** plural suffix,
|
|
9928
|
-
*/ let hasPlurals = (e)=>Object.keys(e).some(hasRequiredPluralSuffix) || Object.keys(e).includes(i$
|
|
9933
|
+
*/ let hasPlurals = (e)=>Object.keys(e).some(hasRequiredPluralSuffix) || Object.keys(e).includes(i$5);
|
|
9929
9934
|
/**
|
|
9930
9935
|
* Is the translation value object only enumerating plurals version?
|
|
9931
9936
|
*/ let hasOnlyPluralKeys = (e)=>!!hasPlurals(e) && 0 === pickNonPluralKeys(e).length;
|
|
@@ -9937,46 +9942,48 @@ let a$6 = (e)=>{
|
|
|
9937
9942
|
* with pluralisation
|
|
9938
9943
|
*/ let pickNonPluralValue = (e)=>hasPlurals(e) ? utils.objectPick(e, pickNonPluralKeys(e)) : e;
|
|
9939
9944
|
|
|
9940
|
-
let d$4 = (
|
|
9945
|
+
let d$4 = (t, n)=>!utils.isArray(n) && utils.isObject(n) && hasPlurals(n) ? hasOnlyPluralKeys(n) ? `"${t}": string;` : `"${t}": ${u$1(pickNonPluralValue(n))}` : `"${t}": ${u$1(n)}`, u$1 = (s)=>{
|
|
9941
9946
|
let o = "", r = "";
|
|
9942
|
-
if (utils.isBoolean(
|
|
9943
|
-
else if (
|
|
9944
|
-
if (utils.isArray(
|
|
9945
|
-
let
|
|
9946
|
-
o += `${u$1(
|
|
9947
|
-
} else if (utils.isObject(
|
|
9947
|
+
if (utils.isBoolean(s) ? r = "boolean" : utils.isString(s) && (r = "string"), r) o += r + ";";
|
|
9948
|
+
else if (s) {
|
|
9949
|
+
if (utils.isArray(s)) {
|
|
9950
|
+
let e = s[0];
|
|
9951
|
+
o += `${u$1(e)}[];`;
|
|
9952
|
+
} else if (utils.isObject(s)) {
|
|
9948
9953
|
o += "{";
|
|
9949
|
-
let
|
|
9950
|
-
for(let
|
|
9951
|
-
let
|
|
9954
|
+
let e = transformKeysForPlurals(Object.keys(s));
|
|
9955
|
+
for(let t = 0; t < e.length; t++){
|
|
9956
|
+
let a = e[t], // fallback to a string otherwise plurals without root definition would
|
|
9952
9957
|
// not get a type otherwise, e.g. ` pluralNoDefault_...` in __mocks__
|
|
9953
|
-
|
|
9954
|
-
o += d$4(
|
|
9958
|
+
n = s[a] || "";
|
|
9959
|
+
o += d$4(a, n);
|
|
9955
9960
|
}
|
|
9956
9961
|
o += "};";
|
|
9957
9962
|
}
|
|
9958
9963
|
} else o += "";
|
|
9959
9964
|
return(// adjust syntax
|
|
9960
9965
|
(o = o.replace(/;\[\];/g, "[];")).replace(/;+/g, ";"));
|
|
9961
|
-
}, h$2 = (e
|
|
9962
|
-
let { translationFiles: a }
|
|
9966
|
+
}, h$2 = (e)=>{
|
|
9967
|
+
let { config: { defaultLocale: t }, input: { translationFiles: a }, options: { translations: { ignorePaths: n } } } = e, s = filterInputTranslationFiles(a, n, (e)=>e.locale === t), o = [];
|
|
9963
9968
|
for(let e = 0; e < s.length; e++){
|
|
9964
9969
|
let { path: t, data: a } = s[e], n = t.replace(".json", "");
|
|
9965
9970
|
o.push(`"${n}": ${u$1(a)}`);
|
|
9966
9971
|
}
|
|
9967
9972
|
return o.sort();
|
|
9968
|
-
}, y$2 = (
|
|
9969
|
-
let
|
|
9970
|
-
|
|
9971
|
-
|
|
9972
|
-
|
|
9973
|
+
}, y$2 = (e)=>{
|
|
9974
|
+
let t = [];
|
|
9975
|
+
for(let a in e.byId){
|
|
9976
|
+
let { params: n } = e.byId[a];
|
|
9977
|
+
n && t.push(`"${a}": { ${dataParamsToTsInterfaceBody(n)} };`);
|
|
9978
|
+
}
|
|
9979
|
+
return t;
|
|
9973
9980
|
}, T = (e)=>e.sort().map((e)=>`"${e}"`).join(" | "), m$4 = (e, t)=>T(Object.keys(e.byId).filter((a)=>t(a, e.byId[a]))) || "never", f$2 = (e)=>Object.keys(e.byId).reduce((t, a)=>{
|
|
9974
9981
|
if (e.byId[a].inWildcard) for(let n = 0; n < e.wildcardIds.length; n++){
|
|
9975
9982
|
let s = e.wildcardIds[n];
|
|
9976
9983
|
a.startsWith(s) && (t[s] = t[s] || [], t[s].push(a));
|
|
9977
9984
|
}
|
|
9978
9985
|
return t;
|
|
9979
|
-
}, {}),
|
|
9986
|
+
}, {}), g$3 = (e, t, a)=>{
|
|
9980
9987
|
let n = f$2(t), s = [];
|
|
9981
9988
|
for(let o in n){
|
|
9982
9989
|
let r = n[o].map(// remove the root id portion and the first character which is always
|
|
@@ -9989,7 +9996,7 @@ let d$4 = (e, a)=>!utils.isArray(a) && utils.isObject(a) && hasPlurals(a) ? hasO
|
|
|
9989
9996
|
s.push(`"${o}": { ${l.join(" ")} }`);
|
|
9990
9997
|
}
|
|
9991
9998
|
return s;
|
|
9992
|
-
},
|
|
9999
|
+
}, x$3 = (e, t)=>{
|
|
9993
10000
|
let a = [];
|
|
9994
10001
|
for(let n in t.byId){
|
|
9995
10002
|
let s = t.byId[n];
|
|
@@ -10000,8 +10007,8 @@ let d$4 = (e, a)=>!utils.isArray(a) && utils.isObject(a) && hasPlurals(a) ? hasO
|
|
|
10000
10007
|
// TODO: maybe move the Translate types into the various adapters unless we
|
|
10001
10008
|
// will use the same api for all of them
|
|
10002
10009
|
var I$1 = createGenerator("js", (e)=>{
|
|
10003
|
-
let { config: t,
|
|
10004
|
-
{ idDelimiter:
|
|
10010
|
+
let { config: t, routes: a, options: n } = e, s = m$4(a, (e, { params: t })=>!t), o = m$4(a, (e, { params: t })=>!!t), // const routeIdSpa = buildRoutesUnion(routes, (_, { inWildcard }) => inWildcard);
|
|
10011
|
+
{ idDelimiter: r } = n.routes.tokens;
|
|
10005
10012
|
return {
|
|
10006
10013
|
types: {
|
|
10007
10014
|
name: "types",
|
|
@@ -10033,38 +10040,38 @@ export namespace I18n {
|
|
|
10033
10040
|
/**
|
|
10034
10041
|
* The static routes available ids
|
|
10035
10042
|
*/
|
|
10036
|
-
export type RouteIdStatic = ${
|
|
10043
|
+
export type RouteIdStatic = ${s};
|
|
10037
10044
|
|
|
10038
10045
|
/**
|
|
10039
10046
|
* The dynamic routes available ids
|
|
10040
10047
|
*/
|
|
10041
|
-
export type RouteIdDynamic = ${
|
|
10048
|
+
export type RouteIdDynamic = ${o};
|
|
10042
10049
|
|
|
10043
10050
|
/**
|
|
10044
10051
|
* Map every SPA path divided by their roots to their actual pathname value for the default locale
|
|
10045
10052
|
*/
|
|
10046
10053
|
export type RouteSpa = {
|
|
10047
|
-
${
|
|
10054
|
+
${g$3(t, a, n).join("\n ")}
|
|
10048
10055
|
}
|
|
10049
10056
|
|
|
10050
10057
|
/**
|
|
10051
10058
|
* Map every route id to its actual pathanem value for the default locale
|
|
10052
10059
|
*/
|
|
10053
10060
|
export type RoutePathnames = {
|
|
10054
|
-
${
|
|
10061
|
+
${x$3(t, a).join("\n ")}
|
|
10055
10062
|
}
|
|
10056
10063
|
|
|
10057
10064
|
/**
|
|
10058
10065
|
* Route dynamic params dictionary for each dynamic route id
|
|
10059
10066
|
*/
|
|
10060
10067
|
export type RouteParams = {
|
|
10061
|
-
${y$2(
|
|
10068
|
+
${y$2(a).join("\n ")}
|
|
10062
10069
|
}
|
|
10063
10070
|
|
|
10064
10071
|
/**
|
|
10065
10072
|
* Utility to join two route ids
|
|
10066
10073
|
*/
|
|
10067
|
-
export type RouteJoinedId<Root extends string, Tail extends string> = \`\${Root}${
|
|
10074
|
+
export type RouteJoinedId<Root extends string, Tail extends string> = \`\${Root}${r}\${Tail}\` extends RouteId ? \`\${Root}${r}\${Tail}\` : never;
|
|
10068
10075
|
|
|
10069
10076
|
/**
|
|
10070
10077
|
* Extract all children routes that starts with the given string
|
|
@@ -10089,7 +10096,7 @@ export namespace I18n {
|
|
|
10089
10096
|
* more sophisticated than the type result of \`typeof "./en/messages.json"\`
|
|
10090
10097
|
*/
|
|
10091
10098
|
export type TranslationsDictionary = {
|
|
10092
|
-
${h$2(
|
|
10099
|
+
${h$2(e).join("\n ")}
|
|
10093
10100
|
}
|
|
10094
10101
|
|
|
10095
10102
|
/**
|
|
@@ -10309,7 +10316,7 @@ export namespace I18n {
|
|
|
10309
10316
|
* such as \`/[lang]/my-route/page.tsx\`.
|
|
10310
10317
|
*/
|
|
10311
10318
|
export type Params = {
|
|
10312
|
-
${
|
|
10319
|
+
${n.routes.localeParamName}: Locale;
|
|
10313
10320
|
};
|
|
10314
10321
|
|
|
10315
10322
|
/**
|
|
@@ -10392,17 +10399,17 @@ export namespace I18n {
|
|
|
10392
10399
|
modularized: !0
|
|
10393
10400
|
},
|
|
10394
10401
|
getGenerators: (r)=>[
|
|
10395
|
-
o$
|
|
10402
|
+
o$8,
|
|
10396
10403
|
t$3,
|
|
10397
10404
|
e,
|
|
10398
10405
|
a$7,
|
|
10399
10406
|
m$6,
|
|
10400
|
-
s$
|
|
10407
|
+
s$8,
|
|
10401
10408
|
n$6,
|
|
10402
10409
|
// TODO: probably remove it or move it to `i18n/client` public utils
|
|
10403
10410
|
// getI18nAlternatesFromDom,
|
|
10404
10411
|
p$5,
|
|
10405
|
-
i$
|
|
10412
|
+
i$6,
|
|
10406
10413
|
// loadTranslations,
|
|
10407
10414
|
f$3,
|
|
10408
10415
|
g$4,
|
|
@@ -10447,7 +10454,7 @@ export const I18nEffects = () => {
|
|
|
10447
10454
|
}
|
|
10448
10455
|
}));
|
|
10449
10456
|
|
|
10450
|
-
var o$
|
|
10457
|
+
var o$7 = createGenerator("react", (a)=>({
|
|
10451
10458
|
I18nHeadTags: {
|
|
10452
10459
|
name: "I18nHeadTags",
|
|
10453
10460
|
ext: "tsx",
|
|
@@ -10811,7 +10818,7 @@ export default useRouteId;
|
|
|
10811
10818
|
}
|
|
10812
10819
|
}));
|
|
10813
10820
|
|
|
10814
|
-
var s$
|
|
10821
|
+
var s$5 = createGenerator("react", (e)=>({
|
|
10815
10822
|
I18nTranslateContext: {
|
|
10816
10823
|
name: "I18nTranslateContext",
|
|
10817
10824
|
ext: "tsx",
|
|
@@ -11077,7 +11084,7 @@ export function formatElements(
|
|
|
11077
11084
|
}
|
|
11078
11085
|
}));
|
|
11079
11086
|
|
|
11080
|
-
var i$
|
|
11087
|
+
var i$4 = createGenerator("react", (e)=>({
|
|
11081
11088
|
getLocale: {
|
|
11082
11089
|
dir: "server",
|
|
11083
11090
|
name: "getLocale",
|
|
@@ -11211,15 +11218,15 @@ const adapterReact = createAdapter({
|
|
|
11211
11218
|
getGenerators: (e)=>[
|
|
11212
11219
|
...adapterJs.getGenerators(e),
|
|
11213
11220
|
t$2,
|
|
11214
|
-
o$
|
|
11221
|
+
o$7,
|
|
11215
11222
|
a$5,
|
|
11216
11223
|
m$3,
|
|
11217
11224
|
n$4,
|
|
11218
|
-
s$
|
|
11225
|
+
s$5,
|
|
11219
11226
|
p$4,
|
|
11220
11227
|
f$1,
|
|
11221
11228
|
g$2,
|
|
11222
|
-
i$
|
|
11229
|
+
i$4,
|
|
11223
11230
|
c$1,
|
|
11224
11231
|
d$3
|
|
11225
11232
|
],
|
|
@@ -11314,7 +11321,7 @@ export default I18nApp;
|
|
|
11314
11321
|
/**
|
|
11315
11322
|
* @see https://nextjs.org/docs/pages/building-your-application/routing/custom-document
|
|
11316
11323
|
* @see https://gist.github.com/marteinn/00b96acf83047d8521a14d52cc276b77
|
|
11317
|
-
*/ var o$
|
|
11324
|
+
*/ var o$6 = createGenerator("next", (t)=>({
|
|
11318
11325
|
I18nDocument: {
|
|
11319
11326
|
name: "I18nDocument",
|
|
11320
11327
|
ext: "tsx",
|
|
@@ -11843,7 +11850,7 @@ export default I18nPage;
|
|
|
11843
11850
|
};
|
|
11844
11851
|
});
|
|
11845
11852
|
|
|
11846
|
-
var i$
|
|
11853
|
+
var i$3 = createGenerator("next", (e)=>({
|
|
11847
11854
|
I18nSetter: {
|
|
11848
11855
|
name: "I18nSetter",
|
|
11849
11856
|
ext: "tsx",
|
|
@@ -11895,7 +11902,7 @@ export default I18nSetter;
|
|
|
11895
11902
|
}
|
|
11896
11903
|
}));
|
|
11897
11904
|
|
|
11898
|
-
var s$
|
|
11905
|
+
var s$4 = createGenerator("next", (a)=>{
|
|
11899
11906
|
let { // routes: { dynamicRoutes },
|
|
11900
11907
|
options: { routes: { localeParamName: e } } } = a;
|
|
11901
11908
|
return {
|
|
@@ -12202,7 +12209,7 @@ module.exports = ${d}
|
|
|
12202
12209
|
};
|
|
12203
12210
|
});
|
|
12204
12211
|
|
|
12205
|
-
function o$
|
|
12212
|
+
function o$5(e) {
|
|
12206
12213
|
let { localeSource: t, localeDestination: a, template: o, pathname: l, passLocale: i } = e, n = "";
|
|
12207
12214
|
t && (n = `/${t}`);
|
|
12208
12215
|
let c = formatRoutePathname.formatRoutePathname(n + l), s = "";
|
|
@@ -12223,12 +12230,12 @@ const generateRewriteForPathname = (e, t, r, a, l)=>{
|
|
|
12223
12230
|
pathname: a
|
|
12224
12231
|
};
|
|
12225
12232
|
c ? // app router:
|
|
12226
|
-
s ? l.push(o$
|
|
12233
|
+
s ? l.push(o$5({
|
|
12227
12234
|
...p,
|
|
12228
12235
|
localeDestination: t,
|
|
12229
12236
|
passLocale: !1
|
|
12230
12237
|
})) : l.push(// prettier-ignore
|
|
12231
|
-
o$
|
|
12238
|
+
o$5({
|
|
12232
12239
|
...p,
|
|
12233
12240
|
localeSource: t,
|
|
12234
12241
|
localeDestination: t,
|
|
@@ -12237,12 +12244,12 @@ const generateRewriteForPathname = (e, t, r, a, l)=>{
|
|
|
12237
12244
|
// this condition only applies to the pages router as with the app one
|
|
12238
12245
|
// even if the template matches the pathname we always need to rewrite
|
|
12239
12246
|
// as the localeParam is always needed in the rewrite destination
|
|
12240
|
-
a !== r && (s ? l.push(o$
|
|
12247
|
+
a !== r && (s ? l.push(o$5(p)) : l.push(// `passLocale` must be `false` or the locale prefixed rewrite won't
|
|
12241
12248
|
// be applied and does not forward the locale to the route context
|
|
12242
12249
|
// when the locale is included in the URL. In fact we explicitly
|
|
12243
12250
|
// add the locale to the rewrite rule in order to get the least
|
|
12244
12251
|
// amount of existing URLs which is a good SEO practice
|
|
12245
|
-
o$
|
|
12252
|
+
o$5({
|
|
12246
12253
|
...p,
|
|
12247
12254
|
localeSource: t,
|
|
12248
12255
|
passLocale: !1
|
|
@@ -12479,11 +12486,11 @@ export default useToSpa;
|
|
|
12479
12486
|
g$1
|
|
12480
12487
|
] : [],
|
|
12481
12488
|
..."pages" === c || "migrating" === c ? [
|
|
12482
|
-
i$
|
|
12489
|
+
i$3,
|
|
12483
12490
|
t$1,
|
|
12484
|
-
o$
|
|
12491
|
+
o$6,
|
|
12485
12492
|
a$4,
|
|
12486
|
-
s$
|
|
12493
|
+
s$4
|
|
12487
12494
|
] : []
|
|
12488
12495
|
];
|
|
12489
12496
|
},
|
|
@@ -12507,7 +12514,7 @@ export default DynamicNamespaces;
|
|
|
12507
12514
|
}
|
|
12508
12515
|
}));
|
|
12509
12516
|
|
|
12510
|
-
var o$
|
|
12517
|
+
var o$4 = createGenerator("next-translate", (e)=>({
|
|
12511
12518
|
I18nProvider: {
|
|
12512
12519
|
name: "I18nProvider",
|
|
12513
12520
|
ext: "tsx",
|
|
@@ -12580,7 +12587,7 @@ export default TransText;
|
|
|
12580
12587
|
}
|
|
12581
12588
|
}));
|
|
12582
12589
|
|
|
12583
|
-
var s$
|
|
12590
|
+
var s$3 = createGenerator("next-translate", (e)=>({
|
|
12584
12591
|
getT: {
|
|
12585
12592
|
name: "getT",
|
|
12586
12593
|
ext: "ts",
|
|
@@ -12648,7 +12655,7 @@ export default useLocale;
|
|
|
12648
12655
|
}
|
|
12649
12656
|
}));
|
|
12650
12657
|
|
|
12651
|
-
var i$
|
|
12658
|
+
var i$2 = createGenerator("next-translate", (e)=>({
|
|
12652
12659
|
useT: {
|
|
12653
12660
|
name: "useT",
|
|
12654
12661
|
ext: "ts",
|
|
@@ -12708,16 +12715,16 @@ const adapterNextTranslate = createAdapter({
|
|
|
12708
12715
|
let { loader: f } = e.options.adapter;
|
|
12709
12716
|
return [
|
|
12710
12717
|
...adapterNext.getGenerators(e),
|
|
12711
|
-
s$
|
|
12718
|
+
s$3,
|
|
12712
12719
|
m$1,
|
|
12713
12720
|
a$2,
|
|
12714
12721
|
n$2,
|
|
12715
|
-
i$
|
|
12722
|
+
i$2,
|
|
12716
12723
|
...!1 === f ? [
|
|
12717
12724
|
p$2
|
|
12718
12725
|
] : [],
|
|
12719
12726
|
...!1 === f ? [
|
|
12720
|
-
o$
|
|
12727
|
+
o$4
|
|
12721
12728
|
] : [],
|
|
12722
12729
|
// TODO: check, probably DynamicNamespaces does not work without the automatic loader?
|
|
12723
12730
|
...!0 === f ? [
|
|
@@ -12764,7 +12771,7 @@ const codeDataRoutesOptions = {
|
|
|
12764
12771
|
}
|
|
12765
12772
|
}
|
|
12766
12773
|
};
|
|
12767
|
-
let r
|
|
12774
|
+
let r = (t, a)=>{
|
|
12768
12775
|
let { idDelimiter: l, parentReference: n, catchAll: r, optionalCatchAll: i } = a.tokens;
|
|
12769
12776
|
return {
|
|
12770
12777
|
...t,
|
|
@@ -12781,7 +12788,7 @@ let r$1 = (t, a)=>{
|
|
|
12781
12788
|
* Normalise user defined route id
|
|
12782
12789
|
*
|
|
12783
12790
|
* 1) remove ending `.index`
|
|
12784
|
-
*/ i$
|
|
12791
|
+
*/ i$1 = (e, { reg: t })=>{
|
|
12785
12792
|
let a = e.replace(t.indexEnd, ""), l = t.optionalCatchAll.test(e), n = t.catchAll.test(e);
|
|
12786
12793
|
return l && (a = a.replace(t.optionalCatchAll, "")), n && (a = a.replace(t.catchAll, "")), {
|
|
12787
12794
|
routeId: a = a.replace(t.trailingDelimiter, ""),
|
|
@@ -12807,14 +12814,14 @@ let r$1 = (t, a)=>{
|
|
|
12807
12814
|
*/ d$1 = (e, t)=>formatRoutePathname.formatRoutePathname(e.replace(/\*/g, "").replace(/[[{]{1,2}(.*?)[\]}]{1,2}/g, (e, t)=>`[${t.trim()}]`), t), /**
|
|
12808
12815
|
* Gathers a dictionary with the params extracted from the given (normalised)
|
|
12809
12816
|
* route id
|
|
12810
|
-
*/ s$
|
|
12817
|
+
*/ s$2 = (e)=>{
|
|
12811
12818
|
let t = e.match(/\[.*?\]/g);
|
|
12812
12819
|
if (t) return t.map((e)=>e.slice(1, -1).trim()).reduce((e, t)=>(// TODO: maybe determine the more specific type with some kind of special
|
|
12813
12820
|
// token used in the route id `[dynamicParam]` portion
|
|
12814
12821
|
e[t] = "stringOrNumber", e), {});
|
|
12815
12822
|
}, /**
|
|
12816
12823
|
* Recursively replace `/^` references with the parent route value
|
|
12817
|
-
*/ o$
|
|
12824
|
+
*/ o$3 = (e, t, a, l, n)=>{
|
|
12818
12825
|
let { tokens: { parentReference: r, idDelimiter: i }, reg: d } = t, s = e.byId[l], p = s.pathnames[a];
|
|
12819
12826
|
// beginning slash is always present here as the route value is already
|
|
12820
12827
|
// normalised at this point
|
|
@@ -12824,7 +12831,7 @@ let r$1 = (t, a)=>{
|
|
|
12824
12831
|
// grab the parent id
|
|
12825
12832
|
let r = l.split(i).slice(0, -1).join(i);
|
|
12826
12833
|
if (!n || n && n(s, r)) {
|
|
12827
|
-
if (r) p = o$
|
|
12834
|
+
if (r) p = o$3(e, t, a, r, n) + p;
|
|
12828
12835
|
else throw Error("Used a parent route token reference without a matching parent route");
|
|
12829
12836
|
}
|
|
12830
12837
|
}
|
|
@@ -12833,7 +12840,7 @@ let r$1 = (t, a)=>{
|
|
|
12833
12840
|
* Mutate the routes data replacing the parent route tokens
|
|
12834
12841
|
* NB: it mutates the data
|
|
12835
12842
|
*/ p$1 = (e, t)=>{
|
|
12836
|
-
for(let a in e.byId)for(let l in e.byId[a].pathnames)e.byId[a].pathnames[l] = o$
|
|
12843
|
+
for(let a in e.byId)for(let l in e.byId[a].pathnames)e.byId[a].pathnames[l] = o$3(e, t, l, a);
|
|
12837
12844
|
}, /**
|
|
12838
12845
|
* Mutate the routes data replacing the parent route tokens
|
|
12839
12846
|
* NB: it mutates the data
|
|
@@ -12842,7 +12849,7 @@ let r$1 = (t, a)=>{
|
|
|
12842
12849
|
for(let l in e.byId){
|
|
12843
12850
|
let { inWildcard: n } = e.byId[l];
|
|
12844
12851
|
if (n && e.byId[l].pathnamesSpa) for(let n in e.byId[l].pathnamesSpa)// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
12845
|
-
e.byId[l].pathnamesSpa[n] = o$
|
|
12852
|
+
e.byId[l].pathnamesSpa[n] = o$3(e, t, n, l, a);
|
|
12846
12853
|
else // discard unneeded data
|
|
12847
12854
|
delete e.byId[l].pathnamesSpa;
|
|
12848
12855
|
}
|
|
@@ -12896,12 +12903,12 @@ let r$1 = (t, a)=>{
|
|
|
12896
12903
|
let p = utils.objectFlat(e, r.tokens.idDelimiter);
|
|
12897
12904
|
for(let e in p){
|
|
12898
12905
|
let t = p[e], // as I18nCompiler.RoutePathname;
|
|
12899
|
-
{ routeId: a, isCatchAll: c, isOptionalCatchAll: m } = i$
|
|
12906
|
+
{ routeId: a, isCatchAll: c, isOptionalCatchAll: m } = i$1(e, r);
|
|
12900
12907
|
// if (isCatchAll || isOptionalCatchAll) console.log({ routeId, key });
|
|
12901
12908
|
// if is the first pass for this routeId
|
|
12902
12909
|
if (!o.byId[a]) {
|
|
12903
12910
|
o.byId[a] = o.byId[a] || {};
|
|
12904
|
-
let e = s$
|
|
12911
|
+
let e = s$2(a);
|
|
12905
12912
|
o.byId[a].id = a, e ? (o.byId[a].params = e, o.dynamicRoutes.push(a), o.onlyStaticRoutes = !1) : o.staticRoutes.push(a), (c || m) && (o.byId[a].wildcard = !0, o.wildcardIds.push(a));
|
|
12906
12913
|
}
|
|
12907
12914
|
o.byId[a].pathnames = o.byId[a].pathnames || {}, // prettier-ignore
|
|
@@ -12924,7 +12931,7 @@ let r$1 = (t, a)=>{
|
|
|
12924
12931
|
onlyStaticRoutes: !0,
|
|
12925
12932
|
dynamicRoutes: [],
|
|
12926
12933
|
staticRoutes: []
|
|
12927
|
-
}, n = r
|
|
12934
|
+
}, n = r(e, t);
|
|
12928
12935
|
for(let e = 0; e < a.length; e++){
|
|
12929
12936
|
let { path: r, locale: i, data: d } = a[e];
|
|
12930
12937
|
r === t.translationJsonFileName && y$1(d, i, n, l);
|
|
@@ -13060,8 +13067,8 @@ y = (e, t, r = {})=>{
|
|
|
13060
13067
|
// object structure for `values`
|
|
13061
13068
|
if (// we need to create it if we only have `x_one` `x_other` but not `x`
|
|
13062
13069
|
t[a] = t[a] || {}, t[r]) {
|
|
13063
|
-
let
|
|
13064
|
-
utils.forin(t[r].values, (r,
|
|
13070
|
+
let i = t[a].values || {};
|
|
13071
|
+
utils.forin(t[r].values, (r, s)=>{
|
|
13065
13072
|
// we need to ensure the value is an object for pluralisation, so if
|
|
13066
13073
|
// we encounter this structure:
|
|
13067
13074
|
// { "plural": "Plural", "plural_one": "One", "plural_other": "Some" }
|
|
@@ -13071,14 +13078,14 @@ y = (e, t, r = {})=>{
|
|
|
13071
13078
|
// developer of improper usage of `plural` translation key, which is
|
|
13072
13079
|
// simply useless
|
|
13073
13080
|
// prettier-ignore
|
|
13074
|
-
|
|
13075
|
-
|
|
13076
|
-
let
|
|
13077
|
-
|
|
13081
|
+
i[r] = utils.isObject(i[r]) ? i[r] : {}, // prettier-ignore
|
|
13082
|
+
i[r][l] = s;
|
|
13083
|
+
let o = y(e, s);
|
|
13084
|
+
o && (t[a].params = {
|
|
13078
13085
|
...t[a].params || {},
|
|
13079
|
-
...
|
|
13086
|
+
...o
|
|
13080
13087
|
});
|
|
13081
|
-
}), Object.keys(
|
|
13088
|
+
}), Object.keys(i).length && (t[a].values = i, t[a].plural = !0), // TODO: probaly here we should remove the non-plural keys from `values`
|
|
13082
13089
|
// as they are anyway accessible from "deeper" functions e.g.
|
|
13083
13090
|
// `withPluralAndOtherKeys({ count: 3 }) => "One" | "Many"`
|
|
13084
13091
|
// `withPluralAndOtherKeys_nonPluralKey()` => "Yes"
|
|
@@ -13119,14 +13126,12 @@ y = (e, t, r = {})=>{
|
|
|
13119
13126
|
* Get translations data
|
|
13120
13127
|
*/ let getCodeDataTranslations = (e, t, { translationFiles: r })=>{
|
|
13121
13128
|
let { ignorePaths: a } = t, l = {};
|
|
13122
|
-
for(let e = 0; e < r.length; e++)(!a || a && a.every((t)=>!minimatch.minimatch(r[e].path, t))) && D(t, r[e], l);
|
|
13123
13129
|
// console.log("generateTypes: outputDir", outputDir, "outputPath", outputPath);
|
|
13124
|
-
return(// sort
|
|
13125
|
-
utils.objectSort(l = _(t, l))
|
|
13130
|
+
return filterInputTranslationFiles(r, a).forEach((e)=>D(t, e, l)), // sort
|
|
13131
|
+
l = utils.objectSort(l = _(t, l));
|
|
13126
13132
|
};
|
|
13127
13133
|
|
|
13128
13134
|
const defaultCodeDataOptions = {
|
|
13129
|
-
outputFiles: {},
|
|
13130
13135
|
routes: codeDataRoutesOptions,
|
|
13131
13136
|
translations: codeDataTranslationsOptions
|
|
13132
13137
|
};
|
|
@@ -13136,36 +13141,23 @@ const defaultCodeDataOptions = {
|
|
|
13136
13141
|
* The adapater configuration to use for code generation.
|
|
13137
13142
|
* Specify its `name` and `options` in an _object dictionary_.
|
|
13138
13143
|
*/ /**
|
|
13139
|
-
* A _dictionary_ that allows to override the filename of each generated file
|
|
13140
|
-
*
|
|
13141
|
-
* TODO: make this works with generics based on chosen adapter?
|
|
13142
|
-
*/ // defaultLocale: string;
|
|
13143
|
-
// index: string;
|
|
13144
|
-
// isLocale: string;
|
|
13145
|
-
// locales: string;
|
|
13146
|
-
// routes: string;
|
|
13147
|
-
// routesSlim: string;
|
|
13148
|
-
// to: string;
|
|
13149
|
-
// types: string;
|
|
13150
|
-
/**
|
|
13151
13144
|
* Options for `routes` code data generation handling
|
|
13152
13145
|
*/ /**
|
|
13153
13146
|
* Options for `translations` code data generation handling
|
|
13154
|
-
*/
|
|
13155
|
-
|
|
13156
|
-
|
|
13157
|
-
|
|
13158
|
-
|
|
13159
|
-
return o.translations.ignorePaths.push(o.routes.translationJsonFileName), // order locales
|
|
13147
|
+
*/ /**
|
|
13148
|
+
* Only here if the compiler actually `write`s
|
|
13149
|
+
*/ let getCodeData = async (a, o, e)=>s$1(a, await resolveAdapterOptions(o), e);
|
|
13150
|
+
function s$1(t, a, e) {
|
|
13151
|
+
return a.translations.ignorePaths.push(a.routes.translationJsonFileName), // order locales
|
|
13160
13152
|
e = {
|
|
13161
13153
|
...e,
|
|
13162
|
-
localesFolders: e.localesFolders.sort((
|
|
13154
|
+
localesFolders: e.localesFolders.sort((a, o)=>t.defaultLocale ? -1 : a.localeCompare(o))
|
|
13163
13155
|
}, {
|
|
13164
13156
|
config: t,
|
|
13165
|
-
options:
|
|
13157
|
+
options: a,
|
|
13166
13158
|
input: e,
|
|
13167
|
-
routes: getCodeDataRoutes(t,
|
|
13168
|
-
translations: getCodeDataTranslations(t,
|
|
13159
|
+
routes: getCodeDataRoutes(t, a.routes, e),
|
|
13160
|
+
translations: getCodeDataTranslations(t, a.translations, e)
|
|
13169
13161
|
};
|
|
13170
13162
|
}
|
|
13171
13163
|
|
|
@@ -13202,8 +13194,8 @@ const resolveAdapterOptions = (t)=>{
|
|
|
13202
13194
|
});
|
|
13203
13195
|
};
|
|
13204
13196
|
const getAdapterFileMeta = (t, e)=>{
|
|
13205
|
-
let r = "." ===
|
|
13206
|
-
a =
|
|
13197
|
+
let r = "." === t.dir ? "" : t.dir || "", // allow overwriting output file names through compiler options
|
|
13198
|
+
a = e?.[t.name] || t.name, s = `${r ? r + "/" : ""}${a}.${t.ext}`;
|
|
13207
13199
|
return {
|
|
13208
13200
|
dir: r,
|
|
13209
13201
|
name: a,
|
|
@@ -13229,44 +13221,45 @@ let l$2 = (e)=>{
|
|
|
13229
13221
|
return e.filter((e)=>e.index).sort((e, t)=>e.name.localeCompare(t.name)).forEach((e)=>{
|
|
13230
13222
|
t += `export * from "./${e.name}";\n`;
|
|
13231
13223
|
}), t;
|
|
13232
|
-
}, a$1 = (
|
|
13233
|
-
let
|
|
13224
|
+
}, a$1 = (e)=>{
|
|
13225
|
+
let t = e.reduce((e, t)=>{
|
|
13234
13226
|
let r = t.dir || ".";
|
|
13235
13227
|
return e[r] = e[r] || [], e[r].push(t), e;
|
|
13236
|
-
}, {}),
|
|
13237
|
-
|
|
13238
|
-
let
|
|
13239
|
-
if (
|
|
13228
|
+
}, {}), n = [];
|
|
13229
|
+
for(let e in t){
|
|
13230
|
+
let a = l$2(t[e]);
|
|
13231
|
+
if (a) {
|
|
13240
13232
|
let t = {
|
|
13241
|
-
content:
|
|
13233
|
+
content: a,
|
|
13242
13234
|
ext: "ts",
|
|
13243
13235
|
name: "index",
|
|
13244
13236
|
dir: e,
|
|
13245
13237
|
index: !1
|
|
13246
|
-
}, l = getAdapterFileMeta({}
|
|
13247
|
-
|
|
13238
|
+
}, l = getAdapterFileMeta(t, {});
|
|
13239
|
+
n.push({
|
|
13248
13240
|
...t,
|
|
13249
13241
|
...l
|
|
13250
13242
|
});
|
|
13251
13243
|
}
|
|
13252
|
-
}
|
|
13253
|
-
|
|
13254
|
-
|
|
13244
|
+
}
|
|
13245
|
+
return n;
|
|
13246
|
+
}, o$2 = (e, n)=>{
|
|
13247
|
+
// NOTE: we allow adapters to produce the same files as their dependent's
|
|
13255
13248
|
// parent adapters, here we ensure the parent adapters files do not override
|
|
13256
13249
|
// their children same-named ones which should get the priority
|
|
13257
|
-
l = {}, { generators:
|
|
13258
|
-
let
|
|
13259
|
-
return Object.keys(
|
|
13260
|
-
let a =
|
|
13250
|
+
let l = {}, { generators: o, transformers: i } = n, u = o.reduce((n, a)=>{
|
|
13251
|
+
let o = a(e);
|
|
13252
|
+
return Object.keys(o).forEach((e)=>{
|
|
13253
|
+
let a = o[e], u = i?.[e]?.(a) ?? a, { content: c } = u, { dir: d, name: p, path: s } = getAdapterFileMeta(u, {});
|
|
13261
13254
|
// check that we haven't already generated this file
|
|
13262
|
-
l[
|
|
13263
|
-
...
|
|
13264
|
-
dir:
|
|
13265
|
-
name:
|
|
13266
|
-
path:
|
|
13267
|
-
content: getAdapterFileContent(
|
|
13255
|
+
l[s] || (l[s] = 1, n.push({
|
|
13256
|
+
...u,
|
|
13257
|
+
dir: d,
|
|
13258
|
+
name: p,
|
|
13259
|
+
path: s,
|
|
13260
|
+
content: getAdapterFileContent(u, c())
|
|
13268
13261
|
}));
|
|
13269
|
-
}),
|
|
13262
|
+
}), n;
|
|
13270
13263
|
}, []);
|
|
13271
13264
|
// TODO: prettier does probably not make sense unless one wants to keep the
|
|
13272
13265
|
// auto-generated files on git, maybe allow this as an option?
|
|
@@ -13281,12 +13274,12 @@ let l$2 = (e)=>{
|
|
|
13281
13274
|
return {
|
|
13282
13275
|
// automatically create indexs file if the adapters want them
|
|
13283
13276
|
files: [
|
|
13284
|
-
...
|
|
13285
|
-
...a$1(
|
|
13277
|
+
...u,
|
|
13278
|
+
...a$1(u) || []
|
|
13286
13279
|
]
|
|
13287
13280
|
};
|
|
13288
13281
|
};
|
|
13289
|
-
let generateCode = async (
|
|
13282
|
+
let generateCode = async (t)=>o$2(t, await getAdapter(t));
|
|
13290
13283
|
|
|
13291
13284
|
let tsCompile = (s, i, o, // Set<string>,
|
|
13292
13285
|
n)=>{
|
|
@@ -13381,7 +13374,7 @@ n)=>{
|
|
|
13381
13374
|
*/ // /**
|
|
13382
13375
|
// * Wether to add the `output` folder with the generated files to the `exclude`
|
|
13383
13376
|
// * tsconfig option
|
|
13384
|
-
// *
|
|
13377
|
+
// *
|
|
13385
13378
|
// * @default
|
|
13386
13379
|
// */
|
|
13387
13380
|
// exclude?: boolean;
|
|
@@ -13398,10 +13391,10 @@ n)=>{
|
|
|
13398
13391
|
* @default true
|
|
13399
13392
|
*/ /** It stores the files' paths being written to disk */ /** It stores the folders' paths being written to disk */ let writeCode = async (t, e)=>{
|
|
13400
13393
|
let o = getWriteCodeConfig(t), i = await generateCode(e);
|
|
13401
|
-
await O(o), await S(o, i), j(o), v(o, i), await
|
|
13394
|
+
await O(o), await S(o, i), j(o), v(o, i), await E(o, e.input), W(o);
|
|
13402
13395
|
};
|
|
13403
13396
|
function resolveWriteCodeOptions(t) {
|
|
13404
|
-
let { cwd: e = process.cwd(), output: o, emptyOutputFolder: i = !0, tsconfig: n = {}, typescriptCompilation: r = !1, copyTranslations: l = !0, gitignore:
|
|
13397
|
+
let { cwd: e = process.cwd(), output: o, emptyOutputFolder: i = !0, tsconfig: n = {}, typescriptCompilation: r = !1, copyTranslations: l = !0, gitignore: s = "all" } = t;
|
|
13405
13398
|
return {
|
|
13406
13399
|
cwd: e,
|
|
13407
13400
|
output: o,
|
|
@@ -13414,7 +13407,7 @@ function resolveWriteCodeOptions(t) {
|
|
|
13414
13407
|
},
|
|
13415
13408
|
typescriptCompilation: r,
|
|
13416
13409
|
copyTranslations: l,
|
|
13417
|
-
gitignore:
|
|
13410
|
+
gitignore: s
|
|
13418
13411
|
};
|
|
13419
13412
|
}
|
|
13420
13413
|
function getWriteCodeConfig(t) {
|
|
@@ -13466,15 +13459,15 @@ async function S(t, e) {
|
|
|
13466
13459
|
}
|
|
13467
13460
|
/**
|
|
13468
13461
|
*/ function j(o) {
|
|
13469
|
-
let { cwd: n, tsconfig: l } = o,
|
|
13462
|
+
let { cwd: n, tsconfig: l } = o, a = node_path.join(n, l.path), p = !1, m = {
|
|
13470
13463
|
compilerOptions: {
|
|
13471
13464
|
baseUrl: ".",
|
|
13472
13465
|
paths: {}
|
|
13473
13466
|
}
|
|
13474
13467
|
};
|
|
13475
|
-
if (node_fs.existsSync(
|
|
13468
|
+
if (node_fs.existsSync(a)) try {
|
|
13476
13469
|
// ts.findConfigFile(tsconfigPath, ...)
|
|
13477
|
-
let t = node_fs.readFileSync(
|
|
13470
|
+
let t = node_fs.readFileSync(a, {
|
|
13478
13471
|
encoding: "utf-8"
|
|
13479
13472
|
}), i = src.parse(t), n = $(o, i);
|
|
13480
13473
|
n && (p = !0, m = n);
|
|
@@ -13486,7 +13479,7 @@ async function S(t, e) {
|
|
|
13486
13479
|
t && (p = !0, m = t);
|
|
13487
13480
|
}
|
|
13488
13481
|
let d = src.stringify(m, null, 2);
|
|
13489
|
-
p ? node_fs.writeFileSync(
|
|
13482
|
+
p ? node_fs.writeFileSync(a, d + node_os.EOL) : process.env.JEST_WORKER_ID && console.log("i18n: tsconfig.json is up to date.");
|
|
13490
13483
|
}
|
|
13491
13484
|
/**
|
|
13492
13485
|
* Compiles generated TypeScript source files to JavaScript and `.d.ts` files.
|
|
@@ -13542,7 +13535,7 @@ async function S(t, e) {
|
|
|
13542
13535
|
});
|
|
13543
13536
|
});
|
|
13544
13537
|
}
|
|
13545
|
-
async function
|
|
13538
|
+
async function E(t, { translationFiles: e }) {
|
|
13546
13539
|
let { cwd: o, output: i, copyTranslations: n } = t;
|
|
13547
13540
|
n && Promise.all(e.map(async ({ data: e, locale: n, path: r })=>{
|
|
13548
13541
|
let l = node_path.join(getTranslationsDir(0), n);
|