code-inspector-plugin 1.0.5 → 1.1.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/README.md CHANGED
@@ -42,17 +42,16 @@ The following are which compilers, web frameworks and editors we supported now:
42
42
  ✅ rspack / rsbuild<br />
43
43
  ✅ farm<br />
44
44
  ✅ esbuild<br />
45
- ✅ turbopack (next.js v15+)<br />
46
- nextjs / nuxt / umijs eg.<br />
45
+ ✅ turbopack<br />
46
+ mako<br />
47
47
  - The following Web frameworks are currently supported:<br />
48
- ✅ vue2<br />
49
- vue3<br />
50
- ✅ react<br />
48
+ ✅ vue2 / vue3 / nuxt<br />
49
+ react / nextjs / umijs<br />
51
50
  ✅ preact<br />
52
51
  ✅ solid<br />
53
52
  ✅ qwik<br />
54
53
  ✅ svelte<br />
55
- ✅ astro
54
+ ✅ astro<br />
56
55
  - The following code editors are currently supported:<br />
57
56
  [VSCode](https://code.visualstudio.com/) | [Cursor](https://www.cursor.com/) | [Windsurf](https://codeium.com/windsurf) | [WebStorm](https://www.jetbrains.com/webstorm/) | [Atom](https://atom.io/) | [HBuilderX](https://www.dcloud.io/hbuilderx.html) | [PhpStorm](https://www.jetbrains.com/phpstorm/) | [PyCharm](https://www.jetbrains.com/pycharm/) | [IntelliJ IDEA](https://www.jetbrains.com/idea/) | [and Others](https://inspector.fe-dev.cn/en/guide/ide.html)
58
57
 
@@ -213,112 +212,136 @@ Please check here for more usage information: [code-inspector-plugin configurati
213
212
  <details>
214
213
  <summary>Click to expand configuration about: <b>nuxt</b></summary>
215
214
 
216
- For nuxt3.x :
215
+ - For nuxt3.x :
217
216
 
218
- ```js
219
- // nuxt.config.js
220
- import { codeInspectorPlugin } from 'code-inspector-plugin';
217
+ ```js
218
+ // nuxt.config.js
219
+ import { codeInspectorPlugin } from 'code-inspector-plugin';
221
220
 
222
- // https://nuxt.com/docs/api/configuration/nuxt-config
223
- export default defineNuxtConfig({
224
- vite: {
225
- plugins: [codeInspectorPlugin({ bundler: 'vite' })],
226
- },
227
- });
228
- ```
221
+ // https://nuxt.com/docs/api/configuration/nuxt-config
222
+ export default defineNuxtConfig({
223
+ vite: {
224
+ plugins: [codeInspectorPlugin({ bundler: 'vite' })],
225
+ },
226
+ });
227
+ ```
229
228
 
230
- For nuxt2.x :
229
+ - For nuxt2.x :
231
230
 
232
- ```js
233
- // nuxt.config.js
234
- import { codeInspectorPlugin } from 'code-inspector-plugin';
231
+ ```js
232
+ // nuxt.config.js
233
+ import { codeInspectorPlugin } from 'code-inspector-plugin';
235
234
 
236
- export default {
237
- build: {
238
- extend(config) {
239
- config.plugins.push(codeInspectorPlugin({ bundler: 'webpack' }));
240
- return config;
235
+ export default {
236
+ build: {
237
+ extend(config) {
238
+ config.plugins.push(codeInspectorPlugin({ bundler: 'webpack' }));
239
+ return config;
240
+ },
241
241
  },
242
- },
243
- };
244
- ```
242
+ };
243
+ ```
245
244
 
246
245
  </details>
247
246
 
248
247
  <details>
249
248
  <summary>Click to expand configuration about: <b>next.js</b></summary>
250
249
 
251
- For next.js(<= 14.x):
252
- ```js
253
- // next.config.js
254
- const { codeInspectorPlugin } = require('code-inspector-plugin');
250
+ - For next.js(<= 14.x):
255
251
 
256
- const nextConfig = {
257
- webpack: (config, { dev, isServer }) => {
258
- config.plugins.push(codeInspectorPlugin({ bundler: 'webpack' }));
259
- return config;
260
- },
261
- };
252
+ ```js
253
+ // next.config.js
254
+ const { codeInspectorPlugin } = require('code-inspector-plugin');
262
255
 
263
- module.exports = nextConfig;
264
- ```
256
+ const nextConfig = {
257
+ webpack: (config, { dev, isServer }) => {
258
+ config.plugins.push(codeInspectorPlugin({ bundler: 'webpack' }));
259
+ return config;
260
+ },
261
+ };
265
262
 
266
- For next.js(15.0.x ~ 15.2.x):
267
- ```js
268
- import type { NextConfig } from 'next';
269
- import { codeInspectorPlugin } from 'code-inspector-plugin';
263
+ module.exports = nextConfig;
264
+ ```
270
265
 
271
- const nextConfig: NextConfig = {
272
- experimental: {
273
- turbo: {
274
- rules: codeInspectorPlugin({
275
- bundler: 'turbopack',
276
- }),
266
+ - For next.js(15.0.x ~ 15.2.x):
267
+
268
+ ```js
269
+ import type { NextConfig } from 'next';
270
+ import { codeInspectorPlugin } from 'code-inspector-plugin';
271
+
272
+ const nextConfig: NextConfig = {
273
+ experimental: {
274
+ turbo: {
275
+ rules: codeInspectorPlugin({
276
+ bundler: 'turbopack',
277
+ }),
278
+ },
277
279
  },
278
- },
279
- };
280
+ };
280
281
 
281
- export default nextConfig;
282
- ```
282
+ export default nextConfig;
283
+ ```
283
284
 
284
- For next.js(>= 15.3.x):
285
- ```js
286
- // next.config.js
287
- import type { NextConfig } from 'next';
288
- import { codeInspectorPlugin } from 'code-inspector-plugin';
285
+ - For next.js(>= 15.3.x):
289
286
 
290
- const nextConfig: NextConfig = {
291
- turbopack: {
292
- rules: codeInspectorPlugin({
293
- bundler: 'turbopack',
294
- }),
295
- },
296
- };
287
+ ```js
288
+ // next.config.js
289
+ import type { NextConfig } from 'next';
290
+ import { codeInspectorPlugin } from 'code-inspector-plugin';
297
291
 
298
- export default nextConfig;
299
- ```
292
+ const nextConfig: NextConfig = {
293
+ turbopack: {
294
+ rules: codeInspectorPlugin({
295
+ bundler: 'turbopack',
296
+ }),
297
+ },
298
+ };
299
+
300
+ export default nextConfig;
301
+ ```
300
302
 
301
303
  </details>
302
304
 
303
305
  <details>
304
306
  <summary>Click to expand configuration about: <b>umi.js</b></summary>
305
307
 
306
- ```js
307
- // umi.config.js or umirc.js
308
- import { defineConfig } from '@umijs/max';
309
- import { codeInspectorPlugin } from 'code-inspector-plugin';
308
+ - With webpack:
310
309
 
311
- export default defineConfig({
312
- chainWebpack(memo) {
313
- memo.plugin('code-inspector-plugin').use(
314
- codeInspectorPlugin({
315
- bundler: 'webpack',
316
- })
317
- );
318
- },
319
- // other config
320
- });
321
- ```
310
+ ```js
311
+ // umi.config.js or umirc.js
312
+ import { defineConfig } from '@umijs/max';
313
+ import { codeInspectorPlugin } from 'code-inspector-plugin';
314
+
315
+ export default defineConfig({
316
+ chainWebpack(memo) {
317
+ memo.plugin('code-inspector-plugin').use(
318
+ codeInspectorPlugin({
319
+ bundler: 'webpack',
320
+ })
321
+ );
322
+ },
323
+ // other config
324
+ });
325
+ ```
326
+
327
+ - With mako:
328
+
329
+ ```ts
330
+ // .umirc.ts
331
+ import { defineConfig } from 'umi';
332
+ import { codeInspectorPlugin } from 'code-inspector-plugin';
333
+
334
+ export default defineConfig({
335
+ // other config...
336
+ mako: {
337
+ plugins: [
338
+ codeInspectorPlugin({
339
+ bundler: 'mako',
340
+ }),
341
+ ],
342
+ },
343
+ });
344
+ ```
322
345
 
323
346
  </details>
324
347
 
package/dist/index.js CHANGED
@@ -1 +1 @@
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;
1
+ "use strict";var x=Object.defineProperty,O=Object.defineProperties;var E=Object.getOwnPropertyDescriptors;var h=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var v=(e,t,r)=>t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,y=(e,t)=>{for(var r in t||(t={}))k.call(t,r)&&v(e,r,t[r]);if(h)for(var r of h(t))F.call(t,r)&&v(e,r,t[r]);return e},b=(e,t)=>O(e,E(t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("@code-inspector/vite"),_=require("@code-inspector/webpack"),i=require("@code-inspector/core"),d=require("path"),D=require("chalk"),S={};var W=(e,t,r)=>new Promise((s,p)=>{var a=n=>{try{l(r.next(n))}catch(o){p(o)}},c=n=>{try{l(r.throw(n))}catch(o){p(o)}},l=n=>n.done?s(n.value):Promise.resolve(n.value).then(a,c);l((r=r.apply(e,t)).next())});const q="@code-inspector/esbuild";function M(e){return{name:q,setup(t){if(e.close||!i.isDev(e.dev,!1))return;const r={port:0,entry:"",output:e.output},{escapeTags:s=[]}=e,p=new Map;t.onLoad({filter:e.match||/\.(jsx|tsx|js|ts|mjs|mts)?$/},a=>W(this,null,function*(){let c=a.path;c=i.getMappingFilePath(c,e.mappings);let l=yield S.promises.readFile(c,"utf8"),n=p.get(c);if(!n||n.originCode!==l){let o=l;if(i.isExcludedFile(c,e))return o;o=yield i.getCodeWithWebComponent({options:e,file:c,code:o,record:r});let u="";if(i.isJsTypeFile(c)?u="jsx":c.endsWith(".svelte")&&(u="svelte"),u)o=i.transformCode({content:o,filePath:c,fileType:u,escapeTags:s,pathType:e.pathType});else if(c.endsWith(".vue")){u="vue";const{descriptor:m}=i.parseSFC(o,{sourceMap:!1}),w=i.transformCode({content:m.template.content,filePath:c,fileType:u,escapeTags:s,pathType:e.pathType});o=o.replace(m.template.content,w)}const C=d.extname(c).replace(".","");n={originCode:l,output:{contents:o,loader:C}},p.set(c,n)}return n.output}))}}}var N=Object.defineProperty,R=Object.defineProperties,L=Object.getOwnPropertyDescriptors,g=Object.getOwnPropertySymbols,U=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable,P=(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={}))U.call(t,r)&&P(e,r,t[r]);if(g)for(var r of g(t))V.call(t,r)&&P(e,r,t[r]);return e},j=(e,t)=>R(e,L(t));function J(e){const t={port:0,entry:"",output:e.output};return e.close||!i.isDev(e.dev,process.env.NODE_ENV==="development")?{}:{"**/*.{jsx,tsx,js,ts,mjs,mts}":{loaders:[f({loader:"@code-inspector/webpack/dist/loader.js",options:j(f({},e),{record:t})},e.enforcePre===!1?{}:{enforce:"pre"}),{loader:"@code-inspector/webpack/dist/inject-loader.js",options:j(f({},e),{record:t}),enforce:"pre"}]}}}var $=(e,t,r)=>new Promise((s,p)=>{var a=n=>{try{l(r.next(n))}catch(o){p(o)}},c=n=>{try{l(r.throw(n))}catch(o){p(o)}},l=n=>n.done?s(n.value):Promise.resolve(n.value).then(a,c);l((r=r.apply(e,t)).next())});function z(e){const t={port:0,entry:"",output:e.output};return e.close||!i.isDev(e.dev,process.env.NODE_ENV==="development")?{name:"@code-inspector/mako"}:{name:"@code-inspector/mako",enforce:e.enforcePre===!1?"post":"pre",transform:(r,s)=>$(this,null,function*(){if(i.isExcludedFile(s,e)||s.includes("/.umi/"))return;const{escapeTags:p=[],mappings:a,match:c}=e||{};if(c&&!c.test(s))return;const l=yield i.getCodeWithWebComponent({options:e,file:s,code:r,record:t});if(i.isJsTypeFile(s)){const n=d.extname(s).slice(1);let o=i.normalizePath(s);return o=i.getMappingFilePath(o,a),{content:i.transformCode({content:l,filePath:o,fileType:"jsx",escapeTags:p,pathType:e.pathType}),type:n}}})}}function T(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;e.needEnvInspector&&(t=!0,i.getEnvVariable("CODE_INSPECTOR",process.cwd())==="true"&&(t=!1));let r="";typeof __dirname!="undefined"?r=__dirname:r=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 s=b(y({},e),{close:t,output:d.resolve(r,"./")});return e.bundler==="webpack"||e.bundler==="rspack"?new _(s):e.bundler==="esbuild"?M(s):e.bundler==="turbopack"?J(s):e.bundler==="mako"?z(s):I.ViteCodeInspectorPlugin(s)}const A=T;exports.CodeInspectorPlugin=T;exports.codeInspectorPlugin=A;
package/dist/index.mjs CHANGED
@@ -1,94 +1,89 @@
1
1
  var I = Object.defineProperty, _ = Object.defineProperties;
2
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) => {
3
+ var v = Object.getOwnPropertySymbols;
4
+ var F = Object.prototype.hasOwnProperty, N = Object.prototype.propertyIsEnumerable;
5
+ var y = (e, t, r) => t in e ? I(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, b = (e, t) => {
6
6
  for (var r in t || (t = {}))
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]);
7
+ F.call(t, r) && y(e, r, t[r]);
8
+ if (v)
9
+ for (var r of v(t))
10
+ N.call(t, r) && y(e, r, t[r]);
11
11
  return e;
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";
17
- import $ from "chalk";
18
- const q = {};
19
- var z = (e, t, r) => new Promise((l, c) => {
20
- var u = (n) => {
12
+ }, P = (e, t) => _(e, D(t));
13
+ import { ViteCodeInspectorPlugin as W } from "@code-inspector/vite";
14
+ import V from "@code-inspector/webpack";
15
+ import { isDev as f, getMappingFilePath as w, isExcludedFile as x, getCodeWithWebComponent as O, isJsTypeFile as k, parseSFC as M, transformCode as d, normalizePath as S, getEnvVariable as L, fileURLToPath as R } from "@code-inspector/core";
16
+ import m, { dirname as $ } from "path";
17
+ import z from "chalk";
18
+ const J = {};
19
+ var U = (e, t, r) => new Promise((s, l) => {
20
+ var i = (n) => {
21
21
  try {
22
- i(r.next(n));
23
- } catch (s) {
24
- c(s);
22
+ p(r.next(n));
23
+ } catch (o) {
24
+ l(o);
25
25
  }
26
- }, o = (n) => {
26
+ }, c = (n) => {
27
27
  try {
28
- i(r.throw(n));
29
- } catch (s) {
30
- c(s);
28
+ p(r.throw(n));
29
+ } catch (o) {
30
+ l(o);
31
31
  }
32
- }, i = (n) => n.done ? l(n.value) : Promise.resolve(n.value).then(u, o);
33
- i((r = r.apply(e, t)).next());
32
+ }, p = (n) => n.done ? s(n.value) : Promise.resolve(n.value).then(i, c);
33
+ p((r = r.apply(e, t)).next());
34
34
  });
35
- const B = "esbuild-code-inspector-plugin";
36
- function G(e) {
35
+ const q = "@code-inspector/esbuild";
36
+ function A(e) {
37
37
  return {
38
- name: B,
38
+ name: q,
39
39
  setup(t) {
40
- if (e.close || !C(e.dev, !1))
40
+ if (e.close || !f(e.dev, !1))
41
41
  return;
42
42
  const r = {
43
43
  port: 0,
44
44
  entry: "",
45
45
  output: e.output
46
- }, { escapeTags: l = [] } = e, c = /* @__PURE__ */ new Map();
46
+ }, { escapeTags: s = [] } = e, l = /* @__PURE__ */ new Map();
47
47
  t.onLoad(
48
48
  { filter: e.match || /\.(jsx|tsx|js|ts|mjs|mts)?$/ },
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\//],
58
- o
59
- ), x = g(e.include || [], o);
60
- if (T && !x)
61
- return s;
62
- s = yield V({
49
+ (i) => U(this, null, function* () {
50
+ let c = i.path;
51
+ c = w(c, e.mappings);
52
+ let p = yield J.promises.readFile(c, "utf8"), n = l.get(c);
53
+ if (!n || n.originCode !== p) {
54
+ let o = p;
55
+ if (x(c, e))
56
+ return o;
57
+ o = yield O({
63
58
  options: e,
64
- file: o,
65
- code: s,
59
+ file: c,
60
+ code: o,
66
61
  record: r
67
62
  });
68
- let p = "";
69
- if (A(o) ? p = "jsx" : o.endsWith(".svelte") && (p = "svelte"), p)
70
- s = h({
71
- content: s,
72
- filePath: o,
73
- fileType: p,
74
- escapeTags: l,
63
+ let a = "";
64
+ if (k(c) ? a = "jsx" : c.endsWith(".svelte") && (a = "svelte"), a)
65
+ o = d({
66
+ content: o,
67
+ filePath: c,
68
+ fileType: a,
69
+ escapeTags: s,
75
70
  pathType: e.pathType
76
71
  });
77
- else if (o.endsWith(".vue")) {
78
- p = "vue";
79
- const { descriptor: f } = L(s, {
72
+ else if (c.endsWith(".vue")) {
73
+ a = "vue";
74
+ const { descriptor: h } = M(o, {
80
75
  sourceMap: !1
81
- }), E = h({
82
- content: f.template.content,
83
- filePath: o,
84
- fileType: p,
85
- escapeTags: l,
76
+ }), E = d({
77
+ content: h.template.content,
78
+ filePath: c,
79
+ fileType: a,
80
+ escapeTags: s,
86
81
  pathType: e.pathType
87
82
  });
88
- s = s.replace(f.template.content, E);
83
+ o = o.replace(h.template.content, E);
89
84
  }
90
- const k = O.extname(o).replace(".", "");
91
- n = { originCode: i, output: { contents: s, loader: k } }, c.set(o, n);
85
+ const C = m.extname(c).replace(".", "");
86
+ n = { originCode: p, output: { contents: o, loader: C } }, l.set(c, n);
92
87
  }
93
88
  return n.output;
94
89
  })
@@ -96,32 +91,32 @@ function G(e) {
96
91
  }
97
92
  };
98
93
  }
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) => {
94
+ var B = Object.defineProperty, G = Object.defineProperties, H = Object.getOwnPropertyDescriptors, g = Object.getOwnPropertySymbols, K = Object.prototype.hasOwnProperty, Q = Object.prototype.propertyIsEnumerable, j = (e, t, r) => t in e ? B(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, u = (e, t) => {
100
95
  for (var r in t || (t = {}))
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]);
96
+ K.call(t, r) && j(e, r, t[r]);
97
+ if (g)
98
+ for (var r of g(t))
99
+ Q.call(t, r) && j(e, r, t[r]);
105
100
  return e;
106
- }, w = (e, t) => K(e, Q(t));
107
- function Z(e) {
101
+ }, T = (e, t) => G(e, H(t));
102
+ function X(e) {
108
103
  const t = {
109
104
  port: 0,
110
105
  entry: "",
111
106
  output: e.output
112
107
  };
113
- return e.close || !C(e.dev, process.env.NODE_ENV === "development") ? {} : {
108
+ return e.close || !f(e.dev, process.env.NODE_ENV === "development") ? {} : {
114
109
  "**/*.{jsx,tsx,js,ts,mjs,mts}": {
115
110
  loaders: [
116
- d({
117
- loader: "webpack-code-inspector-plugin/dist/loader.js",
118
- options: w(d({}, e), {
111
+ u({
112
+ loader: "@code-inspector/webpack/dist/loader.js",
113
+ options: T(u({}, e), {
119
114
  record: t
120
115
  })
121
116
  }, e.enforcePre === !1 ? {} : { enforce: "pre" }),
122
117
  {
123
- loader: "webpack-code-inspector-plugin/dist/inject-loader.js",
124
- options: w(d({}, e), {
118
+ loader: "@code-inspector/webpack/dist/inject-loader.js",
119
+ options: T(u({}, e), {
125
120
  record: t
126
121
  }),
127
122
  enforce: "pre"
@@ -130,27 +125,80 @@ function Z(e) {
130
125
  }
131
126
  };
132
127
  }
128
+ var Y = (e, t, r) => new Promise((s, l) => {
129
+ var i = (n) => {
130
+ try {
131
+ p(r.next(n));
132
+ } catch (o) {
133
+ l(o);
134
+ }
135
+ }, c = (n) => {
136
+ try {
137
+ p(r.throw(n));
138
+ } catch (o) {
139
+ l(o);
140
+ }
141
+ }, p = (n) => n.done ? s(n.value) : Promise.resolve(n.value).then(i, c);
142
+ p((r = r.apply(e, t)).next());
143
+ });
144
+ function Z(e) {
145
+ const t = {
146
+ port: 0,
147
+ entry: "",
148
+ output: e.output
149
+ };
150
+ return e.close || !f(e.dev, process.env.NODE_ENV === "development") ? {
151
+ name: "@code-inspector/mako"
152
+ } : {
153
+ name: "@code-inspector/mako",
154
+ enforce: e.enforcePre === !1 ? "post" : "pre",
155
+ transform: (r, s) => Y(this, null, function* () {
156
+ if (x(s, e) || s.includes("/.umi/"))
157
+ return;
158
+ const { escapeTags: l = [], mappings: i, match: c } = e || {};
159
+ if (c && !c.test(s))
160
+ return;
161
+ const p = yield O({
162
+ options: e,
163
+ file: s,
164
+ code: r,
165
+ record: t
166
+ });
167
+ if (k(s)) {
168
+ const n = m.extname(s).slice(1);
169
+ let o = S(s);
170
+ return o = w(o, i), { content: d({
171
+ content: p,
172
+ filePath: o,
173
+ fileType: "jsx",
174
+ escapeTags: l,
175
+ pathType: e.pathType
176
+ }), type: n };
177
+ }
178
+ })
179
+ };
180
+ }
133
181
  function ee(e) {
134
182
  if (!(e != null && e.bundler)) {
135
183
  console.log(
136
- $.red(
184
+ z.red(
137
185
  "Please specify the bundler in the options of code-inspector-plugin."
138
186
  )
139
187
  );
140
188
  return;
141
189
  }
142
190
  let t = !1;
143
- e.needEnvInspector && (t = !0, R("CODE_INSPECTOR", process.cwd()) === "true" && (t = !1));
191
+ e.needEnvInspector && (t = !0, L("CODE_INSPECTOR", process.cwd()) === "true" && (t = !1));
144
192
  let r = "";
145
- typeof __dirname != "undefined" ? r = __dirname : r = U(J(import.meta.url));
146
- const l = v(y({}, e), {
193
+ typeof __dirname != "undefined" ? r = __dirname : r = $(R(import.meta.url));
194
+ const s = P(b({}, e), {
147
195
  close: t,
148
- output: O.resolve(r, "./")
196
+ output: m.resolve(r, "./")
149
197
  });
150
- return e.bundler === "webpack" || e.bundler === "rspack" ? new N(l) : e.bundler === "esbuild" ? G(l) : e.bundler === "turbopack" ? Z(l) : M(l);
198
+ return e.bundler === "webpack" || e.bundler === "rspack" ? new V(s) : e.bundler === "esbuild" ? A(s) : e.bundler === "turbopack" ? X(s) : e.bundler === "mako" ? Z(s) : W(s);
151
199
  }
152
- const ie = ee;
200
+ const pe = ee;
153
201
  export {
154
202
  ee as CodeInspectorPlugin,
155
- ie as codeInspectorPlugin
203
+ pe as codeInspectorPlugin
156
204
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "code-inspector-plugin",
3
- "version": "1.0.5",
3
+ "version": "1.1.0",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./types/index.d.ts",
@@ -47,11 +47,12 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "chalk": "4.1.1",
50
- "code-inspector-core": "1.0.5",
51
- "vite-code-inspector-plugin": "1.0.5",
52
- "esbuild-code-inspector-plugin": "1.0.5",
53
- "webpack-code-inspector-plugin": "1.0.5",
54
- "turbopack-code-inspector-plugin": "1.0.5"
50
+ "@code-inspector/core": "1.1.0",
51
+ "@code-inspector/esbuild": "1.1.0",
52
+ "@code-inspector/webpack": "1.1.0",
53
+ "@code-inspector/turbopack": "1.1.0",
54
+ "@code-inspector/mako": "1.1.0",
55
+ "@code-inspector/vite": "1.1.0"
55
56
  },
56
57
  "devDependencies": {
57
58
  "@types/node": "^16.0.1",
package/types/index.d.ts CHANGED
@@ -1,10 +1,5 @@
1
- import { CodeOptions } from 'code-inspector-core';
1
+ import { CodeOptions } from '@code-inspector/core';
2
2
  export interface CodeInspectorPluginOptions extends CodeOptions {
3
- /**
4
- * @zh 指定项目的打包器
5
- * @en specify the bundler of the project
6
- */
7
- bundler: 'vite' | 'webpack' | 'rspack' | 'esbuild' | 'turbopack';
8
3
  /**
9
4
  * @zh 设置为 true 时,仅当 .env.local 文件存在且其包含 CODE_INSPECTOR=true 时插件生效;默认值为 false
10
5
  * @en When set the value to true, only if the .env.local file exists and it contains CODE_INSPECTOR=true, the plugin takes effect; The default value is false