svelte-intlayer 8.11.0 → 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.
@@ -17,6 +17,6 @@ import type { LocalesValues } from '@intlayer/types/module_augmentation';
17
17
  * ```
18
18
  */
19
19
  export declare const setupIntlayer: (initialLocale?: LocalesValues) => {
20
- readonly locale: "id" | "cy" | "hr" | "th" | "tr" | "tt" | "mi" | "mn" | "ms" | "af" | "af-ZA" | "ar" | "ar-AE" | "ar-BH" | "ar-DZ" | "ar-EG" | "ar-IQ" | "ar-JO" | "ar-KW" | "ar-LB" | "ar-LY" | "ar-MA" | "ar-OM" | "ar-QA" | "ar-SA" | "ar-SY" | "ar-TN" | "ar-YE" | "az" | "az-AZ" | "be" | "be-BY" | "bg" | "bg-BG" | "bs" | "bs-BA" | "ca" | "ca-ES" | "cs" | "cs-CZ" | "cy-GB" | "da" | "da-DK" | "de" | "de-AT" | "de-CH" | "de-DE" | "de-LI" | "de-LU" | "dv" | "dv-MV" | "el" | "el-GR" | "en" | "en-AU" | "en-BZ" | "en-CA" | "en-CB" | "en-GB" | "en-IE" | "en-JM" | "en-NZ" | "en-PH" | "en-TT" | "en-US" | "en-ZA" | "en-ZW" | "eo" | "es" | "es-AR" | "es-BO" | "es-CL" | "es-CO" | "es-CR" | "es-DO" | "es-EC" | "es-ES" | "es-GT" | "es-HN" | "es-MX" | "es-NI" | "es-PA" | "es-PE" | "es-PR" | "es-PY" | "es-SV" | "es-UY" | "es-VE" | "et" | "et-EE" | "eu" | "eu-ES" | "fa" | "fa-IR" | "fi" | "fi-FI" | "fo" | "fo-FO" | "fr" | "fr-BE" | "fr-CA" | "fr-CH" | "fr-FR" | "fr-LU" | "fr-MC" | "ga" | "ga-IE" | "gd" | "gd-GB" | "gl" | "gl-ES" | "gu" | "gu-IN" | "he" | "he-IL" | "hi" | "hi-IN" | "hr-BA" | "hr-HR" | "hu" | "hu-HU" | "hy" | "hy-AM" | "id-ID" | "is" | "is-IS" | "it" | "it-CH" | "it-IT" | "ja" | "ja-JP" | "ka" | "ka-GE" | "kk" | "kk-KZ" | "kn" | "kn-IN" | "ko" | "ko-KR" | "kok" | "kok-IN" | "ku" | "ku-TR" | "ky" | "ky-KG" | "lt" | "lt-LT" | "lv" | "lv-LV" | "mi-NZ" | "mk" | "mk-MK" | "mn-MN" | "mr" | "mr-IN" | "ms-BN" | "ms-MY" | "mt" | "mt-MT" | "ml" | "ml-IN" | "no" | "nb" | "nb-NO" | "nl" | "nl-BE" | "nl-NL" | "nn" | "nn-NO" | "ns" | "ns-ZA" | "pa" | "pa-IN" | "pl" | "pl-PL" | "ps" | "ps-AR" | "pt" | "pt-BR" | "pt-PT" | "qu" | "qu-BO" | "qu-EC" | "qu-PE" | "ro" | "ro-RO" | "ro-MD" | "rm" | "rm-CH" | "ru" | "ru-RU" | "ru-MD" | "sa" | "sa-IN" | "se" | "se-FI" | "se-NO" | "se-SE" | "hsb" | "hsb-DE" | "dsb" | "dsb-DE" | "sk" | "sk-SK" | "sl" | "sl-SI" | "sq" | "sq-AL" | "sr" | "sr-BA" | "sr-SP" | "sv" | "sv-FI" | "sv-SE" | "sw" | "sw-KE" | "syr" | "syr-SY" | "ta" | "ta-IN" | "te" | "te-IN" | "th-TH" | "tl" | "tl-PH" | "tn" | "tn-ZA" | "tr-TR" | "tt-RU" | "ts" | "uk" | "uk-UA" | "ur" | "ur-PK" | "uz" | "uz-UZ" | "vi" | "vi-VN" | "ve" | "ve-ZA" | "xh" | "xh-ZA" | "zh" | "zh-Hans" | "zh-CN" | "zh-HK" | "zh-MO" | "zh-SG" | "zh-Hant" | "zu" | "zu-ZA" | "bn" | "bn-BD" | "bn-IN" | "bn-MM" | "my" | "my-MM" | "km" | "km-KH" | "lo" | "lo-LA" | "yo" | "yo-NG" | "yi" | "yi-001" | "am" | "am-ET" | "ne" | "ne-NP" | "si" | "si-LK" | "sr-Cyrl" | "sr-RS" | "en-IN" | "en-SG" | "en-HK" | "en-NG" | "en-PK" | "en-MY" | "en-BW" | "en-KE" | "en-TZ" | "en-GH" | "en-UG" | "es-CU" | "es-US" | "pt-GW" | "pt-MZ" | "pt-ST" | "pt-CV" | "pt-TL" | "pt-MO" | "zh-TW" | "ar-MR" | "ar-PS" | "ar-SD" | "ar-DJ" | "ar-SO" | "ar-TD" | "ar-KM" | "mg-MG" | (string & {});
20
+ readonly locale: any;
21
21
  setLocale: (newLocale: LocalesValues) => void;
22
22
  };
@@ -8,4 +8,4 @@ import type { DeepTransformContent } from '../plugins';
8
8
  * @param locale The target locale (optional, uses context or store locale)
9
9
  * @returns Reactive store with transformed dictionary content
10
10
  */
11
- export declare const useDictionary: <T extends Dictionary>(dictionary: T, locale?: LocalesValues) => Readable<DeepTransformContent<T["content"]>>;
11
+ export declare const useDictionary: <const T extends Dictionary>(dictionary: T, locale?: LocalesValues) => Readable<DeepTransformContent<T["content"]>>;
@@ -8,4 +8,4 @@ import { type Readable } from 'svelte/store';
8
8
  * @param locale Target locale (optional)
9
9
  * @returns Reactive store with loaded dictionary content
10
10
  */
11
- export declare const useDictionaryAsync: <T extends Dictionary>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, locale?: LocalesValues) => Promise<Readable<T | null>>;
11
+ export declare const useDictionaryAsync: <const T extends Dictionary>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, locale?: LocalesValues) => Promise<Readable<T | null>>;
@@ -10,7 +10,7 @@ import type { DeepTransformContent } from '../plugins';
10
10
  * @param locale - Optional fixed locale. If not provided, follows the global intlayerStore.
11
11
  * @returns Readable store with the loaded dictionary content
12
12
  */
13
- export declare function useDictionaryDynamic<T extends Dictionary>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, _key: DictionaryKeys, locale?: LocalesValues): Readable<DeepTransformContent<T['content']> & {
13
+ export declare function useDictionaryDynamic<const T extends Dictionary>(dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>, _key: DictionaryKeys, locale?: LocalesValues): Readable<DeepTransformContent<T['content']> & {
14
14
  isLoading: boolean;
15
15
  error: Error | null;
16
16
  }>;
@@ -20,4 +20,4 @@ import type { DeepTransformContent } from '../plugins';
20
20
  * <div>{$content.myField.value}</div>
21
21
  * ```
