@bugsee/react-native 0.0.0-stage → 7.0.0-beta1
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/BugseeReactNative.podspec +95 -0
- package/LICENSE +21 -0
- package/README.md +552 -2
- package/android/build.gradle +162 -0
- package/android/consumer-rules.pro +2 -0
- package/android/src/main/AndroidManifest.xml +33 -0
- package/android/src/main/java/com/bugsee/reactnative/AppearanceBridge.java +82 -0
- package/android/src/main/java/com/bugsee/reactnative/AttributeBridge.java +209 -0
- package/android/src/main/java/com/bugsee/reactnative/BreadcrumbFilterBridge.java +443 -0
- package/android/src/main/java/com/bugsee/reactnative/BridgeJson.java +168 -0
- package/android/src/main/java/com/bugsee/reactnative/BugseeModule.java +1869 -0
- package/android/src/main/java/com/bugsee/reactnative/BugseeOptionEnums.java +136 -0
- package/android/src/main/java/com/bugsee/reactnative/BugseePackage.java +42 -0
- package/android/src/main/java/com/bugsee/reactnative/BugseeReactNativeWrapper.java +200 -0
- package/android/src/main/java/com/bugsee/reactnative/BugseeStatusMapper.java +66 -0
- package/android/src/main/java/com/bugsee/reactnative/BugseeTokens.java +22 -0
- package/android/src/main/java/com/bugsee/reactnative/ConsoleEchoDedup.java +202 -0
- package/android/src/main/java/com/bugsee/reactnative/CreatedReports.java +127 -0
- package/android/src/main/java/com/bugsee/reactnative/DataRequestBridge.java +375 -0
- package/android/src/main/java/com/bugsee/reactnative/ExceptionBridge.java +88 -0
- package/android/src/main/java/com/bugsee/reactnative/ExceptionExecutors.java +33 -0
- package/android/src/main/java/com/bugsee/reactnative/LogFilterBridge.java +375 -0
- package/android/src/main/java/com/bugsee/reactnative/NetworkEvents.java +227 -0
- package/android/src/main/java/com/bugsee/reactnative/NetworkFilterBridge.java +498 -0
- package/android/src/main/java/com/bugsee/reactnative/PluginEndpoint.java +48 -0
- package/android/src/main/java/com/bugsee/reactnative/ReactNativeWebException.java +19 -0
- package/android/src/main/java/com/bugsee/reactnative/ReactNativeWrapperInitProvider.java +61 -0
- package/android/src/main/java/com/bugsee/reactnative/ReactRootOriginTracker.java +867 -0
- package/android/src/main/java/com/bugsee/reactnative/ReportArgs.java +58 -0
- package/android/src/main/java/com/bugsee/reactnative/ReportHandlerBridge.java +336 -0
- package/android/src/main/java/com/bugsee/reactnative/ReportHandlerDeadlines.java +57 -0
- package/android/src/main/java/com/bugsee/reactnative/ReportOps.java +287 -0
- package/android/src/main/java/com/bugsee/reactnative/SecureRectanglePulls.java +113 -0
- package/android/src/main/java/com/bugsee/reactnative/SecureRectangleStore.java +692 -0
- package/android/src/main/java/com/bugsee/reactnative/SpanHandles.java +143 -0
- package/android/src/main/java/com/bugsee/reactnative/WrapperChannelHolder.java +137 -0
- package/android/src/main/java/com/bugsee/reactnative/WrapperEventBus.java +110 -0
- package/android/src/main/java/com/bugsee/reactnative/WrapperRegistrar.java +54 -0
- package/app.plugin.js +4 -0
- package/ios/BGSRNConsoleCapture.h +52 -0
- package/ios/BGSRNConsoleCapture.mm +344 -0
- package/ios/BugseeModule.h +25 -0
- package/ios/BugseeModule.mm +2728 -0
- package/ios/Package.swift +71 -0
- package/ios/Support/Package.resolved +14 -0
- package/ios/Support/Package.swift +44 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNAttributes.m +52 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNCreatedReportOps.m +236 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNCreatedReports.m +184 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNDataRequestBridge.m +431 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNErrorMessage.m +40 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNEventBus.m +70 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNExceptions.m +63 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNGuardedEmit.mm +32 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNJSON.m +40 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNLaunchHold.m +147 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNMainThread.m +23 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNNetworkEvents.m +159 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNNetworkFilter.m +155 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNPluginEndpoint.m +21 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNReactRootOriginTracker.m +63 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNReactWindow.m +251 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNReportArgs.m +47 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNReportDeadlines.m +8 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNReportHandlerBridge.m +308 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNReportOps.m +345 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNSecureRectangles.m +508 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNSettleOnce.m +62 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNSpanHandles.m +136 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNStatusMapper.m +18 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNTokens.m +9 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNValues.m +5 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNWrapper.m +54 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNWrapperChannelHolder.m +59 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNAttributes.h +63 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNCreatedReportOps.h +51 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNCreatedReports.h +81 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNDataRequestBridge.h +118 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNErrorMessage.h +30 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNEventBus.h +45 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNExceptions.h +31 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNGuardedEmit.h +31 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNJSON.h +25 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNLaunchHold.h +86 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNMainThread.h +32 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNNetworkEvents.h +28 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNNetworkFilter.h +28 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNPluginEndpoint.h +17 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReactRootOriginTracker.h +48 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReactWindow.h +135 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportArgs.h +17 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportDeadlines.h +37 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportHandlerBridge.h +94 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportOps.h +86 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNSecureRectangles.h +198 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNSettleOnce.h +25 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNSpanHandles.h +49 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNStatusMapper.h +26 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNTokens.h +14 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNValues.h +18 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNWrapper.h +40 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNWrapperChannelHolder.h +74 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNAttributesTests.m +194 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNCreatedReportOpsTests.m +274 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNCreatedReportsTests.m +240 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNDataRequestBridgeTests.m +685 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNErrorMessageTests.m +102 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNEventBusTests.m +136 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNExceptionsTests.m +68 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNFakeReport.h +41 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNFakeReport.m +166 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNGuardedEmitTests.mm +85 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNJSONTests.m +281 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNLaunchHoldTests.m +230 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNMainThreadTests.m +97 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNNetworkEventsTests.m +99 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNNetworkFilterTests.m +134 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNPluginEndpointTests.m +38 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReactRootOriginTrackerTests.m +210 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReactWindowTests.m +548 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportArgsTests.m +51 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportDeadlinesTests.m +22 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportHandlerBridgeTests.m +382 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportOpsTests.m +295 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNSecureRectanglesTests.m +568 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNSettleOnceTests.m +134 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNSpanHandlesTests.m +153 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNStatusMapperTests.m +81 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNValuesTests.m +32 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNWrapperChannelHolderTests.m +205 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNWrapperTests.m +66 -0
- package/ios/react-native-spm-prefix.h +10 -0
- package/native-versions.json +10 -0
- package/package.json +62 -3
- package/plugin/build/bundle-phase.d.ts +41 -0
- package/plugin/build/bundle-phase.js +116 -0
- package/plugin/build/bundle-phase.js.map +1 -0
- package/plugin/build/dsym-script.d.ts +32 -0
- package/plugin/build/dsym-script.js +159 -0
- package/plugin/build/dsym-script.js.map +1 -0
- package/plugin/build/endpoint.d.ts +30 -0
- package/plugin/build/endpoint.js +69 -0
- package/plugin/build/endpoint.js.map +1 -0
- package/plugin/build/gradle.d.ts +65 -0
- package/plugin/build/gradle.js +1066 -0
- package/plugin/build/gradle.js.map +1 -0
- package/plugin/build/index.d.ts +85 -0
- package/plugin/build/index.js +217 -0
- package/plugin/build/index.js.map +1 -0
- package/plugin/build/manifest.d.ts +48 -0
- package/plugin/build/manifest.js +69 -0
- package/plugin/build/manifest.js.map +1 -0
- package/plugin/build/native-versions.baked.json +4 -0
- package/plugin/build/native-versions.d.ts +10 -0
- package/plugin/build/native-versions.js +27 -0
- package/plugin/build/native-versions.js.map +1 -0
- package/plugin/build/pbx-string.d.ts +8 -0
- package/plugin/build/pbx-string.js +31 -0
- package/plugin/build/pbx-string.js.map +1 -0
- package/plugin/build/podfile.d.ts +3 -0
- package/plugin/build/podfile.js +28 -0
- package/plugin/build/podfile.js.map +1 -0
- package/plugin/build/properties.d.ts +19 -0
- package/plugin/build/properties.js +41 -0
- package/plugin/build/properties.js.map +1 -0
- package/plugin/build/scheme.d.ts +20 -0
- package/plugin/build/scheme.js +107 -0
- package/plugin/build/scheme.js.map +1 -0
- package/react-native.config.js +26 -0
- package/scripts/bugsee-sourcemaps.gradle +201 -0
- package/scripts/bugsee-xcode.sh +83 -0
- package/scripts/compose-then-inject.js +113 -0
- package/scripts/hermes-sourcemaps.js +634 -0
- package/scripts/hermesc-preserve-js.cmd +6 -0
- package/scripts/hermesc-preserve-js.js +200 -0
- package/scripts/hermesc-preserve-js.sh +7 -0
- package/src/NativeBugsee.ts +622 -0
- package/src/apm/notify.ts +58 -0
- package/src/apm/span.ts +403 -0
- package/src/apm/types.ts +57 -0
- package/src/appearance/report.ts +171 -0
- package/src/architecture.ts +48 -0
- package/src/attributes/errors.ts +39 -0
- package/src/attributes/validate.ts +150 -0
- package/src/breadcrumbs/add.ts +58 -0
- package/src/breadcrumbs/data.ts +33 -0
- package/src/breadcrumbs/filter.ts +215 -0
- package/src/breadcrumbs/types.ts +64 -0
- package/src/bridge/json.ts +110 -0
- package/src/console/capture.ts +180 -0
- package/src/console/dedup.ts +175 -0
- package/src/data/validate.ts +259 -0
- package/src/errorName.ts +32 -0
- package/src/exceptions/ErrorBoundary.tsx +92 -0
- package/src/exceptions/RootErrorReporter.tsx +61 -0
- package/src/exceptions/debugIds.ts +118 -0
- package/src/exceptions/handlers.ts +236 -0
- package/src/exceptions/options.ts +85 -0
- package/src/exceptions/payload.ts +456 -0
- package/src/exceptions/report.ts +170 -0
- package/src/exceptions/sha1.ts +148 -0
- package/src/exceptions/stack.ts +355 -0
- package/src/index.ts +944 -0
- package/src/logs/filter.ts +90 -0
- package/src/logs/log.ts +36 -0
- package/src/network/add.ts +165 -0
- package/src/network/filter.ts +198 -0
- package/src/options/AndroidLaunchOptions.ts +78 -0
- package/src/options/BugseeLaunchOptions.ts +190 -0
- package/src/options/IOSLaunchOptions.ts +57 -0
- package/src/options/android-options-manifest.json +646 -0
- package/src/options/createDefaultLaunchOptions.ts +29 -0
- package/src/options/endpoint.ts +58 -0
- package/src/options/enums.ts +104 -0
- package/src/options/ios-enums.json +19 -0
- package/src/options/keys.ts +39 -0
- package/src/options/option-enums.json +34 -0
- package/src/options/option-keys.json +107 -0
- package/src/report/BugseeReport.ts +264 -0
- package/src/report/CreatedReport.ts +127 -0
- package/src/report/dispatcher.ts +95 -0
- package/src/report/errors.ts +48 -0
- package/src/report/fields.ts +40 -0
- package/src/report/types.ts +157 -0
- package/src/report/validate.ts +197 -0
- package/src/secure/BugseeSecure.tsx +202 -0
- package/src/secure/ancestry.ts +622 -0
- package/src/secure/drivers.ts +342 -0
- package/src/secure/followEvents.ts +57 -0
- package/src/secure/hold.ts +99 -0
- package/src/secure/measureLoop.ts +323 -0
- package/src/secure/nativeAnimation.ts +1005 -0
- package/src/secure/rectangles.ts +93 -0
- package/src/secure/registry.ts +237 -0
- package/src/secure/surface.ts +83 -0
- package/src/secure/tracker.ts +723 -0
- package/src/secure/transition.ts +488 -0
- package/src/secure/unit.ts +22 -0
- package/src/status.ts +16 -0
- package/src/version.ts +9 -0
- package/src/viewtree/anchor.tsx +105 -0
- package/src/viewtree/constants.ts +20 -0
- package/src/viewtree/fiber.ts +251 -0
- package/src/viewtree/requests.ts +347 -0
- package/src/viewtree/walk.ts +902 -0
- package/src/wrapper/channel.ts +33 -0
- package/src/wrapper/collect.ts +52 -0
- package/src/wrapper/events.ts +45 -0
- package/src/wrapper/identity.ts +54 -0
- package/src/wrapper/lifecycle-events.ts +89 -0
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
#import <CoreGraphics/CoreGraphics.h>
|
|
2
|
+
#import <Foundation/Foundation.h>
|
|
3
|
+
|
|
4
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
5
|
+
|
|
6
|
+
/// The app's own React root's surface key. Legacy writers that do not name a
|
|
7
|
+
/// surface land here.
|
|
8
|
+
FOUNDATION_EXPORT const NSInteger BGSRNSecureMainSurface;
|
|
9
|
+
|
|
10
|
+
/// The side of the square a surface whose origin is unknown serves before its
|
|
11
|
+
/// display's size is recorded (`setDisplaySize:forDisplay:`).
|
|
12
|
+
FOUNDATION_EXPORT const int32_t BGSRNSecureFallbackDisplaySize;
|
|
13
|
+
|
|
14
|
+
/// The regions the app has asked Bugsee not to record, in the form the SDK
|
|
15
|
+
/// pulls them.
|
|
16
|
+
///
|
|
17
|
+
/// The SDK does not subscribe to changes. It asks on the MAIN thread, once per
|
|
18
|
+
/// captured frame and per report screenshot (and from the touch filter, at
|
|
19
|
+
/// most every 100 ms, while nothing captures), for a packed buffer of
|
|
20
|
+
/// little-endian `int32`
|
|
21
|
+
/// `[version, count, left, top, right, bottom, ...]`, and re-reads the
|
|
22
|
+
/// rectangles only when the version differs from the one it saw last. Two
|
|
23
|
+
/// properties follow, and both are load-bearing rather than cosmetic:
|
|
24
|
+
///
|
|
25
|
+
/// * any change to the set MUST move the version. A stale version is a
|
|
26
|
+
/// privacy defect in the dangerous direction — the SDK keeps redacting the
|
|
27
|
+
/// region the app has stopped considering secret, and records a newly
|
|
28
|
+
/// secret one in the clear until something else happens to move it;
|
|
29
|
+
/// * a no-op write must NOT move it, or the SDK re-reads on every frame.
|
|
30
|
+
///
|
|
31
|
+
/// The version is kept per display, because the SDK's freshness comparison is
|
|
32
|
+
/// per display: a change on one screen must not invalidate another's.
|
|
33
|
+
///
|
|
34
|
+
/// Fabric `measureInWindow` is relative to the measured node's nearest
|
|
35
|
+
/// `RootNodeKind` ancestor: the app's root, or a `<Modal>`'s content (the
|
|
36
|
+
/// `ModalHostView` node, whose transform is the identity). Each rectangle is
|
|
37
|
+
/// stored under the surface it was measured in (the Modal host's React tag,
|
|
38
|
+
/// or `BGSRNSecureMainSurface`) and served moved by that surface's origin in
|
|
39
|
+
/// screen points. A Modal's origin is where its presented view controller's
|
|
40
|
+
/// view sits: the window's origin for a full-screen Modal, inset for a
|
|
41
|
+
/// `pageSheet` or `formSheet` one. A single origin for the display cannot
|
|
42
|
+
/// serve both.
|
|
43
|
+
///
|
|
44
|
+
/// Origins can be fractional. Left and top edges are moved and rounded down,
|
|
45
|
+
/// right and bottom ones up: a rectangle may grow by under a point, never
|
|
46
|
+
/// shrink. Edges saturate at the int32 range rather than wrap.
|
|
47
|
+
///
|
|
48
|
+
/// Fails closed: a surface whose origin has not been recorded yet, the main
|
|
49
|
+
/// one included, serves one rectangle covering its display (the screen's
|
|
50
|
+
/// bounds) instead of its rectangles. While no React root can be found at
|
|
51
|
+
/// all, the main surface stays that one rectangle: there is no origin to
|
|
52
|
+
/// record, and the store will not guess one (ruled, N8).
|
|
53
|
+
///
|
|
54
|
+
/// A Modal surface belongs to one JS runtime: its key is a React tag the next
|
|
55
|
+
/// runtime does not know. A reload drops every surface but the main one
|
|
56
|
+
/// (`claimRuntime`, `releaseRuntime:`), so a Modal that was open when the old
|
|
57
|
+
/// runtime went away does not mask the screen for the rest of the process. A
|
|
58
|
+
/// claim also empties the main surface's rectangles, keeping its origin: they
|
|
59
|
+
/// were the old runtime's, and its clearing write is ignored once stale
|
|
60
|
+
/// (below), so a new tree that never publishes on the main surface would
|
|
61
|
+
/// otherwise leave them masking until the process dies.
|
|
62
|
+
///
|
|
63
|
+
/// The claim also gates the module's rectangle writes
|
|
64
|
+
/// (`setCoordinates:count:forDisplay:surface:runtime:`): one whose claim is no
|
|
65
|
+
/// longer current is ignored, under the same lock as the claim. A reload can
|
|
66
|
+
/// start the new module before the old one is invalidated, and Fabric numbers
|
|
67
|
+
/// React tags from 1 again, so the old runtime's late writes would otherwise
|
|
68
|
+
/// put back a lane the claim dropped, or clear the new runtime's lane on the
|
|
69
|
+
/// same key and uncover its Modal. A Modal surface's host is named the same way
|
|
70
|
+
/// (`setHostResolver:forSurface:runtime:`), so the pull reads each origin
|
|
71
|
+
/// from the current runtime's host. Origins, display sizes and empty-lane drops are
|
|
72
|
+
/// written by the wrapper's pull, which belongs to no runtime.
|
|
73
|
+
///
|
|
74
|
+
/// ## Threading
|
|
75
|
+
///
|
|
76
|
+
/// Writes arrive on the JS thread; the pull is on the main thread. Every
|
|
77
|
+
/// published value is an immutable `NSData` swapped in whole. The SDK's header
|
|
78
|
+
/// is explicit that a buffer rewritten by another thread while it reads is a
|
|
79
|
+
/// use-after-free, so nothing here ever republishes into a buffer it has
|
|
80
|
+
/// already handed out.
|
|
81
|
+
/// A module's lookup of a surface's host by its React tag (see
|
|
82
|
+
/// `setHostResolver:forSurface:runtime:`).
|
|
83
|
+
typedef id _Nullable (^BGSRNSecureHostResolver)(NSInteger surface);
|
|
84
|
+
|
|
85
|
+
@interface BGSRNSecureRectangles : NSObject
|
|
86
|
+
|
|
87
|
+
/// The process-wide set of secured regions.
|
|
88
|
+
///
|
|
89
|
+
/// Deliberately not owned by a wrapper instance: the wrapper object is
|
|
90
|
+
/// replaced mid-session — registered once before launch and swapped when the
|
|
91
|
+
/// JS bridge comes up — and the regions an app marked secret must not be
|
|
92
|
+
/// forgotten when that happens.
|
|
93
|
+
@property (class, readonly) BGSRNSecureRectangles *shared;
|
|
94
|
+
|
|
95
|
+
/// Publishes `coordinates` as the secure set for `display`'s main surface.
|
|
96
|
+
///
|
|
97
|
+
/// @param coordinates may be NULL only when `count` is 0.
|
|
98
|
+
/// @param count number of int32s, which must be a multiple of 4.
|
|
99
|
+
/// @return NO, publishing nothing, when `count` is not whole rectangles.
|
|
100
|
+
- (BOOL)setCoordinates:(nullable const int32_t *)coordinates
|
|
101
|
+
count:(NSUInteger)count
|
|
102
|
+
forDisplay:(NSInteger)display;
|
|
103
|
+
|
|
104
|
+
/// Publishes `coordinates` for one surface on `display`. Other surfaces keep
|
|
105
|
+
/// their rectangles and origins. Writes as whichever runtime holds the claim
|
|
106
|
+
/// now; a module uses the `runtime:` variant with its own claim.
|
|
107
|
+
- (BOOL)setCoordinates:(nullable const int32_t *)coordinates
|
|
108
|
+
count:(NSUInteger)count
|
|
109
|
+
forDisplay:(NSInteger)display
|
|
110
|
+
surface:(NSInteger)surface;
|
|
111
|
+
|
|
112
|
+
/// `setCoordinates:count:forDisplay:surface:`, written by the module holding
|
|
113
|
+
/// `claim` (from `claimRuntime`). What the TurboModule calls.
|
|
114
|
+
///
|
|
115
|
+
/// @return NO, publishing nothing, when `count` is not whole rectangles or a
|
|
116
|
+
/// newer runtime has claimed the store since `claim` was given.
|
|
117
|
+
- (BOOL)setCoordinates:(nullable const int32_t *)coordinates
|
|
118
|
+
count:(NSUInteger)count
|
|
119
|
+
forDisplay:(NSInteger)display
|
|
120
|
+
surface:(NSInteger)surface
|
|
121
|
+
runtime:(NSInteger)claim;
|
|
122
|
+
|
|
123
|
+
/// The claim a runtime holds now. For writers that belong to no runtime of
|
|
124
|
+
/// their own (tests, single-runtime callers); a module writes with the claim
|
|
125
|
+
/// `claimRuntime` gave it.
|
|
126
|
+
- (NSInteger)currentClaim;
|
|
127
|
+
|
|
128
|
+
/// Records where the main surface's window sits on `display`'s screen, in
|
|
129
|
+
/// points. Re-recording the same origin costs nothing.
|
|
130
|
+
- (void)setOrigin:(CGPoint)origin forDisplay:(NSInteger)display;
|
|
131
|
+
|
|
132
|
+
/// Records where one surface's `measureInWindow` (0, 0) sits on `display`'s
|
|
133
|
+
/// screen, in points. Only that surface's rectangles move.
|
|
134
|
+
- (void)setOrigin:(CGPoint)origin forDisplay:(NSInteger)display surface:(NSInteger)surface;
|
|
135
|
+
|
|
136
|
+
/// Records `display`'s screen size in points: what a surface whose origin is
|
|
137
|
+
/// unknown serves. Re-recording the same size costs nothing.
|
|
138
|
+
- (void)setDisplaySize:(CGSize)size forDisplay:(NSInteger)display;
|
|
139
|
+
|
|
140
|
+
/// The surfaces other than the main one that `display` has lanes for, in key
|
|
141
|
+
/// order: the ones whose origin the pull refreshes.
|
|
142
|
+
- (NSArray<NSNumber *> *)surfacesForDisplay:(NSInteger)display;
|
|
143
|
+
|
|
144
|
+
/// A new JS runtime's module is starting: drops every surface but the main
|
|
145
|
+
/// one, empties the main one's rectangles (keeping its origin), and returns
|
|
146
|
+
/// its claim. Serialised with `releaseRuntime:`, so an old
|
|
147
|
+
/// module released after the new one started cannot drop its surfaces.
|
|
148
|
+
- (NSInteger)claimRuntime;
|
|
149
|
+
|
|
150
|
+
/// The module holding `claim` is gone: drops every surface but the main one,
|
|
151
|
+
/// unless a newer runtime has already claimed the store.
|
|
152
|
+
- (void)releaseRuntime:(NSInteger)claim;
|
|
153
|
+
|
|
154
|
+
/// Records `host`, held weakly, as the view whose origin places `surface`, a
|
|
155
|
+
/// `<Modal>` lane of the module holding `claim`. The pull then reads the
|
|
156
|
+
/// origin from this host rather than searching the windows for a view with
|
|
157
|
+
/// the tag, which another runtime's host can share during a reload. Ignored
|
|
158
|
+
/// (NO) when the claim is stale, `surface` is the main one, or no display has
|
|
159
|
+
/// a lane for it. Every recorded host is forgotten on a claim and on a
|
|
160
|
+
/// release that drops lanes, and a surface's host goes with its last lane.
|
|
161
|
+
- (BOOL)setHost:(id)host forSurface:(NSInteger)surface runtime:(NSInteger)claim;
|
|
162
|
+
|
|
163
|
+
/// Records how the module holding `claim` finds `surface`'s host: a lookup
|
|
164
|
+
/// in its own runtime's view registry. A Modal's host is mounted after JS has
|
|
165
|
+
/// measured and published inside it, so the lookup is kept and asked (on
|
|
166
|
+
/// main, by `hostForSurface:accepting:`) until it finds the host, which is
|
|
167
|
+
/// then recorded as by `setHost:forSurface:runtime:`. Same rules: ignored
|
|
168
|
+
/// (NO) when the claim is stale, `surface` is the main one, or it has no
|
|
169
|
+
/// lane; forgotten with the surface's last lane and on a claim.
|
|
170
|
+
- (BOOL)setHostResolver:(BGSRNSecureHostResolver)resolver
|
|
171
|
+
forSurface:(NSInteger)surface
|
|
172
|
+
runtime:(NSInteger)claim;
|
|
173
|
+
|
|
174
|
+
/// `surface`'s host: the recorded one while it lives; otherwise what the
|
|
175
|
+
/// recorded lookup finds now, recorded if `accept` takes it and the claim it
|
|
176
|
+
/// was named with is still current. nil when there is neither, or the lookup
|
|
177
|
+
/// finds nothing acceptable. Calls the lookup outside the store's lock, on
|
|
178
|
+
/// the caller's thread: main, for a view registry.
|
|
179
|
+
- (nullable id)hostForSurface:(NSInteger)surface accepting:(BOOL (^)(id candidate))accept;
|
|
180
|
+
|
|
181
|
+
/// Whether the current runtime has named `surface`'s host or its lookup
|
|
182
|
+
/// (`setHost:...`, `setHostResolver:...`). Once it has, only that host places
|
|
183
|
+
/// the lane: a lookup that finds nothing yet means the origin is unknown, not
|
|
184
|
+
/// that the windows may be searched, where another runtime's host can be the
|
|
185
|
+
/// only one with the tag.
|
|
186
|
+
- (BOOL)isHostNamedForSurface:(NSInteger)surface;
|
|
187
|
+
|
|
188
|
+
/// Forgets `surface` on every display where it holds no rectangles (its
|
|
189
|
+
/// Modal is gone). A surface that still holds rectangles stays.
|
|
190
|
+
- (void)dropSurfaceIfEmpty:(NSInteger)surface;
|
|
191
|
+
|
|
192
|
+
/// The buffer for `display`. A display nothing has secured reports an empty
|
|
193
|
+
/// set rather than nil, so the SDK always has a version to compare against.
|
|
194
|
+
- (NSData *)snapshotForDisplay:(NSInteger)display;
|
|
195
|
+
|
|
196
|
+
@end
|
|
197
|
+
|
|
198
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
|
|
3
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
4
|
+
|
|
5
|
+
/// Matches JS `UNHANDLED_REPORT_WAIT_MS`: the most the fatal path waits for
|
|
6
|
+
/// native before RN's handler runs. On the simulator the SDK never calls the
|
|
7
|
+
/// `logUnhandledException` completion (verified facts), so the promise must
|
|
8
|
+
/// still settle by this deadline.
|
|
9
|
+
FOUNDATION_EXPORT const int64_t BGSRNUnhandledCompletionDeadlineMs;
|
|
10
|
+
|
|
11
|
+
/// Runs `settle` exactly once: when the returned block is first called, or
|
|
12
|
+
/// after `deadlineMs` on `queue`, whichever comes first. The once-flag is
|
|
13
|
+
/// atomic: the SDK may call back on any thread.
|
|
14
|
+
FOUNDATION_EXPORT dispatch_block_t BGSRNSettleOnce(int64_t deadlineMs,
|
|
15
|
+
dispatch_queue_t queue,
|
|
16
|
+
dispatch_block_t settle);
|
|
17
|
+
|
|
18
|
+
/// Test-only: runs twice on every claim attempt — once before the once-flag
|
|
19
|
+
/// load and once after it. Nil in production is a no-op. The concurrent settle
|
|
20
|
+
/// test parks both callers at each phase so a non-atomic once-flag loses
|
|
21
|
+
/// deterministically (both saw unset) while `atomic_exchange` still admits
|
|
22
|
+
/// only one settler.
|
|
23
|
+
FOUNDATION_EXPORT _Nullable dispatch_block_t BGSRNSettleOnceRaceWindow;
|
|
24
|
+
|
|
25
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
|
|
3
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* The little surface the registry needs from a span. The module adapts
|
|
7
|
+
* `id<BGSSpan>` to this so the registry, and its leak test, do not import
|
|
8
|
+
* the SDK's span type.
|
|
9
|
+
*/
|
|
10
|
+
@protocol BGSRNRetainedSpan <NSObject>
|
|
11
|
+
/// `status` nil is the no-arg finish.
|
|
12
|
+
- (void)bgsrnFinishWithStatus:(NSNumber *_Nullable)status;
|
|
13
|
+
- (BOOL)bgsrnIsFinished;
|
|
14
|
+
@end
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The spans the bridge is holding onto.
|
|
18
|
+
*
|
|
19
|
+
* A span is an object with a lifetime. This registry is the strong
|
|
20
|
+
* reference that would leak it: `finishHandle` calls through to the span
|
|
21
|
+
* and then drops that handle even when it still reports unfinished, plus
|
|
22
|
+
* any other span that now reports finished. `liveCount` and `containsHandle` are what the
|
|
23
|
+
* tests assert, so a finish that forgets to remove the entry fails them.
|
|
24
|
+
*/
|
|
25
|
+
@interface BGSRNSpanHandles : NSObject
|
|
26
|
+
|
|
27
|
+
/// Holds `adapter` for `span`. The same `span` returns the handle already
|
|
28
|
+
/// issued and does not store `adapter` again.
|
|
29
|
+
- (NSString *)retainSpan:(id)span adapter:(id<BGSRNRetainedSpan>)adapter;
|
|
30
|
+
|
|
31
|
+
/// Finishes `handle`, then drops that handle even when it still reports
|
|
32
|
+
/// unfinished. Other retained spans are dropped only when they now report
|
|
33
|
+
/// finished. Empty when `handle` is not held.
|
|
34
|
+
- (NSArray<NSString *> *)finishHandle:(NSString *)handle
|
|
35
|
+
status:(NSNumber *_Nullable)status;
|
|
36
|
+
|
|
37
|
+
/// Drops every handle and refuses later retains. Does not finish the spans.
|
|
38
|
+
- (void)releaseAll;
|
|
39
|
+
|
|
40
|
+
/// The registry `invalidate` hands out. It retains nothing.
|
|
41
|
+
+ (BGSRNSpanHandles *)closedRegistry;
|
|
42
|
+
|
|
43
|
+
- (BOOL)containsHandle:(NSString *)handle;
|
|
44
|
+
- (NSUInteger)liveCount;
|
|
45
|
+
- (nullable id<BGSRNRetainedSpan>)adapterForHandle:(NSString *)handle;
|
|
46
|
+
|
|
47
|
+
@end
|
|
48
|
+
|
|
49
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
// Not `@import Bugsee;`: this header is included from ObjC++, where C++ modules
|
|
3
|
+
// are off on both delivery paths and a module import is a hard error.
|
|
4
|
+
#import <Bugsee/Bugsee.h>
|
|
5
|
+
|
|
6
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
7
|
+
|
|
8
|
+
/// Wire numbers shared with the JS `Status` constants and with the Android
|
|
9
|
+
/// bridge's `BugseeStatusMapper`. They are API, not an implementation detail,
|
|
10
|
+
/// and are fixed here rather than derived from the enum so that an SDK
|
|
11
|
+
/// reordering its cases cannot silently change what JS sees.
|
|
12
|
+
typedef NS_ENUM(NSInteger, BGSRNStatusWire) {
|
|
13
|
+
BGSRNStatusWireStopped = 0,
|
|
14
|
+
BGSRNStatusWireLaunching = 1,
|
|
15
|
+
BGSRNStatusWireLaunched = 2,
|
|
16
|
+
BGSRNStatusWireStopping = 3,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/// Translates the SDK's status into the wire number.
|
|
20
|
+
///
|
|
21
|
+
/// An unrecognised value maps to `Stopped`: "we could not tell" is far closer
|
|
22
|
+
/// to stopped than launched, so a caller waiting to start keeps waiting rather
|
|
23
|
+
/// than proceeding on a state nobody mapped.
|
|
24
|
+
FOUNDATION_EXPORT NSInteger BGSRNStatusToWire(BugseeStatus status);
|
|
25
|
+
|
|
26
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
|
|
3
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
4
|
+
|
|
5
|
+
/// Whether an app token is usable.
|
|
6
|
+
///
|
|
7
|
+
/// Deliberately permissive about shape — the token's format is the server's
|
|
8
|
+
/// business, and a wrapper rejecting a valid token because the format changed
|
|
9
|
+
/// would be worse than one that forwarded it. Only genuinely unusable input,
|
|
10
|
+
/// absent or whitespace, is refused, and refused early so the failure names
|
|
11
|
+
/// the real problem instead of surfacing later as a confusing launch failure.
|
|
12
|
+
FOUNDATION_EXPORT BOOL BGSRNTokenIsUsable(NSString *_Nullable token);
|
|
13
|
+
|
|
14
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
|
|
3
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
4
|
+
|
|
5
|
+
/// A boxed `BOOL` whose identity IS the `CFBoolean` singleton, rather than
|
|
6
|
+
/// whatever `@(value)` happens to box a `BOOL` into.
|
|
7
|
+
///
|
|
8
|
+
/// `+[Bugsee trace:value:]` takes `id`, and the SDK's JSON writer
|
|
9
|
+
/// special-cases `CFBoolean` to serialise as `true`/`false` (design doc
|
|
10
|
+
/// Phase 4, verified facts); anything else numeric serialises as a number in
|
|
11
|
+
/// its shortest round-trip form. A `BOOL` boxed the ordinary way is not
|
|
12
|
+
/// reliably a `CFBoolean` -- `@(value)` for a `BOOL` can produce an
|
|
13
|
+
/// `NSNumber` backed by a `char`, indistinguishable at that point from a
|
|
14
|
+
/// `Boolean`-typed value holding 0 or 1 -- so the boolean identity cannot be
|
|
15
|
+
/// left to depend on how a given architecture boxes it. This forces it.
|
|
16
|
+
FOUNDATION_EXPORT NSNumber *BGSRNBoolNumber(BOOL value);
|
|
17
|
+
|
|
18
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
|
|
3
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
4
|
+
|
|
5
|
+
/// What the SDK asks a wrapper to say about itself.
|
|
6
|
+
///
|
|
7
|
+
/// The values are gathered in JS and handed down, because that is where they
|
|
8
|
+
/// are knowable: the React Native version comes from `Platform.constants`, the
|
|
9
|
+
/// engine from whether Hermes installed its global, and the build
|
|
10
|
+
/// configuration from `__DEV__`. Nothing here infers them natively, which
|
|
11
|
+
/// would produce a second, disagreeing answer.
|
|
12
|
+
///
|
|
13
|
+
/// Declared without conforming to `BugseeWrapper` here so that this package
|
|
14
|
+
/// stays testable on its own; the bridge declares the conformance, which is
|
|
15
|
+
/// where the SDK header is in scope.
|
|
16
|
+
@interface BGSRNWrapper : NSObject
|
|
17
|
+
|
|
18
|
+
@property(nonatomic, copy, readonly) NSString *wrapperType;
|
|
19
|
+
@property(nonatomic, copy, readonly) NSString *wrapperVersion;
|
|
20
|
+
@property(nonatomic, copy, readonly, nullable) NSString *wrapperBuild;
|
|
21
|
+
@property(nonatomic, copy, readonly, nullable) NSDictionary<NSString *, NSString *> *context;
|
|
22
|
+
|
|
23
|
+
/// Builds a wrapper from the identity dictionary the bridge received.
|
|
24
|
+
///
|
|
25
|
+
/// Missing values become "unknown" rather than nil: the SDK declares
|
|
26
|
+
/// `wrapperType` and `wrapperVersion` non-null, and an empty string reads in a
|
|
27
|
+
/// report as "this wrapper has no version".
|
|
28
|
+
+ (instancetype)wrapperWithIdentity:(nullable NSDictionary *)identity;
|
|
29
|
+
|
|
30
|
+
/// Type and version only: the identity knowable before a JS runtime exists.
|
|
31
|
+
///
|
|
32
|
+
/// The same split Android's init provider makes. `setWrapperInfo` replaces
|
|
33
|
+
/// this with the full identity once the bridge can supply the React Native
|
|
34
|
+
/// version, the engine and the build configuration. Context is an empty map,
|
|
35
|
+
/// not nil — the SDK's contract is a non-null string-to-string map.
|
|
36
|
+
+ (instancetype)wrapperWithoutJsRuntime;
|
|
37
|
+
|
|
38
|
+
@end
|
|
39
|
+
|
|
40
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
// Not `@import Bugsee;`: this header is included from ObjC++, where C++ modules
|
|
3
|
+
// are off on both delivery paths and a module import is a hard error.
|
|
4
|
+
#import <Bugsee/Bugsee.h>
|
|
5
|
+
|
|
6
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* By value, the table both platforms share: 1 Error .. 5 Verbose, and
|
|
10
|
+
* anything else Info. Never `BugseeLogLevelInvalid` (0) -- a log line has no
|
|
11
|
+
* honest reading of "invalid". Shared by the channel's lines and the app's
|
|
12
|
+
* own `Bugsee.log` lines, which do not go through the channel.
|
|
13
|
+
*/
|
|
14
|
+
FOUNDATION_EXPORT BugseeLogLevel BGSRNLogLevelForWireValue(NSInteger wire);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The SDK's wrapper channel, held for the whole process. The iOS mirror of
|
|
18
|
+
* Android's `WrapperChannelHolder`.
|
|
19
|
+
*
|
|
20
|
+
* The channel is how this wrapper submits what it captured in JS -- log
|
|
21
|
+
* lines now, network events and breadcrumbs later -- attributed as wrapper
|
|
22
|
+
* data rather than as the app's own calls. It is delivered to whichever
|
|
23
|
+
* wrapper is registered, through `-onWrapperChannelAvailable:`, but it is
|
|
24
|
+
* stored here rather than on that instance: the wrapper is replaced when
|
|
25
|
+
* `setWrapperInfo` refines the identity, and the SDK hands the replacement a
|
|
26
|
+
* fresh channel. The last one delivered is the live one; an earlier one goes
|
|
27
|
+
* inert (the SDK itself reports stale use of it, after a grace period).
|
|
28
|
+
*
|
|
29
|
+
* Nothing is buffered. A channel held before `launch` accepts and drops what
|
|
30
|
+
* it is given, which is the SDK's own behaviour, not an error this holder
|
|
31
|
+
* works around.
|
|
32
|
+
*
|
|
33
|
+
* Every channel method is `@optional`, so each call here is guarded with
|
|
34
|
+
* `respondsToSelector:`. There is deliberately no `@try` around a call: the
|
|
35
|
+
* SDK already catches whatever the app's filter throws at `-postEvent:` and
|
|
36
|
+
* drops the line, and unwinding an Objective-C exception through these ARC
|
|
37
|
+
* frames would leak rather than protect anything (unlike Android, which lets
|
|
38
|
+
* the exception reach the calling thread on purpose).
|
|
39
|
+
*/
|
|
40
|
+
@interface BGSRNWrapperChannelHolder : NSObject
|
|
41
|
+
|
|
42
|
+
@property (class, readonly) BGSRNWrapperChannelHolder *shared;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* The channel most recently delivered, or nil before one arrives or after it
|
|
46
|
+
* is cleared. Lives outside the wrapper object on purpose -- see the class
|
|
47
|
+
* comment.
|
|
48
|
+
*/
|
|
49
|
+
@property (atomic, strong, nullable) id<BGSWrapperChannel> channel;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* One JS line, as source `Custom` with no tag.
|
|
53
|
+
*
|
|
54
|
+
* The tag is always nil: iOS has nowhere to put one, and a line must read the
|
|
55
|
+
* same on both platforms. The source is always set explicitly here, never
|
|
56
|
+
* left to the SDK, which on iOS reads a missing source as `Unknown` rather
|
|
57
|
+
* than `Custom`.
|
|
58
|
+
*
|
|
59
|
+
* `level` is the wire value, 1 (Error) .. 5 (Verbose); anything outside that
|
|
60
|
+
* range becomes `Info`. Never `BugseeLogLevelInvalid` (0), which is not a
|
|
61
|
+
* level a log line can honestly carry.
|
|
62
|
+
*/
|
|
63
|
+
- (void)logMessage:(nullable NSString *)message level:(NSInteger)level;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Always `requiresFiltering:YES`. `NO` would also skip the SDK's own network
|
|
67
|
+
* sanitizer, not only the app's filter, and nothing this wrapper sends has
|
|
68
|
+
* been through either.
|
|
69
|
+
*/
|
|
70
|
+
- (void)addNetworkEvent:(nullable BugseeNetworkEvent *)event;
|
|
71
|
+
|
|
72
|
+
@end
|
|
73
|
+
|
|
74
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
@import XCTest;
|
|
2
|
+
@import BugseeRNSupport;
|
|
3
|
+
|
|
4
|
+
/// Exercises `BGSRNAttributes` without the SDK: `setValue:forKey:setter:getter:`
|
|
5
|
+
/// takes the store as plain blocks, so a fake dictionary here plays the part
|
|
6
|
+
/// `+[Bugsee setAttribute:withValue:]`/`+[Bugsee getAttribute:]` play in
|
|
7
|
+
/// `BugseeModule.mm` (Task 5.3). Mirrors Android's `AttributeBridgeTest` by
|
|
8
|
+
/// intent where the rule is shared.
|
|
9
|
+
@interface BGSRNAttributesTests : XCTestCase
|
|
10
|
+
@end
|
|
11
|
+
|
|
12
|
+
@implementation BGSRNAttributesTests {
|
|
13
|
+
NSMutableDictionary<NSString *, id> *_store;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
- (void)setUp {
|
|
17
|
+
[super setUp];
|
|
18
|
+
_store = [NSMutableDictionary dictionary];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/// The fake `setter`: always reports success and actually stores the value --
|
|
22
|
+
/// the well-behaved case every "drops it anyway" test below deliberately
|
|
23
|
+
/// deviates from.
|
|
24
|
+
- (BOOL (^)(NSString *, id))storeSetter {
|
|
25
|
+
NSMutableDictionary<NSString *, id> *store = _store;
|
|
26
|
+
return ^BOOL(NSString *key, id value) {
|
|
27
|
+
store[key] = value;
|
|
28
|
+
return YES;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/// The fake `getter`: reads straight back from the same dictionary.
|
|
33
|
+
- (id _Nullable (^)(NSString *))storeGetter {
|
|
34
|
+
NSMutableDictionary<NSString *, id> *store = _store;
|
|
35
|
+
return ^id(NSString *key) {
|
|
36
|
+
return store[key];
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
#pragma mark - setValue:forKey:setter:getter:
|
|
41
|
+
|
|
42
|
+
- (void)testVerifiedWhenTheStoreKeepsTheValue {
|
|
43
|
+
const BOOL result = [BGSRNAttributes setValue:@"blue"
|
|
44
|
+
forKey:@"color"
|
|
45
|
+
setter:self.storeSetter
|
|
46
|
+
getter:self.storeGetter];
|
|
47
|
+
XCTAssertTrue(result);
|
|
48
|
+
XCTAssertEqualObjects(_store[@"color"], @"blue");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/// iOS's size path: the setter claims success (exactly what
|
|
52
|
+
/// `+setAttribute:withValue:` does even when it silently drops an
|
|
53
|
+
/// over-the-archive-limit value), but nothing actually landed in the store.
|
|
54
|
+
- (void)testRejectedWhenTheSetterSaysYesButTheStoreDroppedIt {
|
|
55
|
+
BOOL (^droppingSetter)(NSString *, id) = ^BOOL(NSString *key, id value) {
|
|
56
|
+
return YES; // as the SDK does for a value it silently discarded
|
|
57
|
+
};
|
|
58
|
+
const BOOL result = [BGSRNAttributes setValue:@"blue"
|
|
59
|
+
forKey:@"color"
|
|
60
|
+
setter:droppingSetter
|
|
61
|
+
getter:self.storeGetter];
|
|
62
|
+
XCTAssertFalse(result);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
- (void)testRejectedWhenTheStoreKeepsAnOlderValue {
|
|
66
|
+
_store[@"color"] = @"red";
|
|
67
|
+
BOOL (^staleSetter)(NSString *, id) = ^BOOL(NSString *key, id value) {
|
|
68
|
+
return YES; // claims success but leaves the previous value in place
|
|
69
|
+
};
|
|
70
|
+
const BOOL result = [BGSRNAttributes setValue:@"blue"
|
|
71
|
+
forKey:@"color"
|
|
72
|
+
setter:staleSetter
|
|
73
|
+
getter:self.storeGetter];
|
|
74
|
+
XCTAssertFalse(result);
|
|
75
|
+
XCTAssertEqualObjects(_store[@"color"], @"red");
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
#pragma mark - readable:
|
|
79
|
+
|
|
80
|
+
- (void)testReadableKeepsBooleansAsCFBooleans {
|
|
81
|
+
NSDictionary<NSString *, id> *readable = [BGSRNAttributes readable:@{ @"flag" : BGSRNBoolNumber(YES) }];
|
|
82
|
+
NSNumber *value = readable[@"flag"];
|
|
83
|
+
XCTAssertEqual(CFGetTypeID((__bridge CFTypeRef)value), CFBooleanGetTypeID());
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/// A plain number must verify and read back as an `NSNumber`, not silently
|
|
87
|
+
/// take the `CFBoolean` path above: `isKindOfClass:NSNumber.class` is true
|
|
88
|
+
/// for both, so this is the one place the two could be confused.
|
|
89
|
+
- (void)testAPlainNumberVerifiesAndReadsBackAsNSNumberNotCFBoolean {
|
|
90
|
+
for (NSNumber *value in @[ @(42), @(1.5) ]) {
|
|
91
|
+
_store = [NSMutableDictionary dictionary];
|
|
92
|
+
const BOOL result = [BGSRNAttributes setValue:value
|
|
93
|
+
forKey:@"n"
|
|
94
|
+
setter:self.storeSetter
|
|
95
|
+
getter:self.storeGetter];
|
|
96
|
+
XCTAssertTrue(result);
|
|
97
|
+
|
|
98
|
+
NSDictionary<NSString *, id> *readable = [BGSRNAttributes readable:_store];
|
|
99
|
+
NSNumber *readBack = readable[@"n"];
|
|
100
|
+
XCTAssertEqualObjects(readBack, value);
|
|
101
|
+
XCTAssertNotEqual(CFGetTypeID((__bridge CFTypeRef)readBack), CFBooleanGetTypeID());
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
- (void)testReadableTurnsAStringArrayIntoAnArray {
|
|
106
|
+
NSDictionary<NSString *, id> *readable = [BGSRNAttributes readable:@{ @"tags" : @[ @"a", @"b" ] }];
|
|
107
|
+
XCTAssertEqualObjects(readable[@"tags"], (@[ @"a", @"b" ]));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
- (void)testReadableDropsUnknownTypes {
|
|
111
|
+
NSDictionary<NSString *, id> *readable = [BGSRNAttributes readable:@{
|
|
112
|
+
@"when" : [NSDate date],
|
|
113
|
+
@"blob" : [NSData data],
|
|
114
|
+
@"kept" : @"value",
|
|
115
|
+
}];
|
|
116
|
+
XCTAssertNil(readable[@"when"]);
|
|
117
|
+
XCTAssertNil(readable[@"blob"]);
|
|
118
|
+
XCTAssertEqualObjects(readable[@"kept"], @"value");
|
|
119
|
+
XCTAssertEqual(readable.count, (NSUInteger)1);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
#pragma mark - identifier:
|
|
123
|
+
|
|
124
|
+
- (void)testEmptyIdentifierReadsAsAbsent {
|
|
125
|
+
XCTAssertNil([BGSRNAttributes identifier:nil]);
|
|
126
|
+
XCTAssertNil([BGSRNAttributes identifier:@""]);
|
|
127
|
+
XCTAssertEqualObjects([BGSRNAttributes identifier:@"someone"], @"someone");
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
#pragma mark - the mirrored archive-math constant, not the SDK's observed behaviour
|
|
131
|
+
|
|
132
|
+
// These three tests pin the archive math of THIS FILE's own mirrored
|
|
133
|
+
// `BGSRNAttributeArchiveLimit` constant against a bare `NSKeyedArchiver`
|
|
134
|
+
// round trip -- they do not call through `+[Bugsee setAttribute:withValue:]`
|
|
135
|
+
// and so cannot observe what the real SDK actually keeps or drops.
|
|
136
|
+
//
|
|
137
|
+
// A bare ASCII `NSString` archives at `length + 286` bytes on current iOS
|
|
138
|
+
// Foundation (measured on both an iOS 26.5 and an iOS 18.5 simulator, with
|
|
139
|
+
// `NSKeyedArchiver archivedDataWithRootObject:requiringSecureCoding:NO`):
|
|
140
|
+
// an 800-character string measures 1086 bytes, 900 measures 1186, and 1024
|
|
141
|
+
// measures 1310 -- so the archive math's crossover against
|
|
142
|
+
// `BGSRNAttributeArchiveLimit` (1124) is around 838 ASCII characters.
|
|
143
|
+
// Corrected by controller ruling after Task 5.3's first pass found the
|
|
144
|
+
// mismatch against the design doc's originally assumed 900-1024 range.
|
|
145
|
+
//
|
|
146
|
+
// Task 5.5 then found the archive math does NOT match the real device: a
|
|
147
|
+
// 900-character value was KEPT by the actual `Bugsee.setAttribute`/
|
|
148
|
+
// `getAttribute` round trip on the published `7.0.0-beta3` binary, even
|
|
149
|
+
// though `testA900CharacterAsciiStringExceedsTheArchiveLimit` below still
|
|
150
|
+
// correctly passes (900 characters really does archive over 1124 bytes by
|
|
151
|
+
// this math, and the SDK source's own check does reject an archive over that
|
|
152
|
+
// limit) -- so the mismatch is between this math and what the binary
|
|
153
|
+
// actually does, not a bug in these tests. By controller ruling, the design
|
|
154
|
+
// doc's Phase 5 table no longer has a 900-character row (the iOS SDK team
|
|
155
|
+
// has been asked why); `e2e_mid` (800, kept on both) and `e2e_long` (1024,
|
|
156
|
+
// dropped on iOS) still pin the two ends this math and the device agree on.
|
|
157
|
+
|
|
158
|
+
/// Pins the archive math only: an 800-character ASCII string archives UNDER
|
|
159
|
+
/// `BGSRNAttributeArchiveLimit` (measured 1086 bytes). Matches the design
|
|
160
|
+
/// doc's `e2e_mid` row (kept on both platforms) -- but that agreement is
|
|
161
|
+
/// what Task 5.5 found does NOT hold for every length in this file's
|
|
162
|
+
/// predicted-safe range; see the section comment above.
|
|
163
|
+
- (void)testAn800CharacterAsciiStringFitsTheArchiveLimit {
|
|
164
|
+
NSString *value = [@"" stringByPaddingToLength:800 withString:@"a" startingAtIndex:0];
|
|
165
|
+
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:value requiringSecureCoding:NO error:nil];
|
|
166
|
+
XCTAssertLessThanOrEqual(data.length, (NSUInteger)BGSRNAttributeArchiveLimit);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/// Pins the archive math only: a 900-character ASCII string archives OVER
|
|
170
|
+
/// `BGSRNAttributeArchiveLimit` (measured 1186 bytes). This test passing does
|
|
171
|
+
/// NOT mean the real SDK rejects a 900-character value -- Task 5.5 found the
|
|
172
|
+
/// opposite on device (`7.0.0-beta3` keeps it); see the section comment
|
|
173
|
+
/// above. If this test starts failing, the archive limit or the archiving
|
|
174
|
+
/// method changed; that is a fact about this mirrored constant, not
|
|
175
|
+
/// confirmation either way about the SDK's own behaviour.
|
|
176
|
+
- (void)testA900CharacterAsciiStringExceedsTheArchiveLimit {
|
|
177
|
+
NSString *value = [@"" stringByPaddingToLength:900 withString:@"a" startingAtIndex:0];
|
|
178
|
+
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:value requiringSecureCoding:NO error:nil];
|
|
179
|
+
XCTAssertGreaterThan(data.length, (NSUInteger)BGSRNAttributeArchiveLimit);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/// Pins the archive math only: a 1024-character ASCII string archives OVER
|
|
183
|
+
/// `BGSRNAttributeArchiveLimit` (measured 1310 bytes). Matches the design
|
|
184
|
+
/// doc's `e2e_long` row, and Task 5.5 confirmed on device that iOS does
|
|
185
|
+
/// reject this length with `E_ATTRIBUTE_REJECTED` while Android keeps it. If
|
|
186
|
+
/// this test fails, the archive limit or the archiving method changed, and
|
|
187
|
+
/// Task 5.5's expectations must be revisited there, not patched around here.
|
|
188
|
+
- (void)testA1024CharacterAsciiStringExceedsTheArchiveLimit {
|
|
189
|
+
NSString *value = [@"" stringByPaddingToLength:1024 withString:@"x" startingAtIndex:0];
|
|
190
|
+
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:value requiringSecureCoding:NO error:nil];
|
|
191
|
+
XCTAssertGreaterThan(data.length, (NSUInteger)BGSRNAttributeArchiveLimit);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
@end
|