@metamask/snaps-controllers 9.19.0 → 10.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/dist/cronjob/CronjobController.cjs.map +1 -1
  3. package/dist/cronjob/CronjobController.d.cts +2 -2
  4. package/dist/cronjob/CronjobController.d.cts.map +1 -1
  5. package/dist/cronjob/CronjobController.d.mts +2 -2
  6. package/dist/cronjob/CronjobController.d.mts.map +1 -1
  7. package/dist/cronjob/CronjobController.mjs.map +1 -1
  8. package/dist/insights/SnapInsightsController.cjs.map +1 -1
  9. package/dist/insights/SnapInsightsController.d.cts +2 -2
  10. package/dist/insights/SnapInsightsController.d.cts.map +1 -1
  11. package/dist/insights/SnapInsightsController.d.mts +2 -2
  12. package/dist/insights/SnapInsightsController.d.mts.map +1 -1
  13. package/dist/insights/SnapInsightsController.mjs.map +1 -1
  14. package/dist/interface/SnapInterfaceController.cjs.map +1 -1
  15. package/dist/interface/SnapInterfaceController.d.cts +2 -2
  16. package/dist/interface/SnapInterfaceController.d.cts.map +1 -1
  17. package/dist/interface/SnapInterfaceController.d.mts +2 -2
  18. package/dist/interface/SnapInterfaceController.d.mts.map +1 -1
  19. package/dist/interface/SnapInterfaceController.mjs.map +1 -1
  20. package/dist/multichain/MultichainRouter.cjs +11 -1
  21. package/dist/multichain/MultichainRouter.cjs.map +1 -1
  22. package/dist/multichain/MultichainRouter.d.cts +5 -3
  23. package/dist/multichain/MultichainRouter.d.cts.map +1 -1
  24. package/dist/multichain/MultichainRouter.d.mts +5 -3
  25. package/dist/multichain/MultichainRouter.d.mts.map +1 -1
  26. package/dist/multichain/MultichainRouter.mjs +11 -1
  27. package/dist/multichain/MultichainRouter.mjs.map +1 -1
  28. package/dist/services/AbstractExecutionService.cjs +2 -0
  29. package/dist/services/AbstractExecutionService.cjs.map +1 -1
  30. package/dist/services/AbstractExecutionService.d.cts +4 -0
  31. package/dist/services/AbstractExecutionService.d.cts.map +1 -1
  32. package/dist/services/AbstractExecutionService.d.mts +4 -0
  33. package/dist/services/AbstractExecutionService.d.mts.map +1 -1
  34. package/dist/services/AbstractExecutionService.mjs +2 -0
  35. package/dist/services/AbstractExecutionService.mjs.map +1 -1
  36. package/dist/services/ExecutionService.cjs.map +1 -1
  37. package/dist/services/ExecutionService.d.cts +4 -2
  38. package/dist/services/ExecutionService.d.cts.map +1 -1
  39. package/dist/services/ExecutionService.d.mts +4 -2
  40. package/dist/services/ExecutionService.d.mts.map +1 -1
  41. package/dist/services/ExecutionService.mjs.map +1 -1
  42. package/dist/services/iframe/IframeExecutionService.cjs +2 -1
  43. package/dist/services/iframe/IframeExecutionService.cjs.map +1 -1
  44. package/dist/services/iframe/IframeExecutionService.d.cts +1 -1
  45. package/dist/services/iframe/IframeExecutionService.d.cts.map +1 -1
  46. package/dist/services/iframe/IframeExecutionService.d.mts +1 -1
  47. package/dist/services/iframe/IframeExecutionService.d.mts.map +1 -1
  48. package/dist/services/iframe/IframeExecutionService.mjs +2 -1
  49. package/dist/services/iframe/IframeExecutionService.mjs.map +1 -1
  50. package/dist/services/offscreen/OffscreenExecutionService.cjs +2 -1
  51. package/dist/services/offscreen/OffscreenExecutionService.cjs.map +1 -1
  52. package/dist/services/offscreen/OffscreenExecutionService.d.cts +1 -1
  53. package/dist/services/offscreen/OffscreenExecutionService.d.cts.map +1 -1
  54. package/dist/services/offscreen/OffscreenExecutionService.d.mts +1 -1
  55. package/dist/services/offscreen/OffscreenExecutionService.d.mts.map +1 -1
  56. package/dist/services/offscreen/OffscreenExecutionService.mjs +2 -1
  57. package/dist/services/offscreen/OffscreenExecutionService.mjs.map +1 -1
  58. package/dist/services/proxy/ProxyExecutionService.cjs +2 -1
  59. package/dist/services/proxy/ProxyExecutionService.cjs.map +1 -1
  60. package/dist/services/proxy/ProxyExecutionService.d.cts +1 -1
  61. package/dist/services/proxy/ProxyExecutionService.d.cts.map +1 -1
  62. package/dist/services/proxy/ProxyExecutionService.d.mts +1 -1
  63. package/dist/services/proxy/ProxyExecutionService.d.mts.map +1 -1
  64. package/dist/services/proxy/ProxyExecutionService.mjs +2 -1
  65. package/dist/services/proxy/ProxyExecutionService.mjs.map +1 -1
  66. package/dist/services/webview/WebViewExecutionService.cjs +20 -22
  67. package/dist/services/webview/WebViewExecutionService.cjs.map +1 -1
  68. package/dist/services/webview/WebViewExecutionService.d.cts +10 -7
  69. package/dist/services/webview/WebViewExecutionService.d.cts.map +1 -1
  70. package/dist/services/webview/WebViewExecutionService.d.mts +10 -7
  71. package/dist/services/webview/WebViewExecutionService.d.mts.map +1 -1
  72. package/dist/services/webview/WebViewExecutionService.mjs +20 -22
  73. package/dist/services/webview/WebViewExecutionService.mjs.map +1 -1
  74. package/dist/services/webview/WebViewMessageStream.cjs +11 -22
  75. package/dist/services/webview/WebViewMessageStream.cjs.map +1 -1
  76. package/dist/services/webview/WebViewMessageStream.d.cts +3 -3
  77. package/dist/services/webview/WebViewMessageStream.d.cts.map +1 -1
  78. package/dist/services/webview/WebViewMessageStream.d.mts +3 -3
  79. package/dist/services/webview/WebViewMessageStream.d.mts.map +1 -1
  80. package/dist/services/webview/WebViewMessageStream.mjs +12 -23
  81. package/dist/services/webview/WebViewMessageStream.mjs.map +1 -1
  82. package/dist/services/webworker/WebWorkerExecutionService.cjs +2 -1
  83. package/dist/services/webworker/WebWorkerExecutionService.cjs.map +1 -1
  84. package/dist/services/webworker/WebWorkerExecutionService.d.cts +1 -1
  85. package/dist/services/webworker/WebWorkerExecutionService.d.cts.map +1 -1
  86. package/dist/services/webworker/WebWorkerExecutionService.d.mts +1 -1
  87. package/dist/services/webworker/WebWorkerExecutionService.d.mts.map +1 -1
  88. package/dist/services/webworker/WebWorkerExecutionService.mjs +2 -1
  89. package/dist/services/webworker/WebWorkerExecutionService.mjs.map +1 -1
  90. package/dist/snaps/SnapController.cjs.map +1 -1
  91. package/dist/snaps/SnapController.d.cts +2 -2
  92. package/dist/snaps/SnapController.d.cts.map +1 -1
  93. package/dist/snaps/SnapController.d.mts +2 -2
  94. package/dist/snaps/SnapController.d.mts.map +1 -1
  95. package/dist/snaps/SnapController.mjs.map +1 -1
  96. package/dist/snaps/registry/json.cjs.map +1 -1
  97. package/dist/snaps/registry/json.d.cts +2 -2
  98. package/dist/snaps/registry/json.d.cts.map +1 -1
  99. package/dist/snaps/registry/json.d.mts +2 -2
  100. package/dist/snaps/registry/json.d.mts.map +1 -1
  101. package/dist/snaps/registry/json.mjs.map +1 -1
  102. package/package.json +11 -11
@@ -5,8 +5,9 @@ const post_message_stream_1 = require("@metamask/post-message-stream");
5
5
  const snaps_utils_1 = require("@metamask/snaps-utils");
6
6
  const AbstractExecutionService_1 = require("../AbstractExecutionService.cjs");
