astro-ghostcms/.pnpm-store/v3/files/5a/6c938669e2bc687b0108c36a665...

71 lines
2.4 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getVueLanguageModule = void 0;
const language_core_1 = require("@volar/language-core");
const vscode_uri_1 = require("vscode-uri");
const utils_js_1 = require("./utils.js");
function getVueLanguageModule() {
return {
createVirtualCode(fileId, languageId, snapshot) {
if (languageId === 'vue') {
const fileName = fileId.includes('://')
? vscode_uri_1.URI.parse(fileId).fsPath.replace(/\\/g, '/')
: fileId;
return new VueVirtualCode(fileName, snapshot);
}
},
updateVirtualCode(_fileId, vueCode, snapshot) {
vueCode.update(snapshot);
return vueCode;
},
typescript: {
extraFileExtensions: [{ extension: 'vue', isMixedContent: true, scriptKind: 7 }],
getScript(vueCode) {
for (const code of (0, language_core_1.forEachEmbeddedCode)(vueCode)) {
if (code.id === 'tsx') {
return {
code,
extension: '.tsx',
scriptKind: 4,
};
}
}
},
},
};
}
exports.getVueLanguageModule = getVueLanguageModule;
class VueVirtualCode {
constructor(fileName, snapshot) {
this.fileName = fileName;
this.snapshot = snapshot;
this.id = 'root';
this.languageId = 'vue';
this.codegenStacks = [];
this.onSnapshotUpdated();
}
update(newSnapshot) {
this.snapshot = newSnapshot;
this.onSnapshotUpdated();
}
onSnapshotUpdated() {
this.mappings = [
{
sourceOffsets: [0],
generatedOffsets: [0],
lengths: [this.snapshot.getLength()],
data: {
verification: true,
completion: true,
semantic: true,
navigation: true,
structure: true,
format: true,
},
},
];
this.embeddedCodes = [];
this.embeddedCodes.push((0, utils_js_1.framework2tsx)(this.fileName, this.snapshot.getText(0, this.snapshot.getLength()), 'vue'));
}
}
//# sourceMappingURL=vue.js.map