@opensumi/ide-utils 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 (114) hide show
  1. package/lib/arrays.d.ts +3 -3
  2. package/lib/arrays.d.ts.map +1 -1
  3. package/lib/arrays.js.map +1 -1
  4. package/lib/async.d.ts +3 -3
  5. package/lib/async.d.ts.map +1 -1
  6. package/lib/buffer.js +4 -4
  7. package/lib/buffer.js.map +1 -1
  8. package/lib/character-classifier.js +3 -3
  9. package/lib/character-classifier.js.map +1 -1
  10. package/lib/decorators.d.ts +1 -1
  11. package/lib/decorators.d.ts.map +1 -1
  12. package/lib/encoding.d.ts +7 -1
  13. package/lib/encoding.d.ts.map +1 -1
  14. package/lib/encoding.js +15 -2
  15. package/lib/encoding.js.map +1 -1
  16. package/lib/errors.d.ts +2 -2
  17. package/lib/errors.d.ts.map +1 -1
  18. package/lib/event.d.ts +2 -2
  19. package/lib/event.d.ts.map +1 -1
  20. package/lib/filters.d.ts +3 -3
  21. package/lib/filters.d.ts.map +1 -1
  22. package/lib/filters.js +25 -25
  23. package/lib/filters.js.map +1 -1
  24. package/lib/glob.d.ts +2 -2
  25. package/lib/glob.d.ts.map +1 -1
  26. package/lib/glob.js +1 -1
  27. package/lib/glob.js.map +1 -1
  28. package/lib/hash.js +10 -10
  29. package/lib/hash.js.map +1 -1
  30. package/lib/iterator.d.ts +1 -1
  31. package/lib/iterator.d.ts.map +1 -1
  32. package/lib/linked-text.d.ts +1 -1
  33. package/lib/linked-text.d.ts.map +1 -1
  34. package/lib/linked-text.js.map +1 -1
  35. package/lib/map.js +17 -17
  36. package/lib/map.js.map +1 -1
  37. package/lib/objects.d.ts +1 -0
  38. package/lib/objects.d.ts.map +1 -1
  39. package/lib/objects.js +38 -1
  40. package/lib/objects.js.map +1 -1
  41. package/lib/os.d.ts +1 -8
  42. package/lib/os.d.ts.map +1 -1
  43. package/lib/os.js +4 -8
  44. package/lib/os.js.map +1 -1
  45. package/lib/path.d.ts +1 -1
  46. package/lib/path.d.ts.map +1 -1
  47. package/lib/path.js +29 -29
  48. package/lib/path.js.map +1 -1
  49. package/lib/platform.js +8 -8
  50. package/lib/platform.js.map +1 -1
  51. package/lib/process.d.ts.map +1 -1
  52. package/lib/process.js +28 -13
  53. package/lib/process.js.map +1 -1
  54. package/lib/progress.js +3 -3
  55. package/lib/progress.js.map +1 -1
  56. package/lib/strings.js +9 -9
  57. package/lib/strings.js.map +1 -1
  58. package/lib/types.d.ts +5 -1
  59. package/lib/types.d.ts.map +1 -1
  60. package/lib/types.js +8 -1
  61. package/lib/types.js.map +1 -1
  62. package/lib/uint.js +4 -4
  63. package/lib/uint.js.map +1 -1
  64. package/lib/uri.js +8 -8
  65. package/lib/uri.js.map +1 -1
  66. package/lib/uuid.d.ts +1 -1
  67. package/lib/uuid.d.ts.map +1 -1
  68. package/lib/uuid.js +3 -2
  69. package/lib/uuid.js.map +1 -1
  70. package/package.json +8 -6
  71. package/src/ansi.ts +10 -0
  72. package/src/argv.ts +57 -0
  73. package/src/arrays.ts +328 -0
  74. package/src/async.ts +580 -0
  75. package/src/buffer.ts +290 -0
  76. package/src/cache.ts +37 -0
  77. package/src/cancellation.ts +136 -0
  78. package/src/charCode.ts +425 -0
  79. package/src/character-classifier.ts +82 -0
  80. package/src/const/encoding.ts +242 -0
  81. package/src/const/index.ts +1 -0
  82. package/src/date.ts +36 -0
  83. package/src/decorators.ts +166 -0
  84. package/src/disposable.ts +377 -0
  85. package/src/encoding.ts +278 -0
  86. package/src/errors.ts +192 -0
  87. package/src/event.ts +1024 -0
  88. package/src/file-uri.ts +41 -0
  89. package/src/filters.ts +887 -0
  90. package/src/functional.ts +43 -0
  91. package/src/glob.ts +752 -0
  92. package/src/hash.ts +336 -0
  93. package/src/iconLabels.ts +149 -0
  94. package/src/index.ts +40 -0
  95. package/src/iterator.ts +36 -0
  96. package/src/lifecycle.ts +48 -0
  97. package/src/linked-list.ts +144 -0
  98. package/src/linked-text.ts +55 -0
  99. package/src/lru-map.ts +133 -0
  100. package/src/map.ts +934 -0
  101. package/src/marshalling.ts +62 -0
  102. package/src/objects.ts +145 -0
  103. package/src/os.ts +76 -0
  104. package/src/path.ts +1885 -0
  105. package/src/platform.ts +194 -0
  106. package/src/process.ts +43 -0
  107. package/src/progress.ts +83 -0
  108. package/src/promises.ts +23 -0
  109. package/src/sequence.ts +28 -0
  110. package/src/strings.ts +1002 -0
  111. package/src/types.ts +214 -0
  112. package/src/uint.ts +59 -0
  113. package/src/uri.ts +298 -0
  114. package/src/uuid.ts +6 -0
