@metamask-previews/json-rpc-engine 9.0.2-preview-367cb1da → 9.0.2-preview-cf09c0a

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 (108) hide show
  1. package/dist/JsonRpcEngine.cjs +355 -0
  2. package/dist/JsonRpcEngine.cjs.map +1 -0
  3. package/dist/{types/JsonRpcEngine.d.ts → JsonRpcEngine.d.cts} +3 -3
  4. package/dist/JsonRpcEngine.d.cts.map +1 -0
  5. package/dist/JsonRpcEngine.d.mts +114 -0
  6. package/dist/JsonRpcEngine.d.mts.map +1 -0
  7. package/dist/JsonRpcEngine.mjs +346 -6
  8. package/dist/JsonRpcEngine.mjs.map +1 -1
  9. package/dist/createAsyncMiddleware.cjs +70 -0
  10. package/dist/createAsyncMiddleware.cjs.map +1 -0
  11. package/dist/{types/createAsyncMiddleware.d.ts → createAsyncMiddleware.d.cts} +3 -3
  12. package/dist/createAsyncMiddleware.d.cts.map +1 -0
  13. package/dist/createAsyncMiddleware.d.mts +27 -0
  14. package/dist/createAsyncMiddleware.d.mts.map +1 -0
  15. package/dist/createAsyncMiddleware.mjs +65 -7
  16. package/dist/createAsyncMiddleware.mjs.map +1 -1
  17. package/dist/createScaffoldMiddleware.cjs +30 -0
  18. package/dist/createScaffoldMiddleware.cjs.map +1 -0
  19. package/dist/{types/createScaffoldMiddleware.d.ts → createScaffoldMiddleware.d.cts} +3 -3
  20. package/dist/createScaffoldMiddleware.d.cts.map +1 -0
  21. package/dist/createScaffoldMiddleware.d.mts +17 -0
  22. package/dist/createScaffoldMiddleware.d.mts.map +1 -0
  23. package/dist/createScaffoldMiddleware.mjs +25 -7
  24. package/dist/createScaffoldMiddleware.mjs.map +1 -1
  25. package/dist/getUniqueId.cjs +20 -0
  26. package/dist/getUniqueId.cjs.map +1 -0
  27. package/dist/{types/getUniqueId.d.ts → getUniqueId.d.cts} +1 -1
  28. package/dist/getUniqueId.d.cts.map +1 -0
  29. package/dist/getUniqueId.d.mts +9 -0
  30. package/dist/getUniqueId.d.mts.map +1 -0
  31. package/dist/getUniqueId.mjs +15 -7
  32. package/dist/getUniqueId.mjs.map +1 -1
  33. package/dist/idRemapMiddleware.cjs +28 -0
  34. package/dist/idRemapMiddleware.cjs.map +1 -0
  35. package/dist/{types/idRemapMiddleware.d.ts → idRemapMiddleware.d.cts} +3 -3
  36. package/dist/idRemapMiddleware.d.cts.map +1 -0
  37. package/dist/idRemapMiddleware.d.mts +13 -0
  38. package/dist/idRemapMiddleware.d.mts.map +1 -0
  39. package/dist/idRemapMiddleware.mjs +23 -8
  40. package/dist/idRemapMiddleware.mjs.map +1 -1
  41. package/dist/index.cjs +16 -0
  42. package/dist/index.cjs.map +1 -0
  43. package/dist/index.d.cts +9 -0
  44. package/dist/index.d.cts.map +1 -0
  45. package/dist/index.d.mts +9 -0
  46. package/dist/index.d.mts.map +1 -0
  47. package/dist/index.mjs +6 -27
  48. package/dist/index.mjs.map +1 -1
  49. package/dist/mergeMiddleware.cjs +17 -0
  50. package/dist/mergeMiddleware.cjs.map +1 -0
  51. package/dist/{types/mergeMiddleware.d.ts → mergeMiddleware.d.cts} +3 -3
  52. package/dist/mergeMiddleware.d.cts.map +1 -0
  53. package/dist/mergeMiddleware.d.mts +10 -0
  54. package/dist/mergeMiddleware.d.mts.map +1 -0
  55. package/dist/mergeMiddleware.mjs +12 -8
  56. package/dist/mergeMiddleware.mjs.map +1 -1
  57. package/package.json +12 -7
  58. package/dist/JsonRpcEngine.js +0 -8
  59. package/dist/JsonRpcEngine.js.map +0 -1
  60. package/dist/chunk-2LXAFMJD.js +0 -416
  61. package/dist/chunk-2LXAFMJD.js.map +0 -1
  62. package/dist/chunk-3AC2MIND.js +0 -19
  63. package/dist/chunk-3AC2MIND.js.map +0 -1
  64. package/dist/chunk-5HCYV4FV.mjs +0 -416
  65. package/dist/chunk-5HCYV4FV.mjs.map +0 -1
  66. package/dist/chunk-6XXPTZV6.mjs +0 -12
  67. package/dist/chunk-6XXPTZV6.mjs.map +0 -1
  68. package/dist/chunk-KFRJCTOQ.mjs +0 -15
  69. package/dist/chunk-KFRJCTOQ.mjs.map +0 -1
  70. package/dist/chunk-KNT3O2VO.mjs +0 -39
  71. package/dist/chunk-KNT3O2VO.mjs.map +0 -1
  72. package/dist/chunk-KZ5RA76F.mjs +0 -19
  73. package/dist/chunk-KZ5RA76F.mjs.map +0 -1
  74. package/dist/chunk-PBQXMZM5.js +0 -23
  75. package/dist/chunk-PBQXMZM5.js.map +0 -1
  76. package/dist/chunk-R7LKI5H5.mjs +0 -23
  77. package/dist/chunk-R7LKI5H5.mjs.map +0 -1
  78. package/dist/chunk-VK4MHWJV.js +0 -15
  79. package/dist/chunk-VK4MHWJV.js.map +0 -1
  80. package/dist/chunk-XDGWQHNY.js +0 -12
  81. package/dist/chunk-XDGWQHNY.js.map +0 -1
  82. package/dist/chunk-XUI43LEZ.mjs +0 -30
  83. package/dist/chunk-XUI43LEZ.mjs.map +0 -1
  84. package/dist/chunk-Z4BLTVTB.js +0 -30
  85. package/dist/chunk-Z4BLTVTB.js.map +0 -1
  86. package/dist/chunk-ZYXL5TCS.js +0 -39
  87. package/dist/chunk-ZYXL5TCS.js.map +0 -1
  88. package/dist/createAsyncMiddleware.js +0 -8
  89. package/dist/createAsyncMiddleware.js.map +0 -1
  90. package/dist/createScaffoldMiddleware.js +0 -8
  91. package/dist/createScaffoldMiddleware.js.map +0 -1
  92. package/dist/getUniqueId.js +0 -8
  93. package/dist/getUniqueId.js.map +0 -1
  94. package/dist/idRemapMiddleware.js +0 -9
  95. package/dist/idRemapMiddleware.js.map +0 -1
  96. package/dist/index.js +0 -28
  97. package/dist/index.js.map +0 -1
  98. package/dist/mergeMiddleware.js +0 -9
  99. package/dist/mergeMiddleware.js.map +0 -1
  100. package/dist/tsconfig.build.tsbuildinfo +0 -1
  101. package/dist/types/JsonRpcEngine.d.ts.map +0 -1
  102. package/dist/types/createAsyncMiddleware.d.ts.map +0 -1
  103. package/dist/types/createScaffoldMiddleware.d.ts.map +0 -1
  104. package/dist/types/getUniqueId.d.ts.map +0 -1
  105. package/dist/types/idRemapMiddleware.d.ts.map +0 -1
  106. package/dist/types/index.d.ts +0 -9
  107. package/dist/types/index.d.ts.map +0 -1
  108. package/dist/types/mergeMiddleware.d.ts.map +0 -1
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createScaffoldMiddleware = void 0;
4
+ /**
5
+ * Creates a middleware function from an object of RPC method handler functions,
6
+ * keyed to particular method names. If a method corresponding to a key of this
7
+ * object is requested, this middleware will pass it to the corresponding
8
+ * handler and return the result.
9
+ *
10
+ * @param handlers - The RPC method handler functions.
11
+ * @returns The scaffold middleware function.
12
+ */
13
+ function createScaffoldMiddleware(handlers) {
14
+ return (req, res, next, end) => {
15
+ const handler = handlers[req.method];
16
+ // if no handler, return
17
+ if (handler === undefined) {
18
+ return next();
19
+ }
20
+ // if handler is fn, call as middleware
21
+ if (typeof handler === 'function') {
22
+ return handler(req, res, next, end);
23
+ }
24
+ // if handler is some other value, use as result
25
+ res.result = handler;
26
+ return end();
27
+ };
28
+ }
29
+ exports.createScaffoldMiddleware = createScaffoldMiddleware;
30
+ //# sourceMappingURL=createScaffoldMiddleware.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createScaffoldMiddleware.cjs","sourceRoot":"","sources":["../src/createScaffoldMiddleware.ts"],"names":[],"mappings":";;;AASA;;;;;;;;GAQG;AACH,SAAgB,wBAAwB,CAAC,QAExC;IACC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAC7B,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACrC,wBAAwB;QACxB,IAAI,OAAO,KAAK,SAAS,EAAE;YACzB,OAAO,IAAI,EAAE,CAAC;SACf;QAED,uCAAuC;QACvC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;YACjC,OAAO,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;SACrC;QACD,gDAAgD;QAC/C,GAA4B,CAAC,MAAM,GAAG,OAAO,CAAC;QAC/C,OAAO,GAAG,EAAE,CAAC;IACf,CAAC,CAAC;AACJ,CAAC;AAlBD,4DAkBC","sourcesContent":["import type { Json, JsonRpcParams, JsonRpcSuccess } from '@metamask/utils';\n\nimport type { JsonRpcMiddleware } from './JsonRpcEngine';\n\ntype ScaffoldMiddlewareHandler<\n Params extends JsonRpcParams,\n Result extends Json,\n> = JsonRpcMiddleware<Params, Result> | Json;\n\n/**\n * Creates a middleware function from an object of RPC method handler functions,\n * keyed to particular method names. If a method corresponding to a key of this\n * object is requested, this middleware will pass it to the corresponding\n * handler and return the result.\n *\n * @param handlers - The RPC method handler functions.\n * @returns The scaffold middleware function.\n */\nexport function createScaffoldMiddleware(handlers: {\n [methodName: string]: ScaffoldMiddlewareHandler<JsonRpcParams, Json>;\n}): JsonRpcMiddleware<JsonRpcParams, Json> {\n return (req, res, next, end) => {\n const handler = handlers[req.method];\n // if no handler, return\n if (handler === undefined) {\n return next();\n }\n\n // if handler is fn, call as middleware\n if (typeof handler === 'function') {\n return handler(req, res, next, end);\n }\n // if handler is some other value, use as result\n (res as JsonRpcSuccess<Json>).result = handler;\n return end();\n };\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { Json, JsonRpcParams } from '@metamask/utils';
2
- import type { JsonRpcMiddleware } from './JsonRpcEngine';
1
+ import type { Json, JsonRpcParams } from "@metamask/utils";
2
+ import type { JsonRpcMiddleware } from "./JsonRpcEngine.cjs";
3
3
  type ScaffoldMiddlewareHandler<Params extends JsonRpcParams, Result extends Json> = JsonRpcMiddleware<Params, Result> | Json;
