@ricsam/isolate 0.0.1 → 0.1.1

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/README.md +243 -34
  2. package/dist/cjs/bridge/diagnostics.cjs +58 -0
  3. package/dist/cjs/bridge/diagnostics.cjs.map +10 -0
  4. package/dist/cjs/bridge/legacy-adapters.cjs +242 -0
  5. package/dist/cjs/bridge/legacy-adapters.cjs.map +10 -0
  6. package/dist/cjs/bridge/request-context.cjs +59 -0
  7. package/dist/cjs/bridge/request-context.cjs.map +10 -0
  8. package/dist/cjs/bridge/runtime-bindings.cjs +367 -0
  9. package/dist/cjs/bridge/runtime-bindings.cjs.map +10 -0
  10. package/dist/cjs/browser/browser-runtime.cjs +157 -0
  11. package/dist/cjs/browser/browser-runtime.cjs.map +10 -0
  12. package/dist/cjs/daemon.cjs +91 -0
  13. package/dist/cjs/daemon.cjs.map +10 -0
  14. package/dist/cjs/files/index.cjs +140 -0
  15. package/dist/cjs/files/index.cjs.map +10 -0
  16. package/dist/cjs/host/create-isolate-host.cjs +235 -0
  17. package/dist/cjs/host/create-isolate-host.cjs.map +10 -0
  18. package/dist/cjs/host/index.cjs +47 -0
  19. package/dist/cjs/host/index.cjs.map +10 -0
  20. package/dist/cjs/index.cjs +55 -0
  21. package/dist/cjs/index.cjs.map +10 -0
  22. package/dist/cjs/internal/client/connection.cjs +1919 -0
  23. package/dist/cjs/internal/client/connection.cjs.map +10 -0
  24. package/dist/cjs/internal/client/index.cjs +48 -0
  25. package/dist/cjs/internal/client/index.cjs.map +10 -0
  26. package/dist/cjs/internal/client/types.cjs +30 -0
  27. package/dist/cjs/internal/client/types.cjs.map +9 -0
  28. package/dist/cjs/internal/console/index.cjs +506 -0
  29. package/dist/cjs/internal/console/index.cjs.map +10 -0
  30. package/dist/cjs/internal/console/utils.cjs +70 -0
  31. package/dist/cjs/internal/console/utils.cjs.map +10 -0
  32. package/dist/cjs/internal/core/index.cjs +2745 -0
  33. package/dist/cjs/internal/core/index.cjs.map +10 -0
  34. package/dist/cjs/internal/crypto/index.cjs +470 -0
  35. package/dist/cjs/internal/crypto/index.cjs.map +10 -0
  36. package/dist/cjs/internal/daemon/callback-fs-handler.cjs +355 -0
  37. package/dist/cjs/internal/daemon/callback-fs-handler.cjs.map +10 -0
  38. package/dist/cjs/internal/daemon/connection.cjs +1952 -0
  39. package/dist/cjs/internal/daemon/connection.cjs.map +10 -0
  40. package/dist/cjs/internal/daemon/daemon.cjs +98 -0
  41. package/dist/cjs/internal/daemon/daemon.cjs.map +10 -0
  42. package/dist/cjs/internal/daemon/index.cjs +145 -0
  43. package/dist/cjs/internal/daemon/index.cjs.map +10 -0
  44. package/dist/cjs/internal/daemon/runtime-pool.cjs +106 -0
  45. package/dist/cjs/internal/daemon/runtime-pool.cjs.map +10 -0
  46. package/dist/cjs/internal/daemon/types.cjs +30 -0
  47. package/dist/cjs/internal/daemon/types.cjs.map +9 -0
  48. package/dist/cjs/internal/encoding/index.cjs +419 -0
  49. package/dist/cjs/internal/encoding/index.cjs.map +10 -0
  50. package/dist/cjs/internal/fetch/consistency/origins.cjs +598 -0
  51. package/dist/cjs/internal/fetch/consistency/origins.cjs.map +10 -0
  52. package/dist/cjs/internal/fetch/index.cjs +2640 -0
  53. package/dist/cjs/internal/fetch/index.cjs.map +10 -0
  54. package/dist/cjs/internal/fetch/stream-state.cjs +256 -0
  55. package/dist/cjs/internal/fetch/stream-state.cjs.map +10 -0
  56. package/dist/cjs/internal/fs/index.cjs +847 -0
  57. package/dist/cjs/internal/fs/index.cjs.map +10 -0
  58. package/dist/cjs/internal/fs/node-adapter.cjs +254 -0
  59. package/dist/cjs/internal/fs/node-adapter.cjs.map +10 -0
  60. package/dist/cjs/internal/module-loader/bundle.cjs +482 -0
  61. package/dist/cjs/internal/module-loader/bundle.cjs.map +10 -0
  62. package/dist/cjs/internal/module-loader/index.cjs +240 -0
  63. package/dist/cjs/internal/module-loader/index.cjs.map +10 -0
  64. package/dist/cjs/internal/module-loader/mappings.cjs +120 -0
  65. package/dist/cjs/internal/module-loader/mappings.cjs.map +10 -0
  66. package/dist/cjs/internal/module-loader/resolve.cjs +177 -0
  67. package/dist/cjs/internal/module-loader/resolve.cjs.map +10 -0
  68. package/dist/cjs/internal/module-loader/strip-types.cjs +236 -0
  69. package/dist/cjs/internal/module-loader/strip-types.cjs.map +10 -0
  70. package/dist/cjs/internal/path/index.cjs +503 -0
  71. package/dist/cjs/internal/path/index.cjs.map +10 -0
  72. package/dist/cjs/internal/playwright/client.cjs +49 -0
  73. package/dist/cjs/internal/playwright/client.cjs.map +10 -0
  74. package/dist/cjs/internal/playwright/handler.cjs +1416 -0
  75. package/dist/cjs/internal/playwright/handler.cjs.map +10 -0
  76. package/dist/cjs/internal/playwright/index.cjs +1289 -0
  77. package/dist/cjs/internal/playwright/index.cjs.map +10 -0
  78. package/dist/cjs/internal/playwright/types.cjs +47 -0
  79. package/dist/cjs/internal/playwright/types.cjs.map +10 -0
  80. package/dist/cjs/internal/protocol/codec.cjs +510 -0
  81. package/dist/cjs/internal/protocol/codec.cjs.map +10 -0
  82. package/dist/cjs/internal/protocol/framing.cjs +141 -0
  83. package/dist/cjs/internal/protocol/framing.cjs.map +10 -0
  84. package/dist/cjs/internal/protocol/index.cjs +110 -0
  85. package/dist/cjs/internal/protocol/index.cjs.map +10 -0
  86. package/dist/cjs/internal/protocol/marshalValue.cjs +518 -0
  87. package/dist/cjs/internal/protocol/marshalValue.cjs.map +10 -0
  88. package/dist/cjs/internal/protocol/serialization.cjs +109 -0
  89. package/dist/cjs/internal/protocol/serialization.cjs.map +10 -0
  90. package/dist/cjs/internal/protocol/types.cjs +181 -0
  91. package/dist/cjs/internal/protocol/types.cjs.map +10 -0
  92. package/dist/cjs/internal/runtime/index.cjs +1235 -0
  93. package/dist/cjs/internal/runtime/index.cjs.map +10 -0
  94. package/dist/cjs/internal/server/index.cjs +223 -0
  95. package/dist/cjs/internal/server/index.cjs.map +10 -0
  96. package/dist/cjs/internal/test-environment/index.cjs +1415 -0
  97. package/dist/cjs/internal/test-environment/index.cjs.map +10 -0
  98. package/dist/cjs/internal/timers/index.cjs +200 -0
  99. package/dist/cjs/internal/timers/index.cjs.map +10 -0
  100. package/dist/cjs/internal/transform/index.cjs +361 -0
  101. package/dist/cjs/internal/transform/index.cjs.map +10 -0
  102. package/dist/cjs/internal/typecheck/index.cjs +60 -0
  103. package/dist/cjs/internal/typecheck/index.cjs.map +10 -0
  104. package/dist/cjs/internal/typecheck/isolate-types.cjs +2614 -0
  105. package/dist/cjs/internal/typecheck/isolate-types.cjs.map +10 -0
  106. package/dist/cjs/internal/typecheck/typecheck.cjs +131 -0
  107. package/dist/cjs/internal/typecheck/typecheck.cjs.map +10 -0
  108. package/dist/cjs/modules/index.cjs +160 -0
  109. package/dist/cjs/modules/index.cjs.map +10 -0
  110. package/dist/cjs/package.json +5 -0
  111. package/dist/cjs/runtime/script-runtime.cjs +97 -0
  112. package/dist/cjs/runtime/script-runtime.cjs.map +10 -0
  113. package/dist/cjs/server/app-server.cjs +158 -0
  114. package/dist/cjs/server/app-server.cjs.map +10 -0
  115. package/dist/cjs/testing/integration-helpers.cjs +127 -0
  116. package/dist/cjs/testing/integration-helpers.cjs.map +10 -0
  117. package/dist/cjs/typecheck/index.cjs +96 -0
  118. package/dist/cjs/typecheck/index.cjs.map +10 -0
  119. package/dist/cjs/types.cjs +30 -0
  120. package/dist/cjs/types.cjs.map +9 -0
  121. package/dist/mjs/bridge/diagnostics.mjs +18 -0
  122. package/dist/mjs/bridge/diagnostics.mjs.map +10 -0
  123. package/dist/mjs/bridge/legacy-adapters.mjs +178 -0
  124. package/dist/mjs/bridge/legacy-adapters.mjs.map +10 -0
  125. package/dist/mjs/bridge/request-context.mjs +19 -0
  126. package/dist/mjs/bridge/request-context.mjs.map +10 -0
  127. package/dist/mjs/bridge/runtime-bindings.mjs +303 -0
  128. package/dist/mjs/bridge/runtime-bindings.mjs.map +10 -0
  129. package/dist/mjs/browser/browser-runtime.mjs +93 -0
  130. package/dist/mjs/browser/browser-runtime.mjs.map +10 -0
  131. package/dist/mjs/daemon.mjs +91 -0
  132. package/dist/mjs/daemon.mjs.map +10 -0
  133. package/dist/mjs/files/index.mjs +76 -0
  134. package/dist/mjs/files/index.mjs.map +10 -0
  135. package/dist/mjs/host/create-isolate-host.mjs +171 -0
  136. package/dist/mjs/host/create-isolate-host.mjs.map +10 -0
  137. package/dist/mjs/host/index.mjs +7 -0
  138. package/dist/mjs/host/index.mjs.map +10 -0
  139. package/dist/mjs/index.mjs +15 -0
  140. package/dist/mjs/index.mjs.map +10 -0
  141. package/dist/mjs/internal/client/connection.mjs +1872 -0
  142. package/dist/mjs/internal/client/connection.mjs.map +10 -0
  143. package/dist/mjs/internal/client/index.mjs +8 -0
  144. package/dist/mjs/internal/client/index.mjs.map +10 -0
  145. package/dist/mjs/internal/client/types.mjs +2 -0
  146. package/dist/mjs/internal/client/types.mjs.map +9 -0
  147. package/dist/mjs/internal/console/index.mjs +442 -0
  148. package/dist/mjs/internal/console/index.mjs.map +10 -0
  149. package/dist/mjs/internal/console/utils.mjs +30 -0
  150. package/dist/mjs/internal/console/utils.mjs.map +10 -0
  151. package/dist/mjs/internal/core/index.mjs +2681 -0
  152. package/dist/mjs/internal/core/index.mjs.map +10 -0
  153. package/dist/mjs/internal/crypto/index.mjs +406 -0
  154. package/dist/mjs/internal/crypto/index.mjs.map +10 -0
  155. package/dist/mjs/internal/daemon/callback-fs-handler.mjs +315 -0
  156. package/dist/mjs/internal/daemon/callback-fs-handler.mjs.map +10 -0
  157. package/dist/mjs/internal/daemon/connection.mjs +1931 -0
  158. package/dist/mjs/internal/daemon/connection.mjs.map +10 -0
  159. package/dist/mjs/internal/daemon/daemon.mjs +98 -0
  160. package/dist/mjs/internal/daemon/daemon.mjs.map +10 -0
  161. package/dist/mjs/internal/daemon/index.mjs +105 -0
  162. package/dist/mjs/internal/daemon/index.mjs.map +10 -0
  163. package/dist/mjs/internal/daemon/runtime-pool.mjs +66 -0
  164. package/dist/mjs/internal/daemon/runtime-pool.mjs.map +10 -0
  165. package/dist/mjs/internal/daemon/types.mjs +2 -0
  166. package/dist/mjs/internal/daemon/types.mjs.map +9 -0
  167. package/dist/mjs/internal/encoding/index.mjs +379 -0
  168. package/dist/mjs/internal/encoding/index.mjs.map +10 -0
  169. package/dist/mjs/internal/fetch/consistency/origins.mjs +558 -0
  170. package/dist/mjs/internal/fetch/consistency/origins.mjs.map +10 -0
  171. package/dist/mjs/internal/fetch/index.mjs +2580 -0
  172. package/dist/mjs/internal/fetch/index.mjs.map +10 -0
  173. package/dist/mjs/internal/fetch/stream-state.mjs +216 -0
  174. package/dist/mjs/internal/fetch/stream-state.mjs.map +10 -0
  175. package/dist/mjs/internal/fs/index.mjs +783 -0
  176. package/dist/mjs/internal/fs/index.mjs.map +10 -0
  177. package/dist/mjs/internal/fs/node-adapter.mjs +190 -0
  178. package/dist/mjs/internal/fs/node-adapter.mjs.map +10 -0
  179. package/dist/mjs/internal/module-loader/bundle.mjs +418 -0
  180. package/dist/mjs/internal/module-loader/bundle.mjs.map +10 -0
  181. package/dist/mjs/internal/module-loader/index.mjs +185 -0
  182. package/dist/mjs/internal/module-loader/index.mjs.map +10 -0
  183. package/dist/mjs/internal/module-loader/mappings.mjs +80 -0
  184. package/dist/mjs/internal/module-loader/mappings.mjs.map +10 -0
  185. package/dist/mjs/internal/module-loader/resolve.mjs +113 -0
  186. package/dist/mjs/internal/module-loader/resolve.mjs.map +10 -0
  187. package/dist/mjs/internal/module-loader/strip-types.mjs +172 -0
  188. package/dist/mjs/internal/module-loader/strip-types.mjs.map +10 -0
  189. package/dist/mjs/internal/path/index.mjs +463 -0
  190. package/dist/mjs/internal/path/index.mjs.map +10 -0
  191. package/dist/mjs/internal/playwright/client.mjs +13 -0
  192. package/dist/mjs/internal/playwright/client.mjs.map +10 -0
  193. package/dist/mjs/internal/playwright/handler.mjs +1378 -0
  194. package/dist/mjs/internal/playwright/handler.mjs.map +10 -0
  195. package/dist/mjs/internal/playwright/index.mjs +1234 -0
  196. package/dist/mjs/internal/playwright/index.mjs.map +10 -0
  197. package/dist/mjs/internal/playwright/types.mjs +7 -0
  198. package/dist/mjs/internal/playwright/types.mjs.map +10 -0
  199. package/dist/mjs/internal/protocol/codec.mjs +470 -0
  200. package/dist/mjs/internal/protocol/codec.mjs.map +10 -0
  201. package/dist/mjs/internal/protocol/framing.mjs +101 -0
  202. package/dist/mjs/internal/protocol/framing.mjs.map +10 -0
  203. package/dist/mjs/internal/protocol/index.mjs +98 -0
  204. package/dist/mjs/internal/protocol/index.mjs.map +10 -0
  205. package/dist/mjs/internal/protocol/marshalValue.mjs +494 -0
  206. package/dist/mjs/internal/protocol/marshalValue.mjs.map +10 -0
  207. package/dist/mjs/internal/protocol/serialization.mjs +69 -0
  208. package/dist/mjs/internal/protocol/serialization.mjs.map +10 -0
  209. package/dist/mjs/internal/protocol/types.mjs +141 -0
  210. package/dist/mjs/internal/protocol/types.mjs.map +10 -0
  211. package/dist/mjs/internal/runtime/index.mjs +1198 -0
  212. package/dist/mjs/internal/runtime/index.mjs.map +10 -0
  213. package/dist/mjs/internal/server/index.mjs +183 -0
  214. package/dist/mjs/internal/server/index.mjs.map +10 -0
  215. package/dist/mjs/internal/test-environment/index.mjs +1351 -0
  216. package/dist/mjs/internal/test-environment/index.mjs.map +10 -0
  217. package/dist/mjs/internal/timers/index.mjs +136 -0
  218. package/dist/mjs/internal/timers/index.mjs.map +10 -0
  219. package/dist/mjs/internal/transform/index.mjs +321 -0
  220. package/dist/mjs/internal/transform/index.mjs.map +10 -0
  221. package/dist/mjs/internal/typecheck/index.mjs +35 -0
  222. package/dist/mjs/internal/typecheck/index.mjs.map +10 -0
  223. package/dist/mjs/internal/typecheck/isolate-types.mjs +2574 -0
  224. package/dist/mjs/internal/typecheck/isolate-types.mjs.map +10 -0
  225. package/dist/mjs/internal/typecheck/typecheck.mjs +91 -0
  226. package/dist/mjs/internal/typecheck/typecheck.mjs.map +10 -0
  227. package/dist/mjs/modules/index.mjs +96 -0
  228. package/dist/mjs/modules/index.mjs.map +10 -0
  229. package/dist/mjs/package.json +5 -0
  230. package/dist/mjs/runtime/script-runtime.mjs +57 -0
  231. package/dist/mjs/runtime/script-runtime.mjs.map +10 -0
  232. package/dist/mjs/server/app-server.mjs +118 -0
  233. package/dist/mjs/server/app-server.mjs.map +10 -0
  234. package/dist/mjs/testing/integration-helpers.mjs +63 -0
  235. package/dist/mjs/testing/integration-helpers.mjs.map +10 -0
  236. package/dist/mjs/typecheck/index.mjs +56 -0
  237. package/dist/mjs/typecheck/index.mjs.map +10 -0
  238. package/dist/mjs/types.mjs +2 -0
  239. package/dist/mjs/types.mjs.map +9 -0
  240. package/dist/types/bridge/diagnostics.d.ts +12 -0
  241. package/dist/types/bridge/legacy-adapters.d.ts +14 -0
  242. package/dist/types/bridge/request-context.d.ts +10 -0
  243. package/dist/types/bridge/runtime-bindings.d.ts +14 -0
  244. package/dist/types/browser/browser-runtime.d.ts +3 -0
  245. package/dist/types/daemon.d.ts +2 -0
  246. package/dist/types/files/index.d.ts +5 -0
  247. package/dist/types/host/create-isolate-host.d.ts +2 -0
  248. package/dist/types/host/index.d.ts +1 -0
  249. package/dist/types/index.d.ts +5 -0
  250. package/dist/types/internal/client/connection.d.ts +9 -0
  251. package/dist/types/internal/client/index.d.ts +8 -0
  252. package/dist/types/internal/client/types.d.ts +198 -0
  253. package/dist/types/internal/console/index.d.ts +108 -0
  254. package/dist/types/internal/console/utils.d.ts +27 -0
  255. package/dist/types/internal/core/index.d.ts +119 -0
  256. package/dist/types/internal/crypto/index.d.ts +18 -0
  257. package/dist/types/internal/daemon/callback-fs-handler.d.ts +28 -0
  258. package/dist/types/internal/daemon/connection.d.ts +9 -0
  259. package/dist/types/internal/daemon/daemon.d.ts +2 -0
  260. package/dist/types/internal/daemon/index.d.ts +14 -0
  261. package/dist/types/internal/daemon/runtime-pool.d.ts +16 -0
  262. package/dist/types/internal/daemon/types.d.ts +211 -0
  263. package/dist/types/internal/encoding/index.d.ts +21 -0
  264. package/dist/types/internal/fetch/consistency/origins.d.ts +179 -0
  265. package/dist/types/internal/fetch/index.d.ts +93 -0
  266. package/dist/types/internal/fetch/stream-state.d.ts +65 -0
  267. package/dist/types/internal/fs/index.d.ts +70 -0
  268. package/dist/types/internal/fs/node-adapter.d.ts +24 -0
  269. package/dist/types/internal/module-loader/bundle.d.ts +33 -0
  270. package/dist/types/internal/module-loader/index.d.ts +30 -0
  271. package/dist/types/internal/module-loader/mappings.d.ts +47 -0
  272. package/dist/types/internal/module-loader/resolve.d.ts +26 -0
  273. package/dist/types/internal/module-loader/strip-types.d.ts +19 -0
  274. package/dist/types/internal/path/index.d.ts +23 -0
  275. package/dist/types/internal/playwright/client.d.ts +7 -0
  276. package/dist/types/internal/playwright/handler.d.ts +44 -0
  277. package/dist/types/internal/playwright/index.d.ts +14 -0
  278. package/dist/types/internal/playwright/types.d.ts +145 -0
  279. package/dist/types/internal/protocol/codec.d.ts +242 -0
  280. package/dist/types/internal/protocol/framing.d.ts +89 -0
  281. package/dist/types/internal/protocol/index.d.ts +10 -0
  282. package/dist/types/internal/protocol/marshalValue.d.ts +79 -0
  283. package/dist/types/internal/protocol/serialization.d.ts +23 -0
  284. package/dist/types/internal/protocol/types.d.ts +996 -0
  285. package/dist/types/internal/runtime/index.d.ts +200 -0
  286. package/dist/types/internal/server/index.d.ts +42 -0
  287. package/dist/types/internal/test-environment/index.d.ts +112 -0
  288. package/dist/types/internal/timers/index.d.ts +22 -0
  289. package/dist/types/internal/transform/index.d.ts +36 -0
  290. package/dist/types/internal/typecheck/index.d.ts +7 -0
  291. package/dist/types/internal/typecheck/isolate-types.d.ts +94 -0
  292. package/dist/types/internal/typecheck/typecheck.d.ts +148 -0
  293. package/dist/types/modules/index.d.ts +2 -0
  294. package/dist/types/runtime/script-runtime.d.ts +6 -0
  295. package/dist/types/server/app-server.d.ts +3 -0
  296. package/dist/types/testing/integration-helpers.d.ts +9 -0
  297. package/dist/types/typecheck/index.d.ts +8 -0
  298. package/dist/types/types.d.ts +233 -0
  299. package/package.json +82 -6
