react-native-google-mobile-ads 12.1.1 → 12.2.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.
- package/android/src/main/java/io/invertase/googlemobileads/ReactNativeGoogleMobileAdsBannerAdViewManager.java +25 -22
- package/docs/index.mdx +19 -4
- package/lib/commonjs/common/index.js +1 -140
- package/lib/commonjs/common/index.js.map +1 -1
- package/lib/commonjs/common/validate.js +0 -89
- package/lib/commonjs/common/validate.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/common/index.js +1 -78
- package/lib/module/common/index.js.map +1 -1
- package/lib/module/common/validate.js +0 -81
- package/lib/module/common/validate.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/common/index.d.ts +0 -26
- package/lib/typescript/common/index.d.ts.map +1 -1
- package/lib/typescript/common/validate.d.ts +0 -35
- package/lib/typescript/common/validate.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +1 -1
- package/lib/typescript/version.d.ts +1 -1
- package/package.json +3 -3
- package/src/common/index.ts +1 -81
- package/src/common/validate.ts +0 -98
- package/src/version.ts +1 -1
- package/lib/commonjs/common/Base64.js +0 -102
- package/lib/commonjs/common/Base64.js.map +0 -1
- package/lib/commonjs/common/MutatableParams.js +0 -50
- package/lib/commonjs/common/MutatableParams.js.map +0 -1
- package/lib/commonjs/common/ReferenceBase.js +0 -49
- package/lib/commonjs/common/ReferenceBase.js.map +0 -1
- package/lib/commonjs/common/deeps.js +0 -85
- package/lib/commonjs/common/deeps.js.map +0 -1
- package/lib/commonjs/common/id.js +0 -72
- package/lib/commonjs/common/id.js.map +0 -1
- package/lib/commonjs/common/path.js +0 -125
- package/lib/commonjs/common/path.js.map +0 -1
- package/lib/commonjs/common/promise.js +0 -64
- package/lib/commonjs/common/promise.js.map +0 -1
- package/lib/commonjs/common/serialize.js +0 -48
- package/lib/commonjs/common/serialize.js.map +0 -1
- package/lib/module/common/Base64.js +0 -93
- package/lib/module/common/Base64.js.map +0 -1
- package/lib/module/common/MutatableParams.js +0 -43
- package/lib/module/common/MutatableParams.js.map +0 -1
- package/lib/module/common/ReferenceBase.js +0 -42
- package/lib/module/common/ReferenceBase.js.map +0 -1
- package/lib/module/common/deeps.js +0 -79
- package/lib/module/common/deeps.js.map +0 -1
- package/lib/module/common/id.js +0 -65
- package/lib/module/common/id.js.map +0 -1
- package/lib/module/common/path.js +0 -110
- package/lib/module/common/path.js.map +0 -1
- package/lib/module/common/promise.js +0 -58
- package/lib/module/common/promise.js.map +0 -1
- package/lib/module/common/serialize.js +0 -41
- package/lib/module/common/serialize.js.map +0 -1
- package/lib/typescript/common/Base64.d.ts +0 -15
- package/lib/typescript/common/Base64.d.ts.map +0 -1
- package/lib/typescript/common/MutatableParams.d.ts +0 -10
- package/lib/typescript/common/MutatableParams.d.ts.map +0 -1
- package/lib/typescript/common/ReferenceBase.d.ts +0 -12
- package/lib/typescript/common/ReferenceBase.d.ts.map +0 -1
- package/lib/typescript/common/deeps.d.ts +0 -19
- package/lib/typescript/common/deeps.d.ts.map +0 -1
- package/lib/typescript/common/id.d.ts +0 -12
- package/lib/typescript/common/id.d.ts.map +0 -1
- package/lib/typescript/common/path.d.ts +0 -44
- package/lib/typescript/common/path.d.ts.map +0 -1
- package/lib/typescript/common/promise.d.ts +0 -14
- package/lib/typescript/common/promise.d.ts.map +0 -1
- package/lib/typescript/common/serialize.d.ts +0 -6
- package/lib/typescript/common/serialize.d.ts.map +0 -1
- package/src/common/Base64.ts +0 -114
- package/src/common/MutatableParams.ts +0 -50
- package/src/common/ReferenceBase.ts +0 -45
- package/src/common/deeps.ts +0 -88
- package/src/common/id.ts +0 -74
- package/src/common/path.ts +0 -114
- package/src/common/promise.ts +0 -66
- package/src/common/serialize.ts +0 -43
|
@@ -17,6 +17,7 @@ package io.invertase.googlemobileads;
|
|
|
17
17
|
*
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
|
+
import android.app.Activity;
|
|
20
21
|
import android.view.ViewGroup;
|
|
21
22
|
import androidx.annotation.NonNull;
|
|
22
23
|
import com.facebook.react.bridge.Arguments;
|
|
@@ -44,7 +45,6 @@ import io.invertase.googlemobileads.common.SharedUtils;
|
|
|
44
45
|
import java.util.ArrayList;
|
|
45
46
|
import java.util.List;
|
|
46
47
|
import java.util.Map;
|
|
47
|
-
import java.util.Objects;
|
|
48
48
|
import javax.annotation.Nonnull;
|
|
49
49
|
import javax.annotation.Nullable;
|
|
50
50
|
import org.json.JSONException;
|
|
@@ -167,12 +167,14 @@ public class ReactNativeGoogleMobileAdsBannerAdViewManager
|
|
|
167
167
|
}
|
|
168
168
|
BaseAdView adView;
|
|
169
169
|
if (ReactNativeGoogleMobileAdsCommon.isAdManagerUnit(reactViewGroup.getUnitId())) {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
170
|
+
Activity currentActivity = ((ReactContext) reactViewGroup.getContext()).getCurrentActivity();
|
|
171
|
+
if (currentActivity != null) {
|
|
172
|
+
// in order to display the debug menu for GAM ads we need the activity context
|
|
173
|
+
// https://github.com/invertase/react-native-google-mobile-ads/issues/188
|
|
174
|
+
adView = new AdManagerAdView(currentActivity);
|
|
175
|
+
} else {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
176
178
|
} else {
|
|
177
179
|
adView = new AdView(reactViewGroup.getContext());
|
|
178
180
|
}
|
|
@@ -255,24 +257,25 @@ public class ReactNativeGoogleMobileAdsBannerAdViewManager
|
|
|
255
257
|
}
|
|
256
258
|
|
|
257
259
|
BaseAdView adView = initAdView(reactViewGroup);
|
|
258
|
-
adView
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
260
|
+
if (adView != null) {
|
|
261
|
+
adView.setAdUnitId(unitId);
|
|
262
|
+
reactViewGroup.setIsFluid(false);
|
|
263
|
+
if (adView instanceof AdManagerAdView) {
|
|
264
|
+
if (sizes.contains(AdSize.FLUID)) {
|
|
265
|
+
reactViewGroup.setIsFluid(true);
|
|
266
|
+
((AdManagerAdView) adView).setAdSizes(AdSize.FLUID);
|
|
267
|
+
} else {
|
|
268
|
+
((AdManagerAdView) adView).setAdSizes(sizes.toArray(new AdSize[0]));
|
|
269
|
+
}
|
|
270
|
+
if (manualImpressionsEnabled) {
|
|
271
|
+
((AdManagerAdView) adView).setManualImpressionsEnabled(true);
|
|
272
|
+
}
|
|
265
273
|
} else {
|
|
266
|
-
|
|
274
|
+
adView.setAdSize(sizes.get(0));
|
|
267
275
|
}
|
|
268
|
-
if (manualImpressionsEnabled) {
|
|
269
|
-
((AdManagerAdView) adView).setManualImpressionsEnabled(true);
|
|
270
|
-
}
|
|
271
|
-
} else {
|
|
272
|
-
adView.setAdSize(sizes.get(0));
|
|
273
|
-
}
|
|
274
276
|
|
|
275
|
-
|
|
277
|
+
adView.loadAd(request);
|
|
278
|
+
}
|
|
276
279
|
}
|
|
277
280
|
|
|
278
281
|
private void sendEvent(ReactNativeAdView reactViewGroup, String type, WritableMap payload) {
|
package/docs/index.mdx
CHANGED
|
@@ -107,14 +107,30 @@ npx react-native run-ios
|
|
|
107
107
|
|
|
108
108
|
# For Android
|
|
109
109
|
npx react-native run-android
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
> ⚠️ This module contains custom native code which is NOT supported by Expo Go
|
|
113
|
+
|
|
114
|
+
If you're using Expo without EAS, run the following commands:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
# For iOS
|
|
118
|
+
npx expo prebuild
|
|
119
|
+
npx expo run:ios
|
|
110
120
|
|
|
111
|
-
# For
|
|
121
|
+
# For Android
|
|
112
122
|
npx expo prebuild
|
|
123
|
+
npx expo run:android
|
|
124
|
+
```
|
|
113
125
|
|
|
114
|
-
|
|
126
|
+
If you're using Expo with EAS, create a new build:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
115
129
|
npx eas-cli build --profile development
|
|
116
130
|
```
|
|
117
131
|
|
|
132
|
+
Don't forget to install the new build on your device!
|
|
133
|
+
|
|
118
134
|
### Configure outbound requests
|
|
119
135
|
|
|
120
136
|
If the default ad settings are not correct for your app, you can provide settings that will apply to all ad requests.
|
|
@@ -172,7 +188,7 @@ If you are using mediation, you may wish to wait until the promise is settled be
|
|
|
172
188
|
### Enable SKAdNetwork to track conversions (iOS)
|
|
173
189
|
|
|
174
190
|
The Google Mobile Ads SDK supports conversion tracking using Apple's SKAdNetwork, which lets Google and participating third-party buyers attribute an app install even when the IDFA is not available.
|
|
175
|
-
Within your projects `app.json` file, add the
|
|
191
|
+
Within your projects `app.json` file, add the advised [SKAdNetwork identifiers](https://developers.google.com/ad-manager/mobile-ads-sdk/ios/3p-skadnetworks):
|
|
176
192
|
|
|
177
193
|
```json
|
|
178
194
|
{
|
|
@@ -196,7 +212,6 @@ Within your projects `app.json` file, add the 50 required SKAdNetwork identifier
|
|
|
196
212
|
"3sh42y64q3.skadnetwork",
|
|
197
213
|
"f38h382jlk.skadnetwork",
|
|
198
214
|
"hs6bdukanm.skadnetwork",
|
|
199
|
-
"prcb7njmu6.skadnetwork",
|
|
200
215
|
"v4nxqhlyqp.skadnetwork",
|
|
201
216
|
"wzmmz9fp6w.skadnetwork",
|
|
202
217
|
"yclnxrl5pm.skadnetwork",
|
|
@@ -4,39 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
|
-
getDataUrlParts: true,
|
|
8
|
-
once: true,
|
|
9
|
-
isError: true,
|
|
10
7
|
hasOwnProperty: true,
|
|
11
|
-
isPropertySet: true
|
|
12
|
-
stripTrailingSlash: true,
|
|
13
|
-
isIOS: true,
|
|
14
|
-
isAndroid: true,
|
|
15
|
-
tryJSONParse: true,
|
|
16
|
-
tryJSONStringify: true,
|
|
17
|
-
Base64: true,
|
|
18
|
-
ReferenceBase: true
|
|
8
|
+
isPropertySet: true
|
|
19
9
|
};
|
|
20
|
-
exports.Base64 = void 0;
|
|
21
|
-
Object.defineProperty(exports, "ReferenceBase", {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _ReferenceBase.ReferenceBase;
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
exports.getDataUrlParts = getDataUrlParts;
|
|
28
10
|
exports.hasOwnProperty = hasOwnProperty;
|
|
29
|
-
exports.isAndroid = void 0;
|
|
30
|
-
exports.isError = isError;
|
|
31
|
-
exports.isIOS = void 0;
|
|
32
11
|
exports.isPropertySet = isPropertySet;
|
|
33
|
-
exports.once = once;
|
|
34
|
-
exports.stripTrailingSlash = stripTrailingSlash;
|
|
35
|
-
exports.tryJSONParse = tryJSONParse;
|
|
36
|
-
exports.tryJSONStringify = tryJSONStringify;
|
|
37
|
-
var _reactNative = require("react-native");
|
|
38
|
-
var Base64 = _interopRequireWildcard(require("./Base64"));
|
|
39
|
-
exports.Base64 = Base64;
|
|
40
12
|
var _validate = require("./validate");
|
|
41
13
|
Object.keys(_validate).forEach(function (key) {
|
|
42
14
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -49,45 +21,6 @@ Object.keys(_validate).forEach(function (key) {
|
|
|
49
21
|
}
|
|
50
22
|
});
|
|
51
23
|
});
|
|
52
|
-
var _id = require("./id");
|
|
53
|
-
Object.keys(_id).forEach(function (key) {
|
|
54
|
-
if (key === "default" || key === "__esModule") return;
|
|
55
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
56
|
-
if (key in exports && exports[key] === _id[key]) return;
|
|
57
|
-
Object.defineProperty(exports, key, {
|
|
58
|
-
enumerable: true,
|
|
59
|
-
get: function () {
|
|
60
|
-
return _id[key];
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
var _path = require("./path");
|
|
65
|
-
Object.keys(_path).forEach(function (key) {
|
|
66
|
-
if (key === "default" || key === "__esModule") return;
|
|
67
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
68
|
-
if (key in exports && exports[key] === _path[key]) return;
|
|
69
|
-
Object.defineProperty(exports, key, {
|
|
70
|
-
enumerable: true,
|
|
71
|
-
get: function () {
|
|
72
|
-
return _path[key];
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
var _promise = require("./promise");
|
|
77
|
-
Object.keys(_promise).forEach(function (key) {
|
|
78
|
-
if (key === "default" || key === "__esModule") return;
|
|
79
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
80
|
-
if (key in exports && exports[key] === _promise[key]) return;
|
|
81
|
-
Object.defineProperty(exports, key, {
|
|
82
|
-
enumerable: true,
|
|
83
|
-
get: function () {
|
|
84
|
-
return _promise[key];
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
var _ReferenceBase = require("./ReferenceBase");
|
|
89
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
90
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
91
24
|
/*
|
|
92
25
|
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
93
26
|
*
|
|
@@ -105,82 +38,10 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
105
38
|
*
|
|
106
39
|
*/
|
|
107
40
|
|
|
108
|
-
function getDataUrlParts(dataUrlString) {
|
|
109
|
-
const isBase64 = dataUrlString.includes(';base64');
|
|
110
|
-
let [mediaType, base64String] = dataUrlString.split(',');
|
|
111
|
-
if (!mediaType || !base64String) {
|
|
112
|
-
return {
|
|
113
|
-
base64String: undefined,
|
|
114
|
-
mediaType: undefined
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
mediaType = mediaType.replace('data:', '').replace(';base64', '');
|
|
118
|
-
if (base64String && base64String.includes('%')) {
|
|
119
|
-
base64String = decodeURIComponent(base64String);
|
|
120
|
-
}
|
|
121
|
-
if (!isBase64) {
|
|
122
|
-
base64String = Base64.btoa(base64String);
|
|
123
|
-
}
|
|
124
|
-
return {
|
|
125
|
-
base64String,
|
|
126
|
-
mediaType
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
function once(fn, context) {
|
|
130
|
-
let onceResult;
|
|
131
|
-
let ranOnce = false;
|
|
132
|
-
return function onceInner() {
|
|
133
|
-
if (!ranOnce) {
|
|
134
|
-
ranOnce = true;
|
|
135
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
136
|
-
args[_key] = arguments[_key];
|
|
137
|
-
}
|
|
138
|
-
onceResult = fn.apply(context || this, args);
|
|
139
|
-
}
|
|
140
|
-
return onceResult;
|
|
141
|
-
};
|
|
142
|
-
}
|
|
143
|
-
function isError(value) {
|
|
144
|
-
if (Object.prototype.toString.call(value) === '[object Error]') {
|
|
145
|
-
return true;
|
|
146
|
-
}
|
|
147
|
-
return value instanceof Error;
|
|
148
|
-
}
|
|
149
41
|
function hasOwnProperty(target, property) {
|
|
150
42
|
return Object.hasOwnProperty.call(target, property);
|
|
151
43
|
}
|
|
152
44
|
function isPropertySet(target, property) {
|
|
153
45
|
return hasOwnProperty(target, property) && !(0, _validate.isUndefined)(target[property]);
|
|
154
46
|
}
|
|
155
|
-
|
|
156
|
-
/**
|
|
157
|
-
* Remove a trailing forward slash from a string if it exists
|
|
158
|
-
*
|
|
159
|
-
* @param string
|
|
160
|
-
* @returns {*}
|
|
161
|
-
*/
|
|
162
|
-
function stripTrailingSlash(string) {
|
|
163
|
-
if (!(0, _validate.isString)(string)) {
|
|
164
|
-
return string;
|
|
165
|
-
}
|
|
166
|
-
return string.endsWith('/') ? string.slice(0, -1) : string;
|
|
167
|
-
}
|
|
168
|
-
const isIOS = _reactNative.Platform.OS === 'ios';
|
|
169
|
-
exports.isIOS = isIOS;
|
|
170
|
-
const isAndroid = _reactNative.Platform.OS === 'android';
|
|
171
|
-
exports.isAndroid = isAndroid;
|
|
172
|
-
function tryJSONParse(string) {
|
|
173
|
-
try {
|
|
174
|
-
return string && JSON.parse(string);
|
|
175
|
-
} catch (jsonError) {
|
|
176
|
-
return string;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
function tryJSONStringify(data) {
|
|
180
|
-
try {
|
|
181
|
-
return JSON.stringify(data);
|
|
182
|
-
} catch (jsonError) {
|
|
183
|
-
return null;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
47
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_validate","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","target","property","isPropertySet","isUndefined"],"sourceRoot":"../../../src","sources":["common/index.ts"],"mappings":";;;;;;;;;;;AAiBA,IAAAA,SAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,SAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,SAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,SAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AAjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKO,SAASE,cAAcA,CAACO,MAAe,EAAEC,QAAqB,EAAE;EACrE,OAAOb,MAAM,CAACK,cAAc,CAACC,IAAI,CAACM,MAAM,EAAEC,QAAQ,CAAC;AACrD;AAEO,SAASC,aAAaA,CAACF,MAAe,EAAEC,QAAqB,EAAE;EACpE,OACER,cAAc,CAACO,MAAM,EAAEC,QAAQ,CAAC,IAChC,CAAC,IAAAE,qBAAW,EAAEH,MAAM,CAAkCC,QAAQ,CAAC,CAAC;AAEpE"}
|
|
@@ -3,24 +3,15 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.isAlphaNumericUnderscore = isAlphaNumericUnderscore;
|
|
7
6
|
exports.isArray = isArray;
|
|
8
7
|
exports.isBoolean = isBoolean;
|
|
9
|
-
exports.isDate = isDate;
|
|
10
|
-
exports.isFinite = isFinite;
|
|
11
8
|
exports.isFunction = isFunction;
|
|
12
|
-
exports.isInteger = isInteger;
|
|
13
9
|
exports.isNull = isNull;
|
|
14
|
-
exports.isNumber = isNumber;
|
|
15
10
|
exports.isObject = isObject;
|
|
16
11
|
exports.isOneOf = isOneOf;
|
|
17
12
|
exports.isString = isString;
|
|
18
13
|
exports.isUndefined = isUndefined;
|
|
19
14
|
exports.isValidUrl = isValidUrl;
|
|
20
|
-
exports.noop = noop;
|
|
21
|
-
exports.objectKeyValuesAreStrings = objectKeyValuesAreStrings;
|
|
22
|
-
exports.validateOptionalNativeDependencyExists = validateOptionalNativeDependencyExists;
|
|
23
|
-
var _reactNative = require("react-native");
|
|
24
15
|
/*
|
|
25
16
|
* Copyright (c) 2016-present Invertase Limited & Contributors
|
|
26
17
|
*
|
|
@@ -38,21 +29,6 @@ var _reactNative = require("react-native");
|
|
|
38
29
|
*
|
|
39
30
|
*/
|
|
40
31
|
|
|
41
|
-
const AlphaNumericUnderscore = /^[a-zA-Z0-9_]+$/;
|
|
42
|
-
function objectKeyValuesAreStrings(object) {
|
|
43
|
-
if (!isObject(object)) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
const entries = Object.entries(object);
|
|
47
|
-
for (let i = 0; i < entries.length; i++) {
|
|
48
|
-
const [key, value] = entries[i];
|
|
49
|
-
if (!isString(key) || !isString(value)) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return true;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
32
|
/**
|
|
57
33
|
* Simple is null check.
|
|
58
34
|
*
|
|
@@ -73,17 +49,6 @@ function isObject(value) {
|
|
|
73
49
|
return value ? typeof value === 'object' && !Array.isArray(value) && !isNull(value) : false;
|
|
74
50
|
}
|
|
75
51
|
|
|
76
|
-
/**
|
|
77
|
-
* Simple is date check
|
|
78
|
-
* https://stackoverflow.com/a/44198641
|
|
79
|
-
* @param value
|
|
80
|
-
* @returns {boolean}
|
|
81
|
-
*/
|
|
82
|
-
function isDate(value) {
|
|
83
|
-
// use the global isNaN() and not Number.isNaN() since it will validate an Invalid Date
|
|
84
|
-
return value && Object.prototype.toString.call(value) === '[object Date]' && !isNaN(value);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
52
|
/**
|
|
88
53
|
* Simple is function check
|
|
89
54
|
*
|
|
@@ -103,33 +68,6 @@ function isString(value) {
|
|
|
103
68
|
return typeof value === 'string';
|
|
104
69
|
}
|
|
105
70
|
|
|
106
|
-
/**
|
|
107
|
-
* Simple is number check
|
|
108
|
-
* @param value
|
|
109
|
-
* @return {boolean}
|
|
110
|
-
*/
|
|
111
|
-
function isNumber(value) {
|
|
112
|
-
return typeof value === 'number';
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Simple finite check
|
|
117
|
-
* @param value
|
|
118
|
-
* @returns {boolean}
|
|
119
|
-
*/
|
|
120
|
-
function isFinite(value) {
|
|
121
|
-
return Number.isFinite(value);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Simple integer check
|
|
126
|
-
* @param value
|
|
127
|
-
* @returns {boolean}
|
|
128
|
-
*/
|
|
129
|
-
function isInteger(value) {
|
|
130
|
-
return Number.isInteger(value);
|
|
131
|
-
}
|
|
132
|
-
|
|
133
71
|
/**
|
|
134
72
|
* Simple is boolean check
|
|
135
73
|
*
|
|
@@ -158,16 +96,6 @@ function isUndefined(value) {
|
|
|
158
96
|
return typeof value === 'undefined';
|
|
159
97
|
}
|
|
160
98
|
|
|
161
|
-
/**
|
|
162
|
-
* /^[a-zA-Z0-9_]+$/
|
|
163
|
-
*
|
|
164
|
-
* @param value
|
|
165
|
-
* @returns {boolean}
|
|
166
|
-
*/
|
|
167
|
-
function isAlphaNumericUnderscore(value) {
|
|
168
|
-
return AlphaNumericUnderscore.test(value);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
99
|
/**
|
|
172
100
|
* URL test
|
|
173
101
|
* @param url
|
|
@@ -192,21 +120,4 @@ function isOneOf(value) {
|
|
|
192
120
|
}
|
|
193
121
|
return oneOf.includes(value);
|
|
194
122
|
}
|
|
195
|
-
function noop() {
|
|
196
|
-
// noop-🐈
|
|
197
|
-
}
|
|
198
|
-
function validateOptionalNativeDependencyExists(firebaseJsonKey, apiName, nativeFnExists) {
|
|
199
|
-
if (nativeFnExists) {
|
|
200
|
-
return;
|
|
201
|
-
}
|
|
202
|
-
let errorMessage = "You attempted to use an optional API that's not enabled natively. \n\n To enable ";
|
|
203
|
-
errorMessage += apiName;
|
|
204
|
-
errorMessage += ` please set the 'react-native' -> '${firebaseJsonKey}' key to true in your firebase.json file`;
|
|
205
|
-
if (_reactNative.Platform.OS === 'android') {
|
|
206
|
-
errorMessage += ' and rebuild your Android app.';
|
|
207
|
-
} else {
|
|
208
|
-
errorMessage += ', re-run pod install and rebuild your iOS app. ' + "If you're not using Pods then make sure you've have downloaded the necessary Firebase iOS SDK dependencies for this API.";
|
|
209
|
-
}
|
|
210
|
-
throw new Error(errorMessage);
|
|
211
|
-
}
|
|
212
123
|
//# sourceMappingURL=validate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["isNull","value","isObject","Array","isArray","isFunction","isString","isBoolean","isUndefined","IS_VALID_URL_REGEX","isValidUrl","url","test","isOneOf","oneOf","arguments","length","undefined","includes"],"sourceRoot":"../../../src","sources":["common/validate.ts"],"mappings":";;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,MAAMA,CAACC,KAAc,EAAE;EACrC,OAAOA,KAAK,KAAK,IAAI;AACvB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,QAAQA,CAACD,KAAc,EAAE;EACvC,OAAOA,KAAK,GAAG,OAAOA,KAAK,KAAK,QAAQ,IAAI,CAACE,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC,IAAI,CAACD,MAAM,CAACC,KAAK,CAAC,GAAG,KAAK;AAC7F;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,UAAUA,CAACJ,KAAc,EAAE;EACzC,OAAOA,KAAK,GAAG,OAAOA,KAAK,KAAK,UAAU,GAAG,KAAK;AACpD;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASK,QAAQA,CAACL,KAAc,EAAE;EACvC,OAAO,OAAOA,KAAK,KAAK,QAAQ;AAClC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASM,SAASA,CAACN,KAAc,EAAE;EACxC,OAAO,OAAOA,KAAK,KAAK,SAAS;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASG,OAAOA,CAACH,KAAc,EAAE;EACtC,OAAOE,KAAK,CAACC,OAAO,CAACH,KAAK,CAAC;AAC7B;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASO,WAAWA,CAACP,KAAc,EAAsB;EAC9D,OAAO,OAAOA,KAAK,KAAK,WAAW;AACrC;;AAEA;AACA;AACA;AACA;AACA;AACA,MAAMQ,kBAAkB,GAAG,2BAA2B;AAC/C,SAASC,UAAUA,CAACC,GAAW,EAAE;EACtC,OAAOF,kBAAkB,CAACG,IAAI,CAACD,GAAG,CAAC;AACrC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,OAAOA,CAACZ,KAAc,EAAyB;EAAA,IAAvBa,KAAgB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EAC3D,IAAI,CAACX,OAAO,CAACU,KAAK,CAAC,EAAE;IACnB,OAAO,KAAK;EACd;EACA,OAAOA,KAAK,CAACI,QAAQ,CAACjB,KAAK,CAAC;AAC9B"}
|
package/lib/commonjs/version.js
CHANGED
|
@@ -15,89 +15,12 @@
|
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
18
|
-
import { Platform } from 'react-native';
|
|
19
|
-
import * as Base64 from './Base64';
|
|
20
|
-
import { isString, isUndefined } from './validate';
|
|
21
|
-
export * from './id';
|
|
22
|
-
export * from './path';
|
|
23
|
-
export * from './promise';
|
|
24
18
|
export * from './validate';
|
|
25
|
-
|
|
26
|
-
export { ReferenceBase } from './ReferenceBase';
|
|
27
|
-
export function getDataUrlParts(dataUrlString) {
|
|
28
|
-
const isBase64 = dataUrlString.includes(';base64');
|
|
29
|
-
let [mediaType, base64String] = dataUrlString.split(',');
|
|
30
|
-
if (!mediaType || !base64String) {
|
|
31
|
-
return {
|
|
32
|
-
base64String: undefined,
|
|
33
|
-
mediaType: undefined
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
mediaType = mediaType.replace('data:', '').replace(';base64', '');
|
|
37
|
-
if (base64String && base64String.includes('%')) {
|
|
38
|
-
base64String = decodeURIComponent(base64String);
|
|
39
|
-
}
|
|
40
|
-
if (!isBase64) {
|
|
41
|
-
base64String = Base64.btoa(base64String);
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
base64String,
|
|
45
|
-
mediaType
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
export function once(fn, context) {
|
|
49
|
-
let onceResult;
|
|
50
|
-
let ranOnce = false;
|
|
51
|
-
return function onceInner() {
|
|
52
|
-
if (!ranOnce) {
|
|
53
|
-
ranOnce = true;
|
|
54
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
55
|
-
args[_key] = arguments[_key];
|
|
56
|
-
}
|
|
57
|
-
onceResult = fn.apply(context || this, args);
|
|
58
|
-
}
|
|
59
|
-
return onceResult;
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
export function isError(value) {
|
|
63
|
-
if (Object.prototype.toString.call(value) === '[object Error]') {
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
return value instanceof Error;
|
|
67
|
-
}
|
|
19
|
+
import { isUndefined } from './validate';
|
|
68
20
|
export function hasOwnProperty(target, property) {
|
|
69
21
|
return Object.hasOwnProperty.call(target, property);
|
|
70
22
|
}
|
|
71
23
|
export function isPropertySet(target, property) {
|
|
72
24
|
return hasOwnProperty(target, property) && !isUndefined(target[property]);
|
|
73
25
|
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Remove a trailing forward slash from a string if it exists
|
|
77
|
-
*
|
|
78
|
-
* @param string
|
|
79
|
-
* @returns {*}
|
|
80
|
-
*/
|
|
81
|
-
export function stripTrailingSlash(string) {
|
|
82
|
-
if (!isString(string)) {
|
|
83
|
-
return string;
|
|
84
|
-
}
|
|
85
|
-
return string.endsWith('/') ? string.slice(0, -1) : string;
|
|
86
|
-
}
|
|
87
|
-
export const isIOS = Platform.OS === 'ios';
|
|
88
|
-
export const isAndroid = Platform.OS === 'android';
|
|
89
|
-
export function tryJSONParse(string) {
|
|
90
|
-
try {
|
|
91
|
-
return string && JSON.parse(string);
|
|
92
|
-
} catch (jsonError) {
|
|
93
|
-
return string;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
export function tryJSONStringify(data) {
|
|
97
|
-
try {
|
|
98
|
-
return JSON.stringify(data);
|
|
99
|
-
} catch (jsonError) {
|
|
100
|
-
return null;
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
26
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["isUndefined","hasOwnProperty","target","property","Object","call","isPropertySet"],"sourceRoot":"../../../src","sources":["common/index.ts"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,cAAc,YAAY;AAC1B,SAASA,WAAW,QAAQ,YAAY;AAExC,OAAO,SAASC,cAAcA,CAACC,MAAe,EAAEC,QAAqB,EAAE;EACrE,OAAOC,MAAM,CAACH,cAAc,CAACI,IAAI,CAACH,MAAM,EAAEC,QAAQ,CAAC;AACrD;AAEA,OAAO,SAASG,aAAaA,CAACJ,MAAe,EAAEC,QAAqB,EAAE;EACpE,OACEF,cAAc,CAACC,MAAM,EAAEC,QAAQ,CAAC,IAChC,CAACH,WAAW,CAAEE,MAAM,CAAkCC,QAAQ,CAAC,CAAC;AAEpE"}
|