volar-service-html 0.0.1 → 0.0.3

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 CHANGED
@@ -1,17 +1,14 @@
1
- import type { ServiceContext, Service, InjectionKey } from '@volar/language-service';
1
+ import type { Service } from '@volar/language-service';
2
2
  import * as html from 'vscode-html-languageservice';
3
3
  import { TextDocument } from 'vscode-languageserver-textdocument';
4
- export declare const rulesInjectionKey: InjectionKey<{
5
- htmlDocument: html.HTMLDocument;
6
- languageService: html.LanguageService;
7
- }>;
8
- export declare function getHtmlDocument(document: TextDocument): html.HTMLDocument;
9
- export interface PluginInstance extends ReturnType<Service> {
10
- getHtmlLs: () => html.LanguageService;
11
- updateCustomData(extraData: html.IHTMLDataProvider[]): void;
4
+ export interface Provide {
5
+ 'html/htmlDocument': (document: TextDocument) => html.HTMLDocument | undefined;
6
+ 'html/languageService': () => html.LanguageService;
7
+ 'html/updateCustomData': (extraData: html.IHTMLDataProvider[]) => void;
12
8
  }
9
+ export declare function getHtmlDocument(document: TextDocument): html.HTMLDocument;
13
10
  declare const _default: (options?: {
14
11
  validLang?: string;
15
12
  disableCustomData?: boolean;
16
- }) => (context: ServiceContext | undefined) => PluginInstance;
13
+ }) => Service<Provide>;
17
14
  export default _default;
package/out/index.js CHANGED
@@ -23,13 +23,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.getHtmlDocument = exports.rulesInjectionKey = void 0;
26
+ exports.getHtmlDocument = void 0;
27
27
  const html = __importStar(require("vscode-html-languageservice"));
28
28
  const vscode = __importStar(require("vscode-languageserver-protocol"));
29
29
  const path = __importStar(require("path"));
30
30
  const parserLs = html.getLanguageService();
31
31
  const htmlDocuments = new WeakMap();
32
- exports.rulesInjectionKey = Symbol();
33
32
  function getHtmlDocument(document) {
34
33
  const cache = htmlDocuments.get(document);
35
34
  if (cache) {
@@ -57,24 +56,16 @@ exports.default = (options = {}) => (context) => {
57
56
  shouldUpdateCustomData = true;
58
57
  });
59
58
  return {
60
- rules: {
61
- provide: {
62
- [exports.rulesInjectionKey](document) {
63
- if (document.languageId !== (options.validLang ?? 'html'))
64
- return;
65
- const htmlDocument = getHtmlDocument(document);
66
- if (!htmlDocument)
67
- return;
68
- return {
69
- htmlDocument,
70
- languageService: htmlLs,
71
- };
72
- },
59
+ provide: {
60
+ 'html/htmlDocument': (document) => {
61
+ if (document.languageId === (options.validLang ?? 'html')) {
62
+ return getHtmlDocument(document);
63
+ }
73
64
  },
65
+ 'html/languageService': () => htmlLs,
66
+ 'html/updateCustomData': updateExtraCustomData,
74
67
  },
75
68
  triggerCharacters,
76
- getHtmlLs: () => htmlLs,
77
- updateCustomData: updateExtraCustomData,
78
69
  async provideCompletionItems(document, position) {
79
70
  return worker(document, async (htmlDocument) => {
80
71
  const configs = await context.env.getConfiguration?.('html.completion');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "volar-service-html",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "main": "out/index.js",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -17,13 +17,5 @@
17
17
  "vscode-languageserver-protocol": "^3.17.3",
18
18
  "vscode-languageserver-textdocument": "^1.0.8"
19
19
  },
20
- "peerDependencies": {
21
- "@volar/language-service": "*"
22
- },
23
- "peerDependenciesMeta": {
24
- "@volar/language-service": {
25
- "optional": true
26
- }
27
- },
28
- "gitHead": "5bf5152f076f25cb1ddbc7aa6978a8d1c7009fd6"
20
+ "gitHead": "28896539331e31b4ef1064b6839ea0924d5d28d0"
29
21
  }