@flow-industries/id 0.26.1 → 0.26.3
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,3 +1,9 @@
|
|
|
1
|
+
// Published redundant IDs must still index saved subjects and cached catalogs.
|
|
2
|
+
const COMPATIBILITY_FIELD_REPLACEMENTS = new Map([
|
|
3
|
+
["programming/vhdl-programming", "programming/vhdl"],
|
|
4
|
+
["programming/verilog-programming", "programming/verilog"],
|
|
5
|
+
["programming/systemverilog-programming", "programming/systemverilog"],
|
|
6
|
+
]);
|
|
1
7
|
export function normalizeSearchText(text) {
|
|
2
8
|
return text
|
|
3
9
|
.normalize("NFD")
|
|
@@ -53,6 +59,9 @@ export function fieldsCoveredBySubjects(subjects, index) {
|
|
|
53
59
|
continue;
|
|
54
60
|
if (normalizeSearchText(subject.name) === normalizeSearchText(ref.field.label)) {
|
|
55
61
|
covered.add(subject.field);
|
|
62
|
+
const replacement = COMPATIBILITY_FIELD_REPLACEMENTS.get(subject.field);
|
|
63
|
+
if (replacement && index.has(replacement))
|
|
64
|
+
covered.add(replacement);
|
|
56
65
|
}
|
|
57
66
|
}
|
|
58
67
|
return covered;
|
|
@@ -72,13 +81,30 @@ export function searchStudy(query, options) {
|
|
|
72
81
|
return [];
|
|
73
82
|
const index = catalogFieldIndex(catalog);
|
|
74
83
|
const covered = fieldsCoveredBySubjects(subjects, index);
|
|
84
|
+
const searchableFields = new Map();
|
|
85
|
+
for (const [compatibilitySlug, originalSlug,] of COMPATIBILITY_FIELD_REPLACEMENTS) {
|
|
86
|
+
const compatibility = index.get(compatibilitySlug)?.field;
|
|
87
|
+
const original = index.get(originalSlug)?.field;
|
|
88
|
+
if (!compatibility || !original)
|
|
89
|
+
continue;
|
|
90
|
+
// Cached catalogs can predate the canonical fields' new aliases.
|
|
91
|
+
searchableFields.set(originalSlug, {
|
|
92
|
+
...original,
|
|
93
|
+
aliases: [
|
|
94
|
+
...(original.aliases ?? []),
|
|
95
|
+
compatibility.label,
|
|
96
|
+
...(compatibility.aliases ?? []),
|
|
97
|
+
],
|
|
98
|
+
});
|
|
99
|
+
}
|
|
75
100
|
const hits = [];
|
|
76
101
|
for (const subject of subjects) {
|
|
77
102
|
const ref = subject.field ? (index.get(subject.field) ?? null) : null;
|
|
78
103
|
let score = matchScore(query, subject.name);
|
|
79
104
|
if (ref) {
|
|
80
|
-
|
|
81
|
-
|
|
105
|
+
const field = searchableFields.get(ref.field.slug) ?? ref.field;
|
|
106
|
+
score = Math.max(score, matchScore(query, field.label));
|
|
107
|
+
const alias = bestAliasMatch(query, field);
|
|
82
108
|
if (alias)
|
|
83
109
|
score = Math.max(score, alias.score);
|
|
84
110
|
}
|
|
@@ -89,8 +115,12 @@ export function searchStudy(query, options) {
|
|
|
89
115
|
for (const ref of index.values()) {
|
|
90
116
|
if (covered.has(ref.field.slug))
|
|
91
117
|
continue;
|
|
92
|
-
const
|
|
93
|
-
|
|
118
|
+
const replacement = COMPATIBILITY_FIELD_REPLACEMENTS.get(ref.field.slug);
|
|
119
|
+
if (replacement && index.has(replacement))
|
|
120
|
+
continue;
|
|
121
|
+
const field = searchableFields.get(ref.field.slug) ?? ref.field;
|
|
122
|
+
const labelScore = matchScore(query, field.label);
|
|
123
|
+
const alias = bestAliasMatch(query, field);
|
|
94
124
|
const score = Math.max(labelScore, alias?.score ?? 0);
|
|
95
125
|
if (score === 0)
|
|
96
126
|
continue;
|
|
@@ -76,5 +76,5 @@ function AccountAvatar({ username, image, trigger, }) {
|
|
|
76
76
|
return (_jsxs(Avatar, { className: trigger ? "size-[var(--flow-profile-height,2.25rem)]" : undefined, children: [_jsx(AvatarImage, { src: image ?? undefined, alt: "" }), _jsx(AvatarFallback, { children: username.slice(0, 1).toUpperCase() })] }));
|
|
77
77
|
}
|
|
78
78
|
function ActionIcon({ icon: Icon }) {
|
|
79
|
-
return (_jsx("span", { className: "flex size-8 shrink-0 items-center justify-center", "aria-hidden": "true", children: _jsx(Icon, { className: "size-
|
|
79
|
+
return (_jsx("span", { className: "flex size-8 shrink-0 items-center justify-center", "aria-hidden": "true", children: _jsx(Icon, { className: "size-4", strokeWidth: 2.25 }) }));
|
|
80
80
|
}
|