UNPKG

@markshawn/code-inspector-mako

Version:

Enhanced code-inspector mako plugin with mode switching: Click DOM to open IDE or copy path. Press Shift+Alt+C to toggle modes.

2 lines (1 loc) 1.07 kB
"use strict";var i=(e,l,c)=>new Promise((t,a)=>{var p=r=>{try{s(c.next(r))}catch(n){a(n)}},u=r=>{try{s(c.throw(r))}catch(n){a(n)}},s=r=>r.done?t(r.value):Promise.resolve(r.value).then(p,u);s((c=c.apply(e,l)).next())});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("@markshawn/code-inspector-core"),f=require("path");function m(e){const l={port:0,entry:"",output:e.output};return e.close||!o.isDev(e.dev,process.env.NODE_ENV==="development")?{name:"@code-inspector/mako"}:{name:"@code-inspector/mako",enforce:e.enforcePre===!1?"post":"pre",transform:(c,t)=>i(this,null,function*(){if(o.isExcludedFile(t,e)||t.includes("/.umi/"))return;const{escapeTags:a=[],mappings:p,match:u}=e||{};if(u&&!u.test(t))return;const s=yield o.getCodeWithWebComponent({options:e,file:t,code:c,record:l});if(o.isJsTypeFile(t)){const r=f.extname(t).slice(1);let n=o.normalizePath(t);return n=o.getMappingFilePath(n,p),{content:o.transformCode({content:s,filePath:n,fileType:"jsx",escapeTags:a,pathType:e.pathType}),type:r}}})}}exports.MakoCodeInspectorPlugin=m;