22
22
  */
23
- export declare const useIntlayer: <T extends DictionaryKeys>(key: T, locale?: LocalesValues) => Readable<DeepTransformContent<DictionaryRegistryContent<T>>>;
23
+ export declare const useIntlayer: <const T extends DictionaryKeys>(key: T, locale?: LocalesValues) => Readable<DeepTransformContent<DictionaryRegistryContent<T>>>;
@@ -2,13 +2,13 @@ import type { LocalesValues } from '@intlayer/types/module_augmentation';
2
2
  /**
3
3
  * Get the locale cookie
4
4
  */
5
- export declare const localeInStorage: import("@intlayer/types").Locale | undefined;
5
+ export declare const localeInStorage: import("intlayer").Locale | undefined;
6
6
  /**
7
7
  * @deprecated Use localeInStorage instead
8
8
  *
9
9
  * Get the locale cookie
10
10
  */
11
- export declare const localeCookie: import("@intlayer/types").Locale | undefined;
11
+ export declare const localeCookie: import("intlayer").Locale | undefined;
12
12
  /**
13
13
  * Set the locale cookie
14
14
  */
@@ -1,5 +1,4 @@
1
- import { localeStorageOptions } from '@intlayer/core/localization';
2
- import { getLocaleFromStorageClient, LocaleStorageClient, setLocaleInStorageClient as setLocaleInStorageCore, } from '@intlayer/core/utils';
1
+ import { getLocaleFromStorageClient, LocaleStorageClient, localeStorageOptions, setLocaleInStorageClient as setLocaleInStorageCore, } from '@intlayer/core/utils';
3
2
  import { readable } from 'svelte/store';
