@metamask/snaps-execution-environments 6.6.2 → 6.7.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 (526) hide show
  1. package/CHANGELOG.md +18 -1
  2. package/dist/common/BaseSnapExecutor.cjs +436 -0
  3. package/dist/common/BaseSnapExecutor.cjs.map +1 -0
  4. package/dist/{types/common/BaseSnapExecutor.d.ts → common/BaseSnapExecutor.d.cts} +8 -6
  5. package/dist/common/BaseSnapExecutor.d.cts.map +1 -0
  6. package/dist/common/BaseSnapExecutor.d.mts +70 -0
  7. package/dist/common/BaseSnapExecutor.d.mts.map +1 -0
  8. package/dist/common/BaseSnapExecutor.mjs +430 -24
  9. package/dist/common/BaseSnapExecutor.mjs.map +1 -1
  10. package/dist/common/commands.cjs +95 -0
  11. package/dist/common/commands.cjs.map +1 -0
  12. package/dist/{types/common/commands.d.ts → common/commands.d.cts} +5 -4
  13. package/dist/common/commands.d.cts.map +1 -0
  14. package/dist/common/commands.d.mts +31 -0
  15. package/dist/common/commands.d.mts.map +1 -0
  16. package/dist/common/commands.mjs +89 -10
  17. package/dist/common/commands.mjs.map +1 -1
  18. package/dist/common/endowments/commonEndowmentFactory.cjs +76 -0
  19. package/dist/common/endowments/commonEndowmentFactory.cjs.map +1 -0
  20. package/dist/{types/common/endowments/commonEndowmentFactory.d.ts → common/endowments/commonEndowmentFactory.d.cts} +5 -4
  21. package/dist/common/endowments/commonEndowmentFactory.d.cts.map +1 -0
  22. package/dist/common/endowments/commonEndowmentFactory.d.mts +26 -0
  23. package/dist/common/endowments/commonEndowmentFactory.d.mts.map +1 -0
  24. package/dist/common/endowments/commonEndowmentFactory.mjs +69 -18
  25. package/dist/common/endowments/commonEndowmentFactory.mjs.map +1 -1
  26. package/dist/common/endowments/console.cjs +103 -0
  27. package/dist/common/endowments/console.cjs.map +1 -0
  28. package/dist/{types/common/endowments/console.d.ts → common/endowments/console.d.cts} +2 -1
  29. package/dist/common/endowments/console.d.cts.map +1 -0
  30. package/dist/common/endowments/console.d.mts +46 -0
  31. package/dist/common/endowments/console.d.mts.map +1 -0
  32. package/dist/common/endowments/console.mjs +98 -11
  33. package/dist/common/endowments/console.mjs.map +1 -1
  34. package/dist/common/endowments/crypto.cjs +30 -0
  35. package/dist/common/endowments/crypto.cjs.map +1 -0
  36. package/dist/{types/common/endowments/crypto.d.ts → common/endowments/crypto.d.cts} +1 -0
  37. package/dist/common/endowments/crypto.d.cts.map +1 -0
  38. package/dist/common/endowments/crypto.d.mts +13 -0
  39. package/dist/common/endowments/crypto.d.mts.map +1 -0
  40. package/dist/common/endowments/crypto.mjs +26 -9
  41. package/dist/common/endowments/crypto.mjs.map +1 -1
  42. package/dist/common/endowments/date.cjs +39 -0
  43. package/dist/common/endowments/date.cjs.map +1 -0
  44. package/dist/{types/common/endowments/date.d.ts → common/endowments/date.d.cts} +1 -0
  45. package/dist/common/endowments/date.d.cts.map +1 -0
  46. package/dist/common/endowments/date.d.mts +16 -0
  47. package/dist/common/endowments/date.d.mts.map +1 -0
  48. package/dist/common/endowments/date.mjs +35 -7
  49. package/dist/common/endowments/date.mjs.map +1 -1
  50. package/dist/common/endowments/index.cjs +93 -0
  51. package/dist/common/endowments/index.cjs.map +1 -0
  52. package/dist/{types/common/endowments/index.d.ts → common/endowments/index.d.cts} +4 -3
  53. package/dist/common/endowments/index.d.cts.map +1 -0
  54. package/dist/common/endowments/index.d.mts +29 -0
  55. package/dist/common/endowments/index.d.mts.map +1 -0
  56. package/dist/common/endowments/index.mjs +85 -20
  57. package/dist/common/endowments/index.mjs.map +1 -1
  58. package/dist/common/endowments/interval.cjs +51 -0
  59. package/dist/common/endowments/interval.cjs.map +1 -0
  60. package/dist/{types/common/endowments/interval.d.ts → common/endowments/interval.d.cts} +1 -0
  61. package/dist/common/endowments/interval.d.cts.map +1 -0
  62. package/dist/common/endowments/interval.d.mts +10 -0
  63. package/dist/common/endowments/interval.d.mts.map +1 -0
  64. package/dist/common/endowments/interval.mjs +47 -6
  65. package/dist/common/endowments/interval.mjs.map +1 -1
  66. package/dist/common/endowments/math.cjs +54 -0
  67. package/dist/common/endowments/math.cjs.map +1 -0
  68. package/dist/{types/common/endowments/math.d.ts → common/endowments/math.d.cts} +1 -0
  69. package/dist/common/endowments/math.d.cts.map +1 -0
  70. package/dist/common/endowments/math.d.mts +61 -0
  71. package/dist/common/endowments/math.d.mts.map +1 -0
  72. package/dist/common/endowments/math.mjs +50 -8
  73. package/dist/common/endowments/math.mjs.map +1 -1
  74. package/dist/common/endowments/network.cjs +255 -0
  75. package/dist/common/endowments/network.cjs.map +1 -0
  76. package/dist/{types/common/endowments/network.d.ts → common/endowments/network.d.cts} +4 -2
  77. package/dist/common/endowments/network.d.cts.map +1 -0
  78. package/dist/common/endowments/network.d.mts +25 -0
  79. package/dist/common/endowments/network.d.mts.map +1 -0
  80. package/dist/common/endowments/network.mjs +251 -8
  81. package/dist/common/endowments/network.mjs.map +1 -1
  82. package/dist/common/endowments/textDecoder.cjs +18 -0
  83. package/dist/common/endowments/textDecoder.cjs.map +1 -0
  84. package/dist/{types/common/endowments/textDecoder.d.ts → common/endowments/textDecoder.d.cts} +1 -0
  85. package/dist/common/endowments/textDecoder.d.cts.map +1 -0
  86. package/dist/common/endowments/textDecoder.d.mts +11 -0
  87. package/dist/common/endowments/textDecoder.d.mts.map +1 -0
  88. package/dist/common/endowments/textDecoder.mjs +14 -6
  89. package/dist/common/endowments/textDecoder.mjs.map +1 -1
  90. package/dist/common/endowments/textEncoder.cjs +18 -0
  91. package/dist/common/endowments/textEncoder.cjs.map +1 -0
  92. package/dist/{types/common/endowments/textEncoder.d.ts → common/endowments/textEncoder.d.cts} +1 -0
  93. package/dist/common/endowments/textEncoder.d.cts.map +1 -0
  94. package/dist/common/endowments/textEncoder.d.mts +11 -0
  95. package/dist/common/endowments/textEncoder.d.mts.map +1 -0
  96. package/dist/common/endowments/textEncoder.mjs +14 -6
  97. package/dist/common/endowments/textEncoder.mjs.map +1 -1
  98. package/dist/common/endowments/timeout.cjs +53 -0
  99. package/dist/common/endowments/timeout.cjs.map +1 -0
  100. package/dist/{types/common/endowments/timeout.d.ts → common/endowments/timeout.d.cts} +1 -0
  101. package/dist/common/endowments/timeout.d.cts.map +1 -0
  102. package/dist/common/endowments/timeout.d.mts +10 -0
  103. package/dist/common/endowments/timeout.d.mts.map +1 -0
  104. package/dist/common/endowments/timeout.mjs +49 -6
  105. package/dist/common/endowments/timeout.mjs.map +1 -1
  106. package/dist/common/globalEvents.cjs +48 -0
  107. package/dist/common/globalEvents.cjs.map +1 -0
  108. package/dist/{types/common/globalEvents.d.ts → common/globalEvents.d.cts} +1 -0
  109. package/dist/common/globalEvents.d.cts.map +1 -0
  110. package/dist/common/globalEvents.d.mts +21 -0
  111. package/dist/common/globalEvents.d.mts.map +1 -0
  112. package/dist/common/globalEvents.mjs +42 -10
  113. package/dist/common/globalEvents.mjs.map +1 -1
  114. package/dist/common/globalObject.cjs +50 -0
  115. package/dist/common/globalObject.cjs.map +1 -0
  116. package/dist/{types/common/globalObject.d.ts → common/globalObject.d.cts} +1 -0
  117. package/dist/common/globalObject.d.cts.map +1 -0
  118. package/dist/common/globalObject.d.mts +10 -0
  119. package/dist/common/globalObject.d.mts.map +1 -0
  120. package/dist/common/globalObject.mjs +45 -9
  121. package/dist/common/globalObject.mjs.map +1 -1
  122. package/dist/common/lockdown/lockdown-events.cjs +60 -0
  123. package/dist/common/lockdown/lockdown-events.cjs.map +1 -0
  124. package/dist/{types/common/lockdown/lockdown-events.d.ts → common/lockdown/lockdown-events.d.cts} +1 -0
  125. package/dist/common/lockdown/lockdown-events.d.cts.map +1 -0
  126. package/dist/common/lockdown/lockdown-events.d.mts +5 -0
  127. package/dist/common/lockdown/lockdown-events.d.mts.map +1 -0
  128. package/dist/common/lockdown/lockdown-events.mjs +55 -7
  129. package/dist/common/lockdown/lockdown-events.mjs.map +1 -1
  130. package/dist/common/lockdown/lockdown-more.cjs +89 -0
  131. package/dist/common/lockdown/lockdown-more.cjs.map +1 -0
  132. package/dist/{types/common/lockdown/lockdown-more.d.ts → common/lockdown/lockdown-more.d.cts} +1 -0
  133. package/dist/common/lockdown/lockdown-more.d.cts.map +1 -0
  134. package/dist/common/lockdown/lockdown-more.d.mts +23 -0
  135. package/dist/common/lockdown/lockdown-more.d.mts.map +1 -0
  136. package/dist/common/lockdown/lockdown-more.mjs +84 -7
  137. package/dist/common/lockdown/lockdown-more.mjs.map +1 -1
  138. package/dist/common/lockdown/lockdown.cjs +29 -0
  139. package/dist/common/lockdown/lockdown.cjs.map +1 -0
  140. package/dist/{types/common/lockdown/lockdown.d.ts → common/lockdown/lockdown.d.cts} +1 -0
  141. package/dist/common/lockdown/lockdown.d.cts.map +1 -0
  142. package/dist/common/lockdown/lockdown.d.mts +8 -0
  143. package/dist/common/lockdown/lockdown.d.mts.map +1 -0
  144. package/dist/common/lockdown/lockdown.mjs +22 -19
  145. package/dist/common/lockdown/lockdown.mjs.map +1 -1
  146. package/dist/common/sortParams.cjs +35 -0
  147. package/dist/common/sortParams.cjs.map +1 -0
  148. package/dist/{types/common/sortParams.d.ts → common/sortParams.d.cts} +2 -1
  149. package/dist/common/sortParams.d.cts.map +1 -0
  150. package/dist/common/sortParams.d.mts +17 -0
  151. package/dist/common/sortParams.d.mts.map +1 -0
  152. package/dist/common/sortParams.mjs +29 -6
  153. package/dist/common/sortParams.mjs.map +1 -1
  154. package/dist/common/utils.cjs +156 -0
  155. package/dist/common/utils.cjs.map +1 -0
  156. package/dist/{types/common/utils.d.ts → common/utils.d.cts} +2 -1
  157. package/dist/common/utils.d.cts.map +1 -0
  158. package/dist/common/utils.d.mts +50 -0
  159. package/dist/common/utils.d.mts.map +1 -0
  160. package/dist/common/utils.mjs +146 -20
  161. package/dist/common/utils.mjs.map +1 -1
  162. package/dist/common/validation.cjs +137 -0
  163. package/dist/common/validation.cjs.map +1 -0
  164. package/dist/{types/common/validation.d.ts → common/validation.d.cts} +37 -36
  165. package/dist/common/validation.d.cts.map +1 -0
  166. package/dist/common/validation.d.mts +199 -0
  167. package/dist/common/validation.d.mts.map +1 -0
  168. package/dist/common/validation.mjs +127 -37
  169. package/dist/common/validation.mjs.map +1 -1
  170. package/dist/iframe/IFrameSnapExecutor.cjs +42 -0
  171. package/dist/iframe/IFrameSnapExecutor.cjs.map +1 -0
  172. package/dist/{types/iframe/IFrameSnapExecutor.d.ts → iframe/IFrameSnapExecutor.d.cts} +3 -2
  173. package/dist/iframe/IFrameSnapExecutor.d.cts.map +1 -0
  174. package/dist/iframe/IFrameSnapExecutor.d.mts +14 -0
  175. package/dist/iframe/IFrameSnapExecutor.d.mts.map +1 -0
  176. package/dist/iframe/IFrameSnapExecutor.mjs +42 -26
  177. package/dist/iframe/IFrameSnapExecutor.mjs.map +1 -1
  178. package/dist/iframe/index.cjs +10 -0
  179. package/dist/iframe/index.cjs.map +1 -0
  180. package/dist/iframe/index.d.cts +2 -0
  181. package/dist/iframe/index.d.cts.map +1 -0
  182. package/dist/iframe/index.d.mts +2 -0
  183. package/dist/iframe/index.d.mts.map +1 -0
  184. package/dist/iframe/index.mjs +4 -31
  185. package/dist/iframe/index.mjs.map +1 -1
  186. package/dist/index.cjs +18 -0
  187. package/dist/index.cjs.map +1 -0
  188. package/dist/index.d.cts +2 -0
  189. package/dist/index.d.cts.map +1 -0
  190. package/dist/index.d.mts +2 -0
  191. package/dist/index.d.mts.map +1 -0
  192. package/dist/index.mjs +1 -8
  193. package/dist/index.mjs.map +1 -1
  194. package/dist/logging.cjs +13 -0
  195. package/dist/logging.cjs.map +1 -0
  196. package/dist/{types/logging.d.ts → logging.d.cts} +1 -0
  197. package/dist/logging.d.cts.map +1 -0
  198. package/dist/logging.d.mts +9 -0
  199. package/dist/logging.d.mts.map +1 -0
  200. package/dist/logging.mjs +9 -7
  201. package/dist/logging.mjs.map +1 -1
  202. package/dist/node-process/ChildProcessSnapExecutor.cjs +30 -0
  203. package/dist/node-process/ChildProcessSnapExecutor.cjs.map +1 -0
  204. package/dist/{types/node-process/ChildProcessSnapExecutor.d.ts → node-process/ChildProcessSnapExecutor.d.cts} +2 -1
  205. package/dist/node-process/ChildProcessSnapExecutor.d.cts.map +1 -0
  206. package/dist/node-process/ChildProcessSnapExecutor.d.mts +5 -0
  207. package/dist/node-process/ChildProcessSnapExecutor.d.mts.map +1 -0
  208. package/dist/node-process/ChildProcessSnapExecutor.mjs +30 -26
  209. package/dist/node-process/ChildProcessSnapExecutor.mjs.map +1 -1
  210. package/dist/node-process/index.cjs +8 -0
  211. package/dist/node-process/index.cjs.map +1 -0
  212. package/dist/node-process/index.d.cts +2 -0
  213. package/dist/node-process/index.d.cts.map +1 -0
  214. package/dist/node-process/index.d.mts +2 -0
  215. package/dist/node-process/index.d.mts.map +1 -0
  216. package/dist/node-process/index.mjs +3 -28
  217. package/dist/node-process/index.mjs.map +1 -1
  218. package/dist/node-thread/ThreadSnapExecutor.cjs +30 -0
  219. package/dist/node-thread/ThreadSnapExecutor.cjs.map +1 -0
  220. package/dist/node-thread/ThreadSnapExecutor.d.cts +5 -0
  221. package/dist/node-thread/ThreadSnapExecutor.d.cts.map +1 -0
  222. package/dist/node-thread/ThreadSnapExecutor.d.mts +5 -0
  223. package/dist/node-thread/ThreadSnapExecutor.d.mts.map +1 -0
  224. package/dist/node-thread/ThreadSnapExecutor.mjs +30 -26
  225. package/dist/node-thread/ThreadSnapExecutor.mjs.map +1 -1
  226. package/dist/node-thread/index.cjs +8 -0
  227. package/dist/node-thread/index.cjs.map +1 -0
  228. package/dist/node-thread/index.d.cts +2 -0
  229. package/dist/node-thread/index.d.cts.map +1 -0
  230. package/dist/node-thread/index.d.mts +2 -0
  231. package/dist/node-thread/index.d.mts.map +1 -0
  232. package/dist/node-thread/index.mjs +3 -28
  233. package/dist/node-thread/index.mjs.map +1 -1
  234. package/dist/proxy/ProxySnapExecutor.cjs +112 -0
  235. package/dist/proxy/ProxySnapExecutor.cjs.map +1 -0
  236. package/dist/{types/proxy/ProxySnapExecutor.d.ts → proxy/ProxySnapExecutor.d.cts} +4 -3
  237. package/dist/proxy/ProxySnapExecutor.d.cts.map +1 -0
  238. package/dist/proxy/ProxySnapExecutor.d.mts +36 -0
  239. package/dist/proxy/ProxySnapExecutor.d.mts.map +1 -0
  240. package/dist/proxy/ProxySnapExecutor.mjs +104 -6
  241. package/dist/proxy/ProxySnapExecutor.mjs.map +1 -1
  242. package/dist/proxy/index.cjs +18 -0
  243. package/dist/proxy/index.cjs.map +1 -0
  244. package/dist/proxy/index.d.cts +2 -0
  245. package/dist/proxy/index.d.cts.map +1 -0
  246. package/dist/proxy/index.d.mts +2 -0
  247. package/dist/proxy/index.d.mts.map +1 -0
  248. package/dist/proxy/index.mjs +1 -8
  249. package/dist/proxy/index.mjs.map +1 -1
  250. package/dist/webview/WebViewExecutorStream.cjs +79 -0
  251. package/dist/webview/WebViewExecutorStream.cjs.map +1 -0
  252. package/dist/{types/webview/WebViewExecutorStream.d.ts → webview/WebViewExecutorStream.d.cts} +3 -2
  253. package/dist/webview/WebViewExecutorStream.d.cts.map +1 -0
  254. package/dist/webview/WebViewExecutorStream.d.mts +33 -0
  255. package/dist/webview/WebViewExecutorStream.d.mts.map +1 -0
  256. package/dist/webview/WebViewExecutorStream.mjs +74 -6
  257. package/dist/webview/WebViewExecutorStream.mjs.map +1 -1
  258. package/dist/webview/index.cjs +16 -0
  259. package/dist/webview/index.cjs.map +1 -0
  260. package/dist/webview/index.d.cts +2 -0
  261. package/dist/webview/index.d.cts.map +1 -0
  262. package/dist/webview/index.d.mts +2 -0
  263. package/dist/webview/index.d.mts.map +1 -0
  264. package/dist/webview/index.mjs +9 -21
  265. package/dist/webview/index.mjs.map +1 -1
  266. package/dist/webworker/executor/WebWorkerSnapExecutor.cjs +37 -0
  267. package/dist/webworker/executor/WebWorkerSnapExecutor.cjs.map +1 -0
  268. package/dist/{types/webworker/executor/WebWorkerSnapExecutor.d.ts → webworker/executor/WebWorkerSnapExecutor.d.cts} +3 -2
  269. package/dist/webworker/executor/WebWorkerSnapExecutor.d.cts.map +1 -0
  270. package/dist/webworker/executor/WebWorkerSnapExecutor.d.mts +14 -0
  271. package/dist/webworker/executor/WebWorkerSnapExecutor.d.mts.map +1 -0
  272. package/dist/webworker/executor/WebWorkerSnapExecutor.mjs +37 -26
  273. package/dist/webworker/executor/WebWorkerSnapExecutor.mjs.map +1 -1
  274. package/dist/webworker/executor/index.cjs +10 -0
  275. package/dist/webworker/executor/index.cjs.map +1 -0
  276. package/dist/webworker/executor/index.d.cts +2 -0
  277. package/dist/webworker/executor/index.d.cts.map +1 -0
  278. package/dist/webworker/executor/index.d.mts +2 -0
  279. package/dist/webworker/executor/index.d.mts.map +1 -0
  280. package/dist/webworker/executor/index.mjs +4 -31
  281. package/dist/webworker/executor/index.mjs.map +1 -1
  282. package/dist/webworker/pool/WebWorkerPool.cjs +168 -0
  283. package/dist/webworker/pool/WebWorkerPool.cjs.map +1 -0
  284. package/dist/{types/webworker/pool/WebWorkerPool.d.ts → webworker/pool/WebWorkerPool.d.cts} +4 -3
  285. package/dist/webworker/pool/WebWorkerPool.d.cts.map +1 -0
  286. package/dist/webworker/pool/WebWorkerPool.d.mts +24 -0
  287. package/dist/webworker/pool/WebWorkerPool.d.mts.map +1 -0
  288. package/dist/webworker/pool/WebWorkerPool.mjs +163 -6
  289. package/dist/webworker/pool/WebWorkerPool.mjs.map +1 -1
  290. package/dist/webworker/pool/index.cjs +10 -0
  291. package/dist/webworker/pool/index.cjs.map +1 -0
  292. package/dist/webworker/pool/index.d.cts +2 -0
  293. package/dist/webworker/pool/index.d.cts.map +1 -0
  294. package/dist/webworker/pool/index.d.mts +2 -0
  295. package/dist/webworker/pool/index.d.mts.map +1 -0
  296. package/dist/webworker/pool/index.mjs +4 -12
  297. package/dist/webworker/pool/index.mjs.map +1 -1
  298. package/package.json +21 -18
  299. package/dist/browserify/iframe/bundle.js +0 -9
  300. package/dist/browserify/iframe/index.html +0 -13394
  301. package/dist/browserify/node-process/bundle.js +0 -13390
  302. package/dist/browserify/node-thread/bundle.js +0 -13390
  303. package/dist/browserify/webview/index.html +0 -13402
  304. package/dist/browserify/worker-executor/bundle.js +0 -13392
  305. package/dist/browserify/worker-pool/bundle.js +0 -9
  306. package/dist/browserify/worker-pool/index.html +0 -13394
  307. package/dist/chunk-2VA6RAEE.js +0 -30
  308. package/dist/chunk-2VA6RAEE.js.map +0 -1
  309. package/dist/chunk-3JCT4MWT.js +0 -108
  310. package/dist/chunk-3JCT4MWT.js.map +0 -1
  311. package/dist/chunk-46LW37FK.js +0 -144
  312. package/dist/chunk-46LW37FK.js.map +0 -1
  313. package/dist/chunk-4COIRXF5.js +0 -86
  314. package/dist/chunk-4COIRXF5.js.map +0 -1
  315. package/dist/chunk-4XRZLEKU.js +0 -49
  316. package/dist/chunk-4XRZLEKU.js.map +0 -1
  317. package/dist/chunk-53ZULHPK.mjs +0 -16
  318. package/dist/chunk-53ZULHPK.mjs.map +0 -1
  319. package/dist/chunk-5DEV3QQU.mjs +0 -12
  320. package/dist/chunk-5DEV3QQU.mjs.map +0 -1
  321. package/dist/chunk-5LGIS4VY.js +0 -33
  322. package/dist/chunk-5LGIS4VY.js.map +0 -1
  323. package/dist/chunk-5STN3QCA.js +0 -183
  324. package/dist/chunk-5STN3QCA.js.map +0 -1
  325. package/dist/chunk-75RCH4ZX.mjs +0 -151
  326. package/dist/chunk-75RCH4ZX.mjs.map +0 -1
  327. package/dist/chunk-7AJWXSDQ.mjs +0 -73
  328. package/dist/chunk-7AJWXSDQ.mjs.map +0 -1
  329. package/dist/chunk-7MMUJJQ2.js +0 -151
  330. package/dist/chunk-7MMUJJQ2.js.map +0 -1
  331. package/dist/chunk-BCBKEUCG.mjs +0 -38
  332. package/dist/chunk-BCBKEUCG.mjs.map +0 -1
  333. package/dist/chunk-BTEAZZKP.mjs +0 -24
  334. package/dist/chunk-BTEAZZKP.mjs.map +0 -1
  335. package/dist/chunk-BVRVUIJB.mjs +0 -67
  336. package/dist/chunk-BVRVUIJB.mjs.map +0 -1
  337. package/dist/chunk-CV5LC4PP.js +0 -24
  338. package/dist/chunk-CV5LC4PP.js.map +0 -1
  339. package/dist/chunk-DAG7NWEU.mjs +0 -33
  340. package/dist/chunk-DAG7NWEU.mjs.map +0 -1
  341. package/dist/chunk-DKDTGAFK.js +0 -67
  342. package/dist/chunk-DKDTGAFK.js.map +0 -1
  343. package/dist/chunk-DLLLH5HN.js +0 -26
  344. package/dist/chunk-DLLLH5HN.js.map +0 -1
  345. package/dist/chunk-EXN2TFDJ.js +0 -38
  346. package/dist/chunk-EXN2TFDJ.js.map +0 -1
  347. package/dist/chunk-FJT65CXB.js +0 -472
  348. package/dist/chunk-FJT65CXB.js.map +0 -1
  349. package/dist/chunk-FOEAIF5U.js +0 -16
  350. package/dist/chunk-FOEAIF5U.js.map +0 -1
  351. package/dist/chunk-FUPEJT7B.js +0 -82
  352. package/dist/chunk-FUPEJT7B.js.map +0 -1
  353. package/dist/chunk-HCJZG6W7.mjs +0 -45
  354. package/dist/chunk-HCJZG6W7.mjs.map +0 -1
  355. package/dist/chunk-HGLRZZ56.js +0 -32
  356. package/dist/chunk-HGLRZZ56.js.map +0 -1
  357. package/dist/chunk-HL2TTKF3.mjs +0 -144
  358. package/dist/chunk-HL2TTKF3.mjs.map +0 -1
  359. package/dist/chunk-HWS4QSOC.mjs +0 -16
  360. package/dist/chunk-HWS4QSOC.mjs.map +0 -1
  361. package/dist/chunk-HXKBUIYS.js +0 -262
  362. package/dist/chunk-HXKBUIYS.js.map +0 -1
  363. package/dist/chunk-I5G4YFHM.js +0 -73
  364. package/dist/chunk-I5G4YFHM.js.map +0 -1
  365. package/dist/chunk-IX5S3V47.mjs +0 -26
  366. package/dist/chunk-IX5S3V47.mjs.map +0 -1
  367. package/dist/chunk-JOT5JH42.js +0 -52
  368. package/dist/chunk-JOT5JH42.js.map +0 -1
  369. package/dist/chunk-KEAB7ZVV.js +0 -50
  370. package/dist/chunk-KEAB7ZVV.js.map +0 -1
  371. package/dist/chunk-LAKWJYBO.js +0 -33
  372. package/dist/chunk-LAKWJYBO.js.map +0 -1
  373. package/dist/chunk-LO5ORVRC.js +0 -16
  374. package/dist/chunk-LO5ORVRC.js.map +0 -1
  375. package/dist/chunk-MCXWFCGV.js +0 -1
  376. package/dist/chunk-MCXWFCGV.js.map +0 -1
  377. package/dist/chunk-MIWGLICQ.mjs +0 -108
  378. package/dist/chunk-MIWGLICQ.mjs.map +0 -1
  379. package/dist/chunk-MMYM63NH.mjs +0 -82
  380. package/dist/chunk-MMYM63NH.mjs.map +0 -1
  381. package/dist/chunk-MS2LQQYH.js +0 -38
  382. package/dist/chunk-MS2LQQYH.js.map +0 -1
  383. package/dist/chunk-MXNMMTJW.mjs +0 -51
  384. package/dist/chunk-MXNMMTJW.mjs.map +0 -1
  385. package/dist/chunk-OBT45IWW.js +0 -92
  386. package/dist/chunk-OBT45IWW.js.map +0 -1
  387. package/dist/chunk-OCNPLHS2.js +0 -51
  388. package/dist/chunk-OCNPLHS2.js.map +0 -1
  389. package/dist/chunk-ODICKSGZ.mjs +0 -86
  390. package/dist/chunk-ODICKSGZ.mjs.map +0 -1
  391. package/dist/chunk-OIN7VU4G.mjs +0 -33
  392. package/dist/chunk-OIN7VU4G.mjs.map +0 -1
  393. package/dist/chunk-Q42NNJFY.mjs +0 -32
  394. package/dist/chunk-Q42NNJFY.mjs.map +0 -1
  395. package/dist/chunk-Q42WB3ZO.js +0 -40
  396. package/dist/chunk-Q42WB3ZO.js.map +0 -1
  397. package/dist/chunk-QZC2X6NG.js +0 -44
  398. package/dist/chunk-QZC2X6NG.js.map +0 -1
  399. package/dist/chunk-S5NWI5Z7.mjs +0 -50
  400. package/dist/chunk-S5NWI5Z7.mjs.map +0 -1
  401. package/dist/chunk-S7257EN3.mjs +0 -49
  402. package/dist/chunk-S7257EN3.mjs.map +0 -1
  403. package/dist/chunk-TSEAPB7L.mjs +0 -1
  404. package/dist/chunk-TSEAPB7L.mjs.map +0 -1
  405. package/dist/chunk-TZAPZE45.mjs +0 -472
  406. package/dist/chunk-TZAPZE45.mjs.map +0 -1
  407. package/dist/chunk-UOPIRTJX.mjs +0 -44
  408. package/dist/chunk-UOPIRTJX.mjs.map +0 -1
  409. package/dist/chunk-V76DI2XM.mjs +0 -183
  410. package/dist/chunk-V76DI2XM.mjs.map +0 -1
  411. package/dist/chunk-VFQ5CRZS.mjs +0 -40
  412. package/dist/chunk-VFQ5CRZS.mjs.map +0 -1
  413. package/dist/chunk-W7EDURT5.mjs +0 -92
  414. package/dist/chunk-W7EDURT5.mjs.map +0 -1
  415. package/dist/chunk-WZDVTU5C.js +0 -45
  416. package/dist/chunk-WZDVTU5C.js.map +0 -1
  417. package/dist/chunk-XPCW7TKM.mjs +0 -262
  418. package/dist/chunk-XPCW7TKM.mjs.map +0 -1
  419. package/dist/chunk-Y7AK2VVC.mjs +0 -52
  420. package/dist/chunk-Y7AK2VVC.mjs.map +0 -1
  421. package/dist/chunk-YRZVIDCF.mjs +0 -38
  422. package/dist/chunk-YRZVIDCF.mjs.map +0 -1
  423. package/dist/chunk-Z7BOREC4.js +0 -12
  424. package/dist/chunk-Z7BOREC4.js.map +0 -1
  425. package/dist/chunk-ZNTCZK7J.mjs +0 -30
  426. package/dist/chunk-ZNTCZK7J.mjs.map +0 -1
  427. package/dist/common/BaseSnapExecutor.js +0 -26
  428. package/dist/common/BaseSnapExecutor.js.map +0 -1
  429. package/dist/common/commands.js +0 -11
  430. package/dist/common/commands.js.map +0 -1
  431. package/dist/common/endowments/commonEndowmentFactory.js +0 -20
  432. package/dist/common/endowments/commonEndowmentFactory.js.map +0 -1
  433. package/dist/common/endowments/console.js +0 -13
  434. package/dist/common/endowments/console.js.map +0 -1
  435. package/dist/common/endowments/crypto.js +0 -11
  436. package/dist/common/endowments/crypto.js.map +0 -1
  437. package/dist/common/endowments/date.js +0 -9
  438. package/dist/common/endowments/date.js.map +0 -1
  439. package/dist/common/endowments/index.js +0 -21
  440. package/dist/common/endowments/index.js.map +0 -1
  441. package/dist/common/endowments/interval.js +0 -8
  442. package/dist/common/endowments/interval.js.map +0 -1
  443. package/dist/common/endowments/math.js +0 -10
  444. package/dist/common/endowments/math.js.map +0 -1
  445. package/dist/common/endowments/network.js +0 -10
  446. package/dist/common/endowments/network.js.map +0 -1
  447. package/dist/common/endowments/textDecoder.js +0 -8
  448. package/dist/common/endowments/textDecoder.js.map +0 -1
  449. package/dist/common/endowments/textEncoder.js +0 -8
  450. package/dist/common/endowments/textEncoder.js.map +0 -1
  451. package/dist/common/endowments/timeout.js +0 -8
  452. package/dist/common/endowments/timeout.js.map +0 -1
  453. package/dist/common/globalEvents.js +0 -11
  454. package/dist/common/globalEvents.js.map +0 -1
  455. package/dist/common/globalObject.js +0 -10
  456. package/dist/common/globalObject.js.map +0 -1
  457. package/dist/common/lockdown/lockdown-events.js +0 -8
  458. package/dist/common/lockdown/lockdown-events.js.map +0 -1
  459. package/dist/common/lockdown/lockdown-more.js +0 -8
  460. package/dist/common/lockdown/lockdown-more.js.map +0 -1
  461. package/dist/common/lockdown/lockdown.js +0 -22
  462. package/dist/common/lockdown/lockdown.js.map +0 -1
  463. package/dist/common/sortParams.js +0 -8
  464. package/dist/common/sortParams.js.map +0 -1
  465. package/dist/common/utils.js +0 -21
  466. package/dist/common/utils.js.map +0 -1
  467. package/dist/common/validation.js +0 -38
  468. package/dist/common/validation.js.map +0 -1
  469. package/dist/globals.d.js +0 -1
  470. package/dist/globals.d.js.map +0 -1
  471. package/dist/globals.d.mjs +0 -1
  472. package/dist/globals.d.mjs.map +0 -1
  473. package/dist/iframe/IFrameSnapExecutor.js +0 -27
  474. package/dist/iframe/IFrameSnapExecutor.js.map +0 -1
  475. package/dist/iframe/index.js +0 -35
  476. package/dist/iframe/index.js.map +0 -1
  477. package/dist/index.js +0 -9
  478. package/dist/index.js.map +0 -1
  479. package/dist/logging.js +0 -8
  480. package/dist/logging.js.map +0 -1
  481. package/dist/node-process/ChildProcessSnapExecutor.js +0 -27
  482. package/dist/node-process/ChildProcessSnapExecutor.js.map +0 -1
  483. package/dist/node-process/index.js +0 -31
  484. package/dist/node-process/index.js.map +0 -1
  485. package/dist/node-thread/ThreadSnapExecutor.js +0 -27
  486. package/dist/node-thread/ThreadSnapExecutor.js.map +0 -1
  487. package/dist/node-thread/index.js +0 -31
  488. package/dist/node-thread/index.js.map +0 -1
  489. package/dist/proxy/ProxySnapExecutor.js +0 -8
  490. package/dist/proxy/ProxySnapExecutor.js.map +0 -1
  491. package/dist/proxy/index.js +0 -9
  492. package/dist/proxy/index.js.map +0 -1
  493. package/dist/tsconfig.build.tsbuildinfo +0 -1
  494. package/dist/types/iframe/index.d.ts +0 -1
  495. package/dist/types/index.d.ts +0 -1
  496. package/dist/types/node-process/index.d.ts +0 -1
  497. package/dist/types/node-thread/ThreadSnapExecutor.d.ts +0 -4
  498. package/dist/types/node-thread/index.d.ts +0 -1
  499. package/dist/types/proxy/index.d.ts +0 -1
  500. package/dist/types/vendor/global.d.js +0 -1
  501. package/dist/types/vendor/global.d.js.map +0 -1
  502. package/dist/types/vendor/global.d.mjs +0 -1
  503. package/dist/types/vendor/global.d.mjs.map +0 -1
  504. package/dist/types/vendor/providers.d.js +0 -1
  505. package/dist/types/vendor/providers.d.js.map +0 -1
  506. package/dist/types/vendor/providers.d.mjs +0 -1
  507. package/dist/types/vendor/providers.d.mjs.map +0 -1
  508. package/dist/types/vendor/readable-stream.d.js +0 -1
  509. package/dist/types/vendor/readable-stream.d.js.map +0 -1
  510. package/dist/types/vendor/readable-stream.d.mjs +0 -1
  511. package/dist/types/vendor/readable-stream.d.mjs.map +0 -1
  512. package/dist/types/webview/index.d.ts +0 -1
  513. package/dist/types/webworker/executor/index.d.ts +0 -1
  514. package/dist/types/webworker/pool/index.d.ts +0 -1
  515. package/dist/webview/WebViewExecutorStream.js +0 -8
  516. package/dist/webview/WebViewExecutorStream.js.map +0 -1
  517. package/dist/webview/index.js +0 -26
  518. package/dist/webview/index.js.map +0 -1
  519. package/dist/webworker/executor/WebWorkerSnapExecutor.js +0 -27
  520. package/dist/webworker/executor/WebWorkerSnapExecutor.js.map +0 -1
  521. package/dist/webworker/executor/index.js +0 -35
  522. package/dist/webworker/executor/index.js.map +0 -1
  523. package/dist/webworker/pool/WebWorkerPool.js +0 -8
  524. package/dist/webworker/pool/WebWorkerPool.js.map +0 -1
  525. package/dist/webworker/pool/index.js +0 -16
  526. package/dist/webworker/pool/index.js.map +0 -1
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Creates TextDecoder function hardened by SES.
5
+ *
6
+ * @returns An object with the attenuated `TextDecoder` function.
7
+ */
8
+ const createTextDecoder = () => {
9
+ return {
10
+ TextDecoder: harden(TextDecoder),
11
+ };
12
+ };
13
+ const endowmentModule = {
14
+ names: ['TextDecoder'],
15
+ factory: createTextDecoder,
16
+ };
17
+ exports.default = endowmentModule;
18
+ //# sourceMappingURL=textDecoder.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textDecoder.cjs","sourceRoot":"","sources":["../../../src/common/endowments/textDecoder.ts"],"names":[],"mappings":";;AAAA;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,GAAG,EAAE;IAC7B,OAAO;QACL,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC;KACxB,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG;IACtB,KAAK,EAAE,CAAC,aAAa,CAAU;IAC/B,OAAO,EAAE,iBAAiB;CAC3B,CAAC;AACF,kBAAe,eAAe,CAAC","sourcesContent":["/**\n * Creates TextDecoder function hardened by SES.\n *\n * @returns An object with the attenuated `TextDecoder` function.\n */\nconst createTextDecoder = () => {\n return {\n TextDecoder: harden(TextDecoder),\n } as const;\n};\n\nconst endowmentModule = {\n names: ['TextDecoder'] as const,\n factory: createTextDecoder,\n};\nexport default endowmentModule;\n"]}
@@ -8,3 +8,4 @@ declare const endowmentModule: {
8
8
  };
