monaco-languageclient 9.8.0 → 10.0.0-next.0

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 +5 -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 +66 -0
  21. package/lib/editorApp/editorApp.d.ts.map +1 -0
  22. package/lib/editorApp/editorApp.js +404 -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 +59 -0
  37. package/lib/vscode/apiWrapper.d.ts.map +1 -0
  38. package/lib/vscode/apiWrapper.js +290 -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 +70 -28
  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 +458 -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 +333 -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,11 @@
2
2
 
3
3
  All notable changes to this npm module are documented in this file.
4
4
 
5
+ ## [10.0.0-next.0] - 2025-0z-xy
6
+
7
+ - Move MonacoLanguageClientWrapper to monaco-languageclient [#920](https://github.com/TypeFox/monaco-languageclient/pull/920)
8
+ - Updated all `@codingame/monaco-vscode` packages to `18.2.0`.
9
+
5
10
  ## [9.8.0] - 2025-06-24
6
11
 
7
12
  - Updated all `@codingame/monaco-vscode` packages to `18.1.0`.
@@ -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 verifyUrlOrCreateDataUrl: (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,wBAAwB,GAAI,OAAO,MAAM,GAAG,GAAG,WAS3D,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 verifyUrlOrCreateDataUrl = (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, 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'@codingame/monaco-vscode-api';
2
+ import { type ITextFileEditorModel } from '@codingame/monaco-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","sour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AoB,CAAC,CAAC;CAC/C;AAED,MAAM,WAAW,eAAe;IAC5B,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) 2024 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,66 @@
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, type CodeResources, type EditorAppConfig, type TextContents, type TextModels } from './config.js';
6
+ /**
7
+ * This is the base class for both Monaco Ediotor 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 textChangedDiposeables;
23
+ private modelDisposables;
24
+ private modelRefDisposeTimeout;
25
+ private startingAwait?;
26
+ private startingResolve;
27
+ private disposingAwait?;
28
+ private disposingResolve;
29
+ constructor(userAppConfig?: EditorAppConfig);
30
+ isDiffEditor(): boolean;
31
+ getConfig(): EditorAppConfig;
32
+ getEditor(): monaco.editor.IStandaloneCodeEditor | undefined;
33
+ getDiffEditor(): monaco.editor.IStandaloneDiffEditor | undefined;
34
+ getTextModels(): TextModels;
35
+ getLogger(): Logger;
36
+ registerOnTextChangedCallback(onTextChanged?: (textChanges: TextContents) => void): void;
37
+ setModelRefDisposeTimeout(modelRefDisposeTimeout: number): void;
38
+ private markStarting;
39
+ private markStarted;
40
+ isStarting(): boolean;
41
+ getStartingAwait(): Promise<void> | undefined;
42
+ isStarted(): boolean;
43
+ /**
44
+ * Starts the single editor application.
45
+ */
46
+ start(htmlContainer: HTMLElement): Promise<void>;
47
+ createEditors(htmlContainer: HTMLElement): Promise<void>;
48
+ updateCode(code: {
49
+ modified?: string;
50
+ original?: string;
51
+ }): void;
52
+ updateCodeResources(codeResources?: CodeResources): Promise<void>;
53
+ buildModelReference(codeContent: CodeContent, logger?: Logger): Promise<IReference<ITextFileEditorModel>>;
54
+ private announceModelUpdate;
55
+ dispose(): Promise<void>;
56
+ isDisposed(): boolean;
57
+ private markDisposing;
58
+ private markDisposed;
59
+ isDisposing(): boolean;
60
+ getDisposingAwait(): Promise<void> | undefined;
61
+ disposeModelRefs(): Promise<void>;
62
+ updateLayout(): void;
63
+ reportStatus(): string[];
64
+ }
65
+ export declare const didModelContentChange: (textModels: TextModels, onTextChanged?: (textChanges: TextContents) => void) => void;
66
+ //# 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,EAAuC,KAAK,WAAW,EAAE,KAAK,aAAa,EAA4B,KAAK,eAAe,EAAE,KAAK,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAE5L;;;;;;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/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oB,CAAC,CAAC;IAgB/G,OAAO,CAAC,mBAAmB;IA4BrB,OAAO;IAyBb,UAAU,IAAI,OAAO;IAMrB,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,YAAY;IAKpB,WAAW;IAIX,iBAAiB;IAIX,gBAAgB;IAuCtB,YAAY;IAQZ,YAAY;CAOf;AAED,eAAO,MAAM,qBAAqB,GAAI,YAAY,UAAU,EAAE,gBAAgB,CAAC,WAAW,EAAE,YAAY,KAAK,IAAI,SAOhH,CAAC"}
@@ -0,0 +1,404 @@
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 Ediotor 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
+ textChangedDiposeables = {};
29
+ modelDisposables = {};
30
+ modelRefDisposeTimeout = -1;
31
+ startingAwait;
32
+ startingResolve;
33
+ disposingAwait;
34
+ disposingResolve;
35
+ constructor(userAppConfig) {
36
+ this.$type = userAppConfig?.$type ?? 'extended';
37
+ this.id = userAppConfig?.id ?? Math.floor(Math.random() * 1000001).toString();
38
+ if ((userAppConfig?.useDiffEditor ?? false) && !userAppConfig?.codeResources?.original) {
39
+ throw new Error(`Use diff editor was used without a valid config. code: ${userAppConfig?.codeResources?.modified} codeOriginal: ${userAppConfig?.codeResources?.original}`);
40
+ }
41
+ this.config = {
42
+ codeResources: userAppConfig?.codeResources ?? undefined,
43
+ useDiffEditor: userAppConfig?.useDiffEditor ?? false,
44
+ readOnly: userAppConfig?.readOnly ?? false,
45
+ domReadOnly: userAppConfig?.domReadOnly ?? false,
46
+ overrideAutomaticLayout: userAppConfig?.overrideAutomaticLayout ?? true
47
+ };
48
+ this.config.editorOptions = {
49
+ ...userAppConfig?.editorOptions,
50
+ automaticLayout: userAppConfig?.overrideAutomaticLayout ?? true
51
+ };
52
+ this.config.diffEditorOptions = {
53
+ ...userAppConfig?.diffEditorOptions,
54
+ automaticLayout: userAppConfig?.overrideAutomaticLayout ?? true
55
+ };
56
+ this.config.languageDef = userAppConfig?.languageDef;
57
+ this.logger.setLevel(this.config.logLevel ?? LogLevel.Off);
58
+ }
59
+ isDiffEditor() {
60
+ return this.config.useDiffEditor === true;
61
+ }
62
+ getConfig() {
63
+ return this.config;
64
+ }
65
+ getEditor() {
66
+ return this.editor;
67
+ }
68
+ getDiffEditor() {
69
+ return this.diffEditor;
70
+ }
71
+ getTextModels() {
72
+ return {
73
+ modified: this.modelRefs.modified?.object.textEditorModel ?? undefined,
74
+ original: this.modelRefs.original?.object.textEditorModel ?? undefined
75
+ };
76
+ }
77
+ getLogger() {
78
+ return this.logger;
79
+ }
80
+ registerOnTextChangedCallback(onTextChanged) {
81
+ this.onTextChanged = onTextChanged;
82
+ }
83
+ setModelRefDisposeTimeout(modelRefDisposeTimeout) {
84
+ this.modelRefDisposeTimeout = modelRefDisposeTimeout;
85
+ }
86
+ markStarting() {
87
+ this.startingAwait = new Promise((resolve) => {
88
+ this.startingResolve = resolve;
89
+ });
90
+ }
91
+ markStarted() {
92
+ this.startingResolve();
93
+ this.startingAwait = undefined;
94
+ }
95
+ isStarting() {
96
+ return this.startingAwait !== undefined;
97
+ }
98
+ getStartingAwait() {
99
+ return this.startingAwait;
100
+ }
101
+ isStarted() {
102
+ return this.editor !== undefined || this.diffEditor !== undefined;
103
+ }
104
+ /**
105
+ * Starts the single editor application.
106
+ */
107
+ async start(htmlContainer) {
108
+ if (this.isStarting()) {
109
+ await this.getStartingAwait();
110
+ }
111
+ this.markStarting();
112
+ if (!this.isDisposed()) {
113
+ throw new Error('You called start without properly disposing the EditorApp.');
114
+ }
115
+ const languageDef = this.config.languageDef;
116
+ if (languageDef) {
117
+ if (this.$type === 'extended') {
118
+ throw new Error('Language definition is not supported for extended editor apps where textmate is used.');
119
+ }
120
+ // register own language first
121
+ monaco.languages.register(languageDef.languageExtensionConfig);
122
+ const languageRegistered = monaco.languages.getLanguages().filter(x => x.id === languageDef.languageExtensionConfig.id);
123
+ if (languageRegistered.length === 0) {
124
+ // this is only meaningful for languages supported by monaco out of the box
125
+ monaco.languages.register({
126
+ id: languageDef.languageExtensionConfig.id
127
+ });
128
+ }
129
+ // apply monarch definitions
130
+ if (languageDef.monarchLanguage) {
131
+ monaco.languages.setMonarchTokensProvider(languageDef.languageExtensionConfig.id, languageDef.monarchLanguage);
132
+ }
133
+ if (languageDef.theme) {
134
+ monaco.editor.defineTheme(languageDef.theme.name, languageDef.theme.data);
135
+ monaco.editor.setTheme(languageDef.theme.name);
136
+ }
137
+ }
138
+ if (this.config.editorOptions?.['semanticHighlighting.enabled'] !== undefined) {
139
+ StandaloneServices.get(IConfigurationService).updateValue('editor.semanticHighlighting.enabled', this.config.editorOptions['semanticHighlighting.enabled'], ConfigurationTarget.USER);
140
+ }
141
+ // ensure proper default resources are initialized, uris have to be unique
142
+ const modified = {
143
+ text: this.config.codeResources?.modified?.text ?? '',
144
+ uri: this.config.codeResources?.modified?.uri ?? `default-uri-modified-${this.id}`,
145
+ enforceLanguageId: this.config.codeResources?.modified?.enforceLanguageId ?? undefined
146
+ };
147
+ this.modelRefs.modified = await this.buildModelReference(modified, this.logger);
148
+ if (this.isDiffEditor()) {
149
+ const original = {
150
+ text: this.config.codeResources?.original?.text ?? '',
151
+ uri: this.config.codeResources?.original?.uri ?? `default-uri-original-${this.id}`,
152
+ enforceLanguageId: this.config.codeResources?.original?.enforceLanguageId ?? undefined
153
+ };
154
+ this.modelRefs.original = await this.buildModelReference(original, this.logger);
155
+ }
156
+ try {
157
+ const envEnhanced = getEnhancedMonacoEnvironment();
158
+ const viewServiceType = envEnhanced.viewServiceType;
159
+ if (viewServiceType === 'EditorService' || viewServiceType === undefined) {
160
+ this.logger.info(`Starting monaco-editor (${this.id})`);
161
+ await this.createEditors(htmlContainer);
162
+ }
163
+ else {
164
+ this.logger.info('No EditorService configured. monaco-editor will not be started.');
165
+ }
166
+ this.logger.info('EditorApp start completed successfully.');
167
+ // eslint-disable-next-line no-useless-catch
168
+ }
169
+ catch (e) {
170
+ throw e;
171
+ }
172
+ finally {
173
+ // in case of rejection, mark as started, otherwise the promise will never resolve
174
+ this.markStarted();
175
+ }
176
+ }
177
+ async createEditors(htmlContainer) {
178
+ if (this.isDiffEditor()) {
179
+ this.diffEditor = monaco.editor.createDiffEditor(htmlContainer, this.config.diffEditorOptions);
180
+ const modified = this.modelRefs.modified?.object.textEditorModel ?? undefined;
181
+ const original = this.modelRefs.original?.object.textEditorModel ?? undefined;
182
+ if (modified !== undefined && original !== undefined) {
183
+ const model = {
184
+ modified,
185
+ original
186
+ };
187
+ this.diffEditor.setModel(model);
188
+ this.announceModelUpdate(model);
189
+ }
190
+ }
191
+ else {
192
+ const model = {
193
+ modified: this.modelRefs.modified?.object.textEditorModel
194
+ };
195
+ this.editor = monaco.editor.create(htmlContainer, {
196
+ ...this.config.editorOptions,
197
+ model: model.modified
198
+ });
199
+ this.announceModelUpdate(model);
200
+ }
201
+ }
202
+ updateCode(code) {
203
+ if (this.isDiffEditor()) {
204
+ if (code.modified !== undefined) {
205
+ this.diffEditor?.getModifiedEditor().setValue(code.modified);
206
+ }
207
+ if (code.original !== undefined) {
208
+ this.diffEditor?.getOriginalEditor().setValue(code.original);
209
+ }
210
+ }
211
+ else {
212
+ if (code.modified !== undefined) {
213
+ this.editor?.setValue(code.modified);
214
+ }
215
+ }
216
+ }
217
+ async updateCodeResources(codeResources) {
218
+ let updateModified = false;
219
+ let updateOriginal = false;
220
+ if (codeResources?.modified !== undefined && codeResources.modified.uri !== this.modelRefs.modified?.object.resource.path) {
221
+ this.modelDisposables.modified = this.modelRefs.modified;
222
+ this.modelRefs.modified = await this.buildModelReference(codeResources.modified, this.logger);
223
+ updateModified = true;
224
+ }
225
+ if (codeResources?.original !== undefined && codeResources.original.uri !== this.modelRefs.original?.object.resource.path) {
226
+ this.modelDisposables.original = this.modelRefs.original;
227
+ this.modelRefs.original = await this.buildModelReference(codeResources.original, this.logger);
228
+ updateOriginal = true;
229
+ }
230
+ if (this.isDiffEditor()) {
231
+ if (updateModified && updateOriginal) {
232
+ const modified = this.modelRefs.modified?.object.textEditorModel ?? undefined;
233
+ const original = this.modelRefs.original?.object.textEditorModel ?? undefined;
234
+ if (modified !== undefined && original !== undefined) {
235
+ const model = {
236
+ modified,
237
+ original
238
+ };
239
+ this.diffEditor?.setModel(model);
240
+ this.announceModelUpdate(model);
241
+ }
242
+ }
243
+ else {
244
+ this.logger.info('Diff Editor: Code resources were not updated. They are ether unchanged or undefined.');
245
+ }
246
+ }
247
+ else {
248
+ if (updateModified) {
249
+ const model = {
250
+ modified: this.modelRefs.modified?.object.textEditorModel
251
+ };
252
+ if (model.modified !== undefined && model.modified !== null) {
253
+ this.editor?.setModel(model.modified);
254
+ this.announceModelUpdate(model);
255
+ }
256
+ }
257
+ else {
258
+ this.logger.info('Editor: Code resources were not updated. They are either unchanged or undefined.');
259
+ }
260
+ }
261
+ await this.disposeModelRefs();
262
+ }
263
+ async buildModelReference(codeContent, logger) {
264
+ const code = codeContent.text;
265
+ const modelRef = await createModelReference(vscode.Uri.parse(codeContent.uri), code);
266
+ // update the text if different
267
+ if (modelRef.object.textEditorModel?.getValue() !== code) {
268
+ modelRef.object.textEditorModel?.setValue(code);
269
+ }
270
+ const enforceLanguageId = codeContent.enforceLanguageId;
271
+ if (enforceLanguageId !== undefined) {
272
+ modelRef.object.setLanguageId(enforceLanguageId);
273
+ logger?.info(`Main languageId is enforced: ${enforceLanguageId}`);
274
+ }
275
+ return modelRef;
276
+ }
277
+ ;
278
+ announceModelUpdate(textModels) {
279
+ if (this.onTextChanged !== undefined) {
280
+ let changed = false;
281
+ if (textModels.modified !== undefined && textModels.modified !== null) {
282
+ const old = this.textChangedDiposeables.modified;
283
+ this.textChangedDiposeables.modified = textModels.modified.onDidChangeContent(() => {
284
+ didModelContentChange(textModels, this.onTextChanged);
285
+ });
286
+ old?.dispose();
287
+ changed = true;
288
+ }
289
+ if (textModels.original !== undefined && textModels.original !== null) {
290
+ const old = this.textChangedDiposeables.original;
291
+ this.textChangedDiposeables.original = textModels.original.onDidChangeContent(() => {
292
+ didModelContentChange(textModels, this.onTextChanged);
293
+ });
294
+ old?.dispose();
295
+ changed = true;
296
+ }
297
+ if (changed) {
298
+ // do it initially
299
+ didModelContentChange(textModels, this.onTextChanged);
300
+ }
301
+ }
302
+ }
303
+ async dispose() {
304
+ if (this.isDisposing()) {
305
+ await this.getDisposingAwait();
306
+ }
307
+ this.markDisposing();
308
+ if (this.editor) {
309
+ this.editor.dispose();
310
+ this.editor = undefined;
311
+ }
312
+ if (this.diffEditor) {
313
+ this.diffEditor.dispose();
314
+ this.diffEditor = undefined;
315
+ }
316
+ this.textChangedDiposeables.modified?.dispose();
317
+ this.textChangedDiposeables.original?.dispose();
318
+ this.textChangedDiposeables.modified = undefined;
319
+ this.textChangedDiposeables.original = undefined;
320
+ await this.disposeModelRefs();
321
+ this.markDisposed();
322
+ }
323
+ isDisposed() {
324
+ return this.editor === undefined && this.diffEditor === undefined &&
325
+ // this.textChangedDiposeables.modified === undefined && this.textChangedDiposeables.original === undefined &&
326
+ this.modelDisposables.original === undefined && this.modelDisposables.modified === undefined;
327
+ }
328
+ markDisposing() {
329
+ this.disposingAwait = new Promise((resolve) => {
330
+ this.disposingResolve = resolve;
331
+ });
332
+ }
333
+ markDisposed() {
334
+ this.disposingResolve();
335
+ this.disposingAwait = undefined;
336
+ }
337
+ isDisposing() {
338
+ return this.disposingAwait !== undefined;
339
+ }
340
+ getDisposingAwait() {
341
+ return this.disposingAwait;
342
+ }
343
+ async disposeModelRefs() {
344
+ const diposeRefs = () => {
345
+ if (this.logger.getLevel() === LogLevel.Debug) {
346
+ const models = monaco.editor.getModels();
347
+ this.logger.debug('Current model URIs:');
348
+ models.forEach((model, _index) => {
349
+ this.logger.debug(`${model.uri.toString()}`);
350
+ });
351
+ }
352
+ if (this.modelDisposables.modified !== undefined && !(this.modelDisposables.modified.object.isDisposed() === true)) {
353
+ this.modelDisposables.modified.dispose();
354
+ this.modelDisposables.modified = undefined;
355
+ }
356
+ if (this.modelDisposables.original !== undefined && !(this.modelDisposables.original.object.isDisposed() === true)) {
357
+ this.modelDisposables.original.dispose();
358
+ this.modelDisposables.original = undefined;
359
+ }
360
+ if (this.logger.getLevel() === LogLevel.Debug) {
361
+ if (this.modelDisposables.modified === undefined && this.modelDisposables.original === undefined) {
362
+ this.logger.debug('All model references are disposed.');
363
+ }
364
+ else {
365
+ this.logger.debug('Model references are still available.');
366
+ }
367
+ }
368
+ };
369
+ if (this.modelRefDisposeTimeout > 0) {
370
+ this.logger.debug('Using async dispose of model references');
371
+ await new Promise(resolve => setTimeout(() => {
372
+ diposeRefs();
373
+ resolve();
374
+ }, this.modelRefDisposeTimeout));
375
+ }
376
+ else {
377
+ diposeRefs();
378
+ }
379
+ }
380
+ updateLayout() {
381
+ if (this.isDiffEditor()) {
382
+ this.diffEditor?.layout();
383
+ }
384
+ else {
385
+ this.editor?.layout();
386
+ }
387
+ }
388
+ reportStatus() {
389
+ const status = [];
390
+ status.push('EditorApp status:');
391
+ status.push(`Editor: ${this.editor?.getId()}`);
392
+ status.push(`DiffEditor: ${this.diffEditor?.getId()}`);
393
+ return status;
394
+ }
395
+ }
396
+ export const didModelContentChange = (textModels, onTextChanged) => {
397
+ const modified = textModels.modified?.getValue() ?? '';
398
+ const original = textModels.original?.getValue() ?? '';
399
+ onTextChanged?.({
400
+ modified,
401
+ original
402
+ });
403
+ };
404
+ //# sourceMappingURL=editorApp.js.map