@alwatr/platform-info
Version:
This module provides a way to detect the current platform where the script is running. It defines a constant `platformInfo` which holds the information about the current platform.
49 lines (47 loc) • 1.57 kB
JavaScript
/* @alwatr/platform-info v5.5.2 */
// src/main.ts
import { packageTracer } from "@alwatr/package-tracer";
__dev_mode__: packageTracer.add("@alwatr/platform-info", "5.5.2");
var platformInfo = /* @__PURE__ */ (() => {
const platformInfo_ = {
development: false,
isNode: false,
isBrowser: false,
isWebWorker: false,
isDeno: false,
isBun: false,
isCli: false,
isNw: false,
isElectron: false
};
if (typeof window === "object" && typeof document === "object" && document.nodeType === Node.DOCUMENT_NODE) {
platformInfo_.isBrowser = true;
platformInfo_.isWebWorker = typeof WorkerGlobalScope !== "undefined" && self instanceof WorkerGlobalScope;
} else if (typeof process === "object") {
platformInfo_.isCli = true;
if (process.versions?.node != null) {
platformInfo_.isNode = true;
}
if (typeof Bun !== "undefined") {
platformInfo_.isBun = true;
} else if (process.versions?.electron != null) {
platformInfo_.isElectron = true;
} else if (typeof nw !== "undefined") {
platformInfo_.isNw = true;
}
}
if (typeof Deno !== "undefined") {
platformInfo_.isCli = true;
platformInfo_.isDeno = true;
}
if (platformInfo_.isBrowser === true) {
platformInfo_.development = location.hostname === "localhost" || location.hostname.indexOf("127.") === 0;
} else if (platformInfo_.isCli === true) {
platformInfo_.development = process.env.NODE_ENV !== "production";
}
return platformInfo_;
})();
export {
platformInfo
};
//# sourceMappingURL=main.mjs.map