code-inspector-plugin 0.19.2 → 0.20.1

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 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{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;
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 I = Object.defineProperty, T = Object.defineProperties;
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 ? I(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, v = (e, t) => {
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) => T(e, x(t));
12
+ }, g = (e, t) => I(e, x(t));
13
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";
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((l, c) => {
21
- var a = (o) => {
20
+ var N = (e, t, n) => new Promise((i, c) => {
21
+ var p = (o) => {
22
22
  try {
23
- s(n.next(o));
24
- } catch (i) {
25
- c(i);
23
+ l(n.next(o));
24
+ } catch (s) {
25
+ c(s);
26
26
  }
27
27
  }, r = (o) => {
28
28
  try {
29
- s(n.throw(o));
30
- } catch (i) {
31
- c(i);
29
+ l(n.throw(o));
30
+ } catch (s) {
31
+ c(s);
32
32
  }
33
- }, s = (o) => o.done ? l(o.value) : Promise.resolve(o.value).then(a, r);
34
- s((n = n.apply(e, t)).next());
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 || !D(e.dev, !1))
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: l = [] } = e, c = /* @__PURE__ */ new Map();
47
+ }, { escapeTags: i = [] } = e, c = /* @__PURE__ */ new Map();
48
48
  t.onLoad(
49
49
  { filter: e.match || /\.(jsx|tsx|js|ts|mjs|mts)?$/ },
50
- (a) => N(this, null, function* () {
51
- let r = a.path;
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;
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
- i = yield S({
60
+ s = yield W({
61
61
  options: e,
62
62
  file: r,
63
- code: i,
63
+ code: s,
64
64
  record: n
65
65
  });
66
- let p = "";
67
- if (j(r) ? p = "jsx" : r.endsWith(".svelte") && (p = "svelte"), p)
68
- i = P({
69
- content: i,
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: p,
72
- escapeTags: l
71
+ fileType: a,
72
+ escapeTags: i,
73
+ pathType: e.pathType
73
74
  });
74
75
  else if (r.endsWith(".vue")) {
75
- p = "vue";
76
- const { descriptor: f } = k(i, {
76
+ a = "vue";
77
+ const { descriptor: f } = k(s, {
77
78
  sourceMap: !1
78
- }), b = P({
79
+ }), T = C({
79
80
  content: f.template.content,
80
81
  filePath: r,
81
- fileType: p,
82
- escapeTags: l
82
+ fileType: a,
83
+ escapeTags: i,
84
+ pathType: e.pathType
83
85
  });
84
- i = i.replace(f.template.content, b);
86
+ s = s.replace(f.template.content, T);
85
87
  }
86
- const y = d.extname(r).replace(".", "");
87
- o = { originCode: s, output: { contents: i, loader: y } }, c.set(r, o);
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 a = d.resolve(process.cwd(), ".env.local");
110
- if (u.existsSync(a)) {
111
- const r = u.readFileSync(a, "utf-8"), s = L.parse(r || "");
112
- (s == null ? void 0 : s.CODE_INSPECTOR) === "true" && (t = !1);
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 l = g(v({}, e), {
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 W(l) : e.bundler === "esbuild" ? U(l) : F(l);
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.19.2",
3
+ "version": "0.20.1",
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.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"
51
+ "code-inspector-core": "0.20.1",
52
+ "vite-code-inspector-plugin": "0.20.1",
53
+ "esbuild-code-inspector-plugin": "0.20.1",
54
+ "webpack-code-inspector-plugin": "0.20.1"
55
55
  },
56
56
  "devDependencies": {
57
57
  "@types/node": "^16.0.1",