@metamask/snaps-controllers 9.8.0 → 9.9.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 (78) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/dist/cronjob/CronjobController.cjs +21 -34
  3. package/dist/cronjob/CronjobController.cjs.map +1 -1
  4. package/dist/cronjob/CronjobController.mjs +21 -34
  5. package/dist/cronjob/CronjobController.mjs.map +1 -1
  6. package/dist/insights/SnapInsightsController.cjs +194 -144
  7. package/dist/insights/SnapInsightsController.cjs.map +1 -1
  8. package/dist/insights/SnapInsightsController.mjs +193 -143
  9. package/dist/insights/SnapInsightsController.mjs.map +1 -1
  10. package/dist/interface/SnapInterfaceController.cjs +90 -65
  11. package/dist/interface/SnapInterfaceController.cjs.map +1 -1
  12. package/dist/interface/SnapInterfaceController.d.cts +2 -1
  13. package/dist/interface/SnapInterfaceController.d.cts.map +1 -1
  14. package/dist/interface/SnapInterfaceController.d.mts +2 -1
  15. package/dist/interface/SnapInterfaceController.d.mts.map +1 -1
  16. package/dist/interface/SnapInterfaceController.mjs +90 -65
  17. package/dist/interface/SnapInterfaceController.mjs.map +1 -1
  18. package/dist/services/AbstractExecutionService.cjs +71 -77
  19. package/dist/services/AbstractExecutionService.cjs.map +1 -1
  20. package/dist/services/AbstractExecutionService.mjs +71 -77
  21. package/dist/services/AbstractExecutionService.mjs.map +1 -1
  22. package/dist/services/ProxyPostMessageStream.cjs +19 -26
  23. package/dist/services/ProxyPostMessageStream.cjs.map +1 -1
  24. package/dist/services/ProxyPostMessageStream.mjs +19 -26
  25. package/dist/services/ProxyPostMessageStream.mjs.map +1 -1
  26. package/dist/services/iframe/IframeExecutionService.cjs +1 -0
  27. package/dist/services/iframe/IframeExecutionService.cjs.map +1 -1
  28. package/dist/services/iframe/IframeExecutionService.mjs +1 -0
  29. package/dist/services/iframe/IframeExecutionService.mjs.map +1 -1
  30. package/dist/services/offscreen/OffscreenExecutionService.cjs +3 -16
  31. package/dist/services/offscreen/OffscreenExecutionService.cjs.map +1 -1
  32. package/dist/services/offscreen/OffscreenExecutionService.mjs +3 -16
  33. package/dist/services/offscreen/OffscreenExecutionService.mjs.map +1 -1
  34. package/dist/services/proxy/ProxyExecutionService.cjs +4 -17
  35. package/dist/services/proxy/ProxyExecutionService.cjs.map +1 -1
  36. package/dist/services/proxy/ProxyExecutionService.mjs +4 -17
  37. package/dist/services/proxy/ProxyExecutionService.mjs.map +1 -1
  38. package/dist/services/webview/WebViewExecutionService.cjs +9 -23
  39. package/dist/services/webview/WebViewExecutionService.cjs.map +1 -1
  40. package/dist/services/webview/WebViewExecutionService.mjs +9 -23
  41. package/dist/services/webview/WebViewExecutionService.mjs.map +1 -1
  42. package/dist/services/webview/WebViewMessageStream.cjs +12 -25
  43. package/dist/services/webview/WebViewMessageStream.cjs.map +1 -1
  44. package/dist/services/webview/WebViewMessageStream.mjs +12 -25
  45. package/dist/services/webview/WebViewMessageStream.mjs.map +1 -1
  46. package/dist/services/webworker/WebWorkerExecutionService.cjs +10 -23
  47. package/dist/services/webworker/WebWorkerExecutionService.cjs.map +1 -1
  48. package/dist/services/webworker/WebWorkerExecutionService.mjs +10 -23
  49. package/dist/services/webworker/WebWorkerExecutionService.mjs.map +1 -1
  50. package/dist/snaps/RequestQueue.cjs +2 -0
  51. package/dist/snaps/RequestQueue.cjs.map +1 -1
  52. package/dist/snaps/RequestQueue.mjs +2 -0
  53. package/dist/snaps/RequestQueue.mjs.map +1 -1
  54. package/dist/snaps/SnapController.cjs +1141 -1001
  55. package/dist/snaps/SnapController.cjs.map +1 -1
  56. package/dist/snaps/SnapController.mjs +1140 -1000
  57. package/dist/snaps/SnapController.mjs.map +1 -1
  58. package/dist/snaps/Timer.cjs +1 -0
  59. package/dist/snaps/Timer.cjs.map +1 -1
  60. package/dist/snaps/Timer.mjs +1 -0
  61. package/dist/snaps/Timer.mjs.map +1 -1
  62. package/dist/snaps/location/http.cjs +11 -7
  63. package/dist/snaps/location/http.cjs.map +1 -1
  64. package/dist/snaps/location/http.mjs +11 -7
  65. package/dist/snaps/location/http.mjs.map +1 -1
  66. package/dist/snaps/location/local.cjs +4 -17
  67. package/dist/snaps/location/local.cjs.map +1 -1
  68. package/dist/snaps/location/local.mjs +4 -17
  69. package/dist/snaps/location/local.mjs.map +1 -1
  70. package/dist/snaps/location/npm.cjs +25 -37
  71. package/dist/snaps/location/npm.cjs.map +1 -1
  72. package/dist/snaps/location/npm.mjs +25 -37
  73. package/dist/snaps/location/npm.mjs.map +1 -1
  74. package/dist/snaps/registry/json.cjs +172 -173
  75. package/dist/snaps/registry/json.cjs.map +1 -1
  76. package/dist/snaps/registry/json.mjs +171 -172
  77. package/dist/snaps/registry/json.mjs.map +1 -1
  78. package/package.json +5 -5
