uidex 0.2.1 → 0.3.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.
Files changed (61) hide show
  1. package/README.md +263 -263
  2. package/dist/cli/cli.cjs +3243 -0
  3. package/dist/cli/cli.cjs.map +1 -0
  4. package/dist/cloud/index.cjs +149 -0
  5. package/dist/cloud/index.cjs.map +1 -0
  6. package/dist/cloud/index.d.cts +108 -0
  7. package/dist/cloud/index.d.ts +108 -0
  8. package/dist/cloud/index.js +120 -0
  9. package/dist/cloud/index.js.map +1 -0
  10. package/dist/headless/index.cjs +3580 -0
  11. package/dist/headless/index.cjs.map +1 -0
  12. package/dist/headless/index.d.cts +214 -0
  13. package/dist/headless/index.d.ts +214 -0
  14. package/dist/headless/index.js +3562 -0
  15. package/dist/headless/index.js.map +1 -0
  16. package/dist/index.cjs +7977 -3301
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +898 -108
  19. package/dist/index.d.ts +898 -108
  20. package/dist/index.js +7934 -3270
  21. package/dist/index.js.map +1 -1
  22. package/dist/playwright/index.cjs +164 -24
  23. package/dist/playwright/index.cjs.map +1 -1
  24. package/dist/playwright/index.d.cts +32 -55
  25. package/dist/playwright/index.d.ts +32 -55
  26. package/dist/playwright/index.js +148 -21
  27. package/dist/playwright/index.js.map +1 -1
  28. package/dist/playwright/reporter.cjs +62 -28
  29. package/dist/playwright/reporter.cjs.map +1 -1
  30. package/dist/playwright/reporter.d.cts +24 -12
  31. package/dist/playwright/reporter.d.ts +24 -12
  32. package/dist/playwright/reporter.js +62 -28
  33. package/dist/playwright/reporter.js.map +1 -1
  34. package/dist/react/index.cjs +7970 -3267
  35. package/dist/react/index.cjs.map +1 -1
  36. package/dist/react/index.d.cts +670 -108
  37. package/dist/react/index.d.ts +670 -108
  38. package/dist/react/index.js +8016 -3274
  39. package/dist/react/index.js.map +1 -1
  40. package/dist/scan/index.cjs +3281 -0
  41. package/dist/scan/index.cjs.map +1 -0
  42. package/dist/scan/index.d.cts +373 -0
  43. package/dist/scan/index.d.ts +373 -0
  44. package/dist/scan/index.js +3224 -0
  45. package/dist/scan/index.js.map +1 -0
  46. package/package.json +74 -56
  47. package/templates/claude/audit.md +37 -0
  48. package/templates/claude/rules.md +212 -0
  49. package/claude/audit-command.md +0 -16
  50. package/claude/rules.md +0 -88
  51. package/dist/core/index.cjs +0 -3490
  52. package/dist/core/index.cjs.map +0 -1
  53. package/dist/core/index.d.cts +0 -441
  54. package/dist/core/index.d.ts +0 -441
  55. package/dist/core/index.global.js +0 -3469
  56. package/dist/core/index.global.js.map +0 -1
  57. package/dist/core/index.js +0 -3444
  58. package/dist/core/index.js.map +0 -1
  59. package/dist/core/style.css +0 -971
  60. package/dist/scripts/cli.cjs +0 -1168
  61. package/uidex.schema.json +0 -93