4
4
  /**
5
5
  * Creates a middleware function from an object of RPC method handler functions,
@@ -14,4 +14,4 @@ export declare function createScaffoldMiddleware(handlers: {
14
14
  [methodName: string]: ScaffoldMiddlewareHandler<JsonRpcParams, Json>;
15
15
  }): JsonRpcMiddleware<JsonRpcParams, Json>;
16
16
  export {};
17
- //# sourceMappingURL=createScaffoldMiddleware.d.ts.map
17
+ //# sourceMappingURL=createScaffoldMiddleware.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createScaffoldMiddleware.d.cts","sourceRoot":"","sources":["../src/createScaffoldMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAkB,wBAAwB;AAE3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,4BAAwB;AAEzD,KAAK,yBAAyB,CAC5B,MAAM,SAAS,aAAa,EAC5B,MAAM,SAAS,IAAI,IACjB,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;AAE7C;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE;IACjD,CAAC,UAAU,EAAE,MAAM,GAAG,yBAAyB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;CACtE,GAAG,iBAAiB,CAAC,aAAa,EAAE,IAAI,CAAC,CAgBzC"}
@@ -0,0 +1,17 @@
1
+ import type { Json, JsonRpcParams } from "@metamask/utils";
2
+ import type { JsonRpcMiddleware } from "./JsonRpcEngine.mjs";
3
+ type ScaffoldMiddlewareHandler<Params extends JsonRpcParams, Result extends Json> = JsonRpcMiddleware<Params, Result> | Json;
4
+ /**
5
+ * Creates a middleware function from an object of RPC method handler functions,
6
+ * keyed to particular method names. If a method corresponding to a key of this
7
+ * object is requested, this middleware will pass it to the corresponding
8
+ * handler and return the result.
9
+ *
10
+ * @param handlers - The RPC method handler functions.
11
+ * @returns The scaffold middleware function.
12
+ */
13
+ export declare function createScaffoldMiddleware(handlers: {
14
+ [methodName: string]: ScaffoldMiddlewareHandler<JsonRpcParams, Json>;
15
+ }): JsonRpcMiddleware<JsonRpcParams, Json>;
16
+ export {};
17
+ //# sourceMappingURL=createScaffoldMiddleware.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"createScaffoldMiddleware.d.mts","sourceRoot":"","sources":["../src/createScaffoldMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAkB,wBAAwB;AAE3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,4BAAwB;AAEzD,KAAK,yBAAyB,CAC5B,MAAM,SAAS,aAAa,EAC5B,MAAM,SAAS,IAAI,IACjB,iBAAiB,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;AAE7C;;;;;;;;GAQG;AACH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE;IACjD,CAAC,UAAU,EAAE,MAAM,GAAG,yBAAyB,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;CACtE,GAAG,iBAAiB,CAAC,aAAa,EAAE,IAAI,CAAC,CAgBzC"}
@@ -1,8 +1,26 @@
1
- import {
2
- createScaffoldMiddleware
3
- } from "./chunk-KZ5RA76F.mjs";
4
- import "./chunk-XUI43LEZ.mjs";
5
- export {
6
- createScaffoldMiddleware
7
- };
1
+ /**
2
+ * Creates a middleware function from an object of RPC method handler functions,
3
+ * keyed to particular method names. If a method corresponding to a key of this
4
+ * object is requested, this middleware will pass it to the corresponding
5
+ * handler and return the result.
6
+ *
7
+ * @param handlers - The RPC method handler functions.
8
+ * @returns The scaffold middleware function.
9
+ */
10
+ export function createScaffoldMiddleware(handlers) {
11
+ return (req, res, next, end) => {
12
+ const handler = handlers[req.method];
13
+ // if no handler, return
14
+ if (handler === undefined) {
15
+ return next();
16
+ }
17
+ // if handler is fn, call as middleware
18
+ if (typeof handler === 'function') {
19
+ return handler(req, res, next, end);
20
+ }
21
+ // if handler is some other value, use as result
22
+ res.result = handler;
23
+ return end();
24
+ };
25
+ }
8
26
  //# sourceMappingURL=createScaffoldMiddleware.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"createScaffoldMiddleware.mjs","sourceRoot":"","sources":["../src/createScaffoldMiddleware.ts"],"names":[],"mappings":"AASA;;;;;;;;GAQG;AACH,MAAM,UAAU,wBAAwB,CAAC,QAExC;IACC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE;QAC7B,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACrC,wBAAwB;QACxB,IAAI,OAAO,KAAK,SAAS,EAAE;YACzB,OAAO,IAAI,EAAE,CAAC;SACf;QAED,uCAAuC;QACvC,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE;YACjC,OAAO,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;SACrC;QACD,gDAAgD;QAC/C,GAA4B,CAAC,MAAM,GAAG,OAAO,CAAC;QAC/C,OAAO,GAAG,EAAE,CAAC;IACf,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { Json, JsonRpcParams, JsonRpcSuccess } from '@metamask/utils';\n\nimport type { JsonRpcMiddleware } from './JsonRpcEngine';\n\ntype ScaffoldMiddlewareHandler<\n Params extends JsonRpcParams,\n Result extends Json,\n> = JsonRpcMiddleware<Params, Result> | Json;\n\n/**\n * Creates a middleware function from an object of RPC method handler functions,\n * keyed to particular method names. If a method corresponding to a key of this\n * object is requested, this middleware will pass it to the corresponding\n * handler and return the result.\n *\n * @param handlers - The RPC method handler functions.\n * @returns The scaffold middleware function.\n */\nexport function createScaffoldMiddleware(handlers: {\n [methodName: string]: ScaffoldMiddlewareHandler<JsonRpcParams, Json>;\n}): JsonRpcMiddleware<JsonRpcParams, Json> {\n return (req, res, next, end) => {\n const handler = handlers[req.method];\n // if no handler, return\n if (handler === undefined) {\n return next();\n }\n\n // if handler is fn, call as middleware\n if (typeof handler === 'function') {\n return handler(req, res, next, end);\n }\n // if handler is some other value, use as result\n (res as JsonRpcSuccess<Json>).result = handler;\n return end();\n };\n}\n"]}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getUniqueId = void 0;
