@testerpaykit/expo 0.7.0 → 0.7.2
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/CHANGELOG.md +28 -0
- package/dist/index.js +376 -357
- package/dist/index.mjs +19 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -2762,6 +2762,9 @@ import {
|
|
|
2762
2762
|
View as View3
|
|
2763
2763
|
} from "react-native";
|
|
2764
2764
|
|
|
2765
|
+
// src/screenshot.ts
|
|
2766
|
+
import { AppState as AppState2 } from "react-native";
|
|
2767
|
+
|
|
2765
2768
|
// src/sensitive-redaction.ts
|
|
2766
2769
|
var STYLE_ID = "tpk-sensitive-redaction-style";
|
|
2767
2770
|
var MODE_STYLE_RULES = {
|
|
@@ -2831,13 +2834,29 @@ async function withNativeCapture(fn) {
|
|
|
2831
2834
|
}
|
|
2832
2835
|
|
|
2833
2836
|
// src/screenshot.ts
|
|
2837
|
+
function isForeground() {
|
|
2838
|
+
const state = AppState2?.currentState;
|
|
2839
|
+
return state == null || state === "active";
|
|
2840
|
+
}
|
|
2834
2841
|
async function captureView(viewRef, options = {}) {
|
|
2835
2842
|
const format = options.format ?? "png";
|
|
2843
|
+
if (!isForeground()) {
|
|
2844
|
+
console.debug(
|
|
2845
|
+
"[testerpaykit/expo] screenshot skipped: app is not in the foreground."
|
|
2846
|
+
);
|
|
2847
|
+
return null;
|
|
2848
|
+
}
|
|
2836
2849
|
const redact = options.redactSensitive !== false;
|
|
2837
2850
|
const teardownCss = redact ? applySensitiveRedaction() : null;
|
|
2838
2851
|
if (redact) beginNativeCapture();
|
|
2839
2852
|
try {
|
|
2840
2853
|
if (redact) await Promise.resolve();
|
|
2854
|
+
if (!isForeground()) {
|
|
2855
|
+
console.debug(
|
|
2856
|
+
"[testerpaykit/expo] screenshot skipped: app left the foreground while preparing."
|
|
2857
|
+
);
|
|
2858
|
+
return null;
|
|
2859
|
+
}
|
|
2841
2860
|
const mod = await import("react-native-view-shot");
|
|
2842
2861
|
const captureRef = (mod.default ?? mod).captureRef ?? mod.captureRef;
|
|
2843
2862
|
const base64 = await captureRef(viewRef, {
|
package/package.json
CHANGED