vanilla-intlayer 9.5.10 → 9.5.12

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.
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_getDictionary = require('../getDictionary.cjs');
3
3
  const require_client_installIntlayer = require('./installIntlayer.cjs');
4
- let _intlayer_config_built = require("@intlayer/config/built");
4
+ let _intlayer_core_interpreter = require("@intlayer/core/interpreter");
5
5
  let _intlayer_core_dictionaryManipulator = require("@intlayer/core/dictionaryManipulator");
6
6
 
7
7
  //#region src/client/useDictionaryDynamic.ts
@@ -49,7 +49,6 @@ const recursiveProxy = new Proxy(() => {}, {
49
49
  */
50
50
  const useDictionaryDynamic = (dictionaryLoaders, key, localeOrSelector) => {
51
51
  const client = require_client_installIntlayer.getIntlayerClient();
52
- const defaultLocale = _intlayer_config_built.internationalization.defaultLocale;
53
52
  if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && (0, _intlayer_core_dictionaryManipulator.isQualifiedDynamicLoaderMap)(dictionaryLoaders)) {
54
53
  const loaderMap = dictionaryLoaders;
55
54
  const { locale: selectorLocale, selector } = (0, _intlayer_core_dictionaryManipulator.parseDictionarySelector)((0, _intlayer_core_dictionaryManipulator.resolveDictionaryArgument)({
@@ -67,7 +66,7 @@ const useDictionaryDynamic = (dictionaryLoaders, key, localeOrSelector) => {
67
66
  selector,
68
67
  transform: (dictionary) => require_getDictionary.getDictionary(dictionary, locale)
69
68
  });
70
- const currentLocale = selectorLocale ?? client.locale ?? defaultLocale;
69
+ const currentLocale = selectorLocale ?? client.locale ?? (0, _intlayer_core_interpreter.resolveInterpreterLocale)();
71
70
  const cacheKey = buildKey(currentLocale);
72
71
  const attachOnChange = (content) => {
73
72
  if (content != null && typeof content === "object") content.onChange = (callback) => {
@@ -98,7 +97,7 @@ const useDictionaryDynamic = (dictionaryLoaders, key, localeOrSelector) => {
98
97
  }
99
98
  return recursiveProxy;
100
99
  }
101
- const currentLocale = (typeof localeOrSelector === "string" ? localeOrSelector : void 0) ?? client.locale ?? defaultLocale;
100
+ const currentLocale = (typeof localeOrSelector === "string" ? localeOrSelector : void 0) ?? client.locale ?? (0, _intlayer_core_interpreter.resolveInterpreterLocale)();
102
101
  const cacheKey = `${String(key)}.${currentLocale}`;
103
102
  const loader = dictionaryLoaders[currentLocale];
104
103
  if (!cache.has(cacheKey)) {
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.cjs","names":["getIntlayerClient","internationalization","isQualifiedDynamicLoaderMap","parseDictionarySelector","resolveDictionaryArgument","getDictionarySelectorCacheKey","resolveQualifiedDynamicContentAsync","getDictionary","getPreloadedDictionary"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport {\n getDictionarySelectorCacheKey,\n getPreloadedDictionary,\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveDictionaryArgument,\n resolveQualifiedDynamicContentAsync,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport type { DeepTransformContent } from '../plugins';\nimport { getIntlayerClient } from './installIntlayer';\nimport type { WithOnChange } from './useDictionary';\n\n/** Simple in-memory cache shared across all calls in the same page. */\nconst cache = new Map<string, Dictionary>();\n\n/** Tracks in-flight loads to avoid duplicate fetches. */\nconst inflight = new Map<string, Promise<void>>();\n\n/** Resolved-content cache for qualified (collection/variant/meta) keys. */\nconst qualifiedCache = new Map<string, unknown>();\nconst qualifiedInflight = new Map<string, Promise<void>>();\n\nconst loadDictionary = <T extends Dictionary>(\n cacheKey: string,\n loader: () => Promise<T>\n): Promise<void> => {\n if (cache.has(cacheKey)) return Promise.resolve();\n if (inflight.has(cacheKey)) return inflight.get(cacheKey)!;\n\n const promise = loader().then((dictionary) => {\n cache.set(cacheKey, dictionary);\n inflight.delete(cacheKey);\n });\n\n inflight.set(cacheKey, promise);\n return promise;\n};\n\n/** Placeholder proxy — safe for any property access while loading. */\nconst recursiveProxy: any = new Proxy(() => {}, {\n get: (_t, prop) => {\n if (prop === Symbol.toPrimitive) return () => '';\n if (prop === 'toString') return () => '';\n if (prop === 'valueOf') return () => '';\n if (prop === 'then') return undefined; // not a Promise\n if (prop === 'onChange') return (_cb: any) => recursiveProxy;\n return recursiveProxy;\n },\n apply: () => recursiveProxy,\n});\n\n/**\n * Dynamically load and transform a dictionary (plain or qualified).\n *\n * For a qualified loader map (collection / variant, possibly\n * combined), only the chunk(s) the selector targets are loaded. For a plain\n * loader map, the locale chunk is loaded. The first call returns a placeholder\n * and triggers a background load; the client then notifies subscribers so the\n * render runs again with real content.\n *\n * @param dictionaryLoaders - Locale-keyed loader map, or a qualified loader map.\n * @param key - Dictionary key (used for cache namespacing).\n * @param localeOrSelector - Optional locale or selector.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const K extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelectorForKey<K> = DeclaredLocales,\n>(\n dictionaryLoaders:\n | StrictModeLocaleMap<() => Promise<T>>\n | QualifiedDynamicLoaderMap,\n key: K,\n localeOrSelector?: A\n): WithOnChange<DeepTransformContent<T['content']>> => {\n const client = getIntlayerClient();\n const defaultLocale = internationalization.defaultLocale;\n\n // --- Qualified loader map (collection / variant) ---\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n isQualifiedDynamicLoaderMap(dictionaryLoaders)\n ) {\n const loaderMap = dictionaryLoaders;\n // Layers the client's ambient variant under the call-site argument before\n // the chunk walk, so only the targeted chunk is loaded.\n const { locale: selectorLocale, selector } =\n parseDictionarySelector<LocalesValues>(\n resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: client.locale,\n contextVariant: client.variant,\n dictionaryKey: String(key),\n })\n );\n const selectorId = getDictionarySelectorCacheKey(selector);\n\n const buildKey = (locale: string) =>\n `${String(key)}.${locale}.${selectorId}`;\n const resolveContent = (locale: LocalesValues) =>\n resolveQualifiedDynamicContentAsync({\n loaderMap,\n key: String(key),\n locale,\n selector,\n transform: (dictionary) =>\n getDictionary(dictionary, locale as DeclaredLocales),\n });\n\n const currentLocale = (selectorLocale ??\n client.locale ??\n defaultLocale) as LocalesValues;\n const cacheKey = buildKey(currentLocale);\n\n const attachOnChange = (content: any) => {\n if (content != null && typeof content === 'object') {\n content.onChange = (callback: (c: any) => void) => {\n client.subscribe((newLocale) => {\n const locale = (selectorLocale ?? newLocale) as LocalesValues;\n const newKey = buildKey(locale);\n\n if (qualifiedCache.has(newKey)) {\n callback(qualifiedCache.get(newKey));\n return;\n }\n\n resolveContent(locale).then((resolved) => {\n qualifiedCache.set(newKey, resolved);\n callback(resolved);\n });\n });\n return content;\n };\n }\n return content;\n };\n\n if (qualifiedCache.has(cacheKey)) {\n return attachOnChange(qualifiedCache.get(cacheKey)) as any;\n }\n\n if (!qualifiedInflight.has(cacheKey)) {\n const promise = resolveContent(currentLocale).then((resolved) => {\n qualifiedCache.set(cacheKey, resolved);\n qualifiedInflight.delete(cacheKey);\n client.notify();\n });\n qualifiedInflight.set(cacheKey, promise);\n }\n\n return recursiveProxy;\n }\n\n // --- Plain locale-keyed loader map ---\n const locale =\n typeof localeOrSelector === 'string'\n ? (localeOrSelector as LocalesValues)\n : undefined;\n const currentLocale = (locale ?? client.locale ?? defaultLocale) as A;\n\n const cacheKey = `${String(key)}.${currentLocale}`;\n const loader = (dictionaryLoaders as Record<string, () => Promise<T>>)[\n currentLocale as string\n ];\n\n // A build-tool plugin may have started this locale's chunk while the entry\n // point evaluated, and it may already have landed. Seeding the cache with it turns the first call into a\n // cache hit, so the branch below returns real content instead of the\n // placeholder proxy — no extra code path needed.\n if (!cache.has(cacheKey)) {\n const preloadedDictionary = getPreloadedDictionary(\n dictionaryLoaders,\n currentLocale as LocalesValues\n );\n\n if (preloadedDictionary) cache.set(cacheKey, preloadedDictionary);\n }\n\n // --- Cache hit: return real content synchronously ---\n const cached = cache.get(cacheKey);\n if (cached) {\n const content = getDictionary(cached, currentLocale) as WithOnChange<\n DeepTransformContent<T['content']>\n >;\n\n content.onChange = (callback) => {\n // Re-fire whenever content reloads (locale change → new cache entry).\n client.subscribe((newLocale) => {\n const newKey = `${String(key)}.${newLocale}`;\n const newLoader = (\n dictionaryLoaders as Record<string, () => Promise<T>>\n )[newLocale];\n\n if (!newLoader) return;\n\n loadDictionary(newKey, newLoader).then(() => {\n const dict = cache.get(newKey);\n if (dict) {\n callback(getDictionary(dict, newLocale as A) as any);\n }\n });\n });\n\n return content;\n };\n\n return content;\n }\n\n // --- Cache miss: kick off background load, then notify to re-render ---\n if (loader) {\n loadDictionary(cacheKey, loader).then(() => {\n client.notify();\n });\n }\n\n return recursiveProxy;\n};\n"],"mappings":";;;;;;;;AAwBA,MAAM,wBAAQ,IAAI,IAAwB;;AAG1C,MAAM,2BAAW,IAAI,IAA2B;;AAGhD,MAAM,iCAAiB,IAAI,IAAqB;AAChD,MAAM,oCAAoB,IAAI,IAA2B;AAEzD,MAAM,kBACJ,UACA,WACkB;CAClB,IAAI,MAAM,IAAI,QAAQ,GAAG,OAAO,QAAQ,QAAQ;CAChD,IAAI,SAAS,IAAI,QAAQ,GAAG,OAAO,SAAS,IAAI,QAAQ;CAExD,MAAM,UAAU,OAAO,CAAC,CAAC,MAAM,eAAe;EAC5C,MAAM,IAAI,UAAU,UAAU;EAC9B,SAAS,OAAO,QAAQ;CAC1B,CAAC;CAED,SAAS,IAAI,UAAU,OAAO;CAC9B,OAAO;AACT;;AAGA,MAAM,iBAAsB,IAAI,YAAY,CAAC,GAAG;CAC9C,MAAM,IAAI,SAAS;EACjB,IAAI,SAAS,OAAO,aAAa,aAAa;EAC9C,IAAI,SAAS,YAAY,aAAa;EAC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AAe,IAAI,QAAQ,CAAC;EAGpD,IAAI,CAAC,kBAAkB,IAAI,QAAQ,GAAG;GACpC,MAAM,UAAU,eAAe,aAAa,CAAC,CAAC,MAAM,aAAa;IAC/D,eAAe,IAAI,UAAU,QAAQ;IACrC,kBAAkB,OAAO,QAAQ;IACjC,OAAO,OAAO;GAChB,CAAC;GACD,kBAAkB,IAAI,UAAU,OAAO;EACzC;EAEA,OAAO;CACT;CAOA,MAAM,iBAHJ,OAAO,qBAAqB,WACvB,mBACD,WAC2B,OAAO,UAAU;CAElD,MAAM,WAAW,GAAG,OAAO,GAAG,EAAE,GAAG;CACnC,MAAM,SAAU,kBACd;CAOF,IAAI,CAAC,MAAM,IAAI,QAAQ,GAAG;EACxB,MAAM,0BAAsBC,6DAC1B,mBACA,aACF;EAEA,IAAI,qBAAqB,MAAM,IAAI,UAAU,mBAAmB;CAClE;CAGA,MAAM,SAAS,MAAM,IAAI,QAAQ;CACjC,IAAI,QAAQ;EACV,MAAM,UAAUD,oCAAc,QAAQ,aAAa;EAInD,QAAQ,YAAY,aAAa;GAE/B,OAAO,WAAW,cAAc;IAC9B,MAAM,SAAS,GAAG,OAAO,GAAG,EAAE,GAAG;IACjC,MAAM,YACJ,kBACA;IAEF,IAAI,CAAC,WAAW;IAEhB,eAAe,QAAQ,SAAS,CAAC,CAAC,WAAW;KAC3C,MAAM,OAAO,MAAM,IAAI,MAAM;KAC7B,IAAI,MACF,SAASA,oCAAc,MAAM,SAAc,CAAQ;IAEvD,CAAC;GACH,CAAC;GAED,OAAO;EACT;EAEA,OAAO;CACT;CAGA,IAAI,QACF,eAAe,UAAU,MAAM,CAAC,CAAC,WAAW;EAC1C,OAAO,OAAO;CAChB,CAAC;CAGH,OAAO;AACT"}
1
+ {"version":3,"file":"useDictionaryDynamic.cjs","names":["getIntlayerClient","isQualifiedDynamicLoaderMap","parseDictionarySelector","resolveDictionaryArgument","getDictionarySelectorCacheKey","resolveQualifiedDynamicContentAsync","getDictionary","resolveInterpreterLocale","getPreloadedDictionary"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["import {\n getDictionarySelectorCacheKey,\n getPreloadedDictionary,\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveDictionaryArgument,\n resolveQualifiedDynamicContentAsync,\n} from '@intlayer/core/dictionaryManipulator';\nimport { resolveInterpreterLocale } from '@intlayer/core/interpreter';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport type { DeepTransformContent } from '../plugins';\nimport { getIntlayerClient } from './installIntlayer';\nimport type { WithOnChange } from './useDictionary';\n\n/** Simple in-memory cache shared across all calls in the same page. */\nconst cache = new Map<string, Dictionary>();\n\n/** Tracks in-flight loads to avoid duplicate fetches. */\nconst inflight = new Map<string, Promise<void>>();\n\n/** Resolved-content cache for qualified (collection/variant/meta) keys. */\nconst qualifiedCache = new Map<string, unknown>();\nconst qualifiedInflight = new Map<string, Promise<void>>();\n\nconst loadDictionary = <T extends Dictionary>(\n cacheKey: string,\n loader: () => Promise<T>\n): Promise<void> => {\n if (cache.has(cacheKey)) return Promise.resolve();\n if (inflight.has(cacheKey)) return inflight.get(cacheKey)!;\n\n const promise = loader().then((dictionary) => {\n cache.set(cacheKey, dictionary);\n inflight.delete(cacheKey);\n });\n\n inflight.set(cacheKey, promise);\n return promise;\n};\n\n/** Placeholder proxy — safe for any property access while loading. */\nconst recursiveProxy: any = new Proxy(() => {}, {\n get: (_t, prop) => {\n if (prop === Symbol.toPrimitive) return () => '';\n if (prop === 'toString') return () => '';\n if (prop === 'valueOf') return () => '';\n if (prop === 'then') return undefined; // not a Promise\n if (prop === 'onChange') return (_cb: any) => recursiveProxy;\n return recursiveProxy;\n },\n apply: () => recursiveProxy,\n});\n\n/**\n * Dynamically load and transform a dictionary (plain or qualified).\n *\n * For a qualified loader map (collection / variant, possibly\n * combined), only the chunk(s) the selector targets are loaded. For a plain\n * loader map, the locale chunk is loaded. The first call returns a placeholder\n * and triggers a background load; the client then notifies subscribers so the\n * render runs again with real content.\n *\n * @param dictionaryLoaders - Locale-keyed loader map, or a qualified loader map.\n * @param key - Dictionary key (used for cache namespacing).\n * @param localeOrSelector - Optional locale or selector.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const K extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelectorForKey<K> = DeclaredLocales,\n>(\n dictionaryLoaders:\n | StrictModeLocaleMap<() => Promise<T>>\n | QualifiedDynamicLoaderMap,\n key: K,\n localeOrSelector?: A\n): WithOnChange<DeepTransformContent<T['content']>> => {\n const client = getIntlayerClient();\n\n // --- Qualified loader map (collection / variant) ---\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n isQualifiedDynamicLoaderMap(dictionaryLoaders)\n ) {\n const loaderMap = dictionaryLoaders;\n // Layers the client's ambient variant under the call-site argument before\n // the chunk walk, so only the targeted chunk is loaded.\n const { locale: selectorLocale, selector } =\n parseDictionarySelector<LocalesValues>(\n resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: client.locale,\n contextVariant: client.variant,\n dictionaryKey: String(key),\n })\n );\n const selectorId = getDictionarySelectorCacheKey(selector);\n\n const buildKey = (locale: string) =>\n `${String(key)}.${locale}.${selectorId}`;\n const resolveContent = (locale: LocalesValues) =>\n resolveQualifiedDynamicContentAsync({\n loaderMap,\n key: String(key),\n locale,\n selector,\n transform: (dictionary) =>\n getDictionary(dictionary, locale as DeclaredLocales),\n });\n\n const currentLocale = (selectorLocale ??\n client.locale ??\n resolveInterpreterLocale()) as LocalesValues;\n const cacheKey = buildKey(currentLocale);\n\n const attachOnChange = (content: any) => {\n if (content != null && typeof content === 'object') {\n content.onChange = (callback: (c: any) => void) => {\n client.subscribe((newLocale) => {\n const locale = (selectorLocale ?? newLocale) as LocalesValues;\n const newKey = buildKey(locale);\n\n if (qualifiedCache.has(newKey)) {\n callback(qualifiedCache.get(newKey));\n return;\n }\n\n resolveContent(locale).then((resolved) => {\n qualifiedCache.set(newKey, resolved);\n callback(resolved);\n });\n });\n return content;\n };\n }\n return content;\n };\n\n if (qualifiedCache.has(cacheKey)) {\n return attachOnChange(qualifiedCache.get(cacheKey)) as any;\n }\n\n if (!qualifiedInflight.has(cacheKey)) {\n const promise = resolveContent(currentLocale).then((resolved) => {\n qualifiedCache.set(cacheKey, resolved);\n qualifiedInflight.delete(cacheKey);\n client.notify();\n });\n qualifiedInflight.set(cacheKey, promise);\n }\n\n return recursiveProxy;\n }\n\n // --- Plain locale-keyed loader map ---\n const locale =\n typeof localeOrSelector === 'string'\n ? (localeOrSelector as LocalesValues)\n : undefined;\n const currentLocale = (locale ??\n client.locale ??\n resolveInterpreterLocale()) as A;\n\n const cacheKey = `${String(key)}.${currentLocale}`;\n const loader = (dictionaryLoaders as Record<string, () => Promise<T>>)[\n currentLocale as string\n ];\n\n // A build-tool plugin may have started this locale's chunk while the entry\n // point evaluated, and it may already have landed. Seeding the cache with it turns the first call into a\n // cache hit, so the branch below returns real content instead of the\n // placeholder proxy — no extra code path needed.\n if (!cache.has(cacheKey)) {\n const preloadedDictionary = getPreloadedDictionary(\n dictionaryLoaders,\n currentLocale as LocalesValues\n );\n\n if (preloadedDictionary) cache.set(cacheKey, preloadedDictionary);\n }\n\n // --- Cache hit: return real content synchronously ---\n const cached = cache.get(cacheKey);\n if (cached) {\n const content = getDictionary(cached, currentLocale) as WithOnChange<\n DeepTransformContent<T['content']>\n >;\n\n content.onChange = (callback) => {\n // Re-fire whenever content reloads (locale change → new cache entry).\n client.subscribe((newLocale) => {\n const newKey = `${String(key)}.${newLocale}`;\n const newLoader = (\n dictionaryLoaders as Record<string, () => Promise<T>>\n )[newLocale];\n\n if (!newLoader) return;\n\n loadDictionary(newKey, newLoader).then(() => {\n const dict = cache.get(newKey);\n if (dict) {\n callback(getDictionary(dict, newLocale as A) as any);\n }\n });\n });\n\n return content;\n };\n\n return content;\n }\n\n // --- Cache miss: kick off background load, then notify to re-render ---\n if (loader) {\n loadDictionary(cacheKey, loader).then(() => {\n client.notify();\n });\n }\n\n return recursiveProxy;\n};\n"],"mappings":";;;;;;;;AAwBA,MAAM,wBAAQ,IAAI,IAAwB;;AAG1C,MAAM,2BAAW,IAAI,IAA2B;;AAGhD,MAAM,iCAAiB,IAAI,IAAqB;AAChD,MAAM,oCAAoB,IAAI,IAA2B;AAEzD,MAAM,kBACJ,UACA,WACkB;CAClB,IAAI,MAAM,IAAI,QAAQ,GAAG,OAAO,QAAQ,QAAQ;CAChD,IAAI,SAAS,IAAI,QAAQ,GAAG,OAAO,SAAS,IAAI,QAAQ;CAExD,MAAM,UAAU,OAAO,CAAC,CAAC,MAAM,eAAe;EAC5C,MAAM,IAAI,UAAU,UAAU;EAC9B,SAAS,OAAO,QAAQ;CAC1B,CAAC;CAED,SAAS,IAAI,UAAU,OAAO;CAC9B,OAAO;AACT;;AAGA,MAAM,iBAAsB,IAAI,YAAY,CAAC,GAAG;CAC9C,MAAM,IAAI,SAAS;EACjB,IAAI,SAAS,OAAO,aAAa,aAAa;EAC9C,IAAI,SAAS,YAAY,aAAa;EACtC,IAAI,SAAS,WAAW,aAAa;EACrC,IAAI,SAAS,QAAQ,OAAO;EAC5B,IAAI,SAAS,YAAY,QAAQ,QAAa;EAC9C,OAAO;CACT;CACA,aAAa;AACf,CAAC;;;;;;;;;;;;;;AAeD,MAAa,wBAKX,mBAGA,KACA,qBACqD;CACrD,MAAM,SAASA,iDAAkB;CAGjC,IACE,QAAQ,IAAI,iCAAiC,eAC7CC,kEAA4B,iBAAiB,GAC7C;EACA,MAAM,YAAY;EAGlB,MAAM,EAAE,QAAQ,gBAAgB,iBAC9BC,kEACEC,gEAA0B;GACxB;GACA,eAAe,OAAO;GACtB,gBAAgB,OAAO;GACvB,eAAe,OAAO,GAAG;EAC3B,CAAC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G;EACxB,MAAM,0BAAsBC,6DAC1B,mBACA,aACF;EAEA,IAAI,qBAAqB,MAAM,IAAI,UAAU,mBAAmB;CAClE;CAGA,MAAM,SAAS,MAAM,IAAI,QAAQ;CACjC,IAAI,QAAQ;EACV,MAAM,UAAUF,oCAAc,QAAQ,aAAa;EAInD,QAAQ,YAAY,aAAa;GAE/B,OAAO,WAAW,cAAc;IAC9B,MAAM,SAAS,GAAG,OAAO,GAAG,EAAE,GAAG;IACjC,MAAM,YACJ,kBACA;IAEF,IAAI,CAAC,WAAW;IAEhB,eAAe,QAAQ,SAAS,CAAC,CAAC,WAAW;KAC3C,MAAM,OAAO,MAAM,IAAI,MAAM;KAC7B,IAAI,MACF,SAASA,oCAAc,MAAM,SAAc,CAAQ;IAEvD,CAAC;GACH,CAAC;GAED,OAAO;EACT;EAEA,OAAO;CACT;CAGA,IAAI,QACF,eAAe,UAAU,MAAM,CAAC,CAAC,WAAW;EAC1C,OAAO,OAAO;CAChB,CAAC;CAGH,OAAO;AACT"}
@@ -207,15 +207,16 @@ const pluginsCache = /* @__PURE__ */ new Map();
207
207
  * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.
208
208
  */
209
209
  const getPlugins = (locale, fallback = true) => {
210
- const cacheKey = `${locale ?? _intlayer_config_built.internationalization.defaultLocale}_${fallback}`;
210
+ const currentLocale = (0, _intlayer_core_interpreter.resolveInterpreterLocale)(locale);
211
+ const cacheKey = `${currentLocale}_${fallback}`;
211
212
  if (pluginsCache.has(cacheKey)) return pluginsCache.get(cacheKey);
212
213
  const enabledPlugins = [
213
214
  intlayerNodePlugins,
214
- (0, _intlayer_core_interpreter.translationPlugin)(locale ?? _intlayer_config_built.internationalization.defaultLocale, fallback ? _intlayer_config_built.internationalization.defaultLocale : void 0),
215
+ (0, _intlayer_core_interpreter.translationPlugin)(currentLocale, fallback ? _intlayer_config_built.internationalization.defaultLocale : void 0),
215
216
  _intlayer_core_interpreter.enumerationPlugin,
216
- (0, _intlayer_core_interpreter.pluralPlugin)(locale ?? _intlayer_config_built.internationalization.defaultLocale),
217
+ (0, _intlayer_core_interpreter.pluralPlugin)(currentLocale),
217
218
  _intlayer_core_interpreter.conditionPlugin,
218
- (0, _intlayer_core_interpreter.nestedPlugin)(locale ?? _intlayer_config_built.internationalization.defaultLocale),
219
+ (0, _intlayer_core_interpreter.nestedPlugin)(currentLocale),
219
220
  _intlayer_core_interpreter.filePlugin,
220
221
  _intlayer_core_interpreter.genderPlugin,
221
222
  _intlayer_core_interpreter.selectPlugin,
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.cjs","names":["editor","renderIntlayerNode","fallbackPlugin","NodeTypes","isInterpolableWrapperNode","transformInterpolableNode","splitInsertionTemplate","resolveInsertedSelector","getMarkdownMetadata","compileWithOptions","getHTML","internationalization","translationPlugin","enumerationPlugin","pluralPlugin","conditionPlugin","nestedPlugin","filePlugin","genderPlugin","selectPlugin"],"sources":["../../src/plugins.ts"],"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 getHTML,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n isInterpolableWrapperNode,\n nestedPlugin,\n type Plugins,\n pluralPlugin,\n resolveInsertedSelector,\n selectPlugin,\n splitInsertionTemplate,\n transformInterpolableNode,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport {\n compileWithOptions,\n getMarkdownMetadata,\n} 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 type { HTMLComponents } from './html/types';\nimport {\n type IntlayerNode as IntlayerNodeCore,\n renderIntlayerNode,\n} from './renderIntlayerNode';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport type IntlayerNode<T, P = {}> = IntlayerNodeCore<T> & P;\n\nconst escapeHtmlAttr = (str: string): string =>\n str.replace(/&/g, '&amp;').replace(/\"/g, '&quot;');\n\nconst escapeHtmlText = (str: string): string =>\n str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\n\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: (_node, { children, keyPath, dictionaryKey }) => {\n if (process.env.INTLAYER_EDITOR_ENABLED !== 'false' && editor.enabled) {\n const rawStr = String(children ?? '');\n const keyPathJson = JSON.stringify(keyPath ?? []);\n const dictKey = String(dictionaryKey ?? '');\n\n /**\n * In editor mode, string coercion returns the wrapper HTML so that\n * `element.innerHTML = content.title` automatically inserts the\n * `<intlayer-content-selector-wrapper>` into the DOM.\n */\n const htmlStr = `<intlayer-content-selector-wrapper key-path=\"${escapeHtmlAttr(keyPathJson)}\" dictionary-key=\"${escapeHtmlAttr(dictKey)}\">${escapeHtmlText(rawStr)}</intlayer-content-selector-wrapper>`;\n\n return renderIntlayerNode({\n value: children as string,\n children: htmlStr,\n keyPath,\n dictionaryKey,\n additionalProps: {\n toElement: (): HTMLElement => {\n const wrapper = document.createElement(\n 'intlayer-content-selector-wrapper'\n );\n wrapper.setAttribute('key-path', keyPathJson);\n wrapper.setAttribute('dictionary-key', dictKey);\n wrapper.textContent = rawStr;\n return wrapper;\n },\n },\n });\n }\n\n return renderIntlayerNode({\n value: children as string,\n children,\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;\n fields: readonly (infer F)[];\n}\n ? <V extends { [K in Extract<F, string>]: string | number }>(\n values: V\n ) => I extends string ? IntlayerNode<string> : DeepTransformContent<I, L>\n : never;\n\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 { type: NodeTypes.INSERTION },\n ];\n\n const children = node[NodeTypes.INSERTION];\n\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) =>\n typeof node === 'string' || isInterpolableWrapperNode(node),\n transform: (node, subProps, deepTransformNode) => {\n // `html()`/`markdown()` nodes carry their `{{ … }}` placeholders\n // inside a raw string. Interpolate into that string, then re-run\n // the transform so the html/markdown renderer applies afterwards.\n if (isInterpolableWrapperNode(node)) {\n return (\n values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }\n ) =>\n transformInterpolableNode(\n node,\n values,\n subProps,\n props.plugins,\n deepTransformNode\n );\n }\n\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: (props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }\n ) => {\n const result = splitInsertionTemplate(\n transformedResult,\n values\n );\n const resultStr = result.isSimple\n ? (result.parts as string)\n : (result.parts as string[]).join('');\n\n return deepTransformNode(resultStr, {\n ...subProps,\n plugins: props.plugins,\n children: resultStr,\n });\n };\n },\n };\n\n const transformed = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n return resolveInsertedSelector(children, transformed);\n },\n };\n\n/** ---------------------------------------------\n * MARKDOWN PLUGIN\n * --------------------------------------------- */\n\nconst vanillaRuntime = {\n createElement: (tag: string, props: any, ...children: any[]) => {\n const attrs = Object.entries(props || {})\n .filter(\n ([key]) => key !== 'children' && key !== 'key' && key !== '_innerHTML'\n )\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(' ');\n const innerHTML = props?._innerHTML;\n const childrenStr =\n innerHTML !== undefined ? innerHTML : children.flat(Infinity).join('');\n return `<${tag}${attrs ? ` ${attrs}` : ''}>${childrenStr}</${tag}>`;\n },\n normalizeProps: (_tag: string, props: Record<string, any>) => {\n const normalized: Record<string, any> = {};\n for (const [key, value] of Object.entries(props)) {\n if (key === 'className') {\n normalized.class = value;\n } else if (key === 'htmlFor') {\n normalized.for = value;\n } else if (key === 'dangerouslySetInnerHTML' && (value as any)?.__html) {\n normalized._innerHTML = (value as any).__html;\n } else {\n normalized[key] = value;\n }\n }\n return normalized;\n },\n};\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<\n string,\n {\n metadata: DeepTransformContent<string>;\n /** Returns the rendered markdown; render with .use(). */\n use: (components?: HTMLComponents<'permissive', {}>) => string;\n }\n >\n : never;\n\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 { plugins: _plugins, ...rest } = props;\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, subProps) =>\n renderIntlayerNode({\n ...subProps,\n value: metadataNode,\n children: node,\n }),\n };\n\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const compile = (components: any = {}) =>\n compileWithOptions(\n node,\n {\n ...vanillaRuntime,\n createElement: (tag: any, props: any, ...children: any[]) => {\n const override = components[tag];\n if (typeof override === 'function') {\n return override({ ...props, children: children.join('') });\n }\n return vanillaRuntime.createElement(tag, props, ...children);\n },\n },\n {}\n ) as any;\n\n const value = compile();\n let children = node;\n\n if (\n process.env.INTLAYER_EDITOR_ENABLED !== 'false' &&\n editor.enabled\n ) {\n const keyPathJson = JSON.stringify(props.keyPath ?? []);\n const dictKey = String(props.dictionaryKey ?? '');\n children = `<intlayer-content-selector-wrapper key-path=\"${escapeHtmlAttr(keyPathJson)}\" dictionary-key=\"${escapeHtmlAttr(dictKey)}\">${escapeHtmlText(value)}</intlayer-content-selector-wrapper>`;\n }\n\n return renderIntlayerNode({\n ...props,\n value,\n children,\n additionalProps: {\n metadata: metadataNodes,\n use: (components?: any) => compile(components),\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>) => IntlayerNode<M>;\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 { type: NodeTypes.MARKDOWN },\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\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 htmlStr = node[NodeTypes.HTML];\n\n const use = (components: Record<string, any> = {}) => {\n const wrappedComponents = new Proxy(components, {\n get(target, prop) {\n if (typeof prop === 'string' && prop in target) {\n const Component = target[prop];\n return (props: any) => {\n const children = Array.isArray(props.children)\n ? props.children.join('')\n : props.children;\n return Component({ ...props, children });\n };\n }\n if (typeof prop === 'string' && /^[a-z][a-z0-9]*$/.test(prop)) {\n return (props: any) => {\n const attrs = Object.entries(props)\n .filter(([key]) => key !== 'children' && key !== 'key')\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(' ');\n const children = Array.isArray(props.children)\n ? props.children.join('')\n : props.children;\n return `<${prop}${attrs ? ` ${attrs}` : ''}>${children}</${prop}>`;\n };\n }\n return undefined;\n },\n });\n\n const result = getHTML(htmlStr, wrappedComponents as any);\n return Array.isArray(result) ? result.join('') : result;\n };\n\n const value = use();\n let children = htmlStr;\n\n if (\n process.env.INTLAYER_EDITOR_ENABLED !== 'false' &&\n editor.enabled\n ) {\n const keyPathJson = JSON.stringify(props.keyPath ?? []);\n const dictKey = String(props.dictionaryKey ?? '');\n children = `<intlayer-content-selector-wrapper key-path=\"${escapeHtmlAttr(keyPathJson)}\" dictionary-key=\"${escapeHtmlAttr(dictKey)}\">${escapeHtmlText(value)}</intlayer-content-selector-wrapper>`;\n }\n\n return renderIntlayerNode({\n ...props,\n value,\n children,\n additionalProps: {\n use: (components?: any) => use(components),\n },\n });\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginVanilla<T, S, L extends LocalesValues> {\n vanillaIntlayerNode: IntlayerNodeCond<T>;\n vanillaInsertion: InsertionCond<T, S, L>;\n vanillaMarkdown: MarkdownCond<T>;\n vanillaHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the `vanilla-intlayer` plugins will override the types of `intlayer` functions.\n * Use `getIntlayer` from `vanilla-intlayer` (not from `intlayer`) to get properly typed\n * `IntlayerNode` wrappers with `.value` access on string/number content.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion'\n> & {\n vanillaIntlayerNode: true;\n vanillaInsertion: true;\n vanillaMarkdown: true;\n vanillaHtml: 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 Vanilla 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 = 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 // First: most nodes are plain strings, which every other plugin rejects\n intlayerNodePlugins,\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 selectPlugin,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ] as Plugins[];\n\n // Plugins disabled at build time never match: skip them on every node\n const enabledPlugins = plugins.filter((plugin) => plugin !== fallbackPlugin);\n\n pluginsCache.set(cacheKey, enabledPlugins);\n\n return en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EACA;CAI2B,CAAC,CAAC,QAAQ,WAAW,WAAWjB,yCAAc;CAE3E,aAAa,IAAI,UAAU,cAAc;CAEzC,OAAO;AACT"}
1
+ {"version":3,"file":"plugins.cjs","names":["editor","renderIntlayerNode","fallbackPlugin","NodeTypes","isInterpolableWrapperNode","transformInterpolableNode","splitInsertionTemplate","resolveInsertedSelector","getMarkdownMetadata","compileWithOptions","getHTML","resolveInterpreterLocale","translationPlugin","internationalization","enumerationPlugin","pluralPlugin","conditionPlugin","nestedPlugin","filePlugin","genderPlugin","selectPlugin"],"sources":["../../src/plugins.ts"],"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 getHTML,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n isInterpolableWrapperNode,\n nestedPlugin,\n type Plugins,\n pluralPlugin,\n resolveInsertedSelector,\n resolveInterpreterLocale,\n selectPlugin,\n splitInsertionTemplate,\n transformInterpolableNode,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport {\n compileWithOptions,\n getMarkdownMetadata,\n} 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 type { HTMLComponents } from './html/types';\nimport {\n type IntlayerNode as IntlayerNodeCore,\n renderIntlayerNode,\n} from './renderIntlayerNode';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport type IntlayerNode<T, P = {}> = IntlayerNodeCore<T> & P;\n\nconst escapeHtmlAttr = (str: string): string =>\n str.replace(/&/g, '&amp;').replace(/\"/g, '&quot;');\n\nconst escapeHtmlText = (str: string): string =>\n str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\n\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: (_node, { children, keyPath, dictionaryKey }) => {\n if (process.env.INTLAYER_EDITOR_ENABLED !== 'false' && editor.enabled) {\n const rawStr = String(children ?? '');\n const keyPathJson = JSON.stringify(keyPath ?? []);\n const dictKey = String(dictionaryKey ?? '');\n\n /**\n * In editor mode, string coercion returns the wrapper HTML so that\n * `element.innerHTML = content.title` automatically inserts the\n * `<intlayer-content-selector-wrapper>` into the DOM.\n */\n const htmlStr = `<intlayer-content-selector-wrapper key-path=\"${escapeHtmlAttr(keyPathJson)}\" dictionary-key=\"${escapeHtmlAttr(dictKey)}\">${escapeHtmlText(rawStr)}</intlayer-content-selector-wrapper>`;\n\n return renderIntlayerNode({\n value: children as string,\n children: htmlStr,\n keyPath,\n dictionaryKey,\n additionalProps: {\n toElement: (): HTMLElement => {\n const wrapper = document.createElement(\n 'intlayer-content-selector-wrapper'\n );\n wrapper.setAttribute('key-path', keyPathJson);\n wrapper.setAttribute('dictionary-key', dictKey);\n wrapper.textContent = rawStr;\n return wrapper;\n },\n },\n });\n }\n\n return renderIntlayerNode({\n value: children as string,\n children,\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;\n fields: readonly (infer F)[];\n}\n ? <V extends { [K in Extract<F, string>]: string | number }>(\n values: V\n ) => I extends string ? IntlayerNode<string> : DeepTransformContent<I, L>\n : never;\n\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 { type: NodeTypes.INSERTION },\n ];\n\n const children = node[NodeTypes.INSERTION];\n\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) =>\n typeof node === 'string' || isInterpolableWrapperNode(node),\n transform: (node, subProps, deepTransformNode) => {\n // `html()`/`markdown()` nodes carry their `{{ … }}` placeholders\n // inside a raw string. Interpolate into that string, then re-run\n // the transform so the html/markdown renderer applies afterwards.\n if (isInterpolableWrapperNode(node)) {\n return (\n values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }\n ) =>\n transformInterpolableNode(\n node,\n values,\n subProps,\n props.plugins,\n deepTransformNode\n );\n }\n\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: (props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }\n ) => {\n const result = splitInsertionTemplate(\n transformedResult,\n values\n );\n const resultStr = result.isSimple\n ? (result.parts as string)\n : (result.parts as string[]).join('');\n\n return deepTransformNode(resultStr, {\n ...subProps,\n plugins: props.plugins,\n children: resultStr,\n });\n };\n },\n };\n\n const transformed = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n return resolveInsertedSelector(children, transformed);\n },\n };\n\n/** ---------------------------------------------\n * MARKDOWN PLUGIN\n * --------------------------------------------- */\n\nconst vanillaRuntime = {\n createElement: (tag: string, props: any, ...children: any[]) => {\n const attrs = Object.entries(props || {})\n .filter(\n ([key]) => key !== 'children' && key !== 'key' && key !== '_innerHTML'\n )\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(' ');\n const innerHTML = props?._innerHTML;\n const childrenStr =\n innerHTML !== undefined ? innerHTML : children.flat(Infinity).join('');\n return `<${tag}${attrs ? ` ${attrs}` : ''}>${childrenStr}</${tag}>`;\n },\n normalizeProps: (_tag: string, props: Record<string, any>) => {\n const normalized: Record<string, any> = {};\n for (const [key, value] of Object.entries(props)) {\n if (key === 'className') {\n normalized.class = value;\n } else if (key === 'htmlFor') {\n normalized.for = value;\n } else if (key === 'dangerouslySetInnerHTML' && (value as any)?.__html) {\n normalized._innerHTML = (value as any).__html;\n } else {\n normalized[key] = value;\n }\n }\n return normalized;\n },\n};\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<\n string,\n {\n metadata: DeepTransformContent<string>;\n /** Returns the rendered markdown; render with .use(). */\n use: (components?: HTMLComponents<'permissive', {}>) => string;\n }\n >\n : never;\n\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 { plugins: _plugins, ...rest } = props;\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, subProps) =>\n renderIntlayerNode({\n ...subProps,\n value: metadataNode,\n children: node,\n }),\n };\n\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const compile = (components: any = {}) =>\n compileWithOptions(\n node,\n {\n ...vanillaRuntime,\n createElement: (tag: any, props: any, ...children: any[]) => {\n const override = components[tag];\n if (typeof override === 'function') {\n return override({ ...props, children: children.join('') });\n }\n return vanillaRuntime.createElement(tag, props, ...children);\n },\n },\n {}\n ) as any;\n\n const value = compile();\n let children = node;\n\n if (\n process.env.INTLAYER_EDITOR_ENABLED !== 'false' &&\n editor.enabled\n ) {\n const keyPathJson = JSON.stringify(props.keyPath ?? []);\n const dictKey = String(props.dictionaryKey ?? '');\n children = `<intlayer-content-selector-wrapper key-path=\"${escapeHtmlAttr(keyPathJson)}\" dictionary-key=\"${escapeHtmlAttr(dictKey)}\">${escapeHtmlText(value)}</intlayer-content-selector-wrapper>`;\n }\n\n return renderIntlayerNode({\n ...props,\n value,\n children,\n additionalProps: {\n metadata: metadataNodes,\n use: (components?: any) => compile(components),\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>) => IntlayerNode<M>;\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 { type: NodeTypes.MARKDOWN },\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\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 htmlStr = node[NodeTypes.HTML];\n\n const use = (components: Record<string, any> = {}) => {\n const wrappedComponents = new Proxy(components, {\n get(target, prop) {\n if (typeof prop === 'string' && prop in target) {\n const Component = target[prop];\n return (props: any) => {\n const children = Array.isArray(props.children)\n ? props.children.join('')\n : props.children;\n return Component({ ...props, children });\n };\n }\n if (typeof prop === 'string' && /^[a-z][a-z0-9]*$/.test(prop)) {\n return (props: any) => {\n const attrs = Object.entries(props)\n .filter(([key]) => key !== 'children' && key !== 'key')\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(' ');\n const children = Array.isArray(props.children)\n ? props.children.join('')\n : props.children;\n return `<${prop}${attrs ? ` ${attrs}` : ''}>${children}</${prop}>`;\n };\n }\n return undefined;\n },\n });\n\n const result = getHTML(htmlStr, wrappedComponents as any);\n return Array.isArray(result) ? result.join('') : result;\n };\n\n const value = use();\n let children = htmlStr;\n\n if (\n process.env.INTLAYER_EDITOR_ENABLED !== 'false' &&\n editor.enabled\n ) {\n const keyPathJson = JSON.stringify(props.keyPath ?? []);\n const dictKey = String(props.dictionaryKey ?? '');\n children = `<intlayer-content-selector-wrapper key-path=\"${escapeHtmlAttr(keyPathJson)}\" dictionary-key=\"${escapeHtmlAttr(dictKey)}\">${escapeHtmlText(value)}</intlayer-content-selector-wrapper>`;\n }\n\n return renderIntlayerNode({\n ...props,\n value,\n children,\n additionalProps: {\n use: (components?: any) => use(components),\n },\n });\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginVanilla<T, S, L extends LocalesValues> {\n vanillaIntlayerNode: IntlayerNodeCond<T>;\n vanillaInsertion: InsertionCond<T, S, L>;\n vanillaMarkdown: MarkdownCond<T>;\n vanillaHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the `vanilla-intlayer` plugins will override the types of `intlayer` functions.\n * Use `getIntlayer` from `vanilla-intlayer` (not from `intlayer`) to get properly typed\n * `IntlayerNode` wrappers with `.value` access on string/number content.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion'\n> & {\n vanillaIntlayerNode: true;\n vanillaInsertion: true;\n vanillaMarkdown: true;\n vanillaHtml: 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 Vanilla 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 = true\n): Plugins[] => {\n const currentLocale = resolveInterpreterLocale(locale);\n const cacheKey = `${currentLocale}_${fallback}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n // First: most nodes are plain strings, which every other plugin rejects\n intlayerNodePlugins,\n translationPlugin(\n currentLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n pluralPlugin(currentLocale),\n conditionPlugin,\n nestedPlugin(currentLocale),\n filePlugin,\n genderPlugin,\n selectPlugin,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ] as Plugins[];\n\n // Plugins disabled at build time never match: skip them on every node\n const enabledPlugins = plugins.filter((plugin) => plugin !== fallbackPlugin);\n\n pluginsCache.set(cacheKey, enabledPlugins);\n\n return enabledPlugins;\n};\n"],"mappings":";;;;;;;;;;AAqDA,MAAM,kBAAkB,QACtB,IAAI,QAAQ,MAAM,OAAO,CAAC,CAAC,QAAQ,MAAM,QAAQ;AAEnD,MAAM,kBAAkB,QACtB,IAAI,QAAQ,MAAM,OAAO,CAAC,CAAC,QAAQ,MAAM,MAAM,CAAC,CAAC,QAAQ,MAAM,MAAM;AAEvE,MAAa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OAAO,QAAQ,IAAI,UAAU,GAAG,GAAG,SAAS,IAAI,KAAK;IAClE;GAGJ,EACF,CAAC;GAED,MAAM,aAASO,oCAAQ,SAAS,iBAAwB;GACxD,OAAO,MAAM,QAAQ,MAAM,IAAI,OAAO,KAAK,EAAE,IAAI;EACnD;EAEA,MAAM,QAAQ,IAAI;EAClB,IAAI,WAAW;EAEf,IACE,QAAQ,IAAI,4BAA4B,WACxCV,8BAAO,SACP;GACA,MAAM,cAAc,KAAK,UAAU,MAAM,WAAW,CAAC,CAAC;GACtD,MAAM,UAAU,OAAO,MAAM,iBAAiB,EAAE;GAChD,WAAW,gDAAgD,eAAe,WAAW,EAAE,oBAAoB,eAAe,OAAO,EAAE,IAAI,eAAe,KAAK,EAAE;EAC/J;EAEA,OAAOC,8CAAmB;GACxB,GAAG;GACH;GACA;GACA,iBAAiB,EACf,MAAM,eAAqB,IAAI,UAAU,EAC3C;EACF,CAAC;CACH;AACF;AAmCN,MAAM,+BAAe,IAAI,IAAuB;;;;;AAMhD,MAAa,cACX,QACA,WAAW,SACG;CACd,MAAM,oBAAgBU,qDAAyB,MAAM;CACrD,MAAM,WAAW,GAAG,cAAc,GAAG;CAErC,IAAI,aAAa,IAAI,QAAQ,GAC3B,OAAO,aAAa,IAAI,QAAQ;CAuBlC,MAAM,iBAAiB;EAlBrB;MACAC,8CACE,eACA,WAAWC,4CAAqB,gBAAgB,MAClD;EACAC;MACAC,yCAAa,aAAa;EAC1BC;MACAC,yCAAa,aAAa;EAC1BC;EACAC;EACAC;EACA;EACA;EACA;CAI2B,CAAC,CAAC,QAAQ,WAAW,WAAWlB,yCAAc;CAE3E,aAAa,IAAI,UAAU,cAAc;CAEzC,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"renderIntlayerNode.cjs","names":["getIntlayerNodePrototype"],"sources":["../../src/renderIntlayerNode.ts"],"sourcesContent":["import { getIntlayerNodePrototype } from '@intlayer/core/utils';\nimport type { ResolvedEditor } from '@intlayer/types/module_augmentation';\n\nexport type IntlayerNode<T = string> = ResolvedEditor<\n T & {\n raw: T;\n value: T;\n toString: () => string;\n valueOf: () => T;\n toJSON: () => T;\n __update: (next: IntlayerNode<T>) => void;\n },\n {\n raw: T;\n value: T;\n toString: () => string;\n valueOf: () => T;\n toJSON: () => T;\n __update: (next: IntlayerNode<T>) => void;\n }\n> &\n T;\n\nexport const renderIntlayerNode = <\n T, // Broadened to support arrays, numbers, objects, etc.\n>({\n value,\n children,\n additionalProps = {},\n}: {\n value: T;\n children?: any;\n additionalProps?: Record<string, unknown>;\n [key: string]: unknown;\n}): IntlayerNode<T> => {\n let _value = value;\n\n // When children is a string that differs from value, it acts as a display\n // override (e.g. editor HTML wrapper). Otherwise toString/toPrimitive reflect\n // the live _value so that __update propagates.\n const displayOverride =\n typeof children === 'string' && children !== String(value ?? '')\n ? children\n : null;\n\n const node = {\n // Serves the value's members: `node.toUpperCase()`, `'trim' in node`\n __proto__: getIntlayerNodePrototype(value),\n\n toString: () => displayOverride ?? String(_value ?? ''),\n valueOf: () => _value,\n [Symbol.toPrimitive]: () => displayOverride ?? _value,\n toJSON: () => _value,\n\n get raw() {\n return _value;\n },\n set raw(value: T) {\n _value = value;\n },\n\n get value() {\n return _value;\n },\n\n __update(next: any) {\n _value = next?.raw ?? next?.value ?? next;\n },\n\n ...additionalProps,\n };\n\n return node as unknown as IntlayerNode<T>;\n};\n"],"mappings":";;;;AAuBA,MAAa,sBAEX,EACA,OACA,UACA,kBAAkB,CAAC,QAME;CACrB,IAAI,SAAS;CAKb,MAAM,kBACJ,OAAO,aAAa,YAAY,aAAa,OAAO,SAAS,EAAE,IAC3D,WACA;CA6BN,OAAO;EAzBL,eAAWA,+CAAyB,KAAK;EAEzC,gBAAgB,mBAAmB,OAAO,UAAU,EAAE;EACtD,eAAe;GACd,OAAO,oBAAoB,mBAAmB;EAC/C,cAAc;EAEd,IAAI,MAAM;GACR,OAAO;EACT;EACA,IAAI,IAAI,OAAU;GAChB,SAAS;EACX;EAEA,IAAI,QAAQ;GACV,OAAO;EACT;EAEA,SAAS,MAAW;GAClB,SAAS,MAAM,OAAO,MAAM,SAAS;EACvC;EAEA,GAAG;CAGK;AACZ"}
1
+ {"version":3,"file":"renderIntlayerNode.cjs","names":["getIntlayerNodePrototype"],"sources":["../../src/renderIntlayerNode.ts"],"sourcesContent":["import { getIntlayerNodePrototype } from '@intlayer/core/utils';\nimport type { ResolvedEditor } from '@intlayer/types/module_augmentation';\n\ntype IntlayerNodeMembers<T> = {\n raw: T;\n value: T;\n toString: () => string;\n valueOf: () => T;\n toJSON: () => T;\n __update: (next: IntlayerNode<T>) => void;\n};\n\n/**\n * Content node returned by `useIntlayer`.\n *\n * Without the editor it is typed as its value plus the node members, so it\n * can be used wherever a string is expected. With the editor, string coercion returns the editor wrapper HTML,\n * so string usages must go through `.value`.\n */\nexport type IntlayerNode<T = string> = ResolvedEditor<\n T & IntlayerNodeMembers<T>,\n IntlayerNodeMembers<T>\n>;\n\nexport const renderIntlayerNode = <\n T, // Broadened to support arrays, numbers, objects, etc.\n>({\n value,\n children,\n additionalProps = {},\n}: {\n value: T;\n children?: any;\n additionalProps?: Record<string, unknown>;\n [key: string]: unknown;\n}): IntlayerNode<T> => {\n let _value = value;\n\n // When children is a string that differs from value, it acts as a display\n // override (e.g. editor HTML wrapper). Otherwise toString/toPrimitive reflect\n // the live _value so that __update propagates.\n const displayOverride =\n typeof children === 'string' && children !== String(value ?? '')\n ? children\n : null;\n\n const node = {\n // Serves the value's members: `node.toUpperCase()`, `'trim' in node`\n __proto__: getIntlayerNodePrototype(value),\n\n toString: () => displayOverride ?? String(_value ?? ''),\n valueOf: () => _value,\n [Symbol.toPrimitive]: () => displayOverride ?? _value,\n toJSON: () => _value,\n\n get raw() {\n return _value;\n },\n set raw(value: T) {\n _value = value;\n },\n\n get value() {\n return _value;\n },\n\n __update(next: any) {\n _value = next?.raw ?? next?.value ?? next;\n },\n\n ...additionalProps,\n };\n\n return node as unknown as IntlayerNode<T>;\n};\n"],"mappings":";;;;AAwBA,MAAa,sBAEX,EACA,OACA,UACA,kBAAkB,CAAC,QAME;CACrB,IAAI,SAAS;CAKb,MAAM,kBACJ,OAAO,aAAa,YAAY,aAAa,OAAO,SAAS,EAAE,IAC3D,WACA;CA6BN,OAAO;EAzBL,eAAWA,+CAAyB,KAAK;EAEzC,gBAAgB,mBAAmB,OAAO,UAAU,EAAE;EACtD,eAAe;GACd,OAAO,oBAAoB,mBAAmB;EAC/C,cAAc;EAEd,IAAI,MAAM;GACR,OAAO;EACT;EACA,IAAI,IAAI,OAAU;GAChB,SAAS;EACX;EAEA,IAAI,QAAQ;GACV,OAAO;EACT;EAEA,SAAS,MAAW;GAClB,SAAS,MAAM,OAAO,MAAM,SAAS;EACvC;EAEA,GAAG;CAGK;AACZ"}
@@ -1,6 +1,6 @@
1
- import { getDictionary } from "../getDictionary.mjs";
1
+ import { getDictionary as getDictionary$1 } from "../getDictionary.mjs";
2
2
  import { getIntlayerClient } from "./installIntlayer.mjs";
3
- import { internationalization } from "@intlayer/config/built";
3
+ import { resolveInterpreterLocale } from "@intlayer/core/interpreter";
4
4
  import { getDictionarySelectorCacheKey, getPreloadedDictionary, isQualifiedDynamicLoaderMap, parseDictionarySelector, resolveDictionaryArgument, resolveQualifiedDynamicContentAsync } from "@intlayer/core/dictionaryManipulator";
5
5
 
6
6
  //#region src/client/useDictionaryDynamic.ts
@@ -48,7 +48,6 @@ const recursiveProxy = new Proxy(() => {}, {
48
48
  */
49
49
  const useDictionaryDynamic = (dictionaryLoaders, key, localeOrSelector) => {
50
50
  const client = getIntlayerClient();
51
- const defaultLocale = internationalization.defaultLocale;
52
51
  if (process.env.INTLAYER_DICTIONARY_SELECTOR !== "false" && isQualifiedDynamicLoaderMap(dictionaryLoaders)) {
53
52
  const loaderMap = dictionaryLoaders;
54
53
  const { locale: selectorLocale, selector } = parseDictionarySelector(resolveDictionaryArgument({
@@ -64,9 +63,9 @@ const useDictionaryDynamic = (dictionaryLoaders, key, localeOrSelector) => {
64
63
  key: String(key),
65
64
  locale,
66
65
  selector,
67
- transform: (dictionary) => getDictionary(dictionary, locale)
66
+ transform: (dictionary) => getDictionary$1(dictionary, locale)
68
67
  });
69
- const currentLocale = selectorLocale ?? client.locale ?? defaultLocale;
68
+ const currentLocale = selectorLocale ?? client.locale ?? resolveInterpreterLocale();
70
69
  const cacheKey = buildKey(currentLocale);
71
70
  const attachOnChange = (content) => {
72
71
  if (content != null && typeof content === "object") content.onChange = (callback) => {
@@ -97,7 +96,7 @@ const useDictionaryDynamic = (dictionaryLoaders, key, localeOrSelector) => {
97
96
  }
98
97
  return recursiveProxy;
99
98
  }
100
- const currentLocale = (typeof localeOrSelector === "string" ? localeOrSelector : void 0) ?? client.locale ?? defaultLocale;
99
+ const currentLocale = (typeof localeOrSelector === "string" ? localeOrSelector : void 0) ?? client.locale ?? resolveInterpreterLocale();
101
100
  const cacheKey = `${String(key)}.${currentLocale}`;
102
101
  const loader = dictionaryLoaders[currentLocale];
103
102
  if (!cache.has(cacheKey)) {
@@ -106,7 +105,7 @@ const useDictionaryDynamic = (dictionaryLoaders, key, localeOrSelector) => {
106
105
  }
107
106
  const cached = cache.get(cacheKey);
108
107
  if (cached) {
109
- const content = getDictionary(cached, currentLocale);
108
+ const content = getDictionary$1(cached, currentLocale);
110
109
  content.onChange = (callback) => {
111
110
  client.subscribe((newLocale) => {
112
111
  const newKey = `${String(key)}.${newLocale}`;
@@ -114,7 +113,7 @@ const useDictionaryDynamic = (dictionaryLoaders, key, localeOrSelector) => {
114
113
  if (!newLoader) return;
115
114
  loadDictionary(newKey, newLoader).then(() => {
116
115
  const dict = cache.get(newKey);
117
- if (dict) callback(getDictionary(dict, newLocale));
116
+ if (dict) callback(getDictionary$1(dict, newLocale));
118
117
  });
119
118
  });
120
119
  return content;
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport {\n getDictionarySelectorCacheKey,\n getPreloadedDictionary,\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveDictionaryArgument,\n resolveQualifiedDynamicContentAsync,\n} from '@intlayer/core/dictionaryManipulator';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport type { DeepTransformContent } from '../plugins';\nimport { getIntlayerClient } from './installIntlayer';\nimport type { WithOnChange } from './useDictionary';\n\n/** Simple in-memory cache shared across all calls in the same page. */\nconst cache = new Map<string, Dictionary>();\n\n/** Tracks in-flight loads to avoid duplicate fetches. */\nconst inflight = new Map<string, Promise<void>>();\n\n/** Resolved-content cache for qualified (collection/variant/meta) keys. */\nconst qualifiedCache = new Map<string, unknown>();\nconst qualifiedInflight = new Map<string, Promise<void>>();\n\nconst loadDictionary = <T extends Dictionary>(\n cacheKey: string,\n loader: () => Promise<T>\n): Promise<void> => {\n if (cache.has(cacheKey)) return Promise.resolve();\n if (inflight.has(cacheKey)) return inflight.get(cacheKey)!;\n\n const promise = loader().then((dictionary) => {\n cache.set(cacheKey, dictionary);\n inflight.delete(cacheKey);\n });\n\n inflight.set(cacheKey, promise);\n return promise;\n};\n\n/** Placeholder proxy — safe for any property access while loading. */\nconst recursiveProxy: any = new Proxy(() => {}, {\n get: (_t, prop) => {\n if (prop === Symbol.toPrimitive) return () => '';\n if (prop === 'toString') return () => '';\n if (prop === 'valueOf') return () => '';\n if (prop === 'then') return undefined; // not a Promise\n if (prop === 'onChange') return (_cb: any) => recursiveProxy;\n return recursiveProxy;\n },\n apply: () => recursiveProxy,\n});\n\n/**\n * Dynamically load and transform a dictionary (plain or qualified).\n *\n * For a qualified loader map (collection / variant, possibly\n * combined), only the chunk(s) the selector targets are loaded. For a plain\n * loader map, the locale chunk is loaded. The first call returns a placeholder\n * and triggers a background load; the client then notifies subscribers so the\n * render runs again with real content.\n *\n * @param dictionaryLoaders - Locale-keyed loader map, or a qualified loader map.\n * @param key - Dictionary key (used for cache namespacing).\n * @param localeOrSelector - Optional locale or selector.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const K extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelectorForKey<K> = DeclaredLocales,\n>(\n dictionaryLoaders:\n | StrictModeLocaleMap<() => Promise<T>>\n | QualifiedDynamicLoaderMap,\n key: K,\n localeOrSelector?: A\n): WithOnChange<DeepTransformContent<T['content']>> => {\n const client = getIntlayerClient();\n const defaultLocale = internationalization.defaultLocale;\n\n // --- Qualified loader map (collection / variant) ---\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n isQualifiedDynamicLoaderMap(dictionaryLoaders)\n ) {\n const loaderMap = dictionaryLoaders;\n // Layers the client's ambient variant under the call-site argument before\n // the chunk walk, so only the targeted chunk is loaded.\n const { locale: selectorLocale, selector } =\n parseDictionarySelector<LocalesValues>(\n resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: client.locale,\n contextVariant: client.variant,\n dictionaryKey: String(key),\n })\n );\n const selectorId = getDictionarySelectorCacheKey(selector);\n\n const buildKey = (locale: string) =>\n `${String(key)}.${locale}.${selectorId}`;\n const resolveContent = (locale: LocalesValues) =>\n resolveQualifiedDynamicContentAsync({\n loaderMap,\n key: String(key),\n locale,\n selector,\n transform: (dictionary) =>\n getDictionary(dictionary, locale as DeclaredLocales),\n });\n\n const currentLocale = (selectorLocale ??\n client.locale ??\n defaultLocale) as LocalesValues;\n const cacheKey = buildKey(currentLocale);\n\n const attachOnChange = (content: any) => {\n if (content != null && typeof content === 'object') {\n content.onChange = (callback: (c: any) => void) => {\n client.subscribe((newLocale) => {\n const locale = (selectorLocale ?? newLocale) as LocalesValues;\n const newKey = buildKey(locale);\n\n if (qualifiedCache.has(newKey)) {\n callback(qualifiedCache.get(newKey));\n return;\n }\n\n resolveContent(locale).then((resolved) => {\n qualifiedCache.set(newKey, resolved);\n callback(resolved);\n });\n });\n return content;\n };\n }\n return content;\n };\n\n if (qualifiedCache.has(cacheKey)) {\n return attachOnChange(qualifiedCache.get(cacheKey)) as any;\n }\n\n if (!qualifiedInflight.has(cacheKey)) {\n const promise = resolveContent(currentLocale).then((resolved) => {\n qualifiedCache.set(cacheKey, resolved);\n qualifiedInflight.delete(cacheKey);\n client.notify();\n });\n qualifiedInflight.set(cacheKey, promise);\n }\n\n return recursiveProxy;\n }\n\n // --- Plain locale-keyed loader map ---\n const locale =\n typeof localeOrSelector === 'string'\n ? (localeOrSelector as LocalesValues)\n : undefined;\n const currentLocale = (locale ?? client.locale ?? defaultLocale) as A;\n\n const cacheKey = `${String(key)}.${currentLocale}`;\n const loader = (dictionaryLoaders as Record<string, () => Promise<T>>)[\n currentLocale as string\n ];\n\n // A build-tool plugin may have started this locale's chunk while the entry\n // point evaluated, and it may already have landed. Seeding the cache with it turns the first call into a\n // cache hit, so the branch below returns real content instead of the\n // placeholder proxy — no extra code path needed.\n if (!cache.has(cacheKey)) {\n const preloadedDictionary = getPreloadedDictionary(\n dictionaryLoaders,\n currentLocale as LocalesValues\n );\n\n if (preloadedDictionary) cache.set(cacheKey, preloadedDictionary);\n }\n\n // --- Cache hit: return real content synchronously ---\n const cached = cache.get(cacheKey);\n if (cached) {\n const content = getDictionary(cached, currentLocale) as WithOnChange<\n DeepTransformContent<T['content']>\n >;\n\n content.onChange = (callback) => {\n // Re-fire whenever content reloads (locale change → new cache entry).\n client.subscribe((newLocale) => {\n const newKey = `${String(key)}.${newLocale}`;\n const newLoader = (\n dictionaryLoaders as Record<string, () => Promise<T>>\n )[newLocale];\n\n if (!newLoader) return;\n\n loadDictionary(newKey, newLoader).then(() => {\n const dict = cache.get(newKey);\n if (dict) {\n callback(getDictionary(dict, newLocale as A) as any);\n }\n });\n });\n\n return content;\n };\n\n return content;\n }\n\n // --- Cache miss: kick off background load, then notify to re-render ---\n if (loader) {\n loadDictionary(cacheKey, loader).then(() => {\n client.notify();\n });\n }\n\n return recursiveProxy;\n};\n"],"mappings":";;;;;;;AAwBA,MAAM,wBAAQ,IAAI,IAAwB;;AAG1C,MAAM,2BAAW,IAAI,IAA2B;;AAGhD,MAAM,iCAAiB,IAAI,IAAqB;AAChD,MAAM,oCAAoB,IAAI,IAA2B;AAEzD,MAAM,kBACJ,UACA,WACkB;CAClB,IAAI,MAAM,IAAI,QAAQ,GAAG,OAAO,QAAQ,QAAQ;CAChD,IAAI,SAAS,IAAI,QAAQ,GAAG,OAAO,SAAS,IAAI,QAAQ;CAExD,MAAM,UAAU,OAAO,CAAC,CAAC,MAAM,eAAe;EAC5C,MAAM,IAAI,UAAU,UAAU;EAC9B,SAAS,OAAO,QAAQ;CAC1B,CAAC;CAED,SAAS,IAAI,UAAU,OAAO;CAC9B,OAAO;AACT;;AAGA,MAAM,iBAAsB,IAAI,YAAY,CAAC,GAAG;CAC9C,MAAM,IAAI,SAAS;EACjB,IAAI,SAAS,OAAO,aAAa,aAAa;EAC9C,IAAI,SAAS,YAAY,aAAa;EACtC,IAAI,SAAS,WAAW,aAAa;EACrC,IAAI,SAAS,QAAQ,OAAO;EAC5B,IAAI,SAAS,YAAY,QAAQ,QAAa;EAC9C,OAAO;CACT;CACA,aAAa;AACf,CAAC;;;;;;;;;;;;;;AAeD,MAAa,wBAKX,mBAGA,KACA,qBACqD;CACrD,MAAM,SAAS,kBAAkB;CACjC,MAAM,gBAAgB,qBAAqB;CAG3C,IACE,QAAQ,IAAI,iCAAiC,WAC7C,4BAA4B,iBAAiB,GAC7C;EACA,MAAM,YAAY;EAGlB,MAAM,EAAE,QAAQ,gBAAgB,aAC9B,wBACE,0BAA0B;GACxB;GACA,eAAe,OAAO;GACtB,gBAAgB,OAAO;GACvB,eAAe,OAAO,GAAG;EAC3B,CAAC,CACH;EACF,MAAM,aAAa,8BAA8B,QAAQ;EAEzD,MAAM,YAAY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AmB;CAClE;CAGA,MAAM,SAAS,MAAM,IAAI,QAAQ;CACjC,IAAI,QAAQ;EACV,MAAM,UAAU,cAAc,QAAQ,aAAa;EAInD,QAAQ,YAAY,aAAa;GAE/B,OAAO,WAAW,cAAc;IAC9B,MAAM,SAAS,GAAG,OAAO,GAAG,EAAE,GAAG;IACjC,MAAM,YACJ,kBACA;IAEF,IAAI,CAAC,WAAW;IAEhB,eAAe,QAAQ,SAAS,CAAC,CAAC,WAAW;KAC3C,MAAM,OAAO,MAAM,IAAI,MAAM;KAC7B,IAAI,MACF,SAAS,cAAc,MAAM,SAAc,CAAQ;IAEvD,CAAC;GACH,CAAC;GAED,OAAO;EACT;EAEA,OAAO;CACT;CAGA,IAAI,QACF,eAAe,UAAU,MAAM,CAAC,CAAC,WAAW;EAC1C,OAAO,OAAO;CAChB,CAAC;CAGH,OAAO;AACT"}
1
+ {"version":3,"file":"useDictionaryDynamic.mjs","names":["getDictionary"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["import {\n getDictionarySelectorCacheKey,\n getPreloadedDictionary,\n isQualifiedDynamicLoaderMap,\n parseDictionarySelector,\n type QualifiedDynamicLoaderMap,\n resolveDictionaryArgument,\n resolveQualifiedDynamicContentAsync,\n} from '@intlayer/core/dictionaryManipulator';\nimport { resolveInterpreterLocale } from '@intlayer/core/interpreter';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionarySelectorForKey,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport type { DeepTransformContent } from '../plugins';\nimport { getIntlayerClient } from './installIntlayer';\nimport type { WithOnChange } from './useDictionary';\n\n/** Simple in-memory cache shared across all calls in the same page. */\nconst cache = new Map<string, Dictionary>();\n\n/** Tracks in-flight loads to avoid duplicate fetches. */\nconst inflight = new Map<string, Promise<void>>();\n\n/** Resolved-content cache for qualified (collection/variant/meta) keys. */\nconst qualifiedCache = new Map<string, unknown>();\nconst qualifiedInflight = new Map<string, Promise<void>>();\n\nconst loadDictionary = <T extends Dictionary>(\n cacheKey: string,\n loader: () => Promise<T>\n): Promise<void> => {\n if (cache.has(cacheKey)) return Promise.resolve();\n if (inflight.has(cacheKey)) return inflight.get(cacheKey)!;\n\n const promise = loader().then((dictionary) => {\n cache.set(cacheKey, dictionary);\n inflight.delete(cacheKey);\n });\n\n inflight.set(cacheKey, promise);\n return promise;\n};\n\n/** Placeholder proxy — safe for any property access while loading. */\nconst recursiveProxy: any = new Proxy(() => {}, {\n get: (_t, prop) => {\n if (prop === Symbol.toPrimitive) return () => '';\n if (prop === 'toString') return () => '';\n if (prop === 'valueOf') return () => '';\n if (prop === 'then') return undefined; // not a Promise\n if (prop === 'onChange') return (_cb: any) => recursiveProxy;\n return recursiveProxy;\n },\n apply: () => recursiveProxy,\n});\n\n/**\n * Dynamically load and transform a dictionary (plain or qualified).\n *\n * For a qualified loader map (collection / variant, possibly\n * combined), only the chunk(s) the selector targets are loaded. For a plain\n * loader map, the locale chunk is loaded. The first call returns a placeholder\n * and triggers a background load; the client then notifies subscribers so the\n * render runs again with real content.\n *\n * @param dictionaryLoaders - Locale-keyed loader map, or a qualified loader map.\n * @param key - Dictionary key (used for cache namespacing).\n * @param localeOrSelector - Optional locale or selector.\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const K extends DictionaryKeys,\n const A extends LocalesValues | DictionarySelectorForKey<K> = DeclaredLocales,\n>(\n dictionaryLoaders:\n | StrictModeLocaleMap<() => Promise<T>>\n | QualifiedDynamicLoaderMap,\n key: K,\n localeOrSelector?: A\n): WithOnChange<DeepTransformContent<T['content']>> => {\n const client = getIntlayerClient();\n\n // --- Qualified loader map (collection / variant) ---\n if (\n process.env.INTLAYER_DICTIONARY_SELECTOR !== 'false' &&\n isQualifiedDynamicLoaderMap(dictionaryLoaders)\n ) {\n const loaderMap = dictionaryLoaders;\n // Layers the client's ambient variant under the call-site argument before\n // the chunk walk, so only the targeted chunk is loaded.\n const { locale: selectorLocale, selector } =\n parseDictionarySelector<LocalesValues>(\n resolveDictionaryArgument({\n localeOrSelector,\n contextLocale: client.locale,\n contextVariant: client.variant,\n dictionaryKey: String(key),\n })\n );\n const selectorId = getDictionarySelectorCacheKey(selector);\n\n const buildKey = (locale: string) =>\n `${String(key)}.${locale}.${selectorId}`;\n const resolveContent = (locale: LocalesValues) =>\n resolveQualifiedDynamicContentAsync({\n loaderMap,\n key: String(key),\n locale,\n selector,\n transform: (dictionary) =>\n getDictionary(dictionary, locale as DeclaredLocales),\n });\n\n const currentLocale = (selectorLocale ??\n client.locale ??\n resolveInterpreterLocale()) as LocalesValues;\n const cacheKey = buildKey(currentLocale);\n\n const attachOnChange = (content: any) => {\n if (content != null && typeof content === 'object') {\n content.onChange = (callback: (c: any) => void) => {\n client.subscribe((newLocale) => {\n const locale = (selectorLocale ?? newLocale) as LocalesValues;\n const newKey = buildKey(locale);\n\n if (qualifiedCache.has(newKey)) {\n callback(qualifiedCache.get(newKey));\n return;\n }\n\n resolveContent(locale).then((resolved) => {\n qualifiedCache.set(newKey, resolved);\n callback(resolved);\n });\n });\n return content;\n };\n }\n return content;\n };\n\n if (qualifiedCache.has(cacheKey)) {\n return attachOnChange(qualifiedCache.get(cacheKey)) as any;\n }\n\n if (!qualifiedInflight.has(cacheKey)) {\n const promise = resolveContent(currentLocale).then((resolved) => {\n qualifiedCache.set(cacheKey, resolved);\n qualifiedInflight.delete(cacheKey);\n client.notify();\n });\n qualifiedInflight.set(cacheKey, promise);\n }\n\n return recursiveProxy;\n }\n\n // --- Plain locale-keyed loader map ---\n const locale =\n typeof localeOrSelector === 'string'\n ? (localeOrSelector as LocalesValues)\n : undefined;\n const currentLocale = (locale ??\n client.locale ??\n resolveInterpreterLocale()) as A;\n\n const cacheKey = `${String(key)}.${currentLocale}`;\n const loader = (dictionaryLoaders as Record<string, () => Promise<T>>)[\n currentLocale as string\n ];\n\n // A build-tool plugin may have started this locale's chunk while the entry\n // point evaluated, and it may already have landed. Seeding the cache with it turns the first call into a\n // cache hit, so the branch below returns real content instead of the\n // placeholder proxy — no extra code path needed.\n if (!cache.has(cacheKey)) {\n const preloadedDictionary = getPreloadedDictionary(\n dictionaryLoaders,\n currentLocale as LocalesValues\n );\n\n if (preloadedDictionary) cache.set(cacheKey, preloadedDictionary);\n }\n\n // --- Cache hit: return real content synchronously ---\n const cached = cache.get(cacheKey);\n if (cached) {\n const content = getDictionary(cached, currentLocale) as WithOnChange<\n DeepTransformContent<T['content']>\n >;\n\n content.onChange = (callback) => {\n // Re-fire whenever content reloads (locale change → new cache entry).\n client.subscribe((newLocale) => {\n const newKey = `${String(key)}.${newLocale}`;\n const newLoader = (\n dictionaryLoaders as Record<string, () => Promise<T>>\n )[newLocale];\n\n if (!newLoader) return;\n\n loadDictionary(newKey, newLoader).then(() => {\n const dict = cache.get(newKey);\n if (dict) {\n callback(getDictionary(dict, newLocale as A) as any);\n }\n });\n });\n\n return content;\n };\n\n return content;\n }\n\n // --- Cache miss: kick off background load, then notify to re-render ---\n if (loader) {\n loadDictionary(cacheKey, loader).then(() => {\n client.notify();\n });\n }\n\n return recursiveProxy;\n};\n"],"mappings":";;;;;;;AAwBA,MAAM,wBAAQ,IAAI,IAAwB;;AAG1C,MAAM,2BAAW,IAAI,IAA2B;;AAGhD,MAAM,iCAAiB,IAAI,IAAqB;AAChD,MAAM,oCAAoB,IAAI,IAA2B;AAEzD,MAAM,kBACJ,UACA,WACkB;CAClB,IAAI,MAAM,IAAI,QAAQ,GAAG,OAAO,QAAQ,QAAQ;CAChD,IAAI,SAAS,IAAI,QAAQ,GAAG,OAAO,SAAS,IAAI,QAAQ;CAExD,MAAM,UAAU,OAAO,CAAC,CAAC,MAAM,eAAe;EAC5C,MAAM,IAAI,UAAU,UAAU;EAC9B,SAAS,OAAO,QAAQ;CAC1B,CAAC;CAED,SAAS,IAAI,UAAU,OAAO;CAC9B,OAAO;AACT;;AAGA,MAAM,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derIntlayerNode.mjs";
2
- import { conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, getHTML, isInterpolableWrapperNode, nestedPlugin, pluralPlugin, resolveInsertedSelector, selectPlugin, splitInsertionTemplate, transformInterpolableNode, translationPlugin } from "@intlayer/core/interpreter";
2
+ import { conditionPlugin, enumerationPlugin, fallbackPlugin, filePlugin, genderPlugin, getHTML, isInterpolableWrapperNode, nestedPlugin, pluralPlugin, resolveInsertedSelector, resolveInterpreterLocale, selectPlugin, splitInsertionTemplate, transformInterpolableNode, translationPlugin } from "@intlayer/core/interpreter";
3
3
  import { editor, internationalization } from "@intlayer/config/built";
4
4
  import { compileWithOptions, getMarkdownMetadata } from "@intlayer/core/markdown";
5
5
  import * as NodeTypes from "@intlayer/types/nodeType";
@@ -204,15 +204,16 @@ const pluginsCache = /* @__PURE__ */ new Map();
204
204
  * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.
205
205
  */
206
206
  const getPlugins = (locale, fallback = true) => {
207
- const cacheKey = `${locale ?? internationalization.defaultLocale}_${fallback}`;
207
+ const currentLocale = resolveInterpreterLocale(locale);
208
+ const cacheKey = `${currentLocale}_${fallback}`;
208
209
  if (pluginsCache.has(cacheKey)) return pluginsCache.get(cacheKey);
209
210
  const enabledPlugins = [
210
211
  intlayerNodePlugins,
211
- translationPlugin(locale ?? internationalization.defaultLocale, fallback ? internationalization.defaultLocale : void 0),
212
+ translationPlugin(currentLocale, fallback ? internationalization.defaultLocale : void 0),
212
213
  enumerationPlugin,
213
- pluralPlugin(locale ?? internationalization.defaultLocale),
214
+ pluralPlugin(currentLocale),
214
215
  conditionPlugin,
215
- nestedPlugin(locale ?? internationalization.defaultLocale),
216
+ nestedPlugin(currentLocale),
216
217
  filePlugin,
217
218
  genderPlugin,
218
219
  selectPlugin,
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/plugins.ts"],"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 getHTML,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n isInterpolableWrapperNode,\n nestedPlugin,\n type Plugins,\n pluralPlugin,\n resolveInsertedSelector,\n selectPlugin,\n splitInsertionTemplate,\n transformInterpolableNode,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport {\n compileWithOptions,\n getMarkdownMetadata,\n} 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 type { HTMLComponents } from './html/types';\nimport {\n type IntlayerNode as IntlayerNodeCore,\n renderIntlayerNode,\n} from './renderIntlayerNode';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport type IntlayerNode<T, P = {}> = IntlayerNodeCore<T> & P;\n\nconst escapeHtmlAttr = (str: string): string =>\n str.replace(/&/g, '&amp;').replace(/\"/g, '&quot;');\n\nconst escapeHtmlText = (str: string): string =>\n str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\n\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: (_node, { children, keyPath, dictionaryKey }) => {\n if (process.env.INTLAYER_EDITOR_ENABLED !== 'false' && editor.enabled) {\n const rawStr = String(children ?? '');\n const keyPathJson = JSON.stringify(keyPath ?? []);\n const dictKey = String(dictionaryKey ?? '');\n\n /**\n * In editor mode, string coercion returns the wrapper HTML so that\n * `element.innerHTML = content.title` automatically inserts the\n * `<intlayer-content-selector-wrapper>` into the DOM.\n */\n const htmlStr = `<intlayer-content-selector-wrapper key-path=\"${escapeHtmlAttr(keyPathJson)}\" dictionary-key=\"${escapeHtmlAttr(dictKey)}\">${escapeHtmlText(rawStr)}</intlayer-content-selector-wrapper>`;\n\n return renderIntlayerNode({\n value: children as string,\n children: htmlStr,\n keyPath,\n dictionaryKey,\n additionalProps: {\n toElement: (): HTMLElement => {\n const wrapper = document.createElement(\n 'intlayer-content-selector-wrapper'\n );\n wrapper.setAttribute('key-path', keyPathJson);\n wrapper.setAttribute('dictionary-key', dictKey);\n wrapper.textContent = rawStr;\n return wrapper;\n },\n },\n });\n }\n\n return renderIntlayerNode({\n value: children as string,\n children,\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;\n fields: readonly (infer F)[];\n}\n ? <V extends { [K in Extract<F, string>]: string | number }>(\n values: V\n ) => I extends string ? IntlayerNode<string> : DeepTransformContent<I, L>\n : never;\n\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 { type: NodeTypes.INSERTION },\n ];\n\n const children = node[NodeTypes.INSERTION];\n\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) =>\n typeof node === 'string' || isInterpolableWrapperNode(node),\n transform: (node, subProps, deepTransformNode) => {\n // `html()`/`markdown()` nodes carry their `{{ … }}` placeholders\n // inside a raw string. Interpolate into that string, then re-run\n // the transform so the html/markdown renderer applies afterwards.\n if (isInterpolableWrapperNode(node)) {\n return (\n values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }\n ) =>\n transformInterpolableNode(\n node,\n values,\n subProps,\n props.plugins,\n deepTransformNode\n );\n }\n\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: (props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }\n ) => {\n const result = splitInsertionTemplate(\n transformedResult,\n values\n );\n const resultStr = result.isSimple\n ? (result.parts as string)\n : (result.parts as string[]).join('');\n\n return deepTransformNode(resultStr, {\n ...subProps,\n plugins: props.plugins,\n children: resultStr,\n });\n };\n },\n };\n\n const transformed = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n return resolveInsertedSelector(children, transformed);\n },\n };\n\n/** ---------------------------------------------\n * MARKDOWN PLUGIN\n * --------------------------------------------- */\n\nconst vanillaRuntime = {\n createElement: (tag: string, props: any, ...children: any[]) => {\n const attrs = Object.entries(props || {})\n .filter(\n ([key]) => key !== 'children' && key !== 'key' && key !== '_innerHTML'\n )\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(' ');\n const innerHTML = props?._innerHTML;\n const childrenStr =\n innerHTML !== undefined ? innerHTML : children.flat(Infinity).join('');\n return `<${tag}${attrs ? ` ${attrs}` : ''}>${childrenStr}</${tag}>`;\n },\n normalizeProps: (_tag: string, props: Record<string, any>) => {\n const normalized: Record<string, any> = {};\n for (const [key, value] of Object.entries(props)) {\n if (key === 'className') {\n normalized.class = value;\n } else if (key === 'htmlFor') {\n normalized.for = value;\n } else if (key === 'dangerouslySetInnerHTML' && (value as any)?.__html) {\n normalized._innerHTML = (value as any).__html;\n } else {\n normalized[key] = value;\n }\n }\n return normalized;\n },\n};\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<\n string,\n {\n metadata: DeepTransformContent<string>;\n /** Returns the rendered markdown; render with .use(). */\n use: (components?: HTMLComponents<'permissive', {}>) => string;\n }\n >\n : never;\n\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 { plugins: _plugins, ...rest } = props;\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, subProps) =>\n renderIntlayerNode({\n ...subProps,\n value: metadataNode,\n children: node,\n }),\n };\n\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const compile = (components: any = {}) =>\n compileWithOptions(\n node,\n {\n ...vanillaRuntime,\n createElement: (tag: any, props: any, ...children: any[]) => {\n const override = components[tag];\n if (typeof override === 'function') {\n return override({ ...props, children: children.join('') });\n }\n return vanillaRuntime.createElement(tag, props, ...children);\n },\n },\n {}\n ) as any;\n\n const value = compile();\n let children = node;\n\n if (\n process.env.INTLAYER_EDITOR_ENABLED !== 'false' &&\n editor.enabled\n ) {\n const keyPathJson = JSON.stringify(props.keyPath ?? []);\n const dictKey = String(props.dictionaryKey ?? '');\n children = `<intlayer-content-selector-wrapper key-path=\"${escapeHtmlAttr(keyPathJson)}\" dictionary-key=\"${escapeHtmlAttr(dictKey)}\">${escapeHtmlText(value)}</intlayer-content-selector-wrapper>`;\n }\n\n return renderIntlayerNode({\n ...props,\n value,\n children,\n additionalProps: {\n metadata: metadataNodes,\n use: (components?: any) => compile(components),\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>) => IntlayerNode<M>;\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 { type: NodeTypes.MARKDOWN },\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\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 htmlStr = node[NodeTypes.HTML];\n\n const use = (components: Record<string, any> = {}) => {\n const wrappedComponents = new Proxy(components, {\n get(target, prop) {\n if (typeof prop === 'string' && prop in target) {\n const Component = target[prop];\n return (props: any) => {\n const children = Array.isArray(props.children)\n ? props.children.join('')\n : props.children;\n return Component({ ...props, children });\n };\n }\n if (typeof prop === 'string' && /^[a-z][a-z0-9]*$/.test(prop)) {\n return (props: any) => {\n const attrs = Object.entries(props)\n .filter(([key]) => key !== 'children' && key !== 'key')\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(' ');\n const children = Array.isArray(props.children)\n ? props.children.join('')\n : props.children;\n return `<${prop}${attrs ? ` ${attrs}` : ''}>${children}</${prop}>`;\n };\n }\n return undefined;\n },\n });\n\n const result = getHTML(htmlStr, wrappedComponents as any);\n return Array.isArray(result) ? result.join('') : result;\n };\n\n const value = use();\n let children = htmlStr;\n\n if (\n process.env.INTLAYER_EDITOR_ENABLED !== 'false' &&\n editor.enabled\n ) {\n const keyPathJson = JSON.stringify(props.keyPath ?? []);\n const dictKey = String(props.dictionaryKey ?? '');\n children = `<intlayer-content-selector-wrapper key-path=\"${escapeHtmlAttr(keyPathJson)}\" dictionary-key=\"${escapeHtmlAttr(dictKey)}\">${escapeHtmlText(value)}</intlayer-content-selector-wrapper>`;\n }\n\n return renderIntlayerNode({\n ...props,\n value,\n children,\n additionalProps: {\n use: (components?: any) => use(components),\n },\n });\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginVanilla<T, S, L extends LocalesValues> {\n vanillaIntlayerNode: IntlayerNodeCond<T>;\n vanillaInsertion: InsertionCond<T, S, L>;\n vanillaMarkdown: MarkdownCond<T>;\n vanillaHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the `vanilla-intlayer` plugins will override the types of `intlayer` functions.\n * Use `getIntlayer` from `vanilla-intlayer` (not from `intlayer`) to get properly typed\n * `IntlayerNode` wrappers with `.value` access on string/number content.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion'\n> & {\n vanillaIntlayerNode: true;\n vanillaInsertion: true;\n vanillaMarkdown: true;\n vanillaHtml: 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 Vanilla 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 = 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 // First: most nodes are plain strings, which every other plugin rejects\n intlayerNodePlugins,\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 selectPlugin,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ] as Plugins[];\n\n // Plugins disabled at build time never match: skip them on every node\n const enabledPlugins = plugins.filter((plugin) => plugin !== fallbackPlugin);\n\n pluginsCache.set(cacheKey, enabledPlugins);\n\n return enabledPlugins;\n};\n"],"mappings":";;;;;;;AAoDA,MAAM,kBAAkB,QACtB,IAAI,QAAQ,MAAM,OAAO,CAAC,CAAC,QAAQ,MAAM,QAAQ;AAEnD,MAAM,kBAAkB,QACtB,IAAI,QAAQ,MAAM,OAAO,CAAC,CAAC,QAAQ,MAAM,MAAM,CAAC,CAAC,QAAQ,MAAM,MAAM;AAEvE,MAAa,sBAA+B;CAC1C,IAAI;CACJ,YAAY,SACV,OAAO,SAAS,YAChB,OAAO,SAAS,YAChB,OAAO,SAAS;CAClB,YAAY,OAAO,EAAE,UAAU,SAAS,oBAAoB;EAC1D,IAAI,QAAQ,IAAI,4BAA4B,WAAW,OAAO,SAAS;GACrE,MAAM,SAAS,OAAO,YAAY,EAAE;GACpC,MAAM,cAAc,KAAK,UAAU,WAAW,CAAC,CAAC;GAChD,MAAM,UAAU,OAAO,iBAAiB,EAAE;;;;;;GAO1C,MAAM,UAAU,gDAAgD,eAAe,WAAW,EAAE,oBAAoB,eAAe,OAAO,EAAE,IA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O,EAAE,IAAI,eAAe,KAAK,EAAE;EAC/J;EAEA,OAAO,mBAAmB;GACxB,GAAG;GACH;GACA;GACA,iBAAiB,EACf,MAAM,eAAqB,IAAI,UAAU,EAC3C;EACF,CAAC;CACH;AACF;AAmCN,MAAM,+BAAe,IAAI,IAAuB;;;;;AAMhD,MAAa,cACX,QACA,WAAW,SACG;CAEd,MAAM,WAAW,GADK,UAAU,qBAAqB,cACnB,GAAG;CAErC,IAAI,aAAa,IAAI,QAAQ,GAC3B,OAAO,aAAa,IAAI,QAAQ;CAuBlC,MAAM,iBAAiB;EAlBrB;EACA,kBACE,UAAU,qBAAqB,eAC/B,WAAW,qBAAqB,gBAAgB,MAClD;EACA;EACA,aAAa,UAAU,qBAAqB,aAAa;EACzD;EACA,aAAa,UAAU,qBAAqB,aAAa;EACzD;EACA;EACA;EACA;EACA;EACA;CAI2B,CAAC,CAAC,QAAQ,WAAW,WAAW,cAAc;CAE3E,aAAa,IAAI,UAAU,cAAc;CAEzC,OAAO;AACT"}
1
+ {"version":3,"file":"plugins.mjs","names":[],"sources":["../../src/plugins.ts"],"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 getHTML,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n isInterpolableWrapperNode,\n nestedPlugin,\n type Plugins,\n pluralPlugin,\n resolveInsertedSelector,\n resolveInterpreterLocale,\n selectPlugin,\n splitInsertionTemplate,\n transformInterpolableNode,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport {\n compileWithOptions,\n getMarkdownMetadata,\n} 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 type { HTMLComponents } from './html/types';\nimport {\n type IntlayerNode as IntlayerNodeCore,\n renderIntlayerNode,\n} from './renderIntlayerNode';\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport type IntlayerNode<T, P = {}> = IntlayerNodeCore<T> & P;\n\nconst escapeHtmlAttr = (str: string): string =>\n str.replace(/&/g, '&amp;').replace(/\"/g, '&quot;');\n\nconst escapeHtmlText = (str: string): string =>\n str.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');\n\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: (_node, { children, keyPath, dictionaryKey }) => {\n if (process.env.INTLAYER_EDITOR_ENABLED !== 'false' && editor.enabled) {\n const rawStr = String(children ?? '');\n const keyPathJson = JSON.stringify(keyPath ?? []);\n const dictKey = String(dictionaryKey ?? '');\n\n /**\n * In editor mode, string coercion returns the wrapper HTML so that\n * `element.innerHTML = content.title` automatically inserts the\n * `<intlayer-content-selector-wrapper>` into the DOM.\n */\n const htmlStr = `<intlayer-content-selector-wrapper key-path=\"${escapeHtmlAttr(keyPathJson)}\" dictionary-key=\"${escapeHtmlAttr(dictKey)}\">${escapeHtmlText(rawStr)}</intlayer-content-selector-wrapper>`;\n\n return renderIntlayerNode({\n value: children as string,\n children: htmlStr,\n keyPath,\n dictionaryKey,\n additionalProps: {\n toElement: (): HTMLElement => {\n const wrapper = document.createElement(\n 'intlayer-content-selector-wrapper'\n );\n wrapper.setAttribute('key-path', keyPathJson);\n wrapper.setAttribute('dictionary-key', dictKey);\n wrapper.textContent = rawStr;\n return wrapper;\n },\n },\n });\n }\n\n return renderIntlayerNode({\n value: children as string,\n children,\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;\n fields: readonly (infer F)[];\n}\n ? <V extends { [K in Extract<F, string>]: string | number }>(\n values: V\n ) => I extends string ? IntlayerNode<string> : DeepTransformContent<I, L>\n : never;\n\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 { type: NodeTypes.INSERTION },\n ];\n\n const children = node[NodeTypes.INSERTION];\n\n const insertionStringPlugin: Plugins = {\n id: 'insertion-string-plugin',\n canHandle: (node) =>\n typeof node === 'string' || isInterpolableWrapperNode(node),\n transform: (node, subProps, deepTransformNode) => {\n // `html()`/`markdown()` nodes carry their `{{ … }}` placeholders\n // inside a raw string. Interpolate into that string, then re-run\n // the transform so the html/markdown renderer applies afterwards.\n if (isInterpolableWrapperNode(node)) {\n return (\n values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }\n ) =>\n transformInterpolableNode(\n node,\n values,\n subProps,\n props.plugins,\n deepTransformNode\n );\n }\n\n const transformedResult = deepTransformNode(node, {\n ...subProps,\n children: node,\n plugins: (props.plugins ?? ([] as Plugins[])).filter(\n (plugin) => plugin.id !== 'intlayer-node-plugin'\n ),\n });\n\n return (\n values: {\n [K in InsertionContent['fields'][number]]: string | number;\n }\n ) => {\n const result = splitInsertionTemplate(\n transformedResult,\n values\n );\n const resultStr = result.isSimple\n ? (result.parts as string)\n : (result.parts as string[]).join('');\n\n return deepTransformNode(resultStr, {\n ...subProps,\n plugins: props.plugins,\n children: resultStr,\n });\n };\n },\n };\n\n const transformed = deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [insertionStringPlugin, ...(props.plugins ?? [])],\n });\n\n return resolveInsertedSelector(children, transformed);\n },\n };\n\n/** ---------------------------------------------\n * MARKDOWN PLUGIN\n * --------------------------------------------- */\n\nconst vanillaRuntime = {\n createElement: (tag: string, props: any, ...children: any[]) => {\n const attrs = Object.entries(props || {})\n .filter(\n ([key]) => key !== 'children' && key !== 'key' && key !== '_innerHTML'\n )\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(' ');\n const innerHTML = props?._innerHTML;\n const childrenStr =\n innerHTML !== undefined ? innerHTML : children.flat(Infinity).join('');\n return `<${tag}${attrs ? ` ${attrs}` : ''}>${childrenStr}</${tag}>`;\n },\n normalizeProps: (_tag: string, props: Record<string, any>) => {\n const normalized: Record<string, any> = {};\n for (const [key, value] of Object.entries(props)) {\n if (key === 'className') {\n normalized.class = value;\n } else if (key === 'htmlFor') {\n normalized.for = value;\n } else if (key === 'dangerouslySetInnerHTML' && (value as any)?.__html) {\n normalized._innerHTML = (value as any).__html;\n } else {\n normalized[key] = value;\n }\n }\n return normalized;\n },\n};\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<\n string,\n {\n metadata: DeepTransformContent<string>;\n /** Returns the rendered markdown; render with .use(). */\n use: (components?: HTMLComponents<'permissive', {}>) => string;\n }\n >\n : never;\n\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 { plugins: _plugins, ...rest } = props;\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, subProps) =>\n renderIntlayerNode({\n ...subProps,\n value: metadataNode,\n children: node,\n }),\n };\n\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const compile = (components: any = {}) =>\n compileWithOptions(\n node,\n {\n ...vanillaRuntime,\n createElement: (tag: any, props: any, ...children: any[]) => {\n const override = components[tag];\n if (typeof override === 'function') {\n return override({ ...props, children: children.join('') });\n }\n return vanillaRuntime.createElement(tag, props, ...children);\n },\n },\n {}\n ) as any;\n\n const value = compile();\n let children = node;\n\n if (\n process.env.INTLAYER_EDITOR_ENABLED !== 'false' &&\n editor.enabled\n ) {\n const keyPathJson = JSON.stringify(props.keyPath ?? []);\n const dictKey = String(props.dictionaryKey ?? '');\n children = `<intlayer-content-selector-wrapper key-path=\"${escapeHtmlAttr(keyPathJson)}\" dictionary-key=\"${escapeHtmlAttr(dictKey)}\">${escapeHtmlText(value)}</intlayer-content-selector-wrapper>`;\n }\n\n return renderIntlayerNode({\n ...props,\n value,\n children,\n additionalProps: {\n metadata: metadataNodes,\n use: (components?: any) => compile(components),\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>) => IntlayerNode<M>;\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 { type: NodeTypes.MARKDOWN },\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\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 htmlStr = node[NodeTypes.HTML];\n\n const use = (components: Record<string, any> = {}) => {\n const wrappedComponents = new Proxy(components, {\n get(target, prop) {\n if (typeof prop === 'string' && prop in target) {\n const Component = target[prop];\n return (props: any) => {\n const children = Array.isArray(props.children)\n ? props.children.join('')\n : props.children;\n return Component({ ...props, children });\n };\n }\n if (typeof prop === 'string' && /^[a-z][a-z0-9]*$/.test(prop)) {\n return (props: any) => {\n const attrs = Object.entries(props)\n .filter(([key]) => key !== 'children' && key !== 'key')\n .map(([key, value]) => `${key}=\"${value}\"`)\n .join(' ');\n const children = Array.isArray(props.children)\n ? props.children.join('')\n : props.children;\n return `<${prop}${attrs ? ` ${attrs}` : ''}>${children}</${prop}>`;\n };\n }\n return undefined;\n },\n });\n\n const result = getHTML(htmlStr, wrappedComponents as any);\n return Array.isArray(result) ? result.join('') : result;\n };\n\n const value = use();\n let children = htmlStr;\n\n if (\n process.env.INTLAYER_EDITOR_ENABLED !== 'false' &&\n editor.enabled\n ) {\n const keyPathJson = JSON.stringify(props.keyPath ?? []);\n const dictKey = String(props.dictionaryKey ?? '');\n children = `<intlayer-content-selector-wrapper key-path=\"${escapeHtmlAttr(keyPathJson)}\" dictionary-key=\"${escapeHtmlAttr(dictKey)}\">${escapeHtmlText(value)}</intlayer-content-selector-wrapper>`;\n }\n\n return renderIntlayerNode({\n ...props,\n value,\n children,\n additionalProps: {\n use: (components?: any) => use(components),\n },\n });\n },\n };\n\n/** ---------------------------------------------\n * PLUGINS RESULT\n * --------------------------------------------- */\n\nexport interface IInterpreterPluginVanilla<T, S, L extends LocalesValues> {\n vanillaIntlayerNode: IntlayerNodeCond<T>;\n vanillaInsertion: InsertionCond<T, S, L>;\n vanillaMarkdown: MarkdownCond<T>;\n vanillaHtml: HTMLPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the `vanilla-intlayer` plugins will override the types of `intlayer` functions.\n * Use `getIntlayer` from `vanilla-intlayer` (not from `intlayer`) to get properly typed\n * `IntlayerNode` wrappers with `.value` access on string/number content.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion'\n> & {\n vanillaIntlayerNode: true;\n vanillaInsertion: true;\n vanillaMarkdown: true;\n vanillaHtml: 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 Vanilla 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 = true\n): Plugins[] => {\n const currentLocale = resolveInterpreterLocale(locale);\n const cacheKey = `${currentLocale}_${fallback}`;\n\n if (pluginsCache.has(cacheKey)) {\n return pluginsCache.get(cacheKey)!;\n }\n\n const plugins = [\n // First: most nodes are plain strings, which every other plugin rejects\n intlayerNodePlugins,\n translationPlugin(\n currentLocale,\n fallback ? internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n pluralPlugin(currentLocale),\n conditionPlugin,\n nestedPlugin(currentLocale),\n filePlugin,\n genderPlugin,\n selectPlugin,\n insertionPlugin,\n markdownPlugin,\n htmlPlugin,\n ] as Plugins[];\n\n // Plugins disabled at build time never match: skip them on every node\n const enabledPlugins = plugins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AAQ,WAAW,WAAW,cAAc;CAE3E,aAAa,IAAI,UAAU,cAAc;CAEzC,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"renderIntlayerNode.mjs","names":[],"sources":["../../src/renderIntlayerNode.ts"],"sourcesContent":["import { getIntlayerNodePrototype } from '@intlayer/core/utils';\nimport type { ResolvedEditor } from '@intlayer/types/module_augmentation';\n\nexport type IntlayerNode<T = string> = ResolvedEditor<\n T & {\n raw: T;\n value: T;\n toString: () => string;\n valueOf: () => T;\n toJSON: () => T;\n __update: (next: IntlayerNode<T>) => void;\n },\n {\n raw: T;\n value: T;\n toString: () => string;\n valueOf: () => T;\n toJSON: () => T;\n __update: (next: IntlayerNode<T>) => void;\n }\n> &\n T;\n\nexport const renderIntlayerNode = <\n T, // Broadened to support arrays, numbers, objects, etc.\n>({\n value,\n children,\n additionalProps = {},\n}: {\n value: T;\n children?: any;\n additionalProps?: Record<string, unknown>;\n [key: string]: unknown;\n}): IntlayerNode<T> => {\n let _value = value;\n\n // When children is a string that differs from value, it acts as a display\n // override (e.g. editor HTML wrapper). Otherwise toString/toPrimitive reflect\n // the live _value so that __update propagates.\n const displayOverride =\n typeof children === 'string' && children !== String(value ?? '')\n ? children\n : null;\n\n const node = {\n // Serves the value's members: `node.toUpperCase()`, `'trim' in node`\n __proto__: getIntlayerNodePrototype(value),\n\n toString: () => displayOverride ?? String(_value ?? ''),\n valueOf: () => _value,\n [Symbol.toPrimitive]: () => displayOverride ?? _value,\n toJSON: () => _value,\n\n get raw() {\n return _value;\n },\n set raw(value: T) {\n _value = value;\n },\n\n get value() {\n return _value;\n },\n\n __update(next: any) {\n _value = next?.raw ?? next?.value ?? next;\n },\n\n ...additionalProps,\n };\n\n return node as unknown as IntlayerNode<T>;\n};\n"],"mappings":";;;AAuBA,MAAa,sBAEX,EACA,OACA,UACA,kBAAkB,CAAC,QAME;CACrB,IAAI,SAAS;CAKb,MAAM,kBACJ,OAAO,aAAa,YAAY,aAAa,OAAO,SAAS,EAAE,IAC3D,WACA;CA6BN,OAAO;EAzBL,WAAW,yBAAyB,KAAK;EAEzC,gBAAgB,mBAAmB,OAAO,UAAU,EAAE;EACtD,eAAe;GACd,OAAO,oBAAoB,mBAAmB;EAC/C,cAAc;EAEd,IAAI,MAAM;GACR,OAAO;EACT;EACA,IAAI,IAAI,OAAU;GAChB,SAAS;EACX;EAEA,IAAI,QAAQ;GACV,OAAO;EACT;EAEA,SAAS,MAAW;GAClB,SAAS,MAAM,OAAO,MAAM,SAAS;EACvC;EAEA,GAAG;CAGK;AACZ"}
1
+ {"version":3,"file":"renderIntlayerNode.mjs","names":[],"sources":["../../src/renderIntlayerNode.ts"],"sourcesContent":["import { getIntlayerNodePrototype } from '@intlayer/core/utils';\nimport type { ResolvedEditor } from '@intlayer/types/module_augmentation';\n\ntype IntlayerNodeMembers<T> = {\n raw: T;\n value: T;\n toString: () => string;\n valueOf: () => T;\n toJSON: () => T;\n __update: (next: IntlayerNode<T>) => void;\n};\n\n/**\n * Content node returned by `useIntlayer`.\n *\n * Without the editor it is typed as its value plus the node members, so it\n * can be used wherever a string is expected. With the editor, string coercion returns the editor wrapper HTML,\n * so string usages must go through `.value`.\n */\nexport type IntlayerNode<T = string> = ResolvedEditor<\n T & IntlayerNodeMembers<T>,\n IntlayerNodeMembers<T>\n>;\n\nexport const renderIntlayerNode = <\n T, // Broadened to support arrays, numbers, objects, etc.\n>({\n value,\n children,\n additionalProps = {},\n}: {\n value: T;\n children?: any;\n additionalProps?: Record<string, unknown>;\n [key: string]: unknown;\n}): IntlayerNode<T> => {\n let _value = value;\n\n // When children is a string that differs from value, it acts as a display\n // override (e.g. editor HTML wrapper). Otherwise toString/toPrimitive reflect\n // the live _value so that __update propagates.\n const displayOverride =\n typeof children === 'string' && children !== String(value ?? '')\n ? children\n : null;\n\n const node = {\n // Serves the value's members: `node.toUpperCase()`, `'trim' in node`\n __proto__: getIntlayerNodePrototype(value),\n\n toString: () => displayOverride ?? String(_value ?? ''),\n valueOf: () => _value,\n [Symbol.toPrimitive]: () => displayOverride ?? _value,\n toJSON: () => _value,\n\n get raw() {\n return _value;\n },\n set raw(value: T) {\n _value = value;\n },\n\n get value() {\n return _value;\n },\n\n __update(next: any) {\n _value = next?.raw ?? next?.value ?? next;\n },\n\n ...additionalProps,\n };\n\n return node as unknown as IntlayerNode<T>;\n};\n"],"mappings":";;;AAwBA,MAAa,sBAEX,EACA,OACA,UACA,kBAAkB,CAAC,QAME;CACrB,IAAI,SAAS;CAKb,MAAM,kBACJ,OAAO,aAAa,YAAY,aAAa,OAAO,SAAS,EAAE,IAC3D,WACA;CA6BN,OAAO;EAzBL,WAAW,yBAAyB,KAAK;EAEzC,gBAAgB,mBAAmB,OAAO,UAAU,EAAE;EACtD,eAAe;GACd,OAAO,oBAAoB,mBAAmB;EAC/C,cAAc;EAEd,IAAI,MAAM;GACR,OAAO;EACT;EACA,IAAI,IAAI,OAAU;GAChB,SAAS;EACX;EAEA,IAAI,QAAQ;GACV,OAAO;EACT;EAEA,SAAS,MAAW;GAClB,SAAS,MAAM,OAAO,MAAM,SAAS;EACvC;EAEA,GAAG;CAGK;AACZ"}
@@ -1 +1 @@
1
- {"version":3,"file":"plugins.d.ts","names":[],"sources":["../../src/plugins.ts"],"mappings":";;;;;;;;;;YA8CY,iBAAiB,KAAK,4BAC9B,aAAa;YAGL,aAAa,GAAG,UAAU,eAAiB,KAAK;qBAQ/C,qBAAqB;;;;YAiDtB,cAAc,GAAG,IAAI,UAAU,iBAAiB;EAC1D,UAAU;GACT,UAAU,kBAAkB;EAC7B,wBAAwB;KAErB,aAAa,KAAK,QAAQ,iCACzB,QAAQ,MACL,mBAAmB,uBAAuB,qBAAqB,GAAG;qBAG9D,iBAAiB;YAiHlB,mBAAmB,KAAK,mBAChC;EAGI,UAAU;;EAEV,MAAM,aAAa;;qBAKd,sBAAsB;YAuEvB,aAAa,KAAK;EAC5B,UAAU;GACT,UAAU,iBAAiB;EAC5B,iBAAiB;EACjB,aAAa;;EA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D,qBAAqB,iBAAiB;EACtC,kBAAkB,cAAc,GAAG,GAAG;EACtC,iBAAiB,aAAa;EAC9B,aAAa,eAAe;;;;;;;;;YAUlB,0BAA0B,KACpC;EAGA;EACA;EACA;EACA;;YAGU,qBACV,GACA,UAAU,gBAAgB,mBACxB,uBAAyB,GAAG,yBAAyB;;;;;qBAQ5C,aAAU,SACZ,eAAa,uBAErB"}
@@ -1,20 +1,21 @@
1
1
  import { ResolvedEditor } from "@intlayer/types/module_augmentation";
2
2
  //#region src/renderIntlayerNode.d.ts
3
- export type IntlayerNode<T = string> = ResolvedEditor<T & {
3
+ type IntlayerNodeMembers<T> = {
4
4
  raw: T;
5
5
  value: T;
6
6
  toString: () => string;
7
7
  valueOf: () => T;
8
8
  toJSON: () => T;
9
9
  __update: (next: IntlayerNode<T>) => void;
10
- }, {
11
- raw: T;
12
- value: T;
13
- toString: () => string;
14
- valueOf: () => T;
15
- toJSON: () => T;
16
- __update: (next: IntlayerNode<T>) => void;
17
- }> & T;
10
+ };
11
+ /**
12
+ * Content node returned by `useIntlayer`.
13
+ *
14
+ * Without the editor it is typed as its value plus the node members, so it
15
+ * can be used wherever a string is expected. With the editor, string coercion returns the editor wrapper HTML,
16
+ * so string usages must go through `.value`.
17
+ */
18
+ export type IntlayerNode<T = string> = ResolvedEditor<T & IntlayerNodeMembers<T>, IntlayerNodeMembers<T>>;
18
19
  export declare const renderIntlayerNode: <T>({ value, children, additionalProps }: {
19
20
  value: T;
20
21
  children?: any;
@@ -1 +1 @@
1
- {"version":3,"file":"renderIntlayerNode.d.ts","names":[],"sources":["../../src/renderIntlayerNode.ts"],"mappings":";;YAGY,aAAa,cAAc,eACrC;EACE,KAAK;EACL,OAAO;EACP;EACA,eAAe;EACf,cAAc;EACd,WAAW,MAAM,aAAa;;EAG9B,KAAK;EACL,OAAO;EACP;EACA,eAAe;EACf,cAAc;EACd,WAAW,MAAM,aAAa;KAGhC;qBAEW,qBACX,KAAC,OAAA,UAAA;EAMD,OAAO;EACP;EACA,kBAAkB;GACjB;MACC,aAAa"}
1
+ {"version":3,"file":"renderIntlayerNode.d.ts","names":[],"sources":["../../src/renderIntlayerNode.ts"],"mappings":";;KAGK,oBAAoB;EACvB,KAAK;EACL,OAAO;EACP;EACA,eAAe;EACf,cAAc;EACd,WAAW,MAAM,aAAa;;;;;;;;;YAUpB,aAAa,cAAc,eACrC,IAAI,oBAAoB,IACxB,oBAAoB;qBAGT,qBACX,KAAC,OAAA,UAAA;EAMD,OAAO;EACP;EACA,kBAAkB;GACjB;MACC,aAAa"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vanilla-intlayer",
3
- "version": "9.5.10",
3
+ "version": "9.5.12",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your Vanilla JS, HTML, and PHP applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -102,11 +102,11 @@
102
102
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
103
103
  },
104
104
  "dependencies": {
105
- "@intlayer/api": "9.5.10",
106
- "@intlayer/config": "9.5.10",
107
- "@intlayer/core": "9.5.10",
108
- "@intlayer/editor": "9.5.10",
109
- "@intlayer/types": "9.5.10"
105
+ "@intlayer/api": "9.5.12",
106
+ "@intlayer/config": "9.5.12",
107
+ "@intlayer/core": "9.5.12",
108
+ "@intlayer/editor": "9.5.12",
109
+ "@intlayer/types": "9.5.12"
110
110
  },
111
111
  "devDependencies": {
112
112
  "@types/node": "^22",
@@ -119,7 +119,7 @@
119
119
  "vitest": "5.0.2"
120
120
  },
121
121
  "peerDependencies": {
122
- "intlayer": "9.5.10"
122
+ "intlayer": "9.5.12"
123
123
  },
124
124
  "peerDependenciesMeta": {
125
125
  "intlayer": {