4
+ // uint32 (two's complement) max
5
+ // more conservative than Number.MAX_SAFE_INTEGER
6
+ const MAX = 4294967295;
7
+ let idCounter = Math.floor(Math.random() * MAX);
8
+ /**
9
+ * Gets an ID that is guaranteed to be unique so long as no more than
10
+ * 4_294_967_295 (uint32 max) IDs are created, or the IDs are rapidly turned
11
+ * over.
12
+ *
13
+ * @returns The unique ID.
14
+ */
15
+ function getUniqueId() {
16
+ idCounter = (idCounter + 1) % MAX;
17
+ return idCounter;
18
+ }
19
+ exports.getUniqueId = getUniqueId;
20
+ //# sourceMappingURL=getUniqueId.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getUniqueId.cjs","sourceRoot":"","sources":["../src/getUniqueId.ts"],"names":[],"mappings":";;;AAAA,gCAAgC;AAChC,iDAAiD;AACjD,MAAM,GAAG,GAAG,UAAa,CAAC;AAC1B,IAAI,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC;AAEhD;;;;;;GAMG;AACH,SAAgB,WAAW;IACzB,SAAS,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;IAClC,OAAO,SAAS,CAAC;AACnB,CAAC;AAHD,kCAGC","sourcesContent":["// uint32 (two's complement) max\n// more conservative than Number.MAX_SAFE_INTEGER\nconst MAX = 4_294_967_295;\nlet idCounter = Math.floor(Math.random() * MAX);\n\n/**\n * Gets an ID that is guaranteed to be unique so long as no more than\n * 4_294_967_295 (uint32 max) IDs are created, or the IDs are rapidly turned\n * over.\n *\n * @returns The unique ID.\n */\nexport function getUniqueId(): number {\n idCounter = (idCounter + 1) % MAX;\n return idCounter;\n}\n"]}
@@ -6,4 +6,4 @@
6
6
  * @returns The unique ID.
