@asiyst/sdk 0.1.3 → 0.1.6

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/README.md CHANGED
@@ -13,7 +13,7 @@ npm install @asiyst/sdk
13
13
  Then connect the project:
14
14
 
15
15
  ```bash
16
- npx asiyst init
16
+ npx @asiyst/cli init
17
17
  ```
18
18
 
19
19
  `asiyst init` opens [https://asiyst.com](https://asiyst.com) so you can create a project and copy credentials. Avatar appearance and behavior live in Asiyst Cloud so you can change them without redeploying the site.
package/dist/index.cjs CHANGED
@@ -68,7 +68,7 @@ var ALL_ACTION_KINDS = [
68
68
  ];
69
69
 
70
70
  // src/core/constants.ts
71
- var SDK_VERSION = "0.1.0";
71
+ var SDK_VERSION = "0.1.5";
72
72
  var DEFAULT_API_BASE_URL = "https://asiyst.com/api/v1";
73
73
  var CONFIG_SCHEMA_VERSION = 1;
74
74
  var HOST_ELEMENT_ID = "asiyst-host";
@@ -982,7 +982,17 @@ var TargetResolver = class {
982
982
  if (!best || bestScore < 2) {
983
983
  return null;
984
984
  }
985
- return findElementByAsiystId(this.doc, best.id) ?? this.doc.querySelector(`[id="${best.id.replace(/^dom:/, "")}"]`);
985
+ return findElementByAsiystId(this.doc, best.id) ?? this.doc.querySelector(`[id="${best.id.replace(/^dom:/, "")}"]`) ?? this.findMappedElement(best);
986
+ }
987
+ findMappedElement(mapped) {
988
+ const candidates = Array.from(this.doc.querySelectorAll("a[href], button, input, select, textarea, form, nav, h1, h2, h3, [role]"));
989
+ return candidates.find((element) => {
990
+ if (!isElementVisible(element) || isDisabled(element)) return false;
991
+ const text = normalize(`${element.getAttribute("aria-label") ?? ""} ${element.textContent ?? ""}`);
992
+ const wanted = normalize(`${mapped.label} ${mapped.text}`);
993
+ const role = normalize(element.getAttribute("role") ?? "");
994
+ return wanted.length > 0 && (text.includes(wanted) || wanted.includes(text)) || mapped.role !== null && role === normalize(mapped.role);
995
+ }) ?? null;
986
996
  }
987
997
  matchesMapped(item, element, ref) {
988
998
  if (ref.id && item.id === ref.id) {