@@ -0,0 +1,242 @@
1
+ export const SUPPORTED_ENCODINGS: {
2
+ [encoding: string]: { labelLong: string; labelShort: string; order: number; encodeOnly?: boolean; alias?: string };
3
+ } = {
4
+ utf8: {
5
+ labelLong: 'UTF-8',
6
+ labelShort: 'UTF-8',
7
+ order: 1,
8
+ alias: 'utf8bom',
9
+ },
10
+ utf8bom: {
11
+ labelLong: 'UTF-8 with BOM',
12
+ labelShort: 'UTF-8 with BOM',
13
+ encodeOnly: true,
14
+ order: 2,
15
+ alias: 'utf8',
16
+ },
17
+ utf16le: {
18
+ labelLong: 'UTF-16 LE',
19
+ labelShort: 'UTF-16 LE',
20
+ order: 3,
21
+ },
22
+ utf16be: {
23
+ labelLong: 'UTF-16 BE',
24
+ labelShort: 'UTF-16 BE',
25
+ order: 4,
26
+ },
27
+ windows1252: {
28
+ labelLong: 'Western (Windows 1252)',
29
+ labelShort: 'Windows 1252',
30
+ order: 5,
31
+ },
32
+ iso88591: {
33
+ labelLong: 'Western (ISO 8859-1)',
34
+ labelShort: 'ISO 8859-1',
35
+ order: 6,
36
+ },
37
+ iso88593: {
38
+ labelLong: 'Western (ISO 8859-3)',
39
+ labelShort: 'ISO 8859-3',
40
+ order: 7,
41
+ },
42
+ iso885915: {
43
+ labelLong: 'Western (ISO 8859-15)',
44
+ labelShort: 'ISO 8859-15',
45
+ order: 8,
46
+ },
47
+ macroman: {
48
+ labelLong: 'Western (Mac Roman)',
49
+ labelShort: 'Mac Roman',
50
+ order: 9,
51
+ },
52
+ cp437: {
53
+ labelLong: 'DOS (CP 437)',
54
+ labelShort: 'CP437',
55
+ order: 10,
56
+ },
57
+ windows1256: {
58
+ labelLong: 'Arabic (Windows 1256)',
59
+ labelShort: 'Windows 1256',
60
+ order: 11,
61
+ },
62
+ iso88596: {
63
+ labelLong: 'Arabic (ISO 8859-6)',
64
+ labelShort: 'ISO 8859-6',
65
+ order: 12,
66
+ },
67
+ windows1257: {
68
+ labelLong: 'Baltic (Windows 1257)',
69
+ labelShort: 'Windows 1257',
70
+ order: 13,
71
+ },
72
+ iso88594: {
73
+ labelLong: 'Baltic (ISO 8859-4)',
74
+ labelShort: 'ISO 8859-4',
75
+ order: 14,
76
+ },
77
+ iso885914: {
78
+ labelLong: 'Celtic (ISO 8859-14)',
79
+ labelShort: 'ISO 8859-14',
80
+ order: 15,
81
+ },
82
+ windows1250: {
83
+ labelLong: 'Central European (Windows 1250)',
84
+ labelShort: 'Windows 1250',
85
+ order: 16,
86
+ },
87
+ iso88592: {
88
+ labelLong: 'Central European (ISO 8859-2)',
89
+ labelShort: 'ISO 8859-2',
90
+ order: 17,
91
+ },
92
+ cp852: {
93
+ labelLong: 'Central European (CP 852)',
94
+ labelShort: 'CP 852',
95
+ order: 18,
96
+ },
97
+ windows1251: {
98
+ labelLong: 'Cyrillic (Windows 1251)',
99
+ labelShort: 'Windows 1251',
100
+ order: 19,
101
+ },
102
+ cp866: {
103
+ labelLong: 'Cyrillic (CP 866)',
104
+ labelShort: 'CP 866',
105
+ order: 20,
106
+ },
107
+ iso88595: {
108
+ labelLong: 'Cyrillic (ISO 8859-5)',
109
+ labelShort: 'ISO 8859-5',
110
+ order: 21,
111
+ },
112
+ koi8r: {
113
+ labelLong: 'Cyrillic (KOI8-R)',
114
+ labelShort: 'KOI8-R',
115
+ order: 22,
116
+ },
117
+ koi8u: {
118
+ labelLong: 'Cyrillic (KOI8-U)',
119
+ labelShort: 'KOI8-U',
120
+ order: 23,
121
+ },
122
+ iso885913: {
123
+ labelLong: 'Estonian (ISO 8859-13)',
124
+ labelShort: 'ISO 8859-13',
125
+ order: 24,
126
+ },
127
+ windows1253: {
128
+ labelLong: 'Greek (Windows 1253)',
129
+ labelShort: 'Windows 1253',
130
+ order: 25,
131
+ },
132
+ iso88597: {
133
+ labelLong: 'Greek (ISO 8859-7)',
134
+ labelShort: 'ISO 8859-7',
135
+ order: 26,
136
+ },
137
+ windows1255: {
138
+ labelLong: 'Hebrew (Windows 1255)',
139
+ labelShort: 'Windows 1255',
140
+ order: 27,
141
+ },
142
+ iso88598: {
143
+ labelLong: 'Hebrew (ISO 8859-8)',
144
+ labelShort: 'ISO 8859-8',
145
+ order: 28,
146
+ },
147
+ iso885910: {
148
+ labelLong: 'Nordic (ISO 8859-10)',
149
+ labelShort: 'ISO 8859-10',
150
+ order: 29,
151
+ },
152
+ iso885916: {
153
+ labelLong: 'Romanian (ISO 8859-16)',
154
+ labelShort: 'ISO 8859-16',
155
+ order: 30,
156
+ },
157
+ windows1254: {
158
+ labelLong: 'Turkish (Windows 1254)',
159
+ labelShort: 'Windows 1254',
160
+ order: 31,
161
+ },
162
+ iso88599: {
163
+ labelLong: 'Turkish (ISO 8859-9)',
164
+ labelShort: 'ISO 8859-9',
165
+ order: 32,
166
+ },
167
+ windows1258: {
168
+ labelLong: 'Vietnamese (Windows 1258)',
169
+ labelShort: 'Windows 1258',
170
+ order: 33,
171
+ },
172
+ gbk: {
173
+ labelLong: 'Simplified Chinese (GBK)',
174
+ labelShort: 'GBK',
175
+ order: 34,
176
+ },
177
+ gb18030: {
178
+ labelLong: 'Simplified Chinese (GB18030)',
179
+ labelShort: 'GB18030',
180
+ order: 35,
181
+ },
182
+ cp950: {
183
+ labelLong: 'Traditional Chinese (Big5)',
184
+ labelShort: 'Big5',
185
+ order: 36,
186
+ },
187
+ big5hkscs: {
188
+ labelLong: 'Traditional Chinese (Big5-HKSCS)',
189
+ labelShort: 'Big5-HKSCS',
190
+ order: 37,
191
+ },
192
+ shiftjis: {
193
+ labelLong: 'Japanese (Shift JIS)',
194
+ labelShort: 'Shift JIS',
195
+ order: 38,
196
+ },
197
+ eucjp: {
198
+ labelLong: 'Japanese (EUC-JP)',
199
+ labelShort: 'EUC-JP',
200
+ order: 39,
201
+ },
202
+ euckr: {
203
+ labelLong: 'Korean (EUC-KR)',
204
+ labelShort: 'EUC-KR',
205
+ order: 40,
206
+ },
207
+ windows874: {
208
+ labelLong: 'Thai (Windows 874)',
209
+ labelShort: 'Windows 874',
210
+ order: 41,
211
+ },
212
+ iso885911: {
213
+ labelLong: 'Latin/Thai (ISO 8859-11)',
214
+ labelShort: 'ISO 8859-11',
215
+ order: 42,
216
+ },
217
+ koi8ru: {
218
+ labelLong: 'Cyrillic (KOI8-RU)',
219
+ labelShort: 'KOI8-RU',
220
+ order: 43,
221
+ },
222
+ koi8t: {
223
+ labelLong: 'Tajik (KOI8-T)',
224
+ labelShort: 'KOI8-T',
225
+ order: 44,
226
+ },
227
+ gb2312: {
228
+ labelLong: 'Simplified Chinese (GB 2312)',
229
+ labelShort: 'GB 2312',
230
+ order: 45,
231
+ },
232
+ cp865: {
233
+ labelLong: 'Nordic DOS (CP 865)',
234
+ labelShort: 'CP 865',
235
+ order: 46,
236
+ },
237
+ cp850: {
238
+ labelLong: 'Western European DOS (CP 850)',
239
+ labelShort: 'CP 850',
240
+ order: 47,
241
+ },
242
+ };
@@ -0,0 +1 @@
1
+ export * from './encoding';
package/src/date.ts ADDED
@@ -0,0 +1,36 @@
1
+ import { pad } from './strings';
2
+
3
+ export function toLocalString(date: Date): string {
4
+ return (
5
+ date.getFullYear() +
6
+ '-' +
7
+ pad(date.getMonth() + 1, 2) +
8
+ '-' +
9
+ pad(date.getDate(), 2) +
10
+ ' ' +
11
+ pad(date.getHours(), 2) +
12
+ ':' +
13
+ pad(date.getMinutes(), 2) +
14
+ ':' +
15
+ pad(date.getSeconds(), 2)
16
+ );
17
+ }
18
+
19
+ export function toLocalISOString(date: Date): string {
20
+ return (
21
+ date.getFullYear() +
22
+ '-' +
23
+ pad(date.getMonth() + 1, 2) +
24
+ '-' +
25
+ pad(date.getDate(), 2) +
26
+ 'T' +
27
+ pad(date.getHours(), 2) +
28
+ ':' +
29
+ pad(date.getMinutes(), 2) +
30
+ ':' +
31
+ pad(date.getSeconds(), 2) +
32
+ '.' +
33
+ (date.getMilliseconds() / 1000).toFixed(3).slice(2, 5) +
34
+ 'Z'
35
+ );
36
+ }
@@ -0,0 +1,166 @@
1
+ /* ---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Microsoft Corporation. All rights reserved.
3
+ * Licensed under the MIT License. See License.txt in the project root for license information.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ // Some code copied and modified from https://github.com/microsoft/vscode/blob/1.44.0/src/vs/base/common/decorators.ts
6
+
7
+ export function createDecorator(mapFn: (fn: Function, key: string) => Function): Function {
8
+ return (target: any, key: string, descriptor: any) => {
9
+ let fnKey: string | null = null;
10
+ let fn: Function | null = null;
11
+
12
+ if (typeof descriptor.value === 'function') {
13
+ fnKey = 'value';
14
+ fn = descriptor.value;
15
+ } else if (typeof descriptor.get === 'function') {
16
+ fnKey = 'get';
17
+ fn = descriptor.get;
18
+ }
19
+
20
+ if (!fn) {
21
+ throw new Error('not supported');
22
+ }
23
+
24
+ descriptor[fnKey!] = mapFn(fn, key);
25
+ };
26
+ }
27
+
28
+ let memoizeId = 0;
29
+ export function createMemoizer() {
30
+ const memoizeKeyPrefix = `$memoize${memoizeId++}`;
31
+ let self: any;
32
+
33
+ const result = function memoize(target: any, key: string, descriptor: any) {
34
+ let fnKey: string | null = null;
35
+ let fn: Function | null = null;
36
+
37
+ if (typeof descriptor.value === 'function') {
38
+ fnKey = 'value';
39
+ fn = descriptor.value;
40
+
41
+ if (fn!.length !== 0) {
42
+ // eslint-disable-next-line no-console
43
+ console.warn('Memoize should only be used in functions with zero parameters');
44
+ }
45
+ } else if (typeof descriptor.get === 'function') {
46
+ fnKey = 'get';
47
+ fn = descriptor.get;
48
+ }
49
+
50
+ if (!fn) {
51
+ throw new Error('not supported');
52
+ }
53
+
54
+ const memoizeKey = `${memoizeKeyPrefix}:${key}`;
55
+ descriptor[fnKey!] = function (...args: any[]) {
56
+ self = this;
57
+
58
+ if (!this.hasOwnProperty(memoizeKey)) {
59
+ Object.defineProperty(this, memoizeKey, {
60
+ configurable: true,
61
+ enumerable: false,
62
+ writable: true,
63
+ value: fn!.apply(this, args),
64
+ });
65
+ }
66
+
67
+ return this[memoizeKey];
68
+ };
69
+ };
70
+
71
+ result.clear = () => {
72
+ if (typeof self === 'undefined') {
73
+ return;
74
+ }
75
+ Object.getOwnPropertyNames(self).forEach((property) => {
76
+ if (property.indexOf(memoizeKeyPrefix) === 0) {
77
+ delete self[property];
78
+ }
79
+ });
80
+ };
81
+
82
+ return result;
83
+ }
84
+
85
+ export function memoize(target: any, key: string, descriptor: any) {
86
+ return createMemoizer()(target, key, descriptor);
87
+ }
88
+
89
+ export type IDebounceReducer<T> = (previousValue: T, ...args: any[]) => T;
90
+
91
+ export function debounce<T>(delay: number, reducer?: IDebounceReducer<T>, initialValueProvider?: () => T): Function {
92
+ return createDecorator((fn, key) => {
93
+ const timerKey = `$debounce$${key}`;
94
+ const resultKey = `$debounce$result$${key}`;
95
+
96
+ return function (this: any, ...args: any[]) {
97
+ if (!this[resultKey]) {
98
+ this[resultKey] = initialValueProvider ? initialValueProvider() : undefined;
99
+ }
100
+
101
+ clearTimeout(this[timerKey]);
102
+
103
+ if (reducer) {
104
+ this[resultKey] = reducer(this[resultKey], ...args);
105
+ args = [this[resultKey]];
106
+ }
107
+
108
+ this[timerKey] = setTimeout(() => {
109
+ fn.apply(this, args);
110
+ this[resultKey] = initialValueProvider ? initialValueProvider() : undefined;
111
+ }, delay);
112
+ };
113
+ });
114
+ }
115
+
116
+ export function throttle<T>(delay: number, reducer?: IDebounceReducer<T>, initialValueProvider?: () => T): Function {
117
+ return createDecorator((fn, key) => {
118
+ const timerKey = `$throttle$timer$${key}`;
119
+ const resultKey = `$throttle$result$${key}`;
120
+ const lastRunKey = `$throttle$lastRun$${key}`;
121
+ const pendingKey = `$throttle$pending$${key}`;
122
+
123
+ return function (this: any, ...args: any[]) {
124
+ if (!this[resultKey]) {
125
+ this[resultKey] = initialValueProvider ? initialValueProvider() : undefined;
126
+ }
127
+ if (this[lastRunKey] === null || this[lastRunKey] === undefined) {
128
+ this[lastRunKey] = -Number.MAX_VALUE;
129
+ }
130
+
131
+ if (reducer) {
132
+ this[resultKey] = reducer(this[resultKey], ...args);
133
+ }
134
+
135
+ if (this[pendingKey]) {
136
+ return;
137
+ }
138
+
139
+ const nextTime = this[lastRunKey] + delay;
140
+ if (nextTime <= Date.now()) {
141
+ this[lastRunKey] = Date.now();
142
+ fn.apply(this, [this[resultKey]]);
143
+ this[resultKey] = initialValueProvider ? initialValueProvider() : undefined;
144
+ } else {
145
+ this[pendingKey] = true;
146
+ this[timerKey] = setTimeout(() => {
147
+ this[pendingKey] = false;
148
+ this[lastRunKey] = Date.now();
149
+ fn.apply(this, [this[resultKey]]);
150
+ this[resultKey] = initialValueProvider ? initialValueProvider() : undefined;
151
+ }, nextTime - Date.now());
152
+ }
153
+ };
154
+ });
155
+ }
156
+
157
+ export function es5ClassCompat(target: any): any {
158
+ function _() {
159
+ // @ts-ignore
160
+ return Reflect.construct(target, arguments, this.constructor);
161
+ }
162
+ Object.defineProperty(_, 'name', Object.getOwnPropertyDescriptor(target, 'name')!);
163
+ Object.setPrototypeOf(_, target);
164
+ Object.setPrototypeOf(_.prototype, target.prototype);
165
+ return _;
166
+ }