@therealitycrafters/react-native-evskit 0.1.2 → 0.1.3
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/package.json +1 -1
- package/plugin/withEvsScreens.js +26 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@therealitycrafters/react-native-evskit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "React Native / Expo bridge for Everysight's Maverick SDK (EvsKit + NativeEvsKit)",
|
|
5
5
|
"author": "Patrick Catanzariti",
|
|
6
6
|
"homepage": "https://therealitycrafters.com",
|
package/plugin/withEvsScreens.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const { withAppBuildGradle, withXcodeProject } = require("@expo/config-plugins");
|
|
1
|
+
const { withAppBuildGradle, withDangerousMod, withXcodeProject } = require("@expo/config-plugins");
|
|
2
2
|
const fs = require("fs");
|
|
3
3
|
const path = require("path");
|
|
4
4
|
|
|
@@ -219,20 +219,34 @@ function generatedAndroidContents(register) {
|
|
|
219
219
|
}
|
|
220
220
|
|
|
221
221
|
function withEvsAndroidScreens(config, androidScreensDir, register) {
|
|
222
|
-
|
|
223
|
-
//
|
|
224
|
-
//
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
222
|
+
// NOTE: config.modRequest only exists inside a mod callback — never read
|
|
223
|
+
// projectRoot at the outer plugin level (it is undefined there and crashes
|
|
224
|
+
// prebuild with "Cannot read properties of undefined").
|
|
225
|
+
const hasRegister = Object.keys(register).length > 0;
|
|
226
|
+
|
|
227
|
+
// Write the generated registrar into a disposable dir under android/.
|
|
228
|
+
// withDangerousMod runs after the native project exists, so ios/android
|
|
229
|
+
// dirs are present and modRequest.projectRoot is available.
|
|
230
|
+
if (hasRegister) {
|
|
231
|
+
config = withDangerousMod(config, [
|
|
232
|
+
"android",
|
|
233
|
+
(config) => {
|
|
234
|
+
const projectRoot = config.modRequest.projectRoot;
|
|
235
|
+
const genDir = path.join(projectRoot, "android", GENERATED_ANDROID_DIR);
|
|
236
|
+
fs.mkdirSync(genDir, { recursive: true });
|
|
237
|
+
fs.writeFileSync(
|
|
238
|
+
path.join(genDir, `${GENERATED_ANDROID_CLASS}.kt`),
|
|
239
|
+
generatedAndroidContents(register),
|
|
240
|
+
);
|
|
241
|
+
return config;
|
|
242
|
+
},
|
|
243
|
+
]);
|
|
232
244
|
}
|
|
245
|
+
|
|
233
246
|
// Register the app-owned screens dir (+ generated dir) as extra java
|
|
234
247
|
// srcDirs so their .kt files compile into the app.
|
|
235
248
|
config = withAppBuildGradle(config, (config) => {
|
|
249
|
+
const projectRoot = config.modRequest.projectRoot;
|
|
236
250
|
const marker = "// react-native-evskit: app-owned glasses screens";
|
|
237
251
|
if (config.modResults.contents.includes(marker)) {
|
|
238
252
|
return config;
|
|
@@ -240,7 +254,7 @@ function withEvsAndroidScreens(config, androidScreensDir, register) {
|
|
|
240
254
|
// Paths relative to <projectRoot>/android/app.
|
|
241
255
|
const appDir = path.join(projectRoot, "android", "app");
|
|
242
256
|
const srcDirs = [toPosix(path.relative(appDir, path.join(projectRoot, androidScreensDir)))];
|
|
243
|
-
if (
|
|
257
|
+
if (hasRegister) {
|
|
244
258
|
srcDirs.push(
|
|
245
259
|
toPosix(path.relative(appDir, path.join(projectRoot, "android", GENERATED_ANDROID_DIR))),
|
|
246
260
|
);
|