@code-inspector/vite 1.2.2 → 1.2.3-beta.2

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 j=Object.defineProperty,w=Object.defineProperties;var P=Object.getOwnPropertyDescriptors;var h=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var y=(e,n,i)=>n in e?j(e,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[n]=i,f=(e,n)=>{for(var i in n||(n={}))W.call(n,i)&&y(e,i,n[i]);if(h)for(var i of h(n))q.call(n,i)&&y(e,i,n[i]);return e},m=(e,n)=>w(e,P(n));var v=(e,n,i)=>new Promise((t,a)=>{var g=c=>{try{u(i.next(c))}catch(r){a(r)}},p=c=>{try{u(i.throw(c))}catch(r){a(r)}},u=c=>c.done?t(c.value):Promise.resolve(c.value).then(g,p);u((i=i.apply(e,n)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("@code-inspector/core"),d=require("chalk"),k="@code-inspector/vite",C=[{name:"vite:react-babel",package:"@vitejs/plugin-react"},{name:"vite:react-swc",package:"@vitejs/plugin-react-swc"},{name:"vite:react-oxc:config",package:"@vitejs/plugin-react-oxc"},{name:"solid",package:"vite-plugin-solid"},{name:"vite-plugin-qwik",package:"qwikVite"},{name:"vite-plugin-qwik-city",package:"qwikCity"},{name:"vite-plugin-qwik-react",package:"qwikReact"},{name:"vite:preact-jsx",package:"@preact/preset-vite"},{name:"vite-plugin-svelte",package:"@sveltejs/vite-plugin-svelte"}],I=["isJsx","isTsx","lang.jsx","lang.tsx"];function b(e=[]){const n=e.findIndex(i=>i.name===k);C.forEach(i=>{const t=e.findIndex(a=>a.name===i.name);if(t!==-1&&t<n){const a=[d.yellow("[WARNING]"),"You need to put",d.green("code-inspector-plugin"),"before",d.green(i.package),"in the vite config file."];console.log(a.join(" "))}})}function T(e){const n={port:0,entry:"",output:e.output,envDir:""};return m(f({name:k},e.enforcePre===!1?{}:{enforce:"pre"}),{apply(t,{command:a}){return!e.close&&l.isDev(e.dev,a==="serve")},configResolved(t){n.envDir=t.envDir||t.root},transform(t,a){return v(this,null,function*(){if(l.isExcludedFile(a,e))return t;t=yield l.getCodeWithWebComponent({options:e,file:a,code:t,record:n});const{escapeTags:g=[],mappings:p}=e,[u,c]=a.split("?",2);let r=l.normalizePath(u);r=l.getMappingFilePath(r,p);const s=new URLSearchParams(c);if(e.match&&!e.match.test(r))return t;let o="";return l.isJsTypeFile(r)||r.endsWith(".vue")&&(I.some(x=>s.get(x)!==null)||s.get("lang")==="tsx"||s.get("lang")==="jsx")?o="jsx":r.endsWith(".html")&&s.get("type")==="template"&&s.has("vue")||r.endsWith(".vue")&&s.get("type")!=="style"&&s.get("raw")===null?o="vue":r.endsWith(".svelte")&&(o="svelte"),o?l.transformCode({content:t,filePath:r,fileType:o,escapeTags:g,pathType:e.pathType}):t})},transformIndexHtml(t){return v(this,null,function*(){const a=yield l.getCodeWithWebComponent({options:m(f({},e),{importClient:"code"}),file:"main.js",code:"",record:n,inject:!0});return t.replace("<head>",'<head><script type="module">\n'.concat(a,"\n<\/script>"))})},configureServer(t){const a=t.config.logger.info;t.config.logger.info=function(g,p){a.call(this,g,p),b(t.config.plugins),t.config.logger.info=a}}})}exports.ViteCodeInspectorPlugin=T;
1
+ "use strict";var j=Object.defineProperty,w=Object.defineProperties;var P=Object.getOwnPropertyDescriptors;var h=Object.getOwnPropertySymbols;var W=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var k=(e,n,i)=>n in e?j(e,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[n]=i,f=(e,n)=>{for(var i in n||(n={}))W.call(n,i)&&k(e,i,n[i]);if(h)for(var i of h(n))q.call(n,i)&&k(e,i,n[i]);return e},m=(e,n)=>w(e,P(n));var v=(e,n,i)=>new Promise((t,a)=>{var c=l=>{try{u(i.next(l))}catch(r){a(r)}},s=l=>{try{u(i.throw(l))}catch(r){a(r)}},u=l=>l.done?t(l.value):Promise.resolve(l.value).then(c,s);u((i=i.apply(e,n)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@code-inspector/core"),d=require("chalk"),y="@code-inspector/vite",C=[{name:"vite:react-babel",package:"@vitejs/plugin-react"},{name:"vite:react-swc",package:"@vitejs/plugin-react-swc"},{name:"vite:react-oxc:config",package:"@vitejs/plugin-react-oxc"},{name:"solid",package:"vite-plugin-solid"},{name:"vite-plugin-qwik",package:"qwikVite"},{name:"vite-plugin-qwik-city",package:"qwikCity"},{name:"vite-plugin-qwik-react",package:"qwikReact"},{name:"vite:preact-jsx",package:"@preact/preset-vite"},{name:"vite-plugin-svelte",package:"@sveltejs/vite-plugin-svelte"}],I=["isJsx","isTsx","lang.jsx","lang.tsx"];function b(e=[]){const n=e.findIndex(i=>i.name===y);C.forEach(i=>{const t=e.findIndex(a=>a.name===i.name);if(t!==-1&&t<n){const a=[d.yellow("[WARNING]"),"You need to put",d.green("code-inspector-plugin"),"before",d.green(i.package),"in the vite config file."];console.log(a.join(" "))}})}function T(e){const n={port:0,entry:"",output:e.output,envDir:""};return m(f({name:y},e.enforcePre===!1?{}:{enforce:"pre"}),{apply(t,{command:a}){return!e.close&&o.isDev(e.dev,a==="serve")},configResolved(t){n.envDir=t.envDir||t.root,n.root=t.root},transform(t,a){return v(this,null,function*(){if(o.isExcludedFile(a,e))return t;t=yield o.getCodeWithWebComponent({options:e,file:a,code:t,record:n});const{escapeTags:c=[],mappings:s}=e,[u,l]=a.split("?",2);let r=o.normalizePath(u);r=o.getMappingFilePath(r,s);const g=new URLSearchParams(l);if(e.match&&!e.match.test(r))return t;let p="";return o.isJsTypeFile(r)||r.endsWith(".vue")&&(I.some(x=>g.get(x)!==null)||g.get("lang")==="tsx"||g.get("lang")==="jsx")?p="jsx":r.endsWith(".html")&&g.get("type")==="template"&&g.has("vue")||r.endsWith(".vue")&&g.get("type")!=="style"&&g.get("raw")===null?p="vue":r.endsWith(".svelte")&&(p="svelte"),p?o.transformCode({content:t,filePath:r,fileType:p,escapeTags:c,pathType:e.pathType}):t})},transformIndexHtml(t){return v(this,null,function*(){var c,s;if((s=(c=e.skipSnippets)==null?void 0:c.includes)!=null&&s.call(c,"htmlScript"))return t;const a=yield o.getCodeWithWebComponent({options:m(f({},e),{importClient:"code"}),file:"main.js",code:"",record:n,inject:!0});return t.replace("<head>",'<head><script type="module">\n'.concat(a,"\n<\/script>"))})},configureServer(t){const a=t.config.logger.info;t.config.logger.info=function(c,s){a.call(this,c,s),b(t.config.plugins),t.config.logger.info=a}}})}exports.ViteCodeInspectorPlugin=T;
package/dist/index.mjs CHANGED
@@ -11,24 +11,24 @@ var h = (e, n, i) => n in e ? w(e, n, { enumerable: !0, configurable: !0, writab
11
11
  return e;
12
12
  }, f = (e, n) => j(e, P(n));
13
13
  var m = (e, n, i) => new Promise((t, a) => {
14
- var g = (c) => {
14
+ var c = (l) => {
15
15
  try {
16
- p(i.next(c));
16
+ p(i.next(l));
17
17
  } catch (r) {
18
18
  a(r);
19
19
  }
20
- }, o = (c) => {
20
+ }, s = (l) => {
21
21
  try {
22
- p(i.throw(c));
22
+ p(i.throw(l));
23
23
  } catch (r) {
24
24
  a(r);
25
25
  }
26
- }, p = (c) => c.done ? t(c.value) : Promise.resolve(c.value).then(g, o);
26
+ }, p = (l) => l.done ? t(l.value) : Promise.resolve(l.value).then(c, s);
27
27
  p((i = i.apply(e, n)).next());
28
28
  });
29
- import { isDev as I, isExcludedFile as C, getCodeWithWebComponent as x, normalizePath as T, getMappingFilePath as b, isJsTypeFile as D, transformCode as R } from "@code-inspector/core";
29
+ import { isDev as I, isExcludedFile as C, getCodeWithWebComponent as k, normalizePath as T, getMappingFilePath as b, isJsTypeFile as D, transformCode as R } from "@code-inspector/core";
30
30
  import v from "chalk";
31
- const k = "@code-inspector/vite", F = [
31
+ const x = "@code-inspector/vite", S = [
32
32
  {
33
33
  name: "vite:react-babel",
34
34
  package: "@vitejs/plugin-react"
@@ -65,10 +65,10 @@ const k = "@code-inspector/vite", F = [
65
65
  name: "vite-plugin-svelte",
66
66
  package: "@sveltejs/vite-plugin-svelte"
67
67
  }
68
- ], L = ["isJsx", "isTsx", "lang.jsx", "lang.tsx"];
69
- function N(e = []) {
70
- const n = e.findIndex((i) => i.name === k);
71
- F.forEach((i) => {
68
+ ], F = ["isJsx", "isTsx", "lang.jsx", "lang.tsx"];
69
+ function L(e = []) {
70
+ const n = e.findIndex((i) => i.name === x);
71
+ S.forEach((i) => {
72
72
  const t = e.findIndex((a) => a.name === i.name);
73
73
  if (t !== -1 && t < n) {
74
74
  const a = [
@@ -83,7 +83,7 @@ function N(e = []) {
83
83
  }
84
84
  });
85
85
  }
86
- function O(e) {
86
+ function J(e) {
87
87
  const n = {
88
88
  port: 0,
89
89
  entry: "",
@@ -91,36 +91,36 @@ function O(e) {
91
91
  envDir: ""
92
92
  };
93
93
  return f(u({
94
- name: k
94
+ name: x
95
95
  }, e.enforcePre === !1 ? {} : { enforce: "pre" }), {
96
96
  apply(t, { command: a }) {
97
97
  return !e.close && I(e.dev, a === "serve");
98
98
  },
99
99
  configResolved(t) {
100
- n.envDir = t.envDir || t.root;
100
+ n.envDir = t.envDir || t.root, n.root = t.root;
101
101
  },
102
102
  transform(t, a) {
103
103
  return m(this, null, function* () {
104
104
  if (C(a, e))
105
105
  return t;
106
- t = yield x({
106
+ t = yield k({
107
107
  options: e,
108
108
  file: a,
109
109
  code: t,
110
110
  record: n
111
111
  });
112
- const { escapeTags: g = [], mappings: o } = e, [p, c] = a.split("?", 2);
112
+ const { escapeTags: c = [], mappings: s } = e, [p, l] = a.split("?", 2);
113
113
  let r = T(p);
114
- r = b(r, o);
115
- const l = new URLSearchParams(c);
114
+ r = b(r, s);
115
+ const o = new URLSearchParams(l);
116
116
  if (e.match && !e.match.test(r))
117
117
  return t;
118
- let s = "";
119
- return D(r) || r.endsWith(".vue") && (L.some((y) => l.get(y) !== null) || l.get("lang") === "tsx" || l.get("lang") === "jsx") ? s = "jsx" : r.endsWith(".html") && l.get("type") === "template" && l.has("vue") || r.endsWith(".vue") && l.get("type") !== "style" && l.get("raw") === null ? s = "vue" : r.endsWith(".svelte") && (s = "svelte"), s ? R({
118
+ let g = "";
119
+ return D(r) || r.endsWith(".vue") && (F.some((y) => o.get(y) !== null) || o.get("lang") === "tsx" || o.get("lang") === "jsx") ? g = "jsx" : r.endsWith(".html") && o.get("type") === "template" && o.has("vue") || r.endsWith(".vue") && o.get("type") !== "style" && o.get("raw") === null ? g = "vue" : r.endsWith(".svelte") && (g = "svelte"), g ? R({
120
120
  content: t,
121
121
  filePath: r,
122
- fileType: s,
123
- escapeTags: g,
122
+ fileType: g,
123
+ escapeTags: c,
124
124
  pathType: e.pathType
125
125
  }) : t;
126
126
  });
@@ -128,7 +128,10 @@ function O(e) {
128
128
  // 追加到 html 中,适配 MPA 项目
129
129
  transformIndexHtml(t) {
130
130
  return m(this, null, function* () {
131
- const a = yield x({
131
+ var c, s;
132
+ if ((s = (c = e.skipSnippets) == null ? void 0 : c.includes) != null && s.call(c, "htmlScript"))
133
+ return t;
134
+ const a = yield k({
132
135
  options: f(u({}, e), { importClient: "code" }),
133
136
  file: "main.js",
134
137
  code: "",
@@ -143,12 +146,12 @@ function O(e) {
143
146
  },
144
147
  configureServer(t) {
145
148
  const a = t.config.logger.info;
146
- t.config.logger.info = function(g, o) {
147
- a.call(this, g, o), N(t.config.plugins), t.config.logger.info = a;
149
+ t.config.logger.info = function(c, s) {
150
+ a.call(this, c, s), L(t.config.plugins), t.config.logger.info = a;
148
151
  };
149
152
  }
150
153
  });
151
154
  }
152
155
  export {
153
- O as ViteCodeInspectorPlugin
156
+ J as ViteCodeInspectorPlugin
154
157
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-inspector/vite",
3
- "version": "1.2.2",
3
+ "version": "1.2.3-beta.2",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "typings": "./types/index.d.ts",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "chalk": "4.1.1",
42
- "@code-inspector/core": "1.2.2"
42
+ "@code-inspector/core": "1.2.3-beta.2"
43
43
  },
44
44
  "devDependencies": {
45
45
  "@types/node": "^16.0.1",