@ricsam/isolate 0.0.1 → 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.
Files changed (299) hide show
  1. package/dist/cjs/bridge/diagnostics.cjs +58 -0
  2. package/dist/cjs/bridge/diagnostics.cjs.map +10 -0
  3. package/dist/cjs/bridge/legacy-adapters.cjs +242 -0
  4. package/dist/cjs/bridge/legacy-adapters.cjs.map +10 -0
  5. package/dist/cjs/bridge/request-context.cjs +59 -0
  6. package/dist/cjs/bridge/request-context.cjs.map +10 -0
  7. package/dist/cjs/bridge/runtime-bindings.cjs +367 -0
  8. package/dist/cjs/bridge/runtime-bindings.cjs.map +10 -0
  9. package/dist/cjs/browser/browser-runtime.cjs +157 -0
  10. package/dist/cjs/browser/browser-runtime.cjs.map +10 -0
  11. package/dist/cjs/daemon.cjs +91 -0
  12. package/dist/cjs/daemon.cjs.map +10 -0
  13. package/dist/cjs/files/index.cjs +140 -0
  14. package/dist/cjs/files/index.cjs.map +10 -0
  15. package/dist/cjs/host/create-isolate-host.cjs +235 -0
  16. package/dist/cjs/host/create-isolate-host.cjs.map +10 -0
  17. package/dist/cjs/host/index.cjs +47 -0
  18. package/dist/cjs/host/index.cjs.map +10 -0
  19. package/dist/cjs/index.cjs +55 -0
  20. package/dist/cjs/index.cjs.map +10 -0
  21. package/dist/cjs/internal/client/connection.cjs +1919 -0
  22. package/dist/cjs/internal/client/connection.cjs.map +10 -0
  23. package/dist/cjs/internal/client/index.cjs +48 -0
  24. package/dist/cjs/internal/client/index.cjs.map +10 -0
  25. package/dist/cjs/internal/client/types.cjs +30 -0
  26. package/dist/cjs/internal/client/types.cjs.map +9 -0
  27. package/dist/cjs/internal/console/index.cjs +506 -0
  28. package/dist/cjs/internal/console/index.cjs.map +10 -0
  29. package/dist/cjs/internal/console/utils.cjs +70 -0
  30. package/dist/cjs/internal/console/utils.cjs.map +10 -0
  31. package/dist/cjs/internal/core/index.cjs +2745 -0
  32. package/dist/cjs/internal/core/index.cjs.map +10 -0
  33. package/dist/cjs/internal/crypto/index.cjs +470 -0
  34. package/dist/cjs/internal/crypto/index.cjs.map +10 -0
  35. package/dist/cjs/internal/daemon/callback-fs-handler.cjs +355 -0
  36. package/dist/cjs/internal/daemon/callback-fs-handler.cjs.map +10 -0
  37. package/dist/cjs/internal/daemon/connection.cjs +1952 -0
  38. package/dist/cjs/internal/daemon/connection.cjs.map +10 -0
  39. package/dist/cjs/internal/daemon/daemon.cjs +98 -0
  40. package/dist/cjs/internal/daemon/daemon.cjs.map +10 -0
  41. package/dist/cjs/internal/daemon/index.cjs +145 -0
  42. package/dist/cjs/internal/daemon/index.cjs.map +10 -0
  43. package/dist/cjs/internal/daemon/runtime-pool.cjs +106 -0
  44. package/dist/cjs/internal/daemon/runtime-pool.cjs.map +10 -0
  45. package/dist/cjs/internal/daemon/types.cjs +30 -0
  46. package/dist/cjs/internal/daemon/types.cjs.map +9 -0
  47. package/dist/cjs/internal/encoding/index.cjs +419 -0
  48. package/dist/cjs/internal/encoding/index.cjs.map +10 -0
  49. package/dist/cjs/internal/fetch/consistency/origins.cjs +598 -0
  50. package/dist/cjs/internal/fetch/consistency/origins.cjs.map +10 -0
  51. package/dist/cjs/internal/fetch/index.cjs +2640 -0
  52. package/dist/cjs/internal/fetch/index.cjs.map +10 -0
  53. package/dist/cjs/internal/fetch/stream-state.cjs +256 -0
  54. package/dist/cjs/internal/fetch/stream-state.cjs.map +10 -0
  55. package/dist/cjs/internal/fs/index.cjs +847 -0
  56. package/dist/cjs/internal/fs/index.cjs.map +10 -0
  57. package/dist/cjs/internal/fs/node-adapter.cjs +254 -0
  58. package/dist/cjs/internal/fs/node-adapter.cjs.map +10 -0
  59. package/dist/cjs/internal/module-loader/bundle.cjs +482 -0
  60. package/dist/cjs/internal/module-loader/bundle.cjs.map +10 -0
  61. package/dist/cjs/internal/module-loader/index.cjs +240 -0
  62. package/dist/cjs/internal/module-loader/index.cjs.map +10 -0
  63. package/dist/cjs/internal/module-loader/mappings.cjs +120 -0
  64. package/dist/cjs/internal/module-loader/mappings.cjs.map +10 -0
  65. package/dist/cjs/internal/module-loader/resolve.cjs +177 -0
  66. package/dist/cjs/internal/module-loader/resolve.cjs.map +10 -0
  67. package/dist/cjs/internal/module-loader/strip-types.cjs +236 -0
  68. package/dist/cjs/internal/module-loader/strip-types.cjs.map +10 -0
  69. package/dist/cjs/internal/path/index.cjs +503 -0
  70. package/dist/cjs/internal/path/index.cjs.map +10 -0
  71. package/dist/cjs/internal/playwright/client.cjs +49 -0
  72. package/dist/cjs/internal/playwright/client.cjs.map +10 -0
  73. package/dist/cjs/internal/playwright/handler.cjs +1416 -0
  74. package/dist/cjs/internal/playwright/handler.cjs.map +10 -0
  75. package/dist/cjs/internal/playwright/index.cjs +1289 -0
  76. package/dist/cjs/internal/playwright/index.cjs.map +10 -0
  77. package/dist/cjs/internal/playwright/types.cjs +47 -0
  78. package/dist/cjs/internal/playwright/types.cjs.map +10 -0
  79. package/dist/cjs/internal/protocol/codec.cjs +510 -0
  80. package/dist/cjs/internal/protocol/codec.cjs.map +10 -0
  81. package/dist/cjs/internal/protocol/framing.cjs +141 -0
  82. package/dist/cjs/internal/protocol/framing.cjs.map +10 -0
  83. package/dist/cjs/internal/protocol/index.cjs +110 -0
  84. package/dist/cjs/internal/protocol/index.cjs.map +10 -0
  85. package/dist/cjs/internal/protocol/marshalValue.cjs +518 -0
  86. package/dist/cjs/internal/protocol/marshalValue.cjs.map +10 -0
  87. package/dist/cjs/internal/protocol/serialization.cjs +109 -0
  88. package/dist/cjs/internal/protocol/serialization.cjs.map +10 -0
  89. package/dist/cjs/internal/protocol/types.cjs +181 -0
  90. package/dist/cjs/internal/protocol/types.cjs.map +10 -0
  91. package/dist/cjs/internal/runtime/index.cjs +1235 -0
  92. package/dist/cjs/internal/runtime/index.cjs.map +10 -0
  93. package/dist/cjs/internal/server/index.cjs +223 -0
  94. package/dist/cjs/internal/server/index.cjs.map +10 -0
  95. package/dist/cjs/internal/test-environment/index.cjs +1415 -0
  96. package/dist/cjs/internal/test-environment/index.cjs.map +10 -0
  97. package/dist/cjs/internal/timers/index.cjs +200 -0
  98. package/dist/cjs/internal/timers/index.cjs.map +10 -0
  99. package/dist/cjs/internal/transform/index.cjs +361 -0
  100. package/dist/cjs/internal/transform/index.cjs.map +10 -0
  101. package/dist/cjs/internal/typecheck/index.cjs +60 -0
  102. package/dist/cjs/internal/typecheck/index.cjs.map +10 -0
  103. package/dist/cjs/internal/typecheck/isolate-types.cjs +2614 -0
  104. package/dist/cjs/internal/typecheck/isolate-types.cjs.map +10 -0
  105. package/dist/cjs/internal/typecheck/typecheck.cjs +131 -0
  106. package/dist/cjs/internal/typecheck/typecheck.cjs.map +10 -0
  107. package/dist/cjs/modules/index.cjs +160 -0
  108. package/dist/cjs/modules/index.cjs.map +10 -0
  109. package/dist/cjs/package.json +5 -0
  110. package/dist/cjs/runtime/script-runtime.cjs +97 -0
  111. package/dist/cjs/runtime/script-runtime.cjs.map +10 -0
  112. package/dist/cjs/server/app-server.cjs +158 -0
  113. package/dist/cjs/server/app-server.cjs.map +10 -0
  114. package/dist/cjs/testing/integration-helpers.cjs +127 -0
  115. package/dist/cjs/testing/integration-helpers.cjs.map +10 -0
  116. package/dist/cjs/typecheck/index.cjs +96 -0
  117. package/dist/cjs/typecheck/index.cjs.map +10 -0
  118. package/dist/cjs/types.cjs +30 -0
  119. package/dist/cjs/types.cjs.map +9 -0
  120. package/dist/mjs/bridge/diagnostics.mjs +18 -0
  121. package/dist/mjs/bridge/diagnostics.mjs.map +10 -0
  122. package/dist/mjs/bridge/legacy-adapters.mjs +178 -0
  123. package/dist/mjs/bridge/legacy-adapters.mjs.map +10 -0
  124. package/dist/mjs/bridge/request-context.mjs +19 -0
  125. package/dist/mjs/bridge/request-context.mjs.map +10 -0
  126. package/dist/mjs/bridge/runtime-bindings.mjs +303 -0
  127. package/dist/mjs/bridge/runtime-bindings.mjs.map +10 -0
  128. package/dist/mjs/browser/browser-runtime.mjs +93 -0
  129. package/dist/mjs/browser/browser-runtime.mjs.map +10 -0
  130. package/dist/mjs/daemon.mjs +91 -0
  131. package/dist/mjs/daemon.mjs.map +10 -0
  132. package/dist/mjs/files/index.mjs +76 -0
  133. package/dist/mjs/files/index.mjs.map +10 -0
  134. package/dist/mjs/host/create-isolate-host.mjs +171 -0
  135. package/dist/mjs/host/create-isolate-host.mjs.map +10 -0
  136. package/dist/mjs/host/index.mjs +7 -0
  137. package/dist/mjs/host/index.mjs.map +10 -0
  138. package/dist/mjs/index.mjs +15 -0
  139. package/dist/mjs/index.mjs.map +10 -0
  140. package/dist/mjs/internal/client/connection.mjs +1872 -0
  141. package/dist/mjs/internal/client/connection.mjs.map +10 -0
  142. package/dist/mjs/internal/client/index.mjs +8 -0
  143. package/dist/mjs/internal/client/index.mjs.map +10 -0
  144. package/dist/mjs/internal/client/types.mjs +2 -0
  145. package/dist/mjs/internal/client/types.mjs.map +9 -0
  146. package/dist/mjs/internal/console/index.mjs +442 -0
  147. package/dist/mjs/internal/console/index.mjs.map +10 -0
  148. package/dist/mjs/internal/console/utils.mjs +30 -0
  149. package/dist/mjs/internal/console/utils.mjs.map +10 -0
  150. package/dist/mjs/internal/core/index.mjs +2681 -0
  151. package/dist/mjs/internal/core/index.mjs.map +10 -0
  152. package/dist/mjs/internal/crypto/index.mjs +406 -0
  153. package/dist/mjs/internal/crypto/index.mjs.map +10 -0
  154. package/dist/mjs/internal/daemon/callback-fs-handler.mjs +315 -0
  155. package/dist/mjs/internal/daemon/callback-fs-handler.mjs.map +10 -0
  156. package/dist/mjs/internal/daemon/connection.mjs +1931 -0
  157. package/dist/mjs/internal/daemon/connection.mjs.map +10 -0
  158. package/dist/mjs/internal/daemon/daemon.mjs +98 -0
  159. package/dist/mjs/internal/daemon/daemon.mjs.map +10 -0
  160. package/dist/mjs/internal/daemon/index.mjs +105 -0
  161. package/dist/mjs/internal/daemon/index.mjs.map +10 -0
  162. package/dist/mjs/internal/daemon/runtime-pool.mjs +66 -0
  163. package/dist/mjs/internal/daemon/runtime-pool.mjs.map +10 -0
  164. package/dist/mjs/internal/daemon/types.mjs +2 -0
  165. package/dist/mjs/internal/daemon/types.mjs.map +9 -0
  166. package/dist/mjs/internal/encoding/index.mjs +379 -0
  167. package/dist/mjs/internal/encoding/index.mjs.map +10 -0
  168. package/dist/mjs/internal/fetch/consistency/origins.mjs +558 -0
  169. package/dist/mjs/internal/fetch/consistency/origins.mjs.map +10 -0
  170. package/dist/mjs/internal/fetch/index.mjs +2580 -0
  171. package/dist/mjs/internal/fetch/index.mjs.map +10 -0
  172. package/dist/mjs/internal/fetch/stream-state.mjs +216 -0
  173. package/dist/mjs/internal/fetch/stream-state.mjs.map +10 -0
  174. package/dist/mjs/internal/fs/index.mjs +783 -0
  175. package/dist/mjs/internal/fs/index.mjs.map +10 -0
  176. package/dist/mjs/internal/fs/node-adapter.mjs +190 -0
  177. package/dist/mjs/internal/fs/node-adapter.mjs.map +10 -0
  178. package/dist/mjs/internal/module-loader/bundle.mjs +418 -0
  179. package/dist/mjs/internal/module-loader/bundle.mjs.map +10 -0
  180. package/dist/mjs/internal/module-loader/index.mjs +185 -0
  181. package/dist/mjs/internal/module-loader/index.mjs.map +10 -0
  182. package/dist/mjs/internal/module-loader/mappings.mjs +80 -0
  183. package/dist/mjs/internal/module-loader/mappings.mjs.map +10 -0
  184. package/dist/mjs/internal/module-loader/resolve.mjs +113 -0
  185. package/dist/mjs/internal/module-loader/resolve.mjs.map +10 -0
  186. package/dist/mjs/internal/module-loader/strip-types.mjs +172 -0
  187. package/dist/mjs/internal/module-loader/strip-types.mjs.map +10 -0
  188. package/dist/mjs/internal/path/index.mjs +463 -0
  189. package/dist/mjs/internal/path/index.mjs.map +10 -0
  190. package/dist/mjs/internal/playwright/client.mjs +13 -0
  191. package/dist/mjs/internal/playwright/client.mjs.map +10 -0
  192. package/dist/mjs/internal/playwright/handler.mjs +1378 -0
  193. package/dist/mjs/internal/playwright/handler.mjs.map +10 -0
  194. package/dist/mjs/internal/playwright/index.mjs +1234 -0
  195. package/dist/mjs/internal/playwright/index.mjs.map +10 -0
  196. package/dist/mjs/internal/playwright/types.mjs +7 -0
  197. package/dist/mjs/internal/playwright/types.mjs.map +10 -0
  198. package/dist/mjs/internal/protocol/codec.mjs +470 -0
  199. package/dist/mjs/internal/protocol/codec.mjs.map +10 -0
  200. package/dist/mjs/internal/protocol/framing.mjs +101 -0
  201. package/dist/mjs/internal/protocol/framing.mjs.map +10 -0
  202. package/dist/mjs/internal/protocol/index.mjs +98 -0
  203. package/dist/mjs/internal/protocol/index.mjs.map +10 -0
  204. package/dist/mjs/internal/protocol/marshalValue.mjs +494 -0
  205. package/dist/mjs/internal/protocol/marshalValue.mjs.map +10 -0
  206. package/dist/mjs/internal/protocol/serialization.mjs +69 -0
  207. package/dist/mjs/internal/protocol/serialization.mjs.map +10 -0
  208. package/dist/mjs/internal/protocol/types.mjs +141 -0
  209. package/dist/mjs/internal/protocol/types.mjs.map +10 -0
  210. package/dist/mjs/internal/runtime/index.mjs +1198 -0
  211. package/dist/mjs/internal/runtime/index.mjs.map +10 -0
  212. package/dist/mjs/internal/server/index.mjs +183 -0
  213. package/dist/mjs/internal/server/index.mjs.map +10 -0
  214. package/dist/mjs/internal/test-environment/index.mjs +1351 -0
  215. package/dist/mjs/internal/test-environment/index.mjs.map +10 -0
  216. package/dist/mjs/internal/timers/index.mjs +136 -0
  217. package/dist/mjs/internal/timers/index.mjs.map +10 -0
  218. package/dist/mjs/internal/transform/index.mjs +321 -0
  219. package/dist/mjs/internal/transform/index.mjs.map +10 -0
  220. package/dist/mjs/internal/typecheck/index.mjs +35 -0
  221. package/dist/mjs/internal/typecheck/index.mjs.map +10 -0
  222. package/dist/mjs/internal/typecheck/isolate-types.mjs +2574 -0
  223. package/dist/mjs/internal/typecheck/isolate-types.mjs.map +10 -0
  224. package/dist/mjs/internal/typecheck/typecheck.mjs +91 -0
  225. package/dist/mjs/internal/typecheck/typecheck.mjs.map +10 -0
  226. package/dist/mjs/modules/index.mjs +96 -0
  227. package/dist/mjs/modules/index.mjs.map +10 -0
  228. package/dist/mjs/package.json +5 -0
  229. package/dist/mjs/runtime/script-runtime.mjs +57 -0
  230. package/dist/mjs/runtime/script-runtime.mjs.map +10 -0
  231. package/dist/mjs/server/app-server.mjs +118 -0
  232. package/dist/mjs/server/app-server.mjs.map +10 -0
  233. package/dist/mjs/testing/integration-helpers.mjs +63 -0
  234. package/dist/mjs/testing/integration-helpers.mjs.map +10 -0
  235. package/dist/mjs/typecheck/index.mjs +56 -0
  236. package/dist/mjs/typecheck/index.mjs.map +10 -0
  237. package/dist/mjs/types.mjs +2 -0
  238. package/dist/mjs/types.mjs.map +9 -0
  239. package/dist/types/bridge/diagnostics.d.ts +12 -0
  240. package/dist/types/bridge/legacy-adapters.d.ts +14 -0
  241. package/dist/types/bridge/request-context.d.ts +10 -0
  242. package/dist/types/bridge/runtime-bindings.d.ts +14 -0
  243. package/dist/types/browser/browser-runtime.d.ts +3 -0
  244. package/dist/types/daemon.d.ts +2 -0
  245. package/dist/types/files/index.d.ts +5 -0
  246. package/dist/types/host/create-isolate-host.d.ts +2 -0
  247. package/dist/types/host/index.d.ts +1 -0
  248. package/dist/types/index.d.ts +5 -0
  249. package/dist/types/internal/client/connection.d.ts +9 -0
  250. package/dist/types/internal/client/index.d.ts +8 -0
  251. package/dist/types/internal/client/types.d.ts +198 -0
  252. package/dist/types/internal/console/index.d.ts +108 -0
  253. package/dist/types/internal/console/utils.d.ts +27 -0
  254. package/dist/types/internal/core/index.d.ts +119 -0
  255. package/dist/types/internal/crypto/index.d.ts +18 -0
  256. package/dist/types/internal/daemon/callback-fs-handler.d.ts +28 -0
  257. package/dist/types/internal/daemon/connection.d.ts +9 -0
  258. package/dist/types/internal/daemon/daemon.d.ts +2 -0
  259. package/dist/types/internal/daemon/index.d.ts +14 -0
  260. package/dist/types/internal/daemon/runtime-pool.d.ts +16 -0
  261. package/dist/types/internal/daemon/types.d.ts +211 -0
  262. package/dist/types/internal/encoding/index.d.ts +21 -0
  263. package/dist/types/internal/fetch/consistency/origins.d.ts +179 -0
  264. package/dist/types/internal/fetch/index.d.ts +93 -0
  265. package/dist/types/internal/fetch/stream-state.d.ts +65 -0
  266. package/dist/types/internal/fs/index.d.ts +70 -0
  267. package/dist/types/internal/fs/node-adapter.d.ts +24 -0
  268. package/dist/types/internal/module-loader/bundle.d.ts +33 -0
  269. package/dist/types/internal/module-loader/index.d.ts +30 -0
  270. package/dist/types/internal/module-loader/mappings.d.ts +47 -0
  271. package/dist/types/internal/module-loader/resolve.d.ts +26 -0
  272. package/dist/types/internal/module-loader/strip-types.d.ts +19 -0
  273. package/dist/types/internal/path/index.d.ts +23 -0
  274. package/dist/types/internal/playwright/client.d.ts +7 -0
  275. package/dist/types/internal/playwright/handler.d.ts +44 -0
  276. package/dist/types/internal/playwright/index.d.ts +14 -0
  277. package/dist/types/internal/playwright/types.d.ts +145 -0
  278. package/dist/types/internal/protocol/codec.d.ts +242 -0
  279. package/dist/types/internal/protocol/framing.d.ts +89 -0
  280. package/dist/types/internal/protocol/index.d.ts +10 -0
  281. package/dist/types/internal/protocol/marshalValue.d.ts +79 -0
  282. package/dist/types/internal/protocol/serialization.d.ts +23 -0
  283. package/dist/types/internal/protocol/types.d.ts +996 -0
  284. package/dist/types/internal/runtime/index.d.ts +200 -0
  285. package/dist/types/internal/server/index.d.ts +42 -0
  286. package/dist/types/internal/test-environment/index.d.ts +112 -0
  287. package/dist/types/internal/timers/index.d.ts +22 -0
  288. package/dist/types/internal/transform/index.d.ts +36 -0
  289. package/dist/types/internal/typecheck/index.d.ts +7 -0
  290. package/dist/types/internal/typecheck/isolate-types.d.ts +94 -0
  291. package/dist/types/internal/typecheck/typecheck.d.ts +148 -0
  292. package/dist/types/modules/index.d.ts +2 -0
  293. package/dist/types/runtime/script-runtime.d.ts +6 -0
  294. package/dist/types/server/app-server.d.ts +3 -0
  295. package/dist/types/testing/integration-helpers.d.ts +9 -0
  296. package/dist/types/typecheck/index.d.ts +8 -0
  297. package/dist/types/types.d.ts +233 -0
  298. package/package.json +74 -6
  299. package/README.md +0 -45
