@absolutejs/beacon 0.6.4 → 0.6.5

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.js CHANGED
@@ -490,14 +490,13 @@ var formControlState = (control) => {
490
490
  }
491
491
  return control.value;
492
492
  };
493
- var snapshotOwningForm = (control) => {
493
+ var snapshotRelevantFormControls = (control) => {
494
494
  const nearest = control.closest("form");
495
495
  const associated = control instanceof HTMLButtonElement || control instanceof HTMLInputElement ? control.form : null;
496
- const form = nearest ?? associated;
497
- if (form === null)
498
- return null;
496
+ const root = nearest ?? associated ?? control.closest('[role="dialog"]') ?? document;
499
497
  const snapshot = new Map;
500
- for (const element of Array.from(form.elements)) {
498
+ const elements = root instanceof HTMLFormElement ? Array.from(root.elements) : Array.from(root.querySelectorAll("input, select, textarea"));
499
+ for (const element of elements) {
501
500
  if (isFormControl(element)) {
502
501
  snapshot.set(element, formControlState(element));
503
502
  }
@@ -703,6 +702,7 @@ var createBeacon = (options) => {
703
702
  const rageCount = signals?.rageClickCount ?? RAGE_COUNT_DEFAULT;
704
703
  let networkRequestCount = 0;
705
704
  let externalNavigationCount = 0;
705
+ let clipboardWriteCount = 0;
706
706
  let inSignalConsole = false;
707
707
  let pageLifecycleEnding = false;
708
708
  let recentInteraction;
@@ -1175,9 +1175,10 @@ var createBeacon = (options) => {
1175
1175
  const urlBefore = location.href;
1176
1176
  const scrollBefore = window.scrollY;
1177
1177
  const activeBefore = document.activeElement;
1178
- const formBefore = snapshotOwningForm(control);
1178
+ const formBefore = snapshotRelevantFormControls(control);
1179
1179
  const networkRequestsBefore = networkRequestCount;
1180
1180
  const externalNavigationsBefore = externalNavigationCount;
1181
+ const clipboardWritesBefore = clipboardWriteCount;
1181
1182
  let routerAcceptedNavigation = false;
1182
1183
  let mutated = false;
1183
1184
  let extended = false;
@@ -1188,7 +1189,7 @@ var createBeacon = (options) => {
1188
1189
  return;
1189
1190
  routerAcceptedNavigation = control instanceof HTMLAnchorElement && handledEvent.defaultPrevented;
1190
1191
  };
1191
- const responded = () => mutated || formStateChanged(formBefore) || location.href !== urlBefore || window.scrollY !== scrollBefore || document.activeElement !== activeBefore || networkRequestCount !== networkRequestsBefore || externalNavigationCount !== externalNavigationsBefore;
1192
+ const responded = () => mutated || formStateChanged(formBefore) || location.href !== urlBefore || window.scrollY !== scrollBefore || document.activeElement !== activeBefore || networkRequestCount !== networkRequestsBefore || externalNavigationCount !== externalNavigationsBefore || clipboardWriteCount !== clipboardWritesBefore;
1192
1193
  const finish = (didRespond, navigationStalled = false) => {
1193
1194
  if (finished)
1194
1195
  return;
@@ -1542,7 +1543,9 @@ var createBeacon = (options) => {
1542
1543
  const target = typeof document !== "undefined" && document.activeElement instanceof Element ? describeElement(document.activeElement) : "unknown";
1543
1544
  const activation = navigator.userActivation?.isActive ?? false;
1544
1545
  try {
1545
- return await originalWriteText.call(clipboard, value);
1546
+ const result = await originalWriteText.call(clipboard, value);
1547
+ clipboardWriteCount += 1;
1548
+ return result;
1546
1549
  } catch (error) {
1547
1550
  if (!pageLifecycleEnding && typeof document !== "undefined" && document.visibilityState !== "hidden") {
1548
1551
  const resolved = toError(error);
@@ -3576,5 +3579,5 @@ export {
3576
3579
  BEACON_ATTRIBUTE
3577
3580
  };
3578
3581
 
3579
- //# debugId=9A47E9967A8B159F64756E2164756E21
3582
+ //# debugId=BB4BB2A50E2A609E64756E2164756E21
3580
3583
  //# sourceMappingURL=index.js.map