react-intlayer 9.4.3 → 9.5.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/README.md +0 -2
- package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -1
- package/dist/cjs/markdown/processor.cjs +4 -13
- package/dist/cjs/markdown/processor.cjs.map +1 -1
- package/dist/cjs/markdown/runtime.cjs +31 -3
- package/dist/cjs/markdown/runtime.cjs.map +1 -1
- package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -1
- package/dist/esm/markdown/processor.mjs +4 -13
- package/dist/esm/markdown/processor.mjs.map +1 -1
- package/dist/esm/markdown/runtime.mjs +31 -3
- package/dist/esm/markdown/runtime.mjs.map +1 -1
- package/dist/types/IntlayerNode.d.ts +2 -3
- package/dist/types/IntlayerNode.d.ts.map +1 -1
- package/dist/types/UI/ContentSelector.d.ts +1 -2
- package/dist/types/UI/ContentSelector.d.ts.map +1 -1
- package/dist/types/analytics/AnalyticsProvider.d.ts +1 -2
- package/dist/types/analytics/AnalyticsProvider.d.ts.map +1 -1
- package/dist/types/analytics/exposureSink.d.ts +4 -5
- package/dist/types/analytics/exposureSink.d.ts.map +1 -1
- package/dist/types/analytics/useAnalytics.d.ts +1 -2
- package/dist/types/analytics/useAnalytics.d.ts.map +1 -1
- package/dist/types/analytics/useConversion.d.ts +2 -3
- package/dist/types/analytics/useConversion.d.ts.map +1 -1
- package/dist/types/analytics/useExperiment.d.ts +2 -3
- package/dist/types/analytics/useExperiment.d.ts.map +1 -1
- package/dist/types/client/IntlayerProvider.d.ts +5 -6
- package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
- package/dist/types/client/format/useCompact.d.ts +2 -4
- package/dist/types/client/format/useCompact.d.ts.map +1 -1
- package/dist/types/client/format/useCurrency.d.ts +2 -4
- package/dist/types/client/format/useCurrency.d.ts.map +1 -1
- package/dist/types/client/format/useDate.d.ts +1 -2
- package/dist/types/client/format/useDate.d.ts.map +1 -1
- package/dist/types/client/format/useIntl.d.ts +1 -2
- package/dist/types/client/format/useIntl.d.ts.map +1 -1
- package/dist/types/client/format/useList.d.ts +2 -8
- package/dist/types/client/format/useList.d.ts.map +1 -1
- package/dist/types/client/format/useNumber.d.ts +2 -4
- package/dist/types/client/format/useNumber.d.ts.map +1 -1
- package/dist/types/client/format/usePercentage.d.ts +2 -4
- package/dist/types/client/format/usePercentage.d.ts.map +1 -1
- package/dist/types/client/format/useRelativeTime.d.ts +2 -4
- package/dist/types/client/format/useRelativeTime.d.ts.map +1 -1
- package/dist/types/client/format/useUnit.d.ts +2 -4
- package/dist/types/client/format/useUnit.d.ts.map +1 -1
- package/dist/types/client/t.d.ts +1 -2
- package/dist/types/client/t.d.ts.map +1 -1
- package/dist/types/client/useDictionary.d.ts +1 -2
- package/dist/types/client/useDictionary.d.ts.map +1 -1
- package/dist/types/client/useDictionaryAsync.d.ts +1 -2
- package/dist/types/client/useDictionaryAsync.d.ts.map +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts +1 -2
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/client/useI18n.d.ts +2 -3
- package/dist/types/client/useI18n.d.ts.map +1 -1
- package/dist/types/client/useIntlayer.d.ts +1 -2
- package/dist/types/client/useIntlayer.d.ts.map +1 -1
- package/dist/types/client/useLoadDynamic.d.ts +2 -3
- package/dist/types/client/useLoadDynamic.d.ts.map +1 -1
- package/dist/types/client/useLocale.d.ts +3 -4
- package/dist/types/client/useLocale.d.ts.map +1 -1
- package/dist/types/client/useLocaleBase.d.ts +3 -5
- package/dist/types/client/useLocaleBase.d.ts.map +1 -1
- package/dist/types/client/useLocaleStorage.d.ts +7 -9
- package/dist/types/client/useLocaleStorage.d.ts.map +1 -1
- package/dist/types/client/usePathname.d.ts +1 -2
- package/dist/types/client/usePathname.d.ts.map +1 -1
- package/dist/types/client/useRewriteURL.d.ts +1 -2
- package/dist/types/client/useRewriteURL.d.ts.map +1 -1
- package/dist/types/client/useTraduction.d.ts +1 -2
- package/dist/types/client/useTraduction.d.ts.map +1 -1
- package/dist/types/editor/ContentSelector.d.ts +2 -3
- package/dist/types/editor/ContentSelector.d.ts.map +1 -1
- package/dist/types/editor/EditorProvider.d.ts +1 -2
- package/dist/types/editor/EditorProvider.d.ts.map +1 -1
- package/dist/types/editor/useEditor.d.ts +1 -2
- package/dist/types/editor/useEditor.d.ts.map +1 -1
- package/dist/types/getDictionary.d.ts +1 -2
- package/dist/types/getDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayer.d.ts +1 -2
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/html/HTMLComponentTypes.d.ts +2 -3
- package/dist/types/html/HTMLComponentTypes.d.ts.map +1 -1
- package/dist/types/html/HTMLProvider.d.ts +2 -3
- package/dist/types/html/HTMLProvider.d.ts.map +1 -1
- package/dist/types/html/HTMLRenderer.d.ts +5 -6
- package/dist/types/html/HTMLRenderer.d.ts.map +1 -1
- package/dist/types/html/HTMLRendererPlugin.d.ts +1 -2
- package/dist/types/html/HTMLRendererPlugin.d.ts.map +1 -1
- package/dist/types/html/types.d.ts +1 -2
- package/dist/types/html/types.d.ts.map +1 -1
- package/dist/types/index.d.ts +10 -18
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownProvider.d.ts +5 -6
- package/dist/types/markdown/MarkdownProvider.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownRenderer.d.ts +5 -6
- package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownRendererPlugin.d.ts +1 -2
- package/dist/types/markdown/MarkdownRendererPlugin.d.ts.map +1 -1
- package/dist/types/markdown/processor.d.ts +4 -4
- package/dist/types/markdown/processor.d.ts.map +1 -1
- package/dist/types/markdown/runtime.d.ts +2 -3
- package/dist/types/markdown/runtime.d.ts.map +1 -1
- package/dist/types/plugins.d.ts +16 -17
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/reactElement/renderReactElement.d.ts +1 -2
- package/dist/types/reactElement/renderReactElement.d.ts.map +1 -1
- package/dist/types/server/IntlayerServerProvider.d.ts +8 -9
- package/dist/types/server/IntlayerServerProvider.d.ts.map +1 -1
- package/dist/types/server/format/useCompact.d.ts +1 -2
- package/dist/types/server/format/useCompact.d.ts.map +1 -1
- package/dist/types/server/format/useCurrency.d.ts +1 -2
- package/dist/types/server/format/useCurrency.d.ts.map +1 -1
- package/dist/types/server/format/useDate.d.ts +1 -2
- package/dist/types/server/format/useDate.d.ts.map +1 -1
- package/dist/types/server/format/useIntl.d.ts +1 -2
- package/dist/types/server/format/useIntl.d.ts.map +1 -1
- package/dist/types/server/format/useList.d.ts +1 -2
- package/dist/types/server/format/useList.d.ts.map +1 -1
- package/dist/types/server/format/useNumber.d.ts +1 -2
- package/dist/types/server/format/useNumber.d.ts.map +1 -1
- package/dist/types/server/format/usePercentage.d.ts +1 -2
- package/dist/types/server/format/usePercentage.d.ts.map +1 -1
- package/dist/types/server/format/useRelativeTime.d.ts +1 -2
- package/dist/types/server/format/useRelativeTime.d.ts.map +1 -1
- package/dist/types/server/format/useUnit.d.ts +1 -2
- package/dist/types/server/format/useUnit.d.ts.map +1 -1
- package/dist/types/server/serverContext.d.ts +3 -4
- package/dist/types/server/serverContext.d.ts.map +1 -1
- package/dist/types/server/t.d.ts +1 -2
- package/dist/types/server/t.d.ts.map +1 -1
- package/dist/types/server/useDictionary.d.ts +1 -2
- package/dist/types/server/useDictionary.d.ts.map +1 -1
- package/dist/types/server/useDictionaryAsync.d.ts +1 -2
- package/dist/types/server/useDictionaryAsync.d.ts.map +1 -1
- package/dist/types/server/useDictionaryDynamic.d.ts +1 -2
- package/dist/types/server/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/server/useI18n.d.ts +2 -3
- package/dist/types/server/useI18n.d.ts.map +1 -1
- package/dist/types/server/useIntlayer.d.ts +1 -2
- package/dist/types/server/useIntlayer.d.ts.map +1 -1
- package/dist/types/server/useLoadDynamic.d.ts +1 -2
- package/dist/types/server/useLoadDynamic.d.ts.map +1 -1
- package/dist/types/server/useLocale.d.ts +2 -3
- package/dist/types/server/useLocale.d.ts.map +1 -1
- package/package.json +11 -11
- package/dist/types/intlayer/dist/types/index.d.ts +0 -14
package/README.md
CHANGED
|
@@ -69,8 +69,6 @@ With **per-locale content files**, **TypeScript autocompletion**, **tree-shakabl
|
|
|
69
69
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/interoperability.png?raw=true" alt="Feature" width="700"> | **Interoperability**<br><br>Allow interoperability with react-i18next, next-i18next, next-intl, react-intl, vue-i18n. <br><br> - [Intlayer and react-intl](https://intlayer.org/blog/intlayer-with-react-intl) <br> - [Intlayer and next-intl](https://intlayer.org/blog/intlayer-with-next-intl) <br> - [Intlayer and next-i18next](https://intlayer.org/blog/intlayer-with-next-i18next) <br> - [Intlayer and vue-i18n](https://intlayer.org/blog/intlayer-with-vue-i18n) <br> - [Intlayer compat adapters](https://intlayer.org/doc/compatibility) |
|
|
70
70
|
| <img src="https://github.com/aymericzip/intlayer/blob/main/docs/assets/benchmark.png?raw=true" alt="Feature" width="700"> | **Performances & Benchmark**<br><br>Uses advanced tree-shaking and dynamic loading to boost performances and keep the solution as light as possible. <br><br> - [Performances & Benchmark](https://intlayer.org/doc/benchmark) |
|
|
71
71
|
|
|
72
|
-
---
|
|
73
|
-
|
|
74
72
|
## 📦 Installation
|
|
75
73
|
|
|
76
74
|
Start your journey with Intlayer today and experience a smoother, more powerful approach to internationalization.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownProvider.cjs","names":["createContext","useContext","compileMarkdown"],"sources":["../../../src/markdown/MarkdownProvider.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n type FC,\n type HTMLAttributes,\n type PropsWithChildren,\n type ReactNode,\n useContext,\n} from 'react';\nimport type { HTMLComponents } from '../html/HTMLComponentTypes';\nimport {\n compileMarkdown,\n type MarkdownRendererOptions,\n type ParsedMarkdown,\n} from './processor';\n\nexport type MarkdownProviderOptions = {\n /** Forces the compiler to always output content with a block-level wrapper. */\n forceBlock?: boolean;\n /** Forces the compiler to always output content with an inline wrapper. */\n forceInline?: boolean;\n /** Whether to preserve frontmatter in the markdown content. */\n preserveFrontmatter?: boolean;\n /** Whether to use the GitHub Tag Filter for security. */\n tagfilter?: boolean;\n};\n\
|
|
1
|
+
{"version":3,"file":"MarkdownProvider.cjs","names":["createContext","useContext","compileMarkdown"],"sources":["../../../src/markdown/MarkdownProvider.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n type FC,\n type HTMLAttributes,\n type PropsWithChildren,\n type ReactNode,\n useContext,\n} from 'react';\nimport type { HTMLComponents } from '../html/HTMLComponentTypes';\nimport {\n compileMarkdown,\n type MarkdownRendererOptions,\n type ParsedMarkdown,\n} from './processor';\n\nexport type MarkdownProviderOptions = {\n /** Forces the compiler to always output content with a block-level wrapper. */\n forceBlock?: boolean;\n /** Forces the compiler to always output content with an inline wrapper. */\n forceInline?: boolean;\n /** Whether to preserve frontmatter in the markdown content. */\n preserveFrontmatter?: boolean;\n /** Whether to use the GitHub Tag Filter for security. */\n tagfilter?: boolean;\n};\n\nexport type MarkdownContextValue = {\n components?: HTMLComponents<'permissive', {}>;\n renderMarkdown: (\n markdown: string | ParsedMarkdown,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: FC<HTMLAttributes<HTMLElement>>\n ) => ReactNode | Promise<ReactNode>;\n};\n\nexport type MarkdownProviderProps = PropsWithChildren<\n MarkdownProviderOptions & {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: FC<HTMLAttributes<HTMLElement>>;\n renderMarkdown?: (\n markdown: string | ParsedMarkdown,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: FC<HTMLAttributes<HTMLElement>>\n ) => ReactNode | Promise<ReactNode>;\n }\n>;\n\nconst MarkdownContext = createContext<MarkdownContextValue | undefined>(\n undefined\n);\n\n/**\n * Returns the raw `MarkdownProvider` context value — the active\n * `renderMarkdown` function plus any provider-level component overrides.\n * Returns `undefined` when called outside a `<MarkdownProvider>`.\n * Prefer `useMarkdownRenderer` for most use cases; use this hook only when\n * you need direct access to the context object itself.\n */\nexport const useMarkdownContext = () => useContext(MarkdownContext);\n\nconst mergeOptions = (\n baseOptions: MarkdownRendererOptions,\n options: MarkdownProviderOptions = {},\n components: HTMLComponents<'permissive', {}> = {},\n wrapper?: FC<HTMLAttributes<HTMLElement>>\n): MarkdownRendererOptions => {\n return {\n ...baseOptions,\n ...options,\n forceBlock: options.forceBlock ?? baseOptions.forceBlock,\n forceInline: options.forceInline ?? baseOptions.forceInline,\n preserveFrontmatter:\n options.preserveFrontmatter ?? baseOptions.preserveFrontmatter,\n tagfilter: options.tagfilter ?? baseOptions.tagfilter,\n wrapper: wrapper || baseOptions.wrapper,\n\n forceWrapper: !!(wrapper || baseOptions.wrapper),\n components: { ...baseOptions.components, ...components },\n };\n};\n\n/**\n * Provider for the MarkdownRenderer component.\n *\n * It will provide the `renderMarkdown` function to the context, which can be used to render markdown.\n *\n * ```tsx\n * const content = useIntlayer('app');\n *\n * return (\n * <div>\n * {content.markdown} // Will be rendered with the components and options provided to the MarkdownProvider\n * </div>\n * );\n * ```\n *\n * @example\n * ```tsx\n * <MarkdownProvider components={{ h1: CustomHeading }}>\n * <MarkdownRenderer>\n * {markdownContent}\n * </MarkdownRenderer>\n * </MarkdownProvider>\n * ```\n */\nexport const MarkdownProvider: FC<MarkdownProviderProps> = ({\n children,\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRenderFn,\n}) => {\n const baseOptions: MarkdownRendererOptions = {\n components,\n forceBlock,\n forceInline,\n wrapper,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n // Standard internal renderer\n const defaultRenderMarkdown = (\n markdown: string | ParsedMarkdown,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: FC<HTMLAttributes<HTMLElement>>\n ) => {\n const mergedOptions = mergeOptions(\n baseOptions,\n options,\n components,\n wrapper\n );\n\n return compileMarkdown(markdown, mergedOptions);\n };\n\n // Wrapper for user-provided custom renderer\n // Note: We wrap in a clean Provider to prevent infinite recursion\n const customRenderMarkdownWrapper = (\n markdown: string | ParsedMarkdown,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: FC<HTMLAttributes<HTMLElement>>\n ) => (\n <MarkdownContext.Provider value={undefined}>\n {customRenderFn?.(markdown, options, components, wrapper) as ReactNode}\n </MarkdownContext.Provider>\n );\n\n return (\n <MarkdownContext.Provider\n value={{\n components,\n renderMarkdown: customRenderFn\n ? customRenderMarkdownWrapper\n : defaultRenderMarkdown,\n }}\n >\n {children}\n </MarkdownContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;AAmDA,MAAM,sBAAkBA,qBACtB,MACF;;;;;;;;AASA,MAAa,+BAA2BC,kBAAW,eAAe;AAElE,MAAM,gBACJ,aACA,UAAmC,CAAC,GACpC,aAA+C,CAAC,GAChD,YAC4B;CAC5B,OAAO;EACL,GAAG;EACH,GAAG;EACH,YAAY,QAAQ,cAAc,YAAY;EAC9C,aAAa,QAAQ,eAAe,YAAY;EAChD,qBACE,QAAQ,uBAAuB,YAAY;EAC7C,WAAW,QAAQ,aAAa,YAAY;EAC5C,SAAS,WAAW,YAAY;EAEhC,cAAc,CAAC,EAAE,WAAW,YAAY;EACxC,YAAY;GAAE,GAAG,YAAY;GAAY,GAAG;EAAW;CACzD;AACF;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,oBAA+C,EAC1D,UACA,YACA,SACA,YACA,aACA,qBACA,WACA,gBAAgB,qBACZ;CACJ,MAAM,cAAuC;EAC3C;EACA;EACA;EACA;EACA,cAAc,CAAC,CAAC;EAChB;EACA;CACF;CAGA,MAAM,yBACJ,UACA,SACA,YACA,YACG;EACH,MAAM,gBAAgB,aACpB,aACA,SACA,YACA,OACF;EAEA,OAAOC,2CAAgB,UAAU,aAAa;CAChD;CAIA,MAAM,+BACJ,UACA,SACA,YACA,YAEA,2CAAC,gBAAgB,UAAjB;EAA0B,OAAO;YAC9B,iBAAiB,UAAU,SAAS,YAAY,OAAO;CAChC;CAG5B,OACE,2CAAC,gBAAgB,UAAjB;EACE,OAAO;GACL;GACA,gBAAgB,iBACZ,8BACA;EACN;EAEC;CACuB;AAE9B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_markdown_runtime = require('./runtime.cjs');
|
|
2
3
|
let _intlayer_core_markdown = require("@intlayer/core/markdown");
|
|
3
|
-
let react = require("react");
|
|
4
4
|
|
|
5
5
|
//#region src/markdown/processor.tsx
|
|
6
6
|
/**
|
|
@@ -9,15 +9,6 @@ let react = require("react");
|
|
|
9
9
|
* [simple-markdown v0.2.2](https://github.com/Khan/simple-markdown) from Khan Academy.
|
|
10
10
|
*/
|
|
11
11
|
/**
|
|
12
|
-
* Default React runtime for markdown rendering.
|
|
13
|
-
*/
|
|
14
|
-
const DEFAULT_RUNTIME = {
|
|
15
|
-
createElement: react.createElement,
|
|
16
|
-
cloneElement: react.cloneElement,
|
|
17
|
-
Fragment: react.Fragment,
|
|
18
|
-
normalizeProps: (_tag, props) => props
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
12
|
* **Step 1 of 2 — parse only.**
|
|
22
13
|
* Converts a raw markdown string into a `ParsedMarkdown` AST without rendering
|
|
23
14
|
* any React elements. Use this when you need to:
|
|
@@ -38,7 +29,7 @@ const DEFAULT_RUNTIME = {
|
|
|
38
29
|
const parseMarkdown = (markdown = "", options = {}) => {
|
|
39
30
|
const { disableAutoLink, disableParsingRawHTML, enforceAtxHeadings, forceBlock, forceInline, forceWrapper, namedCodesToUnicode, components, sanitizer, slugify, wrapper, preserveFrontmatter, tagfilter } = options;
|
|
40
31
|
return (0, _intlayer_core_markdown.parseMarkdown)(markdown, {
|
|
41
|
-
runtime:
|
|
32
|
+
runtime: require_markdown_runtime.reactRuntime,
|
|
42
33
|
components,
|
|
43
34
|
namedCodesToUnicode,
|
|
44
35
|
sanitizer,
|
|
@@ -74,9 +65,9 @@ const compileMarkdown = (input = "", options = {}) => {
|
|
|
74
65
|
const { createElement: customCreateElement, disableAutoLink, disableParsingRawHTML, enforceAtxHeadings, forceBlock, forceInline, forceWrapper, namedCodesToUnicode, components, renderRule, sanitizer, slugify, wrapper, preserveFrontmatter, tagfilter } = options;
|
|
75
66
|
const ctx = {
|
|
76
67
|
runtime: customCreateElement ? {
|
|
77
|
-
...
|
|
68
|
+
...require_markdown_runtime.reactRuntime,
|
|
78
69
|
createElement: customCreateElement
|
|
79
|
-
} :
|
|
70
|
+
} : require_markdown_runtime.reactRuntime,
|
|
80
71
|
components,
|
|
81
72
|
namedCodesToUnicode,
|
|
82
73
|
sanitizer,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processor.cjs","names":["
|
|
1
|
+
{"version":3,"file":"processor.cjs","names":["coreParseMarkdown","reactRuntime","coreCompile","coreRenderMarkdownAst"],"sources":["../../../src/markdown/processor.tsx"],"sourcesContent":["/**\n * it's a fork\n * [markdown-to-jsx v7.7.14](https://github.com/quantizor/markdown-to-jsx) from quantizor\n * [simple-markdown v0.2.2](https://github.com/Khan/simple-markdown) from Khan Academy.\n */\n\nimport {\n compile as coreCompile,\n parseMarkdown as coreParseMarkdown,\n renderMarkdownAst as coreRenderMarkdownAst,\n type MarkdownContext,\n type MarkdownOptions,\n type ParsedMarkdown,\n type RenderRuleHook,\n} from '@intlayer/core/markdown';\nimport type { createElement, JSX, ReactNode } from 'react';\nimport type { HTMLComponents } from '../html/HTMLComponentTypes';\nimport { reactRuntime } from './runtime';\n\ntype HTMLTags = keyof JSX.IntrinsicElements;\n\n/**\n * Refined MarkdownRendererOptions type.\n */\nexport type MarkdownRendererOptions = Partial<{\n /**\n * Ultimate control over the output of all rendered JSX.\n */\n createElement: (\n tag: Parameters<typeof createElement>[0],\n props: JSX.IntrinsicAttributes,\n ...children: ReactNode[]\n ) => ReactNode;\n\n /**\n * The library automatically generates an anchor tag for bare URLs included in the markdown\n * document, but this behavior can be disabled if desired.\n */\n disableAutoLink: boolean;\n\n /**\n * Disable the compiler's best-effort transcription of provided raw HTML\n * into JSX-equivalent.\n */\n disableParsingRawHTML: boolean;\n\n /**\n * Forces the compiler to have space between hash sign and the header text.\n */\n enforceAtxHeadings: boolean;\n\n /**\n * Forces the compiler to always output content with a block-level wrapper.\n */\n forceBlock: boolean;\n\n /**\n * Forces the compiler to always output content with an inline wrapper.\n */\n forceInline: boolean;\n\n /**\n * Forces the compiler to wrap results, even if there is only a single child.\n */\n forceWrapper: boolean;\n\n /**\n * Supply additional HTML entity: unicode replacement mappings.\n */\n namedCodesToUnicode: {\n [key: string]: string;\n };\n\n /**\n * Selectively control the output of particular HTML tags.\n */\n components: HTMLComponents;\n\n /**\n * Allows for full control over rendering of particular rules.\n */\n renderRule: RenderRuleHook;\n\n /**\n * Override the built-in sanitizer function for URLs.\n */\n sanitizer: (value: string, tag: HTMLTags, attribute: string) => string | null;\n\n /**\n * Override normalization of non-URI-safe characters for anchor linking.\n */\n slugify: (input: string) => string;\n\n /**\n * Declare the type of the wrapper to be used when there are multiple children.\n */\n wrapper: any | null;\n\n /**\n * Whether to preserve frontmatter in the markdown content.\n */\n preserveFrontmatter: boolean;\n\n /**\n * Whether to use the GitHub Tag Filter.\n */\n tagfilter: boolean;\n}>;\n\n/**\n * Default React runtime for markdown rendering.\n */\n\n/**\n * Intermediate AST produced by `parseMarkdown`.\n * Pass this to `compileMarkdown` or `<MarkdownRenderer>` to skip re-parsing\n * when the same content is rendered multiple times.\n */\nexport type { ParsedMarkdown };\n\n/**\n * **Step 1 of 2 — parse only.**\n * Converts a raw markdown string into a `ParsedMarkdown` AST without rendering\n * any React elements. Use this when you need to:\n * - Cache the parsed result and render it several times with different options.\n * - Inspect or transform the AST before rendering.\n * - Defer the render step to a later point in the pipeline.\n *\n * @param markdown - The markdown source string.\n * @param options - Options that affect parsing (sanitizer, slugify, …).\n * @returns A `ParsedMarkdown` AST ready to be passed to `compileMarkdown`.\n *\n * @example\n * ```tsx\n * const ast = parseMarkdown('# Hello **world**');\n * const element = compileMarkdown(ast, { forceBlock: true });\n * ```\n */\nexport const parseMarkdown = (\n markdown: string = '',\n options: MarkdownRendererOptions = {}\n): ParsedMarkdown => {\n const {\n disableAutoLink,\n disableParsingRawHTML,\n enforceAtxHeadings,\n forceBlock,\n forceInline,\n forceWrapper,\n namedCodesToUnicode,\n components,\n sanitizer,\n slugify,\n wrapper,\n preserveFrontmatter,\n tagfilter,\n } = options;\n\n const ctx: MarkdownContext<HTMLComponents> = {\n runtime: reactRuntime,\n components,\n namedCodesToUnicode,\n sanitizer: sanitizer as any,\n slugify,\n };\n\n const compilerOptions: MarkdownOptions = {\n disableAutoLink,\n disableParsingRawHTML,\n enforceAtxHeadings,\n forceBlock,\n forceInline,\n forceWrapper,\n wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n return coreParseMarkdown(markdown, ctx, compilerOptions);\n};\n\n/**\n * **Steps 1 + 2 — parse and render in one shot.**\n * Accepts a raw markdown string or a pre-parsed `ParsedMarkdown` AST and\n * returns a React element. Use `parseMarkdown` first when you need to reuse\n * the same AST with different options.\n *\n * @param input - Markdown string or pre-parsed AST.\n * @param options - Rendering options (custom components, sanitizer, slugify, …).\n * @returns A React JSX element representing the rendered markdown.\n *\n * @example\n * ```tsx\n * const element = compileMarkdown('# Hello **world**', { forceBlock: true });\n * ```\n */\nexport const compileMarkdown = (\n input: string | ParsedMarkdown = '',\n options: MarkdownRendererOptions = {}\n): JSX.Element => {\n const {\n createElement: customCreateElement,\n disableAutoLink,\n disableParsingRawHTML,\n enforceAtxHeadings,\n forceBlock,\n forceInline,\n forceWrapper,\n namedCodesToUnicode,\n components,\n renderRule,\n sanitizer,\n slugify,\n wrapper,\n preserveFrontmatter,\n tagfilter,\n } = options;\n\n const runtime = customCreateElement\n ? { ...reactRuntime, createElement: customCreateElement as any }\n : reactRuntime;\n\n const ctx: MarkdownContext<HTMLComponents> = {\n runtime,\n components,\n namedCodesToUnicode,\n sanitizer: sanitizer as any,\n slugify,\n };\n\n const compilerOptions: MarkdownOptions = {\n disableAutoLink,\n disableParsingRawHTML,\n enforceAtxHeadings,\n forceBlock,\n forceInline,\n forceWrapper,\n renderRule,\n wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n if (typeof input === 'string') {\n return coreCompile(input, ctx, compilerOptions) as JSX.Element;\n }\n\n return coreRenderMarkdownAst(input, ctx, compilerOptions) as JSX.Element;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0IA,MAAa,iBACX,WAAmB,IACnB,UAAmC,CAAC,MACjB;CACnB,MAAM,EACJ,iBACA,uBACA,oBACA,YACA,aACA,cACA,qBACA,YACA,WACA,SACA,SACA,qBACA,cACE;CAsBJ,WAAOA,uCAAkB,UAAU;EAnBjC,SAASC;EACT;EACA;EACW;EACX;CAemC,GAAG;EAXtC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CAGoD,CAAC;AACzD;;;;;;;;;;;;;;;;AAiBA,MAAa,mBACX,QAAiC,IACjC,UAAmC,CAAC,MACpB;CAChB,MAAM,EACJ,eAAe,qBACf,iBACA,uBACA,oBACA,YACA,aACA,cACA,qBACA,YACA,YACA,WACA,SACA,SACA,qBACA,cACE;CAMJ,MAAM,MAAuC;EAC3C,SALc,sBACZ;GAAE,GAAGA;GAAc,eAAe;EAA2B,IAC7DA;EAIF;EACA;EACW;EACX;CACF;CAEA,MAAM,kBAAmC;EACvC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CAEA,IAAI,OAAO,UAAU,UACnB,WAAOC,iCAAY,OAAO,KAAK,eAAe;CAGhD,WAAOC,2CAAsB,OAAO,KAAK,eAAe;AAC1D"}
|
|
@@ -6,15 +6,43 @@ let react = require("react");
|
|
|
6
6
|
* React-specific runtime for the markdown processor.
|
|
7
7
|
* Implements the MarkdownRuntime interface using React's primitives.
|
|
8
8
|
*/
|
|
9
|
+
let REACT_ELEMENT_TYPE;
|
|
10
|
+
try {
|
|
11
|
+
const sample = (0, react.createElement)("div");
|
|
12
|
+
REACT_ELEMENT_TYPE = sample && typeof sample === "object" && "$$typeof" in sample && typeof sample.$$typeof === "symbol" ? sample.$$typeof : Symbol.for("react.transitional.element");
|
|
13
|
+
} catch {
|
|
14
|
+
REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element");
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* React-specific runtime for the markdown processor.
|
|
18
|
+
* Implements the MarkdownRuntime interface using React's primitives.
|
|
19
|
+
*/
|
|
9
20
|
const reactRuntime = {
|
|
10
21
|
/**
|
|
11
22
|
* Creates a React element.
|
|
12
23
|
* Handles the conversion of props and children to React format.
|
|
13
24
|
*/
|
|
14
25
|
createElement: (type, props, ...children) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
26
|
+
let key = null;
|
|
27
|
+
const finalProps = props || {};
|
|
28
|
+
if (props && props.key != null) {
|
|
29
|
+
key = String(props.key);
|
|
30
|
+
finalProps.key = void 0;
|
|
31
|
+
}
|
|
32
|
+
const childCount = children.length;
|
|
33
|
+
if (childCount === 1) finalProps.children = children[0];
|
|
34
|
+
else if (childCount > 1) finalProps.children = children;
|
|
35
|
+
return {
|
|
36
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
37
|
+
type,
|
|
38
|
+
key,
|
|
39
|
+
ref: null,
|
|
40
|
+
props: finalProps,
|
|
41
|
+
_owner: null,
|
|
42
|
+
_store: {},
|
|
43
|
+
_debugStack: null,
|
|
44
|
+
_debugTask: null
|
|
45
|
+
};
|
|
18
46
|
},
|
|
19
47
|
/**
|
|
20
48
|
* Clones a React element with new props.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.cjs","names":["createElement","cloneElement"],"sources":["../../../src/markdown/runtime.ts"],"sourcesContent":["import type { HTMLTag, MarkdownRuntime } from '@intlayer/core/markdown';\nimport {\n cloneElement,\n createElement,\n Fragment,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\n/**\n * React-specific runtime for the markdown processor.\n * Implements the MarkdownRuntime interface using React's primitives.\n */\nexport const reactRuntime: MarkdownRuntime = {\n /**\n * Creates a React element.\n * Handles the conversion of props and children to React format.\n */\n createElement: (\n type: string | any,\n props: Record<string, any> | null,\n ...children: any[]\n ): ReactNode => {\n
|
|
1
|
+
{"version":3,"file":"runtime.cjs","names":["createElement","cloneElement"],"sources":["../../../src/markdown/runtime.ts"],"sourcesContent":["import type { HTMLTag, MarkdownRuntime } from '@intlayer/core/markdown';\nimport {\n cloneElement,\n createElement,\n Fragment,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\n/**\n * React-specific runtime for the markdown processor.\n * Implements the MarkdownRuntime interface using React's primitives.\n */\nlet REACT_ELEMENT_TYPE: symbol;\ntry {\n const sample = createElement('div');\n REACT_ELEMENT_TYPE =\n sample &&\n typeof sample === 'object' &&\n '$$typeof' in sample &&\n typeof sample.$$typeof === 'symbol'\n ? (sample.$$typeof as symbol)\n : Symbol.for('react.transitional.element');\n} catch {\n REACT_ELEMENT_TYPE = Symbol.for('react.transitional.element');\n}\n\n/**\n * React-specific runtime for the markdown processor.\n * Implements the MarkdownRuntime interface using React's primitives.\n */\nexport const reactRuntime: MarkdownRuntime = {\n /**\n * Creates a React element.\n * Handles the conversion of props and children to React format.\n */\n createElement: (\n type: string | any,\n props: Record<string, any> | null,\n ...children: any[]\n ): ReactNode => {\n let key: string | null = null;\n const finalProps: any = props || {};\n\n if (props && props.key != null) {\n key = String(props.key);\n finalProps.key = undefined;\n }\n\n const childCount = children.length;\n if (childCount === 1) {\n finalProps.children = children[0];\n } else if (childCount > 1) {\n finalProps.children = children;\n }\n\n return {\n $$typeof: REACT_ELEMENT_TYPE,\n type,\n key,\n ref: null,\n props: finalProps,\n _owner: null,\n _store: {},\n _debugStack: null,\n _debugTask: null,\n } as unknown as ReactNode;\n },\n\n /**\n * Clones a React element with new props.\n */\n cloneElement: (\n element: unknown,\n props: Record<string, any>,\n ...children: any[]\n ): ReactNode => {\n if (children.length === 0) {\n return cloneElement(element as ReactElement, props);\n }\n return cloneElement(element as ReactElement, props, ...children);\n },\n\n /**\n * React Fragment component.\n */\n Fragment,\n\n /**\n * React-specific prop normalization.\n * React uses className instead of class, htmlFor instead of for, etc.\n * The core processor already handles ATTRIBUTE_TO_NODE_PROP_MAP,\n * so this is mostly a no-op but can be used for additional React-specific transforms.\n */\n normalizeProps: (\n _tag: HTMLTag,\n props: Record<string, any>\n ): Record<string, any> => {\n // The core already handles class -> className and for -> htmlFor\n // via ATTRIBUTE_TO_NODE_PROP_MAP in the attrStringToMap function.\n // This hook is available for any additional React-specific transforms.\n return props;\n },\n};\n\n/**\n * Creates a React runtime with custom createElement for advanced use cases.\n * Useful for wrapping elements or adding middleware.\n */\nexport const createReactRuntime = (\n options: {\n onCreateElement?: (\n type: string | any,\n props: Record<string, any> | null,\n children: any[]\n ) => ReactNode;\n } = {}\n): MarkdownRuntime => {\n const { onCreateElement } = options;\n\n if (onCreateElement) {\n return {\n ...reactRuntime,\n createElement: (\n type: string | any,\n props: Record<string, any> | null,\n ...children: any[]\n ): ReactNode => {\n return onCreateElement(type, props, children);\n },\n };\n }\n\n return reactRuntime;\n};\n"],"mappings":";;;;;;;;AAaA,IAAI;AACJ,IAAI;CACF,MAAM,aAASA,qBAAc,KAAK;CAClC,qBACE,UACA,OAAO,WAAW,YAClB,cAAc,UACd,OAAO,OAAO,aAAa,WACtB,OAAO,WACR,OAAO,IAAI,4BAA4B;AAC/C,QAAQ;CACN,qBAAqB,OAAO,IAAI,4BAA4B;AAC9D;;;;;AAMA,MAAa,eAAgC;;;;;CAK3C,gBACE,MACA,OACA,GAAG,aACW;EACd,IAAI,MAAqB;EACzB,MAAM,aAAkB,SAAS,CAAC;EAElC,IAAI,SAAS,MAAM,OAAO,MAAM;GAC9B,MAAM,OAAO,MAAM,GAAG;GACtB,WAAW,MAAM;EACnB;EAEA,MAAM,aAAa,SAAS;EAC5B,IAAI,eAAe,GACjB,WAAW,WAAW,SAAS;OAC1B,IAAI,aAAa,GACtB,WAAW,WAAW;EAGxB,OAAO;GACL,UAAU;GACV;GACA;GACA,KAAK;GACL,OAAO;GACP,QAAQ;GACR,QAAQ,CAAC;GACT,aAAa;GACb,YAAY;EACd;CACF;;;;CAKA,eACE,SACA,OACA,GAAG,aACW;EACd,IAAI,SAAS,WAAW,GACtB,WAAOC,oBAAa,SAAyB,KAAK;EAEpD,WAAOA,oBAAa,SAAyB,OAAO,GAAG,QAAQ;CACjE;;;;CAKA;;;;;;;CAQA,iBACE,MACA,UACwB;EAIxB,OAAO;CACT;AACF;;;;;AAMA,MAAa,sBACX,UAMI,CAAC,MACe;CACpB,MAAM,EAAE,oBAAoB;CAE5B,IAAI,iBACF,OAAO;EACL,GAAG;EACH,gBACE,MACA,OACA,GAAG,aACW;GACd,OAAO,gBAAgB,MAAM,OAAO,QAAQ;EAC9C;CACF;CAGF,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownProvider.mjs","names":[],"sources":["../../../src/markdown/MarkdownProvider.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n type FC,\n type HTMLAttributes,\n type PropsWithChildren,\n type ReactNode,\n useContext,\n} from 'react';\nimport type { HTMLComponents } from '../html/HTMLComponentTypes';\nimport {\n compileMarkdown,\n type MarkdownRendererOptions,\n type ParsedMarkdown,\n} from './processor';\n\nexport type MarkdownProviderOptions = {\n /** Forces the compiler to always output content with a block-level wrapper. */\n forceBlock?: boolean;\n /** Forces the compiler to always output content with an inline wrapper. */\n forceInline?: boolean;\n /** Whether to preserve frontmatter in the markdown content. */\n preserveFrontmatter?: boolean;\n /** Whether to use the GitHub Tag Filter for security. */\n tagfilter?: boolean;\n};\n\
|
|
1
|
+
{"version":3,"file":"MarkdownProvider.mjs","names":[],"sources":["../../../src/markdown/MarkdownProvider.tsx"],"sourcesContent":["'use client';\n\nimport {\n createContext,\n type FC,\n type HTMLAttributes,\n type PropsWithChildren,\n type ReactNode,\n useContext,\n} from 'react';\nimport type { HTMLComponents } from '../html/HTMLComponentTypes';\nimport {\n compileMarkdown,\n type MarkdownRendererOptions,\n type ParsedMarkdown,\n} from './processor';\n\nexport type MarkdownProviderOptions = {\n /** Forces the compiler to always output content with a block-level wrapper. */\n forceBlock?: boolean;\n /** Forces the compiler to always output content with an inline wrapper. */\n forceInline?: boolean;\n /** Whether to preserve frontmatter in the markdown content. */\n preserveFrontmatter?: boolean;\n /** Whether to use the GitHub Tag Filter for security. */\n tagfilter?: boolean;\n};\n\nexport type MarkdownContextValue = {\n components?: HTMLComponents<'permissive', {}>;\n renderMarkdown: (\n markdown: string | ParsedMarkdown,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: FC<HTMLAttributes<HTMLElement>>\n ) => ReactNode | Promise<ReactNode>;\n};\n\nexport type MarkdownProviderProps = PropsWithChildren<\n MarkdownProviderOptions & {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: FC<HTMLAttributes<HTMLElement>>;\n renderMarkdown?: (\n markdown: string | ParsedMarkdown,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: FC<HTMLAttributes<HTMLElement>>\n ) => ReactNode | Promise<ReactNode>;\n }\n>;\n\nconst MarkdownContext = createContext<MarkdownContextValue | undefined>(\n undefined\n);\n\n/**\n * Returns the raw `MarkdownProvider` context value — the active\n * `renderMarkdown` function plus any provider-level component overrides.\n * Returns `undefined` when called outside a `<MarkdownProvider>`.\n * Prefer `useMarkdownRenderer` for most use cases; use this hook only when\n * you need direct access to the context object itself.\n */\nexport const useMarkdownContext = () => useContext(MarkdownContext);\n\nconst mergeOptions = (\n baseOptions: MarkdownRendererOptions,\n options: MarkdownProviderOptions = {},\n components: HTMLComponents<'permissive', {}> = {},\n wrapper?: FC<HTMLAttributes<HTMLElement>>\n): MarkdownRendererOptions => {\n return {\n ...baseOptions,\n ...options,\n forceBlock: options.forceBlock ?? baseOptions.forceBlock,\n forceInline: options.forceInline ?? baseOptions.forceInline,\n preserveFrontmatter:\n options.preserveFrontmatter ?? baseOptions.preserveFrontmatter,\n tagfilter: options.tagfilter ?? baseOptions.tagfilter,\n wrapper: wrapper || baseOptions.wrapper,\n\n forceWrapper: !!(wrapper || baseOptions.wrapper),\n components: { ...baseOptions.components, ...components },\n };\n};\n\n/**\n * Provider for the MarkdownRenderer component.\n *\n * It will provide the `renderMarkdown` function to the context, which can be used to render markdown.\n *\n * ```tsx\n * const content = useIntlayer('app');\n *\n * return (\n * <div>\n * {content.markdown} // Will be rendered with the components and options provided to the MarkdownProvider\n * </div>\n * );\n * ```\n *\n * @example\n * ```tsx\n * <MarkdownProvider components={{ h1: CustomHeading }}>\n * <MarkdownRenderer>\n * {markdownContent}\n * </MarkdownRenderer>\n * </MarkdownProvider>\n * ```\n */\nexport const MarkdownProvider: FC<MarkdownProviderProps> = ({\n children,\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRenderFn,\n}) => {\n const baseOptions: MarkdownRendererOptions = {\n components,\n forceBlock,\n forceInline,\n wrapper,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n // Standard internal renderer\n const defaultRenderMarkdown = (\n markdown: string | ParsedMarkdown,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: FC<HTMLAttributes<HTMLElement>>\n ) => {\n const mergedOptions = mergeOptions(\n baseOptions,\n options,\n components,\n wrapper\n );\n\n return compileMarkdown(markdown, mergedOptions);\n };\n\n // Wrapper for user-provided custom renderer\n // Note: We wrap in a clean Provider to prevent infinite recursion\n const customRenderMarkdownWrapper = (\n markdown: string | ParsedMarkdown,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: FC<HTMLAttributes<HTMLElement>>\n ) => (\n <MarkdownContext.Provider value={undefined}>\n {customRenderFn?.(markdown, options, components, wrapper) as ReactNode}\n </MarkdownContext.Provider>\n );\n\n return (\n <MarkdownContext.Provider\n value={{\n components,\n renderMarkdown: customRenderFn\n ? customRenderMarkdownWrapper\n : defaultRenderMarkdown,\n }}\n >\n {children}\n </MarkdownContext.Provider>\n );\n};\n"],"mappings":";;;;;;;AAmDA,MAAM,kBAAkB,cACtB,MACF;;;;;;;;AASA,MAAa,2BAA2B,WAAW,eAAe;AAElE,MAAM,gBACJ,aACA,UAAmC,CAAC,GACpC,aAA+C,CAAC,GAChD,YAC4B;CAC5B,OAAO;EACL,GAAG;EACH,GAAG;EACH,YAAY,QAAQ,cAAc,YAAY;EAC9C,aAAa,QAAQ,eAAe,YAAY;EAChD,qBACE,QAAQ,uBAAuB,YAAY;EAC7C,WAAW,QAAQ,aAAa,YAAY;EAC5C,SAAS,WAAW,YAAY;EAEhC,cAAc,CAAC,EAAE,WAAW,YAAY;EACxC,YAAY;GAAE,GAAG,YAAY;GAAY,GAAG;EAAW;CACzD;AACF;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,oBAA+C,EAC1D,UACA,YACA,SACA,YACA,aACA,qBACA,WACA,gBAAgB,qBACZ;CACJ,MAAM,cAAuC;EAC3C;EACA;EACA;EACA;EACA,cAAc,CAAC,CAAC;EAChB;EACA;CACF;CAGA,MAAM,yBACJ,UACA,SACA,YACA,YACG;EACH,MAAM,gBAAgB,aACpB,aACA,SACA,YACA,OACF;EAEA,OAAO,gBAAgB,UAAU,aAAa;CAChD;CAIA,MAAM,+BACJ,UACA,SACA,YACA,YAEA,oBAAC,gBAAgB,UAAjB;EAA0B,OAAO;YAC9B,iBAAiB,UAAU,SAAS,YAAY,OAAO;CAChC;CAG5B,OACE,oBAAC,gBAAgB,UAAjB;EACE,OAAO;GACL;GACA,gBAAgB,iBACZ,8BACA;EACN;EAEC;CACuB;AAE9B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { reactRuntime } from "./runtime.mjs";
|
|
1
2
|
import { compile, parseMarkdown as parseMarkdown$1, renderMarkdownAst } from "@intlayer/core/markdown";
|
|
2
|
-
import { Fragment, cloneElement, createElement } from "react";
|
|
3
3
|
|
|
4
4
|
//#region src/markdown/processor.tsx
|
|
5
5
|
/**
|
|
@@ -8,15 +8,6 @@ import { Fragment, cloneElement, createElement } from "react";
|
|
|
8
8
|
* [simple-markdown v0.2.2](https://github.com/Khan/simple-markdown) from Khan Academy.
|
|
9
9
|
*/
|
|
10
10
|
/**
|
|
11
|
-
* Default React runtime for markdown rendering.
|
|
12
|
-
*/
|
|
13
|
-
const DEFAULT_RUNTIME = {
|
|
14
|
-
createElement,
|
|
15
|
-
cloneElement,
|
|
16
|
-
Fragment,
|
|
17
|
-
normalizeProps: (_tag, props) => props
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
11
|
* **Step 1 of 2 — parse only.**
|
|
21
12
|
* Converts a raw markdown string into a `ParsedMarkdown` AST without rendering
|
|
22
13
|
* any React elements. Use this when you need to:
|
|
@@ -37,7 +28,7 @@ const DEFAULT_RUNTIME = {
|
|
|
37
28
|
const parseMarkdown = (markdown = "", options = {}) => {
|
|
38
29
|
const { disableAutoLink, disableParsingRawHTML, enforceAtxHeadings, forceBlock, forceInline, forceWrapper, namedCodesToUnicode, components, sanitizer, slugify, wrapper, preserveFrontmatter, tagfilter } = options;
|
|
39
30
|
return parseMarkdown$1(markdown, {
|
|
40
|
-
runtime:
|
|
31
|
+
runtime: reactRuntime,
|
|
41
32
|
components,
|
|
42
33
|
namedCodesToUnicode,
|
|
43
34
|
sanitizer,
|
|
@@ -73,9 +64,9 @@ const compileMarkdown = (input = "", options = {}) => {
|
|
|
73
64
|
const { createElement: customCreateElement, disableAutoLink, disableParsingRawHTML, enforceAtxHeadings, forceBlock, forceInline, forceWrapper, namedCodesToUnicode, components, renderRule, sanitizer, slugify, wrapper, preserveFrontmatter, tagfilter } = options;
|
|
74
65
|
const ctx = {
|
|
75
66
|
runtime: customCreateElement ? {
|
|
76
|
-
...
|
|
67
|
+
...reactRuntime,
|
|
77
68
|
createElement: customCreateElement
|
|
78
|
-
} :
|
|
69
|
+
} : reactRuntime,
|
|
79
70
|
components,
|
|
80
71
|
namedCodesToUnicode,
|
|
81
72
|
sanitizer,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"processor.mjs","names":["coreParseMarkdown","coreCompile","coreRenderMarkdownAst"],"sources":["../../../src/markdown/processor.tsx"],"sourcesContent":["/**\n * it's a fork\n * [markdown-to-jsx v7.7.14](https://github.com/quantizor/markdown-to-jsx) from quantizor\n * [simple-markdown v0.2.2](https://github.com/Khan/simple-markdown) from Khan Academy.\n */\n\nimport {\n compile as coreCompile,\n parseMarkdown as coreParseMarkdown,\n renderMarkdownAst as coreRenderMarkdownAst,\n type MarkdownContext,\n type MarkdownOptions,\n type
|
|
1
|
+
{"version":3,"file":"processor.mjs","names":["coreParseMarkdown","coreCompile","coreRenderMarkdownAst"],"sources":["../../../src/markdown/processor.tsx"],"sourcesContent":["/**\n * it's a fork\n * [markdown-to-jsx v7.7.14](https://github.com/quantizor/markdown-to-jsx) from quantizor\n * [simple-markdown v0.2.2](https://github.com/Khan/simple-markdown) from Khan Academy.\n */\n\nimport {\n compile as coreCompile,\n parseMarkdown as coreParseMarkdown,\n renderMarkdownAst as coreRenderMarkdownAst,\n type MarkdownContext,\n type MarkdownOptions,\n type ParsedMarkdown,\n type RenderRuleHook,\n} from '@intlayer/core/markdown';\nimport type { createElement, JSX, ReactNode } from 'react';\nimport type { HTMLComponents } from '../html/HTMLComponentTypes';\nimport { reactRuntime } from './runtime';\n\ntype HTMLTags = keyof JSX.IntrinsicElements;\n\n/**\n * Refined MarkdownRendererOptions type.\n */\nexport type MarkdownRendererOptions = Partial<{\n /**\n * Ultimate control over the output of all rendered JSX.\n */\n createElement: (\n tag: Parameters<typeof createElement>[0],\n props: JSX.IntrinsicAttributes,\n ...children: ReactNode[]\n ) => ReactNode;\n\n /**\n * The library automatically generates an anchor tag for bare URLs included in the markdown\n * document, but this behavior can be disabled if desired.\n */\n disableAutoLink: boolean;\n\n /**\n * Disable the compiler's best-effort transcription of provided raw HTML\n * into JSX-equivalent.\n */\n disableParsingRawHTML: boolean;\n\n /**\n * Forces the compiler to have space between hash sign and the header text.\n */\n enforceAtxHeadings: boolean;\n\n /**\n * Forces the compiler to always output content with a block-level wrapper.\n */\n forceBlock: boolean;\n\n /**\n * Forces the compiler to always output content with an inline wrapper.\n */\n forceInline: boolean;\n\n /**\n * Forces the compiler to wrap results, even if there is only a single child.\n */\n forceWrapper: boolean;\n\n /**\n * Supply additional HTML entity: unicode replacement mappings.\n */\n namedCodesToUnicode: {\n [key: string]: string;\n };\n\n /**\n * Selectively control the output of particular HTML tags.\n */\n components: HTMLComponents;\n\n /**\n * Allows for full control over rendering of particular rules.\n */\n renderRule: RenderRuleHook;\n\n /**\n * Override the built-in sanitizer function for URLs.\n */\n sanitizer: (value: string, tag: HTMLTags, attribute: string) => string | null;\n\n /**\n * Override normalization of non-URI-safe characters for anchor linking.\n */\n slugify: (input: string) => string;\n\n /**\n * Declare the type of the wrapper to be used when there are multiple children.\n */\n wrapper: any | null;\n\n /**\n * Whether to preserve frontmatter in the markdown content.\n */\n preserveFrontmatter: boolean;\n\n /**\n * Whether to use the GitHub Tag Filter.\n */\n tagfilter: boolean;\n}>;\n\n/**\n * Default React runtime for markdown rendering.\n */\n\n/**\n * Intermediate AST produced by `parseMarkdown`.\n * Pass this to `compileMarkdown` or `<MarkdownRenderer>` to skip re-parsing\n * when the same content is rendered multiple times.\n */\nexport type { ParsedMarkdown };\n\n/**\n * **Step 1 of 2 — parse only.**\n * Converts a raw markdown string into a `ParsedMarkdown` AST without rendering\n * any React elements. Use this when you need to:\n * - Cache the parsed result and render it several times with different options.\n * - Inspect or transform the AST before rendering.\n * - Defer the render step to a later point in the pipeline.\n *\n * @param markdown - The markdown source string.\n * @param options - Options that affect parsing (sanitizer, slugify, …).\n * @returns A `ParsedMarkdown` AST ready to be passed to `compileMarkdown`.\n *\n * @example\n * ```tsx\n * const ast = parseMarkdown('# Hello **world**');\n * const element = compileMarkdown(ast, { forceBlock: true });\n * ```\n */\nexport const parseMarkdown = (\n markdown: string = '',\n options: MarkdownRendererOptions = {}\n): ParsedMarkdown => {\n const {\n disableAutoLink,\n disableParsingRawHTML,\n enforceAtxHeadings,\n forceBlock,\n forceInline,\n forceWrapper,\n namedCodesToUnicode,\n components,\n sanitizer,\n slugify,\n wrapper,\n preserveFrontmatter,\n tagfilter,\n } = options;\n\n const ctx: MarkdownContext<HTMLComponents> = {\n runtime: reactRuntime,\n components,\n namedCodesToUnicode,\n sanitizer: sanitizer as any,\n slugify,\n };\n\n const compilerOptions: MarkdownOptions = {\n disableAutoLink,\n disableParsingRawHTML,\n enforceAtxHeadings,\n forceBlock,\n forceInline,\n forceWrapper,\n wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n return coreParseMarkdown(markdown, ctx, compilerOptions);\n};\n\n/**\n * **Steps 1 + 2 — parse and render in one shot.**\n * Accepts a raw markdown string or a pre-parsed `ParsedMarkdown` AST and\n * returns a React element. Use `parseMarkdown` first when you need to reuse\n * the same AST with different options.\n *\n * @param input - Markdown string or pre-parsed AST.\n * @param options - Rendering options (custom components, sanitizer, slugify, …).\n * @returns A React JSX element representing the rendered markdown.\n *\n * @example\n * ```tsx\n * const element = compileMarkdown('# Hello **world**', { forceBlock: true });\n * ```\n */\nexport const compileMarkdown = (\n input: string | ParsedMarkdown = '',\n options: MarkdownRendererOptions = {}\n): JSX.Element => {\n const {\n createElement: customCreateElement,\n disableAutoLink,\n disableParsingRawHTML,\n enforceAtxHeadings,\n forceBlock,\n forceInline,\n forceWrapper,\n namedCodesToUnicode,\n components,\n renderRule,\n sanitizer,\n slugify,\n wrapper,\n preserveFrontmatter,\n tagfilter,\n } = options;\n\n const runtime = customCreateElement\n ? { ...reactRuntime, createElement: customCreateElement as any }\n : reactRuntime;\n\n const ctx: MarkdownContext<HTMLComponents> = {\n runtime,\n components,\n namedCodesToUnicode,\n sanitizer: sanitizer as any,\n slugify,\n };\n\n const compilerOptions: MarkdownOptions = {\n disableAutoLink,\n disableParsingRawHTML,\n enforceAtxHeadings,\n forceBlock,\n forceInline,\n forceWrapper,\n renderRule,\n wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n if (typeof input === 'string') {\n return coreCompile(input, ctx, compilerOptions) as JSX.Element;\n }\n\n return coreRenderMarkdownAst(input, ctx, compilerOptions) as JSX.Element;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA0IA,MAAa,iBACX,WAAmB,IACnB,UAAmC,CAAC,MACjB;CACnB,MAAM,EACJ,iBACA,uBACA,oBACA,YACA,aACA,cACA,qBACA,YACA,WACA,SACA,SACA,qBACA,cACE;CAsBJ,OAAOA,gBAAkB,UAAU;EAnBjC,SAAS;EACT;EACA;EACW;EACX;CAemC,GAAG;EAXtC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CAGoD,CAAC;AACzD;;;;;;;;;;;;;;;;AAiBA,MAAa,mBACX,QAAiC,IACjC,UAAmC,CAAC,MACpB;CAChB,MAAM,EACJ,eAAe,qBACf,iBACA,uBACA,oBACA,YACA,aACA,cACA,qBACA,YACA,YACA,WACA,SACA,SACA,qBACA,cACE;CAMJ,MAAM,MAAuC;EAC3C,SALc,sBACZ;GAAE,GAAG;GAAc,eAAe;EAA2B,IAC7D;EAIF;EACA;EACW;EACX;CACF;CAEA,MAAM,kBAAmC;EACvC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CAEA,IAAI,OAAO,UAAU,UACnB,OAAOC,QAAY,OAAO,KAAK,eAAe;CAGhD,OAAOC,kBAAsB,OAAO,KAAK,eAAe;AAC1D"}
|
|
@@ -5,15 +5,43 @@ import { Fragment, cloneElement, createElement } from "react";
|
|
|
5
5
|
* React-specific runtime for the markdown processor.
|
|
6
6
|
* Implements the MarkdownRuntime interface using React's primitives.
|
|
7
7
|
*/
|
|
8
|
+
let REACT_ELEMENT_TYPE;
|
|
9
|
+
try {
|
|
10
|
+
const sample = createElement("div");
|
|
11
|
+
REACT_ELEMENT_TYPE = sample && typeof sample === "object" && "$$typeof" in sample && typeof sample.$$typeof === "symbol" ? sample.$$typeof : Symbol.for("react.transitional.element");
|
|
12
|
+
} catch {
|
|
13
|
+
REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element");
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* React-specific runtime for the markdown processor.
|
|
17
|
+
* Implements the MarkdownRuntime interface using React's primitives.
|
|
18
|
+
*/
|
|
8
19
|
const reactRuntime = {
|
|
9
20
|
/**
|
|
10
21
|
* Creates a React element.
|
|
11
22
|
* Handles the conversion of props and children to React format.
|
|
12
23
|
*/
|
|
13
24
|
createElement: (type, props, ...children) => {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
25
|
+
let key = null;
|
|
26
|
+
const finalProps = props || {};
|
|
27
|
+
if (props && props.key != null) {
|
|
28
|
+
key = String(props.key);
|
|
29
|
+
finalProps.key = void 0;
|
|
30
|
+
}
|
|
31
|
+
const childCount = children.length;
|
|
32
|
+
if (childCount === 1) finalProps.children = children[0];
|
|
33
|
+
else if (childCount > 1) finalProps.children = children;
|
|
34
|
+
return {
|
|
35
|
+
$$typeof: REACT_ELEMENT_TYPE,
|
|
36
|
+
type,
|
|
37
|
+
key,
|
|
38
|
+
ref: null,
|
|
39
|
+
props: finalProps,
|
|
40
|
+
_owner: null,
|
|
41
|
+
_store: {},
|
|
42
|
+
_debugStack: null,
|
|
43
|
+
_debugTask: null
|
|
44
|
+
};
|
|
17
45
|
},
|
|
18
46
|
/**
|
|
19
47
|
* Clones a React element with new props.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.mjs","names":[],"sources":["../../../src/markdown/runtime.ts"],"sourcesContent":["import type { HTMLTag, MarkdownRuntime } from '@intlayer/core/markdown';\nimport {\n cloneElement,\n createElement,\n Fragment,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\n/**\n * React-specific runtime for the markdown processor.\n * Implements the MarkdownRuntime interface using React's primitives.\n */\nexport const reactRuntime: MarkdownRuntime = {\n /**\n * Creates a React element.\n * Handles the conversion of props and children to React format.\n */\n createElement: (\n type: string | any,\n props: Record<string, any> | null,\n ...children: any[]\n ): ReactNode => {\n
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":[],"sources":["../../../src/markdown/runtime.ts"],"sourcesContent":["import type { HTMLTag, MarkdownRuntime } from '@intlayer/core/markdown';\nimport {\n cloneElement,\n createElement,\n Fragment,\n type ReactElement,\n type ReactNode,\n} from 'react';\n\n/**\n * React-specific runtime for the markdown processor.\n * Implements the MarkdownRuntime interface using React's primitives.\n */\nlet REACT_ELEMENT_TYPE: symbol;\ntry {\n const sample = createElement('div');\n REACT_ELEMENT_TYPE =\n sample &&\n typeof sample === 'object' &&\n '$$typeof' in sample &&\n typeof sample.$$typeof === 'symbol'\n ? (sample.$$typeof as symbol)\n : Symbol.for('react.transitional.element');\n} catch {\n REACT_ELEMENT_TYPE = Symbol.for('react.transitional.element');\n}\n\n/**\n * React-specific runtime for the markdown processor.\n * Implements the MarkdownRuntime interface using React's primitives.\n */\nexport const reactRuntime: MarkdownRuntime = {\n /**\n * Creates a React element.\n * Handles the conversion of props and children to React format.\n */\n createElement: (\n type: string | any,\n props: Record<string, any> | null,\n ...children: any[]\n ): ReactNode => {\n let key: string | null = null;\n const finalProps: any = props || {};\n\n if (props && props.key != null) {\n key = String(props.key);\n finalProps.key = undefined;\n }\n\n const childCount = children.length;\n if (childCount === 1) {\n finalProps.children = children[0];\n } else if (childCount > 1) {\n finalProps.children = children;\n }\n\n return {\n $$typeof: REACT_ELEMENT_TYPE,\n type,\n key,\n ref: null,\n props: finalProps,\n _owner: null,\n _store: {},\n _debugStack: null,\n _debugTask: null,\n } as unknown as ReactNode;\n },\n\n /**\n * Clones a React element with new props.\n */\n cloneElement: (\n element: unknown,\n props: Record<string, any>,\n ...children: any[]\n ): ReactNode => {\n if (children.length === 0) {\n return cloneElement(element as ReactElement, props);\n }\n return cloneElement(element as ReactElement, props, ...children);\n },\n\n /**\n * React Fragment component.\n */\n Fragment,\n\n /**\n * React-specific prop normalization.\n * React uses className instead of class, htmlFor instead of for, etc.\n * The core processor already handles ATTRIBUTE_TO_NODE_PROP_MAP,\n * so this is mostly a no-op but can be used for additional React-specific transforms.\n */\n normalizeProps: (\n _tag: HTMLTag,\n props: Record<string, any>\n ): Record<string, any> => {\n // The core already handles class -> className and for -> htmlFor\n // via ATTRIBUTE_TO_NODE_PROP_MAP in the attrStringToMap function.\n // This hook is available for any additional React-specific transforms.\n return props;\n },\n};\n\n/**\n * Creates a React runtime with custom createElement for advanced use cases.\n * Useful for wrapping elements or adding middleware.\n */\nexport const createReactRuntime = (\n options: {\n onCreateElement?: (\n type: string | any,\n props: Record<string, any> | null,\n children: any[]\n ) => ReactNode;\n } = {}\n): MarkdownRuntime => {\n const { onCreateElement } = options;\n\n if (onCreateElement) {\n return {\n ...reactRuntime,\n createElement: (\n type: string | any,\n props: Record<string, any> | null,\n ...children: any[]\n ): ReactNode => {\n return onCreateElement(type, props, children);\n },\n };\n }\n\n return reactRuntime;\n};\n"],"mappings":";;;;;;;AAaA,IAAI;AACJ,IAAI;CACF,MAAM,SAAS,cAAc,KAAK;CAClC,qBACE,UACA,OAAO,WAAW,YAClB,cAAc,UACd,OAAO,OAAO,aAAa,WACtB,OAAO,WACR,OAAO,IAAI,4BAA4B;AAC/C,QAAQ;CACN,qBAAqB,OAAO,IAAI,4BAA4B;AAC9D;;;;;AAMA,MAAa,eAAgC;;;;;CAK3C,gBACE,MACA,OACA,GAAG,aACW;EACd,IAAI,MAAqB;EACzB,MAAM,aAAkB,SAAS,CAAC;EAElC,IAAI,SAAS,MAAM,OAAO,MAAM;GAC9B,MAAM,OAAO,MAAM,GAAG;GACtB,WAAW,MAAM;EACnB;EAEA,MAAM,aAAa,SAAS;EAC5B,IAAI,eAAe,GACjB,WAAW,WAAW,SAAS;OAC1B,IAAI,aAAa,GACtB,WAAW,WAAW;EAGxB,OAAO;GACL,UAAU;GACV;GACA;GACA,KAAK;GACL,OAAO;GACP,QAAQ;GACR,QAAQ,CAAC;GACT,aAAa;GACb,YAAY;EACd;CACF;;;;CAKA,eACE,SACA,OACA,GAAG,aACW;EACd,IAAI,SAAS,WAAW,GACtB,OAAO,aAAa,SAAyB,KAAK;EAEpD,OAAO,aAAa,SAAyB,OAAO,GAAG,QAAQ;CACjE;;;;CAKA;;;;;;;CAQA,iBACE,MACA,UACwB;EAIxB,OAAO;CACT;AACF;;;;;AAMA,MAAa,sBACX,UAMI,CAAC,MACe;CACpB,MAAM,EAAE,oBAAoB;CAE5B,IAAI,iBACF,OAAO;EACL,GAAG;EACH,gBACE,MACA,OACA,GAAG,aACW;GACd,OAAO,gBAAgB,MAAM,OAAO,QAAQ;EAC9C;CACF;CAGF,OAAO;AACT"}
|
|
@@ -2,7 +2,7 @@ import { NodeProps } from "@intlayer/core/interpreter";
|
|
|
2
2
|
import { ResolvedEditor } from "@intlayer/types/module_augmentation";
|
|
3
3
|
import { PropsWithChildren, ReactNode } from "react";
|
|
4
4
|
//#region src/IntlayerNode.d.ts
|
|
5
|
-
type IntlayerNode<T = NodeProps['children'], AdditionalProps = Record<string, never>> = ResolvedEditor<T, ReactNode> & {
|
|
5
|
+
export type IntlayerNode<T = NodeProps['children'], AdditionalProps = Record<string, never>> = ResolvedEditor<T, ReactNode> & {
|
|
6
6
|
value: T;
|
|
7
7
|
} & AdditionalProps & T;
|
|
8
8
|
type RenderIntlayerNodeProps<T> = PropsWithChildren<{
|
|
@@ -12,7 +12,6 @@ type RenderIntlayerNodeProps<T> = PropsWithChildren<{
|
|
|
12
12
|
[key: string]: any;
|
|
13
13
|
};
|
|
14
14
|
}>;
|
|
15
|
-
declare const renderIntlayerNode: <T>({ children, value, additionalProps }: RenderIntlayerNodeProps<T>) => IntlayerNode<T>;
|
|
15
|
+
export declare const renderIntlayerNode: <T>({ children, value, additionalProps }: RenderIntlayerNodeProps<T>) => IntlayerNode<T>;
|
|
16
16
|
//#endregion
|
|
17
|
-
export { IntlayerNode, renderIntlayerNode };
|
|
18
17
|
//# sourceMappingURL=IntlayerNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerNode.d.ts","names":[],"sources":["../../src/IntlayerNode.tsx"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"IntlayerNode.d.ts","names":[],"sources":["../../src/IntlayerNode.tsx"],"mappings":";;;;YASY,aACV,IAAI,uBACJ,kBAAkB,yBAChB,eAAe,GAAG;EACpB,OAAO;IACL,kBACF;KAEG,wBAAwB,KAAK;EAChC,OAAO;EACP,UAAU;EACV;KAAqB;;;qBAGV,qBACX,KAAC,UAAA,OAAA,mBAKA,wBAAwB,OAAK,aAAa"}
|
|
@@ -8,7 +8,6 @@ type ContentSelectorProps = {
|
|
|
8
8
|
pressDuration?: number;
|
|
9
9
|
isSelecting?: boolean;
|
|
10
10
|
} & Omit<HTMLAttributes<HTMLDivElement>, 'content'>;
|
|
11
|
-
declare const ContentSelector: FC<ContentSelectorProps>;
|
|
11
|
+
export declare const ContentSelector: FC<ContentSelectorProps>;
|
|
12
12
|
//#endregion
|
|
13
|
-
export { ContentSelector };
|
|
14
13
|
//# sourceMappingURL=ContentSelector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelector.d.ts","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"mappings":";;KAcK;EACH;EACA;EACA;EACA;EACA;EACA;IACE,KAAK,eAAe;
|
|
1
|
+
{"version":3,"file":"ContentSelector.d.ts","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"mappings":";;KAcK;EACH;EACA;EACA;EACA;EACA;EACA;IACE,KAAK,eAAe;qBAEX,iBAAiB,GAAG"}
|
|
@@ -4,7 +4,6 @@ import { FC, PropsWithChildren } from "react";
|
|
|
4
4
|
* Runs {@link useAnalytics} and renders its children unchanged. Mounted inside
|
|
5
5
|
* {@link IntlayerProvider} alongside `EditorProvider`.
|
|
6
6
|
*/
|
|
7
|
-
declare const AnalyticsProvider: FC<PropsWithChildren>;
|
|
7
|
+
export declare const AnalyticsProvider: FC<PropsWithChildren>;
|
|
8
8
|
//#endregion
|
|
9
|
-
export { AnalyticsProvider };
|
|
10
9
|
//# sourceMappingURL=AnalyticsProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AnalyticsProvider.d.ts","names":[],"sources":["../../../src/analytics/AnalyticsProvider.tsx"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"AnalyticsProvider.d.ts","names":[],"sources":["../../../src/analytics/AnalyticsProvider.tsx"],"mappings":";;;;;;qBAOa,mBAAmB,GAAG"}
|
|
@@ -5,28 +5,27 @@ import { KeyPath } from "@intlayer/types/keyPath";
|
|
|
5
5
|
* only) so the interpreter hot path in `plugins.tsx` never statically imports
|
|
6
6
|
* `@intlayer/analytics` — the package stays optional and tree-shakeable.
|
|
7
7
|
*/
|
|
8
|
-
type ExposureInput = {
|
|
8
|
+
export type ExposureInput = {
|
|
9
9
|
dictionaryKey: string;
|
|
10
10
|
keyPath: KeyPath[];
|
|
11
11
|
locale?: string;
|
|
12
12
|
nodeType?: string;
|
|
13
13
|
};
|
|
14
14
|
/** Consumer of exposure reports, installed by `useAnalytics` after init. */
|
|
15
|
-
type ExposureSink = (input: ExposureInput) => void;
|
|
15
|
+
export type ExposureSink = (input: ExposureInput) => void;
|
|
16
16
|
/**
|
|
17
17
|
* Installs (or clears) the exposure sink. `useAnalytics` sets this once the
|
|
18
18
|
* analytics client has loaded, and clears it on unmount.
|
|
19
19
|
*
|
|
20
20
|
* @param next - The sink to install, or `null` to clear.
|
|
21
21
|
*/
|
|
22
|
-
declare const setExposureSink: (next: ExposureSink | null) => void;
|
|
22
|
+
export declare const setExposureSink: (next: ExposureSink | null) => void;
|
|
23
23
|
/**
|
|
24
24
|
* Forwards a content exposure to the installed sink. A cheap null-check when
|
|
25
25
|
* analytics is not running, so it is safe to call from every node resolution.
|
|
26
26
|
*
|
|
27
27
|
* @param input - The node metadata to report.
|
|
28
28
|
*/
|
|
29
|
-
declare const reportExposure: (input: ExposureInput) => void;
|
|
29
|
+
export declare const reportExposure: (input: ExposureInput) => void;
|
|
30
30
|
//#endregion
|
|
31
|
-
export { ExposureInput, ExposureSink, reportExposure, setExposureSink };
|
|
32
31
|
//# sourceMappingURL=exposureSink.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exposureSink.d.ts","names":[],"sources":["../../../src/analytics/exposureSink.ts"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"exposureSink.d.ts","names":[],"sources":["../../../src/analytics/exposureSink.ts"],"mappings":";;;;;;;YAOY;EACV;EACA,SAAS;EACT;EACA;;;YAIU,gBAAgB,OAAO;;;;;;;qBAUtB,kBAAe,MAAU;;;;;;;qBAUzB,iBAAc,OAAW"}
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
* `@intlayer/analytics`, pay nothing — the whole body is guarded by
|
|
10
10
|
* `INTLAYER_ANALYTICS_ENABLED` and dead-code-eliminated at build time.
|
|
11
11
|
*/
|
|
12
|
-
declare const useAnalytics: () => void;
|
|
12
|
+
export declare const useAnalytics: () => void;
|
|
13
13
|
//#endregion
|
|
14
|
-
export { useAnalytics };
|
|
15
14
|
//# sourceMappingURL=useAnalytics.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAnalytics.d.ts","names":[],"sources":["../../../src/analytics/useAnalytics.tsx"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"useAnalytics.d.ts","names":[],"sources":["../../../src/analytics/useAnalytics.tsx"],"mappings":";;;;;;;;;;;qBAkBa"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Parameters describing a conversion to record.
|
|
4
4
|
*/
|
|
5
|
-
type ConversionParams = {
|
|
5
|
+
export type ConversionParams = {
|
|
6
6
|
/** The experiment this conversion is attributed to. */
|
|
7
7
|
experimentKey: string;
|
|
8
8
|
/** The variant the session was assigned. */
|
|
@@ -25,7 +25,6 @@ type ConversionParams = {
|
|
|
25
25
|
* })}>Get started</button>
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
|
-
declare const useConversion: () => (params: ConversionParams) => void;
|
|
28
|
+
export declare const useConversion: () => (params: ConversionParams) => void;
|
|
29
29
|
//#endregion
|
|
30
|
-
export { ConversionParams, useConversion };
|
|
31
30
|
//# sourceMappingURL=useConversion.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useConversion.d.ts","names":[],"sources":["../../../src/analytics/useConversion.tsx"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"useConversion.d.ts","names":[],"sources":["../../../src/analytics/useConversion.tsx"],"mappings":";;;;YAQY;;EAEV;;EAEA;;EAEA;;EAEA;;;;;;;;;;;;;;;qBAgBW,sBAAa,QACI"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* The state of an A/B experiment for the current session.
|
|
4
4
|
*/
|
|
5
|
-
type ExperimentState = {
|
|
5
|
+
export type ExperimentState = {
|
|
6
6
|
/**
|
|
7
7
|
* The variant assigned to this session. Until assignment resolves (and on
|
|
8
8
|
* the server, or when analytics is disabled), this is the first variant —
|
|
@@ -35,7 +35,6 @@ type ExperimentState = {
|
|
|
35
35
|
* const content = useIntlayer(variant === 'b' ? 'hero-b' : 'hero');
|
|
36
36
|
* ```
|
|
37
37
|
*/
|
|
38
|
-
declare const useExperiment: (experimentKey: string, variants: string[], weights?: number[]) => ExperimentState;
|
|
38
|
+
export declare const useExperiment: (experimentKey: string, variants: string[], weights?: number[]) => ExperimentState;
|
|
39
39
|
//#endregion
|
|
40
|
-
export { ExperimentState, useExperiment };
|
|
41
40
|
//# sourceMappingURL=useExperiment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useExperiment.d.ts","names":[],"sources":["../../../src/analytics/useExperiment.tsx"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"useExperiment.d.ts","names":[],"sources":["../../../src/analytics/useExperiment.tsx"],"mappings":";;;;YAQY;;;;;;EAMV;;;;;;EAMA;;;;;;;;;;;;;;;;;;;;;qBAsBW,gBAAa,uBACH,oBACH,uBAEjB"}
|
|
@@ -15,17 +15,17 @@ type IntlayerValue = {
|
|
|
15
15
|
/**
|
|
16
16
|
* Context that stores the current locale on the client side.
|
|
17
17
|
*/
|
|
18
|
-
declare const IntlayerClientContext: import("react").Context<IntlayerValue>;
|
|
18
|
+
export declare const IntlayerClientContext: import("react").Context<IntlayerValue>;
|
|
19
19
|
/**
|
|
20
20
|
* Hook that provides the current Intlayer client context.
|
|
21
21
|
*
|
|
22
22
|
* @returns The current Intlayer context values.
|
|
23
23
|
*/
|
|
24
|
-
declare const useIntlayerContext: () => {};
|
|
24
|
+
export declare const useIntlayerContext: () => {};
|
|
25
25
|
/**
|
|
26
26
|
* Props for the IntlayerProvider component.
|
|
27
27
|
*/
|
|
28
|
-
type IntlayerProviderProps = PropsWithChildren<{
|
|
28
|
+
export type IntlayerProviderProps = PropsWithChildren<{
|
|
29
29
|
/**
|
|
30
30
|
* The locale to use. If not provided, it will be detected from storage or configuration.
|
|
31
31
|
*/
|
|
@@ -74,7 +74,7 @@ type IntlayerProviderProps = PropsWithChildren<{
|
|
|
74
74
|
* @param props - The provider props.
|
|
75
75
|
* @returns The provider component.
|
|
76
76
|
*/
|
|
77
|
-
declare const IntlayerProviderContent: FC<IntlayerProviderProps>;
|
|
77
|
+
export declare const IntlayerProviderContent: FC<IntlayerProviderProps>;
|
|
78
78
|
/**
|
|
79
79
|
* Main provider for Intlayer in React applications.
|
|
80
80
|
*
|
|
@@ -95,7 +95,6 @@ declare const IntlayerProviderContent: FC<IntlayerProviderProps>;
|
|
|
95
95
|
* );
|
|
96
96
|
* ```
|
|
97
97
|
*/
|
|
98
|
-
declare const IntlayerProvider: FC<IntlayerProviderProps>;
|
|
98
|
+
export declare const IntlayerProvider: FC<IntlayerProviderProps>;
|
|
99
99
|
//#endregion
|
|
100
|
-
export { IntlayerClientContext, IntlayerProvider, IntlayerProviderContent, IntlayerProviderProps, useIntlayerContext };
|
|
101
100
|
//# sourceMappingURL=IntlayerProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerProvider.d.ts","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"mappings":";;;KAqBK;EACH,QAAQ;EACR,YAAY,WAAW;;;;;EAKvB,UAAU;EACV;EACA;;;;;
|
|
1
|
+
{"version":3,"file":"IntlayerProvider.d.ts","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"mappings":";;;KAqBK;EACH,QAAQ;EACR,YAAY,WAAW;;;;;EAKvB,UAAU;EACV;EACA;;;;;qBAMW,uCAAqB,QAAA;;;;;;qBAWrB;;;;YAKD,wBAAwB;;;;EAIlC,SAAS;;;;;;;;;;;;;;;;;;;EAmBT,UAAU;;;;EAIV,gBAAgB;;;;EAIhB,aAAa,QAAQ;;;;EAIrB;;;;EAIA;;;;;;;;;;qBAWW,yBAAyB,GAAG;;;;;;;;;;;;;;;;;;;;;qBAgF5B,kBAAkB,GAAG"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LocalesValues } from "../../intlayer/dist/types/index.js";
|
|
2
1
|
//#region src/client/format/useCompact.d.ts
|
|
3
2
|
/**
|
|
4
3
|
* React client hook that provides a compact number formatter
|
|
@@ -10,9 +9,8 @@ import { LocalesValues } from "../../intlayer/dist/types/index.js";
|
|
|
10
9
|
* formatCompact(1500); // "1.5K"
|
|
11
10
|
* ```
|
|
12
11
|
*/
|
|
13
|
-
declare const useCompact: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
14
|
-
locale?: LocalesValues;
|
|
12
|
+
export declare const useCompact: () => (value: string | number, options?: Intl.NumberFormatOptions & {
|
|
13
|
+
locale?: import("@intlayer/types").LocalesValues;
|
|
15
14
|
}) => string;
|
|
16
15
|
//#endregion
|
|
17
|
-
export { useCompact };
|
|
18
16
|
//# sourceMappingURL=useCompact.d.ts.map
|