@rnmapbox/maps 10.1.35 → 10.1.37-rc.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/com/rnmapbox/rnmbx/RNMBXPackage.kt +1 -1
- package/android/src/main/java/com/rnmapbox/rnmbx/modules/RNMBXLocationModule.kt +20 -9
- package/android/src/main/old-arch/com/rnmapbox/rnmbx/NativeRNMBXLocationModuleSpec.java +68 -0
- package/lib/commonjs/app.plugin.js +1 -0
- package/lib/commonjs/modules/location/locationManager.js +16 -3
- package/lib/commonjs/modules/location/locationManager.js.map +1 -1
- package/lib/commonjs/plugin/build/generateCode.d.ts +42 -0
- package/lib/commonjs/plugin/build/generateCode.js +107 -0
- package/lib/commonjs/plugin/build/withMapbox.d.ts +19 -0
- package/lib/commonjs/plugin/build/withMapbox.js +291 -0
- package/lib/commonjs/plugin/copy-plugin.ts +56 -0
- package/lib/commonjs/plugin/install.md +110 -0
- package/lib/commonjs/plugin/jest.config.js +1 -0
- package/lib/commonjs/plugin/src/generateCode.ts +155 -0
- package/lib/commonjs/plugin/src/withMapbox.ts +466 -0
- package/lib/commonjs/plugin/tsconfig.eslint.json +5 -0
- package/lib/commonjs/plugin/tsconfig.json +9 -0
- package/lib/commonjs/specs/NativeRNMBXLocationModule.js +9 -0
- package/lib/commonjs/specs/NativeRNMBXLocationModule.js.map +1 -0
- package/lib/module/modules/location/locationManager.js +16 -4
- package/lib/module/modules/location/locationManager.js.map +1 -1
- package/lib/module/specs/NativeRNMBXLocationModule.js +5 -0
- package/lib/module/specs/NativeRNMBXLocationModule.js.map +1 -0
- package/lib/typescript/src/modules/location/locationManager.d.ts +2 -2
- package/lib/typescript/src/modules/location/locationManager.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeRNMBXLocationModule.d.ts +29 -0
- package/lib/typescript/src/specs/NativeRNMBXLocationModule.d.ts.map +1 -0
- package/package.json +5 -13
- package/plugin/copy-plugin.ts +56 -0
- package/plugin/tsconfig.eslint.json +5 -0
- package/src/modules/location/locationManager.ts +20 -9
- package/src/specs/NativeRNMBXLocationModule.ts +32 -0
|
@@ -184,7 +184,7 @@ class RNMBXPackage : TurboReactPackage() {
|
|
|
184
184
|
false, // needsEagerInit
|
|
185
185
|
true, // hasConstants
|
|
186
186
|
false, // isCxxModule
|
|
187
|
-
|
|
187
|
+
isTurboModule // isTurboModule
|
|
188
188
|
)
|
|
189
189
|
moduleInfos[RNMBXOfflineModule.REACT_CLASS] = ReactModuleInfo(
|
|
190
190
|
RNMBXOfflineModule.REACT_CLASS,
|
|
@@ -3,6 +3,7 @@ package com.rnmapbox.rnmbx.modules
|
|
|
3
3
|
import com.facebook.react.bridge.*
|
|
4
4
|
import com.rnmapbox.rnmbx.location.LocationManager
|
|
5
5
|
import com.facebook.react.module.annotations.ReactModule
|
|
6
|
+
import com.rnmapbox.rnmbx.NativeRNMBXLocationModuleSpec
|
|
6
7
|
import com.rnmapbox.rnmbx.location.LocationManager.OnUserLocationChange
|
|
7
8
|
import com.rnmapbox.rnmbx.events.LocationEvent
|
|
8
9
|
import com.rnmapbox.rnmbx.events.EventEmitter
|
|
@@ -16,7 +17,7 @@ data class LocationEventThrottle(var waitBetweenEvents: Double? = null, var last
|
|
|
16
17
|
|
|
17
18
|
@ReactModule(name = RNMBXLocationModule.REACT_CLASS)
|
|
18
19
|
class RNMBXLocationModule(reactContext: ReactApplicationContext) :
|
|
19
|
-
|
|
20
|
+
NativeRNMBXLocationModuleSpec(reactContext) {
|
|
20
21
|
private var isEnabled = false
|
|
21
22
|
private var mMinDisplacement = 0f
|
|
22
23
|
private val locationManager: LocationManager? = getInstance(reactContext)
|
|
@@ -57,8 +58,12 @@ class RNMBXLocationModule(reactContext: ReactApplicationContext) :
|
|
|
57
58
|
mLastLocation = location
|
|
58
59
|
if (changed && (location != null) && shouldSendLocationEvent()) {
|
|
59
60
|
val locationEvent = LocationEvent(location)
|
|
61
|
+
|
|
62
|
+
emitOnLocationUpdate(locationEvent.toJSON())
|
|
63
|
+
/*
|
|
60
64
|
val emitter = EventEmitter.getModuleEmitter(reactApplicationContext)
|
|
61
65
|
emitter?.emit(LOCATION_UPDATE, locationEvent.payload)
|
|
66
|
+
*/
|
|
62
67
|
}
|
|
63
68
|
}
|
|
64
69
|
}
|
|
@@ -72,15 +77,16 @@ class RNMBXLocationModule(reactContext: ReactApplicationContext) :
|
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
@ReactMethod
|
|
75
|
-
fun start(minDisplacement:
|
|
80
|
+
override fun start(minDisplacement: Double) {
|
|
76
81
|
isEnabled = true
|
|
77
|
-
mMinDisplacement = minDisplacement
|
|
82
|
+
mMinDisplacement = minDisplacement.toFloat()
|
|
78
83
|
locationManager?.startCounted()
|
|
79
84
|
startLocationManager()
|
|
80
85
|
}
|
|
81
86
|
|
|
82
87
|
@ReactMethod
|
|
83
|
-
fun setMinDisplacement(
|
|
88
|
+
override fun setMinDisplacement(value: Double) {
|
|
89
|
+
val minDisplacement = value.toFloat()
|
|
84
90
|
if (mMinDisplacement == minDisplacement) return
|
|
85
91
|
mMinDisplacement = minDisplacement
|
|
86
92
|
if (isEnabled) {
|
|
@@ -91,17 +97,17 @@ class RNMBXLocationModule(reactContext: ReactApplicationContext) :
|
|
|
91
97
|
}
|
|
92
98
|
|
|
93
99
|
@ReactMethod
|
|
94
|
-
fun setRequestsAlwaysUse(requestsAlwaysUse: Boolean) {
|
|
100
|
+
override fun setRequestsAlwaysUse(requestsAlwaysUse: Boolean) {
|
|
95
101
|
// IOS only. Ignored on Android.
|
|
96
102
|
}
|
|
97
103
|
|
|
98
104
|
@ReactMethod
|
|
99
|
-
fun stop() {
|
|
105
|
+
override fun stop() {
|
|
100
106
|
stopLocationManager()
|
|
101
107
|
}
|
|
102
108
|
|
|
103
109
|
@ReactMethod
|
|
104
|
-
fun getLastKnownLocation(promise: Promise) {
|
|
110
|
+
override fun getLastKnownLocation(promise: Promise) {
|
|
105
111
|
locationManager!!.getLastKnownLocation(
|
|
106
112
|
object : LocationEngineCallback {
|
|
107
113
|
override fun onSuccess(result: LocationEngineResult) {
|
|
@@ -121,6 +127,10 @@ class RNMBXLocationModule(reactContext: ReactApplicationContext) :
|
|
|
121
127
|
)
|
|
122
128
|
}
|
|
123
129
|
|
|
130
|
+
override fun simulateHeading(changesPerSecond: Double, increment: Double) {
|
|
131
|
+
// ios only
|
|
132
|
+
}
|
|
133
|
+
|
|
124
134
|
@ReactMethod
|
|
125
135
|
fun addListener(eventName: String?) {
|
|
126
136
|
// Required for rn built in EventEmitter Calls.
|
|
@@ -150,10 +160,11 @@ class RNMBXLocationModule(reactContext: ReactApplicationContext) :
|
|
|
150
160
|
|
|
151
161
|
// region Location event throttle
|
|
152
162
|
@ReactMethod
|
|
153
|
-
fun setLocationEventThrottle(throttleValue: Double) {
|
|
163
|
+
override fun setLocationEventThrottle(throttleValue: Double) {
|
|
154
164
|
if (throttleValue > 0) {
|
|
155
165
|
locationEventThrottle.waitBetweenEvents = throttleValue;
|
|
156
166
|
} else {
|
|
167
|
+
|
|
157
168
|
locationEventThrottle.waitBetweenEvents = null
|
|
158
169
|
}
|
|
159
170
|
}
|
|
@@ -183,4 +194,4 @@ class RNMBXLocationModule(reactContext: ReactApplicationContext) :
|
|
|
183
194
|
const val REACT_CLASS = "RNMBXLocationModule"
|
|
184
195
|
const val LOCATION_UPDATE = "MapboxUserLocationUpdate"
|
|
185
196
|
}
|
|
186
|
-
}
|
|
197
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
|
|
4
|
+
*
|
|
5
|
+
* Do not edit this file as changes may cause incorrect behavior and will be lost
|
|
6
|
+
* once the code is regenerated.
|
|
7
|
+
*
|
|
8
|
+
* @generated by codegen project: GenerateModuleJavaSpec.js
|
|
9
|
+
*
|
|
10
|
+
* @nolint
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
package com.rnmapbox.rnmbx;
|
|
14
|
+
|
|
15
|
+
import com.facebook.proguard.annotations.DoNotStrip;
|
|
16
|
+
import com.facebook.react.bridge.Promise;
|
|
17
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
18
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
19
|
+
import com.facebook.react.bridge.ReactMethod;
|
|
20
|
+
import com.facebook.react.bridge.ReactModuleWithSpec;
|
|
21
|
+
import com.facebook.react.bridge.ReadableMap;
|
|
22
|
+
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
|
|
23
|
+
import javax.annotation.Nonnull;
|
|
24
|
+
|
|
25
|
+
public abstract class NativeRNMBXLocationModuleSpec extends ReactContextBaseJavaModule implements ReactModuleWithSpec, TurboModule {
|
|
26
|
+
public static final String NAME = "RNMBXLocationModule";
|
|
27
|
+
|
|
28
|
+
public NativeRNMBXLocationModuleSpec(ReactApplicationContext reactContext) {
|
|
29
|
+
super(reactContext);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
@Override
|
|
33
|
+
public @Nonnull String getName() {
|
|
34
|
+
return NAME;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
protected final void emitOnLocationUpdate(ReadableMap value) {
|
|
38
|
+
mEventEmitterCallback.invoke("onLocationUpdate", value);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@ReactMethod
|
|
42
|
+
@DoNotStrip
|
|
43
|
+
public abstract void start(double minDisplacement);
|
|
44
|
+
|
|
45
|
+
@ReactMethod
|
|
46
|
+
@DoNotStrip
|
|
47
|
+
public abstract void stop();
|
|
48
|
+
|
|
49
|
+
@ReactMethod
|
|
50
|
+
@DoNotStrip
|
|
51
|
+
public abstract void setRequestsAlwaysUse(boolean requestsAlwaysUse);
|
|
52
|
+
|
|
53
|
+
@ReactMethod
|
|
54
|
+
@DoNotStrip
|
|
55
|
+
public abstract void setMinDisplacement(double minDisplacement);
|
|
56
|
+
|
|
57
|
+
@ReactMethod
|
|
58
|
+
@DoNotStrip
|
|
59
|
+
public abstract void getLastKnownLocation(Promise promise);
|
|
60
|
+
|
|
61
|
+
@ReactMethod
|
|
62
|
+
@DoNotStrip
|
|
63
|
+
public abstract void simulateHeading(double changesPerSecond, double increment);
|
|
64
|
+
|
|
65
|
+
@ReactMethod
|
|
66
|
+
@DoNotStrip
|
|
67
|
+
public abstract void setLocationEventThrottle(double throttle);
|
|
68
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./plugin/build/withMapbox');
|
|
@@ -5,9 +5,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.LocationModuleEventEmitter = exports.LocationManager = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
|
+
var _NativeRNMBXLocationModule = _interopRequireDefault(require("../../specs/NativeRNMBXLocationModule"));
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
10
|
const MapboxGL = _reactNative.NativeModules.RNMBXModule;
|
|
9
|
-
const MapboxGLLocationManager = _reactNative.
|
|
10
|
-
|
|
11
|
+
const MapboxGLLocationManager = _reactNative.Platform.select({
|
|
12
|
+
ios: _reactNative.NativeModules.RNMBXLocationModule,
|
|
13
|
+
android: _NativeRNMBXLocationModule.default
|
|
14
|
+
});
|
|
15
|
+
const LocationModuleEventEmitter = exports.LocationModuleEventEmitter = new _reactNative.NativeEventEmitter(
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
MapboxGLLocationManager);
|
|
11
18
|
|
|
12
19
|
/**
|
|
13
20
|
* Location sent by locationManager
|
|
@@ -90,7 +97,13 @@ class LocationManager {
|
|
|
90
97
|
}
|
|
91
98
|
if (!this._isListening) {
|
|
92
99
|
MapboxGLLocationManager.start(validDisplacement);
|
|
93
|
-
|
|
100
|
+
if (_reactNative.Platform.OS === 'ios') {
|
|
101
|
+
this.subscription = LocationModuleEventEmitter.addListener(MapboxGL.LocationCallbackName.Update, this._onUpdate);
|
|
102
|
+
} else {
|
|
103
|
+
this.subscription = MapboxGLLocationManager.onLocationUpdate(location => {
|
|
104
|
+
this._onUpdate(location.payload);
|
|
105
|
+
});
|
|
106
|
+
}
|
|
94
107
|
this._isListening = true;
|
|
95
108
|
}
|
|
96
109
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","MapboxGL","NativeModules","RNMBXModule","MapboxGLLocationManager","RNMBXLocationModule","LocationModuleEventEmitter","exports","NativeEventEmitter","LocationManager","constructor","_listeners","_lastKnownLocation","_isListening","_requestsAlwaysUse","_onUpdate","bind","subscription","_appStateListener","AppState","addEventListener","_handleAppStateChange","getLastKnownLocation","lastKnownLocation","error","console","warn","addListener","listener","start","includes","push","removeListener","filter","l","length","stop","removeAllListeners","appState","displacement","validDisplacement","undefined","_minDisplacement","LocationCallbackName","Update","remove","setMinDisplacement","minDisplacement","setRequestsAlwaysUse","requestsAlwaysUse","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_NativeRNMBXLocationModule","_interopRequireDefault","e","__esModule","default","MapboxGL","NativeModules","RNMBXModule","MapboxGLLocationManager","Platform","select","ios","RNMBXLocationModule","android","NativeRNMBXLocationModule","LocationModuleEventEmitter","exports","NativeEventEmitter","LocationManager","constructor","_listeners","_lastKnownLocation","_isListening","_requestsAlwaysUse","_onUpdate","bind","subscription","_appStateListener","AppState","addEventListener","_handleAppStateChange","getLastKnownLocation","lastKnownLocation","error","console","warn","addListener","listener","start","includes","push","removeListener","filter","l","length","stop","removeAllListeners","appState","displacement","validDisplacement","undefined","_minDisplacement","OS","LocationCallbackName","Update","onLocationUpdate","location","payload","remove","setMinDisplacement","minDisplacement","setRequestsAlwaysUse","requestsAlwaysUse","forEach","_simulateHeading","changesPerSecond","increment","simulateHeading","setLocationEventThrottle","throttleValue","_default"],"sourceRoot":"../../../../src","sources":["modules/location/locationManager.ts"],"mappings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AE;IAC/CtD,uBAAuB,CAACqD,oBAAoB,CAACC,iBAAiB,CAAC;IAC/D,IAAI,CAACvC,kBAAkB,GAAGuC,iBAAiB;EAC7C;EAEAtC,SAASA,CAACgC,QAAkB,EAAE;IAC5B,IAAI,CAACnC,kBAAkB,GAAGmC,QAAQ;IAElC,IAAI,CAACpC,UAAU,CAAC2C,OAAO,CAAEpB,CAAC,IAAKA,CAAC,CAACa,QAAQ,CAAC,CAAC;EAC7C;;EAEA;AACF;AACA;EACEQ,gBAAgBA,CAACC,gBAAwB,EAAEC,SAAiB,EAAE;IAC5D1D,uBAAuB,CAAC2D,eAAe,CAACF,gBAAgB,EAAEC,SAAS,CAAC;EACtE;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;EACEE,wBAAwBA,CAACC,aAAqB,EAAE;IAC9C7D,uBAAuB,CAAC4D,wBAAwB,CAACC,aAAa,CAAC;EACjE;AACF;AAACrD,OAAA,CAAAE,eAAA,GAAAA,eAAA;AAAA,IAAAoD,QAAA,GAAAtD,OAAA,CAAAZ,OAAA,GAEc,IAAIc,eAAe,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Taken from @expo/config-plugins
|
|
3
|
+
*
|
|
4
|
+
* Sourcecode: https://github.com/expo/expo/blob/59ece3cb1d5a7aaea42f4c7fe9d1f4f825b338f8/packages/@expo/config-plugins/src/utils/generateCode.ts
|
|
5
|
+
* LICENSE: https://github.com/expo/expo/blob/59ece3cb1d5a7aaea42f4c7fe9d1f4f825b338f8/packages/@expo/config-plugins/LICENSE
|
|
6
|
+
*/
|
|
7
|
+
export type MergeResults = {
|
|
8
|
+
contents: string;
|
|
9
|
+
didClear: boolean;
|
|
10
|
+
didMerge: boolean;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Merge the contents of two files together and add a generated header.
|
|
14
|
+
*
|
|
15
|
+
* @param src contents of the original file
|
|
16
|
+
* @param newSrc new contents to merge into the original file
|
|
17
|
+
* @param identifier used to update and remove merges
|
|
18
|
+
* @param anchor regex to where the merge should begin
|
|
19
|
+
* @param offset line offset to start merging at (<1 for behind the anchor)
|
|
20
|
+
* @param comment comment style `//` or `#`
|
|
21
|
+
*/
|
|
22
|
+
export declare function mergeContents({ src, newSrc, tag, anchor, offset, comment, }: {
|
|
23
|
+
src: string;
|
|
24
|
+
newSrc: string;
|
|
25
|
+
tag: string;
|
|
26
|
+
anchor: string | RegExp;
|
|
27
|
+
offset: number;
|
|
28
|
+
comment: string;
|
|
29
|
+
}): MergeResults;
|
|
30
|
+
export declare function removeContents({ src, tag, }: {
|
|
31
|
+
src: string;
|
|
32
|
+
tag: string;
|
|
33
|
+
}): MergeResults;
|
|
34
|
+
/**
|
|
35
|
+
* Removes the generated section from a file, returns null when nothing can be removed.
|
|
36
|
+
* This sways heavily towards not removing lines unless it's certain that modifications were not made manually.
|
|
37
|
+
*
|
|
38
|
+
* @param src
|
|
39
|
+
*/
|
|
40
|
+
export declare function removeGeneratedContents(src: string, tag: string): string | null;
|
|
41
|
+
export declare function createGeneratedHeaderComment(contents: string, tag: string, comment: string): string;
|
|
42
|
+
export declare function createHash(src: string): string;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Taken from @expo/config-plugins
|
|
4
|
+
*
|
|
5
|
+
* Sourcecode: https://github.com/expo/expo/blob/59ece3cb1d5a7aaea42f4c7fe9d1f4f825b338f8/packages/@expo/config-plugins/src/utils/generateCode.ts
|
|
6
|
+
* LICENSE: https://github.com/expo/expo/blob/59ece3cb1d5a7aaea42f4c7fe9d1f4f825b338f8/packages/@expo/config-plugins/LICENSE
|
|
7
|
+
*/
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.createHash = exports.createGeneratedHeaderComment = exports.removeGeneratedContents = exports.removeContents = exports.mergeContents = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* Get line indexes for the generated section of a file.
|
|
15
|
+
*
|
|
16
|
+
* @param src
|
|
17
|
+
*/
|
|
18
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
19
|
+
function getGeneratedSectionIndexes(src, tag) {
|
|
20
|
+
const contents = src.split('\n');
|
|
21
|
+
const start = contents.findIndex((line) => line.includes(`@generated begin ${tag}`));
|
|
22
|
+
const end = contents.findIndex((line) => line.includes(`@generated end ${tag}`));
|
|
23
|
+
return { contents, start, end };
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Merge the contents of two files together and add a generated header.
|
|
27
|
+
*
|
|
28
|
+
* @param src contents of the original file
|
|
29
|
+
* @param newSrc new contents to merge into the original file
|
|
30
|
+
* @param identifier used to update and remove merges
|
|
31
|
+
* @param anchor regex to where the merge should begin
|
|
32
|
+
* @param offset line offset to start merging at (<1 for behind the anchor)
|
|
33
|
+
* @param comment comment style `//` or `#`
|
|
34
|
+
*/
|
|
35
|
+
function mergeContents({ src, newSrc, tag, anchor, offset, comment, }) {
|
|
36
|
+
const header = createGeneratedHeaderComment(newSrc, tag, comment);
|
|
37
|
+
if (!src.includes(header)) {
|
|
38
|
+
// Ensure the old generated contents are removed.
|
|
39
|
+
const sanitizedTarget = removeGeneratedContents(src, tag);
|
|
40
|
+
return {
|
|
41
|
+
contents: addLines(sanitizedTarget ?? src, anchor, offset, [
|
|
42
|
+
header,
|
|
43
|
+
...newSrc.split('\n'),
|
|
44
|
+
`${comment} @generated end ${tag}`,
|
|
45
|
+
]),
|
|
46
|
+
didMerge: true,
|
|
47
|
+
didClear: !!sanitizedTarget,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
return { contents: src, didClear: false, didMerge: false };
|
|
51
|
+
}
|
|
52
|
+
exports.mergeContents = mergeContents;
|
|
53
|
+
function removeContents({ src, tag, }) {
|
|
54
|
+
// Ensure the old generated contents are removed.
|
|
55
|
+
const sanitizedTarget = removeGeneratedContents(src, tag);
|
|
56
|
+
return {
|
|
57
|
+
contents: sanitizedTarget ?? src,
|
|
58
|
+
didMerge: false,
|
|
59
|
+
didClear: !!sanitizedTarget,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
exports.removeContents = removeContents;
|
|
63
|
+
function addLines(content, find, offset, toAdd) {
|
|
64
|
+
const lines = content.split('\n');
|
|
65
|
+
let lineIndex = lines.findIndex((line) => line.match(find));
|
|
66
|
+
if (lineIndex < 0) {
|
|
67
|
+
const error = new Error(`Failed to match "${find}" in contents:\n${content}`);
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
69
|
+
// @ts-ignore
|
|
70
|
+
error.code = 'ERR_NO_MATCH';
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
for (const newLine of toAdd) {
|
|
74
|
+
lines.splice(lineIndex + offset, 0, newLine);
|
|
75
|
+
lineIndex++;
|
|
76
|
+
}
|
|
77
|
+
return lines.join('\n');
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Removes the generated section from a file, returns null when nothing can be removed.
|
|
81
|
+
* This sways heavily towards not removing lines unless it's certain that modifications were not made manually.
|
|
82
|
+
*
|
|
83
|
+
* @param src
|
|
84
|
+
*/
|
|
85
|
+
function removeGeneratedContents(src, tag) {
|
|
86
|
+
const { contents, start, end } = getGeneratedSectionIndexes(src, tag);
|
|
87
|
+
if (start > -1 && end > -1 && start < end) {
|
|
88
|
+
contents.splice(start, end - start + 1);
|
|
89
|
+
// TODO: We could in theory check that the contents we're removing match the hash used in the header,
|
|
90
|
+
// this would ensure that we don't accidentally remove lines that someone added or removed from the generated section.
|
|
91
|
+
return contents.join('\n');
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
exports.removeGeneratedContents = removeGeneratedContents;
|
|
96
|
+
function createGeneratedHeaderComment(contents, tag, comment) {
|
|
97
|
+
const hashKey = createHash(contents);
|
|
98
|
+
// Everything after the `${tag} ` is unversioned and can be freely modified without breaking changes.
|
|
99
|
+
return `${comment} @generated begin ${tag} - expo prebuild (DO NOT MODIFY) ${hashKey}`;
|
|
100
|
+
}
|
|
101
|
+
exports.createGeneratedHeaderComment = createGeneratedHeaderComment;
|
|
102
|
+
function createHash(src) {
|
|
103
|
+
// this doesn't need to be secure, the shorter the better.
|
|
104
|
+
const hash = crypto_1.default.createHash('sha1').update(src).digest('hex');
|
|
105
|
+
return `sync-${hash}`;
|
|
106
|
+
}
|
|
107
|
+
exports.createHash = createHash;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ConfigPlugin } from 'expo/config-plugins';
|
|
2
|
+
type InstallerBlockName = 'pre' | 'post';
|
|
3
|
+
export type MapboxPlugProps = {
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated
|
|
6
|
+
*/
|
|
7
|
+
RNMapboxMapsImpl?: 'mapbox';
|
|
8
|
+
RNMapboxMapsVersion?: string;
|
|
9
|
+
RNMapboxMapsDownloadToken?: string;
|
|
10
|
+
RNMapboxMapsUseV11?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare const addInstallerBlock: (src: string, blockName: InstallerBlockName) => string;
|
|
13
|
+
export declare const addConstantBlock: (src: string, { RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsDownloadToken, RNMapboxMapsUseV11, }: MapboxPlugProps) => string;
|
|
14
|
+
export declare const applyCocoaPodsModifications: (contents: string, { RNMapboxMapsImpl, RNMapboxMapsVersion, RNMapboxMapsDownloadToken, RNMapboxMapsUseV11, }: MapboxPlugProps) => string;
|
|
15
|
+
export declare const addMapboxInstallerBlock: (src: string, blockName: InstallerBlockName) => string;
|
|
16
|
+
export declare const addMapboxMavenRepo: (src: string) => string;
|
|
17
|
+
declare const _default: ConfigPlugin<MapboxPlugProps>;
|
|
18
|
+
export default _default;
|
|
19
|
+
export { addMapboxMavenRepo as _addMapboxMavenRepo, };
|