@qontinui/ui-bridge 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/dist/ai/index.d.mts +312 -155
  2. package/dist/ai/index.d.ts +312 -155
  3. package/dist/ai/index.js +2363 -67
  4. package/dist/ai/index.js.map +1 -1
  5. package/dist/ai/index.mjs +2328 -68
  6. package/dist/ai/index.mjs.map +1 -1
  7. package/dist/annotations/index.d.mts +218 -0
  8. package/dist/annotations/index.d.ts +218 -0
  9. package/dist/annotations/index.js +246 -0
  10. package/dist/annotations/index.js.map +1 -0
  11. package/dist/annotations/index.mjs +241 -0
  12. package/dist/annotations/index.mjs.map +1 -0
  13. package/dist/assertions-BSR3afVr.d.ts +161 -0
  14. package/dist/assertions-CTw1hfOx.d.mts +161 -0
  15. package/dist/babel-plugin/index.js +504 -0
  16. package/dist/babel-plugin/index.js.map +1 -0
  17. package/dist/babel-plugin/index.mjs +488 -0
  18. package/dist/babel-plugin/index.mjs.map +1 -0
  19. package/dist/browser-capture-Bms60T6f.d.mts +47 -0
  20. package/dist/browser-capture-CsTU29mb.d.ts +47 -0
  21. package/dist/control/index.d.mts +26 -7
  22. package/dist/control/index.d.ts +26 -7
  23. package/dist/control/index.js +276 -48
  24. package/dist/control/index.js.map +1 -1
  25. package/dist/control/index.mjs +276 -48
  26. package/dist/control/index.mjs.map +1 -1
  27. package/dist/core/index.d.mts +115 -44
  28. package/dist/core/index.d.ts +115 -44
  29. package/dist/core/index.js +0 -1560
  30. package/dist/core/index.js.map +1 -1
  31. package/dist/core/index.mjs +1 -1549
  32. package/dist/core/index.mjs.map +1 -1
  33. package/dist/debug/index.d.mts +5 -3
  34. package/dist/debug/index.d.ts +5 -3
  35. package/dist/debug/index.js +925 -1
  36. package/dist/debug/index.js.map +1 -1
  37. package/dist/debug/index.mjs +924 -2
  38. package/dist/debug/index.mjs.map +1 -1
  39. package/dist/index.d.mts +13 -9
  40. package/dist/index.d.ts +13 -9
  41. package/dist/index.js +8310 -3777
  42. package/dist/index.js.map +1 -1
  43. package/dist/index.mjs +8246 -3766
  44. package/dist/index.mjs.map +1 -1
  45. package/dist/{metrics-NC3csD0R.d.mts → metrics-DuA2qIIz.d.mts} +2 -2
  46. package/dist/{metrics-C9XRi_mL.d.ts → metrics-KFAAKNEB.d.ts} +2 -2
  47. package/dist/native/control/index.js +448 -0
  48. package/dist/native/control/index.js.map +1 -0
  49. package/dist/native/control/index.mjs +445 -0
  50. package/dist/native/control/index.mjs.map +1 -0
  51. package/dist/native/core/index.js +486 -0
  52. package/dist/native/core/index.js.map +1 -0
  53. package/dist/native/core/index.mjs +475 -0
  54. package/dist/native/core/index.mjs.map +1 -0
  55. package/dist/native/debug/index.js +408 -0
  56. package/dist/native/debug/index.js.map +1 -0
  57. package/dist/native/debug/index.mjs +406 -0
  58. package/dist/native/debug/index.mjs.map +1 -0
  59. package/dist/native/index.js +2232 -0
  60. package/dist/native/index.js.map +1 -0
  61. package/dist/native/index.mjs +2204 -0
  62. package/dist/native/index.mjs.map +1 -0
  63. package/dist/native/react/index.js +1377 -0
  64. package/dist/native/react/index.js.map +1 -0
  65. package/dist/native/react/index.mjs +1365 -0
  66. package/dist/native/react/index.mjs.map +1 -0
  67. package/dist/native/server/index.js +440 -0
  68. package/dist/native/server/index.js.map +1 -0
  69. package/dist/native/server/index.mjs +435 -0
  70. package/dist/native/server/index.mjs.map +1 -0
  71. package/dist/react/index.d.mts +121 -9
  72. package/dist/react/index.d.ts +121 -9
  73. package/dist/react/index.js +2239 -91
  74. package/dist/react/index.js.map +1 -1
  75. package/dist/react/index.mjs +2239 -92
  76. package/dist/react/index.mjs.map +1 -1
  77. package/dist/{registry-CIEDjbQ9.d.ts → registry-C6dDtn1v.d.ts} +34 -15
  78. package/dist/{registry-SsSDq46X.d.mts → registry-POtcxnal.d.mts} +34 -15
  79. package/dist/render-log/index.d.mts +1 -1
  80. package/dist/render-log/index.d.ts +1 -1
  81. package/dist/server/express.d.mts +37 -0
  82. package/dist/server/express.d.ts +37 -0
  83. package/dist/server/express.js +298 -0
  84. package/dist/server/express.js.map +1 -0
  85. package/dist/server/express.mjs +294 -0
  86. package/dist/server/express.mjs.map +1 -0
  87. package/dist/server/handlers.d.mts +124 -0
  88. package/dist/server/handlers.d.ts +124 -0
  89. package/dist/server/handlers.js +7183 -0
  90. package/dist/server/handlers.js.map +1 -0
  91. package/dist/server/handlers.mjs +7180 -0
  92. package/dist/server/handlers.mjs.map +1 -0
  93. package/dist/server/index.d.mts +12 -0
  94. package/dist/server/index.d.ts +12 -0
  95. package/dist/server/index.js +8384 -0
  96. package/dist/server/index.js.map +1 -0
  97. package/dist/server/index.mjs +8369 -0
  98. package/dist/server/index.mjs.map +1 -0
  99. package/dist/server/nextjs.d.mts +128 -0
  100. package/dist/server/nextjs.d.ts +128 -0
  101. package/dist/server/nextjs.js +390 -0
  102. package/dist/server/nextjs.js.map +1 -0
  103. package/dist/server/nextjs.mjs +385 -0
  104. package/dist/server/nextjs.mjs.map +1 -0
  105. package/dist/server/standalone.d.mts +7 -0
  106. package/dist/server/standalone.d.ts +7 -0
  107. package/dist/server/standalone.js +845 -0
  108. package/dist/server/standalone.js.map +1 -0
  109. package/dist/server/standalone.mjs +841 -0
  110. package/dist/server/standalone.mjs.map +1 -0
  111. package/dist/specs/index.d.mts +365 -0
  112. package/dist/specs/index.d.ts +365 -0
  113. package/dist/specs/index.js +2809 -0
  114. package/dist/specs/index.js.map +1 -0
  115. package/dist/specs/index.mjs +2786 -0
  116. package/dist/specs/index.mjs.map +1 -0
  117. package/dist/standalone-B6GLIEmR.d.ts +216 -0
  118. package/dist/standalone-CjdYqj3P.d.mts +216 -0
  119. package/dist/swc-plugin/index.d.mts +79 -0
  120. package/dist/swc-plugin/index.d.ts +79 -0
  121. package/dist/swc-plugin/index.js +15 -0
  122. package/dist/swc-plugin/index.js.map +1 -0
  123. package/dist/swc-plugin/index.mjs +9 -0
  124. package/dist/swc-plugin/index.mjs.map +1 -0
  125. package/dist/types-B2EfvEaq.d.ts +236 -0
  126. package/dist/{types-Dr6tH-bm.d.mts → types-C7gVYRnF.d.ts} +72 -2
  127. package/dist/{types-oCTrRxSw.d.ts → types-CJGrBEhC.d.mts} +72 -2
  128. package/dist/types-CebMQj76.d.ts +1275 -0
  129. package/dist/types-D_ypYl3T.d.mts +1275 -0
  130. package/dist/types-UBtp7R0u.d.mts +132 -0
  131. package/dist/types-UBtp7R0u.d.ts +132 -0
  132. package/dist/types-gO696T_t.d.mts +236 -0
  133. package/dist/{types-CPMbN_Iw.d.mts → types-suaYwWWg.d.mts} +519 -152
  134. package/dist/{types-CPMbN_Iw.d.ts → types-suaYwWWg.d.ts} +519 -152
  135. package/package.json +123 -4
  136. package/swc-plugin-wasm/ui_bridge_swc_plugin.wasm +0 -0
  137. package/dist/types-BvCfFuEV.d.ts +0 -534
  138. package/dist/types-CFT3Dnx4.d.mts +0 -534
  139. package/dist/websocket-client-CX4QJesI.d.ts +0 -124
  140. package/dist/websocket-client-C_Na0OSp.d.mts +0 -124
