@modelnex/sdk 0.5.15 → 0.5.16
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 +570 -565
- package/dist/index.mjs +570 -565
- package/package.json +11 -12
- package/dist/aom-GA6W42DG.mjs +0 -71
- package/dist/aom-J6NYMGDW.mjs +0 -69
- package/dist/chunk-6DZX6EAA.mjs +0 -37
- package/dist/dom-sync-Y7Z7TOU6.mjs +0 -57
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@modelnex/sdk",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.16",
|
|
4
4
|
"description": "React SDK for natural language control of web apps via AI agents",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -20,15 +20,6 @@
|
|
|
20
20
|
"dist",
|
|
21
21
|
"README.md"
|
|
22
22
|
],
|
|
23
|
-
"scripts": {
|
|
24
|
-
"prepublishOnly": "npm run build",
|
|
25
|
-
"build": "npm exec -- tsup src/index.ts --format cjs,esm --dts",
|
|
26
|
-
"dev": "npm exec -- tsup src/index.ts --format cjs,esm --watch --dts",
|
|
27
|
-
"lint": "eslint src/",
|
|
28
|
-
"test": "npm run build && node --test tests/*.test.js",
|
|
29
|
-
"test:ci": "npm run test && npm run test:unit",
|
|
30
|
-
"test:unit": "node --import tsx --test tests/*.test.ts"
|
|
31
|
-
},
|
|
32
23
|
"peerDependencies": {
|
|
33
24
|
"react": ">=17.0.0",
|
|
34
25
|
"react-dom": ">=17.0.0",
|
|
@@ -67,5 +58,13 @@
|
|
|
67
58
|
"bugs": {
|
|
68
59
|
"url": "https://github.com/sharunaraksha/modelnex-sdk/issues"
|
|
69
60
|
},
|
|
70
|
-
"homepage": "https://github.com/sharunaraksha/modelnex-sdk#readme"
|
|
71
|
-
|
|
61
|
+
"homepage": "https://github.com/sharunaraksha/modelnex-sdk#readme",
|
|
62
|
+
"scripts": {
|
|
63
|
+
"build": "npm exec -- tsup src/index.ts --format cjs,esm --dts",
|
|
64
|
+
"dev": "npm exec -- tsup src/index.ts --format cjs,esm --watch --dts",
|
|
65
|
+
"lint": "eslint src/",
|
|
66
|
+
"test": "npm run build && node --test tests/*.test.js",
|
|
67
|
+
"test:ci": "npm run test && npm run test:unit",
|
|
68
|
+
"test:unit": "node --import tsx --test tests/*.test.ts"
|
|
69
|
+
}
|
|
70
|
+
}
|
package/dist/aom-GA6W42DG.mjs
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import "./chunk-6DZX6EAA.mjs";
|
|
2
|
-
|
|
3
|
-
// src/utils/aom.ts
|
|
4
|
-
var uidMap = /* @__PURE__ */ new Map();
|
|
5
|
-
var nextUid = 1;
|
|
6
|
-
function generateMinifiedAOM() {
|
|
7
|
-
uidMap.clear();
|
|
8
|
-
nextUid = 1;
|
|
9
|
-
const interactives = document.querySelectorAll(
|
|
10
|
-
'button, a, input, select, textarea, [role="button"], [role="link"], [role="tab"], [role="menuitem"], [role="option"]'
|
|
11
|
-
);
|
|
12
|
-
const nodes = [];
|
|
13
|
-
interactives.forEach((el) => {
|
|
14
|
-
if (!el.offsetParent && (el.offsetWidth === 0 || el.offsetHeight === 0)) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
if (el.closest("#modelnex-studio-root") || el.closest("#modelnex-active-agent-root")) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const uid = `node:${nextUid++}`;
|
|
21
|
-
uidMap.set(uid, el);
|
|
22
|
-
let text = (el.textContent || "").replace(/\s+/g, " ").trim();
|
|
23
|
-
const ariaLabel = el.getAttribute("aria-label");
|
|
24
|
-
const placeholder = el.getAttribute("placeholder");
|
|
25
|
-
let value = void 0;
|
|
26
|
-
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement || el instanceof HTMLSelectElement) {
|
|
27
|
-
value = el.value;
|
|
28
|
-
}
|
|
29
|
-
let role = el.tagName.toLowerCase();
|
|
30
|
-
if (el.hasAttribute("role")) {
|
|
31
|
-
role = el.getAttribute("role");
|
|
32
|
-
} else if (role === "a") {
|
|
33
|
-
role = "link";
|
|
34
|
-
} else if (el instanceof HTMLInputElement) {
|
|
35
|
-
role = el.type ? `input[${el.type}]` : "input";
|
|
36
|
-
}
|
|
37
|
-
const node = { uid, role };
|
|
38
|
-
const displayLabel = ariaLabel || text || placeholder;
|
|
39
|
-
if (displayLabel) {
|
|
40
|
-
node.text = displayLabel.substring(0, 100);
|
|
41
|
-
}
|
|
42
|
-
if (el.getAttribute("name")) {
|
|
43
|
-
node.name = el.getAttribute("name");
|
|
44
|
-
}
|
|
45
|
-
if (value) {
|
|
46
|
-
node.value = value.substring(0, 100);
|
|
47
|
-
}
|
|
48
|
-
if (el instanceof HTMLAnchorElement && el.href) {
|
|
49
|
-
try {
|
|
50
|
-
const url = new URL(el.href);
|
|
51
|
-
node.href = url.pathname + url.search + url.hash;
|
|
52
|
-
} catch {
|
|
53
|
-
node.href = el.getAttribute("href");
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
nodes.push(node);
|
|
57
|
-
});
|
|
58
|
-
return { nodes };
|
|
59
|
-
}
|
|
60
|
-
function getElementByUid(uid) {
|
|
61
|
-
return uidMap.get(uid) || null;
|
|
62
|
-
}
|
|
63
|
-
function clearAOMMap() {
|
|
64
|
-
uidMap.clear();
|
|
65
|
-
nextUid = 1;
|
|
66
|
-
}
|
|
67
|
-
export {
|
|
68
|
-
clearAOMMap,
|
|
69
|
-
generateMinifiedAOM,
|
|
70
|
-
getElementByUid
|
|
71
|
-
};
|
package/dist/aom-J6NYMGDW.mjs
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
// src/utils/aom.ts
|
|
2
|
-
var uidMap = /* @__PURE__ */ new Map();
|
|
3
|
-
var nextUid = 1;
|
|
4
|
-
function generateMinifiedAOM() {
|
|
5
|
-
uidMap.clear();
|
|
6
|
-
nextUid = 1;
|
|
7
|
-
const interactives = document.querySelectorAll(
|
|
8
|
-
'button, a, input, select, textarea, [role="button"], [role="link"], [role="tab"], [role="menuitem"], [role="option"]'
|
|
9
|
-
);
|
|
10
|
-
const nodes = [];
|
|
11
|
-
interactives.forEach((el) => {
|
|
12
|
-
if (!el.offsetParent && (el.offsetWidth === 0 || el.offsetHeight === 0)) {
|
|
13
|
-
return;
|
|
14
|
-
}
|
|
15
|
-
if (el.closest("#modelnex-studio-root") || el.closest("#modelnex-active-agent-root")) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
const uid = `node:${nextUid++}`;
|
|
19
|
-
uidMap.set(uid, el);
|
|
20
|
-
let text = (el.textContent || "").replace(/\s+/g, " ").trim();
|
|
21
|
-
const ariaLabel = el.getAttribute("aria-label");
|
|
22
|
-
const placeholder = el.getAttribute("placeholder");
|
|
23
|
-
let value = void 0;
|
|
24
|
-
if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement || el instanceof HTMLSelectElement) {
|
|
25
|
-
value = el.value;
|
|
26
|
-
}
|
|
27
|
-
let role = el.tagName.toLowerCase();
|
|
28
|
-
if (el.hasAttribute("role")) {
|
|
29
|
-
role = el.getAttribute("role");
|
|
30
|
-
} else if (role === "a") {
|
|
31
|
-
role = "link";
|
|
32
|
-
} else if (el instanceof HTMLInputElement) {
|
|
33
|
-
role = el.type ? `input[${el.type}]` : "input";
|
|
34
|
-
}
|
|
35
|
-
const node = { uid, role };
|
|
36
|
-
const displayLabel = ariaLabel || text || placeholder;
|
|
37
|
-
if (displayLabel) {
|
|
38
|
-
node.text = displayLabel.substring(0, 100);
|
|
39
|
-
}
|
|
40
|
-
if (el.getAttribute("name")) {
|
|
41
|
-
node.name = el.getAttribute("name");
|
|
42
|
-
}
|
|
43
|
-
if (value) {
|
|
44
|
-
node.value = value.substring(0, 100);
|
|
45
|
-
}
|
|
46
|
-
if (el instanceof HTMLAnchorElement && el.href) {
|
|
47
|
-
try {
|
|
48
|
-
const url = new URL(el.href);
|
|
49
|
-
node.href = url.pathname + url.search + url.hash;
|
|
50
|
-
} catch {
|
|
51
|
-
node.href = el.getAttribute("href");
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
nodes.push(node);
|
|
55
|
-
});
|
|
56
|
-
return { nodes };
|
|
57
|
-
}
|
|
58
|
-
function getElementByUid(uid) {
|
|
59
|
-
return uidMap.get(uid) || null;
|
|
60
|
-
}
|
|
61
|
-
function clearAOMMap() {
|
|
62
|
-
uidMap.clear();
|
|
63
|
-
nextUid = 1;
|
|
64
|
-
}
|
|
65
|
-
export {
|
|
66
|
-
clearAOMMap,
|
|
67
|
-
generateMinifiedAOM,
|
|
68
|
-
getElementByUid
|
|
69
|
-
};
|
package/dist/chunk-6DZX6EAA.mjs
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
8
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
9
|
-
}) : x)(function(x) {
|
|
10
|
-
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
11
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
12
|
-
});
|
|
13
|
-
var __commonJS = (cb, mod) => function __require2() {
|
|
14
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
15
|
-
};
|
|
16
|
-
var __copyProps = (to, from, except, desc) => {
|
|
17
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
-
for (let key of __getOwnPropNames(from))
|
|
19
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
-
}
|
|
22
|
-
return to;
|
|
23
|
-
};
|
|
24
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
-
mod
|
|
31
|
-
));
|
|
32
|
-
|
|
33
|
-
export {
|
|
34
|
-
__require,
|
|
35
|
-
__commonJS,
|
|
36
|
-
__toESM
|
|
37
|
-
};
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import "./chunk-6DZX6EAA.mjs";
|
|
2
|
-
|
|
3
|
-
// src/utils/dom-sync.ts
|
|
4
|
-
function waitForDomSettle(options = {}) {
|
|
5
|
-
const { timeoutMs = 5e3, debounceMs = 400, minWaitMs = 100 } = options;
|
|
6
|
-
return new Promise((resolve) => {
|
|
7
|
-
let debounceTimer = null;
|
|
8
|
-
let resolved = false;
|
|
9
|
-
const maxTimer = setTimeout(() => {
|
|
10
|
-
if (!resolved) {
|
|
11
|
-
resolved = true;
|
|
12
|
-
cleanup();
|
|
13
|
-
console.log("[DOM Sync] Forced resolution by max timeout");
|
|
14
|
-
resolve();
|
|
15
|
-
}
|
|
16
|
-
}, Math.max(timeoutMs, minWaitMs));
|
|
17
|
-
const finish = () => {
|
|
18
|
-
if (!resolved) {
|
|
19
|
-
resolved = true;
|
|
20
|
-
cleanup();
|
|
21
|
-
resolve();
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
const observer = new MutationObserver((mutations) => {
|
|
25
|
-
const hasSignificantMutations = mutations.some((m) => {
|
|
26
|
-
if (m.target instanceof HTMLElement) {
|
|
27
|
-
if (m.target.hasAttribute("data-modelnex-tour-highlight")) return false;
|
|
28
|
-
if (m.target.hasAttribute("data-modelnex-caption")) return false;
|
|
29
|
-
if (m.target.closest("#modelnex-studio-root")) return false;
|
|
30
|
-
if (m.target.closest("#modelnex-active-agent-root")) return false;
|
|
31
|
-
}
|
|
32
|
-
return true;
|
|
33
|
-
});
|
|
34
|
-
if (!hasSignificantMutations) return;
|
|
35
|
-
if (debounceTimer) clearTimeout(debounceTimer);
|
|
36
|
-
debounceTimer = setTimeout(finish, debounceMs);
|
|
37
|
-
});
|
|
38
|
-
const cleanup = () => {
|
|
39
|
-
observer.disconnect();
|
|
40
|
-
if (debounceTimer) clearTimeout(debounceTimer);
|
|
41
|
-
clearTimeout(maxTimer);
|
|
42
|
-
};
|
|
43
|
-
setTimeout(() => {
|
|
44
|
-
if (resolved) return;
|
|
45
|
-
observer.observe(document.body, {
|
|
46
|
-
childList: true,
|
|
47
|
-
subtree: true,
|
|
48
|
-
attributes: true,
|
|
49
|
-
characterData: true
|
|
50
|
-
});
|
|
51
|
-
debounceTimer = setTimeout(finish, debounceMs);
|
|
52
|
-
}, minWaitMs);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
export {
|
|
56
|
-
waitForDomSettle
|
|
57
|
-
};
|