@webgal/language-server 0.0.2-alpha.1 → 0.0.2-alpha.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/build/browser.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  require('./providerState-B7hGbqQj.cjs');
3
3
  const require_utils = require('./utils.cjs');
4
- const require_onInitialize = require('./onInitialize-uaxhCEGr.cjs');
4
+ const require_onInitialize = require('./onInitialize-7r14ko5I.cjs');
5
5
  let _volar_language_server_browser = require("@volar/language-server/browser");
6
6
 
7
7
  //#region src/browser.ts
package/build/browser.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./providerState-CLCXHs37.mjs";
2
2
  import { bindCoreFileAccessorToClientVfs, createClientVfsFileSystem, createWebgalVirtualCode, updateWebgalVirtualCode } from "./utils.mjs";
3
- import { i as registerConnectionHandlers, n as applyServerCapabilities, r as createWebgalService, t as applyClientCapabilities } from "./onInitialize-DIUUrHI3.mjs";
3
+ import { i as registerConnectionHandlers, n as applyServerCapabilities, r as createWebgalService, t as applyClientCapabilities } from "./onInitialize-DLHBz6ds.mjs";
4
4
  import { createConnection, createConnection as createConnection$1, createServer, createSimpleProject } from "@volar/language-server/browser";
5
5
 
6
6
  //#region src/browser.ts
package/build/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  require('./providerState-B7hGbqQj.cjs');
2
2
  const require_utils = require('./utils.cjs');
3
- const require_onInitialize = require('./onInitialize-uaxhCEGr.cjs');
3
+ const require_onInitialize = require('./onInitialize-7r14ko5I.cjs');
4
4
  let _volar_language_server_node = require("@volar/language-server/node");
5
5
  let vscode_languageserver_node = require("vscode-languageserver/node");
6
6
 
@@ -22,8 +22,8 @@ async function startWebSocketServer(options) {
22
22
  });
23
23
  }
