@vuedx/vue-virtual-textdocument
Advanced tools
Comparing version 0.2.3 to 0.2.4-0
@@ -176,3 +176,3 @@ import { SFCBlock, SFCParseOptions, SFCDescriptor } from '@vue/compiler-sfc'; | ||
static create(uri: string, languageId: string, version: number, content: string, options?: SFCParseOptions): VueTextDocument; | ||
static update(document: VueTextDocument, changes: TextDocumentContentChangeEvent[], version: number): void; | ||
static update(document: VueTextDocument, changes: TextDocumentContentChangeEvent[], version: number): VueTextDocument; | ||
} | ||
@@ -179,0 +179,0 @@ |
@@ -260,6 +260,8 @@ import { URI } from 'vscode-uri'; | ||
refresh() { | ||
var _a; | ||
if (this.isDirty || this.doc.version !== this.container.version) { | ||
this.isDirty = false; | ||
const scriptFile = this.container.getDocumentFileName(SCRIPT_BLOCK_SELECTOR); | ||
const scriptSetupFile = this.container.getDocumentFileName(SCRIPT_SETUP_BLOCK_SELECTOR); | ||
const scriptSetupFile = ((_a = this.container.descriptor.script) === null || _a === void 0 ? void 0 : _a.setup) ? this.container.getDocumentFileName(SCRIPT_SETUP_BLOCK_SELECTOR) | ||
: null; | ||
const renderFile = this.container.getDocumentFileName(RENDER_SELECTOR); | ||
@@ -298,6 +300,8 @@ const lines = []; | ||
refresh() { | ||
var _a; | ||
if (this.isDirty || this.doc.version !== this.container.version) { | ||
this.isDirty = false; | ||
const scriptFile = this.container.getDocumentFileName(SCRIPT_BLOCK_SELECTOR); | ||
const scriptSetupFile = this.container.getDocumentFileName(SCRIPT_SETUP_BLOCK_SELECTOR); | ||
const scriptSetupFile = ((_a = this.container.descriptor.script) === null || _a === void 0 ? void 0 : _a.setup) ? this.container.getDocumentFileName(SCRIPT_SETUP_BLOCK_SELECTOR) | ||
: null; | ||
const lines = []; | ||
@@ -312,3 +316,5 @@ if (scriptSetupFile) { | ||
const path = relativeVirtualImportPath(scriptFile); | ||
lines.push(`import component from '${path}'`); | ||
lines.push(`import { defineComponent } from 'vue'`); | ||
lines.push(`import script from '${path}'`); | ||
lines.push(`const component = defineComponent(script)`); | ||
} | ||
@@ -406,4 +412,3 @@ else { | ||
catch (error) { | ||
console.log(error); | ||
// skip invalid template state | ||
// This is very unlikely to happen as compiler is very error tolerant. | ||
this.doc = TextDocument.update(this.doc, [{ text: `\n/* ${error.message} ${error.stack} */ \n` }], this.container.version); | ||
@@ -438,3 +443,3 @@ this.originalRange = [0, 0]; | ||
}); | ||
return this.result.code + `\n// Version ${this.doc.version}`; | ||
return this.result.code; | ||
} | ||
@@ -445,6 +450,7 @@ } | ||
if (script && script.content) { | ||
// TODO: Cache this. | ||
const result = analyzer.analyzeScript(script.content, 'component.ts'); | ||
const map = {}; | ||
result.components.forEach((component) => { | ||
map[component.name] = { | ||
const result = { | ||
path: component.source.moduleName, | ||
@@ -454,2 +460,5 @@ named: !!component.source.exportName, | ||
}; | ||
component.aliases.forEach((name) => { | ||
map[name] = result; | ||
}); | ||
}); | ||
@@ -652,2 +661,3 @@ return map; | ||
// -- skip invalid state. | ||
// TODO: Catch errors. | ||
} | ||
@@ -659,3 +669,2 @@ } | ||
static update(document, changes, version) { | ||
console.log(`VueTextDocument:: ${document.fsPath} ${document.version} ---> ${version} ===> ${JSON.stringify(changes)}`); | ||
document.doc = TextDocument.update(document.doc, changes, version); | ||
@@ -667,2 +676,3 @@ document.isDirty = true; | ||
}); | ||
return document; | ||
} | ||
@@ -669,0 +679,0 @@ } |
@@ -264,6 +264,8 @@ 'use strict'; | ||
refresh() { | ||
var _a; | ||
if (this.isDirty || this.doc.version !== this.container.version) { | ||
this.isDirty = false; | ||
const scriptFile = this.container.getDocumentFileName(SCRIPT_BLOCK_SELECTOR); | ||
const scriptSetupFile = this.container.getDocumentFileName(SCRIPT_SETUP_BLOCK_SELECTOR); | ||
const scriptSetupFile = ((_a = this.container.descriptor.script) === null || _a === void 0 ? void 0 : _a.setup) ? this.container.getDocumentFileName(SCRIPT_SETUP_BLOCK_SELECTOR) | ||
: null; | ||
const renderFile = this.container.getDocumentFileName(RENDER_SELECTOR); | ||
@@ -302,6 +304,8 @@ const lines = []; | ||
refresh() { | ||
var _a; | ||
if (this.isDirty || this.doc.version !== this.container.version) { | ||
this.isDirty = false; | ||
const scriptFile = this.container.getDocumentFileName(SCRIPT_BLOCK_SELECTOR); | ||
const scriptSetupFile = this.container.getDocumentFileName(SCRIPT_SETUP_BLOCK_SELECTOR); | ||
const scriptSetupFile = ((_a = this.container.descriptor.script) === null || _a === void 0 ? void 0 : _a.setup) ? this.container.getDocumentFileName(SCRIPT_SETUP_BLOCK_SELECTOR) | ||
: null; | ||
const lines = []; | ||
@@ -316,3 +320,5 @@ if (scriptSetupFile) { | ||
const path = relativeVirtualImportPath(scriptFile); | ||
lines.push(`import component from '${path}'`); | ||
lines.push(`import { defineComponent } from 'vue'`); | ||
lines.push(`import script from '${path}'`); | ||
lines.push(`const component = defineComponent(script)`); | ||
} | ||
@@ -410,4 +416,3 @@ else { | ||
catch (error) { | ||
console.log(error); | ||
// skip invalid template state | ||
// This is very unlikely to happen as compiler is very error tolerant. | ||
this.doc = vscodeLanguageserverTextdocument.TextDocument.update(this.doc, [{ text: `\n/* ${error.message} ${error.stack} */ \n` }], this.container.version); | ||
@@ -442,3 +447,3 @@ this.originalRange = [0, 0]; | ||
}); | ||
return this.result.code + `\n// Version ${this.doc.version}`; | ||
return this.result.code; | ||
} | ||
@@ -449,6 +454,7 @@ } | ||
if (script && script.content) { | ||
// TODO: Cache this. | ||
const result = analyzer.analyzeScript(script.content, 'component.ts'); | ||
const map = {}; | ||
result.components.forEach((component) => { | ||
map[component.name] = { | ||
const result = { | ||
path: component.source.moduleName, | ||
@@ -458,2 +464,5 @@ named: !!component.source.exportName, | ||
}; | ||
component.aliases.forEach((name) => { | ||
map[name] = result; | ||
}); | ||
}); | ||
@@ -656,2 +665,3 @@ return map; | ||
// -- skip invalid state. | ||
// TODO: Catch errors. | ||
} | ||
@@ -663,3 +673,2 @@ } | ||
static update(document, changes, version) { | ||
console.log(`VueTextDocument:: ${document.fsPath} ${document.version} ---> ${version} ===> ${JSON.stringify(changes)}`); | ||
document.doc = vscodeLanguageserverTextdocument.TextDocument.update(document.doc, changes, version); | ||
@@ -671,2 +680,3 @@ document.isDirty = true; | ||
}); | ||
return document; | ||
} | ||
@@ -673,0 +683,0 @@ } |
{ | ||
"name": "@vuedx/vue-virtual-textdocument", | ||
"version": "0.2.3", | ||
"version": "0.2.4-0", | ||
"description": "", | ||
@@ -19,4 +19,4 @@ "main": "dist/vue-virtual-textdocument.js", | ||
"@vue/compiler-sfc": "^3.0.0-rc.5", | ||
"@vuedx/analyze": "0.2.3", | ||
"@vuedx/compiler-tsx": "0.2.3", | ||
"@vuedx/analyze": "0.2.4-0", | ||
"@vuedx/compiler-tsx": "0.2.4-0", | ||
"vscode-languageserver-textdocument": "^1.0.1", | ||
@@ -23,0 +23,0 @@ "vscode-uri": "^2.1.2" |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
159193
1538
+ Added@vuedx/analyze@0.2.4-0(transitive)
+ Added@vuedx/compiler-tsx@0.2.4-0(transitive)
+ Added@vuedx/template-ast-types@0.2.4-0(transitive)
- Removed@vuedx/analyze@0.2.3(transitive)
- Removed@vuedx/compiler-tsx@0.2.3(transitive)
- Removed@vuedx/template-ast-types@0.2.3(transitive)
Updated@vuedx/analyze@0.2.4-0
Updated@vuedx/compiler-tsx@0.2.4-0