svelte-intlayer 8.3.1 → 8.3.3

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.
@@ -26,7 +26,7 @@ type useLocaleProps = {
26
26
  export declare const useLocale: ({ isCookieEnabled, onLocaleChange, }?: useLocaleProps) => {
27
27
  locale: import("svelte/store").Readable<LocalesValues>;
28
28
  setLocale: (locale: LocalesValues) => void;
29
- defaultLocale: import("intlayer").Locale;
30
- availableLocales: import("intlayer").Locale[];
29
+ defaultLocale: import("@intlayer/types/allLocales").Locale;
30
+ availableLocales: import("@intlayer/types/allLocales").Locale[];
31
31
  };
32
32
  export {};
@@ -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").Locale | undefined;
5
+ export declare const localeInStorage: import("@intlayer/types/allLocales").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").Locale | undefined;
11
+ export declare const localeCookie: import("@intlayer/types/allLocales").Locale | undefined;
12
12
  /**
13
13
  * Set the locale cookie
14
14
  */
@@ -24,7 +24,7 @@ export const useCrossFrameState = (key, initialState, options = { emit: true, re
24
24
  const state = writable(initialValue);
25
25
  const communicatorStore = useCommunicator();
26
26
  const broadcastState = (value) => {
27
- const { postMessage, senderId } = get(communicatorStore);
27
+ const { postMessage, senderId } = get(communicatorStore) ?? {};
28
28
  if (!emit ||
29
29
  typeof postMessage !== 'function' ||
30
30
  typeof value === 'undefined') {
@@ -45,7 +45,7 @@ export const useCrossFrameState = (key, initialState, options = { emit: true, re
45
45
  });
46
46
  };
47
47
  const postState = () => {
48
- const { postMessage, senderId } = get(communicatorStore);
48
+ const { postMessage, senderId } = get(communicatorStore) ?? {};
49
49
  if (typeof postMessage !== 'function')
50
50
  return;
51
51
  postMessage({
@@ -58,21 +58,21 @@ export const useCrossFrameState = (key, initialState, options = { emit: true, re
58
58
  broadcastState(initialValue);
59
59
  // If receiving, ask for state
60
60
  if (receive && typeof get(state) === 'undefined') {
61
- const { postMessage, senderId } = get(communicatorStore);
61
+ const { postMessage, senderId } = get(communicatorStore) ?? {};
62
62
  if (typeof postMessage === 'function') {
63
63
  postMessage({ type: `${key}/get`, senderId }, '*');
64
64
  }
65
65
  }
66
66
  // Listen for updates
67
67
  const listenerKey = receive ? `${key}/post` : `${key}/ignore`;
68
- const listener = useCrossFrameMessageListener(listenerKey, (data) => {
68
+ useCrossFrameMessageListener(listenerKey, (data) => {
69
69
  if (receive) {
70
70
  state.set(data);
71
71
  }
72
72
  });
73
73
  // Listen for requests
74
74
  const getListenerKey = emit ? `${key}/get` : `${key}/ignore`;
75
- const getListener = useCrossFrameMessageListener(getListenerKey, (_) => {
75
+ useCrossFrameMessageListener(getListenerKey, (_) => {
76
76
  if (emit) {
77
77
  broadcastState(get(state));
78
78
  }
@@ -1,12 +1,10 @@
1
- import { type Plugins } from '@intlayer/core/interpreter';
2
- import type { DeclaredLocales, LocalesValues } from '@intlayer/types/module_augmentation';
3
1
  import type { Dictionary } from '@intlayer/types/dictionary';
2
+ import type { DeclaredLocales, LocalesValues } from '@intlayer/types/module_augmentation';
4
3
  import { type DeepTransformContent } from './plugins';
5
4
  /**
6
5
  * Get dictionary content for a specific locale in Svelte applications
7
6
  * @param dictionary The dictionary object to transform
8
7
  * @param locale The target locale (optional, defaults to current locale)
9
- * @param additionalPlugins Additional transformation plugins
10
8
  * @returns Transformed dictionary content optimized for Svelte
11
9
  */
12
- export declare const getDictionary: <T extends Dictionary, L extends LocalesValues = DeclaredLocales>(dictionary: T, locale?: L, additionalPlugins?: Plugins[]) => DeepTransformContent<T["content"]>;
10
+ export declare const getDictionary: <T extends Dictionary, L extends LocalesValues = DeclaredLocales>(dictionary: T, locale?: L) => DeepTransformContent<T["content"]>;
@@ -1,20 +1,9 @@
1
- import { getDictionary as getDictionaryCore, } from '@intlayer/core/interpreter';
2
- import { htmlPlugin, insertionPlugin, intlayerNodePlugins, markdownPlugin, svelteNodePlugins, } from './plugins';
1
+ import { getDictionary as getDictionaryCore } from '@intlayer/core/interpreter';
2
+ import { getPlugins } from './plugins';
3
3
  /**
4
4
  * Get dictionary content for a specific locale in Svelte applications
5
5
  * @param dictionary The dictionary object to transform
6
6
  * @param locale The target locale (optional, defaults to current locale)
7
- * @param additionalPlugins Additional transformation plugins
8
7
  * @returns Transformed dictionary content optimized for Svelte
9
8
  */
10
- export const getDictionary = (dictionary, locale, additionalPlugins) => {
11
- const plugins = [
12
- intlayerNodePlugins,
13
- svelteNodePlugins,
14
- insertionPlugin,
15
- markdownPlugin,
16
- htmlPlugin,
17
- ...(additionalPlugins ?? []),
18
- ];
19
- return getDictionaryCore(dictionary, locale, plugins);
20
- };
9
+ export const getDictionary = (dictionary, locale) => getDictionaryCore(dictionary, locale, getPlugins(locale));
@@ -1,11 +1,9 @@
1
- import { type Plugins } from '@intlayer/core/interpreter';
2
1
  import type { DeclaredLocales, DictionaryKeys, DictionaryRegistryContent, LocalesValues } from '@intlayer/types/module_augmentation';
3
2
  import { type DeepTransformContent } from './plugins';
4
3
  /**
5
4
  * Get dictionary content by key for Svelte applications
6
5
  * @param key The dictionary key to retrieve
7
6
  * @param locale The target locale (optional)
8
- * @param additionalPlugins Additional transformation plugins
9
7
  * @returns Transformed dictionary content optimized for Svelte
10
8
  */
11
- export declare const getIntlayer: <T extends DictionaryKeys, L extends LocalesValues = DeclaredLocales>(key: T, locale?: L, additionalPlugins?: Plugins[]) => DeepTransformContent<DictionaryRegistryContent<T>>;
9
+ export declare const getIntlayer: <T extends DictionaryKeys, L extends LocalesValues = DeclaredLocales>(key: T, locale?: L) => DeepTransformContent<DictionaryRegistryContent<T>>;
@@ -1,20 +1,9 @@
1
- import { getIntlayer as getIntlayerCore, } from '@intlayer/core/interpreter';
2
- import { htmlPlugin, insertionPlugin, intlayerNodePlugins, markdownPlugin, svelteNodePlugins, } from './plugins';
1
+ import { getIntlayer as getIntlayerCore } from '@intlayer/core/interpreter';
2
+ import { getPlugins } from './plugins';
3
3
  /**
4
4
  * Get dictionary content by key for Svelte applications
5
5
  * @param key The dictionary key to retrieve
6
6
  * @param locale The target locale (optional)
7
- * @param additionalPlugins Additional transformation plugins
8
7
  * @returns Transformed dictionary content optimized for Svelte
9
8
  */
10
- export const getIntlayer = (key, locale, additionalPlugins) => {
11
- const plugins = [
12
- intlayerNodePlugins,
13
- svelteNodePlugins,
14
- insertionPlugin,
15
- markdownPlugin,
16
- htmlPlugin,
17
- ...(additionalPlugins ?? []),
18
- ];
19
- return getIntlayerCore(key, locale, plugins);
20
- };
9
+ export const getIntlayer = (key, locale) => getIntlayerCore(key, locale, getPlugins(locale));
package/dist/plugins.d.ts CHANGED
@@ -74,3 +74,8 @@ export interface IInterpreterPluginSvelte<T, S, L extends LocalesValues> {
74
74
  svelteMarkdown: MarkdownCond<T, S, L>;
75
75
  svelteHtml: HTMLPluginCond<T>;
76
76
  }
77
+ /**
78
+ * Get the plugins array for Svelte content transformation.
79
+ * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.
80
+ */
81
+ export declare const getPlugins: (locale?: LocalesValues, fallback?: boolean) => Plugins[];
package/dist/plugins.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import configuration from '@intlayer/config/built';
2
- import { getHTML, } from '@intlayer/core/interpreter';
2
+ import { conditionPlugin, enumerationPlugin, filePlugin, genderPlugin, getHTML, nestedPlugin, translationPlugin, } from '@intlayer/core/interpreter';
3
3
  import { compile, getMarkdownMetadata } from '@intlayer/core/markdown';
4
4
  import { HTML_TAGS, } from '@intlayer/core/transpiler';
5
5
  import { NodeType } from '@intlayer/types/nodeType';
@@ -290,3 +290,20 @@ export const htmlPlugin = {
290
290
  return render();
291
291
  },
292
292
  };
293
+ /**
294
+ * Get the plugins array for Svelte content transformation.
295
+ * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.
296
+ */
297
+ export const getPlugins = (locale, fallback = true) => [
298
+ translationPlugin(locale ?? configuration.internationalization.defaultLocale, fallback ? configuration.internationalization.defaultLocale : undefined),
299
+ enumerationPlugin,
300
+ conditionPlugin,
301
+ nestedPlugin(locale ?? configuration.internationalization.defaultLocale),
302
+ filePlugin,
303
+ genderPlugin,
304
+ intlayerNodePlugins,
305
+ svelteNodePlugins,
306
+ insertionPlugin,
307
+ markdownPlugin,
308
+ htmlPlugin,
309
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-intlayer",
3
- "version": "8.3.1",
3
+ "version": "8.3.3",
4
4
  "description": "Easily internationalize i18n your Svelte applications with type-safe multilingual content management.",
5
5
  "keywords": [
6
6
  "intlayer",
@@ -72,28 +72,28 @@
72
72
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
73
73
  },
74
74
  "dependencies": {
75
- "@intlayer/api": "8.3.1",
76
- "@intlayer/config": "8.3.1",
77
- "@intlayer/core": "8.3.1",
78
- "@intlayer/editor": "8.3.1",
79
- "@intlayer/types": "8.3.1",
80
- "@intlayer/unmerged-dictionaries-entry": "8.3.1"
75
+ "@intlayer/api": "8.3.3",
76
+ "@intlayer/config": "8.3.3",
77
+ "@intlayer/core": "8.3.3",
78
+ "@intlayer/editor": "8.3.3",
79
+ "@intlayer/types": "8.3.3",
80
+ "@intlayer/unmerged-dictionaries-entry": "8.3.3"
81
81
  },
82
82
  "devDependencies": {
83
- "@sveltejs/adapter-auto": "7.0.0",
84
- "@sveltejs/package": "2.5.4",
85
- "@sveltejs/vite-plugin-svelte": "4.0.0",
86
- "@types/node": "25.4.0",
83
+ "@sveltejs/adapter-auto": "7.0.1",
84
+ "@sveltejs/package": "2.5.7",
85
+ "@sveltejs/vite-plugin-svelte": "7.0.0",
86
+ "@types/node": "25.5.0",
87
87
  "@utils/ts-config": "1.0.4",
88
88
  "@utils/ts-config-types": "1.0.4",
89
89
  "@utils/tsdown-config": "1.0.4",
90
90
  "rimraf": "6.1.3",
91
- "svelte": "5.0.0",
92
- "svelte-check": "4.0.0",
91
+ "svelte": "5.53.11",
92
+ "svelte-check": "4.4.5",
93
93
  "tsdown": "0.21.2",
94
94
  "typescript": "5.9.3",
95
- "vite": "5.0.0",
96
- "vitest": "4.0.18"
95
+ "vite": "8.0.0",
96
+ "vitest": "4.1.0"
97
97
  },
98
98
  "peerDependencies": {
99
99
  "svelte": ">=5.0.0"