code-inspector-plugin 1.0.2 → 1.0.4
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/dist/index.js +1 -1
- package/dist/index.mjs +59 -69
- package/package.json +6 -7
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var _=Object.defineProperty,
|
|
1
|
+
"use strict";var _=Object.defineProperty,k=Object.defineProperties;var D=Object.getOwnPropertyDescriptors;var y=Object.getOwnPropertySymbols;var E=Object.prototype.hasOwnProperty,S=Object.prototype.propertyIsEnumerable;var g=(e,t,r)=>t in e?_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,v=(e,t)=>{for(var r in t||(t={}))E.call(t,r)&&g(e,r,t[r]);if(y)for(var r of y(t))S.call(t,r)&&g(e,r,t[r]);return e},h=(e,t)=>k(e,D(t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=require("vite-code-inspector-plugin"),W=require("webpack-code-inspector-plugin"),c=require("code-inspector-core"),m=require("path"),F=require("chalk"),R={};var L=(e,t,r)=>new Promise((i,p)=>{var d=o=>{try{l(r.next(o))}catch(s){p(s)}},n=o=>{try{l(r.throw(o))}catch(s){p(s)}},l=o=>o.done?i(o.value):Promise.resolve(o.value).then(d,n);l((r=r.apply(e,t)).next())});const M="esbuild-code-inspector-plugin";function U(e){return{name:M,setup(t){if(e.close||!c.isDev(e.dev,!1))return;const r={port:0,entry:"",output:e.output},{escapeTags:i=[]}=e,p=new Map;t.onLoad({filter:e.match||/\.(jsx|tsx|js|ts|mjs|mts)?$/},d=>L(this,null,function*(){let n=d.path;n=c.getMappingFilePath(n,e.mappings);let l=yield R.promises.readFile(n,"utf8"),o=p.get(n);if(!o||o.originCode!==l){let s=l,u=e.exclude||[];Array.isArray(u)||(u=[u]);const T=c.matchCondition([...u,/\/node_modules\//],n),O=c.matchCondition(e.include||[],n);if(T&&!O)return s;s=yield c.getCodeWithWebComponent({options:e,file:n,code:s,record:r});let a="";if(c.isJsTypeFile(n)?a="jsx":n.endsWith(".svelte")&&(a="svelte"),a)s=c.transformCode({content:s,filePath:n,fileType:a,escapeTags:i,pathType:e.pathType});else if(n.endsWith(".vue")){a="vue";const{descriptor:b}=c.parseSFC(s,{sourceMap:!1}),x=c.transformCode({content:b.template.content,filePath:n,fileType:a,escapeTags:i,pathType:e.pathType});s=s.replace(b.template.content,x)}const I=m.extname(n).replace(".","");o={originCode:l,output:{contents:s,loader:I}},p.set(n,o)}return o.output}))}}}var N=Object.defineProperty,V=Object.defineProperties,A=Object.getOwnPropertyDescriptors,P=Object.getOwnPropertySymbols,J=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,j=(e,t,r)=>t in e?N(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,f=(e,t)=>{for(var r in t||(t={}))J.call(t,r)&&j(e,r,t[r]);if(P)for(var r of P(t))$.call(t,r)&&j(e,r,t[r]);return e},C=(e,t)=>V(e,A(t));function z(e){const t={port:0,entry:"",output:e.output};return e.close||!c.isDev(e.dev,process.env.NODE_ENV==="development")?{}:{"**/*.{jsx,tsx,js,ts,mjs,mts}":{loaders:[f({loader:"webpack-code-inspector-plugin/dist/loader.js",options:C(f({},e),{record:t})},e.enforcePre===!1?{}:{enforce:"pre"}),{loader:"webpack-code-inspector-plugin/dist/inject-loader.js",options:C(f({},e),{record:t}),enforce:"pre"}]}}}function w(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;e.needEnvInspector&&(t=!0,c.getEnvVariable("CODE_INSPECTOR",process.cwd())==="true"&&(t=!1));let r="";typeof __dirname!="undefined"?r=__dirname:r=m.dirname(c.fileURLToPath(typeof document=="undefined"?require("url").pathToFileURL(__filename).href:document.currentScript&&document.currentScript.src||new URL("index.js",document.baseURI).href));const i=h(v({},e),{close:t,output:m.resolve(r,"./")});return e.bundler==="webpack"||e.bundler==="rspack"?new W(i):e.bundler==="esbuild"?U(i):e.bundler==="turbopack"?z(i):q.ViteCodeInspectorPlugin(i)}const B=w;exports.CodeInspectorPlugin=w;exports.codeInspectorPlugin=B;
|
package/dist/index.mjs
CHANGED
|
@@ -1,95 +1,94 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var b = (e, t, r) => t in e ?
|
|
1
|
+
var I = Object.defineProperty, _ = Object.defineProperties;
|
|
2
|
+
var D = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var m = Object.getOwnPropertySymbols;
|
|
4
|
+
var W = Object.prototype.hasOwnProperty, F = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var b = (e, t, r) => t in e ? I(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, y = (e, t) => {
|
|
6
6
|
for (var r in t || (t = {}))
|
|
7
|
-
|
|
8
|
-
if (
|
|
9
|
-
for (var r of
|
|
10
|
-
|
|
7
|
+
W.call(t, r) && b(e, r, t[r]);
|
|
8
|
+
if (m)
|
|
9
|
+
for (var r of m(t))
|
|
10
|
+
F.call(t, r) && b(e, r, t[r]);
|
|
11
11
|
return e;
|
|
12
|
-
},
|
|
13
|
-
import { ViteCodeInspectorPlugin as
|
|
14
|
-
import
|
|
15
|
-
import { isDev as
|
|
16
|
-
import
|
|
17
|
-
import m, { dirname as U } from "path";
|
|
12
|
+
}, v = (e, t) => _(e, D(t));
|
|
13
|
+
import { ViteCodeInspectorPlugin as M } from "vite-code-inspector-plugin";
|
|
14
|
+
import N from "webpack-code-inspector-plugin";
|
|
15
|
+
import { isDev as C, getMappingFilePath as S, matchCondition as g, getCodeWithWebComponent as V, isJsTypeFile as A, parseSFC as L, transformCode as h, getEnvVariable as R, fileURLToPath as J } from "code-inspector-core";
|
|
16
|
+
import O, { dirname as U } from "path";
|
|
18
17
|
import $ from "chalk";
|
|
19
|
-
|
|
20
|
-
var z = (e, t, r) => new Promise((l,
|
|
21
|
-
var
|
|
18
|
+
const q = {};
|
|
19
|
+
var z = (e, t, r) => new Promise((l, c) => {
|
|
20
|
+
var u = (n) => {
|
|
22
21
|
try {
|
|
23
|
-
|
|
22
|
+
i(r.next(n));
|
|
24
23
|
} catch (s) {
|
|
25
|
-
|
|
24
|
+
c(s);
|
|
26
25
|
}
|
|
27
26
|
}, o = (n) => {
|
|
28
27
|
try {
|
|
29
|
-
|
|
28
|
+
i(r.throw(n));
|
|
30
29
|
} catch (s) {
|
|
31
|
-
|
|
30
|
+
c(s);
|
|
32
31
|
}
|
|
33
|
-
},
|
|
34
|
-
|
|
32
|
+
}, i = (n) => n.done ? l(n.value) : Promise.resolve(n.value).then(u, o);
|
|
33
|
+
i((r = r.apply(e, t)).next());
|
|
35
34
|
});
|
|
36
35
|
const B = "esbuild-code-inspector-plugin";
|
|
37
36
|
function G(e) {
|
|
38
37
|
return {
|
|
39
38
|
name: B,
|
|
40
39
|
setup(t) {
|
|
41
|
-
if (e.close || !
|
|
40
|
+
if (e.close || !C(e.dev, !1))
|
|
42
41
|
return;
|
|
43
42
|
const r = {
|
|
44
43
|
port: 0,
|
|
45
44
|
entry: "",
|
|
46
45
|
output: e.output
|
|
47
|
-
}, { escapeTags: l = [] } = e,
|
|
46
|
+
}, { escapeTags: l = [] } = e, c = /* @__PURE__ */ new Map();
|
|
48
47
|
t.onLoad(
|
|
49
48
|
{ filter: e.match || /\.(jsx|tsx|js|ts|mjs|mts)?$/ },
|
|
50
|
-
(
|
|
51
|
-
let o =
|
|
52
|
-
o =
|
|
53
|
-
let
|
|
54
|
-
if (!n || n.originCode !==
|
|
55
|
-
let s =
|
|
56
|
-
Array.isArray(
|
|
57
|
-
const
|
|
58
|
-
[...
|
|
49
|
+
(u) => z(this, null, function* () {
|
|
50
|
+
let o = u.path;
|
|
51
|
+
o = S(o, e.mappings);
|
|
52
|
+
let i = yield q.promises.readFile(o, "utf8"), n = c.get(o);
|
|
53
|
+
if (!n || n.originCode !== i) {
|
|
54
|
+
let s = i, a = e.exclude || [];
|
|
55
|
+
Array.isArray(a) || (a = [a]);
|
|
56
|
+
const T = g(
|
|
57
|
+
[...a, /\/node_modules\//],
|
|
59
58
|
o
|
|
60
|
-
),
|
|
61
|
-
if (
|
|
59
|
+
), x = g(e.include || [], o);
|
|
60
|
+
if (T && !x)
|
|
62
61
|
return s;
|
|
63
|
-
s = yield
|
|
62
|
+
s = yield V({
|
|
64
63
|
options: e,
|
|
65
64
|
file: o,
|
|
66
65
|
code: s,
|
|
67
66
|
record: r
|
|
68
67
|
});
|
|
69
|
-
let
|
|
70
|
-
if (
|
|
71
|
-
s =
|
|
68
|
+
let p = "";
|
|
69
|
+
if (A(o) ? p = "jsx" : o.endsWith(".svelte") && (p = "svelte"), p)
|
|
70
|
+
s = h({
|
|
72
71
|
content: s,
|
|
73
72
|
filePath: o,
|
|
74
|
-
fileType:
|
|
73
|
+
fileType: p,
|
|
75
74
|
escapeTags: l,
|
|
76
75
|
pathType: e.pathType
|
|
77
76
|
});
|
|
78
77
|
else if (o.endsWith(".vue")) {
|
|
79
|
-
|
|
80
|
-
const { descriptor:
|
|
78
|
+
p = "vue";
|
|
79
|
+
const { descriptor: f } = L(s, {
|
|
81
80
|
sourceMap: !1
|
|
82
|
-
}),
|
|
83
|
-
content:
|
|
81
|
+
}), E = h({
|
|
82
|
+
content: f.template.content,
|
|
84
83
|
filePath: o,
|
|
85
|
-
fileType:
|
|
84
|
+
fileType: p,
|
|
86
85
|
escapeTags: l,
|
|
87
86
|
pathType: e.pathType
|
|
88
87
|
});
|
|
89
|
-
s = s.replace(
|
|
88
|
+
s = s.replace(f.template.content, E);
|
|
90
89
|
}
|
|
91
|
-
const
|
|
92
|
-
n = { originCode:
|
|
90
|
+
const k = O.extname(o).replace(".", "");
|
|
91
|
+
n = { originCode: i, output: { contents: s, loader: k } }, c.set(o, n);
|
|
93
92
|
}
|
|
94
93
|
return n.output;
|
|
95
94
|
})
|
|
@@ -97,12 +96,12 @@ function G(e) {
|
|
|
97
96
|
}
|
|
98
97
|
};
|
|
99
98
|
}
|
|
100
|
-
var H = Object.defineProperty, K = Object.defineProperties, Q = Object.getOwnPropertyDescriptors,
|
|
99
|
+
var H = Object.defineProperty, K = Object.defineProperties, Q = Object.getOwnPropertyDescriptors, P = Object.getOwnPropertySymbols, X = Object.prototype.hasOwnProperty, Y = Object.prototype.propertyIsEnumerable, j = (e, t, r) => t in e ? H(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, d = (e, t) => {
|
|
101
100
|
for (var r in t || (t = {}))
|
|
102
|
-
X.call(t, r) &&
|
|
103
|
-
if (
|
|
104
|
-
for (var r of
|
|
105
|
-
Y.call(t, r) &&
|
|
101
|
+
X.call(t, r) && j(e, r, t[r]);
|
|
102
|
+
if (P)
|
|
103
|
+
for (var r of P(t))
|
|
104
|
+
Y.call(t, r) && j(e, r, t[r]);
|
|
106
105
|
return e;
|
|
107
106
|
}, w = (e, t) => K(e, Q(t));
|
|
108
107
|
function Z(e) {
|
|
@@ -111,7 +110,7 @@ function Z(e) {
|
|
|
111
110
|
entry: "",
|
|
112
111
|
output: e.output
|
|
113
112
|
};
|
|
114
|
-
return e.close || !
|
|
113
|
+
return e.close || !C(e.dev, process.env.NODE_ENV === "development") ? {} : {
|
|
115
114
|
"**/*.{jsx,tsx,js,ts,mjs,mts}": {
|
|
116
115
|
loaders: [
|
|
117
116
|
d({
|
|
@@ -141,23 +140,14 @@ function ee(e) {
|
|
|
141
140
|
return;
|
|
142
141
|
}
|
|
143
142
|
let t = !1;
|
|
144
|
-
|
|
145
|
-
if (t = !0, process.env.CODE_INSPECTOR === "true")
|
|
146
|
-
t = !1;
|
|
147
|
-
else {
|
|
148
|
-
const i = m.resolve(process.cwd(), ".env.local");
|
|
149
|
-
if (f.existsSync(i)) {
|
|
150
|
-
const o = f.readFileSync(i, "utf-8"), c = q.parse(o || "");
|
|
151
|
-
(c == null ? void 0 : c.CODE_INSPECTOR) === "true" && (t = !1);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
143
|
+
e.needEnvInspector && (t = !0, R("CODE_INSPECTOR", process.cwd()) === "true" && (t = !1));
|
|
154
144
|
let r = "";
|
|
155
145
|
typeof __dirname != "undefined" ? r = __dirname : r = U(J(import.meta.url));
|
|
156
|
-
const l =
|
|
146
|
+
const l = v(y({}, e), {
|
|
157
147
|
close: t,
|
|
158
|
-
output:
|
|
148
|
+
output: O.resolve(r, "./")
|
|
159
149
|
});
|
|
160
|
-
return e.bundler === "webpack" || e.bundler === "rspack" ? new
|
|
150
|
+
return e.bundler === "webpack" || e.bundler === "rspack" ? new N(l) : e.bundler === "esbuild" ? G(l) : e.bundler === "turbopack" ? Z(l) : M(l);
|
|
161
151
|
}
|
|
162
152
|
const ie = ee;
|
|
163
153
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "code-inspector-plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"module": "./dist/index.mjs",
|
|
6
6
|
"typings": "./types/index.d.ts",
|
|
@@ -47,12 +47,11 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"chalk": "4.1.1",
|
|
50
|
-
"
|
|
51
|
-
"code-inspector-
|
|
52
|
-
"esbuild-code-inspector-plugin": "1.0.
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"turbopack-code-inspector-plugin": "1.0.2"
|
|
50
|
+
"code-inspector-core": "1.0.4",
|
|
51
|
+
"vite-code-inspector-plugin": "1.0.4",
|
|
52
|
+
"esbuild-code-inspector-plugin": "1.0.4",
|
|
53
|
+
"webpack-code-inspector-plugin": "1.0.4",
|
|
54
|
+
"turbopack-code-inspector-plugin": "1.0.4"
|
|
56
55
|
},
|
|
57
56
|
"devDependencies": {
|
|
58
57
|
"@types/node": "^16.0.1",
|