@ziggy-ai/client-sdk 0.8.2 → 0.8.3

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
@@ -1541,7 +1541,10 @@ var UIActionExecutor = class {
1541
1541
  */
1542
1542
  highlight(selector, style, duration) {
1543
1543
  const el = document.querySelector(selector);
1544
- if (!el) return false;
1544
+ if (!el) {
1545
+ this.config.onActionFailure?.("highlight", selector, "Element not found");
1546
+ return false;
1547
+ }
1545
1548
  el.scrollIntoView({ behavior: "smooth", block: "center" });
1546
1549
  const prefix = this.config.highlightPrefix || "ziggy-highlight";
1547
1550
  const className = `${prefix}-${style || "pulse"}`;
@@ -1560,7 +1563,10 @@ var UIActionExecutor = class {
1560
1563
  */
1561
1564
  scrollTo(selector, position) {
1562
1565
  const el = document.querySelector(selector);
1563
- if (!el) return false;
1566
+ if (!el) {
1567
+ this.config.onActionFailure?.("scroll", selector, "Element not found");
1568
+ return false;
1569
+ }
1564
1570
  el.scrollIntoView({
1565
1571
  behavior: "smooth",
1566
1572
  block: position || "center"
@@ -1572,7 +1578,10 @@ var UIActionExecutor = class {
1572
1578
  */
1573
1579
  click(selector) {
1574
1580
  const el = document.querySelector(selector);
1575
- if (!el) return false;
1581
+ if (!el) {
1582
+ this.config.onActionFailure?.("click", selector, "Element not found");
1583
+ return false;
1584
+ }
1576
1585
  const prefix = this.config.highlightPrefix || "ziggy-highlight";
1577
1586
  el.classList.add(`${prefix}-pulse`);
1578
1587
  const timeout = setTimeout(() => {
@@ -1589,7 +1598,10 @@ var UIActionExecutor = class {
1589
1598
  */
1590
1599
  typeInto(selector, text) {
1591
1600
  const el = document.querySelector(selector);
1592
- if (!el) return false;
1601
+ if (!el) {
1602
+ this.config.onActionFailure?.("type", selector, "Element not found");
1603
+ return false;
1604
+ }
1593
1605
  el.focus();
1594
1606
  const prefix = this.config.highlightPrefix || "ziggy-highlight";
1595
1607
  el.classList.add(`${prefix}-outline`);
@@ -1623,29 +1635,41 @@ var UIActionExecutor = class {
1623
1635
  */
1624
1636
  async walkthrough(steps, title) {
1625
1637
  if (this.config.onWalkthrough) {
1626
- await this.config.onWalkthrough(steps, title);
1638
+ try {
1639
+ await this.config.onWalkthrough(steps, title);
1640
+ } finally {
1641
+ this.config.onWalkthroughComplete?.();
1642
+ }
1627
1643
  return;
1628
1644
  }
1629
1645
  try {
1630
1646
  const { driver } = await import("driver.js");
1631
1647
  await import("driver.js/dist/driver.css");
1632
- const d = driver({
1633
- showProgress: true,
1634
- animate: true,
1635
- overlayOpacity: 0.4,
1636
- popoverClass: "ziggy-walkthrough",
1637
- steps: steps.map((s) => ({
1638
- element: s.element,
1639
- popover: {
1640
- title: s.title,
1641
- description: s.description,
1642
- side: s.side || "bottom"
1648
+ await new Promise((resolve) => {
1649
+ const d = driver({
1650
+ showProgress: true,
1651
+ animate: true,
1652
+ overlayOpacity: 0.4,
1653
+ popoverClass: "ziggy-walkthrough",
1654
+ steps: steps.map((s) => ({
1655
+ element: s.element,
1656
+ popover: {
1657
+ title: s.title,
1658
+ description: s.description,
1659
+ side: s.side || "bottom"
1660
+ }
1661
+ })),
1662
+ onDestroyStarted: () => {
1663
+ d.destroy();
1664
+ resolve();
1643
1665
  }
1644
- }))
1666
+ });
1667
+ d.drive();
1645
1668
  });
1646
- d.drive();
1669
+ this.config.onWalkthroughComplete?.();
1647
1670
  } catch (err) {
1648
1671
  console.error("Failed to start walkthrough:", err);
1672
+ this.config.onActionFailure?.("walkthrough", void 0, String(err));
1649
1673
  }
1650
1674
  }
1651
1675
  /**
@@ -33,6 +33,10 @@ export interface UIActionExecutorConfig {
33
33
  } | void>;
34
34
  /** Highlight CSS class prefix (default: 'ziggy-highlight') */
35
35
  highlightPrefix?: string;
36
+ /** Called when a walkthrough completes (all steps finished or user dismissed) */
37
+ onWalkthroughComplete?: () => void;
38
+ /** Called when a UI action fails (element not found, etc.) */
39
+ onActionFailure?: (actionType: string, selector?: string, error?: string) => void;
36
40
  }
37
41
  export declare class UIActionExecutor {
38
42
  private config;
@@ -1 +1 @@
1
- {"version":3,"file":"ui-actions.d.ts","sourceRoot":"","sources":["../src/ui-actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EAChB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,sBAAsB;IACrC,sEAAsE;IACtE,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,iEAAiE;IACjE,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACnF,sFAAsF;IACtF,mBAAmB,CAAC,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC;QAAE,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IACrG,8DAA8D;IAC9D,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,gBAAgB,CAAsD;IAC9E,OAAO,CAAC,cAAc,CAA4C;gBAEtD,MAAM,CAAC,EAAE,sBAAsB;IAI3C;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO;IAwBpC;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO;IAqBvE;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO;IAWtD;;OAEG;IACH,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,O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nF;AAED,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,gBAAgB,CAAsD;IAC9E,OAAO,CAAC,cAAc,CAA4C;gBAEtD,MAAM,CAAC,EAAE,sBAAsB;IAI3C;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO;IAwBpC;;;OAGG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO;IAwBvE;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO;IActD;;OAEG;IACH,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAoBhC;;;OAGG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO;IA+BjD;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAS5B;;;OAGG;IACG,WAAW,CAAC,KAAK,EAAE,eAAe,EAAE,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IA8C1E;;;OAGG;YACW,iBAAiB;IAM/B;;OAEG;IACH,OAAO,IAAI,IAAI;CAWhB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ziggy-ai/client-sdk",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "description": "Client SDK for integrating with Ziggy's v1 API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",