@codingame/monaco-languageclient-wrapper 5.0.0-next.1 → 5.0.0-update-monaco.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (200) hide show
  1. package/dist/_virtual/_commonjsHelpers.js +1 -28
  2. package/dist/_virtual/_rollupPluginBabelHelpers.js +29 -29
  3. package/dist/extensions/java/extension.js +1 -1
  4. package/dist/extensions/java/inlayHintsProvider.js +3 -4
  5. package/dist/extensions/java/protocol.js +15 -16
  6. package/dist/extensions/java/sourceAction.js +1 -1
  7. package/dist/index.d.ts +28 -9266
  8. package/dist/node_modules/delay/index.js +1 -2
  9. package/dist/node_modules/vscode-jsonrpc/lib/browser/main.js +1 -1
  10. package/dist/node_modules/vscode-jsonrpc/lib/common/api.js +1 -1
  11. package/dist/node_modules/vscode-jsonrpc/lib/common/cancellation.js +84 -86
  12. package/dist/node_modules/vscode-jsonrpc/lib/common/connection.js +20 -18
  13. package/dist/node_modules/vscode-jsonrpc/lib/common/disposable.js +11 -12
  14. package/dist/node_modules/vscode-jsonrpc/lib/common/events.js +112 -113
  15. package/dist/node_modules/vscode-jsonrpc/lib/common/is.js +1 -1
  16. package/dist/node_modules/vscode-jsonrpc/lib/common/linkedMap.js +378 -380
  17. package/dist/node_modules/vscode-jsonrpc/lib/common/messageBuffer.js +1 -1
  18. package/dist/node_modules/vscode-jsonrpc/lib/common/messageReader.js +186 -182
  19. package/dist/node_modules/vscode-jsonrpc/lib/common/messageWriter.js +110 -111
  20. package/dist/node_modules/vscode-jsonrpc/lib/common/messages.js +232 -233
  21. package/dist/src/createLanguageClient.js +43 -19
  22. package/dist/src/customRequests.js +4 -5
  23. package/dist/src/extensions/cobol.js +2 -3
  24. package/dist/src/extensions/csharp.js +2 -3
  25. package/dist/src/extensions/tools.js +5 -1
  26. package/dist/src/extensions.js +8 -12
  27. package/dist/src/infrastructure.js +18 -4
  28. package/dist/src/languageClient.js +17 -20
  29. package/dist/src/languageClientOptions.js +2 -3
  30. package/package.json +56 -52
  31. package/stats.html +32 -28
  32. package/dist/_virtual/_vscode.js +0 -4
  33. package/dist/_virtual/api2.js +0 -2
  34. package/dist/_virtual/api3.js +0 -2
  35. package/dist/_virtual/async.js +0 -2
  36. package/dist/_virtual/callHierarchy.js +0 -2
  37. package/dist/_virtual/client.js +0 -2
  38. package/dist/_virtual/codeAction.js +0 -2
  39. package/dist/_virtual/codeConverter.js +0 -2
  40. package/dist/_virtual/codeLens.js +0 -2
  41. package/dist/_virtual/colorProvider.js +0 -2
  42. package/dist/_virtual/completion.js +0 -2
  43. package/dist/_virtual/configuration.js +0 -2
  44. package/dist/_virtual/connection2.js +0 -2
  45. package/dist/_virtual/declaration.js +0 -2
  46. package/dist/_virtual/definition.js +0 -2
  47. package/dist/_virtual/diagnostic.js +0 -2
  48. package/dist/_virtual/documentHighlight.js +0 -2
  49. package/dist/_virtual/documentLink.js +0 -2
  50. package/dist/_virtual/documentSymbol.js +0 -2
  51. package/dist/_virtual/executeCommand.js +0 -2
  52. package/dist/_virtual/features.js +0 -2
  53. package/dist/_virtual/fileOperations.js +0 -2
  54. package/dist/_virtual/fileSystemWatcher.js +0 -2
  55. package/dist/_virtual/foldingRange.js +0 -2
  56. package/dist/_virtual/formatting.js +0 -2
  57. package/dist/_virtual/hover.js +0 -2
  58. package/dist/_virtual/implementation.js +0 -2
  59. package/dist/_virtual/inlayHint.js +0 -2
  60. package/dist/_virtual/inlineValue.js +0 -2
  61. package/dist/_virtual/is2.js +0 -2
  62. package/dist/_virtual/is3.js +0 -2
  63. package/dist/_virtual/linkedEditingRange.js +0 -2
  64. package/dist/_virtual/main2.js +0 -2
  65. package/dist/_virtual/main3.js +0 -2
  66. package/dist/_virtual/main4.js +0 -4
  67. package/dist/_virtual/messages2.js +0 -2
  68. package/dist/_virtual/notebook.js +0 -2
  69. package/dist/_virtual/path.js +0 -4
  70. package/dist/_virtual/progress.js +0 -2
  71. package/dist/_virtual/progressPart.js +0 -2
  72. package/dist/_virtual/protocol.callHierarchy.js +0 -2
  73. package/dist/_virtual/protocol.colorProvider.js +0 -2
  74. package/dist/_virtual/protocol.configuration.js +0 -2
  75. package/dist/_virtual/protocol.declaration.js +0 -2
  76. package/dist/_virtual/protocol.diagnostic.js +0 -2
  77. package/dist/_virtual/protocol.fileOperations.js +0 -2
  78. package/dist/_virtual/protocol.foldingRange.js +0 -2
  79. package/dist/_virtual/protocol.implementation.js +0 -2
  80. package/dist/_virtual/protocol.inlayHint.js +0 -2
  81. package/dist/_virtual/protocol.inlineValue.js +0 -2
  82. package/dist/_virtual/protocol.js +0 -2
  83. package/dist/_virtual/protocol.linkedEditingRange.js +0 -2
  84. package/dist/_virtual/protocol.moniker.js +0 -2
  85. package/dist/_virtual/protocol.notebook.js +0 -2
  86. package/dist/_virtual/protocol.progress.js +0 -2
  87. package/dist/_virtual/protocol.selectionRange.js +0 -2
  88. package/dist/_virtual/protocol.semanticTokens.js +0 -2
  89. package/dist/_virtual/protocol.showDocument.js +0 -2
  90. package/dist/_virtual/protocol.typeDefinition.js +0 -2
  91. package/dist/_virtual/protocol.typeHierarchy.js +0 -2
  92. package/dist/_virtual/protocol.workspaceFolder.js +0 -2
  93. package/dist/_virtual/protocolCallHierarchyItem.js +0 -2
  94. package/dist/_virtual/protocolCodeAction.js +0 -2
  95. package/dist/_virtual/protocolCodeLens.js +0 -2
  96. package/dist/_virtual/protocolCompletionItem.js +0 -2
  97. package/dist/_virtual/protocolConverter.js +0 -2
  98. package/dist/_virtual/protocolDiagnostic.js +0 -2
  99. package/dist/_virtual/protocolDocumentLink.js +0 -2
  100. package/dist/_virtual/protocolInlayHint.js +0 -2
  101. package/dist/_virtual/protocolTypeHierarchyItem.js +0 -2
  102. package/dist/_virtual/protocolWorkspaceSymbol.js +0 -2
  103. package/dist/_virtual/reference.js +0 -2
  104. package/dist/_virtual/rename.js +0 -2
  105. package/dist/_virtual/selectionRange.js +0 -2
  106. package/dist/_virtual/semanticTokens.js +0 -2
  107. package/dist/_virtual/signatureHelp.js +0 -2
  108. package/dist/_virtual/textSynchronization.js +0 -2
  109. package/dist/_virtual/typeDefinition.js +0 -2
  110. package/dist/_virtual/typeHierarchy.js +0 -2
  111. package/dist/_virtual/uuid.js +0 -2
  112. package/dist/_virtual/workspaceFolder.js +0 -2
  113. package/dist/_virtual/workspaceSymbol.js +0 -2
  114. package/dist/node_modules/balanced-match/index.js +0 -52
  115. package/dist/node_modules/monaco-languageclient/lib/monaco-language-client.js +0 -127
  116. package/dist/node_modules/vscode-jsonrpc/browser.js +0 -4
  117. package/dist/node_modules/vscode-languageclient/lib/browser/main.js +0 -49
  118. package/dist/node_modules/vscode-languageclient/lib/common/api.js +0 -51
  119. package/dist/node_modules/vscode-languageclient/lib/common/callHierarchy.js +0 -98
  120. package/dist/node_modules/vscode-languageclient/lib/common/client.js +0 -1527
  121. package/dist/node_modules/vscode-languageclient/lib/common/codeAction.js +0 -92
  122. package/dist/node_modules/vscode-languageclient/lib/common/codeConverter.js +0 -881
  123. package/dist/node_modules/vscode-languageclient/lib/common/codeLens.js +0 -84
  124. package/dist/node_modules/vscode-languageclient/lib/common/colorProvider.js +0 -77
  125. package/dist/node_modules/vscode-languageclient/lib/common/completion.js +0 -105
  126. package/dist/node_modules/vscode-languageclient/lib/common/configuration.js +0 -214
  127. package/dist/node_modules/vscode-languageclient/lib/common/declaration.js +0 -59
  128. package/dist/node_modules/vscode-languageclient/lib/common/definition.js +0 -62
  129. package/dist/node_modules/vscode-languageclient/lib/common/diagnostic.js +0 -839
  130. package/dist/node_modules/vscode-languageclient/lib/common/documentHighlight.js +0 -57
  131. package/dist/node_modules/vscode-languageclient/lib/common/documentLink.js +0 -74
  132. package/dist/node_modules/vscode-languageclient/lib/common/documentSymbol.js +0 -82
  133. package/dist/node_modules/vscode-languageclient/lib/common/executeCommand.js +0 -83
  134. package/dist/node_modules/vscode-languageclient/lib/common/features.js +0 -310
  135. package/dist/node_modules/vscode-languageclient/lib/common/fileOperations.js +0 -319
  136. package/dist/node_modules/vscode-languageclient/lib/common/fileSystemWatcher.js +0 -104
  137. package/dist/node_modules/vscode-languageclient/lib/common/foldingRange.js +0 -66
  138. package/dist/node_modules/vscode-languageclient/lib/common/formatting.js +0 -165
  139. package/dist/node_modules/vscode-languageclient/lib/common/hover.js +0 -62
  140. package/dist/node_modules/vscode-languageclient/lib/common/implementation.js +0 -59
  141. package/dist/node_modules/vscode-languageclient/lib/common/inlayHint.js +0 -94
  142. package/dist/node_modules/vscode-languageclient/lib/common/inlineValue.js +0 -73
  143. package/dist/node_modules/vscode-languageclient/lib/common/linkedEditingRange.js +0 -58
  144. package/dist/node_modules/vscode-languageclient/lib/common/notebook.js +0 -858
  145. package/dist/node_modules/vscode-languageclient/lib/common/progress.js +0 -51
  146. package/dist/node_modules/vscode-languageclient/lib/common/progressPart.js +0 -107
  147. package/dist/node_modules/vscode-languageclient/lib/common/protocolCallHierarchyItem.js +0 -15
  148. package/dist/node_modules/vscode-languageclient/lib/common/protocolCodeAction.js +0 -13
  149. package/dist/node_modules/vscode-languageclient/lib/common/protocolCodeLens.js +0 -12
  150. package/dist/node_modules/vscode-languageclient/lib/common/protocolCompletionItem.js +0 -12
  151. package/dist/node_modules/vscode-languageclient/lib/common/protocolConverter.js +0 -1129
  152. package/dist/node_modules/vscode-languageclient/lib/common/protocolDiagnostic.js +0 -27
  153. package/dist/node_modules/vscode-languageclient/lib/common/protocolDocumentLink.js +0 -12
  154. package/dist/node_modules/vscode-languageclient/lib/common/protocolInlayHint.js +0 -12
  155. package/dist/node_modules/vscode-languageclient/lib/common/protocolTypeHierarchyItem.js +0 -15
  156. package/dist/node_modules/vscode-languageclient/lib/common/protocolWorkspaceSymbol.js +0 -17
  157. package/dist/node_modules/vscode-languageclient/lib/common/reference.js +0 -60
  158. package/dist/node_modules/vscode-languageclient/lib/common/rename.js +0 -112
  159. package/dist/node_modules/vscode-languageclient/lib/common/selectionRange.js +0 -62
  160. package/dist/node_modules/vscode-languageclient/lib/common/semanticTokens.js +0 -144
  161. package/dist/node_modules/vscode-languageclient/lib/common/signatureHelp.js +0 -78
  162. package/dist/node_modules/vscode-languageclient/lib/common/textSynchronization.js +0 -422
  163. package/dist/node_modules/vscode-languageclient/lib/common/typeDefinition.js +0 -60
  164. package/dist/node_modules/vscode-languageclient/lib/common/typeHierarchy.js +0 -97
  165. package/dist/node_modules/vscode-languageclient/lib/common/utils/async.js +0 -269
  166. package/dist/node_modules/vscode-languageclient/lib/common/utils/is.js +0 -54
  167. package/dist/node_modules/vscode-languageclient/lib/common/utils/uuid.js +0 -51
  168. package/dist/node_modules/vscode-languageclient/lib/common/workspaceFolder.js +0 -154
  169. package/dist/node_modules/vscode-languageclient/lib/common/workspaceSymbol.js +0 -87
  170. package/dist/node_modules/vscode-languageclient/node_modules/brace-expansion/index.js +0 -160
  171. package/dist/node_modules/vscode-languageclient/node_modules/minimatch/lib/path.js +0 -2
  172. package/dist/node_modules/vscode-languageclient/node_modules/minimatch/minimatch.js +0 -567
  173. package/dist/node_modules/vscode-languageserver-protocol/browser.js +0 -4
  174. package/dist/node_modules/vscode-languageserver-protocol/lib/browser/main.js +0 -30
  175. package/dist/node_modules/vscode-languageserver-protocol/lib/common/api.js +0 -43
  176. package/dist/node_modules/vscode-languageserver-protocol/lib/common/connection.js +0 -14
  177. package/dist/node_modules/vscode-languageserver-protocol/lib/common/messages.js +0 -43
  178. package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.callHierarchy.js +0 -23
  179. package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.colorProvider.js +0 -18
  180. package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.configuration.js +0 -13
  181. package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.declaration.js +0 -13
  182. package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.diagnostic.js +0 -42
  183. package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.fileOperations.js +0 -42
  184. package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.foldingRange.js +0 -13
  185. package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.implementation.js +0 -13
  186. package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.inlayHint.js +0 -23
  187. package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.inlineValue.js +0 -18
  188. package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.js +0 -494
  189. package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.linkedEditingRange.js +0 -13
  190. package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.moniker.js +0 -25
  191. package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.notebook.js +0 -185
  192. package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.progress.js +0 -28
  193. package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.selectionRange.js +0 -13
  194. package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.semanticTokens.js +0 -39
  195. package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.showDocument.js +0 -13
  196. package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.typeDefinition.js +0 -13
  197. package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.typeHierarchy.js +0 -23
  198. package/dist/node_modules/vscode-languageserver-protocol/lib/common/protocol.workspaceFolder.js +0 -18
  199. package/dist/node_modules/vscode-languageserver-protocol/lib/common/utils/is.js +0 -40
  200. package/dist/node_modules/vscode-languageserver-types/lib/esm/main.js +0 -1583
