uidex 0.2.4 → 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 (67) hide show
  1. package/README.md +253 -353
  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 +6902 -9801
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +901 -146
  19. package/dist/index.d.ts +901 -146
  20. package/dist/index.js +6896 -9805
  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 +30 -53
  25. package/dist/playwright/index.d.ts +30 -53
  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 +6936 -9808
  35. package/dist/react/index.cjs.map +1 -1
  36. package/dist/react/index.d.cts +673 -146
  37. package/dist/react/index.d.ts +673 -146
  38. package/dist/react/index.js +6980 -9811
  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 +71 -65
  47. package/templates/claude/audit.md +37 -0
  48. package/templates/claude/rules.md +212 -0
  49. package/claude/audit-command.md +0 -46
  50. package/claude/rules.md +0 -167
  51. package/dist/api/index.cjs +0 -254
  52. package/dist/api/index.cjs.map +0 -1
  53. package/dist/api/index.d.cts +0 -236
  54. package/dist/api/index.d.ts +0 -236
  55. package/dist/api/index.js +0 -226
  56. package/dist/api/index.js.map +0 -1
  57. package/dist/core/index.cjs +0 -11045
  58. package/dist/core/index.cjs.map +0 -1
  59. package/dist/core/index.d.cts +0 -424
  60. package/dist/core/index.d.ts +0 -424
  61. package/dist/core/index.global.js +0 -66516
  62. package/dist/core/index.global.js.map +0 -1
  63. package/dist/core/index.js +0 -10995
  64. package/dist/core/index.js.map +0 -1
  65. package/dist/core/style.css +0 -1529
  66. package/dist/scripts/cli.cjs +0 -3904
  67. package/uidex.schema.json +0 -93
package/dist/index.d.ts CHANGED
@@ -1,78 +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
- }
9
- interface UidexConfig {
10
- defaults?: UidexDefaults;
11
- colors?: Record<string, string>;
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;
12
11
  }
