@startinblox/core 0.17.20 → 0.17.21-beta.1

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 (256) hide show
  1. package/package.json +2 -2
  2. package/dist/_snowpack/env.js +0 -3
  3. package/dist/_snowpack/pkg/autolinker.js +0 -4281
  4. package/dist/_snowpack/pkg/autolinker.js.map +0 -1
  5. package/dist/_snowpack/pkg/autolinker.js.map.proxy.js +0 -1
  6. package/dist/_snowpack/pkg/common/_baseUnary-217dffb2.js +0 -377
  7. package/dist/_snowpack/pkg/common/_baseUnary-217dffb2.js.map +0 -1
  8. package/dist/_snowpack/pkg/common/_baseUnary-217dffb2.js.map.proxy.js +0 -1
  9. package/dist/_snowpack/pkg/common/_commonjsHelpers-8c19dec8.js +0 -22
  10. package/dist/_snowpack/pkg/common/_commonjsHelpers-8c19dec8.js.map +0 -1
  11. package/dist/_snowpack/pkg/common/_commonjsHelpers-8c19dec8.js.map.proxy.js +0 -1
  12. package/dist/_snowpack/pkg/common/decode-a4c334cf.js +0 -216
  13. package/dist/_snowpack/pkg/common/decode-a4c334cf.js.map +0 -1
  14. package/dist/_snowpack/pkg/common/decode-a4c334cf.js.map.proxy.js +0 -1
  15. package/dist/_snowpack/pkg/common/lit-html-babd44cd.js +0 -1119
  16. package/dist/_snowpack/pkg/common/lit-html-babd44cd.js.map +0 -1
  17. package/dist/_snowpack/pkg/common/lit-html-babd44cd.js.map.proxy.js +0 -1
  18. package/dist/_snowpack/pkg/delta-markdown-for-quill.js +0 -25677
  19. package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map +0 -1
  20. package/dist/_snowpack/pkg/delta-markdown-for-quill.js.map.proxy.js +0 -1
  21. package/dist/_snowpack/pkg/dialog-polyfill.js +0 -859
  22. package/dist/_snowpack/pkg/dialog-polyfill.js.map +0 -1
  23. package/dist/_snowpack/pkg/dialog-polyfill.js.map.proxy.js +0 -1
  24. package/dist/_snowpack/pkg/fusejs.js +0 -1783
  25. package/dist/_snowpack/pkg/fusejs.js.map +0 -1
  26. package/dist/_snowpack/pkg/fusejs.js.map.proxy.js +0 -1
  27. package/dist/_snowpack/pkg/import-map.json +0 -23
  28. package/dist/_snowpack/pkg/jsonld-context-parser.js +0 -804
  29. package/dist/_snowpack/pkg/jsonld-context-parser.js.map +0 -1
  30. package/dist/_snowpack/pkg/jsonld-context-parser.js.map.proxy.js +0 -1
  31. package/dist/_snowpack/pkg/leaflet/dist/leaflet.css +0 -640
  32. package/dist/_snowpack/pkg/leaflet/dist/leaflet.css.proxy.js +0 -10
  33. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css +0 -60
  34. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.Default.css.proxy.js +0 -10
  35. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css +0 -14
  36. package/dist/_snowpack/pkg/leaflet.markercluster/dist/MarkerCluster.css.proxy.js +0 -10
  37. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js +0 -40
  38. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map +0 -1
  39. package/dist/_snowpack/pkg/lit-html/directives/if-defined.js.map.proxy.js +0 -1
  40. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js +0 -46
  41. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map +0 -1
  42. package/dist/_snowpack/pkg/lit-html/directives/unsafe-html.js.map.proxy.js +0 -1
  43. package/dist/_snowpack/pkg/lit-html/directives/until.js +0 -88
  44. package/dist/_snowpack/pkg/lit-html/directives/until.js.map +0 -1
  45. package/dist/_snowpack/pkg/lit-html/directives/until.js.map.proxy.js +0 -1
  46. package/dist/_snowpack/pkg/lit-html.js +0 -92
  47. package/dist/_snowpack/pkg/lit-html.js.map +0 -1
  48. package/dist/_snowpack/pkg/lit-html.js.map.proxy.js +0 -1
  49. package/dist/_snowpack/pkg/markdown-it.js +0 -11860
  50. package/dist/_snowpack/pkg/markdown-it.js.map +0 -1
  51. package/dist/_snowpack/pkg/markdown-it.js.map.proxy.js +0 -1
  52. package/dist/_snowpack/pkg/quill/dist/quill.snow.css +0 -945
  53. package/dist/_snowpack/pkg/quill/dist/quill.snow.css.proxy.js +0 -10
  54. package/dist/_snowpack/pkg/quill-delta-to-markdown.js +0 -1029
  55. package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map +0 -1
  56. package/dist/_snowpack/pkg/quill-delta-to-markdown.js.map.proxy.js +0 -1
  57. package/dist/_snowpack/pkg/quill.js +0 -13382
  58. package/dist/_snowpack/pkg/quill.js.map +0 -1
  59. package/dist/_snowpack/pkg/quill.js.map.proxy.js +0 -1
  60. package/dist/_snowpack/pkg/slim-select.js +0 -4
  61. package/dist/_snowpack/pkg/slim-select.js.map +0 -1
  62. package/dist/_snowpack/pkg/slim-select.js.map.proxy.js +0 -1
  63. package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css +0 -1164
  64. package/dist/_snowpack/pkg/tui-calendar/dist/tui-calendar.css.proxy.js +0 -10
  65. package/dist/_snowpack/pkg/tui-calendar.js +0 -42285
  66. package/dist/_snowpack/pkg/tui-calendar.js.map +0 -1
  67. package/dist/_snowpack/pkg/tui-calendar.js.map.proxy.js +0 -1
  68. package/dist/components/solid-ac-checker.js +0 -58
  69. package/dist/components/solid-ac-checker.js.map +0 -1
  70. package/dist/components/solid-calendar.js +0 -87
  71. package/dist/components/solid-calendar.js.map +0 -1
  72. package/dist/components/solid-delete.js +0 -111
  73. package/dist/components/solid-delete.js.map +0 -1
  74. package/dist/components/solid-display.js +0 -194
  75. package/dist/components/solid-display.js.map +0 -1
  76. package/dist/components/solid-form-search.js +0 -226
  77. package/dist/components/solid-form-search.js.map +0 -1
  78. package/dist/components/solid-form.js +0 -354
  79. package/dist/components/solid-form.js.map +0 -1
  80. package/dist/components/solid-lang.js +0 -46
  81. package/dist/components/solid-lang.js.map +0 -1
  82. package/dist/components/solid-map.js +0 -242
  83. package/dist/components/solid-map.js.map +0 -1
  84. package/dist/components/solid-table.js +0 -263
  85. package/dist/components/solid-table.js.map +0 -1
  86. package/dist/components/solid-widget.js +0 -94
  87. package/dist/components/solid-widget.js.map +0 -1
  88. package/dist/import.css +0 -4
  89. package/dist/index.js +0 -43
  90. package/dist/index.js.map +0 -1
  91. package/dist/libs/Component.js +0 -19
  92. package/dist/libs/Component.js.map +0 -1
  93. package/dist/libs/ComponentFactory.js +0 -196
  94. package/dist/libs/ComponentFactory.js.map +0 -1
  95. package/dist/libs/Compositor.js +0 -103
  96. package/dist/libs/Compositor.js.map +0 -1
  97. package/dist/libs/Sib.js +0 -58
  98. package/dist/libs/Sib.js.map +0 -1
  99. package/dist/libs/helpers.js +0 -219
  100. package/dist/libs/helpers.js.map +0 -1
  101. package/dist/libs/interfaces.js +0 -6
  102. package/dist/libs/interfaces.js.map +0 -1
  103. package/dist/libs/lit-helpers.js +0 -169
  104. package/dist/libs/lit-helpers.js.map +0 -1
  105. package/dist/libs/polyfills.js +0 -40
  106. package/dist/libs/polyfills.js.map +0 -1
  107. package/dist/libs/store/store.js +0 -802
  108. package/dist/libs/store/store.js.map +0 -1
  109. package/dist/locales/en.json +0 -10
  110. package/dist/locales/en.json.proxy.js +0 -2
  111. package/dist/locales/fr.json +0 -10
  112. package/dist/locales/fr.json.proxy.js +0 -2
  113. package/dist/mixins/attributeBinderMixin.js +0 -124
  114. package/dist/mixins/attributeBinderMixin.js.map +0 -1
  115. package/dist/mixins/contextMixin.js +0 -28
  116. package/dist/mixins/contextMixin.js.map +0 -1
  117. package/dist/mixins/counterMixin.js +0 -75
  118. package/dist/mixins/counterMixin.js.map +0 -1
  119. package/dist/mixins/federationMixin.js +0 -63
  120. package/dist/mixins/federationMixin.js.map +0 -1
  121. package/dist/mixins/filterMixin.js +0 -195
  122. package/dist/mixins/filterMixin.js.map +0 -1
  123. package/dist/mixins/grouperMixin.js +0 -80
  124. package/dist/mixins/grouperMixin.js.map +0 -1
  125. package/dist/mixins/highlighterMixin.js +0 -42
  126. package/dist/mixins/highlighterMixin.js.map +0 -1
  127. package/dist/mixins/interfaces.js +0 -8
  128. package/dist/mixins/interfaces.js.map +0 -1
  129. package/dist/mixins/listMixin.js +0 -136
  130. package/dist/mixins/listMixin.js.map +0 -1
  131. package/dist/mixins/nextMixin.js +0 -26
  132. package/dist/mixins/nextMixin.js.map +0 -1
  133. package/dist/mixins/paginateMixin.js +0 -110
  134. package/dist/mixins/paginateMixin.js.map +0 -1
  135. package/dist/mixins/requiredMixin.js +0 -34
  136. package/dist/mixins/requiredMixin.js.map +0 -1
  137. package/dist/mixins/sorterMixin.js +0 -149
  138. package/dist/mixins/sorterMixin.js.map +0 -1
  139. package/dist/mixins/storeMixin.js +0 -102
  140. package/dist/mixins/storeMixin.js.map +0 -1
  141. package/dist/mixins/translationMixin.js +0 -68
  142. package/dist/mixins/translationMixin.js.map +0 -1
  143. package/dist/mixins/validationMixin.js +0 -113
  144. package/dist/mixins/validationMixin.js.map +0 -1
  145. package/dist/mixins/widgetMixin.js +0 -447
  146. package/dist/mixins/widgetMixin.js.map +0 -1
  147. package/dist/new-widgets/attributeMixins/actionMixin.js +0 -14
  148. package/dist/new-widgets/attributeMixins/actionMixin.js.map +0 -1
  149. package/dist/new-widgets/attributeMixins/blankMixin.js +0 -10
  150. package/dist/new-widgets/attributeMixins/blankMixin.js.map +0 -1
  151. package/dist/new-widgets/attributeMixins/booleanMixin.js +0 -10
  152. package/dist/new-widgets/attributeMixins/booleanMixin.js.map +0 -1
  153. package/dist/new-widgets/attributeMixins/index.js +0 -20
  154. package/dist/new-widgets/attributeMixins/index.js.map +0 -1
  155. package/dist/new-widgets/attributeMixins/mailtoMixin.js +0 -10
  156. package/dist/new-widgets/attributeMixins/mailtoMixin.js.map +0 -1
  157. package/dist/new-widgets/attributeMixins/multipleMixin.js +0 -28
  158. package/dist/new-widgets/attributeMixins/multipleMixin.js.map +0 -1
  159. package/dist/new-widgets/attributeMixins/numberMixin.js +0 -10
  160. package/dist/new-widgets/attributeMixins/numberMixin.js.map +0 -1
  161. package/dist/new-widgets/attributeMixins/placeholderMixin.js +0 -19
  162. package/dist/new-widgets/attributeMixins/placeholderMixin.js.map +0 -1
  163. package/dist/new-widgets/attributeMixins/telMixin.js +0 -10
  164. package/dist/new-widgets/attributeMixins/telMixin.js.map +0 -1
  165. package/dist/new-widgets/baseWidgetMixin.js +0 -122
  166. package/dist/new-widgets/baseWidgetMixin.js.map +0 -1
  167. package/dist/new-widgets/callbackMixins/autocompletionMixin.js +0 -104
  168. package/dist/new-widgets/callbackMixins/autocompletionMixin.js.map +0 -1
  169. package/dist/new-widgets/callbackMixins/index.js +0 -8
  170. package/dist/new-widgets/callbackMixins/index.js.map +0 -1
  171. package/dist/new-widgets/callbackMixins/richtextMixin.js +0 -42
  172. package/dist/new-widgets/callbackMixins/richtextMixin.js.map +0 -1
  173. package/dist/new-widgets/callbackMixins/slimselect.css +0 -2
  174. package/dist/new-widgets/callbackMixins/slimselect.css.proxy.js +0 -10
  175. package/dist/new-widgets/new-widget-factory.js +0 -96
  176. package/dist/new-widgets/new-widget-factory.js.map +0 -1
  177. package/dist/new-widgets/templateAdditionMixins/addableMixin.js +0 -41
  178. package/dist/new-widgets/templateAdditionMixins/addableMixin.js.map +0 -1
  179. package/dist/new-widgets/templateAdditionMixins/index.js +0 -14
  180. package/dist/new-widgets/templateAdditionMixins/index.js.map +0 -1
  181. package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js +0 -29
  182. package/dist/new-widgets/templateAdditionMixins/labelLastMixin.js.map +0 -1
  183. package/dist/new-widgets/templateAdditionMixins/labelMixin.js +0 -31
  184. package/dist/new-widgets/templateAdditionMixins/labelMixin.js.map +0 -1
  185. package/dist/new-widgets/templates/defaultTemplatesDirectory.js +0 -35
  186. package/dist/new-widgets/templates/defaultTemplatesDirectory.js.map +0 -1
  187. package/dist/new-widgets/templates/displayTemplatesDirectory.js +0 -89
  188. package/dist/new-widgets/templates/displayTemplatesDirectory.js.map +0 -1
  189. package/dist/new-widgets/templates/formTemplatesDirectory.js +0 -397
  190. package/dist/new-widgets/templates/formTemplatesDirectory.js.map +0 -1
  191. package/dist/new-widgets/templates/groupTemplatesDirectory.js +0 -21
  192. package/dist/new-widgets/templates/groupTemplatesDirectory.js.map +0 -1
  193. package/dist/new-widgets/templates/index.js +0 -7
  194. package/dist/new-widgets/templates/index.js.map +0 -1
  195. package/dist/new-widgets/templates/setTemplatesDirectory.js +0 -49
  196. package/dist/new-widgets/templates/setTemplatesDirectory.js.map +0 -1
  197. package/dist/new-widgets/templatesDependencies/altMixin.js +0 -13
  198. package/dist/new-widgets/templatesDependencies/altMixin.js.map +0 -1
  199. package/dist/new-widgets/templatesDependencies/editableMixin.js +0 -77
  200. package/dist/new-widgets/templatesDependencies/editableMixin.js.map +0 -1
  201. package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js +0 -38
  202. package/dist/new-widgets/templatesDependencies/filterRangeFormMixin.js.map +0 -1
  203. package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js +0 -14
  204. package/dist/new-widgets/templatesDependencies/formCheckboxMixin.js.map +0 -1
  205. package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js +0 -51
  206. package/dist/new-widgets/templatesDependencies/formCheckboxesMixin.js.map +0 -1
  207. package/dist/new-widgets/templatesDependencies/formDropdownMixin.js +0 -66
  208. package/dist/new-widgets/templatesDependencies/formDropdownMixin.js.map +0 -1
  209. package/dist/new-widgets/templatesDependencies/formFileMixin.js +0 -81
  210. package/dist/new-widgets/templatesDependencies/formFileMixin.js.map +0 -1
  211. package/dist/new-widgets/templatesDependencies/formLengthMixin.js +0 -19
  212. package/dist/new-widgets/templatesDependencies/formLengthMixin.js.map +0 -1
  213. package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js +0 -19
  214. package/dist/new-widgets/templatesDependencies/formMinMaxMixin.js.map +0 -1
  215. package/dist/new-widgets/templatesDependencies/formMixin.js +0 -66
  216. package/dist/new-widgets/templatesDependencies/formMixin.js.map +0 -1
  217. package/dist/new-widgets/templatesDependencies/formNumberMixin.js +0 -14
  218. package/dist/new-widgets/templatesDependencies/formNumberMixin.js.map +0 -1
  219. package/dist/new-widgets/templatesDependencies/formRadioMixin.js +0 -16
  220. package/dist/new-widgets/templatesDependencies/formRadioMixin.js.map +0 -1
  221. package/dist/new-widgets/templatesDependencies/formStepMixin.js +0 -13
  222. package/dist/new-widgets/templatesDependencies/formStepMixin.js.map +0 -1
  223. package/dist/new-widgets/templatesDependencies/multipleFormMixin.js +0 -107
  224. package/dist/new-widgets/templatesDependencies/multipleFormMixin.js.map +0 -1
  225. package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js +0 -74
  226. package/dist/new-widgets/templatesDependencies/multipleselectFormMixin.js.map +0 -1
  227. package/dist/new-widgets/templatesDependencies/patternMixin.js +0 -19
  228. package/dist/new-widgets/templatesDependencies/patternMixin.js.map +0 -1
  229. package/dist/new-widgets/templatesDependencies/rangeMixin.js +0 -110
  230. package/dist/new-widgets/templatesDependencies/rangeMixin.js.map +0 -1
  231. package/dist/new-widgets/templatesDependencies/setMixin.js +0 -12
  232. package/dist/new-widgets/templatesDependencies/setMixin.js.map +0 -1
  233. package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js +0 -12
  234. package/dist/new-widgets/templatesDependencies/valueRichtextMixin.js.map +0 -1
  235. package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js +0 -18
  236. package/dist/new-widgets/valueTransformationMixins/autolinkMixin.js.map +0 -1
  237. package/dist/new-widgets/valueTransformationMixins/dateMixin.js +0 -35
  238. package/dist/new-widgets/valueTransformationMixins/dateMixin.js.map +0 -1
  239. package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js +0 -16
  240. package/dist/new-widgets/valueTransformationMixins/dateTimeMixin.js.map +0 -1
  241. package/dist/new-widgets/valueTransformationMixins/index.js +0 -16
  242. package/dist/new-widgets/valueTransformationMixins/index.js.map +0 -1
  243. package/dist/new-widgets/valueTransformationMixins/markdownMixin.js +0 -25
  244. package/dist/new-widgets/valueTransformationMixins/markdownMixin.js.map +0 -1
  245. package/dist/new-widgets/valueTransformationMixins/multilineMixin.js +0 -17
  246. package/dist/new-widgets/valueTransformationMixins/multilineMixin.js.map +0 -1
  247. package/dist/new-widgets/valueTransformationMixins/oembedMixin.js +0 -27
  248. package/dist/new-widgets/valueTransformationMixins/oembedMixin.js.map +0 -1
  249. package/dist/solid-template-element.js +0 -164
  250. package/dist/solid-template-element.js.map +0 -1
  251. package/dist/style/default-theme.css +0 -24
  252. package/dist/style/default-theme.css.proxy.js +0 -10
  253. package/dist/widgets/baseWidget.js +0 -332
  254. package/dist/widgets/baseWidget.js.map +0 -1
  255. package/dist/widgets/widget-factory.js +0 -24
  256. package/dist/widgets/widget-factory.js.map +0 -1
