custom-electron-titlebar 3.2.6 → 3.2.10

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 (239) hide show
  1. package/.github/FUNDING.yml +1 -0
  2. package/README.md +15 -24
  3. package/_config.yml +1 -0
  4. package/{lib → build}/browser/browser.d.ts +0 -0
  5. package/{lib → build}/browser/browser.js +0 -0
  6. package/{lib → build}/browser/browser.js.map +0 -0
  7. package/{lib → build}/browser/event.d.ts +0 -0
  8. package/{lib → build}/browser/event.js +2 -1
  9. package/{lib → build}/browser/event.js.map +1 -1
  10. package/{lib → build}/browser/iframe.d.ts +0 -0
  11. package/{lib → build}/browser/iframe.js +0 -0
  12. package/{lib → build}/browser/iframe.js.map +0 -0
  13. package/{lib → build}/browser/keyboardEvent.d.ts +0 -0
  14. package/{lib → build}/browser/keyboardEvent.js +0 -0
  15. package/{lib → build}/browser/keyboardEvent.js.map +0 -0
  16. package/{lib → build}/browser/mouseEvent.d.ts +0 -0
  17. package/{lib → build}/browser/mouseEvent.js +0 -0
  18. package/{lib → build}/browser/mouseEvent.js.map +0 -0
  19. package/{lib → build}/common/arrays.d.ts +0 -0
  20. package/{lib → build}/common/arrays.js +0 -0
  21. package/{lib → build}/common/arrays.js.map +0 -0
  22. package/{lib → build}/common/async.d.ts +0 -0
  23. package/{lib → build}/common/async.js +0 -0
  24. package/{lib → build}/common/async.js.map +0 -0
  25. package/{lib → build}/common/charCode.d.ts +0 -0
  26. package/{lib → build}/common/charCode.js +0 -0
  27. package/{lib → build}/common/charCode.js.map +0 -0
  28. package/{lib → build}/common/color.d.ts +0 -0
  29. package/{lib → build}/common/color.js +0 -0
  30. package/{lib → build}/common/color.js.map +0 -0
  31. package/{lib → build}/common/dom.d.ts +0 -0
  32. package/{lib → build}/common/dom.js +16 -14
  33. package/build/common/dom.js.map +1 -0
  34. package/{lib → build}/common/event.d.ts +0 -0
  35. package/{lib → build}/common/event.js +1 -1
  36. package/build/common/event.js.map +1 -0
  37. package/{lib → build}/common/iterator.d.ts +0 -0
  38. package/{lib → build}/common/iterator.js +0 -0
  39. package/{lib → build}/common/iterator.js.map +0 -0
  40. package/{lib → build}/common/keyCodes.d.ts +0 -0
  41. package/{lib → build}/common/keyCodes.js +0 -0
  42. package/{lib → build}/common/keyCodes.js.map +0 -0
  43. package/{lib → build}/common/lifecycle.d.ts +0 -0
  44. package/{lib → build}/common/lifecycle.js +0 -0
  45. package/{lib → build}/common/lifecycle.js.map +0 -0
  46. package/{lib → build}/common/linkedList.d.ts +0 -0
  47. package/{lib → build}/common/linkedList.js +0 -0
  48. package/{lib → build}/common/linkedList.js.map +0 -0
  49. package/{lib → build}/common/platform.d.ts +0 -0
  50. package/{lib → build}/common/platform.js +0 -0
  51. package/{lib → build}/common/platform.js.map +0 -0
  52. package/{lib → build}/index.d.ts +0 -0
  53. package/{lib → build}/index.js +0 -0
  54. package/{lib → build}/index.js.map +0 -0
  55. package/{lib → build}/menu/menu.d.ts +0 -0
  56. package/{lib → build}/menu/menu.js +38 -38
  57. package/build/menu/menu.js.map +1 -0
  58. package/{lib → build}/menu/menuitem.d.ts +10 -2
  59. package/{lib → build}/menu/menuitem.js +70 -34
  60. package/build/menu/menuitem.js.map +1 -0
  61. package/{lib → build}/menubar.d.ts +0 -0
  62. package/{lib → build}/menubar.js +29 -30
  63. package/build/menubar.js.map +1 -0
  64. package/{lib → build}/themebar.d.ts +0 -0
  65. package/{lib → build}/themebar.js +2 -2
  66. package/build/themebar.js.map +1 -0
  67. package/{lib → build}/titlebar.d.ts +0 -0
  68. package/{lib → build}/titlebar.js +61 -58
  69. package/build/titlebar.js.map +1 -0
  70. package/package.json +13 -7
  71. package/lib/common/dom.js.map +0 -1
  72. package/lib/common/enableNativeMenuCommands.d.ts +0 -1
  73. package/lib/common/enableNativeMenuCommands.js +0 -32
  74. package/lib/common/enableNativeMenuCommands.js.map +0 -1
  75. package/lib/common/event.js.map +0 -1
  76. package/lib/main.d.ts +0 -1
  77. package/lib/main.js +0 -14
  78. package/lib/main.js.map +0 -1
  79. package/lib/menu/menu.js.map +0 -1
  80. package/lib/menu/menuitem.js.map +0 -1
  81. package/lib/menubar.js.map +0 -1
  82. package/lib/themebar.js.map +0 -1
  83. package/lib/titlebar.js.map +0 -1
  84. package/lib/vs/base/browser/browser.js +0 -150
  85. package/lib/vs/base/browser/canIUse.js +0 -58
  86. package/lib/vs/base/browser/codicons.js +0 -37
  87. package/lib/vs/base/browser/contextmenu.js +0 -9
  88. package/lib/vs/base/browser/dnd.js +0 -113
  89. package/lib/vs/base/browser/dom.js +0 -1417
  90. package/lib/vs/base/browser/event.js +0 -36
  91. package/lib/vs/base/browser/fastDomNode.js +0 -265
  92. package/lib/vs/base/browser/formattedTextRenderer.js +0 -248
  93. package/lib/vs/base/browser/globalMouseMoveMonitor.js +0 -137
  94. package/lib/vs/base/browser/history.js +0 -9
  95. package/lib/vs/base/browser/iframe.js +0 -126
  96. package/lib/vs/base/browser/keyboardEvent.js +0 -599
  97. package/lib/vs/base/browser/mouseEvent.js +0 -155
  98. package/lib/vs/base/browser/touch.js +0 -315
  99. package/lib/vs/base/browser/ui/actionbar/actionViewItems.js +0 -397
  100. package/lib/vs/base/browser/ui/actionbar/actionbar.js +0 -583
  101. package/lib/vs/base/browser/ui/checkbox/checkbox.js +0 -251
  102. package/lib/vs/base/browser/ui/codicons/codiconLabel.js +0 -31
  103. package/lib/vs/base/browser/ui/codicons/codiconStyles.js +0 -47
  104. package/lib/vs/base/browser/ui/contextview/contextview.js +0 -367
  105. package/lib/vs/base/browser/ui/dropdown/dropdown.js +0 -256
  106. package/lib/vs/base/browser/ui/dropdown/dropdownActionViewItem.js +0 -120
  107. package/lib/vs/base/browser/ui/keybindingLabel/keybindingLabel.js +0 -118
  108. package/lib/vs/base/browser/ui/list/list.js +0 -54
  109. package/lib/vs/base/browser/ui/list/listPaging.js +0 -322
  110. package/lib/vs/base/browser/ui/list/listView.js +0 -1388
  111. package/lib/vs/base/browser/ui/list/listWidget.js +0 -1709
  112. package/lib/vs/base/browser/ui/list/rangeMap.js +0 -223
  113. package/lib/vs/base/browser/ui/list/rowCache.js +0 -113
  114. package/lib/vs/base/browser/ui/list/splice.js +0 -23
  115. package/lib/vs/base/browser/ui/menu/menu.js +0 -1371
  116. package/lib/vs/base/browser/ui/menu/menubar.js +0 -1139
  117. package/lib/vs/base/browser/ui/scrollbar/abstractScrollbar.js +0 -278
  118. package/lib/vs/base/browser/ui/scrollbar/horizontalScrollbar.js +0 -115
  119. package/lib/vs/base/browser/ui/scrollbar/scrollableElement.js +0 -646
  120. package/lib/vs/base/browser/ui/scrollbar/scrollableElementOptions.js +0 -9
  121. package/lib/vs/base/browser/ui/scrollbar/scrollbarArrow.js +0 -106
  122. package/lib/vs/base/browser/ui/scrollbar/scrollbarState.js +0 -184
  123. package/lib/vs/base/browser/ui/scrollbar/scrollbarVisibilityController.js +0 -116
  124. package/lib/vs/base/browser/ui/scrollbar/verticalScrollbar.js +0 -114
  125. package/lib/vs/base/browser/ui/selectBox/selectBox.js +0 -85
  126. package/lib/vs/base/browser/ui/selectBox/selectBoxCustom.js +0 -985
  127. package/lib/vs/base/browser/ui/selectBox/selectBoxNative.js +0 -188
  128. package/lib/vs/base/browser/ui/toolbar/toolbar.js +0 -206
  129. package/lib/vs/base/browser/ui/widget.js +0 -69
  130. package/lib/vs/base/common/actions.js +0 -224
  131. package/lib/vs/base/common/amd.js +0 -31
  132. package/lib/vs/base/common/arrays.js +0 -641
  133. package/lib/vs/base/common/assert.js +0 -21
  134. package/lib/vs/base/common/async.js +0 -966
  135. package/lib/vs/base/common/buffer.js +0 -250
  136. package/lib/vs/base/common/cache.js +0 -40
  137. package/lib/vs/base/common/cancellation.js +0 -146
  138. package/lib/vs/base/common/charCode.js +0 -9
  139. package/lib/vs/base/common/codicon.js +0 -136
  140. package/lib/vs/base/common/codicons.js +0 -1378
  141. package/lib/vs/base/common/collections.js +0 -133
  142. package/lib/vs/base/common/color.js +0 -716
  143. package/lib/vs/base/common/comparers.js +0 -280
  144. package/lib/vs/base/common/console.js +0 -142
  145. package/lib/vs/base/common/date.js +0 -113
  146. package/lib/vs/base/common/decorators.js +0 -169
  147. package/lib/vs/base/common/errorMessage.js +0 -93
  148. package/lib/vs/base/common/errors.js +0 -213
  149. package/lib/vs/base/common/errorsWithActions.js +0 -28
  150. package/lib/vs/base/common/event.js +0 -873
  151. package/lib/vs/base/common/extpath.js +0 -401
  152. package/lib/vs/base/common/filters.js +0 -948
  153. package/lib/vs/base/common/functional.js +0 -28
  154. package/lib/vs/base/common/fuzzyScorer.js +0 -811
  155. package/lib/vs/base/common/glob.js +0 -696
  156. package/lib/vs/base/common/hash.js +0 -359
  157. package/lib/vs/base/common/history.js +0 -116
  158. package/lib/vs/base/common/htmlContent.js +0 -162
  159. package/lib/vs/base/common/idGenerator.js +0 -25
  160. package/lib/vs/base/common/iterator.js +0 -118
  161. package/lib/vs/base/common/json.js +0 -1624
  162. package/lib/vs/base/common/jsonEdit.js +0 -272
  163. package/lib/vs/base/common/jsonErrorMessages.js +0 -69
  164. package/lib/vs/base/common/jsonFormatter.js +0 -316
  165. package/lib/vs/base/common/jsonSchema.js +0 -9
  166. package/lib/vs/base/common/keyCodes.js +0 -591
  167. package/lib/vs/base/common/keybindingLabels.js +0 -231
  168. package/lib/vs/base/common/keybindingParser.js +0 -142
  169. package/lib/vs/base/common/labels.js +0 -430
  170. package/lib/vs/base/common/lazy.js +0 -71
  171. package/lib/vs/base/common/lifecycle.js +0 -308
  172. package/lib/vs/base/common/linkedList.js +0 -152
  173. package/lib/vs/base/common/linkedText.js +0 -73
  174. package/lib/vs/base/common/map.js +0 -1108
  175. package/lib/vs/base/common/marshalling.js +0 -80
  176. package/lib/vs/base/common/mime.js +0 -321
  177. package/lib/vs/base/common/navigator.js +0 -50
  178. package/lib/vs/base/common/network.js +0 -160
  179. package/lib/vs/base/common/normalization.js +0 -78
  180. package/lib/vs/base/common/numbers.js +0 -55
  181. package/lib/vs/base/common/objects.js +0 -268
  182. package/lib/vs/base/common/paging.js +0 -190
  183. package/lib/vs/base/common/parsers.js +0 -78
  184. package/lib/vs/base/common/path.js +0 -1550
  185. package/lib/vs/base/common/platform.js +0 -245
  186. package/lib/vs/base/common/process.js +0 -52
  187. package/lib/vs/base/common/processes.js +0 -32
  188. package/lib/vs/base/common/range.js +0 -79
  189. package/lib/vs/base/common/resourceTree.js +0 -185
  190. package/lib/vs/base/common/resources.js +0 -421
  191. package/lib/vs/base/common/scanCode.js +0 -1472
  192. package/lib/vs/base/common/scrollable.js +0 -397
  193. package/lib/vs/base/common/search.js +0 -55
  194. package/lib/vs/base/common/sequence.js +0 -64
  195. package/lib/vs/base/common/severity.js +0 -55
  196. package/lib/vs/base/common/skipList.js +0 -234
  197. package/lib/vs/base/common/stopwatch.js +0 -45
  198. package/lib/vs/base/common/stream.js +0 -418
  199. package/lib/vs/base/common/strings.js +0 -1283
  200. package/lib/vs/base/common/styler.js +0 -9
  201. package/lib/vs/base/common/types.js +0 -296
  202. package/lib/vs/base/common/uint.js +0 -46
  203. package/lib/vs/base/common/uri.js +0 -756
  204. package/lib/vs/base/common/uriIpc.js +0 -154
  205. package/lib/vs/base/common/uuid.js +0 -70
  206. package/lib/vs/nls.mock.js +0 -31
  207. package/lib/vs/platform/actions/browser/menuEntryActionViewItem.js +0 -342
  208. package/lib/vs/platform/actions/common/actions.js +0 -456
  209. package/lib/vs/platform/actions/common/menuService.js +0 -194
  210. package/lib/vs/platform/clipboard/browser/clipboardService.js +0 -99
  211. package/lib/vs/platform/clipboard/common/clipboardService.js +0 -14
  212. package/lib/vs/platform/contextkey/common/contextkey.js +0 -1210
  213. package/lib/vs/platform/contextkey/common/contextkeys.js +0 -23
  214. package/lib/vs/platform/contextview/browser/contextView.js +0 -15
  215. package/lib/vs/platform/contextview/browser/contextViewService.js +0 -96
  216. package/lib/vs/platform/environment/common/argv.js +0 -9
  217. package/lib/vs/platform/environment/common/environment.js +0 -15
  218. package/lib/vs/platform/instantiation/common/descriptors.js +0 -25
  219. package/lib/vs/platform/instantiation/common/extensions.js +0 -26
  220. package/lib/vs/platform/instantiation/common/graph.js +0 -93
  221. package/lib/vs/platform/instantiation/common/instantiation.js +0 -84
  222. package/lib/vs/platform/instantiation/common/instantiationService.js +0 -361
  223. package/lib/vs/platform/instantiation/common/serviceCollection.js +0 -39
  224. package/lib/vs/platform/keybinding/common/baseResolvedKeybinding.js +0 -73
  225. package/lib/vs/platform/keybinding/common/keybinding.js +0 -14
  226. package/lib/vs/platform/keybinding/common/keybindingResolver.js +0 -391
  227. package/lib/vs/platform/keybinding/common/keybindingsRegistry.js +0 -229
  228. package/lib/vs/platform/keybinding/common/resolvedKeybindingItem.js +0 -47
  229. package/lib/vs/platform/keybinding/common/usLayoutResolvedKeybinding.js +0 -160
  230. package/lib/vs/platform/layout/browser/layoutService.js +0 -14
  231. package/lib/vs/platform/menubar/common/menubar.js +0 -34
  232. package/lib/vs/platform/registry/common/platform.js +0 -38
  233. package/lib/vs/platform/theme/browser/checkbox.js +0 -32
  234. package/lib/vs/platform/theme/common/colorRegistry.js +0 -1154
  235. package/lib/vs/platform/theme/common/styler.js +0 -290
  236. package/lib/vs/platform/theme/common/theme.js +0 -21
  237. package/lib/vs/platform/theme/common/themeService.js +0 -176
  238. package/lib/vs/platform/theme/common/tokenClassificationRegistry.js +0 -540
  239. package/lib/vs/platform/theme/test/common/testThemeService.js +0 -98