7
7
  */
8
8
  export declare function getUniqueId(): number;
9
- //# sourceMappingURL=getUniqueId.d.ts.map
9
+ //# sourceMappingURL=getUniqueId.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getUniqueId.d.cts","sourceRoot":"","sources":["../src/getUniqueId.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAGpC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Gets an ID that is guaranteed to be unique so long as no more than
3
+ * 4_294_967_295 (uint32 max) IDs are created, or the IDs are rapidly turned
4
+ * over.
5
+ *
6
+ * @returns The unique ID.
7
+ */
8
+ export declare function getUniqueId(): number;
9
+ //# sourceMappingURL=getUniqueId.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getUniqueId.d.mts","sourceRoot":"","sources":["../src/getUniqueId.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,wBAAgB,WAAW,IAAI,MAAM,CAGpC"}
@@ -1,8 +1,16 @@
1
- import {
2
- getUniqueId
3
- } from "./chunk-6XXPTZV6.mjs";
4
- import "./chunk-XUI43LEZ.mjs";
5
- export {
6
- getUniqueId
7
- };
1
+ // uint32 (two's complement) max
2
+ // more conservative than Number.MAX_SAFE_INTEGER
3
+ const MAX = 4294967295;
4
+ let idCounter = Math.floor(Math.random() * MAX);
5
+ /**
6
+ * Gets an ID that is guaranteed to be unique so long as no more than
7
+ * 4_294_967_295 (uint32 max) IDs are created, or the IDs are rapidly turned
8
+ * over.
9
+ *
10
+ * @returns The unique ID.
11
+ */
12
+ export function getUniqueId() {
13
+ idCounter = (idCounter + 1) % MAX;
14
+ return idCounter;
15
+ }
8
16
  //# sourceMappingURL=getUniqueId.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"getUniqueId.mjs","sourceRoot":"","sources":["../src/getUniqueId.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,iDAAiD;AACjD,MAAM,GAAG,GAAG,UAAa,CAAC;AAC1B,IAAI,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,GAAG,CAAC,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,UAAU,WAAW;IACzB,SAAS,GAAG,CAAC,SAAS,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC;IAClC,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["// uint32 (two's complement) max\n// more conservative than Number.MAX_SAFE_INTEGER\nconst MAX = 4_294_967_295;\nlet idCounter = Math.floor(Math.random() * MAX);\n\n/**\n * Gets an ID that is guaranteed to be unique so long as no more than\n * 4_294_967_295 (uint32 max) IDs are created, or the IDs are rapidly turned\n * over.\n *\n * @returns The unique ID.\n */\nexport function getUniqueId(): number {\n idCounter = (idCounter + 1) % MAX;\n return idCounter;\n}\n"]}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createIdRemapMiddleware = void 0;
