@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.
73 lines (71 loc) • 2.61 kB
JavaScript
/* @alwatr/platform-info v5.5.2 */
;
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);
// src/main.ts
var main_exports = {};
__export(main_exports, {
platformInfo: () => platformInfo
});
module.exports = __toCommonJS(main_exports);
var import_package_tracer = require("@alwatr/package-tracer");
__dev_mode__: import_package_tracer.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_;
})();
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
platformInfo
});
//# sourceMappingURL=main.cjs.map