Skip to content

Commit

Permalink
test typescript files
Browse files Browse the repository at this point in the history
  • Loading branch information
izetmolla committed Jul 25, 2021
1 parent 35e4489 commit 5395e3e
Show file tree
Hide file tree
Showing 25 changed files with 24,064 additions and 21 deletions.
2 changes: 2 additions & 0 deletions dist/AdMobInterstitial.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const _default: any;
export default _default;
56 changes: 56 additions & 0 deletions dist/AdMobInterstitial.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { NativeModules, NativeEventEmitter } from "react-native";
import { createErrorFromErrorData } from "./utils";
const RNAdMobInterstitial = NativeModules.RNAdMobInterstitial;
const eventEmitter = new NativeEventEmitter(RNAdMobInterstitial);
const eventMap = {
adLoaded: "interstitialAdLoaded",
adFailedToLoad: "interstitialAdFailedToLoad",
adOpened: "interstitialAdOpened",
adFailedToOpen: "interstitialAdFailedToOpen",
adClosed: "interstitialAdClosed",
adImpression: "interstitialAdImpression",
};
const _subscriptions = new Map();
const addEventListener = (event, handler) => {
const mappedEvent = eventMap[event];
if (mappedEvent) {
let listener;
if (event === "adFailedToLoad") {
listener = eventEmitter.addListener(mappedEvent, (error) => handler(createErrorFromErrorData(error)));
}
else {
listener = eventEmitter.addListener(mappedEvent, handler);
}
_subscriptions.set(handler, listener);
return {
remove: () => removeEventListener(event, handler),
};
}
else {
console.warn(`Trying to subscribe to unknown event: "${event}"`);
return {
remove: () => { },
};
}
};
const removeEventListener = (type, handler) => {
const listener = _subscriptions.get(handler);
if (!listener) {
return;
}
listener.remove();
_subscriptions.delete(handler);
};
const removeAllListeners = () => {
_subscriptions.forEach((listener, key, map) => {
listener.remove();
map.delete(key);
});
};
export default {
...RNAdMobInterstitial,
addEventListener,
removeEventListener,
removeAllListeners,
simulatorId: "SIMULATOR",
};
2 changes: 2 additions & 0 deletions dist/AdMobRewarded.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const _default: any;
export default _default;
57 changes: 57 additions & 0 deletions dist/AdMobRewarded.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { NativeModules, NativeEventEmitter } from "react-native";
import { createErrorFromErrorData } from "./utils";
const RNAdMobRewarded = NativeModules.RNAdMobRewarded;
const eventEmitter = new NativeEventEmitter(RNAdMobRewarded);
const eventMap = {
adLoaded: "rewardedVideoAdLoaded",
adFailedToLoad: "rewardedVideoAdFailedToLoad",
adOpened: "rewardedVideoAdOpened",
adFailedToOpen: "rewardedVideoAdFailedToOpen",
adClosed: "rewardedVideoAdClosed",
rewarded: "rewardedVideoAdRewarded",
adImpression: "rewardedVideoAdImpression",
};
const _subscriptions = new Map();
const addEventListener = (event, handler) => {
const mappedEvent = eventMap[event];
if (mappedEvent) {
let listener;
if (event === "adFailedToLoad") {
listener = eventEmitter.addListener(mappedEvent, (error) => handler(createErrorFromErrorData(error)));
}
else {
listener = eventEmitter.addListener(mappedEvent, handler);
}
_subscriptions.set(handler, listener);
return {
remove: () => removeEventListener(event, handler),
};
}
else {
console.warn(`Trying to subscribe to unknown event: "${event}"`);
return {
remove: () => { },
};
}
};
const removeEventListener = (type, handler) => {
const listener = _subscriptions.get(handler);
if (!listener) {
return;
}
listener.remove();
_subscriptions.delete(handler);
};
const removeAllListeners = () => {
_subscriptions.forEach((listener, key, map) => {
listener.remove();
map.delete(key);
});
};
export default {
...RNAdMobRewarded,
addEventListener,
removeEventListener,
removeAllListeners,
simulatorId: "SIMULATOR",
};
11 changes: 11 additions & 0 deletions dist/AdSize.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
declare const _default: {
BANNER: string;
FULL_BANNER: string;
LARGE_BANNER: string;
FLUID: string;
SKYSCRAPER: string;
LEADERBOARD: string;
MEDIUM_RECTANGLE: string;
ADAPTIVE_BANNER: string;
};
export default _default;
10 changes: 10 additions & 0 deletions dist/AdSize.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export default {
BANNER: "banner",
FULL_BANNER: "fullBanner",
LARGE_BANNER: "largeBanner",
FLUID: "fluid",
SKYSCRAPER: "skyscraper",
LEADERBOARD: "leaderboard",
MEDIUM_RECTANGLE: "mediumRectangle",
ADAPTIVE_BANNER: "adaptiveBanner",
};
6 changes: 6 additions & 0 deletions dist/AdTestIds.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
declare const _default: {
BANNER?: string | undefined;
INTERSTITIAL?: string | undefined;
REWARDED?: string | undefined;
};
export default _default;
15 changes: 15 additions & 0 deletions dist/AdTestIds.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Platform } from 'react-native';
export default {
...Platform.select({
android: {
BANNER: 'ca-app-pub-3940256099942544/6300978111',
INTERSTITIAL: 'ca-app-pub-3940256099942544/1033173712',
REWARDED: 'ca-app-pub-3940256099942544/5224354917',
},
ios: {
BANNER: 'ca-app-pub-3940256099942544/2934735716',
INTERSTITIAL: 'ca-app-pub-3940256099942544/4411468910',
REWARDED: 'ca-app-pub-3940256099942544/1712485313',
},
}),
};
16 changes: 16 additions & 0 deletions dist/AdmobBanner.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { FC } from "react";
declare type AdmobBannerTypes = {
style?: any | {};
onSizeChange?: any;
onAdFailedToLoad?: any;
adSize?: string;
adUnitID?: string;
testDevices?: any;
onAdLoaded?: any;
onAdRecordImpression?: any;
onAdOpened?: any;
onAdClosed?: any;
simulatorId?: string | "SIMULATOR";
};
declare const AdmobBanner: FC<AdmobBannerTypes>;
export default AdmobBanner;
30 changes: 30 additions & 0 deletions dist/AdmobBanner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React, { useEffect, useRef, useState } from "react";
import { requireNativeComponent, UIManager, findNodeHandle, } from "react-native";
import { createErrorFromErrorData } from "./utils";
const AdmobBanner = ({ style, onSizeChange, onAdFailedToLoad, ...res }) => {
const _bannerView = useRef(null);
const [custonStyle, setCustomStyle] = useState({});
useEffect(() => {
loadBanner();
});
const loadBanner = () => {
UIManager.dispatchViewManagerCommand(findNodeHandle(_bannerView), UIManager.getViewManagerConfig("RNGADBannerView").Commands
.loadBanner, undefined);
};
const handleSizeChange = (event) => {
const { height, width } = event.nativeEvent;
setCustomStyle({ width, height });
if (onSizeChange) {
onSizeChange({ width, height });
}
};
const handleAdFailedToLoad = (event) => {
if (onAdFailedToLoad) {
onAdFailedToLoad(createErrorFromErrorData(event.nativeEvent.error));
}
};
return (React.createElement(RNGADBannerView, { ...res, style: [style, custonStyle], onSizeChange: handleSizeChange, onAdFailedToLoad: handleAdFailedToLoad, ref: _bannerView }));
};
AdmobBanner.simulatorId = "SIMULATOR";
const RNGADBannerView = requireNativeComponent("RNGADBannerView");
export default AdmobBanner;
6 changes: 6 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import AdMobBanner from "./AdmobBanner";
import AdMobInterstitial from "./AdMobInterstitial";
import AdMobRewarded from "./AdMobRewarded";
import AdSize from "./AdSize";
import AdTestIds from "./AdTestIds";
export { AdMobBanner, AdMobInterstitial, AdMobRewarded, AdTestIds, AdSize };
6 changes: 6 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import AdMobBanner from "./AdmobBanner";
import AdMobInterstitial from "./AdMobInterstitial";
import AdMobRewarded from "./AdMobRewarded";
import AdSize from "./AdSize";
import AdTestIds from "./AdTestIds";
export { AdMobBanner, AdMobInterstitial, AdMobRewarded, AdTestIds, AdSize };
1 change: 1 addition & 0 deletions dist/utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export declare const createErrorFromErrorData: (errorData: any) => any;
6 changes: 6 additions & 0 deletions dist/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const createErrorFromErrorData = (errorData) => {
const { message, ...extraErrorInfo } = errorData || {};
const error = new Error(message);
error.framesToPop = 1;
return Object.assign(error, extraErrorInfo);
};
Loading

0 comments on commit 5395e3e

Please sign in to comment.