4
+ const getUniqueId_1 = require("./getUniqueId.cjs");
5
+ /**
6
+ * Returns a middleware function that overwrites the `id` property of each
7
+ * request with an ID that is guaranteed to be unique, and restores the original
8
+ * ID in a return handler.
9
+ *
10
+ * If used, should be the first middleware in the stack.
11
+ *
12
+ * @returns The ID remap middleware function.
13
+ */
14
+ function createIdRemapMiddleware() {
15
+ return (request, response, next, _end) => {
16
+ const originalId = request.id;
17
+ const newId = (0, getUniqueId_1.getUniqueId)();
18
+ request.id = newId;
19
+ response.id = newId;
20
+ next((done) => {
21
+ request.id = originalId;
22
+ response.id = originalId;
23
+ done();
24
+ });
25
+ };
26
+ }
27
+ exports.createIdRemapMiddleware = createIdRemapMiddleware;
28
+ //# sourceMappingURL=idRemapMiddleware.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idRemapMiddleware.cjs","sourceRoot":"","sources":["../src/idRemapMiddleware.ts"],"names":[],"mappings":";;;AAEA,mDAA4C;AAG5C;;;;;;;;GAQG;AACH,SAAgB,uBAAuB;IAIrC,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QACvC,MAAM,UAAU,GAAG,OAAO,CAAC,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,IAAA,yBAAW,GAAE,CAAC;QAC5B,OAAO,CAAC,EAAE,GAAG,KAAK,CAAC;QACnB,QAAQ,CAAC,EAAE,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YACZ,OAAO,CAAC,EAAE,GAAG,UAAU,CAAC;YACxB,QAAQ,CAAC,EAAE,GAAG,UAAU,CAAC;YACzB,IAAI,EAAE,CAAC;QACT,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAfD,0DAeC","sourcesContent":["import type { Json, JsonRpcParams } from '@metamask/utils';\n\nimport { getUniqueId } from './getUniqueId';\nimport type { JsonRpcMiddleware } from './JsonRpcEngine';\n\n/**\n * Returns a middleware function that overwrites the `id` property of each\n * request with an ID that is guaranteed to be unique, and restores the original\n * ID in a return handler.\n *\n * If used, should be the first middleware in the stack.\n *\n * @returns The ID remap middleware function.\n */\nexport function createIdRemapMiddleware(): JsonRpcMiddleware<\n JsonRpcParams,\n Json\n> {\n return (request, response, next, _end) => {\n const originalId = request.id;\n const newId = getUniqueId();\n request.id = newId;\n response.id = newId;\n next((done) => {\n request.id = originalId;\n response.id = originalId;\n done();\n });\n };\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { Json, JsonRpcParams } from '@metamask/utils';
2
- import type { JsonRpcMiddleware } from './JsonRpcEngine';
1
+ import type { Json, JsonRpcParams } from "@metamask/utils";
2
+ import type { JsonRpcMiddleware } from "./JsonRpcEngine.cjs";
3
3
  /**
4
4
  * Returns a middleware function that overwrites the `id` property of each
5
5
  * request with an ID that is guaranteed to be unique, and restores the original
@@ -10,4 +10,4 @@ import type { JsonRpcMiddleware } from './JsonRpcEngine';
10
10
  * @returns The ID remap middleware function.
11
11
  */
12
12
  export declare function createIdRemapMiddleware(): JsonRpcMiddleware<JsonRpcParams, Json>;
13
- //# sourceMappingURL=idRemapMiddleware.d.ts.map
13
+ //# sourceMappingURL=idRemapMiddleware.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idRemapMiddleware.d.cts","sourceRoot":"","sources":["../src/idRemapMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,wBAAwB;AAG3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,4BAAwB;AAEzD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,IAAI,iBAAiB,CAC1D,aAAa,EACb,IAAI,CACL,CAYA"}
@@ -0,0 +1,13 @@
1
+ import type { Json, JsonRpcParams } from "@metamask/utils";
2
+ import type { JsonRpcMiddleware } from "./JsonRpcEngine.mjs";
3
+ /**
4
+ * Returns a middleware function that overwrites the `id` property of each
5
+ * request with an ID that is guaranteed to be unique, and restores the original
6
+ * ID in a return handler.
7
+ *
8
+ * If used, should be the first middleware in the stack.
9
+ *
10
+ * @returns The ID remap middleware function.
11
+ */
12
+ export declare function createIdRemapMiddleware(): JsonRpcMiddleware<JsonRpcParams, Json>;
13
+ //# sourceMappingURL=idRemapMiddleware.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"idRemapMiddleware.d.mts","sourceRoot":"","sources":["../src/idRemapMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,wBAAwB;AAG3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,4BAAwB;AAEzD;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,IAAI,iBAAiB,CAC1D,aAAa,EACb,IAAI,CACL,CAYA"}
@@ -1,9 +1,24 @@
1
- import {
2
- createIdRemapMiddleware
3
- } from "./chunk-R7LKI5H5.mjs";
4
- import "./chunk-6XXPTZV6.mjs";
5
- import "./chunk-XUI43LEZ.mjs";
6
- export {
7
- createIdRemapMiddleware
8
- };
1
+ import { getUniqueId } from "./getUniqueId.mjs";
2
+ /**
3
+ * Returns a middleware function that overwrites the `id` property of each
4
+ * request with an ID that is guaranteed to be unique, and restores the original
5
+ * ID in a return handler.
6
+ *
7
+ * If used, should be the first middleware in the stack.
8
+ *
9
+ * @returns The ID remap middleware function.
10
+ */
11
+ export function createIdRemapMiddleware() {
12
+ return (request, response, next, _end) => {
13
+ const originalId = request.id;
14
+ const newId = getUniqueId();
15
+ request.id = newId;
16
+ response.id = newId;
17
+ next((done) => {
18
+ request.id = originalId;
19
+ response.id = originalId;
20
+ done();
21
+ });
22
+ };
23
+ }
9
24
  //# sourceMappingURL=idRemapMiddleware.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"idRemapMiddleware.mjs","sourceRoot":"","sources":["../src/idRemapMiddleware.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,0BAAsB;AAG5C;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB;IAIrC,OAAO,CAAC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QACvC,MAAM,UAAU,GAAG,OAAO,CAAC,EAAE,CAAC;QAC9B,MAAM,KAAK,GAAG,WAAW,EAAE,CAAC;QAC5B,OAAO,CAAC,EAAE,GAAG,KAAK,CAAC;QACnB,QAAQ,CAAC,EAAE,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YACZ,OAAO,CAAC,EAAE,GAAG,UAAU,CAAC;YACxB,QAAQ,CAAC,EAAE,GAAG,UAAU,CAAC;YACzB,IAAI,EAAE,CAAC;QACT,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import type { Json, JsonRpcParams } from '@metamask/utils';\n\nimport { getUniqueId } from './getUniqueId';\nimport type { JsonRpcMiddleware } from './JsonRpcEngine';\n\n/**\n * Returns a middleware function that overwrites the `id` property of each\n * request with an ID that is guaranteed to be unique, and restores the original\n * ID in a return handler.\n *\n * If used, should be the first middleware in the stack.\n *\n * @returns The ID remap middleware function.\n */\nexport function createIdRemapMiddleware(): JsonRpcMiddleware<\n JsonRpcParams,\n Json\n> {\n return (request, response, next, _end) => {\n const originalId = request.id;\n const newId = getUniqueId();\n request.id = newId;\n response.id = newId;\n next((done) => {\n request.id = originalId;\n response.id = originalId;\n done();\n });\n };\n}\n"]}
