toolcraft-openapi 0.0.167 → 0.0.168

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.
@@ -33,12 +33,12 @@
33
33
  },
34
34
  {
35
35
  "name": "toolcraft-openapi",
36
- "version": "0.0.167",
36
+ "version": "0.0.168",
37
37
  "license": "MIT"
38
38
  },
39
39
  {
40
40
  "name": "toolcraft-schema",
41
- "version": "0.0.167",
41
+ "version": "0.0.168",
42
42
  "license": "MIT"
43
43
  },
44
44
  {
@@ -28,17 +28,24 @@ function stripAnsi(value) {
28
28
  return value.replace(/\u001b\[[0-9;]*m/g, "");
29
29
  }
30
30
  function matchSubsequence(query, text) {
31
+ const queryCharacters = Array.from(query);
32
+ const textCharacters = Array.from(text);
31
33
  let previousStates = [];
32
- for (let queryIndex = 0; queryIndex < query.length; queryIndex += 1) {
34
+ for (let queryIndex = 0; queryIndex < queryCharacters.length; queryIndex += 1) {
33
35
  const states = [];
34
- for (let textIndex = 0; textIndex < text.length; textIndex += 1) {
35
- if (text[textIndex] !== query[queryIndex]) {
36
+ let offset = 0;
37
+ for (let textIndex = 0; textIndex < textCharacters.length; textIndex += 1) {
38
+ const character = textCharacters[textIndex];
39
+ const position = offset;
40
+ offset += character.length;
41
+ if (character !== queryCharacters[queryIndex]) {
36
42
  continue;
37
43
  }
44
+ const positions = character.length === 2 ? [position, position + 1] : [position];
38
45
  if (queryIndex === 0) {
39
46
  states[textIndex] = {
40
- score: characterScore(text, textIndex, undefined) + Math.max(0, EARLY_MATCH_BONUS - textIndex),
41
- positions: [textIndex]
47
+ score: characterScore(textCharacters, textIndex, undefined) + Math.max(0, EARLY_MATCH_BONUS - position),
48
+ positions
42
49
  };
43
50
  continue;
44
51
  }
@@ -48,8 +55,8 @@ function matchSubsequence(query, text) {
48
55
  continue;
49
56
  }
50
57
  const next = {
51
- score: previous.score + characterScore(text, textIndex, previousIndex),
52
- positions: [...previous.positions, textIndex]
58
+ score: previous.score + characterScore(textCharacters, textIndex, previousIndex),
59
+ positions: [...previous.positions, ...positions]
53
60
  };
54
61
  if (isBetterMatch(next, states[textIndex])) {
55
62
  states[textIndex] = next;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft-schema",
3
- "version": "0.0.167",
3
+ "version": "0.0.168",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "toolcraft-openapi",
3
- "version": "0.0.167",
3
+ "version": "0.0.168",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -30,7 +30,7 @@
30
30
  "toolcraft-openapi-generate": "dist/bin/generate.js"
31
31
  },
32
32
  "dependencies": {
33
- "toolcraft": "0.0.167",
33
+ "toolcraft": "0.0.168",
34
34
  "fast-string-width": "^3.0.2",
35
35
  "fast-wrap-ansi": "^0.2.0",
36
36
  "sisteransi": "^1.0.5",
@@ -45,7 +45,7 @@
45
45
  "directory": "packages/toolcraft-openapi"
46
46
  },
47
47
  "optionalDependencies": {
48
- "toolcraft-schema": "0.0.167",
48
+ "toolcraft-schema": "0.0.168",
49
49
  "toolcraft-design": "*",
50
50
  "@poe-code/frontmatter": "*"
51
51
  },