@qawolf/run-globals-ios 0.0.18
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/README.md +232 -0
- package/dist/audio.d.ts +98 -0
- package/dist/audio.d.ts.map +1 -0
- package/dist/audio.js +145 -0
- package/dist/audio.js.map +1 -0
- package/dist/barcode.d.ts +58 -0
- package/dist/barcode.d.ts.map +1 -0
- package/dist/barcode.js +45 -0
- package/dist/barcode.js.map +1 -0
- package/dist/beacon.d.ts +48 -0
- package/dist/beacon.d.ts.map +1 -0
- package/dist/beacon.js +49 -0
- package/dist/beacon.js.map +1 -0
- package/dist/configuration-profile.d.ts +27 -0
- package/dist/configuration-profile.d.ts.map +1 -0
- package/dist/configuration-profile.js +40 -0
- package/dist/configuration-profile.js.map +1 -0
- package/dist/gateway.d.ts +443 -0
- package/dist/gateway.d.ts.map +1 -0
- package/dist/gateway.js +433 -0
- package/dist/gateway.js.map +1 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +38 -0
- package/dist/index.js.map +1 -0
- package/dist/injectionHelpers.d.ts +18 -0
- package/dist/injectionHelpers.d.ts.map +1 -0
- package/dist/injectionHelpers.js +68 -0
- package/dist/injectionHelpers.js.map +1 -0
- package/dist/media.d.ts +79 -0
- package/dist/media.d.ts.map +1 -0
- package/dist/media.js +82 -0
- package/dist/media.js.map +1 -0
- package/dist/photo.d.ts +117 -0
- package/dist/photo.d.ts.map +1 -0
- package/dist/photo.js +143 -0
- package/dist/photo.js.map +1 -0
- package/dist/typings.d.ts +773 -0
- package/dist/webview.d.ts +23 -0
- package/dist/webview.d.ts.map +1 -0
- package/dist/webview.js +25 -0
- package/dist/webview.js.map +1 -0
- package/package.json +68 -0
package/dist/media.d.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { Browser } from "webdriverio";
|
|
2
|
+
/**
|
|
3
|
+
* Source configuration for camera/video feed injection.
|
|
4
|
+
*/
|
|
5
|
+
export interface CameraSource {
|
|
6
|
+
/** File path, URL, or data URI for the media to inject */
|
|
7
|
+
data: string;
|
|
8
|
+
/** Media type. Default: inferred from file extension */
|
|
9
|
+
type?: "image" | "video";
|
|
10
|
+
/** Delay in seconds before injection starts */
|
|
11
|
+
delaySeconds?: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Source configuration for microphone/audio injection.
|
|
15
|
+
*/
|
|
16
|
+
export interface AudioSource {
|
|
17
|
+
/** File path, URL, or data URI for the audio to inject */
|
|
18
|
+
data: string;
|
|
19
|
+
/** Delay in seconds before injection starts */
|
|
20
|
+
delaySeconds?: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Inject a camera/video feed into the app's AVCaptureSession.
|
|
24
|
+
*
|
|
25
|
+
* Replaces the camera input with the provided image or video. Affects photo
|
|
26
|
+
* capture, video data output, video recording, and preview layers.
|
|
27
|
+
*
|
|
28
|
+
* When `data` is a local file path, the file is pushed to the device first.
|
|
29
|
+
* URLs and data URIs are downloaded/decoded by the injection dylib on device.
|
|
30
|
+
*
|
|
31
|
+
* Cannot be used simultaneously with `injectAudio` (they share the same config file).
|
|
32
|
+
*
|
|
33
|
+
* @param driver - The WebDriverIO browser instance
|
|
34
|
+
* @param bundleId - Bundle ID of the target app
|
|
35
|
+
* @param source - Media source configuration
|
|
36
|
+
* @returns Cleanup function that removes the injection config and media file
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* // Inject a local image as camera feed
|
|
41
|
+
* const cleanup = await ios.injectCamera(driver, "com.example.app", {
|
|
42
|
+
* data: "/path/to/image.jpg",
|
|
43
|
+
* type: "image",
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* // Inject a video from URL
|
|
47
|
+
* const cleanup = await ios.injectCamera(driver, "com.example.app", {
|
|
48
|
+
* data: "https://example.com/video.mp4",
|
|
49
|
+
* type: "video",
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* await cleanup();
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function injectCamera(driver: Browser, bundleId: string, source: CameraSource): Promise<() => Promise<void>>;
|
|
56
|
+
/**
|
|
57
|
+
* Inject audio into the app's microphone input.
|
|
58
|
+
*
|
|
59
|
+
* Replaces microphone input with the provided audio file. Affects
|
|
60
|
+
* AVAudioRecorder and AVCaptureAudioDataOutput.
|
|
61
|
+
*
|
|
62
|
+
* Cannot be used simultaneously with `injectCamera` (they share the same config file).
|
|
63
|
+
*
|
|
64
|
+
* @param driver - The WebDriverIO browser instance
|
|
65
|
+
* @param bundleId - Bundle ID of the target app
|
|
66
|
+
* @param source - Audio source configuration
|
|
67
|
+
* @returns Cleanup function that removes the injection config and audio file
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```typescript
|
|
71
|
+
* const cleanup = await ios.injectAudio(driver, "com.example.app", {
|
|
72
|
+
* data: "/path/to/audio.mp3",
|
|
73
|
+
* });
|
|
74
|
+
*
|
|
75
|
+
* await cleanup();
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export declare function injectAudio(driver: Browser, bundleId: string, source: AudioSource): Promise<() => Promise<void>>;
|
|
79
|
+
//# sourceMappingURL=media.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAO3C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IACzB,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,+CAA+C;IAC/C,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,YAAY,GACnB,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAwB9B;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,OAAO,EACf,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAuB9B"}
|
package/dist/media.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { inferMediaType, pushJsonConfig, pushLocalOrRemoteMedia, } from "./injectionHelpers.js";
|
|
2
|
+
/**
|
|
3
|
+
* Inject a camera/video feed into the app's AVCaptureSession.
|
|
4
|
+
*
|
|
5
|
+
* Replaces the camera input with the provided image or video. Affects photo
|
|
6
|
+
* capture, video data output, video recording, and preview layers.
|
|
7
|
+
*
|
|
8
|
+
* When `data` is a local file path, the file is pushed to the device first.
|
|
9
|
+
* URLs and data URIs are downloaded/decoded by the injection dylib on device.
|
|
10
|
+
*
|
|
11
|
+
* Cannot be used simultaneously with `injectAudio` (they share the same config file).
|
|
12
|
+
*
|
|
13
|
+
* @param driver - The WebDriverIO browser instance
|
|
14
|
+
* @param bundleId - Bundle ID of the target app
|
|
15
|
+
* @param source - Media source configuration
|
|
16
|
+
* @returns Cleanup function that removes the injection config and media file
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* // Inject a local image as camera feed
|
|
21
|
+
* const cleanup = await ios.injectCamera(driver, "com.example.app", {
|
|
22
|
+
* data: "/path/to/image.jpg",
|
|
23
|
+
* type: "image",
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* // Inject a video from URL
|
|
27
|
+
* const cleanup = await ios.injectCamera(driver, "com.example.app", {
|
|
28
|
+
* data: "https://example.com/video.mp4",
|
|
29
|
+
* type: "video",
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* await cleanup();
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export async function injectCamera(driver, bundleId, source) {
|
|
36
|
+
const type = source.type ?? inferMediaType(source.data);
|
|
37
|
+
const { dataRef, cleanup: mediaCleanup } = await pushLocalOrRemoteMedia(driver, bundleId, source.data);
|
|
38
|
+
const config = { data: dataRef, type };
|
|
39
|
+
if (source.delaySeconds !== undefined) {
|
|
40
|
+
config.delaySeconds = source.delaySeconds;
|
|
41
|
+
}
|
|
42
|
+
const configCleanup = await pushJsonConfig(driver, bundleId, "media.json", config);
|
|
43
|
+
return async () => {
|
|
44
|
+
await configCleanup();
|
|
45
|
+
await mediaCleanup();
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Inject audio into the app's microphone input.
|
|
50
|
+
*
|
|
51
|
+
* Replaces microphone input with the provided audio file. Affects
|
|
52
|
+
* AVAudioRecorder and AVCaptureAudioDataOutput.
|
|
53
|
+
*
|
|
54
|
+
* Cannot be used simultaneously with `injectCamera` (they share the same config file).
|
|
55
|
+
*
|
|
56
|
+
* @param driver - The WebDriverIO browser instance
|
|
57
|
+
* @param bundleId - Bundle ID of the target app
|
|
58
|
+
* @param source - Audio source configuration
|
|
59
|
+
* @returns Cleanup function that removes the injection config and audio file
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const cleanup = await ios.injectAudio(driver, "com.example.app", {
|
|
64
|
+
* data: "/path/to/audio.mp3",
|
|
65
|
+
* });
|
|
66
|
+
*
|
|
67
|
+
* await cleanup();
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export async function injectAudio(driver, bundleId, source) {
|
|
71
|
+
const { dataRef, cleanup: mediaCleanup } = await pushLocalOrRemoteMedia(driver, bundleId, source.data);
|
|
72
|
+
const config = { data: dataRef, type: "audio" };
|
|
73
|
+
if (source.delaySeconds !== undefined) {
|
|
74
|
+
config.delaySeconds = source.delaySeconds;
|
|
75
|
+
}
|
|
76
|
+
const configCleanup = await pushJsonConfig(driver, bundleId, "media.json", config);
|
|
77
|
+
return async () => {
|
|
78
|
+
await configCleanup();
|
|
79
|
+
await mediaCleanup();
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=media.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media.js","sourceRoot":"","sources":["../src/media.ts"],"names":[],"mappings":"AACA,OAAO,EACL,cAAc,EACd,cAAc,EACd,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAwB/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAe,EACf,QAAgB,EAChB,MAAoB;IAEpB,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,IAAI,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACxD,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,sBAAsB,CACrE,MAAM,EACN,QAAQ,EACR,MAAM,CAAC,IAAI,CACZ,CAAC;IAEF,MAAM,MAAM,GAA4B,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IAChE,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACtC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;IAC5C,CAAC;IAED,MAAM,aAAa,GAAG,MAAM,cAAc,CACxC,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,MAAM,CACP,CAAC;IAEF,OAAO,KAAK,IAAI,EAAE;QAChB,MAAM,aAAa,EAAE,CAAC;QACtB,MAAM,YAAY,EAAE,CAAC;IACvB,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAe,EACf,QAAgB,EAChB,MAAmB;IAEnB,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,GAAG,MAAM,sBAAsB,CACrE,MAAM,EACN,QAAQ,EACR,MAAM,CAAC,IAAI,CACZ,CAAC;IAEF,MAAM,MAAM,GAA4B,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IACzE,IAAI,MAAM,CAAC,YAAY,KAAK,SAAS,EAAE,CAAC;QACtC,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;IAC5C,CAAC;IAED,MAAM,aAAa,GAAG,MAAM,cAAc,CACxC,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,MAAM,CACP,CAAC;IAEF,OAAO,KAAK,IAAI,EAAE;QAChB,MAAM,aAAa,EAAE,CAAC;QACtB,MAAM,YAAY,EAAE,CAAC;IACvB,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/photo.d.ts
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { Browser } from "webdriverio";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/**
|
|
4
|
+
* Schema for a photo or video asset in the Photos library
|
|
5
|
+
*/
|
|
6
|
+
export declare const PhotoAssetSchema: z.ZodObject<{
|
|
7
|
+
localIdentifier: z.ZodString;
|
|
8
|
+
mediaType: z.ZodString;
|
|
9
|
+
mediaSubtype: z.ZodString;
|
|
10
|
+
creationDate: z.ZodString;
|
|
11
|
+
modificationDate: z.ZodString;
|
|
12
|
+
pixelWidth: z.ZodNumber;
|
|
13
|
+
pixelHeight: z.ZodNumber;
|
|
14
|
+
duration: z.ZodNumber;
|
|
15
|
+
isFavorite: z.ZodBoolean;
|
|
16
|
+
isHidden: z.ZodBoolean;
|
|
17
|
+
}, z.core.$strip>;
|
|
18
|
+
/**
|
|
19
|
+
* Represents a photo or video asset in the Photos library
|
|
20
|
+
*/
|
|
21
|
+
export type PhotoAsset = z.input<typeof PhotoAssetSchema>;
|
|
22
|
+
/**
|
|
23
|
+
* Schema for the result of saving a photo to the Photos library
|
|
24
|
+
*/
|
|
25
|
+
export declare const SavePhotoResultSchema: z.ZodObject<{
|
|
26
|
+
success: z.ZodBoolean;
|
|
27
|
+
message: z.ZodOptional<z.ZodString>;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
/**
|
|
30
|
+
* Result of saving a photo to the Photos library
|
|
31
|
+
*/
|
|
32
|
+
export type SavePhotoResult = z.input<typeof SavePhotoResultSchema>;
|
|
33
|
+
/**
|
|
34
|
+
* Schema for the result of listing photos from the Photos library
|
|
35
|
+
*/
|
|
36
|
+
export declare const ListPhotosResultSchema: z.ZodObject<{
|
|
37
|
+
success: z.ZodBoolean;
|
|
38
|
+
assets: z.ZodArray<z.ZodObject<{
|
|
39
|
+
localIdentifier: z.ZodString;
|
|
40
|
+
mediaType: z.ZodString;
|
|
41
|
+
mediaSubtype: z.ZodString;
|
|
42
|
+
creationDate: z.ZodString;
|
|
43
|
+
modificationDate: z.ZodString;
|
|
44
|
+
pixelWidth: z.ZodNumber;
|
|
45
|
+
pixelHeight: z.ZodNumber;
|
|
46
|
+
duration: z.ZodNumber;
|
|
47
|
+
isFavorite: z.ZodBoolean;
|
|
48
|
+
isHidden: z.ZodBoolean;
|
|
49
|
+
}, z.core.$strip>>;
|
|
50
|
+
totalCount: z.ZodNumber;
|
|
51
|
+
}, z.core.$strip>;
|
|
52
|
+
/**
|
|
53
|
+
* Result of listing photos from the Photos library
|
|
54
|
+
*/
|
|
55
|
+
export type ListPhotosResult = z.input<typeof ListPhotosResultSchema>;
|
|
56
|
+
/**
|
|
57
|
+
* Schema for the result of deleting all photos from the Photos library
|
|
58
|
+
*/
|
|
59
|
+
export declare const DeletePhotosResultSchema: z.ZodObject<{
|
|
60
|
+
success: z.ZodBoolean;
|
|
61
|
+
deletedCount: z.ZodNumber;
|
|
62
|
+
message: z.ZodOptional<z.ZodString>;
|
|
63
|
+
}, z.core.$strip>;
|
|
64
|
+
/**
|
|
65
|
+
* Result of deleting all photos from the Photos library
|
|
66
|
+
*/
|
|
67
|
+
export type DeletePhotosResult = z.input<typeof DeletePhotosResultSchema>;
|
|
68
|
+
/**
|
|
69
|
+
* Save an image file from the filesystem to the device Photos library.
|
|
70
|
+
* This function handles the entire workflow:
|
|
71
|
+
* 1. Reads the file from the filesystem
|
|
72
|
+
* 2. Pushes it to the device's app container
|
|
73
|
+
* 3. Saves it to Photos library via the iOS agent
|
|
74
|
+
* 4. Cleans up the temporary file from the device
|
|
75
|
+
*
|
|
76
|
+
* @param driver - The WebDriverIO browser instance
|
|
77
|
+
* @param filePath - Absolute path to the file on the filesystem
|
|
78
|
+
* @returns Promise resolving to the save operation result
|
|
79
|
+
* @example
|
|
80
|
+
* ```typescript
|
|
81
|
+
* const result = await ios.savePhoto(driver, '/Users/me/photo.jpg');
|
|
82
|
+
* if (result.success) {
|
|
83
|
+
* console.log('Photo saved to library');
|
|
84
|
+
* }
|
|
85
|
+
* ```
|
|
86
|
+
*/
|
|
87
|
+
export declare function savePhoto(driver: Browser, filePath: string): Promise<SavePhotoResult>;
|
|
88
|
+
/**
|
|
89
|
+
* List all photos and videos from the Photos library.
|
|
90
|
+
* Returns full protocol response with success status, assets array, and total count.
|
|
91
|
+
*
|
|
92
|
+
* @param driver - The WebDriverIO browser instance
|
|
93
|
+
* @returns Promise resolving to list result with assets and count
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const result = await ios.listPhotos(driver);
|
|
97
|
+
* console.log(`Found ${result.totalCount} photos in library`);
|
|
98
|
+
* result.assets.forEach(asset => {
|
|
99
|
+
* console.log(`${asset.mediaType}: ${asset.localIdentifier}`);
|
|
100
|
+
* });
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare function listPhotos(driver: Browser): Promise<ListPhotosResult>;
|
|
104
|
+
/**
|
|
105
|
+
* Delete all photos and videos from the Photos library.
|
|
106
|
+
* This is useful for cleaning up test data between test runs.
|
|
107
|
+
*
|
|
108
|
+
* @param driver - The WebDriverIO browser instance
|
|
109
|
+
* @returns Promise resolving to delete result with count and message
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* const result = await ios.deleteAllPhotos(driver);
|
|
113
|
+
* console.log(`Deleted ${result.deletedCount} photos`);
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export declare function deleteAllPhotos(driver: Browser): Promise<DeletePhotosResult>;
|
|
117
|
+
//# sourceMappingURL=photo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"photo.d.ts","sourceRoot":"","sources":["../src/photo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAG3C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;iBAqB3B,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1D;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;iBAKhC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;iBAOjC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAEtE;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;iBAOnC,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE1E;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,CAmC3F;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAE3E;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,eAAe,CAAC,MAAM,EAAE,OAAO,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAElF"}
|
package/dist/photo.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
/**
|
|
5
|
+
* Schema for a photo or video asset in the Photos library
|
|
6
|
+
*/
|
|
7
|
+
export const PhotoAssetSchema = z.object({
|
|
8
|
+
/** Unique identifier for the photo */
|
|
9
|
+
localIdentifier: z.string(),
|
|
10
|
+
/** Media type: "image", "video", or "audio" */
|
|
11
|
+
mediaType: z.string(),
|
|
12
|
+
/** Media subtype (e.g., "livePhoto", "panorama", "screenshot") */
|
|
13
|
+
mediaSubtype: z.string(),
|
|
14
|
+
/** ISO 8601 creation date */
|
|
15
|
+
creationDate: z.string(),
|
|
16
|
+
/** ISO 8601 modification date */
|
|
17
|
+
modificationDate: z.string(),
|
|
18
|
+
/** Width in pixels */
|
|
19
|
+
pixelWidth: z.number(),
|
|
20
|
+
/** Height in pixels */
|
|
21
|
+
pixelHeight: z.number(),
|
|
22
|
+
/** Duration in seconds (for videos) */
|
|
23
|
+
duration: z.number(),
|
|
24
|
+
/** Whether the asset is marked as favorite */
|
|
25
|
+
isFavorite: z.boolean(),
|
|
26
|
+
/** Whether the asset is hidden */
|
|
27
|
+
isHidden: z.boolean(),
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Schema for the result of saving a photo to the Photos library
|
|
31
|
+
*/
|
|
32
|
+
export const SavePhotoResultSchema = z.object({
|
|
33
|
+
/** Whether the save operation was successful */
|
|
34
|
+
success: z.boolean(),
|
|
35
|
+
/** Optional message providing additional information */
|
|
36
|
+
message: z.string().optional(),
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Schema for the result of listing photos from the Photos library
|
|
40
|
+
*/
|
|
41
|
+
export const ListPhotosResultSchema = z.object({
|
|
42
|
+
/** Whether the list operation was successful */
|
|
43
|
+
success: z.boolean(),
|
|
44
|
+
/** Array of photo/video assets */
|
|
45
|
+
assets: z.array(PhotoAssetSchema),
|
|
46
|
+
/** Total count of assets */
|
|
47
|
+
totalCount: z.number(),
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* Schema for the result of deleting all photos from the Photos library
|
|
51
|
+
*/
|
|
52
|
+
export const DeletePhotosResultSchema = z.object({
|
|
53
|
+
/** Whether the delete operation was successful */
|
|
54
|
+
success: z.boolean(),
|
|
55
|
+
/** Number of photos/videos deleted */
|
|
56
|
+
deletedCount: z.number(),
|
|
57
|
+
/** Optional message providing additional information */
|
|
58
|
+
message: z.string().optional(),
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* Save an image file from the filesystem to the device Photos library.
|
|
62
|
+
* This function handles the entire workflow:
|
|
63
|
+
* 1. Reads the file from the filesystem
|
|
64
|
+
* 2. Pushes it to the device's app container
|
|
65
|
+
* 3. Saves it to Photos library via the iOS agent
|
|
66
|
+
* 4. Cleans up the temporary file from the device
|
|
67
|
+
*
|
|
68
|
+
* @param driver - The WebDriverIO browser instance
|
|
69
|
+
* @param filePath - Absolute path to the file on the filesystem
|
|
70
|
+
* @returns Promise resolving to the save operation result
|
|
71
|
+
* @example
|
|
72
|
+
* ```typescript
|
|
73
|
+
* const result = await ios.savePhoto(driver, '/Users/me/photo.jpg');
|
|
74
|
+
* if (result.success) {
|
|
75
|
+
* console.log('Photo saved to library');
|
|
76
|
+
* }
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
export async function savePhoto(driver, filePath) {
|
|
80
|
+
// Read file from the filesystem
|
|
81
|
+
const fileBuffer = fs.readFileSync(filePath);
|
|
82
|
+
const base64Data = fileBuffer.toString("base64");
|
|
83
|
+
const fileName = path.basename(filePath);
|
|
84
|
+
// Push file to device's PublicFiles folder in ios-agent-tests app container
|
|
85
|
+
// Format: @<bundle_id>:<path_inside_container>
|
|
86
|
+
const deviceRelativePath = `@com.qawolf.ios-agent.tests.xctrunner:Documents/PublicFiles/${fileName}`;
|
|
87
|
+
await driver.pushFile(deviceRelativePath, base64Data);
|
|
88
|
+
// Small delay to ensure filesystem has synced
|
|
89
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
90
|
+
// Construct device path relative to app container
|
|
91
|
+
const devicePath = `Documents/PublicFiles/${fileName}`;
|
|
92
|
+
// Call the protocol command to save to Photos
|
|
93
|
+
const result = (await driver.execute("qawolf: saveToPhotos", [
|
|
94
|
+
{ filePath: devicePath },
|
|
95
|
+
]));
|
|
96
|
+
// Clean up the file from PublicFiles after successful save
|
|
97
|
+
if (result.success) {
|
|
98
|
+
try {
|
|
99
|
+
await driver.execute("mobile: deleteFile", {
|
|
100
|
+
remotePath: `@com.qawolf.ios-agent.tests.xctrunner:${devicePath}`,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
// Log but don't fail if cleanup fails
|
|
105
|
+
console.warn(`Failed to delete file after saving to Photos: ${error}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return result;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* List all photos and videos from the Photos library.
|
|
112
|
+
* Returns full protocol response with success status, assets array, and total count.
|
|
113
|
+
*
|
|
114
|
+
* @param driver - The WebDriverIO browser instance
|
|
115
|
+
* @returns Promise resolving to list result with assets and count
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* const result = await ios.listPhotos(driver);
|
|
119
|
+
* console.log(`Found ${result.totalCount} photos in library`);
|
|
120
|
+
* result.assets.forEach(asset => {
|
|
121
|
+
* console.log(`${asset.mediaType}: ${asset.localIdentifier}`);
|
|
122
|
+
* });
|
|
123
|
+
* ```
|
|
124
|
+
*/
|
|
125
|
+
export async function listPhotos(driver) {
|
|
126
|
+
return (await driver.execute("qawolf: listPhotos", []));
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Delete all photos and videos from the Photos library.
|
|
130
|
+
* This is useful for cleaning up test data between test runs.
|
|
131
|
+
*
|
|
132
|
+
* @param driver - The WebDriverIO browser instance
|
|
133
|
+
* @returns Promise resolving to delete result with count and message
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* const result = await ios.deleteAllPhotos(driver);
|
|
137
|
+
* console.log(`Deleted ${result.deletedCount} photos`);
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
export async function deleteAllPhotos(driver) {
|
|
141
|
+
return (await driver.execute("qawolf: deleteAllPhotos", []));
|
|
142
|
+
}
|
|
143
|
+
//# sourceMappingURL=photo.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"photo.js","sourceRoot":"","sources":["../src/photo.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IACvC,sCAAsC;IACtC,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE;IAC3B,+CAA+C;IAC/C,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,kEAAkE;IAClE,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;IACx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