react-native-airplay-module 0.2.1 → 0.2.3

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.
package/LICENSE CHANGED
@@ -1,7 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020 Spicy Sparks
4
-
3
+ Copyright (c) 2024 Spicy Sparks
5
4
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
5
  of this software and associated documentation files (the "Software"), to deal
7
6
  in the Software without restriction, including without limitation the rights
package/README.md CHANGED
@@ -1,94 +1,44 @@
1
1
  # react-native-airplay-module
2
2
 
3
- AirPlay library for React Native
3
+ React Native AirPlay Module
4
4
 
5
- ## Installation with Automatic Linking
5
+ ## Installation
6
6
 
7
- ```js
8
- npm i react-native-airplay-module --save
9
- react-native link
7
+ ```sh
8
+ npm install react-native-airplay-module
10
9
  ```
11
10
 
12
- Check the [example](https://github.com/Spicy-Sparks/react-native-airplay-module/blob/main/example/src/App.tsx) project
13
-
14
- Make sure to enable Swift support in your project, if you haven't done it yet.
15
- Xcode -> New file -> Swift file -> Create bridging headers
16
-
17
- ### How to create listeners
18
-
19
- ```js
20
- import { AirPlayListener, AirPlay } from react-native-airplay-module
21
-
22
- AirPlay.startScan()
23
-
24
- this.deviceConnected = AirPlayListener.addListener(
25
- 'deviceConnected',
26
- ({ connected, mirroring, devices }) => this.setState({
27
- devices,
28
- connected,
29
- mirroring
30
- })
31
- ); --> returns a boolean
32
-
33
- this.deviceConnected.remove();
11
+ ```sh
12
+ yarn add react-native-airplay-module
34
13
  ```
35
14
 
36
- The result is an object that contains information about currently connected audio output(s):
15
+ ## Usage
37
16
 
38
17
  ```js
39
- {
40
- devices: [{
41
- deviceName: "Some Bluetooth Headphones Model",
42
- portType: "BluetoothA2DPOutput",
43
- isHeadphones: true
44
- }],
45
- connected: true,
46
- mirroring: false
47
- }
18
+ import AirPlay from 'react-native-airplay-module'
48
19
 
49
- // or
50
- {
51
- devices: [{
52
- deviceName: "Speakers",
53
- portType: "Speakers",
54
- isHeadphones: false
55
- }],
56
- connected: true,
57
- mirroring: false
58
- }
20
+ useEffect(() => {
21
+ AirPlay.startScan()
59
22
 
60
- // or
61
- {
62
- devices: [{
63
- deviceName: "Andrey’s Apple TV",
64
- portType: "AirPlay",
65
- isHeadphones: false
66
- }],
67
- connected: true,
68
- mirroring: true
69
- }
70
- ```
23
+ AirPlay.AirPlayListener.addListener('deviceConnected', ({ devices }) => {
24
+ console.log(devices)
25
+ })
71
26
 
72
- ## Methods
27
+ return () => {
28
+ AirPlay.disconnect()
29
+ }
30
+ }, [])
73
31
 
74
- ```js
75
- AirPlay.startScan();
32
+ const openMenu = () => {
33
+ AirPlay.openMenu()
34
+ }
76
35
 
77
- AirPlay.disconnect();
78
36
  ```
79
37
 
80
- ## Author
81
-
82
- Original author of the library:
83
-
84
- Nadia Dillon
85
-
86
- Modifications:
87
-
88
- Andrey Efremov (gazedash)
38
+ ## Contributing
89
39
 
90
- Spicy Sparks
40
+ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
91
41
 
92
- ## Contributing
42
+ ## License
93
43
 
