@d7z-project/gitea-pages 0.0.2
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/globals.d.ts +262 -0
- package/package.json +10 -0
package/globals.d.ts
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Headers {
|
|
3
|
+
get(name: string): string | null;
|
|
4
|
+
set(name: string, value: string): void;
|
|
5
|
+
append(name: string, value: string): void;
|
|
6
|
+
has(name: string): boolean;
|
|
7
|
+
delete(name: string): void;
|
|
8
|
+
keys(): string[];
|
|
9
|
+
values(): string[];
|
|
10
|
+
entries(): [string, string][];
|
|
11
|
+
forEach(callback: (value: string, key: string, parent: Headers) => void): void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface RequestInit {
|
|
15
|
+
method?: string;
|
|
16
|
+
headers?: Headers | Record<string, string>;
|
|
17
|
+
body?: string | Uint8Array | ArrayBuffer;
|
|
18
|
+
signal?: AbortSignal;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface Request {
|
|
22
|
+
readonly method: string;
|
|
23
|
+
readonly url: string;
|
|
24
|
+
readonly headers: Headers;
|
|
25
|
+
readonly bodyUsed: boolean;
|
|
26
|
+
readonly signal: AbortSignal;
|
|
27
|
+
text(): Promise<string>;
|
|
28
|
+
json<T = any>(): Promise<T>;
|
|
29
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
30
|
+
clone(): Request;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
interface ResponseInit {
|
|
34
|
+
status?: number;
|
|
35
|
+
statusText?: string;
|
|
36
|
+
headers?: Headers | Record<string, string>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface Response {
|
|
40
|
+
readonly status: number;
|
|
41
|
+
readonly statusText: string;
|
|
42
|
+
readonly headers: Headers;
|
|
43
|
+
readonly ok: boolean;
|
|
44
|
+
readonly bodyUsed: boolean;
|
|
45
|
+
text(): Promise<string>;
|
|
46
|
+
json<T = any>(): Promise<T>;
|
|
47
|
+
arrayBuffer(): Promise<ArrayBuffer>;
|
|
48
|
+
clone(): Response;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
var Request: {
|
|
52
|
+
new(input: string | Request, init?: RequestInit): Request;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
var Response: {
|
|
56
|
+
new(body?: string | Uint8Array | ArrayBuffer | null, init?: ResponseInit): Response;
|
|
57
|
+
json(data: any, init?: ResponseInit): Response;
|
|
58
|
+
redirect(location: string, status?: number): Response;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
interface FetchOptions extends RequestInit {}
|
|
62
|
+
|
|
63
|
+
function fetch(url: string, options?: FetchOptions): Promise<Response>;
|
|
64
|
+
|
|
65
|
+
type RequestHandler = (request: Request) => Response | Promise<Response>;
|
|
66
|
+
type FetchHandlerObject = {
|
|
67
|
+
fetch(request: Request): Response | Promise<Response>;
|
|
68
|
+
};
|
|
69
|
+
type PageHandler = RequestHandler | FetchHandlerObject;
|
|
70
|
+
function serve(handler: PageHandler): void;
|
|
71
|
+
|
|
72
|
+
interface RouteContext {
|
|
73
|
+
params: Record<string, string>;
|
|
74
|
+
query: URLSearchParams;
|
|
75
|
+
url: URL;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
type RouteHandler = (request: Request, ctx: RouteContext) => Response | Promise<Response>;
|
|
79
|
+
|
|
80
|
+
interface Router {
|
|
81
|
+
on(method: string, path: string, handler: RouteHandler): Router;
|
|
82
|
+
all(path: string, handler: RouteHandler): Router;
|
|
83
|
+
get(path: string, handler: RouteHandler): Router;
|
|
84
|
+
post(path: string, handler: RouteHandler): Router;
|
|
85
|
+
put(path: string, handler: RouteHandler): Router;
|
|
86
|
+
patch(path: string, handler: RouteHandler): Router;
|
|
87
|
+
delete(path: string, handler: RouteHandler): Router;
|
|
88
|
+
options(path: string, handler: RouteHandler): Router;
|
|
89
|
+
head(path: string, handler: RouteHandler): Router;
|
|
90
|
+
fetch(request: Request): Promise<Response>;
|
|
91
|
+
handle(request: Request): Promise<Response>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface HttpHelpers {
|
|
95
|
+
text(body: string, init?: ResponseInit): Response;
|
|
96
|
+
html(body: string, init?: ResponseInit): Response;
|
|
97
|
+
json(data: any, init?: ResponseInit): Response;
|
|
98
|
+
read<T = any>(request: Request, kind?: "json" | "form" | "text" | "bytes" | string): Promise<T | string | ArrayBuffer | Record<string, string>>;
|
|
99
|
+
redirect(location: string, status?: number): Response;
|
|
100
|
+
error(status: number, message?: string): Response;
|
|
101
|
+
noContent(): Response;
|
|
102
|
+
notFound(message?: string): Response;
|
|
103
|
+
methodNotAllowed(methods?: string | string[]): Response;
|
|
104
|
+
cookie(request: Request, name: string): string | null;
|
|
105
|
+
cookie(request: Request): Record<string, string>;
|
|
106
|
+
withHeaders(response: Response, headers: Record<string, string>): Promise<Response>;
|
|
107
|
+
cors(response: Response, options?: {
|
|
108
|
+
origin?: string;
|
|
109
|
+
methods?: string | string[];
|
|
110
|
+
headers?: string | string[];
|
|
111
|
+
exposeHeaders?: string | string[];
|
|
112
|
+
credentials?: boolean;
|
|
113
|
+
}): Promise<Response>;
|
|
114
|
+
setCookie(response: Response, name: string, value: string, options?: {
|
|
115
|
+
maxAge?: number;
|
|
116
|
+
domain?: string;
|
|
117
|
+
path?: string;
|
|
118
|
+
expires?: string;
|
|
119
|
+
sameSite?: string;
|
|
120
|
+
httpOnly?: boolean;
|
|
121
|
+
secure?: boolean;
|
|
122
|
+
}): Promise<Response>;
|
|
123
|
+
clearCookie(response: Response, name: string, options?: {
|
|
124
|
+
domain?: string;
|
|
125
|
+
path?: string;
|
|
126
|
+
sameSite?: string;
|
|
127
|
+
httpOnly?: boolean;
|
|
128
|
+
secure?: boolean;
|
|
129
|
+
}): Promise<Response>;
|
|
130
|
+
sse(): {
|
|
131
|
+
stream: EventStream;
|
|
132
|
+
response: Response;
|
|
133
|
+
};
|
|
134
|
+
router(): Router;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const http: HttpHelpers;
|
|
138
|
+
|
|
139
|
+
interface PageMeta {
|
|
140
|
+
org: string;
|
|
141
|
+
repo: string;
|
|
142
|
+
commit: string;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
interface PageAuthIdentity {
|
|
146
|
+
subject: string;
|
|
147
|
+
name: string;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
interface PageAuth {
|
|
151
|
+
authenticated: boolean;
|
|
152
|
+
identity: PageAuthIdentity | null;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
interface PageEntry {
|
|
156
|
+
name: string;
|
|
157
|
+
path: string;
|
|
158
|
+
type: "file" | "dir" | "symlink" | "submodule";
|
|
159
|
+
size?: number;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
interface PageFS {
|
|
163
|
+
list(path?: string): PageEntry[];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
interface KVListResult {
|
|
167
|
+
keys: string[];
|
|
168
|
+
items: { key: string; value: string }[];
|
|
169
|
+
cursor: string;
|
|
170
|
+
hasNext: boolean;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
interface KVOps {
|
|
174
|
+
get(key: string): string | null;
|
|
175
|
+
set(key: string, value: string, ttl?: number): void;
|
|
176
|
+
delete(key: string): boolean;
|
|
177
|
+
putIfNotExists(key: string, value: string, ttl?: number): boolean;
|
|
178
|
+
compareAndSwap(key: string, oldValue: string, newValue: string): boolean;
|
|
179
|
+
list(limit?: number, cursor?: string): KVListResult;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
interface KVSystem {
|
|
183
|
+
repo(...group: string[]): KVOps;
|
|
184
|
+
org(...group: string[]): KVOps;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
interface EventSystem {
|
|
188
|
+
load(key: string): Promise<any>;
|
|
189
|
+
put(key: string, value: string): Promise<void>;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
interface PageHost {
|
|
193
|
+
meta: PageMeta;
|
|
194
|
+
auth: PageAuth;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const page: PageHost;
|
|
198
|
+
const fs: PageFS;
|
|
199
|
+
const kv: KVSystem;
|
|
200
|
+
const event: EventSystem;
|
|
201
|
+
function upgradeWebSocket(request?: Request): {
|
|
202
|
+
socket: WebSocket;
|
|
203
|
+
response: Response;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
interface EventStream {
|
|
207
|
+
send(data: string, options?: {
|
|
208
|
+
event?: string;
|
|
209
|
+
id?: string;
|
|
210
|
+
retry?: number;
|
|
211
|
+
}): Promise<void>;
|
|
212
|
+
close(): void;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
interface WebSocketEventMap {
|
|
216
|
+
open: Event;
|
|
217
|
+
message: MessageEvent<string | Uint8Array>;
|
|
218
|
+
close: CloseEvent;
|
|
219
|
+
error: Event;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
interface Event {
|
|
223
|
+
type: string;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
interface MessageEvent<T = any> extends Event {
|
|
227
|
+
data: T;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
interface CloseEvent extends Event {
|
|
231
|
+
code?: number;
|
|
232
|
+
reason?: string;
|
|
233
|
+
wasClean?: boolean;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
interface WebSocket {
|
|
237
|
+
readonly CONNECTING: 0;
|
|
238
|
+
readonly OPEN: 1;
|
|
239
|
+
readonly CLOSING: 2;
|
|
240
|
+
readonly CLOSED: 3;
|
|
241
|
+
readonly readyState: number;
|
|
242
|
+
onopen: ((event: Event) => void) | null;
|
|
243
|
+
onmessage: ((event: MessageEvent<string | Uint8Array>) => void) | null;
|
|
244
|
+
onerror: ((event: Event) => void) | null;
|
|
245
|
+
onclose: ((event: CloseEvent) => void) | null;
|
|
246
|
+
addEventListener<K extends keyof WebSocketEventMap>(type: K, listener: (event: WebSocketEventMap[K]) => void): void;
|
|
247
|
+
send(data: string | Uint8Array | ArrayBuffer): Promise<void>;
|
|
248
|
+
close(code?: number): void;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
interface Console {
|
|
252
|
+
log(...args: any[]): void;
|
|
253
|
+
warn(...args: any[]): void;
|
|
254
|
+
error(...args: any[]): void;
|
|
255
|
+
info(...args: any[]): void;
|
|
256
|
+
debug(...args: any[]): void;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const console: Console;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
export {};
|