Aktueller Stand
This commit is contained in:
82
backend/node_modules/hono/dist/cjs/helper/adapter/index.js
generated
vendored
Normal file
82
backend/node_modules/hono/dist/cjs/helper/adapter/index.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
"use strict";
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
var adapter_exports = {};
|
||||
__export(adapter_exports, {
|
||||
checkUserAgentEquals: () => checkUserAgentEquals,
|
||||
env: () => env,
|
||||
getRuntimeKey: () => getRuntimeKey,
|
||||
knownUserAgents: () => knownUserAgents
|
||||
});
|
||||
module.exports = __toCommonJS(adapter_exports);
|
||||
const env = (c, runtime) => {
|
||||
const global = globalThis;
|
||||
const globalEnv = global?.process?.env;
|
||||
runtime ??= getRuntimeKey();
|
||||
const runtimeEnvHandlers = {
|
||||
bun: () => globalEnv,
|
||||
node: () => globalEnv,
|
||||
"edge-light": () => globalEnv,
|
||||
deno: () => {
|
||||
return Deno.env.toObject();
|
||||
},
|
||||
workerd: () => c.env,
|
||||
// On Fastly Compute, you can use the ConfigStore to manage user-defined data.
|
||||
fastly: () => ({}),
|
||||
other: () => ({})
|
||||
};
|
||||
return runtimeEnvHandlers[runtime]();
|
||||
};
|
||||
const knownUserAgents = {
|
||||
deno: "Deno",
|
||||
bun: "Bun",
|
||||
workerd: "Cloudflare-Workers",
|
||||
node: "Node.js"
|
||||
};
|
||||
const getRuntimeKey = () => {
|
||||
const global = globalThis;
|
||||
const userAgentSupported = typeof navigator !== "undefined" && typeof navigator.userAgent === "string";
|
||||
if (userAgentSupported) {
|
||||
for (const [runtimeKey, userAgent] of Object.entries(knownUserAgents)) {
|
||||
if (checkUserAgentEquals(userAgent)) {
|
||||
return runtimeKey;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (typeof global?.EdgeRuntime === "string") {
|
||||
return "edge-light";
|
||||
}
|
||||
if (global?.fastly !== void 0) {
|
||||
return "fastly";
|
||||
}
|
||||
if (global?.process?.release?.name === "node") {
|
||||
return "node";
|
||||
}
|
||||
return "other";
|
||||
};
|
||||
const checkUserAgentEquals = (platform) => {
|
||||
const userAgent = navigator.userAgent;
|
||||
return userAgent.startsWith(platform);
|
||||
};
|
||||
// Annotate the CommonJS export names for ESM import in node:
|
||||
0 && (module.exports = {
|
||||
checkUserAgentEquals,
|
||||
env,
|
||||
getRuntimeKey,
|
||||
knownUserAgents
|
||||
});
|
||||
Reference in New Issue
Block a user