mx-cloud 0.0.10 → 0.0.11

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.
Files changed (2) hide show
  1. package/build/interpret.js +40 -3
  2. package/package.json +1 -1
@@ -695,10 +695,47 @@ class Interpreter extends events_1.EventEmitter {
695
695
  }
696
696
  let retryCount = 0;
697
697
  let paginationSuccess = false;
698
- // Capture basic content signature before click
698
+ // Capture basic content signature before click - with XPath support
699
699
  const captureContentSignature = () => __awaiter(this, void 0, void 0, function* () {
700
- return yield page.evaluate((selector) => {
701
- const items = document.querySelectorAll(selector);
700
+ return yield page.evaluate((listSelector) => {
701
+ const isXPath = (selector) => {
702
+ return selector.startsWith('//') || selector.startsWith('./') || selector.includes('::');
703
+ };
704
+ let items = [];
705
+ if (isXPath(listSelector)) {
706
+ try {
707
+ // Use XPath to find elements
708
+ const xpathResult = document.evaluate(listSelector, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
709
+ items = [];
710
+ for (let i = 0; i < xpathResult.snapshotLength; i++) {
711
+ const node = xpathResult.snapshotItem(i);
712
+ if (node && node.nodeType === Node.ELEMENT_NODE) {
713
+ items.push(node);
714
+ }
715
+ }
716
+ }
717
+ catch (xpathError) {
718
+ console.warn('XPath evaluation failed, trying CSS selector as fallback:', xpathError);
719
+ // Fallback to CSS selector
720
+ try {
721
+ items = document.querySelectorAll(listSelector);
722
+ }
723
+ catch (cssError) {
724
+ console.warn('CSS selector fallback also failed:', cssError);
725
+ items = [];
726
+ }
727
+ }
728
+ }
729
+ else {
730
+ try {
731
+ // Use CSS selector
732
+ items = document.querySelectorAll(listSelector);
733
+ }
734
+ catch (cssError) {
735
+ console.warn('CSS selector failed:', cssError);
736
+ items = [];
737
+ }
738
+ }
702
739
  return {
703
740
  url: window.location.href,
704
741
  itemCount: items.length,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mx-cloud",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "mx cloud",
5
5
  "main": "build/index.js",
6
6
  "typings": "build/index.d.ts",