9
9
  };
10
10
  export default endowmentModule;
11
+ //# sourceMappingURL=textDecoder.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textDecoder.d.cts","sourceRoot":"","sources":["../../../src/common/endowments/textDecoder.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,eAAe;;;;;;;;CAGpB,CAAC;AACF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,11 @@
1
+ declare const endowmentModule: {
2
+ names: readonly ["TextDecoder"];
3
+ factory: () => {
4
+ readonly TextDecoder: {
5
+ new (label?: string | undefined, options?: TextDecoderOptions | undefined): TextDecoder;
6
+ prototype: TextDecoder;
7
+ };
8
+ };
9
+ };
10
+ export default endowmentModule;
11
+ //# sourceMappingURL=textDecoder.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textDecoder.d.mts","sourceRoot":"","sources":["../../../src/common/endowments/textDecoder.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,eAAe;;;;;;;;CAGpB,CAAC;AACF,eAAe,eAAe,CAAC"}
@@ -1,8 +1,16 @@
1
- import {
2
- textDecoder_default
3
- } from "../../chunk-53ZULHPK.mjs";
4
- import "../../chunk-YRZVIDCF.mjs";
5
- export {
6
- textDecoder_default as default
1
+ /**
2
+ * Creates TextDecoder function hardened by SES.
3
+ *
4
+ * @returns An object with the attenuated `TextDecoder` function.
5
+ */
6
+ const createTextDecoder = () => {
7
+ return {
8
+ TextDecoder: harden(TextDecoder),
9
+ };
7
10
  };
11
+ const endowmentModule = {
12
+ names: ['TextDecoder'],
13
+ factory: createTextDecoder,
14
+ };
15
+ export default endowmentModule;
8
16
  //# sourceMappingURL=textDecoder.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"textDecoder.mjs","sourceRoot":"","sources":["../../../src/common/endowments/textDecoder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,GAAG,EAAE;IAC7B,OAAO;QACL,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC;KACxB,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG;IACtB,KAAK,EAAE,CAAC,aAAa,CAAU;IAC/B,OAAO,EAAE,iBAAiB;CAC3B,CAAC;AACF,eAAe,eAAe,CAAC","sourcesContent":["/**\n * Creates TextDecoder function hardened by SES.\n *\n * @returns An object with the attenuated `TextDecoder` function.\n */\nconst createTextDecoder = () => {\n return {\n TextDecoder: harden(TextDecoder),\n } as const;\n};\n\nconst endowmentModule = {\n names: ['TextDecoder'] as const,\n factory: createTextDecoder,\n};\nexport default endowmentModule;\n"]}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
4
+ * Creates TextEncoder function hardened by SES.
5
+ *
6
+ * @returns An object with the attenuated `TextEncoder` function.
7
+ */
8
+ const createTextEncoder = () => {
9
+ return {
10
+ TextEncoder: harden(TextEncoder),
11
+ };
12
+ };
13
+ const endowmentModule = {
14
+ names: ['TextEncoder'],
15
+ factory: createTextEncoder,
16
+ };
17
+ exports.default = endowmentModule;
18
+ //# sourceMappingURL=textEncoder.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textEncoder.cjs","sourceRoot":"","sources":["../../../src/common/endowments/textEncoder.ts"],"names":[],"mappings":";;AAAA;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,GAAG,EAAE;IAC7B,OAAO;QACL,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC;KACxB,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG;IACtB,KAAK,EAAE,CAAC,aAAa,CAAU;IAC/B,OAAO,EAAE,iBAAiB;CAC3B,CAAC;AACF,kBAAe,eAAe,CAAC","sourcesContent":["/**\n * Creates TextEncoder function hardened by SES.\n *\n * @returns An object with the attenuated `TextEncoder` function.\n */\nconst createTextEncoder = () => {\n return {\n TextEncoder: harden(TextEncoder),\n } as const;\n};\n\nconst endowmentModule = {\n names: ['TextEncoder'] as const,\n factory: createTextEncoder,\n};\nexport default endowmentModule;\n"]}
@@ -8,3 +8,4 @@ declare const endowmentModule: {
8
8
  };
9
9
  };
