@zelloptt/react-native-zello-sdk 3.0.0 → 4.0.0

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 (104) hide show
  1. package/README.md +63 -21
  2. package/app.plugin.js +97 -0
  3. package/lib/commonjs/docs/assets/highlight.css +16 -9
  4. package/lib/commonjs/docs/classes/sdk.Zello.html +49 -49
  5. package/lib/commonjs/docs/classes/types.ZelloAlertMessage.html +7 -7
  6. package/lib/commonjs/docs/classes/types.ZelloChannel.html +10 -10
  7. package/lib/commonjs/docs/classes/types.ZelloChannelUser.html +4 -4
  8. package/lib/commonjs/docs/classes/types.ZelloDispatchCall.html +4 -4
  9. package/lib/commonjs/docs/classes/types.ZelloDispatchChannel.html +11 -11
  10. package/lib/commonjs/docs/classes/types.ZelloGroupConversation.html +13 -13
  11. package/lib/commonjs/docs/classes/types.ZelloHistoryAlertMessage.html +8 -8
  12. package/lib/commonjs/docs/classes/types.ZelloHistoryImageMessage.html +7 -7
  13. package/lib/commonjs/docs/classes/types.ZelloHistoryLocationMessage.html +11 -11
  14. package/lib/commonjs/docs/classes/types.ZelloHistoryTextMessage.html +8 -8
  15. package/lib/commonjs/docs/classes/types.ZelloHistoryVoiceMessage.html +9 -9
  16. package/lib/commonjs/docs/classes/types.ZelloImageMessage.html +8 -8
  17. package/lib/commonjs/docs/classes/types.ZelloIncomingEmergency.html +7 -7
  18. package/lib/commonjs/docs/classes/types.ZelloIncomingVoiceMessage.html +7 -7
  19. package/lib/commonjs/docs/classes/types.ZelloLocationMessage.html +10 -10
  20. package/lib/commonjs/docs/classes/types.ZelloOutgoingEmergency.html +5 -5
  21. package/lib/commonjs/docs/classes/types.ZelloOutgoingVoiceMessage.html +7 -7
  22. package/lib/commonjs/docs/classes/types.ZelloRecentEntry.html +7 -7
  23. package/lib/commonjs/docs/classes/types.ZelloTextMessage.html +7 -7
  24. package/lib/commonjs/docs/classes/types.ZelloTranscription.html +7 -7
  25. package/lib/commonjs/docs/classes/types.ZelloTranslation.html +4 -4
  26. package/lib/commonjs/docs/classes/types.ZelloUser.html +10 -10
  27. package/lib/commonjs/docs/classes/types.ZelloUserSupportedFeatures.html +3 -3
  28. package/lib/commonjs/docs/enums/events.ZelloEvent.html +46 -46
  29. package/lib/commonjs/docs/enums/types.ZelloAccountStatus.html +3 -3
  30. package/lib/commonjs/docs/enums/types.ZelloChannelAlertLevel.html +3 -3
  31. package/lib/commonjs/docs/enums/types.ZelloChannelConnectionStatus.html +4 -4
  32. package/lib/commonjs/docs/enums/types.ZelloChannelType.html +5 -5
  33. package/lib/commonjs/docs/enums/types.ZelloConnectionError.html +4 -4
  34. package/lib/commonjs/docs/enums/types.ZelloConnectionState.html +5 -5
  35. package/lib/commonjs/docs/enums/types.ZelloContactType.html +5 -5
  36. package/lib/commonjs/docs/enums/types.ZelloDispatchCallStatus.html +5 -5
  37. package/lib/commonjs/docs/enums/types.ZelloOutgoingVoiceMessageError.html +3 -3
  38. package/lib/commonjs/docs/enums/types.ZelloOutgoingVoiceMessageState.html +6 -6
  39. package/lib/commonjs/docs/enums/types.ZelloRecentEntryType.html +6 -6
  40. package/lib/commonjs/docs/enums/types.ZelloUserStatus.html +5 -5
  41. package/lib/commonjs/docs/index.html +55 -24
  42. package/lib/commonjs/docs/interfaces/specs_NativeZelloSdk.Spec.html +31 -31
  43. package/lib/commonjs/docs/types/types.ZelloChannelOptions.html +9 -9
  44. package/lib/commonjs/docs/types/types.ZelloConfig.html +3 -3
  45. package/lib/commonjs/docs/types/types.ZelloConsoleSettings.html +7 -7
  46. package/lib/commonjs/docs/types/types.ZelloContact.html +4 -4
  47. package/lib/commonjs/docs/types/types.ZelloCredentials.html +4 -4
  48. package/lib/commonjs/docs/types/types.ZelloHistoryMessage.html +6 -6
  49. package/lib/commonjs/docs/types/types.ZelloMessage.html +5 -5
  50. package/lib/commonjs/docs/variables/specs_NativeZelloSdk.default.html +1 -1
  51. package/lib/module/docs/assets/highlight.css +16 -9
  52. package/lib/module/docs/classes/sdk.Zello.html +49 -49
  53. package/lib/module/docs/classes/types.ZelloAlertMessage.html +7 -7
  54. package/lib/module/docs/classes/types.ZelloChannel.html +10 -10
  55. package/lib/module/docs/classes/types.ZelloChannelUser.html +4 -4
  56. package/lib/module/docs/classes/types.ZelloDispatchCall.html +4 -4
  57. package/lib/module/docs/classes/types.ZelloDispatchChannel.html +11 -11
  58. package/lib/module/docs/classes/types.ZelloGroupConversation.html +13 -13
  59. package/lib/module/docs/classes/types.ZelloHistoryAlertMessage.html +8 -8
  60. package/lib/module/docs/classes/types.ZelloHistoryImageMessage.html +7 -7
  61. package/lib/module/docs/classes/types.ZelloHistoryLocationMessage.html +11 -11
  62. package/lib/module/docs/classes/types.ZelloHistoryTextMessage.html +8 -8
  63. package/lib/module/docs/classes/types.ZelloHistoryVoiceMessage.html +9 -9
  64. package/lib/module/docs/classes/types.ZelloImageMessage.html +8 -8
  65. package/lib/module/docs/classes/types.ZelloIncomingEmergency.html +7 -7
  66. package/lib/module/docs/classes/types.ZelloIncomingVoiceMessage.html +7 -7
  67. package/lib/module/docs/classes/types.ZelloLocationMessage.html +10 -10
  68. package/lib/module/docs/classes/types.ZelloOutgoingEmergency.html +5 -5
  69. package/lib/module/docs/classes/types.ZelloOutgoingVoiceMessage.html +7 -7
  70. package/lib/module/docs/classes/types.ZelloRecentEntry.html +7 -7
  71. package/lib/module/docs/classes/types.ZelloTextMessage.html +7 -7
  72. package/lib/module/docs/classes/types.ZelloTranscription.html +7 -7
  73. package/lib/module/docs/classes/types.ZelloTranslation.html +4 -4
  74. package/lib/module/docs/classes/types.ZelloUser.html +10 -10
  75. package/lib/module/docs/classes/types.ZelloUserSupportedFeatures.html +3 -3
  76. package/lib/module/docs/enums/events.ZelloEvent.html +46 -46
  77. package/lib/module/docs/enums/types.ZelloAccountStatus.html +3 -3
  78. package/lib/module/docs/enums/types.ZelloChannelAlertLevel.html +3 -3
  79. package/lib/module/docs/enums/types.ZelloChannelConnectionStatus.html +4 -4
  80. package/lib/module/docs/enums/types.ZelloChannelType.html +5 -5
  81. package/lib/module/docs/enums/types.ZelloConnectionError.html +4 -4
  82. package/lib/module/docs/enums/types.ZelloConnectionState.html +5 -5
  83. package/lib/module/docs/enums/types.ZelloContactType.html +5 -5
  84. package/lib/module/docs/enums/types.ZelloDispatchCallStatus.html +5 -5
  85. package/lib/module/docs/enums/types.ZelloOutgoingVoiceMessageError.html +3 -3
  86. package/lib/module/docs/enums/types.ZelloOutgoingVoiceMessageState.html +6 -6
  87. package/lib/module/docs/enums/types.ZelloRecentEntryType.html +6 -6
  88. package/lib/module/docs/enums/types.ZelloUserStatus.html +5 -5
  89. package/lib/module/docs/index.html +55 -24
  90. package/lib/module/docs/interfaces/specs_NativeZelloSdk.Spec.html +31 -31
  91. package/lib/module/docs/types/types.ZelloChannelOptions.html +9 -9
  92. package/lib/module/docs/types/types.ZelloConfig.html +3 -3
  93. package/lib/module/docs/types/types.ZelloConsoleSettings.html +7 -7
  94. package/lib/module/docs/types/types.ZelloContact.html +4 -4
  95. package/lib/module/docs/types/types.ZelloCredentials.html +4 -4
  96. package/lib/module/docs/types/types.ZelloHistoryMessage.html +6 -6
  97. package/lib/module/docs/types/types.ZelloMessage.html +5 -5
  98. package/lib/module/docs/variables/specs_NativeZelloSdk.default.html +1 -1
  99. package/package.json +23 -2
  100. package/react-native-zello-sdk.podspec +21 -47
  101. package/scripts/podfile-transform.js +416 -0
  102. package/scripts/setup-ios.js +248 -0
  103. package/scripts/zello_pods.rb +128 -0
  104. package/scripts/zello_sdk_requirement.rb +12 -0