94
- Pull requests are welcome!
44
+ MIT
@@ -0,0 +1,99 @@
1
+ buildscript {
2
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3
+ def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["AirplayModule_kotlinVersion"]
4
+
5
+ repositories {
6
+ google()
7
+ mavenCentral()
8
+ }
9
+
10
+ dependencies {
11
+ classpath "com.android.tools.build:gradle:7.2.1"
12
+ // noinspection DifferentKotlinGradleVersion
13
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
+ }
15
+ }
16
+
17
+ def reactNativeArchitectures() {
18
+ def value = rootProject.getProperties().get("reactNativeArchitectures")
19
+ return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
20
+ }
21
+
22
+ def isNewArchitectureEnabled() {
23
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
24
+ }
25
+
26
+ apply plugin: "com.android.library"
27
+ apply plugin: "kotlin-android"
28
+
29
+ if (isNewArchitectureEnabled()) {
30
+ apply plugin: "com.facebook.react"
31
+ }
32
+
33
+ def getExtOrDefault(name) {
34
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["AirplayModule_" + name]
35
+ }
36
+
37
+ def getExtOrIntegerDefault(name) {
38
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["AirplayModule_" + name]).toInteger()
39
+ }
40
+
41
+ def supportsNamespace() {
42
+ def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
43
+ def major = parsed[0].toInteger()
44
+ def minor = parsed[1].toInteger()
45
+
46
+ // Namespace support was added in 7.3.0
47
+ return (major == 7 && minor >= 3) || major >= 8
48
+ }
49
+
50
+ android {
51
+ if (supportsNamespace()) {
52
+ namespace "com.airplaymodule"
53
+
54
+ sourceSets {
55
+ main {
56
+ manifest.srcFile "src/main/AndroidManifestNew.xml"
57
+ }
58
+ }
59
+ }
60
+
61
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
62
+
63
+ defaultConfig {
64
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
65
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
66
+
67
+ }
68
+
69
+ buildTypes {
70
+ release {
71
+ minifyEnabled false
72
+ }
73
+ }
74
+
75
+ lintOptions {
76
+ disable "GradleCompatible"
77
+ }
78
+
79
+ compileOptions {
80
+ sourceCompatibility JavaVersion.VERSION_1_8
81
+ targetCompatibility JavaVersion.VERSION_1_8
82
+ }
83
+ }
84
+
85
+ repositories {
86
+ mavenCentral()
87
+ google()
88
+ }
89
+
90
+ def kotlin_version = getExtOrDefault("kotlinVersion")
91
+
92
+ dependencies {
93
+ // For < 0.71, this will be from the local maven repo
94
+ // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
95
+ //noinspection GradleDynamicVersion
96
+ implementation "com.facebook.react:react-native:+"
97
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
98
+ }
99
+
@@ -0,0 +1,5 @@
1
+ AirplayModule_kotlinVersion=1.7.0
2
+ AirplayModule_minSdkVersion=21
3
+ AirplayModule_targetSdkVersion=31
4
+ AirplayModule_compileSdkVersion=31
5
+ AirplayModule_ndkversion=21.4.7075529
@@ -0,0 +1,3 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.airplaymodule">
3
+ </manifest>
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,25 @@
1
+ package com.airplaymodule
2
+
3
+ import com.facebook.react.bridge.ReactApplicationContext
4
+ import com.facebook.react.bridge.ReactContextBaseJavaModule
5
+ import com.facebook.react.bridge.ReactMethod
6
+ import com.facebook.react.bridge.Promise
7
+
8
+ class AirplayModuleModule(reactContext: ReactApplicationContext) :
9
+ ReactContextBaseJavaModule(reactContext) {
10
+
11
+ override fun getName(): String {
12
+ return NAME
13
+ }
14
+
15
+ // Example method
16
+ // See https://reactnative.dev/docs/native-modules-android
17
+ @ReactMethod
18
+ fun multiply(a: Double, b: Double, promise: Promise) {
19
+ promise.resolve(a * b)
20
+ }
21
+
22
+ companion object {
23
+ const val NAME = "AirplayModule"
24
+ }
25
+ }
@@ -0,0 +1,17 @@
1
+ package com.airplaymodule
2
+
3
+ import com.facebook.react.ReactPackage
4
+ import com.facebook.react.bridge.NativeModule
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.uimanager.ViewManager
7
+
8
+
9
+ class AirplayModulePackage : ReactPackage {
10
+ override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
11
+ return listOf(AirplayModuleModule(reactContext))
12
+ }
13
+
14
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
15
+ return emptyList()
16
+ }
17
+ }
@@ -3,4 +3,4 @@
3
3
 
4
4
  @interface AirplayModule : RCTEventEmitter <RCTBridgeModule>
5
5
 
6
- @end
6
+ @end
@@ -1,6 +1,7 @@
1
1
  #import "AirplayModule.h"
2
2
  #import <AVFoundation/AVFoundation.h>
3
3
  #import <AudioToolbox/AudioToolbox.h>
4
+ #import <AVKit/AVKit.h>
4
5
 
5
6
  @implementation AirplayModule
6
7
  @synthesize bridge = _bridge;
@@ -27,6 +28,20 @@ RCT_EXPORT_METHOD(disconnect) {
27
28
  [[NSNotificationCenter defaultCenter] removeObserver:self];
28
29
  }
29
30
 
31
+ RCT_EXPORT_METHOD(openMenu)
32
+ {
33
+ dispatch_async(dispatch_get_main_queue(), ^{
34
+ AVRoutePickerView *routePickerView = [[AVRoutePickerView alloc] init];
35
+ for (UIView *subview in routePickerView.subviews) {
36
+ if ([subview isKindOfClass:[UIButton class]]) {
37
+ UIButton *button = (UIButton *)subview;
38
+ [button sendActionsForControlEvents:UIControlEventTouchUpInside];
39
+ break;
40
+ }
41
+ }
42
+ });
43
+ }
44
+
30
45
  - (void)routeChanged:(NSNotification *)sender {
31
46
  [self sendInformations];
32
47
  }
