vanilla-intlayer 8.11.1 → 8.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/client/installIntlayer.cjs +0 -1
- package/dist/cjs/client/installIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +0 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs +0 -1
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocaleStorage.cjs +0 -1
- package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
- package/dist/cjs/client/useRewriteURL.cjs +0 -1
- package/dist/cjs/client/useRewriteURL.cjs.map +1 -1
- package/dist/cjs/editor/useEditor.cjs +0 -1
- package/dist/cjs/editor/useEditor.cjs.map +1 -1
- package/dist/cjs/format/useCompact.cjs +0 -1
- package/dist/cjs/format/useCompact.cjs.map +1 -1
- package/dist/cjs/format/useCurrency.cjs +0 -1
- package/dist/cjs/format/useCurrency.cjs.map +1 -1
- package/dist/cjs/format/useDate.cjs +0 -1
- package/dist/cjs/format/useDate.cjs.map +1 -1
- package/dist/cjs/format/useIntl.cjs +0 -1
- package/dist/cjs/format/useIntl.cjs.map +1 -1
- package/dist/cjs/format/useList.cjs +0 -1
- package/dist/cjs/format/useList.cjs.map +1 -1
- package/dist/cjs/format/useNumber.cjs +0 -1
- package/dist/cjs/format/useNumber.cjs.map +1 -1
- package/dist/cjs/format/usePercentage.cjs +0 -1
- package/dist/cjs/format/usePercentage.cjs.map +1 -1
- package/dist/cjs/format/useRelativeTime.cjs +0 -1
- package/dist/cjs/format/useRelativeTime.cjs.map +1 -1
- package/dist/cjs/format/useUnit.cjs +0 -1
- package/dist/cjs/format/useUnit.cjs.map +1 -1
- package/dist/cjs/getDictionary.cjs +0 -1
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs +0 -1
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
- package/dist/cjs/markdown/compiler.cjs +22 -15
- package/dist/cjs/markdown/compiler.cjs.map +1 -1
- package/dist/cjs/markdown/index.cjs +9 -0
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -1
- package/dist/esm/client/useDictionary.mjs.map +1 -1
- package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
- package/dist/esm/client/useIntlayer.mjs.map +1 -1
- package/dist/esm/getDictionary.mjs.map +1 -1
- package/dist/esm/getIntlayer.mjs.map +1 -1
- package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -1
- package/dist/esm/markdown/compiler.mjs +23 -16
- package/dist/esm/markdown/compiler.mjs.map +1 -1
- package/dist/esm/markdown/index.mjs +2 -1
- package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -1
- package/dist/types/client/useDictionary.d.ts +1 -1
- package/dist/types/client/useDictionary.d.ts.map +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts +1 -1
- package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
- package/dist/types/client/useIntlayer.d.ts +1 -1
- package/dist/types/client/useIntlayer.d.ts.map +1 -1
- package/dist/types/getDictionary.d.ts +1 -1
- package/dist/types/getDictionary.d.ts.map +1 -1
- package/dist/types/getIntlayer.d.ts +1 -1
- package/dist/types/getIntlayer.d.ts.map +1 -1
- package/dist/types/markdown/MarkdownRenderer.d.ts +3 -2
- package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -1
- package/dist/types/markdown/compiler.d.ts +6 -18
- package/dist/types/markdown/compiler.d.ts.map +1 -1
- package/dist/types/markdown/index.d.ts +2 -1
- package/dist/types/markdown/installIntlayerMarkdown.d.ts +2 -1
- package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_editor_useEditor = require('../editor/useEditor.cjs');
|
|
4
3
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
5
4
|
let _intlayer_config_client = require("@intlayer/config/client");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installIntlayer.cjs","names":["internationalization"],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport { setIntlayerIdentifier } from '@intlayer/config/client';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useEditor } from '../editor/useEditor';\n\ntype LocaleListener = (locale: LocalesValues) => void;\n\nexport class IntlayerClient {\n private _locale: LocalesValues;\n private _listeners: Set<LocaleListener> = new Set();\n isCookieEnabled: boolean;\n\n constructor(locale?: LocalesValues, isCookieEnabled = true) {\n const { defaultLocale } = internationalization ?? {};\n\n setIntlayerIdentifier();\n\n this._locale =\n (locale as LocalesValues) ?? (defaultLocale as LocalesValues);\n this.isCookieEnabled = isCookieEnabled;\n }\n\n get locale(): LocalesValues {\n return this._locale;\n }\n\n setLocale(newLocale: LocalesValues): void {\n this._locale = newLocale;\n for (const listener of this._listeners) {\n listener(newLocale);\n }\n }\n\n subscribe(listener: LocaleListener): () => void {\n this._listeners.add(listener);\n return () => {\n this._listeners.delete(listener);\n };\n }\n\n /**\n * Fire all listeners with the current locale without changing it.\n * Used to trigger re-renders after async data loads.\n */\n notify(): void {\n for (const listener of this._listeners) {\n listener(this._locale);\n }\n }\n}\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerClient | null = null;\n\n/**\n * Create and return a single IntlayerClient instance.\n */\nexport const createIntlayerClient = (\n locale?: LocalesValues,\n isCookieEnabled = true\n): IntlayerClient => {\n if (instance) return instance;\n\n instance = new IntlayerClient(locale, isCookieEnabled);\n return instance;\n};\n\n/**\n * Get the current IntlayerClient instance, creating one with defaults if needed.\n */\nexport const getIntlayerClient = (): IntlayerClient => {\n if (!instance) {\n instance = new IntlayerClient();\n }\n return instance;\n};\n\n/**\n * Install Intlayer into your vanilla JS application.\n *\n * Call this once at application startup, before any Intlayer APIs are used.\n *\n * When called with a `config` argument, `window.INTLAYER_CONFIG` is set so\n * that `@intlayer/config/built` resolves the correct values in the browser\n * without requiring module aliasing in the bundler configuration.\n *\n * @param locale - Initial locale (defaults to config defaultLocale).\n * @param isCookieEnabled - Whether to persist locale in cookies/localStorage.\n * @param config - Optional Intlayer configuration. When provided, sets\n * `window.INTLAYER_CONFIG` with the browser-safe subset of the config so\n * the application works without a Vite/webpack plugin alias.\n * @returns The IntlayerClient singleton.\n *\n * @example\n * ```ts\n * import { installIntlayer } from 'vanilla-intlayer';\n *\n * // With explicit config (no build plugin alias needed):\n * installIntlayer('en', true, {\n * internationalization: { locales: ['en', 'fr'], defaultLocale: 'en' },\n * });\n *\n * // With build plugin (alias handles config automatically):\n * installIntlayer('en');\n * ```\n */\nexport const installIntlayer = ({\n locale,\n isCookieEnabled,\n}: {\n locale?: LocalesValues;\n isCookieEnabled?: boolean;\n} = {}): IntlayerClient => {\n const client = createIntlayerClient(locale, isCookieEnabled);\n\n useEditor();\n\n return client;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"installIntlayer.cjs","names":["internationalization"],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport { setIntlayerIdentifier } from '@intlayer/config/client';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useEditor } from '../editor/useEditor';\n\ntype LocaleListener = (locale: LocalesValues) => void;\n\nexport class IntlayerClient {\n private _locale: LocalesValues;\n private _listeners: Set<LocaleListener> = new Set();\n isCookieEnabled: boolean;\n\n constructor(locale?: LocalesValues, isCookieEnabled = true) {\n const { defaultLocale } = internationalization ?? {};\n\n setIntlayerIdentifier();\n\n this._locale =\n (locale as LocalesValues) ?? (defaultLocale as LocalesValues);\n this.isCookieEnabled = isCookieEnabled;\n }\n\n get locale(): LocalesValues {\n return this._locale;\n }\n\n setLocale(newLocale: LocalesValues): void {\n this._locale = newLocale;\n for (const listener of this._listeners) {\n listener(newLocale);\n }\n }\n\n subscribe(listener: LocaleListener): () => void {\n this._listeners.add(listener);\n return () => {\n this._listeners.delete(listener);\n };\n }\n\n /**\n * Fire all listeners with the current locale without changing it.\n * Used to trigger re-renders after async data loads.\n */\n notify(): void {\n for (const listener of this._listeners) {\n listener(this._locale);\n }\n }\n}\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerClient | null = null;\n\n/**\n * Create and return a single IntlayerClient instance.\n */\nexport const createIntlayerClient = (\n locale?: LocalesValues,\n isCookieEnabled = true\n): IntlayerClient => {\n if (instance) return instance;\n\n instance = new IntlayerClient(locale, isCookieEnabled);\n return instance;\n};\n\n/**\n * Get the current IntlayerClient instance, creating one with defaults if needed.\n */\nexport const getIntlayerClient = (): IntlayerClient => {\n if (!instance) {\n instance = new IntlayerClient();\n }\n return instance;\n};\n\n/**\n * Install Intlayer into your vanilla JS application.\n *\n * Call this once at application startup, before any Intlayer APIs are used.\n *\n * When called with a `config` argument, `window.INTLAYER_CONFIG` is set so\n * that `@intlayer/config/built` resolves the correct values in the browser\n * without requiring module aliasing in the bundler configuration.\n *\n * @param locale - Initial locale (defaults to config defaultLocale).\n * @param isCookieEnabled - Whether to persist locale in cookies/localStorage.\n * @param config - Optional Intlayer configuration. When provided, sets\n * `window.INTLAYER_CONFIG` with the browser-safe subset of the config so\n * the application works without a Vite/webpack plugin alias.\n * @returns The IntlayerClient singleton.\n *\n * @example\n * ```ts\n * import { installIntlayer } from 'vanilla-intlayer';\n *\n * // With explicit config (no build plugin alias needed):\n * installIntlayer('en', true, {\n * internationalization: { locales: ['en', 'fr'], defaultLocale: 'en' },\n * });\n *\n * // With build plugin (alias handles config automatically):\n * installIntlayer('en');\n * ```\n */\nexport const installIntlayer = ({\n locale,\n isCookieEnabled,\n}: {\n locale?: LocalesValues;\n isCookieEnabled?: boolean;\n} = {}): IntlayerClient => {\n const client = createIntlayerClient(locale, isCookieEnabled);\n\n useEditor();\n\n return client;\n};\n"],"mappings":";;;;;;AAOA,IAAa,iBAAb,MAA4B;CAC1B,AAAQ;CACR,AAAQ,6BAAkC,IAAI,IAAI;CAClD;CAEA,YAAY,QAAwB,kBAAkB,MAAM;EAC1D,MAAM,EAAE,kBAAkBA,+CAAwB,CAAC;EAEnD,mDAAsB;EAEtB,KAAK,UACF,UAA6B;EAChC,KAAK,kBAAkB;CACzB;CAEA,IAAI,SAAwB;EAC1B,OAAO,KAAK;CACd;CAEA,UAAU,WAAgC;EACxC,KAAK,UAAU;EACf,KAAK,MAAM,YAAY,KAAK,YAC1B,SAAS,SAAS;CAEtB;CAEA,UAAU,UAAsC;EAC9C,KAAK,WAAW,IAAI,QAAQ;EAC5B,aAAa;GACX,KAAK,WAAW,OAAO,QAAQ;EACjC;CACF;;;;;CAMA,SAAe;EACb,KAAK,MAAM,YAAY,KAAK,YAC1B,SAAS,KAAK,OAAO;CAEzB;AACF;;;;AAKA,IAAI,WAAkC;;;;AAKtC,MAAa,wBACX,QACA,kBAAkB,SACC;CACnB,IAAI,UAAU,OAAO;CAErB,WAAW,IAAI,eAAe,QAAQ,eAAe;CACrD,OAAO;AACT;;;;AAKA,MAAa,0BAA0C;CACrD,IAAI,CAAC,UACH,WAAW,IAAI,eAAe;CAEhC,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,MAAa,mBAAmB,EAC9B,QACA,oBAIE,CAAC,MAAsB;CACzB,MAAM,SAAS,qBAAqB,QAAQ,eAAe;CAE3D,mCAAU;CAEV,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.cjs","names":["getIntlayerClient","getDictionary"],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport type { DeepTransformContent } from '../plugins';\nimport { getIntlayerClient } from './installIntlayer';\n\nexport type WithOnChange<T> = T & {\n /**\n * Subscribe to locale changes. The callback receives the fresh content\n * whenever the active locale changes. Returns the content object itself\n * for convenient one-liner patterns:\n *\n * ```ts\n * const content = useDictionary(myDict).onChange((c) => {\n * document.querySelector('p')!.textContent = String(c.greeting);\n * });\n * ```\n */\n onChange: (\n callback: <T extends Dictionary, L extends LocalesValues>(\n content: DeepTransformContent<T['content'], L>\n ) => void\n ) => WithOnChange<T>;\n};\n\n/**\n * Get the translated content for a raw dictionary object and optionally\n * subscribe to locale changes via the chainable `.onChange()` method —\n * mirroring the API of `react-intlayer`.\n *\n * Unlike `useIntlayer` (which takes a registered key), this function accepts a\n * dictionary object directly — useful for dictionaries loaded asynchronously\n * or defined inline.\n *\n * The function returns the current content **directly** (same shape as\n * `getDictionary(dict)`), plus the `.onChange()` helper:\n *\n * ```ts\n * // React\n * const content = useDictionary(myDict);\n *\n * // Vanilla — identical surface API, opt-in reactivity via .onChange()\n * const content = useDictionary(myDict);\n * const content = useDictionary(myDict).onChange((c) => render(c));\n * ```\n *\n * @param dictionary - The raw dictionary object.\n * @param locale - Optional locale override.\n * @returns The current translated content with an `.onChange()` method.\n *\n * @example\n * ```ts\n * import myDict from './myDictionary.content';\n * import { installIntlayer, useDictionary } from 'vanilla-intlayer';\n *\n * installIntlayer();\n *\n * const content = useDictionary(myDict).onChange((c) => {\n * document.querySelector('p').textContent = String(c.greeting);\n * });\n *\n * document.querySelector('p').textContent = String(content.greeting);\n * ```\n */\nexport const useDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n): WithOnChange<DeepTransformContent<T['content'], L>> => {\n const client = getIntlayerClient();\n const content = getDictionary(\n dictionary,\n (locale ?? client.locale) as L\n ) as WithOnChange<DeepTransformContent<T['content'], L>>;\n\n content.onChange = (\n callback: (content: DeepTransformContent<T['content'], L>) => void\n ) => {\n client.subscribe((newLocale) => {\n callback(getDictionary(dictionary, (locale ?? newLocale) as L));\n });\n return content;\n };\n\n return content;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,MAAa,iBAIX,YACA,WACwD;CACxD,MAAM,SAASA,iDAAkB;CACjC,MAAM,UAAUC,oCACd,YACC,UAAU,OAAO,MACpB;CAEA,QAAQ,YACN,aACG;EACH,OAAO,WAAW,cAAc;GAC9B,SAASA,oCAAc,YAAa,UAAU,SAAe,CAAC;EAChE,CAAC;EACD,OAAO;CACT;CAEA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"useDictionary.cjs","names":["getIntlayerClient","getDictionary"],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport type { DeepTransformContent } from '../plugins';\nimport { getIntlayerClient } from './installIntlayer';\n\nexport type WithOnChange<T> = T & {\n /**\n * Subscribe to locale changes. The callback receives the fresh content\n * whenever the active locale changes. Returns the content object itself\n * for convenient one-liner patterns:\n *\n * ```ts\n * const content = useDictionary(myDict).onChange((c) => {\n * document.querySelector('p')!.textContent = String(c.greeting);\n * });\n * ```\n */\n onChange: (\n callback: <T extends Dictionary, L extends LocalesValues>(\n content: DeepTransformContent<T['content'], L>\n ) => void\n ) => WithOnChange<T>;\n};\n\n/**\n * Get the translated content for a raw dictionary object and optionally\n * subscribe to locale changes via the chainable `.onChange()` method —\n * mirroring the API of `react-intlayer`.\n *\n * Unlike `useIntlayer` (which takes a registered key), this function accepts a\n * dictionary object directly — useful for dictionaries loaded asynchronously\n * or defined inline.\n *\n * The function returns the current content **directly** (same shape as\n * `getDictionary(dict)`), plus the `.onChange()` helper:\n *\n * ```ts\n * // React\n * const content = useDictionary(myDict);\n *\n * // Vanilla — identical surface API, opt-in reactivity via .onChange()\n * const content = useDictionary(myDict);\n * const content = useDictionary(myDict).onChange((c) => render(c));\n * ```\n *\n * @param dictionary - The raw dictionary object.\n * @param locale - Optional locale override.\n * @returns The current translated content with an `.onChange()` method.\n *\n * @example\n * ```ts\n * import myDict from './myDictionary.content';\n * import { installIntlayer, useDictionary } from 'vanilla-intlayer';\n *\n * installIntlayer();\n *\n * const content = useDictionary(myDict).onChange((c) => {\n * document.querySelector('p').textContent = String(c.greeting);\n * });\n *\n * document.querySelector('p').textContent = String(content.greeting);\n * ```\n */\nexport const useDictionary = <\n const T extends Dictionary,\n const L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n): WithOnChange<DeepTransformContent<T['content'], L>> => {\n const client = getIntlayerClient();\n const content = getDictionary(\n dictionary,\n (locale ?? client.locale) as L\n ) as WithOnChange<DeepTransformContent<T['content'], L>>;\n\n content.onChange = (\n callback: (content: DeepTransformContent<T['content'], L>) => void\n ) => {\n client.subscribe((newLocale) => {\n callback(getDictionary(dictionary, (locale ?? newLocale) as L));\n });\n return content;\n };\n\n return content;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,MAAa,iBAIX,YACA,WACwD;CACxD,MAAM,SAASA,iDAAkB;CACjC,MAAM,UAAUC,oCACd,YACC,UAAU,OAAO,MACpB;CAEA,QAAQ,YACN,aACG;EACH,OAAO,WAAW,cAAc;GAC9B,SAASA,oCAAc,YAAa,UAAU,SAAe,CAAC;EAChE,CAAC;EACD,OAAO;CACT;CAEA,OAAO;AACT"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_getDictionary = require('../getDictionary.cjs');
|
|
4
3
|
const require_client_installIntlayer = require('./installIntlayer.cjs');
|
|
5
4
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.cjs","names":["getIntlayerClient","internationalization","getDictionary"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\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\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/**\n * Dynamically load and transform a locale-keyed dictionary.\n *\n * Works like `useIntlayer` / `useDictionary` but accepts a locale-keyed map\n * of lazy loaders instead of a pre-imported dictionary. Call it inside your\n * render function — the first call triggers a background fetch and returns\n * placeholder values; when the load completes the client notifies all\n * subscribers (including your render loop) so the render runs again with real\n * content. Subsequent calls for the same locale return immediately from cache.\n *\n * Locale switches follow the same two-phase pattern: placeholder on first\n * render, real content after the locale bundle loads.\n *\n * @param dictionaryLoaders - Locale-keyed map of `() => Promise<Dictionary>`.\n * @param key - Dictionary key (used for cache namespacing).\n * @param locale - Optional locale override.\n *\n * @example\n * ```ts\n * import dynDic from '../.intlayer/dynamic_dictionary/app.mjs';\n *\n * const render = () => {\n * const content = useDictionaryDynamic(dynDic, 'app');\n * document.querySelector('h1')!.textContent = String(content.title);\n * };\n *\n * render();\n * getIntlayerClient().subscribe(() => render());\n * ```\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n L extends LocalesValues = LocalesValues,\n>(\n dictionaryLoaders: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: L\n): WithOnChange<DeepTransformContent<T['content'], L>> => {\n const client = getIntlayerClient();\n const currentLocale = (locale ??\n client.locale ??\n internationalization.defaultLocale) as L;\n\n const cacheKey = `${String(key)}.${currentLocale}`;\n const loader = (dictionaryLoaders as Record<string, () => Promise<T>>)[\n currentLocale\n ];\n\n // --- Cache hit: return real content synchronously ---\n const cached = cache.get(cacheKey);\n if (cached) {\n const content = getDictionary(cached as T, currentLocale) as WithOnChange<\n DeepTransformContent<T['content'], L>\n >;\n\n content.onChange = (\n callback: (content: DeepTransformContent<T['content'], L>) => void\n ) => {\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(\n getDictionary(dict as T, newLocale as L) as DeepTransformContent<\n T['content'],\n L\n >\n );\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 // Placeholder proxy — safe for any property access while loading.\n const 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 return recursiveProxy as WithOnChange<DeepTransformContent<T['content'], L>>;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.cjs","names":["getIntlayerClient","internationalization","getDictionary"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\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\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/**\n * Dynamically load and transform a locale-keyed dictionary.\n *\n * Works like `useIntlayer` / `useDictionary` but accepts a locale-keyed map\n * of lazy loaders instead of a pre-imported dictionary. Call it inside your\n * render function — the first call triggers a background fetch and returns\n * placeholder values; when the load completes the client notifies all\n * subscribers (including your render loop) so the render runs again with real\n * content. Subsequent calls for the same locale return immediately from cache.\n *\n * Locale switches follow the same two-phase pattern: placeholder on first\n * render, real content after the locale bundle loads.\n *\n * @param dictionaryLoaders - Locale-keyed map of `() => Promise<Dictionary>`.\n * @param key - Dictionary key (used for cache namespacing).\n * @param locale - Optional locale override.\n *\n * @example\n * ```ts\n * import dynDic from '../.intlayer/dynamic_dictionary/app.mjs';\n *\n * const render = () => {\n * const content = useDictionaryDynamic(dynDic, 'app');\n * document.querySelector('h1')!.textContent = String(content.title);\n * };\n *\n * render();\n * getIntlayerClient().subscribe(() => render());\n * ```\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const K extends DictionaryKeys,\n const L extends LocalesValues = LocalesValues,\n>(\n dictionaryLoaders: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: L\n): WithOnChange<DeepTransformContent<T['content'], L>> => {\n const client = getIntlayerClient();\n const currentLocale = (locale ??\n client.locale ??\n internationalization.defaultLocale) as L;\n\n const cacheKey = `${String(key)}.${currentLocale}`;\n const loader = (dictionaryLoaders as Record<string, () => Promise<T>>)[\n currentLocale\n ];\n\n // --- Cache hit: return real content synchronously ---\n const cached = cache.get(cacheKey);\n if (cached) {\n const content = getDictionary(cached as T, currentLocale) as WithOnChange<\n DeepTransformContent<T['content'], L>\n >;\n\n content.onChange = (\n callback: (content: DeepTransformContent<T['content'], L>) => void\n ) => {\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(\n getDictionary(dict as T, newLocale as L) as DeepTransformContent<\n T['content'],\n L\n >\n );\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 // Placeholder proxy — safe for any property access while loading.\n const 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 return recursiveProxy as WithOnChange<DeepTransformContent<T['content'], L>>;\n};\n"],"mappings":";;;;;;;AAaA,MAAM,wBAAQ,IAAI,IAAwB;;AAG1C,MAAM,2BAAW,IAAI,IAA2B;AAEhD,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,EAAE,MAAM,eAAe;EAC5C,MAAM,IAAI,UAAU,UAAU;EAC9B,SAAS,OAAO,QAAQ;CAC1B,CAAC;CAED,SAAS,IAAI,UAAU,OAAO;CAC9B,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,wBAKX,mBACA,KACA,WACwD;CACxD,MAAM,SAASA,iDAAkB;CACjC,MAAM,gBAAiB,UACrB,OAAO,UACPC,4CAAqB;CAEvB,MAAM,WAAW,GAAG,OAAO,GAAG,EAAE,GAAG;CACnC,MAAM,SAAU,kBACd;CAIF,MAAM,SAAS,MAAM,IAAI,QAAQ;CACjC,IAAI,QAAQ;EACV,MAAM,UAAUC,oCAAc,QAAa,aAAa;EAIxD,QAAQ,YACN,aACG;GAEH,OAAO,WAAW,cAAc;IAC9B,MAAM,SAAS,GAAG,OAAO,GAAG,EAAE,GAAG;IACjC,MAAM,YACJ,kBACA;IAEF,IAAI,CAAC,WAAW;IAEhB,eAAe,QAAQ,SAAS,EAAE,WAAW;KAC3C,MAAM,OAAO,MAAM,IAAI,MAAM;KAC7B,IAAI,MACF,SACEA,oCAAc,MAAW,SAAc,CAIzC;IAEJ,CAAC;GACH,CAAC;GAED,OAAO;EACT;EAEA,OAAO;CACT;CAGA,IAAI,QACF,eAAe,UAAU,MAAM,EAAE,WAAW;EAC1C,OAAO,OAAO;CAChB,CAAC;CAIH,MAAM,iBAAsB,IAAI,YAAY,CAAC,GAAG;EAC9C,MAAM,IAAI,SAAS;GACjB,IAAI,SAAS,OAAO,aAAa,aAAa;GAC9C,IAAI,SAAS,YAAY,aAAa;GACtC,IAAI,SAAS,WAAW,aAAa;GACrC,IAAI,SAAS,QAAQ,OAAO;GAC5B,IAAI,SAAS,YAAY,QAAQ,QAAa;GAC9C,OAAO;EACT;EACA,aAAa;CACf,CAAC;CAED,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.cjs","names":["getIntlayerClient","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { getIntlayerClient } from './installIntlayer';\nimport type { WithOnChange } from './useDictionary';\n\n/**\n * Get the translated content for the given key and optionally subscribe to\n * locale changes via the chainable `.onChange()` method — mirroring the API\n * of `react-intlayer`'s `useIntlayer`.\n *\n * Unlike React (where the hook system automatically re-runs on re-render),\n * vanilla JS has no component lifecycle. The `.onChange()` callback is the\n * explicit equivalent: it is called with fresh content whenever the active\n * locale changes. Use it to patch your DOM or trigger a full re-render.\n *\n * The function returns the current content **directly** (same shape as\n * `getIntlayer(key)`), plus the `.onChange()` helper:\n *\n * ```ts\n * // React\n * const content = useIntlayer('app');\n *\n * // Vanilla — identical surface API, opt-in reactivity via .onChange()\n * const content = useIntlayer('app');\n * const content = useIntlayer('app').onChange((c) => render(c));\n * ```\n *\n * For cleanup (e.g. Vite HMR), subscribe via `getIntlayerClient().subscribe()`\n * and hold the returned unsubscribe function.\n *\n * @param key - Dictionary key registered in your intlayer content files.\n * @param locale - Optional locale override (defaults to the current app locale).\n * @returns The current translated content with an `.onChange()` method.\n *\n * @example\n * ```ts\n * import { installIntlayer, useIntlayer } from 'vanilla-intlayer';\n *\n * installIntlayer();\n *\n * // Static read (no subscription)\n * const content = useIntlayer('homepage');\n * document.querySelector('h1').textContent = String(content.title);\n *\n * // Reactive read — onChange is called on every locale change\n * useIntlayer('homepage').onChange((c) => {\n * document.querySelector('h1').textContent = String(c.title);\n * });\n * ```\n */\nexport const useIntlayer = <T extends DictionaryKeys>(\n key: T,\n locale?: LocalesValues\n): WithOnChange<DeepTransformContent<DictionaryRegistryContent<T>>> => {\n const client = getIntlayerClient();\n const content = getIntlayer(key, locale ?? client.locale) as WithOnChange<\n DeepTransformContent<DictionaryRegistryContent<T>>\n >;\n\n content.onChange = (callback) => {\n client.subscribe((newLocale) => {\n callback(getIntlayer(key, (locale ?? newLocale) as typeof locale));\n });\n return content;\n };\n\n return content;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAa,eACX,KACA,WACqE;CACrE,MAAM,SAASA,iDAAkB;CACjC,MAAM,UAAUC,gCAAY,KAAK,UAAU,OAAO,MAAM;CAIxD,QAAQ,YAAY,aAAa;EAC/B,OAAO,WAAW,cAAc;GAC9B,SAASA,gCAAY,KAAM,UAAU,SAA2B,CAAC;EACnE,CAAC;EACD,OAAO;CACT;CAEA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"useIntlayer.cjs","names":["getIntlayerClient","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { getIntlayerClient } from './installIntlayer';\nimport type { WithOnChange } from './useDictionary';\n\n/**\n * Get the translated content for the given key and optionally subscribe to\n * locale changes via the chainable `.onChange()` method — mirroring the API\n * of `react-intlayer`'s `useIntlayer`.\n *\n * Unlike React (where the hook system automatically re-runs on re-render),\n * vanilla JS has no component lifecycle. The `.onChange()` callback is the\n * explicit equivalent: it is called with fresh content whenever the active\n * locale changes. Use it to patch your DOM or trigger a full re-render.\n *\n * The function returns the current content **directly** (same shape as\n * `getIntlayer(key)`), plus the `.onChange()` helper:\n *\n * ```ts\n * // React\n * const content = useIntlayer('app');\n *\n * // Vanilla — identical surface API, opt-in reactivity via .onChange()\n * const content = useIntlayer('app');\n * const content = useIntlayer('app').onChange((c) => render(c));\n * ```\n *\n * For cleanup (e.g. Vite HMR), subscribe via `getIntlayerClient().subscribe()`\n * and hold the returned unsubscribe function.\n *\n * @param key - Dictionary key registered in your intlayer content files.\n * @param locale - Optional locale override (defaults to the current app locale).\n * @returns The current translated content with an `.onChange()` method.\n *\n * @example\n * ```ts\n * import { installIntlayer, useIntlayer } from 'vanilla-intlayer';\n *\n * installIntlayer();\n *\n * // Static read (no subscription)\n * const content = useIntlayer('homepage');\n * document.querySelector('h1').textContent = String(content.title);\n *\n * // Reactive read — onChange is called on every locale change\n * useIntlayer('homepage').onChange((c) => {\n * document.querySelector('h1').textContent = String(c.title);\n * });\n * ```\n */\nexport const useIntlayer = <const T extends DictionaryKeys>(\n key: T,\n locale?: LocalesValues\n): WithOnChange<DeepTransformContent<DictionaryRegistryContent<T>>> => {\n const client = getIntlayerClient();\n const content = getIntlayer(key, locale ?? client.locale) as WithOnChange<\n DeepTransformContent<DictionaryRegistryContent<T>>\n >;\n\n content.onChange = (callback) => {\n client.subscribe((newLocale) => {\n callback(getIntlayer(key, (locale ?? newLocale) as typeof locale));\n });\n return content;\n };\n\n return content;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAa,eACX,KACA,WACqE;CACrE,MAAM,SAASA,iDAAkB;CACjC,MAAM,UAAUC,gCAAY,KAAK,UAAU,OAAO,MAAM;CAIxD,QAAQ,YAAY,aAAa;EAC/B,OAAO,WAAW,cAAc;GAC9B,SAASA,gCAAY,KAAM,UAAU,SAA2B,CAAC;EACnE,CAAC;EACD,OAAO;CACT;CAEA,OAAO;AACT"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_client_installIntlayer = require('./installIntlayer.cjs');
|
|
4
3
|
const require_client_useLocaleStorage = require('./useLocaleStorage.cjs');
|
|
5
4
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.cjs","names":["getIntlayerClient","internationalization"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayerClient } from './installIntlayer';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\nexport type UseLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: DeclaredLocales) => void;\n};\n\nexport type UseLocaleResult = {\n locale: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n setLocale: (locale: LocalesValues) => void;\n subscribe: (callback: (locale: LocalesValues) => void) => () => void;\n};\n\n/**\n * Get the current locale state and locale management utilities.\n *\n * Returns a plain object with the current `locale`, `defaultLocale`,\n * `availableLocales`, a `setLocale` function, and a `subscribe` function\n * to react to locale changes.\n *\n * @param props - Optional configuration.\n * @returns Locale state and management utilities.\n *\n * @example\n * ```ts\n * import { installIntlayer, useLocale } from 'vanilla-intlayer';\n *\n * installIntlayer('en');\n *\n * const { locale, availableLocales, setLocale, subscribe } = useLocale();\n *\n * const unsubscribe = subscribe((newLocale) => {\n * console.log('Locale changed to', newLocale);\n * });\n *\n * document.querySelector('#lang-switcher').addEventListener('change', (e) => {\n * setLocale(e.target.value);\n * });\n * ```\n */\nexport const useLocale = (props: UseLocaleProps = {}): UseLocaleResult => {\n const client = getIntlayerClient();\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n\n const setLocale = (newLocale: LocalesValues): void => {\n if (!(availableLocales ?? []).map(String).includes(newLocale)) {\n console.error(`Locale \"${newLocale}\" is not available.`);\n return;\n }\n\n client.setLocale(newLocale);\n\n setLocaleInStorage(\n newLocale,\n props.isCookieEnabled ?? client.isCookieEnabled ?? true\n );\n\n props.onLocaleChange?.(newLocale as DeclaredLocales);\n };\n\n return {\n locale: client.locale as DeclaredLocales,\n defaultLocale: defaultLocale as DeclaredLocales,\n availableLocales: (availableLocales ?? []) as DeclaredLocales[],\n setLocale,\n subscribe: (callback) => client.subscribe(callback),\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocale.cjs","names":["getIntlayerClient","internationalization"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayerClient } from './installIntlayer';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\nexport type UseLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: DeclaredLocales) => void;\n};\n\nexport type UseLocaleResult = {\n locale: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n setLocale: (locale: LocalesValues) => void;\n subscribe: (callback: (locale: LocalesValues) => void) => () => void;\n};\n\n/**\n * Get the current locale state and locale management utilities.\n *\n * Returns a plain object with the current `locale`, `defaultLocale`,\n * `availableLocales`, a `setLocale` function, and a `subscribe` function\n * to react to locale changes.\n *\n * @param props - Optional configuration.\n * @returns Locale state and management utilities.\n *\n * @example\n * ```ts\n * import { installIntlayer, useLocale } from 'vanilla-intlayer';\n *\n * installIntlayer('en');\n *\n * const { locale, availableLocales, setLocale, subscribe } = useLocale();\n *\n * const unsubscribe = subscribe((newLocale) => {\n * console.log('Locale changed to', newLocale);\n * });\n *\n * document.querySelector('#lang-switcher').addEventListener('change', (e) => {\n * setLocale(e.target.value);\n * });\n * ```\n */\nexport const useLocale = (props: UseLocaleProps = {}): UseLocaleResult => {\n const client = getIntlayerClient();\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n\n const setLocale = (newLocale: LocalesValues): void => {\n if (!(availableLocales ?? []).map(String).includes(newLocale)) {\n console.error(`Locale \"${newLocale}\" is not available.`);\n return;\n }\n\n client.setLocale(newLocale);\n\n setLocaleInStorage(\n newLocale,\n props.isCookieEnabled ?? client.isCookieEnabled ?? true\n );\n\n props.onLocaleChange?.(newLocale as DeclaredLocales);\n };\n\n return {\n locale: client.locale as DeclaredLocales,\n defaultLocale: defaultLocale as DeclaredLocales,\n availableLocales: (availableLocales ?? []) as DeclaredLocales[],\n setLocale,\n subscribe: (callback) => client.subscribe(callback),\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAa,aAAa,QAAwB,CAAC,MAAuB;CACxE,MAAM,SAASA,iDAAkB;CACjC,MAAM,EAAE,eAAe,SAAS,qBAC9BC,+CAAwB,CAAC;CAE3B,MAAM,aAAa,cAAmC;EACpD,IAAI,EAAE,oBAAoB,CAAC,GAAG,IAAI,MAAM,EAAE,SAAS,SAAS,GAAG;GAC7D,QAAQ,MAAM,WAAW,UAAU,oBAAoB;GACvD;EACF;EAEA,OAAO,UAAU,SAAS;EAE1B,mDACE,WACA,MAAM,mBAAmB,OAAO,mBAAmB,IACrD;EAEA,MAAM,iBAAiB,SAA4B;CACrD;CAEA,OAAO;EACL,QAAQ,OAAO;EACA;EACf,kBAAmB,oBAAoB,CAAC;EACxC;EACA,YAAY,aAAa,OAAO,UAAU,QAAQ;CACpD;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleStorage.cjs","names":["localeStorageOptions"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import {\n getLocaleFromStorageClient,\n LocaleStorageClient,\n localeStorageOptions,\n setLocaleInStorageClient as setLocaleInStorageCore,\n} from '@intlayer/core/utils';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\n/**\n * Get the current locale from storage (cookie or localStorage).\n */\nexport const localeInStorage = getLocaleFromStorageClient(localeStorageOptions);\n\n/**\n * @deprecated Use localeInStorage instead.\n */\nexport const localeCookie = localeInStorage;\n\n/**\n * Persist the locale to storage (cookie and/or localStorage).\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n isCookieEnabled: boolean\n) =>\n setLocaleInStorageCore(locale, {\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n/**\n * @deprecated Use setLocaleInStorage instead.\n */\nexport const setLocaleCookie = setLocaleInStorage;\n\n/**\n * Returns the current locale from storage and a setter.\n */\nexport const useLocaleStorage = (isCookieEnabled?: boolean) => {\n const storage = LocaleStorageClient({\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n return {\n localeStorage: storage.getLocale(),\n setLocaleStorage: storage.setLocale,\n };\n};\n\n/**\n * @deprecated Use useLocaleStorage instead.\n */\nexport const useLocaleCookie = useLocaleStorage;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocaleStorage.cjs","names":["localeStorageOptions"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import {\n getLocaleFromStorageClient,\n LocaleStorageClient,\n localeStorageOptions,\n setLocaleInStorageClient as setLocaleInStorageCore,\n} from '@intlayer/core/utils';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\n/**\n * Get the current locale from storage (cookie or localStorage).\n */\nexport const localeInStorage = getLocaleFromStorageClient(localeStorageOptions);\n\n/**\n * @deprecated Use localeInStorage instead.\n */\nexport const localeCookie = localeInStorage;\n\n/**\n * Persist the locale to storage (cookie and/or localStorage).\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n isCookieEnabled: boolean\n) =>\n setLocaleInStorageCore(locale, {\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n/**\n * @deprecated Use setLocaleInStorage instead.\n */\nexport const setLocaleCookie = setLocaleInStorage;\n\n/**\n * Returns the current locale from storage and a setter.\n */\nexport const useLocaleStorage = (isCookieEnabled?: boolean) => {\n const storage = LocaleStorageClient({\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n return {\n localeStorage: storage.getLocale(),\n setLocaleStorage: storage.setLocale,\n };\n};\n\n/**\n * @deprecated Use useLocaleStorage instead.\n */\nexport const useLocaleCookie = useLocaleStorage;\n"],"mappings":";;;;;;;AAWA,MAAa,uEAA6CA,yCAAoB;;;;AAK9E,MAAa,eAAe;;;;AAK5B,MAAa,sBACX,QACA,uEAEuB,QAAQ;CAC7B,GAAGA;CACH;AACF,CAAC;;;;AAKH,MAAa,kBAAkB;;;;AAK/B,MAAa,oBAAoB,oBAA8B;CAC7D,MAAM,wDAA8B;EAClC,GAAGA;EACH;CACF,CAAC;CAED,OAAO;EACL,eAAe,QAAQ,UAAU;EACjC,kBAAkB,QAAQ;CAC5B;AACF;;;;AAKA,MAAa,kBAAkB"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_client_installIntlayer = require('./installIntlayer.cjs');
|
|
4
3
|
let _intlayer_config_built = require("@intlayer/config/built");
|
|
5
4
|
let _intlayer_core_localization = require("@intlayer/core/localization");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRewriteURL.cjs","names":["routing","getIntlayerClient"],"sources":["../../../src/client/useRewriteURL.ts"],"sourcesContent":["import { routing } from '@intlayer/config/built';\nimport { getRewritePath } from '@intlayer/core/localization';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { getIntlayerClient } from './installIntlayer';\n\nconst rewrite = (locale: string): void => {\n if (typeof window === 'undefined' || !routing?.rewrite) return;\n\n const pathname = window.location.pathname;\n const targetPath = getRewritePath(\n pathname,\n locale as Locale,\n routing?.rewrite\n );\n\n if (targetPath && targetPath !== pathname) {\n window.history.replaceState(\n window.history.state,\n '',\n targetPath + window.location.search + window.location.hash\n );\n }\n};\n\n/**\n * Keep the browser URL in sync with the current locale.\n *\n * Rewrites the current URL immediately and subscribes to future locale changes.\n * Returns an `unsubscribe` function to stop listening.\n *\n * Uses `window.history.replaceState` — no full-page navigation.\n *\n * @returns A cleanup function that removes the locale change listener.\n *\n * @example\n * ```ts\n * import { installIntlayer, useRewriteURL } from 'vanilla-intlayer';\n *\n * installIntlayer('en');\n *\n * const unsubscribe = useRewriteURL();\n *\n * // Later, if you want to stop URL rewriting:\n * unsubscribe();\n * ```\n */\nexport const useRewriteURL = (): (() => void) => {\n const client = getIntlayerClient();\n\n // Rewrite immediately for the current locale\n rewrite(client.locale);\n\n return client.subscribe((newLocale) => {\n rewrite(newLocale);\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useRewriteURL.cjs","names":["routing","getIntlayerClient"],"sources":["../../../src/client/useRewriteURL.ts"],"sourcesContent":["import { routing } from '@intlayer/config/built';\nimport { getRewritePath } from '@intlayer/core/localization';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { getIntlayerClient } from './installIntlayer';\n\nconst rewrite = (locale: string): void => {\n if (typeof window === 'undefined' || !routing?.rewrite) return;\n\n const pathname = window.location.pathname;\n const targetPath = getRewritePath(\n pathname,\n locale as Locale,\n routing?.rewrite\n );\n\n if (targetPath && targetPath !== pathname) {\n window.history.replaceState(\n window.history.state,\n '',\n targetPath + window.location.search + window.location.hash\n );\n }\n};\n\n/**\n * Keep the browser URL in sync with the current locale.\n *\n * Rewrites the current URL immediately and subscribes to future locale changes.\n * Returns an `unsubscribe` function to stop listening.\n *\n * Uses `window.history.replaceState` — no full-page navigation.\n *\n * @returns A cleanup function that removes the locale change listener.\n *\n * @example\n * ```ts\n * import { installIntlayer, useRewriteURL } from 'vanilla-intlayer';\n *\n * installIntlayer('en');\n *\n * const unsubscribe = useRewriteURL();\n *\n * // Later, if you want to stop URL rewriting:\n * unsubscribe();\n * ```\n */\nexport const useRewriteURL = (): (() => void) => {\n const client = getIntlayerClient();\n\n // Rewrite immediately for the current locale\n rewrite(client.locale);\n\n return client.subscribe((newLocale) => {\n rewrite(newLocale);\n });\n};\n"],"mappings":";;;;;;AAKA,MAAM,WAAW,WAAyB;CACxC,IAAI,OAAO,WAAW,eAAe,CAACA,gCAAS,SAAS;CAExD,MAAM,WAAW,OAAO,SAAS;CACjC,MAAM,6DACJ,UACA,QACAA,gCAAS,OACX;CAEA,IAAI,cAAc,eAAe,UAC/B,OAAO,QAAQ,aACb,OAAO,QAAQ,OACf,IACA,aAAa,OAAO,SAAS,SAAS,OAAO,SAAS,IACxD;AAEJ;;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,sBAAoC;CAC/C,MAAM,SAASC,iDAAkB;CAGjC,QAAQ,OAAO,MAAM;CAErB,OAAO,OAAO,WAAW,cAAc;EACrC,QAAQ,SAAS;CACnB,CAAC;AACH"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_client_installIntlayer = require('../client/installIntlayer.cjs');
|
|
4
3
|
let _intlayer_editor_isEnabled = require("@intlayer/editor/isEnabled");
|
|
5
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditor.cjs","names":["isEnabled","getIntlayerClient"],"sources":["../../../src/editor/useEditor.ts"],"sourcesContent":["import type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { getIntlayerClient } from '../client/installIntlayer';\n\n/**\n * Initialises the Intlayer visual editor client.\n *\n * Does nothing when `INTLAYER_EDITOR_ENABLED` is `\"false\"` or the editor\n * package reports that it is disabled.\n *\n * Call this once at application startup.\n *\n * @returns A cleanup function that stops the editor.\n *\n * @example\n * ```ts\n * import { installIntlayer, useEditor } from 'vanilla-intlayer';\n *\n * installIntlayer('en');\n * const stopEditor = useEditor();\n * ```\n */\n\nexport const useEditor = (): (() => void) => {\n if (process.env['INTLAYER_EDITOR_ENABLED'] === 'false' || !isEnabled)\n return () => {};\n\n let unsubscribeLocale: (() => void) | null = null;\n let stopped = false;\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n if (stopped) return;\n const manager: EditorStateManager = initEditorClient();\n const client = getIntlayerClient();\n\n manager.currentLocale.set(client.locale as Locale);\n\n unsubscribeLocale = client.subscribe((newLocale) => {\n manager.currentLocale.set(newLocale as Locale);\n });\n });\n\n return () => {\n stopped = true;\n unsubscribeLocale?.();\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useEditor.cjs","names":["isEnabled","getIntlayerClient"],"sources":["../../../src/editor/useEditor.ts"],"sourcesContent":["import type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { getIntlayerClient } from '../client/installIntlayer';\n\n/**\n * Initialises the Intlayer visual editor client.\n *\n * Does nothing when `INTLAYER_EDITOR_ENABLED` is `\"false\"` or the editor\n * package reports that it is disabled.\n *\n * Call this once at application startup.\n *\n * @returns A cleanup function that stops the editor.\n *\n * @example\n * ```ts\n * import { installIntlayer, useEditor } from 'vanilla-intlayer';\n *\n * installIntlayer('en');\n * const stopEditor = useEditor();\n * ```\n */\n\nexport const useEditor = (): (() => void) => {\n if (process.env['INTLAYER_EDITOR_ENABLED'] === 'false' || !isEnabled)\n return () => {};\n\n let unsubscribeLocale: (() => void) | null = null;\n let stopped = false;\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n if (stopped) return;\n const manager: EditorStateManager = initEditorClient();\n const client = getIntlayerClient();\n\n manager.currentLocale.set(client.locale as Locale);\n\n unsubscribeLocale = client.subscribe((newLocale) => {\n manager.currentLocale.set(newLocale as Locale);\n });\n });\n\n return () => {\n stopped = true;\n unsubscribeLocale?.();\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,kBAAgC;CAC3C,IAAI,QAAQ,IAAI,+BAA+B,WAAW,CAACA,sCACzD,aAAa,CAAC;CAEhB,IAAI,oBAAyC;CAC7C,IAAI,UAAU;CAEd,OAAO,oBAAoB,MAAM,EAAE,uBAAuB;EACxD,IAAI,SAAS;EACb,MAAM,UAA8B,iBAAiB;EACrD,MAAM,SAASC,iDAAkB;EAEjC,QAAQ,cAAc,IAAI,OAAO,MAAgB;EAEjD,oBAAoB,OAAO,WAAW,cAAc;GAClD,QAAQ,cAAc,IAAI,SAAmB;EAC/C,CAAC;CACH,CAAC;CAED,aAAa;EACX,UAAU;EACV,oBAAoB;EACpB,OAAO,oBAAoB,MAAM,EAAE,uBAAuB;GACxD,iBAAiB;EACnB,CAAC;CACH;AACF"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_client_installIntlayer = require('../client/installIntlayer.cjs');
|
|
4
3
|
let _intlayer_core_formatters = require("@intlayer/core/formatters");
|
|
5
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompact.cjs","names":["getIntlayerClient"],"sources":["../../../src/format/useCompact.ts"],"sourcesContent":["import { compact } from '@intlayer/core/formatters';\nimport { getIntlayerClient } from '../client/installIntlayer';\n\nexport const useCompact = () => {\n const client = getIntlayerClient();\n\n return (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? client.locale,\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCompact.cjs","names":["getIntlayerClient"],"sources":["../../../src/format/useCompact.ts"],"sourcesContent":["import { compact } from '@intlayer/core/formatters';\nimport { getIntlayerClient } from '../client/installIntlayer';\n\nexport const useCompact = () => {\n const client = getIntlayerClient();\n\n return (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? client.locale,\n });\n};\n"],"mappings":";;;;;AAGA,MAAa,mBAAmB;CAC9B,MAAM,SAASA,iDAAkB;CAEjC,QAAQ,GAAG,gDACD,KAAK,IAAI;EACf,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU,OAAO;CACpC,CAAC;AACL"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_client_installIntlayer = require('../client/installIntlayer.cjs');
|
|
4
3
|
let _intlayer_core_formatters = require("@intlayer/core/formatters");
|
|
5
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCurrency.cjs","names":["getIntlayerClient"],"sources":["../../../src/format/useCurrency.ts"],"sourcesContent":["import { currency } from '@intlayer/core/formatters';\nimport { getIntlayerClient } from '../client/installIntlayer';\n\nexport const useCurrency = () => {\n const client = getIntlayerClient();\n\n return (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? client.locale,\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useCurrency.cjs","names":["getIntlayerClient"],"sources":["../../../src/format/useCurrency.ts"],"sourcesContent":["import { currency } from '@intlayer/core/formatters';\nimport { getIntlayerClient } from '../client/installIntlayer';\n\nexport const useCurrency = () => {\n const client = getIntlayerClient();\n\n return (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? client.locale,\n });\n};\n"],"mappings":";;;;;AAGA,MAAa,oBAAoB;CAC/B,MAAM,SAASA,iDAAkB;CAEjC,QAAQ,GAAG,iDACA,KAAK,IAAI;EAChB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU,OAAO;CACpC,CAAC;AACL"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_client_installIntlayer = require('../client/installIntlayer.cjs');
|
|
4
3
|
let _intlayer_core_formatters = require("@intlayer/core/formatters");
|
|
5
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDate.cjs","names":["getIntlayerClient","presets"],"sources":["../../../src/format/useDate.ts"],"sourcesContent":["import { date, presets } from '@intlayer/core/formatters';\nimport { getIntlayerClient } from '../client/installIntlayer';\n\n/**\n * Vanilla JS hook that provides a localized date/time formatter.\n */\nexport const useDate = () => {\n const client = getIntlayerClient();\n\n return (...args: Parameters<typeof date>) => {\n const options =\n typeof args[1] === 'string'\n ? { ...presets[args[1]], locale: client.locale }\n : { ...args[1], locale: args[1]?.locale ?? client.locale };\n\n return date(args[0], options as Parameters<typeof date>[1]);\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDate.cjs","names":["getIntlayerClient","presets"],"sources":["../../../src/format/useDate.ts"],"sourcesContent":["import { date, presets } from '@intlayer/core/formatters';\nimport { getIntlayerClient } from '../client/installIntlayer';\n\n/**\n * Vanilla JS hook that provides a localized date/time formatter.\n */\nexport const useDate = () => {\n const client = getIntlayerClient();\n\n return (...args: Parameters<typeof date>) => {\n const options =\n typeof args[1] === 'string'\n ? { ...presets[args[1]], locale: client.locale }\n : { ...args[1], locale: args[1]?.locale ?? client.locale };\n\n return date(args[0], options as Parameters<typeof date>[1]);\n };\n};\n"],"mappings":";;;;;;;;AAMA,MAAa,gBAAgB;CAC3B,MAAM,SAASA,iDAAkB;CAEjC,QAAQ,GAAG,SAAkC;EAC3C,MAAM,UACJ,OAAO,KAAK,OAAO,WACf;GAAE,GAAGC,kCAAQ,KAAK;GAAK,QAAQ,OAAO;EAAO,IAC7C;GAAE,GAAG,KAAK;GAAI,QAAQ,KAAK,IAAI,UAAU,OAAO;EAAO;EAE7D,2CAAY,KAAK,IAAI,OAAqC;CAC5D;AACF"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_client_installIntlayer = require('../client/installIntlayer.cjs');
|
|
4
3
|
let _intlayer_core_utils = require("@intlayer/core/utils");
|
|
5
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntl.cjs","names":["getIntlayerClient"],"sources":["../../../src/format/useIntl.ts"],"sourcesContent":["import { bindIntl, type WrappedIntl } from '@intlayer/core/utils';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getIntlayerClient } from '../client/installIntlayer';\n\n/**\n * Get a locale-bound `Intl` object and subscribe to locale changes.\n *\n * The returned `intl` property acts like the native `Intl` namespace but\n * automatically uses the current application locale, so you do not need to\n * pass the locale manually to `NumberFormat`, `DateTimeFormat`, etc.\n *\n * @param locale - Optional locale override.\n * @returns An object with `intl: WrappedIntl` and a `subscribe` function.\n *\n * @example\n * ```ts\n * import { installIntlayer, useIntl } from 'vanilla-intlayer';\n *\n * installIntlayer('en');\n *\n * const { intl, subscribe } = useIntl();\n *\n * console.log(new intl.NumberFormat({ style: 'currency', currency: 'USD' }).format(9.99));\n *\n * const unsubscribe = subscribe((newIntl) => {\n * console.log(new newIntl.NumberFormat({ style: 'currency', currency: 'USD' }).format(9.99));\n * });\n * ```\n */\nexport const useIntl = (\n locale?: LocalesValues\n): {\n intl: WrappedIntl;\n subscribe: (callback: (intl: WrappedIntl) => void) => () => void;\n} => {\n const client = getIntlayerClient();\n const intl = bindIntl(locale ?? client.locale);\n\n return {\n intl,\n subscribe: (callback) =>\n client.subscribe((newLocale) => {\n callback(bindIntl(locale ?? newLocale));\n }),\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIntl.cjs","names":["getIntlayerClient"],"sources":["../../../src/format/useIntl.ts"],"sourcesContent":["import { bindIntl, type WrappedIntl } from '@intlayer/core/utils';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getIntlayerClient } from '../client/installIntlayer';\n\n/**\n * Get a locale-bound `Intl` object and subscribe to locale changes.\n *\n * The returned `intl` property acts like the native `Intl` namespace but\n * automatically uses the current application locale, so you do not need to\n * pass the locale manually to `NumberFormat`, `DateTimeFormat`, etc.\n *\n * @param locale - Optional locale override.\n * @returns An object with `intl: WrappedIntl` and a `subscribe` function.\n *\n * @example\n * ```ts\n * import { installIntlayer, useIntl } from 'vanilla-intlayer';\n *\n * installIntlayer('en');\n *\n * const { intl, subscribe } = useIntl();\n *\n * console.log(new intl.NumberFormat({ style: 'currency', currency: 'USD' }).format(9.99));\n *\n * const unsubscribe = subscribe((newIntl) => {\n * console.log(new newIntl.NumberFormat({ style: 'currency', currency: 'USD' }).format(9.99));\n * });\n * ```\n */\nexport const useIntl = (\n locale?: LocalesValues\n): {\n intl: WrappedIntl;\n subscribe: (callback: (intl: WrappedIntl) => void) => () => void;\n} => {\n const client = getIntlayerClient();\n const intl = bindIntl(locale ?? client.locale);\n\n return {\n intl,\n subscribe: (callback) =>\n client.subscribe((newLocale) => {\n callback(bindIntl(locale ?? newLocale));\n }),\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,WACX,WAIG;CACH,MAAM,SAASA,iDAAkB;CAGjC,OAAO;EACL,yCAHoB,UAAU,OAAO,MAGlC;EACH,YAAY,aACV,OAAO,WAAW,cAAc;GAC9B,4CAAkB,UAAU,SAAS,CAAC;EACxC,CAAC;CACL;AACF"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_client_installIntlayer = require('../client/installIntlayer.cjs');
|
|
4
3
|
let _intlayer_core_formatters = require("@intlayer/core/formatters");
|
|
5
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useList.cjs","names":["getIntlayerClient"],"sources":["../../../src/format/useList.ts"],"sourcesContent":["import { list } from '@intlayer/core/formatters';\nimport { getIntlayerClient } from '../client/installIntlayer';\n\nexport const useList = () => {\n const client = getIntlayerClient();\n\n return (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? client.locale,\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useList.cjs","names":["getIntlayerClient"],"sources":["../../../src/format/useList.ts"],"sourcesContent":["import { list } from '@intlayer/core/formatters';\nimport { getIntlayerClient } from '../client/installIntlayer';\n\nexport const useList = () => {\n const client = getIntlayerClient();\n\n return (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? client.locale,\n });\n};\n"],"mappings":";;;;;AAGA,MAAa,gBAAgB;CAC3B,MAAM,SAASA,iDAAkB;CAEjC,QAAQ,GAAG,6CACJ,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU,OAAO;CACpC,CAAC;AACL"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_client_installIntlayer = require('../client/installIntlayer.cjs');
|
|
4
3
|
let _intlayer_core_formatters = require("@intlayer/core/formatters");
|
|
5
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNumber.cjs","names":["getIntlayerClient"],"sources":["../../../src/format/useNumber.ts"],"sourcesContent":["import { number } from '@intlayer/core/formatters';\nimport { getIntlayerClient } from '../client/installIntlayer';\n\n/**\n * Vanilla JS hook that provides a localized number formatter.\n */\nexport const useNumber = () => {\n const client = getIntlayerClient();\n\n return (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? client.locale,\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useNumber.cjs","names":["getIntlayerClient"],"sources":["../../../src/format/useNumber.ts"],"sourcesContent":["import { number } from '@intlayer/core/formatters';\nimport { getIntlayerClient } from '../client/installIntlayer';\n\n/**\n * Vanilla JS hook that provides a localized number formatter.\n */\nexport const useNumber = () => {\n const client = getIntlayerClient();\n\n return (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? client.locale,\n });\n};\n"],"mappings":";;;;;;;;AAMA,MAAa,kBAAkB;CAC7B,MAAM,SAASA,iDAAkB;CAEjC,QAAQ,GAAG,+CACF,KAAK,IAAI;EACd,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU,OAAO;CACpC,CAAC;AACL"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_client_installIntlayer = require('../client/installIntlayer.cjs');
|
|
4
3
|
let _intlayer_core_formatters = require("@intlayer/core/formatters");
|
|
5
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePercentage.cjs","names":["getIntlayerClient"],"sources":["../../../src/format/usePercentage.ts"],"sourcesContent":["import { percentage } from '@intlayer/core/formatters';\nimport { getIntlayerClient } from '../client/installIntlayer';\n\nexport const usePercentage = () => {\n const client = getIntlayerClient();\n\n return (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? client.locale,\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePercentage.cjs","names":["getIntlayerClient"],"sources":["../../../src/format/usePercentage.ts"],"sourcesContent":["import { percentage } from '@intlayer/core/formatters';\nimport { getIntlayerClient } from '../client/installIntlayer';\n\nexport const usePercentage = () => {\n const client = getIntlayerClient();\n\n return (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? client.locale,\n });\n};\n"],"mappings":";;;;;AAGA,MAAa,sBAAsB;CACjC,MAAM,SAASA,iDAAkB;CAEjC,QAAQ,GAAG,mDACE,KAAK,IAAI;EAClB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU,OAAO;CACpC,CAAC;AACL"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_client_installIntlayer = require('../client/installIntlayer.cjs');
|
|
4
3
|
let _intlayer_core_formatters = require("@intlayer/core/formatters");
|
|
5
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useRelativeTime.cjs","names":["getIntlayerClient"],"sources":["../../../src/format/useRelativeTime.ts"],"sourcesContent":["import { relativeTime } from '@intlayer/core/formatters';\nimport { getIntlayerClient } from '../client/installIntlayer';\n\nexport const useRelativeTime = () => {\n const client = getIntlayerClient();\n\n return (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1], {\n ...args[2],\n locale: args[2]?.locale ?? client.locale,\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useRelativeTime.cjs","names":["getIntlayerClient"],"sources":["../../../src/format/useRelativeTime.ts"],"sourcesContent":["import { relativeTime } from '@intlayer/core/formatters';\nimport { getIntlayerClient } from '../client/installIntlayer';\n\nexport const useRelativeTime = () => {\n const client = getIntlayerClient();\n\n return (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1], {\n ...args[2],\n locale: args[2]?.locale ?? client.locale,\n });\n};\n"],"mappings":";;;;;AAGA,MAAa,wBAAwB;CACnC,MAAM,SAASA,iDAAkB;CAEjC,QAAQ,GAAG,qDACI,KAAK,IAAI,KAAK,IAAI;EAC7B,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU,OAAO;CACpC,CAAC;AACL"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_client_installIntlayer = require('../client/installIntlayer.cjs');
|
|
4
3
|
let _intlayer_core_formatters = require("@intlayer/core/formatters");
|
|
5
4
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useUnit.cjs","names":["getIntlayerClient"],"sources":["../../../src/format/useUnit.ts"],"sourcesContent":["import { units } from '@intlayer/core/formatters';\nimport { getIntlayerClient } from '../client/installIntlayer';\n\nexport const useUnit = () => {\n const client = getIntlayerClient();\n\n return (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? client.locale,\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useUnit.cjs","names":["getIntlayerClient"],"sources":["../../../src/format/useUnit.ts"],"sourcesContent":["import { units } from '@intlayer/core/formatters';\nimport { getIntlayerClient } from '../client/installIntlayer';\n\nexport const useUnit = () => {\n const client = getIntlayerClient();\n\n return (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? client.locale,\n });\n};\n"],"mappings":";;;;;AAGA,MAAa,gBAAgB;CAC3B,MAAM,SAASA,iDAAkB;CAEjC,QAAQ,GAAG,8CACH,KAAK,IAAI;EACb,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU,OAAO;CACpC,CAAC;AACL"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDictionary.cjs","names":["getPlugins"],"sources":["../../src/getDictionary.ts"],"sourcesContent":["import { getDictionary as getDictionaryCore } from '@intlayer/core/interpreter';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n): DeepTransformContent<T['content'], L> =>\n getDictionaryCore(dictionary, locale, getPlugins(locale)) as any;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getDictionary.cjs","names":["getPlugins"],"sources":["../../src/getDictionary.ts"],"sourcesContent":["import { getDictionary as getDictionaryCore } from '@intlayer/core/interpreter';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\nexport const getDictionary = <\n const T extends Dictionary,\n const L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n): DeepTransformContent<T['content'], L> =>\n getDictionaryCore(dictionary, locale, getPlugins(locale)) as any;\n"],"mappings":";;;;;AAQA,MAAa,iBAIX,YACA,yDAEkB,YAAY,QAAQA,2BAAW,MAAM,CAAC"}
|
package/dist/cjs/getIntlayer.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIntlayer.cjs","names":["getPlugins"],"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import { getIntlayer as getIntlayerCore } from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\nexport const getIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L\n): DeepTransformContent<DictionaryRegistryContent<T>, L> =>\n getIntlayerCore(key, locale, getPlugins(locale)) as any;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"getIntlayer.cjs","names":["getPlugins"],"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import { getIntlayer as getIntlayerCore } from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\nexport const getIntlayer = <\n const T extends DictionaryKeys,\n const L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L\n): DeepTransformContent<DictionaryRegistryContent<T>, L> =>\n getIntlayerCore(key, locale, getPlugins(locale)) as any;\n"],"mappings":";;;;;AASA,MAAa,eAIX,KACA,uDAEgB,KAAK,QAAQA,2BAAW,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownRenderer.cjs","names":["compileMarkdown","useMarkdown"],"sources":["../../../src/markdown/MarkdownRenderer.ts"],"sourcesContent":["import type { HTMLComponents } from '../html/types';\nimport {
|
|
1
|
+
{"version":3,"file":"MarkdownRenderer.cjs","names":["compileMarkdown","useMarkdown"],"sources":["../../../src/markdown/MarkdownRenderer.ts"],"sourcesContent":["import type { HTMLComponents } from '../html/types';\nimport {\n compileMarkdown,\n type MarkdownCompilerOptions,\n type ParsedMarkdown,\n} from './compiler';\nimport {\n type MarkdownProviderOptions,\n type RenderMarkdownFunction,\n useMarkdown,\n} from './installIntlayerMarkdown';\n\nexport type RenderMarkdownProps = MarkdownProviderOptions & {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: string;\n};\n\n/**\n * Renders markdown to an HTML string without using the global provider.\n *\n * @example\n * ```ts\n * import { renderMarkdown } from 'vanilla-intlayer/markdown';\n *\n * document.querySelector('#content').innerHTML = renderMarkdown('# Hello **World**');\n * ```\n */\nexport const renderMarkdown = (\n content: string | ParsedMarkdown,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n }: RenderMarkdownProps = {}\n): string => {\n const options: MarkdownCompilerOptions = {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n };\n return compileMarkdown(content, options);\n};\n\n/**\n * Returns a render function that uses the global provider's configuration\n * (installed via `installIntlayerMarkdown`), falling back to `compileMarkdown`.\n */\nexport const useMarkdownRenderer = (\n props: RenderMarkdownProps = {}\n): ((content: string | ParsedMarkdown) => string | Promise<string>) => {\n const provider = useMarkdown();\n\n return (content: string | ParsedMarkdown) =>\n provider.renderMarkdown(\n content,\n {\n forceBlock: props.forceBlock,\n forceInline: props.forceInline,\n preserveFrontmatter: props.preserveFrontmatter,\n tagfilter: props.tagfilter,\n },\n props.components,\n props.wrapper\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;AA2BA,MAAa,kBACX,SACA,EACE,YACA,aACA,qBACA,cACuB,CAAC,MACf;CAOX,OAAOA,0CAAgB,SAAS;EAL9B;EACA;EACA;EACA;CAEoC,CAAC;AACzC;;;;;AAMA,MAAa,uBACX,QAA6B,CAAC,MACuC;CACrE,MAAM,WAAWC,qDAAY;CAE7B,QAAQ,YACN,SAAS,eACP,SACA;EACE,YAAY,MAAM;EAClB,aAAa,MAAM;EACnB,qBAAqB,MAAM;EAC3B,WAAW,MAAM;CACnB,GACA,MAAM,YACN,MAAM,OACR;AACJ"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
|
|
3
2
|
const require_markdown_runtime = require('./runtime.cjs');
|
|
4
3
|
let _intlayer_core_markdown = require("@intlayer/core/markdown");
|
|
5
4
|
|
|
@@ -10,20 +9,27 @@ let _intlayer_core_markdown = require("@intlayer/core/markdown");
|
|
|
10
9
|
* Compiles markdown to an HTML string for use with `innerHTML` or the
|
|
11
10
|
* `renderMarkdown` utility.
|
|
12
11
|
*/
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
12
|
+
const parseMarkdown = (markdown = "", options = {}) => {
|
|
13
|
+
const { components, namedCodesToUnicode, sanitizer, slugify, ...compilerOptions } = options;
|
|
14
|
+
return (0, _intlayer_core_markdown.parseMarkdown)(markdown, {
|
|
15
|
+
runtime: require_markdown_runtime.default,
|
|
16
|
+
components,
|
|
17
|
+
namedCodesToUnicode,
|
|
18
|
+
sanitizer,
|
|
19
|
+
slugify
|
|
20
|
+
}, compilerOptions);
|
|
21
|
+
};
|
|
22
|
+
const compileMarkdown = (input = "", options = {}) => {
|
|
23
|
+
if (typeof input === "string") return (0, _intlayer_core_markdown.compileWithOptions)(input, require_markdown_runtime.default, options);
|
|
24
|
+
const { components, namedCodesToUnicode, sanitizer, slugify, ...compilerOptions } = options;
|
|
25
|
+
return (0, _intlayer_core_markdown.renderMarkdownAst)(input, {
|
|
26
|
+
runtime: require_markdown_runtime.default,
|
|
27
|
+
components,
|
|
28
|
+
namedCodesToUnicode,
|
|
29
|
+
sanitizer,
|
|
30
|
+
slugify
|
|
31
|
+
}, compilerOptions);
|
|
32
|
+
};
|
|
27
33
|
const compiler = compileMarkdown;
|
|
28
34
|
const compile = compileMarkdown;
|
|
29
35
|
|
|
@@ -32,6 +38,7 @@ exports.RuleType = _intlayer_core_markdown.RuleType;
|
|
|
32
38
|
exports.compile = compile;
|
|
33
39
|
exports.compileMarkdown = compileMarkdown;
|
|
34
40
|
exports.compiler = compiler;
|
|
41
|
+
exports.parseMarkdown = parseMarkdown;
|
|
35
42
|
exports.sanitizer = _intlayer_core_markdown.sanitizer;
|
|
36
43
|
exports.slugify = _intlayer_core_markdown.slugify;
|
|
37
44
|
//# sourceMappingURL=compiler.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.cjs","names":["vanillaRuntime"],"sources":["../../../src/markdown/compiler.ts"],"sourcesContent":["/**\n * Vanilla JS adapter for the framework-agnostic markdown processor.\n *\n * Compiles markdown to an HTML string for use with `innerHTML` or the\n * `renderMarkdown` utility.\n */\n\nimport {\n type CompileOptions,\n compileWithOptions,\n sanitizer as defaultSanitizer,\n slugify as defaultSlugify,\n RuleType,\n} from '@intlayer/core/markdown';\nimport { vanillaRuntime } from './runtime';\n\n// Re-export utilities for compatibility\nexport { defaultSanitizer as sanitizer, defaultSlugify as slugify, RuleType };\n\nexport type MarkdownCompilerOptions = CompileOptions;\n\n/**\n * Compile markdown to an HTML string.\n *\n * The resulting string can be inserted into the DOM via `element.innerHTML`\n * or the `renderMarkdown` helper.\n *\n * @example\n * ```ts\n * import { compileMarkdown } from 'vanilla-intlayer/markdown';\n *\n * document.querySelector('#content').innerHTML = compileMarkdown('# Hello **World**');\n * ```\n */\nexport const
|
|
1
|
+
{"version":3,"file":"compiler.cjs","names":["vanillaRuntime"],"sources":["../../../src/markdown/compiler.ts"],"sourcesContent":["/**\n * Vanilla JS adapter for the framework-agnostic markdown processor.\n *\n * Compiles markdown to an HTML string for use with `innerHTML` or the\n * `renderMarkdown` utility.\n */\n\nimport {\n type CompileOptions,\n compileWithOptions,\n parseMarkdown as coreParseMarkdown,\n renderMarkdownAst as coreRenderMarkdownAst,\n sanitizer as defaultSanitizer,\n slugify as defaultSlugify,\n type MarkdownContext,\n type ParsedMarkdown,\n RuleType,\n} from '@intlayer/core/markdown';\nimport { vanillaRuntime } from './runtime';\n\n// Re-export utilities for compatibility\nexport { defaultSanitizer as sanitizer, defaultSlugify as slugify, RuleType };\n\nexport type MarkdownCompilerOptions = CompileOptions;\n\n/**\n * Compile markdown to an HTML string.\n *\n * The resulting string can be inserted into the DOM via `element.innerHTML`\n * or the `renderMarkdown` helper.\n *\n * @example\n * ```ts\n * import { compileMarkdown } from 'vanilla-intlayer/markdown';\n *\n * document.querySelector('#content').innerHTML = compileMarkdown('# Hello **World**');\n * ```\n */\nexport type { ParsedMarkdown };\n\nexport const parseMarkdown = (\n markdown: string = '',\n options: MarkdownCompilerOptions = {}\n): ParsedMarkdown => {\n const {\n components,\n namedCodesToUnicode,\n sanitizer,\n slugify,\n ...compilerOptions\n } = options;\n\n const ctx: MarkdownContext<any> = {\n runtime: vanillaRuntime,\n components,\n namedCodesToUnicode,\n sanitizer: sanitizer as any,\n slugify,\n };\n\n return coreParseMarkdown(markdown, ctx, compilerOptions);\n};\n\nexport const compileMarkdown = (\n input: string | ParsedMarkdown = '',\n options: MarkdownCompilerOptions = {}\n): string => {\n if (typeof input === 'string') {\n return compileWithOptions(input, vanillaRuntime, options) as string;\n }\n\n const {\n components,\n namedCodesToUnicode,\n sanitizer,\n slugify,\n ...compilerOptions\n } = options;\n\n const ctx: MarkdownContext<any> = {\n runtime: vanillaRuntime,\n components,\n namedCodesToUnicode,\n sanitizer: sanitizer as any,\n slugify,\n };\n\n return coreRenderMarkdownAst(input, ctx, compilerOptions) as string;\n};\n\n// Aliases for consistency with other adapters\nexport const compiler = compileMarkdown;\nexport const compile = compileMarkdown;\n"],"mappings":";;;;;;;;;;;AAwCA,MAAa,iBACX,WAAmB,IACnB,UAAmC,CAAC,MACjB;CACnB,MAAM,EACJ,YACA,qBACA,WACA,SACA,GAAG,oBACD;CAUJ,kDAAyB,UAAU;EAPjC,SAASA;EACT;EACA;EACW;EACX;CAGmC,GAAG,eAAe;AACzD;AAEA,MAAa,mBACX,QAAiC,IACjC,UAAmC,CAAC,MACzB;CACX,IAAI,OAAO,UAAU,UACnB,uDAA0B,OAAOA,kCAAgB,OAAO;CAG1D,MAAM,EACJ,YACA,qBACA,WACA,SACA,GAAG,oBACD;CAUJ,sDAA6B,OAAO;EAPlC,SAASA;EACT;EACA;EACW;EACX;CAGoC,GAAG,eAAe;AAC1D;AAGA,MAAa,WAAW;AACxB,MAAa,UAAU"}
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_markdown_compiler = require('./compiler.cjs');
|
|
2
3
|
const require_markdown_installIntlayerMarkdown = require('./installIntlayerMarkdown.cjs');
|
|
3
4
|
const require_markdown_MarkdownRenderer = require('./MarkdownRenderer.cjs');
|
|
5
|
+
let _intlayer_core_markdown = require("@intlayer/core/markdown");
|
|
4
6
|
|
|
7
|
+
exports.RuleType = _intlayer_core_markdown.RuleType;
|
|
8
|
+
exports.compile = require_markdown_compiler.compile;
|
|
9
|
+
exports.compileMarkdown = require_markdown_compiler.compileMarkdown;
|
|
10
|
+
exports.compiler = require_markdown_compiler.compiler;
|
|
5
11
|
exports.installIntlayerMarkdown = require_markdown_installIntlayerMarkdown.installIntlayerMarkdown;
|
|
6
12
|
exports.installIntlayerMarkdownDynamic = require_markdown_installIntlayerMarkdown.installIntlayerMarkdownDynamic;
|
|
13
|
+
exports.parseMarkdown = require_markdown_compiler.parseMarkdown;
|
|
7
14
|
exports.renderMarkdown = require_markdown_MarkdownRenderer.renderMarkdown;
|
|
15
|
+
exports.sanitizer = _intlayer_core_markdown.sanitizer;
|
|
16
|
+
exports.slugify = _intlayer_core_markdown.slugify;
|
|
8
17
|
exports.useMarkdown = require_markdown_installIntlayerMarkdown.useMarkdown;
|
|
9
18
|
exports.useMarkdownRenderer = require_markdown_MarkdownRenderer.useMarkdownRenderer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installIntlayerMarkdown.cjs","names":["compileMarkdown"],"sources":["../../../src/markdown/installIntlayerMarkdown.ts"],"sourcesContent":["import type { HTMLComponents } from '../html/types';\nimport {
|
|
1
|
+
{"version":3,"file":"installIntlayerMarkdown.cjs","names":["compileMarkdown"],"sources":["../../../src/markdown/installIntlayerMarkdown.ts"],"sourcesContent":["import type { HTMLComponents } from '../html/types';\nimport {\n compileMarkdown,\n type MarkdownCompilerOptions,\n type ParsedMarkdown,\n} from './compiler';\n\nexport type MarkdownProviderOptions = {\n /** Forces the compiler to always output content with a block-level wrapper. */\n forceBlock?: boolean;\n /** Forces the compiler to always output content with an inline wrapper. */\n forceInline?: boolean;\n /** Whether to preserve frontmatter in the markdown content. */\n preserveFrontmatter?: boolean;\n /** Whether to use the GitHub Tag Filter. */\n tagfilter?: boolean;\n};\n\nexport type RenderMarkdownOptions = MarkdownProviderOptions & {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: string;\n};\n\nexport type RenderMarkdownFunction = (\n markdown: string | ParsedMarkdown,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: string\n) => string | Promise<string>;\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerMarkdownProvider | null = null;\n\nexport type IntlayerMarkdownProvider = {\n components?: HTMLComponents<'permissive', {}>;\n renderMarkdown: RenderMarkdownFunction;\n};\n\nexport type IntlayerMarkdownPluginOptions = MarkdownProviderOptions & {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: string;\n renderMarkdown?: RenderMarkdownFunction;\n};\n\n/**\n * Create and return a single IntlayerMarkdownProvider instance.\n */\nexport const createIntlayerMarkdownClient = (\n renderMarkdown: RenderMarkdownFunction,\n components?: HTMLComponents<'permissive', {}>\n): IntlayerMarkdownProvider => {\n if (instance) return instance;\n\n instance = { components, renderMarkdown };\n return instance;\n};\n\n/**\n * Install the Intlayer Markdown provider for your vanilla JS application.\n *\n * @example\n * ```ts\n * import { installIntlayerMarkdown } from 'vanilla-intlayer/markdown';\n *\n * installIntlayerMarkdown({ forceBlock: true });\n * ```\n */\nexport const installIntlayerMarkdown = (\n pluginOptions?: IntlayerMarkdownPluginOptions | RenderMarkdownFunction\n): IntlayerMarkdownProvider => {\n let renderMarkdown: RenderMarkdownFunction;\n let providerComponents: HTMLComponents<'permissive', {}> | undefined;\n\n if (typeof pluginOptions === 'function') {\n renderMarkdown = pluginOptions;\n } else {\n const {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRender,\n } = pluginOptions ?? {};\n\n providerComponents = components;\n\n if (customRender) {\n renderMarkdown = customRender;\n } else {\n const internalOptions: MarkdownCompilerOptions = {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n };\n\n renderMarkdown = (\n markdown,\n options,\n _componentsOverride,\n _wrapperOverride\n ) =>\n compileMarkdown(markdown, {\n ...internalOptions,\n forceBlock: options?.forceBlock ?? internalOptions.forceBlock,\n forceInline: options?.forceInline ?? internalOptions.forceInline,\n preserveFrontmatter:\n options?.preserveFrontmatter ?? internalOptions.preserveFrontmatter,\n tagfilter: options?.tagfilter ?? internalOptions.tagfilter,\n });\n }\n }\n\n return createIntlayerMarkdownClient(renderMarkdown, providerComponents);\n};\n\n/**\n * Access the installed IntlayerMarkdownProvider.\n * Returns a fallback renderer that compiles with default options if no\n * provider has been installed.\n */\nexport const useMarkdown = (): IntlayerMarkdownProvider => {\n if (instance) return instance;\n\n return {\n renderMarkdown: (markdown) =>\n compileMarkdown(markdown as string | ParsedMarkdown),\n };\n};\n\n/**\n * Asynchronously install a markdown renderer whose implementation is loaded\n * via a dynamic `import()`.\n *\n * Use this to keep the markdown compiler out of the initial bundle — the\n * loader is only called the first time this function is executed.\n *\n * The returned promise resolves once the provider is ready. Any calls to\n * `useMarkdown()` before the promise resolves will use the fallback\n * (raw-string) renderer.\n *\n * @param loader - A zero-argument async function that resolves to either a\n * `RenderMarkdownFunction` or an `IntlayerMarkdownPluginOptions` object.\n *\n * @example\n * ```ts\n * // Load a custom markdown renderer (e.g. marked) only when needed\n * await installIntlayerMarkdownDynamic(async () => {\n * const { marked } = await import('marked');\n * return (markdown) => marked(markdown) as string;\n * });\n * ```\n */\nexport const installIntlayerMarkdownDynamic = async (\n loader: () => Promise<IntlayerMarkdownPluginOptions | RenderMarkdownFunction>\n): Promise<IntlayerMarkdownProvider> => {\n if (instance) return instance;\n const pluginOptions = await loader();\n return installIntlayerMarkdown(pluginOptions);\n};\n"],"mappings":";;;;;;;AAiCA,IAAI,WAA4C;;;;AAgBhD,MAAa,gCACX,gBACA,eAC6B;CAC7B,IAAI,UAAU,OAAO;CAErB,WAAW;EAAE;EAAY;CAAe;CACxC,OAAO;AACT;;;;;;;;;;;AAYA,MAAa,2BACX,kBAC6B;CAC7B,IAAI;CACJ,IAAI;CAEJ,IAAI,OAAO,kBAAkB,YAC3B,iBAAiB;MACZ;EACL,MAAM,EACJ,YACA,SACA,YACA,aACA,qBACA,WACA,gBAAgB,iBACd,iBAAiB,CAAC;EAEtB,qBAAqB;EAErB,IAAI,cACF,iBAAiB;OACZ;GACL,MAAM,kBAA2C;IAC/C;IACA;IACA;IACA;GACF;GAEA,kBACE,UACA,SACA,qBACA,qBAEAA,0CAAgB,UAAU;IACxB,GAAG;IACH,YAAY,SAAS,cAAc,gBAAgB;IACnD,aAAa,SAAS,eAAe,gBAAgB;IACrD,qBACE,SAAS,uBAAuB,gBAAgB;IAClD,WAAW,SAAS,aAAa,gBAAgB;GACnD,CAAC;EACL;CACF;CAEA,OAAO,6BAA6B,gBAAgB,kBAAkB;AACxE;;;;;;AAOA,MAAa,oBAA8C;CACzD,IAAI,UAAU,OAAO;CAErB,OAAO,EACL,iBAAiB,aACfA,0CAAgB,QAAmC,EACvD;AACF;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,iCAAiC,OAC5C,WACsC;CACtC,IAAI,UAAU,OAAO;CAErB,OAAO,wBAAwB,MADH,OAAO,CACS;AAC9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport type { DeepTransformContent } from '../plugins';\nimport { getIntlayerClient } from './installIntlayer';\n\nexport type WithOnChange<T> = T & {\n /**\n * Subscribe to locale changes. The callback receives the fresh content\n * whenever the active locale changes. Returns the content object itself\n * for convenient one-liner patterns:\n *\n * ```ts\n * const content = useDictionary(myDict).onChange((c) => {\n * document.querySelector('p')!.textContent = String(c.greeting);\n * });\n * ```\n */\n onChange: (\n callback: <T extends Dictionary, L extends LocalesValues>(\n content: DeepTransformContent<T['content'], L>\n ) => void\n ) => WithOnChange<T>;\n};\n\n/**\n * Get the translated content for a raw dictionary object and optionally\n * subscribe to locale changes via the chainable `.onChange()` method —\n * mirroring the API of `react-intlayer`.\n *\n * Unlike `useIntlayer` (which takes a registered key), this function accepts a\n * dictionary object directly — useful for dictionaries loaded asynchronously\n * or defined inline.\n *\n * The function returns the current content **directly** (same shape as\n * `getDictionary(dict)`), plus the `.onChange()` helper:\n *\n * ```ts\n * // React\n * const content = useDictionary(myDict);\n *\n * // Vanilla — identical surface API, opt-in reactivity via .onChange()\n * const content = useDictionary(myDict);\n * const content = useDictionary(myDict).onChange((c) => render(c));\n * ```\n *\n * @param dictionary - The raw dictionary object.\n * @param locale - Optional locale override.\n * @returns The current translated content with an `.onChange()` method.\n *\n * @example\n * ```ts\n * import myDict from './myDictionary.content';\n * import { installIntlayer, useDictionary } from 'vanilla-intlayer';\n *\n * installIntlayer();\n *\n * const content = useDictionary(myDict).onChange((c) => {\n * document.querySelector('p').textContent = String(c.greeting);\n * });\n *\n * document.querySelector('p').textContent = String(content.greeting);\n * ```\n */\nexport const useDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n): WithOnChange<DeepTransformContent<T['content'], L>> => {\n const client = getIntlayerClient();\n const content = getDictionary(\n dictionary,\n (locale ?? client.locale) as L\n ) as WithOnChange<DeepTransformContent<T['content'], L>>;\n\n content.onChange = (\n callback: (content: DeepTransformContent<T['content'], L>) => void\n ) => {\n client.subscribe((newLocale) => {\n callback(getDictionary(dictionary, (locale ?? newLocale) as L));\n });\n return content;\n };\n\n return content;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,MAAa,iBAIX,YACA,WACwD;CACxD,MAAM,SAAS,kBAAkB;CACjC,MAAM,UAAU,cACd,YACC,UAAU,OAAO,MACpB;CAEA,QAAQ,YACN,aACG;EACH,OAAO,WAAW,cAAc;GAC9B,SAAS,cAAc,YAAa,UAAU,SAAe,CAAC;EAChE,CAAC;EACD,OAAO;CACT;CAEA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"useDictionary.mjs","names":[],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport type { DeepTransformContent } from '../plugins';\nimport { getIntlayerClient } from './installIntlayer';\n\nexport type WithOnChange<T> = T & {\n /**\n * Subscribe to locale changes. The callback receives the fresh content\n * whenever the active locale changes. Returns the content object itself\n * for convenient one-liner patterns:\n *\n * ```ts\n * const content = useDictionary(myDict).onChange((c) => {\n * document.querySelector('p')!.textContent = String(c.greeting);\n * });\n * ```\n */\n onChange: (\n callback: <T extends Dictionary, L extends LocalesValues>(\n content: DeepTransformContent<T['content'], L>\n ) => void\n ) => WithOnChange<T>;\n};\n\n/**\n * Get the translated content for a raw dictionary object and optionally\n * subscribe to locale changes via the chainable `.onChange()` method —\n * mirroring the API of `react-intlayer`.\n *\n * Unlike `useIntlayer` (which takes a registered key), this function accepts a\n * dictionary object directly — useful for dictionaries loaded asynchronously\n * or defined inline.\n *\n * The function returns the current content **directly** (same shape as\n * `getDictionary(dict)`), plus the `.onChange()` helper:\n *\n * ```ts\n * // React\n * const content = useDictionary(myDict);\n *\n * // Vanilla — identical surface API, opt-in reactivity via .onChange()\n * const content = useDictionary(myDict);\n * const content = useDictionary(myDict).onChange((c) => render(c));\n * ```\n *\n * @param dictionary - The raw dictionary object.\n * @param locale - Optional locale override.\n * @returns The current translated content with an `.onChange()` method.\n *\n * @example\n * ```ts\n * import myDict from './myDictionary.content';\n * import { installIntlayer, useDictionary } from 'vanilla-intlayer';\n *\n * installIntlayer();\n *\n * const content = useDictionary(myDict).onChange((c) => {\n * document.querySelector('p').textContent = String(c.greeting);\n * });\n *\n * document.querySelector('p').textContent = String(content.greeting);\n * ```\n */\nexport const useDictionary = <\n const T extends Dictionary,\n const L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n): WithOnChange<DeepTransformContent<T['content'], L>> => {\n const client = getIntlayerClient();\n const content = getDictionary(\n dictionary,\n (locale ?? client.locale) as L\n ) as WithOnChange<DeepTransformContent<T['content'], L>>;\n\n content.onChange = (\n callback: (content: DeepTransformContent<T['content'], L>) => void\n ) => {\n client.subscribe((newLocale) => {\n callback(getDictionary(dictionary, (locale ?? newLocale) as L));\n });\n return content;\n };\n\n return content;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,MAAa,iBAIX,YACA,WACwD;CACxD,MAAM,SAAS,kBAAkB;CACjC,MAAM,UAAU,cACd,YACC,UAAU,OAAO,MACpB;CAEA,QAAQ,YACN,aACG;EACH,OAAO,WAAW,cAAc;GAC9B,SAAS,cAAc,YAAa,UAAU,SAAe,CAAC;EAChE,CAAC;EACD,OAAO;CACT;CAEA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\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\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/**\n * Dynamically load and transform a locale-keyed dictionary.\n *\n * Works like `useIntlayer` / `useDictionary` but accepts a locale-keyed map\n * of lazy loaders instead of a pre-imported dictionary. Call it inside your\n * render function — the first call triggers a background fetch and returns\n * placeholder values; when the load completes the client notifies all\n * subscribers (including your render loop) so the render runs again with real\n * content. Subsequent calls for the same locale return immediately from cache.\n *\n * Locale switches follow the same two-phase pattern: placeholder on first\n * render, real content after the locale bundle loads.\n *\n * @param dictionaryLoaders - Locale-keyed map of `() => Promise<Dictionary>`.\n * @param key - Dictionary key (used for cache namespacing).\n * @param locale - Optional locale override.\n *\n * @example\n * ```ts\n * import dynDic from '../.intlayer/dynamic_dictionary/app.mjs';\n *\n * const render = () => {\n * const content = useDictionaryDynamic(dynDic, 'app');\n * document.querySelector('h1')!.textContent = String(content.title);\n * };\n *\n * render();\n * getIntlayerClient().subscribe(() => render());\n * ```\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n L extends LocalesValues = LocalesValues,\n>(\n dictionaryLoaders: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: L\n): WithOnChange<DeepTransformContent<T['content'], L>> => {\n const client = getIntlayerClient();\n const currentLocale = (locale ??\n client.locale ??\n internationalization.defaultLocale) as L;\n\n const cacheKey = `${String(key)}.${currentLocale}`;\n const loader = (dictionaryLoaders as Record<string, () => Promise<T>>)[\n currentLocale\n ];\n\n // --- Cache hit: return real content synchronously ---\n const cached = cache.get(cacheKey);\n if (cached) {\n const content = getDictionary(cached as T, currentLocale) as WithOnChange<\n DeepTransformContent<T['content'], L>\n >;\n\n content.onChange = (\n callback: (content: DeepTransformContent<T['content'], L>) => void\n ) => {\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(\n getDictionary(dict as T, newLocale as L) as DeepTransformContent<\n T['content'],\n L\n >\n );\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 // Placeholder proxy — safe for any property access while loading.\n const 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 return recursiveProxy as WithOnChange<DeepTransformContent<T['content'], L>>;\n};\n"],"mappings":";;;;;;AAaA,MAAM,wBAAQ,IAAI,IAAwB;;AAG1C,MAAM,2BAAW,IAAI,IAA2B;AAEhD,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,EAAE,MAAM,eAAe;EAC5C,MAAM,IAAI,UAAU,UAAU;EAC9B,SAAS,OAAO,QAAQ;CAC1B,CAAC;CAED,SAAS,IAAI,UAAU,OAAO;CAC9B,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,wBAKX,mBACA,KACA,WACwD;CACxD,MAAM,SAAS,kBAAkB;CACjC,MAAM,gBAAiB,UACrB,OAAO,UACP,qBAAqB;CAEvB,MAAM,WAAW,GAAG,OAAO,GAAG,EAAE,GAAG;CACnC,MAAM,SAAU,kBACd;CAIF,MAAM,SAAS,MAAM,IAAI,QAAQ;CACjC,IAAI,QAAQ;EACV,MAAM,UAAU,cAAc,QAAa,aAAa;EAIxD,QAAQ,YACN,aACG;GAEH,OAAO,WAAW,cAAc;IAC9B,MAAM,SAAS,GAAG,OAAO,GAAG,EAAE,GAAG;IACjC,MAAM,YACJ,kBACA;IAEF,IAAI,CAAC,WAAW;IAEhB,eAAe,QAAQ,SAAS,EAAE,WAAW;KAC3C,MAAM,OAAO,MAAM,IAAI,MAAM;KAC7B,IAAI,MACF,SACE,cAAc,MAAW,SAAc,CAIzC;IAEJ,CAAC;GACH,CAAC;GAED,OAAO;EACT;EAEA,OAAO;CACT;CAGA,IAAI,QACF,eAAe,UAAU,MAAM,EAAE,WAAW;EAC1C,OAAO,OAAO;CAChB,CAAC;CAIH,MAAM,iBAAsB,IAAI,YAAY,CAAC,GAAG;EAC9C,MAAM,IAAI,SAAS;GACjB,IAAI,SAAS,OAAO,aAAa,aAAa;GAC9C,IAAI,SAAS,YAAY,aAAa;GACtC,IAAI,SAAS,WAAW,aAAa;GACrC,IAAI,SAAS,QAAQ,OAAO;GAC5B,IAAI,SAAS,YAAY,QAAQ,QAAa;GAC9C,OAAO;EACT;EACA,aAAa;CACf,CAAC;CAED,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.mjs","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\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\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/**\n * Dynamically load and transform a locale-keyed dictionary.\n *\n * Works like `useIntlayer` / `useDictionary` but accepts a locale-keyed map\n * of lazy loaders instead of a pre-imported dictionary. Call it inside your\n * render function — the first call triggers a background fetch and returns\n * placeholder values; when the load completes the client notifies all\n * subscribers (including your render loop) so the render runs again with real\n * content. Subsequent calls for the same locale return immediately from cache.\n *\n * Locale switches follow the same two-phase pattern: placeholder on first\n * render, real content after the locale bundle loads.\n *\n * @param dictionaryLoaders - Locale-keyed map of `() => Promise<Dictionary>`.\n * @param key - Dictionary key (used for cache namespacing).\n * @param locale - Optional locale override.\n *\n * @example\n * ```ts\n * import dynDic from '../.intlayer/dynamic_dictionary/app.mjs';\n *\n * const render = () => {\n * const content = useDictionaryDynamic(dynDic, 'app');\n * document.querySelector('h1')!.textContent = String(content.title);\n * };\n *\n * render();\n * getIntlayerClient().subscribe(() => render());\n * ```\n */\nexport const useDictionaryDynamic = <\n const T extends Dictionary,\n const K extends DictionaryKeys,\n const L extends LocalesValues = LocalesValues,\n>(\n dictionaryLoaders: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: L\n): WithOnChange<DeepTransformContent<T['content'], L>> => {\n const client = getIntlayerClient();\n const currentLocale = (locale ??\n client.locale ??\n internationalization.defaultLocale) as L;\n\n const cacheKey = `${String(key)}.${currentLocale}`;\n const loader = (dictionaryLoaders as Record<string, () => Promise<T>>)[\n currentLocale\n ];\n\n // --- Cache hit: return real content synchronously ---\n const cached = cache.get(cacheKey);\n if (cached) {\n const content = getDictionary(cached as T, currentLocale) as WithOnChange<\n DeepTransformContent<T['content'], L>\n >;\n\n content.onChange = (\n callback: (content: DeepTransformContent<T['content'], L>) => void\n ) => {\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(\n getDictionary(dict as T, newLocale as L) as DeepTransformContent<\n T['content'],\n L\n >\n );\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 // Placeholder proxy — safe for any property access while loading.\n const 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 return recursiveProxy as WithOnChange<DeepTransformContent<T['content'], L>>;\n};\n"],"mappings":";;;;;;AAaA,MAAM,wBAAQ,IAAI,IAAwB;;AAG1C,MAAM,2BAAW,IAAI,IAA2B;AAEhD,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,EAAE,MAAM,eAAe;EAC5C,MAAM,IAAI,UAAU,UAAU;EAC9B,SAAS,OAAO,QAAQ;CAC1B,CAAC;CAED,SAAS,IAAI,UAAU,OAAO;CAC9B,OAAO;AACT;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,MAAa,wBAKX,mBACA,KACA,WACwD;CACxD,MAAM,SAAS,kBAAkB;CACjC,MAAM,gBAAiB,UACrB,OAAO,UACP,qBAAqB;CAEvB,MAAM,WAAW,GAAG,OAAO,GAAG,EAAE,GAAG;CACnC,MAAM,SAAU,kBACd;CAIF,MAAM,SAAS,MAAM,IAAI,QAAQ;CACjC,IAAI,QAAQ;EACV,MAAM,UAAU,cAAc,QAAa,aAAa;EAIxD,QAAQ,YACN,aACG;GAEH,OAAO,WAAW,cAAc;IAC9B,MAAM,SAAS,GAAG,OAAO,GAAG,EAAE,GAAG;IACjC,MAAM,YACJ,kBACA;IAEF,IAAI,CAAC,WAAW;IAEhB,eAAe,QAAQ,SAAS,EAAE,WAAW;KAC3C,MAAM,OAAO,MAAM,IAAI,MAAM;KAC7B,IAAI,MACF,SACE,cAAc,MAAW,SAAc,CAIzC;IAEJ,CAAC;GACH,CAAC;GAED,OAAO;EACT;EAEA,OAAO;CACT;CAGA,IAAI,QACF,eAAe,UAAU,MAAM,EAAE,WAAW;EAC1C,OAAO,OAAO;CAChB,CAAC;CAIH,MAAM,iBAAsB,IAAI,YAAY,CAAC,GAAG;EAC9C,MAAM,IAAI,SAAS;GACjB,IAAI,SAAS,OAAO,aAAa,aAAa;GAC9C,IAAI,SAAS,YAAY,aAAa;GACtC,IAAI,SAAS,WAAW,aAAa;GACrC,IAAI,SAAS,QAAQ,OAAO;GAC5B,IAAI,SAAS,YAAY,QAAQ,QAAa;GAC9C,OAAO;EACT;EACA,aAAa;CACf,CAAC;CAED,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { getIntlayerClient } from './installIntlayer';\nimport type { WithOnChange } from './useDictionary';\n\n/**\n * Get the translated content for the given key and optionally subscribe to\n * locale changes via the chainable `.onChange()` method — mirroring the API\n * of `react-intlayer`'s `useIntlayer`.\n *\n * Unlike React (where the hook system automatically re-runs on re-render),\n * vanilla JS has no component lifecycle. The `.onChange()` callback is the\n * explicit equivalent: it is called with fresh content whenever the active\n * locale changes. Use it to patch your DOM or trigger a full re-render.\n *\n * The function returns the current content **directly** (same shape as\n * `getIntlayer(key)`), plus the `.onChange()` helper:\n *\n * ```ts\n * // React\n * const content = useIntlayer('app');\n *\n * // Vanilla — identical surface API, opt-in reactivity via .onChange()\n * const content = useIntlayer('app');\n * const content = useIntlayer('app').onChange((c) => render(c));\n * ```\n *\n * For cleanup (e.g. Vite HMR), subscribe via `getIntlayerClient().subscribe()`\n * and hold the returned unsubscribe function.\n *\n * @param key - Dictionary key registered in your intlayer content files.\n * @param locale - Optional locale override (defaults to the current app locale).\n * @returns The current translated content with an `.onChange()` method.\n *\n * @example\n * ```ts\n * import { installIntlayer, useIntlayer } from 'vanilla-intlayer';\n *\n * installIntlayer();\n *\n * // Static read (no subscription)\n * const content = useIntlayer('homepage');\n * document.querySelector('h1').textContent = String(content.title);\n *\n * // Reactive read — onChange is called on every locale change\n * useIntlayer('homepage').onChange((c) => {\n * document.querySelector('h1').textContent = String(c.title);\n * });\n * ```\n */\nexport const useIntlayer = <T extends DictionaryKeys>(\n key: T,\n locale?: LocalesValues\n): WithOnChange<DeepTransformContent<DictionaryRegistryContent<T>>> => {\n const client = getIntlayerClient();\n const content = getIntlayer(key, locale ?? client.locale) as WithOnChange<\n DeepTransformContent<DictionaryRegistryContent<T>>\n >;\n\n content.onChange = (callback) => {\n client.subscribe((newLocale) => {\n callback(getIntlayer(key, (locale ?? newLocale) as typeof locale));\n });\n return content;\n };\n\n return content;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAa,eACX,KACA,WACqE;CACrE,MAAM,SAAS,kBAAkB;CACjC,MAAM,UAAU,YAAY,KAAK,UAAU,OAAO,MAAM;CAIxD,QAAQ,YAAY,aAAa;EAC/B,OAAO,WAAW,cAAc;GAC9B,SAAS,YAAY,KAAM,UAAU,SAA2B,CAAC;EACnE,CAAC;EACD,OAAO;CACT;CAEA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"useIntlayer.mjs","names":[],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { getIntlayerClient } from './installIntlayer';\nimport type { WithOnChange } from './useDictionary';\n\n/**\n * Get the translated content for the given key and optionally subscribe to\n * locale changes via the chainable `.onChange()` method — mirroring the API\n * of `react-intlayer`'s `useIntlayer`.\n *\n * Unlike React (where the hook system automatically re-runs on re-render),\n * vanilla JS has no component lifecycle. The `.onChange()` callback is the\n * explicit equivalent: it is called with fresh content whenever the active\n * locale changes. Use it to patch your DOM or trigger a full re-render.\n *\n * The function returns the current content **directly** (same shape as\n * `getIntlayer(key)`), plus the `.onChange()` helper:\n *\n * ```ts\n * // React\n * const content = useIntlayer('app');\n *\n * // Vanilla — identical surface API, opt-in reactivity via .onChange()\n * const content = useIntlayer('app');\n * const content = useIntlayer('app').onChange((c) => render(c));\n * ```\n *\n * For cleanup (e.g. Vite HMR), subscribe via `getIntlayerClient().subscribe()`\n * and hold the returned unsubscribe function.\n *\n * @param key - Dictionary key registered in your intlayer content files.\n * @param locale - Optional locale override (defaults to the current app locale).\n * @returns The current translated content with an `.onChange()` method.\n *\n * @example\n * ```ts\n * import { installIntlayer, useIntlayer } from 'vanilla-intlayer';\n *\n * installIntlayer();\n *\n * // Static read (no subscription)\n * const content = useIntlayer('homepage');\n * document.querySelector('h1').textContent = String(content.title);\n *\n * // Reactive read — onChange is called on every locale change\n * useIntlayer('homepage').onChange((c) => {\n * document.querySelector('h1').textContent = String(c.title);\n * });\n * ```\n */\nexport const useIntlayer = <const T extends DictionaryKeys>(\n key: T,\n locale?: LocalesValues\n): WithOnChange<DeepTransformContent<DictionaryRegistryContent<T>>> => {\n const client = getIntlayerClient();\n const content = getIntlayer(key, locale ?? client.locale) as WithOnChange<\n DeepTransformContent<DictionaryRegistryContent<T>>\n >;\n\n content.onChange = (callback) => {\n client.subscribe((newLocale) => {\n callback(getIntlayer(key, (locale ?? newLocale) as typeof locale));\n });\n return content;\n };\n\n return content;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDA,MAAa,eACX,KACA,WACqE;CACrE,MAAM,SAAS,kBAAkB;CACjC,MAAM,UAAU,YAAY,KAAK,UAAU,OAAO,MAAM;CAIxD,QAAQ,YAAY,aAAa;EAC/B,OAAO,WAAW,cAAc;GAC9B,SAAS,YAAY,KAAM,UAAU,SAA2B,CAAC;EACnE,CAAC;EACD,OAAO;CACT;CAEA,OAAO;AACT"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDictionary.mjs","names":["getDictionaryCore"],"sources":["../../src/getDictionary.ts"],"sourcesContent":["import { getDictionary as getDictionaryCore } from '@intlayer/core/interpreter';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n): DeepTransformContent<T['content'], L> =>\n getDictionaryCore(dictionary, locale, getPlugins(locale)) as any;\n"],"mappings":";;;;AAQA,MAAa,iBAIX,YACA,WAEAA,gBAAkB,YAAY,QAAQ,WAAW,MAAM,CAAC"}
|
|
1
|
+
{"version":3,"file":"getDictionary.mjs","names":["getDictionaryCore"],"sources":["../../src/getDictionary.ts"],"sourcesContent":["import { getDictionary as getDictionaryCore } from '@intlayer/core/interpreter';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\nexport const getDictionary = <\n const T extends Dictionary,\n const L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n): DeepTransformContent<T['content'], L> =>\n getDictionaryCore(dictionary, locale, getPlugins(locale)) as any;\n"],"mappings":";;;;AAQA,MAAa,iBAIX,YACA,WAEAA,gBAAkB,YAAY,QAAQ,WAAW,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIntlayer.mjs","names":["getIntlayerCore"],"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import { getIntlayer as getIntlayerCore } from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\nexport const getIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L\n): DeepTransformContent<DictionaryRegistryContent<T>, L> =>\n getIntlayerCore(key, locale, getPlugins(locale)) as any;\n"],"mappings":";;;;AASA,MAAa,eAIX,KACA,WAEAA,cAAgB,KAAK,QAAQ,WAAW,MAAM,CAAC"}
|
|
1
|
+
{"version":3,"file":"getIntlayer.mjs","names":["getIntlayerCore"],"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import { getIntlayer as getIntlayerCore } from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\nexport const getIntlayer = <\n const T extends DictionaryKeys,\n const L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L\n): DeepTransformContent<DictionaryRegistryContent<T>, L> =>\n getIntlayerCore(key, locale, getPlugins(locale)) as any;\n"],"mappings":";;;;AASA,MAAa,eAIX,KACA,WAEAA,cAAgB,KAAK,QAAQ,WAAW,MAAM,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownRenderer.mjs","names":[],"sources":["../../../src/markdown/MarkdownRenderer.ts"],"sourcesContent":["import type { HTMLComponents } from '../html/types';\nimport {
|
|
1
|
+
{"version":3,"file":"MarkdownRenderer.mjs","names":[],"sources":["../../../src/markdown/MarkdownRenderer.ts"],"sourcesContent":["import type { HTMLComponents } from '../html/types';\nimport {\n compileMarkdown,\n type MarkdownCompilerOptions,\n type ParsedMarkdown,\n} from './compiler';\nimport {\n type MarkdownProviderOptions,\n type RenderMarkdownFunction,\n useMarkdown,\n} from './installIntlayerMarkdown';\n\nexport type RenderMarkdownProps = MarkdownProviderOptions & {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: string;\n};\n\n/**\n * Renders markdown to an HTML string without using the global provider.\n *\n * @example\n * ```ts\n * import { renderMarkdown } from 'vanilla-intlayer/markdown';\n *\n * document.querySelector('#content').innerHTML = renderMarkdown('# Hello **World**');\n * ```\n */\nexport const renderMarkdown = (\n content: string | ParsedMarkdown,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n }: RenderMarkdownProps = {}\n): string => {\n const options: MarkdownCompilerOptions = {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n };\n return compileMarkdown(content, options);\n};\n\n/**\n * Returns a render function that uses the global provider's configuration\n * (installed via `installIntlayerMarkdown`), falling back to `compileMarkdown`.\n */\nexport const useMarkdownRenderer = (\n props: RenderMarkdownProps = {}\n): ((content: string | ParsedMarkdown) => string | Promise<string>) => {\n const provider = useMarkdown();\n\n return (content: string | ParsedMarkdown) =>\n provider.renderMarkdown(\n content,\n {\n forceBlock: props.forceBlock,\n forceInline: props.forceInline,\n preserveFrontmatter: props.preserveFrontmatter,\n tagfilter: props.tagfilter,\n },\n props.components,\n props.wrapper\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AA2BA,MAAa,kBACX,SACA,EACE,YACA,aACA,qBACA,cACuB,CAAC,MACf;CAOX,OAAO,gBAAgB,SAAS;EAL9B;EACA;EACA;EACA;CAEoC,CAAC;AACzC;;;;;AAMA,MAAa,uBACX,QAA6B,CAAC,MACuC;CACrE,MAAM,WAAW,YAAY;CAE7B,QAAQ,YACN,SAAS,eACP,SACA;EACE,YAAY,MAAM;EAClB,aAAa,MAAM;EACnB,qBAAqB,MAAM;EAC3B,WAAW,MAAM;CACnB,GACA,MAAM,YACN,MAAM,OACR;AACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import vanillaRuntime from "./runtime.mjs";
|
|
2
|
-
import { RuleType, compileWithOptions, sanitizer as defaultSanitizer, slugify as defaultSlugify } from "@intlayer/core/markdown";
|
|
2
|
+
import { RuleType, compileWithOptions, parseMarkdown as parseMarkdown$1, renderMarkdownAst, sanitizer as defaultSanitizer, slugify as defaultSlugify } from "@intlayer/core/markdown";
|
|
3
3
|
|
|
4
4
|
//#region src/markdown/compiler.ts
|
|
5
5
|
/**
|
|
@@ -8,23 +8,30 @@ import { RuleType, compileWithOptions, sanitizer as defaultSanitizer, slugify as
|
|
|
8
8
|
* Compiles markdown to an HTML string for use with `innerHTML` or the
|
|
9
9
|
* `renderMarkdown` utility.
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
11
|
+
const parseMarkdown = (markdown = "", options = {}) => {
|
|
12
|
+
const { components, namedCodesToUnicode, sanitizer, slugify, ...compilerOptions } = options;
|
|
13
|
+
return parseMarkdown$1(markdown, {
|
|
14
|
+
runtime: vanillaRuntime,
|
|
15
|
+
components,
|
|
16
|
+
namedCodesToUnicode,
|
|
17
|
+
sanitizer,
|
|
18
|
+
slugify
|
|
19
|
+
}, compilerOptions);
|
|
20
|
+
};
|
|
21
|
+
const compileMarkdown = (input = "", options = {}) => {
|
|
22
|
+
if (typeof input === "string") return compileWithOptions(input, vanillaRuntime, options);
|
|
23
|
+
const { components, namedCodesToUnicode, sanitizer, slugify, ...compilerOptions } = options;
|
|
24
|
+
return renderMarkdownAst(input, {
|
|
25
|
+
runtime: vanillaRuntime,
|
|
26
|
+
components,
|
|
27
|
+
namedCodesToUnicode,
|
|
28
|
+
sanitizer,
|
|
29
|
+
slugify
|
|
30
|
+
}, compilerOptions);
|
|
31
|
+
};
|
|
25
32
|
const compiler = compileMarkdown;
|
|
26
33
|
const compile = compileMarkdown;
|
|
27
34
|
|
|
28
35
|
//#endregion
|
|
29
|
-
export { RuleType, compile, compileMarkdown, compiler, defaultSanitizer as sanitizer, defaultSlugify as slugify };
|
|
36
|
+
export { RuleType, compile, compileMarkdown, compiler, parseMarkdown, defaultSanitizer as sanitizer, defaultSlugify as slugify };
|
|
30
37
|
//# sourceMappingURL=compiler.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.mjs","names":[],"sources":["../../../src/markdown/compiler.ts"],"sourcesContent":["/**\n * Vanilla JS adapter for the framework-agnostic markdown processor.\n *\n * Compiles markdown to an HTML string for use with `innerHTML` or the\n * `renderMarkdown` utility.\n */\n\nimport {\n type CompileOptions,\n compileWithOptions,\n sanitizer as defaultSanitizer,\n slugify as defaultSlugify,\n RuleType,\n} from '@intlayer/core/markdown';\nimport { vanillaRuntime } from './runtime';\n\n// Re-export utilities for compatibility\nexport { defaultSanitizer as sanitizer, defaultSlugify as slugify, RuleType };\n\nexport type MarkdownCompilerOptions = CompileOptions;\n\n/**\n * Compile markdown to an HTML string.\n *\n * The resulting string can be inserted into the DOM via `element.innerHTML`\n * or the `renderMarkdown` helper.\n *\n * @example\n * ```ts\n * import { compileMarkdown } from 'vanilla-intlayer/markdown';\n *\n * document.querySelector('#content').innerHTML = compileMarkdown('# Hello **World**');\n * ```\n */\nexport const
|
|
1
|
+
{"version":3,"file":"compiler.mjs","names":["coreParseMarkdown","coreRenderMarkdownAst"],"sources":["../../../src/markdown/compiler.ts"],"sourcesContent":["/**\n * Vanilla JS adapter for the framework-agnostic markdown processor.\n *\n * Compiles markdown to an HTML string for use with `innerHTML` or the\n * `renderMarkdown` utility.\n */\n\nimport {\n type CompileOptions,\n compileWithOptions,\n parseMarkdown as coreParseMarkdown,\n renderMarkdownAst as coreRenderMarkdownAst,\n sanitizer as defaultSanitizer,\n slugify as defaultSlugify,\n type MarkdownContext,\n type ParsedMarkdown,\n RuleType,\n} from '@intlayer/core/markdown';\nimport { vanillaRuntime } from './runtime';\n\n// Re-export utilities for compatibility\nexport { defaultSanitizer as sanitizer, defaultSlugify as slugify, RuleType };\n\nexport type MarkdownCompilerOptions = CompileOptions;\n\n/**\n * Compile markdown to an HTML string.\n *\n * The resulting string can be inserted into the DOM via `element.innerHTML`\n * or the `renderMarkdown` helper.\n *\n * @example\n * ```ts\n * import { compileMarkdown } from 'vanilla-intlayer/markdown';\n *\n * document.querySelector('#content').innerHTML = compileMarkdown('# Hello **World**');\n * ```\n */\nexport type { ParsedMarkdown };\n\nexport const parseMarkdown = (\n markdown: string = '',\n options: MarkdownCompilerOptions = {}\n): ParsedMarkdown => {\n const {\n components,\n namedCodesToUnicode,\n sanitizer,\n slugify,\n ...compilerOptions\n } = options;\n\n const ctx: MarkdownContext<any> = {\n runtime: vanillaRuntime,\n components,\n namedCodesToUnicode,\n sanitizer: sanitizer as any,\n slugify,\n };\n\n return coreParseMarkdown(markdown, ctx, compilerOptions);\n};\n\nexport const compileMarkdown = (\n input: string | ParsedMarkdown = '',\n options: MarkdownCompilerOptions = {}\n): string => {\n if (typeof input === 'string') {\n return compileWithOptions(input, vanillaRuntime, options) as string;\n }\n\n const {\n components,\n namedCodesToUnicode,\n sanitizer,\n slugify,\n ...compilerOptions\n } = options;\n\n const ctx: MarkdownContext<any> = {\n runtime: vanillaRuntime,\n components,\n namedCodesToUnicode,\n sanitizer: sanitizer as any,\n slugify,\n };\n\n return coreRenderMarkdownAst(input, ctx, compilerOptions) as string;\n};\n\n// Aliases for consistency with other adapters\nexport const compiler = compileMarkdown;\nexport const compile = compileMarkdown;\n"],"mappings":";;;;;;;;;;AAwCA,MAAa,iBACX,WAAmB,IACnB,UAAmC,CAAC,MACjB;CACnB,MAAM,EACJ,YACA,qBACA,WACA,SACA,GAAG,oBACD;CAUJ,OAAOA,gBAAkB,UAAU;EAPjC,SAAS;EACT;EACA;EACW;EACX;CAGmC,GAAG,eAAe;AACzD;AAEA,MAAa,mBACX,QAAiC,IACjC,UAAmC,CAAC,MACzB;CACX,IAAI,OAAO,UAAU,UACnB,OAAO,mBAAmB,OAAO,gBAAgB,OAAO;CAG1D,MAAM,EACJ,YACA,qBACA,WACA,SACA,GAAG,oBACD;CAUJ,OAAOC,kBAAsB,OAAO;EAPlC,SAAS;EACT;EACA;EACW;EACX;CAGoC,GAAG,eAAe;AAC1D;AAGA,MAAa,WAAW;AACxB,MAAa,UAAU"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
import { RuleType, compile, compileMarkdown, compiler, parseMarkdown, sanitizer as defaultSanitizer, slugify as defaultSlugify } from "./compiler.mjs";
|
|
1
2
|
import { installIntlayerMarkdown, installIntlayerMarkdownDynamic, useMarkdown } from "./installIntlayerMarkdown.mjs";
|
|
2
3
|
import { renderMarkdown, useMarkdownRenderer } from "./MarkdownRenderer.mjs";
|
|
3
4
|
|
|
4
|
-
export { installIntlayerMarkdown, installIntlayerMarkdownDynamic, renderMarkdown, useMarkdown, useMarkdownRenderer };
|
|
5
|
+
export { RuleType, compile, compileMarkdown, compiler, installIntlayerMarkdown, installIntlayerMarkdownDynamic, parseMarkdown, renderMarkdown, defaultSanitizer as sanitizer, defaultSlugify as slugify, useMarkdown, useMarkdownRenderer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installIntlayerMarkdown.mjs","names":[],"sources":["../../../src/markdown/installIntlayerMarkdown.ts"],"sourcesContent":["import type { HTMLComponents } from '../html/types';\nimport {
|
|
1
|
+
{"version":3,"file":"installIntlayerMarkdown.mjs","names":[],"sources":["../../../src/markdown/installIntlayerMarkdown.ts"],"sourcesContent":["import type { HTMLComponents } from '../html/types';\nimport {\n compileMarkdown,\n type MarkdownCompilerOptions,\n type ParsedMarkdown,\n} from './compiler';\n\nexport type MarkdownProviderOptions = {\n /** Forces the compiler to always output content with a block-level wrapper. */\n forceBlock?: boolean;\n /** Forces the compiler to always output content with an inline wrapper. */\n forceInline?: boolean;\n /** Whether to preserve frontmatter in the markdown content. */\n preserveFrontmatter?: boolean;\n /** Whether to use the GitHub Tag Filter. */\n tagfilter?: boolean;\n};\n\nexport type RenderMarkdownOptions = MarkdownProviderOptions & {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: string;\n};\n\nexport type RenderMarkdownFunction = (\n markdown: string | ParsedMarkdown,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: string\n) => string | Promise<string>;\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerMarkdownProvider | null = null;\n\nexport type IntlayerMarkdownProvider = {\n components?: HTMLComponents<'permissive', {}>;\n renderMarkdown: RenderMarkdownFunction;\n};\n\nexport type IntlayerMarkdownPluginOptions = MarkdownProviderOptions & {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: string;\n renderMarkdown?: RenderMarkdownFunction;\n};\n\n/**\n * Create and return a single IntlayerMarkdownProvider instance.\n */\nexport const createIntlayerMarkdownClient = (\n renderMarkdown: RenderMarkdownFunction,\n components?: HTMLComponents<'permissive', {}>\n): IntlayerMarkdownProvider => {\n if (instance) return instance;\n\n instance = { components, renderMarkdown };\n return instance;\n};\n\n/**\n * Install the Intlayer Markdown provider for your vanilla JS application.\n *\n * @example\n * ```ts\n * import { installIntlayerMarkdown } from 'vanilla-intlayer/markdown';\n *\n * installIntlayerMarkdown({ forceBlock: true });\n * ```\n */\nexport const installIntlayerMarkdown = (\n pluginOptions?: IntlayerMarkdownPluginOptions | RenderMarkdownFunction\n): IntlayerMarkdownProvider => {\n let renderMarkdown: RenderMarkdownFunction;\n let providerComponents: HTMLComponents<'permissive', {}> | undefined;\n\n if (typeof pluginOptions === 'function') {\n renderMarkdown = pluginOptions;\n } else {\n const {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRender,\n } = pluginOptions ?? {};\n\n providerComponents = components;\n\n if (customRender) {\n renderMarkdown = customRender;\n } else {\n const internalOptions: MarkdownCompilerOptions = {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n };\n\n renderMarkdown = (\n markdown,\n options,\n _componentsOverride,\n _wrapperOverride\n ) =>\n compileMarkdown(markdown, {\n ...internalOptions,\n forceBlock: options?.forceBlock ?? internalOptions.forceBlock,\n forceInline: options?.forceInline ?? internalOptions.forceInline,\n preserveFrontmatter:\n options?.preserveFrontmatter ?? internalOptions.preserveFrontmatter,\n tagfilter: options?.tagfilter ?? internalOptions.tagfilter,\n });\n }\n }\n\n return createIntlayerMarkdownClient(renderMarkdown, providerComponents);\n};\n\n/**\n * Access the installed IntlayerMarkdownProvider.\n * Returns a fallback renderer that compiles with default options if no\n * provider has been installed.\n */\nexport const useMarkdown = (): IntlayerMarkdownProvider => {\n if (instance) return instance;\n\n return {\n renderMarkdown: (markdown) =>\n compileMarkdown(markdown as string | ParsedMarkdown),\n };\n};\n\n/**\n * Asynchronously install a markdown renderer whose implementation is loaded\n * via a dynamic `import()`.\n *\n * Use this to keep the markdown compiler out of the initial bundle — the\n * loader is only called the first time this function is executed.\n *\n * The returned promise resolves once the provider is ready. Any calls to\n * `useMarkdown()` before the promise resolves will use the fallback\n * (raw-string) renderer.\n *\n * @param loader - A zero-argument async function that resolves to either a\n * `RenderMarkdownFunction` or an `IntlayerMarkdownPluginOptions` object.\n *\n * @example\n * ```ts\n * // Load a custom markdown renderer (e.g. marked) only when needed\n * await installIntlayerMarkdownDynamic(async () => {\n * const { marked } = await import('marked');\n * return (markdown) => marked(markdown) as string;\n * });\n * ```\n */\nexport const installIntlayerMarkdownDynamic = async (\n loader: () => Promise<IntlayerMarkdownPluginOptions | RenderMarkdownFunction>\n): Promise<IntlayerMarkdownProvider> => {\n if (instance) return instance;\n const pluginOptions = await loader();\n return installIntlayerMarkdown(pluginOptions);\n};\n"],"mappings":";;;;;;AAiCA,IAAI,WAA4C;;;;AAgBhD,MAAa,gCACX,gBACA,eAC6B;CAC7B,IAAI,UAAU,OAAO;CAErB,WAAW;EAAE;EAAY;CAAe;CACxC,OAAO;AACT;;;;;;;;;;;AAYA,MAAa,2BACX,kBAC6B;CAC7B,IAAI;CACJ,IAAI;CAEJ,IAAI,OAAO,kBAAkB,YAC3B,iBAAiB;MACZ;EACL,MAAM,EACJ,YACA,SACA,YACA,aACA,qBACA,WACA,gBAAgB,iBACd,iBAAiB,CAAC;EAEtB,qBAAqB;EAErB,IAAI,cACF,iBAAiB;OACZ;GACL,MAAM,kBAA2C;IAC/C;IACA;IACA;IACA;GACF;GAEA,kBACE,UACA,SACA,qBACA,qBAEA,gBAAgB,UAAU;IACxB,GAAG;IACH,YAAY,SAAS,cAAc,gBAAgB;IACnD,aAAa,SAAS,eAAe,gBAAgB;IACrD,qBACE,SAAS,uBAAuB,gBAAgB;IAClD,WAAW,SAAS,aAAa,gBAAgB;GACnD,CAAC;EACL;CACF;CAEA,OAAO,6BAA6B,gBAAgB,kBAAkB;AACxE;;;;;;AAOA,MAAa,oBAA8C;CACzD,IAAI,UAAU,OAAO;CAErB,OAAO,EACL,iBAAiB,aACf,gBAAgB,QAAmC,EACvD;AACF;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,iCAAiC,OAC5C,WACsC;CACtC,IAAI,UAAU,OAAO;CAErB,OAAO,wBAAwB,MADH,OAAO,CACS;AAC9C"}
|
|
@@ -56,7 +56,7 @@ type WithOnChange<T> = T & {
|
|
|
56
56
|
* document.querySelector('p').textContent = String(content.greeting);
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
|
-
declare const useDictionary: <T extends Dictionary, L extends LocalesValues = DeclaredLocales>(dictionary: T, locale?: L) => WithOnChange<DeepTransformContent<T["content"], L>>;
|
|
59
|
+
declare const useDictionary: <const T extends Dictionary, const L extends LocalesValues = DeclaredLocales>(dictionary: T, locale?: L) => WithOnChange<DeepTransformContent<T["content"], L>>;
|
|
60
60
|
//#endregion
|
|
61
61
|
export { WithOnChange, useDictionary };
|
|
62
62
|
//# sourceMappingURL=useDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/client/useDictionary.ts"],"mappings":";;;;;KASY,YAAA,MAAkB,CAAA;;AAA9B;;;;;;;;;;EAYE,QAAA,GACE,QAAA,aAAqB,UAAA,YAAsB,aAAA,EACzC,OAAA,EAAS,oBAAA,CAAqB,CAAA,aAAc,CAAA,eAE3C,YAAA,CAAa,CAAA;AAAA;;;;;;;;;;;;;;;;;AAAC;AA0CrB;;;;;;;;;;;;;;;;;;;;;;cAAa,aAAA,
|
|
1
|
+
{"version":3,"file":"useDictionary.d.ts","names":[],"sources":["../../../src/client/useDictionary.ts"],"mappings":";;;;;KASY,YAAA,MAAkB,CAAA;;AAA9B;;;;;;;;;;EAYE,QAAA,GACE,QAAA,aAAqB,UAAA,YAAsB,aAAA,EACzC,OAAA,EAAS,oBAAA,CAAqB,CAAA,aAAc,CAAA,eAE3C,YAAA,CAAa,CAAA;AAAA;;;;;;;;;;;;;;;;;AAAC;AA0CrB;;;;;;;;;;;;;;;;;;;;;;cAAa,aAAA,mBACK,UAAA,kBACA,aAAA,GAAgB,eAAA,EAEhC,UAAA,EAAY,CAAA,EACZ,MAAA,GAAS,CAAA,KACR,YAAA,CAAa,oBAAA,CAAqB,CAAA,aAAc,CAAA"}
|
|
@@ -34,7 +34,7 @@ import { Dictionary } from "@intlayer/types/dictionary";
|
|
|
34
34
|
* getIntlayerClient().subscribe(() => render());
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
|
-
declare const useDictionaryDynamic: <T extends Dictionary, K extends DictionaryKeys, L extends LocalesValues = LocalesValues>(dictionaryLoaders: StrictModeLocaleMap<() => Promise<T>>, key: K, locale?: L) => WithOnChange<DeepTransformContent<T["content"], L>>;
|
|
37
|
+
declare const useDictionaryDynamic: <const T extends Dictionary, const K extends DictionaryKeys, const L extends LocalesValues = LocalesValues>(dictionaryLoaders: StrictModeLocaleMap<() => Promise<T>>, key: K, locale?: L) => WithOnChange<DeepTransformContent<T["content"], L>>;
|
|
38
38
|
//#endregion
|
|
39
39
|
export { useDictionaryDynamic };
|
|
40
40
|
//# sourceMappingURL=useDictionaryDynamic.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"mappings":";;;;;;;;AAgEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,oBAAA,
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.d.ts","names":[],"sources":["../../../src/client/useDictionaryDynamic.ts"],"mappings":";;;;;;;;AAgEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,oBAAA,mBACK,UAAA,kBACA,cAAA,kBACA,aAAA,GAAgB,aAAA,EAEhC,iBAAA,EAAmB,mBAAA,OAA0B,OAAA,CAAQ,CAAA,IACrD,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,CAAA,KACR,YAAA,CAAa,oBAAA,CAAqB,CAAA,aAAc,CAAA"}
|
|
@@ -48,7 +48,7 @@ import { DictionaryKeys, DictionaryRegistryContent, LocalesValues } from "@intla
|
|
|
48
48
|
* });
|
|
49
49
|
* ```
|
|
50
50
|
*/
|
|
51
|
-
declare const useIntlayer: <T extends DictionaryKeys>(key: T, locale?: LocalesValues) => WithOnChange<DeepTransformContent<DictionaryRegistryContent<T>>>;
|
|
51
|
+
declare const useIntlayer: <const T extends DictionaryKeys>(key: T, locale?: LocalesValues) => WithOnChange<DeepTransformContent<DictionaryRegistryContent<T>>>;
|
|
52
52
|
//#endregion
|
|
53
53
|
export { useIntlayer };
|
|
54
54
|
//# sourceMappingURL=useIntlayer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../../src/client/useIntlayer.ts"],"mappings":";;;;;;;AAuDA;;;;;;;;;;;;;;;;;;;;;;;AAGgE;;;;;;;;;;;;;;;;;;;;cAHnD,WAAA,
|
|
1
|
+
{"version":3,"file":"useIntlayer.d.ts","names":[],"sources":["../../../src/client/useIntlayer.ts"],"mappings":";;;;;;;AAuDA;;;;;;;;;;;;;;;;;;;;;;;AAGgE;;;;;;;;;;;;;;;;;;;;cAHnD,WAAA,mBAA+B,cAAA,EAC1C,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,aAAA,KACR,YAAA,CAAa,oBAAA,CAAqB,yBAAA,CAA0B,CAAA"}
|
|
@@ -3,7 +3,7 @@ import { DeclaredLocales, LocalesValues } from "@intlayer/types/module_augmentat
|
|
|
3
3
|
import { Dictionary } from "@intlayer/types/dictionary";
|
|
4
4
|
|
|
5
5
|
//#region src/getDictionary.d.ts
|
|
6
|
-
declare const getDictionary: <T extends Dictionary, L extends LocalesValues = DeclaredLocales>(dictionary: T, locale?: L) => DeepTransformContent<T["content"], L>;
|
|
6
|
+
declare const getDictionary: <const T extends Dictionary, const L extends LocalesValues = DeclaredLocales>(dictionary: T, locale?: L) => DeepTransformContent<T["content"], L>;
|
|
7
7
|
//#endregion
|
|
8
8
|
export { getDictionary };
|
|
9
9
|
//# sourceMappingURL=getDictionary.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDictionary.d.ts","names":[],"sources":["../../src/getDictionary.ts"],"mappings":";;;;;cAQa,aAAA,
|
|
1
|
+
{"version":3,"file":"getDictionary.d.ts","names":[],"sources":["../../src/getDictionary.ts"],"mappings":";;;;;cAQa,aAAA,mBACK,UAAA,kBACA,aAAA,GAAgB,eAAA,EAEhC,UAAA,EAAY,CAAA,EACZ,MAAA,GAAS,CAAA,KACR,oBAAA,CAAqB,CAAA,aAAc,CAAA"}
|
|
@@ -2,7 +2,7 @@ import { DeepTransformContent } from "./plugins.js";
|
|
|
2
2
|
import { DeclaredLocales, DictionaryKeys, DictionaryRegistryContent, LocalesValues } from "@intlayer/types/module_augmentation";
|
|
3
3
|
|
|
4
4
|
//#region src/getIntlayer.d.ts
|
|
5
|
-
declare const getIntlayer: <T extends DictionaryKeys, L extends LocalesValues = DeclaredLocales>(key: T, locale?: L) => DeepTransformContent<DictionaryRegistryContent<T>, L>;
|
|
5
|
+
declare const getIntlayer: <const T extends DictionaryKeys, const L extends LocalesValues = DeclaredLocales>(key: T, locale?: L) => DeepTransformContent<DictionaryRegistryContent<T>, L>;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { getIntlayer };
|
|
8
8
|
//# sourceMappingURL=getIntlayer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getIntlayer.d.ts","names":[],"sources":["../../src/getIntlayer.ts"],"mappings":";;;;cASa,WAAA,
|
|
1
|
+
{"version":3,"file":"getIntlayer.d.ts","names":[],"sources":["../../src/getIntlayer.ts"],"mappings":";;;;cASa,WAAA,mBACK,cAAA,kBACA,aAAA,GAAgB,eAAA,EAEhC,GAAA,EAAK,CAAA,EACL,MAAA,GAAS,CAAA,KACR,oBAAA,CAAqB,yBAAA,CAA0B,CAAA,GAAI,CAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { HTMLComponents } from "../html/types.js";
|
|
2
|
+
import { ParsedMarkdown } from "./compiler.js";
|
|
2
3
|
import { MarkdownProviderOptions } from "./installIntlayerMarkdown.js";
|
|
3
4
|
|
|
4
5
|
//#region src/markdown/MarkdownRenderer.d.ts
|
|
@@ -16,7 +17,7 @@ type RenderMarkdownProps = MarkdownProviderOptions & {
|
|
|
16
17
|
* document.querySelector('#content').innerHTML = renderMarkdown('# Hello **World**');
|
|
17
18
|
* ```
|
|
18
19
|
*/
|
|
19
|
-
declare const renderMarkdown: (content: string, {
|
|
20
|
+
declare const renderMarkdown: (content: string | ParsedMarkdown, {
|
|
20
21
|
forceBlock,
|
|
21
22
|
forceInline,
|
|
22
23
|
preserveFrontmatter,
|
|
@@ -26,7 +27,7 @@ declare const renderMarkdown: (content: string, {
|
|
|
26
27
|
* Returns a render function that uses the global provider's configuration
|
|
27
28
|
* (installed via `installIntlayerMarkdown`), falling back to `compileMarkdown`.
|
|
28
29
|
*/
|
|
29
|
-
declare const useMarkdownRenderer: (props?: RenderMarkdownProps) => ((content: string) => string | Promise<string>);
|
|
30
|
+
declare const useMarkdownRenderer: (props?: RenderMarkdownProps) => ((content: string | ParsedMarkdown) => string | Promise<string>);
|
|
30
31
|
//#endregion
|
|
31
32
|
export { RenderMarkdownProps, renderMarkdown, useMarkdownRenderer };
|
|
32
33
|
//# sourceMappingURL=MarkdownRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarkdownRenderer.d.ts","names":[],"sources":["../../../src/markdown/MarkdownRenderer.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"MarkdownRenderer.d.ts","names":[],"sources":["../../../src/markdown/MarkdownRenderer.ts"],"mappings":";;;;;KAYY,mBAAA,GAAsB,uBAAA;EAChC,UAAA,GAAa,cAAc;EAC3B,OAAA;AAAA;;;;;;;;AAAO;AAaT;;cAAa,cAAA,GACX,OAAA,WAAkB,cAAA;EAClB,UAAA;EAAA,WAAA;EAAA,mBAAA;EAAA;AAAA,IAKG,mBAAA;;;;;cAeQ,mBAAA,GACX,KAAA,GAAO,mBAAA,OACJ,OAAA,WAAkB,cAAA,cAA4B,OAAA"}
|
|
@@ -1,23 +1,11 @@
|
|
|
1
|
-
import { CompileOptions, RuleType, sanitizer as defaultSanitizer, slugify as defaultSlugify } from "@intlayer/core/markdown";
|
|
1
|
+
import { CompileOptions, ParsedMarkdown, RuleType, sanitizer as defaultSanitizer, slugify as defaultSlugify } from "@intlayer/core/markdown";
|
|
2
2
|
|
|
3
3
|
//#region src/markdown/compiler.d.ts
|
|
4
4
|
type MarkdownCompilerOptions = CompileOptions;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* or the `renderMarkdown` helper.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```ts
|
|
13
|
-
* import { compileMarkdown } from 'vanilla-intlayer/markdown';
|
|
14
|
-
*
|
|
15
|
-
* document.querySelector('#content').innerHTML = compileMarkdown('# Hello **World**');
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
declare const compileMarkdown: (markdown?: string, options?: MarkdownCompilerOptions) => string;
|
|
19
|
-
declare const compiler: (markdown?: string, options?: MarkdownCompilerOptions) => string;
|
|
20
|
-
declare const compile: (markdown?: string, options?: MarkdownCompilerOptions) => string;
|
|
5
|
+
declare const parseMarkdown: (markdown?: string, options?: MarkdownCompilerOptions) => ParsedMarkdown;
|
|
6
|
+
declare const compileMarkdown: (input?: string | ParsedMarkdown, options?: MarkdownCompilerOptions) => string;
|
|
7
|
+
declare const compiler: (input?: string | ParsedMarkdown, options?: MarkdownCompilerOptions) => string;
|
|
8
|
+
declare const compile: (input?: string | ParsedMarkdown, options?: MarkdownCompilerOptions) => string;
|
|
21
9
|
//#endregion
|
|
22
|
-
export { MarkdownCompilerOptions, RuleType, compile, compileMarkdown, compiler, defaultSanitizer as sanitizer, defaultSlugify as slugify };
|
|
10
|
+
export { MarkdownCompilerOptions, type ParsedMarkdown, RuleType, compile, compileMarkdown, compiler, parseMarkdown, defaultSanitizer as sanitizer, defaultSlugify as slugify };
|
|
23
11
|
//# sourceMappingURL=compiler.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.d.ts","names":[],"sources":["../../../src/markdown/compiler.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"compiler.d.ts","names":[],"sources":["../../../src/markdown/compiler.ts"],"mappings":";;;KAuBY,uBAAA,GAA0B,cAAc;AAAA,cAiBvC,aAAA,GACX,QAAA,WACA,OAAA,GAAS,uBAAA,KACR,cAkBF;AAAA,cAEY,eAAA,GACX,KAAA,YAAgB,cAAA,EAChB,OAAA,GAAS,uBAA4B;AAAA,cA0B1B,QAAA,GAAQ,KAAA,YA3BH,cAAA,EAAc,OAAA,GACrB,uBAAuB;AAAA,cA2BrB,OAAA,GAAO,KAAA,YA5BF,cAAA,EAAc,OAAA,GACrB,uBAAuB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MarkdownCompilerOptions, ParsedMarkdown, RuleType, compile, compileMarkdown, compiler, parseMarkdown, sanitizer as defaultSanitizer, slugify as defaultSlugify } from "./compiler.js";
|
|
1
2
|
import { IntlayerMarkdownPluginOptions, IntlayerMarkdownProvider, MarkdownProviderOptions, RenderMarkdownFunction, installIntlayerMarkdown, installIntlayerMarkdownDynamic, useMarkdown } from "./installIntlayerMarkdown.js";
|
|
2
3
|
import { RenderMarkdownProps, renderMarkdown, useMarkdownRenderer } from "./MarkdownRenderer.js";
|
|
3
|
-
export { type IntlayerMarkdownPluginOptions, type IntlayerMarkdownProvider, type MarkdownProviderOptions, type RenderMarkdownFunction, type RenderMarkdownProps, installIntlayerMarkdown, installIntlayerMarkdownDynamic, renderMarkdown, useMarkdown, useMarkdownRenderer };
|
|
4
|
+
export { type IntlayerMarkdownPluginOptions, type IntlayerMarkdownProvider, MarkdownCompilerOptions, type MarkdownProviderOptions, type ParsedMarkdown, type RenderMarkdownFunction, type RenderMarkdownProps, RuleType, compile, compileMarkdown, compiler, installIntlayerMarkdown, installIntlayerMarkdownDynamic, parseMarkdown, renderMarkdown, defaultSanitizer as sanitizer, defaultSlugify as slugify, useMarkdown, useMarkdownRenderer };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { HTMLComponents } from "../html/types.js";
|
|
2
|
+
import { ParsedMarkdown } from "./compiler.js";
|
|
2
3
|
|
|
3
4
|
//#region src/markdown/installIntlayerMarkdown.d.ts
|
|
4
5
|
type MarkdownProviderOptions = {
|
|
@@ -11,7 +12,7 @@ type RenderMarkdownOptions = MarkdownProviderOptions & {
|
|
|
11
12
|
components?: HTMLComponents<'permissive', {}>;
|
|
12
13
|
wrapper?: string;
|
|
13
14
|
};
|
|
14
|
-
type RenderMarkdownFunction = (markdown: string, options?: MarkdownProviderOptions, components?: HTMLComponents<'permissive', {}>, wrapper?: string) => string | Promise<string>;
|
|
15
|
+
type RenderMarkdownFunction = (markdown: string | ParsedMarkdown, options?: MarkdownProviderOptions, components?: HTMLComponents<'permissive', {}>, wrapper?: string) => string | Promise<string>;
|
|
15
16
|
type IntlayerMarkdownProvider = {
|
|
16
17
|
components?: HTMLComponents<'permissive', {}>;
|
|
17
18
|
renderMarkdown: RenderMarkdownFunction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installIntlayerMarkdown.d.ts","names":[],"sources":["../../../src/markdown/installIntlayerMarkdown.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"installIntlayerMarkdown.d.ts","names":[],"sources":["../../../src/markdown/installIntlayerMarkdown.ts"],"mappings":";;;;KAOY,uBAAA;iFAEV,UAAA,YAFiC;EAIjC,WAAA,YAJiC;EAMjC,mBAAA,YAFA;EAIA,SAAA;AAAA;AAAA,KAGU,qBAAA,GAAwB,uBAAA;EAClC,UAAA,GAAa,cAAc;EAC3B,OAAA;AAAA;AAAA,KAGU,sBAAA,IACV,QAAA,WAAmB,cAAA,EACnB,OAAA,GAAU,uBAAA,EACV,UAAA,GAAa,cAAA,oBACb,OAAA,uBACY,OAAA;AAAA,KAOF,wBAAA;EACV,UAAA,GAAa,cAAA;EACb,cAAA,EAAgB,sBAAsB;AAAA;AAAA,KAG5B,6BAAA,GAAgC,uBAAA;EAC1C,UAAA,GAAa,cAAA;EACb,OAAA;EACA,cAAA,GAAiB,sBAAA;AAAA;;;;cAMN,4BAAA,GACX,cAAA,EAAgB,sBAAA,EAChB,UAAA,GAAa,cAAA,uBACZ,wBAAA;;;;;;;;;;;cAiBU,uBAAA,GACX,aAAA,GAAgB,6BAAA,GAAgC,sBAAA,KAC/C,wBAAA;;AA3CkB;AAOrB;;;cA0Fa,WAAA,QAAkB,wBAO9B;;;;;;AA/FuC;AAGxC;;;;;;;;;;;;;;;AAGyC;AAMzC;cA4Ga,8BAAA,GACX,MAAA,QAAc,OAAA,CAAQ,6BAAA,GAAgC,sBAAA,MACrD,OAAA,CAAQ,wBAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vanilla-intlayer",
|
|
3
|
-
"version": "8.11.
|
|
3
|
+
"version": "8.11.2",
|
|
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": [
|
|
@@ -101,11 +101,11 @@
|
|
|
101
101
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
102
102
|
},
|
|
103
103
|
"dependencies": {
|
|
104
|
-
"@intlayer/api": "8.11.
|
|
105
|
-
"@intlayer/config": "8.11.
|
|
106
|
-
"@intlayer/core": "8.11.
|
|
107
|
-
"@intlayer/editor": "8.11.
|
|
108
|
-
"@intlayer/types": "8.11.
|
|
104
|
+
"@intlayer/api": "8.11.2",
|
|
105
|
+
"@intlayer/config": "8.11.2",
|
|
106
|
+
"@intlayer/core": "8.11.2",
|
|
107
|
+
"@intlayer/editor": "8.11.2",
|
|
108
|
+
"@intlayer/types": "8.11.2"
|
|
109
109
|
},
|
|
110
110
|
"devDependencies": {
|
|
111
111
|
"@types/node": "25.9.1",
|
|
@@ -113,12 +113,12 @@
|
|
|
113
113
|
"@utils/ts-config-types": "1.0.4",
|
|
114
114
|
"@utils/tsdown-config": "1.0.4",
|
|
115
115
|
"rimraf": "6.1.3",
|
|
116
|
-
"tsdown": "0.22.
|
|
116
|
+
"tsdown": "0.22.1",
|
|
117
117
|
"typescript": "6.0.3",
|
|
118
118
|
"vitest": "4.1.7"
|
|
119
119
|
},
|
|
120
120
|
"peerDependencies": {
|
|
121
|
-
"intlayer": "8.11.
|
|
121
|
+
"intlayer": "8.11.2"
|
|
122
122
|
},
|
|
123
123
|
"peerDependenciesMeta": {
|
|
124
124
|
"intlayer": {
|