feat: 迁移到Cloudflare Workers并重构API请求处理
refactor: 使用fetch替换axios并优化请求处理逻辑 docs: 添加DEPLOYMENT.md部署指南 build: 更新package.json依赖和脚本配置 style: 更新组件类型定义和注释 perf: 优化图片代理和用户数据初始化逻辑
This commit is contained in:
30
.wrangler/tmp/bundle-A5JBNI/checked-fetch.js
Normal file
30
.wrangler/tmp/bundle-A5JBNI/checked-fetch.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
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);
|
||||||
|
},
|
||||||
|
});
|
||||||
11
.wrangler/tmp/bundle-A5JBNI/middleware-insertion-facade.js
Normal file
11
.wrangler/tmp/bundle-A5JBNI/middleware-insertion-facade.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import worker, * as OTHER_EXPORTS from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
import * as __MIDDLEWARE_0__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-ensure-req-body-drained.ts";
|
||||||
|
import * as __MIDDLEWARE_1__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-miniflare3-json-error.ts";
|
||||||
|
|
||||||
|
export * from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
const MIDDLEWARE_TEST_INJECT = "__INJECT_FOR_TESTING_WRANGLER_MIDDLEWARE__";
|
||||||
|
export const __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
|
||||||
|
__MIDDLEWARE_0__.default,__MIDDLEWARE_1__.default
|
||||||
|
]
|
||||||
|
export default worker;
|
||||||
134
.wrangler/tmp/bundle-A5JBNI/middleware-loader.entry.ts
Normal file
134
.wrangler/tmp/bundle-A5JBNI/middleware-loader.entry.ts
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
// 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 "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-A5JBNI\\middleware-insertion-facade.js";
|
||||||
|
import { __facade_invoke__, __facade_register__, Dispatcher } from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\common.ts";
|
||||||
|
import type { WorkerEntrypointConstructor } from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-A5JBNI\\middleware-insertion-facade.js";
|
||||||
|
|
||||||
|
// Preserve all the exports from the worker
|
||||||
|
export * from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-A5JBNI\\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;
|
||||||
30
.wrangler/tmp/bundle-BPqujt/checked-fetch.js
Normal file
30
.wrangler/tmp/bundle-BPqujt/checked-fetch.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
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);
|
||||||
|
},
|
||||||
|
});
|
||||||
11
.wrangler/tmp/bundle-BPqujt/middleware-insertion-facade.js
Normal file
11
.wrangler/tmp/bundle-BPqujt/middleware-insertion-facade.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import worker, * as OTHER_EXPORTS from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
import * as __MIDDLEWARE_0__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-ensure-req-body-drained.ts";
|
||||||
|
import * as __MIDDLEWARE_1__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-miniflare3-json-error.ts";
|
||||||
|
|
||||||
|
export * from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
const MIDDLEWARE_TEST_INJECT = "__INJECT_FOR_TESTING_WRANGLER_MIDDLEWARE__";
|
||||||
|
export const __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
|
||||||
|
__MIDDLEWARE_0__.default,__MIDDLEWARE_1__.default
|
||||||
|
]
|
||||||
|
export default worker;
|
||||||
134
.wrangler/tmp/bundle-BPqujt/middleware-loader.entry.ts
Normal file
134
.wrangler/tmp/bundle-BPqujt/middleware-loader.entry.ts
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
// 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 "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-BPqujt\\middleware-insertion-facade.js";
|
||||||
|
import { __facade_invoke__, __facade_register__, Dispatcher } from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\common.ts";
|
||||||
|
import type { WorkerEntrypointConstructor } from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-BPqujt\\middleware-insertion-facade.js";
|
||||||
|
|
||||||
|
// Preserve all the exports from the worker
|
||||||
|
export * from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-BPqujt\\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;
|
||||||
30
.wrangler/tmp/bundle-MMP94b/checked-fetch.js
Normal file
30
.wrangler/tmp/bundle-MMP94b/checked-fetch.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
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);
|
||||||
|
},
|
||||||
|
});
|
||||||
11
.wrangler/tmp/bundle-MMP94b/middleware-insertion-facade.js
Normal file
11
.wrangler/tmp/bundle-MMP94b/middleware-insertion-facade.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import worker, * as OTHER_EXPORTS from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
import * as __MIDDLEWARE_0__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-ensure-req-body-drained.ts";
|
||||||
|
import * as __MIDDLEWARE_1__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-miniflare3-json-error.ts";
|
||||||
|
|
||||||
|
export * from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
const MIDDLEWARE_TEST_INJECT = "__INJECT_FOR_TESTING_WRANGLER_MIDDLEWARE__";
|
||||||
|
export const __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
|
||||||
|
__MIDDLEWARE_0__.default,__MIDDLEWARE_1__.default
|
||||||
|
]
|
||||||
|
export default worker;
|
||||||
134
.wrangler/tmp/bundle-MMP94b/middleware-loader.entry.ts
Normal file
134
.wrangler/tmp/bundle-MMP94b/middleware-loader.entry.ts
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
// 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 "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-MMP94b\\middleware-insertion-facade.js";
|
||||||
|
import { __facade_invoke__, __facade_register__, Dispatcher } from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\common.ts";
|
||||||
|
import type { WorkerEntrypointConstructor } from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-MMP94b\\middleware-insertion-facade.js";
|
||||||
|
|
||||||
|
// Preserve all the exports from the worker
|
||||||
|
export * from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-MMP94b\\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;
|
||||||
30
.wrangler/tmp/bundle-Oml82W/checked-fetch.js
Normal file
30
.wrangler/tmp/bundle-Oml82W/checked-fetch.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
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);
|
||||||
|
},
|
||||||
|
});
|
||||||
11
.wrangler/tmp/bundle-Oml82W/middleware-insertion-facade.js
Normal file
11
.wrangler/tmp/bundle-Oml82W/middleware-insertion-facade.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import worker, * as OTHER_EXPORTS from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
import * as __MIDDLEWARE_0__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-ensure-req-body-drained.ts";
|
||||||
|
import * as __MIDDLEWARE_1__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-miniflare3-json-error.ts";
|
||||||
|
|
||||||
|
export * from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
const MIDDLEWARE_TEST_INJECT = "__INJECT_FOR_TESTING_WRANGLER_MIDDLEWARE__";
|
||||||
|
export const __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
|
||||||
|
__MIDDLEWARE_0__.default,__MIDDLEWARE_1__.default
|
||||||
|
]
|
||||||
|
export default worker;
|
||||||
134
.wrangler/tmp/bundle-Oml82W/middleware-loader.entry.ts
Normal file
134
.wrangler/tmp/bundle-Oml82W/middleware-loader.entry.ts
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
// 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 "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-Oml82W\\middleware-insertion-facade.js";
|
||||||
|
import { __facade_invoke__, __facade_register__, Dispatcher } from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\common.ts";
|
||||||
|
import type { WorkerEntrypointConstructor } from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-Oml82W\\middleware-insertion-facade.js";
|
||||||
|
|
||||||
|
// Preserve all the exports from the worker
|
||||||
|
export * from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-Oml82W\\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;
|
||||||
30
.wrangler/tmp/bundle-P1vEyM/checked-fetch.js
Normal file
30
.wrangler/tmp/bundle-P1vEyM/checked-fetch.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
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);
|
||||||
|
},
|
||||||
|
});
|
||||||
11
.wrangler/tmp/bundle-P1vEyM/middleware-insertion-facade.js
Normal file
11
.wrangler/tmp/bundle-P1vEyM/middleware-insertion-facade.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import worker, * as OTHER_EXPORTS from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
import * as __MIDDLEWARE_0__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-ensure-req-body-drained.ts";
|
||||||
|
import * as __MIDDLEWARE_1__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-miniflare3-json-error.ts";
|
||||||
|
|
||||||
|
export * from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
const MIDDLEWARE_TEST_INJECT = "__INJECT_FOR_TESTING_WRANGLER_MIDDLEWARE__";
|
||||||
|
export const __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
|
||||||
|
__MIDDLEWARE_0__.default,__MIDDLEWARE_1__.default
|
||||||
|
]
|
||||||
|
export default worker;
|
||||||
134
.wrangler/tmp/bundle-P1vEyM/middleware-loader.entry.ts
Normal file
134
.wrangler/tmp/bundle-P1vEyM/middleware-loader.entry.ts
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
// 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 "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-P1vEyM\\middleware-insertion-facade.js";
|
||||||
|
import { __facade_invoke__, __facade_register__, Dispatcher } from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\common.ts";
|
||||||
|
import type { WorkerEntrypointConstructor } from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-P1vEyM\\middleware-insertion-facade.js";
|
||||||
|
|
||||||
|
// Preserve all the exports from the worker
|
||||||
|
export * from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-P1vEyM\\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;
|
||||||
30
.wrangler/tmp/bundle-RkXBq4/checked-fetch.js
Normal file
30
.wrangler/tmp/bundle-RkXBq4/checked-fetch.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
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);
|
||||||
|
},
|
||||||
|
});
|
||||||
11
.wrangler/tmp/bundle-RkXBq4/middleware-insertion-facade.js
Normal file
11
.wrangler/tmp/bundle-RkXBq4/middleware-insertion-facade.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import worker, * as OTHER_EXPORTS from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
import * as __MIDDLEWARE_0__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-ensure-req-body-drained.ts";
|
||||||
|
import * as __MIDDLEWARE_1__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-miniflare3-json-error.ts";
|
||||||
|
|
||||||
|
export * from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
const MIDDLEWARE_TEST_INJECT = "__INJECT_FOR_TESTING_WRANGLER_MIDDLEWARE__";
|
||||||
|
export const __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
|
||||||
|
__MIDDLEWARE_0__.default,__MIDDLEWARE_1__.default
|
||||||
|
]
|
||||||
|
export default worker;
|
||||||
134
.wrangler/tmp/bundle-RkXBq4/middleware-loader.entry.ts
Normal file
134
.wrangler/tmp/bundle-RkXBq4/middleware-loader.entry.ts
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
// 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 "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-RkXBq4\\middleware-insertion-facade.js";
|
||||||
|
import { __facade_invoke__, __facade_register__, Dispatcher } from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\common.ts";
|
||||||
|
import type { WorkerEntrypointConstructor } from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-RkXBq4\\middleware-insertion-facade.js";
|
||||||
|
|
||||||
|
// Preserve all the exports from the worker
|
||||||
|
export * from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-RkXBq4\\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;
|
||||||
30
.wrangler/tmp/bundle-YuxJya/checked-fetch.js
Normal file
30
.wrangler/tmp/bundle-YuxJya/checked-fetch.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
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);
|
||||||
|
},
|
||||||
|
});
|
||||||
11
.wrangler/tmp/bundle-YuxJya/middleware-insertion-facade.js
Normal file
11
.wrangler/tmp/bundle-YuxJya/middleware-insertion-facade.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import worker, * as OTHER_EXPORTS from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
import * as __MIDDLEWARE_0__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-ensure-req-body-drained.ts";
|
||||||
|
import * as __MIDDLEWARE_1__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-miniflare3-json-error.ts";
|
||||||
|
|
||||||
|
export * from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
const MIDDLEWARE_TEST_INJECT = "__INJECT_FOR_TESTING_WRANGLER_MIDDLEWARE__";
|
||||||
|
export const __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
|
||||||
|
__MIDDLEWARE_0__.default,__MIDDLEWARE_1__.default
|
||||||
|
]
|
||||||
|
export default worker;
|
||||||
134
.wrangler/tmp/bundle-YuxJya/middleware-loader.entry.ts
Normal file
134
.wrangler/tmp/bundle-YuxJya/middleware-loader.entry.ts
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
// 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 "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-YuxJya\\middleware-insertion-facade.js";
|
||||||
|
import { __facade_invoke__, __facade_register__, Dispatcher } from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\common.ts";
|
||||||
|
import type { WorkerEntrypointConstructor } from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-YuxJya\\middleware-insertion-facade.js";
|
||||||
|
|
||||||
|
// Preserve all the exports from the worker
|
||||||
|
export * from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-YuxJya\\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;
|
||||||
30
.wrangler/tmp/bundle-d5bXFA/checked-fetch.js
Normal file
30
.wrangler/tmp/bundle-d5bXFA/checked-fetch.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
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);
|
||||||
|
},
|
||||||
|
});
|
||||||
11
.wrangler/tmp/bundle-d5bXFA/middleware-insertion-facade.js
Normal file
11
.wrangler/tmp/bundle-d5bXFA/middleware-insertion-facade.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import worker, * as OTHER_EXPORTS from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
import * as __MIDDLEWARE_0__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-ensure-req-body-drained.ts";
|
||||||
|
import * as __MIDDLEWARE_1__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-miniflare3-json-error.ts";
|
||||||
|
|
||||||
|
export * from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
const MIDDLEWARE_TEST_INJECT = "__INJECT_FOR_TESTING_WRANGLER_MIDDLEWARE__";
|
||||||
|
export const __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
|
||||||
|
__MIDDLEWARE_0__.default,__MIDDLEWARE_1__.default
|
||||||
|
]
|
||||||
|
export default worker;
|
||||||
134
.wrangler/tmp/bundle-d5bXFA/middleware-loader.entry.ts
Normal file
134
.wrangler/tmp/bundle-d5bXFA/middleware-loader.entry.ts
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
// 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 "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-d5bXFA\\middleware-insertion-facade.js";
|
||||||
|
import { __facade_invoke__, __facade_register__, Dispatcher } from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\common.ts";
|
||||||
|
import type { WorkerEntrypointConstructor } from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-d5bXFA\\middleware-insertion-facade.js";
|
||||||
|
|
||||||
|
// Preserve all the exports from the worker
|
||||||
|
export * from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-d5bXFA\\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;
|
||||||
30
.wrangler/tmp/bundle-fNR4lX/checked-fetch.js
Normal file
30
.wrangler/tmp/bundle-fNR4lX/checked-fetch.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
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);
|
||||||
|
},
|
||||||
|
});
|
||||||
11
.wrangler/tmp/bundle-fNR4lX/middleware-insertion-facade.js
Normal file
11
.wrangler/tmp/bundle-fNR4lX/middleware-insertion-facade.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import worker, * as OTHER_EXPORTS from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
import * as __MIDDLEWARE_0__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-ensure-req-body-drained.ts";
|
||||||
|
import * as __MIDDLEWARE_1__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-miniflare3-json-error.ts";
|
||||||
|
|
||||||
|
export * from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
const MIDDLEWARE_TEST_INJECT = "__INJECT_FOR_TESTING_WRANGLER_MIDDLEWARE__";
|
||||||
|
export const __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
|
||||||
|
__MIDDLEWARE_0__.default,__MIDDLEWARE_1__.default
|
||||||
|
]
|
||||||
|
export default worker;
|
||||||
134
.wrangler/tmp/bundle-fNR4lX/middleware-loader.entry.ts
Normal file
134
.wrangler/tmp/bundle-fNR4lX/middleware-loader.entry.ts
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
// 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 "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-fNR4lX\\middleware-insertion-facade.js";
|
||||||
|
import { __facade_invoke__, __facade_register__, Dispatcher } from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\common.ts";
|
||||||
|
import type { WorkerEntrypointConstructor } from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-fNR4lX\\middleware-insertion-facade.js";
|
||||||
|
|
||||||
|
// Preserve all the exports from the worker
|
||||||
|
export * from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-fNR4lX\\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;
|
||||||
30
.wrangler/tmp/bundle-hVAKjn/checked-fetch.js
Normal file
30
.wrangler/tmp/bundle-hVAKjn/checked-fetch.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
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);
|
||||||
|
},
|
||||||
|
});
|
||||||
11
.wrangler/tmp/bundle-hVAKjn/middleware-insertion-facade.js
Normal file
11
.wrangler/tmp/bundle-hVAKjn/middleware-insertion-facade.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import worker, * as OTHER_EXPORTS from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
import * as __MIDDLEWARE_0__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-ensure-req-body-drained.ts";
|
||||||
|
import * as __MIDDLEWARE_1__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-miniflare3-json-error.ts";
|
||||||
|
|
||||||
|
export * from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
const MIDDLEWARE_TEST_INJECT = "__INJECT_FOR_TESTING_WRANGLER_MIDDLEWARE__";
|
||||||
|
export const __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
|
||||||
|
__MIDDLEWARE_0__.default,__MIDDLEWARE_1__.default
|
||||||
|
]
|
||||||
|
export default worker;
|
||||||
134
.wrangler/tmp/bundle-hVAKjn/middleware-loader.entry.ts
Normal file
134
.wrangler/tmp/bundle-hVAKjn/middleware-loader.entry.ts
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
// 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 "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-hVAKjn\\middleware-insertion-facade.js";
|
||||||
|
import { __facade_invoke__, __facade_register__, Dispatcher } from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\common.ts";
|
||||||
|
import type { WorkerEntrypointConstructor } from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-hVAKjn\\middleware-insertion-facade.js";
|
||||||
|
|
||||||
|
// Preserve all the exports from the worker
|
||||||
|
export * from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-hVAKjn\\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;
|
||||||
30
.wrangler/tmp/bundle-ikDXAQ/checked-fetch.js
Normal file
30
.wrangler/tmp/bundle-ikDXAQ/checked-fetch.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
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);
|
||||||
|
},
|
||||||
|
});
|
||||||
11
.wrangler/tmp/bundle-ikDXAQ/middleware-insertion-facade.js
Normal file
11
.wrangler/tmp/bundle-ikDXAQ/middleware-insertion-facade.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import worker, * as OTHER_EXPORTS from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
import * as __MIDDLEWARE_0__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-ensure-req-body-drained.ts";
|
||||||
|
import * as __MIDDLEWARE_1__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-miniflare3-json-error.ts";
|
||||||
|
|
||||||
|
export * from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
const MIDDLEWARE_TEST_INJECT = "__INJECT_FOR_TESTING_WRANGLER_MIDDLEWARE__";
|
||||||
|
export const __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
|
||||||
|
__MIDDLEWARE_0__.default,__MIDDLEWARE_1__.default
|
||||||
|
]
|
||||||
|
export default worker;
|
||||||
134
.wrangler/tmp/bundle-ikDXAQ/middleware-loader.entry.ts
Normal file
134
.wrangler/tmp/bundle-ikDXAQ/middleware-loader.entry.ts
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
// 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 "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-ikDXAQ\\middleware-insertion-facade.js";
|
||||||
|
import { __facade_invoke__, __facade_register__, Dispatcher } from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\common.ts";
|
||||||
|
import type { WorkerEntrypointConstructor } from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-ikDXAQ\\middleware-insertion-facade.js";
|
||||||
|
|
||||||
|
// Preserve all the exports from the worker
|
||||||
|
export * from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-ikDXAQ\\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;
|
||||||
30
.wrangler/tmp/bundle-lcE67Q/checked-fetch.js
Normal file
30
.wrangler/tmp/bundle-lcE67Q/checked-fetch.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
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);
|
||||||
|
},
|
||||||
|
});
|
||||||
11
.wrangler/tmp/bundle-lcE67Q/middleware-insertion-facade.js
Normal file
11
.wrangler/tmp/bundle-lcE67Q/middleware-insertion-facade.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import worker, * as OTHER_EXPORTS from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
import * as __MIDDLEWARE_0__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-ensure-req-body-drained.ts";
|
||||||
|
import * as __MIDDLEWARE_1__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-miniflare3-json-error.ts";
|
||||||
|
|
||||||
|
export * from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
const MIDDLEWARE_TEST_INJECT = "__INJECT_FOR_TESTING_WRANGLER_MIDDLEWARE__";
|
||||||
|
export const __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
|
||||||
|
__MIDDLEWARE_0__.default,__MIDDLEWARE_1__.default
|
||||||
|
]
|
||||||
|
export default worker;
|
||||||
134
.wrangler/tmp/bundle-lcE67Q/middleware-loader.entry.ts
Normal file
134
.wrangler/tmp/bundle-lcE67Q/middleware-loader.entry.ts
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
// 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 "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-lcE67Q\\middleware-insertion-facade.js";
|
||||||
|
import { __facade_invoke__, __facade_register__, Dispatcher } from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\common.ts";
|
||||||
|
import type { WorkerEntrypointConstructor } from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-lcE67Q\\middleware-insertion-facade.js";
|
||||||
|
|
||||||
|
// Preserve all the exports from the worker
|
||||||
|
export * from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-lcE67Q\\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;
|
||||||
30
.wrangler/tmp/bundle-mYQ48C/checked-fetch.js
Normal file
30
.wrangler/tmp/bundle-mYQ48C/checked-fetch.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
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);
|
||||||
|
},
|
||||||
|
});
|
||||||
11
.wrangler/tmp/bundle-mYQ48C/middleware-insertion-facade.js
Normal file
11
.wrangler/tmp/bundle-mYQ48C/middleware-insertion-facade.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import worker, * as OTHER_EXPORTS from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
import * as __MIDDLEWARE_0__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-ensure-req-body-drained.ts";
|
||||||
|
import * as __MIDDLEWARE_1__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-miniflare3-json-error.ts";
|
||||||
|
|
||||||
|
export * from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
const MIDDLEWARE_TEST_INJECT = "__INJECT_FOR_TESTING_WRANGLER_MIDDLEWARE__";
|
||||||
|
export const __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
|
||||||
|
__MIDDLEWARE_0__.default,__MIDDLEWARE_1__.default
|
||||||
|
]
|
||||||
|
export default worker;
|
||||||
134
.wrangler/tmp/bundle-mYQ48C/middleware-loader.entry.ts
Normal file
134
.wrangler/tmp/bundle-mYQ48C/middleware-loader.entry.ts
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
// 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 "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-mYQ48C\\middleware-insertion-facade.js";
|
||||||
|
import { __facade_invoke__, __facade_register__, Dispatcher } from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\common.ts";
|
||||||
|
import type { WorkerEntrypointConstructor } from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-mYQ48C\\middleware-insertion-facade.js";
|
||||||
|
|
||||||
|
// Preserve all the exports from the worker
|
||||||
|
export * from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-mYQ48C\\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;
|
||||||
30
.wrangler/tmp/bundle-sMKHZl/checked-fetch.js
Normal file
30
.wrangler/tmp/bundle-sMKHZl/checked-fetch.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
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);
|
||||||
|
},
|
||||||
|
});
|
||||||
11
.wrangler/tmp/bundle-sMKHZl/middleware-insertion-facade.js
Normal file
11
.wrangler/tmp/bundle-sMKHZl/middleware-insertion-facade.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import worker, * as OTHER_EXPORTS from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
import * as __MIDDLEWARE_0__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-ensure-req-body-drained.ts";
|
||||||
|
import * as __MIDDLEWARE_1__ from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\middleware-miniflare3-json-error.ts";
|
||||||
|
|
||||||
|
export * from "D:\\github\\pixivnow\\functions\\[[path]].ts";
|
||||||
|
const MIDDLEWARE_TEST_INJECT = "__INJECT_FOR_TESTING_WRANGLER_MIDDLEWARE__";
|
||||||
|
export const __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
|
||||||
|
__MIDDLEWARE_0__.default,__MIDDLEWARE_1__.default
|
||||||
|
]
|
||||||
|
export default worker;
|
||||||
134
.wrangler/tmp/bundle-sMKHZl/middleware-loader.entry.ts
Normal file
134
.wrangler/tmp/bundle-sMKHZl/middleware-loader.entry.ts
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
// 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 "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-sMKHZl\\middleware-insertion-facade.js";
|
||||||
|
import { __facade_invoke__, __facade_register__, Dispatcher } from "D:\\github\\pixivnow\\node_modules\\.pnpm\\wrangler@4.42.1\\node_modules\\wrangler\\templates\\middleware\\common.ts";
|
||||||
|
import type { WorkerEntrypointConstructor } from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-sMKHZl\\middleware-insertion-facade.js";
|
||||||
|
|
||||||
|
// Preserve all the exports from the worker
|
||||||
|
export * from "D:\\github\\pixivnow\\.wrangler\\tmp\\bundle-sMKHZl\\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;
|
||||||
397
.wrangler/tmp/dev-1YRfaC/[[path]].js
Normal file
397
.wrangler/tmp/dev-1YRfaC/[[path]].js
Normal file
@@ -0,0 +1,397 @@
|
|||||||
|
var __defProp = Object.defineProperty;
|
||||||
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||||
|
|
||||||
|
// .wrangler/tmp/bundle-MMP94b/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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// functions/[[path]].ts
|
||||||
|
function corsHeaders() {
|
||||||
|
return {
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
|
||||||
|
"Access-Control-Allow-Headers": "Content-Type, Authorization, X-Requested-With",
|
||||||
|
"Access-Control-Max-Age": "86400"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
__name(corsHeaders, "corsHeaders");
|
||||||
|
function corsResponse(response) {
|
||||||
|
const headers = new Headers(response.headers);
|
||||||
|
Object.entries(corsHeaders()).forEach(([key, value]) => {
|
||||||
|
headers.set(key, value);
|
||||||
|
});
|
||||||
|
return new Response(response.body, {
|
||||||
|
status: response.status,
|
||||||
|
statusText: response.statusText,
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
}
|
||||||
|
__name(corsResponse, "corsResponse");
|
||||||
|
var path_default = {
|
||||||
|
fetch: /* @__PURE__ */ __name(async (request, env, ctx) => {
|
||||||
|
console.log("Worker fetch called:", request.method, request.url);
|
||||||
|
const url = new URL(request.url);
|
||||||
|
const path = url.pathname;
|
||||||
|
if (request.method === "OPTIONS") {
|
||||||
|
return new Response(null, {
|
||||||
|
status: 200,
|
||||||
|
headers: corsHeaders()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (path === "/") {
|
||||||
|
return corsResponse(new Response("Pixiv Now Worker is running!", {
|
||||||
|
headers: { "Content-Type": "text/plain" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (path === "/test") {
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
message: "Test successful",
|
||||||
|
timestamp: Date.now(),
|
||||||
|
method: request.method,
|
||||||
|
path
|
||||||
|
}), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (path === "/api/illust/random") {
|
||||||
|
return await handleRandomAPI(request, env, url);
|
||||||
|
}
|
||||||
|
if (path.match(/^\/(ajax|rpc)\//)) {
|
||||||
|
return await handleGenericProxy(request, env);
|
||||||
|
}
|
||||||
|
if (path.match(/^\/[~-]\//)) {
|
||||||
|
return await handleImageProxy(request, env);
|
||||||
|
}
|
||||||
|
if (path === "/api/user") {
|
||||||
|
return await handleUserAPI(request, env, url);
|
||||||
|
}
|
||||||
|
return corsResponse(new Response("Not Found", {
|
||||||
|
status: 404,
|
||||||
|
headers: { "Content-Type": "text/plain" }
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Worker error:", error);
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}, "fetch")
|
||||||
|
};
|
||||||
|
async function handleRandomAPI(request, env, url) {
|
||||||
|
try {
|
||||||
|
const requestImage = (request.headers.get("accept")?.includes("image") || url.searchParams.get("format") === "image") && url.searchParams.get("format") !== "json";
|
||||||
|
const mockIllusts = [
|
||||||
|
{
|
||||||
|
id: "123456789",
|
||||||
|
title: "Test Illustration",
|
||||||
|
userId: "987654321",
|
||||||
|
userName: "Test Artist",
|
||||||
|
tags: ["test", "mock"],
|
||||||
|
updateDate: "2024-01-01T12:00:00+00:00",
|
||||||
|
urls: {
|
||||||
|
mini: "https://i.pximg.net/c/48x48/img-master/img/2024/01/01/12/00/00/123456789_p0_square1200.jpg",
|
||||||
|
thumb: "https://i.pximg.net/c/250x250_80_a2/img-master/img/2024/01/01/12/00/00/123456789_p0_square1200.jpg",
|
||||||
|
small: "https://i.pximg.net/c/540x540_70/img-master/img/2024/01/01/12/00/00/123456789_p0_master1200.jpg",
|
||||||
|
regular: "https://i.pximg.net/img-master/img/2024/01/01/12/00/00/123456789_p0_master1200.jpg",
|
||||||
|
original: "https://i.pximg.net/img-original/img/2024/01/01/12/00/00/123456789_p0.jpg"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
if (requestImage && mockIllusts[0]?.urls?.regular) {
|
||||||
|
return corsResponse(new Response(null, {
|
||||||
|
status: 302,
|
||||||
|
headers: { Location: mockIllusts[0].urls.regular }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
return corsResponse(new Response(JSON.stringify(mockIllusts), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in random API:", error);
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__name(handleRandomAPI, "handleRandomAPI");
|
||||||
|
async function handleGenericProxy(request, env) {
|
||||||
|
const url = new URL(request.url);
|
||||||
|
url.hostname = "www.pixiv.net";
|
||||||
|
const headers = new Headers(request.headers);
|
||||||
|
headers.set("origin", "https://www.pixiv.net");
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
method: request.method,
|
||||||
|
headers,
|
||||||
|
body: request.body
|
||||||
|
});
|
||||||
|
const response = await fetch(newReq);
|
||||||
|
return corsResponse(response);
|
||||||
|
}
|
||||||
|
__name(handleGenericProxy, "handleGenericProxy");
|
||||||
|
async function handleImageProxy(request, env) {
|
||||||
|
const url = new URL(request.url);
|
||||||
|
const path = url.pathname.slice(2);
|
||||||
|
if (url.pathname.startsWith("/~")) {
|
||||||
|
url.hostname = "i.pximg.net";
|
||||||
|
} else {
|
||||||
|
url.hostname = "s.pximg.net";
|
||||||
|
}
|
||||||
|
url.pathname = "/" + path;
|
||||||
|
const headers = new Headers();
|
||||||
|
for (const h of ["accept", "accept-encoding", "accept-language", "cache-control", "user-agent"]) {
|
||||||
|
if (request.headers.get(h)) {
|
||||||
|
headers.set(h, request.headers.get(h));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
const response = await fetch(newReq);
|
||||||
|
return corsResponse(response);
|
||||||
|
}
|
||||||
|
__name(handleImageProxy, "handleImageProxy");
|
||||||
|
async function handleUserAPI(request, env, url) {
|
||||||
|
try {
|
||||||
|
const userId = url.searchParams.get("id");
|
||||||
|
if (!userId) {
|
||||||
|
return corsResponse(new Response(JSON.stringify({ error: "User ID is required" }), {
|
||||||
|
status: 400,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
const pixivUrl = new URL(`https://www.pixiv.net/ajax/user/${userId}`);
|
||||||
|
const headers = new Headers();
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const response = await fetch(pixivUrl.toString(), { headers });
|
||||||
|
if (!response.ok) {
|
||||||
|
return corsResponse(new Response(JSON.stringify({ error: `Pixiv API returned ${response.status}` }), {
|
||||||
|
status: response.status,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
const data = await response.json();
|
||||||
|
return corsResponse(new Response(JSON.stringify(data), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in user API:", error);
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__name(handleUserAPI, "handleUserAPI");
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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@4.42.1/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-MMP94b/middleware-insertion-facade.js
|
||||||
|
var __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
middleware_ensure_req_body_drained_default,
|
||||||
|
middleware_miniflare3_json_error_default
|
||||||
|
];
|
||||||
|
var middleware_insertion_facade_default = path_default;
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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-MMP94b/middleware-loader.entry.ts
|
||||||
|
var __Facade_ScheduledController__ = class ___Facade_ScheduledController__ {
|
||||||
|
constructor(scheduledTime, cron, noRetry) {
|
||||||
|
this.scheduledTime = scheduledTime;
|
||||||
|
this.cron = cron;
|
||||||
|
this.#noRetry = noRetry;
|
||||||
|
}
|
||||||
|
static {
|
||||||
|
__name(this, "__Facade_ScheduledController__");
|
||||||
|
}
|
||||||
|
#noRetry;
|
||||||
|
noRetry() {
|
||||||
|
if (!(this instanceof ___Facade_ScheduledController__)) {
|
||||||
|
throw new TypeError("Illegal invocation");
|
||||||
|
}
|
||||||
|
this.#noRetry();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
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 = /* @__PURE__ */ __name((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);
|
||||||
|
}, "#fetchDispatcher");
|
||||||
|
#dispatcher = /* @__PURE__ */ __name((type, init) => {
|
||||||
|
if (type === "scheduled" && super.scheduled !== void 0) {
|
||||||
|
const controller = new __Facade_ScheduledController__(
|
||||||
|
Date.now(),
|
||||||
|
init.cron ?? "",
|
||||||
|
() => {
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return super.scheduled(controller);
|
||||||
|
}
|
||||||
|
}, "#dispatcher");
|
||||||
|
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=%5B%5Bpath%5D%5D.js.map
|
||||||
8
.wrangler/tmp/dev-1YRfaC/[[path]].js.map
Normal file
8
.wrangler/tmp/dev-1YRfaC/[[path]].js.map
Normal file
File diff suppressed because one or more lines are too long
230
.wrangler/tmp/dev-2s8pio/[[path]].js
Normal file
230
.wrangler/tmp/dev-2s8pio/[[path]].js
Normal file
@@ -0,0 +1,230 @@
|
|||||||
|
var __defProp = Object.defineProperty;
|
||||||
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||||
|
|
||||||
|
// .wrangler/tmp/bundle-Oml82W/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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// functions/[[path]].ts
|
||||||
|
var path_default = {
|
||||||
|
fetch: /* @__PURE__ */ __name((request, env, ctx) => {
|
||||||
|
console.log("Basic Worker fetch called:", request.method, request.url);
|
||||||
|
const url = new URL(request.url);
|
||||||
|
if (url.pathname === "/") {
|
||||||
|
return new Response("Pixiv Now Worker is running!", {
|
||||||
|
headers: { "Content-Type": "text/plain" }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (url.pathname === "/test") {
|
||||||
|
return new Response(JSON.stringify({
|
||||||
|
message: "Test successful",
|
||||||
|
timestamp: Date.now(),
|
||||||
|
method: request.method,
|
||||||
|
path: url.pathname
|
||||||
|
}), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return new Response("Not Found", {
|
||||||
|
status: 404,
|
||||||
|
headers: { "Content-Type": "text/plain" }
|
||||||
|
});
|
||||||
|
}, "fetch")
|
||||||
|
};
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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@4.42.1/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-Oml82W/middleware-insertion-facade.js
|
||||||
|
var __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
middleware_ensure_req_body_drained_default,
|
||||||
|
middleware_miniflare3_json_error_default
|
||||||
|
];
|
||||||
|
var middleware_insertion_facade_default = path_default;
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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-Oml82W/middleware-loader.entry.ts
|
||||||
|
var __Facade_ScheduledController__ = class ___Facade_ScheduledController__ {
|
||||||
|
constructor(scheduledTime, cron, noRetry) {
|
||||||
|
this.scheduledTime = scheduledTime;
|
||||||
|
this.cron = cron;
|
||||||
|
this.#noRetry = noRetry;
|
||||||
|
}
|
||||||
|
static {
|
||||||
|
__name(this, "__Facade_ScheduledController__");
|
||||||
|
}
|
||||||
|
#noRetry;
|
||||||
|
noRetry() {
|
||||||
|
if (!(this instanceof ___Facade_ScheduledController__)) {
|
||||||
|
throw new TypeError("Illegal invocation");
|
||||||
|
}
|
||||||
|
this.#noRetry();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
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 = /* @__PURE__ */ __name((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);
|
||||||
|
}, "#fetchDispatcher");
|
||||||
|
#dispatcher = /* @__PURE__ */ __name((type, init) => {
|
||||||
|
if (type === "scheduled" && super.scheduled !== void 0) {
|
||||||
|
const controller = new __Facade_ScheduledController__(
|
||||||
|
Date.now(),
|
||||||
|
init.cron ?? "",
|
||||||
|
() => {
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return super.scheduled(controller);
|
||||||
|
}
|
||||||
|
}, "#dispatcher");
|
||||||
|
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=%5B%5Bpath%5D%5D.js.map
|
||||||
8
.wrangler/tmp/dev-2s8pio/[[path]].js.map
Normal file
8
.wrangler/tmp/dev-2s8pio/[[path]].js.map
Normal file
File diff suppressed because one or more lines are too long
407
.wrangler/tmp/dev-8ou9Jm/[[path]].js
Normal file
407
.wrangler/tmp/dev-8ou9Jm/[[path]].js
Normal file
@@ -0,0 +1,407 @@
|
|||||||
|
var __defProp = Object.defineProperty;
|
||||||
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||||
|
|
||||||
|
// .wrangler/tmp/bundle-P1vEyM/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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// functions/[[path]].ts
|
||||||
|
function corsHeaders() {
|
||||||
|
return {
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
|
||||||
|
"Access-Control-Allow-Headers": "Content-Type, Authorization, X-Requested-With",
|
||||||
|
"Access-Control-Max-Age": "86400"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
__name(corsHeaders, "corsHeaders");
|
||||||
|
function corsResponse(response) {
|
||||||
|
const headers = new Headers(response.headers);
|
||||||
|
Object.entries(corsHeaders()).forEach(([key, value]) => {
|
||||||
|
headers.set(key, value);
|
||||||
|
});
|
||||||
|
return new Response(response.body, {
|
||||||
|
status: response.status,
|
||||||
|
statusText: response.statusText,
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
}
|
||||||
|
__name(corsResponse, "corsResponse");
|
||||||
|
var path_default = {
|
||||||
|
fetch: /* @__PURE__ */ __name(async (request, env, ctx) => {
|
||||||
|
console.log("Worker fetch called:", request.method, request.url);
|
||||||
|
const url = new URL(request.url);
|
||||||
|
const path = url.pathname;
|
||||||
|
if (request.method === "OPTIONS") {
|
||||||
|
return new Response(null, {
|
||||||
|
status: 200,
|
||||||
|
headers: corsHeaders()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (path === "/") {
|
||||||
|
return corsResponse(new Response("Pixiv Now Worker is running!", {
|
||||||
|
headers: { "Content-Type": "text/plain" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (path === "/test") {
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
message: "Test successful",
|
||||||
|
timestamp: Date.now(),
|
||||||
|
method: request.method,
|
||||||
|
path
|
||||||
|
}), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (path === "/api/illust/random") {
|
||||||
|
return await handleRandomAPI(request, env, url);
|
||||||
|
}
|
||||||
|
if (path.match(/^\/(ajax|rpc)\//)) {
|
||||||
|
return await handleGenericProxy(request, env);
|
||||||
|
}
|
||||||
|
if (path.match(/^\/[~-]\//)) {
|
||||||
|
return await handleImageProxy(request, env);
|
||||||
|
}
|
||||||
|
if (path === "/api/user") {
|
||||||
|
return await handleUserAPI(request, env, url);
|
||||||
|
}
|
||||||
|
return corsResponse(new Response("Not Found", {
|
||||||
|
status: 404,
|
||||||
|
headers: { "Content-Type": "text/plain" }
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Worker error:", error);
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}, "fetch")
|
||||||
|
};
|
||||||
|
async function handleRandomAPI(request, env, url) {
|
||||||
|
try {
|
||||||
|
const requestImage = (request.headers.get("accept")?.includes("image") || url.searchParams.get("format") === "image") && url.searchParams.get("format") !== "json";
|
||||||
|
const mockIllusts = [
|
||||||
|
{
|
||||||
|
id: "123456789",
|
||||||
|
title: "Test Illustration",
|
||||||
|
userId: "987654321",
|
||||||
|
userName: "Test Artist",
|
||||||
|
tags: ["test", "mock"],
|
||||||
|
updateDate: "2024-01-01T12:00:00+00:00",
|
||||||
|
urls: {
|
||||||
|
mini: "https://i.pximg.net/c/48x48/img-master/img/2024/01/01/12/00/00/123456789_p0_square1200.jpg",
|
||||||
|
thumb: "https://i.pximg.net/c/250x250_80_a2/img-master/img/2024/01/01/12/00/00/123456789_p0_square1200.jpg",
|
||||||
|
small: "https://i.pximg.net/c/540x540_70/img-master/img/2024/01/01/12/00/00/123456789_p0_master1200.jpg",
|
||||||
|
regular: "https://i.pximg.net/img-master/img/2024/01/01/12/00/00/123456789_p0_master1200.jpg",
|
||||||
|
original: "https://i.pximg.net/img-original/img/2024/01/01/12/00/00/123456789_p0.jpg"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
if (requestImage && mockIllusts[0]?.urls?.regular) {
|
||||||
|
return corsResponse(new Response(null, {
|
||||||
|
status: 302,
|
||||||
|
headers: { Location: mockIllusts[0].urls.regular }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
return corsResponse(new Response(JSON.stringify(mockIllusts), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in random API:", error);
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__name(handleRandomAPI, "handleRandomAPI");
|
||||||
|
async function handleGenericProxy(request, env) {
|
||||||
|
const url = new URL(request.url);
|
||||||
|
url.hostname = "www.pixiv.net";
|
||||||
|
const headers = new Headers(request.headers);
|
||||||
|
headers.set("origin", "https://www.pixiv.net");
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
method: request.method,
|
||||||
|
headers,
|
||||||
|
body: request.body
|
||||||
|
});
|
||||||
|
const response = await fetch(newReq);
|
||||||
|
return corsResponse(response);
|
||||||
|
}
|
||||||
|
__name(handleGenericProxy, "handleGenericProxy");
|
||||||
|
async function handleImageProxy(request, env) {
|
||||||
|
const url = new URL(request.url);
|
||||||
|
const path = url.pathname.slice(2);
|
||||||
|
if (url.pathname.startsWith("/~")) {
|
||||||
|
if (env.VITE_PXIMG_BASEURL_S) {
|
||||||
|
url.href = env.VITE_PXIMG_BASEURL_S + path;
|
||||||
|
} else {
|
||||||
|
url.hostname = "s.pximg.net";
|
||||||
|
url.pathname = "/" + path;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (env.VITE_PXIMG_BASEURL_I) {
|
||||||
|
url.href = env.VITE_PXIMG_BASEURL_I + path;
|
||||||
|
} else {
|
||||||
|
url.hostname = "i.pximg.net";
|
||||||
|
url.pathname = "/" + path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const headers = new Headers();
|
||||||
|
for (const h of ["accept", "accept-encoding", "accept-language", "cache-control", "user-agent"]) {
|
||||||
|
if (request.headers.get(h)) {
|
||||||
|
headers.set(h, request.headers.get(h));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
const response = await fetch(newReq);
|
||||||
|
return corsResponse(response);
|
||||||
|
}
|
||||||
|
__name(handleImageProxy, "handleImageProxy");
|
||||||
|
async function handleUserAPI(request, env, url) {
|
||||||
|
try {
|
||||||
|
const userId = url.searchParams.get("id");
|
||||||
|
if (!userId) {
|
||||||
|
return corsResponse(new Response(JSON.stringify({ error: "User ID is required" }), {
|
||||||
|
status: 400,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
const pixivUrl = new URL(`https://www.pixiv.net/ajax/user/${userId}`);
|
||||||
|
const headers = new Headers();
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const response = await fetch(pixivUrl.toString(), { headers });
|
||||||
|
if (!response.ok) {
|
||||||
|
return corsResponse(new Response(JSON.stringify({ error: `Pixiv API returned ${response.status}` }), {
|
||||||
|
status: response.status,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
const data = await response.json();
|
||||||
|
return corsResponse(new Response(JSON.stringify(data), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in user API:", error);
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__name(handleUserAPI, "handleUserAPI");
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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@4.42.1/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-P1vEyM/middleware-insertion-facade.js
|
||||||
|
var __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
middleware_ensure_req_body_drained_default,
|
||||||
|
middleware_miniflare3_json_error_default
|
||||||
|
];
|
||||||
|
var middleware_insertion_facade_default = path_default;
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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-P1vEyM/middleware-loader.entry.ts
|
||||||
|
var __Facade_ScheduledController__ = class ___Facade_ScheduledController__ {
|
||||||
|
constructor(scheduledTime, cron, noRetry) {
|
||||||
|
this.scheduledTime = scheduledTime;
|
||||||
|
this.cron = cron;
|
||||||
|
this.#noRetry = noRetry;
|
||||||
|
}
|
||||||
|
static {
|
||||||
|
__name(this, "__Facade_ScheduledController__");
|
||||||
|
}
|
||||||
|
#noRetry;
|
||||||
|
noRetry() {
|
||||||
|
if (!(this instanceof ___Facade_ScheduledController__)) {
|
||||||
|
throw new TypeError("Illegal invocation");
|
||||||
|
}
|
||||||
|
this.#noRetry();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
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 = /* @__PURE__ */ __name((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);
|
||||||
|
}, "#fetchDispatcher");
|
||||||
|
#dispatcher = /* @__PURE__ */ __name((type, init) => {
|
||||||
|
if (type === "scheduled" && super.scheduled !== void 0) {
|
||||||
|
const controller = new __Facade_ScheduledController__(
|
||||||
|
Date.now(),
|
||||||
|
init.cron ?? "",
|
||||||
|
() => {
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return super.scheduled(controller);
|
||||||
|
}
|
||||||
|
}, "#dispatcher");
|
||||||
|
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=%5B%5Bpath%5D%5D.js.map
|
||||||
8
.wrangler/tmp/dev-8ou9Jm/[[path]].js.map
Normal file
8
.wrangler/tmp/dev-8ou9Jm/[[path]].js.map
Normal file
File diff suppressed because one or more lines are too long
407
.wrangler/tmp/dev-CARoER/[[path]].js
Normal file
407
.wrangler/tmp/dev-CARoER/[[path]].js
Normal file
@@ -0,0 +1,407 @@
|
|||||||
|
var __defProp = Object.defineProperty;
|
||||||
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||||
|
|
||||||
|
// .wrangler/tmp/bundle-BPqujt/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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// functions/[[path]].ts
|
||||||
|
function corsHeaders() {
|
||||||
|
return {
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
|
||||||
|
"Access-Control-Allow-Headers": "Content-Type, Authorization, X-Requested-With",
|
||||||
|
"Access-Control-Max-Age": "86400"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
__name(corsHeaders, "corsHeaders");
|
||||||
|
function corsResponse(response) {
|
||||||
|
const headers = new Headers(response.headers);
|
||||||
|
Object.entries(corsHeaders()).forEach(([key, value]) => {
|
||||||
|
headers.set(key, value);
|
||||||
|
});
|
||||||
|
return new Response(response.body, {
|
||||||
|
status: response.status,
|
||||||
|
statusText: response.statusText,
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
}
|
||||||
|
__name(corsResponse, "corsResponse");
|
||||||
|
var path_default = {
|
||||||
|
fetch: /* @__PURE__ */ __name(async (request, env, ctx) => {
|
||||||
|
console.log("Worker fetch called:", request.method, request.url);
|
||||||
|
const url = new URL(request.url);
|
||||||
|
const path = url.pathname;
|
||||||
|
if (request.method === "OPTIONS") {
|
||||||
|
return new Response(null, {
|
||||||
|
status: 200,
|
||||||
|
headers: corsHeaders()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (path === "/") {
|
||||||
|
return corsResponse(new Response("Pixiv Now Worker is running!", {
|
||||||
|
headers: { "Content-Type": "text/plain" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (path === "/test") {
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
message: "Test successful",
|
||||||
|
timestamp: Date.now(),
|
||||||
|
method: request.method,
|
||||||
|
path
|
||||||
|
}), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (path === "/api/illust/random") {
|
||||||
|
return await handleRandomAPI(request, env, url);
|
||||||
|
}
|
||||||
|
if (path.match(/^\/(ajax|rpc)\//)) {
|
||||||
|
return await handleGenericProxy(request, env);
|
||||||
|
}
|
||||||
|
if (path.match(/^\/[~-]\//)) {
|
||||||
|
return await handleImageProxy(request, env);
|
||||||
|
}
|
||||||
|
if (path === "/api/user") {
|
||||||
|
return await handleUserAPI(request, env, url);
|
||||||
|
}
|
||||||
|
return corsResponse(new Response("Not Found", {
|
||||||
|
status: 404,
|
||||||
|
headers: { "Content-Type": "text/plain" }
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Worker error:", error);
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}, "fetch")
|
||||||
|
};
|
||||||
|
async function handleRandomAPI(request, env, url) {
|
||||||
|
try {
|
||||||
|
const requestImage = (request.headers.get("accept")?.includes("image") || url.searchParams.get("format") === "image") && url.searchParams.get("format") !== "json";
|
||||||
|
const mockIllusts = [
|
||||||
|
{
|
||||||
|
id: "123456789",
|
||||||
|
title: "Test Illustration",
|
||||||
|
userId: "987654321",
|
||||||
|
userName: "Test Artist",
|
||||||
|
tags: ["test", "mock"],
|
||||||
|
updateDate: "2024-01-01T12:00:00+00:00",
|
||||||
|
urls: {
|
||||||
|
mini: "https://i.pximg.net/c/48x48/img-master/img/2024/01/01/12/00/00/123456789_p0_square1200.jpg",
|
||||||
|
thumb: "https://i.pximg.net/c/250x250_80_a2/img-master/img/2024/01/01/12/00/00/123456789_p0_square1200.jpg",
|
||||||
|
small: "https://i.pximg.net/c/540x540_70/img-master/img/2024/01/01/12/00/00/123456789_p0_master1200.jpg",
|
||||||
|
regular: "https://i.pximg.net/img-master/img/2024/01/01/12/00/00/123456789_p0_master1200.jpg",
|
||||||
|
original: "https://i.pximg.net/img-original/img/2024/01/01/12/00/00/123456789_p0.jpg"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
if (requestImage && mockIllusts[0]?.urls?.regular) {
|
||||||
|
return corsResponse(new Response(null, {
|
||||||
|
status: 302,
|
||||||
|
headers: { Location: mockIllusts[0].urls.regular }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
return corsResponse(new Response(JSON.stringify(mockIllusts), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in random API:", error);
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__name(handleRandomAPI, "handleRandomAPI");
|
||||||
|
async function handleGenericProxy(request, env) {
|
||||||
|
const url = new URL(request.url);
|
||||||
|
url.hostname = "www.pixiv.net";
|
||||||
|
const headers = new Headers(request.headers);
|
||||||
|
headers.set("origin", "https://www.pixiv.net");
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
method: request.method,
|
||||||
|
headers,
|
||||||
|
body: request.body
|
||||||
|
});
|
||||||
|
const response = await fetch(newReq);
|
||||||
|
return corsResponse(response);
|
||||||
|
}
|
||||||
|
__name(handleGenericProxy, "handleGenericProxy");
|
||||||
|
async function handleImageProxy(request, env) {
|
||||||
|
const url = new URL(request.url);
|
||||||
|
const path = url.pathname.slice(2);
|
||||||
|
if (url.pathname.startsWith("/~")) {
|
||||||
|
if (env.VITE_PXIMG_BASEURL_S) {
|
||||||
|
url.href = env.VITE_PXIMG_BASEURL_S + path;
|
||||||
|
} else {
|
||||||
|
url.hostname = "s.pximg.net";
|
||||||
|
url.pathname = "/" + path;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (env.VITE_PXIMG_BASEURL_I) {
|
||||||
|
url.href = env.VITE_PXIMG_BASEURL_I + path;
|
||||||
|
} else {
|
||||||
|
url.hostname = "i.pximg.net";
|
||||||
|
url.pathname = "/" + path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const headers = new Headers();
|
||||||
|
for (const h of ["accept", "accept-encoding", "accept-language", "cache-control", "user-agent"]) {
|
||||||
|
if (request.headers.get(h)) {
|
||||||
|
headers.set(h, request.headers.get(h));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
const response = await fetch(newReq);
|
||||||
|
return corsResponse(response);
|
||||||
|
}
|
||||||
|
__name(handleImageProxy, "handleImageProxy");
|
||||||
|
async function handleUserAPI(request, env, url) {
|
||||||
|
try {
|
||||||
|
const userId = url.searchParams.get("id");
|
||||||
|
if (!userId) {
|
||||||
|
return corsResponse(new Response(JSON.stringify({ error: "User ID is required" }), {
|
||||||
|
status: 400,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
const pixivUrl = new URL(`https://www.pixiv.net/ajax/user/${userId}`);
|
||||||
|
const headers = new Headers();
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const response = await fetch(pixivUrl.toString(), { headers });
|
||||||
|
if (!response.ok) {
|
||||||
|
return corsResponse(new Response(JSON.stringify({ error: `Pixiv API returned ${response.status}` }), {
|
||||||
|
status: response.status,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
const data = await response.json();
|
||||||
|
return corsResponse(new Response(JSON.stringify(data), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in user API:", error);
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__name(handleUserAPI, "handleUserAPI");
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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@4.42.1/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-BPqujt/middleware-insertion-facade.js
|
||||||
|
var __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
middleware_ensure_req_body_drained_default,
|
||||||
|
middleware_miniflare3_json_error_default
|
||||||
|
];
|
||||||
|
var middleware_insertion_facade_default = path_default;
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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-BPqujt/middleware-loader.entry.ts
|
||||||
|
var __Facade_ScheduledController__ = class ___Facade_ScheduledController__ {
|
||||||
|
constructor(scheduledTime, cron, noRetry) {
|
||||||
|
this.scheduledTime = scheduledTime;
|
||||||
|
this.cron = cron;
|
||||||
|
this.#noRetry = noRetry;
|
||||||
|
}
|
||||||
|
static {
|
||||||
|
__name(this, "__Facade_ScheduledController__");
|
||||||
|
}
|
||||||
|
#noRetry;
|
||||||
|
noRetry() {
|
||||||
|
if (!(this instanceof ___Facade_ScheduledController__)) {
|
||||||
|
throw new TypeError("Illegal invocation");
|
||||||
|
}
|
||||||
|
this.#noRetry();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
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 = /* @__PURE__ */ __name((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);
|
||||||
|
}, "#fetchDispatcher");
|
||||||
|
#dispatcher = /* @__PURE__ */ __name((type, init) => {
|
||||||
|
if (type === "scheduled" && super.scheduled !== void 0) {
|
||||||
|
const controller = new __Facade_ScheduledController__(
|
||||||
|
Date.now(),
|
||||||
|
init.cron ?? "",
|
||||||
|
() => {
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return super.scheduled(controller);
|
||||||
|
}
|
||||||
|
}, "#dispatcher");
|
||||||
|
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=%5B%5Bpath%5D%5D.js.map
|
||||||
8
.wrangler/tmp/dev-CARoER/[[path]].js.map
Normal file
8
.wrangler/tmp/dev-CARoER/[[path]].js.map
Normal file
File diff suppressed because one or more lines are too long
441
.wrangler/tmp/dev-FoKuMg/[[path]].js
Normal file
441
.wrangler/tmp/dev-FoKuMg/[[path]].js
Normal file
@@ -0,0 +1,441 @@
|
|||||||
|
var __defProp = Object.defineProperty;
|
||||||
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||||
|
|
||||||
|
// .wrangler/tmp/bundle-ikDXAQ/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/itty-router@5.0.22/node_modules/itty-router/index.mjs
|
||||||
|
var t = /* @__PURE__ */ __name(({ base: e = "", routes: t2 = [], ...r2 } = {}) => ({ __proto__: new Proxy({}, { get: /* @__PURE__ */ __name((r3, o2, a, s) => (r4, ...c) => t2.push([o2.toUpperCase?.(), RegExp(`^${(s = (e + r4).replace(/\/+(\/|$)/g, "$1")).replace(/(\/?\.?):(\w+)\+/g, "($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g, "($1(?<$2>[^$1/]+?))").replace(/\./g, "\\.").replace(/(\/?)\*/g, "($1.*)?")}/*$`), c, s]) && a, "get") }), routes: t2, ...r2, async fetch(e2, ...o2) {
|
||||||
|
let a, s, c = new URL(e2.url), n = e2.query = { __proto__: null };
|
||||||
|
for (let [e3, t3] of c.searchParams) n[e3] = n[e3] ? [].concat(n[e3], t3) : t3;
|
||||||
|
e: try {
|
||||||
|
for (let t3 of r2.before || []) if (null != (a = await t3(e2.proxy ?? e2, ...o2))) break e;
|
||||||
|
t: for (let [r3, n2, l, i] of t2) if ((r3 == e2.method || "ALL" == r3) && (s = c.pathname.match(n2))) {
|
||||||
|
e2.params = s.groups || {}, e2.route = i;
|
||||||
|
for (let t3 of l) if (null != (a = await t3(e2.proxy ?? e2, ...o2))) break t;
|
||||||
|
}
|
||||||
|
} catch (t3) {
|
||||||
|
if (!r2.catch) throw t3;
|
||||||
|
a = await r2.catch(t3, e2.proxy ?? e2, ...o2);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
for (let t3 of r2.finally || []) a = await t3(a, e2.proxy ?? e2, ...o2) ?? a;
|
||||||
|
} catch (t3) {
|
||||||
|
if (!r2.catch) throw t3;
|
||||||
|
a = await r2.catch(t3, e2.proxy ?? e2, ...o2);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
} }), "t");
|
||||||
|
var r = /* @__PURE__ */ __name((e = "text/plain; charset=utf-8", t2) => (r2, o2 = {}) => {
|
||||||
|
if (void 0 === r2 || r2 instanceof Response) return r2;
|
||||||
|
const a = new Response(t2?.(r2) ?? r2, o2.url ? void 0 : o2);
|
||||||
|
return a.headers.set("content-type", e), a;
|
||||||
|
}, "r");
|
||||||
|
var o = r("application/json; charset=utf-8", JSON.stringify);
|
||||||
|
var p = r("text/plain; charset=utf-8", String);
|
||||||
|
var f = r("text/html");
|
||||||
|
var u = r("image/jpeg");
|
||||||
|
var h = r("image/png");
|
||||||
|
var g = r("image/webp");
|
||||||
|
var y = /* @__PURE__ */ __name((e = {}) => {
|
||||||
|
const { origin: t2 = "*", credentials: r2 = false, allowMethods: o2 = "*", allowHeaders: a, exposeHeaders: s, maxAge: c } = e, n = /* @__PURE__ */ __name((e2) => {
|
||||||
|
const o3 = e2?.headers.get("origin");
|
||||||
|
return true === t2 ? o3 : t2 instanceof RegExp ? t2.test(o3) ? o3 : void 0 : Array.isArray(t2) ? t2.includes(o3) ? o3 : void 0 : t2 instanceof Function ? t2(o3) : "*" == t2 && r2 ? o3 : t2;
|
||||||
|
}, "n"), l = /* @__PURE__ */ __name((e2, t3) => {
|
||||||
|
for (const [r3, o3] of Object.entries(t3)) o3 && e2.headers.append(r3, o3);
|
||||||
|
return e2;
|
||||||
|
}, "l");
|
||||||
|
return { corsify: /* @__PURE__ */ __name((e2, t3) => e2?.headers?.get("access-control-allow-origin") || 101 == e2.status ? e2 : l(e2.clone(), { "access-control-allow-origin": n(t3), "access-control-allow-credentials": r2 }), "corsify"), preflight: /* @__PURE__ */ __name((e2) => {
|
||||||
|
if ("OPTIONS" == e2.method) {
|
||||||
|
const t3 = new Response(null, { status: 204 });
|
||||||
|
return l(t3, { "access-control-allow-origin": n(e2), "access-control-allow-methods": o2?.join?.(",") ?? o2, "access-control-expose-headers": s?.join?.(",") ?? s, "access-control-allow-headers": a?.join?.(",") ?? a ?? e2.headers.get("access-control-request-headers"), "access-control-max-age": c, "access-control-allow-credentials": r2 });
|
||||||
|
}
|
||||||
|
}, "preflight") };
|
||||||
|
}, "y");
|
||||||
|
|
||||||
|
// functions/[[path]].ts
|
||||||
|
var { preflight, corsify } = y();
|
||||||
|
var router = t();
|
||||||
|
router.all("/*", preflight);
|
||||||
|
router.all("/(ajax|rpc)/:path+", async (req, env) => {
|
||||||
|
const url = new URL(req.url);
|
||||||
|
url.hostname = "www.pixiv.net";
|
||||||
|
const headers = new Headers(req.headers);
|
||||||
|
headers.set("origin", "https://www.pixiv.net");
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
method: req.method,
|
||||||
|
headers,
|
||||||
|
body: req.body
|
||||||
|
});
|
||||||
|
return fetch(newReq);
|
||||||
|
});
|
||||||
|
router.all("/(~|-)/:path+", async (req, env) => {
|
||||||
|
const url = new URL(req.url);
|
||||||
|
const prefix = url.pathname.split("/")[1];
|
||||||
|
switch (prefix) {
|
||||||
|
case "-":
|
||||||
|
url.hostname = "i.pximg.net";
|
||||||
|
break;
|
||||||
|
case "~":
|
||||||
|
url.hostname = "s.pximg.net";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return new Response("Invalid request", { status: 400 });
|
||||||
|
}
|
||||||
|
url.pathname = url.pathname.substring(prefix.length + 1);
|
||||||
|
const headers = new Headers();
|
||||||
|
const proxyHeaders = [
|
||||||
|
"accept",
|
||||||
|
"accept-encoding",
|
||||||
|
"accept-language",
|
||||||
|
"range",
|
||||||
|
"if-range",
|
||||||
|
"if-none-match",
|
||||||
|
"if-modified-since",
|
||||||
|
"cache-control"
|
||||||
|
];
|
||||||
|
for (const h2 of proxyHeaders) {
|
||||||
|
if (req.headers.has(h2)) {
|
||||||
|
headers.set(h2, req.headers.get(h2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
return fetch(newReq);
|
||||||
|
});
|
||||||
|
router.all("/api/illust/random", async (req, env) => {
|
||||||
|
try {
|
||||||
|
const url = new URL(req.url);
|
||||||
|
const requestImage = (req.headers.get("accept")?.includes("image") || url.searchParams.get("format") === "image") && url.searchParams.get("format") !== "json";
|
||||||
|
const pixivUrl = new URL("https://www.pixiv.net/ajax/illust/discovery");
|
||||||
|
pixivUrl.searchParams.set("mode", url.searchParams.get("mode") ?? "safe");
|
||||||
|
pixivUrl.searchParams.set("max", requestImage ? "1" : url.searchParams.get("max") ?? "18");
|
||||||
|
const headers = new Headers();
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const response = await fetch(pixivUrl.toString(), { headers });
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`Pixiv API returned ${response.status}`);
|
||||||
|
}
|
||||||
|
const data = await response.json();
|
||||||
|
const illusts = (data.illusts ?? []).filter(
|
||||||
|
(value) => Object.keys(value).includes("id")
|
||||||
|
);
|
||||||
|
if (illusts.length === 0) {
|
||||||
|
return new Response(JSON.stringify([]), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const PXIMG_BASEURL_I = (env.VITE_PXIMG_BASEURL_I || "https://i.pximg.net/").replace(/\/$/, "") + "/";
|
||||||
|
illusts.forEach((value) => {
|
||||||
|
try {
|
||||||
|
const updateDate = new Date(value.updateDate);
|
||||||
|
const tokyoTime = new Date(updateDate.getTime() + 9 * 60 * 60 * 1e3);
|
||||||
|
const year = tokyoTime.getUTCFullYear();
|
||||||
|
const month = String(tokyoTime.getUTCMonth() + 1).padStart(2, "0");
|
||||||
|
const day = String(tokyoTime.getUTCDate()).padStart(2, "0");
|
||||||
|
const hour = String(tokyoTime.getUTCHours()).padStart(2, "0");
|
||||||
|
const minute = String(tokyoTime.getUTCMinutes()).padStart(2, "0");
|
||||||
|
const second = String(tokyoTime.getUTCSeconds()).padStart(2, "0");
|
||||||
|
const middle = `img/${year}/${month}/${day}/${hour}/${minute}/${second}/${value.id}`;
|
||||||
|
value.urls = {
|
||||||
|
mini: `${PXIMG_BASEURL_I}c/48x48/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
thumb: `${PXIMG_BASEURL_I}c/250x250_80_a2/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
small: `${PXIMG_BASEURL_I}c/540x540_70/img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
regular: `${PXIMG_BASEURL_I}img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
original: `${PXIMG_BASEURL_I}img-original/${middle}_p0.jpg`
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error formatting date for illust:", value.id, error);
|
||||||
|
value.urls = {
|
||||||
|
mini: `${PXIMG_BASEURL_I}c/48x48/img-master/img/2024/01/01/00/00/00/${value.id}_p0_square1200.jpg`,
|
||||||
|
thumb: `${PXIMG_BASEURL_I}c/250x250_80_a2/img-master/img/2024/01/01/00/00/00/${value.id}_p0_square1200.jpg`,
|
||||||
|
small: `${PXIMG_BASEURL_I}c/540x540_70/img-master/img/2024/01/01/00/00/00/${value.id}_p0_master1200.jpg`,
|
||||||
|
regular: `${PXIMG_BASEURL_I}img-master/img/2024/01/01/00/00/00/${value.id}_p0_master1200.jpg`,
|
||||||
|
original: `${PXIMG_BASEURL_I}img-original/img/2024/01/01/00/00/00/${value.id}_p0.jpg`
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (requestImage) {
|
||||||
|
return new Response(null, {
|
||||||
|
status: 302,
|
||||||
|
headers: { Location: illusts[0].urls.regular }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return new Response(JSON.stringify(illusts), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in random API:", error);
|
||||||
|
return new Response(JSON.stringify({ error: "Internal server error" }), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
router.all("/api/user", async (req, env) => {
|
||||||
|
const token = req.headers.get("cookie")?.match(/PHPSESSID=([^;]+)/)?.[1] || new URL(req.url).searchParams.get("token");
|
||||||
|
if (!token) {
|
||||||
|
return new Response(JSON.stringify({ message: "\u672A\u914D\u7F6E\u7528\u6237\u5BC6\u94A5" }), { status: 403, headers: { "Content-Type": "application/json" } });
|
||||||
|
}
|
||||||
|
const url = new URL(req.url);
|
||||||
|
url.hostname = "www.pixiv.net";
|
||||||
|
url.pathname = "/";
|
||||||
|
const headers = new Headers(req.headers);
|
||||||
|
headers.set("cookie", `PHPSESSID=${token}`);
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
const res = await fetch(newReq);
|
||||||
|
const text = await res.text();
|
||||||
|
let meta = null;
|
||||||
|
class MetaHandler {
|
||||||
|
constructor(type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
static {
|
||||||
|
__name(this, "MetaHandler");
|
||||||
|
}
|
||||||
|
text(chunk) {
|
||||||
|
try {
|
||||||
|
if (this.type === "legacy") {
|
||||||
|
const data = JSON.parse(chunk.text);
|
||||||
|
meta = {
|
||||||
|
userData: data.userData,
|
||||||
|
token: data.token || ""
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const nextData = JSON.parse(chunk.text);
|
||||||
|
const perloadState = JSON.parse(
|
||||||
|
nextData?.props?.pageProps?.serverSerializedPreloadedState
|
||||||
|
);
|
||||||
|
meta = {
|
||||||
|
userData: perloadState?.userData?.self,
|
||||||
|
token: perloadState?.api?.token || ""
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Error parsing meta", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const rewriter = new HTMLRewriter().on('meta[name="global-data"]', new MetaHandler("legacy")).on("script#__NEXT_DATA__", new MetaHandler("next"));
|
||||||
|
await rewriter.transform(new Response(text)).text();
|
||||||
|
if (!meta || !meta.userData) {
|
||||||
|
return new Response(JSON.stringify({ message: "\u65E0\u6CD5\u83B7\u53D6\u767B\u5F55\u72B6\u6001" }), { status: 401, headers: { "Content-Type": "application/json" } });
|
||||||
|
}
|
||||||
|
const responseHeaders = new Headers({
|
||||||
|
"cache-control": "no-cache",
|
||||||
|
"set-cookie": `CSRFTOKEN=${meta.token}; path=/; secure; sameSite=Lax`,
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
});
|
||||||
|
return new Response(JSON.stringify(meta), { headers: responseHeaders });
|
||||||
|
});
|
||||||
|
var path_default = {
|
||||||
|
fetch: /* @__PURE__ */ __name((req, env, ctx) => router.handle(req, env, ctx).then(corsify).catch((err) => {
|
||||||
|
console.error(err);
|
||||||
|
return new Response("Internal Server Error", { status: 500 });
|
||||||
|
}), "fetch")
|
||||||
|
};
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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@4.42.1/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-ikDXAQ/middleware-insertion-facade.js
|
||||||
|
var __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
middleware_ensure_req_body_drained_default,
|
||||||
|
middleware_miniflare3_json_error_default
|
||||||
|
];
|
||||||
|
var middleware_insertion_facade_default = path_default;
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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-ikDXAQ/middleware-loader.entry.ts
|
||||||
|
var __Facade_ScheduledController__ = class ___Facade_ScheduledController__ {
|
||||||
|
constructor(scheduledTime, cron, noRetry) {
|
||||||
|
this.scheduledTime = scheduledTime;
|
||||||
|
this.cron = cron;
|
||||||
|
this.#noRetry = noRetry;
|
||||||
|
}
|
||||||
|
static {
|
||||||
|
__name(this, "__Facade_ScheduledController__");
|
||||||
|
}
|
||||||
|
#noRetry;
|
||||||
|
noRetry() {
|
||||||
|
if (!(this instanceof ___Facade_ScheduledController__)) {
|
||||||
|
throw new TypeError("Illegal invocation");
|
||||||
|
}
|
||||||
|
this.#noRetry();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
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 = /* @__PURE__ */ __name((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);
|
||||||
|
}, "#fetchDispatcher");
|
||||||
|
#dispatcher = /* @__PURE__ */ __name((type, init) => {
|
||||||
|
if (type === "scheduled" && super.scheduled !== void 0) {
|
||||||
|
const controller = new __Facade_ScheduledController__(
|
||||||
|
Date.now(),
|
||||||
|
init.cron ?? "",
|
||||||
|
() => {
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return super.scheduled(controller);
|
||||||
|
}
|
||||||
|
}, "#dispatcher");
|
||||||
|
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=%5B%5Bpath%5D%5D.js.map
|
||||||
8
.wrangler/tmp/dev-FoKuMg/[[path]].js.map
Normal file
8
.wrangler/tmp/dev-FoKuMg/[[path]].js.map
Normal file
File diff suppressed because one or more lines are too long
443
.wrangler/tmp/dev-J5r0KN/[[path]].js
Normal file
443
.wrangler/tmp/dev-J5r0KN/[[path]].js
Normal file
@@ -0,0 +1,443 @@
|
|||||||
|
var __defProp = Object.defineProperty;
|
||||||
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||||
|
|
||||||
|
// .wrangler/tmp/bundle-sMKHZl/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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// functions/[[path]].ts
|
||||||
|
function corsHeaders() {
|
||||||
|
return {
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
|
||||||
|
"Access-Control-Allow-Headers": "Content-Type, Authorization, X-Requested-With",
|
||||||
|
"Access-Control-Max-Age": "86400"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
__name(corsHeaders, "corsHeaders");
|
||||||
|
function corsResponse(response) {
|
||||||
|
const headers = new Headers(response.headers);
|
||||||
|
Object.entries(corsHeaders()).forEach(([key, value]) => {
|
||||||
|
headers.set(key, value);
|
||||||
|
});
|
||||||
|
return new Response(response.body, {
|
||||||
|
status: response.status,
|
||||||
|
statusText: response.statusText,
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
}
|
||||||
|
__name(corsResponse, "corsResponse");
|
||||||
|
var path_default = {
|
||||||
|
fetch: /* @__PURE__ */ __name(async (request, env, ctx) => {
|
||||||
|
console.log("Worker fetch called:", request.method, request.url);
|
||||||
|
const url = new URL(request.url);
|
||||||
|
const path = url.pathname;
|
||||||
|
if (request.method === "OPTIONS") {
|
||||||
|
return new Response(null, {
|
||||||
|
status: 200,
|
||||||
|
headers: corsHeaders()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (path === "/") {
|
||||||
|
return corsResponse(new Response("Pixiv Now Worker is running!", {
|
||||||
|
headers: { "Content-Type": "text/plain" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (path === "/test") {
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
message: "Test successful",
|
||||||
|
timestamp: Date.now(),
|
||||||
|
method: request.method,
|
||||||
|
path
|
||||||
|
}), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (path === "/api/illust/random") {
|
||||||
|
return await handleRandomAPI(request, env, url);
|
||||||
|
}
|
||||||
|
if (path.match(/^\/(ajax|rpc)\//)) {
|
||||||
|
return await handleGenericProxy(request, env);
|
||||||
|
}
|
||||||
|
if (path.match(/^\/[~-]\//)) {
|
||||||
|
return await handleImageProxy(request, env);
|
||||||
|
}
|
||||||
|
if (path === "/api/user") {
|
||||||
|
return await handleUserAPI(request, env, url);
|
||||||
|
}
|
||||||
|
return corsResponse(new Response("Not Found", {
|
||||||
|
status: 404,
|
||||||
|
headers: { "Content-Type": "text/plain" }
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Worker error:", error);
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}, "fetch")
|
||||||
|
};
|
||||||
|
async function handleRandomAPI(request, env, url) {
|
||||||
|
try {
|
||||||
|
const requestImage = (request.headers.get("accept")?.includes("image") || url.searchParams.get("format") === "image") && url.searchParams.get("format") !== "json";
|
||||||
|
const pixivUrl = new URL("https://www.pixiv.net/ajax/illust/discovery");
|
||||||
|
pixivUrl.searchParams.set("mode", url.searchParams.get("mode") ?? "safe");
|
||||||
|
pixivUrl.searchParams.set("max", requestImage ? "1" : url.searchParams.get("max") ?? "18");
|
||||||
|
const headers = new Headers();
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const response = await fetch(pixivUrl.toString(), { headers });
|
||||||
|
if (!response.ok) {
|
||||||
|
return corsResponse(new Response(JSON.stringify({ error: `Pixiv API returned ${response.status}` }), {
|
||||||
|
status: response.status,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
const data = await response.json();
|
||||||
|
const illusts = (data.illusts ?? []).filter(
|
||||||
|
(value) => value && typeof value === "object" && value.id
|
||||||
|
);
|
||||||
|
if (illusts.length === 0) {
|
||||||
|
return corsResponse(new Response(JSON.stringify([]), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
const PXIMG_BASEURL_I = (env.VITE_PXIMG_BASEURL_I || "https://i.pximg.net/").replace(/\/$/, "") + "/";
|
||||||
|
illusts.forEach((value) => {
|
||||||
|
try {
|
||||||
|
if (value.updateDate) {
|
||||||
|
const date = new Date(value.updateDate);
|
||||||
|
const year = date.getFullYear();
|
||||||
|
const month = String(date.getMonth() + 1).padStart(2, "0");
|
||||||
|
const day = String(date.getDate()).padStart(2, "0");
|
||||||
|
const hour = String(date.getHours()).padStart(2, "0");
|
||||||
|
const minute = String(date.getMinutes()).padStart(2, "0");
|
||||||
|
const second = String(date.getSeconds()).padStart(2, "0");
|
||||||
|
const middle = `img/${year}/${month}/${day}/${hour}/${minute}/${second}/${value.id}`;
|
||||||
|
value.urls = {
|
||||||
|
mini: `${PXIMG_BASEURL_I}c/48x48/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
thumb: `${PXIMG_BASEURL_I}c/250x250_80_a2/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
small: `${PXIMG_BASEURL_I}c/540x540_70/img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
regular: `${PXIMG_BASEURL_I}img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
original: `${PXIMG_BASEURL_I}img-original/${middle}_p0.jpg`
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const middle = `img/2024/01/01/00/00/00/${value.id}`;
|
||||||
|
value.urls = {
|
||||||
|
mini: `${PXIMG_BASEURL_I}c/48x48/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
thumb: `${PXIMG_BASEURL_I}c/250x250_80_a2/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
small: `${PXIMG_BASEURL_I}c/540x540_70/img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
regular: `${PXIMG_BASEURL_I}img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
original: `${PXIMG_BASEURL_I}img-original/${middle}_p0.jpg`
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error processing illust:", value.id, error);
|
||||||
|
const middle = `img/2024/01/01/00/00/00/${value.id}`;
|
||||||
|
value.urls = {
|
||||||
|
mini: `${PXIMG_BASEURL_I}c/48x48/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
thumb: `${PXIMG_BASEURL_I}c/250x250_80_a2/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
small: `${PXIMG_BASEURL_I}c/540x540_70/img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
regular: `${PXIMG_BASEURL_I}img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
original: `${PXIMG_BASEURL_I}img-original/${middle}_p0.jpg`
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (requestImage && illusts[0]?.urls?.regular) {
|
||||||
|
return corsResponse(new Response(null, {
|
||||||
|
status: 302,
|
||||||
|
headers: { Location: illusts[0].urls.regular }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
return corsResponse(new Response(JSON.stringify(illusts), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in random API:", error);
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__name(handleRandomAPI, "handleRandomAPI");
|
||||||
|
async function handleGenericProxy(request, env) {
|
||||||
|
const url = new URL(request.url);
|
||||||
|
url.hostname = "www.pixiv.net";
|
||||||
|
const headers = new Headers(request.headers);
|
||||||
|
headers.set("origin", "https://www.pixiv.net");
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
method: request.method,
|
||||||
|
headers,
|
||||||
|
body: request.body
|
||||||
|
});
|
||||||
|
const response = await fetch(newReq);
|
||||||
|
return corsResponse(response);
|
||||||
|
}
|
||||||
|
__name(handleGenericProxy, "handleGenericProxy");
|
||||||
|
async function handleImageProxy(request, env) {
|
||||||
|
const url = new URL(request.url);
|
||||||
|
const path = url.pathname.slice(2);
|
||||||
|
if (url.pathname.startsWith("/~")) {
|
||||||
|
url.hostname = "i.pximg.net";
|
||||||
|
} else {
|
||||||
|
url.hostname = "s.pximg.net";
|
||||||
|
}
|
||||||
|
url.pathname = "/" + path;
|
||||||
|
const headers = new Headers();
|
||||||
|
for (const h of ["accept", "accept-encoding", "accept-language", "cache-control", "user-agent"]) {
|
||||||
|
if (request.headers.get(h)) {
|
||||||
|
headers.set(h, request.headers.get(h));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
const response = await fetch(newReq);
|
||||||
|
return corsResponse(response);
|
||||||
|
}
|
||||||
|
__name(handleImageProxy, "handleImageProxy");
|
||||||
|
async function handleUserAPI(request, env, url) {
|
||||||
|
try {
|
||||||
|
const userId = url.searchParams.get("id");
|
||||||
|
if (!userId) {
|
||||||
|
return corsResponse(new Response(JSON.stringify({ error: "User ID is required" }), {
|
||||||
|
status: 400,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
const pixivUrl = new URL(`https://www.pixiv.net/ajax/user/${userId}`);
|
||||||
|
const headers = new Headers();
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const response = await fetch(pixivUrl.toString(), { headers });
|
||||||
|
if (!response.ok) {
|
||||||
|
return corsResponse(new Response(JSON.stringify({ error: `Pixiv API returned ${response.status}` }), {
|
||||||
|
status: response.status,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
const data = await response.json();
|
||||||
|
return corsResponse(new Response(JSON.stringify(data), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in user API:", error);
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__name(handleUserAPI, "handleUserAPI");
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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@4.42.1/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-sMKHZl/middleware-insertion-facade.js
|
||||||
|
var __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
middleware_ensure_req_body_drained_default,
|
||||||
|
middleware_miniflare3_json_error_default
|
||||||
|
];
|
||||||
|
var middleware_insertion_facade_default = path_default;
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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-sMKHZl/middleware-loader.entry.ts
|
||||||
|
var __Facade_ScheduledController__ = class ___Facade_ScheduledController__ {
|
||||||
|
constructor(scheduledTime, cron, noRetry) {
|
||||||
|
this.scheduledTime = scheduledTime;
|
||||||
|
this.cron = cron;
|
||||||
|
this.#noRetry = noRetry;
|
||||||
|
}
|
||||||
|
static {
|
||||||
|
__name(this, "__Facade_ScheduledController__");
|
||||||
|
}
|
||||||
|
#noRetry;
|
||||||
|
noRetry() {
|
||||||
|
if (!(this instanceof ___Facade_ScheduledController__)) {
|
||||||
|
throw new TypeError("Illegal invocation");
|
||||||
|
}
|
||||||
|
this.#noRetry();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
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 = /* @__PURE__ */ __name((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);
|
||||||
|
}, "#fetchDispatcher");
|
||||||
|
#dispatcher = /* @__PURE__ */ __name((type, init) => {
|
||||||
|
if (type === "scheduled" && super.scheduled !== void 0) {
|
||||||
|
const controller = new __Facade_ScheduledController__(
|
||||||
|
Date.now(),
|
||||||
|
init.cron ?? "",
|
||||||
|
() => {
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return super.scheduled(controller);
|
||||||
|
}
|
||||||
|
}, "#dispatcher");
|
||||||
|
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=%5B%5Bpath%5D%5D.js.map
|
||||||
8
.wrangler/tmp/dev-J5r0KN/[[path]].js.map
Normal file
8
.wrangler/tmp/dev-J5r0KN/[[path]].js.map
Normal file
File diff suppressed because one or more lines are too long
288
.wrangler/tmp/dev-NuKMFb/[[path]].js
Normal file
288
.wrangler/tmp/dev-NuKMFb/[[path]].js
Normal file
@@ -0,0 +1,288 @@
|
|||||||
|
var __defProp = Object.defineProperty;
|
||||||
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||||
|
|
||||||
|
// .wrangler/tmp/bundle-hVAKjn/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/itty-router@5.0.22/node_modules/itty-router/index.mjs
|
||||||
|
var t = /* @__PURE__ */ __name(({ base: e = "", routes: t2 = [], ...r2 } = {}) => ({ __proto__: new Proxy({}, { get: /* @__PURE__ */ __name((r3, o2, a, s) => (r4, ...c) => t2.push([o2.toUpperCase?.(), RegExp(`^${(s = (e + r4).replace(/\/+(\/|$)/g, "$1")).replace(/(\/?\.?):(\w+)\+/g, "($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g, "($1(?<$2>[^$1/]+?))").replace(/\./g, "\\.").replace(/(\/?)\*/g, "($1.*)?")}/*$`), c, s]) && a, "get") }), routes: t2, ...r2, async fetch(e2, ...o2) {
|
||||||
|
let a, s, c = new URL(e2.url), n = e2.query = { __proto__: null };
|
||||||
|
for (let [e3, t3] of c.searchParams) n[e3] = n[e3] ? [].concat(n[e3], t3) : t3;
|
||||||
|
e: try {
|
||||||
|
for (let t3 of r2.before || []) if (null != (a = await t3(e2.proxy ?? e2, ...o2))) break e;
|
||||||
|
t: for (let [r3, n2, l, i] of t2) if ((r3 == e2.method || "ALL" == r3) && (s = c.pathname.match(n2))) {
|
||||||
|
e2.params = s.groups || {}, e2.route = i;
|
||||||
|
for (let t3 of l) if (null != (a = await t3(e2.proxy ?? e2, ...o2))) break t;
|
||||||
|
}
|
||||||
|
} catch (t3) {
|
||||||
|
if (!r2.catch) throw t3;
|
||||||
|
a = await r2.catch(t3, e2.proxy ?? e2, ...o2);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
for (let t3 of r2.finally || []) a = await t3(a, e2.proxy ?? e2, ...o2) ?? a;
|
||||||
|
} catch (t3) {
|
||||||
|
if (!r2.catch) throw t3;
|
||||||
|
a = await r2.catch(t3, e2.proxy ?? e2, ...o2);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
} }), "t");
|
||||||
|
var r = /* @__PURE__ */ __name((e = "text/plain; charset=utf-8", t2) => (r2, o2 = {}) => {
|
||||||
|
if (void 0 === r2 || r2 instanceof Response) return r2;
|
||||||
|
const a = new Response(t2?.(r2) ?? r2, o2.url ? void 0 : o2);
|
||||||
|
return a.headers.set("content-type", e), a;
|
||||||
|
}, "r");
|
||||||
|
var o = r("application/json; charset=utf-8", JSON.stringify);
|
||||||
|
var p = r("text/plain; charset=utf-8", String);
|
||||||
|
var f = r("text/html");
|
||||||
|
var u = r("image/jpeg");
|
||||||
|
var h = r("image/png");
|
||||||
|
var g = r("image/webp");
|
||||||
|
var y = /* @__PURE__ */ __name((e = {}) => {
|
||||||
|
const { origin: t2 = "*", credentials: r2 = false, allowMethods: o2 = "*", allowHeaders: a, exposeHeaders: s, maxAge: c } = e, n = /* @__PURE__ */ __name((e2) => {
|
||||||
|
const o3 = e2?.headers.get("origin");
|
||||||
|
return true === t2 ? o3 : t2 instanceof RegExp ? t2.test(o3) ? o3 : void 0 : Array.isArray(t2) ? t2.includes(o3) ? o3 : void 0 : t2 instanceof Function ? t2(o3) : "*" == t2 && r2 ? o3 : t2;
|
||||||
|
}, "n"), l = /* @__PURE__ */ __name((e2, t3) => {
|
||||||
|
for (const [r3, o3] of Object.entries(t3)) o3 && e2.headers.append(r3, o3);
|
||||||
|
return e2;
|
||||||
|
}, "l");
|
||||||
|
return { corsify: /* @__PURE__ */ __name((e2, t3) => e2?.headers?.get("access-control-allow-origin") || 101 == e2.status ? e2 : l(e2.clone(), { "access-control-allow-origin": n(t3), "access-control-allow-credentials": r2 }), "corsify"), preflight: /* @__PURE__ */ __name((e2) => {
|
||||||
|
if ("OPTIONS" == e2.method) {
|
||||||
|
const t3 = new Response(null, { status: 204 });
|
||||||
|
return l(t3, { "access-control-allow-origin": n(e2), "access-control-allow-methods": o2?.join?.(",") ?? o2, "access-control-expose-headers": s?.join?.(",") ?? s, "access-control-allow-headers": a?.join?.(",") ?? a ?? e2.headers.get("access-control-request-headers"), "access-control-max-age": c, "access-control-allow-credentials": r2 });
|
||||||
|
}
|
||||||
|
}, "preflight") };
|
||||||
|
}, "y");
|
||||||
|
|
||||||
|
// functions/[[path]].ts
|
||||||
|
var { preflight, corsify } = y();
|
||||||
|
var router = t();
|
||||||
|
router.all("/*", preflight);
|
||||||
|
router.get("/", () => {
|
||||||
|
console.log("Health check endpoint called");
|
||||||
|
return new Response("Pixiv Now Worker is running!", {
|
||||||
|
headers: { "Content-Type": "text/plain" }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
router.get("/test", () => {
|
||||||
|
console.log("Test endpoint called");
|
||||||
|
return new Response(JSON.stringify({ message: "Test successful", timestamp: Date.now() }), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
router.all("*", () => {
|
||||||
|
console.log("404 handler called");
|
||||||
|
return new Response("Not Found", { status: 404 });
|
||||||
|
});
|
||||||
|
var path_default = {
|
||||||
|
fetch: /* @__PURE__ */ __name((request, env, ctx) => {
|
||||||
|
console.log("Worker fetch called:", request.method, request.url);
|
||||||
|
return router.handle(request, env, ctx).then(corsify).catch((err) => {
|
||||||
|
console.error("Worker error:", err);
|
||||||
|
return new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: err instanceof Error ? err.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, "fetch")
|
||||||
|
};
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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@4.42.1/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-hVAKjn/middleware-insertion-facade.js
|
||||||
|
var __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
middleware_ensure_req_body_drained_default,
|
||||||
|
middleware_miniflare3_json_error_default
|
||||||
|
];
|
||||||
|
var middleware_insertion_facade_default = path_default;
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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-hVAKjn/middleware-loader.entry.ts
|
||||||
|
var __Facade_ScheduledController__ = class ___Facade_ScheduledController__ {
|
||||||
|
constructor(scheduledTime, cron, noRetry) {
|
||||||
|
this.scheduledTime = scheduledTime;
|
||||||
|
this.cron = cron;
|
||||||
|
this.#noRetry = noRetry;
|
||||||
|
}
|
||||||
|
static {
|
||||||
|
__name(this, "__Facade_ScheduledController__");
|
||||||
|
}
|
||||||
|
#noRetry;
|
||||||
|
noRetry() {
|
||||||
|
if (!(this instanceof ___Facade_ScheduledController__)) {
|
||||||
|
throw new TypeError("Illegal invocation");
|
||||||
|
}
|
||||||
|
this.#noRetry();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
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 = /* @__PURE__ */ __name((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);
|
||||||
|
}, "#fetchDispatcher");
|
||||||
|
#dispatcher = /* @__PURE__ */ __name((type, init) => {
|
||||||
|
if (type === "scheduled" && super.scheduled !== void 0) {
|
||||||
|
const controller = new __Facade_ScheduledController__(
|
||||||
|
Date.now(),
|
||||||
|
init.cron ?? "",
|
||||||
|
() => {
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return super.scheduled(controller);
|
||||||
|
}
|
||||||
|
}, "#dispatcher");
|
||||||
|
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=%5B%5Bpath%5D%5D.js.map
|
||||||
8
.wrangler/tmp/dev-NuKMFb/[[path]].js.map
Normal file
8
.wrangler/tmp/dev-NuKMFb/[[path]].js.map
Normal file
File diff suppressed because one or more lines are too long
440
.wrangler/tmp/dev-XWclmn/[[path]].js
Normal file
440
.wrangler/tmp/dev-XWclmn/[[path]].js
Normal file
@@ -0,0 +1,440 @@
|
|||||||
|
var __defProp = Object.defineProperty;
|
||||||
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||||
|
|
||||||
|
// .wrangler/tmp/bundle-d5bXFA/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/itty-router@5.0.22/node_modules/itty-router/index.mjs
|
||||||
|
var t = /* @__PURE__ */ __name(({ base: e = "", routes: t2 = [], ...r2 } = {}) => ({ __proto__: new Proxy({}, { get: /* @__PURE__ */ __name((r3, o2, a, s) => (r4, ...c) => t2.push([o2.toUpperCase?.(), RegExp(`^${(s = (e + r4).replace(/\/+(\/|$)/g, "$1")).replace(/(\/?\.?):(\w+)\+/g, "($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g, "($1(?<$2>[^$1/]+?))").replace(/\./g, "\\.").replace(/(\/?)\*/g, "($1.*)?")}/*$`), c, s]) && a, "get") }), routes: t2, ...r2, async fetch(e2, ...o2) {
|
||||||
|
let a, s, c = new URL(e2.url), n = e2.query = { __proto__: null };
|
||||||
|
for (let [e3, t3] of c.searchParams) n[e3] = n[e3] ? [].concat(n[e3], t3) : t3;
|
||||||
|
e: try {
|
||||||
|
for (let t3 of r2.before || []) if (null != (a = await t3(e2.proxy ?? e2, ...o2))) break e;
|
||||||
|
t: for (let [r3, n2, l, i] of t2) if ((r3 == e2.method || "ALL" == r3) && (s = c.pathname.match(n2))) {
|
||||||
|
e2.params = s.groups || {}, e2.route = i;
|
||||||
|
for (let t3 of l) if (null != (a = await t3(e2.proxy ?? e2, ...o2))) break t;
|
||||||
|
}
|
||||||
|
} catch (t3) {
|
||||||
|
if (!r2.catch) throw t3;
|
||||||
|
a = await r2.catch(t3, e2.proxy ?? e2, ...o2);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
for (let t3 of r2.finally || []) a = await t3(a, e2.proxy ?? e2, ...o2) ?? a;
|
||||||
|
} catch (t3) {
|
||||||
|
if (!r2.catch) throw t3;
|
||||||
|
a = await r2.catch(t3, e2.proxy ?? e2, ...o2);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
} }), "t");
|
||||||
|
var r = /* @__PURE__ */ __name((e = "text/plain; charset=utf-8", t2) => (r2, o2 = {}) => {
|
||||||
|
if (void 0 === r2 || r2 instanceof Response) return r2;
|
||||||
|
const a = new Response(t2?.(r2) ?? r2, o2.url ? void 0 : o2);
|
||||||
|
return a.headers.set("content-type", e), a;
|
||||||
|
}, "r");
|
||||||
|
var o = r("application/json; charset=utf-8", JSON.stringify);
|
||||||
|
var p = r("text/plain; charset=utf-8", String);
|
||||||
|
var f = r("text/html");
|
||||||
|
var u = r("image/jpeg");
|
||||||
|
var h = r("image/png");
|
||||||
|
var g = r("image/webp");
|
||||||
|
var y = /* @__PURE__ */ __name((e = {}) => {
|
||||||
|
const { origin: t2 = "*", credentials: r2 = false, allowMethods: o2 = "*", allowHeaders: a, exposeHeaders: s, maxAge: c } = e, n = /* @__PURE__ */ __name((e2) => {
|
||||||
|
const o3 = e2?.headers.get("origin");
|
||||||
|
return true === t2 ? o3 : t2 instanceof RegExp ? t2.test(o3) ? o3 : void 0 : Array.isArray(t2) ? t2.includes(o3) ? o3 : void 0 : t2 instanceof Function ? t2(o3) : "*" == t2 && r2 ? o3 : t2;
|
||||||
|
}, "n"), l = /* @__PURE__ */ __name((e2, t3) => {
|
||||||
|
for (const [r3, o3] of Object.entries(t3)) o3 && e2.headers.append(r3, o3);
|
||||||
|
return e2;
|
||||||
|
}, "l");
|
||||||
|
return { corsify: /* @__PURE__ */ __name((e2, t3) => e2?.headers?.get("access-control-allow-origin") || 101 == e2.status ? e2 : l(e2.clone(), { "access-control-allow-origin": n(t3), "access-control-allow-credentials": r2 }), "corsify"), preflight: /* @__PURE__ */ __name((e2) => {
|
||||||
|
if ("OPTIONS" == e2.method) {
|
||||||
|
const t3 = new Response(null, { status: 204 });
|
||||||
|
return l(t3, { "access-control-allow-origin": n(e2), "access-control-allow-methods": o2?.join?.(",") ?? o2, "access-control-expose-headers": s?.join?.(",") ?? s, "access-control-allow-headers": a?.join?.(",") ?? a ?? e2.headers.get("access-control-request-headers"), "access-control-max-age": c, "access-control-allow-credentials": r2 });
|
||||||
|
}
|
||||||
|
}, "preflight") };
|
||||||
|
}, "y");
|
||||||
|
|
||||||
|
// functions/[[path]].ts
|
||||||
|
var { preflight, corsify } = y();
|
||||||
|
var router = t();
|
||||||
|
router.all("/*", preflight);
|
||||||
|
router.all("/(ajax|rpc)/:path+", async (req, env) => {
|
||||||
|
const url = new URL(req.url);
|
||||||
|
url.hostname = "www.pixiv.net";
|
||||||
|
const headers = new Headers(req.headers);
|
||||||
|
headers.set("origin", "https://www.pixiv.net");
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
method: req.method,
|
||||||
|
headers,
|
||||||
|
body: req.body
|
||||||
|
});
|
||||||
|
return fetch(newReq);
|
||||||
|
});
|
||||||
|
router.all("/(~|-)/:path+", async (req, env) => {
|
||||||
|
const url = new URL(req.url);
|
||||||
|
const prefix = url.pathname.split("/")[1];
|
||||||
|
switch (prefix) {
|
||||||
|
case "-":
|
||||||
|
url.hostname = "i.pximg.net";
|
||||||
|
break;
|
||||||
|
case "~":
|
||||||
|
url.hostname = "s.pximg.net";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return new Response("Invalid request", { status: 400 });
|
||||||
|
}
|
||||||
|
url.pathname = url.pathname.substring(prefix.length + 1);
|
||||||
|
const headers = new Headers();
|
||||||
|
const proxyHeaders = [
|
||||||
|
"accept",
|
||||||
|
"accept-encoding",
|
||||||
|
"accept-language",
|
||||||
|
"range",
|
||||||
|
"if-range",
|
||||||
|
"if-none-match",
|
||||||
|
"if-modified-since",
|
||||||
|
"cache-control"
|
||||||
|
];
|
||||||
|
for (const h2 of proxyHeaders) {
|
||||||
|
if (req.headers.has(h2)) {
|
||||||
|
headers.set(h2, req.headers.get(h2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
return fetch(newReq);
|
||||||
|
});
|
||||||
|
router.all("/api/illust/random", async (req, env) => {
|
||||||
|
try {
|
||||||
|
const url = new URL(req.url);
|
||||||
|
url.hostname = "www.pixiv.net";
|
||||||
|
url.pathname = "/ajax/illust/discovery";
|
||||||
|
const requestImage = (req.headers.get("accept")?.includes("image") || url.searchParams.get("format") === "image") && url.searchParams.get("format") !== "json";
|
||||||
|
url.searchParams.set("mode", url.searchParams.get("mode") ?? "safe");
|
||||||
|
url.searchParams.set("max", requestImage ? "1" : url.searchParams.get("max") ?? "18");
|
||||||
|
const headers = new Headers(req.headers);
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
const res = await fetch(newReq);
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error(`Pixiv API returned ${res.status}`);
|
||||||
|
}
|
||||||
|
const data = await res.json();
|
||||||
|
const illusts = (data.illusts ?? []).filter(
|
||||||
|
(value) => Object.keys(value).includes("id")
|
||||||
|
);
|
||||||
|
if (illusts.length === 0) {
|
||||||
|
return new Response(JSON.stringify([]), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const PXIMG_BASEURL_I = (env.VITE_PXIMG_BASEURL_I || "https://i.pximg.net/").replace(/\/$/, "") + "/";
|
||||||
|
illusts.forEach((value) => {
|
||||||
|
try {
|
||||||
|
const updateDate = new Date(value.updateDate);
|
||||||
|
const year = updateDate.getFullYear();
|
||||||
|
const month = String(updateDate.getMonth() + 1).padStart(2, "0");
|
||||||
|
const day = String(updateDate.getDate()).padStart(2, "0");
|
||||||
|
const hour = String(updateDate.getHours()).padStart(2, "0");
|
||||||
|
const minute = String(updateDate.getMinutes()).padStart(2, "0");
|
||||||
|
const second = String(updateDate.getSeconds()).padStart(2, "0");
|
||||||
|
const middle = `img/${year}/${month}/${day}/${hour}/${minute}/${second}/${value.id}`;
|
||||||
|
value.urls = {
|
||||||
|
mini: `${PXIMG_BASEURL_I}c/48x48/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
thumb: `${PXIMG_BASEURL_I}c/250x250_80_a2/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
small: `${PXIMG_BASEURL_I}c/540x540_70/img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
regular: `${PXIMG_BASEURL_I}img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
original: `${PXIMG_BASEURL_I}img-original/${middle}_p0.jpg`
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error formatting date for illust:", value.id, error);
|
||||||
|
value.urls = {
|
||||||
|
mini: `${PXIMG_BASEURL_I}c/48x48/img-master/img/2024/01/01/00/00/00/${value.id}_p0_square1200.jpg`,
|
||||||
|
thumb: `${PXIMG_BASEURL_I}c/250x250_80_a2/img-master/img/2024/01/01/00/00/00/${value.id}_p0_square1200.jpg`,
|
||||||
|
small: `${PXIMG_BASEURL_I}c/540x540_70/img-master/img/2024/01/01/00/00/00/${value.id}_p0_master1200.jpg`,
|
||||||
|
regular: `${PXIMG_BASEURL_I}img-master/img/2024/01/01/00/00/00/${value.id}_p0_master1200.jpg`,
|
||||||
|
original: `${PXIMG_BASEURL_I}img-original/img/2024/01/01/00/00/00/${value.id}_p0.jpg`
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (requestImage) {
|
||||||
|
return new Response(null, { status: 302, headers: { Location: illusts[0].urls.regular } });
|
||||||
|
}
|
||||||
|
return new Response(JSON.stringify(illusts), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in random API:", error);
|
||||||
|
return new Response(JSON.stringify({ error: "Internal server error" }), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
router.all("/api/user", async (req, env) => {
|
||||||
|
const token = req.headers.get("cookie")?.match(/PHPSESSID=([^;]+)/)?.[1] || new URL(req.url).searchParams.get("token");
|
||||||
|
if (!token) {
|
||||||
|
return new Response(JSON.stringify({ message: "\u672A\u914D\u7F6E\u7528\u6237\u5BC6\u94A5" }), { status: 403, headers: { "Content-Type": "application/json" } });
|
||||||
|
}
|
||||||
|
const url = new URL(req.url);
|
||||||
|
url.hostname = "www.pixiv.net";
|
||||||
|
url.pathname = "/";
|
||||||
|
const headers = new Headers(req.headers);
|
||||||
|
headers.set("cookie", `PHPSESSID=${token}`);
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
const res = await fetch(newReq);
|
||||||
|
const text = await res.text();
|
||||||
|
let meta = null;
|
||||||
|
class MetaHandler {
|
||||||
|
constructor(type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
static {
|
||||||
|
__name(this, "MetaHandler");
|
||||||
|
}
|
||||||
|
text(chunk) {
|
||||||
|
try {
|
||||||
|
if (this.type === "legacy") {
|
||||||
|
const data = JSON.parse(chunk.text);
|
||||||
|
meta = {
|
||||||
|
userData: data.userData,
|
||||||
|
token: data.token || ""
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const nextData = JSON.parse(chunk.text);
|
||||||
|
const perloadState = JSON.parse(
|
||||||
|
nextData?.props?.pageProps?.serverSerializedPreloadedState
|
||||||
|
);
|
||||||
|
meta = {
|
||||||
|
userData: perloadState?.userData?.self,
|
||||||
|
token: perloadState?.api?.token || ""
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error("Error parsing meta", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const rewriter = new HTMLRewriter().on('meta[name="global-data"]', new MetaHandler("legacy")).on("script#__NEXT_DATA__", new MetaHandler("next"));
|
||||||
|
await rewriter.transform(new Response(text)).text();
|
||||||
|
if (!meta || !meta.userData) {
|
||||||
|
return new Response(JSON.stringify({ message: "\u65E0\u6CD5\u83B7\u53D6\u767B\u5F55\u72B6\u6001" }), { status: 401, headers: { "Content-Type": "application/json" } });
|
||||||
|
}
|
||||||
|
const responseHeaders = new Headers({
|
||||||
|
"cache-control": "no-cache",
|
||||||
|
"set-cookie": `CSRFTOKEN=${meta.token}; path=/; secure; sameSite=Lax`,
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
});
|
||||||
|
return new Response(JSON.stringify(meta), { headers: responseHeaders });
|
||||||
|
});
|
||||||
|
var path_default = {
|
||||||
|
fetch: /* @__PURE__ */ __name((req, env, ctx) => router.handle(req, env, ctx).then(corsify).catch((err) => {
|
||||||
|
console.error(err);
|
||||||
|
return new Response("Internal Server Error", { status: 500 });
|
||||||
|
}), "fetch")
|
||||||
|
};
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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@4.42.1/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-d5bXFA/middleware-insertion-facade.js
|
||||||
|
var __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
middleware_ensure_req_body_drained_default,
|
||||||
|
middleware_miniflare3_json_error_default
|
||||||
|
];
|
||||||
|
var middleware_insertion_facade_default = path_default;
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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-d5bXFA/middleware-loader.entry.ts
|
||||||
|
var __Facade_ScheduledController__ = class ___Facade_ScheduledController__ {
|
||||||
|
constructor(scheduledTime, cron, noRetry) {
|
||||||
|
this.scheduledTime = scheduledTime;
|
||||||
|
this.cron = cron;
|
||||||
|
this.#noRetry = noRetry;
|
||||||
|
}
|
||||||
|
static {
|
||||||
|
__name(this, "__Facade_ScheduledController__");
|
||||||
|
}
|
||||||
|
#noRetry;
|
||||||
|
noRetry() {
|
||||||
|
if (!(this instanceof ___Facade_ScheduledController__)) {
|
||||||
|
throw new TypeError("Illegal invocation");
|
||||||
|
}
|
||||||
|
this.#noRetry();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
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 = /* @__PURE__ */ __name((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);
|
||||||
|
}, "#fetchDispatcher");
|
||||||
|
#dispatcher = /* @__PURE__ */ __name((type, init) => {
|
||||||
|
if (type === "scheduled" && super.scheduled !== void 0) {
|
||||||
|
const controller = new __Facade_ScheduledController__(
|
||||||
|
Date.now(),
|
||||||
|
init.cron ?? "",
|
||||||
|
() => {
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return super.scheduled(controller);
|
||||||
|
}
|
||||||
|
}, "#dispatcher");
|
||||||
|
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=%5B%5Bpath%5D%5D.js.map
|
||||||
8
.wrangler/tmp/dev-XWclmn/[[path]].js.map
Normal file
8
.wrangler/tmp/dev-XWclmn/[[path]].js.map
Normal file
File diff suppressed because one or more lines are too long
433
.wrangler/tmp/dev-bqo4cO/[[path]].js
Normal file
433
.wrangler/tmp/dev-bqo4cO/[[path]].js
Normal file
@@ -0,0 +1,433 @@
|
|||||||
|
var __defProp = Object.defineProperty;
|
||||||
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||||
|
|
||||||
|
// .wrangler/tmp/bundle-mYQ48C/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/itty-router@5.0.22/node_modules/itty-router/index.mjs
|
||||||
|
var t = /* @__PURE__ */ __name(({ base: e = "", routes: t2 = [], ...r2 } = {}) => ({ __proto__: new Proxy({}, { get: /* @__PURE__ */ __name((r3, o2, a, s) => (r4, ...c) => t2.push([o2.toUpperCase?.(), RegExp(`^${(s = (e + r4).replace(/\/+(\/|$)/g, "$1")).replace(/(\/?\.?):(\w+)\+/g, "($1(?<$2>*))").replace(/(\/?\.?):(\w+)/g, "($1(?<$2>[^$1/]+?))").replace(/\./g, "\\.").replace(/(\/?)\*/g, "($1.*)?")}/*$`), c, s]) && a, "get") }), routes: t2, ...r2, async fetch(e2, ...o2) {
|
||||||
|
let a, s, c = new URL(e2.url), n = e2.query = { __proto__: null };
|
||||||
|
for (let [e3, t3] of c.searchParams) n[e3] = n[e3] ? [].concat(n[e3], t3) : t3;
|
||||||
|
e: try {
|
||||||
|
for (let t3 of r2.before || []) if (null != (a = await t3(e2.proxy ?? e2, ...o2))) break e;
|
||||||
|
t: for (let [r3, n2, l, i] of t2) if ((r3 == e2.method || "ALL" == r3) && (s = c.pathname.match(n2))) {
|
||||||
|
e2.params = s.groups || {}, e2.route = i;
|
||||||
|
for (let t3 of l) if (null != (a = await t3(e2.proxy ?? e2, ...o2))) break t;
|
||||||
|
}
|
||||||
|
} catch (t3) {
|
||||||
|
if (!r2.catch) throw t3;
|
||||||
|
a = await r2.catch(t3, e2.proxy ?? e2, ...o2);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
for (let t3 of r2.finally || []) a = await t3(a, e2.proxy ?? e2, ...o2) ?? a;
|
||||||
|
} catch (t3) {
|
||||||
|
if (!r2.catch) throw t3;
|
||||||
|
a = await r2.catch(t3, e2.proxy ?? e2, ...o2);
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
} }), "t");
|
||||||
|
var r = /* @__PURE__ */ __name((e = "text/plain; charset=utf-8", t2) => (r2, o2 = {}) => {
|
||||||
|
if (void 0 === r2 || r2 instanceof Response) return r2;
|
||||||
|
const a = new Response(t2?.(r2) ?? r2, o2.url ? void 0 : o2);
|
||||||
|
return a.headers.set("content-type", e), a;
|
||||||
|
}, "r");
|
||||||
|
var o = r("application/json; charset=utf-8", JSON.stringify);
|
||||||
|
var p = r("text/plain; charset=utf-8", String);
|
||||||
|
var f = r("text/html");
|
||||||
|
var u = r("image/jpeg");
|
||||||
|
var h = r("image/png");
|
||||||
|
var g = r("image/webp");
|
||||||
|
var y = /* @__PURE__ */ __name((e = {}) => {
|
||||||
|
const { origin: t2 = "*", credentials: r2 = false, allowMethods: o2 = "*", allowHeaders: a, exposeHeaders: s, maxAge: c } = e, n = /* @__PURE__ */ __name((e2) => {
|
||||||
|
const o3 = e2?.headers.get("origin");
|
||||||
|
return true === t2 ? o3 : t2 instanceof RegExp ? t2.test(o3) ? o3 : void 0 : Array.isArray(t2) ? t2.includes(o3) ? o3 : void 0 : t2 instanceof Function ? t2(o3) : "*" == t2 && r2 ? o3 : t2;
|
||||||
|
}, "n"), l = /* @__PURE__ */ __name((e2, t3) => {
|
||||||
|
for (const [r3, o3] of Object.entries(t3)) o3 && e2.headers.append(r3, o3);
|
||||||
|
return e2;
|
||||||
|
}, "l");
|
||||||
|
return { corsify: /* @__PURE__ */ __name((e2, t3) => e2?.headers?.get("access-control-allow-origin") || 101 == e2.status ? e2 : l(e2.clone(), { "access-control-allow-origin": n(t3), "access-control-allow-credentials": r2 }), "corsify"), preflight: /* @__PURE__ */ __name((e2) => {
|
||||||
|
if ("OPTIONS" == e2.method) {
|
||||||
|
const t3 = new Response(null, { status: 204 });
|
||||||
|
return l(t3, { "access-control-allow-origin": n(e2), "access-control-allow-methods": o2?.join?.(",") ?? o2, "access-control-expose-headers": s?.join?.(",") ?? s, "access-control-allow-headers": a?.join?.(",") ?? a ?? e2.headers.get("access-control-request-headers"), "access-control-max-age": c, "access-control-allow-credentials": r2 });
|
||||||
|
}
|
||||||
|
}, "preflight") };
|
||||||
|
}, "y");
|
||||||
|
|
||||||
|
// functions/[[path]].ts
|
||||||
|
var { preflight, corsify } = y();
|
||||||
|
var router = t();
|
||||||
|
router.all("/*", preflight);
|
||||||
|
router.get("/", () => {
|
||||||
|
return new Response("Pixiv Now Worker is running!", {
|
||||||
|
headers: { "Content-Type": "text/plain" }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
router.all("/(ajax|rpc)/:path+", async (req, env) => {
|
||||||
|
const url = new URL(req.url);
|
||||||
|
url.hostname = "www.pixiv.net";
|
||||||
|
const headers = new Headers(req.headers);
|
||||||
|
headers.set("origin", "https://www.pixiv.net");
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
method: req.method,
|
||||||
|
headers,
|
||||||
|
body: req.body
|
||||||
|
});
|
||||||
|
return fetch(newReq);
|
||||||
|
});
|
||||||
|
router.all("/(~|-)/:path+", async (req, env) => {
|
||||||
|
const url = new URL(req.url);
|
||||||
|
const path = url.pathname.slice(2);
|
||||||
|
if (url.pathname.startsWith("/~")) {
|
||||||
|
url.hostname = "i.pximg.net";
|
||||||
|
} else {
|
||||||
|
url.hostname = "s.pximg.net";
|
||||||
|
}
|
||||||
|
url.pathname = "/" + path;
|
||||||
|
const headers = new Headers();
|
||||||
|
for (const h2 of ["accept", "accept-encoding", "accept-language", "cache-control", "user-agent"]) {
|
||||||
|
if (req.headers.get(h2)) {
|
||||||
|
headers.set(h2, req.headers.get(h2));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
return fetch(newReq);
|
||||||
|
});
|
||||||
|
router.all("/api/illust/random", async (req, env) => {
|
||||||
|
try {
|
||||||
|
const url = new URL(req.url);
|
||||||
|
const requestImage = (req.headers.get("accept")?.includes("image") || url.searchParams.get("format") === "image") && url.searchParams.get("format") !== "json";
|
||||||
|
const pixivUrl = new URL("https://www.pixiv.net/ajax/illust/discovery");
|
||||||
|
pixivUrl.searchParams.set("mode", url.searchParams.get("mode") ?? "safe");
|
||||||
|
pixivUrl.searchParams.set("max", requestImage ? "1" : url.searchParams.get("max") ?? "18");
|
||||||
|
const headers = new Headers();
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const response = await fetch(pixivUrl.toString(), { headers });
|
||||||
|
if (!response.ok) {
|
||||||
|
return new Response(JSON.stringify({ error: `Pixiv API returned ${response.status}` }), {
|
||||||
|
status: response.status,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const data = await response.json();
|
||||||
|
const illusts = (data.illusts ?? []).filter(
|
||||||
|
(value) => value && typeof value === "object" && value.id
|
||||||
|
);
|
||||||
|
if (illusts.length === 0) {
|
||||||
|
return new Response(JSON.stringify([]), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const PXIMG_BASEURL_I = (env.VITE_PXIMG_BASEURL_I || "https://i.pximg.net/").replace(/\/$/, "") + "/";
|
||||||
|
illusts.forEach((value) => {
|
||||||
|
try {
|
||||||
|
if (value.updateDate) {
|
||||||
|
const date = new Date(value.updateDate);
|
||||||
|
const year = date.getFullYear();
|
||||||
|
const month = String(date.getMonth() + 1).padStart(2, "0");
|
||||||
|
const day = String(date.getDate()).padStart(2, "0");
|
||||||
|
const hour = String(date.getHours()).padStart(2, "0");
|
||||||
|
const minute = String(date.getMinutes()).padStart(2, "0");
|
||||||
|
const second = String(date.getSeconds()).padStart(2, "0");
|
||||||
|
const middle = `img/${year}/${month}/${day}/${hour}/${minute}/${second}/${value.id}`;
|
||||||
|
value.urls = {
|
||||||
|
mini: `${PXIMG_BASEURL_I}c/48x48/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
thumb: `${PXIMG_BASEURL_I}c/250x250_80_a2/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
small: `${PXIMG_BASEURL_I}c/540x540_70/img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
regular: `${PXIMG_BASEURL_I}img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
original: `${PXIMG_BASEURL_I}img-original/${middle}_p0.jpg`
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const middle = `img/2024/01/01/00/00/00/${value.id}`;
|
||||||
|
value.urls = {
|
||||||
|
mini: `${PXIMG_BASEURL_I}c/48x48/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
thumb: `${PXIMG_BASEURL_I}c/250x250_80_a2/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
small: `${PXIMG_BASEURL_I}c/540x540_70/img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
regular: `${PXIMG_BASEURL_I}img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
original: `${PXIMG_BASEURL_I}img-original/${middle}_p0.jpg`
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error processing illust:", value.id, error);
|
||||||
|
const middle = `img/2024/01/01/00/00/00/${value.id}`;
|
||||||
|
value.urls = {
|
||||||
|
mini: `${PXIMG_BASEURL_I}c/48x48/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
thumb: `${PXIMG_BASEURL_I}c/250x250_80_a2/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
small: `${PXIMG_BASEURL_I}c/540x540_70/img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
regular: `${PXIMG_BASEURL_I}img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
original: `${PXIMG_BASEURL_I}img-original/${middle}_p0.jpg`
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (requestImage && illusts[0]?.urls?.regular) {
|
||||||
|
return new Response(null, {
|
||||||
|
status: 302,
|
||||||
|
headers: { Location: illusts[0].urls.regular }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return new Response(JSON.stringify(illusts), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in random API:", error);
|
||||||
|
return new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
router.all("/api/user", async (req, env) => {
|
||||||
|
try {
|
||||||
|
const url = new URL(req.url);
|
||||||
|
const userId = url.searchParams.get("id");
|
||||||
|
if (!userId) {
|
||||||
|
return new Response(JSON.stringify({ error: "User ID is required" }), {
|
||||||
|
status: 400,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const pixivUrl = new URL(`https://www.pixiv.net/ajax/user/${userId}`);
|
||||||
|
const headers = new Headers();
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const response = await fetch(pixivUrl.toString(), { headers });
|
||||||
|
if (!response.ok) {
|
||||||
|
return new Response(JSON.stringify({ error: `Pixiv API returned ${response.status}` }), {
|
||||||
|
status: response.status,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const data = await response.json();
|
||||||
|
return new Response(JSON.stringify(data), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in user API:", error);
|
||||||
|
return new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
router.all("*", () => new Response("Not Found", { status: 404 }));
|
||||||
|
var path_default = {
|
||||||
|
fetch: /* @__PURE__ */ __name((request, env, ctx) => router.handle(request, env, ctx).then(corsify).catch((err) => {
|
||||||
|
console.error("Worker error:", err);
|
||||||
|
return new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: err instanceof Error ? err.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
});
|
||||||
|
}), "fetch")
|
||||||
|
};
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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@4.42.1/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-mYQ48C/middleware-insertion-facade.js
|
||||||
|
var __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
middleware_ensure_req_body_drained_default,
|
||||||
|
middleware_miniflare3_json_error_default
|
||||||
|
];
|
||||||
|
var middleware_insertion_facade_default = path_default;
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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-mYQ48C/middleware-loader.entry.ts
|
||||||
|
var __Facade_ScheduledController__ = class ___Facade_ScheduledController__ {
|
||||||
|
constructor(scheduledTime, cron, noRetry) {
|
||||||
|
this.scheduledTime = scheduledTime;
|
||||||
|
this.cron = cron;
|
||||||
|
this.#noRetry = noRetry;
|
||||||
|
}
|
||||||
|
static {
|
||||||
|
__name(this, "__Facade_ScheduledController__");
|
||||||
|
}
|
||||||
|
#noRetry;
|
||||||
|
noRetry() {
|
||||||
|
if (!(this instanceof ___Facade_ScheduledController__)) {
|
||||||
|
throw new TypeError("Illegal invocation");
|
||||||
|
}
|
||||||
|
this.#noRetry();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
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 = /* @__PURE__ */ __name((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);
|
||||||
|
}, "#fetchDispatcher");
|
||||||
|
#dispatcher = /* @__PURE__ */ __name((type, init) => {
|
||||||
|
if (type === "scheduled" && super.scheduled !== void 0) {
|
||||||
|
const controller = new __Facade_ScheduledController__(
|
||||||
|
Date.now(),
|
||||||
|
init.cron ?? "",
|
||||||
|
() => {
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return super.scheduled(controller);
|
||||||
|
}
|
||||||
|
}, "#dispatcher");
|
||||||
|
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=%5B%5Bpath%5D%5D.js.map
|
||||||
8
.wrangler/tmp/dev-bqo4cO/[[path]].js.map
Normal file
8
.wrangler/tmp/dev-bqo4cO/[[path]].js.map
Normal file
File diff suppressed because one or more lines are too long
453
.wrangler/tmp/dev-giCNda/[[path]].js
Normal file
453
.wrangler/tmp/dev-giCNda/[[path]].js
Normal file
@@ -0,0 +1,453 @@
|
|||||||
|
var __defProp = Object.defineProperty;
|
||||||
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||||
|
|
||||||
|
// .wrangler/tmp/bundle-RkXBq4/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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// functions/[[path]].ts
|
||||||
|
function corsHeaders() {
|
||||||
|
return {
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
|
||||||
|
"Access-Control-Allow-Headers": "Content-Type, Authorization, X-Requested-With",
|
||||||
|
"Access-Control-Max-Age": "86400"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
__name(corsHeaders, "corsHeaders");
|
||||||
|
function corsResponse(response) {
|
||||||
|
const headers = new Headers(response.headers);
|
||||||
|
Object.entries(corsHeaders()).forEach(([key, value]) => {
|
||||||
|
headers.set(key, value);
|
||||||
|
});
|
||||||
|
return new Response(response.body, {
|
||||||
|
status: response.status,
|
||||||
|
statusText: response.statusText,
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
}
|
||||||
|
__name(corsResponse, "corsResponse");
|
||||||
|
var path_default = {
|
||||||
|
fetch: /* @__PURE__ */ __name(async (request, env, ctx) => {
|
||||||
|
console.log("Worker fetch called:", request.method, request.url);
|
||||||
|
const url = new URL(request.url);
|
||||||
|
const path = url.pathname;
|
||||||
|
if (request.method === "OPTIONS") {
|
||||||
|
return new Response(null, {
|
||||||
|
status: 200,
|
||||||
|
headers: corsHeaders()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (path === "/") {
|
||||||
|
return corsResponse(new Response("Pixiv Now Worker is running!", {
|
||||||
|
headers: { "Content-Type": "text/plain" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (path === "/test") {
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
message: "Test successful",
|
||||||
|
timestamp: Date.now(),
|
||||||
|
method: request.method,
|
||||||
|
path
|
||||||
|
}), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (path === "/api/illust/random") {
|
||||||
|
return await handleRandomAPI(request, env, url);
|
||||||
|
}
|
||||||
|
if (path.match(/^\/(ajax|rpc)\//)) {
|
||||||
|
return await handleGenericProxy(request, env);
|
||||||
|
}
|
||||||
|
if (path.match(/^\/[~-]\//)) {
|
||||||
|
return await handleImageProxy(request, env);
|
||||||
|
}
|
||||||
|
if (path === "/api/user") {
|
||||||
|
return await handleUserAPI(request, env, url);
|
||||||
|
}
|
||||||
|
return corsResponse(new Response("Not Found", {
|
||||||
|
status: 404,
|
||||||
|
headers: { "Content-Type": "text/plain" }
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Worker error:", error);
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}, "fetch")
|
||||||
|
};
|
||||||
|
async function handleRandomAPI(request, env, url) {
|
||||||
|
try {
|
||||||
|
const requestImage = (request.headers.get("accept")?.includes("image") || url.searchParams.get("format") === "image") && url.searchParams.get("format") !== "json";
|
||||||
|
const pixivUrl = new URL("https://www.pixiv.net/ajax/illust/discovery");
|
||||||
|
pixivUrl.searchParams.set("mode", url.searchParams.get("mode") ?? "safe");
|
||||||
|
pixivUrl.searchParams.set("max", requestImage ? "1" : url.searchParams.get("max") ?? "18");
|
||||||
|
const headers = new Headers();
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
console.log("Fetching from Pixiv API:", pixivUrl.toString());
|
||||||
|
const response = await fetch(pixivUrl.toString(), { headers });
|
||||||
|
if (!response.ok) {
|
||||||
|
console.error("Pixiv API error:", response.status, response.statusText);
|
||||||
|
return corsResponse(new Response(JSON.stringify({ error: `Pixiv API returned ${response.status}` }), {
|
||||||
|
status: response.status,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
const data = await response.json();
|
||||||
|
console.log("Pixiv API response:", data);
|
||||||
|
if (data.error) {
|
||||||
|
console.error("Pixiv API returned error:", data.error);
|
||||||
|
return corsResponse(new Response(JSON.stringify({ error: data.error }), {
|
||||||
|
status: 400,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
const illusts = (data.illusts ?? []).filter(
|
||||||
|
(value) => value && typeof value === "object" && value.id
|
||||||
|
);
|
||||||
|
if (illusts.length === 0) {
|
||||||
|
return corsResponse(new Response(JSON.stringify([]), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
const PXIMG_BASEURL_I = (env.VITE_PXIMG_BASEURL_I || "https://i.pximg.net/").replace(/\/$/, "") + "/";
|
||||||
|
illusts.forEach((value) => {
|
||||||
|
try {
|
||||||
|
if (value.updateDate) {
|
||||||
|
const date = new Date(value.updateDate);
|
||||||
|
const year = date.getFullYear();
|
||||||
|
const month = String(date.getMonth() + 1).padStart(2, "0");
|
||||||
|
const day = String(date.getDate()).padStart(2, "0");
|
||||||
|
const hour = String(date.getHours()).padStart(2, "0");
|
||||||
|
const minute = String(date.getMinutes()).padStart(2, "0");
|
||||||
|
const second = String(date.getSeconds()).padStart(2, "0");
|
||||||
|
const middle = `img/${year}/${month}/${day}/${hour}/${minute}/${second}/${value.id}`;
|
||||||
|
value.urls = {
|
||||||
|
mini: `${PXIMG_BASEURL_I}c/48x48/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
thumb: `${PXIMG_BASEURL_I}c/250x250_80_a2/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
small: `${PXIMG_BASEURL_I}c/540x540_70/img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
regular: `${PXIMG_BASEURL_I}img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
original: `${PXIMG_BASEURL_I}img-original/${middle}_p0.jpg`
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
const middle = `img/2024/01/01/00/00/00/${value.id}`;
|
||||||
|
value.urls = {
|
||||||
|
mini: `${PXIMG_BASEURL_I}c/48x48/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
thumb: `${PXIMG_BASEURL_I}c/250x250_80_a2/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
small: `${PXIMG_BASEURL_I}c/540x540_70/img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
regular: `${PXIMG_BASEURL_I}img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
original: `${PXIMG_BASEURL_I}img-original/${middle}_p0.jpg`
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error processing illust:", value.id, error);
|
||||||
|
const middle = `img/2024/01/01/00/00/00/${value.id}`;
|
||||||
|
value.urls = {
|
||||||
|
mini: `${PXIMG_BASEURL_I}c/48x48/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
thumb: `${PXIMG_BASEURL_I}c/250x250_80_a2/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
small: `${PXIMG_BASEURL_I}c/540x540_70/img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
regular: `${PXIMG_BASEURL_I}img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
original: `${PXIMG_BASEURL_I}img-original/${middle}_p0.jpg`
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (requestImage && illusts[0]?.urls?.regular) {
|
||||||
|
return corsResponse(new Response(null, {
|
||||||
|
status: 302,
|
||||||
|
headers: { Location: illusts[0].urls.regular }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
return corsResponse(new Response(JSON.stringify(illusts), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in random API:", error);
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__name(handleRandomAPI, "handleRandomAPI");
|
||||||
|
async function handleGenericProxy(request, env) {
|
||||||
|
const url = new URL(request.url);
|
||||||
|
url.hostname = "www.pixiv.net";
|
||||||
|
const headers = new Headers(request.headers);
|
||||||
|
headers.set("origin", "https://www.pixiv.net");
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
method: request.method,
|
||||||
|
headers,
|
||||||
|
body: request.body
|
||||||
|
});
|
||||||
|
const response = await fetch(newReq);
|
||||||
|
return corsResponse(response);
|
||||||
|
}
|
||||||
|
__name(handleGenericProxy, "handleGenericProxy");
|
||||||
|
async function handleImageProxy(request, env) {
|
||||||
|
const url = new URL(request.url);
|
||||||
|
const path = url.pathname.slice(2);
|
||||||
|
if (url.pathname.startsWith("/~")) {
|
||||||
|
url.hostname = "i.pximg.net";
|
||||||
|
} else {
|
||||||
|
url.hostname = "s.pximg.net";
|
||||||
|
}
|
||||||
|
url.pathname = "/" + path;
|
||||||
|
const headers = new Headers();
|
||||||
|
for (const h of ["accept", "accept-encoding", "accept-language", "cache-control", "user-agent"]) {
|
||||||
|
if (request.headers.get(h)) {
|
||||||
|
headers.set(h, request.headers.get(h));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
const response = await fetch(newReq);
|
||||||
|
return corsResponse(response);
|
||||||
|
}
|
||||||
|
__name(handleImageProxy, "handleImageProxy");
|
||||||
|
async function handleUserAPI(request, env, url) {
|
||||||
|
try {
|
||||||
|
const userId = url.searchParams.get("id");
|
||||||
|
if (!userId) {
|
||||||
|
return corsResponse(new Response(JSON.stringify({ error: "User ID is required" }), {
|
||||||
|
status: 400,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
const pixivUrl = new URL(`https://www.pixiv.net/ajax/user/${userId}`);
|
||||||
|
const headers = new Headers();
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const response = await fetch(pixivUrl.toString(), { headers });
|
||||||
|
if (!response.ok) {
|
||||||
|
return corsResponse(new Response(JSON.stringify({ error: `Pixiv API returned ${response.status}` }), {
|
||||||
|
status: response.status,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
const data = await response.json();
|
||||||
|
return corsResponse(new Response(JSON.stringify(data), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in user API:", error);
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__name(handleUserAPI, "handleUserAPI");
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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@4.42.1/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-RkXBq4/middleware-insertion-facade.js
|
||||||
|
var __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
middleware_ensure_req_body_drained_default,
|
||||||
|
middleware_miniflare3_json_error_default
|
||||||
|
];
|
||||||
|
var middleware_insertion_facade_default = path_default;
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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-RkXBq4/middleware-loader.entry.ts
|
||||||
|
var __Facade_ScheduledController__ = class ___Facade_ScheduledController__ {
|
||||||
|
constructor(scheduledTime, cron, noRetry) {
|
||||||
|
this.scheduledTime = scheduledTime;
|
||||||
|
this.cron = cron;
|
||||||
|
this.#noRetry = noRetry;
|
||||||
|
}
|
||||||
|
static {
|
||||||
|
__name(this, "__Facade_ScheduledController__");
|
||||||
|
}
|
||||||
|
#noRetry;
|
||||||
|
noRetry() {
|
||||||
|
if (!(this instanceof ___Facade_ScheduledController__)) {
|
||||||
|
throw new TypeError("Illegal invocation");
|
||||||
|
}
|
||||||
|
this.#noRetry();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
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 = /* @__PURE__ */ __name((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);
|
||||||
|
}, "#fetchDispatcher");
|
||||||
|
#dispatcher = /* @__PURE__ */ __name((type, init) => {
|
||||||
|
if (type === "scheduled" && super.scheduled !== void 0) {
|
||||||
|
const controller = new __Facade_ScheduledController__(
|
||||||
|
Date.now(),
|
||||||
|
init.cron ?? "",
|
||||||
|
() => {
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return super.scheduled(controller);
|
||||||
|
}
|
||||||
|
}, "#dispatcher");
|
||||||
|
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=%5B%5Bpath%5D%5D.js.map
|
||||||
8
.wrangler/tmp/dev-giCNda/[[path]].js.map
Normal file
8
.wrangler/tmp/dev-giCNda/[[path]].js.map
Normal file
File diff suppressed because one or more lines are too long
398
.wrangler/tmp/dev-kRSTjH/[[path]].js
Normal file
398
.wrangler/tmp/dev-kRSTjH/[[path]].js
Normal file
@@ -0,0 +1,398 @@
|
|||||||
|
var __defProp = Object.defineProperty;
|
||||||
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||||
|
|
||||||
|
// .wrangler/tmp/bundle-YuxJya/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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// functions/[[path]].ts
|
||||||
|
function corsHeaders() {
|
||||||
|
return {
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
|
||||||
|
"Access-Control-Allow-Headers": "Content-Type, Authorization, X-Requested-With",
|
||||||
|
"Access-Control-Max-Age": "86400"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
__name(corsHeaders, "corsHeaders");
|
||||||
|
function corsResponse(response) {
|
||||||
|
const headers = new Headers(response.headers);
|
||||||
|
Object.entries(corsHeaders()).forEach(([key, value]) => {
|
||||||
|
headers.set(key, value);
|
||||||
|
});
|
||||||
|
return new Response(response.body, {
|
||||||
|
status: response.status,
|
||||||
|
statusText: response.statusText,
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
}
|
||||||
|
__name(corsResponse, "corsResponse");
|
||||||
|
var path_default = {
|
||||||
|
fetch: /* @__PURE__ */ __name(async (request, env, ctx) => {
|
||||||
|
console.log("Worker fetch called:", request.method, request.url);
|
||||||
|
const url = new URL(request.url);
|
||||||
|
const path = url.pathname;
|
||||||
|
if (request.method === "OPTIONS") {
|
||||||
|
return new Response(null, {
|
||||||
|
status: 200,
|
||||||
|
headers: corsHeaders()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (path === "/") {
|
||||||
|
return corsResponse(new Response("Pixiv Now Worker is running!", {
|
||||||
|
headers: { "Content-Type": "text/plain" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (path === "/test") {
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
message: "Test successful",
|
||||||
|
timestamp: Date.now(),
|
||||||
|
method: request.method,
|
||||||
|
path
|
||||||
|
}), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (path === "/api/illust/random") {
|
||||||
|
return await handleRandomAPI(request, env, url);
|
||||||
|
}
|
||||||
|
if (path.match(/^\/(ajax|rpc)\//)) {
|
||||||
|
return await handleGenericProxy(request, env);
|
||||||
|
}
|
||||||
|
if (path.match(/^\/[~-]\//)) {
|
||||||
|
return await handleImageProxy(request, env);
|
||||||
|
}
|
||||||
|
if (path === "/api/user") {
|
||||||
|
return await handleUserAPI(request, env, url);
|
||||||
|
}
|
||||||
|
return corsResponse(new Response("Not Found", {
|
||||||
|
status: 404,
|
||||||
|
headers: { "Content-Type": "text/plain" }
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Worker error:", error);
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}, "fetch")
|
||||||
|
};
|
||||||
|
async function handleRandomAPI(request, env, url) {
|
||||||
|
try {
|
||||||
|
const requestImage = (request.headers.get("accept")?.includes("image") || url.searchParams.get("format") === "image") && url.searchParams.get("format") !== "json";
|
||||||
|
const mockIllusts = [
|
||||||
|
{
|
||||||
|
id: "123456789",
|
||||||
|
title: "Test Illustration",
|
||||||
|
userId: "987654321",
|
||||||
|
userName: "Test Artist",
|
||||||
|
tags: ["test", "mock"],
|
||||||
|
updateDate: "2024-01-01T12:00:00+00:00",
|
||||||
|
urls: {
|
||||||
|
mini: "https://i.pximg.net/c/48x48/img-master/img/2024/01/01/12/00/00/123456789_p0_square1200.jpg",
|
||||||
|
thumb: "https://i.pximg.net/c/250x250_80_a2/img-master/img/2024/01/01/12/00/00/123456789_p0_square1200.jpg",
|
||||||
|
small: "https://i.pximg.net/c/540x540_70/img-master/img/2024/01/01/12/00/00/123456789_p0_master1200.jpg",
|
||||||
|
regular: "https://i.pximg.net/img-master/img/2024/01/01/12/00/00/123456789_p0_master1200.jpg",
|
||||||
|
original: "https://i.pximg.net/img-original/img/2024/01/01/12/00/00/123456789_p0.jpg"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
if (requestImage && mockIllusts[0]?.urls?.regular) {
|
||||||
|
return corsResponse(new Response(null, {
|
||||||
|
status: 302,
|
||||||
|
headers: { Location: mockIllusts[0].urls.regular }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
return corsResponse(new Response(JSON.stringify(mockIllusts), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in random API:", error);
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__name(handleRandomAPI, "handleRandomAPI");
|
||||||
|
async function handleGenericProxy(request, env) {
|
||||||
|
const url = new URL(request.url);
|
||||||
|
url.hostname = "www.pixiv.net";
|
||||||
|
const headers = new Headers(request.headers);
|
||||||
|
headers.set("origin", "https://www.pixiv.net");
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
method: request.method,
|
||||||
|
headers,
|
||||||
|
body: request.body
|
||||||
|
});
|
||||||
|
const response = await fetch(newReq);
|
||||||
|
return corsResponse(response);
|
||||||
|
}
|
||||||
|
__name(handleGenericProxy, "handleGenericProxy");
|
||||||
|
async function handleImageProxy(request, env) {
|
||||||
|
const url = new URL(request.url);
|
||||||
|
const path = url.pathname.slice(2);
|
||||||
|
if (url.pathname.startsWith("/~")) {
|
||||||
|
url.hostname = "i.pximg.net";
|
||||||
|
} else {
|
||||||
|
url.hostname = "s.pximg.net";
|
||||||
|
}
|
||||||
|
url.pathname = "/" + path;
|
||||||
|
const headers = new Headers();
|
||||||
|
for (const h of ["accept", "accept-encoding", "accept-language", "cache-control", "user-agent"]) {
|
||||||
|
if (request.headers.get(h)) {
|
||||||
|
headers.set(h, request.headers.get(h));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
const response = await fetch(newReq);
|
||||||
|
return corsResponse(response);
|
||||||
|
}
|
||||||
|
__name(handleImageProxy, "handleImageProxy");
|
||||||
|
async function handleUserAPI(request, env, url) {
|
||||||
|
try {
|
||||||
|
const userId = url.searchParams.get("id");
|
||||||
|
if (!userId) {
|
||||||
|
return corsResponse(new Response(JSON.stringify({ error: "User ID is required" }), {
|
||||||
|
status: 400,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
const pixivUrl = new URL(`https://www.pixiv.net/ajax/user/${userId}`);
|
||||||
|
const headers = new Headers();
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const response = await fetch(pixivUrl.toString(), { headers });
|
||||||
|
if (!response.ok) {
|
||||||
|
return corsResponse(new Response(JSON.stringify({ error: `Pixiv API returned ${response.status}` }), {
|
||||||
|
status: response.status,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
const data = await response.json();
|
||||||
|
return corsResponse(new Response(JSON.stringify(data), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in user API:", error);
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__name(handleUserAPI, "handleUserAPI");
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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@4.42.1/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-YuxJya/middleware-insertion-facade.js
|
||||||
|
var __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
middleware_ensure_req_body_drained_default,
|
||||||
|
middleware_miniflare3_json_error_default
|
||||||
|
];
|
||||||
|
var middleware_insertion_facade_default = path_default;
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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-YuxJya/middleware-loader.entry.ts
|
||||||
|
var __Facade_ScheduledController__ = class ___Facade_ScheduledController__ {
|
||||||
|
constructor(scheduledTime, cron, noRetry) {
|
||||||
|
this.scheduledTime = scheduledTime;
|
||||||
|
this.cron = cron;
|
||||||
|
this.#noRetry = noRetry;
|
||||||
|
}
|
||||||
|
static {
|
||||||
|
__name(this, "__Facade_ScheduledController__");
|
||||||
|
}
|
||||||
|
#noRetry;
|
||||||
|
noRetry() {
|
||||||
|
if (!(this instanceof ___Facade_ScheduledController__)) {
|
||||||
|
throw new TypeError("Illegal invocation");
|
||||||
|
}
|
||||||
|
this.#noRetry();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
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 = /* @__PURE__ */ __name((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);
|
||||||
|
}, "#fetchDispatcher");
|
||||||
|
#dispatcher = /* @__PURE__ */ __name((type, init) => {
|
||||||
|
if (type === "scheduled" && super.scheduled !== void 0) {
|
||||||
|
const controller = new __Facade_ScheduledController__(
|
||||||
|
Date.now(),
|
||||||
|
init.cron ?? "",
|
||||||
|
() => {
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return super.scheduled(controller);
|
||||||
|
}
|
||||||
|
}, "#dispatcher");
|
||||||
|
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=%5B%5Bpath%5D%5D.js.map
|
||||||
8
.wrangler/tmp/dev-kRSTjH/[[path]].js.map
Normal file
8
.wrangler/tmp/dev-kRSTjH/[[path]].js.map
Normal file
File diff suppressed because one or more lines are too long
2744
.wrangler/tmp/dev-m5fb1Z/[[path]].js
Normal file
2744
.wrangler/tmp/dev-m5fb1Z/[[path]].js
Normal file
File diff suppressed because it is too large
Load Diff
8
.wrangler/tmp/dev-m5fb1Z/[[path]].js.map
Normal file
8
.wrangler/tmp/dev-m5fb1Z/[[path]].js.map
Normal file
File diff suppressed because one or more lines are too long
407
.wrangler/tmp/dev-puTXdr/[[path]].js
Normal file
407
.wrangler/tmp/dev-puTXdr/[[path]].js
Normal file
@@ -0,0 +1,407 @@
|
|||||||
|
var __defProp = Object.defineProperty;
|
||||||
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
||||||
|
|
||||||
|
// .wrangler/tmp/bundle-fNR4lX/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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// functions/[[path]].ts
|
||||||
|
function corsHeaders() {
|
||||||
|
return {
|
||||||
|
"Access-Control-Allow-Origin": "*",
|
||||||
|
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS",
|
||||||
|
"Access-Control-Allow-Headers": "Content-Type, Authorization, X-Requested-With",
|
||||||
|
"Access-Control-Max-Age": "86400"
|
||||||
|
};
|
||||||
|
}
|
||||||
|
__name(corsHeaders, "corsHeaders");
|
||||||
|
function corsResponse(response) {
|
||||||
|
const headers = new Headers(response.headers);
|
||||||
|
Object.entries(corsHeaders()).forEach(([key, value]) => {
|
||||||
|
headers.set(key, value);
|
||||||
|
});
|
||||||
|
return new Response(response.body, {
|
||||||
|
status: response.status,
|
||||||
|
statusText: response.statusText,
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
}
|
||||||
|
__name(corsResponse, "corsResponse");
|
||||||
|
var path_default = {
|
||||||
|
fetch: /* @__PURE__ */ __name(async (request, env, ctx) => {
|
||||||
|
console.log("Worker fetch called:", request.method, request.url);
|
||||||
|
const url = new URL(request.url);
|
||||||
|
const path = url.pathname;
|
||||||
|
if (request.method === "OPTIONS") {
|
||||||
|
return new Response(null, {
|
||||||
|
status: 200,
|
||||||
|
headers: corsHeaders()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (path === "/") {
|
||||||
|
return corsResponse(new Response("Pixiv Now Worker is running!", {
|
||||||
|
headers: { "Content-Type": "text/plain" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (path === "/test") {
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
message: "Test successful",
|
||||||
|
timestamp: Date.now(),
|
||||||
|
method: request.method,
|
||||||
|
path
|
||||||
|
}), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
if (path === "/api/illust/random") {
|
||||||
|
return await handleRandomAPI(request, env, url);
|
||||||
|
}
|
||||||
|
if (path.match(/^\/(ajax|rpc)\//)) {
|
||||||
|
return await handleGenericProxy(request, env);
|
||||||
|
}
|
||||||
|
if (path.match(/^\/[~-]\//)) {
|
||||||
|
return await handleImageProxy(request, env);
|
||||||
|
}
|
||||||
|
if (path === "/api/user") {
|
||||||
|
return await handleUserAPI(request, env, url);
|
||||||
|
}
|
||||||
|
return corsResponse(new Response("Not Found", {
|
||||||
|
status: 404,
|
||||||
|
headers: { "Content-Type": "text/plain" }
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Worker error:", error);
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}, "fetch")
|
||||||
|
};
|
||||||
|
async function handleRandomAPI(request, env, url) {
|
||||||
|
try {
|
||||||
|
const requestImage = (request.headers.get("accept")?.includes("image") || url.searchParams.get("format") === "image") && url.searchParams.get("format") !== "json";
|
||||||
|
const mockIllusts = [
|
||||||
|
{
|
||||||
|
id: "123456789",
|
||||||
|
title: "Test Illustration",
|
||||||
|
userId: "987654321",
|
||||||
|
userName: "Test Artist",
|
||||||
|
tags: ["test", "mock"],
|
||||||
|
updateDate: "2024-01-01T12:00:00+00:00",
|
||||||
|
urls: {
|
||||||
|
mini: "https://i.pximg.net/c/48x48/img-master/img/2024/01/01/12/00/00/123456789_p0_square1200.jpg",
|
||||||
|
thumb: "https://i.pximg.net/c/250x250_80_a2/img-master/img/2024/01/01/12/00/00/123456789_p0_square1200.jpg",
|
||||||
|
small: "https://i.pximg.net/c/540x540_70/img-master/img/2024/01/01/12/00/00/123456789_p0_master1200.jpg",
|
||||||
|
regular: "https://i.pximg.net/img-master/img/2024/01/01/12/00/00/123456789_p0_master1200.jpg",
|
||||||
|
original: "https://i.pximg.net/img-original/img/2024/01/01/12/00/00/123456789_p0.jpg"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
|
if (requestImage && mockIllusts[0]?.urls?.regular) {
|
||||||
|
return corsResponse(new Response(null, {
|
||||||
|
status: 302,
|
||||||
|
headers: { Location: mockIllusts[0].urls.regular }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
return corsResponse(new Response(JSON.stringify(mockIllusts), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in random API:", error);
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__name(handleRandomAPI, "handleRandomAPI");
|
||||||
|
async function handleGenericProxy(request, env) {
|
||||||
|
const url = new URL(request.url);
|
||||||
|
url.hostname = "www.pixiv.net";
|
||||||
|
const headers = new Headers(request.headers);
|
||||||
|
headers.set("origin", "https://www.pixiv.net");
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
method: request.method,
|
||||||
|
headers,
|
||||||
|
body: request.body
|
||||||
|
});
|
||||||
|
const response = await fetch(newReq);
|
||||||
|
return corsResponse(response);
|
||||||
|
}
|
||||||
|
__name(handleGenericProxy, "handleGenericProxy");
|
||||||
|
async function handleImageProxy(request, env) {
|
||||||
|
const url = new URL(request.url);
|
||||||
|
const path = url.pathname.slice(2);
|
||||||
|
if (url.pathname.startsWith("/~")) {
|
||||||
|
if (env.VITE_PXIMG_BASEURL_S) {
|
||||||
|
url.href = env.VITE_PXIMG_BASEURL_S + path;
|
||||||
|
} else {
|
||||||
|
url.hostname = "s.pximg.net";
|
||||||
|
url.pathname = "/" + path;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (env.VITE_PXIMG_BASEURL_I) {
|
||||||
|
url.href = env.VITE_PXIMG_BASEURL_I + path;
|
||||||
|
} else {
|
||||||
|
url.hostname = "i.pximg.net";
|
||||||
|
url.pathname = "/" + path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const headers = new Headers();
|
||||||
|
for (const h of ["accept", "accept-encoding", "accept-language", "cache-control", "user-agent"]) {
|
||||||
|
if (request.headers.get(h)) {
|
||||||
|
headers.set(h, request.headers.get(h));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
headers
|
||||||
|
});
|
||||||
|
const response = await fetch(newReq);
|
||||||
|
return corsResponse(response);
|
||||||
|
}
|
||||||
|
__name(handleImageProxy, "handleImageProxy");
|
||||||
|
async function handleUserAPI(request, env, url) {
|
||||||
|
try {
|
||||||
|
const userId = url.searchParams.get("id");
|
||||||
|
if (!userId) {
|
||||||
|
return corsResponse(new Response(JSON.stringify({ error: "User ID is required" }), {
|
||||||
|
status: 400,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
const pixivUrl = new URL(`https://www.pixiv.net/ajax/user/${userId}`);
|
||||||
|
const headers = new Headers();
|
||||||
|
headers.set("referer", "https://www.pixiv.net/");
|
||||||
|
headers.set("user-agent", env.USER_AGENT || "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0");
|
||||||
|
const response = await fetch(pixivUrl.toString(), { headers });
|
||||||
|
if (!response.ok) {
|
||||||
|
return corsResponse(new Response(JSON.stringify({ error: `Pixiv API returned ${response.status}` }), {
|
||||||
|
status: response.status,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
const data = await response.json();
|
||||||
|
return corsResponse(new Response(JSON.stringify(data), {
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error in user API:", error);
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: "Internal server error",
|
||||||
|
message: error instanceof Error ? error.message : "Unknown error"
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
__name(handleUserAPI, "handleUserAPI");
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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@4.42.1/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-fNR4lX/middleware-insertion-facade.js
|
||||||
|
var __INTERNAL_WRANGLER_MIDDLEWARE__ = [
|
||||||
|
middleware_ensure_req_body_drained_default,
|
||||||
|
middleware_miniflare3_json_error_default
|
||||||
|
];
|
||||||
|
var middleware_insertion_facade_default = path_default;
|
||||||
|
|
||||||
|
// node_modules/.pnpm/wrangler@4.42.1/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-fNR4lX/middleware-loader.entry.ts
|
||||||
|
var __Facade_ScheduledController__ = class ___Facade_ScheduledController__ {
|
||||||
|
constructor(scheduledTime, cron, noRetry) {
|
||||||
|
this.scheduledTime = scheduledTime;
|
||||||
|
this.cron = cron;
|
||||||
|
this.#noRetry = noRetry;
|
||||||
|
}
|
||||||
|
static {
|
||||||
|
__name(this, "__Facade_ScheduledController__");
|
||||||
|
}
|
||||||
|
#noRetry;
|
||||||
|
noRetry() {
|
||||||
|
if (!(this instanceof ___Facade_ScheduledController__)) {
|
||||||
|
throw new TypeError("Illegal invocation");
|
||||||
|
}
|
||||||
|
this.#noRetry();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
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 = /* @__PURE__ */ __name((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);
|
||||||
|
}, "#fetchDispatcher");
|
||||||
|
#dispatcher = /* @__PURE__ */ __name((type, init) => {
|
||||||
|
if (type === "scheduled" && super.scheduled !== void 0) {
|
||||||
|
const controller = new __Facade_ScheduledController__(
|
||||||
|
Date.now(),
|
||||||
|
init.cron ?? "",
|
||||||
|
() => {
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return super.scheduled(controller);
|
||||||
|
}
|
||||||
|
}, "#dispatcher");
|
||||||
|
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=%5B%5Bpath%5D%5D.js.map
|
||||||
8
.wrangler/tmp/dev-puTXdr/[[path]].js.map
Normal file
8
.wrangler/tmp/dev-puTXdr/[[path]].js.map
Normal file
File diff suppressed because one or more lines are too long
121
DEPLOYMENT.md
Normal file
121
DEPLOYMENT.md
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
# PixivNow Worker 部署指南
|
||||||
|
|
||||||
|
## 快速部署(零配置)
|
||||||
|
|
||||||
|
PixivNow Worker 支持零配置部署,无需设置任何环境变量即可正常运行:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. 安装依赖
|
||||||
|
pnpm install
|
||||||
|
|
||||||
|
# 2. 登录 Cloudflare
|
||||||
|
pnpm wrangler login
|
||||||
|
|
||||||
|
# 3. 部署到 Cloudflare Workers
|
||||||
|
pnpm deploy
|
||||||
|
```
|
||||||
|
|
||||||
|
## 本地开发
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 启动本地开发服务器
|
||||||
|
pnpm serve
|
||||||
|
|
||||||
|
# 服务器将在 http://127.0.0.1:8787 启动
|
||||||
|
```
|
||||||
|
|
||||||
|
## API 端点
|
||||||
|
|
||||||
|
- `GET /` - 健康检查
|
||||||
|
- `GET /api/illust/random` - 随机插画 API
|
||||||
|
- `GET /api/user?id={user_id}` - 用户信息 API
|
||||||
|
- `GET /-/{image_path}` - i.pximg.net 图片代理
|
||||||
|
- `GET /~/{image_path}` - s.pximg.net 图片代理
|
||||||
|
- `GET /{pixiv_path}` - 通用 Pixiv 代理
|
||||||
|
|
||||||
|
## 反代配置
|
||||||
|
|
||||||
|
### 通过 wrangler.toml 配置
|
||||||
|
|
||||||
|
编辑 `wrangler.toml` 文件中的 `[vars]` 部分:
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[vars]
|
||||||
|
# 图片反代配置
|
||||||
|
VITE_PXIMG_BASEURL_I = "https://i.pixiv.re/" # i.pximg.net 反代
|
||||||
|
VITE_PXIMG_BASEURL_S = "https://s.pixiv.re/" # s.pximg.net 反代
|
||||||
|
|
||||||
|
# 其他可选配置
|
||||||
|
USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
|
||||||
|
UA_BLACKLIST = "[]"
|
||||||
|
```
|
||||||
|
|
||||||
|
### 通过 Cloudflare Dashboard 配置
|
||||||
|
|
||||||
|
1. 登录 [Cloudflare Dashboard](https://dash.cloudflare.com/)
|
||||||
|
2. 进入 Workers & Pages
|
||||||
|
3. 选择你的 Worker
|
||||||
|
4. 进入 Settings > Variables
|
||||||
|
5. 添加环境变量:
|
||||||
|
- `VITE_PXIMG_BASEURL_I`: i.pximg.net 的反代 URL
|
||||||
|
- `VITE_PXIMG_BASEURL_S`: s.pximg.net 的反代 URL
|
||||||
|
- `USER_AGENT`: 自定义 User-Agent(可选)
|
||||||
|
|
||||||
|
### 常用反代服务
|
||||||
|
|
||||||
|
```toml
|
||||||
|
# pixiv.re (推荐)
|
||||||
|
VITE_PXIMG_BASEURL_I = "https://i.pixiv.re/"
|
||||||
|
VITE_PXIMG_BASEURL_S = "https://s.pixiv.re/"
|
||||||
|
|
||||||
|
# pixiv.cat
|
||||||
|
VITE_PXIMG_BASEURL_I = "https://i.pixiv.cat/"
|
||||||
|
VITE_PXIMG_BASEURL_S = "https://s.pixiv.cat/"
|
||||||
|
|
||||||
|
# 自定义反代
|
||||||
|
VITE_PXIMG_BASEURL_I = "https://your-proxy-domain.com/"
|
||||||
|
VITE_PXIMG_BASEURL_S = "https://your-s-proxy-domain.com/"
|
||||||
|
```
|
||||||
|
|
||||||
|
## 默认配置
|
||||||
|
|
||||||
|
如果不设置环境变量,Worker 将使用以下默认值:
|
||||||
|
|
||||||
|
- **图片代理**: 直接访问 Pixiv 原始 URL (`i.pximg.net`, `s.pximg.net`)
|
||||||
|
- **User-Agent**: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0`
|
||||||
|
- **UA 黑名单**: 空数组 `[]`
|
||||||
|
- **CORS**: 完全开放,支持所有域名
|
||||||
|
|
||||||
|
## 测试反代配置
|
||||||
|
|
||||||
|
部署后,可以通过以下方式测试反代是否生效:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 测试 i.pximg.net 反代
|
||||||
|
curl -I "https://your-worker.your-subdomain.workers.dev/-/img-master/img/2024/01/01/00/00/00/123456_p0_master1200.jpg"
|
||||||
|
|
||||||
|
# 测试 s.pximg.net 反代
|
||||||
|
curl -I "https://your-worker.your-subdomain.workers.dev/~/c/250x250_80_a2_g5/img-master/img/2024/01/01/00/00/00/123456_p0_square1200.jpg"
|
||||||
|
```
|
||||||
|
|
||||||
|
如果配置了反代,响应头中应该包含反代服务的标识(如 `x-proxied-by`)。
|
||||||
|
|
||||||
|
## 故障排除
|
||||||
|
|
||||||
|
### 1. 图片无法加载
|
||||||
|
- 检查反代 URL 是否正确
|
||||||
|
- 确认反代服务是否可用
|
||||||
|
- 验证环境变量是否正确设置
|
||||||
|
|
||||||
|
### 2. CORS 错误
|
||||||
|
- Worker 默认启用 CORS,支持所有域名
|
||||||
|
- 如果仍有问题,检查请求头是否正确
|
||||||
|
|
||||||
|
### 3. 部署失败
|
||||||
|
- 确认已登录 Cloudflare: `pnpm wrangler login`
|
||||||
|
- 检查 `wrangler.toml` 配置是否正确
|
||||||
|
- 验证 Worker 名称是否唯一
|
||||||
|
|
||||||
|
## 许可证
|
||||||
|
|
||||||
|
MIT License
|
||||||
356
functions/[[path]].ts
Normal file
356
functions/[[path]].ts
Normal file
@@ -0,0 +1,356 @@
|
|||||||
|
// 手动实现 CORS 处理
|
||||||
|
function corsHeaders() {
|
||||||
|
return {
|
||||||
|
'Access-Control-Allow-Origin': '*',
|
||||||
|
'Access-Control-Allow-Methods': 'GET, POST, PUT, DELETE, OPTIONS',
|
||||||
|
'Access-Control-Allow-Headers': 'Content-Type, Authorization, X-Requested-With',
|
||||||
|
'Access-Control-Max-Age': '86400',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function corsResponse(response: Response) {
|
||||||
|
const headers = new Headers(response.headers)
|
||||||
|
Object.entries(corsHeaders()).forEach(([key, value]) => {
|
||||||
|
headers.set(key, value)
|
||||||
|
})
|
||||||
|
return new Response(response.body, {
|
||||||
|
status: response.status,
|
||||||
|
statusText: response.statusText,
|
||||||
|
headers,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default {
|
||||||
|
fetch: async (request: Request, env: any, ctx: any) => {
|
||||||
|
console.log('Worker fetch called:', request.method, request.url)
|
||||||
|
|
||||||
|
const url = new URL(request.url)
|
||||||
|
const path = url.pathname
|
||||||
|
|
||||||
|
// 处理 OPTIONS 请求(CORS 预检)
|
||||||
|
if (request.method === 'OPTIONS') {
|
||||||
|
return new Response(null, {
|
||||||
|
status: 200,
|
||||||
|
headers: corsHeaders(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 健康检查端点
|
||||||
|
if (path === '/') {
|
||||||
|
return corsResponse(new Response('Pixiv Now Worker is running!', {
|
||||||
|
headers: { 'Content-Type': 'text/plain' },
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 测试端点
|
||||||
|
if (path === '/test') {
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
message: 'Test successful',
|
||||||
|
timestamp: Date.now(),
|
||||||
|
method: request.method,
|
||||||
|
path: path
|
||||||
|
}), {
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 随机图片 API
|
||||||
|
if (path === '/api/illust/random') {
|
||||||
|
return await handleRandomAPI(request, env, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通用代理 (ajax|rpc)
|
||||||
|
if (path.match(/^\/(ajax|rpc)\//)) {
|
||||||
|
return await handleGenericProxy(request, env)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 图片代理 (~|-)
|
||||||
|
if (path.match(/^\/[~-]\//)) {
|
||||||
|
return await handleImageProxy(request, env)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 用户 API
|
||||||
|
if (path === '/api/user') {
|
||||||
|
return await handleUserAPI(request, env, url)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 404
|
||||||
|
return corsResponse(new Response('Not Found', {
|
||||||
|
status: 404,
|
||||||
|
headers: { 'Content-Type': 'text/plain' }
|
||||||
|
}))
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Worker error:', error)
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: 'Internal server error',
|
||||||
|
message: error instanceof Error ? error.message : 'Unknown error'
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// 随机图片 API 处理器
|
||||||
|
async function handleRandomAPI(request: Request, env: any, url: URL) {
|
||||||
|
try {
|
||||||
|
// 简化版本:返回模拟数据而不是调用 Pixiv API
|
||||||
|
const requestImage =
|
||||||
|
(request.headers.get('accept')?.includes('image') || url.searchParams.get('format') === 'image') &&
|
||||||
|
url.searchParams.get('format') !== 'json'
|
||||||
|
|
||||||
|
// 模拟数据用于测试
|
||||||
|
const mockIllusts = [
|
||||||
|
{
|
||||||
|
id: '123456789',
|
||||||
|
title: 'Test Illustration',
|
||||||
|
userId: '987654321',
|
||||||
|
userName: 'Test Artist',
|
||||||
|
tags: ['test', 'mock'],
|
||||||
|
updateDate: '2024-01-01T12:00:00+00:00',
|
||||||
|
urls: {
|
||||||
|
mini: 'https://i.pximg.net/c/48x48/img-master/img/2024/01/01/12/00/00/123456789_p0_square1200.jpg',
|
||||||
|
thumb: 'https://i.pximg.net/c/250x250_80_a2/img-master/img/2024/01/01/12/00/00/123456789_p0_square1200.jpg',
|
||||||
|
small: 'https://i.pximg.net/c/540x540_70/img-master/img/2024/01/01/12/00/00/123456789_p0_master1200.jpg',
|
||||||
|
regular: 'https://i.pximg.net/img-master/img/2024/01/01/12/00/00/123456789_p0_master1200.jpg',
|
||||||
|
original: 'https://i.pximg.net/img-original/img/2024/01/01/12/00/00/123456789_p0.jpg',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
if (requestImage && mockIllusts[0]?.urls?.regular) {
|
||||||
|
return corsResponse(new Response(null, {
|
||||||
|
status: 302,
|
||||||
|
headers: { Location: mockIllusts[0].urls.regular }
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
return corsResponse(new Response(JSON.stringify(mockIllusts), {
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
}))
|
||||||
|
|
||||||
|
/* 原始 Pixiv API 调用代码 - 暂时注释掉
|
||||||
|
const pixivUrl = new URL('https://www.pixiv.net/ajax/illust/discovery')
|
||||||
|
pixivUrl.searchParams.set('mode', url.searchParams.get('mode') ?? 'safe')
|
||||||
|
pixivUrl.searchParams.set('max', requestImage ? '1' : url.searchParams.get('max') ?? '18')
|
||||||
|
|
||||||
|
const headers = new Headers()
|
||||||
|
headers.set('referer', 'https://www.pixiv.net/')
|
||||||
|
// 使用默认的 User-Agent,或者环境变量中的自定义 User-Agent
|
||||||
|
// 使用默认的 User-Agent,或者环境变量中的自定义 User-Agent
|
||||||
|
headers.set('user-agent', env.USER_AGENT || 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0')
|
||||||
|
|
||||||
|
console.log('Fetching from Pixiv API:', pixivUrl.toString())
|
||||||
|
const response = await fetch(pixivUrl.toString(), { headers })
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
console.error('Pixiv API error:', response.status, response.statusText)
|
||||||
|
return corsResponse(new Response(JSON.stringify({ error: `Pixiv API returned ${response.status}` }), {
|
||||||
|
status: response.status,
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json()
|
||||||
|
console.log('Pixiv API response:', data)
|
||||||
|
|
||||||
|
// 检查 API 响应是否有错误
|
||||||
|
if (data.error) {
|
||||||
|
console.error('Pixiv API returned error:', data.error)
|
||||||
|
return corsResponse(new Response(JSON.stringify({ error: data.error }), {
|
||||||
|
status: 400,
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
const illusts = (data.illusts ?? []).filter((value: any) =>
|
||||||
|
value && typeof value === 'object' && value.id
|
||||||
|
)
|
||||||
|
|
||||||
|
if (illusts.length === 0) {
|
||||||
|
return corsResponse(new Response(JSON.stringify([]), {
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
// 使用默认的 Pixiv 图片 URL,或者环境变量中的自定义代理 URL
|
||||||
|
const PXIMG_BASEURL_I = (env.VITE_PXIMG_BASEURL_I || 'https://i.pximg.net/').replace(/\/$/, '') + '/'
|
||||||
|
|
||||||
|
// 处理图片 URL
|
||||||
|
illusts.forEach((value: any) => {
|
||||||
|
try {
|
||||||
|
if (value.updateDate) {
|
||||||
|
const date = new Date(value.updateDate)
|
||||||
|
const year = date.getFullYear()
|
||||||
|
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||||
|
const day = String(date.getDate()).padStart(2, '0')
|
||||||
|
const hour = String(date.getHours()).padStart(2, '0')
|
||||||
|
const minute = String(date.getMinutes()).padStart(2, '0')
|
||||||
|
const second = String(date.getSeconds()).padStart(2, '0')
|
||||||
|
|
||||||
|
const middle = `img/${year}/${month}/${day}/${hour}/${minute}/${second}/${value.id}`
|
||||||
|
|
||||||
|
value.urls = {
|
||||||
|
mini: `${PXIMG_BASEURL_I}c/48x48/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
thumb: `${PXIMG_BASEURL_I}c/250x250_80_a2/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
small: `${PXIMG_BASEURL_I}c/540x540_70/img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
regular: `${PXIMG_BASEURL_I}img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
original: `${PXIMG_BASEURL_I}img-original/${middle}_p0.jpg`,
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const middle = `img/2024/01/01/00/00/00/${value.id}`
|
||||||
|
value.urls = {
|
||||||
|
mini: `${PXIMG_BASEURL_I}c/48x48/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
thumb: `${PXIMG_BASEURL_I}c/250x250_80_a2/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
small: `${PXIMG_BASEURL_I}c/540x540_70/img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
regular: `${PXIMG_BASEURL_I}img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
original: `${PXIMG_BASEURL_I}img-original/${middle}_p0.jpg`,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error processing illust:', value.id, error)
|
||||||
|
const middle = `img/2024/01/01/00/00/00/${value.id}`
|
||||||
|
value.urls = {
|
||||||
|
mini: `${PXIMG_BASEURL_I}c/48x48/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
thumb: `${PXIMG_BASEURL_I}c/250x250_80_a2/img-master/${middle}_p0_square1200.jpg`,
|
||||||
|
small: `${PXIMG_BASEURL_I}c/540x540_70/img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
regular: `${PXIMG_BASEURL_I}img-master/${middle}_p0_master1200.jpg`,
|
||||||
|
original: `${PXIMG_BASEURL_I}img-original/${middle}_p0.jpg`,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (requestImage && illusts[0]?.urls?.regular) {
|
||||||
|
return corsResponse(new Response(null, {
|
||||||
|
status: 302,
|
||||||
|
headers: { Location: illusts[0].urls.regular }
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
return corsResponse(new Response(JSON.stringify(illusts), {
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
}))
|
||||||
|
*/
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error in random API:', error)
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: 'Internal server error',
|
||||||
|
message: error instanceof Error ? error.message : 'Unknown error'
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通用代理处理器
|
||||||
|
async function handleGenericProxy(request: Request, env: any) {
|
||||||
|
const url = new URL(request.url)
|
||||||
|
url.hostname = 'www.pixiv.net'
|
||||||
|
|
||||||
|
const headers = new Headers(request.headers)
|
||||||
|
headers.set('origin', 'https://www.pixiv.net')
|
||||||
|
headers.set('referer', 'https://www.pixiv.net/')
|
||||||
|
// 使用默认的 User-Agent,或者环境变量中的自定义 User-Agent
|
||||||
|
headers.set('user-agent', env.USER_AGENT || 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0')
|
||||||
|
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
method: request.method,
|
||||||
|
headers,
|
||||||
|
body: request.body,
|
||||||
|
})
|
||||||
|
|
||||||
|
const response = await fetch(newReq)
|
||||||
|
return corsResponse(response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 图片代理处理器
|
||||||
|
async function handleImageProxy(request: Request, env: any) {
|
||||||
|
const url = new URL(request.url)
|
||||||
|
const path = url.pathname.slice(2)
|
||||||
|
|
||||||
|
// 使用环境变量配置的反代 URL,或者默认的 Pixiv 原始 URL
|
||||||
|
if (url.pathname.startsWith('/~')) {
|
||||||
|
// 处理 s.pximg.net 的图片
|
||||||
|
if (env.VITE_PXIMG_BASEURL_S) {
|
||||||
|
url.href = env.VITE_PXIMG_BASEURL_S + path
|
||||||
|
} else {
|
||||||
|
url.hostname = 's.pximg.net'
|
||||||
|
url.pathname = '/' + path
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 处理 i.pximg.net 的图片
|
||||||
|
if (env.VITE_PXIMG_BASEURL_I) {
|
||||||
|
url.href = env.VITE_PXIMG_BASEURL_I + path
|
||||||
|
} else {
|
||||||
|
url.hostname = 'i.pximg.net'
|
||||||
|
url.pathname = '/' + path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const headers = new Headers()
|
||||||
|
for (const h of ['accept', 'accept-encoding', 'accept-language', 'cache-control', 'user-agent']) {
|
||||||
|
if (request.headers.get(h)) {
|
||||||
|
headers.set(h, request.headers.get(h)!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
headers.set('referer', 'https://www.pixiv.net/')
|
||||||
|
// 使用默认的 User-Agent,或者环境变量中的自定义 User-Agent
|
||||||
|
headers.set('user-agent', env.USER_AGENT || 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0')
|
||||||
|
|
||||||
|
const newReq = new Request(url.toString(), {
|
||||||
|
headers,
|
||||||
|
})
|
||||||
|
|
||||||
|
const response = await fetch(newReq)
|
||||||
|
return corsResponse(response)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 用户 API 处理器
|
||||||
|
async function handleUserAPI(request: Request, env: any, url: URL) {
|
||||||
|
try {
|
||||||
|
const userId = url.searchParams.get('id')
|
||||||
|
|
||||||
|
if (!userId) {
|
||||||
|
return corsResponse(new Response(JSON.stringify({ error: 'User ID is required' }), {
|
||||||
|
status: 400,
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
const pixivUrl = new URL(`https://www.pixiv.net/ajax/user/${userId}`)
|
||||||
|
|
||||||
|
const headers = new Headers()
|
||||||
|
headers.set('referer', 'https://www.pixiv.net/')
|
||||||
|
// 使用默认的 User-Agent,或者环境变量中的自定义 User-Agent
|
||||||
|
headers.set('user-agent', env.USER_AGENT || 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 Edg/122.0.0.0')
|
||||||
|
|
||||||
|
const response = await fetch(pixivUrl.toString(), { headers })
|
||||||
|
|
||||||
|
if (!response.ok) {
|
||||||
|
return corsResponse(new Response(JSON.stringify({ error: `Pixiv API returned ${response.status}` }), {
|
||||||
|
status: response.status,
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
const data = await response.json()
|
||||||
|
|
||||||
|
return corsResponse(new Response(JSON.stringify(data), {
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
}))
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error in user API:', error)
|
||||||
|
return corsResponse(new Response(JSON.stringify({
|
||||||
|
error: 'Internal server error',
|
||||||
|
message: error instanceof Error ? error.message : 'Unknown error'
|
||||||
|
}), {
|
||||||
|
status: 500,
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
}
|
||||||
12
package.json
12
package.json
@@ -12,17 +12,17 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "vite",
|
"start": "vite",
|
||||||
"serve": "vercel dev",
|
"serve": "wrangler dev",
|
||||||
"build": "vite build",
|
"build": "vite build",
|
||||||
"preview": "vercel deploy",
|
"preview": "wrangler deploy",
|
||||||
"changelog": "conventional-changelog -p jquery -i CHANGELOG.md -s -r 0"
|
"changelog": "conventional-changelog -p jquery -i CHANGELOG.md -s -r 0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^1.11.0",
|
|
||||||
"date-fns": "^4.1.0",
|
"date-fns": "^4.1.0",
|
||||||
"date-fns-tz": "^3.2.0",
|
"date-fns-tz": "^3.2.0",
|
||||||
"fflate": "^0.8.2",
|
"fflate": "^0.8.2",
|
||||||
"gif.js": "^0.2.0",
|
"gif.js": "^0.2.0",
|
||||||
|
"itty-router": "^5.0.22",
|
||||||
"js-cookie": "^3.0.5",
|
"js-cookie": "^3.0.5",
|
||||||
"modern-mp4": "^0.2.0",
|
"modern-mp4": "^0.2.0",
|
||||||
"naive-ui": "^2.42.0",
|
"naive-ui": "^2.42.0",
|
||||||
@@ -44,11 +44,9 @@
|
|||||||
"@types/lodash.escaperegexp": "^4.1.9",
|
"@types/lodash.escaperegexp": "^4.1.9",
|
||||||
"@types/node": "^22.17.2",
|
"@types/node": "^22.17.2",
|
||||||
"@types/nprogress": "^0.2.3",
|
"@types/nprogress": "^0.2.3",
|
||||||
"@vercel/node": "^5.3.13",
|
|
||||||
"@vitejs/plugin-vue": "^6.0.1",
|
"@vitejs/plugin-vue": "^6.0.1",
|
||||||
"@vue/language-plugin-pug": "^3.0.6",
|
"@vue/language-plugin-pug": "^3.0.6",
|
||||||
"@vueuse/core": "^13.7.0",
|
"@vueuse/core": "^13.7.0",
|
||||||
"cheerio": "^1.1.2",
|
|
||||||
"conventional-changelog-cli": "^5.0.0",
|
"conventional-changelog-cli": "^5.0.0",
|
||||||
"cookie": "^1.0.2",
|
"cookie": "^1.0.2",
|
||||||
"lodash.escaperegexp": "^4.1.2",
|
"lodash.escaperegexp": "^4.1.2",
|
||||||
@@ -61,8 +59,8 @@
|
|||||||
"unplugin-auto-import": "^20.0.0",
|
"unplugin-auto-import": "^20.0.0",
|
||||||
"unplugin-icons": "^22.2.0",
|
"unplugin-icons": "^22.2.0",
|
||||||
"unplugin-vue-components": "^29.0.0",
|
"unplugin-vue-components": "^29.0.0",
|
||||||
"vercel": "^46.0.2",
|
"vite": "^7.1.3",
|
||||||
"vite": "^7.1.3"
|
"wrangler": "^4.42.1"
|
||||||
},
|
},
|
||||||
"packageManager": "pnpm@10.18.1"
|
"packageManager": "pnpm@10.18.1"
|
||||||
}
|
}
|
||||||
|
|||||||
2817
pnpm-lock.yaml
generated
2817
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
7
src/components.d.ts
vendored
7
src/components.d.ts
vendored
@@ -27,9 +27,16 @@ declare module 'vue' {
|
|||||||
ListLink: typeof import('./components/SideNav/ListLink.vue')['default']
|
ListLink: typeof import('./components/SideNav/ListLink.vue')['default']
|
||||||
NaiveuiProvider: typeof import('./components/NaiveuiProvider.vue')['default']
|
NaiveuiProvider: typeof import('./components/NaiveuiProvider.vue')['default']
|
||||||
NAlert: typeof import('naive-ui')['NAlert']
|
NAlert: typeof import('naive-ui')['NAlert']
|
||||||
|
NButton: typeof import('naive-ui')['NButton']
|
||||||
|
NCard: typeof import('naive-ui')['NCard']
|
||||||
|
NEmpty: typeof import('naive-ui')['NEmpty']
|
||||||
|
NFlex: typeof import('naive-ui')['NFlex']
|
||||||
NLi: typeof import('naive-ui')['NLi']
|
NLi: typeof import('naive-ui')['NLi']
|
||||||
|
NPagination: typeof import('naive-ui')['NPagination']
|
||||||
NProgress: typeof import('./components/NProgress.vue')['default']
|
NProgress: typeof import('./components/NProgress.vue')['default']
|
||||||
NSpace: typeof import('naive-ui')['NSpace']
|
NSpace: typeof import('naive-ui')['NSpace']
|
||||||
|
NTabPane: typeof import('naive-ui')['NTabPane']
|
||||||
|
NTabs: typeof import('naive-ui')['NTabs']
|
||||||
NTag: typeof import('naive-ui')['NTag']
|
NTag: typeof import('naive-ui')['NTag']
|
||||||
NUl: typeof import('naive-ui')['NUl']
|
NUl: typeof import('naive-ui')['NUl']
|
||||||
Placeholder: typeof import('./components/Placeholder.vue')['default']
|
Placeholder: typeof import('./components/Placeholder.vue')['default']
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import Cookies from 'js-cookie'
|
import Cookies from 'js-cookie'
|
||||||
import { useUserStore } from '@/composables/states'
|
import { useUserStore } from '@/composables/states'
|
||||||
|
import { ajax } from '@/utils/ajax'
|
||||||
|
|
||||||
const store = useUserStore()
|
const store = useUserStore()
|
||||||
|
|
||||||
@@ -41,20 +42,22 @@ async function submit(): Promise<void> {
|
|||||||
if (loading.value) return
|
if (loading.value) return
|
||||||
try {
|
try {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
const { data } = await axios.post(
|
const response = await ajax.post(
|
||||||
`/ajax/illusts/comments/post`,
|
`/ajax/illusts/comments/post`,
|
||||||
{
|
JSON.stringify({
|
||||||
type: 'comment',
|
type: 'comment',
|
||||||
illust_id: props.id,
|
illust_id: props.id,
|
||||||
author_user_id: store.userId,
|
author_user_id: store.userId,
|
||||||
comment,
|
comment,
|
||||||
},
|
}),
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
'X-CSRF-TOKEN': Cookies.get('csrf_token'),
|
'X-CSRF-TOKEN': Cookies.get('csrf_token'),
|
||||||
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
const data = await response.json()
|
||||||
comment.value = ''
|
comment.value = ''
|
||||||
emit('push-comment', {
|
emit('push-comment', {
|
||||||
img: store.userProfileImg,
|
img: store.userProfileImg,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { PixivUser } from '@/types'
|
import { PixivUser } from '@/types'
|
||||||
import Cookies from 'js-cookie'
|
import Cookies from 'js-cookie'
|
||||||
|
import { ajax } from '@/utils/ajax'
|
||||||
|
|
||||||
export function existsSessionId(): boolean {
|
export function existsSessionId(): boolean {
|
||||||
const sessionId = Cookies.get('PHPSESSID')
|
const sessionId = Cookies.get('PHPSESSID')
|
||||||
@@ -13,14 +14,12 @@ export function existsSessionId(): boolean {
|
|||||||
|
|
||||||
export async function initUser(): Promise<PixivUser> {
|
export async function initUser(): Promise<PixivUser> {
|
||||||
try {
|
try {
|
||||||
const { data } = await axios.get<{ userData: PixivUser; token: string }>(
|
const response = await ajax.get(`/api/user`, {
|
||||||
`/api/user`,
|
headers: {
|
||||||
{
|
'Cache-Control': 'no-store',
|
||||||
headers: {
|
},
|
||||||
'Cache-Control': 'no-store',
|
})
|
||||||
},
|
const data: { userData: PixivUser; token: string } = await response.json()
|
||||||
}
|
|
||||||
)
|
|
||||||
if (data.token) {
|
if (data.token) {
|
||||||
console.log('session ID认证成功', data)
|
console.log('session ID认证成功', data)
|
||||||
Cookies.set('CSRFTOKEN', data.token, { secure: true, sameSite: 'Strict' })
|
Cookies.set('CSRFTOKEN', data.token, { secure: true, sameSite: 'Strict' })
|
||||||
|
|||||||
@@ -1,26 +1,34 @@
|
|||||||
import { AxiosRequestConfig } from 'axios'
|
|
||||||
import nprogress from 'nprogress'
|
import nprogress from 'nprogress'
|
||||||
|
|
||||||
export const ajax = axios.create({
|
const createAjax = () => {
|
||||||
timeout: 15 * 1000,
|
const fetchWithInterceptor = async (
|
||||||
headers: {
|
url: string,
|
||||||
'Content-Type': 'application/json',
|
options?: RequestInit,
|
||||||
},
|
): Promise<Response> => {
|
||||||
})
|
nprogress.start()
|
||||||
ajax.interceptors.request.use((config) => {
|
try {
|
||||||
nprogress.start()
|
const response = await fetch(url, options)
|
||||||
return config
|
return response
|
||||||
})
|
} catch (error) {
|
||||||
ajax.interceptors.response.use(
|
return Promise.reject(error)
|
||||||
(res) => {
|
} finally {
|
||||||
nprogress.done()
|
nprogress.done()
|
||||||
return res
|
}
|
||||||
},
|
|
||||||
(err) => {
|
|
||||||
nprogress.done()
|
|
||||||
return Promise.reject(err)
|
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
return {
|
||||||
|
get: (url: string, options?: RequestInit) =>
|
||||||
|
fetchWithInterceptor(url, { ...options, method: 'GET' }),
|
||||||
|
post: (url: string, body?: any, options?: RequestInit) =>
|
||||||
|
fetchWithInterceptor(url, {
|
||||||
|
...options,
|
||||||
|
method: 'POST',
|
||||||
|
body: body,
|
||||||
|
}),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ajax = createAjax()
|
||||||
|
|
||||||
export const ajaxPostWithFormData = (
|
export const ajaxPostWithFormData = (
|
||||||
url: string,
|
url: string,
|
||||||
@@ -30,12 +38,13 @@ export const ajaxPostWithFormData = (
|
|||||||
| Record<string, string>
|
| Record<string, string>
|
||||||
| URLSearchParams
|
| URLSearchParams
|
||||||
| undefined,
|
| undefined,
|
||||||
config?: AxiosRequestConfig
|
config?: RequestInit,
|
||||||
) =>
|
) => {
|
||||||
ajax.post(url, new URLSearchParams(data).toString(), {
|
return ajax.post(url, new URLSearchParams(data).toString(), {
|
||||||
...config,
|
...config,
|
||||||
headers: {
|
headers: {
|
||||||
...config?.headers,
|
...(config?.headers || {}),
|
||||||
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
|
'Content-Type': 'application/x-www-form-urlencoded; charset=utf-8',
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -235,9 +235,13 @@ async function init(id: string): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const [{ data: illustData }, { data: illustPage }] = await Promise.all([
|
const [illustData, illustPage] = await Promise.all([
|
||||||
ajax.get<Artwork>(`/ajax/illust/${id}?full=1`),
|
ajax
|
||||||
ajax.get<ArtworkGallery[]>(`/ajax/illust/${id}/pages`),
|
.get(`/ajax/illust/${id}?full=1`)
|
||||||
|
.then((res) => res.json() as Promise<Artwork>),
|
||||||
|
ajax
|
||||||
|
.get(`/ajax/illust/${id}/pages`)
|
||||||
|
.then((res) => res.json() as Promise<ArtworkGallery[]>),
|
||||||
])
|
])
|
||||||
setCache(`illust.${id}`, illustData)
|
setCache(`illust.${id}`, illustData)
|
||||||
setCache(`illust.${id}.page`, illustPage)
|
setCache(`illust.${id}.page`, illustPage)
|
||||||
@@ -263,11 +267,16 @@ async function handleUserInit(userId: string): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const [{ data: userData }, { data: profileData }] = await Promise.all([
|
const [userData, profileData] = await Promise.all([
|
||||||
axios.get<User>(`/ajax/user/${userId}?full=1`),
|
ajax
|
||||||
axios.get<{ illusts: Record<string, ArtworkInfo> }>(
|
.get(`/ajax/user/${userId}?full=1`)
|
||||||
`/ajax/user/${userId}/profile/top`
|
.then((res) => res.json() as Promise<User>),
|
||||||
),
|
ajax
|
||||||
|
.get(`/ajax/user/${userId}/profile/top`)
|
||||||
|
.then(
|
||||||
|
(res) =>
|
||||||
|
res.json() as Promise<{ illusts: Record<string, ArtworkInfo> }>
|
||||||
|
),
|
||||||
])
|
])
|
||||||
const { illusts } = profileData
|
const { illusts } = profileData
|
||||||
const userValue = {
|
const userValue = {
|
||||||
@@ -286,10 +295,15 @@ async function handleRecommendInit(id: string): Promise<void> {
|
|||||||
try {
|
try {
|
||||||
recommendLoading.value = true
|
recommendLoading.value = true
|
||||||
console.log('init recommend')
|
console.log('init recommend')
|
||||||
const { data } = await ajax.get<{
|
const data = await ajax
|
||||||
illusts: ArtworkInfo[]
|
.get(`/ajax/illust/${id}/recommend/init?limit=18`)
|
||||||
nextIds: string[]
|
.then(
|
||||||
}>(`/ajax/illust/${id}/recommend/init?limit=18`)
|
(res) =>
|
||||||
|
res.json() as Promise<{
|
||||||
|
illusts: ArtworkInfo[]
|
||||||
|
nextIds: string[]
|
||||||
|
}>
|
||||||
|
)
|
||||||
recommend.value = data.illusts
|
recommend.value = data.illusts
|
||||||
recommendNextIds.value = data.nextIds
|
recommendNextIds.value = data.nextIds
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -313,10 +327,15 @@ async function handleMoreRecommend(): Promise<void> {
|
|||||||
for (const id of requestIds) {
|
for (const id of requestIds) {
|
||||||
searchParams.append('illust_ids', id)
|
searchParams.append('illust_ids', id)
|
||||||
}
|
}
|
||||||
const { data } = await ajax.get<{
|
const data = await ajax
|
||||||
illusts: ArtworkInfo[]
|
.get(`/ajax/illust/recommend/illusts?${searchParams.toString()}`)
|
||||||
nextIds: string[]
|
.then(
|
||||||
}>('/ajax/illust/recommend/illusts', { params: searchParams })
|
(res) =>
|
||||||
|
res.json() as Promise<{
|
||||||
|
illusts: ArtworkInfo[]
|
||||||
|
nextIds: string[]
|
||||||
|
}>
|
||||||
|
)
|
||||||
recommend.value = recommend.value.concat(data.illusts)
|
recommend.value = recommend.value.concat(data.illusts)
|
||||||
recommendNextIds.value = recommendNextIds.value.concat(data.nextIds)
|
recommendNextIds.value = recommendNextIds.value.concat(data.nextIds)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
21
wrangler.toml
Normal file
21
wrangler.toml
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
name = "pixivnow-worker"
|
||||||
|
main = "functions/[[path]].ts"
|
||||||
|
compatibility_date = "2023-10-30"
|
||||||
|
|
||||||
|
# 环境变量配置
|
||||||
|
# 这些变量都有默认值,可以根据需要自定义
|
||||||
|
[vars]
|
||||||
|
# User-Agent 黑名单(JSON 数组格式)
|
||||||
|
UA_BLACKLIST = "[]"
|
||||||
|
# 自定义 User-Agent(可选,有默认值)
|
||||||
|
# USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
|
||||||
|
# 自定义图片代理 URL(可选,默认使用 Pixiv 原始 URL)
|
||||||
|
# 示例配置:
|
||||||
|
# VITE_PXIMG_BASEURL_I = "https://i.pixiv.re/"
|
||||||
|
# VITE_PXIMG_BASEURL_S = "https://s.pixiv.re/"
|
||||||
|
VITE_PXIMG_BASEURL_I = "https://i.pixiv.re/"
|
||||||
|
VITE_PXIMG_BASEURL_S = "https://s.pixiv.re/"
|
||||||
|
|
||||||
|
[[rules]]
|
||||||
|
type = "ESModule"
|
||||||
|
globs = ["**/*.ts"]
|
||||||
Reference in New Issue
Block a user