@fishjam-cloud/react-native-client 0.5.0 → 0.6.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 (88) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/java/io/fishjam/reactnative/EmitableEvents.kt +13 -14
  3. package/android/src/main/java/io/fishjam/reactnative/RNFishjamClient.kt +23 -10
  4. package/android/src/main/java/io/fishjam/reactnative/RNFishjamClientModule.kt +9 -7
  5. package/build/RNFishjamClientModule.d.ts +23 -6
  6. package/build/RNFishjamClientModule.d.ts.map +1 -1
  7. package/build/RNFishjamClientModule.js +19 -4
  8. package/build/RNFishjamClientModule.js.map +1 -1
  9. package/build/common/client.d.ts +1 -6
  10. package/build/common/client.d.ts.map +1 -1
  11. package/build/common/client.js +0 -4
  12. package/build/common/client.js.map +1 -1
  13. package/build/common/metadata.d.ts +1 -1
  14. package/build/common/metadata.js +1 -1
  15. package/build/common/metadata.js.map +1 -1
  16. package/build/components/FishjamRoom/parsePeersToTracks.d.ts.map +1 -1
  17. package/build/components/FishjamRoom/parsePeersToTracks.js +4 -6
  18. package/build/components/FishjamRoom/parsePeersToTracks.js.map +1 -1
  19. package/build/debug/stats/useRTCStatistics.d.ts.map +1 -1
  20. package/build/debug/stats/useRTCStatistics.js +13 -13
  21. package/build/debug/stats/useRTCStatistics.js.map +1 -1
  22. package/build/hooks/internal/useFishjamEvent.d.ts +3 -0
  23. package/build/hooks/internal/useFishjamEvent.d.ts.map +1 -0
  24. package/build/hooks/internal/useFishjamEvent.js +11 -0
  25. package/build/hooks/internal/useFishjamEvent.js.map +1 -0
  26. package/build/hooks/internal/useFishjamEventState.d.ts +3 -0
  27. package/build/hooks/internal/useFishjamEventState.d.ts.map +1 -0
  28. package/build/hooks/{useFishjamEventState.js → internal/useFishjamEventState.js} +3 -1
  29. package/build/hooks/internal/useFishjamEventState.js.map +1 -0
  30. package/build/hooks/useAppScreenShare.d.ts.map +1 -1
  31. package/build/hooks/useAppScreenShare.js +5 -7
  32. package/build/hooks/useAppScreenShare.js.map +1 -1
  33. package/build/hooks/useAudioSettings.d.ts.map +1 -1
  34. package/build/hooks/useAudioSettings.js +8 -11
  35. package/build/hooks/useAudioSettings.js.map +1 -1
  36. package/build/hooks/useBandwidthEstimation.d.ts.map +1 -1
  37. package/build/hooks/useBandwidthEstimation.js +3 -4
  38. package/build/hooks/useBandwidthEstimation.js.map +1 -1
  39. package/build/hooks/useCamera.d.ts.map +1 -1
  40. package/build/hooks/useCamera.js +7 -8
  41. package/build/hooks/useCamera.js.map +1 -1
  42. package/build/hooks/useConnection.d.ts +42 -0
  43. package/build/hooks/useConnection.d.ts.map +1 -0
  44. package/build/hooks/useConnection.js +33 -0
  45. package/build/hooks/useConnection.js.map +1 -0
  46. package/build/hooks/useMicrophone.d.ts.map +1 -1
  47. package/build/hooks/useMicrophone.js +2 -3
  48. package/build/hooks/useMicrophone.js.map +1 -1
  49. package/build/hooks/usePeerStatus.d.ts +2 -3
  50. package/build/hooks/usePeerStatus.d.ts.map +1 -1
  51. package/build/hooks/usePeerStatus.js +4 -10
  52. package/build/hooks/usePeerStatus.js.map +1 -1
  53. package/build/hooks/usePeers.d.ts.map +1 -1
  54. package/build/hooks/usePeers.js +4 -15
  55. package/build/hooks/usePeers.js.map +1 -1
  56. package/build/hooks/useReconnection.d.ts +1 -1
  57. package/build/hooks/useReconnection.d.ts.map +1 -1
  58. package/build/hooks/useReconnection.js +4 -10
  59. package/build/hooks/useReconnection.js.map +1 -1
  60. package/build/hooks/useScreenShare.d.ts.map +1 -1
  61. package/build/hooks/useScreenShare.js +6 -10
  62. package/build/hooks/useScreenShare.js.map +1 -1
  63. package/build/hooks/useUpdatePeerMetadata.d.ts +15 -0
  64. package/build/hooks/useUpdatePeerMetadata.d.ts.map +1 -0
  65. package/build/hooks/useUpdatePeerMetadata.js +21 -0
  66. package/build/hooks/useUpdatePeerMetadata.js.map +1 -0
  67. package/build/index.d.ts +22 -15
  68. package/build/index.d.ts.map +1 -1
  69. package/build/index.js +17 -6
  70. package/build/index.js.map +1 -1
  71. package/build/utils/errorListener.d.ts.map +1 -1
  72. package/build/utils/errorListener.js +2 -3
  73. package/build/utils/errorListener.js.map +1 -1
  74. package/ios/Events.swift +4 -7
  75. package/ios/RNFishjamClient.podspec +1 -1
  76. package/ios/RNFishjamClient.swift +14 -9
  77. package/ios/RNFishjamClientModule.swift +8 -4
  78. package/ios/Utils.swift +0 -20
  79. package/package.json +6 -7
  80. package/plugin/build/withFishjamAndroid.js +18 -20
  81. package/plugin/build/withFishjamIos.js +99 -103
  82. package/build/hooks/useFishjamEvent.d.ts +0 -18
  83. package/build/hooks/useFishjamEvent.d.ts.map +0 -1
  84. package/build/hooks/useFishjamEvent.js +0 -27
  85. package/build/hooks/useFishjamEvent.js.map +0 -1
  86. package/build/hooks/useFishjamEventState.d.ts +0 -3
  87. package/build/hooks/useFishjamEventState.d.ts.map +0 -1
  88. package/build/hooks/useFishjamEventState.js.map +0 -1
