GUI-STUDIO commited on
Commit
2108cc1
·
0 Parent(s):

TEST UPDATES

Browse files
.gitignore ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+ # dependencies
4
+ /node_modules
5
+ /.pnp
6
+ .pnp.js
7
+
8
+ # testing
9
+ /coverage
10
+
11
+ # next.js
12
+ /.next/
13
+ /out/
14
+
15
+ # production
16
+ /build
17
+
18
+ # misc
19
+ .DS_Store
20
+ *.pem
21
+
22
+ # debug
23
+ npm-debug.log*
24
+ yarn-debug.log*
25
+ yarn-error.log*
26
+
27
+ # local env files
28
+ .env.local
29
+ .env.development.local
30
+ .env.test.local
31
+ .env.production.local
32
+ *.env.*
33
+ .env
34
+
35
+ # vercel
36
+ .vercel
37
+
38
+ **/*.trace
39
+ **/*.zip
40
+ **/*.tar.gz
41
+ **/*.tgz
42
+ **/*.log
43
+ package-lock.json
44
+ **/*.bun
Dockerfile ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM oven/bun:latest
2
+
3
+ # USER root
4
+ # RUN apt-get update
5
+
6
+ RUN useradd -m -u 1001 user
7
+ WORKDIR /app
8
+
9
+ COPY --chown=user package.json ./
10
+ RUN bun install
11
+
12
+ USER user
13
+ ENV PATH="/home/user/.bun/bin:$PATH"
14
+
15
+ COPY --chown=user . .
16
+
17
+ EXPOSE 7860
18
+
19
+ CMD ["bun", "run", "start:prod:tsdown"]
README.md ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Elysia with Bun runtime
2
+
3
+ ## Getting Started
4
+ To get started with this template, simply paste this command into your terminal:
5
+ ```bash
6
+ bun create elysia ./elysia-example
7
+ ```
8
+
9
+ ## Development
10
+ To start the development server run:
11
+ ```bash
12
+ bun run dev
13
+ ```
14
+
15
+ Open http://localhost:3000/ with your browser to see the result.
package.json ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "hf-app-proxima",
3
+ "version": "1.0.50",
4
+ "private": true,
5
+ "scripts": {
6
+ "test": "echo \"Error: no test specified\" && exit 1",
7
+ "dev": "bun run start:dev",
8
+ "start:dev": "bun run --watch src/index.ts",
9
+ "start:dev:tsdown": "bun run --watch dist/index.mjs",
10
+ "prod": "bun run start:prod",
11
+ "start:prod": "NODE_ENV=production bun src/index.ts",
12
+ "start:prod:tsdown": "NODE_ENV=production bun dist/index.mjs",
13
+ "build:tsdown": "bun run tsdown"
14
+ },
15
+ "dependencies": {
16
+ "@elysiajs/cors": "^1.4.1",
17
+ "@elysiajs/html": "^1.4.0",
18
+ "@hono/standard-validator": "^0.2.2",
19
+ "axios": "^1.13.5",
20
+ "devalue": "^5.6.3",
21
+ "elysia": "latest",
22
+ "hono": "^4.12.2",
23
+ "html-prettify": "^1.0.7",
24
+ "http-errors": "^2.0.1",
25
+ "valibot": "^1.2.0"
26
+ },
27
+ "devDependencies": {
28
+ "bun-types": "latest",
29
+ "tsdown": "^0.20.3"
30
+ },
31
+ "module": "src/index.js"
32
+ }
src/index.ts ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Elysia, Context, t } from "elysia";
2
+ import { logger } from "@chneau/elysia-logger";
3
+ import { staticPlugin } from "@elysiajs/static";
4
+ import { cors } from "@elysiajs/cors";
5
+ import {
6
+ NS_helpers_client,
7
+ NS_helpers_server
8
+ } from "../../../../packages/lib/helpers/index";
9
+ import { HonoRouter } from "./sub-router/hono.index";
10
+
11
+ const APP_ENV = Bun.env.APP_ENV;
12
+ const APP_ORIGIN = Bun.env.APP_ORIGIN;
13
+
14
+ const app = new Elysia()
15
+
16
+ .use(
17
+ cors({
18
+ origin: "*",
19
+ allowedHeaders: "*",
20
+ methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
21
+ exposeHeaders: "*"
22
+ })
23
+ )
24
+
25
+ .derive((ctx: any) => ({
26
+ publicOrigin: NS_helpers_server.NS_routes.elysia.F_public_origin(ctx)
27
+ }))
28
+
29
+ .use(logger())
30
+
31
+ .onError(async ({ code, error }) => {
32
+ let e_message = "";
33
+ if (code === "VALIDATION") {
34
+ e_message = error.message;
35
+ try {
36
+ e_message = JSON.parse(e_message).summary;
37
+ } catch (err) {}
38
+ }
39
+
40
+ const err_d = NS_helpers_client.NS_error.F_collect_error_status_n_message({
41
+ ERR: error
42
+ });
43
+
44
+ if (APP_ENV === "dev") {
45
+ console.log("\n");
46
+ console.log({ code, e_message, ...err_d }, "\n");
47
+ }
48
+
49
+ return new Response(error.toString(), {
50
+ status: err_d.status,
51
+ headers: {
52
+ "x-error-message": err_d.message,
53
+ "x-error-status": err_d.status
54
+ }
55
+ });
56
+ })
57
+
58
+ .mount("/", HonoRouter.fetch)
59
+
60
+ .get("/", () => "Hello Elysia")
61
+ .listen(7860);
62
+
63
+ console.log(
64
+ `🦊 Elysia is running at ${app.server?.hostname}:${app.server?.port}`
65
+ );
src/sub-router/hono.index.ts ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Hono } from "hono";
2
+ import { cors } from "hono/cors";
3
+ import { logger } from "hono/logger";
4
+ import { trimTrailingSlash } from "hono/trailing-slash";
5
+ import { ProximaRouter } from "./proxima";
6
+
7
+ const app = new Hono({ strict: true });
8
+
9
+ app.use(
10
+ trimTrailingSlash(),
11
+ logger(),
12
+ cors({
13
+ origin: "*",
14
+ allowHeaders: ["*"],
15
+ exposeHeaders: ["*"]
16
+ })
17
+ );
18
+
19
+ app.route("/", ProximaRouter);
20
+
21
+ export const HonoRouter = app;
src/sub-router/proxima.ts ADDED
@@ -0,0 +1,382 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { Hono, type Context } from "hono";
2
+ import { proxy } from "hono/proxy";
3
+ import * as cheerio from "cheerio";
4
+ import { NS_promise } from "../../../../../packages/lib/helpers/client/promise";
5
+ import { NS_routes_c } from "../../../../../packages/lib/helpers/client/route";
6
+ import { stream } from "hono/streaming";
7
+ import prettify from "html-prettify";
8
+ import { NS_Misc } from "../../../../../packages/lib/helpers/client/misc";
9
+ import { NS_playback_helper } from "../../../../../packages/lib/helpers/server/playback";
10
+ import axios from "axios";
11
+ import { sValidator } from "@hono/standard-validator";
12
+ import { NS_unpack_proxima } from "../../../../../packages/lib/helpers/server/proxima/unpack";
13
+ import { NS_error } from "../../../../../packages/lib/helpers/client/error";
14
+
15
+ const APP_ENV = process.env.APP_ENV;
16
+ const X_OFFLINE = process.env.X_OFFLINE;
17
+ const APP_ORIGIN = process.env.APP_ORIGIN;
18
+ const REPO_ORIGIN = process.env.REPO_ORIGIN;
19
+
20
+ const sub_router = new Hono().basePath("/proxima");
21
+
22
+ sub_router.get(
23
+ "/:proxima_endpoint/:proxima_commands?",
24
+ sValidator("param", NS_unpack_proxima.schema, (result, c) => {
25
+ if (!result.success) {
26
+ const message = result.error[0].message;
27
+ return c.text(message, 400);
28
+ }
29
+ }),
30
+ async (ctx) => {
31
+ const params = ctx.req.valid("param");
32
+ const query = ctx.req.query();
33
+
34
+ const REQ0 = ctx.req.url;
35
+ const REQ_ORIGIN = APP_ORIGIN || new URL(REQ0).origin;
36
+ const REQ_headers = ctx.req.raw.headers;
37
+
38
+ const { proxima_endpoint, proxima_commands } = params;
39
+
40
+ const [E_, R_] = await NS_promise.F_catch_promise({
41
+ promise: NS_unpack_proxima.F_unpack_proxima_endpoint_n_commands({
42
+ proxima_endpoint,
43
+ proxima_commands
44
+ })
45
+ });
46
+
47
+ if (E_) {
48
+ const { status, message } = NS_error.F_collect_error_status_n_message({
49
+ ERR: E_
50
+ });
51
+
52
+ return ctx.text(message, status);
53
+ }
54
+
55
+ const { decoded_proxy_endpoint, decoded_proxy_commands } = R_;
56
+
57
+ const iFilm_id =
58
+ decoded_proxy_commands?.iMovie_id || decoded_proxy_commands?.iFilm_id;
59
+
60
+ const season = decoded_proxy_commands?.season;
61
+ const episode = decoded_proxy_commands?.episode;
62
+ const cinema_quality = decoded_proxy_commands?.cinema_quality;
63
+
64
+ const og_endpoint = decoded_proxy_endpoint.href;
65
+
66
+ if (query?.ops === "raw") {
67
+ return ctx.json({
68
+ decoded_proxy_endpoint: og_endpoint,
69
+ decoded_proxy_commands
70
+ });
71
+ }
72
+
73
+ const req0_headers_object = Object.fromEntries(
74
+ (REQ_headers as any).entries()
75
+ );
76
+
77
+ F_handle_clean_req_headers({ avoid_cert_val: true });
78
+
79
+ function F_handle_clean_req_headers(arg0: { avoid_cert_val?: boolean }) {
80
+ const { avoid_cert_val } = arg0;
81
+
82
+ const has_dpx_referer =
83
+ decoded_proxy_commands?.headers &&
84
+ (decoded_proxy_commands.headers["Referer"] ||
85
+ decoded_proxy_commands.headers["referer"]);
86
+
87
+ const has_dpx_host =
88
+ decoded_proxy_commands?.headers &&
89
+ (decoded_proxy_commands.headers["Host"] ||
90
+ decoded_proxy_commands.headers["host"]);
91
+
92
+ const has_dpx_origin =
93
+ decoded_proxy_commands?.headers &&
94
+ (decoded_proxy_commands.headers["Origin"] ||
95
+ decoded_proxy_commands.headers["origin"]);
96
+
97
+ // delete ip headers
98
+ delete req0_headers_object["x-forwarded-for"];
99
+ delete req0_headers_object["true-client-ip"];
100
+ delete req0_headers_object["cf-ipcountry"];
101
+ delete req0_headers_object["cf-connecting-ip"];
102
+ delete req0_headers_object["x-request-start"];
103
+ delete req0_headers_object["rndr-id"];
104
+ delete req0_headers_object["render-proxy-ttl"];
105
+
106
+ for (const key in req0_headers_object) {
107
+ if (!(key in req0_headers_object)) continue;
108
+
109
+ const xx = req0_headers_object[key];
110
+
111
+ if (key?.startsWith("x-")) {
112
+ delete req0_headers_object[key];
113
+ }
114
+
115
+ if (key.toLowerCase() === "referer" && has_dpx_referer) {
116
+ delete req0_headers_object[key];
117
+ }
118
+
119
+ if (key.toLowerCase() === "host") {
120
+ if (has_dpx_host) {
121
+ delete req0_headers_object[key];
122
+ } else {
123
+ req0_headers_object[key] = decoded_proxy_endpoint!.hostname;
124
+ }
125
+ }
126
+
127
+ if (key.toLowerCase() === "origin") {
128
+ delete req0_headers_object[key];
129
+ }
130
+ }
131
+
132
+ if (decoded_proxy_commands?.headers) {
133
+ for (const key in decoded_proxy_commands.headers) {
134
+ if (
135
+ Object.prototype.hasOwnProperty.call(
136
+ decoded_proxy_commands.headers,
137
+ key
138
+ )
139
+ ) {
140
+ const value = decoded_proxy_commands.headers[key];
141
+
142
+ req0_headers_object[key.toLowerCase()] = value;
143
+ }
144
+ }
145
+ }
146
+ }
147
+
148
+ // 1. fetch upstream
149
+ const upstream = await (async () => {
150
+ try {
151
+ return await proxy(decoded_proxy_endpoint.href, {
152
+ headers: req0_headers_object
153
+ });
154
+ } catch (err: any) {
155
+ if (err?.code === "ConnectionRefused" || err?.code === "ECONNREFUSED") {
156
+ if (
157
+ !decoded_proxy_commands ||
158
+ !decoded_proxy_commands.ECONNREFUSED_fallback
159
+ )
160
+ return;
161
+
162
+ const ECONNREFUSED_fallback = new URL(
163
+ decoded_proxy_commands.ECONNREFUSED_fallback.toString()
164
+ );
165
+
166
+ if (
167
+ req0_headers_object &&
168
+ req0_headers_object.host &&
169
+ req0_headers_object.host !== ECONNREFUSED_fallback.hostname
170
+ ) {
171
+ req0_headers_object.host = ECONNREFUSED_fallback.hostname;
172
+ }
173
+
174
+ console.log({ ECONNREFUSED_fallback }, { req0_headers_object });
175
+
176
+ return await proxy(ECONNREFUSED_fallback.toString(), {
177
+ headers: req0_headers_object
178
+ });
179
+ }
180
+ }
181
+ })();
182
+
183
+ // 2. short-circuit
184
+ if (!upstream) {
185
+ return new Response("upstream undefined", {
186
+ status: 500
187
+ });
188
+ }
189
+
190
+ // 3. strip security headers
191
+
192
+ // 2. strip security headers
193
+ upstream.headers.delete("content-security-policy");
194
+ upstream.headers.delete("x-frame-options");
195
+
196
+ const resHeaders = new Headers(upstream.headers);
197
+ const resHeadersObj = Object.fromEntries((resHeaders as any).entries());
198
+
199
+ const content_type = resHeaders.get("content-type") ?? "";
200
+
201
+ if (!upstream.ok) {
202
+ // simply forward the response unchanged
203
+ return upstream;
204
+ }
205
+
206
+ const is_m3u8 = await NS_playback_helper.F_is_M3U8_response(upstream);
207
+
208
+ // 4. HTML rewrite
209
+ if (
210
+ !decoded_proxy_commands?.m3u8_playlist_child &&
211
+ content_type?.includes("text/html") &&
212
+ !is_m3u8
213
+ ) {
214
+ return stream(ctx, async (stream) => {
215
+ ctx.header("Content-Encoding", "Identity");
216
+
217
+ ctx.status(upstream.status as any);
218
+
219
+ for (const key in resHeadersObj) {
220
+ if (Object.prototype.hasOwnProperty.call(resHeadersObj, key)) {
221
+ const element = resHeadersObj[key];
222
+
223
+ ctx.header(key, element);
224
+ }
225
+ }
226
+
227
+ stream.onAbort(() => {
228
+ console.log("Aborted!");
229
+ });
230
+
231
+ await stream.write(
232
+ await (async () => {
233
+ let data = await upstream.text();
234
+
235
+ const $ = cheerio.load(data);
236
+
237
+ // fix relative href/src
238
+ $(`[href]`).each((i, el) => {
239
+ const href = $(el).attr("href")?.trim();
240
+ if (href && !href.startsWith("//") && !href.startsWith("http")) {
241
+ const new_href = NS_routes_c.F_flat_url_slash(
242
+ decoded_proxy_endpoint.origin + "/" + href
243
+ );
244
+ $(el).attr("href", new_href);
245
+ }
246
+ });
247
+
248
+ $(`[src]`).each((i, el) => {
249
+ const src = $(el).attr("src")?.trim();
250
+ if (src && !src.startsWith("//") && !src.startsWith("http")) {
251
+ const new_src = NS_routes_c.F_flat_url_slash(
252
+ decoded_proxy_endpoint.origin + "/" + src
253
+ );
254
+ $(el).attr("src", new_src);
255
+ }
256
+ });
257
+
258
+ // inject monkey-patch
259
+ if (
260
+ decoded_proxy_commands?.monkey_patch &&
261
+ NS_Misc.F_is_record(decoded_proxy_commands.monkey_patch)
262
+ ) {
263
+ const [ERROR, RESULT] = await NS_promise.F_catch_promise({
264
+ promise: axios({
265
+ method: "POST",
266
+ baseURL: REPO_ORIGIN,
267
+ url: "/sd/monkey-patch",
268
+ data: {
269
+ filename: "client-monkey-patch.ts",
270
+ obfuscate: true,
271
+ proxy_origin:
272
+ decoded_proxy_commands.monkey_patch?.alpha_proxy ||
273
+ REQ_ORIGIN,
274
+ monkey_config: decoded_proxy_commands.monkey_patch,
275
+ use_fs: true,
276
+ tool: "esbuild"
277
+ }
278
+ })
279
+ });
280
+
281
+ if (ERROR) {
282
+ console.error({ ERROR });
283
+ }
284
+
285
+ const data = RESULT?.data;
286
+
287
+ if (typeof data === "string") {
288
+ $("head").prepend(`<script>${data}</script>`);
289
+ }
290
+ }
291
+
292
+ const rewritten = prettify($.html());
293
+
294
+ return rewritten;
295
+ })()
296
+ );
297
+ });
298
+ }
299
+
300
+ if (
301
+ decoded_proxy_endpoint.toString().includes(".m3u8") ||
302
+ content_type?.includes("application/vnd.apple.mpegurl") ||
303
+ content_type?.includes("application/x-mpegurl")
304
+ ) {
305
+ let m3u8_content = await upstream.text();
306
+
307
+ const [ERROR, RESULT] = await NS_promise.F_catch_promise({
308
+ promise: NS_playback_helper.F_transform_m3u8({
309
+ content: m3u8_content,
310
+ true_origin: decoded_proxy_endpoint.origin,
311
+ true_base: NS_Misc.F_remove_last_array_element({
312
+ arr: decoded_proxy_endpoint.pathname.split("/")
313
+ }).join("/"),
314
+ proxy_base: NS_routes_c.F_flat_url_slash(REQ_ORIGIN + "/proxima"),
315
+ proxima_commands: decoded_proxy_commands
316
+ })
317
+ });
318
+
319
+ m3u8_content = RESULT || m3u8_content || "";
320
+
321
+ if (query?.ops === "get-master-m3u8-resolutions") {
322
+ const _ = NS_playback_helper.F_extract_resolutions_from_M3U8({
323
+ m3u8Content: m3u8_content
324
+ });
325
+
326
+ const play_resolutions = _ || [];
327
+
328
+ return ctx.json({
329
+ resolutions: play_resolutions,
330
+ content: m3u8_content
331
+ });
332
+ }
333
+
334
+ if (!decoded_proxy_commands?.m3u8_playlist_child && REPO_ORIGIN) {
335
+ const [ERROR, RESULT] = await NS_promise.F_catch_promise({
336
+ promise: axios({
337
+ method: "POST",
338
+ baseURL: REPO_ORIGIN,
339
+ url: "/proxima/post-processing/hls",
340
+ data: {
341
+ post_data: m3u8_content,
342
+ proxima_endpoint: decoded_proxy_endpoint.toString(),
343
+ proxima_commands: decoded_proxy_commands,
344
+ req_headers: req0_headers_object
345
+ }
346
+ })
347
+ });
348
+
349
+ if (RESULT?.data) {
350
+ const java_set = RESULT.data["xx-java-set"];
351
+ const lo_java_set = RESULT.data["xx-lo-java-set"];
352
+
353
+ if (java_set) {
354
+ // set x-java-set header
355
+ ctx.header("x-java-set", java_set);
356
+ }
357
+
358
+ if (lo_java_set) {
359
+ // set xx-lo-java-set header
360
+ ctx.header("x-lo-java-set", lo_java_set);
361
+ }
362
+ }
363
+ }
364
+
365
+ ctx.status(upstream.status as any);
366
+
367
+ for (const key in resHeadersObj) {
368
+ if (Object.prototype.hasOwnProperty.call(resHeadersObj, key)) {
369
+ const element = resHeadersObj[key];
370
+
371
+ ctx.header(key, element);
372
+ }
373
+ }
374
+
375
+ return ctx.body(m3u8_content);
376
+ }
377
+
378
+ return upstream;
379
+ }
380
+ );
381
+
382
+ export const ProximaRouter = sub_router;
tsconfig.json ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig to read more about this file */
4
+
5
+ /* Projects */
6
+ // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
7
+ // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
+ // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
9
+ // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10
+ // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
+ // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
+
13
+ /* Language and Environment */
14
+ "target": "ES2021", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
15
+ // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
16
+ // "jsx": "preserve", /* Specify what JSX code is generated. */
17
+ // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
18
+ // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
19
+ // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
20
+ // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
21
+ // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
22
+ // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
23
+ // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
24
+ // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
25
+ // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
26
+
27
+ /* Modules */
28
+ "module": "ES2022", /* Specify what module code is generated. */
29
+ // "rootDir": "./", /* Specify the root folder within your source files. */
30
+ "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
31
+ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
32
+ // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
33
+ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
34
+ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
35
+ "types": ["bun-types"], /* Specify type package names to be included without being referenced in a source file. */
36
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
37
+ // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
38
+ // "resolveJsonModule": true, /* Enable importing .json files. */
39
+ // "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
40
+
41
+ /* JavaScript Support */
42
+ // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
43
+ // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
44
+ // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
45
+
46
+ /* Emit */
47
+ // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
48
+ // "declarationMap": true, /* Create sourcemaps for d.ts files. */
49
+ // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
50
+ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
51
+ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
52
+ // "outDir": "./", /* Specify an output folder for all emitted files. */
53
+ // "removeComments": true, /* Disable emitting comments. */
54
+ // "noEmit": true, /* Disable emitting files from a compilation. */
55
+ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
56
+ // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
57
+ // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
58
+ // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
59
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
60
+ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
61
+ // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
62
+ // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
63
+ // "newLine": "crlf", /* Set the newline character for emitting files. */
64
+ // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
65
+ // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
66
+ // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
67
+ // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
68
+ // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
69
+ // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
70
+
71
+ /* Interop Constraints */
72
+ // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
73
+ // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
74
+ "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
75
+ // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
76
+ "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
77
+
78
+ /* Type Checking */
79
+ "strict": true, /* Enable all strict type-checking options. */
80
+ // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
81
+ // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
82
+ // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
83
+ // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
84
+ // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
85
+ // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
86
+ // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
87
+ // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
88
+ // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
89
+ // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
90
+ // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
91
+ // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
92
+ // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
93
+ // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
94
+ // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
95
+ // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
96
+ // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
97
+ // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
98
+
99
+ /* Completeness */
100
+ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
101
+ "skipLibCheck": true /* Skip type checking all .d.ts files. */
102
+ }
103
+ }
tsdown.config.ts ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import { defineConfig } from "tsdown";
2
+
3
+ export default defineConfig({
4
+ entry: "src/index.ts",
5
+ shims: true,
6
+ tsconfig: "./tsconfig.json",
7
+ outDir: "dist",
8
+ noExternal: ["lib"],
9
+ external: [/^(?!\.{1,2}\/|(?:\/|\\\\|[a-zA-Z]:)).*$/]
10
+ });