@nyssance/tauri-hasgard 0.1.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/LICENSE ADDED
@@ -0,0 +1,226 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Nyssance
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+
203
+ -------------------------------------------------------------------------------
204
+
205
+ THIRD-PARTY MIT LICENSE NOTICES
206
+
207
+ Copyright (c) 2026 Mathieu Piton
208
+ Copyright (c) 2026 Simon Holmes
209
+
210
+ Permission is hereby granted, free of charge, to any person obtaining a copy
211
+ of this software and associated documentation files (the "Software"), to deal
212
+ in the Software without restriction, including without limitation the rights
213
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
214
+ copies of the Software, and to permit persons to whom the Software is
215
+ furnished to do so, subject to the following conditions:
216
+
217
+ The above copyright notice and this permission notice shall be included in all
218
+ copies or substantial portions of the Software.
219
+
220
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
221
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
222
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
223
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
224
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
225
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
226
+ SOFTWARE.
package/NOTICE.md ADDED
@@ -0,0 +1,14 @@
1
+ # Tauri Hasgard Notice
2
+
3
+ Copyright 2026 Nyssance
4
+
5
+ Tauri Hasgard is licensed under the Apache License, Version 2.0.
6
+
7
+ ## Third-party provenance
8
+
9
+ Tauri Hasgard includes and adapts MIT-licensed work from:
10
+
11
+ - `mpiton/tauri-pilot` at commit `219dfc2f0ebbcdbebf3e6041bb4a5ea268bb026e`
12
+ - `srsholmes/tauri-playwright` at commit `7e50bff1905ad8d5e6a52fb40e6439e0dbcbe6e6`
13
+
14
+ The original copyright notices and MIT license terms remain in [LICENSE](LICENSE).
package/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # @nyssance/tauri-hasgard
2
+
3
+ Playwright Test fixtures for real Tauri 2 webviews. The package uses Playwright for test scheduling, assertions, retries, reporters, and artifacts; native application control goes through Hasgard's JSON-RPC bridge.
4
+
5
+ It deliberately does not expose a fake Playwright `Page`. WKWebView and WebKitGTK do not implement Chromium's CDP contract.
6
+
7
+ The fixture object model is `HasgardApplication → HasgardWindow → HasgardLocator`. `hasgard` is the worker-scoped application fixture; `window` is the test-scoped configured primary window.
8
+
9
+ ## Setup
10
+
11
+ ```ts
12
+ import { createHasgardTest } from "@nyssance/tauri-hasgard"
13
+ import { expect as playwrightExpect, test as playwrightTest } from "@playwright/test"
14
+
15
+ export const { test, expect } = createHasgardTest({
16
+ test: playwrightTest,
17
+ expect: playwrightExpect,
18
+ socketPath: workerIndex => `/tmp/my-app-e2e-${workerIndex}.sock`,
19
+ windowLabel: "main",
20
+ readySelector: '[data-app-ready="true"]',
21
+ launch: {
22
+ command: "bun",
23
+ args: ["run", "tauri", "dev"],
24
+ cwd: import.meta.dirname,
25
+ timeoutMs: 120_000
26
+ }
27
+ })
28
+ ```
29
+
30
+ The fixture passes the selected socket to the application as `TAURI_HASGARD_SOCKET`, so each Playwright worker receives an isolated connection.
31
+
32
+ ## Test
33
+
34
+ ```ts
35
+ test("saves settings in a secondary window", async ({ hasgard }) => {
36
+ const settings = hasgard.window("settings")
37
+ await settings.getByRole("textbox", { name: "Display name" }).fill("Nyssance")
38
+ await settings.getByRole("button", { name: "Save", exact: true }).click()
39
+ await expect(settings.getByRole("status")).toHaveText("Saved")
40
+ })
41
+ ```
42
+
43
+ Use `window` for the configured primary window:
44
+
45
+ ```ts
46
+ test("opens preferences", async ({ window }) => {
47
+ await window.getByRole("button", { name: "Settings", exact: true }).click()
48
+ })
49
+ ```
50
+
51
+ ## Targets
52
+
53
+ - `window.locator(css)` sends a CSS selector directly.
54
+ - `window.getByRole(role, query)` takes a fresh accessibility snapshot, demands exactly one match for actions, then sends its snapshot ref.
55
+ - `byPoint(x, y)` and `byRef(ref)` are available for low-level calls.
56
+
57
+ Ambiguous semantic locators throw. Missing required configuration throws. There is no browser-mode fallback and no silent switch to a different window.
@@ -0,0 +1,2 @@
1
+ export declare function endpointPathForPlatform(name: string, platform: NodeJS.Platform, temporaryDirectory: string): string;
2
+ export declare function hasgardEndpointPath(name: string): string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { HasgardLocator } from "./window.js";
2
+ export declare function createHasgardExpect(playwrightExpect: typeof import("@playwright/test").expect): import("@playwright/test").Expect<{
3
+ toBeVisible(this: import("@playwright/test").ExpectMatcherState, locator: HasgardLocator, options?: {
4
+ timeout?: number;
5
+ }): Promise<{
6
+ pass: boolean;
7
+ message: () => string;
8
+ }>;
9
+ toHaveText(this: import("@playwright/test").ExpectMatcherState, locator: HasgardLocator, expected: string | RegExp, options?: {
10
+ timeout?: number;
11
+ }): Promise<{
12
+ pass: boolean;
13
+ message: () => string;
14
+ }>;
15
+ }>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ import type { HasgardFixtures, HasgardTestConfig, HasgardWorkerFixtures } from "./types.js";
2
+ export declare function createHasgardTest(config: HasgardTestConfig): {
3
+ test: import("@playwright/test").TestType<import("@playwright/test").PlaywrightTestArgs & import("@playwright/test").PlaywrightTestOptions & HasgardFixtures, import("@playwright/test").PlaywrightWorkerArgs & import("@playwright/test").PlaywrightWorkerOptions & HasgardWorkerFixtures>;
4
+ expect: import("@playwright/test").Expect<{
5
+ toBeVisible(this: import("@playwright/test").ExpectMatcherState, locator: import("./window.js").HasgardLocator, options?: {
6
+ timeout?: number;
7
+ }): Promise<{
8
+ pass: boolean;
9
+ message: () => string;
10
+ }>;
11
+ toHaveText(this: import("@playwright/test").ExpectMatcherState, locator: import("./window.js").HasgardLocator, expected: string | RegExp, options?: {
12
+ timeout?: number;
13
+ }): Promise<{
14
+ pass: boolean;
15
+ message: () => string;
16
+ }>;
17
+ }>;
18
+ };
@@ -0,0 +1,7 @@
1
+ export { createHasgardExpect } from "./expect.js";
2
+ export { hasgardEndpointPath } from "./endpoint.js";
3
+ export { createHasgardTest } from "./fixture.js";
4
+ export { HasgardProcess } from "./process-manager.js";
5
+ export { HasgardRpcClient, HasgardRpcError } from "./rpc-client.js";
6
+ export type { HasgardFixtures, HasgardLaunchConfig, HasgardTarget, HasgardTestConfig, HasgardWorkerFixtures, JsonPrimitive, JsonValue, RoleQuery, Snapshot, SnapshotElement, SnapshotOptions, WaitOptions, WindowInfo, WindowState } from "./types.js";
7
+ export { byPoint, byRef, bySelector, HasgardApplication, HasgardLocator, HasgardWindow } from "./window.js";
package/dist/index.js ADDED
@@ -0,0 +1,614 @@
1
+ // src/expect.ts
2
+ async function poll(read, matches, timeoutMs) {
3
+ const deadline = Date.now() + timeoutMs;
4
+ let value;
5
+ let error;
6
+ while (Date.now() <= deadline) {
7
+ try {
8
+ value = await read();
9
+ error = void 0;
10
+ if (matches(value)) return { pass: true, value, error };
11
+ } catch (caught) {
12
+ error = caught;
13
+ }
14
+ await new Promise((resolve) => setTimeout(resolve, 50));
15
+ }
16
+ return { pass: false, value, error };
17
+ }
18
+ function createHasgardExpect(playwrightExpect) {
19
+ return playwrightExpect.extend({
20
+ async toBeVisible(locator, options = {}) {
21
+ const timeout = options.timeout === void 0 ? 5e3 : options.timeout;
22
+ const result = await poll(
23
+ () => locator.isVisible(),
24
+ (visible) => this.isNot ? !visible : visible,
25
+ timeout
26
+ );
27
+ return {
28
+ pass: result.value === true,
29
+ message: () => this.isNot ? "expected Hasgard locator not to be visible" : `expected Hasgard locator to be visible within ${timeout}ms${result.error ? `: ${String(result.error)}` : ""}`
30
+ };
31
+ },
32
+ async toHaveText(locator, expected, options = {}) {
33
+ const timeout = options.timeout === void 0 ? 5e3 : options.timeout;
34
+ const matches = (text) => {
35
+ if (typeof expected === "string") return text === expected;
36
+ expected.lastIndex = 0;
37
+ return expected.test(text);
38
+ };
39
+ const result = await poll(
40
+ () => locator.textContent(),
41
+ (text) => this.isNot ? !matches(text) : matches(text),
42
+ timeout
43
+ );
44
+ return {
45
+ pass: result.value === void 0 ? false : matches(result.value),
46
+ message: () => this.isNot ? `expected Hasgard locator text not to match ${String(expected)}, received ${String(result.value)}` : `expected Hasgard locator text to match ${String(expected)}, received ${String(result.value)}`
47
+ };
48
+ }
49
+ });
50
+ }
51
+
52
+ // src/endpoint.ts
53
+ import { tmpdir } from "os";
54
+ import { join } from "path";
55
+ function endpointPathForPlatform(name, platform, temporaryDirectory) {
56
+ if (platform === "win32") return `\\\\.\\pipe\\${name}`;
57
+ return join(temporaryDirectory, `${name}.sock`);
58
+ }
59
+ function hasgardEndpointPath(name) {
60
+ return endpointPathForPlatform(name, process.platform, tmpdir());
61
+ }
62
+
63
+ // src/process-manager.ts
64
+ import { spawn } from "child_process";
65
+ import { access, rm } from "fs/promises";
66
+ import { createConnection } from "net";
67
+ var HasgardProcess = class {
68
+ child;
69
+ stdout = "";
70
+ stderr = "";
71
+ async start(config, socketPath) {
72
+ if (this.child) throw new Error("Hasgard app process is already running");
73
+ if (process.platform !== "win32") await rm(socketPath, { force: true });
74
+ const child = spawn(config.command, config.args, {
75
+ cwd: config.cwd,
76
+ env: { ...process.env, ...config.env, TAURI_HASGARD_SOCKET: socketPath },
77
+ stdio: ["ignore", "pipe", "pipe"],
78
+ detached: process.platform !== "win32"
79
+ });
80
+ this.child = child;
81
+ child.stdout?.on("data", (data) => {
82
+ this.stdout += data.toString();
83
+ });
84
+ child.stderr?.on("data", (data) => {
85
+ this.stderr += data.toString();
86
+ });
87
+ await new Promise((resolve, reject) => {
88
+ child.once("spawn", resolve);
89
+ child.once("error", reject);
90
+ });
91
+ try {
92
+ await this.waitForSocket(socketPath, config.timeoutMs);
93
+ } catch (error) {
94
+ await this.stop();
95
+ throw error;
96
+ }
97
+ }
98
+ async waitForSocket(socketPath, timeoutMs) {
99
+ const deadline = Date.now() + timeoutMs;
100
+ while (Date.now() <= deadline) {
101
+ if (this.child?.exitCode !== null && this.child?.exitCode !== void 0) {
102
+ throw new Error(
103
+ `Tauri process exited with code ${this.child.exitCode}
104
+ stdout:
105
+ ${this.stdout}
106
+ stderr:
107
+ ${this.stderr}`
108
+ );
109
+ }
110
+ if (process.platform === "win32") {
111
+ if (await namedPipeAcceptsConnections(socketPath)) return;
112
+ } else {
113
+ try {
114
+ await access(socketPath);
115
+ return;
116
+ } catch (error) {
117
+ const code = error.code;
118
+ if (code !== "ENOENT") throw error;
119
+ }
120
+ }
121
+ await new Promise((resolve) => setTimeout(resolve, 50));
122
+ }
123
+ throw new Error(`Hasgard socket did not appear within ${timeoutMs}ms: ${socketPath}`);
124
+ }
125
+ async stop() {
126
+ const child = this.child;
127
+ if (!child || child.exitCode !== null) return;
128
+ const exited = new Promise((resolve) => child.once("exit", () => resolve()));
129
+ if (process.platform === "win32" && child.pid !== void 0) {
130
+ await terminateWindowsProcessTree(child.pid);
131
+ } else if (child.pid !== void 0) {
132
+ process.kill(-child.pid, "SIGTERM");
133
+ }
134
+ const timeout = new Promise((resolve) => setTimeout(() => resolve("timeout"), 5e3));
135
+ if (await Promise.race([exited, timeout]) === "timeout") {
136
+ if (process.platform === "win32" && child.pid !== void 0) await terminateWindowsProcessTree(child.pid);
137
+ else if (child.pid !== void 0) process.kill(-child.pid, "SIGKILL");
138
+ await exited;
139
+ }
140
+ this.child = void 0;
141
+ }
142
+ };
143
+ async function namedPipeAcceptsConnections(path) {
144
+ return new Promise((resolve, reject) => {
145
+ const socket = createConnection({ path });
146
+ socket.once("connect", () => {
147
+ socket.destroy();
148
+ resolve(true);
149
+ });
150
+ socket.once("error", (error) => {
151
+ const code = error.code;
152
+ if (code === "ENOENT" || code === "ECONNREFUSED" || code === "EBUSY") {
153
+ resolve(false);
154
+ return;
155
+ }
156
+ reject(error);
157
+ });
158
+ });
159
+ }
160
+ async function terminateWindowsProcessTree(pid) {
161
+ const taskkill = spawn("taskkill", ["/PID", String(pid), "/T", "/F"], { stdio: "ignore" });
162
+ await new Promise((resolve, reject) => {
163
+ taskkill.once("exit", () => resolve());
164
+ taskkill.once("error", reject);
165
+ });
166
+ }
167
+
168
+ // src/rpc-client.ts
169
+ import { createConnection as createConnection2 } from "net";
170
+ import { createInterface } from "readline";
171
+ var HasgardRpcError = class extends Error {
172
+ code;
173
+ data;
174
+ constructor(code, message, data) {
175
+ super(`Hasgard RPC ${code}: ${message}`);
176
+ this.name = "HasgardRpcError";
177
+ this.code = code;
178
+ this.data = data;
179
+ }
180
+ };
181
+ var HasgardRpcClient = class {
182
+ socketPath;
183
+ socket;
184
+ lines;
185
+ nextId = 1;
186
+ pending = /* @__PURE__ */ new Map();
187
+ constructor(socketPath) {
188
+ this.socketPath = socketPath;
189
+ }
190
+ async connect(timeoutMs) {
191
+ if (this.socket) throw new Error("Hasgard RPC client is already connected");
192
+ const socket = createConnection2({ path: this.socketPath });
193
+ this.socket = socket;
194
+ await new Promise((resolve, reject) => {
195
+ const timeout = setTimeout(() => {
196
+ socket.destroy();
197
+ reject(new Error(`Hasgard socket connection timed out after ${timeoutMs}ms: ${this.socketPath}`));
198
+ }, timeoutMs);
199
+ socket.once("connect", () => {
200
+ clearTimeout(timeout);
201
+ resolve();
202
+ });
203
+ socket.once("error", (error) => {
204
+ clearTimeout(timeout);
205
+ reject(error);
206
+ });
207
+ });
208
+ this.lines = createInterface({ input: socket });
209
+ this.lines.on("line", (line) => this.handleLine(line));
210
+ socket.on("close", () => this.rejectPending(new Error("Hasgard socket closed")));
211
+ socket.on("error", (error) => this.rejectPending(error));
212
+ }
213
+ async call(method, params) {
214
+ const socket = this.socket;
215
+ if (!socket) throw new Error("Hasgard RPC client is not connected");
216
+ const id = this.nextId;
217
+ this.nextId += 1;
218
+ const request = params ? { jsonrpc: "2.0", id, method, params } : { jsonrpc: "2.0", id, method };
219
+ const result = new Promise((resolve, reject) => {
220
+ this.pending.set(id, {
221
+ resolve: (value) => resolve(value),
222
+ reject
223
+ });
224
+ });
225
+ socket.write(`${JSON.stringify(request)}
226
+ `, (error) => {
227
+ if (!error) return;
228
+ const pending = this.pending.get(id);
229
+ if (!pending) return;
230
+ this.pending.delete(id);
231
+ pending.reject(error);
232
+ });
233
+ return result;
234
+ }
235
+ disconnect() {
236
+ this.lines?.close();
237
+ this.lines = void 0;
238
+ this.socket?.destroy();
239
+ this.socket = void 0;
240
+ this.rejectPending(new Error("Hasgard RPC client disconnected"));
241
+ }
242
+ handleLine(line) {
243
+ let response;
244
+ try {
245
+ response = JSON.parse(line);
246
+ } catch {
247
+ this.rejectPending(new Error(`Invalid Hasgard JSON-RPC response: ${line}`));
248
+ return;
249
+ }
250
+ if (response.jsonrpc !== "2.0" || !Number.isInteger(response.id)) {
251
+ this.rejectPending(new Error(`Invalid Hasgard JSON-RPC envelope: ${line}`));
252
+ return;
253
+ }
254
+ const pending = this.pending.get(response.id);
255
+ if (!pending) {
256
+ this.rejectPending(new Error(`Unexpected Hasgard JSON-RPC response id: ${response.id}`));
257
+ return;
258
+ }
259
+ this.pending.delete(response.id);
260
+ if ("error" in response) {
261
+ pending.reject(new HasgardRpcError(response.error.code, response.error.message, response.error.data));
262
+ return;
263
+ }
264
+ pending.resolve(response.result);
265
+ }
266
+ rejectPending(error) {
267
+ for (const pending of this.pending.values()) pending.reject(error);
268
+ this.pending.clear();
269
+ }
270
+ };
271
+
272
+ // src/window.ts
273
+ var locks = /* @__PURE__ */ new WeakMap();
274
+ function lockFor(rpc, label) {
275
+ let clientLocks = locks.get(rpc);
276
+ if (!clientLocks) {
277
+ clientLocks = /* @__PURE__ */ new Map();
278
+ locks.set(rpc, clientLocks);
279
+ }
280
+ let lock = clientLocks.get(label);
281
+ if (!lock) {
282
+ lock = { tail: Promise.resolve() };
283
+ clientLocks.set(label, lock);
284
+ }
285
+ return lock;
286
+ }
287
+ var byRef = (ref) => ({ ref });
288
+ var bySelector = (selector) => ({ selector });
289
+ var byPoint = (x, y) => ({ x, y });
290
+ function withWindow(window, params) {
291
+ return params ? { ...params, window } : { window };
292
+ }
293
+ function targetParams(target) {
294
+ if ("ref" in target) return { ref: target.ref };
295
+ if ("selector" in target) return { selector: target.selector };
296
+ return { x: target.x, y: target.y };
297
+ }
298
+ function expectRecord(value, context) {
299
+ if (typeof value !== "object" || value === null || Array.isArray(value)) {
300
+ throw new Error(`${context} must be an object`);
301
+ }
302
+ return value;
303
+ }
304
+ function expectString(value, context) {
305
+ if (typeof value !== "string") throw new Error(`${context} must be a string`);
306
+ return value;
307
+ }
308
+ function expectBoolean(value, context) {
309
+ if (typeof value !== "boolean") throw new Error(`${context} must be a boolean`);
310
+ return value;
311
+ }
312
+ function expectNumber(value, context) {
313
+ if (typeof value !== "number") throw new Error(`${context} must be a number`);
314
+ return value;
315
+ }
316
+ var HasgardApplication = class {
317
+ rpc;
318
+ constructor(rpc) {
319
+ this.rpc = rpc;
320
+ }
321
+ async ping() {
322
+ const value = expectRecord(await this.rpc.call("ping"), "ping result");
323
+ return {
324
+ status: expectString(value.status, "ping.status"),
325
+ plugin_version: expectString(value.plugin_version, "ping.plugin_version")
326
+ };
327
+ }
328
+ async windows() {
329
+ const value = expectRecord(await this.rpc.call("windows.list"), "windows.list result");
330
+ if (!Array.isArray(value.windows)) throw new Error("windows.list.windows must be an array");
331
+ return value.windows.map((entry, index) => {
332
+ const window = expectRecord(entry, `windows[${index}]`);
333
+ return {
334
+ label: expectString(window.label, `windows[${index}].label`),
335
+ url: expectString(window.url, `windows[${index}].url`),
336
+ title: expectString(window.title, `windows[${index}].title`)
337
+ };
338
+ });
339
+ }
340
+ async waitForWindow(label, timeoutMs) {
341
+ const deadline = Date.now() + timeoutMs;
342
+ while (Date.now() <= deadline) {
343
+ if ((await this.windows()).some((window) => window.label === label)) {
344
+ const window = this.window(label);
345
+ const state = await window.state();
346
+ if (state.url !== "about:blank" && state.readyState !== "loading") {
347
+ return window;
348
+ }
349
+ }
350
+ await new Promise((resolve) => setTimeout(resolve, 50));
351
+ }
352
+ throw new Error(`Window '${label}' did not finish loading within ${timeoutMs}ms`);
353
+ }
354
+ async waitForWindowReady(label, readySelector, timeoutMs) {
355
+ const window = await this.waitForWindow(label, timeoutMs);
356
+ const deadline = Date.now() + timeoutMs;
357
+ while (Date.now() <= deadline) {
358
+ if (await window.locator(readySelector).count() === 1) return window;
359
+ await new Promise((resolve) => setTimeout(resolve, 50));
360
+ }
361
+ throw new Error(`Window '${label}' did not match ready selector '${readySelector}' within ${timeoutMs}ms`);
362
+ }
363
+ window(label) {
364
+ return new HasgardWindow(this.rpc, label);
365
+ }
366
+ };
367
+ var HasgardWindow = class {
368
+ label;
369
+ rpc;
370
+ constructor(rpc, label) {
371
+ this.rpc = rpc;
372
+ this.label = label;
373
+ }
374
+ locator(selector) {
375
+ return new HasgardLocator(this, { kind: "selector", selector });
376
+ }
377
+ getByRole(role, query = {}) {
378
+ return new HasgardLocator(this, { kind: "role", role, query });
379
+ }
380
+ async snapshot(options = {}) {
381
+ const raw = expectRecord(
382
+ await this.rpc.call("snapshot", withWindow(this.label, options)),
383
+ "snapshot result"
384
+ );
385
+ if (!Array.isArray(raw.elements)) throw new Error("snapshot.elements must be an array");
386
+ return {
387
+ elements: raw.elements.map((entry, index) => parseSnapshotElement(entry, index))
388
+ };
389
+ }
390
+ async state() {
391
+ const value = expectRecord(await this.rpc.call("state", withWindow(this.label)), "state result");
392
+ const viewport = expectRecord(value.viewport, "state.viewport");
393
+ const scroll = expectRecord(value.scroll, "state.scroll");
394
+ return {
395
+ url: expectString(value.url, "state.url"),
396
+ title: expectString(value.title, "state.title"),
397
+ readyState: expectString(value.readyState, "state.readyState"),
398
+ viewport: {
399
+ width: expectNumber(viewport.width, "state.viewport.width"),
400
+ height: expectNumber(viewport.height, "state.viewport.height")
401
+ },
402
+ scroll: {
403
+ x: expectNumber(scroll.x, "state.scroll.x"),
404
+ y: expectNumber(scroll.y, "state.scroll.y")
405
+ },
406
+ plugin_version: expectString(value.plugin_version, "state.plugin_version")
407
+ };
408
+ }
409
+ async press(key) {
410
+ await this.rpc.call("press", withWindow(this.label, { key }));
411
+ }
412
+ async evaluate(script) {
413
+ return this.rpc.call("eval", withWindow(this.label, { script }));
414
+ }
415
+ async invoke(command, args) {
416
+ return this.rpc.call("ipc", withWindow(this.label, { command, args }));
417
+ }
418
+ async screenshot(selector) {
419
+ const params = selector ? { selector } : void 0;
420
+ const dataUrl = await this.rpc.call("screenshot", withWindow(this.label, params));
421
+ const prefix = "data:image/png;base64,";
422
+ if (!dataUrl.startsWith(prefix)) throw new Error("screenshot result is not a PNG data URL");
423
+ return Buffer.from(dataUrl.slice(prefix.length), "base64");
424
+ }
425
+ async call(method, params) {
426
+ return this.rpc.call(method, withWindow(this.label, params));
427
+ }
428
+ async runExclusive(operation) {
429
+ const lock = lockFor(this.rpc, this.label);
430
+ const previous = lock.tail;
431
+ let release;
432
+ const gate = new Promise((resolve) => {
433
+ release = resolve;
434
+ });
435
+ lock.tail = previous.then(() => gate);
436
+ await previous;
437
+ try {
438
+ return await operation();
439
+ } finally {
440
+ release();
441
+ }
442
+ }
443
+ };
444
+ var HasgardLocator = class {
445
+ window;
446
+ query;
447
+ constructor(window, query) {
448
+ this.window = window;
449
+ this.query = query;
450
+ }
451
+ async click() {
452
+ await this.withTarget((target) => this.window.call("click", targetParams(target)));
453
+ }
454
+ async fill(value) {
455
+ await this.withTarget((target) => this.window.call("fill", { ...targetParams(target), value }));
456
+ }
457
+ async type(text) {
458
+ await this.withTarget((target) => this.window.call("type", { ...targetParams(target), text }));
459
+ }
460
+ async selectOption(value) {
461
+ await this.withTarget((target) => this.window.call("select", { ...targetParams(target), value }));
462
+ }
463
+ async check() {
464
+ await this.withTarget((target) => this.window.call("check", targetParams(target)));
465
+ }
466
+ async textContent() {
467
+ return this.withTarget(
468
+ async (target) => expectString(await this.window.call("text", targetParams(target)), "text result")
469
+ );
470
+ }
471
+ async inputValue() {
472
+ return this.withTarget(
473
+ async (target) => expectString(await this.window.call("value", targetParams(target)), "value result")
474
+ );
475
+ }
476
+ async attributes() {
477
+ return this.withTarget(async (target) => {
478
+ const value = expectRecord(await this.window.call("attrs", targetParams(target)), "attrs result");
479
+ return Object.fromEntries(
480
+ Object.entries(value).map(([name, attr]) => [name, expectString(attr, `attribute ${name}`)])
481
+ );
482
+ });
483
+ }
484
+ async isVisible() {
485
+ return this.withTarget(async (target) => {
486
+ const value = expectRecord(await this.window.call("visible", targetParams(target)), "visible result");
487
+ return expectBoolean(value.visible, "visible.visible");
488
+ });
489
+ }
490
+ async isChecked() {
491
+ return this.withTarget(async (target) => {
492
+ const value = expectRecord(await this.window.call("checked", targetParams(target)), "checked result");
493
+ return expectBoolean(value.checked, "checked.checked");
494
+ });
495
+ }
496
+ async count() {
497
+ if (this.query.kind === "role") return (await this.resolveAll()).length;
498
+ const value = expectRecord(await this.window.call("count", { selector: this.query.selector }), "count result");
499
+ return expectNumber(value.count, "count.count");
500
+ }
501
+ async waitFor(options) {
502
+ if (this.query.kind === "selector") {
503
+ await this.window.call("wait", {
504
+ selector: this.query.selector,
505
+ gone: options.state === "detached",
506
+ timeout: options.timeoutMs
507
+ });
508
+ return;
509
+ }
510
+ const deadline = Date.now() + options.timeoutMs;
511
+ while (Date.now() <= deadline) {
512
+ const found = (await this.resolveAll()).length > 0;
513
+ if (found === (options.state === "attached")) return;
514
+ await new Promise((resolve) => setTimeout(resolve, 50));
515
+ }
516
+ throw new Error(`Role locator did not become ${options.state} within ${options.timeoutMs}ms`);
517
+ }
518
+ async resolveUnique() {
519
+ if (this.query.kind === "selector") return bySelector(this.query.selector);
520
+ const elements = await this.resolveAll();
521
+ if (elements.length !== 1) {
522
+ throw new Error(`Role locator resolved to ${elements.length} elements; expected exactly one`);
523
+ }
524
+ return byRef(elements[0].ref);
525
+ }
526
+ async withTarget(operation) {
527
+ return this.window.runExclusive(async () => operation(await this.resolveUnique()));
528
+ }
529
+ async resolveAll() {
530
+ if (this.query.kind === "selector") {
531
+ throw new Error("resolveAll is only valid for role locators");
532
+ }
533
+ const query = this.query;
534
+ const snapshot = await this.window.snapshot();
535
+ return snapshot.elements.filter((element) => {
536
+ if (element.role !== query.role) return false;
537
+ const expected = query.query.name;
538
+ if (expected === void 0) return true;
539
+ if (element.name === void 0) return false;
540
+ if (expected instanceof RegExp) return expected.test(element.name);
541
+ return query.query.exact ? element.name === expected : element.name.includes(expected);
542
+ });
543
+ }
544
+ };
545
+ function parseSnapshotElement(value, index) {
546
+ const entry = expectRecord(value, `snapshot.elements[${index}]`);
547
+ const element = {
548
+ ref: expectString(entry.ref, `snapshot.elements[${index}].ref`),
549
+ role: expectString(entry.role, `snapshot.elements[${index}].role`),
550
+ depth: expectNumber(entry.depth, `snapshot.elements[${index}].depth`)
551
+ };
552
+ if (entry.name !== void 0) element.name = expectString(entry.name, `snapshot.elements[${index}].name`);
553
+ if (entry.value !== void 0) element.value = expectString(entry.value, `snapshot.elements[${index}].value`);
554
+ if (entry.checked !== void 0) element.checked = expectBoolean(entry.checked, `snapshot.elements[${index}].checked`);
555
+ if (entry.disabled !== void 0)
556
+ element.disabled = expectBoolean(entry.disabled, `snapshot.elements[${index}].disabled`);
557
+ return element;
558
+ }
559
+
560
+ // src/fixture.ts
561
+ function createHasgardTest(config) {
562
+ const base = config.test;
563
+ const expect = createHasgardExpect(config.expect);
564
+ const readinessTimeoutMs = config.launch ? config.launch.timeoutMs : 3e4;
565
+ const fixtureTimeoutMs = config.launch ? config.launch.timeoutMs + 3e4 : 3e4;
566
+ const test = base.extend({
567
+ hasgard: [
568
+ async ({}, use, workerInfo) => {
569
+ const socketPath = typeof config.socketPath === "function" ? config.socketPath(workerInfo.workerIndex) : config.socketPath;
570
+ const process2 = new HasgardProcess();
571
+ const rpc = new HasgardRpcClient(socketPath);
572
+ try {
573
+ if (config.launch) await process2.start(config.launch, socketPath);
574
+ else await process2.waitForSocket(socketPath, workerInfo.project.timeout);
575
+ await rpc.connect(workerInfo.project.timeout);
576
+ const hasgard = new HasgardApplication(rpc);
577
+ const ping = await hasgard.ping();
578
+ if (ping.status !== "ok") throw new Error(`Unexpected Hasgard ping status: ${ping.status}`);
579
+ await hasgard.waitForWindowReady(config.windowLabel, config.readySelector, readinessTimeoutMs);
580
+ await use(hasgard);
581
+ } finally {
582
+ rpc.disconnect();
583
+ await process2.stop();
584
+ }
585
+ },
586
+ { scope: "worker", timeout: fixtureTimeoutMs }
587
+ ],
588
+ window: async ({ hasgard }, use, testInfo) => {
589
+ await use(hasgard.window(config.windowLabel));
590
+ if (testInfo.status !== testInfo.expectedStatus) {
591
+ const screenshot = await hasgard.window(config.windowLabel).screenshot();
592
+ await testInfo.attach("hasgard-screenshot", {
593
+ body: screenshot,
594
+ contentType: "image/png"
595
+ });
596
+ }
597
+ }
598
+ });
599
+ return { test, expect };
600
+ }
601
+ export {
602
+ HasgardApplication,
603
+ HasgardLocator,
604
+ HasgardProcess,
605
+ HasgardRpcClient,
606
+ HasgardRpcError,
607
+ HasgardWindow,
608
+ byPoint,
609
+ byRef,
610
+ bySelector,
611
+ createHasgardExpect,
612
+ createHasgardTest,
613
+ hasgardEndpointPath
614
+ };
@@ -0,0 +1,9 @@
1
+ import type { HasgardLaunchConfig } from "./types.js";
2
+ export declare class HasgardProcess {
3
+ private child;
4
+ private stdout;
5
+ private stderr;
6
+ start(config: HasgardLaunchConfig, socketPath: string): Promise<void>;
7
+ waitForSocket(socketPath: string, timeoutMs: number): Promise<void>;
8
+ stop(): Promise<void>;
9
+ }
@@ -0,0 +1,19 @@
1
+ import type { JsonValue } from "./types.js";
2
+ export declare class HasgardRpcError extends Error {
3
+ readonly code: number;
4
+ readonly data: JsonValue | undefined;
5
+ constructor(code: number, message: string, data: JsonValue | undefined);
6
+ }
7
+ export declare class HasgardRpcClient {
8
+ readonly socketPath: string;
9
+ private socket;
10
+ private lines;
11
+ private nextId;
12
+ private readonly pending;
13
+ constructor(socketPath: string);
14
+ connect(timeoutMs: number): Promise<void>;
15
+ call<T>(method: string, params?: Record<string, JsonValue>): Promise<T>;
16
+ disconnect(): void;
17
+ private handleLine;
18
+ private rejectPending;
19
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,77 @@
1
+ export type JsonPrimitive = boolean | number | string | null;
2
+ export type JsonValue = JsonPrimitive | JsonValue[] | {
3
+ [key: string]: JsonValue;
4
+ };
5
+ export type HasgardTarget = {
6
+ ref: string;
7
+ } | {
8
+ selector: string;
9
+ } | {
10
+ x: number;
11
+ y: number;
12
+ };
13
+ export interface SnapshotElement {
14
+ ref: string;
15
+ role: string;
16
+ depth: number;
17
+ name?: string;
18
+ value?: string;
19
+ checked?: boolean;
20
+ disabled?: boolean;
21
+ }
22
+ export interface Snapshot {
23
+ elements: SnapshotElement[];
24
+ }
25
+ export interface SnapshotOptions {
26
+ interactive?: boolean;
27
+ selector?: string;
28
+ depth?: number;
29
+ }
30
+ export interface WindowInfo {
31
+ label: string;
32
+ url: string;
33
+ title: string;
34
+ }
35
+ export interface WindowState {
36
+ url: string;
37
+ title: string;
38
+ readyState: string;
39
+ viewport: {
40
+ width: number;
41
+ height: number;
42
+ };
43
+ scroll: {
44
+ x: number;
45
+ y: number;
46
+ };
47
+ plugin_version: string;
48
+ }
49
+ export interface RoleQuery {
50
+ name?: string | RegExp;
51
+ exact?: boolean;
52
+ }
53
+ export interface WaitOptions {
54
+ state: "attached" | "detached";
55
+ timeoutMs: number;
56
+ }
57
+ export interface HasgardLaunchConfig {
58
+ command: string;
59
+ args: string[];
60
+ cwd: string;
61
+ timeoutMs: number;
62
+ env?: NodeJS.ProcessEnv;
63
+ }
64
+ export interface HasgardTestConfig {
65
+ test: typeof import("@playwright/test").test;
66
+ expect: typeof import("@playwright/test").expect;
67
+ socketPath: string | ((workerIndex: number) => string);
68
+ windowLabel: string;
69
+ readySelector: string;
70
+ launch?: HasgardLaunchConfig;
71
+ }
72
+ export interface HasgardFixtures {
73
+ window: import("./window.js").HasgardWindow;
74
+ }
75
+ export interface HasgardWorkerFixtures {
76
+ hasgard: import("./window.js").HasgardApplication;
77
+ }
@@ -0,0 +1,61 @@
1
+ import { HasgardRpcClient } from "./rpc-client.js";
2
+ import type { HasgardTarget, JsonValue, RoleQuery, Snapshot, SnapshotOptions, WaitOptions, WindowInfo, WindowState } from "./types.js";
3
+ export declare const byRef: (ref: string) => HasgardTarget;
4
+ export declare const bySelector: (selector: string) => HasgardTarget;
5
+ export declare const byPoint: (x: number, y: number) => HasgardTarget;
6
+ export declare class HasgardApplication {
7
+ readonly rpc: HasgardRpcClient;
8
+ constructor(rpc: HasgardRpcClient);
9
+ ping(): Promise<{
10
+ status: string;
11
+ plugin_version: string;
12
+ }>;
13
+ windows(): Promise<WindowInfo[]>;
14
+ waitForWindow(label: string, timeoutMs: number): Promise<HasgardWindow>;
15
+ waitForWindowReady(label: string, readySelector: string, timeoutMs: number): Promise<HasgardWindow>;
16
+ window(label: string): HasgardWindow;
17
+ }
18
+ export declare class HasgardWindow {
19
+ readonly label: string;
20
+ private readonly rpc;
21
+ constructor(rpc: HasgardRpcClient, label: string);
22
+ locator(selector: string): HasgardLocator;
23
+ getByRole(role: string, query?: RoleQuery): HasgardLocator;
24
+ snapshot(options?: SnapshotOptions): Promise<Snapshot>;
25
+ state(): Promise<WindowState>;
26
+ press(key: string): Promise<void>;
27
+ evaluate<T>(script: string): Promise<T>;
28
+ invoke<T>(command: string, args: Record<string, JsonValue>): Promise<T>;
29
+ screenshot(selector?: string): Promise<Buffer>;
30
+ call<T>(method: string, params?: Record<string, JsonValue>): Promise<T>;
31
+ runExclusive<T>(operation: () => Promise<T>): Promise<T>;
32
+ }
33
+ type LocatorQuery = {
34
+ kind: "selector";
35
+ selector: string;
36
+ } | {
37
+ kind: "role";
38
+ role: string;
39
+ query: RoleQuery;
40
+ };
41
+ export declare class HasgardLocator {
42
+ readonly window: HasgardWindow;
43
+ private readonly query;
44
+ constructor(window: HasgardWindow, query: LocatorQuery);
45
+ click(): Promise<void>;
46
+ fill(value: string): Promise<void>;
47
+ type(text: string): Promise<void>;
48
+ selectOption(value: string): Promise<void>;
49
+ check(): Promise<void>;
50
+ textContent(): Promise<string>;
51
+ inputValue(): Promise<string>;
52
+ attributes(): Promise<Record<string, string>>;
53
+ isVisible(): Promise<boolean>;
54
+ isChecked(): Promise<boolean>;
55
+ count(): Promise<number>;
56
+ waitFor(options: WaitOptions): Promise<void>;
57
+ private resolveUnique;
58
+ private withTarget;
59
+ private resolveAll;
60
+ }
61
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@nyssance/tauri-hasgard",
3
+ "version": "0.1.0",
4
+ "description": "Playwright Test fixtures for native Tauri Hasgard automation",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "README.md",
17
+ "LICENSE",
18
+ "NOTICE.md"
19
+ ],
20
+ "scripts": {
21
+ "build": "bun node_modules/tsup/dist/cli-default.js src/index.ts --format esm --outDir dist --clean && bun node_modules/typescript/bin/tsc -p tsconfig.json --noEmit false --emitDeclarationOnly --declaration true",
22
+ "dev": "tsup src/index.ts --format esm --dts --outDir dist --watch",
23
+ "test": "vitest run",
24
+ "test:watch": "vitest",
25
+ "typecheck": "tsc --noEmit",
26
+ "clean": "rm -rf dist"
27
+ },
28
+ "peerDependencies": {
29
+ "@playwright/test": ">=1.61.1 <2"
30
+ },
31
+ "devDependencies": {
32
+ "@playwright/test": "1.62.1",
33
+ "@types/node": "^26.1.0",
34
+ "tsup": "^8.5.1",
35
+ "typescript": "^7.0.2",
36
+ "vitest": "^4.1.10"
37
+ },
38
+ "keywords": [
39
+ "tauri",
40
+ "playwright",
41
+ "e2e",
42
+ "testing",
43
+ "desktop",
44
+ "webview"
45
+ ],
46
+ "license": "Apache-2.0",
47
+ "homepage": "https://github.com/nyssance/tauri-hasgard",
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "https://github.com/nyssance/tauri-hasgard"
51
+ },
52
+ "engines": {
53
+ "node": ">=20"
54
+ }
55
+ }