@wsxjs/wsx-press 0.0.18
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/dist/client.cjs +1 -0
- package/dist/client.js +1256 -0
- package/dist/index-ChO3PMD5.js +461 -0
- package/dist/index-uNJnOC7n.cjs +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.js +8 -0
- package/dist/node.cjs +47 -0
- package/dist/node.js +1708 -0
- package/package.json +90 -0
- package/src/client/components/DocLayout.css +49 -0
- package/src/client/components/DocLayout.wsx +92 -0
- package/src/client/components/DocPage.css +56 -0
- package/src/client/components/DocPage.wsx +480 -0
- package/src/client/components/DocSearch.css +113 -0
- package/src/client/components/DocSearch.wsx +328 -0
- package/src/client/components/DocSidebar.css +97 -0
- package/src/client/components/DocSidebar.wsx +173 -0
- package/src/client/components/DocTOC.css +105 -0
- package/src/client/components/DocTOC.wsx +262 -0
- package/src/client/index.ts +32 -0
- package/src/client/styles/code.css +242 -0
- package/src/client/styles/index.css +12 -0
- package/src/client/styles/reset.css +116 -0
- package/src/client/styles/theme.css +171 -0
- package/src/client/styles/typography.css +239 -0
- package/src/index.ts +26 -0
- package/src/node/index.ts +16 -0
- package/src/node/metadata.ts +113 -0
- package/src/node/plugin.ts +223 -0
- package/src/node/search.ts +53 -0
- package/src/node/toc.ts +148 -0
- package/src/node/typedoc.ts +96 -0
- package/src/types/wsx.d.ts +11 -0
- package/src/types.test.ts +118 -0
- package/src/types.ts +150 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for @wsxjs/wsx-press
|
|
3
|
+
* Zero any types - all types are explicitly defined
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 文档元数据
|
|
8
|
+
*/
|
|
9
|
+
export interface DocMetadata {
|
|
10
|
+
/** 文档标题 */
|
|
11
|
+
title: string;
|
|
12
|
+
/** 文档类别 */
|
|
13
|
+
category: string;
|
|
14
|
+
/** 文档路由 */
|
|
15
|
+
route: string;
|
|
16
|
+
/** 上一篇文档路由 */
|
|
17
|
+
prev?: string | null;
|
|
18
|
+
/** 下一篇文档路由 */
|
|
19
|
+
next?: string | null;
|
|
20
|
+
/** 文档描述 */
|
|
21
|
+
description?: string;
|
|
22
|
+
/** 标签 */
|
|
23
|
+
tags?: string[];
|
|
24
|
+
/** 扩展字段 */
|
|
25
|
+
[key: string]: unknown;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 文档元数据集合
|
|
30
|
+
*/
|
|
31
|
+
export type DocsMetaCollection = Record<string, DocMetadata>;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 搜索文档
|
|
35
|
+
*/
|
|
36
|
+
export interface SearchDocument {
|
|
37
|
+
/** 文档唯一ID */
|
|
38
|
+
id: string;
|
|
39
|
+
/** 文档标题 */
|
|
40
|
+
title: string;
|
|
41
|
+
/** 文档类别 */
|
|
42
|
+
category: string;
|
|
43
|
+
/** 文档路由 */
|
|
44
|
+
route: string;
|
|
45
|
+
/** 文档内容片段(用于搜索) */
|
|
46
|
+
content: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 搜索结果
|
|
51
|
+
*/
|
|
52
|
+
export interface SearchResult {
|
|
53
|
+
/** 匹配的文档 */
|
|
54
|
+
item: SearchDocument;
|
|
55
|
+
/** 匹配分数 */
|
|
56
|
+
score?: number;
|
|
57
|
+
/** 匹配位置 */
|
|
58
|
+
matches?: Array<{
|
|
59
|
+
indices: [number, number][];
|
|
60
|
+
value: string;
|
|
61
|
+
key: string;
|
|
62
|
+
}>;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 搜索索引配置
|
|
67
|
+
*/
|
|
68
|
+
export interface SearchIndexOptions {
|
|
69
|
+
/** 搜索字段配置 */
|
|
70
|
+
keys: Array<{ name: string; weight: number }>;
|
|
71
|
+
/** 匹配阈值 */
|
|
72
|
+
threshold: number;
|
|
73
|
+
/** 是否包含分数 */
|
|
74
|
+
includeScore: boolean;
|
|
75
|
+
/** 是否包含匹配位置 */
|
|
76
|
+
includeMatches?: boolean;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* 搜索索引
|
|
81
|
+
*/
|
|
82
|
+
export interface SearchIndex {
|
|
83
|
+
/** 所有文档 */
|
|
84
|
+
documents: SearchDocument[];
|
|
85
|
+
/** Fuse.js 配置 */
|
|
86
|
+
options: SearchIndexOptions;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* 路由参数
|
|
91
|
+
*/
|
|
92
|
+
export interface RouteParams {
|
|
93
|
+
/** 文档类别 */
|
|
94
|
+
category: string;
|
|
95
|
+
/** 文档页面 */
|
|
96
|
+
page: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* API 路由参数
|
|
101
|
+
*/
|
|
102
|
+
export interface ApiRouteParams {
|
|
103
|
+
/** API 模块 */
|
|
104
|
+
module: string;
|
|
105
|
+
/** API 项目 */
|
|
106
|
+
item: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* 加载状态
|
|
111
|
+
*/
|
|
112
|
+
export type LoadingState = "idle" | "loading" | "success" | "error";
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* 文档加载错误代码
|
|
116
|
+
*/
|
|
117
|
+
export type DocumentLoadErrorCode =
|
|
118
|
+
| "NOT_FOUND"
|
|
119
|
+
| "NETWORK_ERROR"
|
|
120
|
+
| "PARSE_ERROR"
|
|
121
|
+
| "INVALID_PARAMS";
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* 文档加载错误
|
|
125
|
+
*/
|
|
126
|
+
export class DocumentLoadError extends Error {
|
|
127
|
+
public readonly code: DocumentLoadErrorCode;
|
|
128
|
+
public readonly details?: unknown;
|
|
129
|
+
|
|
130
|
+
constructor(message: string, code: DocumentLoadErrorCode, details?: unknown) {
|
|
131
|
+
super(message);
|
|
132
|
+
this.name = "DocumentLoadError";
|
|
133
|
+
this.code = code;
|
|
134
|
+
this.details = details;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* TOC 项接口(从 node/toc.ts 导出,供客户端使用)
|
|
140
|
+
*/
|
|
141
|
+
export interface TOCItem {
|
|
142
|
+
/** 标题级别 (1-6) */
|
|
143
|
+
level: number;
|
|
144
|
+
/** 标题文本 */
|
|
145
|
+
text: string;
|
|
146
|
+
/** 锚点 ID */
|
|
147
|
+
id: string;
|
|
148
|
+
/** 子项 */
|
|
149
|
+
children: TOCItem[];
|
|
150
|
+
}
|