13
- type UidexKind = 'block' | 'component' | 'primitive';
14
- interface UidexLocation {
15
- filePath: string;
16
- line: number;
17
- kind: UidexKind;
18
- doc?: string;
19
- scopes?: string[];
12
+ interface EntityRef {
13
+ kind: EntityKind;
14
+ id: string;
20
15
  }
21
- type UidexMap = Record<string, UidexLocation[]>;
22
- interface PrimitiveEntry {
23
- name: string;
24
- filePath: string;
25
- scope: string;
26
- composes: string[];
27
- usedBy: string[];
28
- kind: 'primitive';
29
- }
30
- interface UidexPage {
31
- dir: string;
32
- content: string;
16
+ interface Metadata {
17
+ name?: string;
33
18
  description?: string;
34
- componentIds: string[];
35
- rootId?: string;
19
+ acceptance?: string[];
20
+ notes?: string;
21
+ composes?: EntityRef[];
22
+ flows?: readonly string[];
23
+ features?: string[];
24
+ widgets?: string[];
36
25
  }
37
- interface UidexFeature {
38
- dir: string;
39
- content: string;
40
- description?: string;
41
- componentIds: string[];
26
+ interface EntityWithMetaBase {
27
+ id: string;
28
+ loc?: Location;
29
+ scopes?: Scope[];
30
+ meta?: Metadata;
42
31
  }
43
- interface KeyboardShortcut {
44
- key: string;
45
- ctrlKey?: boolean;
46
- shiftKey?: boolean;
47
- altKey?: boolean;
48
- metaKey?: boolean;
32
+ interface Route {
33
+ kind: "route";
34
+ path: string;
35
+ page: string;
49
36
  }
50
- interface IngestConfig {
51
- endpoint: string;
52
- apiKey: string;
53
- environment?: string;
54
- appVersion?: string;
55
- reporter?: {
56
- email?: string;
57
- name?: string;
58
- };
59
- metadata?: Record<string, string>;
60
- captureConsole?: boolean;
61
- captureNetwork?: boolean;
37
+ interface Flow {
38
+ kind: "flow";
39
+ id: string;
40
+ loc: Location;
41
+ touches: string[];
42
+ }
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";
62
57
  }
63
- type FeedbackResult = {
64
- ok: true;
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[];
81
+ }
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 {
65
106
  id: string;
66
- 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";
67
186
  } | {
68
- ok: false;
69
- error: string;
187
+ type: "PIN";
188
+ ref?: EntityRef;
189
+ } | {
190
+ type: "UNPIN";
191
+ } | {
192
+ type: "SET_THEME";
193
+ theme: ThemePreference;
194
+ resolvedTheme: ResolvedTheme;
195
+ } | {
196
+ type: "SET_INGEST";
197
+ active: boolean;
70
198
  };
71
- type UidexTheme = 'dark' | 'light' | 'auto';
72
- type FeedbackType = 'bug' | 'feature' | 'improvement' | 'question';
73
- 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
+
74
277
  interface ConsoleLogEntry {
75
- level: 'warn' | 'error';
278
+ level: "log" | "warn" | "error" | "info";
76
279
  message: string;
77
280
  timestamp: string;
78
281
  }
@@ -80,105 +283,657 @@ interface NetworkErrorEntry {
80
283
  url: string;
81
284
  method: string;
82
285
  status: number | null;
83
- statusText: string;
286
+ statusText: string | null;
84
287
  timestamp: string;
85
288
  }
86
- interface FeedbackReport {
87
- type: FeedbackType;
88
- 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";
89
304
  title?: string;
90
305
  description: string;
91
306
  componentId: string;
92
- element: string | null;
93
- sources: {
94
- filePath: string;
95
- line: number;
96
- }[];
307
+ element?: string | null;
308
+ sources?: SourceRef[];
97
309
  url: string;
98
310
  path: string;
99
- route: string | null;
100
- timestamp: string;
101
- pageTitle: string;
102
- pageDescription?: string;
103
- locale: string;
104
- sessionId: string;
105
- viewport: {
106
- width: number;
107
- height: number;
108
- };
109
- screen: {
110
- width: number;
111
- height: number;
112
- };
113
- userAgent: string;
114
- screenshot?: string;
311
+ route?: string | null;
312
+ pageTitle?: string;
313
+ sessionId?: string;
115
314
  reporterEmail?: string;
116
315
  reporterName?: string;
316
+ timestamp: string;
317
+ viewport: Viewport;
318
+ screen: Viewport;
319
+ userAgent: string;
320
+ locale?: string;
117
321
  environment?: string;
118
322
  appVersion?: string;
119
- metadata?: Record<string, string>;
120
323
  consoleLogs?: ConsoleLogEntry[];
121
324
  networkErrors?: NetworkErrorEntry[];
122
- gitBranch?: string;
123
- gitCommit?: string;
124
- contextId?: string;
125
- }
126
- interface GitContext {
127
- branch: string;
128
- commit?: string;
129
- }
130
-
131
- interface UidexDevtoolsProps {
132
- components?: UidexMap;
133
- pages?: UidexPage[];
134
- features?: UidexFeature[];
135
- uiComponents?: PrimitiveEntry[];
136
- config?: UidexConfig;
137
- buttonPosition?: ButtonPosition;
138
- /** Theme for the devtools widget. Default: 'auto'. */
139
- theme?: UidexTheme;
140
- disabled?: boolean;
141
- onSelect?: (id: string) => void;
142
- /** Keyboard shortcut to toggle inspect mode. Default: Shift+Cmd+U. Set to false to disable. */
143
- inspectShortcut?: KeyboardShortcut | false;
144
- /** Ingest configuration for submitting feedback to a server. */
145
- ingest?: IngestConfig;
146
- /** Called after feedback submission with the report and result. */
147
- onSubmit?: (report: FeedbackReport, result: FeedbackResult) => void;
148
- }
149
- declare function UidexDevtools({ components, pages, features, uiComponents, config, buttonPosition, theme, disabled, onSelect, inspectShortcut, ingest, onSubmit, }: UidexDevtoolsProps): null;
150
-
151
- type DataProps = 'components' | 'pages' | 'features' | 'uiComponents';
152
- declare function createUidexDevtools(data: {
153
- components: UidexMap;
154
- pages?: UidexPage[];
155
- features?: UidexFeature[];
156
- uiComponents?: PrimitiveEntry[];
157
- }): {
158
- (props: Omit<UidexDevtoolsProps, DataProps>): null;
159
- displayName: string;
160
- };
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;
363
+ }
364
+
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;
373
+ }
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;
386
+
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
+ }
161
409
 
162
- interface UidexOverlayProps {
163
- target: HTMLElement | null;
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;
164
430
  color?: string;
165
- borderStyle?: BorderStyle;
431
+ padding?: number;
432
+ borderStyle?: string;
166
433
  borderWidth?: number;
167
- 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;
168
493
  }
169
- declare function UidexOverlay({ target, color, borderStyle, borderWidth, colors, }: UidexOverlayProps): null;
494
+ declare function createMenuBar(options: MenuBarOptions): MenuBar;
170
495
 
171
- declare function registerComponents(components: UidexMap): void;
172
- declare function getComponents(): UidexMap | null;
173
- declare function registerPages(pages: UidexPage[]): void;
174
- declare function getPages(): UidexPage[] | null;
175
- declare function registerFeatures(features: UidexFeature[]): void;
176
- declare function getFeatures(): UidexFeature[] | null;
177
- declare function registerGitContext(ctx: GitContext): void;
496
+ interface ThemeDetector {
497
+ destroy(): void;
498
+ /** Resolve the current theme preference against the environment. */
499
+ readonly resolved: ResolvedTheme;
500
+ }
501
+ interface ThemeDetectorDeps {
502
+ session: SessionStore;
503
+ onResolve?: (theme: ResolvedTheme) => void;
504
+ }
505
+ declare function createThemeDetector(deps: ThemeDetectorDeps): ThemeDetector;
178
506
 
179
- declare function classNames(...classes: (string | undefined | null | false)[]): string;
180
- declare function getContrastColor(hexColor: string): string;
181
- declare function hexToRgba(hex: string, alpha: number): string;
182
- declare function resolveColor(color: string | undefined, colorMap?: Record<string, string>): string | undefined;
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;
540
+
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;
183
938
 
184
- export { type BorderStyle, type ButtonPosition, type FeedbackReport, type FeedbackResult, type FeedbackSeverity, type FeedbackType, type IngestConfig, type KeyboardShortcut, type LabelPosition, type PrimitiveEntry, type UidexConfig, type UidexDefaults, UidexDevtools, type UidexDevtoolsProps, type UidexFeature, type UidexLocation, type UidexMap, UidexOverlay, type UidexOverlayProps, type UidexPage, classNames, createUidexDevtools, getComponents, getContrastColor, getFeatures, getPages, hexToRgba, registerComponents, registerFeatures, registerGitContext, 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 };