@next-box/i18n 0.0.9 → 0.0.11
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 +2 -2
- package/dist/cjs/client.cjs.map +1 -1
- package/dist/cjs/macros.cjs +1 -1
- package/dist/cjs/macros.cjs.map +1 -1
- package/dist/esm/client.mjs.map +1 -1
- package/dist/esm/macros.mjs +1 -1
- package/dist/esm/macros.mjs.map +1 -1
- package/dist/production.analysis.txt +11 -11
- package/dist/types/cjs/components/I18nProvider.d.cts +10 -11
- package/dist/types/cjs/components/I18nProvider.d.cts.map +1 -1
- package/dist/types/cjs/components/Md.d.cts +4 -5
- package/dist/types/cjs/components/Md.d.cts.map +1 -1
- package/dist/types/cjs/helpers/loadConfig.d.cts.map +1 -1
- package/dist/types/cjs/types.d.cts +0 -2
- package/dist/types/cjs/types.d.cts.map +1 -1
- package/dist/types/esm/components/I18nProvider.d.ts +10 -11
- package/dist/types/esm/components/I18nProvider.d.ts.map +1 -1
- package/dist/types/esm/components/Md.d.ts +4 -5
- package/dist/types/esm/components/Md.d.ts.map +1 -1
- package/dist/types/esm/helpers/loadConfig.d.ts.map +1 -1
- package/dist/types/esm/types.d.ts +0 -2
- package/dist/types/esm/types.d.ts.map +1 -1
- package/dist/types/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/I18nProvider.tsx +6 -7
- package/src/components/Md.test.tsx +5 -3
- package/src/components/Md.tsx +4 -5
- package/src/helpers/loadConfig.ts +4 -1
- package/src/types.ts +0 -5
package/README.md
CHANGED
|
@@ -177,12 +177,12 @@ The `markdownDir` path supports a template variable `NEXT_PUBLIC_LANGUAGE_CODE`,
|
|
|
177
177
|
|
|
178
178
|
The `md` macro is designed to be used with the `Md` markdown render component and `I18nProvider` context provider. `Md` transforms markdown into React components, while `I18nProvider` provides a way to share a component mapper and `markdown-to-jsx` options between instances of `Md`.
|
|
179
179
|
|
|
180
|
-
> Under the hood, the library uses the `markdown-to-jsx` npm package to transform markdown into JSX.
|
|
180
|
+
> Under the hood, the library uses the `markdown-to-jsx` npm package to transform markdown into JSX. See [the package's documentation](https://github.com/quantizor/markdown-to-jsx) for more information on its configuration options. Our `componentMapper` prop maps to the `markdown-to-jsx` `overrides` option.
|
|
181
181
|
|
|
182
182
|
The contrived example below illustrates how to use the `md` macro, `I18nProvider`, and `Md` component together.
|
|
183
183
|
|
|
184
184
|
```tsx
|
|
185
|
-
import { md } from '@next-box/i18n/macros' with {type: 'macro'};
|
|
185
|
+
import { md } from '@next-box/i18n/macros' with { type: 'macro' };
|
|
186
186
|
import { I18nProvider, Md } from '@next-box/i18n';
|
|
187
187
|
import { componentMapper } from './componentMapper.ts';
|
|
188
188
|
|
package/dist/cjs/client.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.cjs","sources":["../i18n/src//components/I18nProvider.tsx","../i18n/src//helpers/injectVariables.ts","../i18n/src//components/Md.tsx"],"sourcesContent":["import type
|
|
1
|
+
{"version":3,"file":"client.cjs","sources":["../i18n/src//components/I18nProvider.tsx","../i18n/src//helpers/injectVariables.ts","../i18n/src//components/Md.tsx"],"sourcesContent":["import { type MarkdownToJSX } from 'markdown-to-jsx';\nimport { type JSX, type ReactNode, createContext } from 'react';\n\nexport const I18nContext = createContext<\n {\n componentMapper: MarkdownToJSX.Overrides;\n } & Omit<MarkdownToJSX.Options, 'overrides'>\n>({\n componentMapper: {},\n});\n\nexport type I18nProviderProps = {\n children: ReactNode;\n componentMapper: MarkdownToJSX.Overrides;\n} & Omit<MarkdownToJSX.Options, 'overrides'>;\n\nexport const I18nProvider = ({\n children,\n componentMapper,\n ...markdownToJsxOptions\n}: I18nProviderProps): JSX.Element => {\n return <I18nContext.Provider value={{ componentMapper, ...markdownToJsxOptions }}>{children}</I18nContext.Provider>;\n};\n","const extractTemplateVariables = /{{[^\\s{}]+}}/g;\nconst extractVarName = /{{ *([^ }]*) *}}/;\n\nexport const injectVariables = (markdown: string, variables?: Record<string, string | number>): string =>\n variables\n ? // @ts-expect-error lib config needs updating\n markdown.replaceAll(extractTemplateVariables, (match: string) => {\n const varName = match.replace(extractVarName, '$1');\n const replacementValue = variables[varName];\n\n if (replacementValue) {\n return replacementValue;\n }\n\n throw new Error(`Markdown contains un-replaced variable '${varName}'`);\n })\n : markdown;\n","import MarkdownToJsx, { type MarkdownToJSX } from 'markdown-to-jsx';\nimport { type JSX, useContext } from 'react';\nimport { I18nContext } from '#components/I18nProvider.tsx';\nimport { injectVariables } from '#helpers/injectVariables.ts';\n\nexport type MdProps = {\n // The markdown to convert into JSX.\n children: string;\n // An object of key/value pairs, with the key being the\n // name of the html tag that maps to supported markdown or\n // the name of a React component, and the value being a\n // React component. This prop is designed as an override\n // for the componentMapper passed into the I18nProvider.\n componentMapper?: MarkdownToJSX.Overrides;\n // An object of key/value pairs for content with template variables.\n variables?: Record<string, string | number>;\n} & Omit<MarkdownToJSX.Options, 'overrides'>;\n\nexport const Md = ({\n children,\n componentMapper: componentMapperOverrides,\n variables,\n ...markdownToJsxOptionOverrides\n}: MdProps): JSX.Element => {\n const { componentMapper, ...markdownToJsxOptions } = useContext(I18nContext);\n\n return (\n <MarkdownToJsx\n options={{\n overrides: { ...componentMapper, ...componentMapperOverrides },\n ...markdownToJsxOptions,\n ...markdownToJsxOptionOverrides,\n }}\n >\n {injectVariables(children, variables)}\n </MarkdownToJsx>\n );\n};\n"],"names":["I18nContext","createContext","componentMapper","extractTemplateVariables","extractVarName","injectVariables","markdown","variables","replaceAll","match","varName","replace","replacementValue","Error","children","markdownToJsxOptions","_jsx","jsx","Provider","value","componentMapperOverrides","markdownToJsxOptionOverrides","useContext","MarkdownToJsx","options","overrides"],"mappings":"gGAGO,MAAMA,EAAcC,EAAAA,cAIzB,CACAC,gBAAiB,CAAA,ICRbC,EAA2B,gBAC3BC,EAAiB,mBAEVC,EAAkB,CAACC,EAAkBC,IAChDA,EAEID,EAASE,WAAWL,GAA2BM,IAC7C,MAAMC,EAAUD,EAAME,QAAQP,EAAgB,MACxCQ,EAAmBL,EAAUG,GAEnC,GAAIE,EACF,OAAOA,EAGT,MAAM,IAAIC,MAAM,2CAA2CH,SAE7DJ,6CDAsB,EAC1BQ,WACAZ,qBACGa,KAEIC,EAAAC,IAACjB,EAAYkB,SAAQ,CAACC,MAAO,CAAEjB,qBAAoBa,GAAyBD,SAAAA,eEHnE,EAChBA,WACAZ,gBAAiBkB,EACjBb,eACGc,MAEH,MAAMnB,gBAAEA,KAAoBa,GAAyBO,EAAAA,WAAWtB,GAEhE,OACEgB,EAAAA,IAACO,EAAAA,CACCC,QAAS,CACPC,UAAW,IAAKvB,KAAoBkB,MACjCL,KACAM,GAGJhB,SAAAA,EAAgBS,EAAUP"}
|
package/dist/cjs/macros.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("node:fs"),r=require("node:path");const{NEXT_PUBLIC_LANGUAGE_CODE:n}=process.env;exports.md=
|
|
1
|
+
"use strict";var e=require("node:fs"),r=require("node:path");const{NEXT_PUBLIC_LANGUAGE_CODE:n}=process.env;exports.md=o=>{if(!o)throw new Error("md expected a path, but received none");let c=process.cwd(),{markdownDir:t}=(()=>{let n={};try{n=JSON.parse(e.readFileSync(r.resolve(process.cwd(),".i18n-macro.config.json"),{encoding:"utf8"}))}catch{}return n})();t&&(n&&(t=t.replaceAll("{{NEXT_PUBLIC_LANGUAGE_CODE}}",n)),c=r.resolve(c,t));const s=r.resolve(c,o);return e.readFileSync(s,{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":["../i18n/src//constants.ts","../i18n/src//macros.ts","../i18n/src//helpers/loadConfig.ts"],"sourcesContent":["export const CONFIG_FILENAME = '.i18n-macro.config.json';\n","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","import { readFileSync } from 'node:fs';\nimport { CONFIG_FILENAME } from '#constants.ts';\nimport { type MacrosConfig } from '#types.ts';\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(CONFIG_FILENAME, { encoding: 'utf8' })) as Partial<MacrosConfig>;\n } catch {\n // no catch\n }\n\n return config;\n};\n"],"names":["NEXT_PUBLIC_LANGUAGE_CODE","process","env","path","Error","dir","cwd","markdownDir","config","JSON","parse","readFileSync","encoding","loadConfig","replaceAll","
|
|
1
|
+
{"version":3,"file":"macros.cjs","sources":["../i18n/src//constants.ts","../i18n/src//macros.ts","../i18n/src//helpers/loadConfig.ts"],"sourcesContent":["export const CONFIG_FILENAME = '.i18n-macro.config.json';\n","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","import { readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { CONFIG_FILENAME } from '#constants.ts';\nimport { type MacrosConfig } from '#types.ts';\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(\n readFileSync(resolve(process.cwd(), CONFIG_FILENAME), { encoding: 'utf8' }),\n ) as Partial<MacrosConfig>;\n } catch {\n // no catch\n }\n\n return config;\n};\n"],"names":["NEXT_PUBLIC_LANGUAGE_CODE","process","env","path","Error","dir","cwd","markdownDir","config","JSON","parse","readFileSync","resolve","encoding","loadConfig","replaceAll","fullPath","trim"],"mappings":"6DAAO,MCIDA,0BAAEA,GAA8BC,QAAQC,eAETC,IACnC,IAAKA,EACH,MAAM,IAAIC,MAAM,yCAGlB,IAAIC,EAAMJ,QAAQK,OACdC,YAAEA,GCPkB,MACxB,IAAIC,EAAgC,CAAC,EAErC,IAGEA,EAASC,KAAKC,MACZC,EAAAA,aAAaC,UAAQX,QAAQK,MFZJ,2BEY6B,CAAEO,SAAU,SAEtE,CAAE,MAEF,CAEA,OAAOL,GDNeM,GAElBP,IACEP,IACFO,EAAcA,EAAYQ,WAAW,gCAAiCf,IAGxEK,EAAMO,EAAAA,QAAQP,EAAKE,IAGrB,MAAMS,EAAWJ,EAAAA,QAAQP,EAAKF,GAK9B,OAAOQ,EAAAA,aAAaK,EAAU,CAAEH,SAAU,SAAUI"}
|
package/dist/esm/client.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.mjs","sources":["../i18n/src//components/I18nProvider.tsx","../i18n/src//helpers/injectVariables.ts","../i18n/src//components/Md.tsx"],"sourcesContent":["import type
|
|
1
|
+
{"version":3,"file":"client.mjs","sources":["../i18n/src//components/I18nProvider.tsx","../i18n/src//helpers/injectVariables.ts","../i18n/src//components/Md.tsx"],"sourcesContent":["import { type MarkdownToJSX } from 'markdown-to-jsx';\nimport { type JSX, type ReactNode, createContext } from 'react';\n\nexport const I18nContext = createContext<\n {\n componentMapper: MarkdownToJSX.Overrides;\n } & Omit<MarkdownToJSX.Options, 'overrides'>\n>({\n componentMapper: {},\n});\n\nexport type I18nProviderProps = {\n children: ReactNode;\n componentMapper: MarkdownToJSX.Overrides;\n} & Omit<MarkdownToJSX.Options, 'overrides'>;\n\nexport const I18nProvider = ({\n children,\n componentMapper,\n ...markdownToJsxOptions\n}: I18nProviderProps): JSX.Element => {\n return <I18nContext.Provider value={{ componentMapper, ...markdownToJsxOptions }}>{children}</I18nContext.Provider>;\n};\n","const extractTemplateVariables = /{{[^\\s{}]+}}/g;\nconst extractVarName = /{{ *([^ }]*) *}}/;\n\nexport const injectVariables = (markdown: string, variables?: Record<string, string | number>): string =>\n variables\n ? // @ts-expect-error lib config needs updating\n markdown.replaceAll(extractTemplateVariables, (match: string) => {\n const varName = match.replace(extractVarName, '$1');\n const replacementValue = variables[varName];\n\n if (replacementValue) {\n return replacementValue;\n }\n\n throw new Error(`Markdown contains un-replaced variable '${varName}'`);\n })\n : markdown;\n","import MarkdownToJsx, { type MarkdownToJSX } from 'markdown-to-jsx';\nimport { type JSX, useContext } from 'react';\nimport { I18nContext } from '#components/I18nProvider.tsx';\nimport { injectVariables } from '#helpers/injectVariables.ts';\n\nexport type MdProps = {\n // The markdown to convert into JSX.\n children: string;\n // An object of key/value pairs, with the key being the\n // name of the html tag that maps to supported markdown or\n // the name of a React component, and the value being a\n // React component. This prop is designed as an override\n // for the componentMapper passed into the I18nProvider.\n componentMapper?: MarkdownToJSX.Overrides;\n // An object of key/value pairs for content with template variables.\n variables?: Record<string, string | number>;\n} & Omit<MarkdownToJSX.Options, 'overrides'>;\n\nexport const Md = ({\n children,\n componentMapper: componentMapperOverrides,\n variables,\n ...markdownToJsxOptionOverrides\n}: MdProps): JSX.Element => {\n const { componentMapper, ...markdownToJsxOptions } = useContext(I18nContext);\n\n return (\n <MarkdownToJsx\n options={{\n overrides: { ...componentMapper, ...componentMapperOverrides },\n ...markdownToJsxOptions,\n ...markdownToJsxOptionOverrides,\n }}\n >\n {injectVariables(children, variables)}\n </MarkdownToJsx>\n );\n};\n"],"names":["I18nContext","createContext","componentMapper","I18nProvider","children","markdownToJsxOptions","_jsx","Provider","value","extractTemplateVariables","extractVarName","injectVariables","markdown","variables","replaceAll","match","varName","replace","replacementValue","Error","Md","componentMapperOverrides","markdownToJsxOptionOverrides","useContext","MarkdownToJsx","options","overrides"],"mappings":"6HAGO,MAAMA,EAAcC,EAIzB,CACAC,gBAAiB,CAAA,IAQNC,EAAe,EAC1BC,WACAF,qBACGG,KAEIC,EAACN,EAAYO,SAAQ,CAACC,MAAO,CAAEN,qBAAoBG,GAAyBD,SAAAA,ICrB/EK,EAA2B,gBAC3BC,EAAiB,mBAEVC,EAAkB,CAACC,EAAkBC,IAChDA,EAEID,EAASE,WAAWL,GAA2BM,IAC7C,MAAMC,EAAUD,EAAME,QAAQP,EAAgB,MACxCQ,EAAmBL,EAAUG,GAEnC,GAAIE,EACF,OAAOA,EAGT,MAAM,IAAIC,MAAM,2CAA2CH,SAE7DJ,ECEOQ,EAAK,EAChBhB,WACAF,gBAAiBmB,EACjBR,eACGS,MAEH,MAAMpB,gBAAEA,KAAoBG,GAAyBkB,EAAWvB,GAEhE,OACEM,EAACkB,EAAAA,CACCC,QAAS,CACPC,UAAW,IAAKxB,KAAoBmB,MACjChB,KACAiB,GAGJX,SAAAA,EAAgBP,EAAUS"}
|
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";const{NEXT_PUBLIC_LANGUAGE_CODE:o}=process.env,t=t=>{if(!t)throw new Error("md expected a path, but received none");let n=process.cwd(),{markdownDir:c}=(()=>{let
|
|
1
|
+
import{readFileSync as e}from"node:fs";import{resolve as r}from"node:path";const{NEXT_PUBLIC_LANGUAGE_CODE:o}=process.env,t=t=>{if(!t)throw new Error("md expected a path, but received none");let n=process.cwd(),{markdownDir:c}=(()=>{let o={};try{o=JSON.parse(e(r(process.cwd(),".i18n-macro.config.json"),{encoding:"utf8"}))}catch{}return o})();c&&(o&&(c=c.replaceAll("{{NEXT_PUBLIC_LANGUAGE_CODE}}",o)),n=r(n,c));const p=r(n,t);return e(p,{encoding:"utf8"}).trim()};export{t as md};
|
|
2
2
|
//# sourceMappingURL=macros.mjs.map
|
package/dist/esm/macros.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"macros.mjs","sources":["../i18n/src//constants.ts","../i18n/src//macros.ts","../i18n/src//helpers/loadConfig.ts"],"sourcesContent":["export const CONFIG_FILENAME = '.i18n-macro.config.json';\n","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","import { readFileSync } from 'node:fs';\nimport { CONFIG_FILENAME } from '#constants.ts';\nimport { type MacrosConfig } from '#types.ts';\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(CONFIG_FILENAME, { encoding: 'utf8' })) as Partial<MacrosConfig>;\n } catch {\n // no catch\n }\n\n return config;\n};\n"],"names":["NEXT_PUBLIC_LANGUAGE_CODE","process","env","md","path","Error","dir","cwd","markdownDir","config","JSON","parse","readFileSync","encoding","loadConfig","replaceAll","
|
|
1
|
+
{"version":3,"file":"macros.mjs","sources":["../i18n/src//constants.ts","../i18n/src//macros.ts","../i18n/src//helpers/loadConfig.ts"],"sourcesContent":["export const CONFIG_FILENAME = '.i18n-macro.config.json';\n","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","import { readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { CONFIG_FILENAME } from '#constants.ts';\nimport { type MacrosConfig } from '#types.ts';\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(\n readFileSync(resolve(process.cwd(), CONFIG_FILENAME), { encoding: 'utf8' }),\n ) as Partial<MacrosConfig>;\n } catch {\n // no catch\n }\n\n return config;\n};\n"],"names":["NEXT_PUBLIC_LANGUAGE_CODE","process","env","md","path","Error","dir","cwd","markdownDir","config","JSON","parse","readFileSync","resolve","encoding","loadConfig","replaceAll","fullPath","trim"],"mappings":"2EAAO,MCIDA,0BAAEA,GAA8BC,QAAQC,IAEjCC,EAAwBC,IACnC,IAAKA,EACH,MAAM,IAAIC,MAAM,yCAGlB,IAAIC,EAAML,QAAQM,OACdC,YAAEA,GCPkB,MACxB,IAAIC,EAAgC,CAAC,EAErC,IAGEA,EAASC,KAAKC,MACZC,EAAaC,EAAQZ,QAAQM,MFZJ,2BEY6B,CAAEO,SAAU,SAEtE,CAAE,MAEF,CAEA,OAAOL,GDNeM,GAElBP,IACER,IACFQ,EAAcA,EAAYQ,WAAW,gCAAiChB,IAGxEM,EAAMO,EAAQP,EAAKE,IAGrB,MAAMS,EAAWJ,EAAQP,EAAKF,GAK9B,OAAOQ,EAAaK,EAAU,CAAEH,SAAU,SAAUI"}
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
-----------------------------
|
|
2
2
|
Rollup File Analysis
|
|
3
3
|
-----------------------------
|
|
4
|
-
bundle size: 1.
|
|
5
|
-
original size: 1.
|
|
6
|
-
code reduction:
|
|
4
|
+
bundle size: 1.3 KB
|
|
5
|
+
original size: 1.601 KB
|
|
6
|
+
code reduction: 18.8 %
|
|
7
7
|
module count: 3
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
█████████████████████████████████░░░░░░░░░░░░░░░░░
|
|
10
10
|
file: /src/macros.ts
|
|
11
|
-
bundle space:
|
|
11
|
+
bundle space: 66.77 %
|
|
12
12
|
rendered size: 868 Bytes
|
|
13
13
|
original size: 952 Bytes
|
|
14
14
|
code reduction: 8.82 %
|
|
15
15
|
dependents: 0
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
██████████████░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
|
|
18
18
|
file: /src/helpers/loadConfig.ts
|
|
19
|
-
bundle space:
|
|
20
|
-
rendered size:
|
|
21
|
-
original size:
|
|
22
|
-
code reduction:
|
|
19
|
+
bundle space: 29.38 %
|
|
20
|
+
rendered size: 382 Bytes
|
|
21
|
+
original size: 591 Bytes
|
|
22
|
+
code reduction: 35.36 %
|
|
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.85 %
|
|
29
29
|
rendered size: 50 Bytes
|
|
30
30
|
original size: 58 Bytes
|
|
31
31
|
code reduction: 13.79 %
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { type
|
|
3
|
-
import { type ComponentMapper } from '#types.cts';
|
|
1
|
+
import { type MarkdownToJSX } from 'markdown-to-jsx';
|
|
2
|
+
import { type JSX, type ReactNode } from 'react';
|
|
4
3
|
export declare const I18nContext: import("react").Context<{
|
|
5
|
-
componentMapper:
|
|
4
|
+
componentMapper: MarkdownToJSX.Overrides;
|
|
6
5
|
} & Omit<Partial<{
|
|
7
|
-
createElement: (tag: Parameters<
|
|
6
|
+
createElement: (tag: Parameters<MarkdownToJSX.CreateElement>[0], props: JSX.IntrinsicAttributes, ...children: ReactNode[]) => ReactNode;
|
|
8
7
|
disableAutoLink: boolean;
|
|
9
8
|
disableParsingRawHTML: boolean;
|
|
10
9
|
enforceAtxHeadings: boolean;
|
|
@@ -14,15 +13,15 @@ export declare const I18nContext: import("react").Context<{
|
|
|
14
13
|
namedCodesToUnicode: {
|
|
15
14
|
[key: string]: string;
|
|
16
15
|
};
|
|
17
|
-
overrides:
|
|
18
|
-
renderRule: (next: () => ReactNode, node:
|
|
19
|
-
sanitizer: (value: string, tag:
|
|
16
|
+
overrides: MarkdownToJSX.Overrides;
|
|
17
|
+
renderRule: (next: () => ReactNode, node: MarkdownToJSX.ParserResult, renderChildren: MarkdownToJSX.RuleOutput, state: MarkdownToJSX.State) => ReactNode;
|
|
18
|
+
sanitizer: (value: string, tag: MarkdownToJSX.HTMLTags, attribute: string) => string | null;
|
|
20
19
|
slugify: (input: string, defaultFn: (input: string) => string) => string;
|
|
21
20
|
wrapper: import("react").ElementType | null;
|
|
22
|
-
}
|
|
21
|
+
}>, "overrides">>;
|
|
23
22
|
export type I18nProviderProps = {
|
|
24
23
|
children: ReactNode;
|
|
25
|
-
componentMapper:
|
|
26
|
-
} & Omit<
|
|
24
|
+
componentMapper: MarkdownToJSX.Overrides;
|
|
25
|
+
} & Omit<MarkdownToJSX.Options, 'overrides'>;
|
|
27
26
|
export declare const I18nProvider: ({ children, componentMapper, ...markdownToJsxOptions }: I18nProviderProps) => JSX.Element;
|
|
28
27
|
//# sourceMappingURL=I18nProvider.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18nProvider.d.cts","sourceRoot":"","sources":["../../../../src/components/I18nProvider.ctsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"I18nProvider.d.cts","sourceRoot":"","sources":["../../../../src/components/I18nProvider.ctsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,SAAS,EAAiB,MAAM,OAAO,CAAC;AAEhE,eAAO,MAAM,WAAW;qBAEH,aAAa,CAAC,SAAS;;qGAkBmsT,GAAI;;;;;;;;;;;;;;;iBAdjvT,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,2DAItB,iBAAiB,KAAG,GAAG,CAAC,OAE1B,CAAC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { type
|
|
3
|
-
import { type ComponentMapper } from '#types.cts';
|
|
1
|
+
import { type MarkdownToJSX } from 'markdown-to-jsx';
|
|
2
|
+
import { type JSX } from 'react';
|
|
4
3
|
export type MdProps = {
|
|
5
4
|
children: string;
|
|
6
|
-
componentMapper?:
|
|
5
|
+
componentMapper?: MarkdownToJSX.Overrides;
|
|
7
6
|
variables?: Record<string, string | number>;
|
|
8
|
-
} & Omit<
|
|
7
|
+
} & Omit<MarkdownToJSX.Options, 'overrides'>;
|
|
9
8
|
export declare const Md: ({ children, componentMapper: componentMapperOverrides, variables, ...markdownToJsxOptionOverrides }: MdProps) => JSX.Element;
|
|
10
9
|
//# sourceMappingURL=Md.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Md.d.cts","sourceRoot":"","sources":["../../../../src/components/Md.ctsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"Md.d.cts","sourceRoot":"","sources":["../../../../src/components/Md.ctsx"],"names":[],"mappings":"AAAA,OAAsB,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,KAAK,GAAG,EAAc,MAAM,OAAO,CAAC;AAI7C,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,wGAKZ,OAAO,KAAG,GAAG,CAAC,OAchB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadConfig.d.cts","sourceRoot":"","sources":["../../../../src/helpers/loadConfig.cts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loadConfig.d.cts","sourceRoot":"","sources":["../../../../src/helpers/loadConfig.cts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C,eAAO,MAAM,UAAU,QAAO,OAAO,CAAC,YAAY,CAcjD,CAAC"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { type ComponentType } from 'react';
|
|
2
1
|
import { type AnyRecord, type ConfigReader } from 'zcb';
|
|
3
|
-
export type ComponentMapper = Record<string, ComponentType<any>>;
|
|
4
2
|
export type CreateI18nResult<U extends object> = {
|
|
5
3
|
t: (key: string, variables?: AnyRecord) => string | undefined;
|
|
6
4
|
tt: ConfigReader<U>['read'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../src/types.cts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.cts","sourceRoot":"","sources":["../../../src/types.cts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,KAAK,CAAC;AAExD,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,MAAM,IAAI;IAI/C,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS,KAAK,MAAM,GAAG,SAAS,CAAC;IAM9D,EAAE,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IAMzB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { type
|
|
3
|
-
import { type ComponentMapper } from '#types.ts';
|
|
1
|
+
import { type MarkdownToJSX } from 'markdown-to-jsx';
|
|
2
|
+
import { type JSX, type ReactNode } from 'react';
|
|
4
3
|
export declare const I18nContext: import("react").Context<{
|
|
5
|
-
componentMapper:
|
|
4
|
+
componentMapper: MarkdownToJSX.Overrides;
|
|
6
5
|
} & Omit<Partial<{
|
|
7
|
-
createElement: (tag: Parameters<
|
|
6
|
+
createElement: (tag: Parameters<MarkdownToJSX.CreateElement>[0], props: JSX.IntrinsicAttributes, ...children: ReactNode[]) => ReactNode;
|
|
8
7
|
disableAutoLink: boolean;
|
|
9
8
|
disableParsingRawHTML: boolean;
|
|
10
9
|
enforceAtxHeadings: boolean;
|
|
@@ -14,15 +13,15 @@ export declare const I18nContext: import("react").Context<{
|
|
|
14
13
|
namedCodesToUnicode: {
|
|
15
14
|
[key: string]: string;
|
|
16
15
|
};
|
|
17
|
-
overrides:
|
|
18
|
-
renderRule: (next: () => ReactNode, node:
|
|
19
|
-
sanitizer: (value: string, tag:
|
|
16
|
+
overrides: MarkdownToJSX.Overrides;
|
|
17
|
+
renderRule: (next: () => ReactNode, node: MarkdownToJSX.ParserResult, renderChildren: MarkdownToJSX.RuleOutput, state: MarkdownToJSX.State) => ReactNode;
|
|
18
|
+
sanitizer: (value: string, tag: MarkdownToJSX.HTMLTags, attribute: string) => string | null;
|
|
20
19
|
slugify: (input: string, defaultFn: (input: string) => string) => string;
|
|
21
20
|
wrapper: import("react").ElementType | null;
|
|
22
|
-
}
|
|
21
|
+
}>, "overrides">>;
|
|
23
22
|
export type I18nProviderProps = {
|
|
24
23
|
children: ReactNode;
|
|
25
|
-
componentMapper:
|
|
26
|
-
} & Omit<
|
|
24
|
+
componentMapper: MarkdownToJSX.Overrides;
|
|
25
|
+
} & Omit<MarkdownToJSX.Options, 'overrides'>;
|
|
27
26
|
export declare const I18nProvider: ({ children, componentMapper, ...markdownToJsxOptions }: I18nProviderProps) => JSX.Element;
|
|
28
27
|
//# sourceMappingURL=I18nProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18nProvider.d.ts","sourceRoot":"","sources":["../../../../src/components/I18nProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,aAAa,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"I18nProvider.d.ts","sourceRoot":"","sources":["../../../../src/components/I18nProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,SAAS,EAAiB,MAAM,OAAO,CAAC;AAEhE,eAAO,MAAM,WAAW;qBAEH,aAAa,CAAC,SAAS;;qGAkBmsT,GAAI;;;;;;;;;;;;;;;iBAdjvT,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,2DAItB,iBAAiB,KAAG,GAAG,CAAC,OAE1B,CAAC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { type
|
|
3
|
-
import { type ComponentMapper } from '#types.ts';
|
|
1
|
+
import { type MarkdownToJSX } from 'markdown-to-jsx';
|
|
2
|
+
import { type JSX } from 'react';
|
|
4
3
|
export type MdProps = {
|
|
5
4
|
children: string;
|
|
6
|
-
componentMapper?:
|
|
5
|
+
componentMapper?: MarkdownToJSX.Overrides;
|
|
7
6
|
variables?: Record<string, string | number>;
|
|
8
|
-
} & Omit<
|
|
7
|
+
} & Omit<MarkdownToJSX.Options, 'overrides'>;
|
|
9
8
|
export declare const Md: ({ children, componentMapper: componentMapperOverrides, variables, ...markdownToJsxOptionOverrides }: MdProps) => JSX.Element;
|
|
10
9
|
//# sourceMappingURL=Md.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Md.d.ts","sourceRoot":"","sources":["../../../../src/components/Md.tsx"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"Md.d.ts","sourceRoot":"","sources":["../../../../src/components/Md.tsx"],"names":[],"mappings":"AAAA,OAAsB,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAE,KAAK,GAAG,EAAc,MAAM,OAAO,CAAC;AAI7C,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,wGAKZ,OAAO,KAAG,GAAG,CAAC,OAchB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadConfig.d.ts","sourceRoot":"","sources":["../../../../src/helpers/loadConfig.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"loadConfig.d.ts","sourceRoot":"","sources":["../../../../src/helpers/loadConfig.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C,eAAO,MAAM,UAAU,QAAO,OAAO,CAAC,YAAY,CAcjD,CAAC"}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import { type ComponentType } from 'react';
|
|
2
1
|
import { type AnyRecord, type ConfigReader } from 'zcb';
|
|
3
|
-
export type ComponentMapper = Record<string, ComponentType<any>>;
|
|
4
2
|
export type CreateI18nResult<U extends object> = {
|
|
5
3
|
t: (key: string, variables?: AnyRecord) => string | undefined;
|
|
6
4
|
tt: ConfigReader<U>['read'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,KAAK,CAAC;AAExD,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,MAAM,IAAI;IAI/C,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,SAAS,KAAK,MAAM,GAAG,SAAS,CAAC;IAM9D,EAAE,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IAMzB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC"}
|