@mlola/browser-backend 0.2.11 → 0.4.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.
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Deadlines for browser round-trips.
3
+ *
4
+ * A page whose main thread never yields, or a browser that stopped answering,
5
+ * leaves a pending promise that never settles. Playwright cannot cancel an
6
+ * in-flight `evaluate`, so the caller races it against a timer instead: the run
7
+ * moves on with a typed failure, and the abandoned promise is silenced so its
8
+ * eventual rejection cannot surface as an unhandled rejection.
9
+ */
10
+ export declare class DeadlineExceededError extends Error {
11
+ readonly label: string;
12
+ readonly timeoutMs: number;
13
+ constructor(label: string, timeoutMs: number);
14
+ }
15
+ export declare const withDeadline: <T>(promise: Promise<T>, timeoutMs: number, label: string) => Promise<T>;
16
+ //# sourceMappingURL=deadline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deadline.d.ts","sourceRoot":"","sources":["../src/deadline.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBACf,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAM7C;AAED,eAAO,MAAM,YAAY,GAAI,CAAC,EAAE,SAAS,OAAO,CAAC,CAAC,CAAC,EAAE,WAAW,MAAM,EAAE,OAAO,MAAM,KAAG,OAAO,CAAC,CAAC,CAsBhG,CAAC"}
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Deadlines for browser round-trips.
3
+ *
4
+ * A page whose main thread never yields, or a browser that stopped answering,
5
+ * leaves a pending promise that never settles. Playwright cannot cancel an
6
+ * in-flight `evaluate`, so the caller races it against a timer instead: the run
7
+ * moves on with a typed failure, and the abandoned promise is silenced so its
8
+ * eventual rejection cannot surface as an unhandled rejection.
9
+ */
10
+ export class DeadlineExceededError extends Error {
11
+ label;
12
+ timeoutMs;
13
+ constructor(label, timeoutMs) {
14
+ super(`${label} did not finish within ${timeoutMs}ms`);
15
+ this.name = "DeadlineExceededError";
16
+ this.label = label;
17
+ this.timeoutMs = timeoutMs;
18
+ }
19
+ }
20
+ export const withDeadline = (promise, timeoutMs, label) => {
21
+ if (!Number.isFinite(timeoutMs) || timeoutMs <= 0) {
22
+ void promise.catch(() => undefined);
23
+ return Promise.reject(new DeadlineExceededError(label, Math.max(0, timeoutMs)));
24
+ }
25
+ return new Promise((resolve, reject) => {
26
+ const timer = setTimeout(() => {
27
+ void promise.catch(() => undefined);
28
+ reject(new DeadlineExceededError(label, timeoutMs));
29
+ }, timeoutMs);
30
+ timer.unref?.();
31
+ promise.then((value) => {
32
+ clearTimeout(timer);
33
+ resolve(value);
34
+ }, (err) => {
35
+ clearTimeout(timer);
36
+ reject(err);
37
+ });
38
+ });
39
+ };
40
+ //# sourceMappingURL=deadline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deadline.js","sourceRoot":"","sources":["../src/deadline.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IACrC,KAAK,CAAS;IACd,SAAS,CAAS;IAC3B,YAAY,KAAa,EAAE,SAAiB;QAC1C,KAAK,CAAC,GAAG,KAAK,0BAA0B,SAAS,IAAI,CAAC,CAAC;QACvD,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF;AAED,MAAM,CAAC,MAAM,YAAY,GAAG,CAAI,OAAmB,EAAE,SAAiB,EAAE,KAAa,EAAc,EAAE;IACnG,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;QAClD,KAAK,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QACpC,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,qBAAqB,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;IAClF,CAAC;IACD,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACxC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC5B,KAAK,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YACpC,MAAM,CAAC,IAAI,qBAAqB,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC;QACtD,CAAC,EAAE,SAAS,CAAC,CAAC;QACd,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;QAChB,OAAO,CAAC,IAAI,CACV,CAAC,KAAK,EAAE,EAAE;YACR,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC,EACD,CAAC,GAAY,EAAE,EAAE;YACf,YAAY,CAAC,KAAK,CAAC,CAAC;YACpB,MAAM,CAAC,GAAG,CAAC,CAAC;QACd,CAAC,CACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./interface.ts";
2
2
  export * from "./registry.ts";
3
3
  export * from "./webmcp.ts";
4
+ export * from "./deadline.ts";
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from "./interface.js";
2
2
  export * from "./registry.js";
3
3
  export * from "./webmcp.js";
4
+ export * from "./deadline.js";
4
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlola/browser-backend",
3
- "version": "0.2.11",
3
+ "version": "0.4.0",
4
4
  "description": "BrowserBackend interface, capability negotiation and backend registry.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -47,6 +47,6 @@
47
47
  "access": "public"
48
48
  },
49
49
  "dependencies": {
50
- "@mlola/browser-protocol": "0.2.11"
50
+ "@mlola/browser-protocol": "0.4.0"
51
51
  }
52
52
  }