4
3
  /**
5
4
  * Get the locale cookie
@@ -1,3 +1,3 @@
1
1
  export declare const useCompact: () => import("svelte/store").Readable<(value: string | number, options?: (Intl.NumberFormatOptions & {
2
- locale?: import("@intlayer/types").LocalesValues;
2
+ locale?: import("intlayer").LocalesValues;
3
3
  }) | undefined) => string>;
@@ -1,3 +1,3 @@
1
1
  export declare const useCurrency: () => import("svelte/store").Readable<(value: string | number, options?: (Intl.NumberFormatOptions & {
2
- locale?: import("@intlayer/types").LocalesValues;
2
+ locale?: import("intlayer").LocalesValues;
3
3
  }) | undefined) => string>;
@@ -5,5 +5,5 @@
5
5
  * A store containing a date/time formatting function bound to the active locale.
6
6
  */
7
7
  export declare const useDate: () => import("svelte/store").Readable<(date: string | number | Date, options?: import("@intlayer/core/formatters").DateTimePreset | (Intl.DateTimeFormatOptions & {
8
- locale?: import("@intlayer/types").LocalesValues;
8
+ locale?: import("intlayer").LocalesValues;
9
9
  }) | undefined) => string>;
@@ -3,5 +3,5 @@ export declare const useList: () => import("svelte/store").Readable<(values: (st
3
3
  type?: "conjunction" | "disjunction" | "unit";
4
4
  style?: "long" | "short" | "narrow";
5
5
  } & {
6
- locale?: import("@intlayer/types").LocalesValues;
6
+ locale?: import("intlayer").LocalesValues;
7
7
  }) | undefined) => string>;
@@ -5,5 +5,5 @@
5
5
  * A store containing a number formatting function bound to the active locale.
6
6
  */
7
7
  export declare const useNumber: () => import("svelte/store").Readable<(value: string | number, args_1?: (Intl.NumberFormatOptions & {
8
- locale?: import("@intlayer/types").LocalesValues;
8
+ locale?: import("intlayer").LocalesValues;
9
9
  }) | undefined) => string>;
@@ -1,3 +1,3 @@
1
1
  export declare const usePercentage: () => import("svelte/store").Readable<(value: string | number, args_1?: (Intl.NumberFormatOptions & {
2
- locale?: import("@intlayer/types").LocalesValues;
2
+ locale?: import("intlayer").LocalesValues;
3
3
  }) | undefined) => string>;
@@ -1,4 +1,4 @@
1
1
  export declare const useRelativeTime: () => import("svelte/store").Readable<(from: string | number | Date, to?: string | number | Date | undefined, options?: (Intl.RelativeTimeFormatOptions & {
2
- locale?: import("@intlayer/types").LocalesValues;
2
+ locale?: import("intlayer").LocalesValues;
3
3
  unit?: Intl.RelativeTimeFormatUnit;
4
4
  }) | undefined) => string>;
@@ -1,3 +1,3 @@
1
1
  export declare const useUnit: () => import("svelte/store").Readable<(value: string | number, options?: (Intl.NumberFormatOptions & {
2
- locale?: import("@intlayer/types").LocalesValues;
2
+ locale?: import("intlayer").LocalesValues;
3
3
  }) | undefined) => string>;
@@ -7,4 +7,4 @@ import { type DeepTransformContent } from './plugins';
7
7
  * @param locale The target locale (optional, defaults to current locale)
8
8
  * @returns Transformed dictionary content optimized for Svelte
9
9
  */
10
- export declare const getDictionary: <T extends Dictionary, L extends LocalesValues = DeclaredLocales>(dictionary: T, locale?: L) => DeepTransformContent<T["content"]>;
10
+ export declare const getDictionary: <const T extends Dictionary, const L extends LocalesValues = DeclaredLocales>(dictionary: T, locale?: L) => DeepTransformContent<T["content"]>;
@@ -6,4 +6,4 @@ import { type DeepTransformContent } from './plugins';
6
6
  * @param locale The target locale (optional)
7
7
  * @returns Transformed dictionary content optimized for Svelte
8
8
  */
9
- export declare const getIntlayer: <T extends DictionaryKeys, L extends LocalesValues = DeclaredLocales>(key: T, locale?: L) => DeepTransformContent<DictionaryRegistryContent<T>>;
9
+ export declare const getIntlayer: <const T extends DictionaryKeys, const L extends LocalesValues = DeclaredLocales>(key: T, locale?: L) => DeepTransformContent<DictionaryRegistryContent<T>>;
@@ -2,7 +2,9 @@
2
2
  import type { HTMLComponents } from '../html/types';