10
10
  export default endowmentModule;
11
+ //# sourceMappingURL=textEncoder.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textEncoder.d.cts","sourceRoot":"","sources":["../../../src/common/endowments/textEncoder.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,eAAe;;;;;;;;CAGpB,CAAC;AACF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,11 @@
1
+ declare const endowmentModule: {
2
+ names: readonly ["TextEncoder"];
3
+ factory: () => {
4
+ readonly TextEncoder: {
5
+ new (): TextEncoder;
6
+ prototype: TextEncoder;
7
+ };
8
+ };
9
+ };
10
+ export default endowmentModule;
11
+ //# sourceMappingURL=textEncoder.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"textEncoder.d.mts","sourceRoot":"","sources":["../../../src/common/endowments/textEncoder.ts"],"names":[],"mappings":"AAWA,QAAA,MAAM,eAAe;;;;;;;;CAGpB,CAAC;AACF,eAAe,eAAe,CAAC"}
@@ -1,8 +1,16 @@
1
- import {
2
- textEncoder_default
3
- } from "../../chunk-HWS4QSOC.mjs";
4
- import "../../chunk-YRZVIDCF.mjs";
5
- export {
6
- textEncoder_default as default
1
+ /**
2
+ * Creates TextEncoder function hardened by SES.
3
+ *
4
+ * @returns An object with the attenuated `TextEncoder` function.
5
+ */
6
+ const createTextEncoder = () => {
7
+ return {
8
+ TextEncoder: harden(TextEncoder),
9
+ };
7
10
  };
11
+ const endowmentModule = {
12
+ names: ['TextEncoder'],
13
+ factory: createTextEncoder,
14
+ };
15
+ export default endowmentModule;
8
16
  //# sourceMappingURL=textEncoder.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"textEncoder.mjs","sourceRoot":"","sources":["../../../src/common/endowments/textEncoder.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,GAAG,EAAE;IAC7B,OAAO;QACL,WAAW,EAAE,MAAM,CAAC,WAAW,CAAC;KACxB,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG;IACtB,KAAK,EAAE,CAAC,aAAa,CAAU;IAC/B,OAAO,EAAE,iBAAiB;CAC3B,CAAC;AACF,eAAe,eAAe,CAAC","sourcesContent":["/**\n * Creates TextEncoder function hardened by SES.\n *\n * @returns An object with the attenuated `TextEncoder` function.\n */\nconst createTextEncoder = () => {\n return {\n TextEncoder: harden(TextEncoder),\n } as const;\n};\n\nconst endowmentModule = {\n names: ['TextEncoder'] as const,\n factory: createTextEncoder,\n};\nexport default endowmentModule;\n"]}
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const rpc_errors_1 = require("@metamask/rpc-errors");
4
+ const MINIMUM_TIMEOUT = 10;
5
+ /**
6
+ * Creates a pair of `setTimeout` and `clearTimeout` functions attenuated such
7
+ * that:
8
+ * - `setTimeout` throws if its "handler" parameter is not a function.
9
+ * - `clearTimeout` only clears timeouts created by its sibling `setTimeout`,
10
+ * or else no-ops.
11
+ *
12
+ * @returns An object with the attenuated `setTimeout` and `clearTimeout`
13
+ * functions.
14
+ */
15
+ const createTimeout = () => {
16
+ const registeredHandles = new Map();
17
+ const _setTimeout = (handler, timeout, ...args) => {
18
+ if (typeof handler !== 'function') {
19
+ throw rpc_errors_1.rpcErrors.internal(`The timeout handler must be a function. Received: ${typeof handler}.`);
20
+ }
21
+ harden(handler);
22
+ const handle = Object.freeze(Object.create(null));
23
+ const platformHandle = setTimeout((...passedArgs) => {
24
+ registeredHandles.delete(handle);
25
+ handler(...passedArgs);
26
+ }, Math.max(MINIMUM_TIMEOUT, timeout ?? 0), ...args);
27
+ registeredHandles.set(handle, platformHandle);
28
+ return handle;
29
+ };
30
+ const _clearTimeout = (handle) => {
31
+ const platformHandle = registeredHandles.get(handle);
32
+ if (platformHandle !== undefined) {
33
+ clearTimeout(platformHandle);
34
+ registeredHandles.delete(handle);
35
+ }
36
+ };
37
+ const teardownFunction = () => {
38
+ for (const handle of registeredHandles.keys()) {
39
+ _clearTimeout(handle);
40
+ }
41
+ };
42
+ return {
43
+ setTimeout: harden(_setTimeout),
44
+ clearTimeout: harden(_clearTimeout),
45
+ teardownFunction,
46
+ };
47
+ };
48
+ const endowmentModule = {
49
+ names: ['setTimeout', 'clearTimeout'],
50
+ factory: createTimeout,
51
+ };
52
+ exports.default = endowmentModule;
53
+ //# sourceMappingURL=timeout.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeout.cjs","sourceRoot":"","sources":["../../../src/common/endowments/timeout.ts"],"names":[],"mappings":";;AAAA,qDAAiD;AAEjD,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B;;;;;;;;;GASG;AACH,MAAM,aAAa,GAAG,GAAG,EAAE;IACzB,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAoB,CAAC;IACtD,MAAM,WAAW,GAAG,CAClB,OAAqB,EACrB,OAAgB,EAChB,GAAG,IAAW,EACL,EAAE;QACX,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;YAClC,MAAM,sBAAS,CAAC,QAAQ,CACtB,qDAAqD,OAAO,OAAO,GAAG,CACvE,CAAC;QACJ,CAAC;QACD,MAAM,CAAC,OAAO,CAAC,CAAC;QAChB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAClD,MAAM,cAAc,GAAG,UAAU,CAC/B,CAAC,GAAG,UAAU,EAAE,EAAE;YAChB,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACjC,OAAO,CAAC,GAAG,UAAU,CAAC,CAAC;QACzB,CAAC,EACD,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,OAAO,IAAI,CAAC,CAAC,EACvC,GAAG,IAAI,CACR,CAAC;QAEF,iBAAiB,CAAC,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;QAC9C,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,CAAC,MAAe,EAAQ,EAAE;QAC9C,MAAM,cAAc,GAAG,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACrD,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;YACjC,YAAY,CAAC,cAAqB,CAAC,CAAC;YACpC,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,gBAAgB,GAAG,GAAS,EAAE;QAClC,KAAK,MAAM,MAAM,IAAI,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC;YAC9C,aAAa,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC;QAC/B,YAAY,EAAE,MAAM,CAAC,aAAa,CAAC;QACnC,gBAAgB;KACR,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG;IACtB,KAAK,EAAE,CAAC,YAAY,EAAE,cAAc,CAAU;IAC9C,OAAO,EAAE,aAAa;CACvB,CAAC;AACF,kBAAe,eAAe,CAAC","sourcesContent":["import { rpcErrors } from '@metamask/rpc-errors';\n\nconst MINIMUM_TIMEOUT = 10;\n\n/**\n * Creates a pair of `setTimeout` and `clearTimeout` functions attenuated such\n * that:\n * - `setTimeout` throws if its \"handler\" parameter is not a function.\n * - `clearTimeout` only clears timeouts created by its sibling `setTimeout`,\n * or else no-ops.\n *\n * @returns An object with the attenuated `setTimeout` and `clearTimeout`\n * functions.\n */\nconst createTimeout = () => {\n const registeredHandles = new Map<unknown, unknown>();\n const _setTimeout = (\n handler: TimerHandler,\n timeout?: number,\n ...args: any[]\n ): unknown => {\n if (typeof handler !== 'function') {\n throw rpcErrors.internal(\n `The timeout handler must be a function. Received: ${typeof handler}.`,\n );\n }\n harden(handler);\n const handle = Object.freeze(Object.create(null));\n const platformHandle = setTimeout(\n (...passedArgs) => {\n registeredHandles.delete(handle);\n handler(...passedArgs);\n },\n Math.max(MINIMUM_TIMEOUT, timeout ?? 0),\n ...args,\n );\n\n registeredHandles.set(handle, platformHandle);\n return handle;\n };\n\n const _clearTimeout = (handle: unknown): void => {\n const platformHandle = registeredHandles.get(handle);\n if (platformHandle !== undefined) {\n clearTimeout(platformHandle as any);\n registeredHandles.delete(handle);\n }\n };\n\n const teardownFunction = (): void => {\n for (const handle of registeredHandles.keys()) {\n _clearTimeout(handle);\n }\n };\n\n return {\n setTimeout: harden(_setTimeout),\n clearTimeout: harden(_clearTimeout),\n teardownFunction,\n } as const;\n};\n\nconst endowmentModule = {\n names: ['setTimeout', 'clearTimeout'] as const,\n factory: createTimeout,\n};\nexport default endowmentModule;\n"]}
@@ -7,3 +7,4 @@ declare const endowmentModule: {
7
7
  };
8
8
  };
