monaco-languageclient 9.11.0 → 10.0.0-next.1

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 (140) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/lib/{commonTypes.d.ts → common/commonTypes.d.ts} +2 -2
  3. package/lib/common/commonTypes.d.ts.map +1 -0
  4. package/lib/common/commonTypes.js +6 -0
  5. package/lib/common/commonTypes.js.map +1 -0
  6. package/lib/common/index.d.ts +4 -0
  7. package/lib/common/index.d.ts.map +1 -0
  8. package/lib/{tools → common}/index.js +1 -0
  9. package/lib/common/index.js.map +1 -0
  10. package/lib/common/logging.d.ts.map +1 -0
  11. package/lib/common/logging.js.map +1 -0
  12. package/lib/common/utils.d.ts +5 -0
  13. package/lib/common/utils.d.ts.map +1 -0
  14. package/lib/{tools → common}/utils.js +14 -0
  15. package/lib/common/utils.js.map +1 -0
  16. package/lib/editorApp/config.d.ts +55 -0
  17. package/lib/editorApp/config.d.ts.map +1 -0
  18. package/lib/editorApp/config.js +13 -0
  19. package/lib/editorApp/config.js.map +1 -0
  20. package/lib/editorApp/editorApp.d.ts +60 -0
  21. package/lib/editorApp/editorApp.d.ts.map +1 -0
  22. package/lib/editorApp/editorApp.js +394 -0
  23. package/lib/editorApp/editorApp.js.map +1 -0
  24. package/lib/editorApp/index.d.ts +3 -0
  25. package/lib/editorApp/index.d.ts.map +1 -0
  26. package/lib/editorApp/index.js +7 -0
  27. package/lib/editorApp/index.js.map +1 -0
  28. package/lib/fs/definitions.d.ts +1 -1
  29. package/lib/fs/definitions.d.ts.map +1 -1
  30. package/lib/fs/endpoints/defaultEndpoint.d.ts +1 -1
  31. package/lib/fs/endpoints/defaultEndpoint.d.ts.map +1 -1
  32. package/lib/index.d.ts +15 -2
  33. package/lib/index.d.ts.map +1 -1
  34. package/lib/index.js +18 -2
  35. package/lib/index.js.map +1 -1
  36. package/lib/vscode/apiWrapper.d.ts +62 -0
  37. package/lib/vscode/apiWrapper.d.ts.map +1 -0
  38. package/lib/vscode/apiWrapper.js +299 -0
  39. package/lib/vscode/apiWrapper.js.map +1 -0
  40. package/lib/vscode/config.d.ts +46 -0
  41. package/lib/vscode/config.d.ts.map +1 -0
  42. package/lib/vscode/config.js +7 -0
  43. package/lib/vscode/config.js.map +1 -0
  44. package/lib/vscode/index.d.ts +4 -2
  45. package/lib/vscode/index.d.ts.map +1 -1
  46. package/lib/vscode/index.js +4 -2
  47. package/lib/vscode/index.js.map +1 -1
  48. package/lib/vscode/locales.d.ts +5 -0
  49. package/lib/vscode/locales.d.ts.map +1 -0
  50. package/lib/vscode/locales.js +124 -0
  51. package/lib/vscode/locales.js.map +1 -0
  52. package/lib/vscode/utils.d.ts +13 -0
  53. package/lib/vscode/utils.d.ts.map +1 -0
  54. package/lib/vscode/utils.js +56 -0
  55. package/lib/vscode/utils.js.map +1 -0
  56. package/lib/vscode/viewsService.d.ts +4 -0
  57. package/lib/vscode/viewsService.d.ts.map +1 -0
  58. package/lib/vscode/viewsService.js +67 -0
  59. package/lib/vscode/viewsService.js.map +1 -0
  60. package/lib/{vscode → worker}/fakeWorker.d.ts.map +1 -1
  61. package/lib/{vscode → worker}/fakeWorker.js.map +1 -1
  62. package/lib/worker/index.d.ts +4 -0
  63. package/lib/worker/index.d.ts.map +1 -0
  64. package/lib/worker/index.js +8 -0
  65. package/lib/worker/index.js.map +1 -0
  66. package/lib/{workerFactory.d.ts → worker/workerFactory.d.ts} +1 -1
  67. package/lib/worker/workerFactory.d.ts.map +1 -0
  68. package/lib/{workerFactory.js → worker/workerFactory.js} +1 -1
  69. package/lib/worker/workerFactory.js.map +1 -0
  70. package/lib/worker/workerLoaders.d.ts +5 -0
  71. package/lib/worker/workerLoaders.d.ts.map +1 -0
  72. package/lib/worker/workerLoaders.js +26 -0
  73. package/lib/worker/workerLoaders.js.map +1 -0
  74. package/lib/wrapper/index.d.ts +4 -0
  75. package/lib/wrapper/index.d.ts.map +1 -0
  76. package/lib/wrapper/index.js +8 -0
  77. package/lib/wrapper/index.js.map +1 -0
  78. package/lib/wrapper/lcconfig.d.ts +24 -0
  79. package/lib/wrapper/lcconfig.d.ts.map +1 -0
  80. package/lib/wrapper/lcconfig.js +6 -0
  81. package/lib/wrapper/lcconfig.js.map +1 -0
  82. package/lib/wrapper/lcmanager.d.ts +18 -0
  83. package/lib/wrapper/lcmanager.d.ts.map +1 -0
  84. package/lib/wrapper/lcmanager.js +75 -0
  85. package/lib/wrapper/lcmanager.js.map +1 -0
  86. package/lib/wrapper/lcwrapper.d.ts +37 -0
  87. package/lib/wrapper/lcwrapper.d.ts.map +1 -0
  88. package/lib/wrapper/lcwrapper.js +247 -0
  89. package/lib/wrapper/lcwrapper.js.map +1 -0
  90. package/package.json +61 -18
  91. package/src/{commonTypes.ts → common/commonTypes.ts} +2 -2
  92. package/src/{tools → common}/index.ts +1 -0
  93. package/src/{tools → common}/utils.ts +16 -1
  94. package/src/editorApp/config.ts +67 -0
  95. package/src/editorApp/editorApp.ts +448 -0
  96. package/{lib/commonTypes.js → src/editorApp/index.ts} +3 -2
  97. package/src/fs/definitions.ts +1 -1
  98. package/src/fs/endpoints/defaultEndpoint.ts +1 -1
  99. package/src/index.ts +29 -2
  100. package/src/vscode/apiWrapper.ts +341 -0
  101. package/src/vscode/config.ts +55 -0
  102. package/src/vscode/index.ts +4 -2
  103. package/src/vscode/locales.ts +128 -0
  104. package/src/vscode/utils.ts +67 -0
  105. package/src/vscode/viewsService.ts +73 -0
  106. package/src/worker/index.ts +8 -0
  107. package/src/{workerFactory.ts → worker/workerFactory.ts} +2 -2
  108. package/src/worker/workerLoaders.ts +36 -0
  109. package/src/wrapper/index.ts +8 -0
  110. package/src/wrapper/lcconfig.ts +32 -0
  111. package/src/wrapper/lcmanager.ts +89 -0
  112. package/src/wrapper/lcwrapper.ts +280 -0
  113. package/lib/client.d.ts +0 -13
  114. package/lib/client.d.ts.map +0 -1
  115. package/lib/client.js +0 -16
  116. package/lib/client.js.map +0 -1
  117. package/lib/commonTypes.d.ts.map +0 -1
  118. package/lib/commonTypes.js.map +0 -1
  119. package/lib/tools/index.d.ts +0 -3
  120. package/lib/tools/index.d.ts.map +0 -1
  121. package/lib/tools/index.js.map +0 -1
  122. package/lib/tools/logging.d.ts.map +0 -1
  123. package/lib/tools/logging.js.map +0 -1
  124. package/lib/tools/utils.d.ts +0 -3
  125. package/lib/tools/utils.d.ts.map +0 -1
  126. package/lib/tools/utils.js.map +0 -1
  127. package/lib/vscode/services.d.ts +0 -64
  128. package/lib/vscode/services.d.ts.map +0 -1
  129. package/lib/vscode/services.js +0 -192
  130. package/lib/vscode/services.js.map +0 -1
  131. package/lib/workerFactory.d.ts.map +0 -1
  132. package/lib/workerFactory.js.map +0 -1
  133. package/src/client.ts +0 -26
  134. package/src/vscode/services.ts +0 -249
  135. /package/lib/{tools → common}/logging.d.ts +0 -0
  136. /package/lib/{tools → common}/logging.js +0 -0
  137. /package/lib/{vscode → worker}/fakeWorker.d.ts +0 -0
  138. /package/lib/{vscode → worker}/fakeWorker.js +0 -0
  139. /package/src/{tools → common}/logging.ts +0 -0
  140. /package/src/{vscode → worker}/fakeWorker.ts +0 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  All notable changes to this npm module are documented in this file.
