bpmn-js 18.1.0 → 18.1.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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * bpmn-js - bpmn-modeler v18.1.0
2
+ * bpmn-js - bpmn-modeler v18.1.1
3
3
  *
4
4
  * Copyright (c) 2014-present, camunda Services GmbH
5
5
  *
@@ -8,7 +8,7 @@
8
8
  *
9
9
  * Source Code: https://github.com/bpmn-io/bpmn-js
10
10
  *
11
- * Date: 2024-11-20
11
+ * Date: 2024-11-21
12
12
  */
13
13
  (function (global, factory) {
14
14
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
@@ -27760,7 +27760,7 @@
27760
27760
  return originalEntries;
27761
27761
  }
27762
27762
 
27763
- if (!value) {
27763
+ if (!value.trim()) {
27764
27764
  return originalEntries.filter(({ rank = 0 }) => rank >= 0);
27765
27765
  }
27766
27766
 
@@ -28637,6 +28637,12 @@
28637
28637
  keys
28638
28638
  } = options;
28639
28639
 
28640
+ pattern = pattern.trim().toLowerCase();
28641
+
28642
+ if (!pattern) {
28643
+ throw new Error('<pattern> must not be empty');
28644
+ }
28645
+
28640
28646
  const words = pattern.trim().toLowerCase().split(/\s+/);
28641
28647
 
28642
28648
  return items.flatMap((item) => {
@@ -28764,22 +28770,33 @@
28764
28770
  }
28765
28771
 
28766
28772
  /**
28767
- * Score a token.
28773
+ * Score a token based on its characteristics
28774
+ * and the length of the matched content.
28768
28775
  *
28769
28776
  * @param { Token } token
28770
28777
  *
28771
28778
  * @returns { number }
28772
28779
  */
28773
28780
  function scoreToken(token) {
28781
+ const modifier = Math.log(token.value.length);
28782
+
28774
28783
  if (!token.match) {
28775
- return 0;
28784
+ return -0.07 * modifier;
28776
28785
  }
28777
28786
 
28778
- return token.start
28779
- ? 1.37
28780
- : token.wordStart
28781
- ? 1.13
28782
- : 1;
28787
+ return (
28788
+ token.start
28789
+ ? (
28790
+ token.end
28791
+ ? 131.9
28792
+ : 7.87
28793
+ )
28794
+ : (
28795
+ token.wordStart
28796
+ ? 2.19
28797
+ : 1
28798
+ )
28799
+ ) * modifier;
28783
28800
  }
28784
28801
 
28785
28802
  /**
@@ -28818,7 +28835,12 @@
28818
28835
  const tokens = [];
28819
28836
  const matchedWords = {};
28820
28837
 
28821
- const regexpString = words.map(escapeRegexp).flatMap(str => [ '(?<wordStart>\\b' + str + ')', str ]).join('|');
28838
+ const wordsEscaped = words.map(escapeRegexp);
28839
+
28840
+ const regexpString = [
28841
+ `(?<all>${wordsEscaped.join('\\s+')})`,
28842
+ ...wordsEscaped
28843
+ ].join('|');
28822
28844
 
28823
28845
  const regexp = new RegExp(regexpString, 'ig');
28824
28846
 
@@ -28829,6 +28851,17 @@
28829
28851
 
28830
28852
  const [ value ] = match;
28831
28853
 
28854
+ const startIndex = match.index;
28855
+ const endIndex = match.index + value.length;
28856
+
28857
+ const start = startIndex === 0;
28858
+ const end = endIndex === string.length;
28859
+
28860
+ const all = !!match.groups.all;
28861
+
28862
+ const wordStart = start || /\s/.test(string.charAt(startIndex - 1));
28863
+ const wordEnd = end || /\s/.test(string.charAt(endIndex + 1));
28864
+
28832
28865
  if (match.index > lastIndex) {
28833
28866
 
28834
28867
  // add previous token (NO match)
@@ -28843,11 +28876,18 @@
28843
28876
  value,
28844
28877
  index: match.index,
28845
28878
  match: true,
28846
- wordStart: !!match.groups.wordStart,
28847
- start: match.index === 0
28879
+ wordStart,
28880
+ wordEnd,
28881
+ start,
28882
+ end,
28883
+ all
28848
28884
  });
28849
28885
 
28850
- matchedWords[value.toLowerCase()] = true;
28886
+ const newMatchedWords = all ? words : [ value ];
28887
+
28888
+ for (const word of newMatchedWords) {
28889
+ matchedWords[word.toLowerCase()] = true;
28890
+ }
28851
28891
 
28852
28892
  lastIndex = match.index + value.length;
28853
28893
  }
@@ -65048,7 +65088,7 @@
65048
65088
  this._clearResults();
65049
65089
 
65050
65090
  // do not search on empty query
65051
- if (!pattern || pattern === '') {
65091
+ if (!pattern.trim()) {
65052
65092
  return;
65053
65093
  }
65054
65094