@@ -0,0 +1,47 @@
1
+ import { n as BrowserCaptureConfig, Q as OnBrowserEventCallback, h as AnyCapturedEvent, p as BrowserEventType, C as CapturedError } from './types-suaYwWWg.js';
2
+
3
+ /**
4
+ * Browser Event Capture Orchestrator
5
+ *
6
+ * Single entry point that delegates to focused sub-modules.
7
+ * Replaces the old ConsoleCapture class with unified event capture.
8
+ */
9
+
10
+ declare class BrowserEventCapture {
11
+ private buffer;
12
+ private maxEntries;
13
+ private installed;
14
+ private cleanups;
15
+ private onEvent;
16
+ private config;
17
+ constructor(config?: BrowserCaptureConfig);
18
+ setOnEvent(cb: OnBrowserEventCallback | null): void;
19
+ /**
20
+ * Install all enabled capture sub-modules.
21
+ * Safe to call multiple times (no-ops if already installed).
22
+ */
23
+ install(): void;
24
+ /**
25
+ * Uninstall all capture sub-modules.
26
+ */
27
+ uninstall(): void;
28
+ reportReactError(error: Error, errorInfo: {
29
+ componentStack?: string;
30
+ }): void;
31
+ reportWsStateChange(prev: string, next: string, reconnectAttempt?: number): void;
32
+ getSince(ts: number): AnyCapturedEvent[];
33
+ getRecent(n?: number): AnyCapturedEvent[];
34
+ getByType(type: BrowserEventType): AnyCapturedEvent[];
35
+ /**
36
+ * Get console errors since a timestamp (backward-compat for ActionExecutor).
37
+ */
38
+ getConsoleSince(ts: number): CapturedError[];
39
+ /**
40
+ * Get recent console errors (backward-compat for ActionExecutor).
41
+ */
42
+ getConsoleRecent(n?: number): CapturedError[];
43
+ clear(): void;
44
+ private trim;
45
+ }
46
+
47
+ export { BrowserEventCapture as B };
@@ -1,8 +1,9 @@
1
- import { A as ActionExecutor, b as ControlActionRequest, c as ControlActionResponse, C as ComponentActionRequest, a as ComponentActionResponse, W as WaitResult, F as FindRequest, g as FindResponse, d as ControlSnapshot, i as WorkflowEngine, j as WorkflowRunRequest, k as WorkflowRunResponse } from '../types-Dr6tH-bm.mjs';
2
- export { D as DiscoveredElement, e as DiscoveryRequest, f as DiscoveryResponse, K as KeyboardAction, M as MouseAction, S as ScrollAction, h as SelectAction, T as TypeAction, l as WorkflowRunStatus, m as WorkflowStepResult } from '../types-Dr6tH-bm.mjs';
3
- import { U as UIBridgeRegistry } from '../registry-SsSDq46X.mjs';
4
- import { a0 as WaitOptions } from '../types-CPMbN_Iw.mjs';
5
- import '../types-CFT3Dnx4.mjs';
1
+ import { A as ActionExecutor, b as ControlActionRequest, c as ControlActionResponse, C as ComponentActionRequest, a as ComponentActionResponse, W as WaitResult, F as FindRequest, h as FindResponse, d as ControlSnapshot, k as WorkflowEngine, l as WorkflowRunRequest, m as WorkflowRunResponse } from '../types-CJGrBEhC.mjs';
2
+ export { D as DiscoveredElement, e as DiscoveryRequest, f as DiscoveryResponse, g as DragAction, K as KeyboardAction, M as MouseAction, P as PageNavigateRequest, i as PageNavigationResponse, S as ScrollAction, j as SelectAction, T as TypeAction, n as WorkflowRunStatus, o as WorkflowStepResult } from '../types-CJGrBEhC.mjs';
3
+ import { U as UIBridgeRegistry } from '../registry-POtcxnal.mjs';
4
+ import { ax as WaitOptions } from '../types-suaYwWWg.mjs';
5
+ import { B as BrowserEventCapture } from '../browser-capture-Bms60T6f.mjs';
6
+ import '../types-D_ypYl3T.mjs';
6
7
 