24
24
  function getWsOptions(argv) {
25
- let port = Number(process.env.WEBGAL_LSP_WS_PORT ?? 3001);
26
- let path = process.env.WEBGAL_LSP_WS_PATH ?? "/webgal-lsp";
25
+ let port = 5882;
26
+ let path = "/webgal-lsp";
27
27
  for (const arg of argv) {
28
28
  if (arg.startsWith("--ws=")) {
29
29
  const value = Number(arg.slice(5));
package/build/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import "./providerState-CLCXHs37.mjs";
2
2
  import { bindCoreFileAccessorToClientVfs, createClientVfsFileSystem, createWebgalVirtualCode, updateWebgalVirtualCode } from "./utils.mjs";
3
- import { i as registerConnectionHandlers, n as applyServerCapabilities, r as createWebgalService, t as applyClientCapabilities } from "./onInitialize-DIUUrHI3.mjs";
3
+ import { i as registerConnectionHandlers, n as applyServerCapabilities, r as createWebgalService, t as applyClientCapabilities } from "./onInitialize-DLHBz6ds.mjs";
4
4
  import { createConnection, createServer, createSimpleProject } from "@volar/language-server/node";
5
5
  import { createConnection as createConnection$1 } from "vscode-languageserver/node";
6
6
 
@@ -22,8 +22,8 @@ async function startWebSocketServer(options) {
22
22
  });
23
23
  }
24
24
  function getWsOptions(argv) {
25
- let port = Number(process.env.WEBGAL_LSP_WS_PORT ?? 3001);
26
- let path = process.env.WEBGAL_LSP_WS_PATH ?? "/webgal-lsp";
25
+ let port = 5882;
26
+ let path = "/webgal-lsp";
27
27
  for (const arg of argv) {
28
28
  if (arg.startsWith("--ws=")) {
29
29
  const value = Number(arg.slice(5));
@@ -1,5 +1,6 @@
1
1
  const require_utils = require('./utils.cjs');
2
2
  let _volar_language_server = require("@volar/language-server");
3
+ let vscode_uri = require("vscode-uri");
3
4
 
4
5
  //#region src/events/onDid.ts
5
6
  var onDid_default = function(documents, connection) {
@@ -11,6 +12,9 @@ var onDid_default = function(documents, connection) {
11
12
  else require_utils.setGlobalSettings(change.settings.XRWebGalLanguageServer || require_utils.defaultSettings);
12
13
  connection.languages.diagnostics.refresh();
13
14
  });
15
+ connection.onNotification("webgal/vfsChanged", () => {
16
+ connection.sendRequest("workspace/documentLink/refresh");
17
+ });
14
18
  };
15
19
 
16
20
  //#endregion
@@ -1294,6 +1298,11 @@ function provideDefinition(document, position, definitionMap) {
1294
1298
  //#endregion
1295
1299
  //#region src/events/onDocumentLinks.ts
1296
1300
  async function provideDocumentLinks(document, connection, candidates) {
1301
+ const toFileTarget = (path) => {
1302
+ if (!path) return;
1303
+ if (path.startsWith("file://")) return vscode_uri.URI.parse(path).toString();
1304
+ return vscode_uri.URI.file(path).toString();
1305
+ };
1297
1306
  const pathArray = document.uri.split("/");
1298
1307
  const currentDirectory = await connection.sendRequest("client/currentDirectory");
1299
1308
  const documentLinks = [];
@@ -1305,12 +1314,21 @@ async function provideDocumentLinks(document, connection, candidates) {
1305
1314
  let targetPath;
1306
1315
  if (isConfig) targetPath = await connection.sendRequest("client/FJoin", currentDirectory + "/");
1307
1316
  else targetPath = await connection.sendRequest("client/FJoin", currentDirectory + "/" + dirResources);
1308
- let basePath = await connection.sendRequest("client/FJoin", targetPath + "/" + matchText);
1309
- if (!await connection.sendRequest("client/FStat", basePath)) basePath = await connection.sendRequest("client/findFile", [currentDirectory, matchText]);
1317
+ const defaultPath = await connection.sendRequest("client/FJoin", targetPath + "/" + matchText);
1318
+ let stat = await connection.sendRequest("client/FStat", defaultPath);
1319
+ let resolvedPath = defaultPath;
1320
+ if (!stat) {
1321
+ const foundPath = await connection.sendRequest("client/findFile", [currentDirectory, matchText]);
1322
+ if (foundPath) {
1323
+ resolvedPath = foundPath;
1324
+ stat = await connection.sendRequest("client/FStat", resolvedPath);
1325
+ }
1326
+ }
1327
+ const tooltip = stat && resolvedPath ? resolvedPath : "unknown file";
1310
1328
  documentLinks.push({
1311
- target: "file:///" + basePath,
1329
+ target: toFileTarget(resolvedPath),
1312
1330
  range: _volar_language_server.Range.create(_volar_language_server.Position.create(candidate.line, candidate.start), _volar_language_server.Position.create(candidate.line, candidate.end)),
1313
- tooltip: basePath
1331
+ tooltip
1314
1332
  });
1315
1333
  }
1316
1334
  return [...documentLinks];
@@ -1,5 +1,6 @@
1
1
  import { StateConfig, defaultSettings, documentSettings, findTokenRange, getPatternAtPosition, getStageCompletionContext, getWebgalDefinitionMap, getWebgalDocumentLinkCandidates, getWebgalFoldingRanges, getWebgalLineCommandTypes, getWebgalSourceUriString, getWebgalVirtualCodeLines, getWebgalVirtualCodeText, getWordAtPosition, setGlobalSettings, validateTextDocument } from "./utils.mjs";
2
2
  import { CompletionItemKind, DidChangeConfigurationNotification, InsertTextFormat, LocationLink, MarkupKind, Position, Range, TextDocumentSyncKind } from "@volar/language-server";
3
+ import { URI } from "vscode-uri";
3
4
 
4
5
  //#region src/events/onDid.ts
5
6
  var onDid_default = function(documents, connection) {
@@ -11,6 +12,9 @@ var onDid_default = function(documents, connection) {
11
12
  else setGlobalSettings(change.settings.XRWebGalLanguageServer || defaultSettings);
12
13
  connection.languages.diagnostics.refresh();
13
14
  });
15
+ connection.onNotification("webgal/vfsChanged", () => {
16
+ connection.sendRequest("workspace/documentLink/refresh");
17
+ });
14
18
  };
15
19
 
16
20
  //#endregion
@@ -1294,6 +1298,11 @@ function provideDefinition(document, position, definitionMap) {
1294
1298
  //#endregion
1295
1299
  //#region src/events/onDocumentLinks.ts
1296
1300
  async function provideDocumentLinks(document, connection, candidates) {
1301
+ const toFileTarget = (path) => {
1302
+ if (!path) return;
1303
+ if (path.startsWith("file://")) return URI.parse(path).toString();
1304
+ return URI.file(path).toString();
1305
+ };
1297
1306
  const pathArray = document.uri.split("/");
1298
1307
  const currentDirectory = await connection.sendRequest("client/currentDirectory");
1299
1308
  const documentLinks = [];
@@ -1305,12 +1314,21 @@ async function provideDocumentLinks(document, connection, candidates) {
1305
1314
  let targetPath;
1306
1315
  if (isConfig) targetPath = await connection.sendRequest("client/FJoin", currentDirectory + "/");
1307
1316
  else targetPath = await connection.sendRequest("client/FJoin", currentDirectory + "/" + dirResources);
1308
- let basePath = await connection.sendRequest("client/FJoin", targetPath + "/" + matchText);
1309
- if (!await connection.sendRequest("client/FStat", basePath)) basePath = await connection.sendRequest("client/findFile", [currentDirectory, matchText]);
1317
+ const defaultPath = await connection.sendRequest("client/FJoin", targetPath + "/" + matchText);
1318
+ let stat = await connection.sendRequest("client/FStat", defaultPath);
1319
+ let resolvedPath = defaultPath;
1320
+ if (!stat) {
1321
+ const foundPath = await connection.sendRequest("client/findFile", [currentDirectory, matchText]);
1322
+ if (foundPath) {
1323
+ resolvedPath = foundPath;
1324
+ stat = await connection.sendRequest("client/FStat", resolvedPath);
1325
+ }
1326
+ }
1327
+ const tooltip = stat && resolvedPath ? resolvedPath : "unknown file";
1310
1328
  documentLinks.push({
1311
- target: "file:///" + basePath,
1329
+ target: toFileTarget(resolvedPath),
1312
1330
  range: Range.create(Position.create(candidate.line, candidate.start), Position.create(candidate.line, candidate.end)),
1313
- tooltip: basePath
1331
+ tooltip
1314
1332
  });
1315
1333
  }
1316
1334
  return [...documentLinks];
package/build/utils.cjs CHANGED
@@ -173,6 +173,8 @@ const analyzeWebgalFoldingRanges = (text) => {
173
173
  return foldingRanges;
174
174
  };
175
175
  const createWebgalVirtualCode = (scriptId, languageId, snapshot) => {
176
+ const originalId = scriptId.toString();
177
+ const normalizedId = originalId.toLowerCase();
176
178
  const length = snapshot.getLength();
177
179
  const text = getSnapshotText(snapshot);
178
180
  const lines = text.split(/\r?\n/);
@@ -181,7 +183,7 @@ const createWebgalVirtualCode = (scriptId, languageId, snapshot) => {
181
183
  const linkCandidates = analyzeWebgalDocumentLinks(lines);
182
184
  const foldingRanges = analyzeWebgalFoldingRanges(text);
183
185
  return {
184
- id: scriptId.toString(),
186
+ id: normalizedId,
185
187
  languageId,
186
188
  snapshot,
187
189
  mappings: [{
@@ -190,6 +192,7 @@ const createWebgalVirtualCode = (scriptId, languageId, snapshot) => {
190
192
  lengths: [length],
191
193
  data: fullCodeInformation
192
194
  }],
195
+ webgalOriginalId: originalId,
193
196
  webgalDefinitionMap: map,
194
197
  webgalDocumentLinkCandidates: linkCandidates,
195
198
  webgalFoldingRanges: foldingRanges,
package/build/utils.d.cts CHANGED
@@ -27,6 +27,7 @@ type WebgalVirtualCode = VirtualCode & {
27
27
  webgalFoldingRanges?: FoldingRange[];
28
28
  webgalLines?: string[];
29
29
  webgalLineCommandTypes?: string[];
30
+ webgalOriginalId?: string;
30
31
  };
31
32
  type WebgalDocumentLinkCandidate = {
32
33
  line: number;
package/build/utils.d.mts CHANGED
@@ -27,6 +27,7 @@ type WebgalVirtualCode = VirtualCode & {
27
27
  webgalFoldingRanges?: FoldingRange[];
28
28
  webgalLines?: string[];
29
29
  webgalLineCommandTypes?: string[];
30
+ webgalOriginalId?: string;
30
31
  };
31
32
  type WebgalDocumentLinkCandidate = {
32
33
  line: number;
package/build/utils.mjs CHANGED
@@ -172,6 +172,8 @@ const analyzeWebgalFoldingRanges = (text) => {
172
172
  return foldingRanges;
173
173
  };
174
174
  const createWebgalVirtualCode = (scriptId, languageId, snapshot) => {
175
+ const originalId = scriptId.toString();
176
+ const normalizedId = originalId.toLowerCase();
175
177
  const length = snapshot.getLength();
176
178
  const text = getSnapshotText(snapshot);
177
179
  const lines = text.split(/\r?\n/);
@@ -180,7 +182,7 @@ const createWebgalVirtualCode = (scriptId, languageId, snapshot) => {
180
182
  const linkCandidates = analyzeWebgalDocumentLinks(lines);
181
183
  const foldingRanges = analyzeWebgalFoldingRanges(text);
182
184
  return {
183
- id: scriptId.toString(),
185
+ id: normalizedId,
184
186
  languageId,
185
187
  snapshot,
186
188
  mappings: [{
@@ -189,6 +191,7 @@ const createWebgalVirtualCode = (scriptId, languageId, snapshot) => {
189
191
  lengths: [length],
190
192
  data: fullCodeInformation
191
193
  }],
194
+ webgalOriginalId: originalId,
192
195
  webgalDefinitionMap: map,
193
196
  webgalDocumentLinkCandidates: linkCandidates,
194
197
  webgalFoldingRanges: foldingRanges,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webgal/language-server",
3
- "version": "0.0.2-alpha.1",
3
+ "version": "0.0.2-alpha.3",
4
4
  "main": "build/index.cjs",
5
5
  "module": "build/index.mjs",
6
6
  "types": "build/index.d.mts",
@@ -43,7 +43,7 @@
43
43
  "build": "tsdown",
44
44
  "gen": "tsx scripts/gen.ts",
45
45
  "dev": "pnpm build && node bin/webgal-language-server.js --stdio",
46
- "dev:ws": "pnpm build && node bin/webgal-language-server.js --ws=3001",
46
+ "dev:ws": "pnpm build && node bin/webgal-language-server.js --ws",
47
47
  "format": " prettier --write \"src/**/*.ts\"",
48
48
  "lint": "eslint src --ext ts --fix",
49
49
  "typecheck": "tsc --noEmit",
@@ -55,7 +55,7 @@
55
55
  "@volar/language-service": "~2.4.0",
56
56
  "@volar/typescript": "~2.4.0",
57
57
  "@webgal/language-core": "0.0.2-alpha.1",
58
- "@webgal/language-service": "0.0.2-alpha.1",
58
+ "@webgal/language-service": "0.0.2-alpha.4",
59
59
  "tsc-alias": "^1.8.16",
60
60
  "vscode-languageserver": "^9.0.1",
61
61
  "vscode-languageserver-textdocument": "^1.0.11",
@@ -68,5 +68,5 @@
68
68
  "tsdown": "^0.20.3",
69
69
  "tsx": "^4.21.0"
70
70
  },
71
- "gitHead": "9f3a9d6bf3914857b2f87f4ea83821b1d544b2bd"
71
+ "gitHead": "8ae85838b6fd53666ccdedaa6a1afcf5d51451ce"
72
72
  }