@verbaly/svelte 0.75.0 → 0.77.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/dist/index.d.ts CHANGED
@@ -1,12 +1,9 @@
1
1
  import { Readable, Writable } from "svelte/store";
2
2
  import { DictionaryInput, Params, TFunction, Verbaly } from "verbaly";
3
- //#region src/index.d.ts
4
3
  export declare function provideVerbaly<D extends DictionaryInput>(instance: Verbaly<D>): Verbaly<D>;
5
4
  export declare function useVerbaly<D extends DictionaryInput = DictionaryInput>(): Verbaly<D>;
6
5
  export declare function tStore<D extends DictionaryInput>(instance: Verbaly<D>): Readable<Verbaly<D>['t']>;
7
6
  export declare function localeStore(instance: Verbaly): Writable<string>;
8
7
  export declare function useT<D extends DictionaryInput = DictionaryInput>(): Readable<Verbaly<D>['t']>;
9
8
  export declare function useLocale(): Writable<string>;
10
- //#endregion
11
- export type { Params, TFunction, Verbaly };
12
- //# sourceMappingURL=index.d.ts.map
9
+ export type { Params, TFunction, Verbaly };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { getContext, setContext } from "svelte";
2
- //#region src/index.ts
2
+ // src/index.ts
3
3
  const KEY = {};
4
4
  function provideVerbaly(instance) {
5
5
  setContext(KEY, instance);
@@ -37,7 +37,4 @@ function useT() {
37
37
  function useLocale() {
38
38
  return localeStore(useVerbaly());
39
39
  }
40
- //#endregion
41
40
  export { localeStore, provideVerbaly, tStore, useLocale, useT, useVerbaly };
42
-
43
- //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verbaly/svelte",
3
- "version": "0.75.0",
3
+ "version": "0.77.0",
4
4
  "description": "Svelte bindings for Verbaly: stores over the reactive core.",
5
5
  "keywords": [
6
6
  "i18n",
@@ -19,6 +19,10 @@
19
19
  "bugs": {
20
20
  "url": "https://github.com/AronSoto/verbaly/issues"
21
21
  },
22
+ "funding": {
23
+ "type": "github",
24
+ "url": "https://github.com/sponsors/AronSoto"
25
+ },
22
26
  "type": "module",
23
27
  "types": "./dist/index.d.ts",
24
28
  "exports": {
@@ -45,13 +49,13 @@
45
49
  },
46
50
  "peerDependencies": {
47
51
  "svelte": "^5.0.0",
48
- "verbaly": "^0.75.0"
52
+ "verbaly": "^0.77.0"
49
53
  },
50
54
  "devDependencies": {
51
55
  "@sveltejs/vite-plugin-svelte": "^7.3.1",
52
- "happy-dom": "^21.0.3",
53
- "svelte": "^5.57.2",
54
- "verbaly": "^0.75.0"
56
+ "happy-dom": "^21.0.4",
57
+ "svelte": "^5.57.3",
58
+ "verbaly": "^0.77.0"
55
59
  },
56
60
  "scripts": {
57
61
  "build": "tsdown && node scripts/copy-svelte.mjs",
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
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\n// what virtual:verbaly registers in a browser; a server holds one instance per request instead\nconst APP_INSTANCE = Symbol.for('verbaly.app');\n\nfunction appInstance<D extends DictionaryInput>(): Verbaly<D> | undefined {\n if (typeof document === 'undefined') return undefined;\n return (globalThis as Record<symbol, unknown>)[APP_INSTANCE] as Verbaly<D> | undefined;\n}\n\n// a parent's wins; without one, a browser or a test reads the app's own instance\nexport function useVerbaly<D extends DictionaryInput = DictionaryInput>(): Verbaly<D> {\n const instance = getContext<Verbaly<D> | undefined>(KEY) ?? appInstance<D>();\n if (!instance) {\n throw new Error(\n '[verbaly] useVerbaly requires provideVerbaly(...) in a parent: on a server, or before virtual:verbaly loads',\n );\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<Verbaly<D>['t']> {\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\n// typed by the project's catalog once verbaly.d.ts exists, by a dictionary when one is named\nexport function useT<D extends DictionaryInput = DictionaryInput>(): Readable<Verbaly<D>['t']> {\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;AAGA,MAAM,eAAe,OAAO,IAAI,aAAa;AAE7C,SAAS,cAAiE;CACxE,IAAI,OAAO,aAAa,aAAa,OAAO,KAAA;CAC5C,OAAQ,WAAuC;AACjD;AAGA,SAAgB,aAAsE;CACpF,MAAM,WAAW,WAAmC,GAAG,KAAK,YAAe;CAC3E,IAAI,CAAC,UACH,MAAM,IAAI,MACR,6GACF;CAEF,OAAO;AACT;AAGA,SAAgB,OAAkC,UAAiD;CACjG,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;AAGA,SAAgB,OAA+E;CAC7F,OAAO,OAAO,WAAc,CAAC;AAC/B;AAEA,SAAgB,YAA8B;CAC5C,OAAO,YAAY,WAAW,CAAC;AACjC"}