7
8
  /**
8
9
  * Action Executor
@@ -15,7 +16,8 @@ import '../types-CFT3Dnx4.mjs';
15
16
  */
16
17
  declare class DefaultActionExecutor implements ActionExecutor {
17
18
  private registry;
18
- constructor(registry: UIBridgeRegistry);
19
+ private consoleCapture?;
20
+ constructor(registry: UIBridgeRegistry, consoleCapture?: BrowserEventCapture | undefined);
19
21
  /**
20
22
  * Execute an action on an element
21
23
  */
@@ -61,6 +63,23 @@ declare class DefaultActionExecutor implements ActionExecutor {
61
63
  private performScroll;
62
64
  private performCheck;
63
65
  private performToggle;
66
+ private performSetValue;
67
+ private performSubmit;
68
+ private performReset;
69
+ /**
70
+ * Perform a drag operation by dispatching a sequence of mouse events.
71
+ *
72
+ * Follows the same composite pattern as the qontinui core library:
73
+ * mousedown on source → wait → mousemove × N along path → mouseup on target.
74
+ *
75
+ * Optionally dispatches HTML5 drag events (dragstart/dragover/drop/dragend)
76
+ * for apps that use the HTML5 Drag and Drop API instead of mouse events.
77
+ */
78
+ private performDrag;
79
+ /**
80
+ * Resolve a drag target element from a target descriptor.
81
+ */
82
+ private resolveTargetElement;
64
83
  private getElementId;
65
84
  private getElementLabel;
66
85
  private getAccessibleName;
@@ -70,7 +89,7 @@ declare class DefaultActionExecutor implements ActionExecutor {
70
89
  /**
71
90
  * Create an action executor
72
91
  */
73
- declare function createActionExecutor(registry: UIBridgeRegistry): ActionExecutor;
92
+ declare function createActionExecutor(registry: UIBridgeRegistry, consoleCapture?: BrowserEventCapture): ActionExecutor;
74
93
 
75
94
  /**
76
95
  * Workflow Engine
@@ -1,8 +1,9 @@
1
- import { A as ActionExecutor, b as ControlActionRequest, c as ControlActionResponse, C as ComponentActionRequest, a as ComponentActionResponse, W as WaitResult, F as FindRequest, g as FindResponse, d as ControlSnapshot, i as WorkflowEngine, j as WorkflowRunRequest, k as WorkflowRunResponse } from '../types-oCTrRxSw.js';
2
- export { D as DiscoveredElement, e as DiscoveryRequest, f as DiscoveryResponse, K as KeyboardAction, M as MouseAction, S as ScrollAction, h as SelectAction, T as TypeAction, l as WorkflowRunStatus, m as WorkflowStepResult } from '../types-oCTrRxSw.js';
3
- import { U as UIBridgeRegistry } from '../registry-CIEDjbQ9.js';
4
- import { a0 as WaitOptions } from '../types-CPMbN_Iw.js';
5
- import '../types-BvCfFuEV.js';
1
+ import { A as ActionExecutor, b as ControlActionRequest, c as ControlActionResponse, C as ComponentActionRequest, a as ComponentActionResponse, W as WaitResult, F as FindRequest, h as FindResponse, d as ControlSnapshot, k as WorkflowEngine, l as WorkflowRunRequest, m as WorkflowRunResponse } from '../types-C7gVYRnF.js';
2
+ export { D as DiscoveredElement, e as DiscoveryRequest, f as DiscoveryResponse, g as DragAction, K as KeyboardAction, M as MouseAction, P as PageNavigateRequest, i as PageNavigationResponse, S as ScrollAction, j as SelectAction, T as TypeAction, n as WorkflowRunStatus, o as WorkflowStepResult } from '../types-C7gVYRnF.js';
3
+ import { U as UIBridgeRegistry } from '../registry-C6dDtn1v.js';
4
+ import { ax as WaitOptions } from '../types-suaYwWWg.js';
5
+ import { B as BrowserEventCapture } from '../browser-capture-CsTU29mb.js';
6
+ import '../types-CebMQj76.js';
6
7
 
7
8
  /**
8
9
  * Action Executor
@@ -15,7 +16,8 @@ import '../types-BvCfFuEV.js';
15
16
  */
16
17
  declare class DefaultActionExecutor implements ActionExecutor {
17
18
  private registry;
18
- constructor(registry: UIBridgeRegistry);
19
+ private consoleCapture?;
20
+ constructor(registry: UIBridgeRegistry, consoleCapture?: BrowserEventCapture | undefined);
19
21
  /**
20
22
  * Execute an action on an element
21
23
  */
@@ -61,6 +63,23 @@ declare class DefaultActionExecutor implements ActionExecutor {
61
63
  private performScroll;
62
64
  private performCheck;
63
65
  private performToggle;
66
+ private performSetValue;
67
+ private performSubmit;
68
+ private performReset;
69
+ /**
70
+ * Perform a drag operation by dispatching a sequence of mouse events.
71
+ *
72
+ * Follows the same composite pattern as the qontinui core library:
73
+ * mousedown on source → wait → mousemove × N along path → mouseup on target.
74
+ *
75
+ * Optionally dispatches HTML5 drag events (dragstart/dragover/drop/dragend)
76
+ * for apps that use the HTML5 Drag and Drop API instead of mouse events.
77
+ */
78
+ private performDrag;
79
+ /**
80
+ * Resolve a drag target element from a target descriptor.
81
+ */
82
+ private resolveTargetElement;
64
83
  private getElementId;
65
84
  private getElementLabel;
66
85
  private getAccessibleName;
@@ -70,7 +89,7 @@ declare class DefaultActionExecutor implements ActionExecutor {
70
89
  /**
71
90
  * Create an action executor
72
91
  */
73
- declare function createActionExecutor(registry: UIBridgeRegistry): ActionExecutor;
92
+ declare function createActionExecutor(registry: UIBridgeRegistry, consoleCapture?: BrowserEventCapture): ActionExecutor;
74
93
 
75
94
  /**
76
95
  * Workflow Engine
@@ -105,6 +105,10 @@ function getElementState(element) {
105
105
  pointerEvents: style.pointerEvents
106
106
  }
107
107
  };
108
+ const rawText = element.textContent?.trim();
109
+ if (rawText) {
110
+ state.textContent = rawText.replace(/\s+/g, " ").slice(0, 500);
111
+ }
108
112
  if (element instanceof HTMLInputElement) {
109
113
  state.value = element.value;
110
114
  if (element.type === "checkbox" || element.type === "radio") {
@@ -146,9 +150,25 @@ function createMouseEvent(type, element, options) {
146
150
  clientY: rect.top + y
147
151
  });
148
152
  }
153
+ function elementFromPointSafe(x, y) {
154
+ if (typeof document.elementFromPoint === "function") {
155
+ return document.elementFromPoint(x, y);
156
+ }
157
+ return null;
158
+ }
159
+ function createMouseEventAt(type, clientX, clientY) {
160
+ return new MouseEvent(type, {
161
+ bubbles: true,
162
+ cancelable: true,
163
+ button: 0,
164
+ clientX,
165
+ clientY
166
+ });
167
+ }
149
168
  var DefaultActionExecutor = class {
150
- constructor(registry) {
169
+ constructor(registry, consoleCapture) {
151
170
  this.registry = registry;
171
+ this.consoleCapture = consoleCapture;
152
172
  }
153
173
  /**
154
174
  * Execute an action on an element
@@ -185,11 +205,19 @@ var DefaultActionExecutor = class {
185
205
  };
186
206
  }
187
207
  }
208
+ const actionStartTime = Date.now();
188
209
  const result = await this.performAction(element, request.action, request.params);
210
+ let consoleErrors;
211
+ if (this.consoleCapture) {
212
+ await sleep(50);
213
+ const errors = this.consoleCapture.getConsoleSince(actionStartTime);
214
+ if (errors.length > 0) consoleErrors = errors;
215
+ }
189
216
  return {
190
217
  success: true,
191
218
  elementState: getElementState(element),
192
219
  result,
220
+ consoleErrors,
193
221
  durationMs: performance.now() - startTime,
194
222
  timestamp: Date.now(),
195
223
  requestId: request.requestId,
@@ -281,47 +309,76 @@ var DefaultActionExecutor = class {
281
309
  const rootEl = document.querySelector(options.root);
282
310
  if (rootEl) root = rootEl;
283
311
  }
284
- const interactiveSelectors = [
285
- "a[href]",
286
- "button",
287
- "input",
288
- "select",
289
- "textarea",
290
- "[onclick]",
291
- '[role="button"]',
292
- '[role="link"]',
293
- '[role="checkbox"]',
294
- '[role="radio"]',
295
- '[role="menuitem"]',
296
- '[role="tab"]',
297
- '[role="switch"]',
298
- '[tabindex]:not([tabindex="-1"])',
299
- '[contenteditable="true"]',
300
- "[data-ui-id]",
301
- "[data-testid]"
302
- ];
303
- const selector = options?.selector || interactiveSelectors.join(", ");
304
- const foundElements = root.querySelectorAll(selector);
305
- for (const el of foundElements) {
306
- if (options?.limit && elements.length >= options.limit) break;
307
- const state = getElementState(el);
308
- if (!options?.includeHidden && !state.visible) continue;
309
- if (options?.types) {
310
- const type = this.inferElementType(el);
311
- if (!options.types.includes(type)) continue;
312
- }
313
- const registered = this.registry.findByDOMElement(el);
314
- elements.push({
315
- id: registered?.id || this.getElementId(el),
316
- type: registered?.type || this.inferElementType(el),
317
- label: registered?.label || this.getElementLabel(el),
318
- tagName: el.tagName.toLowerCase(),
319
- role: el.getAttribute("role") || void 0,
320
- accessibleName: this.getAccessibleName(el),
321
- actions: registered?.actions || this.inferActions(el),
322
- state,
323
- registered: !!registered
324
- });
312
+ if (!options?.contentOnly) {
313
+ const interactiveSelectors = [
314
+ "a[href]",
315
+ "button",
316
+ "input",
317
+ "select",
318
+ "textarea",
319
+ "[onclick]",
320
+ '[role="button"]',
321
+ '[role="link"]',
322
+ '[role="checkbox"]',
323
+ '[role="radio"]',
324
+ '[role="menuitem"]',
325
+ '[role="tab"]',
326
+ '[role="switch"]',
327
+ '[tabindex]:not([tabindex="-1"])',
328
+ '[contenteditable="true"]',
329
+ "[data-ui-element]",
330
+ "[data-ui-id]",
331
+ "[data-testid]"
332
+ ];
333
+ const selector = options?.selector || interactiveSelectors.join(", ");
334
+ const foundElements = root.querySelectorAll(selector);
335
+ for (const el of foundElements) {
336
+ if (options?.limit && elements.length >= options.limit) break;
337
+ const state = getElementState(el);
338
+ if (!options?.includeHidden && !state.visible) continue;
339
+ if (options?.types) {
340
+ const type = this.inferElementType(el);
341
+ if (!options.types.includes(type)) continue;
342
+ }
343
+ const registered = this.registry.findByDOMElement(el);
344
+ elements.push({
345
+ id: registered?.id || this.getElementId(el),
346
+ type: registered?.type || this.inferElementType(el),
347
+ label: registered?.label || this.getElementLabel(el),
348
+ tagName: el.tagName.toLowerCase(),
349
+ role: el.getAttribute("role") || void 0,
350
+ accessibleName: this.getAccessibleName(el),
351
+ actions: registered?.actions || this.inferActions(el),
352
+ state,
353
+ registered: !!registered,
354
+ category: registered?.category || "interactive",
355
+ contentMetadata: registered?.contentMetadata
356
+ });
357
+ }
358
+ }
359
+ if (options?.includeContent || options?.contentOnly) {
360
+ const contentElements = this.registry.getAllContentElements();
361
+ for (const el of contentElements) {
362
+ if (options?.limit && elements.length >= options.limit) break;
363
+ const state = el.getState();
364
+ if (!options?.includeHidden && !state.visible) continue;
365
+ if (options?.contentRole && el.contentMetadata?.contentRole !== options.contentRole) {
366
+ continue;
367
+ }
368
+ elements.push({
369
+ id: el.id,
370
+ type: el.type,
371
+ label: el.label,
372
+ tagName: el.element.tagName.toLowerCase(),
373
+ role: el.element.getAttribute("role") || void 0,
374
+ accessibleName: el.label || state.textContent?.trim(),
375
+ actions: [],
376
+ state,
377
+ registered: true,
378
+ category: "content",
379
+ contentMetadata: el.contentMetadata
380
+ });
381
+ }
325
382
  }
326
383
  return {
327
384
  elements,
@@ -351,7 +408,9 @@ var DefaultActionExecutor = class {
351
408
  type: el.type,
352
409
  label: el.label,
353
410
  actions: [...el.actions, ...el.customActions ? Object.keys(el.customActions) : []],
354
- state: el.getState()
411
+ state: el.getState(),
412
+ category: el.category,
413
+ contentMetadata: el.contentMetadata
355
414
  })),
356
415
  components: components.map((comp) => ({
357
416
  id: comp.id,
@@ -435,6 +494,14 @@ var DefaultActionExecutor = class {
435
494
  return this.performCheck(element, false);
436
495
  case "toggle":
437
496
  return this.performToggle(element);
497
+ case "drag":
498
+ return this.performDrag(element, params);
499
+ case "setValue":
500
+ return this.performSetValue(element, params);
501
+ case "submit":
502
+ return this.performSubmit(element);
503
+ case "reset":
504
+ return this.performReset(element);
438
505
  default: {
439
506
  const registered = this.registry.findByDOMElement(element);
440
507
  if (registered?.customActions?.[action]) {
@@ -464,15 +531,26 @@ var DefaultActionExecutor = class {
464
531
  if (!(element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement)) {
465
532
  throw new Error("Type action requires an input or textarea element");
466
533
  }
534
+ const proto = element instanceof HTMLTextAreaElement ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
535
+ const nativeSetter = Object.getOwnPropertyDescriptor(proto, "value")?.set;
467
536
  element.focus();
468
537
  if (options?.clear) {
469
- element.value = "";
538
+ if (nativeSetter) {
539
+ nativeSetter.call(element, "");
540
+ } else {
541
+ element.value = "";
542
+ }
470
543
  element.dispatchEvent(new Event("input", { bubbles: true }));
471
544
  }
472
545
  const text = options?.text || "";
473
546
  const delay = options?.delay || 0;
474
547
  for (const char of text) {
475
- element.value += char;
548
+ const current = element.value;
549
+ if (nativeSetter) {
550
+ nativeSetter.call(element, current + char);
551
+ } else {
552
+ element.value = current + char;
553
+ }
476
554
  if (options?.triggerEvents !== false) {
477
555
  element.dispatchEvent(new Event("input", { bubbles: true }));
478
556
  }
@@ -486,7 +564,13 @@ var DefaultActionExecutor = class {
486
564
  }
487
565
  performClear(element) {
488
566
  if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) {
489
- element.value = "";
567
+ const proto = element instanceof HTMLTextAreaElement ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype;
568
+ const nativeSetter = Object.getOwnPropertyDescriptor(proto, "value")?.set;
569
+ if (nativeSetter) {
570
+ nativeSetter.call(element, "");
571
+ } else {
572
+ element.value = "";
573
+ }
490
574
  element.dispatchEvent(new Event("input", { bubbles: true }));
491
575
  element.dispatchEvent(new Event("change", { bubbles: true }));
492
576
  }
@@ -568,6 +652,150 @@ var DefaultActionExecutor = class {
568
652
  element.dispatchEvent(new Event("change", { bubbles: true }));
569
653
  }
570
654
  }
655
+ performSetValue(element, params) {
656
+ const value = params?.value;
657
+ if (value === void 0) {
658
+ throw new Error('setValue requires a "value" parameter');
659
+ }
660
+ if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) {
661
+ const nativeSetter = Object.getOwnPropertyDescriptor(
662
+ element instanceof HTMLTextAreaElement ? HTMLTextAreaElement.prototype : HTMLInputElement.prototype,
663
+ "value"
664
+ )?.set;
665
+ if (nativeSetter) {
666
+ nativeSetter.call(element, value);
667
+ } else {
668
+ element.value = value;
669
+ }
670
+ element.dispatchEvent(new Event("input", { bubbles: true }));
671
+ element.dispatchEvent(new Event("change", { bubbles: true }));
672
+ } else if (element instanceof HTMLSelectElement) {
673
+ element.value = value;
674
+ element.dispatchEvent(new Event("change", { bubbles: true }));
675
+ }
676
+ }
677
+ performSubmit(element) {
678
+ const form = element instanceof HTMLFormElement ? element : element.closest("form");
679
+ if (form) {
680
+ const submitEvent = new Event("submit", { bubbles: true, cancelable: true });
681
+ if (form.dispatchEvent(submitEvent)) {
682
+ form.requestSubmit();
683
+ }
684
+ } else {
685
+ throw new Error("No form found for submit action");
686
+ }
687
+ }
688
+ performReset(element) {
689
+ const form = element instanceof HTMLFormElement ? element : element.closest("form");
690
+ if (form) {
691
+ form.reset();
692
+ form.dispatchEvent(new Event("reset", { bubbles: true }));
693
+ } else {
694
+ throw new Error("No form found for reset action");
695
+ }
696
+ }
697
+ /**
698
+ * Perform a drag operation by dispatching a sequence of mouse events.
699
+ *
700
+ * Follows the same composite pattern as the qontinui core library:
701
+ * mousedown on source → wait → mousemove × N along path → mouseup on target.
702
+ *
703
+ * Optionally dispatches HTML5 drag events (dragstart/dragover/drop/dragend)
704
+ * for apps that use the HTML5 Drag and Drop API instead of mouse events.
705
+ */
706
+ async performDrag(sourceElement, options) {
707
+ const sourceRect = sourceElement.getBoundingClientRect();
708
+ const sourceX = sourceRect.left + (options?.sourceOffset?.x ?? sourceRect.width / 2);
709
+ const sourceY = sourceRect.top + (options?.sourceOffset?.y ?? sourceRect.height / 2);
710
+ let targetX;
711
+ let targetY;
712
+ if (options?.targetPosition) {
713
+ targetX = options.targetPosition.x;
714
+ targetY = options.targetPosition.y;
715
+ } else if (options?.target) {
716
+ const targetElement = this.resolveTargetElement(options.target);
717
+ if (!targetElement) {
718
+ throw new Error(`Drag target element not found: ${JSON.stringify(options.target)}`);
719
+ }
720
+ const targetRect = targetElement.getBoundingClientRect();
721
+ targetX = targetRect.left + (options?.targetOffset?.x ?? targetRect.width / 2);
722
+ targetY = targetRect.top + (options?.targetOffset?.y ?? targetRect.height / 2);
723
+ } else {
724
+ throw new Error("Drag requires either target or targetPosition");
725
+ }
726
+ const steps = options?.steps ?? 10;
727
+ const holdDelay = options?.holdDelay ?? 100;
728
+ const releaseDelay = options?.releaseDelay ?? 50;
729
+ sourceElement.dispatchEvent(createMouseEventAt("mousedown", sourceX, sourceY));
730
+ const canHTML5 = options?.html5 && typeof DragEvent !== "undefined";
731
+ if (canHTML5) {
732
+ sourceElement.dispatchEvent(
733
+ new DragEvent("dragstart", {
734
+ bubbles: true,
735
+ cancelable: true,
736
+ clientX: sourceX,
737
+ clientY: sourceY
738
+ })
739
+ );
740
+ }
741
+ if (holdDelay > 0) {
742
+ await sleep(holdDelay);
743
+ }
744
+ for (let i = 1; i <= steps; i++) {
745
+ const progress = i / steps;
746
+ const currentX = sourceX + (targetX - sourceX) * progress;
747
+ const currentY = sourceY + (targetY - sourceY) * progress;
748
+ const dispatchTarget = elementFromPointSafe(currentX, currentY) || sourceElement;
749
+ dispatchTarget.dispatchEvent(createMouseEventAt("mousemove", currentX, currentY));
750
+ if (canHTML5) {
751
+ dispatchTarget.dispatchEvent(
752
+ new DragEvent("dragover", {
753
+ bubbles: true,
754
+ cancelable: true,
755
+ clientX: currentX,
756
+ clientY: currentY
757
+ })
758
+ );
759
+ }
760
+ }
761
+ const dropTarget = elementFromPointSafe(targetX, targetY) || sourceElement;
762
+ dropTarget.dispatchEvent(createMouseEventAt("mouseup", targetX, targetY));
763
+ if (canHTML5) {
764
+ dropTarget.dispatchEvent(
765
+ new DragEvent("drop", {
766
+ bubbles: true,
767
+ cancelable: true,
768
+ clientX: targetX,
769
+ clientY: targetY
770
+ })
771
+ );
772
+ sourceElement.dispatchEvent(
773
+ new DragEvent("dragend", {
774
+ bubbles: true,
775
+ cancelable: true,
776
+ clientX: targetX,
777
+ clientY: targetY
778
+ })
779
+ );
780
+ }
781
+ if (releaseDelay > 0) {
782
+ await sleep(releaseDelay);
783
+ }
784
+ }
785
+ /**
786
+ * Resolve a drag target element from a target descriptor.
787
+ */
788
+ resolveTargetElement(target) {
789
+ if (target.elementId) {
790
+ const registered = this.registry.getElement(target.elementId);
791
+ if (registered?.element) return registered.element;
792
+ return findElementByIdentifier(target.elementId);
793
+ }
794
+ if (target.selector) {
795
+ return document.querySelector(target.selector);
796
+ }
797
+ return null;
798
+ }
571
799
  getElementId(element) {
572
800
  return element.getAttribute("data-ui-id") || element.getAttribute("data-testid") || element.id || `${element.tagName.toLowerCase()}-${Math.random().toString(36).substr(2, 8)}`;
573
801
  }
@@ -663,8 +891,8 @@ var DefaultActionExecutor = class {
663
891
  }
664
892
  }
665
893
  };
666
- function createActionExecutor(registry) {
667
- return new DefaultActionExecutor(registry);
894
+ function createActionExecutor(registry, consoleCapture) {
895
+ return new DefaultActionExecutor(registry, consoleCapture);
668
896
  }
669
897
 
670
898
  // src/control/workflow-engine.ts