@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 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
 
@@ -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 MarkdownToJsx from 'markdown-to-jsx';\nimport { type ComponentProps, type JSX, type ReactNode, createContext } from 'react';\nimport { type ComponentMapper } from '#types.ts';\n\nexport const I18nContext = createContext<\n {\n componentMapper: ComponentMapper;\n } & Omit<ComponentProps<typeof MarkdownToJsx>['options'], 'overrides'>\n>({\n componentMapper: {},\n});\n\nexport type I18nProviderProps = {\n children: ReactNode;\n componentMapper: ComponentMapper;\n} & Omit<ComponentProps<typeof 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 from 'markdown-to-jsx';\nimport { type ComponentProps, type JSX, useContext } from 'react';\nimport { I18nContext } from '#components/I18nProvider.tsx';\nimport { injectVariables } from '#helpers/injectVariables.ts';\nimport { type ComponentMapper } from '#types.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?: ComponentMapper;\n // An object of key/value pairs for content with template variables.\n variables?: Record<string, string | number>;\n} & Omit<ComponentProps<typeof 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":"gGAIO,MAAMA,EAAcC,EAAAA,cAIzB,CACAC,gBAAiB,CAAA,ICTbC,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,6CDCsB,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"}
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"}
@@ -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=t=>{if(!t)throw new Error("md expected a path, but received none");let o=process.cwd(),{markdownDir:c}=(()=>{let r={};try{r=JSON.parse(e.readFileSync(".i18n-macro.config.json",{encoding:"utf8"}))}catch{}return r})();c&&(n&&(c=c.replaceAll("{{NEXT_PUBLIC_LANGUAGE_CODE}}",n)),o=r.resolve(o,c));const s=r.resolve(o,t);return e.readFileSync(s,{encoding:"utf8"}).trim()};
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
@@ -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","resolve","fullPath","trim"],"mappings":"6DAAO,MCIDA,0BAAEA,GAA8BC,QAAQC,eAETC,IACnC,IAAKA,EACH,MAAM,IAAIC,MAAM,yCAGlB,IAAIC,EAAMJ,QAAQK,OACdC,YAAEA,GCRkB,MACxB,IAAIC,EAAgC,CAAC,EAErC,IAGEA,EAASC,KAAKC,MAAMC,EAAAA,aFVO,0BEUuB,CAAEC,SAAU,SAChE,CAAE,MAEF,CAEA,OAAOJ,GDHeK,GAElBN,IACEP,IACFO,EAAcA,EAAYO,WAAW,gCAAiCd,IAGxEK,EAAMU,EAAAA,QAAQV,EAAKE,IAGrB,MAAMS,EAAWD,EAAAA,QAAQV,EAAKF,GAK9B,OAAOQ,EAAAA,aAAaK,EAAU,CAAEJ,SAAU,SAAUK"}
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"}
@@ -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 MarkdownToJsx from 'markdown-to-jsx';\nimport { type ComponentProps, type JSX, type ReactNode, createContext } from 'react';\nimport { type ComponentMapper } from '#types.ts';\n\nexport const I18nContext = createContext<\n {\n componentMapper: ComponentMapper;\n } & Omit<ComponentProps<typeof MarkdownToJsx>['options'], 'overrides'>\n>({\n componentMapper: {},\n});\n\nexport type I18nProviderProps = {\n children: ReactNode;\n componentMapper: ComponentMapper;\n} & Omit<ComponentProps<typeof 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 from 'markdown-to-jsx';\nimport { type ComponentProps, type JSX, useContext } from 'react';\nimport { I18nContext } from '#components/I18nProvider.tsx';\nimport { injectVariables } from '#helpers/injectVariables.ts';\nimport { type ComponentMapper } from '#types.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?: ComponentMapper;\n // An object of key/value pairs for content with template variables.\n variables?: Record<string, string | number>;\n} & Omit<ComponentProps<typeof 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":"6HAIO,MAAMA,EAAcC,EAIzB,CACAC,gBAAiB,CAAA,IAQNC,EAAe,EAC1BC,WACAF,qBACGG,KAEIC,EAACN,EAAYO,SAAQ,CAACC,MAAO,CAAEN,qBAAoBG,GAAyBD,SAAAA,ICtB/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,ECGOQ,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"}
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"}
@@ -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 r={};try{r=JSON.parse(e(".i18n-macro.config.json",{encoding:"utf8"}))}catch{}return r})();c&&(o&&(c=c.replaceAll("{{NEXT_PUBLIC_LANGUAGE_CODE}}",o)),n=r(n,c));const i=r(n,t);return e(i,{encoding:"utf8"}).trim()};export{t as md};
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
@@ -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","resolve","fullPath","trim"],"mappings":"2EAAO,MCIDA,0BAAEA,GAA8BC,QAAQC,IAEjCC,EAAwBC,IACnC,IAAKA,EACH,MAAM,IAAIC,MAAM,yCAGlB,IAAIC,EAAML,QAAQM,OACdC,YAAEA,GCRkB,MACxB,IAAIC,EAAgC,CAAC,EAErC,IAGEA,EAASC,KAAKC,MAAMC,EFVO,0BEUuB,CAAEC,SAAU,SAChE,CAAE,MAEF,CAEA,OAAOJ,GDHeK,GAElBN,IACER,IACFQ,EAAcA,EAAYO,WAAW,gCAAiCf,IAGxEM,EAAMU,EAAQV,EAAKE,IAGrB,MAAMS,EAAWD,EAAQV,EAAKF,GAK9B,OAAOQ,EAAaK,EAAU,CAAEJ,SAAU,SAAUK"}
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.266 KB
5
- original size: 1.527 KB
6
- code reduction: 17.09 %
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: 68.56 %
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: 27.49 %
20
- rendered size: 348 Bytes
21
- original size: 517 Bytes
22
- code reduction: 32.69 %
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.95 %
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 MarkdownToJsx from 'markdown-to-jsx';
2
- import { type ComponentProps, type JSX, type ReactNode } from 'react';
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: ComponentMapper;
4
+ componentMapper: MarkdownToJSX.Overrides;
6
5
  } & Omit<Partial<{
7
- createElement: (tag: Parameters<import("markdown-to-jsx").MarkdownToJSX.CreateElement>[0], props: JSX.IntrinsicAttributes, ...children: ReactNode[]) => ReactNode;
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: import("markdown-to-jsx").MarkdownToJSX.Overrides;
18
- renderRule: (next: () => ReactNode, node: import("markdown-to-jsx").MarkdownToJSX.ParserResult, renderChildren: import("markdown-to-jsx").MarkdownToJSX.RuleOutput, state: import("markdown-to-jsx").MarkdownToJSX.State) => ReactNode;
19
- sanitizer: (value: string, tag: import("markdown-to-jsx").MarkdownToJSX.HTMLTags, attribute: string) => string | null;
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
- }> | undefined, "overrides">>;
21
+ }>, "overrides">>;
23
22
  export type I18nProviderProps = {
24
23
  children: ReactNode;
25
- componentMapper: ComponentMapper;
26
- } & Omit<ComponentProps<typeof MarkdownToJsx>['options'], 'overrides'>;
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;AACjD,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,GAAG,EAAE,KAAK,SAAS,EAAiB,MAAM,OAAO,CAAC;AACrF,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,eAAO,MAAM,WAAW;qBAEH,eAAe;;+HAkBomT,GAAI;;;;;;;;;;;;;;;6BAd1oT,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,SAAS,CAAC;IACpB,eAAe,EAAE,eAAe,CAAC;CAClC,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,CAAC,SAAS,CAAC,EAAE,WAAW,CAAC,CAAC;AAEvE,eAAO,MAAM,YAAY,2DAItB,iBAAiB,KAAG,GAAG,CAAC,OAE1B,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 MarkdownToJsx from 'markdown-to-jsx';
2
- import { type ComponentProps, type JSX } from 'react';
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?: ComponentMapper;
5
+ componentMapper?: MarkdownToJSX.Overrides;
7
6
  variables?: Record<string, string | number>;
