@itwin/appui-abstract 4.0.0-dev.52 → 4.0.0-dev.54

Sign up to get free protection for your applications and to get access to all the features.
Files changed (327) hide show
  1. package/lib/cjs/appui-abstract/BaseUiItemsProvider.d.ts +30 -30
  2. package/lib/cjs/appui-abstract/BaseUiItemsProvider.d.ts.map +1 -1
  3. package/lib/cjs/appui-abstract/BaseUiItemsProvider.js +79 -79
  4. package/lib/cjs/appui-abstract/BaseUiItemsProvider.js.map +1 -1
  5. package/lib/cjs/appui-abstract/UiAdmin.d.ts +221 -221
  6. package/lib/cjs/appui-abstract/UiAdmin.js +224 -224
  7. package/lib/cjs/appui-abstract/UiAdmin.js.map +1 -1
  8. package/lib/cjs/appui-abstract/UiItemsManager.d.ts +113 -113
  9. package/lib/cjs/appui-abstract/UiItemsManager.d.ts.map +1 -1
  10. package/lib/cjs/appui-abstract/UiItemsManager.js +193 -193
  11. package/lib/cjs/appui-abstract/UiItemsManager.js.map +1 -1
  12. package/lib/cjs/appui-abstract/UiItemsProvider.d.ts +29 -29
  13. package/lib/cjs/appui-abstract/UiItemsProvider.js +9 -9
  14. package/lib/cjs/appui-abstract/UiItemsProvider.js.map +1 -1
  15. package/lib/cjs/appui-abstract/backstage/BackstageItem.d.ts +91 -91
  16. package/lib/cjs/appui-abstract/backstage/BackstageItem.d.ts.map +1 -1
  17. package/lib/cjs/appui-abstract/backstage/BackstageItem.js +70 -70
  18. package/lib/cjs/appui-abstract/backstage/BackstageItem.js.map +1 -1
  19. package/lib/cjs/appui-abstract/backstage/BackstageItemsManager.d.ts +38 -38
  20. package/lib/cjs/appui-abstract/backstage/BackstageItemsManager.js +133 -133
  21. package/lib/cjs/appui-abstract/backstage/BackstageItemsManager.js.map +1 -1
  22. package/lib/cjs/appui-abstract/common/KeyboardKey.d.ts +51 -51
  23. package/lib/cjs/appui-abstract/common/KeyboardKey.js +63 -63
  24. package/lib/cjs/appui-abstract/common/KeyboardKey.js.map +1 -1
  25. package/lib/cjs/appui-abstract/content/ContentLayoutProps.d.ts +62 -62
  26. package/lib/cjs/appui-abstract/content/ContentLayoutProps.js +9 -9
  27. package/lib/cjs/appui-abstract/content/ContentLayoutProps.js.map +1 -1
  28. package/lib/cjs/appui-abstract/content/StandardContentLayouts.d.ts +19 -19
  29. package/lib/cjs/appui-abstract/content/StandardContentLayouts.js +108 -108
  30. package/lib/cjs/appui-abstract/content/StandardContentLayouts.js.map +1 -1
  31. package/lib/cjs/appui-abstract/dialogs/DialogItem.d.ts +76 -76
  32. package/lib/cjs/appui-abstract/dialogs/DialogItem.js +67 -67
  33. package/lib/cjs/appui-abstract/dialogs/DialogItem.js.map +1 -1
  34. package/lib/cjs/appui-abstract/dialogs/UiDataProvider.d.ts +55 -55
  35. package/lib/cjs/appui-abstract/dialogs/UiDataProvider.js +66 -66
  36. package/lib/cjs/appui-abstract/dialogs/UiDataProvider.js.map +1 -1
  37. package/lib/cjs/appui-abstract/dialogs/UiLayoutDataProvider.d.ts +97 -97
  38. package/lib/cjs/appui-abstract/dialogs/UiLayoutDataProvider.js +175 -175
  39. package/lib/cjs/appui-abstract/dialogs/UiLayoutDataProvider.js.map +1 -1
  40. package/lib/cjs/appui-abstract/items/AbstractItemProps.d.ts +53 -53
  41. package/lib/cjs/appui-abstract/items/AbstractItemProps.d.ts.map +1 -1
  42. package/lib/cjs/appui-abstract/items/AbstractItemProps.js +9 -9
  43. package/lib/cjs/appui-abstract/items/AbstractItemProps.js.map +1 -1
  44. package/lib/cjs/appui-abstract/items/AbstractMenuItemProps.d.ts +20 -20
  45. package/lib/cjs/appui-abstract/items/AbstractMenuItemProps.js +9 -9
  46. package/lib/cjs/appui-abstract/items/AbstractMenuItemProps.js.map +1 -1
  47. package/lib/cjs/appui-abstract/items/AbstractToolbarProps.d.ts +13 -13
  48. package/lib/cjs/appui-abstract/items/AbstractToolbarProps.js +9 -9
  49. package/lib/cjs/appui-abstract/items/AbstractToolbarProps.js.map +1 -1
  50. package/lib/cjs/appui-abstract/items/BadgeType.d.ts +14 -14
  51. package/lib/cjs/appui-abstract/items/BadgeType.js +22 -22
  52. package/lib/cjs/appui-abstract/items/BadgeType.js.map +1 -1
  53. package/lib/cjs/appui-abstract/items/ConditionalBooleanValue.d.ts +27 -27
  54. package/lib/cjs/appui-abstract/items/ConditionalBooleanValue.js +60 -60
  55. package/lib/cjs/appui-abstract/items/ConditionalBooleanValue.js.map +1 -1
  56. package/lib/cjs/appui-abstract/items/ConditionalStringValue.d.ts +29 -29
  57. package/lib/cjs/appui-abstract/items/ConditionalStringValue.js +62 -62
  58. package/lib/cjs/appui-abstract/items/ConditionalStringValue.js.map +1 -1
  59. package/lib/cjs/appui-abstract/items/ProvidedItem.d.ts +11 -11
  60. package/lib/cjs/appui-abstract/items/ProvidedItem.js +9 -9
  61. package/lib/cjs/appui-abstract/items/ProvidedItem.js.map +1 -1
  62. package/lib/cjs/appui-abstract/items/RelativePosition.d.ts +18 -18
  63. package/lib/cjs/appui-abstract/items/RelativePosition.js +26 -26
  64. package/lib/cjs/appui-abstract/items/RelativePosition.js.map +1 -1
  65. package/lib/cjs/appui-abstract/items/StageUsage.d.ts +16 -16
  66. package/lib/cjs/appui-abstract/items/StageUsage.js +24 -24
  67. package/lib/cjs/appui-abstract/items/StageUsage.js.map +1 -1
  68. package/lib/cjs/appui-abstract/notification/MessagePresenter.d.ts +42 -42
  69. package/lib/cjs/appui-abstract/notification/MessagePresenter.js +24 -24
  70. package/lib/cjs/appui-abstract/notification/MessagePresenter.js.map +1 -1
  71. package/lib/cjs/appui-abstract/notification/MessageSeverity.d.ts +15 -15
  72. package/lib/cjs/appui-abstract/notification/MessageSeverity.js +23 -23
  73. package/lib/cjs/appui-abstract/notification/MessageSeverity.js.map +1 -1
  74. package/lib/cjs/appui-abstract/properties/Description.d.ts +127 -127
  75. package/lib/cjs/appui-abstract/properties/Description.js +196 -196
  76. package/lib/cjs/appui-abstract/properties/Description.js.map +1 -1
  77. package/lib/cjs/appui-abstract/properties/EditorParams.d.ts +260 -260
  78. package/lib/cjs/appui-abstract/properties/EditorParams.d.ts.map +1 -1
  79. package/lib/cjs/appui-abstract/properties/EditorParams.js +106 -106
  80. package/lib/cjs/appui-abstract/properties/EditorParams.js.map +1 -1
  81. package/lib/cjs/appui-abstract/properties/PrimitiveTypes.d.ts +60 -60
  82. package/lib/cjs/appui-abstract/properties/PrimitiveTypes.js +9 -9
  83. package/lib/cjs/appui-abstract/properties/PrimitiveTypes.js.map +1 -1
  84. package/lib/cjs/appui-abstract/properties/Record.d.ts +57 -57
  85. package/lib/cjs/appui-abstract/properties/Record.js +78 -78
  86. package/lib/cjs/appui-abstract/properties/Record.js.map +1 -1
  87. package/lib/cjs/appui-abstract/properties/StandardEditorNames.d.ts +22 -22
  88. package/lib/cjs/appui-abstract/properties/StandardEditorNames.js +30 -30
  89. package/lib/cjs/appui-abstract/properties/StandardEditorNames.js.map +1 -1
  90. package/lib/cjs/appui-abstract/properties/StandardTypeNames.d.ts +30 -30
  91. package/lib/cjs/appui-abstract/properties/StandardTypeNames.js +39 -39
  92. package/lib/cjs/appui-abstract/properties/StandardTypeNames.js.map +1 -1
  93. package/lib/cjs/appui-abstract/properties/Value.d.ts +49 -49
  94. package/lib/cjs/appui-abstract/properties/Value.d.ts.map +1 -1
  95. package/lib/cjs/appui-abstract/properties/Value.js +20 -20
  96. package/lib/cjs/appui-abstract/properties/Value.js.map +1 -1
  97. package/lib/cjs/appui-abstract/quantity/BaseQuantityDescription.d.ts +22 -22
  98. package/lib/cjs/appui-abstract/quantity/BaseQuantityDescription.js +48 -48
  99. package/lib/cjs/appui-abstract/quantity/BaseQuantityDescription.js.map +1 -1
  100. package/lib/cjs/appui-abstract/statusbar/StatusBarItem.d.ts +128 -128
  101. package/lib/cjs/appui-abstract/statusbar/StatusBarItem.d.ts.map +1 -1
  102. package/lib/cjs/appui-abstract/statusbar/StatusBarItem.js +87 -87
  103. package/lib/cjs/appui-abstract/statusbar/StatusBarItem.js.map +1 -1
  104. package/lib/cjs/appui-abstract/statusbar/StatusBarItemsManager.d.ts +39 -39
  105. package/lib/cjs/appui-abstract/statusbar/StatusBarItemsManager.js +135 -135
  106. package/lib/cjs/appui-abstract/statusbar/StatusBarItemsManager.js.map +1 -1
  107. package/lib/cjs/appui-abstract/toolbars/ToolbarItem.d.ts +121 -121
  108. package/lib/cjs/appui-abstract/toolbars/ToolbarItem.d.ts.map +1 -1
  109. package/lib/cjs/appui-abstract/toolbars/ToolbarItem.js +64 -64
  110. package/lib/cjs/appui-abstract/toolbars/ToolbarItem.js.map +1 -1
  111. package/lib/cjs/appui-abstract/toolbars/ToolbarItemsManager.d.ts +45 -45
  112. package/lib/cjs/appui-abstract/toolbars/ToolbarItemsManager.js +235 -235
  113. package/lib/cjs/appui-abstract/toolbars/ToolbarItemsManager.js.map +1 -1
  114. package/lib/cjs/appui-abstract/utils/IconSpecUtilities.d.ts +29 -29
  115. package/lib/cjs/appui-abstract/utils/IconSpecUtilities.js +51 -51
  116. package/lib/cjs/appui-abstract/utils/IconSpecUtilities.js.map +1 -1
  117. package/lib/cjs/appui-abstract/utils/PointProps.d.ts +10 -10
  118. package/lib/cjs/appui-abstract/utils/PointProps.js +9 -9
  119. package/lib/cjs/appui-abstract/utils/PointProps.js.map +1 -1
  120. package/lib/cjs/appui-abstract/utils/UiError.d.ts +12 -12
  121. package/lib/cjs/appui-abstract/utils/UiError.js +22 -22
  122. package/lib/cjs/appui-abstract/utils/UiError.js.map +1 -1
  123. package/lib/cjs/appui-abstract/utils/UiEvent.d.ts +9 -9
  124. package/lib/cjs/appui-abstract/utils/UiEvent.js +17 -17
  125. package/lib/cjs/appui-abstract/utils/UiEvent.js.map +1 -1
  126. package/lib/cjs/appui-abstract/utils/UiEventDispatcher.d.ts +46 -46
  127. package/lib/cjs/appui-abstract/utils/UiEventDispatcher.js +131 -131
  128. package/lib/cjs/appui-abstract/utils/UiEventDispatcher.js.map +1 -1
  129. package/lib/cjs/appui-abstract/utils/callbacks.d.ts +20 -20
  130. package/lib/cjs/appui-abstract/utils/callbacks.d.ts.map +1 -1
  131. package/lib/cjs/appui-abstract/utils/callbacks.js +9 -9
  132. package/lib/cjs/appui-abstract/utils/callbacks.js.map +1 -1
  133. package/lib/cjs/appui-abstract/utils/filter/charCode.d.ts +416 -416
  134. package/lib/cjs/appui-abstract/utils/filter/charCode.js +6 -6
  135. package/lib/cjs/appui-abstract/utils/filter/charCode.js.map +1 -1
  136. package/lib/cjs/appui-abstract/utils/filter/filters.d.ts +98 -98
  137. package/lib/cjs/appui-abstract/utils/filter/filters.d.ts.map +1 -1
  138. package/lib/cjs/appui-abstract/utils/filter/filters.js +709 -709
  139. package/lib/cjs/appui-abstract/utils/filter/filters.js.map +1 -1
  140. package/lib/cjs/appui-abstract/utils/filter/map.d.ts +59 -59
  141. package/lib/cjs/appui-abstract/utils/filter/map.js +402 -402
  142. package/lib/cjs/appui-abstract/utils/filter/map.js.map +1 -1
  143. package/lib/cjs/appui-abstract/utils/filter/strings.d.ts +20 -20
  144. package/lib/cjs/appui-abstract/utils/filter/strings.js +78 -78
  145. package/lib/cjs/appui-abstract/utils/filter/strings.js.map +1 -1
  146. package/lib/cjs/appui-abstract/utils/isLetter.d.ts +9 -9
  147. package/lib/cjs/appui-abstract/utils/isLetter.js +19 -19
  148. package/lib/cjs/appui-abstract/utils/isLetter.js.map +1 -1
  149. package/lib/cjs/appui-abstract/utils/misc.d.ts +11 -11
  150. package/lib/cjs/appui-abstract/utils/misc.js +36 -36
  151. package/lib/cjs/appui-abstract/utils/misc.js.map +1 -1
  152. package/lib/cjs/appui-abstract/widget/AbstractWidgetProps.d.ts +86 -86
  153. package/lib/cjs/appui-abstract/widget/AbstractWidgetProps.js +9 -9
  154. package/lib/cjs/appui-abstract/widget/AbstractWidgetProps.js.map +1 -1
  155. package/lib/cjs/appui-abstract/widget/StagePanel.d.ts +36 -36
  156. package/lib/cjs/appui-abstract/widget/StagePanel.js +46 -46
  157. package/lib/cjs/appui-abstract/widget/StagePanel.js.map +1 -1
  158. package/lib/cjs/appui-abstract/widget/WidgetState.d.ts +19 -19
  159. package/lib/cjs/appui-abstract/widget/WidgetState.js +27 -27
  160. package/lib/cjs/appui-abstract/widget/WidgetState.js.map +1 -1
  161. package/lib/cjs/appui-abstract.d.ts +103 -103
  162. package/lib/cjs/appui-abstract.js +123 -119
  163. package/lib/cjs/appui-abstract.js.map +1 -1
  164. package/lib/esm/appui-abstract/BaseUiItemsProvider.d.ts +30 -30
  165. package/lib/esm/appui-abstract/BaseUiItemsProvider.d.ts.map +1 -1
  166. package/lib/esm/appui-abstract/BaseUiItemsProvider.js +75 -75
  167. package/lib/esm/appui-abstract/BaseUiItemsProvider.js.map +1 -1
  168. package/lib/esm/appui-abstract/UiAdmin.d.ts +221 -221
  169. package/lib/esm/appui-abstract/UiAdmin.js +220 -219
  170. package/lib/esm/appui-abstract/UiAdmin.js.map +1 -1
  171. package/lib/esm/appui-abstract/UiItemsManager.d.ts +113 -113
  172. package/lib/esm/appui-abstract/UiItemsManager.d.ts.map +1 -1
  173. package/lib/esm/appui-abstract/UiItemsManager.js +190 -189
  174. package/lib/esm/appui-abstract/UiItemsManager.js.map +1 -1
  175. package/lib/esm/appui-abstract/UiItemsProvider.d.ts +29 -29
  176. package/lib/esm/appui-abstract/UiItemsProvider.js +8 -8
  177. package/lib/esm/appui-abstract/UiItemsProvider.js.map +1 -1
  178. package/lib/esm/appui-abstract/backstage/BackstageItem.d.ts +91 -91
  179. package/lib/esm/appui-abstract/backstage/BackstageItem.d.ts.map +1 -1
  180. package/lib/esm/appui-abstract/backstage/BackstageItem.js +65 -64
  181. package/lib/esm/appui-abstract/backstage/BackstageItem.js.map +1 -1
  182. package/lib/esm/appui-abstract/backstage/BackstageItemsManager.d.ts +38 -38
  183. package/lib/esm/appui-abstract/backstage/BackstageItemsManager.js +129 -129
  184. package/lib/esm/appui-abstract/backstage/BackstageItemsManager.js.map +1 -1
  185. package/lib/esm/appui-abstract/common/KeyboardKey.d.ts +51 -51
  186. package/lib/esm/appui-abstract/common/KeyboardKey.js +59 -59
  187. package/lib/esm/appui-abstract/common/KeyboardKey.js.map +1 -1
  188. package/lib/esm/appui-abstract/content/ContentLayoutProps.d.ts +62 -62
  189. package/lib/esm/appui-abstract/content/ContentLayoutProps.js +8 -8
  190. package/lib/esm/appui-abstract/content/ContentLayoutProps.js.map +1 -1
  191. package/lib/esm/appui-abstract/content/StandardContentLayouts.d.ts +19 -19
  192. package/lib/esm/appui-abstract/content/StandardContentLayouts.js +105 -104
  193. package/lib/esm/appui-abstract/content/StandardContentLayouts.js.map +1 -1
  194. package/lib/esm/appui-abstract/dialogs/DialogItem.d.ts +76 -76
  195. package/lib/esm/appui-abstract/dialogs/DialogItem.js +63 -63
  196. package/lib/esm/appui-abstract/dialogs/DialogItem.js.map +1 -1
  197. package/lib/esm/appui-abstract/dialogs/UiDataProvider.d.ts +55 -55
  198. package/lib/esm/appui-abstract/dialogs/UiDataProvider.js +61 -61
  199. package/lib/esm/appui-abstract/dialogs/UiDataProvider.js.map +1 -1
  200. package/lib/esm/appui-abstract/dialogs/UiLayoutDataProvider.d.ts +97 -97
  201. package/lib/esm/appui-abstract/dialogs/UiLayoutDataProvider.js +171 -170
  202. package/lib/esm/appui-abstract/dialogs/UiLayoutDataProvider.js.map +1 -1
  203. package/lib/esm/appui-abstract/items/AbstractItemProps.d.ts +53 -53
  204. package/lib/esm/appui-abstract/items/AbstractItemProps.d.ts.map +1 -1
  205. package/lib/esm/appui-abstract/items/AbstractItemProps.js +8 -8
  206. package/lib/esm/appui-abstract/items/AbstractItemProps.js.map +1 -1
  207. package/lib/esm/appui-abstract/items/AbstractMenuItemProps.d.ts +20 -20
  208. package/lib/esm/appui-abstract/items/AbstractMenuItemProps.js +8 -8
  209. package/lib/esm/appui-abstract/items/AbstractMenuItemProps.js.map +1 -1
  210. package/lib/esm/appui-abstract/items/AbstractToolbarProps.d.ts +13 -13
  211. package/lib/esm/appui-abstract/items/AbstractToolbarProps.js +8 -8
  212. package/lib/esm/appui-abstract/items/AbstractToolbarProps.js.map +1 -1
  213. package/lib/esm/appui-abstract/items/BadgeType.d.ts +14 -14
  214. package/lib/esm/appui-abstract/items/BadgeType.js +19 -19
  215. package/lib/esm/appui-abstract/items/BadgeType.js.map +1 -1
  216. package/lib/esm/appui-abstract/items/ConditionalBooleanValue.d.ts +27 -27
  217. package/lib/esm/appui-abstract/items/ConditionalBooleanValue.js +56 -56
  218. package/lib/esm/appui-abstract/items/ConditionalBooleanValue.js.map +1 -1
  219. package/lib/esm/appui-abstract/items/ConditionalStringValue.d.ts +29 -29
  220. package/lib/esm/appui-abstract/items/ConditionalStringValue.js +58 -58
  221. package/lib/esm/appui-abstract/items/ConditionalStringValue.js.map +1 -1
  222. package/lib/esm/appui-abstract/items/ProvidedItem.d.ts +11 -11
  223. package/lib/esm/appui-abstract/items/ProvidedItem.js +8 -8
  224. package/lib/esm/appui-abstract/items/ProvidedItem.js.map +1 -1
  225. package/lib/esm/appui-abstract/items/RelativePosition.d.ts +18 -18
  226. package/lib/esm/appui-abstract/items/RelativePosition.js +23 -23
  227. package/lib/esm/appui-abstract/items/RelativePosition.js.map +1 -1
  228. package/lib/esm/appui-abstract/items/StageUsage.d.ts +16 -16
  229. package/lib/esm/appui-abstract/items/StageUsage.js +21 -21
  230. package/lib/esm/appui-abstract/items/StageUsage.js.map +1 -1
  231. package/lib/esm/appui-abstract/notification/MessagePresenter.d.ts +42 -42
  232. package/lib/esm/appui-abstract/notification/MessagePresenter.js +21 -21
  233. package/lib/esm/appui-abstract/notification/MessagePresenter.js.map +1 -1
  234. package/lib/esm/appui-abstract/notification/MessageSeverity.d.ts +15 -15
  235. package/lib/esm/appui-abstract/notification/MessageSeverity.js +20 -20
  236. package/lib/esm/appui-abstract/notification/MessageSeverity.js.map +1 -1
  237. package/lib/esm/appui-abstract/properties/Description.d.ts +127 -127
  238. package/lib/esm/appui-abstract/properties/Description.js +192 -192
  239. package/lib/esm/appui-abstract/properties/Description.js.map +1 -1
  240. package/lib/esm/appui-abstract/properties/EditorParams.d.ts +260 -260
  241. package/lib/esm/appui-abstract/properties/EditorParams.d.ts.map +1 -1
  242. package/lib/esm/appui-abstract/properties/EditorParams.js +97 -97
  243. package/lib/esm/appui-abstract/properties/EditorParams.js.map +1 -1
  244. package/lib/esm/appui-abstract/properties/PrimitiveTypes.d.ts +60 -60
  245. package/lib/esm/appui-abstract/properties/PrimitiveTypes.js +8 -8
  246. package/lib/esm/appui-abstract/properties/PrimitiveTypes.js.map +1 -1
  247. package/lib/esm/appui-abstract/properties/Record.d.ts +57 -57
  248. package/lib/esm/appui-abstract/properties/Record.js +74 -74
  249. package/lib/esm/appui-abstract/properties/Record.js.map +1 -1
  250. package/lib/esm/appui-abstract/properties/StandardEditorNames.d.ts +22 -22
  251. package/lib/esm/appui-abstract/properties/StandardEditorNames.js +27 -27
  252. package/lib/esm/appui-abstract/properties/StandardEditorNames.js.map +1 -1
  253. package/lib/esm/appui-abstract/properties/StandardTypeNames.d.ts +30 -30
  254. package/lib/esm/appui-abstract/properties/StandardTypeNames.js +36 -36
  255. package/lib/esm/appui-abstract/properties/StandardTypeNames.js.map +1 -1
  256. package/lib/esm/appui-abstract/properties/Value.d.ts +49 -49
  257. package/lib/esm/appui-abstract/properties/Value.d.ts.map +1 -1
  258. package/lib/esm/appui-abstract/properties/Value.js +17 -17
  259. package/lib/esm/appui-abstract/properties/Value.js.map +1 -1
  260. package/lib/esm/appui-abstract/quantity/BaseQuantityDescription.d.ts +22 -22
  261. package/lib/esm/appui-abstract/quantity/BaseQuantityDescription.js +44 -44
  262. package/lib/esm/appui-abstract/quantity/BaseQuantityDescription.js.map +1 -1
  263. package/lib/esm/appui-abstract/statusbar/StatusBarItem.d.ts +128 -128
  264. package/lib/esm/appui-abstract/statusbar/StatusBarItem.d.ts.map +1 -1
  265. package/lib/esm/appui-abstract/statusbar/StatusBarItem.js +81 -80
  266. package/lib/esm/appui-abstract/statusbar/StatusBarItem.js.map +1 -1
  267. package/lib/esm/appui-abstract/statusbar/StatusBarItemsManager.d.ts +39 -39
  268. package/lib/esm/appui-abstract/statusbar/StatusBarItemsManager.js +131 -131
  269. package/lib/esm/appui-abstract/statusbar/StatusBarItemsManager.js.map +1 -1
  270. package/lib/esm/appui-abstract/toolbars/ToolbarItem.d.ts +121 -121
  271. package/lib/esm/appui-abstract/toolbars/ToolbarItem.d.ts.map +1 -1
  272. package/lib/esm/appui-abstract/toolbars/ToolbarItem.js +61 -60
  273. package/lib/esm/appui-abstract/toolbars/ToolbarItem.js.map +1 -1
  274. package/lib/esm/appui-abstract/toolbars/ToolbarItemsManager.d.ts +45 -45
  275. package/lib/esm/appui-abstract/toolbars/ToolbarItemsManager.js +231 -231
  276. package/lib/esm/appui-abstract/toolbars/ToolbarItemsManager.js.map +1 -1
  277. package/lib/esm/appui-abstract/utils/IconSpecUtilities.d.ts +29 -29
  278. package/lib/esm/appui-abstract/utils/IconSpecUtilities.js +48 -47
  279. package/lib/esm/appui-abstract/utils/IconSpecUtilities.js.map +1 -1
  280. package/lib/esm/appui-abstract/utils/PointProps.d.ts +10 -10
  281. package/lib/esm/appui-abstract/utils/PointProps.js +8 -8
  282. package/lib/esm/appui-abstract/utils/PointProps.js.map +1 -1
  283. package/lib/esm/appui-abstract/utils/UiError.d.ts +12 -12
  284. package/lib/esm/appui-abstract/utils/UiError.js +18 -18
  285. package/lib/esm/appui-abstract/utils/UiError.js.map +1 -1
  286. package/lib/esm/appui-abstract/utils/UiEvent.d.ts +9 -9
  287. package/lib/esm/appui-abstract/utils/UiEvent.js +13 -13
  288. package/lib/esm/appui-abstract/utils/UiEvent.js.map +1 -1
  289. package/lib/esm/appui-abstract/utils/UiEventDispatcher.d.ts +46 -46
  290. package/lib/esm/appui-abstract/utils/UiEventDispatcher.js +126 -126
  291. package/lib/esm/appui-abstract/utils/UiEventDispatcher.js.map +1 -1
  292. package/lib/esm/appui-abstract/utils/callbacks.d.ts +20 -20
  293. package/lib/esm/appui-abstract/utils/callbacks.d.ts.map +1 -1
  294. package/lib/esm/appui-abstract/utils/callbacks.js +8 -8
  295. package/lib/esm/appui-abstract/utils/callbacks.js.map +1 -1
  296. package/lib/esm/appui-abstract/utils/filter/charCode.d.ts +416 -416
  297. package/lib/esm/appui-abstract/utils/filter/charCode.js +5 -5
  298. package/lib/esm/appui-abstract/utils/filter/charCode.js.map +1 -1
  299. package/lib/esm/appui-abstract/utils/filter/filters.d.ts +98 -98
  300. package/lib/esm/appui-abstract/utils/filter/filters.d.ts.map +1 -1
  301. package/lib/esm/appui-abstract/utils/filter/filters.js +694 -694
  302. package/lib/esm/appui-abstract/utils/filter/filters.js.map +1 -1
  303. package/lib/esm/appui-abstract/utils/filter/map.d.ts +59 -59
  304. package/lib/esm/appui-abstract/utils/filter/map.js +397 -397
  305. package/lib/esm/appui-abstract/utils/filter/map.js.map +1 -1
  306. package/lib/esm/appui-abstract/utils/filter/strings.d.ts +20 -20
  307. package/lib/esm/appui-abstract/utils/filter/strings.js +70 -70
  308. package/lib/esm/appui-abstract/utils/filter/strings.js.map +1 -1
  309. package/lib/esm/appui-abstract/utils/isLetter.d.ts +9 -9
  310. package/lib/esm/appui-abstract/utils/isLetter.js +15 -15
  311. package/lib/esm/appui-abstract/utils/isLetter.js.map +1 -1
  312. package/lib/esm/appui-abstract/utils/misc.d.ts +11 -11
  313. package/lib/esm/appui-abstract/utils/misc.js +31 -31
  314. package/lib/esm/appui-abstract/utils/misc.js.map +1 -1
  315. package/lib/esm/appui-abstract/widget/AbstractWidgetProps.d.ts +86 -86
  316. package/lib/esm/appui-abstract/widget/AbstractWidgetProps.js +8 -8
  317. package/lib/esm/appui-abstract/widget/AbstractWidgetProps.js.map +1 -1
  318. package/lib/esm/appui-abstract/widget/StagePanel.d.ts +36 -36
  319. package/lib/esm/appui-abstract/widget/StagePanel.js +43 -43
  320. package/lib/esm/appui-abstract/widget/StagePanel.js.map +1 -1
  321. package/lib/esm/appui-abstract/widget/WidgetState.d.ts +19 -19
  322. package/lib/esm/appui-abstract/widget/WidgetState.js +24 -24
  323. package/lib/esm/appui-abstract/widget/WidgetState.js.map +1 -1
  324. package/lib/esm/appui-abstract.d.ts +103 -103
  325. package/lib/esm/appui-abstract.js +107 -107
  326. package/lib/esm/appui-abstract.js.map +1 -1
  327. package/package.json +6 -6
