code-inspector-plugin 0.19.2 → 0.20.0
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 +50 -48
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var T=Object.defineProperty,b=Object.defineProperties;var S=Object.getOwnPropertyDescriptors;var m=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var g=(e,t,n)=>t in e?T(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(m)for(var n of m(t))q.call(t,n)&&g(e,n,t[n]);return e},v=(e,t)=>b(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"),d=require("path"),F=require("chalk"),j=require("dotenv");var R=(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 D="esbuild-code-inspector-plugin";function E(e){return{name:D,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 c=yield f.promises.readFile(r,"utf8"),o=u.get(r);if(!o||o.originCode!==c){let s=c;if(r.match("node_modules")||i.matchCondition(e.include||[],r)){if(!i.matchCondition(e.include||[],r))return s}else s=yield i.getCodeWithWebComponent({options:e,file:r,code:s,record:n});let p="";if(i.isJsTypeFile(r)?p="jsx":r.endsWith(".svelte")&&(p="svelte"),p)s=i.transformCode({content:s,filePath:r,fileType:p,escapeTags:l,pathType:e.pathType});else if(r.endsWith(".vue")){p="vue";const{descriptor:h}=i.parseSFC(s,{sourceMap:!1}),I=i.transformCode({content:h.template.content,filePath:r,fileType:p,escapeTags:l,pathType:e.pathType});s=s.replace(h.template.content,I)}const P=d.extname(r).replace(".","");o={originCode:c,output:{contents:s,loader:P}},u.set(r,o)}return o.output}))}}}function y(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=d.resolve(process.cwd(),".env.local");if(f.existsSync(a)){const r=f.readFileSync(a,"utf-8"),c=j.parse(r||"");(c==null?void 0:c.CODE_INSPECTOR)==="true"&&(t=!1)}}let n="";typeof __dirname!="undefined"?n=__dirname:n=d.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:d.resolve(n,"./")});return e.bundler==="webpack"||e.bundler==="rspack"?new w(l):e.bundler==="esbuild"?E(l):x.ViteCodeInspectorPlugin(l)}const O=y;exports.CodeInspectorPlugin=y;exports.codeInspectorPlugin=O;
|
package/dist/index.mjs
CHANGED
|
@@ -1,90 +1,92 @@
|
|
|
1
|
-
var
|
|
1
|
+
var b = Object.defineProperty, I = Object.defineProperties;
|
|
2
2
|
var x = Object.getOwnPropertyDescriptors;
|
|
3
3
|
var m = Object.getOwnPropertySymbols;
|
|
4
4
|
var _ = Object.prototype.hasOwnProperty, w = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var h = (e, t, n) => t in e ?
|
|
5
|
+
var h = (e, t, n) => t in e ? b(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) =>
|
|
12
|
+
}, g = (e, t) => I(e, x(t));
|
|
13
13
|
import { ViteCodeInspectorPlugin as F } from "vite-code-inspector-plugin";
|
|
14
|
-
import
|
|
15
|
-
import { isDev as
|
|
14
|
+
import D from "webpack-code-inspector-plugin";
|
|
15
|
+
import { isDev as E, getMappingFilePath as S, matchCondition as y, getCodeWithWebComponent as W, isJsTypeFile as j, parseSFC as k, transformCode as C, 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((
|
|
21
|
-
var
|
|
20
|
+
var N = (e, t, n) => new Promise((i, c) => {
|
|
21
|
+
var p = (o) => {
|
|
22
22
|
try {
|
|
23
|
-
|
|
24
|
-
} catch (
|
|
25
|
-
c(
|
|
23
|
+
l(n.next(o));
|
|
24
|
+
} catch (s) {
|
|
25
|
+
c(s);
|
|
26
26
|
}
|
|
27
27
|
}, r = (o) => {
|
|
28
28
|
try {
|
|
29
|
-
|
|
30
|
-
} catch (
|
|
31
|
-
c(
|
|
29
|
+
l(n.throw(o));
|
|
30
|
+
} catch (s) {
|
|
31
|
+
c(s);
|
|
32
32
|
}
|
|
33
|
-
},
|
|
34
|
-
|
|
33
|
+
}, l = (o) => o.done ? i(o.value) : Promise.resolve(o.value).then(p, r);
|
|
34
|
+
l((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 || !E(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: i = [] } = e, c = /* @__PURE__ */ new Map();
|
|
48
48
|
t.onLoad(
|
|
49
49
|
{ filter: e.match || /\.(jsx|tsx|js|ts|mjs|mts)?$/ },
|
|
50
|
-
(
|
|
51
|
-
let r =
|
|
52
|
-
r =
|
|
53
|
-
let
|
|
54
|
-
if (!o || o.originCode !==
|
|
55
|
-
let
|
|
56
|
-
if (r.match("node_modules") ||
|
|
57
|
-
if (!
|
|
58
|
-
return
|
|
50
|
+
(p) => N(this, null, function* () {
|
|
51
|
+
let r = p.path;
|
|
52
|
+
r = S(r, e.mappings);
|
|
53
|
+
let l = yield u.promises.readFile(r, "utf8"), o = c.get(r);
|
|
54
|
+
if (!o || o.originCode !== l) {
|
|
55
|
+
let s = l;
|
|
56
|
+
if (r.match("node_modules") || y(e.include || [], r)) {
|
|
57
|
+
if (!y(e.include || [], r))
|
|
58
|
+
return s;
|
|
59
59
|
} else
|
|
60
|
-
|
|
60
|
+
s = yield W({
|
|
61
61
|
options: e,
|
|
62
62
|
file: r,
|
|
63
|
-
code:
|
|
63
|
+
code: s,
|
|
64
64
|
record: n
|
|
65
65
|
});
|
|
66
|
-
let
|
|
67
|
-
if (j(r) ?
|
|
68
|
-
|
|
69
|
-
content:
|
|
66
|
+
let a = "";
|
|
67
|
+
if (j(r) ? a = "jsx" : r.endsWith(".svelte") && (a = "svelte"), a)
|
|
68
|
+
s = C({
|
|
69
|
+
content: s,
|
|
70
70
|
filePath: r,
|
|
71
|
-
fileType:
|
|
72
|
-
escapeTags:
|
|
71
|
+
fileType: a,
|
|
72
|
+
escapeTags: i,
|
|
73
|
+
pathType: e.pathType
|
|
73
74
|
});
|
|
74
75
|
else if (r.endsWith(".vue")) {
|
|
75
|
-
|
|
76
|
-
const { descriptor: f } = k(
|
|
76
|
+
a = "vue";
|
|
77
|
+
const { descriptor: f } = k(s, {
|
|
77
78
|
sourceMap: !1
|
|
78
|
-
}),
|
|
79
|
+
}), T = C({
|
|
79
80
|
content: f.template.content,
|
|
80
81
|
filePath: r,
|
|
81
|
-
fileType:
|
|
82
|
-
escapeTags:
|
|
82
|
+
fileType: a,
|
|
83
|
+
escapeTags: i,
|
|
84
|
+
pathType: e.pathType
|
|
83
85
|
});
|
|
84
|
-
|
|
86
|
+
s = s.replace(f.template.content, T);
|
|
85
87
|
}
|
|
86
|
-
const
|
|
87
|
-
o = { originCode:
|
|
88
|
+
const P = d.extname(r).replace(".", "");
|
|
89
|
+
o = { originCode: l, output: { contents: s, loader: P } }, c.set(r, o);
|
|
88
90
|
}
|
|
89
91
|
return o.output;
|
|
90
92
|
})
|
|
@@ -106,19 +108,19 @@ function V(e) {
|
|
|
106
108
|
if (t = !0, process.env.CODE_INSPECTOR === "true")
|
|
107
109
|
t = !1;
|
|
108
110
|
else {
|
|
109
|
-
const
|
|
110
|
-
if (u.existsSync(
|
|
111
|
-
const r = u.readFileSync(
|
|
112
|
-
(
|
|
111
|
+
const p = d.resolve(process.cwd(), ".env.local");
|
|
112
|
+
if (u.existsSync(p)) {
|
|
113
|
+
const r = u.readFileSync(p, "utf-8"), l = L.parse(r || "");
|
|
114
|
+
(l == null ? void 0 : l.CODE_INSPECTOR) === "true" && (t = !1);
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
117
|
let n = "";
|
|
116
118
|
typeof __dirname != "undefined" ? n = __dirname : n = M(O(import.meta.url));
|
|
117
|
-
const
|
|
119
|
+
const i = g(v({}, e), {
|
|
118
120
|
close: t,
|
|
119
121
|
output: d.resolve(n, "./")
|
|
120
122
|
});
|
|
121
|
-
return e.bundler === "webpack" || e.bundler === "rspack" ? new
|
|
123
|
+
return e.bundler === "webpack" || e.bundler === "rspack" ? new D(i) : e.bundler === "esbuild" ? U(i) : F(i);
|
|
122
124
|
}
|
|
123
125
|
const Q = V;
|
|
124
126
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "code-inspector-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
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.
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
51
|
+
"code-inspector-core": "0.20.0",
|
|
52
|
+
"webpack-code-inspector-plugin": "0.20.0",
|
|
53
|
+
"esbuild-code-inspector-plugin": "0.20.0",
|
|
54
|
+
"vite-code-inspector-plugin": "0.20.0"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
57
|
"@types/node": "^16.0.1",
|