@cheemsup/dsh-plugin-console 0.0.0-stage → 0.1.1

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.
Files changed (90) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +85 -2
  3. package/cordis.patch.yml +5 -0
  4. package/lib/client.activity.js +222 -0
  5. package/lib/client.apply.js +171 -0
  6. package/lib/client.changes.js +206 -0
  7. package/lib/client.cleanup.js +270 -0
  8. package/lib/client.control.js +242 -0
  9. package/lib/client.dialog.js +77 -0
  10. package/lib/client.draft.js +280 -0
  11. package/lib/client.editor-messages.js +421 -0
  12. package/lib/client.editor-store.js +266 -0
  13. package/lib/client.editor.js +433 -0
  14. package/lib/client.effects.js +115 -0
  15. package/lib/client.influence.js +361 -0
  16. package/lib/client.js +216 -0
  17. package/lib/client.page.js +584 -0
  18. package/lib/client.plugin-filters.js +62 -0
  19. package/lib/client.plugins.js +504 -0
  20. package/lib/client.preview-messages.js +495 -0
  21. package/lib/client.preview-raw.js +132 -0
  22. package/lib/client.preview-store.js +128 -0
  23. package/lib/client.preview-tools.js +194 -0
  24. package/lib/client.preview.js +447 -0
  25. package/lib/client.schema.js +327 -0
  26. package/lib/client.search.js +408 -0
  27. package/lib/client.session-detail.js +503 -0
  28. package/lib/client.sessions.js +495 -0
  29. package/lib/client.shared.js +559 -0
  30. package/lib/client.store.js +452 -0
  31. package/lib/client.styles.js +524 -0
  32. package/lib/client.template-card.js +240 -0
  33. package/lib/client.tools.js +366 -0
  34. package/lib/client.workspace-picker.js +204 -0
  35. package/lib/host/activity.js +252 -0
  36. package/lib/host/assembly-preview.js +244 -0
  37. package/lib/host/attribution.js +307 -0
  38. package/lib/host/catalog.js +133 -0
  39. package/lib/host/categorize.js +40 -0
  40. package/lib/host/constants.js +66 -0
  41. package/lib/host/control.js +159 -0
  42. package/lib/host/entries.js +289 -0
  43. package/lib/host/fiber.js +86 -0
  44. package/lib/host/fs.js +99 -0
  45. package/lib/host/health.js +178 -0
  46. package/lib/host/http.js +65 -0
  47. package/lib/host/impact.js +132 -0
  48. package/lib/host/layers.js +132 -0
  49. package/lib/host/masks.js +145 -0
  50. package/lib/host/modes.js +96 -0
  51. package/lib/host/names.js +44 -0
  52. package/lib/host/patch-scan.js +103 -0
  53. package/lib/host/preview-conditions.js +281 -0
  54. package/lib/host/preview-contexts.js +174 -0
  55. package/lib/host/preview-envelope.js +31 -0
  56. package/lib/host/preview-instructions.js +450 -0
  57. package/lib/host/preview-messages.js +284 -0
  58. package/lib/host/preview-modules.js +233 -0
  59. package/lib/host/preview-skills.js +200 -0
  60. package/lib/host/prompt.js +213 -0
  61. package/lib/host/recipe-overlay.js +209 -0
  62. package/lib/host/request-preview.js +114 -0
  63. package/lib/host/routes/activation.js +96 -0
  64. package/lib/host/routes/activity.js +22 -0
  65. package/lib/host/routes/apply.js +93 -0
  66. package/lib/host/routes/cleanup.js +62 -0
  67. package/lib/host/routes/control.js +22 -0
  68. package/lib/host/routes/impact.js +19 -0
  69. package/lib/host/routes/operations.js +22 -0
  70. package/lib/host/routes/preview.js +58 -0
  71. package/lib/host/routes/session-influence.js +23 -0
  72. package/lib/host/routes/snapshot.js +21 -0
  73. package/lib/host/routes/template.js +54 -0
  74. package/lib/host/routes/templates.js +28 -0
  75. package/lib/host/scope-impact.js +125 -0
  76. package/lib/host/session-events.js +39 -0
  77. package/lib/host/session-influence.js +475 -0
  78. package/lib/host/sessions.js +293 -0
  79. package/lib/host/snapshot.js +218 -0
  80. package/lib/host/source-scan.js +225 -0
  81. package/lib/host/templates/cleanup.js +219 -0
  82. package/lib/host/templates/inheritance.js +144 -0
  83. package/lib/host/templates/materialize.js +317 -0
  84. package/lib/host/templates/message-overlay.js +184 -0
  85. package/lib/host/templates/repository.js +323 -0
  86. package/lib/host/templates/store.js +131 -0
  87. package/lib/host/tool-set.js +150 -0
  88. package/lib/host/tools.js +129 -0
  89. package/lib/index.js +103 -0
  90. package/package.json +111 -4
