@pyreon/zero 0.12.2 → 0.12.3
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/lib/actions.js +97 -0
- package/lib/actions.js.map +1 -0
- package/lib/ai.js +503 -0
- package/lib/ai.js.map +1 -0
- package/lib/api-routes.js +137 -0
- package/lib/api-routes.js.map +1 -0
- package/lib/compression.js +80 -0
- package/lib/compression.js.map +1 -0
- package/lib/cors.js +57 -0
- package/lib/cors.js.map +1 -0
- package/lib/csp.js +119 -0
- package/lib/csp.js.map +1 -0
- package/lib/env.js +217 -0
- package/lib/env.js.map +1 -0
- package/lib/favicon.js +424 -0
- package/lib/favicon.js.map +1 -0
- package/lib/i18n-routing.js +167 -0
- package/lib/i18n-routing.js.map +1 -0
- package/lib/index.js +80 -22
- package/lib/index.js.map +1 -1
- package/lib/link.js +5 -0
- package/lib/link.js.map +1 -1
- package/lib/logger.js +78 -0
- package/lib/logger.js.map +1 -0
- package/lib/meta.js +336 -0
- package/lib/meta.js.map +1 -0
- package/lib/middleware.js +53 -0
- package/lib/middleware.js.map +1 -0
- package/lib/og-image.js +233 -0
- package/lib/og-image.js.map +1 -0
- package/lib/rate-limit.js +76 -0
- package/lib/rate-limit.js.map +1 -0
- package/lib/testing.js +179 -0
- package/lib/testing.js.map +1 -0
- package/lib/theme.js +11 -2
- package/lib/theme.js.map +1 -1
- package/lib/types/actions.d.ts +27 -24
- package/lib/types/actions.d.ts.map +1 -1
- package/lib/types/ai.d.ts +76 -95
- package/lib/types/ai.d.ts.map +1 -1
- package/lib/types/api-routes.d.ts +37 -33
- package/lib/types/api-routes.d.ts.map +1 -1
- package/lib/types/cache.d.ts +26 -22
- package/lib/types/cache.d.ts.map +1 -1
- package/lib/types/client.d.ts +13 -9
- package/lib/types/client.d.ts.map +1 -1
- package/lib/types/compression.d.ts +14 -10
- package/lib/types/compression.d.ts.map +1 -1
- package/lib/types/config.d.ts +39 -4
- package/lib/types/config.d.ts.map +1 -1
- package/lib/types/cors.d.ts +20 -16
- package/lib/types/cors.d.ts.map +1 -1
- package/lib/types/csp.d.ts +42 -61
- package/lib/types/csp.d.ts.map +1 -1
- package/lib/types/env.d.ts +26 -26
- package/lib/types/env.d.ts.map +1 -1
- package/lib/types/favicon.d.ts +58 -54
- package/lib/types/favicon.d.ts.map +1 -1
- package/lib/types/font.d.ts +68 -65
- package/lib/types/font.d.ts.map +1 -1
- package/lib/types/i18n-routing.d.ts +43 -37
- package/lib/types/i18n-routing.d.ts.map +1 -1
- package/lib/types/image-plugin.d.ts +49 -45
- package/lib/types/image-plugin.d.ts.map +1 -1
- package/lib/types/image.d.ts +47 -36
- package/lib/types/image.d.ts.map +1 -1
- package/lib/types/index.d.ts +1961 -56
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/link.d.ts +61 -56
- package/lib/types/link.d.ts.map +1 -1
- package/lib/types/logger.d.ts +37 -48
- package/lib/types/logger.d.ts.map +1 -1
- package/lib/types/meta.d.ts +180 -105
- package/lib/types/meta.d.ts.map +1 -1
- package/lib/types/middleware.d.ts +8 -4
- package/lib/types/middleware.d.ts.map +1 -1
- package/lib/types/og-image.d.ts +63 -59
- package/lib/types/og-image.d.ts.map +1 -1
- package/lib/types/rate-limit.d.ts +20 -16
- package/lib/types/rate-limit.d.ts.map +1 -1
- package/lib/types/script.d.ts +23 -19
- package/lib/types/script.d.ts.map +1 -1
- package/lib/types/seo.d.ts +47 -43
- package/lib/types/seo.d.ts.map +1 -1
- package/lib/types/testing.d.ts +64 -27
- package/lib/types/testing.d.ts.map +1 -1
- package/lib/types/theme.d.ts +22 -12
- package/lib/types/theme.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/actions.ts +1 -3
- package/src/adapters/bun.ts +2 -0
- package/src/adapters/cloudflare.ts +2 -0
- package/src/adapters/netlify.ts +2 -0
- package/src/adapters/node.ts +2 -0
- package/src/adapters/validate.ts +16 -0
- package/src/adapters/vercel.ts +2 -0
- package/src/compression.ts +19 -3
- package/src/entry-server.ts +28 -5
- package/src/index.ts +1 -0
- package/src/link.tsx +6 -0
- package/src/meta.tsx +41 -13
- package/src/rate-limit.ts +11 -9
- package/src/theme.tsx +12 -1
- package/src/vite-plugin.ts +5 -1
- package/lib/types/adapters/bun.d.ts +0 -6
- package/lib/types/adapters/bun.d.ts.map +0 -1
- package/lib/types/adapters/cloudflare.d.ts +0 -26
- package/lib/types/adapters/cloudflare.d.ts.map +0 -1
- package/lib/types/adapters/index.d.ts +0 -13
- package/lib/types/adapters/index.d.ts.map +0 -1
- package/lib/types/adapters/netlify.d.ts +0 -21
- package/lib/types/adapters/netlify.d.ts.map +0 -1
- package/lib/types/adapters/node.d.ts +0 -6
- package/lib/types/adapters/node.d.ts.map +0 -1
- package/lib/types/adapters/static.d.ts +0 -7
- package/lib/types/adapters/static.d.ts.map +0 -1
- package/lib/types/adapters/vercel.d.ts +0 -21
- package/lib/types/adapters/vercel.d.ts.map +0 -1
- package/lib/types/app.d.ts +0 -24
- package/lib/types/app.d.ts.map +0 -1
- package/lib/types/entry-server.d.ts +0 -37
- package/lib/types/entry-server.d.ts.map +0 -1
- package/lib/types/error-overlay.d.ts +0 -6
- package/lib/types/error-overlay.d.ts.map +0 -1
- package/lib/types/fs-router.d.ts +0 -47
- package/lib/types/fs-router.d.ts.map +0 -1
- package/lib/types/isr.d.ts +0 -9
- package/lib/types/isr.d.ts.map +0 -1
- package/lib/types/not-found.d.ts +0 -7
- package/lib/types/not-found.d.ts.map +0 -1
- package/lib/types/types.d.ts +0 -111
- package/lib/types/types.d.ts.map +0 -1
- package/lib/types/utils/use-intersection-observer.d.ts +0 -10
- package/lib/types/utils/use-intersection-observer.d.ts.map +0 -1
- package/lib/types/utils/with-headers.d.ts +0 -6
- package/lib/types/utils/with-headers.d.ts.map +0 -1
- package/lib/types/vite-plugin.d.ts +0 -17
- package/lib/types/vite-plugin.d.ts.map +0 -1
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Middleware, MiddlewareContext } from "@pyreon/server";
|
|
2
|
+
|
|
3
|
+
//#region src/middleware.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Compose multiple middleware into a single middleware function.
|
|
4
6
|
* Middleware runs sequentially — if any returns a Response, the chain stops.
|
|
@@ -14,7 +16,7 @@ import type { Middleware, MiddlewareContext } from '@pyreon/server';
|
|
|
14
16
|
* cacheMiddleware(),
|
|
15
17
|
* )
|
|
16
18
|
*/
|
|
17
|
-
|
|
19
|
+
declare function compose(...middlewares: Middleware[]): Middleware;
|
|
18
20
|
/**
|
|
19
21
|
* Get the shared Zero context from a middleware context.
|
|
20
22
|
* Creates one if it doesn't exist. Middleware can use this to
|
|
@@ -31,5 +33,7 @@ export declare function compose(...middlewares: Middleware[]): Middleware;
|
|
|
31
33
|
* console.log("User:", zctx.userId)
|
|
32
34
|
* }
|
|
33
35
|
*/
|
|
34
|
-
|
|
35
|
-
//#
|
|
36
|
+
declare function getContext(ctx: MiddlewareContext): Record<string, unknown>;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { compose, getContext };
|
|
39
|
+
//# sourceMappingURL=middleware2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"middleware2.d.ts","names":[],"sources":["../../../src/middleware.ts"],"mappings":";;;;;AAwBA;;;;;;;;;AAiCA;;;;iBAjCgB,OAAA,CAAA,GAAW,WAAA,EAAa,UAAA,KAAe,UAAA;;;;;;;;;;;;;;;;;iBAiCvC,UAAA,CAAW,GAAA,EAAK,iBAAA,GAAoB,MAAA"}
|
package/lib/types/og-image.d.ts
CHANGED
|
@@ -1,72 +1,74 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
|
|
3
|
+
//#region src/og-image.d.ts
|
|
4
|
+
interface OgImageLayer {
|
|
5
|
+
/**
|
|
6
|
+
* Text content. Can be:
|
|
7
|
+
* - A string (same for all locales)
|
|
8
|
+
* - A record mapping locale → text
|
|
9
|
+
* - A function receiving locale and returning text
|
|
10
|
+
*/
|
|
11
|
+
text: string | Record<string, string> | ((locale: string) => string);
|
|
12
|
+
/** X position — number (px) or string with % (e.g. "50%"). Default: "50%" */
|
|
13
|
+
x?: number | string;
|
|
14
|
+
/** Y position — number (px) or string with % (e.g. "40%"). Default: "50%" */
|
|
15
|
+
y?: number | string;
|
|
16
|
+
/** Font size in px. Default: 64 */
|
|
17
|
+
fontSize?: number;
|
|
18
|
+
/** Font family. Default: "sans-serif" */
|
|
19
|
+
fontFamily?: string;
|
|
20
|
+
/** Font weight. Default: "bold" */
|
|
21
|
+
fontWeight?: string;
|
|
22
|
+
/** Text color. Default: "#ffffff" */
|
|
23
|
+
color?: string;
|
|
24
|
+
/** Text anchor (alignment). Default: "middle" */
|
|
25
|
+
textAnchor?: 'start' | 'middle' | 'end';
|
|
26
|
+
/** Max width in px before wrapping. Default: 80% of image width. */
|
|
27
|
+
maxWidth?: number;
|
|
26
28
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
width?: number;
|
|
39
|
-
height?: number;
|
|
40
|
-
};
|
|
41
|
-
/** Output width. Default: 1200 */
|
|
29
|
+
interface OgImageTemplate {
|
|
30
|
+
/** Template name — used for output file naming. */
|
|
31
|
+
name: string;
|
|
32
|
+
/**
|
|
33
|
+
* Background: path to an image file, or a solid color config.
|
|
34
|
+
*
|
|
35
|
+
* @example "./src/assets/og-bg.jpg"
|
|
36
|
+
* @example { color: "#0066ff", width: 1200, height: 630 }
|
|
37
|
+
*/
|
|
38
|
+
background: string | {
|
|
39
|
+
color: string;
|
|
42
40
|
width?: number;
|
|
43
|
-
/** Output height. Default: 630 */
|
|
44
41
|
height?: number;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
42
|
+
};
|
|
43
|
+
/** Output width. Default: 1200 */
|
|
44
|
+
width?: number;
|
|
45
|
+
/** Output height. Default: 630 */
|
|
46
|
+
height?: number;
|
|
47
|
+
/** Output format. Default: "png" */
|
|
48
|
+
format?: 'png' | 'jpeg';
|
|
49
|
+
/** JPEG quality (1-100). Default: 90 */
|
|
50
|
+
quality?: number;
|
|
51
|
+
/** Text layers to overlay on the background. */
|
|
52
|
+
layers?: OgImageLayer[];
|
|
51
53
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
interface OgImagePluginConfig {
|
|
55
|
+
/** Templates to generate. */
|
|
56
|
+
templates: OgImageTemplate[];
|
|
57
|
+
/** Locales to generate for. When omitted, generates a single image per template. */
|
|
58
|
+
locales?: string[];
|
|
59
|
+
/** Output directory prefix. Default: "og" */
|
|
60
|
+
outDir?: string;
|
|
59
61
|
}
|
|
60
62
|
/**
|
|
61
63
|
* Build an SVG overlay with text layers.
|
|
62
64
|
* @internal Exported for testing.
|
|
63
65
|
*/
|
|
64
|
-
|
|
66
|
+
declare function buildTextOverlaySvg(layers: OgImageLayer[], width: number, height: number, locale: string): string;
|
|
65
67
|
/**
|
|
66
68
|
* Render an OG image from a template for a specific locale.
|
|
67
69
|
* @internal Exported for testing.
|
|
68
70
|
*/
|
|
69
|
-
|
|
71
|
+
declare function renderOgImage(template: OgImageTemplate, locale: string, rootDir: string): Promise<Uint8Array | null>;
|
|
70
72
|
/**
|
|
71
73
|
* Compute the OG image path for a template and locale.
|
|
72
74
|
*
|
|
@@ -77,7 +79,7 @@ export declare function renderOgImage(template: OgImageTemplate, locale: string,
|
|
|
77
79
|
* ogImagePath("hero", "en", "images") // → "/images/hero-en.png"
|
|
78
80
|
* ```
|
|
79
81
|
*/
|
|
80
|
-
|
|
82
|
+
declare function ogImagePath(templateName: string, locale?: string, outDir?: string, format?: 'png' | 'jpeg'): string;
|
|
81
83
|
/**
|
|
82
84
|
* OG image generation Vite plugin.
|
|
83
85
|
*
|
|
@@ -103,5 +105,7 @@ export declare function ogImagePath(templateName: string, locale?: string, outDi
|
|
|
103
105
|
* }
|
|
104
106
|
* ```
|
|
105
107
|
*/
|
|
106
|
-
|
|
107
|
-
//#
|
|
108
|
+
declare function ogImagePlugin(config: OgImagePluginConfig): Plugin;
|
|
109
|
+
//#endregion
|
|
110
|
+
export { OgImageLayer, OgImagePluginConfig, OgImageTemplate, buildTextOverlaySvg, ogImagePath, ogImagePlugin, renderOgImage };
|
|
111
|
+
//# sourceMappingURL=og-image2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"og-
|
|
1
|
+
{"version":3,"file":"og-image2.d.ts","names":[],"sources":["../../../src/og-image.ts"],"mappings":";;;UA8CiB,YAAA;;AAAjB;;;;;EAOE,IAAA,WAAe,MAAA,qBAA2B,MAAA;EAAA;EAE1C,CAAA;EAEA;EAAA,CAAA;EAIA;EAFA,QAAA;EAMA;EAJA,UAAA;EAQA;EANA,UAAA;EAMQ;EAJR,KAAA;EAO8B;EAL9B,UAAA;EAwBqB;EAtBrB,QAAA;AAAA;AAAA,UAGe,eAAA;EASuB;EAPtC,IAAA;EASA;;;;;;EAFA,UAAA;IAAuB,KAAA;IAAe,KAAA;IAAgB,MAAA;EAAA;EAe5B;EAb1B,KAAA;EAaW;EAXX,MAAA;EAeA;EAbA,MAAA;EAaM;EAXN,OAAA;EA0CiC;EAxCjC,MAAA,GAAS,YAAA;AAAA;AAAA,UAGM,mBAAA;EAsCf;EApCA,SAAA,EAAW,eAAA;EAsCX;EApCA,OAAA;EAqCc;EAnCd,MAAA;AAAA;;;;;iBA+Bc,mBAAA,CACd,MAAA,EAAQ,YAAA,IACR,KAAA,UACA,MAAA,UACA,MAAA;;;;;iBAiEoB,aAAA,CACpB,QAAA,EAAU,eAAA,EACV,MAAA,UACA,OAAA,WACC,OAAA,CAAQ,UAAA;;;;;;AAqDX;;;;;iBAAgB,WAAA,CACd,YAAA,UACA,MAAA,WACA,MAAA,WACA,MAAA;;;;;AAkCF;;;;;;;;;;;;;;;;;;;;;iBAAgB,aAAA,CAAc,MAAA,EAAQ,mBAAA,GAAsB,MAAA"}
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { Middleware, MiddlewareContext } from "@pyreon/server";
|
|
2
|
+
|
|
3
|
+
//#region src/rate-limit.d.ts
|
|
4
|
+
interface RateLimitConfig {
|
|
5
|
+
/** Maximum requests per window. Default: `100` */
|
|
6
|
+
max?: number;
|
|
7
|
+
/** Time window in seconds. Default: `60` */
|
|
8
|
+
window?: number;
|
|
9
|
+
/** Function to extract the client identifier. Default: IP from headers. */
|
|
10
|
+
keyFn?: (ctx: MiddlewareContext) => string;
|
|
11
|
+
/** Custom response when rate limited. */
|
|
12
|
+
onLimit?: (ctx: MiddlewareContext) => Response;
|
|
13
|
+
/** URL patterns to rate limit (glob-style). Default: all paths. */
|
|
14
|
+
include?: string[];
|
|
15
|
+
/** URL patterns to exclude from rate limiting. */
|
|
16
|
+
exclude?: string[];
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
19
|
* Rate limiting middleware — limits requests per client within a time window.
|
|
@@ -30,5 +32,7 @@ export interface RateLimitConfig {
|
|
|
30
32
|
* include: ["/api/*"],
|
|
31
33
|
* })
|
|
32
34
|
*/
|
|
33
|
-
|
|
34
|
-
//#
|
|
35
|
+
declare function rateLimitMiddleware(config?: RateLimitConfig): Middleware;
|
|
36
|
+
//#endregion
|
|
37
|
+
export { RateLimitConfig, rateLimitMiddleware };
|
|
38
|
+
//# sourceMappingURL=rate-limit2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rate-
|
|
1
|
+
{"version":3,"file":"rate-limit2.d.ts","names":[],"sources":["../../../src/rate-limit.ts"],"mappings":";;;UAIiB,eAAA;;EAEf,GAAA;EAF8B;EAI9B,MAAA;EAEc;EAAd,KAAA,IAAS,GAAA,EAAK,iBAAA;EAEwB;EAAtC,OAAA,IAAW,GAAA,EAAK,iBAAA,KAAsB,QAAA;EAAQ;EAE9C,OAAA;EANA;EAQA,OAAA;AAAA;;;;;;;;;;AAyBF;;;;;;;;iBAAgB,mBAAA,CAAoB,MAAA,GAAQ,eAAA,GAAuB,UAAA"}
|
package/lib/types/script.d.ts
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
1
|
+
import { VNodeChild } from "@pyreon/core";
|
|
2
|
+
|
|
3
|
+
//#region src/script.d.ts
|
|
4
|
+
interface ScriptProps {
|
|
5
|
+
/** Script source URL. */
|
|
6
|
+
src: string;
|
|
7
|
+
/** Loading strategy. Default: "afterHydration" */
|
|
8
|
+
strategy?: ScriptStrategy;
|
|
9
|
+
/** Inline script content (alternative to src). */
|
|
10
|
+
children?: string;
|
|
11
|
+
/** Script id for deduplication. */
|
|
12
|
+
id?: string;
|
|
13
|
+
/** Async attribute. Default: true */
|
|
14
|
+
async?: boolean;
|
|
15
|
+
/** onLoad callback. */
|
|
16
|
+
onLoad?: () => void;
|
|
17
|
+
/** onError callback. */
|
|
18
|
+
onError?: (error: Error) => void;
|
|
17
19
|
}
|
|
18
|
-
|
|
20
|
+
type ScriptStrategy = 'beforeHydration' | 'afterHydration' | 'onIdle' | 'onInteraction' | 'onViewport';
|
|
19
21
|
/**
|
|
20
22
|
* Optimized script loading component.
|
|
21
23
|
*
|
|
@@ -31,5 +33,7 @@ export type ScriptStrategy = 'beforeHydration' | 'afterHydration' | 'onIdle' | '
|
|
|
31
33
|
* {`console.log("App hydrated!")`}
|
|
32
34
|
* </Script>
|
|
33
35
|
*/
|
|
34
|
-
|
|
35
|
-
//#
|
|
36
|
+
declare function Script(props: ScriptProps): VNodeChild;
|
|
37
|
+
//#endregion
|
|
38
|
+
export { Script, ScriptProps, ScriptStrategy };
|
|
39
|
+
//# sourceMappingURL=script2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"script2.d.ts","names":[],"sources":["../../../src/script.tsx"],"mappings":";;;UAaiB,WAAA;;EAEf,GAAA;EAF0B;EAI1B,QAAA,GAAW,cAAA;EAUY;EARvB,QAAA;EAFA;EAIA,EAAA;EAFA;EAIA,KAAA;EAAA;EAEA,MAAA;EAEA;EAAA,OAAA,IAAW,KAAA,EAAO,KAAA;AAAA;AAAA,KAGR,cAAA;;AAAZ;;;;;AAsBA;;;;;;;;;iBAAgB,MAAA,CAAO,KAAA,EAAO,WAAA,GAAc,UAAA"}
|
package/lib/types/seo.d.ts
CHANGED
|
@@ -1,47 +1,49 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { Middleware } from "@pyreon/server";
|
|
2
|
+
import { Plugin } from "vite";
|
|
3
|
+
|
|
4
|
+
//#region src/seo.d.ts
|
|
5
|
+
interface SitemapConfig {
|
|
6
|
+
/** Base URL of the site (required). e.g. "https://example.com" */
|
|
7
|
+
origin: string;
|
|
8
|
+
/** Paths to exclude from the sitemap. */
|
|
9
|
+
exclude?: string[];
|
|
10
|
+
/** Default change frequency. Default: "weekly" */
|
|
11
|
+
changefreq?: ChangeFreq;
|
|
12
|
+
/** Default priority. Default: 0.7 */
|
|
13
|
+
priority?: number;
|
|
14
|
+
/** Additional URLs to include (for dynamic routes). */
|
|
15
|
+
additionalPaths?: SitemapEntry[];
|
|
14
16
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
interface SitemapEntry {
|
|
18
|
+
path: string;
|
|
19
|
+
changefreq?: ChangeFreq;
|
|
20
|
+
priority?: number;
|
|
21
|
+
lastmod?: string;
|
|
20
22
|
}
|
|
21
|
-
|
|
23
|
+
type ChangeFreq = 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
|
|
22
24
|
/**
|
|
23
25
|
* Generate a sitemap.xml string from route file paths.
|
|
24
26
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
declare function generateSitemap(routeFiles: string[], config: SitemapConfig): string;
|
|
28
|
+
interface RobotsConfig {
|
|
29
|
+
/** Rules per user-agent. */
|
|
30
|
+
rules?: RobotsRule[];
|
|
31
|
+
/** Sitemap URL. */
|
|
32
|
+
sitemap?: string;
|
|
33
|
+
/** Host directive. */
|
|
34
|
+
host?: string;
|
|
33
35
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
36
|
+
interface RobotsRule {
|
|
37
|
+
userAgent: string;
|
|
38
|
+
allow?: string[];
|
|
39
|
+
disallow?: string[];
|
|
40
|
+
crawlDelay?: number;
|
|
39
41
|
}
|
|
40
42
|
/**
|
|
41
43
|
* Generate a robots.txt string.
|
|
42
44
|
*/
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
declare function generateRobots(config?: RobotsConfig): string;
|
|
46
|
+
type JsonLdType = 'WebSite' | 'WebPage' | 'Article' | 'BlogPosting' | 'Product' | 'Organization' | 'Person' | 'BreadcrumbList' | 'FAQPage' | (string & {});
|
|
45
47
|
/**
|
|
46
48
|
* Generate a JSON-LD script tag string for structured data.
|
|
47
49
|
*
|
|
@@ -54,12 +56,12 @@ export type JsonLdType = 'WebSite' | 'WebPage' | 'Article' | 'BlogPosting' | 'Pr
|
|
|
54
56
|
* })],
|
|
55
57
|
* })
|
|
56
58
|
*/
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
declare function jsonLd(data: Record<string, unknown>): string;
|
|
60
|
+
interface SeoPluginConfig {
|
|
61
|
+
/** Sitemap configuration. */
|
|
62
|
+
sitemap?: SitemapConfig;
|
|
63
|
+
/** Robots.txt configuration. */
|
|
64
|
+
robots?: RobotsConfig;
|
|
63
65
|
}
|
|
64
66
|
/**
|
|
65
67
|
* Zero SEO Vite plugin.
|
|
@@ -79,10 +81,12 @@ export interface SeoPluginConfig {
|
|
|
79
81
|
* ],
|
|
80
82
|
* }
|
|
81
83
|
*/
|
|
82
|
-
|
|
84
|
+
declare function seoPlugin(config?: SeoPluginConfig): Plugin;
|
|
83
85
|
/**
|
|
84
86
|
* SEO middleware for dev server.
|
|
85
87
|
* Serves sitemap.xml and robots.txt dynamically during development.
|
|
86
88
|
*/
|
|
87
|
-
|
|
88
|
-
//#
|
|
89
|
+
declare function seoMiddleware(config?: SeoPluginConfig): Middleware;
|
|
90
|
+
//#endregion
|
|
91
|
+
export { ChangeFreq, JsonLdType, RobotsConfig, RobotsRule, SeoPluginConfig, SitemapConfig, SitemapEntry, generateRobots, generateSitemap, jsonLd, seoMiddleware, seoPlugin };
|
|
92
|
+
//# sourceMappingURL=seo2.d.ts.map
|
package/lib/types/seo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"seo2.d.ts","names":[],"sources":["../../../src/seo.ts"],"mappings":";;;;UAWiB,aAAA;;EAEf,MAAA;EAF4B;EAI5B,OAAA;EAM8B;EAJ9B,UAAA,GAAa,UAAA;EAFb;EAIA,QAAA;EAFa;EAIb,eAAA,GAAkB,YAAA;AAAA;AAAA,UAGH,YAAA;EACf,IAAA;EACA,UAAA,GAAa,UAAA;EACb,QAAA;EACA,OAAA;AAAA;AAAA,KAGU,UAAA;;;;iBAKI,eAAA,CAAgB,UAAA,YAAsB,MAAA,EAAQ,aAAA;AAAA,UAgE7C,YAAA;EAxER;EA0EP,KAAA,GAAQ,UAAA;EAvEE;EAyEV,OAAA;;EAEA,IAAA;AAAA;AAAA,UAGe,UAAA;EACf,SAAA;EACA,KAAA;EACA,QAAA;EACA,UAAA;AAAA;;;;iBAMc,cAAA,CAAe,MAAA,GAAQ,YAAA;AAAA,KAwB3B,UAAA;;;;;;;;;AAlCZ;;;;iBA0DgB,MAAA,CAAO,IAAA,EAAM,MAAA;AAAA,UAUZ,eAAA;EAjEf;EAmEA,OAAA,GAAU,aAAA;EAlEA;EAoEV,MAAA,GAAS,YAAA;AAAA;;;;;AAtCX;;;;;AAwBA;;;;;AAUA;;;;iBAyBgB,SAAA,CAAU,MAAA,GAAQ,eAAA,GAAuB,MAAA;;;;;iBA6CzC,aAAA,CAAc,MAAA,GAAQ,eAAA,GAAuB,UAAA"}
|
package/lib/types/testing.d.ts
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { Middleware, MiddlewareContext } from "@pyreon/server";
|
|
2
|
+
|
|
3
|
+
//#region src/api-routes.d.ts
|
|
4
|
+
/** Context passed to API route handlers. */
|
|
5
|
+
interface ApiContext {
|
|
6
|
+
/** The incoming request. */
|
|
7
|
+
request: Request;
|
|
8
|
+
/** Parsed URL. */
|
|
9
|
+
url: URL;
|
|
10
|
+
/** URL path. */
|
|
11
|
+
path: string;
|
|
12
|
+
/** Dynamic route parameters (e.g., { id: "123" }). */
|
|
13
|
+
params: Record<string, string>;
|
|
14
|
+
/** Request headers. */
|
|
15
|
+
headers: Headers;
|
|
16
|
+
}
|
|
17
|
+
/** An API route handler function. */
|
|
18
|
+
type ApiHandler = (ctx: ApiContext) => Response | Promise<Response>;
|
|
19
|
+
/** An API route module — exports named HTTP method handlers. */
|
|
20
|
+
interface ApiRouteModule {
|
|
21
|
+
GET?: ApiHandler;
|
|
22
|
+
POST?: ApiHandler;
|
|
23
|
+
PUT?: ApiHandler;
|
|
24
|
+
PATCH?: ApiHandler;
|
|
25
|
+
DELETE?: ApiHandler;
|
|
26
|
+
HEAD?: ApiHandler;
|
|
27
|
+
OPTIONS?: ApiHandler;
|
|
28
|
+
}
|
|
29
|
+
/** A registered API route entry. */
|
|
30
|
+
interface ApiRouteEntry {
|
|
31
|
+
/** URL pattern (e.g., "/api/posts/:id"). */
|
|
32
|
+
pattern: string;
|
|
33
|
+
/** The route module with method handlers. */
|
|
34
|
+
module: ApiRouteModule;
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/testing.d.ts
|
|
3
38
|
/**
|
|
4
39
|
* Create a mock MiddlewareContext for testing middleware.
|
|
5
40
|
*
|
|
@@ -9,10 +44,10 @@ import type { ApiHandler, ApiRouteEntry } from './api-routes';
|
|
|
9
44
|
* const ctx = createTestContext("/api/posts", { method: "POST", body: { title: "Hello" } })
|
|
10
45
|
* const result = await myMiddleware(ctx)
|
|
11
46
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
47
|
+
declare function createTestContext(path: string, options?: {
|
|
48
|
+
method?: string;
|
|
49
|
+
headers?: Record<string, string>;
|
|
50
|
+
body?: unknown;
|
|
16
51
|
}): MiddlewareContext;
|
|
17
52
|
/**
|
|
18
53
|
* Test a middleware by running it with a mock context and returning
|
|
@@ -27,13 +62,13 @@ export declare function createTestContext(path: string, options?: {
|
|
|
27
62
|
* )
|
|
28
63
|
* expect(headers.get("Access-Control-Allow-Origin")).toBe("*")
|
|
29
64
|
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
65
|
+
declare function testMiddleware(middleware: Middleware, path: string, options?: {
|
|
66
|
+
method?: string;
|
|
67
|
+
headers?: Record<string, string>;
|
|
68
|
+
body?: unknown;
|
|
34
69
|
}): Promise<{
|
|
35
|
-
|
|
36
|
-
|
|
70
|
+
response: Response | undefined;
|
|
71
|
+
headers: Headers;
|
|
37
72
|
}>;
|
|
38
73
|
/**
|
|
39
74
|
* Create a test server for API routes. Returns a function that
|
|
@@ -53,12 +88,12 @@ export declare function testMiddleware(middleware: Middleware, path: string, opt
|
|
|
53
88
|
* const data = await server.request("/api/posts", { method: "POST", body: { title: "Hi" } })
|
|
54
89
|
* expect(data.status).toBe(201)
|
|
55
90
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
91
|
+
declare function createTestApiServer(routes: ApiRouteEntry[]): {
|
|
92
|
+
request(path: string, options?: {
|
|
93
|
+
method?: string;
|
|
94
|
+
headers?: Record<string, string>;
|
|
95
|
+
body?: unknown;
|
|
96
|
+
}): Promise<Response>;
|
|
62
97
|
};
|
|
63
98
|
/**
|
|
64
99
|
* Create a mock API handler for testing.
|
|
@@ -72,14 +107,16 @@ export declare function createTestApiServer(routes: ApiRouteEntry[]): {
|
|
|
72
107
|
* expect(handler.calls).toHaveLength(1)
|
|
73
108
|
* expect(handler.calls[0].params).toEqual({ id: "123" })
|
|
74
109
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
110
|
+
declare function createMockHandler(responseConfig?: {
|
|
111
|
+
status?: number;
|
|
112
|
+
body?: unknown;
|
|
113
|
+
headers?: Record<string, string>;
|
|
79
114
|
}): ApiHandler & {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
115
|
+
calls: Array<{
|
|
116
|
+
path: string;
|
|
117
|
+
params: Record<string, string>;
|
|
118
|
+
}>;
|
|
84
119
|
};
|
|
85
|
-
//#
|
|
120
|
+
//#endregion
|
|
121
|
+
export { createMockHandler, createTestApiServer, createTestContext, testMiddleware };
|
|
122
|
+
//# sourceMappingURL=testing2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"testing2.d.ts","names":[],"sources":["../../../src/api-routes.ts","../../../src/testing.ts"],"mappings":";;;AAQA;AAAA,UAAiB,UAAA;;EAEf,OAAA,EAAS,OAAA;EAEJ;EAAL,GAAA,EAAK,GAAA;EAMI;EAJT,IAAA;EAIgB;EAFhB,MAAA,EAAQ,MAAA;EANC;EAQT,OAAA,EAAS,OAAA;AAAA;;KAIC,UAAA,IAAc,GAAA,EAAK,UAAA,KAAe,QAAA,GAAW,OAAA,CAAQ,QAAA;;UAGhD,cAAA;EACf,GAAA,GAAM,UAAA;EACN,IAAA,GAAO,UAAA;EACP,GAAA,GAAM,UAAA;EACN,KAAA,GAAQ,UAAA;EACR,MAAA,GAAS,UAAA;EACT,IAAA,GAAO,UAAA;EACP,OAAA,GAAU,UAAA;AAAA;;UAIK,aAAA;EAd+C;EAgB9D,OAAA;EAhB6B;EAkB7B,MAAA,EAAQ,cAAA;AAAA;;;;AAhCV;;;;;;;;iBCOgB,iBAAA,CACd,IAAA,UACA,OAAA;EACE,MAAA;EACA,OAAA,GAAU,MAAA;EACV,IAAA;AAAA,IAED,iBAAA;;;;;;;;ADAH;;;;;;iBCwCsB,cAAA,CACpB,UAAA,EAAY,UAAA,EACZ,IAAA,UACA,OAAA;EACE,MAAA;EACA,OAAA,GAAU,MAAA;EACV,IAAA;AAAA,IAED,OAAA;EAAU,QAAA,EAAU,QAAA;EAAsB,OAAA,EAAS,OAAA;AAAA;;;AD7CtD;;;;;;;;;;;;;;;;iBCqEgB,mBAAA,CAAoB,MAAA,EAAQ,aAAA;wBAK1B,OAAA;IAEV,MAAA;IACA,OAAA,GAAU,MAAA;IACV,IAAA;EAAA,IAED,OAAA,CAAQ,QAAA;AAAA;;;;;;ADrEf;;;;;;;iBC4FgB,iBAAA,CACd,cAAA;EAAkB,MAAA;EAAiB,IAAA;EAAgB,OAAA,GAAU,MAAA;AAAA,IAC5D,UAAA;EACD,KAAA,EAAO,KAAA;IAAQ,IAAA;IAAc,MAAA,EAAQ,MAAA;EAAA;AAAA"}
|