@vitest/browser 5.0.0-beta.7 → 5.0.0-rc.2

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/context.d.ts CHANGED
@@ -447,6 +447,9 @@ export interface LocatorOptions {
447
447
  * regular expression. Note that exact match still trims whitespace.
448
448
  */
449
449
  exact?: boolean
450
+ }
451
+
452
+ export interface LocatorFilterOptions {
450
453
  hasText?: string | RegExp
451
454
  hasNotText?: string | RegExp
452
455
  has?: Locator
@@ -766,7 +769,7 @@ export interface Locator extends LocatorSelectors {
766
769
  * Narrows existing locator according to the options.
767
770
  * @see {@link https://vitest.dev/api/browser/locators#filter}
768
771
  */
769
- filter(options: LocatorOptions): Locator
772
+ filter(options: LocatorFilterOptions): Locator
770
773
  /**
771
774
  * This method returns an element matching the locator.
772
775
  * Unlike [`.element()`](https://vitest.dev/api/browser/locators#element),
@@ -1,33 +1,33 @@
1
1
  {
2
- "../../../../node_modules/.pnpm/rrweb-snapshot@2.0.1_patch_hash=9e976b2c55a5c2ed589c41b8f46cc44b6fe6f528ebb4d3780a44b1ca8cbb17a4/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js": {
3
- "file": "__vitest_browser__/rrweb-snapshot-DkFyu2W8.js",
2
+ "../../../../node_modules/.pnpm/rrweb-snapshot@2.1.1_patch_hash=0b0dbc551d27a6f24438e9582c41a0ec34fd444760d383a4172013031d73c4e7/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js": {
3
+ "file": "__vitest_browser__/rrweb-snapshot-g5vjbXoV.js",
4
4
  "name": "rrweb-snapshot",
5
- "src": "../../../../node_modules/.pnpm/rrweb-snapshot@2.0.1_patch_hash=9e976b2c55a5c2ed589c41b8f46cc44b6fe6f528ebb4d3780a44b1ca8cbb17a4/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js",
5
+ "src": "../../../../node_modules/.pnpm/rrweb-snapshot@2.1.1_patch_hash=0b0dbc551d27a6f24438e9582c41a0ec34fd444760d383a4172013031d73c4e7/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js",
6
6
  "isDynamicEntry": true
7
7
  },
8
- "_defineProperty-WHpdAQXR.js": {
9
- "file": "__vitest_browser__/defineProperty-WHpdAQXR.js",
8
+ "_defineProperty-BOtRrjRA.js": {
9
+ "file": "__vitest_browser__/defineProperty-BOtRrjRA.js",
10
10
  "name": "defineProperty"
11
11
  },
12
12
  "orchestrator.html": {
13
- "file": "__vitest_browser__/orchestrator-Bdv4lWwV.js",
13
+ "file": "__vitest_browser__/orchestrator-DJgIeTMM.js",
14
14
  "name": "orchestrator",
15
15
  "src": "orchestrator.html",
16
16
  "isEntry": true,
17
17
  "imports": [
18
- "_defineProperty-WHpdAQXR.js"
18
+ "_defineProperty-BOtRrjRA.js"
19
19
  ]
20
20
  },
21
21
  "tester/tester.html": {
22
- "file": "__vitest_browser__/tester-CREI5Ivt.js",
22
+ "file": "__vitest_browser__/tester-DDRabqAJ.js",
23
23
  "name": "tester",
24
24
  "src": "tester/tester.html",
25
25
  "isEntry": true,
26
26
  "imports": [
27
- "_defineProperty-WHpdAQXR.js"
27
+ "_defineProperty-BOtRrjRA.js"
28
28
  ],
29
29
  "dynamicImports": [
30
- "../../../../node_modules/.pnpm/rrweb-snapshot@2.0.1_patch_hash=9e976b2c55a5c2ed589c41b8f46cc44b6fe6f528ebb4d3780a44b1ca8cbb17a4/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js"
30
+ "../../../../node_modules/.pnpm/rrweb-snapshot@2.1.1_patch_hash=0b0dbc551d27a6f24438e9582c41a0ec34fd444760d383a4172013031d73c4e7/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js"
31
31
  ]
32
32
  }
33
33
  }
@@ -121,6 +121,18 @@ var relative = function(from, to) {
121
121
  }
122
122
  return [..._from.map(() => ".."), ..._to].join("/");
123
123
  };
124
+ var basename = function(p, extension) {
125
+ const segments = normalizeWindowsPath(p).split("/");
126
+ let lastSegment = "";
127
+ for (let i = segments.length - 1; i >= 0; i--) {
128
+ const val = segments[i];
129
+ if (val) {
130
+ lastSegment = val;
131
+ break;
132
+ }
133
+ }
134
+ return extension && lastSegment.endsWith(extension) ? lastSegment.slice(0, -extension.length) : lastSegment;
135
+ };
124
136
 
125
137
  //#endregion
126
138
  //#region ../vitest/src/utils/tasks.ts
@@ -307,4 +319,4 @@ function _defineProperty(e, r, t) {
307
319
  }
308
320
 
309
321
  //#endregion
310
- export { moduleRunner as a, generateFileHash as c, resolve as d, getWorkerState as i, getTestName as l, getBrowserState as n, now as o, getConfig as r, __vitePreload as s, _defineProperty as t, relative as u };
322
+ export { moduleRunner as a, generateFileHash as c, relative as d, resolve as f, getWorkerState as i, getTestName as l, getBrowserState as n, now as o, getConfig as r, __vitePreload as s, _defineProperty as t, basename as u };
@@ -1,4 +1,4 @@
1
- import { c as generateFileHash, n as getBrowserState, r as getConfig, t as _defineProperty, u as relative } from "./defineProperty-WHpdAQXR.js";
1
+ import { c as generateFileHash, d as relative, n as getBrowserState, r as getConfig, t as _defineProperty } from "./defineProperty-BOtRrjRA.js";
2
2
  import { channel, client, globalChannel } from "@vitest/browser/client";
3
3
  import { Traces } from "vitest/internal/traces";
4
4
 
@@ -1,4 +1,4 @@
1
- //#region ../../node_modules/.pnpm/rrweb-snapshot@2.0.1_patch_hash=9e976b2c55a5c2ed589c41b8f46cc44b6fe6f528ebb4d3780a44b1ca8cbb17a4/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js
1
+ //#region ../../node_modules/.pnpm/rrweb-snapshot@2.1.1_patch_hash=0b0dbc551d27a6f24438e9582c41a0ec34fd444760d383a4172013031d73c4e7/node_modules/rrweb-snapshot/dist/rrweb-snapshot.js
2
2
  var __defProp = Object.defineProperty;
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
4
4
  enumerable: true,
@@ -358,13 +358,15 @@ function absolutifyURLs(cssText, href) {
358
358
  if (URL_PROTOCOL_MATCH.test(filePath) || URL_WWW_MATCH.test(filePath)) return `url(${maybeQuote}${filePath}${maybeQuote})`;
359
359
  if (DATA_URI.test(filePath)) return `url(${maybeQuote}${filePath}${maybeQuote})`;
360
360
  if (filePath[0] === "/") return `url(${maybeQuote}${extractOrigin(href) + filePath}${maybeQuote})`;
361
- const stack = href.split("/");
362
- const parts = filePath.split("/");
361
+ const filePathNoHash = filePath.split("#")[0];
362
+ const maybeHash = filePath.substring(filePathNoHash.length);
363
+ const stack = href.split("#")[0].split("/");
364
+ const parts = filePathNoHash.split("/");
363
365
  stack.pop();
364
366
  for (const part of parts) if (part === ".") continue;
365
367
  else if (part === "..") stack.pop();
366
368
  else stack.push(part);
367
- return `url(${maybeQuote}${stack.join("/")}${maybeQuote})`;
369
+ return `url(${maybeQuote}${stack.join("/")}${maybeHash}${maybeQuote})`;
368
370
  });
369
371
  }
370
372
  function normalizeCssString(cssText, _testNoPxNorm = false) {
@@ -1,4 +1,4 @@
1
- import { a as moduleRunner, d as resolve, i as getWorkerState, l as getTestName, n as getBrowserState, o as now$1, r as getConfig, s as __vitePreload, t as _defineProperty } from "./defineProperty-WHpdAQXR.js";
1
+ import { a as moduleRunner, f as resolve, i as getWorkerState, l as getTestName, n as getBrowserState, o as now$1, r as getConfig, s as __vitePreload, t as _defineProperty, u as basename } from "./defineProperty-BOtRrjRA.js";
2
2
  import { channel, client, globalChannel, onCancel, registerPageMarkHandler } from "@vitest/browser/client";
3
3
  import { Traces } from "vitest/internal/traces";
4
4
  import { page, server, userEvent } from "vitest/browser";
@@ -33,7 +33,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
33
33
  }) : target, mod));
34
34
 
35
35
  //#endregion
36
- //#region ../../node_modules/.pnpm/flatted@3.4.2/node_modules/flatted/esm/index.js
36
+ //#region ../../node_modules/.pnpm/flatted@3.4.4/node_modules/flatted/esm/index.js
37
37
  var { parse: $parse, stringify: $stringify } = JSON;
38
38
  var { keys } = Object;
39
39
  var Primitive = String;
@@ -720,6 +720,9 @@ var VitestBrowserSnapshotEnvironment = class {
720
720
  readSnapshotFile(filepath) {
721
721
  return rpc$1().readSnapshotFile(filepath);
722
722
  }
723
+ readSnapshotFileData(filepath) {
724
+ return rpc$1().readSnapshotFileData(filepath);
725
+ }
723
726
  saveSnapshotFile(filepath, snapshot) {
724
727
  return rpc$1().saveSnapshotFile(filepath, snapshot);
725
728
  }
@@ -898,10 +901,10 @@ function createBrowserRunner(mocker, state, coverageModule) {
898
901
  const lastErrorContext = (_task$result3 = task.result) === null || _task$result3 === void 0 || (_task$result3 = _task$result3.errors) === null || _task$result3 === void 0 || (_task$result3 = _task$result3.at(-1)) === null || _task$result3 === void 0 ? void 0 : _task$result3.__vitest_error_context__;
899
902
  if (this.config.browser.screenshotFailures && document.body.clientHeight > 0 && ((_task$result4 = task.result) === null || _task$result4 === void 0 ? void 0 : _task$result4.state) === "fail" && task.type === "test" && !(lastErrorContext && Reflect.get(lastErrorContext, "assertionName") === "toMatchScreenshot" && ((_Reflect$get = Reflect.get(lastErrorContext, "meta")) === null || _Reflect$get === void 0 ? void 0 : _Reflect$get.outcome) !== "unstable-screenshot")) {
900
903
  var _this$config$browser$;
901
- const screenshot = await page.screenshot(
902
- { timeout: ((_this$config$browser$ = this.config.browser.providerOptions) === null || _this$config$browser$ === void 0 ? void 0 : _this$config$browser$.actionTimeout) ?? 5e3 }
903
- /** TODO */
904
- ).catch((err) => {
904
+ const screenshot = await page.screenshot({
905
+ timeout: ((_this$config$browser$ = this.config.browser.providerOptions) === null || _this$config$browser$ === void 0 ? void 0 : _this$config$browser$.actionTimeout) ?? 5e3,
906
+ path: resolve(this.config.attachmentsDir, "failure-screenshots", basename(task.file.filepath), `${task.fullTestName.replace(/\W/g, "-")}.png`)
907
+ }).catch((err) => {
905
908
  console.error("[vitest] Failed to take a screenshot", err);
906
909
  });
907
910
  if (screenshot) await recordArtifact(task, {
@@ -1032,7 +1035,7 @@ function createBrowserRunner(mocker, state, coverageModule) {
1032
1035
  return;
1033
1036
  }
1034
1037
  if (shouldTraceView) {
1035
- (/* @__PURE__ */ getBrowserState()).browserTraceDomSnapshot = await __vitePreload(() => import("./rrweb-snapshot-DkFyu2W8.js"), []);
1038
+ (/* @__PURE__ */ getBrowserState()).browserTraceDomSnapshot = await __vitePreload(() => import("./rrweb-snapshot-g5vjbXoV.js"), []);
1036
1039
  (/* @__PURE__ */ getBrowserState()).browserTraceAttempts.set(test.id, {
1037
1040
  retry,
1038
1041
  repeats,
@@ -1276,6 +1279,9 @@ var MockerRegistry = class {
1276
1279
  };
1277
1280
  var AutomockedModule = class AutomockedModule {
1278
1281
  constructor(raw, id, url) {
1282
+ _defineProperty(this, "raw", void 0);
1283
+ _defineProperty(this, "id", void 0);
1284
+ _defineProperty(this, "url", void 0);
1279
1285
  _defineProperty(this, "type", "automock");
1280
1286
  this.raw = raw;
1281
1287
  this.id = id;
@@ -1295,6 +1301,9 @@ var AutomockedModule = class AutomockedModule {
1295
1301
  };
1296
1302
  var AutospiedModule = class AutospiedModule {
1297
1303
  constructor(raw, id, url) {
1304
+ _defineProperty(this, "raw", void 0);
1305
+ _defineProperty(this, "id", void 0);
1306
+ _defineProperty(this, "url", void 0);
1298
1307
  _defineProperty(this, "type", "autospy");
1299
1308
  this.raw = raw;
1300
1309
  this.id = id;
@@ -1314,6 +1323,10 @@ var AutospiedModule = class AutospiedModule {
1314
1323
  };
1315
1324
  var RedirectedModule = class RedirectedModule {
1316
1325
  constructor(raw, id, url, redirect) {
1326
+ _defineProperty(this, "raw", void 0);
1327
+ _defineProperty(this, "id", void 0);
1328
+ _defineProperty(this, "url", void 0);
1329
+ _defineProperty(this, "redirect", void 0);
1317
1330
  _defineProperty(this, "type", "redirect");
1318
1331
  this.raw = raw;
1319
1332
  this.id = id;
@@ -1335,6 +1348,10 @@ var RedirectedModule = class RedirectedModule {
1335
1348
  };
1336
1349
  var ManualMockedModule = class ManualMockedModule {
1337
1350
  constructor(raw, id, url, factory) {
1351
+ _defineProperty(this, "raw", void 0);
1352
+ _defineProperty(this, "id", void 0);
1353
+ _defineProperty(this, "url", void 0);
1354
+ _defineProperty(this, "factory", void 0);
1338
1355
  _defineProperty(this, "cache", void 0);
1339
1356
  _defineProperty(this, "type", "manual");
1340
1357
  this.raw = raw;
@@ -1344,20 +1361,20 @@ var ManualMockedModule = class ManualMockedModule {
1344
1361
  }
1345
1362
  resolve() {
1346
1363
  if (this.cache) return this.cache;
1347
- let exports$1;
1364
+ let exports;
1348
1365
  try {
1349
- exports$1 = this.factory();
1366
+ exports = this.factory();
1350
1367
  } catch (err) {
1351
1368
  throw createHelpfulError(err);
1352
1369
  }
1353
- if (typeof exports$1 === "object" && typeof (exports$1 === null || exports$1 === void 0 ? void 0 : exports$1.then) === "function") return exports$1.then((result) => {
1370
+ if (typeof exports === "object" && typeof (exports === null || exports === void 0 ? void 0 : exports.then) === "function") return exports.then((result) => {
1354
1371
  assertValidExports(this.raw, result);
1355
1372
  return this.cache = result;
1356
1373
  }, (error) => {
1357
1374
  throw createHelpfulError(error);
1358
1375
  });
1359
- assertValidExports(this.raw, exports$1);
1360
- return this.cache = exports$1;
1376
+ assertValidExports(this.raw, exports);
1377
+ return this.cache = exports;
1361
1378
  }
1362
1379
  static fromJSON(data, factory) {
1363
1380
  return new ManualMockedModule(data.raw, data.id, data.url, factory);
@@ -1376,8 +1393,8 @@ function createHelpfulError(cause) {
1376
1393
  error.cause = cause;
1377
1394
  return error;
1378
1395
  }
1379
- function assertValidExports(raw, exports$1) {
1380
- if (exports$1 === null || typeof exports$1 !== "object" || Array.isArray(exports$1)) throw new TypeError(`[vitest] vi.mock("${raw}", factory?: () => unknown) is not returning an object. Did you mean to return an object with a "default" key?`);
1396
+ function assertValidExports(raw, exports) {
1397
+ if (exports === null || typeof exports !== "object" || Array.isArray(exports)) throw new TypeError(`[vitest] vi.mock("${raw}", factory?: () => unknown) is not returning an object. Did you mean to return an object with a "default" key?`);
1381
1398
  }
1382
1399
 
1383
1400
  //#endregion
@@ -1446,14 +1463,14 @@ function mockObject(options, object, mockExports = {}) {
1446
1463
  continue;
1447
1464
  }
1448
1465
  if (options.type === "autospy" && type === "Module") {
1449
- const exports$1 = Object.create(null);
1450
- Object.defineProperty(exports$1, Symbol.toStringTag, {
1466
+ const exports = Object.create(null);
1467
+ Object.defineProperty(exports, Symbol.toStringTag, {
1451
1468
  value: "Module",
1452
1469
  configurable: true,
1453
1470
  writable: true
1454
1471
  });
1455
1472
  try {
1456
- newContainer[property] = exports$1;
1473
+ newContainer[property] = exports;
1457
1474
  } catch {
1458
1475
  continue;
1459
1476
  }
@@ -1652,6 +1669,10 @@ var REGEXP_VITEST = new RegExp(`vitest=\\d{${NOW_LENGTH}}`);
1652
1669
  var { now } = Date;
1653
1670
  var ModuleMocker = class {
1654
1671
  constructor(interceptor, rpc, createMockInstance, config) {
1672
+ _defineProperty(this, "interceptor", void 0);
1673
+ _defineProperty(this, "rpc", void 0);
1674
+ _defineProperty(this, "createMockInstance", void 0);
1675
+ _defineProperty(this, "config", void 0);
1655
1676
  _defineProperty(this, "registry", new MockerRegistry());
1656
1677
  _defineProperty(this, "queue", /* @__PURE__ */ new Set());
1657
1678
  _defineProperty(this, "mockedIds", /* @__PURE__ */ new Set());
@@ -1942,8 +1963,10 @@ var traces = new Traces({
1942
1963
  });
1943
1964
  var rootTesterSpan;
1944
1965
  (/* @__PURE__ */ getBrowserState()).traces = traces;
1966
+ var isEmbedded = window.self !== window.top;
1945
1967
  channel.addEventListener("message", async (e) => {
1946
1968
  const data = e.data;
1969
+ if (!isEmbedded) return;
1947
1970
  if (!isEvent(data)) {
1948
1971
  await client.waitForConnection();
1949
1972
  unhandledError(/* @__PURE__ */ new Error(`Unknown message: ${JSON.stringify(e.data)}`), "Unknown Iframe Message");
@@ -2010,7 +2033,7 @@ var commands = new CommandsManager();
2010
2033
  (/* @__PURE__ */ getBrowserState()).browserTraceAttempts = /* @__PURE__ */ new Map();
2011
2034
  (/* @__PURE__ */ getBrowserState()).iframeId = iframeId;
2012
2035
  registerPageMarkHandler((name, options) => page.mark(name, options));
2013
- channel.postMessage({
2036
+ if (isEmbedded) channel.postMessage({
2014
2037
  event: "ready",
2015
2038
  iframeId
2016
2039
  });
@@ -26,8 +26,8 @@
26
26
  {__VITEST_INJECTOR__}
27
27
  {__VITEST_ERROR_CATCHER__}
28
28
  {__VITEST_SCRIPTS__}
29
- <script type="module" crossorigin src="/__vitest_browser__/orchestrator-Bdv4lWwV.js"></script>
30
- <link rel="modulepreload" crossorigin href="/__vitest_browser__/defineProperty-WHpdAQXR.js">
29
+ <script type="module" crossorigin src="/__vitest_browser__/orchestrator-DJgIeTMM.js"></script>
30
+ <link rel="modulepreload" crossorigin href="/__vitest_browser__/defineProperty-BOtRrjRA.js">
31
31
  </head>
32
32
  <body>
33
33
  <div id="vitest-tester"></div>
@@ -1,4 +1,4 @@
1
- import type { LocatorByRoleOptions, LocatorOptions, LocatorScreenshotOptions, MarkOptions, SelectorOptions, UserEventClearOptions, UserEventClickOptions, UserEventDragAndDropOptions, UserEventFillOptions, UserEventHoverOptions, UserEventSelectOptions, UserEventUploadOptions, UserEventWheelOptions } from "vitest/browser";
1
+ import type { LocatorByRoleOptions, LocatorFilterOptions, LocatorOptions, LocatorScreenshotOptions, MarkOptions, SelectorOptions, UserEventClearOptions, UserEventClickOptions, UserEventDragAndDropOptions, UserEventFillOptions, UserEventHoverOptions, UserEventSelectOptions, UserEventUploadOptions, UserEventWheelOptions } from "vitest/browser";
2
2
  import { Ivya } from "ivya";
3
3
  export { ensureAwaited } from "../utils.js";
4
4
  export { convertElementToCssSelector, getIframeScale, processTimeoutOptions } from "./tester-utils.js";
@@ -40,7 +40,7 @@ export declare abstract class Locator {
40
40
  getByTestId(testId: string | RegExp): Locator;
41
41
  getByText(text: string | RegExp, options?: LocatorOptions): Locator;
42
42
  getByTitle(title: string | RegExp, options?: LocatorOptions): Locator;
43
- filter(filter: LocatorOptions): Locator;
43
+ filter(filter: LocatorFilterOptions): Locator;
44
44
  and(locator: Locator): Locator;
45
45
  or(locator: Locator): Locator;
46
46
  query(): HTMLElement | SVGElement | null;
@@ -5,8 +5,8 @@
5
5
  <link rel="icon" href="{__VITEST_FAVICON__}" type="image/svg+xml">
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
7
  <title>Vitest Browser Tester</title>
8
- <script type="module" crossorigin src="/__vitest_browser__/tester-CREI5Ivt.js"></script>
9
- <link rel="modulepreload" crossorigin href="/__vitest_browser__/defineProperty-WHpdAQXR.js">
8
+ <script type="module" crossorigin src="/__vitest_browser__/tester-DDRabqAJ.js"></script>
9
+ <link rel="modulepreload" crossorigin href="/__vitest_browser__/defineProperty-BOtRrjRA.js">
10
10
  </head>
11
11
  <body>
12
12
  </body>
@@ -8,9 +8,9 @@ export interface BrowserTraceData {
8
8
  entries: BrowserTraceEntry[];
9
9
  }
10
10
  export type BrowserTraceEntryStatus = "pass" | "fail";
11
- export type BrowserTraceEntryRangePhase = "start" | "end";
12
- export type BrowserTraceSelectorResolution = "matched" | "missing" | "error";
13
- export interface BrowserTraceEntryRange {
11
+ type BrowserTraceEntryRangePhase = "start" | "end";
12
+ type BrowserTraceSelectorResolution = "matched" | "missing" | "error";
13
+ interface BrowserTraceEntryRange {
14
14
  id: string;
15
15
  phase: BrowserTraceEntryRangePhase;
16
16
  }
package/dist/client.js CHANGED
@@ -1,8 +1,3 @@
1
- //#region src/messages.ts
2
- const TYPE_REQUEST = "q";
3
- const TYPE_RESPONSE = "s";
4
-
5
- //#endregion
6
1
  //#region src/utils.ts
7
2
  function createPromiseWithResolvers() {
8
3
  let resolve;
@@ -25,7 +20,6 @@ function nanoid(size = 21) {
25
20
  return id;
26
21
  }
27
22
 
28
- //#endregion
29
23
  //#region src/main.ts
30
24
  const DEFAULT_TIMEOUT = 6e4;
31
25
  const defaultSerialize = (i) => i;
@@ -42,7 +36,7 @@ function createBirpc($functions, options) {
42
36
  const req = {
43
37
  m: method,
44
38
  a: args,
45
- t: TYPE_REQUEST
39
+ t: "q"
46
40
  };
47
41
  if (optional) req.o = true;
48
42
  const send = async (_req) => post(serialize(_req));
@@ -96,7 +90,7 @@ function createBirpc($functions, options) {
96
90
  $call: (method, ...args) => _call(method, args, false),
97
91
  $callOptional: (method, ...args) => _call(method, args, false, true),
98
92
  $callEvent: (method, ...args) => _call(method, args, true),
99
- $callRaw: (options$1) => _call(options$1.method, options$1.args, options$1.event, options$1.optional),
93
+ $callRaw: (options) => _call(options.method, options.args, options.event, options.optional),
100
94
  $rejectPendingCalls,
101
95
  get $closed() {
102
96
  return $closed;
@@ -108,7 +102,7 @@ function createBirpc($functions, options) {
108
102
  $functions
109
103
  };
110
104
  if (proxify) rpc = new Proxy({}, { get(_, method) {
111
- if (Object.prototype.hasOwnProperty.call(builtinMethods, method)) return builtinMethods[method];
105
+ if (Object.hasOwn(builtinMethods, method)) return builtinMethods[method];
112
106
  if (method === "then" && !eventNames.includes("then") && !("then" in $functions)) return void 0;
113
107
  const sendEvent = (...args) => _call(method, args, true);
114
108
  if (eventNames.includes(method)) {
@@ -152,7 +146,7 @@ function createBirpc($functions, options) {
152
146
  if (options.onGeneralError?.call(rpc, e) !== true) throw e;
153
147
  return;
154
148
  }
155
- if (msg.t === TYPE_REQUEST) {
149
+ if (msg.t === "q") {
156
150
  const { m: method, a: args, o: optional } = msg;
157
151
  let result, error;
158
152
  let fn = await (resolver ? resolver.call(rpc, method, $functions[method]) : $functions[method]);
@@ -169,7 +163,7 @@ function createBirpc($functions, options) {
169
163
  }
170
164
  if (!error) try {
171
165
  await post(serialize({
172
- t: TYPE_RESPONSE,
166
+ t: "s",
173
167
  i: msg.i,
174
168
  r: result
175
169
  }), ...extra);
@@ -180,7 +174,7 @@ function createBirpc($functions, options) {
180
174
  }
181
175
  try {
182
176
  await post(serialize({
183
- t: TYPE_RESPONSE,
177
+ t: "s",
184
178
  i: msg.i,
185
179
  e: error
186
180
  }), ...extra);
@@ -336,6 +330,12 @@ const ENTRY_URL = `${location.protocol === "https:" ? "wss:" : "ws:"}//${HOST}/_
336
330
  const onCancelCallbacks = [];
337
331
  function onCancel(callback) {
338
332
  onCancelCallbacks.push(callback);
333
+ return () => {
334
+ const index = onCancelCallbacks.indexOf(callback);
335
+ if (index !== -1) {
336
+ onCancelCallbacks.splice(index, 1);
337
+ }
338
+ };
339
339
  }
340
340
  let pageMarkHandler = null;
341
341
  function registerPageMarkHandler(handler) {
@@ -405,8 +405,8 @@ function createClient() {
405
405
  responseId
406
406
  };
407
407
  }
408
- const exports$1 = await mocker.resolveFactoryModule(url);
409
- const keys = Object.keys(exports$1);
408
+ const exports = await mocker.resolveFactoryModule(url);
409
+ const keys = Object.keys(exports);
410
410
  return {
411
411
  url,
412
412
  keys,
package/dist/context.js CHANGED
@@ -372,6 +372,7 @@ function createUserEvent(__tl_user_event_base__, options) {
372
372
  upload(element, files, options) {
373
373
  return convertToLocator(element).upload(files, options);
374
374
  },
375
+ // non userEvent events, but still useful
375
376
  fill(element, text, options) {
376
377
  return convertToLocator(element).fill(text, options);
377
378
  },
@@ -380,6 +381,7 @@ function createUserEvent(__tl_user_event_base__, options) {
380
381
  const targetLocator = convertToLocator(target);
381
382
  return sourceLocator.dropTo(targetLocator, options);
382
383
  },
384
+ // testing-library user-event
383
385
  type(element, text, options) {
384
386
  return ensureAwaited(async (error) => {
385
387
  const serializedElement = await serializeElement(element, options);