@melra/browser-runtime 0.3.0-alpha.11 → 0.3.0-alpha.12

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.
Files changed (56) hide show
  1. package/dist/bounded.d.ts +27 -0
  2. package/dist/bounded.d.ts.map +1 -0
  3. package/dist/bounded.js +50 -0
  4. package/dist/bounded.js.map +1 -0
  5. package/dist/browser-connection.d.ts.map +1 -1
  6. package/dist/browser-connection.js +22 -7
  7. package/dist/browser-connection.js.map +1 -1
  8. package/dist/index.d.ts +71 -1
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +302 -50
  11. package/dist/index.js.map +1 -1
  12. package/dist/stable-dom.d.ts +13 -1
  13. package/dist/stable-dom.d.ts.map +1 -1
  14. package/dist/stable-dom.js +22 -3
  15. package/dist/stable-dom.js.map +1 -1
  16. package/package.json +6 -6
  17. package/dist/browser-connection.test.d.ts +0 -2
  18. package/dist/browser-connection.test.d.ts.map +0 -1
  19. package/dist/browser-connection.test.js +0 -210
  20. package/dist/browser-connection.test.js.map +0 -1
  21. package/dist/dialogs.test.d.ts +0 -2
  22. package/dist/dialogs.test.d.ts.map +0 -1
  23. package/dist/dialogs.test.js +0 -165
  24. package/dist/dialogs.test.js.map +0 -1
  25. package/dist/frames.test.d.ts +0 -2
  26. package/dist/frames.test.d.ts.map +0 -1
  27. package/dist/frames.test.js +0 -157
  28. package/dist/frames.test.js.map +0 -1
  29. package/dist/history-tabs.test.d.ts +0 -2
  30. package/dist/history-tabs.test.d.ts.map +0 -1
  31. package/dist/history-tabs.test.js +0 -176
  32. package/dist/history-tabs.test.js.map +0 -1
  33. package/dist/input-fidelity.test.d.ts +0 -2
  34. package/dist/input-fidelity.test.d.ts.map +0 -1
  35. package/dist/input-fidelity.test.js +0 -260
  36. package/dist/input-fidelity.test.js.map +0 -1
  37. package/dist/pinning-proxy.test.d.ts +0 -2
  38. package/dist/pinning-proxy.test.d.ts.map +0 -1
  39. package/dist/pinning-proxy.test.js +0 -80
  40. package/dist/pinning-proxy.test.js.map +0 -1
  41. package/dist/popups-profile.test.d.ts +0 -2
  42. package/dist/popups-profile.test.d.ts.map +0 -1
  43. package/dist/popups-profile.test.js +0 -170
  44. package/dist/popups-profile.test.js.map +0 -1
  45. package/dist/see-act.test.d.ts +0 -2
  46. package/dist/see-act.test.d.ts.map +0 -1
  47. package/dist/see-act.test.js +0 -152
  48. package/dist/see-act.test.js.map +0 -1
  49. package/dist/selector.test.d.ts +0 -2
  50. package/dist/selector.test.d.ts.map +0 -1
  51. package/dist/selector.test.js +0 -34
  52. package/dist/selector.test.js.map +0 -1
  53. package/dist/stable-dom.test.d.ts +0 -2
  54. package/dist/stable-dom.test.d.ts.map +0 -1
  55. package/dist/stable-dom.test.js +0 -22
  56. package/dist/stable-dom.test.js.map +0 -1
