@maplibre/maplibre-react-native 10.0.0-beta.13 → 10.0.0-beta.14

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.
Files changed (35) hide show
  1. package/README.md +9 -11
  2. package/android/src/main/java/org/maplibre/reactnative/components/camera/MLRNCamera.java +37 -48
  3. package/android/src/main/java/org/maplibre/reactnative/components/location/LocationComponentManager.java +16 -9
  4. package/app.plugin.js +1 -1
  5. package/ios/MLRN/MLRNCamera.m +6 -7
  6. package/lib/commonjs/components/Camera.js +109 -60
  7. package/lib/commonjs/components/Camera.js.map +1 -1
  8. package/lib/commonjs/components/MapView.js +6 -6
  9. package/lib/commonjs/modules/offline/OfflineManager.js +8 -8
  10. package/lib/commonjs/plugin/withMapLibre.js +149 -0
  11. package/lib/commonjs/plugin/withMapLibre.js.map +1 -0
  12. package/lib/module/components/Camera.js +111 -62
  13. package/lib/module/components/Camera.js.map +1 -1
  14. package/lib/module/components/MapView.js +6 -6
  15. package/lib/module/modules/offline/OfflineManager.js +8 -8
  16. package/lib/module/plugin/withMapLibre.js +140 -0
  17. package/lib/module/plugin/withMapLibre.js.map +1 -0
  18. package/lib/typescript/commonjs/src/components/Camera.d.ts.map +1 -1
  19. package/lib/typescript/commonjs/src/modules/offline/OfflineManager.d.ts +8 -8
  20. package/{plugin/build → lib/typescript/commonjs/src/plugin}/withMapLibre.d.ts +1 -0
  21. package/lib/typescript/commonjs/src/plugin/withMapLibre.d.ts.map +1 -0
  22. package/lib/typescript/module/src/components/Camera.d.ts.map +1 -1
  23. package/lib/typescript/module/src/modules/offline/OfflineManager.d.ts +8 -8
  24. package/lib/typescript/module/src/plugin/withMapLibre.d.ts +13 -0
  25. package/lib/typescript/module/src/plugin/withMapLibre.d.ts.map +1 -0
  26. package/package.json +8 -10
  27. package/src/components/Camera.tsx +151 -73
  28. package/src/components/MapView.tsx +6 -6
  29. package/src/modules/offline/OfflineManager.ts +8 -8
  30. package/src/plugin/withMapLibre.ts +181 -0
  31. package/lib/typescript/commonjs/jest.config.d.ts +0 -2
  32. package/lib/typescript/commonjs/jest.config.d.ts.map +0 -1
  33. package/lib/typescript/module/jest.config.d.ts +0 -2
  34. package/lib/typescript/module/jest.config.d.ts.map +0 -1
  35. package/plugin/build/withMapLibre.js +0 -148
