@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 ADDED
@@ -0,0 +1,19 @@
1
+ # @x-oasis/env
2
+
3
+ ## Installation
4
+
5
+ ```bash
6
+ $ npm i @x-oasis/env
7
+ ```
8
+
9
+ ## How to use
10
+
11
+ ```typescript
12
+ import env from '@x-oasis/env'
13
+ ```
14
+
15
+ ## How to run test
16
+
17
+ ```bash
18
+ $ pnpm test
19
+ ```
@@ -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"}
@@ -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;;;;"}
@@ -0,0 +1,8 @@
1
+ declare const env: {
2
+ canUseDOM: boolean;
3
+ canUseWorkers: boolean;
4
+ canUseEventListeners: boolean;
5
+ canUseViewport: boolean;
6
+ isInWorker: boolean;
7
+ };
8
+ export default env;
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+
2
+ 'use strict'
3
+
4
+ if (process.env.NODE_ENV === 'production') {
5
+ module.exports = require('./env.cjs.production.min.js')
6
+ } else {
7
+ module.exports = require('./env.cjs.development.js')
8
+ }
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;