@@ -1,695 +1,695 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- /** @packageDocumentation
6
- * @module Utilities
7
- */
8
- import { LRUCache } from "./map";
9
- import * as strings from "./strings";
10
- // Combined filters
11
- /**
12
- * @returns A filter which combines the provided set
13
- * of filters with an or. The *first* filters that
14
- * matches defined the return value of the returned
15
- * filter.
16
- * @internal
17
- */
18
- export function or(...filter) {
19
- return function (word, wordToMatchAgainst) {
20
- for (let i = 0, len = filter.length; i < len; i++) {
21
- const match = filter[i](word, wordToMatchAgainst);
22
- if (match) {
23
- return match;
24
- }
25
- }
26
- return null;
27
- };
28
- }
29
- // Prefix
30
- /** @internal */
31
- export const matchesStrictPrefix = _matchesPrefix.bind(undefined, false);
32
- /** @internal */
33
- export const matchesPrefix = _matchesPrefix.bind(undefined, true);
34
- function _matchesPrefix(ignoreCase, word, wordToMatchAgainst) {
35
- if (!wordToMatchAgainst || wordToMatchAgainst.length < word.length) {
36
- return null;
37
- }
38
- let matches;
39
- if (ignoreCase) {
40
- matches = strings.startsWithIgnoreCase(wordToMatchAgainst, word);
41
- }
42
- else {
43
- matches = wordToMatchAgainst.indexOf(word) === 0;
44
- }
45
- if (!matches) {
46
- return null;
47
- }
48
- return word.length > 0 ? [{ start: 0, end: word.length }] : [];
49
- }
50
- // Contiguous Substring
51
- /** @internal */
52
- export function matchesContiguousSubString(word, wordToMatchAgainst) {
53
- const index = wordToMatchAgainst.toLowerCase().indexOf(word.toLowerCase());
54
- if (index === -1) {
55
- return null;
56
- }
57
- return [{ start: index, end: index + word.length }];
58
- }
59
- // Substring
60
- /**
61
- * Return case insensitive substring matches
62
- * @param word filter string
63
- * @param wordToMatchAgainst string to test
64
- * @internal
65
- */
66
- export function matchesSubString(word, wordToMatchAgainst) {
67
- return _matchesSubString(word.toLowerCase(), wordToMatchAgainst.toLowerCase(), 0, 0);
68
- }
69
- function _matchesSubString(word, wordToMatchAgainst, i, j) {
70
- if (i === word.length) {
71
- return [];
72
- }
73
- else if (j === wordToMatchAgainst.length) {
74
- return null;
75
- }
76
- else {
77
- if (word[i] === wordToMatchAgainst[j]) {
78
- let result = null;
79
- if (result = _matchesSubString(word, wordToMatchAgainst, i + 1, j + 1)) {
80
- return join({ start: j, end: j + 1 }, result);
81
- }
82
- return null;
83
- }
84
- return _matchesSubString(word, wordToMatchAgainst, i, j + 1);
85
- }
86
- }
87
- // CamelCase
88
- function isLower(code) {
89
- return 97 /* a */ <= code && code <= 122 /* z */;
90
- }
91
- function isUpper(code) {
92
- return 65 /* A */ <= code && code <= 90 /* Z */;
93
- }
94
- function isNumber(code) {
95
- return 48 /* Digit0 */ <= code && code <= 57 /* Digit9 */;
96
- }
97
- function isWhitespace(code) {
98
- return (code === 32 /* Space */
99
- || code === 9 /* Tab */
100
- || code === 10 /* LineFeed */
101
- || code === 13 /* CarriageReturn */);
102
- }
103
- const wordSeparators = new Set();
104
- '`~!@#$%^&*()-=+[{]}\\|;:\'",.<>/?'
105
- .split("")
106
- .forEach((s) => wordSeparators.add(s.charCodeAt(0)));
107
- function isWordSeparator(code) {
108
- return isWhitespace(code) || wordSeparators.has(code);
109
- }
110
- function charactersMatch(codeA, codeB) {
111
- return (codeA === codeB) || (isWordSeparator(codeA) && isWordSeparator(codeB));
112
- }
113
- function isAlphanumeric(code) {
114
- return isLower(code) || isUpper(code) || isNumber(code);
115
- }
116
- function join(head, tail) {
117
- if (tail.length === 0) {
118
- tail = [head];
119
- }
120
- else if (head.end === tail[0].start) {
121
- tail[0].start = head.start;
122
- }
123
- else {
124
- tail.unshift(head);
125
- }
126
- return tail;
127
- }
128
- function nextAnchor(camelCaseWord, start) {
129
- for (let i = start; i < camelCaseWord.length; i++) {
130
- const c = camelCaseWord.charCodeAt(i);
131
- if (isUpper(c) || isNumber(c) || (i > 0 && !isAlphanumeric(camelCaseWord.charCodeAt(i - 1)))) {
132
- return i;
133
- }
134
- }
135
- return camelCaseWord.length;
136
- }
137
- function _matchesCamelCase(word, camelCaseWord, i, j) {
138
- if (i === word.length) {
139
- return [];
140
- }
141
- else if (j === camelCaseWord.length) {
142
- return null;
143
- }
144
- else if (word[i] !== camelCaseWord[j].toLowerCase()) {
145
- return null;
146
- }
147
- else {
148
- let result = null;
149
- let nextUpperIndex = j + 1;
150
- result = _matchesCamelCase(word, camelCaseWord, i + 1, j + 1);
151
- while (!result && (nextUpperIndex = nextAnchor(camelCaseWord, nextUpperIndex)) < camelCaseWord.length) {
152
- result = _matchesCamelCase(word, camelCaseWord, i + 1, nextUpperIndex);
153
- nextUpperIndex++;
154
- }
155
- return result === null ? null : join({ start: j, end: j + 1 }, result);
156
- }
157
- }
158
- // Heuristic to avoid computing camel case matcher for words that don't
159
- // look like camelCaseWords.
160
- function analyzeCamelCaseWord(word) {
161
- let upper = 0, lower = 0, alpha = 0, numeric = 0, code = 0;
162
- for (let i = 0; i < word.length; i++) {
163
- code = word.charCodeAt(i);
164
- if (isUpper(code)) {
165
- upper++;
166
- }
167
- if (isLower(code)) {
168
- lower++;
169
- }
170
- if (isAlphanumeric(code)) {
171
- alpha++;
172
- }
173
- if (isNumber(code)) {
174
- numeric++;
175
- }
176
- }
177
- const upperPercent = upper / word.length;
178
- const lowerPercent = lower / word.length;
179
- const alphaPercent = alpha / word.length;
180
- const numericPercent = numeric / word.length;
181
- return { upperPercent, lowerPercent, alphaPercent, numericPercent };
182
- }
183
- function isUpperCaseWord(analysis) {
184
- const { upperPercent, lowerPercent } = analysis;
185
- return lowerPercent === 0 && upperPercent > 0.6;
186
- }
187
- function isCamelCaseWord(analysis) {
188
- const { upperPercent, lowerPercent, alphaPercent, numericPercent } = analysis;
189
- return lowerPercent > 0.2 && upperPercent < 0.8 && alphaPercent > 0.6 && numericPercent < 0.2;
190
- }
191
- // Heuristic to avoid computing camel case matcher for words that don't
192
- // look like camel case patterns.
193
- function isCamelCasePattern(word) {
194
- let upper = 0, lower = 0, code = 0, whitespace = 0;
195
- for (let i = 0; i < word.length; i++) {
196
- code = word.charCodeAt(i);
197
- if (isUpper(code)) {
198
- upper++;
199
- }
200
- if (isLower(code)) {
201
- lower++;
202
- }
203
- if (isWhitespace(code)) {
204
- whitespace++;
205
- }
206
- }
207
- if ((upper === 0 || lower === 0) && whitespace === 0) {
208
- return word.length <= 30;
209
- }
210
- else {
211
- return upper <= 5;
212
- }
213
- }
214
- /**
215
- * Return matches treating "camelCase" words separately. For example the filter string "gp" would return two matches in string "Git Pull".
216
- * @param word filter string
217
- * @param wordToMatchAgainst string to test
218
- * @internal
219
- */
220
- export function matchesCamelCase(word, camelCaseWord) {
221
- if (!camelCaseWord) {
222
- return null;
223
- }
224
- camelCaseWord = camelCaseWord.trim();
225
- if (camelCaseWord.length === 0) {
226
- return null;
227
- }
228
- if (!isCamelCasePattern(camelCaseWord)) {
229
- return null;
230
- }
231
- if (camelCaseWord.length > 60) {
232
- return null;
233
- }
234
- const analysis = analyzeCamelCaseWord(camelCaseWord);
235
- if (!isCamelCaseWord(analysis)) {
236
- // istanbul ignore next
237
- if (!isUpperCaseWord(analysis)) {
238
- return null;
239
- }
240
- camelCaseWord = camelCaseWord.toLowerCase();
241
- }
242
- let result = null;
243
- let i = 0;
244
- word = word.toLowerCase();
245
- while (i < camelCaseWord.length && (result = _matchesCamelCase(word, camelCaseWord, 0, i)) === null) {
246
- i = nextAnchor(camelCaseWord, i + 1);
247
- }
248
- return result;
249
- }
250
- /**
251
- * Matches beginning of words supporting non-ASCII languages.
252
- * @param word Filter string
253
- * @param target String being searched
254
- * @param contiguous - If true the filter string must be found "contiguous" in the searched string (E.g. "pul" will match "Git: Pull").
255
- * 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").
256
- * Useful in cases where the target is words (e.g. command labels)
257
- * @internal
258
- */
259
- export function matchesWords(word, target, contiguous = false) {
260
- if (!target || target.length === 0) {
261
- return null;
262
- }
263
- let result = null;
264
- let i = 0;
265
- word = word.toLowerCase();
266
- target = target.toLowerCase();
267
- while (i < target.length && (result = _matchesWords(word, target, 0, i, contiguous)) === null) {
268
- i = nextWord(target, i + 1);
269
- }
270
- return result;
271
- }
272
- function _matchesWords(word, target, i, j, contiguous) {
273
- if (i === word.length) {
274
- return [];
275
- }
276
- else if (j === target.length) {
277
- return null;
278
- }
279
- else if (!charactersMatch(word.charCodeAt(i), target.charCodeAt(j))) {
280
- return null;
281
- }
282
- else {
283
- let result = null;
284
- let nextWordIndex = j + 1;
285
- result = _matchesWords(word, target, i + 1, j + 1, contiguous);
286
- // istanbul ignore else
287
- if (!contiguous) {
288
- while (!result && (nextWordIndex = nextWord(target, nextWordIndex)) < target.length) {
289
- result = _matchesWords(word, target, i + 1, nextWordIndex, contiguous);
290
- nextWordIndex++;
291
- }
292
- }
293
- return result === null ? null : join({ start: j, end: j + 1 }, result);
294
- }
295
- }
296
- function nextWord(word, start) {
297
- for (let i = start; i < word.length; i++) {
298
- if (isWordSeparator(word.charCodeAt(i)) ||
299
- (i > 0 && isWordSeparator(word.charCodeAt(i - 1)))) {
300
- return i;
301
- }
302
- }
303
- return word.length;
304
- }
305
- // Fuzzy
306
- const fuzzyContiguousFilter = or(matchesPrefix, matchesCamelCase, matchesContiguousSubString);
307
- const fuzzySeparateFilter = or(matchesPrefix, matchesCamelCase, matchesSubString);
308
- const fuzzyRegExpCache = new LRUCache(10000); // bounded to 10000 elements
309
- /**
310
- * Match pattern against word in a fuzzy way. This will only return a single match.
311
- * @internal
312
- */
313
- export function matchesFuzzy(word, wordToMatchAgainst, enableSeparateSubstringMatching = false) {
314
- // istanbul ignore next
315
- if (typeof word !== "string" || typeof wordToMatchAgainst !== "string") {
316
- return null; // return early for invalid input
317
- }
318
- // Form RegExp for wildcard matches
319
- let regexp = fuzzyRegExpCache.get(word);
320
- if (!regexp) {
321
- regexp = new RegExp(strings.convertSimple2RegExpPattern(word), "i");
322
- fuzzyRegExpCache.set(word, regexp);
323
- }
324
- // RegExp Filter
325
- const match = regexp.exec(wordToMatchAgainst);
326
- if (match) {
327
- return [{ start: match.index, end: match.index + match[0].length }];
328
- }
329
- // Default Filter
330
- return enableSeparateSubstringMatching ? /* istanbul ignore next */ fuzzySeparateFilter(word, wordToMatchAgainst) : fuzzyContiguousFilter(word, wordToMatchAgainst);
331
- }
332
- /**
333
- * Match pattern against word in a fuzzy way. As in IntelliSense and faster and more
334
- * powerful than `matchesFuzzy`. This will only return a single match.
335
- * @internal
336
- */
337
- export function matchesFuzzy2(pattern, word) {
338
- const score = fuzzyScore(pattern, pattern.toLowerCase(), 0, word, word.toLowerCase(), 0, true);
339
- return score ? createMatches(score) : null;
340
- }
341
- // #region --- fuzzyScore ---
342
- /**
343
- * @internal
344
- */
345
- export function createMatches(score) {
346
- // istanbul ignore next
347
- if (typeof score === "undefined") {
348
- return [];
349
- }
350
- const matches = score[1].toString(2);
351
- const wordStart = score[2];
352
- const res = [];
353
- for (let pos = wordStart; pos < _maxLen; pos++) {
354
- if (matches[matches.length - (pos + 1)] === "1") {
355
- const last = res[res.length - 1];
356
- if (last && last.end === pos) {
357
- last.end = pos + 1;
358
- }
359
- else {
360
- res.push({ start: pos, end: pos + 1 });
361
- }
362
- }
363
- }
364
- return res;
365
- }
366
- const _maxLen = 128;
367
- function initTable() {
368
- const table = [];
369
- const row = [0];
370
- for (let i = 1; i <= _maxLen; i++) {
371
- row.push(-i);
372
- }
373
- for (let i = 0; i <= _maxLen; i++) {
374
- const thisRow = row.slice(0);
375
- thisRow[0] = -i;
376
- table.push(thisRow);
377
- }
378
- return table;
379
- }
380
- const _table = initTable();
381
- const _scores = initTable();
382
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
383
- const _arrows = initTable();
384
- const _debug = false;
385
- function isSeparatorAtPos(value, index) {
386
- if (index < 0 || index >= value.length) {
387
- return false;
388
- }
389
- const code = value.charCodeAt(index);
390
- switch (code) {
391
- case 95 /* Underline */:
392
- case 45 /* Dash */:
393
- case 46 /* Period */:
394
- case 32 /* Space */:
395
- case 47 /* Slash */:
396
- case 92 /* Backslash */:
397
- case 39 /* SingleQuote */:
398
- case 34 /* DoubleQuote */:
399
- case 58 /* Colon */:
400
- case 36 /* DollarSign */:
401
- return true;
402
- default:
403
- return false;
404
- }
405
- }
406
- function isWhitespaceAtPos(value, index) {
407
- if (index < 0 || index >= value.length) {
408
- return false;
409
- }
410
- const code = value.charCodeAt(index);
411
- switch (code) {
412
- // istanbul ignore next
413
- case 32 /* Space */:
414
- case 9 /* Tab */:
415
- return true;
416
- default:
417
- return false;
418
- }
419
- }
420
- function isUpperCaseAtPos(pos, word, wordLow) {
421
- return word[pos] !== wordLow[pos];
422
- }
423
- /** @internal */
424
- export function isPatternInWord(patternLow, patternPos, patternLen, wordLow, wordPos, wordLen) {
425
- while (patternPos < patternLen && wordPos < wordLen) {
426
- if (patternLow[patternPos] === wordLow[wordPos]) {
427
- patternPos += 1;
428
- }
429
- wordPos += 1;
430
- }
431
- return patternPos === patternLen; // pattern must be exhausted
432
- }
433
- /** @internal */
434
- export var FuzzyScore;
435
- (function (FuzzyScore) {
436
- /**
437
- * No matches and value `-100`
438
- * @internal
439
- */
440
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
441
- FuzzyScore.Default = Object.freeze([-100, 0, 0]);
442
- // istanbul ignore next
443
- /** @internal */
444
- function isDefault(score) {
445
- return !score || (score[0] === -100 && score[1] === 0 && score[2] === 0);
446
- }
447
- FuzzyScore.isDefault = isDefault;
448
- })(FuzzyScore || (FuzzyScore = {}));
449
- /** @internal */
450
- export function fuzzyScore(pattern, patternLow, patternStart, word, wordLow, wordStart, firstMatchCanBeWeak) {
451
- // istanbul ignore next
452
- const patternLen = pattern.length > _maxLen ? _maxLen : pattern.length;
453
- const wordLen = word.length > _maxLen ? _maxLen : word.length;
454
- if (patternStart >= patternLen || wordStart >= wordLen || (patternLen - patternStart) > (wordLen - wordStart)) {
455
- return undefined;
456
- }
457
- // Run a simple check if the characters of pattern occur
458
- // (in order) at all in word. If that isn't the case we
459
- // stop because no match will be possible
460
- if (!isPatternInWord(patternLow, patternStart, patternLen, wordLow, wordStart, wordLen)) {
461
- return undefined;
462
- }
463
- let row = 1;
464
- let column = 1;
465
- let patternPos = patternStart;
466
- let wordPos = wordStart;
467
- let hasStrongFirstMatch = false;
468
- // There will be a match, fill in tables
469
- for (row = 1, patternPos = patternStart; patternPos < patternLen; row++, patternPos++) {
470
- for (column = 1, wordPos = wordStart; wordPos < wordLen; column++, wordPos++) {
471
- const score = _doScore(pattern, patternLow, patternPos, patternStart, word, wordLow, wordPos);
472
- if (patternPos === patternStart && score > 1) {
473
- hasStrongFirstMatch = true;
474
- }
475
- _scores[row][column] = score;
476
- const diag = _table[row - 1][column - 1] + (score > 1 ? 1 : score);
477
- const top = _table[row - 1][column] + -1;
478
- const left = _table[row][column - 1] + -1;
479
- if (left >= top) {
480
- // left or diag
481
- if (left > diag) {
482
- _table[row][column] = left;
483
- _arrows[row][column] = 4 /* Left */;
484
- }
485
- else if (left === diag) {
486
- _table[row][column] = left;
487
- _arrows[row][column] = 4 /* Left */ | 2 /* Diag */;
488
- }
489
- else {
490
- _table[row][column] = diag;
491
- _arrows[row][column] = 2 /* Diag */;
492
- }
493
- }
494
- else {
495
- // top or diag
496
- if (top > diag) {
497
- _table[row][column] = top;
498
- _arrows[row][column] = 1 /* Top */;
499
- }
500
- else if (top === diag) {
501
- _table[row][column] = top;
502
- _arrows[row][column] = 1 /* Top */ | 2 /* Diag */;
503
- }
504
- else {
505
- _table[row][column] = diag;
506
- _arrows[row][column] = 2 /* Diag */;
507
- }
508
- }
509
- }
510
- }
511
- if (!hasStrongFirstMatch && !firstMatchCanBeWeak) {
512
- return undefined;
513
- }
514
- _matchesCount = 0;
515
- _topScore = -100;
516
- _wordStart = wordStart;
517
- _firstMatchCanBeWeak = firstMatchCanBeWeak;
518
- _findAllMatches2(row - 1, column - 1, patternLen === wordLen ? 1 : 0, 0, false);
519
- if (_matchesCount === 0) {
520
- return undefined;
521
- }
522
- return [_topScore, _topMatch2, wordStart];
523
- }
524
- function _doScore(pattern, patternLow, patternPos, patternStart, word, wordLow, wordPos) {
525
- if (patternLow[patternPos] !== wordLow[wordPos]) {
526
- return -1;
527
- }
528
- if (wordPos === (patternPos - patternStart)) {
529
- // common prefix: `foobar <-> foobaz`
530
- // ^^^^^
531
- if (pattern[patternPos] === word[wordPos]) {
532
- return 7;
533
- }
534
- else {
535
- return 5;
536
- }
537
- }
538
- else if (isUpperCaseAtPos(wordPos, word, wordLow) && (wordPos === 0 || !isUpperCaseAtPos(wordPos - 1, word, wordLow))) {
539
- // hitting upper-case: `foo <-> forOthers`
540
- // ^^ ^
541
- if (pattern[patternPos] === word[wordPos]) {
542
- return 7;
543
- }
544
- else {
545
- return 5;
546
- }
547
- }
548
- else if (isSeparatorAtPos(wordLow, wordPos) && (wordPos === 0 || !isSeparatorAtPos(wordLow, wordPos - 1))) {
549
- // hitting a separator: `. <-> foo.bar`
550
- // ^
551
- return 5;
552
- }
553
- else if (isSeparatorAtPos(wordLow, wordPos - 1) || isWhitespaceAtPos(wordLow, wordPos - 1)) {
554
- // post separator: `foo <-> bar_foo`
555
- // ^^^
556
- return 5;
557
- }
558
- else {
559
- return 1;
560
- }
561
- }
562
- let _matchesCount = 0;
563
- let _topMatch2 = 0;
564
- let _topScore = 0;
565
- let _wordStart = 0;
566
- let _firstMatchCanBeWeak = false;
567
- function _findAllMatches2(row, column, total, matches, lastMatched) {
568
- if (_matchesCount >= 10 || total < -25) {
569
- // stop when having already 10 results, or
570
- // when a potential alignment as already 5 gaps
571
- return;
572
- }
573
- let simpleMatchCount = 0;
574
- while (row > 0 && column > 0) {
575
- const score = _scores[row][column];
576
- const arrow = _arrows[row][column];
577
- if (arrow === 4 /* Left */) {
578
- // left -> no match, skip a word character
579
- column -= 1;
580
- if (lastMatched) {
581
- total -= 5; // new gap penalty
582
- }
583
- else if (matches !== 0) {
584
- total -= 1; // gap penalty after first match
585
- }
586
- lastMatched = false;
587
- simpleMatchCount = 0;
588
- }
589
- else {
590
- /* istanbul ignore else */
591
- if (arrow & 2 /* Diag */) {
592
- if (arrow & 4 /* Left */) {
593
- // left
594
- _findAllMatches2(row, column - 1, matches !== 0 ? total - 1 : total, // gap penalty after first match
595
- matches, lastMatched);
596
- }
597
- // diag
598
- total += score;
599
- row -= 1;
600
- column -= 1;
601
- lastMatched = true;
602
- // match -> set a 1 at the word pos
603
- matches += 2 ** (column + _wordStart);
604
- // count simple matches and boost a row of
605
- // simple matches when they yield in a
606
- // strong match.
607
- if (score === 1) {
608
- simpleMatchCount += 1;
609
- if (row === 0 && !_firstMatchCanBeWeak) {
610
- // when the first match is a weak
611
- // match we discard it
612
- return undefined;
613
- }
614
- }
615
- else {
616
- // boost
617
- total += 1 + (simpleMatchCount * (score - 1));
618
- simpleMatchCount = 0;
619
- }
620
- }
621
- else {
622
- // istanbul ignore next
623
- return undefined;
624
- }
625
- }
626
- }
627
- total -= column >= 3 ? 9 : column * 3; // late start penalty
628
- // dynamically keep track of the current top score
629
- // and insert the current best score at head, the rest at tail
630
- _matchesCount += 1;
631
- if (total > _topScore) {
632
- _topScore = total;
633
- _topMatch2 = matches;
634
- }
635
- }
636
- // #endregion
637
- // #region --- graceful ---
638
- /** @internal */
639
- export function fuzzyScoreGracefulAggressive(pattern, lowPattern, patternPos, word, lowWord, wordPos, firstMatchCanBeWeak) {
640
- return fuzzyScoreWithPermutations(pattern, lowPattern, patternPos, word, lowWord, wordPos, true, firstMatchCanBeWeak);
641
- }
642
- /** @internal */
643
- export function fuzzyScoreGraceful(pattern, lowPattern, patternPos, word, lowWord, wordPos, firstMatchCanBeWeak) {
644
- return fuzzyScoreWithPermutations(pattern, lowPattern, patternPos, word, lowWord, wordPos, false, firstMatchCanBeWeak);
645
- }
646
- function fuzzyScoreWithPermutations(pattern, lowPattern, patternPos, word, lowWord, wordPos, aggressive, firstMatchCanBeWeak) {
647
- let top = fuzzyScore(pattern, lowPattern, patternPos, word, lowWord, wordPos, firstMatchCanBeWeak);
648
- if (top && !aggressive) {
649
- // when using the original pattern yield a result we`
650
- // return it unless we are aggressive and try to find
651
- // a better alignment, e.g. `cno` -> `^co^ns^ole` or `^c^o^nsole`.
652
- return top;
653
- }
654
- // istanbul ignore else
655
- if (pattern.length >= 3) {
656
- // When the pattern is long enough then try a few (max 7)
657
- // permutations of the pattern to find a better match. The
658
- // permutations only swap neighbouring characters, e.g
659
- // `cnoso` becomes `conso`, `cnsoo`, `cnoos`.
660
- const tries = Math.min(7, pattern.length - 1);
661
- for (let movingPatternPos = patternPos + 1; movingPatternPos < tries; movingPatternPos++) {
662
- const newPattern = nextTypoPermutation(pattern, movingPatternPos);
663
- // istanbul ignore else
664
- if (newPattern) {
665
- const candidate = fuzzyScore(newPattern, newPattern.toLowerCase(), patternPos, word, lowWord, wordPos, firstMatchCanBeWeak);
666
- if (candidate) {
667
- candidate[0] -= 3; // permutation penalty
668
- // istanbul ignore else
669
- if (!top || candidate[0] > top[0]) {
670
- top = candidate;
671
- }
672
- }
673
- }
674
- }
675
- }
676
- return top;
677
- }
678
- function nextTypoPermutation(pattern, patternPos) {
679
- // istanbul ignore next
680
- if (patternPos + 1 >= pattern.length) {
681
- return undefined;
682
- }
683
- const swap1 = pattern[patternPos];
684
- const swap2 = pattern[patternPos + 1];
685
- // istanbul ignore next
686
- if (swap1 === swap2) {
687
- return undefined;
688
- }
689
- return pattern.slice(0, patternPos)
690
- + swap2
691
- + swap1
692
- + pattern.slice(patternPos + 2);
693
- }
694
- // #endregion
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module Utilities
7
+ */
8
+ import { LRUCache } from "./map";
9
+ import * as strings from "./strings";
10
+ // Combined filters
11
+ /**
12
+ * @returns A filter which combines the provided set
13
+ * of filters with an or. The *first* filters that
14
+ * matches defined the return value of the returned
15
+ * filter.
16
+ * @internal
17
+ */
18
+ export function or(...filter) {
19
+ return function (word, wordToMatchAgainst) {
20
+ for (let i = 0, len = filter.length; i < len; i++) {
21
+ const match = filter[i](word, wordToMatchAgainst);
22
+ if (match) {
23
+ return match;
24
+ }
25
+ }
26
+ return null;
27
+ };
28
+ }
29
+ // Prefix
30
+ /** @internal */
31
+ export const matchesStrictPrefix = _matchesPrefix.bind(undefined, false);
32
+ /** @internal */
33
+ export const matchesPrefix = _matchesPrefix.bind(undefined, true);
34
+ function _matchesPrefix(ignoreCase, word, wordToMatchAgainst) {
35
+ if (!wordToMatchAgainst || wordToMatchAgainst.length < word.length) {
36
+ return null;
37
+ }
38
+ let matches;
39
+ if (ignoreCase) {
40
+ matches = strings.startsWithIgnoreCase(wordToMatchAgainst, word);
41
+ }
42
+ else {
43
+ matches = wordToMatchAgainst.indexOf(word) === 0;
44
+ }
45
+ if (!matches) {
46
+ return null;
47
+ }
48
+ return word.length > 0 ? [{ start: 0, end: word.length }] : [];
49
+ }
50
+ // Contiguous Substring
51
+ /** @internal */
52
+ export function matchesContiguousSubString(word, wordToMatchAgainst) {
53
+ const index = wordToMatchAgainst.toLowerCase().indexOf(word.toLowerCase());
54
+ if (index === -1) {
55
+ return null;
56
+ }
57
+ return [{ start: index, end: index + word.length }];
58
+ }
59
+ // Substring
60
+ /**
61
+ * Return case insensitive substring matches
62
+ * @param word filter string
63
+ * @param wordToMatchAgainst string to test
64
+ * @internal
65
+ */
66
+ export function matchesSubString(word, wordToMatchAgainst) {
67
+ return _matchesSubString(word.toLowerCase(), wordToMatchAgainst.toLowerCase(), 0, 0);
68
+ }
69
+ function _matchesSubString(word, wordToMatchAgainst, i, j) {
70
+ if (i === word.length) {
71
+ return [];
72
+ }
73
+ else if (j === wordToMatchAgainst.length) {
74
+ return null;
75
+ }
76
+ else {
77
+ if (word[i] === wordToMatchAgainst[j]) {
78
+ let result = null;
79
+ if (result = _matchesSubString(word, wordToMatchAgainst, i + 1, j + 1)) {
80
+ return join({ start: j, end: j + 1 }, result);
81
+ }
82
+ return null;
83
+ }
84
+ return _matchesSubString(word, wordToMatchAgainst, i, j + 1);
85
+ }
86
+ }
87
+ // CamelCase
88
+ function isLower(code) {
89
+ return 97 /* CharCode.a */ <= code && code <= 122 /* CharCode.z */;
90
+ }
91
+ function isUpper(code) {
92
+ return 65 /* CharCode.A */ <= code && code <= 90 /* CharCode.Z */;
93
+ }
94
+ function isNumber(code) {
95
+ return 48 /* CharCode.Digit0 */ <= code && code <= 57 /* CharCode.Digit9 */;
96
+ }
97
+ function isWhitespace(code) {
98
+ return (code === 32 /* CharCode.Space */
99
+ || code === 9 /* CharCode.Tab */
100
+ || code === 10 /* CharCode.LineFeed */
101
+ || code === 13 /* CharCode.CarriageReturn */);
102
+ }
103
+ const wordSeparators = new Set();
104
+ '`~!@#$%^&*()-=+[{]}\\|;:\'",.<>/?'
105
+ .split("")
106
+ .forEach((s) => wordSeparators.add(s.charCodeAt(0)));
107
+ function isWordSeparator(code) {
108
+ return isWhitespace(code) || wordSeparators.has(code);
109
+ }
110
+ function charactersMatch(codeA, codeB) {
111
+ return (codeA === codeB) || (isWordSeparator(codeA) && isWordSeparator(codeB));
112
+ }
113
+ function isAlphanumeric(code) {
114
+ return isLower(code) || isUpper(code) || isNumber(code);
115
+ }
116
+ function join(head, tail) {
117
+ if (tail.length === 0) {
118
+ tail = [head];
119
+ }
120
+ else if (head.end === tail[0].start) {
121
+ tail[0].start = head.start;
122
+ }
123
+ else {
124
+ tail.unshift(head);
125
+ }
126
+ return tail;
127
+ }
128
+ function nextAnchor(camelCaseWord, start) {
129
+ for (let i = start; i < camelCaseWord.length; i++) {
130
+ const c = camelCaseWord.charCodeAt(i);
131
+ if (isUpper(c) || isNumber(c) || (i > 0 && !isAlphanumeric(camelCaseWord.charCodeAt(i - 1)))) {
132
+ return i;
133
+ }
134
+ }
135
+ return camelCaseWord.length;
136
+ }
137
+ function _matchesCamelCase(word, camelCaseWord, i, j) {
138
+ if (i === word.length) {
139
+ return [];
140
+ }
141
+ else if (j === camelCaseWord.length) {
142
+ return null;
143
+ }
144
+ else if (word[i] !== camelCaseWord[j].toLowerCase()) {
145
+ return null;
146
+ }
147
+ else {
148
+ let result = null;
149
+ let nextUpperIndex = j + 1;
150
+ result = _matchesCamelCase(word, camelCaseWord, i + 1, j + 1);
151
+ while (!result && (nextUpperIndex = nextAnchor(camelCaseWord, nextUpperIndex)) < camelCaseWord.length) {
152
+ result = _matchesCamelCase(word, camelCaseWord, i + 1, nextUpperIndex);
153
+ nextUpperIndex++;
154
+ }
155
+ return result === null ? null : join({ start: j, end: j + 1 }, result);
156
+ }
157
+ }
158
+ // Heuristic to avoid computing camel case matcher for words that don't
159
+ // look like camelCaseWords.
160
+ function analyzeCamelCaseWord(word) {
161
+ let upper = 0, lower = 0, alpha = 0, numeric = 0, code = 0;
162
+ for (let i = 0; i < word.length; i++) {
163
+ code = word.charCodeAt(i);
164
+ if (isUpper(code)) {
165
+ upper++;
166
+ }
167
+ if (isLower(code)) {
168
+ lower++;
169
+ }
170
+ if (isAlphanumeric(code)) {
171
+ alpha++;
172
+ }
173
+ if (isNumber(code)) {
174
+ numeric++;
175
+ }
176
+ }
177
+ const upperPercent = upper / word.length;
178
+ const lowerPercent = lower / word.length;
179
+ const alphaPercent = alpha / word.length;
180
+ const numericPercent = numeric / word.length;
181
+ return { upperPercent, lowerPercent, alphaPercent, numericPercent };
182
+ }
183
+ function isUpperCaseWord(analysis) {
184
+ const { upperPercent, lowerPercent } = analysis;
185
+ return lowerPercent === 0 && upperPercent > 0.6;
186
+ }
187
+ function isCamelCaseWord(analysis) {
188
+ const { upperPercent, lowerPercent, alphaPercent, numericPercent } = analysis;
189
+ return lowerPercent > 0.2 && upperPercent < 0.8 && alphaPercent > 0.6 && numericPercent < 0.2;
190
+ }
191
+ // Heuristic to avoid computing camel case matcher for words that don't
192
+ // look like camel case patterns.
193
+ function isCamelCasePattern(word) {
194
+ let upper = 0, lower = 0, code = 0, whitespace = 0;
195
+ for (let i = 0; i < word.length; i++) {
196
+ code = word.charCodeAt(i);
197
+ if (isUpper(code)) {
198
+ upper++;
199
+ }
200
+ if (isLower(code)) {
201
+ lower++;
202
+ }
203
+ if (isWhitespace(code)) {
204
+ whitespace++;
205
+ }
206
+ }
207
+ if ((upper === 0 || lower === 0) && whitespace === 0) {
208
+ return word.length <= 30;
209
+ }
210
+ else {
211
+ return upper <= 5;
212
+ }
213
+ }
214
+ /**
215
+ * Return matches treating "camelCase" words separately. For example the filter string "gp" would return two matches in string "Git Pull".
216
+ * @param word filter string
217
+ * @param wordToMatchAgainst string to test
218
+ * @internal
219
+ */
220
+ export function matchesCamelCase(word, camelCaseWord) {
221
+ if (!camelCaseWord) {
222
+ return null;
223
+ }
224
+ camelCaseWord = camelCaseWord.trim();
225
+ if (camelCaseWord.length === 0) {
226
+ return null;
227
+ }
228
+ if (!isCamelCasePattern(camelCaseWord)) {
229
+ return null;
230
+ }
231
+ if (camelCaseWord.length > 60) {
232
+ return null;
233
+ }
234
+ const analysis = analyzeCamelCaseWord(camelCaseWord);
235
+ if (!isCamelCaseWord(analysis)) {
236
+ // istanbul ignore next
237
+ if (!isUpperCaseWord(analysis)) {
238
+ return null;
239
+ }
240
+ camelCaseWord = camelCaseWord.toLowerCase();
241
+ }
242
+ let result = null;
243
+ let i = 0;
244
+ word = word.toLowerCase();
245
+ while (i < camelCaseWord.length && (result = _matchesCamelCase(word, camelCaseWord, 0, i)) === null) {
246
+ i = nextAnchor(camelCaseWord, i + 1);
247
+ }
248
+ return result;
249
+ }
250
+ /**
251
+ * Matches beginning of words supporting non-ASCII languages.
252
+ * @param word Filter string
253
+ * @param target String being searched
254
+ * @param contiguous - If true the filter string must be found "contiguous" in the searched string (E.g. "pul" will match "Git: Pull").
255
+ * 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").
256
+ * Useful in cases where the target is words (e.g. command labels)
257
+ * @internal
258
+ */
259
+ export function matchesWords(word, target, contiguous = false) {
260
+ if (!target || target.length === 0) {
261
+ return null;
262
+ }
263
+ let result = null;
264
+ let i = 0;
265
+ word = word.toLowerCase();
266
+ target = target.toLowerCase();
267
+ while (i < target.length && (result = _matchesWords(word, target, 0, i, contiguous)) === null) {
268
+ i = nextWord(target, i + 1);
269
+ }
270
+ return result;
271
+ }
272
+ function _matchesWords(word, target, i, j, contiguous) {
273
+ if (i === word.length) {
274
+ return [];
275
+ }
276
+ else if (j === target.length) {
277
+ return null;
278
+ }
279
+ else if (!charactersMatch(word.charCodeAt(i), target.charCodeAt(j))) {
280
+ return null;
281
+ }
282
+ else {
283
+ let result = null;
284
+ let nextWordIndex = j + 1;
285
+ result = _matchesWords(word, target, i + 1, j + 1, contiguous);
286
+ // istanbul ignore else
287
+ if (!contiguous) {
288
+ while (!result && (nextWordIndex = nextWord(target, nextWordIndex)) < target.length) {
289
+ result = _matchesWords(word, target, i + 1, nextWordIndex, contiguous);
290
+ nextWordIndex++;
291
+ }
292
+ }
293
+ return result === null ? null : join({ start: j, end: j + 1 }, result);
294
+ }
295
+ }
296
+ function nextWord(word, start) {
297
+ for (let i = start; i < word.length; i++) {
298
+ if (isWordSeparator(word.charCodeAt(i)) ||
299
+ (i > 0 && isWordSeparator(word.charCodeAt(i - 1)))) {
300
+ return i;
301
+ }
302
+ }
303
+ return word.length;
304
+ }
305
+ // Fuzzy
306
+ const fuzzyContiguousFilter = or(matchesPrefix, matchesCamelCase, matchesContiguousSubString);
307
+ const fuzzySeparateFilter = or(matchesPrefix, matchesCamelCase, matchesSubString);
308
+ const fuzzyRegExpCache = new LRUCache(10000); // bounded to 10000 elements
309
+ /**
310
+ * Match pattern against word in a fuzzy way. This will only return a single match.
311
+ * @internal
312
+ */
313
+ export function matchesFuzzy(word, wordToMatchAgainst, enableSeparateSubstringMatching = false) {
314
+ // istanbul ignore next
315
+ if (typeof word !== "string" || typeof wordToMatchAgainst !== "string") {
316
+ return null; // return early for invalid input
317
+ }
318
+ // Form RegExp for wildcard matches
319
+ let regexp = fuzzyRegExpCache.get(word);
320
+ if (!regexp) {
321
+ regexp = new RegExp(strings.convertSimple2RegExpPattern(word), "i");
322
+ fuzzyRegExpCache.set(word, regexp);
323
+ }
324
+ // RegExp Filter
325
+ const match = regexp.exec(wordToMatchAgainst);
326
+ if (match) {
327
+ return [{ start: match.index, end: match.index + match[0].length }];
328
+ }
329
+ // Default Filter
330
+ return enableSeparateSubstringMatching ? /* istanbul ignore next */ fuzzySeparateFilter(word, wordToMatchAgainst) : fuzzyContiguousFilter(word, wordToMatchAgainst);
331
+ }
332
+ /**
333
+ * Match pattern against word in a fuzzy way. As in IntelliSense and faster and more
334
+ * powerful than `matchesFuzzy`. This will only return a single match.
335
+ * @internal
336
+ */
337
+ export function matchesFuzzy2(pattern, word) {
338
+ const score = fuzzyScore(pattern, pattern.toLowerCase(), 0, word, word.toLowerCase(), 0, true);
339
+ return score ? createMatches(score) : null;
340
+ }
341
+ // #region --- fuzzyScore ---
342
+ /**
343
+ * @internal
344
+ */
345
+ export function createMatches(score) {
346
+ // istanbul ignore next
347
+ if (typeof score === "undefined") {
348
+ return [];
349
+ }
350
+ const matches = score[1].toString(2);
351
+ const wordStart = score[2];
352
+ const res = [];
353
+ for (let pos = wordStart; pos < _maxLen; pos++) {
354
+ if (matches[matches.length - (pos + 1)] === "1") {
355
+ const last = res[res.length - 1];
356
+ if (last && last.end === pos) {
357
+ last.end = pos + 1;
358
+ }
359
+ else {
360
+ res.push({ start: pos, end: pos + 1 });
361
+ }
362
+ }
363
+ }
364
+ return res;
365
+ }
366
+ const _maxLen = 128;
367
+ function initTable() {
368
+ const table = [];
369
+ const row = [0];
370
+ for (let i = 1; i <= _maxLen; i++) {
371
+ row.push(-i);
372
+ }
373
+ for (let i = 0; i <= _maxLen; i++) {
374
+ const thisRow = row.slice(0);
375
+ thisRow[0] = -i;
376
+ table.push(thisRow);
377
+ }
378
+ return table;
379
+ }
380
+ const _table = initTable();
381
+ const _scores = initTable();
382
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
383
+ const _arrows = initTable();
384
+ const _debug = false;
385
+ function isSeparatorAtPos(value, index) {
386
+ if (index < 0 || index >= value.length) {
387
+ return false;
388
+ }
389
+ const code = value.charCodeAt(index);
390
+ switch (code) {
391
+ case 95 /* CharCode.Underline */:
392
+ case 45 /* CharCode.Dash */:
393
+ case 46 /* CharCode.Period */:
394
+ case 32 /* CharCode.Space */:
395
+ case 47 /* CharCode.Slash */:
396
+ case 92 /* CharCode.Backslash */:
397
+ case 39 /* CharCode.SingleQuote */:
398
+ case 34 /* CharCode.DoubleQuote */:
399
+ case 58 /* CharCode.Colon */:
400
+ case 36 /* CharCode.DollarSign */:
401
+ return true;
402
+ default:
403
+ return false;
404
+ }
405
+ }
406
+ function isWhitespaceAtPos(value, index) {
407
+ if (index < 0 || index >= value.length) {
408
+ return false;
409
+ }
410
+ const code = value.charCodeAt(index);
411
+ switch (code) {
412
+ // istanbul ignore next
413
+ case 32 /* CharCode.Space */:
414
+ case 9 /* CharCode.Tab */:
415
+ return true;
416
+ default:
417
+ return false;
418
+ }
419
+ }
420
+ function isUpperCaseAtPos(pos, word, wordLow) {
421
+ return word[pos] !== wordLow[pos];
422
+ }
423
+ /** @internal */
424
+ export function isPatternInWord(patternLow, patternPos, patternLen, wordLow, wordPos, wordLen) {
425
+ while (patternPos < patternLen && wordPos < wordLen) {
426
+ if (patternLow[patternPos] === wordLow[wordPos]) {
427
+ patternPos += 1;
428
+ }
429
+ wordPos += 1;
430
+ }
431
+ return patternPos === patternLen; // pattern must be exhausted
432
+ }
433
+ /** @internal */
434
+ export var FuzzyScore;
435
+ (function (FuzzyScore) {
436
+ /**
437
+ * No matches and value `-100`
438
+ * @internal
439
+ */
440
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
441
+ FuzzyScore.Default = Object.freeze([-100, 0, 0]);
442
+ // istanbul ignore next
443
+ /** @internal */
444
+ function isDefault(score) {
445
+ return !score || (score[0] === -100 && score[1] === 0 && score[2] === 0);
446
+ }
447
+ FuzzyScore.isDefault = isDefault;
448
+ })(FuzzyScore || (FuzzyScore = {}));
449
+ /** @internal */
450
+ export function fuzzyScore(pattern, patternLow, patternStart, word, wordLow, wordStart, firstMatchCanBeWeak) {
451
+ // istanbul ignore next
452
+ const patternLen = pattern.length > _maxLen ? _maxLen : pattern.length;
453
+ const wordLen = word.length > _maxLen ? _maxLen : word.length;
454
+ if (patternStart >= patternLen || wordStart >= wordLen || (patternLen - patternStart) > (wordLen - wordStart)) {
455
+ return undefined;
456
+ }
457
+ // Run a simple check if the characters of pattern occur
458
+ // (in order) at all in word. If that isn't the case we
459
+ // stop because no match will be possible
460
+ if (!isPatternInWord(patternLow, patternStart, patternLen, wordLow, wordStart, wordLen)) {
461
+ return undefined;
462
+ }
463
+ let row = 1;
464
+ let column = 1;
465
+ let patternPos = patternStart;
466
+ let wordPos = wordStart;
467
+ let hasStrongFirstMatch = false;
468
+ // There will be a match, fill in tables
469
+ for (row = 1, patternPos = patternStart; patternPos < patternLen; row++, patternPos++) {
470
+ for (column = 1, wordPos = wordStart; wordPos < wordLen; column++, wordPos++) {
471
+ const score = _doScore(pattern, patternLow, patternPos, patternStart, word, wordLow, wordPos);
472
+ if (patternPos === patternStart && score > 1) {
473
+ hasStrongFirstMatch = true;
474
+ }
475
+ _scores[row][column] = score;
476
+ const diag = _table[row - 1][column - 1] + (score > 1 ? 1 : score);
477
+ const top = _table[row - 1][column] + -1;
478
+ const left = _table[row][column - 1] + -1;
479
+ if (left >= top) {
480
+ // left or diag
481
+ if (left > diag) {
482
+ _table[row][column] = left;
483
+ _arrows[row][column] = 4 /* Arrow.Left */;
484
+ }
485
+ else if (left === diag) {
486
+ _table[row][column] = left;
487
+ _arrows[row][column] = 4 /* Arrow.Left */ | 2 /* Arrow.Diag */;
488
+ }
489
+ else {
490
+ _table[row][column] = diag;
491
+ _arrows[row][column] = 2 /* Arrow.Diag */;
492
+ }
493
+ }
494
+ else {
495
+ // top or diag
496
+ if (top > diag) {
497
+ _table[row][column] = top;
498
+ _arrows[row][column] = 1 /* Arrow.Top */;
499
+ }
500
+ else if (top === diag) {
501
+ _table[row][column] = top;
502
+ _arrows[row][column] = 1 /* Arrow.Top */ | 2 /* Arrow.Diag */;
503
+ }
504
+ else {
505
+ _table[row][column] = diag;
506
+ _arrows[row][column] = 2 /* Arrow.Diag */;
507
+ }
508
+ }
509
+ }
510
+ }
511
+ if (!hasStrongFirstMatch && !firstMatchCanBeWeak) {
512
+ return undefined;
513
+ }
514
+ _matchesCount = 0;
515
+ _topScore = -100;
516
+ _wordStart = wordStart;
517
+ _firstMatchCanBeWeak = firstMatchCanBeWeak;
518
+ _findAllMatches2(row - 1, column - 1, patternLen === wordLen ? 1 : 0, 0, false);
519
+ if (_matchesCount === 0) {
520
+ return undefined;
521
+ }
522
+ return [_topScore, _topMatch2, wordStart];
523
+ }
524
+ function _doScore(pattern, patternLow, patternPos, patternStart, word, wordLow, wordPos) {
525
+ if (patternLow[patternPos] !== wordLow[wordPos]) {
526
+ return -1;
527
+ }
528
+ if (wordPos === (patternPos - patternStart)) {
529
+ // common prefix: `foobar <-> foobaz`
530
+ // ^^^^^
531
+ if (pattern[patternPos] === word[wordPos]) {
532
+ return 7;
533
+ }
534
+ else {
535
+ return 5;
536
+ }
537
+ }
538
+ else if (isUpperCaseAtPos(wordPos, word, wordLow) && (wordPos === 0 || !isUpperCaseAtPos(wordPos - 1, word, wordLow))) {
539
+ // hitting upper-case: `foo <-> forOthers`
540
+ // ^^ ^
541
+ if (pattern[patternPos] === word[wordPos]) {
542
+ return 7;
543
+ }
544
+ else {
545
+ return 5;
546
+ }
547
+ }
548
+ else if (isSeparatorAtPos(wordLow, wordPos) && (wordPos === 0 || !isSeparatorAtPos(wordLow, wordPos - 1))) {
549
+ // hitting a separator: `. <-> foo.bar`
550
+ // ^
551
+ return 5;
552
+ }
553
+ else if (isSeparatorAtPos(wordLow, wordPos - 1) || isWhitespaceAtPos(wordLow, wordPos - 1)) {
554
+ // post separator: `foo <-> bar_foo`
555
+ // ^^^
556
+ return 5;
557
+ }
558
+ else {
559
+ return 1;
560
+ }
561
+ }
562
+ let _matchesCount = 0;
563
+ let _topMatch2 = 0;
564
+ let _topScore = 0;
565
+ let _wordStart = 0;
566
+ let _firstMatchCanBeWeak = false;
567
+ function _findAllMatches2(row, column, total, matches, lastMatched) {
568
+ if (_matchesCount >= 10 || total < -25) {
569
+ // stop when having already 10 results, or
570
+ // when a potential alignment as already 5 gaps
571
+ return;
572
+ }
573
+ let simpleMatchCount = 0;
574
+ while (row > 0 && column > 0) {
575
+ const score = _scores[row][column];
576
+ const arrow = _arrows[row][column];
577
+ if (arrow === 4 /* Arrow.Left */) {
578
+ // left -> no match, skip a word character
579
+ column -= 1;
580
+ if (lastMatched) {
581
+ total -= 5; // new gap penalty
582
+ }
583
+ else if (matches !== 0) {
584
+ total -= 1; // gap penalty after first match
585
+ }
586
+ lastMatched = false;
587
+ simpleMatchCount = 0;
588
+ }
589
+ else {
590
+ /* istanbul ignore else */
591
+ if (arrow & 2 /* Arrow.Diag */) {
592
+ if (arrow & 4 /* Arrow.Left */) {
593
+ // left
594
+ _findAllMatches2(row, column - 1, matches !== 0 ? total - 1 : total, // gap penalty after first match
595
+ matches, lastMatched);
596
+ }
597
+ // diag
598
+ total += score;
599
+ row -= 1;
600
+ column -= 1;
601
+ lastMatched = true;
602
+ // match -> set a 1 at the word pos
603
+ matches += 2 ** (column + _wordStart);
604
+ // count simple matches and boost a row of
605
+ // simple matches when they yield in a
606
+ // strong match.
607
+ if (score === 1) {
608
+ simpleMatchCount += 1;
609
+ if (row === 0 && !_firstMatchCanBeWeak) {
610
+ // when the first match is a weak
611
+ // match we discard it
612
+ return undefined;
613
+ }
614
+ }
615
+ else {
616
+ // boost
617
+ total += 1 + (simpleMatchCount * (score - 1));
618
+ simpleMatchCount = 0;
619
+ }
620
+ }
621
+ else {
622
+ // istanbul ignore next
623
+ return undefined;
624
+ }
625
+ }
626
+ }
627
+ total -= column >= 3 ? 9 : column * 3; // late start penalty
628
+ // dynamically keep track of the current top score
629
+ // and insert the current best score at head, the rest at tail
630
+ _matchesCount += 1;
631
+ if (total > _topScore) {
632
+ _topScore = total;
633
+ _topMatch2 = matches;
634
+ }
635
+ }
636
+ // #endregion
637
+ // #region --- graceful ---
638
+ /** @internal */
639
+ export function fuzzyScoreGracefulAggressive(pattern, lowPattern, patternPos, word, lowWord, wordPos, firstMatchCanBeWeak) {
640
+ return fuzzyScoreWithPermutations(pattern, lowPattern, patternPos, word, lowWord, wordPos, true, firstMatchCanBeWeak);
641
+ }
642
+ /** @internal */
643
+ export function fuzzyScoreGraceful(pattern, lowPattern, patternPos, word, lowWord, wordPos, firstMatchCanBeWeak) {
644
+ return fuzzyScoreWithPermutations(pattern, lowPattern, patternPos, word, lowWord, wordPos, false, firstMatchCanBeWeak);
645
+ }
646
+ function fuzzyScoreWithPermutations(pattern, lowPattern, patternPos, word, lowWord, wordPos, aggressive, firstMatchCanBeWeak) {
647
+ let top = fuzzyScore(pattern, lowPattern, patternPos, word, lowWord, wordPos, firstMatchCanBeWeak);
648
+ if (top && !aggressive) {
649
+ // when using the original pattern yield a result we`
650
+ // return it unless we are aggressive and try to find
651
+ // a better alignment, e.g. `cno` -> `^co^ns^ole` or `^c^o^nsole`.
652
+ return top;
653
+ }
654
+ // istanbul ignore else
655
+ if (pattern.length >= 3) {
656
+ // When the pattern is long enough then try a few (max 7)
657
+ // permutations of the pattern to find a better match. The
658
+ // permutations only swap neighbouring characters, e.g
659
+ // `cnoso` becomes `conso`, `cnsoo`, `cnoos`.
660
+ const tries = Math.min(7, pattern.length - 1);
661
+ for (let movingPatternPos = patternPos + 1; movingPatternPos < tries; movingPatternPos++) {
662
+ const newPattern = nextTypoPermutation(pattern, movingPatternPos);
663
+ // istanbul ignore else
664
+ if (newPattern) {
665
+ const candidate = fuzzyScore(newPattern, newPattern.toLowerCase(), patternPos, word, lowWord, wordPos, firstMatchCanBeWeak);
666
+ if (candidate) {
667
+ candidate[0] -= 3; // permutation penalty
668
+ // istanbul ignore else
669
+ if (!top || candidate[0] > top[0]) {
670
+ top = candidate;
671
+ }
672
+ }
673
+ }
674
+ }
675
+ }
676
+ return top;
677
+ }
678
+ function nextTypoPermutation(pattern, patternPos) {
679
+ // istanbul ignore next
680
+ if (patternPos + 1 >= pattern.length) {
681
+ return undefined;
682
+ }
683
+ const swap1 = pattern[patternPos];
684
+ const swap2 = pattern[patternPos + 1];
685
+ // istanbul ignore next
686
+ if (swap1 === swap2) {
687
+ return undefined;
688
+ }
689
+ return pattern.slice(0, patternPos)
690
+ + swap2
691
+ + swap1
692
+ + pattern.slice(patternPos + 2);
693
+ }
694
+ // #endregion
695
695
  //# sourceMappingURL=filters.js.map