@@ -2,6 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RequestQueue = void 0;
4
4
  class RequestQueue {
5
+ maxQueueSize;
6
+ queueSizes;
5
7
  constructor(maxQueueSize) {
6
8
  this.maxQueueSize = maxQueueSize;
7
9
  this.queueSizes = new Map();
@@ -1 +1 @@
1
- {"version":3,"file":"RequestQueue.cjs","sourceRoot":"","sources":["../../src/snaps/RequestQueue.ts"],"names":[],"mappings":";;;AAAA,MAAa,YAAY;IAKvB,YAAY,YAAoB;QAC9B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,MAAc;QAC7B,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtD,IAAI,YAAY,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,MAAc;QAC7B,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtD,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CACb,qBAAqB,MAAM,0CAA0C,CACtE,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;IAChD,CAAC;IAED;;;;;OAKG;IACI,GAAG,CAAC,MAAc;QACvB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF;AA/CD,oCA+CC","sourcesContent":["export class RequestQueue {\n public readonly maxQueueSize: number;\n\n private readonly queueSizes: Map<string, number>;\n\n constructor(maxQueueSize: number) {\n this.maxQueueSize = maxQueueSize;\n this.queueSizes = new Map<string, number>();\n }\n\n /**\n * Increments the queue count for a particular origin.\n *\n * @param origin - A string identifying the origin.\n */\n public increment(origin: string) {\n const currentCount = this.queueSizes.get(origin) ?? 0;\n if (currentCount >= this.maxQueueSize) {\n throw new Error('Maximum number of requests reached. Try again later.');\n }\n this.queueSizes.set(origin, currentCount + 1);\n }\n\n /**\n * Decrements the queue count for a particular origin.\n *\n * @param origin - A string identifying the origin.\n */\n public decrement(origin: string) {\n const currentCount = this.queueSizes.get(origin) ?? 0;\n if (currentCount === 0) {\n throw new Error(\n `Cannot decrement, ${origin} does not have any outstanding requests.`,\n );\n }\n this.queueSizes.set(origin, currentCount - 1);\n }\n\n /**\n * Gets the queue count for a particular origin.\n *\n * @param origin - A string identifying the origin.\n * @returns The queue count for the origin.\n */\n public get(origin: string): number {\n return this.queueSizes.get(origin) ?? 0;\n }\n}\n"]}
1
+ {"version":3,"file":"RequestQueue.cjs","sourceRoot":"","sources":["../../src/snaps/RequestQueue.ts"],"names":[],"mappings":";;;AAAA,MAAa,YAAY;IACP,YAAY,CAAS;IAEpB,UAAU,CAAsB;IAEjD,YAAY,YAAoB;QAC9B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,MAAc;QAC7B,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtD,IAAI,YAAY,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,MAAc;QAC7B,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtD,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CACb,qBAAqB,MAAM,0CAA0C,CACtE,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;IAChD,CAAC;IAED;;;;;OAKG;IACI,GAAG,CAAC,MAAc;QACvB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF;AA/CD,oCA+CC","sourcesContent":["export class RequestQueue {\n public readonly maxQueueSize: number;\n\n private readonly queueSizes: Map<string, number>;\n\n constructor(maxQueueSize: number) {\n this.maxQueueSize = maxQueueSize;\n this.queueSizes = new Map<string, number>();\n }\n\n /**\n * Increments the queue count for a particular origin.\n *\n * @param origin - A string identifying the origin.\n */\n public increment(origin: string) {\n const currentCount = this.queueSizes.get(origin) ?? 0;\n if (currentCount >= this.maxQueueSize) {\n throw new Error('Maximum number of requests reached. Try again later.');\n }\n this.queueSizes.set(origin, currentCount + 1);\n }\n\n /**\n * Decrements the queue count for a particular origin.\n *\n * @param origin - A string identifying the origin.\n */\n public decrement(origin: string) {\n const currentCount = this.queueSizes.get(origin) ?? 0;\n if (currentCount === 0) {\n throw new Error(\n `Cannot decrement, ${origin} does not have any outstanding requests.`,\n );\n }\n this.queueSizes.set(origin, currentCount - 1);\n }\n\n /**\n * Gets the queue count for a particular origin.\n *\n * @param origin - A string identifying the origin.\n * @returns The queue count for the origin.\n */\n public get(origin: string): number {\n return this.queueSizes.get(origin) ?? 0;\n }\n}\n"]}
@@ -1,4 +1,6 @@
1
1
  export class RequestQueue {
2
+ maxQueueSize;
3
+ queueSizes;
2
4
  constructor(maxQueueSize) {
3
5
  this.maxQueueSize = maxQueueSize;
4
6
  this.queueSizes = new Map();
@@ -1 +1 @@
1
- {"version":3,"file":"RequestQueue.mjs","sourceRoot":"","sources":["../../src/snaps/RequestQueue.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,YAAY;IAKvB,YAAY,YAAoB;QAC9B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,MAAc;QAC7B,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtD,IAAI,YAAY,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,MAAc;QAC7B,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtD,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CACb,qBAAqB,MAAM,0CAA0C,CACtE,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;IAChD,CAAC;IAED;;;;;OAKG;IACI,GAAG,CAAC,MAAc;QACvB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["export class RequestQueue {\n public readonly maxQueueSize: number;\n\n private readonly queueSizes: Map<string, number>;\n\n constructor(maxQueueSize: number) {\n this.maxQueueSize = maxQueueSize;\n this.queueSizes = new Map<string, number>();\n }\n\n /**\n * Increments the queue count for a particular origin.\n *\n * @param origin - A string identifying the origin.\n */\n public increment(origin: string) {\n const currentCount = this.queueSizes.get(origin) ?? 0;\n if (currentCount >= this.maxQueueSize) {\n throw new Error('Maximum number of requests reached. Try again later.');\n }\n this.queueSizes.set(origin, currentCount + 1);\n }\n\n /**\n * Decrements the queue count for a particular origin.\n *\n * @param origin - A string identifying the origin.\n */\n public decrement(origin: string) {\n const currentCount = this.queueSizes.get(origin) ?? 0;\n if (currentCount === 0) {\n throw new Error(\n `Cannot decrement, ${origin} does not have any outstanding requests.`,\n );\n }\n this.queueSizes.set(origin, currentCount - 1);\n }\n\n /**\n * Gets the queue count for a particular origin.\n *\n * @param origin - A string identifying the origin.\n * @returns The queue count for the origin.\n */\n public get(origin: string): number {\n return this.queueSizes.get(origin) ?? 0;\n }\n}\n"]}
1
+ {"version":3,"file":"RequestQueue.mjs","sourceRoot":"","sources":["../../src/snaps/RequestQueue.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,YAAY;IACP,YAAY,CAAS;IAEpB,UAAU,CAAsB;IAEjD,YAAY,YAAoB;QAC9B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC9C,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,MAAc;QAC7B,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtD,IAAI,YAAY,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;QAC1E,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;IAChD,CAAC;IAED;;;;OAIG;IACI,SAAS,CAAC,MAAc;QAC7B,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtD,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CACb,qBAAqB,MAAM,0CAA0C,CACtE,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,GAAG,CAAC,CAAC,CAAC;IAChD,CAAC;IAED;;;;;OAKG;IACI,GAAG,CAAC,MAAc;QACvB,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["export class RequestQueue {\n public readonly maxQueueSize: number;\n\n private readonly queueSizes: Map<string, number>;\n\n constructor(maxQueueSize: number) {\n this.maxQueueSize = maxQueueSize;\n this.queueSizes = new Map<string, number>();\n }\n\n /**\n * Increments the queue count for a particular origin.\n *\n * @param origin - A string identifying the origin.\n */\n public increment(origin: string) {\n const currentCount = this.queueSizes.get(origin) ?? 0;\n if (currentCount >= this.maxQueueSize) {\n throw new Error('Maximum number of requests reached. Try again later.');\n }\n this.queueSizes.set(origin, currentCount + 1);\n }\n\n /**\n * Decrements the queue count for a particular origin.\n *\n * @param origin - A string identifying the origin.\n */\n public decrement(origin: string) {\n const currentCount = this.queueSizes.get(origin) ?? 0;\n if (currentCount === 0) {\n throw new Error(\n `Cannot decrement, ${origin} does not have any outstanding requests.`,\n );\n }\n this.queueSizes.set(origin, currentCount - 1);\n }\n\n /**\n * Gets the queue count for a particular origin.\n *\n * @param origin - A string identifying the origin.\n * @returns The queue count for the origin.\n */\n public get(origin: string): number {\n return this.queueSizes.get(origin) ?? 0;\n }\n}\n"]}