@pyreon/zero 0.12.2 → 0.12.4
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 +340 -4015
- 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 +310 -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/server.js +1534 -0
- package/lib/server.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 +594 -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 +145 -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/server.d.ts +455 -0
- package/lib/types/server.d.ts.map +1 -0
- 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 +17 -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 +20 -182
- package/src/link.tsx +6 -0
- package/src/meta.tsx +78 -16
- package/src/rate-limit.ts +11 -9
- package/src/server.ts +70 -0
- package/src/theme.tsx +12 -1
- package/src/vite-plugin.ts +5 -1
- package/lib/fs-router-Dil4IKZR.js +0 -290
- package/lib/fs-router-Dil4IKZR.js.map +0 -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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"actions2.d.ts","names":[],"sources":["../../../src/actions.ts"],"mappings":";;;;UAKiB,aAAA;EAAA;EAEf,OAAA,EAAS,OAAA;;EAET,QAAA,EAAU,QAAA;EAAA;EAEV,IAAA;EAEgB;EAAhB,OAAA,EAAS,OAAA;AAAA;;KAIC,aAAA,iBAA8B,GAAA,EAAK,aAAA,KAAkB,CAAA,GAAI,OAAA,CAAQ,CAAA;;UAGnE,gBAAA;EACR,EAAA;EACA,OAAA,EAAS,aAAA;AAAA;;UAIM,MAAA;EATQ;EAAA,CAWtB,IAAA,aAAiB,OAAA,CAAQ,CAAA;EAXmB;EAa7C,QAAA;AAAA;;;;;;;;;;;;AAb6E;;;;;iBAoC/D,YAAA,aAAA,CAA0B,OAAA,EAAS,aAAA,CAAc,CAAA,IAAK,MAAA,CAAO,CAAA;;iBAsC7D,oBAAA,CAAA,GAAwB,GAAA,SAAY,gBAAA;;AAjEpD;;;iBAyEgB,aAAA,CAAA;;;;;iBAUA,sBAAA,CAAA,IACd,GAAA,EAAK,iBAAA,KACF,QAAA,eAAuB,OAAA,CAAQ,QAAA"}
|
package/lib/types/ai.d.ts
CHANGED
|
@@ -1,68 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* ```ts
|
|
48
|
-
* apiDescriptions: {
|
|
49
|
-
* "GET /api/posts": "List all blog posts, supports ?page=N&limit=N",
|
|
50
|
-
* "GET /api/posts/:id": "Get a single post by ID",
|
|
51
|
-
* "POST /api/posts": "Create a new post (requires auth)",
|
|
52
|
-
* }
|
|
53
|
-
* ```
|
|
54
|
-
*/
|
|
55
|
-
apiDescriptions?: Record<string, string>;
|
|
56
|
-
/**
|
|
57
|
-
* Page descriptions — map of URL path to description.
|
|
58
|
-
* Used for llms.txt. Falls back to route meta.title/description.
|
|
59
|
-
*/
|
|
60
|
-
pageDescriptions?: Record<string, string>;
|
|
61
|
-
/**
|
|
62
|
-
* Additional content to append to llms.txt.
|
|
63
|
-
* Useful for authentication instructions, rate limits, etc.
|
|
64
|
-
*/
|
|
65
|
-
llmsExtra?: string;
|
|
1
|
+
import { Plugin } from "vite";
|
|
2
|
+
|
|
3
|
+
//#region src/ai.d.ts
|
|
4
|
+
interface AiPluginConfig {
|
|
5
|
+
/** App/API name. */
|
|
6
|
+
name: string;
|
|
7
|
+
/** App description for AI agents. */
|
|
8
|
+
description: string;
|
|
9
|
+
/** Base URL. e.g. "https://example.com" */
|
|
10
|
+
origin: string;
|
|
11
|
+
/** Contact email (required by OpenAI plugin spec). */
|
|
12
|
+
contactEmail?: string;
|
|
13
|
+
/** Legal info URL. */
|
|
14
|
+
legalUrl?: string;
|
|
15
|
+
/** Logo URL for the plugin. */
|
|
16
|
+
logoUrl?: string;
|
|
17
|
+
/** Routes directory relative to project root. Default: "src/routes" */
|
|
18
|
+
routesDir?: string;
|
|
19
|
+
/** API routes directory relative to project root. Default: "src/api" */
|
|
20
|
+
apiDir?: string;
|
|
21
|
+
/**
|
|
22
|
+
* API route descriptions — map of pattern to description.
|
|
23
|
+
* Used for llms.txt and ai-plugin.json.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* apiDescriptions: {
|
|
28
|
+
* "GET /api/posts": "List all blog posts, supports ?page=N&limit=N",
|
|
29
|
+
* "GET /api/posts/:id": "Get a single post by ID",
|
|
30
|
+
* "POST /api/posts": "Create a new post (requires auth)",
|
|
31
|
+
* }
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
apiDescriptions?: Record<string, string>;
|
|
35
|
+
/**
|
|
36
|
+
* Page descriptions — map of URL path to description.
|
|
37
|
+
* Used for llms.txt. Falls back to route meta.title/description.
|
|
38
|
+
*/
|
|
39
|
+
pageDescriptions?: Record<string, string>;
|
|
40
|
+
/**
|
|
41
|
+
* Additional content to append to llms.txt.
|
|
42
|
+
* Useful for authentication instructions, rate limits, etc.
|
|
43
|
+
*/
|
|
44
|
+
llmsExtra?: string;
|
|
66
45
|
}
|
|
67
46
|
/**
|
|
68
47
|
* Generate llms.txt content from route files and config.
|
|
@@ -81,38 +60,38 @@ export interface AiPluginConfig {
|
|
|
81
60
|
*
|
|
82
61
|
* @internal Exported for testing.
|
|
83
62
|
*/
|
|
84
|
-
|
|
63
|
+
declare function generateLlmsTxt(routeFiles: string[], apiFiles: string[], config: AiPluginConfig): string;
|
|
85
64
|
/**
|
|
86
65
|
* Generate llms-full.txt — expanded version with more detail.
|
|
87
66
|
* Includes all route metadata and API descriptions.
|
|
88
67
|
*
|
|
89
68
|
* @internal Exported for testing.
|
|
90
69
|
*/
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
70
|
+
declare function generateLlmsFullTxt(routeFiles: string[], apiFiles: string[], config: AiPluginConfig): string;
|
|
71
|
+
interface InferJsonLdOptions {
|
|
72
|
+
/** Page URL. */
|
|
73
|
+
url: string;
|
|
74
|
+
/** Page title. */
|
|
75
|
+
title?: string;
|
|
76
|
+
/** Page description. */
|
|
77
|
+
description?: string;
|
|
78
|
+
/** Page image. */
|
|
79
|
+
image?: string;
|
|
80
|
+
/** Site name. */
|
|
81
|
+
siteName?: string;
|
|
82
|
+
/** Page type hint. */
|
|
83
|
+
type?: 'website' | 'article' | 'product' | 'profile';
|
|
84
|
+
/** Article metadata. */
|
|
85
|
+
publishedTime?: string;
|
|
86
|
+
/** Article author. */
|
|
87
|
+
author?: string;
|
|
88
|
+
/** Article tags. */
|
|
89
|
+
tags?: string[];
|
|
90
|
+
/** Breadcrumb path segments. */
|
|
91
|
+
breadcrumbs?: Array<{
|
|
92
|
+
name: string;
|
|
94
93
|
url: string;
|
|
95
|
-
|
|
96
|
-
title?: string;
|
|
97
|
-
/** Page description. */
|
|
98
|
-
description?: string;
|
|
99
|
-
/** Page image. */
|
|
100
|
-
image?: string;
|
|
101
|
-
/** Site name. */
|
|
102
|
-
siteName?: string;
|
|
103
|
-
/** Page type hint. */
|
|
104
|
-
type?: 'website' | 'article' | 'product' | 'profile';
|
|
105
|
-
/** Article metadata. */
|
|
106
|
-
publishedTime?: string;
|
|
107
|
-
/** Article author. */
|
|
108
|
-
author?: string;
|
|
109
|
-
/** Article tags. */
|
|
110
|
-
tags?: string[];
|
|
111
|
-
/** Breadcrumb path segments. */
|
|
112
|
-
breadcrumbs?: Array<{
|
|
113
|
-
name: string;
|
|
114
|
-
url: string;
|
|
115
|
-
}>;
|
|
94
|
+
}>;
|
|
116
95
|
}
|
|
117
96
|
/**
|
|
118
97
|
* Auto-infer JSON-LD structured data from page metadata.
|
|
@@ -133,7 +112,7 @@ export interface InferJsonLdOptions {
|
|
|
133
112
|
* // → [Article schema, BreadcrumbList schema]
|
|
134
113
|
* ```
|
|
135
114
|
*/
|
|
136
|
-
|
|
115
|
+
declare function inferJsonLd(options: InferJsonLdOptions): Record<string, unknown>[];
|
|
137
116
|
/**
|
|
138
117
|
* Generate an OpenAI-compatible AI plugin manifest.
|
|
139
118
|
*
|
|
@@ -141,13 +120,13 @@ export declare function inferJsonLd(options: InferJsonLdOptions): Record<string,
|
|
|
141
120
|
*
|
|
142
121
|
* @internal Exported for testing.
|
|
143
122
|
*/
|
|
144
|
-
|
|
123
|
+
declare function generateAiPluginManifest(config: AiPluginConfig): Record<string, unknown>;
|
|
145
124
|
/**
|
|
146
125
|
* Generate a minimal OpenAPI 3.0 spec from API route descriptions.
|
|
147
126
|
*
|
|
148
127
|
* @internal Exported for testing.
|
|
149
128
|
*/
|
|
150
|
-
|
|
129
|
+
declare function generateOpenApiSpec(apiFiles: string[], config: AiPluginConfig): Record<string, unknown>;
|
|
151
130
|
/**
|
|
152
131
|
* AI integration Vite plugin.
|
|
153
132
|
*
|
|
@@ -178,5 +157,7 @@ export declare function generateOpenApiSpec(apiFiles: string[], config: AiPlugin
|
|
|
178
157
|
* }
|
|
179
158
|
* ```
|
|
180
159
|
*/
|
|
181
|
-
|
|
182
|
-
//#
|
|
160
|
+
declare function aiPlugin(config: AiPluginConfig): Plugin;
|
|
161
|
+
//#endregion
|
|
162
|
+
export { AiPluginConfig, InferJsonLdOptions, aiPlugin, generateAiPluginManifest, generateLlmsFullTxt, generateLlmsTxt, generateOpenApiSpec, inferJsonLd };
|
|
163
|
+
//# sourceMappingURL=ai2.d.ts.map
|
package/lib/types/ai.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"ai2.d.ts","names":[],"sources":["../../../src/ai.ts"],"mappings":";;;UA4BiB,cAAA;EAiEO;EA/DtB,IAAA;EA8DA;EA5DA,WAAA;EA6DA;EA3DA,MAAA;EA2DsB;EAzDtB,YAAA;EAmJiC;EAjJjC,QAAA;EAoJsB;EAlJtB,OAAA;EAiJA;EA/IA,SAAA;EAgJA;EA9IA,MAAA;EA8IsB;AAsDxB;;;;;;;;;;;;EAtLE,eAAA,GAAkB,MAAA;EA0MlB;;;;EArMA,gBAAA,GAAmB,MAAA;EAqMoB;AAsBzC;;;EAtNE,SAAA;AAAA;;;;;AAwTF;;;;;;;;;AAuBA;;;;iBAzTgB,eAAA,CACd,UAAA,YACA,QAAA,YACA,MAAA,EAAQ,cAAA;;;;;;AAuYV;iBA7SgB,mBAAA,CACd,UAAA,YACA,QAAA,YACA,MAAA,EAAQ,cAAA;AAAA,UAsDO,kBAAA;EAoPuC;EAlPtD,GAAA;EAkPuB;EAhPvB,KAAA;EAgPsD;EA9OtD,WAAA;;EAEA,KAAA;;EAEA,QAAA;;EAEA,IAAA;;EAEA,aAAA;;EAEA,MAAA;;EAEA,IAAA;;EAEA,WAAA,GAAc,KAAA;IAAQ,IAAA;IAAc,GAAA;EAAA;AAAA;;;;;;;;;;;;;;;;;;;;iBAsBtB,WAAA,CAAY,OAAA,EAAS,kBAAA,GAAqB,MAAA;;;;;;;;iBAkG1C,wBAAA,CAAyB,MAAA,EAAQ,cAAA,GAAiB,MAAA;;;;;;iBAuBlD,mBAAA,CACd,QAAA,YACA,MAAA,EAAQ,cAAA,GACP,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8Ea,QAAA,CAAS,MAAA,EAAQ,cAAA,GAAiB,MAAA"}
|
|
@@ -1,53 +1,55 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Middleware } from "@pyreon/server";
|
|
2
|
+
|
|
3
|
+
//#region src/api-routes.d.ts
|
|
2
4
|
/** HTTP methods supported by API routes. */
|
|
3
|
-
|
|
5
|
+
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
4
6
|
/** Context passed to API route handlers. */
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
interface ApiContext {
|
|
8
|
+
/** The incoming request. */
|
|
9
|
+
request: Request;
|
|
10
|
+
/** Parsed URL. */
|
|
11
|
+
url: URL;
|
|
12
|
+
/** URL path. */
|
|
13
|
+
path: string;
|
|
14
|
+
/** Dynamic route parameters (e.g., { id: "123" }). */
|
|
15
|
+
params: Record<string, string>;
|
|
16
|
+
/** Request headers. */
|
|
17
|
+
headers: Headers;
|
|
16
18
|
}
|
|
17
19
|
/** An API route handler function. */
|
|
18
|
-
|
|
20
|
+
type ApiHandler = (ctx: ApiContext) => Response | Promise<Response>;
|
|
19
21
|
/** An API route module — exports named HTTP method handlers. */
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
interface ApiRouteModule {
|
|
23
|
+
GET?: ApiHandler;
|
|
24
|
+
POST?: ApiHandler;
|
|
25
|
+
PUT?: ApiHandler;
|
|
26
|
+
PATCH?: ApiHandler;
|
|
27
|
+
DELETE?: ApiHandler;
|
|
28
|
+
HEAD?: ApiHandler;
|
|
29
|
+
OPTIONS?: ApiHandler;
|
|
28
30
|
}
|
|
29
31
|
/** A registered API route entry. */
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
interface ApiRouteEntry {
|
|
33
|
+
/** URL pattern (e.g., "/api/posts/:id"). */
|
|
34
|
+
pattern: string;
|
|
35
|
+
/** The route module with method handlers. */
|
|
36
|
+
module: ApiRouteModule;
|
|
35
37
|
}
|
|
36
38
|
/**
|
|
37
39
|
* Match a URL path against an API route pattern.
|
|
38
40
|
* Returns extracted params or null if no match.
|
|
39
41
|
*/
|
|
40
|
-
|
|
42
|
+
declare function matchApiRoute(pattern: string, path: string): Record<string, string> | null;
|
|
41
43
|
/**
|
|
42
44
|
* Create a middleware that dispatches API route requests.
|
|
43
45
|
* API routes are matched by URL pattern and HTTP method.
|
|
44
46
|
*/
|
|
45
|
-
|
|
47
|
+
declare function createApiMiddleware(routes: ApiRouteEntry[]): Middleware;
|
|
46
48
|
/**
|
|
47
49
|
* Detect whether a route file is an API route.
|
|
48
50
|
* API routes are `.ts` or `.js` files inside an `api/` directory.
|
|
49
51
|
*/
|
|
50
|
-
|
|
52
|
+
declare function isApiRoute(filePath: string): boolean;
|
|
51
53
|
/**
|
|
52
54
|
* Convert an API route file path to a URL pattern.
|
|
53
55
|
*
|
|
@@ -57,10 +59,12 @@ export declare function isApiRoute(filePath: string): boolean;
|
|
|
57
59
|
* "api/posts/[id].ts" → "/api/posts/:id"
|
|
58
60
|
* "api/[...path].ts" → "/api/:path*"
|
|
59
61
|
*/
|
|
60
|
-
|
|
62
|
+
declare function apiFilePathToPattern(filePath: string): string;
|
|
61
63
|
/**
|
|
62
64
|
* Generate a virtual module that exports API route entries.
|
|
63
65
|
* Each entry maps a URL pattern to a module with HTTP method handlers.
|
|
64
66
|
*/
|
|
65
|
-
|
|
66
|
-
//#
|
|
67
|
+
declare function generateApiRouteModule(files: string[], routesDir: string): string;
|
|
68
|
+
//#endregion
|
|
69
|
+
export { ApiContext, ApiHandler, ApiRouteEntry, ApiRouteModule, HttpMethod, apiFilePathToPattern, createApiMiddleware, generateApiRouteModule, isApiRoute, matchApiRoute };
|
|
70
|
+
//# sourceMappingURL=api-routes2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-
|
|
1
|
+
{"version":3,"file":"api-routes2.d.ts","names":[],"sources":["../../../src/api-routes.ts"],"mappings":";;;;KAKY,UAAA;AAAZ;AAAA,UAGiB,UAAA;;EAEf,OAAA,EAAS,OAAA;EALW;EAOpB,GAAA,EAAK,GAAA;EAJoB;EAMzB,IAAA;EAJS;EAMT,MAAA,EAAQ,MAAA;EAAA;EAER,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;AAVZ;AAAA,UAciB,aAAA;;EAEf,OAAA;EAhB4C;EAkB5C,MAAA,EAAQ,cAAA;AAAA;;;;;iBASM,aAAA,CAAc,OAAA,UAAiB,IAAA,WAAe,MAAA;;;;;iBAwC9C,mBAAA,CAAoB,MAAA,EAAQ,aAAA,KAAkB,UAAA;;;;;iBAsC9C,UAAA,CAAW,QAAA;;;;;;;;;;iBAmBX,oBAAA,CAAqB,QAAA;;;;;iBAwCrB,sBAAA,CAAuB,KAAA,YAAiB,SAAA"}
|
package/lib/types/cache.d.ts
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { Middleware } from "@pyreon/server";
|
|
2
|
+
|
|
3
|
+
//#region src/cache.d.ts
|
|
4
|
+
interface CacheConfig {
|
|
5
|
+
/** Cache duration for immutable hashed assets (seconds). Default: 31536000 (1 year) */
|
|
6
|
+
immutable?: number;
|
|
7
|
+
/** Cache duration for static assets like images/fonts (seconds). Default: 86400 (1 day) */
|
|
8
|
+
static?: number;
|
|
9
|
+
/** Cache duration for pages (seconds). Default: 0 (no cache) */
|
|
10
|
+
pages?: number;
|
|
11
|
+
/** Stale-while-revalidate window for pages (seconds). Default: 60 */
|
|
12
|
+
staleWhileRevalidate?: number;
|
|
13
|
+
/** Custom rules by URL pattern. */
|
|
14
|
+
rules?: CacheRule[];
|
|
13
15
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
interface CacheRule {
|
|
17
|
+
/** URL pattern to match (glob-style). e.g. "/api/*" */
|
|
18
|
+
match: string;
|
|
19
|
+
/** Cache-Control header value. */
|
|
20
|
+
control: string;
|
|
19
21
|
}
|
|
20
22
|
/** @internal Exported for testing */
|
|
21
|
-
|
|
23
|
+
declare function matchGlob(pattern: string, path: string): boolean;
|
|
22
24
|
/**
|
|
23
25
|
* Cache control middleware for Zero.
|
|
24
26
|
* Sets Cache-Control headers on the response based on asset type.
|
|
@@ -39,16 +41,18 @@ export declare function matchGlob(pattern: string, path: string): boolean;
|
|
|
39
41
|
* ],
|
|
40
42
|
* })
|
|
41
43
|
*/
|
|
42
|
-
|
|
44
|
+
declare function cacheMiddleware(config?: CacheConfig): Middleware;
|
|
43
45
|
/**
|
|
44
46
|
* Security headers middleware.
|
|
45
47
|
* Adds common security headers to all responses.
|
|
46
48
|
*/
|
|
47
|
-
|
|
49
|
+
declare function securityHeaders(): Middleware;
|
|
48
50
|
/**
|
|
49
51
|
* Compression detection middleware.
|
|
50
52
|
* Sets Vary: Accept-Encoding header so caches can serve compressed variants.
|
|
51
53
|
* Actual compression is handled by the runtime (Bun/Node) or reverse proxy.
|
|
52
54
|
*/
|
|
53
|
-
|
|
54
|
-
//#
|
|
55
|
+
declare function varyEncoding(): Middleware;
|
|
56
|
+
//#endregion
|
|
57
|
+
export { CacheConfig, CacheRule, cacheMiddleware, matchGlob, securityHeaders, varyEncoding };
|
|
58
|
+
//# sourceMappingURL=cache2.d.ts.map
|
package/lib/types/cache.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"cache2.d.ts","names":[],"sources":["../../../src/cache.ts"],"mappings":";;;UAaiB,WAAA;;EAEf,SAAA;EAF0B;EAI1B,MAAA;EAMiB;EAJjB,KAAA;EAFA;EAIA,oBAAA;EAAA;EAEA,KAAA,GAAQ,SAAA;AAAA;AAAA,UAGO,SAAA;EAHE;EAKjB,KAAA;EAFwB;EAIxB,OAAA;AAAA;;iBAQc,SAAA,CAAU,OAAA,UAAiB,IAAA;;;;;AAiD3C;;;;;;;;;AA0BA;;;;;AAeA;;iBAzCgB,eAAA,CAAgB,MAAA,GAAQ,WAAA,GAAmB,UAAA;;;;;iBA0B3C,eAAA,CAAA,GAAmB,UAAA;;;;;;iBAenB,YAAA,CAAA,GAAgB,UAAA"}
|
package/lib/types/client.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { ComponentFn } from "@pyreon/core";
|
|
2
|
+
import { RouteRecord } from "@pyreon/router";
|
|
3
|
+
|
|
4
|
+
//#region src/client.d.ts
|
|
5
|
+
interface StartClientOptions {
|
|
6
|
+
/** Route definitions. */
|
|
7
|
+
routes: RouteRecord[];
|
|
8
|
+
/** Root layout component. */
|
|
9
|
+
layout?: ComponentFn;
|
|
8
10
|
}
|
|
9
11
|
/**
|
|
10
12
|
* Start the client-side app — hydrates SSR content or mounts fresh for SPA.
|
|
@@ -15,5 +17,7 @@ export interface StartClientOptions {
|
|
|
15
17
|
*
|
|
16
18
|
* startClient({ routes })
|
|
17
19
|
*/
|
|
18
|
-
|
|
19
|
-
//#
|
|
20
|
+
declare function startClient(options: StartClientOptions): () => void;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { StartClientOptions, startClient };
|
|
23
|
+
//# sourceMappingURL=client2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"client2.d.ts","names":[],"sources":["../../../src/client.ts"],"mappings":";;;;UAQiB,kBAAA;;EAEf,MAAA,EAAQ,WAAA;EAFyB;EAIjC,MAAA,GAAS,WAAA;AAAA;;;;;;;AAYX;;;iBAAgB,WAAA,CAAY,OAAA,EAAS,kBAAA"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { Middleware } from "@pyreon/server";
|
|
2
|
+
|
|
3
|
+
//#region src/compression.d.ts
|
|
4
|
+
interface CompressionConfig {
|
|
5
|
+
/** Minimum response size in bytes to compress. Default: `1024` (1KB) */
|
|
6
|
+
threshold?: number;
|
|
7
|
+
/** Encoding preference order. Default: `["gzip", "deflate"]` */
|
|
8
|
+
encodings?: ('gzip' | 'deflate')[];
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
11
|
* Compression middleware — compresses responses using gzip or deflate
|
|
@@ -18,7 +20,7 @@ export interface CompressionConfig {
|
|
|
18
20
|
* compressionMiddleware() // gzip with 1KB threshold
|
|
19
21
|
* compressionMiddleware({ threshold: 512, encodings: ["gzip"] })
|
|
20
22
|
*/
|
|
21
|
-
|
|
23
|
+
declare function compressionMiddleware(config?: CompressionConfig): Middleware;
|
|
22
24
|
/**
|
|
23
25
|
* Compress a Response body if it meets the criteria.
|
|
24
26
|
* Use this to post-process responses after the handler runs.
|
|
@@ -27,7 +29,9 @@ export declare function compressionMiddleware(config?: CompressionConfig): Middl
|
|
|
27
29
|
* const response = await handler(request)
|
|
28
30
|
* const compressed = await compressResponse(response, 'gzip', 1024)
|
|
29
31
|
*/
|
|
30
|
-
|
|
32
|
+
declare function compressResponse(response: Response, encoding: 'gzip' | 'deflate', threshold: number): Promise<Response>;
|
|
31
33
|
/** Check if a content type is compressible. Exported for testing. */
|
|
32
|
-
|
|
33
|
-
//#
|
|
34
|
+
declare function isCompressible(contentType: string): boolean;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { CompressionConfig, compressResponse, compressionMiddleware, isCompressible };
|
|
37
|
+
//# sourceMappingURL=compression2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"compression2.d.ts","names":[],"sources":["../../../src/compression.ts"],"mappings":";;;UAIiB,iBAAA;;EAEf,SAAA;EAFgC;EAIhC,SAAA;AAAA;;AAgBF;;;;;;;;;AAyBA;;;iBAzBgB,qBAAA,CAAsB,MAAA,GAAQ,iBAAA,GAAyB,UAAA;;;;;;;;;iBAyBjD,gBAAA,CACpB,QAAA,EAAU,QAAA,EACV,QAAA,sBACA,SAAA,WACC,OAAA,CAAQ,QAAA;;iBAsCK,cAAA,CAAe,WAAA"}
|
package/lib/types/config.d.ts
CHANGED
|
@@ -1,4 +1,37 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Middleware } from "@pyreon/server";
|
|
2
|
+
|
|
3
|
+
//#region src/types.d.ts
|
|
4
|
+
type RenderMode = 'ssr' | 'ssg' | 'spa' | 'isr';
|
|
5
|
+
interface ISRConfig {
|
|
6
|
+
/** Revalidation interval in seconds. */
|
|
7
|
+
revalidate: number;
|
|
8
|
+
}
|
|
9
|
+
interface ZeroConfig {
|
|
10
|
+
/** Default rendering mode. Default: "ssr" */
|
|
11
|
+
mode?: RenderMode;
|
|
12
|
+
/** Vite config overrides. */
|
|
13
|
+
vite?: Record<string, unknown>;
|
|
14
|
+
/** SSR options. */
|
|
15
|
+
ssr?: {
|
|
16
|
+
/** Streaming mode. Default: "string" */mode?: 'string' | 'stream';
|
|
17
|
+
};
|
|
18
|
+
/** SSG options — only used when mode is "ssg". */
|
|
19
|
+
ssg?: {
|
|
20
|
+
/** Paths to prerender (or function returning paths). */paths?: string[] | (() => string[] | Promise<string[]>);
|
|
21
|
+
};
|
|
22
|
+
/** ISR config — only used when mode is "isr". */
|
|
23
|
+
isr?: ISRConfig;
|
|
24
|
+
/** Deploy adapter. Default: "node" */
|
|
25
|
+
adapter?: 'node' | 'bun' | 'static' | 'vercel' | 'cloudflare' | 'netlify';
|
|
26
|
+
/** Base URL path. Default: "/" */
|
|
27
|
+
base?: string;
|
|
28
|
+
/** App-level middleware applied to all routes. */
|
|
29
|
+
middleware?: Middleware[];
|
|
30
|
+
/** Server port for dev/preview. Default: 3000 */
|
|
31
|
+
port?: number;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
//#region src/config.d.ts
|
|
2
35
|
/**
|
|
3
36
|
* Define a Zero configuration.
|
|
4
37
|
* Used in `zero.config.ts` at the project root.
|
|
@@ -12,7 +45,9 @@ import type { ZeroConfig } from './types';
|
|
|
12
45
|
* port: 3000,
|
|
13
46
|
* })
|
|
14
47
|
*/
|
|
15
|
-
|
|
48
|
+
declare function defineConfig(config: ZeroConfig): ZeroConfig;
|
|
16
49
|
/** Merge user config with defaults. */
|
|
17
|
-
|
|
18
|
-
//#
|
|
50
|
+
declare function resolveConfig(userConfig?: ZeroConfig): Required<Pick<ZeroConfig, 'mode' | 'base' | 'port' | 'adapter'>> & ZeroConfig;
|
|
51
|
+
//#endregion
|
|
52
|
+
export { defineConfig, resolveConfig };
|
|
53
|
+
//# sourceMappingURL=config2.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"config2.d.ts","names":[],"sources":["../../../src/types.ts","../../../src/config.ts"],"mappings":";;;KA6CY,UAAA;AAAA,UAEK,SAAA;EAoCF;EAlCb,UAAA;AAAA;AAAA,UAKe,UAAA;;EAEf,IAAA,GAAO,UAAA;;EAGP,IAAA,GAAO,MAAA;EC5CmB;ED+C1B,GAAA;IC/C0D,wCDiDxD,IAAA;EAAA;ECjD8C;EDqDhD,GAAA;ICrD0D,wDDuDxD,KAAA,gCAAqC,OAAA;EAAA;;EAIvC,GAAA,GAAM,SAAA;ECpDS;EDuDf,OAAA;ECvDC;ED0DD,IAAA;EC1D8E;ED6D9E,UAAA,GAAa,UAAA;EC9DD;EDiEZ,IAAA;AAAA;;;;;;;AAzCF;;;;;AAEA;;;;iBChCgB,YAAA,CAAa,MAAA,EAAQ,UAAA,GAAa,UAAA;ADuClD;AAAA,iBClCgB,aAAA,CACd,UAAA,GAAY,UAAA,GACX,QAAA,CAAS,IAAA,CAAK,UAAA,2CAAqD,UAAA"}
|
package/lib/types/cors.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { Middleware } from "@pyreon/server";
|
|
2
|
+
|
|
3
|
+
//#region src/cors.d.ts
|
|
4
|
+
interface CorsConfig {
|
|
5
|
+
/** Allowed origins. Use `"*"` for any origin. Default: `"*"` */
|
|
6
|
+
origin?: string | string[] | ((origin: string) => boolean);
|
|
7
|
+
/** Allowed HTTP methods. Default: `["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"]` */
|
|
8
|
+
methods?: string[];
|
|
9
|
+
/** Allowed request headers. Default: `["Content-Type", "Authorization"]` */
|
|
10
|
+
allowedHeaders?: string[];
|
|
11
|
+
/** Headers exposed to the client. Default: `[]` */
|
|
12
|
+
exposedHeaders?: string[];
|
|
13
|
+
/** Allow credentials (cookies, auth headers). Default: `false` */
|
|
14
|
+
credentials?: boolean;
|
|
15
|
+
/** Preflight cache duration in seconds. Default: `86400` (24 hours) */
|
|
16
|
+
maxAge?: number;
|
|
15
17
|
}
|
|
16
18
|
/**
|
|
17
19
|
* CORS middleware — handles preflight requests and sets appropriate
|
|
@@ -28,5 +30,7 @@ export interface CorsConfig {
|
|
|
28
30
|
* // Multiple origins
|
|
29
31
|
* corsMiddleware({ origin: ["https://app.com", "https://admin.com"] })
|
|
30
32
|
*/
|
|
31
|
-
|
|
32
|
-
//#
|
|
33
|
+
declare function corsMiddleware(config?: CorsConfig): Middleware;
|
|
34
|
+
//#endregion
|
|
35
|
+
export { CorsConfig, corsMiddleware };
|
|
36
|
+
//# sourceMappingURL=cors2.d.ts.map
|
package/lib/types/cors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"
|
|
1
|
+
{"version":3,"file":"cors2.d.ts","names":[],"sources":["../../../src/cors.ts"],"mappings":";;;UAIiB,UAAA;;EAEf,MAAA,yBAA+B,MAAA;EAFN;EAIzB,OAAA;EAJyB;EAMzB,cAAA;EAJ+B;EAM/B,cAAA;EAFA;EAIA,WAAA;EAAA;EAEA,MAAA;AAAA;;AAqBF;;;;;;;;;;;;;;iBAAgB,cAAA,CAAe,MAAA,GAAQ,UAAA,GAAkB,UAAA"}
|