chore(8.0): final pre-RC1 sweep — API consistency, named errors, orphans, zero-cast codebase

This commit is contained in:
David Snelling 2026-06-11 14:51:00 -07:00
parent 970e08c466
commit 1f7e365a4e
237 changed files with 1951 additions and 49413 deletions

View file

@ -76,20 +76,29 @@ export const INTEGRATION_CATALOG: Record<IntegrationType, IntegrationInfo> = {
* Detect current runtime environment
*/
export function detectEnvironment(): RuntimeEnvironment {
// Runtime-detection boundary: these globals exist only in specific runtimes
// (Deno, Bun, Cloudflare Workers), so they aren't on TypeScript's view of
// globalThis — probe them through an optional-keyed view.
const runtimeGlobals = globalThis as typeof globalThis & {
Deno?: unknown
Bun?: unknown
HTMLRewriter?: unknown
}
// Deno
if (typeof (globalThis as any).Deno !== 'undefined') {
if (typeof runtimeGlobals.Deno !== 'undefined') {
return 'deno'
}
// Bun
if (typeof (globalThis as any).Bun !== 'undefined') {
if (typeof runtimeGlobals.Bun !== 'undefined') {
return 'bun'
}
// Cloudflare Workers
if (
typeof (globalThis as any).caches !== 'undefined' &&
typeof (globalThis as any).HTMLRewriter !== 'undefined'
typeof runtimeGlobals.caches !== 'undefined' &&
typeof runtimeGlobals.HTMLRewriter !== 'undefined'
) {
return 'cloudflare'
}