@@ -0,0 +1,1415 @@
1
+ var __create = Object.create;
2
+ var __getProtoOf = Object.getPrototypeOf;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ function __accessProp(key) {
8
+ return this[key];
9
+ }
10
+ var __toESMCache_node;
11
+ var __toESMCache_esm;
12
+ var __toESM = (mod, isNodeMode, target) => {
13
+ var canCache = mod != null && typeof mod === "object";
14
+ if (canCache) {
15
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
16
+ var cached = cache.get(mod);
17
+ if (cached)
18
+ return cached;
19
+ }
20
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
21
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
22
+ for (let key of __getOwnPropNames(mod))
23
+ if (!__hasOwnProp.call(to, key))
24
+ __defProp(to, key, {
25
+ get: __accessProp.bind(mod, key),
26
+ enumerable: true
27
+ });
28
+ if (canCache)
29
+ cache.set(mod, to);
30
+ return to;
31
+ };
32
+ var __toCommonJS = (from) => {
33
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
34
+ if (entry)
35
+ return entry;
36
+ entry = __defProp({}, "__esModule", { value: true });
37
+ if (from && typeof from === "object" || typeof from === "function") {
38
+ for (var key of __getOwnPropNames(from))
39
+ if (!__hasOwnProp.call(entry, key))
40
+ __defProp(entry, key, {
41
+ get: __accessProp.bind(from, key),
42
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
43
+ });
44
+ }
45
+ __moduleCache.set(from, entry);
46
+ return entry;
47
+ };
48
+ var __moduleCache;
49
+ var __returnValue = (v) => v;
50
+ function __exportSetter(name, newValue) {
51
+ this[name] = __returnValue.bind(null, newValue);
52
+ }
53
+ var __export = (target, all) => {
54
+ for (var name in all)
55
+ __defProp(target, name, {
56
+ get: all[name],
57
+ enumerable: true,
58
+ configurable: true,
59
+ set: __exportSetter.bind(all, name)
60
+ });
61
+ };
62
+
63
+ // packages/isolate/src/internal/test-environment/index.ts
64
+ var exports_test_environment = {};
65
+ __export(exports_test_environment, {
66
+ setupTestEnvironment: () => setupTestEnvironment,
67
+ runTests: () => runTests,
68
+ hasTests: () => hasTests,
69
+ getTestCount: () => getTestCount
70
+ });
71
+ module.exports = __toCommonJS(exports_test_environment);
72
+ var import_isolated_vm = __toESM(require("isolated-vm"));
73
+ var testEnvironmentCode = `
74
+ (function() {
75
+ // ============================================================
76
+ // Internal State
77
+ // ============================================================
78
+
79
+ // Mock registry and call counter
80
+ let __mockCallOrder = 0;
81
+ const __mockRegistry = [];
82
+
83
+ // Assertion counting state
84
+ let __expectedAssertions = null;
85
+ let __assertionCount = 0;
86
+ let __hasAssertionsFlag = false;
87
+
88
+ function createMockState() {
89
+ return {
90
+ calls: [],
91
+ results: [],
92
+ contexts: [],
93
+ instances: [],
94
+ invocationCallOrder: [],
95
+ lastCall: undefined,
96
+ };
97
+ }
98
+
99
+ function createSuite(name, skip = false, only = false) {
100
+ return {
101
+ name,
102
+ tests: [],
103
+ children: [],
104
+ beforeAll: [],
105
+ afterAll: [],
106
+ beforeEach: [],
107
+ afterEach: [],
108
+ skip,
109
+ only,
110
+ };
111
+ }
112
+
113
+ const rootSuite = createSuite('root');
114
+ let currentSuite = rootSuite;
115
+ const suiteStack = [rootSuite];
116
+
117
+ // Event callback (set from host)
118
+ let eventCallback = null;
119
+
120
+ function emitEvent(event) {
121
+ if (eventCallback) {
122
+ try {
123
+ eventCallback(JSON.stringify(event));
124
+ } catch (e) {
125
+ // Ignore callback errors
126
+ }
127
+ }
128
+ }
129
+
130
+ // ============================================================
131
+ // TestError class for rich error info
132
+ // ============================================================
133
+
134
+ class TestError extends Error {
135
+ constructor(message, matcherName, expected, actual) {
136
+ super(message);
137
+ this.name = 'TestError';
138
+ this.matcherName = matcherName;
139
+ this.expected = expected;
140
+ this.actual = actual;
141
+ }
142
+ }
143
+
144
+ // ============================================================
145
+ // Asymmetric Matcher Infrastructure
146
+ // ============================================================
147
+
148
+ const ASYMMETRIC_MATCHER = Symbol('asymmetricMatcher');
149
+
150
+ function isAsymmetricMatcher(obj) {
151
+ return obj && obj[ASYMMETRIC_MATCHER] === true;
152
+ }
153
+
154
+ // Deep equality with asymmetric matcher support
155
+ function asymmetricDeepEqual(a, b) {
156
+ if (isAsymmetricMatcher(b)) return b.asymmetricMatch(a);
157
+ if (isAsymmetricMatcher(a)) return a.asymmetricMatch(b);
158
+ if (a === b) return true;
159
+ if (typeof a !== typeof b) return false;
160
+ if (typeof a !== 'object' || a === null || b === null) return false;
161
+ if (Array.isArray(a) !== Array.isArray(b)) return false;
162
+ const keysA = Object.keys(a);
163
+ const keysB = Object.keys(b);
164
+ if (keysA.length !== keysB.length) return false;
165
+ for (const key of keysA) {
166
+ if (!keysB.includes(key)) return false;
167
+ if (!asymmetricDeepEqual(a[key], b[key])) return false;
168
+ }
169
+ return true;
170
+ }
171
+
172
+ // ============================================================
173
+ // Deep Equality Helper
174
+ // ============================================================
175
+
176
+ function deepEqual(a, b) {
177
+ if (a === b) return true;
178
+ if (typeof a !== typeof b) return false;
179
+ if (typeof a !== 'object' || a === null || b === null) return false;
180
+
181
+ if (Array.isArray(a) !== Array.isArray(b)) return false;
182
+
183
+ const keysA = Object.keys(a);
184
+ const keysB = Object.keys(b);
185
+ if (keysA.length !== keysB.length) return false;
186
+
187
+ for (const key of keysA) {
188
+ if (!keysB.includes(key)) return false;
189
+ if (!deepEqual(a[key], b[key])) return false;
190
+ }
191
+ return true;
192
+ }
193
+
194
+ function strictDeepEqual(a, b) {
195
+ if (a === b) return true;
196
+ if (typeof a !== typeof b) return false;
197
+ if (typeof a !== 'object' || a === null || b === null) return false;
198
+
199
+ // Check prototypes
200
+ if (Object.getPrototypeOf(a) !== Object.getPrototypeOf(b)) return false;
201
+
202
+ if (Array.isArray(a) !== Array.isArray(b)) return false;
203
+
204
+ // For arrays, check sparse arrays (holes)
205
+ if (Array.isArray(a)) {
206
+ if (a.length !== b.length) return false;
207
+ for (let i = 0; i < a.length; i++) {
208
+ const aHasIndex = i in a;
209
+ const bHasIndex = i in b;
210
+ if (aHasIndex !== bHasIndex) return false;
211
+ if (aHasIndex && !strictDeepEqual(a[i], b[i])) return false;
212
+ }
213
+ return true;
214
+ }
215
+
216
+ // Check for undefined properties vs missing properties
217
+ const keysA = Object.keys(a);
218
+ const keysB = Object.keys(b);
219
+ if (keysA.length !== keysB.length) return false;
220
+
221
+ for (const key of keysA) {
222
+ if (!keysB.includes(key)) return false;
223
+ if (!strictDeepEqual(a[key], b[key])) return false;
224
+ }
225
+
226
+ // Check for symbol properties
227
+ const symbolsA = Object.getOwnPropertySymbols(a);
228
+ const symbolsB = Object.getOwnPropertySymbols(b);
229
+ if (symbolsA.length !== symbolsB.length) return false;
230
+
231
+ for (const sym of symbolsA) {
232
+ if (!symbolsB.includes(sym)) return false;
233
+ if (!strictDeepEqual(a[sym], b[sym])) return false;
234
+ }
235
+
236
+ return true;
237
+ }
238
+
239
+ function getNestedProperty(obj, path) {
240
+ const parts = path.split('.');
241
+ let current = obj;
242
+ for (const part of parts) {
243
+ if (current == null || !(part in current)) {
244
+ return { exists: false };
245
+ }
246
+ current = current[part];
247
+ }
248
+ return { exists: true, value: current };
249
+ }
250
+
251
+ function formatValue(val) {
252
+ if (val === null) return 'null';
253
+ if (val === undefined) return 'undefined';
254
+ if (typeof val === 'string') return JSON.stringify(val);
255
+ if (typeof val === 'object') {
256
+ try {
257
+ return JSON.stringify(val);
258
+ } catch {
259
+ return String(val);
260
+ }
261
+ }
262
+ return String(val);
263
+ }
264
+
265
+ // ============================================================
266
+ // expect() Implementation
267
+ // ============================================================
268
+
269
+ function expect(actual) {
270
+ function createMatchers(negated = false) {
271
+ const assert = (condition, message, matcherName, expected) => {
272
+ __assertionCount++;
273
+ const pass = negated ? !condition : condition;
274
+ if (!pass) {
275
+ throw new TestError(message, matcherName, expected, actual);
276
+ }
277
+ };
278
+
279
+ const matchers = {
280
+ toBe(expected) {
281
+ assert(
282
+ actual === expected,
283
+ negated
284
+ ? \`Expected \${formatValue(actual)} not to be \${formatValue(expected)}\`
285
+ : \`Expected \${formatValue(actual)} to be \${formatValue(expected)}\`,
286
+ 'toBe',
287
+ expected
288
+ );
289
+ },
290
+
291
+ toEqual(expected) {
292
+ assert(
293
+ asymmetricDeepEqual(actual, expected),
294
+ negated
295
+ ? \`Expected \${formatValue(actual)} not to equal \${formatValue(expected)}\`
296
+ : \`Expected \${formatValue(actual)} to equal \${formatValue(expected)}\`,
297
+ 'toEqual',
298
+ expected
299
+ );
300
+ },
301
+
302
+ toStrictEqual(expected) {
303
+ assert(
304
+ strictDeepEqual(actual, expected),
305
+ negated
306
+ ? \`Expected \${formatValue(actual)} not to strictly equal \${formatValue(expected)}\`
307
+ : \`Expected \${formatValue(actual)} to strictly equal \${formatValue(expected)}\`,
308
+ 'toStrictEqual',
309
+ expected
310
+ );
311
+ },
312
+
313
+ toBeTruthy() {
314
+ assert(
315
+ !!actual,
316
+ negated
317
+ ? \`Expected \${formatValue(actual)} not to be truthy\`
318
+ : \`Expected \${formatValue(actual)} to be truthy\`,
319
+ 'toBeTruthy',
320
+ true
321
+ );
322
+ },
323
+
324
+ toBeFalsy() {
325
+ assert(
326
+ !actual,
327
+ negated
328
+ ? \`Expected \${formatValue(actual)} not to be falsy\`
329
+ : \`Expected \${formatValue(actual)} to be falsy\`,
330
+ 'toBeFalsy',
331
+ false
332
+ );
333
+ },
334
+
335
+ toBeNull() {
336
+ assert(
337
+ actual === null,
338
+ negated
339
+ ? \`Expected \${formatValue(actual)} not to be null\`
340
+ : \`Expected \${formatValue(actual)} to be null\`,
341
+ 'toBeNull',
342
+ null
343
+ );
344
+ },
345
+
346
+ toBeUndefined() {
347
+ assert(
348
+ actual === undefined,
349
+ negated
350
+ ? \`Expected \${formatValue(actual)} not to be undefined\`
351
+ : \`Expected \${formatValue(actual)} to be undefined\`,
352
+ 'toBeUndefined',
353
+ undefined
354
+ );
355
+ },
356
+
357
+ toBeDefined() {
358
+ assert(
359
+ actual !== undefined,
360
+ negated
361
+ ? \`Expected \${formatValue(actual)} not to be defined\`
362
+ : \`Expected \${formatValue(actual)} to be defined\`,
363
+ 'toBeDefined',
364
+ 'defined'
365
+ );
366
+ },
367
+
368
+ toContain(item) {
369
+ let contains = false;
370
+ if (Array.isArray(actual)) {
371
+ contains = actual.includes(item);
372
+ } else if (typeof actual === 'string') {
373
+ contains = actual.includes(item);
374
+ }
375
+ assert(
376
+ contains,
377
+ negated
378
+ ? \`Expected \${formatValue(actual)} not to contain \${formatValue(item)}\`
379
+ : \`Expected \${formatValue(actual)} to contain \${formatValue(item)}\`,
380
+ 'toContain',
381
+ item
382
+ );
383
+ },
384
+
385
+ toThrow(expected) {
386
+ if (typeof actual !== 'function') {
387
+ throw new Error('toThrow requires a function');
388
+ }
389
+
390
+ let threw = false;
391
+ let error = null;
392
+ try {
393
+ actual();
394
+ } catch (e) {
395
+ threw = true;
396
+ error = e;
397
+ }
398
+
399
+ if (expected !== undefined) {
400
+ const matches = threw && (
401
+ (typeof expected === 'string' && error.message.includes(expected)) ||
402
+ (expected instanceof RegExp && expected.test(error.message)) ||
403
+ (typeof expected === 'function' && error instanceof expected)
404
+ );
405
+ assert(
406
+ matches,
407
+ negated
408
+ ? \`Expected function not to throw \${formatValue(expected)}\`
409
+ : \`Expected function to throw \${formatValue(expected)}, but \${threw ? \`threw: \${error.message}\` : 'did not throw'}\`,
410
+ 'toThrow',
411
+ expected
412
+ );
413
+ } else {
414
+ assert(
415
+ threw,
416
+ negated
417
+ ? \`Expected function not to throw\`
418
+ : \`Expected function to throw\`,
419
+ 'toThrow',
420
+ 'any error'
421
+ );
422
+ }
423
+ },
424
+
425
+ toBeInstanceOf(cls) {
426
+ assert(
427
+ actual instanceof cls,
428
+ negated
429
+ ? \`Expected \${formatValue(actual)} not to be instance of \${cls.name || cls}\`
430
+ : \`Expected \${formatValue(actual)} to be instance of \${cls.name || cls}\`,
431
+ 'toBeInstanceOf',
432
+ cls.name || cls
433
+ );
434
+ },
435
+
436
+ toHaveLength(length) {
437
+ const actualLength = actual?.length;
438
+ assert(
439
+ actualLength === length,
440
+ negated
441
+ ? \`Expected length not to be \${length}, but got \${actualLength}\`
442
+ : \`Expected length to be \${length}, but got \${actualLength}\`,
443
+ 'toHaveLength',
444
+ length
445
+ );
446
+ },
447
+
448
+ toMatch(pattern) {
449
+ let matches = false;
450
+ if (typeof pattern === 'string') {
451
+ matches = actual.includes(pattern);
452
+ } else if (pattern instanceof RegExp) {
453
+ matches = pattern.test(actual);
454
+ }
455
+ assert(
456
+ matches,
457
+ negated
458
+ ? \`Expected \${formatValue(actual)} not to match \${pattern}\`
459
+ : \`Expected \${formatValue(actual)} to match \${pattern}\`,
460
+ 'toMatch',
461
+ pattern
462
+ );
463
+ },
464
+
465
+ toHaveProperty(path, value) {
466
+ const prop = getNestedProperty(actual, path);
467
+ const hasProperty = prop.exists;
468
+ const valueMatches = arguments.length < 2 || asymmetricDeepEqual(prop.value, value);
469
+
470
+ assert(
471
+ hasProperty && valueMatches,
472
+ negated
473
+ ? \`Expected \${formatValue(actual)} not to have property \${path}\${arguments.length >= 2 ? \` with value \${formatValue(value)}\` : ''}\`
474
+ : \`Expected \${formatValue(actual)} to have property \${path}\${arguments.length >= 2 ? \` with value \${formatValue(value)}\` : ''}\`,
475
+ 'toHaveProperty',
476
+ arguments.length >= 2 ? { path, value } : { path }
477
+ );
478
+ },
479
+
480
+ toBeGreaterThan(expected) {
481
+ assert(
482
+ actual > expected,
483
+ negated
484
+ ? \`Expected \${formatValue(actual)} not to be greater than \${formatValue(expected)}\`
485
+ : \`Expected \${formatValue(actual)} to be greater than \${formatValue(expected)}\`,
486
+ 'toBeGreaterThan',
487
+ expected
488
+ );
489
+ },
490
+
491
+ toBeGreaterThanOrEqual(expected) {
492
+ assert(
493
+ actual >= expected,
494
+ negated
495
+ ? \`Expected \${formatValue(actual)} not to be greater than or equal to \${formatValue(expected)}\`
496
+ : \`Expected \${formatValue(actual)} to be greater than or equal to \${formatValue(expected)}\`,
497
+ 'toBeGreaterThanOrEqual',
498
+ expected
499
+ );
500
+ },
501
+
502
+ toBeLessThan(expected) {
503
+ assert(
504
+ actual < expected,
505
+ negated
506
+ ? \`Expected \${formatValue(actual)} not to be less than \${formatValue(expected)}\`
507
+ : \`Expected \${formatValue(actual)} to be less than \${formatValue(expected)}\`,
508
+ 'toBeLessThan',
509
+ expected
510
+ );
511
+ },
512
+
513
+ toBeLessThanOrEqual(expected) {
514
+ assert(
515
+ actual <= expected,
516
+ negated
517
+ ? \`Expected \${formatValue(actual)} not to be less than or equal to \${formatValue(expected)}\`
518
+ : \`Expected \${formatValue(actual)} to be less than or equal to \${formatValue(expected)}\`,
519
+ 'toBeLessThanOrEqual',
520
+ expected
521
+ );
522
+ },
523
+
524
+ toBeCloseTo(expected, numDigits = 2) {
525
+ const precision = Math.pow(10, -numDigits) / 2;
526
+ const pass = Math.abs(actual - expected) < precision;
527
+ assert(
528
+ pass,
529
+ negated
530
+ ? \`Expected \${formatValue(actual)} not to be close to \${formatValue(expected)} (precision: \${numDigits} digits)\`
531
+ : \`Expected \${formatValue(actual)} to be close to \${formatValue(expected)} (precision: \${numDigits} digits)\`,
532
+ 'toBeCloseTo',
533
+ expected
534
+ );
535
+ },
536
+
537
+ toBeNaN() {
538
+ assert(
539
+ Number.isNaN(actual),
540
+ negated
541
+ ? \`Expected \${formatValue(actual)} not to be NaN\`
542
+ : \`Expected \${formatValue(actual)} to be NaN\`,
543
+ 'toBeNaN',
544
+ NaN
545
+ );
546
+ },
547
+
548
+ toMatchObject(expected) {
549
+ function matchesObject(obj, pattern) {
550
+ if (isAsymmetricMatcher(pattern)) return pattern.asymmetricMatch(obj);
551
+ if (typeof pattern !== 'object' || pattern === null) return obj === pattern;
552
+ if (typeof obj !== 'object' || obj === null) return false;
553
+ for (const key of Object.keys(pattern)) {
554
+ if (!(key in obj)) return false;
555
+ if (!matchesObject(obj[key], pattern[key])) return false;
556
+ }
557
+ return true;
558
+ }
559
+ assert(
560
+ matchesObject(actual, expected),
561
+ negated
562
+ ? \`Expected \${formatValue(actual)} not to match object \${formatValue(expected)}\`
563
+ : \`Expected \${formatValue(actual)} to match object \${formatValue(expected)}\`,
564
+ 'toMatchObject',
565
+ expected
566
+ );
567
+ },
568
+
569
+ toContainEqual(item) {
570
+ const contains = Array.isArray(actual) && actual.some(el => asymmetricDeepEqual(el, item));
571
+ assert(
572
+ contains,
573
+ negated
574
+ ? \`Expected array not to contain equal \${formatValue(item)}\`
575
+ : \`Expected array to contain equal \${formatValue(item)}\`,
576
+ 'toContainEqual',
577
+ item
578
+ );
579
+ },
580
+
581
+ toBeTypeOf(expectedType) {
582
+ const actualType = typeof actual;
583
+ assert(
584
+ actualType === expectedType,
585
+ negated
586
+ ? \`Expected typeof \${formatValue(actual)} not to be "\${expectedType}"\`
587
+ : \`Expected typeof \${formatValue(actual)} to be "\${expectedType}", got "\${actualType}"\`,
588
+ 'toBeTypeOf',
589
+ expectedType
590
+ );
591
+ },
592
+
593
+ // Mock matchers
594
+ toHaveBeenCalled() {
595
+ if (!actual.__isMockFunction) throw new Error('toHaveBeenCalled requires a mock function');
596
+ assert(actual.mock.calls.length > 0,
597
+ negated ? \`Expected mock not to have been called\` : \`Expected mock to have been called\`,
598
+ 'toHaveBeenCalled', 'called');
599
+ },
600
+
601
+ toHaveBeenCalledTimes(n) {
602
+ if (!actual.__isMockFunction) throw new Error('toHaveBeenCalledTimes requires a mock function');
603
+ assert(actual.mock.calls.length === n,
604
+ negated ? \`Expected mock not to have been called \${n} times\`
605
+ : \`Expected mock to be called \${n} times, got \${actual.mock.calls.length}\`,
606
+ 'toHaveBeenCalledTimes', n);
607
+ },
608
+
609
+ toHaveBeenCalledWith(...expectedArgs) {
610
+ if (!actual.__isMockFunction) throw new Error('toHaveBeenCalledWith requires a mock function');
611
+ const match = actual.mock.calls.some(args => asymmetricDeepEqual(args, expectedArgs));
612
+ assert(match,
613
+ negated ? \`Expected mock not to have been called with \${formatValue(expectedArgs)}\`
614
+ : \`Expected mock to have been called with \${formatValue(expectedArgs)}\`,
615
+ 'toHaveBeenCalledWith', expectedArgs);
616
+ },
617
+
618
+ toHaveBeenLastCalledWith(...expectedArgs) {
619
+ if (!actual.__isMockFunction) throw new Error('toHaveBeenLastCalledWith requires a mock function');
620
+ assert(actual.mock.lastCall && asymmetricDeepEqual(actual.mock.lastCall, expectedArgs),
621
+ negated ? \`Expected last call not to be \${formatValue(expectedArgs)}\`
622
+ : \`Expected last call to be \${formatValue(expectedArgs)}, got \${formatValue(actual.mock.lastCall)}\`,
623
+ 'toHaveBeenLastCalledWith', expectedArgs);
624
+ },
625
+
626
+ toHaveBeenNthCalledWith(n, ...expectedArgs) {
627
+ if (!actual.__isMockFunction) throw new Error('toHaveBeenNthCalledWith requires a mock function');
628
+ const nthCall = actual.mock.calls[n - 1];
629
+ assert(nthCall && asymmetricDeepEqual(nthCall, expectedArgs),
630
+ negated ? \`Expected call \${n} not to be \${formatValue(expectedArgs)}\`
631
+ : \`Expected call \${n} to be \${formatValue(expectedArgs)}, got \${formatValue(nthCall)}\`,
632
+ 'toHaveBeenNthCalledWith', expectedArgs);
633
+ },
634
+
635
+ toHaveReturned() {
636
+ if (!actual.__isMockFunction) throw new Error('toHaveReturned requires a mock function');
637
+ const hasReturned = actual.mock.results.some(r => r.type === 'return');
638
+ assert(hasReturned,
639
+ negated ? \`Expected mock not to have returned\` : \`Expected mock to have returned\`,
640
+ 'toHaveReturned', 'returned');
641
+ },
642
+
643
+ toHaveReturnedWith(value) {
644
+ if (!actual.__isMockFunction) throw new Error('toHaveReturnedWith requires a mock function');
645
+ const match = actual.mock.results.some(r => r.type === 'return' && asymmetricDeepEqual(r.value, value));
646
+ assert(match,
647
+ negated ? \`Expected mock not to have returned \${formatValue(value)}\`
648
+ : \`Expected mock to have returned \${formatValue(value)}\`,
649
+ 'toHaveReturnedWith', value);
650
+ },
651
+
652
+ toHaveLastReturnedWith(value) {
653
+ if (!actual.__isMockFunction) throw new Error('toHaveLastReturnedWith requires a mock function');
654
+ const returns = actual.mock.results.filter(r => r.type === 'return');
655
+ const last = returns[returns.length - 1];
656
+ assert(last && asymmetricDeepEqual(last.value, value),
657
+ negated ? \`Expected last return not to be \${formatValue(value)}\`
658
+ : \`Expected last return to be \${formatValue(value)}, got \${formatValue(last?.value)}\`,
659
+ 'toHaveLastReturnedWith', value);
660
+ },
661
+
662
+ toHaveReturnedTimes(n) {
663
+ if (!actual.__isMockFunction) throw new Error('toHaveReturnedTimes requires a mock function');
664
+ const returnCount = actual.mock.results.filter(r => r.type === 'return').length;
665
+ assert(returnCount === n,
666
+ negated ? \`Expected mock not to have returned \${n} times\`
667
+ : \`Expected mock to have returned \${n} times, got \${returnCount}\`,
668
+ 'toHaveReturnedTimes', n);
669
+ },
670
+
671
+ toHaveNthReturnedWith(n, value) {
672
+ if (!actual.__isMockFunction) throw new Error('toHaveNthReturnedWith requires a mock function');
673
+ const returns = actual.mock.results.filter(r => r.type === 'return');
674
+ const nthReturn = returns[n - 1];
675
+ assert(nthReturn && asymmetricDeepEqual(nthReturn.value, value),
676
+ negated ? \`Expected return \${n} not to be \${formatValue(value)}\`
677
+ : \`Expected return \${n} to be \${formatValue(value)}, got \${formatValue(nthReturn?.value)}\`,
678
+ 'toHaveNthReturnedWith', value);
679
+ },
680
+ };
681
+
682
+ return matchers;
683
+ }
684
+
685
+ const matchers = createMatchers(false);
686
+ matchers.not = createMatchers(true);
687
+
688
+ // Promise matchers using Proxy
689
+ matchers.resolves = new Proxy({}, {
690
+ get(_, matcherName) {
691
+ if (matcherName === 'not') {
692
+ return new Proxy({}, {
693
+ get(_, negatedMatcherName) {
694
+ return async (...args) => {
695
+ const result = await actual;
696
+ return expect(result).not[negatedMatcherName](...args);
697
+ };
698
+ }
699
+ });
700
+ }
701
+ return async (...args) => {
702
+ const result = await actual;
703
+ return expect(result)[matcherName](...args);
704
+ };
705
+ }
706
+ });
707
+
708
+ matchers.rejects = new Proxy({}, {
709
+ get(_, matcherName) {
710
+ if (matcherName === 'not') {
711
+ return new Proxy({}, {
712
+ get(_, negatedMatcherName) {
713
+ return async (...args) => {
714
+ let error;
715
+ try {
716
+ await actual;
717
+ throw new TestError('Expected promise to reject', 'rejects', 'rejection', undefined);
718
+ } catch (e) {
719
+ if (e instanceof TestError && e.matcherName === 'rejects') throw e;
720
+ error = e;
721
+ }
722
+ return expect(error).not[negatedMatcherName](...args);
723
+ };
724
+ }
725
+ });
726
+ }
727
+ return async (...args) => {
728
+ let error;
729
+ try {
730
+ await actual;
731
+ throw new TestError('Expected promise to reject', 'rejects', 'rejection', undefined);
732
+ } catch (e) {
733
+ if (e instanceof TestError && e.matcherName === 'rejects') throw e;
734
+ error = e;
735
+ }
736
+ return expect(error)[matcherName](...args);
737
+ };
738
+ }
739
+ });
740
+
741
+ return matchers;
742
+ }
743
+
744
+ // Asymmetric matcher implementations
745
+ expect.anything = () => ({
746
+ [ASYMMETRIC_MATCHER]: true,
747
+ asymmetricMatch: (other) => other !== null && other !== undefined,
748
+ toString: () => 'anything()',
749
+ });
750
+
751
+ expect.any = (constructor) => ({
752
+ [ASYMMETRIC_MATCHER]: true,
753
+ asymmetricMatch: (other) => {
754
+ if (constructor === String) return typeof other === 'string' || other instanceof String;
755
+ if (constructor === Number) return typeof other === 'number' || other instanceof Number;
756
+ if (constructor === Boolean) return typeof other === 'boolean' || other instanceof Boolean;
757
+ if (constructor === Function) return typeof other === 'function';
758
+ if (constructor === Object) return typeof other === 'object' && other !== null;
759
+ if (constructor === Array) return Array.isArray(other);
760
+ return other instanceof constructor;
761
+ },
762
+ toString: () => \`any(\${constructor.name || constructor})\`,
763
+ });
764
+
765
+ expect.stringContaining = (str) => ({
766
+ [ASYMMETRIC_MATCHER]: true,
767
+ asymmetricMatch: (other) => typeof other === 'string' && other.includes(str),
768
+ toString: () => \`stringContaining("\${str}")\`,
769
+ });
770
+
771
+ expect.stringMatching = (pattern) => ({
772
+ [ASYMMETRIC_MATCHER]: true,
773
+ asymmetricMatch: (other) => {
774
+ if (typeof other !== 'string') return false;
775
+ return typeof pattern === 'string' ? other.includes(pattern) : pattern.test(other);
776
+ },
777
+ toString: () => \`stringMatching(\${pattern})\`,
778
+ });
779
+
780
+ expect.arrayContaining = (expected) => ({
781
+ [ASYMMETRIC_MATCHER]: true,
782
+ asymmetricMatch: (other) => {
783
+ if (!Array.isArray(other)) return false;
784
+ return expected.every(exp => other.some(item => asymmetricDeepEqual(item, exp)));
785
+ },
786
+ toString: () => \`arrayContaining(\${formatValue(expected)})\`,
787
+ });
788
+
789
+ expect.objectContaining = (expected) => ({
790
+ [ASYMMETRIC_MATCHER]: true,
791
+ asymmetricMatch: (other) => {
792
+ if (typeof other !== 'object' || other === null) return false;
793
+ for (const key of Object.keys(expected)) {
794
+ if (!(key in other)) return false;
795
+ if (!asymmetricDeepEqual(other[key], expected[key])) return false;
796
+ }
797
+ return true;
798
+ },
799
+ toString: () => \`objectContaining(\${formatValue(expected)})\`,
800
+ });
801
+
802
+ // Assertion counting
803
+ expect.assertions = (n) => {
804
+ __expectedAssertions = n;
805
+ };
806
+
807
+ expect.hasAssertions = () => {
808
+ __hasAssertionsFlag = true;
809
+ };
810
+
811
+ // ============================================================
812
+ // Test Registration Functions
813
+ // ============================================================
814
+
815
+ function describe(name, fn) {
816
+ const suite = createSuite(name);
817
+ currentSuite.children.push(suite);
818
+
819
+ const parentSuite = currentSuite;
820
+ currentSuite = suite;
821
+ suiteStack.push(suite);
822
+
823
+ fn();
824
+
825
+ suiteStack.pop();
826
+ currentSuite = parentSuite;
827
+ }
828
+
829
+ describe.skip = function(name, fn) {
830
+ const suite = createSuite(name, true, false);
831
+ currentSuite.children.push(suite);
832
+
833
+ const parentSuite = currentSuite;
834
+ currentSuite = suite;
835
+ suiteStack.push(suite);
836
+
837
+ fn();
838
+
839
+ suiteStack.pop();
840
+ currentSuite = parentSuite;
841
+ };
842
+
843
+ describe.only = function(name, fn) {
844
+ const suite = createSuite(name, false, true);
845
+ currentSuite.children.push(suite);
846
+
847
+ const parentSuite = currentSuite;
848
+ currentSuite = suite;
849
+ suiteStack.push(suite);
850
+
851
+ fn();
852
+
853
+ suiteStack.pop();
854
+ currentSuite = parentSuite;
855
+ };
856
+
857
+ function test(name, fn) {
858
+ currentSuite.tests.push({
859
+ name,
860
+ fn,
861
+ skip: false,
862
+ only: false,
863
+ });
864
+ }
865
+
866
+ test.skip = function(name, fn) {
867
+ currentSuite.tests.push({
868
+ name,
869
+ fn,
870
+ skip: true,
871
+ only: false,
872
+ });
873
+ };
874
+
875
+ test.only = function(name, fn) {
876
+ currentSuite.tests.push({
877
+ name,
878
+ fn,
879
+ skip: false,
880
+ only: true,
881
+ });
882
+ };
883
+
884
+ test.todo = function(name) {
885
+ currentSuite.tests.push({
886
+ name,
887
+ fn: null,
888
+ skip: false,
889
+ only: false,
890
+ todo: true,
891
+ });
892
+ };
893
+
894
+ const it = test;
895
+ it.skip = test.skip;
896
+ it.only = test.only;
897
+ it.todo = test.todo;
898
+
899
+ // ============================================================
900
+ // Lifecycle Hooks
901
+ // ============================================================
902
+
903
+ function beforeEach(fn) {
904
+ currentSuite.beforeEach.push(fn);
905
+ }
906
+
907
+ function afterEach(fn) {
908
+ currentSuite.afterEach.push(fn);
909
+ }
910
+
911
+ function beforeAll(fn) {
912
+ currentSuite.beforeAll.push(fn);
913
+ }
914
+
915
+ function afterAll(fn) {
916
+ currentSuite.afterAll.push(fn);
917
+ }
918
+
919
+ // ============================================================
920
+ // Mock Implementation
921
+ // ============================================================
922
+
923
+ const mock = {
924
+ fn(implementation) {
925
+ const mockState = createMockState();
926
+ let defaultImpl = implementation;
927
+ const onceImpls = [];
928
+ const onceReturns = [];
929
+ let returnVal, resolvedVal, rejectedVal;
930
+ let returnSet = false, resolvedSet = false, rejectedSet = false;
931
+
932
+ function mockFn(...args) {
933
+ mockState.calls.push(args);
934
+ mockState.contexts.push(this);
935
+ mockState.lastCall = args;
936
+ mockState.invocationCallOrder.push(++__mockCallOrder);
937
+
938
+ let result;
939
+ try {
940
+ if (onceImpls.length > 0) {
941
+ result = onceImpls.shift().apply(this, args);
942
+ } else if (onceReturns.length > 0) {
943
+ result = onceReturns.shift();
944
+ } else if (returnSet) {
945
+ result = returnVal;
946
+ } else if (resolvedSet) {
947
+ result = Promise.resolve(resolvedVal);
948
+ } else if (rejectedSet) {
949
+ result = Promise.reject(rejectedVal);
950
+ } else if (defaultImpl) {
951
+ result = defaultImpl.apply(this, args);
952
+ }
953
+ mockState.results.push({ type: 'return', value: result });
954
+ return result;
955
+ } catch (e) {
956
+ mockState.results.push({ type: 'throw', value: e });
957
+ throw e;
958
+ }
959
+ }
960
+
961
+ mockFn.__isMockFunction = true;
962
+ mockFn.mock = mockState;
963
+
964
+ // Configuration methods
965
+ mockFn.mockReturnValue = (v) => { returnVal = v; returnSet = true; return mockFn; };
966
+ mockFn.mockReturnValueOnce = (v) => { onceReturns.push(v); return mockFn; };
967
+ mockFn.mockResolvedValue = (v) => { resolvedVal = v; resolvedSet = true; return mockFn; };
968
+ mockFn.mockRejectedValue = (v) => { rejectedVal = v; rejectedSet = true; return mockFn; };
969
+ mockFn.mockImplementation = (fn) => { defaultImpl = fn; return mockFn; };
970
+ mockFn.mockImplementationOnce = (fn) => { onceImpls.push(fn); return mockFn; };
971
+
972
+ // Clearing methods
973
+ mockFn.mockClear = () => {
974
+ mockState.calls = []; mockState.results = []; mockState.contexts = [];
975
+ mockState.instances = []; mockState.invocationCallOrder = []; mockState.lastCall = undefined;
976
+ return mockFn;
977
+ };
978
+ mockFn.mockReset = () => {
979
+ mockFn.mockClear();
980
+ defaultImpl = undefined; returnVal = resolvedVal = rejectedVal = undefined;
981
+ returnSet = resolvedSet = rejectedSet = false;
982
+ onceImpls.length = 0; onceReturns.length = 0;
983
+ return mockFn;
984
+ };
985
+ mockFn.mockRestore = () => mockFn.mockReset();
986
+
987
+ __mockRegistry.push(mockFn);
988
+ return mockFn;
989
+ },
990
+
991
+ spyOn(object, methodName) {
992
+ const original = object[methodName];
993
+ if (typeof original !== 'function') {
994
+ throw new Error(\`Cannot spy on \${methodName}: not a function\`);
995
+ }
996
+ const spy = mock.fn(original);
997
+ spy.__originalMethod = original;
998
+ spy.__spyTarget = object;
999
+ spy.__spyMethodName = methodName;
1000
+ spy.__isSpyFunction = true;
1001
+ spy.mockRestore = () => {
1002
+ object[methodName] = original;
1003
+ const idx = __mockRegistry.indexOf(spy);
1004
+ if (idx !== -1) __mockRegistry.splice(idx, 1);
1005
+ return spy;
1006
+ };
1007
+ object[methodName] = spy;
1008
+ return spy;
1009
+ },
1010
+
1011
+ clearAllMocks() {
1012
+ for (const fn of __mockRegistry) fn.mockClear();
1013
+ },
1014
+
1015
+ resetAllMocks() {
1016
+ for (const fn of __mockRegistry) fn.mockReset();
1017
+ },
1018
+
1019
+ restoreAllMocks() {
1020
+ for (let i = __mockRegistry.length - 1; i >= 0; i--) {
1021
+ if (__mockRegistry[i].__isSpyFunction) __mockRegistry[i].mockRestore();
1022
+ }
1023
+ },
1024
+ };
1025
+
1026
+ // ============================================================
1027
+ // Test Runner Helpers
1028
+ // ============================================================
1029
+
1030
+ function checkForOnly(suite) {
1031
+ if (suite.only) return true;
1032
+ for (const t of suite.tests) {
1033
+ if (t.only) return true;
1034
+ }
1035
+ for (const child of suite.children) {
1036
+ if (checkForOnly(child)) return true;
1037
+ }
1038
+ return false;
1039
+ }
1040
+
1041
+ function suiteHasOnly(suite) {
1042
+ if (suite.only) return true;
1043
+ for (const t of suite.tests) {
1044
+ if (t.only) return true;
1045
+ }
1046
+ for (const child of suite.children) {
1047
+ if (suiteHasOnly(child)) return true;
1048
+ }
1049
+ return false;
1050
+ }
1051
+
1052
+ function countTests(suite, hasOnly) {
1053
+ let count = 0;
1054
+ if (hasOnly && !suiteHasOnly(suite)) return 0;
1055
+ if (suite.skip) return suite.tests.length;
1056
+
1057
+ for (const t of suite.tests) {
1058
+ if (hasOnly && !t.only && !suite.only) continue;
1059
+ count++;
1060
+ }
1061
+ for (const child of suite.children) {
1062
+ count += countTests(child, hasOnly);
1063
+ }
1064
+ return count;
1065
+ }
1066
+
1067
+ function countSuites(suite, hasOnly) {
1068
+ let count = 0;
1069
+ if (hasOnly && !suiteHasOnly(suite)) return 0;
1070
+
1071
+ for (const child of suite.children) {
1072
+ count++;
1073
+ count += countSuites(child, hasOnly);
1074
+ }
1075
+ return count;
1076
+ }
1077
+
1078
+ // ============================================================
1079
+ // Test Runner
1080
+ // ============================================================
1081
+
1082
+ async function __runAllTests() {
1083
+ const testResults = [];
1084
+ const suiteResults = [];
1085
+ const hasOnly = checkForOnly(rootSuite);
1086
+ const runStart = Date.now();
1087
+
1088
+ // Emit runStart
1089
+ const testCount = countTests(rootSuite, hasOnly);
1090
+ const suiteCount = countSuites(rootSuite, hasOnly);
1091
+ emitEvent({ type: 'runStart', testCount, suiteCount });
1092
+
1093
+ async function runSuite(suite, parentHooks, pathArray, depth) {
1094
+ // Skip if this suite doesn't have any .only when .only exists elsewhere
1095
+ if (hasOnly && !suiteHasOnly(suite)) return;
1096
+
1097
+ const suitePath = [...pathArray];
1098
+ const fullName = suitePath.join(' > ');
1099
+ const suiteInfo = {
1100
+ name: suite.name,
1101
+ path: suitePath.slice(0, -1),
1102
+ fullName,
1103
+ depth,
1104
+ };
1105
+
1106
+ // Emit suiteStart (only for non-root suites)
1107
+ if (suite !== rootSuite) {
1108
+ emitEvent({ type: 'suiteStart', suite: suiteInfo });
1109
+ }
1110
+
1111
+ const suiteStart = Date.now();
1112
+ let suitePassed = 0;
1113
+ let suiteFailed = 0;
1114
+ let suiteSkipped = 0;
1115
+ let suiteTodo = 0;
1116
+
1117
+ // Skip if suite is marked as skip
1118
+ if (suite.skip) {
1119
+ // Mark all tests in this suite as skipped
1120
+ for (const t of suite.tests) {
1121
+ const testFullName = fullName ? fullName + ' > ' + t.name : t.name;
1122
+ const testInfo = {
1123
+ name: t.name,
1124
+ suitePath: suitePath,
1125
+ fullName: testFullName,
1126
+ };
1127
+ emitEvent({ type: 'testStart', test: testInfo });
1128
+
1129
+ const testResult = {
1130
+ name: t.name,
1131
+ suitePath: suitePath,
1132
+ fullName: testFullName,
1133
+ status: 'skip',
1134
+ duration: 0,
1135
+ };
1136
+ testResults.push(testResult);
1137
+ suiteSkipped++;
1138
+
1139
+ emitEvent({ type: 'testEnd', test: testResult });
1140
+ }
1141
+ } else {
1142
+ // Run beforeAll hooks
1143
+ for (const hook of suite.beforeAll) {
1144
+ await hook();
1145
+ }
1146
+
1147
+ // Run tests
1148
+ for (const t of suite.tests) {
1149
+ const testFullName = fullName ? fullName + ' > ' + t.name : t.name;
1150
+ const testInfo = {
1151
+ name: t.name,
1152
+ suitePath: suitePath,
1153
+ fullName: testFullName,
1154
+ };
1155
+
1156
+ // Skip if .only is used and this test isn't .only AND the suite doesn't have .only
1157
+ if (hasOnly && !t.only && !suite.only) continue;
1158
+
1159
+ emitEvent({ type: 'testStart', test: testInfo });
1160
+
1161
+ // Skip if test is marked as skip
1162
+ if (t.skip) {
1163
+ const testResult = {
1164
+ name: t.name,
1165
+ suitePath: suitePath,
1166
+ fullName: testFullName,
1167
+ status: 'skip',
1168
+ duration: 0,
1169
+ };
1170
+ testResults.push(testResult);
1171
+ suiteSkipped++;
1172
+ emitEvent({ type: 'testEnd', test: testResult });
1173
+ continue;
1174
+ }
1175
+
1176
+ // Handle todo tests (no function provided)
1177
+ if (t.todo) {
1178
+ const testResult = {
1179
+ name: t.name,
1180
+ suitePath: suitePath,
1181
+ fullName: testFullName,
1182
+ status: 'todo',
1183
+ duration: 0,
1184
+ };
1185
+ testResults.push(testResult);
1186
+ suiteTodo++;
1187
+ emitEvent({ type: 'testEnd', test: testResult });
1188
+ continue;
1189
+ }
1190
+
1191
+ const testStart = Date.now();
1192
+ // Reset assertion counting state before each test
1193
+ __expectedAssertions = null;
1194
+ __assertionCount = 0;
1195
+ __hasAssertionsFlag = false;
1196
+
1197
+ try {
1198
+ // Run all beforeEach hooks (parent first, then current)
1199
+ for (const hook of [...parentHooks.beforeEach, ...suite.beforeEach]) {
1200
+ await hook();
1201
+ }
1202
+
1203
+ // Run test
1204
+ await t.fn();
1205
+
1206
+ // Run all afterEach hooks (current first, then parent)
1207
+ for (const hook of [...suite.afterEach, ...parentHooks.afterEach]) {
1208
+ await hook();
1209
+ }
1210
+
1211
+ // Verify assertion counts after test passes
1212
+ if (__hasAssertionsFlag && __assertionCount === 0) {
1213
+ throw new TestError('Expected at least one assertion', 'hasAssertions', '>0', 0);
1214
+ }
1215
+ if (__expectedAssertions !== null && __assertionCount !== __expectedAssertions) {
1216
+ throw new TestError(
1217
+ \`Expected \${__expectedAssertions} assertions, got \${__assertionCount}\`,
1218
+ 'assertions', __expectedAssertions, __assertionCount
1219
+ );
1220
+ }
1221
+
1222
+ const testResult = {
1223
+ name: t.name,
1224
+ suitePath: suitePath,
1225
+ fullName: testFullName,
1226
+ status: 'pass',
1227
+ duration: Date.now() - testStart,
1228
+ };
1229
+ testResults.push(testResult);
1230
+ suitePassed++;
1231
+ emitEvent({ type: 'testEnd', test: testResult });
1232
+ } catch (err) {
1233
+ const testError = {
1234
+ message: err.message || String(err),
1235
+ stack: err.stack,
1236
+ };
1237
+ // If it's a TestError, include matcher info
1238
+ if (err.matcherName !== undefined) {
1239
+ testError.matcherName = err.matcherName;
1240
+ testError.expected = err.expected;
1241
+ testError.actual = err.actual;
1242
+ }
1243
+ const testResult = {
1244
+ name: t.name,
1245
+ suitePath: suitePath,
1246
+ fullName: testFullName,
1247
+ status: 'fail',
1248
+ duration: Date.now() - testStart,
1249
+ error: testError,
1250
+ };
1251
+ testResults.push(testResult);
1252
+ suiteFailed++;
1253
+ emitEvent({ type: 'testEnd', test: testResult });
1254
+ }
1255
+ }
1256
+
1257
+ // Run child suites
1258
+ for (const child of suite.children) {
1259
+ const childPath = [...suitePath, child.name];
1260
+ await runSuite(child, {
1261
+ beforeEach: [...parentHooks.beforeEach, ...suite.beforeEach],
1262
+ afterEach: [...suite.afterEach, ...parentHooks.afterEach],
1263
+ }, childPath, depth + 1);
1264
+ }
1265
+
1266
+ // Run afterAll hooks
1267
+ for (const hook of suite.afterAll) {
1268
+ await hook();
1269
+ }
1270
+ }
1271
+
1272
+ // Emit suiteEnd (only for non-root suites)
1273
+ if (suite !== rootSuite) {
1274
+ const suiteResult = {
1275
+ ...suiteInfo,
1276
+ passed: suitePassed,
1277
+ failed: suiteFailed,
1278
+ skipped: suiteSkipped,
1279
+ todo: suiteTodo,
1280
+ duration: Date.now() - suiteStart,
1281
+ };
1282
+ suiteResults.push(suiteResult);
1283
+ emitEvent({ type: 'suiteEnd', suite: suiteResult });
1284
+ }
1285
+ }
1286
+
1287
+ await runSuite(rootSuite, { beforeEach: [], afterEach: [] }, [], -1);
1288
+
1289
+ const passed = testResults.filter(r => r.status === 'pass').length;
1290
+ const failed = testResults.filter(r => r.status === 'fail').length;
1291
+ const skipped = testResults.filter(r => r.status === 'skip').length;
1292
+ const todo = testResults.filter(r => r.status === 'todo').length;
1293
+
1294
+ const runResults = {
1295
+ passed,
1296
+ failed,
1297
+ skipped,
1298
+ todo,
1299
+ total: testResults.length,
1300
+ duration: Date.now() - runStart,
1301
+ success: failed === 0,
1302
+ suites: suiteResults,
1303
+ tests: testResults,
1304
+ };
1305
+
1306
+ emitEvent({ type: 'runEnd', results: runResults });
1307
+
1308
+ return JSON.stringify(runResults);
1309
+ }
1310
+
1311
+ // ============================================================
1312
+ // Helper Functions
1313
+ // ============================================================
1314
+
1315
+ function __hasTests() {
1316
+ function checkSuite(suite) {
1317
+ if (suite.tests.length > 0) return true;
1318
+ for (const child of suite.children) {
1319
+ if (checkSuite(child)) return true;
1320
+ }
1321
+ return false;
1322
+ }
1323
+ return checkSuite(rootSuite);
1324
+ }
1325
+
1326
+ function __getTestCount() {
1327
+ function countInSuite(suite) {
1328
+ let count = suite.tests.length;
1329
+ for (const child of suite.children) {
1330
+ count += countInSuite(child);
1331
+ }
1332
+ return count;
1333
+ }
1334
+ return countInSuite(rootSuite);
1335
+ }
1336
+
1337
+ // Reset function to clear state between runs
1338
+ function __resetTestEnvironment() {
1339
+ rootSuite.tests = [];
1340
+ rootSuite.children = [];
1341
+ rootSuite.beforeAll = [];
1342
+ rootSuite.afterAll = [];
1343
+ rootSuite.beforeEach = [];
1344
+ rootSuite.afterEach = [];
1345
+ currentSuite = rootSuite;
1346
+ suiteStack.length = 0;
1347
+ suiteStack.push(rootSuite);
1348
+ // Clear mocks
1349
+ __mockCallOrder = 0;
1350
+ mock.restoreAllMocks();
1351
+ __mockRegistry.length = 0;
1352
+ }
1353
+
1354
+ function __setEventCallback(callback) {
1355
+ eventCallback = callback;
1356
+ }
1357
+
1358
+ // ============================================================
1359
+ // Expose Globals
1360
+ // ============================================================
1361
+
1362
+ globalThis.describe = describe;
1363
+ globalThis.test = test;
1364
+ globalThis.it = it;
1365
+ globalThis.expect = expect;
1366
+ globalThis.beforeEach = beforeEach;
1367
+ globalThis.afterEach = afterEach;
1368
+ globalThis.beforeAll = beforeAll;
1369
+ globalThis.afterAll = afterAll;
1370
+ globalThis.mock = mock;
1371
+ globalThis.jest = mock; // Jest compatibility alias
1372
+ globalThis.__runAllTests = __runAllTests;
1373
+ globalThis.__resetTestEnvironment = __resetTestEnvironment;
1374
+ globalThis.__hasTests = __hasTests;
1375
+ globalThis.__getTestCount = __getTestCount;
1376
+ globalThis.__setEventCallback = __setEventCallback;
1377
+ })();
1378
+ `;
1379
+ async function setupTestEnvironment(context, options) {
1380
+ context.evalSync(testEnvironmentCode);
1381
+ if (options?.onEvent) {
1382
+ const eventCallbackRef = new import_isolated_vm.default.Reference((eventJson) => {
1383
+ try {
1384
+ const event = JSON.parse(eventJson);
1385
+ options.onEvent(event);
1386
+ } catch {}
1387
+ });
1388
+ const global = context.global;
1389
+ global.setSync("__eventCallbackRef", eventCallbackRef);
1390
+ context.evalSync(`
1391
+ __setEventCallback((eventJson) => {
1392
+ __eventCallbackRef.applySync(undefined, [eventJson]);
1393
+ });
1394
+ `);
1395
+ }
1396
+ return {
1397
+ dispose() {
1398
+ try {
1399
+ context.evalSync("__resetTestEnvironment()");
1400
+ } catch {}
1401
+ }
1402
+ };
1403
+ }
1404
+ async function runTests(context) {
1405
+ const resultJson = await context.eval("__runAllTests()", { promise: true });
1406
+ return JSON.parse(resultJson);
1407
+ }
1408
+ function hasTests(context) {
1409
+ return context.evalSync("__hasTests()");
1410
+ }
1411
+ function getTestCount(context) {
1412
+ return context.evalSync("__getTestCount()");
1413
+ }
1414
+
1415
+ //# debugId=336CB4E94F57119564756E2164756E21