@@ -0,0 +1,128 @@
1
+ # CocoaPods helper for @zelloptt/react-native-zello-sdk.
2
+ #
3
+ # The native ZelloSDK is consumed through Swift Package Manager (product `ZelloSDKUmbrella`).
4
+ # `spm_dependency` in the podspec only wires the package into the bridge pod inside
5
+ # Pods.xcodeproj; the app (and its extensions) must also link the dynamic product, and the
6
+ # app must embed it. `zello_post_install` does that in the user's Xcode project.
7
+ #
8
+ # require Pod::Executable.execute_command('node', ['-p',
9
+ # "require.resolve('@zelloptt/react-native-zello-sdk/scripts/zello_pods.rb', {paths: [process.argv[1]]})",
10
+ # __dir__]).strip
11
+ #
12
+ # post_install do |installer|
13
+ # zello_post_install(installer, app_target: 'MyApp', extension_targets: ['NotificationServiceExtension'])
14
+ # react_native_post_install(...)
15
+ # end
16
+ require 'xcodeproj'
17
+ require_relative 'zello_sdk_requirement'
18
+
19
+ ZELLO_EXTENSION_RUNPATH = '@executable_path/../../Frameworks'
20
+
21
+ def zello_post_install(installer, app_target:, extension_targets: [])
22
+ leftover = installer.pod_targets.select { |t| t.pod_name == 'ZelloSDK' }
23
+ unless leftover.empty?
24
+ raise "[react-native-zello-sdk] Pod target(s) #{leftover.map(&:name).join(', ')} found: the native ZelloSDK now comes " \
25
+ "from Swift Package Manager. Remove `pod 'ZelloSDK'` from your Podfile (`npx @zelloptt/react-native-zello-sdk setup-ios` does it for you)."
26
+ end
27
+
28
+ aggregate = installer.aggregate_targets.find { |t| t.user_targets.map(&:name).include?(app_target) }
29
+ user_project = aggregate&.user_project
30
+ raise "[react-native-zello-sdk] App target '#{app_target}' not found in any project integrated by your Podfile." unless user_project
31
+
32
+ app = user_project.targets.find { |t| t.name == app_target }
33
+ extensions = Array(extension_targets).map do |name|
34
+ user_project.targets.find { |t| t.name == name } ||
35
+ raise("[react-native-zello-sdk] Extension target '#{name}' not found in #{File.basename(user_project.path)}.")
36
+ end
37
+
38
+ ([app] + extensions).each { |t| zello_check_deployment_target!(t) }
39
+
40
+ package = zello_ensure_package_reference(user_project)
41
+ zello_link_product(user_project, app, package, embed: true)
42
+ extensions.each do |ext|
43
+ zello_link_product(user_project, ext, package, embed: false)
44
+ zello_ensure_extension_runpath(ext)
45
+ end
46
+
47
+ # CocoaPods only saves the user project for targets it integrates, so a no-op install would not persist this.
48
+ user_project.save
49
+ end
50
+
51
+ def zello_check_deployment_target!(target)
52
+ minimum = Gem::Version.new(ZELLO_MIN_IOS_VERSION)
53
+ target.resolved_build_setting('IPHONEOS_DEPLOYMENT_TARGET', true).each do |config, value|
54
+ next if value.nil?
55
+
56
+ version = begin
57
+ Gem::Version.new(value.to_s)
58
+ rescue ArgumentError
59
+ next
60
+ end
61
+ next if version >= minimum
62
+
63
+ raise "[react-native-zello-sdk] Target '#{target.name}' (#{config}) has IPHONEOS_DEPLOYMENT_TARGET #{value}; " \
64
+ "ZelloSDK requires iOS #{ZELLO_MIN_IOS_VERSION} or later."
65
+ end
66
+ end
67
+
68
+ def zello_ensure_package_reference(project)
69
+ klass = Xcodeproj::Project::Object::XCRemoteSwiftPackageReference
70
+ package = project.root_object.package_references.find { |r| r.is_a?(klass) && r.repositoryURL == ZELLO_SDK_URL }
71
+ unless package
72
+ package = project.new(klass)
73
+ package.repositoryURL = ZELLO_SDK_URL
74
+ project.root_object.package_references << package
75
+ end
76
+ package.requirement = ZELLO_SDK_REQUIREMENT.dup if zello_replace_requirement?(package.requirement)
77
+ package
78
+ end
79
+
80
+ # Keeps an app's own requirement unless it is missing or an `upToNextMajorVersion` below ours.
81
+ def zello_replace_requirement?(current)
82
+ return true if current.nil? || current.empty?
83
+ return false unless current['kind'] == ZELLO_SDK_REQUIREMENT['kind']
84
+
85
+ Gem::Version.new(current['minimumVersion'].to_s) < Gem::Version.new(ZELLO_SDK_REQUIREMENT['minimumVersion'])
86
+ rescue ArgumentError
87
+ false
88
+ end
89
+
90
+ def zello_link_product(project, target, package, embed:)
91
+ dependency = target.package_product_dependencies.find { |d| d.product_name == ZELLO_SDK_PRODUCT && d.package == package }
92
+ unless dependency
93
+ dependency = project.new(Xcodeproj::Project::Object::XCSwiftPackageProductDependency)
94
+ dependency.product_name = ZELLO_SDK_PRODUCT
95
+ dependency.package = package
96
+ target.package_product_dependencies << dependency
97
+ end
98
+
99
+ unless target.frameworks_build_phase.files.any? { |f| f.product_ref == dependency }
100
+ build_file = project.new(Xcodeproj::Project::Object::PBXBuildFile)
101
+ build_file.product_ref = dependency
102
+ target.frameworks_build_phase.files << build_file
103
+ end
104
+ return unless embed
105
+
106
+ phase = target.copy_files_build_phases.find { |p| p.name == 'Embed Frameworks' && p.dst_subfolder_spec == '10' }
107
+ unless phase
108
+ phase = target.new_copy_files_build_phase('Embed Frameworks')
109
+ phase.dst_subfolder_spec = '10'
110
+ end
111
+ return if phase.files.any? { |f| f.product_ref == dependency }
112
+
113
+ build_file = project.new(Xcodeproj::Project::Object::PBXBuildFile)
114
+ build_file.product_ref = dependency
115
+ build_file.settings = { 'ATTRIBUTES' => ['CodeSignOnCopy'] }
116
+ phase.files << build_file
117
+ end
118
+
119
+ # Extensions link the product but do not embed it; it is loaded from the host app's Frameworks directory.
120
+ def zello_ensure_extension_runpath(target)
121
+ target.build_configurations.each do |config|
122
+ paths = config.build_settings['LD_RUNPATH_SEARCH_PATHS'] || ['$(inherited)']
123
+ next if Array(paths.is_a?(String) ? paths.split : paths).include?(ZELLO_EXTENSION_RUNPATH)
124
+
125
+ config.build_settings['LD_RUNPATH_SEARCH_PATHS'] =
126
+ paths.is_a?(String) ? "#{paths} #{ZELLO_EXTENSION_RUNPATH}" : paths + [ZELLO_EXTENSION_RUNPATH]
127
+ end
128
+ end
@@ -0,0 +1,12 @@
1
+ # Single source of truth for the native ZelloSDK Swift package requirement.
2
+ # Loaded by both the podspec (Pods.xcodeproj) and scripts/zello_pods.rb (app
3
+ # project); the URL must be byte-identical in both projects, otherwise Xcode
4
+ # reports "package is required using two different URLs".
5
+ #
6
+ # The podspec is evaluated more than once per process, hence the guards.
7
+ ZELLO_SDK_URL = 'https://github.com/zelloptt/ios-mobile-sdk' unless defined?(ZELLO_SDK_URL)
8
+ ZELLO_SDK_PRODUCT = 'ZelloSDKUmbrella' unless defined?(ZELLO_SDK_PRODUCT)
9
+ unless defined?(ZELLO_SDK_REQUIREMENT)
10
+ ZELLO_SDK_REQUIREMENT = { 'kind' => 'upToNextMajorVersion', 'minimumVersion' => '3.3.2' }.freeze
11
+ end
12
+ ZELLO_MIN_IOS_VERSION = '17.0' unless defined?(ZELLO_MIN_IOS_VERSION)