@verbaly/svelte 0.11.0 → 0.13.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.
- package/README.md +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +24 -33
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<img src="https://raw.githubusercontent.com/AronSoto/verbaly/develop/assets/logo
|
|
2
|
+
<img src="https://raw.githubusercontent.com/AronSoto/verbaly/develop/assets/logo.png" alt="Verbaly" width="300" />
|
|
3
3
|
</p>
|
|
4
4
|
|
|
5
5
|
<p align="center"><em>Svelte bindings for Verbaly — stores over the reactive core.</em></p>
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { Readable, Writable } from "svelte/store";
|
|
2
|
+
import { DictionaryInput, Params, TFunction, Verbaly } from "verbaly";
|
|
3
|
+
//#region src/index.d.ts
|
|
5
4
|
declare function provideVerbaly<D extends DictionaryInput>(instance: Verbaly<D>): Verbaly<D>;
|
|
6
5
|
declare function useVerbaly<D extends DictionaryInput = DictionaryInput>(): Verbaly<D>;
|
|
7
6
|
declare function tStore<D extends DictionaryInput>(instance: Verbaly<D>): Readable<TFunction<D>>;
|
|
8
7
|
declare function localeStore(instance: Verbaly): Writable<string>;
|
|
9
8
|
declare function useT<D extends DictionaryInput = DictionaryInput>(): Readable<TFunction<D>>;
|
|
10
9
|
declare function useLocale(): Writable<string>;
|
|
11
|
-
|
|
12
|
-
export { localeStore, provideVerbaly, tStore, useLocale, useT, useVerbaly };
|
|
10
|
+
//#endregion
|
|
11
|
+
export { type Params, type TFunction, type Verbaly, localeStore, provideVerbaly, tStore, useLocale, useT, useVerbaly };
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,47 +1,38 @@
|
|
|
1
|
-
// src/index.ts
|
|
2
1
|
import { getContext, setContext } from "svelte";
|
|
3
|
-
|
|
2
|
+
//#region src/index.ts
|
|
3
|
+
const KEY = {};
|
|
4
4
|
function provideVerbaly(instance) {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
setContext(KEY, instance);
|
|
6
|
+
return instance;
|
|
7
7
|
}
|
|
8
8
|
function useVerbaly() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
return instance;
|
|
9
|
+
const instance = getContext(KEY);
|
|
10
|
+
if (!instance) throw new Error("[verbaly] useVerbaly requires provideVerbaly(...) in a parent component");
|
|
11
|
+
return instance;
|
|
14
12
|
}
|
|
15
13
|
function tStore(instance) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
};
|
|
14
|
+
return { subscribe(run) {
|
|
15
|
+
run(instance.t);
|
|
16
|
+
return instance.subscribe(() => run(instance.t));
|
|
17
|
+
} };
|
|
22
18
|
}
|
|
23
19
|
function localeStore(instance) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
return {
|
|
21
|
+
subscribe(run) {
|
|
22
|
+
run(instance.locale);
|
|
23
|
+
return instance.subscribe(() => run(instance.locale));
|
|
24
|
+
},
|
|
25
|
+
set: (locale) => instance.setLocale(locale),
|
|
26
|
+
update: (fn) => instance.setLocale(fn(instance.locale))
|
|
27
|
+
};
|
|
32
28
|
}
|
|
33
29
|
function useT() {
|
|
34
|
-
|
|
30
|
+
return tStore(useVerbaly());
|
|
35
31
|
}
|
|
36
32
|
function useLocale() {
|
|
37
|
-
|
|
33
|
+
return localeStore(useVerbaly());
|
|
38
34
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
tStore,
|
|
43
|
-
useLocale,
|
|
44
|
-
useT,
|
|
45
|
-
useVerbaly
|
|
46
|
-
};
|
|
35
|
+
//#endregion
|
|
36
|
+
export { localeStore, provideVerbaly, tStore, useLocale, useT, useVerbaly };
|
|
37
|
+
|
|
47
38
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { getContext, setContext } from 'svelte';\nimport type { Readable, Writable } from 'svelte/store';\nimport type { DictionaryInput, Params, TFunction, Verbaly } from 'verbaly';\n\nconst KEY = {};\n\nexport function provideVerbaly<D extends DictionaryInput>(instance: Verbaly<D>): Verbaly<D> {\n setContext(KEY, instance);\n return instance;\n}\n\nexport function useVerbaly<D extends DictionaryInput = DictionaryInput>(): Verbaly<D> {\n const instance = getContext<Verbaly<D> | undefined>(KEY);\n if (!instance) {\n throw new Error('[verbaly] useVerbaly requires provideVerbaly(...) in a parent component');\n }\n return instance;\n}\n\n// store factories — also usable without context (app-level singleton)\nexport function tStore<D extends DictionaryInput>(instance: Verbaly<D>): Readable<TFunction<D>> {\n return {\n subscribe(run) {\n run(instance.t);\n return instance.subscribe(() => run(instance.t));\n },\n };\n}\n\nexport function localeStore(instance: Verbaly): Writable<string> {\n return {\n subscribe(run) {\n run(instance.locale);\n return instance.subscribe(() => run(instance.locale));\n },\n set: (locale) => instance.setLocale(locale),\n update: (fn) => instance.setLocale(fn(instance.locale)),\n };\n}\n\nexport function useT<D extends DictionaryInput = DictionaryInput>(): Readable<TFunction<D>> {\n return tStore(useVerbaly<D>());\n}\n\nexport function useLocale(): Writable<string> {\n return localeStore(useVerbaly());\n}\n\nexport type { Params, TFunction, Verbaly };\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { getContext, setContext } from 'svelte';\nimport type { Readable, Writable } from 'svelte/store';\nimport type { DictionaryInput, Params, TFunction, Verbaly } from 'verbaly';\n\nconst KEY = {};\n\nexport function provideVerbaly<D extends DictionaryInput>(instance: Verbaly<D>): Verbaly<D> {\n setContext(KEY, instance);\n return instance;\n}\n\nexport function useVerbaly<D extends DictionaryInput = DictionaryInput>(): Verbaly<D> {\n const instance = getContext<Verbaly<D> | undefined>(KEY);\n if (!instance) {\n throw new Error('[verbaly] useVerbaly requires provideVerbaly(...) in a parent component');\n }\n return instance;\n}\n\n// store factories — also usable without context (app-level singleton)\nexport function tStore<D extends DictionaryInput>(instance: Verbaly<D>): Readable<TFunction<D>> {\n return {\n subscribe(run) {\n run(instance.t);\n return instance.subscribe(() => run(instance.t));\n },\n };\n}\n\nexport function localeStore(instance: Verbaly): Writable<string> {\n return {\n subscribe(run) {\n run(instance.locale);\n return instance.subscribe(() => run(instance.locale));\n },\n set: (locale) => instance.setLocale(locale),\n update: (fn) => instance.setLocale(fn(instance.locale)),\n };\n}\n\nexport function useT<D extends DictionaryInput = DictionaryInput>(): Readable<TFunction<D>> {\n return tStore(useVerbaly<D>());\n}\n\nexport function useLocale(): Writable<string> {\n return localeStore(useVerbaly());\n}\n\nexport type { Params, TFunction, Verbaly };\n"],"mappings":";;AAIA,MAAM,MAAM,CAAC;AAEb,SAAgB,eAA0C,UAAkC;CAC1F,WAAW,KAAK,QAAQ;CACxB,OAAO;AACT;AAEA,SAAgB,aAAsE;CACpF,MAAM,WAAW,WAAmC,GAAG;CACvD,IAAI,CAAC,UACH,MAAM,IAAI,MAAM,yEAAyE;CAE3F,OAAO;AACT;AAGA,SAAgB,OAAkC,UAA8C;CAC9F,OAAO,EACL,UAAU,KAAK;EACb,IAAI,SAAS,CAAC;EACd,OAAO,SAAS,gBAAgB,IAAI,SAAS,CAAC,CAAC;CACjD,EACF;AACF;AAEA,SAAgB,YAAY,UAAqC;CAC/D,OAAO;EACL,UAAU,KAAK;GACb,IAAI,SAAS,MAAM;GACnB,OAAO,SAAS,gBAAgB,IAAI,SAAS,MAAM,CAAC;EACtD;EACA,MAAM,WAAW,SAAS,UAAU,MAAM;EAC1C,SAAS,OAAO,SAAS,UAAU,GAAG,SAAS,MAAM,CAAC;CACxD;AACF;AAEA,SAAgB,OAA4E;CAC1F,OAAO,OAAO,WAAc,CAAC;AAC/B;AAEA,SAAgB,YAA8B;CAC5C,OAAO,YAAY,WAAW,CAAC;AACjC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verbaly/svelte",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Svelte bindings for Verbaly — stores over the reactive core.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
@@ -45,17 +45,17 @@
|
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"svelte": "^4.0.0 || ^5.0.0",
|
|
48
|
-
"verbaly": "^0.
|
|
48
|
+
"verbaly": "^0.13.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@sveltejs/vite-plugin-svelte": "^7.2.0",
|
|
52
52
|
"happy-dom": "^20.10.6",
|
|
53
53
|
"svelte": "^5.56.4",
|
|
54
|
-
"verbaly": "0.
|
|
54
|
+
"verbaly": "0.13.0"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
|
-
"build": "
|
|
58
|
-
"dev": "
|
|
57
|
+
"build": "tsdown && node scripts/copy-svelte.mjs",
|
|
58
|
+
"dev": "tsdown --watch",
|
|
59
59
|
"test": "vitest run --passWithNoTests",
|
|
60
60
|
"typecheck": "tsc --noEmit"
|
|
61
61
|
}
|