package/dist/index.d.cts CHANGED
@@ -1,65 +1,281 @@
1
- type BorderStyle = 'solid' | 'dashed' | 'dotted';
2
- type LabelPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
3
- type ButtonPosition = 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
4
- interface UidexDefaults {
5
- color?: string;
6
- borderStyle?: BorderStyle;
7
- borderWidth?: number;
8
- showLabel?: boolean;
9
- labelPosition?: LabelPosition;
1
+ import { StoreApi } from 'zustand/vanilla';
2
+ import { IconNode } from 'lucide';
3
+
4
+ declare const ENTITY_KINDS: readonly ["route", "page", "feature", "widget", "region", "element", "primitive", "flow"];
5
+ type EntityKind = (typeof ENTITY_KINDS)[number];
6
+ type Scope = string;
7
+ interface Location {
8
+ file: string;
9
+ line?: number;
10
+ column?: number;
10
11
  }
11
- interface UidexConfig {
12
- defaults?: UidexDefaults;
13
- colors?: Record<string, string>;
12
+ interface EntityRef {
13
+ kind: EntityKind;
14
+ id: string;
14
15
  }
15
- interface UidexLocation {
16
- filePath: string;
17
- line: number;
18
- doc?: string;
16
+ interface Metadata {
17
+ name?: string;
18
+ description?: string;
19
+ acceptance?: string[];
20
+ notes?: string;
21
+ composes?: EntityRef[];
22
+ flows?: readonly string[];
23
+ features?: string[];
24
+ widgets?: string[];
19
25
  }
20
- type UidexMap = Record<string, UidexLocation[]>;
21
- interface UidexPage {
22
- dir: string;
23
- content: string;
24
- componentIds: string[];
26
+ interface EntityWithMetaBase {
27
+ id: string;
28
+ loc?: Location;
29
+ scopes?: Scope[];
30
+ meta?: Metadata;
25
31
  }
26
- interface UidexFeature {
27
- dir: string;
28
- content: string;
29
- componentIds: string[];
32
+ interface Route {
33
+ kind: "route";
34
+ path: string;
35
+ page: string;
30
36
  }
31
- interface KeyboardShortcut {
32
- key: string;
33
- ctrlKey?: boolean;
34
- shiftKey?: boolean;
35
- altKey?: boolean;
36
- metaKey?: boolean;
37
+ interface Flow {
38
+ kind: "flow";
39
+ id: string;
40
+ loc: Location;
41
+ touches: string[];
37
42
  }
38
- interface IngestConfig {
39
- endpoint: string;
40
- apiKey: string;
41
- environment?: string;
42
- appVersion?: string;
43
- reporter?: {
44
- email?: string;
45
- name?: string;
46
- };
47
- metadata?: Record<string, string>;
48
- captureConsole?: boolean;
49
- captureNetwork?: boolean;
43
+ interface Page extends EntityWithMetaBase {
44
+ kind: "page";
45
+ }
46
+ interface Feature extends EntityWithMetaBase {
47
+ kind: "feature";
48
+ }
49
+ interface Widget extends EntityWithMetaBase {
50
+ kind: "widget";
51
+ }
52
+ interface Region extends EntityWithMetaBase {
53
+ kind: "region";
54
+ }
55
+ interface Element$1 extends EntityWithMetaBase {
56
+ kind: "element";
57
+ }
58
+ interface Primitive extends EntityWithMetaBase {
59
+ kind: "primitive";
60
+ }
61
+ type Entity = Route | Page | Feature | Widget | Region | Element$1 | Primitive | Flow;
62
+ type EntityByKind<K extends EntityKind> = Extract<Entity, {
63
+ kind: K;
64
+ }>;
65
+ type MetaEntityKind = Exclude<EntityKind, "route" | "flow">;
66
+ declare function isMetaKind(kind: EntityKind): kind is MetaEntityKind;
67
+ declare function entityKey(entity: Entity): string;
68
+ declare class UnknownEntityKindError extends Error {
69
+ readonly kind: string;
70
+ constructor(kind: string);
71
+ }
72
+ declare function assertEntityKind(kind: string): asserts kind is EntityKind;
73
+
74
+ interface Registry {
75
+ add(entity: Entity): void;
76
+ get<K extends EntityKind>(kind: K, id: string): EntityByKind<K> | undefined;
77
+ list<K extends EntityKind>(kind: K): ReadonlyArray<EntityByKind<K>>;
78
+ query(predicate: (entity: Entity) => boolean): Entity[];
79
+ byScope(scope: Scope): Entity[];
80
+ touchedBy(flowId: string): Entity[];
50
81
  }
51
- type FeedbackResult = {
52
- ok: true;
82
+ declare function createRegistry(): Registry;
83
+
84
+ interface KindStyleEntry {
85
+ icon: IconNode;
86
+ tone: string;
87
+ chip: string;
88
+ color: string;
89
+ label: string;
90
+ }
91
+ declare const KIND_STYLE: Record<EntityKind, KindStyleEntry>;
92
+
93
+ declare function prettify(id: string): string;
94
+ declare function displayName(entity: Entity, node?: Element | null): string;
95
+
96
+ interface HighlightContext {
97
+ ref: EntityRef | null;
98
+ element: HTMLElement | null;
99
+ pinnedRef: EntityRef | null;
100
+ color: string | null;
101
+ }
102
+
103
+ type ThemePreference = "light" | "dark" | "auto";
104
+ type ResolvedTheme = "light" | "dark";
105
+ interface ViewStackEntry {
53
106
  id: string;
54
- sequenceNumber: number;
107
+ ref: EntityRef | null;
108
+ }
109
+ interface SessionSnapshot {
110
+ hover: EntityRef | null;
111
+ selection: EntityRef | null;
112
+ stack: ViewStackEntry[];
113
+ /** Sticky overlay highlight. Set by "Highlight Element" actions; cleared on Esc. */
114
+ pinnedHighlight: EntityRef | null;
115
+ inspectorActive: boolean;
116
+ theme: ThemePreference;
117
+ resolvedTheme: ResolvedTheme;
118
+ ingestActive: boolean;
119
+ }
120
+ interface SessionActions {
121
+ hover(ref: EntityRef | null): void;
122
+ select(ref: EntityRef | null): void;
123
+ /**
124
+ * Append a view onto the view stack. Pure: never resolves defaults.
125
+ */
126
+ pushStack(entry: ViewStackEntry): void;
127
+ /**
128
+ * Remove the top entry from the view stack. No-op when the stack is empty.
129
+ */
130
+ popStack(): void;
131
+ /**
132
+ * Empty the view stack.
133
+ */
134
+ clearStack(): void;
135
+ /**
136
+ * Open a view by id. If `ref` is omitted, the current `selection` is captured;
137
+ * pass `null` explicitly to open the view with no ref context. Thin wrapper
138
+ * around `pushStack`.
139
+ */
140
+ openView(id: string, ref?: EntityRef | null): void;
141
+ /**
142
+ * Clear the entire view stack. Thin wrapper around `clearStack`.
143
+ */
144
+ closeView(): void;
145
+ setInspectorActive(active: boolean): void;
146
+ toggleInspector(): void;
147
+ /** Pin the overlay to `ref` until `clearPinnedHighlight` is called. */
148
+ pinHighlight(ref: EntityRef): void;
149
+ clearPinnedHighlight(): void;
150
+ setTheme(theme: ThemePreference, resolved?: ResolvedTheme): void;
151
+ setIngest(active: boolean): void;
152
+ }
153
+ interface SessionState extends SessionSnapshot {
154
+ actions: SessionActions;
155
+ }
156
+
157
+ type SurfaceEvent = {
158
+ type: "TOGGLE_INSPECTOR";
159
+ } | {
160
+ type: "OPEN_PALETTE";
161
+ } | {
162
+ type: "PUSH_VIEW";
163
+ entry: ViewStackEntry;
164
+ } | {
165
+ type: "POP_VIEW";
166
+ } | {
167
+ type: "CLOSE";
168
+ } | {
169
+ type: "ESC";
170
+ } | {
171
+ type: "CMD_K";
172
+ } | {
173
+ type: "SELECT";
174
+ ref: EntityRef | null;
175
+ entry: ViewStackEntry;
176
+ } | {
177
+ type: "SET_SELECTION";
178
+ ref: EntityRef | null;
179
+ } | {
180
+ type: "HOVER";
181
+ ref: EntityRef;
182
+ element: HTMLElement | null;
183
+ color?: string | null;
184
+ } | {
185
+ type: "UNHOVER";
186
+ } | {
187
+ type: "PIN";
188
+ ref?: EntityRef;
189
+ } | {
190
+ type: "UNPIN";
191
+ } | {
192
+ type: "SET_THEME";
193
+ theme: ThemePreference;
194
+ resolvedTheme: ResolvedTheme;
55
195
  } | {
56
- ok: false;
57
- error: string;
196
+ type: "SET_INGEST";
197
+ active: boolean;
58
198
  };
59
- type FeedbackType = 'bug' | 'feature' | 'improvement' | 'question';
60
- type FeedbackSeverity = 'low' | 'medium' | 'high' | 'critical';
199
+
200
+ type SessionStore = StoreApi<SessionState> & {
201
+ send(event: SurfaceEvent): void;
202
+ };
203
+ interface SurfaceBindings {
204
+ mountInspector?: () => void;
205
+ destroyInspector?: () => void;
206
+ openActionsPopup?: () => void;
207
+ closePopup?: () => void;
208
+ }
209
+ interface HighlightBindings {
210
+ showOverlay?: (context: HighlightContext) => void;
211
+ hideOverlay?: () => void;
212
+ updateOverlay?: (context: HighlightContext) => void;
213
+ }
214
+ interface SessionBindings {
215
+ surface?: SurfaceBindings;
216
+ highlight?: HighlightBindings;
217
+ }
218
+ interface CreateSessionOptions extends Partial<SessionSnapshot> {
219
+ detectTheme?: () => ResolvedTheme;
220
+ /**
221
+ * Action implementations injected into the surface machine and its
222
+ * highlight child actor. Implementations may be closures that read from
223
+ * mutable refs filled in after `createSession` returns (e.g., the SDK's
224
+ * shell isn't available until `mount`).
225
+ */
226
+ bindings?: SessionBindings;
227
+ }
228
+ declare function resolveTheme(preference: ThemePreference, detect?: () => ResolvedTheme): ResolvedTheme;
229
+ declare function createSession(options?: CreateSessionOptions): SessionStore;
230
+
231
+ type ConsoleLevel = "warn" | "error";
232
+ interface ConsoleEntry {
233
+ level: ConsoleLevel;
234
+ message: string;
235
+ timestamp: string;
236
+ }
237
+ interface ConsoleCaptureOptions {
238
+ limit?: number;
239
+ target?: Console;
240
+ now?: () => Date;
241
+ }
242
+ interface ConsoleCapture {
243
+ start(): void;
244
+ stop(): void;
245
+ readonly isActive: boolean;
246
+ entries(): readonly ConsoleEntry[];
247
+ clear(): void;
248
+ }
249
+ declare function createConsoleCapture(options?: ConsoleCaptureOptions): ConsoleCapture;
250
+
251
+ interface NetworkEntry {
252
+ method: string;
253
+ url: string;
254
+ status: number;
255
+ timestamp: string;
256
+ error?: string;
257
+ }
258
+ interface NetworkCaptureOptions {
259
+ limit?: number;
260
+ target?: {
261
+ fetch?: typeof fetch;
262
+ };
263
+ now?: () => Date;
264
+ }
265
+ interface NetworkCapture {
266
+ start(): void;
267
+ stop(): void;
268
+ readonly isActive: boolean;
269
+ entries(): readonly NetworkEntry[];
270
+ clear(): void;
271
+ }
272
+ declare function createNetworkCapture(options?: NetworkCaptureOptions): NetworkCapture;
273
+
274
+ declare const nativeFetch: typeof fetch | undefined;
275
+ declare function getNativeFetch(): typeof fetch | undefined;
276
+
61
277
  interface ConsoleLogEntry {
62
- level: 'warn' | 'error';
278
+ level: "log" | "warn" | "error" | "info";
63
279
  message: string;
64
280
  timestamp: string;
65
281
  }
@@ -67,83 +283,657 @@ interface NetworkErrorEntry {
67
283
  url: string;
68
284
  method: string;
69
285
  status: number | null;
70
- statusText: string;
286
+ statusText: string | null;
71
287
  timestamp: string;
72
288
  }
73
- interface FeedbackReport {
74
- type: FeedbackType;
75
- severity: FeedbackSeverity;
289
+ interface Viewport {
290
+ width: number;
291
+ height: number;
292
+ }
293
+ interface SourceRef {
294
+ filePath: string;
295
+ line: number;
296
+ }
297
+ interface FeedbackSuggestedTarget {
298
+ integrationId: string;
299
+ targetConfig: Record<string, unknown>;
300
+ }
301
+ interface FeedbackPayload {
302
+ type: "bug" | "feature" | "improvement" | "question";
303
+ severity: "low" | "medium" | "high" | "critical";
76
304
  title?: string;
77
305
  description: string;
78
306
  componentId: string;
79
- element: string | null;
80
- sources: {
81
- filePath: string;
82
- line: number;
83
- }[];
307
+ element?: string | null;
308
+ sources?: SourceRef[];
84
309
  url: string;
85
310
  path: string;
86
- route: string | null;
87
- timestamp: string;
88
- pageTitle: string;
89
- locale: string;
90
- sessionId: string;
91
- viewport: {
92
- width: number;
93
- height: number;
94
- };
95
- screen: {
96
- width: number;
97
- height: number;
98
- };
99
- userAgent: string;
100
- screenshot?: string;
311
+ route?: string | null;
312
+ pageTitle?: string;
313
+ sessionId?: string;
101
314
  reporterEmail?: string;
102
315
  reporterName?: string;
316
+ timestamp: string;
317
+ viewport: Viewport;
318
+ screen: Viewport;
319
+ userAgent: string;
320
+ locale?: string;
103
321
  environment?: string;
104
322
  appVersion?: string;
105
- metadata?: Record<string, string>;
106
323
  consoleLogs?: ConsoleLogEntry[];
107
324
  networkErrors?: NetworkErrorEntry[];
325
+ metadata?: Record<string, string>;
326
+ screenshot?: string;
327
+ suggestedTarget?: FeedbackSuggestedTarget;
328
+ }
329
+ interface FeedbackExternalLink {
330
+ ok: boolean;
331
+ url?: string;
332
+ key?: string;
333
+ error?: string;
334
+ }
335
+ interface FeedbackResult {
336
+ id: string;
337
+ sequenceNumber: number;
338
+ externalLink?: FeedbackExternalLink;
339
+ }
340
+ interface IngestConfigEpic {
341
+ key: string;
342
+ summary: string;
343
+ status: string;
344
+ }
345
+ interface IngestConfig {
346
+ hasJira: boolean;
347
+ integrationId?: string;
348
+ epics?: IngestConfigEpic[];
349
+ }
350
+ /**
351
+ * Generic so third-party adapters (e.g. `uidex-cloud`) can plug in their own
352
+ * payload/result/integration shapes. SDK-bundled `cloud()` returns the
353
+ * defaulted form. `ViewContext.cloud` uses the fully-open variant; consumers
354
+ * that need the SDK shape narrow with `as CloudAdapter`.
355
+ */
356
+ interface CloudAdapter<TPayload = FeedbackPayload, TResult = FeedbackResult, TIntegrations = {
357
+ getConfig(): Promise<IngestConfig>;
358
+ }> {
359
+ readonly feedback: {
360
+ submit(payload: TPayload): Promise<TResult>;
361
+ };
362
+ readonly integrations: TIntegrations;
108
363
  }
109
364
 
110
- interface UidexDevtoolsProps {
111
- components?: UidexMap;
112
- config?: UidexConfig;
113
- buttonPosition?: ButtonPosition;
114
- disabled?: boolean;
115
- onSelect?: (id: string) => void;
116
- /** Keyboard shortcut to toggle inspect mode. Default: Shift+Cmd+U. Set to false to disable. */
117
- inspectShortcut?: KeyboardShortcut | false;
118
- /** Ingest configuration for submitting feedback to a server. */
119
- ingest?: IngestConfig;
120
- /** Called after feedback submission with the report and result. */
121
- onSubmit?: (report: FeedbackReport, result: FeedbackResult) => void;
365
+ interface IngestOptions {
366
+ captureConsole?: boolean;
367
+ captureNetwork?: boolean;
368
+ consoleLimit?: number;
369
+ networkLimit?: number;
370
+ consoleTarget?: ConsoleCaptureOptions["target"];
371
+ networkTarget?: NetworkCaptureOptions["target"];
372
+ now?: () => Date;
122
373
  }
123
- declare function UidexDevtools({ components, config, buttonPosition, disabled, onSelect, inspectShortcut, ingest, onSubmit, }: UidexDevtoolsProps): null;
374
+ interface Ingest {
375
+ start(): void;
376
+ stop(): void;
377
+ readonly isActive: boolean;
378
+ readonly console: ConsoleCapture | null;
379
+ readonly network: NetworkCapture | null;
380
+ }
381
+ interface CreateIngestOptions extends IngestOptions {
382
+ session?: SessionStore;
383
+ }
384
+ declare function createIngest(options?: CreateIngestOptions): Ingest;
385
+ declare function resolveIngestOptions(explicit: IngestOptions | null | undefined, hasCloud: boolean): IngestOptions | null;
124
386
 
125
- interface UidexOverlayProps {
126
- target: HTMLElement | null;
387
+ interface SurfaceHost {
388
+ readonly hostEl: HTMLElement;
389
+ readonly shadowRoot: ShadowRoot;
390
+ readonly chromeEl: HTMLElement;
391
+ applyTheme(theme: ResolvedTheme): void;
392
+ destroy(): void;
393
+ }
394
+ interface SurfaceHostOptions {
395
+ mount: Element;
396
+ stylesheets?: string[];
397
+ initialTheme?: ResolvedTheme;
398
+ }
399
+ declare function createSurfaceHost(options: SurfaceHostOptions): SurfaceHost;
400
+
401
+ type Cleanup$1 = () => void;
402
+ interface Disposable {
403
+ destroy(): void;
404
+ }
405
+ interface CleanupStack {
406
+ add(cleanup: Cleanup$1 | Disposable | null | undefined): void;
407
+ drain(): void;
408
+ }
409
+
410
+ type CursorTooltipContent = {
411
+ entity: Entity;
412
+ node?: Element | null;
413
+ } | string;
414
+ interface CursorTooltip {
415
+ destroy(): void;
416
+ /** Present content for the current cursor position. */
417
+ update(content: CursorTooltipContent | null, cursor: {
418
+ x: number;
419
+ y: number;
420
+ } | null): void;
421
+ }
422
+ interface CursorTooltipDeps {
423
+ container: Element;
424
+ session: SessionStore;
425
+ }
426
+ declare function createCursorTooltip(deps: CursorTooltipDeps): CursorTooltip;
427
+
428
+ interface OverlayShowOptions {
429
+ label?: string;
127
430
  color?: string;
128
- borderStyle?: BorderStyle;
431
+ padding?: number;
432
+ borderStyle?: string;
129
433
  borderWidth?: number;
130
- label?: string;
131
- showLabel?: boolean;
132
- labelPosition?: LabelPosition;
133
- colors?: Record<string, string>;
434
+ fillOpacity?: number;
435
+ }
436
+ interface Overlay {
437
+ show(target: Element, options?: OverlayShowOptions): void;
438
+ hide(): void;
439
+ destroy(): void;
440
+ readonly isVisible: boolean;
441
+ }
442
+ interface OverlayDeps {
443
+ container: Element;
444
+ }
445
+ declare function createOverlay(deps: OverlayDeps): Overlay;
446
+
447
+ interface InspectorMatch {
448
+ element: HTMLElement;
449
+ ref: EntityRef;
450
+ entity: Entity;
451
+ /** Display name resolved via `displayName(entity, element)`. */
452
+ label: string;
453
+ }
454
+ interface InspectorOptions {
455
+ session: SessionStore;
456
+ registry?: Registry;
457
+ resolve?: (target: Element) => InspectorMatch | null;
458
+ onHover?: (match: InspectorMatch | null, cursor: {
459
+ x: number;
460
+ y: number;
461
+ } | null) => void;
462
+ onSelect?: (match: InspectorMatch, cursor: {
463
+ x: number;
464
+ y: number;
465
+ }) => void;
466
+ }
467
+ interface Inspector {
468
+ mount(): void;
469
+ destroy(): void;
470
+ }
471
+ declare function defaultResolveMatch(target: Element, registry?: Registry): InspectorMatch | null;
472
+ declare function resolveEntityElement(ref: EntityRef): HTMLElement | null;
473
+ interface HighlightControllerLike {
474
+ show(ref: EntityRef, opts?: OverlayShowOptions): void;
475
+ hide(): void;
476
+ }
477
+ declare function createHighlightController(overlay: Overlay): HighlightControllerLike;
478
+ declare function createInspector(options: InspectorOptions): Inspector;
479
+
480
+ type Corner = "top-left" | "top-right" | "bottom-left" | "bottom-right";
481
+ interface MenuBarOptions {
482
+ container: Element;
483
+ session: SessionStore;
484
+ initialCorner?: Corner;
485
+ appTitle?: string;
486
+ }
487
+ interface MenuBar {
488
+ destroy(): void;
489
+ snapTo(corner: Corner): void;
490
+ snapToNearest(x: number, y: number): void;
491
+ readonly corner: Corner;
492
+ readonly root: HTMLElement;
493
+ }
494
+ declare function createMenuBar(options: MenuBarOptions): MenuBar;
495
+
496
+ interface ThemeDetector {
497
+ destroy(): void;
498
+ /** Resolve the current theme preference against the environment. */
499
+ readonly resolved: ResolvedTheme;
134
500
  }
135
- declare function UidexOverlay({ target, color, borderStyle, borderWidth, label, showLabel, labelPosition, colors, }: UidexOverlayProps): null;
501
+ interface ThemeDetectorDeps {
502
+ session: SessionStore;
503
+ onResolve?: (theme: ResolvedTheme) => void;
504
+ }
505
+ declare function createThemeDetector(deps: ThemeDetectorDeps): ThemeDetector;
136
506
 
137
- declare function registerComponents(components: UidexMap): void;
138
- declare function getComponents(): UidexMap | null;
139
- declare function registerPages(pages: UidexPage[]): void;
140
- declare function getPages(): UidexPage[] | null;
141
- declare function registerFeatures(features: UidexFeature[]): void;
142
- declare function getFeatures(): UidexFeature[] | null;
507
+ interface CreateSurfaceShellOptions {
508
+ mount: Element;
509
+ registry: Registry;
510
+ session: SessionStore;
511
+ stylesheets?: string[];
512
+ initialCorner?: Corner;
513
+ appTitle?: string;
514
+ /**
515
+ * Additional inspector wiring. Hover is pre-wired to overlay + tooltip; pass
516
+ * `onSelect` (and `onAfterHover`) to extend behaviour without rebuilding the
517
+ * host.
518
+ */
519
+ inspector?: Pick<InspectorOptions, "onSelect"> & {
520
+ onAfterHover?: InspectorOptions["onHover"];
521
+ };
522
+ }
523
+ interface SurfaceShell {
524
+ host: SurfaceHost;
525
+ overlay: Overlay;
526
+ tooltip: CursorTooltip;
527
+ inspector: Inspector;
528
+ menuBar: MenuBar;
529
+ themeDetector: ThemeDetector;
530
+ cleanup: CleanupStack;
531
+ destroy(): void;
532
+ }
533
+ /**
534
+ * Builds the chrome bundle shared by `createUidex` and `createHeadless`:
535
+ * host + theme detector + overlay + cursor tooltip + inspector + menu bar.
536
+ * Returns a cleanup stack so callers can register their own teardown in LIFO
537
+ * order, then call `destroy()` once to drain the whole thing.
538
+ */
539
+ declare function createSurfaceShell(options: CreateSurfaceShellOptions): SurfaceShell;
143
540
 
144
- declare function classNames(...classes: (string | undefined | null | false)[]): string;
145
- declare function getContrastColor(hexColor: string): string;
146
- declare function hexToRgba(hex: string, alpha: number): string;
147
- declare function resolveColor(color: string | undefined, colorMap?: Record<string, string>): string | undefined;
541
+ type ViewSurface = ListSurface | DetailSurface | FormSurface | CustomSurface;
542
+ interface ListSurface {
543
+ kind: "list";
544
+ id: string;
545
+ items: readonly ListItem[];
546
+ onSelect?(item: ListItem): void;
547
+ emptyLabel?: string;
548
+ defaultHighlight?: string;
549
+ filter?(item: ListItem, query: string): boolean;
550
+ }
551
+ interface ListItem {
552
+ value: string;
553
+ label: string;
554
+ subtitle?: string;
555
+ group?: string;
556
+ shortcut?: string;
557
+ /**
558
+ * When highlighted, the shell calls `ctx.highlight.show(preview)`.
559
+ * Cleared on unhighlight or view unmount.
560
+ */
561
+ preview?: EntityRef;
562
+ /** Renders a kind chip on the left. `entity.kind` drives icon + color. */
563
+ entityChip?: {
564
+ entity: Entity;
565
+ node?: Element | null;
566
+ };
567
+ /**
568
+ * Optional leading-icon factory used for non-entity rows (e.g. a palette
569
+ * "Feedback" command). Called per-render so the returned Node is fresh.
570
+ * The shell wraps whatever is returned in a rounded-square tile.
571
+ */
572
+ leading?: () => Node;
573
+ /** Raw data attribute tag appended to the row (for test/e2e hooks). */
574
+ tag?: string;
575
+ }
576
+ interface DetailSurface {
577
+ kind: "detail";
578
+ entityKind: EntityKind;
579
+ /** Registry lookup failed — renders the "not found" placeholder. */
580
+ notFound?: EntityRef;
581
+ /** Entity display name, rendered as the heading. */
582
+ title?: string;
583
+ subtitle?: DetailSubtitle;
584
+ actions?: readonly DetailAction[];
585
+ sections?: readonly DetailSection[];
586
+ }
587
+ interface DetailSubtitle {
588
+ rawId: string;
589
+ extra?: string;
590
+ }
591
+ interface DetailActionBase {
592
+ id: string;
593
+ label: string;
594
+ icon?: DetailActionIcon;
595
+ ariaLabel?: string;
596
+ hint?: string;
597
+ intent?: ShellActionIntent;
598
+ }
599
+ type DetailAction = (DetailActionBase & {
600
+ copy: string;
601
+ }) | (DetailActionBase & {
602
+ scrollTo: string;
603
+ }) | (DetailActionBase & {
604
+ push: {
605
+ id: string;
606
+ ref?: EntityRef | null;
607
+ };
608
+ }) | (DetailActionBase & {
609
+ navigate: EntityRef;
610
+ }) | (DetailActionBase & {
611
+ highlight: EntityRef;
612
+ }) | (DetailActionBase & {
613
+ run: (ctx: DetailActionRunContext) => void | Promise<void>;
614
+ });
615
+ type DetailActionIcon = "copy" | "message-circle" | "chevron-down" | "target";
616
+ interface DetailActionRunContext {
617
+ setLabel(next: string, durationMs?: number): void;
618
+ }
619
+ type DetailSection = {
620
+ id: "description";
621
+ text: string;
622
+ } | {
623
+ id: "acceptance";
624
+ items: readonly string[];
625
+ } | {
626
+ id: "scopes";
627
+ scopes: readonly string[];
628
+ } | {
629
+ id: "composes";
630
+ label: string;
631
+ entities: readonly Entity[];
632
+ filterable?: boolean;
633
+ } | {
634
+ id: "used-by";
635
+ label: string;
636
+ entities: readonly Entity[];
637
+ filterable?: boolean;
638
+ } | {
639
+ id: "flows";
640
+ flows: readonly Flow[];
641
+ filterable?: boolean;
642
+ } | {
643
+ id: "touches";
644
+ entities: readonly Entity[];
645
+ unresolved: readonly string[];
646
+ filterable?: boolean;
647
+ } | {
648
+ id: "routes";
649
+ paths: readonly string[];
650
+ filterable?: boolean;
651
+ };
652
+ interface FormSurface {
653
+ kind: "form";
654
+ id: string;
655
+ fields: readonly FormField[];
656
+ submit: FormSubmit;
657
+ initial?: Record<string, FormValue>;
658
+ /**
659
+ * Optional Standard Schema (Zod v4, Valibot, ArkType, etc.) run against the
660
+ * collected form values before `submit.onSubmit`. On failure, issues are
661
+ * routed to the matching `<FieldError>` and submission is skipped.
662
+ */
663
+ schema?: StandardSchemaV1<Record<string, unknown>>;
664
+ }
665
+ /**
666
+ * Minimal StandardSchemaV1 surface — kept inline so the SDK doesn't need a
667
+ * type-level dep on any specific validator package.
668
+ */
669
+ interface StandardSchemaV1<Input = unknown, Output = Input> {
670
+ readonly "~standard": {
671
+ readonly version: 1;
672
+ readonly vendor: string;
673
+ readonly validate: (value: unknown) => StandardSchemaResult<Output> | Promise<StandardSchemaResult<Output>>;
674
+ readonly types?: {
675
+ readonly input: Input;
676
+ readonly output: Output;
677
+ };
678
+ };
679
+ }
680
+ type StandardSchemaResult<Output> = {
681
+ readonly value: Output;
682
+ readonly issues?: undefined;
683
+ } | {
684
+ readonly issues: ReadonlyArray<StandardSchemaIssue>;
685
+ };
686
+ interface StandardSchemaIssue {
687
+ readonly message: string;
688
+ readonly path?: ReadonlyArray<PropertyKey | {
689
+ readonly key: PropertyKey;
690
+ }>;
691
+ }
692
+ interface FormSubmit {
693
+ label: string;
694
+ onSubmit: (values: Record<string, FormValue>) => FormSubmitResult | void | Promise<FormSubmitResult | void>;
695
+ }
696
+ type FormSubmitResult = {
697
+ status: "success";
698
+ message?: string;
699
+ link?: {
700
+ url: string;
701
+ label?: string;
702
+ };
703
+ resetFields?: readonly string[];
704
+ } | {
705
+ status: "error";
706
+ message: string;
707
+ /** Per-field error messages keyed by field `name`. */
708
+ fieldErrors?: Record<string, string>;
709
+ };
710
+ type FormValue = string | boolean;
711
+ interface FormFieldBase {
712
+ name: string;
713
+ label: string;
714
+ }
715
+ type FormField = (FormFieldBase & {
716
+ kind: "select";
717
+ options: readonly {
718
+ value: string;
719
+ label: string;
720
+ }[];
721
+ required?: boolean;
722
+ value?: string;
723
+ }) | (FormFieldBase & {
724
+ kind: "text";
725
+ placeholder?: string;
726
+ required?: boolean;
727
+ value?: string;
728
+ }) | (FormFieldBase & {
729
+ kind: "email";
730
+ placeholder?: string;
731
+ required?: boolean;
732
+ value?: string;
733
+ }) | (FormFieldBase & {
734
+ kind: "textarea";
735
+ placeholder?: string;
736
+ required?: boolean;
737
+ rows?: number;
738
+ value?: string;
739
+ }) | (FormFieldBase & {
740
+ kind: "checkbox";
741
+ value?: boolean;
742
+ });
743
+ interface CustomSurface {
744
+ kind: "custom";
745
+ render: (ctx: ViewContext, root: HTMLElement) => Cleanup | void;
746
+ }
747
+
748
+ interface ViewPalette {
749
+ label: string;
750
+ group?: string;
751
+ /**
752
+ * Leading-icon factory rendered as a rounded-square tile on the palette
753
+ * row. Called fresh per render (so a returned SVG isn't reparented).
754
+ */
755
+ icon?: () => Node;
756
+ shortcut?: string;
757
+ }
758
+ interface ViewDirectory {
759
+ list(): readonly View[];
760
+ }
761
+ interface ViewPushTarget {
762
+ id: string;
763
+ ref?: EntityRef | null;
764
+ }
765
+ interface HighlightController {
766
+ show(ref: EntityRef, opts?: OverlayShowOptions): void;
767
+ hide(): void;
768
+ }
769
+ interface ViewContext {
770
+ ref: EntityRef | null;
771
+ registry: Registry;
772
+ cloud: CloudAdapter<unknown, unknown, unknown> | null;
773
+ sdkCloud: CloudAdapter;
774
+ views: ViewDirectory;
775
+ /** Push a view onto the stack. Unregistered ids are a no-op. */
776
+ push: (target: ViewPushTarget) => void;
777
+ /** Pop the top view off the stack. No-op when the stack is empty. */
778
+ pop: () => void;
779
+ /** Clear the entire view stack. */
780
+ close: () => void;
781
+ /** Resolve the first view matching `ref` and push it onto the stack. */
782
+ navigate: (ref: EntityRef) => void;
783
+ /** Pin the overlay to `ref` until the user presses Esc. */
784
+ pinHighlight: (ref: EntityRef) => void;
785
+ /** Shell-owned search input. The shell dispatches its value into the active surface. */
786
+ searchInput: HTMLInputElement;
787
+ /** Drives the Surface's singleton overlay from inside a custom surface. */
788
+ highlight: HighlightController;
789
+ /** Snapshot of the current view stack (top-most last). */
790
+ getStack: () => readonly ViewStackEntry[];
791
+ }
792
+ interface ShellHint {
793
+ key: string;
794
+ label: string;
795
+ }
796
+ type ShellActionIntent = {
797
+ kind: "push";
798
+ viewId: string;
799
+ refKind?: EntityKind;
800
+ } | {
801
+ kind: "pop";
802
+ } | {
803
+ kind: "close";
804
+ } | {
805
+ kind: "navigate";
806
+ refKind?: EntityKind;
807
+ } | {
808
+ kind: "external";
809
+ describe: string;
810
+ };
811
+ interface ShellAction {
812
+ id: string;
813
+ label: string;
814
+ shortcut?: string;
815
+ perform: () => void | Promise<void>;
816
+ intent?: ShellActionIntent;
817
+ }
818
+ type Cleanup = () => void;
819
+ interface View {
820
+ id: string;
821
+ matches?: (ref: EntityRef) => boolean;
822
+ palette?: ViewPalette;
823
+ title?: string | ((ctx: ViewContext) => string);
824
+ /** Show the shell search input when this view is on top. Default: true. */
825
+ searchable?: boolean;
826
+ hints?: ShellHint[] | ((ctx: ViewContext) => ShellHint[]);
827
+ actions?: (ctx: ViewContext) => ShellAction[];
828
+ /**
829
+ * Element focused when this view becomes the top of the stack. The shell
830
+ * falls back to the first focusable element in the host when omitted, or
831
+ * when the declared target has been removed from the host.
832
+ */
833
+ focusTarget?: (root: HTMLElement, ctx: ViewContext) => HTMLElement | null;
834
+ surface: (ctx: ViewContext) => ViewSurface;
835
+ }
836
+ declare class ViewValidationError extends Error {
837
+ constructor(message: string);
838
+ }
839
+
840
+ interface ActionsPopupHandle {
841
+ readonly element: HTMLElement;
842
+ open(actions: ShellAction[]): void;
843
+ close(): void;
844
+ isOpen(): boolean;
845
+ handleKey(e: KeyboardEvent): boolean;
846
+ destroy(): void;
847
+ }
848
+
849
+ declare const SURFACE_HOST_CLASS = "uidex-surface-host";
850
+ declare const SURFACE_CONTAINER_CLASS = "uidex-container";
851
+ declare const Z_BASE = 2147483644;
852
+ declare const Z_OVERLAY = 2147483645;
853
+ declare const Z_CHROME = 2147483646;
854
+ declare const SURFACE_IGNORE_SELECTOR = ".uidex-surface-host,.uidex-container";
855
+
856
+ interface ViewRegistrar {
857
+ register(view: View): void;
858
+ unregister(id: string): void;
859
+ list(): readonly View[];
860
+ get(id: string): View | undefined;
861
+ findMatch(ref: EntityRef): View | null;
862
+ navigate(ref: EntityRef): void;
863
+ }
864
+ interface ViewRegistrarOptions {
865
+ session: SessionStore;
866
+ dev?: boolean;
867
+ }
868
+ declare function createViewRegistrar(options: ViewRegistrarOptions): ViewRegistrar;
869
+
870
+ interface ViewStackOptions {
871
+ container: HTMLElement;
872
+ views: ViewRegistrar;
873
+ session: SessionStore;
874
+ registry: Registry;
875
+ cloud?: CloudAdapter | null;
876
+ sdkCloud: CloudAdapter;
877
+ highlight: HighlightController;
878
+ globalActions?: (ctx: ViewContext) => ShellAction[];
879
+ dev?: boolean;
880
+ }
881
+ interface ViewStack {
882
+ /**
883
+ * The actions popup belonging to the currently mounted stack shell, or
884
+ * `null` when the shell is not mounted. Exposed so the unified shadow-root
885
+ * keydown handler can intercept keys while the popup is open.
886
+ */
887
+ getActionsPopup(): ActionsPopupHandle | null;
888
+ destroy(): void;
889
+ }
890
+ declare function createViewStack(options: ViewStackOptions): ViewStack;
891
+
892
+ declare const commandPaletteView: View;
893
+
894
+ declare const componentDetailView: View;
895
+ declare const featureDetailView: View;
896
+ declare const regionDetailView: View;
897
+ declare const widgetDetailView: View;
898
+ declare const primitiveDetailView: View;
899
+ declare const pageDetailView: View;
900
+
901
+ declare const feedbackView: View;
902
+
903
+ declare const flowDetailView: View;
904
+
905
+ declare const DEFAULT_VIEWS: readonly [View, View, View, View, View, View, View, View, View, View, View, View];
906
+
907
+ interface CreateUidexOptions {
908
+ theme?: ThemePreference;
909
+ resolvedTheme?: ResolvedTheme;
910
+ stylesheets?: string[];
911
+ initialCorner?: Corner;
912
+ /** Shown as a label at the start of the menu bar. */
913
+ appTitle?: string;
914
+ cloud?: CloudAdapter | null;
915
+ dev?: boolean;
916
+ /** Register bundled default views. Defaults to `true`. */
917
+ defaultViews?: boolean;
918
+ /** Additional views to register (after defaults). */
919
+ views?: readonly View[];
920
+ /**
921
+ * Override ingest behaviour. When `cloud` is non-null, ingest auto-enables
922
+ * (both console and network capture). Pass `null` to disable entirely, or
923
+ * an options object to override either channel.
924
+ */
925
+ ingest?: IngestOptions | null;
926
+ }
927
+ interface Uidex {
928
+ mount(target?: Element): void;
929
+ unmount(): void;
930
+ readonly registry: Registry;
931
+ readonly session: SessionStore;
932
+ readonly views: ViewRegistrar;
933
+ readonly cloud: CloudAdapter | null;
934
+ readonly ingest: Ingest | null;
935
+ readonly shadowRoot: ShadowRoot | null;
936
+ }
937
+ declare function createUidex(options?: CreateUidexOptions): Uidex;
148
938
 
149
- export { type BorderStyle, type ButtonPosition, type FeedbackReport, type FeedbackResult, type FeedbackSeverity, type FeedbackType, type IngestConfig, type KeyboardShortcut, type LabelPosition, type UidexConfig, type UidexDefaults, UidexDevtools, type UidexDevtoolsProps, type UidexFeature, type UidexLocation, type UidexMap, UidexOverlay, type UidexOverlayProps, type UidexPage, classNames, getComponents, getContrastColor, getFeatures, getPages, hexToRgba, registerComponents, registerFeatures, registerPages, resolveColor };
939
+ export { type Cleanup, type CloudAdapter, type ConsoleCapture, type ConsoleEntry, type ConsoleLevel, type ConsoleLogEntry, type Corner, type CreateSessionOptions, type CreateSurfaceShellOptions, type CreateUidexOptions, type CursorTooltip, type CursorTooltipDeps, type CustomSurface, DEFAULT_VIEWS, type DetailAction, type DetailActionIcon, type DetailActionRunContext, type DetailSection, type DetailSubtitle, type DetailSurface, ENTITY_KINDS, type Element$1 as Element, type Entity, type EntityByKind, type EntityKind, type EntityRef, type Feature, type FeedbackExternalLink, type FeedbackPayload, type FeedbackResult, type FeedbackSuggestedTarget, type Flow, type FormField, type FormSubmit, type FormSubmitResult, type FormSurface, type FormValue, type HighlightController, type Ingest, type IngestConfig, type IngestConfigEpic, type IngestOptions, type Inspector, type InspectorMatch, type InspectorOptions, KIND_STYLE, type KindStyleEntry, type ListItem, type ListSurface, type Location, type MenuBar, type MenuBarOptions, type MetaEntityKind, type Metadata, type NetworkCapture, type NetworkEntry, type NetworkErrorEntry, type Overlay, type OverlayShowOptions, type Page, type Primitive, type Region, type Registry, type ResolvedTheme, type Route, SURFACE_CONTAINER_CLASS, SURFACE_HOST_CLASS, SURFACE_IGNORE_SELECTOR, type Scope, type SessionActions, type SessionSnapshot, type SessionState, type SessionStore, type ShellAction, type ShellHint, type SourceRef, type SurfaceHost, type SurfaceHostOptions, type SurfaceShell, type ThemeDetector, type ThemeDetectorDeps, type ThemePreference, type Uidex, UnknownEntityKindError, type View, type ViewContext, type ViewDirectory, type ViewPalette, type ViewPushTarget, type ViewRegistrar, type ViewRegistrarOptions, type ViewStack, type ViewStackEntry, type ViewStackOptions, type ViewSurface, ViewValidationError, type Viewport, type Widget, Z_BASE, Z_CHROME, Z_OVERLAY, assertEntityKind, commandPaletteView, componentDetailView, createConsoleCapture, createCursorTooltip, createHighlightController, createIngest, createInspector, createMenuBar, createNetworkCapture, createOverlay, createRegistry, createSession, createSurfaceHost, createSurfaceShell, createThemeDetector, createUidex, createViewRegistrar, createViewStack, defaultResolveMatch, displayName, entityKey, featureDetailView, feedbackView, flowDetailView, getNativeFetch, isMetaKind, nativeFetch, pageDetailView, prettify, primitiveDetailView, regionDetailView, resolveEntityElement, resolveIngestOptions, resolveTheme, widgetDetailView };