@webgal/language-service 0.0.2-alpha.2 → 0.0.2-alpha.4

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.
@@ -1,3 +1,196 @@
1
- import { n as createWebgalMonacoLanguageClient, r as createWebgalMonacoLanguageClientWithWorker, t as initWebgalMonaco } from "../monaco-init-D6m312d3.mjs";
1
+ import { i as createVirtualFileSystem, n as registerWebgalClientHandlers, r as createMemoryVolarFileSystem, t as createWebgalClientHandlers } from "../client-handlers-CrU8stw6.mjs";
2
+ import { webgalConfigGrammar, webgalGrammar, webgalLanguageConfiguration } from "../syntaxes.mjs";
3
+ import { webgalDarkTheme, webgalWhiteTheme } from "../themes.mjs";
4
+ import { WebSocketMessageReader, WebSocketMessageWriter, toSocket } from "vscode-ws-jsonrpc";
5
+ import { BrowserMessageReader, BrowserMessageWriter, CloseAction, ErrorAction } from "vscode-languageclient/browser.js";
6
+ import { MonacoLanguageClient } from "monaco-languageclient";
7
+ import { initialize } from "@codingame/monaco-vscode-api";
8
+ import { ExtensionHostKind, registerExtension } from "@codingame/monaco-vscode-api/extensions";
9
+ import getLanguagesServiceOverride from "@codingame/monaco-vscode-languages-service-override";
10
+ import getThemeServiceOverride from "@codingame/monaco-vscode-theme-service-override";
11
+ import getTextMateServiceOverride from "@codingame/monaco-vscode-textmate-service-override";
12
+ import "vscode/localExtensionHost";
2
13
 