@@ -34,7 +34,7 @@ target '${SBE_TARGET_NAME}' do
34
34
  pod 'FishjamCloudClient/Broadcast'
35
35
  end`;
36
36
  const TARGETED_DEVICE_FAMILY = `"1,2"`;
37
- const IPHONEOS_DEPLOYMENT_TARGET = '13.4';
37
+ const IPHONEOS_DEPLOYMENT_TARGET = '15.1';
38
38
  const GROUP_IDENTIFIER_TEMPLATE_REGEX = /{{GROUP_IDENTIFIER}}/gm;
39
39
  const BUNDLE_IDENTIFIER_TEMPLATE_REGEX = /{{BUNDLE_IDENTIFIER}}/gm;
40
40
  /**
@@ -95,113 +95,109 @@ const withAppGroupPermissions = (config) => {
95
95
  * Adds constants to Info.plist
96
96
  * In other to dynamically retreive extension's bundleId and group name we need to store it in Info.plist.
97
97
  */
98
- const withInfoPlistConstants = (config) => {
99
- return (0, config_plugins_1.withInfoPlist)(config, (config) => {
100
- const bundleIdentifier = config.ios?.bundleIdentifier || '';
101
- config.modResults['AppGroupName'] = `group.${bundleIdentifier}`;
102
- config.modResults['ScreenShareExtensionBundleId'] =
103
- `${bundleIdentifier}.${SBE_TARGET_NAME}`;
104
- return config;
105
- });
106
- };
98
+ const withInfoPlistConstants = (config) => (0, config_plugins_1.withInfoPlist)(config, (configuration) => {
99
+ const bundleIdentifier = configuration.ios?.bundleIdentifier || '';
100
+ configuration.modResults['AppGroupName'] = `group.${bundleIdentifier}`;
101
+ configuration.modResults['ScreenShareExtensionBundleId'] =
102
+ `${bundleIdentifier}.${SBE_TARGET_NAME}`;
103
+ return configuration;
104
+ });
107
105
  /**
108
106
  * Updates and copies required extension files.
109
107
  * Our extension needs to be properly setup inside the Xcode project. In order to do that we need to copy the files and update the pbxproj.
110
108
  */
111
- const withFishjamSBE = (config, options) => {
112
- return (0, config_plugins_1.withXcodeProject)(config, async (props) => {
113
- const appName = props.modRequest.projectName || '';
114
- const iosPath = props.modRequest.platformProjectRoot;
115
- const bundleIdentifier = props.ios?.bundleIdentifier;
116
- const xcodeProject = props.modResults;
117
- const pluginDir = require.resolve('@fishjam-cloud/react-native-client/package.json');
118
- const extensionSourceDir = path.join(pluginDir, '../plugin/broadcastExtensionFiles/');
119
- await updatePodfile(iosPath);
120
- const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
121
- const extFiles = [
122
- 'FishjamBroadcastSampleHandler.swift',
123
- `${SBE_TARGET_NAME}.entitlements`,
124
- `Info.plist`,
125
- ];
126
- await xcodeProject.parse(async function (err) {
127
- if (err) {
128
- console.error(`Error parsing iOS project: ${JSON.stringify(err)}`);
129
- return;
130
- }
131
- if (xcodeProject.pbxTargetByName(SBE_TARGET_NAME)) {
132
- console.log(`${SBE_TARGET_NAME} already exists in project. Skipping...`);
133
- return;
134
- }
135
- try {
136
- // copy extension files
137
- await fs.mkdir(`${iosPath}/${SBE_TARGET_NAME}`, { recursive: true });
138
- for (let i = 0; i < extFiles.length; i++) {
139
- const extFile = extFiles[i];
140
- const targetFile = `${iosPath}/${SBE_TARGET_NAME}/${extFile}`;
141
- await fs.copyFile(`${extensionSourceDir}${extFile}`, targetFile);
142
- }
143
- }
144
- catch (e) {
145
- console.error('Error copying extension files: ', e);
109
+ const withFishjamSBE = (config, options) => (0, config_plugins_1.withXcodeProject)(config, async (props) => {
110
+ const appName = props.modRequest.projectName || '';
111
+ const iosPath = props.modRequest.platformProjectRoot;
112
+ const bundleIdentifier = props.ios?.bundleIdentifier;
113
+ const xcodeProject = props.modResults;
114
+ const pluginDir = require.resolve('@fishjam-cloud/react-native-client/package.json');
115
+ const extensionSourceDir = path.join(pluginDir, '../plugin/broadcastExtensionFiles/');
116
+ await updatePodfile(iosPath);
117
+ const projPath = `${iosPath}/${appName}.xcodeproj/project.pbxproj`;
118
+ const extFiles = [
119
+ 'FishjamBroadcastSampleHandler.swift',
120
+ `${SBE_TARGET_NAME}.entitlements`,
121
+ `Info.plist`,
122
+ ];
123
+ await xcodeProject.parse(async function (err) {
124
+ if (err) {
125
+ console.error(`Error parsing iOS project: ${JSON.stringify(err)}`);
126
+ return;
127
+ }
128
+ if (xcodeProject.pbxTargetByName(SBE_TARGET_NAME)) {
129
+ console.log(`${SBE_TARGET_NAME} already exists in project. Skipping...`);
130
+ return;
131
+ }
132
+ try {
133
+ // copy extension files
134
+ await fs.mkdir(`${iosPath}/${SBE_TARGET_NAME}`, { recursive: true });
135
+ for (let i = 0; i < extFiles.length; i++) {
136
+ const extFile = extFiles[i];
137
+ const targetFile = `${iosPath}/${SBE_TARGET_NAME}/${extFile}`;
138
+ await fs.copyFile(`${extensionSourceDir}${extFile}`, targetFile);
146
139
  }
147
- // update extension files
148
- await updateFileWithRegex(iosPath, `${SBE_TARGET_NAME}.entitlements`, GROUP_IDENTIFIER_TEMPLATE_REGEX, `group.${bundleIdentifier}`);
149
- await updateFileWithRegex(iosPath, 'FishjamBroadcastSampleHandler.swift', GROUP_IDENTIFIER_TEMPLATE_REGEX, `group.${bundleIdentifier}`);
150
- await updateFileWithRegex(iosPath, 'FishjamBroadcastSampleHandler.swift', BUNDLE_IDENTIFIER_TEMPLATE_REGEX, bundleIdentifier || '');
151
- // Create new PBXGroup for the extension
152
- const extGroup = xcodeProject.addPbxGroup(extFiles, SBE_TARGET_NAME, SBE_TARGET_NAME);
153
- // Add the new PBXGroup to the top level group. This makes the
154
- // files / folder appear in the file explorer in Xcode.
155
- const groups = xcodeProject.hash.project.objects['PBXGroup'];
156
- Object.keys(groups).forEach(function (key) {
157
- if (groups[key].name === undefined) {
158
- xcodeProject.addToPbxGroup(extGroup.uuid, key);
159
- }
160
- });
161
- // WORK AROUND for codeProject.addTarget BUG
162
- // Xcode projects don't contain these if there is only one target
163
- // An upstream fix should be made to the code referenced in this link:
164
- // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
165
- const projObjects = xcodeProject.hash.project.objects;
166
- projObjects['PBXTargetDependency'] =
167
- projObjects['PBXTargetDependency'] || {};
168
- projObjects['PBXContainerItemProxy'] =
169
- projObjects['PBXTargetDependency'] || {};
170
- // Add the SBE target
171
- // This adds PBXTargetDependency and PBXContainerItemProxy for you
172
- const sbeTarget = xcodeProject.addTarget(SBE_TARGET_NAME, 'app_extension', SBE_TARGET_NAME, `${bundleIdentifier}.${SBE_TARGET_NAME}`);
173
- // Add build phases to the new target
174
- xcodeProject.addBuildPhase(['FishjamBroadcastSampleHandler.swift'], 'PBXSourcesBuildPhase', 'Sources', sbeTarget.uuid);
175
- xcodeProject.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', sbeTarget.uuid);
176
- xcodeProject.addBuildPhase([], 'PBXFrameworksBuildPhase', 'Frameworks', sbeTarget.uuid);
177
- xcodeProject.addFramework('ReplayKit.framework', {
178
- target: sbeTarget.uuid,
179
- });
180
- // Edit the Deployment info of the new Target, only IphoneOS and Targeted Device Family
181
- // However, can be more
182
- const configurations = xcodeProject.pbxXCBuildConfigurationSection();
183
- for (const key in configurations) {
184
- if (typeof configurations[key].buildSettings !== 'undefined' &&
185
- configurations[key].buildSettings.PRODUCT_NAME ===
186
- `"${SBE_TARGET_NAME}"`) {
187
- const buildSettingsObj = configurations[key].buildSettings;
188
- buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =
189
- options?.ios?.iphoneDeploymentTarget ?? IPHONEOS_DEPLOYMENT_TARGET;
190
- buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
191
- buildSettingsObj.CODE_SIGN_ENTITLEMENTS = `${SBE_TARGET_NAME}/${SBE_TARGET_NAME}.entitlements`;
192
- buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
193
- buildSettingsObj.INFOPLIST_FILE = `${SBE_TARGET_NAME}/Info.plist`;
194
- buildSettingsObj.SWIFT_VERSION = '5.0';
195
- buildSettingsObj.MARKETING_VERSION = '1.0.0';
196
- buildSettingsObj.CURRENT_PROJECT_VERSION = '1';
197
- buildSettingsObj.ENABLE_BITCODE = 'NO';
198
- }
140
+ }
141
+ catch (e) {
142
+ console.error('Error copying extension files: ', e);
143
+ }
144
+ // update extension files
145
+ await updateFileWithRegex(iosPath, `${SBE_TARGET_NAME}.entitlements`, GROUP_IDENTIFIER_TEMPLATE_REGEX, `group.${bundleIdentifier}`);
146
+ await updateFileWithRegex(iosPath, 'FishjamBroadcastSampleHandler.swift', GROUP_IDENTIFIER_TEMPLATE_REGEX, `group.${bundleIdentifier}`);
147
+ await updateFileWithRegex(iosPath, 'FishjamBroadcastSampleHandler.swift', BUNDLE_IDENTIFIER_TEMPLATE_REGEX, bundleIdentifier || '');
148
+ // Create new PBXGroup for the extension
149
+ const extGroup = xcodeProject.addPbxGroup(extFiles, SBE_TARGET_NAME, SBE_TARGET_NAME);
150
+ // Add the new PBXGroup to the top level group. This makes the
151
+ // files / folder appear in the file explorer in Xcode.
152
+ const groups = xcodeProject.hash.project.objects['PBXGroup'];
153
+ Object.keys(groups).forEach(function (key) {
154
+ if (groups[key].name === undefined) {
155
+ xcodeProject.addToPbxGroup(extGroup.uuid, key);
199
156
  }
200
- await fs.writeFile(projPath, xcodeProject.writeSync());
201
157
  });
202
- return props;
158
+ // WORK AROUND for codeProject.addTarget BUG
159
+ // Xcode projects don't contain these if there is only one target
160
+ // An upstream fix should be made to the code referenced in this link:
161
+ // - https://github.com/apache/cordova-node-xcode/blob/8b98cabc5978359db88dc9ff2d4c015cba40f150/lib/pbxProject.js#L860
162
+ const projObjects = xcodeProject.hash.project.objects;
163
+ projObjects['PBXTargetDependency'] =
164
+ projObjects['PBXTargetDependency'] || {};
165
+ projObjects['PBXContainerItemProxy'] =
166
+ projObjects['PBXTargetDependency'] || {};
167
+ // Add the SBE target
168
+ // This adds PBXTargetDependency and PBXContainerItemProxy for you
169
+ const sbeTarget = xcodeProject.addTarget(SBE_TARGET_NAME, 'app_extension', SBE_TARGET_NAME, `${bundleIdentifier}.${SBE_TARGET_NAME}`);
170
+ // Add build phases to the new target
171
+ xcodeProject.addBuildPhase(['FishjamBroadcastSampleHandler.swift'], 'PBXSourcesBuildPhase', 'Sources', sbeTarget.uuid);
172
+ xcodeProject.addBuildPhase([], 'PBXResourcesBuildPhase', 'Resources', sbeTarget.uuid);
173
+ xcodeProject.addBuildPhase([], 'PBXFrameworksBuildPhase', 'Frameworks', sbeTarget.uuid);
174
+ xcodeProject.addFramework('ReplayKit.framework', {
175
+ target: sbeTarget.uuid,
176
+ });
177
+ // Edit the Deployment info of the new Target, only IphoneOS and Targeted Device Family
178
+ // However, can be more
179
+ const configurations = xcodeProject.pbxXCBuildConfigurationSection();
180
+ for (const key in configurations) {
181
+ if (typeof configurations[key].buildSettings !== 'undefined' &&
182
+ configurations[key].buildSettings.PRODUCT_NAME ===
183
+ `"${SBE_TARGET_NAME}"`) {
184
+ const buildSettingsObj = configurations[key].buildSettings;
185
+ buildSettingsObj.IPHONEOS_DEPLOYMENT_TARGET =
186
+ options?.ios?.iphoneDeploymentTarget ?? IPHONEOS_DEPLOYMENT_TARGET;
187
+ buildSettingsObj.TARGETED_DEVICE_FAMILY = TARGETED_DEVICE_FAMILY;
188
+ buildSettingsObj.CODE_SIGN_ENTITLEMENTS = `${SBE_TARGET_NAME}/${SBE_TARGET_NAME}.entitlements`;
189
+ buildSettingsObj.CODE_SIGN_STYLE = 'Automatic';
190
+ buildSettingsObj.INFOPLIST_FILE = `${SBE_TARGET_NAME}/Info.plist`;
191
+ buildSettingsObj.SWIFT_VERSION = '5.0';
192
+ buildSettingsObj.MARKETING_VERSION = '1.0.0';
193
+ buildSettingsObj.CURRENT_PROJECT_VERSION = '1';
194
+ buildSettingsObj.ENABLE_BITCODE = 'NO';
195
+ }
196
+ }
197
+ await fs.writeFile(projPath, xcodeProject.writeSync());
203
198
  });
204
- };
199
+ return props;
200
+ });
205
201
  /**
206
202
  * Applies screen sharing plugin if enabled. In order for screensharing to work, we need to copy extension files to your iOS project.
207
203
  * Allows for dynamically changing deploymentTarget.
@@ -212,10 +208,10 @@ const withFishjamIos = (config, props) => {
212
208
  withInfoPlistConstants(config);
213
209
  withFishjamSBE(config, props);
214
210
  }
215
- (0, config_plugins_1.withPodfileProperties)(config, (config) => {
216
- config.modResults['ios.deploymentTarget'] =
211
+ (0, config_plugins_1.withPodfileProperties)(config, (configuration) => {
212
+ configuration.modResults['ios.deploymentTarget'] =
217
213
  props?.ios?.iphoneDeploymentTarget ?? IPHONEOS_DEPLOYMENT_TARGET;
218
- return config;
214
+ return configuration;
219
215
  });
220
216
  return config;
221
217
  };
@@ -1,18 +0,0 @@
1
- export declare const ReceivableEvents: {
2
- readonly IsMicrophoneOn: "IsMicrophoneOn";
3
- readonly IsScreenShareOn: "IsScreenShareOn";
4
- readonly IsAppScreenShareOn: "IsAppScreenShareOn";
5
- readonly SimulcastConfigUpdate: "SimulcastConfigUpdate";
6
- readonly PeersUpdate: "PeersUpdate";
7
- readonly AudioDeviceUpdate: "AudioDeviceUpdate";
8
- readonly SendMediaEvent: "SendMediaEvent";
9
- readonly BandwidthEstimation: "BandwidthEstimation";
10
- readonly ReconnectionRetriesLimitReached: "ReconnectionRetriesLimitReached";
11
- readonly ReconnectionStarted: "ReconnectionStarted";
12
- readonly Reconnected: "Reconnected";
13
- readonly Warning: "Warning";
14
- readonly PeerStatusChanged: "PeerStatusChanged";
15
- readonly CurrentCameraChanged: "CurrentCameraChanged";
16
- };
17
- export declare function useFishjamEvent<T>(eventName: keyof typeof ReceivableEvents, callback: (event: T) => void): void;
18
- //# sourceMappingURL=useFishjamEvent.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useFishjamEvent.d.ts","sourceRoot":"","sources":["../../src/hooks/useFishjamEvent.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;CAenB,CAAC;AAEX,wBAAgB,eAAe,CAAC,CAAC,EAC/B,SAAS,EAAE,MAAM,OAAO,gBAAgB,EACxC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,QAU7B"}
@@ -1,27 +0,0 @@
1
- import { useEffect } from 'react';
2
- import { nativeModuleEventEmitter } from '../RNFishjamClientModule';
3
- export const ReceivableEvents = {
4
- IsMicrophoneOn: 'IsMicrophoneOn',
5
- IsScreenShareOn: 'IsScreenShareOn',
6
- IsAppScreenShareOn: 'IsAppScreenShareOn', // only for iOS
7
- SimulcastConfigUpdate: 'SimulcastConfigUpdate',
8
- PeersUpdate: 'PeersUpdate',
9
- AudioDeviceUpdate: 'AudioDeviceUpdate',
10
- SendMediaEvent: 'SendMediaEvent',
11
- BandwidthEstimation: 'BandwidthEstimation',
12
- ReconnectionRetriesLimitReached: 'ReconnectionRetriesLimitReached',
13
- ReconnectionStarted: 'ReconnectionStarted',
14
- Reconnected: 'Reconnected',
15
- Warning: 'Warning',
16
- PeerStatusChanged: 'PeerStatusChanged',
17
- CurrentCameraChanged: 'CurrentCameraChanged',
18
- };
19
- export function useFishjamEvent(eventName, callback) {
20
- useEffect(() => {
21
- const eventListener = nativeModuleEventEmitter.addListener(eventName, (event) => {
22
- callback(event[eventName]);
23
- });
24
- return () => eventListener.remove();
25
- }, [callback, eventName]);
26
- }
27
- //# sourceMappingURL=useFishjamEvent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useFishjamEvent.js","sourceRoot":"","sources":["../../src/hooks/useFishjamEvent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,wBAAwB,EAAE,MAAM,0BAA0B,CAAC;AAEpE,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,cAAc,EAAE,gBAAgB;IAChC,eAAe,EAAE,iBAAiB;IAClC,kBAAkB,EAAE,oBAAoB,EAAE,eAAe;IACzD,qBAAqB,EAAE,uBAAuB;IAC9C,WAAW,EAAE,aAAa;IAC1B,iBAAiB,EAAE,mBAAmB;IACtC,cAAc,EAAE,gBAAgB;IAChC,mBAAmB,EAAE,qBAAqB;IAC1C,+BAA+B,EAAE,iCAAiC;IAClE,mBAAmB,EAAE,qBAAqB;IAC1C,WAAW,EAAE,aAAa;IAC1B,OAAO,EAAE,SAAS;IAClB,iBAAiB,EAAE,mBAAmB;IACtC,oBAAoB,EAAE,sBAAsB;CACpC,CAAC;AAEX,MAAM,UAAU,eAAe,CAC7B,SAAwC,EACxC,QAA4B;IAE5B,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,aAAa,GAAG,wBAAwB,CAAC,WAAW,CAExD,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE;YACrB,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;QAC7B,CAAC,CAAC,CAAC;QACH,OAAO,GAAG,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,CAAC;IACtC,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;AAC5B,CAAC","sourcesContent":["import { useEffect } from 'react';\nimport { nativeModuleEventEmitter } from '../RNFishjamClientModule';\n\nexport const ReceivableEvents = {\n IsMicrophoneOn: 'IsMicrophoneOn',\n IsScreenShareOn: 'IsScreenShareOn',\n IsAppScreenShareOn: 'IsAppScreenShareOn', // only for iOS\n SimulcastConfigUpdate: 'SimulcastConfigUpdate',\n PeersUpdate: 'PeersUpdate',\n AudioDeviceUpdate: 'AudioDeviceUpdate',\n SendMediaEvent: 'SendMediaEvent',\n BandwidthEstimation: 'BandwidthEstimation',\n ReconnectionRetriesLimitReached: 'ReconnectionRetriesLimitReached',\n ReconnectionStarted: 'ReconnectionStarted',\n Reconnected: 'Reconnected',\n Warning: 'Warning',\n PeerStatusChanged: 'PeerStatusChanged',\n CurrentCameraChanged: 'CurrentCameraChanged',\n} as const;\n\nexport function useFishjamEvent<T>(\n eventName: keyof typeof ReceivableEvents,\n callback: (event: T) => void,\n) {\n useEffect(() => {\n const eventListener = nativeModuleEventEmitter.addListener<\n Record<keyof typeof ReceivableEvents, T>\n >(eventName, (event) => {\n callback(event[eventName]);\n });\n return () => eventListener.remove();\n }, [callback, eventName]);\n}\n"]}
@@ -1,3 +0,0 @@
1
- import { ReceivableEvents } from './useFishjamEvent';
2
- export declare function useFishjamEventState<EventType, StateType = EventType>(eventName: keyof typeof ReceivableEvents, defaultValue: StateType, transform?: StateType extends EventType ? undefined : (eventValue: EventType) => StateType): StateType;
3
- //# sourceMappingURL=useFishjamEventState.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useFishjamEventState.d.ts","sourceRoot":"","sources":["../../src/hooks/useFishjamEventState.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAmB,MAAM,mBAAmB,CAAC;AAEtE,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,EACnE,SAAS,EAAE,MAAM,OAAO,gBAAgB,EACxC,YAAY,EAAE,SAAS,EACvB,SAAS,CAAC,EAAE,SAAS,SAAS,SAAS,GACnC,SAAS,GACT,CAAC,UAAU,EAAE,SAAS,KAAK,SAAS,aAkBzC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useFishjamEventState.js","sourceRoot":"","sources":["../../src/hooks/useFishjamEventState.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC9C,OAAO,EAAoB,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEtE,MAAM,UAAU,oBAAoB,CAClC,SAAwC,EACxC,YAAuB,EACvB,SAEwC;IAExC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAY,YAAY,CAAC,CAAC;IAE5D,MAAM,OAAO,GAAG,WAAW,CACzB,CAAC,QAAmB,EAAE,EAAE;QACtB,IAAI,SAAS,EAAE,CAAC;YACd,QAAQ,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,CAAC;QAChC,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,QAAgC,CAAC,CAAC;QAC7C,CAAC;IACH,CAAC,EACD,CAAC,SAAS,CAAC,CACZ,CAAC;IAEF,eAAe,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAEpC,OAAO,KAAK,CAAC;AACf,CAAC","sourcesContent":["import { useCallback, useState } from 'react';\nimport { ReceivableEvents, useFishjamEvent } from './useFishjamEvent';\n\nexport function useFishjamEventState<EventType, StateType = EventType>(\n eventName: keyof typeof ReceivableEvents,\n defaultValue: StateType,\n transform?: StateType extends EventType\n ? undefined\n : (eventValue: EventType) => StateType,\n) {\n const [value, setValue] = useState<StateType>(defaultValue);\n\n const onEvent = useCallback(\n (newValue: EventType) => {\n if (transform) {\n setValue(transform(newValue));\n } else {\n setValue(newValue as unknown as StateType);\n }\n },\n [transform],\n );\n\n useFishjamEvent(eventName, onEvent);\n\n return value;\n}\n"]}