@opensumi/ide-core-common 2.21.13 → 2.22.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 (159) hide show
  1. package/lib/command.d.ts +15 -5
  2. package/lib/command.d.ts.map +1 -1
  3. package/lib/command.js +11 -1
  4. package/lib/command.js.map +1 -1
  5. package/lib/const/application.d.ts +6 -1
  6. package/lib/const/application.d.ts.map +1 -1
  7. package/lib/const/application.js +8 -3
  8. package/lib/const/application.js.map +1 -1
  9. package/lib/declare.d.ts +2 -2
  10. package/lib/declare.d.ts.map +1 -1
  11. package/lib/editor.d.ts +4 -0
  12. package/lib/editor.d.ts.map +1 -1
  13. package/lib/electron.d.ts +1 -1
  14. package/lib/electron.d.ts.map +1 -1
  15. package/lib/event-bus/event-bus-types.d.ts +1 -1
  16. package/lib/event-bus/event-bus-types.d.ts.map +1 -1
  17. package/lib/event-bus/event-bus.js.map +1 -1
  18. package/lib/event-bus/event-decorator.js.map +1 -1
  19. package/lib/extension.schema.d.ts +1 -1
  20. package/lib/extension.schema.d.ts.map +1 -1
  21. package/lib/hash-calculate/WASMInterface.d.ts +2 -2
  22. package/lib/hash-calculate/WASMInterface.d.ts.map +1 -1
  23. package/lib/hash-calculate/hash-calculate.js.map +1 -1
  24. package/lib/hash-calculate/util.d.ts +2 -2
  25. package/lib/hash-calculate/util.d.ts.map +1 -1
  26. package/lib/json-schema.d.ts +9 -0
  27. package/lib/json-schema.d.ts.map +1 -1
  28. package/lib/keyboard/keymap.d.ts +1 -1
  29. package/lib/keyboard/keymap.d.ts.map +1 -1
  30. package/lib/localize.d.ts +1 -1
  31. package/lib/localize.d.ts.map +1 -1
  32. package/lib/log.d.ts +2 -2
  33. package/lib/log.d.ts.map +1 -1
  34. package/lib/mime.d.ts +6 -6
  35. package/lib/module.js.map +1 -1
  36. package/lib/preferences/preference-schema.d.ts +13 -3
  37. package/lib/preferences/preference-schema.d.ts.map +1 -1
  38. package/lib/preferences/preference-schema.js +11 -1
  39. package/lib/preferences/preference-schema.js.map +1 -1
  40. package/lib/preferences/preference-scope.d.ts +8 -1
  41. package/lib/preferences/preference-scope.d.ts.map +1 -1
  42. package/lib/preferences/preference-scope.js +11 -2
  43. package/lib/preferences/preference-scope.js.map +1 -1
  44. package/lib/problem-matcher.d.ts +1 -1
  45. package/lib/problem-matcher.d.ts.map +1 -1
  46. package/lib/problem-matcher.js.map +1 -1
  47. package/lib/problem-pattern.d.ts +4 -2
  48. package/lib/problem-pattern.d.ts.map +1 -1
  49. package/lib/problem-pattern.js +24 -1
  50. package/lib/problem-pattern.js.map +1 -1
  51. package/lib/reference.d.ts +2 -1
  52. package/lib/reference.d.ts.map +1 -1
  53. package/lib/reference.js +11 -6
  54. package/lib/reference.js.map +1 -1
  55. package/lib/reporter.js.map +1 -1
  56. package/lib/storage.d.ts +1 -1
  57. package/lib/storage.d.ts.map +1 -1
  58. package/lib/storage.js.map +1 -1
  59. package/lib/task-definition.js.map +1 -1
  60. package/lib/types/common.d.ts +1 -1
  61. package/lib/types/common.d.ts.map +1 -1
  62. package/lib/types/editor.d.ts +2 -2
  63. package/lib/types/editor.d.ts.map +1 -1
  64. package/lib/types/file-watch.d.ts +1 -1
  65. package/lib/types/file-watch.d.ts.map +1 -1
  66. package/lib/types/markers/markers-manager.d.ts.map +1 -1
  67. package/lib/types/markers/markers-manager.js +4 -10
  68. package/lib/types/markers/markers-manager.js.map +1 -1
  69. package/lib/types/markers/markers.d.ts +2 -0
  70. package/lib/types/markers/markers.d.ts.map +1 -1
  71. package/lib/types/markers/markers.js.map +1 -1
  72. package/package.json +7 -6
  73. package/src/LifeCyclePhase.ts +6 -0
  74. package/src/application-error.ts +77 -0
  75. package/src/application-props.ts +28 -0
  76. package/src/application.lifecycle.ts +15 -0
  77. package/src/browser-fs/ensure-dir.ts +46 -0
  78. package/src/browser-fs/util.ts +52 -0
  79. package/src/clipboard.ts +31 -0
  80. package/src/command.ts +726 -0
  81. package/src/commands/terminal.ts +0 -0
  82. package/src/comparers.ts +152 -0
  83. package/src/connection.ts +7 -0
  84. package/src/const/application.ts +11 -0
  85. package/src/const/index.ts +1 -0
  86. package/src/contribution-provider.ts +47 -0
  87. package/src/credential.ts +21 -0
  88. package/src/crypto.ts +8 -0
  89. package/src/declare.ts +3 -0
  90. package/src/di-helper/domain-helper.ts +48 -0
  91. package/src/di-helper/index.ts +1 -0
  92. package/src/editor.ts +6 -0
  93. package/src/electron.ts +168 -0
  94. package/src/env.ts +1 -0
  95. package/src/event-bus/basic-event.ts +3 -0
  96. package/src/event-bus/event-bus-types.ts +68 -0
  97. package/src/event-bus/event-bus.ts +57 -0
  98. package/src/event-bus/event-decorator.ts +32 -0
  99. package/src/event-bus/index.ts +4 -0
  100. package/src/extension.schema.ts +16 -0
  101. package/src/hash-calculate/WASMInterface.ts +266 -0
  102. package/src/hash-calculate/hash-calculate.ts +53 -0
  103. package/src/hash-calculate/lockedCreate.ts +17 -0
  104. package/src/hash-calculate/md5.wasm.json +1 -0
  105. package/src/hash-calculate/mutex.ts +30 -0
  106. package/src/hash-calculate/util.ts +190 -0
  107. package/src/id-generator.ts +15 -0
  108. package/src/index.ts +39 -0
  109. package/src/json-schema.ts +80 -0
  110. package/src/keyboard/index.ts +2 -0
  111. package/src/keyboard/keyboard-layout-provider.ts +46 -0
  112. package/src/keyboard/keymap.ts +224 -0
  113. package/src/line-text.ts +93 -0
  114. package/src/localize.ts +203 -0
  115. package/src/log.ts +338 -0
  116. package/src/markdown.ts +8 -0
  117. package/src/menu.ts +31 -0
  118. package/src/mime.ts +8 -0
  119. package/src/mocks/electron/browserMock.ts +10 -0
  120. package/src/mocks/electron/ipcRenderer.ts +30 -0
  121. package/src/module.ts +31 -0
  122. package/src/network.ts +47 -0
  123. package/src/node/cli.ts +5 -0
  124. package/src/node/port.ts +134 -0
  125. package/src/preferences/index.ts +2 -0
  126. package/src/preferences/preference-schema.ts +122 -0
  127. package/src/preferences/preference-scope.ts +65 -0
  128. package/src/problem-matcher.ts +389 -0
  129. package/src/problem-pattern.ts +574 -0
  130. package/src/range.ts +24 -0
  131. package/src/reference.ts +141 -0
  132. package/src/reporter.ts +64 -0
  133. package/src/settings/general.ts +5 -0
  134. package/src/settings/index.ts +3 -0
  135. package/src/settings/search.ts +7 -0
  136. package/src/settings/terminal.ts +9 -0
  137. package/src/storage.ts +99 -0
  138. package/src/task-definition.ts +172 -0
  139. package/src/theme.ts +7 -0
  140. package/src/types/accessibility.ts +4 -0
  141. package/src/types/application.ts +14 -0
  142. package/src/types/authentication.ts +120 -0
  143. package/src/types/common.ts +14 -0
  144. package/src/types/dnd.ts +8 -0
  145. package/src/types/editor.ts +246 -0
  146. package/src/types/extension.ts +96 -0
  147. package/src/types/file-watch.ts +100 -0
  148. package/src/types/file.ts +262 -0
  149. package/src/types/index.ts +15 -0
  150. package/src/types/markdown.ts +10 -0
  151. package/src/types/markers/index.ts +2 -0
  152. package/src/types/markers/markers-manager.ts +392 -0
  153. package/src/types/markers/markers.ts +125 -0
  154. package/src/types/message.ts +6 -0
  155. package/src/types/reporter.ts +96 -0
  156. package/src/types/statusbar.ts +6 -0
  157. package/src/types/string.ts +3 -0
  158. package/src/utils/index.ts +1 -0
  159. package/src/utils/ipc.ts +28 -0
