@yapyak/sveltekit 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Joakim Uhrwing
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # @yapyak/sveltekit
2
+
3
+ > Node-only
4
+
5
+ SvelteKit adapter for yapyak.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @yapyak/sveltekit
11
+ # or
12
+ pnpm add @yapyak/sveltekit
13
+ ```
14
+
15
+ ## Documentation
16
+
17
+ [yapyak.dev/reference/sveltekit](https://yapyak.dev/reference/sveltekit)
@@ -0,0 +1,27 @@
1
+ import { Handle } from "@sveltejs/kit";
2
+ //#region src/handle.d.ts
3
+ /**
4
+ * Handle for SvelteKit. Provides yapyak's per-request locale context.
5
+ *
6
+ * @example
7
+ * ```html [src/app.html]
8
+ * <html lang="%yapyak.lang%">
9
+ * ```
10
+ *
11
+ * @example Re-export from hooks.server.ts
12
+ * ```ts [src/hooks.server.ts]
13
+ * export { handle } from '@yapyak/sveltekit';
14
+ * ```
15
+ *
16
+ * @example Compose with other handles
17
+ * ```ts [src/hooks.server.ts]
18
+ * import { sequence } from '@sveltejs/kit/hooks';
19
+ * import { handle as yapyakHandle } from '@yapyak/sveltekit';
20
+ * import { handle as authHandle } from './auth';
21
+ *
22
+ * export const handle = sequence(yapyakHandle, authHandle);
23
+ * ```
24
+ */
25
+ declare const handle: Handle;
26
+ //#endregion
27
+ export { handle };
package/dist/index.js ADDED
@@ -0,0 +1,29 @@
1
+ import { getLocale } from "yapyak";
2
+ import { withResponse } from "yapyak/adapter";
3
+ //#region src/handle.ts
4
+ const PLACEHOLDER = "%yapyak.lang%";
5
+ /**
6
+ * Handle for SvelteKit. Provides yapyak's per-request locale context.
7
+ *
8
+ * @example
9
+ * ```html [src/app.html]
10
+ * <html lang="%yapyak.lang%">
11
+ * ```
12
+ *
13
+ * @example Re-export from hooks.server.ts
14
+ * ```ts [src/hooks.server.ts]
15
+ * export { handle } from '@yapyak/sveltekit';
16
+ * ```
17
+ *
18
+ * @example Compose with other handles
19
+ * ```ts [src/hooks.server.ts]
20
+ * import { sequence } from '@sveltejs/kit/hooks';
21
+ * import { handle as yapyakHandle } from '@yapyak/sveltekit';
22
+ * import { handle as authHandle } from './auth';
23
+ *
24
+ * export const handle = sequence(yapyakHandle, authHandle);
25
+ * ```
26
+ */
27
+ const handle = ({ event, resolve }) => withResponse(event.request, () => resolve(event, { transformPageChunk: ({ html }) => html.replaceAll(PLACEHOLDER, getLocale()) }));
28
+ //#endregion
29
+ export { handle };
package/package.json ADDED
@@ -0,0 +1,57 @@
1
+ {
2
+ "name": "@yapyak/sveltekit",
3
+ "version": "0.0.1",
4
+ "description": "SvelteKit adapter for yapyak.",
5
+ "keywords": [
6
+ "adapter",
7
+ "i18n",
8
+ "svelte",
9
+ "sveltekit",
10
+ "translation",
11
+ "yapyak"
12
+ ],
13
+ "homepage": "https://yapyak.dev",
14
+ "bugs": "https://github.com/yapyak/yapyak/issues",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/yapyak/yapyak.git",
18
+ "directory": "packages/sveltekit"
19
+ },
20
+ "license": "MIT",
21
+ "author": "Joakim Uhrwing",
22
+ "sideEffects": false,
23
+ "type": "module",
24
+ "exports": {
25
+ ".": {
26
+ "types": "./dist/index.d.ts",
27
+ "default": "./dist/index.js"
28
+ }
29
+ },
30
+ "files": [
31
+ "dist"
32
+ ],
33
+ "devDependencies": {
34
+ "@sveltejs/kit": "2.70.1",
35
+ "svelte": "5.56.7",
36
+ "tsdown": "0.22.12",
37
+ "typescript": "6.0.3",
38
+ "vitest": "4.1.10",
39
+ "@yapyak/tsdown-config": "0.0.0",
40
+ "@yapyak/typescript-config": "0.0.0"
41
+ },
42
+ "peerDependencies": {
43
+ "@sveltejs/kit": ">=2",
44
+ "yapyak": "0.0.1"
45
+ },
46
+ "engines": {
47
+ "node": ">=22.22"
48
+ },
49
+ "publishConfig": {
50
+ "access": "public"
51
+ },
52
+ "scripts": {
53
+ "build": "tsdown",
54
+ "test": "pnpm -w vitest --run --project=@yapyak/sveltekit",
55
+ "typecheck": "tsc --noEmit"
56
+ }
57
+ }