Comparing version 1.0.2 to 2.0.0
@@ -1,11 +0,13 @@ | ||
declare const IS_TEST: boolean; | ||
declare const IS_ELECTRON: boolean; | ||
declare const IS_ELECTRON_MAIN: boolean; | ||
declare const IS_ELECTRON_RENDERER: boolean; | ||
declare const IS_NODE: boolean; | ||
declare const IS_BROWSER: boolean; | ||
declare const IS_WEBWORKER: boolean; | ||
declare const IS_ENV_WITH_DOM: boolean; | ||
declare const IS_REACT_NATIVE: boolean; | ||
export { IS_TEST as isTest, IS_ELECTRON as isElectron, IS_ELECTRON_MAIN as isElectronMain, IS_ELECTRON_RENDERER as isElectronRenderer, IS_NODE as isNode, IS_BROWSER as isBrowser, IS_WEBWORKER as isWebWorker, IS_ENV_WITH_DOM as isEnvWithDom, IS_REACT_NATIVE as isReactNative }; | ||
export const isEnvWithDom: boolean; | ||
export const isElectron: boolean; | ||
/** | ||
* Detects browser main thread **NOT** web worker or service worker | ||
*/ | ||
export const isBrowser: boolean; | ||
export const isElectronMain: boolean; | ||
export const isElectronRenderer: boolean; | ||
export const isNode: boolean; | ||
export const isWebWorker: boolean; | ||
export const isTest: boolean; | ||
export const isReactNative: boolean; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "wherearewe", | ||
"version": "1.0.2", | ||
"description": "", | ||
"version": "2.0.0", | ||
"description": "Detect the current environment", | ||
"author": "", | ||
@@ -19,4 +19,4 @@ "license": "Apache-2.0 OR MIT", | ||
}, | ||
"main": "src/index.js", | ||
"types": "dist/src/index.d.ts", | ||
"type": "module", | ||
"types": "./dist/src/index.d.ts", | ||
"typesVersions": { | ||
@@ -27,3 +27,4 @@ "*": { | ||
"dist/*", | ||
"dist/src/*" | ||
"dist/src/*", | ||
"dist/src/*/index" | ||
], | ||
@@ -33,3 +34,4 @@ "src/*": [ | ||
"dist/*", | ||
"dist/src/*" | ||
"dist/src/*", | ||
"dist/src/*/index" | ||
] | ||
@@ -40,6 +42,17 @@ } | ||
"src", | ||
"dist" | ||
"dist", | ||
"!dist/test", | ||
"!**/*.tsbuildinfo" | ||
], | ||
"exports": { | ||
".": { | ||
"types": "./dist/src/index.d.ts", | ||
"import": "./src/index.js" | ||
} | ||
}, | ||
"eslintConfig": { | ||
"extends": "ipfs" | ||
"extends": "ipfs", | ||
"parserOptions": { | ||
"sourceType": "module" | ||
} | ||
}, | ||
@@ -73,11 +86,11 @@ "release": { | ||
{ | ||
"type": "chore", | ||
"type": "docs", | ||
"release": "patch" | ||
}, | ||
{ | ||
"type": "docs", | ||
"type": "test", | ||
"release": "patch" | ||
}, | ||
{ | ||
"type": "test", | ||
"type": "deps", | ||
"release": "patch" | ||
@@ -112,5 +125,9 @@ }, | ||
"type": "docs", | ||
"section": "Trivial Changes" | ||
"section": "Documentation" | ||
}, | ||
{ | ||
"type": "deps", | ||
"section": "Dependencies" | ||
}, | ||
{ | ||
"type": "test", | ||
@@ -130,7 +147,14 @@ "section": "Tests" | ||
"scripts": { | ||
"build": "tsc", | ||
"pretest": "npm run build", | ||
"test": "aegir test -t node -t browser -t webworker -t electron-main -t electron-renderer", | ||
"clean": "aegir clean", | ||
"lint": "aegir lint", | ||
"release": "semantic-release" | ||
"build": "aegir build", | ||
"release": "aegir release", | ||
"test": "aegir test -t node -t browser -t webworker -t electron-main", | ||
"test:node": "aegir test -t node --cov", | ||
"test:chrome": "aegir test -t browser --cov", | ||
"test:chrome-webworker": "aegir test -t webworker", | ||
"test:firefox": "aegir test -t browser -- --browser firefox", | ||
"test:firefox-webworker": "aegir test -t webworker -- --browser firefox", | ||
"test:electron-main": "aegir test -t electron-main", | ||
"dep-check": "aegir dep-check" | ||
}, | ||
@@ -141,4 +165,4 @@ "dependencies": { | ||
"devDependencies": { | ||
"aegir": "^36.1.3" | ||
"aegir": "^37.5.1" | ||
} | ||
} |
@@ -1,9 +0,19 @@ | ||
# where are we? | ||
# wherearewe <!-- omit in toc --> | ||
> environment detection | ||
[![codecov](https://img.shields.io/codecov/c/github/achingbrain/wherearewe.svg?style=flat-square)](https://codecov.io/gh/achingbrain/wherearewe) | ||
[![CI](https://img.shields.io/github/workflow/status/achingbrain/wherearewe/test%20&%20maybe%20release/master?style=flat-square)](https://github.com/achingbrain/wherearewe/actions/workflows/js-test-and-release.yml) | ||
> Detect the current environment | ||
## Table of contents <!-- omit in toc --> | ||
- [Install](#install) | ||
- [Usage](#usage) | ||
- [License](#license) | ||
- [Contribution](#contribution) | ||
## Install | ||
```console | ||
$ npm install wherearewe | ||
$ npm i wherearewe | ||
``` | ||
@@ -14,3 +24,3 @@ | ||
```javascript | ||
const where = require('wherearewe') | ||
import * as where from 'wherearewe' | ||
@@ -29,1 +39,12 @@ console.info(where) | ||
``` | ||
## License | ||
Licensed under either of | ||
- Apache 2.0, ([LICENSE-APACHE](LICENSE-APACHE) / <http://www.apache.org/licenses/LICENSE-2.0>) | ||
- MIT ([LICENSE-MIT](LICENSE-MIT) / <http://opensource.org/licenses/MIT>) | ||
## Contribution | ||
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions. |
@@ -1,34 +0,19 @@ | ||
'use strict' | ||
import detectElectron from 'is-electron' | ||
/** @type {() => boolean} */ | ||
// @ts-ignore | ||
const isElectron = require('is-electron') | ||
export const isEnvWithDom = typeof window === 'object' && typeof document === 'object' && document.nodeType === 9 | ||
export const isElectron = detectElectron() | ||
const IS_ENV_WITH_DOM = typeof window === 'object' && typeof document === 'object' && document.nodeType === 9 | ||
const IS_ELECTRON = isElectron() | ||
const IS_BROWSER = IS_ENV_WITH_DOM && !IS_ELECTRON | ||
const IS_ELECTRON_MAIN = IS_ELECTRON && !IS_ENV_WITH_DOM | ||
const IS_ELECTRON_RENDERER = IS_ELECTRON && IS_ENV_WITH_DOM | ||
const IS_NODE = typeof require === 'function' && typeof globalThis.process !== 'undefined' && typeof globalThis.process.release !== 'undefined' && globalThis.process.release.name === 'node' && !IS_ELECTRON | ||
/** | ||
* Detects browser main thread **NOT** web worker or service worker | ||
*/ | ||
export const isBrowser = isEnvWithDom && !isElectron | ||
export const isElectronMain = isElectron && !isEnvWithDom | ||
export const isElectronRenderer = isElectron && isEnvWithDom | ||
export const isNode = typeof globalThis.process !== 'undefined' && typeof globalThis.process.release !== 'undefined' && globalThis.process.release.name === 'node' && !isElectron | ||
// @ts-ignore | ||
// eslint-disable-next-line no-undef | ||
const IS_WEBWORKER = typeof importScripts === 'function' && typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope | ||
export const isWebWorker = typeof importScripts === 'function' && typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope | ||
// defeat bundlers replacing process.env.NODE_ENV with "development" or whatever | ||
const IS_TEST = typeof globalThis.process !== 'undefined' && typeof globalThis.process.env !== 'undefined' && globalThis.process.env['NODE' + (() => '_')() + 'ENV'] === 'test' | ||
const IS_REACT_NATIVE = typeof navigator !== 'undefined' && navigator.product === 'ReactNative' | ||
module.exports = { | ||
isTest: IS_TEST, | ||
isElectron: IS_ELECTRON, | ||
isElectronMain: IS_ELECTRON_MAIN, | ||
isElectronRenderer: IS_ELECTRON_RENDERER, | ||
isNode: IS_NODE, | ||
/** | ||
* Detects browser main thread **NOT** web worker or service worker | ||
*/ | ||
isBrowser: IS_BROWSER, | ||
isWebWorker: IS_WEBWORKER, | ||
isEnvWithDom: IS_ENV_WITH_DOM, | ||
isReactNative: IS_REACT_NATIVE | ||
} | ||
export const isTest = typeof globalThis.process !== 'undefined' && typeof globalThis.process.env !== 'undefined' && globalThis.process.env['NODE' + (() => '_')() + 'ENV'] === 'test' | ||
export const isReactNative = typeof navigator !== 'undefined' && navigator.product === 'ReactNative' |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
53
49
Yes
11513