ms-vite-plugin 1.5.23 → 1.5.25

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.
@@ -1 +1 @@
1
- "use strict";var F=exports&&exports.__createBinding||(Object.create?(function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}):(function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]})),O=exports&&exports.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),$=exports&&exports.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var r=[];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[r.length]=i);return r},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var r=t(e),i=0;i<r.length;i++)r[i]!=="default"&&F(n,e,r[i]);return O(n,e),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.createDebugInstrumentPlugin=N;const h=$(require("acorn")),E=require("magic-string"),g="__kjs_bp_hit",_="__kjs_bp",f="__kjs_enter",l="__kjs_leave";function N(){let t=process.cwd();return{name:"kuaijs-debug-instrument",enforce:"post",configResolved(e){t=e.root||t},transform(e,n){const r=P(n,t);if(!r)return null;const i=B(e,r);if(i.length===0)return null;const s=new E(e);for(const o of i)o.start===o.end?s.appendLeft(o.start,o.text):s.overwrite(o.start,o.end,o.text);return{code:s.toString(),map:s.generateMap({hires:!0})}}}}function P(t,e){if(!t||t.startsWith("\0")||t.includes("node_modules"))return null;const n=t.split("?")[0].split("#")[0];return!/\.[cm]?[jt]sx?$/.test(n)||!n.startsWith(e)?null:n.slice(e.length).replace(/^[\\/]+/,"").replace(/\\/g,"/")}function D(t){try{return h.parse(t,{allowHashBang:!0,ecmaVersion:"latest",sourceType:"script"})}catch{return h.parse(t,{allowHashBang:!0,ecmaVersion:"latest",sourceType:"module"})}}function B(t,e){const n=D(t),r=[],i=W(t),s=JSON.stringify(e);return b(n,[],{onStatement:(a,u)=>{if(typeof a.start!="number")return;const y=U(i,a.start),w=`()=>({${u.join(",")}})`,j="(s)=>eval(s)",m=a.type==="DebuggerStatement",d=`${_}(${s},${y},${w},${j}${m?",true":""})`;r.push({start:a.start,end:a.start,text:m?`${d};`:`${g}(${s},${y})&&${d};`})},onFunctionBody:a=>x(r,a),onExpressionBody:a=>A(r,a,t)}),r}function x(t,e){if(typeof e.start!="number"||typeof e.end!="number")return;let n=e.start+1;if(Array.isArray(e.body)){let r=0;for(;r<e.body.length&&v(e.body[r]);){const i=e.body[r];typeof i.end=="number"&&(n=i.end),r+=1}}t.push({start:n,end:n,text:`${f}();try{`}),t.push({start:e.end-1,end:e.end-1,text:`}finally{${l}();}`})}function A(t,e,n){const r=e.body;if(!r||typeof r.start!="number"||typeof r.end!="number")return;const i=n.slice(r.start,r.end),s=e.async?"(async()=>":"(()=>";t.push({start:r.start,end:r.end,text:`${s}{${f}();try{return ${i};}finally{${l}();}})()`})}function b(t,e,n,r=!1){if(!(!t||typeof t!="object")){if(S(t)){const i=new Map;for(const s of t.params??[])c(s,i);t.body?.type==="BlockStatement"?(C(t.body,i),n.onFunctionBody(t.body)):t.body&&n.onExpressionBody(t),e.push(i),p(t,e,n,r),e.pop();return}if(H(t)){e.push(new Map),p(t,e,n,r),e.pop();return}p(t,e,n,r)}}function p(t,e,n,r){for(const i of Object.keys(t)){if(i==="start"||i==="end"||i==="type")continue;const s=t[i],o=Array.isArray(s)?s:[s];for(const a of o){if(!a||typeof a!="object")continue;const u=k(t)&&M.has(i);!r&&!u&&V(a)&&!v(a)&&!R(a)&&n.onStatement(a,I(e)),b(a,e,n,r||u),T(a,e)}}}function I(t){const e=new Set;for(const n of t)for(const r of n.keys())e.add(r);return[...e].sort()}function T(t,e){const n=e[e.length-1];if(!n)return;if(t?.type==="VariableDeclaration"&&t.kind!=="var"){for(const i of t.declarations??[])c(i.id,n);return}const r=t?.declaration;r?.type==="ClassDeclaration"&&r.id?.name&&n.set(r.id.name,!0)}function c(t,e){if(t)switch(t.type){case"Identifier":e.set(t.name,!0);return;case"ObjectPattern":for(const n of t.properties??[])c(n.value??n.argument??n.key,e);return;case"ArrayPattern":for(const n of t.elements??[])c(n,e);return;case"AssignmentPattern":c(t.left,e);return;case"RestElement":c(t.argument,e);return;default:return}}function C(t,e){const n=[t];for(;n.length>0;){const r=n.pop();if(!(!r||typeof r!="object")){if(r.type==="VariableDeclaration"&&r.kind==="var")for(const i of r.declarations??[])c(i.id,e);if(r.type==="FunctionDeclaration"&&r.id?.name&&e.set(r.id.name,!0),!(S(r)&&r!==t))for(const i of Object.keys(r)){if(i==="start"||i==="end"||i==="type")continue;const s=r[i],o=Array.isArray(s)?s:[s];for(const a of o)a&&typeof a=="object"&&n.push(a)}}}}function S(t){return t.type==="FunctionDeclaration"||t.type==="FunctionExpression"||t.type==="ArrowFunctionExpression"}const M=new Set(["init","left","right","test","update"]);function k(t){return t.type==="ForStatement"||t.type==="ForInStatement"||t.type==="ForOfStatement"}function H(t){return t.type==="BlockStatement"||t.type==="Program"||t.type==="SwitchStatement"||t.type==="ForStatement"||t.type==="ForInStatement"||t.type==="ForOfStatement"}function V(t){return t.type==="BlockStatement"||t.type==="EmptyStatement"?!1:typeof t.type=="string"&&(t.type.endsWith("Statement")||t.type.endsWith("Declaration"))}function v(t){return t?.type==="ExpressionStatement"&&t.expression?.type==="Literal"&&typeof t.expression.value=="string"}function R(t){const e=t?.expression;if(e?.type!=="CallExpression")return!1;const n=e.callee?.name;return n===g||n===_||n===f||n===l}function W(t){const e=[0];for(let n=0;n<t.length;n+=1)t.charCodeAt(n)===10&&e.push(n+1);return e}function U(t,e){let n=0,r=t.length-1;for(;n<r;){const i=n+r+1>>1;t[i]<=e?n=i:r=i-1}return n+1}
1
+ "use strict";var D=exports&&exports.__createBinding||(Object.create?(function(t,e,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(e,n);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[n]}}),Object.defineProperty(t,r,i)}):(function(t,e,n,r){r===void 0&&(r=n),t[r]=e[n]})),A=exports&&exports.__setModuleDefault||(Object.create?(function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}):function(t,e){t.default=e}),I=exports&&exports.__importStar||(function(){var t=function(e){return t=Object.getOwnPropertyNames||function(n){var r=[];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[r.length]=i);return r},t(e)};return function(e){if(e&&e.__esModule)return e;var n={};if(e!=null)for(var r=t(e),i=0;i<r.length;i++)r[i]!=="default"&&D(n,e,r[i]);return A(n,e),n}})();Object.defineProperty(exports,"__esModule",{value:!0}),exports.createDebugInstrumentPlugin=M;const w=I(require("acorn")),P=require("magic-string"),O="__kjs_bp_hit",v="__kjs_bp",p="__kjs_enter",m="__kjs_leave",d="__kjs_throw",B="<anonymous>";function M(){let t=process.cwd(),e="";const n=new Map;return{name:"kuaijs-debug-instrument",enforce:"post",configResolved(r){t=r.root||t,e=r.build?.outDir??""},writeBundle(){C(t,e,n)},transform(r,i){const o=x(i,t);if(!o)return null;const{edits:c,lines:s}=L(r,o);if(c.length===0)return null;const a=n.get(o)??new Set;for(const u of s)a.add(u);n.set(o,a);const f=new P(r);for(const u of c)u.start===u.end?f.appendLeft(u.start,u.text):f.overwrite(u.start,u.end,u.text);return{code:f.toString(),map:f.generateMap({hires:!0})}}}}function x(t,e){if(!t||t.startsWith("\0")||t.includes("node_modules"))return null;const n=t.split("?")[0].split("#")[0];return!/\.[cm]?[jt]sx?$/.test(n)||!n.startsWith(e)?null:n.slice(e.length).replace(/^[\\/]+/,"").replace(/\\/g,"/")}function H(t){try{return w.parse(t,{allowHashBang:!0,ecmaVersion:"latest",sourceType:"script"})}catch{return w.parse(t,{allowHashBang:!0,ecmaVersion:"latest",sourceType:"module"})}}function L(t,e){const n=H(t),r=[],i=Q(t),o=JSON.stringify(e),c=new Set;return $(n,[],{onStatement:(a,f)=>{if(typeof a.start!="number")return;const u=h(i,a.start),E=`()=>({${f.map(y=>`get ${y}(){return ${y}},set ${y}(v){${y}=v}`).join(",")}})`,S=a.type==="DebuggerStatement",N=`${v}(${o},${u},${E}${S?",true":""})`;c.add(u),r.push({start:a.start,end:a.start,text:S?`${N};`:`${O}(${o},${u})&&${N};`})},onFunctionBody:a=>k(r,a,e,h(i,a.start)),onExpressionBody:a=>J(r,a,t,e,h(i,a.start))}),{edits:r,lines:[...c].sort((a,f)=>a-f)}}const T="kuaijs-debug-lines.json";function C(t,e,n){if(!t||!e)return;const r={};for(const[i,o]of n)r[i]=[...o].sort((c,s)=>c-s);try{const i=require("fs"),o=require("path"),c=o.join(t,e);i.mkdirSync(c,{recursive:!0}),i.writeFileSync(o.join(c,T),JSON.stringify(r),"utf8")}catch{}}function k(t,e,n,r){const i=e?.body;if(!i||typeof i.start!="number"||typeof i.end!="number")return;const o=JSON.stringify(j(e));let c=i.start+1;if(Array.isArray(i.body)){let s=0;for(;s<i.body.length&&F(i.body[s]);){const a=i.body[s];typeof a.end=="number"&&(c=a.end),s+=1}}t.push({start:c,end:c,text:`${p}(${o},${JSON.stringify(n)},${r});try{`}),t.push({start:i.end-1,end:i.end-1,text:`}catch(e){${d}(e);throw e}finally{${m}();}`})}function J(t,e,n,r,i){const o=e.body;if(!o||typeof o.start!="number"||typeof o.end!="number")return;const c=n.slice(o.start,o.end),s=e.async?"(async()=>":"(()=>",a=JSON.stringify(j(e));t.push({start:o.start,end:o.end,text:`${s}{${p}(${a},${JSON.stringify(r)},${i});try{return ${c};}catch(e){${d}(e);throw e}finally{${m}();}})()`})}function j(t){const e=t?.id?.name;if(typeof e=="string"&&e)return e;const n=t?.__kjsNameHint;return typeof n=="string"&&n?n:B}function V(t,e,n){if(!_(n))return"";if(t?.type==="VariableDeclarator"&&e==="init"&&t.id?.type==="Identifier")return t.id.name;if(t?.type==="Property"&&e==="value"||(t?.type==="MethodDefinition"||t?.type==="PropertyDefinition")&&e==="value")return g(t.key);if(t?.type==="AssignmentExpression"&&e==="right"){const r=t.left;if(r?.type==="Identifier")return r.name;if(r?.type==="MemberExpression"&&r.property)return g(r.property)}return""}function g(t){return t?t.type==="Identifier"&&typeof t.name=="string"?t.name:t.type==="Literal"&&typeof t.value=="string"?t.value:"":""}function $(t,e,n,r=!1){if(!(!t||typeof t!="object")){if(_(t)){const i=new Map;for(const o of t.params??[])l(o,i);t.body?.type==="BlockStatement"?(W(t.body,i),n.onFunctionBody(t)):t.body&&n.onExpressionBody(t),e.push(i),b(t,e,n,r),e.pop();return}if(G(t)){e.push(new Map),b(t,e,n,r),e.pop();return}b(t,e,n,r)}}function b(t,e,n,r){for(const i of Object.keys(t)){if(i==="start"||i==="end"||i==="type")continue;const o=t[i],c=Array.isArray(o)?o:[o];for(const s of c){if(!s||typeof s!="object")continue;const a=K(t)&&q.has(i),f=t.type==="LabeledStatement"&&i==="body",u=V(t,i,s);u&&!s.__kjsNameHint&&(s.__kjsNameHint=u),!r&&!a&&!f&&Y(s)&&!F(s)&&!z(s)&&n.onStatement(s,R(e)),$(s,e,n,r||a),U(s,e)}}}function R(t){const e=new Set;for(const n of t)for(const r of n.keys())e.add(r);return[...e].sort()}function U(t,e){const n=e[e.length-1];if(!n)return;if(t?.type==="VariableDeclaration"&&t.kind!=="var"){for(const i of t.declarations??[])l(i.id,n);return}const r=t?.declaration;r?.type==="ClassDeclaration"&&r.id?.name&&n.set(r.id.name,!0)}function l(t,e){if(t)switch(t.type){case"Identifier":e.set(t.name,!0);return;case"ObjectPattern":for(const n of t.properties??[])l(n.value??n.argument??n.key,e);return;case"ArrayPattern":for(const n of t.elements??[])l(n,e);return;case"AssignmentPattern":l(t.left,e);return;case"RestElement":l(t.argument,e);return;default:return}}function W(t,e){const n=[t];for(;n.length>0;){const r=n.pop();if(!(!r||typeof r!="object")){if(r.type==="VariableDeclaration"&&r.kind==="var")for(const i of r.declarations??[])l(i.id,e);if(r.type==="FunctionDeclaration"&&r.id?.name&&e.set(r.id.name,!0),!(_(r)&&r!==t))for(const i of Object.keys(r)){if(i==="start"||i==="end"||i==="type")continue;const o=r[i],c=Array.isArray(o)?o:[o];for(const s of c)s&&typeof s=="object"&&n.push(s)}}}}function _(t){return t.type==="FunctionDeclaration"||t.type==="FunctionExpression"||t.type==="ArrowFunctionExpression"}const q=new Set(["init","left","right","test","update"]);function K(t){return t.type==="ForStatement"||t.type==="ForInStatement"||t.type==="ForOfStatement"}function G(t){return t.type==="BlockStatement"||t.type==="Program"||t.type==="SwitchStatement"||t.type==="ForStatement"||t.type==="ForInStatement"||t.type==="ForOfStatement"}function Y(t){return t.type==="BlockStatement"||t.type==="EmptyStatement"||t.type==="LabeledStatement"?!1:typeof t.type=="string"&&(t.type.endsWith("Statement")||t.type.endsWith("Declaration"))}function F(t){return t?.type==="ExpressionStatement"&&t.expression?.type==="Literal"&&typeof t.expression.value=="string"}function z(t){const e=t?.expression;if(e?.type!=="CallExpression")return!1;const n=e.callee?.name;return n===O||n===v||n===p||n===m||n===d}function Q(t){const e=[0];for(let n=0;n<t.length;n+=1)t.charCodeAt(n)===10&&e.push(n+1);return e}function h(t,e){let n=0,r=t.length-1;for(;n<r;){const i=n+r+1>>1;t[i]<=e?n=i:r=i-1}return n+1}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ms-vite-plugin",
3
- "version": "1.5.23",
3
+ "version": "1.5.25",
4
4
  "type": "commonjs",
5
5
  "license": "MIT",
6
6
  "publishConfig": {