dsh-exa-tools 0.0.0-stage → 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/client.js ADDED
@@ -0,0 +1,468 @@
1
+ /**
2
+ * dsh-exa-tools — client half (runs in the Web and Desktop renderers).
3
+ *
4
+ * Registers the plugin's configuration card into the Plugins page's
5
+ * `plugins.bundle.config` slot (keyed by this package name), so the bundle's
6
+ * page shows an API key form between its description and its rows. Values
7
+ * read and write through the shared settings transport (`ctx.configForms`);
8
+ * the API key is a write-only secret: the Host never returns its value, only
9
+ * a set/unset presence marker, which this card renders as the input's
10
+ * placeholder state.
11
+ *
12
+ * Controls are self-contained and styled with the host theme tokens
13
+ * (--dsw-alias-*); no Harness Client package is imported as a module.
14
+ */
15
+
16
+ window.__ModuleLoader__.load({
17
+ id: 'dsh-exa-tools',
18
+ factory(require) {
19
+ const React = require('react')
20
+ const h = React.createElement
21
+ const { useState, useCallback, useSyncExternalStore, useId, useRef } = React
22
+
23
+ const PKG = 'dsh-exa-tools'
24
+ const NS = 'exaTools'
25
+ const ENTRY_ID = 'exa-tools'
26
+
27
+ const DICTS = {
28
+ en: {
29
+ nav: 'Exa tools',
30
+ pageTitle: 'Exa search tools',
31
+ intro: 'Exa powers exa_search and exa_fetch. Without a key the tools use Exa\'s free hosted endpoint (rate-limited); with a key they use the official Exa API.',
32
+ modeApi: 'API mode — official Exa API (api.exa.ai)',
33
+ modeFree: 'Free mode — hosted MCP endpoint (mcp.exa.ai)',
34
+ modeFreeHint: 'The free endpoint is rate-limited. Add an API key for higher limits.',
35
+ keyLabel: 'API key',
36
+ keyHint: 'The key is stored in this profile\'s configuration and never shown again after saving.',
37
+ keyLink: 'Get an API key',
38
+ keyPlaceholderSet: 'Key configured — type to replace',
39
+ keyPlaceholderUnset: 'Paste your Exa API key',
40
+ keyReveal: 'Show key',
41
+ keyHide: 'Hide key',
42
+ advanced: 'Limits and timeouts',
43
+ advancedHint: 'Leave a field empty and save to restore its default.',
44
+ searchMaxResults: 'Max search results',
45
+ fetchMaxCharacters: 'Max fetch characters',
46
+ searchTimeoutMs: 'Search timeout (ms)',
47
+ fetchTimeoutMs: 'Fetch timeout (ms)',
48
+ default: 'default',
49
+ save: 'Save',
50
+ saving: 'Saving…',
51
+ clearKey: 'Clear API key',
52
+ clearing: 'Clearing…',
53
+ saved: 'Saved. Changes apply immediately.',
54
+ cleared: 'API key cleared. The tools now use the free endpoint.',
55
+ noChanges: 'No changes to save.',
56
+ refused: 'The configuration was updated elsewhere; the latest values were reloaded. Your drafts are kept — review them and save again.',
57
+ saveFailed: 'Save failed: ',
58
+ invalidNumber: 'enter a whole number in the allowed range',
59
+ loading: 'Loading configuration…',
60
+ unavailable: 'The Exa tools plugin is not active in this profile.',
61
+ readonly: 'This profile\'s configuration is read-only here.',
62
+ },
63
+ zh: {
64
+ nav: 'Exa 搜索',
65
+ pageTitle: 'Exa 搜索工具',
66
+ intro: 'Exa 为 exa_search 和 exa_fetch 提供支持。未填写 API Key 时使用 Exa 免费托管端点(有速率限制);填写后改用 Exa 官方 API。',
67
+ modeApi: 'API 模式 —— Exa 官方 API(api.exa.ai)',
68
+ modeFree: '免费模式 —— 托管 MCP 端点(mcp.exa.ai)',
69
+ modeFreeHint: '免费端点有速率限制。填写 API Key 可获得更高限额。',
70
+ keyLabel: 'API Key',
71
+ keyHint: '密钥保存在本 profile 的配置中,保存后不再回显。',
72
+ keyLink: '获取 API Key',
73
+ keyPlaceholderSet: '已配置 —— 输入新值可替换',
74
+ keyPlaceholderUnset: '粘贴 Exa API Key',
75
+ keyReveal: '显示密钥',
76
+ keyHide: '隐藏密钥',
77
+ advanced: '限额与超时',
78
+ advancedHint: '清空某字段并保存即恢复其默认值。',
79
+ searchMaxResults: '搜索最大结果数',
80
+ fetchMaxCharacters: '抓取最大字符数',
81
+ searchTimeoutMs: '搜索超时(毫秒)',
82
+ fetchTimeoutMs: '抓取超时(毫秒)',
83
+ default: '默认',
84
+ save: '保存',
85
+ saving: '保存中…',
86
+ clearKey: '清除 API Key',
87
+ clearing: '清除中…',
88
+ saved: '已保存,立即生效。',
89
+ cleared: '已清除 API Key,工具改用免费端点。',
90
+ noChanges: '没有需要保存的改动。',
91
+ refused: '配置已被其他改动更新,最新值已重新载入。草稿已保留,请核对后重新保存。',
92
+ saveFailed: '保存失败:',
93
+ invalidNumber: '请输入允许范围内的整数',
94
+ loading: '正在加载配置…',
95
+ unavailable: 'Exa 工具插件未在本 profile 中启用。',
96
+ readonly: '本 profile 的配置在此只读。',
97
+ },
98
+ }
99
+
100
+ /**
101
+ * Numeric volatile fields with their schema ranges and defaults, in form
102
+ * order. Kept in sync with the Config schema in index.js by hand; the
103
+ * ranges are also validated Host-side on every write.
104
+ */
105
+ const NUM_FIELDS = [
106
+ { name: 'searchMaxResults', min: 1, max: 50, def: 10 },
107
+ { name: 'fetchMaxCharacters', min: 1000, max: 500000, def: 50000 },
108
+ { name: 'searchTimeoutMs', min: 1000, max: 300000, def: 30000 },
109
+ { name: 'fetchTimeoutMs', min: 1000, max: 300000, def: 60000 },
110
+ ]
111
+
112
+ const EYE_CONTOUR = 'M1.5 8C2.9 5.25 5.25 3.5 8 3.5C10.75 3.5 13.1 5.25 14.5 8C13.1 10.75 10.75 12.5 8 12.5C5.25 12.5 2.9 10.75 1.5 8Z'
113
+ const EYE_PATH = `${EYE_CONTOUR}M10 8C10 9.1 9.1 10 8 10C6.9 10 6 9.1 6 8C6 6.9 6.9 6 8 6C9.1 6 10 6.9 10 8Z`
114
+ const EYE_OFF_PATH = `${EYE_CONTOUR}M2.5 2.5L13.5 13.5`
115
+
116
+ const STYLE = `
117
+ .dsh-exa-page { display: flex; flex-direction: column; gap: 16px; max-width: 720px; color: var(--dsw-alias-label-primary); }
118
+ .dsh-exa-page-title { margin: 0; font-size: 16px; line-height: 24px; font-weight: 500; color: var(--dsw-alias-label-primary); }
119
+ .dsh-exa-card { display: flex; flex-direction: column; gap: 12px; max-width: 720px; color: var(--dsw-alias-label-primary); }
120
+ .dsh-exa-intro { margin: 0; font-size: 14px; line-height: 22px; color: var(--dsw-alias-label-secondary); }
121
+ .dsh-exa-mode { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; line-height: 20px; }
122
+ .dsh-exa-dot { box-sizing: border-box; display: inline-block; flex: none; width: 8px; height: 8px; border-radius: 50%; corner-shape: round; }
123
+ .dsh-exa-dot-on { background: var(--dsw-alias-state-success-primary); }
124
+ .dsh-exa-dot-off { background: var(--dsw-alias-state-warn-primary, var(--dsw-alias-label-tertiary)); }
125
+ .dsh-exa-hint { margin: 0; font-size: 12px; line-height: 18px; color: var(--dsw-alias-label-tertiary); }
126
+ .dsh-exa-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
127
+ .dsh-exa-label { font-size: 12px; line-height: 18px; font-weight: 500; color: var(--dsw-alias-label-secondary); }
128
+ .dsh-exa-input { box-sizing: border-box; width: 100%; height: 32px; padding: 0 10px; border: 0.5px solid var(--dsw-alias-border-l4); border-radius: var(--dsw-radius-md); font: inherit; font-size: 14px; line-height: 22px; background: var(--dsw-alias-bg-layer-1); color: var(--dsw-alias-label-primary); }
129
+ .dsh-exa-input:focus { outline: none; border-color: var(--dsw-alias-state-business-primary); }
130
+ .dsh-exa-input::placeholder { color: var(--dsw-alias-label-dimmed); }
131
+ .dsh-exa-input:disabled { opacity: 0.6; cursor: default; }
132
+ .dsh-exa-input[aria-invalid='true'] { border-color: var(--dsw-alias-state-error-primary); }
133
+ .dsh-exa-input-filled { padding-right: 40px; }
134
+ .dsh-exa-keyrow { position: relative; }
135
+ .dsh-exa-keytoggle { position: absolute; inset: 1px 1px 1px auto; display: inline-flex; align-items: center; justify-content: center; width: 32px; padding: 0; border: none; border-radius: var(--dsw-radius-md); background: none; color: var(--dsw-alias-label-secondary); cursor: pointer; }
136
+ @media (hover: hover) { .dsh-exa-keytoggle:hover:not(:disabled) { color: var(--dsw-alias-label-primary); } }
137
+ .dsh-exa-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
138
+ .dsh-exa-range { font-size: 11px; line-height: 16px; color: var(--dsw-alias-label-tertiary); }
139
+ .dsh-exa-actions { display: flex; align-items: center; gap: 8px; }
140
+ .dsh-exa-primary, .dsh-exa-danger { box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; height: 36px; padding: 0 14px; border: none; border-radius: var(--dsw-radius-md); font: inherit; font-size: 14px; line-height: 22px; cursor: pointer; }
141
+ .dsh-exa-primary { background: var(--dsw-alias-button-primary-fill); color: var(--dsw-alias-label-primary-foreground); }
142
+ @media (hover: hover) { .dsh-exa-primary:hover:not(:disabled) { background: var(--dsw-alias-button-primary-hover); } }
143
+ .dsh-exa-danger { background: transparent; color: var(--dsw-alias-state-error-primary); }
144
+ @media (hover: hover) { .dsh-exa-danger:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover-danger); } }
145
+ .dsh-exa-primary:disabled, .dsh-exa-danger:disabled { opacity: 0.4; cursor: default; }
146
+ .dsh-exa-primary:focus-visible, .dsh-exa-danger:focus-visible, .dsh-exa-keytoggle:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary)); }
147
+ .dsh-exa-saved { margin: 0; font-size: 12px; line-height: 18px; color: var(--dsw-alias-state-success-primary); }
148
+ .dsh-exa-error { margin: 0; font-size: 12px; line-height: 18px; color: var(--dsw-alias-state-error-primary); }
149
+ .dsh-exa-advanced { border-top: 0.5px solid var(--dsw-alias-border-l2); padding-top: 10px; }
150
+ .dsh-exa-advanced summary { display: flex; align-items: center; gap: 6px; width: fit-content; cursor: pointer; font-size: 12px; line-height: 18px; font-weight: 500; color: var(--dsw-alias-label-secondary); list-style: none; }
151
+ .dsh-exa-advanced summary::-webkit-details-marker { display: none; }
152
+ .dsh-exa-advanced summary::before { content: ''; width: 5px; height: 5px; border-right: 1.5px solid currentcolor; border-bottom: 1.5px solid currentcolor; transform: rotate(-45deg) translate(-1px, -1px); transition: transform 120ms ease; }
153
+ .dsh-exa-advanced[open] summary::before { transform: rotate(45deg) translate(-1px, -1px); }
154
+ .dsh-exa-advanced-body { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; }
155
+ .dsh-exa-link { color: var(--dsw-alias-state-business-primary); text-decoration: none; }
156
+ @media (hover: hover) { .dsh-exa-link:hover { text-decoration: underline; } }
157
+ @media (prefers-reduced-motion: reduce) { .dsh-exa-advanced summary::before { transition: none; } }
158
+ `
159
+
160
+ /** The bundle-page configuration card. Props: t, view, form, mirror. */
161
+ function ExaConfigCard(props) {
162
+ const { t, form, mirror } = props
163
+ const subscribeForm = useCallback(listener => form.subscribe(listener), [form])
164
+ const readForm = useCallback(() => form.getSnapshot(), [form])
165
+ const subscribeMirror = useCallback(listener => mirror.subscribe(listener), [mirror])
166
+ const readMirror = useCallback(() => mirror.getSnapshot(), [mirror])
167
+ const snap = useSyncExternalStore(subscribeForm, readForm)
168
+ const mirrorSnap = useSyncExternalStore(subscribeMirror, readMirror)
169
+
170
+ const idPrefix = useId()
171
+ const fieldRefs = useRef({})
172
+ const [drafts, setDrafts] = useState({})
173
+ // Revision read when editing began: the fence against concurrent writes.
174
+ // Reset after a settled write; a refusal also resets it so an informed
175
+ // retry (the message says the latest values were reloaded) can proceed.
176
+ const [baseRevision, setBaseRevision] = useState(undefined)
177
+ const [busyAction, setBusyAction] = useState(null)
178
+ const [message, setMessage] = useState(null)
179
+ const [revealed, setRevealed] = useState(false)
180
+ const [invalidField, setInvalidField] = useState(null)
181
+ const [advancedOpen, setAdvancedOpen] = useState(false)
182
+
183
+ const nsView = mirrorSnap.view?.namespaces?.find(candidate => candidate.ns === ENTRY_ID)
184
+ const keySet = nsView?.secrets?.some(secret => secret.path.length === 1 && secret.path[0] === 'apiKey' && secret.set) === true
185
+
186
+ if (snap.status === 'loading') return h('p', { className: 'dsh-exa-hint' }, t('loading'))
187
+ if (snap.status === 'unavailable') return h('p', { className: 'dsh-exa-hint' }, t('unavailable'))
188
+
189
+ const value = snap.value ?? {}
190
+ const base = snap.base ?? {}
191
+ const writable = snap.writable
192
+ const busy = busyAction !== null
193
+ const disabled = !writable || busy
194
+ const keyDraft = drafts.apiKey ?? ''
195
+ const messageId = `${idPrefix}-message`
196
+ const draftText = field => drafts[field] ?? (value[field] !== undefined ? String(value[field]) : '')
197
+
198
+ // Dirty check normalizes numeric drafts the same way save parses them,
199
+ // so "10.0" or "010" never light up Save for a no-op.
200
+ let dirty = keyDraft.trim().length > 0
201
+ for (const field of NUM_FIELDS) {
202
+ const draft = drafts[field.name]
203
+ if (draft === undefined) continue
204
+ const text = draft.trim()
205
+ if (text === '') { if (value[field.name] !== undefined) dirty = true; continue }
206
+ if (!/^\d+$/.test(text)) { dirty = true; continue }
207
+ if (Number(text) !== value[field.name]) dirty = true
208
+ }
209
+
210
+ const edit = (field, text) => {
211
+ if (baseRevision === undefined) setBaseRevision(snap.revision)
212
+ setDrafts(current => ({ ...current, [field]: text }))
213
+ setMessage(null)
214
+ setInvalidField(null)
215
+ if (field === 'apiKey') setRevealed(false)
216
+ }
217
+
218
+ const save = async () => {
219
+ if (busy || !writable) return
220
+ const ops = []
221
+ const trimmedKey = keyDraft.trim()
222
+ if (trimmedKey) ops.push({ op: 'set', path: ['apiKey'], value: trimmedKey })
223
+ let firstInvalid = null
224
+ for (const field of NUM_FIELDS) {
225
+ const draft = drafts[field.name]
226
+ if (draft === undefined) continue
227
+ const text = draft.trim()
228
+ if (text === '') {
229
+ if (value[field.name] !== undefined) ops.push({ op: 'unset', path: [field.name] })
230
+ continue
231
+ }
232
+ const number = /^\d+$/.test(text) ? Number(text) : NaN
233
+ if (!Number.isInteger(number) || number < field.min || number > field.max) {
234
+ firstInvalid ??= field
235
+ continue
236
+ }
237
+ if (number !== value[field.name]) ops.push({ op: 'set', path: [field.name], value: number })
238
+ }
239
+ if (firstInvalid) {
240
+ setInvalidField(firstInvalid.name)
241
+ setAdvancedOpen(true)
242
+ setMessage({ kind: 'err', text: `${t(firstInvalid.name)}: ${t('invalidNumber')} (${firstInvalid.min}–${firstInvalid.max})` })
243
+ // Focus the offending input once the expanded details has rendered.
244
+ setTimeout(() => { fieldRefs.current[firstInvalid.name]?.focus() }, 0)
245
+ return
246
+ }
247
+ if (ops.length === 0) {
248
+ setMessage({ kind: 'ok', text: t('noChanges') })
249
+ return
250
+ }
251
+ setBusyAction('save')
252
+ try {
253
+ const accepted = await form.mutate(ops, baseRevision ?? snap.revision)
254
+ if (accepted) {
255
+ setMessage({ kind: 'ok', text: t('saved') })
256
+ setDrafts({})
257
+ setRevealed(false)
258
+ setInvalidField(null)
259
+ } else {
260
+ // The transport already reloaded the latest Host values; drafts
261
+ // stay for review. Drop the stale fence so a retry can proceed.
262
+ setMessage({ kind: 'err', text: t('refused') })
263
+ }
264
+ setBaseRevision(undefined)
265
+ } catch (error) {
266
+ setMessage({ kind: 'err', text: t('saveFailed') + (error?.message ?? String(error)) })
267
+ } finally {
268
+ setBusyAction(null)
269
+ }
270
+ }
271
+
272
+ const clearKey = async () => {
273
+ if (busy || !writable) return
274
+ setBusyAction('clear')
275
+ try {
276
+ const accepted = await form.unset('apiKey')
277
+ if (accepted) {
278
+ setMessage({ kind: 'ok', text: t('cleared') })
279
+ setDrafts(current => {
280
+ const next = { ...current }
281
+ delete next.apiKey
282
+ return next
283
+ })
284
+ setRevealed(false)
285
+ } else {
286
+ setMessage({ kind: 'err', text: t('refused') })
287
+ }
288
+ setBaseRevision(undefined)
289
+ } catch (error) {
290
+ setMessage({ kind: 'err', text: t('saveFailed') + (error?.message ?? String(error)) })
291
+ } finally {
292
+ setBusyAction(null)
293
+ }
294
+ }
295
+
296
+ const canReveal = keyDraft.length > 0 && !disabled
297
+ const showText = canReveal && revealed
298
+ const keyInputId = `${idPrefix}-api-key`
299
+
300
+ return h('div', { className: 'dsh-exa-card' },
301
+ h('p', { className: 'dsh-exa-intro' }, t('intro')),
302
+ h('span', { className: 'dsh-exa-mode' },
303
+ h('span', { className: `dsh-exa-dot ${keySet ? 'dsh-exa-dot-on' : 'dsh-exa-dot-off'}`, 'aria-hidden': true }),
304
+ keySet ? t('modeApi') : t('modeFree')),
305
+ keySet ? null : h('p', { className: 'dsh-exa-hint' }, t('modeFreeHint')),
306
+ h('div', { className: 'dsh-exa-field' },
307
+ h('label', { className: 'dsh-exa-label', htmlFor: keyInputId }, t('keyLabel')),
308
+ h('div', { className: 'dsh-exa-keyrow' },
309
+ h('input', {
310
+ id: keyInputId,
311
+ className: `dsh-exa-input${keyDraft.length > 0 ? ' dsh-exa-input-filled' : ''}`,
312
+ type: showText ? 'text' : 'password',
313
+ autoComplete: 'new-password',
314
+ value: keyDraft,
315
+ placeholder: keySet ? t('keyPlaceholderSet') : t('keyPlaceholderUnset'),
316
+ disabled,
317
+ onChange: event => edit('apiKey', event.target.value),
318
+ }),
319
+ canReveal ? h('button', {
320
+ type: 'button',
321
+ className: 'dsh-exa-keytoggle',
322
+ 'aria-label': t(showText ? 'keyHide' : 'keyReveal'),
323
+ 'aria-pressed': showText,
324
+ onClick: () => setRevealed(current => !current),
325
+ }, h('svg', {
326
+ width: 16, height: 16, viewBox: '0 0 16 16', fill: 'none',
327
+ stroke: 'currentColor', strokeWidth: 1.3, strokeLinecap: 'round', 'aria-hidden': true,
328
+ }, h('path', { d: showText ? EYE_OFF_PATH : EYE_PATH }))) : null),
329
+ h('p', { className: 'dsh-exa-hint' },
330
+ t('keyHint'), ' ',
331
+ h('a', {
332
+ className: 'dsh-exa-link',
333
+ href: 'https://dashboard.exa.ai/api-keys',
334
+ target: '_blank',
335
+ rel: 'noreferrer',
336
+ }, t('keyLink')))),
337
+ h('details', {
338
+ className: 'dsh-exa-advanced',
339
+ open: advancedOpen,
340
+ onToggle: event => setAdvancedOpen(event.currentTarget.open),
341
+ },
342
+ h('summary', null, t('advanced')),
343
+ h('div', { className: 'dsh-exa-advanced-body' },
344
+ h('p', { className: 'dsh-exa-hint' }, t('advancedHint')),
345
+ h('div', { className: 'dsh-exa-grid' },
346
+ NUM_FIELDS.map(field => {
347
+ const inputId = `${idPrefix}-${field.name}`
348
+ const rangeId = `${idPrefix}-range-${field.name}`
349
+ const invalid = invalidField === field.name
350
+ const describedBy = invalid ? `${rangeId} ${messageId}` : rangeId
351
+ return h('div', { className: 'dsh-exa-field', key: field.name },
352
+ h('label', { className: 'dsh-exa-label', htmlFor: inputId }, t(field.name)),
353
+ h('input', {
354
+ id: inputId,
355
+ ref: (element) => { fieldRefs.current[field.name] = element },
356
+ className: 'dsh-exa-input',
357
+ type: 'text',
358
+ inputMode: 'numeric',
359
+ value: draftText(field.name),
360
+ disabled,
361
+ 'aria-invalid': invalid || undefined,
362
+ 'aria-describedby': describedBy,
363
+ onChange: event => edit(field.name, event.target.value),
364
+ }),
365
+ h('span', { className: 'dsh-exa-range', id: rangeId },
366
+ `${field.min}–${field.max} · ${t('default')} ${base[field.name] ?? field.def}`))
367
+ })))),
368
+ h('div', { className: 'dsh-exa-actions' },
369
+ h('button', {
370
+ type: 'button',
371
+ className: 'dsh-exa-primary',
372
+ disabled: disabled || !dirty,
373
+ onClick: () => { void save() },
374
+ }, busyAction === 'save' ? t('saving') : t('save')),
375
+ keySet ? h('button', {
376
+ type: 'button',
377
+ className: 'dsh-exa-danger',
378
+ disabled,
379
+ onClick: () => { void clearKey() },
380
+ }, busyAction === 'clear' ? t('clearing') : t('clearKey')) : null),
381
+ writable ? null : h('p', { className: 'dsh-exa-hint' }, t('readonly')),
382
+ message ? h('p', {
383
+ id: messageId,
384
+ className: message.kind === 'ok' ? 'dsh-exa-saved' : 'dsh-exa-error',
385
+ role: message.kind === 'err' ? 'alert' : 'status',
386
+ 'aria-live': message.kind === 'err' ? 'assertive' : 'polite',
387
+ }, message.text) : null)
388
+ }
389
+
390
+ /**
391
+ * Navigation icon for the settings section, addressed by the matching
392
+ * section id. The shell owns the button, label, and row color; the mark
393
+ * draws in currentColor so it follows the nav row's resting/active tone.
394
+ */
395
+ function ExaSettingsIcon(props) {
396
+ const size = props.size
397
+ return h('svg', {
398
+ width: size, height: size, viewBox: '0 0 36 36', fill: 'none', 'aria-hidden': true,
399
+ },
400
+ h('path', { d: 'M21.2 21.2L28.6 28.6', stroke: 'currentColor', strokeWidth: 3, strokeLinecap: 'round' }),
401
+ h('circle', { cx: 15, cy: 15, r: 8.5, stroke: 'currentColor', strokeWidth: 2.5 }),
402
+ h('g', { stroke: 'currentColor', strokeWidth: 1.2, strokeLinecap: 'round' },
403
+ h('path', { d: 'M11.8 13.2L17.8 12.2' }),
404
+ h('path', { d: 'M11.8 13.2L15.2 18.4' }),
405
+ h('path', { d: 'M17.8 12.2L15.2 18.4' })),
406
+ h('g', { fill: 'currentColor' },
407
+ h('circle', { cx: 11.8, cy: 13.2, r: 1.5 }),
408
+ h('circle', { cx: 17.8, cy: 12.2, r: 1.5 }),
409
+ h('circle', { cx: 15.2, cy: 18.4, r: 1.5 })))
410
+ }
411
+
412
+ /** The Settings-panel page: a heading over the same configuration card. */
413
+ function ExaSettingsPage(props) {
414
+ const { t, form, mirror } = props
415
+ return h('div', { className: 'dsh-exa-page' },
416
+ h('h2', { className: 'dsh-exa-page-title' }, t('pageTitle')),
417
+ h(ExaConfigCard, { t, form, mirror }))
418
+ }
419
+
420
+ return {
421
+ name: 'exa-tools-client',
422
+ inject: ['slots', 'locale', 'configForms'],
423
+ apply(ctx) {
424
+ ctx.effect(function* () {
425
+ yield ctx.locale.register(NS, DICTS)
426
+ const t = ctx.locale.bind(NS)
427
+ const style = document.createElement('style')
428
+ style.dataset.plugin = PKG
429
+ style.textContent = STYLE
430
+ document.head.appendChild(style)
431
+ const form = ctx.configForms.get(ENTRY_ID)
432
+ const mirror = ctx.configForms.describe()
433
+ // The card exists while the Host serves this plugin's settings
434
+ // namespace; a profile without the plugin shows no trace of it.
435
+ yield ctx.configForms.whileServed([ENTRY_ID], () => ctx.slots.inject('plugins.bundle.config', () => ctx.slots.register({
436
+ name: 'plugins.bundle.config',
437
+ key: PKG,
438
+ locale: NS,
439
+ inject: () => ({ form, mirror }),
440
+ }, ExaConfigCard)))
441
+ // A standalone page in the Settings panel navigation. The shell
442
+ // never subscribes locale state, so re-register with a fresh label
443
+ // whenever the locale changes.
444
+ const registerSection = () => ctx.slots.register({
445
+ name: 'settings.section',
446
+ id: ENTRY_ID,
447
+ order: 35,
448
+ label: () => t('nav'),
449
+ inject: () => ({ form, mirror, t }),
450
+ }, ExaSettingsPage)
451
+ let sectionOff = registerSection()
452
+ yield ctx.locale.subscribe(() => {
453
+ try {
454
+ sectionOff()
455
+ sectionOff = registerSection()
456
+ } catch { /* the shell may be mid-reload; the next locale event retries */ }
457
+ })
458
+ yield () => { sectionOff() }
459
+ yield ctx.slots.inject('settings.section.icon', () => ctx.slots.register({
460
+ name: 'settings.section.icon',
461
+ id: ENTRY_ID,
462
+ }, ExaSettingsIcon))
463
+ yield () => { style.remove() }
464
+ }, 'dsh-exa-tools client lifecycle')
465
+ },
466
+ }
467
+ },
468
+ })
@@ -0,0 +1,4 @@
1
+ - insert:
2
+ - id: exa-tools
3
+ name: dsh-exa-tools
4
+ config: {}