vanilla-intlayer 8.7.14 → 8.9.0
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/dist/cjs/_virtual/_rolldown/runtime.cjs +29 -0
- package/dist/cjs/client/index.cjs +24 -1
- package/dist/cjs/client/installIntlayer.cjs +98 -1
- package/dist/cjs/client/installIntlayer.cjs.map +1 -0
- package/dist/cjs/client/useDictionary.cjs +59 -1
- package/dist/cjs/client/useDictionary.cjs.map +1 -0
- package/dist/cjs/client/useDictionaryDynamic.cjs +93 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -0
- package/dist/cjs/client/useIntlayer.cjs +65 -1
- package/dist/cjs/client/useIntlayer.cjs.map +1 -0
- package/dist/cjs/client/useLocale.cjs +58 -1
- package/dist/cjs/client/useLocale.cjs.map +1 -0
- package/dist/cjs/client/useLocaleStorage.cjs +51 -1
- package/dist/cjs/client/useLocaleStorage.cjs.map +1 -0
- package/dist/cjs/client/useRewriteURL.cjs +46 -1
- package/dist/cjs/client/useRewriteURL.cjs.map +1 -0
- package/dist/cjs/editor/useEditor.cjs +49 -1
- package/dist/cjs/editor/useEditor.cjs.map +1 -0
- package/dist/cjs/format/index.cjs +20 -1
- package/dist/cjs/format/useCompact.cjs +17 -1
- package/dist/cjs/format/useCompact.cjs.map +1 -0
- package/dist/cjs/format/useCurrency.cjs +17 -1
- package/dist/cjs/format/useCurrency.cjs.map +1 -0
- package/dist/cjs/format/useDate.cjs +26 -1
- package/dist/cjs/format/useDate.cjs.map +1 -0
- package/dist/cjs/format/useIntl.cjs +44 -1
- package/dist/cjs/format/useIntl.cjs.map +1 -0
- package/dist/cjs/format/useList.cjs +17 -1
- package/dist/cjs/format/useList.cjs.map +1 -0
- package/dist/cjs/format/useNumber.cjs +20 -1
- package/dist/cjs/format/useNumber.cjs.map +1 -0
- package/dist/cjs/format/usePercentage.cjs +17 -1
- package/dist/cjs/format/usePercentage.cjs.map +1 -0
- package/dist/cjs/format/useRelativeTime.cjs +17 -1
- package/dist/cjs/format/useRelativeTime.cjs.map +1 -0
- package/dist/cjs/format/useUnit.cjs +17 -1
- package/dist/cjs/format/useUnit.cjs.map +1 -0
- package/dist/cjs/getDictionary.cjs +11 -1
- package/dist/cjs/getDictionary.cjs.map +1 -0
- package/dist/cjs/getIntlayer.cjs +11 -1
- package/dist/cjs/getIntlayer.cjs.map +1 -0
- package/dist/cjs/html/HTMLRenderer.cjs +22 -1
- package/dist/cjs/html/HTMLRenderer.cjs.map +1 -0
- package/dist/cjs/html/index.cjs +9 -1
- package/dist/cjs/html/installIntlayerHTML.cjs +91 -1
- package/dist/cjs/html/installIntlayerHTML.cjs.map +1 -0
- package/dist/cjs/html/types.cjs +0 -1
- package/dist/cjs/index.cjs +37 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs +41 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -0
- package/dist/cjs/markdown/compiler.cjs +37 -1
- package/dist/cjs/markdown/compiler.cjs.map +1 -0
- package/dist/cjs/markdown/index.cjs +11 -1
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs +98 -1
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -0
- package/dist/cjs/markdown/runtime.cjs +87 -1
- package/dist/cjs/markdown/runtime.cjs.map +1 -0
- package/dist/cjs/plugins.cjs +240 -1
- package/dist/cjs/plugins.cjs.map +1 -0
- package/dist/cjs/renderIntlayerNode.cjs +44 -1
- package/dist/cjs/renderIntlayerNode.cjs.map +1 -0
- package/dist/esm/client/index.mjs +9 -8
- package/dist/esm/client/installIntlayer.mjs +93 -2
- package/dist/esm/client/installIntlayer.mjs.map +1 -0
- package/dist/esm/client/useDictionary.mjs +55 -8
- package/dist/esm/client/useDictionary.mjs.map +1 -0
- package/dist/esm/client/useDictionaryDynamic.mjs +82 -28
- package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -0
- package/dist/esm/client/useIntlayer.mjs +61 -8
- package/dist/esm/client/useIntlayer.mjs.map +1 -0
- package/dist/esm/client/useLocale.mjs +51 -17
- package/dist/esm/client/useLocale.mjs.map +1 -0
- package/dist/esm/client/useLocaleStorage.mjs +39 -13
- package/dist/esm/client/useLocaleStorage.mjs.map +1 -0
- package/dist/esm/client/useRewriteURL.mjs +40 -12
- package/dist/esm/client/useRewriteURL.mjs.map +1 -0
- package/dist/esm/editor/useEditor.mjs +47 -2
- package/dist/esm/editor/useEditor.mjs.map +1 -0
- package/dist/esm/format/index.mjs +11 -10
- package/dist/esm/format/useCompact.mjs +11 -8
- package/dist/esm/format/useCompact.mjs.map +1 -0
- package/dist/esm/format/useCurrency.mjs +11 -8
- package/dist/esm/format/useCurrency.mjs.map +1 -0
- package/dist/esm/format/useDate.mjs +18 -12
- package/dist/esm/format/useDate.mjs.map +1 -0
- package/dist/esm/format/useIntl.mjs +36 -8
- package/dist/esm/format/useIntl.mjs.map +1 -0
- package/dist/esm/format/useList.mjs +11 -8
- package/dist/esm/format/useList.mjs.map +1 -0
- package/dist/esm/format/useNumber.mjs +14 -8
- package/dist/esm/format/useNumber.mjs.map +1 -0
- package/dist/esm/format/usePercentage.mjs +11 -8
- package/dist/esm/format/usePercentage.mjs.map +1 -0
- package/dist/esm/format/useRelativeTime.mjs +11 -8
- package/dist/esm/format/useRelativeTime.mjs.map +1 -0
- package/dist/esm/format/useUnit.mjs +11 -8
- package/dist/esm/format/useUnit.mjs.map +1 -0
- package/dist/esm/getDictionary.mjs +7 -4
- package/dist/esm/getDictionary.mjs.map +1 -0
- package/dist/esm/getIntlayer.mjs +7 -4
- package/dist/esm/getIntlayer.mjs.map +1 -0
- package/dist/esm/html/HTMLRenderer.mjs +17 -5
- package/dist/esm/html/HTMLRenderer.mjs.map +1 -0
- package/dist/esm/html/index.mjs +4 -3
- package/dist/esm/html/installIntlayerHTML.mjs +81 -13
- package/dist/esm/html/installIntlayerHTML.mjs.map +1 -0
- package/dist/esm/index.mjs +13 -12
- package/dist/esm/markdown/MarkdownRenderer.mjs +36 -16
- package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -0
- package/dist/esm/markdown/compiler.mjs +28 -4
- package/dist/esm/markdown/compiler.mjs.map +1 -0
- package/dist/esm/markdown/index.mjs +5 -4
- package/dist/esm/markdown/installIntlayerMarkdown.mjs +86 -23
- package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -0
- package/dist/esm/markdown/runtime.mjs +60 -28
- package/dist/esm/markdown/runtime.mjs.map +1 -0
- package/dist/esm/plugins.mjs +187 -133
- package/dist/esm/plugins.mjs.map +1 -0
- package/dist/esm/renderIntlayerNode.mjs +32 -15
- package/dist/esm/renderIntlayerNode.mjs.map +1 -0
- package/dist/types/client/index.d.ts +8 -0
- package/dist/{client → types/client}/installIntlayer.d.ts +27 -20
- package/dist/types/client/installIntlayer.d.ts.map +1 -0
- package/dist/{client → types/client}/useDictionary.d.ts +22 -17
- package/dist/types/client/useDictionary.d.ts.map +1 -0
- package/dist/{client → types/client}/useDictionaryDynamic.d.ts +10 -5
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -0
- package/dist/{client → types/client}/useIntlayer.d.ts +9 -4
- package/dist/types/client/useIntlayer.d.ts.map +1 -0
- package/dist/{client → types/client}/useLocale.d.ts +14 -10
- package/dist/types/client/useLocale.d.ts.map +1 -0
- package/dist/types/client/useLocaleStorage.d.ts +37 -0
- package/dist/types/client/useLocaleStorage.d.ts.map +1 -0
- package/dist/{client → types/client}/useRewriteURL.d.ts +5 -1
- package/dist/types/client/useRewriteURL.d.ts.map +1 -0
- package/dist/{editor → types/editor}/useEditor.d.ts +5 -1
- package/dist/types/editor/useEditor.d.ts.map +1 -0
- package/dist/types/format/index.d.ts +10 -0
- package/dist/types/format/useCompact.d.ts +7 -0
- package/dist/types/format/useCompact.d.ts.map +1 -0
- package/dist/types/format/useCurrency.d.ts +7 -0
- package/dist/types/format/useCurrency.d.ts.map +1 -0
- package/dist/types/format/useDate.d.ts +10 -0
- package/dist/types/format/useDate.d.ts.map +1 -0
- package/dist/{format → types/format}/useIntl.d.ts +10 -5
- package/dist/types/format/useIntl.d.ts.map +1 -0
- package/dist/types/format/useList.d.ts +7 -0
- package/dist/types/format/useList.d.ts.map +1 -0
- package/dist/types/format/useNumber.d.ts +10 -0
- package/dist/types/format/useNumber.d.ts.map +1 -0
- package/dist/types/format/usePercentage.d.ts +7 -0
- package/dist/types/format/usePercentage.d.ts.map +1 -0
- package/dist/types/format/useRelativeTime.d.ts +7 -0
- package/dist/types/format/useRelativeTime.d.ts.map +1 -0
- package/dist/types/format/useUnit.d.ts +7 -0
- package/dist/types/format/useUnit.d.ts.map +1 -0
- package/dist/types/getDictionary.d.ts +9 -0
- package/dist/types/getDictionary.d.ts.map +1 -0
- package/dist/types/getIntlayer.d.ts +8 -0
- package/dist/types/getIntlayer.d.ts.map +1 -0
- package/dist/types/html/HTMLRenderer.d.ts +21 -0
- package/dist/types/html/HTMLRenderer.d.ts.map +1 -0
- package/dist/types/html/index.d.ts +4 -0
- package/dist/{html → types/html}/installIntlayerHTML.d.ts +18 -13
- package/dist/types/html/installIntlayerHTML.d.ts.map +1 -0
- package/dist/{html → types/html}/types.d.ts +12 -14
- package/dist/types/html/types.d.ts.map +1 -0
- package/dist/types/index.d.ts +20 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/markdown/MarkdownRenderer.d.ts +32 -0
- package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -0
- package/dist/types/markdown/compiler.d.ts +23 -0
- package/dist/types/markdown/compiler.d.ts.map +1 -0
- package/dist/types/markdown/index.d.ts +4 -0
- package/dist/types/markdown/installIntlayerMarkdown.d.ts +71 -0
- package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +1 -0
- package/dist/types/markdown/runtime.d.ts +16 -0
- package/dist/types/markdown/runtime.d.ts.map +1 -0
- package/dist/types/plugins.d.ts +80 -0
- package/dist/types/plugins.d.ts.map +1 -0
- package/dist/types/renderIntlayerNode.d.ts +31 -0
- package/dist/types/renderIntlayerNode.d.ts.map +1 -0
- package/package.json +10 -13
- package/dist/client/index.d.ts +0 -7
- package/dist/client/useLocaleStorage.d.ts +0 -31
- package/dist/format/index.d.ts +0 -9
- package/dist/format/useCompact.d.ts +0 -2
- package/dist/format/useCurrency.d.ts +0 -2
- package/dist/format/useDate.d.ts +0 -5
- package/dist/format/useList.d.ts +0 -2
- package/dist/format/useNumber.d.ts +0 -5
- package/dist/format/usePercentage.d.ts +0 -2
- package/dist/format/useRelativeTime.d.ts +0 -2
- package/dist/format/useUnit.d.ts +0 -2
- package/dist/getDictionary.d.ts +0 -4
- package/dist/getIntlayer.d.ts +0 -3
- package/dist/html/HTMLRenderer.d.ts +0 -14
- package/dist/html/index.d.ts +0 -3
- package/dist/index.d.ts +0 -11
- package/dist/installIntlayer-C99qMzFH.mjs +0 -47
- package/dist/installIntlayer-CxkE8IxM.js +0 -1
- package/dist/markdown/MarkdownRenderer.d.ts +0 -22
- package/dist/markdown/compiler.d.ts +0 -19
- package/dist/markdown/index.d.ts +0 -3
- package/dist/markdown/installIntlayerMarkdown.d.ts +0 -70
- package/dist/markdown/runtime.d.ts +0 -12
- package/dist/plugins-Bp8aaTny.js +0 -1
- package/dist/plugins.d.ts +0 -78
- package/dist/renderIntlayerNode.d.ts +0 -22
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { HTMLComponents } from "../html/types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/markdown/installIntlayerMarkdown.d.ts
|
|
4
|
+
type MarkdownProviderOptions = {
|
|
5
|
+
/** Forces the compiler to always output content with a block-level wrapper. */forceBlock?: boolean; /** Forces the compiler to always output content with an inline wrapper. */
|
|
6
|
+
forceInline?: boolean; /** Whether to preserve frontmatter in the markdown content. */
|
|
7
|
+
preserveFrontmatter?: boolean; /** Whether to use the GitHub Tag Filter. */
|
|
8
|
+
tagfilter?: boolean;
|
|
9
|
+
};
|
|
10
|
+
type RenderMarkdownOptions = MarkdownProviderOptions & {
|
|
11
|
+
components?: HTMLComponents<'permissive', {}>;
|
|
12
|
+
wrapper?: string;
|
|
13
|
+
};
|
|
14
|
+
type RenderMarkdownFunction = (markdown: string, options?: MarkdownProviderOptions, components?: HTMLComponents<'permissive', {}>, wrapper?: string) => string | Promise<string>;
|
|
15
|
+
type IntlayerMarkdownProvider = {
|
|
16
|
+
components?: HTMLComponents<'permissive', {}>;
|
|
17
|
+
renderMarkdown: RenderMarkdownFunction;
|
|
18
|
+
};
|
|
19
|
+
type IntlayerMarkdownPluginOptions = MarkdownProviderOptions & {
|
|
20
|
+
components?: HTMLComponents<'permissive', {}>;
|
|
21
|
+
wrapper?: string;
|
|
22
|
+
renderMarkdown?: RenderMarkdownFunction;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Create and return a single IntlayerMarkdownProvider instance.
|
|
26
|
+
*/
|
|
27
|
+
declare const createIntlayerMarkdownClient: (renderMarkdown: RenderMarkdownFunction, components?: HTMLComponents<"permissive", {}>) => IntlayerMarkdownProvider;
|
|
28
|
+
/**
|
|
29
|
+
* Install the Intlayer Markdown provider for your vanilla JS application.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* import { installIntlayerMarkdown } from 'vanilla-intlayer/markdown';
|
|
34
|
+
*
|
|
35
|
+
* installIntlayerMarkdown({ forceBlock: true });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
declare const installIntlayerMarkdown: (pluginOptions?: IntlayerMarkdownPluginOptions | RenderMarkdownFunction) => IntlayerMarkdownProvider;
|
|
39
|
+
/**
|
|
40
|
+
* Access the installed IntlayerMarkdownProvider.
|
|
41
|
+
* Returns a fallback renderer that compiles with default options if no
|
|
42
|
+
* provider has been installed.
|
|
43
|
+
*/
|
|
44
|
+
declare const useMarkdown: () => IntlayerMarkdownProvider;
|
|
45
|
+
/**
|
|
46
|
+
* Asynchronously install a markdown renderer whose implementation is loaded
|
|
47
|
+
* via a dynamic `import()`.
|
|
48
|
+
*
|
|
49
|
+
* Use this to keep the markdown compiler out of the initial bundle — the
|
|
50
|
+
* loader is only called the first time this function is executed.
|
|
51
|
+
*
|
|
52
|
+
* The returned promise resolves once the provider is ready. Any calls to
|
|
53
|
+
* `useMarkdown()` before the promise resolves will use the fallback
|
|
54
|
+
* (raw-string) renderer.
|
|
55
|
+
*
|
|
56
|
+
* @param loader - A zero-argument async function that resolves to either a
|
|
57
|
+
* `RenderMarkdownFunction` or an `IntlayerMarkdownPluginOptions` object.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* // Load a custom markdown renderer (e.g. marked) only when needed
|
|
62
|
+
* await installIntlayerMarkdownDynamic(async () => {
|
|
63
|
+
* const { marked } = await import('marked');
|
|
64
|
+
* return (markdown) => marked(markdown) as string;
|
|
65
|
+
* });
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
declare const installIntlayerMarkdownDynamic: (loader: () => Promise<IntlayerMarkdownPluginOptions | RenderMarkdownFunction>) => Promise<IntlayerMarkdownProvider>;
|
|
69
|
+
//#endregion
|
|
70
|
+
export { IntlayerMarkdownPluginOptions, IntlayerMarkdownProvider, MarkdownProviderOptions, RenderMarkdownFunction, RenderMarkdownOptions, createIntlayerMarkdownClient, installIntlayerMarkdown, installIntlayerMarkdownDynamic, useMarkdown };
|
|
71
|
+
//# sourceMappingURL=installIntlayerMarkdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installIntlayerMarkdown.d.ts","names":[],"sources":["../../../src/markdown/installIntlayerMarkdown.ts"],"mappings":";;;KAGY,uBAAA;iFAEV,UAAA,YAFiC;EAIjC,WAAA,YAJiC;EAMjC,mBAAA,YAFA;EAIA,SAAA;AAAA;AAAA,KAGU,qBAAA,GAAwB,uBAAA;EAClC,UAAA,GAAa,cAAA;EACb,OAAA;AAAA;AAAA,KAGU,sBAAA,IACV,QAAA,UACA,OAAA,GAAU,uBAAA,EACV,UAAA,GAAa,cAAA,oBACb,OAAA,uBACY,OAAA;AAAA,KAOF,wBAAA;EACV,UAAA,GAAa,cAAA;EACb,cAAA,EAAgB,sBAAA;AAAA;AAAA,KAGN,6BAAA,GAAgC,uBAAA;EAC1C,UAAA,GAAa,cAAA;EACb,OAAA;EACA,cAAA,GAAiB,sBAAA;AAAA;;;;cAMN,4BAAA,GACX,cAAA,EAAgB,sBAAA,EAChB,UAAA,GAAa,cAAA,uBACZ,wBAAA;;;;;;;;;;;cAiBU,uBAAA,GACX,aAAA,GAAgB,6BAAA,GAAgC,sBAAA,KAC/C,wBAAA;AApCH;;;;;AAAA,cA0Fa,WAAA,QAAkB,wBAAA;;;;;AArF/B;;;;;;;;;;;;;;;;AASA;;;cA2Ga,8BAAA,GACX,MAAA,QAAc,OAAA,CAAQ,6BAAA,GAAgC,sBAAA,MACrD,OAAA,CAAQ,wBAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MarkdownRuntime } from "@intlayer/core/markdown";
|
|
2
|
+
|
|
3
|
+
//#region src/markdown/runtime.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Vanilla-specific MarkdownRuntime that produces HTML strings.
|
|
6
|
+
*/
|
|
7
|
+
declare const vanillaRuntime: MarkdownRuntime;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a vanilla runtime with a custom createElement for advanced use cases.
|
|
10
|
+
*/
|
|
11
|
+
declare const createVanillaRuntime: (options?: {
|
|
12
|
+
onCreateElement?: (type: any, props: Record<string, any> | null, children: any[]) => string;
|
|
13
|
+
}) => MarkdownRuntime;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { createVanillaRuntime, vanillaRuntime as default, vanillaRuntime };
|
|
16
|
+
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","names":[],"sources":["../../../src/markdown/runtime.ts"],"mappings":";;;;AA0HA;;cA7Ea,cAAA,EAAgB,eAAA;;;;cA6EhB,oBAAA,GACX,OAAA;EACE,eAAA,IACE,IAAA,OACA,KAAA,EAAO,MAAA,sBACP,QAAA;AAAA,MAGH,eAAA"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { HTMLComponents } from "./html/types.js";
|
|
2
|
+
import { IntlayerNode as IntlayerNode$1 } from "./renderIntlayerNode.js";
|
|
3
|
+
import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
4
|
+
import { DeepTransformContent as DeepTransformContent$1, IInterpreterPluginState as IInterpreterPluginState$1, Plugins } from "@intlayer/core/interpreter";
|
|
5
|
+
import * as NodeTypes from "@intlayer/types/nodeType";
|
|
6
|
+
import { NodeType } from "@intlayer/types/nodeType";
|
|
7
|
+
|
|
8
|
+
//#region src/plugins.d.ts
|
|
9
|
+
/** ---------------------------------------------
|
|
10
|
+
* INTLAYER NODE PLUGIN
|
|
11
|
+
* --------------------------------------------- */
|
|
12
|
+
type IntlayerNodeCond<T> = T extends number | string ? IntlayerNode<T> : never;
|
|
13
|
+
type IntlayerNode<T, P = {}> = IntlayerNode$1<T> & P;
|
|
14
|
+
declare const intlayerNodePlugins: Plugins;
|
|
15
|
+
/** ---------------------------------------------
|
|
16
|
+
* INSERTION PLUGIN
|
|
17
|
+
* --------------------------------------------- */
|
|
18
|
+
type InsertionCond<T, _S, L extends LocalesValues> = T extends {
|
|
19
|
+
nodeType: NodeType | string;
|
|
20
|
+
[NodeTypes.INSERTION]: infer I;
|
|
21
|
+
fields: readonly (infer F)[];
|
|
22
|
+
} ? <V extends { [K in Extract<F, string>]: string | number }>(values: V) => I extends string ? IntlayerNode<string> : DeepTransformContent<I, L> : never;
|
|
23
|
+
declare const insertionPlugin: Plugins;
|
|
24
|
+
type MarkdownStringCond<T> = T extends string ? IntlayerNode<string, {
|
|
25
|
+
metadata: DeepTransformContent<string>; /** Returns the rendered markdown; render with .use(). */
|
|
26
|
+
use: (components?: HTMLComponents<'permissive', {}>) => string;
|
|
27
|
+
}> : never;
|
|
28
|
+
declare const markdownStringPlugin: Plugins;
|
|
29
|
+
type MarkdownCond<T> = T extends {
|
|
30
|
+
nodeType: NodeType | string;
|
|
31
|
+
[NodeTypes.MARKDOWN]: infer M;
|
|
32
|
+
metadata?: infer U;
|
|
33
|
+
tags?: infer U;
|
|
34
|
+
} ? {
|
|
35
|
+
use: (components?: HTMLComponents<'permissive', U>) => IntlayerNode<M>;
|
|
36
|
+
metadata: DeepTransformContent<U>;
|
|
37
|
+
} : never;
|
|
38
|
+
declare const markdownPlugin: Plugins;
|
|
39
|
+
/** ---------------------------------------------
|
|
40
|
+
* HTML PLUGIN
|
|
41
|
+
* --------------------------------------------- */
|
|
42
|
+
type HTMLPluginCond<T> = T extends {
|
|
43
|
+
nodeType: NodeType | string;
|
|
44
|
+
[NodeTypes.HTML]: infer I;
|
|
45
|
+
tags?: infer U;
|
|
46
|
+
} ? {
|
|
47
|
+
use: (components?: HTMLComponents<'permissive', U>) => IntlayerNode<I>;
|
|
48
|
+
} : never;
|
|
49
|
+
declare const htmlPlugin: Plugins;
|
|
50
|
+
/** ---------------------------------------------
|
|
51
|
+
* PLUGINS RESULT
|
|
52
|
+
* --------------------------------------------- */
|
|
53
|
+
interface IInterpreterPluginVanilla<T, S, L extends LocalesValues> {
|
|
54
|
+
vanillaIntlayerNode: IntlayerNodeCond<T>;
|
|
55
|
+
vanillaInsertion: InsertionCond<T, S, L>;
|
|
56
|
+
vanillaMarkdown: MarkdownCond<T>;
|
|
57
|
+
vanillaHtml: HTMLPluginCond<T>;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.
|
|
61
|
+
*
|
|
62
|
+
* Otherwise the `vanilla-intlayer` plugins will override the types of `intlayer` functions.
|
|
63
|
+
* Use `getIntlayer` from `vanilla-intlayer` (not from `intlayer`) to get properly typed
|
|
64
|
+
* `IntlayerNode` wrappers with `.value` access on string/number content.
|
|
65
|
+
*/
|
|
66
|
+
type IInterpreterPluginState = Omit<IInterpreterPluginState$1, 'insertion'> & {
|
|
67
|
+
vanillaIntlayerNode: true;
|
|
68
|
+
vanillaInsertion: true;
|
|
69
|
+
vanillaMarkdown: true;
|
|
70
|
+
vanillaHtml: true;
|
|
71
|
+
};
|
|
72
|
+
type DeepTransformContent<T, L extends LocalesValues = DeclaredLocales> = DeepTransformContent$1<T, IInterpreterPluginState, L>;
|
|
73
|
+
/**
|
|
74
|
+
* Get the plugins array for Vanilla content transformation.
|
|
75
|
+
* This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.
|
|
76
|
+
*/
|
|
77
|
+
declare const getPlugins: (locale?: LocalesValues, fallback?: boolean) => Plugins[];
|
|
78
|
+
//#endregion
|
|
79
|
+
export { DeepTransformContent, HTMLPluginCond, IInterpreterPluginState, IInterpreterPluginVanilla, InsertionCond, IntlayerNode, IntlayerNodeCond, MarkdownCond, MarkdownStringCond, getPlugins, htmlPlugin, insertionPlugin, intlayerNodePlugins, markdownPlugin, markdownStringPlugin };
|
|
80
|
+
//# sourceMappingURL=plugins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.ts"],"mappings":";;;;;;;;;;AA0CA;KAAY,gBAAA,MAAsB,CAAA,2BAC9B,YAAA,CAAa,CAAA;AAAA,KAGL,YAAA,cAA0B,cAAA,CAAiB,CAAA,IAAK,CAAA;AAAA,cAQ/C,mBAAA,EAAqB,OAAA;;;;KAmDtB,aAAA,kBAA+B,aAAA,IAAiB,CAAA;EAC1D,QAAA,EAAU,QAAA;EAAA,CACT,SAAA,CAAU,SAAA;EACX,MAAA;AAAA,uBAEqB,OAAA,CAAQ,CAAA,+BACzB,MAAA,EAAQ,CAAA,KACL,CAAA,kBAAmB,YAAA,WAAuB,oBAAA,CAAqB,CAAA,EAAG,CAAA;AAAA,cAG9D,eAAA,EAAiB,OAAA;AAAA,KA4GlB,kBAAA,MAAwB,CAAA,kBAChC,YAAA;EAGI,QAAA,EAAU,oBAAA,UArLqC;EAuL/C,GAAA,GAAM,UAAA,GAAa,cAAA;AAAA;AAAA,cAKd,oBAAA,EAAsB,OAAA;AAAA,KAuEvB,YAAA,MAAkB,CAAA;EAC5B,QAAA,EAAU,QAAA;EAAA,CACT,SAAA,CAAU,QAAA;EACX,QAAA;EACA,IAAA;AAAA;EAGI,GAAA,GAAM,UAAA,GAAa,cAAA,eAA6B,CAAA,MAAO,YAAA,CAAa,CAAA;EACpE,QAAA,EAAU,oBAAA,CAAqB,CAAA;AAAA;AAAA,cAIxB,cAAA,EAAgB,OAAA;;;;KA2BjB,cAAA,MAAoB,CAAA;EAC9B,QAAA,EAAU,QAAA;EAAA,CACT,SAAA,CAAU,IAAA;EACX,IAAA;AAAA;EAGI,GAAA,GAAM,UAAA,GAAa,cAAA,eAA6B,CAAA,MAAO,YAAA,CAAa,CAAA;AAAA;AAAA,cAI7D,UAAA,EAAY,OAAA;;;;UAqER,yBAAA,iBAA0C,aAAA;EACzD,mBAAA,EAAqB,gBAAA,CAAiB,CAAA;EACtC,gBAAA,EAAkB,aAAA,CAAc,CAAA,EAAG,CAAA,EAAG,CAAA;EACtC,eAAA,EAAiB,YAAA,CAAa,CAAA;EAC9B,WAAA,EAAa,cAAA,CAAe,CAAA;AAAA;;;;;;;;KAUlB,uBAAA,GAA0B,IAAA,CACpC,yBAAA;EAGA,mBAAA;EACA,gBAAA;EACA,eAAA;EACA,WAAA;AAAA;AAAA,KAGU,oBAAA,cAEA,aAAA,GAAgB,eAAA,IACxB,sBAAA,CAAyB,CAAA,EAAG,uBAAA,EAAyB,CAAA;;;;;cAQ5C,UAAA,GACX,MAAA,GAAS,aAAA,EACT,QAAA,eACC,OAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ResolvedEditor } from "@intlayer/types/module_augmentation";
|
|
2
|
+
|
|
3
|
+
//#region src/renderIntlayerNode.d.ts
|
|
4
|
+
type IntlayerNode<T = string> = ResolvedEditor<T & {
|
|
5
|
+
raw: T;
|
|
6
|
+
value: T;
|
|
7
|
+
toString: () => string;
|
|
8
|
+
valueOf: () => T;
|
|
9
|
+
toJSON: () => T;
|
|
10
|
+
__update: (next: IntlayerNode<T>) => void;
|
|
11
|
+
}, {
|
|
12
|
+
raw: T;
|
|
13
|
+
value: T;
|
|
14
|
+
toString: () => string;
|
|
15
|
+
valueOf: () => T;
|
|
16
|
+
toJSON: () => T;
|
|
17
|
+
__update: (next: IntlayerNode<T>) => void;
|
|
18
|
+
}> & T;
|
|
19
|
+
declare const renderIntlayerNode: <T>({
|
|
20
|
+
value,
|
|
21
|
+
children,
|
|
22
|
+
additionalProps
|
|
23
|
+
}: {
|
|
24
|
+
value: T;
|
|
25
|
+
children?: any;
|
|
26
|
+
additionalProps?: Record<string, unknown>;
|
|
27
|
+
[key: string]: unknown;
|
|
28
|
+
}) => IntlayerNode<T>;
|
|
29
|
+
//#endregion
|
|
30
|
+
export { IntlayerNode, renderIntlayerNode };
|
|
31
|
+
//# sourceMappingURL=renderIntlayerNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderIntlayerNode.d.ts","names":[],"sources":["../../src/renderIntlayerNode.ts"],"mappings":";;;KAEY,YAAA,eAA2B,cAAA,CACrC,CAAA;EACE,GAAA,EAAK,CAAA;EACL,KAAA,EAAO,CAAA;EACP,QAAA;EACA,OAAA,QAAe,CAAA;EACf,MAAA,QAAc,CAAA;EACd,QAAA,GAAW,IAAA,EAAM,YAAA,CAAa,CAAA;AAAA;EAG9B,GAAA,EAAK,CAAA;EACL,KAAA,EAAO,CAAA;EACP,QAAA;EACA,OAAA,QAAe,CAAA;EACf,MAAA,QAAc,CAAA;EACd,QAAA,GAAW,IAAA,EAAM,YAAA,CAAa,CAAA;AAAA,KAGhC,CAAA;AAAA,cAEW,kBAAA;EAEX,KAAA;EAAA,QAAA;EAAA;AAAA;EAKA,KAAA,EAAO,CAAA;EACP,QAAA;EACA,eAAA,GAAkB,MAAA;EAAA,CACjB,GAAA;AAAA,MACC,YAAA,CAAa,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vanilla-intlayer",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.9.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Easily internationalize i18n your Vanilla JS, HTML, and PHP applications with type-safe multilingual content management.",
|
|
6
6
|
"keywords": [
|
|
@@ -84,10 +84,10 @@
|
|
|
84
84
|
"./package.json"
|
|
85
85
|
],
|
|
86
86
|
"scripts": {
|
|
87
|
-
"build": "bun --bun
|
|
88
|
-
"build:ci": "bun --bun
|
|
87
|
+
"build": "bun --bun tsdown --config tsdown.config.ts",
|
|
88
|
+
"build:ci": "bun --bun tsdown --config tsdown.config.ts",
|
|
89
89
|
"clean": "bun --bun rimraf ./dist .turbo",
|
|
90
|
-
"dev": "bun --bun
|
|
90
|
+
"dev": "bun --bun tsdown --config tsdown.config.ts --watch",
|
|
91
91
|
"format": "bun --bun biome format . --check",
|
|
92
92
|
"format:fix": "bun --bun biome format --write .",
|
|
93
93
|
"lint": "bun --bun biome lint .",
|
|
@@ -101,27 +101,24 @@
|
|
|
101
101
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
|
-
"@intlayer/api": "8.
|
|
105
|
-
"@intlayer/config": "8.
|
|
106
|
-
"@intlayer/core": "8.
|
|
107
|
-
"@intlayer/editor": "8.
|
|
108
|
-
"@intlayer/types": "8.
|
|
104
|
+
"@intlayer/api": "8.9.0",
|
|
105
|
+
"@intlayer/config": "8.9.0",
|
|
106
|
+
"@intlayer/core": "8.9.0",
|
|
107
|
+
"@intlayer/editor": "8.9.0",
|
|
108
|
+
"@intlayer/types": "8.9.0"
|
|
109
109
|
},
|
|
110
110
|
"devDependencies": {
|
|
111
111
|
"@types/node": "25.6.0",
|
|
112
112
|
"@utils/ts-config": "1.0.4",
|
|
113
113
|
"@utils/ts-config-types": "1.0.4",
|
|
114
114
|
"@utils/tsdown-config": "1.0.4",
|
|
115
|
-
"fast-glob": "3.3.3",
|
|
116
115
|
"rimraf": "6.1.3",
|
|
117
116
|
"tsdown": "0.21.10",
|
|
118
117
|
"typescript": "6.0.3",
|
|
119
|
-
"vite": "8.0.10",
|
|
120
|
-
"vite-plugin-dts": "5.0.0",
|
|
121
118
|
"vitest": "4.1.5"
|
|
122
119
|
},
|
|
123
120
|
"peerDependencies": {
|
|
124
|
-
"intlayer": "8.
|
|
121
|
+
"intlayer": "8.9.0"
|
|
125
122
|
},
|
|
126
123
|
"peerDependenciesMeta": {
|
|
127
124
|
"intlayer": {
|
package/dist/client/index.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { LocalesValues } from '@intlayer/types/module_augmentation';
|
|
2
|
-
/**
|
|
3
|
-
* Get the current locale from storage (cookie or localStorage).
|
|
4
|
-
*/
|
|
5
|
-
export declare const localeInStorage: import('intlayer').Locale | undefined;
|
|
6
|
-
/**
|
|
7
|
-
* @deprecated Use localeInStorage instead.
|
|
8
|
-
*/
|
|
9
|
-
export declare const localeCookie: import('intlayer').Locale | undefined;
|
|
10
|
-
/**
|
|
11
|
-
* Persist the locale to storage (cookie and/or localStorage).
|
|
12
|
-
*/
|
|
13
|
-
export declare const setLocaleInStorage: (locale: LocalesValues, isCookieEnabled: boolean) => void;
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated Use setLocaleInStorage instead.
|
|
16
|
-
*/
|
|
17
|
-
export declare const setLocaleCookie: (locale: LocalesValues, isCookieEnabled: boolean) => void;
|
|
18
|
-
/**
|
|
19
|
-
* Returns the current locale from storage and a setter.
|
|
20
|
-
*/
|
|
21
|
-
export declare const useLocaleStorage: (isCookieEnabled?: boolean) => {
|
|
22
|
-
localeStorage: import('intlayer').Locale;
|
|
23
|
-
setLocaleStorage: (locale: LocalesValues) => void;
|
|
24
|
-
};
|
|
25
|
-
/**
|
|
26
|
-
* @deprecated Use useLocaleStorage instead.
|
|
27
|
-
*/
|
|
28
|
-
export declare const useLocaleCookie: (isCookieEnabled?: boolean) => {
|
|
29
|
-
localeStorage: import('intlayer').Locale;
|
|
30
|
-
setLocaleStorage: (locale: LocalesValues) => void;
|
|
31
|
-
};
|
package/dist/format/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { useCompact } from './useCompact';
|
|
2
|
-
export { useCurrency } from './useCurrency';
|
|
3
|
-
export { useDate } from './useDate';
|
|
4
|
-
export { useIntl } from './useIntl';
|
|
5
|
-
export { useList } from './useList';
|
|
6
|
-
export { useNumber } from './useNumber';
|
|
7
|
-
export { usePercentage } from './usePercentage';
|
|
8
|
-
export { useRelativeTime } from './useRelativeTime';
|
|
9
|
-
export { useUnit } from './useUnit';
|
package/dist/format/useDate.d.ts
DELETED
package/dist/format/useList.d.ts
DELETED
package/dist/format/useUnit.d.ts
DELETED
package/dist/getDictionary.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Dictionary } from '@intlayer/types/dictionary';
|
|
2
|
-
import { DeclaredLocales, LocalesValues } from '@intlayer/types/module_augmentation';
|
|
3
|
-
import { DeepTransformContent } from './plugins';
|
|
4
|
-
export declare const getDictionary: <T extends Dictionary, L extends LocalesValues = DeclaredLocales>(dictionary: T, locale?: L) => DeepTransformContent<T["content"], L>;
|
package/dist/getIntlayer.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { DeclaredLocales, DictionaryKeys, DictionaryRegistryContent, LocalesValues } from '@intlayer/types/module_augmentation';
|
|
2
|
-
import { DeepTransformContent } from './plugins';
|
|
3
|
-
export declare const getIntlayer: <T extends DictionaryKeys, L extends LocalesValues = DeclaredLocales>(key: T, locale?: L) => DeepTransformContent<DictionaryRegistryContent<T>, L>;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { HTMLComponents } from './types';
|
|
2
|
-
export type RenderHTMLProps = {
|
|
3
|
-
components?: HTMLComponents<'permissive', {}>;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* Renders an HTML string directly, without a global provider.
|
|
7
|
-
* Returns the raw string unchanged.
|
|
8
|
-
*/
|
|
9
|
-
export declare const renderHTML: (content: string, _props?: RenderHTMLProps) => string;
|
|
10
|
-
/**
|
|
11
|
-
* Returns a render function that uses the global provider's configuration
|
|
12
|
-
* (installed via `installIntlayerHTML`), falling back to identity.
|
|
13
|
-
*/
|
|
14
|
-
export declare const useHTMLRenderer: ({ components, }?: RenderHTMLProps) => ((content: string) => string);
|
package/dist/html/index.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { type RenderHTMLProps, renderHTML, useHTMLRenderer, } from './HTMLRenderer';
|
|
2
|
-
export { type IntlayerHTMLPluginOptions, type IntlayerHTMLProvider, installIntlayerHTML, installIntlayerHTMLDynamic, type RenderHTMLFunction, type RenderHTMLOptions, useHTML, } from './installIntlayerHTML';
|
|
3
|
-
export type { HTMLComponents } from './types';
|
package/dist/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { LocalesValues } from '@intlayer/types/module_augmentation';
|
|
2
|
-
import { IInterpreterPluginVanilla } from './plugins';
|
|
3
|
-
declare module '@intlayer/core/interpreter' {
|
|
4
|
-
interface IInterpreterPlugin<T, S, L extends LocalesValues> extends IInterpreterPluginVanilla<T, S, L> {
|
|
5
|
-
}
|
|
6
|
-
}
|
|
7
|
-
export * from './client';
|
|
8
|
-
export * from './editor/useEditor';
|
|
9
|
-
export * from './getDictionary';
|
|
10
|
-
export * from './getIntlayer';
|
|
11
|
-
export * from './plugins';
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { internationalization as e } from "@intlayer/config/built";
|
|
2
|
-
import { setIntlayerIdentifier as t } from "@intlayer/config/client";
|
|
3
|
-
import { isEnabled as n } from "@intlayer/editor/isEnabled";
|
|
4
|
-
//#region src/editor/useEditor.ts
|
|
5
|
-
var r = () => {
|
|
6
|
-
if (process.env.INTLAYER_EDITOR_ENABLED === "false" || !n) return () => {};
|
|
7
|
-
let e = null, t = !1;
|
|
8
|
-
return import("@intlayer/editor").then(({ initEditorClient: n }) => {
|
|
9
|
-
if (t) return;
|
|
10
|
-
let r = n(), i = s();
|
|
11
|
-
r.currentLocale.set(i.locale), e = i.subscribe((e) => {
|
|
12
|
-
r.currentLocale.set(e);
|
|
13
|
-
});
|
|
14
|
-
}), () => {
|
|
15
|
-
t = !0, e?.(), import("@intlayer/editor").then(({ stopEditorClient: e }) => {
|
|
16
|
-
e();
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
}, i = class {
|
|
20
|
-
_locale;
|
|
21
|
-
_listeners = /* @__PURE__ */ new Set();
|
|
22
|
-
isCookieEnabled;
|
|
23
|
-
constructor(n, r = !0) {
|
|
24
|
-
let { defaultLocale: i } = e ?? {};
|
|
25
|
-
t(), this._locale = n ?? i, this.isCookieEnabled = r;
|
|
26
|
-
}
|
|
27
|
-
get locale() {
|
|
28
|
-
return this._locale;
|
|
29
|
-
}
|
|
30
|
-
setLocale(e) {
|
|
31
|
-
this._locale = e;
|
|
32
|
-
for (let t of this._listeners) t(e);
|
|
33
|
-
}
|
|
34
|
-
subscribe(e) {
|
|
35
|
-
return this._listeners.add(e), () => {
|
|
36
|
-
this._listeners.delete(e);
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
notify() {
|
|
40
|
-
for (let e of this._listeners) e(this._locale);
|
|
41
|
-
}
|
|
42
|
-
}, a = null, o = (e, t = !0) => a || (a = new i(e, t), a), s = () => (a ||= new i(), a), c = ({ locale: e, isCookieEnabled: t } = {}) => {
|
|
43
|
-
let n = o(e, t);
|
|
44
|
-
return r(), n;
|
|
45
|
-
};
|
|
46
|
-
//#endregion
|
|
47
|
-
export { r as a, c as i, o as n, s as r, i as t };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require(`./plugins-Bp8aaTny.js`);let e=require(`@intlayer/config/built`),t=require(`@intlayer/config/client`),n=require(`@intlayer/editor/isEnabled`);var r=()=>{if(process.env.INTLAYER_EDITOR_ENABLED===`false`||!n.isEnabled)return()=>{};let e=null,t=!1;return import(`@intlayer/editor`).then(({initEditorClient:n})=>{if(t)return;let r=n(),i=s();r.currentLocale.set(i.locale),e=i.subscribe(e=>{r.currentLocale.set(e)})}),()=>{t=!0,e?.(),import(`@intlayer/editor`).then(({stopEditorClient:e})=>{e()})}},i=class{_locale;_listeners=new Set;isCookieEnabled;constructor(n,r=!0){let{defaultLocale:i}=e.internationalization??{};(0,t.setIntlayerIdentifier)(),this._locale=n??i,this.isCookieEnabled=r}get locale(){return this._locale}setLocale(e){this._locale=e;for(let t of this._listeners)t(e)}subscribe(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}notify(){for(let e of this._listeners)e(this._locale)}},a=null,o=(e,t=!0)=>a||(a=new i(e,t),a),s=()=>(a||=new i,a),c=({locale:e,isCookieEnabled:t}={})=>{let n=o(e,t);return r(),n};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return i}});
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { HTMLComponents } from '../html/types';
|
|
2
|
-
import { MarkdownProviderOptions } from './installIntlayerMarkdown';
|
|
3
|
-
export type RenderMarkdownProps = MarkdownProviderOptions & {
|
|
4
|
-
components?: HTMLComponents<'permissive', {}>;
|
|
5
|
-
wrapper?: string;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Renders markdown to an HTML string without using the global provider.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* import { renderMarkdown } from 'vanilla-intlayer/markdown';
|
|
13
|
-
*
|
|
14
|
-
* document.querySelector('#content').innerHTML = renderMarkdown('# Hello **World**');
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export declare const renderMarkdown: (content: string, { forceBlock, forceInline, preserveFrontmatter, tagfilter, }?: RenderMarkdownProps) => string;
|
|
18
|
-
/**
|
|
19
|
-
* Returns a render function that uses the global provider's configuration
|
|
20
|
-
* (installed via `installIntlayerMarkdown`), falling back to `compileMarkdown`.
|
|
21
|
-
*/
|
|
22
|
-
export declare const useMarkdownRenderer: (props?: RenderMarkdownProps) => ((content: string) => string | Promise<string>);
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { CompileOptions, sanitizer as defaultSanitizer, slugify as defaultSlugify, RuleType } from '@intlayer/core/markdown';
|
|
2
|
-
export { defaultSanitizer as sanitizer, defaultSlugify as slugify, RuleType };
|
|
3
|
-
export type MarkdownCompilerOptions = CompileOptions;
|
|
4
|
-
/**
|
|
5
|
-
* Compile markdown to an HTML string.
|
|
6
|
-
*
|
|
7
|
-
* The resulting string can be inserted into the DOM via `element.innerHTML`
|
|
8
|
-
* or the `renderMarkdown` helper.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```ts
|
|
12
|
-
* import { compileMarkdown } from 'vanilla-intlayer/markdown';
|
|
13
|
-
*
|
|
14
|
-
* document.querySelector('#content').innerHTML = compileMarkdown('# Hello **World**');
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
17
|
-
export declare const compileMarkdown: (markdown?: string, options?: MarkdownCompilerOptions) => string;
|
|
18
|
-
export declare const compiler: (markdown?: string, options?: MarkdownCompilerOptions) => string;
|
|
19
|
-
export declare const compile: (markdown?: string, options?: MarkdownCompilerOptions) => string;
|
package/dist/markdown/index.d.ts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { compileMarkdown } from './compiler';
|
|
2
|
-
export { type IntlayerMarkdownPluginOptions, type IntlayerMarkdownProvider, installIntlayerMarkdown, installIntlayerMarkdownDynamic, type MarkdownProviderOptions, type RenderMarkdownFunction, useMarkdown, } from './installIntlayerMarkdown';
|
|
3
|
-
export { type RenderMarkdownProps, renderMarkdown, useMarkdownRenderer, } from './MarkdownRenderer';
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { HTMLComponents } from '../html/types';
|
|
2
|
-
export type MarkdownProviderOptions = {
|
|
3
|
-
/** Forces the compiler to always output content with a block-level wrapper. */
|
|
4
|
-
forceBlock?: boolean;
|
|
5
|
-
/** Forces the compiler to always output content with an inline wrapper. */
|
|
6
|
-
forceInline?: boolean;
|
|
7
|
-
/** Whether to preserve frontmatter in the markdown content. */
|
|
8
|
-
preserveFrontmatter?: boolean;
|
|
9
|
-
/** Whether to use the GitHub Tag Filter. */
|
|
10
|
-
tagfilter?: boolean;
|
|
11
|
-
};
|
|
12
|
-
export type RenderMarkdownOptions = MarkdownProviderOptions & {
|
|
13
|
-
components?: HTMLComponents<'permissive', {}>;
|
|
14
|
-
wrapper?: string;
|
|
15
|
-
};
|
|
16
|
-
export type RenderMarkdownFunction = (markdown: string, options?: MarkdownProviderOptions, components?: HTMLComponents<'permissive', {}>, wrapper?: string) => string | Promise<string>;
|
|
17
|
-
export type IntlayerMarkdownProvider = {
|
|
18
|
-
components?: HTMLComponents<'permissive', {}>;
|
|
19
|
-
renderMarkdown: RenderMarkdownFunction;
|
|
20
|
-
};
|
|
21
|
-
export type IntlayerMarkdownPluginOptions = MarkdownProviderOptions & {
|
|
22
|
-
components?: HTMLComponents<'permissive', {}>;
|
|
23
|
-
wrapper?: string;
|
|
24
|
-
renderMarkdown?: RenderMarkdownFunction;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Create and return a single IntlayerMarkdownProvider instance.
|
|
28
|
-
*/
|
|
29
|
-
export declare const createIntlayerMarkdownClient: (renderMarkdown: RenderMarkdownFunction, components?: HTMLComponents<"permissive", {}>) => IntlayerMarkdownProvider;
|
|
30
|
-
/**
|
|
31
|
-
* Install the Intlayer Markdown provider for your vanilla JS application.
|
|
32
|
-
*
|
|
33
|
-
* @example
|
|
34
|
-
* ```ts
|
|
35
|
-
* import { installIntlayerMarkdown } from 'vanilla-intlayer/markdown';
|
|
36
|
-
*
|
|
37
|
-
* installIntlayerMarkdown({ forceBlock: true });
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
export declare const installIntlayerMarkdown: (pluginOptions?: IntlayerMarkdownPluginOptions | RenderMarkdownFunction) => IntlayerMarkdownProvider;
|
|
41
|
-
/**
|
|
42
|
-
* Access the installed IntlayerMarkdownProvider.
|
|
43
|
-
* Returns a fallback renderer that compiles with default options if no
|
|
44
|
-
* provider has been installed.
|
|
45
|
-
*/
|
|
46
|
-
export declare const useMarkdown: () => IntlayerMarkdownProvider;
|
|
47
|
-
/**
|
|
48
|
-
* Asynchronously install a markdown renderer whose implementation is loaded
|
|
49
|
-
* via a dynamic `import()`.
|
|
50
|
-
*
|
|
51
|
-
* Use this to keep the markdown compiler out of the initial bundle — the
|
|
52
|
-
* loader is only called the first time this function is executed.
|
|
53
|
-
*
|
|
54
|
-
* The returned promise resolves once the provider is ready. Any calls to
|
|
55
|
-
* `useMarkdown()` before the promise resolves will use the fallback
|
|
56
|
-
* (raw-string) renderer.
|
|
57
|
-
*
|
|
58
|
-
* @param loader - A zero-argument async function that resolves to either a
|
|
59
|
-
* `RenderMarkdownFunction` or an `IntlayerMarkdownPluginOptions` object.
|
|
60
|
-
*
|
|
61
|
-
* @example
|
|
62
|
-
* ```ts
|
|
63
|
-
* // Load a custom markdown renderer (e.g. marked) only when needed
|
|
64
|
-
* await installIntlayerMarkdownDynamic(async () => {
|
|
65
|
-
* const { marked } = await import('marked');
|
|
66
|
-
* return (markdown) => marked(markdown) as string;
|
|
67
|
-
* });
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
export declare const installIntlayerMarkdownDynamic: (loader: () => Promise<IntlayerMarkdownPluginOptions | RenderMarkdownFunction>) => Promise<IntlayerMarkdownProvider>;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { MarkdownRuntime } from '@intlayer/core/markdown';
|
|
2
|
-
/**
|
|
3
|
-
* Vanilla-specific MarkdownRuntime that produces HTML strings.
|
|
4
|
-
*/
|
|
5
|
-
export declare const vanillaRuntime: MarkdownRuntime;
|
|
6
|
-
/**
|
|
7
|
-
* Creates a vanilla runtime with a custom createElement for advanced use cases.
|
|
8
|
-
*/
|
|
9
|
-
export declare const createVanillaRuntime: (options?: {
|
|
10
|
-
onCreateElement?: (type: any, props: Record<string, any> | null, children: any[]) => string;
|
|
11
|
-
}) => MarkdownRuntime;
|
|
12
|
-
export default vanillaRuntime;
|
package/dist/plugins-Bp8aaTny.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=require(`./cjs/renderIntlayerNode.cjs`);let l=require(`@intlayer/core/interpreter`),u=require(`@intlayer/config/built`),d=require(`@intlayer/core/markdown`),f=require(`@intlayer/types/nodeType`);f=s(f);var p=e=>e.replace(/&/g,`&`).replace(/"/g,`"`),m=e=>e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`),h={id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(e,{children:t,keyPath:n,dictionaryKey:r,...i})=>{if(process.env.INTLAYER_EDITOR_ENABLED!==`false`&&u.editor.enabled){let e=String(t??``),a=JSON.stringify(n??[]),o=String(r??``),s=`<intlayer-content-selector-wrapper key-path="${p(a)}" dictionary-key="${p(o)}">${m(e)}</intlayer-content-selector-wrapper>`;return c.renderIntlayerNode({...i,value:t,children:s,keyPath:n,dictionaryKey:r,additionalProps:{toElement:()=>{let t=document.createElement(`intlayer-content-selector-wrapper`);return t.setAttribute(`key-path`,a),t.setAttribute(`dictionary-key`,o),t.textContent=e,t}}})}return c.renderIntlayerNode({...i,value:t,children:t})}},g=process.env.INTLAYER_NODE_TYPE_INSERTION===`false`?l.fallbackPlugin:{id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===f.INSERTION,transform:(e,t,n)=>{let r=[...t.keyPath,{type:f.INSERTION}],i=e[f.INSERTION],a={id:`insertion-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,n,r)=>{let i=r(e,{...n,children:e,plugins:(t.plugins??[]).filter(e=>e.id!==`intlayer-node-plugin`)});return e=>{let a=(0,l.splitInsertionTemplate)(i,e),o=a.isSimple?a.parts:a.parts.join(``);return r(o,{...n,plugins:t.plugins,children:o})}}},o=n(i,{...t,children:i,keyPath:r,plugins:[a,...t.plugins??[]]});return typeof i==`object`&&i&&`nodeType`in i&&[f.ENUMERATION,f.CONDITION].includes(i.nodeType)?e=>t=>{let n=o(t);return typeof n==`function`?n(e):n}:o}},_={createElement:(e,t,...n)=>{let r=Object.entries(t||{}).filter(([e])=>e!==`children`&&e!==`key`&&e!==`_innerHTML`).map(([e,t])=>`${e}="${t}"`).join(` `),i=t?._innerHTML,a=i===void 0?n.flat(1/0).join(``):i;return`<${e}${r?` ${r}`:``}>${a}</${e}>`},normalizeProps:(e,t)=>{let n={};for(let[e,r]of Object.entries(t))e===`className`?n.class=r:e===`htmlFor`?n.for=r:e===`dangerouslySetInnerHTML`&&r?.__html?n._innerHTML=r.__html:n[e]=r;return n}},v=process.env.INTLAYER_NODE_TYPE_MARKDOWN===`false`?l.fallbackPlugin:{id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,t,n)=>{let{plugins:r,...i}=t,a=n((0,d.getMarkdownMetadata)(e)??{},{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(t,n)=>c.renderIntlayerNode({...n,value:t,children:e})}],dictionaryKey:i.dictionaryKey,keyPath:[]}),o=(t={})=>(0,d.compileWithOptions)(e,{..._,createElement:(e,n,...r)=>{let i=t[e];return typeof i==`function`?i({...n,children:r.join(``)}):_.createElement(e,n,...r)}},{}),s=o(),l=e;if(process.env.INTLAYER_EDITOR_ENABLED!==`false`&&u.editor.enabled){let e=JSON.stringify(t.keyPath??[]),n=String(t.dictionaryKey??``);l=`<intlayer-content-selector-wrapper key-path="${p(e)}" dictionary-key="${p(n)}">${m(s)}</intlayer-content-selector-wrapper>`}return c.renderIntlayerNode({...t,value:s,children:l,additionalProps:{metadata:a,use:e=>o(e)}})}},y=process.env.INTLAYER_NODE_TYPE_MARKDOWN===`false`?l.fallbackPlugin:{id:`markdown-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===f.MARKDOWN,transform:(e,t,n)=>{let r=[...t.keyPath,{type:f.MARKDOWN}],i=e[f.MARKDOWN];return n(i,{...t,children:i,keyPath:r,plugins:[v,...t.plugins??[]]})}},b=process.env.INTLAYER_NODE_TYPE_HTML===`false`?l.fallbackPlugin:{id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===f.HTML,transform:(e,t)=>{let n=e[f.HTML],r=(e={})=>{let t=(0,l.getHTML)(n,new Proxy(e,{get(e,t){if(typeof t==`string`&&t in e){let n=e[t];return e=>{let t=Array.isArray(e.children)?e.children.join(``):e.children;return n({...e,children:t})}}if(typeof t==`string`&&/^[a-z][a-z0-9]*$/.test(t))return e=>{let n=Object.entries(e).filter(([e])=>e!==`children`&&e!==`key`).map(([e,t])=>`${e}="${t}"`).join(` `),r=Array.isArray(e.children)?e.children.join(``):e.children;return`<${t}${n?` ${n}`:``}>${r}</${t}>`}}}));return Array.isArray(t)?t.join(``):t},i=r(),a=n;if(process.env.INTLAYER_EDITOR_ENABLED!==`false`&&u.editor.enabled){let e=JSON.stringify(t.keyPath??[]),n=String(t.dictionaryKey??``);a=`<intlayer-content-selector-wrapper key-path="${p(e)}" dictionary-key="${p(n)}">${m(i)}</intlayer-content-selector-wrapper>`}return c.renderIntlayerNode({...t,value:i,children:a,additionalProps:{use:e=>r(e)}})}},x=new Map,S=(e,t=!0)=>{let n=`${e??u.internationalization.defaultLocale}_${t}`;if(x.has(n))return x.get(n);let r=[(0,l.translationPlugin)(e??u.internationalization.defaultLocale,t?u.internationalization.defaultLocale:void 0),l.enumerationPlugin,l.conditionPlugin,(0,l.nestedPlugin)(e??u.internationalization.defaultLocale),l.filePlugin,l.genderPlugin,h,g,y,b];return x.set(n,r),r};Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return S}});
|