package/dist/index.cjs ADDED
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeMiddleware = exports.JsonRpcEngine = exports.createIdRemapMiddleware = exports.getUniqueId = exports.createScaffoldMiddleware = exports.createAsyncMiddleware = void 0;
4
+ var createAsyncMiddleware_1 = require("./createAsyncMiddleware.cjs");
5
+ Object.defineProperty(exports, "createAsyncMiddleware", { enumerable: true, get: function () { return createAsyncMiddleware_1.createAsyncMiddleware; } });
6
+ var createScaffoldMiddleware_1 = require("./createScaffoldMiddleware.cjs");
7
+ Object.defineProperty(exports, "createScaffoldMiddleware", { enumerable: true, get: function () { return createScaffoldMiddleware_1.createScaffoldMiddleware; } });
8
+ var getUniqueId_1 = require("./getUniqueId.cjs");
9
+ Object.defineProperty(exports, "getUniqueId", { enumerable: true, get: function () { return getUniqueId_1.getUniqueId; } });
10
+ var idRemapMiddleware_1 = require("./idRemapMiddleware.cjs");
11
+ Object.defineProperty(exports, "createIdRemapMiddleware", { enumerable: true, get: function () { return idRemapMiddleware_1.createIdRemapMiddleware; } });
12
+ var JsonRpcEngine_1 = require("./JsonRpcEngine.cjs");
13
+ Object.defineProperty(exports, "JsonRpcEngine", { enumerable: true, get: function () { return JsonRpcEngine_1.JsonRpcEngine; } });
14
+ var mergeMiddleware_1 = require("./mergeMiddleware.cjs");
15
+ Object.defineProperty(exports, "mergeMiddleware", { enumerable: true, get: function () { return mergeMiddleware_1.mergeMiddleware; } });
16
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAIA,qEAAgE;AAAvD,8HAAA,qBAAqB,OAAA;AAC9B,2EAAsE;AAA7D,oIAAA,wBAAwB,OAAA;AACjC,iDAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,6DAA8D;AAArD,4HAAA,uBAAuB,OAAA;AAShC,qDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,yDAAoD;AAA3C,kHAAA,eAAe,OAAA","sourcesContent":["export type {\n AsyncJsonRpcEngineNextCallback,\n AsyncJsonrpcMiddleware,\n} from './createAsyncMiddleware';\nexport { createAsyncMiddleware } from './createAsyncMiddleware';\nexport { createScaffoldMiddleware } from './createScaffoldMiddleware';\nexport { getUniqueId } from './getUniqueId';\nexport { createIdRemapMiddleware } from './idRemapMiddleware';\nexport type {\n JsonRpcEngineCallbackError,\n JsonRpcEngineReturnHandler,\n JsonRpcEngineNextCallback,\n JsonRpcEngineEndCallback,\n JsonRpcMiddleware,\n JsonRpcNotificationHandler,\n} from './JsonRpcEngine';\nexport { JsonRpcEngine } from './JsonRpcEngine';\nexport { mergeMiddleware } from './mergeMiddleware';\n"]}
@@ -0,0 +1,9 @@
1
+ export type { AsyncJsonRpcEngineNextCallback, AsyncJsonrpcMiddleware, } from "./createAsyncMiddleware.cjs";
2
+ export { createAsyncMiddleware } from "./createAsyncMiddleware.cjs";
3
+ export { createScaffoldMiddleware } from "./createScaffoldMiddleware.cjs";
4
+ export { getUniqueId } from "./getUniqueId.cjs";
5
+ export { createIdRemapMiddleware } from "./idRemapMiddleware.cjs";
6
+ export type { JsonRpcEngineCallbackError, JsonRpcEngineReturnHandler, JsonRpcEngineNextCallback, JsonRpcEngineEndCallback, JsonRpcMiddleware, JsonRpcNotificationHandler, } from "./JsonRpcEngine.cjs";
7
+ export { JsonRpcEngine } from "./JsonRpcEngine.cjs";
8
+ export { mergeMiddleware } from "./mergeMiddleware.cjs";
9
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,8BAA8B,EAC9B,sBAAsB,GACvB,oCAAgC;AACjC,OAAO,EAAE,qBAAqB,EAAE,oCAAgC;AAChE,OAAO,EAAE,wBAAwB,EAAE,uCAAmC;AACtE,OAAO,EAAE,WAAW,EAAE,0BAAsB;AAC5C,OAAO,EAAE,uBAAuB,EAAE,gCAA4B;AAC9D,YAAY,EACV,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,EACzB,wBAAwB,EACxB,iBAAiB,EACjB,0BAA0B,GAC3B,4BAAwB;AACzB,OAAO,EAAE,aAAa,EAAE,4BAAwB;AAChD,OAAO,EAAE,eAAe,EAAE,8BAA0B"}
@@ -0,0 +1,9 @@
1
+ export type { AsyncJsonRpcEngineNextCallback, AsyncJsonrpcMiddleware, } from "./createAsyncMiddleware.mjs";
2
+ export { createAsyncMiddleware } from "./createAsyncMiddleware.mjs";
3
+ export { createScaffoldMiddleware } from "./createScaffoldMiddleware.mjs";
4
+ export { getUniqueId } from "./getUniqueId.mjs";
5
+ export { createIdRemapMiddleware } from "./idRemapMiddleware.mjs";
6
+ export type { JsonRpcEngineCallbackError, JsonRpcEngineReturnHandler, JsonRpcEngineNextCallback, JsonRpcEngineEndCallback, JsonRpcMiddleware, JsonRpcNotificationHandler, } from "./JsonRpcEngine.mjs";
7
+ export { JsonRpcEngine } from "./JsonRpcEngine.mjs";
8
+ export { mergeMiddleware } from "./mergeMiddleware.mjs";
9
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,8BAA8B,EAC9B,sBAAsB,GACvB,oCAAgC;AACjC,OAAO,EAAE,qBAAqB,EAAE,oCAAgC;AAChE,OAAO,EAAE,wBAAwB,EAAE,uCAAmC;AACtE,OAAO,EAAE,WAAW,EAAE,0BAAsB;AAC5C,OAAO,EAAE,uBAAuB,EAAE,gCAA4B;AAC9D,YAAY,EACV,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,EACzB,wBAAwB,EACxB,iBAAiB,EACjB,0BAA0B,GAC3B,4BAAwB;AACzB,OAAO,EAAE,aAAa,EAAE,4BAAwB;AAChD,OAAO,EAAE,eAAe,EAAE,8BAA0B"}
package/dist/index.mjs CHANGED
@@ -1,28 +1,7 @@
1
- import {
2
- createAsyncMiddleware
3
- } from "./chunk-KNT3O2VO.mjs";
4
- import {
5
- createScaffoldMiddleware
6
- } from "./chunk-KZ5RA76F.mjs";
7
- import {
8
- createIdRemapMiddleware
9
- } from "./chunk-R7LKI5H5.mjs";
10
- import {
11
- getUniqueId
12
- } from "./chunk-6XXPTZV6.mjs";
13
- import {
14
- mergeMiddleware
15
- } from "./chunk-KFRJCTOQ.mjs";
16
- import {
17
- JsonRpcEngine
18
- } from "./chunk-5HCYV4FV.mjs";
19
- import "./chunk-XUI43LEZ.mjs";
20
- export {
21
- JsonRpcEngine,
22
- createAsyncMiddleware,
23
- createIdRemapMiddleware,
24
- createScaffoldMiddleware,
25
- getUniqueId,
26
- mergeMiddleware
27
- };
1
+ export { createAsyncMiddleware } from "./createAsyncMiddleware.mjs";
2
+ export { createScaffoldMiddleware } from "./createScaffoldMiddleware.mjs";
3
+ export { getUniqueId } from "./getUniqueId.mjs";
4
+ export { createIdRemapMiddleware } from "./idRemapMiddleware.mjs";
5
+ export { JsonRpcEngine } from "./JsonRpcEngine.mjs";
6
+ export { mergeMiddleware } from "./mergeMiddleware.mjs";
28
7
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"index.mjs","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,qBAAqB,EAAE,oCAAgC;AAChE,OAAO,EAAE,wBAAwB,EAAE,uCAAmC;AACtE,OAAO,EAAE,WAAW,EAAE,0BAAsB;AAC5C,OAAO,EAAE,uBAAuB,EAAE,gCAA4B;AAS9D,OAAO,EAAE,aAAa,EAAE,4BAAwB;AAChD,OAAO,EAAE,eAAe,EAAE,8BAA0B","sourcesContent":["export type {\n AsyncJsonRpcEngineNextCallback,\n AsyncJsonrpcMiddleware,\n} from './createAsyncMiddleware';\nexport { createAsyncMiddleware } from './createAsyncMiddleware';\nexport { createScaffoldMiddleware } from './createScaffoldMiddleware';\nexport { getUniqueId } from './getUniqueId';\nexport { createIdRemapMiddleware } from './idRemapMiddleware';\nexport type {\n JsonRpcEngineCallbackError,\n JsonRpcEngineReturnHandler,\n JsonRpcEngineNextCallback,\n JsonRpcEngineEndCallback,\n JsonRpcMiddleware,\n JsonRpcNotificationHandler,\n} from './JsonRpcEngine';\nexport { JsonRpcEngine } from './JsonRpcEngine';\nexport { mergeMiddleware } from './mergeMiddleware';\n"]}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeMiddleware = void 0;
4
+ const JsonRpcEngine_1 = require("./JsonRpcEngine.cjs");
5
+ /**
6
+ * Takes a stack of middleware and joins them into a single middleware function.
7
+ *
8
+ * @param middlewareStack - The middleware stack to merge.
9
+ * @returns The merged middleware function.
10
+ */
11
+ function mergeMiddleware(middlewareStack) {
12
+ const engine = new JsonRpcEngine_1.JsonRpcEngine();
13
+ middlewareStack.forEach((middleware) => engine.push(middleware));
14
+ return engine.asMiddleware();
15
+ }
16
+ exports.mergeMiddleware = mergeMiddleware;
17
+ //# sourceMappingURL=mergeMiddleware.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeMiddleware.cjs","sourceRoot":"","sources":["../src/mergeMiddleware.ts"],"names":[],"mappings":";;;AAGA,uDAAgD;AAEhD;;;;;GAKG;AACH,SAAgB,eAAe,CAC7B,eAAyD;IAEzD,MAAM,MAAM,GAAG,IAAI,6BAAa,EAAE,CAAC;IACnC,eAAe,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACjE,OAAO,MAAM,CAAC,YAAY,EAAE,CAAC;AAC/B,CAAC;AAND,0CAMC","sourcesContent":["import type { Json, JsonRpcParams } from '@metamask/utils';\n\nimport type { JsonRpcMiddleware } from './JsonRpcEngine';\nimport { JsonRpcEngine } from './JsonRpcEngine';\n\n/**\n * Takes a stack of middleware and joins them into a single middleware function.\n *\n * @param middlewareStack - The middleware stack to merge.\n * @returns The merged middleware function.\n */\nexport function mergeMiddleware(\n middlewareStack: JsonRpcMiddleware<JsonRpcParams, Json>[],\n) {\n const engine = new JsonRpcEngine();\n middlewareStack.forEach((middleware) => engine.push(middleware));\n return engine.asMiddleware();\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { Json, JsonRpcParams } from '@metamask/utils';
2
- import type { JsonRpcMiddleware } from './JsonRpcEngine';
1
+ import type { Json, JsonRpcParams } from "@metamask/utils";
2
+ import type { JsonRpcMiddleware } from "./JsonRpcEngine.cjs";
3
3
  /**
4
4
  * Takes a stack of middleware and joins them into a single middleware function.
5
5
  *
@@ -7,4 +7,4 @@ import type { JsonRpcMiddleware } from './JsonRpcEngine';
7
7
  * @returns The merged middleware function.
8
8
  */
