@next-box/i18n 0.0.4 → 0.0.6

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
@@ -150,7 +150,7 @@ import { md } from '@next-box/i18n/macros' with { type: 'macro' }; // This is im
150
150
 
151
151
  const content = {
152
152
  en: {
153
- contactUs: md('./src/markdown/contactUs.md'),
153
+ contactUs: md('./markdown/contactUs.md'), // relative to the file's directory
154
154
  },
155
155
  } as const;
156
156
  ```
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("react/jsx-runtime"),r=require("react"),t=require("markdown-to-jsx"),n=require("zcb");const o=r.createContext({componentMapper:{}}),a=/{{[^\s{}]+}}/g,c=/{{ *([^ }]*) *}}/,p=(e,r)=>r?e.replaceAll(a,(e=>{const t=e.replace(c,"$1"),n=r[t];if(n)return n;throw new Error(`Markdown contains un-replaced variable '${t}'`)})):e;exports.I18nContext=o,exports.I18nProvider=({children:r,componentMapper:t,...n})=>e.jsx(o.Provider,{value:{componentMapper:t,...n},children:r}),exports.Md=({children:n,componentMapper:a,variables:c,...i})=>{const{componentMapper:s,...d}=r.useContext(o);return e.jsx(t,{options:{overrides:{...s,...a},...d,...i},children:p(n,c)})},exports.createI18n=e=>{const r=n.createConfigReader(e);return{t:(e,t)=>r.read(e,t),tt:(e,t)=>{const n=r.read(e,t);if(!n)throw new Error(`Path "${String(e)}" did not resolve to a value`);return n}}};
1
+ "use strict";var r=require("zcb");exports.createI18n=e=>{const t=r.createConfigReader(e);return{t:(r,e)=>t.read(r,e),tt:(r,e)=>{const a=t.read(r,e);if(!a)throw new Error(`Path "${String(r)}" did not resolve to a value`);return a}}};
2
2
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../i18n/src//components/I18nProvider.tsx","../i18n/src//helpers/injectVariables.ts","../i18n/src//components/Md.tsx","../i18n/src//main.ts"],"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","import { 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) => {\n const result = reader.read(path, variables);\n\n // This can resolve to a falsy value at runtime\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!result) {\n throw new Error(`Path \"${String(path)}\" did not resolve to a value`);\n }\n\n return result;\n },\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","i18n","reader","createConfigReader","t","key","read","tt","path","result","String"],"mappings":"iHAIO,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,yBChCYmB,IAC3C,MAAMC,EAASC,EAAsBF,mBAAAA,GAErC,MAAO,CAGLG,EAAG,CAACC,EAAavB,IAA8CoB,EAAOI,KAAKD,EAAKvB,GAChFyB,GAAI,CAAoBC,EAAS1B,KAC/B,MAAM2B,EAASP,EAAOI,KAAKE,EAAM1B,GAIjC,IAAK2B,EACH,MAAM,IAAIrB,MAAM,SAASsB,OAAOF,kCAGlC,OAAOC"}
1
+ {"version":3,"file":"index.cjs","sources":["../i18n/src//main.ts"],"sourcesContent":["import { 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) => {\n const result = reader.read(path, variables);\n\n // This can resolve to a falsy value at runtime\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!result) {\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","Error","String"],"mappings":"qDAG6CA,IAC3C,MAAMC,EAASC,EAAsBF,mBAAAA,GAErC,MAAO,CAGLG,EAAG,CAACC,EAAaC,IAA8CJ,EAAOK,KAAKF,EAAKC,GAChFE,GAAI,CAAoBC,EAASH,KAC/B,MAAMI,EAASR,EAAOK,KAAKE,EAAMH,GAIjC,IAAKI,EACH,MAAM,IAAIC,MAAM,SAASC,OAAOH,kCAGlC,OAAOC"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("node:fs"),r=require("node:path");exports.md=t=>{if(!t)throw new Error("Tagged template expected a path, but received none");const n=r.resolve(process.cwd(),t);return e.readFileSync(n,{encoding:"utf8"}).trim()};
1
+ "use strict";var e=require("node:fs"),r=require("node:path"),n=require("node:url"),t="undefined"!=typeof document?document.currentScript:null;const o=r.dirname(n.fileURLToPath("undefined"==typeof document?require("url").pathToFileURL(__filename).href:t&&"SCRIPT"===t.tagName.toUpperCase()&&t.src||new URL("macros.cjs",document.baseURI).href));exports.md=n=>{if(!n)throw new Error("md expected a path, but received none");const t=r.resolve(o,n);return e.readFileSync(t,{encoding:"utf8"}).trim()};
2
2
  //# sourceMappingURL=macros.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"macros.cjs","sources":["../i18n/src//macros.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\n\nexport const md = <P extends string>(path: P): P => {\n if (!path) {\n throw new Error('Tagged template expected a path, but received none');\n }\n\n const fullPath = resolve(process.cwd(), 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":["path","Error","fullPath","resolve","process","cwd","readFileSync","encoding","trim"],"mappings":"wEAGqCA,IACnC,IAAKA,EACH,MAAM,IAAIC,MAAM,sDAGlB,MAAMC,EAAWC,EAAAA,QAAQC,QAAQC,MAAOL,GAKxC,OAAOM,EAAAA,aAAaJ,EAAU,CAAEK,SAAU,SAAUC"}
1
+ {"version":3,"file":"macros.cjs","sources":["../i18n/src//macros.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst dir = dirname(fileURLToPath(import.meta.url));\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 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":["dir","dirname","fileURLToPath","document","require","pathToFileURL","__filename","href","_documentCurrentScript","tagName","toUpperCase","src","URL","baseURI","path","Error","fullPath","resolve","readFileSync","encoding","trim"],"mappings":"8IAIA,MAAMA,EAAMC,EAAAA,QAAQC,gBAAc,oBAAAC,SAAAC,QAAA,OAAAC,cAAAC,YAAAC,KAAAC,GAAA,WAAAA,EAAAC,QAAAC,eAAAF,EAAAG,KAAA,IAAAC,IAAA,aAAAT,SAAAU,SAAAN,kBAEGO,IACnC,IAAKA,EACH,MAAM,IAAIC,MAAM,yCAGlB,MAAMC,EAAWC,EAAAA,QAAQjB,EAAKc,GAK9B,OAAOI,EAAAA,aAAaF,EAAU,CAAEG,SAAU,SAAUC"}
@@ -1,2 +1,2 @@
1
- import{jsx as r}from"react/jsx-runtime";import{createContext as e,useContext as o}from"react";import n from"markdown-to-jsx";import{createConfigReader as t}from"zcb";const p=e({componentMapper:{}}),a=({children:e,componentMapper:o,...n})=>r(p.Provider,{value:{componentMapper:o,...n},children:e}),c=/{{[^\s{}]+}}/g,i=/{{ *([^ }]*) *}}/,m=(r,e)=>e?r.replaceAll(c,(r=>{const o=r.replace(i,"$1"),n=e[o];if(n)return n;throw new Error(`Markdown contains un-replaced variable '${o}'`)})):r,l=({children:e,componentMapper:t,variables:a,...c})=>{const{componentMapper:i,...l}=o(p);return r(n,{options:{overrides:{...i,...t},...l,...c},children:m(e,a)})},d=r=>{const e=t(r);return{t:(r,o)=>e.read(r,o),tt:(r,o)=>{const n=e.read(r,o);if(!n)throw new Error(`Path "${String(r)}" did not resolve to a value`);return n}}};export{p as I18nContext,a as I18nProvider,l as Md,d as createI18n};
1
+ import{createConfigReader as r}from"zcb";const t=t=>{const o=r(t);return{t:(r,t)=>o.read(r,t),tt:(r,t)=>{const e=o.read(r,t);if(!e)throw new Error(`Path "${String(r)}" did not resolve to a value`);return e}}};export{t as createI18n};
2
2
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../i18n/src//components/I18nProvider.tsx","../i18n/src//helpers/injectVariables.ts","../i18n/src//components/Md.tsx","../i18n/src//main.ts"],"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","import { 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) => {\n const result = reader.read(path, variables);\n\n // This can resolve to a falsy value at runtime\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!result) {\n throw new Error(`Path \"${String(path)}\" did not resolve to a value`);\n }\n\n return result;\n },\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","createI18n","i18n","reader","createConfigReader","t","key","read","tt","path","result","String"],"mappings":"sKAIO,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,MChCpBc,EAAgCC,IAC3C,MAAMC,EAASC,EAAsBF,GAErC,MAAO,CAGLG,EAAG,CAACC,EAAanB,IAA8CgB,EAAOI,KAAKD,EAAKnB,GAChFqB,GAAI,CAAoBC,EAAStB,KAC/B,MAAMuB,EAASP,EAAOI,KAAKE,EAAMtB,GAIjC,IAAKuB,EACH,MAAM,IAAIjB,MAAM,SAASkB,OAAOF,kCAGlC,OAAOC"}
1
+ {"version":3,"file":"index.mjs","sources":["../i18n/src//main.ts"],"sourcesContent":["import { 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) => {\n const result = reader.read(path, variables);\n\n // This can resolve to a falsy value at runtime\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (!result) {\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","Error","String"],"mappings":"yCAGO,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,GAIjC,IAAKI,EACH,MAAM,IAAIC,MAAM,SAASC,OAAOH,kCAGlC,OAAOC"}
@@ -1,2 +1,2 @@
1
- import{readFileSync as e}from"node:fs";import{resolve as t}from"node:path";const o=o=>{if(!o)throw new Error("Tagged template expected a path, but received none");const r=t(process.cwd(),o);return e(r,{encoding:"utf8"}).trim()};export{o as md};
1
+ import{readFileSync as r}from"node:fs";import{dirname as o,resolve as t}from"node:path";import{fileURLToPath as e}from"node:url";const n=o(e(import.meta.url)),m=o=>{if(!o)throw new Error("md expected a path, but received none");const e=t(n,o);return r(e,{encoding:"utf8"}).trim()};export{m as md};
2
2
  //# sourceMappingURL=macros.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"macros.mjs","sources":["../i18n/src//macros.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\n\nexport const md = <P extends string>(path: P): P => {\n if (!path) {\n throw new Error('Tagged template expected a path, but received none');\n }\n\n const fullPath = resolve(process.cwd(), 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":["md","path","Error","fullPath","resolve","process","cwd","readFileSync","encoding","trim"],"mappings":"2EAGO,MAAMA,EAAwBC,IACnC,IAAKA,EACH,MAAM,IAAIC,MAAM,sDAGlB,MAAMC,EAAWC,EAAQC,QAAQC,MAAOL,GAKxC,OAAOM,EAAaJ,EAAU,CAAEK,SAAU,SAAUC"}
1
+ {"version":3,"file":"macros.mjs","sources":["../i18n/src//macros.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\n\nconst dir = dirname(fileURLToPath(import.meta.url));\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 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":["dir","dirname","fileURLToPath","url","md","path","Error","fullPath","resolve","readFileSync","encoding","trim"],"mappings":"iIAIA,MAAMA,EAAMC,EAAQC,cAA0BC,MAEjCC,EAAwBC,IACnC,IAAKA,EACH,MAAM,IAAIC,MAAM,yCAGlB,MAAMC,EAAWC,EAAQR,EAAKK,GAK9B,OAAOI,EAAaF,EAAU,CAAEG,SAAU,SAAUC"}
@@ -1,16 +1,16 @@
1
1
  -----------------------------
2
2
  Rollup File Analysis
3
3
  -----------------------------
4
- bundle size: 530 Bytes
5
- original size: 593 Bytes
6
- code reduction: 10.62 %
4
+ bundle size: 542 Bytes
5
+ original size: 675 Bytes
6
+ code reduction: 19.7 %
7
7
  module count: 1
8
8
 
9
9
  ██████████████████████████████████████████████████
10
10
  file: /src/macros.ts
11
11
  bundle space: 100 %
12
- rendered size: 530 Bytes
13
- original size: 593 Bytes
14
- code reduction: 10.62 %
12
+ rendered size: 542 Bytes
13
+ original size: 675 Bytes
14
+ code reduction: 19.7 %
15
15
  dependents: 0
16
16
 
@@ -1,5 +1,3 @@
1
- export * from './components/I18nProvider.ctsx';
2
- export * from './components/Md.ctsx';
3
1
  export * from './main.cts';
4
2
  export * from './types.cts';
5
3
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/index.cts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../../../src/index.cts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"macros.d.cts","sourceRoot":"","sources":["../../../src/macros.cts"],"names":[],"mappings":"AAGA,eAAO,MAAM,EAAE,GAAI,CAAC,SAAS,MAAM,QAAQ,CAAC,KAAG,CAW9C,CAAC"}
1
+ {"version":3,"file":"macros.d.cts","sourceRoot":"","sources":["../../../src/macros.cts"],"names":[],"mappings":"AAMA,eAAO,MAAM,EAAE,GAAI,CAAC,SAAS,MAAM,QAAQ,CAAC,KAAG,CAW9C,CAAC"}
@@ -1,5 +1,3 @@
1
- export * from './components/I18nProvider.tsx';
2
- export * from './components/Md.tsx';
3
1
  export * from './main.ts';
4
2
  export * from './types.ts';
5
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAC9C,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"macros.d.ts","sourceRoot":"","sources":["../../../src/macros.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,EAAE,GAAI,CAAC,SAAS,MAAM,QAAQ,CAAC,KAAG,CAW9C,CAAC"}
1
+ {"version":3,"file":"macros.d.ts","sourceRoot":"","sources":["../../../src/macros.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,EAAE,GAAI,CAAC,SAAS,MAAM,QAAQ,CAAC,KAAG,CAW9C,CAAC"}