@swipt/api 0.1.0-nightly.36 → 0.1.0-nightly.38
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/accessibility.d.ts +8 -18
- package/accessibility.mjs +2 -2
- package/package.json +1 -1
- package/screen.d.ts +29 -3
- package/screen.mjs +1 -0
- package/swiplet.d.ts +2 -0
- package/swiplet.mjs +1 -0
package/accessibility.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { CallOptions, Point, Rect } from "./index";
|
|
2
|
-
import type { TapOptions } from "./input";
|
|
3
2
|
|
|
4
3
|
export type AccessibilityTrait = "button" | "link" | "image" | "playsSound" | "keyboardKey" | "staticText" | "summaryElement"
|
|
5
4
|
| "updatesFrequently" | "searchField" | "startsMediaSession" | "adjustable" | "allowsDirectInteraction"
|
|
@@ -49,10 +48,6 @@ export interface AccessibilitySnapshot {
|
|
|
49
48
|
type TextField = "role" | "class" | "label" | "value" | "identifier" | "placeholder" | "hint" | "url" | "app";
|
|
50
49
|
type Flag = "disabled" | "focused" | "selected" | "expanded" | "secure" | "partial" | "offScreen" | "inert" | "remote";
|
|
51
50
|
|
|
52
|
-
export type AccessibilityQuery = { traits?: AccessibilityTrait[]; within?: AccessibilityQuery; parent?: AccessibilityQuery; has?: AccessibilityQuery; not?: AccessibilityQuery; index?: number }
|
|
53
|
-
& { [field in TextField]?: string | RegExp }
|
|
54
|
-
& { [field in Flag]?: boolean };
|
|
55
|
-
|
|
56
51
|
export type AccessibilitySelector =
|
|
57
52
|
| ({ traits?: AccessibilityTrait[]; within?: AccessibilitySelector | AccessibilityElement; parent?: AccessibilitySelector | AccessibilityElement; has?: AccessibilitySelector | AccessibilityElement; not?: AccessibilitySelector | AccessibilityElement; index?: number }
|
|
58
53
|
& { [field in TextField]?: string | RegExp }
|
|
@@ -64,20 +59,15 @@ export interface SnapshotOptions extends CallOptions {
|
|
|
64
59
|
readonly full?: boolean;
|
|
65
60
|
}
|
|
66
61
|
|
|
67
|
-
export interface
|
|
68
|
-
/**
|
|
62
|
+
export interface FindOptions extends CallOptions {
|
|
63
|
+
/** Omitted or 0 reads once; a positive number or Infinity reads until a match, and answers null at the limit. */
|
|
69
64
|
readonly timeoutMs?: number;
|
|
65
|
+
/** Reads again as soon as a read ends. Without it, a read waits for the device's next screen push, which comes 0.75 s after a change at the soonest and not at all for a change that adds or removes no element. */
|
|
66
|
+
readonly poll?: boolean;
|
|
67
|
+
readonly pollTimeoutMs?: number;
|
|
70
68
|
}
|
|
71
69
|
|
|
72
|
-
export interface AccessibilityLocator {
|
|
73
|
-
tap(options?: LocatorOptions & TapOptions): Promise<void>;
|
|
74
|
-
/** Taps each element as it comes to match, once while it stays matched, and resolves when the app in front at the call leaves the front, at once if the query names only other apps. */
|
|
75
|
-
tapEach(options?: TapOptions): Promise<void>;
|
|
76
|
-
setText(text: string, options?: LocatorOptions): Promise<void>;
|
|
77
|
-
perform(action: AccessibilityAction | (string & {}), options?: LocatorOptions): Promise<void>;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
export declare function locator(query: AccessibilityQuery | readonly AccessibilityQuery[]): AccessibilityLocator;
|
|
81
70
|
export declare function snapshot(options?: SnapshotOptions): Promise<AccessibilitySnapshot>;
|
|
82
|
-
export declare function find(selector: AccessibilitySelector, options?:
|
|
83
|
-
export declare function
|
|
71
|
+
export declare function find(selector: AccessibilitySelector | readonly AccessibilitySelector[], options?: FindOptions): Promise<AccessibilityElement | null>;
|
|
72
|
+
export declare function setText(element: AccessibilityElement, text: string, options?: CallOptions): Promise<void>;
|
|
73
|
+
export declare function perform(element: AccessibilityElement, action: AccessibilityAction | (string & {}), options?: CallOptions): Promise<void>;
|
package/accessibility.mjs
CHANGED
|
@@ -2,7 +2,7 @@ const outside = () => {
|
|
|
2
2
|
throw new Error("@swipt/api/accessibility runs inside Swipt; build the swiplet with `swipt build`");
|
|
3
3
|
};
|
|
4
4
|
|
|
5
|
-
export const locator = outside;
|
|
6
5
|
export const snapshot = outside;
|
|
7
6
|
export const find = outside;
|
|
8
|
-
export const
|
|
7
|
+
export const setText = outside;
|
|
8
|
+
export const perform = outside;
|
package/package.json
CHANGED
package/screen.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CallOptions, ObservableState, Rect } from "./index";
|
|
1
|
+
import type { CallOptions, ObservableState, Point, Rect } from "./index";
|
|
2
2
|
import type { FileHandle } from "./file-system";
|
|
3
3
|
import type { ImageDifference, RasterImage } from "./image";
|
|
4
4
|
|
|
@@ -18,10 +18,11 @@ export interface ScreenChange {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export type TimelineEvent =
|
|
21
|
-
| { readonly time: number; readonly type: "operation"; readonly name: string; readonly arguments?: readonly unknown[]; readonly durationMs?: number; readonly error?: string }
|
|
21
|
+
| { readonly time: number; readonly type: "operation"; readonly name: string; readonly arguments?: readonly unknown[]; readonly durationMs?: number; readonly error?: string; readonly message?: string; readonly swiplet?: string }
|
|
22
22
|
| { readonly time: number; readonly type: "action"; readonly swiplet: string; readonly action: string; readonly caller: "app" | "shortcuts" | "api" }
|
|
23
23
|
| { readonly time: number; readonly type: "foreground"; readonly app: string }
|
|
24
|
-
| { readonly time: number; readonly type: "log"; readonly swiplet: string; readonly level: "error" | "warn" | "info" | "debug"; readonly message: string }
|
|
24
|
+
| { readonly time: number; readonly type: "log"; readonly swiplet: string; readonly level: "error" | "warn" | "info" | "debug"; readonly message: string }
|
|
25
|
+
| { readonly time: number; readonly type: "feed"; readonly frames: number; readonly decodedMs: number };
|
|
25
26
|
|
|
26
27
|
export interface ScreenRecording {
|
|
27
28
|
readonly file: FileHandle;
|
|
@@ -37,6 +38,7 @@ export interface ScreenRecording {
|
|
|
37
38
|
frames(times: readonly number[] | { readonly everyMs: number; readonly from?: number; readonly to?: number }): RasterImage[];
|
|
38
39
|
grid(options?: CallOptions & { readonly times?: readonly number[]; readonly columns?: number; readonly width?: number }): Promise<RasterImage>;
|
|
39
40
|
diff(from: number, to: number, options?: CallOptions & { readonly threshold?: number }): Promise<ImageDifference>;
|
|
41
|
+
find(target: ScreenTarget | readonly ScreenTarget[], options?: Omit<ScreenFindOptions, "timeoutMs"> & { readonly from?: number; readonly to?: number }): Promise<(ScreenMatch & { readonly time: number }) | null>;
|
|
40
42
|
export(options?: CallOptions & {
|
|
41
43
|
readonly file?: FileHandle | string;
|
|
42
44
|
readonly from?: number;
|
|
@@ -54,7 +56,31 @@ export interface RecordingSession {
|
|
|
54
56
|
stop(options?: CallOptions): Promise<ScreenRecording>;
|
|
55
57
|
}
|
|
56
58
|
|
|
59
|
+
export type ScreenTarget = RasterImage | RegExp | string;
|
|
60
|
+
|
|
61
|
+
export interface ScreenFindOptions extends CallOptions {
|
|
62
|
+
readonly region?: Rect;
|
|
63
|
+
/** Omitted or 0 reads the latest frame once; a positive number or Infinity keeps reading frames until a match, and answers null at the limit. */
|
|
64
|
+
readonly timeoutMs?: number;
|
|
65
|
+
readonly threshold?: number;
|
|
66
|
+
readonly scales?: readonly number[];
|
|
67
|
+
readonly languages?: readonly string[];
|
|
68
|
+
readonly minimumHeight?: number;
|
|
69
|
+
/** Compares templates and the screen as black and white, split at this gray level, so a mark keeps matching over changing backgrounds. */
|
|
70
|
+
readonly binarize?: number;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface ScreenMatch {
|
|
74
|
+
readonly frame: Rect;
|
|
75
|
+
readonly center: Point;
|
|
76
|
+
readonly score: number;
|
|
77
|
+
readonly text: string | null;
|
|
78
|
+
readonly target: number;
|
|
79
|
+
readonly image: RasterImage;
|
|
80
|
+
}
|
|
81
|
+
|
|
57
82
|
export declare function screenshot(options?: CallOptions): Promise<RasterImage>;
|
|
83
|
+
export declare function find(target: ScreenTarget | readonly ScreenTarget[], options?: ScreenFindOptions): Promise<ScreenMatch | null>;
|
|
58
84
|
export declare const frames: ObservableState<RasterImage>;
|
|
59
85
|
export declare function waitFor(predicate: (frame: RasterImage) => boolean | Promise<boolean>, options?: CallOptions & { readonly timeoutMs?: number }): Promise<RasterImage>;
|
|
60
86
|
export declare function waitForChange(options?: WaitOptions & { readonly from?: RasterImage }): Promise<RasterImage>;
|
package/screen.mjs
CHANGED
package/swiplet.d.ts
CHANGED
|
@@ -106,3 +106,5 @@ export declare function actions<E extends Extension<any, any>>(): ActionCalls<E>
|
|
|
106
106
|
export declare function useService<E extends Extension<any, true>>(): ServiceHandle;
|
|
107
107
|
|
|
108
108
|
export declare function exit(): void;
|
|
109
|
+
|
|
110
|
+
export declare function preferredLocalizations(localizations: readonly string[]): string[];
|
package/swiplet.mjs
CHANGED