7onic 0.1.18 → 0.1.19
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.
- package/dist/index.js +27 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -21631,8 +21631,34 @@ function findSimilar(input, candidates) {
|
|
|
21631
21631
|
best = name;
|
|
21632
21632
|
}
|
|
21633
21633
|
}
|
|
21634
|
+
if (best) return best;
|
|
21635
|
+
let bestDistance = Infinity;
|
|
21636
|
+
for (const name of candidates) {
|
|
21637
|
+
const distance = editDistance(input.toLowerCase(), name.toLowerCase());
|
|
21638
|
+
const limit = Math.min(2, Math.floor(name.length / 3));
|
|
21639
|
+
if (distance <= limit && distance < bestDistance) {
|
|
21640
|
+
bestDistance = distance;
|
|
21641
|
+
best = name;
|
|
21642
|
+
}
|
|
21643
|
+
}
|
|
21634
21644
|
return best;
|
|
21635
21645
|
}
|
|
21646
|
+
function editDistance(a, b) {
|
|
21647
|
+
const d3 = Array.from(
|
|
21648
|
+
{ length: a.length + 1 },
|
|
21649
|
+
(_2, i) => Array.from({ length: b.length + 1 }, (_3, j2) => i === 0 ? j2 : j2 === 0 ? i : 0)
|
|
21650
|
+
);
|
|
21651
|
+
for (let i = 1; i <= a.length; i++) {
|
|
21652
|
+
for (let j2 = 1; j2 <= b.length; j2++) {
|
|
21653
|
+
const cost = a[i - 1] === b[j2 - 1] ? 0 : 1;
|
|
21654
|
+
d3[i][j2] = Math.min(d3[i - 1][j2] + 1, d3[i][j2 - 1] + 1, d3[i - 1][j2 - 1] + cost);
|
|
21655
|
+
if (i > 1 && j2 > 1 && a[i - 1] === b[j2 - 2] && a[i - 2] === b[j2 - 1]) {
|
|
21656
|
+
d3[i][j2] = Math.min(d3[i][j2], d3[i - 2][j2 - 2] + 1);
|
|
21657
|
+
}
|
|
21658
|
+
}
|
|
21659
|
+
}
|
|
21660
|
+
return d3[a.length][b.length];
|
|
21661
|
+
}
|
|
21636
21662
|
function similarity(a, b) {
|
|
21637
21663
|
if (a === b) return 1;
|
|
21638
21664
|
if (a.length < 2 || b.length < 2) return 0;
|
|
@@ -21701,7 +21727,7 @@ function showCompanionHints(names) {
|
|
|
21701
21727
|
|
|
21702
21728
|
// cli/src/index.ts
|
|
21703
21729
|
var import_picocolors4 = __toESM(require_picocolors());
|
|
21704
|
-
var VERSION = "0.1.
|
|
21730
|
+
var VERSION = "0.1.19";
|
|
21705
21731
|
var HELP = `
|
|
21706
21732
|
${import_picocolors4.default.bold("7onic")} \u2014 Add 7onic design system components to your project
|
|
21707
21733
|
|