@g9tm/app-diagnostic-tauri 0.5.0 → 0.6.0
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/Cargo.toml +1 -1
- package/README.md +2 -0
- package/android/build.gradle.kts +29 -29
- package/android/proguard-rules.pro +2 -2
- package/android/settings.gradle +2 -2
- package/android/src/main/AndroidManifest.xml +5 -5
- package/android/src/main/java/com/g9tm/appdiagnostic/tauri/G9DiagnosticPlugin.kt +1 -1
- package/build.rs +13 -13
- package/ios/Package.swift +20 -20
- package/ios/Sources/G9AppDiagnosticCore/G9AppDiagnosticHost.m +72 -72
- package/ios/Sources/G9AppDiagnosticCore/G9DiagnosticRecorders.m +514 -514
- package/ios/Sources/G9AppDiagnosticCore/include/G9AppDiagnosticHost.h +32 -32
- package/ios/Sources/G9AppDiagnosticCore/include/G9DiagnosticRecorders.h +36 -36
- package/ios/Sources/G9DiagnosticPlugin/G9DiagnosticPlugin.swift +135 -135
- package/package.json +3 -3
- package/permissions/autogenerated/commands/capabilities.toml +13 -13
- package/permissions/autogenerated/commands/read_chunk.toml +13 -13
- package/permissions/autogenerated/commands/registerListener.toml +13 -13
- package/permissions/autogenerated/commands/remove.toml +13 -13
- package/permissions/autogenerated/commands/remove_listener.toml +13 -13
- package/permissions/autogenerated/commands/screenshot.toml +13 -13
- package/permissions/autogenerated/commands/start_screen.toml +13 -13
- package/permissions/autogenerated/commands/start_voice.toml +13 -13
- package/permissions/autogenerated/commands/state.toml +13 -13
- package/permissions/autogenerated/commands/stop_screen.toml +13 -13
- package/permissions/autogenerated/commands/stop_voice.toml +13 -13
- package/permissions/autogenerated/commands/touch.toml +13 -13
- package/permissions/autogenerated/commands/watch_touches.toml +13 -13
- package/permissions/autogenerated/reference.md +367 -367
- package/permissions/default.toml +9 -9
- package/permissions/schemas/schema.json +461 -461
- package/src/index.ts +97 -97
- package/src/lib.rs +119 -119
package/Cargo.toml
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[package]
|
|
2
2
|
name = "tauri-plugin-g9-diagnostic"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.6.0"
|
|
4
4
|
description = "The tester mode of a Tauri v2 app: the native recorders, the window screenshot, the tester gesture and the remote touch of G9AppDiagnostic on Android and iOS; the web layer (@g9tm/app-diagnostic-web) everywhere."
|
|
5
5
|
edition = "2021"
|
|
6
6
|
rust-version = "1.77.2"
|
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @g9tm/app-diagnostic-tauri
|
|
2
2
|
|
|
3
|
+
> 0.6.0: the web element underneath carries both reports with the shared G9 design — the testers' pill and the users' problem report (`tester.openProblemReport()`); every option of `startTester` (`access`, `problemReport`, `features`, `theme`, `strings`) passes through. Guide: `@g9tm/app-diagnostic-web`'s AGENTS.md.
|
|
4
|
+
|
|
3
5
|
The tester mode of a Tauri v2 app: the JS side of the crate `tauri-plugin-g9-diagnostic` (this folder) — the native
|
|
4
6
|
screen, voice, screenshot, gesture and remote touch on Android and iOS — under [`@g9tm/app-diagnostic-web`](https://www.npmjs.com/package/@g9tm/app-diagnostic-web)'s
|
|
5
7
|
`<g9-tester>`. On a desktop the plugin answers that it has no native half and the web recorders work.
|
package/android/build.gradle.kts
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
// tauri-plugin-g9-diagnostic for Android. The recorders, the window capture and the gesture under
|
|
2
|
-
// src/main/java/com/g9tm/appdiagnostic/ are @g9tm/app-diagnostic-lynx's own files (scripts/sync-native.mjs); the plugin is
|
|
3
|
-
// src/main/java/com/g9tm/appdiagnostic/tauri/.
|
|
4
|
-
plugins {
|
|
5
|
-
id("com.android.library")
|
|
6
|
-
id("org.jetbrains.kotlin.android")
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
android {
|
|
10
|
-
namespace = "com.g9tm.appdiagnostic"
|
|
11
|
-
compileSdk = 36
|
|
12
|
-
defaultConfig {
|
|
13
|
-
minSdk = 24
|
|
14
|
-
consumerProguardFiles("proguard-rules.pro")
|
|
15
|
-
}
|
|
16
|
-
compileOptions {
|
|
17
|
-
sourceCompatibility = JavaVersion.VERSION_17
|
|
18
|
-
targetCompatibility = JavaVersion.VERSION_17
|
|
19
|
-
}
|
|
20
|
-
kotlinOptions { jvmTarget = "17" }
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
dependencies {
|
|
24
|
-
implementation("androidx.core:core-ktx:1.13.1")
|
|
25
|
-
implementation("androidx.activity:activity:1.10.1")
|
|
26
|
-
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2")
|
|
27
|
-
implementation("com.squareup.okhttp3:okhttp:4.12.0")
|
|
28
|
-
implementation(project(":tauri-android"))
|
|
29
|
-
}
|
|
1
|
+
// tauri-plugin-g9-diagnostic for Android. The recorders, the window capture and the gesture under
|
|
2
|
+
// src/main/java/com/g9tm/appdiagnostic/ are @g9tm/app-diagnostic-lynx's own files (scripts/sync-native.mjs); the plugin is
|
|
3
|
+
// src/main/java/com/g9tm/appdiagnostic/tauri/.
|
|
4
|
+
plugins {
|
|
5
|
+
id("com.android.library")
|
|
6
|
+
id("org.jetbrains.kotlin.android")
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
android {
|
|
10
|
+
namespace = "com.g9tm.appdiagnostic"
|
|
11
|
+
compileSdk = 36
|
|
12
|
+
defaultConfig {
|
|
13
|
+
minSdk = 24
|
|
14
|
+
consumerProguardFiles("proguard-rules.pro")
|
|
15
|
+
}
|
|
16
|
+
compileOptions {
|
|
17
|
+
sourceCompatibility = JavaVersion.VERSION_17
|
|
18
|
+
targetCompatibility = JavaVersion.VERSION_17
|
|
19
|
+
}
|
|
20
|
+
kotlinOptions { jvmTarget = "17" }
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
dependencies {
|
|
24
|
+
implementation("androidx.core:core-ktx:1.13.1")
|
|
25
|
+
implementation("androidx.activity:activity:1.10.1")
|
|
26
|
+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2")
|
|
27
|
+
implementation("com.squareup.okhttp3:okhttp:4.12.0")
|
|
28
|
+
implementation(project(":tauri-android"))
|
|
29
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
# The plugin's commands are found by reflection (Tauri's @Command / @InvokeArg).
|
|
2
|
-
-keep class com.g9tm.appdiagnostic.tauri.** { *; }
|
|
1
|
+
# The plugin's commands are found by reflection (Tauri's @Command / @InvokeArg).
|
|
2
|
+
-keep class com.g9tm.appdiagnostic.tauri.** { *; }
|
package/android/settings.gradle
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
include ':tauri-android'
|
|
2
|
-
project(':tauri-android').projectDir = new File('./.tauri/tauri-api')
|
|
1
|
+
include ':tauri-android'
|
|
2
|
+
project(':tauri-android').projectDir = new File('./.tauri/tauri-api')
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
|
-
<!-- The voice note; asked at the first note, never at start. -->
|
|
4
|
-
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
|
5
|
-
</manifest>
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
|
+
<!-- The voice note; asked at the first note, never at start. -->
|
|
4
|
+
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
|
5
|
+
</manifest>
|
|
@@ -88,7 +88,7 @@ class G9DiagnosticPlugin(private val activity: Activity) : Plugin(activity) {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
@Command fun capabilities(invoke: Invoke) = run(invoke) {
|
|
91
|
-
JSObject().put("version", "0.
|
|
91
|
+
JSObject().put("version", "0.6.0").put("platform", "android").put("screen", ScreenRecorder.supported()).put("voice", VoiceRecorder.supported()).put("consume", true).put("native", true)
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
@Command fun state(invoke: Invoke) = run(invoke) { JSObject().put("screen", ScreenRecorder.isRecording).put("voice", VoiceRecorder.isRecording) }
|
package/build.rs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
// The plugin's commands (each a permission `g9-diagnostic:allow-<command>`, the set `g9-diagnostic:default`) and its mobile
|
|
2
|
-
// halves: android/ (Kotlin, the Lynx package's recorders copied by scripts/sync-native.mjs) and ios/ (Swift + the Lynx
|
|
3
|
-
// package's Objective-C recorders).
|
|
4
|
-
const COMMANDS: &[&str] = &[
|
|
5
|
-
"capabilities", "state", "start_screen", "stop_screen", "start_voice", "stop_voice", "screenshot", "watch_touches", "touch", "read_chunk", "remove",
|
|
6
|
-
// The mobile halves' event channel: @tauri-apps/api's addPluginListener sends these two to the plugin, and the ACL refuses
|
|
7
|
-
// them unless they are permissions too (found on a real phone: without them no touch ever reached the web layer).
|
|
8
|
-
"registerListener", "remove_listener",
|
|
9
|
-
];
|
|
10
|
-
|
|
11
|
-
fn main() {
|
|
12
|
-
tauri_plugin::Builder::new(COMMANDS).android_path("android").ios_path("ios").build();
|
|
13
|
-
}
|
|
1
|
+
// The plugin's commands (each a permission `g9-diagnostic:allow-<command>`, the set `g9-diagnostic:default`) and its mobile
|
|
2
|
+
// halves: android/ (Kotlin, the Lynx package's recorders copied by scripts/sync-native.mjs) and ios/ (Swift + the Lynx
|
|
3
|
+
// package's Objective-C recorders).
|
|
4
|
+
const COMMANDS: &[&str] = &[
|
|
5
|
+
"capabilities", "state", "start_screen", "stop_screen", "start_voice", "stop_voice", "screenshot", "watch_touches", "touch", "read_chunk", "remove",
|
|
6
|
+
// The mobile halves' event channel: @tauri-apps/api's addPluginListener sends these two to the plugin, and the ACL refuses
|
|
7
|
+
// them unless they are permissions too (found on a real phone: without them no touch ever reached the web layer).
|
|
8
|
+
"registerListener", "remove_listener",
|
|
9
|
+
];
|
|
10
|
+
|
|
11
|
+
fn main() {
|
|
12
|
+
tauri_plugin::Builder::new(COMMANDS).android_path("android").ios_path("ios").build();
|
|
13
|
+
}
|
package/ios/Package.swift
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
// swift-tools-version:5.3
|
|
2
|
-
// tauri-plugin-g9-diagnostic for iOS: the plugin (Swift) over @g9tm/app-diagnostic-lynx's Objective-C recorders
|
|
3
|
-
// (Sources/G9AppDiagnosticCore, copied by scripts/sync-native.mjs — never edited here).
|
|
4
|
-
import PackageDescription
|
|
5
|
-
|
|
6
|
-
let package = Package(
|
|
7
|
-
name: "tauri-plugin-g9-diagnostic",
|
|
8
|
-
platforms: [.iOS(.v14)],
|
|
9
|
-
products: [
|
|
10
|
-
.library(name: "tauri-plugin-g9-diagnostic", type: .static, targets: ["tauri-plugin-g9-diagnostic"]),
|
|
11
|
-
],
|
|
12
|
-
dependencies: [
|
|
13
|
-
.package(name: "Tauri", path: "../.tauri/tauri-api"),
|
|
14
|
-
],
|
|
15
|
-
targets: [
|
|
16
|
-
.target(name: "G9AppDiagnosticCore", path: "Sources/G9AppDiagnosticCore", publicHeadersPath: "include",
|
|
17
|
-
linkerSettings: [.linkedFramework("AVFoundation"), .linkedFramework("CoreVideo"), .linkedFramework("CoreMedia"), .linkedFramework("UIKit")]),
|
|
18
|
-
.target(name: "tauri-plugin-g9-diagnostic", dependencies: [.byName(name: "Tauri"), "G9AppDiagnosticCore"], path: "Sources/G9DiagnosticPlugin"),
|
|
19
|
-
]
|
|
20
|
-
)
|
|
1
|
+
// swift-tools-version:5.3
|
|
2
|
+
// tauri-plugin-g9-diagnostic for iOS: the plugin (Swift) over @g9tm/app-diagnostic-lynx's Objective-C recorders
|
|
3
|
+
// (Sources/G9AppDiagnosticCore, copied by scripts/sync-native.mjs — never edited here).
|
|
4
|
+
import PackageDescription
|
|
5
|
+
|
|
6
|
+
let package = Package(
|
|
7
|
+
name: "tauri-plugin-g9-diagnostic",
|
|
8
|
+
platforms: [.iOS(.v14)],
|
|
9
|
+
products: [
|
|
10
|
+
.library(name: "tauri-plugin-g9-diagnostic", type: .static, targets: ["tauri-plugin-g9-diagnostic"]),
|
|
11
|
+
],
|
|
12
|
+
dependencies: [
|
|
13
|
+
.package(name: "Tauri", path: "../.tauri/tauri-api"),
|
|
14
|
+
],
|
|
15
|
+
targets: [
|
|
16
|
+
.target(name: "G9AppDiagnosticCore", path: "Sources/G9AppDiagnosticCore", publicHeadersPath: "include",
|
|
17
|
+
linkerSettings: [.linkedFramework("AVFoundation"), .linkedFramework("CoreVideo"), .linkedFramework("CoreMedia"), .linkedFramework("UIKit")]),
|
|
18
|
+
.target(name: "tauri-plugin-g9-diagnostic", dependencies: [.byName(name: "Tauri"), "G9AppDiagnosticCore"], path: "Sources/G9DiagnosticPlugin"),
|
|
19
|
+
]
|
|
20
|
+
)
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
#import "G9AppDiagnosticHost.h"
|
|
2
|
-
|
|
3
|
-
static NSURLSession * (^gSession)(void);
|
|
4
|
-
static NSArray<NSString *> * (^gRoots)(void);
|
|
5
|
-
static BOOL (^gExcluded)(UIView *);
|
|
6
|
-
|
|
7
|
-
@implementation G9AppDiagnosticHost
|
|
8
|
-
|
|
9
|
-
+ (NSURLSession * (^)(void))urlSession { return gSession; }
|
|
10
|
-
+ (void)setUrlSession:(NSURLSession * (^)(void))b { gSession = [b copy]; }
|
|
11
|
-
+ (NSArray<NSString *> * (^)(void))allowedRoots { return gRoots; }
|
|
12
|
-
+ (void)setAllowedRoots:(NSArray<NSString *> * (^)(void))b { gRoots = [b copy]; }
|
|
13
|
-
+ (BOOL (^)(UIView *))isExcludedView { return gExcluded; }
|
|
14
|
-
+ (void)setIsExcludedView:(BOOL (^)(UIView *))b { gExcluded = [b copy]; }
|
|
15
|
-
|
|
16
|
-
+ (NSArray<NSString *> *)roots {
|
|
17
|
-
NSArray<NSString *> *raw = gRoots ? gRoots() : @[
|
|
18
|
-
NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES).firstObject ?: NSTemporaryDirectory(),
|
|
19
|
-
NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject ?: NSTemporaryDirectory(),
|
|
20
|
-
NSTemporaryDirectory(),
|
|
21
|
-
];
|
|
22
|
-
NSMutableArray<NSString *> *out = [NSMutableArray array];
|
|
23
|
-
for (NSString *r in raw) {
|
|
24
|
-
NSString *p = r.stringByStandardizingPath.stringByResolvingSymlinksInPath;
|
|
25
|
-
while (p.length > 1 && [p hasSuffix:@"/"]) p = [p substringToIndex:p.length - 1];
|
|
26
|
-
if (p.length) [out addObject:p];
|
|
27
|
-
}
|
|
28
|
-
return out;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
+ (NSString *)inside:(NSString *)path folder:(BOOL)folder {
|
|
32
|
-
if (path.length == 0) return nil;
|
|
33
|
-
NSString *p = path.stringByStandardizingPath.stringByResolvingSymlinksInPath;
|
|
34
|
-
while (p.length > 1 && [p hasSuffix:@"/"]) p = [p substringToIndex:p.length - 1];
|
|
35
|
-
for (NSString *root in [self roots]) {
|
|
36
|
-
if ([p hasPrefix:[root stringByAppendingString:@"/"]]) return p; // strictly inside: never «/rootX» for «/root»
|
|
37
|
-
if (folder && [p isEqualToString:root]) return p;
|
|
38
|
-
}
|
|
39
|
-
return nil;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
+ (UIWindow *)keyWindow {
|
|
43
|
-
UIWindow *any = nil;
|
|
44
|
-
for (UIScene *scene in UIApplication.sharedApplication.connectedScenes) {
|
|
45
|
-
if (![scene isKindOfClass:UIWindowScene.class]) continue;
|
|
46
|
-
for (UIWindow *w in ((UIWindowScene *)scene).windows) {
|
|
47
|
-
if (w.isKeyWindow) return w;
|
|
48
|
-
if (!any && !w.hidden) any = w;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return any;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
+ (CGSize)windowSize {
|
|
55
|
-
UIWindow *w = [self keyWindow];
|
|
56
|
-
return w ? w.bounds.size : CGSizeZero;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
+ (UIImage *)captureWindowAtScale:(CGFloat)scale {
|
|
60
|
-
UIWindow *window = [self keyWindow];
|
|
61
|
-
if (window == nil || CGRectIsEmpty(window.bounds)) return nil;
|
|
62
|
-
UIGraphicsImageRendererFormat *format = [UIGraphicsImageRendererFormat preferredFormat];
|
|
63
|
-
format.scale = scale;
|
|
64
|
-
format.opaque = YES;
|
|
65
|
-
// drawViewHierarchyInRect snapshots the composited screen, Metal layers included (a MapLibre map) — what PixelCopy
|
|
66
|
-
// and the SurfaceView composite give on Android.
|
|
67
|
-
return [[[UIGraphicsImageRenderer alloc] initWithSize:window.bounds.size format:format] imageWithActions:^(UIGraphicsImageRendererContext *ctx) {
|
|
68
|
-
[window drawViewHierarchyInRect:window.bounds afterScreenUpdates:NO];
|
|
69
|
-
}];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
@end
|
|
1
|
+
#import "G9AppDiagnosticHost.h"
|
|
2
|
+
|
|
3
|
+
static NSURLSession * (^gSession)(void);
|
|
4
|
+
static NSArray<NSString *> * (^gRoots)(void);
|
|
5
|
+
static BOOL (^gExcluded)(UIView *);
|
|
6
|
+
|
|
7
|
+
@implementation G9AppDiagnosticHost
|
|
8
|
+
|
|
9
|
+
+ (NSURLSession * (^)(void))urlSession { return gSession; }
|
|
10
|
+
+ (void)setUrlSession:(NSURLSession * (^)(void))b { gSession = [b copy]; }
|
|
11
|
+
+ (NSArray<NSString *> * (^)(void))allowedRoots { return gRoots; }
|
|
12
|
+
+ (void)setAllowedRoots:(NSArray<NSString *> * (^)(void))b { gRoots = [b copy]; }
|
|
13
|
+
+ (BOOL (^)(UIView *))isExcludedView { return gExcluded; }
|
|
14
|
+
+ (void)setIsExcludedView:(BOOL (^)(UIView *))b { gExcluded = [b copy]; }
|
|
15
|
+
|
|
16
|
+
+ (NSArray<NSString *> *)roots {
|
|
17
|
+
NSArray<NSString *> *raw = gRoots ? gRoots() : @[
|
|
18
|
+
NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES).firstObject ?: NSTemporaryDirectory(),
|
|
19
|
+
NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES).firstObject ?: NSTemporaryDirectory(),
|
|
20
|
+
NSTemporaryDirectory(),
|
|
21
|
+
];
|
|
22
|
+
NSMutableArray<NSString *> *out = [NSMutableArray array];
|
|
23
|
+
for (NSString *r in raw) {
|
|
24
|
+
NSString *p = r.stringByStandardizingPath.stringByResolvingSymlinksInPath;
|
|
25
|
+
while (p.length > 1 && [p hasSuffix:@"/"]) p = [p substringToIndex:p.length - 1];
|
|
26
|
+
if (p.length) [out addObject:p];
|
|
27
|
+
}
|
|
28
|
+
return out;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
+ (NSString *)inside:(NSString *)path folder:(BOOL)folder {
|
|
32
|
+
if (path.length == 0) return nil;
|
|
33
|
+
NSString *p = path.stringByStandardizingPath.stringByResolvingSymlinksInPath;
|
|
34
|
+
while (p.length > 1 && [p hasSuffix:@"/"]) p = [p substringToIndex:p.length - 1];
|
|
35
|
+
for (NSString *root in [self roots]) {
|
|
36
|
+
if ([p hasPrefix:[root stringByAppendingString:@"/"]]) return p; // strictly inside: never «/rootX» for «/root»
|
|
37
|
+
if (folder && [p isEqualToString:root]) return p;
|
|
38
|
+
}
|
|
39
|
+
return nil;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
+ (UIWindow *)keyWindow {
|
|
43
|
+
UIWindow *any = nil;
|
|
44
|
+
for (UIScene *scene in UIApplication.sharedApplication.connectedScenes) {
|
|
45
|
+
if (![scene isKindOfClass:UIWindowScene.class]) continue;
|
|
46
|
+
for (UIWindow *w in ((UIWindowScene *)scene).windows) {
|
|
47
|
+
if (w.isKeyWindow) return w;
|
|
48
|
+
if (!any && !w.hidden) any = w;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return any;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
+ (CGSize)windowSize {
|
|
55
|
+
UIWindow *w = [self keyWindow];
|
|
56
|
+
return w ? w.bounds.size : CGSizeZero;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
+ (UIImage *)captureWindowAtScale:(CGFloat)scale {
|
|
60
|
+
UIWindow *window = [self keyWindow];
|
|
61
|
+
if (window == nil || CGRectIsEmpty(window.bounds)) return nil;
|
|
62
|
+
UIGraphicsImageRendererFormat *format = [UIGraphicsImageRendererFormat preferredFormat];
|
|
63
|
+
format.scale = scale;
|
|
64
|
+
format.opaque = YES;
|
|
65
|
+
// drawViewHierarchyInRect snapshots the composited screen, Metal layers included (a MapLibre map) — what PixelCopy
|
|
66
|
+
// and the SurfaceView composite give on Android.
|
|
67
|
+
return [[[UIGraphicsImageRenderer alloc] initWithSize:window.bounds.size format:format] imageWithActions:^(UIGraphicsImageRendererContext *ctx) {
|
|
68
|
+
[window drawViewHierarchyInRect:window.bounds afterScreenUpdates:NO];
|
|
69
|
+
}];
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@end
|