@verbaly/sveltekit 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 +1 -4
- package/dist/index.js +1 -4
- package/package.json +9 -5
- package/dist/index.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Routing, SwitchLocaleOptions, switchLocale } from "verbaly";
|
|
2
|
-
//#region src/index.d.ts
|
|
3
2
|
export declare const LOCALE_COOKIE: string;
|
|
4
3
|
interface HandleEvent {
|
|
5
4
|
request: Request;
|
|
@@ -36,6 +35,4 @@ export interface VerbalyRerouteOptions {
|
|
|
36
35
|
export declare function verbalyReroute(options: VerbalyRerouteOptions): ({ url }: {
|
|
37
36
|
url: URL;
|
|
38
37
|
}) => string;
|
|
39
|
-
|
|
40
|
-
export { type SwitchLocaleOptions, switchLocale };
|
|
41
|
-
//# sourceMappingURL=index.d.ts.map
|
|
38
|
+
export { type SwitchLocaleOptions, switchLocale };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LOCALE_STORAGE_KEY, localeDirection, resolveRequestLocale, stripLocalePath, switchLocale } from "verbaly";
|
|
2
|
-
|
|
2
|
+
// src/index.ts
|
|
3
3
|
const LOCALE_COOKIE = LOCALE_STORAGE_KEY;
|
|
4
4
|
const LANG_PLACEHOLDER = "%verbaly.lang%";
|
|
5
5
|
const DIR_PLACEHOLDER = "%verbaly.dir%";
|
|
@@ -30,7 +30,4 @@ function verbalyReroute(options) {
|
|
|
30
30
|
base: options.base
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
//#endregion
|
|
34
33
|
export { LOCALE_COOKIE, switchLocale, verbalyHandle, verbalyReroute };
|
|
35
|
-
|
|
36
|
-
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verbaly/sveltekit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.77.0",
|
|
4
4
|
"description": "SvelteKit SSR integration for Verbaly: per-request locale negotiation and flash-free hydration.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"i18n",
|
|
@@ -20,6 +20,10 @@
|
|
|
20
20
|
"bugs": {
|
|
21
21
|
"url": "https://github.com/AronSoto/verbaly/issues"
|
|
22
22
|
},
|
|
23
|
+
"funding": {
|
|
24
|
+
"type": "github",
|
|
25
|
+
"url": "https://github.com/sponsors/AronSoto"
|
|
26
|
+
},
|
|
23
27
|
"type": "module",
|
|
24
28
|
"types": "./dist/index.d.ts",
|
|
25
29
|
"exports": {
|
|
@@ -40,12 +44,12 @@
|
|
|
40
44
|
"access": "public"
|
|
41
45
|
},
|
|
42
46
|
"peerDependencies": {
|
|
43
|
-
"verbaly": "^0.
|
|
47
|
+
"verbaly": "^0.77.0"
|
|
44
48
|
},
|
|
45
49
|
"devDependencies": {
|
|
46
|
-
"@sveltejs/kit": "^3.1.
|
|
47
|
-
"svelte": "^5.57.
|
|
48
|
-
"verbaly": "^0.
|
|
50
|
+
"@sveltejs/kit": "^3.1.1",
|
|
51
|
+
"svelte": "^5.57.3",
|
|
52
|
+
"verbaly": "^0.77.0"
|
|
49
53
|
},
|
|
50
54
|
"scripts": {
|
|
51
55
|
"build": "tsdown",
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import {\n LOCALE_STORAGE_KEY,\n localeDirection,\n resolveRequestLocale,\n stripLocalePath,\n type Routing,\n} from 'verbaly';\n\n// derived from core's localStorage key: one identity per user across channels\nexport const LOCALE_COOKIE: string = LOCALE_STORAGE_KEY;\nconst LANG_PLACEHOLDER = '%verbaly.lang%';\nconst DIR_PLACEHOLDER = '%verbaly.dir%';\n\n// structural subset of @sveltejs/kit: no runtime or type dependency on kit\ninterface HandleEvent {\n request: Request;\n url: URL;\n cookies: { get(name: string): string | undefined };\n locals: { verbalyLocale?: string };\n}\ninterface ResolveOptions {\n transformPageChunk?(input: { html: string; done: boolean }): string | undefined;\n}\ninterface HandleInput {\n event: HandleEvent;\n resolve(event: HandleEvent, opts?: ResolveOptions): Response | Promise<Response>;\n}\n\nexport interface VerbalyHandleOptions {\n locales: string[];\n fallback?: string;\n cookie?: string | false;\n routing?: Routing;\n base?: string;\n}\n\n// server hook: sets event.locals.verbalyLocale and fills %verbaly.lang% / %verbaly.dir%\nexport function verbalyHandle(options: VerbalyHandleOptions) {\n const { locales, cookie = LOCALE_COOKIE } = options;\n if (!Array.isArray(locales) || locales.length === 0) {\n throw new Error(\n \"[verbaly] verbalyHandle needs `locales`: pass the `locales` export from 'virtual:verbaly' \" +\n '(requires @verbaly/vite ≥0.16) or list them yourself: verbalyHandle({ locales: [...] })',\n );\n }\n const fallback = options.fallback ?? locales[0]!;\n\n return ({ event, resolve }: HandleInput): Response | Promise<Response> => {\n const resolved = resolveRequestLocale({\n supported: locales,\n path: event.url.pathname,\n routing: options.routing,\n base: options.base,\n cookie: cookie ? event.cookies.get(cookie) : undefined,\n header: event.request.headers.get('accept-language'),\n fallback,\n });\n\n event.locals.verbalyLocale = resolved;\n return resolve(event, {\n transformPageChunk: ({ html }) =>\n html\n .replaceAll(LANG_PLACEHOLDER, resolved)\n .replaceAll(DIR_PLACEHOLDER, localeDirection(resolved)),\n });\n };\n}\n\nexport interface VerbalyRerouteOptions {\n locales: string[];\n base?: string;\n}\n\n// universal hook (hooks.ts, never hooks.server.ts): /es/docs routes as /docs, one route tree\nexport function verbalyReroute(options: VerbalyRerouteOptions) {\n const { locales } = options;\n if (!Array.isArray(locales) || locales.length === 0) {\n throw new Error(\n \"[verbaly] verbalyReroute needs `locales`: pass the `locales` export from 'virtual:verbaly'\",\n );\n }\n return ({ url }: { url: URL }): string =>\n stripLocalePath({ supported: locales, path: url.pathname, base: options.base });\n}\n\n// switchLocale moved to core in 0.18.0 (shared with @verbaly/nuxt): same API, re-exported\nexport { switchLocale } from 'verbaly';\nexport type { SwitchLocaleOptions } from 'verbaly';\n"],"mappings":";;AASA,MAAa,gBAAwB;AACrC,MAAM,mBAAmB;AACzB,MAAM,kBAAkB;AA0BxB,SAAgB,cAAc,SAA+B;CAC3D,MAAM,EAAE,SAAS,SAAS,kBAAkB;CAC5C,IAAI,CAAC,MAAM,QAAQ,OAAO,KAAK,QAAQ,WAAW,GAChD,MAAM,IAAI,MACR,mLAEF;CAEF,MAAM,WAAW,QAAQ,YAAY,QAAQ;CAE7C,QAAQ,EAAE,OAAO,cAAyD;EACxE,MAAM,WAAW,qBAAqB;GACpC,WAAW;GACX,MAAM,MAAM,IAAI;GAChB,SAAS,QAAQ;GACjB,MAAM,QAAQ;GACd,QAAQ,SAAS,MAAM,QAAQ,IAAI,MAAM,IAAI,KAAA;GAC7C,QAAQ,MAAM,QAAQ,QAAQ,IAAI,iBAAiB;GACnD;EACF,CAAC;EAED,MAAM,OAAO,gBAAgB;EAC7B,OAAO,QAAQ,OAAO,EACpB,qBAAqB,EAAE,WACrB,KACG,WAAW,kBAAkB,QAAQ,CAAC,CACtC,WAAW,iBAAiB,gBAAgB,QAAQ,CAAC,EAC5D,CAAC;CACH;AACF;AAQA,SAAgB,eAAe,SAAgC;CAC7D,MAAM,EAAE,YAAY;CACpB,IAAI,CAAC,MAAM,QAAQ,OAAO,KAAK,QAAQ,WAAW,GAChD,MAAM,IAAI,MACR,4FACF;CAEF,QAAQ,EAAE,UACR,gBAAgB;EAAE,WAAW;EAAS,MAAM,IAAI;EAAU,MAAM,QAAQ;CAAK,CAAC;AAClF"}
|