|
792 | 792 | } |
793 | 793 | }); |
794 | 794 | } catch (error) {} |
795 | | - const processed = await function(rawData, options) { |
| 795 | + let processed = null; |
| 796 | + try { |
| 797 | + processed = await function(rawData, options) { |
796 | 798 | return new Promise((resolve, reject) => { |
797 | 799 | const requestId = Math.random().toString(36).substring(7); |
798 | 800 | let resolved = !1; |
|
823 | 825 | } |
824 | 826 | }); |
825 | 827 | }(allRawElements, options); |
826 | | - if (!processed || !processed.elements) throw new Error("WASM processing returned invalid result"); |
| 828 | + } catch (error) { |
| 829 | + processed = { |
| 830 | + elements: (allRawElements || []).map(r => { |
| 831 | + const rect = r && r.rect || { |
| 832 | + x: 0, |
| 833 | + y: 0, |
| 834 | + width: 0, |
| 835 | + height: 0 |
| 836 | + }, attrs = r && r.attributes || {}, role = attrs.role || r && (r.inferred_role || r.inferredRole) || ("a" === r.tag ? "link" : "generic"); |
| 837 | + return { |
| 838 | + id: Number(r && r.id || 0), |
| 839 | + role: String(role || "generic"), |
| 840 | + text: r && (r.text || r.semantic_text || r.semanticText) || null, |
| 841 | + importance: 1, |
| 842 | + bbox: { |
| 843 | + x: Number(rect.x || 0), |
| 844 | + y: Number(rect.y || 0), |
| 845 | + width: Number(rect.width || 0), |
| 846 | + height: Number(rect.height || 0) |
| 847 | + }, |
| 848 | + visual_cues: { |
| 849 | + is_primary: !1, |
| 850 | + is_clickable: !1 |
| 851 | + }, |
| 852 | + in_viewport: !0, |
| 853 | + is_occluded: !!(r && (r.occluded || r.is_occluded)), |
| 854 | + z_index: 0, |
| 855 | + name: attrs.aria_label || attrs.ariaLabel || null, |
| 856 | + value: r && r.value || null, |
| 857 | + input_type: attrs.type_ || attrs.type || null, |
| 858 | + checked: "boolean" == typeof r.checked ? r.checked : null, |
| 859 | + disabled: "boolean" == typeof r.disabled ? r.disabled : null, |
| 860 | + expanded: "boolean" == typeof r.expanded ? r.expanded : null |
| 861 | + }; |
| 862 | + }), |
| 863 | + raw_elements: allRawElements, |
| 864 | + duration: null |
| 865 | + }; |
| 866 | + } |
| 867 | + if (!processed || !processed.elements) processed = { |
| 868 | + elements: (allRawElements || []).map(r => { |
| 869 | + const rect = r && r.rect || { |
| 870 | + x: 0, |
| 871 | + y: 0, |
| 872 | + width: 0, |
| 873 | + height: 0 |
| 874 | + }, attrs = r && r.attributes || {}, role = attrs.role || r && (r.inferred_role || r.inferredRole) || ("a" === r.tag ? "link" : "generic"); |
| 875 | + return { |
| 876 | + id: Number(r && r.id || 0), |
| 877 | + role: String(role || "generic"), |
| 878 | + text: r && (r.text || r.semantic_text || r.semanticText) || null, |
| 879 | + importance: 1, |
| 880 | + bbox: { |
| 881 | + x: Number(rect.x || 0), |
| 882 | + y: Number(rect.y || 0), |
| 883 | + width: Number(rect.width || 0), |
| 884 | + height: Number(rect.height || 0) |
| 885 | + }, |
| 886 | + visual_cues: { |
| 887 | + is_primary: !1, |
| 888 | + is_clickable: !1 |
| 889 | + }, |
| 890 | + in_viewport: !0, |
| 891 | + is_occluded: !!(r && (r.occluded || r.is_occluded)), |
| 892 | + z_index: 0, |
| 893 | + name: attrs.aria_label || attrs.ariaLabel || null, |
| 894 | + value: r && r.value || null, |
| 895 | + input_type: attrs.type_ || attrs.type || null, |
| 896 | + checked: "boolean" == typeof r.checked ? r.checked : null, |
| 897 | + disabled: "boolean" == typeof r.disabled ? r.disabled : null, |
| 898 | + expanded: "boolean" == typeof r.expanded ? r.expanded : null |
| 899 | + }; |
| 900 | + }), |
| 901 | + raw_elements: allRawElements, |
| 902 | + duration: null |
| 903 | + }; |
827 | 904 | let screenshot = null; |
828 | 905 | options.screenshot && (screenshot = await function(options) { |
829 | 906 | return new Promise(resolve => { |
|
0 commit comments