react-native-daro 1.0.15 → 1.0.16
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/android/build.gradle +11 -1
- package/android/src/main/java/com/daro/reactnative/DaroMAdBannerViewManager.kt +34 -11
- package/android/src/main/java/com/daro/reactnative/DaroMAdNativeViewManager.kt +79 -48
- package/android/src/main/java/com/daro/reactnative/DaroMModule.kt +80 -25
- package/android/src/main/java/com/daro/reactnative/DaroMPackage.kt +28 -4
- package/android/src/main/java/com/daro/reactnative/DaroMediaViewManager.kt +25 -0
- package/android/src/main/java/com/daro/reactnative/event/DaroMEvent.kt +18 -7
- package/android/src/main/java/com/daro/reactnative/util/EventEmitterUtil.kt +18 -5
- package/android/src/main/java/com/daro/reactnative/view/DaroMAdNativeViewContainer.kt +301 -52
- package/android/src/main/java/com/daro/reactnative/view/DaroMediaView.kt +123 -0
- package/android/src/newarch/java/com/daro/reactnative/DaroMModuleSpec.kt +6 -0
- package/android/src/oldarch/java/com/daro/reactnative/DaroMModuleSpec.kt +90 -0
- package/ios/DaroMModule+AppOpen.swift +13 -10
- package/ios/DaroMModule+Interstitial.swift +12 -9
- package/ios/DaroMModule+LightPopup.swift +16 -13
- package/ios/DaroMModule+Rewarded.swift +12 -9
- package/ios/DaroMModule.mm +45 -17
- package/ios/DaroMModule.swift +4 -4
- package/ios/Fabric/DaroMAdBannerComponentView.mm +207 -0
- package/ios/Fabric/DaroMFabricEventSink.mm +31 -0
- package/ios/Fabric/DaroMFabricPropApplier.mm +123 -0
- package/ios/Fabric/DaroMNativeAdComponentView.mm +294 -0
- package/ios/{DaroMAdBannerViewManager.m → Paper/DaroMAdBannerViewManager.m} +3 -1
- package/ios/Paper/DaroMAdBannerViewManager.swift +21 -0
- package/ios/{DaroMNativeAdViewManager.m → Paper/DaroMNativeAdViewManager.m} +2 -1
- package/ios/Paper/DaroMNativeAdViewManager.swift +22 -0
- package/ios/Shared/DaroMAdEventSink.swift +24 -0
- package/ios/Shared/DaroMBannerAdView.swift +188 -0
- package/ios/Shared/DaroMNativeAdLoadCoordinator.swift +49 -0
- package/ios/Shared/DaroMNativeAdView.swift +575 -0
- package/ios/Shared/DaroMNativeAssetResolver.swift +53 -0
- package/ios/mediation/admob/DaroMediationTypes.swift +1 -0
- package/lib/commonjs/AdBannerView.js +20 -39
- package/lib/commonjs/AdBannerView.js.map +1 -1
- package/lib/commonjs/AppOpenAd.js +43 -10
- package/lib/commonjs/AppOpenAd.js.map +1 -1
- package/lib/commonjs/DaroMAdBannerViewNativeComponent.ts +47 -0
- package/lib/commonjs/DaroMNativeAdViewNativeComponent.ts +62 -0
- package/lib/commonjs/DaroMediaViewNativeComponent.ts +9 -0
- package/lib/commonjs/EventEmitter.js +4 -5
- package/lib/commonjs/EventEmitter.js.map +1 -1
- package/lib/commonjs/InterstitialAd.js +9 -11
- package/lib/commonjs/InterstitialAd.js.map +1 -1
- package/lib/commonjs/LightPopupAd.js +11 -12
- package/lib/commonjs/LightPopupAd.js.map +1 -1
- package/lib/commonjs/NativeDaroModule.js +9 -0
- package/lib/commonjs/NativeDaroModule.js.map +1 -0
- package/lib/commonjs/RewardedAd.js +9 -11
- package/lib/commonjs/RewardedAd.js.map +1 -1
- package/lib/commonjs/codegen-env.d.js +2 -0
- package/lib/commonjs/codegen-env.d.js.map +1 -0
- package/lib/commonjs/hooks/useInterstitialAd.js +110 -0
- package/lib/commonjs/hooks/useInterstitialAd.js.map +1 -0
- package/lib/commonjs/hooks/useLightPopupAd.js +114 -0
- package/lib/commonjs/hooks/useLightPopupAd.js.map +1 -0
- package/lib/commonjs/hooks/useRewardedAd.js +113 -0
- package/lib/commonjs/hooks/useRewardedAd.js.map +1 -0
- package/lib/commonjs/index.js +29 -13
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/nativeAd/NativeAdView.js +23 -22
- package/lib/commonjs/nativeAd/NativeAdView.js.map +1 -1
- package/lib/commonjs/nativeAd/NativeAdViewComponents.js +43 -31
- package/lib/commonjs/nativeAd/NativeAdViewComponents.js.map +1 -1
- package/lib/commonjs/nativeAd/NativeAdViewProvider.js +34 -7
- package/lib/commonjs/nativeAd/NativeAdViewProvider.js.map +1 -1
- package/lib/module/AdBannerView.js +19 -40
- package/lib/module/AdBannerView.js.map +1 -1
- package/lib/module/AppOpenAd.js +43 -11
- package/lib/module/AppOpenAd.js.map +1 -1
- package/lib/module/DaroMAdBannerViewNativeComponent.ts +47 -0
- package/lib/module/DaroMNativeAdViewNativeComponent.ts +62 -0
- package/lib/module/DaroMediaViewNativeComponent.ts +9 -0
- package/lib/module/EventEmitter.js +4 -6
- package/lib/module/EventEmitter.js.map +1 -1
- package/lib/module/InterstitialAd.js +8 -11
- package/lib/module/InterstitialAd.js.map +1 -1
- package/lib/module/LightPopupAd.js +11 -13
- package/lib/module/LightPopupAd.js.map +1 -1
- package/lib/module/NativeDaroModule.js +5 -0
- package/lib/module/NativeDaroModule.js.map +1 -0
- package/lib/module/RewardedAd.js +8 -11
- package/lib/module/RewardedAd.js.map +1 -1
- package/lib/module/codegen-env.d.js +2 -0
- package/lib/module/codegen-env.d.js.map +1 -0
- package/lib/module/hooks/useInterstitialAd.js +106 -0
- package/lib/module/hooks/useInterstitialAd.js.map +1 -0
- package/lib/module/hooks/useLightPopupAd.js +110 -0
- package/lib/module/hooks/useLightPopupAd.js.map +1 -0
- package/lib/module/hooks/useRewardedAd.js +109 -0
- package/lib/module/hooks/useRewardedAd.js.map +1 -0
- package/lib/module/index.js +7 -13
- package/lib/module/index.js.map +1 -1
- package/lib/module/nativeAd/NativeAdView.js +22 -23
- package/lib/module/nativeAd/NativeAdView.js.map +1 -1
- package/lib/module/nativeAd/NativeAdViewComponents.js +45 -34
- package/lib/module/nativeAd/NativeAdViewComponents.js.map +1 -1
- package/lib/module/nativeAd/NativeAdViewProvider.js +35 -8
- package/lib/module/nativeAd/NativeAdViewProvider.js.map +1 -1
- package/lib/typescript/commonjs/plugin/src/index.d.ts +1 -1
- package/lib/typescript/commonjs/plugin/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/plugin/src/withAndroid.d.ts.map +1 -1
- package/lib/typescript/commonjs/plugin/src/withIos.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/AdBannerView.d.ts +2 -2
- package/lib/typescript/commonjs/src/AdBannerView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/AppOpenAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/DaroMAdBannerViewNativeComponent.d.ts +32 -0
- package/lib/typescript/commonjs/src/DaroMAdBannerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/DaroMNativeAdViewNativeComponent.d.ts +42 -0
- package/lib/typescript/commonjs/src/DaroMNativeAdViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/DaroMediaViewNativeComponent.d.ts +6 -0
- package/lib/typescript/commonjs/src/DaroMediaViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/EventEmitter.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/InterstitialAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/LightPopupAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/NativeDaroModule.d.ts +61 -0
- package/lib/typescript/commonjs/src/NativeDaroModule.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/RewardedAd.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/hooks/useInterstitialAd.d.ts +19 -0
- package/lib/typescript/commonjs/src/hooks/useInterstitialAd.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/useLightPopupAd.d.ts +23 -0
- package/lib/typescript/commonjs/src/hooks/useLightPopupAd.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/hooks/useRewardedAd.d.ts +20 -0
- package/lib/typescript/commonjs/src/hooks/useRewardedAd.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +7 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts +1 -0
- package/lib/typescript/commonjs/src/nativeAd/NativeAdView.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/nativeAd/NativeAdViewComponents.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/nativeAd/NativeAdViewProvider.d.ts +11 -5
- package/lib/typescript/commonjs/src/nativeAd/NativeAdViewProvider.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts +2 -0
- package/lib/typescript/commonjs/src/types/NativeAdViewProps.d.ts.map +1 -1
- package/lib/typescript/module/plugin/src/index.d.ts +1 -1
- package/lib/typescript/module/plugin/src/index.d.ts.map +1 -1
- package/lib/typescript/module/plugin/src/withAndroid.d.ts.map +1 -1
- package/lib/typescript/module/plugin/src/withIos.d.ts.map +1 -1
- package/lib/typescript/module/src/AdBannerView.d.ts +2 -2
- package/lib/typescript/module/src/AdBannerView.d.ts.map +1 -1
- package/lib/typescript/module/src/AppOpenAd.d.ts.map +1 -1
- package/lib/typescript/module/src/DaroMAdBannerViewNativeComponent.d.ts +32 -0
- package/lib/typescript/module/src/DaroMAdBannerViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/DaroMNativeAdViewNativeComponent.d.ts +42 -0
- package/lib/typescript/module/src/DaroMNativeAdViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/DaroMediaViewNativeComponent.d.ts +6 -0
- package/lib/typescript/module/src/DaroMediaViewNativeComponent.d.ts.map +1 -0
- package/lib/typescript/module/src/EventEmitter.d.ts.map +1 -1
- package/lib/typescript/module/src/InterstitialAd.d.ts.map +1 -1
- package/lib/typescript/module/src/LightPopupAd.d.ts.map +1 -1
- package/lib/typescript/module/src/NativeDaroModule.d.ts +61 -0
- package/lib/typescript/module/src/NativeDaroModule.d.ts.map +1 -0
- package/lib/typescript/module/src/RewardedAd.d.ts.map +1 -1
- package/lib/typescript/module/src/hooks/useInterstitialAd.d.ts +19 -0
- package/lib/typescript/module/src/hooks/useInterstitialAd.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/useLightPopupAd.d.ts +23 -0
- package/lib/typescript/module/src/hooks/useLightPopupAd.d.ts.map +1 -0
- package/lib/typescript/module/src/hooks/useRewardedAd.d.ts +20 -0
- package/lib/typescript/module/src/hooks/useRewardedAd.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +7 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts +1 -0
- package/lib/typescript/module/src/nativeAd/NativeAdView.d.ts.map +1 -1
- package/lib/typescript/module/src/nativeAd/NativeAdViewComponents.d.ts.map +1 -1
- package/lib/typescript/module/src/nativeAd/NativeAdViewProvider.d.ts +11 -5
- package/lib/typescript/module/src/nativeAd/NativeAdViewProvider.d.ts.map +1 -1
- package/lib/typescript/module/src/types/NativeAdViewProps.d.ts +2 -0
- package/lib/typescript/module/src/types/NativeAdViewProps.d.ts.map +1 -1
- package/package.json +12 -5
- package/plugin/build/index.d.ts +1 -1
- package/plugin/build/withAndroid.js +99 -17
- package/plugin/build/withIos.js +4 -5
- package/react-native-daro.podspec +3 -0
- package/src/AdBannerView.tsx +24 -61
- package/src/AppOpenAd.ts +46 -9
- package/src/DaroMAdBannerViewNativeComponent.ts +47 -0
- package/src/DaroMNativeAdViewNativeComponent.ts +62 -0
- package/src/DaroMediaViewNativeComponent.ts +9 -0
- package/src/EventEmitter.ts +4 -5
- package/src/InterstitialAd.ts +8 -10
- package/src/LightPopupAd.ts +11 -12
- package/src/NativeDaroModule.ts +91 -0
- package/src/RewardedAd.ts +8 -10
- package/src/codegen-env.d.ts +45 -0
- package/src/hooks/useInterstitialAd.ts +117 -0
- package/src/hooks/useLightPopupAd.ts +132 -0
- package/src/hooks/useRewardedAd.ts +122 -0
- package/src/index.tsx +21 -22
- package/src/nativeAd/NativeAdView.tsx +41 -54
- package/src/nativeAd/NativeAdViewComponents.tsx +80 -42
- package/src/nativeAd/NativeAdViewProvider.tsx +75 -17
- package/src/types/NativeAdViewProps.ts +7 -0
- package/ios/DaroMAdBannerViewManager.swift +0 -91
- package/ios/DaroMNativeAdViewManager.swift +0 -291
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-daro",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.16",
|
|
4
4
|
"description": "React Native module for the Daro SDK on Android and iOS",
|
|
5
5
|
"main": "./lib/commonjs/index.js",
|
|
6
6
|
"module": "./lib/module/index.js",
|
|
@@ -38,6 +38,9 @@
|
|
|
38
38
|
"!**/__fixtures__",
|
|
39
39
|
"!**/__mocks__",
|
|
40
40
|
"!**/.*",
|
|
41
|
+
"ios/Fabric",
|
|
42
|
+
"android/src/newarch",
|
|
43
|
+
"android/src/oldarch",
|
|
41
44
|
"plugin/build"
|
|
42
45
|
],
|
|
43
46
|
"scripts": {
|
|
@@ -87,7 +90,6 @@
|
|
|
87
90
|
"react": "19.1.0",
|
|
88
91
|
"react-native": "0.81.5",
|
|
89
92
|
"react-native-builder-bob": "^0.41.0",
|
|
90
|
-
"release-it": "^19.2.4",
|
|
91
93
|
"turbo": "^2.8.21",
|
|
92
94
|
"typescript": "~5.9.3"
|
|
93
95
|
},
|
|
@@ -128,8 +130,14 @@
|
|
|
128
130
|
},
|
|
129
131
|
"codegenConfig": {
|
|
130
132
|
"name": "DaroReactNativeSpec",
|
|
131
|
-
"type": "
|
|
133
|
+
"type": "all",
|
|
132
134
|
"jsSrcsDir": "src",
|
|
135
|
+
"ios": {
|
|
136
|
+
"componentProvider": {
|
|
137
|
+
"DaroMAdBannerView": "DaroMAdBannerViewComponentView",
|
|
138
|
+
"DaroMNativeAdView": "DaroMNativeAdViewComponentView"
|
|
139
|
+
}
|
|
140
|
+
},
|
|
133
141
|
"android": {
|
|
134
142
|
"javaPackageName": "com.daro.reactnative"
|
|
135
143
|
}
|
|
@@ -164,8 +172,7 @@
|
|
|
164
172
|
"tools": [
|
|
165
173
|
"eslint",
|
|
166
174
|
"jest",
|
|
167
|
-
"lefthook"
|
|
168
|
-
"release-it"
|
|
175
|
+
"lefthook"
|
|
169
176
|
],
|
|
170
177
|
"version": "0.60.0"
|
|
171
178
|
}
|
package/plugin/build/index.d.ts
CHANGED
|
@@ -38,17 +38,33 @@ const config_plugins_1 = require("expo/config-plugins");
|
|
|
38
38
|
const fs = __importStar(require("fs"));
|
|
39
39
|
const path = __importStar(require("path"));
|
|
40
40
|
const KEY_FILE_NAME = 'android-daro-key.txt';
|
|
41
|
+
const JETIFIER_IGNORELIST_KEY = 'android.jetifier.ignorelist';
|
|
42
|
+
const JETIFIER_IGNORELIST_ENTRIES = ['react-android', 'hermes-android'];
|
|
41
43
|
const DARO_GRADLE_PLUGIN_CLASSPATH = 'so.daro:daro-plugin:1.0.13';
|
|
42
44
|
const MAX_QUALITY_CLASSPATH = 'com.applovin.quality:AppLovinQualityServiceGradlePlugin:5.5.2';
|
|
43
|
-
const
|
|
45
|
+
const APPLOVIN_MAVEN_REPO = 'https://artifacts.applovin.com/android';
|
|
46
|
+
const MAX_ALLPROJECTS_MAVEN_REPOS = [
|
|
47
|
+
'https://android-sdk.is.com',
|
|
48
|
+
'https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea',
|
|
49
|
+
'https://maven.ogury.co',
|
|
50
|
+
'https://artifact.bytedance.com/repository/pangle',
|
|
51
|
+
'https://s3.amazonaws.com/smaato-sdk-releases/',
|
|
52
|
+
'https://cboost.jfrog.io/artifactory/chartboost-ads/',
|
|
53
|
+
APPLOVIN_MAVEN_REPO,
|
|
54
|
+
];
|
|
44
55
|
const DARO_APP_PLUGIN_IDS = {
|
|
45
56
|
admob: 'so.daro.a',
|
|
46
57
|
max: 'so.daro.m',
|
|
47
58
|
};
|
|
59
|
+
const DARO_SDK_DEPENDENCIES = {
|
|
60
|
+
admob: 'so.daro:daro-a:1.5.5',
|
|
61
|
+
max: 'so.daro:daro-m:1.3.8',
|
|
62
|
+
};
|
|
63
|
+
const DARO_SDK_DEPENDENCY_LINE_PATTERN = /^\s*(?:implementation|api|compileOnly|runtimeOnly)\s*(?:\(\s*)?['"]so\.daro:daro-[am]:[^'"]+['"]\s*\)?\s*(?:\/\/.*)?$/gm;
|
|
48
64
|
const DARO_MAVEN_REPOS = [
|
|
49
65
|
'https://artifact.bytedance.com/repository/pangle',
|
|
50
66
|
'https://cboost.jfrog.io/artifactory/chartboost-ads/',
|
|
51
|
-
'https://android-sdk.is.com
|
|
67
|
+
'https://android-sdk.is.com',
|
|
52
68
|
'https://dl-maven-android.mintegral.com/repository/mbridge_android_sdk_oversea',
|
|
53
69
|
];
|
|
54
70
|
function replaceOrThrow(contents, pattern, replacement, target) {
|
|
@@ -58,9 +74,68 @@ function replaceOrThrow(contents, pattern, replacement, target) {
|
|
|
58
74
|
}
|
|
59
75
|
return contents.replace(pattern, replacement);
|
|
60
76
|
}
|
|
77
|
+
function findClosingBrace(contents, openBraceIndex) {
|
|
78
|
+
let depth = 0;
|
|
79
|
+
for (let index = openBraceIndex; index < contents.length; index += 1) {
|
|
80
|
+
const char = contents[index];
|
|
81
|
+
if (char === '{') {
|
|
82
|
+
depth += 1;
|
|
83
|
+
}
|
|
84
|
+
else if (char === '}') {
|
|
85
|
+
depth -= 1;
|
|
86
|
+
if (depth === 0)
|
|
87
|
+
return index;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
throw new Error('[daro-react-native] Cannot automatically update android/build.gradle. ' +
|
|
91
|
+
'Expected to find a complete repositories block.');
|
|
92
|
+
}
|
|
93
|
+
function findRepositoriesBlock(contents, pattern, target) {
|
|
94
|
+
const match = pattern.exec(contents);
|
|
95
|
+
if (!match) {
|
|
96
|
+
throw new Error(`[daro-react-native] Cannot automatically update android/build.gradle. ` +
|
|
97
|
+
`Expected to find ${target}.`);
|
|
98
|
+
}
|
|
99
|
+
const openBraceIndex = match.index + match[0].lastIndexOf('{');
|
|
100
|
+
const closeBraceIndex = findClosingBrace(contents, openBraceIndex);
|
|
101
|
+
return {
|
|
102
|
+
insertIndex: match.index + match[0].length,
|
|
103
|
+
contentStartIndex: openBraceIndex + 1,
|
|
104
|
+
contents: contents.slice(openBraceIndex + 1, closeBraceIndex),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function addMavenRepositories(contents, pattern, urls, target) {
|
|
108
|
+
const repositoriesBlock = findRepositoriesBlock(contents, pattern, target);
|
|
109
|
+
const missingUrls = urls.filter((url) => !repositoriesBlock.contents.includes(url));
|
|
110
|
+
if (missingUrls.length === 0)
|
|
111
|
+
return contents;
|
|
112
|
+
const insertIndex = findRepositoryInsertIndex(repositoriesBlock);
|
|
113
|
+
return `${contents.slice(0, insertIndex)}\n${missingUrls
|
|
114
|
+
.map((url) => ` maven { url = uri("${url}") }`)
|
|
115
|
+
.join('\n')}${contents.slice(insertIndex)}`;
|
|
116
|
+
}
|
|
117
|
+
function findRepositoryInsertIndex(repositoriesBlock) {
|
|
118
|
+
const preferredAnchor = /mavenCentral\(\)[^\S\r\n]*/.exec(repositoriesBlock.contents) ??
|
|
119
|
+
/google\(\)[^\S\r\n]*/.exec(repositoriesBlock.contents);
|
|
120
|
+
return preferredAnchor
|
|
121
|
+
? repositoriesBlock.contentStartIndex +
|
|
122
|
+
preferredAnchor.index +
|
|
123
|
+
preferredAnchor[0].length
|
|
124
|
+
: repositoriesBlock.insertIndex;
|
|
125
|
+
}
|
|
126
|
+
function addMaxBuildscriptRepository(contents) {
|
|
127
|
+
const repositoriesBlock = findRepositoriesBlock(contents, /buildscript\s*\{[\s\S]*?repositories\s*\{/, 'a buildscript repositories block');
|
|
128
|
+
if (repositoriesBlock.contents.includes(APPLOVIN_MAVEN_REPO)) {
|
|
129
|
+
return contents;
|
|
130
|
+
}
|
|
131
|
+
const insertIndex = findRepositoryInsertIndex(repositoriesBlock);
|
|
132
|
+
const repositoryLine = `\n maven { url = uri("${APPLOVIN_MAVEN_REPO}") }`;
|
|
133
|
+
return `${contents.slice(0, insertIndex)}${repositoryLine}${contents.slice(insertIndex)}`;
|
|
134
|
+
}
|
|
61
135
|
const withAndroidConfiguration = (config, props) => {
|
|
62
136
|
const { mediation } = props;
|
|
63
137
|
const daroAppPluginId = DARO_APP_PLUGIN_IDS[mediation];
|
|
138
|
+
const daroSdkDependency = DARO_SDK_DEPENDENCIES[mediation];
|
|
64
139
|
// 1. project build.gradle: classpath + maven repos
|
|
65
140
|
config = (0, config_plugins_1.withProjectBuildGradle)(config, (gradleConfig) => {
|
|
66
141
|
if (gradleConfig.modResults.language !== 'groovy') {
|
|
@@ -74,31 +149,26 @@ const withAndroidConfiguration = (config, props) => {
|
|
|
74
149
|
if (mediation === 'max' && !contents.includes(MAX_QUALITY_CLASSPATH)) {
|
|
75
150
|
contents = replaceOrThrow(contents, /dependencies\s*\{/, (match) => `${match}\n classpath("${MAX_QUALITY_CLASSPATH}")`, 'a buildscript dependencies block');
|
|
76
151
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
for (const url of mavenRepos) {
|
|
81
|
-
if (contents.includes(url))
|
|
82
|
-
continue;
|
|
83
|
-
contents = replaceOrThrow(contents, /allprojects\s*\{[\s\S]*?repositories\s*\{/, (match) => `${match}\n maven { url = uri("${url}") }`, 'an allprojects repositories block');
|
|
84
|
-
}
|
|
85
|
-
if (mediation === 'max' &&
|
|
86
|
-
!contents.includes('daro-react-native-max-buildscript-repo')) {
|
|
87
|
-
contents = replaceOrThrow(contents, /buildscript\s*\{[\s\S]*?repositories\s*\{/, (match) => `${match}\n // daro-react-native-max-buildscript-repo\n maven { url = uri("${MAX_MAVEN_REPO}") }`, 'a buildscript repositories block');
|
|
152
|
+
contents = addMavenRepositories(contents, /allprojects\s*\{[\s\S]*?repositories\s*\{/, mediation === 'max' ? MAX_ALLPROJECTS_MAVEN_REPOS : DARO_MAVEN_REPOS, 'an allprojects repositories block');
|
|
153
|
+
if (mediation === 'max') {
|
|
154
|
+
contents = addMaxBuildscriptRepository(contents);
|
|
88
155
|
}
|
|
89
156
|
gradleConfig.modResults.contents = contents;
|
|
90
157
|
return gradleConfig;
|
|
91
158
|
});
|
|
92
|
-
// 2. app/build.gradle:
|
|
159
|
+
// 2. app/build.gradle: add selected Daro SDK dependency and plugin.
|
|
93
160
|
config = (0, config_plugins_1.withAppBuildGradle)(config, (gradleConfig) => {
|
|
94
161
|
if (gradleConfig.modResults.language !== 'groovy') {
|
|
95
162
|
config_plugins_1.WarningAggregator.addWarningAndroid('daro-react-native', 'Cannot automatically configure app/build.gradle if it is not groovy.');
|
|
96
163
|
return gradleConfig;
|
|
97
164
|
}
|
|
98
165
|
let contents = gradleConfig.modResults.contents.replace(/\n?apply plugin: ['"]so\.daro\.[am]['"]\n?/g, '\n');
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
166
|
+
contents = contents.replace(DARO_SDK_DEPENDENCY_LINE_PATTERN, '');
|
|
167
|
+
contents = replaceOrThrow(contents, /dependencies\s*\{/, (match) => `${match}\n implementation("${daroSdkDependency}")`, 'an app dependencies block');
|
|
168
|
+
if (!contents.includes(daroAppPluginId)) {
|
|
169
|
+
contents = `${contents.trimEnd()}\napply plugin: "${daroAppPluginId}"\n`;
|
|
170
|
+
}
|
|
171
|
+
gradleConfig.modResults.contents = contents;
|
|
102
172
|
return gradleConfig;
|
|
103
173
|
});
|
|
104
174
|
// 3. gradle.properties: daroAppKey + Jetifier
|
|
@@ -109,6 +179,18 @@ const withAndroidConfiguration = (config, props) => {
|
|
|
109
179
|
{ key: 'android.useAndroidX', value: 'true' },
|
|
110
180
|
{ key: 'android.enableJetifier', value: 'true' },
|
|
111
181
|
];
|
|
182
|
+
const existingIgnorelist = propertiesConfig.modResults
|
|
183
|
+
.filter((item) => item.type === 'property' && item.key === JETIFIER_IGNORELIST_KEY)
|
|
184
|
+
.flatMap((item) => item.value.split(','))
|
|
185
|
+
.map((item) => item.trim())
|
|
186
|
+
.filter(Boolean);
|
|
187
|
+
propertiesConfig.modResults = propertiesConfig.modResults.filter((item) => !(item.type === 'property' && item.key === JETIFIER_IGNORELIST_KEY));
|
|
188
|
+
entries.push({
|
|
189
|
+
key: JETIFIER_IGNORELIST_KEY,
|
|
190
|
+
value: [
|
|
191
|
+
...new Set([...existingIgnorelist, ...JETIFIER_IGNORELIST_ENTRIES]),
|
|
192
|
+
].join(','),
|
|
193
|
+
});
|
|
112
194
|
for (const { key, value } of entries) {
|
|
113
195
|
const existingIndex = propertiesConfig.modResults.findIndex((item) => item.type === 'property' && item.key === key);
|
|
114
196
|
const entry = { type: 'property', key, value };
|
package/plugin/build/withIos.js
CHANGED
|
@@ -46,12 +46,11 @@ const withIosConfiguration = (config, props) => {
|
|
|
46
46
|
config.modResults.DaroAppKey = props.daroAppKey;
|
|
47
47
|
config.modResults.NSUserTrackingUsageDescription =
|
|
48
48
|
props.attUsageDescription ?? DEFAULT_ATT_USAGE_DESCRIPTION;
|
|
49
|
-
if (
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
config.modResults.GADApplicationIdentifier = props.admobAppId;
|
|
49
|
+
if (!props.admobAppId) {
|
|
50
|
+
throw new Error(`[daro-react-native] "ios.admobAppId" is required when mediation is "${mediation}". ` +
|
|
51
|
+
'Google Mobile Ads SDK requires GADApplicationIdentifier.');
|
|
54
52
|
}
|
|
53
|
+
config.modResults.GADApplicationIdentifier = props.admobAppId;
|
|
55
54
|
// SKAdNetworkItems: 사용자가 미리 추가한 항목과 머지 (중복 제거)
|
|
56
55
|
const existing = config.modResults.SKAdNetworkItems ??
|
|
57
56
|
[];
|
|
@@ -15,6 +15,9 @@ Pod::Spec.new do |s|
|
|
|
15
15
|
|
|
16
16
|
s.source_files = [
|
|
17
17
|
"ios/*.{h,m,mm,swift,cpp}",
|
|
18
|
+
"ios/Shared/**/*.{h,m,mm,swift,cpp}",
|
|
19
|
+
"ios/Paper/**/*.{h,m,mm,swift,cpp}",
|
|
20
|
+
"ios/Fabric/**/*.{h,m,mm,swift,cpp}",
|
|
18
21
|
"ios/mediation/admob/**/*.{h,m,mm,swift,cpp}"
|
|
19
22
|
]
|
|
20
23
|
s.private_header_files = "ios/**/*.h"
|
package/src/AdBannerView.tsx
CHANGED
|
@@ -5,17 +5,13 @@ import {
|
|
|
5
5
|
useImperativeHandle,
|
|
6
6
|
useRef,
|
|
7
7
|
useState,
|
|
8
|
+
type ElementRef,
|
|
8
9
|
} from 'react';
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
View,
|
|
15
|
-
type DimensionValue,
|
|
16
|
-
type NativeMethods,
|
|
17
|
-
type ViewProps,
|
|
18
|
-
} from 'react-native';
|
|
10
|
+
import { View, type ViewProps } from 'react-native';
|
|
11
|
+
import AdBannerViewNativeComponent, {
|
|
12
|
+
Commands,
|
|
13
|
+
} from './DaroMAdBannerViewNativeComponent';
|
|
14
|
+
import NativeDaroModule from './NativeDaroModule';
|
|
19
15
|
import type {
|
|
20
16
|
AdBannerViewHandler,
|
|
21
17
|
AdBannerViewProps,
|
|
@@ -23,36 +19,26 @@ import type {
|
|
|
23
19
|
import type { AdNativeEvent } from './types/AdEvent';
|
|
24
20
|
import type { AdInfo, AdLoadFailedInfo } from './types/AdInfo';
|
|
25
21
|
|
|
26
|
-
const { DaroMModule } = NativeModules;
|
|
27
|
-
|
|
28
22
|
const { BANNER_AD_FORMAT_LABEL, MREC_AD_FORMAT_LABEL } =
|
|
29
|
-
|
|
23
|
+
NativeDaroModule.getConstants();
|
|
30
24
|
|
|
31
25
|
export enum AdFormat {
|
|
32
|
-
BANNER =
|
|
33
|
-
MREC =
|
|
26
|
+
BANNER = 'BANNER',
|
|
27
|
+
MREC = 'MREC',
|
|
34
28
|
}
|
|
35
29
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
30
|
+
const toNativeAdFormat = (adFormat: AdFormat | string): string => {
|
|
31
|
+
switch (adFormat) {
|
|
32
|
+
case AdFormat.BANNER:
|
|
33
|
+
return BANNER_AD_FORMAT_LABEL;
|
|
34
|
+
case AdFormat.MREC:
|
|
35
|
+
return MREC_AD_FORMAT_LABEL;
|
|
36
|
+
default:
|
|
37
|
+
return adFormat;
|
|
38
|
+
}
|
|
41
39
|
};
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
const AdViewComponent = requireNativeComponent<
|
|
45
|
-
AdBannerViewProps & ViewProps & AdViewNativeEvents
|
|
46
|
-
>(ComponentName);
|
|
47
|
-
type AdViewType = React.Component<AdBannerViewProps> & NativeMethods;
|
|
48
|
-
|
|
49
|
-
type SizeKey = 'width' | 'height';
|
|
50
|
-
type SizeRecord = Partial<Record<SizeKey, DimensionValue>>;
|
|
51
|
-
|
|
52
|
-
const ADVIEW_SIZE = {
|
|
53
|
-
banner: { width: 320, height: 50 },
|
|
54
|
-
mrec: { width: 300, height: 250 },
|
|
55
|
-
};
|
|
41
|
+
type AdViewType = ElementRef<typeof AdBannerViewNativeComponent>;
|
|
56
42
|
|
|
57
43
|
export const AdBannerView = forwardRef<
|
|
58
44
|
AdBannerViewHandler,
|
|
@@ -73,24 +59,12 @@ export const AdBannerView = forwardRef<
|
|
|
73
59
|
},
|
|
74
60
|
ref
|
|
75
61
|
) {
|
|
76
|
-
const adFormatSize = useRef<SizeRecord>({});
|
|
77
62
|
const adViewRef = useRef<AdViewType | null>(null);
|
|
78
63
|
const [isInitialized, setIsInitialized] = useState<boolean>(false);
|
|
79
64
|
|
|
80
65
|
const loadAd = useCallback(() => {
|
|
81
66
|
if (adViewRef.current) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (typeof nodeHandle !== 'number') {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
UIManager.dispatchViewManagerCommand(
|
|
89
|
-
nodeHandle,
|
|
90
|
-
// @ts-ignore: Issue in RN ts defs
|
|
91
|
-
UIManager.getViewManagerConfig(ComponentName).Commands.loadAd,
|
|
92
|
-
[]
|
|
93
|
-
);
|
|
67
|
+
Commands.loadAd(adViewRef.current);
|
|
94
68
|
}
|
|
95
69
|
}, []);
|
|
96
70
|
|
|
@@ -102,18 +76,7 @@ export const AdBannerView = forwardRef<
|
|
|
102
76
|
|
|
103
77
|
useEffect(() => {
|
|
104
78
|
(async () => {
|
|
105
|
-
|
|
106
|
-
adFormatSize.current = {
|
|
107
|
-
width: ADVIEW_SIZE.banner.width,
|
|
108
|
-
height: ADVIEW_SIZE.banner.height,
|
|
109
|
-
};
|
|
110
|
-
} else {
|
|
111
|
-
adFormatSize.current = {
|
|
112
|
-
width: ADVIEW_SIZE.mrec.width,
|
|
113
|
-
height: ADVIEW_SIZE.mrec.height,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
const initialized = await DaroMModule.isInitialized();
|
|
79
|
+
const initialized = await NativeDaroModule.isInitialized();
|
|
117
80
|
setIsInitialized(initialized);
|
|
118
81
|
|
|
119
82
|
if (!initialized) {
|
|
@@ -122,7 +85,7 @@ export const AdBannerView = forwardRef<
|
|
|
122
85
|
);
|
|
123
86
|
}
|
|
124
87
|
})();
|
|
125
|
-
}, [
|
|
88
|
+
}, []);
|
|
126
89
|
|
|
127
90
|
const onAdLoadedEvent = useCallback(
|
|
128
91
|
(event: AdNativeEvent<AdInfo>) => {
|
|
@@ -159,9 +122,9 @@ export const AdBannerView = forwardRef<
|
|
|
159
122
|
}
|
|
160
123
|
|
|
161
124
|
return (
|
|
162
|
-
<
|
|
125
|
+
<AdBannerViewNativeComponent
|
|
163
126
|
style={style}
|
|
164
|
-
adFormat={adFormat}
|
|
127
|
+
adFormat={toNativeAdFormat(adFormat)}
|
|
165
128
|
ref={saveElement}
|
|
166
129
|
adUnitId={adUnitId}
|
|
167
130
|
placement={placement}
|
package/src/AppOpenAd.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
2
|
import {
|
|
3
3
|
addEventListener,
|
|
4
4
|
removeEventListener,
|
|
5
5
|
AdEventEmitter,
|
|
6
6
|
} from './EventEmitter';
|
|
7
|
+
import NativeDaroModule from './NativeDaroModule';
|
|
7
8
|
import type {
|
|
8
9
|
AdDisplayFailedInfo,
|
|
9
10
|
AdInfo,
|
|
@@ -11,7 +12,11 @@ import type {
|
|
|
11
12
|
} from './types/AdInfo';
|
|
12
13
|
import { AdEventType, type AdEventPayloadMap } from './types/AdEvent';
|
|
13
14
|
|
|
14
|
-
const
|
|
15
|
+
const IS_SUPPORTED_PLATFORM = Platform.OS === 'ios';
|
|
16
|
+
|
|
17
|
+
const warnUnsupportedPlatform = () => {
|
|
18
|
+
console.warn('AppOpenAd is only supported on iOS.');
|
|
19
|
+
};
|
|
15
20
|
|
|
16
21
|
const {
|
|
17
22
|
ON_APPOPEN_AD_LOADED_EVENT,
|
|
@@ -21,7 +26,7 @@ const {
|
|
|
21
26
|
ON_APPOPEN_AD_FAILED_TO_DISPLAY_EVENT,
|
|
22
27
|
ON_APPOPEN_AD_HIDDEN_EVENT,
|
|
23
28
|
ON_APPOPEN_AD_IMPRESSION_RECORDED,
|
|
24
|
-
} =
|
|
29
|
+
} = NativeDaroModule.getConstants();
|
|
25
30
|
|
|
26
31
|
const NATIVE_EVENT_BY_TYPE: Record<AdEventType, string> = {
|
|
27
32
|
[AdEventType.LOADED]: ON_APPOPEN_AD_LOADED_EVENT,
|
|
@@ -51,15 +56,26 @@ export class AppOpenAd {
|
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
isAdReady(): Promise<boolean> {
|
|
54
|
-
|
|
59
|
+
if (!IS_SUPPORTED_PLATFORM) {
|
|
60
|
+
return Promise.resolve(false);
|
|
61
|
+
}
|
|
62
|
+
return NativeDaroModule.isAppOpenAdReady(this.requestId, this.adUnitId);
|
|
55
63
|
}
|
|
56
64
|
|
|
57
65
|
load(): void {
|
|
58
|
-
|
|
66
|
+
if (!IS_SUPPORTED_PLATFORM) {
|
|
67
|
+
warnUnsupportedPlatform();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
NativeDaroModule.loadAppOpenAd(this.requestId, this.adUnitId);
|
|
59
71
|
}
|
|
60
72
|
|
|
61
73
|
show(placement?: string | null, customData?: string | null): void {
|
|
62
|
-
|
|
74
|
+
if (!IS_SUPPORTED_PLATFORM) {
|
|
75
|
+
warnUnsupportedPlatform();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
NativeDaroModule.showAppOpenAd(
|
|
63
79
|
this.requestId,
|
|
64
80
|
this.adUnitId,
|
|
65
81
|
placement ?? undefined,
|
|
@@ -71,6 +87,11 @@ export class AppOpenAd {
|
|
|
71
87
|
type: T,
|
|
72
88
|
listener: (info: AdEventPayloadMap[T]) => void
|
|
73
89
|
): () => void {
|
|
90
|
+
if (!IS_SUPPORTED_PLATFORM) {
|
|
91
|
+
warnUnsupportedPlatform();
|
|
92
|
+
return () => {};
|
|
93
|
+
}
|
|
94
|
+
|
|
74
95
|
const nativeEvent = NATIVE_EVENT_BY_TYPE[type];
|
|
75
96
|
const requestId = this.requestId;
|
|
76
97
|
return this.eventEmitter.addEventListener(nativeEvent, (payload: any) => {
|
|
@@ -101,6 +122,11 @@ export class AppOpenAd {
|
|
|
101
122
|
event: string,
|
|
102
123
|
listener: (info: T) => void
|
|
103
124
|
): void {
|
|
125
|
+
if (!IS_SUPPORTED_PLATFORM) {
|
|
126
|
+
warnUnsupportedPlatform();
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
|
|
104
130
|
addEventListener(event, (payload: any) => {
|
|
105
131
|
if (!AppOpenAd._legacyRequestIdSet.has(payload?.requestId)) {
|
|
106
132
|
return;
|
|
@@ -111,14 +137,21 @@ export class AppOpenAd {
|
|
|
111
137
|
|
|
112
138
|
/** @deprecated `AppOpenAd.createForAdRequest(adUnitId)` 인스턴스의 `isAdReady()`를 사용하세요. */
|
|
113
139
|
static isAdReady(adUnitId: string): Promise<boolean> {
|
|
140
|
+
if (!IS_SUPPORTED_PLATFORM) {
|
|
141
|
+
return Promise.resolve(false);
|
|
142
|
+
}
|
|
114
143
|
const requestId = AppOpenAd._getLegacyRequestId(adUnitId);
|
|
115
|
-
return
|
|
144
|
+
return NativeDaroModule.isAppOpenAdReady(requestId, adUnitId);
|
|
116
145
|
}
|
|
117
146
|
|
|
118
147
|
/** @deprecated `AppOpenAd.createForAdRequest(adUnitId)` 인스턴스의 `load()`를 사용하세요. */
|
|
119
148
|
static loadAd(adUnitId: string): void {
|
|
149
|
+
if (!IS_SUPPORTED_PLATFORM) {
|
|
150
|
+
warnUnsupportedPlatform();
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
120
153
|
const requestId = AppOpenAd._getLegacyRequestId(adUnitId);
|
|
121
|
-
|
|
154
|
+
NativeDaroModule.loadAppOpenAd(requestId, adUnitId);
|
|
122
155
|
}
|
|
123
156
|
|
|
124
157
|
/** @deprecated `AppOpenAd.createForAdRequest(adUnitId)` 인스턴스의 `show()`를 사용하세요. */
|
|
@@ -127,8 +160,12 @@ export class AppOpenAd {
|
|
|
127
160
|
placement?: string | null,
|
|
128
161
|
customData?: string | null
|
|
129
162
|
): void {
|
|
163
|
+
if (!IS_SUPPORTED_PLATFORM) {
|
|
164
|
+
warnUnsupportedPlatform();
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
130
167
|
const requestId = AppOpenAd._getLegacyRequestId(adUnitId);
|
|
131
|
-
|
|
168
|
+
NativeDaroModule.showAppOpenAd(
|
|
132
169
|
requestId,
|
|
133
170
|
adUnitId,
|
|
134
171
|
placement ?? undefined,
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* eslint-disable @react-native/no-deep-imports -- React Native 0.74 codegen parser compatibility requires these imports. */
|
|
2
|
+
import type * as React from 'react';
|
|
3
|
+
import type { HostComponent, ViewProps } from 'react-native';
|
|
4
|
+
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
|
5
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
6
|
+
import type {
|
|
7
|
+
DirectEventHandler,
|
|
8
|
+
Double,
|
|
9
|
+
Int32,
|
|
10
|
+
WithDefault,
|
|
11
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
12
|
+
|
|
13
|
+
type AdInfoPayload = {
|
|
14
|
+
adUnitId: string;
|
|
15
|
+
latencyMillis: Double;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type AdLoadFailedInfoPayload = {
|
|
19
|
+
adUnitId: string;
|
|
20
|
+
code: Int32;
|
|
21
|
+
message: string;
|
|
22
|
+
latencyMillis: Double;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export interface NativeProps extends ViewProps {
|
|
26
|
+
adUnitId: string;
|
|
27
|
+
adFormat: string;
|
|
28
|
+
placement?: string | null;
|
|
29
|
+
loadOnMount?: WithDefault<boolean, true>;
|
|
30
|
+
isVisible?: WithDefault<boolean, true>;
|
|
31
|
+
onAdLoadedEvent?: DirectEventHandler<AdInfoPayload>;
|
|
32
|
+
onAdLoadFailedEvent?: DirectEventHandler<AdLoadFailedInfoPayload>;
|
|
33
|
+
onAdClickedEvent?: DirectEventHandler<AdInfoPayload>;
|
|
34
|
+
onAdImpressionRecordedEvent?: DirectEventHandler<AdInfoPayload>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type ComponentType = HostComponent<NativeProps>;
|
|
38
|
+
|
|
39
|
+
interface NativeCommands {
|
|
40
|
+
loadAd: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
44
|
+
supportedCommands: ['loadAd'],
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export default codegenNativeComponent<NativeProps>('DaroMAdBannerView');
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/* eslint-disable @react-native/no-deep-imports -- React Native 0.74 codegen parser compatibility requires these imports. */
|
|
2
|
+
import type * as React from 'react';
|
|
3
|
+
import type { HostComponent, ViewProps } from 'react-native';
|
|
4
|
+
import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
|
|
5
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
6
|
+
import type {
|
|
7
|
+
DirectEventHandler,
|
|
8
|
+
Double,
|
|
9
|
+
Int32,
|
|
10
|
+
UnsafeMixed,
|
|
11
|
+
WithDefault,
|
|
12
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
13
|
+
|
|
14
|
+
type AdInfoPayload = {
|
|
15
|
+
adUnitId: string;
|
|
16
|
+
latencyMillis: Double;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type AdLoadFailedInfoPayload = {
|
|
20
|
+
adUnitId: string;
|
|
21
|
+
code: Int32;
|
|
22
|
+
message: string;
|
|
23
|
+
latencyMillis: Double;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type AdChoicesPosition = 'topLeft' | 'topRight' | 'bottomRight' | 'bottomLeft';
|
|
27
|
+
|
|
28
|
+
export interface NativeProps extends ViewProps {
|
|
29
|
+
adUnitId: string;
|
|
30
|
+
placement?: string | null;
|
|
31
|
+
loadOnMount?: WithDefault<boolean, true>;
|
|
32
|
+
adChoicesPosition?: WithDefault<AdChoicesPosition, 'bottomRight'>;
|
|
33
|
+
|
|
34
|
+
titleView?: Int32;
|
|
35
|
+
bodyView?: Int32;
|
|
36
|
+
callToActionView?: Int32;
|
|
37
|
+
iconView?: Int32;
|
|
38
|
+
mediaView?: Int32;
|
|
39
|
+
|
|
40
|
+
titleViewStyleProps?: UnsafeMixed;
|
|
41
|
+
bodyViewStyleProps?: UnsafeMixed;
|
|
42
|
+
callToActionViewStyleProps?: UnsafeMixed;
|
|
43
|
+
iconViewStyleProps?: UnsafeMixed;
|
|
44
|
+
mediaViewStyleProps?: UnsafeMixed;
|
|
45
|
+
|
|
46
|
+
onAdLoadedEvent?: DirectEventHandler<AdInfoPayload>;
|
|
47
|
+
onAdLoadFailedEvent?: DirectEventHandler<AdLoadFailedInfoPayload>;
|
|
48
|
+
onAdClickedEvent?: DirectEventHandler<AdInfoPayload>;
|
|
49
|
+
onAdImpressionRecordedEvent?: DirectEventHandler<AdInfoPayload>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
type ComponentType = HostComponent<NativeProps>;
|
|
53
|
+
|
|
54
|
+
interface NativeCommands {
|
|
55
|
+
loadAd: (viewRef: React.ElementRef<ComponentType>) => void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
59
|
+
supportedCommands: ['loadAd'],
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
export default codegenNativeComponent<NativeProps>('DaroMNativeAdView');
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* eslint-disable @react-native/no-deep-imports -- React Native 0.74 codegen parser compatibility requires this import. */
|
|
2
|
+
import type { ViewProps } from 'react-native';
|
|
3
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
4
|
+
|
|
5
|
+
export interface NativeProps extends ViewProps {}
|
|
6
|
+
|
|
7
|
+
export default codegenNativeComponent<NativeProps>('DaroMediaView', {
|
|
8
|
+
excludedPlatforms: ['iOS'],
|
|
9
|
+
});
|
package/src/EventEmitter.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NativeEventEmitter } from 'react-native';
|
|
2
2
|
import type { EventSubscription } from 'react-native';
|
|
3
|
+
import NativeDaroModule from './NativeDaroModule';
|
|
3
4
|
import type { AdEventObject, AdEventListener } from './types/AdEvent';
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const emitter = new NativeEventEmitter(DaroMModule);
|
|
6
|
+
const emitter = new NativeEventEmitter(NativeDaroModule);
|
|
8
7
|
const subscriptions: Map<string, Set<EventSubscription>> = new Map();
|
|
9
8
|
|
|
10
9
|
export const addEventListener = <T extends AdEventObject>(
|
|
@@ -37,7 +36,7 @@ export class AdEventEmitter {
|
|
|
37
36
|
private subscriptions: Map<string, Set<EventSubscription>> = new Map();
|
|
38
37
|
|
|
39
38
|
constructor() {
|
|
40
|
-
this.emitter = new NativeEventEmitter(
|
|
39
|
+
this.emitter = new NativeEventEmitter(NativeDaroModule);
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
addEventListener<T extends AdEventObject>(
|