@rnmapbox/maps 10.0.0-beta.28 → 10.0.0-beta.31
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/.eslintrc.js +1 -0
- package/javascript/components/AbstractLayer.js +0 -3
- package/javascript/components/Images.js +2 -3
- package/javascript/index.web.js +2 -0
- package/javascript/utils/StyleValue.ts +2 -3
- package/javascript/utils/index.js +8 -3
- package/javascript/web/MapContext.js +5 -0
- package/javascript/web/MapboxModule.js +16 -0
- package/javascript/web/UnimplementedComponent.js +10 -0
- package/javascript/web/index.js +18 -0
- package/javascript/web/utils/Logger.ts +107 -0
- package/package.json +10 -2
- package/scripts/autogenHelpers/DocJSONBuilder.js +6 -3
package/.eslintrc.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
/* eslint react/prop-types:0 */
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import { processColor } from 'react-native';
|
|
4
|
-
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
|
|
5
4
|
|
|
6
5
|
import { getFilter } from '../utils/filterUtils';
|
|
7
|
-
import { getStyleType } from '../utils/styleMap';
|
|
8
|
-
import BridgeValue from '../utils/BridgeValue';
|
|
9
6
|
import { transformStyle } from '../utils/StyleValue';
|
|
10
7
|
|
|
11
8
|
class AbstractLayer extends React.PureComponent {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { requireNativeComponent } from 'react-native';
|
|
4
|
-
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
|
|
3
|
+
import { requireNativeComponent, Image } from 'react-native';
|
|
5
4
|
|
|
6
5
|
import { viewPropTypes } from '../utils';
|
|
7
6
|
|
|
@@ -73,7 +72,7 @@ class Images extends React.Component {
|
|
|
73
72
|
} else if (_isUrlOrPath(value)) {
|
|
74
73
|
images[imageName] = value;
|
|
75
74
|
} else {
|
|
76
|
-
const res = resolveAssetSource(value);
|
|
75
|
+
const res = Image.resolveAssetSource(value);
|
|
77
76
|
if (res && res.uri) {
|
|
78
77
|
images[imageName] = res;
|
|
79
78
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { processColor } from 'react-native';
|
|
2
|
-
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
|
|
1
|
+
import { processColor, Image } from 'react-native';
|
|
3
2
|
|
|
4
3
|
import { getStyleType } from './styleMap';
|
|
5
4
|
import BridgeValue from './BridgeValue';
|
|
@@ -30,7 +29,7 @@ export function transformStyle(
|
|
|
30
29
|
if (styleType === 'color' && typeof rawStyle === 'string') {
|
|
31
30
|
rawStyle = processColor(rawStyle);
|
|
32
31
|
} else if (styleType === 'image' && typeof rawStyle === 'number') {
|
|
33
|
-
rawStyle = resolveAssetSource(rawStyle) || {};
|
|
32
|
+
rawStyle = Image.resolveAssetSource(rawStyle) || {};
|
|
34
33
|
}
|
|
35
34
|
|
|
36
35
|
const bridgeValue = new BridgeValue(rawStyle);
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
View,
|
|
4
|
+
NativeModules,
|
|
5
|
+
findNodeHandle,
|
|
6
|
+
Platform,
|
|
7
|
+
Image,
|
|
8
|
+
} from 'react-native';
|
|
3
9
|
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
4
|
-
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
|
|
5
10
|
import PropTypes from 'prop-types';
|
|
6
11
|
|
|
7
12
|
function getAndroidManagerInstance(module) {
|
|
@@ -108,7 +113,7 @@ export function cloneReactChildrenWithProps(children, propsToAdd = {}) {
|
|
|
108
113
|
}
|
|
109
114
|
|
|
110
115
|
export function resolveImagePath(imageRef) {
|
|
111
|
-
const res = resolveAssetSource(imageRef);
|
|
116
|
+
const res = Image.resolveAssetSource(imageRef);
|
|
112
117
|
return res.uri;
|
|
113
118
|
}
|
|
114
119
|
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import mapboxgl from 'mapbox-gl';
|
|
2
|
+
|
|
3
|
+
const MapboxModule = {
|
|
4
|
+
LineJoin: {},
|
|
5
|
+
|
|
6
|
+
StyleURL: {
|
|
7
|
+
Street: 'mapbox://styles/mapbox/streets-v11',
|
|
8
|
+
Satellite: 'mapbox://styles/mapbox/satellite-v9',
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
setAccessToken: (token) => {
|
|
12
|
+
mapboxgl.accessToken = token;
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default MapboxModule;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import MapboxModule from './MapboxModule';
|
|
2
|
+
import Camera from './components/Camera';
|
|
3
|
+
import MapView from './components/MapView';
|
|
4
|
+
import Logger from './utils/Logger';
|
|
5
|
+
|
|
6
|
+
const ExportedComponents = {
|
|
7
|
+
Camera,
|
|
8
|
+
MapView,
|
|
9
|
+
Logger,
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const Mapbox = {
|
|
13
|
+
...MapboxModule,
|
|
14
|
+
...ExportedComponents,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { Camera, MapView, Logger };
|
|
18
|
+
export default Mapbox;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-empty-function */
|
|
2
|
+
type LogMessage = {
|
|
3
|
+
level: LogLevel;
|
|
4
|
+
message: string;
|
|
5
|
+
tag: string;
|
|
6
|
+
};
|
|
7
|
+
type LogCallback = (log: LogMessage) => boolean;
|
|
8
|
+
type LogLevel = 'error' | 'warning' | 'info' | 'debug' | 'verbose';
|
|
9
|
+
|
|
10
|
+
class Logger {
|
|
11
|
+
static instance: Logger | null = null;
|
|
12
|
+
|
|
13
|
+
level: LogLevel = 'info';
|
|
14
|
+
logCallback: LogCallback | null;
|
|
15
|
+
startedCount = 0;
|
|
16
|
+
|
|
17
|
+
static sharedInstance() {
|
|
18
|
+
if (this.instance === null) {
|
|
19
|
+
this.instance = new Logger();
|
|
20
|
+
}
|
|
21
|
+
return this.instance;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
constructor() {
|
|
25
|
+
this.logCallback = null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Set custom logger function.
|
|
30
|
+
* @param {Logger~logCallback} logCallback - callback taking a log object as param. If callback return falsy value then
|
|
31
|
+
* default logging will take place.
|
|
32
|
+
*/
|
|
33
|
+
static setLogCallback(logCallback: LogCallback) {
|
|
34
|
+
this.sharedInstance().setLogCallback(logCallback);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Set custom logger function.
|
|
39
|
+
* @param {Logger~logCallback} logCallback - callback taking a log object as param. If callback return falsy value then
|
|
40
|
+
* default logging will take place.
|
|
41
|
+
*/
|
|
42
|
+
setLogCallback(logCallback: LogCallback) {
|
|
43
|
+
this.logCallback = logCallback;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* This callback is displayed as part of the Requester class.
|
|
48
|
+
* @callback Logger~logCallback
|
|
49
|
+
* @param {object} log
|
|
50
|
+
* @param {string} log.message - the message of the log
|
|
51
|
+
* @param {string} log.level - log level
|
|
52
|
+
* @param {string} log.tag - optional tag used on android
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* setLogLevel
|
|
57
|
+
* @param {LogLevel} level
|
|
58
|
+
*/
|
|
59
|
+
static setLogLevel(level: LogLevel) {
|
|
60
|
+
this.sharedInstance().level = level;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
start() {}
|
|
64
|
+
|
|
65
|
+
stop() {}
|
|
66
|
+
|
|
67
|
+
subscribe() {
|
|
68
|
+
//TODO
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
unsubscribe() {
|
|
72
|
+
//TODO
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
effectiveLevel(log: LogMessage): LogLevel {
|
|
76
|
+
const { level, message, tag } = log;
|
|
77
|
+
|
|
78
|
+
if (level === 'warning') {
|
|
79
|
+
if (
|
|
80
|
+
tag === 'Mbgl-HttpRequest' &&
|
|
81
|
+
message.startsWith('Request failed due to a permanent error: Canceled')
|
|
82
|
+
) {
|
|
83
|
+
// this seems to happening too much to show a warning every time
|
|
84
|
+
return 'info';
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return level;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
onLog(log: LogMessage) {
|
|
91
|
+
if (!this.logCallback || !this.logCallback(log)) {
|
|
92
|
+
const { message } = log;
|
|
93
|
+
const level = this.effectiveLevel(log);
|
|
94
|
+
if (level === 'error') {
|
|
95
|
+
console.error('Mapbox error', message, log);
|
|
96
|
+
} else if (level === 'warning') {
|
|
97
|
+
console.warn('Mapbox warning', message, log);
|
|
98
|
+
} else {
|
|
99
|
+
console.log(`Mapbox [${level}]`, message, log);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
Logger.sharedInstance().start();
|
|
106
|
+
|
|
107
|
+
export default Logger;
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rnmapbox/maps",
|
|
3
3
|
"description": "A Mapbox react native module for creating custom maps",
|
|
4
|
-
"version": "10.0.0-beta.
|
|
4
|
+
"version": "10.0.0-beta.31",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
8
8
|
"author": "React Native Mapbox Team",
|
|
9
9
|
"main": "./javascript/index.js",
|
|
10
|
+
"browser": "./javascript/index.web.js",
|
|
11
|
+
"react-native": "./javascript/index.js",
|
|
10
12
|
"keywords": [
|
|
11
13
|
"gl",
|
|
12
14
|
"ios",
|
|
@@ -35,7 +37,13 @@
|
|
|
35
37
|
"peerDependencies": {
|
|
36
38
|
"prop-types": ">=15.5.8",
|
|
37
39
|
"react": ">=16.6.1",
|
|
38
|
-
"react-native": ">=0.59.9"
|
|
40
|
+
"react-native": ">=0.59.9",
|
|
41
|
+
"mapbox-gl": "^ 2.9.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependenciesMeta": {
|
|
44
|
+
"mapbox-gl": {
|
|
45
|
+
"optional": true
|
|
46
|
+
}
|
|
39
47
|
},
|
|
40
48
|
"dependencies": {
|
|
41
49
|
"@expo/config-plugins": "^4.0.3",
|
|
@@ -23,6 +23,7 @@ const IGNORE_FILES = [
|
|
|
23
23
|
'AbstractSource',
|
|
24
24
|
'NativeBridgeComponent',
|
|
25
25
|
];
|
|
26
|
+
const IGNORE_PATTERN = /\.web\./;
|
|
26
27
|
|
|
27
28
|
const IGNORE_METHODS = ['setNativeProps'];
|
|
28
29
|
|
|
@@ -267,8 +268,10 @@ class DocJSONBuilder {
|
|
|
267
268
|
}
|
|
268
269
|
|
|
269
270
|
let fileName = fileNameWithExt.replace(/.(js)/, '');
|
|
270
|
-
|
|
271
|
-
|
|
271
|
+
if (
|
|
272
|
+
IGNORE_FILES.includes(fileName) ||
|
|
273
|
+
fileName.match(IGNORE_PATTERN)
|
|
274
|
+
) {
|
|
272
275
|
next();
|
|
273
276
|
return;
|
|
274
277
|
}
|
|
@@ -282,7 +285,7 @@ class DocJSONBuilder {
|
|
|
282
285
|
|
|
283
286
|
this.postprocess(results[fileName], fileName);
|
|
284
287
|
|
|
285
|
-
next();
|
|
288
|
+
return next();
|
|
286
289
|
},
|
|
287
290
|
() => resolve(),
|
|
288
291
|
);
|