svelte-intlayer 7.1.6 → 7.1.8-canary.0

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 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("svelte/store"),r=require("./intlayerContext.cjs"),t=require("./intlayerStore.cjs"),c=()=>{const e=r.getIntlayerContext();return e?{locale:l.derived([t.intlayerStore],([o])=>e.locale||o.locale),setLocale:e.setLocale}:{locale:t.intlayerStore.getLocale(),setLocale:t.intlayerStore.setLocale}};exports.useLocale=c;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@intlayer/config/built"),n=require("svelte/store"),c=require("./intlayerContext.cjs"),t=require("./intlayerStore.cjs"),i=()=>{const e=c.getIntlayerContext(),{defaultLocale:o,locales:l}=r?.internationalization??{};return e?{locale:n.derived([t.intlayerStore],([a])=>e.locale||a.locale),setLocale:e.setLocale}:{locale:t.intlayerStore.getLocale(),setLocale:t.intlayerStore.setLocale,defaultLocale:o,availableLocales:l}};exports.useLocale=i;
@@ -1,19 +1,22 @@
1
- import { derived as l } from "svelte/store";
2
- import { getIntlayerContext as r } from "./intlayerContext.mjs";
1
+ import r from "@intlayer/config/built";
2
+ import { derived as c } from "svelte/store";
3
+ import { getIntlayerContext as n } from "./intlayerContext.mjs";
3
4
  import { intlayerStore as o } from "./intlayerStore.mjs";
4
- const s = () => {
5
- const e = r();
5
+ const f = () => {
6
+ const e = n(), { defaultLocale: t, locales: l } = r?.internationalization ?? {};
6
7
  return e ? {
7
- locale: l(
8
+ locale: c(
8
9
  [o],
9
- ([t]) => e.locale || t.locale
10
+ ([a]) => e.locale || a.locale
10
11
  ),
11
12
  setLocale: e.setLocale
12
13
  } : {
13
14
  locale: o.getLocale(),
14
- setLocale: o.setLocale
15
+ setLocale: o.setLocale,
16
+ defaultLocale: t,
17
+ availableLocales: l
15
18
  };
16
19
  };
17
20
  export {
18
- s as useLocale
21
+ f as useLocale
19
22
  };
@@ -1,5 +1,4 @@
1
1
  import { DictionaryKeys, DictionaryRegistryContent, LocalesValues } from '@intlayer/types';
2
- import { Readable } from 'svelte/store';
3
2
  import { DeepTransformContent } from '../plugins';
4
3
  /**
5
4
  * Svelte hook that picks one dictionary by its key and returns reactive content
@@ -7,4 +6,4 @@ import { DeepTransformContent } from '../plugins';
7
6
  * @param locale The target locale (optional, uses context or store locale)
8
7
  * @returns Reactive store with transformed dictionary content
9
8
  */
10
- export declare const useIntlayer: <T extends DictionaryKeys>(key: T, locale?: LocalesValues) => Readable<DeepTransformContent<DictionaryRegistryContent<T>>>;
9
+ export declare const useIntlayer: <T extends DictionaryKeys>(key: T, locale?: LocalesValues) => DeepTransformContent<DictionaryRegistryContent<T>>;
@@ -5,4 +5,11 @@
5
5
  export declare const useLocale: () => {
6
6
  locale: import('svelte/store').Readable<import('@intlayer/types').LocalesValues>;
7
7
  setLocale: (locale: import('@intlayer/types').LocalesValues) => void;
8
+ defaultLocale?: undefined;
9
+ availableLocales?: undefined;
10
+ } | {
11
+ locale: import('svelte/store').Readable<import('@intlayer/types').LocalesValues>;
12
+ setLocale: (locale: import('@intlayer/types').LocalesValues) => void;
13
+ defaultLocale: import('@intlayer/types').Locale;
14
+ availableLocales: import('@intlayer/types').Locale[];
8
15
  };
@@ -1,19 +1,15 @@
1
- import { Plugins } from '@intlayer/core';
1
+ import { DeepTransformContent as DeepTransformContentCore, IInterpreterPluginState as IInterpreterPluginStateCore, Plugins } from '@intlayer/core';
2
+ import { DeclaredLocales, LocalesValues } from '@intlayer/types';
2
3
  /**
3
4
  * Interface for Svelte-specific plugin functionality
4
5
  * This interface can be augmented to add more Svelte-specific transformations
5
6
  */
6
- export interface IInterpreterPluginSvelte<T> {
7
- /** Any Svelte-specific properties can be added here */
8
- svelteRendered?: T;
9
- }
7
+ export type IInterpreterPluginState = IInterpreterPluginStateCore & {};
10
8
  /**
11
9
  * Type that represents the deep transformation of content for Svelte
12
10
  * This applies Svelte-specific transformations recursively to all content
13
11
  */
14
- export type DeepTransformContent<T> = T extends object ? {
15
- [K in keyof T]: DeepTransformContent<T[K]>;
16
- } & IInterpreterPluginSvelte<T> : T;
12
+ export type DeepTransformContent<T, L extends LocalesValues = DeclaredLocales> = DeepTransformContentCore<T, IInterpreterPluginState, L>;
17
13
  /**
18
14
  * Svelte-specific node plugins for handling basic content types
19
15
  * These plugins handle strings, numbers, and bigints in Svelte applications
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-intlayer",
3
- "version": "7.1.6",
3
+ "version": "7.1.8-canary.0",
4
4
  "private": false,
5
5
  "description": "Easily internationalize i18n your Svelte applications with type-safe multilingual content management.",
6
6
  "keywords": [
@@ -74,11 +74,11 @@
74
74
  "typecheck": "tsc --noEmit --project tsconfig.types.json"
75
75
  },
76
76
  "dependencies": {
77
- "@intlayer/api": "7.1.6",
78
- "@intlayer/config": "7.1.6",
79
- "@intlayer/core": "7.1.6",
80
- "@intlayer/editor": "7.1.6",
81
- "@intlayer/types": "7.1.6"
77
+ "@intlayer/api": "7.1.8-canary.0",
78
+ "@intlayer/config": "7.1.8-canary.0",
79
+ "@intlayer/core": "7.1.8-canary.0",
80
+ "@intlayer/editor": "7.1.8-canary.0",
81
+ "@intlayer/types": "7.1.8-canary.0"
82
82
  },
83
83
  "devDependencies": {
84
84
  "@sveltejs/vite-plugin-svelte": "6.1.4",
@@ -91,7 +91,7 @@
91
91
  "typescript": "5.9.3",
92
92
  "vite": "7.2.2",
93
93
  "vite-plugin-dts": "4.5.4",
94
- "vitest": "4.0.8"
94
+ "vitest": "4.0.10"
95
95
  },
96
96
  "peerDependencies": {
97
97
  "svelte": ">=5.0.0"