3
- export { createWebgalMonacoLanguageClient, createWebgalMonacoLanguageClientWithWorker, initWebgalMonaco };
14
+ //#region src/monaco/monaco.ts
15
+ function createMemoryFileSystem(options) {
16
+ return createVirtualFileSystem(createMemoryVolarFileSystem(options));
17
+ }
18
+ const createWebgalMonacoLanguageClient = (options) => {
19
+ const { languageServerUrl, editor } = options;
20
+ const editorInstance = editor;
21
+ const vfs = options.virtualFileSystem || createMemoryFileSystem({ root: "file:///game" });
22
+ if (!options.virtualFileSystem) {
23
+ vfs.writeFile("file:///game/scene/start.txt", "WebGal:Start;");
24
+ vfs.writeFile("file:///game/config.txt", "");
25
+ }
26
+ const webSocket = new WebSocket(languageServerUrl);
27
+ webSocket.onopen = () => {
28
+ const socket = toSocket(webSocket);
29
+ const reader = new WebSocketMessageReader(socket);
30
+ const languageClient = createLanguageClient({
31
+ reader,
32
+ writer: new WebSocketMessageWriter(socket)
33
+ }, {
34
+ editor: editorInstance,
35
+ vfs
36
+ });
37
+ languageClient.start();
38
+ reader.onClose(() => languageClient.stop());
39
+ };
40
+ return {
41
+ webSocket,
42
+ vfs
43
+ };
44
+ };
45
+ const createWebgalMonacoLanguageClientWithWorker = (options) => {
46
+ const { worker, editor } = options;
47
+ const editorInstance = editor;
48
+ const vfs = options.virtualFileSystem || createMemoryFileSystem({ root: "file:///game" });
49
+ if (!options.virtualFileSystem) {
50
+ vfs.writeFile("file:///game/scene/start.txt", "WebGal:Start;");
51
+ vfs.writeFile("file:///game/config.txt", "");
52
+ }
53
+ const languageClient = createLanguageClient({
54
+ reader: new BrowserMessageReader(worker),
55
+ writer: new BrowserMessageWriter(worker)
56
+ }, {
57
+ editor: editorInstance,
58
+ vfs
59
+ });
60
+ languageClient.start();
61
+ worker.onerror = () => languageClient.stop();
62
+ worker.onmessageerror = () => languageClient.stop();
63
+ return {
64
+ worker,
65
+ vfs
66
+ };
67
+ };
68
+ const createLanguageClient = (messageTransports, options) => {
69
+ const handlers = createWebgalClientHandlers({
70
+ vfs: options.vfs,
71
+ overrides: {
72
+ "client/showTip": function(message) {
73
+ console.log(message);
74
+ },
75
+ "workspace/documentLink/refresh": () => {
76
+ const model = options.editor.getModel();
77
+ if (!model) return null;
78
+ options.editor.setModel(model);
79
+ return null;
80
+ }
81
+ }
82
+ });
83
+ const client = new MonacoLanguageClient({
84
+ name: "WebGAL Language Client",
85
+ clientOptions: {
86
+ documentSelector: [
87
+ {
88
+ scheme: "file",
89
+ language: "webgal"
90
+ },
91
+ {
92
+ scheme: "file",
93
+ language: "webgal-config"
94
+ },
95
+ {
96
+ scheme: "inmemory",
97
+ language: "webgal"
98
+ },
99
+ {
100
+ scheme: "inmemory",
101
+ language: "webgal-config"
102
+ }
103
+ ],
104
+ errorHandler: {
105
+ error: () => ({ action: ErrorAction.Continue }),
106
+ closed: () => ({ action: CloseAction.DoNotRestart })
107
+ },
108
+ synchronize: { configurationSection: ["webgal", "http"] },
109
+ initializationOptions() {
110
+ const model = options.editor.getModel();
111
+ return {
112
+ processId: Math.random(),
113
+ rootPath: "file:///game",
114
+ rootUri: "file:///game",
115
+ capabilities: {},
116
+ workspaceFolders: [{
117
+ uri: "file:///game",
118
+ name: "example"
119
+ }],
120
+ ...model ? { textDocument: { uri: model.uri.toString() } } : {}
121
+ };
122
+ }
123
+ },
124
+ messageTransports
125
+ });
126
+ registerWebgalClientHandlers(client, handlers);
127
+ options.vfs.onDidChange(() => {
128
+ client.sendNotification("webgal/vfsChanged");
129
+ });
130
+ return client;
131
+ };
132
+
133
+ //#endregion
134
+ //#region src/monaco/monaco-init.ts
135
+ let initPromise = null;
136
+ const initResources = {
137
+ "./webgal.tmLanguage.json": webgalGrammar,
138
+ "./webgal-config.tmLanguage.json": webgalConfigGrammar,
139
+ "./language-configuration.json": webgalLanguageConfiguration,
140
+ "./dark.json": webgalDarkTheme,
141
+ "./white.json": webgalWhiteTheme
142
+ };
143
+ async function initWebgalMonaco() {
144
+ if (initPromise) return initPromise;
145
+ initPromise = (async () => {
146
+ const { registerFileUrl } = registerExtension({
147
+ name: "webgal",
148
+ publisher: "openwebgal",
149
+ version: "1.0.0",
150
+ engines: { vscode: "^1.0.0" },
151
+ activationEvents: ["onLanguage:webgal", "onLanguage:webgal-config"],
152
+ contributes: {
153
+ languages: [{
154
+ id: "webgal",
155
+ extensions: [".webgal"],
156
+ aliases: ["WebGAL"],
157
+ configuration: "./language-configuration.json"
158
+ }, {
159
+ id: "webgal-config",
160
+ extensions: [".webgal-config"],
161
+ aliases: ["WebGAL Config"]
162
+ }],
163
+ grammars: [{
164
+ language: "webgal",
165
+ scopeName: "source.webgal",
166
+ path: "./webgal.tmLanguage.json"
167
+ }, {
168
+ language: "webgal-config",
169
+ scopeName: "source.webgal-config",
170
+ path: "./webgal-config.tmLanguage.json"
171
+ }],
172
+ themes: [{
173
+ id: "webgal-dark",
174
+ label: "WebGAL Dark",
175
+ uiTheme: "vs-dark",
176
+ path: "./dark.json"
177
+ }, {
178
+ id: "webgal-white",
179
+ label: "WebGAL White",
180
+ uiTheme: "vs",
181
+ path: "./white.json"
182
+ }]
183
+ }
184
+ }, ExtensionHostKind.LocalProcess);
185
+ for (const [key, value] of Object.entries(initResources)) registerFileUrl(key, new URL("data:application/json;base64," + btoa(decodeURIComponent(encodeURIComponent(JSON.stringify(value)))), import.meta.url).href);
186
+ await initialize({
187
+ ...getTextMateServiceOverride(),
188
+ ...getThemeServiceOverride(),
189
+ ...getLanguagesServiceOverride()
190
+ });
191
+ })();
192
+ return initPromise;
193
+ }
194
+
195
+ //#endregion
196
+ export { createMemoryFileSystem, createWebgalMonacoLanguageClient, createWebgalMonacoLanguageClientWithWorker, initResources, initWebgalMonaco };
package/build/node.d.cts CHANGED
@@ -1,5 +1,4 @@
1
- import { C as VirtualFileSystem } from "./monaco-init-DUnVu1qx.cjs";
2
- import "./index.cjs";
1
+ import { c as VirtualFileSystem } from "./types-BPQnQEAd.cjs";
3
2
 
