@itwin/appui-abstract 3.6.0-dev.8 → 4.0.0-dev.2

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