mirror of
https://github.com/placeholder-soft/Babylong.git
synced 2026-04-30 12:32:27 +08:00
fix: ts error
This commit is contained in:
24
.gitignore
vendored
24
.gitignore
vendored
@@ -1,17 +1,23 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Dependencies
|
||||
node_modules
|
||||
.pnp
|
||||
.pnp.js
|
||||
|
||||
# Testing
|
||||
coverage
|
||||
|
||||
# Production
|
||||
dist
|
||||
dist-ssr
|
||||
*.local
|
||||
|
||||
# Environment files
|
||||
.env
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
# Editor directories and files
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
const urls = new Set();
|
||||
|
||||
function checkURL(request, init) {
|
||||
const url =
|
||||
request instanceof URL
|
||||
? request
|
||||
: new URL(
|
||||
(typeof request === "string"
|
||||
? new Request(request, init)
|
||||
: request
|
||||
).url
|
||||
);
|
||||
if (url.port && url.port !== "443" && url.protocol === "https:") {
|
||||
if (!urls.has(url.toString())) {
|
||||
urls.add(url.toString());
|
||||
console.warn(
|
||||
`WARNING: known issue with \`fetch()\` requests to custom HTTPS ports in published Workers:\n` +
|
||||
` - ${url.toString()} - the custom port will be ignored when the Worker is published using the \`wrangler deploy\` command.\n`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
globalThis.fetch = new Proxy(globalThis.fetch, {
|
||||
apply(target, thisArg, argArray) {
|
||||
const [request, init] = argArray;
|
||||
checkURL(request, init);
|
||||
return Reflect.apply(target, thisArg, argArray);
|
||||
},
|
||||
});
|
||||
@@ -1,11 +0,0 @@
|
||||
import worker, * as OTHER_EXPORTS from "/Users/chuan_yu/Desktop/work/satlayer-hackathon/node_modules/.pnpm/wrangler@3.85.0/node_modules/wrangler/templates/pages-template-worker.ts";
|
||||
import * as __MIDDLEWARE_0__ from "/Users/chuan_yu/Desktop/work/satlayer-hackathon/node_modules/.pnpm/wrangler@3.85.0/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts";
|
||||
import * as __MIDDLEWARE_1__ from "/Users/chuan_yu/Desktop/work/satlayer-hackathon/node_modules/.pnpm/wrangler@3.85.0/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts";
|
||||
|
||||
export * from "/Users/chuan_yu/Desktop/work/satlayer-hackathon/node_modules/.pnpm/wrangler@3.85.0/node_modules/wrangler/templates/pages-template-worker.ts";
|
||||
|
||||
export const __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||
|
||||
__MIDDLEWARE_0__.default,__MIDDLEWARE_1__.default
|
||||
]
|
||||
export default worker;
|
||||
@@ -1,134 +0,0 @@
|
||||
// This loads all middlewares exposed on the middleware object and then starts
|
||||
// the invocation chain. The big idea is that we can add these to the middleware
|
||||
// export dynamically through wrangler, or we can potentially let users directly
|
||||
// add them as a sort of "plugin" system.
|
||||
|
||||
import ENTRY, { __INTERNAL_WRANGLER_MIDDLEWARE__ } from "/Users/chuan_yu/Desktop/work/satlayer-hackathon/.wrangler/tmp/bundle-EUTT79/middleware-insertion-facade.js";
|
||||
import { __facade_invoke__, __facade_register__, Dispatcher } from "/Users/chuan_yu/Desktop/work/satlayer-hackathon/node_modules/.pnpm/wrangler@3.85.0/node_modules/wrangler/templates/middleware/common.ts";
|
||||
import type { WorkerEntrypointConstructor } from "/Users/chuan_yu/Desktop/work/satlayer-hackathon/.wrangler/tmp/bundle-EUTT79/middleware-insertion-facade.js";
|
||||
|
||||
// Preserve all the exports from the worker
|
||||
export * from "/Users/chuan_yu/Desktop/work/satlayer-hackathon/.wrangler/tmp/bundle-EUTT79/middleware-insertion-facade.js";
|
||||
|
||||
class __Facade_ScheduledController__ implements ScheduledController {
|
||||
readonly #noRetry: ScheduledController["noRetry"];
|
||||
|
||||
constructor(
|
||||
readonly scheduledTime: number,
|
||||
readonly cron: string,
|
||||
noRetry: ScheduledController["noRetry"]
|
||||
) {
|
||||
this.#noRetry = noRetry;
|
||||
}
|
||||
|
||||
noRetry() {
|
||||
if (!(this instanceof __Facade_ScheduledController__)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
// Need to call native method immediately in case uncaught error thrown
|
||||
this.#noRetry();
|
||||
}
|
||||
}
|
||||
|
||||
function wrapExportedHandler(worker: ExportedHandler): ExportedHandler {
|
||||
// If we don't have any middleware defined, just return the handler as is
|
||||
if (
|
||||
__INTERNAL_WRANGLER_MIDDLEWARE__ === undefined ||
|
||||
__INTERNAL_WRANGLER_MIDDLEWARE__.length === 0
|
||||
) {
|
||||
return worker;
|
||||
}
|
||||
// Otherwise, register all middleware once
|
||||
for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) {
|
||||
__facade_register__(middleware);
|
||||
}
|
||||
|
||||
const fetchDispatcher: ExportedHandlerFetchHandler = function (
|
||||
request,
|
||||
env,
|
||||
ctx
|
||||
) {
|
||||
if (worker.fetch === undefined) {
|
||||
throw new Error("Handler does not export a fetch() function.");
|
||||
}
|
||||
return worker.fetch(request, env, ctx);
|
||||
};
|
||||
|
||||
return {
|
||||
...worker,
|
||||
fetch(request, env, ctx) {
|
||||
const dispatcher: Dispatcher = function (type, init) {
|
||||
if (type === "scheduled" && worker.scheduled !== undefined) {
|
||||
const controller = new __Facade_ScheduledController__(
|
||||
Date.now(),
|
||||
init.cron ?? "",
|
||||
() => {}
|
||||
);
|
||||
return worker.scheduled(controller, env, ctx);
|
||||
}
|
||||
};
|
||||
return __facade_invoke__(request, env, ctx, dispatcher, fetchDispatcher);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function wrapWorkerEntrypoint(
|
||||
klass: WorkerEntrypointConstructor
|
||||
): WorkerEntrypointConstructor {
|
||||
// If we don't have any middleware defined, just return the handler as is
|
||||
if (
|
||||
__INTERNAL_WRANGLER_MIDDLEWARE__ === undefined ||
|
||||
__INTERNAL_WRANGLER_MIDDLEWARE__.length === 0
|
||||
) {
|
||||
return klass;
|
||||
}
|
||||
// Otherwise, register all middleware once
|
||||
for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) {
|
||||
__facade_register__(middleware);
|
||||
}
|
||||
|
||||
// `extend`ing `klass` here so other RPC methods remain callable
|
||||
return class extends klass {
|
||||
#fetchDispatcher: ExportedHandlerFetchHandler<Record<string, unknown>> = (
|
||||
request,
|
||||
env,
|
||||
ctx
|
||||
) => {
|
||||
this.env = env;
|
||||
this.ctx = ctx;
|
||||
if (super.fetch === undefined) {
|
||||
throw new Error("Entrypoint class does not define a fetch() function.");
|
||||
}
|
||||
return super.fetch(request);
|
||||
};
|
||||
|
||||
#dispatcher: Dispatcher = (type, init) => {
|
||||
if (type === "scheduled" && super.scheduled !== undefined) {
|
||||
const controller = new __Facade_ScheduledController__(
|
||||
Date.now(),
|
||||
init.cron ?? "",
|
||||
() => {}
|
||||
);
|
||||
return super.scheduled(controller);
|
||||
}
|
||||
};
|
||||
|
||||
fetch(request: Request<unknown, IncomingRequestCfProperties>) {
|
||||
return __facade_invoke__(
|
||||
request,
|
||||
this.env,
|
||||
this.ctx,
|
||||
this.#dispatcher,
|
||||
this.#fetchDispatcher
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let WRAPPED_ENTRY: ExportedHandler | WorkerEntrypointConstructor | undefined;
|
||||
if (typeof ENTRY === "object") {
|
||||
WRAPPED_ENTRY = wrapExportedHandler(ENTRY);
|
||||
} else if (typeof ENTRY === "function") {
|
||||
WRAPPED_ENTRY = wrapWorkerEntrypoint(ENTRY);
|
||||
}
|
||||
export default WRAPPED_ENTRY;
|
||||
@@ -1,30 +0,0 @@
|
||||
const urls = new Set();
|
||||
|
||||
function checkURL(request, init) {
|
||||
const url =
|
||||
request instanceof URL
|
||||
? request
|
||||
: new URL(
|
||||
(typeof request === "string"
|
||||
? new Request(request, init)
|
||||
: request
|
||||
).url
|
||||
);
|
||||
if (url.port && url.port !== "443" && url.protocol === "https:") {
|
||||
if (!urls.has(url.toString())) {
|
||||
urls.add(url.toString());
|
||||
console.warn(
|
||||
`WARNING: known issue with \`fetch()\` requests to custom HTTPS ports in published Workers:\n` +
|
||||
` - ${url.toString()} - the custom port will be ignored when the Worker is published using the \`wrangler deploy\` command.\n`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
globalThis.fetch = new Proxy(globalThis.fetch, {
|
||||
apply(target, thisArg, argArray) {
|
||||
const [request, init] = argArray;
|
||||
checkURL(request, init);
|
||||
return Reflect.apply(target, thisArg, argArray);
|
||||
},
|
||||
});
|
||||
@@ -1,11 +0,0 @@
|
||||
import worker, * as OTHER_EXPORTS from "/Users/chuan_yu/Desktop/work/satlayer-hackathon/.wrangler/tmp/pages-r4dXCe/functionsWorker-0.9817993910801683.mjs";
|
||||
import * as __MIDDLEWARE_0__ from "/Users/chuan_yu/Desktop/work/satlayer-hackathon/node_modules/.pnpm/wrangler@3.85.0/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts";
|
||||
import * as __MIDDLEWARE_1__ from "/Users/chuan_yu/Desktop/work/satlayer-hackathon/node_modules/.pnpm/wrangler@3.85.0/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts";
|
||||
|
||||
export * from "/Users/chuan_yu/Desktop/work/satlayer-hackathon/.wrangler/tmp/pages-r4dXCe/functionsWorker-0.9817993910801683.mjs";
|
||||
|
||||
export const __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||
|
||||
__MIDDLEWARE_0__.default,__MIDDLEWARE_1__.default
|
||||
]
|
||||
export default worker;
|
||||
@@ -1,134 +0,0 @@
|
||||
// This loads all middlewares exposed on the middleware object and then starts
|
||||
// the invocation chain. The big idea is that we can add these to the middleware
|
||||
// export dynamically through wrangler, or we can potentially let users directly
|
||||
// add them as a sort of "plugin" system.
|
||||
|
||||
import ENTRY, { __INTERNAL_WRANGLER_MIDDLEWARE__ } from "/Users/chuan_yu/Desktop/work/satlayer-hackathon/.wrangler/tmp/bundle-ooiDol/middleware-insertion-facade.js";
|
||||
import { __facade_invoke__, __facade_register__, Dispatcher } from "/Users/chuan_yu/Desktop/work/satlayer-hackathon/node_modules/.pnpm/wrangler@3.85.0/node_modules/wrangler/templates/middleware/common.ts";
|
||||
import type { WorkerEntrypointConstructor } from "/Users/chuan_yu/Desktop/work/satlayer-hackathon/.wrangler/tmp/bundle-ooiDol/middleware-insertion-facade.js";
|
||||
|
||||
// Preserve all the exports from the worker
|
||||
export * from "/Users/chuan_yu/Desktop/work/satlayer-hackathon/.wrangler/tmp/bundle-ooiDol/middleware-insertion-facade.js";
|
||||
|
||||
class __Facade_ScheduledController__ implements ScheduledController {
|
||||
readonly #noRetry: ScheduledController["noRetry"];
|
||||
|
||||
constructor(
|
||||
readonly scheduledTime: number,
|
||||
readonly cron: string,
|
||||
noRetry: ScheduledController["noRetry"]
|
||||
) {
|
||||
this.#noRetry = noRetry;
|
||||
}
|
||||
|
||||
noRetry() {
|
||||
if (!(this instanceof __Facade_ScheduledController__)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
// Need to call native method immediately in case uncaught error thrown
|
||||
this.#noRetry();
|
||||
}
|
||||
}
|
||||
|
||||
function wrapExportedHandler(worker: ExportedHandler): ExportedHandler {
|
||||
// If we don't have any middleware defined, just return the handler as is
|
||||
if (
|
||||
__INTERNAL_WRANGLER_MIDDLEWARE__ === undefined ||
|
||||
__INTERNAL_WRANGLER_MIDDLEWARE__.length === 0
|
||||
) {
|
||||
return worker;
|
||||
}
|
||||
// Otherwise, register all middleware once
|
||||
for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) {
|
||||
__facade_register__(middleware);
|
||||
}
|
||||
|
||||
const fetchDispatcher: ExportedHandlerFetchHandler = function (
|
||||
request,
|
||||
env,
|
||||
ctx
|
||||
) {
|
||||
if (worker.fetch === undefined) {
|
||||
throw new Error("Handler does not export a fetch() function.");
|
||||
}
|
||||
return worker.fetch(request, env, ctx);
|
||||
};
|
||||
|
||||
return {
|
||||
...worker,
|
||||
fetch(request, env, ctx) {
|
||||
const dispatcher: Dispatcher = function (type, init) {
|
||||
if (type === "scheduled" && worker.scheduled !== undefined) {
|
||||
const controller = new __Facade_ScheduledController__(
|
||||
Date.now(),
|
||||
init.cron ?? "",
|
||||
() => {}
|
||||
);
|
||||
return worker.scheduled(controller, env, ctx);
|
||||
}
|
||||
};
|
||||
return __facade_invoke__(request, env, ctx, dispatcher, fetchDispatcher);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
function wrapWorkerEntrypoint(
|
||||
klass: WorkerEntrypointConstructor
|
||||
): WorkerEntrypointConstructor {
|
||||
// If we don't have any middleware defined, just return the handler as is
|
||||
if (
|
||||
__INTERNAL_WRANGLER_MIDDLEWARE__ === undefined ||
|
||||
__INTERNAL_WRANGLER_MIDDLEWARE__.length === 0
|
||||
) {
|
||||
return klass;
|
||||
}
|
||||
// Otherwise, register all middleware once
|
||||
for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) {
|
||||
__facade_register__(middleware);
|
||||
}
|
||||
|
||||
// `extend`ing `klass` here so other RPC methods remain callable
|
||||
return class extends klass {
|
||||
#fetchDispatcher: ExportedHandlerFetchHandler<Record<string, unknown>> = (
|
||||
request,
|
||||
env,
|
||||
ctx
|
||||
) => {
|
||||
this.env = env;
|
||||
this.ctx = ctx;
|
||||
if (super.fetch === undefined) {
|
||||
throw new Error("Entrypoint class does not define a fetch() function.");
|
||||
}
|
||||
return super.fetch(request);
|
||||
};
|
||||
|
||||
#dispatcher: Dispatcher = (type, init) => {
|
||||
if (type === "scheduled" && super.scheduled !== undefined) {
|
||||
const controller = new __Facade_ScheduledController__(
|
||||
Date.now(),
|
||||
init.cron ?? "",
|
||||
() => {}
|
||||
);
|
||||
return super.scheduled(controller);
|
||||
}
|
||||
};
|
||||
|
||||
fetch(request: Request<unknown, IncomingRequestCfProperties>) {
|
||||
return __facade_invoke__(
|
||||
request,
|
||||
this.env,
|
||||
this.ctx,
|
||||
this.#dispatcher,
|
||||
this.#fetchDispatcher
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
let WRAPPED_ENTRY: ExportedHandler | WorkerEntrypointConstructor | undefined;
|
||||
if (typeof ENTRY === "object") {
|
||||
WRAPPED_ENTRY = wrapExportedHandler(ENTRY);
|
||||
} else if (typeof ENTRY === "function") {
|
||||
WRAPPED_ENTRY = wrapWorkerEntrypoint(ENTRY);
|
||||
}
|
||||
export default WRAPPED_ENTRY;
|
||||
@@ -1,884 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||
|
||||
// .wrangler/tmp/bundle-ooiDol/checked-fetch.js
|
||||
var urls = /* @__PURE__ */ new Set();
|
||||
function checkURL(request, init) {
|
||||
const url = request instanceof URL ? request : new URL(
|
||||
(typeof request === "string" ? new Request(request, init) : request).url
|
||||
);
|
||||
if (url.port && url.port !== "443" && url.protocol === "https:") {
|
||||
if (!urls.has(url.toString())) {
|
||||
urls.add(url.toString());
|
||||
console.warn(
|
||||
`WARNING: known issue with \`fetch()\` requests to custom HTTPS ports in published Workers:
|
||||
- ${url.toString()} - the custom port will be ignored when the Worker is published using the \`wrangler deploy\` command.
|
||||
`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
__name(checkURL, "checkURL");
|
||||
globalThis.fetch = new Proxy(globalThis.fetch, {
|
||||
apply(target, thisArg, argArray) {
|
||||
const [request, init] = argArray;
|
||||
checkURL(request, init);
|
||||
return Reflect.apply(target, thisArg, argArray);
|
||||
}
|
||||
});
|
||||
|
||||
// .wrangler/tmp/pages-r4dXCe/functionsWorker-0.9817993910801683.mjs
|
||||
var __defProp2 = Object.defineProperty;
|
||||
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp2(target, "name", { value, configurable: true }), "__name");
|
||||
var urls2 = /* @__PURE__ */ new Set();
|
||||
function checkURL2(request, init) {
|
||||
const url = request instanceof URL ? request : new URL(
|
||||
(typeof request === "string" ? new Request(request, init) : request).url
|
||||
);
|
||||
if (url.port && url.port !== "443" && url.protocol === "https:") {
|
||||
if (!urls2.has(url.toString())) {
|
||||
urls2.add(url.toString());
|
||||
console.warn(
|
||||
`WARNING: known issue with \`fetch()\` requests to custom HTTPS ports in published Workers:
|
||||
- ${url.toString()} - the custom port will be ignored when the Worker is published using the \`wrangler deploy\` command.
|
||||
`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
__name(checkURL2, "checkURL");
|
||||
__name2(checkURL2, "checkURL");
|
||||
globalThis.fetch = new Proxy(globalThis.fetch, {
|
||||
apply(target, thisArg, argArray) {
|
||||
const [request, init] = argArray;
|
||||
checkURL2(request, init);
|
||||
return Reflect.apply(target, thisArg, argArray);
|
||||
}
|
||||
});
|
||||
var CloudflareResponse = /* @__PURE__ */ __name(class extends Response {
|
||||
}, "CloudflareResponse");
|
||||
__name2(CloudflareResponse, "CloudflareResponse");
|
||||
function makePagesFunction(fn) {
|
||||
return async (context) => makeResponse(await fn(context));
|
||||
}
|
||||
__name(makePagesFunction, "makePagesFunction");
|
||||
__name2(makePagesFunction, "makePagesFunction");
|
||||
function makeResponse(body, init = {}) {
|
||||
if (body instanceof Response || body instanceof CloudflareResponse) {
|
||||
return body;
|
||||
} else {
|
||||
return new CloudflareResponse(JSON.stringify(body), {
|
||||
...init,
|
||||
headers: { "Content-Type": "application/json", ...init.headers }
|
||||
});
|
||||
}
|
||||
}
|
||||
__name(makeResponse, "makeResponse");
|
||||
__name2(makeResponse, "makeResponse");
|
||||
var onRequestGet = makePagesFunction(
|
||||
async ({ params, env }) => {
|
||||
return {
|
||||
message: "Hello, World!"
|
||||
};
|
||||
}
|
||||
);
|
||||
var routes = [
|
||||
{
|
||||
routePath: "/api/create",
|
||||
mountPath: "/api",
|
||||
method: "GET",
|
||||
middlewares: [],
|
||||
modules: [onRequestGet]
|
||||
}
|
||||
];
|
||||
function lexer(str) {
|
||||
var tokens = [];
|
||||
var i = 0;
|
||||
while (i < str.length) {
|
||||
var char = str[i];
|
||||
if (char === "*" || char === "+" || char === "?") {
|
||||
tokens.push({ type: "MODIFIER", index: i, value: str[i++] });
|
||||
continue;
|
||||
}
|
||||
if (char === "\\") {
|
||||
tokens.push({ type: "ESCAPED_CHAR", index: i++, value: str[i++] });
|
||||
continue;
|
||||
}
|
||||
if (char === "{") {
|
||||
tokens.push({ type: "OPEN", index: i, value: str[i++] });
|
||||
continue;
|
||||
}
|
||||
if (char === "}") {
|
||||
tokens.push({ type: "CLOSE", index: i, value: str[i++] });
|
||||
continue;
|
||||
}
|
||||
if (char === ":") {
|
||||
var name = "";
|
||||
var j = i + 1;
|
||||
while (j < str.length) {
|
||||
var code = str.charCodeAt(j);
|
||||
if (
|
||||
// `0-9`
|
||||
code >= 48 && code <= 57 || // `A-Z`
|
||||
code >= 65 && code <= 90 || // `a-z`
|
||||
code >= 97 && code <= 122 || // `_`
|
||||
code === 95
|
||||
) {
|
||||
name += str[j++];
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!name)
|
||||
throw new TypeError("Missing parameter name at ".concat(i));
|
||||
tokens.push({ type: "NAME", index: i, value: name });
|
||||
i = j;
|
||||
continue;
|
||||
}
|
||||
if (char === "(") {
|
||||
var count = 1;
|
||||
var pattern = "";
|
||||
var j = i + 1;
|
||||
if (str[j] === "?") {
|
||||
throw new TypeError('Pattern cannot start with "?" at '.concat(j));
|
||||
}
|
||||
while (j < str.length) {
|
||||
if (str[j] === "\\") {
|
||||
pattern += str[j++] + str[j++];
|
||||
continue;
|
||||
}
|
||||
if (str[j] === ")") {
|
||||
count--;
|
||||
if (count === 0) {
|
||||
j++;
|
||||
break;
|
||||
}
|
||||
} else if (str[j] === "(") {
|
||||
count++;
|
||||
if (str[j + 1] !== "?") {
|
||||
throw new TypeError("Capturing groups are not allowed at ".concat(j));
|
||||
}
|
||||
}
|
||||
pattern += str[j++];
|
||||
}
|
||||
if (count)
|
||||
throw new TypeError("Unbalanced pattern at ".concat(i));
|
||||
if (!pattern)
|
||||
throw new TypeError("Missing pattern at ".concat(i));
|
||||
tokens.push({ type: "PATTERN", index: i, value: pattern });
|
||||
i = j;
|
||||
continue;
|
||||
}
|
||||
tokens.push({ type: "CHAR", index: i, value: str[i++] });
|
||||
}
|
||||
tokens.push({ type: "END", index: i, value: "" });
|
||||
return tokens;
|
||||
}
|
||||
__name(lexer, "lexer");
|
||||
__name2(lexer, "lexer");
|
||||
function parse(str, options) {
|
||||
if (options === void 0) {
|
||||
options = {};
|
||||
}
|
||||
var tokens = lexer(str);
|
||||
var _a = options.prefixes, prefixes = _a === void 0 ? "./" : _a, _b = options.delimiter, delimiter = _b === void 0 ? "/#?" : _b;
|
||||
var result = [];
|
||||
var key = 0;
|
||||
var i = 0;
|
||||
var path = "";
|
||||
var tryConsume = /* @__PURE__ */ __name2(function(type) {
|
||||
if (i < tokens.length && tokens[i].type === type)
|
||||
return tokens[i++].value;
|
||||
}, "tryConsume");
|
||||
var mustConsume = /* @__PURE__ */ __name2(function(type) {
|
||||
var value2 = tryConsume(type);
|
||||
if (value2 !== void 0)
|
||||
return value2;
|
||||
var _a2 = tokens[i], nextType = _a2.type, index = _a2.index;
|
||||
throw new TypeError("Unexpected ".concat(nextType, " at ").concat(index, ", expected ").concat(type));
|
||||
}, "mustConsume");
|
||||
var consumeText = /* @__PURE__ */ __name2(function() {
|
||||
var result2 = "";
|
||||
var value2;
|
||||
while (value2 = tryConsume("CHAR") || tryConsume("ESCAPED_CHAR")) {
|
||||
result2 += value2;
|
||||
}
|
||||
return result2;
|
||||
}, "consumeText");
|
||||
var isSafe = /* @__PURE__ */ __name2(function(value2) {
|
||||
for (var _i = 0, delimiter_1 = delimiter; _i < delimiter_1.length; _i++) {
|
||||
var char2 = delimiter_1[_i];
|
||||
if (value2.indexOf(char2) > -1)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}, "isSafe");
|
||||
var safePattern = /* @__PURE__ */ __name2(function(prefix2) {
|
||||
var prev = result[result.length - 1];
|
||||
var prevText = prefix2 || (prev && typeof prev === "string" ? prev : "");
|
||||
if (prev && !prevText) {
|
||||
throw new TypeError('Must have text between two parameters, missing text after "'.concat(prev.name, '"'));
|
||||
}
|
||||
if (!prevText || isSafe(prevText))
|
||||
return "[^".concat(escapeString(delimiter), "]+?");
|
||||
return "(?:(?!".concat(escapeString(prevText), ")[^").concat(escapeString(delimiter), "])+?");
|
||||
}, "safePattern");
|
||||
while (i < tokens.length) {
|
||||
var char = tryConsume("CHAR");
|
||||
var name = tryConsume("NAME");
|
||||
var pattern = tryConsume("PATTERN");
|
||||
if (name || pattern) {
|
||||
var prefix = char || "";
|
||||
if (prefixes.indexOf(prefix) === -1) {
|
||||
path += prefix;
|
||||
prefix = "";
|
||||
}
|
||||
if (path) {
|
||||
result.push(path);
|
||||
path = "";
|
||||
}
|
||||
result.push({
|
||||
name: name || key++,
|
||||
prefix,
|
||||
suffix: "",
|
||||
pattern: pattern || safePattern(prefix),
|
||||
modifier: tryConsume("MODIFIER") || ""
|
||||
});
|
||||
continue;
|
||||
}
|
||||
var value = char || tryConsume("ESCAPED_CHAR");
|
||||
if (value) {
|
||||
path += value;
|
||||
continue;
|
||||
}
|
||||
if (path) {
|
||||
result.push(path);
|
||||
path = "";
|
||||
}
|
||||
var open = tryConsume("OPEN");
|
||||
if (open) {
|
||||
var prefix = consumeText();
|
||||
var name_1 = tryConsume("NAME") || "";
|
||||
var pattern_1 = tryConsume("PATTERN") || "";
|
||||
var suffix = consumeText();
|
||||
mustConsume("CLOSE");
|
||||
result.push({
|
||||
name: name_1 || (pattern_1 ? key++ : ""),
|
||||
pattern: name_1 && !pattern_1 ? safePattern(prefix) : pattern_1,
|
||||
prefix,
|
||||
suffix,
|
||||
modifier: tryConsume("MODIFIER") || ""
|
||||
});
|
||||
continue;
|
||||
}
|
||||
mustConsume("END");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
__name(parse, "parse");
|
||||
__name2(parse, "parse");
|
||||
function match(str, options) {
|
||||
var keys = [];
|
||||
var re = pathToRegexp(str, keys, options);
|
||||
return regexpToFunction(re, keys, options);
|
||||
}
|
||||
__name(match, "match");
|
||||
__name2(match, "match");
|
||||
function regexpToFunction(re, keys, options) {
|
||||
if (options === void 0) {
|
||||
options = {};
|
||||
}
|
||||
var _a = options.decode, decode = _a === void 0 ? function(x) {
|
||||
return x;
|
||||
} : _a;
|
||||
return function(pathname) {
|
||||
var m = re.exec(pathname);
|
||||
if (!m)
|
||||
return false;
|
||||
var path = m[0], index = m.index;
|
||||
var params = /* @__PURE__ */ Object.create(null);
|
||||
var _loop_1 = /* @__PURE__ */ __name2(function(i2) {
|
||||
if (m[i2] === void 0)
|
||||
return "continue";
|
||||
var key = keys[i2 - 1];
|
||||
if (key.modifier === "*" || key.modifier === "+") {
|
||||
params[key.name] = m[i2].split(key.prefix + key.suffix).map(function(value) {
|
||||
return decode(value, key);
|
||||
});
|
||||
} else {
|
||||
params[key.name] = decode(m[i2], key);
|
||||
}
|
||||
}, "_loop_1");
|
||||
for (var i = 1; i < m.length; i++) {
|
||||
_loop_1(i);
|
||||
}
|
||||
return { path, index, params };
|
||||
};
|
||||
}
|
||||
__name(regexpToFunction, "regexpToFunction");
|
||||
__name2(regexpToFunction, "regexpToFunction");
|
||||
function escapeString(str) {
|
||||
return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
|
||||
}
|
||||
__name(escapeString, "escapeString");
|
||||
__name2(escapeString, "escapeString");
|
||||
function flags(options) {
|
||||
return options && options.sensitive ? "" : "i";
|
||||
}
|
||||
__name(flags, "flags");
|
||||
__name2(flags, "flags");
|
||||
function regexpToRegexp(path, keys) {
|
||||
if (!keys)
|
||||
return path;
|
||||
var groupsRegex = /\((?:\?<(.*?)>)?(?!\?)/g;
|
||||
var index = 0;
|
||||
var execResult = groupsRegex.exec(path.source);
|
||||
while (execResult) {
|
||||
keys.push({
|
||||
// Use parenthesized substring match if available, index otherwise
|
||||
name: execResult[1] || index++,
|
||||
prefix: "",
|
||||
suffix: "",
|
||||
modifier: "",
|
||||
pattern: ""
|
||||
});
|
||||
execResult = groupsRegex.exec(path.source);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
__name(regexpToRegexp, "regexpToRegexp");
|
||||
__name2(regexpToRegexp, "regexpToRegexp");
|
||||
function arrayToRegexp(paths, keys, options) {
|
||||
var parts = paths.map(function(path) {
|
||||
return pathToRegexp(path, keys, options).source;
|
||||
});
|
||||
return new RegExp("(?:".concat(parts.join("|"), ")"), flags(options));
|
||||
}
|
||||
__name(arrayToRegexp, "arrayToRegexp");
|
||||
__name2(arrayToRegexp, "arrayToRegexp");
|
||||
function stringToRegexp(path, keys, options) {
|
||||
return tokensToRegexp(parse(path, options), keys, options);
|
||||
}
|
||||
__name(stringToRegexp, "stringToRegexp");
|
||||
__name2(stringToRegexp, "stringToRegexp");
|
||||
function tokensToRegexp(tokens, keys, options) {
|
||||
if (options === void 0) {
|
||||
options = {};
|
||||
}
|
||||
var _a = options.strict, strict = _a === void 0 ? false : _a, _b = options.start, start = _b === void 0 ? true : _b, _c = options.end, end = _c === void 0 ? true : _c, _d = options.encode, encode = _d === void 0 ? function(x) {
|
||||
return x;
|
||||
} : _d, _e = options.delimiter, delimiter = _e === void 0 ? "/#?" : _e, _f = options.endsWith, endsWith = _f === void 0 ? "" : _f;
|
||||
var endsWithRe = "[".concat(escapeString(endsWith), "]|$");
|
||||
var delimiterRe = "[".concat(escapeString(delimiter), "]");
|
||||
var route = start ? "^" : "";
|
||||
for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
|
||||
var token = tokens_1[_i];
|
||||
if (typeof token === "string") {
|
||||
route += escapeString(encode(token));
|
||||
} else {
|
||||
var prefix = escapeString(encode(token.prefix));
|
||||
var suffix = escapeString(encode(token.suffix));
|
||||
if (token.pattern) {
|
||||
if (keys)
|
||||
keys.push(token);
|
||||
if (prefix || suffix) {
|
||||
if (token.modifier === "+" || token.modifier === "*") {
|
||||
var mod = token.modifier === "*" ? "?" : "";
|
||||
route += "(?:".concat(prefix, "((?:").concat(token.pattern, ")(?:").concat(suffix).concat(prefix, "(?:").concat(token.pattern, "))*)").concat(suffix, ")").concat(mod);
|
||||
} else {
|
||||
route += "(?:".concat(prefix, "(").concat(token.pattern, ")").concat(suffix, ")").concat(token.modifier);
|
||||
}
|
||||
} else {
|
||||
if (token.modifier === "+" || token.modifier === "*") {
|
||||
throw new TypeError('Can not repeat "'.concat(token.name, '" without a prefix and suffix'));
|
||||
}
|
||||
route += "(".concat(token.pattern, ")").concat(token.modifier);
|
||||
}
|
||||
} else {
|
||||
route += "(?:".concat(prefix).concat(suffix, ")").concat(token.modifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (end) {
|
||||
if (!strict)
|
||||
route += "".concat(delimiterRe, "?");
|
||||
route += !options.endsWith ? "$" : "(?=".concat(endsWithRe, ")");
|
||||
} else {
|
||||
var endToken = tokens[tokens.length - 1];
|
||||
var isEndDelimited = typeof endToken === "string" ? delimiterRe.indexOf(endToken[endToken.length - 1]) > -1 : endToken === void 0;
|
||||
if (!strict) {
|
||||
route += "(?:".concat(delimiterRe, "(?=").concat(endsWithRe, "))?");
|
||||
}
|
||||
if (!isEndDelimited) {
|
||||
route += "(?=".concat(delimiterRe, "|").concat(endsWithRe, ")");
|
||||
}
|
||||
}
|
||||
return new RegExp(route, flags(options));
|
||||
}
|
||||
__name(tokensToRegexp, "tokensToRegexp");
|
||||
__name2(tokensToRegexp, "tokensToRegexp");
|
||||
function pathToRegexp(path, keys, options) {
|
||||
if (path instanceof RegExp)
|
||||
return regexpToRegexp(path, keys);
|
||||
if (Array.isArray(path))
|
||||
return arrayToRegexp(path, keys, options);
|
||||
return stringToRegexp(path, keys, options);
|
||||
}
|
||||
__name(pathToRegexp, "pathToRegexp");
|
||||
__name2(pathToRegexp, "pathToRegexp");
|
||||
var escapeRegex = /[.+?^${}()|[\]\\]/g;
|
||||
function* executeRequest(request) {
|
||||
const requestPath = new URL(request.url).pathname;
|
||||
for (const route of [...routes].reverse()) {
|
||||
if (route.method && route.method !== request.method) {
|
||||
continue;
|
||||
}
|
||||
const routeMatcher = match(route.routePath.replace(escapeRegex, "\\$&"), {
|
||||
end: false
|
||||
});
|
||||
const mountMatcher = match(route.mountPath.replace(escapeRegex, "\\$&"), {
|
||||
end: false
|
||||
});
|
||||
const matchResult = routeMatcher(requestPath);
|
||||
const mountMatchResult = mountMatcher(requestPath);
|
||||
if (matchResult && mountMatchResult) {
|
||||
for (const handler of route.middlewares.flat()) {
|
||||
yield {
|
||||
handler,
|
||||
params: matchResult.params,
|
||||
path: mountMatchResult.path
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const route of routes) {
|
||||
if (route.method && route.method !== request.method) {
|
||||
continue;
|
||||
}
|
||||
const routeMatcher = match(route.routePath.replace(escapeRegex, "\\$&"), {
|
||||
end: true
|
||||
});
|
||||
const mountMatcher = match(route.mountPath.replace(escapeRegex, "\\$&"), {
|
||||
end: false
|
||||
});
|
||||
const matchResult = routeMatcher(requestPath);
|
||||
const mountMatchResult = mountMatcher(requestPath);
|
||||
if (matchResult && mountMatchResult && route.modules.length) {
|
||||
for (const handler of route.modules.flat()) {
|
||||
yield {
|
||||
handler,
|
||||
params: matchResult.params,
|
||||
path: matchResult.path
|
||||
};
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
__name(executeRequest, "executeRequest");
|
||||
__name2(executeRequest, "executeRequest");
|
||||
var pages_template_worker_default = {
|
||||
async fetch(originalRequest, env, workerContext) {
|
||||
let request = originalRequest;
|
||||
const handlerIterator = executeRequest(request);
|
||||
let data = {};
|
||||
let isFailOpen = false;
|
||||
const next = /* @__PURE__ */ __name2(async (input, init) => {
|
||||
if (input !== void 0) {
|
||||
let url = input;
|
||||
if (typeof input === "string") {
|
||||
url = new URL(input, request.url).toString();
|
||||
}
|
||||
request = new Request(url, init);
|
||||
}
|
||||
const result = handlerIterator.next();
|
||||
if (result.done === false) {
|
||||
const { handler, params, path } = result.value;
|
||||
const context = {
|
||||
request: new Request(request.clone()),
|
||||
functionPath: path,
|
||||
next,
|
||||
params,
|
||||
get data() {
|
||||
return data;
|
||||
},
|
||||
set data(value) {
|
||||
if (typeof value !== "object" || value === null) {
|
||||
throw new Error("context.data must be an object");
|
||||
}
|
||||
data = value;
|
||||
},
|
||||
env,
|
||||
waitUntil: workerContext.waitUntil.bind(workerContext),
|
||||
passThroughOnException: () => {
|
||||
isFailOpen = true;
|
||||
}
|
||||
};
|
||||
const response = await handler(context);
|
||||
if (!(response instanceof Response)) {
|
||||
throw new Error("Your Pages function should return a Response");
|
||||
}
|
||||
return cloneResponse(response);
|
||||
} else if ("ASSETS") {
|
||||
const response = await env["ASSETS"].fetch(request);
|
||||
return cloneResponse(response);
|
||||
} else {
|
||||
const response = await fetch(request);
|
||||
return cloneResponse(response);
|
||||
}
|
||||
}, "next");
|
||||
try {
|
||||
return await next();
|
||||
} catch (error) {
|
||||
if (isFailOpen) {
|
||||
const response = await env["ASSETS"].fetch(request);
|
||||
return cloneResponse(response);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
};
|
||||
var cloneResponse = /* @__PURE__ */ __name2((response) => (
|
||||
// https://fetch.spec.whatwg.org/#null-body-status
|
||||
new Response(
|
||||
[101, 204, 205, 304].includes(response.status) ? null : response.body,
|
||||
response
|
||||
)
|
||||
), "cloneResponse");
|
||||
var drainBody = /* @__PURE__ */ __name2(async (request, env, _ctx, middlewareCtx) => {
|
||||
try {
|
||||
return await middlewareCtx.next(request, env);
|
||||
} finally {
|
||||
try {
|
||||
if (request.body !== null && !request.bodyUsed) {
|
||||
const reader = request.body.getReader();
|
||||
while (!(await reader.read()).done) {
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to drain the unused request body.", e);
|
||||
}
|
||||
}
|
||||
}, "drainBody");
|
||||
var middleware_ensure_req_body_drained_default = drainBody;
|
||||
function reduceError(e) {
|
||||
return {
|
||||
name: e?.name,
|
||||
message: e?.message ?? String(e),
|
||||
stack: e?.stack,
|
||||
cause: e?.cause === void 0 ? void 0 : reduceError(e.cause)
|
||||
};
|
||||
}
|
||||
__name(reduceError, "reduceError");
|
||||
__name2(reduceError, "reduceError");
|
||||
var jsonError = /* @__PURE__ */ __name2(async (request, env, _ctx, middlewareCtx) => {
|
||||
try {
|
||||
return await middlewareCtx.next(request, env);
|
||||
} catch (e) {
|
||||
const error = reduceError(e);
|
||||
return Response.json(error, {
|
||||
status: 500,
|
||||
headers: { "MF-Experimental-Error-Stack": "true" }
|
||||
});
|
||||
}
|
||||
}, "jsonError");
|
||||
var middleware_miniflare3_json_error_default = jsonError;
|
||||
var __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||
middleware_ensure_req_body_drained_default,
|
||||
middleware_miniflare3_json_error_default
|
||||
];
|
||||
var middleware_insertion_facade_default = pages_template_worker_default;
|
||||
var __facade_middleware__ = [];
|
||||
function __facade_register__(...args) {
|
||||
__facade_middleware__.push(...args.flat());
|
||||
}
|
||||
__name(__facade_register__, "__facade_register__");
|
||||
__name2(__facade_register__, "__facade_register__");
|
||||
function __facade_invokeChain__(request, env, ctx, dispatch, middlewareChain) {
|
||||
const [head, ...tail] = middlewareChain;
|
||||
const middlewareCtx = {
|
||||
dispatch,
|
||||
next(newRequest, newEnv) {
|
||||
return __facade_invokeChain__(newRequest, newEnv, ctx, dispatch, tail);
|
||||
}
|
||||
};
|
||||
return head(request, env, ctx, middlewareCtx);
|
||||
}
|
||||
__name(__facade_invokeChain__, "__facade_invokeChain__");
|
||||
__name2(__facade_invokeChain__, "__facade_invokeChain__");
|
||||
function __facade_invoke__(request, env, ctx, dispatch, finalMiddleware) {
|
||||
return __facade_invokeChain__(request, env, ctx, dispatch, [
|
||||
...__facade_middleware__,
|
||||
finalMiddleware
|
||||
]);
|
||||
}
|
||||
__name(__facade_invoke__, "__facade_invoke__");
|
||||
__name2(__facade_invoke__, "__facade_invoke__");
|
||||
var __Facade_ScheduledController__ = /* @__PURE__ */ __name(class {
|
||||
constructor(scheduledTime, cron, noRetry) {
|
||||
this.scheduledTime = scheduledTime;
|
||||
this.cron = cron;
|
||||
this.#noRetry = noRetry;
|
||||
}
|
||||
#noRetry;
|
||||
noRetry() {
|
||||
if (!(this instanceof __Facade_ScheduledController__)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
this.#noRetry();
|
||||
}
|
||||
}, "__Facade_ScheduledController__");
|
||||
__name2(__Facade_ScheduledController__, "__Facade_ScheduledController__");
|
||||
function wrapExportedHandler(worker) {
|
||||
if (__INTERNAL_WRANGLER_MIDDLEWARE__ === void 0 || __INTERNAL_WRANGLER_MIDDLEWARE__.length === 0) {
|
||||
return worker;
|
||||
}
|
||||
for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) {
|
||||
__facade_register__(middleware);
|
||||
}
|
||||
const fetchDispatcher = /* @__PURE__ */ __name2(function(request, env, ctx) {
|
||||
if (worker.fetch === void 0) {
|
||||
throw new Error("Handler does not export a fetch() function.");
|
||||
}
|
||||
return worker.fetch(request, env, ctx);
|
||||
}, "fetchDispatcher");
|
||||
return {
|
||||
...worker,
|
||||
fetch(request, env, ctx) {
|
||||
const dispatcher = /* @__PURE__ */ __name2(function(type, init) {
|
||||
if (type === "scheduled" && worker.scheduled !== void 0) {
|
||||
const controller = new __Facade_ScheduledController__(
|
||||
Date.now(),
|
||||
init.cron ?? "",
|
||||
() => {
|
||||
}
|
||||
);
|
||||
return worker.scheduled(controller, env, ctx);
|
||||
}
|
||||
}, "dispatcher");
|
||||
return __facade_invoke__(request, env, ctx, dispatcher, fetchDispatcher);
|
||||
}
|
||||
};
|
||||
}
|
||||
__name(wrapExportedHandler, "wrapExportedHandler");
|
||||
__name2(wrapExportedHandler, "wrapExportedHandler");
|
||||
function wrapWorkerEntrypoint(klass) {
|
||||
if (__INTERNAL_WRANGLER_MIDDLEWARE__ === void 0 || __INTERNAL_WRANGLER_MIDDLEWARE__.length === 0) {
|
||||
return klass;
|
||||
}
|
||||
for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) {
|
||||
__facade_register__(middleware);
|
||||
}
|
||||
return class extends klass {
|
||||
#fetchDispatcher = (request, env, ctx) => {
|
||||
this.env = env;
|
||||
this.ctx = ctx;
|
||||
if (super.fetch === void 0) {
|
||||
throw new Error("Entrypoint class does not define a fetch() function.");
|
||||
}
|
||||
return super.fetch(request);
|
||||
};
|
||||
#dispatcher = (type, init) => {
|
||||
if (type === "scheduled" && super.scheduled !== void 0) {
|
||||
const controller = new __Facade_ScheduledController__(
|
||||
Date.now(),
|
||||
init.cron ?? "",
|
||||
() => {
|
||||
}
|
||||
);
|
||||
return super.scheduled(controller);
|
||||
}
|
||||
};
|
||||
fetch(request) {
|
||||
return __facade_invoke__(
|
||||
request,
|
||||
this.env,
|
||||
this.ctx,
|
||||
this.#dispatcher,
|
||||
this.#fetchDispatcher
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
__name(wrapWorkerEntrypoint, "wrapWorkerEntrypoint");
|
||||
__name2(wrapWorkerEntrypoint, "wrapWorkerEntrypoint");
|
||||
var WRAPPED_ENTRY;
|
||||
if (typeof middleware_insertion_facade_default === "object") {
|
||||
WRAPPED_ENTRY = wrapExportedHandler(middleware_insertion_facade_default);
|
||||
} else if (typeof middleware_insertion_facade_default === "function") {
|
||||
WRAPPED_ENTRY = wrapWorkerEntrypoint(middleware_insertion_facade_default);
|
||||
}
|
||||
var middleware_loader_entry_default = WRAPPED_ENTRY;
|
||||
|
||||
// node_modules/.pnpm/wrangler@3.85.0/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts
|
||||
var drainBody2 = /* @__PURE__ */ __name(async (request, env, _ctx, middlewareCtx) => {
|
||||
try {
|
||||
return await middlewareCtx.next(request, env);
|
||||
} finally {
|
||||
try {
|
||||
if (request.body !== null && !request.bodyUsed) {
|
||||
const reader = request.body.getReader();
|
||||
while (!(await reader.read()).done) {
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to drain the unused request body.", e);
|
||||
}
|
||||
}
|
||||
}, "drainBody");
|
||||
var middleware_ensure_req_body_drained_default2 = drainBody2;
|
||||
|
||||
// node_modules/.pnpm/wrangler@3.85.0/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts
|
||||
function reduceError2(e) {
|
||||
return {
|
||||
name: e?.name,
|
||||
message: e?.message ?? String(e),
|
||||
stack: e?.stack,
|
||||
cause: e?.cause === void 0 ? void 0 : reduceError2(e.cause)
|
||||
};
|
||||
}
|
||||
__name(reduceError2, "reduceError");
|
||||
var jsonError2 = /* @__PURE__ */ __name(async (request, env, _ctx, middlewareCtx) => {
|
||||
try {
|
||||
return await middlewareCtx.next(request, env);
|
||||
} catch (e) {
|
||||
const error = reduceError2(e);
|
||||
return Response.json(error, {
|
||||
status: 500,
|
||||
headers: { "MF-Experimental-Error-Stack": "true" }
|
||||
});
|
||||
}
|
||||
}, "jsonError");
|
||||
var middleware_miniflare3_json_error_default2 = jsonError2;
|
||||
|
||||
// .wrangler/tmp/bundle-ooiDol/middleware-insertion-facade.js
|
||||
var __INTERNAL_WRANGLER_MIDDLEWARE__2 = [
|
||||
middleware_ensure_req_body_drained_default2,
|
||||
middleware_miniflare3_json_error_default2
|
||||
];
|
||||
var middleware_insertion_facade_default2 = middleware_loader_entry_default;
|
||||
|
||||
// node_modules/.pnpm/wrangler@3.85.0/node_modules/wrangler/templates/middleware/common.ts
|
||||
var __facade_middleware__2 = [];
|
||||
function __facade_register__2(...args) {
|
||||
__facade_middleware__2.push(...args.flat());
|
||||
}
|
||||
__name(__facade_register__2, "__facade_register__");
|
||||
function __facade_invokeChain__2(request, env, ctx, dispatch, middlewareChain) {
|
||||
const [head, ...tail] = middlewareChain;
|
||||
const middlewareCtx = {
|
||||
dispatch,
|
||||
next(newRequest, newEnv) {
|
||||
return __facade_invokeChain__2(newRequest, newEnv, ctx, dispatch, tail);
|
||||
}
|
||||
};
|
||||
return head(request, env, ctx, middlewareCtx);
|
||||
}
|
||||
__name(__facade_invokeChain__2, "__facade_invokeChain__");
|
||||
function __facade_invoke__2(request, env, ctx, dispatch, finalMiddleware) {
|
||||
return __facade_invokeChain__2(request, env, ctx, dispatch, [
|
||||
...__facade_middleware__2,
|
||||
finalMiddleware
|
||||
]);
|
||||
}
|
||||
__name(__facade_invoke__2, "__facade_invoke__");
|
||||
|
||||
// .wrangler/tmp/bundle-ooiDol/middleware-loader.entry.ts
|
||||
var __Facade_ScheduledController__2 = class {
|
||||
constructor(scheduledTime, cron, noRetry) {
|
||||
this.scheduledTime = scheduledTime;
|
||||
this.cron = cron;
|
||||
this.#noRetry = noRetry;
|
||||
}
|
||||
#noRetry;
|
||||
noRetry() {
|
||||
if (!(this instanceof __Facade_ScheduledController__2)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
this.#noRetry();
|
||||
}
|
||||
};
|
||||
__name(__Facade_ScheduledController__2, "__Facade_ScheduledController__");
|
||||
function wrapExportedHandler2(worker) {
|
||||
if (__INTERNAL_WRANGLER_MIDDLEWARE__2 === void 0 || __INTERNAL_WRANGLER_MIDDLEWARE__2.length === 0) {
|
||||
return worker;
|
||||
}
|
||||
for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__2) {
|
||||
__facade_register__2(middleware);
|
||||
}
|
||||
const fetchDispatcher = /* @__PURE__ */ __name(function(request, env, ctx) {
|
||||
if (worker.fetch === void 0) {
|
||||
throw new Error("Handler does not export a fetch() function.");
|
||||
}
|
||||
return worker.fetch(request, env, ctx);
|
||||
}, "fetchDispatcher");
|
||||
return {
|
||||
...worker,
|
||||
fetch(request, env, ctx) {
|
||||
const dispatcher = /* @__PURE__ */ __name(function(type, init) {
|
||||
if (type === "scheduled" && worker.scheduled !== void 0) {
|
||||
const controller = new __Facade_ScheduledController__2(
|
||||
Date.now(),
|
||||
init.cron ?? "",
|
||||
() => {
|
||||
}
|
||||
);
|
||||
return worker.scheduled(controller, env, ctx);
|
||||
}
|
||||
}, "dispatcher");
|
||||
return __facade_invoke__2(request, env, ctx, dispatcher, fetchDispatcher);
|
||||
}
|
||||
};
|
||||
}
|
||||
__name(wrapExportedHandler2, "wrapExportedHandler");
|
||||
function wrapWorkerEntrypoint2(klass) {
|
||||
if (__INTERNAL_WRANGLER_MIDDLEWARE__2 === void 0 || __INTERNAL_WRANGLER_MIDDLEWARE__2.length === 0) {
|
||||
return klass;
|
||||
}
|
||||
for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__2) {
|
||||
__facade_register__2(middleware);
|
||||
}
|
||||
return class extends klass {
|
||||
#fetchDispatcher = (request, env, ctx) => {
|
||||
this.env = env;
|
||||
this.ctx = ctx;
|
||||
if (super.fetch === void 0) {
|
||||
throw new Error("Entrypoint class does not define a fetch() function.");
|
||||
}
|
||||
return super.fetch(request);
|
||||
};
|
||||
#dispatcher = (type, init) => {
|
||||
if (type === "scheduled" && super.scheduled !== void 0) {
|
||||
const controller = new __Facade_ScheduledController__2(
|
||||
Date.now(),
|
||||
init.cron ?? "",
|
||||
() => {
|
||||
}
|
||||
);
|
||||
return super.scheduled(controller);
|
||||
}
|
||||
};
|
||||
fetch(request) {
|
||||
return __facade_invoke__2(
|
||||
request,
|
||||
this.env,
|
||||
this.ctx,
|
||||
this.#dispatcher,
|
||||
this.#fetchDispatcher
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
__name(wrapWorkerEntrypoint2, "wrapWorkerEntrypoint");
|
||||
var WRAPPED_ENTRY2;
|
||||
if (typeof middleware_insertion_facade_default2 === "object") {
|
||||
WRAPPED_ENTRY2 = wrapExportedHandler2(middleware_insertion_facade_default2);
|
||||
} else if (typeof middleware_insertion_facade_default2 === "function") {
|
||||
WRAPPED_ENTRY2 = wrapWorkerEntrypoint2(middleware_insertion_facade_default2);
|
||||
}
|
||||
var middleware_loader_entry_default2 = WRAPPED_ENTRY2;
|
||||
export {
|
||||
__INTERNAL_WRANGLER_MIDDLEWARE__2 as __INTERNAL_WRANGLER_MIDDLEWARE__,
|
||||
middleware_loader_entry_default2 as default
|
||||
};
|
||||
//# sourceMappingURL=functionsWorker-0.9817993910801683.js.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1,11 +0,0 @@
|
||||
import { onRequestGet as __api_create_ts_onRequestGet } from "/Users/chuan_yu/Desktop/work/satlayer-hackathon/functions/api/create.ts"
|
||||
|
||||
export const routes = [
|
||||
{
|
||||
routePath: "/api/create",
|
||||
mountPath: "/api",
|
||||
method: "GET",
|
||||
middlewares: [],
|
||||
modules: [__api_create_ts_onRequestGet],
|
||||
},
|
||||
]
|
||||
@@ -1,687 +0,0 @@
|
||||
var __defProp = Object.defineProperty;
|
||||
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||
|
||||
// ../.wrangler/tmp/bundle-EUTT79/checked-fetch.js
|
||||
var urls = /* @__PURE__ */ new Set();
|
||||
function checkURL(request, init) {
|
||||
const url = request instanceof URL ? request : new URL(
|
||||
(typeof request === "string" ? new Request(request, init) : request).url
|
||||
);
|
||||
if (url.port && url.port !== "443" && url.protocol === "https:") {
|
||||
if (!urls.has(url.toString())) {
|
||||
urls.add(url.toString());
|
||||
console.warn(
|
||||
`WARNING: known issue with \`fetch()\` requests to custom HTTPS ports in published Workers:
|
||||
- ${url.toString()} - the custom port will be ignored when the Worker is published using the \`wrangler deploy\` command.
|
||||
`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
__name(checkURL, "checkURL");
|
||||
globalThis.fetch = new Proxy(globalThis.fetch, {
|
||||
apply(target, thisArg, argArray) {
|
||||
const [request, init] = argArray;
|
||||
checkURL(request, init);
|
||||
return Reflect.apply(target, thisArg, argArray);
|
||||
}
|
||||
});
|
||||
|
||||
// ../node_modules/.pnpm/vite-plugin-cloudflare-functions@0.8.0_axios@0.27.2_vite@5.4.10_wrangler@3.85.0/node_modules/vite-plugin-cloudflare-functions/dist/worker.mjs
|
||||
var CloudflareResponse = class extends Response {
|
||||
};
|
||||
__name(CloudflareResponse, "CloudflareResponse");
|
||||
function makePagesFunction(fn) {
|
||||
return async (context) => makeResponse(await fn(context));
|
||||
}
|
||||
__name(makePagesFunction, "makePagesFunction");
|
||||
function makeResponse(body, init = {}) {
|
||||
if (body instanceof Response || body instanceof CloudflareResponse) {
|
||||
return body;
|
||||
} else {
|
||||
return new CloudflareResponse(JSON.stringify(body), {
|
||||
...init,
|
||||
headers: { "Content-Type": "application/json", ...init.headers }
|
||||
});
|
||||
}
|
||||
}
|
||||
__name(makeResponse, "makeResponse");
|
||||
|
||||
// api/create.ts
|
||||
var onRequestGet = makePagesFunction(
|
||||
async ({ params, env }) => {
|
||||
return {
|
||||
message: "Hello, World!"
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
// ../.wrangler/tmp/pages-r4dXCe/functionsRoutes-0.6627960299070452.mjs
|
||||
var routes = [
|
||||
{
|
||||
routePath: "/api/create",
|
||||
mountPath: "/api",
|
||||
method: "GET",
|
||||
middlewares: [],
|
||||
modules: [onRequestGet]
|
||||
}
|
||||
];
|
||||
|
||||
// ../node_modules/.pnpm/path-to-regexp@6.3.0/node_modules/path-to-regexp/dist.es2015/index.js
|
||||
function lexer(str) {
|
||||
var tokens = [];
|
||||
var i = 0;
|
||||
while (i < str.length) {
|
||||
var char = str[i];
|
||||
if (char === "*" || char === "+" || char === "?") {
|
||||
tokens.push({ type: "MODIFIER", index: i, value: str[i++] });
|
||||
continue;
|
||||
}
|
||||
if (char === "\\") {
|
||||
tokens.push({ type: "ESCAPED_CHAR", index: i++, value: str[i++] });
|
||||
continue;
|
||||
}
|
||||
if (char === "{") {
|
||||
tokens.push({ type: "OPEN", index: i, value: str[i++] });
|
||||
continue;
|
||||
}
|
||||
if (char === "}") {
|
||||
tokens.push({ type: "CLOSE", index: i, value: str[i++] });
|
||||
continue;
|
||||
}
|
||||
if (char === ":") {
|
||||
var name = "";
|
||||
var j = i + 1;
|
||||
while (j < str.length) {
|
||||
var code = str.charCodeAt(j);
|
||||
if (
|
||||
// `0-9`
|
||||
code >= 48 && code <= 57 || // `A-Z`
|
||||
code >= 65 && code <= 90 || // `a-z`
|
||||
code >= 97 && code <= 122 || // `_`
|
||||
code === 95
|
||||
) {
|
||||
name += str[j++];
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!name)
|
||||
throw new TypeError("Missing parameter name at ".concat(i));
|
||||
tokens.push({ type: "NAME", index: i, value: name });
|
||||
i = j;
|
||||
continue;
|
||||
}
|
||||
if (char === "(") {
|
||||
var count = 1;
|
||||
var pattern = "";
|
||||
var j = i + 1;
|
||||
if (str[j] === "?") {
|
||||
throw new TypeError('Pattern cannot start with "?" at '.concat(j));
|
||||
}
|
||||
while (j < str.length) {
|
||||
if (str[j] === "\\") {
|
||||
pattern += str[j++] + str[j++];
|
||||
continue;
|
||||
}
|
||||
if (str[j] === ")") {
|
||||
count--;
|
||||
if (count === 0) {
|
||||
j++;
|
||||
break;
|
||||
}
|
||||
} else if (str[j] === "(") {
|
||||
count++;
|
||||
if (str[j + 1] !== "?") {
|
||||
throw new TypeError("Capturing groups are not allowed at ".concat(j));
|
||||
}
|
||||
}
|
||||
pattern += str[j++];
|
||||
}
|
||||
if (count)
|
||||
throw new TypeError("Unbalanced pattern at ".concat(i));
|
||||
if (!pattern)
|
||||
throw new TypeError("Missing pattern at ".concat(i));
|
||||
tokens.push({ type: "PATTERN", index: i, value: pattern });
|
||||
i = j;
|
||||
continue;
|
||||
}
|
||||
tokens.push({ type: "CHAR", index: i, value: str[i++] });
|
||||
}
|
||||
tokens.push({ type: "END", index: i, value: "" });
|
||||
return tokens;
|
||||
}
|
||||
__name(lexer, "lexer");
|
||||
function parse(str, options) {
|
||||
if (options === void 0) {
|
||||
options = {};
|
||||
}
|
||||
var tokens = lexer(str);
|
||||
var _a = options.prefixes, prefixes = _a === void 0 ? "./" : _a, _b = options.delimiter, delimiter = _b === void 0 ? "/#?" : _b;
|
||||
var result = [];
|
||||
var key = 0;
|
||||
var i = 0;
|
||||
var path = "";
|
||||
var tryConsume = /* @__PURE__ */ __name(function(type) {
|
||||
if (i < tokens.length && tokens[i].type === type)
|
||||
return tokens[i++].value;
|
||||
}, "tryConsume");
|
||||
var mustConsume = /* @__PURE__ */ __name(function(type) {
|
||||
var value2 = tryConsume(type);
|
||||
if (value2 !== void 0)
|
||||
return value2;
|
||||
var _a2 = tokens[i], nextType = _a2.type, index = _a2.index;
|
||||
throw new TypeError("Unexpected ".concat(nextType, " at ").concat(index, ", expected ").concat(type));
|
||||
}, "mustConsume");
|
||||
var consumeText = /* @__PURE__ */ __name(function() {
|
||||
var result2 = "";
|
||||
var value2;
|
||||
while (value2 = tryConsume("CHAR") || tryConsume("ESCAPED_CHAR")) {
|
||||
result2 += value2;
|
||||
}
|
||||
return result2;
|
||||
}, "consumeText");
|
||||
var isSafe = /* @__PURE__ */ __name(function(value2) {
|
||||
for (var _i = 0, delimiter_1 = delimiter; _i < delimiter_1.length; _i++) {
|
||||
var char2 = delimiter_1[_i];
|
||||
if (value2.indexOf(char2) > -1)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}, "isSafe");
|
||||
var safePattern = /* @__PURE__ */ __name(function(prefix2) {
|
||||
var prev = result[result.length - 1];
|
||||
var prevText = prefix2 || (prev && typeof prev === "string" ? prev : "");
|
||||
if (prev && !prevText) {
|
||||
throw new TypeError('Must have text between two parameters, missing text after "'.concat(prev.name, '"'));
|
||||
}
|
||||
if (!prevText || isSafe(prevText))
|
||||
return "[^".concat(escapeString(delimiter), "]+?");
|
||||
return "(?:(?!".concat(escapeString(prevText), ")[^").concat(escapeString(delimiter), "])+?");
|
||||
}, "safePattern");
|
||||
while (i < tokens.length) {
|
||||
var char = tryConsume("CHAR");
|
||||
var name = tryConsume("NAME");
|
||||
var pattern = tryConsume("PATTERN");
|
||||
if (name || pattern) {
|
||||
var prefix = char || "";
|
||||
if (prefixes.indexOf(prefix) === -1) {
|
||||
path += prefix;
|
||||
prefix = "";
|
||||
}
|
||||
if (path) {
|
||||
result.push(path);
|
||||
path = "";
|
||||
}
|
||||
result.push({
|
||||
name: name || key++,
|
||||
prefix,
|
||||
suffix: "",
|
||||
pattern: pattern || safePattern(prefix),
|
||||
modifier: tryConsume("MODIFIER") || ""
|
||||
});
|
||||
continue;
|
||||
}
|
||||
var value = char || tryConsume("ESCAPED_CHAR");
|
||||
if (value) {
|
||||
path += value;
|
||||
continue;
|
||||
}
|
||||
if (path) {
|
||||
result.push(path);
|
||||
path = "";
|
||||
}
|
||||
var open = tryConsume("OPEN");
|
||||
if (open) {
|
||||
var prefix = consumeText();
|
||||
var name_1 = tryConsume("NAME") || "";
|
||||
var pattern_1 = tryConsume("PATTERN") || "";
|
||||
var suffix = consumeText();
|
||||
mustConsume("CLOSE");
|
||||
result.push({
|
||||
name: name_1 || (pattern_1 ? key++ : ""),
|
||||
pattern: name_1 && !pattern_1 ? safePattern(prefix) : pattern_1,
|
||||
prefix,
|
||||
suffix,
|
||||
modifier: tryConsume("MODIFIER") || ""
|
||||
});
|
||||
continue;
|
||||
}
|
||||
mustConsume("END");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
__name(parse, "parse");
|
||||
function match(str, options) {
|
||||
var keys = [];
|
||||
var re = pathToRegexp(str, keys, options);
|
||||
return regexpToFunction(re, keys, options);
|
||||
}
|
||||
__name(match, "match");
|
||||
function regexpToFunction(re, keys, options) {
|
||||
if (options === void 0) {
|
||||
options = {};
|
||||
}
|
||||
var _a = options.decode, decode = _a === void 0 ? function(x) {
|
||||
return x;
|
||||
} : _a;
|
||||
return function(pathname) {
|
||||
var m = re.exec(pathname);
|
||||
if (!m)
|
||||
return false;
|
||||
var path = m[0], index = m.index;
|
||||
var params = /* @__PURE__ */ Object.create(null);
|
||||
var _loop_1 = /* @__PURE__ */ __name(function(i2) {
|
||||
if (m[i2] === void 0)
|
||||
return "continue";
|
||||
var key = keys[i2 - 1];
|
||||
if (key.modifier === "*" || key.modifier === "+") {
|
||||
params[key.name] = m[i2].split(key.prefix + key.suffix).map(function(value) {
|
||||
return decode(value, key);
|
||||
});
|
||||
} else {
|
||||
params[key.name] = decode(m[i2], key);
|
||||
}
|
||||
}, "_loop_1");
|
||||
for (var i = 1; i < m.length; i++) {
|
||||
_loop_1(i);
|
||||
}
|
||||
return { path, index, params };
|
||||
};
|
||||
}
|
||||
__name(regexpToFunction, "regexpToFunction");
|
||||
function escapeString(str) {
|
||||
return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
|
||||
}
|
||||
__name(escapeString, "escapeString");
|
||||
function flags(options) {
|
||||
return options && options.sensitive ? "" : "i";
|
||||
}
|
||||
__name(flags, "flags");
|
||||
function regexpToRegexp(path, keys) {
|
||||
if (!keys)
|
||||
return path;
|
||||
var groupsRegex = /\((?:\?<(.*?)>)?(?!\?)/g;
|
||||
var index = 0;
|
||||
var execResult = groupsRegex.exec(path.source);
|
||||
while (execResult) {
|
||||
keys.push({
|
||||
// Use parenthesized substring match if available, index otherwise
|
||||
name: execResult[1] || index++,
|
||||
prefix: "",
|
||||
suffix: "",
|
||||
modifier: "",
|
||||
pattern: ""
|
||||
});
|
||||
execResult = groupsRegex.exec(path.source);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
__name(regexpToRegexp, "regexpToRegexp");
|
||||
function arrayToRegexp(paths, keys, options) {
|
||||
var parts = paths.map(function(path) {
|
||||
return pathToRegexp(path, keys, options).source;
|
||||
});
|
||||
return new RegExp("(?:".concat(parts.join("|"), ")"), flags(options));
|
||||
}
|
||||
__name(arrayToRegexp, "arrayToRegexp");
|
||||
function stringToRegexp(path, keys, options) {
|
||||
return tokensToRegexp(parse(path, options), keys, options);
|
||||
}
|
||||
__name(stringToRegexp, "stringToRegexp");
|
||||
function tokensToRegexp(tokens, keys, options) {
|
||||
if (options === void 0) {
|
||||
options = {};
|
||||
}
|
||||
var _a = options.strict, strict = _a === void 0 ? false : _a, _b = options.start, start = _b === void 0 ? true : _b, _c = options.end, end = _c === void 0 ? true : _c, _d = options.encode, encode = _d === void 0 ? function(x) {
|
||||
return x;
|
||||
} : _d, _e = options.delimiter, delimiter = _e === void 0 ? "/#?" : _e, _f = options.endsWith, endsWith = _f === void 0 ? "" : _f;
|
||||
var endsWithRe = "[".concat(escapeString(endsWith), "]|$");
|
||||
var delimiterRe = "[".concat(escapeString(delimiter), "]");
|
||||
var route = start ? "^" : "";
|
||||
for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
|
||||
var token = tokens_1[_i];
|
||||
if (typeof token === "string") {
|
||||
route += escapeString(encode(token));
|
||||
} else {
|
||||
var prefix = escapeString(encode(token.prefix));
|
||||
var suffix = escapeString(encode(token.suffix));
|
||||
if (token.pattern) {
|
||||
if (keys)
|
||||
keys.push(token);
|
||||
if (prefix || suffix) {
|
||||
if (token.modifier === "+" || token.modifier === "*") {
|
||||
var mod = token.modifier === "*" ? "?" : "";
|
||||
route += "(?:".concat(prefix, "((?:").concat(token.pattern, ")(?:").concat(suffix).concat(prefix, "(?:").concat(token.pattern, "))*)").concat(suffix, ")").concat(mod);
|
||||
} else {
|
||||
route += "(?:".concat(prefix, "(").concat(token.pattern, ")").concat(suffix, ")").concat(token.modifier);
|
||||
}
|
||||
} else {
|
||||
if (token.modifier === "+" || token.modifier === "*") {
|
||||
throw new TypeError('Can not repeat "'.concat(token.name, '" without a prefix and suffix'));
|
||||
}
|
||||
route += "(".concat(token.pattern, ")").concat(token.modifier);
|
||||
}
|
||||
} else {
|
||||
route += "(?:".concat(prefix).concat(suffix, ")").concat(token.modifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (end) {
|
||||
if (!strict)
|
||||
route += "".concat(delimiterRe, "?");
|
||||
route += !options.endsWith ? "$" : "(?=".concat(endsWithRe, ")");
|
||||
} else {
|
||||
var endToken = tokens[tokens.length - 1];
|
||||
var isEndDelimited = typeof endToken === "string" ? delimiterRe.indexOf(endToken[endToken.length - 1]) > -1 : endToken === void 0;
|
||||
if (!strict) {
|
||||
route += "(?:".concat(delimiterRe, "(?=").concat(endsWithRe, "))?");
|
||||
}
|
||||
if (!isEndDelimited) {
|
||||
route += "(?=".concat(delimiterRe, "|").concat(endsWithRe, ")");
|
||||
}
|
||||
}
|
||||
return new RegExp(route, flags(options));
|
||||
}
|
||||
__name(tokensToRegexp, "tokensToRegexp");
|
||||
function pathToRegexp(path, keys, options) {
|
||||
if (path instanceof RegExp)
|
||||
return regexpToRegexp(path, keys);
|
||||
if (Array.isArray(path))
|
||||
return arrayToRegexp(path, keys, options);
|
||||
return stringToRegexp(path, keys, options);
|
||||
}
|
||||
__name(pathToRegexp, "pathToRegexp");
|
||||
|
||||
// ../node_modules/.pnpm/wrangler@3.85.0/node_modules/wrangler/templates/pages-template-worker.ts
|
||||
var escapeRegex = /[.+?^${}()|[\]\\]/g;
|
||||
function* executeRequest(request) {
|
||||
const requestPath = new URL(request.url).pathname;
|
||||
for (const route of [...routes].reverse()) {
|
||||
if (route.method && route.method !== request.method) {
|
||||
continue;
|
||||
}
|
||||
const routeMatcher = match(route.routePath.replace(escapeRegex, "\\$&"), {
|
||||
end: false
|
||||
});
|
||||
const mountMatcher = match(route.mountPath.replace(escapeRegex, "\\$&"), {
|
||||
end: false
|
||||
});
|
||||
const matchResult = routeMatcher(requestPath);
|
||||
const mountMatchResult = mountMatcher(requestPath);
|
||||
if (matchResult && mountMatchResult) {
|
||||
for (const handler of route.middlewares.flat()) {
|
||||
yield {
|
||||
handler,
|
||||
params: matchResult.params,
|
||||
path: mountMatchResult.path
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
for (const route of routes) {
|
||||
if (route.method && route.method !== request.method) {
|
||||
continue;
|
||||
}
|
||||
const routeMatcher = match(route.routePath.replace(escapeRegex, "\\$&"), {
|
||||
end: true
|
||||
});
|
||||
const mountMatcher = match(route.mountPath.replace(escapeRegex, "\\$&"), {
|
||||
end: false
|
||||
});
|
||||
const matchResult = routeMatcher(requestPath);
|
||||
const mountMatchResult = mountMatcher(requestPath);
|
||||
if (matchResult && mountMatchResult && route.modules.length) {
|
||||
for (const handler of route.modules.flat()) {
|
||||
yield {
|
||||
handler,
|
||||
params: matchResult.params,
|
||||
path: matchResult.path
|
||||
};
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
__name(executeRequest, "executeRequest");
|
||||
var pages_template_worker_default = {
|
||||
async fetch(originalRequest, env, workerContext) {
|
||||
let request = originalRequest;
|
||||
const handlerIterator = executeRequest(request);
|
||||
let data = {};
|
||||
let isFailOpen = false;
|
||||
const next = /* @__PURE__ */ __name(async (input, init) => {
|
||||
if (input !== void 0) {
|
||||
let url = input;
|
||||
if (typeof input === "string") {
|
||||
url = new URL(input, request.url).toString();
|
||||
}
|
||||
request = new Request(url, init);
|
||||
}
|
||||
const result = handlerIterator.next();
|
||||
if (result.done === false) {
|
||||
const { handler, params, path } = result.value;
|
||||
const context = {
|
||||
request: new Request(request.clone()),
|
||||
functionPath: path,
|
||||
next,
|
||||
params,
|
||||
get data() {
|
||||
return data;
|
||||
},
|
||||
set data(value) {
|
||||
if (typeof value !== "object" || value === null) {
|
||||
throw new Error("context.data must be an object");
|
||||
}
|
||||
data = value;
|
||||
},
|
||||
env,
|
||||
waitUntil: workerContext.waitUntil.bind(workerContext),
|
||||
passThroughOnException: () => {
|
||||
isFailOpen = true;
|
||||
}
|
||||
};
|
||||
const response = await handler(context);
|
||||
if (!(response instanceof Response)) {
|
||||
throw new Error("Your Pages function should return a Response");
|
||||
}
|
||||
return cloneResponse(response);
|
||||
} else if ("ASSETS") {
|
||||
const response = await env["ASSETS"].fetch(request);
|
||||
return cloneResponse(response);
|
||||
} else {
|
||||
const response = await fetch(request);
|
||||
return cloneResponse(response);
|
||||
}
|
||||
}, "next");
|
||||
try {
|
||||
return await next();
|
||||
} catch (error) {
|
||||
if (isFailOpen) {
|
||||
const response = await env["ASSETS"].fetch(request);
|
||||
return cloneResponse(response);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
};
|
||||
var cloneResponse = /* @__PURE__ */ __name((response) => (
|
||||
// https://fetch.spec.whatwg.org/#null-body-status
|
||||
new Response(
|
||||
[101, 204, 205, 304].includes(response.status) ? null : response.body,
|
||||
response
|
||||
)
|
||||
), "cloneResponse");
|
||||
|
||||
// ../node_modules/.pnpm/wrangler@3.85.0/node_modules/wrangler/templates/middleware/middleware-ensure-req-body-drained.ts
|
||||
var drainBody = /* @__PURE__ */ __name(async (request, env, _ctx, middlewareCtx) => {
|
||||
try {
|
||||
return await middlewareCtx.next(request, env);
|
||||
} finally {
|
||||
try {
|
||||
if (request.body !== null && !request.bodyUsed) {
|
||||
const reader = request.body.getReader();
|
||||
while (!(await reader.read()).done) {
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Failed to drain the unused request body.", e);
|
||||
}
|
||||
}
|
||||
}, "drainBody");
|
||||
var middleware_ensure_req_body_drained_default = drainBody;
|
||||
|
||||
// ../node_modules/.pnpm/wrangler@3.85.0/node_modules/wrangler/templates/middleware/middleware-miniflare3-json-error.ts
|
||||
function reduceError(e) {
|
||||
return {
|
||||
name: e?.name,
|
||||
message: e?.message ?? String(e),
|
||||
stack: e?.stack,
|
||||
cause: e?.cause === void 0 ? void 0 : reduceError(e.cause)
|
||||
};
|
||||
}
|
||||
__name(reduceError, "reduceError");
|
||||
var jsonError = /* @__PURE__ */ __name(async (request, env, _ctx, middlewareCtx) => {
|
||||
try {
|
||||
return await middlewareCtx.next(request, env);
|
||||
} catch (e) {
|
||||
const error = reduceError(e);
|
||||
return Response.json(error, {
|
||||
status: 500,
|
||||
headers: { "MF-Experimental-Error-Stack": "true" }
|
||||
});
|
||||
}
|
||||
}, "jsonError");
|
||||
var middleware_miniflare3_json_error_default = jsonError;
|
||||
|
||||
// ../.wrangler/tmp/bundle-EUTT79/middleware-insertion-facade.js
|
||||
var __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||
middleware_ensure_req_body_drained_default,
|
||||
middleware_miniflare3_json_error_default
|
||||
];
|
||||
var middleware_insertion_facade_default = pages_template_worker_default;
|
||||
|
||||
// ../node_modules/.pnpm/wrangler@3.85.0/node_modules/wrangler/templates/middleware/common.ts
|
||||
var __facade_middleware__ = [];
|
||||
function __facade_register__(...args) {
|
||||
__facade_middleware__.push(...args.flat());
|
||||
}
|
||||
__name(__facade_register__, "__facade_register__");
|
||||
function __facade_invokeChain__(request, env, ctx, dispatch, middlewareChain) {
|
||||
const [head, ...tail] = middlewareChain;
|
||||
const middlewareCtx = {
|
||||
dispatch,
|
||||
next(newRequest, newEnv) {
|
||||
return __facade_invokeChain__(newRequest, newEnv, ctx, dispatch, tail);
|
||||
}
|
||||
};
|
||||
return head(request, env, ctx, middlewareCtx);
|
||||
}
|
||||
__name(__facade_invokeChain__, "__facade_invokeChain__");
|
||||
function __facade_invoke__(request, env, ctx, dispatch, finalMiddleware) {
|
||||
return __facade_invokeChain__(request, env, ctx, dispatch, [
|
||||
...__facade_middleware__,
|
||||
finalMiddleware
|
||||
]);
|
||||
}
|
||||
__name(__facade_invoke__, "__facade_invoke__");
|
||||
|
||||
// ../.wrangler/tmp/bundle-EUTT79/middleware-loader.entry.ts
|
||||
var __Facade_ScheduledController__ = class {
|
||||
constructor(scheduledTime, cron, noRetry) {
|
||||
this.scheduledTime = scheduledTime;
|
||||
this.cron = cron;
|
||||
this.#noRetry = noRetry;
|
||||
}
|
||||
#noRetry;
|
||||
noRetry() {
|
||||
if (!(this instanceof __Facade_ScheduledController__)) {
|
||||
throw new TypeError("Illegal invocation");
|
||||
}
|
||||
this.#noRetry();
|
||||
}
|
||||
};
|
||||
__name(__Facade_ScheduledController__, "__Facade_ScheduledController__");
|
||||
function wrapExportedHandler(worker) {
|
||||
if (__INTERNAL_WRANGLER_MIDDLEWARE__ === void 0 || __INTERNAL_WRANGLER_MIDDLEWARE__.length === 0) {
|
||||
return worker;
|
||||
}
|
||||
for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) {
|
||||
__facade_register__(middleware);
|
||||
}
|
||||
const fetchDispatcher = /* @__PURE__ */ __name(function(request, env, ctx) {
|
||||
if (worker.fetch === void 0) {
|
||||
throw new Error("Handler does not export a fetch() function.");
|
||||
}
|
||||
return worker.fetch(request, env, ctx);
|
||||
}, "fetchDispatcher");
|
||||
return {
|
||||
...worker,
|
||||
fetch(request, env, ctx) {
|
||||
const dispatcher = /* @__PURE__ */ __name(function(type, init) {
|
||||
if (type === "scheduled" && worker.scheduled !== void 0) {
|
||||
const controller = new __Facade_ScheduledController__(
|
||||
Date.now(),
|
||||
init.cron ?? "",
|
||||
() => {
|
||||
}
|
||||
);
|
||||
return worker.scheduled(controller, env, ctx);
|
||||
}
|
||||
}, "dispatcher");
|
||||
return __facade_invoke__(request, env, ctx, dispatcher, fetchDispatcher);
|
||||
}
|
||||
};
|
||||
}
|
||||
__name(wrapExportedHandler, "wrapExportedHandler");
|
||||
function wrapWorkerEntrypoint(klass) {
|
||||
if (__INTERNAL_WRANGLER_MIDDLEWARE__ === void 0 || __INTERNAL_WRANGLER_MIDDLEWARE__.length === 0) {
|
||||
return klass;
|
||||
}
|
||||
for (const middleware of __INTERNAL_WRANGLER_MIDDLEWARE__) {
|
||||
__facade_register__(middleware);
|
||||
}
|
||||
return class extends klass {
|
||||
#fetchDispatcher = (request, env, ctx) => {
|
||||
this.env = env;
|
||||
this.ctx = ctx;
|
||||
if (super.fetch === void 0) {
|
||||
throw new Error("Entrypoint class does not define a fetch() function.");
|
||||
}
|
||||
return super.fetch(request);
|
||||
};
|
||||
#dispatcher = (type, init) => {
|
||||
if (type === "scheduled" && super.scheduled !== void 0) {
|
||||
const controller = new __Facade_ScheduledController__(
|
||||
Date.now(),
|
||||
init.cron ?? "",
|
||||
() => {
|
||||
}
|
||||
);
|
||||
return super.scheduled(controller);
|
||||
}
|
||||
};
|
||||
fetch(request) {
|
||||
return __facade_invoke__(
|
||||
request,
|
||||
this.env,
|
||||
this.ctx,
|
||||
this.#dispatcher,
|
||||
this.#fetchDispatcher
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
__name(wrapWorkerEntrypoint, "wrapWorkerEntrypoint");
|
||||
var WRAPPED_ENTRY;
|
||||
if (typeof middleware_insertion_facade_default === "object") {
|
||||
WRAPPED_ENTRY = wrapExportedHandler(middleware_insertion_facade_default);
|
||||
} else if (typeof middleware_insertion_facade_default === "function") {
|
||||
WRAPPED_ENTRY = wrapWorkerEntrypoint(middleware_insertion_facade_default);
|
||||
}
|
||||
var middleware_loader_entry_default = WRAPPED_ENTRY;
|
||||
export {
|
||||
__INTERNAL_WRANGLER_MIDDLEWARE__,
|
||||
middleware_loader_entry_default as default
|
||||
};
|
||||
//# sourceMappingURL=functionsWorker-0.9817993910801683.mjs.map
|
||||
File diff suppressed because one or more lines are too long
@@ -1,26 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
|
||||
"target": "ES2020",
|
||||
"useDefineForClassFields": true,
|
||||
"lib": ["ES2020", "DOM", "DOM.Iterable"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "Bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"isolatedModules": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -1,7 +1,45 @@
|
||||
{
|
||||
"files": [],
|
||||
"references": [
|
||||
{ "path": "./tsconfig.app.json" },
|
||||
{ "path": "./tsconfig.node.json" }
|
||||
]
|
||||
"compilerOptions": {
|
||||
"target": "ESNext",
|
||||
"lib": ["dom", "dom.iterable", "esnext"],
|
||||
"allowJs": true,
|
||||
"skipLibCheck": true,
|
||||
"esModuleInterop": true,
|
||||
"noUncheckedIndexedAccess": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"strict": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "bundler",
|
||||
"resolveJsonModule": true,
|
||||
"isolatedModules": true,
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"useDefineForClassFields": false,
|
||||
"importsNotUsedAsValues": "remove",
|
||||
"baseUrl": ".",
|
||||
"types": ["@cloudflare/workers-types"],
|
||||
"paths": {
|
||||
"@clients/graphql": ["./src/clients/graphql"],
|
||||
"@clients/rest": ["./src/clients/rest"],
|
||||
"@env": ["./src/env"]
|
||||
}
|
||||
},
|
||||
"include": [
|
||||
"src",
|
||||
"generator",
|
||||
"./global.d.ts",
|
||||
"./cloudflare.d.ts",
|
||||
"./seeds",
|
||||
"tests"
|
||||
],
|
||||
"ts-node": {
|
||||
"require": ["tsconfig-paths/register"],
|
||||
"compilerOptions": {
|
||||
"module": "commonjs"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo",
|
||||
"target": "ES2022",
|
||||
"lib": ["ES2023"],
|
||||
"module": "ESNext",
|
||||
"skipLibCheck": true,
|
||||
|
||||
/* Bundler mode */
|
||||
"moduleResolution": "Bundler",
|
||||
"allowImportingTsExtensions": true,
|
||||
"isolatedModules": true,
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
|
||||
/* Linting */
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"noUncheckedSideEffectImports": true
|
||||
},
|
||||
"include": ["vite.config.ts"]
|
||||
}
|
||||
@@ -3,6 +3,7 @@ import { defineConfig } from "vite"
|
||||
import { nodePolyfills } from "vite-plugin-node-polyfills"
|
||||
import svgr from "vite-plugin-svgr"
|
||||
import CloudflarePagesFunctions from "vite-plugin-cloudflare-functions"
|
||||
import type { Plugin } from 'vite'
|
||||
|
||||
// https://vite.dev/config/
|
||||
export default defineConfig({
|
||||
|
||||
Reference in New Issue
Block a user