4
3
  //#region src/node.d.ts
5
4
  type NodeFileSystemOptions = {
package/build/node.d.mts CHANGED
@@ -1,5 +1,4 @@
1
- import { C as VirtualFileSystem } from "./monaco-init-BR2AgVuN.mjs";
2
- import "./index.mjs";
1
+ import { c as VirtualFileSystem } from "./types-FltMUZDB.mjs";
3
2
 
4
3
  //#region src/node.d.ts
5
4
  type NodeFileSystemOptions = {
@@ -1,7 +1,5 @@
1
- import { createMemoryFileSystem } from "./index.mjs";
2
1
  import { FileSystem } from "@volar/language-service";
3
2
  import { URI } from "vscode-uri";
4
- import "vscode/localExtensionHost";
5
3
 
6
4
  //#region src/vfs/types.d.ts
7
5
  type DirectoryEntry = {
@@ -65,6 +63,7 @@ type VirtualFileSystem = {
65
63
  onDidChange: (listener: VirtualFileSystemChangeListener) => () => void;
66
64
  };
67
65
  type WebgalClientHandlers = {
66
+ "workspace/documentLink/refresh": () => MaybePromise<unknown>;
68
67
  "client/showTip": (message: string) => MaybePromise<unknown>;
69
68
  "client/currentDirectory": () => MaybePromise<string | null>;
70
69
  "client/FJoin": (args: string | string[]) => MaybePromise<string | null>;
@@ -109,50 +108,4 @@ interface VolarWritableFileSystem extends FileSystem {
109
108
  root: string;
110
109
  }
111
110
  //#endregion
112
- //#region src/client-handlers.d.ts
113
- declare function createWebgalClientHandlers(options: CreateWebgalClientHandlersOptions): WebgalClientHandlers;
114
- declare function registerWebgalClientHandlers(client: LanguageClientLike, handlers: Partial<WebgalClientHandlers>): void;
115
- //#endregion
116
- //#region src/vfs/adapter.d.ts
117
- declare function createVirtualFileSystem(fs: VolarWritableFileSystem): VirtualFileSystem;
118
- declare function createVolarFileSystem(vfs: VirtualFileSystem, options?: {
119
- uriToPath?: (uri: URI) => string;
120
- }): FileSystem;
121
- //#endregion
122
- //#region src/vfs/memory.d.ts
123
- declare function createMemoryVolarFileSystem(options?: {
124
- root?: string;
125
- tree?: VirtualEntry;
126
- }): VolarWritableFileSystem;
127
- //#endregion
128
- //#region src/vfs/utils.d.ts
129
- declare const normalizePath: (input: string) => string;
130
- declare const joinPaths: (...parts: string[]) => string;
131
- declare const uriToPath: (value: string | URI) => string;
132
- declare const pathToUri: (path: string) => URI;
133
- declare const toVfsPath: (value: string) => string;
134
- //#endregion
135
- //#region src/monaco/monaco.d.ts
136
- interface CreateWebgalMonacoLanguageClientOptions {
137
- languageServerUrl: string;
138
- editor: any;
139
- virtualFileSystem?: ReturnType<typeof createMemoryFileSystem>;
140
- }
141
- declare const createWebgalMonacoLanguageClient: (options: CreateWebgalMonacoLanguageClientOptions) => {
142
- webSocket: WebSocket;
143
- vfs: ReturnType<typeof createMemoryFileSystem>;
144
- };
145
- interface CreateWebgalMonacoLanguageClientWorkerOptions {
146
- editor: any;
147
- worker: Worker;
148
- virtualFileSystem?: ReturnType<typeof createMemoryFileSystem>;
149
- }
150
- declare const createWebgalMonacoLanguageClientWithWorker: (options: CreateWebgalMonacoLanguageClientWorkerOptions) => {
151
- worker: Worker;
152
- vfs: ReturnType<typeof createMemoryFileSystem>;
153
- };
154
- //#endregion
155
- //#region src/monaco/monaco-init.d.ts
156
- declare function initWebgalMonaco(): Promise<void>;
157
- //#endregion
158
- export { VirtualFileSystem as C, WebgalClientHandlers as D, VolarWritableFileSystem as E, VirtualFileEntry as S, VirtualFileSystemChangeListener as T, DirectoryEntry as _, createWebgalMonacoLanguageClientWithWorker as a, VirtualDirectoryEntry as b, pathToUri as c, createMemoryVolarFileSystem as d, createVirtualFileSystem as f, CreateWebgalClientHandlersOptions as g, registerWebgalClientHandlers as h, createWebgalMonacoLanguageClient as i, toVfsPath as l, createWebgalClientHandlers as m, CreateWebgalMonacoLanguageClientOptions as n, joinPaths as o, createVolarFileSystem as p, CreateWebgalMonacoLanguageClientWorkerOptions as r, normalizePath as s, initWebgalMonaco as t, uriToPath as u, LanguageClientLike as v, VirtualFileSystemChange as w, VirtualEntry as x, MaybePromise as y };
111
+ export { VirtualDirectoryEntry as a, VirtualFileSystem as c, VolarWritableFileSystem as d, WebgalClientHandlers as f, MaybePromise as i, VirtualFileSystemChange as l, DirectoryEntry as n, VirtualEntry as o, LanguageClientLike as r, VirtualFileEntry as s, CreateWebgalClientHandlersOptions as t, VirtualFileSystemChangeListener as u };
@@ -1,7 +1,5 @@
1
- import { createMemoryFileSystem } from "./index.cjs";
2
1
  import { FileSystem } from "@volar/language-service";
3
2
  import { URI } from "vscode-uri";
4
- import "vscode/localExtensionHost";
5
3
 
6
4
  //#region src/vfs/types.d.ts
7
5
  type DirectoryEntry = {
@@ -65,6 +63,7 @@ type VirtualFileSystem = {
65
63
  onDidChange: (listener: VirtualFileSystemChangeListener) => () => void;
66
64
  };
67
65
  type WebgalClientHandlers = {
66
+ "workspace/documentLink/refresh": () => MaybePromise<unknown>;
68
67
  "client/showTip": (message: string) => MaybePromise<unknown>;
69
68
  "client/currentDirectory": () => MaybePromise<string | null>;
70
69
  "client/FJoin": (args: string | string[]) => MaybePromise<string | null>;
@@ -109,50 +108,4 @@ interface VolarWritableFileSystem extends FileSystem {
109
108
  root: string;
110
109
  }
111
110
  //#endregion
112
- //#region src/client-handlers.d.ts
113
- declare function createWebgalClientHandlers(options: CreateWebgalClientHandlersOptions): WebgalClientHandlers;
114
- declare function registerWebgalClientHandlers(client: LanguageClientLike, handlers: Partial<WebgalClientHandlers>): void;
115
- //#endregion
116
- //#region src/vfs/adapter.d.ts
117
- declare function createVirtualFileSystem(fs: VolarWritableFileSystem): VirtualFileSystem;
118
- declare function createVolarFileSystem(vfs: VirtualFileSystem, options?: {
119
- uriToPath?: (uri: URI) => string;
120
- }): FileSystem;
121
- //#endregion
122
- //#region src/vfs/memory.d.ts
123
- declare function createMemoryVolarFileSystem(options?: {
124
- root?: string;
125
- tree?: VirtualEntry;
126
- }): VolarWritableFileSystem;
127
- //#endregion
128
- //#region src/vfs/utils.d.ts
129
- declare const normalizePath: (input: string) => string;
130
- declare const joinPaths: (...parts: string[]) => string;
131
- declare const uriToPath: (value: string | URI) => string;
132
- declare const pathToUri: (path: string) => URI;
133
- declare const toVfsPath: (value: string) => string;
134
- //#endregion
135
- //#region src/monaco/monaco.d.ts
136
- interface CreateWebgalMonacoLanguageClientOptions {
137
- languageServerUrl: string;
138
- editor: any;
139
- virtualFileSystem?: ReturnType<typeof createMemoryFileSystem>;
140
- }
141
- declare const createWebgalMonacoLanguageClient: (options: CreateWebgalMonacoLanguageClientOptions) => {
142
- webSocket: WebSocket;
143
- vfs: ReturnType<typeof createMemoryFileSystem>;
144
- };
145
- interface CreateWebgalMonacoLanguageClientWorkerOptions {
146
- editor: any;
147
- worker: Worker;
148
- virtualFileSystem?: ReturnType<typeof createMemoryFileSystem>;
149
- }
150
- declare const createWebgalMonacoLanguageClientWithWorker: (options: CreateWebgalMonacoLanguageClientWorkerOptions) => {
151
- worker: Worker;
152
- vfs: ReturnType<typeof createMemoryFileSystem>;
153
- };
154
- //#endregion
155
- //#region src/monaco/monaco-init.d.ts
156
- declare function initWebgalMonaco(): Promise<void>;
157
- //#endregion
158
- export { VirtualFileSystem as C, WebgalClientHandlers as D, VolarWritableFileSystem as E, VirtualFileEntry as S, VirtualFileSystemChangeListener as T, DirectoryEntry as _, createWebgalMonacoLanguageClientWithWorker as a, VirtualDirectoryEntry as b, pathToUri as c, createMemoryVolarFileSystem as d, createVirtualFileSystem as f, CreateWebgalClientHandlersOptions as g, registerWebgalClientHandlers as h, createWebgalMonacoLanguageClient as i, toVfsPath as l, createWebgalClientHandlers as m, CreateWebgalMonacoLanguageClientOptions as n, joinPaths as o, createVolarFileSystem as p, CreateWebgalMonacoLanguageClientWorkerOptions as r, normalizePath as s, initWebgalMonaco as t, uriToPath as u, LanguageClientLike as v, VirtualFileSystemChange as w, VirtualEntry as x, MaybePromise as y };
111
+ export { VirtualDirectoryEntry as a, VirtualFileSystem as c, VolarWritableFileSystem as d, WebgalClientHandlers as f, MaybePromise as i, VirtualFileSystemChange as l, DirectoryEntry as n, VirtualEntry as o, LanguageClientLike as r, VirtualFileEntry as s, CreateWebgalClientHandlersOptions as t, VirtualFileSystemChangeListener as u };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webgal/language-service",
3
- "version": "0.0.2-alpha.2",
3
+ "version": "0.0.2-alpha.4",
4
4
  "type": "module",
5
5
  "main": "build/index.cjs",
6
6
  "module": "build/index.mjs",
@@ -26,14 +26,9 @@
26
26
  "require": "./build/node.cjs"
27
27
  },
28
28
  "./monaco": {
29
- "types": "./build/monaco.d.mts",
30
- "import": "./build/monaco.mjs",
31
- "require": "./build/monaco.cjs"
32
- },
33
- "./monaco-init": {
34
- "types": "./build/monaco-init.d.mts",
35
- "import": "./build/monaco-init.mjs",
36
- "require": "./build/monaco-init.cjs"
29
+ "types": "./build/monaco/index.d.mts",
30
+ "import": "./build/monaco/index.mjs",
31
+ "require": "./build/monaco/index.cjs"
37
32
  },
38
33
  "./syntaxes": {
39
34
  "types": "./build/syntaxes.d.mts",
@@ -55,7 +50,6 @@
55
50
  },
56
51
  "devDependencies": {
57
52
  "@types/node": "^18.0.0",
58
- "monaco-editor": "^0.55.1",
59
53
  "tsdown": "^0.20.3"
60
54
  },
61
55
  "dependencies": {
@@ -65,11 +59,12 @@
65
59
  "@codingame/monaco-vscode-theme-service-override": "^26.1.1",
66
60
  "@volar/language-core": "^2.4.28",
67
61
  "@volar/language-service": "^2.4.28",
62
+ "monaco-editor": "npm:@codingame/monaco-vscode-editor-api@^26.1.1",
68
63
  "monaco-languageclient": "^10.7.0",
69
- "vscode": "npm:@codingame/monaco-vscode-extension-api@26.1.1",
64
+ "vscode": "npm:@codingame/monaco-vscode-extension-api@^26.1.1",
70
65
  "vscode-languageclient": "^9.0.1",
71
66
  "vscode-uri": "^3.1.0",
72
67
  "vscode-ws-jsonrpc": "^3.5.0"
73
68
  },
74
- "gitHead": "db8b60d474455cb41023f70d804d44bb8b96f3be"
69
+ "gitHead": "8ae85838b6fd53666ccdedaa6a1afcf5d51451ce"
75
70
  }