trueicon 0.1.0
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/LICENSE +21 -0
- package/README.md +334 -0
- package/dist/cache/downloader.d.ts +18 -0
- package/dist/cache/downloader.js +131 -0
- package/dist/cache/downloader.js.map +1 -0
- package/dist/config/ensureIndex.d.ts +16 -0
- package/dist/config/ensureIndex.js +41 -0
- package/dist/config/ensureIndex.js.map +1 -0
- package/dist/config/loadConfig.d.ts +12 -0
- package/dist/config/loadConfig.js +71 -0
- package/dist/config/loadConfig.js.map +1 -0
- package/dist/config/versions.d.ts +16 -0
- package/dist/config/versions.js +31 -0
- package/dist/config/versions.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/indexer/buildIndex.d.ts +27 -0
- package/dist/indexer/buildIndex.js +83 -0
- package/dist/indexer/buildIndex.js.map +1 -0
- package/dist/indexer/types.d.ts +35 -0
- package/dist/indexer/types.js +2 -0
- package/dist/indexer/types.js.map +1 -0
- package/dist/providers/adapter.d.ts +20 -0
- package/dist/providers/adapter.js +10 -0
- package/dist/providers/adapter.js.map +1 -0
- package/dist/providers/adapters/heroicons.d.ts +4 -0
- package/dist/providers/adapters/heroicons.js +73 -0
- package/dist/providers/adapters/heroicons.js.map +1 -0
- package/dist/providers/adapters/index.d.ts +2 -0
- package/dist/providers/adapters/index.js +10 -0
- package/dist/providers/adapters/index.js.map +1 -0
- package/dist/providers/adapters/lucide.d.ts +2 -0
- package/dist/providers/adapters/lucide.js +57 -0
- package/dist/providers/adapters/lucide.js.map +1 -0
- package/dist/providers/adapters/react-icons.d.ts +3 -0
- package/dist/providers/adapters/react-icons.js +66 -0
- package/dist/providers/adapters/react-icons.js.map +1 -0
- package/dist/providers/jsLiteral.d.ts +20 -0
- package/dist/providers/jsLiteral.js +137 -0
- package/dist/providers/jsLiteral.js.map +1 -0
- package/dist/providers/registry.d.ts +9 -0
- package/dist/providers/registry.js +23 -0
- package/dist/providers/registry.js.map +1 -0
- package/dist/providers/svg.d.ts +9 -0
- package/dist/providers/svg.js +97 -0
- package/dist/providers/svg.js.map +1 -0
- package/dist/search/search.d.ts +26 -0
- package/dist/search/search.js +45 -0
- package/dist/search/search.js.map +1 -0
- package/dist/server.d.ts +4 -0
- package/dist/server.js +17 -0
- package/dist/server.js.map +1 -0
- package/dist/synonyms/loadSynonyms.d.ts +5 -0
- package/dist/synonyms/loadSynonyms.js +20 -0
- package/dist/synonyms/loadSynonyms.js.map +1 -0
- package/dist/synonyms/synonyms.json +80 -0
- package/dist/tools/context.d.ts +26 -0
- package/dist/tools/context.js +43 -0
- package/dist/tools/context.js.map +1 -0
- package/dist/tools/getIcon.d.ts +16 -0
- package/dist/tools/getIcon.js +50 -0
- package/dist/tools/getIcon.js.map +1 -0
- package/dist/tools/listProviders.d.ts +20 -0
- package/dist/tools/listProviders.js +22 -0
- package/dist/tools/listProviders.js.map +1 -0
- package/dist/tools/ping.d.ts +2 -0
- package/dist/tools/ping.js +12 -0
- package/dist/tools/ping.js.map +1 -0
- package/dist/tools/searchIcons.d.ts +31 -0
- package/dist/tools/searchIcons.js +97 -0
- package/dist/tools/searchIcons.js.map +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type JsValue = string | number | boolean | null | JsValue[] | {
|
|
2
|
+
[key: string]: JsValue;
|
|
3
|
+
};
|
|
4
|
+
export declare class LiteralCursor {
|
|
5
|
+
readonly src: string;
|
|
6
|
+
pos: number;
|
|
7
|
+
constructor(src: string, pos?: number);
|
|
8
|
+
skipWs(): void;
|
|
9
|
+
peek(): string | undefined;
|
|
10
|
+
eat(token: string): boolean;
|
|
11
|
+
expect(token: string): void;
|
|
12
|
+
fail(message: string): never;
|
|
13
|
+
identifier(): string;
|
|
14
|
+
string(): string;
|
|
15
|
+
value(): JsValue;
|
|
16
|
+
array(): JsValue[];
|
|
17
|
+
object(): {
|
|
18
|
+
[key: string]: JsValue;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Minimal reader for the JavaScript literals found in compiled icon modules: strings,
|
|
3
|
+
* numbers, booleans, null, arrays and objects with bare or quoted keys. It is not a general
|
|
4
|
+
* JS parser; it only needs to cover what icon build tools emit, and throws on anything else.
|
|
5
|
+
*/
|
|
6
|
+
const IDENTIFIER = /[A-Za-z_$][\w$]*/y;
|
|
7
|
+
const NUMBER = /-?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/y;
|
|
8
|
+
export class LiteralCursor {
|
|
9
|
+
src;
|
|
10
|
+
pos;
|
|
11
|
+
constructor(src, pos = 0) {
|
|
12
|
+
this.src = src;
|
|
13
|
+
this.pos = pos;
|
|
14
|
+
}
|
|
15
|
+
// Skips whitespace and comments (including /*#__PURE__*/ annotations).
|
|
16
|
+
skipWs() {
|
|
17
|
+
for (;;) {
|
|
18
|
+
while (this.pos < this.src.length && /\s/.test(this.src[this.pos]))
|
|
19
|
+
this.pos++;
|
|
20
|
+
if (this.src.startsWith("/*", this.pos)) {
|
|
21
|
+
const end = this.src.indexOf("*/", this.pos + 2);
|
|
22
|
+
this.pos = end < 0 ? this.src.length : end + 2;
|
|
23
|
+
}
|
|
24
|
+
else if (this.src.startsWith("//", this.pos)) {
|
|
25
|
+
const end = this.src.indexOf("\n", this.pos);
|
|
26
|
+
this.pos = end < 0 ? this.src.length : end + 1;
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
peek() {
|
|
34
|
+
this.skipWs();
|
|
35
|
+
return this.src[this.pos];
|
|
36
|
+
}
|
|
37
|
+
// Consumes `token` if it comes next; returns whether it did.
|
|
38
|
+
eat(token) {
|
|
39
|
+
this.skipWs();
|
|
40
|
+
if (!this.src.startsWith(token, this.pos))
|
|
41
|
+
return false;
|
|
42
|
+
this.pos += token.length;
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
expect(token) {
|
|
46
|
+
if (!this.eat(token))
|
|
47
|
+
this.fail(`expected "${token}"`);
|
|
48
|
+
}
|
|
49
|
+
fail(message) {
|
|
50
|
+
const context = this.src.slice(this.pos, this.pos + 40);
|
|
51
|
+
throw new Error(`Parse error at offset ${this.pos}: ${message} (near ${JSON.stringify(context)})`);
|
|
52
|
+
}
|
|
53
|
+
identifier() {
|
|
54
|
+
this.skipWs();
|
|
55
|
+
IDENTIFIER.lastIndex = this.pos;
|
|
56
|
+
const match = IDENTIFIER.exec(this.src);
|
|
57
|
+
if (!match)
|
|
58
|
+
this.fail("expected identifier");
|
|
59
|
+
this.pos += match[0].length;
|
|
60
|
+
return match[0];
|
|
61
|
+
}
|
|
62
|
+
string() {
|
|
63
|
+
this.skipWs();
|
|
64
|
+
const quote = this.src[this.pos];
|
|
65
|
+
if (quote !== '"' && quote !== "'")
|
|
66
|
+
this.fail("expected string");
|
|
67
|
+
let out = "";
|
|
68
|
+
let i = this.pos + 1;
|
|
69
|
+
while (i < this.src.length && this.src[i] !== quote) {
|
|
70
|
+
if (this.src[i] === "\\") {
|
|
71
|
+
const next = this.src[i + 1];
|
|
72
|
+
if (next === "u") {
|
|
73
|
+
out += String.fromCharCode(parseInt(this.src.slice(i + 2, i + 6), 16));
|
|
74
|
+
i += 6;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
out += next === "n" ? "\n" : next === "t" ? "\t" : next === "r" ? "\r" : (next ?? "");
|
|
78
|
+
i += 2;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
out += this.src[i];
|
|
82
|
+
i++;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
if (i >= this.src.length)
|
|
86
|
+
this.fail("unterminated string");
|
|
87
|
+
this.pos = i + 1;
|
|
88
|
+
return out;
|
|
89
|
+
}
|
|
90
|
+
value() {
|
|
91
|
+
const ch = this.peek();
|
|
92
|
+
if (ch === '"' || ch === "'")
|
|
93
|
+
return this.string();
|
|
94
|
+
if (ch === "[")
|
|
95
|
+
return this.array();
|
|
96
|
+
if (ch === "{")
|
|
97
|
+
return this.object();
|
|
98
|
+
NUMBER.lastIndex = this.pos;
|
|
99
|
+
const num = NUMBER.exec(this.src);
|
|
100
|
+
if (num) {
|
|
101
|
+
this.pos += num[0].length;
|
|
102
|
+
return Number(num[0]);
|
|
103
|
+
}
|
|
104
|
+
const word = this.identifier();
|
|
105
|
+
if (word === "true")
|
|
106
|
+
return true;
|
|
107
|
+
if (word === "false")
|
|
108
|
+
return false;
|
|
109
|
+
if (word === "null")
|
|
110
|
+
return null;
|
|
111
|
+
this.fail(`unsupported value "${word}"`);
|
|
112
|
+
}
|
|
113
|
+
array() {
|
|
114
|
+
this.expect("[");
|
|
115
|
+
const out = [];
|
|
116
|
+
while (!this.eat("]")) {
|
|
117
|
+
out.push(this.value());
|
|
118
|
+
if (!this.eat(",") && this.peek() !== "]")
|
|
119
|
+
this.fail('expected "," or "]"');
|
|
120
|
+
}
|
|
121
|
+
return out;
|
|
122
|
+
}
|
|
123
|
+
object() {
|
|
124
|
+
this.expect("{");
|
|
125
|
+
const out = {};
|
|
126
|
+
while (!this.eat("}")) {
|
|
127
|
+
const ch = this.peek();
|
|
128
|
+
const key = ch === '"' || ch === "'" ? this.string() : this.identifier();
|
|
129
|
+
this.expect(":");
|
|
130
|
+
out[key] = this.value();
|
|
131
|
+
if (!this.eat(",") && this.peek() !== "}")
|
|
132
|
+
this.fail('expected "," or "}"');
|
|
133
|
+
}
|
|
134
|
+
return out;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
//# sourceMappingURL=jsLiteral.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"jsLiteral.js","sourceRoot":"","sources":["../../src/providers/jsLiteral.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,UAAU,GAAG,mBAAmB,CA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AC;YACtB,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;YACvB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG;gBAAE,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAC9E,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACjB,MAAM,GAAG,GAA+B,EAAE,CAAC;QAC3C,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;YACvB,MAAM,GAAG,GAAG,EAAE,KAAK,GAAG,IAAI,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACzE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACjB,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,GAAG;gBAAE,IAAI,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;QAC9E,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface Provider {
|
|
2
|
+
/** Stable identifier used by trueicon tools. */
|
|
3
|
+
id: string;
|
|
4
|
+
/** npm package the icons are read from. */
|
|
5
|
+
package: string;
|
|
6
|
+
description: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const PROVIDERS: readonly Provider[];
|
|
9
|
+
export declare function getProvider(idOrPackage: string): Provider | undefined;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Icon providers supported in v1.
|
|
2
|
+
export const PROVIDERS = [
|
|
3
|
+
{
|
|
4
|
+
id: "react-icons",
|
|
5
|
+
package: "react-icons",
|
|
6
|
+
description: "Aggregated icon sets (Font Awesome, Material, Feather, and more) as React components",
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
id: "lucide",
|
|
10
|
+
package: "lucide-react",
|
|
11
|
+
description: "Lucide icons as React components",
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
id: "heroicons",
|
|
15
|
+
package: "@heroicons/react",
|
|
16
|
+
description: "Heroicons by the Tailwind CSS team as React components",
|
|
17
|
+
},
|
|
18
|
+
];
|
|
19
|
+
// Finds a provider by its id or by its npm package name.
|
|
20
|
+
export function getProvider(idOrPackage) {
|
|
21
|
+
return PROVIDERS.find((p) => p.id === idOrPackage || p.package === idOrPackage);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/providers/registry.ts"],"names":[],"mappings":"AAQA,kCAAkC;AAClC,MAAM,CAAC,MAAM,SAAS,GAAwB;IAC5C;QACE,EAAE,EAAE,aAAa;QACjB,OAAO,EAAE,aAAa;QACtB,WAAW,EAAE,sFAAsF;KACpG;IACD;QACE,EAAE,EAAE,QAAQ;QACZ,OAAO,EAAE,cAAc;QACvB,WAAW,EAAE,kCAAkC;KAChD;IACD;QACE,EAAE,EAAE,WAAW;QACf,OAAO,EAAE,kBAAkB;QAC3B,WAAW,EAAE,wDAAwD;KACtE;CACF,CAAC;AAEF,yDAAyD;AACzD,MAAM,UAAU,WAAW,CAAC,WAAmB;IAC7C,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,WAAW,IAAI,CAAC,CAAC,OAAO,KAAK,WAAW,CAAC,CAAC;AAClF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { JsValue } from "./jsLiteral.js";
|
|
2
|
+
export interface SvgNode {
|
|
3
|
+
tag: string;
|
|
4
|
+
attr: Record<string, string | number>;
|
|
5
|
+
child: SvgNode[];
|
|
6
|
+
}
|
|
7
|
+
export declare function svgAttrName(reactName: string): string;
|
|
8
|
+
export declare function renderSvg(nodes: readonly SvgNode[]): string;
|
|
9
|
+
export declare function toSvgAttrs(value: JsValue | undefined): Record<string, string | number>;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// SVG attributes whose names are camelCase in SVG itself, so React names must be kept as-is.
|
|
2
|
+
const CASE_SENSITIVE_ATTRS = new Set([
|
|
3
|
+
"viewBox",
|
|
4
|
+
"preserveAspectRatio",
|
|
5
|
+
"baseProfile",
|
|
6
|
+
"pathLength",
|
|
7
|
+
"textLength",
|
|
8
|
+
"lengthAdjust",
|
|
9
|
+
"startOffset",
|
|
10
|
+
"spreadMethod",
|
|
11
|
+
"gradientUnits",
|
|
12
|
+
"gradientTransform",
|
|
13
|
+
"patternUnits",
|
|
14
|
+
"patternContentUnits",
|
|
15
|
+
"patternTransform",
|
|
16
|
+
"clipPathUnits",
|
|
17
|
+
"maskUnits",
|
|
18
|
+
"maskContentUnits",
|
|
19
|
+
"filterUnits",
|
|
20
|
+
"primitiveUnits",
|
|
21
|
+
"markerUnits",
|
|
22
|
+
"markerWidth",
|
|
23
|
+
"markerHeight",
|
|
24
|
+
"refX",
|
|
25
|
+
"refY",
|
|
26
|
+
"stdDeviation",
|
|
27
|
+
"baseFrequency",
|
|
28
|
+
"numOctaves",
|
|
29
|
+
"stitchTiles",
|
|
30
|
+
"kernelMatrix",
|
|
31
|
+
"kernelUnitLength",
|
|
32
|
+
"tableValues",
|
|
33
|
+
"surfaceScale",
|
|
34
|
+
"specularConstant",
|
|
35
|
+
"specularExponent",
|
|
36
|
+
"diffuseConstant",
|
|
37
|
+
"edgeMode",
|
|
38
|
+
"targetX",
|
|
39
|
+
"targetY",
|
|
40
|
+
"xChannelSelector",
|
|
41
|
+
"yChannelSelector",
|
|
42
|
+
"limitingConeAngle",
|
|
43
|
+
"pointsAtX",
|
|
44
|
+
"pointsAtY",
|
|
45
|
+
"pointsAtZ",
|
|
46
|
+
"attributeName",
|
|
47
|
+
"attributeType",
|
|
48
|
+
"repeatCount",
|
|
49
|
+
"calcMode",
|
|
50
|
+
"keyTimes",
|
|
51
|
+
"keySplines",
|
|
52
|
+
]);
|
|
53
|
+
const SPECIAL_ATTRS = {
|
|
54
|
+
className: "class",
|
|
55
|
+
xlinkHref: "xlink:href",
|
|
56
|
+
xmlnsXlink: "xmlns:xlink",
|
|
57
|
+
xmlSpace: "xml:space",
|
|
58
|
+
};
|
|
59
|
+
// React-only props that are not SVG attributes.
|
|
60
|
+
const DROPPED_ATTRS = new Set(["key", "ref", "children"]);
|
|
61
|
+
// Maps a React prop name (strokeWidth) to its SVG attribute name (stroke-width).
|
|
62
|
+
export function svgAttrName(reactName) {
|
|
63
|
+
if (SPECIAL_ATTRS[reactName])
|
|
64
|
+
return SPECIAL_ATTRS[reactName];
|
|
65
|
+
if (CASE_SENSITIVE_ATTRS.has(reactName))
|
|
66
|
+
return reactName;
|
|
67
|
+
return reactName.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
68
|
+
}
|
|
69
|
+
function escapeAttr(value) {
|
|
70
|
+
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
71
|
+
}
|
|
72
|
+
// Serializes nodes to SVG markup, e.g. [{tag: "path", attr: {d: "M0 0"}}] -> '<path d="M0 0"/>'.
|
|
73
|
+
export function renderSvg(nodes) {
|
|
74
|
+
return nodes
|
|
75
|
+
.map((node) => {
|
|
76
|
+
const attrs = Object.entries(node.attr)
|
|
77
|
+
.filter(([name]) => !DROPPED_ATTRS.has(name))
|
|
78
|
+
.map(([name, value]) => ` ${svgAttrName(name)}="${escapeAttr(String(value))}"`)
|
|
79
|
+
.join("");
|
|
80
|
+
return node.child.length > 0
|
|
81
|
+
? `<${node.tag}${attrs}>${renderSvg(node.child)}</${node.tag}>`
|
|
82
|
+
: `<${node.tag}${attrs}/>`;
|
|
83
|
+
})
|
|
84
|
+
.join("");
|
|
85
|
+
}
|
|
86
|
+
// Keeps only string/number attribute values from a parsed object literal.
|
|
87
|
+
export function toSvgAttrs(value) {
|
|
88
|
+
const attrs = {};
|
|
89
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
90
|
+
for (const [key, v] of Object.entries(value)) {
|
|
91
|
+
if (typeof v === "string" || typeof v === "number")
|
|
92
|
+
attrs[key] = v;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return attrs;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=svg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"svg.js","sourceRoot":"","sources":["../../src/providers/svg.ts"],"names":[],"mappings":"AAQA,6FAA6F;AAC7F,MAAM,oBAAoB,GAAG,IAAI,GAAG,CAAC;IACnC,SAAS;IACT,qBAAqB;IACrB,aAAa;IACb,YAAY;IACZ,YAAY;IACZ,cAAc;IACd,aAAa;IACb,cAAc;IACd,eAAe;IACf,mBAAmB;IACnB,cAAc;IACd,qBAAqB;IACrB,kBAAkB;IAClB,eAAe;IACf,WAAW;IACX,kBAAkB;IAClB,aAAa;IACb,gBAAgB;IAChB,aAAa;IACb,aAAa;IACb,cAAc;IACd,MAAM;IACN,MAAM;IACN,cAAc;IACd,eAAe;IACf,YAAY;IACZ,aAAa;IACb,cAAc;IACd,kBAAkB;IAClB,aAAa;IACb,cAAc;IACd,kBAAkB;IAClB,kBAAkB;IAClB,iBAAiB;IACjB,UAAU;IACV,SAAS;IACT,SAAS;IACT,kBAAkB;IAClB,kBAAkB;IAClB,mBAAmB;IACnB,WAAW;IACX,WAAW;IACX,WAAW;IACX,eAAe;IACf,eAAe;IACf,aAAa;IACb,UAAU;IACV,UAAU;IACV,YA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,KAAK,CAAC,CAAC,GAAG,CAAC;aAC9E,IAAI,CAAC,EAAE,CAAC,CAAC;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC;YAC1B,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,GAAG,KAAK,IAAI,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,GAAG,GAAG;YAC/D,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,GAAG,KAAK,IAAI,CAAC;IAC/B,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,UAAU,CAAC,KAA0B;IACnD,MAAM,KAAK,GAAoC,EAAE,CAAC;IAClD,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAChE,KAAK,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7C,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,QAAQ;gBAAE,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { IconRecord, IndexMeta, Synonyms } from "../indexer/types.js";
|
|
2
|
+
export interface LoadedIndex {
|
|
3
|
+
records: IconRecord[];
|
|
4
|
+
meta: IndexMeta;
|
|
5
|
+
}
|
|
6
|
+
export interface SearchOptions {
|
|
7
|
+
/** Exact (case-insensitive) provider id filter, e.g. "lucide". */
|
|
8
|
+
provider?: string;
|
|
9
|
+
/** Exact (case-insensitive) style filter, e.g. "outline". */
|
|
10
|
+
style?: string;
|
|
11
|
+
/** Exact (case-insensitive) set filter, e.g. "fa6". */
|
|
12
|
+
set?: string;
|
|
13
|
+
/** Maximum number of results, applied after ranking. */
|
|
14
|
+
limit?: number;
|
|
15
|
+
}
|
|
16
|
+
export interface SearchResult {
|
|
17
|
+
record: IconRecord;
|
|
18
|
+
/** Fuse.js score: 0 is a perfect match, 1 is no match. */
|
|
19
|
+
score: number;
|
|
20
|
+
}
|
|
21
|
+
/** Reads index.json and meta.json from an index directory written by writeIndex. */
|
|
22
|
+
export declare function loadIndex(cacheDir: string): Promise<LoadedIndex>;
|
|
23
|
+
/** True when an index was built with different synonyms or an older index format. */
|
|
24
|
+
export declare function indexNeedsRebuild(meta: IndexMeta, synonyms: Synonyms): boolean;
|
|
25
|
+
/** Filters records by provider/style/set exactly, then ranks them against the query with Fuse.js. */
|
|
26
|
+
export declare function searchIcons(records: readonly IconRecord[], query: string, options?: SearchOptions): SearchResult[];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import Fuse from "fuse.js";
|
|
4
|
+
import { hashSynonyms, INDEX_FILE, INDEX_VERSION, META_FILE } from "../indexer/buildIndex.js";
|
|
5
|
+
/** Reads index.json and meta.json from an index directory written by writeIndex. */
|
|
6
|
+
export async function loadIndex(cacheDir) {
|
|
7
|
+
const [index, meta] = await Promise.all([
|
|
8
|
+
readFile(join(cacheDir, INDEX_FILE), "utf8"),
|
|
9
|
+
readFile(join(cacheDir, META_FILE), "utf8"),
|
|
10
|
+
]);
|
|
11
|
+
return { records: JSON.parse(index), meta: JSON.parse(meta) };
|
|
12
|
+
}
|
|
13
|
+
/** True when an index was built with different synonyms or an older index format. */
|
|
14
|
+
export function indexNeedsRebuild(meta, synonyms) {
|
|
15
|
+
return meta.indexVersion !== INDEX_VERSION || meta.synonymsHash !== hashSynonyms(synonyms);
|
|
16
|
+
}
|
|
17
|
+
const FUSE_OPTIONS = {
|
|
18
|
+
keys: [
|
|
19
|
+
{ name: "name", weight: 3 },
|
|
20
|
+
{ name: "importName", weight: 2 },
|
|
21
|
+
{ name: "keywords", weight: 2 },
|
|
22
|
+
{ name: "tags", weight: 1 },
|
|
23
|
+
],
|
|
24
|
+
includeScore: true,
|
|
25
|
+
// Match anywhere in the field; 0.4 tolerates a couple of typos in short words ("detele" -> "delete").
|
|
26
|
+
ignoreLocation: true,
|
|
27
|
+
threshold: 0.4,
|
|
28
|
+
minMatchCharLength: 2,
|
|
29
|
+
};
|
|
30
|
+
function matches(value, filter) {
|
|
31
|
+
return filter === undefined || value?.toLowerCase() === filter.toLowerCase();
|
|
32
|
+
}
|
|
33
|
+
/** Filters records by provider/style/set exactly, then ranks them against the query with Fuse.js. */
|
|
34
|
+
export function searchIcons(records, query, options = {}) {
|
|
35
|
+
const trimmed = query.trim();
|
|
36
|
+
if (!trimmed)
|
|
37
|
+
return [];
|
|
38
|
+
const { provider, style, set, limit } = options;
|
|
39
|
+
const filtered = records.filter((r) => matches(r.provider, provider) && matches(r.style, style) && matches(r.set, set));
|
|
40
|
+
const results = new Fuse(filtered, FUSE_OPTIONS)
|
|
41
|
+
.search(trimmed)
|
|
42
|
+
.map((result) => ({ record: result.item, score: result.score ?? 0 }));
|
|
43
|
+
return limit === undefined ? results : results.slice(0, Math.max(0, limit));
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search.js","sourceRoot":"","sources":["../../src/search/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,IAA2B,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAyB9F,oFAAoF;AACpF,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAgB;IAC9C,MAAM,C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GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,CAAC,OAAO;QAAE,OAAO,EAAE,CAAC;IACxB,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAChD,MAAM,QAAQ,GAAG,OAAO,CAAC,MAAM,CAC7B,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CACvF,CAAC;IACF,MAAM,OAAO,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC;SAC7C,MAAM,CAAC,OAAO,CAAC;SACf,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACxE,OAAO,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;AAC9E,CAAC"}
|
package/dist/server.d.ts
ADDED
package/dist/server.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { registerGetIconTool } from "./tools/getIcon.js";
|
|
3
|
+
import { registerListProvidersTool } from "./tools/listProviders.js";
|
|
4
|
+
import { registerPingTool } from "./tools/ping.js";
|
|
5
|
+
import { registerSearchIconsTool } from "./tools/searchIcons.js";
|
|
6
|
+
export const SERVER_NAME = "trueicon";
|
|
7
|
+
export const SERVER_VERSION = "0.1.0";
|
|
8
|
+
// Builds the MCP server with all tools registered. Transport wiring lives in index.ts.
|
|
9
|
+
export function createServer() {
|
|
10
|
+
const server = new McpServer({ name: SERVER_NAME, version: SERVER_VERSION });
|
|
11
|
+
registerPingTool(server);
|
|
12
|
+
registerSearchIconsTool(server);
|
|
13
|
+
registerListProvidersTool(server);
|
|
14
|
+
registerGetIconTool(server);
|
|
15
|
+
return server;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE,MAAM,CAAC,MAAM,WAAW,GAAG,UAAU,CAAC;AACtC,MAAM,CAAC,MAAM,cAAc,GAAG,OAAO,CAAC;AAEtC,uFAAuF;AACvF,MAAM,UAAU,YAAY;IAC1B,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC;IAE7E,gBAAgB,CAAC,MAAM,CAAC,CAAC;IACzB,uBAAuB,CAAC,MAAM,CAAC,CAAC;IAChC,yBAAyB,CAAC,MAAM,CAAC,CAAC;IAClC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAE5B,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Synonyms } from "../indexer/types.js";
|
|
2
|
+
/** Checks that `value` is an object mapping lowercase terms to arrays of lowercase strings. */
|
|
3
|
+
export declare function parseSynonyms(value: unknown): Synonyms;
|
|
4
|
+
/** Loads the synonyms bundled with the package (src/synonyms/synonyms.json). */
|
|
5
|
+
export declare function loadSynonyms(): Synonyms;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import bundled from "./synonyms.json" with { type: "json" };
|
|
2
|
+
/** Checks that `value` is an object mapping lowercase terms to arrays of lowercase strings. */
|
|
3
|
+
export function parseSynonyms(value) {
|
|
4
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) {
|
|
5
|
+
throw new Error("Synonyms must be an object of term -> string[]");
|
|
6
|
+
}
|
|
7
|
+
const synonyms = {};
|
|
8
|
+
for (const [term, alternates] of Object.entries(value)) {
|
|
9
|
+
if (!Array.isArray(alternates) || !alternates.every((a) => typeof a === "string")) {
|
|
10
|
+
throw new Error(`Synonyms for "${term}" must be an array of strings`);
|
|
11
|
+
}
|
|
12
|
+
synonyms[term.toLowerCase()] = alternates.map((a) => a.toLowerCase());
|
|
13
|
+
}
|
|
14
|
+
return synonyms;
|
|
15
|
+
}
|
|
16
|
+
/** Loads the synonyms bundled with the package (src/synonyms/synonyms.json). */
|
|
17
|
+
export function loadSynonyms() {
|
|
18
|
+
return parseSynonyms(bundled);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=loadSynonyms.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loadSynonyms.js","sourceRoot":"","sources":["../../src/synonyms/loadSynonyms.ts"],"names":[],"mappings":"AACA,OAAO,OAAO,MAAM,iBAAiB,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAE5D,+FAA+F;AAC/F,MAAM,UAAU,aAAa,CAAC,KAAc;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACxE,MAAM,IAAI,KAAK,CAAC,gDAAgD,CAAC,CAAC;IACpE,CAAC;IACD,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,KAAK,MAAM,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACvD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAe,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,EAAE,CAAC;YAC/F,MAAM,IAAI,KAAK,CAAC,iBAAiB,IAAI,+BAA+B,CAAC,CAAC;QACxE,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;IACxE,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,YAAY;IAC1B,OAAO,aAAa,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"trash": ["delete", "remove", "bin", "garbage", "rubbish"],
|
|
3
|
+
"delete": ["trash", "remove", "bin"],
|
|
4
|
+
"logout": ["sign-out", "signout", "exit", "leave"],
|
|
5
|
+
"login": ["sign-in", "signin", "enter"],
|
|
6
|
+
"exit": ["logout", "leave", "quit"],
|
|
7
|
+
"photo": ["image", "picture", "gallery"],
|
|
8
|
+
"image": ["photo", "picture", "gallery"],
|
|
9
|
+
"settings": ["gear", "cog", "preferences", "config"],
|
|
10
|
+
"gear": ["settings", "cog", "preferences"],
|
|
11
|
+
"cog": ["settings", "gear", "preferences"],
|
|
12
|
+
"home": ["house", "dashboard"],
|
|
13
|
+
"house": ["home"],
|
|
14
|
+
"search": ["magnify", "magnifying-glass", "find", "lookup"],
|
|
15
|
+
"magnify": ["search", "find"],
|
|
16
|
+
"magnifying": ["search", "find"],
|
|
17
|
+
"user": ["person", "account", "profile", "avatar"],
|
|
18
|
+
"person": ["user", "account", "profile"],
|
|
19
|
+
"account": ["user", "person", "profile"],
|
|
20
|
+
"profile": ["user", "person", "account"],
|
|
21
|
+
"edit": ["pencil", "pen", "write", "modify"],
|
|
22
|
+
"pencil": ["edit", "write"],
|
|
23
|
+
"plus": ["add", "new", "create"],
|
|
24
|
+
"add": ["plus", "new", "create"],
|
|
25
|
+
"minus": ["subtract", "remove", "less"],
|
|
26
|
+
"close": ["x", "cancel", "dismiss"],
|
|
27
|
+
"x": ["close", "cancel", "dismiss"],
|
|
28
|
+
"xmark": ["close", "x", "cancel"],
|
|
29
|
+
"menu": ["hamburger", "bars", "navigation"],
|
|
30
|
+
"bars": ["menu", "hamburger"],
|
|
31
|
+
"arrow": ["direction", "pointer"],
|
|
32
|
+
"up": ["north", "top"],
|
|
33
|
+
"down": ["south", "bottom"],
|
|
34
|
+
"left": ["west", "back", "previous"],
|
|
35
|
+
"right": ["east", "forward", "next"],
|
|
36
|
+
"chevron": ["caret", "angle", "arrow"],
|
|
37
|
+
"caret": ["chevron", "angle", "arrow"],
|
|
38
|
+
"check": ["tick", "done", "success", "confirm"],
|
|
39
|
+
"tick": ["check", "done"],
|
|
40
|
+
"warning": ["alert", "caution", "danger", "exclamation"],
|
|
41
|
+
"alert": ["warning", "caution", "exclamation"],
|
|
42
|
+
"info": ["information", "help", "about"],
|
|
43
|
+
"help": ["question", "info", "support"],
|
|
44
|
+
"heart": ["like", "love", "favorite"],
|
|
45
|
+
"star": ["favorite", "rating", "bookmark"],
|
|
46
|
+
"lock": ["secure", "private", "password", "locked"],
|
|
47
|
+
"unlock": ["open", "unlocked", "unsecure"],
|
|
48
|
+
"mail": ["email", "envelope", "message", "inbox"],
|
|
49
|
+
"email": ["mail", "envelope", "message"],
|
|
50
|
+
"envelope": ["mail", "email", "message"],
|
|
51
|
+
"phone": ["call", "telephone", "mobile"],
|
|
52
|
+
"calendar": ["date", "schedule", "event"],
|
|
53
|
+
"clock": ["time", "watch", "schedule"],
|
|
54
|
+
"download": ["save", "export"],
|
|
55
|
+
"upload": ["import", "send"],
|
|
56
|
+
"share": ["send", "export"],
|
|
57
|
+
"link": ["url", "chain", "hyperlink"],
|
|
58
|
+
"filter": ["funnel", "refine"],
|
|
59
|
+
"sort": ["order", "arrange"],
|
|
60
|
+
"refresh": ["reload", "sync", "update", "rotate"],
|
|
61
|
+
"reload": ["refresh", "sync"],
|
|
62
|
+
"sync": ["refresh", "reload"],
|
|
63
|
+
"play": ["start", "run", "resume"],
|
|
64
|
+
"pause": ["hold", "wait"],
|
|
65
|
+
"stop": ["halt", "end"],
|
|
66
|
+
"volume": ["sound", "speaker", "audio"],
|
|
67
|
+
"wifi": ["wireless", "network", "internet"],
|
|
68
|
+
"battery": ["power", "charge"],
|
|
69
|
+
"camera": ["photo", "snapshot"],
|
|
70
|
+
"map": ["location", "navigation"],
|
|
71
|
+
"location": ["pin", "marker", "place", "map"],
|
|
72
|
+
"pin": ["location", "marker", "place"],
|
|
73
|
+
"cart": ["basket", "shopping", "checkout"],
|
|
74
|
+
"basket": ["cart", "shopping"],
|
|
75
|
+
"shopping": ["cart", "basket", "bag"],
|
|
76
|
+
"bell": ["notification", "alarm", "alert"],
|
|
77
|
+
"chat": ["message", "comment", "conversation"],
|
|
78
|
+
"copy": ["duplicate", "clone"],
|
|
79
|
+
"eye": ["view", "visible", "show"]
|
|
80
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import { type ProjectConfig } from "../config/loadConfig.js";
|
|
3
|
+
import type { IconRecord, Synonyms } from "../indexer/types.js";
|
|
4
|
+
/** Everything the icon tools need from their environment. */
|
|
5
|
+
export interface ToolContext {
|
|
6
|
+
projectDir: string;
|
|
7
|
+
cacheRoot: string;
|
|
8
|
+
synonyms: Synonyms;
|
|
9
|
+
}
|
|
10
|
+
export type VersionSource = "iconmcp.json" | "package.json";
|
|
11
|
+
export interface ResolvedVersion {
|
|
12
|
+
version: string;
|
|
13
|
+
source: VersionSource;
|
|
14
|
+
}
|
|
15
|
+
/** Resolves the context from $TRUEICON_PROJECT_DIR (else cwd), the cache root and the bundled synonyms. */
|
|
16
|
+
export declare function resolveContext(): ToolContext;
|
|
17
|
+
/** The import statement for an icon, e.g. "import { Trash2 } from 'lucide-react';". */
|
|
18
|
+
export declare function usageSnippet(record: IconRecord): string;
|
|
19
|
+
/**
|
|
20
|
+
* Version for packageName: the .iconmcp.json pin, else the range in package.json.
|
|
21
|
+
* Returns null when neither is available.
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveVersion(projectDir: string, config: ProjectConfig, packageName: string): ResolvedVersion | null;
|
|
24
|
+
export declare function errorMessage(error: unknown): string;
|
|
25
|
+
/** Runs a tool body and wraps its result (or error) as MCP JSON text content. */
|
|
26
|
+
export declare function jsonToolResult(run: () => unknown): Promise<CallToolResult>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { resolveCacheRoot } from "../cache/downloader.js";
|
|
2
|
+
import { detectVersion } from "../config/loadConfig.js";
|
|
3
|
+
import { loadSynonyms } from "../synonyms/loadSynonyms.js";
|
|
4
|
+
/** Resolves the context from $TRUEICON_PROJECT_DIR (else cwd), the cache root and the bundled synonyms. */
|
|
5
|
+
export function resolveContext() {
|
|
6
|
+
return {
|
|
7
|
+
projectDir: process.env.TRUEICON_PROJECT_DIR ?? process.cwd(),
|
|
8
|
+
cacheRoot: resolveCacheRoot({}),
|
|
9
|
+
synonyms: loadSynonyms(),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
/** The import statement for an icon, e.g. "import { Trash2 } from 'lucide-react';". */
|
|
13
|
+
export function usageSnippet(record) {
|
|
14
|
+
return `import { ${record.importName} } from '${record.importPath}';`;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Version for packageName: the .iconmcp.json pin, else the range in package.json.
|
|
18
|
+
* Returns null when neither is available.
|
|
19
|
+
*/
|
|
20
|
+
export function resolveVersion(projectDir, config, packageName) {
|
|
21
|
+
const pinned = config.providers.find((p) => p.package === packageName)?.version;
|
|
22
|
+
if (pinned !== undefined)
|
|
23
|
+
return { version: pinned, source: "iconmcp.json" };
|
|
24
|
+
try {
|
|
25
|
+
return { version: detectVersion(projectDir, packageName), source: "package.json" };
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export function errorMessage(error) {
|
|
32
|
+
return error instanceof Error ? error.message : String(error);
|
|
33
|
+
}
|
|
34
|
+
/** Runs a tool body and wraps its result (or error) as MCP JSON text content. */
|
|
35
|
+
export async function jsonToolResult(run) {
|
|
36
|
+
try {
|
|
37
|
+
return { content: [{ type: "text", text: JSON.stringify(await run()) }] };
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
return { content: [{ type: "text", text: JSON.stringify({ error: errorMessage(error) }) }], isError: true };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/tools/context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAsB,MAAM,yBAAyB,CAAC;AAE5E,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAgB3D,2GAA2G;AAC3G,MAAM,UAAU,cAAc;IAC5B,OAAO;QACL,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,OAAO,CAAC,GAAG,EAAE;QAC7D,SAAS,EAAE,gBAAgB,CAAC,EAAE,CAAC;QAC/B,QAAQ,EAAE,YAAY,EAAE;KACzB,CAAC;AACJ,CAAC;AAED,uFAAuF;AACvF,MAAM,UAAU,YAAY,CAAC,MAAkB;IAC7C,OAAO,Y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G,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import type { IconRecord } from "../indexer/types.js";
|
|
3
|
+
import { type ToolContext } from "./context.js";
|
|
4
|
+
export interface GetIconInput {
|
|
5
|
+
/** Icon name ("trash-2") or import name ("Trash2"). */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Provider id or npm package name. */
|
|
8
|
+
provider: string;
|
|
9
|
+
version?: string;
|
|
10
|
+
}
|
|
11
|
+
export type GetIconOutput = IconRecord & {
|
|
12
|
+
usage: string;
|
|
13
|
+
};
|
|
14
|
+
/** Looks up one icon by name or import name and returns its full record plus an import snippet. */
|
|
15
|
+
export declare function getIconTool(input: GetIconInput, ctx: ToolContext): Promise<GetIconOutput>;
|
|
16
|
+
export declare function registerGetIconTool(server: McpServer): void;
|