@arcjet/runtime
Advanced tools
| //#region src/edge-light.d.ts | ||
| type Runtime = "workerd" | "deno" | "node" | "bun" | "edge-light" | ""; | ||
| declare function runtime(): Runtime; | ||
| //#endregion | ||
| export { Runtime, runtime }; |
| //#region src/edge-light.ts | ||
| function runtime() { | ||
| if (typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers") return "workerd"; | ||
| if (typeof Deno !== "undefined") return "deno"; | ||
| if (typeof Bun !== "undefined") return "bun"; | ||
| if (typeof EdgeRuntime !== "undefined") return "edge-light"; | ||
| return ""; | ||
| } | ||
| //#endregion | ||
| export { runtime }; |
| //#region src/index.d.ts | ||
| /** | ||
| * Runtime environment that can be detected. | ||
| */ | ||
| type Runtime = "workerd" | "deno" | "node" | "bun" | "edge-light" | ""; | ||
| /** | ||
| * Detect the current runtime environment at runtime. | ||
| * | ||
| * @returns | ||
| * Runtime; empty string if not found. | ||
| */ | ||
| declare function runtime(): Runtime; | ||
| //#endregion | ||
| export { Runtime, runtime }; |
| //#region src/index.ts | ||
| /** | ||
| * Detect the current runtime environment at runtime. | ||
| * | ||
| * @returns | ||
| * Runtime; empty string if not found. | ||
| */ | ||
| function runtime() { | ||
| if (typeof navigator !== "undefined" && navigator.userAgent === "Cloudflare-Workers") return "workerd"; | ||
| if (typeof Deno !== "undefined") return "deno"; | ||
| if (typeof Bun !== "undefined") return "bun"; | ||
| if (typeof EdgeRuntime !== "undefined") return "edge-light"; | ||
| if (typeof process !== "undefined" && process?.release?.name === "node") return "node"; | ||
| return ""; | ||
| } | ||
| //#endregion | ||
| export { runtime }; |
+37
-34
| { | ||
| "name": "@arcjet/runtime", | ||
| "version": "1.6.1", | ||
| "version": "1.7.0-rc.0", | ||
| "description": "Arcjet runtime detection", | ||
@@ -9,12 +9,6 @@ "keywords": [ | ||
| "runtime", | ||
| "utility", | ||
| "util" | ||
| "util", | ||
| "utility" | ||
| ], | ||
| "license": "Apache-2.0", | ||
| "homepage": "https://arcjet.com", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/arcjet/arcjet-js.git", | ||
| "directory": "runtime" | ||
| }, | ||
| "bugs": { | ||
@@ -24,2 +18,3 @@ "url": "https://github.com/arcjet/arcjet-js/issues", | ||
| }, | ||
| "license": "Apache-2.0", | ||
| "author": { | ||
@@ -30,37 +25,45 @@ "name": "Arcjet", | ||
| }, | ||
| "engines": { | ||
| "node": ">=22.21.0 <23 || >=24.5.0" | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/arcjet/arcjet-js.git", | ||
| "directory": "runtime" | ||
| }, | ||
| "files": [ | ||
| "dist" | ||
| ], | ||
| "type": "module", | ||
| "main": "./index.js", | ||
| "types": "./index.d.ts", | ||
| "main": "./dist/index.js", | ||
| "types": "./dist/index.d.ts", | ||
| "exports": { | ||
| "edge-light": "./edge-light.js", | ||
| "default": "./index.js" | ||
| ".": { | ||
| "edge-light": { | ||
| "types": "./dist/edge-light.d.ts", | ||
| "default": "./dist/edge-light.js" | ||
| }, | ||
| "default": { | ||
| "types": "./dist/index.d.ts", | ||
| "default": "./dist/index.js" | ||
| } | ||
| }, | ||
| "./package.json": "./package.json" | ||
| }, | ||
| "files": [ | ||
| "edge-light.d.ts", | ||
| "edge-light.js", | ||
| "index.d.ts", | ||
| "index.js" | ||
| ], | ||
| "publishConfig": { | ||
| "access": "public", | ||
| "tag": "latest" | ||
| }, | ||
| "scripts": { | ||
| "build": "rollup --config rollup.config.js", | ||
| "lint": "eslint .", | ||
| "test-api": "node --experimental-vm-modules --test -- test/*.test.js", | ||
| "test-coverage": "node --experimental-test-coverage --experimental-vm-modules --test -- test/*.test.js", | ||
| "test": "npm run build && npm run lint && npm run test-coverage" | ||
| "build": "tsdown", | ||
| "typecheck": "tsgo --noEmit", | ||
| "test-api": "node --experimental-vm-modules --test -- test/*.test.ts", | ||
| "test-coverage": "node --experimental-test-coverage --experimental-vm-modules --test -- test/*.test.ts", | ||
| "test": "npm run build && npm run test-coverage" | ||
| }, | ||
| "dependencies": {}, | ||
| "devDependencies": { | ||
| "@arcjet/eslint-config": "1.6.1", | ||
| "@arcjet/rollup-config": "1.6.1", | ||
| "@rollup/wasm-node": "4.62.2", | ||
| "eslint": "9.39.4", | ||
| "typescript": "5.9.3" | ||
| "tsdown": "0.22.3", | ||
| "typescript": "6.0.3" | ||
| }, | ||
| "publishConfig": { | ||
| "access": "public", | ||
| "tag": "latest" | ||
| "engines": { | ||
| "node": ">=22.21.0 <23 || >=24.5.0" | ||
| } | ||
| } |
| export type Runtime = "workerd" | "deno" | "node" | "bun" | "edge-light" | ""; | ||
| export declare function runtime(): Runtime; |
| /* | ||
| This file is mostly a duplication of `index.ts` with the `process` lookup | ||
| removed. We do this because Next.js uses an error-prone method for showing | ||
| a warning when compiling for the edge runtime. | ||
| */ | ||
| // This code was improved by detection mechanisms in | ||
| // https://github.com/unjs/std-env/blob/b4ef16832baf4594ece7796a2c1805712fde70a3/src/runtimes.ts | ||
| // | ||
| // MIT License | ||
| // | ||
| // Copyright (c) Pooya Parsa <pooya@pi0.io> | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| // of this software and associated documentation files (the "Software"), to deal | ||
| // in the Software without restriction, including without limitation the rights | ||
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| // copies of the Software, and to permit persons to whom the Software is | ||
| // furnished to do so, subject to the following conditions: | ||
| // | ||
| // The above copyright notice and this permission notice shall be included in | ||
| // all copies or substantial portions of the Software. | ||
| // | ||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| // SOFTWARE. | ||
| function runtime() { | ||
| // The detection order matters in this function because some platforms will | ||
| // implement compatibility layers, but we want to detect them accurately. | ||
| // https://developers.cloudflare.com/workers/configuration/compatibility-dates/#global-navigator | ||
| if (typeof navigator !== "undefined" && | ||
| navigator.userAgent === "Cloudflare-Workers") { | ||
| return "workerd"; | ||
| } | ||
| if (typeof Deno !== "undefined") { | ||
| return "deno"; | ||
| } | ||
| if (typeof Bun !== "undefined") { | ||
| return "bun"; | ||
| } | ||
| if (typeof EdgeRuntime !== "undefined") { | ||
| return "edge-light"; | ||
| } | ||
| // Unknown or unsupported runtime | ||
| return ""; | ||
| } | ||
| export { runtime }; |
-11
| /** | ||
| * Runtime environment that can be detected. | ||
| */ | ||
| export type Runtime = "workerd" | "deno" | "node" | "bun" | "edge-light" | ""; | ||
| /** | ||
| * Detect the current runtime environment at runtime. | ||
| * | ||
| * @returns | ||
| * Runtime; empty string if not found. | ||
| */ | ||
| export declare function runtime(): Runtime; |
-55
| // This code was improved by detection mechanisms in | ||
| // https://github.com/unjs/std-env/blob/b4ef16832baf4594ece7796a2c1805712fde70a3/src/runtimes.ts | ||
| // | ||
| // MIT License | ||
| // | ||
| // Copyright (c) Pooya Parsa <pooya@pi0.io> | ||
| // | ||
| // Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| // of this software and associated documentation files (the "Software"), to deal | ||
| // in the Software without restriction, including without limitation the rights | ||
| // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| // copies of the Software, and to permit persons to whom the Software is | ||
| // furnished to do so, subject to the following conditions: | ||
| // | ||
| // The above copyright notice and this permission notice shall be included in | ||
| // all copies or substantial portions of the Software. | ||
| // | ||
| // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| // SOFTWARE. | ||
| /** | ||
| * Detect the current runtime environment at runtime. | ||
| * | ||
| * @returns | ||
| * Runtime; empty string if not found. | ||
| */ | ||
| function runtime() { | ||
| // The detection order matters in this function because some platforms will | ||
| // implement compatibility layers, but we want to detect them accurately. | ||
| // https://developers.cloudflare.com/workers/configuration/compatibility-dates/#global-navigator | ||
| if (typeof navigator !== "undefined" && | ||
| navigator.userAgent === "Cloudflare-Workers") { | ||
| return "workerd"; | ||
| } | ||
| if (typeof Deno !== "undefined") { | ||
| return "deno"; | ||
| } | ||
| if (typeof Bun !== "undefined") { | ||
| return "bun"; | ||
| } | ||
| if (typeof EdgeRuntime !== "undefined") { | ||
| return "edge-light"; | ||
| } | ||
| if (typeof process !== "undefined" && process?.release?.name === "node") { | ||
| return "node"; | ||
| } | ||
| // Unknown or unsupported runtime | ||
| return ""; | ||
| } | ||
| export { runtime }; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
2
-60%17469
-16.24%44
-62.39%1
Infinity%1
Infinity%