@@ -1,948 +0,0 @@
1
- "use strict";
2
- /*---------------------------------------------------------------------------------------------
3
- * Copyright (c) Microsoft Corporation. All rights reserved.
4
- * Licensed under the MIT License. See License.txt in the project root for license information.
5
- *--------------------------------------------------------------------------------------------*/
6
-
7
- Object.defineProperty(exports, "__esModule", {
8
- value: true
9
- });
10
- exports.fuzzyScoreGraceful = exports.fuzzyScoreGracefulAggressive = exports.fuzzyScore = exports.FuzzyScore = exports.isPatternInWord = exports.createMatches = exports.anyScore = exports.matchesFuzzy2 = exports.matchesFuzzy = exports.matchesWords = exports.matchesCamelCase = exports.isUpper = exports.matchesSubString = exports.matchesContiguousSubString = exports.matchesPrefix = exports.matchesStrictPrefix = exports.or = void 0;
11
-
12
- const map_1 = require("./map");
13
-
14
- const strings = require("./strings"); // Combined filters
15
-
16
- /**
17
- * @returns A filter which combines the provided set
18
- * of filters with an or. The *first* filters that
19
- * matches defined the return value of the returned
20
- * filter.
21
- */
22
-
23
-
24
- function or(...filter) {
25
- return function (word, wordToMatchAgainst) {
26
- for (let i = 0, len = filter.length; i < len; i++) {
27
- const match = filter[i](word, wordToMatchAgainst);
28
-
29
- if (match) {
30
- return match;
31
- }
32
- }
33
-
34
- return null;
35
- };
36
- }
37
-
38
- exports.or = or; // Prefix
39
-
40
- exports.matchesStrictPrefix = _matchesPrefix.bind(undefined, false);
41
- exports.matchesPrefix = _matchesPrefix.bind(undefined, true);
42
-
43
- function _matchesPrefix(ignoreCase, word, wordToMatchAgainst) {
44
- if (!wordToMatchAgainst || wordToMatchAgainst.length < word.length) {
45
- return null;
46
- }
47
-
48
- let matches;
49
-
50
- if (ignoreCase) {
51
- matches = strings.startsWithIgnoreCase(wordToMatchAgainst, word);
52
- } else {
53
- matches = wordToMatchAgainst.indexOf(word) === 0;
54
- }
55
-
56
- if (!matches) {
57
- return null;
58
- }
59
-
60
- return word.length > 0 ? [{
61
- start: 0,
62
- end: word.length
63
- }] : [];
64
- } // Contiguous Substring
65
-
66
-
67
- function matchesContiguousSubString(word, wordToMatchAgainst) {
68
- const index = wordToMatchAgainst.toLowerCase().indexOf(word.toLowerCase());
69
-
70
- if (index === -1) {
71
- return null;
72
- }
73
-
74
- return [{
75
- start: index,
76
- end: index + word.length
77
- }];
78
- }
79
-
80
- exports.matchesContiguousSubString = matchesContiguousSubString; // Substring
81
-
82
- function matchesSubString(word, wordToMatchAgainst) {
83
- return _matchesSubString(word.toLowerCase(), wordToMatchAgainst.toLowerCase(), 0, 0);
84
- }
85
-
86
- exports.matchesSubString = matchesSubString;
87
-
88
- function _matchesSubString(word, wordToMatchAgainst, i, j) {
89
- if (i === word.length) {
90
- return [];
91
- } else if (j === wordToMatchAgainst.length) {
92
- return null;
93
- } else {
94
- if (word[i] === wordToMatchAgainst[j]) {
95
- let result = null;
96
-
97
- if (result = _matchesSubString(word, wordToMatchAgainst, i + 1, j + 1)) {
98
- return join({
99
- start: j,
100
- end: j + 1
101
- }, result);
102
- }
103
-
104
- return null;
105
- }
106
-
107
- return _matchesSubString(word, wordToMatchAgainst, i, j + 1);
108
- }
109
- } // CamelCase
110
-
111
-
112
- function isLower(code) {
113
- return 97
114
- /* a */
115
- <= code && code <= 122
116
- /* z */
117
- ;
118
- }
119
-
120
- function isUpper(code) {
121
- return 65
122
- /* A */
123
- <= code && code <= 90
124
- /* Z */
125
- ;
126
- }
127
-
128
- exports.isUpper = isUpper;
129
-
130
- function isNumber(code) {
131
- return 48
132
- /* Digit0 */
133
- <= code && code <= 57
134
- /* Digit9 */
135
- ;
136
- }
137
-
138
- function isWhitespace(code) {
139
- return code === 32
140
- /* Space */
141
- || code === 9
142
- /* Tab */
143
- || code === 10
144
- /* LineFeed */
145
- || code === 13
146
- /* CarriageReturn */
147
- ;
148
- }
149
-
150
- const wordSeparators = new Set();
151
- '`~!@#$%^&*()-=+[{]}\\|;:\'",.<>/?'.split('').forEach(s => wordSeparators.add(s.charCodeAt(0)));
152
-
153
- function isWordSeparator(code) {
154
- return isWhitespace(code) || wordSeparators.has(code);
155
- }
156
-
157
- function charactersMatch(codeA, codeB) {
158
- return codeA === codeB || isWordSeparator(codeA) && isWordSeparator(codeB);
159
- }
160
-
161
- function isAlphanumeric(code) {
162
- return isLower(code) || isUpper(code) || isNumber(code);
163
- }
164
-
165
- function join(head, tail) {
166
- if (tail.length === 0) {
167
- tail = [head];
168
- } else if (head.end === tail[0].start) {
169
- tail[0].start = head.start;
170
- } else {
171
- tail.unshift(head);
172
- }
173
-
174
- return tail;
175
- }
176
-
177
- function nextAnchor(camelCaseWord, start) {
178
- for (let i = start; i < camelCaseWord.length; i++) {
179
- const c = camelCaseWord.charCodeAt(i);
180
-
181
- if (isUpper(c) || isNumber(c) || i > 0 && !isAlphanumeric(camelCaseWord.charCodeAt(i - 1))) {
182
- return i;
183
- }
184
- }
185
-
186
- return camelCaseWord.length;
187
- }
188
-
189
- function _matchesCamelCase(word, camelCaseWord, i, j) {
190
- if (i === word.length) {
191
- return [];
192
- } else if (j === camelCaseWord.length) {
193
- return null;
194
- } else if (word[i] !== camelCaseWord[j].toLowerCase()) {
195
- return null;
196
- } else {
197
- let result = null;
198
- let nextUpperIndex = j + 1;
199
- result = _matchesCamelCase(word, camelCaseWord, i + 1, j + 1);
200
-
201
- while (!result && (nextUpperIndex = nextAnchor(camelCaseWord, nextUpperIndex)) < camelCaseWord.length) {
202
- result = _matchesCamelCase(word, camelCaseWord, i + 1, nextUpperIndex);
203
- nextUpperIndex++;
204
- }
205
-
206
- return result === null ? null : join({
207
- start: j,
208
- end: j + 1
209
- }, result);
210
- }
211
- } // Heuristic to avoid computing camel case matcher for words that don't
212
- // look like camelCaseWords.
213
-
214
-
215
- function analyzeCamelCaseWord(word) {
216
- let upper = 0,
217
- lower = 0,
218
- alpha = 0,
219
- numeric = 0,
220
- code = 0;
221
-
222
- for (let i = 0; i < word.length; i++) {
223
- code = word.charCodeAt(i);
224
-
225
- if (isUpper(code)) {
226
- upper++;
227
- }
228
-
229
- if (isLower(code)) {
230
- lower++;
231
- }
232
-
233
- if (isAlphanumeric(code)) {
234
- alpha++;
235
- }
236
-
237
- if (isNumber(code)) {
238
- numeric++;
239
- }
240
- }
241
-
242
- const upperPercent = upper / word.length;
243
- const lowerPercent = lower / word.length;
244
- const alphaPercent = alpha / word.length;
245
- const numericPercent = numeric / word.length;
246
- return {
247
- upperPercent,
248
- lowerPercent,
249
- alphaPercent,
250
- numericPercent
251
- };
252
- }
253
-
254
- function isUpperCaseWord(analysis) {
255
- const {
256
- upperPercent,
257
- lowerPercent
258
- } = analysis;
259
- return lowerPercent === 0 && upperPercent > 0.6;
260
- }
261
-
262
- function isCamelCaseWord(analysis) {
263
- const {
264
- upperPercent,
265
- lowerPercent,
266
- alphaPercent,
267
- numericPercent
268
- } = analysis;
269
- return lowerPercent > 0.2 && upperPercent < 0.8 && alphaPercent > 0.6 && numericPercent < 0.2;
270
- } // Heuristic to avoid computing camel case matcher for words that don't
271
- // look like camel case patterns.
272
-
273
-
274
- function isCamelCasePattern(word) {
275
- let upper = 0,
276
- lower = 0,
277
- code = 0,
278
- whitespace = 0;
279
-
280
- for (let i = 0; i < word.length; i++) {
281
- code = word.charCodeAt(i);
282
-
283
- if (isUpper(code)) {
284
- upper++;
285
- }
286
-
287
- if (isLower(code)) {
288
- lower++;
289
- }
290
-
291
- if (isWhitespace(code)) {
292
- whitespace++;
293
- }
294
- }
295
-
296
- if ((upper === 0 || lower === 0) && whitespace === 0) {
297
- return word.length <= 30;
298
- } else {
299
- return upper <= 5;
300
- }
301
- }
302
-
303
- function matchesCamelCase(word, camelCaseWord) {
304
- if (!camelCaseWord) {
305
- return null;
306
- }
307
-
308
- camelCaseWord = camelCaseWord.trim();
309
-
310
- if (camelCaseWord.length === 0) {
311
- return null;
312
- }
313
-
314
- if (!isCamelCasePattern(word)) {
315
- return null;
316
- }
317
-
318
- if (camelCaseWord.length > 60) {
319
- return null;
320
- }
321
-
322
- const analysis = analyzeCamelCaseWord(camelCaseWord);
323
-
324
- if (!isCamelCaseWord(analysis)) {
325
- if (!isUpperCaseWord(analysis)) {
326
- return null;
327
- }
328
-
329
- camelCaseWord = camelCaseWord.toLowerCase();
330
- }
331
-
332
- let result = null;
333
- let i = 0;
334
- word = word.toLowerCase();
335
-
336
- while (i < camelCaseWord.length && (result = _matchesCamelCase(word, camelCaseWord, 0, i)) === null) {
337
- i = nextAnchor(camelCaseWord, i + 1);
338
- }
339
-
340
- return result;
341
- }
342
-
343
- exports.matchesCamelCase = matchesCamelCase; // Matches beginning of words supporting non-ASCII languages
344
- // If `contiguous` is true then matches word with beginnings of the words in the target. E.g. "pul" will match "Git: Pull"
345
- // Otherwise also matches sub string of the word with beginnings of the words in the target. E.g. "gp" or "g p" will match "Git: Pull"
346
- // Useful in cases where the target is words (e.g. command labels)
347
-
348
- function matchesWords(word, target, contiguous = false) {
349
- if (!target || target.length === 0) {
350
- return null;
351
- }
352
-
353
- let result = null;
354
- let i = 0;
355
- word = word.toLowerCase();
356
- target = target.toLowerCase();
357
-
358
- while (i < target.length && (result = _matchesWords(word, target, 0, i, contiguous)) === null) {
359
- i = nextWord(target, i + 1);
360
- }
361
-
362
- return result;
363
- }
364
-
365
- exports.matchesWords = matchesWords;
366
-
367
- function _matchesWords(word, target, i, j, contiguous) {
368
- if (i === word.length) {
369
- return [];
370
- } else if (j === target.length) {
371
- return null;
372
- } else if (!charactersMatch(word.charCodeAt(i), target.charCodeAt(j))) {
373
- return null;
374
- } else {
375
- let result = null;
376
- let nextWordIndex = j + 1;
377
- result = _matchesWords(word, target, i + 1, j + 1, contiguous);
378
-
379
- if (!contiguous) {
380
- while (!result && (nextWordIndex = nextWord(target, nextWordIndex)) < target.length) {
381
- result = _matchesWords(word, target, i + 1, nextWordIndex, contiguous);
382
- nextWordIndex++;
383
- }
384
- }
385
-
386
- return result === null ? null : join({
387
- start: j,
388
- end: j + 1
389
- }, result);
390
- }
391
- }
392
-
393
- function nextWord(word, start) {
394
- for (let i = start; i < word.length; i++) {
395
- if (isWordSeparator(word.charCodeAt(i)) || i > 0 && isWordSeparator(word.charCodeAt(i - 1))) {
396
- return i;
397
- }
398
- }
399
-
400
- return word.length;
401
- } // Fuzzy
402
-
403
-
404
- const fuzzyContiguousFilter = or(exports.matchesPrefix, matchesCamelCase, matchesContiguousSubString);
405
- const fuzzySeparateFilter = or(exports.matchesPrefix, matchesCamelCase, matchesSubString);
406
- const fuzzyRegExpCache = new map_1.LRUCache(10000); // bounded to 10000 elements
407
-
408
- function matchesFuzzy(word, wordToMatchAgainst, enableSeparateSubstringMatching = false) {
409
- if (typeof word !== 'string' || typeof wordToMatchAgainst !== 'string') {
410
- return null; // return early for invalid input
411
- } // Form RegExp for wildcard matches
412
-
413
-
414
- let regexp = fuzzyRegExpCache.get(word);
415
-
416
- if (!regexp) {
417
- regexp = new RegExp(strings.convertSimple2RegExpPattern(word), 'i');
418
- fuzzyRegExpCache.set(word, regexp);
419
- } // RegExp Filter
420
-
421
-
422
- const match = regexp.exec(wordToMatchAgainst);
423
-
424
- if (match) {
425
- return [{
426
- start: match.index,
427
- end: match.index + match[0].length
428
- }];
429
- } // Default Filter
430
-
431
-
432
- return enableSeparateSubstringMatching ? fuzzySeparateFilter(word, wordToMatchAgainst) : fuzzyContiguousFilter(word, wordToMatchAgainst);
433
- }
434
-
435
- exports.matchesFuzzy = matchesFuzzy;
436
- /**
437
- * Match pattern againt word in a fuzzy way. As in IntelliSense and faster and more
438
- * powerfull than `matchesFuzzy`
439
- */
440
-
441
- function matchesFuzzy2(pattern, word) {
442
- const score = fuzzyScore(pattern, pattern.toLowerCase(), 0, word, word.toLowerCase(), 0, true);
443
- return score ? createMatches(score) : null;
444
- }
445
-
446
- exports.matchesFuzzy2 = matchesFuzzy2;
447
-
448
- function anyScore(pattern, lowPattern, _patternPos, word, lowWord, _wordPos) {
449
- const result = fuzzyScore(pattern, lowPattern, 0, word, lowWord, 0, true);
450
-
451
- if (result) {
452
- return result;
453
- }
454
-
455
- let matches = 0;
456
- let score = 0;
457
- let idx = _wordPos;
458
-
459
- for (let patternPos = 0; patternPos < lowPattern.length && patternPos < _maxLen; ++patternPos) {
460
- const wordPos = lowWord.indexOf(lowPattern.charAt(patternPos), idx);
461
-
462
- if (wordPos >= 0) {
463
- score += 1;
464
- matches += 2 ** wordPos;
465
- idx = wordPos + 1;
466
- } else if (matches !== 0) {
467
- // once we have started matching things
468
- // we need to match the remaining pattern
469
- // characters
470
- break;
471
- }
472
- }
473
-
474
- return [score, matches, _wordPos];
475
- }
476
-
477
- exports.anyScore = anyScore; //#region --- fuzzyScore ---
478
-
479
- function createMatches(score) {
480
- if (typeof score === 'undefined') {
481
- return [];
482
- }
483
-
484
- const matches = score[1].toString(2);
485
- const wordStart = score[2];
486
- const res = [];
487
-
488
- for (let pos = wordStart; pos < _maxLen; pos++) {
489
- if (matches[matches.length - (pos + 1)] === '1') {
490
- const last = res[res.length - 1];
491
-
492
- if (last && last.end === pos) {
493
- last.end = pos + 1;
494
- } else {
495
- res.push({
496
- start: pos,
497
- end: pos + 1
498
- });
499
- }
500
- }
501
- }
502
-
503
- return res;
504
- }
505
-
506
- exports.createMatches = createMatches;
507
- const _maxLen = 128;
508
-
509
- function initTable() {
510
- const table = [];
511
- const row = [0];
512
-
513
- for (let i = 1; i <= _maxLen; i++) {
514
- row.push(-i);
515
- }
516
-
517
- for (let i = 0; i <= _maxLen; i++) {
518
- const thisRow = row.slice(0);
519
- thisRow[0] = -i;
520
- table.push(thisRow);
521
- }
522
-
523
- return table;
524
- }
525
-
526
- const _table = initTable();
527
-
528
- const _scores = initTable();
529
-
530
- const _arrows = initTable();
531
-
532
- const _debug = false;
533
-
534
- function printTable(table, pattern, patternLen, word, wordLen) {
535
- function pad(s, n, pad = ' ') {
536
- while (s.length < n) {
537
- s = pad + s;
538
- }
539
-
540
- return s;
541
- }
542
-
543
- let ret = ` | |${word.split('').map(c => pad(c, 3)).join('|')}\n`;
544
-
545
- for (let i = 0; i <= patternLen; i++) {
546
- if (i === 0) {
547
- ret += ' |';
548
- } else {
549
- ret += `${pattern[i - 1]}|`;
550
- }
551
-
552
- ret += table[i].slice(0, wordLen + 1).map(n => pad(n.toString(), 3)).join('|') + '\n';
553
- }
554
-
555
- return ret;
556
- }
557
-
558
- function printTables(pattern, patternStart, word, wordStart) {
559
- pattern = pattern.substr(patternStart);
560
- word = word.substr(wordStart);
561
- console.log(printTable(_table, pattern, pattern.length, word, word.length));
562
- console.log(printTable(_arrows, pattern, pattern.length, word, word.length));
563
- console.log(printTable(_scores, pattern, pattern.length, word, word.length));
564
- }
565
-
566
- function isSeparatorAtPos(value, index) {
567
- if (index < 0 || index >= value.length) {
568
- return false;
569
- }
570
-
571
- const code = value.charCodeAt(index);
572
-
573
- switch (code) {
574
- case 95
575
- /* Underline */
576
- :
577
- case 45
578
- /* Dash */
579
- :
580
- case 46
581
- /* Period */
582
- :
583
- case 32
584
- /* Space */
585
- :
586
- case 47
587
- /* Slash */
588
- :
589
- case 92
590
- /* Backslash */
591
- :
592
- case 39
593
- /* SingleQuote */
594
- :
595
- case 34
596
- /* DoubleQuote */
597
- :
598
- case 58
599
- /* Colon */
600
- :
601
- case 36
602
- /* DollarSign */
603
- :
604
- return true;
605
-
606
- default:
607
- return false;
608
- }
609
- }
610
-
611
- function isWhitespaceAtPos(value, index) {
612
- if (index < 0 || index >= value.length) {
613
- return false;
614
- }
615
-
616
- const code = value.charCodeAt(index);
617
-
618
- switch (code) {
619
- case 32
620
- /* Space */
621
- :
622
- case 9
623
- /* Tab */
624
- :
625
- return true;
626
-
627
- default:
628
- return false;
629
- }
630
- }
631
-
632
- function isUpperCaseAtPos(pos, word, wordLow) {
633
- return word[pos] !== wordLow[pos];
634
- }
635
-
636
- function isPatternInWord(patternLow, patternPos, patternLen, wordLow, wordPos, wordLen) {
637
- while (patternPos < patternLen && wordPos < wordLen) {
638
- if (patternLow[patternPos] === wordLow[wordPos]) {
639
- patternPos += 1;
640
- }
641
-
642
- wordPos += 1;
643
- }
644
-
645
- return patternPos === patternLen; // pattern must be exhausted
646
- }
647
-
648
- exports.isPatternInWord = isPatternInWord;
649
- var FuzzyScore;
650
-
651
- (function (FuzzyScore) {
652
- /**
653
- * No matches and value `-100`
654
- */
655
- FuzzyScore.Default = Object.freeze([-100, 0, 0]);
656
-
657
- function isDefault(score) {
658
- return !score || score[0] === -100 && score[1] === 0 && score[2] === 0;
659
- }
660
-
661
- FuzzyScore.isDefault = isDefault;
662
- })(FuzzyScore = exports.FuzzyScore || (exports.FuzzyScore = {}));
663
-
664
- function fuzzyScore(pattern, patternLow, patternStart, word, wordLow, wordStart, firstMatchCanBeWeak) {
665
- const patternLen = pattern.length > _maxLen ? _maxLen : pattern.length;
666
- const wordLen = word.length > _maxLen ? _maxLen : word.length;
667
-
668
- if (patternStart >= patternLen || wordStart >= wordLen || patternLen - patternStart > wordLen - wordStart) {
669
- return undefined;
670
- } // Run a simple check if the characters of pattern occur
671
- // (in order) at all in word. If that isn't the case we
672
- // stop because no match will be possible
673
-
674
-
675
- if (!isPatternInWord(patternLow, patternStart, patternLen, wordLow, wordStart, wordLen)) {
676
- return undefined;
677
- }
678
-
679
- let row = 1;
680
- let column = 1;
681
- let patternPos = patternStart;
682
- let wordPos = wordStart;
683
- let hasStrongFirstMatch = false; // There will be a match, fill in tables
684
-
685
- for (row = 1, patternPos = patternStart; patternPos < patternLen; row++, patternPos++) {
686
- for (column = 1, wordPos = wordStart; wordPos < wordLen; column++, wordPos++) {
687
- const score = _doScore(pattern, patternLow, patternPos, patternStart, word, wordLow, wordPos);
688
-
689
- if (patternPos === patternStart && score > 1) {
690
- hasStrongFirstMatch = true;
691
- }
692
-
693
- _scores[row][column] = score;
694
- const diag = _table[row - 1][column - 1] + (score > 1 ? 1 : score);
695
- const top = _table[row - 1][column] + -1;
696
- const left = _table[row][column - 1] + -1;
697
-
698
- if (left >= top) {
699
- // left or diag
700
- if (left > diag) {
701
- _table[row][column] = left;
702
- _arrows[row][column] = 4
703
- /* Left */
704
- ;
705
- } else if (left === diag) {
706
- _table[row][column] = left;
707
- _arrows[row][column] = 4
708
- /* Left */
709
- | 2
710
- /* Diag */
711
- ;
712
- } else {
713
- _table[row][column] = diag;
714
- _arrows[row][column] = 2
715
- /* Diag */
716
- ;
717
- }
718
- } else {
719
- // top or diag
720
- if (top > diag) {
721
- _table[row][column] = top;
722
- _arrows[row][column] = 1
723
- /* Top */
724
- ;
725
- } else if (top === diag) {
726
- _table[row][column] = top;
727
- _arrows[row][column] = 1
728
- /* Top */
729
- | 2
730
- /* Diag */
731
- ;
732
- } else {
733
- _table[row][column] = diag;
734
- _arrows[row][column] = 2
735
- /* Diag */
736
- ;
737
- }
738
- }
739
- }
740
- }
741
-
742
- if (_debug) {
743
- printTables(pattern, patternStart, word, wordStart);
744
- }
745
-
746
- if (!hasStrongFirstMatch && !firstMatchCanBeWeak) {
747
- return undefined;
748
- }
749
-
750
- _matchesCount = 0;
751
- _topScore = -100;
752
- _wordStart = wordStart;
753
- _firstMatchCanBeWeak = firstMatchCanBeWeak;
754
-
755
- _findAllMatches2(row - 1, column - 1, patternLen === wordLen ? 1 : 0, 0, false);
756
-
757
- if (_matchesCount === 0) {
758
- return undefined;
759
- }
760
-
761
- return [_topScore, _topMatch2, wordStart];
762
- }
763
-
764
- exports.fuzzyScore = fuzzyScore;
765
-
766
- function _doScore(pattern, patternLow, patternPos, patternStart, word, wordLow, wordPos) {
767
- if (patternLow[patternPos] !== wordLow[wordPos]) {
768
- return -1;
769
- }
770
-
771
- if (wordPos === patternPos - patternStart) {
772
- // common prefix: `foobar <-> foobaz`
773
- // ^^^^^
774
- if (pattern[patternPos] === word[wordPos]) {
775
- return 7;
776
- } else {
777
- return 5;
778
- }
779
- } else if (isUpperCaseAtPos(wordPos, word, wordLow) && (wordPos === 0 || !isUpperCaseAtPos(wordPos - 1, word, wordLow))) {
780
- // hitting upper-case: `foo <-> forOthers`
781
- // ^^ ^
782
- if (pattern[patternPos] === word[wordPos]) {
783
- return 7;
784
- } else {
785
- return 5;
786
- }
787
- } else if (isSeparatorAtPos(wordLow, wordPos) && (wordPos === 0 || !isSeparatorAtPos(wordLow, wordPos - 1))) {
788
- // hitting a separator: `. <-> foo.bar`
789
- // ^
790
- return 5;
791
- } else if (isSeparatorAtPos(wordLow, wordPos - 1) || isWhitespaceAtPos(wordLow, wordPos - 1)) {
792
- // post separator: `foo <-> bar_foo`
793
- // ^^^
794
- return 5;
795
- } else {
796
- return 1;
797
- }
798
- }
799
-
800
- let _matchesCount = 0;
801
- let _topMatch2 = 0;
802
- let _topScore = 0;
803
- let _wordStart = 0;
804
- let _firstMatchCanBeWeak = false;
805
-
806
- function _findAllMatches2(row, column, total, matches, lastMatched) {
807
- if (_matchesCount >= 10 || total < -25) {
808
- // stop when having already 10 results, or
809
- // when a potential alignment as already 5 gaps
810
- return;
811
- }
812
-
813
- let simpleMatchCount = 0;
814
-
815
- while (row > 0 && column > 0) {
816
- const score = _scores[row][column];
817
- const arrow = _arrows[row][column];
818
-
819
- if (arrow === 4
820
- /* Left */
821
- ) {
822
- // left -> no match, skip a word character
823
- column -= 1;
824
-
825
- if (lastMatched) {
826
- total -= 5; // new gap penalty
827
- } else if (matches !== 0) {
828
- total -= 1; // gap penalty after first match
829
- }
830
-
831
- lastMatched = false;
832
- simpleMatchCount = 0;
833
- } else if (arrow & 2
834
- /* Diag */
835
- ) {
836
- if (arrow & 4
837
- /* Left */
838
- ) {
839
- // left
840
- _findAllMatches2(row, column - 1, matches !== 0 ? total - 1 : total, // gap penalty after first match
841
- matches, lastMatched);
842
- } // diag
843
-
844
-
845
- total += score;
846
- row -= 1;
847
- column -= 1;
848
- lastMatched = true; // match -> set a 1 at the word pos
849
-
850
- matches += 2 ** (column + _wordStart); // count simple matches and boost a row of
851
- // simple matches when they yield in a
852
- // strong match.
853
-
854
- if (score === 1) {
855
- simpleMatchCount += 1;
856
-
857
- if (row === 0 && !_firstMatchCanBeWeak) {
858
- // when the first match is a weak
859
- // match we discard it
860
- return undefined;
861
- }
862
- } else {
863
- // boost
864
- total += 1 + simpleMatchCount * (score - 1);
865
- simpleMatchCount = 0;
866
- }
867
- } else {
868
- return undefined;
869
- }
870
- }
871
-
872
- total -= column >= 3 ? 9 : column * 3; // late start penalty
873
- // dynamically keep track of the current top score
874
- // and insert the current best score at head, the rest at tail
875
-
876
- _matchesCount += 1;
877
-
878
- if (total > _topScore) {
879
- _topScore = total;
880
- _topMatch2 = matches;
881
- }
882
- } //#endregion
883
- //#region --- graceful ---
884
-
885
-
886
- function fuzzyScoreGracefulAggressive(pattern, lowPattern, patternPos, word, lowWord, wordPos, firstMatchCanBeWeak) {
887
- return fuzzyScoreWithPermutations(pattern, lowPattern, patternPos, word, lowWord, wordPos, true, firstMatchCanBeWeak);
888
- }
889
-
890
- exports.fuzzyScoreGracefulAggressive = fuzzyScoreGracefulAggressive;
891
-
892
- function fuzzyScoreGraceful(pattern, lowPattern, patternPos, word, lowWord, wordPos, firstMatchCanBeWeak) {
893
- return fuzzyScoreWithPermutations(pattern, lowPattern, patternPos, word, lowWord, wordPos, false, firstMatchCanBeWeak);
894
- }
895
-
896
- exports.fuzzyScoreGraceful = fuzzyScoreGraceful;
897
-
898
- function fuzzyScoreWithPermutations(pattern, lowPattern, patternPos, word, lowWord, wordPos, aggressive, firstMatchCanBeWeak) {
899
- let top = fuzzyScore(pattern, lowPattern, patternPos, word, lowWord, wordPos, firstMatchCanBeWeak);
900
-
901
- if (top && !aggressive) {
902
- // when using the original pattern yield a result we`
903
- // return it unless we are aggressive and try to find
904
- // a better alignment, e.g. `cno` -> `^co^ns^ole` or `^c^o^nsole`.
905
- return top;
906
- }
907
-
908
- if (pattern.length >= 3) {
909
- // When the pattern is long enough then try a few (max 7)
910
- // permutations of the pattern to find a better match. The
911
- // permutations only swap neighbouring characters, e.g
912
- // `cnoso` becomes `conso`, `cnsoo`, `cnoos`.
913
- const tries = Math.min(7, pattern.length - 1);
914
-
915
- for (let movingPatternPos = patternPos + 1; movingPatternPos < tries; movingPatternPos++) {
916
- const newPattern = nextTypoPermutation(pattern, movingPatternPos);
917
-
918
- if (newPattern) {
919
- const candidate = fuzzyScore(newPattern, newPattern.toLowerCase(), patternPos, word, lowWord, wordPos, firstMatchCanBeWeak);
920
-
921
- if (candidate) {
922
- candidate[0] -= 3; // permutation penalty
923
-
924
- if (!top || candidate[0] > top[0]) {
925
- top = candidate;
926
- }
927
- }
928
- }
929
- }
930
- }
931
-
932
- return top;
933
- }
934
-
935
- function nextTypoPermutation(pattern, patternPos) {
936
- if (patternPos + 1 >= pattern.length) {
937
- return undefined;
938
- }
939
-
940
- const swap1 = pattern[patternPos];
941
- const swap2 = pattern[patternPos + 1];
942
-
943
- if (swap1 === swap2) {
944
- return undefined;
945
- }
946
-
947
- return pattern.slice(0, patternPos) + swap2 + swap1 + pattern.slice(patternPos + 2);
948
- } //#endregion