@testing-library/user-event 14.0.0-beta.6 → 14.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -41,6 +41,7 @@ var __toCommonJS = /* @__PURE__ */ ((cache) => {
41
41
  // src/index.ts
42
42
  var src_exports = {};
43
43
  __export(src_exports, {
44
+ PointerEventsCheckLevel: () => PointerEventsCheckLevel,
44
45
  default: () => userEvent
45
46
  });
46
47
 
@@ -1312,13 +1313,121 @@ function isDescendantOrSelf(potentialDescendant, potentialAncestor) {
1312
1313
  return false;
1313
1314
  }
1314
1315
 
1316
+ // src/utils/misc/level.ts
1317
+ var Level = Symbol("Api level refs");
1318
+ function setLevelRef(config, level) {
1319
+ var _a;
1320
+ (_a = config[Level]) != null ? _a : config[Level] = {};
1321
+ config[Level][level] = {};
1322
+ }
1323
+ function getLevelRef(config, level) {
1324
+ var _a;
1325
+ return (_a = config[Level]) == null ? void 0 : _a[level];
1326
+ }
1327
+
1315
1328
  // src/utils/misc/wait.ts
1316
1329
  function wait(time) {
1317
1330
  return new Promise((resolve) => setTimeout(() => resolve(), time));
1318
1331
  }
1319
1332
 
1320
- // src/utils/misc/hasPointerEvents.ts
1333
+ // src/utils/misc/hasFormSubmit.ts
1334
+ var hasFormSubmit = (form) => !!(form == null ? void 0 : form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]'));
1335
+
1336
+ // src/utils/pointer/cssPointerEvents.ts
1321
1337
  var import_helpers2 = require("@testing-library/dom/dist/helpers.js");
1338
+
1339
+ // src/keyboard/keyMap.ts
1340
+ var defaultKeyMap = [
1341
+ ..."0123456789".split("").map((c) => ({ code: `Digit${c}`, key: c })),
1342
+ ...")!@#$%^&*(".split("").map((c, i) => ({ code: `Digit${i}`, key: c, shiftKey: true })),
1343
+ ..."abcdefghijklmnopqrstuvwxyz".split("").map((c) => ({ code: `Key${c.toUpperCase()}`, key: c })),
1344
+ ..."ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("").map((c) => ({ code: `Key${c}`, key: c, shiftKey: true })),
1345
+ { code: "Space", key: " " },
1346
+ { code: "AltLeft", key: "Alt", location: 1 /* LEFT */ },
1347
+ { code: "AltRight", key: "Alt", location: 2 /* RIGHT */ },
1348
+ {
1349
+ code: "ShiftLeft",
1350
+ key: "Shift",
1351
+ location: 1 /* LEFT */
1352
+ },
1353
+ {
1354
+ code: "ShiftRight",
1355
+ key: "Shift",
1356
+ location: 2 /* RIGHT */
1357
+ },
1358
+ {
1359
+ code: "ControlLeft",
1360
+ key: "Control",
1361
+ location: 1 /* LEFT */
1362
+ },
1363
+ {
1364
+ code: "ControlRight",
1365
+ key: "Control",
1366
+ location: 2 /* RIGHT */
1367
+ },
1368
+ { code: "MetaLeft", key: "Meta", location: 1 /* LEFT */ },
1369
+ {
1370
+ code: "MetaRight",
1371
+ key: "Meta",
1372
+ location: 2 /* RIGHT */
1373
+ },
1374
+ { code: "OSLeft", key: "OS", location: 1 /* LEFT */ },
1375
+ { code: "OSRight", key: "OS", location: 2 /* RIGHT */ },
1376
+ { code: "Tab", key: "Tab" },
1377
+ { code: "CapsLock", key: "CapsLock" },
1378
+ { code: "Backspace", key: "Backspace" },
1379
+ { code: "Enter", key: "Enter" },
1380
+ { code: "Escape", key: "Escape" },
1381
+ { code: "ArrowUp", key: "ArrowUp" },
1382
+ { code: "ArrowDown", key: "ArrowDown" },
1383
+ { code: "ArrowLeft", key: "ArrowLeft" },
1384
+ { code: "ArrowRight", key: "ArrowRight" },
1385
+ { code: "Home", key: "Home" },
1386
+ { code: "End", key: "End" },
1387
+ { code: "Delete", key: "Delete" },
1388
+ { code: "PageUp", key: "PageUp" },
1389
+ { code: "PageDown", key: "PageDown" },
1390
+ { code: "Fn", key: "Fn" },
1391
+ { code: "Symbol", key: "Symbol" },
1392
+ { code: "AltRight", key: "AltGraph" }
1393
+ ];
1394
+
1395
+ // src/pointer/keyMap.ts
1396
+ var defaultKeyMap2 = [
1397
+ { name: "MouseLeft", pointerType: "mouse", button: "primary" },
1398
+ { name: "MouseRight", pointerType: "mouse", button: "secondary" },
1399
+ { name: "MouseMiddle", pointerType: "mouse", button: "auxiliary" },
1400
+ { name: "TouchA", pointerType: "touch" },
1401
+ { name: "TouchB", pointerType: "touch" },
1402
+ { name: "TouchC", pointerType: "touch" }
1403
+ ];
1404
+
1405
+ // src/options.ts
1406
+ var PointerEventsCheckLevel = /* @__PURE__ */ ((PointerEventsCheckLevel2) => {
1407
+ PointerEventsCheckLevel2[PointerEventsCheckLevel2["EachTrigger"] = 4] = "EachTrigger";
1408
+ PointerEventsCheckLevel2[PointerEventsCheckLevel2["EachApiCall"] = 2] = "EachApiCall";
1409
+ PointerEventsCheckLevel2[PointerEventsCheckLevel2["EachTarget"] = 1] = "EachTarget";
1410
+ PointerEventsCheckLevel2[PointerEventsCheckLevel2["Never"] = 0] = "Never";
1411
+ return PointerEventsCheckLevel2;
1412
+ })(PointerEventsCheckLevel || {});
1413
+ var defaultOptionsDirect = {
1414
+ applyAccept: true,
1415
+ autoModify: true,
1416
+ delay: 0,
1417
+ document: global.document,
1418
+ keyboardMap: defaultKeyMap,
1419
+ pointerMap: defaultKeyMap2,
1420
+ pointerEventsCheck: 2 /* EachApiCall */,
1421
+ skipAutoClose: false,
1422
+ skipClick: false,
1423
+ skipHover: false,
1424
+ writeToClipboard: false
1425
+ };
1426
+ var defaultOptionsSetup = __spreadProps(__spreadValues({}, defaultOptionsDirect), {
1427
+ writeToClipboard: true
1428
+ });
1429
+
1430
+ // src/utils/pointer/cssPointerEvents.ts
1322
1431
  function hasPointerEvents(element) {
1323
1432
  const window2 = (0, import_helpers2.getWindowFromNode)(element);
1324
1433
  for (let el = element; el == null ? void 0 : el.ownerDocument; el = el.parentElement) {
@@ -1329,9 +1438,26 @@ function hasPointerEvents(element) {
1329
1438
  }
1330
1439
  return true;
1331
1440
  }
1332
-
1333
- // src/utils/misc/hasFormSubmit.ts
1334
- var hasFormSubmit = (form) => !!(form == null ? void 0 : form.querySelector('input[type="submit"], button:not([type]), button[type="submit"]'));
1441
+ var PointerEventsCheck = Symbol("Last check for pointer-events");
1442
+ function assertPointerEvents(config, element) {
1443
+ const lastCheck = element[PointerEventsCheck];
1444
+ const needsCheck = config.pointerEventsCheck !== 0 /* Never */ && (!lastCheck || hasBitFlag(config.pointerEventsCheck, 2 /* EachApiCall */) && lastCheck[1 /* Call */] !== getLevelRef(config, 1 /* Call */) || hasBitFlag(config.pointerEventsCheck, 4 /* EachTrigger */) && lastCheck[2 /* Trigger */] !== getLevelRef(config, 2 /* Trigger */));
1445
+ if (!needsCheck) {
1446
+ return;
1447
+ }
1448
+ const result = hasPointerEvents(element);
1449
+ element[PointerEventsCheck] = {
1450
+ [1 /* Call */]: getLevelRef(config, 1 /* Call */),
1451
+ [2 /* Trigger */]: getLevelRef(config, 2 /* Trigger */),
1452
+ result
1453
+ };
1454
+ if (!result) {
1455
+ throw new Error('Unable to perform pointer interaction as the element has or inherits pointer-events set to "none".');
1456
+ }
1457
+ }
1458
+ function hasBitFlag(conf, flag) {
1459
+ return (conf & flag) > 0;
1460
+ }
1335
1461
 
1336
1462
  // src/utils/pointer/firePointerEvents.ts
1337
1463
  var import_dom5 = require("@testing-library/dom");
@@ -2001,7 +2127,8 @@ function findNodeAtTextOffset(node, offset, isRoot = true) {
2001
2127
  }
2002
2128
 
2003
2129
  // src/pointer/pointerMove.ts
2004
- async function pointerMove({ pointerName = "mouse", target, coords, node, offset }, { pointerState, keyboardState }) {
2130
+ async function pointerMove(config, { pointerName = "mouse", target, coords, node, offset }) {
2131
+ const { pointerState, keyboardState } = config;
2005
2132
  if (!(pointerName in pointerState.position)) {
2006
2133
  throw new Error(`Trying to move pointer "${pointerName}" which does not exist.`);
2007
2134
  }
@@ -2013,11 +2140,15 @@ async function pointerMove({ pointerName = "mouse", target, coords, node, offset
2013
2140
  selectionRange
2014
2141
  } = pointerState.position[pointerName];
2015
2142
  if (prevTarget && prevTarget !== target) {
2143
+ setLevelRef(config, 2 /* Trigger */);
2144
+ assertPointerEvents(config, prevTarget);
2016
2145
  fireMove(prevTarget, prevCoords);
2017
2146
  if (!isDescendantOrSelf(target, prevTarget)) {
2018
2147
  fireLeave(prevTarget, prevCoords);
2019
2148
  }
2020
2149
  }
2150
+ setLevelRef(config, 2 /* Trigger */);
2151
+ assertPointerEvents(config, target);
2021
2152
  pointerState.position[pointerName] = __spreadProps(__spreadValues({}, pointerState.position[pointerName]), {
2022
2153
  target,
2023
2154
  coords
@@ -2083,18 +2214,18 @@ async function pointerMove({ pointerName = "mouse", target, coords, node, offset
2083
2214
  }
2084
2215
 
2085
2216
  // src/pointer/pointerPress.ts
2086
- async function pointerPress(action, state) {
2217
+ async function pointerPress(config, action) {
2087
2218
  const { keyDef, target, releasePrevious, releaseSelf } = action;
2088
- const previous = state.pointerState.pressed.find((p) => p.keyDef === keyDef);
2219
+ const previous = config.pointerState.pressed.find((p) => p.keyDef === keyDef);
2089
2220
  const pointerName = keyDef.pointerType === "touch" ? keyDef.name : keyDef.pointerType;
2090
2221
  const targetIsDisabled = isDisabled(target);
2091
2222
  if (previous) {
2092
- up(state, pointerName, action, previous, targetIsDisabled);
2223
+ up(config, pointerName, action, previous, targetIsDisabled);
2093
2224
  }
2094
2225
  if (!releasePrevious) {
2095
- const press = down(state, pointerName, action, targetIsDisabled);
2226
+ const press = down(config, pointerName, action, targetIsDisabled);
2096
2227
  if (releaseSelf) {
2097
- up(state, pointerName, action, press, targetIsDisabled);
2228
+ up(config, pointerName, action, press, targetIsDisabled);
2098
2229
  }
2099
2230
  }
2100
2231
  }
@@ -2102,8 +2233,11 @@ function getNextPointerId(state) {
2102
2233
  state.pointerId = state.pointerId + 1;
2103
2234
  return state.pointerId;
2104
2235
  }
2105
- function down({ pointerState, keyboardState }, pointerName, { keyDef, node, offset, target, coords }, targetIsDisabled) {
2236
+ function down(config, pointerName, { keyDef, node, offset, target, coords }, targetIsDisabled) {
2106
2237
  var _a, _b, _c;
2238
+ setLevelRef(config, 2 /* Trigger */);
2239
+ assertPointerEvents(config, target);
2240
+ const { pointerState, keyboardState } = config;
2107
2241
  const { name, pointerType, button } = keyDef;
2108
2242
  const pointerId = pointerType === "mouse" ? 1 : getNextPointerId(pointerState);
2109
2243
  pointerState.position[pointerName] = __spreadProps(__spreadValues({}, pointerState.position[pointerName]), {
@@ -2177,7 +2311,7 @@ function down({ pointerState, keyboardState }, pointerName, { keyDef, node, offs
2177
2311
  });
2178
2312
  }
2179
2313
  }
2180
- function up({ pointerState, keyboardState }, pointerName, {
2314
+ function up(config, pointerName, {
2181
2315
  keyDef: { pointerType, button },
2182
2316
  target,
2183
2317
  coords,
@@ -2185,6 +2319,9 @@ function up({ pointerState, keyboardState }, pointerName, {
2185
2319
  offset
2186
2320
  }, pressed, targetIsDisabled) {
2187
2321
  var _a;
2322
+ setLevelRef(config, 2 /* Trigger */);
2323
+ assertPointerEvents(config, target);
2324
+ const { pointerState, keyboardState } = config;
2188
2325
  pointerState.pressed = pointerState.pressed.filter((p) => p !== pressed);
2189
2326
  const { isMultiTouch, isPrimary, pointerId, clickCount } = pressed;
2190
2327
  let { unpreventedDefault } = pressed;
@@ -2319,7 +2456,7 @@ async function pointerAction(config, actions) {
2319
2456
  const pointerName = "pointerName" in action && action.pointerName ? action.pointerName : "keyDef" in action ? action.keyDef.pointerType === "touch" ? action.keyDef.name : action.keyDef.pointerType : "mouse";
2320
2457
  const target = (_a = action.target) != null ? _a : getPrevTarget(pointerName, config.pointerState);
2321
2458
  const coords = (_b = action.coords) != null ? _b : pointerName in config.pointerState.position ? config.pointerState.position[pointerName].coords : void 0;
2322
- await ("keyDef" in action ? pointerPress(__spreadProps(__spreadValues({}, action), { target, coords }), config) : pointerMove(__spreadProps(__spreadValues({}, action), { target, coords }), config));
2459
+ await ("keyDef" in action ? pointerPress(config, __spreadProps(__spreadValues({}, action), { target, coords })) : pointerMove(config, __spreadProps(__spreadValues({}, action), { target, coords })));
2323
2460
  if (typeof config.delay === "number") {
2324
2461
  if (i < actions.length - 1) {
2325
2462
  await wait(config.delay);
@@ -2374,90 +2511,6 @@ function createPointerState(document2) {
2374
2511
  };
2375
2512
  }
2376
2513
 
2377
- // src/keyboard/keyMap.ts
2378
- var defaultKeyMap = [
2379
- ..."0123456789".split("").map((c) => ({ code: `Digit${c}`, key: c })),
2380
- ...")!@#$%^&*(".split("").map((c, i) => ({ code: `Digit${i}`, key: c, shiftKey: true })),
2381
- ..."abcdefghijklmnopqrstuvwxyz".split("").map((c) => ({ code: `Key${c.toUpperCase()}`, key: c })),
2382
- ..."ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("").map((c) => ({ code: `Key${c}`, key: c, shiftKey: true })),
2383
- { code: "Space", key: " " },
2384
- { code: "AltLeft", key: "Alt", location: 1 /* LEFT */ },
2385
- { code: "AltRight", key: "Alt", location: 2 /* RIGHT */ },
2386
- {
2387
- code: "ShiftLeft",
2388
- key: "Shift",
2389
- location: 1 /* LEFT */
2390
- },
2391
- {
2392
- code: "ShiftRight",
2393
- key: "Shift",
2394
- location: 2 /* RIGHT */
2395
- },
2396
- {
2397
- code: "ControlLeft",
2398
- key: "Control",
2399
- location: 1 /* LEFT */
2400
- },
2401
- {
2402
- code: "ControlRight",
2403
- key: "Control",
2404
- location: 2 /* RIGHT */
2405
- },
2406
- { code: "MetaLeft", key: "Meta", location: 1 /* LEFT */ },
2407
- {
2408
- code: "MetaRight",
2409
- key: "Meta",
2410
- location: 2 /* RIGHT */
2411
- },
2412
- { code: "OSLeft", key: "OS", location: 1 /* LEFT */ },
2413
- { code: "OSRight", key: "OS", location: 2 /* RIGHT */ },
2414
- { code: "Tab", key: "Tab" },
2415
- { code: "CapsLock", key: "CapsLock" },
2416
- { code: "Backspace", key: "Backspace" },
2417
- { code: "Enter", key: "Enter" },
2418
- { code: "Escape", key: "Escape" },
2419
- { code: "ArrowUp", key: "ArrowUp" },
2420
- { code: "ArrowDown", key: "ArrowDown" },
2421
- { code: "ArrowLeft", key: "ArrowLeft" },
2422
- { code: "ArrowRight", key: "ArrowRight" },
2423
- { code: "Home", key: "Home" },
2424
- { code: "End", key: "End" },
2425
- { code: "Delete", key: "Delete" },
2426
- { code: "PageUp", key: "PageUp" },
2427
- { code: "PageDown", key: "PageDown" },
2428
- { code: "Fn", key: "Fn" },
2429
- { code: "Symbol", key: "Symbol" },
2430
- { code: "AltRight", key: "AltGraph" }
2431
- ];
2432
-
2433
- // src/pointer/keyMap.ts
2434
- var defaultKeyMap2 = [
2435
- { name: "MouseLeft", pointerType: "mouse", button: "primary" },
2436
- { name: "MouseRight", pointerType: "mouse", button: "secondary" },
2437
- { name: "MouseMiddle", pointerType: "mouse", button: "auxiliary" },
2438
- { name: "TouchA", pointerType: "touch" },
2439
- { name: "TouchB", pointerType: "touch" },
2440
- { name: "TouchC", pointerType: "touch" }
2441
- ];
2442
-
2443
- // src/options.ts
2444
- var defaultOptionsDirect = {
2445
- applyAccept: true,
2446
- autoModify: true,
2447
- delay: 0,
2448
- document: global.document,
2449
- keyboardMap: defaultKeyMap,
2450
- pointerMap: defaultKeyMap2,
2451
- skipAutoClose: false,
2452
- skipClick: false,
2453
- skipHover: false,
2454
- skipPointerEventsCheck: false,
2455
- writeToClipboard: false
2456
- };
2457
- var defaultOptionsSetup = __spreadProps(__spreadValues({}, defaultOptionsDirect), {
2458
- writeToClipboard: true
2459
- });
2460
-
2461
2514
  // src/setup/config.ts
2462
2515
  var Config = Symbol("Config");
2463
2516
 
@@ -2484,9 +2537,6 @@ __export(api_exports, {
2484
2537
 
2485
2538
  // src/convenience/click.ts
2486
2539
  async function click(element) {
2487
- if (!this[Config].skipPointerEventsCheck && !hasPointerEvents(element)) {
2488
- throw new Error('unable to click element as it has or inherits pointer-events set to "none".');
2489
- }
2490
2540
  const pointerIn = [];
2491
2541
  if (!this[Config].skipHover) {
2492
2542
  pointerIn.push({ target: element });
@@ -2495,29 +2545,17 @@ async function click(element) {
2495
2545
  return this.pointer(pointerIn);
2496
2546
  }
2497
2547
  async function dblClick(element) {
2498
- if (!this[Config].skipPointerEventsCheck && !hasPointerEvents(element)) {
2499
- throw new Error('unable to double-click element as it has or inherits pointer-events set to "none".');
2500
- }
2501
2548
  return this.pointer([{ target: element }, "[MouseLeft][MouseLeft]"]);
2502
2549
  }
2503
2550
  async function tripleClick(element) {
2504
- if (!this[Config].skipPointerEventsCheck && !hasPointerEvents(element)) {
2505
- throw new Error('unable to triple-click element as it has or inherits pointer-events set to "none".');
2506
- }
2507
2551
  return this.pointer([{ target: element }, "[MouseLeft][MouseLeft][MouseLeft]"]);
2508
2552
  }
2509
2553
 
2510
2554
  // src/convenience/hover.ts
2511
2555
  async function hover(element) {
2512
- if (!this[Config].skipPointerEventsCheck && !hasPointerEvents(element)) {
2513
- throw new Error('unable to hover element as it has or inherits pointer-events set to "none".');
2514
- }
2515
2556
  return this.pointer({ target: element });
2516
2557
  }
2517
2558
  async function unhover(element) {
2518
- if (!this[Config].skipPointerEventsCheck && !hasPointerEvents(element)) {
2519
- throw new Error('unable to unhover element as it has or inherits pointer-events set to "none".');
2520
- }
2521
2559
  return this.pointer({ target: element.ownerDocument.body });
2522
2560
  }
2523
2561
 
@@ -2646,7 +2684,7 @@ async function selectOptionsBase(newValue, select, values) {
2646
2684
  if (isElementType(select, "select")) {
2647
2685
  if (select.multiple) {
2648
2686
  for (const option of selectedOptions) {
2649
- const withPointerEvents = this[Config].skipPointerEventsCheck ? true : hasPointerEvents(option);
2687
+ const withPointerEvents = this[Config].pointerEventsCheck === 0 ? true : hasPointerEvents(option);
2650
2688
  if (withPointerEvents) {
2651
2689
  import_dom14.fireEvent.pointerOver(option);
2652
2690
  import_dom14.fireEvent.pointerEnter(select);
@@ -2668,7 +2706,7 @@ async function selectOptionsBase(newValue, select, values) {
2668
2706
  }
2669
2707
  }
2670
2708
  } else if (selectedOptions.length === 1) {
2671
- const withPointerEvents = this[Config].skipPointerEventsCheck ? true : hasPointerEvents(select);
2709
+ const withPointerEvents = this[Config].pointerEventsCheck === 0 ? true : hasPointerEvents(select);
2672
2710
  if (withPointerEvents) {
2673
2711
  await this.click(select);
2674
2712
  } else {
@@ -2779,7 +2817,7 @@ function setupMain(options = {}) {
2779
2817
  prepareDocument(doc);
2780
2818
  const view = (_a = doc.defaultView) != null ? _a : window;
2781
2819
  attachClipboardStubToView(view);
2782
- return doSetup(__spreadProps(__spreadValues({}, defaultOptionsSetup), {
2820
+ return doSetup(__spreadProps(__spreadValues(__spreadValues({}, defaultOptionsSetup), options), {
2783
2821
  keyboardState: createKeyboardState(),
2784
2822
  pointerState: createPointerState(doc)
2785
2823
  }));
@@ -2787,26 +2825,35 @@ function setupMain(options = {}) {
2787
2825
  function setupDirect(options = {}, node) {
2788
2826
  const doc = getDocument(options, node);
2789
2827
  prepareDocument(doc);
2790
- return doSetup(__spreadValues(__spreadValues({
2828
+ const config = __spreadValues(__spreadValues({
2791
2829
  keyboardState: createKeyboardState(),
2792
2830
  pointerState: createPointerState(doc)
2793
- }, defaultOptionsDirect), options));
2831
+ }, defaultOptionsDirect), options);
2832
+ return {
2833
+ config,
2834
+ api: doSetup(config)
2835
+ };
2794
2836
  }
2795
2837
  function setupSub(options) {
2796
2838
  return doSetup(__spreadValues(__spreadValues({}, this[Config]), options));
2797
2839
  }
2798
- function wrapImpl(impl) {
2840
+ function wrapAndBindImpl(instance, impl) {
2799
2841
  function method(...args) {
2800
- return wrapAsync(() => impl.apply(this, args));
2842
+ setLevelRef(instance[Config], 1 /* Call */);
2843
+ return wrapAsync(() => impl.apply(instance, args));
2801
2844
  }
2802
2845
  Object.defineProperty(method, "name", { get: () => impl.name });
2803
2846
  return method;
2804
2847
  }
2805
- var wrappedApis = Object.fromEntries(Object.entries(api_exports).map(([name, impl]) => [name, wrapImpl(impl)]));
2806
2848
  function doSetup(config) {
2807
- return __spreadProps(__spreadValues({}, wrappedApis), {
2808
- setup: setupSub,
2849
+ const instance = __spreadValues({
2809
2850
  [Config]: config
2851
+ }, api_exports);
2852
+ return __spreadProps(__spreadValues({}, Object.fromEntries(Object.entries(api_exports).map(([name, api]) => [
2853
+ name,
2854
+ wrapAndBindImpl(instance, api)
2855
+ ]))), {
2856
+ setup: setupSub.bind(instance)
2810
2857
  });
2811
2858
  }
2812
2859
  function getDocument(options, node) {
@@ -2835,58 +2882,56 @@ __export(directApi_exports, {
2835
2882
  upload: () => upload2
2836
2883
  });
2837
2884
  function clear2(element) {
2838
- return setupDirect().clear(element);
2885
+ return setupDirect().api.clear(element);
2839
2886
  }
2840
2887
  function click2(element, options = {}) {
2841
- return setupDirect(options, element).click(element);
2888
+ return setupDirect(options, element).api.click(element);
2842
2889
  }
2843
2890
  function copy2(options = {}) {
2844
- return setupDirect(options).copy();
2891
+ return setupDirect(options).api.copy();
2845
2892
  }
2846
2893
  function cut2(options = {}) {
2847
- return setupDirect(options).cut();
2894
+ return setupDirect(options).api.cut();
2848
2895
  }
2849
2896
  function dblClick2(element, options = {}) {
2850
- return setupDirect(options).dblClick(element);
2897
+ return setupDirect(options).api.dblClick(element);
2851
2898
  }
2852
2899
  function deselectOptions2(select, values, options = {}) {
2853
- return setupDirect(options).deselectOptions(select, values);
2900
+ return setupDirect(options).api.deselectOptions(select, values);
2854
2901
  }
2855
2902
  function hover2(element, options = {}) {
2856
- return setupDirect(options).hover(element);
2903
+ return setupDirect(options).api.hover(element);
2857
2904
  }
2858
2905
  async function keyboard2(text, options = {}) {
2859
- const instance = setupDirect(options);
2860
- const promise = instance.keyboard(text);
2861
- return promise.then(() => instance[Config].keyboardState);
2906
+ const { config, api } = setupDirect(options);
2907
+ return api.keyboard(text).then(() => config.keyboardState);
2862
2908
  }
2863
2909
  async function pointer2(input, options = {}) {
2864
- const instance = setupDirect(options);
2865
- const promise = instance.pointer(input);
2866
- return promise.then(() => instance[Config].pointerState);
2910
+ const { config, api } = setupDirect(options);
2911
+ return api.pointer(input).then(() => config.pointerState);
2867
2912
  }
2868
2913
  function paste2(clipboardData, options) {
2869
- return setupDirect(options).paste(clipboardData);
2914
+ return setupDirect(options).api.paste(clipboardData);
2870
2915
  }
2871
2916
  function selectOptions2(select, values, options = {}) {
2872
- return setupDirect(options).selectOptions(select, values);
2917
+ return setupDirect(options).api.selectOptions(select, values);
2873
2918
  }
2874
2919
  function tripleClick2(element, options = {}) {
2875
- return setupDirect(options).tripleClick(element);
2920
+ return setupDirect(options).api.tripleClick(element);
2876
2921
  }
2877
2922
  function type2(element, text, options = {}) {
2878
- return setupDirect(options, element).type(element, text, options);
2923
+ return setupDirect(options, element).api.type(element, text, options);
2879
2924
  }
2880
2925
  function unhover2(element, options = {}) {
2881
- const instance = setupDirect(options);
2882
- instance[Config].pointerState.position.mouse.target = element;
2883
- return instance.unhover(element);
2926
+ const { config, api } = setupDirect(options);
2927
+ config.pointerState.position.mouse.target = element;
2928
+ return api.unhover(element);
2884
2929
  }
2885
2930
  function upload2(element, fileOrFiles, options = {}) {
2886
- return setupDirect(options).upload(element, fileOrFiles);
2931
+ return setupDirect(options).api.upload(element, fileOrFiles);
2887
2932
  }
2888
2933
  function tab2(options = {}) {
2889
- return setupDirect().tab(options);
2934
+ return setupDirect().api.tab(options);
2890
2935
  }
2891
2936
 
2892
2937
  // src/setup/index.ts