@@ -3,15 +3,26 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.AirPlayListener = exports.AirPlay = void 0;
7
-
6
+ exports.default = void 0;
8
7
  var _reactNative = require("react-native");
9
-
10
- const {
11
- AirplayModule
12
- } = _reactNative.NativeModules;
13
- const AirPlay = AirplayModule;
14
- exports.AirPlay = AirPlay;
8
+ const AirplayModule = _reactNative.NativeModules.AirplayModule;
15
9
  const AirPlayListener = new _reactNative.NativeEventEmitter(AirplayModule);
16
- exports.AirPlayListener = AirPlayListener;
10
+ const startScan = function () {
11
+ if (_reactNative.Platform.OS !== 'ios' || !AirplayModule) return;
12
+ return AirplayModule.startScan();
13
+ };
14
+ const disconnect = function () {
15
+ if (_reactNative.Platform.OS !== 'ios' || !AirplayModule) return;
16
+ return AirplayModule.disconnect();
17
+ };
18
+ const openMenu = function () {
19
+ if (_reactNative.Platform.OS !== 'ios' || !AirplayModule) return;
20
+ return AirplayModule.openMenu();
21
+ };
22
+ var _default = exports.default = {
23
+ AirPlayListener,
24
+ startScan,
25
+ disconnect,
26
+ openMenu
27
+ };
17
28
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":["AirplayModule","NativeModules","AirPlay","AirPlayListener","NativeEventEmitter"],"mappings":";;;;;;;AAAA;;AAKA,MAAM;AAAEA,EAAAA;AAAF,IAAoBC,0BAA1B;AAEO,MAAMC,OAAO,GAAGF,aAAhB;;AAEA,MAAMG,eAAe,GAAG,IAAIC,+BAAJ,CAAuBJ,aAAvB,CAAxB","sourcesContent":["import {\n NativeModules,\n NativeEventEmitter,\n} from \"react-native\"\n\nconst { AirplayModule } = NativeModules\n\nexport const AirPlay = AirplayModule\n\nexport const AirPlayListener = new NativeEventEmitter(AirplayModule)\n"]}
1
+ {"version":3,"names":["_reactNative","require","AirplayModule","NativeModules","AirPlayListener","NativeEventEmitter","startScan","Platform","OS","disconnect","openMenu","_default","exports","default"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,MAAMC,aAAa,GAAGC,0BAAa,CAACD,aAAa;AAEjD,MAAME,eAAe,GAAG,IAAIC,+BAAkB,CAACH,aAAa,CAAC;AAE7D,MAAMI,SAAS,GAAG,SAAAA,CAAA,EAAY;EAC5B,IAAIC,qBAAQ,CAACC,EAAE,KAAK,KAAK,IAAI,CAACN,aAAa,EAAE;EAC7C,OAAOA,aAAa,CAACI,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,MAAMG,UAAU,GAAG,SAAAA,CAAA,EAAY;EAC7B,IAAIF,qBAAQ,CAACC,EAAE,KAAK,KAAK,IAAI,CAACN,aAAa,EAAE;EAC7C,OAAOA,aAAa,CAACO,UAAU,CAAC,CAAC;AACnC,CAAC;AAED,MAAMC,QAAQ,GAAG,SAAAA,CAAA,EAAY;EAC3B,IAAIH,qBAAQ,CAACC,EAAE,KAAK,KAAK,IAAI,CAACN,aAAa,EAAE;EAC7C,OAAOA,aAAa,CAACQ,QAAQ,CAAC,CAAC;AACjC,CAAC;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa;EACbT,eAAe;EACfE,SAAS;EACTG,UAAU;EACVC;AACF,CAAC","ignoreList":[]}
@@ -1,7 +1,22 @@
1
- import { NativeModules, NativeEventEmitter } from "react-native";
2
- const {
3
- AirplayModule
4
- } = NativeModules;
5
- export const AirPlay = AirplayModule;
6
- export const AirPlayListener = new NativeEventEmitter(AirplayModule);
1
+ import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
2
+ const AirplayModule = NativeModules.AirplayModule;
3
+ const AirPlayListener = new NativeEventEmitter(AirplayModule);
4
+ const startScan = function () {
5
+ if (Platform.OS !== 'ios' || !AirplayModule) return;
6
+ return AirplayModule.startScan();
7
+ };
8
+ const disconnect = function () {
9
+ if (Platform.OS !== 'ios' || !AirplayModule) return;
10
+ return AirplayModule.disconnect();
11
+ };
12
+ const openMenu = function () {
13
+ if (Platform.OS !== 'ios' || !AirplayModule) return;
14
+ return AirplayModule.openMenu();
15
+ };
16
+ export default {
17
+ AirPlayListener,
18
+ startScan,
19
+ disconnect,
20
+ openMenu
21
+ };
7
22
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["index.tsx"],"names":["NativeModules","NativeEventEmitter","AirplayModule","AirPlay","AirPlayListener"],"mappings":"AAAA,SACEA,aADF,EAEEC,kBAFF,QAGO,cAHP;AAKA,MAAM;AAAEC,EAAAA;AAAF,IAAoBF,aAA1B;AAEA,OAAO,MAAMG,OAAO,GAAGD,aAAhB;AAEP,OAAO,MAAME,eAAe,GAAG,IAAIH,kBAAJ,CAAuBC,aAAvB,CAAxB","sourcesContent":["import {\n NativeModules,\n NativeEventEmitter,\n} from \"react-native\"\n\nconst { AirplayModule } = NativeModules\n\nexport const AirPlay = AirplayModule\n\nexport const AirPlayListener = new NativeEventEmitter(AirplayModule)\n"]}
1
+ {"version":3,"names":["NativeModules","NativeEventEmitter","Platform","AirplayModule","AirPlayListener","startScan","OS","disconnect","openMenu"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":"AAAA,SAASA,aAAa,EAAEC,kBAAkB,EAAEC,QAAQ,QAAQ,cAAc;AAE1E,MAAMC,aAAa,GAAGH,aAAa,CAACG,aAAa;AAEjD,MAAMC,eAAe,GAAG,IAAIH,kBAAkB,CAACE,aAAa,CAAC;AAE7D,MAAME,SAAS,GAAG,SAAAA,CAAA,EAAY;EAC5B,IAAIH,QAAQ,CAACI,EAAE,KAAK,KAAK,IAAI,CAACH,aAAa,EAAE;EAC7C,OAAOA,aAAa,CAACE,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,MAAME,UAAU,GAAG,SAAAA,CAAA,EAAY;EAC7B,IAAIL,QAAQ,CAACI,EAAE,KAAK,KAAK,IAAI,CAACH,aAAa,EAAE;EAC7C,OAAOA,aAAa,CAACI,UAAU,CAAC,CAAC;AACnC,CAAC;AAED,MAAMC,QAAQ,GAAG,SAAAA,CAAA,EAAY;EAC3B,IAAIN,QAAQ,CAACI,EAAE,KAAK,KAAK,IAAI,CAACH,aAAa,EAAE;EAC7C,OAAOA,aAAa,CAACK,QAAQ,CAAC,CAAC;AACjC,CAAC;AAED,eAAe;EACbJ,eAAe;EACfC,SAAS;EACTE,UAAU;EACVC;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ import { NativeEventEmitter } from 'react-native';
2
+ declare const _default: {
3
+ AirPlayListener: NativeEventEmitter;
4
+ startScan: () => any;
5
+ disconnect: () => any;
6
+ openMenu: () => any;
7
+ };
8
+ export default _default;
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,kBAAkB,EAAY,MAAM,cAAc,CAAC;;;;;;;AAqB3E,wBAKE"}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "react-native-airplay-module",
3
- "version": "0.2.1",
4
- "description": "AirPlay library for React Native",
3
+ "version": "0.2.3",
4
+ "description": "React Native Airplay module",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
7
- "types": "lib/typescript/index.d.ts",
7
+ "types": "lib/typescript/src/index.d.ts",
8
8
  "react-native": "src/index",
9
9
  "source": "src/index",
10
10
  "files": [
@@ -13,31 +13,37 @@
13
13
  "android",
14
14
  "ios",
15
15
  "cpp",
16
- "react-native-airplay-module.podspec",
17
- "!lib/typescript/example",
18
- "!android/build",
16
+ "*.podspec",
19
17
  "!ios/build",
18
+ "!android/build",
19
+ "!android/gradle",
20
+ "!android/gradlew",
21
+ "!android/gradlew.bat",
22
+ "!android/local.properties",
20
23
  "!**/__tests__",
21
24
  "!**/__fixtures__",
22
- "!**/__mocks__"
25
+ "!**/__mocks__",
26
+ "!**/.*"
23
27
  ],
24
28
  "scripts": {
29
+ "example": "yarn workspace react-native-airplay-module-example",
25
30
  "test": "jest",
26
- "typescript": "tsc --noEmit",
31
+ "typecheck": "tsc --noEmit",
27
32
  "lint": "eslint \"**/*.{js,ts,tsx}\"",
33
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
28
34
  "prepare": "bob build",
29
- "release": "release-it",
30
- "example": "yarn --cwd example",
31
- "pods": "cd example && pod-install --quiet",
32
- "bootstrap": "yarn example && yarn && yarn pods"
35
+ "release": "release-it"
33
36
  },
34
37
  "keywords": [
35
38
  "react-native",
36
39
  "ios",
37
40
  "android"
38
41
  ],
39
- "repository": "https://github.com/Spicy-Sparks/react-native-airplay-module",
40
- "author": "Spicy Sparks <support@spicysparks.com> (https://github.com/Spicy-Sparks)",
42
+ "repository": {
43
+ "type": "git",
44
+ "url": "git+https://github.com/Spicy-Sparks/react-native-airplay-module.git"
45
+ },
46
+ "author": "Spicy Sparks <hello@spicysparks.com> (https://github.com/Spicy-Sparks)",
41
47
  "license": "MIT",
42
48
  "bugs": {
43
49
  "url": "https://github.com/Spicy-Sparks/react-native-airplay-module/issues"
@@ -47,30 +53,37 @@
47
53
  "registry": "https://registry.npmjs.org/"
48
54
  },
49
55
  "devDependencies": {
50
- "@commitlint/config-conventional": "^11.0.0",
51
- "@react-native-community/eslint-config": "^2.0.0",
52
- "@release-it/conventional-changelog": "^2.0.0",
53
- "@types/jest": "^26.0.0",
54
- "@types/react": "^16.9.19",
55
- "@types/react-native": "0.62.13",
56
- "commitlint": "^11.0.0",
57
- "eslint": "^7.2.0",
58
- "eslint-config-prettier": "^7.0.0",
59
- "eslint-plugin-prettier": "^3.1.3",
60
- "husky": "^4.2.5",
61
- "jest": "^26.0.1",
62
- "pod-install": "^0.1.0",
63
- "prettier": "^2.0.5",
64
- "react": "16.13.1",
65
- "react-native": "0.63.4",
66
- "react-native-builder-bob": "^0.18.0",
67
- "release-it": "^14.2.2",
68
- "typescript": "^4.1.3"
56
+ "@commitlint/config-conventional": "^17.0.2",
57
+ "@evilmartians/lefthook": "^1.5.0",
58
+ "@react-native/eslint-config": "^0.73.1",
59
+ "@release-it/conventional-changelog": "^5.0.0",
60
+ "@types/jest": "^29.5.5",
61
+ "@types/react": "^18.2.44",
62
+ "commitlint": "^17.0.2",
63
+ "del-cli": "^5.1.0",
64
+ "eslint": "^8.51.0",
65
+ "eslint-config-prettier": "^9.0.0",
66
+ "eslint-plugin-prettier": "^5.0.1",
67
+ "jest": "^29.7.0",
68
+ "prettier": "^3.0.3",
69
+ "react": "18.2.0",
70
+ "react-native": "0.74.2",
71
+ "react-native-builder-bob": "^0.23.2",
72
+ "release-it": "^15.0.0",
73
+ "turbo": "^1.10.7",
74
+ "typescript": "^5.2.2"
75
+ },
76
+ "resolutions": {
77
+ "@types/react": "^18.2.44"
69
78
  },
70
79
  "peerDependencies": {
71
80
  "react": "*",
72
81
  "react-native": "*"
73
82
  },
83
+ "workspaces": [
84
+ "example"
85
+ ],
86
+ "packageManager": "yarn@3.6.1",
74
87
  "jest": {
75
88
  "preset": "react-native",
76
89
  "modulePathIgnorePatterns": [
@@ -103,7 +116,7 @@
103
116
  "eslintConfig": {
104
117
  "root": true,
105
118
  "extends": [
106
- "@react-native-community",
119
+ "@react-native",
107
120
  "prettier"
108
121
  ],
109
122
  "rules": {
@@ -1,6 +1,7 @@
1
1
  require "json"
2
2
 
3
3
  package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
4
5
 
5
6
  Pod::Spec.new do |s|
6
7
  s.name = "react-native-airplay-module"
@@ -10,10 +11,31 @@ Pod::Spec.new do |s|
10
11
  s.license = package["license"]
11
12
  s.authors = package["author"]
12
13
 
13
- s.platforms = { :ios => "10.0" }
14
+ s.platforms = { :ios => min_ios_version_supported }
14
15
  s.source = { :git => "https://github.com/Spicy-Sparks/react-native-airplay-module.git", :tag => "#{s.version}" }
15
16
 
16
17
  s.source_files = "ios/**/*.{h,m,mm}"
17
18
 
18
- s.dependency "React-Core"
19
+ # Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
20
+ # See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
21
+ if respond_to?(:install_modules_dependencies, true)
22
+ install_modules_dependencies(s)
23
+ else
24
+ s.dependency "React-Core"
25
+
26
+ # Don't install the dependencies when we run `pod install` in the old architecture.
27
+ if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
28
+ s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
29
+ s.pod_target_xcconfig = {
30
+ "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
31
+ "OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
32
+ "CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
33
+ }
34
+ s.dependency "React-Codegen"
35
+ s.dependency "RCT-Folly"
36
+ s.dependency "RCTRequired"
37
+ s.dependency "RCTTypeSafety"
38
+ s.dependency "ReactCommon/turbomodule/core"
39
+ end
40
+ end
19
41
  end
package/src/index.tsx CHANGED
@@ -1,10 +1,27 @@
1
- import {
2
- NativeModules,
3
- NativeEventEmitter,
4
- } from "react-native"
1
+ import { NativeModules, NativeEventEmitter, Platform } from 'react-native';
5
2
 
6
- const { AirplayModule } = NativeModules
3
+ const AirplayModule = NativeModules.AirplayModule;
7
4
 
8
- export const AirPlay = AirplayModule
5
+ const AirPlayListener = new NativeEventEmitter(AirplayModule);
9
6
 
10
- export const AirPlayListener = new NativeEventEmitter(AirplayModule)
7
+ const startScan = function () {
8
+ if (Platform.OS !== 'ios' || !AirplayModule) return;
9
+ return AirplayModule.startScan();
10
+ };
11
+
12
+ const disconnect = function () {
13
+ if (Platform.OS !== 'ios' || !AirplayModule) return;
14
+ return AirplayModule.disconnect();
15
+ };
16
+
17
+ const openMenu = function () {
18
+ if (Platform.OS !== 'ios' || !AirplayModule) return;
19
+ return AirplayModule.openMenu();
20
+ };
21
+
22
+ export default {
23
+ AirPlayListener,
24
+ startScan,
25
+ disconnect,
26
+ openMenu,
27
+ };
@@ -1,282 +0,0 @@
1
- // !$*UTF8*$!
2
- {
3
- archiveVersion = 1;
4
- classes = {
5
- };
6
- objectVersion = 46;
7
- objects = {
8
-
9
- /* Begin PBXBuildFile section */
10
-
11
- 5E555C0D2413F4C50049A1A2 /* AirplayModule.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* AirplayModule.m */; };
12
-
13
- /* End PBXBuildFile section */
14
-
15
- /* Begin PBXCopyFilesBuildPhase section */
16
- 58B511D91A9E6C8500147676 /* CopyFiles */ = {
17
- isa = PBXCopyFilesBuildPhase;
18
- buildActionMask = 2147483647;
19
- dstPath = "include/$(PRODUCT_NAME)";
20
- dstSubfolderSpec = 16;
21
- files = (
22
- );
23
- runOnlyForDeploymentPostprocessing = 0;
24
- };
25
- /* End PBXCopyFilesBuildPhase section */
26
-
27
- /* Begin PBXFileReference section */
28
- 134814201AA4EA6300B7C361 /* libAirplayModule.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libAirplayModule.a; sourceTree = BUILT_PRODUCTS_DIR; };
29
-
30
- B3E7B5881CC2AC0600A0062D /* AirplayModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AirplayModule.h; sourceTree = "<group>"; };
31
- B3E7B5891CC2AC0600A0062D /* AirplayModule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AirplayModule.m; sourceTree = "<group>"; };
32
-
33
- /* End PBXFileReference section */
34
-
35
- /* Begin PBXFrameworksBuildPhase section */
36
- 58B511D81A9E6C8500147676 /* Frameworks */ = {
37
- isa = PBXFrameworksBuildPhase;
38
- buildActionMask = 2147483647;
39
- files = (
40
- );
41
- runOnlyForDeploymentPostprocessing = 0;
42
- };
43
- /* End PBXFrameworksBuildPhase section */
44
-
45
- /* Begin PBXGroup section */
46
- 134814211AA4EA7D00B7C361 /* Products */ = {
47
- isa = PBXGroup;
48
- children = (
49
- 134814201AA4EA6300B7C361 /* libAirplayModule.a */,
50
- );
51
- name = Products;
52
- sourceTree = "<group>";
53
- };
54
- 58B511D21A9E6C8500147676 = {
55
- isa = PBXGroup;
56
- children = (
57
-
58
- B3E7B5881CC2AC0600A0062D /* AirplayModule.h */,
59
- B3E7B5891CC2AC0600A0062D /* AirplayModule.m */,
60
-
61
- 134814211AA4EA7D00B7C361 /* Products */,
62
- );
63
- sourceTree = "<group>";
64
- };
65
- /* End PBXGroup section */
66
-
67
- /* Begin PBXNativeTarget section */
68
- 58B511DA1A9E6C8500147676 /* AirplayModule */ = {
69
- isa = PBXNativeTarget;
70
- buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "AirplayModule" */;
71
- buildPhases = (
72
- 58B511D71A9E6C8500147676 /* Sources */,
73
- 58B511D81A9E6C8500147676 /* Frameworks */,
74
- 58B511D91A9E6C8500147676 /* CopyFiles */,
75
- );
76
- buildRules = (
77
- );
78
- dependencies = (
79
- );
80
- name = AirplayModule;
81
- productName = RCTDataManager;
82
- productReference = 134814201AA4EA6300B7C361 /* libAirplayModule.a */;
83
- productType = "com.apple.product-type.library.static";
84
- };
85
- /* End PBXNativeTarget section */
86
-
87
- /* Begin PBXProject section */
88
- 58B511D31A9E6C8500147676 /* Project object */ = {
89
- isa = PBXProject;
90
- attributes = {
91
- LastUpgradeCheck = 0920;
92
- ORGANIZATIONNAME = Facebook;
93
- TargetAttributes = {
94
- 58B511DA1A9E6C8500147676 = {
95
- CreatedOnToolsVersion = 6.1.1;
96
- };
97
- };
98
- };
99
- buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "AirplayModule" */;
100
- compatibilityVersion = "Xcode 3.2";
101
- developmentRegion = English;
102
- hasScannedForEncodings = 0;
103
- knownRegions = (
104
- English,
105
- en,
106
- );
107
- mainGroup = 58B511D21A9E6C8500147676;
108
- productRefGroup = 58B511D21A9E6C8500147676;
109
- projectDirPath = "";
110
- projectRoot = "";
111
- targets = (
112
- 58B511DA1A9E6C8500147676 /* AirplayModule */,
113
- );
114
- };
115
- /* End PBXProject section */
116
-
117
- /* Begin PBXSourcesBuildPhase section */
118
- 58B511D71A9E6C8500147676 /* Sources */ = {
119
- isa = PBXSourcesBuildPhase;
120
- buildActionMask = 2147483647;
121
- files = (
122
-
123
- B3E7B58A1CC2AC0600A0062D /* AirplayModule.m in Sources */,
124
-
125
- );
126
- runOnlyForDeploymentPostprocessing = 0;
127
- };
128
- /* End PBXSourcesBuildPhase section */
129
-
130
- /* Begin XCBuildConfiguration section */
131
- 58B511ED1A9E6C8500147676 /* Debug */ = {
132
- isa = XCBuildConfiguration;
133
- buildSettings = {
134
- ALWAYS_SEARCH_USER_PATHS = NO;
135
- CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
136
- CLANG_CXX_LIBRARY = "libc++";
137
- CLANG_ENABLE_MODULES = YES;
138
- CLANG_ENABLE_OBJC_ARC = YES;
139
- CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
140
- CLANG_WARN_BOOL_CONVERSION = YES;
141
- CLANG_WARN_COMMA = YES;
142
- CLANG_WARN_CONSTANT_CONVERSION = YES;
143
- CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
144
- CLANG_WARN_EMPTY_BODY = YES;
145
- CLANG_WARN_ENUM_CONVERSION = YES;
146
- CLANG_WARN_INFINITE_RECURSION = YES;
147
- CLANG_WARN_INT_CONVERSION = YES;
148
- CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
149
- CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
150
- CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
151
- CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
152
- CLANG_WARN_STRICT_PROTOTYPES = YES;
153
- CLANG_WARN_SUSPICIOUS_MOVE = YES;
154
- CLANG_WARN_UNREACHABLE_CODE = YES;
155
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
156
- COPY_PHASE_STRIP = NO;
157
- ENABLE_STRICT_OBJC_MSGSEND = YES;
158
- ENABLE_TESTABILITY = YES;
159
- GCC_C_LANGUAGE_STANDARD = gnu99;
160
- GCC_DYNAMIC_NO_PIC = NO;
161
- GCC_NO_COMMON_BLOCKS = YES;
162
- GCC_OPTIMIZATION_LEVEL = 0;
163
- GCC_PREPROCESSOR_DEFINITIONS = (
164
- "DEBUG=1",
165
- "$(inherited)",
166
- );
167
- GCC_SYMBOLS_PRIVATE_EXTERN = NO;
168
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
169
- GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
170
- GCC_WARN_UNDECLARED_SELECTOR = YES;
171
- GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
172
- GCC_WARN_UNUSED_FUNCTION = YES;
173
- GCC_WARN_UNUSED_VARIABLE = YES;
174
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
175
- MTL_ENABLE_DEBUG_INFO = YES;
176
- ONLY_ACTIVE_ARCH = YES;
177
- SDKROOT = iphoneos;
178
- };
179
- name = Debug;
180
- };
181
- 58B511EE1A9E6C8500147676 /* Release */ = {
182
- isa = XCBuildConfiguration;
183
- buildSettings = {
184
- ALWAYS_SEARCH_USER_PATHS = NO;
185
- CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
186
- CLANG_CXX_LIBRARY = "libc++";
187
- CLANG_ENABLE_MODULES = YES;
188
- CLANG_ENABLE_OBJC_ARC = YES;
189
- CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
190
- CLANG_WARN_BOOL_CONVERSION = YES;
191
- CLANG_WARN_COMMA = YES;
192
- CLANG_WARN_CONSTANT_CONVERSION = YES;
193
- CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
194
- CLANG_WARN_EMPTY_BODY = YES;
195
- CLANG_WARN_ENUM_CONVERSION = YES;
196
- CLANG_WARN_INFINITE_RECURSION = YES;
197
- CLANG_WARN_INT_CONVERSION = YES;
198
- CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
199
- CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
200
- CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
201
- CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
202
- CLANG_WARN_STRICT_PROTOTYPES = YES;
203
- CLANG_WARN_SUSPICIOUS_MOVE = YES;
204
- CLANG_WARN_UNREACHABLE_CODE = YES;
205
- CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
206
- COPY_PHASE_STRIP = YES;
207
- ENABLE_NS_ASSERTIONS = NO;
208
- ENABLE_STRICT_OBJC_MSGSEND = YES;
209
- GCC_C_LANGUAGE_STANDARD = gnu99;
210
- GCC_NO_COMMON_BLOCKS = YES;
211
- GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
212
- GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
213
- GCC_WARN_UNDECLARED_SELECTOR = YES;
214
- GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
215
- GCC_WARN_UNUSED_FUNCTION = YES;
216
- GCC_WARN_UNUSED_VARIABLE = YES;
217
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
218
- MTL_ENABLE_DEBUG_INFO = NO;
219
- SDKROOT = iphoneos;
220
- VALIDATE_PRODUCT = YES;
221
- };
222
- name = Release;
223
- };
224
- 58B511F01A9E6C8500147676 /* Debug */ = {
225
- isa = XCBuildConfiguration;
226
- buildSettings = {
227
- HEADER_SEARCH_PATHS = (
228
- "$(inherited)",
229
- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
230
- "$(SRCROOT)/../../../React/**",
231
- "$(SRCROOT)/../../react-native/React/**",
232
- );
233
- LIBRARY_SEARCH_PATHS = "$(inherited)";
234
- OTHER_LDFLAGS = "-ObjC";
235
- PRODUCT_NAME = AirplayModule;
236
- SKIP_INSTALL = YES;
237
-
238
- };
239
- name = Debug;
240
- };
241
- 58B511F11A9E6C8500147676 /* Release */ = {
242
- isa = XCBuildConfiguration;
243
- buildSettings = {
244
- HEADER_SEARCH_PATHS = (
245
- "$(inherited)",
246
- /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
247
- "$(SRCROOT)/../../../React/**",
248
- "$(SRCROOT)/../../react-native/React/**",
249
- );
250
- LIBRARY_SEARCH_PATHS = "$(inherited)";
251
- OTHER_LDFLAGS = "-ObjC";
252
- PRODUCT_NAME = AirplayModule;
253
- SKIP_INSTALL = YES;
254
-
255
- };
256
- name = Release;
257
- };
258
- /* End XCBuildConfiguration section */
259
-
260
- /* Begin XCConfigurationList section */
261
- 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "AirplayModule" */ = {
262
- isa = XCConfigurationList;
263
- buildConfigurations = (
264
- 58B511ED1A9E6C8500147676 /* Debug */,
265
- 58B511EE1A9E6C8500147676 /* Release */,
266
- );
267
- defaultConfigurationIsVisible = 0;
268
- defaultConfigurationName = Release;
269
- };
270
- 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "AirplayModule" */ = {
271
- isa = XCConfigurationList;
272
- buildConfigurations = (
273
- 58B511F01A9E6C8500147676 /* Debug */,
274
- 58B511F11A9E6C8500147676 /* Release */,
275
- );
276
- defaultConfigurationIsVisible = 0;
277
- defaultConfigurationName = Release;
278
- };
279
- /* End XCConfigurationList section */
280
- };
281
- rootObject = 58B511D31A9E6C8500147676 /* Project object */;
282
- }
@@ -1,4 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Workspace
3
- version = "1.0">
4
- </Workspace>
@@ -1,8 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>IDEDidComputeMac32BitWarning</key>
6
- <true/>
7
- </dict>
8
- </plist>
@@ -1,14 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
- <plist version="1.0">
4
- <dict>
5
- <key>SchemeUserState</key>
6
- <dict>
7
- <key>AirplayModule.xcscheme_^#shared#^_</key>
8
- <dict>
9
- <key>orderHint</key>
10
- <integer>0</integer>
11
- </dict>
12
- </dict>
13
- </dict>
14
- </plist>
@@ -1,3 +0,0 @@
1
- import { NativeEventEmitter } from "react-native";
2
- export declare const AirPlay: any;
3
- export declare const AirPlayListener: NativeEventEmitter;