@ansight/capacitor 1.3.0-preview.11 → 1.3.0-preview.12
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/AnsightCapacitor.podspec +1 -1
- package/Package.swift +1 -1
- package/README.md +59 -24
- package/android/build.gradle +2 -2
- package/dist/esm/dom.d.ts +11 -0
- package/dist/esm/dom.d.ts.map +1 -1
- package/dist/esm/dom.js +69 -14
- package/dist/esm/dom.js.map +1 -1
- package/dist/esm/session-properties.d.ts +1 -1
- package/dist/esm/session-properties.js +1 -1
- package/dist/esm/standalone-options.d.ts +3 -0
- package/dist/esm/standalone-options.d.ts.map +1 -0
- package/dist/esm/standalone-options.js +15 -0
- package/dist/esm/standalone-options.js.map +1 -0
- package/dist/esm/standalone.d.ts.map +1 -1
- package/dist/esm/standalone.js +2 -11
- package/dist/esm/standalone.js.map +1 -1
- package/dist/plugin.cjs.js +70 -15
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +70 -15
- package/dist/plugin.js.map +1 -1
- package/dist/standalone.js +77 -18
- package/dist/standalone.js.map +1 -1
- package/package.json +1 -1
package/dist/standalone.js
CHANGED
|
@@ -700,6 +700,19 @@
|
|
|
700
700
|
element.id ??
|
|
701
701
|
undefined)?.trim() || undefined);
|
|
702
702
|
}
|
|
703
|
+
const tapRoles = new Set([
|
|
704
|
+
"button",
|
|
705
|
+
"checkbox",
|
|
706
|
+
"combobox",
|
|
707
|
+
"link",
|
|
708
|
+
"menuitem",
|
|
709
|
+
"menuitemcheckbox",
|
|
710
|
+
"menuitemradio",
|
|
711
|
+
"option",
|
|
712
|
+
"radio",
|
|
713
|
+
"switch",
|
|
714
|
+
"tab",
|
|
715
|
+
]);
|
|
703
716
|
function semanticRole(element) {
|
|
704
717
|
const declared = element.getAttribute("role")?.trim().toLowerCase();
|
|
705
718
|
if (declared)
|
|
@@ -731,24 +744,54 @@
|
|
|
731
744
|
if (!allowActions)
|
|
732
745
|
return [];
|
|
733
746
|
const actions = [];
|
|
747
|
+
const htmlElement = element;
|
|
748
|
+
const role = semanticRole(element);
|
|
734
749
|
if (["A", "BUTTON", "SUMMARY"].includes(element.tagName) ||
|
|
735
|
-
element instanceof HTMLInputElement
|
|
750
|
+
element instanceof HTMLInputElement ||
|
|
751
|
+
tapRoles.has(role) ||
|
|
752
|
+
element.hasAttribute("onclick") ||
|
|
753
|
+
typeof htmlElement.onclick === "function") {
|
|
736
754
|
actions.push("tap");
|
|
737
755
|
}
|
|
738
756
|
if (element instanceof HTMLInputElement ||
|
|
739
757
|
element instanceof HTMLTextAreaElement ||
|
|
740
|
-
element instanceof HTMLSelectElement
|
|
758
|
+
element instanceof HTMLSelectElement ||
|
|
759
|
+
htmlElement.isContentEditable) {
|
|
741
760
|
actions.push("typeText", "focus");
|
|
742
761
|
}
|
|
743
|
-
else if (
|
|
762
|
+
else if (htmlElement.tabIndex >= 0) {
|
|
744
763
|
actions.push("focus");
|
|
745
764
|
}
|
|
746
|
-
if (
|
|
747
|
-
|
|
765
|
+
if (htmlElement.scrollHeight > htmlElement.clientHeight ||
|
|
766
|
+
htmlElement.scrollWidth > htmlElement.clientWidth) {
|
|
748
767
|
actions.push("scroll", "swipe");
|
|
749
768
|
}
|
|
750
769
|
return [...new Set(actions)];
|
|
751
770
|
}
|
|
771
|
+
function positiveFinite(value) {
|
|
772
|
+
const parsed = Number(value);
|
|
773
|
+
return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;
|
|
774
|
+
}
|
|
775
|
+
function createDomCoordinateSpace(browserWindow = typeof window === "undefined"
|
|
776
|
+
? undefined
|
|
777
|
+
: window, documentElement = typeof document === "undefined"
|
|
778
|
+
? null
|
|
779
|
+
: document.documentElement) {
|
|
780
|
+
const width = positiveFinite(browserWindow?.innerWidth) ??
|
|
781
|
+
positiveFinite(documentElement?.clientWidth);
|
|
782
|
+
const height = positiveFinite(browserWindow?.innerHeight) ??
|
|
783
|
+
positiveFinite(documentElement?.clientHeight);
|
|
784
|
+
if (width === undefined || height === undefined)
|
|
785
|
+
return undefined;
|
|
786
|
+
return { x: 0, y: 0, width, height, source: "dom.viewport" };
|
|
787
|
+
}
|
|
788
|
+
function normalizeDomAction(action) {
|
|
789
|
+
if (action === "tap")
|
|
790
|
+
return "click";
|
|
791
|
+
if (action === "typeText")
|
|
792
|
+
return "setValue";
|
|
793
|
+
return String(action ?? "");
|
|
794
|
+
}
|
|
752
795
|
function computedColorToArgbHex(value) {
|
|
753
796
|
const normalized = value.trim().toLowerCase();
|
|
754
797
|
if (!normalized)
|
|
@@ -913,6 +956,7 @@
|
|
|
913
956
|
platform: "web",
|
|
914
957
|
source: options.source,
|
|
915
958
|
adapter: "@ansight/capacitor",
|
|
959
|
+
coordinateSpace: createDomCoordinateSpace(),
|
|
916
960
|
capturedAtUtc: new Date().toISOString(),
|
|
917
961
|
types: typeRegistry.types,
|
|
918
962
|
truncated: limits.count >= limits.maxNodes,
|
|
@@ -947,6 +991,7 @@
|
|
|
947
991
|
platform: "web",
|
|
948
992
|
source: options.source,
|
|
949
993
|
adapter: "@ansight/capacitor",
|
|
994
|
+
coordinateSpace: createDomCoordinateSpace(),
|
|
950
995
|
capturedAtUtc: new Date().toISOString(),
|
|
951
996
|
types: typeRegistry.types,
|
|
952
997
|
node,
|
|
@@ -985,7 +1030,7 @@
|
|
|
985
1030
|
registrations.push(registerTool({
|
|
986
1031
|
id: "dom.invoke_action",
|
|
987
1032
|
name: "Invoke DOM action",
|
|
988
|
-
description: "
|
|
1033
|
+
description: "Taps, focuses, blurs, or enters text in a DOM node.",
|
|
989
1034
|
category: "UI",
|
|
990
1035
|
scope: "write",
|
|
991
1036
|
argumentsSchema: {
|
|
@@ -993,7 +1038,10 @@
|
|
|
993
1038
|
required: ["nodeId", "action"],
|
|
994
1039
|
properties: {
|
|
995
1040
|
nodeId: { type: "string" },
|
|
996
|
-
action: {
|
|
1041
|
+
action: {
|
|
1042
|
+
type: "string",
|
|
1043
|
+
enum: ["tap", "typeText", "click", "focus", "blur", "setValue"],
|
|
1044
|
+
},
|
|
997
1045
|
value: { type: "string" },
|
|
998
1046
|
},
|
|
999
1047
|
},
|
|
@@ -1010,17 +1058,24 @@
|
|
|
1010
1058
|
errorCode: "dom_node_not_found",
|
|
1011
1059
|
};
|
|
1012
1060
|
}
|
|
1013
|
-
|
|
1061
|
+
const normalizedAction = normalizeDomAction(action);
|
|
1062
|
+
if (normalizedAction === "click")
|
|
1014
1063
|
element.click();
|
|
1015
|
-
else if (
|
|
1064
|
+
else if (normalizedAction === "focus")
|
|
1016
1065
|
element.focus();
|
|
1017
|
-
else if (
|
|
1066
|
+
else if (normalizedAction === "blur")
|
|
1018
1067
|
element.blur();
|
|
1019
|
-
else if (
|
|
1068
|
+
else if (normalizedAction === "setValue" &&
|
|
1020
1069
|
(element instanceof HTMLInputElement ||
|
|
1021
1070
|
element instanceof HTMLTextAreaElement ||
|
|
1022
|
-
element instanceof HTMLSelectElement
|
|
1023
|
-
|
|
1071
|
+
element instanceof HTMLSelectElement ||
|
|
1072
|
+
element.isContentEditable)) {
|
|
1073
|
+
if (element.isContentEditable) {
|
|
1074
|
+
element.textContent = value ?? "";
|
|
1075
|
+
}
|
|
1076
|
+
else {
|
|
1077
|
+
element.value = value ?? "";
|
|
1078
|
+
}
|
|
1024
1079
|
element.dispatchEvent(new Event("input", { bubbles: true }));
|
|
1025
1080
|
element.dispatchEvent(new Event("change", { bubbles: true }));
|
|
1026
1081
|
}
|
|
@@ -1031,7 +1086,7 @@
|
|
|
1031
1086
|
errorCode: "dom_action_unsupported",
|
|
1032
1087
|
};
|
|
1033
1088
|
}
|
|
1034
|
-
return successful({ nodeId: id, action }, `DOM action '${action}' invoked.`);
|
|
1089
|
+
return successful({ nodeId: id, action, performedAction: normalizedAction }, `DOM action '${action}' invoked.`);
|
|
1035
1090
|
}));
|
|
1036
1091
|
}
|
|
1037
1092
|
return {
|
|
@@ -2156,7 +2211,7 @@
|
|
|
2156
2211
|
};
|
|
2157
2212
|
}
|
|
2158
2213
|
|
|
2159
|
-
const ANSIGHT_CAPACITOR_SDK_VERSION = "1.3.0-preview.
|
|
2214
|
+
const ANSIGHT_CAPACITOR_SDK_VERSION = "1.3.0-preview.12";
|
|
2160
2215
|
const COMPILED_CAPACITOR_CORE_VERSION = "8.4.2";
|
|
2161
2216
|
const CAPACITOR_GROUP = "capacitor";
|
|
2162
2217
|
const LOCALIZATION_GROUP = "localization";
|
|
@@ -2969,10 +3024,9 @@
|
|
|
2969
3024
|
platform: Capacitor.getPlatform(),
|
|
2970
3025
|
};
|
|
2971
3026
|
|
|
2972
|
-
|
|
2973
|
-
|
|
3027
|
+
function createStandaloneOptions(overrides = {}) {
|
|
3028
|
+
return createOptionsBuilder(overrides)
|
|
2974
3029
|
.withAnsightDefaults()
|
|
2975
|
-
.withAllToolAccess()
|
|
2976
3030
|
.withVisualTreeTools()
|
|
2977
3031
|
.withFileSystemTools()
|
|
2978
3032
|
.withDatabaseTools()
|
|
@@ -2980,7 +3034,12 @@
|
|
|
2980
3034
|
.withReflectionTools()
|
|
2981
3035
|
.withDomTools()
|
|
2982
3036
|
.withErrorCapture()
|
|
3037
|
+
.withToolGuard(overrides.toolGuard ?? "readOnly")
|
|
2983
3038
|
.build();
|
|
3039
|
+
}
|
|
3040
|
+
|
|
3041
|
+
if (typeof window !== "undefined") {
|
|
3042
|
+
const options = createStandaloneOptions(globalThis.__ANSIGHT_CAPACITOR_STANDALONE_OPTIONS__ ?? {});
|
|
2984
3043
|
void Ansight.initializeAndActivate(options).catch((error) => {
|
|
2985
3044
|
console.error("[Ansight Capacitor]", error);
|
|
2986
3045
|
});
|