@next-box/i18n 0.0.13 → 0.1.1
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 +44 -29
- package/dist/cjs/client.cjs +1 -1
- package/dist/cjs/client.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/macros.cjs +1 -1
- package/dist/cjs/macros.cjs.map +1 -1
- package/dist/esm/client.mjs +1 -1
- package/dist/esm/client.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/index.mjs.map +1 -1
- package/dist/esm/macros.mjs +1 -1
- package/dist/esm/macros.mjs.map +1 -1
- package/dist/production.analysis.txt +13 -13
- package/dist/types/cjs/components/I18nProvider.d.cts +12 -8
- package/dist/types/cjs/components/I18nProvider.d.cts.map +1 -1
- package/dist/types/cjs/components/Md.d.cts +2 -2
- 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/main.d.cts.map +1 -1
- package/dist/types/esm/components/I18nProvider.d.ts +12 -8
- package/dist/types/esm/components/I18nProvider.d.ts.map +1 -1
- package/dist/types/esm/components/Md.d.ts +2 -2
- 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/main.d.ts.map +1 -1
- package/dist/types/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +18 -15
- package/src/components/I18nProvider.tsx +3 -7
- package/src/components/Md.tsx +4 -4
- package/src/helpers/loadConfig.ts +3 -3
- package/src/macros.ts +1 -1
- package/src/main.ts +3 -2
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ A type-safe content resolver with content path auto-complete, value preview, and
|
|
|
5
5
|
[](https://badge.fury.io/js/%40next-box%2Fi18n)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
|
|
8
|
-
> To use this library you must be able
|
|
8
|
+
> To use this library, you must be able and willing to define your content in TypeScript and markdown files.
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
@@ -18,9 +18,9 @@ npm add @next-box/i18n
|
|
|
18
18
|
|
|
19
19
|
### Create content files
|
|
20
20
|
|
|
21
|
-
Content needs to be
|
|
21
|
+
Content needs to be provided to the library's `createI18n` init function in the form of a serializable object. Each language for which you have content should live in its own file, be structured the same way, and have a `content` named export.
|
|
22
22
|
|
|
23
|
-
Below is a simplistic example of how to define a content file that
|
|
23
|
+
Below is a simplistic example of how to define a content file that is compatible with `createI18n`.
|
|
24
24
|
|
|
25
25
|
```ts
|
|
26
26
|
// ./content.ts
|
|
@@ -30,17 +30,17 @@ export const content = {
|
|
|
30
30
|
documentTitle: 'This is the homepage',
|
|
31
31
|
},
|
|
32
32
|
},
|
|
33
|
-
} as const; //
|
|
33
|
+
} as const; // Important for preserving the literal types used by the typed resolver.
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
If you
|
|
36
|
+
If you support multiple languages, your content files might look like the examples below.
|
|
37
37
|
|
|
38
38
|
```ts
|
|
39
39
|
// ./content/fr/index.ts
|
|
40
40
|
export const content = {
|
|
41
41
|
pages: {
|
|
42
42
|
homepage: {
|
|
43
|
-
documentTitle: 'Voici la page d’accueil'
|
|
43
|
+
documentTitle: 'Voici la page d’accueil',
|
|
44
44
|
},
|
|
45
45
|
},
|
|
46
46
|
} as const; // This is important!
|
|
@@ -51,7 +51,7 @@ export const content = {
|
|
|
51
51
|
export const content = {
|
|
52
52
|
pages: {
|
|
53
53
|
homepage: {
|
|
54
|
-
documentTitle: 'This is the homepage'
|
|
54
|
+
documentTitle: 'This is the homepage',
|
|
55
55
|
},
|
|
56
56
|
},
|
|
57
57
|
} as const; // This is important!
|
|
@@ -73,49 +73,60 @@ let language: typeof import('./en/index.ts') | typeof import('./fr/index.ts');
|
|
|
73
73
|
|
|
74
74
|
switch (NEXT_PUBLIC_LANGUAGE_CODE) {
|
|
75
75
|
case 'en': {
|
|
76
|
-
language = await import('./en/index
|
|
76
|
+
language = await import('./en/index');
|
|
77
77
|
break;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
case 'fr': {
|
|
81
|
-
language = await import('./fr/index
|
|
81
|
+
language = await import('./fr/index');
|
|
82
82
|
break;
|
|
83
83
|
}
|
|
84
|
+
|
|
85
|
+
default: {
|
|
86
|
+
throw new Error(`Unsupported language: ${NEXT_PUBLIC_LANGUAGE_CODE}`);
|
|
87
|
+
}
|
|
84
88
|
}
|
|
85
89
|
|
|
86
90
|
export const { content } = language;
|
|
87
91
|
```
|
|
88
92
|
|
|
89
|
-
Read the [
|
|
93
|
+
Read the [TypeScript documentation on `const` assertions](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions) for more details on `as const`.
|
|
90
94
|
|
|
91
|
-
### Create an instance of
|
|
95
|
+
### Create an instance of i18n
|
|
92
96
|
|
|
93
97
|
`createI18n` takes the `content` object as an argument and returns an object with the `t` and `tt` content resolver functions as properties. You can then use those functions to look up content by its path from the root of the object.
|
|
94
98
|
|
|
95
|
-
If you pass the above content into `createI18n`, you can use the `t` and `tt` functions to retrieve the `documentTitle`
|
|
99
|
+
If you pass the above content into `createI18n`, you can use the `t` and `tt` functions to retrieve the `documentTitle` as shown below.
|
|
96
100
|
|
|
97
101
|
```ts
|
|
98
102
|
import { createI18n } from '@next-box/i18n';
|
|
99
103
|
import { content } from './content.ts';
|
|
100
104
|
|
|
101
105
|
const { tt } = createI18n(content);
|
|
102
|
-
|
|
103
|
-
//
|
|
104
|
-
//
|
|
105
|
-
//
|
|
106
|
+
|
|
107
|
+
// The path passed to `tt` is type-checked against the object
|
|
108
|
+
// passed to `createI18n`.
|
|
109
|
+
//
|
|
110
|
+
// Hover over `documentTitle` or `tt` to see the inferred type
|
|
111
|
+
// and value preview in your IDE.
|
|
112
|
+
//
|
|
113
|
+
// This would be "This is the homepage" for the single-language example.
|
|
114
|
+
// For a multi-language content object, this can be a union of the
|
|
115
|
+
// corresponding values.
|
|
106
116
|
const documentTitle = tt('pages.homepage.documentTitle');
|
|
117
|
+
|
|
107
118
|
// Do something with `documentTitle`
|
|
108
119
|
```
|
|
109
120
|
|
|
110
|
-
The `t` function is an untyped content lookup.
|
|
121
|
+
The `t` function is an untyped content lookup. It takes a string and returns the value that the path resolves to in the i18n object passed into `createI18n`. If the function resolves no value, it returns `undefined`.
|
|
111
122
|
|
|
112
|
-
The `tt` function, on the other hand, is a typed content lookup.
|
|
123
|
+
The `tt` function, on the other hand, is a typed content lookup. It takes a string that is type-checked against the possible paths in the i18n object passed into `createI18n`. The value that the path resolves to can be previewed through your IDE's built-in TypeScript type preview. If the function resolves no value, it throws an error.
|
|
113
124
|
|
|
114
125
|
#### Templating
|
|
115
126
|
|
|
116
|
-
The `t` and `tt` functions support content with template variables. You can define template variables in content with double
|
|
127
|
+
The `t` and `tt` functions support content with template variables. You can define template variables in content with double curly braces around a camelCase variable name, for example `Welcome back, {{fullName}}!`.
|
|
117
128
|
|
|
118
|
-
|
|
129
|
+
When you want to retrieve that piece of content, provide a second argument containing the key/value pairs used to populate the template variables, as shown below.
|
|
119
130
|
|
|
120
131
|
```ts
|
|
121
132
|
import { createI18n } from '@next-box/i18n';
|
|
@@ -127,21 +138,23 @@ const content = {
|
|
|
127
138
|
} as const;
|
|
128
139
|
|
|
129
140
|
const { tt } = createI18n(content);
|
|
141
|
+
|
|
130
142
|
const greeting = tt('en.greeting', { fullName: 'Joe Bloggs' });
|
|
143
|
+
|
|
131
144
|
console.log(greeting); // Will log 'Welcome back, Joe Bloggs!'
|
|
132
145
|
```
|
|
133
146
|
|
|
134
147
|
#### Error handling
|
|
135
148
|
|
|
136
|
-
|
|
149
|
+
The typed `tt` resolver provides compile-time type checking and runtime validation. TypeScript can prevent invalid paths from being passed to `tt`, while the runtime check provides a backstop if an invalid path is nevertheless supplied at runtime.
|
|
137
150
|
|
|
138
|
-
>
|
|
151
|
+
> The `t` function does not perform this type checking or throw when a path cannot be resolved. It is intentionally looser in terms of what a developer can enter and returns `undefined` when the requested value cannot be resolved.
|
|
139
152
|
|
|
140
153
|
### Using markdown files
|
|
141
154
|
|
|
142
155
|
For blocks of content that consist of multiple paragraphs or different types of content, it can be easier to define these in markdown files. The library supports markdown files through the `md` macro.
|
|
143
156
|
|
|
144
|
-
|
|
157
|
+
The `md` macro processes a markdown file at build time and produces a value that can be included in your content object.
|
|
145
158
|
|
|
146
159
|
Below is an example of a content object that includes markdown.
|
|
147
160
|
|
|
@@ -155,7 +168,7 @@ const content = {
|
|
|
155
168
|
} as const;
|
|
156
169
|
```
|
|
157
170
|
|
|
158
|
-
>
|
|
171
|
+
> The functions exported from the `'/macros'` sub-path are intended to be imported with the `with { type: 'macro' }` import attribute when using `unplugin-macros` or a compiler/bundler that supports this macro import mechanism, such as [Bun](https://bun.sh/) or [Parcel](https://parceljs.org/).
|
|
159
172
|
|
|
160
173
|
By default, the path you pass into the `md` macro is relative to the current working directory. You can change this via the `.i18n-macro.config.json` config file. Create one in your project root and add a `markdownDir` property with a relative path from the current working directory to the directory where your markdown files live.
|
|
161
174
|
|
|
@@ -165,7 +178,9 @@ By default, the path you pass into the `md` macro is relative to the current wor
|
|
|
165
178
|
}
|
|
166
179
|
```
|
|
167
180
|
|
|
168
|
-
The `markdownDir` path supports
|
|
181
|
+
The `markdownDir` path supports the `NEXT_PUBLIC_LANGUAGE_CODE` template variable. This value is read from the environment when the macro is processed. You can use this if you support multiple languages.
|
|
182
|
+
|
|
183
|
+
The multi-language content directory structure must be the same for this approach to work correctly.
|
|
169
184
|
|
|
170
185
|
```json
|
|
171
186
|
{
|
|
@@ -175,11 +190,11 @@ The `markdownDir` path supports a template variable `NEXT_PUBLIC_LANGUAGE_CODE`,
|
|
|
175
190
|
|
|
176
191
|
#### Markdown to JSX
|
|
177
192
|
|
|
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
|
|
193
|
+
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 shared configuration such as a component mapper and `markdown-to-jsx` options to descendant `Md` components.
|
|
179
194
|
|
|
180
|
-
> Under the hood, the library uses the `markdown-to-jsx` npm package to transform markdown into JSX. See
|
|
195
|
+
> Under the hood, the library uses the [`markdown-to-jsx`](https://github.com/quantizor/markdown-to-jsx) npm package to transform markdown into JSX. See the package's documentation for more information on its configuration options. The `componentMapper` prop maps to the `markdown-to-jsx` `overrides` option.
|
|
181
196
|
|
|
182
|
-
The
|
|
197
|
+
The example below illustrates how to use the `md` macro, `I18nProvider`, and `Md` component together.
|
|
183
198
|
|
|
184
199
|
```tsx
|
|
185
200
|
import { md } from '@next-box/i18n/macros' with { type: 'macro' };
|
|
@@ -189,7 +204,7 @@ import { componentMapper } from './componentMapper.ts';
|
|
|
189
204
|
export const Component = () => {
|
|
190
205
|
return (
|
|
191
206
|
<I18nProvider componentMapper={componentMapper}>
|
|
192
|
-
<Md>{md('content
|
|
207
|
+
<Md>{md('./content/markdown/contactUs.md')}</Md>
|
|
193
208
|
</I18nProvider>
|
|
194
209
|
);
|
|
195
210
|
};
|
package/dist/cjs/client.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),r=require("react"),n=require("markdown-to-jsx");const o=r.createContext({componentMapper:{}}),t=/{{[^\s{}]+}}/g,p=/{{ *([^ }]*) *}}/,a=(e,r)=>r?e.replaceAll(t,e=>{const n=e.replace(p,"$1"),o=r[n];if(o)return o;throw new Error(`Markdown contains un-replaced variable '${n}'`)}):e;exports.I18nContext=o,exports.I18nProvider=({children:r,componentMapper:n,...t})=>e.jsx(o
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("react"),n=require("markdown-to-jsx");const o=r.createContext({componentMapper:{}}),t=/{{[^\s{}]+}}/g,p=/{{ *([^ }]*) *}}/,a=(e,r)=>r?e.replaceAll(t,e=>{const n=e.replace(p,"$1"),o=r[n];if(o)return o;throw new Error(`Markdown contains un-replaced variable '${n}'`)}):e;exports.I18nContext=o,exports.I18nProvider=({children:r,componentMapper:n,...t})=>e.jsx(o,{value:{componentMapper:n,...t},children:r}),exports.Md=({children:t,componentMapper:p,variables:c,...s})=>{const{componentMapper:i,...l}=r.use(o);return e.jsx(n,{options:{overrides:{...i,...p},...l,...s},children:a(t,c)})};
|
|
2
2
|
//# sourceMappingURL=client.cjs.map
|
package/dist/cjs/client.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.cjs","sources":["
|
|
1
|
+
{"version":3,"file":"client.cjs","sources":["../../src/components/I18nProvider.tsx","../../src/helpers/injectVariables.ts","../../src/components/Md.tsx"],"sourcesContent":["import { type MarkdownToJSX } from 'markdown-to-jsx';\nimport { type FC, 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: FC<I18nProviderProps> = ({ children, componentMapper, ...markdownToJsxOptions }) => {\n return <I18nContext value={{ componentMapper, ...markdownToJsxOptions }}>{children}</I18nContext>;\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 FC, use } 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: FC<MdProps> = ({\n children,\n componentMapper: componentMapperOverrides,\n variables,\n ...markdownToJsxOptionOverrides\n}) => {\n const { componentMapper, ...markdownToJsxOptions } = use(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","value","componentMapperOverrides","markdownToJsxOptionOverrides","use","MarkdownToJsx","options","overrides"],"mappings":"gGAGO,MAAMA,EAAcC,EAAAA,cAIzB,CACAC,gBAAiB,CAAA,ICRbC,EAA2B,gBAC3BC,EAAiB,mBAEVC,EAAkB,CAACC,EAAkBC,IAChDA,EAEID,EAASE,WAAWL,EAA2BM,IAC7C,MAAMC,EAAUD,EAAME,QAAQP,EAAgB,MACxCQ,EAAmBL,EAAUG,GAEnC,GAAIE,EACF,OAAOA,EAGT,MAAM,IAAIC,MAAM,2CAA2CH,QAE7DJ,6CDA6C,EAAGQ,WAAUZ,qBAAoBa,KAC3EC,EAAAA,IAAChB,EAAAA,CAAYiB,MAAO,CAAEf,qBAAoBa,GAAyBD,SAAAA,eEC7C,EAC7BA,WACAZ,gBAAiBgB,EACjBX,eACGY,MAEH,MAAMjB,gBAAEA,KAAoBa,GAAyBK,EAAAA,IAAIpB,GAEzD,OACEgB,EAAAA,IAACK,EAAAA,CACCC,QAAS,CACPC,UAAW,IAAKrB,KAAoBgB,MACjCH,KACAI,GAGJd,SAAAA,EAAgBS,EAAUP"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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
|
|
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 o=t.read(r,e);if(void 0===o)throw new Error(`Path "${String(r)}" did not resolve to a value`);return o}}};
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/main.ts"],"sourcesContent":["import { type Get } from 'type-fest';\nimport { type AnyRecord, type Path, createConfigReader } from 'zcb';\nimport { type CreateI18nResult } from '#types.ts';\n\nexport const createI18n = <U extends object>(i18n: U): CreateI18nResult<U> => {\n const reader = createConfigReader<U>(i18n);\n\n return {\n // @ts-expect-error intentionally ignoring the type checking here as\n // function is supposed to be untyped.\n t: (key: string, variables?: AnyRecord): string | undefined => reader.read(key, variables),\n tt: <P extends Path<U>>(path: P, variables?: AnyRecord): Get<U, P> => {\n const result = reader.read(path, variables);\n\n // This can resolve to a falsy value at runtime\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (result === undefined) {\n throw new Error(`Path \"${String(path)}\" did not resolve to a value`);\n }\n\n return result;\n },\n };\n};\n"],"names":["i18n","reader","createConfigReader","t","key","variables","read","tt","path","result","undefined","Error","String"],"mappings":"qDAI6CA,IAC3C,MAAMC,EAASC,EAAAA,mBAAsBF,GAErC,MAAO,CAGLG,EAAG,CAACC,EAAaC,IAA8CJ,EAAOK,KAAKF,EAAKC,GAChFE,GAAI,CAAoBC,EAASH,KAC/B,MAAMI,EAASR,EAAOK,KAAKE,EAAMH,GAIjC,QAAeK,IAAXD,EACF,MAAM,IAAIE,MAAM,SAASC,OAAOJ,kCAGlC,OAAOC"}
|
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:
|
|
1
|
+
"use strict";var e=require("node:fs"),r=require("node:path");const n=process.cwd(),{NEXT_PUBLIC_LANGUAGE_CODE:o}=process.env;exports.md=c=>{if(!c)throw new Error("md expected a path, but received none");let t=process.cwd(),{markdownDir:s}=(()=>{let o={};try{o=JSON.parse(e.readFileSync(r.resolve(n,".i18n-macro.config.json"),{encoding:"utf8"}))}catch{}return o})();s&&(o&&(s=s.replaceAll("{{NEXT_PUBLIC_LANGUAGE_CODE}}",()=>o)),t=r.resolve(t,s));const d=r.resolve(t,c);return e.readFileSync(d,{encoding:"utf8"}).trim()};
|
|
2
2
|
//# sourceMappingURL=macros.cjs.map
|
package/dist/cjs/macros.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"macros.cjs","sources":["
|
|
1
|
+
{"version":3,"file":"macros.cjs","sources":["../../src/constants.ts","../../src/helpers/loadConfig.ts","../../src/macros.ts"],"sourcesContent":["export const CONFIG_FILENAME = '.i18n-macro.config.json';\n","import { readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { CONFIG_FILENAME } from '#constants.ts';\nimport { type MacrosConfig } from '#types.ts';\n\nconst cwd = process.cwd();\n\nexport const loadConfig = (): Partial<MacrosConfig> => {\n let config: Partial<MacrosConfig> = {};\n\n try {\n // JSON.parse returns an any time\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n config = JSON.parse(readFileSync(resolve(cwd, CONFIG_FILENAME), { encoding: 'utf8' })) as Partial<MacrosConfig>;\n } catch {\n // no catch\n }\n\n return config;\n};\n","import { readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { loadConfig } from '#helpers/loadConfig.ts';\n\nconst { NEXT_PUBLIC_LANGUAGE_CODE } = process.env;\n\nexport const md = <P extends string>(path: P): P => {\n if (!path) {\n throw new Error('md expected a path, but received none');\n }\n\n let dir = process.cwd();\n let { markdownDir } = loadConfig();\n\n if (markdownDir) {\n if (NEXT_PUBLIC_LANGUAGE_CODE) {\n markdownDir = markdownDir.replaceAll('{{NEXT_PUBLIC_LANGUAGE_CODE}}', () => NEXT_PUBLIC_LANGUAGE_CODE);\n }\n\n dir = resolve(dir, markdownDir);\n }\n\n const fullPath = resolve(dir, path);\n // @ts-expect-error `md` function runs and build time and its return value\n // replaces the `md` invocation. We are forcing the return type to be the\n // input type to aid type inference when using `createI18n` and its\n // `tt` content resolvers.\n return readFileSync(fullPath, { encoding: 'utf8' }).trim();\n};\n"],"names":["cwd","process","NEXT_PUBLIC_LANGUAGE_CODE","env","path","Error","dir","markdownDir","config","JSON","parse","readFileSync","resolve","encoding","loadConfig","replaceAll","fullPath","trim"],"mappings":"6DAAO,MCKDA,EAAMC,QAAQD,OCDdE,0BAAEA,GAA8BD,QAAQE,eAETC,IACnC,IAAKA,EACH,MAAM,IAAIC,MAAM,yCAGlB,IAAIC,EAAML,QAAQD,OACdO,YAAEA,GDLkB,MACxB,IAAIC,EAAgC,CAAA,EAEpC,IAGEA,EAASC,KAAKC,MAAMC,EAAAA,aAAaC,EAAAA,QAAQZ,EDbd,2BCaqC,CAAEa,SAAU,SAC9E,CAAE,MAEF,CAEA,OAAOL,GCNeM,GAElBP,IACEL,IACFK,EAAcA,EAAYQ,WAAW,gCAAiC,IAAMb,IAG9EI,EAAMM,EAAAA,QAAQN,EAAKC,IAGrB,MAAMS,EAAWJ,EAAAA,QAAQN,EAAKF,GAK9B,OAAOO,EAAAA,aAAaK,EAAU,CAAEH,SAAU,SAAUI"}
|
package/dist/esm/client.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{jsx as r}from"react/jsx-runtime";import{createContext as e,
|
|
1
|
+
import{jsx as r}from"react/jsx-runtime";import{createContext as e,use as o}from"react";import n from"markdown-to-jsx";const p=e({componentMapper:{}}),t=({children:e,componentMapper:o,...n})=>r(p,{value:{componentMapper:o,...n},children:e}),a=/{{[^\s{}]+}}/g,c=/{{ *([^ }]*) *}}/,i=(r,e)=>e?r.replaceAll(a,r=>{const o=r.replace(c,"$1"),n=e[o];if(n)return n;throw new Error(`Markdown contains un-replaced variable '${o}'`)}):r,m=({children:e,componentMapper:t,variables:a,...c})=>{const{componentMapper:m,...l}=o(p);return r(n,{options:{overrides:{...m,...t},...l,...c},children:i(e,a)})};export{p as I18nContext,t as I18nProvider,m as Md};
|
|
2
2
|
//# sourceMappingURL=client.mjs.map
|
package/dist/esm/client.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.mjs","sources":["
|
|
1
|
+
{"version":3,"file":"client.mjs","sources":["../../src/components/I18nProvider.tsx","../../src/helpers/injectVariables.ts","../../src/components/Md.tsx"],"sourcesContent":["import { type MarkdownToJSX } from 'markdown-to-jsx';\nimport { type FC, 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: FC<I18nProviderProps> = ({ children, componentMapper, ...markdownToJsxOptions }) => {\n return <I18nContext value={{ componentMapper, ...markdownToJsxOptions }}>{children}</I18nContext>;\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 FC, use } 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: FC<MdProps> = ({\n children,\n componentMapper: componentMapperOverrides,\n variables,\n ...markdownToJsxOptionOverrides\n}) => {\n const { componentMapper, ...markdownToJsxOptions } = use(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","value","extractTemplateVariables","extractVarName","injectVariables","markdown","variables","replaceAll","match","varName","replace","replacementValue","Error","Md","componentMapperOverrides","markdownToJsxOptionOverrides","use","MarkdownToJsx","options","overrides"],"mappings":"sHAGO,MAAMA,EAAcC,EAIzB,CACAC,gBAAiB,CAAA,IAQNC,EAAsC,EAAGC,WAAUF,qBAAoBG,KAC3EC,EAACN,EAAAA,CAAYO,MAAO,CAAEL,qBAAoBG,GAAyBD,SAAAA,ICjBtEI,EAA2B,gBAC3BC,EAAiB,mBAEVC,EAAkB,CAACC,EAAkBC,IAChDA,EAEID,EAASE,WAAWL,EAA2BM,IAC7C,MAAMC,EAAUD,EAAME,QAAQP,EAAgB,MACxCQ,EAAmBL,EAAUG,GAEnC,GAAIE,EACF,OAAOA,EAGT,MAAM,IAAIC,MAAM,2CAA2CH,QAE7DJ,ECEOQ,EAAkB,EAC7Bf,WACAF,gBAAiBkB,EACjBR,eACGS,MAEH,MAAMnB,gBAAEA,KAAoBG,GAAyBiB,EAAItB,GAEzD,OACEM,EAACiB,EAAAA,CACCC,QAAS,CACPC,UAAW,IAAKvB,KAAoBkB,MACjCf,KACAgB,GAGJX,SAAAA,EAAgBN,EAAUQ"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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(
|
|
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(void 0===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
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/main.ts"],"sourcesContent":["import { type Get } from 'type-fest';\nimport { type AnyRecord, type Path, createConfigReader } from 'zcb';\nimport { type CreateI18nResult } from '#types.ts';\n\nexport const createI18n = <U extends object>(i18n: U): CreateI18nResult<U> => {\n const reader = createConfigReader<U>(i18n);\n\n return {\n // @ts-expect-error intentionally ignoring the type checking here as\n // function is supposed to be untyped.\n t: (key: string, variables?: AnyRecord): string | undefined => reader.read(key, variables),\n tt: <P extends Path<U>>(path: P, variables?: AnyRecord): Get<U, P> => {\n const result = reader.read(path, variables);\n\n // This can resolve to a falsy value at runtime\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (result === undefined) {\n throw new Error(`Path \"${String(path)}\" did not resolve to a value`);\n }\n\n return result;\n },\n };\n};\n"],"names":["createI18n","i18n","reader","createConfigReader","t","key","variables","read","tt","path","result","undefined","Error","String"],"mappings":"yCAIO,MAAMA,EAAgCC,IAC3C,MAAMC,EAASC,EAAsBF,GAErC,MAAO,CAGLG,EAAG,CAACC,EAAaC,IAA8CJ,EAAOK,KAAKF,EAAKC,GAChFE,GAAI,CAAoBC,EAASH,KAC/B,MAAMI,EAASR,EAAOK,KAAKE,EAAMH,GAIjC,QAAeK,IAAXD,EACF,MAAM,IAAIE,MAAM,SAASC,OAAOJ,kCAGlC,OAAOC"}
|
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:
|
|
1
|
+
import{readFileSync as e}from"node:fs";import{resolve as r}from"node:path";const o=process.cwd(),{NEXT_PUBLIC_LANGUAGE_CODE:t}=process.env,n=n=>{if(!n)throw new Error("md expected a path, but received none");let c=process.cwd(),{markdownDir:p}=(()=>{let t={};try{t=JSON.parse(e(r(o,".i18n-macro.config.json"),{encoding:"utf8"}))}catch{}return t})();p&&(t&&(p=p.replaceAll("{{NEXT_PUBLIC_LANGUAGE_CODE}}",()=>t)),c=r(c,p));const s=r(c,n);return e(s,{encoding:"utf8"}).trim()};export{n as md};
|
|
2
2
|
//# sourceMappingURL=macros.mjs.map
|
package/dist/esm/macros.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"macros.mjs","sources":["
|
|
1
|
+
{"version":3,"file":"macros.mjs","sources":["../../src/constants.ts","../../src/helpers/loadConfig.ts","../../src/macros.ts"],"sourcesContent":["export const CONFIG_FILENAME = '.i18n-macro.config.json';\n","import { readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { CONFIG_FILENAME } from '#constants.ts';\nimport { type MacrosConfig } from '#types.ts';\n\nconst cwd = process.cwd();\n\nexport const loadConfig = (): Partial<MacrosConfig> => {\n let config: Partial<MacrosConfig> = {};\n\n try {\n // JSON.parse returns an any time\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n config = JSON.parse(readFileSync(resolve(cwd, CONFIG_FILENAME), { encoding: 'utf8' })) as Partial<MacrosConfig>;\n } catch {\n // no catch\n }\n\n return config;\n};\n","import { readFileSync } from 'node:fs';\nimport { resolve } from 'node:path';\nimport { loadConfig } from '#helpers/loadConfig.ts';\n\nconst { NEXT_PUBLIC_LANGUAGE_CODE } = process.env;\n\nexport const md = <P extends string>(path: P): P => {\n if (!path) {\n throw new Error('md expected a path, but received none');\n }\n\n let dir = process.cwd();\n let { markdownDir } = loadConfig();\n\n if (markdownDir) {\n if (NEXT_PUBLIC_LANGUAGE_CODE) {\n markdownDir = markdownDir.replaceAll('{{NEXT_PUBLIC_LANGUAGE_CODE}}', () => NEXT_PUBLIC_LANGUAGE_CODE);\n }\n\n dir = resolve(dir, markdownDir);\n }\n\n const fullPath = resolve(dir, path);\n // @ts-expect-error `md` function runs and build time and its return value\n // replaces the `md` invocation. We are forcing the return type to be the\n // input type to aid type inference when using `createI18n` and its\n // `tt` content resolvers.\n return readFileSync(fullPath, { encoding: 'utf8' }).trim();\n};\n"],"names":["cwd","process","NEXT_PUBLIC_LANGUAGE_CODE","env","md","path","Error","dir","markdownDir","config","JSON","parse","readFileSync","resolve","encoding","loadConfig","replaceAll","fullPath","trim"],"mappings":"2EAAO,MCKDA,EAAMC,QAAQD,OCDdE,0BAAEA,GAA8BD,QAAQE,IAEjCC,EAAwBC,IACnC,IAAKA,EACH,MAAM,IAAIC,MAAM,yCAGlB,IAAIC,EAAMN,QAAQD,OACdQ,YAAEA,GDLkB,MACxB,IAAIC,EAAgC,CAAA,EAEpC,IAGEA,EAASC,KAAKC,MAAMC,EAAaC,EAAQb,EDbd,2BCaqC,CAAEc,SAAU,SAC9E,CAAE,MAEF,CAEA,OAAOL,GCNeM,GAElBP,IACEN,IACFM,EAAcA,EAAYQ,WAAW,gCAAiC,IAAMd,IAG9EK,EAAMM,EAAQN,EAAKC,IAGrB,MAAMS,EAAWJ,EAAQN,EAAKF,GAK9B,OAAOO,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.321 KB
|
|
5
|
+
original size: 1.612 KB
|
|
6
|
+
code reduction: 18.05 %
|
|
7
7
|
module count: 3
|
|
8
8
|
|
|
9
9
|
█████████████████████████████████░░░░░░░░░░░░░░░░░
|
|
10
10
|
file: /src/macros.ts
|
|
11
|
-
bundle space: 66.
|
|
12
|
-
rendered size:
|
|
13
|
-
original size:
|
|
14
|
-
code reduction:
|
|
11
|
+
bundle space: 66.01 %
|
|
12
|
+
rendered size: 872 Bytes
|
|
13
|
+
original size: 958 Bytes
|
|
14
|
+
code reduction: 8.98 %
|
|
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: 30.2 %
|
|
20
|
+
rendered size: 399 Bytes
|
|
21
|
+
original size: 596 Bytes
|
|
22
|
+
code reduction: 33.05 %
|
|
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.79 %
|
|
29
29
|
rendered size: 50 Bytes
|
|
30
30
|
original size: 58 Bytes
|
|
31
31
|
code reduction: 13.79 %
|
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
import { type MarkdownToJSX } from 'markdown-to-jsx';
|
|
2
|
-
import { type
|
|
2
|
+
import { type FC, type ReactNode } from 'react';
|
|
3
3
|
export declare const I18nContext: import("react").Context<{
|
|
4
4
|
componentMapper: MarkdownToJSX.Overrides;
|
|
5
5
|
} & Omit<Partial<{
|
|
6
|
-
createElement: (tag: Parameters<MarkdownToJSX.CreateElement>[0], props: JSX.IntrinsicAttributes, ...children: ReactNode[]) => ReactNode;
|
|
6
|
+
createElement: (tag: Parameters<MarkdownToJSX.CreateElement>[0], props: import("react").JSX.IntrinsicAttributes, ...children: ReactNode[]) => ReactNode;
|
|
7
|
+
disableFrontmatter: boolean;
|
|
7
8
|
disableAutoLink: boolean;
|
|
8
9
|
disableParsingRawHTML: boolean;
|
|
10
|
+
ignoreHTMLBlocks?: boolean;
|
|
11
|
+
tagfilter?: boolean;
|
|
9
12
|
enforceAtxHeadings: boolean;
|
|
13
|
+
evalUnserializableExpressions?: boolean;
|
|
10
14
|
forceBlock: boolean;
|
|
11
15
|
forceInline: boolean;
|
|
12
16
|
forceWrapper: boolean;
|
|
13
|
-
namedCodesToUnicode: {
|
|
14
|
-
[key: string]: string;
|
|
15
|
-
};
|
|
16
17
|
overrides: MarkdownToJSX.Overrides;
|
|
17
|
-
renderRule: (next: () => ReactNode, node: MarkdownToJSX.
|
|
18
|
-
sanitizer: (value: string, tag:
|
|
18
|
+
renderRule: (next: () => ReactNode, node: MarkdownToJSX.ASTNode, renderChildren: MarkdownToJSX.ASTRender, state: MarkdownToJSX.State) => ReactNode;
|
|
19
|
+
sanitizer: (value: string, tag: string, attribute: string) => string | null;
|
|
19
20
|
slugify: (input: string, defaultFn: (input: string) => string) => string;
|
|
20
21
|
wrapper: import("react").ElementType | null;
|
|
22
|
+
wrapperProps?: import("react").JSX.IntrinsicAttributes;
|
|
23
|
+
preserveFrontmatter?: boolean;
|
|
24
|
+
optimizeForStreaming?: boolean;
|
|
21
25
|
}>, "overrides">>;
|
|
22
26
|
export type I18nProviderProps = {
|
|
23
27
|
children: ReactNode;
|
|
24
28
|
componentMapper: MarkdownToJSX.Overrides;
|
|
25
29
|
} & Omit<MarkdownToJSX.Options, 'overrides'>;
|
|
26
|
-
export declare const I18nProvider:
|
|
30
|
+
export declare const I18nProvider: FC<I18nProviderProps>;
|
|
27
31
|
//# sourceMappingURL=I18nProvider.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,EAAE,EAAE,KAAK,SAAS,EAAiB,MAAM,OAAO,CAAC;AAE/D,eAAO,MAAM,WAAW;qBAEH,aAAa,CAAC,SAAS;;qHAcu4W,GAAI;;;;;;;;;;;;;;;;;;;iBAVr7W,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,SAAS,CAAC;IACpB,eAAe,EAAE,aAAa,CAAC,SAAS,CAAC;CAC1C,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AAE7C,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAE9C,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type MarkdownToJSX } from 'markdown-to-jsx';
|
|
2
|
-
import { type
|
|
2
|
+
import { type FC } from 'react';
|
|
3
3
|
export type MdProps = {
|
|
4
4
|
children: string;
|
|
5
5
|
componentMapper?: MarkdownToJSX.Overrides;
|
|
6
6
|
variables?: Record<string, string | number>;
|
|
7
7
|
} & Omit<MarkdownToJSX.Options, 'overrides'>;
|
|
8
|
-
export declare const Md:
|
|
8
|
+
export declare const Md: FC<MdProps>;
|
|
9
9
|
//# sourceMappingURL=Md.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,EAAE,EAAO,MAAM,OAAO,CAAC;AAIrC,MAAM,MAAM,OAAO,GAAG;IAEpB,QAAQ,EAAE,MAAM,CAAC;IAMjB,eAAe,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC;IAE1C,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CAC7C,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AAE7C,eAAO,MAAM,EAAE,EAAE,EAAE,CAAC,OAAO,CAmB1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadConfig.d.cts","sourceRoot":"","sources":["../../../../src/helpers/loadConfig.cts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,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;AAI9C,eAAO,MAAM,UAAU,QAAO,OAAO,CAAC,YAAY,CAYjD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.cts","sourceRoot":"","sources":["../../../src/main.cts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.d.cts","sourceRoot":"","sources":["../../../src/main.cts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElD,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,MAAM,EAAE,MAAM,CAAC,KAAG,gBAAgB,CAAC,CAAC,CAmBxE,CAAC"}
|
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
import { type MarkdownToJSX } from 'markdown-to-jsx';
|
|
2
|
-
import { type
|
|
2
|
+
import { type FC, type ReactNode } from 'react';
|
|
3
3
|
export declare const I18nContext: import("react").Context<{
|
|
4
4
|
componentMapper: MarkdownToJSX.Overrides;
|
|
5
5
|
} & Omit<Partial<{
|
|
6
|
-
createElement: (tag: Parameters<MarkdownToJSX.CreateElement>[0], props: JSX.IntrinsicAttributes, ...children: ReactNode[]) => ReactNode;
|
|
6
|
+
createElement: (tag: Parameters<MarkdownToJSX.CreateElement>[0], props: import("react").JSX.IntrinsicAttributes, ...children: ReactNode[]) => ReactNode;
|
|
7
|
+
disableFrontmatter: boolean;
|
|
7
8
|
disableAutoLink: boolean;
|
|
8
9
|
disableParsingRawHTML: boolean;
|
|
10
|
+
ignoreHTMLBlocks?: boolean;
|
|
11
|
+
tagfilter?: boolean;
|
|
9
12
|
enforceAtxHeadings: boolean;
|
|
13
|
+
evalUnserializableExpressions?: boolean;
|
|
10
14
|
forceBlock: boolean;
|
|
11
15
|
forceInline: boolean;
|
|
12
16
|
forceWrapper: boolean;
|
|
13
|
-
namedCodesToUnicode: {
|
|
14
|
-
[key: string]: string;
|
|
15
|
-
};
|
|
16
17
|
overrides: MarkdownToJSX.Overrides;
|
|
17
|
-
renderRule: (next: () => ReactNode, node: MarkdownToJSX.
|
|
18
|
-
sanitizer: (value: string, tag:
|
|
18
|
+
renderRule: (next: () => ReactNode, node: MarkdownToJSX.ASTNode, renderChildren: MarkdownToJSX.ASTRender, state: MarkdownToJSX.State) => ReactNode;
|
|
19
|
+
sanitizer: (value: string, tag: string, attribute: string) => string | null;
|
|
19
20
|
slugify: (input: string, defaultFn: (input: string) => string) => string;
|
|
20
21
|
wrapper: import("react").ElementType | null;
|
|
22
|
+
wrapperProps?: import("react").JSX.IntrinsicAttributes;
|
|
23
|
+
preserveFrontmatter?: boolean;
|
|
24
|
+
optimizeForStreaming?: boolean;
|
|
21
25
|
}>, "overrides">>;
|
|
22
26
|
export type I18nProviderProps = {
|
|
23
27
|
children: ReactNode;
|
|
24
28
|
componentMapper: MarkdownToJSX.Overrides;
|
|
25
29
|
} & Omit<MarkdownToJSX.Options, 'overrides'>;
|
|
26
|
-
export declare const I18nProvider:
|
|
30
|
+
export declare const I18nProvider: FC<I18nProviderProps>;
|
|
27
31
|
//# sourceMappingURL=I18nProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,EAAE,EAAE,KAAK,SAAS,EAAiB,MAAM,OAAO,CAAC;AAE/D,eAAO,MAAM,WAAW;qBAEH,aAAa,CAAC,SAAS;;qHAcu4W,GAAI;;;;;;;;;;;;;;;;;;;iBAVr7W,CAAC;AAEH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,SAAS,CAAC;IACpB,eAAe,EAAE,aAAa,CAAC,SAAS,CAAC;CAC1C,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AAE7C,eAAO,MAAM,YAAY,EAAE,EAAE,CAAC,iBAAiB,CAE9C,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type MarkdownToJSX } from 'markdown-to-jsx';
|
|
2
|
-
import { type
|
|
2
|
+
import { type FC } from 'react';
|
|
3
3
|
export type MdProps = {
|
|
4
4
|
children: string;
|
|
5
5
|
componentMapper?: MarkdownToJSX.Overrides;
|
|
6
6
|
variables?: Record<string, string | number>;
|
|
7
7
|
} & Omit<MarkdownToJSX.Options, 'overrides'>;
|
|
8
|
-
export declare const Md:
|
|
8
|
+
export declare const Md: FC<MdProps>;
|
|
9
9
|
//# sourceMappingURL=Md.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,EAAE,EAAO,MAAM,OAAO,CAAC;AAIrC,MAAM,MAAM,OAAO,GAAG;IAEpB,QAAQ,EAAE,MAAM,CAAC;IAMjB,eAAe,CAAC,EAAE,aAAa,CAAC,SAAS,CAAC;IAE1C,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;CAC7C,GAAG,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AAE7C,eAAO,MAAM,EAAE,EAAE,EAAE,CAAC,OAAO,CAmB1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadConfig.d.ts","sourceRoot":"","sources":["../../../../src/helpers/loadConfig.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,WAAW,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;AAI9C,eAAO,MAAM,UAAU,QAAO,OAAO,CAAC,YAAY,CAYjD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/main.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../src/main.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAElD,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,MAAM,EAAE,MAAM,CAAC,KAAG,gBAAgB,CAAC,CAAC,CAmBxE,CAAC"}
|