@@ -0,0 +1,27 @@
1
+ /**
2
+ * A browser call that did not answer within its bound.
3
+ *
4
+ * Its own type so the code that swallows a detached frame or a closed page can
5
+ * tell "this went away" from "this stopped answering" — the second is never an
6
+ * answer, and treating it as one would hide a wedged renderer behind a
7
+ * plausible empty result.
8
+ */
9
+ export declare class BrowserCallTimeoutError extends Error {
10
+ constructor(what: string);
11
+ }
12
+ /**
13
+ * Settle with `call`, or fail once `ms` passes or `signal` aborts.
14
+ *
15
+ * Several Playwright calls — `title()`, `evaluate()`, `count()`, `close()`, a
16
+ * CDP `send` — take no timeout of their own, so a renderer that stopped
17
+ * answering held the action until the task budget ran out, or forever where no
18
+ * budget was armed. The call itself cannot be cancelled; it is left to finish
19
+ * or not, and its eventual rejection is consumed here rather than surfacing as
20
+ * an unhandled one. The timer and the abort listener are both released the
21
+ * moment either side wins, so nothing is left holding the process open.
22
+ *
23
+ * `ms` may be `Infinity` for a call whose only legitimate bound is the task's
24
+ * own budget.
25
+ */
26
+ export declare function bounded<T>(call: Promise<T>, ms: number, what: string, signal?: AbortSignal): Promise<T>;
27
+ //# sourceMappingURL=bounded.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bounded.d.ts","sourceRoot":"","sources":["../src/bounded.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;gBACpC,IAAI,EAAE,MAAM;CAIzB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,CAAC,EACvB,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,EAChB,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,CAAC,CAAC,CAoBZ"}
@@ -0,0 +1,50 @@
1
+ // Copyright 2026 XAGI Labs Private Limited
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ /**
4
+ * A browser call that did not answer within its bound.
5
+ *
6
+ * Its own type so the code that swallows a detached frame or a closed page can
7
+ * tell "this went away" from "this stopped answering" — the second is never an
8
+ * answer, and treating it as one would hide a wedged renderer behind a
9
+ * plausible empty result.
10
+ */
11
+ export class BrowserCallTimeoutError extends Error {
12
+ constructor(what) {
13
+ super(`browser_call_timeout:${what}`);
14
+ this.name = "BrowserCallTimeoutError";
15
+ }
16
+ }
17
+ /**
18
+ * Settle with `call`, or fail once `ms` passes or `signal` aborts.
19
+ *
20
+ * Several Playwright calls — `title()`, `evaluate()`, `count()`, `close()`, a
21
+ * CDP `send` — take no timeout of their own, so a renderer that stopped
22
+ * answering held the action until the task budget ran out, or forever where no
23
+ * budget was armed. The call itself cannot be cancelled; it is left to finish
24
+ * or not, and its eventual rejection is consumed here rather than surfacing as
25
+ * an unhandled one. The timer and the abort listener are both released the
26
+ * moment either side wins, so nothing is left holding the process open.
27
+ *
28
+ * `ms` may be `Infinity` for a call whose only legitimate bound is the task's
29
+ * own budget.
30
+ */
31
+ export function bounded(call, ms, what, signal) {
32
+ return new Promise((resolve, reject) => {
33
+ const finish = (settle) => {
34
+ clearTimeout(timer);
35
+ signal?.removeEventListener("abort", aborted);
36
+ settle();
37
+ };
38
+ const aborted = () => {
39
+ finish(() => reject(signal?.reason ?? new Error("task_cancelled")));
40
+ };
41
+ const timer = Number.isFinite(ms)
42
+ ? setTimeout(() => finish(() => reject(new BrowserCallTimeoutError(what))), ms)
43
+ : undefined;
44
+ signal?.addEventListener("abort", aborted, { once: true });
45
+ call.then((value) => finish(() => resolve(value)), (error) => finish(() => reject(error)));
46
+ if (signal?.aborted === true)
47
+ aborted();
48
+ });
49
+ }
50
+ //# sourceMappingURL=bounded.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bounded.js","sourceRoot":"","sources":["../src/bounded.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,sCAAsC;AAEtC;;;;;;;GAOG;AACH,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAChD,YAAY,IAAY;QACtB,KAAK,CAAC,wBAAwB,IAAI,EAAE,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,OAAO,CACrB,IAAgB,EAChB,EAAU,EACV,IAAY,EACZ,MAAoB;IAEpB,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACxC,MAAM,MAAM,GAAG,CAAC,MAAkB,EAAE,EAAE;YACpC,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC9C,MAAM,EAAE,CAAC;QACX,CAAC,CAAC;QACF,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,MAAM,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,IAAI,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;QACtE,CAAC,CAAC;QACF,MAAM,KAAK,GAAG,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/B,CAAC,CAAC,UAAU,CAAC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AAM,GAAG,SAAS,CAAC,CAU3E;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,iBAAiB,CAAC,CAkF5B"}
1
+ {"version":3,"file":"browser-connection.d.ts","sourceRoot":"","sources":["../src/browser-connection.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AA+B/D,MAAM,WAAW,wBAAwB;IACvC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,cAAc,CAAC;IACxB,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,wBAAsB,uBAAuB,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAU3E;AAED,wBAAsB,cAAc,CAClC,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,iBAAiB,CAAC,CA+F5B"}
@@ -3,6 +3,13 @@
3
3
  import { constants } from "node:fs";
4
4
  import { access } from "node:fs/promises";
5
5
  import { chromium } from "playwright-core";
6
+ import { bounded } from "./bounded.js";
7
+ /**
8
+ * Bound on creating the first context in a browser MELRA just launched. Matches
9
+ * Playwright's default action timeout; a fresh browser that cannot open a
10
+ * context in that long is not going to.
11
+ */
12
+ const NEW_CONTEXT_TIMEOUT_MS = 30_000;
6
13
  const CHROME_PATHS = {
7
14
  darwin: [
8
15
  "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
@@ -107,13 +114,21 @@ export async function connectBrowser(options) {
107
114
  throw new Error("browser_persistent_profile_unavailable");
108
115
  return { browser, context, ownsBrowser: true, ownsContext: true };
109
116
  }
117
+ // `launch` carries Playwright's own 180s timeout; `newContext` carries none.
110
118
  const browser = await chromium.launch(launchOptions);
111
- const context = await browser.newContext(contextOptions);
112
- return {
113
- browser,
114
- context,
115
- ownsBrowser: true,
116
- ownsContext: true,
117
- };
119
+ try {
120
+ const context = await bounded(browser.newContext(contextOptions), NEW_CONTEXT_TIMEOUT_MS, "new_context");
121
+ return {
122
+ browser,
123
+ context,
124
+ ownsBrowser: true,
125
+ ownsContext: true,
126
+ };
127
+ }
128
+ catch (error) {
129
+ // Nobody else holds this browser yet, so a failure here would leak it.
130
+ await bounded(browser.close(), NEW_CONTEXT_TIMEOUT_MS, "close_browser").catch(() => undefined);
131
+ throw error;
132
+ }
118
133
  }
119
134
  //# sourceMappingURL=browser-connection.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser-connection.js","sourceRoot":"","sources":["../src/browser-connection.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,sCAAsC;AAEtC,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,MAAM,YAAY,GAA+C;IAC/D,MAAM,EAAE;QACN,8DAA8D;QAC9D,oDAAoD;QACpD,gEAAgE;KACjE;IACD,KAAK,EAAE;QACL,wBAAwB;QACxB,+BAA+B;QAC/B,mBAAmB;QACnB,2BAA2B;QAC3B,yBAAyB;KAC1B;IACD,KAAK,EAAE;QACL,4DAA4D;QAC5D,kEAAkE;QAClE,6DAA6D;KAC9D;CACF,CAAC;AAyBF,MAAM,CAAC,KAAK,UAAU,uBAAuB;IAC3C,KAAK,MAAM,IAAI,IAAI,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,EAAE,CAAC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AO,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;QAClC,IAAI,OAAO,KAAK,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;QAChF,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;IACpE,CAAC;IACD,6EAA6E;IAC7E,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IACrD,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,OAAO,CAC3B,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,EAClC,sBAAsB,EACtB,aAAa,CACd,CAAC;QACF,OAAO;YACL,OAAO;YACP,OAAO;YACP,WAAW,EAAE,IAAI;YACjB,WAAW,EAAE,IAAI;SAClB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,uEAAuE;QACvE,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,sBAAsB,EAAE,eAAe,CAAC,CAAC,KAAK,CAC3E,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;QACF,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
package/dist/index.d.ts CHANGED
@@ -41,6 +41,24 @@ export interface BrowserRuntimeOptions extends NetworkPolicy {
41
41
  * Returns nothing when the page is clear, so a normal snapshot is unchanged.
42
42
  */
43
43
  export declare function captchaReport(frameUrls: string[]): Record<string, unknown>;
44
+ /**
45
+ * Whether a Playwright action failed after its input had already been sent.
46
+ *
47
+ * A click's own timeout covers more than waiting for the element: after the
48
+ * mouse events go out, Playwright still asks the page to stop its hit-target
49
+ * check. When the click handler stalls the page, that request is what times
50
+ * out — with the click already delivered. Playwright logs `performing <name>
51
+ * action` immediately before dispatching, and the call log is part of the
52
+ * error, so that line is Playwright's own record that the input left. Keyboard,
53
+ * fill, select, and upload calls log no such line; their timeouts stay plain
54
+ * failures, which for them is overwhelmingly a field that never became ready.
55
+ *
56
+ * Playwright paints the call log dim when colour is on (a TTY, FORCE_COLOR),
57
+ * so each line can end in an escape code; those are stripped first. Without
58
+ * that, a click delivered under colour read as never sent: a plain failure
59
+ * where the outcome was unknown, seen first on the Windows CI runners.
60
+ */
61
+ export declare function inputSent(error: unknown): boolean;
44
62
  export declare class BrowserRuntime {
45
63
  private readonly options;
46
64
  private browser;
@@ -66,9 +84,56 @@ export declare class BrowserRuntime {
66
84
  private closing;
67
85
  /** True only while `tab_new` is opening the tab the caller asked for. */
68
86
  private openingTab;
87
+ /**
88
+ * Browser-level session that hears about a new window the moment Chromium
89
+ * creates it, which is what lets an action wait for a popup it knows exists
90
+ * instead of guessing how long one might take. Absent if the browser would
91
+ * not grant one; popups are then reported on Playwright's timing alone.
92
+ */
93
+ private targets;
94
+ /** Windows Chromium has created since tracking began, by browser context. */
95
+ private windowsCreated;
96
+ /** Windows Playwright has handed to the `page` handler, popup or not. */
97
+ private windowsAdopted;
98
+ /** This context's id in CDP, resolved on first use and then fixed. */
99
+ private contextId;
100
+ /**
101
+ * The running action's cancel signal and `timeoutMs`, read by `call`. Same
102
+ * per-action lifetime as `dialogs`, set by `execute`.
103
+ */
104
+ private signal;
105
+ private callMs;
106
+ /**
107
+ * Set once the running action's effect call has returned. From then on the
108
+ * page may have acted on it, so a failure is no longer evidence that nothing
109
+ * happened — see `execute`.
110
+ */
111
+ private dispatched;
69
112
  constructor(options: BrowserRuntimeOptions);
113
+ /**
114
+ * Bound a Playwright call that takes no timeout of its own by the running
115
+ * action's `timeoutMs` and cancel signal.
116
+ *
117
+ * `title()`, `evaluate()`, `count()`, `isVisible()`, `close()` and CDP
118
+ * `send` all wait for the renderer or the browser to answer, and one that
119
+ * stopped answering held the action until the task budget ran out — or
120
+ * forever, where nothing armed one. Failing with `browser_call_timeout:<what>`
121
+ * instead spends the budget on something that can still answer.
122
+ */
123
+ private call;
70
124
  private uploadPaths;
71
125
  private ensureContext;
126
+ /**
127
+ * Hold the action's result until Playwright has handed over every window
128
+ * Chromium created, so the action that opened a window is the one that
129
+ * reports it.
130
+ *
131
+ * Costs one round trip when nothing was opened. Waits only while a window is
132
+ * known to exist and is still unreported, bounded by the action's own
133
+ * timeout: the window is part of what the action did. A window still pending
134
+ * after that is reported by the action running when Playwright delivers it.
135
+ */
136
+ private awaitOpenedWindows;
72
137
  /**
73
138
  * Opens a page MELRA asked for, not one the site opened by itself.
74
139
  *
@@ -116,6 +181,10 @@ export declare class BrowserRuntime {
116
181
  *
117
182
  * A target that matches nothing is reported as such instead of being handed to
118
183
  * Playwright to fail as an opaque action timeout thirty seconds later.
184
+ *
185
+ * Resolution only reads the page and always runs before an action's effect,
186
+ * so a `count` that times out here fails a click or a fill cleanly: nothing
187
+ * was sent, and `execute` does not report it as an unknown outcome.
119
188
  */
120
189
  private locator;
121
190
  /**
@@ -157,7 +226,7 @@ export declare class BrowserRuntime {
157
226
  */
158
227
  private extract;
159
228
  private settledSnapshot;
160
- execute(operation: BrowserOperation): Promise<Record<string, unknown>>;
229
+ execute(operation: BrowserOperation, signal?: AbortSignal): Promise<Record<string, unknown>>;
161
230
  private run;
162
231
  close(): Promise<void>;
163
232
  }
@@ -166,4 +235,5 @@ export * from "./pinning-proxy.js";
166
235
  export * from "./selector.js";
167
236
  export * from "./stable-dom.js";
168
237
  export * from "./browser-connection.js";
238
+ export * from "./bounded.js";
169
239
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,gBAAgB,EAAiB,MAAM,iBAAiB,CAAC;AAKvE,OAAO,EAEL,KAAK,aAAa,EACnB,MAAM,oBAAoB,CAAC;AAK5B,MAAM,WAAW,qBAAsB,SAAQ,aAAa;IAC1D,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,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