9
9
  export default endowmentModule;
10
+ //# sourceMappingURL=timeout.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeout.d.cts","sourceRoot":"","sources":["../../../src/common/endowments/timeout.ts"],"names":[],"mappings":"AA8DA,QAAA,MAAM,eAAe;;;uCA7CR,YAAY,YACX,MAAM,WACP,GAAG,EAAE,KACb,OAAO;wCAqBqB,OAAO,KAAG,IAAI;yCAQhB,IAAI;;CAgBlC,CAAC;AACF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,10 @@
1
+ declare const endowmentModule: {
2
+ names: readonly ["setTimeout", "clearTimeout"];
3
+ factory: () => {
4
+ readonly setTimeout: (handler: TimerHandler, timeout?: number, ...args: any[]) => unknown;
5
+ readonly clearTimeout: (handle: unknown) => void;
6
+ readonly teardownFunction: () => void;
7
+ };
8
+ };
9
+ export default endowmentModule;
10
+ //# sourceMappingURL=timeout.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeout.d.mts","sourceRoot":"","sources":["../../../src/common/endowments/timeout.ts"],"names":[],"mappings":"AA8DA,QAAA,MAAM,eAAe;;;uCA7CR,YAAY,YACX,MAAM,WACP,GAAG,EAAE,KACb,OAAO;wCAqBqB,OAAO,KAAG,IAAI;yCAQhB,IAAI;;CAgBlC,CAAC;AACF,eAAe,eAAe,CAAC"}
@@ -1,8 +1,51 @@
1
- import {
2
- timeout_default
3
- } from "../../chunk-Y7AK2VVC.mjs";
4
- import "../../chunk-YRZVIDCF.mjs";
5
- export {
6
- timeout_default as default
1
+ import { rpcErrors } from "@metamask/rpc-errors";
2
+ const MINIMUM_TIMEOUT = 10;
3
+ /**
4
+ * Creates a pair of `setTimeout` and `clearTimeout` functions attenuated such
5
+ * that:
6
+ * - `setTimeout` throws if its "handler" parameter is not a function.
7
+ * - `clearTimeout` only clears timeouts created by its sibling `setTimeout`,
8
+ * or else no-ops.
9
+ *
10
+ * @returns An object with the attenuated `setTimeout` and `clearTimeout`
11
+ * functions.
12
+ */
13
+ const createTimeout = () => {
14
+ const registeredHandles = new Map();
15
+ const _setTimeout = (handler, timeout, ...args) => {
16
+ if (typeof handler !== 'function') {
17
+ throw rpcErrors.internal(`The timeout handler must be a function. Received: ${typeof handler}.`);
18
+ }
19
+ harden(handler);
20
+ const handle = Object.freeze(Object.create(null));
21
+ const platformHandle = setTimeout((...passedArgs) => {
22
+ registeredHandles.delete(handle);
23
+ handler(...passedArgs);
24
+ }, Math.max(MINIMUM_TIMEOUT, timeout ?? 0), ...args);
25
+ registeredHandles.set(handle, platformHandle);
26
+ return handle;
27
+ };
28
+ const _clearTimeout = (handle) => {
29
+ const platformHandle = registeredHandles.get(handle);
30
+ if (platformHandle !== undefined) {
31
+ clearTimeout(platformHandle);
32
+ registeredHandles.delete(handle);
33
+ }
34
+ };
35
+ const teardownFunction = () => {
36
+ for (const handle of registeredHandles.keys()) {
37
+ _clearTimeout(handle);
38
+ }
39
+ };
40
+ return {
41
+ setTimeout: harden(_setTimeout),
42
+ clearTimeout: harden(_clearTimeout),
43
+ teardownFunction,
44
+ };
7
45
  };
46
+ const endowmentModule = {
47
+ names: ['setTimeout', 'clearTimeout'],
48
+ factory: createTimeout,
49
+ };
50
+ export default endowmentModule;
8
51
  //# sourceMappingURL=timeout.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"timeout.mjs","sourceRoot":"","sources":["../../../src/common/endowments/timeout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,6BAA6B;AAEjD,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B;;;;;;;;;GASG;AACH,MAAM,aAAa,GAAG,GAAG,EAAE;IACzB,MAAM,iBAAiB,GAAG,IAAI,GAAG,EAAoB,CAAC;IACtD,MAAM,WAAW,GAAG,CAClB,OAAqB,EACrB,OAAgB,EAChB,GAAG,IAAW,EACL,EAAE;QACX,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;YAClC,MAAM,SAAS,CAAC,QAAQ,CACtB,qDAAqD,OAAO,OAAO,GAAG,CACvE,CAAC;QACJ,CAAC;QACD,MAAM,CAAC,OAAO,CAAC,CAAC;QAChB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QAClD,MAAM,cAAc,GAAG,UAAU,CAC/B,CAAC,GAAG,UAAU,EAAE,EAAE;YAChB,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YACjC,OAAO,CAAC,GAAG,UAAU,CAAC,CAAC;QACzB,CAAC,EACD,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,OAAO,IAAI,CAAC,CAAC,EACvC,GAAG,IAAI,CACR,CAAC;QAEF,iBAAiB,CAAC,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;QAC9C,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,CAAC,MAAe,EAAQ,EAAE;QAC9C,MAAM,cAAc,GAAG,iBAAiB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACrD,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;YACjC,YAAY,CAAC,cAAqB,CAAC,CAAC;YACpC,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,gBAAgB,GAAG,GAAS,EAAE;QAClC,KAAK,MAAM,MAAM,IAAI,iBAAiB,CAAC,IAAI,EAAE,EAAE,CAAC;YAC9C,aAAa,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,CAAC;IAEF,OAAO;QACL,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC;QAC/B,YAAY,EAAE,MAAM,CAAC,aAAa,CAAC;QACnC,gBAAgB;KACR,CAAC;AACb,CAAC,CAAC;AAEF,MAAM,eAAe,GAAG;IACtB,KAAK,EAAE,CAAC,YAAY,EAAE,cAAc,CAAU;IAC9C,OAAO,EAAE,aAAa;CACvB,CAAC;AACF,eAAe,eAAe,CAAC","sourcesContent":["import { rpcErrors } from '@metamask/rpc-errors';\n\nconst MINIMUM_TIMEOUT = 10;\n\n/**\n * Creates a pair of `setTimeout` and `clearTimeout` functions attenuated such\n * that:\n * - `setTimeout` throws if its \"handler\" parameter is not a function.\n * - `clearTimeout` only clears timeouts created by its sibling `setTimeout`,\n * or else no-ops.\n *\n * @returns An object with the attenuated `setTimeout` and `clearTimeout`\n * functions.\n */\nconst createTimeout = () => {\n const registeredHandles = new Map<unknown, unknown>();\n const _setTimeout = (\n handler: TimerHandler,\n timeout?: number,\n ...args: any[]\n ): unknown => {\n if (typeof handler !== 'function') {\n throw rpcErrors.internal(\n `The timeout handler must be a function. Received: ${typeof handler}.`,\n );\n }\n harden(handler);\n const handle = Object.freeze(Object.create(null));\n const platformHandle = setTimeout(\n (...passedArgs) => {\n registeredHandles.delete(handle);\n handler(...passedArgs);\n },\n Math.max(MINIMUM_TIMEOUT, timeout ?? 0),\n ...args,\n );\n\n registeredHandles.set(handle, platformHandle);\n return handle;\n };\n\n const _clearTimeout = (handle: unknown): void => {\n const platformHandle = registeredHandles.get(handle);\n if (platformHandle !== undefined) {\n clearTimeout(platformHandle as any);\n registeredHandles.delete(handle);\n }\n };\n\n const teardownFunction = (): void => {\n for (const handle of registeredHandles.keys()) {\n _clearTimeout(handle);\n }\n };\n\n return {\n setTimeout: harden(_setTimeout),\n clearTimeout: harden(_clearTimeout),\n teardownFunction,\n } as const;\n};\n\nconst endowmentModule = {\n names: ['setTimeout', 'clearTimeout'] as const,\n factory: createTimeout,\n};\nexport default endowmentModule;\n"]}
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.removeEventListener = exports.addEventListener = void 0;
4
+ const rpc_errors_1 = require("@metamask/rpc-errors");
5
+ const globalObject_1 = require("./globalObject.cjs");
6
+ /**
7
+ * Adds an event listener platform agnostically, trying both `globalThis.addEventListener` and `globalThis.process.on`
8
+ *
9
+ * @param event - The event to listen for.
10
+ * @param listener - The listener to be triggered when the event occurs.
11
+ * @returns The result of the platform agnostic operation if any.
12
+ * @throws If none of the platform options are present.
13
+ */
14
+ function addEventListener(event, listener) {
15
+ if ('addEventListener' in globalObject_1.rootRealmGlobal &&
16
+ typeof globalObject_1.rootRealmGlobal.addEventListener === 'function') {
17
+ return globalObject_1.rootRealmGlobal.addEventListener(event.toLowerCase(), listener);
18
+ }
19
+ if (globalObject_1.rootRealmGlobal.process &&
20
+ 'on' in globalObject_1.rootRealmGlobal.process &&
21
+ typeof globalObject_1.rootRealmGlobal.process.on === 'function') {
22
+ return globalObject_1.rootRealmGlobal.process.on(event, listener);
23
+ }
24
+ throw rpc_errors_1.rpcErrors.internal('Platform agnostic addEventListener failed.');
25
+ }
26
+ exports.addEventListener = addEventListener;
27
+ /**
28
+ * Removes an event listener platform agnostically, trying both `globalThis.removeEventListener` and `globalThis.process.removeListener`
29
+ *
30
+ * @param event - The event to remove the listener for.
31
+ * @param listener - The currently attached listener.
32
+ * @returns The result of the platform agnostic operation if any.
33
+ * @throws If none of the platform options are present.
34
+ */
35
+ function removeEventListener(event, listener) {
36
+ if ('removeEventListener' in globalObject_1.rootRealmGlobal &&
37
+ typeof globalObject_1.rootRealmGlobal.removeEventListener === 'function') {
38
+ return globalObject_1.rootRealmGlobal.removeEventListener(event.toLowerCase(), listener);
39
+ }
40
+ if (globalObject_1.rootRealmGlobal.process &&
41
+ 'removeListener' in globalObject_1.rootRealmGlobal.process &&
42
+ typeof globalObject_1.rootRealmGlobal.process.removeListener === 'function') {
43
+ return globalObject_1.rootRealmGlobal.process.removeListener(event, listener);
44
+ }
45
+ throw new Error('Platform agnostic removeEventListener failed');
46
+ }
47
+ exports.removeEventListener = removeEventListener;
48
+ //# sourceMappingURL=globalEvents.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globalEvents.cjs","sourceRoot":"","sources":["../../src/common/globalEvents.ts"],"names":[],"mappings":";;;AAAA,qDAAiD;AAEjD,qDAAiD;AAEjD;;;;;;;GAOG;AACH,SAAgB,gBAAgB,CAC9B,KAAa,EACb,QAAkC;IAElC,IACE,kBAAkB,IAAI,8BAAe;QACrC,OAAO,8BAAe,CAAC,gBAAgB,KAAK,UAAU,EACtD,CAAC;QACD,OAAO,8BAAe,CAAC,gBAAgB,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAC;IACzE,CAAC;IAED,IACE,8BAAe,CAAC,OAAO;QACvB,IAAI,IAAI,8BAAe,CAAC,OAAO;QAC/B,OAAO,8BAAe,CAAC,OAAO,CAAC,EAAE,KAAK,UAAU,EAChD,CAAC;QACD,OAAO,8BAAe,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,sBAAS,CAAC,QAAQ,CAAC,4CAA4C,CAAC,CAAC;AACzE,CAAC;AApBD,4CAoBC;AAED;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CACjC,KAAa,EACb,QAAkC;IAElC,IACE,qBAAqB,IAAI,8BAAe;QACxC,OAAO,8BAAe,CAAC,mBAAmB,KAAK,UAAU,EACzD,CAAC;QACD,OAAO,8BAAe,CAAC,mBAAmB,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC5E,CAAC;IAED,IACE,8BAAe,CAAC,OAAO;QACvB,gBAAgB,IAAI,8BAAe,CAAC,OAAO;QAC3C,OAAO,8BAAe,CAAC,OAAO,CAAC,cAAc,KAAK,UAAU,EAC5D,CAAC;QACD,OAAO,8BAAe,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;AAClE,CAAC;AApBD,kDAoBC","sourcesContent":["import { rpcErrors } from '@metamask/rpc-errors';\n\nimport { rootRealmGlobal } from './globalObject';\n\n/**\n * Adds an event listener platform agnostically, trying both `globalThis.addEventListener` and `globalThis.process.on`\n *\n * @param event - The event to listen for.\n * @param listener - The listener to be triggered when the event occurs.\n * @returns The result of the platform agnostic operation if any.\n * @throws If none of the platform options are present.\n */\nexport function addEventListener(\n event: string,\n listener: (...args: any[]) => void,\n) {\n if (\n 'addEventListener' in rootRealmGlobal &&\n typeof rootRealmGlobal.addEventListener === 'function'\n ) {\n return rootRealmGlobal.addEventListener(event.toLowerCase(), listener);\n }\n\n if (\n rootRealmGlobal.process &&\n 'on' in rootRealmGlobal.process &&\n typeof rootRealmGlobal.process.on === 'function'\n ) {\n return rootRealmGlobal.process.on(event, listener);\n }\n\n throw rpcErrors.internal('Platform agnostic addEventListener failed.');\n}\n\n/**\n * Removes an event listener platform agnostically, trying both `globalThis.removeEventListener` and `globalThis.process.removeListener`\n *\n * @param event - The event to remove the listener for.\n * @param listener - The currently attached listener.\n * @returns The result of the platform agnostic operation if any.\n * @throws If none of the platform options are present.\n */\nexport function removeEventListener(\n event: string,\n listener: (...args: any[]) => void,\n) {\n if (\n 'removeEventListener' in rootRealmGlobal &&\n typeof rootRealmGlobal.removeEventListener === 'function'\n ) {\n return rootRealmGlobal.removeEventListener(event.toLowerCase(), listener);\n }\n\n if (\n rootRealmGlobal.process &&\n 'removeListener' in rootRealmGlobal.process &&\n typeof rootRealmGlobal.process.removeListener === 'function'\n ) {\n return rootRealmGlobal.process.removeListener(event, listener);\n }\n\n throw new Error('Platform agnostic removeEventListener failed');\n}\n"]}
@@ -18,3 +18,4 @@ export declare function addEventListener(event: string, listener: (...args: any[
18
18
  * @throws If none of the platform options are present.
19
19
  */
20
20
  export declare function removeEventListener(event: string, listener: (...args: any[]) => void): void | NodeJS.Process;
21
+ //# sourceMappingURL=globalEvents.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globalEvents.d.cts","sourceRoot":"","sources":["../../src/common/globalEvents.ts"],"names":[],"mappings":";;AAIA;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,yBAkBnC;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,yBAkBnC"}
@@ -0,0 +1,21 @@
1
+ /// <reference types="webpack-env" />
2
+ /// <reference types="node" />
3
+ /**
4
+ * Adds an event listener platform agnostically, trying both `globalThis.addEventListener` and `globalThis.process.on`
5
+ *
6
+ * @param event - The event to listen for.
7
+ * @param listener - The listener to be triggered when the event occurs.
8
+ * @returns The result of the platform agnostic operation if any.
9
+ * @throws If none of the platform options are present.
10
+ */
11
+ export declare function addEventListener(event: string, listener: (...args: any[]) => void): void | NodeJS.Process;
12
+ /**
13
+ * Removes an event listener platform agnostically, trying both `globalThis.removeEventListener` and `globalThis.process.removeListener`
14
+ *
15
+ * @param event - The event to remove the listener for.
16
+ * @param listener - The currently attached listener.
17
+ * @returns The result of the platform agnostic operation if any.
18
+ * @throws If none of the platform options are present.
19
+ */
20
+ export declare function removeEventListener(event: string, listener: (...args: any[]) => void): void | NodeJS.Process;
21
+ //# sourceMappingURL=globalEvents.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globalEvents.d.mts","sourceRoot":"","sources":["../../src/common/globalEvents.ts"],"names":[],"mappings":";;AAIA;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,yBAkBnC;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,IAAI,yBAkBnC"}
@@ -1,11 +1,43 @@
1
- import {
2
- addEventListener,
3
- removeEventListener
4
- } from "../chunk-ZNTCZK7J.mjs";
5
- import "../chunk-IX5S3V47.mjs";
6
- import "../chunk-YRZVIDCF.mjs";
7
- export {
8
- addEventListener,
9
- removeEventListener
10
- };
1
+ import { rpcErrors } from "@metamask/rpc-errors";
2
+ import { rootRealmGlobal } from "./globalObject.mjs";
3
+ /**
4
+ * Adds an event listener platform agnostically, trying both `globalThis.addEventListener` and `globalThis.process.on`
5
+ *
6
+ * @param event - The event to listen for.
7
+ * @param listener - The listener to be triggered when the event occurs.
8
+ * @returns The result of the platform agnostic operation if any.
9
+ * @throws If none of the platform options are present.
10
+ */
11
+ export function addEventListener(event, listener) {
12
+ if ('addEventListener' in rootRealmGlobal &&
13
+ typeof rootRealmGlobal.addEventListener === 'function') {
14
+ return rootRealmGlobal.addEventListener(event.toLowerCase(), listener);
15
+ }
16
+ if (rootRealmGlobal.process &&
17
+ 'on' in rootRealmGlobal.process &&
18
+ typeof rootRealmGlobal.process.on === 'function') {
19
+ return rootRealmGlobal.process.on(event, listener);
20
+ }
21
+ throw rpcErrors.internal('Platform agnostic addEventListener failed.');
22
+ }
23
+ /**
24
+ * Removes an event listener platform agnostically, trying both `globalThis.removeEventListener` and `globalThis.process.removeListener`
25
+ *
26
+ * @param event - The event to remove the listener for.
27
+ * @param listener - The currently attached listener.
28
+ * @returns The result of the platform agnostic operation if any.
29
+ * @throws If none of the platform options are present.
30
+ */
31
+ export function removeEventListener(event, listener) {
32
+ if ('removeEventListener' in rootRealmGlobal &&
33
+ typeof rootRealmGlobal.removeEventListener === 'function') {
34
+ return rootRealmGlobal.removeEventListener(event.toLowerCase(), listener);
35
+ }
36
+ if (rootRealmGlobal.process &&
37
+ 'removeListener' in rootRealmGlobal.process &&
38
+ typeof rootRealmGlobal.process.removeListener === 'function') {
39
+ return rootRealmGlobal.process.removeListener(event, listener);
40
+ }
41
+ throw new Error('Platform agnostic removeEventListener failed');
42
+ }
11
43
  //# sourceMappingURL=globalEvents.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"globalEvents.mjs","sourceRoot":"","sources":["../../src/common/globalEvents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,6BAA6B;AAEjD,OAAO,EAAE,eAAe,EAAE,2BAAuB;AAEjD;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAa,EACb,QAAkC;IAElC,IACE,kBAAkB,IAAI,eAAe;QACrC,OAAO,eAAe,CAAC,gBAAgB,KAAK,UAAU,EACtD,CAAC;QACD,OAAO,eAAe,CAAC,gBAAgB,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAC;IACzE,CAAC;IAED,IACE,eAAe,CAAC,OAAO;QACvB,IAAI,IAAI,eAAe,CAAC,OAAO;QAC/B,OAAO,eAAe,CAAC,OAAO,CAAC,EAAE,KAAK,UAAU,EAChD,CAAC;QACD,OAAO,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,SAAS,CAAC,QAAQ,CAAC,4CAA4C,CAAC,CAAC;AACzE,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CACjC,KAAa,EACb,QAAkC;IAElC,IACE,qBAAqB,IAAI,eAAe;QACxC,OAAO,eAAe,CAAC,mBAAmB,KAAK,UAAU,EACzD,CAAC;QACD,OAAO,eAAe,CAAC,mBAAmB,CAAC,KAAK,CAAC,WAAW,EAAE,EAAE,QAAQ,CAAC,CAAC;IAC5E,CAAC;IAED,IACE,eAAe,CAAC,OAAO;QACvB,gBAAgB,IAAI,eAAe,CAAC,OAAO;QAC3C,OAAO,eAAe,CAAC,OAAO,CAAC,cAAc,KAAK,UAAU,EAC5D,CAAC;QACD,OAAO,eAAe,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;AAClE,CAAC","sourcesContent":["import { rpcErrors } from '@metamask/rpc-errors';\n\nimport { rootRealmGlobal } from './globalObject';\n\n/**\n * Adds an event listener platform agnostically, trying both `globalThis.addEventListener` and `globalThis.process.on`\n *\n * @param event - The event to listen for.\n * @param listener - The listener to be triggered when the event occurs.\n * @returns The result of the platform agnostic operation if any.\n * @throws If none of the platform options are present.\n */\nexport function addEventListener(\n event: string,\n listener: (...args: any[]) => void,\n) {\n if (\n 'addEventListener' in rootRealmGlobal &&\n typeof rootRealmGlobal.addEventListener === 'function'\n ) {\n return rootRealmGlobal.addEventListener(event.toLowerCase(), listener);\n }\n\n if (\n rootRealmGlobal.process &&\n 'on' in rootRealmGlobal.process &&\n typeof rootRealmGlobal.process.on === 'function'\n ) {\n return rootRealmGlobal.process.on(event, listener);\n }\n\n throw rpcErrors.internal('Platform agnostic addEventListener failed.');\n}\n\n/**\n * Removes an event listener platform agnostically, trying both `globalThis.removeEventListener` and `globalThis.process.removeListener`\n *\n * @param event - The event to remove the listener for.\n * @param listener - The currently attached listener.\n * @returns The result of the platform agnostic operation if any.\n * @throws If none of the platform options are present.\n */\nexport function removeEventListener(\n event: string,\n listener: (...args: any[]) => void,\n) {\n if (\n 'removeEventListener' in rootRealmGlobal &&\n typeof rootRealmGlobal.removeEventListener === 'function'\n ) {\n return rootRealmGlobal.removeEventListener(event.toLowerCase(), listener);\n }\n\n if (\n rootRealmGlobal.process &&\n 'removeListener' in rootRealmGlobal.process &&\n typeof rootRealmGlobal.process.removeListener === 'function'\n ) {\n return rootRealmGlobal.process.removeListener(event, listener);\n }\n\n throw new Error('Platform agnostic removeEventListener failed');\n}\n"]}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rootRealmGlobalName = exports.rootRealmGlobal = void 0;
4
+ var GlobalObjectNames;
5
+ (function (GlobalObjectNames) {
6
+ // The globalThis entry is incorrectly identified as shadowing the global
7
+ // globalThis.
8
+ /* eslint-disable @typescript-eslint/naming-convention */
9
+ // eslint-disable-next-line @typescript-eslint/no-shadow
10
+ GlobalObjectNames["globalThis"] = "globalThis";
11
+ GlobalObjectNames["global"] = "global";
12
+ GlobalObjectNames["self"] = "self";
13
+ GlobalObjectNames["window"] = "window";
14
+ /* eslint-enable @typescript-eslint/naming-convention */
15
+ })(GlobalObjectNames || (GlobalObjectNames = {}));
16
+ let _rootRealmGlobal;
17
+ let _rootRealmGlobalName;
18
+ /* istanbul ignore next */
19
+ /* eslint-disable no-negated-condition */
20
+ if (typeof globalThis !== 'undefined') {
21
+ _rootRealmGlobal = globalThis;
22
+ _rootRealmGlobalName = GlobalObjectNames.globalThis;
23
+ }
24
+ else if (typeof self !== 'undefined') {
25
+ _rootRealmGlobal = self;
26
+ _rootRealmGlobalName = GlobalObjectNames.self;
27
+ }
28
+ else if (typeof window !== 'undefined') {
29
+ _rootRealmGlobal = window;
30
+ _rootRealmGlobalName = GlobalObjectNames.window;
31
+ }
32
+ else if (typeof global !== 'undefined') {
33
+ _rootRealmGlobal = global;
34
+ _rootRealmGlobalName = GlobalObjectNames.global;
35
+ }
36
+ else {
37
+ throw new Error('Unknown realm type; failed to identify global object.');
38
+ }
39
+ /* eslint-enable no-negated-condition */
40
+ /**
41
+ * A platform-agnostic alias for the root realm global object.
42
+ */
43
+ const rootRealmGlobal = _rootRealmGlobal;
44
+ exports.rootRealmGlobal = rootRealmGlobal;
45
+ /**
46
+ * The string literal corresponding to the name of the root realm global object.
47
+ */
48
+ const rootRealmGlobalName = _rootRealmGlobalName;
49
+ exports.rootRealmGlobalName = rootRealmGlobalName;
50
+ //# sourceMappingURL=globalObject.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globalObject.cjs","sourceRoot":"","sources":["../../src/common/globalObject.ts"],"names":[],"mappings":";;;AAAA,IAAK,iBAUJ;AAVD,WAAK,iBAAiB;IACpB,yEAAyE;IACzE,cAAc;IACd,yDAAyD;IACzD,wDAAwD;IACxD,8CAAyB,CAAA;IACzB,sCAAiB,CAAA;IACjB,kCAAa,CAAA;IACb,sCAAiB,CAAA;IACjB,wDAAwD;AAC1D,CAAC,EAVI,iBAAiB,KAAjB,iBAAiB,QAUrB;AAED,IAAI,gBAAmC,CAAC;AACxC,IAAI,oBAA4B,CAAC;AAEjC,0BAA0B;AAC1B,yCAAyC;AACzC,IAAI,OAAO,UAAU,KAAK,WAAW,EAAE,CAAC;IACtC,gBAAgB,GAAG,UAAU,CAAC;IAC9B,oBAAoB,GAAG,iBAAiB,CAAC,UAAU,CAAC;AACtD,CAAC;KAAM,IAAI,OAAO,IAAI,KAAK,WAAW,EAAE,CAAC;IACvC,gBAAgB,GAAG,IAAI,CAAC;IACxB,oBAAoB,GAAG,iBAAiB,CAAC,IAAI,CAAC;AAChD,CAAC;KAAM,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;IACzC,gBAAgB,GAAG,MAAM,CAAC;IAC1B,oBAAoB,GAAG,iBAAiB,CAAC,MAAM,CAAC;AAClD,CAAC;KAAM,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;IACzC,gBAAgB,GAAG,MAAM,CAAC;IAC1B,oBAAoB,GAAG,iBAAiB,CAAC,MAAM,CAAC;AAClD,CAAC;KAAM,CAAC;IACN,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;AAC3E,CAAC;AACD,wCAAwC;AAExC;;GAEG;AACH,MAAM,eAAe,GAAG,gBAAgB,CAAC;AAOhC,0CAAe;AALxB;;GAEG;AACH,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAEvB,kDAAmB","sourcesContent":["enum GlobalObjectNames {\n // The globalThis entry is incorrectly identified as shadowing the global\n // globalThis.\n /* eslint-disable @typescript-eslint/naming-convention */\n // eslint-disable-next-line @typescript-eslint/no-shadow\n globalThis = 'globalThis',\n global = 'global',\n self = 'self',\n window = 'window',\n /* eslint-enable @typescript-eslint/naming-convention */\n}\n\nlet _rootRealmGlobal: typeof globalThis;\nlet _rootRealmGlobalName: string;\n\n/* istanbul ignore next */\n/* eslint-disable no-negated-condition */\nif (typeof globalThis !== 'undefined') {\n _rootRealmGlobal = globalThis;\n _rootRealmGlobalName = GlobalObjectNames.globalThis;\n} else if (typeof self !== 'undefined') {\n _rootRealmGlobal = self;\n _rootRealmGlobalName = GlobalObjectNames.self;\n} else if (typeof window !== 'undefined') {\n _rootRealmGlobal = window;\n _rootRealmGlobalName = GlobalObjectNames.window;\n} else if (typeof global !== 'undefined') {\n _rootRealmGlobal = global;\n _rootRealmGlobalName = GlobalObjectNames.global;\n} else {\n throw new Error('Unknown realm type; failed to identify global object.');\n}\n/* eslint-enable no-negated-condition */\n\n/**\n * A platform-agnostic alias for the root realm global object.\n */\nconst rootRealmGlobal = _rootRealmGlobal;\n\n/**\n * The string literal corresponding to the name of the root realm global object.\n */\nconst rootRealmGlobalName = _rootRealmGlobalName;\n\nexport { rootRealmGlobal, rootRealmGlobalName };\n"]}
@@ -7,3 +7,4 @@ declare const rootRealmGlobal: typeof globalThis;
7
7
  */
8
8
  declare const rootRealmGlobalName: string;
9
9
  export { rootRealmGlobal, rootRealmGlobalName };
10
+ //# sourceMappingURL=globalObject.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globalObject.d.cts","sourceRoot":"","sources":["../../src/common/globalObject.ts"],"names":[],"mappings":"AAkCA;;GAEG;AACH,QAAA,MAAM,eAAe,mBAAmB,CAAC;AAEzC;;GAEG;AACH,QAAA,MAAM,mBAAmB,QAAuB,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,CAAC"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ * A platform-agnostic alias for the root realm global object.
3
+ */
4
+ declare const rootRealmGlobal: typeof globalThis;
5
+ /**
6
+ * The string literal corresponding to the name of the root realm global object.
7
+ */
8
+ declare const rootRealmGlobalName: string;
9
+ export { rootRealmGlobal, rootRealmGlobalName };
10
+ //# sourceMappingURL=globalObject.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globalObject.d.mts","sourceRoot":"","sources":["../../src/common/globalObject.ts"],"names":[],"mappings":"AAkCA;;GAEG;AACH,QAAA,MAAM,eAAe,mBAAmB,CAAC;AAEzC;;GAEG;AACH,QAAA,MAAM,mBAAmB,QAAuB,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,CAAC"}
@@ -1,10 +1,46 @@
1
- import {
2
- rootRealmGlobal,
3
- rootRealmGlobalName
4
- } from "../chunk-IX5S3V47.mjs";
5
- import "../chunk-YRZVIDCF.mjs";
6
- export {
7
- rootRealmGlobal,
8
- rootRealmGlobalName
9
- };
1
+ var GlobalObjectNames;
2
+ (function (GlobalObjectNames) {
3
+ // The globalThis entry is incorrectly identified as shadowing the global
4
+ // globalThis.
5
+ /* eslint-disable @typescript-eslint/naming-convention */
6
+ // eslint-disable-next-line @typescript-eslint/no-shadow
7
+ GlobalObjectNames["globalThis"] = "globalThis";
8
+ GlobalObjectNames["global"] = "global";
9
+ GlobalObjectNames["self"] = "self";
10
+ GlobalObjectNames["window"] = "window";
11
+ /* eslint-enable @typescript-eslint/naming-convention */
12
+ })(GlobalObjectNames || (GlobalObjectNames = {}));
13
+ let _rootRealmGlobal;
14
+ let _rootRealmGlobalName;
15
+ /* istanbul ignore next */
16
+ /* eslint-disable no-negated-condition */
17
+ if (typeof globalThis !== 'undefined') {
18
+ _rootRealmGlobal = globalThis;
19
+ _rootRealmGlobalName = GlobalObjectNames.globalThis;
20
+ }
21
+ else if (typeof self !== 'undefined') {
22
+ _rootRealmGlobal = self;
23
+ _rootRealmGlobalName = GlobalObjectNames.self;
24
+ }
25
+ else if (typeof window !== 'undefined') {
26
+ _rootRealmGlobal = window;
27
+ _rootRealmGlobalName = GlobalObjectNames.window;
28
+ }
29
+ else if (typeof global !== 'undefined') {
30
+ _rootRealmGlobal = global;
31
+ _rootRealmGlobalName = GlobalObjectNames.global;
32
+ }
33
+ else {
34
+ throw new Error('Unknown realm type; failed to identify global object.');
35
+ }
36
+ /* eslint-enable no-negated-condition */
37
+ /**
38
+ * A platform-agnostic alias for the root realm global object.
39
+ */
40
+ const rootRealmGlobal = _rootRealmGlobal;
41
+ /**
42
+ * The string literal corresponding to the name of the root realm global object.
43
+ */
44
+ const rootRealmGlobalName = _rootRealmGlobalName;
45
+ export { rootRealmGlobal, rootRealmGlobalName };
10
46
  //# sourceMappingURL=globalObject.mjs.map