camunda-bpmn-js 5.2.0 → 5.2.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.
@@ -27777,7 +27777,7 @@
27777
27777
  return originalEntries;
27778
27778
  }
27779
27779
 
27780
- if (!value) {
27780
+ if (!value.trim()) {
27781
27781
  return originalEntries.filter(({ rank = 0 }) => rank >= 0);
27782
27782
  }
27783
27783
 
@@ -28654,6 +28654,12 @@
28654
28654
  keys
28655
28655
  } = options;
28656
28656
 
28657
+ pattern = pattern.trim().toLowerCase();
28658
+
28659
+ if (!pattern) {
28660
+ throw new Error('<pattern> must not be empty');
28661
+ }
28662
+
28657
28663
  const words = pattern.trim().toLowerCase().split(/\s+/);
28658
28664
 
28659
28665
  return items.flatMap((item) => {
@@ -28781,22 +28787,33 @@
28781
28787
  }
28782
28788
 
28783
28789
  /**
28784
- * Score a token.
28790
+ * Score a token based on its characteristics
28791
+ * and the length of the matched content.
28785
28792
  *
28786
28793
  * @param { Token } token
28787
28794
  *
28788
28795
  * @returns { number }
28789
28796
  */
28790
28797
  function scoreToken(token) {
28798
+ const modifier = Math.log(token.value.length);
28799
+
28791
28800
  if (!token.match) {
28792
- return 0;
28801
+ return -0.07 * modifier;
28793
28802
  }
28794
28803
 
28795
- return token.start
28796
- ? 1.37
28797
- : token.wordStart
28798
- ? 1.13
28799
- : 1;
28804
+ return (
28805
+ token.start
28806
+ ? (
28807
+ token.end
28808
+ ? 131.9
28809
+ : 7.87
28810
+ )
28811
+ : (
28812
+ token.wordStart
28813
+ ? 2.19
28814
+ : 1
28815
+ )
28816
+ ) * modifier;
28800
28817
  }
28801
28818
 
28802
28819
  /**
@@ -28835,7 +28852,12 @@
28835
28852
  const tokens = [];
28836
28853
  const matchedWords = {};
28837
28854
 
28838
- const regexpString = words.map(escapeRegexp).flatMap(str => [ '(?<wordStart>\\b' + str + ')', str ]).join('|');
28855
+ const wordsEscaped = words.map(escapeRegexp);
28856
+
28857
+ const regexpString = [
28858
+ `(?<all>${wordsEscaped.join('\\s+')})`,
28859
+ ...wordsEscaped
28860
+ ].join('|');
28839
28861
 
28840
28862
  const regexp = new RegExp(regexpString, 'ig');
28841
28863
 
@@ -28846,6 +28868,17 @@
28846
28868
 
28847
28869
  const [ value ] = match;
28848
28870
 
28871
+ const startIndex = match.index;
28872
+ const endIndex = match.index + value.length;
28873
+
28874
+ const start = startIndex === 0;
28875
+ const end = endIndex === string.length;
28876
+
28877
+ const all = !!match.groups.all;
28878
+
28879
+ const wordStart = start || /\s/.test(string.charAt(startIndex - 1));
28880
+ const wordEnd = end || /\s/.test(string.charAt(endIndex + 1));
28881
+
28849
28882
  if (match.index > lastIndex) {
28850
28883
 
28851
28884
  // add previous token (NO match)
@@ -28860,11 +28893,18 @@
28860
28893
  value,
28861
28894
  index: match.index,
28862
28895
  match: true,
28863
- wordStart: !!match.groups.wordStart,
28864
- start: match.index === 0
28896
+ wordStart,
28897
+ wordEnd,
28898
+ start,
28899
+ end,
28900
+ all
28865
28901
  });
28866
28902
 
28867
- matchedWords[value.toLowerCase()] = true;
28903
+ const newMatchedWords = all ? words : [ value ];
28904
+
28905
+ for (const word of newMatchedWords) {
28906
+ matchedWords[word.toLowerCase()] = true;
28907
+ }
28868
28908
 
28869
28909
  lastIndex = match.index + value.length;
28870
28910
  }
@@ -65065,7 +65105,7 @@
65065
65105
  this._clearResults();
65066
65106
 
65067
65107
  // do not search on empty query
65068
- if (!pattern || pattern === '') {
65108
+ if (!pattern.trim()) {
65069
65109
  return;
65070
65110
  }
65071
65111