@code-inspector/webpack 1.2.1 → 1.2.3-beta.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.mjs CHANGED
@@ -1,68 +1,68 @@
1
- var _ = Object.defineProperty, E = Object.defineProperties;
2
- var T = Object.getOwnPropertyDescriptors;
3
- var k = Object.getOwnPropertySymbols;
4
- var L = Object.prototype.hasOwnProperty, N = Object.prototype.propertyIsEnumerable;
5
- var x = (e, t, s) => t in e ? _(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, c = (e, t) => {
1
+ var L = Object.defineProperty, N = Object.defineProperties;
2
+ var O = Object.getOwnPropertyDescriptors;
3
+ var $ = Object.getOwnPropertySymbols;
4
+ var S = Object.prototype.hasOwnProperty, z = Object.prototype.propertyIsEnumerable;
5
+ var w = (e, t, s) => t in e ? L(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, h = (e, t) => {
6
6
  for (var s in t || (t = {}))
7
- L.call(t, s) && x(e, s, t[s]);
8
- if (k)
9
- for (var s of k(t))
10
- N.call(t, s) && x(e, s, t[s]);
7
+ S.call(t, s) && w(e, s, t[s]);
8
+ if ($)
9
+ for (var s of $(t))
10
+ z.call(t, s) && w(e, s, t[s]);
11
11
  return e;
12
- }, j = (e, t) => E(e, T(t));
13
- var d = (e, t, s) => new Promise((n, a) => {
14
- var r = (o) => {
12
+ }, v = (e, t) => N(e, O(t));
13
+ var d = (e, t, s) => new Promise((n, r) => {
14
+ var a = (o) => {
15
15
  try {
16
16
  u(s.next(o));
17
17
  } catch (f) {
18
- a(f);
18
+ r(f);
19
19
  }
20
20
  }, i = (o) => {
21
21
  try {
22
22
  u(s.throw(o));
23
23
  } catch (f) {
24
- a(f);
24
+ r(f);
25
25
  }
26
- }, u = (o) => o.done ? n(o.value) : Promise.resolve(o.value).then(r, i);
26
+ }, u = (o) => o.done ? n(o.value) : Promise.resolve(o.value).then(a, i);
27
27
  u((s = s.apply(e, t)).next());
28
28
  });
29
- import { normalizePath as C, fileURLToPath as O, isDev as z, isNextjsProject as I, getCodeWithWebComponent as F } from "@code-inspector/core";
30
- import p, { dirname as H } from "path";
31
- function Q(e, t) {
29
+ import { normalizePath as D, fileURLToPath as I, isDev as F, isNextjsProject as H, getCodeWithWebComponent as Q } from "@code-inspector/core";
30
+ import p, { dirname as R } from "path";
31
+ function U(e, t) {
32
32
  return d(this, null, function* () {
33
33
  if (!e || !t)
34
34
  return [];
35
35
  const s = typeof e == "function" ? yield e() : e;
36
36
  let n = [];
37
37
  if (typeof s == "object" && !Array.isArray(s))
38
- for (const a in s) {
39
- const r = s[a], i = r.import || r;
40
- $(n, i, t);
38
+ for (const r in s) {
39
+ const a = s[r], i = a.import || a;
40
+ W(n, i, t);
41
41
  }
42
42
  else
43
- $(n, s, t);
44
- return n.filter((a) => !!a);
43
+ W(n, s, t);
44
+ return n.filter((r) => !!r);
45
45
  });
46
46
  }
47
- function $(e, t, s) {
48
- typeof t == "string" ? e.push(w(t, s)) : Array.isArray(t) && e.push(
49
- ...t.map((n) => w(n, s))
47
+ function W(e, t, s) {
48
+ typeof t == "string" ? e.push(_(t, s)) : Array.isArray(t) && e.push(
49
+ ...t.map((n) => _(n, s))
50
50
  );
51
51
  }
52
- function w(e, t) {
53
- return p.isAbsolute(e) ? C(e) : e.startsWith(".") ? p.resolve(t, C(e)) : "";
52
+ function _(e, t) {
53
+ return p.isAbsolute(e) ? D(e) : e.startsWith(".") ? p.resolve(t, D(e)) : "";
54
54
  }
55
55
  let y = "";
56
- typeof __dirname != "undefined" ? y = __dirname : y = H(O(import.meta.url));
57
- let g = !0;
58
- const R = (e, t) => {
59
- var r, i;
60
- if (!g)
56
+ typeof __dirname != "undefined" ? y = __dirname : y = R(I(import.meta.url));
57
+ let b = !0;
58
+ const V = (e, t) => {
59
+ var a, i;
60
+ if (!b)
61
61
  return;
62
- g = !1;
63
- const s = (t == null ? void 0 : t.compiler) || t, n = (r = s == null ? void 0 : s.options) == null ? void 0 : r.module;
62
+ b = !1;
63
+ const s = (t == null ? void 0 : t.compiler) || t, n = (a = s == null ? void 0 : s.options) == null ? void 0 : a.module;
64
64
  ((n == null ? void 0 : n.rules) || (n == null ? void 0 : n.loaders) || []).push(
65
- c({
65
+ h({
66
66
  test: (i = e.match) != null ? i : /\.html$/,
67
67
  resourceQuery: /vue/,
68
68
  use: [
@@ -72,7 +72,7 @@ const R = (e, t) => {
72
72
  }
73
73
  ]
74
74
  }, e.enforcePre === !1 ? {} : { enforce: "pre" }),
75
- c({
75
+ h({
76
76
  test: /\.(vue|jsx|tsx|js|ts|mjs|mts|svelte)$/,
77
77
  use: [
78
78
  {
@@ -81,7 +81,7 @@ const R = (e, t) => {
81
81
  }
82
82
  ]
83
83
  }, e.enforcePre === !1 ? {} : { enforce: "pre" }),
84
- j(c({}, e.injectTo ? { resource: e.injectTo } : {
84
+ v(h({}, e.injectTo ? { resource: e.injectTo } : {
85
85
  test: /\.(jsx|tsx|js|ts|mjs|mts)$/,
86
86
  exclude: /node_modules/
87
87
  }), {
@@ -91,53 +91,53 @@ const R = (e, t) => {
91
91
  options: e
92
92
  }
93
93
  ],
94
- enforce: I() ? "pre" : "post"
94
+ enforce: H() ? "pre" : "post"
95
95
  })
96
96
  );
97
97
  };
98
- function b(e, t) {
99
- return F({
100
- options: j(c({}, e), { importClient: "code" }),
98
+ function k(e, t) {
99
+ return Q({
100
+ options: v(h({}, e), { importClient: "code" }),
101
101
  file: "main.js",
102
102
  code: "",
103
103
  record: t,
104
104
  inject: !0
105
105
  });
106
106
  }
107
- function S(n) {
107
+ function q(n) {
108
108
  return d(this, arguments, function* ({
109
109
  options: e,
110
110
  record: t,
111
111
  assets: s
112
112
  }) {
113
- const a = Object.keys(s).filter((r) => /\.html$/.test(r));
114
- if (a.length) {
115
- const r = yield b(e, t);
116
- a.forEach((i) => {
113
+ const r = Object.keys(s).filter((a) => /\.html$/.test(a));
114
+ if (r.length) {
115
+ const a = yield k(e, t);
116
+ r.forEach((i) => {
117
117
  var o, f;
118
118
  const u = (f = (o = s[i]) == null ? void 0 : o.source) == null ? void 0 : f.call(o);
119
119
  if (typeof u == "string") {
120
- const h = u.replace(
120
+ const c = u.replace(
121
121
  "<head>",
122
- '<head><script type="module">\n'.concat(r, "\n<\/script>")
122
+ '<head><script type="module">\n'.concat(a, "\n<\/script>")
123
123
  );
124
124
  s[i] = {
125
- source: () => h,
126
- size: () => h.length
125
+ source: () => c,
126
+ size: () => c.length
127
127
  };
128
128
  }
129
129
  });
130
130
  }
131
131
  });
132
132
  }
133
- class B {
133
+ class K {
134
134
  constructor(t) {
135
135
  this.options = t;
136
136
  }
137
137
  apply(t) {
138
138
  return d(this, null, function* () {
139
- var n, a, r, i, u, o, f, h, A, P;
140
- if (g = !0, this.options.close || !z(
139
+ var n, r, a, i, u, o, f, c, x, A, P, j, C;
140
+ if (b = !0, this.options.close || !F(
141
141
  this.options.dev,
142
142
  ((n = t == null ? void 0 : t.options) == null ? void 0 : n.mode) === "development" || process.env.NODE_ENV === "development"
143
143
  ))
@@ -146,23 +146,24 @@ class B {
146
146
  port: 0,
147
147
  entry: "",
148
148
  output: this.options.output,
149
- inputs: Q(
150
- (a = t == null ? void 0 : t.options) == null ? void 0 : a.entry,
151
- (r = t == null ? void 0 : t.options) == null ? void 0 : r.context
149
+ inputs: U(
150
+ (r = t == null ? void 0 : t.options) == null ? void 0 : r.entry,
151
+ (a = t == null ? void 0 : t.options) == null ? void 0 : a.context
152
152
  ),
153
- envDir: (i = t == null ? void 0 : t.options) == null ? void 0 : i.context
153
+ envDir: (i = t == null ? void 0 : t.options) == null ? void 0 : i.context,
154
+ root: (u = t == null ? void 0 : t.options) == null ? void 0 : u.context
154
155
  };
155
- if (((o = (u = t == null ? void 0 : t.options) == null ? void 0 : u.cache) == null ? void 0 : o.type) === "filesystem" && (this.options.cache ? b(this.options, s) : t.options.cache.version = "code-inspector-".concat(Date.now())), ((A = (h = (f = t == null ? void 0 : t.options) == null ? void 0 : f.experiments) == null ? void 0 : h.cache) == null ? void 0 : A.type) === "persistent" && (this.options.cache ? b(this.options, s) : t.options.experiments.cache.version = "code-inspector-".concat(Date.now())), R(j(c({}, this.options), { record: s }), t), (P = t == null ? void 0 : t.hooks) != null && P.emit) {
156
- const D = this.options;
156
+ if (((f = (o = t == null ? void 0 : t.options) == null ? void 0 : o.cache) == null ? void 0 : f.type) === "filesystem" && (this.options.cache ? k(this.options, s) : t.options.cache.version = "code-inspector-".concat(Date.now())), ((A = (x = (c = t == null ? void 0 : t.options) == null ? void 0 : c.experiments) == null ? void 0 : x.cache) == null ? void 0 : A.type) === "persistent" && (this.options.cache ? k(this.options, s) : t.options.experiments.cache.version = "code-inspector-".concat(Date.now())), V(v(h({}, this.options), { record: s }), t), (P = t == null ? void 0 : t.hooks) != null && P.emit && !((C = (j = this.options.skipSnippets) == null ? void 0 : j.includes) != null && C.call(j, "htmlScript"))) {
157
+ const E = this.options;
157
158
  t.hooks.emit.tapAsync(
158
159
  "WebpackCodeInspectorPlugin",
159
- (v, W) => d(this, null, function* () {
160
+ (g, T) => d(this, null, function* () {
160
161
  let l = {};
161
- v.getAssets ? l = yield v.getAssets() : l = v.assets, yield S({
162
- options: D,
162
+ g.getAssets ? l = yield g.getAssets() : l = g.assets, yield q({
163
+ options: E,
163
164
  record: s,
164
165
  assets: l
165
- }), W();
166
+ }), T();
166
167
  })
167
168
  );
168
169
  }
@@ -170,5 +171,5 @@ class B {
170
171
  }
171
172
  }
172
173
  export {
173
- B as default
174
+ K as default
174
175
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(n,s){typeof exports=="object"&&typeof module!="undefined"?module.exports=s(require("@code-inspector/core"),require("path")):typeof define=="function"&&define.amd?define(["@code-inspector/core","path"],s):(n=typeof globalThis!="undefined"?globalThis:n||self,n.WebpackCodeInspectorPlugin=s(n.core,n.path))})(this,function(n,s){"use strict";var R=Object.defineProperty,U=Object.defineProperties;var q=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var z=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable;var $=(n,s,i)=>s in n?R(n,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[s]=i,j=(n,s)=>{for(var i in s||(s={}))z.call(s,i)&&$(n,i,s[i]);if(W)for(var i of W(s))N.call(s,i)&&$(n,i,s[i]);return n},C=(n,s)=>U(n,q(s));var P=(n,s,i)=>new Promise((k,l)=>{var x=a=>{try{h(i.next(a))}catch(p){l(p)}},c=a=>{try{h(i.throw(a))}catch(p){l(p)}},h=a=>a.done?k(a.value):Promise.resolve(a.value).then(x,c);h((i=i.apply(n,s)).next())});var i=typeof document!="undefined"?document.currentScript:null;function k(t,e){return P(this,null,function*(){if(!t||!e)return[];const o=typeof t=="function"?yield t():t;let r=[];if(typeof o=="object"&&!Array.isArray(o))for(const f in o){const u=o[f],d=u.import||u;l(r,d,e)}else l(r,o,e);return r.filter(f=>!!f)})}function l(t,e,o){typeof e=="string"?t.push(x(e,o)):Array.isArray(e)&&t.push(...e.map(r=>x(r,o)))}function x(t,e){return s.isAbsolute(t)?n.normalizePath(t):t.startsWith(".")?s.resolve(e,n.normalizePath(t)):""}let c="";typeof __dirname!="undefined"?c=__dirname:c=s.dirname(n.fileURLToPath(typeof document=="undefined"&&typeof location=="undefined"?require("url").pathToFileURL(__filename).href:typeof document=="undefined"?location.href:i&&i.src||new URL("index.umd.js",document.baseURI).href));let h=!0;const a=(t,e)=>{var u,d;if(!h)return;h=!1;const o=(e==null?void 0:e.compiler)||e,r=(u=o==null?void 0:o.options)==null?void 0:u.module;((r==null?void 0:r.rules)||(r==null?void 0:r.loaders)||[]).push(j({test:(d=t.match)!=null?d:/\.html$/,resourceQuery:/vue/,use:[{loader:s.resolve(c,"./loader.js"),options:t}]},t.enforcePre===!1?{}:{enforce:"pre"}),j({test:/\.(vue|jsx|tsx|js|ts|mjs|mts|svelte)$/,use:[{loader:s.resolve(c,"./loader.js"),options:t}]},t.enforcePre===!1?{}:{enforce:"pre"}),C(j({},t.injectTo?{resource:t.injectTo}:{test:/\.(jsx|tsx|js|ts|mjs|mts)$/,exclude:/node_modules/}),{use:[{loader:s.resolve(c,"./inject-loader.js"),options:t}],enforce:n.isNextjsProject()?"pre":"post"}))};function p(t,e){return n.getCodeWithWebComponent({options:C(j({},t),{importClient:"code"}),file:"main.js",code:"",record:e,inject:!0})}function D(r){return P(this,arguments,function*({options:t,record:e,assets:o}){const f=Object.keys(o).filter(u=>/\.html$/.test(u));if(f.length){const u=yield p(t,e);f.forEach(d=>{var y,b;const v=(b=(y=o[d])==null?void 0:y.source)==null?void 0:b.call(y);if(typeof v=="string"){const g=v.replace("<head>",'<head><script type="module">\n'.concat(u,"\n<\/script>"));o[d]={source:()=>g,size:()=>g.length}}})}})}class L{constructor(e){this.options=e}apply(e){return P(this,null,function*(){var r,f,u,d,v,y,b,g,w,T;if(h=!0,this.options.close||!n.isDev(this.options.dev,((r=e==null?void 0:e.options)==null?void 0:r.mode)==="development"||process.env.NODE_ENV==="development"))return;const o={port:0,entry:"",output:this.options.output,inputs:k((f=e==null?void 0:e.options)==null?void 0:f.entry,(u=e==null?void 0:e.options)==null?void 0:u.context),envDir:(d=e==null?void 0:e.options)==null?void 0:d.context};if(((y=(v=e==null?void 0:e.options)==null?void 0:v.cache)==null?void 0:y.type)==="filesystem"&&(this.options.cache?p(this.options,o):e.options.cache.version="code-inspector-".concat(Date.now())),((w=(g=(b=e==null?void 0:e.options)==null?void 0:b.experiments)==null?void 0:g.cache)==null?void 0:w.type)==="persistent"&&(this.options.cache?p(this.options,o):e.options.experiments.cache.version="code-inspector-".concat(Date.now())),a(C(j({},this.options),{record:o}),e),(T=e==null?void 0:e.hooks)!=null&&T.emit){const E=this.options;e.hooks.emit.tapAsync("WebpackCodeInspectorPlugin",(A,I)=>P(this,null,function*(){let _={};A.getAssets?_=yield A.getAssets():_=A.assets,yield D({options:E,record:o,assets:_}),I()}))}})}}return L});
1
+ (function(n,s){typeof exports=="object"&&typeof module!="undefined"?module.exports=s(require("@code-inspector/core"),require("path")):typeof define=="function"&&define.amd?define(["@code-inspector/core","path"],s):(n=typeof globalThis!="undefined"?globalThis:n||self,n.WebpackCodeInspectorPlugin=s(n.core,n.path))})(this,function(n,s){"use strict";var q=Object.defineProperty,z=Object.defineProperties;var N=Object.getOwnPropertyDescriptors;var L=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var S=(n,s,i)=>s in n?q(n,s,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[s]=i,j=(n,s)=>{for(var i in s||(s={}))O.call(s,i)&&S(n,i,s[i]);if(L)for(var i of L(s))F.call(s,i)&&S(n,i,s[i]);return n},C=(n,s)=>z(n,N(s));var x=(n,s,i)=>new Promise((A,l)=>{var P=a=>{try{h(i.next(a))}catch(p){l(p)}},c=a=>{try{h(i.throw(a))}catch(p){l(p)}},h=a=>a.done?A(a.value):Promise.resolve(a.value).then(P,c);h((i=i.apply(n,s)).next())});var i=typeof document!="undefined"?document.currentScript:null;function A(t,e){return x(this,null,function*(){if(!t||!e)return[];const o=typeof t=="function"?yield t():t;let u=[];if(typeof o=="object"&&!Array.isArray(o))for(const f in o){const r=o[f],d=r.import||r;l(u,d,e)}else l(u,o,e);return u.filter(f=>!!f)})}function l(t,e,o){typeof e=="string"?t.push(P(e,o)):Array.isArray(e)&&t.push(...e.map(u=>P(u,o)))}function P(t,e){return s.isAbsolute(t)?n.normalizePath(t):t.startsWith(".")?s.resolve(e,n.normalizePath(t)):""}let c="";typeof __dirname!="undefined"?c=__dirname:c=s.dirname(n.fileURLToPath(typeof document=="undefined"&&typeof location=="undefined"?require("url").pathToFileURL(__filename).href:typeof document=="undefined"?location.href:i&&i.src||new URL("index.umd.js",document.baseURI).href));let h=!0;const a=(t,e)=>{var r,d;if(!h)return;h=!1;const o=(e==null?void 0:e.compiler)||e,u=(r=o==null?void 0:o.options)==null?void 0:r.module;((u==null?void 0:u.rules)||(u==null?void 0:u.loaders)||[]).push(j({test:(d=t.match)!=null?d:/\.html$/,resourceQuery:/vue/,use:[{loader:s.resolve(c,"./loader.js"),options:t}]},t.enforcePre===!1?{}:{enforce:"pre"}),j({test:/\.(vue|jsx|tsx|js|ts|mjs|mts|svelte)$/,use:[{loader:s.resolve(c,"./loader.js"),options:t}]},t.enforcePre===!1?{}:{enforce:"pre"}),C(j({},t.injectTo?{resource:t.injectTo}:{test:/\.(jsx|tsx|js|ts|mjs|mts)$/,exclude:/node_modules/}),{use:[{loader:s.resolve(c,"./inject-loader.js"),options:t}],enforce:n.isNextjsProject()?"pre":"post"}))};function p(t,e){return n.getCodeWithWebComponent({options:C(j({},t),{importClient:"code"}),file:"main.js",code:"",record:e,inject:!0})}function E(u){return x(this,arguments,function*({options:t,record:e,assets:o}){const f=Object.keys(o).filter(r=>/\.html$/.test(r));if(f.length){const r=yield p(t,e);f.forEach(d=>{var y,b;const v=(b=(y=o[d])==null?void 0:y.source)==null?void 0:b.call(y);if(typeof v=="string"){const g=v.replace("<head>",'<head><script type="module">\n'.concat(r,"\n<\/script>"));o[d]={source:()=>g,size:()=>g.length}}})}})}class I{constructor(e){this.options=e}apply(e){return x(this,null,function*(){var u,f,r,d,v,y,b,g,T,W,$,k,D;if(h=!0,this.options.close||!n.isDev(this.options.dev,((u=e==null?void 0:e.options)==null?void 0:u.mode)==="development"||process.env.NODE_ENV==="development"))return;const o={port:0,entry:"",output:this.options.output,inputs:A((f=e==null?void 0:e.options)==null?void 0:f.entry,(r=e==null?void 0:e.options)==null?void 0:r.context),envDir:(d=e==null?void 0:e.options)==null?void 0:d.context,root:(v=e==null?void 0:e.options)==null?void 0:v.context};if(((b=(y=e==null?void 0:e.options)==null?void 0:y.cache)==null?void 0:b.type)==="filesystem"&&(this.options.cache?p(this.options,o):e.options.cache.version="code-inspector-".concat(Date.now())),((W=(T=(g=e==null?void 0:e.options)==null?void 0:g.experiments)==null?void 0:T.cache)==null?void 0:W.type)==="persistent"&&(this.options.cache?p(this.options,o):e.options.experiments.cache.version="code-inspector-".concat(Date.now())),a(C(j({},this.options),{record:o}),e),($=e==null?void 0:e.hooks)!=null&&$.emit&&!((D=(k=this.options.skipSnippets)==null?void 0:k.includes)!=null&&D.call(k,"htmlScript"))){const R=this.options;e.hooks.emit.tapAsync("WebpackCodeInspectorPlugin",(_,U)=>x(this,null,function*(){let w={};_.getAssets?w=yield _.getAssets():w=_.assets,yield E({options:R,record:o,assets:w}),U()}))}})}}return I});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-inspector/webpack",
3
- "version": "1.2.1",
3
+ "version": "1.2.3-beta.1",
4
4
  "main": "./dist/index.umd.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./types/index.d.ts",
@@ -40,7 +40,7 @@
40
40
  "url": "https://github.com/zh-lx/code-inspector/issues"
41
41
  },
42
42
  "dependencies": {
43
- "@code-inspector/core": "1.2.1"
43
+ "@code-inspector/core": "1.2.3-beta.1"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/node": "^20.3.3",