@@ -3,386 +3,384 @@ var hasRequiredLinkedMap;
3
3
  function requireLinkedMap () {
4
4
  if (hasRequiredLinkedMap) return linkedMap;
5
5
  hasRequiredLinkedMap = 1;
6
- (function (exports) {
7
- var _a;
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.LRUCache = exports.LinkedMap = exports.Touch = void 0;
10
- var Touch;
11
- (function (Touch) {
12
- Touch.None = 0;
13
- Touch.First = 1;
14
- Touch.AsOld = Touch.First;
15
- Touch.Last = 2;
16
- Touch.AsNew = Touch.Last;
17
- })(Touch = exports.Touch || (exports.Touch = {}));
18
- class LinkedMap {
19
- constructor() {
20
- this[_a] = 'LinkedMap';
21
- this._map = new Map();
22
- this._head = undefined;
23
- this._tail = undefined;
24
- this._size = 0;
25
- this._state = 0;
26
- }
27
- clear() {
28
- this._map.clear();
29
- this._head = undefined;
30
- this._tail = undefined;
31
- this._size = 0;
32
- this._state++;
33
- }
34
- isEmpty() {
35
- return !this._head && !this._tail;
36
- }
37
- get size() {
38
- return this._size;
39
- }
40
- get first() {
41
- return this._head?.value;
42
- }
43
- get last() {
44
- return this._tail?.value;
45
- }
46
- has(key) {
47
- return this._map.has(key);
48
- }
49
- get(key, touch = Touch.None) {
50
- const item = this._map.get(key);
51
- if (!item) {
52
- return undefined;
53
- }
54
- if (touch !== Touch.None) {
55
- this.touch(item, touch);
56
- }
57
- return item.value;
58
- }
59
- set(key, value, touch = Touch.None) {
60
- let item = this._map.get(key);
61
- if (item) {
62
- item.value = value;
63
- if (touch !== Touch.None) {
64
- this.touch(item, touch);
65
- }
66
- }
67
- else {
68
- item = { key, value, next: undefined, previous: undefined };
69
- switch (touch) {
70
- case Touch.None:
71
- this.addItemLast(item);
72
- break;
73
- case Touch.First:
74
- this.addItemFirst(item);
75
- break;
76
- case Touch.Last:
77
- this.addItemLast(item);
78
- break;
79
- default:
80
- this.addItemLast(item);
81
- break;
82
- }
83
- this._map.set(key, item);
84
- this._size++;
85
- }
86
- return this;
87
- }
88
- delete(key) {
89
- return !!this.remove(key);
90
- }
91
- remove(key) {
92
- const item = this._map.get(key);
93
- if (!item) {
94
- return undefined;
95
- }
96
- this._map.delete(key);
97
- this.removeItem(item);
98
- this._size--;
99
- return item.value;
100
- }
101
- shift() {
102
- if (!this._head && !this._tail) {
103
- return undefined;
104
- }
105
- if (!this._head || !this._tail) {
106
- throw new Error('Invalid list');
107
- }
108
- const item = this._head;
109
- this._map.delete(item.key);
110
- this.removeItem(item);
111
- this._size--;
112
- return item.value;
113
- }
114
- forEach(callbackfn, thisArg) {
115
- const state = this._state;
116
- let current = this._head;
117
- while (current) {
118
- if (thisArg) {
119
- callbackfn.bind(thisArg)(current.value, current.key, this);
120
- }
121
- else {
122
- callbackfn(current.value, current.key, this);
123
- }
124
- if (this._state !== state) {
125
- throw new Error(`LinkedMap got modified during iteration.`);
126
- }
127
- current = current.next;
128
- }
129
- }
130
- keys() {
131
- const state = this._state;
132
- let current = this._head;
133
- const iterator = {
134
- [Symbol.iterator]: () => {
135
- return iterator;
136
- },
137
- next: () => {
138
- if (this._state !== state) {
139
- throw new Error(`LinkedMap got modified during iteration.`);
140
- }
141
- if (current) {
142
- const result = { value: current.key, done: false };
143
- current = current.next;
144
- return result;
145
- }
146
- else {
147
- return { value: undefined, done: true };
148
- }
149
- }
150
- };
151
- return iterator;
152
- }
153
- values() {
154
- const state = this._state;
155
- let current = this._head;
156
- const iterator = {
157
- [Symbol.iterator]: () => {
158
- return iterator;
159
- },
160
- next: () => {
161
- if (this._state !== state) {
162
- throw new Error(`LinkedMap got modified during iteration.`);
163
- }
164
- if (current) {
165
- const result = { value: current.value, done: false };
166
- current = current.next;
167
- return result;
168
- }
169
- else {
170
- return { value: undefined, done: true };
171
- }
172
- }
173
- };
174
- return iterator;
175
- }
176
- entries() {
177
- const state = this._state;
178
- let current = this._head;
179
- const iterator = {
180
- [Symbol.iterator]: () => {
181
- return iterator;
182
- },
183
- next: () => {
184
- if (this._state !== state) {
185
- throw new Error(`LinkedMap got modified during iteration.`);
186
- }
187
- if (current) {
188
- const result = { value: [current.key, current.value], done: false };
189
- current = current.next;
190
- return result;
191
- }
192
- else {
193
- return { value: undefined, done: true };
194
- }
195
- }
196
- };
197
- return iterator;
198
- }
199
- [(_a = Symbol.toStringTag, Symbol.iterator)]() {
200
- return this.entries();
201
- }
202
- trimOld(newSize) {
203
- if (newSize >= this.size) {
204
- return;
205
- }
206
- if (newSize === 0) {
207
- this.clear();
208
- return;
209
- }
210
- let current = this._head;
211
- let currentSize = this.size;
212
- while (current && currentSize > newSize) {
213
- this._map.delete(current.key);
214
- current = current.next;
215
- currentSize--;
216
- }
217
- this._head = current;
218
- this._size = currentSize;
219
- if (current) {
220
- current.previous = undefined;
221
- }
222
- this._state++;
223
- }
224
- addItemFirst(item) {
225
- if (!this._head && !this._tail) {
226
- this._tail = item;
227
- }
228
- else if (!this._head) {
229
- throw new Error('Invalid list');
230
- }
231
- else {
232
- item.next = this._head;
233
- this._head.previous = item;
234
- }
235
- this._head = item;
236
- this._state++;
237
- }
238
- addItemLast(item) {
239
- if (!this._head && !this._tail) {
240
- this._head = item;
241
- }
242
- else if (!this._tail) {
243
- throw new Error('Invalid list');
244
- }
245
- else {
246
- item.previous = this._tail;
247
- this._tail.next = item;
248
- }
249
- this._tail = item;
250
- this._state++;
251
- }
252
- removeItem(item) {
253
- if (item === this._head && item === this._tail) {
254
- this._head = undefined;
255
- this._tail = undefined;
256
- }
257
- else if (item === this._head) {
258
- if (!item.next) {
259
- throw new Error('Invalid list');
260
- }
261
- item.next.previous = undefined;
262
- this._head = item.next;
263
- }
264
- else if (item === this._tail) {
265
- if (!item.previous) {
266
- throw new Error('Invalid list');
267
- }
268
- item.previous.next = undefined;
269
- this._tail = item.previous;
270
- }
271
- else {
272
- const next = item.next;
273
- const previous = item.previous;
274
- if (!next || !previous) {
275
- throw new Error('Invalid list');
276
- }
277
- next.previous = previous;
278
- previous.next = next;
279
- }
280
- item.next = undefined;
281
- item.previous = undefined;
282
- this._state++;
283
- }
284
- touch(item, touch) {
285
- if (!this._head || !this._tail) {
286
- throw new Error('Invalid list');
287
- }
288
- if ((touch !== Touch.First && touch !== Touch.Last)) {
289
- return;
290
- }
291
- if (touch === Touch.First) {
292
- if (item === this._head) {
293
- return;
294
- }
295
- const next = item.next;
296
- const previous = item.previous;
297
- if (item === this._tail) {
298
- previous.next = undefined;
299
- this._tail = previous;
300
- }
301
- else {
302
- next.previous = previous;
303
- previous.next = next;
304
- }
305
- item.previous = undefined;
306
- item.next = this._head;
307
- this._head.previous = item;
308
- this._head = item;
309
- this._state++;
310
- }
311
- else if (touch === Touch.Last) {
312
- if (item === this._tail) {
313
- return;
314
- }
315
- const next = item.next;
316
- const previous = item.previous;
317
- if (item === this._head) {
318
- next.previous = undefined;
319
- this._head = next;
320
- }
321
- else {
322
- next.previous = previous;
323
- previous.next = next;
324
- }
325
- item.next = undefined;
326
- item.previous = this._tail;
327
- this._tail.next = item;
328
- this._tail = item;
329
- this._state++;
330
- }
331
- }
332
- toJSON() {
333
- const data = [];
334
- this.forEach((value, key) => {
335
- data.push([key, value]);
336
- });
337
- return data;
338
- }
339
- fromJSON(data) {
340
- this.clear();
341
- for (const [key, value] of data) {
342
- this.set(key, value);
343
- }
344
- }
345
- }
346
- exports.LinkedMap = LinkedMap;
347
- class LRUCache extends LinkedMap {
348
- constructor(limit, ratio = 1) {
349
- super();
350
- this._limit = limit;
351
- this._ratio = Math.min(Math.max(0, ratio), 1);
352
- }
353
- get limit() {
354
- return this._limit;
355
- }
356
- set limit(limit) {
357
- this._limit = limit;
358
- this.checkTrim();
359
- }
360
- get ratio() {
361
- return this._ratio;
362
- }
363
- set ratio(ratio) {
364
- this._ratio = Math.min(Math.max(0, ratio), 1);
365
- this.checkTrim();
366
- }
367
- get(key, touch = Touch.AsNew) {
368
- return super.get(key, touch);
369
- }
370
- peek(key) {
371
- return super.get(key, Touch.None);
372
- }
373
- set(key, value) {
374
- super.set(key, value, Touch.Last);
375
- this.checkTrim();
376
- return this;
377
- }
378
- checkTrim() {
379
- if (this.size > this._limit) {
380
- this.trimOld(Math.round(this._limit * this._ratio));
381
- }
382
- }
383
- }
384
- exports.LRUCache = LRUCache;
385
- } (linkedMap));
6
+ var _a;
7
+ Object.defineProperty(linkedMap, "__esModule", { value: true });
8
+ linkedMap.LRUCache = linkedMap.LinkedMap = linkedMap.Touch = void 0;
9
+ var Touch;
10
+ (function (Touch) {
11
+ Touch.None = 0;
12
+ Touch.First = 1;
13
+ Touch.AsOld = Touch.First;
14
+ Touch.Last = 2;
15
+ Touch.AsNew = Touch.Last;
16
+ })(Touch || (linkedMap.Touch = Touch = {}));
17
+ class LinkedMap {
18
+ constructor() {
19
+ this[_a] = 'LinkedMap';
20
+ this._map = new Map();
21
+ this._head = undefined;
22
+ this._tail = undefined;
23
+ this._size = 0;
24
+ this._state = 0;
25
+ }
26
+ clear() {
27
+ this._map.clear();
28
+ this._head = undefined;
29
+ this._tail = undefined;
30
+ this._size = 0;
31
+ this._state++;
32
+ }
33
+ isEmpty() {
34
+ return !this._head && !this._tail;
35
+ }
36
+ get size() {
37
+ return this._size;
38
+ }
39
+ get first() {
40
+ return this._head?.value;
41
+ }
42
+ get last() {
43
+ return this._tail?.value;
44
+ }
45
+ has(key) {
46
+ return this._map.has(key);
47
+ }
48
+ get(key, touch = Touch.None) {
49
+ const item = this._map.get(key);
50
+ if (!item) {
51
+ return undefined;
52
+ }
53
+ if (touch !== Touch.None) {
54
+ this.touch(item, touch);
55
+ }
56
+ return item.value;
57
+ }
58
+ set(key, value, touch = Touch.None) {
59
+ let item = this._map.get(key);
60
+ if (item) {
61
+ item.value = value;
62
+ if (touch !== Touch.None) {
63
+ this.touch(item, touch);
64
+ }
65
+ }
66
+ else {
67
+ item = { key, value, next: undefined, previous: undefined };
68
+ switch (touch) {
69
+ case Touch.None:
70
+ this.addItemLast(item);
71
+ break;
72
+ case Touch.First:
73
+ this.addItemFirst(item);
74
+ break;
75
+ case Touch.Last:
76
+ this.addItemLast(item);
77
+ break;
78
+ default:
79
+ this.addItemLast(item);
80
+ break;
81
+ }
82
+ this._map.set(key, item);
83
+ this._size++;
84
+ }
85
+ return this;
86
+ }
87
+ delete(key) {
88
+ return !!this.remove(key);
89
+ }
90
+ remove(key) {
91
+ const item = this._map.get(key);
92
+ if (!item) {
93
+ return undefined;
94
+ }
95
+ this._map.delete(key);
96
+ this.removeItem(item);
97
+ this._size--;
98
+ return item.value;
99
+ }
100
+ shift() {
101
+ if (!this._head && !this._tail) {
102
+ return undefined;
103
+ }
104
+ if (!this._head || !this._tail) {
105
+ throw new Error('Invalid list');
106
+ }
107
+ const item = this._head;
108
+ this._map.delete(item.key);
109
+ this.removeItem(item);
110
+ this._size--;
111
+ return item.value;
112
+ }
113
+ forEach(callbackfn, thisArg) {
114
+ const state = this._state;
115
+ let current = this._head;
116
+ while (current) {
117
+ if (thisArg) {
118
+ callbackfn.bind(thisArg)(current.value, current.key, this);
119
+ }
120
+ else {
121
+ callbackfn(current.value, current.key, this);
122
+ }
123
+ if (this._state !== state) {
124
+ throw new Error(`LinkedMap got modified during iteration.`);
125
+ }
126
+ current = current.next;
127
+ }
128
+ }
129
+ keys() {
130
+ const state = this._state;
131
+ let current = this._head;
132
+ const iterator = {
133
+ [Symbol.iterator]: () => {
134
+ return iterator;
135
+ },
136
+ next: () => {
137
+ if (this._state !== state) {
138
+ throw new Error(`LinkedMap got modified during iteration.`);
139
+ }
140
+ if (current) {
141
+ const result = { value: current.key, done: false };
142
+ current = current.next;
143
+ return result;
144
+ }
145
+ else {
146
+ return { value: undefined, done: true };
147
+ }
148
+ }
149
+ };
150
+ return iterator;
151
+ }
152
+ values() {
153
+ const state = this._state;
154
+ let current = this._head;
155
+ const iterator = {
156
+ [Symbol.iterator]: () => {
157
+ return iterator;
158
+ },
159
+ next: () => {
160
+ if (this._state !== state) {
161
+ throw new Error(`LinkedMap got modified during iteration.`);
162
+ }
163
+ if (current) {
164
+ const result = { value: current.value, done: false };
165
+ current = current.next;
166
+ return result;
167
+ }
168
+ else {
169
+ return { value: undefined, done: true };
170
+ }
171
+ }
172
+ };
173
+ return iterator;
174
+ }
175
+ entries() {
176
+ const state = this._state;
177
+ let current = this._head;
178
+ const iterator = {
179
+ [Symbol.iterator]: () => {
180
+ return iterator;
181
+ },
182
+ next: () => {
183
+ if (this._state !== state) {
184
+ throw new Error(`LinkedMap got modified during iteration.`);
185
+ }
186
+ if (current) {
187
+ const result = { value: [current.key, current.value], done: false };
188
+ current = current.next;
189
+ return result;
190
+ }
191
+ else {
192
+ return { value: undefined, done: true };
193
+ }
194
+ }
195
+ };
196
+ return iterator;
197
+ }
198
+ [(_a = Symbol.toStringTag, Symbol.iterator)]() {
199
+ return this.entries();
200
+ }
201
+ trimOld(newSize) {
202
+ if (newSize >= this.size) {
203
+ return;
204
+ }
205
+ if (newSize === 0) {
206
+ this.clear();
207
+ return;
208
+ }
209
+ let current = this._head;
210
+ let currentSize = this.size;
211
+ while (current && currentSize > newSize) {
212
+ this._map.delete(current.key);
213
+ current = current.next;
214
+ currentSize--;
215
+ }
216
+ this._head = current;
217
+ this._size = currentSize;
218
+ if (current) {
219
+ current.previous = undefined;
220
+ }
221
+ this._state++;
222
+ }
223
+ addItemFirst(item) {
224
+ if (!this._head && !this._tail) {
225
+ this._tail = item;
226
+ }
227
+ else if (!this._head) {
228
+ throw new Error('Invalid list');
229
+ }
230
+ else {
231
+ item.next = this._head;
232
+ this._head.previous = item;
233
+ }
234
+ this._head = item;
235
+ this._state++;
236
+ }
237
+ addItemLast(item) {
238
+ if (!this._head && !this._tail) {
239
+ this._head = item;
240
+ }
241
+ else if (!this._tail) {
242
+ throw new Error('Invalid list');
243
+ }
244
+ else {
245
+ item.previous = this._tail;
246
+ this._tail.next = item;
247
+ }
248
+ this._tail = item;
249
+ this._state++;
250
+ }
251
+ removeItem(item) {
252
+ if (item === this._head && item === this._tail) {
253
+ this._head = undefined;
254
+ this._tail = undefined;
255
+ }
256
+ else if (item === this._head) {
257
+ if (!item.next) {
258
+ throw new Error('Invalid list');
259
+ }
260
+ item.next.previous = undefined;
261
+ this._head = item.next;
262
+ }
263
+ else if (item === this._tail) {
264
+ if (!item.previous) {
265
+ throw new Error('Invalid list');
266
+ }
267
+ item.previous.next = undefined;
268
+ this._tail = item.previous;
269
+ }
270
+ else {
271
+ const next = item.next;
272
+ const previous = item.previous;
273
+ if (!next || !previous) {
274
+ throw new Error('Invalid list');
275
+ }
276
+ next.previous = previous;
277
+ previous.next = next;
278
+ }
279
+ item.next = undefined;
280
+ item.previous = undefined;
281
+ this._state++;
282
+ }
283
+ touch(item, touch) {
284
+ if (!this._head || !this._tail) {
285
+ throw new Error('Invalid list');
286
+ }
287
+ if ((touch !== Touch.First && touch !== Touch.Last)) {
288
+ return;
289
+ }
290
+ if (touch === Touch.First) {
291
+ if (item === this._head) {
292
+ return;
293
+ }
294
+ const next = item.next;
295
+ const previous = item.previous;
296
+ if (item === this._tail) {
297
+ previous.next = undefined;
298
+ this._tail = previous;
299
+ }
300
+ else {
301
+ next.previous = previous;
302
+ previous.next = next;
303
+ }
304
+ item.previous = undefined;
305
+ item.next = this._head;
306
+ this._head.previous = item;
307
+ this._head = item;
308
+ this._state++;
309
+ }
310
+ else if (touch === Touch.Last) {
311
+ if (item === this._tail) {
312
+ return;
313
+ }
314
+ const next = item.next;
315
+ const previous = item.previous;
316
+ if (item === this._head) {
317
+ next.previous = undefined;
318
+ this._head = next;
319
+ }
320
+ else {
321
+ next.previous = previous;
322
+ previous.next = next;
323
+ }
324
+ item.next = undefined;
325
+ item.previous = this._tail;
326
+ this._tail.next = item;
327
+ this._tail = item;
328
+ this._state++;
329
+ }
330
+ }
331
+ toJSON() {
332
+ const data = [];
333
+ this.forEach((value, key) => {
334
+ data.push([key, value]);
335
+ });
336
+ return data;
337
+ }
338
+ fromJSON(data) {
339
+ this.clear();
340
+ for (const [key, value] of data) {
341
+ this.set(key, value);
342
+ }
343
+ }
344
+ }
345
+ linkedMap.LinkedMap = LinkedMap;
346
+ class LRUCache extends LinkedMap {
347
+ constructor(limit, ratio = 1) {
348
+ super();
349
+ this._limit = limit;
350
+ this._ratio = Math.min(Math.max(0, ratio), 1);
351
+ }
352
+ get limit() {
353
+ return this._limit;
354
+ }
355
+ set limit(limit) {
356
+ this._limit = limit;
357
+ this.checkTrim();
358
+ }
359
+ get ratio() {
360
+ return this._ratio;
361
+ }
362
+ set ratio(ratio) {
363
+ this._ratio = Math.min(Math.max(0, ratio), 1);
364
+ this.checkTrim();
365
+ }
366
+ get(key, touch = Touch.AsNew) {
367
+ return super.get(key, touch);
368
+ }
369
+ peek(key) {
370
+ return super.get(key, Touch.None);
371
+ }
372
+ set(key, value) {
373
+ super.set(key, value, Touch.Last);
374
+ this.checkTrim();
375
+ return this;
376
+ }
377
+ checkTrim() {
378
+ if (this.size > this._limit) {
379
+ this.trimOld(Math.round(this._limit * this._ratio));
380
+ }
381
+ }
382
+ }
383
+ linkedMap.LRUCache = LRUCache;
386
384
  return linkedMap;
387
385
  }
388
386
  export { requireLinkedMap as __require };