9
9
  export declare function mergeMiddleware(middlewareStack: JsonRpcMiddleware<JsonRpcParams, Json>[]): JsonRpcMiddleware<JsonRpcParams, Json>;
10
- //# sourceMappingURL=mergeMiddleware.d.ts.map
10
+ //# sourceMappingURL=mergeMiddleware.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeMiddleware.d.cts","sourceRoot":"","sources":["../src/mergeMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,wBAAwB;AAE3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,4BAAwB;AAGzD;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,eAAe,EAAE,iBAAiB,CAAC,aAAa,EAAE,IAAI,CAAC,EAAE,0CAK1D"}
@@ -0,0 +1,10 @@
1
+ import type { Json, JsonRpcParams } from "@metamask/utils";
2
+ import type { JsonRpcMiddleware } from "./JsonRpcEngine.mjs";
3
+ /**
4
+ * Takes a stack of middleware and joins them into a single middleware function.
5
+ *
6
+ * @param middlewareStack - The middleware stack to merge.
7
+ * @returns The merged middleware function.
8
+ */
9
+ export declare function mergeMiddleware(middlewareStack: JsonRpcMiddleware<JsonRpcParams, Json>[]): JsonRpcMiddleware<JsonRpcParams, Json>;
10
+ //# sourceMappingURL=mergeMiddleware.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergeMiddleware.d.mts","sourceRoot":"","sources":["../src/mergeMiddleware.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,wBAAwB;AAE3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,4BAAwB;AAGzD;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,eAAe,EAAE,iBAAiB,CAAC,aAAa,EAAE,IAAI,CAAC,EAAE,0CAK1D"}
@@ -1,9 +1,13 @@
1
- import {
2
- mergeMiddleware
3
- } from "./chunk-KFRJCTOQ.mjs";
4
- import "./chunk-5HCYV4FV.mjs";
5
- import "./chunk-XUI43LEZ.mjs";
6
- export {
7
- mergeMiddleware
8
- };
1
+ import { JsonRpcEngine } from "./JsonRpcEngine.mjs";
2
+ /**
3
+ * Takes a stack of middleware and joins them into a single middleware function.
4
+ *
5
+ * @param middlewareStack - The middleware stack to merge.
6
+ * @returns The merged middleware function.
7
+ */
8
+ export function mergeMiddleware(middlewareStack) {
9
+ const engine = new JsonRpcEngine();
10
+ middlewareStack.forEach((middleware) => engine.push(middleware));
11
+ return engine.asMiddleware();
12
+ }
9
13
  //# sourceMappingURL=mergeMiddleware.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"file":"mergeMiddleware.mjs","sourceRoot":"","sources":["../src/mergeMiddleware.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,4BAAwB;AAEhD;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAC7B,eAAyD;IAEzD,MAAM,MAAM,GAAG,IAAI,aAAa,EAAE,CAAC;IACnC,eAAe,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;IACjE,OAAO,MAAM,CAAC,YAAY,EAAE,CAAC;AAC/B,CAAC","sourcesContent":["import type { Json, JsonRpcParams } from '@metamask/utils';\n\nimport type { JsonRpcMiddleware } from './JsonRpcEngine';\nimport { JsonRpcEngine } from './JsonRpcEngine';\n\n/**\n * Takes a stack of middleware and joins them into a single middleware function.\n *\n * @param middlewareStack - The middleware stack to merge.\n * @returns The merged middleware function.\n */\nexport function mergeMiddleware(\n middlewareStack: JsonRpcMiddleware<JsonRpcParams, Json>[],\n) {\n const engine = new JsonRpcEngine();\n middlewareStack.forEach((middleware) => engine.push(middleware));\n return engine.asMiddleware();\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/json-rpc-engine",
