@thehoneyjar/sigil-hud 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/src/types.ts ADDED
@@ -0,0 +1,276 @@
1
+ /**
2
+ * @sigil/hud
3
+ *
4
+ * Types for the diagnostic HUD.
5
+ */
6
+
7
+ import type { ReactNode } from 'react'
8
+
9
+ // Local interfaces for optional services
10
+ // These mirror the actual service interfaces from optional packages
11
+
12
+ export interface LensState {
13
+ enabled: boolean
14
+ impersonatedAddress: string | null
15
+ realAddress: string | null
16
+ savedAddresses: Array<{ address: string; label: string }>
17
+ }
18
+
19
+ export interface LensService {
20
+ getState(): LensState
21
+ setImpersonatedAddress(address: string): void
22
+ clearImpersonation(): void
23
+ saveAddress(entry: { address: string; label: string }): void
24
+ enable(): void
25
+ disable(): void
26
+ }
27
+
28
+ export interface ForkState {
29
+ active: boolean
30
+ chainId?: number
31
+ blockNumber?: number
32
+ snapshotCount?: number
33
+ rpcUrl?: string
34
+ }
35
+
36
+ export interface ForkService {
37
+ getState(): ForkState
38
+ }
39
+
40
+ export interface SimulationState {
41
+ isRunning: boolean
42
+ lastResult: unknown | null
43
+ }
44
+
45
+ export interface SimulationService {
46
+ getState(): SimulationState
47
+ }
48
+
49
+ export interface DiagnosticIssue {
50
+ severity: 'error' | 'warning' | 'info'
51
+ code: string
52
+ message: string
53
+ suggestion?: string
54
+ }
55
+
56
+ export type EffectType = 'financial' | 'destructive' | 'soft-delete' | 'standard' | 'local' | 'navigation' | 'query'
57
+
58
+ export interface BehavioralCompliance {
59
+ sync: string
60
+ timing: number
61
+ confirmation: boolean
62
+ compliant: boolean
63
+ }
64
+
65
+ export interface AnimationCompliance {
66
+ easing: string
67
+ duration: number
68
+ compliant: boolean
69
+ }
70
+
71
+ export interface MaterialCompliance {
72
+ surface: string
73
+ shadow: string
74
+ compliant: boolean
75
+ }
76
+
77
+ export interface ComplianceResult {
78
+ behavioral: BehavioralCompliance
79
+ animation: AnimationCompliance
80
+ material: MaterialCompliance
81
+ }
82
+
83
+ export interface DiagnosticResult {
84
+ component: string
85
+ effect: EffectType
86
+ issues: DiagnosticIssue[]
87
+ compliance: ComplianceResult
88
+ suggestions: string[]
89
+ }
90
+
91
+ export interface DiagnosticsService {
92
+ analyze(component: string, code?: string): Promise<DiagnosticResult>
93
+ diagnose(symptom: string): string
94
+ checkCompliance(effect: string, physics: unknown): boolean
95
+ detectEffect(keywords: string[], types?: string[]): string
96
+ }
97
+
98
+ // Anchor client is not directly used but kept for compatibility
99
+ export type AnchorClient = unknown
100
+
101
+ /**
102
+ * HUD panel position
103
+ */
104
+ export type HudPosition =
105
+ | 'bottom-right'
106
+ | 'bottom-left'
107
+ | 'top-right'
108
+ | 'top-left'
109
+
110
+ /**
111
+ * HUD configuration
112
+ */
113
+ export interface HudConfig {
114
+ /** Enable keyboard shortcuts */
115
+ shortcuts?: boolean
116
+ /** Default panel position */
117
+ position?: HudPosition
118
+ /** Persist panel state to localStorage */
119
+ persist?: boolean
120
+ /** Enable observation capture */
121
+ observationCapture?: boolean
122
+ /** Enable signal capture */
123
+ signalCapture?: boolean
124
+ /** Default panel to open */
125
+ defaultPanel?: HudPanelType
126
+ }
127
+
128
+ /**
129
+ * HUD panel types
130
+ */
131
+ export type HudPanelType =
132
+ | 'lens'
133
+ | 'simulation'
134
+ | 'diagnostics'
135
+ | 'state'
136
+ | 'signals'
137
+
138
+ /**
139
+ * HUD state
140
+ */
141
+ export interface HudState {
142
+ /** Whether HUD is open */
143
+ isOpen: boolean
144
+ /** Current active panel */
145
+ activePanel: HudPanelType | null
146
+ /** Panel position */
147
+ position: HudPosition
148
+ /** Whether HUD is minimized */
149
+ isMinimized: boolean
150
+ }
151
+
152
+ /**
153
+ * HUD actions
154
+ */
155
+ export interface HudActions {
156
+ /** Open the HUD */
157
+ open: () => void
158
+ /** Close the HUD */
159
+ close: () => void
160
+ /** Toggle HUD visibility */
161
+ toggle: () => void
162
+ /** Set active panel */
163
+ setActivePanel: (panel: HudPanelType | null) => void
164
+ /** Set position */
165
+ setPosition: (position: HudPosition) => void
166
+ /** Toggle minimized state */
167
+ toggleMinimized: () => void
168
+ }
169
+
170
+ /**
171
+ * HUD context value
172
+ */
173
+ export interface HudContextValue extends HudState, HudActions {
174
+ /** Lens service instance (if available) */
175
+ lensService: LensService | null
176
+ /** Fork service instance (if available) */
177
+ forkService: ForkService | null
178
+ /** Simulation service instance (if available) */
179
+ simulationService: SimulationService | null
180
+ /** Diagnostics service instance (if available) */
181
+ diagnosticsService: DiagnosticsService | null
182
+ /** Anchor client instance (if available) */
183
+ anchorClient: AnchorClient | null
184
+ /** HUD configuration */
185
+ config: HudConfig
186
+ }
187
+
188
+ /**
189
+ * HUD provider props
190
+ */
191
+ export interface HudProviderProps {
192
+ children: ReactNode
193
+ config?: HudConfig
194
+ /** Optional package instances (for composition) */
195
+ lensService?: LensService
196
+ forkService?: ForkService
197
+ simulationService?: SimulationService
198
+ diagnosticsService?: DiagnosticsService
199
+ anchorClient?: AnchorClient
200
+ }
201
+
202
+ /**
203
+ * Observation for capturing user insights
204
+ */
205
+ export interface Observation {
206
+ id: string
207
+ timestamp: string
208
+ type: 'user-truth' | 'issue' | 'insight'
209
+ content: string
210
+ tags: string[]
211
+ context?: {
212
+ component?: string
213
+ effect?: string
214
+ lensAddress?: string
215
+ screenshot?: string
216
+ }
217
+ linkedSignals?: string[]
218
+ }
219
+
220
+ /**
221
+ * Taste signal for learning user preferences
222
+ */
223
+ export interface Signal {
224
+ timestamp: string
225
+ signal: 'ACCEPT' | 'MODIFY' | 'REJECT'
226
+ source: 'cli' | 'toolbar' | 'hud'
227
+ component: {
228
+ name: string
229
+ effect: string
230
+ craft_type: 'generate' | 'diagnose' | 'repair'
231
+ }
232
+ physics?: {
233
+ behavioral?: { sync: string; timing: string; confirmation: string }
234
+ animation?: { easing: string; duration: string }
235
+ material?: { surface: string; shadow: string; radius: string }
236
+ }
237
+ hud_context?: {
238
+ panel_visible: boolean
239
+ diagnostics_shown: boolean
240
+ observation_linked?: string
241
+ }
242
+ change?: { from: string; to: string }
243
+ learning?: { inference: string; recommendation?: string }
244
+ rejection_reason?: string
245
+ }
246
+
247
+ /**
248
+ * Default HUD state
249
+ */
250
+ export const DEFAULT_HUD_STATE: HudState = {
251
+ isOpen: false,
252
+ activePanel: null,
253
+ position: 'bottom-right',
254
+ isMinimized: false,
255
+ }
256
+
257
+ /**
258
+ * Default HUD config
259
+ */
260
+ export const DEFAULT_HUD_CONFIG: HudConfig = {
261
+ shortcuts: true,
262
+ position: 'bottom-right',
263
+ persist: true,
264
+ observationCapture: true,
265
+ signalCapture: true,
266
+ }
267
+
268
+ /**
269
+ * Default lens state for when lens service is not available
270
+ */
271
+ export const DEFAULT_LENS_STATE: LensState = {
272
+ enabled: false,
273
+ impersonatedAddress: null,
274
+ realAddress: null,
275
+ savedAddresses: [],
276
+ }