"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const plugin = ({ modules }) => { return { version: 1, compileSFCTemplate(lang, template, options) { if (lang === 'html') { const compiler = modules['@vue/compiler-dom']; return compiler.compile(template, { ...options, comments: true, }); } }, updateSFCTemplate(oldResult, change) { const CompilerDOM = modules['@vue/compiler-dom']; const lengthDiff = change.newText.length - (change.end - change.start); let hitNodes = []; if (tryUpdateNode(oldResult.ast) && hitNodes.length) { hitNodes = hitNodes.sort((a, b) => a.loc.source.length - b.loc.source.length); const hitNode = hitNodes[0]; if (hitNode.type === 4 /* CompilerDOM.NodeTypes.SIMPLE_EXPRESSION */) { return oldResult; } } function tryUpdateNode(node) { if (withinChangeRange(node.loc)) { hitNodes.push(node); } if (tryUpdateNodeLoc(node.loc)) { if (node.type === 0 /* CompilerDOM.NodeTypes.ROOT */) { for (const child of node.children) { if (!tryUpdateNode(child)) { return false; } } } else if (node.type === 1 /* CompilerDOM.NodeTypes.ELEMENT */) { if (withinChangeRange(node.loc)) { // if not self closing, should not hit tag name const start = node.loc.start.offset + 2; const end = node.loc.start.offset + node.loc.source.lastIndexOf('= loc.end.offset) { return true; // no need update } return false; } function withinChangeRange(loc) { const originalLocEnd = loc.__endOffset ?? loc.end.offset; return change.start >= loc.start.offset && change.end <= originalLocEnd; } }, }; }; exports.default = plugin; //# sourceMappingURL=vue-template-html.js.map