3
- "version": "9.0.2-preview-367cb1da",
3
+ "version": "9.0.2-preview-cf09c0a",
4
4
  "description": "A tool for processing JSON-RPC messages",
5
5
  "keywords": [
6
6
  "MetaMask",
@@ -18,14 +18,19 @@
18
18
  "sideEffects": false,
19
19
  "exports": {
20
20
  ".": {
21
- "import": "./dist/index.mjs",
22
- "require": "./dist/index.js",
23
- "types": "./dist/types/index.d.ts"
21
+ "import": {
22
+ "types": "./dist/index.d.mts",
23
+ "default": "./dist/index.mjs"
24
+ },
25
+ "require": {
26
+ "types": "./dist/index.d.cts",
27
+ "default": "./dist/index.cjs"
28
+ }
24
29
  },
25
30
  "./package.json": "./package.json"
26
31
  },
27
- "main": "./dist/index.js",
28
- "types": "./dist/types/index.d.ts",
32
+ "main": "./dist/index.cjs",
33
+ "types": "./dist/index.d.cts",
29
34
  "directories": {
30
35
  "test": "test"
31
36
  },
@@ -33,7 +38,7 @@
33
38
  "dist/"
34
39
  ],
35
40
  "scripts": {
36
- "build": "tsup --config ../../tsup.config.ts --tsconfig ./tsconfig.build.json --clean",
41
+ "build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
37
42
  "build:docs": "typedoc",
38
43
  "changelog:update": "../../scripts/update-changelog.sh @metamask/json-rpc-engine --tag-prefix-before-package-rename json-rpc-engine@ --version-before-package-rename 6.1.0",
39
44
  "changelog:validate": "../../scripts/validate-changelog.sh @metamask/json-rpc-engine --tag-prefix-before-package-rename json-rpc-engine@ --version-before-package-rename 6.1.0",
@@ -1,8 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
-
3
- var _chunk2LXAFMJDjs = require('./chunk-2LXAFMJD.js');
4
- require('./chunk-Z4BLTVTB.js');
5
-
6
-
7
- exports.JsonRpcEngine = _chunk2LXAFMJDjs.JsonRpcEngine;
8
- //# sourceMappingURL=JsonRpcEngine.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":""}