7
7
  class IframeExecutionService extends AbstractExecutionService_1.AbstractExecutionService {
8
- constructor({ iframeUrl, messenger, setupSnapProvider, }) {
8
+ constructor({ iframeUrl, messenger, setupSnapProvider, ...args }) {
9
9
  super({
10
+ ...args,
10
11
  messenger,
11
12
  setupSnapProvider,
12
13
  });
@@ -1 +1 @@
1
- {"version":3,"file":"IframeExecutionService.cjs","sourceRoot":"","sources":["../../../src/services/iframe/IframeExecutionService.ts"],"names":[],"mappings":";;;AACA,uEAAwE;AACxE,uDAAqD;AAMrD,8EAAuE;AAMvE,MAAa,sBAAuB,SAAQ,mDAAgC;IAG1E,YAAY,EACV,SAAS,EACT,SAAS,EACT,iBAAiB,GACqB;QACtC,KAAK,CAAC;YACJ,SAAS;YACT,iBAAiB;SAClB,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAES,YAAY,CAAC,UAAoC;QACzD,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IACnD,CAAC;IAES,KAAK,CAAC,aAAa,CAAC,KAAa;QAIzC,MAAM,YAAY,GAAG,MAAM,IAAA,0BAAY,EAAC;YACtC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE;YAC9B,EAAE,EAAE,KAAK;SACV,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,IAAI,6CAAuB,CAAC;YACzC,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,OAAO;YACf,YAAY,EAAE,YAAY;YAC1B,YAAY,EAAE,GAAG;SAClB,CAAC,CAAC;QAEH,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC;IAC1C,CAAC;CACF;AArCD,wDAqCC","sourcesContent":["import type { BasePostMessageStream } from '@metamask/post-message-stream';\nimport { WindowPostMessageStream } from '@metamask/post-message-stream';\nimport { createWindow } from '@metamask/snaps-utils';\n\nimport type {\n ExecutionServiceArgs,\n TerminateJobArgs,\n} from '../AbstractExecutionService';\nimport { AbstractExecutionService } from '../AbstractExecutionService';\n\ntype IframeExecutionEnvironmentServiceArgs = {\n iframeUrl: URL;\n} & ExecutionServiceArgs;\n\nexport class IframeExecutionService extends AbstractExecutionService<Window> {\n public iframeUrl: URL;\n\n constructor({\n iframeUrl,\n messenger,\n setupSnapProvider,\n }: IframeExecutionEnvironmentServiceArgs) {\n super({\n messenger,\n setupSnapProvider,\n });\n this.iframeUrl = iframeUrl;\n }\n\n protected terminateJob(jobWrapper: TerminateJobArgs<Window>): void {\n document.getElementById(jobWrapper.id)?.remove();\n }\n\n protected async initEnvStream(jobId: string): Promise<{\n worker: Window;\n stream: BasePostMessageStream;\n }> {\n const iframeWindow = await createWindow({\n uri: this.iframeUrl.toString(),\n id: jobId,\n });\n\n const stream = new WindowPostMessageStream({\n name: 'parent',\n target: 'child',\n targetWindow: iframeWindow,\n targetOrigin: '*',\n });\n\n return { worker: iframeWindow, stream };\n }\n}\n"]}
1
+ {"version":3,"file":"IframeExecutionService.cjs","sourceRoot":"","sources":["../../../src/services/iframe/IframeExecutionService.ts"],"names":[],"mappings":";;;AACA,uEAAwE;AACxE,uDAAqD;AAMrD,8EAAuE;AAMvE,MAAa,sBAAuB,SAAQ,mDAAgC;IAG1E,YAAY,EACV,SAAS,EACT,SAAS,EACT,iBAAiB,EACjB,GAAG,IAAI,EAC+B;QACtC,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,SAAS;YACT,iBAAiB;SAClB,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAES,YAAY,CAAC,UAAoC;QACzD,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IACnD,CAAC;IAES,KAAK,CAAC,aAAa,CAAC,KAAa;QAIzC,MAAM,YAAY,GAAG,MAAM,IAAA,0BAAY,EAAC;YACtC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE;YAC9B,EAAE,EAAE,KAAK;SACV,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,IAAI,6CAAuB,CAAC;YACzC,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,OAAO;YACf,YAAY,EAAE,YAAY;YAC1B,YAAY,EAAE,GAAG;SAClB,CAAC,CAAC;QAEH,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC;IAC1C,CAAC;CACF;AAvCD,wDAuCC","sourcesContent":["import type { BasePostMessageStream } from '@metamask/post-message-stream';\nimport { WindowPostMessageStream } from '@metamask/post-message-stream';\nimport { createWindow } from '@metamask/snaps-utils';\n\nimport type {\n ExecutionServiceArgs,\n TerminateJobArgs,\n} from '../AbstractExecutionService';\nimport { AbstractExecutionService } from '../AbstractExecutionService';\n\ntype IframeExecutionEnvironmentServiceArgs = {\n iframeUrl: URL;\n} & ExecutionServiceArgs;\n\nexport class IframeExecutionService extends AbstractExecutionService<Window> {\n public iframeUrl: URL;\n\n constructor({\n iframeUrl,\n messenger,\n setupSnapProvider,\n ...args\n }: IframeExecutionEnvironmentServiceArgs) {\n super({\n ...args,\n messenger,\n setupSnapProvider,\n });\n this.iframeUrl = iframeUrl;\n }\n\n protected terminateJob(jobWrapper: TerminateJobArgs<Window>): void {\n document.getElementById(jobWrapper.id)?.remove();\n }\n\n protected async initEnvStream(jobId: string): Promise<{\n worker: Window;\n stream: BasePostMessageStream;\n }> {\n const iframeWindow = await createWindow({\n uri: this.iframeUrl.toString(),\n id: jobId,\n });\n\n const stream = new WindowPostMessageStream({\n name: 'parent',\n target: 'child',\n targetWindow: iframeWindow,\n targetOrigin: '*',\n });\n\n return { worker: iframeWindow, stream };\n }\n}\n"]}
@@ -6,7 +6,7 @@ type IframeExecutionEnvironmentServiceArgs = {
6
6
  } & ExecutionServiceArgs;
7
7
  export declare class IframeExecutionService extends AbstractExecutionService<Window> {
8
8
  iframeUrl: URL;
9
- constructor({ iframeUrl, messenger, setupSnapProvider, }: IframeExecutionEnvironmentServiceArgs);
9
+ constructor({ iframeUrl, messenger, setupSnapProvider, ...args }: IframeExecutionEnvironmentServiceArgs);
10
10
  protected terminateJob(jobWrapper: TerminateJobArgs<Window>): void;
11
11
  protected initEnvStream(jobId: string): Promise<{
12
12
  worker: Window;
@@ -1 +1 @@
1
- {"version":3,"file":"IframeExecutionService.d.cts","sourceRoot":"","sources":["../../../src/services/iframe/IframeExecutionService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,sCAAsC;AAI3E,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EACjB,wCAAoC;AACrC,OAAO,EAAE,wBAAwB,EAAE,wCAAoC;AAEvE,KAAK,qCAAqC,GAAG;IAC3C,SAAS,EAAE,GAAG,CAAC;CAChB,GAAG,oBAAoB,CAAC;AAEzB,qBAAa,sBAAuB,SAAQ,wBAAwB,CAAC,MAAM,CAAC;IACnE,SAAS,EAAE,GAAG,CAAC;gBAEV,EACV,SAAS,EACT,SAAS,EACT,iBAAiB,GAClB,EAAE,qCAAqC;IAQxC,SAAS,CAAC,YAAY,CAAC,UAAU,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,IAAI;cAIlD,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QACpD,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,qBAAqB,CAAC;KAC/B,CAAC;CAeH"}
1
+ {"version":3,"file":"IframeExecutionService.d.cts","sourceRoot":"","sources":["../../../src/services/iframe/IframeExecutionService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,sCAAsC;AAI3E,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EACjB,wCAAoC;AACrC,OAAO,EAAE,wBAAwB,EAAE,wCAAoC;AAEvE,KAAK,qCAAqC,GAAG;IAC3C,SAAS,EAAE,GAAG,CAAC;CAChB,GAAG,oBAAoB,CAAC;AAEzB,qBAAa,sBAAuB,SAAQ,wBAAwB,CAAC,MAAM,CAAC;IACnE,SAAS,EAAE,GAAG,CAAC;gBAEV,EACV,SAAS,EACT,SAAS,EACT,iBAAiB,EACjB,GAAG,IAAI,EACR,EAAE,qCAAqC;IASxC,SAAS,CAAC,YAAY,CAAC,UAAU,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,IAAI;cAIlD,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QACpD,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,qBAAqB,CAAC;KAC/B,CAAC;CAeH"}
@@ -6,7 +6,7 @@ type IframeExecutionEnvironmentServiceArgs = {
6
6
  } & ExecutionServiceArgs;
7
7
  export declare class IframeExecutionService extends AbstractExecutionService<Window> {
8
8
  iframeUrl: URL;
9
- constructor({ iframeUrl, messenger, setupSnapProvider, }: IframeExecutionEnvironmentServiceArgs);
9
+ constructor({ iframeUrl, messenger, setupSnapProvider, ...args }: IframeExecutionEnvironmentServiceArgs);
10
10
  protected terminateJob(jobWrapper: TerminateJobArgs<Window>): void;
11
11
  protected initEnvStream(jobId: string): Promise<{
12
12
  worker: Window;
@@ -1 +1 @@
1
- {"version":3,"file":"IframeExecutionService.d.mts","sourceRoot":"","sources":["../../../src/services/iframe/IframeExecutionService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,sCAAsC;AAI3E,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EACjB,wCAAoC;AACrC,OAAO,EAAE,wBAAwB,EAAE,wCAAoC;AAEvE,KAAK,qCAAqC,GAAG;IAC3C,SAAS,EAAE,GAAG,CAAC;CAChB,GAAG,oBAAoB,CAAC;AAEzB,qBAAa,sBAAuB,SAAQ,wBAAwB,CAAC,MAAM,CAAC;IACnE,SAAS,EAAE,GAAG,CAAC;gBAEV,EACV,SAAS,EACT,SAAS,EACT,iBAAiB,GAClB,EAAE,qCAAqC;IAQxC,SAAS,CAAC,YAAY,CAAC,UAAU,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,IAAI;cAIlD,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QACpD,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,qBAAqB,CAAC;KAC/B,CAAC;CAeH"}
1
+ {"version":3,"file":"IframeExecutionService.d.mts","sourceRoot":"","sources":["../../../src/services/iframe/IframeExecutionService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,sCAAsC;AAI3E,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EACjB,wCAAoC;AACrC,OAAO,EAAE,wBAAwB,EAAE,wCAAoC;AAEvE,KAAK,qCAAqC,GAAG;IAC3C,SAAS,EAAE,GAAG,CAAC;CAChB,GAAG,oBAAoB,CAAC;AAEzB,qBAAa,sBAAuB,SAAQ,wBAAwB,CAAC,MAAM,CAAC;IACnE,SAAS,EAAE,GAAG,CAAC;gBAEV,EACV,SAAS,EACT,SAAS,EACT,iBAAiB,EACjB,GAAG,IAAI,EACR,EAAE,qCAAqC;IASxC,SAAS,CAAC,YAAY,CAAC,UAAU,EAAE,gBAAgB,CAAC,MAAM,CAAC,GAAG,IAAI;cAIlD,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;QACpD,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,EAAE,qBAAqB,CAAC;KAC/B,CAAC;CAeH"}
@@ -2,8 +2,9 @@ import { WindowPostMessageStream } from "@metamask/post-message-stream";
2
2
  import { createWindow } from "@metamask/snaps-utils";
3
3
  import { AbstractExecutionService } from "../AbstractExecutionService.mjs";
4
4
  export class IframeExecutionService extends AbstractExecutionService {
5
- constructor({ iframeUrl, messenger, setupSnapProvider, }) {
5
+ constructor({ iframeUrl, messenger, setupSnapProvider, ...args }) {
6
6
  super({
7
+ ...args,
7
8
  messenger,
8
9
  setupSnapProvider,
9
10
  });
@@ -1 +1 @@
1
- {"version":3,"file":"IframeExecutionService.mjs","sourceRoot":"","sources":["../../../src/services/iframe/IframeExecutionService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,sCAAsC;AACxE,OAAO,EAAE,YAAY,EAAE,8BAA8B;AAMrD,OAAO,EAAE,wBAAwB,EAAE,wCAAoC;AAMvE,MAAM,OAAO,sBAAuB,SAAQ,wBAAgC;IAG1E,YAAY,EACV,SAAS,EACT,SAAS,EACT,iBAAiB,GACqB;QACtC,KAAK,CAAC;YACJ,SAAS;YACT,iBAAiB;SAClB,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAES,YAAY,CAAC,UAAoC;QACzD,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IACnD,CAAC;IAES,KAAK,CAAC,aAAa,CAAC,KAAa;QAIzC,MAAM,YAAY,GAAG,MAAM,YAAY,CAAC;YACtC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE;YAC9B,EAAE,EAAE,KAAK;SACV,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,IAAI,uBAAuB,CAAC;YACzC,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,OAAO;YACf,YAAY,EAAE,YAAY;YAC1B,YAAY,EAAE,GAAG;SAClB,CAAC,CAAC;QAEH,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC;IAC1C,CAAC;CACF","sourcesContent":["import type { BasePostMessageStream } from '@metamask/post-message-stream';\nimport { WindowPostMessageStream } from '@metamask/post-message-stream';\nimport { createWindow } from '@metamask/snaps-utils';\n\nimport type {\n ExecutionServiceArgs,\n TerminateJobArgs,\n} from '../AbstractExecutionService';\nimport { AbstractExecutionService } from '../AbstractExecutionService';\n\ntype IframeExecutionEnvironmentServiceArgs = {\n iframeUrl: URL;\n} & ExecutionServiceArgs;\n\nexport class IframeExecutionService extends AbstractExecutionService<Window> {\n public iframeUrl: URL;\n\n constructor({\n iframeUrl,\n messenger,\n setupSnapProvider,\n }: IframeExecutionEnvironmentServiceArgs) {\n super({\n messenger,\n setupSnapProvider,\n });\n this.iframeUrl = iframeUrl;\n }\n\n protected terminateJob(jobWrapper: TerminateJobArgs<Window>): void {\n document.getElementById(jobWrapper.id)?.remove();\n }\n\n protected async initEnvStream(jobId: string): Promise<{\n worker: Window;\n stream: BasePostMessageStream;\n }> {\n const iframeWindow = await createWindow({\n uri: this.iframeUrl.toString(),\n id: jobId,\n });\n\n const stream = new WindowPostMessageStream({\n name: 'parent',\n target: 'child',\n targetWindow: iframeWindow,\n targetOrigin: '*',\n });\n\n return { worker: iframeWindow, stream };\n }\n}\n"]}
1
+ {"version":3,"file":"IframeExecutionService.mjs","sourceRoot":"","sources":["../../../src/services/iframe/IframeExecutionService.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,sCAAsC;AACxE,OAAO,EAAE,YAAY,EAAE,8BAA8B;AAMrD,OAAO,EAAE,wBAAwB,EAAE,wCAAoC;AAMvE,MAAM,OAAO,sBAAuB,SAAQ,wBAAgC;IAG1E,YAAY,EACV,SAAS,EACT,SAAS,EACT,iBAAiB,EACjB,GAAG,IAAI,EAC+B;QACtC,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,SAAS;YACT,iBAAiB;SAClB,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;IAES,YAAY,CAAC,UAAoC;QACzD,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC;IACnD,CAAC;IAES,KAAK,CAAC,aAAa,CAAC,KAAa;QAIzC,MAAM,YAAY,GAAG,MAAM,YAAY,CAAC;YACtC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE;YAC9B,EAAE,EAAE,KAAK;SACV,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,IAAI,uBAAuB,CAAC;YACzC,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,OAAO;YACf,YAAY,EAAE,YAAY;YAC1B,YAAY,EAAE,GAAG;SAClB,CAAC,CAAC;QAEH,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC;IAC1C,CAAC;CACF","sourcesContent":["import type { BasePostMessageStream } from '@metamask/post-message-stream';\nimport { WindowPostMessageStream } from '@metamask/post-message-stream';\nimport { createWindow } from '@metamask/snaps-utils';\n\nimport type {\n ExecutionServiceArgs,\n TerminateJobArgs,\n} from '../AbstractExecutionService';\nimport { AbstractExecutionService } from '../AbstractExecutionService';\n\ntype IframeExecutionEnvironmentServiceArgs = {\n iframeUrl: URL;\n} & ExecutionServiceArgs;\n\nexport class IframeExecutionService extends AbstractExecutionService<Window> {\n public iframeUrl: URL;\n\n constructor({\n iframeUrl,\n messenger,\n setupSnapProvider,\n ...args\n }: IframeExecutionEnvironmentServiceArgs) {\n super({\n ...args,\n messenger,\n setupSnapProvider,\n });\n this.iframeUrl = iframeUrl;\n }\n\n protected terminateJob(jobWrapper: TerminateJobArgs<Window>): void {\n document.getElementById(jobWrapper.id)?.remove();\n }\n\n protected async initEnvStream(jobId: string): Promise<{\n worker: Window;\n stream: BasePostMessageStream;\n }> {\n const iframeWindow = await createWindow({\n uri: this.iframeUrl.toString(),\n id: jobId,\n });\n\n const stream = new WindowPostMessageStream({\n name: 'parent',\n target: 'child',\n targetWindow: iframeWindow,\n targetOrigin: '*',\n });\n\n return { worker: iframeWindow, stream };\n }\n}\n"]}
@@ -27,8 +27,9 @@ class OffscreenExecutionService extends ProxyExecutionService_1.ProxyExecutionSe
27
27
  * @param args.offscreenPromise - A promise that resolves when the offscreen
28
28
  * environment is ready.
29
29
  */
30
- constructor({ messenger, setupSnapProvider, offscreenPromise, }) {
30
+ constructor({ messenger, setupSnapProvider, offscreenPromise, ...args }) {
31
31
  super({
32
+ ...args,
32
33
  messenger,
33
34
  setupSnapProvider,
34
35
  stream: new post_message_stream_1.BrowserRuntimePostMessageStream({
@@ -1 +1 @@
1
- {"version":3,"file":"OffscreenExecutionService.cjs","sourceRoot":"","sources":["../../../src/services/offscreen/OffscreenExecutionService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uEAAgF;AAGhF,8EAAuE;AAMvE,MAAa,yBAA0B,SAAQ,6CAAqB;IAGlE;;;;;;;;;;OAUG;IACH,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,gBAAgB,GACyB;QACzC,KAAK,CAAC;YACJ,SAAS;YACT,iBAAiB;YACjB,MAAM,EAAE,IAAI,qDAA+B,CAAC;gBAC1C,IAAI,EAAE,QAAQ;gBACd,MAAM,EAAE,OAAO;aAChB,CAAC;SACH,CAAC,CAAC;QAzBI,8DAAoC;QA2B3C,uBAAA,IAAI,+CAAqB,gBAAgB,MAAA,CAAC;IAC5C,CAAC;IAED;;;;;;OAMG;IACO,KAAK,CAAC,aAAa,CAAC,KAAa;QACzC,MAAM,uBAAA,IAAI,mDAAkB,CAAC;QAE7B,OAAO,MAAM,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;CACF;AA3CD,8DA2CC","sourcesContent":["import { BrowserRuntimePostMessageStream } from '@metamask/post-message-stream';\n\nimport type { ExecutionServiceArgs } from '../AbstractExecutionService';\nimport { ProxyExecutionService } from '../proxy/ProxyExecutionService';\n\ntype OffscreenExecutionEnvironmentServiceArgs = {\n offscreenPromise: Promise<unknown>;\n} & ExecutionServiceArgs;\n\nexport class OffscreenExecutionService extends ProxyExecutionService {\n readonly #offscreenPromise: Promise<unknown>;\n\n /**\n * Create a new offscreen execution service.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger to use for communication with the\n * `SnapController`.\n * @param args.setupSnapProvider - The function to use to set up the snap\n * provider.\n * @param args.offscreenPromise - A promise that resolves when the offscreen\n * environment is ready.\n */\n constructor({\n messenger,\n setupSnapProvider,\n offscreenPromise,\n }: OffscreenExecutionEnvironmentServiceArgs) {\n super({\n messenger,\n setupSnapProvider,\n stream: new BrowserRuntimePostMessageStream({\n name: 'parent',\n target: 'child',\n }),\n });\n\n this.#offscreenPromise = offscreenPromise;\n }\n\n /**\n * Create a new stream for the given job ID. This will wait for the offscreen\n * environment to be ready before creating the stream.\n *\n * @param jobId - The job ID to create a stream for.\n * @returns The stream for the given job ID.\n */\n protected async initEnvStream(jobId: string) {\n await this.#offscreenPromise;\n\n return await super.initEnvStream(jobId);\n }\n}\n"]}
1
+ {"version":3,"file":"OffscreenExecutionService.cjs","sourceRoot":"","sources":["../../../src/services/offscreen/OffscreenExecutionService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uEAAgF;AAGhF,8EAAuE;AAMvE,MAAa,yBAA0B,SAAQ,6CAAqB;IAGlE;;;;;;;;;;OAUG;IACH,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,GAAG,IAAI,EACkC;QACzC,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,SAAS;YACT,iBAAiB;YACjB,MAAM,EAAE,IAAI,qDAA+B,CAAC;gBAC1C,IAAI,EAAE,QAAQ;gBACd,MAAM,EAAE,OAAO;aAChB,CAAC;SACH,CAAC,CAAC;QA3BI,8DAAoC;QA6B3C,uBAAA,IAAI,+CAAqB,gBAAgB,MAAA,CAAC;IAC5C,CAAC;IAED;;;;;;OAMG;IACO,KAAK,CAAC,aAAa,CAAC,KAAa;QACzC,MAAM,uBAAA,IAAI,mDAAkB,CAAC;QAE7B,OAAO,MAAM,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;CACF;AA7CD,8DA6CC","sourcesContent":["import { BrowserRuntimePostMessageStream } from '@metamask/post-message-stream';\n\nimport type { ExecutionServiceArgs } from '../AbstractExecutionService';\nimport { ProxyExecutionService } from '../proxy/ProxyExecutionService';\n\ntype OffscreenExecutionEnvironmentServiceArgs = {\n offscreenPromise: Promise<unknown>;\n} & ExecutionServiceArgs;\n\nexport class OffscreenExecutionService extends ProxyExecutionService {\n readonly #offscreenPromise: Promise<unknown>;\n\n /**\n * Create a new offscreen execution service.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger to use for communication with the\n * `SnapController`.\n * @param args.setupSnapProvider - The function to use to set up the snap\n * provider.\n * @param args.offscreenPromise - A promise that resolves when the offscreen\n * environment is ready.\n */\n constructor({\n messenger,\n setupSnapProvider,\n offscreenPromise,\n ...args\n }: OffscreenExecutionEnvironmentServiceArgs) {\n super({\n ...args,\n messenger,\n setupSnapProvider,\n stream: new BrowserRuntimePostMessageStream({\n name: 'parent',\n target: 'child',\n }),\n });\n\n this.#offscreenPromise = offscreenPromise;\n }\n\n /**\n * Create a new stream for the given job ID. This will wait for the offscreen\n * environment to be ready before creating the stream.\n *\n * @param jobId - The job ID to create a stream for.\n * @returns The stream for the given job ID.\n */\n protected async initEnvStream(jobId: string) {\n await this.#offscreenPromise;\n\n return await super.initEnvStream(jobId);\n }\n}\n"]}
@@ -16,7 +16,7 @@ export declare class OffscreenExecutionService extends ProxyExecutionService {
16
16
  * @param args.offscreenPromise - A promise that resolves when the offscreen
17
17
  * environment is ready.
18
18
  */
19
- constructor({ messenger, setupSnapProvider, offscreenPromise, }: OffscreenExecutionEnvironmentServiceArgs);
19
+ constructor({ messenger, setupSnapProvider, offscreenPromise, ...args }: OffscreenExecutionEnvironmentServiceArgs);
20
20
  /**
21
21
  * Create a new stream for the given job ID. This will wait for the offscreen
22
22
  * environment to be ready before creating the stream.
@@ -1 +1 @@
1
- {"version":3,"file":"OffscreenExecutionService.d.cts","sourceRoot":"","sources":["../../../src/services/offscreen/OffscreenExecutionService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,wCAAoC;AACxE,OAAO,EAAE,qBAAqB,EAAE,2CAAuC;AAEvE,KAAK,wCAAwC,GAAG;IAC9C,gBAAgB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;CACpC,GAAG,oBAAoB,CAAC;AAEzB,qBAAa,yBAA0B,SAAQ,qBAAqB;;IAGlE;;;;;;;;;;OAUG;gBACS,EACV,SAAS,EACT,iBAAiB,EACjB,gBAAgB,GACjB,EAAE,wCAAwC;IAa3C;;;;;;OAMG;cACa,aAAa,CAAC,KAAK,EAAE,MAAM;;;;CAK5C"}
1
+ {"version":3,"file":"OffscreenExecutionService.d.cts","sourceRoot":"","sources":["../../../src/services/offscreen/OffscreenExecutionService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,wCAAoC;AACxE,OAAO,EAAE,qBAAqB,EAAE,2CAAuC;AAEvE,KAAK,wCAAwC,GAAG;IAC9C,gBAAgB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;CACpC,GAAG,oBAAoB,CAAC;AAEzB,qBAAa,yBAA0B,SAAQ,qBAAqB;;IAGlE;;;;;;;;;;OAUG;gBACS,EACV,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,GAAG,IAAI,EACR,EAAE,wCAAwC;IAc3C;;;;;;OAMG;cACa,aAAa,CAAC,KAAK,EAAE,MAAM;;;;CAK5C"}
@@ -16,7 +16,7 @@ export declare class OffscreenExecutionService extends ProxyExecutionService {
16
16
  * @param args.offscreenPromise - A promise that resolves when the offscreen
17
17
  * environment is ready.
18
18
  */
19
- constructor({ messenger, setupSnapProvider, offscreenPromise, }: OffscreenExecutionEnvironmentServiceArgs);
19
+ constructor({ messenger, setupSnapProvider, offscreenPromise, ...args }: OffscreenExecutionEnvironmentServiceArgs);
20
20
  /**
21
21
  * Create a new stream for the given job ID. This will wait for the offscreen
22
22
  * environment to be ready before creating the stream.
@@ -1 +1 @@
1
- {"version":3,"file":"OffscreenExecutionService.d.mts","sourceRoot":"","sources":["../../../src/services/offscreen/OffscreenExecutionService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,wCAAoC;AACxE,OAAO,EAAE,qBAAqB,EAAE,2CAAuC;AAEvE,KAAK,wCAAwC,GAAG;IAC9C,gBAAgB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;CACpC,GAAG,oBAAoB,CAAC;AAEzB,qBAAa,yBAA0B,SAAQ,qBAAqB;;IAGlE;;;;;;;;;;OAUG;gBACS,EACV,SAAS,EACT,iBAAiB,EACjB,gBAAgB,GACjB,EAAE,wCAAwC;IAa3C;;;;;;OAMG;cACa,aAAa,CAAC,KAAK,EAAE,MAAM;;;;CAK5C"}
1
+ {"version":3,"file":"OffscreenExecutionService.d.mts","sourceRoot":"","sources":["../../../src/services/offscreen/OffscreenExecutionService.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,wCAAoC;AACxE,OAAO,EAAE,qBAAqB,EAAE,2CAAuC;AAEvE,KAAK,wCAAwC,GAAG;IAC9C,gBAAgB,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;CACpC,GAAG,oBAAoB,CAAC;AAEzB,qBAAa,yBAA0B,SAAQ,qBAAqB;;IAGlE;;;;;;;;;;OAUG;gBACS,EACV,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,GAAG,IAAI,EACR,EAAE,wCAAwC;IAc3C;;;;;;OAMG;cACa,aAAa,CAAC,KAAK,EAAE,MAAM;;;;CAK5C"}
@@ -24,8 +24,9 @@ export class OffscreenExecutionService extends ProxyExecutionService {
24
24
  * @param args.offscreenPromise - A promise that resolves when the offscreen
25
25
  * environment is ready.
26
26
  */
27
- constructor({ messenger, setupSnapProvider, offscreenPromise, }) {
27
+ constructor({ messenger, setupSnapProvider, offscreenPromise, ...args }) {
28
28
  super({
29
+ ...args,
29
30
  messenger,
30
31
  setupSnapProvider,
31
32
  stream: new BrowserRuntimePostMessageStream({
@@ -1 +1 @@
1
- {"version":3,"file":"OffscreenExecutionService.mjs","sourceRoot":"","sources":["../../../src/services/offscreen/OffscreenExecutionService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,+BAA+B,EAAE,sCAAsC;AAGhF,OAAO,EAAE,qBAAqB,EAAE,2CAAuC;AAMvE,MAAM,OAAO,yBAA0B,SAAQ,qBAAqB;IAGlE;;;;;;;;;;OAUG;IACH,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,gBAAgB,GACyB;QACzC,KAAK,CAAC;YACJ,SAAS;YACT,iBAAiB;YACjB,MAAM,EAAE,IAAI,+BAA+B,CAAC;gBAC1C,IAAI,EAAE,QAAQ;gBACd,MAAM,EAAE,OAAO;aAChB,CAAC;SACH,CAAC,CAAC;QAzBI,8DAAoC;QA2B3C,uBAAA,IAAI,+CAAqB,gBAAgB,MAAA,CAAC;IAC5C,CAAC;IAED;;;;;;OAMG;IACO,KAAK,CAAC,aAAa,CAAC,KAAa;QACzC,MAAM,uBAAA,IAAI,mDAAkB,CAAC;QAE7B,OAAO,MAAM,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["import { BrowserRuntimePostMessageStream } from '@metamask/post-message-stream';\n\nimport type { ExecutionServiceArgs } from '../AbstractExecutionService';\nimport { ProxyExecutionService } from '../proxy/ProxyExecutionService';\n\ntype OffscreenExecutionEnvironmentServiceArgs = {\n offscreenPromise: Promise<unknown>;\n} & ExecutionServiceArgs;\n\nexport class OffscreenExecutionService extends ProxyExecutionService {\n readonly #offscreenPromise: Promise<unknown>;\n\n /**\n * Create a new offscreen execution service.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger to use for communication with the\n * `SnapController`.\n * @param args.setupSnapProvider - The function to use to set up the snap\n * provider.\n * @param args.offscreenPromise - A promise that resolves when the offscreen\n * environment is ready.\n */\n constructor({\n messenger,\n setupSnapProvider,\n offscreenPromise,\n }: OffscreenExecutionEnvironmentServiceArgs) {\n super({\n messenger,\n setupSnapProvider,\n stream: new BrowserRuntimePostMessageStream({\n name: 'parent',\n target: 'child',\n }),\n });\n\n this.#offscreenPromise = offscreenPromise;\n }\n\n /**\n * Create a new stream for the given job ID. This will wait for the offscreen\n * environment to be ready before creating the stream.\n *\n * @param jobId - The job ID to create a stream for.\n * @returns The stream for the given job ID.\n */\n protected async initEnvStream(jobId: string) {\n await this.#offscreenPromise;\n\n return await super.initEnvStream(jobId);\n }\n}\n"]}
1
+ {"version":3,"file":"OffscreenExecutionService.mjs","sourceRoot":"","sources":["../../../src/services/offscreen/OffscreenExecutionService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,+BAA+B,EAAE,sCAAsC;AAGhF,OAAO,EAAE,qBAAqB,EAAE,2CAAuC;AAMvE,MAAM,OAAO,yBAA0B,SAAQ,qBAAqB;IAGlE;;;;;;;;;;OAUG;IACH,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,GAAG,IAAI,EACkC;QACzC,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,SAAS;YACT,iBAAiB;YACjB,MAAM,EAAE,IAAI,+BAA+B,CAAC;gBAC1C,IAAI,EAAE,QAAQ;gBACd,MAAM,EAAE,OAAO;aAChB,CAAC;SACH,CAAC,CAAC;QA3BI,8DAAoC;QA6B3C,uBAAA,IAAI,+CAAqB,gBAAgB,MAAA,CAAC;IAC5C,CAAC;IAED;;;;;;OAMG;IACO,KAAK,CAAC,aAAa,CAAC,KAAa;QACzC,MAAM,uBAAA,IAAI,mDAAkB,CAAC;QAE7B,OAAO,MAAM,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["import { BrowserRuntimePostMessageStream } from '@metamask/post-message-stream';\n\nimport type { ExecutionServiceArgs } from '../AbstractExecutionService';\nimport { ProxyExecutionService } from '../proxy/ProxyExecutionService';\n\ntype OffscreenExecutionEnvironmentServiceArgs = {\n offscreenPromise: Promise<unknown>;\n} & ExecutionServiceArgs;\n\nexport class OffscreenExecutionService extends ProxyExecutionService {\n readonly #offscreenPromise: Promise<unknown>;\n\n /**\n * Create a new offscreen execution service.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger to use for communication with the\n * `SnapController`.\n * @param args.setupSnapProvider - The function to use to set up the snap\n * provider.\n * @param args.offscreenPromise - A promise that resolves when the offscreen\n * environment is ready.\n */\n constructor({\n messenger,\n setupSnapProvider,\n offscreenPromise,\n ...args\n }: OffscreenExecutionEnvironmentServiceArgs) {\n super({\n ...args,\n messenger,\n setupSnapProvider,\n stream: new BrowserRuntimePostMessageStream({\n name: 'parent',\n target: 'child',\n }),\n });\n\n this.#offscreenPromise = offscreenPromise;\n }\n\n /**\n * Create a new stream for the given job ID. This will wait for the offscreen\n * environment to be ready before creating the stream.\n *\n * @param jobId - The job ID to create a stream for.\n * @returns The stream for the given job ID.\n */\n protected async initEnvStream(jobId: string) {\n await this.#offscreenPromise;\n\n return await super.initEnvStream(jobId);\n }\n}\n"]}
@@ -28,8 +28,9 @@ class ProxyExecutionService extends AbstractExecutionService_1.AbstractExecution
28
28
  * @param args.stream - The stream to use for communicating with the proxy
29
29
  * executor.
30
30
  */
31
- constructor({ stream, messenger, setupSnapProvider, }) {
31
+ constructor({ stream, messenger, setupSnapProvider, ...args }) {
32
32
  super({
33
+ ...args,
33
34
  messenger,
34
35
  setupSnapProvider,
35
36
  usePing: false,
@@ -1 +1 @@
1
- {"version":3,"file":"ProxyExecutionService.cjs","sourceRoot":"","sources":["../../../src/services/proxy/ProxyExecutionService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,mCAAgC;AAMhC,8EAAuE;AACvE,0EAAmE;AAMnE,MAAa,qBAAsB,SAAQ,mDAAgC;IAGzE;;;;;;;;;;OAUG;IACH,YAAY,EACV,MAAM,EACN,SAAS,EACT,iBAAiB,GACoB;QACrC,KAAK,CAAC;YACJ,SAAS;YACT,iBAAiB;YACjB,OAAO,EAAE,KAAK;SACf,CAAC,CAAC;QAtBI,gDAA+B;QAwBtC,uBAAA,IAAI,iCAAW,MAAM,MAAA,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,YAAY,CAAC,GAA6B;QACxD,0EAA0E;QAC1E,8CAA8C;QAC9C,uBAAA,IAAI,qCAAQ,CAAC,KAAK,CAAC;YACjB,KAAK,EAAE,GAAG,CAAC,EAAE;YACb,IAAI,EAAE;gBACJ,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,cAAc;gBACtB,EAAE,EAAE,IAAA,eAAM,GAAE;aACb;SACF,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACO,KAAK,CAAC,aAAa,CAAC,KAAa;QACzC,MAAM,MAAM,GAAG,IAAI,+CAAsB,CAAC;YACxC,MAAM,EAAE,uBAAA,IAAI,qCAAQ;YACpB,KAAK;SACN,CAAC,CAAC;QAEH,0DAA0D;QAC1D,iFAAiF;QACjF,2DAA2D;QAC3D,sFAAsF;QACtF,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5B,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAC7B,MAAM,CAAC,KAAK,CAAC;gBACX,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,IAAA,eAAM,GAAE,EAAE;aACvD,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IACnC,CAAC;CACF;AAzED,sDAyEC","sourcesContent":["import type { BasePostMessageStream } from '@metamask/post-message-stream';\nimport { nanoid } from 'nanoid';\n\nimport type {\n ExecutionServiceArgs,\n TerminateJobArgs,\n} from '../AbstractExecutionService';\nimport { AbstractExecutionService } from '../AbstractExecutionService';\nimport { ProxyPostMessageStream } from '../ProxyPostMessageStream';\n\ntype ProxyExecutionEnvironmentServiceArgs = {\n stream: BasePostMessageStream;\n} & ExecutionServiceArgs;\n\nexport class ProxyExecutionService extends AbstractExecutionService<string> {\n readonly #stream: BasePostMessageStream;\n\n /**\n * Create a new proxy execution service.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger to use for communication with the\n * `SnapController`.\n * @param args.setupSnapProvider - The function to use to set up the snap\n * provider.\n * @param args.stream - The stream to use for communicating with the proxy\n * executor.\n */\n constructor({\n stream,\n messenger,\n setupSnapProvider,\n }: ProxyExecutionEnvironmentServiceArgs) {\n super({\n messenger,\n setupSnapProvider,\n usePing: false,\n });\n\n this.#stream = stream;\n }\n\n /**\n * Send a termination command to the proxy stream.\n *\n * @param job - The job to terminate.\n */\n protected async terminateJob(job: TerminateJobArgs<string>) {\n // The `AbstractExecutionService` will have already closed the job stream,\n // so we write to the runtime stream directly.\n this.#stream.write({\n jobId: job.id,\n data: {\n jsonrpc: '2.0',\n method: 'terminateJob',\n id: nanoid(),\n },\n });\n }\n\n /**\n * Create a new stream for the specified job. This wraps the root stream\n * in a stream specific to the job.\n *\n * @param jobId - The job ID.\n * @returns An object with the worker ID and stream.\n */\n protected async initEnvStream(jobId: string) {\n const stream = new ProxyPostMessageStream({\n stream: this.#stream,\n jobId,\n });\n\n // Send a request and await any response before continuing\n // This simulates the behaviour of non-proxy environments by effectively awaiting\n // the load of the environment inside the proxy environment\n // This assumes the proxy environment is already loaded before this function is called\n await new Promise((resolve) => {\n stream.once('data', resolve);\n stream.write({\n name: 'command',\n data: { jsonrpc: '2.0', method: 'ping', id: nanoid() },\n });\n });\n\n return { worker: jobId, stream };\n }\n}\n"]}
1
+ {"version":3,"file":"ProxyExecutionService.cjs","sourceRoot":"","sources":["../../../src/services/proxy/ProxyExecutionService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,mCAAgC;AAMhC,8EAAuE;AACvE,0EAAmE;AAMnE,MAAa,qBAAsB,SAAQ,mDAAgC;IAGzE;;;;;;;;;;OAUG;IACH,YAAY,EACV,MAAM,EACN,SAAS,EACT,iBAAiB,EACjB,GAAG,IAAI,EAC8B;QACrC,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,SAAS;YACT,iBAAiB;YACjB,OAAO,EAAE,KAAK;SACf,CAAC,CAAC;QAxBI,gDAA+B;QA0BtC,uBAAA,IAAI,iCAAW,MAAM,MAAA,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,YAAY,CAAC,GAA6B;QACxD,0EAA0E;QAC1E,8CAA8C;QAC9C,uBAAA,IAAI,qCAAQ,CAAC,KAAK,CAAC;YACjB,KAAK,EAAE,GAAG,CAAC,EAAE;YACb,IAAI,EAAE;gBACJ,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,cAAc;gBACtB,EAAE,EAAE,IAAA,eAAM,GAAE;aACb;SACF,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACO,KAAK,CAAC,aAAa,CAAC,KAAa;QACzC,MAAM,MAAM,GAAG,IAAI,+CAAsB,CAAC;YACxC,MAAM,EAAE,uBAAA,IAAI,qCAAQ;YACpB,KAAK;SACN,CAAC,CAAC;QAEH,0DAA0D;QAC1D,iFAAiF;QACjF,2DAA2D;QAC3D,sFAAsF;QACtF,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5B,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAC7B,MAAM,CAAC,KAAK,CAAC;gBACX,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,IAAA,eAAM,GAAE,EAAE;aACvD,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IACnC,CAAC;CACF;AA3ED,sDA2EC","sourcesContent":["import type { BasePostMessageStream } from '@metamask/post-message-stream';\nimport { nanoid } from 'nanoid';\n\nimport type {\n ExecutionServiceArgs,\n TerminateJobArgs,\n} from '../AbstractExecutionService';\nimport { AbstractExecutionService } from '../AbstractExecutionService';\nimport { ProxyPostMessageStream } from '../ProxyPostMessageStream';\n\ntype ProxyExecutionEnvironmentServiceArgs = {\n stream: BasePostMessageStream;\n} & ExecutionServiceArgs;\n\nexport class ProxyExecutionService extends AbstractExecutionService<string> {\n readonly #stream: BasePostMessageStream;\n\n /**\n * Create a new proxy execution service.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger to use for communication with the\n * `SnapController`.\n * @param args.setupSnapProvider - The function to use to set up the snap\n * provider.\n * @param args.stream - The stream to use for communicating with the proxy\n * executor.\n */\n constructor({\n stream,\n messenger,\n setupSnapProvider,\n ...args\n }: ProxyExecutionEnvironmentServiceArgs) {\n super({\n ...args,\n messenger,\n setupSnapProvider,\n usePing: false,\n });\n\n this.#stream = stream;\n }\n\n /**\n * Send a termination command to the proxy stream.\n *\n * @param job - The job to terminate.\n */\n protected async terminateJob(job: TerminateJobArgs<string>) {\n // The `AbstractExecutionService` will have already closed the job stream,\n // so we write to the runtime stream directly.\n this.#stream.write({\n jobId: job.id,\n data: {\n jsonrpc: '2.0',\n method: 'terminateJob',\n id: nanoid(),\n },\n });\n }\n\n /**\n * Create a new stream for the specified job. This wraps the root stream\n * in a stream specific to the job.\n *\n * @param jobId - The job ID.\n * @returns An object with the worker ID and stream.\n */\n protected async initEnvStream(jobId: string) {\n const stream = new ProxyPostMessageStream({\n stream: this.#stream,\n jobId,\n });\n\n // Send a request and await any response before continuing\n // This simulates the behaviour of non-proxy environments by effectively awaiting\n // the load of the environment inside the proxy environment\n // This assumes the proxy environment is already loaded before this function is called\n await new Promise((resolve) => {\n stream.once('data', resolve);\n stream.write({\n name: 'command',\n data: { jsonrpc: '2.0', method: 'ping', id: nanoid() },\n });\n });\n\n return { worker: jobId, stream };\n }\n}\n"]}
@@ -18,7 +18,7 @@ export declare class ProxyExecutionService extends AbstractExecutionService<stri
18
18
  * @param args.stream - The stream to use for communicating with the proxy
19
19
  * executor.
20
20
  */
21
- constructor({ stream, messenger, setupSnapProvider, }: ProxyExecutionEnvironmentServiceArgs);
21
+ constructor({ stream, messenger, setupSnapProvider, ...args }: ProxyExecutionEnvironmentServiceArgs);
22
22
  /**
23
23
  * Send a termination command to the proxy stream.
24
24
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ProxyExecutionService.d.cts","sourceRoot":"","sources":["../../../src/services/proxy/ProxyExecutionService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,sCAAsC;AAG3E,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EACjB,wCAAoC;AACrC,OAAO,EAAE,wBAAwB,EAAE,wCAAoC;AACvE,OAAO,EAAE,sBAAsB,EAAE,sCAAkC;AAEnE,KAAK,oCAAoC,GAAG;IAC1C,MAAM,EAAE,qBAAqB,CAAC;CAC/B,GAAG,oBAAoB,CAAC;AAEzB,qBAAa,qBAAsB,SAAQ,wBAAwB,CAAC,MAAM,CAAC;;IAGzE;;;;;;;;;;OAUG;gBACS,EACV,MAAM,EACN,SAAS,EACT,iBAAiB,GAClB,EAAE,oCAAoC;IAUvC;;;;OAIG;cACa,YAAY,CAAC,GAAG,EAAE,gBAAgB,CAAC,MAAM,CAAC;IAa1D;;;;;;OAMG;cACa,aAAa,CAAC,KAAK,EAAE,MAAM;;;;CAoB5C"}
1
+ {"version":3,"file":"ProxyExecutionService.d.cts","sourceRoot":"","sources":["../../../src/services/proxy/ProxyExecutionService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,sCAAsC;AAG3E,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EACjB,wCAAoC;AACrC,OAAO,EAAE,wBAAwB,EAAE,wCAAoC;AACvE,OAAO,EAAE,sBAAsB,EAAE,sCAAkC;AAEnE,KAAK,oCAAoC,GAAG;IAC1C,MAAM,EAAE,qBAAqB,CAAC;CAC/B,GAAG,oBAAoB,CAAC;AAEzB,qBAAa,qBAAsB,SAAQ,wBAAwB,CAAC,MAAM,CAAC;;IAGzE;;;;;;;;;;OAUG;gBACS,EACV,MAAM,EACN,SAAS,EACT,iBAAiB,EACjB,GAAG,IAAI,EACR,EAAE,oCAAoC;IAWvC;;;;OAIG;cACa,YAAY,CAAC,GAAG,EAAE,gBAAgB,CAAC,MAAM,CAAC;IAa1D;;;;;;OAMG;cACa,aAAa,CAAC,KAAK,EAAE,MAAM;;;;CAoB5C"}
@@ -18,7 +18,7 @@ export declare class ProxyExecutionService extends AbstractExecutionService<stri
18
18
  * @param args.stream - The stream to use for communicating with the proxy
19
19
  * executor.
20
20
  */
21
- constructor({ stream, messenger, setupSnapProvider, }: ProxyExecutionEnvironmentServiceArgs);
21
+ constructor({ stream, messenger, setupSnapProvider, ...args }: ProxyExecutionEnvironmentServiceArgs);
22
22
  /**
23
23
  * Send a termination command to the proxy stream.
24
24
  *
@@ -1 +1 @@
1
- {"version":3,"file":"ProxyExecutionService.d.mts","sourceRoot":"","sources":["../../../src/services/proxy/ProxyExecutionService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,sCAAsC;AAG3E,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EACjB,wCAAoC;AACrC,OAAO,EAAE,wBAAwB,EAAE,wCAAoC;AACvE,OAAO,EAAE,sBAAsB,EAAE,sCAAkC;AAEnE,KAAK,oCAAoC,GAAG;IAC1C,MAAM,EAAE,qBAAqB,CAAC;CAC/B,GAAG,oBAAoB,CAAC;AAEzB,qBAAa,qBAAsB,SAAQ,wBAAwB,CAAC,MAAM,CAAC;;IAGzE;;;;;;;;;;OAUG;gBACS,EACV,MAAM,EACN,SAAS,EACT,iBAAiB,GAClB,EAAE,oCAAoC;IAUvC;;;;OAIG;cACa,YAAY,CAAC,GAAG,EAAE,gBAAgB,CAAC,MAAM,CAAC;IAa1D;;;;;;OAMG;cACa,aAAa,CAAC,KAAK,EAAE,MAAM;;;;CAoB5C"}
1
+ {"version":3,"file":"ProxyExecutionService.d.mts","sourceRoot":"","sources":["../../../src/services/proxy/ProxyExecutionService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,sCAAsC;AAG3E,OAAO,KAAK,EACV,oBAAoB,EACpB,gBAAgB,EACjB,wCAAoC;AACrC,OAAO,EAAE,wBAAwB,EAAE,wCAAoC;AACvE,OAAO,EAAE,sBAAsB,EAAE,sCAAkC;AAEnE,KAAK,oCAAoC,GAAG;IAC1C,MAAM,EAAE,qBAAqB,CAAC;CAC/B,GAAG,oBAAoB,CAAC;AAEzB,qBAAa,qBAAsB,SAAQ,wBAAwB,CAAC,MAAM,CAAC;;IAGzE;;;;;;;;;;OAUG;gBACS,EACV,MAAM,EACN,SAAS,EACT,iBAAiB,EACjB,GAAG,IAAI,EACR,EAAE,oCAAoC;IAWvC;;;;OAIG;cACa,YAAY,CAAC,GAAG,EAAE,gBAAgB,CAAC,MAAM,CAAC;IAa1D;;;;;;OAMG;cACa,aAAa,CAAC,KAAK,EAAE,MAAM;;;;CAoB5C"}
@@ -25,8 +25,9 @@ export class ProxyExecutionService extends AbstractExecutionService {
25
25
  * @param args.stream - The stream to use for communicating with the proxy
26
26
  * executor.
27
27
  */
28
- constructor({ stream, messenger, setupSnapProvider, }) {
28
+ constructor({ stream, messenger, setupSnapProvider, ...args }) {
29
29
  super({
30
+ ...args,
30
31
  messenger,
31
32
  setupSnapProvider,
32
33
  usePing: false,
@@ -1 +1 @@
1
- {"version":3,"file":"ProxyExecutionService.mjs","sourceRoot":"","sources":["../../../src/services/proxy/ProxyExecutionService.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,eAAe;AAMhC,OAAO,EAAE,wBAAwB,EAAE,wCAAoC;AACvE,OAAO,EAAE,sBAAsB,EAAE,sCAAkC;AAMnE,MAAM,OAAO,qBAAsB,SAAQ,wBAAgC;IAGzE;;;;;;;;;;OAUG;IACH,YAAY,EACV,MAAM,EACN,SAAS,EACT,iBAAiB,GACoB;QACrC,KAAK,CAAC;YACJ,SAAS;YACT,iBAAiB;YACjB,OAAO,EAAE,KAAK;SACf,CAAC,CAAC;QAtBI,gDAA+B;QAwBtC,uBAAA,IAAI,iCAAW,MAAM,MAAA,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,YAAY,CAAC,GAA6B;QACxD,0EAA0E;QAC1E,8CAA8C;QAC9C,uBAAA,IAAI,qCAAQ,CAAC,KAAK,CAAC;YACjB,KAAK,EAAE,GAAG,CAAC,EAAE;YACb,IAAI,EAAE;gBACJ,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,cAAc;gBACtB,EAAE,EAAE,MAAM,EAAE;aACb;SACF,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACO,KAAK,CAAC,aAAa,CAAC,KAAa;QACzC,MAAM,MAAM,GAAG,IAAI,sBAAsB,CAAC;YACxC,MAAM,EAAE,uBAAA,IAAI,qCAAQ;YACpB,KAAK;SACN,CAAC,CAAC;QAEH,0DAA0D;QAC1D,iFAAiF;QACjF,2DAA2D;QAC3D,sFAAsF;QACtF,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5B,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAC7B,MAAM,CAAC,KAAK,CAAC;gBACX,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE;aACvD,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IACnC,CAAC;CACF","sourcesContent":["import type { BasePostMessageStream } from '@metamask/post-message-stream';\nimport { nanoid } from 'nanoid';\n\nimport type {\n ExecutionServiceArgs,\n TerminateJobArgs,\n} from '../AbstractExecutionService';\nimport { AbstractExecutionService } from '../AbstractExecutionService';\nimport { ProxyPostMessageStream } from '../ProxyPostMessageStream';\n\ntype ProxyExecutionEnvironmentServiceArgs = {\n stream: BasePostMessageStream;\n} & ExecutionServiceArgs;\n\nexport class ProxyExecutionService extends AbstractExecutionService<string> {\n readonly #stream: BasePostMessageStream;\n\n /**\n * Create a new proxy execution service.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger to use for communication with the\n * `SnapController`.\n * @param args.setupSnapProvider - The function to use to set up the snap\n * provider.\n * @param args.stream - The stream to use for communicating with the proxy\n * executor.\n */\n constructor({\n stream,\n messenger,\n setupSnapProvider,\n }: ProxyExecutionEnvironmentServiceArgs) {\n super({\n messenger,\n setupSnapProvider,\n usePing: false,\n });\n\n this.#stream = stream;\n }\n\n /**\n * Send a termination command to the proxy stream.\n *\n * @param job - The job to terminate.\n */\n protected async terminateJob(job: TerminateJobArgs<string>) {\n // The `AbstractExecutionService` will have already closed the job stream,\n // so we write to the runtime stream directly.\n this.#stream.write({\n jobId: job.id,\n data: {\n jsonrpc: '2.0',\n method: 'terminateJob',\n id: nanoid(),\n },\n });\n }\n\n /**\n * Create a new stream for the specified job. This wraps the root stream\n * in a stream specific to the job.\n *\n * @param jobId - The job ID.\n * @returns An object with the worker ID and stream.\n */\n protected async initEnvStream(jobId: string) {\n const stream = new ProxyPostMessageStream({\n stream: this.#stream,\n jobId,\n });\n\n // Send a request and await any response before continuing\n // This simulates the behaviour of non-proxy environments by effectively awaiting\n // the load of the environment inside the proxy environment\n // This assumes the proxy environment is already loaded before this function is called\n await new Promise((resolve) => {\n stream.once('data', resolve);\n stream.write({\n name: 'command',\n data: { jsonrpc: '2.0', method: 'ping', id: nanoid() },\n });\n });\n\n return { worker: jobId, stream };\n }\n}\n"]}
1
+ {"version":3,"file":"ProxyExecutionService.mjs","sourceRoot":"","sources":["../../../src/services/proxy/ProxyExecutionService.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,MAAM,EAAE,eAAe;AAMhC,OAAO,EAAE,wBAAwB,EAAE,wCAAoC;AACvE,OAAO,EAAE,sBAAsB,EAAE,sCAAkC;AAMnE,MAAM,OAAO,qBAAsB,SAAQ,wBAAgC;IAGzE;;;;;;;;;;OAUG;IACH,YAAY,EACV,MAAM,EACN,SAAS,EACT,iBAAiB,EACjB,GAAG,IAAI,EAC8B;QACrC,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,SAAS;YACT,iBAAiB;YACjB,OAAO,EAAE,KAAK;SACf,CAAC,CAAC;QAxBI,gDAA+B;QA0BtC,uBAAA,IAAI,iCAAW,MAAM,MAAA,CAAC;IACxB,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,YAAY,CAAC,GAA6B;QACxD,0EAA0E;QAC1E,8CAA8C;QAC9C,uBAAA,IAAI,qCAAQ,CAAC,KAAK,CAAC;YACjB,KAAK,EAAE,GAAG,CAAC,EAAE;YACb,IAAI,EAAE;gBACJ,OAAO,EAAE,KAAK;gBACd,MAAM,EAAE,cAAc;gBACtB,EAAE,EAAE,MAAM,EAAE;aACb;SACF,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACO,KAAK,CAAC,aAAa,CAAC,KAAa;QACzC,MAAM,MAAM,GAAG,IAAI,sBAAsB,CAAC;YACxC,MAAM,EAAE,uBAAA,IAAI,qCAAQ;YACpB,KAAK;SACN,CAAC,CAAC;QAEH,0DAA0D;QAC1D,iFAAiF;QACjF,2DAA2D;QAC3D,sFAAsF;QACtF,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC5B,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YAC7B,MAAM,CAAC,KAAK,CAAC;gBACX,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE;aACvD,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IACnC,CAAC;CACF","sourcesContent":["import type { BasePostMessageStream } from '@metamask/post-message-stream';\nimport { nanoid } from 'nanoid';\n\nimport type {\n ExecutionServiceArgs,\n TerminateJobArgs,\n} from '../AbstractExecutionService';\nimport { AbstractExecutionService } from '../AbstractExecutionService';\nimport { ProxyPostMessageStream } from '../ProxyPostMessageStream';\n\ntype ProxyExecutionEnvironmentServiceArgs = {\n stream: BasePostMessageStream;\n} & ExecutionServiceArgs;\n\nexport class ProxyExecutionService extends AbstractExecutionService<string> {\n readonly #stream: BasePostMessageStream;\n\n /**\n * Create a new proxy execution service.\n *\n * @param args - The constructor arguments.\n * @param args.messenger - The messenger to use for communication with the\n * `SnapController`.\n * @param args.setupSnapProvider - The function to use to set up the snap\n * provider.\n * @param args.stream - The stream to use for communicating with the proxy\n * executor.\n */\n constructor({\n stream,\n messenger,\n setupSnapProvider,\n ...args\n }: ProxyExecutionEnvironmentServiceArgs) {\n super({\n ...args,\n messenger,\n setupSnapProvider,\n usePing: false,\n });\n\n this.#stream = stream;\n }\n\n /**\n * Send a termination command to the proxy stream.\n *\n * @param job - The job to terminate.\n */\n protected async terminateJob(job: TerminateJobArgs<string>) {\n // The `AbstractExecutionService` will have already closed the job stream,\n // so we write to the runtime stream directly.\n this.#stream.write({\n jobId: job.id,\n data: {\n jsonrpc: '2.0',\n method: 'terminateJob',\n id: nanoid(),\n },\n });\n }\n\n /**\n * Create a new stream for the specified job. This wraps the root stream\n * in a stream specific to the job.\n *\n * @param jobId - The job ID.\n * @returns An object with the worker ID and stream.\n */\n protected async initEnvStream(jobId: string) {\n const stream = new ProxyPostMessageStream({\n stream: this.#stream,\n jobId,\n });\n\n // Send a request and await any response before continuing\n // This simulates the behaviour of non-proxy environments by effectively awaiting\n // the load of the environment inside the proxy environment\n // This assumes the proxy environment is already loaded before this function is called\n await new Promise((resolve) => {\n stream.once('data', resolve);\n stream.write({\n name: 'command',\n data: { jsonrpc: '2.0', method: 'ping', id: nanoid() },\n });\n });\n\n return { worker: jobId, stream };\n }\n}\n"]}
@@ -10,25 +10,22 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
10
10
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
11
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
12
  };
13
- var _WebViewExecutionService_instances, _WebViewExecutionService_getWebView, _WebViewExecutionService_ensureWebViewLoaded;
13
+ var _WebViewExecutionService_createWebView, _WebViewExecutionService_removeWebView;
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.WebViewExecutionService = void 0;
16
- const ProxyExecutionService_1 = require("../proxy/ProxyExecutionService.cjs");
16
+ const AbstractExecutionService_1 = require("../AbstractExecutionService.cjs");
17
17
  const WebViewMessageStream_1 = require("./WebViewMessageStream.cjs");
18
- class WebViewExecutionService extends ProxyExecutionService_1.ProxyExecutionService {
19
- constructor({ messenger, setupSnapProvider, getWebView, }) {
18
+ class WebViewExecutionService extends AbstractExecutionService_1.AbstractExecutionService {
19
+ constructor({ messenger, setupSnapProvider, createWebView, removeWebView, ...args }) {
20
20
  super({
21
+ ...args,
21
22
  messenger,
22
23
  setupSnapProvider,
23
- stream: new WebViewMessageStream_1.WebViewMessageStream({
24
- name: 'parent',
25
- target: 'child',
26
- getWebView,
27
- }),
28
24
  });
29
- _WebViewExecutionService_instances.add(this);
30
- _WebViewExecutionService_getWebView.set(this, void 0);
31
- __classPrivateFieldSet(this, _WebViewExecutionService_getWebView, getWebView, "f");
25
+ _WebViewExecutionService_createWebView.set(this, void 0);
26
+ _WebViewExecutionService_removeWebView.set(this, void 0);
27
+ __classPrivateFieldSet(this, _WebViewExecutionService_createWebView, createWebView, "f");
28
+ __classPrivateFieldSet(this, _WebViewExecutionService_removeWebView, removeWebView, "f");
32
29
  }
33
30
  /**
34
31
  * Create a new stream for the specified job. This wraps the runtime stream
@@ -38,17 +35,18 @@ class WebViewExecutionService extends ProxyExecutionService_1.ProxyExecutionServ
38
35
  * @returns An object with the worker ID and stream.
39
36
  */
40
37
  async initEnvStream(jobId) {
41
- // Ensure that the WebView has been loaded before we proceed.
42
- await __classPrivateFieldGet(this, _WebViewExecutionService_instances, "m", _WebViewExecutionService_ensureWebViewLoaded).call(this);
43
- return super.initEnvStream(jobId);
38
+ const webView = await __classPrivateFieldGet(this, _WebViewExecutionService_createWebView, "f").call(this, jobId);
39
+ const stream = new WebViewMessageStream_1.WebViewMessageStream({
40
+ name: 'parent',
41
+ target: 'child',
42
+ webView,
43
+ });
44
+ return { worker: webView, stream };
45
+ }
46
+ terminateJob(jobWrapper) {
47
+ __classPrivateFieldGet(this, _WebViewExecutionService_removeWebView, "f").call(this, jobWrapper.id);
44
48
  }
45
49
  }
46
50
  exports.WebViewExecutionService = WebViewExecutionService;
47
- _WebViewExecutionService_getWebView = new WeakMap(), _WebViewExecutionService_instances = new WeakSet(), _WebViewExecutionService_ensureWebViewLoaded =
48
- /**
49
- * Ensure that the WebView has been loaded by awaiting the getWebView promise.
50
- */
51
- async function _WebViewExecutionService_ensureWebViewLoaded() {
52
- await __classPrivateFieldGet(this, _WebViewExecutionService_getWebView, "f").call(this);
53
- };
51
+ _WebViewExecutionService_createWebView = new WeakMap(), _WebViewExecutionService_removeWebView = new WeakMap();
54
52
  //# sourceMappingURL=WebViewExecutionService.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"WebViewExecutionService.cjs","sourceRoot":"","sources":["../../../src/services/webview/WebViewExecutionService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,8EAAuE;AAEvE,qEAA8D;AAM9D,MAAa,uBAAwB,SAAQ,6CAAqB;IAGhE,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,UAAU,GACkB;QAC5B,KAAK,CAAC;YACJ,SAAS;YACT,iBAAiB;YACjB,MAAM,EAAE,IAAI,2CAAoB,CAAC;gBAC/B,IAAI,EAAE,QAAQ;gBACd,MAAM,EAAE,OAAO;gBACf,UAAU;aACX,CAAC;SACH,CAAC,CAAC;;QAfL,sDAAY;QAgBV,uBAAA,IAAI,uCAAe,UAAU,MAAA,CAAC;IAChC,CAAC;IAED;;;;;;OAMG;IACO,KAAK,CAAC,aAAa,CAAC,KAAa;QACzC,6DAA6D;QAC7D,MAAM,uBAAA,IAAI,wFAAqB,MAAzB,IAAI,CAAuB,CAAC;QAElC,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;CAQF;AAxCD,0DAwCC;;AANC;;GAEG;AACH,KAAK;IACH,MAAM,uBAAA,IAAI,2CAAY,MAAhB,IAAI,CAAc,CAAC;AAC3B,CAAC","sourcesContent":["import type { ExecutionServiceArgs } from '../AbstractExecutionService';\nimport { ProxyExecutionService } from '../proxy/ProxyExecutionService';\nimport type { WebViewInterface } from './WebViewMessageStream';\nimport { WebViewMessageStream } from './WebViewMessageStream';\n\nexport type WebViewExecutionServiceArgs = ExecutionServiceArgs & {\n getWebView: () => Promise<WebViewInterface>;\n};\n\nexport class WebViewExecutionService extends ProxyExecutionService {\n #getWebView;\n\n constructor({\n messenger,\n setupSnapProvider,\n getWebView,\n }: WebViewExecutionServiceArgs) {\n super({\n messenger,\n setupSnapProvider,\n stream: new WebViewMessageStream({\n name: 'parent',\n target: 'child',\n getWebView,\n }),\n });\n this.#getWebView = getWebView;\n }\n\n /**\n * Create a new stream for the specified job. This wraps the runtime stream\n * in a stream specific to the job.\n *\n * @param jobId - The job ID.\n * @returns An object with the worker ID and stream.\n */\n protected async initEnvStream(jobId: string) {\n // Ensure that the WebView has been loaded before we proceed.\n await this.#ensureWebViewLoaded();\n\n return super.initEnvStream(jobId);\n }\n\n /**\n * Ensure that the WebView has been loaded by awaiting the getWebView promise.\n */\n async #ensureWebViewLoaded() {\n await this.#getWebView();\n }\n}\n"]}
1
+ {"version":3,"file":"WebViewExecutionService.cjs","sourceRoot":"","sources":["../../../src/services/webview/WebViewExecutionService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,8EAGqC;AAErC,qEAA8D;AAO9D,MAAa,uBAAwB,SAAQ,mDAA0C;IAKrF,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,GAAG,IAAI,EACqB;QAC5B,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,SAAS;YACT,iBAAiB;SAClB,CAAC,CAAC;QAfI,yDAAe;QAEf,yDAAe;QActB,uBAAA,IAAI,0CAAkB,aAAa,MAAA,CAAC;QACpC,uBAAA,IAAI,0CAAkB,aAAa,MAAA,CAAC;IACtC,CAAC;IAED;;;;;;OAMG;IACO,KAAK,CAAC,aAAa,CAAC,KAAa;QACzC,MAAM,OAAO,GAAG,MAAM,uBAAA,IAAI,8CAAe,MAAnB,IAAI,EAAgB,KAAK,CAAC,CAAC;QAEjD,MAAM,MAAM,GAAG,IAAI,2CAAoB,CAAC;YACtC,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,OAAO;YACf,OAAO;SACR,CAAC,CAAC;QAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IACrC,CAAC;IAES,YAAY,CAAC,UAA8C;QACnE,uBAAA,IAAI,8CAAe,MAAnB,IAAI,EAAgB,UAAU,CAAC,EAAE,CAAC,CAAC;IACrC,CAAC;CACF;AA3CD,0DA2CC","sourcesContent":["import type { TerminateJobArgs } from '../AbstractExecutionService';\nimport {\n AbstractExecutionService,\n type ExecutionServiceArgs,\n} from '../AbstractExecutionService';\nimport type { WebViewInterface } from './WebViewMessageStream';\nimport { WebViewMessageStream } from './WebViewMessageStream';\n\nexport type WebViewExecutionServiceArgs = ExecutionServiceArgs & {\n createWebView: (jobId: string) => Promise<WebViewInterface>;\n removeWebView: (jobId: string) => void;\n};\n\nexport class WebViewExecutionService extends AbstractExecutionService<WebViewInterface> {\n readonly #createWebView;\n\n readonly #removeWebView;\n\n constructor({\n messenger,\n setupSnapProvider,\n createWebView,\n removeWebView,\n ...args\n }: WebViewExecutionServiceArgs) {\n super({\n ...args,\n messenger,\n setupSnapProvider,\n });\n this.#createWebView = createWebView;\n this.#removeWebView = removeWebView;\n }\n\n /**\n * Create a new stream for the specified job. This wraps the runtime stream\n * in a stream specific to the job.\n *\n * @param jobId - The job ID.\n * @returns An object with the worker ID and stream.\n */\n protected async initEnvStream(jobId: string) {\n const webView = await this.#createWebView(jobId);\n\n const stream = new WebViewMessageStream({\n name: 'parent',\n target: 'child',\n webView,\n });\n\n return { worker: webView, stream };\n }\n\n protected terminateJob(jobWrapper: TerminateJobArgs<WebViewInterface>): void {\n this.#removeWebView(jobWrapper.id);\n }\n}\n"]}
@@ -1,12 +1,14 @@
1
- import type { ExecutionServiceArgs } from "../AbstractExecutionService.cjs";
2
- import { ProxyExecutionService } from "../proxy/ProxyExecutionService.cjs";
1
+ import type { TerminateJobArgs } from "../AbstractExecutionService.cjs";
2
+ import { AbstractExecutionService, type ExecutionServiceArgs } from "../AbstractExecutionService.cjs";
3
3
  import type { WebViewInterface } from "./WebViewMessageStream.cjs";
4
+ import { WebViewMessageStream } from "./WebViewMessageStream.cjs";
4
5
  export type WebViewExecutionServiceArgs = ExecutionServiceArgs & {
5
- getWebView: () => Promise<WebViewInterface>;
6
+ createWebView: (jobId: string) => Promise<WebViewInterface>;
7
+ removeWebView: (jobId: string) => void;
6
8
  };
7
- export declare class WebViewExecutionService extends ProxyExecutionService {
9
+ export declare class WebViewExecutionService extends AbstractExecutionService<WebViewInterface> {
8
10
  #private;
9
- constructor({ messenger, setupSnapProvider, getWebView, }: WebViewExecutionServiceArgs);
11
+ constructor({ messenger, setupSnapProvider, createWebView, removeWebView, ...args }: WebViewExecutionServiceArgs);
10
12
  /**
11
13
  * Create a new stream for the specified job. This wraps the runtime stream
12
14
  * in a stream specific to the job.
@@ -15,8 +17,9 @@ export declare class WebViewExecutionService extends ProxyExecutionService {
15
17
  * @returns An object with the worker ID and stream.
16
18
  */
17
19
  protected initEnvStream(jobId: string): Promise<{
18
- worker: string;
19
- stream: import("../index.cjs").ProxyPostMessageStream;
20
+ worker: WebViewInterface;
21
+ stream: WebViewMessageStream;
20
22
  }>;
23
+ protected terminateJob(jobWrapper: TerminateJobArgs<WebViewInterface>): void;
21
24
  }
22
25
  //# sourceMappingURL=WebViewExecutionService.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WebViewExecutionService.d.cts","sourceRoot":"","sources":["../../../src/services/webview/WebViewExecutionService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,wCAAoC;AACxE,OAAO,EAAE,qBAAqB,EAAE,2CAAuC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,mCAA+B;AAG/D,MAAM,MAAM,2BAA2B,GAAG,oBAAoB,GAAG;IAC/D,UAAU,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC7C,CAAC;AAEF,qBAAa,uBAAwB,SAAQ,qBAAqB;;gBAGpD,EACV,SAAS,EACT,iBAAiB,EACjB,UAAU,GACX,EAAE,2BAA2B;IAa9B;;;;;;OAMG;cACa,aAAa,CAAC,KAAK,EAAE,MAAM;;;;CAa5C"}
1
+ {"version":3,"file":"WebViewExecutionService.d.cts","sourceRoot":"","sources":["../../../src/services/webview/WebViewExecutionService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,wCAAoC;AACpE,OAAO,EACL,wBAAwB,EACxB,KAAK,oBAAoB,EAC1B,wCAAoC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,mCAA+B;AAC/D,OAAO,EAAE,oBAAoB,EAAE,mCAA+B;AAE9D,MAAM,MAAM,2BAA2B,GAAG,oBAAoB,GAAG;IAC/D,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC5D,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC,CAAC;AAEF,qBAAa,uBAAwB,SAAQ,wBAAwB,CAAC,gBAAgB,CAAC;;gBAKzE,EACV,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,GAAG,IAAI,EACR,EAAE,2BAA2B;IAU9B;;;;;;OAMG;cACa,aAAa,CAAC,KAAK,EAAE,MAAM;;;;IAY3C,SAAS,CAAC,YAAY,CAAC,UAAU,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,IAAI;CAG7E"}
@@ -1,12 +1,14 @@
1
- import type { ExecutionServiceArgs } from "../AbstractExecutionService.mjs";
2
- import { ProxyExecutionService } from "../proxy/ProxyExecutionService.mjs";
1
+ import type { TerminateJobArgs } from "../AbstractExecutionService.mjs";
2
+ import { AbstractExecutionService, type ExecutionServiceArgs } from "../AbstractExecutionService.mjs";
3
3
  import type { WebViewInterface } from "./WebViewMessageStream.mjs";
4
+ import { WebViewMessageStream } from "./WebViewMessageStream.mjs";
4
5
  export type WebViewExecutionServiceArgs = ExecutionServiceArgs & {
5
- getWebView: () => Promise<WebViewInterface>;
6
+ createWebView: (jobId: string) => Promise<WebViewInterface>;
7
+ removeWebView: (jobId: string) => void;
6
8
  };
7
- export declare class WebViewExecutionService extends ProxyExecutionService {
9
+ export declare class WebViewExecutionService extends AbstractExecutionService<WebViewInterface> {
8
10
  #private;
9
- constructor({ messenger, setupSnapProvider, getWebView, }: WebViewExecutionServiceArgs);
11
+ constructor({ messenger, setupSnapProvider, createWebView, removeWebView, ...args }: WebViewExecutionServiceArgs);
10
12
  /**
11
13
  * Create a new stream for the specified job. This wraps the runtime stream
12
14
  * in a stream specific to the job.
@@ -15,8 +17,9 @@ export declare class WebViewExecutionService extends ProxyExecutionService {
15
17
  * @returns An object with the worker ID and stream.
16
18
  */
17
19
  protected initEnvStream(jobId: string): Promise<{
18
- worker: string;
19
- stream: import("../index.mjs").ProxyPostMessageStream;
20
+ worker: WebViewInterface;
21
+ stream: WebViewMessageStream;
20
22
  }>;
23
+ protected terminateJob(jobWrapper: TerminateJobArgs<WebViewInterface>): void;
21
24
  }
22
25
  //# sourceMappingURL=WebViewExecutionService.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WebViewExecutionService.d.mts","sourceRoot":"","sources":["../../../src/services/webview/WebViewExecutionService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,wCAAoC;AACxE,OAAO,EAAE,qBAAqB,EAAE,2CAAuC;AACvE,OAAO,KAAK,EAAE,gBAAgB,EAAE,mCAA+B;AAG/D,MAAM,MAAM,2BAA2B,GAAG,oBAAoB,GAAG;IAC/D,UAAU,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC7C,CAAC;AAEF,qBAAa,uBAAwB,SAAQ,qBAAqB;;gBAGpD,EACV,SAAS,EACT,iBAAiB,EACjB,UAAU,GACX,EAAE,2BAA2B;IAa9B;;;;;;OAMG;cACa,aAAa,CAAC,KAAK,EAAE,MAAM;;;;CAa5C"}
1
+ {"version":3,"file":"WebViewExecutionService.d.mts","sourceRoot":"","sources":["../../../src/services/webview/WebViewExecutionService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,wCAAoC;AACpE,OAAO,EACL,wBAAwB,EACxB,KAAK,oBAAoB,EAC1B,wCAAoC;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,mCAA+B;AAC/D,OAAO,EAAE,oBAAoB,EAAE,mCAA+B;AAE9D,MAAM,MAAM,2BAA2B,GAAG,oBAAoB,GAAG;IAC/D,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,gBAAgB,CAAC,CAAC;IAC5D,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC,CAAC;AAEF,qBAAa,uBAAwB,SAAQ,wBAAwB,CAAC,gBAAgB,CAAC;;gBAKzE,EACV,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,GAAG,IAAI,EACR,EAAE,2BAA2B;IAU9B;;;;;;OAMG;cACa,aAAa,CAAC,KAAK,EAAE,MAAM;;;;IAY3C,SAAS,CAAC,YAAY,CAAC,UAAU,EAAE,gBAAgB,CAAC,gBAAgB,CAAC,GAAG,IAAI;CAG7E"}
@@ -9,23 +9,20 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _WebViewExecutionService_instances, _WebViewExecutionService_getWebView, _WebViewExecutionService_ensureWebViewLoaded;
13
- import { ProxyExecutionService } from "../proxy/ProxyExecutionService.mjs";
12
+ var _WebViewExecutionService_createWebView, _WebViewExecutionService_removeWebView;
13
+ import { AbstractExecutionService } from "../AbstractExecutionService.mjs";
14
14
  import { WebViewMessageStream } from "./WebViewMessageStream.mjs";
15
- export class WebViewExecutionService extends ProxyExecutionService {
16
- constructor({ messenger, setupSnapProvider, getWebView, }) {
15
+ export class WebViewExecutionService extends AbstractExecutionService {
16
+ constructor({ messenger, setupSnapProvider, createWebView, removeWebView, ...args }) {
17
17
  super({
18
+ ...args,
18
19
  messenger,
19
20
  setupSnapProvider,
20
- stream: new WebViewMessageStream({
21
- name: 'parent',
22
- target: 'child',
23
- getWebView,
24
- }),
25
21
  });
26
- _WebViewExecutionService_instances.add(this);
27
- _WebViewExecutionService_getWebView.set(this, void 0);
28
- __classPrivateFieldSet(this, _WebViewExecutionService_getWebView, getWebView, "f");
22
+ _WebViewExecutionService_createWebView.set(this, void 0);
23
+ _WebViewExecutionService_removeWebView.set(this, void 0);
24
+ __classPrivateFieldSet(this, _WebViewExecutionService_createWebView, createWebView, "f");
25
+ __classPrivateFieldSet(this, _WebViewExecutionService_removeWebView, removeWebView, "f");
29
26
  }
30
27
  /**
31
28
  * Create a new stream for the specified job. This wraps the runtime stream
@@ -35,16 +32,17 @@ export class WebViewExecutionService extends ProxyExecutionService {
35
32
  * @returns An object with the worker ID and stream.
36
33
  */
37
34
  async initEnvStream(jobId) {
38
- // Ensure that the WebView has been loaded before we proceed.
39
- await __classPrivateFieldGet(this, _WebViewExecutionService_instances, "m", _WebViewExecutionService_ensureWebViewLoaded).call(this);
40
- return super.initEnvStream(jobId);
35
+ const webView = await __classPrivateFieldGet(this, _WebViewExecutionService_createWebView, "f").call(this, jobId);
36
+ const stream = new WebViewMessageStream({
37
+ name: 'parent',
38
+ target: 'child',
39
+ webView,
40
+ });
41
+ return { worker: webView, stream };
42
+ }
43
+ terminateJob(jobWrapper) {
44
+ __classPrivateFieldGet(this, _WebViewExecutionService_removeWebView, "f").call(this, jobWrapper.id);
41
45
  }
42
46
  }
43
- _WebViewExecutionService_getWebView = new WeakMap(), _WebViewExecutionService_instances = new WeakSet(), _WebViewExecutionService_ensureWebViewLoaded =
44
- /**
45
- * Ensure that the WebView has been loaded by awaiting the getWebView promise.
46
- */
47
- async function _WebViewExecutionService_ensureWebViewLoaded() {
48
- await __classPrivateFieldGet(this, _WebViewExecutionService_getWebView, "f").call(this);
49
- };
47
+ _WebViewExecutionService_createWebView = new WeakMap(), _WebViewExecutionService_removeWebView = new WeakMap();
50
48
  //# sourceMappingURL=WebViewExecutionService.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"WebViewExecutionService.mjs","sourceRoot":"","sources":["../../../src/services/webview/WebViewExecutionService.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,qBAAqB,EAAE,2CAAuC;AAEvE,OAAO,EAAE,oBAAoB,EAAE,mCAA+B;AAM9D,MAAM,OAAO,uBAAwB,SAAQ,qBAAqB;IAGhE,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,UAAU,GACkB;QAC5B,KAAK,CAAC;YACJ,SAAS;YACT,iBAAiB;YACjB,MAAM,EAAE,IAAI,oBAAoB,CAAC;gBAC/B,IAAI,EAAE,QAAQ;gBACd,MAAM,EAAE,OAAO;gBACf,UAAU;aACX,CAAC;SACH,CAAC,CAAC;;QAfL,sDAAY;QAgBV,uBAAA,IAAI,uCAAe,UAAU,MAAA,CAAC;IAChC,CAAC;IAED;;;;;;OAMG;IACO,KAAK,CAAC,aAAa,CAAC,KAAa;QACzC,6DAA6D;QAC7D,MAAM,uBAAA,IAAI,wFAAqB,MAAzB,IAAI,CAAuB,CAAC;QAElC,OAAO,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IACpC,CAAC;CAQF;;AANC;;GAEG;AACH,KAAK;IACH,MAAM,uBAAA,IAAI,2CAAY,MAAhB,IAAI,CAAc,CAAC;AAC3B,CAAC","sourcesContent":["import type { ExecutionServiceArgs } from '../AbstractExecutionService';\nimport { ProxyExecutionService } from '../proxy/ProxyExecutionService';\nimport type { WebViewInterface } from './WebViewMessageStream';\nimport { WebViewMessageStream } from './WebViewMessageStream';\n\nexport type WebViewExecutionServiceArgs = ExecutionServiceArgs & {\n getWebView: () => Promise<WebViewInterface>;\n};\n\nexport class WebViewExecutionService extends ProxyExecutionService {\n #getWebView;\n\n constructor({\n messenger,\n setupSnapProvider,\n getWebView,\n }: WebViewExecutionServiceArgs) {\n super({\n messenger,\n setupSnapProvider,\n stream: new WebViewMessageStream({\n name: 'parent',\n target: 'child',\n getWebView,\n }),\n });\n this.#getWebView = getWebView;\n }\n\n /**\n * Create a new stream for the specified job. This wraps the runtime stream\n * in a stream specific to the job.\n *\n * @param jobId - The job ID.\n * @returns An object with the worker ID and stream.\n */\n protected async initEnvStream(jobId: string) {\n // Ensure that the WebView has been loaded before we proceed.\n await this.#ensureWebViewLoaded();\n\n return super.initEnvStream(jobId);\n }\n\n /**\n * Ensure that the WebView has been loaded by awaiting the getWebView promise.\n */\n async #ensureWebViewLoaded() {\n await this.#getWebView();\n }\n}\n"]}
1
+ {"version":3,"file":"WebViewExecutionService.mjs","sourceRoot":"","sources":["../../../src/services/webview/WebViewExecutionService.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EACL,wBAAwB,EAEzB,wCAAoC;AAErC,OAAO,EAAE,oBAAoB,EAAE,mCAA+B;AAO9D,MAAM,OAAO,uBAAwB,SAAQ,wBAA0C;IAKrF,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,GAAG,IAAI,EACqB;QAC5B,KAAK,CAAC;YACJ,GAAG,IAAI;YACP,SAAS;YACT,iBAAiB;SAClB,CAAC,CAAC;QAfI,yDAAe;QAEf,yDAAe;QActB,uBAAA,IAAI,0CAAkB,aAAa,MAAA,CAAC;QACpC,uBAAA,IAAI,0CAAkB,aAAa,MAAA,CAAC;IACtC,CAAC;IAED;;;;;;OAMG;IACO,KAAK,CAAC,aAAa,CAAC,KAAa;QACzC,MAAM,OAAO,GAAG,MAAM,uBAAA,IAAI,8CAAe,MAAnB,IAAI,EAAgB,KAAK,CAAC,CAAC;QAEjD,MAAM,MAAM,GAAG,IAAI,oBAAoB,CAAC;YACtC,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,OAAO;YACf,OAAO;SACR,CAAC,CAAC;QAEH,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IACrC,CAAC;IAES,YAAY,CAAC,UAA8C;QACnE,uBAAA,IAAI,8CAAe,MAAnB,IAAI,EAAgB,UAAU,CAAC,EAAE,CAAC,CAAC;IACrC,CAAC;CACF","sourcesContent":["import type { TerminateJobArgs } from '../AbstractExecutionService';\nimport {\n AbstractExecutionService,\n type ExecutionServiceArgs,\n} from '../AbstractExecutionService';\nimport type { WebViewInterface } from './WebViewMessageStream';\nimport { WebViewMessageStream } from './WebViewMessageStream';\n\nexport type WebViewExecutionServiceArgs = ExecutionServiceArgs & {\n createWebView: (jobId: string) => Promise<WebViewInterface>;\n removeWebView: (jobId: string) => void;\n};\n\nexport class WebViewExecutionService extends AbstractExecutionService<WebViewInterface> {\n readonly #createWebView;\n\n readonly #removeWebView;\n\n constructor({\n messenger,\n setupSnapProvider,\n createWebView,\n removeWebView,\n ...args\n }: WebViewExecutionServiceArgs) {\n super({\n ...args,\n messenger,\n setupSnapProvider,\n });\n this.#createWebView = createWebView;\n this.#removeWebView = removeWebView;\n }\n\n /**\n * Create a new stream for the specified job. This wraps the runtime stream\n * in a stream specific to the job.\n *\n * @param jobId - The job ID.\n * @returns An object with the worker ID and stream.\n */\n protected async initEnvStream(jobId: string) {\n const webView = await this.#createWebView(jobId);\n\n const stream = new WebViewMessageStream({\n name: 'parent',\n target: 'child',\n webView,\n });\n\n return { worker: webView, stream };\n }\n\n protected terminateJob(jobWrapper: TerminateJobArgs<WebViewInterface>): void {\n this.#removeWebView(jobWrapper.id);\n }\n}\n"]}
@@ -15,7 +15,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.WebViewMessageStream = void 0;
16
16
  const post_message_stream_1 = require("@metamask/post-message-stream");
17
17
  const utils_1 = require("@metamask/post-message-stream/dist/utils.js");
18
- const snaps_utils_1 = require("@metamask/snaps-utils");
19
18
  const utils_2 = require("@metamask/utils");
20
19
  /**
21
20
  * A special postMessage stream used to interface with a WebView.
@@ -28,9 +27,9 @@ class WebViewMessageStream extends post_message_stream_1.BasePostMessageStream {
28
27
  * @param args.name - The name of the stream. Used to differentiate between
29
28
  * multiple streams sharing the same window object.
30
29
  * @param args.target - The name of the stream to exchange messages with.
31
- * @param args.getWebView - A asynchronous getter for the webview.
30
+ * @param args.webView - A reference to the WebView.
32
31
  */
33
- constructor({ name, target, getWebView }) {
32
+ constructor({ name, target, webView }) {
34
33
  super();
35
34
  _WebViewMessageStream_name.set(this, void 0);
36
35
  _WebViewMessageStream_target.set(this, void 0);
@@ -38,19 +37,11 @@ class WebViewMessageStream extends post_message_stream_1.BasePostMessageStream {
38
37
  __classPrivateFieldSet(this, _WebViewMessageStream_name, name, "f");
39
38
  __classPrivateFieldSet(this, _WebViewMessageStream_target, target, "f");
40
39
  this._onMessage = this._onMessage.bind(this);
41
- // This is a bit atypical from other post-message streams.
42
- // We have to wait for the WebView to fully load before we can continue using the stream.
43
- getWebView()
44
- .then((webView) => {
45
- __classPrivateFieldSet(this, _WebViewMessageStream_webView, webView, "f");
46
- // This method is already bound.
47
- // eslint-disable-next-line @typescript-eslint/unbound-method
48
- webView.registerMessageListener(this._onMessage);
49
- this._handshake();
50
- })
51
- .catch((error) => {
52
- (0, snaps_utils_1.logError)(error);
53
- });
40
+ __classPrivateFieldSet(this, _WebViewMessageStream_webView, webView, "f");
41
+ // This method is already bound.
42
+ // eslint-disable-next-line @typescript-eslint/unbound-method
43
+ __classPrivateFieldGet(this, _WebViewMessageStream_webView, "f").registerMessageListener(this._onMessage);
44
+ this._handshake();
54
45
  }
55
46
  _postMessage(data) {
56
47
  (0, utils_2.assert)(__classPrivateFieldGet(this, _WebViewMessageStream_webView, "f"));
@@ -58,12 +49,10 @@ class WebViewMessageStream extends post_message_stream_1.BasePostMessageStream {
58
49
  target: __classPrivateFieldGet(this, _WebViewMessageStream_target, "f"),
59
50
  data,
60
51
  });
61
- // To prevent XSS, we base64 encode the message before injecting it.
62
- // This adds significant performance overhead.
63
- // TODO: Should we use mobile native base64 here?
64
- const bytes = (0, utils_2.stringToBytes)(json);
65
- const base64 = (0, utils_2.bytesToBase64)(bytes);
66
- __classPrivateFieldGet(this, _WebViewMessageStream_webView, "f").injectJavaScript(`window.postMessage('${base64}')`);
52
+ // To prevent XSS, we encode the message before injecting it.
53
+ // This adds significant performance overhead for larger messages.
54
+ const bytes = new Uint8Array((0, utils_2.stringToBytes)(json));
55
+ __classPrivateFieldGet(this, _WebViewMessageStream_webView, "f").injectJavaScript(`window.postMessage([${bytes.toString()}])`);
67
56
  }
68
57
  _onMessage(event) {
69
58
  if (typeof event.data !== 'string') {