agentation-vue 0.2.3 → 0.2.4

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 DELETED
@@ -1,168 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "AgentationVue", {
7
- enumerable: true,
8
- get: function () {
9
- return _AgentationVue.default;
10
- }
11
- });
12
- exports.AgentationVuePlugin = void 0;
13
- Object.defineProperty(exports, "ComponentChain", {
14
- enumerable: true,
15
- get: function () {
16
- return _ComponentChain.default;
17
- }
18
- });
19
- Object.defineProperty(exports, "DEFAULT_SHORTCUT_CONFIG", {
20
- enumerable: true,
21
- get: function () {
22
- return _useKeyboardShortcuts.DEFAULT_SHORTCUT_CONFIG;
23
- }
24
- });
25
- Object.defineProperty(exports, "VaButton", {
26
- enumerable: true,
27
- get: function () {
28
- return _VaButton.default;
29
- }
30
- });
31
- Object.defineProperty(exports, "VaIcon", {
32
- enumerable: true,
33
- get: function () {
34
- return _VaIcon.default;
35
- }
36
- });
37
- Object.defineProperty(exports, "VaIconButton", {
38
- enumerable: true,
39
- get: function () {
40
- return _VaIconButton.default;
41
- }
42
- });
43
- Object.defineProperty(exports, "VaToggle", {
44
- enumerable: true,
45
- get: function () {
46
- return _VaToggle.default;
47
- }
48
- });
49
-
50
- Object.defineProperty(exports, "formatAnnotations", {
51
- enumerable: true,
52
- get: function () {
53
- return _useOutputFormatter.formatAnnotations;
54
- }
55
- });
56
- Object.defineProperty(exports, "icons", {
57
- enumerable: true,
58
- get: function () {
59
- return _icons.icons;
60
- }
61
- });
62
- Object.defineProperty(exports, "useAnimationPause", {
63
- enumerable: true,
64
- get: function () {
65
- return _useAnimationPause.useAnimationPause;
66
- }
67
- });
68
- Object.defineProperty(exports, "useAnnotations", {
69
- enumerable: true,
70
- get: function () {
71
- return _useAnnotations.useAnnotations;
72
- }
73
- });
74
- Object.defineProperty(exports, "useAreaSelect", {
75
- enumerable: true,
76
- get: function () {
77
- return _useAreaSelect.useAreaSelect;
78
- }
79
- });
80
- Object.defineProperty(exports, "useElementDetection", {
81
- enumerable: true,
82
- get: function () {
83
- return _useElementDetection.useElementDetection;
84
- }
85
- });
86
- Object.defineProperty(exports, "useInteractionMode", {
87
- enumerable: true,
88
- get: function () {
89
- return _useInteractionMode.useInteractionMode;
90
- }
91
- });
92
- Object.defineProperty(exports, "useKeyboardShortcuts", {
93
- enumerable: true,
94
- get: function () {
95
- return _useKeyboardShortcuts.useKeyboardShortcuts;
96
- }
97
- });
98
- Object.defineProperty(exports, "useMarkerPositions", {
99
- enumerable: true,
100
- get: function () {
101
- return _useMarkerPositions.useMarkerPositions;
102
- }
103
- });
104
- Object.defineProperty(exports, "useMultiSelect", {
105
- enumerable: true,
106
- get: function () {
107
- return _useMultiSelect.useMultiSelect;
108
- }
109
- });
110
- Object.defineProperty(exports, "useOutputFormatter", {
111
- enumerable: true,
112
- get: function () {
113
- return _useOutputFormatter.useOutputFormatter;
114
- }
115
- });
116
- Object.defineProperty(exports, "useSettings", {
117
- enumerable: true,
118
- get: function () {
119
- return _useSettings.useSettings;
120
- }
121
- });
122
- Object.defineProperty(exports, "useTextSelection", {
123
- enumerable: true,
124
- get: function () {
125
- return _useTextSelection.useTextSelection;
126
- }
127
- });
128
- Object.defineProperty(exports, "useToolbarAutoHide", {
129
- enumerable: true,
130
- get: function () {
131
- return _useToolbarAutoHide.useToolbarAutoHide;
132
- }
133
- });
134
- Object.defineProperty(exports, "vaTooltipDirective", {
135
- enumerable: true,
136
- get: function () {
137
- return _vaTooltip.vaTooltipDirective;
138
- }
139
- });
140
- var _AgentationVue = _interopRequireDefault(require("./AgentationVue.vue"));
141
- var _vaTooltip = require("./directives/vaTooltip");
142
- var _ComponentChain = _interopRequireDefault(require("./components/ComponentChain.vue"));
143
- var _VaButton = _interopRequireDefault(require("./components/VaButton.vue"));
144
- var _VaIcon = _interopRequireDefault(require("./components/VaIcon.vue"));
145
- var _VaIconButton = _interopRequireDefault(require("./components/VaIconButton.vue"));
146
- var _VaToggle = _interopRequireDefault(require("./components/VaToggle.vue"));
147
- var _useAnimationPause = require("./composables/useAnimationPause");
148
- var _useAnnotations = require("./composables/useAnnotations");
149
- var _useAreaSelect = require("./composables/useAreaSelect");
150
- var _useElementDetection = require("./composables/useElementDetection");
151
- var _useInteractionMode = require("./composables/useInteractionMode");
152
- var _useKeyboardShortcuts = require("./composables/useKeyboardShortcuts");
153
- var _useMarkerPositions = require("./composables/useMarkerPositions");
154
- var _useMultiSelect = require("./composables/useMultiSelect");
155
- var _useOutputFormatter = require("./composables/useOutputFormatter");
156
- var _useSettings = require("./composables/useSettings");
157
- var _useTextSelection = require("./composables/useTextSelection");
158
- var _useToolbarAutoHide = require("./composables/useToolbarAutoHide");
159
- var _icons = require("./icons");
160
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
161
- module.exports = _AgentationVue.default;
162
- const AgentationVuePlugin = exports.AgentationVuePlugin = {
163
- install(app) {
164
- app.component("AgentationVue", _AgentationVue.default);
165
- app.component("agentation-vue", _AgentationVue.default);
166
- app.directive("va-tooltip", _vaTooltip.vaTooltipDirective);
167
- }
168
- };
package/dist/types.js DELETED
@@ -1 +0,0 @@
1
- "use strict";
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.copyToClipboard = copyToClipboard;
7
- async function copyToClipboard(text) {
8
- try {
9
- await navigator.clipboard.writeText(text);
10
- return true;
11
- } catch {
12
- const textarea = document.createElement("textarea");
13
- textarea.value = text;
14
- textarea.style.position = "fixed";
15
- textarea.style.opacity = "0";
16
- document.body.appendChild(textarea);
17
- textarea.select();
18
- const success = document.execCommand("copy");
19
- document.body.removeChild(textarea);
20
- return success;
21
- }
22
- }
@@ -1,168 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.detectVueComponents = detectVueComponents;
7
- exports.getAccessibilityInfo = getAccessibilityInfo;
8
- exports.getComputedStylesSummary = getComputedStylesSummary;
9
- exports.getNearbyElements = getNearbyElements;
10
- exports.getNearbyText = getNearbyText;
11
- exports.getRelevantComputedStyles = getRelevantComputedStyles;
12
- exports.isFixed = isFixed;
13
- let vueDetectionAvailable = null;
14
- const DEFAULT_STYLE_VALUES = /* @__PURE__ */new Set(["none", "normal", "auto", "0px", "rgba(0, 0, 0, 0)", "transparent", "static", "visible"]);
15
- const TEXT_ELEMENTS = /* @__PURE__ */new Set(["p", "span", "h1", "h2", "h3", "h4", "h5", "h6", "label", "li", "td", "th", "blockquote", "figcaption", "caption", "legend", "dt", "dd", "pre", "code", "em", "strong", "b", "i", "a", "time", "cite", "q"]);
16
- const FORM_INPUT_ELEMENTS = /* @__PURE__ */new Set(["input", "textarea", "select"]);
17
- const MEDIA_ELEMENTS = /* @__PURE__ */new Set(["img", "video", "canvas", "svg"]);
18
- const CONTAINER_ELEMENTS = /* @__PURE__ */new Set(["div", "section", "article", "nav", "header", "footer", "aside", "main", "ul", "ol", "form", "fieldset"]);
19
- function getComponentFromElement(el) {
20
- const v2 = el.__vue__;
21
- if (v2) return v2;
22
- const v3 = el.__vueParentComponent;
23
- if (v3) return v3;
24
- let current = el.parentElement;
25
- while (current && current !== document.body) {
26
- const v2p = current.__vue__;
27
- if (v2p) return v2p;
28
- const v3p = current.__vueParentComponent;
29
- if (v3p) return v3p;
30
- current = current.parentElement;
31
- }
32
- return null;
33
- }
34
- function inferNameFromFile(filePath) {
35
- const file = filePath.split("/").pop();
36
- if (!file) return null;
37
- return file.replace(/\.vue$/, "");
38
- }
39
- function getInstanceName(inst, includeFile) {
40
- if (inst.$options) {
41
- const name = inst.$options.name || inst.$options._componentTag || inferNameFromFile(inst.$options.__file || "");
42
- if (name) {
43
- if (includeFile && inst.$options.__file) {
44
- const file = inst.$options.__file.split("/").pop();
45
- return `${name} (${file})`;
46
- }
47
- return name;
48
- }
49
- }
50
- if (inst.type) {
51
- const name = inst.type.name || inst.type.__name || inferNameFromFile(inst.type.__file || "");
52
- if (!name) return null;
53
- if (includeFile && inst.type.__file) {
54
- const file = inst.type.__file.split("/").pop();
55
- return `${name} (${file})`;
56
- }
57
- return name;
58
- }
59
- return null;
60
- }
61
- function walkComponentChain(inst, includeFile) {
62
- const chain = [];
63
- let current = inst;
64
- let depth = 0;
65
- while (current && depth < 20) {
66
- const name = getInstanceName(current, includeFile);
67
- if (name && !name.startsWith("_") && !/^App(?:\s*\(|$)/.test(name)) chain.push(name);
68
- current = current.$parent || current.parent;
69
- depth++;
70
- }
71
- return chain.reverse();
72
- }
73
- function detectVueComponents(el, includeFile = false) {
74
- if (vueDetectionAvailable === false) return void 0;
75
- const inst = getComponentFromElement(el);
76
- if (inst) {
77
- vueDetectionAvailable = true;
78
- const chain = walkComponentChain(inst, includeFile);
79
- return chain.length > 0 ? chain.join(" > ") : void 0;
80
- }
81
- if (vueDetectionAvailable === null) {
82
- vueDetectionAvailable = false;
83
- return void 0;
84
- }
85
- return void 0;
86
- }
87
- function isFixed(el) {
88
- let current = el;
89
- while (current && current !== document.body) {
90
- const position = getComputedStyle(current).position;
91
- if (position === "fixed" || position === "sticky") return true;
92
- current = current.parentElement;
93
- }
94
- return false;
95
- }
96
- function getNearbyElements(el, maxCount = 3) {
97
- const nearby = [];
98
- const parent = el.parentElement;
99
- if (!parent) return "";
100
- for (const sibling of Array.from(parent.children)) {
101
- if (sibling === el) continue;
102
- const tag = sibling.tagName.toLowerCase();
103
- const cls = Array.from(sibling.classList).filter(c => !c.startsWith("__va-")).slice(0, 2).join(".");
104
- const name = cls ? `${tag}.${cls}` : tag;
105
- nearby.push(`\`${name}\``);
106
- if (nearby.length >= maxCount) break;
107
- }
108
- return nearby.join(", ");
109
- }
110
- function getNearbyText(el, maxLen = 140) {
111
- const ownText = (el.textContent || "").replace(/\s+/g, " ").trim();
112
- if (ownText.length >= 2) {
113
- return ownText.length > maxLen ? `${ownText.slice(0, maxLen)}...` : ownText;
114
- }
115
- const parentText = (el.parentElement?.textContent || "").replace(/\s+/g, " ").trim();
116
- if (parentText.length >= 2) {
117
- return parentText.length > maxLen ? `${parentText.slice(0, maxLen)}...` : parentText;
118
- }
119
- return void 0;
120
- }
121
- function getRelevantComputedStyles(el) {
122
- const style = getComputedStyle(el);
123
- const tag = el.tagName.toLowerCase();
124
- const result = {};
125
- let properties;
126
- if (TEXT_ELEMENTS.has(tag)) {
127
- properties = ["color", "font-size", "font-weight", "font-family", "line-height"];
128
- } else if (tag === "button" || tag === "a" && el.getAttribute("role") === "button") {
129
- properties = ["background-color", "color", "padding", "border-radius", "font-size"];
130
- } else if (FORM_INPUT_ELEMENTS.has(tag)) {
131
- properties = ["background-color", "color", "padding", "border-radius", "font-size"];
132
- } else if (MEDIA_ELEMENTS.has(tag)) {
133
- properties = ["width", "height", "object-fit", "border-radius", "background"];
134
- } else if (CONTAINER_ELEMENTS.has(tag)) {
135
- properties = ["display", "gap", "padding", "margin", "background-color", "border-radius"];
136
- } else {
137
- properties = ["color", "font-size", "margin", "padding", "background-color"];
138
- }
139
- for (const prop of properties) {
140
- const value = style.getPropertyValue(prop).trim();
141
- if (value && !DEFAULT_STYLE_VALUES.has(value)) result[prop] = value;
142
- }
143
- return result;
144
- }
145
- function getComputedStylesSummary(el) {
146
- const style = getComputedStyle(el);
147
- const props = ["display", "padding", "margin", "background-color", "color", "border-radius", "font-size", "font-weight", "width", "height", "position", "z-index", "opacity", "transition", "transform"];
148
- return props.map(p => `${p}: ${style.getPropertyValue(p)}`).filter(line => {
149
- const [prop, val] = line.split(": ");
150
- if (!val) return false;
151
- if (DEFAULT_STYLE_VALUES.has(val)) return false;
152
- if (["1", "400"].includes(val)) return false;
153
- if (prop === "display" && val === "block") return false;
154
- if (prop === "display" && val === "inline") return false;
155
- return true;
156
- }).join("\n");
157
- }
158
- function getAccessibilityInfo(el) {
159
- const parts = [];
160
- const role = el.getAttribute("role");
161
- if (role) parts.push(`role="${role}"`);
162
- for (const attr of Array.from(el.attributes)) {
163
- if (attr.name.startsWith("aria-")) {
164
- parts.push(`${attr.name}="${attr.value}"`);
165
- }
166
- }
167
- return parts.length > 0 ? parts.join(", ") : void 0;
168
- }
@@ -1,9 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.clamp = clamp;
7
- function clamp(value, min, max) {
8
- return Math.min(Math.max(value, min), max);
9
- }
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.createPortalContainer = createPortalContainer;
7
- exports.destroyPortalContainer = destroyPortalContainer;
8
- var _constants = require("../constants");
9
- function createPortalContainer() {
10
- const container = document.createElement("div");
11
- container.id = "__va-portal";
12
- container.setAttribute(_constants.VA_DATA_ATTR, "");
13
- document.body.appendChild(container);
14
- return container;
15
- }
16
- function destroyPortalContainer(el) {
17
- el.remove();
18
- }
@@ -1,103 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.generateSelector = generateSelector;
7
- exports.getElementName = getElementName;
8
- exports.getElementPath = getElementPath;
9
- const HASH_CLASS_PATTERNS = [/^[a-z]+-[a-zA-Z0-9]{5,}$/, /^css-[a-z0-9]+$/, /^_[a-z0-9]{6,}$/i, /^__/, /^svelte-/, /^emotion-/];
10
- function isHashClass(cls) {
11
- return HASH_CLASS_PATTERNS.some(p => p.test(cls));
12
- }
13
- function getMeaningfulClasses(el) {
14
- return Array.from(el.classList).filter(c => !isHashClass(c) && !c.startsWith("__va-"));
15
- }
16
- function bubbleSvg(el) {
17
- if (el instanceof SVGElement && !(el instanceof SVGSVGElement)) {
18
- const svg = el.closest("svg");
19
- if (svg) return svg;
20
- }
21
- return el;
22
- }
23
- function generateSelector(el) {
24
- el = bubbleSvg(el);
25
- if (el.id && document.querySelectorAll(`#${CSS.escape(el.id)}`).length === 1) {
26
- return `#${el.id}`;
27
- }
28
- const tag = el.tagName.toLowerCase();
29
- const classes = getMeaningfulClasses(el);
30
- if (classes.length > 0) {
31
- const selector = `${tag}.${classes.join(".")}`;
32
- if (document.querySelectorAll(selector).length === 1) {
33
- return selector;
34
- }
35
- const parent2 = el.parentElement;
36
- if (parent2) {
37
- const parentTag = parent2.tagName.toLowerCase();
38
- const parentClasses = getMeaningfulClasses(parent2);
39
- let parentSelector = parentTag;
40
- if (parentClasses.length > 0) {
41
- parentSelector = `${parentTag}.${parentClasses[0]}`;
42
- }
43
- const full = `${parentSelector} > ${selector}`;
44
- if (document.querySelectorAll(full).length === 1) {
45
- return full;
46
- }
47
- }
48
- }
49
- const parent = el.parentElement;
50
- if (parent) {
51
- const siblings = Array.from(parent.children);
52
- const index = siblings.indexOf(el) + 1;
53
- const parentSelector = parent === document.body ? "body" : generateSelector(parent);
54
- return `${parentSelector} > ${tag}:nth-child(${index})`;
55
- }
56
- return tag;
57
- }
58
- function getElementName(el) {
59
- el = bubbleSvg(el);
60
- const tag = el.tagName.toLowerCase();
61
- const textTags = ["button", "a", "h1", "h2", "h3", "h4", "h5", "h6", "label", "span", "p"];
62
- if (textTags.includes(tag)) {
63
- const text = (el.textContent || "").trim();
64
- if (text.length > 0) {
65
- const truncated = text.length > 30 ? `${text.slice(0, 30)}...` : text;
66
- return `"${truncated}" ${tag}`;
67
- }
68
- }
69
- if (tag === "img") {
70
- const alt = el.getAttribute("alt");
71
- if (alt) return `img[alt="${alt}"]`;
72
- }
73
- if (tag === "input") {
74
- const placeholder = el.getAttribute("placeholder");
75
- if (placeholder) return `input[placeholder="${placeholder}"]`;
76
- const type = el.getAttribute("type") || "text";
77
- return `input[type="${type}"]`;
78
- }
79
- const classes = getMeaningfulClasses(el);
80
- if (classes.length > 0) {
81
- return `${tag}.${classes.join(".")}`;
82
- }
83
- return `<${tag}>`;
84
- }
85
- function getElementPath(el) {
86
- el = bubbleSvg(el);
87
- const parts = [];
88
- let current = el;
89
- while (current && current !== document.documentElement) {
90
- const tag = current.tagName.toLowerCase();
91
- const classes = getMeaningfulClasses(current);
92
- if (current.id) {
93
- parts.unshift(`${tag}#${current.id}`);
94
- break;
95
- } else if (classes.length > 0) {
96
- parts.unshift(`${tag}.${classes.join(".")}`);
97
- } else {
98
- parts.unshift(tag);
99
- }
100
- current = current.parentElement;
101
- }
102
- return parts.join(" > ");
103
- }
@@ -1,14 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.boundingBoxToStyle = boundingBoxToStyle;
7
- function boundingBoxToStyle(rect) {
8
- return {
9
- left: `${rect.x}px`,
10
- top: `${rect.y}px`,
11
- width: `${rect.width}px`,
12
- height: `${rect.height}px`
13
- };
14
- }