code-inspector-plugin 0.19.0 → 0.19.2
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 +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +43 -43
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -67,7 +67,7 @@ pnpm add code-inspector-plugin -D
|
|
|
67
67
|
|
|
68
68
|
## 🌈 Usage
|
|
69
69
|
|
|
70
|
-
Please check here for more usage information: [code-inspector-plugin configuration](https://
|
|
70
|
+
Please check here for more usage information: [code-inspector-plugin configuration](https://inspector.fe-dev.cn/en/guide/start.html#configuration)
|
|
71
71
|
|
|
72
72
|
- 1.Configuring Build Tools
|
|
73
73
|
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var b=Object.defineProperty,T=Object.defineProperties;var S=Object.getOwnPropertyDescriptors;var h=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var g=(e,t,n)=>t in e?b(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,C=(e,t)=>{for(var n in t||(t={}))_.call(t,n)&&g(e,n,t[n]);if(h)for(var n of h(t))q.call(t,n)&&g(e,n,t[n]);return e},v=(e,t)=>T(e,S(t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("vite-code-inspector-plugin"),w=require("webpack-code-inspector-plugin"),i=require("code-inspector-core"),f=require("fs"),p=require("path"),F=require("chalk"),j=require("dotenv");var R=(e,t,n)=>new Promise((l,u)=>{var a=o=>{try{
|
|
1
|
+
"use strict";var b=Object.defineProperty,T=Object.defineProperties;var S=Object.getOwnPropertyDescriptors;var h=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var g=(e,t,n)=>t in e?b(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,C=(e,t)=>{for(var n in t||(t={}))_.call(t,n)&&g(e,n,t[n]);if(h)for(var n of h(t))q.call(t,n)&&g(e,n,t[n]);return e},v=(e,t)=>T(e,S(t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("vite-code-inspector-plugin"),w=require("webpack-code-inspector-plugin"),i=require("code-inspector-core"),f=require("fs"),p=require("path"),F=require("chalk"),j=require("dotenv");var R=(e,t,n)=>new Promise((l,u)=>{var a=o=>{try{s(n.next(o))}catch(c){u(c)}},r=o=>{try{s(n.throw(o))}catch(c){u(c)}},s=o=>o.done?l(o.value):Promise.resolve(o.value).then(a,r);s((n=n.apply(e,t)).next())});const W="esbuild-code-inspector-plugin";function D(e){return{name:W,setup(t){if(e.close||!i.isDev(e.dev,!1))return;const n={port:0,entry:"",output:e.output},{escapeTags:l=[]}=e,u=new Map;t.onLoad({filter:e.match||/\.(jsx|tsx|js|ts|mjs|mts)?$/},a=>R(this,null,function*(){let r=a.path;r=i.getMappingFilePath(r,e.mappings);let s=yield f.promises.readFile(r,"utf8"),o=u.get(r);if(!o||o.originCode!==s){let c=s;if(r.match("node_modules")||i.matchCondition(e.include||[],r)){if(!i.matchCondition(e.include||[],r))return c}else c=yield i.getCodeWithWebComponent({options:e,file:r,code:c,record:n});let d="";if(i.isJsTypeFile(r)?d="jsx":r.endsWith(".svelte")&&(d="svelte"),d)c=i.transformCode({content:c,filePath:r,fileType:d,escapeTags:l});else if(r.endsWith(".vue")){d="vue";const{descriptor:m}=i.parseSFC(c,{sourceMap:!1}),I=i.transformCode({content:m.template.content,filePath:r,fileType:d,escapeTags:l});c=c.replace(m.template.content,I)}const y=p.extname(r).replace(".","");o={originCode:s,output:{contents:c,loader:y}},u.set(r,o)}return o.output}))}}}function P(e){if(!(e!=null&&e.bundler)){console.log(F.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 a=p.resolve(process.cwd(),".env.local");if(f.existsSync(a)){const r=f.readFileSync(a,"utf-8"),s=j.parse(r||"");(s==null?void 0:s.CODE_INSPECTOR)==="true"&&(t=!1)}}let n="";typeof __dirname!="undefined"?n=__dirname:n=p.dirname(i.fileURLToPath(typeof document=="undefined"?require("url").pathToFileURL(__filename).href:document.currentScript&&document.currentScript.src||new URL("index.js",document.baseURI).href));const l=v(C({},e),{close:t,output:p.resolve(n,"./")});return e.bundler==="webpack"||e.bundler==="rspack"?new w(l):e.bundler==="esbuild"?D(l):x.ViteCodeInspectorPlugin(l)}const E=P;exports.CodeInspectorPlugin=P;exports.codeInspectorPlugin=E;
|
package/dist/index.mjs
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
1
|
+
var I = Object.defineProperty, T = Object.defineProperties;
|
|
2
|
+
var x = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var m = Object.getOwnPropertySymbols;
|
|
4
|
-
var
|
|
5
|
-
var h = (e, t, n) => t in e ?
|
|
4
|
+
var _ = Object.prototype.hasOwnProperty, w = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var h = (e, t, n) => t in e ? I(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, v = (e, t) => {
|
|
6
6
|
for (var n in t || (t = {}))
|
|
7
|
-
|
|
7
|
+
_.call(t, n) && h(e, n, t[n]);
|
|
8
8
|
if (m)
|
|
9
9
|
for (var n of m(t))
|
|
10
|
-
|
|
10
|
+
w.call(t, n) && h(e, n, t[n]);
|
|
11
11
|
return e;
|
|
12
|
-
}, g = (e, t) =>
|
|
13
|
-
import { ViteCodeInspectorPlugin as
|
|
14
|
-
import
|
|
15
|
-
import { isDev as
|
|
12
|
+
}, g = (e, t) => T(e, x(t));
|
|
13
|
+
import { ViteCodeInspectorPlugin as F } from "vite-code-inspector-plugin";
|
|
14
|
+
import W from "webpack-code-inspector-plugin";
|
|
15
|
+
import { isDev as D, getMappingFilePath as E, matchCondition as C, getCodeWithWebComponent as S, isJsTypeFile as j, parseSFC as k, transformCode as P, fileURLToPath as O } from "code-inspector-core";
|
|
16
16
|
import u from "fs";
|
|
17
17
|
import d, { dirname as M } from "path";
|
|
18
18
|
import R from "chalk";
|
|
19
19
|
import L from "dotenv";
|
|
20
|
-
var N = (e, t, n) => new Promise((
|
|
20
|
+
var N = (e, t, n) => new Promise((l, c) => {
|
|
21
21
|
var a = (o) => {
|
|
22
22
|
try {
|
|
23
|
-
|
|
24
|
-
} catch (
|
|
25
|
-
c(
|
|
23
|
+
s(n.next(o));
|
|
24
|
+
} catch (i) {
|
|
25
|
+
c(i);
|
|
26
26
|
}
|
|
27
27
|
}, r = (o) => {
|
|
28
28
|
try {
|
|
29
|
-
|
|
30
|
-
} catch (
|
|
31
|
-
c(
|
|
29
|
+
s(n.throw(o));
|
|
30
|
+
} catch (i) {
|
|
31
|
+
c(i);
|
|
32
32
|
}
|
|
33
|
-
},
|
|
34
|
-
|
|
33
|
+
}, s = (o) => o.done ? l(o.value) : Promise.resolve(o.value).then(a, r);
|
|
34
|
+
s((n = n.apply(e, t)).next());
|
|
35
35
|
});
|
|
36
36
|
const J = "esbuild-code-inspector-plugin";
|
|
37
37
|
function U(e) {
|
|
38
38
|
return {
|
|
39
39
|
name: J,
|
|
40
40
|
setup(t) {
|
|
41
|
-
if (e.close || !
|
|
41
|
+
if (e.close || !D(e.dev, !1))
|
|
42
42
|
return;
|
|
43
43
|
const n = {
|
|
44
44
|
port: 0,
|
|
45
45
|
entry: "",
|
|
46
46
|
output: e.output
|
|
47
|
-
}, { escapeTags:
|
|
47
|
+
}, { escapeTags: l = [] } = e, c = /* @__PURE__ */ new Map();
|
|
48
48
|
t.onLoad(
|
|
49
49
|
{ filter: e.match || /\.(jsx|tsx|js|ts|mjs|mts)?$/ },
|
|
50
50
|
(a) => N(this, null, function* () {
|
|
51
51
|
let r = a.path;
|
|
52
|
-
r =
|
|
53
|
-
let
|
|
54
|
-
if (!o || o.originCode !==
|
|
55
|
-
let
|
|
56
|
-
if (r.match("node_modules")) {
|
|
57
|
-
if (!
|
|
58
|
-
return
|
|
52
|
+
r = E(r, e.mappings);
|
|
53
|
+
let s = yield u.promises.readFile(r, "utf8"), o = c.get(r);
|
|
54
|
+
if (!o || o.originCode !== s) {
|
|
55
|
+
let i = s;
|
|
56
|
+
if (r.match("node_modules") || C(e.include || [], r)) {
|
|
57
|
+
if (!C(e.include || [], r))
|
|
58
|
+
return i;
|
|
59
59
|
} else
|
|
60
|
-
|
|
60
|
+
i = yield S({
|
|
61
61
|
options: e,
|
|
62
62
|
file: r,
|
|
63
|
-
code:
|
|
63
|
+
code: i,
|
|
64
64
|
record: n
|
|
65
65
|
});
|
|
66
66
|
let p = "";
|
|
67
67
|
if (j(r) ? p = "jsx" : r.endsWith(".svelte") && (p = "svelte"), p)
|
|
68
|
-
|
|
69
|
-
content:
|
|
68
|
+
i = P({
|
|
69
|
+
content: i,
|
|
70
70
|
filePath: r,
|
|
71
71
|
fileType: p,
|
|
72
|
-
escapeTags:
|
|
72
|
+
escapeTags: l
|
|
73
73
|
});
|
|
74
74
|
else if (r.endsWith(".vue")) {
|
|
75
75
|
p = "vue";
|
|
76
|
-
const { descriptor: f } = k(
|
|
76
|
+
const { descriptor: f } = k(i, {
|
|
77
77
|
sourceMap: !1
|
|
78
|
-
}),
|
|
78
|
+
}), b = P({
|
|
79
79
|
content: f.template.content,
|
|
80
80
|
filePath: r,
|
|
81
81
|
fileType: p,
|
|
82
|
-
escapeTags:
|
|
82
|
+
escapeTags: l
|
|
83
83
|
});
|
|
84
|
-
|
|
84
|
+
i = i.replace(f.template.content, b);
|
|
85
85
|
}
|
|
86
|
-
const
|
|
87
|
-
o = { originCode:
|
|
86
|
+
const y = d.extname(r).replace(".", "");
|
|
87
|
+
o = { originCode: s, output: { contents: i, loader: y } }, c.set(r, o);
|
|
88
88
|
}
|
|
89
89
|
return o.output;
|
|
90
90
|
})
|
|
@@ -108,17 +108,17 @@ function V(e) {
|
|
|
108
108
|
else {
|
|
109
109
|
const a = d.resolve(process.cwd(), ".env.local");
|
|
110
110
|
if (u.existsSync(a)) {
|
|
111
|
-
const r = u.readFileSync(a, "utf-8"),
|
|
112
|
-
(
|
|
111
|
+
const r = u.readFileSync(a, "utf-8"), s = L.parse(r || "");
|
|
112
|
+
(s == null ? void 0 : s.CODE_INSPECTOR) === "true" && (t = !1);
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
let n = "";
|
|
116
116
|
typeof __dirname != "undefined" ? n = __dirname : n = M(O(import.meta.url));
|
|
117
|
-
const
|
|
117
|
+
const l = g(v({}, e), {
|
|
118
118
|
close: t,
|
|
119
119
|
output: d.resolve(n, "./")
|
|
120
120
|
});
|
|
121
|
-
return e.bundler === "webpack" || e.bundler === "rspack" ? new
|
|
121
|
+
return e.bundler === "webpack" || e.bundler === "rspack" ? new W(l) : e.bundler === "esbuild" ? U(l) : F(l);
|
|
122
122
|
}
|
|
123
123
|
const Q = V;
|
|
124
124
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "code-inspector-plugin",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.2",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"typings": "./types/index.d.ts",
|
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"chalk": "4.1.1",
|
|
50
50
|
"dotenv": "^16.3.1",
|
|
51
|
-
"code-inspector-core": "0.19.
|
|
52
|
-
"vite-code-inspector-plugin": "0.19.
|
|
53
|
-
"webpack-code-inspector-plugin": "0.19.
|
|
54
|
-
"esbuild-code-inspector-plugin": "0.19.
|
|
51
|
+
"code-inspector-core": "0.19.2",
|
|
52
|
+
"vite-code-inspector-plugin": "0.19.2",
|
|
53
|
+
"webpack-code-inspector-plugin": "0.19.2",
|
|
54
|
+
"esbuild-code-inspector-plugin": "0.19.2"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/node": "^16.0.1",
|