@@ -1,148 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.applyCocoaPodsModifications = applyCocoaPodsModifications;
7
- exports.addInstallerBlock = addInstallerBlock;
8
- exports.addMapLibreInstallerBlock = addMapLibreInstallerBlock;
9
- exports.setExcludedArchitectures = setExcludedArchitectures;
10
- const config_plugins_1 = require("@expo/config-plugins");
11
- const generateCode_1 = require("@expo/config-plugins/build/utils/generateCode");
12
- const node_fs_1 = require("node:fs");
13
- const node_path_1 = __importDefault(require("node:path"));
14
- let pkg = {
15
- name: "@maplibre/maplibre-react-native",
16
- };
17
- try {
18
- pkg = require("@maplibre/maplibre-react-native/package.json");
19
- }
20
- catch {
21
- // empty catch block
22
- }
23
- /**
24
- * Dangerously adds the custom installer hooks to the Podfile.
25
- * In the future this should be removed in favor of some custom hooks provided by Expo autolinking.
26
- *
27
- * https://github.com/maplibre/maplibre-react-native/blob/main/docs/guides/setup/iOS.md
28
- * @param config
29
- * @returns
30
- */
31
- const withCocoaPodsInstallerBlocks = (c) => {
32
- return (0, config_plugins_1.withDangerousMod)(c, [
33
- "ios",
34
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
35
- async (config) => {
36
- const file = node_path_1.default.join(config.modRequest.platformProjectRoot, "Podfile");
37
- const contents = await node_fs_1.promises.readFile(file, "utf8");
38
- await node_fs_1.promises.writeFile(file, applyCocoaPodsModifications(contents), "utf-8");
39
- return config;
40
- },
41
- ]);
42
- };
43
- // Only the preinstaller block is required, the post installer block is
44
- // used for spm (swift package manager) which Expo doesn't currently support.
45
- function applyCocoaPodsModifications(contents) {
46
- // Ensure installer blocks exist
47
- // let src = addInstallerBlock(contents, 'pre');
48
- let src = addInstallerBlock(contents, "post");
49
- // src = addMapLibreInstallerBlock(src, 'pre');
50
- src = addMapLibreInstallerBlock(src, "post");
51
- return src;
52
- }
53
- function addInstallerBlock(src, blockName) {
54
- const matchBlock = new RegExp(`${blockName}_install do \\|installer\\|`);
55
- const tag = `${blockName}_installer`;
56
- for (const line of src.split("\n")) {
57
- const contents = line.trim();
58
- // Ignore comments
59
- if (!contents.startsWith("#")) {
60
- // Prevent adding the block if it exists outside of comments.
61
- if (contents.match(matchBlock)) {
62
- // This helps to still allow revisions, since we enabled the block previously.
63
- // Only continue if the generated block exists...
64
- const modified = (0, generateCode_1.removeGeneratedContents)(src, tag);
65
- if (!modified) {
66
- return src;
67
- }
68
- }
69
- }
70
- }
71
- return (0, generateCode_1.mergeContents)({
72
- tag,
73
- src,
74
- newSrc: [` ${blockName}_install do |installer|`, " end"].join("\n"),
75
- anchor: /use_react_native/,
76
- // 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).
77
- offset: 0,
78
- comment: "#",
79
- }).contents;
80
- }
81
- function addMapLibreInstallerBlock(src, blockName) {
82
- return (0, generateCode_1.mergeContents)({
83
- tag: `@maplibre/maplibre-react-native-${blockName}_installer`,
84
- src,
85
- newSrc: ` $MLRN.${blockName}_install(installer)`,
86
- anchor: new RegExp(`${blockName}_install do \\|installer\\|`),
87
- offset: 1,
88
- comment: "#",
89
- }).contents;
90
- }
91
- /**
92
- * Exclude building for arm64 on simulator devices in the pbxproj project.
93
- * Without this, production builds targeting simulators will fail.
94
- */
95
- function setExcludedArchitectures(project) {
96
- const configurations = project.pbxXCBuildConfigurationSection();
97
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
98
- // @ts-ignore
99
- for (const { name, buildSettings } 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" &&
103
- typeof buildSettings?.PRODUCT_NAME !== "undefined") {
104
- buildSettings['"EXCLUDED_ARCHS[sdk=iphonesimulator*]"'] = '"arm64"';
105
- }
106
- }
107
- return project;
108
- }
109
- const withoutSignatures = (config) => {
110
- const shellScript = `
111
- echo "Remove signature files (Xcode workaround)";
112
- rm -rf "$CONFIGURATION_BUILD_DIR/MapLibre.xcframework-ios.signature";
113
- `;
114
- return (0, config_plugins_1.withXcodeProject)(config, async (config) => {
115
- const xcodeProject = config.modResults;
116
- xcodeProject.addBuildPhase([], "PBXShellScriptBuildPhase", "Remove signature files (Xcode workaround)", null, {
117
- shellPath: "/bin/sh",
118
- shellScript,
119
- });
120
- return config;
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, config_plugins_1.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, config_plugins_1.withXcodeProject)(c, (config) => {
140
- config.modResults = setExcludedArchitectures(config.modResults);
141
- return config;
142
- });
143
- };
144
- const withMapLibre = (config) => {
145
- config = withoutSignatures(withDwarfDsym(withExcludedSimulatorArchitectures(config)));
146
- return withCocoaPodsInstallerBlocks(config);
147
- };
148
- exports.default = (0, config_plugins_1.createRunOncePlugin)(withMapLibre, pkg.name, pkg.version);