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 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
+ [![Star History Chart](https://api.star-history.com/svg?repos=zh-lx/code-inspector&type=Date)](https://www.star-history.com/#zh-lx/code-inspector&Date)
package/dist/index.js CHANGED
@@ -1 +1 @@
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;
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 b = Object.defineProperty, I = Object.defineProperties;
2
- var x = Object.getOwnPropertyDescriptors;
3
- var m = Object.getOwnPropertySymbols;
4
- var _ = Object.prototype.hasOwnProperty, w = Object.prototype.propertyIsEnumerable;
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
- for (var n in t || (t = {}))
7
- _.call(t, n) && h(e, n, t[n]);
8
- if (m)
9
- for (var n of m(t))
10
- w.call(t, n) && h(e, n, t[n]);
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
- }, g = (e, t) => I(e, x(t));
13
- import { ViteCodeInspectorPlugin as F } from "vite-code-inspector-plugin";
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
- import u from "fs";
17
- import d, { dirname as M } from "path";
18
- import R from "chalk";
19
- import L from "dotenv";
20
- var N = (e, t, n) => new Promise((i, c) => {
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
- l(n.next(o));
23
+ i(r.next(o));
24
24
  } catch (s) {
25
25
  c(s);
26
26
  }
27
- }, r = (o) => {
27
+ }, n = (o) => {
28
28
  try {
29
- l(n.throw(o));
29
+ i(r.throw(o));
30
30
  } catch (s) {
31
31
  c(s);
32
32
  }
33
- }, l = (o) => o.done ? i(o.value) : Promise.resolve(o.value).then(p, r);
34
- l((n = n.apply(e, t)).next());
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 J = "esbuild-code-inspector-plugin";
37
- function U(e) {
36
+ const V = "esbuild-code-inspector-plugin";
37
+ function $(e) {
38
38
  return {
39
- name: J,
39
+ name: V,
40
40
  setup(t) {
41
- if (e.close || !E(e.dev, !1))
41
+ if (e.close || !j(e.dev, !1))
42
42
  return;
43
- const n = {
43
+ const r = {
44
44
  port: 0,
45
45
  entry: "",
46
46
  output: e.output
47
- }, { escapeTags: i = [] } = e, c = /* @__PURE__ */ new Map();
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) => 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
- } else
60
- s = yield W({
61
- options: e,
62
- file: r,
63
- code: s,
64
- record: n
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 (j(r) ? a = "jsx" : r.endsWith(".svelte") && (a = "svelte"), a)
68
- s = C({
70
+ if (M(n) ? a = "jsx" : n.endsWith(".svelte") && (a = "svelte"), a)
71
+ s = P({
69
72
  content: s,
70
- filePath: r,
73
+ filePath: n,
71
74
  fileType: a,
72
- escapeTags: i,
75
+ escapeTags: l,
73
76
  pathType: e.pathType
74
77
  });
75
- else if (r.endsWith(".vue")) {
78
+ else if (n.endsWith(".vue")) {
76
79
  a = "vue";
77
- const { descriptor: f } = k(s, {
80
+ const { descriptor: m } = R(s, {
78
81
  sourceMap: !1
79
- }), T = C({
80
- content: f.template.content,
81
- filePath: r,
82
+ }), x = P({
83
+ content: m.template.content,
84
+ filePath: n,
82
85
  fileType: a,
83
- escapeTags: i,
86
+ escapeTags: l,
84
87
  pathType: e.pathType
85
88
  });
86
- s = s.replace(f.template.content, T);
89
+ s = s.replace(m.template.content, x);
87
90
  }
88
- const P = d.extname(r).replace(".", "");
89
- o = { originCode: l, output: { contents: s, loader: P } }, c.set(r, o);
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 V(e) {
100
+ function q(e) {
98
101
  if (!(e != null && e.bundler)) {
99
102
  console.log(
100
- R.red(
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 = 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);
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 n = "";
118
- typeof __dirname != "undefined" ? n = __dirname : n = M(O(import.meta.url));
119
- const i = g(v({}, e), {
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: d.resolve(n, "./")
124
+ output: f.resolve(r, "./")
122
125
  });
123
- return e.bundler === "webpack" || e.bundler === "rspack" ? new D(i) : e.bundler === "esbuild" ? U(i) : F(i);
126
+ return e.bundler === "webpack" || e.bundler === "rspack" ? new W(l) : e.bundler === "esbuild" ? $(l) : S(l);
124
127
  }
125
- const Q = V;
128
+ const Z = q;
126
129
  export {
127
- V as CodeInspectorPlugin,
128
- Q as codeInspectorPlugin
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.14",
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-core": "0.20.14",
52
- "webpack-code-inspector-plugin": "0.20.14",
53
- "vite-code-inspector-plugin": "0.20.14",
54
- "esbuild-code-inspector-plugin": "0.20.14"
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",