@therealitycrafters/react-native-evskit 0.1.2 → 0.1.4

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.
@@ -251,10 +251,7 @@ public class EvsKitModule: Module {
251
251
 
252
252
  AsyncFunction("setApiKey") { (base64Key: String) -> Void in
253
253
  guard let data = Data(base64Encoded: base64Key) else { return }
254
- let byteArray = KotlinByteArray(size: Int32(data.count))
255
- for i in 0..<data.count {
256
- byteArray.set(index: Int32(i), value: Int8(data[i]))
257
- }
254
+ guard let byteArray = data.toKotlinData() else { return }
258
255
  Evs.instance().auth().setApiKey(apiKey: byteArray)
259
256
  }
260
257
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@therealitycrafters/react-native-evskit",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
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",
@@ -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
- const projectRoot = config.modRequest.projectRoot;
223
- // Write the generated registrar into a disposable dir under android/ and
224
- // compile it via an extra srcDir (same mechanism as the app-owned dir).
225
- if (Object.keys(register).length) {
226
- const genDir = path.join(projectRoot, "android", GENERATED_ANDROID_DIR);
227
- fs.mkdirSync(genDir, { recursive: true });
228
- fs.writeFileSync(
229
- path.join(genDir, `${GENERATED_ANDROID_CLASS}.kt`),
230
- generatedAndroidContents(register),
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 (Object.keys(register).length) {
257
+ if (hasRegister) {
244
258
  srcDirs.push(
245
259
  toPosix(path.relative(appDir, path.join(projectRoot, "android", GENERATED_ANDROID_DIR))),
246
260
  );