@next-box/i18n 0.1.1 → 0.1.3
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/README.md +3 -1
- package/dist/cjs/client.cjs +2 -1
- package/dist/cjs/client.cjs.map +1 -1
- package/dist/cjs/components/I18nProvider.cjs +3 -0
- package/dist/cjs/components/I18nProvider.cjs.map +1 -0
- package/dist/cjs/components/Md.cjs +3 -0
- package/dist/cjs/components/Md.cjs.map +1 -0
- package/dist/cjs/constants.cjs +2 -0
- package/dist/cjs/constants.cjs.map +1 -0
- package/dist/cjs/helpers/injectVariables.cjs +2 -0
- package/dist/cjs/helpers/injectVariables.cjs.map +1 -0
- package/dist/cjs/helpers/loadConfig.cjs +2 -0
- package/dist/cjs/helpers/loadConfig.cjs.map +1 -0
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/macros.cjs +1 -1
- package/dist/cjs/macros.cjs.map +1 -1
- package/dist/cjs/main.cjs +2 -0
- package/dist/cjs/main.cjs.map +1 -0
- package/dist/esm/client.mjs +2 -1
- package/dist/esm/client.mjs.map +1 -1
- package/dist/esm/components/I18nProvider.mjs +3 -0
- package/dist/esm/components/I18nProvider.mjs.map +1 -0
- package/dist/esm/components/Md.mjs +3 -0
- package/dist/esm/components/Md.mjs.map +1 -0
- package/dist/esm/constants.mjs +2 -0
- package/dist/esm/constants.mjs.map +1 -0
- package/dist/esm/helpers/injectVariables.mjs +2 -0
- package/dist/esm/helpers/injectVariables.mjs.map +1 -0
- package/dist/esm/helpers/loadConfig.mjs +2 -0
- package/dist/esm/helpers/loadConfig.mjs.map +1 -0
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/macros.mjs +1 -1
- package/dist/esm/macros.mjs.map +1 -1
- package/dist/esm/main.mjs +2 -0
- package/dist/esm/main.mjs.map +1 -0
- package/dist/production.analysis.txt +10 -10
- package/dist/types/cjs/client.d.cts.map +1 -1
- package/dist/types/cjs/components/I18nProvider.d.cts.map +1 -1
- package/dist/types/cjs/components/Md.d.cts.map +1 -1
- package/dist/types/cjs/helpers/injectVariables.d.cts.map +1 -1
- package/dist/types/cjs/main.d.cts.map +1 -1
- package/dist/types/esm/client.d.ts.map +1 -1
- package/dist/types/esm/components/I18nProvider.d.ts.map +1 -1
- package/dist/types/esm/components/Md.d.ts.map +1 -1
- package/dist/types/esm/helpers/injectVariables.d.ts.map +1 -1
- package/dist/types/esm/main.d.ts.map +1 -1
- package/dist/types/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +13 -12
- package/rollup.config.mjs +1 -9
- package/src/client.ts +2 -0
- package/src/components/I18nProvider.tsx +2 -0
- package/src/components/Md.test.tsx +34 -32
- package/src/components/Md.tsx +2 -0
- package/src/helpers/injectVariables.test.ts +37 -0
- package/src/helpers/injectVariables.ts +3 -4
- package/src/macros.test.ts +34 -21
- package/src/main.test.ts +98 -62
- package/src/main.ts +0 -2
- package/src/types.ts +1 -1
- package/tsconfig.json +3 -0
package/README.md
CHANGED
|
@@ -197,8 +197,10 @@ The `md` macro is designed to be used with the `Md` markdown render component an
|
|
|
197
197
|
The example below illustrates how to use the `md` macro, `I18nProvider`, and `Md` component together.
|
|
198
198
|
|
|
199
199
|
```tsx
|
|
200
|
+
'use client';
|
|
201
|
+
|
|
200
202
|
import { md } from '@next-box/i18n/macros' with { type: 'macro' };
|
|
201
|
-
import { I18nProvider, Md } from '@next-box/i18n';
|
|
203
|
+
import { I18nProvider, Md } from '@next-box/i18n/client';
|
|
202
204
|
import { componentMapper } from './componentMapper.ts';
|
|
203
205
|
|
|
204
206
|
export const Component = () => {
|
package/dist/cjs/client.cjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
"use
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";var e=require("./components/I18nProvider.cjs"),r=require("./components/Md.cjs");exports.I18nContext=e.I18nContext,exports.I18nProvider=e.I18nProvider,exports.Md=r.Md;
|
|
2
3
|
//# sourceMappingURL=client.cjs.map
|
package/dist/cjs/client.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.cjs","sources":[
|
|
1
|
+
{"version":3,"file":"client.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";var e=require("react/jsx-runtime");const r=require("react").createContext({componentMapper:{}});exports.I18nContext=r,exports.I18nProvider=({children:t,componentMapper:n,...o})=>e.jsx(r,{value:{componentMapper:n,...o},children:t});
|
|
3
|
+
//# sourceMappingURL=I18nProvider.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"I18nProvider.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("markdown-to-jsx"),i=require("react"),n=require("./I18nProvider.cjs"),s=require("../helpers/injectVariables.cjs");exports.Md=({children:t,componentMapper:o,variables:a,...c})=>{const{componentMapper:p,...u}=i.use(n.I18nContext);return e.jsx(r,{options:{overrides:{...p,...o},...u,...c},children:s.injectVariables(t,a)})};
|
|
3
|
+
//# sourceMappingURL=Md.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Md.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.cjs","sources":["../../src/constants.ts"],"sourcesContent":["export const CONFIG_FILENAME = '.i18n-macro.config.json';\n"],"names":[],"mappings":"qCAA+B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const r=/{{[^\s{}]+}}/g,e=/{{ *([^ }]*) *}}/;exports.injectVariables=(n,t)=>t?n.replaceAll(r,r=>{const n=r.replace(e,"$1"),a=t[n];if(void 0!==a)return String(a);throw new Error(`Markdown contains un-replaced variable '${n}'`)}):n;
|
|
2
|
+
//# sourceMappingURL=injectVariables.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectVariables.cjs","sources":["../../../src/helpers/injectVariables.ts"],"sourcesContent":["const extractTemplateVariables = /{{[^\\s{}]+}}/g;\nconst extractVarName = /{{ *([^ }]*) *}}/;\n\nexport const injectVariables = (markdown: string, variables?: Record<string, string | number>): string =>\n variables\n ? markdown.replaceAll(extractTemplateVariables, (match: string) => {\n const varName = match.replace(extractVarName, '$1');\n const replacementValue = variables[varName];\n\n if (replacementValue !== undefined) {\n return String(replacementValue);\n }\n\n throw new Error(`Markdown contains un-replaced variable '${varName}'`);\n })\n : markdown;\n"],"names":["extractTemplateVariables","extractVarName","markdown","variables","replaceAll","match","varName","replace","replacementValue","undefined","String","Error"],"mappings":"aAAA,MAAMA,EAA2B,gBAC3BC,EAAiB,2CAEQ,CAACC,EAAkBC,IAChDA,EACID,EAASE,WAAWJ,EAA2BK,IAC7C,MAAMC,EAAUD,EAAME,QAAQN,EAAgB,MACxCO,EAAmBL,EAAUG,GAEnC,QAAyBG,IAArBD,EACF,OAAOE,OAAOF,GAGhB,MAAM,IAAIG,MAAM,2CAA2CL,QAE7DJ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var e=require("node:fs"),r=require("node:path"),s=require("../constants.cjs");const t=process.cwd();exports.loadConfig=()=>{let c={};try{c=JSON.parse(e.readFileSync(r.resolve(t,s.CONFIG_FILENAME),{encoding:"utf8"}))}catch{}return c};
|
|
2
|
+
//# sourceMappingURL=loadConfig.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadConfig.cjs","sources":["../../../src/helpers/loadConfig.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { CONFIG_FILENAME } from '#constants.ts';\nimport { type MacrosConfig } from '#types.ts';\n\nconst cwd = process.cwd();\n\nexport const loadConfig = (): Partial<MacrosConfig> => {\n let config: Partial<MacrosConfig> = {};\n\n try {\n // JSON.parse returns an any time\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n config = JSON.parse(readFileSync(resolve(cwd, CONFIG_FILENAME), { encoding: 'utf8' })) as Partial<MacrosConfig>;\n } catch {\n // no catch\n }\n\n return config;\n};\n"],"names":["cwd","process","config","JSON","parse","readFileSync","resolve","CONFIG_FILENAME","encoding"],"mappings":"2FAKA,MAAMA,EAAMC,QAAQD,yBAEM,KACxB,IAAIE,EAAgC,CAAA,EAEpC,IAGEA,EAASC,KAAKC,MAAMC,EAAAA,aAAaC,EAAAA,QAAQN,EAAKO,EAAAA,iBAAkB,CAAEC,SAAU,SAC9E,CAAE,MAEF,CAEA,OAAON"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var e=require("./main.cjs");exports.createI18n=e.createI18n;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":[
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/cjs/macros.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("node:fs"),r=require("node:path")
|
|
1
|
+
"use strict";var e=require("node:fs"),r=require("node:path"),o=require("./helpers/loadConfig.cjs");const{NEXT_PUBLIC_LANGUAGE_CODE:n}=process.env;exports.md=s=>{if(!s)throw new Error("md expected a path, but received none");let t=process.cwd(),{markdownDir:c}=o.loadConfig();c&&(n&&(c=c.replaceAll("{{NEXT_PUBLIC_LANGUAGE_CODE}}",()=>n)),t=r.resolve(t,c));const d=r.resolve(t,s);return e.readFileSync(d,{encoding:"utf8"}).trim()};
|
|
2
2
|
//# sourceMappingURL=macros.cjs.map
|
package/dist/cjs/macros.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"macros.cjs","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"macros.cjs","sources":["../../src/macros.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { loadConfig } from '#helpers/loadConfig.ts';\n\nconst { NEXT_PUBLIC_LANGUAGE_CODE } = process.env;\n\nexport const md = <P extends string>(path: P): P => {\n if (!path) {\n throw new Error('md expected a path, but received none');\n }\n\n let dir = process.cwd();\n let { markdownDir } = loadConfig();\n\n if (markdownDir) {\n if (NEXT_PUBLIC_LANGUAGE_CODE) {\n markdownDir = markdownDir.replaceAll('{{NEXT_PUBLIC_LANGUAGE_CODE}}', () => NEXT_PUBLIC_LANGUAGE_CODE);\n }\n\n dir = resolve(dir, markdownDir);\n }\n\n const fullPath = resolve(dir, path);\n // @ts-expect-error `md` function runs and build time and its return value\n // replaces the `md` invocation. We are forcing the return type to be the\n // input type to aid type inference when using `createI18n` and its\n // `tt` content resolvers.\n return readFileSync(fullPath, { encoding: 'utf8' }).trim();\n};\n"],"names":["NEXT_PUBLIC_LANGUAGE_CODE","process","env","path","Error","dir","cwd","markdownDir","loadConfig","replaceAll","resolve","fullPath","readFileSync","encoding","trim"],"mappings":"mGAIA,MAAMA,0BAAEA,GAA8BC,QAAQC,eAETC,IACnC,IAAKA,EACH,MAAM,IAAIC,MAAM,yCAGlB,IAAIC,EAAMJ,QAAQK,OACdC,YAAEA,GAAgBC,eAElBD,IACEP,IACFO,EAAcA,EAAYE,WAAW,gCAAiC,IAAMT,IAG9EK,EAAMK,EAAAA,QAAQL,EAAKE,IAGrB,MAAMI,EAAWD,EAAAA,QAAQL,EAAKF,GAK9B,OAAOS,EAAAA,aAAaD,EAAU,CAAEE,SAAU,SAAUC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.cjs","sources":["../../src/main.ts"],"sourcesContent":["import { type Get } from 'type-fest';\nimport { type AnyRecord, type Path, createConfigReader } from 'zcb';\nimport { type CreateI18nResult } from '#types.ts';\n\nexport const createI18n = <U extends object>(i18n: U): CreateI18nResult<U> => {\n const reader = createConfigReader<U>(i18n);\n\n return {\n // @ts-expect-error intentionally ignoring the type checking here as\n // function is supposed to be untyped.\n t: (key: string, variables?: AnyRecord): string | undefined => reader.read(key, variables),\n tt: <P extends Path<U>>(path: P, variables?: AnyRecord): Get<U, P> => {\n const result = reader.read(path, variables);\n\n if (result === undefined) {\n throw new Error(`Path \"${String(path)}\" did not resolve to a value`);\n }\n\n return result;\n },\n };\n};\n"],"names":["i18n","reader","createConfigReader","t","key","variables","read","tt","path","result","undefined","Error","String"],"mappings":"qDAI6CA,IAC3C,MAAMC,EAASC,EAAAA,mBAAsBF,GAErC,MAAO,CAGLG,EAAG,CAACC,EAAaC,IAA8CJ,EAAOK,KAAKF,EAAKC,GAChFE,GAAI,CAAoBC,EAASH,KAC/B,MAAMI,EAASR,EAAOK,KAAKE,EAAMH,GAEjC,QAAeK,IAAXD,EACF,MAAM,IAAIE,MAAM,SAASC,OAAOJ,kCAGlC,OAAOC"}
|
package/dist/esm/client.mjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
export{I18nContext,I18nProvider}from"./components/I18nProvider.mjs";export{Md}from"./components/Md.mjs";
|
|
2
3
|
//# sourceMappingURL=client.mjs.map
|
package/dist/esm/client.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.mjs","sources":[
|
|
1
|
+
{"version":3,"file":"client.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as e}from"react/jsx-runtime";import{createContext as r}from"react";const o=r({componentMapper:{}}),p=({children:r,componentMapper:p,...n})=>e(o,{value:{componentMapper:p,...n},children:r});export{o as I18nContext,p as I18nProvider};
|
|
3
|
+
//# sourceMappingURL=I18nProvider.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"I18nProvider.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import{jsx as r}from"react/jsx-runtime";import o from"markdown-to-jsx";import{use as e}from"react";import{I18nContext as t}from"./I18nProvider.mjs";import{injectVariables as m}from"../helpers/injectVariables.mjs";const i=({children:i,componentMapper:n,variables:p,...s})=>{const{componentMapper:a,...c}=e(t);return r(o,{options:{overrides:{...a,...n},...c,...s},children:m(i,p)})};export{i as Md};
|
|
3
|
+
//# sourceMappingURL=Md.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Md.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.mjs","sources":["../../src/constants.ts"],"sourcesContent":["export const CONFIG_FILENAME = '.i18n-macro.config.json';\n"],"names":["CONFIG_FILENAME"],"mappings":"AAAO,MAAMA,EAAkB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const r=/{{[^\s{}]+}}/g,e=/{{ *([^ }]*) *}}/,n=(n,o)=>o?n.replaceAll(r,r=>{const n=r.replace(e,"$1"),a=o[n];if(void 0!==a)return String(a);throw new Error(`Markdown contains un-replaced variable '${n}'`)}):n;export{n as injectVariables};
|
|
2
|
+
//# sourceMappingURL=injectVariables.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"injectVariables.mjs","sources":["../../../src/helpers/injectVariables.ts"],"sourcesContent":["const extractTemplateVariables = /{{[^\\s{}]+}}/g;\nconst extractVarName = /{{ *([^ }]*) *}}/;\n\nexport const injectVariables = (markdown: string, variables?: Record<string, string | number>): string =>\n variables\n ? markdown.replaceAll(extractTemplateVariables, (match: string) => {\n const varName = match.replace(extractVarName, '$1');\n const replacementValue = variables[varName];\n\n if (replacementValue !== undefined) {\n return String(replacementValue);\n }\n\n throw new Error(`Markdown contains un-replaced variable '${varName}'`);\n })\n : markdown;\n"],"names":["extractTemplateVariables","extractVarName","injectVariables","markdown","variables","replaceAll","match","varName","replace","replacementValue","undefined","String","Error"],"mappings":"AAAA,MAAMA,EAA2B,gBAC3BC,EAAiB,mBAEVC,EAAkB,CAACC,EAAkBC,IAChDA,EACID,EAASE,WAAWL,EAA2BM,IAC7C,MAAMC,EAAUD,EAAME,QAAQP,EAAgB,MACxCQ,EAAmBL,EAAUG,GAEnC,QAAyBG,IAArBD,EACF,OAAOE,OAAOF,GAGhB,MAAM,IAAIG,MAAM,2CAA2CL,QAE7DJ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{readFileSync as o}from"node:fs";import{resolve as t}from"node:path";import{CONFIG_FILENAME as r}from"../constants.mjs";const e=process.cwd(),n=()=>{let n={};try{n=JSON.parse(o(t(e,r),{encoding:"utf8"}))}catch{}return n};export{n as loadConfig};
|
|
2
|
+
//# sourceMappingURL=loadConfig.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadConfig.mjs","sources":["../../../src/helpers/loadConfig.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { CONFIG_FILENAME } from '#constants.ts';\nimport { type MacrosConfig } from '#types.ts';\n\nconst cwd = process.cwd();\n\nexport const loadConfig = (): Partial<MacrosConfig> => {\n let config: Partial<MacrosConfig> = {};\n\n try {\n // JSON.parse returns an any time\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n config = JSON.parse(readFileSync(resolve(cwd, CONFIG_FILENAME), { encoding: 'utf8' })) as Partial<MacrosConfig>;\n } catch {\n // no catch\n }\n\n return config;\n};\n"],"names":["cwd","process","loadConfig","config","JSON","parse","readFileSync","resolve","CONFIG_FILENAME","encoding"],"mappings":"8HAKA,MAAMA,EAAMC,QAAQD,MAEPE,EAAa,KACxB,IAAIC,EAAgC,CAAA,EAEpC,IAGEA,EAASC,KAAKC,MAAMC,EAAaC,EAAQP,EAAKQ,GAAkB,CAAEC,SAAU,SAC9E,CAAE,MAEF,CAEA,OAAON"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export{createI18n}from"./main.mjs";
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/dist/esm/macros.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{readFileSync as e}from"node:fs";import{resolve as r}from"node:path";
|
|
1
|
+
import{readFileSync as e}from"node:fs";import{resolve as r}from"node:path";import{loadConfig as o}from"./helpers/loadConfig.mjs";const{NEXT_PUBLIC_LANGUAGE_CODE:t}=process.env,n=n=>{if(!n)throw new Error("md expected a path, but received none");let p=process.cwd(),{markdownDir:m}=o();m&&(t&&(m=m.replaceAll("{{NEXT_PUBLIC_LANGUAGE_CODE}}",()=>t)),p=r(p,m));const c=r(p,n);return e(c,{encoding:"utf8"}).trim()};export{n as md};
|
|
2
2
|
//# sourceMappingURL=macros.mjs.map
|
package/dist/esm/macros.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"macros.mjs","sources":["../../src/
|
|
1
|
+
{"version":3,"file":"macros.mjs","sources":["../../src/macros.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { loadConfig } from '#helpers/loadConfig.ts';\n\nconst { NEXT_PUBLIC_LANGUAGE_CODE } = process.env;\n\nexport const md = <P extends string>(path: P): P => {\n if (!path) {\n throw new Error('md expected a path, but received none');\n }\n\n let dir = process.cwd();\n let { markdownDir } = loadConfig();\n\n if (markdownDir) {\n if (NEXT_PUBLIC_LANGUAGE_CODE) {\n markdownDir = markdownDir.replaceAll('{{NEXT_PUBLIC_LANGUAGE_CODE}}', () => NEXT_PUBLIC_LANGUAGE_CODE);\n }\n\n dir = resolve(dir, markdownDir);\n }\n\n const fullPath = resolve(dir, path);\n // @ts-expect-error `md` function runs and build time and its return value\n // replaces the `md` invocation. We are forcing the return type to be the\n // input type to aid type inference when using `createI18n` and its\n // `tt` content resolvers.\n return readFileSync(fullPath, { encoding: 'utf8' }).trim();\n};\n"],"names":["NEXT_PUBLIC_LANGUAGE_CODE","process","env","md","path","Error","dir","cwd","markdownDir","loadConfig","replaceAll","resolve","fullPath","readFileSync","encoding","trim"],"mappings":"iIAIA,MAAMA,0BAAEA,GAA8BC,QAAQC,IAEjCC,EAAwBC,IACnC,IAAKA,EACH,MAAM,IAAIC,MAAM,yCAGlB,IAAIC,EAAML,QAAQM,OACdC,YAAEA,GAAgBC,IAElBD,IACER,IACFQ,EAAcA,EAAYE,WAAW,gCAAiC,IAAMV,IAG9EM,EAAMK,EAAQL,EAAKE,IAGrB,MAAMI,EAAWD,EAAQL,EAAKF,GAK9B,OAAOS,EAAaD,EAAU,CAAEE,SAAU,SAAUC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.mjs","sources":["../../src/main.ts"],"sourcesContent":["import { type Get } from 'type-fest';\nimport { type AnyRecord, type Path, createConfigReader } from 'zcb';\nimport { type CreateI18nResult } from '#types.ts';\n\nexport const createI18n = <U extends object>(i18n: U): CreateI18nResult<U> => {\n const reader = createConfigReader<U>(i18n);\n\n return {\n // @ts-expect-error intentionally ignoring the type checking here as\n // function is supposed to be untyped.\n t: (key: string, variables?: AnyRecord): string | undefined => reader.read(key, variables),\n tt: <P extends Path<U>>(path: P, variables?: AnyRecord): Get<U, P> => {\n const result = reader.read(path, variables);\n\n if (result === undefined) {\n throw new Error(`Path \"${String(path)}\" did not resolve to a value`);\n }\n\n return result;\n },\n };\n};\n"],"names":["createI18n","i18n","reader","createConfigReader","t","key","variables","read","tt","path","result","undefined","Error","String"],"mappings":"yCAIO,MAAMA,EAAgCC,IAC3C,MAAMC,EAASC,EAAsBF,GAErC,MAAO,CAGLG,EAAG,CAACC,EAAaC,IAA8CJ,EAAOK,KAAKF,EAAKC,GAChFE,GAAI,CAAoBC,EAASH,KAC/B,MAAMI,EAASR,EAAOK,KAAKE,EAAMH,GAEjC,QAAeK,IAAXD,EACF,MAAM,IAAIE,MAAM,SAASC,OAAOJ,kCAGlC,OAAOC"}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
-----------------------------
|
|
2
2
|
Rollup File Analysis
|
|
3
3
|
-----------------------------
|
|
4
|
-
bundle size: 1.
|
|
4
|
+
bundle size: 1.275 KB
|
|
5
5
|
original size: 1.612 KB
|
|
6
|
-
code reduction:
|
|
6
|
+
code reduction: 20.91 %
|
|
7
7
|
module count: 3
|
|
8
8
|
|
|
9
9
|
█████████████████████████████████░░░░░░░░░░░░░░░░░
|
|
10
10
|
file: /src/macros.ts
|
|
11
|
-
bundle space: 66.
|
|
12
|
-
rendered size:
|
|
11
|
+
bundle space: 66.2 %
|
|
12
|
+
rendered size: 844 Bytes
|
|
13
13
|
original size: 958 Bytes
|
|
14
|
-
code reduction:
|
|
14
|
+
code reduction: 11.9 %
|
|
15
15
|
dependents: 0
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
██████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
|
|
18
18
|
file: /src/helpers/loadConfig.ts
|
|
19
|
-
bundle space:
|
|
20
|
-
rendered size:
|
|
19
|
+
bundle space: 29.88 %
|
|
20
|
+
rendered size: 381 Bytes
|
|
21
21
|
original size: 596 Bytes
|
|
22
|
-
code reduction:
|
|
22
|
+
code reduction: 36.07 %
|
|
23
23
|
dependents: 1
|
|
24
24
|
- /src/macros.ts
|
|
25
25
|
|
|
26
26
|
█░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
|
|
27
27
|
file: /src/constants.ts
|
|
28
|
-
bundle space: 3.
|
|
28
|
+
bundle space: 3.92 %
|
|
29
29
|
rendered size: 50 Bytes
|
|
30
30
|
original size: 58 Bytes
|
|
31
31
|
code reduction: 13.79 %
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.cts","sourceRoot":"","sources":["../../../src/client.cts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.cts","sourceRoot":"","sources":["../../../src/client.cts"],"names":[],"mappings":"AAEA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18nProvider.d.cts","sourceRoot":"","sources":["../../../../src/components/I18nProvider.ctsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"I18nProvider.d.cts","sourceRoot":"","sources":["../../../../src/components/I18nProvider.ctsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,SAAS,EAAiB,MAAM,OAAO,CAAC;AAE/D,eAAO,MAAM,WAAW;qBAEH,aAAa,CAAC,SAAS;;qHAcg5W,GAAI;;;;;;;;;;;;;;;;;;;iBAV97W,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,SAAS,CAAC;IACpB,eAAe,EAAE,aAAa,CAAC,SAAS,CAAC;CAC1C,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AAE7C,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAE9C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Md.d.cts","sourceRoot":"","sources":["../../../../src/components/Md.ctsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Md.d.cts","sourceRoot":"","sources":["../../../../src/components/Md.ctsx"],"names":[],"mappings":"AAEA,OAAsB,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,EAAO,MAAM,OAAO,CAAC;AAIrC,MAAM,MAAM,OAAO,GAAG;IAEpB,QAAQ,EAAE,MAAM,CAAC;IAMjB,eAAe,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC;IAE1C,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CAC7C,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AAE7C,eAAO,MAAM,EAAE,EAAE,EAAE,CAAC,OAAO,CAmB1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectVariables.d.cts","sourceRoot":"","sources":["../../../../src/helpers/injectVariables.cts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,EAAE,YAAY,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KAAG,
|
|
1
|
+
{"version":3,"file":"injectVariables.d.cts","sourceRoot":"","sources":["../../../../src/helpers/injectVariables.cts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,EAAE,YAAY,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KAAG,MAYlF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.cts","sourceRoot":"","sources":["../../../src/main.cts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElD,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,MAAM,EAAE,MAAM,CAAC,KAAG,gBAAgB,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"main.d.cts","sourceRoot":"","sources":["../../../src/main.cts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElD,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,MAAM,EAAE,MAAM,CAAC,KAAG,gBAAgB,CAAC,CAAC,CAiBxE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/client.ts"],"names":[],"mappings":"AAEA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18nProvider.d.ts","sourceRoot":"","sources":["../../../../src/components/I18nProvider.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"I18nProvider.d.ts","sourceRoot":"","sources":["../../../../src/components/I18nProvider.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,SAAS,EAAiB,MAAM,OAAO,CAAC;AAE/D,eAAO,MAAM,WAAW;qBAEH,aAAa,CAAC,SAAS;;qHAcg5W,GAAI;;;;;;;;;;;;;;;;;;;iBAV97W,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,SAAS,CAAC;IACpB,eAAe,EAAE,aAAa,CAAC,SAAS,CAAC;CAC1C,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AAE7C,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAE9C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Md.d.ts","sourceRoot":"","sources":["../../../../src/components/Md.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Md.d.ts","sourceRoot":"","sources":["../../../../src/components/Md.tsx"],"names":[],"mappings":"AAEA,OAAsB,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,KAAK,EAAE,EAAO,MAAM,OAAO,CAAC;AAIrC,MAAM,MAAM,OAAO,GAAG;IAEpB,QAAQ,EAAE,MAAM,CAAC;IAMjB,eAAe,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC;IAE1C,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CAC7C,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AAE7C,eAAO,MAAM,EAAE,EAAE,EAAE,CAAC,OAAO,CAmB1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"injectVariables.d.ts","sourceRoot":"","sources":["../../../../src/helpers/injectVariables.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,EAAE,YAAY,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KAAG,
|
|
1
|
+
{"version":3,"file":"injectVariables.d.ts","sourceRoot":"","sources":["../../../../src/helpers/injectVariables.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,EAAE,YAAY,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KAAG,MAYlF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/main.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElD,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,MAAM,EAAE,MAAM,CAAC,KAAG,gBAAgB,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/main.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElD,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,MAAM,EAAE,MAAM,CAAC,KAAG,gBAAgB,CAAC,CAAC,CAiBxE,CAAC"}
|