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,114 @@
1
+ import * as Brand from 'effect/Brand'
2
+
3
+ import * as EMIDIPort from './EMIDIPort.ts'
4
+ import * as StreamMaker from './StreamMaker.ts'
5
+ import * as Util from './Util.ts'
6
+
7
+ // TODO: implement scoping of midi access that will clean up all message queues
8
+ // and streams, and remove listeners
9
+
10
+ // TODO: implement scope inheritance
11
+
12
+ /**
13
+ * Thin wrapper around {@linkcode MIDIInput} instance. Will be seen in all
14
+ * external code.
15
+ */
16
+ export interface EMIDIInput extends EMIDIPort.EMIDIPort<'input'> {}
17
+
18
+ /**
19
+ * Thin wrapper around {@linkcode MIDIInput} instance giving access to the
20
+ * actual field storing it.
21
+ * @internal
22
+ */
23
+ interface EMIDIInputImpl extends EMIDIPort.EMIDIPortImpl<MIDIInput, 'input'> {}
24
+
25
+ /**
26
+ * Validates the raw MIDI input port, and puts it into a field hidden from the
27
+ * client's code
28
+ *
29
+ * @internal
30
+ */
31
+ const makeImpl = (rawInput: MIDIInput): EMIDIInputImpl =>
32
+ EMIDIPort.makeImpl(rawInput, 'input', globalThis.MIDIInput)
33
+
34
+ /**
35
+ * Asserts an object to be valid EMIDIInput and casts it to internal
36
+ * implementation type
37
+ *
38
+ * @internal
39
+ */
40
+ const assertImpl = (input: unknown) => {
41
+ if (!isImpl(input)) throw new Error('Failed to cast to EMIDIInputImpl')
42
+ return input
43
+ }
44
+
45
+ /**
46
+ * Asserts an object to be valid EMIDIInput
47
+ */
48
+ export const assert: (input: unknown) => EMIDIInput = assertImpl
49
+
50
+ /**
51
+ * @internal
52
+ */
53
+ const assumeImpl = (input: EMIDIInput) => input as EMIDIInputImpl
54
+
55
+ /**
56
+ *
57
+ *
58
+ * @internal
59
+ */
60
+ export const make: (rawInput: MIDIInput) => EMIDIInput = makeImpl
61
+
62
+ /**
63
+ *
64
+ *
65
+ * @internal
66
+ */
67
+ const isImpl: (input: unknown) => input is EMIDIInputImpl =
68
+ EMIDIPort.isImplOfSpecificType('input', globalThis.MIDIInput)
69
+
70
+ /**
71
+ *
72
+ *
73
+ */
74
+ export const is: (input: unknown) => input is EMIDIInput = isImpl
75
+
76
+ /**
77
+ * [MIDIMessageEvent MDN
78
+ * Reference](https://developer.mozilla.org/docs/Web/API/MIDIMessageEvent)
79
+ *
80
+ * MIDI spec says that synthetically built `MIDIMessageEvent`s can have `data`
81
+ * field equal to `null`, but when coming from the browser, they won't. The
82
+ * default behavior is to defect on `null`.
83
+ */
84
+ export const makeMessagesStreamByPort =
85
+ StreamMaker.createStreamMakerFrom<MIDIInputEventMap>()(
86
+ is,
87
+ input => ({
88
+ tag: 'MIDIMessage',
89
+ eventListener: { target: assumeImpl(input)._port, type: 'midimessage' },
90
+ spanAttributes: {
91
+ spanTargetName: 'MIDI port',
92
+ port: Util.getStaticMIDIPortInfo(input),
93
+ },
94
+ nullableFieldName: 'data',
95
+ }),
96
+ midiMessage => ({ midiMessage }),
97
+ )
98
+
99
+ /**
100
+ *
101
+ *
102
+ */
103
+ export type PolymorphicInput<E, R> = EMIDIPort.PolymorphicPort<E, R, 'input'>
104
+
105
+ /**
106
+ *
107
+ *
108
+ */
109
+ export type PolymorphicInputClean = EMIDIPort.PolymorphicPortClean<'input'>
110
+
111
+ export type Id = EMIDIPort.Id<'input'>
112
+ export const Id = Brand.nominal<Id>()
113
+
114
+ export interface InputIdToInstanceMap extends Record<Id, EMIDIInput> {}
@@ -0,0 +1,231 @@
1
+ /** biome-ignore-all lint/style/useShorthandFunctionType: It's a nice way to
2
+ * preserve JSDoc comments attached to the function signature */
3
+
4
+ import * as Brand from 'effect/Brand'
5
+ import * as Effect from 'effect/Effect'
6
+ import * as EFunction from 'effect/Function'
7
+
8
+ import * as EMIDIPort from './EMIDIPort.ts'
9
+ import * as MIDIErrors from './MIDIErrors.ts'
10
+ import * as Util from './Util.ts'
11
+
12
+ /**
13
+ * Thin wrapper around {@linkcode MIDIOutput} instance. Will be seen in all
14
+ * external code.
15
+ */
16
+ export interface EMIDIOutput extends EMIDIPort.EMIDIPort<'output'> {}
17
+
18
+ /**
19
+ * Thin wrapper around {@linkcode MIDIOutput} instance giving access to the
20
+ * actual field storing it.
21
+ * @internal
22
+ */
23
+ interface EMIDIOutputImpl
24
+ extends EMIDIPort.EMIDIPortImpl<MIDIOutput, 'output'> {}
25
+
26
+ /**
27
+ * Validates the raw MIDI output port, and puts it into a field hidden from the
28
+ * client's code
29
+ *
30
+ * @internal
31
+ */
32
+ const makeImpl = (rawOutput: MIDIOutput): EMIDIOutputImpl =>
33
+ EMIDIPort.makeImpl(rawOutput, 'output', globalThis.MIDIOutput)
34
+
35
+ /**
36
+ * Asserts an object to be valid EMIDIOutput and casts it to
37
+ * internal implementation type
38
+ *
39
+ * @internal
40
+ */
41
+ const assertImpl = (output: unknown) => {
42
+ if (!isImpl(output))
43
+ throw new Error('Assertion failed: Not a EMIDIOutputImpl')
44
+ return output
45
+ }
46
+
47
+ /**
48
+ * Asserts an object to be valid EMIDIOutput
49
+ */
50
+ export const assert: (output: unknown) => EMIDIOutput = assertImpl
51
+
52
+ /**
53
+ * Casts
54
+ * @internal
55
+ */
56
+ const assumeImpl = (output: EMIDIOutput) => output as EMIDIOutputImpl
57
+
58
+ /**
59
+ *
60
+ * @internal
61
+ */
62
+ export const make: (rawOutput: MIDIOutput) => EMIDIOutput = makeImpl
63
+
64
+ /**
65
+ *
66
+ * @internal
67
+ */
68
+ const isImpl = EMIDIPort.isImplOfSpecificType('output', globalThis.MIDIOutput)
69
+
70
+ /**
71
+ *
72
+ */
73
+ export const is: (output: unknown) => output is EMIDIOutput = isImpl
74
+
75
+ /**
76
+ *
77
+ *
78
+ * @internal
79
+ */
80
+ const simplify = <E = never, R = never>(
81
+ polymorphicPort: PolymorphicOutput<E, R>,
82
+ ) => Util.fromPolymorphic(polymorphicPort, is)
83
+
84
+ /**
85
+ * If `midiMessage` is a System Exclusive message, and the `MIDIAccess` did not
86
+ * enable System Exclusive access, an `InvalidAccessError` exception will be
87
+ * thrown
88
+ *
89
+ * If the port is `"connected"` and the connection is `"closed"`, asynchronously
90
+ * tries to open the port. It's unclear in the spec if potential error of `open`
91
+ * call would result in an `InvalidAccessError` error coming from the `send`
92
+ * method itself.
93
+ *
94
+ * @returns An effect with the same port for easier chaining of operations
95
+ */
96
+ export const send: DualSendMIDIMessageFromPort = EFunction.dual<
97
+ SendMIDIMessagePortLast,
98
+ SendMIDIMessagePortFirst
99
+ >(
100
+ Util.polymorphicCheckInDual(is),
101
+ Effect.fn('EMIDIOutput.send')(
102
+ function* (polymorphicOutput, midiMessage, timestamp) {
103
+ const output = yield* simplify(polymorphicOutput)
104
+
105
+ yield* Effect.annotateCurrentSpan({
106
+ midiMessage,
107
+ timestamp,
108
+ port: Util.getStaticMIDIPortInfo(output),
109
+ })
110
+
111
+ yield* Effect.try({
112
+ try: () => assumeImpl(output)._port.send(midiMessage, timestamp),
113
+ catch: MIDIErrors.remapErrorByName(
114
+ {
115
+ NotAllowedError: MIDIErrors.CannotSendSysexMessageError,
116
+ // InvalidAccessError is kept for compatibility reason
117
+ // (https://github.com/WebAudio/web-midi-api/pull/278):
118
+ InvalidAccessError: MIDIErrors.CannotSendSysexMessageError,
119
+
120
+ InvalidStateError: MIDIErrors.CannotSendToDisconnectedPortError,
121
+ TypeError: MIDIErrors.MalformedMIDIMessageError,
122
+ },
123
+ 'EMIDIOutput.send error handling absurd',
124
+ { portId: output.id, midiMessage: [...midiMessage] },
125
+ ),
126
+ })
127
+
128
+ return output as EMIDIOutput
129
+ },
130
+ ),
131
+ )
132
+
133
+ /**
134
+ * Clears any enqueued send data that has not yet been sent from the
135
+ * `MIDIOutput`'s queue. The browser will ensure the MIDI stream is left in a
136
+ * good state, and if the output port is in the middle of a sysex message, a
137
+ * sysex termination byte (`0xf7`) will be sent.
138
+ *
139
+ * @param polymorphicOutput An effectful output port
140
+ *
141
+ * @returns An effect with the same port for easier chaining of operations
142
+ * @experimental Supported only in Firefox. {@link https://caniuse.com/mdn-api_midioutput_clear|Can I use - MIDIOutput API: clear}
143
+ * @see {@link https://www.w3.org/TR/webmidi/#dom-midioutput-clear|Web MIDI spec}, {@link https://developer.mozilla.org/en-US/docs/Web/API/MIDIOutput/clear|MDN reference}
144
+ */
145
+ export const clear = Effect.fn('EMIDIOutput.clear')(function* <
146
+ E = never,
147
+ R = never,
148
+ >(polymorphicOutput: PolymorphicOutput<E, R>) {
149
+ const output = yield* simplify(polymorphicOutput)
150
+
151
+ yield* Effect.annotateCurrentSpan({
152
+ port: Util.getStaticMIDIPortInfo(output),
153
+ })
154
+
155
+ yield* Effect.try({
156
+ // @ts-expect-error even though `.clear` is in spec, the API is not
157
+ // supported in at least 2 major browsers, hence doesn't meet the condition
158
+ // to be included into TS's DOM types
159
+ try: () => assumeImpl(output)._port.clear(),
160
+ catch: MIDIErrors.remapErrorByName(
161
+ {
162
+ // TODO: test this
163
+ // most likely it would be something like `TypeError: Undefined is not a function`
164
+ TypeError: MIDIErrors.ClearingSendingQueueIsNotSupportedError,
165
+ NotSupportedError: MIDIErrors.ClearingSendingQueueIsNotSupportedError,
166
+ },
167
+ 'EMIDIOutput.clear error handling absurd',
168
+ { portId: output.id },
169
+ ),
170
+ })
171
+
172
+ return output
173
+ })
174
+
175
+ /**
176
+ *
177
+ *
178
+ */
179
+ export type PolymorphicOutput<E, R> = EMIDIPort.PolymorphicPort<E, R, 'output'>
180
+
181
+ /**
182
+ *
183
+ *
184
+ */
185
+ export type PolymorphicOutputClean = EMIDIPort.PolymorphicPortClean<'output'>
186
+
187
+ export type SendFromPortArgs = [
188
+ midiMessage: Iterable<number>,
189
+ timestamp?: DOMHighResTimeStamp,
190
+ ]
191
+
192
+ export interface DualSendMIDIMessageFromPort
193
+ extends SendMIDIMessagePortLast,
194
+ SendMIDIMessagePortFirst {}
195
+
196
+ export interface SendMIDIMessagePortLast {
197
+ /**
198
+ *
199
+ */
200
+ (
201
+ ...args: SendFromPortArgs
202
+ ): {
203
+ /**
204
+ *
205
+ */
206
+ <E = never, R = never>(
207
+ polymorphicOutput: PolymorphicOutput<E, R>,
208
+ ): SentMessageEffectFromPort<E, R>
209
+ }
210
+ }
211
+
212
+ export interface SendMIDIMessagePortFirst {
213
+ /**
214
+ *
215
+ */
216
+ <E = never, R = never>(
217
+ polymorphicOutput: PolymorphicOutput<E, R>,
218
+ ...args: SendFromPortArgs
219
+ ): SentMessageEffectFromPort<E, R>
220
+ }
221
+
222
+ /**
223
+ *
224
+ */
225
+ export interface SentMessageEffectFromPort<E = never, R = never>
226
+ extends Util.SentMessageEffectFrom<EMIDIOutput, E, R> {}
227
+
228
+ export type Id = EMIDIPort.Id<'output'>
229
+ export const Id = Brand.nominal<Id>()
230
+
231
+ export interface OutputIdToInstanceMap extends Record<Id, EMIDIOutput> {}
@@ -0,0 +1,239 @@
1
+ /** biome-ignore-all lint/style/useShorthandFunctionType: It's a nice way to
2
+ * preserve JSDoc comments attached to the function signature */
3
+
4
+ import * as Brand from 'effect/Brand'
5
+ import * as Equal from 'effect/Equal'
6
+ import * as Hash from 'effect/Hash'
7
+ import * as Inspectable from 'effect/Inspectable'
8
+ import * as Pipeable from 'effect/Pipeable'
9
+
10
+ import type * as EMIDIInput from './EMIDIInput.ts'
11
+ import type * as EMIDIOutput from './EMIDIOutput.ts'
12
+ import type * as Util from './Util.ts'
13
+
14
+ /**
15
+ * Unique symbol used for distinguishing {@linkcode EMIDIPort} instances
16
+ * from other objects at both runtime and type-level
17
+ * @internal
18
+ */
19
+ const TypeId: unique symbol = Symbol.for('effect-web-midi/EMIDIPort')
20
+
21
+ /**
22
+ * Unique symbol used for distinguishing {@linkcode EMIDIPort} instances
23
+ * from other objects at both runtime and type-level
24
+ */
25
+ export type TypeId = typeof TypeId
26
+
27
+ /**
28
+ * Prototype of all {@linkcode EMIDIPort} instances
29
+ * @internal
30
+ */
31
+ const CommonProto = {
32
+ _tag: 'EMIDIPort' as const,
33
+
34
+ [TypeId]: TypeId,
35
+
36
+ [Hash.symbol]() {
37
+ return Hash.string(this.id)
38
+ },
39
+
40
+ [Equal.symbol](that: Equal.Equal) {
41
+ return 'id' in that && this.id === that.id
42
+ },
43
+
44
+ pipe() {
45
+ // biome-ignore lint/complexity/noArguments: Effect's tradition
46
+ return Pipeable.pipeArguments(this, arguments)
47
+ },
48
+
49
+ toString() {
50
+ return Inspectable.format(this.toJSON())
51
+ },
52
+
53
+ toJSON() {
54
+ return {
55
+ _id: 'EMIDIPort',
56
+ id: this.id,
57
+ name: this.name,
58
+ manufacturer: this.manufacturer,
59
+ version: this.version,
60
+ type: this.type,
61
+ }
62
+ },
63
+
64
+ [Inspectable.NodeInspectSymbol]() {
65
+ return this.toJSON()
66
+ },
67
+
68
+ get id() {
69
+ return BothId(assumeImpl(this)._port.id)
70
+ },
71
+ get name() {
72
+ return assumeImpl(this)._port.name
73
+ },
74
+ get manufacturer() {
75
+ return assumeImpl(this)._port.manufacturer
76
+ },
77
+ get version() {
78
+ return assumeImpl(this)._port.version
79
+ },
80
+ get type() {
81
+ return assumeImpl(this)._port.type
82
+ },
83
+ } satisfies EMIDIPort
84
+
85
+ /**
86
+ * Thin wrapper around {@linkcode MIDIPort} instance. Will be seen in all
87
+ * external code.
88
+ */
89
+ export interface EMIDIPort<TMIDIPortType extends MIDIPortType = MIDIPortType>
90
+ extends Equal.Equal,
91
+ Pipeable.Pipeable,
92
+ Inspectable.Inspectable,
93
+ Pick<MIDIPort, 'version' | 'name' | 'manufacturer'> {
94
+ /**
95
+ * The **`id`** read-only property of the MIDIPort interface returns the unique ID of the port.
96
+ *
97
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MIDIPort/id)
98
+ */
99
+ readonly id: Id<TMIDIPortType>
100
+ readonly [TypeId]: TypeId
101
+ readonly _tag: 'EMIDIPort'
102
+ readonly type: TMIDIPortType
103
+ }
104
+
105
+ /**
106
+ * Thin wrapper around {@linkcode MIDIPort} instance giving access to the
107
+ * actual field storing it.
108
+ * @internal
109
+ */
110
+ export interface EMIDIPortImpl<
111
+ TPort extends MIDIPort = MIDIPort,
112
+ TPortType extends MIDIPortType = MIDIPortType,
113
+ > extends EMIDIPort<TPortType> {
114
+ readonly _port: TPort
115
+ }
116
+
117
+ /**
118
+ *
119
+ *
120
+ * @internal
121
+ */
122
+ export const makeImpl = <
123
+ TPort extends MIDIPort,
124
+ TPortType extends MIDIPortType,
125
+ >(
126
+ port: NoInfer<TPort>,
127
+ type: TPortType,
128
+ ClassToAssertInheritance: new (...args: unknown[]) => TPort,
129
+ ): EMIDIPortImpl<TPort, TPortType> => {
130
+ if (port.type !== type || !(port instanceof ClassToAssertInheritance))
131
+ throw new Error(`EMIDIPort constructor accepts only ${type} ports`)
132
+
133
+ const instance = Object.create(CommonProto)
134
+ instance._port = port
135
+ return instance
136
+ }
137
+
138
+ /**
139
+ * Asserts an object to be valid EMIDIPort and casts it to internal
140
+ * implementation type
141
+ *
142
+ * @internal
143
+ */
144
+ const assertImpl = (port: unknown) => {
145
+ if (!isGeneralImpl(port)) throw new Error('Failed to cast to EMIDIPort')
146
+ return port
147
+ }
148
+
149
+ /**
150
+ * Asserts an object to be valid EMIDIPort
151
+ */
152
+ export const assert: (port: unknown) => EMIDIPort = assertImpl
153
+
154
+ /**
155
+ * @internal
156
+ */
157
+ export const assumeImpl = (port: EMIDIPort) => port as EMIDIPortImpl
158
+
159
+ /**
160
+ *
161
+ *
162
+ * @internal
163
+ */
164
+ const isGeneralImpl = (port: unknown): port is EMIDIPortImpl =>
165
+ typeof port === 'object' &&
166
+ port !== null &&
167
+ Object.getPrototypeOf(port) === CommonProto &&
168
+ TypeId in port &&
169
+ 'type' in port &&
170
+ '_port' in port &&
171
+ typeof port._port === 'object' &&
172
+ port._port instanceof MIDIPort
173
+
174
+ /**
175
+ *
176
+ *
177
+ */
178
+ export type PolymorphicPort<
179
+ E,
180
+ R,
181
+ TMIDIPortType extends MIDIPortType = MIDIPortType,
182
+ > = Util.PolymorphicEffect<EMIDIPort<TMIDIPortType>, E, R>
183
+
184
+ /**
185
+ *
186
+ *
187
+ */
188
+ export type PolymorphicPortClean<
189
+ TMIDIPortType extends MIDIPortType = MIDIPortType,
190
+ > = PolymorphicPort<never, never, TMIDIPortType>
191
+
192
+ export type ExtractTypeFromPort<TPort extends EMIDIPort> =
193
+ TPort extends EMIDIPort<infer TPortType> ? TPortType : never
194
+
195
+ /**
196
+ *
197
+ *
198
+ * @internal
199
+ */
200
+ export const isImplOfSpecificType =
201
+ <const TPortType extends MIDIPortType, TPort extends MIDIPort>(
202
+ type: TPortType,
203
+ ClassToAssertInheritance: new (...args: unknown[]) => TPort,
204
+ ) =>
205
+ (port: unknown): port is EMIDIPortImpl<TPort, TPortType> => {
206
+ if (!ClassToAssertInheritance)
207
+ throw new Error(
208
+ 'Called in a context where ClassToAssertInheritance is falsy, probably on a platform where MIDI APIs are not supported, like node.js or bun',
209
+ )
210
+
211
+ return (
212
+ isGeneralImpl(port) &&
213
+ port.type === type &&
214
+ port._port instanceof ClassToAssertInheritance
215
+ )
216
+ }
217
+
218
+ /**
219
+ *
220
+ *
221
+ */
222
+ export const is: (port: unknown) => port is EMIDIPort = isGeneralImpl
223
+
224
+ /**
225
+ * Unique identifier of the MIDI port.
226
+ *
227
+ * [MDN Reference](https://developer.mozilla.org/docs/Web/API/MIDIPort/id)
228
+ */
229
+ export type Id<TPortType extends MIDIPortType> =
230
+ // for distribution
231
+ TPortType extends MIDIPortType
232
+ ? Brand.Branded<string, 'MIDIPortId'> & Brand.Brand<TPortType>
233
+ : never
234
+
235
+ export type BothId = Id<MIDIPortType>
236
+ export const BothId = Brand.nominal<BothId>()
237
+
238
+ export type BothIdToBothInstanceMap = EMIDIInput.InputIdToInstanceMap &
239
+ EMIDIOutput.OutputIdToInstanceMap