volar-service-html 0.0.14 → 0.0.16

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.
Files changed (2) hide show
  1. package/out/index.js +4 -63
  2. package/package.json +3 -2
package/out/index.js CHANGED
@@ -1,31 +1,7 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  Object.defineProperty(exports, "__esModule", { value: true });
26
3
  exports.create = exports.getHtmlDocument = void 0;
27
- const html = __importStar(require("vscode-html-languageservice"));
28
- const path = __importStar(require("path"));
4
+ const html = require("vscode-html-languageservice");
29
5
  const vscode_uri_1 = require("vscode-uri");
30
6
  const parserLs = html.getLanguageService();
31
7
  const htmlDocuments = new WeakMap();
@@ -132,12 +108,7 @@ function create({ languageId = 'html', useDefaultDataProvider = true, useCustomD
132
108
  },
133
109
  provideDocumentSymbols(document) {
134
110
  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;
111
+ return htmlLs.findDocumentSymbols2(document, htmlDocument);
141
112
  });
142
113
  },
143
114
  provideFoldingRanges(document) {
@@ -275,6 +246,8 @@ function create({ languageId = 'html', useDefaultDataProvider = true, useCustomD
275
246
  const newData = [];
276
247
  for (const customDataPath of customData) {
277
248
  try {
249
+ const pathModuleName = 'path'; // avoid bundle
250
+ const { posix: path } = require(pathModuleName);
278
251
  const jsonPath = path.resolve(customDataPath);
279
252
  newData.push(html.newHTMLDataProvider(customDataPath, require(jsonPath)));
280
253
  }
@@ -305,36 +278,4 @@ const NL = '\n'.charCodeAt(0);
305
278
  function isNewlineCharacter(charCode) {
306
279
  return charCode === CR || charCode === NL;
307
280
  }
308
- function provideFileSymbolsInternal(document, node, symbols) {
309
- const name = nodeToName(node);
310
- const range = {
311
- start: document.positionAt(node.start),
312
- end: document.positionAt(node.end),
313
- };
314
- const symbol = {
315
- name,
316
- kind: 8,
317
- range,
318
- selectionRange: range,
319
- };
320
- symbols.push(symbol);
321
- node.children.forEach(child => {
322
- symbol.children ??= [];
323
- provideFileSymbolsInternal(document, child, symbol.children);
324
- });
325
- }
326
- function nodeToName(node) {
327
- let name = node.tag;
328
- if (node.attributes) {
329
- const id = node.attributes['id'];
330
- const classes = node.attributes['class'];
331
- if (id) {
332
- name += `#${id.replace(/[\"\']/g, '')}`;
333
- }
334
- if (classes) {
335
- name += classes.replace(/[\"\']/g, '').split(/\s+/).map(className => `.${className}`).join('');
336
- }
337
- }
338
- return name || '?';
339
- }
340
281
  //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volar-service-html",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "description": "Integrate vscode-languageservice-html into Volar",
5
5
  "homepage": "https://github.com/volarjs/services/tree/master/packages/html",
6
6
  "bugs": "https://github.com/volarjs/services/issues",
@@ -29,6 +29,7 @@
29
29
  "vscode-uri": "^3.0.8"
30
30
  },
31
31
  "devDependencies": {
32
+ "@types/node": "latest",
32
33
  "vscode-languageserver-textdocument": "^1.0.11"
33
34
  },
34
35
  "peerDependencies": {
@@ -39,5 +40,5 @@
39
40
  "optional": true
40
41
  }
41
42
  },
42
- "gitHead": "6fb81d23ead08b2fdb0812b272216ced8497aed0"
43
+ "gitHead": "fdcd47eb5dc865999ac7ac610f8e0dfb458aca04"
43
44
  }