@@ -0,0 +1,2574 @@
1
+ // src/internal/typecheck/isolate-types.ts
2
+ var CORE_TYPES = `/**
3
+ * Global Type Definitions for ../core/index.ts
4
+ *
5
+ * These types define the globals injected by setupCore() into an isolated-vm context.
6
+ * Use these types to typecheck user code that will run inside the V8 isolate.
7
+ *
8
+ * @example
9
+ * // In your tsconfig.isolate.json
10
+ * {
11
+ * "compilerOptions": {
12
+ * "lib": ["ESNext", "DOM"]
13
+ * }
14
+ * }
15
+ *
16
+ * // Then reference this file or use ts-morph for code strings
17
+ */
18
+
19
+ export {};
20
+
21
+ declare global {
22
+ // ============================================
23
+ // Web Streams API
24
+ // ============================================
25
+
26
+ /**
27
+ * A readable stream of data.
28
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream
29
+ */
30
+ const ReadableStream: typeof globalThis.ReadableStream;
31
+
32
+ /**
33
+ * A writable stream of data.
34
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/WritableStream
35
+ */
36
+ const WritableStream: typeof globalThis.WritableStream;
37
+
38
+ /**
39
+ * A transform stream that can be used to pipe data through a transformer.
40
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/TransformStream
41
+ */
42
+ const TransformStream: typeof globalThis.TransformStream;
43
+
44
+ /**
45
+ * Default reader for ReadableStream
46
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/ReadableStreamDefaultReader
47
+ */
48
+ const ReadableStreamDefaultReader: typeof globalThis.ReadableStreamDefaultReader;
49
+
50
+ /**
51
+ * Default writer for WritableStream
52
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/WritableStreamDefaultWriter
53
+ */
54
+ const WritableStreamDefaultWriter: typeof globalThis.WritableStreamDefaultWriter;
55
+
56
+ // ============================================
57
+ // Blob and File APIs
58
+ // ============================================
59
+
60
+ /**
61
+ * A file-like object of immutable, raw data.
62
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Blob
63
+ */
64
+ const Blob: typeof globalThis.Blob;
65
+
66
+ /**
67
+ * A file object representing a file.
68
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/File
69
+ */
70
+ const File: typeof globalThis.File;
71
+
72
+ // ============================================
73
+ // URL APIs
74
+ // ============================================
75
+
76
+ /**
77
+ * Interface for URL manipulation.
78
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/URL
79
+ */
80
+ const URL: typeof globalThis.URL;
81
+
82
+ /**
83
+ * Utility for working with URL query strings.
84
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
85
+ */
86
+ const URLSearchParams: typeof globalThis.URLSearchParams;
87
+
88
+ // ============================================
89
+ // DOM Parsing and Constructors
90
+ // ============================================
91
+
92
+ /**
93
+ * Parses HTML/XML strings into Document objects.
94
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMParser
95
+ */
96
+ const DOMParser: typeof globalThis.DOMParser;
97
+
98
+ /**
99
+ * Base DOM node constructor.
100
+ */
101
+ const Node: typeof globalThis.Node;
102
+
103
+ /**
104
+ * DOM document constructor.
105
+ */
106
+ const Document: typeof globalThis.Document;
107
+
108
+ /**
109
+ * DOM document fragment constructor.
110
+ */
111
+ const DocumentFragment: typeof globalThis.DocumentFragment;
112
+
113
+ /**
114
+ * DOM document type constructor.
115
+ */
116
+ const DocumentType: typeof globalThis.DocumentType;
117
+
118
+ /**
119
+ * DOM element constructor.
120
+ */
121
+ const Element: typeof globalThis.Element;
122
+
123
+ /**
124
+ * DOM attribute constructor.
125
+ */
126
+ const Attr: typeof globalThis.Attr;
127
+
128
+ /**
129
+ * DOM text node constructor.
130
+ */
131
+ const Text: typeof globalThis.Text;
132
+
133
+ /**
134
+ * DOM comment node constructor.
135
+ */
136
+ const Comment: typeof globalThis.Comment;
137
+
138
+ /**
139
+ * DOM event constructor.
140
+ */
141
+ const Event: typeof globalThis.Event;
142
+
143
+ /**
144
+ * Base event target constructor.
145
+ */
146
+ const EventTarget: typeof globalThis.EventTarget;
147
+
148
+ /**
149
+ * Custom event constructor.
150
+ */
151
+ const CustomEvent: typeof globalThis.CustomEvent;
152
+
153
+ // ============================================
154
+ // Error Handling
155
+ // ============================================
156
+
157
+ /**
158
+ * Exception type for DOM operations.
159
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMException
160
+ */
161
+ const DOMException: typeof globalThis.DOMException;
162
+ }
163
+ `;
164
+ var FETCH_TYPES = `/**
165
+ * Global Type Definitions for ../fetch/index.ts
166
+ *
167
+ * These types define the globals injected by setupFetch() into an isolated-vm context.
168
+ * Use these types to typecheck user code that will run inside the V8 isolate.
169
+ *
170
+ * @example
171
+ * // Typecheck isolate code with serve()
172
+ * type WebSocketData = { id: number; connectedAt: number };
173
+ *
174
+ * serve({
175
+ * fetch(request, server) {
176
+ * if (request.url.includes("/ws")) {
177
+ * // server.upgrade knows data should be WebSocketData
178
+ * server.upgrade(request, { data: { id: 123, connectedAt: Date.now() } });
179
+ * return new Response(null, { status: 101 });
180
+ * }
181
+ * return new Response("Hello!");
182
+ * },
183
+ * websocket: {
184
+ * // Type hint - specifies the type of ws.data
185
+ * data: {} as WebSocketData,
186
+ * message(ws, message) {
187
+ * // ws.data is typed as WebSocketData
188
+ * console.log("User", ws.data.id, "says:", message);
189
+ * ws.send("Echo: " + message);
190
+ * }
191
+ * }
192
+ * });
193
+ */
194
+
195
+ export {};
196
+
197
+ declare global {
198
+ // ============================================
199
+ // Standard Fetch API (from lib.dom)
200
+ // ============================================
201
+
202
+ /**
203
+ * Headers class for HTTP headers manipulation.
204
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Headers
205
+ */
206
+ const Headers: typeof globalThis.Headers;
207
+
208
+ /**
209
+ * Request class for HTTP requests.
210
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Request
211
+ */
212
+ const Request: typeof globalThis.Request;
213
+
214
+ /**
215
+ * Response class for HTTP responses.
216
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Response
217
+ */
218
+ const Response: typeof globalThis.Response;
219
+
220
+ /**
221
+ * AbortController for cancelling fetch requests.
222
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortController
223
+ */
224
+ const AbortController: typeof globalThis.AbortController;
225
+
226
+ /**
227
+ * AbortSignal for listening to abort events.
228
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
229
+ */
230
+ const AbortSignal: typeof globalThis.AbortSignal;
231
+
232
+ /**
233
+ * FormData for constructing form data.
234
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/FormData
235
+ */
236
+ const FormData: typeof globalThis.FormData;
237
+
238
+ /**
239
+ * Fetch function for making HTTP requests.
240
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/fetch
241
+ */
242
+ function fetch(
243
+ input: RequestInfo | URL,
244
+ init?: RequestInit
245
+ ): Promise<Response>;
246
+
247
+ // ============================================
248
+ // Isolate-specific: serve() API
249
+ // ============================================
250
+
251
+ /**
252
+ * Server interface for handling WebSocket upgrades within serve() handlers.
253
+ *
254
+ * @typeParam T - The type of data associated with WebSocket connections
255
+ */
256
+ interface Server<T = unknown> {
257
+ /**
258
+ * Upgrade an HTTP request to a WebSocket connection.
259
+ *
260
+ * @param request - The incoming HTTP request to upgrade
261
+ * @param options - Optional data to associate with the WebSocket connection
262
+ * @returns true if upgrade will proceed, false otherwise
263
+ *
264
+ * @example
265
+ * serve({
266
+ * fetch(request, server) {
267
+ * if (server.upgrade(request, { data: { userId: 123 } })) {
268
+ * return new Response(null, { status: 101 });
269
+ * }
270
+ * return new Response("Upgrade failed", { status: 400 });
271
+ * }
272
+ * });
273
+ */
274
+ upgrade(request: Request, options?: { data?: T }): boolean;
275
+ }
276
+
277
+ /**
278
+ * ServerWebSocket interface for WebSocket connections within serve() handlers.
279
+ *
280
+ * @typeParam T - The type of data associated with this WebSocket connection
281
+ */
282
+ interface ServerWebSocket<T = unknown> {
283
+ /**
284
+ * User data associated with this connection.
285
+ * Set via \`server.upgrade(request, { data: ... })\`.
286
+ */
287
+ readonly data: T;
288
+
289
+ /**
290
+ * Send a message to the client.
291
+ *
292
+ * @param message - The message to send (string, ArrayBuffer, or Uint8Array)
293
+ */
294
+ send(message: string | ArrayBuffer | Uint8Array): void;
295
+
296
+ /**
297
+ * Close the WebSocket connection.
298
+ *
299
+ * @param code - Optional close code (default: 1000)
300
+ * @param reason - Optional close reason
301
+ */
302
+ close(code?: number, reason?: string): void;
303
+
304
+ /**
305
+ * WebSocket ready state.
306
+ * - 0: CONNECTING
307
+ * - 1: OPEN
308
+ * - 2: CLOSING
309
+ * - 3: CLOSED
310
+ */
311
+ readonly readyState: number;
312
+ }
313
+
314
+ /**
315
+ * Options for the serve() function.
316
+ *
317
+ * @typeParam T - The type of data associated with WebSocket connections
318
+ */
319
+ interface ServeOptions<T = unknown> {
320
+ /**
321
+ * Handler for HTTP requests.
322
+ *
323
+ * @param request - The incoming HTTP request
324
+ * @param server - Server interface for WebSocket upgrades
325
+ * @returns Response or Promise resolving to Response
326
+ */
327
+ fetch(request: Request, server: Server<T>): Response | Promise<Response>;
328
+
329
+ /**
330
+ * WebSocket event handlers.
331
+ */
332
+ websocket?: {
333
+ /**
334
+ * Type hint for WebSocket data. The value is not used at runtime.
335
+ * Specifies the type of \`ws.data\` for all handlers and \`server.upgrade()\`.
336
+ *
337
+ * @example
338
+ * websocket: {
339
+ * data: {} as { userId: string },
340
+ * message(ws, message) {
341
+ * // ws.data.userId is typed as string
342
+ * }
343
+ * }
344
+ */
345
+ data?: T;
346
+
347
+ /**
348
+ * Called when a WebSocket connection is opened.
349
+ *
350
+ * @param ws - The WebSocket connection
351
+ */
352
+ open?(ws: ServerWebSocket<T>): void | Promise<void>;
353
+
354
+ /**
355
+ * Called when a message is received.
356
+ *
357
+ * @param ws - The WebSocket connection
358
+ * @param message - The received message (string or ArrayBuffer)
359
+ */
360
+ message?(
361
+ ws: ServerWebSocket<T>,
362
+ message: string | ArrayBuffer
363
+ ): void | Promise<void>;
364
+
365
+ /**
366
+ * Called when the connection is closed.
367
+ *
368
+ * @param ws - The WebSocket connection
369
+ * @param code - The close code
370
+ * @param reason - The close reason
371
+ */
372
+ close?(
373
+ ws: ServerWebSocket<T>,
374
+ code: number,
375
+ reason: string
376
+ ): void | Promise<void>;
377
+
378
+ /**
379
+ * Called when an error occurs.
380
+ *
381
+ * @param ws - The WebSocket connection
382
+ * @param error - The error that occurred
383
+ */
384
+ error?(ws: ServerWebSocket<T>, error: Error): void | Promise<void>;
385
+ };
386
+ }
387
+
388
+ /**
389
+ * Register an HTTP server handler in the isolate.
390
+ *
391
+ * Only one serve() handler can be active at a time.
392
+ * Calling serve() again replaces the previous handler.
393
+ *
394
+ * @param options - Server configuration including fetch handler and optional WebSocket handlers
395
+ *
396
+ * @example
397
+ * type WsData = { connectedAt: number };
398
+ *
399
+ * serve({
400
+ * fetch(request, server) {
401
+ * const url = new URL(request.url);
402
+ *
403
+ * if (url.pathname === "/ws") {
404
+ * if (server.upgrade(request, { data: { connectedAt: Date.now() } })) {
405
+ * return new Response(null, { status: 101 });
406
+ * }
407
+ * }
408
+ *
409
+ * if (url.pathname === "/api/hello") {
410
+ * return Response.json({ message: "Hello!" });
411
+ * }
412
+ *
413
+ * return new Response("Not Found", { status: 404 });
414
+ * },
415
+ * websocket: {
416
+ * data: {} as WsData,
417
+ * open(ws) {
418
+ * console.log("Connected at:", ws.data.connectedAt);
419
+ * },
420
+ * message(ws, message) {
421
+ * ws.send("Echo: " + message);
422
+ * },
423
+ * close(ws, code, reason) {
424
+ * console.log("Closed:", code, reason);
425
+ * }
426
+ * }
427
+ * });
428
+ */
429
+ function serve<T = unknown>(options: ServeOptions<T>): void;
430
+
431
+ // ============================================
432
+ // Client WebSocket API (outbound connections)
433
+ // ============================================
434
+
435
+ /**
436
+ * The type for WebSocket binary data handling.
437
+ */
438
+ type BinaryType = "blob" | "arraybuffer";
439
+
440
+ /**
441
+ * Event fired when a WebSocket connection is closed.
442
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent
443
+ */
444
+ interface CloseEvent extends Event {
445
+ /**
446
+ * The close code sent by the server.
447
+ */
448
+ readonly code: number;
449
+
450
+ /**
451
+ * The close reason sent by the server.
452
+ */
453
+ readonly reason: string;
454
+
455
+ /**
456
+ * Whether the connection was closed cleanly.
457
+ */
458
+ readonly wasClean: boolean;
459
+ }
460
+
461
+ /**
462
+ * Event fired when a WebSocket receives a message.
463
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent
464
+ */
465
+ interface MessageEvent<T = any> extends Event {
466
+ /**
467
+ * The data sent by the message emitter.
468
+ */
469
+ readonly data: T;
470
+
471
+ /**
472
+ * The origin of the message emitter.
473
+ */
474
+ readonly origin: string;
475
+
476
+ /**
477
+ * The last event ID (for Server-Sent Events).
478
+ */
479
+ readonly lastEventId: string;
480
+
481
+ /**
482
+ * The MessagePort array sent with the message (if any).
483
+ */
484
+ readonly ports: ReadonlyArray<MessagePort>;
485
+
486
+ /**
487
+ * The source of the message (if applicable).
488
+ */
489
+ readonly source: MessageEventSource | null;
490
+ }
491
+
492
+ /**
493
+ * WHATWG WebSocket client for making outbound WebSocket connections.
494
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket
495
+ *
496
+ * @example
497
+ * const ws = new WebSocket("wss://echo.websocket.org");
498
+ *
499
+ * ws.onopen = () => {
500
+ * console.log("Connected!");
501
+ * ws.send("Hello, server!");
502
+ * };
503
+ *
504
+ * ws.onmessage = (event) => {
505
+ * console.log("Received:", event.data);
506
+ * };
507
+ *
508
+ * ws.onclose = (event) => {
509
+ * console.log("Closed:", event.code, event.reason);
510
+ * };
511
+ *
512
+ * ws.onerror = () => {
513
+ * console.log("Error occurred");
514
+ * };
515
+ */
516
+ interface WebSocket extends EventTarget {
517
+ /**
518
+ * The URL of the WebSocket connection.
519
+ */
520
+ readonly url: string;
521
+
522
+ /**
523
+ * The current state of the connection.
524
+ * - 0: CONNECTING
525
+ * - 1: OPEN
526
+ * - 2: CLOSING
527
+ * - 3: CLOSED
528
+ */
529
+ readonly readyState: number;
530
+
531
+ /**
532
+ * The number of bytes of data that have been queued but not yet transmitted.
533
+ */
534
+ readonly bufferedAmount: number;
535
+
536
+ /**
537
+ * The extensions selected by the server.
538
+ */
539
+ readonly extensions: string;
540
+
541
+ /**
542
+ * The subprotocol selected by the server.
543
+ */
544
+ readonly protocol: string;
545
+
546
+ /**
547
+ * The type of binary data being transmitted.
548
+ * Can be "blob" or "arraybuffer".
549
+ */
550
+ binaryType: BinaryType;
551
+
552
+ /**
553
+ * Send data through the WebSocket connection.
554
+ *
555
+ * @param data - The data to send
556
+ * @throws InvalidStateError if the connection is not open
557
+ *
558
+ * @example
559
+ * ws.send("Hello!");
560
+ * ws.send(new Uint8Array([1, 2, 3]));
561
+ */
562
+ send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;
563
+
564
+ /**
565
+ * Close the WebSocket connection.
566
+ *
567
+ * @param code - The close code (default: 1000)
568
+ * @param reason - The close reason (max 123 bytes UTF-8)
569
+ *
570
+ * @example
571
+ * ws.close();
572
+ * ws.close(1000, "Normal closure");
573
+ */
574
+ close(code?: number, reason?: string): void;
575
+
576
+ /**
577
+ * Event handler for when the connection is established.
578
+ */
579
+ onopen: ((this: WebSocket, ev: Event) => any) | null;
580
+
581
+ /**
582
+ * Event handler for when a message is received.
583
+ */
584
+ onmessage: ((this: WebSocket, ev: MessageEvent) => any) | null;
585
+
586
+ /**
587
+ * Event handler for when an error occurs.
588
+ */
589
+ onerror: ((this: WebSocket, ev: Event) => any) | null;
590
+
591
+ /**
592
+ * Event handler for when the connection is closed.
593
+ */
594
+ onclose: ((this: WebSocket, ev: CloseEvent) => any) | null;
595
+
596
+ /**
597
+ * Connection is being established.
598
+ */
599
+ readonly CONNECTING: 0;
600
+
601
+ /**
602
+ * Connection is open and ready to communicate.
603
+ */
604
+ readonly OPEN: 1;
605
+
606
+ /**
607
+ * Connection is in the process of closing.
608
+ */
609
+ readonly CLOSING: 2;
610
+
611
+ /**
612
+ * Connection is closed or couldn't be opened.
613
+ */
614
+ readonly CLOSED: 3;
615
+ }
616
+
617
+ /**
618
+ * WebSocket constructor.
619
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/WebSocket
620
+ */
621
+ interface WebSocketConstructor {
622
+ /**
623
+ * Create a new WebSocket connection.
624
+ *
625
+ * @param url - The URL to connect to (must be ws:// or wss://)
626
+ * @param protocols - Optional subprotocol(s) to request
627
+ * @throws SyntaxError if the URL is invalid
628
+ *
629
+ * @example
630
+ * const ws = new WebSocket("wss://example.com/socket");
631
+ * const ws = new WebSocket("wss://example.com/socket", "graphql-ws");
632
+ * const ws = new WebSocket("wss://example.com/socket", ["protocol1", "protocol2"]);
633
+ */
634
+ new (url: string | URL, protocols?: string | string[]): WebSocket;
635
+
636
+ readonly prototype: WebSocket;
637
+
638
+ /**
639
+ * Connection is being established.
640
+ */
641
+ readonly CONNECTING: 0;
642
+
643
+ /**
644
+ * Connection is open and ready to communicate.
645
+ */
646
+ readonly OPEN: 1;
647
+
648
+ /**
649
+ * Connection is in the process of closing.
650
+ */
651
+ readonly CLOSING: 2;
652
+
653
+ /**
654
+ * Connection is closed or couldn't be opened.
655
+ */
656
+ readonly CLOSED: 3;
657
+ }
658
+
659
+ /**
660
+ * WHATWG WebSocket client for making outbound WebSocket connections.
661
+ */
662
+ const WebSocket: WebSocketConstructor;
663
+ }
664
+ `;
665
+ var FS_TYPES = `/**
666
+ * Global Type Definitions for ../fs/index.ts
667
+ *
668
+ * These types define the globals injected by setupFs() into an isolated-vm context.
669
+ * Use these types to typecheck user code that will run inside the V8 isolate.
670
+ *
671
+ * @example
672
+ * // Typecheck isolate code with file system access
673
+ * const root = await getDirectory("/data");
674
+ * const fileHandle = await root.getFileHandle("config.json");
675
+ * const file = await fileHandle.getFile();
676
+ * const content = await file.text();
677
+ */
678
+
679
+ export {};
680
+
681
+ declare global {
682
+ // ============================================
683
+ // getDirectory - Isolate-specific entry point
684
+ // ============================================
685
+
686
+ /**
687
+ * Get a directory handle for the given path.
688
+ *
689
+ * The host controls which paths are accessible. Invalid or unauthorized
690
+ * paths will throw an error.
691
+ *
692
+ * @param path - The path to request from the host
693
+ * @returns A promise resolving to a directory handle
694
+ * @throws If the path is not allowed or doesn't exist
695
+ *
696
+ * @example
697
+ * const root = await getDirectory("/");
698
+ * const dataDir = await getDirectory("/data");
699
+ */
700
+ function getDirectory(path: string): Promise<FileSystemDirectoryHandle>;
701
+
702
+ // ============================================
703
+ // File System Access API
704
+ // ============================================
705
+
706
+ /**
707
+ * Base interface for file system handles.
708
+ */
709
+ interface FileSystemHandle {
710
+ /**
711
+ * The kind of handle: "file" or "directory".
712
+ */
713
+ readonly kind: "file" | "directory";
714
+
715
+ /**
716
+ * The name of the file or directory.
717
+ */
718
+ readonly name: string;
719
+
720
+ /**
721
+ * Compare two handles to check if they reference the same entry.
722
+ *
723
+ * @param other - Another FileSystemHandle to compare against
724
+ * @returns true if both handles reference the same entry
725
+ */
726
+ isSameEntry(other: FileSystemHandle): Promise<boolean>;
727
+ }
728
+
729
+ /**
730
+ * Handle for a file in the file system.
731
+ */
732
+ interface FileSystemFileHandle extends FileSystemHandle {
733
+ /**
734
+ * Always "file" for file handles.
735
+ */
736
+ readonly kind: "file";
737
+
738
+ /**
739
+ * Get the file contents as a File object.
740
+ *
741
+ * @returns A promise resolving to a File object
742
+ *
743
+ * @example
744
+ * const file = await fileHandle.getFile();
745
+ * const text = await file.text();
746
+ */
747
+ getFile(): Promise<File>;
748
+
749
+ /**
750
+ * Create a writable stream for writing to the file.
751
+ *
752
+ * @param options - Options for the writable stream
753
+ * @returns A promise resolving to a writable stream
754
+ *
755
+ * @example
756
+ * const writable = await fileHandle.createWritable();
757
+ * await writable.write("Hello, World!");
758
+ * await writable.close();
759
+ */
760
+ createWritable(options?: {
761
+ /**
762
+ * If true, keeps existing file data. Otherwise, truncates the file.
763
+ */
764
+ keepExistingData?: boolean;
765
+ }): Promise<FileSystemWritableFileStream>;
766
+ }
767
+
768
+ /**
769
+ * Handle for a directory in the file system.
770
+ */
771
+ interface FileSystemDirectoryHandle extends FileSystemHandle {
772
+ /**
773
+ * Always "directory" for directory handles.
774
+ */
775
+ readonly kind: "directory";
776
+
777
+ /**
778
+ * Get a file handle within this directory.
779
+ *
780
+ * @param name - The name of the file
781
+ * @param options - Options for getting the file handle
782
+ * @returns A promise resolving to a file handle
783
+ * @throws If the file doesn't exist and create is not true
784
+ *
785
+ * @example
786
+ * const file = await dir.getFileHandle("data.json");
787
+ * const newFile = await dir.getFileHandle("output.txt", { create: true });
788
+ */
789
+ getFileHandle(
790
+ name: string,
791
+ options?: {
792
+ /**
793
+ * If true, creates the file if it doesn't exist.
794
+ */
795
+ create?: boolean;
796
+ }
797
+ ): Promise<FileSystemFileHandle>;
798
+
799
+ /**
800
+ * Get a subdirectory handle within this directory.
801
+ *
802
+ * @param name - The name of the subdirectory
803
+ * @param options - Options for getting the directory handle
804
+ * @returns A promise resolving to a directory handle
805
+ * @throws If the directory doesn't exist and create is not true
806
+ *
807
+ * @example
808
+ * const subdir = await dir.getDirectoryHandle("logs");
809
+ * const newDir = await dir.getDirectoryHandle("cache", { create: true });
810
+ */
811
+ getDirectoryHandle(
812
+ name: string,
813
+ options?: {
814
+ /**
815
+ * If true, creates the directory if it doesn't exist.
816
+ */
817
+ create?: boolean;
818
+ }
819
+ ): Promise<FileSystemDirectoryHandle>;
820
+
821
+ /**
822
+ * Remove a file or directory within this directory.
823
+ *
824
+ * @param name - The name of the entry to remove
825
+ * @param options - Options for removal
826
+ * @throws If the entry doesn't exist or cannot be removed
827
+ *
828
+ * @example
829
+ * await dir.removeEntry("old-file.txt");
830
+ * await dir.removeEntry("old-dir", { recursive: true });
831
+ */
832
+ removeEntry(
833
+ name: string,
834
+ options?: {
835
+ /**
836
+ * If true, removes directories recursively.
837
+ */
838
+ recursive?: boolean;
839
+ }
840
+ ): Promise<void>;
841
+
842
+ /**
843
+ * Resolve the path from this directory to a descendant handle.
844
+ *
845
+ * @param possibleDescendant - A handle that may be a descendant
846
+ * @returns An array of path segments, or null if not a descendant
847
+ *
848
+ * @example
849
+ * const path = await root.resolve(nestedFile);
850
+ * // ["subdir", "file.txt"]
851
+ */
852
+ resolve(possibleDescendant: FileSystemHandle): Promise<string[] | null>;
853
+
854
+ /**
855
+ * Iterate over entries in this directory.
856
+ *
857
+ * @returns An async iterator of [name, handle] pairs
858
+ *
859
+ * @example
860
+ * for await (const [name, handle] of dir.entries()) {
861
+ * console.log(name, handle.kind);
862
+ * }
863
+ */
864
+ entries(): AsyncIterableIterator<[string, FileSystemHandle]>;
865
+
866
+ /**
867
+ * Iterate over entry names in this directory.
868
+ *
869
+ * @returns An async iterator of names
870
+ *
871
+ * @example
872
+ * for await (const name of dir.keys()) {
873
+ * console.log(name);
874
+ * }
875
+ */
876
+ keys(): AsyncIterableIterator<string>;
877
+
878
+ /**
879
+ * Iterate over handles in this directory.
880
+ *
881
+ * @returns An async iterator of handles
882
+ *
883
+ * @example
884
+ * for await (const handle of dir.values()) {
885
+ * console.log(handle.name, handle.kind);
886
+ * }
887
+ */
888
+ values(): AsyncIterableIterator<FileSystemHandle>;
889
+
890
+ /**
891
+ * Async iterator support for directory entries.
892
+ *
893
+ * @example
894
+ * for await (const [name, handle] of dir) {
895
+ * console.log(name, handle.kind);
896
+ * }
897
+ */
898
+ [Symbol.asyncIterator](): AsyncIterableIterator<[string, FileSystemHandle]>;
899
+ }
900
+
901
+ /**
902
+ * Parameters for write operations on FileSystemWritableFileStream.
903
+ */
904
+ interface WriteParams {
905
+ /**
906
+ * The type of write operation.
907
+ * - "write": Write data at the current position or specified position
908
+ * - "seek": Move the file position
909
+ * - "truncate": Truncate the file to a specific size
910
+ */
911
+ type: "write" | "seek" | "truncate";
912
+
913
+ /**
914
+ * The data to write (for "write" type).
915
+ */
916
+ data?: string | ArrayBuffer | Uint8Array | Blob;
917
+
918
+ /**
919
+ * The position to write at or seek to.
920
+ */
921
+ position?: number;
922
+
923
+ /**
924
+ * The size to truncate to (for "truncate" type).
925
+ */
926
+ size?: number;
927
+ }
928
+
929
+ /**
930
+ * Writable stream for writing to a file.
931
+ * Extends WritableStream with file-specific operations.
932
+ */
933
+ interface FileSystemWritableFileStream extends WritableStream<Uint8Array> {
934
+ /**
935
+ * Write data to the file.
936
+ *
937
+ * @param data - The data to write
938
+ * @returns A promise that resolves when the write completes
939
+ *
940
+ * @example
941
+ * await writable.write("Hello, World!");
942
+ * await writable.write(new Uint8Array([1, 2, 3]));
943
+ * await writable.write({ type: "write", data: "text", position: 0 });
944
+ */
945
+ write(
946
+ data: string | ArrayBuffer | Uint8Array | Blob | WriteParams
947
+ ): Promise<void>;
948
+
949
+ /**
950
+ * Seek to a position in the file.
951
+ *
952
+ * @param position - The byte position to seek to
953
+ * @returns A promise that resolves when the seek completes
954
+ *
955
+ * @example
956
+ * await writable.seek(0); // Seek to beginning
957
+ * await writable.write("Overwrite");
958
+ */
959
+ seek(position: number): Promise<void>;
960
+
961
+ /**
962
+ * Truncate the file to a specific size.
963
+ *
964
+ * @param size - The size to truncate to
965
+ * @returns A promise that resolves when the truncation completes
966
+ *
967
+ * @example
968
+ * await writable.truncate(100); // Keep only first 100 bytes
969
+ */
970
+ truncate(size: number): Promise<void>;
971
+ }
972
+ }
973
+ `;
974
+ var TEST_ENV_TYPES = `/**
975
+ * Global Type Definitions for ../test-environment/index.ts
976
+ *
977
+ * These types define the globals injected by setupTestEnvironment() into an isolated-vm context.
978
+ * Use these types to typecheck user code that will run inside the V8 isolate.
979
+ *
980
+ * @example
981
+ * describe("Math operations", () => {
982
+ * it("should add numbers", () => {
983
+ * expect(1 + 1).toBe(2);
984
+ * });
985
+ * });
986
+ */
987
+
988
+ export {};
989
+
990
+ declare global {
991
+ // ============================================
992
+ // Test Structure
993
+ // ============================================
994
+
995
+ /**
996
+ * Define a test suite.
997
+ *
998
+ * @param name - The name of the test suite
999
+ * @param fn - Function containing tests and nested suites
1000
+ *
1001
+ * @example
1002
+ * describe("Calculator", () => {
1003
+ * it("adds numbers", () => {
1004
+ * expect(1 + 1).toBe(2);
1005
+ * });
1006
+ * });
1007
+ */
1008
+ function describe(name: string, fn: () => void): void;
1009
+
1010
+ namespace describe {
1011
+ /**
1012
+ * Skip this suite and all its tests.
1013
+ */
1014
+ function skip(name: string, fn: () => void): void;
1015
+
1016
+ /**
1017
+ * Only run this suite (and other .only suites).
1018
+ */
1019
+ function only(name: string, fn: () => void): void;
1020
+
1021
+ /**
1022
+ * Mark suite as todo (skipped with different status).
1023
+ */
1024
+ function todo(name: string, fn?: () => void): void;
1025
+ }
1026
+
1027
+ /**
1028
+ * Define a test case.
1029
+ *
1030
+ * @param name - The name of the test
1031
+ * @param fn - The test function (can be async)
1032
+ *
1033
+ * @example
1034
+ * it("should work", () => {
1035
+ * expect(true).toBe(true);
1036
+ * });
1037
+ *
1038
+ * it("should work async", async () => {
1039
+ * const result = await Promise.resolve(42);
1040
+ * expect(result).toBe(42);
1041
+ * });
1042
+ */
1043
+ function it(name: string, fn: () => void | Promise<void>): void;
1044
+
1045
+ namespace it {
1046
+ /**
1047
+ * Skip this test.
1048
+ */
1049
+ function skip(name: string, fn?: () => void | Promise<void>): void;
1050
+
1051
+ /**
1052
+ * Only run this test (and other .only tests).
1053
+ */
1054
+ function only(name: string, fn: () => void | Promise<void>): void;
1055
+
1056
+ /**
1057
+ * Mark test as todo.
1058
+ */
1059
+ function todo(name: string, fn?: () => void | Promise<void>): void;
1060
+ }
1061
+
1062
+ /**
1063
+ * Alias for it().
1064
+ */
1065
+ function test(name: string, fn: () => void | Promise<void>): void;
1066
+
1067
+ namespace test {
1068
+ /**
1069
+ * Skip this test.
1070
+ */
1071
+ function skip(name: string, fn?: () => void | Promise<void>): void;
1072
+
1073
+ /**
1074
+ * Only run this test (and other .only tests).
1075
+ */
1076
+ function only(name: string, fn: () => void | Promise<void>): void;
1077
+
1078
+ /**
1079
+ * Mark test as todo.
1080
+ */
1081
+ function todo(name: string, fn?: () => void | Promise<void>): void;
1082
+ }
1083
+
1084
+ // ============================================
1085
+ // Lifecycle Hooks
1086
+ // ============================================
1087
+
1088
+ /**
1089
+ * Run once before all tests in the current suite.
1090
+ *
1091
+ * @param fn - Setup function (can be async)
1092
+ */
1093
+ function beforeAll(fn: () => void | Promise<void>): void;
1094
+
1095
+ /**
1096
+ * Run once after all tests in the current suite.
1097
+ *
1098
+ * @param fn - Teardown function (can be async)
1099
+ */
1100
+ function afterAll(fn: () => void | Promise<void>): void;
1101
+
1102
+ /**
1103
+ * Run before each test in the current suite (and nested suites).
1104
+ *
1105
+ * @param fn - Setup function (can be async)
1106
+ */
1107
+ function beforeEach(fn: () => void | Promise<void>): void;
1108
+
1109
+ /**
1110
+ * Run after each test in the current suite (and nested suites).
1111
+ *
1112
+ * @param fn - Teardown function (can be async)
1113
+ */
1114
+ function afterEach(fn: () => void | Promise<void>): void;
1115
+
1116
+ // ============================================
1117
+ // Assertions
1118
+ // ============================================
1119
+
1120
+ /**
1121
+ * Matchers for assertions.
1122
+ */
1123
+ interface Matchers<T> {
1124
+ /**
1125
+ * Strict equality (===).
1126
+ */
1127
+ toBe(expected: T): void;
1128
+
1129
+ /**
1130
+ * Deep equality.
1131
+ */
1132
+ toEqual(expected: unknown): void;
1133
+
1134
+ /**
1135
+ * Deep equality with type checking.
1136
+ */
1137
+ toStrictEqual(expected: unknown): void;
1138
+
1139
+ /**
1140
+ * Check if value is truthy.
1141
+ */
1142
+ toBeTruthy(): void;
1143
+
1144
+ /**
1145
+ * Check if value is falsy.
1146
+ */
1147
+ toBeFalsy(): void;
1148
+
1149
+ /**
1150
+ * Check if value is null.
1151
+ */
1152
+ toBeNull(): void;
1153
+
1154
+ /**
1155
+ * Check if value is undefined.
1156
+ */
1157
+ toBeUndefined(): void;
1158
+
1159
+ /**
1160
+ * Check if value is defined (not undefined).
1161
+ */
1162
+ toBeDefined(): void;
1163
+
1164
+ /**
1165
+ * Check if value is NaN.
1166
+ */
1167
+ toBeNaN(): void;
1168
+
1169
+ /**
1170
+ * Check if number is greater than expected.
1171
+ */
1172
+ toBeGreaterThan(n: number): void;
1173
+
1174
+ /**
1175
+ * Check if number is greater than or equal to expected.
1176
+ */
1177
+ toBeGreaterThanOrEqual(n: number): void;
1178
+
1179
+ /**
1180
+ * Check if number is less than expected.
1181
+ */
1182
+ toBeLessThan(n: number): void;
1183
+
1184
+ /**
1185
+ * Check if number is less than or equal to expected.
1186
+ */
1187
+ toBeLessThanOrEqual(n: number): void;
1188
+
1189
+ /**
1190
+ * Check if array/string contains item/substring.
1191
+ */
1192
+ toContain(item: unknown): void;
1193
+
1194
+ /**
1195
+ * Check length of array/string.
1196
+ */
1197
+ toHaveLength(length: number): void;
1198
+
1199
+ /**
1200
+ * Check if object has property (optionally with value).
1201
+ */
1202
+ toHaveProperty(key: string, value?: unknown): void;
1203
+
1204
+ /**
1205
+ * Check if function throws.
1206
+ */
1207
+ toThrow(expected?: string | RegExp | Error): void;
1208
+
1209
+ /**
1210
+ * Check if string matches pattern.
1211
+ */
1212
+ toMatch(pattern: string | RegExp): void;
1213
+
1214
+ /**
1215
+ * Check if object matches subset of properties.
1216
+ */
1217
+ toMatchObject(object: object): void;
1218
+
1219
+ /**
1220
+ * Check if value is instance of class.
1221
+ */
1222
+ toBeInstanceOf(constructor: Function): void;
1223
+
1224
+ /**
1225
+ * Negate the matcher.
1226
+ */
1227
+ not: Matchers<T>;
1228
+
1229
+ /**
1230
+ * Await promise and check resolved value.
1231
+ */
1232
+ resolves: Matchers<Awaited<T>>;
1233
+
1234
+ /**
1235
+ * Await promise and check rejection.
1236
+ */
1237
+ rejects: Matchers<unknown>;
1238
+ }
1239
+
1240
+ /**
1241
+ * Create an expectation for a value.
1242
+ *
1243
+ * @param actual - The value to test
1244
+ * @returns Matchers for the value
1245
+ *
1246
+ * @example
1247
+ * expect(1 + 1).toBe(2);
1248
+ * expect({ a: 1 }).toEqual({ a: 1 });
1249
+ * expect(() => { throw new Error(); }).toThrow();
1250
+ * expect(promise).resolves.toBe(42);
1251
+ */
1252
+ function expect<T>(actual: T): Matchers<T>;
1253
+ }
1254
+ `;
1255
+ var CONSOLE_TYPES = `/**
1256
+ * Global Type Definitions for ../console/index.ts
1257
+ *
1258
+ * These types define the globals injected by setupConsole() into an isolated-vm context.
1259
+ * Use these types to typecheck user code that will run inside the V8 isolate.
1260
+ */
1261
+
1262
+ export {};
1263
+
1264
+ declare global {
1265
+ /**
1266
+ * Console interface for logging and debugging.
1267
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Console
1268
+ */
1269
+ interface Console {
1270
+ /**
1271
+ * Log a message to the console.
1272
+ * @param data - Values to log
1273
+ */
1274
+ log(...data: unknown[]): void;
1275
+
1276
+ /**
1277
+ * Log a warning message.
1278
+ * @param data - Values to log
1279
+ */
1280
+ warn(...data: unknown[]): void;
1281
+
1282
+ /**
1283
+ * Log an error message.
1284
+ * @param data - Values to log
1285
+ */
1286
+ error(...data: unknown[]): void;
1287
+
1288
+ /**
1289
+ * Log a debug message.
1290
+ * @param data - Values to log
1291
+ */
1292
+ debug(...data: unknown[]): void;
1293
+
1294
+ /**
1295
+ * Log an info message.
1296
+ * @param data - Values to log
1297
+ */
1298
+ info(...data: unknown[]): void;
1299
+
1300
+ /**
1301
+ * Log a stack trace.
1302
+ * @param data - Values to log with the trace
1303
+ */
1304
+ trace(...data: unknown[]): void;
1305
+
1306
+ /**
1307
+ * Display an object in a formatted way.
1308
+ * @param item - Object to display
1309
+ * @param options - Display options
1310
+ */
1311
+ dir(item: unknown, options?: object): void;
1312
+
1313
+ /**
1314
+ * Display tabular data.
1315
+ * @param tabularData - Data to display as a table
1316
+ * @param properties - Optional array of property names to include
1317
+ */
1318
+ table(tabularData: unknown, properties?: string[]): void;
1319
+
1320
+ /**
1321
+ * Start a timer.
1322
+ * @param label - Timer label (default: "default")
1323
+ */
1324
+ time(label?: string): void;
1325
+
1326
+ /**
1327
+ * End a timer and log the elapsed time.
1328
+ * @param label - Timer label (default: "default")
1329
+ */
1330
+ timeEnd(label?: string): void;
1331
+
1332
+ /**
1333
+ * Log the elapsed time of a timer without ending it.
1334
+ * @param label - Timer label (default: "default")
1335
+ * @param data - Additional values to log
1336
+ */
1337
+ timeLog(label?: string, ...data: unknown[]): void;
1338
+
1339
+ /**
1340
+ * Log an error if the assertion is false.
1341
+ * @param condition - Condition to test
1342
+ * @param data - Values to log if assertion fails
1343
+ */
1344
+ assert(condition?: boolean, ...data: unknown[]): void;
1345
+
1346
+ /**
1347
+ * Increment and log a counter.
1348
+ * @param label - Counter label (default: "default")
1349
+ */
1350
+ count(label?: string): void;
1351
+
1352
+ /**
1353
+ * Reset a counter.
1354
+ * @param label - Counter label (default: "default")
1355
+ */
1356
+ countReset(label?: string): void;
1357
+
1358
+ /**
1359
+ * Clear the console.
1360
+ */
1361
+ clear(): void;
1362
+
1363
+ /**
1364
+ * Start an inline group.
1365
+ * @param data - Group label
1366
+ */
1367
+ group(...data: unknown[]): void;
1368
+
1369
+ /**
1370
+ * Start a collapsed inline group.
1371
+ * @param data - Group label
1372
+ */
1373
+ groupCollapsed(...data: unknown[]): void;
1374
+
1375
+ /**
1376
+ * End the current inline group.
1377
+ */
1378
+ groupEnd(): void;
1379
+ }
1380
+
1381
+ /**
1382
+ * Console object for logging and debugging.
1383
+ */
1384
+ const console: Console;
1385
+ }
1386
+ `;
1387
+ var ENCODING_TYPES = `/**
1388
+ * Global Type Definitions for ../encoding/index.ts
1389
+ *
1390
+ * These types define the globals injected by setupEncoding() into an isolated-vm context.
1391
+ * Use these types to typecheck user code that will run inside the V8 isolate.
1392
+ */
1393
+
1394
+ export {};
1395
+
1396
+ declare global {
1397
+ /**
1398
+ * Decodes a Base64-encoded string.
1399
+ *
1400
+ * @param encodedData - The Base64 string to decode
1401
+ * @returns The decoded string
1402
+ * @throws DOMException if the input is not valid Base64
1403
+ *
1404
+ * @example
1405
+ * atob("SGVsbG8="); // "Hello"
1406
+ */
1407
+ function atob(encodedData: string): string;
1408
+
1409
+ /**
1410
+ * Encodes a string to Base64.
1411
+ *
1412
+ * @param stringToEncode - The string to encode (must contain only Latin1 characters)
1413
+ * @returns The Base64 encoded string
1414
+ * @throws DOMException if the string contains characters outside Latin1 range (0-255)
1415
+ *
1416
+ * @example
1417
+ * btoa("Hello"); // "SGVsbG8="
1418
+ */
1419
+ function btoa(stringToEncode: string): string;
1420
+
1421
+ // ============================================
1422
+ // Buffer
1423
+ // ============================================
1424
+
1425
+ /**
1426
+ * Buffer encoding types supported by the isolate Buffer implementation.
1427
+ */
1428
+ type BufferEncoding = "utf8" | "utf-8" | "base64" | "hex";
1429
+
1430
+ /**
1431
+ * Buffer class for working with binary data.
1432
+ * Extends Uint8Array for compatibility.
1433
+ * @see https://nodejs.org/api/buffer.html
1434
+ */
1435
+ interface Buffer extends Uint8Array {
1436
+ /**
1437
+ * Convert the buffer to a string.
1438
+ *
1439
+ * @param encoding - The encoding to use (default: "utf8")
1440
+ * @returns The string representation
1441
+ *
1442
+ * @example
1443
+ * const buf = Buffer.from("hello");
1444
+ * buf.toString(); // "hello"
1445
+ * buf.toString("hex"); // "68656c6c6f"
1446
+ * buf.toString("base64"); // "aGVsbG8="
1447
+ */
1448
+ toString(encoding?: BufferEncoding): string;
1449
+
1450
+ /**
1451
+ * Returns a new Buffer that references the same memory as the original,
1452
+ * but offset and cropped by the start and end indices.
1453
+ *
1454
+ * @param start - Start index (default: 0)
1455
+ * @param end - End index (default: buffer.length)
1456
+ * @returns A new Buffer instance
1457
+ *
1458
+ * @example
1459
+ * const buf = Buffer.from("hello");
1460
+ * buf.slice(1, 4).toString(); // "ell"
1461
+ */
1462
+ slice(start?: number, end?: number): Buffer;
1463
+
1464
+ /**
1465
+ * Returns a new Buffer that references the same memory as the original,
1466
+ * but offset and cropped by the start and end indices.
1467
+ *
1468
+ * @param start - Start index (default: 0)
1469
+ * @param end - End index (default: buffer.length)
1470
+ * @returns A new Buffer instance
1471
+ */
1472
+ subarray(start?: number, end?: number): Buffer;
1473
+ }
1474
+
1475
+ /**
1476
+ * Buffer constructor interface.
1477
+ */
1478
+ interface BufferConstructor {
1479
+ /**
1480
+ * Creates a new Buffer from a string, array, ArrayBuffer, or another Buffer.
1481
+ *
1482
+ * @param value - The value to create a buffer from
1483
+ * @param encodingOrOffset - Encoding for strings, or byte offset for ArrayBuffer
1484
+ * @param length - Length for ArrayBuffer (when offset is provided)
1485
+ * @returns A new Buffer instance
1486
+ *
1487
+ * @example
1488
+ * Buffer.from("hello"); // UTF-8 encoded
1489
+ * Buffer.from("aGVsbG8=", "base64"); // base64 decoded
1490
+ * Buffer.from("68656c6c6f", "hex"); // hex decoded
1491
+ * Buffer.from([104, 101, 108, 108, 111]); // from array
1492
+ */
1493
+ from(value: string, encoding?: BufferEncoding): Buffer;
1494
+ from(value: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
1495
+ from(value: Uint8Array | ReadonlyArray<number>): Buffer;
1496
+ from(value: Iterable<number>): Buffer;
1497
+
1498
+ /**
1499
+ * Allocates a new Buffer of the specified size, filled with zeros or the specified fill value.
1500
+ *
1501
+ * @param size - The size of the buffer in bytes
1502
+ * @param fill - Value to fill the buffer with (default: 0)
1503
+ * @param encoding - Encoding for string fill values
1504
+ * @returns A new Buffer instance
1505
+ *
1506
+ * @example
1507
+ * Buffer.alloc(5); // <Buffer 00 00 00 00 00>
1508
+ * Buffer.alloc(5, 1); // <Buffer 01 01 01 01 01>
1509
+ * Buffer.alloc(5, "ab"); // <Buffer 61 62 61 62 61>
1510
+ */
1511
+ alloc(size: number, fill?: number | string | Buffer, encoding?: BufferEncoding): Buffer;
1512
+
1513
+ /**
1514
+ * Allocates a new Buffer of the specified size without initializing the memory.
1515
+ * The contents are unknown and may contain sensitive data.
1516
+ *
1517
+ * @param size - The size of the buffer in bytes
1518
+ * @returns A new Buffer instance
1519
+ */
1520
+ allocUnsafe(size: number): Buffer;
1521
+
1522
+ /**
1523
+ * Concatenates a list of Buffers.
1524
+ *
1525
+ * @param list - Array of Buffer instances to concatenate
1526
+ * @param totalLength - Total length of the buffers (optional)
1527
+ * @returns A new Buffer instance
1528
+ *
1529
+ * @example
1530
+ * const buf1 = Buffer.from("hel");
1531
+ * const buf2 = Buffer.from("lo");
1532
+ * Buffer.concat([buf1, buf2]).toString(); // "hello"
1533
+ */
1534
+ concat(list: ReadonlyArray<Uint8Array>, totalLength?: number): Buffer;
1535
+
1536
+ /**
1537
+ * Returns true if the given object is a Buffer.
1538
+ *
1539
+ * @param obj - Object to test
1540
+ * @returns true if obj is a Buffer
1541
+ *
1542
+ * @example
1543
+ * Buffer.isBuffer(Buffer.from("test")); // true
1544
+ * Buffer.isBuffer(new Uint8Array(5)); // false
1545
+ */
1546
+ isBuffer(obj: unknown): obj is Buffer;
1547
+
1548
+ /**
1549
+ * Returns the byte length of a string when encoded.
1550
+ *
1551
+ * @param string - The string to measure
1552
+ * @param encoding - The encoding (default: "utf8")
1553
+ * @returns The byte length
1554
+ *
1555
+ * @example
1556
+ * Buffer.byteLength("hello"); // 5
1557
+ * Buffer.byteLength("aGVsbG8=", "base64"); // 5 (decoded length)
1558
+ */
1559
+ byteLength(string: string, encoding?: BufferEncoding): number;
1560
+ byteLength(buffer: ArrayBufferView | ArrayBuffer): number;
1561
+
1562
+ /**
1563
+ * Returns true if the encoding is a valid buffer encoding.
1564
+ *
1565
+ * @param encoding - The encoding to check
1566
+ * @returns true if the encoding is supported
1567
+ */
1568
+ isEncoding(encoding: string): encoding is BufferEncoding;
1569
+
1570
+ readonly prototype: Buffer;
1571
+ }
1572
+
1573
+ /**
1574
+ * Buffer class for working with binary data.
1575
+ * @see https://nodejs.org/api/buffer.html
1576
+ */
1577
+ const Buffer: BufferConstructor;
1578
+ }
1579
+ `;
1580
+ var CRYPTO_TYPES = `/**
1581
+ * Global Type Definitions for ../crypto/index.ts
1582
+ *
1583
+ * These types define the globals injected by setupCrypto() into an isolated-vm context.
1584
+ * Use these types to typecheck user code that will run inside the V8 isolate.
1585
+ *
1586
+ * @example
1587
+ * // Generate random bytes
1588
+ * const arr = new Uint8Array(16);
1589
+ * crypto.getRandomValues(arr);
1590
+ *
1591
+ * // Generate UUID
1592
+ * const uuid = crypto.randomUUID();
1593
+ *
1594
+ * // Use SubtleCrypto
1595
+ * const key = await crypto.subtle.generateKey(
1596
+ * { name: "AES-GCM", length: 256 },
1597
+ * true,
1598
+ * ["encrypt", "decrypt"]
1599
+ * );
1600
+ */
1601
+
1602
+ export {};
1603
+
1604
+ declare global {
1605
+ /**
1606
+ * CryptoKey represents a cryptographic key.
1607
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/CryptoKey
1608
+ */
1609
+ interface CryptoKey {
1610
+ /**
1611
+ * The type of key: "public", "private", or "secret".
1612
+ */
1613
+ readonly type: "public" | "private" | "secret";
1614
+
1615
+ /**
1616
+ * Whether the key can be exported.
1617
+ */
1618
+ readonly extractable: boolean;
1619
+
1620
+ /**
1621
+ * The algorithm used by this key.
1622
+ */
1623
+ readonly algorithm: KeyAlgorithm;
1624
+
1625
+ /**
1626
+ * The usages allowed for this key.
1627
+ */
1628
+ readonly usages: ReadonlyArray<KeyUsage>;
1629
+ }
1630
+
1631
+ /**
1632
+ * CryptoKey constructor (keys cannot be constructed directly).
1633
+ */
1634
+ const CryptoKey: {
1635
+ prototype: CryptoKey;
1636
+ };
1637
+
1638
+ /**
1639
+ * SubtleCrypto interface for cryptographic operations.
1640
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto
1641
+ */
1642
+ interface SubtleCrypto {
1643
+ /**
1644
+ * Generate a digest (hash) of the given data.
1645
+ *
1646
+ * @param algorithm - Hash algorithm (e.g., "SHA-256", "SHA-384", "SHA-512")
1647
+ * @param data - Data to hash
1648
+ * @returns Promise resolving to the hash as ArrayBuffer
1649
+ */
1650
+ digest(
1651
+ algorithm: AlgorithmIdentifier,
1652
+ data: BufferSource
1653
+ ): Promise<ArrayBuffer>;
1654
+
1655
+ /**
1656
+ * Generate a new cryptographic key or key pair.
1657
+ *
1658
+ * @param algorithm - Key generation algorithm
1659
+ * @param extractable - Whether the key can be exported
1660
+ * @param keyUsages - Allowed key usages
1661
+ * @returns Promise resolving to a CryptoKey or CryptoKeyPair
1662
+ */
1663
+ generateKey(
1664
+ algorithm: RsaHashedKeyGenParams | EcKeyGenParams | AesKeyGenParams | HmacKeyGenParams,
1665
+ extractable: boolean,
1666
+ keyUsages: KeyUsage[]
1667
+ ): Promise<CryptoKey | CryptoKeyPair>;
1668
+
1669
+ /**
1670
+ * Sign data using a private key.
1671
+ *
1672
+ * @param algorithm - Signing algorithm
1673
+ * @param key - Private key to sign with
1674
+ * @param data - Data to sign
1675
+ * @returns Promise resolving to the signature as ArrayBuffer
1676
+ */
1677
+ sign(
1678
+ algorithm: AlgorithmIdentifier,
1679
+ key: CryptoKey,
1680
+ data: BufferSource
1681
+ ): Promise<ArrayBuffer>;
1682
+
1683
+ /**
1684
+ * Verify a signature.
1685
+ *
1686
+ * @param algorithm - Signing algorithm
1687
+ * @param key - Public key to verify with
1688
+ * @param signature - Signature to verify
1689
+ * @param data - Data that was signed
1690
+ * @returns Promise resolving to true if valid, false otherwise
1691
+ */
1692
+ verify(
1693
+ algorithm: AlgorithmIdentifier,
1694
+ key: CryptoKey,
1695
+ signature: BufferSource,
1696
+ data: BufferSource
1697
+ ): Promise<boolean>;
1698
+
1699
+ /**
1700
+ * Encrypt data.
1701
+ *
1702
+ * @param algorithm - Encryption algorithm
1703
+ * @param key - Encryption key
1704
+ * @param data - Data to encrypt
1705
+ * @returns Promise resolving to encrypted data as ArrayBuffer
1706
+ */
1707
+ encrypt(
1708
+ algorithm: AlgorithmIdentifier,
1709
+ key: CryptoKey,
1710
+ data: BufferSource
1711
+ ): Promise<ArrayBuffer>;
1712
+
1713
+ /**
1714
+ * Decrypt data.
1715
+ *
1716
+ * @param algorithm - Decryption algorithm
1717
+ * @param key - Decryption key
1718
+ * @param data - Data to decrypt
1719
+ * @returns Promise resolving to decrypted data as ArrayBuffer
1720
+ */
1721
+ decrypt(
1722
+ algorithm: AlgorithmIdentifier,
1723
+ key: CryptoKey,
1724
+ data: BufferSource
1725
+ ): Promise<ArrayBuffer>;
1726
+
1727
+ /**
1728
+ * Import a key from external data.
1729
+ *
1730
+ * @param format - Key format ("raw", "pkcs8", "spki", "jwk")
1731
+ * @param keyData - Key data
1732
+ * @param algorithm - Key algorithm
1733
+ * @param extractable - Whether the key can be exported
1734
+ * @param keyUsages - Allowed key usages
1735
+ * @returns Promise resolving to a CryptoKey
1736
+ */
1737
+ importKey(
1738
+ format: "raw" | "pkcs8" | "spki" | "jwk",
1739
+ keyData: BufferSource | JsonWebKey,
1740
+ algorithm: AlgorithmIdentifier,
1741
+ extractable: boolean,
1742
+ keyUsages: KeyUsage[]
1743
+ ): Promise<CryptoKey>;
1744
+
1745
+ /**
1746
+ * Export a key.
1747
+ *
1748
+ * @param format - Export format ("raw", "pkcs8", "spki", "jwk")
1749
+ * @param key - Key to export
1750
+ * @returns Promise resolving to ArrayBuffer or JsonWebKey
1751
+ */
1752
+ exportKey(
1753
+ format: "raw" | "pkcs8" | "spki" | "jwk",
1754
+ key: CryptoKey
1755
+ ): Promise<ArrayBuffer | JsonWebKey>;
1756
+
1757
+ /**
1758
+ * Derive bits from a key.
1759
+ *
1760
+ * @param algorithm - Derivation algorithm
1761
+ * @param baseKey - Base key for derivation
1762
+ * @param length - Number of bits to derive
1763
+ * @returns Promise resolving to derived bits as ArrayBuffer
1764
+ */
1765
+ deriveBits(
1766
+ algorithm: AlgorithmIdentifier,
1767
+ baseKey: CryptoKey,
1768
+ length: number
1769
+ ): Promise<ArrayBuffer>;
1770
+
1771
+ /**
1772
+ * Derive a new key from a base key.
1773
+ *
1774
+ * @param algorithm - Derivation algorithm
1775
+ * @param baseKey - Base key for derivation
1776
+ * @param derivedKeyType - Type of key to derive
1777
+ * @param extractable - Whether the derived key can be exported
1778
+ * @param keyUsages - Allowed usages for derived key
1779
+ * @returns Promise resolving to a CryptoKey
1780
+ */
1781
+ deriveKey(
1782
+ algorithm: AlgorithmIdentifier,
1783
+ baseKey: CryptoKey,
1784
+ derivedKeyType: AlgorithmIdentifier,
1785
+ extractable: boolean,
1786
+ keyUsages: KeyUsage[]
1787
+ ): Promise<CryptoKey>;
1788
+
1789
+ /**
1790
+ * Wrap a key for secure export.
1791
+ *
1792
+ * @param format - Key format
1793
+ * @param key - Key to wrap
1794
+ * @param wrappingKey - Key to wrap with
1795
+ * @param wrapAlgorithm - Wrapping algorithm
1796
+ * @returns Promise resolving to wrapped key as ArrayBuffer
1797
+ */
1798
+ wrapKey(
1799
+ format: "raw" | "pkcs8" | "spki" | "jwk",
1800
+ key: CryptoKey,
1801
+ wrappingKey: CryptoKey,
1802
+ wrapAlgorithm: AlgorithmIdentifier
1803
+ ): Promise<ArrayBuffer>;
1804
+
1805
+ /**
1806
+ * Unwrap a wrapped key.
1807
+ *
1808
+ * @param format - Key format
1809
+ * @param wrappedKey - Wrapped key data
1810
+ * @param unwrappingKey - Key to unwrap with
1811
+ * @param unwrapAlgorithm - Unwrapping algorithm
1812
+ * @param unwrappedKeyAlgorithm - Algorithm for the unwrapped key
1813
+ * @param extractable - Whether the unwrapped key can be exported
1814
+ * @param keyUsages - Allowed usages for unwrapped key
1815
+ * @returns Promise resolving to a CryptoKey
1816
+ */
1817
+ unwrapKey(
1818
+ format: "raw" | "pkcs8" | "spki" | "jwk",
1819
+ wrappedKey: BufferSource,
1820
+ unwrappingKey: CryptoKey,
1821
+ unwrapAlgorithm: AlgorithmIdentifier,
1822
+ unwrappedKeyAlgorithm: AlgorithmIdentifier,
1823
+ extractable: boolean,
1824
+ keyUsages: KeyUsage[]
1825
+ ): Promise<CryptoKey>;
1826
+ }
1827
+
1828
+ /**
1829
+ * Crypto interface providing cryptographic functionality.
1830
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/Crypto
1831
+ */
1832
+ interface Crypto {
1833
+ /**
1834
+ * SubtleCrypto interface for cryptographic operations.
1835
+ */
1836
+ readonly subtle: SubtleCrypto;
1837
+
1838
+ /**
1839
+ * Fill a TypedArray with cryptographically random values.
1840
+ *
1841
+ * @param array - TypedArray to fill (max 65536 bytes)
1842
+ * @returns The same array, filled with random values
1843
+ *
1844
+ * @example
1845
+ * const arr = new Uint8Array(16);
1846
+ * crypto.getRandomValues(arr);
1847
+ */
1848
+ getRandomValues<T extends ArrayBufferView | null>(array: T): T;
1849
+
1850
+ /**
1851
+ * Generate a random UUID v4.
1852
+ *
1853
+ * @returns A random UUID string
1854
+ *
1855
+ * @example
1856
+ * const uuid = crypto.randomUUID();
1857
+ * // "550e8400-e29b-41d4-a716-446655440000"
1858
+ */
1859
+ randomUUID(): string;
1860
+ }
1861
+
1862
+ /**
1863
+ * Crypto object providing cryptographic functionality.
1864
+ */
1865
+ const crypto: Crypto;
1866
+ }
1867
+ `;
1868
+ var PATH_TYPES = `/**
1869
+ * Global Type Definitions for ../path/index.ts
1870
+ *
1871
+ * These types define the globals injected by setupPath() into an isolated-vm context.
1872
+ * Use these types to typecheck user code that will run inside the V8 isolate.
1873
+ *
1874
+ * @example
1875
+ * // Typecheck isolate code with path operations
1876
+ * const joined = path.join('/foo', 'bar', 'baz');
1877
+ * const resolved = path.resolve('relative/path');
1878
+ * const cwd = path.cwd();
1879
+ */
1880
+
1881
+ export {};
1882
+
1883
+ declare global {
1884
+ /**
1885
+ * Parsed path object returned by path.parse().
1886
+ */
1887
+ interface ParsedPath {
1888
+ /** The root of the path (e.g., "/" for absolute paths, "" for relative) */
1889
+ root: string;
1890
+ /** The directory portion of the path */
1891
+ dir: string;
1892
+ /** The file name including extension */
1893
+ base: string;
1894
+ /** The file extension (e.g., ".txt") */
1895
+ ext: string;
1896
+ /** The file name without extension */
1897
+ name: string;
1898
+ }
1899
+
1900
+ /**
1901
+ * Input object for path.format().
1902
+ */
1903
+ interface FormatInputPathObject {
1904
+ root?: string;
1905
+ dir?: string;
1906
+ base?: string;
1907
+ ext?: string;
1908
+ name?: string;
1909
+ }
1910
+
1911
+ /**
1912
+ * Path utilities for POSIX paths.
1913
+ * @see https://nodejs.org/api/path.html
1914
+ */
1915
+ namespace path {
1916
+ /**
1917
+ * Join path segments with the platform-specific separator.
1918
+ *
1919
+ * @param paths - Path segments to join
1920
+ * @returns The joined path, normalized
1921
+ *
1922
+ * @example
1923
+ * path.join('/foo', 'bar', 'baz'); // "/foo/bar/baz"
1924
+ * path.join('foo', 'bar', '..', 'baz'); // "foo/baz"
1925
+ */
1926
+ function join(...paths: string[]): string;
1927
+
1928
+ /**
1929
+ * Normalize a path, resolving '..' and '.' segments.
1930
+ *
1931
+ * @param p - The path to normalize
1932
+ * @returns The normalized path
1933
+ *
1934
+ * @example
1935
+ * path.normalize('/foo/bar/../baz'); // "/foo/baz"
1936
+ * path.normalize('/foo//bar'); // "/foo/bar"
1937
+ */
1938
+ function normalize(p: string): string;
1939
+
1940
+ /**
1941
+ * Get the last portion of a path (the file name).
1942
+ *
1943
+ * @param p - The path
1944
+ * @param ext - Optional extension to remove from the result
1945
+ * @returns The base name of the path
1946
+ *
1947
+ * @example
1948
+ * path.basename('/foo/bar/baz.txt'); // "baz.txt"
1949
+ * path.basename('/foo/bar/baz.txt', '.txt'); // "baz"
1950
+ */
1951
+ function basename(p: string, ext?: string): string;
1952
+
1953
+ /**
1954
+ * Get the directory name of a path.
1955
+ *
1956
+ * @param p - The path
1957
+ * @returns The directory portion of the path
1958
+ *
1959
+ * @example
1960
+ * path.dirname('/foo/bar/baz.txt'); // "/foo/bar"
1961
+ * path.dirname('/foo'); // "/"
1962
+ */
1963
+ function dirname(p: string): string;
1964
+
1965
+ /**
1966
+ * Get the extension of a path.
1967
+ *
1968
+ * @param p - The path
1969
+ * @returns The extension including the dot, or empty string
1970
+ *
1971
+ * @example
1972
+ * path.extname('file.txt'); // ".txt"
1973
+ * path.extname('file.tar.gz'); // ".gz"
1974
+ * path.extname('.bashrc'); // ""
1975
+ */
1976
+ function extname(p: string): string;
1977
+
1978
+ /**
1979
+ * Check if a path is absolute.
1980
+ *
1981
+ * @param p - The path to check
1982
+ * @returns True if the path is absolute
1983
+ *
1984
+ * @example
1985
+ * path.isAbsolute('/foo/bar'); // true
1986
+ * path.isAbsolute('foo/bar'); // false
1987
+ */
1988
+ function isAbsolute(p: string): boolean;
1989
+
1990
+ /**
1991
+ * Parse a path into its components.
1992
+ *
1993
+ * @param p - The path to parse
1994
+ * @returns An object with root, dir, base, ext, and name properties
1995
+ *
1996
+ * @example
1997
+ * path.parse('/foo/bar/baz.txt');
1998
+ * // { root: "/", dir: "/foo/bar", base: "baz.txt", ext: ".txt", name: "baz" }
1999
+ */
2000
+ function parse(p: string): ParsedPath;
2001
+
2002
+ /**
2003
+ * Build a path from an object.
2004
+ *
2005
+ * @param pathObject - Object with path components
2006
+ * @returns The formatted path string
2007
+ *
2008
+ * @example
2009
+ * path.format({ dir: '/foo/bar', base: 'baz.txt' }); // "/foo/bar/baz.txt"
2010
+ * path.format({ root: '/', name: 'file', ext: '.txt' }); // "/file.txt"
2011
+ */
2012
+ function format(pathObject: FormatInputPathObject): string;
2013
+
2014
+ /**
2015
+ * Resolve a sequence of paths to an absolute path.
2016
+ * Processes paths from right to left, prepending each until an absolute path is formed.
2017
+ * Uses the configured working directory for relative paths.
2018
+ *
2019
+ * @param paths - Path segments to resolve
2020
+ * @returns The resolved absolute path
2021
+ *
2022
+ * @example
2023
+ * // With cwd set to "/home/user"
2024
+ * path.resolve('foo/bar'); // "/home/user/foo/bar"
2025
+ * path.resolve('/foo', 'bar'); // "/foo/bar"
2026
+ * path.resolve('/foo', '/bar', 'baz'); // "/bar/baz"
2027
+ */
2028
+ function resolve(...paths: string[]): string;
2029
+
2030
+ /**
2031
+ * Compute the relative path from one path to another.
2032
+ *
2033
+ * @param from - The source path
2034
+ * @param to - The destination path
2035
+ * @returns The relative path from 'from' to 'to'
2036
+ *
2037
+ * @example
2038
+ * path.relative('/foo/bar', '/foo/baz'); // "../baz"
2039
+ * path.relative('/foo', '/foo/bar/baz'); // "bar/baz"
2040
+ */
2041
+ function relative(from: string, to: string): string;
2042
+
2043
+ /**
2044
+ * Get the configured working directory.
2045
+ *
2046
+ * @returns The current working directory
2047
+ *
2048
+ * @example
2049
+ * path.cwd(); // "/home/user" (or whatever was configured)
2050
+ */
2051
+ function cwd(): string;
2052
+
2053
+ /**
2054
+ * The platform-specific path segment separator.
2055
+ * Always "/" for POSIX paths.
2056
+ */
2057
+ const sep: string;
2058
+
2059
+ /**
2060
+ * The platform-specific path delimiter.
2061
+ * Always ":" for POSIX paths.
2062
+ */
2063
+ const delimiter: string;
2064
+ }
2065
+ }
2066
+ `;
2067
+ var TIMERS_TYPES = `/**
2068
+ * Global Type Definitions for ../timers/index.ts
2069
+ *
2070
+ * These types define the globals injected by setupTimers() into an isolated-vm context.
2071
+ * Use these types to typecheck user code that will run inside the V8 isolate.
2072
+ *
2073
+ * @example
2074
+ * const timeoutId = setTimeout(() => {
2075
+ * console.log("fired!");
2076
+ * }, 1000);
2077
+ *
2078
+ * clearTimeout(timeoutId);
2079
+ *
2080
+ * const intervalId = setInterval(() => {
2081
+ * console.log("tick");
2082
+ * }, 100);
2083
+ *
2084
+ * clearInterval(intervalId);
2085
+ */
2086
+
2087
+ export {};
2088
+
2089
+ declare global {
2090
+ /**
2091
+ * Schedule a callback to execute after a delay.
2092
+ *
2093
+ * @param callback - The function to call after the delay
2094
+ * @param ms - The delay in milliseconds (default: 0)
2095
+ * @param args - Additional arguments to pass to the callback
2096
+ * @returns A timer ID that can be passed to clearTimeout
2097
+ *
2098
+ * @example
2099
+ * const id = setTimeout(() => console.log("done"), 1000);
2100
+ * setTimeout((a, b) => console.log(a, b), 100, "hello", "world");
2101
+ */
2102
+ function setTimeout(
2103
+ callback: (...args: unknown[]) => void,
2104
+ ms?: number,
2105
+ ...args: unknown[]
2106
+ ): number;
2107
+
2108
+ /**
2109
+ * Schedule a callback to execute repeatedly at a fixed interval.
2110
+ *
2111
+ * @param callback - The function to call at each interval
2112
+ * @param ms - The interval in milliseconds (minimum: 4ms)
2113
+ * @param args - Additional arguments to pass to the callback
2114
+ * @returns A timer ID that can be passed to clearInterval
2115
+ *
2116
+ * @example
2117
+ * const id = setInterval(() => console.log("tick"), 1000);
2118
+ */
2119
+ function setInterval(
2120
+ callback: (...args: unknown[]) => void,
2121
+ ms?: number,
2122
+ ...args: unknown[]
2123
+ ): number;
2124
+
2125
+ /**
2126
+ * Cancel a timeout previously scheduled with setTimeout.
2127
+ *
2128
+ * @param id - The timer ID returned by setTimeout
2129
+ *
2130
+ * @example
2131
+ * const id = setTimeout(() => {}, 1000);
2132
+ * clearTimeout(id);
2133
+ */
2134
+ function clearTimeout(id: number | undefined): void;
2135
+
2136
+ /**
2137
+ * Cancel an interval previously scheduled with setInterval.
2138
+ *
2139
+ * @param id - The timer ID returned by setInterval
2140
+ *
2141
+ * @example
2142
+ * const id = setInterval(() => {}, 1000);
2143
+ * clearInterval(id);
2144
+ */
2145
+ function clearInterval(id: number | undefined): void;
2146
+ }
2147
+ `;
2148
+ var PLAYWRIGHT_TYPES = `
2149
+ /**
2150
+ * Locator represents an element or group of elements in the page.
2151
+ */
2152
+ declare class Locator {
2153
+ /** Click the element */
2154
+ click(): Promise<void>;
2155
+ /** Double-click the element */
2156
+ dblclick(): Promise<void>;
2157
+ /** Fill an input element with text */
2158
+ fill(text: string): Promise<void>;
2159
+ /** Type text into an element (key by key) */
2160
+ type(text: string): Promise<void>;
2161
+ /** Check a checkbox or radio */
2162
+ check(): Promise<void>;
2163
+ /** Uncheck a checkbox */
2164
+ uncheck(): Promise<void>;
2165
+ /** Select an option in a dropdown */
2166
+ selectOption(value: string | string[]): Promise<void>;
2167
+ /** Clear an input element */
2168
+ clear(): Promise<void>;
2169
+ /** Press a key */
2170
+ press(key: string): Promise<void>;
2171
+ /** Hover over the element */
2172
+ hover(): Promise<void>;
2173
+ /** Focus the element */
2174
+ focus(): Promise<void>;
2175
+ /** Get text content of the element */
2176
+ textContent(): Promise<string | null>;
2177
+ /** Get the value of an input element */
2178
+ inputValue(): Promise<string>;
2179
+ /** Check if the element is visible */
2180
+ isVisible(): Promise<boolean>;
2181
+ /** Check if the element is enabled */
2182
+ isEnabled(): Promise<boolean>;
2183
+ /** Check if the element is checked */
2184
+ isChecked(): Promise<boolean>;
2185
+ /** Check if the element is disabled */
2186
+ isDisabled(): Promise<boolean>;
2187
+ /** Check if the element is hidden */
2188
+ isHidden(): Promise<boolean>;
2189
+ /** Get the count of matching elements */
2190
+ count(): Promise<number>;
2191
+ /** Get an attribute value */
2192
+ getAttribute(name: string): Promise<string | null>;
2193
+ /** Get innerHTML */
2194
+ innerHTML(): Promise<string>;
2195
+ /** Get innerText */
2196
+ innerText(): Promise<string>;
2197
+ /** Get all text contents */
2198
+ allTextContents(): Promise<string[]>;
2199
+ /** Get all inner texts */
2200
+ allInnerTexts(): Promise<string[]>;
2201
+ /** Wait for the element to match a state */
2202
+ waitFor(options?: { state?: "attached" | "detached" | "visible" | "hidden"; timeout?: number }): Promise<void>;
2203
+ /** Get bounding box */
2204
+ boundingBox(): Promise<{ x: number; y: number; width: number; height: number } | null>;
2205
+ /** Set input files for a file input */
2206
+ setInputFiles(files: string | string[] | { name: string; mimeType: string; buffer: ArrayBuffer | Uint8Array | string }[]): Promise<void>;
2207
+ /** Take a screenshot of the element */
2208
+ screenshot(options?: { path?: string; type?: "png" | "jpeg"; quality?: number }): Promise<string>;
2209
+ /** Drag to another element */
2210
+ dragTo(target: Locator): Promise<void>;
2211
+ /** Scroll element into view */
2212
+ scrollIntoViewIfNeeded(): Promise<void>;
2213
+ /** Highlight the element for debugging */
2214
+ highlight(): Promise<void>;
2215
+ /** Evaluate a function in the context of the element */
2216
+ evaluate<R>(fn: (el: Element, arg?: unknown) => R, arg?: unknown): Promise<R>;
2217
+ /** Evaluate a function for all matching elements */
2218
+ evaluateAll<R>(fn: (els: Element[], arg?: unknown) => R, arg?: unknown): Promise<R>;
2219
+
2220
+ // Chaining methods
2221
+ /** Chain with another CSS selector */
2222
+ locator(selector: string): Locator;
2223
+ /** Chain with getByRole */
2224
+ getByRole(role: string, options?: { name?: string | RegExp; exact?: boolean }): Locator;
2225
+ /** Chain with getByText */
2226
+ getByText(text: string | RegExp): Locator;
2227
+ /** Chain with getByLabel */
2228
+ getByLabel(label: string | RegExp): Locator;
2229
+ /** Chain with getByPlaceholder */
2230
+ getByPlaceholder(placeholder: string | RegExp): Locator;
2231
+ /** Chain with getByTestId */
2232
+ getByTestId(testId: string): Locator;
2233
+ /** Chain with getByAltText */
2234
+ getByAltText(alt: string | RegExp): Locator;
2235
+ /** Chain with getByTitle */
2236
+ getByTitle(title: string | RegExp): Locator;
2237
+
2238
+ // Subset selection
2239
+ /** Get all matching locators as an array */
2240
+ all(): Promise<Locator[]>;
2241
+ /** Get the nth matching element */
2242
+ nth(index: number): Locator;
2243
+ /** Get the first matching element */
2244
+ first(): Locator;
2245
+ /** Get the last matching element */
2246
+ last(): Locator;
2247
+
2248
+ // Filtering
2249
+ /** Filter locators by additional criteria */
2250
+ filter(options: { hasText?: string | RegExp; hasNotText?: string | RegExp; has?: Locator; hasNot?: Locator }): Locator;
2251
+ /** Create a locator matching either this or the other locator */
2252
+ or(other: Locator): Locator;
2253
+ /** Create a locator matching both this and the other locator */
2254
+ and(other: Locator): Locator;
2255
+ }
2256
+
2257
+ /**
2258
+ * FrameLocator for interacting with elements inside iframes.
2259
+ */
2260
+ interface FrameLocator {
2261
+ locator(selector: string): Locator;
2262
+ getByRole(role: string, options?: { name?: string | RegExp; exact?: boolean }): Locator;
2263
+ getByText(text: string | RegExp): Locator;
2264
+ getByLabel(label: string | RegExp): Locator;
2265
+ getByPlaceholder(placeholder: string | RegExp): Locator;
2266
+ getByTestId(testId: string): Locator;
2267
+ getByAltText(alt: string | RegExp): Locator;
2268
+ getByTitle(title: string | RegExp): Locator;
2269
+ }
2270
+
2271
+ /**
2272
+ * Keyboard API for simulating keyboard input.
2273
+ */
2274
+ interface Keyboard {
2275
+ type(text: string, options?: { delay?: number }): Promise<void>;
2276
+ press(key: string, options?: { delay?: number }): Promise<void>;
2277
+ down(key: string): Promise<void>;
2278
+ up(key: string): Promise<void>;
2279
+ insertText(text: string): Promise<void>;
2280
+ }
2281
+
2282
+ /**
2283
+ * Mouse API for simulating mouse input.
2284
+ */
2285
+ interface Mouse {
2286
+ move(x: number, y: number, options?: { steps?: number }): Promise<void>;
2287
+ click(x: number, y: number, options?: { button?: "left" | "right" | "middle"; clickCount?: number; delay?: number }): Promise<void>;
2288
+ down(options?: { button?: "left" | "right" | "middle"; clickCount?: number }): Promise<void>;
2289
+ up(options?: { button?: "left" | "right" | "middle"; clickCount?: number }): Promise<void>;
2290
+ wheel(deltaX: number, deltaY: number): Promise<void>;
2291
+ }
2292
+
2293
+ /**
2294
+ * API Response from page.request methods.
2295
+ */
2296
+ interface APIResponse {
2297
+ status(): number;
2298
+ ok(): boolean;
2299
+ headers(): Record<string, string>;
2300
+ json(): Promise<unknown>;
2301
+ text(): Promise<string>;
2302
+ body(): Promise<ArrayBuffer>;
2303
+ }
2304
+
2305
+ /**
2306
+ * Request API for making HTTP requests with page cookies.
2307
+ */
2308
+ interface APIRequestContext {
2309
+ fetch(url: string, options?: { method?: string; data?: unknown; headers?: Record<string, string> }): Promise<APIResponse>;
2310
+ get(url: string, options?: { headers?: Record<string, string> }): Promise<APIResponse>;
2311
+ post(url: string, options?: { data?: unknown; headers?: Record<string, string> }): Promise<APIResponse>;
2312
+ put(url: string, options?: { data?: unknown; headers?: Record<string, string> }): Promise<APIResponse>;
2313
+ delete(url: string, options?: { headers?: Record<string, string> }): Promise<APIResponse>;
2314
+ }
2315
+
2316
+ /**
2317
+ * Frame information.
2318
+ */
2319
+ interface FrameInfo {
2320
+ name: string;
2321
+ url: string;
2322
+ }
2323
+
2324
+ /**
2325
+ * Cookie data.
2326
+ */
2327
+ interface Cookie {
2328
+ name: string;
2329
+ value: string;
2330
+ domain?: string;
2331
+ path?: string;
2332
+ expires?: number;
2333
+ httpOnly?: boolean;
2334
+ secure?: boolean;
2335
+ sameSite?: "Strict" | "Lax" | "None";
2336
+ }
2337
+
2338
+ /**
2339
+ * IsolatePage - represents a browser page in the isolate.
2340
+ */
2341
+ declare class IsolatePage {
2342
+ /** Navigate to a URL */
2343
+ goto(url: string, options?: { waitUntil?: "load" | "domcontentloaded" | "networkidle" }): Promise<void>;
2344
+ /** Reload the page */
2345
+ reload(): Promise<void>;
2346
+ /** Get the current URL */
2347
+ url(): Promise<string>;
2348
+ /** Get the page title */
2349
+ title(): Promise<string>;
2350
+ /** Get the page HTML content */
2351
+ content(): Promise<string>;
2352
+ /** Wait for a selector to appear */
2353
+ waitForSelector(selector: string, options?: { state?: "attached" | "detached" | "visible" | "hidden"; timeout?: number }): Promise<void>;
2354
+ /** Wait for a specified time */
2355
+ waitForTimeout(ms: number): Promise<void>;
2356
+ /** Wait for a load state */
2357
+ waitForLoadState(state?: "load" | "domcontentloaded" | "networkidle"): Promise<void>;
2358
+ /** Wait for the URL to match */
2359
+ waitForURL(url: string | RegExp, options?: { timeout?: number; waitUntil?: "load" | "domcontentloaded" | "networkidle" }): Promise<void>;
2360
+ /** Evaluate JavaScript in the browser context */
2361
+ evaluate<R>(script: string | (() => R) | ((arg: unknown) => R), arg?: unknown): Promise<R>;
2362
+ /** Create a locator by CSS selector */
2363
+ locator(selector: string): Locator;
2364
+ /** Create a locator by ARIA role */
2365
+ getByRole(role: string, options?: { name?: string | RegExp; exact?: boolean }): Locator;
2366
+ /** Create a locator by text content */
2367
+ getByText(text: string | RegExp): Locator;
2368
+ /** Create a locator by label */
2369
+ getByLabel(label: string | RegExp): Locator;
2370
+ /** Create a locator by placeholder */
2371
+ getByPlaceholder(placeholder: string | RegExp): Locator;
2372
+ /** Create a locator by test ID */
2373
+ getByTestId(testId: string): Locator;
2374
+ /** Create a locator by alt text */
2375
+ getByAltText(alt: string | RegExp): Locator;
2376
+ /** Create a locator by title */
2377
+ getByTitle(title: string | RegExp): Locator;
2378
+ /** Create a frame locator */
2379
+ frameLocator(selector: string): FrameLocator;
2380
+ /** Navigate back */
2381
+ goBack(options?: { waitUntil?: "load" | "domcontentloaded" | "networkidle" }): Promise<void>;
2382
+ /** Navigate forward */
2383
+ goForward(options?: { waitUntil?: "load" | "domcontentloaded" | "networkidle" }): Promise<void>;
2384
+ /** Click an element (shorthand) */
2385
+ click(selector: string): Promise<void>;
2386
+ /** Fill an input (shorthand) */
2387
+ fill(selector: string, value: string): Promise<void>;
2388
+ /** Take a screenshot */
2389
+ screenshot(options?: { path?: string; fullPage?: boolean; type?: "png" | "jpeg"; quality?: number }): Promise<string>;
2390
+ /** Generate a PDF (Chromium only) */
2391
+ pdf(options?: { path?: string; format?: string; landscape?: boolean; margin?: { top?: string; bottom?: string; left?: string; right?: string } }): Promise<string>;
2392
+ /** Set the viewport size */
2393
+ setViewportSize(size: { width: number; height: number }): Promise<void>;
2394
+ /** Get the viewport size */
2395
+ viewportSize(): Promise<{ width: number; height: number } | null>;
2396
+ /** Emulate media type or color scheme */
2397
+ emulateMedia(options: { media?: "screen" | "print" | null; colorScheme?: "light" | "dark" | "no-preference" | null }): Promise<void>;
2398
+ /** Set extra HTTP headers */
2399
+ setExtraHTTPHeaders(headers: Record<string, string>): Promise<void>;
2400
+ /** Bring the page to front */
2401
+ bringToFront(): Promise<void>;
2402
+ /** Close the page */
2403
+ close(): Promise<void>;
2404
+ /** Check if the page is closed */
2405
+ isClosed(): Promise<boolean>;
2406
+ /** Pause execution (for debugging) */
2407
+ pause(): Promise<void>;
2408
+ /** Get all frames */
2409
+ frames(): Promise<FrameInfo[]>;
2410
+ /** Get the main frame */
2411
+ mainFrame(): Promise<FrameInfo>;
2412
+ /** Get the browser context for this page */
2413
+ context(): IsolateContext;
2414
+ /** Keyboard API */
2415
+ readonly keyboard: Keyboard;
2416
+ /** Mouse API */
2417
+ readonly mouse: Mouse;
2418
+ /** Request API for making HTTP requests */
2419
+ readonly request: APIRequestContext;
2420
+ }
2421
+
2422
+ /**
2423
+ * IsolateContext - represents a browser context in the isolate.
2424
+ */
2425
+ declare class IsolateContext {
2426
+ /** Create a new page in this context (requires createPage callback) */
2427
+ newPage(): Promise<IsolatePage>;
2428
+ /** Close this context and all its pages */
2429
+ close(): Promise<void>;
2430
+ /** Clear all cookies */
2431
+ clearCookies(): Promise<void>;
2432
+ /** Add cookies */
2433
+ addCookies(cookies: Cookie[]): Promise<void>;
2434
+ /** Get cookies */
2435
+ cookies(urls?: string | string[]): Promise<Cookie[]>;
2436
+ }
2437
+
2438
+ /**
2439
+ * Browser object for creating new contexts.
2440
+ */
2441
+ interface IsolateBrowser {
2442
+ /** Create a new browser context (requires createContext callback) */
2443
+ newContext(options?: {
2444
+ viewport?: { width: number; height: number } | null;
2445
+ userAgent?: string;
2446
+ locale?: string;
2447
+ timezoneId?: string;
2448
+ geolocation?: { latitude: number; longitude: number; accuracy?: number };
2449
+ permissions?: string[];
2450
+ colorScheme?: "light" | "dark" | "no-preference";
2451
+ }): Promise<IsolateContext>;
2452
+ }
2453
+
2454
+ /**
2455
+ * The default page object.
2456
+ */
2457
+ declare const page: IsolatePage;
2458
+
2459
+ /**
2460
+ * The default browser context.
2461
+ */
2462
+ declare const context: IsolateContext;
2463
+
2464
+ /**
2465
+ * Browser object for creating new contexts.
2466
+ */
2467
+ declare const browser: IsolateBrowser;
2468
+
2469
+ // ============================================================================
2470
+ // Playwright Expect Matchers (extends test-environment expect)
2471
+ // ============================================================================
2472
+
2473
+ /**
2474
+ * Options for locator assertion timeouts.
2475
+ */
2476
+ interface LocatorAssertionOptions {
2477
+ timeout?: number;
2478
+ }
2479
+
2480
+ /**
2481
+ * Locator-specific assertion matchers (added to expect when using Playwright).
2482
+ * These are available when calling expect(locator).
2483
+ */
2484
+ interface PlaywrightLocatorMatchers {
2485
+ /** Assert element is visible */
2486
+ toBeVisible(options?: LocatorAssertionOptions): Promise<void>;
2487
+ /** Assert element is hidden */
2488
+ toBeHidden(options?: LocatorAssertionOptions): Promise<void>;
2489
+ /** Assert element is enabled */
2490
+ toBeEnabled(options?: LocatorAssertionOptions): Promise<void>;
2491
+ /** Assert element is disabled */
2492
+ toBeDisabled(options?: LocatorAssertionOptions): Promise<void>;
2493
+ /** Assert element is checked */
2494
+ toBeChecked(options?: LocatorAssertionOptions): Promise<void>;
2495
+ /** Assert element is focused */
2496
+ toBeFocused(options?: LocatorAssertionOptions): Promise<void>;
2497
+ /** Assert element is empty */
2498
+ toBeEmpty(options?: LocatorAssertionOptions): Promise<void>;
2499
+ /** Assert element is attached to DOM */
2500
+ toBeAttached(options?: LocatorAssertionOptions): Promise<void>;
2501
+ /** Assert element is editable */
2502
+ toBeEditable(options?: LocatorAssertionOptions): Promise<void>;
2503
+ /** Assert element is in viewport */
2504
+ toBeInViewport(options?: LocatorAssertionOptions): Promise<void>;
2505
+ /** Assert element contains text */
2506
+ toContainText(expected: string | RegExp, options?: LocatorAssertionOptions): Promise<void>;
2507
+ /** Assert element has exact text */
2508
+ toHaveText(expected: string | RegExp, options?: LocatorAssertionOptions): Promise<void>;
2509
+ /** Assert element has value (for inputs) */
2510
+ toHaveValue(expected: string, options?: LocatorAssertionOptions): Promise<void>;
2511
+ /** Assert element has attribute */
2512
+ toHaveAttribute(name: string, value?: string | RegExp, options?: LocatorAssertionOptions): Promise<void>;
2513
+ /** Assert element count */
2514
+ toHaveCount(count: number, options?: LocatorAssertionOptions): Promise<void>;
2515
+ /** Assert element has class */
2516
+ toHaveClass(expected: string | RegExp, options?: LocatorAssertionOptions): Promise<void>;
2517
+ /** Assert element contains class */
2518
+ toContainClass(expected: string, options?: LocatorAssertionOptions): Promise<void>;
2519
+ /** Assert element has id */
2520
+ toHaveId(expected: string, options?: LocatorAssertionOptions): Promise<void>;
2521
+ /** Assert element has CSS property */
2522
+ toHaveCSS(name: string, value: string | RegExp, options?: LocatorAssertionOptions): Promise<void>;
2523
+ /** Assert element has JavaScript property */
2524
+ toHaveJSProperty(name: string, value: unknown, options?: LocatorAssertionOptions): Promise<void>;
2525
+ /** Assert element has accessible name */
2526
+ toHaveAccessibleName(expected: string | RegExp, options?: LocatorAssertionOptions): Promise<void>;
2527
+ /** Assert element has accessible description */
2528
+ toHaveAccessibleDescription(expected: string | RegExp, options?: LocatorAssertionOptions): Promise<void>;
2529
+ /** Assert element has ARIA role */
2530
+ toHaveRole(expected: string, options?: LocatorAssertionOptions): Promise<void>;
2531
+ /** Negated matchers */
2532
+ not: PlaywrightLocatorMatchers;
2533
+ }
2534
+
2535
+ /**
2536
+ * Page-specific assertion matchers (added to expect when using Playwright).
2537
+ * These are available when calling expect(page).
2538
+ */
2539
+ interface PlaywrightPageMatchers {
2540
+ /** Assert page has URL */
2541
+ toHaveURL(expected: string | RegExp, options?: LocatorAssertionOptions): Promise<void>;
2542
+ /** Assert page has title */
2543
+ toHaveTitle(expected: string | RegExp, options?: LocatorAssertionOptions): Promise<void>;
2544
+ /** Negated matchers */
2545
+ not: PlaywrightPageMatchers;
2546
+ }
2547
+ `;
2548
+ var TYPE_DEFINITIONS = {
2549
+ core: CORE_TYPES,
2550
+ console: CONSOLE_TYPES,
2551
+ crypto: CRYPTO_TYPES,
2552
+ encoding: ENCODING_TYPES,
2553
+ fetch: FETCH_TYPES,
2554
+ fs: FS_TYPES,
2555
+ path: PATH_TYPES,
2556
+ testEnvironment: TEST_ENV_TYPES,
2557
+ timers: TIMERS_TYPES,
2558
+ playwright: PLAYWRIGHT_TYPES
2559
+ };
2560
+ export {
2561
+ TYPE_DEFINITIONS,
2562
+ TIMERS_TYPES,
2563
+ TEST_ENV_TYPES,
2564
+ PLAYWRIGHT_TYPES,
2565
+ PATH_TYPES,
2566
+ FS_TYPES,
2567
+ FETCH_TYPES,
2568
+ ENCODING_TYPES,
2569
+ CRYPTO_TYPES,
2570
+ CORE_TYPES,
2571
+ CONSOLE_TYPES
2572
+ };
2573
+
2574
+ //# debugId=DC7C8AF0CA76086864756E2164756E21