@@ -0,0 +1,408 @@
1
+ /**
2
+ * 搜索:页头筛选的匹配口径与页内多词标记。
3
+ *
4
+ * 两层搜索分工不同:页头**筛掉**不匹配的条目,页内「文本检索」**不隐藏任何内容**,
5
+ * 只把长文本里的命中底色改掉并标上搜索框编号。所以页头用的是
6
+ * `normalizeQuery` / `matchesQuery` / `searchHint` / `renderQueryEmpty`,
7
+ * 页内用的是搜索词列表、`createHighlighter` 与上下定位。
8
+ *
9
+ * 匹配口径(字面子串、忽略大小写、去首尾空格)只在这里定义一次:五个页面原先各写一份
10
+ * `query.toLowerCase().includes(...)`,尾部空格的差异让同一句话在不同页面上结果不同。
11
+ *
12
+ * 渲染层是纯函数:匹配结果只由 (文本, 搜索词 / query) 决定,视图仍然是纯函数。
13
+ * 本文件是一个包内 chunk:入口用 `require.async('./client.search.js')` 取它。
14
+ */
15
+
16
+ window.__ModuleLoader__.load({
17
+ id: '@cheemsup/dsh-plugin-console',
18
+ chunk: 'client.search.js',
19
+ factory: (require) => {
20
+ const React = require('react')
21
+ const { createElement: h, useCallback, useRef, useState } = React
22
+
23
+ /** 颜色槽数量:与 client.styles.js 里的 [data-search="0..5"] 一一对应。 */
24
+ const SLOT_COUNT = 6
25
+ /** 单个文本块最多渲染的命中数;超长提示词里搜单字时保护 DOM 与输入流畅度。 */
26
+ const MAX_HITS_PER_TEXT = 500
27
+
28
+ /**
29
+ * 页头筛选的归一化:去首尾空格 + 小写。
30
+ *
31
+ * 只做这两件事:正则、模糊与全词匹配都不在范围内。非字符串归一成空串,
32
+ * 让「还没输过字」与「输了几个空格」走同一条路径。
33
+ * @param {unknown} value - 输入框里的原文。
34
+ * @returns {string} 归一后的搜索词。
35
+ */
36
+ function normalizeQuery(value) {
37
+ return typeof value === 'string' ? value.trim().toLowerCase() : ''
38
+ }
39
+
40
+ /**
41
+ * 判断一组字段里有没有命中。
42
+ *
43
+ * 空词命中一切;非字符串字段直接跳过——`title`、`description` 在快照里经常缺席,
44
+ * 让调用方逐个写 `typeof value === 'string'` 只会把同一段代码复制五遍。
45
+ * @param {unknown} query - 页头搜索框原文。
46
+ * @param {unknown[]} fields - 这一条目参与匹配的可见字段。
47
+ * @returns {boolean} 是否命中。
48
+ */
49
+ function matchesQuery(query, fields) {
50
+ const needle = normalizeQuery(query)
51
+ if (needle === '') return true
52
+ if (!Array.isArray(fields)) return false
53
+ return fields.some((value) => typeof value === 'string' && value.toLowerCase().includes(needle))
54
+ }
55
+
56
+ /**
57
+ * 把一段文本里的页头命中切成 `<mark class="ptQueryMark">`。
58
+ *
59
+ * 与页内检索的彩色编号徽标区分开:这里是单色、无编号、不改变行高,
60
+ * 只回答「这一行为什么留下」。命中上限与页内检索共用同一个常量。
61
+ * @param {string} value - 原文。
62
+ * @param {unknown} query - 页头搜索框原文。
63
+ * @returns {string | Array} 无命中时原样返回字符串,便于直接当 React children 用。
64
+ */
65
+ function markQuery(value, query) {
66
+ const needle = normalizeQuery(query)
67
+ if (typeof value !== 'string' || value.length === 0 || needle === '') return value
68
+ const haystack = value.toLowerCase()
69
+ const out = []
70
+ let at = 0
71
+ let rendered = 0
72
+ while (rendered < MAX_HITS_PER_TEXT) {
73
+ const found = haystack.indexOf(needle, at)
74
+ if (found < 0) break
75
+ if (found > at) out.push(value.slice(at, found))
76
+ out.push(h('mark', { key: 'q-' + found, className: 'ptQueryMark' }, value.slice(found, found + needle.length)))
77
+ at = found + needle.length
78
+ rendered += 1
79
+ }
80
+ if (out.length === 0) return value
81
+ if (at < value.length) out.push(value.slice(at))
82
+ return out
83
+ }
84
+
85
+ /**
86
+ * 页头占位符:只说这个标签真的能筛什么。
87
+ *
88
+ * 占位符是契约的一部分。旧实现按主视图给字,预演页于是承诺了「提示词段、
89
+ * 运行时上下文或工具」,但其中两个子标签根本不读 query。占位符说了筛不到的东西,
90
+ * 就是在教用户不信任这个输入框。
91
+ * @param {{view?: string, editing?: boolean, previewTab?: string}} [scope] - 当前位置。
92
+ * @returns {string} 占位符。
93
+ */
94
+ function searchHint(scope) {
95
+ const { view, editing, previewTab } = scope ?? {}
96
+ if (editing) return '筛选段落、消息或工具…'
97
+ if (view === 'sessions') return '筛选会话…'
98
+ if (view === 'plugins') return '筛选插件…'
99
+ if (view === 'tools') return '筛选工具…'
100
+ if (view !== 'preview') return '筛选…'
101
+ if (previewTab === 'prompt') return '筛选提示词段…'
102
+ if (previewTab === 'tools') return '筛选工具…'
103
+ // 请求结构没有可筛的列表,只有下方文本检索;页头不装作能筛,回车把词交棒下去。
104
+ if (previewTab === 'raw') return '此标签用下方文本检索'
105
+ // 消息标签按消息与分段筛:只说它真的会筛的东西。
106
+ return '筛选消息、分段或 skill…'
107
+ }
108
+
109
+ /**
110
+ * 页头筛选的统一空状态。
111
+ *
112
+ * 搜索框在页头、结果在正文,打完字看到空白时用户分不清「没命中」与「页面坏了」。
113
+ * 所以固定给「没有匹配的 X」和一个清除出口;`extra` 留给同页还有别的筛选条件的场合。
114
+ * @param {{noun?: string, onClear?: Function, extra?: object}} [opts] - 名词、清除回调、附加节点。
115
+ * @returns {object} React 节点。
116
+ */
117
+ function renderQueryEmpty(opts) {
118
+ const { noun, onClear, extra } = opts ?? {}
119
+ const hasAction = typeof onClear === 'function'
120
+ return h(
121
+ 'div',
122
+ { className: 'ptEmpty' },
123
+ '没有匹配的' + (noun ?? '条目') + '。',
124
+ !hasAction && extra === undefined
125
+ ? null
126
+ : h(
127
+ 'div',
128
+ { style: { marginTop: '10px' } },
129
+ hasAction
130
+ ? h('button', { type: 'button', className: 'ptTextBtn', onClick: onClear }, '清除搜索')
131
+ : null,
132
+ extra ?? null,
133
+ ),
134
+ )
135
+ }
136
+
137
+ return function create() {
138
+ /**
139
+ * 生成一个搜索框。
140
+ *
141
+ * 颜色槽优先用空的,用满后按编号取模复用;编号 `no` 只增不减,
142
+ * 删除中间的搜索框不会让后面的编号重排——用户记住的「2 号搜索」始终指同一个框。
143
+ * @param {object[]} items - 现有搜索框。
144
+ * @param {number} no - 新搜索框编号。
145
+ * @param {string} [text] - 可选的初始搜索词(页头交棒用)。
146
+ * @returns {object} 新搜索框。
147
+ */
148
+ function makeSearchItem(items, no, text) {
149
+ const used = new Set(items.map((item) => item.slot))
150
+ let slot = 0
151
+ while (slot < SLOT_COUNT && used.has(slot)) slot++
152
+ return { id: 'search-' + no, no, slot: slot % SLOT_COUNT, text: typeof text === 'string' ? text : '', cursor: 0 }
153
+ }
154
+
155
+ /** 一份页内搜索列表:会话页与预演页各调用一次,互不影响。 */
156
+ function useSearchState() {
157
+ const [items, setItems] = useState([])
158
+ // 编号放在 ref 里:state updater 可能被 React 重放,计数器不能写进 updater。
159
+ const nextNo = useRef(1)
160
+ // 删除搜索框后焦点要回到「+ 添加搜索」:按钮的 ref 由渲染层挂上。
161
+ const addButtonRef = useRef(null)
162
+ /**
163
+ * 添加一个搜索框。
164
+ * @param {string} [text] - 可选的初始搜索词:页头会把「请求结构」标签里的词交棒进来。
165
+ */
166
+ const add = useCallback((text) => {
167
+ const no = nextNo.current++
168
+ setItems((prev) => [...prev, makeSearchItem(prev, no, text)])
169
+ }, [])
170
+ const update = useCallback((id, text) => {
171
+ // 改词后回到第 1 处:旧游标对新的命中集合没有意义。
172
+ setItems((prev) => prev.map((item) => (item.id === id ? { ...item, text, cursor: 0 } : item)))
173
+ }, [])
174
+ const setCursor = useCallback((id, cursor) => {
175
+ setItems((prev) => prev.map((item) => (item.id === id ? { ...item, cursor } : item)))
176
+ }, [])
177
+ const remove = useCallback((id) => {
178
+ setItems((prev) => prev.filter((item) => item.id !== id))
179
+ // 等 React 把被删的输入框卸载掉再聚焦,否则焦点会在卸载时掉回 body。
180
+ const focusAdd = () => {
181
+ const button = addButtonRef.current
182
+ if (button !== null && button !== undefined && typeof button.focus === 'function') button.focus()
183
+ }
184
+ if (typeof requestAnimationFrame === 'function') requestAnimationFrame(focusAdd)
185
+ else focusAdd()
186
+ }, [])
187
+ return { items, add, update, setCursor, remove, addButtonRef }
188
+ }
189
+
190
+ /**
191
+ * 一段文本里的命中区间。
192
+ *
193
+ * 字面子串、不区分大小写;空搜索词与纯空白不参与匹配。重叠时按
194
+ * 「起点更早 → 更长 → 列表靠前」取舍,保证不会产生嵌套的 <mark>。
195
+ * @param {string} text - 文本。
196
+ * @param {object[]} items - 搜索框列表。
197
+ * @returns {{start: number, end: number, qi: number}[]} 命中区间。
198
+ */
199
+ function findHits(text, items) {
200
+ if (typeof text !== 'string' || text.length === 0) return []
201
+ const haystack = text.toLowerCase()
202
+ const hits = []
203
+ items.forEach((item, qi) => {
204
+ const needle = typeof item.text === 'string' ? item.text.trim() : ''
205
+ if (needle === '') return
206
+ const target = needle.toLowerCase()
207
+ let from = 0
208
+ while (from <= haystack.length - target.length) {
209
+ const at = haystack.indexOf(target, from)
210
+ if (at < 0) break
211
+ hits.push({ start: at, end: at + target.length, qi })
212
+ from = at + target.length
213
+ }
214
+ })
215
+ hits.sort((left, right) => left.start - right.start || right.end - left.end || left.qi - right.qi)
216
+ const kept = []
217
+ let cursor = 0
218
+ for (const hit of hits) {
219
+ if (hit.start < cursor) continue
220
+ kept.push(hit)
221
+ cursor = hit.end
222
+ }
223
+ return kept
224
+ }
225
+
226
+ /**
227
+ * 高亮器:跨多个文本块共用同一份计数。
228
+ *
229
+ * 徽标写的是**搜索框编号**而不是命中序号,所以渲染顺序不影响编号;
230
+ * 计数仍然跨块累加,工具行上的「N 处」才是整段文本的总数。
231
+ * @param {object[]} items - 搜索框列表。
232
+ * @returns {{text: Function, counts: number[], capped: boolean}} 高亮器。
233
+ */
234
+ function createHighlighter(items) {
235
+ const counts = items.map(() => 0)
236
+ let capped = false
237
+ /**
238
+ * 一处命中。
239
+ *
240
+ * 做成组件而不是直接建 `<mark>`,是因为「当前那一处」要等所有文本块都过一遍才定得下来:
241
+ * 游标可能指到已经不存在的位置(内容变短、切换会话),读数会夹紧到最后一处,
242
+ * 描边必须跟着夹紧。组件在父视图返回之后才真正渲染,此时 `counts` 已经是最终值。
243
+ */
244
+ function QueryMark({ item, qi, index, text: hitText }) {
245
+ const total = counts[qi]
246
+ const current = total > 0 && Math.min(item.cursor ?? 0, total - 1) === index
247
+ return h('mark', {
248
+ className: 'ptSearchMark',
249
+ 'data-search': item.slot,
250
+ 'data-box': item.no,
251
+ 'data-current': current ? 'true' : undefined,
252
+ title: `搜索 ${item.no}「${String(item.text).trim()}」`,
253
+ }, hitText)
254
+ }
255
+ /** 把一段文本切成「普通文本 / 命中标记」的 children。 */
256
+ function text(value) {
257
+ if (typeof value !== 'string' || value.length === 0) return value ?? ''
258
+ const hits = findHits(value, items)
259
+ if (hits.length === 0) return value
260
+ const out = []
261
+ let at = 0
262
+ let rendered = 0
263
+ for (const hit of hits) {
264
+ if (rendered >= MAX_HITS_PER_TEXT) {
265
+ capped = true
266
+ break
267
+ }
268
+ if (hit.start > at) out.push(value.slice(at, hit.start))
269
+ out.push(h(QueryMark, {
270
+ key: 'hit-' + hit.start,
271
+ item: items[hit.qi],
272
+ qi: hit.qi,
273
+ index: counts[hit.qi],
274
+ text: value.slice(hit.start, hit.end),
275
+ }))
276
+ counts[hit.qi] += 1
277
+ at = hit.end
278
+ rendered += 1
279
+ }
280
+ if (at < value.length) out.push(value.slice(at))
281
+ return out
282
+ }
283
+ return {
284
+ text,
285
+ counts,
286
+ get capped() { return capped },
287
+ }
288
+ }
289
+
290
+ /**
291
+ * 把第 index 处命中滚进视野。
292
+ *
293
+ * 命中可能落在折叠块里:先把祖先 `<details>` 打开,否则 scrollIntoView 只会滚到一个
294
+ * 不可见的节点。与「折叠全部」一样,这是页面内的显示状态,不改数据。
295
+ * @param {number} no - 搜索框编号。
296
+ * @param {number} index - 0 基命中序号。
297
+ */
298
+ function scrollToHit(no, index) {
299
+ if (typeof document === 'undefined' || typeof document.querySelectorAll !== 'function') return
300
+ const nodes = document.querySelectorAll('.ptSearchMark[data-box="' + no + '"]')
301
+ if (nodes.length === 0) return
302
+ const node = nodes[Math.max(0, Math.min(index, nodes.length - 1))]
303
+ let parent = node.parentElement
304
+ while (parent !== null && parent !== undefined) {
305
+ if (parent.tagName === 'DETAILS' && parent.open !== true) parent.open = true
306
+ parent = parent.parentElement
307
+ }
308
+ node.scrollIntoView({ block: 'center', behavior: 'smooth' })
309
+ }
310
+
311
+ /**
312
+ * 搜索工具行:标题 + 永远存在的添加按钮 + 每个搜索框一行。
313
+ *
314
+ * 每行带 PDF 式的上/下定位:按 DOM 顺序在命中之间循环,当前命中加描边。
315
+ * 循环而不是在两端停住,是为了让「下一处」在最后一处之后仍能继续读。
316
+ * @param {{items: object[], add: Function, update: Function, setCursor: Function, remove: Function}} state - 搜索状态。
317
+ * @param {number[]} counts - 每个搜索框的命中数。
318
+ * @param {boolean} capped - 是否有文本块达到命中上限。
319
+ * @returns {object} React 节点。
320
+ */
321
+ function renderSearchBar(state, counts, capped) {
322
+ const { items, add, update, setCursor, remove } = state
323
+ return h(
324
+ 'div',
325
+ // 有搜索框时把整块工具行吸在滚动容器顶部:长文本下滑后仍能改词与上/下定位。
326
+ // 只有「+ 添加搜索」时保持普通文档流,不占住正文的顶部。
327
+ { className: 'ptSearchTools', role: 'group', 'aria-label': '页内多词检索', 'data-docked': items.length > 0 ? 'true' : undefined },
328
+ h(
329
+ 'div',
330
+ { className: 'ptSearchToolsHead' },
331
+ h('span', { className: 'ptSearchToolsTitle', title: '同时标出多个词:每个搜索框一种颜色,命中右上角的数字是搜索框编号' }, '文本检索'),
332
+ h('button', { type: 'button', className: 'ptBtn', ref: state.addButtonRef, onClick: add, title: '添加一个搜索框;可以同时添加多个' }, '+ 添加搜索'),
333
+ ),
334
+ items.length === 0
335
+ ? null
336
+ : h(
337
+ 'div',
338
+ { className: 'ptSearchList' },
339
+ items.map((item, index) => {
340
+ const total = counts?.[index] ?? 0
341
+ const cursor = total === 0 ? 0 : Math.min(item.cursor ?? 0, total - 1)
342
+ /** 在命中之间循环定位;空结果时按钮禁用,不跳。 */
343
+ const go = (delta) => {
344
+ if (total === 0) return
345
+ const next = (cursor + delta + total) % total
346
+ setCursor?.(item.id, next)
347
+ scrollToHit(item.no, next)
348
+ }
349
+ return h(
350
+ 'div',
351
+ { key: item.id, className: 'ptSearchItem' },
352
+ h('span', { className: 'ptSearchSwatch', 'data-search': item.slot, title: `搜索 ${item.no} 的颜色与编号` }, String(item.no)),
353
+ h('input', {
354
+ className: 'ptSearch ptSearchInline',
355
+ type: 'search',
356
+ value: item.text,
357
+ placeholder: '输入要标出的文字…',
358
+ autoFocus: index === items.length - 1,
359
+ 'aria-label': '搜索 ' + item.no,
360
+ onChange: (event) => update(item.id, event.target.value),
361
+ onKeyDown: (event) => {
362
+ // 输入法确认候选词时也会发 Enter / Escape(keyCode 229)。
363
+ // 那不是定位更不是清空,必须原样交给输入法。
364
+ if (event.nativeEvent?.isComposing === true || event.keyCode === 229) return
365
+ if (event.key === 'Enter') {
366
+ // Enter / Shift+Enter 与 PDF 查看器一致:下一处 / 上一处。
367
+ event.preventDefault()
368
+ go(event.shiftKey ? -1 : 1)
369
+ return
370
+ }
371
+ if (event.key !== 'Escape') return
372
+ // Esc 只清空这个词;不让页面级 Esc(收起详情/清空全局搜索)接手。
373
+ event.stopPropagation()
374
+ update(item.id, '')
375
+ },
376
+ }),
377
+ h(
378
+ 'span',
379
+ { className: 'ptSearchNav' },
380
+ h('span', { className: 'ptSearchCount', title: '当前第几处 / 该搜索框的命中总数' }, total === 0 ? '0 处' : (cursor + 1) + '/' + total),
381
+ h('button', { type: 'button', className: 'ptTextBtn ptSearchNavBtn', disabled: total === 0, 'aria-label': `上一个命中(搜索 ${item.no})`, title: '上一个命中', onClick: () => go(-1) }, '↑'),
382
+ h('button', { type: 'button', className: 'ptTextBtn ptSearchNavBtn', disabled: total === 0, 'aria-label': `下一个命中(搜索 ${item.no})`, title: '下一个命中', onClick: () => go(1) }, '↓'),
383
+ ),
384
+ h('button', { type: 'button', className: 'ptTextBtn', 'aria-label': '删除搜索 ' + item.no, title: '删除这个搜索框', onClick: () => remove(item.id) }, '×'),
385
+ )
386
+ }),
387
+ ),
388
+ capped
389
+ ? h('p', { className: 'ptSectionNote' }, `命中过多,每个文本块只标出前 ${MAX_HITS_PER_TEXT} 处;把搜索词写得更具体可以缩小范围`)
390
+ : null,
391
+ )
392
+ }
393
+
394
+ return {
395
+ useSearchState,
396
+ makeSearchItem,
397
+ findHits,
398
+ createHighlighter,
399
+ renderSearchBar,
400
+ normalizeQuery,
401
+ matchesQuery,
402
+ markQuery,
403
+ searchHint,
404
+ renderQueryEmpty,
405
+ }
406
+ }
407
+ },
408
+ })