volar-service-pug 0.0.0 → 0.0.2

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/empty.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- console.warn('volar-service-pug: This plugin is not support on web yet.');
3
+ console.warn('volar-service-pug: this module is not yet supported for web.');
4
4
  exports.default = () => () => ({});
5
5
  //# sourceMappingURL=empty.js.map
package/out/index.d.ts CHANGED
@@ -1,7 +1,11 @@
1
- import type { Service, ServiceContext } from '@volar/language-service';
1
+ import { InjectionKey, Service, ServiceContext } from '@volar/language-service';
2
2
  import type * as html from 'vscode-html-languageservice';
3
3
  import { TextDocument } from 'vscode-languageserver-textdocument';
4
4
  import * as pug from './languageService';
5
+ export declare const injectionKeys: {
6
+ pugDocument: InjectionKey<[TextDocument], pug.PugDocument>;
7
+ languageService: InjectionKey<[], pug.LanguageService>;
8
+ };
5
9
  export interface PluginInstance extends ReturnType<Service> {
6
10
  getHtmlLs: () => html.LanguageService;
7
11
  updateCustomData(extraData: html.IHTMLDataProvider[]): void;
package/out/index.js CHANGED
@@ -26,9 +26,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.injectionKeys = void 0;
29
30
  const volar_service_html_1 = __importDefault(require("volar-service-html"));
30
31
  const language_service_1 = require("@volar/language-service");
32
+ const language_service_2 = require("@volar/language-service");
31
33
  const pug = __importStar(require("./languageService"));
34
+ exports.injectionKeys = {
35
+ pugDocument: 'pug/pugDocument',
36
+ languageService: 'pug/languageService',
37
+ };
32
38
  exports.default = () => (context) => {
33
39
  if (!context) {
34
40
  return {};
@@ -37,20 +43,13 @@ exports.default = () => (context) => {
37
43
  const htmlPlugin = (0, volar_service_html_1.default)()(context);
38
44
  const pugLs = pug.getLanguageService(htmlPlugin.getHtmlLs());
39
45
  return {
46
+ provide: {
47
+ ...(0, language_service_1.defineProvide)(exports.injectionKeys.pugDocument, getPugDocument),
48
+ ...(0, language_service_1.defineProvide)(exports.injectionKeys.languageService, () => pugLs),
49
+ },
40
50
  ...htmlPlugin,
41
51
  getPugLs: () => pugLs,
42
52
  getPugDocument,
43
- resolveRuleContext(context) {
44
- worker(context.document, (pugDocument) => {
45
- if (pugDocument.ast) {
46
- context.pug = {
47
- rootNode: pugDocument.ast,
48
- languageService: pugLs,
49
- };
50
- }
51
- });
52
- return context;
53
- },
54
53
  provideCompletionItems(document, position, _) {
55
54
  return worker(document, (pugDocument) => {
56
55
  return pugLs.doComplete(pugDocument, position, context.env.documentContext);
@@ -93,7 +92,7 @@ exports.default = () => (context) => {
93
92
  provideDocumentSymbols(document, token) {
94
93
  return worker(document, async (pugDoc) => {
95
94
  const htmlResult = await htmlPlugin.provideDocumentSymbols?.(pugDoc.map.virtualFileDocument, token) ?? [];
96
- const pugResult = htmlResult.map(htmlSymbol => language_service_1.transformer.asDocumentSymbol(htmlSymbol, range => pugDoc.map.toSourceRange(range))).filter((symbol) => symbol !== undefined);
95
+ const pugResult = htmlResult.map(htmlSymbol => language_service_2.transformer.asDocumentSymbol(htmlSymbol, range => pugDoc.map.toSourceRange(range))).filter((symbol) => symbol !== undefined);
97
96
  return pugResult;
98
97
  });
99
98
  },
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "volar-service-pug",
3
- "version": "0.0.0",
3
+ "version": "0.0.2",
4
4
  "main": "out/index.js",
5
5
  "license": "MIT",
6
6
  "files": [
7
- "rules.d.ts",
8
7
  "out/**/*.js",
9
8
  "out/**/*.d.ts"
10
9
  ],
@@ -17,7 +16,7 @@
17
16
  "muggle-string": "^0.2.2",
18
17
  "pug-lexer": "^5.0.1",
19
18
  "pug-parser": "^6.0.0",
20
- "volar-service-html": "0.0.0",
19
+ "volar-service-html": "0.0.2",
21
20
  "vscode-html-languageservice": "^5.0.4",
22
21
  "vscode-languageserver-textdocument": "^1.0.8",
23
22
  "vscode-languageserver-types": "^3.17.2"
@@ -29,5 +28,5 @@
29
28
  "browser": {
30
29
  "./out/index.js": "./out/empty.js"
31
30
  },
32
- "gitHead": "1011561ac4bbf79c53c3b80c27692569bf861519"
31
+ "gitHead": "19482084693c7349f461dc75ec52ee6917739c51"
33
32
  }
package/rules.d.ts DELETED
@@ -1,10 +0,0 @@
1
- import * as pug from 'volar-service-pug';
2
-
3
- declare module '@volar/language-service' {
4
- interface RuleContext {
5
- pug?: {
6
- rootNode: pug.Node;
7
- languageService: pug.LanguageService;
8
- }
9
- }
10
- }