code-inspector-plugin 0.3.0 → 0.3.2-beta.1

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2022 zhoulixiang
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2022 zhoulixiang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,71 +1,63 @@
1
- <div align="center">
2
- <img src="https://github.com/zh-lx/code-inspector/assets/73059627/842c3e88-dca7-4743-854c-d61093d3d34f" width=160px" style="margin-bottom: 12px;" />
3
-
4
- <p align="center">
5
- <h2>code-inspector-plugin</h2>
6
- <span>中文文档</span> |
7
- <a href="https://github.com/zh-lx/code-inspector/blob/main/docs/README-EN.md">English Doc</a> |
8
- <a href="https://inspector.fe-dev.cn">在线文档</a>
9
- </p>
10
-
11
- [![NPM version](https://img.shields.io/npm/v/code-inspector-plugin.svg)](https://www.npmjs.com/package/code-inspector-plugin)
12
- [![GITHUB star](https://img.shields.io/github/stars/zh-lx/code-inspector.svg)](https://github.com/zh-lx/code-inspector)
13
- [![MIT-license](https://img.shields.io/npm/l/code-inspector.svg)](https://opensource.org/licenses/MIT)
14
-
15
- </div>
16
-
17
- <hr />
18
-
19
- ## 📖 介绍
20
-
21
- 点击页面上的元素,能够自动打开你的代码编辑器并将光标定位到元素对应的代码位置。
22
-
23
- ![code-inspector](https://user-images.githubusercontent.com/73059627/227070438-6e40e112-6f1d-4f67-9f26-53986bff77c3.gif)
24
-
25
- ## 💻 在线体验
26
-
27
- - [vue online demo](https://stackblitz.com/edit/vitejs-vite-4pseos?file=vite.config.ts)
28
- - [react online demo](https://stackblitz.com/edit/vitejs-vite-svtwrr?file=vite.config.ts)
29
- - [preact online demo](https://stackblitz.com/edit/vitejs-vite-iyawbf?file=vite.config.ts)
30
- - [solid online demo](https://stackblitz.com/edit/solidjs-templates-6u76jn?file=vite.config.ts)
31
-
32
- ## 🚀 安装
33
-
34
- ```perl
35
- npm i code-inspector-plugin -D
36
- # or
37
- yarn add code-inspector-plugin -D
38
- # or
39
- pnpm add code-inspector-plugin -D
40
- ```
41
-
42
- ## 🌈 使用
43
-
44
- 完整的接入及使用方式请查看:[code-inspector-plugin 配置](https://inspector.fe-dev.cn/guide/start.html#%E9%85%8D%E7%BD%AE)
45
-
46
- ## 🎨 支持列表
47
-
48
- 下面是编译器、web 框架以及代码编辑器支持列表:
49
-
50
- - 当前支持以下打包工具<br />
51
- webpack(3.x/4.x/5.x)<br />
52
- vite<br />
53
- rspack
54
- - 当前支持以下 Web 框架<br />
55
- vue2<br />
56
- vue3<br />
57
- react<br />
58
- preact<br />
59
- solid
60
- - 当前支持以下代码编辑器<br />
61
- [VSCode](https://code.visualstudio.com/) | [Visual Studio Code - Insiders](https://code.visualstudio.com/insiders/) | [WebStorm](https://www.jetbrains.com/webstorm/) | [Atom](https://atom.io/) | [HBuilderX](https://www.dcloud.io/hbuilderx.html) | [PhpStorm](https://www.jetbrains.com/phpstorm/) | [PyCharm](https://www.jetbrains.com/pycharm/) | [IntelliJ IDEA](https://www.jetbrains.com/idea/)
62
-
63
- ## 📧 交流与反馈
64
-
65
- 任何使用问题可以加入 QQ 群 `769748484`、微信群或者添加作者微信 `zhoulx1688888` 进行咨询与反馈:
66
-
67
- <div style="display: flex; column-gap: 16px; row-gap: 16px; flex-wrap: wrap;">
68
- <img src="https://github.com/zh-lx/code-inspector/assets/73059627/6f0c8197-21e3-48d7-b9db-ffeb0e0d4ba7" width="200" height="272" />
69
- <img src="https://github.com/zh-lx/code-inspector/assets/73059627/acd7dafb-b47a-480c-8ab0-93801f39477f" width="200" height="272" />
70
- <img src="https://github.com/zh-lx/code-inspector/assets/73059627/28ebb97a-a114-4598-a6f2-0e45103284cc" width="200" height="272" />
71
- </div>
1
+ <div align="center">
2
+ <img src="https://github.com/zh-lx/code-inspector/assets/73059627/842c3e88-dca7-4743-854c-d61093d3d34f" width=160px" style="margin-bottom: 12px;" />
3
+
4
+ <p align="center">
5
+ <h2>code-inspector</h2>
6
+ <span>English Doc</span> | <a href="https://github.com/zh-lx/code-inspector/blob/main/docs/README-ZH.md">中文文档</a> | <a href="https://inspector.fe-dev.cn/en">Read Docs for More</a>
7
+ </p>
8
+
9
+ [![NPM version](https://img.shields.io/npm/v/code-inspector-plugin.svg)](https://www.npmjs.com/package/code-inspector-plugin)
10
+ [![GITHUB star](https://img.shields.io/github/stars/zh-lx/code-inspector.svg)](https://github.com/zh-lx/code-inspector)
11
+ [![MIT-license](https://img.shields.io/npm/l/code-inspector.svg)](https://opensource.org/licenses/MIT)
12
+
13
+ </div>
14
+
15
+ <hr />
16
+
17
+ ## 📖 Introduction
18
+
19
+ Click the element on the page, it can automatically open the code editor and position the cursor to the source code of the element.
20
+
21
+ ![code-inspector](https://github.com/zh-lx/code-inspector/assets/73059627/ad7974e6-e8b5-4bda-a005-d8387108e997)
22
+
23
+ ## 💻 Try it out online
24
+
25
+ - [vue online demo](https://stackblitz.com/edit/vitejs-vite-4pseos?file=vite.config.ts)
26
+ - [react online demo](https://stackblitz.com/edit/vitejs-vite-svtwrr?file=vite.config.ts)
27
+ - [preact online demo](https://stackblitz.com/edit/vitejs-vite-iyawbf?file=vite.config.ts)
28
+ - [solid online demo](https://stackblitz.com/edit/solidjs-templates-6u76jn?file=vite.config.ts)
29
+
30
+ ## 🚀 Install
31
+
32
+ ```perl
33
+ npm i webpack-code-inspector-plugin -D
34
+ # or
35
+ yarn add webpack-code-inspector-plugin -D
36
+ # or
37
+ pnpm add webpack-code-inspector-plugin -D
38
+ ```
39
+
40
+ ## 🌈 Usage
41
+
42
+ Please check here for complete access and usage information: [code-inspector-plugin configuration](https://en.inspector.fe-dev.cn/guide/start.html#configuration)
43
+
44
+ ## 🎨 Support
45
+
46
+ The following are which compilers, web frameworks and editors we supported now:
47
+
48
+ - The following bundlers are currently supported:<br />
49
+ ✅ webpack(3.x/4.x/5.x)<br />
50
+ vite<br />
51
+ rspack
52
+ - The following Web frameworks are currently supported:<br />
53
+ vue2<br />
54
+ vue3<br />
55
+ react<br />
56
+ preact<br />
57
+ solid
58
+ - The following code editors are currently supported:<br />
59
+ [VSCode](https://code.visualstudio.com/) | [Visual Studio Code - Insiders](https://code.visualstudio.com/insiders/) | [WebStorm](https://www.jetbrains.com/webstorm/) | [Atom](https://atom.io/) | [HBuilderX](https://www.dcloud.io/hbuilderx.html) | [PhpStorm](https://www.jetbrains.com/phpstorm/) | [PyCharm](https://www.jetbrains.com/pycharm/) | [IntelliJ IDEA](https://www.jetbrains.com/idea/)
60
+
61
+ ## 📧 Communication and Feedback
62
+
63
+ For any usage issues, please leave a message below my [Twitter](https://twitter.com/zhulxing312147) post or [submit an issue](https://github.com/zh-lx/code-inspector/issues) on Github.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var I=Object.defineProperty,$=Object.defineProperties;var V=Object.getOwnPropertyDescriptors;var h=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,k=Object.prototype.propertyIsEnumerable;var E=(e,t,n)=>t in e?I(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))j.call(t,n)&&E(e,n,t[n]);if(h)for(var n of h(t))k.call(t,n)&&E(e,n,t[n]);return e},f=(e,t)=>$(e,V(t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("vite-code-inspector-plugin"),P=require("chalk"),v=require("fs"),_=require("path");function C(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var n=function o(){if(this instanceof o){var s=[null];s.push.apply(s,arguments);var r=Function.bind.apply(t,s);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(o){var s=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(n,o,s.get?s:{enumerable:!0,get:function(){return e[o]}})}),n}var a={},x={get exports(){return a},set exports(e){a=e}};const S={},K=Object.freeze(Object.defineProperty({__proto__:null,default:S},Symbol.toStringTag,{value:"Module"})),b=C(K),R="dotenv",A="16.3.1",Y="Loads environment variables from .env file",L="lib/main.js",F="lib/main.d.ts",M={".":{types:"./lib/main.d.ts",require:"./lib/main.js",default:"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},B={"dts-check":"tsc --project tests/types/tsconfig.json",lint:"standard","lint-readme":"standard-markdown",pretest:"npm run lint && npm run dts-check",test:"tap tests/*.js --100 -Rspec",prerelease:"npm test",release:"standard-version"},q={type:"git",url:"git://github.com/motdotla/dotenv.git"},U="https://github.com/motdotla/dotenv?sponsor=1",W=["dotenv","env",".env","environment","variables","config","settings"],G="README.md",J="BSD-2-Clause",Q={"@definitelytyped/dtslint":"^0.0.133","@types/node":"^18.11.3",decache:"^4.6.1",sinon:"^14.0.1",standard:"^17.0.0","standard-markdown":"^7.1.0","standard-version":"^9.5.0",tap:"^16.3.0",tar:"^6.1.11",typescript:"^4.8.4"},z={node:">=12"},H={fs:!1},X={name:R,version:A,description:Y,main:L,types:F,exports:M,scripts:B,repository:q,funding:U,keywords:W,readmeFilename:G,license:J,devDependencies:Q,engines:z,browser:H},w=v,m=_,Z=b,ee=b,te=X,y=te.version,ne=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function re(e){const t={};let n=e.toString();n=n.replace(/\r\n?/mg,"\n");let o;for(;(o=ne.exec(n))!=null;){const s=o[1];let r=o[2]||"";r=r.trim();const c=r[0];r=r.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),c==='"'&&(r=r.replace(/\\n/g,"\n"),r=r.replace(/\\r/g,"\r")),t[s]=r}return t}function oe(e){const t=O(e),n=i.configDotenv({path:t});if(!n.parsed)throw new Error("MISSING_DATA: Cannot parse ".concat(t," for an unknown reason"));const o=D(e).split(","),s=o.length;let r;for(let c=0;c<s;c++)try{const l=o[c].trim(),u=ie(n,l);r=i.decrypt(u.ciphertext,u.key);break}catch(l){if(c+1>=s)throw l}return i.parse(r)}function se(e){console.log("[dotenv@".concat(y,"][INFO] ").concat(e))}function ce(e){console.log("[dotenv@".concat(y,"][WARN] ").concat(e))}function g(e){console.log("[dotenv@".concat(y,"][DEBUG] ").concat(e))}function D(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function ie(e,t){let n;try{n=new URL(t)}catch(l){throw l.code==="ERR_INVALID_URL"?new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenv.org/vault/.env.vault?environment=development"):l}const o=n.password;if(!o)throw new Error("INVALID_DOTENV_KEY: Missing key part");const s=n.searchParams.get("environment");if(!s)throw new Error("INVALID_DOTENV_KEY: Missing environment part");const r="DOTENV_VAULT_".concat(s.toUpperCase()),c=e.parsed[r];if(!c)throw new Error("NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ".concat(r," in your .env.vault file."));return{ciphertext:c,key:o}}function O(e){let t=m.resolve(process.cwd(),".env");return e&&e.path&&e.path.length>0&&(t=e.path),t.endsWith(".vault")?t:"".concat(t,".vault")}function ae(e){return e[0]==="~"?m.join(Z.homedir(),e.slice(1)):e}function le(e){se("Loading env from encrypted .env.vault");const t=i._parseVault(e);let n=process.env;return e&&e.processEnv!=null&&(n=e.processEnv),i.populate(n,t,e),{parsed:t}}function ue(e){let t=m.resolve(process.cwd(),".env"),n="utf8";const o=!!(e&&e.debug);e&&(e.path!=null&&(t=ae(e.path)),e.encoding!=null&&(n=e.encoding));try{const s=i.parse(w.readFileSync(t,{encoding:n}));let r=process.env;return e&&e.processEnv!=null&&(r=e.processEnv),i.populate(r,s,e),{parsed:s}}catch(s){return o&&g("Failed to load ".concat(t," ").concat(s.message)),{error:s}}}function de(e){const t=O(e);return D(e).length===0?i.configDotenv(e):w.existsSync(t)?i._configVault(e):(ce("You set DOTENV_KEY but you are missing a .env.vault file at ".concat(t,". Did you forget to build it?")),i.configDotenv(e))}function pe(e,t){const n=Buffer.from(t.slice(-64),"hex");let o=Buffer.from(e,"base64");const s=o.slice(0,12),r=o.slice(-16);o=o.slice(12,-16);try{const c=ee.createDecipheriv("aes-256-gcm",n,s);return c.setAuthTag(r),"".concat(c.update(o)).concat(c.final())}catch(c){const l=c instanceof RangeError,u=c.message==="Invalid key length",N=c.message==="Unsupported state or unable to authenticate data";if(l||u){const d="INVALID_DOTENV_KEY: It must be 64 characters long (or more)";throw new Error(d)}else if(N){const d="DECRYPTION_FAILED: Please check your DOTENV_KEY";throw new Error(d)}else throw console.error("Error: ",c.code),console.error("Error: ",c.message),c}}function fe(e,t,n={}){const o=!!(n&&n.debug),s=!!(n&&n.override);if(typeof t!="object")throw new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");for(const r of Object.keys(t))Object.prototype.hasOwnProperty.call(e,r)?(s===!0&&(e[r]=t[r]),o&&g(s===!0?'"'.concat(r,'" is already defined and WAS overwritten'):'"'.concat(r,'" is already defined and was NOT overwritten'))):e[r]=t[r]}const i={configDotenv:ue,_configVault:le,_parseVault:oe,config:de,decrypt:pe,parse:re,populate:fe};a.configDotenv=i.configDotenv;a._configVault=i._configVault;a._parseVault=i._parseVault;a.config=i.config;a.decrypt=i.decrypt;a.parse=i.parse;a.populate=i.populate;x.exports=i;function ve(e){if(!(e!=null&&e.bundler)){console.log(P.red("Please specify the bundler in the options of code-inspector-plugin."));return}let t=!1;if(e.needEnvInspector)if(t=!0,process.env.CODE_INSPECTOR==="true")t=!1;else{const o=_.resolve(process.cwd(),".env.local");if(v.existsSync(o)){const s=v.readFileSync(o,"utf-8"),r=a.parse(s||"");(r==null?void 0:r.CODE_INSPECTOR)==="true"&&(t=!1)}}if(e.bundler==="webpack"||e.bundler==="rspack"){const n=require("webpack-code-inspector-plugin");return new n(f(p({},e),{close:t}))}else return T.ViteCodeInspectorPlugin(f(p({},e),{close:t}))}exports.CodeInspectorPlugin=ve;
1
+ "use strict";var $=Object.defineProperty,V=Object.defineProperties;var j=Object.getOwnPropertyDescriptors;var h=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable;var E=(e,t,n)=>t in e?$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,p=(e,t)=>{for(var n in t||(t={}))k.call(t,n)&&E(e,n,t[n]);if(h)for(var n of h(t))T.call(t,n)&&E(e,n,t[n]);return e},f=(e,t)=>V(e,j(t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("vite-code-inspector-plugin"),C=require("chalk"),v=require("fs"),_=require("path");function x(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var n=function o(){if(this instanceof o){var s=[null];s.push.apply(s,arguments);var r=Function.bind.apply(t,s);return new r}return t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(o){var s=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(n,o,s.get?s:{enumerable:!0,get:function(){return e[o]}})}),n}var a={},S={get exports(){return a},set exports(e){a=e}};const K={},R=Object.freeze(Object.defineProperty({__proto__:null,default:K},Symbol.toStringTag,{value:"Module"})),b=x(R),A="dotenv",Y="16.3.1",L="Loads environment variables from .env file",F="lib/main.js",M="lib/main.d.ts",B={".":{types:"./lib/main.d.ts",require:"./lib/main.js",default:"./lib/main.js"},"./config":"./config.js","./config.js":"./config.js","./lib/env-options":"./lib/env-options.js","./lib/env-options.js":"./lib/env-options.js","./lib/cli-options":"./lib/cli-options.js","./lib/cli-options.js":"./lib/cli-options.js","./package.json":"./package.json"},q={"dts-check":"tsc --project tests/types/tsconfig.json",lint:"standard","lint-readme":"standard-markdown",pretest:"npm run lint && npm run dts-check",test:"tap tests/*.js --100 -Rspec",prerelease:"npm test",release:"standard-version"},U={type:"git",url:"git://github.com/motdotla/dotenv.git"},W="https://github.com/motdotla/dotenv?sponsor=1",G=["dotenv","env",".env","environment","variables","config","settings"],J="README.md",Q="BSD-2-Clause",z={"@definitelytyped/dtslint":"^0.0.133","@types/node":"^18.11.3",decache:"^4.6.1",sinon:"^14.0.1",standard:"^17.0.0","standard-markdown":"^7.1.0","standard-version":"^9.5.0",tap:"^16.3.0",tar:"^6.1.11",typescript:"^4.8.4"},H={node:">=12"},X={fs:!1},Z={name:A,version:Y,description:L,main:F,types:M,exports:B,scripts:q,repository:U,funding:W,keywords:G,readmeFilename:J,license:Q,devDependencies:z,engines:H,browser:X},w=v,m=_,ee=b,te=b,ne=Z,y=ne.version,re=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function oe(e){const t={};let n=e.toString();n=n.replace(/\r\n?/mg,"\n");let o;for(;(o=re.exec(n))!=null;){const s=o[1];let r=o[2]||"";r=r.trim();const c=r[0];r=r.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),c==='"'&&(r=r.replace(/\\n/g,"\n"),r=r.replace(/\\r/g,"\r")),t[s]=r}return t}function se(e){const t=O(e),n=i.configDotenv({path:t});if(!n.parsed)throw new Error("MISSING_DATA: Cannot parse ".concat(t," for an unknown reason"));const o=D(e).split(","),s=o.length;let r;for(let c=0;c<s;c++)try{const l=o[c].trim(),u=ae(n,l);r=i.decrypt(u.ciphertext,u.key);break}catch(l){if(c+1>=s)throw l}return i.parse(r)}function ce(e){console.log("[dotenv@".concat(y,"][INFO] ").concat(e))}function ie(e){console.log("[dotenv@".concat(y,"][WARN] ").concat(e))}function g(e){console.log("[dotenv@".concat(y,"][DEBUG] ").concat(e))}function D(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}function ae(e,t){let n;try{n=new URL(t)}catch(l){throw l.code==="ERR_INVALID_URL"?new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenv.org/vault/.env.vault?environment=development"):l}const o=n.password;if(!o)throw new Error("INVALID_DOTENV_KEY: Missing key part");const s=n.searchParams.get("environment");if(!s)throw new Error("INVALID_DOTENV_KEY: Missing environment part");const r="DOTENV_VAULT_".concat(s.toUpperCase()),c=e.parsed[r];if(!c)throw new Error("NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ".concat(r," in your .env.vault file."));return{ciphertext:c,key:o}}function O(e){let t=m.resolve(process.cwd(),".env");return e&&e.path&&e.path.length>0&&(t=e.path),t.endsWith(".vault")?t:"".concat(t,".vault")}function le(e){return e[0]==="~"?m.join(ee.homedir(),e.slice(1)):e}function ue(e){ce("Loading env from encrypted .env.vault");const t=i._parseVault(e);let n=process.env;return e&&e.processEnv!=null&&(n=e.processEnv),i.populate(n,t,e),{parsed:t}}function de(e){let t=m.resolve(process.cwd(),".env"),n="utf8";const o=!!(e&&e.debug);e&&(e.path!=null&&(t=le(e.path)),e.encoding!=null&&(n=e.encoding));try{const s=i.parse(w.readFileSync(t,{encoding:n}));let r=process.env;return e&&e.processEnv!=null&&(r=e.processEnv),i.populate(r,s,e),{parsed:s}}catch(s){return o&&g("Failed to load ".concat(t," ").concat(s.message)),{error:s}}}function pe(e){const t=O(e);return D(e).length===0?i.configDotenv(e):w.existsSync(t)?i._configVault(e):(ie("You set DOTENV_KEY but you are missing a .env.vault file at ".concat(t,". Did you forget to build it?")),i.configDotenv(e))}function fe(e,t){const n=Buffer.from(t.slice(-64),"hex");let o=Buffer.from(e,"base64");const s=o.slice(0,12),r=o.slice(-16);o=o.slice(12,-16);try{const c=te.createDecipheriv("aes-256-gcm",n,s);return c.setAuthTag(r),"".concat(c.update(o)).concat(c.final())}catch(c){const l=c instanceof RangeError,u=c.message==="Invalid key length",N=c.message==="Unsupported state or unable to authenticate data";if(l||u){const d="INVALID_DOTENV_KEY: It must be 64 characters long (or more)";throw new Error(d)}else if(N){const d="DECRYPTION_FAILED: Please check your DOTENV_KEY";throw new Error(d)}else throw console.error("Error: ",c.code),console.error("Error: ",c.message),c}}function ve(e,t,n={}){const o=!!(n&&n.debug),s=!!(n&&n.override);if(typeof t!="object")throw new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");for(const r of Object.keys(t))Object.prototype.hasOwnProperty.call(e,r)?(s===!0&&(e[r]=t[r]),o&&g(s===!0?'"'.concat(r,'" is already defined and WAS overwritten'):'"'.concat(r,'" is already defined and was NOT overwritten'))):e[r]=t[r]}const i={configDotenv:de,_configVault:ue,_parseVault:se,config:pe,decrypt:fe,parse:oe,populate:ve};a.configDotenv=i.configDotenv;a._configVault=i._configVault;a._parseVault=i._parseVault;a.config=i.config;a.decrypt=i.decrypt;a.parse=i.parse;a.populate=i.populate;S.exports=i;function I(e){if(!(e!=null&&e.bundler)){console.log(C.red("Please specify the bundler in the options of code-inspector-plugin."));return}let t=!1;if(e.needEnvInspector)if(t=!0,process.env.CODE_INSPECTOR==="true")t=!1;else{const o=_.resolve(process.cwd(),".env.local");if(v.existsSync(o)){const s=v.readFileSync(o,"utf-8"),r=a.parse(s||"");(r==null?void 0:r.CODE_INSPECTOR)==="true"&&(t=!1)}}if(e.bundler==="webpack"||e.bundler==="rspack"){const n=require("webpack-code-inspector-plugin");return new n(f(p({},e),{close:t}))}else return P.ViteCodeInspectorPlugin(f(p({},e),{close:t}))}const ge=I;exports.CodeInspectorPlugin=I;exports.codeInspectorPlugin=ge;
package/dist/index.mjs CHANGED
@@ -1,15 +1,15 @@
1
- var $ = Object.defineProperty, I = Object.defineProperties;
1
+ var I = Object.defineProperty, $ = Object.defineProperties;
2
2
  var V = Object.getOwnPropertyDescriptors;
3
3
  var h = Object.getOwnPropertySymbols;
4
4
  var j = Object.prototype.hasOwnProperty, k = Object.prototype.propertyIsEnumerable;
5
- var E = (e, t, n) => t in e ? $(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, f = (e, t) => {
5
+ var E = (e, t, n) => t in e ? I(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, p = (e, t) => {
6
6
  for (var n in t || (t = {}))
7
7
  j.call(t, n) && E(e, n, t[n]);
8
8
  if (h)
9
9
  for (var n of h(t))
10
10
  k.call(t, n) && E(e, n, t[n]);
11
11
  return e;
12
- }, p = (e, t) => I(e, V(t));
12
+ }, f = (e, t) => $(e, V(t));
13
13
  import { ViteCodeInspectorPlugin as T } from "vite-code-inspector-plugin";
14
14
  import P from "chalk";
15
15
  import v from "fs";
@@ -206,7 +206,7 @@ function de(e) {
206
206
  const t = O(e);
207
207
  return D(e).length === 0 ? i.configDotenv(e) : w.existsSync(t) ? i._configVault(e) : (ce("You set DOTENV_KEY but you are missing a .env.vault file at ".concat(t, ". Did you forget to build it?")), i.configDotenv(e));
208
208
  }
209
- function fe(e, t) {
209
+ function pe(e, t) {
210
210
  const n = Buffer.from(t.slice(-64), "hex");
211
211
  let o = Buffer.from(e, "base64");
212
212
  const s = o.slice(0, 12), r = o.slice(-16);
@@ -226,7 +226,7 @@ function fe(e, t) {
226
226
  throw console.error("Error: ", c.code), console.error("Error: ", c.message), c;
227
227
  }
228
228
  }
229
- function pe(e, t, n = {}) {
229
+ function fe(e, t, n = {}) {
230
230
  const o = !!(n && n.debug), s = !!(n && n.override);
231
231
  if (typeof t != "object")
232
232
  throw new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
@@ -238,9 +238,9 @@ const i = {
238
238
  _configVault: le,
239
239
  _parseVault: oe,
240
240
  config: de,
241
- decrypt: fe,
241
+ decrypt: pe,
242
242
  parse: re,
243
- populate: pe
243
+ populate: fe
244
244
  };
245
245
  a.configDotenv = i.configDotenv;
246
246
  a._configVault = i._configVault;
@@ -250,7 +250,7 @@ a.decrypt = i.decrypt;
250
250
  a.parse = i.parse;
251
251
  a.populate = i.populate;
252
252
  C.exports = i;
253
- function Ee(e) {
253
+ function ve(e) {
254
254
  if (!(e != null && e.bundler)) {
255
255
  console.log(
256
256
  P.red(
@@ -272,10 +272,12 @@ function Ee(e) {
272
272
  }
273
273
  if (e.bundler === "webpack" || e.bundler === "rspack") {
274
274
  const n = require("webpack-code-inspector-plugin");
275
- return new n(p(f({}, e), { close: t }));
275
+ return new n(f(p({}, e), { close: t }));
276
276
  } else
277
- return T(p(f({}, e), { close: t }));
277
+ return T(f(p({}, e), { close: t }));
278
278
  }
279
+ const _e = ve;
279
280
  export {
280
- Ee as CodeInspectorPlugin
281
+ ve as CodeInspectorPlugin,
282
+ _e as codeInspectorPlugin
281
283
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-inspector-plugin",
3
- "version": "0.3.0",
3
+ "version": "0.3.2-beta.1",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./types/index.d.ts",
@@ -39,9 +39,9 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "chalk": "4.1.1",
42
- "code-inspector-core": "0.3.0",
43
- "webpack-code-inspector-plugin": "0.3.0",
44
- "vite-code-inspector-plugin": "0.3.0"
42
+ "code-inspector-core": "0.3.2-beta.1",
43
+ "vite-code-inspector-plugin": "0.3.2-beta.1",
44
+ "webpack-code-inspector-plugin": "0.3.2-beta.1"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/node": "^16.0.1",
package/types/index.d.ts CHANGED
@@ -1,14 +1,15 @@
1
- import { CodeOptions } from 'code-inspector-core';
2
- export interface CodeInspectorPluginOptions extends CodeOptions {
3
- /**
4
- * @zh 指定项目的打包器
5
- * @en specify the bundler of the project
6
- */
7
- bundler: 'vite' | 'webpack' | 'rspack';
8
- /**
9
- * @zh 设置为 true 时,仅当 .env.local 文件存在且其包含 CODE_INSPECTOR=true 时插件生效;默认值为 false
10
- * @en When set the value to true, only if the .env.local file exists and it contains CODE_INSPECTOR=true, the plugin takes effect; The default value is false
11
- */
12
- needEnvInspector?: boolean;
13
- }
14
- export declare function CodeInspectorPlugin(options: CodeInspectorPluginOptions): any;
1
+ import { CodeOptions } from 'code-inspector-core';
2
+ export interface CodeInspectorPluginOptions extends CodeOptions {
3
+ /**
4
+ * @zh 指定项目的打包器
5
+ * @en specify the bundler of the project
6
+ */
7
+ bundler: 'vite' | 'webpack' | 'rspack';
8
+ /**
9
+ * @zh 设置为 true 时,仅当 .env.local 文件存在且其包含 CODE_INSPECTOR=true 时插件生效;默认值为 false
10
+ * @en When set the value to true, only if the .env.local file exists and it contains CODE_INSPECTOR=true, the plugin takes effect; The default value is false
11
+ */
12
+ needEnvInspector?: boolean;
13
+ }
14
+ export declare function CodeInspectorPlugin(options: CodeInspectorPluginOptions): any;
15
+ export declare const codeInspectorPlugin: typeof CodeInspectorPlugin;