@lism-css/mcp 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 +76 -0
- package/bin/lism-mcp.mjs +2 -0
- package/dist/data/components.json +366 -0
- package/dist/data/docs-index.json +646 -0
- package/dist/data/meta.d.ts +2 -0
- package/dist/data/meta.js +5 -0
- package/dist/data/overview.json +80 -0
- package/dist/data/props-system.json +596 -0
- package/dist/data/tokens.json +131 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +26 -0
- package/dist/lib/load-data.d.ts +3 -0
- package/dist/lib/load-data.js +29 -0
- package/dist/lib/response.d.ts +14 -0
- package/dist/lib/response.js +28 -0
- package/dist/lib/schemas.d.ts +232 -0
- package/dist/lib/schemas.js +65 -0
- package/dist/lib/search.d.ts +2 -0
- package/dist/lib/search.js +57 -0
- package/dist/lib/types.d.ts +76 -0
- package/dist/lib/types.js +1 -0
- package/dist/tools/get-component.d.ts +2 -0
- package/dist/tools/get-component.js +39 -0
- package/dist/tools/get-overview.d.ts +2 -0
- package/dist/tools/get-overview.js +50 -0
- package/dist/tools/get-props-system.d.ts +2 -0
- package/dist/tools/get-props-system.js +32 -0
- package/dist/tools/get-tokens.d.ts +2 -0
- package/dist/tools/get-tokens.js +19 -0
- package/dist/tools/search-docs.d.ts +2 -0
- package/dist/tools/search-docs.js +22 -0
- package/package.json +29 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"category": "color",
|
|
4
|
+
"description": "セマンティックカラートークン。サイト全体のカラー設計に使用。",
|
|
5
|
+
"tokens": [
|
|
6
|
+
{ "name": "--base", "value": "サイトの基本背景色", "description": "ベース背景色" },
|
|
7
|
+
{ "name": "--base-2", "value": "サイトの第2背景色", "description": "代替背景色" },
|
|
8
|
+
{ "name": "--text", "value": "メインのテキストカラー", "description": "基本テキスト色" },
|
|
9
|
+
{ "name": "--text-2", "value": "サブテキストカラー", "description": "補助テキスト色" },
|
|
10
|
+
{ "name": "--divider", "value": "ボーダー・区切り線の色", "description": "区切り線色" },
|
|
11
|
+
{ "name": "--link", "value": "リンクテキスト色", "description": "リンク色" },
|
|
12
|
+
{ "name": "--brand", "value": "ブランドカラー", "description": "ブランド色" },
|
|
13
|
+
{ "name": "--accent", "value": "アクセントカラー", "description": "アクセント色" }
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"category": "color",
|
|
18
|
+
"description": "パレットカラートークン。装飾やバリエーションに使用。",
|
|
19
|
+
"tokens": [
|
|
20
|
+
{ "name": "--red", "value": "赤系カラー" },
|
|
21
|
+
{ "name": "--blue", "value": "青系カラー" },
|
|
22
|
+
{ "name": "--green", "value": "緑系カラー" },
|
|
23
|
+
{ "name": "--yellow", "value": "黄系カラー" },
|
|
24
|
+
{ "name": "--purple", "value": "紫系カラー" },
|
|
25
|
+
{ "name": "--orange", "value": "オレンジ系カラー" },
|
|
26
|
+
{ "name": "--pink", "value": "ピンク系カラー" },
|
|
27
|
+
{ "name": "--gray", "value": "グレー系カラー" },
|
|
28
|
+
{ "name": "--white", "value": "白" },
|
|
29
|
+
{ "name": "--black", "value": "黒" },
|
|
30
|
+
{ "name": "--keycolor", "value": "コンポーネントごとのキーカラー" }
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"category": "spacing",
|
|
35
|
+
"description": "スペーシングトークン。padding, margin, gap 等で使用。CSS変数名は --s{値}。",
|
|
36
|
+
"tokens": [
|
|
37
|
+
{ "name": "--s5", "value": "最小の余白 (step 5)" },
|
|
38
|
+
{ "name": "--s10", "value": "余白 step 10" },
|
|
39
|
+
{ "name": "--s15", "value": "余白 step 15" },
|
|
40
|
+
{ "name": "--s20", "value": "余白 step 20" },
|
|
41
|
+
{ "name": "--s30", "value": "余白 step 30" },
|
|
42
|
+
{ "name": "--s40", "value": "余白 step 40" },
|
|
43
|
+
{ "name": "--s50", "value": "余白 step 50" },
|
|
44
|
+
{ "name": "--s60", "value": "余白 step 60" },
|
|
45
|
+
{ "name": "--s70", "value": "余白 step 70" },
|
|
46
|
+
{ "name": "--s80", "value": "最大の余白 (step 80)" }
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"category": "fontSize",
|
|
51
|
+
"description": "フォントサイズトークン。CSS変数名は --fz--{値}。",
|
|
52
|
+
"tokens": [
|
|
53
|
+
{ "name": "--fz--root", "value": "ルートのフォントサイズ" },
|
|
54
|
+
{ "name": "--fz--base", "value": "本文の基本フォントサイズ" },
|
|
55
|
+
{ "name": "--fz--5xl", "value": "最大サイズ" },
|
|
56
|
+
{ "name": "--fz--4xl", "value": "特大サイズ" },
|
|
57
|
+
{ "name": "--fz--3xl", "value": "3XLサイズ" },
|
|
58
|
+
{ "name": "--fz--2xl", "value": "2XLサイズ" },
|
|
59
|
+
{ "name": "--fz--xl", "value": "XLサイズ" },
|
|
60
|
+
{ "name": "--fz--l", "value": "Lサイズ" },
|
|
61
|
+
{ "name": "--fz--m", "value": "Mサイズ" },
|
|
62
|
+
{ "name": "--fz--s", "value": "Sサイズ" },
|
|
63
|
+
{ "name": "--fz--xs", "value": "XSサイズ" },
|
|
64
|
+
{ "name": "--fz--2xs", "value": "最小サイズ" }
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"category": "lineHeight",
|
|
69
|
+
"description": "行間 (heading line-height) トークン。CSS変数名は --hl--{値}。",
|
|
70
|
+
"tokens": [
|
|
71
|
+
{ "name": "--hl--base", "value": "基本の行間" },
|
|
72
|
+
{ "name": "--hl--xs", "value": "極小の行間" },
|
|
73
|
+
{ "name": "--hl--s", "value": "小さめの行間" },
|
|
74
|
+
{ "name": "--hl--l", "value": "大きめの行間" }
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"category": "letterSpacing",
|
|
79
|
+
"description": "文字間隔トークン。CSS変数名は --lts--{値}。",
|
|
80
|
+
"tokens": [
|
|
81
|
+
{ "name": "--lts--base", "value": "基本の文字間隔" },
|
|
82
|
+
{ "name": "--lts--s", "value": "狭めの文字間隔" },
|
|
83
|
+
{ "name": "--lts--l", "value": "広めの文字間隔" }
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"category": "fontFamily",
|
|
88
|
+
"description": "フォントファミリートークン。CSS変数名は --ff--{値}。",
|
|
89
|
+
"tokens": [
|
|
90
|
+
{ "name": "--ff--base", "value": "基本フォント" },
|
|
91
|
+
{ "name": "--ff--accent", "value": "アクセントフォント" },
|
|
92
|
+
{ "name": "--ff--mono", "value": "モノスペースフォント" }
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"category": "radius",
|
|
97
|
+
"description": "角丸トークン。CSS変数名は --bdrs--{値}。段階的に値が大きくなる。",
|
|
98
|
+
"tokens": [
|
|
99
|
+
{ "name": "--bdrs--5", "value": "角丸 step 5" },
|
|
100
|
+
{ "name": "--bdrs--10", "value": "角丸 step 10" },
|
|
101
|
+
{ "name": "--bdrs--20", "value": "角丸 step 20" },
|
|
102
|
+
{ "name": "--bdrs--30", "value": "角丸 step 30" },
|
|
103
|
+
{ "name": "--bdrs--40", "value": "角丸 step 40" },
|
|
104
|
+
{ "name": "--bdrs--50", "value": "角丸 step 50" },
|
|
105
|
+
{ "name": "--bdrs--99", "value": "完全な丸 (pill)" },
|
|
106
|
+
{ "name": "--bdrs--inner", "value": "内側の角丸 (親要素に合わせる)" }
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"category": "shadow",
|
|
111
|
+
"description": "ボックスシャドウトークン。CSS変数名は --bxsh--{値}。段階的に影が強くなる。",
|
|
112
|
+
"tokens": [
|
|
113
|
+
{ "name": "--bxsh--5", "value": "シャドウ step 5 (最も薄い)" },
|
|
114
|
+
{ "name": "--bxsh--10", "value": "シャドウ step 10" },
|
|
115
|
+
{ "name": "--bxsh--20", "value": "シャドウ step 20" },
|
|
116
|
+
{ "name": "--bxsh--30", "value": "シャドウ step 30" },
|
|
117
|
+
{ "name": "--bxsh--40", "value": "シャドウ step 40" },
|
|
118
|
+
{ "name": "--bxsh--50", "value": "シャドウ step 50 (最も濃い)" }
|
|
119
|
+
]
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"category": "zIndex",
|
|
123
|
+
"description": "z-index プリセット値。",
|
|
124
|
+
"tokens": [
|
|
125
|
+
{ "name": "-1", "value": "-1" },
|
|
126
|
+
{ "name": "0", "value": "0" },
|
|
127
|
+
{ "name": "1", "value": "1" },
|
|
128
|
+
{ "name": "99", "value": "99" }
|
|
129
|
+
]
|
|
130
|
+
}
|
|
131
|
+
]
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
3
|
+
import { preloadAll } from './lib/load-data.js';
|
|
4
|
+
import { registerGetOverview } from './tools/get-overview.js';
|
|
5
|
+
import { registerGetTokens } from './tools/get-tokens.js';
|
|
6
|
+
import { registerGetPropsSystem } from './tools/get-props-system.js';
|
|
7
|
+
import { registerGetComponent } from './tools/get-component.js';
|
|
8
|
+
import { registerSearchDocs } from './tools/search-docs.js';
|
|
9
|
+
async function main() {
|
|
10
|
+
preloadAll();
|
|
11
|
+
const server = new McpServer({
|
|
12
|
+
name: 'lism-css',
|
|
13
|
+
version: '0.1.0',
|
|
14
|
+
});
|
|
15
|
+
registerGetOverview(server);
|
|
16
|
+
registerGetTokens(server);
|
|
17
|
+
registerGetPropsSystem(server);
|
|
18
|
+
registerGetComponent(server);
|
|
19
|
+
registerSearchDocs(server);
|
|
20
|
+
const transport = new StdioServerTransport();
|
|
21
|
+
await server.connect(transport);
|
|
22
|
+
}
|
|
23
|
+
main().catch((err) => {
|
|
24
|
+
console.error('MCP server failed to start:', err);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, resolve } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { OverviewDataSchema, TokenCategorySchema, PropsSystemDataSchema, ComponentInfoSchema, DocsEntrySchema } from './schemas.js';
|
|
6
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
const dataDir = resolve(__dirname, '..', 'data');
|
|
8
|
+
const cache = new Map();
|
|
9
|
+
export function loadJSON(filename, schema) {
|
|
10
|
+
if (cache.has(filename))
|
|
11
|
+
return cache.get(filename);
|
|
12
|
+
const filePath = resolve(dataDir, filename);
|
|
13
|
+
const raw = readFileSync(filePath, 'utf-8');
|
|
14
|
+
const data = schema.parse(JSON.parse(raw));
|
|
15
|
+
cache.set(filename, data);
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
18
|
+
export function preloadAll() {
|
|
19
|
+
const entries = [
|
|
20
|
+
{ filename: 'overview.json', schema: OverviewDataSchema },
|
|
21
|
+
{ filename: 'tokens.json', schema: z.array(TokenCategorySchema) },
|
|
22
|
+
{ filename: 'props-system.json', schema: PropsSystemDataSchema },
|
|
23
|
+
{ filename: 'components.json', schema: z.array(ComponentInfoSchema) },
|
|
24
|
+
{ filename: 'docs-index.json', schema: z.array(DocsEntrySchema) },
|
|
25
|
+
];
|
|
26
|
+
for (const { filename, schema } of entries) {
|
|
27
|
+
loadJSON(filename, schema);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ToolAnnotations } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
export declare const READ_ONLY_ANNOTATIONS: ToolAnnotations;
|
|
3
|
+
type ToolResult = {
|
|
4
|
+
content: {
|
|
5
|
+
type: 'text';
|
|
6
|
+
text: string;
|
|
7
|
+
}[];
|
|
8
|
+
isError?: boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare function success(data: Record<string, unknown>): ToolResult;
|
|
11
|
+
export declare function notFound(message: string, extra?: Record<string, unknown>): ToolResult;
|
|
12
|
+
export declare function error(message: string, extra?: Record<string, unknown>): ToolResult;
|
|
13
|
+
export declare function markdownResponse(text: string): ToolResult;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { meta } from '../data/meta.js';
|
|
2
|
+
export const READ_ONLY_ANNOTATIONS = {
|
|
3
|
+
readOnlyHint: true,
|
|
4
|
+
destructiveHint: false,
|
|
5
|
+
idempotentHint: true,
|
|
6
|
+
openWorldHint: false,
|
|
7
|
+
};
|
|
8
|
+
export function success(data) {
|
|
9
|
+
return {
|
|
10
|
+
content: [{ type: 'text', text: JSON.stringify({ meta, ...data }, null, 2) }],
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function notFound(message, extra) {
|
|
14
|
+
return {
|
|
15
|
+
content: [{ type: 'text', text: JSON.stringify({ meta, error: message, ...extra }, null, 2) }],
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function error(message, extra) {
|
|
19
|
+
return {
|
|
20
|
+
content: [{ type: 'text', text: JSON.stringify({ meta, error: message, ...extra }, null, 2) }],
|
|
21
|
+
isError: true,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export function markdownResponse(text) {
|
|
25
|
+
return {
|
|
26
|
+
content: [{ type: 'text', text }],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const DocsEntrySchema: z.ZodObject<{
|
|
3
|
+
sourcePath: z.ZodString;
|
|
4
|
+
title: z.ZodString;
|
|
5
|
+
description: z.ZodString;
|
|
6
|
+
category: z.ZodString;
|
|
7
|
+
headings: z.ZodArray<z.ZodString, "many">;
|
|
8
|
+
keywords: z.ZodArray<z.ZodString, "many">;
|
|
9
|
+
snippet: z.ZodString;
|
|
10
|
+
}, "strip", z.ZodTypeAny, {
|
|
11
|
+
sourcePath: string;
|
|
12
|
+
title: string;
|
|
13
|
+
description: string;
|
|
14
|
+
category: string;
|
|
15
|
+
headings: string[];
|
|
16
|
+
keywords: string[];
|
|
17
|
+
snippet: string;
|
|
18
|
+
}, {
|
|
19
|
+
sourcePath: string;
|
|
20
|
+
title: string;
|
|
21
|
+
description: string;
|
|
22
|
+
category: string;
|
|
23
|
+
headings: string[];
|
|
24
|
+
keywords: string[];
|
|
25
|
+
snippet: string;
|
|
26
|
+
}>;
|
|
27
|
+
export declare const ComponentInfoSchema: z.ZodObject<{
|
|
28
|
+
name: z.ZodString;
|
|
29
|
+
package: z.ZodEnum<["lism-css", "@lism-css/ui"]>;
|
|
30
|
+
category: z.ZodString;
|
|
31
|
+
description: z.ZodString;
|
|
32
|
+
props: z.ZodArray<z.ZodObject<{
|
|
33
|
+
name: z.ZodString;
|
|
34
|
+
type: z.ZodString;
|
|
35
|
+
default: z.ZodOptional<z.ZodString>;
|
|
36
|
+
description: z.ZodString;
|
|
37
|
+
}, "strip", z.ZodTypeAny, {
|
|
38
|
+
description: string;
|
|
39
|
+
type: string;
|
|
40
|
+
name: string;
|
|
41
|
+
default?: string | undefined;
|
|
42
|
+
}, {
|
|
43
|
+
description: string;
|
|
44
|
+
type: string;
|
|
45
|
+
name: string;
|
|
46
|
+
default?: string | undefined;
|
|
47
|
+
}>, "many">;
|
|
48
|
+
usage: z.ZodString;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
description: string;
|
|
51
|
+
category: string;
|
|
52
|
+
name: string;
|
|
53
|
+
package: "lism-css" | "@lism-css/ui";
|
|
54
|
+
props: {
|
|
55
|
+
description: string;
|
|
56
|
+
type: string;
|
|
57
|
+
name: string;
|
|
58
|
+
default?: string | undefined;
|
|
59
|
+
}[];
|
|
60
|
+
usage: string;
|
|
61
|
+
}, {
|
|
62
|
+
description: string;
|
|
63
|
+
category: string;
|
|
64
|
+
name: string;
|
|
65
|
+
package: "lism-css" | "@lism-css/ui";
|
|
66
|
+
props: {
|
|
67
|
+
description: string;
|
|
68
|
+
type: string;
|
|
69
|
+
name: string;
|
|
70
|
+
default?: string | undefined;
|
|
71
|
+
}[];
|
|
72
|
+
usage: string;
|
|
73
|
+
}>;
|
|
74
|
+
export declare const TokenCategorySchema: z.ZodObject<{
|
|
75
|
+
category: z.ZodString;
|
|
76
|
+
description: z.ZodString;
|
|
77
|
+
tokens: z.ZodArray<z.ZodObject<{
|
|
78
|
+
name: z.ZodString;
|
|
79
|
+
value: z.ZodString;
|
|
80
|
+
description: z.ZodOptional<z.ZodString>;
|
|
81
|
+
}, "strip", z.ZodTypeAny, {
|
|
82
|
+
value: string;
|
|
83
|
+
name: string;
|
|
84
|
+
description?: string | undefined;
|
|
85
|
+
}, {
|
|
86
|
+
value: string;
|
|
87
|
+
name: string;
|
|
88
|
+
description?: string | undefined;
|
|
89
|
+
}>, "many">;
|
|
90
|
+
}, "strip", z.ZodTypeAny, {
|
|
91
|
+
description: string;
|
|
92
|
+
category: string;
|
|
93
|
+
tokens: {
|
|
94
|
+
value: string;
|
|
95
|
+
name: string;
|
|
96
|
+
description?: string | undefined;
|
|
97
|
+
}[];
|
|
98
|
+
}, {
|
|
99
|
+
description: string;
|
|
100
|
+
category: string;
|
|
101
|
+
tokens: {
|
|
102
|
+
value: string;
|
|
103
|
+
name: string;
|
|
104
|
+
description?: string | undefined;
|
|
105
|
+
}[];
|
|
106
|
+
}>;
|
|
107
|
+
export declare const PropsSystemDataSchema: z.ZodObject<{
|
|
108
|
+
description: z.ZodString;
|
|
109
|
+
categories: z.ZodArray<z.ZodObject<{
|
|
110
|
+
category: z.ZodString;
|
|
111
|
+
description: z.ZodString;
|
|
112
|
+
props: z.ZodArray<z.ZodObject<{
|
|
113
|
+
prop: z.ZodString;
|
|
114
|
+
cssProperty: z.ZodString;
|
|
115
|
+
type: z.ZodString;
|
|
116
|
+
responsive: z.ZodBoolean;
|
|
117
|
+
description: z.ZodString;
|
|
118
|
+
values: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
119
|
+
}, "strip", z.ZodTypeAny, {
|
|
120
|
+
description: string;
|
|
121
|
+
type: string;
|
|
122
|
+
prop: string;
|
|
123
|
+
cssProperty: string;
|
|
124
|
+
responsive: boolean;
|
|
125
|
+
values?: string[] | undefined;
|
|
126
|
+
}, {
|
|
127
|
+
description: string;
|
|
128
|
+
type: string;
|
|
129
|
+
prop: string;
|
|
130
|
+
cssProperty: string;
|
|
131
|
+
responsive: boolean;
|
|
132
|
+
values?: string[] | undefined;
|
|
133
|
+
}>, "many">;
|
|
134
|
+
}, "strip", z.ZodTypeAny, {
|
|
135
|
+
description: string;
|
|
136
|
+
category: string;
|
|
137
|
+
props: {
|
|
138
|
+
description: string;
|
|
139
|
+
type: string;
|
|
140
|
+
prop: string;
|
|
141
|
+
cssProperty: string;
|
|
142
|
+
responsive: boolean;
|
|
143
|
+
values?: string[] | undefined;
|
|
144
|
+
}[];
|
|
145
|
+
}, {
|
|
146
|
+
description: string;
|
|
147
|
+
category: string;
|
|
148
|
+
props: {
|
|
149
|
+
description: string;
|
|
150
|
+
type: string;
|
|
151
|
+
prop: string;
|
|
152
|
+
cssProperty: string;
|
|
153
|
+
responsive: boolean;
|
|
154
|
+
values?: string[] | undefined;
|
|
155
|
+
}[];
|
|
156
|
+
}>, "many">;
|
|
157
|
+
}, "strip", z.ZodTypeAny, {
|
|
158
|
+
description: string;
|
|
159
|
+
categories: {
|
|
160
|
+
description: string;
|
|
161
|
+
category: string;
|
|
162
|
+
props: {
|
|
163
|
+
description: string;
|
|
164
|
+
type: string;
|
|
165
|
+
prop: string;
|
|
166
|
+
cssProperty: string;
|
|
167
|
+
responsive: boolean;
|
|
168
|
+
values?: string[] | undefined;
|
|
169
|
+
}[];
|
|
170
|
+
}[];
|
|
171
|
+
}, {
|
|
172
|
+
description: string;
|
|
173
|
+
categories: {
|
|
174
|
+
description: string;
|
|
175
|
+
category: string;
|
|
176
|
+
props: {
|
|
177
|
+
description: string;
|
|
178
|
+
type: string;
|
|
179
|
+
prop: string;
|
|
180
|
+
cssProperty: string;
|
|
181
|
+
responsive: boolean;
|
|
182
|
+
values?: string[] | undefined;
|
|
183
|
+
}[];
|
|
184
|
+
}[];
|
|
185
|
+
}>;
|
|
186
|
+
export declare const OverviewDataSchema: z.ZodObject<{
|
|
187
|
+
description: z.ZodString;
|
|
188
|
+
architecture: z.ZodString;
|
|
189
|
+
packages: z.ZodArray<z.ZodObject<{
|
|
190
|
+
name: z.ZodString;
|
|
191
|
+
npmName: z.ZodString;
|
|
192
|
+
description: z.ZodString;
|
|
193
|
+
version: z.ZodString;
|
|
194
|
+
}, "strip", z.ZodTypeAny, {
|
|
195
|
+
description: string;
|
|
196
|
+
name: string;
|
|
197
|
+
npmName: string;
|
|
198
|
+
version: string;
|
|
199
|
+
}, {
|
|
200
|
+
description: string;
|
|
201
|
+
name: string;
|
|
202
|
+
npmName: string;
|
|
203
|
+
version: string;
|
|
204
|
+
}>, "many">;
|
|
205
|
+
breakpoints: z.ZodRecord<z.ZodString, z.ZodString>;
|
|
206
|
+
installation: z.ZodString;
|
|
207
|
+
cssLayers: z.ZodString;
|
|
208
|
+
}, "strip", z.ZodTypeAny, {
|
|
209
|
+
description: string;
|
|
210
|
+
architecture: string;
|
|
211
|
+
packages: {
|
|
212
|
+
description: string;
|
|
213
|
+
name: string;
|
|
214
|
+
npmName: string;
|
|
215
|
+
version: string;
|
|
216
|
+
}[];
|
|
217
|
+
breakpoints: Record<string, string>;
|
|
218
|
+
installation: string;
|
|
219
|
+
cssLayers: string;
|
|
220
|
+
}, {
|
|
221
|
+
description: string;
|
|
222
|
+
architecture: string;
|
|
223
|
+
packages: {
|
|
224
|
+
description: string;
|
|
225
|
+
name: string;
|
|
226
|
+
npmName: string;
|
|
227
|
+
version: string;
|
|
228
|
+
}[];
|
|
229
|
+
breakpoints: Record<string, string>;
|
|
230
|
+
installation: string;
|
|
231
|
+
cssLayers: string;
|
|
232
|
+
}>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export const DocsEntrySchema = z.object({
|
|
3
|
+
sourcePath: z.string(),
|
|
4
|
+
title: z.string(),
|
|
5
|
+
description: z.string(),
|
|
6
|
+
category: z.string(),
|
|
7
|
+
headings: z.array(z.string()),
|
|
8
|
+
keywords: z.array(z.string()),
|
|
9
|
+
snippet: z.string(),
|
|
10
|
+
});
|
|
11
|
+
const ComponentPropSchema = z.object({
|
|
12
|
+
name: z.string(),
|
|
13
|
+
type: z.string(),
|
|
14
|
+
default: z.string().optional(),
|
|
15
|
+
description: z.string(),
|
|
16
|
+
});
|
|
17
|
+
export const ComponentInfoSchema = z.object({
|
|
18
|
+
name: z.string(),
|
|
19
|
+
package: z.enum(['lism-css', '@lism-css/ui']),
|
|
20
|
+
category: z.string(),
|
|
21
|
+
description: z.string(),
|
|
22
|
+
props: z.array(ComponentPropSchema),
|
|
23
|
+
usage: z.string(),
|
|
24
|
+
});
|
|
25
|
+
const TokenEntrySchema = z.object({
|
|
26
|
+
name: z.string(),
|
|
27
|
+
value: z.string(),
|
|
28
|
+
description: z.string().optional(),
|
|
29
|
+
});
|
|
30
|
+
export const TokenCategorySchema = z.object({
|
|
31
|
+
category: z.string(),
|
|
32
|
+
description: z.string(),
|
|
33
|
+
tokens: z.array(TokenEntrySchema),
|
|
34
|
+
});
|
|
35
|
+
const PropEntrySchema = z.object({
|
|
36
|
+
prop: z.string(),
|
|
37
|
+
cssProperty: z.string(),
|
|
38
|
+
type: z.string(),
|
|
39
|
+
responsive: z.boolean(),
|
|
40
|
+
description: z.string(),
|
|
41
|
+
values: z.array(z.string()).optional(),
|
|
42
|
+
});
|
|
43
|
+
const PropCategorySchema = z.object({
|
|
44
|
+
category: z.string(),
|
|
45
|
+
description: z.string(),
|
|
46
|
+
props: z.array(PropEntrySchema),
|
|
47
|
+
});
|
|
48
|
+
export const PropsSystemDataSchema = z.object({
|
|
49
|
+
description: z.string(),
|
|
50
|
+
categories: z.array(PropCategorySchema),
|
|
51
|
+
});
|
|
52
|
+
const PackageInfoSchema = z.object({
|
|
53
|
+
name: z.string(),
|
|
54
|
+
npmName: z.string(),
|
|
55
|
+
description: z.string(),
|
|
56
|
+
version: z.string(),
|
|
57
|
+
});
|
|
58
|
+
export const OverviewDataSchema = z.object({
|
|
59
|
+
description: z.string(),
|
|
60
|
+
architecture: z.string(),
|
|
61
|
+
packages: z.array(PackageInfoSchema),
|
|
62
|
+
breakpoints: z.record(z.string()),
|
|
63
|
+
installation: z.string(),
|
|
64
|
+
cssLayers: z.string(),
|
|
65
|
+
});
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
function tokenize(text) {
|
|
2
|
+
return text
|
|
3
|
+
.toLowerCase()
|
|
4
|
+
.split(/[\s\-_./]+/)
|
|
5
|
+
.filter((t) => t.length > 0);
|
|
6
|
+
}
|
|
7
|
+
function scoreEntry(entry, queryTokens) {
|
|
8
|
+
let score = 0;
|
|
9
|
+
const titleLower = entry.title.toLowerCase();
|
|
10
|
+
const descLower = entry.description.toLowerCase();
|
|
11
|
+
const headingsLower = entry.headings.join(' ').toLowerCase();
|
|
12
|
+
const keywordsLower = entry.keywords.join(' ').toLowerCase();
|
|
13
|
+
const snippetLower = entry.snippet.toLowerCase();
|
|
14
|
+
for (const token of queryTokens) {
|
|
15
|
+
// title matches are weighted highest
|
|
16
|
+
if (titleLower.includes(token))
|
|
17
|
+
score += 10;
|
|
18
|
+
// keywords
|
|
19
|
+
if (keywordsLower.includes(token))
|
|
20
|
+
score += 5;
|
|
21
|
+
// headings
|
|
22
|
+
if (headingsLower.includes(token))
|
|
23
|
+
score += 3;
|
|
24
|
+
// description
|
|
25
|
+
if (descLower.includes(token))
|
|
26
|
+
score += 2;
|
|
27
|
+
// snippet
|
|
28
|
+
if (snippetLower.includes(token))
|
|
29
|
+
score += 1;
|
|
30
|
+
}
|
|
31
|
+
return score;
|
|
32
|
+
}
|
|
33
|
+
export function searchDocs(entries, query, category, limit = 10) {
|
|
34
|
+
const queryTokens = tokenize(query);
|
|
35
|
+
if (queryTokens.length === 0)
|
|
36
|
+
return [];
|
|
37
|
+
let filtered = entries;
|
|
38
|
+
if (category && category !== 'all') {
|
|
39
|
+
filtered = entries.filter((e) => e.category === category);
|
|
40
|
+
}
|
|
41
|
+
const scored = filtered
|
|
42
|
+
.map((entry) => {
|
|
43
|
+
const score = scoreEntry(entry, queryTokens);
|
|
44
|
+
return { entry, score };
|
|
45
|
+
})
|
|
46
|
+
.filter(({ score }) => score > 0)
|
|
47
|
+
.sort((a, b) => b.score - a.score)
|
|
48
|
+
.slice(0, limit);
|
|
49
|
+
const DOCS_BASE_URL = 'https://lism-css.com/ja/docs';
|
|
50
|
+
return scored.map(({ entry, score }) => ({
|
|
51
|
+
sourcePath: entry.sourcePath,
|
|
52
|
+
url: `${DOCS_BASE_URL}/${entry.sourcePath.replace(/\.mdx$/, '')}/`,
|
|
53
|
+
heading: entry.title,
|
|
54
|
+
snippet: entry.snippet,
|
|
55
|
+
score,
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
export interface MetaInfo {
|
|
2
|
+
generatedAt: string;
|
|
3
|
+
sourceCommit: string;
|
|
4
|
+
docsVersion: string;
|
|
5
|
+
}
|
|
6
|
+
export interface SearchResult {
|
|
7
|
+
sourcePath: string;
|
|
8
|
+
url: string;
|
|
9
|
+
heading: string;
|
|
10
|
+
snippet: string;
|
|
11
|
+
score: number;
|
|
12
|
+
}
|
|
13
|
+
export interface DocsEntry {
|
|
14
|
+
sourcePath: string;
|
|
15
|
+
title: string;
|
|
16
|
+
description: string;
|
|
17
|
+
category: string;
|
|
18
|
+
headings: string[];
|
|
19
|
+
keywords: string[];
|
|
20
|
+
snippet: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ComponentInfo {
|
|
23
|
+
name: string;
|
|
24
|
+
package: 'lism-css' | '@lism-css/ui';
|
|
25
|
+
category: string;
|
|
26
|
+
description: string;
|
|
27
|
+
props: ComponentProp[];
|
|
28
|
+
usage: string;
|
|
29
|
+
}
|
|
30
|
+
export interface ComponentProp {
|
|
31
|
+
name: string;
|
|
32
|
+
type: string;
|
|
33
|
+
default?: string;
|
|
34
|
+
description: string;
|
|
35
|
+
}
|
|
36
|
+
export interface TokenCategory {
|
|
37
|
+
category: string;
|
|
38
|
+
description: string;
|
|
39
|
+
tokens: TokenEntry[];
|
|
40
|
+
}
|
|
41
|
+
export interface TokenEntry {
|
|
42
|
+
name: string;
|
|
43
|
+
value: string;
|
|
44
|
+
description?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface PropEntry {
|
|
47
|
+
prop: string;
|
|
48
|
+
cssProperty: string;
|
|
49
|
+
type: string;
|
|
50
|
+
responsive: boolean;
|
|
51
|
+
description: string;
|
|
52
|
+
values?: string[];
|
|
53
|
+
}
|
|
54
|
+
export interface PropsSystemData {
|
|
55
|
+
description: string;
|
|
56
|
+
categories: PropCategory[];
|
|
57
|
+
}
|
|
58
|
+
export interface PropCategory {
|
|
59
|
+
category: string;
|
|
60
|
+
description: string;
|
|
61
|
+
props: PropEntry[];
|
|
62
|
+
}
|
|
63
|
+
export interface OverviewData {
|
|
64
|
+
description: string;
|
|
65
|
+
architecture: string;
|
|
66
|
+
packages: PackageInfo[];
|
|
67
|
+
breakpoints: Record<string, string>;
|
|
68
|
+
installation: string;
|
|
69
|
+
cssLayers: string;
|
|
70
|
+
}
|
|
71
|
+
export interface PackageInfo {
|
|
72
|
+
name: string;
|
|
73
|
+
npmName: string;
|
|
74
|
+
description: string;
|
|
75
|
+
version: string;
|
|
76
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|