8
- } & Omit<ComponentProps<typeof MarkdownToJsx>['options'], 'overrides'>;
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,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,GAAG,EAAc,MAAM,OAAO,CAAC;AAGlE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,MAAM,MAAM,OAAO,GAAG;IAEpB,QAAQ,EAAE,MAAM,CAAC;IAMjB,eAAe,CAAC,EAAE,eAAe,CAAC;IAElC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CAC7C,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,CAAC,SAAS,CAAC,EAAE,WAAW,CAAC,CAAC;AAEvE,eAAO,MAAM,EAAE,wGAKZ,OAAO,KAAG,GAAG,CAAC,OAchB,CAAC"}
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":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C,eAAO,MAAM,UAAU,QAAO,OAAO,CAAC,YAAY,CAYjD,CAAC"}
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,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,KAAK,CAAC;AAIxD,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;AAEjE,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
+ {"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 MarkdownToJsx from 'markdown-to-jsx';
2
- import { type ComponentProps, type JSX, type ReactNode } from 'react';
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: ComponentMapper;
4
+ componentMapper: MarkdownToJSX.Overrides;
6
5
  } & Omit<Partial<{
7
- createElement: (tag: Parameters<import("markdown-to-jsx").MarkdownToJSX.CreateElement>[0], props: JSX.IntrinsicAttributes, ...children: ReactNode[]) => ReactNode;
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: import("markdown-to-jsx").MarkdownToJSX.Overrides;
18
- renderRule: (next: () => ReactNode, node: import("markdown-to-jsx").MarkdownToJSX.ParserResult, renderChildren: import("markdown-to-jsx").MarkdownToJSX.RuleOutput, state: import("markdown-to-jsx").MarkdownToJSX.State) => ReactNode;
19
- sanitizer: (value: string, tag: import("markdown-to-jsx").MarkdownToJSX.HTMLTags, attribute: string) => string | null;
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
- }> | undefined, "overrides">>;
21
+ }>, "overrides">>;
23
22
  export type I18nProviderProps = {
24
23
  children: ReactNode;
25
- componentMapper: ComponentMapper;
26
- } & Omit<ComponentProps<typeof MarkdownToJsx>['options'], 'overrides'>;
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;AACjD,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,GAAG,EAAE,KAAK,SAAS,EAAiB,MAAM,OAAO,CAAC;AACrF,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,eAAO,MAAM,WAAW;qBAEH,eAAe;;+HAkBomT,GAAI;;;;;;;;;;;;;;;6BAd1oT,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,SAAS,CAAC;IACpB,eAAe,EAAE,eAAe,CAAC;CAClC,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,CAAC,SAAS,CAAC,EAAE,WAAW,CAAC,CAAC;AAEvE,eAAO,MAAM,YAAY,2DAItB,iBAAiB,KAAG,GAAG,CAAC,OAE1B,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 MarkdownToJsx from 'markdown-to-jsx';
2
- import { type ComponentProps, type JSX } from 'react';
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?: ComponentMapper;
5
+ componentMapper?: MarkdownToJSX.Overrides;
7
6
  variables?: Record<string, string | number>;
8
- } & Omit<ComponentProps<typeof MarkdownToJsx>['options'], 'overrides'>;
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,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,KAAK,cAAc,EAAE,KAAK,GAAG,EAAc,MAAM,OAAO,CAAC;AAGlE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAEjD,MAAM,MAAM,OAAO,GAAG;IAEpB,QAAQ,EAAE,MAAM,CAAC;IAMjB,eAAe,CAAC,EAAE,eAAe,CAAC;IAElC,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CAC7C,GAAG,IAAI,CAAC,cAAc,CAAC,OAAO,aAAa,CAAC,CAAC,SAAS,CAAC,EAAE,WAAW,CAAC,CAAC;AAEvE,eAAO,MAAM,EAAE,wGAKZ,OAAO,KAAG,GAAG,CAAC,OAchB,CAAC"}
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":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAE9C,eAAO,MAAM,UAAU,QAAO,OAAO,CAAC,YAAY,CAYjD,CAAC"}
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,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,MAAM,KAAK,CAAC;AAIxD,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;AAEjE,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
+ {"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"}