volar-service-html 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/index.d.ts +3 -3
- package/out/index.js +237 -233
- package/package.json +3 -3
package/out/index.d.ts
CHANGED
|
@@ -8,8 +8,8 @@ export interface Provide {
|
|
|
8
8
|
'html/updateCustomData': (extraData: html.IHTMLDataProvider[]) => void;
|
|
9
9
|
}
|
|
10
10
|
export declare function getHtmlDocument(document: TextDocument): html.HTMLDocument;
|
|
11
|
-
declare
|
|
11
|
+
export declare function create(options?: {
|
|
12
12
|
validLang?: string;
|
|
13
13
|
disableCustomData?: boolean;
|
|
14
|
-
})
|
|
15
|
-
export default
|
|
14
|
+
}): Service<Provide>;
|
|
15
|
+
export default create;
|
package/out/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getHtmlDocument = void 0;
|
|
26
|
+
exports.create = exports.getHtmlDocument = void 0;
|
|
27
27
|
const html = __importStar(require("vscode-html-languageservice"));
|
|
28
28
|
const path = __importStar(require("path"));
|
|
29
29
|
const vscode_uri_1 = require("vscode-uri");
|
|
@@ -42,257 +42,261 @@ function getHtmlDocument(document) {
|
|
|
42
42
|
return doc;
|
|
43
43
|
}
|
|
44
44
|
exports.getHtmlDocument = getHtmlDocument;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
readDirectory: async (uri) => context.env.fs?.readDirectory(uri) ?? [],
|
|
62
|
-
};
|
|
63
|
-
const documentContext = {
|
|
64
|
-
resolveReference(ref, base) {
|
|
65
|
-
if (ref.match(/^\w[\w\d+.-]*:/)) {
|
|
66
|
-
// starts with a schema
|
|
67
|
-
return ref;
|
|
68
|
-
}
|
|
69
|
-
if (ref[0] === '/') { // resolve absolute path against the current workspace folder
|
|
70
|
-
return base + ref;
|
|
71
|
-
}
|
|
72
|
-
const baseUri = vscode_uri_1.URI.parse(base);
|
|
73
|
-
const baseUriDir = baseUri.path.endsWith('/') ? baseUri : vscode_uri_1.Utils.dirname(baseUri);
|
|
74
|
-
return vscode_uri_1.Utils.resolvePath(baseUriDir, ref).toString(true);
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
const htmlLs = html.getLanguageService({
|
|
78
|
-
fileSystemProvider,
|
|
79
|
-
clientCapabilities: context.env.clientCapabilities,
|
|
80
|
-
});
|
|
81
|
-
context.env.onDidChangeConfiguration?.(() => {
|
|
82
|
-
shouldUpdateCustomData = true;
|
|
83
|
-
});
|
|
84
|
-
return {
|
|
85
|
-
provide: {
|
|
86
|
-
'html/htmlDocument': (document) => {
|
|
87
|
-
if (document.languageId === (options.validLang ?? 'html')) {
|
|
88
|
-
return getHtmlDocument(document);
|
|
89
|
-
}
|
|
45
|
+
// https://github.com/microsoft/vscode/blob/09850876e652688fb142e2e19fd00fd38c0bc4ba/extensions/html-language-features/server/src/htmlServer.ts#L183
|
|
46
|
+
const triggerCharacters = ['.', ':', '<', '"', '=', '/'];
|
|
47
|
+
function create(options = {}) {
|
|
48
|
+
return (context) => {
|
|
49
|
+
if (!context) {
|
|
50
|
+
return { triggerCharacters };
|
|
51
|
+
}
|
|
52
|
+
let shouldUpdateCustomData = true;
|
|
53
|
+
let customData = [];
|
|
54
|
+
let extraData = [];
|
|
55
|
+
const fileSystemProvider = {
|
|
56
|
+
stat: async (uri) => await context.env.fs?.stat(uri) ?? {
|
|
57
|
+
type: html.FileType.Unknown,
|
|
58
|
+
ctime: 0,
|
|
59
|
+
mtime: 0,
|
|
60
|
+
size: 0,
|
|
90
61
|
},
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
const configs = await context.env.getConfiguration?.('html.completion');
|
|
99
|
-
return htmlLs.doComplete2(document, position, htmlDocument, documentContext, configs);
|
|
100
|
-
});
|
|
101
|
-
},
|
|
102
|
-
provideRenameRange(document, position) {
|
|
103
|
-
return worker(document, (htmlDocument) => {
|
|
104
|
-
const offset = document.offsetAt(position);
|
|
105
|
-
return htmlLs
|
|
106
|
-
.findDocumentHighlights(document, position, htmlDocument)
|
|
107
|
-
?.find(h => offset >= document.offsetAt(h.range.start) && offset <= document.offsetAt(h.range.end))
|
|
108
|
-
?.range;
|
|
109
|
-
});
|
|
110
|
-
},
|
|
111
|
-
provideRenameEdits(document, position, newName) {
|
|
112
|
-
return worker(document, (htmlDocument) => {
|
|
113
|
-
return htmlLs.doRename(document, position, newName, htmlDocument);
|
|
114
|
-
});
|
|
115
|
-
},
|
|
116
|
-
async provideHover(document, position) {
|
|
117
|
-
return worker(document, async (htmlDocument) => {
|
|
118
|
-
const hoverSettings = await context.env.getConfiguration?.('html.hover');
|
|
119
|
-
return htmlLs.doHover(document, position, htmlDocument, hoverSettings);
|
|
120
|
-
});
|
|
121
|
-
},
|
|
122
|
-
provideDocumentHighlights(document, position) {
|
|
123
|
-
return worker(document, (htmlDocument) => {
|
|
124
|
-
return htmlLs.findDocumentHighlights(document, position, htmlDocument);
|
|
125
|
-
});
|
|
126
|
-
},
|
|
127
|
-
provideDocumentLinks(document) {
|
|
128
|
-
return worker(document, () => {
|
|
129
|
-
return htmlLs.findDocumentLinks(document, documentContext);
|
|
130
|
-
});
|
|
131
|
-
},
|
|
132
|
-
provideDocumentSymbols(document) {
|
|
133
|
-
return worker(document, (htmlDocument) => {
|
|
134
|
-
// TODO: wait for https://github.com/microsoft/vscode-html-languageservice/pull/152
|
|
135
|
-
const symbols = [];
|
|
136
|
-
htmlDocument.roots.forEach(node => {
|
|
137
|
-
provideFileSymbolsInternal(document, node, symbols);
|
|
138
|
-
});
|
|
139
|
-
return symbols;
|
|
140
|
-
});
|
|
141
|
-
},
|
|
142
|
-
provideFoldingRanges(document) {
|
|
143
|
-
return worker(document, () => {
|
|
144
|
-
return htmlLs.getFoldingRanges(document);
|
|
145
|
-
});
|
|
146
|
-
},
|
|
147
|
-
provideSelectionRanges(document, positions) {
|
|
148
|
-
return worker(document, () => {
|
|
149
|
-
return htmlLs.getSelectionRanges(document, positions);
|
|
150
|
-
});
|
|
151
|
-
},
|
|
152
|
-
async provideDocumentFormattingEdits(document, formatRange, options) {
|
|
153
|
-
return worker(document, async () => {
|
|
154
|
-
const options_2 = await context.env.getConfiguration?.('html.format');
|
|
155
|
-
if (options_2?.enable === false) {
|
|
156
|
-
return;
|
|
62
|
+
readDirectory: async (uri) => context.env.fs?.readDirectory(uri) ?? [],
|
|
63
|
+
};
|
|
64
|
+
const documentContext = {
|
|
65
|
+
resolveReference(ref, base) {
|
|
66
|
+
if (ref.match(/^\w[\w\d+.-]*:/)) {
|
|
67
|
+
// starts with a schema
|
|
68
|
+
return ref;
|
|
157
69
|
}
|
|
158
|
-
{ //
|
|
159
|
-
|
|
160
|
-
let endOffset = document.offsetAt(endPos);
|
|
161
|
-
const content = document.getText();
|
|
162
|
-
if (endPos.character === 0 && endPos.line > 0 && endOffset !== content.length) {
|
|
163
|
-
// if selection ends after a new line, exclude that new line
|
|
164
|
-
const prevLineStart = document.offsetAt({ line: endPos.line - 1, character: 0 });
|
|
165
|
-
while (isEOL(content, endOffset - 1) && endOffset > prevLineStart) {
|
|
166
|
-
endOffset--;
|
|
167
|
-
}
|
|
168
|
-
formatRange = {
|
|
169
|
-
start: formatRange.start,
|
|
170
|
-
end: document.positionAt(endOffset),
|
|
171
|
-
};
|
|
172
|
-
}
|
|
70
|
+
if (ref[0] === '/') { // resolve absolute path against the current workspace folder
|
|
71
|
+
return base + ref;
|
|
173
72
|
}
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
73
|
+
const baseUri = vscode_uri_1.URI.parse(base);
|
|
74
|
+
const baseUriDir = baseUri.path.endsWith('/') ? baseUri : vscode_uri_1.Utils.dirname(baseUri);
|
|
75
|
+
return vscode_uri_1.Utils.resolvePath(baseUriDir, ref).toString(true);
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
const htmlLs = html.getLanguageService({
|
|
79
|
+
fileSystemProvider,
|
|
80
|
+
clientCapabilities: context.env.clientCapabilities,
|
|
81
|
+
});
|
|
82
|
+
context.env.onDidChangeConfiguration?.(() => {
|
|
83
|
+
shouldUpdateCustomData = true;
|
|
84
|
+
});
|
|
85
|
+
return {
|
|
86
|
+
provide: {
|
|
87
|
+
'html/htmlDocument': (document) => {
|
|
88
|
+
if (document.languageId === (options.validLang ?? 'html')) {
|
|
89
|
+
return getHtmlDocument(document);
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
'html/languageService': () => htmlLs,
|
|
93
|
+
'html/documentContext': () => documentContext,
|
|
94
|
+
'html/updateCustomData': updateExtraCustomData,
|
|
95
|
+
},
|
|
96
|
+
triggerCharacters,
|
|
97
|
+
async provideCompletionItems(document, position) {
|
|
98
|
+
return worker(document, async (htmlDocument) => {
|
|
99
|
+
const configs = await context.env.getConfiguration?.('html.completion');
|
|
100
|
+
return htmlLs.doComplete2(document, position, htmlDocument, documentContext, configs);
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
provideRenameRange(document, position) {
|
|
104
|
+
return worker(document, (htmlDocument) => {
|
|
105
|
+
const offset = document.offsetAt(position);
|
|
106
|
+
return htmlLs
|
|
107
|
+
.findDocumentHighlights(document, position, htmlDocument)
|
|
108
|
+
?.find(h => offset >= document.offsetAt(h.range.start) && offset <= document.offsetAt(h.range.end))
|
|
109
|
+
?.range;
|
|
110
|
+
});
|
|
111
|
+
},
|
|
112
|
+
provideRenameEdits(document, position, newName) {
|
|
113
|
+
return worker(document, (htmlDocument) => {
|
|
114
|
+
return htmlLs.doRename(document, position, newName, htmlDocument);
|
|
115
|
+
});
|
|
116
|
+
},
|
|
117
|
+
async provideHover(document, position) {
|
|
118
|
+
return worker(document, async (htmlDocument) => {
|
|
119
|
+
const hoverSettings = await context.env.getConfiguration?.('html.hover');
|
|
120
|
+
return htmlLs.doHover(document, position, htmlDocument, hoverSettings);
|
|
121
|
+
});
|
|
122
|
+
},
|
|
123
|
+
provideDocumentHighlights(document, position) {
|
|
124
|
+
return worker(document, (htmlDocument) => {
|
|
125
|
+
return htmlLs.findDocumentHighlights(document, position, htmlDocument);
|
|
126
|
+
});
|
|
127
|
+
},
|
|
128
|
+
provideDocumentLinks(document) {
|
|
129
|
+
return worker(document, () => {
|
|
130
|
+
return htmlLs.findDocumentLinks(document, documentContext);
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
provideDocumentSymbols(document) {
|
|
134
|
+
return worker(document, (htmlDocument) => {
|
|
135
|
+
// TODO: wait for https://github.com/microsoft/vscode-html-languageservice/pull/152
|
|
136
|
+
const symbols = [];
|
|
137
|
+
htmlDocument.roots.forEach(node => {
|
|
138
|
+
provideFileSymbolsInternal(document, node, symbols);
|
|
139
|
+
});
|
|
140
|
+
return symbols;
|
|
141
|
+
});
|
|
142
|
+
},
|
|
143
|
+
provideFoldingRanges(document) {
|
|
144
|
+
return worker(document, () => {
|
|
145
|
+
return htmlLs.getFoldingRanges(document);
|
|
146
|
+
});
|
|
147
|
+
},
|
|
148
|
+
provideSelectionRanges(document, positions) {
|
|
149
|
+
return worker(document, () => {
|
|
150
|
+
return htmlLs.getSelectionRanges(document, positions);
|
|
177
151
|
});
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
* comments
|
|
185
|
-
*/
|
|
186
|
-
const scanner = htmlLs.createScanner(document.getText());
|
|
187
|
-
let token = scanner.scan();
|
|
188
|
-
let startCommentTagLine;
|
|
189
|
-
while (token !== html.TokenType.EOS) {
|
|
190
|
-
if (token === html.TokenType.StartCommentTag) {
|
|
191
|
-
startCommentTagLine = document.positionAt(scanner.getTokenOffset()).line;
|
|
152
|
+
},
|
|
153
|
+
async provideDocumentFormattingEdits(document, formatRange, options) {
|
|
154
|
+
return worker(document, async () => {
|
|
155
|
+
const options_2 = await context.env.getConfiguration?.('html.format');
|
|
156
|
+
if (options_2?.enable === false) {
|
|
157
|
+
return;
|
|
192
158
|
}
|
|
193
|
-
|
|
194
|
-
const
|
|
195
|
-
|
|
196
|
-
|
|
159
|
+
{ // https://github.com/microsoft/vscode/blob/dce493cb6e36346ef2714e82c42ce14fc461b15c/extensions/html-language-features/server/src/modes/formatting.ts#L13-L23
|
|
160
|
+
const endPos = formatRange.end;
|
|
161
|
+
let endOffset = document.offsetAt(endPos);
|
|
162
|
+
const content = document.getText();
|
|
163
|
+
if (endPos.character === 0 && endPos.line > 0 && endOffset !== content.length) {
|
|
164
|
+
// if selection ends after a new line, exclude that new line
|
|
165
|
+
const prevLineStart = document.offsetAt({ line: endPos.line - 1, character: 0 });
|
|
166
|
+
while (isEOL(content, endOffset - 1) && endOffset > prevLineStart) {
|
|
167
|
+
endOffset--;
|
|
168
|
+
}
|
|
169
|
+
formatRange = {
|
|
170
|
+
start: formatRange.start,
|
|
171
|
+
end: document.positionAt(endOffset),
|
|
172
|
+
};
|
|
197
173
|
}
|
|
198
|
-
startCommentTagLine = undefined;
|
|
199
174
|
}
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
175
|
+
return htmlLs.format(document, formatRange, {
|
|
176
|
+
...options_2,
|
|
177
|
+
...options,
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
},
|
|
181
|
+
provideFormattingIndentSensitiveLines(document) {
|
|
182
|
+
return worker(document, (htmlDocument) => {
|
|
183
|
+
const lines = [];
|
|
184
|
+
/**
|
|
185
|
+
* comments
|
|
186
|
+
*/
|
|
187
|
+
const scanner = htmlLs.createScanner(document.getText());
|
|
188
|
+
let token = scanner.scan();
|
|
189
|
+
let startCommentTagLine;
|
|
190
|
+
while (token !== html.TokenType.EOS) {
|
|
191
|
+
if (token === html.TokenType.StartCommentTag) {
|
|
192
|
+
startCommentTagLine = document.positionAt(scanner.getTokenOffset()).line;
|
|
204
193
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
// https://github.com/beautify-web/js-beautify/blob/686f8c1b265990908ece86ce39291733c75c997c/js/src/html/options.js#L81
|
|
212
|
-
const indentSensitiveTags = new Set(['pre', 'textarea']);
|
|
213
|
-
htmlDocument.roots.forEach(function visit(node) {
|
|
214
|
-
if (node.tag !== undefined
|
|
215
|
-
&& node.startTagEnd !== undefined
|
|
216
|
-
&& node.endTagStart !== undefined
|
|
217
|
-
&& indentSensitiveTags.has(node.tag)) {
|
|
218
|
-
for (let i = document.positionAt(node.startTagEnd).line + 1; i <= document.positionAt(node.endTagStart).line; i++) {
|
|
219
|
-
lines.push(i);
|
|
194
|
+
else if (token === html.TokenType.EndCommentTag) {
|
|
195
|
+
const line = document.positionAt(scanner.getTokenOffset()).line;
|
|
196
|
+
for (let i = startCommentTagLine + 1; i <= line; i++) {
|
|
197
|
+
lines.push(i);
|
|
198
|
+
}
|
|
199
|
+
startCommentTagLine = undefined;
|
|
220
200
|
}
|
|
201
|
+
else if (token === html.TokenType.AttributeValue) {
|
|
202
|
+
const startLine = document.positionAt(scanner.getTokenOffset()).line;
|
|
203
|
+
for (let i = 1; i < scanner.getTokenText().split('\n').length; i++) {
|
|
204
|
+
lines.push(startLine + i);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
token = scanner.scan();
|
|
221
208
|
}
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
209
|
+
/**
|
|
210
|
+
* tags
|
|
211
|
+
*/
|
|
212
|
+
// https://github.com/beautify-web/js-beautify/blob/686f8c1b265990908ece86ce39291733c75c997c/js/src/html/options.js#L81
|
|
213
|
+
const indentSensitiveTags = new Set(['pre', 'textarea']);
|
|
214
|
+
htmlDocument.roots.forEach(function visit(node) {
|
|
215
|
+
if (node.tag !== undefined
|
|
216
|
+
&& node.startTagEnd !== undefined
|
|
217
|
+
&& node.endTagStart !== undefined
|
|
218
|
+
&& indentSensitiveTags.has(node.tag)) {
|
|
219
|
+
for (let i = document.positionAt(node.startTagEnd).line + 1; i <= document.positionAt(node.endTagStart).line; i++) {
|
|
220
|
+
lines.push(i);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
node.children.forEach(visit);
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
return lines;
|
|
228
|
+
});
|
|
229
|
+
},
|
|
230
|
+
provideLinkedEditingRanges(document, position) {
|
|
231
|
+
return worker(document, (htmlDocument) => {
|
|
232
|
+
const ranges = htmlLs.findLinkedEditingRanges(document, position, htmlDocument);
|
|
233
|
+
if (!ranges)
|
|
234
|
+
return;
|
|
235
|
+
return { ranges };
|
|
225
236
|
});
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
async provideAutoInsertionEdit(document, position, insertContext) {
|
|
238
|
-
return worker(document, async (htmlDocument) => {
|
|
239
|
-
const lastCharacter = insertContext.lastChange.text[insertContext.lastChange.text.length - 1];
|
|
240
|
-
if (insertContext.lastChange.rangeLength === 0 && lastCharacter === '=') {
|
|
241
|
-
const enabled = (await context.env.getConfiguration?.('html.autoCreateQuotes')) ?? true;
|
|
242
|
-
if (enabled) {
|
|
243
|
-
const text = htmlLs.doQuoteComplete(document, position, htmlDocument, await context.env.getConfiguration?.('html.completion'));
|
|
244
|
-
if (text) {
|
|
245
|
-
return text;
|
|
237
|
+
},
|
|
238
|
+
async provideAutoInsertionEdit(document, position, insertContext) {
|
|
239
|
+
return worker(document, async (htmlDocument) => {
|
|
240
|
+
const lastCharacter = insertContext.lastChange.text[insertContext.lastChange.text.length - 1];
|
|
241
|
+
if (insertContext.lastChange.rangeLength === 0 && lastCharacter === '=') {
|
|
242
|
+
const enabled = (await context.env.getConfiguration?.('html.autoCreateQuotes')) ?? true;
|
|
243
|
+
if (enabled) {
|
|
244
|
+
const text = htmlLs.doQuoteComplete(document, position, htmlDocument, await context.env.getConfiguration?.('html.completion'));
|
|
245
|
+
if (text) {
|
|
246
|
+
return text;
|
|
247
|
+
}
|
|
246
248
|
}
|
|
247
249
|
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
250
|
+
if (insertContext.lastChange.rangeLength === 0 && (lastCharacter === '>' || lastCharacter === '/')) {
|
|
251
|
+
const enabled = (await context.env.getConfiguration?.('html.autoClosingTags')) ?? true;
|
|
252
|
+
if (enabled) {
|
|
253
|
+
const text = htmlLs.doTagComplete(document, position, htmlDocument);
|
|
254
|
+
if (text) {
|
|
255
|
+
return text;
|
|
256
|
+
}
|
|
255
257
|
}
|
|
256
258
|
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
259
|
+
});
|
|
260
|
+
},
|
|
261
|
+
};
|
|
262
|
+
async function initCustomData() {
|
|
263
|
+
if (shouldUpdateCustomData && !options.disableCustomData) {
|
|
264
|
+
shouldUpdateCustomData = false;
|
|
265
|
+
customData = await getCustomData();
|
|
266
|
+
htmlLs.setDataProviders(true, [...customData, ...extraData]);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
function updateExtraCustomData(data) {
|
|
270
|
+
extraData = data;
|
|
265
271
|
htmlLs.setDataProviders(true, [...customData, ...extraData]);
|
|
266
272
|
}
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
newData.push(html.newHTMLDataProvider(customDataPath, require(jsonPath)));
|
|
279
|
-
}
|
|
280
|
-
catch (error) {
|
|
281
|
-
console.error(error);
|
|
273
|
+
async function getCustomData() {
|
|
274
|
+
const customData = await context?.env.getConfiguration?.('html.customData') ?? [];
|
|
275
|
+
const newData = [];
|
|
276
|
+
for (const customDataPath of customData) {
|
|
277
|
+
try {
|
|
278
|
+
const jsonPath = path.resolve(customDataPath);
|
|
279
|
+
newData.push(html.newHTMLDataProvider(customDataPath, require(jsonPath)));
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
console.error(error);
|
|
283
|
+
}
|
|
282
284
|
}
|
|
285
|
+
return newData;
|
|
283
286
|
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
return;
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
287
|
+
async function worker(document, callback) {
|
|
288
|
+
if (document.languageId !== (options.validLang ?? 'html'))
|
|
289
|
+
return;
|
|
290
|
+
const htmlDocument = getHtmlDocument(document);
|
|
291
|
+
if (!htmlDocument)
|
|
292
|
+
return;
|
|
293
|
+
await initCustomData();
|
|
294
|
+
return callback(htmlDocument);
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
exports.create = create;
|
|
299
|
+
exports.default = create;
|
|
296
300
|
function isEOL(content, offset) {
|
|
297
301
|
return isNewlineCharacter(content.charCodeAt(offset));
|
|
298
302
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "volar-service-html",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
4
4
|
"main": "out/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -20,12 +20,12 @@
|
|
|
20
20
|
"vscode-languageserver-textdocument": "^1.0.8"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"@volar/language-service": "~1.
|
|
23
|
+
"@volar/language-service": "~1.10.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependenciesMeta": {
|
|
26
26
|
"@volar/language-service": {
|
|
27
27
|
"optional": true
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "7422c8d99d498df660ff9be3491545a5b45b3622"
|
|
31
31
|
}
|