@@ -0,0 +1,266 @@
1
+ /* ---------------------------------------------------------------------------------------------
2
+ * MIT License Copyright (c) 2020 Dani All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ * https://github.com/Daninet/hash-wasm
5
+ *--------------------------------------------------------------------------------------------*/
6
+
7
+ // copy and modified from https://github.com/Daninet/hash-wasm/blob/bd3a205ca5603fc80adf71d0966fc72e8d4fa0ef/lib/WASMInterface.ts
8
+
9
+ import { Mutex } from './mutex';
10
+ import { decodeBase64, getDigestHex, getUInt8Buffer, IDataType, writeHexToUInt8, hexStringEqualsUInt8 } from './util';
11
+
12
+ export const MAX_HEAP = 16 * 1024;
13
+ const WASM_FUNC_HASH_LENGTH = 4;
14
+ const wasmMutex = new Mutex();
15
+
16
+ type ThenArg<T> = T extends Promise<infer U> ? U : T extends (...args: any[]) => Promise<infer V> ? V : T;
17
+
18
+ export interface IHasher {
19
+ /**
20
+ * Initializes hash state to default value
21
+ */
22
+ init: () => IHasher;
23
+ /**
24
+ * Updates the hash content with the given data
25
+ */
26
+ update: (data: IDataType) => IHasher;
27
+ /**
28
+ * Calculates the hash of all of the data passed to be hashed with hash.update().
29
+ * Defaults to hexadecimal string
30
+ * @param outputType If outputType is "binary", it returns Uint8Array. Otherwise it
31
+ * returns hexadecimal string
32
+ */
33
+ digest: {
34
+ (outputType: 'binary'): Uint8Array;
35
+ (outputType?: 'hex'): string;
36
+ };
37
+ /**
38
+ * Save the current internal state of the hasher for later resumption with load().
39
+ * Cannot be called before .init() or after .digest()
40
+ *
41
+ * Note that this state can include arbitrary information about the value being hashed (e.g.
42
+ * could include N plaintext bytes from the value), so needs to be treated as being as
43
+ * sensitive as the input value itself.
44
+ */
45
+ save: () => Uint8Array;
46
+ /**
47
+ * Resume a state that was created by save(). If this state was not created by a
48
+ * compatible build of hash-wasm, an exception will be thrown.
49
+ */
50
+ load: (state: Uint8Array) => IHasher;
51
+ /**
52
+ * Block size in bytes
53
+ */
54
+ blockSize: number;
55
+ /**
56
+ * Digest size in bytes
57
+ */
58
+ digestSize: number;
59
+ }
60
+
61
+ const wasmModuleCache = new Map<string, Promise<WebAssembly.Module>>();
62
+
63
+ export async function WASMInterface(binary: any, hashLength: number) {
64
+ let wasmInstance: WebAssembly.Instance | null = null;
65
+ let memoryView: Uint8Array | null = null;
66
+ let initialized = false;
67
+
68
+ if (typeof WebAssembly === 'undefined') {
69
+ throw new Error('WebAssembly is not supported in this environment!');
70
+ }
71
+
72
+ const writeMemory = (data: Uint8Array, offset = 0) => {
73
+ memoryView?.set(data, offset);
74
+ };
75
+
76
+ const getMemory = () => memoryView;
77
+ const getExports = () => wasmInstance?.exports;
78
+
79
+ const setMemorySize = (totalSize: number) => {
80
+ (wasmInstance?.exports as any).Hash_SetMemorySize(totalSize);
81
+ const arrayOffset: number = (wasmInstance?.exports as any).Hash_GetBuffer();
82
+ const memoryBuffer = (wasmInstance?.exports as any).memory.buffer;
83
+ memoryView = new Uint8Array(memoryBuffer, arrayOffset, totalSize);
84
+ };
85
+
86
+ const getStateSize = () => {
87
+ const view = new DataView((wasmInstance?.exports as any).memory.buffer);
88
+ const stateSize = view.getUint32((wasmInstance?.exports as any).STATE_SIZE, true);
89
+ return stateSize;
90
+ };
91
+
92
+ const loadWASMPromise = wasmMutex.dispatch(async () => {
93
+ if (!wasmModuleCache.has(binary.name)) {
94
+ const asm = decodeBase64(binary.data);
95
+ const promise = WebAssembly.compile(asm);
96
+
97
+ wasmModuleCache.set(binary.name, promise);
98
+ }
99
+
100
+ const module = await wasmModuleCache.get(binary.name);
101
+ wasmInstance = await WebAssembly.instantiate(module!);
102
+ });
103
+
104
+ const setupInterface = async () => {
105
+ if (!wasmInstance) {
106
+ await loadWASMPromise;
107
+ }
108
+
109
+ const arrayOffset: number = (wasmInstance?.exports as any).Hash_GetBuffer();
110
+ const memoryBuffer = (wasmInstance?.exports as any).memory.buffer;
111
+ memoryView = new Uint8Array(memoryBuffer, arrayOffset, MAX_HEAP);
112
+ };
113
+
114
+ const init = (bits: number | null = null) => {
115
+ initialized = true;
116
+ (wasmInstance?.exports as any).Hash_Init(bits);
117
+ };
118
+
119
+ const updateUInt8Array = (data: Uint8Array): void => {
120
+ let read = 0;
121
+ while (read < data.length) {
122
+ const chunk = data.subarray(read, read + MAX_HEAP);
123
+ read += chunk.length;
124
+ memoryView?.set(chunk);
125
+ (wasmInstance?.exports as any).Hash_Update(chunk.length);
126
+ }
127
+ };
128
+
129
+ const update = (data: IDataType) => {
130
+ if (!initialized) {
131
+ throw new Error('update() called before init()');
132
+ }
133
+ const Uint8Buffer = getUInt8Buffer(data);
134
+ updateUInt8Array(Uint8Buffer);
135
+ };
136
+
137
+ const digestChars = new Uint8Array(hashLength * 2);
138
+
139
+ const digest = (outputType: 'hex' | 'binary', padding: number | null = null): Uint8Array | string => {
140
+ if (!initialized) {
141
+ throw new Error('digest() called before init()');
142
+ }
143
+ initialized = false;
144
+
145
+ (wasmInstance?.exports as any).Hash_Final(padding);
146
+
147
+ if (outputType === 'binary') {
148
+ // the data is copied to allow GC of the original memory object
149
+ return memoryView!.slice(0, hashLength);
150
+ }
151
+
152
+ return getDigestHex(digestChars, memoryView!, hashLength);
153
+ };
154
+
155
+ const save = (): Uint8Array => {
156
+ if (!initialized) {
157
+ throw new Error('save() can only be called after init() and before digest()');
158
+ }
159
+
160
+ const stateOffset: number = (wasmInstance?.exports as any).Hash_GetState();
161
+ const stateLength: number = getStateSize();
162
+ const memoryBuffer = (wasmInstance?.exports as any).memory.buffer;
163
+ const internalState = new Uint8Array(memoryBuffer, stateOffset, stateLength);
164
+
165
+ // prefix is 4 bytes from SHA1 hash of the WASM binary
166
+ // it is used to detect incompatible internal states between different versions of hash-wasm
167
+ const prefixedState = new Uint8Array(WASM_FUNC_HASH_LENGTH + stateLength);
168
+ writeHexToUInt8(prefixedState, binary.hash);
169
+ prefixedState.set(internalState, WASM_FUNC_HASH_LENGTH);
170
+ return prefixedState;
171
+ };
172
+
173
+ const load = (state: Uint8Array) => {
174
+ if (!(state instanceof Uint8Array)) {
175
+ throw new Error('load() expects an Uint8Array generated by save()');
176
+ }
177
+
178
+ const stateOffset: number = (wasmInstance?.exports as any).Hash_GetState();
179
+ const stateLength: number = getStateSize();
180
+ const overallLength: number = WASM_FUNC_HASH_LENGTH + stateLength;
181
+ const memoryBuffer = (wasmInstance?.exports as any).memory.buffer;
182
+
183
+ if (state.length !== overallLength) {
184
+ throw new Error(`Bad state length (expected ${overallLength} bytes, got ${state.length})`);
185
+ }
186
+
187
+ if (!hexStringEqualsUInt8(binary.hash, state.subarray(0, WASM_FUNC_HASH_LENGTH))) {
188
+ throw new Error('This state was written by an incompatible hash implementation');
189
+ }
190
+
191
+ const internalState = state.subarray(WASM_FUNC_HASH_LENGTH);
192
+ new Uint8Array(memoryBuffer, stateOffset, stateLength).set(internalState);
193
+ initialized = true;
194
+ };
195
+
196
+ const isDataShort = (data: IDataType) => {
197
+ if (typeof data === 'string') {
198
+ // worst case is 4 bytes / char
199
+ return data.length < MAX_HEAP / 4;
200
+ }
201
+
202
+ return data.byteLength < MAX_HEAP;
203
+ };
204
+
205
+ let canSimplify: (data: IDataType, initParam?: number) => boolean = isDataShort;
206
+
207
+ switch (binary.name) {
208
+ case 'argon2':
209
+ case 'scrypt':
210
+ canSimplify = () => true;
211
+ break;
212
+
213
+ case 'blake2b':
214
+ case 'blake2s':
215
+ // if there is a key at blake2 then cannot simplify
216
+ canSimplify = (data, initParam) => initParam! <= 512 && isDataShort(data);
217
+ break;
218
+
219
+ case 'blake3':
220
+ // if there is a key at blake3 then cannot simplify
221
+ canSimplify = (data, initParam) => initParam === 0 && isDataShort(data);
222
+ break;
223
+
224
+ case 'xxhash64': // cannot simplify
225
+ case 'xxhash3':
226
+ case 'xxhash128':
227
+ canSimplify = () => false;
228
+ break;
229
+
230
+ default:
231
+ break;
232
+ }
233
+
234
+ // shorthand for (init + update + digest) for better performance
235
+ const calculate = (data: IDataType, initParam = null, digestParam = null): string => {
236
+ if (!canSimplify(data, initParam!)) {
237
+ init(initParam);
238
+ update(data);
239
+ return digest('hex', digestParam) as string;
240
+ }
241
+
242
+ const buffer = getUInt8Buffer(data);
243
+ memoryView?.set(buffer);
244
+ (wasmInstance?.exports as any).Hash_Calculate(buffer.length, initParam, digestParam);
245
+
246
+ return getDigestHex(digestChars, memoryView!, hashLength);
247
+ };
248
+
249
+ await setupInterface();
250
+
251
+ return {
252
+ getMemory,
253
+ writeMemory,
254
+ getExports,
255
+ setMemorySize,
256
+ init,
257
+ update,
258
+ digest,
259
+ save,
260
+ load,
261
+ calculate,
262
+ hashLength,
263
+ };
264
+ }
265
+
266
+ export type IWASMInterface = ThenArg<ReturnType<typeof WASMInterface>>;
@@ -0,0 +1,53 @@
1
+ import { Injectable } from '@opensumi/di';
2
+ import { memoize } from '@opensumi/ide-utils';
3
+
4
+ import { lockedCreate } from './lockedCreate';
5
+ import wasmJson from './md5.wasm.json';
6
+ import { Mutex } from './mutex';
7
+ import { IDataType } from './util';
8
+
9
+ export const IHashCalculateService = Symbol('IHashCalculateService');
10
+
11
+ export interface IHashCalculateService {
12
+ initialize(): Promise<void>;
13
+
14
+ calculate(content: IDataType): string;
15
+
16
+ readonly initialized: boolean;
17
+ }
18
+
19
+ type Awaited<T> = T extends PromiseLike<infer U> ? U : T;
20
+
21
+ type Calculator = Awaited<ReturnType<typeof lockedCreate>>;
22
+
23
+ function md5WasmCalculatorFactory() {
24
+ const mutex = new Mutex();
25
+ return lockedCreate(mutex, wasmJson, 16);
26
+ }
27
+
28
+ @Injectable()
29
+ export class HashCalculateServiceImpl implements IHashCalculateService {
30
+ private cachedCalculator?: Calculator;
31
+
32
+ private _initialized = false;
33
+
34
+ public get initialized() {
35
+ return this._initialized;
36
+ }
37
+
38
+ @memoize
39
+ async initialize(): Promise<void> {
40
+ if (!this.cachedCalculator) {
41
+ this.cachedCalculator = await md5WasmCalculatorFactory();
42
+ }
43
+ this._initialized = true;
44
+ }
45
+
46
+ calculate(content: IDataType): string {
47
+ if (!this.initialized) {
48
+ throw new Error('Please call #initialize first!');
49
+ }
50
+ const hash = this.cachedCalculator!.calculate(content);
51
+ return hash;
52
+ }
53
+ }
@@ -0,0 +1,17 @@
1
+ /* ---------------------------------------------------------------------------------------------
2
+ * MIT License Copyright (c) 2020 Dani All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ * https://github.com/Daninet/hash-wasm
5
+ *--------------------------------------------------------------------------------------------*/
6
+
7
+ // copy and modified from https://github.com/Daninet/hash-wasm/blob/bd3a205ca5603fc80adf71d0966fc72e8d4fa0ef/lib/lockedCreate.ts
8
+
9
+ import { Mutex } from './mutex';
10
+ import { WASMInterface, IWASMInterface } from './WASMInterface';
11
+
12
+ export async function lockedCreate(mutex: Mutex, binary: any, hashLength: number): Promise<IWASMInterface> {
13
+ const unlock = await mutex.lock();
14
+ const wasm = await WASMInterface(binary, hashLength);
15
+ unlock();
16
+ return wasm;
17
+ }
@@ -0,0 +1 @@
1
+ {"name":"md5","data":"AGFzbQEAAAABEgRgAAF/YAAAYAF/AGACf38BfwMIBwABAgMBAAIEBQFwAQEBBQQBAQICBg4CfwFBoIoFC38AQYAICwdwCAZtZW1vcnkCAA5IYXNoX0dldEJ1ZmZlcgAACUhhc2hfSW5pdAABC0hhc2hfVXBkYXRlAAIKSGFzaF9GaW5hbAAEDUhhc2hfR2V0U3RhdGUABQ5IYXNoX0NhbGN1bGF0ZQAGClNUQVRFX1NJWkUDAQqzFgcFAEGACQstAEEAQv6568XpjpWZEDcCkIkBQQBCgcaUupbx6uZvNwKIiQFBAEIANwKAiQEL6AIBA39BAEEAKAKAiQEiASAAakH/////AXEiAjYCgIkBQQAoAoSJASEDAkAgAiABTw0AQQAgA0EBaiIDNgKEiQELQQAgAyAAQR12ajYChIkBAkACQAJAAkACQAJAIAFBP3EiAw0AQYAJIQIMAQtBwAAgA2siAiAASw0BIANBGGohA0EAIQEDQCADIAFqQYCJAWogAUGACWotAAA6AAAgAyABQQFqIgFqQdgARw0AC0GYiQFBwAAQAxogACACayEAIAJBgAlqIQILIABBwABPDQEgACEDDAILIABFDQJBACEBIANBmIkBakEALQCACToAACAAQQFGDQIgA0GZiQFqIQMgAEF/aiECA0AgAyABaiABQYEJai0AADoAACACIAFBAWoiAUcNAAwDCwsgAEE/cSEDIAIgAEFAcRADIQILIANFDQBBACEBA0AgAUGYiQFqIAIgAWotAAA6AAAgAyABQQFqIgFHDQALCwu0EAEZf0EAKAKUiQEhAkEAKAKQiQEhA0EAKAKMiQEhBEEAKAKIiQEhBQNAIABBCGooAgAiBiAAQRhqKAIAIgcgAEEoaigCACIIIABBOGooAgAiCSAAQTxqKAIAIgogAEEMaigCACILIABBHGooAgAiDCAAQSxqKAIAIg0gDCALIAogDSAJ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FWoiECASQX9zciAVc2pBz/yh/QZqQQZ3IBBqIhEgFUF/c3IgEHNqQeDNs3FqQQp3IBFqIhIgEEF/c3IgEXNqQZSGhZh6akEPdyASaiIVaiANIBJqIBQgEWogGCAQaiAVIBFBf3NyIBJzakGho6DwBGpBFXcgFWoiECASQX9zciAVc2pBgv3Nun9qQQZ3IBBqIhEgFUF/c3IgEHNqQbXk6+l7akEKdyARaiISIBBBf3NyIBFzakG7pd/WAmpBD3cgEmoiFSAEaiAWIBBqIBUgEUF/c3IgEnNqQZGnm9x+akEVd2ohBCAVIANqIQMgEiACaiECIBEgBWohBSAAQcAAaiEAIAFBQGoiAQ0AC0EAIAI2ApSJAUEAIAM2ApCJAUEAIAQ2AoyJAUEAIAU2AoiJASAAC6ECAQN/QQAoAoCJASIAQT9xIgFBmIkBakGAAToAAAJAAkACQCABQT9zIgJBB0sNAAJAIAJFDQAgAUGZiQFqIQADQCAAQQA6AAAgAEEBaiEAIAJBf2oiAg0ACwtBwAAhAkGYiQFBwAAQAxpBACEADAELIAJBCEYNASABQQFqIQALIABBj4kBaiEBA0AgASACakEAOgAAIAJBd2ohACACQX9qIQIgAEEASg0AC0EAKAKAiQEhAAtBACAAQRV2OgDTiQFBACAAQQ12OgDSiQFBACAAQQV2OgDRiQFBACAAQQN0IgI6ANCJAUEAIAI2AoCJAUEAQQAoAoSJATYC1IkBQZiJAUHAABADGkEAQQApAoiJATcDgAlBAEEAKQKQiQE3A4gJCwYAQYCJAQszAEEAQv6568XpjpWZEDcCkIkBQQBCgcaUupbx6uZvNwKIiQFBAEIANwKAiQEgABACEAQLCwsBAEGACAsEmAAAAA==","hash":"9b0fac7d"}
@@ -0,0 +1,30 @@
1
+ /* ---------------------------------------------------------------------------------------------
2
+ * MIT License Copyright (c) 2020 Dani All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ * https://github.com/Daninet/hash-wasm
5
+ *--------------------------------------------------------------------------------------------*/
6
+
7
+ // copy and modified from https://github.com/Daninet/hash-wasm/blob/bd3a205ca5603fc80adf71d0966fc72e8d4fa0ef/lib/mutex.ts
8
+
9
+ export class Mutex {
10
+ private mutex = Promise.resolve();
11
+
12
+ lock(): PromiseLike<() => void> {
13
+ let begin: (unlock: () => void) => void = () => {};
14
+
15
+ this.mutex = this.mutex.then(() => new Promise(begin));
16
+
17
+ return new Promise((res) => {
18
+ begin = res;
19
+ });
20
+ }
21
+
22
+ async dispatch<T>(fn: () => PromiseLike<T>): Promise<T> {
23
+ const unlock = await this.lock();
24
+ try {
25
+ return await Promise.resolve(fn());
26
+ } finally {
27
+ unlock();
28
+ }
29
+ }
30
+ }
@@ -0,0 +1,190 @@
1
+ /* ---------------------------------------------------------------------------------------------
2
+ * MIT License Copyright (c) 2020 Dani All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ * https://github.com/Daninet/hash-wasm
5
+ *--------------------------------------------------------------------------------------------*/
6
+
7
+ // copy and modified from https://github.com/Daninet/hash-wasm/blob/bd3a205ca5603fc80adf71d0966fc72e8d4fa0ef/lib/util.ts
8
+
9
+ function getGlobal() {
10
+ if (typeof globalThis !== 'undefined') {
11
+ return globalThis;
12
+ }
13
+ // eslint-disable-next-line no-restricted-globals
14
+ if (typeof self !== 'undefined') {
15
+ return self;
16
+ }
17
+ if (typeof window !== 'undefined') {
18
+ return window;
19
+ }
20
+ return global;
21
+ }
22
+
23
+ const globalObject = getGlobal();
24
+ // @ts-ignore
25
+ const nodeBuffer = globalObject.Buffer ?? null;
26
+ // @ts-ignore
27
+ const textEncoder = globalObject.TextEncoder ? new globalObject.TextEncoder() : null;
28
+
29
+ export type ITypedArray = Uint8Array | Uint16Array | Uint32Array;
30
+ export type IDataType = string | Buffer | ITypedArray;
31
+
32
+ export function intArrayToString(arr: Uint8Array, len: number): string {
33
+ return String.fromCharCode(...arr.subarray(0, len));
34
+ }
35
+
36
+ function hexCharCodesToInt(a: number, b: number): number {
37
+ return (((a & 0xf) + ((a >> 6) | ((a >> 3) & 0x8))) << 4) | ((b & 0xf) + ((b >> 6) | ((b >> 3) & 0x8)));
38
+ }
39
+
40
+ export function writeHexToUInt8(buf: Uint8Array, str: string) {
41
+ const size = str.length >> 1;
42
+ for (let i = 0; i < size; i++) {
43
+ const index = i << 1;
44
+ buf[i] = hexCharCodesToInt(str.charCodeAt(index), str.charCodeAt(index + 1));
45
+ }
46
+ }
47
+
48
+ export function hexStringEqualsUInt8(str: string, buf: Uint8Array): boolean {
49
+ if (str.length !== buf.length * 2) {
50
+ return false;
51
+ }
52
+ for (let i = 0; i < buf.length; i++) {
53
+ const strIndex = i << 1;
54
+ if (buf[i] !== hexCharCodesToInt(str.charCodeAt(strIndex), str.charCodeAt(strIndex + 1))) {
55
+ return false;
56
+ }
57
+ }
58
+ return true;
59
+ }
60
+
61
+ const alpha = 'a'.charCodeAt(0) - 10;
62
+ const digit = '0'.charCodeAt(0);
63
+ export function getDigestHex(tmpBuffer: Uint8Array, input: Uint8Array, hashLength: number): string {
64
+ let p = 0;
65
+ /* eslint-disable no-plusplus */
66
+ for (let i = 0; i < hashLength; i++) {
67
+ let nibble = input[i] >>> 4;
68
+ tmpBuffer[p++] = nibble > 9 ? nibble + alpha : nibble + digit;
69
+ nibble = input[i] & 0xf;
70
+ tmpBuffer[p++] = nibble > 9 ? nibble + alpha : nibble + digit;
71
+ }
72
+ /* eslint-enable no-plusplus */
73
+
74
+ return String.fromCharCode.apply(null, tmpBuffer as unknown as number[]);
75
+ }
76
+
77
+ export const getUInt8Buffer =
78
+ nodeBuffer !== null
79
+ ? (data: IDataType): Uint8Array => {
80
+ if (typeof data === 'string') {
81
+ const buf = nodeBuffer.from(data, 'utf8');
82
+ return new Uint8Array(buf.buffer, buf.byteOffset, buf.length);
83
+ }
84
+
85
+ if (nodeBuffer.isBuffer(data)) {
86
+ return new Uint8Array(data.buffer, data.byteOffset, data.length);
87
+ }
88
+
89
+ if (ArrayBuffer.isView(data)) {
90
+ return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
91
+ }
92
+
93
+ throw new Error('Invalid data type!');
94
+ }
95
+ : (data: IDataType): Uint8Array => {
96
+ if (typeof data === 'string') {
97
+ return textEncoder.encode(data);
98
+ }
99
+
100
+ if (ArrayBuffer.isView(data)) {
101
+ return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
102
+ }
103
+
104
+ throw new Error('Invalid data type!');
105
+ };
106
+
107
+ const base64Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
108
+ const base64Lookup = new Uint8Array(256);
109
+ for (let i = 0; i < base64Chars.length; i++) {
110
+ base64Lookup[base64Chars.charCodeAt(i)] = i;
111
+ }
112
+
113
+ export function encodeBase64(data: Uint8Array, pad = true): string {
114
+ const len = data.length;
115
+ const extraBytes = len % 3;
116
+ const parts: string[] = [];
117
+
118
+ const len2 = len - extraBytes;
119
+ for (let i = 0; i < len2; i += 3) {
120
+ const tmp = ((data[i] << 16) & 0xff0000) + ((data[i + 1] << 8) & 0xff00) + (data[i + 2] & 0xff);
121
+
122
+ const triplet =
123
+ base64Chars.charAt((tmp >> 18) & 0x3f) +
124
+ base64Chars.charAt((tmp >> 12) & 0x3f) +
125
+ base64Chars.charAt((tmp >> 6) & 0x3f) +
126
+ base64Chars.charAt(tmp & 0x3f);
127
+
128
+ parts.push(triplet);
129
+ }
130
+
131
+ if (extraBytes === 1) {
132
+ const tmp = data[len - 1];
133
+ const a = base64Chars.charAt(tmp >> 2);
134
+ const b = base64Chars.charAt((tmp << 4) & 0x3f);
135
+
136
+ parts.push(`${a}${b}`);
137
+ if (pad) {
138
+ parts.push('==');
139
+ }
140
+ } else if (extraBytes === 2) {
141
+ const tmp = (data[len - 2] << 8) + data[len - 1];
142
+ const a = base64Chars.charAt(tmp >> 10);
143
+ const b = base64Chars.charAt((tmp >> 4) & 0x3f);
144
+ const c = base64Chars.charAt((tmp << 2) & 0x3f);
145
+ parts.push(`${a}${b}${c}`);
146
+ if (pad) {
147
+ parts.push('=');
148
+ }
149
+ }
150
+
151
+ return parts.join('');
152
+ }
153
+
154
+ export function getDecodeBase64Length(data: string): number {
155
+ let bufferLength = Math.floor(data.length * 0.75);
156
+ const len = data.length;
157
+
158
+ if (data[len - 1] === '=') {
159
+ bufferLength -= 1;
160
+ if (data[len - 2] === '=') {
161
+ bufferLength -= 1;
162
+ }
163
+ }
164
+
165
+ return bufferLength;
166
+ }
167
+
168
+ export function decodeBase64(data: string): Uint8Array {
169
+ const bufferLength = getDecodeBase64Length(data);
170
+ const len = data.length;
171
+
172
+ const bytes = new Uint8Array(bufferLength);
173
+
174
+ let p = 0;
175
+ for (let i = 0; i < len; i += 4) {
176
+ const encoded1 = base64Lookup[data.charCodeAt(i)];
177
+ const encoded2 = base64Lookup[data.charCodeAt(i + 1)];
178
+ const encoded3 = base64Lookup[data.charCodeAt(i + 2)];
179
+ const encoded4 = base64Lookup[data.charCodeAt(i + 3)];
180
+
181
+ bytes[p] = (encoded1 << 2) | (encoded2 >> 4);
182
+ p += 1;
183
+ bytes[p] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
184
+ p += 1;
185
+ bytes[p] = ((encoded3 & 3) << 6) | (encoded4 & 63);
186
+ p += 1;
187
+ }
188
+
189
+ return bytes;
190
+ }
@@ -0,0 +1,15 @@
1
+ export class IdGenerator {
2
+ private _prefix: string;
3
+ private _lastId: number;
4
+
5
+ constructor(prefix: string) {
6
+ this._prefix = prefix;
7
+ this._lastId = 0;
8
+ }
9
+
10
+ public nextId(): string {
11
+ return this._prefix + ++this._lastId;
12
+ }
13
+ }
14
+
15
+ export const defaultGenerator = new IdGenerator('id#');
package/src/index.ts ADDED
@@ -0,0 +1,39 @@
1
+ export * from './di-helper';
2
+ export * from './event-bus';
3
+ export * from './contribution-provider';
4
+ export * from './declare';
5
+ export * from './editor';
6
+ export * from './reference';
7
+ export * from './module';
8
+ export * from './command';
9
+ export * from './menu';
10
+ export * from './localize';
11
+ export * from './types';
12
+ export * from './application-props';
13
+ export * from './application-error';
14
+ export * from './preferences';
15
+ export * from './storage';
16
+ export * from './network';
17
+ export * from './log';
18
+ export * from './json-schema';
19
+ export * from './reporter';
20
+ export * from './connection';
21
+ export * from './comparers';
22
+ export * from './range';
23
+ export * from './problem-pattern';
24
+ export * from './problem-matcher';
25
+ export * from './task-definition';
26
+ export * from './node/port';
27
+ export * from './line-text';
28
+ export * from './keyboard';
29
+ export * from './theme';
30
+ export * from './env';
31
+ export * from './credential';
32
+ export * from './crypto';
33
+ export * from './markdown';
34
+ export * from './settings';
35
+ export * from './utils';
36
+ export * from './clipboard';
37
+ export * from './mime';
38
+ export * from './application.lifecycle';
39
+ export * from './extension.schema';