effect-web-midi 0.2.3

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 (232) hide show
  1. package/README.md +276 -0
  2. package/dist/index.js +2 -0
  3. package/dist/index.js.map +1 -0
  4. package/dist/src/EMIDIAccess.js +129 -0
  5. package/dist/src/EMIDIAccess.js.map +1 -0
  6. package/dist/src/EMIDIInput.js +226 -0
  7. package/dist/src/EMIDIInput.js.map +1 -0
  8. package/dist/src/EMIDIOutput.js +227 -0
  9. package/dist/src/EMIDIOutput.js.map +1 -0
  10. package/dist/src/EMIDIPort.js +218 -0
  11. package/dist/src/EMIDIPort.js.map +1 -0
  12. package/dist/src/MIDIErrors.js +4 -0
  13. package/dist/src/MIDIErrors.js.map +1 -0
  14. package/dist/src/MIDIEventStreams.js +2 -0
  15. package/dist/src/MIDIEventStreams.js.map +1 -0
  16. package/dist/src/Parsing.js +2 -0
  17. package/dist/src/Parsing.js.map +1 -0
  18. package/dist/src/StreamMaker.js +1 -0
  19. package/dist/src/StreamMaker.js.map +1 -0
  20. package/dist/src/Util.js +2 -0
  21. package/dist/src/Util.js.map +1 -0
  22. package/dist/src/index.js +10 -0
  23. package/dist/src/index.js.map +1 -0
  24. package/dist/src/internal/EMIDIAccess.js +634 -0
  25. package/dist/src/internal/EMIDIAccess.js.map +1 -0
  26. package/dist/src/internal/EMIDIInput.js +66 -0
  27. package/dist/src/internal/EMIDIInput.js.map +1 -0
  28. package/dist/src/internal/EMIDIOutput.js +120 -0
  29. package/dist/src/internal/EMIDIOutput.js.map +1 -0
  30. package/dist/src/internal/EMIDIPort.js +125 -0
  31. package/dist/src/internal/EMIDIPort.js.map +1 -0
  32. package/dist/src/internal/MIDIErrors.js +190 -0
  33. package/dist/src/internal/MIDIErrors.js.map +1 -0
  34. package/dist/src/internal/MIDIEventStreams.js +41 -0
  35. package/dist/src/internal/MIDIEventStreams.js.map +1 -0
  36. package/dist/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPort.js +27 -0
  37. package/dist/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPort.js.map +1 -0
  38. package/dist/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdAndAccess.js +19 -0
  39. package/dist/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdAndAccess.js.map +1 -0
  40. package/dist/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdInContext.js +16 -0
  41. package/dist/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdInContext.js.map +1 -0
  42. package/dist/src/internal/MIDIPortMethodCalls/actOnPort.js +17 -0
  43. package/dist/src/internal/MIDIPortMethodCalls/actOnPort.js.map +1 -0
  44. package/dist/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPort.js +27 -0
  45. package/dist/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPort.js.map +1 -0
  46. package/dist/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdAndAccess.js +18 -0
  47. package/dist/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdAndAccess.js.map +1 -0
  48. package/dist/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdInContext.js +16 -0
  49. package/dist/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdInContext.js.map +1 -0
  50. package/dist/src/internal/MIDIPortMethodCalls/makeMIDIPortMethodCallerFactory.js +21 -0
  51. package/dist/src/internal/MIDIPortMethodCalls/makeMIDIPortMethodCallerFactory.js.map +1 -0
  52. package/dist/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPort.js +34 -0
  53. package/dist/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPort.js.map +1 -0
  54. package/dist/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdAndAccess.js +18 -0
  55. package/dist/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdAndAccess.js.map +1 -0
  56. package/dist/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdInContext.js +16 -0
  57. package/dist/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdInContext.js.map +1 -0
  58. package/dist/src/internal/Parsing.js +119 -0
  59. package/dist/src/internal/Parsing.js.map +1 -0
  60. package/dist/src/internal/StreamMaker.js +105 -0
  61. package/dist/src/internal/StreamMaker.js.map +1 -0
  62. package/dist/src/internal/Util.js +59 -0
  63. package/dist/src/internal/Util.js.map +1 -0
  64. package/dist/src/internal/getPortByPortId/getPortByPortIdAndAccess.js +53 -0
  65. package/dist/src/internal/getPortByPortId/getPortByPortIdAndAccess.js.map +1 -0
  66. package/dist/src/internal/getPortByPortId/getPortByPortIdInContext.js +18 -0
  67. package/dist/src/internal/getPortByPortId/getPortByPortIdInContext.js.map +1 -0
  68. package/dist/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPort.js +52 -0
  69. package/dist/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPort.js.map +1 -0
  70. package/dist/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdAndAccess.js +21 -0
  71. package/dist/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdAndAccess.js.map +1 -0
  72. package/dist/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdInContext.js +21 -0
  73. package/dist/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdInContext.js.map +1 -0
  74. package/dist/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPort.js +66 -0
  75. package/dist/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPort.js.map +1 -0
  76. package/dist/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdAndAccess.js +61 -0
  77. package/dist/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdAndAccess.js.map +1 -0
  78. package/dist/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdInContext.js +68 -0
  79. package/dist/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdInContext.js.map +1 -0
  80. package/dist/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPort.js +42 -0
  81. package/dist/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPort.js.map +1 -0
  82. package/dist/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdAndAccess.js +43 -0
  83. package/dist/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdAndAccess.js.map +1 -0
  84. package/dist/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdInContext.js +33 -0
  85. package/dist/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdInContext.js.map +1 -0
  86. package/dist/src/internal/mutablePropertyTools/getValueInRawPortFieldUnsafe.js +6 -0
  87. package/dist/src/internal/mutablePropertyTools/getValueInRawPortFieldUnsafe.js.map +1 -0
  88. package/dist/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPort.js +46 -0
  89. package/dist/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPort.js.map +1 -0
  90. package/dist/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdAndAccess.js +25 -0
  91. package/dist/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdAndAccess.js.map +1 -0
  92. package/dist/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdInContext.js +31 -0
  93. package/dist/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdInContext.js.map +1 -0
  94. package/dist-types/index.d.ts +2 -0
  95. package/dist-types/index.d.ts.map +1 -0
  96. package/dist-types/src/EMIDIAccess.d.ts +18 -0
  97. package/dist-types/src/EMIDIAccess.d.ts.map +1 -0
  98. package/dist-types/src/EMIDIInput.d.ts +26 -0
  99. package/dist-types/src/EMIDIInput.d.ts.map +1 -0
  100. package/dist-types/src/EMIDIOutput.d.ts +26 -0
  101. package/dist-types/src/EMIDIOutput.d.ts.map +1 -0
  102. package/dist-types/src/EMIDIPort.d.ts +26 -0
  103. package/dist-types/src/EMIDIPort.d.ts.map +1 -0
  104. package/dist-types/src/MIDIErrors.d.ts +2 -0
  105. package/dist-types/src/MIDIErrors.d.ts.map +1 -0
  106. package/dist-types/src/MIDIEventStreams.d.ts +2 -0
  107. package/dist-types/src/MIDIEventStreams.d.ts.map +1 -0
  108. package/dist-types/src/Parsing.d.ts +2 -0
  109. package/dist-types/src/Parsing.d.ts.map +1 -0
  110. package/dist-types/src/StreamMaker.d.ts +2 -0
  111. package/dist-types/src/StreamMaker.d.ts.map +1 -0
  112. package/dist-types/src/Util.d.ts +2 -0
  113. package/dist-types/src/Util.d.ts.map +1 -0
  114. package/dist-types/src/index.d.ts +10 -0
  115. package/dist-types/src/index.d.ts.map +1 -0
  116. package/dist-types/src/internal/EMIDIAccess.d.ts +551 -0
  117. package/dist-types/src/internal/EMIDIAccess.d.ts.map +1 -0
  118. package/dist-types/src/internal/EMIDIInput.d.ts +50 -0
  119. package/dist-types/src/internal/EMIDIInput.d.ts.map +1 -0
  120. package/dist-types/src/internal/EMIDIOutput.d.ts +95 -0
  121. package/dist-types/src/internal/EMIDIOutput.d.ts.map +1 -0
  122. package/dist-types/src/internal/EMIDIPort.d.ts +90 -0
  123. package/dist-types/src/internal/EMIDIPort.d.ts.map +1 -0
  124. package/dist-types/src/internal/MIDIErrors.d.ts +270 -0
  125. package/dist-types/src/internal/MIDIErrors.d.ts.map +1 -0
  126. package/dist-types/src/internal/MIDIEventStreams.d.ts +74 -0
  127. package/dist-types/src/internal/MIDIEventStreams.d.ts.map +1 -0
  128. package/dist-types/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPort.d.ts +16 -0
  129. package/dist-types/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPort.d.ts.map +1 -0
  130. package/dist-types/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdAndAccess.d.ts +15 -0
  131. package/dist-types/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdAndAccess.d.ts.map +1 -0
  132. package/dist-types/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdInContext.d.ts +13 -0
  133. package/dist-types/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdInContext.d.ts.map +1 -0
  134. package/dist-types/src/internal/MIDIPortMethodCalls/actOnPort.d.ts +11 -0
  135. package/dist-types/src/internal/MIDIPortMethodCalls/actOnPort.d.ts.map +1 -0
  136. package/dist-types/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPort.d.ts +23 -0
  137. package/dist-types/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPort.d.ts.map +1 -0
  138. package/dist-types/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdAndAccess.d.ts +15 -0
  139. package/dist-types/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdAndAccess.d.ts.map +1 -0
  140. package/dist-types/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdInContext.d.ts +13 -0
  141. package/dist-types/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdInContext.d.ts.map +1 -0
  142. package/dist-types/src/internal/MIDIPortMethodCalls/makeMIDIPortMethodCallerFactory.d.ts +15 -0
  143. package/dist-types/src/internal/MIDIPortMethodCalls/makeMIDIPortMethodCallerFactory.d.ts.map +1 -0
  144. package/dist-types/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPort.d.ts +21 -0
  145. package/dist-types/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPort.d.ts.map +1 -0
  146. package/dist-types/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdAndAccess.d.ts +15 -0
  147. package/dist-types/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdAndAccess.d.ts.map +1 -0
  148. package/dist-types/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdInContext.d.ts +13 -0
  149. package/dist-types/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdInContext.d.ts.map +1 -0
  150. package/dist-types/src/internal/Parsing.d.ts +110 -0
  151. package/dist-types/src/internal/Parsing.d.ts.map +1 -0
  152. package/dist-types/src/internal/StreamMaker.d.ts +204 -0
  153. package/dist-types/src/internal/StreamMaker.d.ts.map +1 -0
  154. package/dist-types/src/internal/Util.d.ts +33 -0
  155. package/dist-types/src/internal/Util.d.ts.map +1 -0
  156. package/dist-types/src/internal/getPortByPortId/getPortByPortIdAndAccess.d.ts +27 -0
  157. package/dist-types/src/internal/getPortByPortId/getPortByPortIdAndAccess.d.ts.map +1 -0
  158. package/dist-types/src/internal/getPortByPortId/getPortByPortIdInContext.d.ts +20 -0
  159. package/dist-types/src/internal/getPortByPortId/getPortByPortIdInContext.d.ts.map +1 -0
  160. package/dist-types/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPort.d.ts +76 -0
  161. package/dist-types/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPort.d.ts.map +1 -0
  162. package/dist-types/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdAndAccess.d.ts +39 -0
  163. package/dist-types/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdAndAccess.d.ts.map +1 -0
  164. package/dist-types/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdInContext.d.ts +29 -0
  165. package/dist-types/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdInContext.d.ts.map +1 -0
  166. package/dist-types/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPort.d.ts +62 -0
  167. package/dist-types/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPort.d.ts.map +1 -0
  168. package/dist-types/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdAndAccess.d.ts +16 -0
  169. package/dist-types/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdAndAccess.d.ts.map +1 -0
  170. package/dist-types/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdInContext.d.ts +65 -0
  171. package/dist-types/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdInContext.d.ts.map +1 -0
  172. package/dist-types/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPort.d.ts +36 -0
  173. package/dist-types/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPort.d.ts.map +1 -0
  174. package/dist-types/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdAndAccess.d.ts +23 -0
  175. package/dist-types/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdAndAccess.d.ts.map +1 -0
  176. package/dist-types/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdInContext.d.ts +35 -0
  177. package/dist-types/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdInContext.d.ts.map +1 -0
  178. package/dist-types/src/internal/mutablePropertyTools/getValueInRawPortFieldUnsafe.d.ts +7 -0
  179. package/dist-types/src/internal/mutablePropertyTools/getValueInRawPortFieldUnsafe.d.ts.map +1 -0
  180. package/dist-types/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPort.d.ts +71 -0
  181. package/dist-types/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPort.d.ts.map +1 -0
  182. package/dist-types/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdAndAccess.d.ts +7 -0
  183. package/dist-types/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdAndAccess.d.ts.map +1 -0
  184. package/dist-types/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdInContext.d.ts +28 -0
  185. package/dist-types/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdInContext.d.ts.map +1 -0
  186. package/index.ts +1 -0
  187. package/package.json +87 -0
  188. package/src/EMIDIAccess.ts +285 -0
  189. package/src/EMIDIInput.ts +273 -0
  190. package/src/EMIDIOutput.ts +272 -0
  191. package/src/EMIDIPort.ts +270 -0
  192. package/src/MIDIErrors.ts +13 -0
  193. package/src/MIDIEventStreams.ts +36 -0
  194. package/src/Parsing.ts +32 -0
  195. package/src/StreamMaker.ts +12 -0
  196. package/src/Util.ts +19 -0
  197. package/src/index.ts +9 -0
  198. package/src/internal/EMIDIAccess.ts +1280 -0
  199. package/src/internal/EMIDIInput.ts +114 -0
  200. package/src/internal/EMIDIOutput.ts +231 -0
  201. package/src/internal/EMIDIPort.ts +239 -0
  202. package/src/internal/MIDIErrors.ts +260 -0
  203. package/src/internal/MIDIEventStreams.ts +255 -0
  204. package/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPort.ts +48 -0
  205. package/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdAndAccess.ts +31 -0
  206. package/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdInContext.ts +28 -0
  207. package/src/internal/MIDIPortMethodCalls/actOnPort.ts +66 -0
  208. package/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPort.ts +38 -0
  209. package/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdAndAccess.ts +38 -0
  210. package/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdInContext.ts +28 -0
  211. package/src/internal/MIDIPortMethodCalls/makeMIDIPortMethodCallerFactory.ts +68 -0
  212. package/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPort.ts +48 -0
  213. package/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdAndAccess.ts +38 -0
  214. package/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdInContext.ts +28 -0
  215. package/src/internal/Parsing.ts +304 -0
  216. package/src/internal/StreamMaker.ts +416 -0
  217. package/src/internal/Util.ts +152 -0
  218. package/src/internal/getPortByPortId/getPortByPortIdAndAccess.ts +117 -0
  219. package/src/internal/getPortByPortId/getPortByPortIdInContext.ts +26 -0
  220. package/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPort.ts +148 -0
  221. package/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdAndAccess.ts +135 -0
  222. package/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdInContext.ts +70 -0
  223. package/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPort.ts +128 -0
  224. package/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdAndAccess.ts +74 -0
  225. package/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdInContext.ts +132 -0
  226. package/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPort.ts +64 -0
  227. package/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdAndAccess.ts +114 -0
  228. package/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdInContext.ts +47 -0
  229. package/src/internal/mutablePropertyTools/getValueInRawPortFieldUnsafe.ts +12 -0
  230. package/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPort.ts +182 -0
  231. package/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdAndAccess.ts +29 -0
  232. package/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdInContext.ts +87 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"acquireReleasePortConnectionByPortIdInContext.js","sourceRoot":"","sources":["../../../../../src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdInContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAEtC,OAAO,KAAK,GAAG,MAAM,mDAAmD,CAAA;AACxE,OAAO,KAAK,OAAO,MAAM,yCAAyC,CAAA;AAElE;;GAEG;AACH,MAAM,CAAC,MAAM,6CAA6C,GAAG,IAAI,CAC/D,GAAG,CAAC,wBAAwB,EAC5B,OAAO,CAAC,kCAAkC,CAC3C,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,8CAA8C,GAAG,IAAI,CAChE,GAAG,CAAC,yBAAyB,EAC7B,OAAO,CAAC,mCAAmC,CAC5C,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,+CAA+C,GAAG,IAAI,CACjE,GAAG,CAAC,0BAA0B,EAC9B,OAAO,CAAC,oCAAoC,CAC7C,CAAA"}
