yaver-feedback-react-native 0.7.13 → 0.7.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.
- package/app.plugin.js +44 -3
- package/package.json +1 -1
package/app.plugin.js
CHANGED
|
@@ -188,9 +188,22 @@ function withYaverAppDelegateHook(config) {
|
|
|
188
188
|
);
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
// 2. Add reload notification handler and bridge recreation logic
|
|
192
|
-
//
|
|
193
|
-
|
|
191
|
+
// 2. Add reload notification handler and bridge recreation logic.
|
|
192
|
+
//
|
|
193
|
+
// Must be inserted into the AppDelegate class — NOT ReactNativeDelegate
|
|
194
|
+
// (a separate class below it in the same file). The handler accesses
|
|
195
|
+
// `self.window`, `self.reactNativeDelegate`, `self.reactNativeFactory`,
|
|
196
|
+
// and `self.bindReactNativeFactory(...)` — all of which only exist
|
|
197
|
+
// on AppDelegate. An earlier version of this plugin used
|
|
198
|
+
// lastIndexOf("}"), which in modern Expo templates lands inside
|
|
199
|
+
// ReactNativeDelegate, producing build errors like
|
|
200
|
+
// "cannot find 'setupYaverHotReload' in scope"
|
|
201
|
+
// "value of type 'ReactNativeDelegate' has no member 'window'"
|
|
202
|
+
//
|
|
203
|
+
// The anchor we want is the closing brace of the AppDelegate class
|
|
204
|
+
// declaration itself. Find its opening, then walk braces to its
|
|
205
|
+
// matching close.
|
|
206
|
+
const classCloseIndex = findAppDelegateClassClose(patched);
|
|
194
207
|
if (classCloseIndex > 0) {
|
|
195
208
|
const reloadHandler = `
|
|
196
209
|
// MARK: - Yaver Feedback SDK Hot Reload
|
|
@@ -298,6 +311,34 @@ function withYaverAppDelegateHook(config) {
|
|
|
298
311
|
});
|
|
299
312
|
}
|
|
300
313
|
|
|
314
|
+
// Locate the closing brace of `class AppDelegate: ...` in an Expo
|
|
315
|
+
// Swift AppDelegate file. Returns the index of the matching `}` for
|
|
316
|
+
// the AppDelegate class's opening `{`, or -1 if not found. We need
|
|
317
|
+
// this because Expo's modern template declares TWO classes in the
|
|
318
|
+
// same file (AppDelegate + ReactNativeDelegate), and the SDK's
|
|
319
|
+
// reload handler only makes sense on the AppDelegate one.
|
|
320
|
+
function findAppDelegateClassClose(contents) {
|
|
321
|
+
// Match both `public class AppDelegate` and `class AppDelegate`,
|
|
322
|
+
// with either inheritance colon or a plain body.
|
|
323
|
+
const headerMatch = contents.match(/class\s+AppDelegate\s*[:{][^{]*\{/);
|
|
324
|
+
if (!headerMatch) return -1;
|
|
325
|
+
const bodyStart = headerMatch.index + headerMatch[0].length - 1; // index of the opening `{`
|
|
326
|
+
// Walk braces to find the matching close. Minimal — we don't try
|
|
327
|
+
// to parse strings/comments because the file is machine-generated
|
|
328
|
+
// by Expo, so braces inside strings are not a realistic concern
|
|
329
|
+
// at this layer.
|
|
330
|
+
let depth = 0;
|
|
331
|
+
for (let i = bodyStart; i < contents.length; i++) {
|
|
332
|
+
const ch = contents[i];
|
|
333
|
+
if (ch === "{") depth++;
|
|
334
|
+
else if (ch === "}") {
|
|
335
|
+
depth--;
|
|
336
|
+
if (depth === 0) return i;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return -1;
|
|
340
|
+
}
|
|
341
|
+
|
|
301
342
|
/**
|
|
302
343
|
* Copy Android native module source files and register the package.
|
|
303
344
|
* Also patches MainApplication to use hot-reloaded bundle on startup.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "yaver-feedback-react-native",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.14",
|
|
4
4
|
"description": "Visual feedback SDK for Yaver — bug reports, screen recording, voice annotations, and local-first developer workflows",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|