katanakit-js 2.1.5
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/CHANGELOG.md +96 -0
- package/LICENSE +22 -0
- package/README.md +446 -0
- package/dist/adapters/astro/astro.service.d.ts +18 -0
- package/dist/adapters/astro/astro.service.d.ts.map +1 -0
- package/dist/adapters/astro/astro.service.js +83 -0
- package/dist/adapters/astro/astro.service.js.map +1 -0
- package/dist/adapters/astro/index.d.ts +4 -0
- package/dist/adapters/astro/index.d.ts.map +1 -0
- package/dist/adapters/astro/index.js +4 -0
- package/dist/adapters/astro/index.js.map +1 -0
- package/dist/adapters/astro/rss.service.d.ts +115 -0
- package/dist/adapters/astro/rss.service.d.ts.map +1 -0
- package/dist/adapters/astro/rss.service.js +231 -0
- package/dist/adapters/astro/rss.service.js.map +1 -0
- package/dist/adapters/express/app.d.ts +4 -0
- package/dist/adapters/express/app.d.ts.map +1 -0
- package/dist/adapters/express/app.js +4 -0
- package/dist/adapters/express/app.js.map +1 -0
- package/dist/adapters/express/index.d.ts +5 -0
- package/dist/adapters/express/index.d.ts.map +1 -0
- package/dist/adapters/express/index.js +5 -0
- package/dist/adapters/express/index.js.map +1 -0
- package/dist/adapters/express/main.d.ts +2 -0
- package/dist/adapters/express/main.d.ts.map +1 -0
- package/dist/adapters/express/main.js +3 -0
- package/dist/adapters/express/main.js.map +1 -0
- package/dist/adapters/express/products.controller.d.ts +10 -0
- package/dist/adapters/express/products.controller.d.ts.map +1 -0
- package/dist/adapters/express/products.controller.js +53 -0
- package/dist/adapters/express/products.controller.js.map +1 -0
- package/dist/adapters/express/router.d.ts +3 -0
- package/dist/adapters/express/router.d.ts.map +1 -0
- package/dist/adapters/express/router.js +14 -0
- package/dist/adapters/express/router.js.map +1 -0
- package/dist/adapters/express/server.d.ts +15 -0
- package/dist/adapters/express/server.d.ts.map +1 -0
- package/dist/adapters/express/server.js +59 -0
- package/dist/adapters/express/server.js.map +1 -0
- package/dist/adapters/index.d.ts +2 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +2 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/adapters/nuxt/index.d.ts +2 -0
- package/dist/adapters/nuxt/index.d.ts.map +1 -0
- package/dist/adapters/nuxt/index.js +2 -0
- package/dist/adapters/nuxt/index.js.map +1 -0
- package/dist/adapters/nuxt/nuxt.service.d.ts +83 -0
- package/dist/adapters/nuxt/nuxt.service.d.ts.map +1 -0
- package/dist/adapters/nuxt/nuxt.service.js +104 -0
- package/dist/adapters/nuxt/nuxt.service.js.map +1 -0
- package/dist/config/index.d.ts +3 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +3 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/seo.service.d.ts +72 -0
- package/dist/config/seo.service.d.ts.map +1 -0
- package/dist/config/seo.service.js +190 -0
- package/dist/config/seo.service.js.map +1 -0
- package/dist/config/site.config.d.ts +89 -0
- package/dist/config/site.config.d.ts.map +1 -0
- package/dist/config/site.config.js +59 -0
- package/dist/config/site.config.js.map +1 -0
- package/dist/core/index.d.ts +13 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +13 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/services/dates.service.d.ts +24 -0
- package/dist/core/services/dates.service.d.ts.map +1 -0
- package/dist/core/services/dates.service.js +64 -0
- package/dist/core/services/dates.service.js.map +1 -0
- package/dist/core/services/error.service.d.ts +25 -0
- package/dist/core/services/error.service.d.ts.map +1 -0
- package/dist/core/services/error.service.js +39 -0
- package/dist/core/services/error.service.js.map +1 -0
- package/dist/core/services/formatter.service.d.ts +36 -0
- package/dist/core/services/formatter.service.d.ts.map +1 -0
- package/dist/core/services/formatter.service.js +64 -0
- package/dist/core/services/formatter.service.js.map +1 -0
- package/dist/core/services/generator.service.d.ts +34 -0
- package/dist/core/services/generator.service.d.ts.map +1 -0
- package/dist/core/services/generator.service.js +83 -0
- package/dist/core/services/generator.service.js.map +1 -0
- package/dist/core/services/geometry.service.d.ts +45 -0
- package/dist/core/services/geometry.service.d.ts.map +1 -0
- package/dist/core/services/geometry.service.js +100 -0
- package/dist/core/services/geometry.service.js.map +1 -0
- package/dist/core/services/http.service.d.ts +22 -0
- package/dist/core/services/http.service.d.ts.map +1 -0
- package/dist/core/services/http.service.js +124 -0
- package/dist/core/services/http.service.js.map +1 -0
- package/dist/core/services/logger.service.d.ts +36 -0
- package/dist/core/services/logger.service.d.ts.map +1 -0
- package/dist/core/services/logger.service.js +60 -0
- package/dist/core/services/logger.service.js.map +1 -0
- package/dist/core/services/reactive.service.d.ts +22 -0
- package/dist/core/services/reactive.service.d.ts.map +1 -0
- package/dist/core/services/reactive.service.js +167 -0
- package/dist/core/services/reactive.service.js.map +1 -0
- package/dist/core/services/timing.service.d.ts +23 -0
- package/dist/core/services/timing.service.d.ts.map +1 -0
- package/dist/core/services/timing.service.js +217 -0
- package/dist/core/services/timing.service.js.map +1 -0
- package/dist/core/services/utils.service.d.ts +44 -0
- package/dist/core/services/utils.service.d.ts.map +1 -0
- package/dist/core/services/utils.service.js +143 -0
- package/dist/core/services/utils.service.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/dom/dom.service.d.ts +49 -0
- package/dist/infrastructure/dom/dom.service.d.ts.map +1 -0
- package/dist/infrastructure/dom/dom.service.js +133 -0
- package/dist/infrastructure/dom/dom.service.js.map +1 -0
- package/dist/infrastructure/index.d.ts +11 -0
- package/dist/infrastructure/index.d.ts.map +1 -0
- package/dist/infrastructure/index.js +11 -0
- package/dist/infrastructure/index.js.map +1 -0
- package/dist/infrastructure/observer/observer.service.d.ts +34 -0
- package/dist/infrastructure/observer/observer.service.d.ts.map +1 -0
- package/dist/infrastructure/observer/observer.service.js +145 -0
- package/dist/infrastructure/observer/observer.service.js.map +1 -0
- package/dist/infrastructure/sensors/sensors.service.d.ts +25 -0
- package/dist/infrastructure/sensors/sensors.service.d.ts.map +1 -0
- package/dist/infrastructure/sensors/sensors.service.js +133 -0
- package/dist/infrastructure/sensors/sensors.service.js.map +1 -0
- package/dist/infrastructure/storage/storage.service.d.ts +48 -0
- package/dist/infrastructure/storage/storage.service.d.ts.map +1 -0
- package/dist/infrastructure/storage/storage.service.js +108 -0
- package/dist/infrastructure/storage/storage.service.js.map +1 -0
- package/dist/infrastructure/theme/theme.service.d.ts +30 -0
- package/dist/infrastructure/theme/theme.service.d.ts.map +1 -0
- package/dist/infrastructure/theme/theme.service.js +104 -0
- package/dist/infrastructure/theme/theme.service.js.map +1 -0
- package/dist/infrastructure/viewport/viewport.service.d.ts +38 -0
- package/dist/infrastructure/viewport/viewport.service.d.ts.map +1 -0
- package/dist/infrastructure/viewport/viewport.service.js +145 -0
- package/dist/infrastructure/viewport/viewport.service.js.map +1 -0
- package/dist/infrastructure/worker/worker.service.d.ts +42 -0
- package/dist/infrastructure/worker/worker.service.d.ts.map +1 -0
- package/dist/infrastructure/worker/worker.service.js +151 -0
- package/dist/infrastructure/worker/worker.service.js.map +1 -0
- package/dist/prisma/db.d.ts +4 -0
- package/dist/prisma/db.d.ts.map +1 -0
- package/dist/prisma/db.js +12 -0
- package/dist/prisma/db.js.map +1 -0
- package/dist/prisma/schema.json +411 -0
- package/dist/types/index.d.ts +436 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +117 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/adapters/nuxt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/adapters/nuxt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { FetchResult } from "../../types/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Unwraps a KatanaKit Safe Result, throwing an H3-compatible error on failure.
|
|
4
|
+
* Returns the data directly on success.
|
|
5
|
+
*
|
|
6
|
+
* @param result - The Safe Result from `useFetch`, `useGet`, `usePost`, etc.
|
|
7
|
+
* @param context - Optional context prefix for the error message.
|
|
8
|
+
* @returns The data from the result.
|
|
9
|
+
* @throws H3-compatible error with the appropriate status code.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* // server/api/pokemon/[id].ts
|
|
14
|
+
* import { useGet } from "katanakit-js";
|
|
15
|
+
* import { useUnwrap } from "katanakit-js/adapters/nuxt";
|
|
16
|
+
*
|
|
17
|
+
* export default defineEventHandler(async (event) => {
|
|
18
|
+
* const id = getRouterParam(event, "id");
|
|
19
|
+
* const result = await useGet("pokeapi", "pokemonById", { params: { id } });
|
|
20
|
+
* return useUnwrap(result, `Pokemon ${id}`);
|
|
21
|
+
* });
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
export declare function useUnwrap<T>(result: FetchResult<T>, context?: string): T;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a Safe Result response for Nuxt API routes.
|
|
27
|
+
* Returns the data with proper status code on success,
|
|
28
|
+
* or an error response on failure.
|
|
29
|
+
*
|
|
30
|
+
* @param result - The Safe Result from any KatanaKit fetch method.
|
|
31
|
+
* @returns An H3-compatible response object.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* // server/api/users.ts
|
|
36
|
+
* import { useGet } from "katanakit-js";
|
|
37
|
+
* import { useSafeResponse } from "katanakit-js/adapters/nuxt";
|
|
38
|
+
*
|
|
39
|
+
* export default defineEventHandler(async () => {
|
|
40
|
+
* const result = await useGet("api", "users");
|
|
41
|
+
* return useSafeResponse(result);
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare function useSafeResponse<T>(result: FetchResult<T>): {
|
|
46
|
+
data: T | null;
|
|
47
|
+
error: {
|
|
48
|
+
message: string;
|
|
49
|
+
status: number;
|
|
50
|
+
} | null;
|
|
51
|
+
ok: boolean;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Maps a KatanaKit Safe Result to an H3 event response.
|
|
55
|
+
* Sets the appropriate status code and returns the data or error.
|
|
56
|
+
*
|
|
57
|
+
* @param event - The H3 event object.
|
|
58
|
+
* @param result - The Safe Result from any KatanaKit fetch method.
|
|
59
|
+
* @returns The data on success.
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* // server/api/products.ts
|
|
64
|
+
* import { useFetch } from "katanakit-js";
|
|
65
|
+
* import { useEventResponse } from "katanakit-js/adapters/nuxt";
|
|
66
|
+
*
|
|
67
|
+
* export default defineEventHandler(async (event) => {
|
|
68
|
+
* const result = await useFetch("shop", "products");
|
|
69
|
+
* return useEventResponse(event, result);
|
|
70
|
+
* });
|
|
71
|
+
* ```
|
|
72
|
+
*/
|
|
73
|
+
export declare function useEventResponse<T>(event: {
|
|
74
|
+
node: {
|
|
75
|
+
res: {
|
|
76
|
+
statusCode: number;
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
}, result: FetchResult<T>): T | {
|
|
80
|
+
error: string;
|
|
81
|
+
status: number;
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=nuxt.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nuxt.service.d.ts","sourceRoot":"","sources":["../../../src/adapters/nuxt/nuxt.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,CAAC,CAYxE;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG;IAC3D,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IACf,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAClD,EAAE,EAAE,OAAO,CAAC;CACZ,CAaA;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EACjC,KAAK,EAAE;IAAE,IAAI,EAAE;QAAE,GAAG,EAAE;YAAE,UAAU,EAAE,MAAM,CAAA;SAAE,CAAA;KAAE,CAAA;CAAE,EAChD,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,GACpB,CAAC,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAWvC"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unwraps a KatanaKit Safe Result, throwing an H3-compatible error on failure.
|
|
3
|
+
* Returns the data directly on success.
|
|
4
|
+
*
|
|
5
|
+
* @param result - The Safe Result from `useFetch`, `useGet`, `usePost`, etc.
|
|
6
|
+
* @param context - Optional context prefix for the error message.
|
|
7
|
+
* @returns The data from the result.
|
|
8
|
+
* @throws H3-compatible error with the appropriate status code.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* // server/api/pokemon/[id].ts
|
|
13
|
+
* import { useGet } from "katanakit-js";
|
|
14
|
+
* import { useUnwrap } from "katanakit-js/adapters/nuxt";
|
|
15
|
+
*
|
|
16
|
+
* export default defineEventHandler(async (event) => {
|
|
17
|
+
* const id = getRouterParam(event, "id");
|
|
18
|
+
* const result = await useGet("pokeapi", "pokemonById", { params: { id } });
|
|
19
|
+
* return useUnwrap(result, `Pokemon ${id}`);
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export function useUnwrap(result, context) {
|
|
24
|
+
if (result.ok) {
|
|
25
|
+
return result.data;
|
|
26
|
+
}
|
|
27
|
+
const message = context ? `${context}: ${result.error.message}` : result.error.message;
|
|
28
|
+
const statusCode = result.error.status || 500;
|
|
29
|
+
// Dynamic import to avoid hard dependency on h3.
|
|
30
|
+
// Consumers must have h3 installed (it comes with Nuxt).
|
|
31
|
+
throw createH3Error(statusCode, message);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Creates a Safe Result response for Nuxt API routes.
|
|
35
|
+
* Returns the data with proper status code on success,
|
|
36
|
+
* or an error response on failure.
|
|
37
|
+
*
|
|
38
|
+
* @param result - The Safe Result from any KatanaKit fetch method.
|
|
39
|
+
* @returns An H3-compatible response object.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* // server/api/users.ts
|
|
44
|
+
* import { useGet } from "katanakit-js";
|
|
45
|
+
* import { useSafeResponse } from "katanakit-js/adapters/nuxt";
|
|
46
|
+
*
|
|
47
|
+
* export default defineEventHandler(async () => {
|
|
48
|
+
* const result = await useGet("api", "users");
|
|
49
|
+
* return useSafeResponse(result);
|
|
50
|
+
* });
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
export function useSafeResponse(result) {
|
|
54
|
+
if (result.ok) {
|
|
55
|
+
return { data: result.data, error: null, ok: true };
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
data: null,
|
|
59
|
+
error: {
|
|
60
|
+
message: result.error.message,
|
|
61
|
+
status: result.error.status,
|
|
62
|
+
},
|
|
63
|
+
ok: false,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Maps a KatanaKit Safe Result to an H3 event response.
|
|
68
|
+
* Sets the appropriate status code and returns the data or error.
|
|
69
|
+
*
|
|
70
|
+
* @param event - The H3 event object.
|
|
71
|
+
* @param result - The Safe Result from any KatanaKit fetch method.
|
|
72
|
+
* @returns The data on success.
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* // server/api/products.ts
|
|
77
|
+
* import { useFetch } from "katanakit-js";
|
|
78
|
+
* import { useEventResponse } from "katanakit-js/adapters/nuxt";
|
|
79
|
+
*
|
|
80
|
+
* export default defineEventHandler(async (event) => {
|
|
81
|
+
* const result = await useFetch("shop", "products");
|
|
82
|
+
* return useEventResponse(event, result);
|
|
83
|
+
* });
|
|
84
|
+
* ```
|
|
85
|
+
*/
|
|
86
|
+
export function useEventResponse(event, result) {
|
|
87
|
+
if (result.ok) {
|
|
88
|
+
event.node.res.statusCode = 200;
|
|
89
|
+
return result.data;
|
|
90
|
+
}
|
|
91
|
+
event.node.res.statusCode = result.error.status || 500;
|
|
92
|
+
return {
|
|
93
|
+
error: result.error.message,
|
|
94
|
+
status: result.error.status,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
// Internal helper: creates an error that looks like an H3 error.
|
|
98
|
+
// We don't import h3 directly to avoid a hard peer dependency.
|
|
99
|
+
function createH3Error(statusCode, message) {
|
|
100
|
+
const error = new Error(message);
|
|
101
|
+
error.statusCode = statusCode;
|
|
102
|
+
return error;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=nuxt.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nuxt.service.js","sourceRoot":"","sources":["../../../src/adapters/nuxt/nu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G,CAAC,UAAU,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,IAAI,GAAG,CAAC;IACvD,OAAO;QACN,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,OAAO;QAC3B,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM;KAC3B,CAAC;AACH,CAAC;AAED,iEAAiE;AACjE,+DAA+D;AAC/D,SAAS,aAAa,CAAC,UAAkB,EAAE,OAAe;IACzD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,OAAO,CAAmC,CAAC;IACnE,KAAK,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,OAAO,KAAK,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,OAAO,EACZ,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,QAAQ,GACR,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,KAAK,UAAU,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,QAAQ,GACR,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAmB,UAAU,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { SiteConfig } from "./site.config.js";
|
|
2
|
+
/**
|
|
3
|
+
* SEO meta tag configuration for a single page.
|
|
4
|
+
*/
|
|
5
|
+
export interface SeoMeta {
|
|
6
|
+
/** Page title (will be suffixed with site title). */
|
|
7
|
+
title: string;
|
|
8
|
+
/** Page description (falls back to site description). */
|
|
9
|
+
description?: string;
|
|
10
|
+
/** Canonical URL (absolute). If omitted, derived from `url`. */
|
|
11
|
+
canonical?: string;
|
|
12
|
+
/** Page URL (absolute, e.g. "https://example.com/blog/post/"). */
|
|
13
|
+
url?: string;
|
|
14
|
+
/** OG image URL (absolute). Falls back to site config. */
|
|
15
|
+
ogImage?: string;
|
|
16
|
+
/** Content type: "website" | "article" | "profile" (default: "website"). */
|
|
17
|
+
ogType?: "website" | "article" | "profile";
|
|
18
|
+
/** Article published date (ISO string, for og:type=article). */
|
|
19
|
+
publishedTime?: string;
|
|
20
|
+
/** Article modified date (ISO string, for og:type=article). */
|
|
21
|
+
modifiedTime?: string;
|
|
22
|
+
/** Article author (for og:type=article). */
|
|
23
|
+
author?: string;
|
|
24
|
+
/** Article tags (for og:type=article). */
|
|
25
|
+
tags?: string[];
|
|
26
|
+
/** Whether to add noindex (default: false). */
|
|
27
|
+
noindex?: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Generates all `<head>` meta tags for SEO, Open Graph, Twitter Card,
|
|
31
|
+
* canonical URL, and JSON-LD structured data.
|
|
32
|
+
*
|
|
33
|
+
* @param config - Site-wide configuration.
|
|
34
|
+
* @param meta - Page-specific meta.
|
|
35
|
+
* @returns HTML string of meta tags to inject in `<head>`.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```astro
|
|
39
|
+
* ---
|
|
40
|
+
* import { siteConfig } from "@/config/site.config";
|
|
41
|
+
* import { useGenerateMetaTags } from "@/config/seo.service";
|
|
42
|
+
*
|
|
43
|
+
* const metaTags = useGenerateMetaTags(siteConfig, {
|
|
44
|
+
* title: "My Blog Post",
|
|
45
|
+
* description: "A great post about TypeScript",
|
|
46
|
+
* url: "https://example.com/blog/my-post/",
|
|
47
|
+
* ogType: "article",
|
|
48
|
+
* publishedTime: "2024-01-15T00:00:00Z",
|
|
49
|
+
* });
|
|
50
|
+
* ---
|
|
51
|
+
* <head>
|
|
52
|
+
* <Fragment set:html={metaTags} />
|
|
53
|
+
* </head>
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export declare function useGenerateMetaTags(config: SiteConfig, meta: SeoMeta): string;
|
|
57
|
+
/**
|
|
58
|
+
* Generates a `<title>` tag string.
|
|
59
|
+
*/
|
|
60
|
+
export declare function useTitle(config: SiteConfig, pageTitle?: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Generates the RSS `<link>` tag for the `<head>`.
|
|
63
|
+
*/
|
|
64
|
+
export declare function useRssHeadLink(config: SiteConfig): string;
|
|
65
|
+
/**
|
|
66
|
+
* Generates all default `<head>` meta tags for a page (title, description,
|
|
67
|
+
* canonical, OG, Twitter, JSON-LD, RSS link).
|
|
68
|
+
*
|
|
69
|
+
* Convenience wrapper around `useGenerateMetaTags` + `useRssHeadLink`.
|
|
70
|
+
*/
|
|
71
|
+
export declare function useHeadTags(config: SiteConfig, meta: SeoMeta): string;
|
|
72
|
+
//# sourceMappingURL=seo.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seo.service.d.ts","sourceRoot":"","sources":["../../src/config/seo.service.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,OAAO;IACvB,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kEAAkE;IAClE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,0DAA0D;IAC1D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IAC3C,gEAAgE;IAChE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+DAA+D;IAC/D,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,4CAA4C;IAC5C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,CAmG7E;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAKvE;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,CAKzD;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,CAIrE"}
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates all `<head>` meta tags for SEO, Open Graph, Twitter Card,
|
|
3
|
+
* canonical URL, and JSON-LD structured data.
|
|
4
|
+
*
|
|
5
|
+
* @param config - Site-wide configuration.
|
|
6
|
+
* @param meta - Page-specific meta.
|
|
7
|
+
* @returns HTML string of meta tags to inject in `<head>`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```astro
|
|
11
|
+
* ---
|
|
12
|
+
* import { siteConfig } from "@/config/site.config";
|
|
13
|
+
* import { useGenerateMetaTags } from "@/config/seo.service";
|
|
14
|
+
*
|
|
15
|
+
* const metaTags = useGenerateMetaTags(siteConfig, {
|
|
16
|
+
* title: "My Blog Post",
|
|
17
|
+
* description: "A great post about TypeScript",
|
|
18
|
+
* url: "https://example.com/blog/my-post/",
|
|
19
|
+
* ogType: "article",
|
|
20
|
+
* publishedTime: "2024-01-15T00:00:00Z",
|
|
21
|
+
* });
|
|
22
|
+
* ---
|
|
23
|
+
* <head>
|
|
24
|
+
* <Fragment set:html={metaTags} />
|
|
25
|
+
* </head>
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export function useGenerateMetaTags(config, meta) {
|
|
29
|
+
const tags = [];
|
|
30
|
+
const fullTitle = meta.title === config.title ? config.title : `${meta.title} | ${config.title}`;
|
|
31
|
+
const description = meta.description ?? config.description;
|
|
32
|
+
const url = meta.url ?? config.site;
|
|
33
|
+
const ogImage = meta.ogImage ?? config.ogImage;
|
|
34
|
+
const ogImageUrl = ogImage
|
|
35
|
+
? ogImage.startsWith("http")
|
|
36
|
+
? ogImage
|
|
37
|
+
: `${config.site}${ogImage}`
|
|
38
|
+
: undefined;
|
|
39
|
+
// Basic meta tags.
|
|
40
|
+
tags.push(`<title>${escapeHtml(fullTitle)}</title>`);
|
|
41
|
+
tags.push(`<meta name="description" content="${escapeAttr(description)}" />`);
|
|
42
|
+
if (config.author) {
|
|
43
|
+
tags.push(`<meta name="author" content="${escapeAttr(config.author)}" />`);
|
|
44
|
+
}
|
|
45
|
+
// Canonical URL.
|
|
46
|
+
if (config.seo.canonical && url) {
|
|
47
|
+
const canonical = meta.canonical ?? url;
|
|
48
|
+
tags.push(`<link rel="canonical" href="${escapeAttr(canonical)}" />`);
|
|
49
|
+
}
|
|
50
|
+
// Noindex.
|
|
51
|
+
if (meta.noindex || config.seo.noindex) {
|
|
52
|
+
tags.push('<meta name="robots" content="noindex, nofollow" />');
|
|
53
|
+
}
|
|
54
|
+
// Open Graph.
|
|
55
|
+
if (config.seo.openGraph) {
|
|
56
|
+
tags.push(`<meta property="og:type" content="${meta.ogType ?? "website"}" />`);
|
|
57
|
+
tags.push(`<meta property="og:title" content="${escapeAttr(fullTitle)}" />`);
|
|
58
|
+
tags.push(`<meta property="og:description" content="${escapeAttr(description)}" />`);
|
|
59
|
+
tags.push(`<meta property="og:site_name" content="${escapeAttr(config.title)}" />`);
|
|
60
|
+
tags.push(`<meta property="og:locale" content="${escapeAttr(config.lang.replace("-", "_"))}" />`);
|
|
61
|
+
if (url) {
|
|
62
|
+
tags.push(`<meta property="og:url" content="${escapeAttr(url)}" />`);
|
|
63
|
+
}
|
|
64
|
+
if (ogImageUrl) {
|
|
65
|
+
tags.push(`<meta property="og:image" content="${escapeAttr(ogImageUrl)}" />`);
|
|
66
|
+
tags.push(`<meta property="og:image:alt" content="${escapeAttr(fullTitle)}" />`);
|
|
67
|
+
}
|
|
68
|
+
// Article-specific OG tags.
|
|
69
|
+
if (meta.ogType === "article") {
|
|
70
|
+
if (meta.publishedTime) {
|
|
71
|
+
tags.push(`<meta property="article:published_time" content="${escapeAttr(meta.publishedTime)}" />`);
|
|
72
|
+
}
|
|
73
|
+
if (meta.modifiedTime) {
|
|
74
|
+
tags.push(`<meta property="article:modified_time" content="${escapeAttr(meta.modifiedTime)}" />`);
|
|
75
|
+
}
|
|
76
|
+
if (meta.author) {
|
|
77
|
+
tags.push(`<meta property="article:author" content="${escapeAttr(meta.author)}" />`);
|
|
78
|
+
}
|
|
79
|
+
if (meta.tags) {
|
|
80
|
+
for (const tag of meta.tags) {
|
|
81
|
+
tags.push(`<meta property="article:tag" content="${escapeAttr(tag)}" />`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// Twitter Card.
|
|
87
|
+
if (config.seo.twitterCard) {
|
|
88
|
+
tags.push('<meta name="twitter:card" content="summary_large_image" />');
|
|
89
|
+
tags.push(`<meta name="twitter:title" content="${escapeAttr(fullTitle)}" />`);
|
|
90
|
+
tags.push(`<meta name="twitter:description" content="${escapeAttr(description)}" />`);
|
|
91
|
+
if (config.twitter) {
|
|
92
|
+
tags.push(`<meta name="twitter:site" content="@${escapeAttr(config.twitter)}" />`);
|
|
93
|
+
tags.push(`<meta name="twitter:creator" content="@${escapeAttr(config.twitter)}" />`);
|
|
94
|
+
}
|
|
95
|
+
if (ogImageUrl) {
|
|
96
|
+
tags.push(`<meta name="twitter:image" content="${escapeAttr(ogImageUrl)}" />`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
// JSON-LD structured data.
|
|
100
|
+
if (config.seo.jsonLd) {
|
|
101
|
+
const jsonLd = buildJsonLd(config, meta);
|
|
102
|
+
// Escape <, >, & to prevent XSS via </script> breakout.
|
|
103
|
+
const safeJson = JSON.stringify(jsonLd)
|
|
104
|
+
.replace(/</g, "\\u003c")
|
|
105
|
+
.replace(/>/g, "\\u003e")
|
|
106
|
+
.replace(/&/g, "\\u0026");
|
|
107
|
+
tags.push(`<script type="application/ld+json">${safeJson}</script>`);
|
|
108
|
+
}
|
|
109
|
+
return tags.join("\n");
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Generates a `<title>` tag string.
|
|
113
|
+
*/
|
|
114
|
+
export function useTitle(config, pageTitle) {
|
|
115
|
+
if (!pageTitle || pageTitle === config.title) {
|
|
116
|
+
return `<title>${escapeHtml(config.title)}</title>`;
|
|
117
|
+
}
|
|
118
|
+
return `<title>${escapeHtml(`${pageTitle} | ${config.title}`)}</title>`;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Generates the RSS `<link>` tag for the `<head>`.
|
|
122
|
+
*/
|
|
123
|
+
export function useRssHeadLink(config) {
|
|
124
|
+
if (!config.rss.enabled)
|
|
125
|
+
return "";
|
|
126
|
+
const path = config.rss.path ?? "/rss.xml";
|
|
127
|
+
const title = config.rss.title ?? config.title;
|
|
128
|
+
return `<link rel="alternate" type="application/rss+xml" title="${escapeAttr(title)}" href="${escapeAttr(path)}" />`;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Generates all default `<head>` meta tags for a page (title, description,
|
|
132
|
+
* canonical, OG, Twitter, JSON-LD, RSS link).
|
|
133
|
+
*
|
|
134
|
+
* Convenience wrapper around `useGenerateMetaTags` + `useRssHeadLink`.
|
|
135
|
+
*/
|
|
136
|
+
export function useHeadTags(config, meta) {
|
|
137
|
+
const metaTags = useGenerateMetaTags(config, meta);
|
|
138
|
+
const rssLink = useRssHeadLink(config);
|
|
139
|
+
return rssLink ? `${metaTags}\n${rssLink}` : metaTags;
|
|
140
|
+
}
|
|
141
|
+
// --- Internal helpers ---
|
|
142
|
+
function escapeHtml(text) {
|
|
143
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
144
|
+
}
|
|
145
|
+
function escapeAttr(text) {
|
|
146
|
+
return text
|
|
147
|
+
.replace(/&/g, "&")
|
|
148
|
+
.replace(/"/g, """)
|
|
149
|
+
.replace(/</g, "<")
|
|
150
|
+
.replace(/>/g, ">");
|
|
151
|
+
}
|
|
152
|
+
function buildJsonLd(config, meta) {
|
|
153
|
+
const url = meta.url ?? config.site;
|
|
154
|
+
if (meta.ogType === "article") {
|
|
155
|
+
return {
|
|
156
|
+
"@context": "https://schema.org",
|
|
157
|
+
"@type": "Article",
|
|
158
|
+
headline: meta.title,
|
|
159
|
+
description: meta.description ?? config.description,
|
|
160
|
+
url,
|
|
161
|
+
author: {
|
|
162
|
+
"@type": "Person",
|
|
163
|
+
name: meta.author ?? config.author,
|
|
164
|
+
},
|
|
165
|
+
publisher: {
|
|
166
|
+
"@type": "Organization",
|
|
167
|
+
name: config.title,
|
|
168
|
+
},
|
|
169
|
+
datePublished: meta.publishedTime,
|
|
170
|
+
dateModified: meta.modifiedTime ?? meta.publishedTime,
|
|
171
|
+
image: meta.ogImage ?? config.ogImage,
|
|
172
|
+
mainEntityOfPage: {
|
|
173
|
+
"@type": "WebPage",
|
|
174
|
+
"@id": url,
|
|
175
|
+
},
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
"@context": "https://schema.org",
|
|
180
|
+
"@type": "WebSite",
|
|
181
|
+
name: config.title,
|
|
182
|
+
description: config.description,
|
|
183
|
+
url: config.site,
|
|
184
|
+
author: {
|
|
185
|
+
"@type": "Person",
|
|
186
|
+
name: config.author,
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
//# sourceMappingURL=seo.service.js.map
|
|
@@ -0,0 +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D,SAAS,EAAE;gBACV,OAAO,EAAE,cAAc;gBACvB,IAAI,EAAE,MAAM,CAAC,KAAK;aAClB;YACD,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,aAAa;YACrD,KAAK,EAAE,IAAI,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO;YACrC,gBAAgB,EAAE;gBACjB,OAAO,EAAE,SAAS;gBAClB,KAAK,EAAE,GAAG;aACV;SACD,CAAC;IACH,CAAC;IAED,OAAO;QACN,UAAU,EAAE,oBAAoB;QAChC,OAAO,EAAE,SAAS;QAClB,IAAI,EAAE,MAAM,CAAC,KAAK;QAClB,WAAW,EAAE,MAAM,CAAC,WAAW;QAC/B,GAAG,EAAE,MAAM,CAAC,IAAI;QAChB,MAAM,EAAE;YACP,OAAO,EAAE,QAAQ;YACjB,IAAI,EAAE,MAAM,CAAC,MAAM;SACnB;KACD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Site-wide configuration for KatanaKit-powered Astro projects.
|
|
3
|
+
*
|
|
4
|
+
* Import this in your layouts, RSS endpoint, and SEO components
|
|
5
|
+
* to keep everything consistent.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* // astro.config.mjs
|
|
10
|
+
* import { siteConfig } from "./src/config/site.config.js";
|
|
11
|
+
* export default defineConfig({ site: siteConfig.site });
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export interface SiteConfig {
|
|
15
|
+
/** Base URL of the site (no trailing slash). */
|
|
16
|
+
site: string;
|
|
17
|
+
/** Site title (used in <title>, RSS, Open Graph). */
|
|
18
|
+
title: string;
|
|
19
|
+
/** Default meta description. */
|
|
20
|
+
description: string;
|
|
21
|
+
/** Language code (e.g. "en", "es"). */
|
|
22
|
+
lang: string;
|
|
23
|
+
/** Author name for RSS and meta tags. */
|
|
24
|
+
author: string;
|
|
25
|
+
/** Social/OG image URL (absolute or relative to public/). */
|
|
26
|
+
ogImage?: string;
|
|
27
|
+
/** Twitter handle (without @). */
|
|
28
|
+
twitter?: string;
|
|
29
|
+
/** RSS feed configuration. */
|
|
30
|
+
rss: {
|
|
31
|
+
/** Whether to enable the RSS feed (default: true). */
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
/** Output path (default: "/rss.xml"). */
|
|
34
|
+
path: string;
|
|
35
|
+
/** Feed title (defaults to site title). */
|
|
36
|
+
title?: string;
|
|
37
|
+
/** Feed description (defaults to site description). */
|
|
38
|
+
description?: string;
|
|
39
|
+
/** Number of items to include (default: 20). */
|
|
40
|
+
limit: number;
|
|
41
|
+
};
|
|
42
|
+
/** Default SEO settings. */
|
|
43
|
+
seo: {
|
|
44
|
+
/** Whether to add noindex to all pages (default: false). */
|
|
45
|
+
noindex: boolean;
|
|
46
|
+
/** Whether to add the canonical URL (default: true). */
|
|
47
|
+
canonical: boolean;
|
|
48
|
+
/** Whether to add Open Graph tags (default: true). */
|
|
49
|
+
openGraph: boolean;
|
|
50
|
+
/** Whether to add Twitter Card tags (default: true). */
|
|
51
|
+
twitterCard: boolean;
|
|
52
|
+
/** Whether to add JSON-LD structured data (default: true). */
|
|
53
|
+
jsonLd: boolean;
|
|
54
|
+
};
|
|
55
|
+
/** Navigation links (optional, for header/footer). */
|
|
56
|
+
nav?: Array<{
|
|
57
|
+
label: string;
|
|
58
|
+
href: string;
|
|
59
|
+
external?: boolean;
|
|
60
|
+
}>;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Default site configuration. Override in your project.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* // src/config/site.config.ts
|
|
68
|
+
* import { type SiteConfig } from "katanakit";
|
|
69
|
+
*
|
|
70
|
+
* export const siteConfig: SiteConfig = {
|
|
71
|
+
* site: "https://myblog.com",
|
|
72
|
+
* title: "My Blog",
|
|
73
|
+
* description: "A blog about TypeScript",
|
|
74
|
+
* lang: "en",
|
|
75
|
+
* author: "John Doe",
|
|
76
|
+
* ogImage: "/og-default.png",
|
|
77
|
+
* twitter: "johndoe",
|
|
78
|
+
* rss: { enabled: true, path: "/rss.xml", limit: 20 },
|
|
79
|
+
* seo: { noindex: false, canonical: true, openGraph: true, twitterCard: true, jsonLd: true },
|
|
80
|
+
* nav: [
|
|
81
|
+
* { label: "Home", href: "/" },
|
|
82
|
+
* { label: "Blog", href: "/blog" },
|
|
83
|
+
* { label: "GitHub", href: "https://github.com/...", external: true },
|
|
84
|
+
* ],
|
|
85
|
+
* };
|
|
86
|
+
* ```
|
|
87
|
+
*/
|
|
88
|
+
export declare const siteConfig: SiteConfig;
|
|
89
|
+
//# sourceMappingURL=site.config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"site.config.d.ts","sourceRoot":"","sources":["../../src/config/site.config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,MAAM,WAAW,UAAU;IAC1B,gDAAgD;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,uCAAuC;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kCAAkC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8BAA8B;IAC9B,GAAG,EAAE;QACJ,sDAAsD;QACtD,OAAO,EAAE,OAAO,CAAC;QACjB,yCAAyC;QACzC,IAAI,EAAE,MAAM,CAAC;QACb,2CAA2C;QAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,uDAAuD;QACvD,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,gDAAgD;QAChD,KAAK,EAAE,MA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