preact-intlayer 8.9.6 → 8.9.8
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/IntlayerNode.cjs.map +1 -1
- package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
- package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
- package/dist/cjs/client/index.cjs +1 -1
- package/dist/cjs/client/t.cjs.map +1 -1
- package/dist/cjs/client/useContent.cjs.map +1 -1
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocaleBase.cjs.map +1 -1
- package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
- package/dist/cjs/client/useTraduction.cjs.map +1 -1
- package/dist/cjs/editor/ContentSelector.cjs.map +1 -1
- package/dist/cjs/editor/EditorProvider.cjs.map +1 -1
- package/dist/cjs/editor/useEditor.cjs.map +1 -1
- package/dist/cjs/format/useCompact.cjs.map +1 -1
- package/dist/cjs/format/useCurrency.cjs.map +1 -1
- package/dist/cjs/format/useDate.cjs.map +1 -1
- package/dist/cjs/format/useIntl.cjs.map +1 -1
- package/dist/cjs/format/useList.cjs.map +1 -1
- package/dist/cjs/format/useNumber.cjs.map +1 -1
- package/dist/cjs/format/usePercentage.cjs.map +1 -1
- package/dist/cjs/format/useRelativeTime.cjs.map +1 -1
- package/dist/cjs/format/useUnit.cjs.map +1 -1
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/html/HTMLProvider.cjs.map +1 -1
- package/dist/cjs/html/HTMLRenderer.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
- package/dist/cjs/markdown/MarkdownRendererPlugin.cjs.map +1 -1
- package/dist/cjs/markdown/compiler.cjs.map +1 -1
- package/dist/cjs/markdown/runtime.cjs.map +1 -1
- package/dist/cjs/plugins.cjs +36 -29
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/preactElement/renderPreactElement.cjs.map +1 -1
- package/dist/esm/IntlayerNode.mjs.map +1 -1
- package/dist/esm/UI/ContentSelector.mjs.map +1 -1
- package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/client/t.mjs.map +1 -1
- package/dist/esm/client/useContent.mjs.map +1 -1
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
- package/dist/esm/client/useDictionaryDynamic.mjs +1 -1
- package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
- package/dist/esm/client/useLocale.mjs.map +1 -1
- package/dist/esm/client/useLocaleBase.mjs.map +1 -1
- package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
- package/dist/esm/client/useTraduction.mjs.map +1 -1
- package/dist/esm/editor/ContentSelector.mjs.map +1 -1
- package/dist/esm/editor/EditorProvider.mjs.map +1 -1
- package/dist/esm/editor/useEditor.mjs.map +1 -1
- package/dist/esm/format/useCompact.mjs.map +1 -1
- package/dist/esm/format/useCurrency.mjs.map +1 -1
- package/dist/esm/format/useDate.mjs.map +1 -1
- package/dist/esm/format/useIntl.mjs.map +1 -1
- package/dist/esm/format/useList.mjs.map +1 -1
- package/dist/esm/format/useNumber.mjs.map +1 -1
- package/dist/esm/format/usePercentage.mjs.map +1 -1
- package/dist/esm/format/useRelativeTime.mjs.map +1 -1
- package/dist/esm/format/useUnit.mjs.map +1 -1
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/html/HTMLProvider.mjs.map +1 -1
- package/dist/esm/html/HTMLRenderer.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownRendererPlugin.mjs.map +1 -1
- package/dist/esm/markdown/compiler.mjs.map +1 -1
- package/dist/esm/markdown/runtime.mjs.map +1 -1
- package/dist/esm/plugins.mjs +36 -29
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/esm/preactElement/renderPreactElement.mjs.map +1 -1
- package/dist/types/IntlayerNode.d.ts.map +1 -1
- package/dist/types/UI/ContentSelector.d.ts.map +1 -1
- package/dist/types/client/IntlayerProvider.d.ts +1 -2
- package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
- package/dist/types/client/useContent.d.ts +1 -2
- package/dist/types/client/useContent.d.ts.map +1 -1
- package/dist/types/client/useDictionary.d.ts +2 -4
- package/dist/types/client/useDictionary.d.ts.map +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts +2 -4
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/client/useLocale.d.ts.map +1 -1
- package/dist/types/client/useLocaleBase.d.ts +4 -6
- package/dist/types/client/useLocaleBase.d.ts.map +1 -1
- package/dist/types/client/useLocaleStorage.d.ts +4 -5
- package/dist/types/client/useLocaleStorage.d.ts.map +1 -1
- package/dist/types/client/useTraduction.d.ts.map +1 -1
- package/dist/types/editor/ContentSelector.d.ts.map +1 -1
- package/dist/types/editor/EditorProvider.d.ts.map +1 -1
- package/dist/types/format/useCompact.d.ts +1 -3
- package/dist/types/format/useCompact.d.ts.map +1 -1
- package/dist/types/format/useCurrency.d.ts +1 -3
- package/dist/types/format/useCurrency.d.ts.map +1 -1
- package/dist/types/format/useDate.d.ts.map +1 -1
- package/dist/types/format/useIntl.d.ts.map +1 -1
- package/dist/types/format/useList.d.ts +1 -3
- package/dist/types/format/useList.d.ts.map +1 -1
- package/dist/types/format/useNumber.d.ts +1 -3
- package/dist/types/format/useNumber.d.ts.map +1 -1
- package/dist/types/format/usePercentage.d.ts +1 -3
- package/dist/types/format/usePercentage.d.ts.map +1 -1
- package/dist/types/format/useRelativeTime.d.ts +1 -3
- package/dist/types/format/useRelativeTime.d.ts.map +1 -1
- package/dist/types/format/useUnit.d.ts +1 -3
- package/dist/types/format/useUnit.d.ts.map +1 -1
- package/dist/types/html/HTMLProvider.d.ts.map +1 -1
- package/dist/types/html/HTMLRenderer.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownProvider.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownRendererPlugin.d.ts.map +1 -1
- package/dist/types/markdown/compiler.d.ts.map +1 -1
- package/dist/types/markdown/runtime.d.ts.map +1 -1
- package/dist/types/plugins.d.ts.map +1 -1
- package/dist/types/preactElement/renderPreactElement.d.ts.map +1 -1
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../src/format/useIntl.ts"],"sourcesContent":["import { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Preact client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass locale as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const { locale: contextLocale } = useContext(IntlayerClientContext) ?? {};\n const currentLocale = locale ?? contextLocale;\n\n return useMemo<WrappedIntl>(() => bindIntl(currentLocale), [currentLocale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,WAAW,WAA2B;CACjD,MAAM,EAAE,QAAQ,kBAAkB,WAAW,
|
|
1
|
+
{"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../src/format/useIntl.ts"],"sourcesContent":["import { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Preact client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass locale as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const { locale: contextLocale } = useContext(IntlayerClientContext) ?? {};\n const currentLocale = locale ?? contextLocale;\n\n return useMemo<WrappedIntl>(() => bindIntl(currentLocale), [currentLocale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,WAAW,WAA2B;CACjD,MAAM,EAAE,QAAQ,kBAAkB,WAAW,qBAAqB,KAAK,CAAC;CACxE,MAAM,gBAAgB,UAAU;CAEhC,OAAO,cAA2B,SAAS,aAAa,GAAG,CAAC,aAAa,CAAC;AAC5E"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useList.mjs","names":[],"sources":["../../../src/format/useList.ts"],"sourcesContent":["import { list } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a list formatter\n * bound to the current application locale.\n *\n * @returns {(values: (string | number)[], options?: ListProps) => string}\n * A function to format arrays into localized list strings.\n *\n * @example\n * ```tsx\n * const formatList = useList();\n *\n * formatList(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * formatList(['red', 'green', 'blue'], { type: 'disjunction' });\n * // \"red, green, or blue\"\n *\n * formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });\n * // \"1, 2 und 3\"\n * ```\n */\nexport const useList = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,WAAW,WAAW,
|
|
1
|
+
{"version":3,"file":"useList.mjs","names":[],"sources":["../../../src/format/useList.ts"],"sourcesContent":["import { list } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a list formatter\n * bound to the current application locale.\n *\n * @returns {(values: (string | number)[], options?: ListProps) => string}\n * A function to format arrays into localized list strings.\n *\n * @example\n * ```tsx\n * const formatList = useList();\n *\n * formatList(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * formatList(['red', 'green', 'blue'], { type: 'disjunction' });\n * // \"red, green, or blue\"\n *\n * formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });\n * // \"1, 2 und 3\"\n * ```\n */\nexport const useList = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,WAAW,WAAW,qBAAqB,KAAK,CAAC;CAEzD,OAAO,aACJ,GAAG,SACF,KAAK,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;CAC7B,CAAC,GACH,CAAC,MAAM,CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNumber.mjs","names":[],"sources":["../../../src/format/useNumber.ts"],"sourcesContent":["import { number } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a localized number formatter.\n *\n * Uses the current locale from {@link useLocaleBase} and returns\n * a function that can be used to format numbers consistently\n * according to the user's locale.\n *\n * @example\n * ```tsx\n * const formatNumber = useNumber();\n *\n * formatNumber(12345);\n * // e.g. \"12,345\" (en-US)\n * // e.g. \"12 345\" (fr-FR)\n *\n * formatNumber(0.75, { style: \"percent\" });\n * // e.g. \"75%\"\n * ```\n *\n * @returns {(value: string | number, options?: import(\"../createNumber\").NumberProps) => string}\n * A number formatting function bound to the active locale.\n */\nexport const useNumber = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,kBAAkB;CAC7B,MAAM,EAAE,WAAW,WAAW,
|
|
1
|
+
{"version":3,"file":"useNumber.mjs","names":[],"sources":["../../../src/format/useNumber.ts"],"sourcesContent":["import { number } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a localized number formatter.\n *\n * Uses the current locale from {@link useLocaleBase} and returns\n * a function that can be used to format numbers consistently\n * according to the user's locale.\n *\n * @example\n * ```tsx\n * const formatNumber = useNumber();\n *\n * formatNumber(12345);\n * // e.g. \"12,345\" (en-US)\n * // e.g. \"12 345\" (fr-FR)\n *\n * formatNumber(0.75, { style: \"percent\" });\n * // e.g. \"75%\"\n * ```\n *\n * @returns {(value: string | number, options?: import(\"../createNumber\").NumberProps) => string}\n * A number formatting function bound to the active locale.\n */\nexport const useNumber = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,kBAAkB;CAC7B,MAAM,EAAE,WAAW,WAAW,qBAAqB,KAAK,CAAC;CAEzD,OAAO,aACJ,GAAG,SACF,OAAO,KAAK,IAAI;EACd,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;CAC7B,CAAC,GACH,CAAC,MAAM,CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePercentage.mjs","names":[],"sources":["../../../src/format/usePercentage.ts"],"sourcesContent":["import { percentage } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React hook to provide a percentage formatter function\n * based on the current application locale.\n *\n * This hook retrieves the active locale using {@link useLocaleBase}\n * and memoizes a `createPercentage` instance for that locale.\n *\n * @example\n * ```tsx\n * const formatPercentage = usePercentage();\n *\n * const result = formatPercentage(0.875, { maximumFractionDigits: 1 });\n * // \"87.5%\" (depending on locale)\n * ```\n *\n * @returns {(value: string | number, options?: Omit<PercentageOptions, \"value\">) => string}\n * A function that formats numbers or numeric strings into localized percentages.\n */\nexport const usePercentage = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,sBAAsB;CACjC,MAAM,EAAE,WAAW,WAAW,
|
|
1
|
+
{"version":3,"file":"usePercentage.mjs","names":[],"sources":["../../../src/format/usePercentage.ts"],"sourcesContent":["import { percentage } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React hook to provide a percentage formatter function\n * based on the current application locale.\n *\n * This hook retrieves the active locale using {@link useLocaleBase}\n * and memoizes a `createPercentage` instance for that locale.\n *\n * @example\n * ```tsx\n * const formatPercentage = usePercentage();\n *\n * const result = formatPercentage(0.875, { maximumFractionDigits: 1 });\n * // \"87.5%\" (depending on locale)\n * ```\n *\n * @returns {(value: string | number, options?: Omit<PercentageOptions, \"value\">) => string}\n * A function that formats numbers or numeric strings into localized percentages.\n */\nexport const usePercentage = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,sBAAsB;CACjC,MAAM,EAAE,WAAW,WAAW,qBAAqB,KAAK,CAAC;CAEzD,OAAO,aACJ,GAAG,SACF,WAAW,KAAK,IAAI;EAClB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;CAC7B,CAAC,GACH,CAAC,MAAM,CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRelativeTime.mjs","names":[],"sources":["../../../src/format/useRelativeTime.ts"],"sourcesContent":["import { relativeTime } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Client-side React hook for accessing a localized relative time formatter.\n *\n * This hook:\n * - Reads the current locale from {@link useLocaleBase}.\n * - Creates a new relative time formatter with {@link createRelativeTime}.\n * - Returns a function that can format time differences into localized strings.\n *\n * Example:\n * ```tsx\n * const relativeTime = useRelativeTime();\n * const formatted = relativeTime(new Date(\"2024-08-01\"), new Date());\n * // e.g., \"2 weeks ago\"\n * ```\n *\n * @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function\n * bound to the current client locale.\n */\nexport const useRelativeTime = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1], {\n ...args[2],\n locale: args[2]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,wBAAwB;CACnC,MAAM,EAAE,WAAW,WAAW,
|
|
1
|
+
{"version":3,"file":"useRelativeTime.mjs","names":[],"sources":["../../../src/format/useRelativeTime.ts"],"sourcesContent":["import { relativeTime } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Client-side React hook for accessing a localized relative time formatter.\n *\n * This hook:\n * - Reads the current locale from {@link useLocaleBase}.\n * - Creates a new relative time formatter with {@link createRelativeTime}.\n * - Returns a function that can format time differences into localized strings.\n *\n * Example:\n * ```tsx\n * const relativeTime = useRelativeTime();\n * const formatted = relativeTime(new Date(\"2024-08-01\"), new Date());\n * // e.g., \"2 weeks ago\"\n * ```\n *\n * @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function\n * bound to the current client locale.\n */\nexport const useRelativeTime = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1], {\n ...args[2],\n locale: args[2]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,wBAAwB;CACnC,MAAM,EAAE,WAAW,WAAW,qBAAqB,KAAK,CAAC;CAEzD,OAAO,aACJ,GAAG,SACF,aAAa,KAAK,IAAI,KAAK,IAAI;EAC7B,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;CAC7B,CAAC,GACH,CAAC,MAAM,CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUnit.mjs","names":[],"sources":["../../../src/format/useUnit.ts"],"sourcesContent":["import { units } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React hook that provides a unit formatting function\n * based on the current locale from {@link useLocaleBase}.\n *\n * This hook wraps {@link createUnit} to return a formatter\n * that can convert values into human-readable localized units\n * (e.g., \"10 km\", \"5 lbs\").\n *\n * @example\n * ```tsx\n * const formatUnit = useUnit();\n * const distance = formatUnit(10, { unit: \"kilometer\" });\n * // \"10 km\" (depending on locale)\n * ```\n *\n * @returns {Function} A unit formatting function that accepts a value and optional formatting options.\n */\nexport const useUnit = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,WAAW,WAAW,
|
|
1
|
+
{"version":3,"file":"useUnit.mjs","names":[],"sources":["../../../src/format/useUnit.ts"],"sourcesContent":["import { units } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React hook that provides a unit formatting function\n * based on the current locale from {@link useLocaleBase}.\n *\n * This hook wraps {@link createUnit} to return a formatter\n * that can convert values into human-readable localized units\n * (e.g., \"10 km\", \"5 lbs\").\n *\n * @example\n * ```tsx\n * const formatUnit = useUnit();\n * const distance = formatUnit(10, { unit: \"kilometer\" });\n * // \"10 km\" (depending on locale)\n * ```\n *\n * @returns {Function} A unit formatting function that accepts a value and optional formatting options.\n */\nexport const useUnit = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,WAAW,WAAW,qBAAqB,KAAK,CAAC;CAEzD,OAAO,aACJ,GAAG,SACF,MAAM,KAAK,IAAI;EACb,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;CAC7B,CAAC,GACH,CAAC,MAAM,CACT;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDictionary.mjs","names":["getDictionaryCore"],"sources":["../../src/getDictionary.ts"],"sourcesContent":["import { getDictionary as getDictionaryCore } from '@intlayer/core/interpreter';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n): DeepTransformContent<T['content']> =>\n getDictionaryCore<T, L>(dictionary, locale, getPlugins(locale)) as any;\n"],"mappings":";;;;AAQA,MAAa,iBAIX,YACA,WAEAA,gBAAwB,YAAY,QAAQ,WAAW,
|
|
1
|
+
{"version":3,"file":"getDictionary.mjs","names":["getDictionaryCore"],"sources":["../../src/getDictionary.ts"],"sourcesContent":["import { getDictionary as getDictionaryCore } from '@intlayer/core/interpreter';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n): DeepTransformContent<T['content']> =>\n getDictionaryCore<T, L>(dictionary, locale, getPlugins(locale)) as any;\n"],"mappings":";;;;AAQA,MAAa,iBAIX,YACA,WAEAA,gBAAwB,YAAY,QAAQ,WAAW,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIntlayer.mjs","names":["getIntlayerCore"],"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import { getIntlayer as getIntlayerCore } from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\nexport const getIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L\n) =>\n getIntlayerCore<T, L>(\n key,\n locale,\n getPlugins(locale)\n ) as DeepTransformContent<DictionaryRegistryContent<T>>;\n"],"mappings":";;;;AASA,MAAa,eAIX,KACA,WAEAA,cACE,KACA,QACA,WAAW,
|
|
1
|
+
{"version":3,"file":"getIntlayer.mjs","names":["getIntlayerCore"],"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import { getIntlayer as getIntlayerCore } from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\nexport const getIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L\n) =>\n getIntlayerCore<T, L>(\n key,\n locale,\n getPlugins(locale)\n ) as DeepTransformContent<DictionaryRegistryContent<T>>;\n"],"mappings":";;;;AASA,MAAa,eAIX,KACA,WAEAA,cACE,KACA,QACA,WAAW,MAAM,CACnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HTMLProvider.mjs","names":[],"sources":["../../../src/html/HTMLProvider.tsx"],"sourcesContent":["import {\n createContext,\n type FunctionalComponent,\n type RenderableProps,\n} from 'preact';\nimport { useContext } from 'preact/hooks';\nimport type { HTMLComponents } from './types';\n\ntype HTMLContextValue = {\n components?: HTMLComponents<'permissive', {}>;\n};\n\ntype HTMLProviderProps = RenderableProps<{\n /**\n * Component overrides for HTML tags.\n */\n components?: HTMLComponents<'permissive', {}>;\n}>;\n\nconst HTMLContext = createContext<HTMLContextValue | undefined>(undefined);\n\nexport const useHTMLContext = () => useContext(HTMLContext);\n\nexport const HTMLProvider: FunctionalComponent<HTMLProviderProps> = ({\n children,\n components,\n}) => (\n <HTMLContext.Provider value={{ components }}>{children}</HTMLContext.Provider>\n);\n"],"mappings":";;;;;AAmBA,MAAM,cAAc,cAA4C,
|
|
1
|
+
{"version":3,"file":"HTMLProvider.mjs","names":[],"sources":["../../../src/html/HTMLProvider.tsx"],"sourcesContent":["import {\n createContext,\n type FunctionalComponent,\n type RenderableProps,\n} from 'preact';\nimport { useContext } from 'preact/hooks';\nimport type { HTMLComponents } from './types';\n\ntype HTMLContextValue = {\n components?: HTMLComponents<'permissive', {}>;\n};\n\ntype HTMLProviderProps = RenderableProps<{\n /**\n * Component overrides for HTML tags.\n */\n components?: HTMLComponents<'permissive', {}>;\n}>;\n\nconst HTMLContext = createContext<HTMLContextValue | undefined>(undefined);\n\nexport const useHTMLContext = () => useContext(HTMLContext);\n\nexport const HTMLProvider: FunctionalComponent<HTMLProviderProps> = ({\n children,\n components,\n}) => (\n <HTMLContext.Provider value={{ components }}>{children}</HTMLContext.Provider>\n);\n"],"mappings":";;;;;AAmBA,MAAM,cAAc,cAA4C,MAAS;AAEzE,MAAa,uBAAuB,WAAW,WAAW;AAE1D,MAAa,gBAAwD,EACnE,UACA,iBAEA,oBAAC,YAAY,UAAb;CAAsB,OAAO,EAAE,WAAW;CAAI;AAA+B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HTMLRenderer.mjs","names":[],"sources":["../../../src/html/HTMLRenderer.tsx"],"sourcesContent":["import { getHTML } from '@intlayer/core/interpreter';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { Fragment, type FunctionComponent, h, type JSX } from 'preact';\nimport { useHTMLContext } from './HTMLProvider';\nimport type { HTMLComponents } from './types';\n\nexport type RenderHTMLProps = {\n /**\n * Component overrides for HTML tags.\n * Allows you to customize how specific HTML elements are rendered.\n */\n components?: HTMLComponents<'permissive', {}>;\n};\n\n/**\n * Renders HTML-like content to JSX with the provided components.\n *\n * This function does not use context from HTMLProvider. Use `useHTMLRenderer`\n * hook if you want to leverage provider context.\n */\nexport const renderHTML = (\n content: string,\n { components = {} }: RenderHTMLProps = {}\n): JSX.Element => {\n // Wrap explicit user components to ensure they are rendered via Preact's h\n const userComponents = Object.fromEntries(\n Object.entries(components)\n .filter(([, Component]) => Component)\n .map(([key, Component]) => [\n key,\n (props: any) => h(Component as any, props),\n ])\n );\n\n // Proxy handles standard HTML tags lazily without a hardcoded list\n const wrappedComponents = new Proxy(userComponents, {\n get(target, prop) {\n if (typeof prop === 'string' && prop in target) {\n return target[prop];\n }\n // Fallback: Lazily generate a wrapper for standard lowercase HTML tags\n if (typeof prop === 'string' && /^[a-z][a-z0-9]*$/.test(prop)) {\n return (props: any) => h(prop, props);\n }\n return undefined;\n },\n });\n\n // Cast wrappedComponents to any to satisfy getHTML's dictionary typing\n return h(Fragment, null, getHTML(content, wrappedComponents as any));\n};\n\n/**\n * Hook that returns a function to render HTML content.\n *\n * This hook considers the configuration from the `HTMLProvider` context if available,\n * falling back to the provided components.\n */\nexport const useHTMLRenderer = ({ components }: RenderHTMLProps = {}) => {\n const context = useHTMLContext();\n\n return (content: string) => {\n return renderHTML(content, {\n components: {\n ...context?.components,\n ...components,\n },\n });\n };\n};\n\nexport type HTMLRendererProps = RenderHTMLProps & {\n /**\n * The HTML content to render as a string.\n */\n children?: string;\n /**\n * Alias for children, used by the plugin.\n */\n html?: string;\n /**\n * Alias for components, used by the plugin.\n */\n components?: HTMLComponents<'permissive', {}>;\n dictionaryKey?: string;\n keyPath?: KeyPath[];\n};\n\n/**\n * Preact component that renders HTML-like content to JSX.\n */\nexport const HTMLRenderer: FunctionComponent<HTMLRendererProps> = ({\n children = '',\n html,\n components,\n}) => {\n const render = useHTMLRenderer({ components });\n const content = children || html || '';\n\n return render(content);\n};\n"],"mappings":";;;;;;;;;;;AAoBA,MAAa,cACX,SACA,EAAE,aAAa,
|
|
1
|
+
{"version":3,"file":"HTMLRenderer.mjs","names":[],"sources":["../../../src/html/HTMLRenderer.tsx"],"sourcesContent":["import { getHTML } from '@intlayer/core/interpreter';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { Fragment, type FunctionComponent, h, type JSX } from 'preact';\nimport { useHTMLContext } from './HTMLProvider';\nimport type { HTMLComponents } from './types';\n\nexport type RenderHTMLProps = {\n /**\n * Component overrides for HTML tags.\n * Allows you to customize how specific HTML elements are rendered.\n */\n components?: HTMLComponents<'permissive', {}>;\n};\n\n/**\n * Renders HTML-like content to JSX with the provided components.\n *\n * This function does not use context from HTMLProvider. Use `useHTMLRenderer`\n * hook if you want to leverage provider context.\n */\nexport const renderHTML = (\n content: string,\n { components = {} }: RenderHTMLProps = {}\n): JSX.Element => {\n // Wrap explicit user components to ensure they are rendered via Preact's h\n const userComponents = Object.fromEntries(\n Object.entries(components)\n .filter(([, Component]) => Component)\n .map(([key, Component]) => [\n key,\n (props: any) => h(Component as any, props),\n ])\n );\n\n // Proxy handles standard HTML tags lazily without a hardcoded list\n const wrappedComponents = new Proxy(userComponents, {\n get(target, prop) {\n if (typeof prop === 'string' && prop in target) {\n return target[prop];\n }\n // Fallback: Lazily generate a wrapper for standard lowercase HTML tags\n if (typeof prop === 'string' && /^[a-z][a-z0-9]*$/.test(prop)) {\n return (props: any) => h(prop, props);\n }\n return undefined;\n },\n });\n\n // Cast wrappedComponents to any to satisfy getHTML's dictionary typing\n return h(Fragment, null, getHTML(content, wrappedComponents as any));\n};\n\n/**\n * Hook that returns a function to render HTML content.\n *\n * This hook considers the configuration from the `HTMLProvider` context if available,\n * falling back to the provided components.\n */\nexport const useHTMLRenderer = ({ components }: RenderHTMLProps = {}) => {\n const context = useHTMLContext();\n\n return (content: string) => {\n return renderHTML(content, {\n components: {\n ...context?.components,\n ...components,\n },\n });\n };\n};\n\nexport type HTMLRendererProps = RenderHTMLProps & {\n /**\n * The HTML content to render as a string.\n */\n children?: string;\n /**\n * Alias for children, used by the plugin.\n */\n html?: string;\n /**\n * Alias for components, used by the plugin.\n */\n components?: HTMLComponents<'permissive', {}>;\n dictionaryKey?: string;\n keyPath?: KeyPath[];\n};\n\n/**\n * Preact component that renders HTML-like content to JSX.\n */\nexport const HTMLRenderer: FunctionComponent<HTMLRendererProps> = ({\n children = '',\n html,\n components,\n}) => {\n const render = useHTMLRenderer({ components });\n const content = children || html || '';\n\n return render(content);\n};\n"],"mappings":";;;;;;;;;;;AAoBA,MAAa,cACX,SACA,EAAE,aAAa,CAAC,MAAuB,CAAC,MACxB;CAEhB,MAAM,iBAAiB,OAAO,YAC5B,OAAO,QAAQ,UAAU,EACtB,QAAQ,GAAG,eAAe,SAAS,EACnC,KAAK,CAAC,KAAK,eAAe,CACzB,MACC,UAAe,EAAE,WAAkB,KAAK,CAC3C,CAAC,CACL;CAiBA,OAAO,EAAE,UAAU,MAAM,QAAQ,SAAS,IAdZ,MAAM,gBAAgB,EAClD,IAAI,QAAQ,MAAM;EAChB,IAAI,OAAO,SAAS,YAAY,QAAQ,QACtC,OAAO,OAAO;EAGhB,IAAI,OAAO,SAAS,YAAY,mBAAmB,KAAK,IAAI,GAC1D,QAAQ,UAAe,EAAE,MAAM,KAAK;CAGxC,EACF,CAG0D,CAAQ,CAAC;AACrE;;;;;;;AAQA,MAAa,mBAAmB,EAAE,eAAgC,CAAC,MAAM;CACvE,MAAM,UAAU,eAAe;CAE/B,QAAQ,YAAoB;EAC1B,OAAO,WAAW,SAAS,EACzB,YAAY;GACV,GAAG,SAAS;GACZ,GAAG;EACL,EACF,CAAC;CACH;AACF;;;;AAsBA,MAAa,gBAAsD,EACjE,WAAW,IACX,MACA,iBACI;CAIJ,OAHe,gBAAgB,EAAE,WAAW,CAGhC,EAFI,YAAY,QAAQ,EAEf;AACvB"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useLoadDynamic } from "./client/useLoadDynamic.mjs";
|
|
1
2
|
import { getIntlayer } from "./getIntlayer.mjs";
|
|
2
3
|
import { getDictionary } from "./getDictionary.mjs";
|
|
3
4
|
import { localeCookie, setLocaleCookie, setLocaleInStorage, useLocaleCookie, useLocaleStorage } from "./client/useLocaleStorage.mjs";
|
|
@@ -5,7 +6,6 @@ import { IntlayerClientContext, IntlayerProvider, IntlayerProviderContent, useIn
|
|
|
5
6
|
import { t } from "./client/t.mjs";
|
|
6
7
|
import { useDictionary } from "./client/useDictionary.mjs";
|
|
7
8
|
import { useDictionaryAsync } from "./client/useDictionaryAsync.mjs";
|
|
8
|
-
import { useLoadDynamic } from "./client/useLoadDynamic.mjs";
|
|
9
9
|
import { useDictionaryDynamic } from "./client/useDictionaryDynamic.mjs";
|
|
10
10
|
import { useIntlayer } from "./client/useIntlayer.mjs";
|
|
11
11
|
import { useLocale } from "./client/useLocale.mjs";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownProvider.mjs","names":[],"sources":["../../../src/markdown/MarkdownProvider.tsx"],"sourcesContent":["import {\n type ComponentChildren,\n type ComponentType,\n createContext,\n type FunctionComponent,\n type JSX,\n} from 'preact';\nimport { useContext } from 'preact/hooks';\nimport type { HTMLComponents } from '../html/types';\nimport { compileMarkdown } from './compiler';\n\ntype PropsWithChildren<P = {}> = P & { children?: ComponentChildren };\n\n/**\n * Refined options for the MarkdownProvider.\n */\nexport type MarkdownProviderOptions = {\n /**\n * Forces the compiler to always output content with a block-level wrapper.\n */\n forceBlock?: boolean;\n /**\n * Forces the compiler to always output content with an inline wrapper.\n */\n forceInline?: boolean;\n /**\n * Whether to preserve frontmatter in the markdown content.\n */\n preserveFrontmatter?: boolean;\n /**\n * Whether to use the GitHub Tag Filter.\n */\n tagfilter?: boolean;\n};\n\ntype RenderMarkdownOptions = MarkdownProviderOptions & {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n forceWrapper?: boolean;\n};\n\ntype MarkdownContextValue = {\n components?: HTMLComponents<'permissive', {}>;\n renderMarkdown: (\n markdown: string,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n ) => ComponentChildren | Promise<ComponentChildren>;\n};\n\ntype MarkdownProviderProps = PropsWithChildren<\n MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n */\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite all rules and default rendering.\n */\n renderMarkdown?: (\n markdown: string,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n ) => ComponentChildren | Promise<ComponentChildren>;\n }\n>;\n\nconst MarkdownContext = createContext<MarkdownContextValue | undefined>(\n undefined\n);\n\nexport const useMarkdownContext = () => useContext(MarkdownContext);\n\nconst mergeOptions = (\n baseComponents: HTMLComponents<'permissive', {}> | undefined,\n baseOptions: Omit<RenderMarkdownOptions, 'components'>,\n options: MarkdownProviderOptions = {},\n components: HTMLComponents<'permissive', {}> = {},\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n): RenderMarkdownOptions => {\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 forceWrapper: !!(wrapper || baseOptions.wrapper),\n components: { ...baseComponents, ...components },\n };\n};\n\nexport const MarkdownProvider: FunctionComponent<MarkdownProviderProps> = ({\n children,\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRenderFn,\n}) => {\n const baseOptions: Omit<RenderMarkdownOptions, '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,\n options?: MarkdownProviderOptions,\n componentsOverride?: HTMLComponents<'permissive', {}>,\n wrapperOverride?: ComponentType<any> | keyof JSX.IntrinsicElements\n ): ComponentChildren => {\n const mergedOptions = mergeOptions(\n components,\n baseOptions,\n options,\n componentsOverride ?? {},\n wrapperOverride\n );\n return compileMarkdown(markdown, mergedOptions) as ComponentChildren;\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,\n options?: MarkdownProviderOptions,\n componentsOverride?: HTMLComponents<'permissive', {}>,\n wrapperOverride?: ComponentType<any> | keyof JSX.IntrinsicElements\n ): ComponentChildren => (\n <MarkdownContext.Provider value={undefined}>\n {customRenderFn?.(markdown, options, componentsOverride, wrapperOverride)}\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":";;;;;;AA0EA,MAAM,kBAAkB,cACtB,
|
|
1
|
+
{"version":3,"file":"MarkdownProvider.mjs","names":[],"sources":["../../../src/markdown/MarkdownProvider.tsx"],"sourcesContent":["import {\n type ComponentChildren,\n type ComponentType,\n createContext,\n type FunctionComponent,\n type JSX,\n} from 'preact';\nimport { useContext } from 'preact/hooks';\nimport type { HTMLComponents } from '../html/types';\nimport { compileMarkdown } from './compiler';\n\ntype PropsWithChildren<P = {}> = P & { children?: ComponentChildren };\n\n/**\n * Refined options for the MarkdownProvider.\n */\nexport type MarkdownProviderOptions = {\n /**\n * Forces the compiler to always output content with a block-level wrapper.\n */\n forceBlock?: boolean;\n /**\n * Forces the compiler to always output content with an inline wrapper.\n */\n forceInline?: boolean;\n /**\n * Whether to preserve frontmatter in the markdown content.\n */\n preserveFrontmatter?: boolean;\n /**\n * Whether to use the GitHub Tag Filter.\n */\n tagfilter?: boolean;\n};\n\ntype RenderMarkdownOptions = MarkdownProviderOptions & {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n forceWrapper?: boolean;\n};\n\ntype MarkdownContextValue = {\n components?: HTMLComponents<'permissive', {}>;\n renderMarkdown: (\n markdown: string,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n ) => ComponentChildren | Promise<ComponentChildren>;\n};\n\ntype MarkdownProviderProps = PropsWithChildren<\n MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n */\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite all rules and default rendering.\n */\n renderMarkdown?: (\n markdown: string,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n ) => ComponentChildren | Promise<ComponentChildren>;\n }\n>;\n\nconst MarkdownContext = createContext<MarkdownContextValue | undefined>(\n undefined\n);\n\nexport const useMarkdownContext = () => useContext(MarkdownContext);\n\nconst mergeOptions = (\n baseComponents: HTMLComponents<'permissive', {}> | undefined,\n baseOptions: Omit<RenderMarkdownOptions, 'components'>,\n options: MarkdownProviderOptions = {},\n components: HTMLComponents<'permissive', {}> = {},\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n): RenderMarkdownOptions => {\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 forceWrapper: !!(wrapper || baseOptions.wrapper),\n components: { ...baseComponents, ...components },\n };\n};\n\nexport const MarkdownProvider: FunctionComponent<MarkdownProviderProps> = ({\n children,\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRenderFn,\n}) => {\n const baseOptions: Omit<RenderMarkdownOptions, '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,\n options?: MarkdownProviderOptions,\n componentsOverride?: HTMLComponents<'permissive', {}>,\n wrapperOverride?: ComponentType<any> | keyof JSX.IntrinsicElements\n ): ComponentChildren => {\n const mergedOptions = mergeOptions(\n components,\n baseOptions,\n options,\n componentsOverride ?? {},\n wrapperOverride\n );\n return compileMarkdown(markdown, mergedOptions) as ComponentChildren;\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,\n options?: MarkdownProviderOptions,\n componentsOverride?: HTMLComponents<'permissive', {}>,\n wrapperOverride?: ComponentType<any> | keyof JSX.IntrinsicElements\n ): ComponentChildren => (\n <MarkdownContext.Provider value={undefined}>\n {customRenderFn?.(markdown, options, componentsOverride, wrapperOverride)}\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":";;;;;;AA0EA,MAAM,kBAAkB,cACtB,MACF;AAEA,MAAa,2BAA2B,WAAW,eAAe;AAElE,MAAM,gBACJ,gBACA,aACA,UAAmC,CAAC,GACpC,aAA+C,CAAC,GAChD,YAC0B;CAC1B,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;EAChC,cAAc,CAAC,EAAE,WAAW,YAAY;EACxC,YAAY;GAAE,GAAG;GAAgB,GAAG;EAAW;CACjD;AACF;AAEA,MAAa,oBAA8D,EACzE,UACA,YACA,SACA,YACA,aACA,qBACA,WACA,gBAAgB,qBACZ;CACJ,MAAM,cAAyD;EAC7D;EACA;EACA;EACA,cAAc,CAAC,CAAC;EAChB;EACA;CACF;CAGA,MAAM,yBACJ,UACA,SACA,oBACA,oBACsB;EAQtB,OAAO,gBAAgB,UAPD,aACpB,YACA,aACA,SACA,sBAAsB,CAAC,GACvB,eAE2C,CAAC;CAChD;CAIA,MAAM,+BACJ,UACA,SACA,oBACA,oBAEA,oBAAC,gBAAgB,UAAjB;EAA0B,OAAO;YAC9B,iBAAiB,UAAU,SAAS,oBAAoB,eAAe;CAChD;CAG5B,OACE,oBAAC,gBAAgB,UAAjB;EACE,OAAO;GACL;GACA,gBAAgB,iBACZ,8BACA;EACN;EAEC;CACuB;AAE9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownRenderer.mjs","names":[],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["import type {\n ComponentChildren,\n ComponentType,\n FunctionComponent,\n JSX,\n} from 'preact';\nimport type { HTMLComponents } from '../html/types';\nimport { compileMarkdown, type MarkdownCompilerOptions } from './compiler';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\n\nexport type RenderMarkdownProps = MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n * Only used if not wrapped in a MarkdownProvider.\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n * Only used if not wrapped in a MarkdownProvider.\n */\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n};\n\nexport const renderMarkdown = (\n content: string,\n {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n }: RenderMarkdownProps = {}\n): JSX.Element => {\n // Map public options to internal processor options\n const internalOptions: MarkdownCompilerOptions = {\n components,\n forceBlock,\n forceInline,\n wrapper: wrapper as any,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n return compileMarkdown(content, internalOptions) as JSX.Element;\n};\n\nexport const useMarkdownRenderer = ({\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n}: RenderMarkdownProps = {}) => {\n const context = useMarkdownContext();\n\n return (content: string) => {\n if (context) {\n return context.renderMarkdown(\n content,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n );\n }\n\n return renderMarkdown(content, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n };\n};\n\nexport type MarkdownRendererProps = RenderMarkdownProps & {\n /**\n * The markdown content to render.\n */\n children: string;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite context and default rendering.\n */\n renderMarkdown?: (\n markdown: string,\n options?: {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n forceBlock?: boolean;\n forceInline?: boolean;\n preserveFrontmatter?: boolean;\n tagfilter?: boolean;\n }\n ) => ComponentChildren | Promise<ComponentChildren>;\n};\n\n/**\n * Preact component that renders markdown to JSX.\n *\n * It uses the renderMarkdown function from the MarkdownProvider context if available.\n * Otherwise, it falls back to the default compiler with provided components and options.\n */\nexport const MarkdownRenderer: FunctionComponent<MarkdownRendererProps> = ({\n children = '',\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRenderMarkdown,\n}) => {\n const context = useMarkdownContext();\n\n if (customRenderMarkdown) {\n return (\n <>\n {customRenderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n })}\n </>\n );\n }\n\n if (context) {\n return (\n <>\n {context.renderMarkdown(\n children,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n )}\n </>\n );\n }\n\n return renderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n};\n"],"mappings":";;;;;AA0BA,MAAa,kBACX,SACA,EACE,YACA,SACA,YACA,aACA,qBACA,cACuB,
|
|
1
|
+
{"version":3,"file":"MarkdownRenderer.mjs","names":[],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["import type {\n ComponentChildren,\n ComponentType,\n FunctionComponent,\n JSX,\n} from 'preact';\nimport type { HTMLComponents } from '../html/types';\nimport { compileMarkdown, type MarkdownCompilerOptions } from './compiler';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\n\nexport type RenderMarkdownProps = MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n * Only used if not wrapped in a MarkdownProvider.\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n * Only used if not wrapped in a MarkdownProvider.\n */\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n};\n\nexport const renderMarkdown = (\n content: string,\n {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n }: RenderMarkdownProps = {}\n): JSX.Element => {\n // Map public options to internal processor options\n const internalOptions: MarkdownCompilerOptions = {\n components,\n forceBlock,\n forceInline,\n wrapper: wrapper as any,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n return compileMarkdown(content, internalOptions) as JSX.Element;\n};\n\nexport const useMarkdownRenderer = ({\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n}: RenderMarkdownProps = {}) => {\n const context = useMarkdownContext();\n\n return (content: string) => {\n if (context) {\n return context.renderMarkdown(\n content,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n );\n }\n\n return renderMarkdown(content, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n };\n};\n\nexport type MarkdownRendererProps = RenderMarkdownProps & {\n /**\n * The markdown content to render.\n */\n children: string;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite context and default rendering.\n */\n renderMarkdown?: (\n markdown: string,\n options?: {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n forceBlock?: boolean;\n forceInline?: boolean;\n preserveFrontmatter?: boolean;\n tagfilter?: boolean;\n }\n ) => ComponentChildren | Promise<ComponentChildren>;\n};\n\n/**\n * Preact component that renders markdown to JSX.\n *\n * It uses the renderMarkdown function from the MarkdownProvider context if available.\n * Otherwise, it falls back to the default compiler with provided components and options.\n */\nexport const MarkdownRenderer: FunctionComponent<MarkdownRendererProps> = ({\n children = '',\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRenderMarkdown,\n}) => {\n const context = useMarkdownContext();\n\n if (customRenderMarkdown) {\n return (\n <>\n {customRenderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n })}\n </>\n );\n }\n\n if (context) {\n return (\n <>\n {context.renderMarkdown(\n children,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n )}\n </>\n );\n }\n\n return renderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n};\n"],"mappings":";;;;;AA0BA,MAAa,kBACX,SACA,EACE,YACA,SACA,YACA,aACA,qBACA,cACuB,CAAC,MACV;CAYhB,OAAO,gBAAgB,SAAS;EAT9B;EACA;EACA;EACS;EACT,cAAc,CAAC,CAAC;EAChB;EACA;CAG4C,CAAC;AACjD;AAEA,MAAa,uBAAuB,EAClC,YACA,SACA,YACA,aACA,qBACA,cACuB,CAAC,MAAM;CAC9B,MAAM,UAAU,mBAAmB;CAEnC,QAAQ,YAAoB;EAC1B,IAAI,SACF,OAAO,QAAQ,eACb,SACA;GACE;GACA;GACA;GACA;EACF,GACA,YACA,OACF;EAGF,OAAO,eAAe,SAAS;GAC7B;GACA;GACA;GACA;GACA;GACA;EACF,CAAC;CACH;AACF;;;;;;;AA8BA,MAAa,oBAA8D,EACzE,WAAW,IACX,YACA,SACA,YACA,aACA,qBACA,WACA,gBAAgB,2BACZ;CACJ,MAAM,UAAU,mBAAmB;CAEnC,IAAI,sBACF,OACE,0CACG,qBAAqB,UAAU;EAC9B;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,EACD;CAIN,IAAI,SACF,OACE,0CACG,QAAQ,eACP,UACA;EACE;EACA;EACA;EACA;CACF,GACA,YACA,OACF,EACA;CAIN,OAAO,eAAe,UAAU;EAC9B;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownRendererPlugin.mjs","names":[],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"sourcesContent":["'use client';\n\nimport { getContentNodeByKeyPath } from '@intlayer/core/dictionaryManipulator';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { ComponentChildren, FunctionComponent } from 'preact';\nimport { useLocale } from '../client/useLocale';\nimport type { HTMLComponents } from '../html/types';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\n\ntype MarkdownRendererPluginProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: LocalesValues;\n children: string;\n options?: MarkdownProviderOptions;\n components?: HTMLComponents<'permissive', {}>;\n};\n\nexport const MarkdownRendererPlugin: FunctionComponent<\n MarkdownRendererPluginProps\n> = (props): ComponentChildren => {\n const { children, options, components } = props;\n const context = useMarkdownContext();\n const renderMarkdown = context?.renderMarkdown ?? ((md) => md);\n\n return renderMarkdown(children, options, {\n ...(context?.components ?? {}),\n ...(components ?? {}),\n }) as ComponentChildren;\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererPluginProps & {\n metadataKeyPath: KeyPath[];\n};\n\nexport const MarkdownMetadataRenderer: FunctionComponent<\n MarkdownMetadataRendererProps\n> = ({ children, metadataKeyPath }): ComponentChildren => {\n const { locale: currentLocale } = useLocale();\n\n const metadata = getMarkdownMetadata(children);\n\n const metadataEl = getContentNodeByKeyPath(\n metadata as ContentNode,\n metadataKeyPath,\n currentLocale as any\n );\n\n return metadataEl as ComponentChildren;\n};\n"],"mappings":";;;;;;;;AAwBA,MAAa,0BAER,UAA6B;CAChC,MAAM,EAAE,UAAU,SAAS,eAAe;CAC1C,MAAM,UAAU,
|
|
1
|
+
{"version":3,"file":"MarkdownRendererPlugin.mjs","names":[],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"sourcesContent":["'use client';\n\nimport { getContentNodeByKeyPath } from '@intlayer/core/dictionaryManipulator';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { ComponentChildren, FunctionComponent } from 'preact';\nimport { useLocale } from '../client/useLocale';\nimport type { HTMLComponents } from '../html/types';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\n\ntype MarkdownRendererPluginProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: LocalesValues;\n children: string;\n options?: MarkdownProviderOptions;\n components?: HTMLComponents<'permissive', {}>;\n};\n\nexport const MarkdownRendererPlugin: FunctionComponent<\n MarkdownRendererPluginProps\n> = (props): ComponentChildren => {\n const { children, options, components } = props;\n const context = useMarkdownContext();\n const renderMarkdown = context?.renderMarkdown ?? ((md) => md);\n\n return renderMarkdown(children, options, {\n ...(context?.components ?? {}),\n ...(components ?? {}),\n }) as ComponentChildren;\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererPluginProps & {\n metadataKeyPath: KeyPath[];\n};\n\nexport const MarkdownMetadataRenderer: FunctionComponent<\n MarkdownMetadataRendererProps\n> = ({ children, metadataKeyPath }): ComponentChildren => {\n const { locale: currentLocale } = useLocale();\n\n const metadata = getMarkdownMetadata(children);\n\n const metadataEl = getContentNodeByKeyPath(\n metadata as ContentNode,\n metadataKeyPath,\n currentLocale as any\n );\n\n return metadataEl as ComponentChildren;\n};\n"],"mappings":";;;;;;;;AAwBA,MAAa,0BAER,UAA6B;CAChC,MAAM,EAAE,UAAU,SAAS,eAAe;CAC1C,MAAM,UAAU,mBAAmB;CAGnC,QAFuB,SAAS,oBAAoB,OAAO,KAErC,UAAU,SAAS;EACvC,GAAI,SAAS,cAAc,CAAC;EAC5B,GAAI,cAAc,CAAC;CACrB,CAAC;AACH;AAMA,MAAa,4BAER,EAAE,UAAU,sBAAyC;CACxD,MAAM,EAAE,QAAQ,kBAAkB,UAAU;CAU5C,OANmB,wBAFF,oBAAoB,QAG5B,GACP,iBACA,aAGc;AAClB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.mjs","names":[],"sources":["../../../src/markdown/compiler.ts"],"sourcesContent":["/**\n * Preact adapter for the framework-agnostic markdown processor.\n */\n\nimport {\n type CompileOptions,\n compileWithOptions,\n sanitizer as defaultSanitizer,\n slugify as defaultSlugify,\n RuleType,\n} from '@intlayer/core/markdown';\nimport { preactRuntime } from './runtime';\n\n// Re-export RuleType and utilities for compatibility\nexport {
|
|
1
|
+
{"version":3,"file":"compiler.mjs","names":[],"sources":["../../../src/markdown/compiler.ts"],"sourcesContent":["/**\n * Preact adapter for the framework-agnostic markdown processor.\n */\n\nimport {\n type CompileOptions,\n compileWithOptions,\n sanitizer as defaultSanitizer,\n slugify as defaultSlugify,\n RuleType,\n} from '@intlayer/core/markdown';\nimport { preactRuntime } from './runtime';\n\n// Re-export RuleType and utilities for compatibility\nexport { defaultSanitizer as sanitizer, defaultSlugify as slugify, RuleType };\n\nexport type MarkdownCompilerOptions = CompileOptions;\n\n/**\n * Compile markdown to Preact VNodes.\n * This is the primary export - use this for new code.\n */\nexport const compileMarkdown = (\n markdown: string = '',\n options: MarkdownCompilerOptions = {}\n) => compileWithOptions(markdown, preactRuntime, options);\n\n// Aliases for consistency with React adapter\nexport const compiler = compileMarkdown;\nexport const compile = compileMarkdown;\n"],"mappings":";;;;;;;;;;;AAsBA,MAAa,mBACX,WAAmB,IACnB,UAAmC,CAAC,MACjC,mBAAmB,UAAU,eAAe,OAAO;AAGxD,MAAa,WAAW;AACxB,MAAa,UAAU"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.mjs","names":[],"sources":["../../../src/markdown/runtime.ts"],"sourcesContent":["/**\n * Preact-specific MarkdownRuntime implementation.\n */\n\nimport type { HTMLTag, MarkdownRuntime } from '@intlayer/core/markdown';\nimport {\n type Component,\n cloneElement,\n createElement,\n Fragment,\n type VNode,\n} from 'preact';\n\n/**\n * Preact-specific runtime for the markdown processor.\n */\nexport const preactRuntime: MarkdownRuntime = {\n createElement: (\n type: string | Component,\n props: Record<string, any> | null,\n ...children: any[]\n ): any => createElement(type as any, props, ...children),\n\n cloneElement: (\n element: unknown,\n props: Record<string, any>,\n ...children: any[]\n ): any => cloneElement(element as VNode, props, ...children),\n\n Fragment,\n\n normalizeProps: (\n _tag: HTMLTag,\n props: Record<string, any>\n ): Record<string, any> => props,\n};\n\nexport default preactRuntime;\n"],"mappings":";;;;;;AAgBA,MAAa,gBAAiC;CAC5C,gBACE,MACA,OACA,GAAG,aACK,cAAc,MAAa,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"runtime.mjs","names":[],"sources":["../../../src/markdown/runtime.ts"],"sourcesContent":["/**\n * Preact-specific MarkdownRuntime implementation.\n */\n\nimport type { HTMLTag, MarkdownRuntime } from '@intlayer/core/markdown';\nimport {\n type Component,\n cloneElement,\n createElement,\n Fragment,\n type VNode,\n} from 'preact';\n\n/**\n * Preact-specific runtime for the markdown processor.\n */\nexport const preactRuntime: MarkdownRuntime = {\n createElement: (\n type: string | Component,\n props: Record<string, any> | null,\n ...children: any[]\n ): any => createElement(type as any, props, ...children),\n\n cloneElement: (\n element: unknown,\n props: Record<string, any>,\n ...children: any[]\n ): any => cloneElement(element as VNode, props, ...children),\n\n Fragment,\n\n normalizeProps: (\n _tag: HTMLTag,\n props: Record<string, any>\n ): Record<string, any> => props,\n};\n\nexport default preactRuntime;\n"],"mappings":";;;;;;AAgBA,MAAa,gBAAiC;CAC5C,gBACE,MACA,OACA,GAAG,aACK,cAAc,MAAa,OAAO,GAAG,QAAQ;CAEvD,eACE,SACA,OACA,GAAG,aACK,aAAa,SAAkB,OAAO,GAAG,QAAQ;CAE3D;CAEA,iBACE,MACA,UACwB;AAC5B"}
|
package/dist/esm/plugins.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useLoadDynamic } from "./client/useLoadDynamic.mjs";
|
|
1
2
|
import { ContentSelector } from "./editor/ContentSelector.mjs";
|
|
2
3
|
import { renderIntlayerNode } from "./IntlayerNode.mjs";
|
|
3
4
|
import { renderPreactElement } from "./preactElement/renderPreactElement.mjs";
|
|
@@ -6,13 +7,14 @@ import { conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderP
|
|
|
6
7
|
import { getMarkdownMetadata } from "@intlayer/core/markdown";
|
|
7
8
|
import * as NodeTypes from "@intlayer/types/nodeType";
|
|
8
9
|
import { Fragment, createElement, h } from "preact";
|
|
9
|
-
import { Suspense, lazy } from "preact/compat";
|
|
10
10
|
import { jsx } from "preact/jsx-runtime";
|
|
11
11
|
|
|
12
12
|
//#region src/plugins.tsx
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
const markdownRendererModulePromise = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] !== "false" ? import("./markdown/MarkdownRendererPlugin.mjs").then((m) => ({
|
|
14
|
+
MarkdownRendererPlugin: m.MarkdownRendererPlugin,
|
|
15
|
+
MarkdownMetadataRenderer: m.MarkdownMetadataRenderer
|
|
16
|
+
})) : null;
|
|
17
|
+
const htmlRendererModulePromise = process.env["INTLAYER_NODE_TYPE_HTML"] !== "false" ? import("./html/HTMLRenderer.mjs").then((m) => m.HTMLRenderer) : null;
|
|
16
18
|
/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */
|
|
17
19
|
const intlayerNodePlugins = {
|
|
18
20
|
id: "intlayer-node-plugin",
|
|
@@ -107,6 +109,20 @@ const insertionPlugin = process.env["INTLAYER_NODE_TYPE_INSERTION"] === "false"
|
|
|
107
109
|
return result;
|
|
108
110
|
}
|
|
109
111
|
};
|
|
112
|
+
const MarkdownSuspenseRenderer = ({ children, ...props }) => {
|
|
113
|
+
const { MarkdownRendererPlugin } = useLoadDynamic("preact-markdown-renderer", markdownRendererModulePromise);
|
|
114
|
+
return h(MarkdownRendererPlugin, {
|
|
115
|
+
...props,
|
|
116
|
+
children
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
const MarkdownMetadataSuspenseRenderer = ({ children, ...props }) => {
|
|
120
|
+
const { MarkdownMetadataRenderer } = useLoadDynamic("preact-markdown-renderer", markdownRendererModulePromise);
|
|
121
|
+
return h(MarkdownMetadataRenderer, {
|
|
122
|
+
...props,
|
|
123
|
+
children
|
|
124
|
+
});
|
|
125
|
+
};
|
|
110
126
|
/** Markdown string plugin. Replaces string node with a component that render the markdown. */
|
|
111
127
|
const markdownStringPlugin = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] === "false" ? fallbackPlugin : {
|
|
112
128
|
id: "markdown-string-plugin",
|
|
@@ -122,21 +138,15 @@ const markdownStringPlugin = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] === "fal
|
|
|
122
138
|
value: metadataNode,
|
|
123
139
|
children: process.env["INTLAYER_EDITOR_ENABLED"] !== "false" && editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
|
|
124
140
|
...rest,
|
|
125
|
-
children: /* @__PURE__ */ jsx(
|
|
126
|
-
fallback: node,
|
|
127
|
-
children: /* @__PURE__ */ jsx(LazyMarkdownMetadataRenderer, {
|
|
128
|
-
...rest,
|
|
129
|
-
metadataKeyPath: props.keyPath,
|
|
130
|
-
children: node
|
|
131
|
-
})
|
|
132
|
-
})
|
|
133
|
-
}) : /* @__PURE__ */ jsx(Suspense, {
|
|
134
|
-
fallback: node,
|
|
135
|
-
children: /* @__PURE__ */ jsx(LazyMarkdownMetadataRenderer, {
|
|
141
|
+
children: /* @__PURE__ */ jsx(MarkdownMetadataSuspenseRenderer, {
|
|
136
142
|
...rest,
|
|
137
143
|
metadataKeyPath: props.keyPath,
|
|
138
144
|
children: node
|
|
139
145
|
})
|
|
146
|
+
}) : /* @__PURE__ */ jsx(MarkdownMetadataSuspenseRenderer, {
|
|
147
|
+
...rest,
|
|
148
|
+
metadataKeyPath: props.keyPath,
|
|
149
|
+
children: node
|
|
140
150
|
})
|
|
141
151
|
})
|
|
142
152
|
}],
|
|
@@ -148,21 +158,15 @@ const markdownStringPlugin = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] === "fal
|
|
|
148
158
|
value: node,
|
|
149
159
|
children: process.env["INTLAYER_EDITOR_ENABLED"] !== "false" && editor.enabled ? /* @__PURE__ */ jsx(ContentSelector, {
|
|
150
160
|
...rest,
|
|
151
|
-
children: /* @__PURE__ */ jsx(
|
|
152
|
-
fallback: node,
|
|
153
|
-
children: /* @__PURE__ */ jsx(LazyMarkdownRendererPlugin, {
|
|
154
|
-
...rest,
|
|
155
|
-
components,
|
|
156
|
-
children: node
|
|
157
|
-
})
|
|
158
|
-
})
|
|
159
|
-
}) : /* @__PURE__ */ jsx(Suspense, {
|
|
160
|
-
fallback: node,
|
|
161
|
-
children: /* @__PURE__ */ jsx(LazyMarkdownRendererPlugin, {
|
|
161
|
+
children: /* @__PURE__ */ jsx(MarkdownSuspenseRenderer, {
|
|
162
162
|
...rest,
|
|
163
163
|
components,
|
|
164
164
|
children: node
|
|
165
165
|
})
|
|
166
|
+
}) : /* @__PURE__ */ jsx(MarkdownSuspenseRenderer, {
|
|
167
|
+
...rest,
|
|
168
|
+
components,
|
|
169
|
+
children: node
|
|
166
170
|
}),
|
|
167
171
|
additionalProps: { metadata: metadataNodes }
|
|
168
172
|
});
|
|
@@ -196,6 +200,9 @@ const markdownPlugin = process.env["INTLAYER_NODE_TYPE_MARKDOWN"] === "false" ?
|
|
|
196
200
|
});
|
|
197
201
|
}
|
|
198
202
|
};
|
|
203
|
+
const HTMLSuspenseRenderer = (props) => {
|
|
204
|
+
return h(useLoadDynamic("preact-html-renderer", htmlRendererModulePromise), props);
|
|
205
|
+
};
|
|
199
206
|
/** HTML plugin. Replaces node with a function that takes components => VNode. */
|
|
200
207
|
const htmlPlugin = process.env["INTLAYER_NODE_TYPE_HTML"] === "false" ? fallbackPlugin : {
|
|
201
208
|
id: "html-plugin",
|
|
@@ -207,15 +214,15 @@ const htmlPlugin = process.env["INTLAYER_NODE_TYPE_HTML"] === "false" ? fallback
|
|
|
207
214
|
const render = (userComponents) => renderIntlayerNode({
|
|
208
215
|
...rest,
|
|
209
216
|
value: html,
|
|
210
|
-
children: process.env["INTLAYER_EDITOR_ENABLED"] !== "false" && editor.enabled ? h(ContentSelector, { ...rest }, h(
|
|
217
|
+
children: process.env["INTLAYER_EDITOR_ENABLED"] !== "false" && editor.enabled ? h(ContentSelector, { ...rest }, h(HTMLSuspenseRenderer, {
|
|
211
218
|
...rest,
|
|
212
219
|
html,
|
|
213
220
|
userComponents
|
|
214
|
-
}))
|
|
221
|
+
})) : h(HTMLSuspenseRenderer, {
|
|
215
222
|
...rest,
|
|
216
223
|
html,
|
|
217
224
|
userComponents
|
|
218
|
-
})
|
|
225
|
+
})
|
|
219
226
|
});
|
|
220
227
|
const element = render();
|
|
221
228
|
return new Proxy(element, { get(target, prop) {
|
package/dist/esm/plugins.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.mjs","names":["func"],"sources":["../../src/plugins.tsx"],"sourcesContent":["import { editor, internationalization } from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n pluralPlugin,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { Fragment, h, type VNode } from 'preact';\nimport { lazy, Suspense } from 'preact/compat';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\nconst LazyMarkdownMetadataRenderer = (\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownMetadataRenderer,\n }))\n )\n)!;\n\nconst LazyMarkdownRendererPlugin = (\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\n ? null\n : lazy(() =>\n import('./markdown/MarkdownRendererPlugin').then((m) => ({\n default: m.MarkdownRendererPlugin,\n }))\n )\n)!;\n\nconst LazyHTMLRenderer = (\n process.env['INTLAYER_NODE_TYPE_HTML'] === 'false'\n ? null\n : lazy(() =>\n import('./html/HTMLRenderer').then((m) => ({ default: m.HTMLRenderer }))\n )\n)!;\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' && editor.enabled ? (\n <ContentSelector {...rest} key={rest.children}>\n {rest.children}\n </ContentSelector>\n ) : (\n rest.children\n ),\n }),\n};\n\n/** ---------------------------------------------\n * PREACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type PreactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? VNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const preactNodePlugins: Plugins =\n process.env['INTLAYER_NODE_TYPE_PREACT_NODE'] === 'false'\n ? fallbackPlugin\n : {\n id: 'preact-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[preact-element]]',\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n {renderPreactElement(node)}\n </ContentSelector>\n ) : (\n renderPreactElement(node)\n ),\n }),\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, _S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer I; // Accept strings OR nested nodes like enumerations\n fields: readonly (infer F)[]; // Infer the exact string literals in the array\n}\n ? <V extends { [K in Extract<F, string>]: string | number | VNode }>(\n values: V\n ) => I extends string\n ? V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<VNode>\n : DeepTransformContent<I, L> // Delegate nested nodes (like enumerations) back to the core\n : never;\n\n/**\n * Check if a value is a Preact VNode\n */\nconst isVNode = (value: any): value is VNode => {\n return (\n value !== null &&\n value !== undefined &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean'\n );\n};\n\n/**\n * Split insertion string and join with Preact VNodes\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | VNode>\n): VNode => {\n // Check if any value is a VNode\n const hasVNode = Object.values(values).some(isVNode);\n\n if (!hasVNode) {\n // Simple string replacement\n return template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (values[trimmedKey] ?? '').toString();\n }) as any;\n }\n\n // Split the template by placeholders while keeping the structure\n const parts: (string | VNode)[] = [];\n let lastIndex = 0;\n const regex = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n let match: RegExpExecArray | null = regex.exec(template);\n\n while (match !== null) {\n // Add text before the placeholder\n if (match.index > lastIndex) {\n parts.push(template.substring(lastIndex, match.index));\n }\n\n // Add the replaced value\n const key = match[1].trim();\n const value = values[key];\n if (value !== undefined && value !== null) {\n parts.push(typeof value === 'number' ? String(value) : value);\n }\n\n lastIndex = match.index + match[0].length;\n match = regex.exec(template);\n }\n\n // Add remaining text\n if (lastIndex < template.length) {\n parts.push(template.substring(lastIndex));\n }\n\n // Return as Fragment\n return h(\n Fragment,\n null,\n ...parts.map((part, index) => h(Fragment, { key: index }, part))\n );\n};\n\n/** Insertion plugin for Preact. Handles component/node insertion. */\nexport const insertionPlugin: Plugins =\n process.env['INTLAYER_NODE_TYPE_INSERTION'] === 'false'\n ? fallbackPlugin\n : {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.INSERTION,\n },\n ];\n\n const children = node[NodeTypes.INSERTION];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, subProps, deepTransformNode) => {\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n ],\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]:\n | string\n | number\n | VNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result as any,\n });\n };\n },\n };\n\n const result = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n if (\n typeof children === 'object' &&\n children !== null &&\n 'nodeType' in children &&\n [NodeTypes.ENUMERATION, NodeTypes.CONDITION].includes(\n children.nodeType as\n | typeof NodeTypes.ENUMERATION\n | typeof NodeTypes.CONDITION\n )\n ) {\n return (values: any) => (arg: any) => {\n const func = result as Function;\n const inner = func(arg);\n\n if (typeof inner === 'function') {\n return inner(values);\n }\n return inner;\n };\n }\n\n return result;\n },\n };\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<\n string,\n {\n metadata: DeepTransformContent<string>;\n use: (components?: HTMLComponents<'permissive', {}>) => VNode;\n }\n >\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins =\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\n ? fallbackPlugin\n : {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node) ?? {};\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownMetadataRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </LazyMarkdownMetadataRenderer>\n </Suspense>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin\n {...rest}\n components={components}\n >\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n </ContentSelector>\n ) : (\n <Suspense fallback={node}>\n <LazyMarkdownRendererPlugin\n {...rest}\n components={components}\n >\n {node}\n </LazyMarkdownRendererPlugin>\n </Suspense>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') return node;\n if (prop === Symbol.toPrimitive) return () => node;\n if (prop === 'toString') return () => node;\n if (prop === 'valueOf') return () => node;\n if (typeof prop === 'string' && prop !== 'constructor') {\n const method = (String.prototype as any)[prop];\n if (typeof method === 'function') return method.bind(node);\n }\n if (prop === 'metadata') return metadataNodes;\n if (prop === 'use')\n return (components?: any) => render(components);\n return Reflect.get(target, prop);\n },\n }) as any;\n },\n };\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer _M;\n metadata?: infer U;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => VNode;\n metadata: DeepTransformContent<U>;\n }\n : never;\n\nexport const markdownPlugin: Plugins =\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\n ? fallbackPlugin\n : {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.MARKDOWN,\n },\n ];\n\n const children = node[NodeTypes.MARKDOWN];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n };\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => IntlayerNode<I>;\n }\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => VNode. */\nexport const htmlPlugin: Plugins =\n process.env['INTLAYER_NODE_TYPE_HTML'] === 'false'\n ? fallbackPlugin\n : {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const _tags = node.tags ?? [];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): VNode =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n editor.enabled\n ? h(\n ContentSelector,\n { ...rest },\n h(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n )\n )\n : h(\n Suspense as any,\n { fallback: html },\n h(LazyHTMLRenderer as any, {\n ...rest,\n html,\n userComponents,\n })\n ),\n }) as any;\n\n const element = render() as any;\n\n const proxy = new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') return html;\n if (prop === Symbol.toPrimitive) return () => html;\n if (prop === 'toString') return () => html;\n if (prop === 'valueOf') return () => html;\n if (typeof prop === 'string' && prop !== 'constructor') {\n const method = (String.prototype as any)[prop];\n if (typeof method === 'function') return method.bind(html);\n }\n if (prop === 'use')\n return (userComponents?: HTMLComponents) =>\n render(userComponents);\n return Reflect.get(target, prop);\n },\n });\n\n return proxy;\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginPreact<T, S, L extends LocalesValues> {\n preactNode: PreactNodeCond<T>;\n preactIntlayerNode: IntlayerNodeCond<T>;\n preactInsertion: InsertionCond<T, S, L>;\n preactMarkdown: MarkdownCond<T>;\n preactHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `preact-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n preactNode: true;\n preactIntlayerNode: true;\n preactInsertion: true;\n preactMarkdown: true;\n preactHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Get the plugins array for Preact content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => {\n const currentLocale = locale ?? internationalization.defaultLocale;\n const cacheKey = `${currentLocale}_${fallback}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n translationPlugin(\n locale ?? internationalization.defaultLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n pluralPlugin(locale ?? internationalization.defaultLocale),\n conditionPlugin,\n nestedPlugin(locale ?? internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n // Always include: handle plain strings/numbers and React elements\n intlayerNodePlugins,\n preactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ] as Plugins[];\n\n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S,EAC5B,OAAO,aAAa,IAAI,SAAS;CAGnC,MAAM,UAAU;EACd,kBACE,UAAU,qBAAqB,eAC/B,WAAW,qBAAqB,gBAAgB,OACjD;EACD;EACA,aAAa,UAAU,qBAAqB,cAAc;EAC1D;EACA,aAAa,UAAU,qBAAqB,cAAc;EAC1D;EACA;EAEA;EACA;EACA;EACA;EACA;EACD;CAED,aAAa,IAAI,UAAU,QAAQ;CAEnC,OAAO"}
|
|
1
|
+
{"version":3,"file":"plugins.mjs","names":["func"],"sources":["../../src/plugins.tsx"],"sourcesContent":["import { editor, internationalization } from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n fallbackPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n pluralPlugin,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type {\n HTMLContent,\n InsertionContent,\n MarkdownContent,\n} from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport type { NodeType } from '@intlayer/types/nodeType';\nimport * as NodeTypes from '@intlayer/types/nodeType';\nimport { Fragment, type FunctionComponent, h, type VNode } from 'preact';\nimport { useLoadDynamic } from './client/useLoadDynamic';\nimport { ContentSelector } from './editor/ContentSelector';\nimport type { HTMLComponents } from './html/types';\nimport { type IntlayerNode, renderIntlayerNode } from './IntlayerNode';\nimport { renderPreactElement } from './preactElement/renderPreactElement';\n\nconst markdownRendererModulePromise =\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] !== 'false'\n ? import('./markdown/MarkdownRendererPlugin').then((m) => ({\n MarkdownRendererPlugin: m.MarkdownRendererPlugin,\n MarkdownMetadataRenderer: m.MarkdownMetadataRenderer,\n }))\n : null;\n\nconst htmlRendererModulePromise =\n process.env['INTLAYER_NODE_TYPE_HTML'] !== 'false'\n ? import('./html/HTMLRenderer').then((m) => m.HTMLRenderer)\n : null;\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (\n _node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: rest.children,\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' && editor.enabled ? (\n <ContentSelector {...rest} key={rest.children}>\n {rest.children}\n </ContentSelector>\n ) : (\n rest.children\n ),\n }),\n};\n\n/** ---------------------------------------------\n * PREACT NODE PLUGIN\n * --------------------------------------------- */\n\nexport type PreactNodeCond<T> = T extends {\n props: any;\n key: any;\n}\n ? VNode\n : never;\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const preactNodePlugins: Plugins =\n process.env['INTLAYER_NODE_TYPE_PREACT_NODE'] === 'false'\n ? fallbackPlugin\n : {\n id: 'preact-node-plugin',\n canHandle: (node) =>\n typeof node === 'object' &&\n typeof node.props !== 'undefined' &&\n typeof node.key !== 'undefined',\n\n transform: (\n node,\n {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n }\n ) =>\n renderIntlayerNode({\n ...rest,\n value: '[[preact-element]]',\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n {renderPreactElement(node)}\n </ContentSelector>\n ) : (\n renderPreactElement(node)\n ),\n }),\n };\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\nexport type InsertionCond<T, _S, L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.INSERTION]: infer I; // Accept strings OR nested nodes like enumerations\n fields: readonly (infer F)[]; // Infer the exact string literals in the array\n}\n ? <V extends { [K in Extract<F, string>]: string | number | VNode }>(\n values: V\n ) => I extends string\n ? V[keyof V] extends string | number\n ? IntlayerNode<string>\n : IntlayerNode<VNode>\n : DeepTransformContent<I, L> // Delegate nested nodes (like enumerations) back to the core\n : never;\n\n/**\n * Check if a value is a Preact VNode\n */\nconst isVNode = (value: any): value is VNode => {\n return (\n value !== null &&\n value !== undefined &&\n typeof value !== 'string' &&\n typeof value !== 'number' &&\n typeof value !== 'boolean'\n );\n};\n\n/**\n * Split insertion string and join with Preact VNodes\n */\nconst splitAndJoinInsertion = (\n template: string,\n values: Record<string, string | number | VNode>\n): VNode => {\n // Check if any value is a VNode\n const hasVNode = Object.values(values).some(isVNode);\n\n if (!hasVNode) {\n // Simple string replacement\n return template.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_, key) => {\n const trimmedKey = key.trim();\n return (values[trimmedKey] ?? '').toString();\n }) as any;\n }\n\n // Split the template by placeholders while keeping the structure\n const parts: (string | VNode)[] = [];\n let lastIndex = 0;\n const regex = /\\{\\{\\s*(.*?)\\s*\\}\\}/g;\n let match: RegExpExecArray | null = regex.exec(template);\n\n while (match !== null) {\n // Add text before the placeholder\n if (match.index > lastIndex) {\n parts.push(template.substring(lastIndex, match.index));\n }\n\n // Add the replaced value\n const key = match[1].trim();\n const value = values[key];\n if (value !== undefined && value !== null) {\n parts.push(typeof value === 'number' ? String(value) : value);\n }\n\n lastIndex = match.index + match[0].length;\n match = regex.exec(template);\n }\n\n // Add remaining text\n if (lastIndex < template.length) {\n parts.push(template.substring(lastIndex));\n }\n\n // Return as Fragment\n return h(\n Fragment,\n null,\n ...parts.map((part, index) => h(Fragment, { key: index }, part))\n );\n};\n\n/** Insertion plugin for Preact. Handles component/node insertion. */\nexport const insertionPlugin: Plugins =\n process.env['INTLAYER_NODE_TYPE_INSERTION'] === 'false'\n ? fallbackPlugin\n : {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.INSERTION,\n transform: (node: InsertionContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.INSERTION,\n },\n ];\n\n const children = node[NodeTypes.INSERTION];\n\n /** Insertion string plugin. Replaces string node with a component that render the insertion. */\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, subProps, deepTransformNode) => {\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: [\n ...(props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n ],\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]:\n | string\n | number\n | VNode;\n }\n ) => {\n const result = splitAndJoinInsertion(transformedResult, values);\n\n return deepTransformNode(result, {\n ...subProps,\n plugins: props.plugins,\n children: result as any,\n });\n };\n },\n };\n\n const result = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n if (\n typeof children === 'object' &&\n children !== null &&\n 'nodeType' in children &&\n [NodeTypes.ENUMERATION, NodeTypes.CONDITION].includes(\n children.nodeType as\n | typeof NodeTypes.ENUMERATION\n | typeof NodeTypes.CONDITION\n )\n ) {\n return (values: any) => (arg: any) => {\n const func = result as Function;\n const inner = func(arg);\n\n if (typeof inner === 'function') {\n return inner(values);\n }\n return inner;\n };\n }\n\n return result;\n },\n };\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<\n string,\n {\n metadata: DeepTransformContent<string>;\n use: (components?: HTMLComponents<'permissive', {}>) => VNode;\n }\n >\n : never;\n\nconst MarkdownSuspenseRenderer: FunctionComponent<Record<string, any>> = ({\n children,\n ...props\n}) => {\n const { MarkdownRendererPlugin } = useLoadDynamic(\n 'preact-markdown-renderer',\n markdownRendererModulePromise!\n );\n return h(MarkdownRendererPlugin as any, { ...props, children });\n};\n\nconst MarkdownMetadataSuspenseRenderer: FunctionComponent<\n Record<string, any>\n> = ({ children, ...props }) => {\n const { MarkdownMetadataRenderer } = useLoadDynamic(\n 'preact-markdown-renderer',\n markdownRendererModulePromise!\n );\n return h(MarkdownMetadataRenderer as any, { ...props, children });\n};\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins =\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\n ? fallbackPlugin\n : {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node) ?? {};\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n <MarkdownMetadataSuspenseRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataSuspenseRenderer>\n </ContentSelector>\n ) : (\n <MarkdownMetadataSuspenseRenderer\n {...rest}\n metadataKeyPath={props.keyPath}\n >\n {node}\n </MarkdownMetadataSuspenseRenderer>\n ),\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...props,\n value: node,\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n editor.enabled ? (\n <ContentSelector {...rest}>\n <MarkdownSuspenseRenderer {...rest} components={components}>\n {node}\n </MarkdownSuspenseRenderer>\n </ContentSelector>\n ) : (\n <MarkdownSuspenseRenderer {...rest} components={components}>\n {node}\n </MarkdownSuspenseRenderer>\n ),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const element = render() as any;\n\n return new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') return node;\n if (prop === Symbol.toPrimitive) return () => node;\n if (prop === 'toString') return () => node;\n if (prop === 'valueOf') return () => node;\n if (typeof prop === 'string' && prop !== 'constructor') {\n const method = (String.prototype as any)[prop];\n if (typeof method === 'function') return method.bind(node);\n }\n if (prop === 'metadata') return metadataNodes;\n if (prop === 'use')\n return (components?: any) => render(components);\n return Reflect.get(target, prop);\n },\n }) as any;\n },\n };\n\nexport type MarkdownCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.MARKDOWN]: infer _M;\n metadata?: infer U;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => VNode;\n metadata: DeepTransformContent<U>;\n }\n : never;\n\nexport const markdownPlugin: Plugins =\n process.env['INTLAYER_NODE_TYPE_MARKDOWN'] === 'false'\n ? fallbackPlugin\n : {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.MARKDOWN,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeTypes.MARKDOWN,\n },\n ];\n\n const children = node[NodeTypes.MARKDOWN];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n };\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\nexport type HTMLPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeTypes.HTML]: infer I;\n tags?: infer U;\n}\n ? {\n use: (components?: HTMLComponents<'permissive', U>) => IntlayerNode<I>;\n }\n : never;\n\nconst HTMLSuspenseRenderer: FunctionComponent<Record<string, any>> = (\n props\n) => {\n const HTMLRenderer = useLoadDynamic(\n 'preact-html-renderer',\n htmlRendererModulePromise!\n );\n return h(HTMLRenderer as any, props);\n};\n\n/** HTML plugin. Replaces node with a function that takes components => VNode. */\nexport const htmlPlugin: Plugins =\n process.env['INTLAYER_NODE_TYPE_HTML'] === 'false'\n ? fallbackPlugin\n : {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeTypes.HTML,\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeTypes.HTML];\n const _tags = node.tags ?? [];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: HTMLComponents): VNode =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children:\n process.env['INTLAYER_EDITOR_ENABLED'] !== 'false' &&\n editor.enabled\n ? h(\n ContentSelector,\n { ...rest },\n h(HTMLSuspenseRenderer, { ...rest, html, userComponents })\n )\n : h(HTMLSuspenseRenderer, { ...rest, html, userComponents }),\n }) as any;\n\n const element = render() as any;\n\n const proxy = new Proxy(element, {\n get(target, prop) {\n if (prop === 'value') return html;\n if (prop === Symbol.toPrimitive) return () => html;\n if (prop === 'toString') return () => html;\n if (prop === 'valueOf') return () => html;\n if (typeof prop === 'string' && prop !== 'constructor') {\n const method = (String.prototype as any)[prop];\n if (typeof method === 'function') return method.bind(html);\n }\n if (prop === 'use')\n return (userComponents?: HTMLComponents) =>\n render(userComponents);\n return Reflect.get(target, prop);\n },\n });\n\n return proxy;\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginPreact<T, S, L extends LocalesValues> {\n preactNode: PreactNodeCond<T>;\n preactIntlayerNode: IntlayerNodeCond<T>;\n preactInsertion: InsertionCond<T, S, L>;\n preactMarkdown: MarkdownCond<T>;\n preactHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `preact-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n preactNode: true;\n preactIntlayerNode: true;\n preactInsertion: true;\n preactMarkdown: true;\n preactHtml: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\nconst pluginsCache = new Map<string, Plugins[]>();\n\n/**\n * Get the plugins array for Preact content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => {\n const currentLocale = locale ?? internationalization.defaultLocale;\n const cacheKey = `${currentLocale}_${fallback}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n translationPlugin(\n locale ?? internationalization.defaultLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n pluralPlugin(locale ?? internationalization.defaultLocale),\n conditionPlugin,\n nestedPlugin(locale ?? internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n // Always include: handle plain strings/numbers and React elements\n intlayerNodePlugins,\n preactNodePlugins,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ] as Plugins[];\n\n pluginsCache.set(cacheKey, plugins);\n\n return plugins;\n};\n"],"mappings":";;;;;;;;;;;;AAkCA,MAAM,gCACJ,QAAQ,IAAI,mCAAmC,UAC3C,OAAO,yCAAqC,MAAM,OAAO;CACvD,wBAAwB,EAAE;CAC1B,0BAA0B,EAAE;AAC9B,EAAE,IACF;AAEN,MAAM,4BACJ,QAAQ,IAAI,+BAA+B,UACvC,OAAO,2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a,UAAU,qBAAqB,aAAa;EACzD;EACA;EAEA;EACA;EACA;EACA;EACA;CACF;CAEA,aAAa,IAAI,UAAU,OAAO;CAElC,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"renderPreactElement.mjs","names":[],"sources":["../../../src/preactElement/renderPreactElement.ts"],"sourcesContent":["import { type ComponentChild, createElement, type VNode } from 'preact';\n\n// This function recursively creates Preact elements from a given JSON-like structure\nexport const renderPreactElement = (element: VNode<any>): any => {\n if (element === null || typeof element !== 'object') {\n return element;\n }\n\n const convertChildrenAsArray = (\n element: VNode<{ children?: ComponentChild | ComponentChild[] }>\n ): VNode<{ children?: ComponentChild | ComponentChild[] }> => {\n const children = element.props?.children;\n\n if (Array.isArray(children)) {\n const childrenResult: ComponentChild[] = children.map((child) =>\n renderPreactElement(child as VNode<any>)\n );\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n } else if (typeof children !== 'undefined' && children !== null) {\n const renderedChild = renderPreactElement(children as VNode<any>);\n return {\n ...element,\n props: { ...element.props, children: [renderedChild] },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: [] },\n };\n };\n\n const fixedElement = convertChildrenAsArray(\n element as VNode<{ children?: ComponentChild | ComponentChild[] }>\n );\n\n const { type, props } = fixedElement;\n\n // Create and return the Preact element\n return createElement(\n (type as any) ?? 'span',\n props as any,\n ...(props.children as ComponentChild[])\n );\n};\n"],"mappings":";;;AAGA,MAAa,uBAAuB,YAA6B;CAC/D,IAAI,YAAY,QAAQ,OAAO,YAAY,UACzC,OAAO;CAGT,MAAM,0BACJ,YAC4D;EAC5D,MAAM,WAAW,QAAQ,OAAO;EAEhC,IAAI,MAAM,QAAQ,
|
|
1
|
+
{"version":3,"file":"renderPreactElement.mjs","names":[],"sources":["../../../src/preactElement/renderPreactElement.ts"],"sourcesContent":["import { type ComponentChild, createElement, type VNode } from 'preact';\n\n// This function recursively creates Preact elements from a given JSON-like structure\nexport const renderPreactElement = (element: VNode<any>): any => {\n if (element === null || typeof element !== 'object') {\n return element;\n }\n\n const convertChildrenAsArray = (\n element: VNode<{ children?: ComponentChild | ComponentChild[] }>\n ): VNode<{ children?: ComponentChild | ComponentChild[] }> => {\n const children = element.props?.children;\n\n if (Array.isArray(children)) {\n const childrenResult: ComponentChild[] = children.map((child) =>\n renderPreactElement(child as VNode<any>)\n );\n\n return {\n ...element,\n props: { ...element.props, children: childrenResult },\n };\n } else if (typeof children !== 'undefined' && children !== null) {\n const renderedChild = renderPreactElement(children as VNode<any>);\n return {\n ...element,\n props: { ...element.props, children: [renderedChild] },\n };\n }\n\n return {\n ...element,\n props: { ...element.props, children: [] },\n };\n };\n\n const fixedElement = convertChildrenAsArray(\n element as VNode<{ children?: ComponentChild | ComponentChild[] }>\n );\n\n const { type, props } = fixedElement;\n\n // Create and return the Preact element\n return createElement(\n (type as any) ?? 'span',\n props as any,\n ...(props.children as ComponentChild[])\n );\n};\n"],"mappings":";;;AAGA,MAAa,uBAAuB,YAA6B;CAC/D,IAAI,YAAY,QAAQ,OAAO,YAAY,UACzC,OAAO;CAGT,MAAM,0BACJ,YAC4D;EAC5D,MAAM,WAAW,QAAQ,OAAO;EAEhC,IAAI,MAAM,QAAQ,QAAQ,GAAG;GAC3B,MAAM,iBAAmC,SAAS,KAAK,UACrD,oBAAoB,KAAmB,CACzC;GAEA,OAAO;IACL,GAAG;IACH,OAAO;KAAE,GAAG,QAAQ;KAAO,UAAU;IAAe;GACtD;EACF,OAAO,IAAI,OAAO,aAAa,eAAe,aAAa,MAAM;GAC/D,MAAM,gBAAgB,oBAAoB,QAAsB;GAChE,OAAO;IACL,GAAG;IACH,OAAO;KAAE,GAAG,QAAQ;KAAO,UAAU,CAAC,aAAa;IAAE;GACvD;EACF;EAEA,OAAO;GACL,GAAG;GACH,OAAO;IAAE,GAAG,QAAQ;IAAO,UAAU,CAAC;GAAE;EAC1C;CACF;CAMA,MAAM,EAAE,MAAM,UAJO,uBACnB,OAGiC;CAGnC,OAAO,cACJ,QAAgB,QACjB,OACA,GAAI,MAAM,QACZ;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerNode.d.ts","names":[],"sources":["../../src/IntlayerNode.tsx"],"mappings":";;;;;KAUY,YAAA,KACN,SAAA,sCAEF,cAAA,CAAe,CAAA,EAAG,KAAA;EACpB,KAAA,EAAO,CAAA;AAAA,IACL,eAAA,GACF,CAAA;AAAA,KAEG,uBAAA;EACH,KAAA,EAAO,CAAA;EACP,QAAA,EAAU,
|
|
1
|
+
{"version":3,"file":"IntlayerNode.d.ts","names":[],"sources":["../../src/IntlayerNode.tsx"],"mappings":";;;;;KAUY,YAAA,KACN,SAAA,sCAEF,cAAA,CAAe,CAAA,EAAG,KAAA;EACpB,KAAA,EAAO,CAAA;AAAA,IACL,eAAA,GACF,CAAA;AAAA,KAEG,uBAAA;EACH,KAAA,EAAO,CAAA;EACP,QAAA,EAAU,iBAAiB;EAC3B,eAAA;IAAA,CAAqB,GAAA;EAAA;AAAA;AAAA,cAGV,kBAAA;EAEX,QAAA;EAAA,KAAA;EAAA;AAAA,GAIC,uBAAA,CAAwB,CAAA,MAAK,YAAA,CAAa,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContentSelector.d.ts","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"mappings":";;;KAKK,oBAAA;EACH,OAAA;EACA,OAAA;EACA,SAAA;EACA,cAAA;EACA,aAAA;EACA,WAAA;AAAA,IACE,IAAA,CAAK,GAAA,CAAI,cAAA,CAAe,cAAA;AAAA,cAEf,eAAA,EAAiB,
|
|
1
|
+
{"version":3,"file":"ContentSelector.d.ts","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"mappings":";;;KAKK,oBAAA;EACH,OAAA;EACA,OAAA;EACA,SAAA;EACA,cAAA;EACA,aAAA;EACA,WAAA;AAAA,IACE,IAAA,CAAK,GAAA,CAAI,cAAA,CAAe,cAAA;AAAA,cAEf,eAAA,EAAiB,mBAAmB,CAAC,oBAAA"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { LocalesValues } from "@intlayer/types/module_augmentation";
|
|
2
|
-
import * as _$preact from "preact";
|
|
3
2
|
import { ComponentChild, FunctionComponent } from "preact";
|
|
4
3
|
|
|
5
4
|
//#region src/client/IntlayerProvider.d.ts
|
|
@@ -11,7 +10,7 @@ type IntlayerValue = {
|
|
|
11
10
|
/**
|
|
12
11
|
* Context that store the current locale on the client side
|
|
13
12
|
*/
|
|
14
|
-
declare const IntlayerClientContext:
|
|
13
|
+
declare const IntlayerClientContext: import("preact").Context<IntlayerValue>;
|
|
15
14
|
/**
|
|
16
15
|
* Hook that provides the current locale
|
|
17
16
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IntlayerProvider.d.ts","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"IntlayerProvider.d.ts","names":[],"sources":["../../../src/client/IntlayerProvider.tsx"],"mappings":";;;;KAaK,aAAA;EACH,MAAA,EAAQ,aAAA;EACR,SAAA,GAAY,SAAA,EAAW,aAAa;EACpC,eAAA;AAAA;;;;cAMW,qBAAA,mBAAqB,OAAA,CAAA,aAAA;;;;cAQrB,kBAAA;AAAA,KAED,qBAAA;EACV,QAAA,GAAW,cAAA;EACX,MAAA,GAAS,aAAA;EACT,aAAA,GAAgB,aAAA;EAChB,SAAA,IAAa,MAAA,EAAQ,aAAA;EACrB,eAAA;AAAA;;;;cAMW,uBAAA,EAAyB,iBAAiB,CACrD,qBAAA;AAZF;;;;;;;;;;;;;;;;;;;;AAAA,cAyFa,gBAAA,EAAkB,iBAAiB,CAAC,qBAAA"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { StrictModeLocaleMap } from "@intlayer/types/module_augmentation";
|
|
2
|
-
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
3
2
|
|
|
4
3
|
//#region src/client/useContent.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* On the client side, hook to get the translation content based on the locale
|
|
7
6
|
*/
|
|
8
7
|
declare const useContent: <Content>(languageContent: StrictModeLocaleMap<Content>) => {
|
|
9
|
-
locale:
|
|
8
|
+
locale: import("@intlayer/types").LocalesValues;
|
|
10
9
|
content: Content;
|
|
11
10
|
t: <Content_1 = string>(languageContent: StrictModeLocaleMap<Content_1>) => Content_1;
|
|
12
11
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContent.d.ts","names":[],"sources":["../../../src/client/useContent.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useContent.d.ts","names":[],"sources":["../../../src/client/useContent.ts"],"mappings":";;;;;AAOA;cAAa,UAAA,YACX,eAAA,EAAiB,mBAAA,CAAoB,OAAA"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { IInterpreterPluginState
|
|
2
|
-
import * as _$_intlayer_core_interpreter0 from "@intlayer/core/interpreter";
|
|
1
|
+
import { IInterpreterPluginState } from "../plugins.js";
|
|
3
2
|
import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
4
|
-
import * as _$_intlayer_types0 from "@intlayer/types";
|
|
5
3
|
import { Dictionary } from "@intlayer/types/dictionary";
|
|
6
4
|
|
|
7
5
|
//#region src/client/useDictionary.d.ts
|
|
@@ -10,7 +8,7 @@ import { Dictionary } from "@intlayer/types/dictionary";
|
|
|
10
8
|
*
|
|
11
9
|
* If the locale is not provided, it will use the locale from the client context
|
|
12
10
|
*/
|
|
13
|
-
declare const useDictionary: <T extends Dictionary, L extends LocalesValues = DeclaredLocales>(dictionary: T, locale?: L) =>
|
|
11
|
+
declare const useDictionary: <T extends Dictionary, L extends LocalesValues = DeclaredLocales>(dictionary: T, locale?: L) => import("@intlayer/core/interpreter").DeepTransformContent<T["content"], IInterpreterPluginState, import("@intlayer/types").Locale>;
|
|
14
12
|
//#endregion
|
|
15
13
|
export { useDictionary };
|
|
16
14
|
//# sourceMappingURL=useDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/client/useDictionary.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/client/useDictionary.ts"],"mappings":";;;;;;;;AAcA;;cAAa,aAAA,aACD,UAAA,YACA,aAAA,GAAgB,eAAA,EAE1B,UAAA,EAAY,CAAA,EACZ,MAAA,GAAS,CAAA,0CAAC,oBAAA,CAAA,CAAA,aAAA,uBAAA,4BAAA,MAAA"}
|