also looking at this
fix(ios): no gated dispatcher arm can hang the page any more (58 → 0)
#120
1 file
+298
-106
Review threads live on the whole diff, not on one commit, so none are shown here - a thread's line means something in the branch's final form, and painting it into an intermediate step would put it on code it is not about.
| @@ -568,6 +568,8 @@ struct CraftWebView: UIViewRepresentable { | ||
| 568 | 568 | if config.enableHaptics { |
| 569 | 569 | let style = body["style"] as? String ?? "medium" |
| 570 | 570 | triggerHaptic(style: style) |
| 571 | } else { | |
| 572 | rejectCallback(callbackId, error: "Haptics is disabled", code: "CAPABILITY_DISABLED") | |
| 571 | 573 | } |
| 572 | 574 | case "share": |
| 573 | 575 | if config.enableShare { |
| @@ -585,20 +587,28 @@ struct CraftWebView: UIViewRepresentable { | ||
| 585 | 587 | if config.enableCamera { |
| 586 | 588 | pendingCallbackId = callbackId |
| 587 | 589 | openCamera() |
| 590 | } else { | |
| 591 | rejectCallback(callbackId, error: "Camera is disabled", code: "CAPABILITY_DISABLED") | |
| 588 | 592 | } |
| 589 | 593 | case "pickImage": |
| 590 | 594 | if config.enableCamera { |
| 591 | 595 | pendingCallbackId = callbackId |
| 592 | 596 | pickImage() |
| 597 | } else { | |
| 598 | rejectCallback(callbackId, error: "Camera is disabled", code: "CAPABILITY_DISABLED") | |
| 593 | 599 | } |
| 594 | 600 | case "authenticate": |
| 595 | 601 | if config.enableBiometric { |
| 596 | 602 | let reason = body["reason"] as? String ?? "Authenticate to continue" |
| 597 | 603 | authenticate(reason: reason, callbackId: callbackId) |
| 604 | } else { | |
| 605 | rejectCallback(callbackId, error: "Biometric authentication is disabled", code: "CAPABILITY_DISABLED") | |
| 598 | 606 | } |
| 599 | 607 | case "registerPush": |
| 600 | 608 | if config.enablePushNotifications { |
| 601 | 609 | registerPushNotifications(callbackId: callbackId) |
| 610 | } else { | |
| 611 | rejectCallback(callbackId, error: "Push notifications are disabled", code: "CAPABILITY_DISABLED") | |
| 602 | 612 | } |
| 603 | 613 | case "secureSet": |
| 604 | 614 | if config.enableSecureStorage, |
| @@ -688,6 +698,8 @@ struct CraftWebView: UIViewRepresentable { | ||
| 688 | 698 | if config.enableClipboard { |
| 689 | 699 | let text = UIPasteboard.general.string ?? "" |
| 690 | 700 | resolveCallback(callbackId, result: text) |
| 701 | } else { | |
| 702 | rejectCallback(callbackId, error: "Clipboard is disabled", code: "CAPABILITY_DISABLED") | |
| 691 | 703 | } |
| 692 | 704 | // Device Info |
| 693 | 705 | case "getDeviceInfo": |
| @@ -735,6 +747,8 @@ struct CraftWebView: UIViewRepresentable { | ||
| 735 | 747 | case "getContacts": |
| 736 | 748 | if config.enableContacts { |
| 737 | 749 | getContacts(callbackId: callbackId) |
| 750 | } else { | |
| 751 | rejectCallback(callbackId, error: "Contacts access is disabled", code: "CAPABILITY_DISABLED") | |
| 738 | 752 | } |
| 739 | 753 | case "addContact": |
| 740 | 754 | if config.enableContacts, |
| @@ -748,6 +762,8 @@ struct CraftWebView: UIViewRepresentable { | ||
| 748 | 762 | let startDate = body["startDate"] as? Double |
| 749 | 763 | let endDate = body["endDate"] as? Double |
| 750 | 764 | getCalendarEvents(startDate: startDate, endDate: endDate, callbackId: callbackId) |
| 765 | } else { | |
| 766 | rejectCallback(callbackId, error: "Calendar access is disabled", code: "CAPABILITY_DISABLED") | |
| 751 | 767 | } |
| 752 | 768 | case "createCalendarEvent": |
| 753 | 769 | if config.enableCalendar, |
| @@ -774,10 +790,14 @@ struct CraftWebView: UIViewRepresentable { | ||
| 774 | 790 | case "cancelAllNotifications": |
| 775 | 791 | if config.enableLocalNotifications { |
| 776 | 792 | cancelAllLocalNotifications(callbackId: callbackId) |
| 793 | } else { | |
| 794 | rejectCallback(callbackId, error: "Local notifications are disabled", code: "CAPABILITY_DISABLED") | |
| 777 | 795 | } |
| 778 | 796 | case "getPendingNotifications": |
| 779 | 797 | if config.enableLocalNotifications { |
| 780 | 798 | getPendingNotifications(callbackId: callbackId) |
| 799 | } else { | |
| 800 | rejectCallback(callbackId, error: "Local notifications are disabled", code: "CAPABILITY_DISABLED") | |
| 781 | 801 | } |
| 782 | 802 | |
| 783 | 803 | // MARK: - Deep Links |
| @@ -785,6 +805,8 @@ struct CraftWebView: UIViewRepresentable { | ||
| 785 | 805 | if config.enableDeepLinks { |
| 786 | 806 | // Handler is registered in JS |
| 787 | 807 | resolveCallback(callbackId, result: true) |
| 808 | } else { | |
| 809 | rejectCallback(callbackId, error: "Deep links are disabled", code: "CAPABILITY_DISABLED") | |
| 788 | 810 | } |
| 789 | 811 | case "getInitialURL": |
| 790 | 812 | if config.enableDeepLinks { |
| @@ -799,6 +821,8 @@ struct CraftWebView: UIViewRepresentable { | ||
| 799 | 821 | } else { |
| 800 | 822 | resolveCallback(callbackId, result: NSNull()) |
| 801 | 823 | } |
| 824 | } else { | |
| 825 | rejectCallback(callbackId, error: "Deep links are disabled", code: "CAPABILITY_DISABLED") | |
| 802 | 826 | } |
| 803 | 827 | |
| 804 | 828 | // MARK: - In-App Purchase |
| @@ -815,6 +839,8 @@ struct CraftWebView: UIViewRepresentable { | ||
| 815 | 839 | case "restorePurchases": |
| 816 | 840 | if config.enableInAppPurchase { |
| 817 | 841 | restorePurchases(callbackId: callbackId) |
| 842 | } else { | |
| 843 | rejectCallback(callbackId, error: "In-app purchase is disabled", code: "CAPABILITY_DISABLED") | |
| 818 | 844 | } |
| 819 | 845 | |
| 820 | 846 | // MARK: - Keep Awake |
| @@ -833,12 +859,16 @@ struct CraftWebView: UIViewRepresentable { | ||
| 833 | 859 | case "unlockOrientation": |
| 834 | 860 | if config.enableOrientationLock { |
| 835 | 861 | unlockOrientation(callbackId: callbackId) |
| 862 | } else { | |
| 863 | rejectCallback(callbackId, error: "Orientation lock is disabled", code: "CAPABILITY_DISABLED") | |
| 836 | 864 | } |
| 837 | 865 | |
| 838 | 866 | // MARK: - QR/Barcode Scanner |
| 839 | 867 | case "scanQRCode": |
| 840 | 868 | if config.enableQRScanner { |
| 841 | 869 | scanQRCode(callbackId: callbackId) |
| 870 | } else { | |
| 871 | rejectCallback(callbackId, error: "QR scanning is disabled", code: "CAPABILITY_DISABLED") | |
| 842 | 872 | } |
| 843 | 873 | |
| 844 | 874 | // MARK: - File Picker |
| @@ -846,6 +876,8 @@ struct CraftWebView: UIViewRepresentable { | ||
| 846 | 876 | if config.enableFilePicker { |
| 847 | 877 | let types = body["types"] as? [String] |
| 848 | 878 | pickFile(types: types, callbackId: callbackId) |
| 879 | } else { | |
| 880 | rejectCallback(callbackId, error: "File picker is disabled", code: "CAPABILITY_DISABLED") | |
| 849 | 881 | } |
| 850 | 882 | |
| 851 | 883 | // MARK: - File Download |
| @@ -866,22 +898,30 @@ struct CraftWebView: UIViewRepresentable { | ||
| 866 | 898 | case "signInWithApple": |
| 867 | 899 | if config.enableSocialAuth { |
| 868 | 900 | signInWithApple(callbackId: callbackId) |
| 901 | } else { | |
| 902 | rejectCallback(callbackId, error: "Social sign-in is disabled", code: "CAPABILITY_DISABLED") | |
| 869 | 903 | } |
| 870 | 904 | |
| 871 | 905 | // MARK: - Audio Recording |
| 872 | 906 | case "startAudioRecording": |
| 873 | 907 | if config.enableAudioRecording { |
| 874 | 908 | startAudioRecording(callbackId: callbackId) |
| 909 | } else { | |
| 910 | rejectCallback(callbackId, error: "Audio recording is disabled", code: "CAPABILITY_DISABLED") | |
| 875 | 911 | } |
| 876 | 912 | case "stopAudioRecording": |
| 877 | 913 | if config.enableAudioRecording { |
| 878 | 914 | stopAudioRecording(callbackId: callbackId) |
| 915 | } else { | |
| 916 | rejectCallback(callbackId, error: "Audio recording is disabled", code: "CAPABILITY_DISABLED") | |
| 879 | 917 | } |
| 880 | 918 | |
| 881 | 919 | // MARK: - Video Recording |
| 882 | 920 | case "startVideoRecording": |
| 883 | 921 | if config.enableVideoRecording { |
| 884 | 922 | startVideoRecording(callbackId: callbackId) |
| 923 | } else { | |
| 924 | rejectCallback(callbackId, error: "Video recording is disabled", code: "CAPABILITY_DISABLED") | |
| 885 | 925 | } |
| 886 | 926 | |
| 887 | 927 | // MARK: - Motion Sensors |
| @@ -889,6 +929,8 @@ struct CraftWebView: UIViewRepresentable { | ||
| 889 | 929 | if config.enableMotionSensors { |
| 890 | 930 | let interval = body["interval"] as? Double ?? 100 |
| 891 | 931 | startMotionUpdates(interval: interval, callbackId: callbackId) |
| 932 | } else { | |
| 933 | rejectCallback(callbackId, error: "Motion sensors are disabled", code: "CAPABILITY_DISABLED") | |
| 892 | 934 | } |
| 893 | 935 | case "stopMotionUpdates": |
| 894 | 936 | stopMotionUpdates() |
| @@ -912,6 +954,8 @@ struct CraftWebView: UIViewRepresentable { | ||
| 912 | 954 | case "startBluetoothScan": |
| 913 | 955 | if config.enableBluetooth { |
| 914 | 956 | startBluetoothScan(callbackId: callbackId) |
| 957 | } else { | |
| 958 | rejectCallback(callbackId, error: "Bluetooth is disabled", code: "CAPABILITY_DISABLED") | |
| 915 | 959 | } |
| 916 | 960 | case "stopBluetoothScan": |
| 917 | 961 | stopBluetoothScan() |
| @@ -921,6 +965,8 @@ struct CraftWebView: UIViewRepresentable { | ||
| 921 | 965 | case "scanNFC": |
| 922 | 966 | if config.enableNFC { |
| 923 | 967 | scanNFC(callbackId: callbackId) |
| 968 | } else { | |
| 969 | rejectCallback(callbackId, error: "NFC is disabled", code: "CAPABILITY_DISABLED") | |
| 924 | 970 | } |
| 925 | 971 | |
| 926 | 972 | // MARK: - Health |
| @@ -928,6 +974,8 @@ struct CraftWebView: UIViewRepresentable { | ||
| 928 | 974 | if config.enableHealthKit { |
| 929 | 975 | let types = body["types"] as? [String] ?? [] |
| 930 | 976 | requestHealthAuthorization(types: types, callbackId: callbackId) |
| 977 | } else { | |
| 978 | rejectCallback(callbackId, error: "HealthKit is disabled", code: "CAPABILITY_DISABLED") | |
| 931 | 979 | } |
| 932 | 980 | case "getHealthData": |
| 933 | 981 | if config.enableHealthKit, |
| @@ -959,6 +1007,8 @@ struct CraftWebView: UIViewRepresentable { | ||
| 959 | 1007 | case "takeScreenshot": |
| 960 | 1008 | if config.enableScreenCapture { |
| 961 | 1009 | takeScreenshot(callbackId: callbackId) |
| 1010 | } else { | |
| 1011 | rejectCallback(callbackId, error: "Screen capture is disabled", code: "CAPABILITY_DISABLED") | |
| 962 | 1012 | } |
| 963 | 1013 | |
| 964 | 1014 | // MARK: - Background Tasks |
| @@ -983,6 +1033,8 @@ struct CraftWebView: UIViewRepresentable { | ||
| 983 | 1033 | case "cancelAllBackgroundTasks": |
| 984 | 1034 | if config.enableBackgroundTasks { |
| 985 | 1035 | cancelAllBackgroundTasks(callbackId: callbackId) |
| 1036 | } else { | |
| 1037 | rejectCallback(callbackId, error: "Background tasks are disabled", code: "CAPABILITY_DISABLED") | |
| 986 | 1038 | } |
| 987 | 1039 | |
| 988 | 1040 | // MARK: - PDF Viewer |
| @@ -1000,6 +1052,8 @@ struct CraftWebView: UIViewRepresentable { | ||
| 1000 | 1052 | if config.enableContacts { |
| 1001 | 1053 | let multiple = body["multiple"] as? Bool ?? false |
| 1002 | 1054 | pickContact(multiple: multiple, callbackId: callbackId) |
| 1055 | } else { | |
| 1056 | rejectCallback(callbackId, error: "Contacts access is disabled", code: "CAPABILITY_DISABLED") | |
| 1003 | 1057 | } |
| 1004 | 1058 | |
| 1005 | 1059 | // MARK: - App Shortcuts |
| @@ -1044,10 +1098,14 @@ struct CraftWebView: UIViewRepresentable { | ||
| 1044 | 1098 | if config.enableAR { |
| 1045 | 1099 | let options = body["options"] as? [String: Any] ?? [:] |
| 1046 | 1100 | startAR(options: options, callbackId: callbackId) |
| 1101 | } else { | |
| 1102 | rejectCallback(callbackId, error: "AR is disabled", code: "CAPABILITY_DISABLED") | |
| 1047 | 1103 | } |
| 1048 | 1104 | case "stopAR": |
| 1049 | 1105 | if config.enableAR { |
| 1050 | 1106 | stopAR(callbackId: callbackId) |
| 1107 | } else { | |
| 1108 | rejectCallback(callbackId, error: "AR is disabled", code: "CAPABILITY_DISABLED") | |
| 1051 | 1109 | } |
| 1052 | 1110 | case "placeARObject": |
| 1053 | 1111 | if config.enableAR, |
| @@ -1063,6 +1121,8 @@ struct CraftWebView: UIViewRepresentable { | ||
| 1063 | 1121 | case "getARPlanes": |
| 1064 | 1122 | if config.enableAR { |
| 1065 | 1123 | getARPlanes(callbackId: callbackId) |
| 1124 | } else { | |
| 1125 | rejectCallback(callbackId, error: "AR is disabled", code: "CAPABILITY_DISABLED") | |
| 1066 | 1126 | } |
| 1067 | 1127 | |
| 1068 | 1128 | // MARK: - ML (Core ML / Vision) |