code-inspector-plugin 0.20.14 → 0.20.16
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 +4 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +76 -73
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -331,3 +331,7 @@ For Chinese users, you can join the QQ group `769748484` or add the author's Wei
|
|
|
331
331
|
## 💖 Sponsor
|
|
332
332
|
|
|
333
333
|
Sponsoring this project can help the author create better. If you are willing, thanks for sponsoring me through [here](https://inspector.fe-dev.cn/en/more/sponsor.html).
|
|
334
|
+
|
|
335
|
+
## Star History
|
|
336
|
+
|
|
337
|
+
[](https://www.star-history.com/#zh-lx/code-inspector&Date)
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var S=Object.defineProperty,_=Object.defineProperties;var q=Object.getOwnPropertyDescriptors;var y=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var C=(e,t,n)=>t in e?S(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g=(e,t)=>{for(var n in t||(t={}))w.call(t,n)&&C(e,n,t[n]);if(y)for(var n of y(t))F.call(t,n)&&C(e,n,t[n]);return e},v=(e,t)=>_(e,q(t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const j=require("vite-code-inspector-plugin"),R=require("webpack-code-inspector-plugin"),i=require("code-inspector-core"),m=require("fs"),f=require("path"),D=require("chalk"),E=require("dotenv");var O=(e,t,n)=>new Promise((l,u)=>{var a=o=>{try{c(n.next(o))}catch(s){u(s)}},r=o=>{try{c(n.throw(o))}catch(s){u(s)}},c=o=>o.done?l(o.value):Promise.resolve(o.value).then(a,r);c((n=n.apply(e,t)).next())});const W="esbuild-code-inspector-plugin";function k(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=>O(this,null,function*(){let r=a.path;r=i.getMappingFilePath(r,e.mappings);let c=yield m.promises.readFile(r,"utf8"),o=u.get(r);if(!o||o.originCode!==c){let s=c,p=e.exclude||[];Array.isArray(p)||(p=[p]);const I=i.matchCondition([...p,/\/node_modules\//],r),T=i.matchCondition(e.include||[],r);if(I&&!T)return s;s=yield i.getCodeWithWebComponent({options:e,file:r,code:s,record:n});let d="";if(i.isJsTypeFile(r)?d="jsx":r.endsWith(".svelte")&&(d="svelte"),d)s=i.transformCode({content:s,filePath:r,fileType:d,escapeTags:l,pathType:e.pathType});else if(r.endsWith(".vue")){d="vue";const{descriptor:h}=i.parseSFC(s,{sourceMap:!1}),x=i.transformCode({content:h.template.content,filePath:r,fileType:d,escapeTags:l,pathType:e.pathType});s=s.replace(h.template.content,x)}const b=f.extname(r).replace(".","");o={originCode:c,output:{contents:s,loader:b}},u.set(r,o)}return o.output}))}}}function P(e){if(!(e!=null&&e.bundler)){console.log(D.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=f.resolve(process.cwd(),".env.local");if(m.existsSync(a)){const r=m.readFileSync(a,"utf-8"),c=E.parse(r||"");(c==null?void 0:c.CODE_INSPECTOR)==="true"&&(t=!1)}}let n="";typeof __dirname!="undefined"?n=__dirname:n=f.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(g({},e),{close:t,output:f.resolve(n,"./")});return e.bundler==="webpack"||e.bundler==="rspack"?new R(l):e.bundler==="esbuild"?k(l):j.ViteCodeInspectorPlugin(l)}const L=P;exports.CodeInspectorPlugin=P;exports.codeInspectorPlugin=L;
|
package/dist/index.mjs
CHANGED
|
@@ -1,92 +1,95 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
for (var
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var
|
|
10
|
-
|
|
1
|
+
var w = Object.defineProperty, _ = Object.defineProperties;
|
|
2
|
+
var F = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var h = Object.getOwnPropertySymbols;
|
|
4
|
+
var D = Object.prototype.hasOwnProperty, E = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var y = (e, t, r) => t in e ? w(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, v = (e, t) => {
|
|
6
|
+
for (var r in t || (t = {}))
|
|
7
|
+
D.call(t, r) && y(e, r, t[r]);
|
|
8
|
+
if (h)
|
|
9
|
+
for (var r of h(t))
|
|
10
|
+
E.call(t, r) && y(e, r, t[r]);
|
|
11
11
|
return e;
|
|
12
|
-
},
|
|
13
|
-
import { ViteCodeInspectorPlugin as
|
|
14
|
-
import
|
|
15
|
-
import { isDev as
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
var
|
|
12
|
+
}, C = (e, t) => _(e, F(t));
|
|
13
|
+
import { ViteCodeInspectorPlugin as S } from "vite-code-inspector-plugin";
|
|
14
|
+
import W from "webpack-code-inspector-plugin";
|
|
15
|
+
import { isDev as j, getMappingFilePath as k, matchCondition as g, getCodeWithWebComponent as O, isJsTypeFile as M, parseSFC as R, transformCode as P, fileURLToPath as A } from "code-inspector-core";
|
|
16
|
+
import d from "fs";
|
|
17
|
+
import f, { dirname as L } from "path";
|
|
18
|
+
import N from "chalk";
|
|
19
|
+
import J from "dotenv";
|
|
20
|
+
var U = (e, t, r) => new Promise((l, c) => {
|
|
21
21
|
var p = (o) => {
|
|
22
22
|
try {
|
|
23
|
-
|
|
23
|
+
i(r.next(o));
|
|
24
24
|
} catch (s) {
|
|
25
25
|
c(s);
|
|
26
26
|
}
|
|
27
|
-
},
|
|
27
|
+
}, n = (o) => {
|
|
28
28
|
try {
|
|
29
|
-
|
|
29
|
+
i(r.throw(o));
|
|
30
30
|
} catch (s) {
|
|
31
31
|
c(s);
|
|
32
32
|
}
|
|
33
|
-
},
|
|
34
|
-
|
|
33
|
+
}, i = (o) => o.done ? l(o.value) : Promise.resolve(o.value).then(p, n);
|
|
34
|
+
i((r = r.apply(e, t)).next());
|
|
35
35
|
});
|
|
36
|
-
const
|
|
37
|
-
function
|
|
36
|
+
const V = "esbuild-code-inspector-plugin";
|
|
37
|
+
function $(e) {
|
|
38
38
|
return {
|
|
39
|
-
name:
|
|
39
|
+
name: V,
|
|
40
40
|
setup(t) {
|
|
41
|
-
if (e.close || !
|
|
41
|
+
if (e.close || !j(e.dev, !1))
|
|
42
42
|
return;
|
|
43
|
-
const
|
|
43
|
+
const r = {
|
|
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
|
-
(p) =>
|
|
51
|
-
let
|
|
52
|
-
|
|
53
|
-
let
|
|
54
|
-
if (!o || o.originCode !==
|
|
55
|
-
let s =
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
50
|
+
(p) => U(this, null, function* () {
|
|
51
|
+
let n = p.path;
|
|
52
|
+
n = k(n, e.mappings);
|
|
53
|
+
let i = yield d.promises.readFile(n, "utf8"), o = c.get(n);
|
|
54
|
+
if (!o || o.originCode !== i) {
|
|
55
|
+
let s = i, u = e.exclude || [];
|
|
56
|
+
Array.isArray(u) || (u = [u]);
|
|
57
|
+
const T = g(
|
|
58
|
+
[...u, /\/node_modules\//],
|
|
59
|
+
n
|
|
60
|
+
), b = g(e.include || [], n);
|
|
61
|
+
if (T && !b)
|
|
62
|
+
return s;
|
|
63
|
+
s = yield O({
|
|
64
|
+
options: e,
|
|
65
|
+
file: n,
|
|
66
|
+
code: s,
|
|
67
|
+
record: r
|
|
68
|
+
});
|
|
66
69
|
let a = "";
|
|
67
|
-
if (
|
|
68
|
-
s =
|
|
70
|
+
if (M(n) ? a = "jsx" : n.endsWith(".svelte") && (a = "svelte"), a)
|
|
71
|
+
s = P({
|
|
69
72
|
content: s,
|
|
70
|
-
filePath:
|
|
73
|
+
filePath: n,
|
|
71
74
|
fileType: a,
|
|
72
|
-
escapeTags:
|
|
75
|
+
escapeTags: l,
|
|
73
76
|
pathType: e.pathType
|
|
74
77
|
});
|
|
75
|
-
else if (
|
|
78
|
+
else if (n.endsWith(".vue")) {
|
|
76
79
|
a = "vue";
|
|
77
|
-
const { descriptor:
|
|
80
|
+
const { descriptor: m } = R(s, {
|
|
78
81
|
sourceMap: !1
|
|
79
|
-
}),
|
|
80
|
-
content:
|
|
81
|
-
filePath:
|
|
82
|
+
}), x = P({
|
|
83
|
+
content: m.template.content,
|
|
84
|
+
filePath: n,
|
|
82
85
|
fileType: a,
|
|
83
|
-
escapeTags:
|
|
86
|
+
escapeTags: l,
|
|
84
87
|
pathType: e.pathType
|
|
85
88
|
});
|
|
86
|
-
s = s.replace(
|
|
89
|
+
s = s.replace(m.template.content, x);
|
|
87
90
|
}
|
|
88
|
-
const
|
|
89
|
-
o = { originCode:
|
|
91
|
+
const I = f.extname(n).replace(".", "");
|
|
92
|
+
o = { originCode: i, output: { contents: s, loader: I } }, c.set(n, o);
|
|
90
93
|
}
|
|
91
94
|
return o.output;
|
|
92
95
|
})
|
|
@@ -94,10 +97,10 @@ function U(e) {
|
|
|
94
97
|
}
|
|
95
98
|
};
|
|
96
99
|
}
|
|
97
|
-
function
|
|
100
|
+
function q(e) {
|
|
98
101
|
if (!(e != null && e.bundler)) {
|
|
99
102
|
console.log(
|
|
100
|
-
|
|
103
|
+
N.red(
|
|
101
104
|
"Please specify the bundler in the options of code-inspector-plugin."
|
|
102
105
|
)
|
|
103
106
|
);
|
|
@@ -108,22 +111,22 @@ function V(e) {
|
|
|
108
111
|
if (t = !0, process.env.CODE_INSPECTOR === "true")
|
|
109
112
|
t = !1;
|
|
110
113
|
else {
|
|
111
|
-
const p =
|
|
112
|
-
if (
|
|
113
|
-
const
|
|
114
|
-
(
|
|
114
|
+
const p = f.resolve(process.cwd(), ".env.local");
|
|
115
|
+
if (d.existsSync(p)) {
|
|
116
|
+
const n = d.readFileSync(p, "utf-8"), i = J.parse(n || "");
|
|
117
|
+
(i == null ? void 0 : i.CODE_INSPECTOR) === "true" && (t = !1);
|
|
115
118
|
}
|
|
116
119
|
}
|
|
117
|
-
let
|
|
118
|
-
typeof __dirname != "undefined" ?
|
|
119
|
-
const
|
|
120
|
+
let r = "";
|
|
121
|
+
typeof __dirname != "undefined" ? r = __dirname : r = L(A(import.meta.url));
|
|
122
|
+
const l = C(v({}, e), {
|
|
120
123
|
close: t,
|
|
121
|
-
output:
|
|
124
|
+
output: f.resolve(r, "./")
|
|
122
125
|
});
|
|
123
|
-
return e.bundler === "webpack" || e.bundler === "rspack" ? new
|
|
126
|
+
return e.bundler === "webpack" || e.bundler === "rspack" ? new W(l) : e.bundler === "esbuild" ? $(l) : S(l);
|
|
124
127
|
}
|
|
125
|
-
const
|
|
128
|
+
const Z = q;
|
|
126
129
|
export {
|
|
127
|
-
|
|
128
|
-
|
|
130
|
+
q as CodeInspectorPlugin,
|
|
131
|
+
Z as codeInspectorPlugin
|
|
129
132
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "code-inspector-plugin",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.16",
|
|
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-
|
|
52
|
-
"
|
|
53
|
-
"vite-code-inspector-plugin": "0.20.
|
|
54
|
-
"
|
|
51
|
+
"esbuild-code-inspector-plugin": "0.20.16",
|
|
52
|
+
"code-inspector-core": "0.20.16",
|
|
53
|
+
"vite-code-inspector-plugin": "0.20.16",
|
|
54
|
+
"webpack-code-inspector-plugin": "0.20.16"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/node": "^16.0.1",
|