@x-oasis/env 0.1.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/dist/env.cjs.development.js +15 -0
- package/dist/env.cjs.development.js.map +1 -0
- package/dist/env.cjs.production.min.js +2 -0
- package/dist/env.cjs.production.min.js.map +1 -0
- package/dist/env.esm.js +11 -0
- package/dist/env.esm.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/package.json +24 -0
- package/src/index.ts +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
6
|
+
var env = {
|
|
7
|
+
canUseDOM: canUseDOM,
|
|
8
|
+
canUseWorkers: typeof Worker !== 'undefined',
|
|
9
|
+
canUseEventListeners: canUseDOM && !!(window.addEventListener || window.attachEvent),
|
|
10
|
+
canUseViewport: canUseDOM && !!window.screen,
|
|
11
|
+
isInWorker: !canUseDOM
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.default = env;
|
|
15
|
+
//# sourceMappingURL=env.cjs.development.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.cjs.development.js","sources":["../src/index.ts"],"sourcesContent":["const canUseDOM = !!(\n typeof window !== 'undefined' &&\n window.document &&\n window.document.createElement\n);\n\n/**\n * Simple, lightweight module assisting with the detection and context of\n * Worker. Helps avoid circular dependencies and allows code to reason about\n * whether or not they are in a Worker, even if they never include the main\n * `ReactWorker` dependency.\n */\nconst env = {\n canUseDOM,\n\n canUseWorkers: typeof Worker !== 'undefined',\n\n canUseEventListeners:\n // @ts-ignore\n canUseDOM && !!(window.addEventListener || window.attachEvent),\n\n canUseViewport: canUseDOM && !!window.screen,\n\n isInWorker: !canUseDOM, // For now, this is true - might change in the future.\n};\n\nexport default env;\n"],"names":["canUseDOM","window","document","createElement","env","canUseWorkers","Worker","canUseEventListeners","addEventListener","attachEvent","canUseViewport","screen","isInWorker"],"mappings":";;;;AAAA,IAAMA,SAAS,GAAG,CAAC,EACjB,OAAOC,MAAM,KAAK,WAAW,IAC7BA,MAAM,CAACC,QAAQ,IACfD,MAAM,CAACC,QAAQ,CAACC,aAAa,CAC9B;AAQD,IAAMC,GAAG,GAAG;EACVJ,SAAS,EAATA,SAAS;EAETK,aAAa,EAAE,OAAOC,MAAM,KAAK,WAAW;EAE5CC,oBAAoB,EAElBP,SAAS,IAAI,CAAC,EAAEC,MAAM,CAACO,gBAAgB,IAAIP,MAAM,CAACQ,WAAW,CAAC;EAEhEC,cAAc,EAAEV,SAAS,IAAI,CAAC,CAACC,MAAM,CAACU,MAAM;EAE5CC,UAAU,EAAE,CAACZ;CACd;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=!("undefined"==typeof window||!window.document||!window.document.createElement),n={canUseDOM:e,canUseWorkers:"undefined"!=typeof Worker,canUseEventListeners:e&&!(!window.addEventListener&&!window.attachEvent),canUseViewport:e&&!!window.screen,isInWorker:!e};exports.default=n;
|
|
2
|
+
//# sourceMappingURL=env.cjs.production.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.cjs.production.min.js","sources":["../src/index.ts"],"sourcesContent":["const canUseDOM = !!(\n typeof window !== 'undefined' &&\n window.document &&\n window.document.createElement\n);\n\n/**\n * Simple, lightweight module assisting with the detection and context of\n * Worker. Helps avoid circular dependencies and allows code to reason about\n * whether or not they are in a Worker, even if they never include the main\n * `ReactWorker` dependency.\n */\nconst env = {\n canUseDOM,\n\n canUseWorkers: typeof Worker !== 'undefined',\n\n canUseEventListeners:\n // @ts-ignore\n canUseDOM && !!(window.addEventListener || window.attachEvent),\n\n canUseViewport: canUseDOM && !!window.screen,\n\n isInWorker: !canUseDOM, // For now, this is true - might change in the future.\n};\n\nexport default env;\n"],"names":["canUseDOM","window","document","createElement","env","canUseWorkers","Worker","canUseEventListeners","addEventListener","attachEvent","canUseViewport","screen","isInWorker"],"mappings":"oEAAA,IAAMA,IACc,oBAAXC,SACPA,OAAOC,WACPD,OAAOC,SAASC,eASZC,EAAM,CACVJ,UAAAA,EAEAK,cAAiC,oBAAXC,OAEtBC,qBAEEP,MAAgBC,OAAOO,mBAAoBP,OAAOQ,aAEpDC,eAAgBV,KAAeC,OAAOU,OAEtCC,YAAaZ"}
|
package/dist/env.esm.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
|
|
2
|
+
var env = {
|
|
3
|
+
canUseDOM: canUseDOM,
|
|
4
|
+
canUseWorkers: typeof Worker !== 'undefined',
|
|
5
|
+
canUseEventListeners: canUseDOM && !!(window.addEventListener || window.attachEvent),
|
|
6
|
+
canUseViewport: canUseDOM && !!window.screen,
|
|
7
|
+
isInWorker: !canUseDOM
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export default env;
|
|
11
|
+
//# sourceMappingURL=env.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.esm.js","sources":["../src/index.ts"],"sourcesContent":["const canUseDOM = !!(\n typeof window !== 'undefined' &&\n window.document &&\n window.document.createElement\n);\n\n/**\n * Simple, lightweight module assisting with the detection and context of\n * Worker. Helps avoid circular dependencies and allows code to reason about\n * whether or not they are in a Worker, even if they never include the main\n * `ReactWorker` dependency.\n */\nconst env = {\n canUseDOM,\n\n canUseWorkers: typeof Worker !== 'undefined',\n\n canUseEventListeners:\n // @ts-ignore\n canUseDOM && !!(window.addEventListener || window.attachEvent),\n\n canUseViewport: canUseDOM && !!window.screen,\n\n isInWorker: !canUseDOM, // For now, this is true - might change in the future.\n};\n\nexport default env;\n"],"names":["canUseDOM","window","document","createElement","env","canUseWorkers","Worker","canUseEventListeners","addEventListener","attachEvent","canUseViewport","screen","isInWorker"],"mappings":"AAAA,IAAMA,SAAS,GAAG,CAAC,EACjB,OAAOC,MAAM,KAAK,WAAW,IAC7BA,MAAM,CAACC,QAAQ,IACfD,MAAM,CAACC,QAAQ,CAACC,aAAa,CAC9B;AAQD,IAAMC,GAAG,GAAG;EACVJ,SAAS,EAATA,SAAS;EAETK,aAAa,EAAE,OAAOC,MAAM,KAAK,WAAW;EAE5CC,oBAAoB,EAElBP,SAAS,IAAI,CAAC,EAAEC,MAAM,CAACO,gBAAgB,IAAIP,MAAM,CAACQ,WAAW,CAAC;EAEhEC,cAAc,EAAEV,SAAS,IAAI,CAAC,CAACC,MAAM,CAACU,MAAM;EAE5CC,UAAU,EAAE,CAACZ;CACd;;;;"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@x-oasis/env",
|
|
3
|
+
"version": "0.1.34",
|
|
4
|
+
"description": "env function",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"typings": "dist/index.d.ts",
|
|
7
|
+
"module": "dist/env.esm.js",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"index.ts",
|
|
11
|
+
"src"
|
|
12
|
+
],
|
|
13
|
+
"author": "",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"tsdx": "^0.14.1"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsdx build --tsconfig tsconfig.build.json",
|
|
20
|
+
"clean": "rimraf ./dist",
|
|
21
|
+
"test": "vitest",
|
|
22
|
+
"compile": "tsc -p tsconfig.build.json"
|
|
23
|
+
}
|
|
24
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const canUseDOM = !!(
|
|
2
|
+
typeof window !== 'undefined' &&
|
|
3
|
+
window.document &&
|
|
4
|
+
window.document.createElement
|
|
5
|
+
);
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Simple, lightweight module assisting with the detection and context of
|
|
9
|
+
* Worker. Helps avoid circular dependencies and allows code to reason about
|
|
10
|
+
* whether or not they are in a Worker, even if they never include the main
|
|
11
|
+
* `ReactWorker` dependency.
|
|
12
|
+
*/
|
|
13
|
+
const env = {
|
|
14
|
+
canUseDOM,
|
|
15
|
+
|
|
16
|
+
canUseWorkers: typeof Worker !== 'undefined',
|
|
17
|
+
|
|
18
|
+
canUseEventListeners:
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
canUseDOM && !!(window.addEventListener || window.attachEvent),
|
|
21
|
+
|
|
22
|
+
canUseViewport: canUseDOM && !!window.screen,
|
|
23
|
+
|
|
24
|
+
isInWorker: !canUseDOM, // For now, this is true - might change in the future.
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export default env;
|