@@ -1,1783 +0,0 @@
1
- /**
2
- * Fuse.js v6.4.6 - Lightweight fuzzy-search (http://fusejs.io)
3
- *
4
- * Copyright (c) 2021 Kiro Risk (http://kiro.me)
5
- * All Rights Reserved. Apache Software License 2.0
6
- *
7
- * http://www.apache.org/licenses/LICENSE-2.0
8
- */
9
-
10
- function isArray(value) {
11
- return !Array.isArray
12
- ? getTag(value) === '[object Array]'
13
- : Array.isArray(value)
14
- }
15
-
16
- // Adapted from: https://github.com/lodash/lodash/blob/master/.internal/baseToString.js
17
- const INFINITY = 1 / 0;
18
- function baseToString(value) {
19
- // Exit early for strings to avoid a performance hit in some environments.
20
- if (typeof value == 'string') {
21
- return value
22
- }
23
- let result = value + '';
24
- return result == '0' && 1 / value == -INFINITY ? '-0' : result
25
- }
26
-
27
- function toString(value) {
28
- return value == null ? '' : baseToString(value)
29
- }
30
-
31
- function isString(value) {
32
- return typeof value === 'string'
33
- }
34
-
35
- function isNumber(value) {
36
- return typeof value === 'number'
37
- }
38
-
39
- // Adapted from: https://github.com/lodash/lodash/blob/master/isBoolean.js
40
- function isBoolean(value) {
41
- return (
42
- value === true ||
43
- value === false ||
44
- (isObjectLike(value) && getTag(value) == '[object Boolean]')
45
- )
46
- }
47
-
48
- function isObject(value) {
49
- return typeof value === 'object'
50
- }
51
-
52
- // Checks if `value` is object-like.
53
- function isObjectLike(value) {
54
- return isObject(value) && value !== null
55
- }
56
-
57
- function isDefined(value) {
58
- return value !== undefined && value !== null
59
- }
60
-
61
- function isBlank(value) {
62
- return !value.trim().length
63
- }
64
-
65
- // Gets the `toStringTag` of `value`.
66
- // Adapted from: https://github.com/lodash/lodash/blob/master/.internal/getTag.js
67
- function getTag(value) {
68
- return value == null
69
- ? value === undefined
70
- ? '[object Undefined]'
71
- : '[object Null]'
72
- : Object.prototype.toString.call(value)
73
- }
74
-
75
- const EXTENDED_SEARCH_UNAVAILABLE = 'Extended search is not available';
76
-
77
- const INCORRECT_INDEX_TYPE = "Incorrect 'index' type";
78
-
79
- const LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY = (key) =>
80
- `Invalid value for key ${key}`;
81
-
82
- const PATTERN_LENGTH_TOO_LARGE = (max) =>
83
- `Pattern length exceeds max of ${max}.`;
84
-
85
- const MISSING_KEY_PROPERTY = (name) => `Missing ${name} property in key`;
86
-
87
- const INVALID_KEY_WEIGHT_VALUE = (key) =>
88
- `Property 'weight' in key '${key}' must be a positive integer`;
89
-
90
- const hasOwn = Object.prototype.hasOwnProperty;
91
-
92
- class KeyStore {
93
- constructor(keys) {
94
- this._keys = [];
95
- this._keyMap = {};
96
-
97
- let totalWeight = 0;
98
-
99
- keys.forEach((key) => {
100
- let obj = createKey(key);
101
-
102
- totalWeight += obj.weight;
103
-
104
- this._keys.push(obj);
105
- this._keyMap[obj.id] = obj;
106
-
107
- totalWeight += obj.weight;
108
- });
109
-
110
- // Normalize weights so that their sum is equal to 1
111
- this._keys.forEach((key) => {
112
- key.weight /= totalWeight;
113
- });
114
- }
115
- get(keyId) {
116
- return this._keyMap[keyId]
117
- }
118
- keys() {
119
- return this._keys
120
- }
121
- toJSON() {
122
- return JSON.stringify(this._keys)
123
- }
124
- }
125
-
126
- function createKey(key) {
127
- let path = null;
128
- let id = null;
129
- let src = null;
130
- let weight = 1;
131
-
132
- if (isString(key) || isArray(key)) {
133
- src = key;
134
- path = createKeyPath(key);
135
- id = createKeyId(key);
136
- } else {
137
- if (!hasOwn.call(key, 'name')) {
138
- throw new Error(MISSING_KEY_PROPERTY('name'))
139
- }
140
-
141
- const name = key.name;
142
- src = name;
143
-
144
- if (hasOwn.call(key, 'weight')) {
145
- weight = key.weight;
146
-
147
- if (weight <= 0) {
148
- throw new Error(INVALID_KEY_WEIGHT_VALUE(name))
149
- }
150
- }
151
-
152
- path = createKeyPath(name);
153
- id = createKeyId(name);
154
- }
155
-
156
- return { path, id, weight, src }
157
- }
158
-
159
- function createKeyPath(key) {
160
- return isArray(key) ? key : key.split('.')
161
- }
162
-
163
- function createKeyId(key) {
164
- return isArray(key) ? key.join('.') : key
165
- }
166
-
167
- function get(obj, path) {
168
- let list = [];
169
- let arr = false;
170
-
171
- const deepGet = (obj, path, index) => {
172
- if (!isDefined(obj)) {
173
- return
174
- }
175
- if (!path[index]) {
176
- // If there's no path left, we've arrived at the object we care about.
177
- list.push(obj);
178
- } else {
179
- let key = path[index];
180
-
181
- const value = obj[key];
182
-
183
- if (!isDefined(value)) {
184
- return
185
- }
186
-
187
- // If we're at the last value in the path, and if it's a string/number/bool,
188
- // add it to the list
189
- if (
190
- index === path.length - 1 &&
191
- (isString(value) || isNumber(value) || isBoolean(value))
192
- ) {
193
- list.push(toString(value));
194
- } else if (isArray(value)) {
195
- arr = true;
196
- // Search each item in the array.
197
- for (let i = 0, len = value.length; i < len; i += 1) {
198
- deepGet(value[i], path, index + 1);
199
- }
200
- } else if (path.length) {
201
- // An object. Recurse further.
202
- deepGet(value, path, index + 1);
203
- }
204
- }
205
- };
206
-
207
- // Backwards compatibility (since path used to be a string)
208
- deepGet(obj, isString(path) ? path.split('.') : path, 0);
209
-
210
- return arr ? list : list[0]
211
- }
212
-
213
- const MatchOptions = {
214
- // Whether the matches should be included in the result set. When `true`, each record in the result
215
- // set will include the indices of the matched characters.
216
- // These can consequently be used for highlighting purposes.
217
- includeMatches: false,
218
- // When `true`, the matching function will continue to the end of a search pattern even if
219
- // a perfect match has already been located in the string.
220
- findAllMatches: false,
221
- // Minimum number of characters that must be matched before a result is considered a match
222
- minMatchCharLength: 1
223
- };
224
-
225
- const BasicOptions = {
226
- // When `true`, the algorithm continues searching to the end of the input even if a perfect
227
- // match is found before the end of the same input.
228
- isCaseSensitive: false,
229
- // When true, the matching function will continue to the end of a search pattern even if
230
- includeScore: false,
231
- // List of properties that will be searched. This also supports nested properties.
232
- keys: [],
233
- // Whether to sort the result list, by score
234
- shouldSort: true,
235
- // Default sort function: sort by ascending score, ascending index
236
- sortFn: (a, b) =>
237
- a.score === b.score ? (a.idx < b.idx ? -1 : 1) : a.score < b.score ? -1 : 1
238
- };
239
-
240
- const FuzzyOptions = {
241
- // Approximately where in the text is the pattern expected to be found?
242
- location: 0,
243
- // At what point does the match algorithm give up. A threshold of '0.0' requires a perfect match
244
- // (of both letters and location), a threshold of '1.0' would match anything.
245
- threshold: 0.6,
246
- // Determines how close the match must be to the fuzzy location (specified above).
247
- // An exact letter match which is 'distance' characters away from the fuzzy location
248
- // would score as a complete mismatch. A distance of '0' requires the match be at
249
- // the exact location specified, a threshold of '1000' would require a perfect match
250
- // to be within 800 characters of the fuzzy location to be found using a 0.8 threshold.
251
- distance: 100
252
- };
253
-
254
- const AdvancedOptions = {
255
- // When `true`, it enables the use of unix-like search commands
256
- useExtendedSearch: false,
257
- // The get function to use when fetching an object's properties.
258
- // The default will search nested paths *ie foo.bar.baz*
259
- getFn: get,
260
- // When `true`, search will ignore `location` and `distance`, so it won't matter
261
- // where in the string the pattern appears.
262
- // More info: https://fusejs.io/concepts/scoring-theory.html#fuzziness-score
263
- ignoreLocation: false,
264
- // When `true`, the calculation for the relevance score (used for sorting) will
265
- // ignore the field-length norm.
266
- // More info: https://fusejs.io/concepts/scoring-theory.html#field-length-norm
267
- ignoreFieldNorm: false
268
- };
269
-
270
- var Config = {
271
- ...BasicOptions,
272
- ...MatchOptions,
273
- ...FuzzyOptions,
274
- ...AdvancedOptions
275
- };
276
-
277
- const SPACE = /[^ ]+/g;
278
-
279
- // Field-length norm: the shorter the field, the higher the weight.
280
- // Set to 3 decimals to reduce index size.
281
- function norm(mantissa = 3) {
282
- const cache = new Map();
283
- const m = Math.pow(10, mantissa);
284
-
285
- return {
286
- get(value) {
287
- const numTokens = value.match(SPACE).length;
288
-
289
- if (cache.has(numTokens)) {
290
- return cache.get(numTokens)
291
- }
292
-
293
- const norm = 1 / Math.sqrt(numTokens);
294
-
295
- // In place of `toFixed(mantissa)`, for faster computation
296
- const n = parseFloat(Math.round(norm * m) / m);
297
-
298
- cache.set(numTokens, n);
299
-
300
- return n
301
- },
302
- clear() {
303
- cache.clear();
304
- }
305
- }
306
- }
307
-
308
- class FuseIndex {
309
- constructor({ getFn = Config.getFn } = {}) {
310
- this.norm = norm(3);
311
- this.getFn = getFn;
312
- this.isCreated = false;
313
-
314
- this.setIndexRecords();
315
- }
316
- setSources(docs = []) {
317
- this.docs = docs;
318
- }
319
- setIndexRecords(records = []) {
320
- this.records = records;
321
- }
322
- setKeys(keys = []) {
323
- this.keys = keys;
324
- this._keysMap = {};
325
- keys.forEach((key, idx) => {
326
- this._keysMap[key.id] = idx;
327
- });
328
- }
329
- create() {
330
- if (this.isCreated || !this.docs.length) {
331
- return
332
- }
333
-
334
- this.isCreated = true;
335
-
336
- // List is Array<String>
337
- if (isString(this.docs[0])) {
338
- this.docs.forEach((doc, docIndex) => {
339
- this._addString(doc, docIndex);
340
- });
341
- } else {
342
- // List is Array<Object>
343
- this.docs.forEach((doc, docIndex) => {
344
- this._addObject(doc, docIndex);
345
- });
346
- }
347
-
348
- this.norm.clear();
349
- }
350
- // Adds a doc to the end of the index
351
- add(doc) {
352
- const idx = this.size();
353
-
354
- if (isString(doc)) {
355
- this._addString(doc, idx);
356
- } else {
357
- this._addObject(doc, idx);
358
- }
359
- }
360
- // Removes the doc at the specified index of the index
361
- removeAt(idx) {
362
- this.records.splice(idx, 1);
363
-
364
- // Change ref index of every subsquent doc
365
- for (let i = idx, len = this.size(); i < len; i += 1) {
366
- this.records[i].i -= 1;
367
- }
368
- }
369
- getValueForItemAtKeyId(item, keyId) {
370
- return item[this._keysMap[keyId]]
371
- }
372
- size() {
373
- return this.records.length
374
- }
375
- _addString(doc, docIndex) {
376
- if (!isDefined(doc) || isBlank(doc)) {
377
- return
378
- }
379
-
380
- let record = {
381
- v: doc,
382
- i: docIndex,
383
- n: this.norm.get(doc)
384
- };
385
-
386
- this.records.push(record);
387
- }
388
- _addObject(doc, docIndex) {
389
- let record = { i: docIndex, $: {} };
390
-
391
- // Iterate over every key (i.e, path), and fetch the value at that key
392
- this.keys.forEach((key, keyIndex) => {
393
- // console.log(key)
394
- let value = this.getFn(doc, key.path);
395
-
396
- if (!isDefined(value)) {
397
- return
398
- }
399
-
400
- if (isArray(value)) {
401
- let subRecords = [];
402
- const stack = [{ nestedArrIndex: -1, value }];
403
-
404
- while (stack.length) {
405
- const { nestedArrIndex, value } = stack.pop();
406
-
407
- if (!isDefined(value)) {
408
- continue
409
- }
410
-
411
- if (isString(value) && !isBlank(value)) {
412
- let subRecord = {
413
- v: value,
414
- i: nestedArrIndex,
415
- n: this.norm.get(value)
416
- };
417
-
418
- subRecords.push(subRecord);
419
- } else if (isArray(value)) {
420
- value.forEach((item, k) => {
421
- stack.push({
422
- nestedArrIndex: k,
423
- value: item
424
- });
425
- });
426
- }
427
- }
428
- record.$[keyIndex] = subRecords;
429
- } else if (!isBlank(value)) {
430
- let subRecord = {
431
- v: value,
432
- n: this.norm.get(value)
433
- };
434
-
435
- record.$[keyIndex] = subRecord;
436
- }
437
- });
438
-
439
- this.records.push(record);
440
- }
441
- toJSON() {
442
- return {
443
- keys: this.keys,
444
- records: this.records
445
- }
446
- }
447
- }
448
-
449
- function createIndex(keys, docs, { getFn = Config.getFn } = {}) {
450
- const myIndex = new FuseIndex({ getFn });
451
- myIndex.setKeys(keys.map(createKey));
452
- myIndex.setSources(docs);
453
- myIndex.create();
454
- return myIndex
455
- }
456
-
457
- function parseIndex(data, { getFn = Config.getFn } = {}) {
458
- const { keys, records } = data;
459
- const myIndex = new FuseIndex({ getFn });
460
- myIndex.setKeys(keys);
461
- myIndex.setIndexRecords(records);
462
- return myIndex
463
- }
464
-
465
- function computeScore(
466
- pattern,
467
- {
468
- errors = 0,
469
- currentLocation = 0,
470
- expectedLocation = 0,
471
- distance = Config.distance,
472
- ignoreLocation = Config.ignoreLocation
473
- } = {}
474
- ) {
475
- const accuracy = errors / pattern.length;
476
-
477
- if (ignoreLocation) {
478
- return accuracy
479
- }
480
-
481
- const proximity = Math.abs(expectedLocation - currentLocation);
482
-
483
- if (!distance) {
484
- // Dodge divide by zero error.
485
- return proximity ? 1.0 : accuracy
486
- }
487
-
488
- return accuracy + proximity / distance
489
- }
490
-
491
- function convertMaskToIndices(
492
- matchmask = [],
493
- minMatchCharLength = Config.minMatchCharLength
494
- ) {
495
- let indices = [];
496
- let start = -1;
497
- let end = -1;
498
- let i = 0;
499
-
500
- for (let len = matchmask.length; i < len; i += 1) {
501
- let match = matchmask[i];
502
- if (match && start === -1) {
503
- start = i;
504
- } else if (!match && start !== -1) {
505
- end = i - 1;
506
- if (end - start + 1 >= minMatchCharLength) {
507
- indices.push([start, end]);
508
- }
509
- start = -1;
510
- }
511
- }
512
-
513
- // (i-1 - start) + 1 => i - start
514
- if (matchmask[i - 1] && i - start >= minMatchCharLength) {
515
- indices.push([start, i - 1]);
516
- }
517
-
518
- return indices
519
- }
520
-
521
- // Machine word size
522
- const MAX_BITS = 32;
523
-
524
- function search(
525
- text,
526
- pattern,
527
- patternAlphabet,
528
- {
529
- location = Config.location,
530
- distance = Config.distance,
531
- threshold = Config.threshold,
532
- findAllMatches = Config.findAllMatches,
533
- minMatchCharLength = Config.minMatchCharLength,
534
- includeMatches = Config.includeMatches,
535
- ignoreLocation = Config.ignoreLocation
536
- } = {}
537
- ) {
538
- if (pattern.length > MAX_BITS) {
539
- throw new Error(PATTERN_LENGTH_TOO_LARGE(MAX_BITS))
540
- }
541
-
542
- const patternLen = pattern.length;
543
- // Set starting location at beginning text and initialize the alphabet.
544
- const textLen = text.length;
545
- // Handle the case when location > text.length
546
- const expectedLocation = Math.max(0, Math.min(location, textLen));
547
- // Highest score beyond which we give up.
548
- let currentThreshold = threshold;
549
- // Is there a nearby exact match? (speedup)
550
- let bestLocation = expectedLocation;
551
-
552
- // Performance: only computer matches when the minMatchCharLength > 1
553
- // OR if `includeMatches` is true.
554
- const computeMatches = minMatchCharLength > 1 || includeMatches;
555
- // A mask of the matches, used for building the indices
556
- const matchMask = computeMatches ? Array(textLen) : [];
557
-
558
- let index;
559
-
560
- // Get all exact matches, here for speed up
561
- while ((index = text.indexOf(pattern, bestLocation)) > -1) {
562
- let score = computeScore(pattern, {
563
- currentLocation: index,
564
- expectedLocation,
565
- distance,
566
- ignoreLocation
567
- });
568
-
569
- currentThreshold = Math.min(score, currentThreshold);
570
- bestLocation = index + patternLen;
571
-
572
- if (computeMatches) {
573
- let i = 0;
574
- while (i < patternLen) {
575
- matchMask[index + i] = 1;
576
- i += 1;
577
- }
578
- }
579
- }
580
-
581
- // Reset the best location
582
- bestLocation = -1;
583
-
584
- let lastBitArr = [];
585
- let finalScore = 1;
586
- let binMax = patternLen + textLen;
587
-
588
- const mask = 1 << (patternLen - 1);
589
-
590
- for (let i = 0; i < patternLen; i += 1) {
591
- // Scan for the best match; each iteration allows for one more error.
592
- // Run a binary search to determine how far from the match location we can stray
593
- // at this error level.
594
- let binMin = 0;
595
- let binMid = binMax;
596
-
597
- while (binMin < binMid) {
598
- const score = computeScore(pattern, {
599
- errors: i,
600
- currentLocation: expectedLocation + binMid,
601
- expectedLocation,
602
- distance,
603
- ignoreLocation
604
- });
605
-
606
- if (score <= currentThreshold) {
607
- binMin = binMid;
608
- } else {
609
- binMax = binMid;
610
- }
611
-
612
- binMid = Math.floor((binMax - binMin) / 2 + binMin);
613
- }
614
-
615
- // Use the result from this iteration as the maximum for the next.
616
- binMax = binMid;
617
-
618
- let start = Math.max(1, expectedLocation - binMid + 1);
619
- let finish = findAllMatches
620
- ? textLen
621
- : Math.min(expectedLocation + binMid, textLen) + patternLen;
622
-
623
- // Initialize the bit array
624
- let bitArr = Array(finish + 2);
625
-
626
- bitArr[finish + 1] = (1 << i) - 1;
627
-
628
- for (let j = finish; j >= start; j -= 1) {
629
- let currentLocation = j - 1;
630
- let charMatch = patternAlphabet[text.charAt(currentLocation)];
631
-
632
- if (computeMatches) {
633
- // Speed up: quick bool to int conversion (i.e, `charMatch ? 1 : 0`)
634
- matchMask[currentLocation] = +!!charMatch;
635
- }
636
-
637
- // First pass: exact match
638
- bitArr[j] = ((bitArr[j + 1] << 1) | 1) & charMatch;
639
-
640
- // Subsequent passes: fuzzy match
641
- if (i) {
642
- bitArr[j] |=
643
- ((lastBitArr[j + 1] | lastBitArr[j]) << 1) | 1 | lastBitArr[j + 1];
644
- }
645
-
646
- if (bitArr[j] & mask) {
647
- finalScore = computeScore(pattern, {
648
- errors: i,
649
- currentLocation,
650
- expectedLocation,
651
- distance,
652
- ignoreLocation
653
- });
654
-
655
- // This match will almost certainly be better than any existing match.
656
- // But check anyway.
657
- if (finalScore <= currentThreshold) {
658
- // Indeed it is
659
- currentThreshold = finalScore;
660
- bestLocation = currentLocation;
661
-
662
- // Already passed `loc`, downhill from here on in.
663
- if (bestLocation <= expectedLocation) {
664
- break
665
- }
666
-
667
- // When passing `bestLocation`, don't exceed our current distance from `expectedLocation`.
668
- start = Math.max(1, 2 * expectedLocation - bestLocation);
669
- }
670
- }
671
- }
672
-
673
- // No hope for a (better) match at greater error levels.
674
- const score = computeScore(pattern, {
675
- errors: i + 1,
676
- currentLocation: expectedLocation,
677
- expectedLocation,
678
- distance,
679
- ignoreLocation
680
- });
681
-
682
- if (score > currentThreshold) {
683
- break
684
- }
685
-
686
- lastBitArr = bitArr;
687
- }
688
-
689
- const result = {
690
- isMatch: bestLocation >= 0,
691
- // Count exact matches (those with a score of 0) to be "almost" exact
692
- score: Math.max(0.001, finalScore)
693
- };
694
-
695
- if (computeMatches) {
696
- const indices = convertMaskToIndices(matchMask, minMatchCharLength);
697
- if (!indices.length) {
698
- result.isMatch = false;
699
- } else if (includeMatches) {
700
- result.indices = indices;
701
- }
702
- }
703
-
704
- return result
705
- }
706
-
707
- function createPatternAlphabet(pattern) {
708
- let mask = {};
709
-
710
- for (let i = 0, len = pattern.length; i < len; i += 1) {
711
- const char = pattern.charAt(i);
712
- mask[char] = (mask[char] || 0) | (1 << (len - i - 1));
713
- }
714
-
715
- return mask
716
- }
717
-
718
- class BitapSearch {
719
- constructor(
720
- pattern,
721
- {
722
- location = Config.location,
723
- threshold = Config.threshold,
724
- distance = Config.distance,
725
- includeMatches = Config.includeMatches,
726
- findAllMatches = Config.findAllMatches,
727
- minMatchCharLength = Config.minMatchCharLength,
728
- isCaseSensitive = Config.isCaseSensitive,
729
- ignoreLocation = Config.ignoreLocation
730
- } = {}
731
- ) {
732
- this.options = {
733
- location,
734
- threshold,
735
- distance,
736
- includeMatches,
737
- findAllMatches,
738
- minMatchCharLength,
739
- isCaseSensitive,
740
- ignoreLocation
741
- };
742
-
743
- this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
744
-
745
- this.chunks = [];
746
-
747
- if (!this.pattern.length) {
748
- return
749
- }
750
-
751
- const addChunk = (pattern, startIndex) => {
752
- this.chunks.push({
753
- pattern,
754
- alphabet: createPatternAlphabet(pattern),
755
- startIndex
756
- });
757
- };
758
-
759
- const len = this.pattern.length;
760
-
761
- if (len > MAX_BITS) {
762
- let i = 0;
763
- const remainder = len % MAX_BITS;
764
- const end = len - remainder;
765
-
766
- while (i < end) {
767
- addChunk(this.pattern.substr(i, MAX_BITS), i);
768
- i += MAX_BITS;
769
- }
770
-
771
- if (remainder) {
772
- const startIndex = len - MAX_BITS;
773
- addChunk(this.pattern.substr(startIndex), startIndex);
774
- }
775
- } else {
776
- addChunk(this.pattern, 0);
777
- }
778
- }
779
-
780
- searchIn(text) {
781
- const { isCaseSensitive, includeMatches } = this.options;
782
-
783
- if (!isCaseSensitive) {
784
- text = text.toLowerCase();
785
- }
786
-
787
- // Exact match
788
- if (this.pattern === text) {
789
- let result = {
790
- isMatch: true,
791
- score: 0
792
- };
793
-
794
- if (includeMatches) {
795
- result.indices = [[0, text.length - 1]];
796
- }
797
-
798
- return result
799
- }
800
-
801
- // Otherwise, use Bitap algorithm
802
- const {
803
- location,
804
- distance,
805
- threshold,
806
- findAllMatches,
807
- minMatchCharLength,
808
- ignoreLocation
809
- } = this.options;
810
-
811
- let allIndices = [];
812
- let totalScore = 0;
813
- let hasMatches = false;
814
-
815
- this.chunks.forEach(({ pattern, alphabet, startIndex }) => {
816
- const { isMatch, score, indices } = search(text, pattern, alphabet, {
817
- location: location + startIndex,
818
- distance,
819
- threshold,
820
- findAllMatches,
821
- minMatchCharLength,
822
- includeMatches,
823
- ignoreLocation
824
- });
825
-
826
- if (isMatch) {
827
- hasMatches = true;
828
- }
829
-
830
- totalScore += score;
831
-
832
- if (isMatch && indices) {
833
- allIndices = [...allIndices, ...indices];
834
- }
835
- });
836
-
837
- let result = {
838
- isMatch: hasMatches,
839
- score: hasMatches ? totalScore / this.chunks.length : 1
840
- };
841
-
842
- if (hasMatches && includeMatches) {
843
- result.indices = allIndices;
844
- }
845
-
846
- return result
847
- }
848
- }
849
-
850
- class BaseMatch {
851
- constructor(pattern) {
852
- this.pattern = pattern;
853
- }
854
- static isMultiMatch(pattern) {
855
- return getMatch(pattern, this.multiRegex)
856
- }
857
- static isSingleMatch(pattern) {
858
- return getMatch(pattern, this.singleRegex)
859
- }
860
- search(/*text*/) {}
861
- }
862
-
863
- function getMatch(pattern, exp) {
864
- const matches = pattern.match(exp);
865
- return matches ? matches[1] : null
866
- }
867
-
868
- // Token: 'file
869
-
870
- class ExactMatch extends BaseMatch {
871
- constructor(pattern) {
872
- super(pattern);
873
- }
874
- static get type() {
875
- return 'exact'
876
- }
877
- static get multiRegex() {
878
- return /^="(.*)"$/
879
- }
880
- static get singleRegex() {
881
- return /^=(.*)$/
882
- }
883
- search(text) {
884
- const isMatch = text === this.pattern;
885
-
886
- return {
887
- isMatch,
888
- score: isMatch ? 0 : 1,
889
- indices: [0, this.pattern.length - 1]
890
- }
891
- }
892
- }
893
-
894
- // Token: !fire
895
-
896
- class InverseExactMatch extends BaseMatch {
897
- constructor(pattern) {
898
- super(pattern);
899
- }
900
- static get type() {
901
- return 'inverse-exact'
902
- }
903
- static get multiRegex() {
904
- return /^!"(.*)"$/
905
- }
906
- static get singleRegex() {
907
- return /^!(.*)$/
908
- }
909
- search(text) {
910
- const index = text.indexOf(this.pattern);
911
- const isMatch = index === -1;
912
-
913
- return {
914
- isMatch,
915
- score: isMatch ? 0 : 1,
916
- indices: [0, text.length - 1]
917
- }
918
- }
919
- }
920
-
921
- // Token: ^file
922
-
923
- class PrefixExactMatch extends BaseMatch {
924
- constructor(pattern) {
925
- super(pattern);
926
- }
927
- static get type() {
928
- return 'prefix-exact'
929
- }
930
- static get multiRegex() {
931
- return /^\^"(.*)"$/
932
- }
933
- static get singleRegex() {
934
- return /^\^(.*)$/
935
- }
936
- search(text) {
937
- const isMatch = text.startsWith(this.pattern);
938
-
939
- return {
940
- isMatch,
941
- score: isMatch ? 0 : 1,
942
- indices: [0, this.pattern.length - 1]
943
- }
944
- }
945
- }
946
-
947
- // Token: !^fire
948
-
949
- class InversePrefixExactMatch extends BaseMatch {
950
- constructor(pattern) {
951
- super(pattern);
952
- }
953
- static get type() {
954
- return 'inverse-prefix-exact'
955
- }
956
- static get multiRegex() {
957
- return /^!\^"(.*)"$/
958
- }
959
- static get singleRegex() {
960
- return /^!\^(.*)$/
961
- }
962
- search(text) {
963
- const isMatch = !text.startsWith(this.pattern);
964
-
965
- return {
966
- isMatch,
967
- score: isMatch ? 0 : 1,
968
- indices: [0, text.length - 1]
969
- }
970
- }
971
- }
972
-
973
- // Token: .file$
974
-
975
- class SuffixExactMatch extends BaseMatch {
976
- constructor(pattern) {
977
- super(pattern);
978
- }
979
- static get type() {
980
- return 'suffix-exact'
981
- }
982
- static get multiRegex() {
983
- return /^"(.*)"\$$/
984
- }
985
- static get singleRegex() {
986
- return /^(.*)\$$/
987
- }
988
- search(text) {
989
- const isMatch = text.endsWith(this.pattern);
990
-
991
- return {
992
- isMatch,
993
- score: isMatch ? 0 : 1,
994
- indices: [text.length - this.pattern.length, text.length - 1]
995
- }
996
- }
997
- }
998
-
999
- // Token: !.file$
1000
-
1001
- class InverseSuffixExactMatch extends BaseMatch {
1002
- constructor(pattern) {
1003
- super(pattern);
1004
- }
1005
- static get type() {
1006
- return 'inverse-suffix-exact'
1007
- }
1008
- static get multiRegex() {
1009
- return /^!"(.*)"\$$/
1010
- }
1011
- static get singleRegex() {
1012
- return /^!(.*)\$$/
1013
- }
1014
- search(text) {
1015
- const isMatch = !text.endsWith(this.pattern);
1016
- return {
1017
- isMatch,
1018
- score: isMatch ? 0 : 1,
1019
- indices: [0, text.length - 1]
1020
- }
1021
- }
1022
- }
1023
-
1024
- class FuzzyMatch extends BaseMatch {
1025
- constructor(
1026
- pattern,
1027
- {
1028
- location = Config.location,
1029
- threshold = Config.threshold,
1030
- distance = Config.distance,
1031
- includeMatches = Config.includeMatches,
1032
- findAllMatches = Config.findAllMatches,
1033
- minMatchCharLength = Config.minMatchCharLength,
1034
- isCaseSensitive = Config.isCaseSensitive,
1035
- ignoreLocation = Config.ignoreLocation
1036
- } = {}
1037
- ) {
1038
- super(pattern);
1039
- this._bitapSearch = new BitapSearch(pattern, {
1040
- location,
1041
- threshold,
1042
- distance,
1043
- includeMatches,
1044
- findAllMatches,
1045
- minMatchCharLength,
1046
- isCaseSensitive,
1047
- ignoreLocation
1048
- });
1049
- }
1050
- static get type() {
1051
- return 'fuzzy'
1052
- }
1053
- static get multiRegex() {
1054
- return /^"(.*)"$/
1055
- }
1056
- static get singleRegex() {
1057
- return /^(.*)$/
1058
- }
1059
- search(text) {
1060
- return this._bitapSearch.searchIn(text)
1061
- }
1062
- }
1063
-
1064
- // Token: 'file
1065
-
1066
- class IncludeMatch extends BaseMatch {
1067
- constructor(pattern) {
1068
- super(pattern);
1069
- }
1070
- static get type() {
1071
- return 'include'
1072
- }
1073
- static get multiRegex() {
1074
- return /^'"(.*)"$/
1075
- }
1076
- static get singleRegex() {
1077
- return /^'(.*)$/
1078
- }
1079
- search(text) {
1080
- let location = 0;
1081
- let index;
1082
-
1083
- const indices = [];
1084
- const patternLen = this.pattern.length;
1085
-
1086
- // Get all exact matches
1087
- while ((index = text.indexOf(this.pattern, location)) > -1) {
1088
- location = index + patternLen;
1089
- indices.push([index, location - 1]);
1090
- }
1091
-
1092
- const isMatch = !!indices.length;
1093
-
1094
- return {
1095
- isMatch,
1096
- score: isMatch ? 0 : 1,
1097
- indices
1098
- }
1099
- }
1100
- }
1101
-
1102
- // ❗Order is important. DO NOT CHANGE.
1103
- const searchers = [
1104
- ExactMatch,
1105
- IncludeMatch,
1106
- PrefixExactMatch,
1107
- InversePrefixExactMatch,
1108
- InverseSuffixExactMatch,
1109
- SuffixExactMatch,
1110
- InverseExactMatch,
1111
- FuzzyMatch
1112
- ];
1113
-
1114
- const searchersLen = searchers.length;
1115
-
1116
- // Regex to split by spaces, but keep anything in quotes together
1117
- const SPACE_RE = / +(?=([^\"]*\"[^\"]*\")*[^\"]*$)/;
1118
- const OR_TOKEN = '|';
1119
-
1120
- // Return a 2D array representation of the query, for simpler parsing.
1121
- // Example:
1122
- // "^core go$ | rb$ | py$ xy$" => [["^core", "go$"], ["rb$"], ["py$", "xy$"]]
1123
- function parseQuery(pattern, options = {}) {
1124
- return pattern.split(OR_TOKEN).map((item) => {
1125
- let query = item
1126
- .trim()
1127
- .split(SPACE_RE)
1128
- .filter((item) => item && !!item.trim());
1129
-
1130
- let results = [];
1131
- for (let i = 0, len = query.length; i < len; i += 1) {
1132
- const queryItem = query[i];
1133
-
1134
- // 1. Handle multiple query match (i.e, once that are quoted, like `"hello world"`)
1135
- let found = false;
1136
- let idx = -1;
1137
- while (!found && ++idx < searchersLen) {
1138
- const searcher = searchers[idx];
1139
- let token = searcher.isMultiMatch(queryItem);
1140
- if (token) {
1141
- results.push(new searcher(token, options));
1142
- found = true;
1143
- }
1144
- }
1145
-
1146
- if (found) {
1147
- continue
1148
- }
1149
-
1150
- // 2. Handle single query matches (i.e, once that are *not* quoted)
1151
- idx = -1;
1152
- while (++idx < searchersLen) {
1153
- const searcher = searchers[idx];
1154
- let token = searcher.isSingleMatch(queryItem);
1155
- if (token) {
1156
- results.push(new searcher(token, options));
1157
- break
1158
- }
1159
- }
1160
- }
1161
-
1162
- return results
1163
- })
1164
- }
1165
-
1166
- // These extended matchers can return an array of matches, as opposed
1167
- // to a singl match
1168
- const MultiMatchSet = new Set([FuzzyMatch.type, IncludeMatch.type]);
1169
-
1170
- /**
1171
- * Command-like searching
1172
- * ======================
1173
- *
1174
- * Given multiple search terms delimited by spaces.e.g. `^jscript .python$ ruby !java`,
1175
- * search in a given text.
1176
- *
1177
- * Search syntax:
1178
- *
1179
- * | Token | Match type | Description |
1180
- * | ----------- | -------------------------- | -------------------------------------- |
1181
- * | `jscript` | fuzzy-match | Items that fuzzy match `jscript` |
1182
- * | `=scheme` | exact-match | Items that are `scheme` |
1183
- * | `'python` | include-match | Items that include `python` |
1184
- * | `!ruby` | inverse-exact-match | Items that do not include `ruby` |
1185
- * | `^java` | prefix-exact-match | Items that start with `java` |
1186
- * | `!^earlang` | inverse-prefix-exact-match | Items that do not start with `earlang` |
1187
- * | `.js$` | suffix-exact-match | Items that end with `.js` |
1188
- * | `!.go$` | inverse-suffix-exact-match | Items that do not end with `.go` |
1189
- *
1190
- * A single pipe character acts as an OR operator. For example, the following
1191
- * query matches entries that start with `core` and end with either`go`, `rb`,
1192
- * or`py`.
1193
- *
1194
- * ```
1195
- * ^core go$ | rb$ | py$
1196
- * ```
1197
- */
1198
- class ExtendedSearch {
1199
- constructor(
1200
- pattern,
1201
- {
1202
- isCaseSensitive = Config.isCaseSensitive,
1203
- includeMatches = Config.includeMatches,
1204
- minMatchCharLength = Config.minMatchCharLength,
1205
- ignoreLocation = Config.ignoreLocation,
1206
- findAllMatches = Config.findAllMatches,
1207
- location = Config.location,
1208
- threshold = Config.threshold,
1209
- distance = Config.distance
1210
- } = {}
1211
- ) {
1212
- this.query = null;
1213
- this.options = {
1214
- isCaseSensitive,
1215
- includeMatches,
1216
- minMatchCharLength,
1217
- findAllMatches,
1218
- ignoreLocation,
1219
- location,
1220
- threshold,
1221
- distance
1222
- };
1223
-
1224
- this.pattern = isCaseSensitive ? pattern : pattern.toLowerCase();
1225
- this.query = parseQuery(this.pattern, this.options);
1226
- }
1227
-
1228
- static condition(_, options) {
1229
- return options.useExtendedSearch
1230
- }
1231
-
1232
- searchIn(text) {
1233
- const query = this.query;
1234
-
1235
- if (!query) {
1236
- return {
1237
- isMatch: false,
1238
- score: 1
1239
- }
1240
- }
1241
-
1242
- const { includeMatches, isCaseSensitive } = this.options;
1243
-
1244
- text = isCaseSensitive ? text : text.toLowerCase();
1245
-
1246
- let numMatches = 0;
1247
- let allIndices = [];
1248
- let totalScore = 0;
1249
-
1250
- // ORs
1251
- for (let i = 0, qLen = query.length; i < qLen; i += 1) {
1252
- const searchers = query[i];
1253
-
1254
- // Reset indices
1255
- allIndices.length = 0;
1256
- numMatches = 0;
1257
-
1258
- // ANDs
1259
- for (let j = 0, pLen = searchers.length; j < pLen; j += 1) {
1260
- const searcher = searchers[j];
1261
- const { isMatch, indices, score } = searcher.search(text);
1262
-
1263
- if (isMatch) {
1264
- numMatches += 1;
1265
- totalScore += score;
1266
- if (includeMatches) {
1267
- const type = searcher.constructor.type;
1268
- if (MultiMatchSet.has(type)) {
1269
- allIndices = [...allIndices, ...indices];
1270
- } else {
1271
- allIndices.push(indices);
1272
- }
1273
- }
1274
- } else {
1275
- totalScore = 0;
1276
- numMatches = 0;
1277
- allIndices.length = 0;
1278
- break
1279
- }
1280
- }
1281
-
1282
- // OR condition, so if TRUE, return
1283
- if (numMatches) {
1284
- let result = {
1285
- isMatch: true,
1286
- score: totalScore / numMatches
1287
- };
1288
-
1289
- if (includeMatches) {
1290
- result.indices = allIndices;
1291
- }
1292
-
1293
- return result
1294
- }
1295
- }
1296
-
1297
- // Nothing was matched
1298
- return {
1299
- isMatch: false,
1300
- score: 1
1301
- }
1302
- }
1303
- }
1304
-
1305
- const registeredSearchers = [];
1306
-
1307
- function register(...args) {
1308
- registeredSearchers.push(...args);
1309
- }
1310
-
1311
- function createSearcher(pattern, options) {
1312
- for (let i = 0, len = registeredSearchers.length; i < len; i += 1) {
1313
- let searcherClass = registeredSearchers[i];
1314
- if (searcherClass.condition(pattern, options)) {
1315
- return new searcherClass(pattern, options)
1316
- }
1317
- }
1318
-
1319
- return new BitapSearch(pattern, options)
1320
- }
1321
-
1322
- const LogicalOperator = {
1323
- AND: '$and',
1324
- OR: '$or'
1325
- };
1326
-
1327
- const KeyType = {
1328
- PATH: '$path',
1329
- PATTERN: '$val'
1330
- };
1331
-
1332
- const isExpression = (query) =>
1333
- !!(query[LogicalOperator.AND] || query[LogicalOperator.OR]);
1334
-
1335
- const isPath = (query) => !!query[KeyType.PATH];
1336
-
1337
- const isLeaf = (query) =>
1338
- !isArray(query) && isObject(query) && !isExpression(query);
1339
-
1340
- const convertToExplicit = (query) => ({
1341
- [LogicalOperator.AND]: Object.keys(query).map((key) => ({
1342
- [key]: query[key]
1343
- }))
1344
- });
1345
-
1346
- // When `auto` is `true`, the parse function will infer and initialize and add
1347
- // the appropriate `Searcher` instance
1348
- function parse(query, options, { auto = true } = {}) {
1349
- const next = (query) => {
1350
- let keys = Object.keys(query);
1351
-
1352
- const isQueryPath = isPath(query);
1353
-
1354
- if (!isQueryPath && keys.length > 1 && !isExpression(query)) {
1355
- return next(convertToExplicit(query))
1356
- }
1357
-
1358
- if (isLeaf(query)) {
1359
- const key = isQueryPath ? query[KeyType.PATH] : keys[0];
1360
-
1361
- const pattern = isQueryPath ? query[KeyType.PATTERN] : query[key];
1362
-
1363
- if (!isString(pattern)) {
1364
- throw new Error(LOGICAL_SEARCH_INVALID_QUERY_FOR_KEY(key))
1365
- }
1366
-
1367
- const obj = {
1368
- keyId: createKeyId(key),
1369
- pattern
1370
- };
1371
-
1372
- if (auto) {
1373
- obj.searcher = createSearcher(pattern, options);
1374
- }
1375
-
1376
- return obj
1377
- }
1378
-
1379
- let node = {
1380
- children: [],
1381
- operator: keys[0]
1382
- };
1383
-
1384
- keys.forEach((key) => {
1385
- const value = query[key];
1386
-
1387
- if (isArray(value)) {
1388
- value.forEach((item) => {
1389
- node.children.push(next(item));
1390
- });
1391
- }
1392
- });
1393
-
1394
- return node
1395
- };
1396
-
1397
- if (!isExpression(query)) {
1398
- query = convertToExplicit(query);
1399
- }
1400
-
1401
- return next(query)
1402
- }
1403
-
1404
- // Practical scoring function
1405
- function computeScore$1(
1406
- results,
1407
- { ignoreFieldNorm = Config.ignoreFieldNorm }
1408
- ) {
1409
- results.forEach((result) => {
1410
- let totalScore = 1;
1411
-
1412
- result.matches.forEach(({ key, norm, score }) => {
1413
- const weight = key ? key.weight : null;
1414
-
1415
- totalScore *= Math.pow(
1416
- score === 0 && weight ? Number.EPSILON : score,
1417
- (weight || 1) * (ignoreFieldNorm ? 1 : norm)
1418
- );
1419
- });
1420
-
1421
- result.score = totalScore;
1422
- });
1423
- }
1424
-
1425
- function transformMatches(result, data) {
1426
- const matches = result.matches;
1427
- data.matches = [];
1428
-
1429
- if (!isDefined(matches)) {
1430
- return
1431
- }
1432
-
1433
- matches.forEach((match) => {
1434
- if (!isDefined(match.indices) || !match.indices.length) {
1435
- return
1436
- }
1437
-
1438
- const { indices, value } = match;
1439
-
1440
- let obj = {
1441
- indices,
1442
- value
1443
- };
1444
-
1445
- if (match.key) {
1446
- obj.key = match.key.src;
1447
- }
1448
-
1449
- if (match.idx > -1) {
1450
- obj.refIndex = match.idx;
1451
- }
1452
-
1453
- data.matches.push(obj);
1454
- });
1455
- }
1456
-
1457
- function transformScore(result, data) {
1458
- data.score = result.score;
1459
- }
1460
-
1461
- function format(
1462
- results,
1463
- docs,
1464
- {
1465
- includeMatches = Config.includeMatches,
1466
- includeScore = Config.includeScore
1467
- } = {}
1468
- ) {
1469
- const transformers = [];
1470
-
1471
- if (includeMatches) transformers.push(transformMatches);
1472
- if (includeScore) transformers.push(transformScore);
1473
-
1474
- return results.map((result) => {
1475
- const { idx } = result;
1476
-
1477
- const data = {
1478
- item: docs[idx],
1479
- refIndex: idx
1480
- };
1481
-
1482
- if (transformers.length) {
1483
- transformers.forEach((transformer) => {
1484
- transformer(result, data);
1485
- });
1486
- }
1487
-
1488
- return data
1489
- })
1490
- }
1491
-
1492
- class Fuse {
1493
- constructor(docs, options = {}, index) {
1494
- this.options = { ...Config, ...options };
1495
-
1496
- if (
1497
- this.options.useExtendedSearch &&
1498
- !true
1499
- ) {
1500
- throw new Error(EXTENDED_SEARCH_UNAVAILABLE)
1501
- }
1502
-
1503
- this._keyStore = new KeyStore(this.options.keys);
1504
-
1505
- this.setCollection(docs, index);
1506
- }
1507
-
1508
- setCollection(docs, index) {
1509
- this._docs = docs;
1510
-
1511
- if (index && !(index instanceof FuseIndex)) {
1512
- throw new Error(INCORRECT_INDEX_TYPE)
1513
- }
1514
-
1515
- this._myIndex =
1516
- index ||
1517
- createIndex(this.options.keys, this._docs, {
1518
- getFn: this.options.getFn
1519
- });
1520
- }
1521
-
1522
- add(doc) {
1523
- if (!isDefined(doc)) {
1524
- return
1525
- }
1526
-
1527
- this._docs.push(doc);
1528
- this._myIndex.add(doc);
1529
- }
1530
-
1531
- remove(predicate = (/* doc, idx */) => false) {
1532
- const results = [];
1533
-
1534
- for (let i = 0, len = this._docs.length; i < len; i += 1) {
1535
- const doc = this._docs[i];
1536
- if (predicate(doc, i)) {
1537
- this.removeAt(i);
1538
- i -= 1;
1539
- len -= 1;
1540
-
1541
- results.push(doc);
1542
- }
1543
- }
1544
-
1545
- return results
1546
- }
1547
-
1548
- removeAt(idx) {
1549
- this._docs.splice(idx, 1);
1550
- this._myIndex.removeAt(idx);
1551
- }
1552
-
1553
- getIndex() {
1554
- return this._myIndex
1555
- }
1556
-
1557
- search(query, { limit = -1 } = {}) {
1558
- const {
1559
- includeMatches,
1560
- includeScore,
1561
- shouldSort,
1562
- sortFn,
1563
- ignoreFieldNorm
1564
- } = this.options;
1565
-
1566
- let results = isString(query)
1567
- ? isString(this._docs[0])
1568
- ? this._searchStringList(query)
1569
- : this._searchObjectList(query)
1570
- : this._searchLogical(query);
1571
-
1572
- computeScore$1(results, { ignoreFieldNorm });
1573
-
1574
- if (shouldSort) {
1575
- results.sort(sortFn);
1576
- }
1577
-
1578
- if (isNumber(limit) && limit > -1) {
1579
- results = results.slice(0, limit);
1580
- }
1581
-
1582
- return format(results, this._docs, {
1583
- includeMatches,
1584
- includeScore
1585
- })
1586
- }
1587
-
1588
- _searchStringList(query) {
1589
- const searcher = createSearcher(query, this.options);
1590
- const { records } = this._myIndex;
1591
- const results = [];
1592
-
1593
- // Iterate over every string in the index
1594
- records.forEach(({ v: text, i: idx, n: norm }) => {
1595
- if (!isDefined(text)) {
1596
- return
1597
- }
1598
-
1599
- const { isMatch, score, indices } = searcher.searchIn(text);
1600
-
1601
- if (isMatch) {
1602
- results.push({
1603
- item: text,
1604
- idx,
1605
- matches: [{ score, value: text, norm, indices }]
1606
- });
1607
- }
1608
- });
1609
-
1610
- return results
1611
- }
1612
-
1613
- _searchLogical(query) {
1614
-
1615
- const expression = parse(query, this.options);
1616
-
1617
- const evaluate = (node, item, idx) => {
1618
- if (!node.children) {
1619
- const { keyId, searcher } = node;
1620
-
1621
- const matches = this._findMatches({
1622
- key: this._keyStore.get(keyId),
1623
- value: this._myIndex.getValueForItemAtKeyId(item, keyId),
1624
- searcher
1625
- });
1626
-
1627
- if (matches && matches.length) {
1628
- return [
1629
- {
1630
- idx,
1631
- item,
1632
- matches
1633
- }
1634
- ]
1635
- }
1636
-
1637
- return []
1638
- }
1639
-
1640
- /*eslint indent: [2, 2, {"SwitchCase": 1}]*/
1641
- switch (node.operator) {
1642
- case LogicalOperator.AND: {
1643
- const res = [];
1644
- for (let i = 0, len = node.children.length; i < len; i += 1) {
1645
- const child = node.children[i];
1646
- const result = evaluate(child, item, idx);
1647
- if (result.length) {
1648
- res.push(...result);
1649
- } else {
1650
- return []
1651
- }
1652
- }
1653
- return res
1654
- }
1655
- case LogicalOperator.OR: {
1656
- const res = [];
1657
- for (let i = 0, len = node.children.length; i < len; i += 1) {
1658
- const child = node.children[i];
1659
- const result = evaluate(child, item, idx);
1660
- if (result.length) {
1661
- res.push(...result);
1662
- break
1663
- }
1664
- }
1665
- return res
1666
- }
1667
- }
1668
- };
1669
-
1670
- const records = this._myIndex.records;
1671
- const resultMap = {};
1672
- const results = [];
1673
-
1674
- records.forEach(({ $: item, i: idx }) => {
1675
- if (isDefined(item)) {
1676
- let expResults = evaluate(expression, item, idx);
1677
-
1678
- if (expResults.length) {
1679
- // Dedupe when adding
1680
- if (!resultMap[idx]) {
1681
- resultMap[idx] = { idx, item, matches: [] };
1682
- results.push(resultMap[idx]);
1683
- }
1684
- expResults.forEach(({ matches }) => {
1685
- resultMap[idx].matches.push(...matches);
1686
- });
1687
- }
1688
- }
1689
- });
1690
-
1691
- return results
1692
- }
1693
-
1694
- _searchObjectList(query) {
1695
- const searcher = createSearcher(query, this.options);
1696
- const { keys, records } = this._myIndex;
1697
- const results = [];
1698
-
1699
- // List is Array<Object>
1700
- records.forEach(({ $: item, i: idx }) => {
1701
- if (!isDefined(item)) {
1702
- return
1703
- }
1704
-
1705
- let matches = [];
1706
-
1707
- // Iterate over every key (i.e, path), and fetch the value at that key
1708
- keys.forEach((key, keyIndex) => {
1709
- matches.push(
1710
- ...this._findMatches({
1711
- key,
1712
- value: item[keyIndex],
1713
- searcher
1714
- })
1715
- );
1716
- });
1717
-
1718
- if (matches.length) {
1719
- results.push({
1720
- idx,
1721
- item,
1722
- matches
1723
- });
1724
- }
1725
- });
1726
-
1727
- return results
1728
- }
1729
- _findMatches({ key, value, searcher }) {
1730
- if (!isDefined(value)) {
1731
- return []
1732
- }
1733
-
1734
- let matches = [];
1735
-
1736
- if (isArray(value)) {
1737
- value.forEach(({ v: text, i: idx, n: norm }) => {
1738
- if (!isDefined(text)) {
1739
- return
1740
- }
1741
-
1742
- const { isMatch, score, indices } = searcher.searchIn(text);
1743
-
1744
- if (isMatch) {
1745
- matches.push({
1746
- score,
1747
- key,
1748
- value: text,
1749
- idx,
1750
- norm,
1751
- indices
1752
- });
1753
- }
1754
- });
1755
- } else {
1756
- const { v: text, n: norm } = value;
1757
-
1758
- const { isMatch, score, indices } = searcher.searchIn(text);
1759
-
1760
- if (isMatch) {
1761
- matches.push({ score, key, value: text, norm, indices });
1762
- }
1763
- }
1764
-
1765
- return matches
1766
- }
1767
- }
1768
-
1769
- Fuse.version = '6.4.6';
1770
- Fuse.createIndex = createIndex;
1771
- Fuse.parseIndex = parseIndex;
1772
- Fuse.config = Config;
1773
-
1774
- {
1775
- Fuse.parseQuery = parse;
1776
- }
1777
-
1778
- {
1779
- register(ExtendedSearch);
1780
- }
1781
-
1782
- export default Fuse;
1783
- //# sourceMappingURL=fusejs.js.map