@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.
59 lines (58 loc) • 1.5 kB
JavaScript
var m = (e, p, o) => new Promise((t, a) => {
var l = (r) => {
try {
c(o.next(r));
} catch (n) {
a(n);
}
}, s = (r) => {
try {
c(o.throw(r));
} catch (n) {
a(n);
}
}, c = (r) => r.done ? t(r.value) : Promise.resolve(r.value).then(l, s);
c((o = o.apply(e, p)).next());
});
import { isDev as u, isExcludedFile as f, getCodeWithWebComponent as i, isJsTypeFile as h, normalizePath as d, getMappingFilePath as y, transformCode as g } from "@markshawn/code-inspector-core";
import x from "path";
function k(e) {
const p = {
port: 0,
entry: "",
output: e.output
};
return e.close || !u(e.dev, process.env.NODE_ENV === "development") ? {
name: "@code-inspector/mako"
} : {
name: "@code-inspector/mako",
enforce: e.enforcePre === !1 ? "post" : "pre",
transform: (o, t) => m(this, null, function* () {
if (f(t, e) || t.includes("/.umi/"))
return;
const { escapeTags: a = [], mappings: l, match: s } = e || {};
if (s && !s.test(t))
return;
const c = yield i({
options: e,
file: t,
code: o,
record: p
});
if (h(t)) {
const r = x.extname(t).slice(1);
let n = d(t);
return n = y(n, l), { content: g({
content: c,
filePath: n,
fileType: "jsx",
escapeTags: a,
pathType: e.pathType
}), type: r };
}
})
};
}
export {
k as MakoCodeInspectorPlugin
};