@@ -0,0 +1,17 @@
1
+ /** biome-ignore-all lint/style/useShorthandFunctionType: It's a nice way to
2
+ * preserve JSDoc comments attached to the function signature */
3
+ import * as Effect from 'effect/Effect';
4
+ import * as EFunction from 'effect/Function';
5
+ import * as EMIDIAccess from '../EMIDIAccess.js';
6
+ /**
7
+ *
8
+ * @internal
9
+ */
10
+ export const actOnPort = (getPortFromAccessAndPortId, act) => EFunction.dual(2, (polymorphicAccess, portId) => Effect.gen(function* () {
11
+ const access = yield* EMIDIAccess.simplify(polymorphicAccess);
12
+ const port = yield* getPortFromAccessAndPortId(access, portId);
13
+ const actEffect = act(port);
14
+ yield* actEffect;
15
+ return access;
16
+ }));
17
+ //# sourceMappingURL=actOnPort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"actOnPort.js","sourceRoot":"","sources":["../../../../src/internal/MIDIPortMethodCalls/actOnPort.ts"],"names":[],"mappings":"AAAA;gEACgE;AAEhE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAA;AAE5C,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAA;AAKhD;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAUvB,0BAOC,EACD,GAIC,EAQD,EAAE,CACF,SAAS,CAAC,IAAI,CACZ,CAAC,EACD,CAAC,iBAAiB,EAAE,MAAM,EAAE,EAAE,CAC5B,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAA;IAE7D,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,0BAA0B,CAC5C,MAAM,EACN,MAAgD,CACjD,CAAA;IAED,MAAM,SAAS,GAAG,GAAG,CACnB,IAAkE,CACnE,CAAA;IAED,KAAK,CAAC,CAAC,SAAS,CAAA;IAEhB,OAAO,MAAM,CAAA;AACf,CAAC,CAAQ,CACZ,CAAA"}
@@ -0,0 +1,27 @@
1
+ /** biome-ignore-all lint/style/useShorthandFunctionType: It's a nice way to
2
+ * preserve JSDoc comments attached to the function signature */
3
+ import * as EMIDIInput from '../../EMIDIInput.js';
4
+ import * as EMIDIOutput from '../../EMIDIOutput.js';
5
+ import * as EMIDIPort from '../../EMIDIPort.js';
6
+ import * as F from '../makeMIDIPortMethodCallerFactory.js';
7
+ /**
8
+ * @internal
9
+ *
10
+ * exported for acquire-release
11
+ */
12
+ export const makePortConnectionCloser = F.makeMIDIPortMethodCallerFactory('close', () => err => {
13
+ throw err;
14
+ });
15
+ /**
16
+ *
17
+ */
18
+ export const closePortConnectionByPort = makePortConnectionCloser(EMIDIPort.is);
19
+ /**
20
+ *
21
+ */
22
+ export const closeInputConnectionByPort = makePortConnectionCloser(EMIDIInput.is);
23
+ /**
24
+ *
25
+ */
26
+ export const closeOutputConnectionByPort = makePortConnectionCloser(EMIDIOutput.is);
27
+ //# sourceMappingURL=closePortConnectionByPort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"closePortConnectionByPort.js","sourceRoot":"","sources":["../../../../../src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPort.ts"],"names":[],"mappings":"AAAA;gEACgE;AAEhE,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,WAAW,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,CAAC,MAAM,uCAAuC,CAAA;AAE1D;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,+BAA+B,CACvE,OAAO,EACP,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE;IACV,MAAM,GAAG,CAAA;AACX,CAAC,CACF,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,wBAAwB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,wBAAwB,CAChE,UAAU,CAAC,EAAE,CACd,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,wBAAwB,CACjE,WAAW,CAAC,EAAE,CACf,CAAA"}
@@ -0,0 +1,18 @@
1
+ /** biome-ignore-all lint/style/useShorthandFunctionType: It's a nice way to
2
+ * preserve JSDoc comments attached to the function signature */
3
+ import { getInputByPortIdAndAccess, getOutputByPortIdAndAccess, getPortByPortIdAndAccess, } from '../../getPortByPortId/getPortByPortIdAndAccess.js';
4
+ import { actOnPort } from '../actOnPort.js';
5
+ import { closeInputConnectionByPort, closeOutputConnectionByPort, closePortConnectionByPort, } from './closePortConnectionByPort.js';
6
+ /**
7
+ *
8
+ */
9
+ export const closePortConnectionByPortIdAndAccess = actOnPort(getPortByPortIdAndAccess, closePortConnectionByPort);
10
+ /**
11
+ *
12
+ */
13
+ export const closeInputConnectionByPortIdAndAccess = actOnPort(getInputByPortIdAndAccess, closeInputConnectionByPort);
14
+ /**
15
+ *
16
+ */
17
+ export const closeOutputConnectionByPortIdAndAccess = actOnPort(getOutputByPortIdAndAccess, closeOutputConnectionByPort);
18
+ //# sourceMappingURL=closePortConnectionByPortIdAndAccess.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"closePortConnectionByPortIdAndAccess.js","sourceRoot":"","sources":["../../../../../src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdAndAccess.ts"],"names":[],"mappings":"AAAA;gEACgE;AAEhE,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,mDAAmD,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,gCAAgC,CAAA;AAEvC;;GAEG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,SAAS,CAC3D,wBAAwB,EACxB,yBAAyB,CAC1B,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,SAAS,CAC5D,yBAAyB,EACzB,0BAA0B,CAC3B,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAG,SAAS,CAC7D,0BAA0B,EAC1B,2BAA2B,CAC5B,CAAA"}
@@ -0,0 +1,16 @@
1
+ import { flow } from 'effect/Function';
2
+ import * as Get from '../../getPortByPortId/getPortByPortIdInContext.js';
3
+ import * as Close from './closePortConnectionByPort.js';
4
+ /**
5
+ *
6
+ */
7
+ export const closePortConnectionByPortIdInContext = flow(Get.getPortByPortIdInContext, Close.closePortConnectionByPort);
8
+ /**
9
+ *
10
+ */
11
+ export const closeInputConnectionByPortIdInContext = flow(Get.getInputByPortIdInContext, Close.closeInputConnectionByPort);
12
+ /**
13
+ *
14
+ */
15
+ export const closeOutputConnectionByPortIdInContext = flow(Get.getOutputByPortIdInContext, Close.closeOutputConnectionByPort);
16
+ //# sourceMappingURL=closePortConnectionByPortIdInContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"closePortConnectionByPortIdInContext.js","sourceRoot":"","sources":["../../../../../src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdInContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAEtC,OAAO,KAAK,GAAG,MAAM,mDAAmD,CAAA;AACxE,OAAO,KAAK,KAAK,MAAM,gCAAgC,CAAA;AAEvD;;GAEG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,IAAI,CACtD,GAAG,CAAC,wBAAwB,EAC5B,KAAK,CAAC,yBAAyB,CAChC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,IAAI,CACvD,GAAG,CAAC,yBAAyB,EAC7B,KAAK,CAAC,0BAA0B,CACjC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAG,IAAI,CACxD,GAAG,CAAC,0BAA0B,EAC9B,KAAK,CAAC,2BAA2B,CAClC,CAAA"}
@@ -0,0 +1,21 @@
1
+ /** biome-ignore-all lint/style/useShorthandFunctionType: It's a nice way to
2
+ * preserve JSDoc comments attached to the function signature */
3
+ import * as Effect from 'effect/Effect';
4
+ import * as EMIDIPort from '../EMIDIPort.js';
5
+ import * as Util from '../Util.js';
6
+ /**
7
+ * @internal
8
+ */
9
+ export const makeMIDIPortMethodCallerFactory = (method, mapError) => (is) => Effect.fn(`EMIDIPort.${method}`)(function* (polymorphicPort) {
10
+ const port = yield* Util.fromPolymorphic(polymorphicPort, is);
11
+ yield* Effect.annotateCurrentSpan({
12
+ method,
13
+ port: Util.getStaticMIDIPortInfo(port),
14
+ });
15
+ yield* Effect.tryPromise({
16
+ try: () => EMIDIPort.assumeImpl(port)._port[method](),
17
+ catch: mapError(port.id),
18
+ });
19
+ return port;
20
+ });
21
+ //# sourceMappingURL=makeMIDIPortMethodCallerFactory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"makeMIDIPortMethodCallerFactory.js","sourceRoot":"","sources":["../../../../src/internal/MIDIPortMethodCalls/makeMIDIPortMethodCallerFactory.ts"],"names":[],"mappings":"AAAA;gEACgE;AAEhE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAA;AAC5C,OAAO,KAAK,IAAI,MAAM,YAAY,CAAA;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAC1C,CACE,MAAwB,EACxB,QAA4D,EAC5D,EAAE,CACJ,CACE,EAAsE,EACxB,EAAE,CAChD,MAAM,CAAC,EAAE,CAAC,aAAa,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,EAIxC,eAA2D;IAC3D,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,eAAe,CACtC,eAAe,EACf,EAE2C,CAC5C,CAAA;IAED,KAAK,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC;QAChC,MAAM;QACN,IAAI,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC;KACvC,CAAC,CAAA;IAEF,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC;QACvB,GAAG,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;QACrD,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;KACzB,CAAC,CAAA;IAEF,OAAO,IAAI,CAAA;AACb,CAAC,CAAC,CAAA"}
@@ -0,0 +1,34 @@
1
+ import * as EMIDIInput from '../../EMIDIInput.js';
2
+ import * as EMIDIOutput from '../../EMIDIOutput.js';
3
+ import * as EMIDIPort from '../../EMIDIPort.js';
4
+ import * as MIDIErrors from '../../MIDIErrors.js';
5
+ import { makeMIDIPortMethodCallerFactory } from '../makeMIDIPortMethodCallerFactory.js';
6
+ /**
7
+ * @internal
8
+ *
9
+ * exported for acquire-release
10
+ */
11
+ export const makePortConnectionOpener = makeMIDIPortMethodCallerFactory('open', portId => MIDIErrors.remapErrorByName({
12
+ NotAllowedError: MIDIErrors.CannotOpenUnavailablePortError,
13
+ // InvalidAccessError is kept for compatibility reason
14
+ // (https://github.com/WebAudio/web-midi-api/pull/278):
15
+ InvalidAccessError: MIDIErrors.CannotOpenUnavailablePortError,
16
+ // InvalidStateError is not mentioned in the list of possible failures
17
+ // of `.open()` method in the specification, but given `.send()` throws
18
+ // `InvalidStateError`, when the port is "disconnected", this remapping
19
+ // wouldn't hurt
20
+ InvalidStateError: MIDIErrors.CannotOpenUnavailablePortError,
21
+ }, 'MIDI port open error handling absurd', { portId }));
22
+ /**
23
+ *
24
+ */
25
+ export const openPortConnectionByPort = makePortConnectionOpener(EMIDIPort.is);
26
+ /**
27
+ *
28
+ */
29
+ export const openInputConnectionByPort = makePortConnectionOpener(EMIDIInput.is);
30
+ /**
31
+ *
32
+ */
33
+ export const openOutputConnectionByPort = makePortConnectionOpener(EMIDIOutput.is);
34
+ //# sourceMappingURL=openPortConnectionByPort.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openPortConnectionByPort.js","sourceRoot":"","sources":["../../../../../src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,WAAW,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAA;AACjD,OAAO,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAA;AAEvF;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,+BAA+B,CACrE,MAAM,EACN,MAAM,CAAC,EAAE,CACP,UAAU,CAAC,gBAAgB,CACzB;IACE,eAAe,EAAE,UAAU,CAAC,8BAA8B;IAC1D,sDAAsD;IACtD,uDAAuD;IACvD,kBAAkB,EAAE,UAAU,CAAC,8BAA8B;IAE7D,sEAAsE;IACtE,uEAAuE;IACvE,uEAAuE;IACvE,gBAAgB;IAChB,iBAAiB,EAAE,UAAU,CAAC,8BAA8B;CAC7D,EACD,sCAAsC,EACtC,EAAE,MAAM,EAAE,CACX,CACJ,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,wBAAwB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;AAE9E;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,wBAAwB,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;AAEhF;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,wBAAwB,CAChE,WAAW,CAAC,EAAE,CACf,CAAA"}
@@ -0,0 +1,18 @@
1
+ /** biome-ignore-all lint/style/useShorthandFunctionType: It's a nice way to
2
+ * preserve JSDoc comments attached to the function signature */
3
+ import { getInputByPortIdAndAccess, getOutputByPortIdAndAccess, getPortByPortIdAndAccess, } from '../../getPortByPortId/getPortByPortIdAndAccess.js';
4
+ import { actOnPort } from '../actOnPort.js';
5
+ import { openInputConnectionByPort, openOutputConnectionByPort, openPortConnectionByPort, } from './openPortConnectionByPort.js';
6
+ /**
7
+ *
8
+ */
9
+ export const openPortConnectionByPortIdAndAccess = actOnPort(getPortByPortIdAndAccess, openPortConnectionByPort);
10
+ /**
11
+ *
12
+ */
13
+ export const openInputConnectionByPortIdAndAccess = actOnPort(getInputByPortIdAndAccess, openInputConnectionByPort);
14
+ /**
15
+ *
16
+ */
17
+ export const openOutputConnectionByPortIdAndAccess = actOnPort(getOutputByPortIdAndAccess, openOutputConnectionByPort);
18
+ //# sourceMappingURL=openPortConnectionByPortIdAndAccess.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openPortConnectionByPortIdAndAccess.js","sourceRoot":"","sources":["../../../../../src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdAndAccess.ts"],"names":[],"mappings":"AAAA;gEACgE;AAEhE,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,mDAAmD,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,+BAA+B,CAAA;AAEtC;;GAEG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,SAAS,CAC1D,wBAAwB,EACxB,wBAAwB,CACzB,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,SAAS,CAC3D,yBAAyB,EACzB,yBAAyB,CAC1B,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,SAAS,CAC5D,0BAA0B,EAC1B,0BAA0B,CAC3B,CAAA"}
@@ -0,0 +1,16 @@
1
+ import { flow } from 'effect/Function';
2
+ import * as Get from '../../getPortByPortId/getPortByPortIdInContext.js';
3
+ import * as Open from './openPortConnectionByPort.js';
4
+ /**
5
+ *
6
+ */
7
+ export const openPortConnectionByPortIdInContext = flow(Get.getPortByPortIdInContext, Open.openPortConnectionByPort);
8
+ /**
9
+ *
10
+ */
11
+ export const openInputConnectionByPortIdInContext = flow(Get.getInputByPortIdInContext, Open.openInputConnectionByPort);
12
+ /**
13
+ *
14
+ */
15
+ export const openOutputConnectionByPortIdInContext = flow(Get.getOutputByPortIdInContext, Open.openOutputConnectionByPort);
16
+ //# sourceMappingURL=openPortConnectionByPortIdInContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"openPortConnectionByPortIdInContext.js","sourceRoot":"","sources":["../../../../../src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdInContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAEtC,OAAO,KAAK,GAAG,MAAM,mDAAmD,CAAA;AACxE,OAAO,KAAK,IAAI,MAAM,+BAA+B,CAAA;AAErD;;GAEG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,IAAI,CACrD,GAAG,CAAC,wBAAwB,EAC5B,IAAI,CAAC,wBAAwB,CAC9B,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,IAAI,CACtD,GAAG,CAAC,yBAAyB,EAC7B,IAAI,CAAC,yBAAyB,CAC/B,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,IAAI,CACvD,GAAG,CAAC,0BAA0B,EAC9B,IAAI,CAAC,0BAA0B,CAChC,CAAA"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * @file This module is not for general use, these are just helpers to test the
3
+ * MIDI API with the only MIDI device I have: nanoPAD v1
4
+ */
5
+ import * as Stream from 'effect/Stream';
6
+ //? NOTE: Look at the issue https://github.com/WebAudio/web-midi-api/issues/179
7
+ // which discusses higher-level MIDI message access
8
+ /**
9
+ *
10
+ * @param self
11
+ * @returns
12
+ */
13
+ export const withParsedDataField = (self) => Stream.map(self, ({ midiMessage, ...obj }) => ({
14
+ ...obj,
15
+ _tag: 'ParsedMIDIMessage',
16
+ midiMessage: parseMIDIMessagePayload(midiMessage),
17
+ }));
18
+ /**
19
+ *
20
+ * @param self
21
+ * @returns
22
+ */
23
+ export const withTouchpadPositionUpdates = (self) => Stream.mapAccum(self, { x: null, y: null }, (ctx, current) => {
24
+ const { midiMessage, ...rest } = current;
25
+ const state = isControlChangePayload(midiMessage)
26
+ ? { ...ctx, y: midiMessage.value }
27
+ : isPitchBendChangePayload(midiMessage)
28
+ ? { ...ctx, x: midiMessage.value }
29
+ : midiMessage._tag === 'Touchpad Release'
30
+ ? { x: null, y: null }
31
+ : ctx;
32
+ return [
33
+ state,
34
+ state.x !== null && state.y !== null
35
+ ? Stream.make(current, {
36
+ ...rest,
37
+ midiMessage: {
38
+ _tag: 'Touchpad Position Update',
39
+ x: state.x,
40
+ y: state.y,
41
+ },
42
+ })
43
+ : Stream.succeed(current),
44
+ ];
45
+ }).pipe(Stream.flatten());
46
+ function parseMIDIMessagePayload(rawPayload) {
47
+ const unknown = () => {
48
+ let stack = '';
49
+ if ('stackTraceLimit' in Error &&
50
+ 'captureStackTrace' in Error &&
51
+ typeof Error.captureStackTrace === 'function') {
52
+ const { stackTraceLimit } = Error;
53
+ Error.stackTraceLimit = 4;
54
+ const stackHolder = {};
55
+ Error.captureStackTrace(stackHolder);
56
+ Error.stackTraceLimit = stackTraceLimit;
57
+ stack = stackHolder.stack ?? new Error().stack ?? '';
58
+ }
59
+ const result = {
60
+ _tag: 'Unknown Reply',
61
+ unexpectedData: rawPayload.toString(),
62
+ stack,
63
+ };
64
+ return result;
65
+ };
66
+ const status = rawPayload.at(0);
67
+ if (status === undefined)
68
+ return unknown();
69
+ const second = rawPayload.at(1);
70
+ if (second === undefined)
71
+ return unknown();
72
+ const code = status >> 4;
73
+ const channel = status & 0b1111;
74
+ if (rawPayload.length === 2) {
75
+ if (code === 0xd)
76
+ return { _tag: 'Channel Pressure', channel, velocity: second };
77
+ }
78
+ if (rawPayload.length !== 3)
79
+ return unknown();
80
+ const third = rawPayload.at(2);
81
+ if (third === undefined)
82
+ return unknown();
83
+ if (code === 0x8)
84
+ return { _tag: 'Note Release', channel, note: second, velocity: third };
85
+ if (code === 0x9) {
86
+ if (third === 0)
87
+ return { _tag: 'Note Release', channel, note: second, velocity: 64 };
88
+ return { _tag: 'Note Press', channel, note: second, velocity: third };
89
+ }
90
+ if (code === 0xb)
91
+ return { _tag: 'Control Change', channel, control: second, value: third };
92
+ if (code === 0xe) {
93
+ if (second === 0 && third === 0x40)
94
+ return { _tag: 'Touchpad Release', channel };
95
+ if (second === third)
96
+ return { _tag: 'Pitch Bend Change', channel, value: second };
97
+ return unknown();
98
+ }
99
+ return unknown();
100
+ }
101
+ const isSpecificPayload = (tag) => (e) => e._tag === tag;
102
+ const isSpecificMessage = (isSpecificPayload) => (m) => isSpecificPayload(m.midiMessage);
103
+ export const isUnknownReplyPayload = isSpecificPayload('Unknown Reply');
104
+ export const isUnknownReply = isSpecificMessage(isUnknownReplyPayload);
105
+ export const isNotePressPayload = isSpecificPayload('Note Press');
106
+ export const isNotePress = isSpecificMessage(isNotePressPayload);
107
+ export const isChannelPressurePayload = isSpecificPayload('Channel Pressure');
108
+ export const isChannelPressure = isSpecificMessage(isChannelPressurePayload);
109
+ export const isNoteReleasePayload = isSpecificPayload('Note Release');
110
+ export const isNoteRelease = isSpecificMessage(isNoteReleasePayload);
111
+ export const isControlChangePayload = isSpecificPayload('Control Change');
112
+ export const isControlChange = isSpecificMessage(isControlChangePayload);
113
+ export const isTouchpadReleasePayload = isSpecificPayload('Touchpad Release');
114
+ export const isTouchpadRelease = isSpecificMessage(isTouchpadReleasePayload);
115
+ export const isPitchBendChangePayload = isSpecificPayload('Pitch Bend Change');
116
+ export const isPitchBendChange = isSpecificMessage(isPitchBendChangePayload);
117
+ export const isTouchpadPositionUpdatePayload = isSpecificPayload('Touchpad Position Update');
118
+ export const isTouchpadPositionUpdate = isSpecificMessage(isTouchpadPositionUpdatePayload);
119
+ //# sourceMappingURL=Parsing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Parsing.js","sourceRoot":"","sources":["../../../src/internal/Parsing.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAIvC,+EAA+E;AAC/E,mDAAmD;AAEnD;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,IAA4B,EACY,EAAE,CAC1C,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,EAAE,WAAW,EAAE,GAAG,GAAG,EAAE,EAAE,EAAE,CAAC,CAAC;IAC7C,GAAG,GAAG;IACN,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,uBAAuB,CAAC,WAAW,CAAC;CAClD,CAAC,CAAC,CAAA;AAEL;;;;GAIG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAWzC,IAA4B,EAQ5B,EAAE,CACF,MAAM,CAAC,QAAQ,CACb,IAAI,EACJ,EAAE,CAAC,EAAE,IAAqB,EAAE,CAAC,EAAE,IAAqB,EAAE,EACtD,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE;IACf,MAAM,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAA;IACxC,MAAM,KAAK,GAAG,sBAAsB,CAAC,WAAW,CAAC;QAC/C,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,EAAE,WAAW,CAAC,KAAK,EAAE;QAClC,CAAC,CAAC,wBAAwB,CAAC,WAAW,CAAC;YACrC,CAAC,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,EAAE,WAAW,CAAC,KAAK,EAAE;YAClC,CAAC,CAAC,WAAW,CAAC,IAAI,KAAK,kBAAkB;gBACvC,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE;gBACtB,CAAC,CAAC,GAA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AM,CAAC,MAAM,sBAAsB,GACjC,iBAAiB,CAAuB,gBAAgB,CAAC,CAAA;AAE3D,MAAM,CAAC,MAAM,eAAe,GAAG,iBAAiB,CAAC,sBAAsB,CAAC,CAAA;AAOxE,MAAM,CAAC,MAAM,wBAAwB,GACnC,iBAAiB,CAAyB,kBAAkB,CAAC,CAAA;AAE/D,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,wBAAwB,CAAC,CAAA;AAW5E,MAAM,CAAC,MAAM,wBAAwB,GACnC,iBAAiB,CAAyB,mBAAmB,CAAC,CAAA;AAEhE,MAAM,CAAC,MAAM,iBAAiB,GAAG,iBAAiB,CAAC,wBAAwB,CAAC,CAAA;AAW5E,MAAM,CAAC,MAAM,+BAA+B,GAC1C,iBAAiB,CAAgC,0BAA0B,CAAC,CAAA;AAE9E,MAAM,CAAC,MAAM,wBAAwB,GAAG,iBAAiB,CACvD,+BAA+B,CAChC,CAAA"}
@@ -0,0 +1,105 @@
1
+ /** biome-ignore-all lint/style/useShorthandFunctionType: It's a nice way to
2
+ * preserve JSDoc comments attached to the function signature */
3
+ import * as Cause from 'effect/Cause';
4
+ import * as Effect from 'effect/Effect';
5
+ import * as EFunction from 'effect/Function';
6
+ import * as Stream from 'effect/Stream';
7
+ import * as EMIDIAccess from './EMIDIAccess.js';
8
+ import * as EMIDIInput from './EMIDIInput.js';
9
+ import * as EMIDIOutput from './EMIDIOutput.js';
10
+ import * as Util from './Util.js';
11
+ // TODO: make an experiment to see if listeners are automatically removed on disconnect
12
+ /**
13
+ * Set of possible ways to react when the MIDI-related event will have relevant
14
+ * field be null. Although there should be no sane scenario where it would be
15
+ * the case, it's still allowed by the spec, and for a better UX this lib lets
16
+ * the developer make a decision on how to handle such cases.
17
+ *
18
+ * - `fail` will add an error into a signature of a stream, allowing the user to
19
+ * handle it
20
+ * - `die` will throw a defect, which won't be reflected as a possible failure
21
+ * in types
22
+ * - `ignore` will just silently remove such events from the stream
23
+ * - `passthrough` - will pass such events with an unmodified content of the
24
+ * relevant field
25
+ *
26
+ * @internal
27
+ */
28
+ const validOnNullStrategies = new Set([
29
+ 'fail',
30
+ 'die',
31
+ 'ignore',
32
+ 'passthrough',
33
+ ]);
34
+ /**
35
+ * Helper utility to turn MIDI event listeners into effect's Streams.
36
+ *
37
+ * The signature is split into 2 calls, so that you are able at first call pass
38
+ * into generic an interface with `addEventListener` types of the raw web MIDI
39
+ * objects as keys and according event structures as values.
40
+ *
41
+ * **Second call arguments**
42
+ *
43
+ * - `isSelf` - Function determining if the maker was called as an overload with
44
+ * all parameters passed at once, or with them spread by 2 calls. `self` will
45
+ * be later assigned to a `cameFrom` property of the object in the success
46
+ * channel of the stream
47
+ *
48
+ * - `buildConfig` - Function that makes config out of an effectful version
49
+ * (e.g. {@linkcode EMIDIAccess.EMIDIAccessInstance|EMIDIAccess.Instance},
50
+ * {@linkcode EMIDIInput.EMIDIInput}, {@linkcode EMIDIOutput.EMIDIOutput}) of
51
+ * a MIDI object.
52
+ *
53
+ * - `remapValueToContainer` - Callback that maps the value of the event's
54
+ * selected field to an extension of the object inside stream's success
55
+ * channel. All fields of the returned object must always be present and
56
+ * should be consistently nullable, when the incoming event's field is null.
57
+ *
58
+ * @template TEventTypeToEventValueMap An interface with event types of raw Web
59
+ * MIDI objects as keys and according event structures as values. e.g.
60
+ * {@linkcode MIDIAccessEventMap}, {@linkcode MIDIPortEventMap},
61
+ * {@linkcode MIDIInputEventMap}
62
+ *
63
+ * @internal
64
+ */
65
+ export const createStreamMakerFrom = () =>
66
+ /**
67
+ * @param isSelf Function determining if the maker was called as an overload
68
+ * with all parameters passed at once, or with them spread by 2 calls.
69
+ * `self` will be later assigned to a `cameFrom` property of the object in the
70
+ * success channel of the stream
71
+ *
72
+ * @param buildConfig Function that makes config out of an effectful version
73
+ * (e.g. {@linkcode EMIDIAccess.EMIDIAccessInstance|EMIDIAccess.Instance}, {@linkcode EMIDIInput.EMIDIInput},
74
+ * {@linkcode EMIDIOutput.EMIDIOutput}) of a MIDI object.
75
+ *
76
+ * @param remapValueToContainer Callback that maps the `fieldValue` of the
77
+ * event's selected field (`nullableFieldName`) to an extension of the object
78
+ * inside stream's success channel. The value is not null, except when
79
+ * `onNullStrategy` is `'passthrough'`. All fields of the returned object must
80
+ * always be present and should be consistently nullable, if the incoming
81
+ * event's field is null.
82
+ */
83
+ (isSelf, buildConfig, remapValueToContainer) => EFunction.dual(Util.polymorphicCheckInDual(isSelf), (cameFromPolymorphic, options) => Effect.gen(function* () {
84
+ const onNullStrategy = (options?.onExtremelyRareNullableField ?? 'die');
85
+ if (!validOnNullStrategies.has(onNullStrategy))
86
+ throw new Error(`Invalid strategy to handle nullish values: ${onNullStrategy}`);
87
+ const cameFrom = yield* Util.fromPolymorphic(cameFromPolymorphic, isSelf);
88
+ const { tag, eventListener: { target, type }, spanAttributes, nullableFieldName: field, } = buildConfig(cameFrom);
89
+ const missingFieldMessage = `Property ${field} of ${tag} is null`;
90
+ const NullCausedErrorEffect = new Cause.NoSuchElementException(missingFieldMessage);
91
+ return Stream.fromEventListener(target, type, options).pipe(Stream.filter(event => !!event[field] || onNullStrategy !== 'ignore'), Stream.mapEffect(event => event[field] || onNullStrategy === 'passthrough'
92
+ ? Effect.succeed({
93
+ _tag: tag,
94
+ ...remapValueToContainer(event[field]),
95
+ cameFrom,
96
+ capturedAt: new Date(),
97
+ })
98
+ : onNullStrategy === 'fail'
99
+ ? NullCausedErrorEffect
100
+ : Effect.dieMessage(missingFieldMessage)), Stream.withSpan('MIDI Web API event stream', {
101
+ kind: 'producer',
102
+ attributes: { eventType: type, ...spanAttributes },
103
+ }));
104
+ }).pipe(Stream.unwrap));
105
+ //# sourceMappingURL=StreamMaker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StreamMaker.js","sourceRoot":"","sources":["../../../src/internal/StreamMaker.ts"],"names":[],"mappings":"AAAA;gEACgE;AAEhE,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,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CAAA;IAEzB,MAAM,mBAAmB,GAAG,YAAY,KAAK,OAAO,GAAG,UAAU,CAAA;IACjE,MAAM,qBAAqB,GAAG,IAAI,KAAK,CAAC,sBAAsB,CAC5D,mBAAmB,CACpB,CAAA;IAED,OAAO,MAAM,CAAC,iBAAiB,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CACzD,MAAM,CAAC,MAAM,CACX,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,cAAc,KAAK,QAAQ,CACvD,EACD,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CACvB,KAAK,CAAC,KAAK,CAAC,IAAI,cAAc,KAAK,aAAa;QAC9C,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;YACb,IAAI,EAAE,GAAG;YACT,GAAG,qBAAqB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YACtC,QAAQ;YACR,UAAU,EAAE,IAAI,IAAI,EAAE;SACvB,CAAC;QACJ,CAAC,CAAC,cAAc,KAAK,MAAM;YACzB,CAAC,CAAC,qBAAqB;YACvB,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC,mBAAmB,CAAC,CAC7C,EACD,MAAM,CAAC,QAAQ,CAAC,2BAA2B,EAAE;QAC3C,IAAI,EAAE,UAAU;QAChB,UAAU,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,cAAc,EAAE;KACnD,CAAC,CACH,CAAA;AACH,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAQ,CAChC,CAAA"}
@@ -0,0 +1,59 @@
1
+ import * as EArray from 'effect/Array';
2
+ import * as Effect from 'effect/Effect';
3
+ import * as EFunction from 'effect/Function';
4
+ import * as Record from 'effect/Record';
5
+ import * as Stream from 'effect/Stream';
6
+ import * as Struct from 'effect/Struct';
7
+ export const midiPortStaticFields = [
8
+ 'id',
9
+ 'name',
10
+ 'manufacturer',
11
+ 'version',
12
+ 'type',
13
+ ];
14
+ export const getStaticMIDIPortInfo = (port) => Struct.pick(port, ...midiPortStaticFields);
15
+ export const polymorphicCheckInDual = (is) => (args) => Effect.isEffect(args[0]) || is(args[0]);
16
+ export function fromPolymorphic(polymorphicValue, is) {
17
+ const check = (value) => is(value)
18
+ ? Effect.succeed(value)
19
+ : Effect.dieMessage('Assertion failed on polymorphic value');
20
+ return Effect.isEffect(polymorphicValue)
21
+ ? Effect.flatMap(polymorphicValue, check)
22
+ : check(polymorphicValue);
23
+ }
24
+ /**
25
+ * @internal
26
+ */
27
+ const isEqual = () => (expected) => (self) => Effect.map(self, current => (current === expected));
28
+ export const isCertainDeviceState = isEqual();
29
+ export const isCertainConnectionState = isEqual();
30
+ export const isDeviceConnected = isCertainDeviceState('connected');
31
+ export const isDeviceDisconnected = isCertainDeviceState('disconnected');
32
+ export const isConnectionOpen = isCertainConnectionState('open');
33
+ export const isConnectionPending = isCertainConnectionState('pending');
34
+ export const isConnectionClosed = isCertainConnectionState('closed');
35
+ export const mapToGlidingStringLogOfLimitedEntriesCount = (windowSize, show, objectify) => (self) => {
36
+ if (windowSize < 1)
37
+ throw new Error('Window size should be greater than 0');
38
+ return Stream.mapAccum(self, { text: '', entrySizeLog: [] }, ({ entrySizeLog: oldLog, text: oldText }, current) => {
39
+ const currMapped = EFunction.pipe(objectify(current), Record.toEntries, EArray.map(EArray.join(': ')), EArray.join(', ')) + '\n';
40
+ const potentiallyShiftedLog = oldLog.length >= windowSize
41
+ ? oldLog.slice(...(show === 'latestFirst' ? [0, -1] : [1]))
42
+ : oldLog;
43
+ const potentiallyShiftedText = oldLog.length >= windowSize
44
+ ? oldText.slice(...(show === 'latestFirst'
45
+ ? // biome-ignore lint/style/noNonNullAssertion: oldLog guaranteed to have at least one element by oldLog.length >= windowSize
46
+ [0, -oldLog.at(-1)]
47
+ : // biome-ignore lint/style/noNonNullAssertion: oldLog guaranteed to have at least one element by oldLog.length >= windowSize
48
+ [oldLog.at(0)]))
49
+ : oldText;
50
+ const text = show === 'latestFirst'
51
+ ? currMapped + potentiallyShiftedText
52
+ : potentiallyShiftedText + currMapped;
53
+ const entrySizeLog = show === 'latestFirst'
54
+ ? [currMapped.length, ...potentiallyShiftedLog]
55
+ : [...potentiallyShiftedLog, currMapped.length];
56
+ return [{ text, entrySizeLog }, text];
57
+ });
58
+ };
59
+ //# sourceMappingURL=Util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Util.js","sourceRoot":"","sources":["../../../src/internal/Util.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,cAAc,CAAA;AAEtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAA;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAIvC,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,IAAI;IACJ,MAAM;IACN,cAAc;IACd,SAAS;IACT,MAAM;CACE,CAAA;AAIV,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,IAA0C,EAC1C,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,oBAAoB,CAAC,CAAA;AAyB/C,MAAM,CAAC,MAAM,sBAAsB,GACjC,CAAC,EAA6B,EAAE,EAAE,CAAC,CAAC,IAAgB,EAAE,EAAE,CACtD,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;AAE3C,MAAM,UAAU,eAAe,CAC7B,gBAA4C,EAC5C,EAAuC;IAEvC,MAAM,KAAK,GAAG,CAAC,KAAQ,EAAE,EAAE,CACzB,EAAE,CAAC,KAAK,CAAC;QACP,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,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AC,GAAG,qBAAqB,EAAE,UAAU,CAAC,MAAM,CAAC,CAAA;QAEnD,OAAO,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,EAAE,IAAI,CAAC,CAAA;IACvC,CAAC,CACF,CAAA;AACH,CAAC,CAAA"}
@@ -0,0 +1,53 @@
1
+ /** biome-ignore-all lint/style/useShorthandFunctionType: It's a nice way to
2
+ * preserve JSDoc comments attached to the function signature */
3
+ import * as Effect from 'effect/Effect';
4
+ import * as EFunction from 'effect/Function';
5
+ import * as EMIDIAccess from '../EMIDIAccess.js';
6
+ import * as EMIDIInput from '../EMIDIInput.js';
7
+ import * as EMIDIOutput from '../EMIDIOutput.js';
8
+ import * as MIDIErrors from '../MIDIErrors.js';
9
+ /**
10
+ *
11
+ * @internal
12
+ */
13
+ const getPortByIdAndRemap = (handlers) => EFunction.dual(2, (polymorphicAccess, portId) => Effect.flatMap(EMIDIAccess.simplify(polymorphicAccess), access => {
14
+ const rawAccess = EMIDIAccess.assumeImpl(access)._access;
15
+ let rawPort = rawAccess.inputs.get(portId);
16
+ if (rawPort)
17
+ return handlers.onInputFound(rawPort);
18
+ rawPort = rawAccess.outputs.get(portId);
19
+ if (rawPort)
20
+ return handlers.onOutputFound(rawPort);
21
+ return new MIDIErrors.PortNotFoundError({
22
+ portId,
23
+ });
24
+ }));
25
+ /**
26
+ *
27
+ * If you want to ensure the type of returned port match the type of ID, use
28
+ * type-specific getters {@linkcode getInputByPortIdAndAccess} and
29
+ * {@linkcode getOutputByPortIdAndAccess}, because in runtime, these branded
30
+ * port IDs passed as function arguments, are just strings and cannot ensure
31
+ * soundness
32
+ */
33
+ export const getPortByPortIdAndAccess = getPortByIdAndRemap({
34
+ onInputFound: EFunction.flow(EMIDIInput.make, Effect.succeed),
35
+ onOutputFound: EFunction.flow(EMIDIOutput.make, Effect.succeed),
36
+ });
37
+ /**
38
+ *
39
+ *
40
+ */
41
+ export const getInputByPortIdAndAccess = getPortByIdAndRemap({
42
+ onInputFound: EFunction.flow(EMIDIInput.make, Effect.succeed),
43
+ onOutputFound: rawOutput => Effect.dieMessage(`Assertion failed: getInputById expected id=${rawOutput.id} to point at input, but it points at output instead`),
44
+ });
45
+ /**
46
+ *
47
+ *
48
+ */
49
+ export const getOutputByPortIdAndAccess = getPortByIdAndRemap({
50
+ onInputFound: rawInput => Effect.dieMessage(`Assertion failed: getOutputById expected id=${rawInput.id} to point at output, but it points at input instead`),
51
+ onOutputFound: EFunction.flow(EMIDIOutput.make, Effect.succeed),
52
+ });
53
+ //# sourceMappingURL=getPortByPortIdAndAccess.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPortByPortIdAndAccess.js","sourceRoot":"","sources":["../../../../src/internal/getPortByPortId/getPortByPortIdAndAccess.ts"],"names":[],"mappings":"AAAA;gEACgE;AAEhE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAA;AAE5C,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAA;AAC9C,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAA;AAEhD,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAA;AAE9C;;;GAGG;AACH,MAAM,mBAAmB,GAAG,CAO1B,QAOD,EAOC,EAAE,CACF,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,iBAAiB,EAAE,MAAM,EAAE,EAAE,CAC9C,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC,EAAE;IAC/D,MAAM,SAAS,GAAG,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,OAAO,CAAA;IAExD,IAAI,OAAO,GACT,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;IAE9B,IAAI,OAAO;QAAE,OAAO,QAAQ,CAAC,YAAY,CAAC,OAAO,CAAC,C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ext = (id) => Get.getPortByPortIdAndAccess(EMIDIAccess.EMIDIAccess, id);
8
+ /**
9
+ *
10
+ *
11
+ */
12
+ export const getInputByPortIdInContext = (id) => Get.getInputByPortIdAndAccess(EMIDIAccess.EMIDIAccess, id);
13
+ /**
14
+ *
15
+ *
16
+ */
17
+ export const getOutputByPortIdInContext = (id) => Get.getOutputByPortIdAndAccess(EMIDIAccess.EMIDIAccess, id);
18
+ //# sourceMappingURL=getPortByPortIdInContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getPortByPortIdInContext.js","sourceRoot":"","sources":["../../../../src/internal/getPortByPortId/getPortByPortIdInContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAA;AAIhD,OAAO,KAAK,GAAG,MAAM,+BAA+B,CAAA;AAEpD;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,EAAoB,EAAE,EAAE,CAC/D,GAAG,CAAC,wBAAwB,CAAC,WAAW,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAE3D;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,EAAiB,EAAE,EAAE,CAC7D,GAAG,CAAC,yBAAyB,CAAC,WAAW,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAE5D;;;GAGG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,EAAkB,EAAE,EAAE,CAC/D,GAAG,CAAC,0BAA0B,CAAC,WAAW,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA"}