4
4
 
5
+ ## [10.0.0] - unreleased
6
+
7
+ - Move MonacoLanguageClientWrapper to monaco-languageclient [#920](https://github.com/TypeFox/monaco-languageclient/pull/920).
8
+
5
9
  ## [9.11.0] - 2025-08-21
6
10
 
7
11
  - Updated all `@codingame/monaco-vscode` packages to `20.2.1`.
@@ -1,8 +1,8 @@
1
- import type { MonacoLanguageClient } from './client.js';
1
+ import { BaseLanguageClient } from 'vscode-languageclient/browser.js';
2
2
  export type ConnectionConfigOptions = WebSocketConfigOptionsDirect | WebSocketConfigOptionsParams | WebSocketConfigOptionsUrl | WorkerConfigOptionsParams | WorkerConfigOptionsDirect;
3
3
  export interface WebSocketCallOptions {
4
4
  /** Adds handle on languageClient */
5
- onCall: (languageClient?: MonacoLanguageClient) => void;
5
+ onCall: (languageClient?: BaseLanguageClient) => void;
6
6
  /** Reports Status Of Language Client */
7
7
  reportStatus?: boolean;
8
8
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commonTypes.d.ts","sourceRoot":"","sources":["../../src/common/commonTypes.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AAEtE,MAAM,MAAM,uBAAuB,GAAG,4BAA4B,GAAG,4BAA4B,GAAG,yBAAyB,GAAG,yBAAyB,GAAG,yBAAyB,CAAC;AAEtL,MAAM,WAAW,oBAAoB;IACjC,oCAAoC;IACpC,MAAM,EAAE,CAAC,cAAc,CAAC,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACtD,wCAAwC;IACxC,YAAY,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,4BAA4B;IACzC,KAAK,EAAE,iBAAiB,CAAA;IACxB,SAAS,EAAE,SAAS,CAAA;IACpB,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC,WAAW,CAAC,EAAE,oBAAoB,CAAC;CACtC;AAED,MAAM,WAAW,kBAAkB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC;CAC1E;AAED,MAAM,WAAW,4BAA6B,SAAQ,kBAAkB;IACpE,KAAK,EAAE,iBAAiB,CAAA;IACxB,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC,WAAW,CAAC,EAAE,oBAAoB,CAAC;CACtC;AAED,MAAM,WAAW,kBAAkB;IAC/B,GAAG,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,yBAA0B,SAAQ,kBAAkB;IACjE,KAAK,EAAE,cAAc,CAAA;IACrB,YAAY,CAAC,EAAE,oBAAoB,CAAC;IACpC,WAAW,CAAC,EAAE,oBAAoB,CAAC;CACtC;AAED,MAAM,WAAW,yBAAyB;IACtC,KAAK,EAAE,cAAc,CAAA;IACrB,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC3B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,yBAAyB;IACtC,KAAK,EAAE,cAAc,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,WAAW,CAAC;CAC7B"}
@@ -0,0 +1,6 @@
1
+ /* --------------------------------------------------------------------------------------------
2
+ * Copyright (c) 2024 TypeFox and others.
3
+ * Licensed under the MIT License. See LICENSE in the package root for license information.
4
+ * ------------------------------------------------------------------------------------------ */
5
+ import { BaseLanguageClient } from 'vscode-languageclient/browser.js';
6
+ //# sourceMappingURL=commonTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commonTypes.js","sourceRoot":"","sources":["../../src/common/commonTypes.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './commonTypes.js';
2
+ export * from './logging.js';
3
+ export * from './utils.js';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAKA,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
@@ -2,6 +2,7 @@
2
2
  * Copyright (c) 2024 TypeFox and others.
3
3
  * Licensed under the MIT License. See LICENSE in the package root for license information.
4
4
  * ------------------------------------------------------------------------------------------ */
5
+ export * from './commonTypes.js';
5
6
  export * from './logging.js';
6
7
  export * from './utils.js';
7
8
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/common/index.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../src/common/logging.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,IAAI,mBAAmB,EAAE,KAAK,OAAO,EAAE,MAAM,+CAA+C,CAAC;AACnH,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAExD,MAAM,WAAW,MAAO,SAAQ,OAAO;IACnC,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;CACnE;AAED,qBAAa,aAAc,SAAQ,mBAAmB;gBAEtC,QAAQ,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,OAAO;IAIpD,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE;CAO1D"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.js","sourceRoot":"","sources":["../../src/common/logging.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,IAAI,mBAAmB,EAAgB,MAAM,+CAA+C,CAAC;AACnH,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAMxD,MAAM,OAAO,aAAc,SAAQ,mBAAmB;IAElD,YAAY,QAAmB,EAAE,SAAmB;QAChD,KAAK,CAAC,QAAQ,IAAI,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC/C,CAAC;IAED,iBAAiB,CAAC,OAAe,EAAE,GAAG,MAAiB;QACnD,IAAI,IAAI,CAAC,QAAQ,EAAE,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;YACpC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;CAEJ"}
@@ -0,0 +1,5 @@
1
+ import type { WebSocketUrlParams, WebSocketUrlString } from './commonTypes.js';
2
+ export declare const createUrl: (config: WebSocketUrlParams | WebSocketUrlString) => string;
3
+ export declare const encodeStringOrUrlToDataUrl: (input: string | URL) => string;
4
+ export declare const delayExecution: (ms: number) => Promise<unknown>;
5
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/common/utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE/E,eAAO,MAAM,SAAS,GAAI,QAAQ,kBAAkB,GAAG,kBAAkB,WA+BxE,CAAC;AAEF,eAAO,MAAM,0BAA0B,GAAI,OAAO,MAAM,GAAG,GAAG,WAS7D,CAAC;AAEF,eAAO,MAAM,cAAc,GAAI,IAAI,MAAM,qBAExC,CAAC"}
@@ -33,4 +33,18 @@ export const createUrl = (config) => {
33
33
  }
34
34
  return buildUrl;
35
35
  };
36
+ export const encodeStringOrUrlToDataUrl = (input) => {
37
+ if (input instanceof URL) {
38
+ return input.href;
39
+ }
40
+ else {
41
+ const bytes = new TextEncoder().encode(input);
42
+ const binString = Array.from(bytes, (b) => String.fromCodePoint(b)).join('');
43
+ const base64 = btoa(binString);
44
+ return new URL(`data:text/plain;base64,${base64}`).href;
45
+ }
46
+ };
47
+ export const delayExecution = (ms) => {
48
+ return new Promise((resolve) => setTimeout(resolve, ms));
49
+ };
36
50
  //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @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co-vscode-api/monaco';
3
+ import * as monaco from '@codingame/monaco-vscode-editor-api';
4
+ import type { IReference } from '@codingame/monaco-vscode-editor-service-override';
5
+ import { type OverallConfigType } from 'monaco-languageclient/vscodeApiWrapper';
6
+ export declare class ModelRefs {
7
+ modified?: IReference<ITextFileEditorModel>;
8
+ original?: IReference<ITextFileEditorModel>;
9
+ }
10
+ export interface TextModels {
11
+ modified?: monaco.editor.ITextModel | null;
12
+ original?: monaco.editor.ITextModel | null;
13
+ }
14
+ export interface TextContents {
15
+ modified?: string;
16
+ original?: string;
17
+ }
18
+ export interface CodeContent {
19
+ text: string;
20
+ uri: string;
21
+ enforceLanguageId?: string;
22
+ }
23
+ export interface CodeResources {
24
+ modified?: CodeContent;
25
+ original?: CodeContent;
26
+ }
27
+ export interface CallbackDisposeable {
28
+ modified?: monaco.IDisposable;
29
+ original?: monaco.IDisposable;
30
+ }
31
+ export interface DisposableModelRefs {
32
+ modified?: IReference<ITextFileEditorModel>;
33
+ original?: IReference<ITextFileEditorModel>;
34
+ }
35
+ export interface EditorAppConfig {
36
+ id?: string;
37
+ $type?: OverallConfigType;
38
+ logLevel?: LogLevel | number;
39
+ codeResources?: CodeResources;
40
+ useDiffEditor?: boolean;
41
+ domReadOnly?: boolean;
42
+ readOnly?: boolean;
43
+ overrideAutomaticLayout?: boolean;
44
+ editorOptions?: monaco.editor.IStandaloneEditorConstructionOptions;
45
+ diffEditorOptions?: monaco.editor.IStandaloneDiffEditorConstructionOptions;
46
+ languageDef?: {
47
+ languageExtensionConfig: monaco.languages.ILanguageExtensionPoint;
48
+ monarchLanguage?: monaco.languages.IMonarchLanguage;
49
+ theme?: {
50
+ name: monaco.editor.BuiltinTheme | string;
51
+ data: monaco.editor.IStandaloneThemeData;
52
+ };
53
+ };
54
+ }
55
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/editorApp/config.ts"],"names":[],"mappings":"AAKA,OA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,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,CAAC,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC7B,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,oCAAoC,CAAC;IACnE,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,wCAAwC,CAAC;IAC3E,WAAW,CAAC,EAAE;QACV,uBAAuB,EAAE,MAAM,CAAC,SAAS,CAAC,uBAAuB,CAAC;QAClE,eAAe,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC;QACpD,KAAK,CAAC,EAAE;YACJ,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC;YAC1C,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,oBAAoB,CAAC;SAC5C,CAAA;KACJ,CAAA;CACJ"}
@@ -0,0 +1,13 @@
1
+ /* --------------------------------------------------------------------------------------------
2
+ * Copyright (c) 2025 TypeFox and others.
3
+ * Licensed under the MIT License. See LICENSE in the package root for license information.
4
+ * ------------------------------------------------------------------------------------------ */
5
+ import { LogLevel } from '@codingame/monaco-vscode-api';
6
+ import {} from '@codingame/monaco-vscode-api/monaco';
7
+ import * as monaco from '@codingame/monaco-vscode-editor-api';
8
+ import {} from 'monaco-languageclient/vscodeApiWrapper';
9
+ export class ModelRefs {
10
+ modified;
11
+ original;
12
+ }
13
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/editorApp/config.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAA6B,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,MAAM,MAAM,qCAAqC,CAAC;AAE9D,OAAO,EAA0B,MAAM,wCAAwC,CAAC;AAEhF,MAAM,OAAO,SAAS;IAClB,QAAQ,CAAoC;IAC5C,QAAQ,CAAoC;CAC/C"}
@@ -0,0 +1,60 @@
1
+ import { type ITextFileEditorModel } from '@codingame/monaco-vscode-api/monaco';
2
+ import * as monaco from '@codingame/monaco-vscode-editor-api';
3
+ import type { IReference } from '@codingame/monaco-vscode-editor-service-override';
4
+ import { type Logger } from 'monaco-languageclient/common';
5
+ import type { CodeContent, CodeResources, EditorAppConfig, TextContents, TextModels } from './config.js';
6
+ /**
7
+ * This is the base class for both Monaco Editor Apps:
8
+ * - EditorAppClassic
9
+ * - EditorAppExtended
10
+ *
11
+ * It provides the generic functionality for both implementations.
12
+ */
13
+ export declare class EditorApp {
14
+ private $type;
15
+ private id;
16
+ private config;
17
+ protected logger: Logger;
18
+ private editor;
19
+ private diffEditor;
20
+ private modelRefs;
21
+ private onTextChanged?;
22
+ private textChangedDisposables;
23
+ private modelDisposables;
24
+ private modelRefDisposeTimeout;
25
+ private startingAwait?;
26
+ private disposingAwait?;
27
+ constructor(userAppConfig?: EditorAppConfig);
28
+ isDiffEditor(): boolean;
29
+ getConfig(): EditorAppConfig;
30
+ getEditor(): monaco.editor.IStandaloneCodeEditor | undefined;
31
+ getDiffEditor(): monaco.editor.IStandaloneDiffEditor | undefined;
32
+ getTextModels(): TextModels;
33
+ getLogger(): Logger;
34
+ registerOnTextChangedCallback(onTextChanged?: (textChanges: TextContents) => void): void;
35
+ setModelRefDisposeTimeout(modelRefDisposeTimeout: number): void;
36
+ isStarting(): boolean;
37
+ getStartingAwait(): Promise<void> | undefined;
38
+ isStarted(): boolean;
39
+ /**
40
+ * Starts the single editor application.
41
+ */
42
+ start(htmlContainer: HTMLElement): Promise<undefined>;
43
+ createEditors(htmlContainer: HTMLElement): Promise<void>;
44
+ updateCode(code: {
45
+ modified?: string;
46
+ original?: string;
47
+ }): void;
48
+ updateCodeResources(codeResources?: CodeResources): Promise<void>;
49
+ buildModelReference(codeContent: CodeContent, logger?: Logger): Promise<IReference<ITextFileEditorModel>>;
50
+ private announceModelUpdate;
51
+ dispose(): Promise<void>;
52
+ isDisposed(): boolean;
53
+ isDisposing(): boolean;
54
+ getDisposingAwait(): Promise<void> | undefined;
55
+ disposeModelRefs(): Promise<void>;
56
+ updateLayout(): void;
57
+ reportStatus(): string[];
58
+ }
59
+ export declare const didModelContentChange: (textModels: TextModels, onTextChanged?: (textChanges: TextContents) => void) => void;
60
+ //# sourceMappingURL=editorApp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"editorApp.d.ts","sourceRoot":"","sources":["../../src/editorApp/editorApp.ts"],"names":[],"mappings":"AAMA,OAAO,EAAwB,KAAK,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AACtG,OAAO,KAAK,MAAM,MAAM,qCAAqC,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kDAAkD,CAAC;AACnF,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAG1E,OAAO,KAAK,EAAuB,WAAW,EAAE,aAAa,EAAuB,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGnJ;;;;;;GAMG;AACH,qBAAa,SAAS;IAElB,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,EAAE,CAAS;IACnB,OAAO,CAAC,MAAM,CAAkB;IAEhC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAuB;IAE/C,OAAO,CAAC,MAAM,CAAkD;IAChE,OAAO,CAAC,UAAU,CAAkD;IAEpE,OAAO,CAAC,SAAS,CAA8B;IAE/C,OAAO,CAAC,aAAa,CAAC,CAAsC;IAC5D,OAAO,CAAC,sBAAsB,CAA2B;IAC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1,394 @@
1
+ /* --------------------------------------------------------------------------------------------
2
+ * Copyright (c) 2024 TypeFox and others.
3
+ * Licensed under the MIT License. See LICENSE in the package root for license information.
4
+ * ------------------------------------------------------------------------------------------ */
5
+ import { ConfigurationTarget, IConfigurationService, LogLevel, StandaloneServices } from '@codingame/monaco-vscode-api';
6
+ import { createModelReference } from '@codingame/monaco-vscode-api/monaco';
7
+ import * as monaco from '@codingame/monaco-vscode-editor-api';
8
+ import { ConsoleLogger } from 'monaco-languageclient/common';
9
+ import { getEnhancedMonacoEnvironment } from 'monaco-languageclient/vscodeApiWrapper';
10
+ import * as vscode from 'vscode';
11
+ import { ModelRefs } from './config.js';
12
+ /**
13
+ * This is the base class for both Monaco Editor Apps:
14
+ * - EditorAppClassic
15
+ * - EditorAppExtended
16
+ *
17
+ * It provides the generic functionality for both implementations.
18
+ */
19
+ export class EditorApp {
20
+ $type;
21
+ id;
22
+ config;
23
+ logger = new ConsoleLogger();
24
+ editor;
25
+ diffEditor;
26
+ modelRefs = new ModelRefs();
27
+ onTextChanged;
28
+ textChangedDisposables = {};
29
+ modelDisposables = {};
30
+ modelRefDisposeTimeout = -1;
31
+ startingAwait;
32
+ disposingAwait;
33
+ constructor(userAppConfig) {
34
+ this.$type = userAppConfig?.$type ?? 'extended';
35
+ this.id = userAppConfig?.id ?? Math.floor(Math.random() * 1000001).toString();
36
+ if ((userAppConfig?.useDiffEditor ?? false) && !userAppConfig?.codeResources?.original) {
37
+ throw new Error(`Use diff editor was used without a valid config. code: ${userAppConfig?.codeResources?.modified} codeOriginal: ${userAppConfig?.codeResources?.original}`);
38
+ }
39
+ this.config = {
40
+ codeResources: userAppConfig?.codeResources ?? undefined,
41
+ useDiffEditor: userAppConfig?.useDiffEditor ?? false,
42
+ readOnly: userAppConfig?.readOnly ?? false,
43
+ domReadOnly: userAppConfig?.domReadOnly ?? false,
44
+ overrideAutomaticLayout: userAppConfig?.overrideAutomaticLayout ?? true
45
+ };
46
+ this.config.editorOptions = {
47
+ ...userAppConfig?.editorOptions,
48
+ automaticLayout: userAppConfig?.overrideAutomaticLayout ?? true
49
+ };
50
+ this.config.diffEditorOptions = {
51
+ ...userAppConfig?.diffEditorOptions,
52
+ automaticLayout: userAppConfig?.overrideAutomaticLayout ?? true
53
+ };
54
+ this.config.languageDef = userAppConfig?.languageDef;
55
+ this.logger.setLevel(this.config.logLevel ?? LogLevel.Off);
56
+ }
57
+ isDiffEditor() {
58
+ return this.config.useDiffEditor === true;
59
+ }
60
+ getConfig() {
61
+ return this.config;
62
+ }
63
+ getEditor() {
64
+ return this.editor;
65
+ }
66
+ getDiffEditor() {
67
+ return this.diffEditor;
68
+ }
69
+ getTextModels() {
70
+ return {
71
+ modified: this.modelRefs.modified?.object.textEditorModel ?? undefined,
72
+ original: this.modelRefs.original?.object.textEditorModel ?? undefined
73
+ };
74
+ }
75
+ getLogger() {
76
+ return this.logger;
77
+ }
78
+ registerOnTextChangedCallback(onTextChanged) {
79
+ this.onTextChanged = onTextChanged;
80
+ }
81
+ setModelRefDisposeTimeout(modelRefDisposeTimeout) {
82
+ this.modelRefDisposeTimeout = modelRefDisposeTimeout;
83
+ }
84
+ isStarting() {
85
+ return this.startingAwait !== undefined;
86
+ }
87
+ getStartingAwait() {
88
+ return this.startingAwait;
89
+ }
90
+ isStarted() {
91
+ return this.editor !== undefined || this.diffEditor !== undefined;
92
+ }
93
+ /**
94
+ * Starts the single editor application.
95
+ */
96
+ async start(htmlContainer) {
97
+ if (this.isStarting()) {
98
+ await this.getStartingAwait();
99
+ }
100
+ let startingResolve = () => { };
101
+ this.startingAwait = new Promise((resolve) => {
102
+ startingResolve = resolve;
103
+ });
104
+ try {
105
+ const envEnhanced = getEnhancedMonacoEnvironment();
106
+ const viewServiceType = envEnhanced.viewServiceType;
107
+ // check general error case first
108
+ if (!(envEnhanced.vscodeApiInitialised ?? false)) {
109
+ return Promise.reject('monaco-vscode-api was not initialized. Aborting.');
110
+ }
111
+ if (viewServiceType !== 'EditorService' && viewServiceType !== undefined) {
112
+ return Promise.reject('No EditorService configured. monaco-editor will not be started.');
113
+ }
114
+ if (!this.isDisposed()) {
115
+ return Promise.reject('Start was called without properly disposing the EditorApp first.');
116
+ }
117
+ const languageDef = this.config.languageDef;
118
+ if (languageDef) {
119
+ if (this.$type === 'extended') {
120
+ throw new Error('Language definition is not supported for extended editor apps where textmate is used.');
121
+ }
122
+ // register own language first
123
+ monaco.languages.register(languageDef.languageExtensionConfig);
124
+ const languageRegistered = monaco.languages.getLanguages().filter(x => x.id === languageDef.languageExtensionConfig.id);
125
+ if (languageRegistered.length === 0) {
126
+ // this is only meaningful for languages supported by monaco out of the box
127
+ monaco.languages.register({
128
+ id: languageDef.languageExtensionConfig.id
129
+ });
130
+ }
131
+ // apply monarch definitions
132
+ if (languageDef.monarchLanguage) {
133
+ monaco.languages.setMonarchTokensProvider(languageDef.languageExtensionConfig.id, languageDef.monarchLanguage);
134
+ }
135
+ if (languageDef.theme) {
136
+ monaco.editor.defineTheme(languageDef.theme.name, languageDef.theme.data);
137
+ monaco.editor.setTheme(languageDef.theme.name);
138
+ }
139
+ }
140
+ if (this.config.editorOptions?.['semanticHighlighting.enabled'] !== undefined) {
141
+ StandaloneServices.get(IConfigurationService).updateValue('editor.semanticHighlighting.enabled', this.config.editorOptions['semanticHighlighting.enabled'], ConfigurationTarget.USER);
142
+ }
143
+ await this.createEditors(htmlContainer);
144
+ // everything is fine at this point
145
+ startingResolve();
146
+ this.logger.info('EditorApp start completed successfully.');
147
+ }
148
+ catch (e) {
149
+ // in case of further errors (after general ones above)
150
+ // take the error and build a new rejection to complete the promise
151
+ return Promise.reject(e);
152
+ }
153
+ finally {
154
+ this.startingAwait = undefined;
155
+ }
156
+ }
157
+ async createEditors(htmlContainer) {
158
+ // ensure proper default resources are initialized, uris have to be unique
159
+ const modified = {
160
+ text: this.config.codeResources?.modified?.text ?? '',
161
+ uri: this.config.codeResources?.modified?.uri ?? `default-uri-modified-${this.id}`,
162
+ enforceLanguageId: this.config.codeResources?.modified?.enforceLanguageId ?? undefined
163
+ };
164
+ this.modelRefs.modified = await this.buildModelReference(modified, this.logger);
165
+ if (this.isDiffEditor()) {
166
+ const original = {
167
+ text: this.config.codeResources?.original?.text ?? '',
168
+ uri: this.config.codeResources?.original?.uri ?? `default-uri-original-${this.id}`,
169
+ enforceLanguageId: this.config.codeResources?.original?.enforceLanguageId ?? undefined
170
+ };
171
+ this.modelRefs.original = await this.buildModelReference(original, this.logger);
172
+ }
173
+ this.logger.info(`Starting monaco-editor (${this.id})`);
174
+ if (this.isDiffEditor()) {
175
+ this.diffEditor = monaco.editor.createDiffEditor(htmlContainer, this.config.diffEditorOptions);
176
+ const modified = this.modelRefs.modified.object.textEditorModel ?? undefined;
177
+ const original = this.modelRefs.original?.object.textEditorModel ?? undefined;
178
+ if (modified !== undefined && original !== undefined) {
179
+ const model = {
180
+ modified,
181
+ original
182
+ };
183
+ this.diffEditor.setModel(model);
184
+ this.announceModelUpdate(model);
185
+ }
186
+ }
187
+ else {
188
+ const model = {
189
+ modified: this.modelRefs.modified.object.textEditorModel
190
+ };
191
+ this.editor = monaco.editor.create(htmlContainer, {
192
+ ...this.config.editorOptions,
193
+ model: model.modified
194
+ });
195
+ this.announceModelUpdate(model);
196
+ }
197
+ }
198
+ updateCode(code) {
199
+ if (this.isDiffEditor()) {
200
+ if (code.modified !== undefined) {
201
+ this.diffEditor?.getModifiedEditor().setValue(code.modified);
202
+ }
203
+ if (code.original !== undefined) {
204
+ this.diffEditor?.getOriginalEditor().setValue(code.original);
205
+ }
206
+ }
207
+ else {
208
+ if (code.modified !== undefined) {
209
+ this.editor?.setValue(code.modified);
210
+ }
211
+ }
212
+ }
213
+ async updateCodeResources(codeResources) {
214
+ let updateModified = false;
215
+ let updateOriginal = false;
216
+ if (codeResources?.modified !== undefined && codeResources.modified.uri !== this.modelRefs.modified?.object.resource.path) {
217
+ this.modelDisposables.modified = this.modelRefs.modified;
218
+ this.modelRefs.modified = await this.buildModelReference(codeResources.modified, this.logger);
219
+ updateModified = true;
220
+ }
221
+ if (codeResources?.original !== undefined && codeResources.original.uri !== this.modelRefs.original?.object.resource.path) {
222
+ this.modelDisposables.original = this.modelRefs.original;
223
+ this.modelRefs.original = await this.buildModelReference(codeResources.original, this.logger);
224
+ updateOriginal = true;
225
+ }
226
+ if (this.isDiffEditor()) {
227
+ if (updateModified && updateOriginal) {
228
+ const modified = this.modelRefs.modified?.object.textEditorModel ?? undefined;
229
+ const original = this.modelRefs.original?.object.textEditorModel ?? undefined;
230
+ if (modified !== undefined && original !== undefined) {
231
+ const model = {
232
+ modified,
233
+ original
234
+ };
235
+ this.diffEditor?.setModel(model);
236
+ this.announceModelUpdate(model);
237
+ }
238
+ }
239
+ else {
240
+ this.logger.info('Diff Editor: Code resources were not updated. They are ether unchanged or undefined.');
241
+ }
242
+ }
243
+ else {
244
+ if (updateModified) {
245
+ const model = {
246
+ modified: this.modelRefs.modified?.object.textEditorModel
247
+ };
248
+ if (model.modified !== undefined && model.modified !== null) {
249
+ this.editor?.setModel(model.modified);
250
+ this.announceModelUpdate(model);
251
+ }
252
+ }
253
+ else {
254
+ this.logger.info('Editor: Code resources were not updated. They are either unchanged or undefined.');
255
+ }
256
+ }
257
+ await this.disposeModelRefs();
258
+ }
259
+ async buildModelReference(codeContent, logger) {
260
+ const code = codeContent.text;
261
+ const modelRef = await createModelReference(vscode.Uri.parse(codeContent.uri), code);
262
+ // update the text if different
263
+ if (modelRef.object.textEditorModel?.getValue() !== code) {
264
+ modelRef.object.textEditorModel?.setValue(code);
265
+ }
266
+ const enforceLanguageId = codeContent.enforceLanguageId;
267
+ if (enforceLanguageId !== undefined) {
268
+ modelRef.object.setLanguageId(enforceLanguageId);
269
+ logger?.info(`Main languageId is enforced: ${enforceLanguageId}`);
270
+ }
271
+ return modelRef;
272
+ }
273
+ ;
274
+ announceModelUpdate(textModels) {
275
+ if (this.onTextChanged !== undefined) {
276
+ let changed = false;
277
+ if (textModels.modified !== undefined && textModels.modified !== null) {
278
+ const old = this.textChangedDisposables.modified;
279
+ this.textChangedDisposables.modified = textModels.modified.onDidChangeContent(() => {
280
+ didModelContentChange(textModels, this.onTextChanged);
281
+ });
282
+ old?.dispose();
283
+ changed = true;
284
+ }
285
+ if (textModels.original !== undefined && textModels.original !== null) {
286
+ const old = this.textChangedDisposables.original;
287
+ this.textChangedDisposables.original = textModels.original.onDidChangeContent(() => {
288
+ didModelContentChange(textModels, this.onTextChanged);
289
+ });
290
+ old?.dispose();
291
+ changed = true;
292
+ }
293
+ if (changed) {
294
+ // do it initially
295
+ didModelContentChange(textModels, this.onTextChanged);
296
+ }
297
+ }
298
+ }
299
+ async dispose() {
300
+ if (this.isDisposing()) {
301
+ await this.getDisposingAwait();
302
+ }
303
+ let disposingResolve = () => { };
304
+ this.disposingAwait = new Promise((resolve) => {
305
+ disposingResolve = resolve;
306
+ });
307
+ if (this.editor) {
308
+ this.editor.dispose();
309
+ this.editor = undefined;
310
+ }
311
+ if (this.diffEditor) {
312
+ this.diffEditor.dispose();
313
+ this.diffEditor = undefined;
314
+ }
315
+ this.textChangedDisposables.modified?.dispose();
316
+ this.textChangedDisposables.original?.dispose();
317
+ this.textChangedDisposables.modified = undefined;
318
+ this.textChangedDisposables.original = undefined;
319
+ await this.disposeModelRefs();
320
+ disposingResolve();
321
+ this.disposingAwait = undefined;
322
+ }
323
+ isDisposed() {
324
+ return this.editor === undefined && this.diffEditor === undefined &&
325
+ this.modelDisposables.original === undefined && this.modelDisposables.modified === undefined;
326
+ }
327
+ isDisposing() {
328
+ return this.disposingAwait !== undefined;
329
+ }
330
+ getDisposingAwait() {
331
+ return this.disposingAwait;
332
+ }
333
+ async disposeModelRefs() {
334
+ const disposeRefs = () => {
335
+ if (this.logger.getLevel() === LogLevel.Debug) {
336
+ const models = monaco.editor.getModels();
337
+ this.logger.debug('Current model URIs:');
338
+ models.forEach((model, _index) => {
339
+ this.logger.debug(`${model.uri.toString()}`);
340
+ });
341
+ }
342
+ if (this.modelDisposables.modified !== undefined && !this.modelDisposables.modified.object.isDisposed()) {
343
+ this.modelDisposables.modified.dispose();
344
+ this.modelDisposables.modified = undefined;
345
+ }
346
+ if (this.modelDisposables.original !== undefined && !this.modelDisposables.original.object.isDisposed()) {
347
+ this.modelDisposables.original.dispose();
348
+ this.modelDisposables.original = undefined;
349
+ }
350
+ if (this.logger.getLevel() === LogLevel.Debug) {
351
+ if (this.modelDisposables.modified === undefined && this.modelDisposables.original === undefined) {
352
+ this.logger.debug('All model references are disposed.');
353
+ }
354
+ else {
355
+ this.logger.debug('Model references are still available.');
356
+ }
357
+ }
358
+ };
359
+ if (this.modelRefDisposeTimeout > 0) {
360
+ this.logger.debug('Using async dispose of model references');
361
+ await new Promise(resolve => setTimeout(() => {
362
+ disposeRefs();
363
+ resolve();
364
+ }, this.modelRefDisposeTimeout));
365
+ }
366
+ else {
367
+ disposeRefs();
368
+ }
369
+ }
370
+ updateLayout() {
371
+ if (this.isDiffEditor()) {
372
+ this.diffEditor?.layout();
373
+ }
374
+ else {
375
+ this.editor?.layout();
376
+ }
377
+ }
378
+ reportStatus() {
379
+ const status = [];
380
+ status.push('EditorApp status:');
381
+ status.push(`Editor: ${this.editor?.getId()}`);
382
+ status.push(`DiffEditor: ${this.diffEditor?.getId()}`);
383
+ return status;
384
+ }
385
+ }
386
+ export const didModelContentChange = (textModels, onTextChanged) => {
387
+ const modified = textModels.modified?.getValue() ?? '';
388
+ const original = textModels.original?.getValue() ?? '';
389
+ onTextChanged?.({
390
+ modified,
391
+ original
392
+ });
393
+ };
394
+ //# sourceMappingURL=editorApp.js.map