@maplibre/maplibre-react-native 10.0.0-beta.14 → 10.0.0-beta.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/README.md +2 -2
- package/android/src/main/java/org/maplibre/reactnative/utils/GeoJSONUtils.java +49 -24
- package/lib/commonjs/plugin/ios.js +97 -0
- package/lib/commonjs/plugin/ios.js.map +1 -0
- package/lib/commonjs/plugin/withMapLibre.js +7 -130
- package/lib/commonjs/plugin/withMapLibre.js.map +1 -1
- package/lib/module/plugin/ios.js +93 -0
- package/lib/module/plugin/ios.js.map +1 -0
- package/lib/module/plugin/withMapLibre.js +8 -126
- package/lib/module/plugin/withMapLibre.js.map +1 -1
- package/lib/typescript/commonjs/src/plugin/ios.d.ts +13 -0
- package/lib/typescript/commonjs/src/plugin/ios.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/plugin/withMapLibre.d.ts +1 -10
- package/lib/typescript/commonjs/src/plugin/withMapLibre.d.ts.map +1 -1
- package/lib/typescript/module/src/plugin/ios.d.ts +13 -0
- package/lib/typescript/module/src/plugin/ios.d.ts.map +1 -0
- package/lib/typescript/module/src/plugin/withMapLibre.d.ts +1 -10
- package/lib/typescript/module/src/plugin/withMapLibre.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/plugin/ios.ts +112 -0
- package/src/plugin/withMapLibre.ts +10 -167
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ diverged, it has become necessary to separate the projects into specific wrapper
|
|
|
27
27
|
|
|
28
28
|
## Documentation
|
|
29
29
|
|
|
30
|
-
- [Getting Started](/docs/guides/setup/Getting-Started)
|
|
30
|
+
- [Getting Started](/docs/guides/setup/Getting-Started.md)
|
|
31
31
|
- Installation
|
|
32
32
|
- [Expo](/docs/guides/setup/Expo.md)
|
|
33
33
|
- [React Native](/docs/guides/setup/React-Native.md)
|
|
@@ -80,4 +80,4 @@ set up your local development environment.
|
|
|
80
80
|
|
|
81
81
|
## Community
|
|
82
82
|
|
|
83
|
-
Join the `#maplibre-react-native` or `#maplibre` [
|
|
83
|
+
Join the `#maplibre-react-native` or `#maplibre` [on the Open Street Map Slack](https://slack.openstreetmap.us/).
|
|
@@ -6,6 +6,8 @@ import com.facebook.react.bridge.WritableArray;
|
|
|
6
6
|
import com.facebook.react.bridge.WritableMap;
|
|
7
7
|
import com.facebook.react.bridge.WritableNativeArray;
|
|
8
8
|
import com.facebook.react.bridge.WritableNativeMap;
|
|
9
|
+
import com.google.gson.JsonObject;
|
|
10
|
+
|
|
9
11
|
import org.maplibre.geojson.Feature;
|
|
10
12
|
import org.maplibre.geojson.FeatureCollection;
|
|
11
13
|
import org.maplibre.geojson.Geometry;
|
|
@@ -19,23 +21,34 @@ import org.maplibre.geojson.Polygon;
|
|
|
19
21
|
import org.maplibre.android.geometry.LatLng;
|
|
20
22
|
import org.maplibre.android.geometry.LatLngBounds;
|
|
21
23
|
import org.maplibre.android.geometry.LatLngQuad;
|
|
22
|
-
import org.maplibre.android.
|
|
24
|
+
import org.maplibre.android.log.Logger;
|
|
23
25
|
import org.maplibre.turf.TurfMeasurement;
|
|
24
26
|
|
|
25
27
|
import java.util.ArrayList;
|
|
26
28
|
import java.util.List;
|
|
29
|
+
import java.util.stream.Collectors;
|
|
27
30
|
|
|
28
31
|
public class GeoJSONUtils {
|
|
32
|
+
public static final String LOG_TAG = "GeoJSONUtils";
|
|
33
|
+
|
|
29
34
|
public static WritableMap fromFeature(Feature feature) {
|
|
30
35
|
WritableMap map = Arguments.createMap();
|
|
31
36
|
map.putString("type", "Feature");
|
|
32
37
|
map.putString("id", feature.id());
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
Geometry geometry = feature.geometry();
|
|
40
|
+
if (geometry == null) {
|
|
41
|
+
map.putNull("geometry");
|
|
42
|
+
} else {
|
|
43
|
+
map.putMap("geometry", fromGeometry(geometry));
|
|
44
|
+
}
|
|
36
45
|
|
|
37
|
-
|
|
38
|
-
|
|
46
|
+
JsonObject properties = feature.properties();
|
|
47
|
+
if(properties == null) {
|
|
48
|
+
map.putNull("properties");
|
|
49
|
+
} else {
|
|
50
|
+
map.putMap("properties", ConvertUtils.toWritableMap(properties));
|
|
51
|
+
}
|
|
39
52
|
|
|
40
53
|
return map;
|
|
41
54
|
}
|
|
@@ -43,22 +56,20 @@ public class GeoJSONUtils {
|
|
|
43
56
|
public static WritableMap fromGeometry(Geometry geometry) {
|
|
44
57
|
final String type = geometry.type();
|
|
45
58
|
|
|
46
|
-
switch (type) {
|
|
47
|
-
case "Point"
|
|
48
|
-
|
|
49
|
-
case "
|
|
50
|
-
|
|
51
|
-
case "
|
|
52
|
-
|
|
53
|
-
case "
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return null;
|
|
61
|
-
}
|
|
59
|
+
return switch (type) {
|
|
60
|
+
case "Point" -> fromPoint((Point) geometry);
|
|
61
|
+
case "LineString" -> fromLineString((LineString) geometry);
|
|
62
|
+
case "Polygon" -> fromPolygon((Polygon) geometry);
|
|
63
|
+
case "MultiPoint" -> fromMultiPoint((MultiPoint) geometry);
|
|
64
|
+
case "MultiLineString" -> fromMultiLineString((MultiLineString) geometry);
|
|
65
|
+
case "MultiPolygon" -> fromMultiPolygon((MultiPolygon) geometry);
|
|
66
|
+
case "GeometryCollection" -> fromGeometryCollection((GeometryCollection) geometry);
|
|
67
|
+
default -> {
|
|
68
|
+
Logger.w(LOG_TAG, "GeoJSONUtils.fromGeometry unsupported type: \"" + type + "\"");
|
|
69
|
+
|
|
70
|
+
yield null;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
62
73
|
}
|
|
63
74
|
|
|
64
75
|
public static WritableMap fromPoint(Point point) {
|
|
@@ -103,6 +114,23 @@ public class GeoJSONUtils {
|
|
|
103
114
|
return map;
|
|
104
115
|
}
|
|
105
116
|
|
|
117
|
+
public static WritableMap fromGeometryCollection(GeometryCollection geometryCollection) {
|
|
118
|
+
WritableMap map = Arguments.createMap();
|
|
119
|
+
map.putString("type", "GeometryCollection");
|
|
120
|
+
|
|
121
|
+
map.putArray("geometries",
|
|
122
|
+
Arguments.fromList(
|
|
123
|
+
geometryCollection
|
|
124
|
+
.geometries()
|
|
125
|
+
.stream()
|
|
126
|
+
.map(GeoJSONUtils::fromGeometry)
|
|
127
|
+
.collect(Collectors.toList())
|
|
128
|
+
)
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
return map;
|
|
132
|
+
}
|
|
133
|
+
|
|
106
134
|
public static WritableArray getCoordinates(Point point) {
|
|
107
135
|
return Arguments.fromArray(pointToDoubleArray(point));
|
|
108
136
|
}
|
|
@@ -122,9 +150,6 @@ public class GeoJSONUtils {
|
|
|
122
150
|
WritableArray array = Arguments.createArray();
|
|
123
151
|
|
|
124
152
|
List<List<Point>> points = polygon.coordinates();
|
|
125
|
-
if (points == null) {
|
|
126
|
-
return array;
|
|
127
|
-
}
|
|
128
153
|
|
|
129
154
|
for (List<Point> curPoint : points) {
|
|
130
155
|
WritableArray innerArray = Arguments.createArray();
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.applyPodfilePostInstall = applyPodfilePostInstall;
|
|
7
|
+
exports.ios = void 0;
|
|
8
|
+
var _configPlugins = require("@expo/config-plugins");
|
|
9
|
+
var _generateCode = require("@expo/config-plugins/build/utils/generateCode");
|
|
10
|
+
/**
|
|
11
|
+
* Only the post-install block is required, the post installer block is used for SPM (Swift Package Manager) which Expo
|
|
12
|
+
* doesn't currently support.
|
|
13
|
+
*/
|
|
14
|
+
function applyPodfilePostInstall(contents) {
|
|
15
|
+
const result = (0, _generateCode.mergeContents)({
|
|
16
|
+
tag: `@maplibre/maplibre-react-native-post_installer`,
|
|
17
|
+
src: contents,
|
|
18
|
+
newSrc: ` $MLRN.post_install(installer)`,
|
|
19
|
+
anchor: new RegExp(`post_install do \\|installer\\|`),
|
|
20
|
+
offset: 1,
|
|
21
|
+
comment: "#"
|
|
22
|
+
});
|
|
23
|
+
if (result.didMerge || result.didClear) {
|
|
24
|
+
return result.contents;
|
|
25
|
+
}
|
|
26
|
+
return contents;
|
|
27
|
+
}
|
|
28
|
+
const withPodfilePostInstall = config => {
|
|
29
|
+
return (0, _configPlugins.withPodfile)(config, c => {
|
|
30
|
+
c.modResults.contents = applyPodfilePostInstall(c.modResults.contents);
|
|
31
|
+
return c;
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Exclude building for arm64 on simulator devices in the pbxproj project.
|
|
37
|
+
* Without this, production builds targeting simulators will fail.
|
|
38
|
+
*/
|
|
39
|
+
function setExcludedArchitectures(project) {
|
|
40
|
+
const configurations = project.pbxXCBuildConfigurationSection();
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
for (const {
|
|
44
|
+
name,
|
|
45
|
+
buildSettings
|
|
46
|
+
} of Object.values(configurations || {})) {
|
|
47
|
+
// Guessing that this is the best way to emulate Xcode.
|
|
48
|
+
// Using `project.addToBuildSettings` modifies too many targets.
|
|
49
|
+
if (name === "Release" && typeof buildSettings?.PRODUCT_NAME !== "undefined") {
|
|
50
|
+
buildSettings['"EXCLUDED_ARCHS[sdk=iphonesimulator*]"'] = '"arm64"';
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return project;
|
|
54
|
+
}
|
|
55
|
+
const withoutSignatures = config => {
|
|
56
|
+
return (0, _configPlugins.withXcodeProject)(config, async c => {
|
|
57
|
+
c.modResults.addBuildPhase([], "PBXShellScriptBuildPhase", "Remove signature files (Xcode workaround)", null, {
|
|
58
|
+
shellPath: "/bin/sh",
|
|
59
|
+
shellScript: `
|
|
60
|
+
echo "Remove signature files (Xcode workaround)";
|
|
61
|
+
rm -rf "$CONFIGURATION_BUILD_DIR/MapLibre.xcframework-ios.signature";
|
|
62
|
+
`
|
|
63
|
+
});
|
|
64
|
+
return c;
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Set the Debug Information Format to DWARF with dSYM File during EAS Build for Managed App
|
|
70
|
+
* https://github.com/expo/eas-cli/issues/968
|
|
71
|
+
*
|
|
72
|
+
* Set `artifactPath` in `eas.json`:
|
|
73
|
+
* ```json
|
|
74
|
+
* "ios": {
|
|
75
|
+
* "artifactPath": "ios/build/*"
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
const withDwarfDsym = config => {
|
|
80
|
+
return (0, _configPlugins.withXcodeProject)(config, async c => {
|
|
81
|
+
c.modResults.debugInformationFormat = "dwarf-with-dsym";
|
|
82
|
+
return c;
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
const withExcludedSimulatorArchitectures = config => {
|
|
86
|
+
return (0, _configPlugins.withXcodeProject)(config, c => {
|
|
87
|
+
c.modResults = setExcludedArchitectures(c.modResults);
|
|
88
|
+
return c;
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
const ios = exports.ios = {
|
|
92
|
+
withPodfilePostInstall,
|
|
93
|
+
withoutSignatures,
|
|
94
|
+
withDwarfDsym,
|
|
95
|
+
withExcludedSimulatorArchitectures
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=ios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","_generateCode","applyPodfilePostInstall","contents","result","mergeContents","tag","src","newSrc","anchor","RegExp","offset","comment","didMerge","didClear","withPodfilePostInstall","config","withPodfile","c","modResults","setExcludedArchitectures","project","configurations","pbxXCBuildConfigurationSection","name","buildSettings","Object","values","PRODUCT_NAME","withoutSignatures","withXcodeProject","addBuildPhase","shellPath","shellScript","withDwarfDsym","debugInformationFormat","withExcludedSimulatorArchitectures","ios","exports"],"sourceRoot":"../../../src","sources":["plugin/ios.ts"],"mappings":";;;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAMA,IAAAC,aAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACO,SAASE,uBAAuBA,CAACC,QAAgB,EAAU;EAChE,MAAMC,MAAM,GAAG,IAAAC,2BAAa,EAAC;IAC3BC,GAAG,EAAE,gDAAgD;IACrDC,GAAG,EAAEJ,QAAQ;IACbK,MAAM,EAAE,mCAAmC;IAC3CC,MAAM,EAAE,IAAIC,MAAM,CAAC,iCAAiC,CAAC;IACrDC,MAAM,EAAE,CAAC;IACTC,OAAO,EAAE;EACX,CAAC,CAAC;EAEF,IAAIR,MAAM,CAACS,QAAQ,IAAIT,MAAM,CAACU,QAAQ,EAAE;IACtC,OAAOV,MAAM,CAACD,QAAQ;EACxB;EAEA,OAAOA,QAAQ;AACjB;AAEA,MAAMY,sBAAoC,GAAIC,MAAM,IAAK;EACvD,OAAO,IAAAC,0BAAW,EAACD,MAAM,EAAGE,CAAC,IAAK;IAChCA,CAAC,CAACC,UAAU,CAAChB,QAAQ,GAAGD,uBAAuB,CAACgB,CAAC,CAACC,UAAU,CAAChB,QAAQ,CAAC;IAEtE,OAAOe,CAAC;EACV,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA,SAASE,wBAAwBA,CAACC,OAAqB,EAAgB;EACrE,MAAMC,cAAc,GAAGD,OAAO,CAACE,8BAA8B,CAAC,CAAC;EAC/D;EACA;EACA,KAAK,MAAM;IAAEC,IAAI;IAAEC;EAAc,CAAC,IAAIC,MAAM,CAACC,MAAM,CAACL,cAAc,IAAI,CAAC,CAAC,CAAC,EAAE;IACzE;IACA;IACA,IACEE,IAAI,KAAK,SAAS,IAClB,OAAOC,aAAa,EAAEG,YAAY,KAAK,WAAW,EAClD;MACAH,aAAa,CAAC,wCAAwC,CAAC,GAAG,SAAS;IACrE;EACF;EAEA,OAAOJ,OAAO;AAChB;AAEA,MAAMQ,iBAA+B,GAAIb,MAAM,IAAK;EAClD,OAAO,IAAAc,+BAAgB,EAACd,MAAM,EAAE,MAAOE,CAAC,IAAK;IAC3CA,CAAC,CAACC,UAAU,CAACY,aAAa,CACxB,EAAE,EACF,0BAA0B,EAC1B,2CAA2C,EAC3C,IAAI,EACJ;MACEC,SAAS,EAAE,SAAS;MACpBC,WAAW,EAAE;AACrB;AACA;AACA;IACM,CACF,CAAC;IAED,OAAOf,CAAC;EACV,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMgB,aAA2B,GAAIlB,MAAM,IAAK;EAC9C,OAAO,IAAAc,+BAAgB,EAACd,MAAM,EAAE,MAAOE,CAAC,IAAK;IAC3CA,CAAC,CAACC,UAAU,CAACgB,sBAAsB,GAAG,iBAAiB;IAEvD,OAAOjB,CAAC;EACV,CAAC,CAAC;AACJ,CAAC;AAED,MAAMkB,kCAAgD,GAAIpB,MAAM,IAAK;EACnE,OAAO,IAAAc,+BAAgB,EAACd,MAAM,EAAGE,CAAC,IAAK;IACrCA,CAAC,CAACC,UAAU,GAAGC,wBAAwB,CAACF,CAAC,CAACC,UAAU,CAAC;IAErD,OAAOD,CAAC;EACV,CAAC,CAAC;AACJ,CAAC;AAEM,MAAMmB,GAAG,GAAAC,OAAA,CAAAD,GAAA,GAAG;EACjBtB,sBAAsB;EACtBc,iBAAiB;EACjBK,aAAa;EACbE;AACF,CAAC","ignoreList":[]}
|
|
@@ -3,16 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.addInstallerBlock = addInstallerBlock;
|
|
7
|
-
exports.addMapLibreInstallerBlock = addMapLibreInstallerBlock;
|
|
8
|
-
exports.applyCocoaPodsModifications = applyCocoaPodsModifications;
|
|
9
6
|
exports.default = void 0;
|
|
10
|
-
exports.setExcludedArchitectures = setExcludedArchitectures;
|
|
11
7
|
var _configPlugins = require("@expo/config-plugins");
|
|
12
|
-
var
|
|
13
|
-
var _nodeFs = require("node:fs");
|
|
14
|
-
var _nodePath = _interopRequireDefault(require("node:path"));
|
|
15
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
var _ios = require("./ios.js");
|
|
16
9
|
let pkg = {
|
|
17
10
|
name: "@maplibre/maplibre-react-native"
|
|
18
11
|
};
|
|
@@ -21,129 +14,13 @@ try {
|
|
|
21
14
|
} catch {
|
|
22
15
|
// empty catch block
|
|
23
16
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Dangerously adds the custom installer hooks to the Podfile.
|
|
26
|
-
* In the future this should be removed in favor of some custom hooks provided by Expo autolinking.
|
|
27
|
-
*
|
|
28
|
-
* https://github.com/maplibre/maplibre-react-native/blob/main/docs/guides/setup/iOS.md
|
|
29
|
-
*/
|
|
30
|
-
const withCocoaPodsInstallerBlocks = c => {
|
|
31
|
-
return (0, _configPlugins.withDangerousMod)(c, ["ios",
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
33
|
-
async config => {
|
|
34
|
-
const file = _nodePath.default.join(config.modRequest.platformProjectRoot, "Podfile");
|
|
35
|
-
const contents = await _nodeFs.promises.readFile(file, "utf8");
|
|
36
|
-
await _nodeFs.promises.writeFile(file, applyCocoaPodsModifications(contents), "utf-8");
|
|
37
|
-
return config;
|
|
38
|
-
}]);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// Only the post-install block is required, the post installer block is
|
|
42
|
-
// used for spm (swift package manager) which Expo doesn't currently support.
|
|
43
|
-
function applyCocoaPodsModifications(contents) {
|
|
44
|
-
// Ensure installer blocks exist
|
|
45
|
-
let src = addInstallerBlock(contents, "post");
|
|
46
|
-
src = addMapLibreInstallerBlock(src, "post");
|
|
47
|
-
return src;
|
|
48
|
-
}
|
|
49
|
-
function addInstallerBlock(src, blockName) {
|
|
50
|
-
const matchBlock = new RegExp(`${blockName}_install do \\|installer\\|`);
|
|
51
|
-
const tag = `${blockName}_installer`;
|
|
52
|
-
for (const line of src.split("\n")) {
|
|
53
|
-
const contents = line.trim();
|
|
54
|
-
// Ignore comments
|
|
55
|
-
if (!contents.startsWith("#")) {
|
|
56
|
-
// Prevent adding the block if it exists outside of comments.
|
|
57
|
-
if (contents.match(matchBlock)) {
|
|
58
|
-
// This helps to still allow revisions, since we enabled the block previously.
|
|
59
|
-
// Only continue if the generated block exists...
|
|
60
|
-
const modified = (0, _generateCode.removeGeneratedContents)(src, tag);
|
|
61
|
-
if (!modified) {
|
|
62
|
-
return src;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return (0, _generateCode.mergeContents)({
|
|
68
|
-
tag,
|
|
69
|
-
src,
|
|
70
|
-
newSrc: [` ${blockName}_install do |installer|`, " end"].join("\n"),
|
|
71
|
-
anchor: /use_react_native/,
|
|
72
|
-
// We can't go after the use_react_native block because it might have parameters, causing it to be multi-line (see react-native template).
|
|
73
|
-
offset: 0,
|
|
74
|
-
comment: "#"
|
|
75
|
-
}).contents;
|
|
76
|
-
}
|
|
77
|
-
function addMapLibreInstallerBlock(src, blockName) {
|
|
78
|
-
return (0, _generateCode.mergeContents)({
|
|
79
|
-
tag: `@maplibre/maplibre-react-native-${blockName}_installer`,
|
|
80
|
-
src,
|
|
81
|
-
newSrc: ` $MLRN.${blockName}_install(installer)`,
|
|
82
|
-
anchor: new RegExp(`${blockName}_install do \\|installer\\|`),
|
|
83
|
-
offset: 1,
|
|
84
|
-
comment: "#"
|
|
85
|
-
}).contents;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Exclude building for arm64 on simulator devices in the pbxproj project.
|
|
90
|
-
* Without this, production builds targeting simulators will fail.
|
|
91
|
-
*/
|
|
92
|
-
function setExcludedArchitectures(project) {
|
|
93
|
-
const configurations = project.pbxXCBuildConfigurationSection();
|
|
94
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
95
|
-
// @ts-ignore
|
|
96
|
-
for (const {
|
|
97
|
-
name,
|
|
98
|
-
buildSettings
|
|
99
|
-
} of Object.values(configurations || {})) {
|
|
100
|
-
// Guessing that this is the best way to emulate Xcode.
|
|
101
|
-
// Using `project.addToBuildSettings` modifies too many targets.
|
|
102
|
-
if (name === "Release" && typeof buildSettings?.PRODUCT_NAME !== "undefined") {
|
|
103
|
-
buildSettings['"EXCLUDED_ARCHS[sdk=iphonesimulator*]"'] = '"arm64"';
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
return project;
|
|
107
|
-
}
|
|
108
|
-
const withoutSignatures = config => {
|
|
109
|
-
const shellScript = `
|
|
110
|
-
echo "Remove signature files (Xcode workaround)";
|
|
111
|
-
rm -rf "$CONFIGURATION_BUILD_DIR/MapLibre.xcframework-ios.signature";
|
|
112
|
-
`;
|
|
113
|
-
return (0, _configPlugins.withXcodeProject)(config, async config => {
|
|
114
|
-
const xcodeProject = config.modResults;
|
|
115
|
-
xcodeProject.addBuildPhase([], "PBXShellScriptBuildPhase", "Remove signature files (Xcode workaround)", null, {
|
|
116
|
-
shellPath: "/bin/sh",
|
|
117
|
-
shellScript
|
|
118
|
-
});
|
|
119
|
-
return config;
|
|
120
|
-
});
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Set the Debug Information Format to DWARF with dSYM File during EAS Build for Managed App
|
|
125
|
-
* https://github.com/expo/eas-cli/issues/968
|
|
126
|
-
* // Set artifactPath in eas.json
|
|
127
|
-
* "ios": {
|
|
128
|
-
* "artifactPath": "ios/build/*"
|
|
129
|
-
* }
|
|
130
|
-
*/
|
|
131
|
-
const withDwarfDsym = config => {
|
|
132
|
-
return (0, _configPlugins.withXcodeProject)(config, async config => {
|
|
133
|
-
const xcodeProject = config.modResults;
|
|
134
|
-
xcodeProject.debugInformationFormat = "dwarf-with-dsym";
|
|
135
|
-
return config;
|
|
136
|
-
});
|
|
137
|
-
};
|
|
138
|
-
const withExcludedSimulatorArchitectures = c => {
|
|
139
|
-
return (0, _configPlugins.withXcodeProject)(c, config => {
|
|
140
|
-
config.modResults = setExcludedArchitectures(config.modResults);
|
|
141
|
-
return config;
|
|
142
|
-
});
|
|
143
|
-
};
|
|
144
17
|
const withMapLibre = config => {
|
|
145
|
-
|
|
146
|
-
|
|
18
|
+
// iOS
|
|
19
|
+
config = _ios.ios.withExcludedSimulatorArchitectures(config);
|
|
20
|
+
config = _ios.ios.withDwarfDsym(config);
|
|
21
|
+
config = _ios.ios.withoutSignatures(config);
|
|
22
|
+
config = _ios.ios.withPodfilePostInstall(config);
|
|
23
|
+
return config;
|
|
147
24
|
};
|
|
148
25
|
var _default = exports.default = (0, _configPlugins.createRunOncePlugin)(withMapLibre, pkg.name, pkg.version);
|
|
149
26
|
//# sourceMappingURL=withMapLibre.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_configPlugins","require","
|
|
1
|
+
{"version":3,"names":["_configPlugins","require","_ios","pkg","name","withMapLibre","config","ios","withExcludedSimulatorArchitectures","withDwarfDsym","withoutSignatures","withPodfilePostInstall","_default","exports","default","createRunOncePlugin","version"],"sourceRoot":"../../../src","sources":["plugin/withMapLibre.ts"],"mappings":";;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAEA,IAAAC,IAAA,GAAAD,OAAA;AAEA,IAAIE,GAAuC,GAAG;EAC5CC,IAAI,EAAE;AACR,CAAC;AACD,IAAI;EACFD,GAAG,GAAGF,OAAO,CAAC,8CAA8C,CAAC;AAC/D,CAAC,CAAC,MAAM;EACN;AAAA;AAGF,MAAMI,YAA0B,GAAIC,MAAM,IAAK;EAC7C;EACAA,MAAM,GAAGC,QAAG,CAACC,kCAAkC,CAACF,MAAM,CAAC;EACvDA,MAAM,GAAGC,QAAG,CAACE,aAAa,CAACH,MAAM,CAAC;EAClCA,MAAM,GAAGC,QAAG,CAACG,iBAAiB,CAACJ,MAAM,CAAC;EACtCA,MAAM,GAAGC,QAAG,CAACI,sBAAsB,CAACL,MAAM,CAAC;EAE3C,OAAOA,MAAM;AACf,CAAC;AAAC,IAAAM,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEa,IAAAC,kCAAmB,EAACV,YAAY,EAAEF,GAAG,CAACC,IAAI,EAAED,GAAG,CAACa,OAAO,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { withPodfile, withXcodeProject } from "@expo/config-plugins";
|
|
4
|
+
import { mergeContents } from "@expo/config-plugins/build/utils/generateCode";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Only the post-install block is required, the post installer block is used for SPM (Swift Package Manager) which Expo
|
|
8
|
+
* doesn't currently support.
|
|
9
|
+
*/
|
|
10
|
+
export function applyPodfilePostInstall(contents) {
|
|
11
|
+
const result = mergeContents({
|
|
12
|
+
tag: `@maplibre/maplibre-react-native-post_installer`,
|
|
13
|
+
src: contents,
|
|
14
|
+
newSrc: ` $MLRN.post_install(installer)`,
|
|
15
|
+
anchor: new RegExp(`post_install do \\|installer\\|`),
|
|
16
|
+
offset: 1,
|
|
17
|
+
comment: "#"
|
|
18
|
+
});
|
|
19
|
+
if (result.didMerge || result.didClear) {
|
|
20
|
+
return result.contents;
|
|
21
|
+
}
|
|
22
|
+
return contents;
|
|
23
|
+
}
|
|
24
|
+
const withPodfilePostInstall = config => {
|
|
25
|
+
return withPodfile(config, c => {
|
|
26
|
+
c.modResults.contents = applyPodfilePostInstall(c.modResults.contents);
|
|
27
|
+
return c;
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Exclude building for arm64 on simulator devices in the pbxproj project.
|
|
33
|
+
* Without this, production builds targeting simulators will fail.
|
|
34
|
+
*/
|
|
35
|
+
function setExcludedArchitectures(project) {
|
|
36
|
+
const configurations = project.pbxXCBuildConfigurationSection();
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
38
|
+
// @ts-ignore
|
|
39
|
+
for (const {
|
|
40
|
+
name,
|
|
41
|
+
buildSettings
|
|
42
|
+
} of Object.values(configurations || {})) {
|
|
43
|
+
// Guessing that this is the best way to emulate Xcode.
|
|
44
|
+
// Using `project.addToBuildSettings` modifies too many targets.
|
|
45
|
+
if (name === "Release" && typeof buildSettings?.PRODUCT_NAME !== "undefined") {
|
|
46
|
+
buildSettings['"EXCLUDED_ARCHS[sdk=iphonesimulator*]"'] = '"arm64"';
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return project;
|
|
50
|
+
}
|
|
51
|
+
const withoutSignatures = config => {
|
|
52
|
+
return withXcodeProject(config, async c => {
|
|
53
|
+
c.modResults.addBuildPhase([], "PBXShellScriptBuildPhase", "Remove signature files (Xcode workaround)", null, {
|
|
54
|
+
shellPath: "/bin/sh",
|
|
55
|
+
shellScript: `
|
|
56
|
+
echo "Remove signature files (Xcode workaround)";
|
|
57
|
+
rm -rf "$CONFIGURATION_BUILD_DIR/MapLibre.xcframework-ios.signature";
|
|
58
|
+
`
|
|
59
|
+
});
|
|
60
|
+
return c;
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Set the Debug Information Format to DWARF with dSYM File during EAS Build for Managed App
|
|
66
|
+
* https://github.com/expo/eas-cli/issues/968
|
|
67
|
+
*
|
|
68
|
+
* Set `artifactPath` in `eas.json`:
|
|
69
|
+
* ```json
|
|
70
|
+
* "ios": {
|
|
71
|
+
* "artifactPath": "ios/build/*"
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
const withDwarfDsym = config => {
|
|
76
|
+
return withXcodeProject(config, async c => {
|
|
77
|
+
c.modResults.debugInformationFormat = "dwarf-with-dsym";
|
|
78
|
+
return c;
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
const withExcludedSimulatorArchitectures = config => {
|
|
82
|
+
return withXcodeProject(config, c => {
|
|
83
|
+
c.modResults = setExcludedArchitectures(c.modResults);
|
|
84
|
+
return c;
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
export const ios = {
|
|
88
|
+
withPodfilePostInstall,
|
|
89
|
+
withoutSignatures,
|
|
90
|
+
withDwarfDsym,
|
|
91
|
+
withExcludedSimulatorArchitectures
|
|
92
|
+
};
|
|
93
|
+
//# sourceMappingURL=ios.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["withPodfile","withXcodeProject","mergeContents","applyPodfilePostInstall","contents","result","tag","src","newSrc","anchor","RegExp","offset","comment","didMerge","didClear","withPodfilePostInstall","config","c","modResults","setExcludedArchitectures","project","configurations","pbxXCBuildConfigurationSection","name","buildSettings","Object","values","PRODUCT_NAME","withoutSignatures","addBuildPhase","shellPath","shellScript","withDwarfDsym","debugInformationFormat","withExcludedSimulatorArchitectures","ios"],"sourceRoot":"../../../src","sources":["plugin/ios.ts"],"mappings":";;AAAA,SAEEA,WAAW,EACXC,gBAAgB,QAEX,sBAAsB;AAC7B,SAASC,aAAa,QAAQ,+CAA+C;;AAE7E;AACA;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CAACC,QAAgB,EAAU;EAChE,MAAMC,MAAM,GAAGH,aAAa,CAAC;IAC3BI,GAAG,EAAE,gDAAgD;IACrDC,GAAG,EAAEH,QAAQ;IACbI,MAAM,EAAE,mCAAmC;IAC3CC,MAAM,EAAE,IAAIC,MAAM,CAAC,iCAAiC,CAAC;IACrDC,MAAM,EAAE,CAAC;IACTC,OAAO,EAAE;EACX,CAAC,CAAC;EAEF,IAAIP,MAAM,CAACQ,QAAQ,IAAIR,MAAM,CAACS,QAAQ,EAAE;IACtC,OAAOT,MAAM,CAACD,QAAQ;EACxB;EAEA,OAAOA,QAAQ;AACjB;AAEA,MAAMW,sBAAoC,GAAIC,MAAM,IAAK;EACvD,OAAOhB,WAAW,CAACgB,MAAM,EAAGC,CAAC,IAAK;IAChCA,CAAC,CAACC,UAAU,CAACd,QAAQ,GAAGD,uBAAuB,CAACc,CAAC,CAACC,UAAU,CAACd,QAAQ,CAAC;IAEtE,OAAOa,CAAC;EACV,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA,SAASE,wBAAwBA,CAACC,OAAqB,EAAgB;EACrE,MAAMC,cAAc,GAAGD,OAAO,CAACE,8BAA8B,CAAC,CAAC;EAC/D;EACA;EACA,KAAK,MAAM;IAAEC,IAAI;IAAEC;EAAc,CAAC,IAAIC,MAAM,CAACC,MAAM,CAACL,cAAc,IAAI,CAAC,CAAC,CAAC,EAAE;IACzE;IACA;IACA,IACEE,IAAI,KAAK,SAAS,IAClB,OAAOC,aAAa,EAAEG,YAAY,KAAK,WAAW,EAClD;MACAH,aAAa,CAAC,wCAAwC,CAAC,GAAG,SAAS;IACrE;EACF;EAEA,OAAOJ,OAAO;AAChB;AAEA,MAAMQ,iBAA+B,GAAIZ,MAAM,IAAK;EAClD,OAAOf,gBAAgB,CAACe,MAAM,EAAE,MAAOC,CAAC,IAAK;IAC3CA,CAAC,CAACC,UAAU,CAACW,aAAa,CACxB,EAAE,EACF,0BAA0B,EAC1B,2CAA2C,EAC3C,IAAI,EACJ;MACEC,SAAS,EAAE,SAAS;MACpBC,WAAW,EAAE;AACrB;AACA;AACA;IACM,CACF,CAAC;IAED,OAAOd,CAAC;EACV,CAAC,CAAC;AACJ,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMe,aAA2B,GAAIhB,MAAM,IAAK;EAC9C,OAAOf,gBAAgB,CAACe,MAAM,EAAE,MAAOC,CAAC,IAAK;IAC3CA,CAAC,CAACC,UAAU,CAACe,sBAAsB,GAAG,iBAAiB;IAEvD,OAAOhB,CAAC;EACV,CAAC,CAAC;AACJ,CAAC;AAED,MAAMiB,kCAAgD,GAAIlB,MAAM,IAAK;EACnE,OAAOf,gBAAgB,CAACe,MAAM,EAAGC,CAAC,IAAK;IACrCA,CAAC,CAACC,UAAU,GAAGC,wBAAwB,CAACF,CAAC,CAACC,UAAU,CAAC;IAErD,OAAOD,CAAC;EACV,CAAC,CAAC;AACJ,CAAC;AAED,OAAO,MAAMkB,GAAG,GAAG;EACjBpB,sBAAsB;EACtBa,iBAAiB;EACjBI,aAAa;EACbE;AACF,CAAC","ignoreList":[]}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { createRunOncePlugin
|
|
4
|
-
import {
|
|
5
|
-
import { promises } from "node:fs";
|
|
6
|
-
import path from "node:path";
|
|
3
|
+
import { createRunOncePlugin } from "@expo/config-plugins";
|
|
4
|
+
import { ios } from "./ios.js";
|
|
7
5
|
let pkg = {
|
|
8
6
|
name: "@maplibre/maplibre-react-native"
|
|
9
7
|
};
|
|
@@ -12,129 +10,13 @@ try {
|
|
|
12
10
|
} catch {
|
|
13
11
|
// empty catch block
|
|
14
12
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Dangerously adds the custom installer hooks to the Podfile.
|
|
17
|
-
* In the future this should be removed in favor of some custom hooks provided by Expo autolinking.
|
|
18
|
-
*
|
|
19
|
-
* https://github.com/maplibre/maplibre-react-native/blob/main/docs/guides/setup/iOS.md
|
|
20
|
-
*/
|
|
21
|
-
const withCocoaPodsInstallerBlocks = c => {
|
|
22
|
-
return withDangerousMod(c, ["ios",
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
24
|
-
async config => {
|
|
25
|
-
const file = path.join(config.modRequest.platformProjectRoot, "Podfile");
|
|
26
|
-
const contents = await promises.readFile(file, "utf8");
|
|
27
|
-
await promises.writeFile(file, applyCocoaPodsModifications(contents), "utf-8");
|
|
28
|
-
return config;
|
|
29
|
-
}]);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// Only the post-install block is required, the post installer block is
|
|
33
|
-
// used for spm (swift package manager) which Expo doesn't currently support.
|
|
34
|
-
export function applyCocoaPodsModifications(contents) {
|
|
35
|
-
// Ensure installer blocks exist
|
|
36
|
-
let src = addInstallerBlock(contents, "post");
|
|
37
|
-
src = addMapLibreInstallerBlock(src, "post");
|
|
38
|
-
return src;
|
|
39
|
-
}
|
|
40
|
-
export function addInstallerBlock(src, blockName) {
|
|
41
|
-
const matchBlock = new RegExp(`${blockName}_install do \\|installer\\|`);
|
|
42
|
-
const tag = `${blockName}_installer`;
|
|
43
|
-
for (const line of src.split("\n")) {
|
|
44
|
-
const contents = line.trim();
|
|
45
|
-
// Ignore comments
|
|
46
|
-
if (!contents.startsWith("#")) {
|
|
47
|
-
// Prevent adding the block if it exists outside of comments.
|
|
48
|
-
if (contents.match(matchBlock)) {
|
|
49
|
-
// This helps to still allow revisions, since we enabled the block previously.
|
|
50
|
-
// Only continue if the generated block exists...
|
|
51
|
-
const modified = removeGeneratedContents(src, tag);
|
|
52
|
-
if (!modified) {
|
|
53
|
-
return src;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return mergeContents({
|
|
59
|
-
tag,
|
|
60
|
-
src,
|
|
61
|
-
newSrc: [` ${blockName}_install do |installer|`, " end"].join("\n"),
|
|
62
|
-
anchor: /use_react_native/,
|
|
63
|
-
// We can't go after the use_react_native block because it might have parameters, causing it to be multi-line (see react-native template).
|
|
64
|
-
offset: 0,
|
|
65
|
-
comment: "#"
|
|
66
|
-
}).contents;
|
|
67
|
-
}
|
|
68
|
-
export function addMapLibreInstallerBlock(src, blockName) {
|
|
69
|
-
return mergeContents({
|
|
70
|
-
tag: `@maplibre/maplibre-react-native-${blockName}_installer`,
|
|
71
|
-
src,
|
|
72
|
-
newSrc: ` $MLRN.${blockName}_install(installer)`,
|
|
73
|
-
anchor: new RegExp(`${blockName}_install do \\|installer\\|`),
|
|
74
|
-
offset: 1,
|
|
75
|
-
comment: "#"
|
|
76
|
-
}).contents;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Exclude building for arm64 on simulator devices in the pbxproj project.
|
|
81
|
-
* Without this, production builds targeting simulators will fail.
|
|
82
|
-
*/
|
|
83
|
-
export function setExcludedArchitectures(project) {
|
|
84
|
-
const configurations = project.pbxXCBuildConfigurationSection();
|
|
85
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
86
|
-
// @ts-ignore
|
|
87
|
-
for (const {
|
|
88
|
-
name,
|
|
89
|
-
buildSettings
|
|
90
|
-
} of Object.values(configurations || {})) {
|
|
91
|
-
// Guessing that this is the best way to emulate Xcode.
|
|
92
|
-
// Using `project.addToBuildSettings` modifies too many targets.
|
|
93
|
-
if (name === "Release" && typeof buildSettings?.PRODUCT_NAME !== "undefined") {
|
|
94
|
-
buildSettings['"EXCLUDED_ARCHS[sdk=iphonesimulator*]"'] = '"arm64"';
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return project;
|
|
98
|
-
}
|
|
99
|
-
const withoutSignatures = config => {
|
|
100
|
-
const shellScript = `
|
|
101
|
-
echo "Remove signature files (Xcode workaround)";
|
|
102
|
-
rm -rf "$CONFIGURATION_BUILD_DIR/MapLibre.xcframework-ios.signature";
|
|
103
|
-
`;
|
|
104
|
-
return withXcodeProject(config, async config => {
|
|
105
|
-
const xcodeProject = config.modResults;
|
|
106
|
-
xcodeProject.addBuildPhase([], "PBXShellScriptBuildPhase", "Remove signature files (Xcode workaround)", null, {
|
|
107
|
-
shellPath: "/bin/sh",
|
|
108
|
-
shellScript
|
|
109
|
-
});
|
|
110
|
-
return config;
|
|
111
|
-
});
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Set the Debug Information Format to DWARF with dSYM File during EAS Build for Managed App
|
|
116
|
-
* https://github.com/expo/eas-cli/issues/968
|
|
117
|
-
* // Set artifactPath in eas.json
|
|
118
|
-
* "ios": {
|
|
119
|
-
* "artifactPath": "ios/build/*"
|
|
120
|
-
* }
|
|
121
|
-
*/
|
|
122
|
-
const withDwarfDsym = config => {
|
|
123
|
-
return withXcodeProject(config, async config => {
|
|
124
|
-
const xcodeProject = config.modResults;
|
|
125
|
-
xcodeProject.debugInformationFormat = "dwarf-with-dsym";
|
|
126
|
-
return config;
|
|
127
|
-
});
|
|
128
|
-
};
|
|
129
|
-
const withExcludedSimulatorArchitectures = c => {
|
|
130
|
-
return withXcodeProject(c, config => {
|
|
131
|
-
config.modResults = setExcludedArchitectures(config.modResults);
|
|
132
|
-
return config;
|
|
133
|
-
});
|
|
134
|
-
};
|
|
135
13
|
const withMapLibre = config => {
|
|
136
|
-
|
|
137
|
-
|
|
14
|
+
// iOS
|
|
15
|
+
config = ios.withExcludedSimulatorArchitectures(config);
|
|
16
|
+
config = ios.withDwarfDsym(config);
|
|
17
|
+
config = ios.withoutSignatures(config);
|
|
18
|
+
config = ios.withPodfilePostInstall(config);
|
|
19
|
+
return config;
|
|
138
20
|
};
|
|
139
21
|
export default createRunOncePlugin(withMapLibre, pkg.name, pkg.version);
|
|
140
22
|
//# sourceMappingURL=withMapLibre.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createRunOncePlugin","
|
|
1
|
+
{"version":3,"names":["createRunOncePlugin","ios","pkg","name","require","withMapLibre","config","withExcludedSimulatorArchitectures","withDwarfDsym","withoutSignatures","withPodfilePostInstall","version"],"sourceRoot":"../../../src","sources":["plugin/withMapLibre.ts"],"mappings":";;AAAA,SAA4BA,mBAAmB,QAAQ,sBAAsB;AAE7E,SAASC,GAAG,QAAQ,UAAO;AAE3B,IAAIC,GAAuC,GAAG;EAC5CC,IAAI,EAAE;AACR,CAAC;AACD,IAAI;EACFD,GAAG,GAAGE,OAAO,CAAC,8CAA8C,CAAC;AAC/D,CAAC,CAAC,MAAM;EACN;AAAA;AAGF,MAAMC,YAA0B,GAAIC,MAAM,IAAK;EAC7C;EACAA,MAAM,GAAGL,GAAG,CAACM,kCAAkC,CAACD,MAAM,CAAC;EACvDA,MAAM,GAAGL,GAAG,CAACO,aAAa,CAACF,MAAM,CAAC;EAClCA,MAAM,GAAGL,GAAG,CAACQ,iBAAiB,CAACH,MAAM,CAAC;EACtCA,MAAM,GAAGL,GAAG,CAACS,sBAAsB,CAACJ,MAAM,CAAC;EAE3C,OAAOA,MAAM;AACf,CAAC;AAED,eAAeN,mBAAmB,CAACK,YAAY,EAAEH,GAAG,CAACC,IAAI,EAAED,GAAG,CAACS,OAAO,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ConfigPlugin } from "@expo/config-plugins";
|
|
2
|
+
/**
|
|
3
|
+
* Only the post-install block is required, the post installer block is used for SPM (Swift Package Manager) which Expo
|
|
4
|
+
* doesn't currently support.
|
|
5
|
+
*/
|
|
6
|
+
export declare function applyPodfilePostInstall(contents: string): string;
|
|
7
|
+
export declare const ios: {
|
|
8
|
+
withPodfilePostInstall: ConfigPlugin;
|
|
9
|
+
withoutSignatures: ConfigPlugin;
|
|
10
|
+
withDwarfDsym: ConfigPlugin;
|
|
11
|
+
withExcludedSimulatorArchitectures: ConfigPlugin;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=ios.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../../../../src/plugin/ios.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EAIlB,MAAM,sBAAsB,CAAC;AAG9B;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAehE;AA+ED,eAAO,MAAM,GAAG;;;;;CAKf,CAAC"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import { type ConfigPlugin
|
|
2
|
-
type InstallerBlockName = "pre" | "post";
|
|
3
|
-
export declare function applyCocoaPodsModifications(contents: string): string;
|
|
4
|
-
export declare function addInstallerBlock(src: string, blockName: InstallerBlockName): string;
|
|
5
|
-
export declare function addMapLibreInstallerBlock(src: string, blockName: InstallerBlockName): string;
|
|
6
|
-
/**
|
|
7
|
-
* Exclude building for arm64 on simulator devices in the pbxproj project.
|
|
8
|
-
* Without this, production builds targeting simulators will fail.
|
|
9
|
-
*/
|
|
10
|
-
export declare function setExcludedArchitectures(project: XcodeProject): XcodeProject;
|
|
1
|
+
import { type ConfigPlugin } from "@expo/config-plugins";
|
|
11
2
|
declare const _default: ConfigPlugin<void>;
|
|
12
3
|
export default _default;
|
|
13
4
|
//# sourceMappingURL=withMapLibre.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withMapLibre.d.ts","sourceRoot":"","sources":["../../../../../src/plugin/withMapLibre.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"withMapLibre.d.ts","sourceRoot":"","sources":["../../../../../src/plugin/withMapLibre.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAuB,MAAM,sBAAsB,CAAC;;AAuB9E,wBAAwE"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ConfigPlugin } from "@expo/config-plugins";
|
|
2
|
+
/**
|
|
3
|
+
* Only the post-install block is required, the post installer block is used for SPM (Swift Package Manager) which Expo
|
|
4
|
+
* doesn't currently support.
|
|
5
|
+
*/
|
|
6
|
+
export declare function applyPodfilePostInstall(contents: string): string;
|
|
7
|
+
export declare const ios: {
|
|
8
|
+
withPodfilePostInstall: ConfigPlugin;
|
|
9
|
+
withoutSignatures: ConfigPlugin;
|
|
10
|
+
withDwarfDsym: ConfigPlugin;
|
|
11
|
+
withExcludedSimulatorArchitectures: ConfigPlugin;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=ios.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ios.d.ts","sourceRoot":"","sources":["../../../../../src/plugin/ios.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,YAAY,EAIlB,MAAM,sBAAsB,CAAC;AAG9B;;;GAGG;AACH,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAehE;AA+ED,eAAO,MAAM,GAAG;;;;;CAKf,CAAC"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
import { type ConfigPlugin
|
|
2
|
-
type InstallerBlockName = "pre" | "post";
|
|
3
|
-
export declare function applyCocoaPodsModifications(contents: string): string;
|
|
4
|
-
export declare function addInstallerBlock(src: string, blockName: InstallerBlockName): string;
|
|
5
|
-
export declare function addMapLibreInstallerBlock(src: string, blockName: InstallerBlockName): string;
|
|
6
|
-
/**
|
|
7
|
-
* Exclude building for arm64 on simulator devices in the pbxproj project.
|
|
8
|
-
* Without this, production builds targeting simulators will fail.
|
|
9
|
-
*/
|
|
10
|
-
export declare function setExcludedArchitectures(project: XcodeProject): XcodeProject;
|
|
1
|
+
import { type ConfigPlugin } from "@expo/config-plugins";
|
|
11
2
|
declare const _default: ConfigPlugin<void>;
|
|
12
3
|
export default _default;
|
|
13
4
|
//# sourceMappingURL=withMapLibre.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withMapLibre.d.ts","sourceRoot":"","sources":["../../../../../src/plugin/withMapLibre.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"withMapLibre.d.ts","sourceRoot":"","sources":["../../../../../src/plugin/withMapLibre.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAuB,MAAM,sBAAsB,CAAC;;AAuB9E,wBAAwE"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maplibre/maplibre-react-native",
|
|
3
3
|
"description": "React Native library for creating maps with MapLibre Native for Android & iOS",
|
|
4
|
-
"version": "10.0.0-beta.
|
|
4
|
+
"version": "10.0.0-beta.16",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
7
7
|
"provenance": true
|
|
@@ -165,6 +165,7 @@
|
|
|
165
165
|
"react-native-builder-bob": "^0.34.0",
|
|
166
166
|
"react-test-renderer": "18.3.1",
|
|
167
167
|
"semantic-release": "^24.2.0",
|
|
168
|
+
"snapshot-diff": "^0.10.0",
|
|
168
169
|
"ts-node": "^10.9.2",
|
|
169
170
|
"tsx": "^4.19.2",
|
|
170
171
|
"typescript": "^5.7.2"
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type ConfigPlugin,
|
|
3
|
+
withPodfile,
|
|
4
|
+
withXcodeProject,
|
|
5
|
+
type XcodeProject,
|
|
6
|
+
} from "@expo/config-plugins";
|
|
7
|
+
import { mergeContents } from "@expo/config-plugins/build/utils/generateCode";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Only the post-install block is required, the post installer block is used for SPM (Swift Package Manager) which Expo
|
|
11
|
+
* doesn't currently support.
|
|
12
|
+
*/
|
|
13
|
+
export function applyPodfilePostInstall(contents: string): string {
|
|
14
|
+
const result = mergeContents({
|
|
15
|
+
tag: `@maplibre/maplibre-react-native-post_installer`,
|
|
16
|
+
src: contents,
|
|
17
|
+
newSrc: ` $MLRN.post_install(installer)`,
|
|
18
|
+
anchor: new RegExp(`post_install do \\|installer\\|`),
|
|
19
|
+
offset: 1,
|
|
20
|
+
comment: "#",
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
if (result.didMerge || result.didClear) {
|
|
24
|
+
return result.contents;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return contents;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const withPodfilePostInstall: ConfigPlugin = (config) => {
|
|
31
|
+
return withPodfile(config, (c) => {
|
|
32
|
+
c.modResults.contents = applyPodfilePostInstall(c.modResults.contents);
|
|
33
|
+
|
|
34
|
+
return c;
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Exclude building for arm64 on simulator devices in the pbxproj project.
|
|
40
|
+
* Without this, production builds targeting simulators will fail.
|
|
41
|
+
*/
|
|
42
|
+
function setExcludedArchitectures(project: XcodeProject): XcodeProject {
|
|
43
|
+
const configurations = project.pbxXCBuildConfigurationSection();
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
for (const { name, buildSettings } of Object.values(configurations || {})) {
|
|
47
|
+
// Guessing that this is the best way to emulate Xcode.
|
|
48
|
+
// Using `project.addToBuildSettings` modifies too many targets.
|
|
49
|
+
if (
|
|
50
|
+
name === "Release" &&
|
|
51
|
+
typeof buildSettings?.PRODUCT_NAME !== "undefined"
|
|
52
|
+
) {
|
|
53
|
+
buildSettings['"EXCLUDED_ARCHS[sdk=iphonesimulator*]"'] = '"arm64"';
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return project;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const withoutSignatures: ConfigPlugin = (config) => {
|
|
61
|
+
return withXcodeProject(config, async (c) => {
|
|
62
|
+
c.modResults.addBuildPhase(
|
|
63
|
+
[],
|
|
64
|
+
"PBXShellScriptBuildPhase",
|
|
65
|
+
"Remove signature files (Xcode workaround)",
|
|
66
|
+
null,
|
|
67
|
+
{
|
|
68
|
+
shellPath: "/bin/sh",
|
|
69
|
+
shellScript: `
|
|
70
|
+
echo "Remove signature files (Xcode workaround)";
|
|
71
|
+
rm -rf "$CONFIGURATION_BUILD_DIR/MapLibre.xcframework-ios.signature";
|
|
72
|
+
`,
|
|
73
|
+
},
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
return c;
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Set the Debug Information Format to DWARF with dSYM File during EAS Build for Managed App
|
|
82
|
+
* https://github.com/expo/eas-cli/issues/968
|
|
83
|
+
*
|
|
84
|
+
* Set `artifactPath` in `eas.json`:
|
|
85
|
+
* ```json
|
|
86
|
+
* "ios": {
|
|
87
|
+
* "artifactPath": "ios/build/*"
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
const withDwarfDsym: ConfigPlugin = (config) => {
|
|
92
|
+
return withXcodeProject(config, async (c) => {
|
|
93
|
+
c.modResults.debugInformationFormat = "dwarf-with-dsym";
|
|
94
|
+
|
|
95
|
+
return c;
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const withExcludedSimulatorArchitectures: ConfigPlugin = (config) => {
|
|
100
|
+
return withXcodeProject(config, (c) => {
|
|
101
|
+
c.modResults = setExcludedArchitectures(c.modResults);
|
|
102
|
+
|
|
103
|
+
return c;
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export const ios = {
|
|
108
|
+
withPodfilePostInstall,
|
|
109
|
+
withoutSignatures,
|
|
110
|
+
withDwarfDsym,
|
|
111
|
+
withExcludedSimulatorArchitectures,
|
|
112
|
+
};
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
withDangerousMod,
|
|
5
|
-
withXcodeProject,
|
|
6
|
-
type XcodeProject,
|
|
7
|
-
} from "@expo/config-plugins";
|
|
8
|
-
import {
|
|
9
|
-
mergeContents,
|
|
10
|
-
removeGeneratedContents,
|
|
11
|
-
} from "@expo/config-plugins/build/utils/generateCode";
|
|
12
|
-
import { promises } from "node:fs";
|
|
13
|
-
import path from "node:path";
|
|
1
|
+
import { type ConfigPlugin, createRunOncePlugin } from "@expo/config-plugins";
|
|
2
|
+
|
|
3
|
+
import { ios } from "./ios";
|
|
14
4
|
|
|
15
5
|
let pkg: { name: string; version?: string } = {
|
|
16
6
|
name: "@maplibre/maplibre-react-native",
|
|
@@ -21,161 +11,14 @@ try {
|
|
|
21
11
|
// empty catch block
|
|
22
12
|
}
|
|
23
13
|
|
|
24
|
-
type InstallerBlockName = "pre" | "post";
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Dangerously adds the custom installer hooks to the Podfile.
|
|
28
|
-
* In the future this should be removed in favor of some custom hooks provided by Expo autolinking.
|
|
29
|
-
*
|
|
30
|
-
* https://github.com/maplibre/maplibre-react-native/blob/main/docs/guides/setup/iOS.md
|
|
31
|
-
*/
|
|
32
|
-
const withCocoaPodsInstallerBlocks: ConfigPlugin = (c) => {
|
|
33
|
-
return withDangerousMod(c, [
|
|
34
|
-
"ios",
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
36
|
-
async (config) => {
|
|
37
|
-
const file = path.join(config.modRequest.platformProjectRoot, "Podfile");
|
|
38
|
-
|
|
39
|
-
const contents = await promises.readFile(file, "utf8");
|
|
40
|
-
|
|
41
|
-
await promises.writeFile(
|
|
42
|
-
file,
|
|
43
|
-
applyCocoaPodsModifications(contents),
|
|
44
|
-
"utf-8",
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
return config;
|
|
48
|
-
},
|
|
49
|
-
]);
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// Only the post-install block is required, the post installer block is
|
|
53
|
-
// used for spm (swift package manager) which Expo doesn't currently support.
|
|
54
|
-
export function applyCocoaPodsModifications(contents: string): string {
|
|
55
|
-
// Ensure installer blocks exist
|
|
56
|
-
let src = addInstallerBlock(contents, "post");
|
|
57
|
-
src = addMapLibreInstallerBlock(src, "post");
|
|
58
|
-
|
|
59
|
-
return src;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export function addInstallerBlock(
|
|
63
|
-
src: string,
|
|
64
|
-
blockName: InstallerBlockName,
|
|
65
|
-
): string {
|
|
66
|
-
const matchBlock = new RegExp(`${blockName}_install do \\|installer\\|`);
|
|
67
|
-
const tag = `${blockName}_installer`;
|
|
68
|
-
for (const line of src.split("\n")) {
|
|
69
|
-
const contents = line.trim();
|
|
70
|
-
// Ignore comments
|
|
71
|
-
if (!contents.startsWith("#")) {
|
|
72
|
-
// Prevent adding the block if it exists outside of comments.
|
|
73
|
-
if (contents.match(matchBlock)) {
|
|
74
|
-
// This helps to still allow revisions, since we enabled the block previously.
|
|
75
|
-
// Only continue if the generated block exists...
|
|
76
|
-
const modified = removeGeneratedContents(src, tag);
|
|
77
|
-
if (!modified) {
|
|
78
|
-
return src;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return mergeContents({
|
|
85
|
-
tag,
|
|
86
|
-
src,
|
|
87
|
-
newSrc: [` ${blockName}_install do |installer|`, " end"].join("\n"),
|
|
88
|
-
anchor: /use_react_native/,
|
|
89
|
-
// We can't go after the use_react_native block because it might have parameters, causing it to be multi-line (see react-native template).
|
|
90
|
-
offset: 0,
|
|
91
|
-
comment: "#",
|
|
92
|
-
}).contents;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export function addMapLibreInstallerBlock(
|
|
96
|
-
src: string,
|
|
97
|
-
blockName: InstallerBlockName,
|
|
98
|
-
): string {
|
|
99
|
-
return mergeContents({
|
|
100
|
-
tag: `@maplibre/maplibre-react-native-${blockName}_installer`,
|
|
101
|
-
src,
|
|
102
|
-
newSrc: ` $MLRN.${blockName}_install(installer)`,
|
|
103
|
-
anchor: new RegExp(`${blockName}_install do \\|installer\\|`),
|
|
104
|
-
offset: 1,
|
|
105
|
-
comment: "#",
|
|
106
|
-
}).contents;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Exclude building for arm64 on simulator devices in the pbxproj project.
|
|
111
|
-
* Without this, production builds targeting simulators will fail.
|
|
112
|
-
*/
|
|
113
|
-
export function setExcludedArchitectures(project: XcodeProject): XcodeProject {
|
|
114
|
-
const configurations = project.pbxXCBuildConfigurationSection();
|
|
115
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
116
|
-
// @ts-ignore
|
|
117
|
-
for (const { name, buildSettings } of Object.values(configurations || {})) {
|
|
118
|
-
// Guessing that this is the best way to emulate Xcode.
|
|
119
|
-
// Using `project.addToBuildSettings` modifies too many targets.
|
|
120
|
-
if (
|
|
121
|
-
name === "Release" &&
|
|
122
|
-
typeof buildSettings?.PRODUCT_NAME !== "undefined"
|
|
123
|
-
) {
|
|
124
|
-
buildSettings['"EXCLUDED_ARCHS[sdk=iphonesimulator*]"'] = '"arm64"';
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
return project;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const withoutSignatures: ConfigPlugin = (config) => {
|
|
131
|
-
const shellScript = `
|
|
132
|
-
echo "Remove signature files (Xcode workaround)";
|
|
133
|
-
rm -rf "$CONFIGURATION_BUILD_DIR/MapLibre.xcframework-ios.signature";
|
|
134
|
-
`;
|
|
135
|
-
return withXcodeProject(config, async (config) => {
|
|
136
|
-
const xcodeProject = config.modResults;
|
|
137
|
-
xcodeProject.addBuildPhase(
|
|
138
|
-
[],
|
|
139
|
-
"PBXShellScriptBuildPhase",
|
|
140
|
-
"Remove signature files (Xcode workaround)",
|
|
141
|
-
null,
|
|
142
|
-
{
|
|
143
|
-
shellPath: "/bin/sh",
|
|
144
|
-
shellScript,
|
|
145
|
-
},
|
|
146
|
-
);
|
|
147
|
-
return config;
|
|
148
|
-
});
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* Set the Debug Information Format to DWARF with dSYM File during EAS Build for Managed App
|
|
153
|
-
* https://github.com/expo/eas-cli/issues/968
|
|
154
|
-
* // Set artifactPath in eas.json
|
|
155
|
-
* "ios": {
|
|
156
|
-
* "artifactPath": "ios/build/*"
|
|
157
|
-
* }
|
|
158
|
-
*/
|
|
159
|
-
const withDwarfDsym: ConfigPlugin = (config) => {
|
|
160
|
-
return withXcodeProject(config, async (config) => {
|
|
161
|
-
const xcodeProject = config.modResults;
|
|
162
|
-
xcodeProject.debugInformationFormat = "dwarf-with-dsym";
|
|
163
|
-
return config;
|
|
164
|
-
});
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
const withExcludedSimulatorArchitectures: ConfigPlugin = (c) => {
|
|
168
|
-
return withXcodeProject(c, (config) => {
|
|
169
|
-
config.modResults = setExcludedArchitectures(config.modResults);
|
|
170
|
-
return config;
|
|
171
|
-
});
|
|
172
|
-
};
|
|
173
|
-
|
|
174
14
|
const withMapLibre: ConfigPlugin = (config) => {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
);
|
|
178
|
-
|
|
15
|
+
// iOS
|
|
16
|
+
config = ios.withExcludedSimulatorArchitectures(config);
|
|
17
|
+
config = ios.withDwarfDsym(config);
|
|
18
|
+
config = ios.withoutSignatures(config);
|
|
19
|
+
config = ios.withPodfilePostInstall(config);
|
|
20
|
+
|
|
21
|
+
return config;
|
|
179
22
|
};
|
|
180
23
|
|
|
181
24
|
export default createRunOncePlugin(withMapLibre, pkg.name, pkg.version);
|