svelte-intlayer 9.3.1 → 9.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.
@@ -1,4 +1,4 @@
1
- import { isQualifiedDynamicLoaderMap, resolveProviderVariant, resolveQualifiedDynamicContentAsync, } from '@intlayer/core/dictionaryManipulator';
1
+ import { getPreloadedDictionary, isQualifiedDynamicLoaderMap, resolveProviderVariant, resolveQualifiedDynamicContentAsync, } from '@intlayer/core/dictionaryManipulator';
2
2
  import { derived } from 'svelte/store';
3
3
  import { getDictionary } from '../getDictionary';
4
4
  import { getIntlayerContext } from './intlayerContext';
@@ -71,6 +71,16 @@ export function useDictionaryDynamic(dictionaryPromise, key, localeOrSelector) {
71
71
  : localeOrSelector;
72
72
  const localeStore = derived(intlayerStore, ($store) => explicitLocale ?? context?.locale ?? $store.locale);
73
73
  return derived(localeStore, ($locale, set) => {
74
+ // A build-tool plugin may have resolved this locale's dictionary while
75
+ // the entry point evaluated. Publishing it synchronously lets the store
76
+ // open on real content — otherwise every dynamic dictionary starts on
77
+ // `loadingProxy()` and flips a microtask later, one placeholder frame
78
+ // each, even when nothing has to be fetched.
79
+ const preloadedDictionary = getPreloadedDictionary(dictionaryPromise, $locale);
80
+ if (preloadedDictionary) {
81
+ set(withState(getDictionary(preloadedDictionary, $locale)));
82
+ return;
83
+ }
74
84
  // Set loading state immediately with proxy
75
85
  set(loadingProxy());
76
86
  let isCancelled = false;
@@ -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
  */
@@ -15,7 +15,8 @@ export const useEditor = () => {
15
15
  return;
16
16
  let unsubscribeLocale = null;
17
17
  onMount(() => {
18
- import('@intlayer/editor').then(({ initEditorClient }) => {
18
+ import('@intlayer/editor')
19
+ .then(({ initEditorClient }) => {
19
20
  const manager = initEditorClient();
20
21
  // Subscribe immediately — Svelte stores call the subscriber with the
21
22
  // current value on subscription, so the initial locale is set right away.
@@ -23,12 +24,15 @@ export const useEditor = () => {
23
24
  if (locale)
24
25
  manager.currentLocale.set(locale);
25
26
  });
26
- });
27
+ })
28
+ .catch(() => { });
27
29
  });
28
30
  onDestroy(() => {
29
31
  unsubscribeLocale?.();
30
- import('@intlayer/editor').then(({ stopEditorClient }) => {
32
+ import('@intlayer/editor')
33
+ .then(({ stopEditorClient }) => {
31
34
  stopEditorClient();
32
- });
35
+ })
36
+ .catch(() => { });
33
37
  });
34
38
  };
@@ -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>;
package/dist/plugins.js CHANGED
@@ -20,10 +20,12 @@ let _HTMLWithSelector = null;
20
20
  */
21
21
  let markdownRendererModulesPromise = null;
22
22
  if (process.env.INTLAYER_NODE_TYPE_MARKDOWN !== 'false') {
23
- void import('@intlayer/core/markdown').then((m) => {
23
+ void import('@intlayer/core/markdown')
24
+ .then((m) => {
24
25
  _getMarkdownMetadata = m.getMarkdownMetadata;
25
26
  _compile = m.compile;
26
- });
27
+ })
28
+ .catch(() => { });
27
29
  markdownRendererModulesPromise = Promise.all([
28
30
  import('./markdown/MarkdownMetadataRenderer.svelte'),
29
31
  import('./markdown/MarkdownMetadataWithSelector.svelte'),
@@ -39,9 +41,16 @@ if (process.env.INTLAYER_NODE_TYPE_MARKDOWN !== 'false') {
39
41
  MarkdownWithSelector: withSelectorModule.default,
40
42
  };
41
43
  });
44
+ // Read later by `resolveMarkdownRenderer`, so the rejection must stay on the
45
+ // promise: a `.catch()` chained into it would resolve with `undefined` and be
46
+ // mistaken for loaded renderers. Handle it on the side instead, so an aborted
47
+ // chunk load never escapes as an unhandled rejection.
48
+ markdownRendererModulesPromise.catch(() => { });
42
49
  }
43
50
  if (process.env.INTLAYER_NODE_TYPE_HTML !== 'false') {
44
- void import('./html/HTMLWithSelector.svelte').then((m) => (_HTMLWithSelector = m.default));
51
+ void import('./html/HTMLWithSelector.svelte')
52
+ .then((m) => (_HTMLWithSelector = m.default))
53
+ .catch(() => { });
45
54
  }
46
55
  /**
47
56
  * Resolves the Svelte component that renders a markdown node, awaiting the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-intlayer",
3
- "version": "9.3.1",
3
+ "version": "9.3.3",
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": "9.3.1",
86
- "@intlayer/config": "9.3.1",
87
- "@intlayer/core": "9.3.1",
88
- "@intlayer/editor": "9.3.1",
89
- "@intlayer/types": "9.3.1"
85
+ "@intlayer/api": "9.3.2",
86
+ "@intlayer/config": "9.3.3",
87
+ "@intlayer/core": "9.3.3",
88
+ "@intlayer/editor": "9.3.3",
89
+ "@intlayer/types": "9.3.3"
90
90
  },
91
91
  "devDependencies": {
92
92
  "@sveltejs/adapter-auto": "7.0.1",
@@ -102,13 +102,13 @@
102
102
  "tsdown": "0.22.14",
103
103
  "typescript": "5.9.3",
104
104
  "vite": "8.2.1",
105
- "vitest": "4.1.10"
105
+ "vitest": "4.1.11"
106
106
  },
107
107
  "peerDependencies": {
108
108
  "svelte": ">=5.0.0"
109
109
  },
110
110
  "optionalDependencies": {
111
- "@intlayer/analytics": "9.3.1"
111
+ "@intlayer/analytics": "9.3.3"
112
112
  },
113
113
  "engines": {
114
114
  "node": ">=14.18"