@nyssance/tauri-hasgard 0.4.1 → 0.5.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/dist/index.js +40 -3
- package/dist/window.d.ts +17 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -739,9 +739,11 @@ var HasgardApplication = class {
|
|
|
739
739
|
while (Date.now() <= deadline) {
|
|
740
740
|
if ((await this.windows()).some((window) => window.label === label)) {
|
|
741
741
|
const window = this.window(label);
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
return window;
|
|
742
|
+
try {
|
|
743
|
+
const state = await window.state();
|
|
744
|
+
if (state.url !== "about:blank" && state.readyState !== "loading") return window;
|
|
745
|
+
} catch (error) {
|
|
746
|
+
if (!(error instanceof HasgardRpcError) || error.code !== -32002) throw error;
|
|
745
747
|
}
|
|
746
748
|
}
|
|
747
749
|
await new Promise((resolve) => setTimeout(resolve, 50));
|
|
@@ -1006,6 +1008,32 @@ var HasgardWindow = class {
|
|
|
1006
1008
|
if (!dataUrl.startsWith(prefix)) throw new Error("screenshot result is not a PNG data URL");
|
|
1007
1009
|
return Buffer.from(dataUrl.slice(prefix.length), "base64");
|
|
1008
1010
|
}
|
|
1011
|
+
/** Start a bounded recording of this native window. macOS only; requires ffmpeg. */
|
|
1012
|
+
async startVideo(options) {
|
|
1013
|
+
await this.rpc.call("video.start", {
|
|
1014
|
+
window: this.label,
|
|
1015
|
+
output_path: options.outputPath,
|
|
1016
|
+
...options.fps === void 0 ? {} : { fps: options.fps },
|
|
1017
|
+
...options.maxDurationMs === void 0 ? {} : { max_duration_ms: options.maxDurationMs }
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1020
|
+
/** Stop recording; capture and encoder failures reject rather than returning an empty artifact. */
|
|
1021
|
+
async stopVideo() {
|
|
1022
|
+
const value = expectRecord(await this.rpc.call("video.stop", { window: this.label }), "video.stop result");
|
|
1023
|
+
return {
|
|
1024
|
+
outputPath: expectString(value.output_path, "video.output_path"),
|
|
1025
|
+
frames: expectNumber(value.frames, "video.frames"),
|
|
1026
|
+
durationMs: expectNumber(value.duration_ms, "video.duration_ms"),
|
|
1027
|
+
byteSize: expectNumber(value.byte_size, "video.byte_size")
|
|
1028
|
+
};
|
|
1029
|
+
}
|
|
1030
|
+
async videoStatus() {
|
|
1031
|
+
const value = expectRecord(await this.rpc.call("video.status", { window: this.label }), "video.status result");
|
|
1032
|
+
return {
|
|
1033
|
+
active: expectBoolean(value.active, "video.active"),
|
|
1034
|
+
pendingResult: expectBoolean(value.pending_result, "video.pending_result")
|
|
1035
|
+
};
|
|
1036
|
+
}
|
|
1009
1037
|
/**
|
|
1010
1038
|
* Capture this window through the native compositor, writing a PNG to
|
|
1011
1039
|
* `outputPath`. macOS only.
|
|
@@ -1599,6 +1627,15 @@ function createHasgardTest(config) {
|
|
|
1599
1627
|
if (ping.status !== "ok") throw new Error(`Unexpected Hasgard ping status: ${ping.status}`);
|
|
1600
1628
|
await hasgard.waitForWindowReady(config.windowLabel, config.readySelector, readinessTimeoutMs);
|
|
1601
1629
|
await use(hasgard);
|
|
1630
|
+
} catch (error) {
|
|
1631
|
+
if (config.launch) {
|
|
1632
|
+
try {
|
|
1633
|
+
console.error(`Hasgard fixture failed: ${JSON.stringify(await process2.diagnostics(250))}`);
|
|
1634
|
+
} catch (diagnosticError) {
|
|
1635
|
+
console.error("Hasgard diagnostics failed:", diagnosticError);
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
throw error;
|
|
1602
1639
|
} finally {
|
|
1603
1640
|
rpc.disconnect();
|
|
1604
1641
|
await process2.stop();
|
package/dist/window.d.ts
CHANGED
|
@@ -91,6 +91,23 @@ export declare class HasgardWindow {
|
|
|
91
91
|
evaluate<T>(script: string): Promise<T>;
|
|
92
92
|
invoke<T>(command: string, args: Record<string, JsonValue>): Promise<T>;
|
|
93
93
|
screenshot(selector?: string): Promise<Buffer>;
|
|
94
|
+
/** Start a bounded recording of this native window. macOS only; requires ffmpeg. */
|
|
95
|
+
startVideo(options: {
|
|
96
|
+
outputPath: string;
|
|
97
|
+
fps?: number;
|
|
98
|
+
maxDurationMs?: number;
|
|
99
|
+
}): Promise<void>;
|
|
100
|
+
/** Stop recording; capture and encoder failures reject rather than returning an empty artifact. */
|
|
101
|
+
stopVideo(): Promise<{
|
|
102
|
+
outputPath: string;
|
|
103
|
+
frames: number;
|
|
104
|
+
durationMs: number;
|
|
105
|
+
byteSize: number;
|
|
106
|
+
}>;
|
|
107
|
+
videoStatus(): Promise<{
|
|
108
|
+
active: boolean;
|
|
109
|
+
pendingResult: boolean;
|
|
110
|
+
}>;
|
|
94
111
|
/**
|
|
95
112
|
* Capture this window through the native compositor, writing a PNG to
|
|
96
113
|
* `outputPath`. macOS only.
|