3
3
  import { getMarkdownContext } from './context';
4
4
 
5
- export let value: string;
5
+ import type { ParsedMarkdown } from './compiler';
6
+
7
+ export let value: string | ParsedMarkdown;
6
8
  export const components: HTMLComponents<'permissive', {}> | undefined =
7
9
  undefined;
8
10
  export const wrapper: any = undefined;
@@ -1,4 +1,5 @@
1
1
  import type { HTMLComponents } from '../html/types';
2
+ import type { ParsedMarkdown } from './compiler';
2
3
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
4
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
5
  $$bindings?: Bindings;
@@ -13,7 +14,7 @@ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> =
13
14
  z_$$bindings?: Bindings;
14
15
  }
15
16
  declare const MarkdownRenderer: $$__sveltets_2_IsomorphicComponent<{
16
- value: string;
17
+ value: string | ParsedMarkdown;
17
18
  components?: HTMLComponents<"permissive", {}> | undefined;
18
19
  wrapper?: any;
19
20
  forceBlock?: boolean | undefined;
@@ -3,9 +3,11 @@ import type { KeyPath } from '@intlayer/types/keyPath';
3
3
  import ContentSelector from '../editor/ContentSelector.svelte';
4
4
  import MarkdownRenderer from './MarkdownRenderer.svelte';
5
5
 
6
+ import type { ParsedMarkdown } from './compiler';
7
+
6
8
  export let dictionaryKey: string;
7
9
  export let keyPath: KeyPath[];
8
- export let value: string;
10
+ export let value: string | ParsedMarkdown;
9
11
 
10
12
  $: overrides = { ...$$restProps };
11
13
  </script>
@@ -1,4 +1,5 @@
1
1
  import type { KeyPath } from '@intlayer/types/keyPath';
2
+ import type { ParsedMarkdown } from './compiler';
2
3
  interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
3
4
  new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
4
5
  $$bindings?: Bindings;
@@ -16,7 +17,7 @@ declare const MarkdownWithSelector: $$__sveltets_2_IsomorphicComponent<{
16
17
  [x: string]: any;
17
18
  dictionaryKey: string;
18
19
  keyPath: KeyPath[];
19
- value: string;
20
+ value: string | ParsedMarkdown;
20
21
  }, {
21
22
  [evt: string]: CustomEvent<any>;
22
23
  }, {}, {}, string>;
@@ -1,4 +1,7 @@
1
+ import { type ParsedMarkdown } from '@intlayer/core/markdown';
1
2
  /**
2
3
  * Compile markdown to HTML strings for Svelte.
3
4
  */
4
- export declare const compileMarkdown: (markdown?: string, options?: any) => unknown;
5
+ export type { ParsedMarkdown };
6
+ export declare const parseMarkdown: (markdown?: string, options?: any) => ParsedMarkdown;
7
+ export declare const compileMarkdown: (input?: string | ParsedMarkdown, options?: any) => unknown;
@@ -1,6 +1,27 @@
1
- import { compileWithOptions } from '@intlayer/core/markdown';
1
+ import { compileWithOptions, parseMarkdown as coreParseMarkdown, renderMarkdownAst as coreRenderMarkdownAst, } from '@intlayer/core/markdown';
2
2
  import { svelteHtmlRuntime } from './runtime';
3
- /**
4
- * Compile markdown to HTML strings for Svelte.
5
- */
6
- export const compileMarkdown = (markdown = '', options = {}) => compileWithOptions(markdown, svelteHtmlRuntime, options);
3
+ export const parseMarkdown = (markdown = '', options = {}) => {
4
+ const { components, namedCodesToUnicode, sanitizer, slugify, ...compilerOptions } = options;
5
+ const ctx = {
6
+ runtime: svelteHtmlRuntime,
7
+ components,
8
+ namedCodesToUnicode,
9
+ sanitizer: sanitizer,
10
+ slugify,
11
+ };
12
+ return coreParseMarkdown(markdown, ctx, compilerOptions);
13
+ };
14
+ export const compileMarkdown = (input = '', options = {}) => {
15
+ if (typeof input === 'string') {
16
+ return compileWithOptions(input, svelteHtmlRuntime, options);
17
+ }
18
+ const { components, namedCodesToUnicode, sanitizer, slugify, ...compilerOptions } = options;
19
+ const ctx = {
20
+ runtime: svelteHtmlRuntime,
21
+ components,
22
+ namedCodesToUnicode,
23
+ sanitizer: sanitizer,
24
+ slugify,
25
+ };
26
+ return coreRenderMarkdownAst(input, ctx, compilerOptions);
27
+ };
@@ -1,5 +1,6 @@
1
1
  import { type ComponentType } from 'svelte';
2
2
  import type { HTMLComponents } from '../html/types';
3
+ import { type ParsedMarkdown } from './compiler';
3
4
  export declare const MARKDOWN_CONTEXT_KEY: unique symbol;
4
5
  export type MarkdownProviderOptions = {
5
6
  forceBlock?: boolean;
@@ -13,7 +14,7 @@ export type RenderMarkdownOptions = MarkdownProviderOptions & {
13
14
  };
14
15
  export interface MarkdownContext {
15
16
  components?: HTMLComponents<'permissive', {}>;
16
- renderMarkdown: (markdown: string, options?: MarkdownProviderOptions, components?: HTMLComponents<'permissive', {}>, wrapper?: string | ComponentType) => string | Promise<string>;
17
+ renderMarkdown: (markdown: string | ParsedMarkdown, options?: MarkdownProviderOptions, components?: HTMLComponents<'permissive', {}>, wrapper?: string | ComponentType) => string | Promise<string>;
17
18
  }
18
19
  export declare const getMarkdownContext: () => MarkdownContext;
19
20
  export declare const setMarkdownContext: (context: MarkdownContext) => void;
@@ -1,8 +1,10 @@
1
1
  export { getMarkdownContext, type MarkdownContext, type RenderMarkdownOptions, setMarkdownContext, setMarkdownContext as setIntlayerMarkdown, } from './context';
2
+ import { type ParsedMarkdown } from './compiler';
2
3
  import { type RenderMarkdownOptions } from './context';
4
+ export * from './compiler';
3
5
  export { default as MarkdownMetadataRenderer } from './MarkdownMetadataRenderer.svelte';
4
6
  export { default as MarkdownProvider } from './MarkdownProvider.svelte';
5
7
  export { default as MarkdownRenderer } from './MarkdownRenderer.svelte';
6
8
  export type RenderMarkdownProps = RenderMarkdownOptions;
7
- export declare const renderMarkdown: (markdown?: string, options?: any) => unknown;
8
- export declare const useMarkdownRenderer: (options?: RenderMarkdownProps) => (content: string) => string | Promise<string>;
9
+ export declare const renderMarkdown: (input?: string | ParsedMarkdown, options?: any) => unknown;
10
+ export declare const useMarkdownRenderer: (options?: RenderMarkdownProps) => (content: string | ParsedMarkdown) => string | Promise<string>;
@@ -1,6 +1,7 @@
1
1
  export { getMarkdownContext, setMarkdownContext, setMarkdownContext as setIntlayerMarkdown, } from './context';
2
2
  import { compileMarkdown } from './compiler';
3
3
  import { getMarkdownContext } from './context';
4
+ export * from './compiler';
4
5
  export { default as MarkdownMetadataRenderer } from './MarkdownMetadataRenderer.svelte';
5
6
  export { default as MarkdownProvider } from './MarkdownProvider.svelte';
6
7
  export { default as MarkdownRenderer } from './MarkdownRenderer.svelte';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-intlayer",
3
- "version": "8.11.0",
3
+ "version": "8.11.2",
4
4
  "description": "Easily internationalize i18n your Svelte applications with type-safe multilingual content management.",
5
5
  "keywords": [
6
6
  "intlayer",
@@ -82,11 +82,11 @@
82
82
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
83
83
  },
84
84
  "dependencies": {
85
- "@intlayer/api": "8.11.0",
86
- "@intlayer/config": "8.11.0",
87
- "@intlayer/core": "8.11.0",
88
- "@intlayer/editor": "8.11.0",
89
- "@intlayer/types": "8.11.0"
85
+ "@intlayer/api": "8.11.2",
86
+ "@intlayer/config": "8.11.2",
87
+ "@intlayer/core": "8.11.2",
88
+ "@intlayer/editor": "8.11.2",
89
+ "@intlayer/types": "8.11.2"
90
90
  },
91
91
  "devDependencies": {
92
92
  "@sveltejs/adapter-auto": "7.0.1",
@@ -99,7 +99,7 @@
99
99
  "rimraf": "6.1.3",
100
100
  "svelte": "5.55.8",
101
101
  "svelte-check": "4.4.8",
102
- "tsdown": "0.22.00",
102
+ "tsdown": "0.22.1",
103
103
  "typescript": "6.0.3",
104
104
  "vite": "8.0.14",
105
105
  "vitest": "4.1.7"