effect-web-midi 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/README.md +7 -0
  2. package/dist/index.js +2 -0
  3. package/dist/index.js.map +1 -0
  4. package/dist/src/EMIDIAccess.js +68 -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 +225 -0
  9. package/dist/src/EMIDIOutput.js.map +1 -0
  10. package/dist/src/EMIDIPort.js +213 -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/Parsing.js +2 -0
  15. package/dist/src/Parsing.js.map +1 -0
  16. package/dist/src/StreamMaker.js +1 -0
  17. package/dist/src/StreamMaker.js.map +1 -0
  18. package/dist/src/Util.js +4 -0
  19. package/dist/src/Util.js.map +1 -0
  20. package/dist/src/index.js +9 -0
  21. package/dist/src/index.js.map +1 -0
  22. package/dist/src/internal/EMIDIAccess.js +409 -0
  23. package/dist/src/internal/EMIDIAccess.js.map +1 -0
  24. package/dist/src/internal/EMIDIInput.js +69 -0
  25. package/dist/src/internal/EMIDIInput.js.map +1 -0
  26. package/dist/src/internal/EMIDIOutput.js +120 -0
  27. package/dist/src/internal/EMIDIOutput.js.map +1 -0
  28. package/dist/src/internal/EMIDIPort.js +125 -0
  29. package/dist/src/internal/EMIDIPort.js.map +1 -0
  30. package/dist/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPort.js +27 -0
  31. package/dist/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPort.js.map +1 -0
  32. package/dist/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdAndAccess.js +19 -0
  33. package/dist/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdAndAccess.js.map +1 -0
  34. package/dist/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdInContext.js +16 -0
  35. package/dist/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdInContext.js.map +1 -0
  36. package/dist/src/internal/MIDIPortMethodCalls/actOnPort.js +18 -0
  37. package/dist/src/internal/MIDIPortMethodCalls/actOnPort.js.map +1 -0
  38. package/dist/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPort.js +27 -0
  39. package/dist/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPort.js.map +1 -0
  40. package/dist/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdAndAccess.js +18 -0
  41. package/dist/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdAndAccess.js.map +1 -0
  42. package/dist/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdInContext.js +16 -0
  43. package/dist/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdInContext.js.map +1 -0
  44. package/dist/src/internal/MIDIPortMethodCalls/makeMIDIPortMethodCallerFactory.js +21 -0
  45. package/dist/src/internal/MIDIPortMethodCalls/makeMIDIPortMethodCallerFactory.js.map +1 -0
  46. package/dist/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPort.js +30 -0
  47. package/dist/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPort.js.map +1 -0
  48. package/dist/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdAndAccess.js +18 -0
  49. package/dist/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdAndAccess.js.map +1 -0
  50. package/dist/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdInContext.js +16 -0
  51. package/dist/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdInContext.js.map +1 -0
  52. package/dist/src/internal/StreamMaker.js +101 -0
  53. package/dist/src/internal/StreamMaker.js.map +1 -0
  54. package/dist/src/internal/errors.js +161 -0
  55. package/dist/src/internal/errors.js.map +1 -0
  56. package/dist/src/internal/getPortByPortId/getPortByPortIdAndAccess.js +53 -0
  57. package/dist/src/internal/getPortByPortId/getPortByPortIdAndAccess.js.map +1 -0
  58. package/dist/src/internal/getPortByPortId/getPortByPortIdInContext.js +18 -0
  59. package/dist/src/internal/getPortByPortId/getPortByPortIdInContext.js.map +1 -0
  60. package/dist/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPort.js +52 -0
  61. package/dist/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPort.js.map +1 -0
  62. package/dist/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdAndAccess.js +13 -0
  63. package/dist/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdAndAccess.js.map +1 -0
  64. package/dist/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdInContext.js +18 -0
  65. package/dist/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdInContext.js.map +1 -0
  66. package/dist/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPort.js +66 -0
  67. package/dist/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPort.js.map +1 -0
  68. package/dist/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdAndAccess.js +61 -0
  69. package/dist/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdAndAccess.js.map +1 -0
  70. package/dist/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdInContext.js +61 -0
  71. package/dist/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdInContext.js.map +1 -0
  72. package/dist/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPort.js +42 -0
  73. package/dist/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPort.js.map +1 -0
  74. package/dist/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdAndAccess.js +42 -0
  75. package/dist/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdAndAccess.js.map +1 -0
  76. package/dist/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdInContext.js +29 -0
  77. package/dist/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdInContext.js.map +1 -0
  78. package/dist/src/internal/mutablePropertyTools/getValueInRawPortFieldUnsafe.js +6 -0
  79. package/dist/src/internal/mutablePropertyTools/getValueInRawPortFieldUnsafe.js.map +1 -0
  80. package/dist/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPort.js +46 -0
  81. package/dist/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPort.js.map +1 -0
  82. package/dist/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdAndAccess.js +25 -0
  83. package/dist/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdAndAccess.js.map +1 -0
  84. package/dist/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdInContext.js +31 -0
  85. package/dist/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdInContext.js.map +1 -0
  86. package/dist/src/internal/parsing.js +117 -0
  87. package/dist/src/internal/parsing.js.map +1 -0
  88. package/dist/src/internal/util.js +59 -0
  89. package/dist/src/internal/util.js.map +1 -0
  90. package/dist-types/index.d.ts +2 -0
  91. package/dist-types/index.d.ts.map +1 -0
  92. package/dist-types/src/EMIDIAccess.d.ts +27 -0
  93. package/dist-types/src/EMIDIAccess.d.ts.map +1 -0
  94. package/dist-types/src/EMIDIInput.d.ts +26 -0
  95. package/dist-types/src/EMIDIInput.d.ts.map +1 -0
  96. package/dist-types/src/EMIDIOutput.d.ts +26 -0
  97. package/dist-types/src/EMIDIOutput.d.ts.map +1 -0
  98. package/dist-types/src/EMIDIPort.d.ts +26 -0
  99. package/dist-types/src/EMIDIPort.d.ts.map +1 -0
  100. package/dist-types/src/MIDIErrors.d.ts +2 -0
  101. package/dist-types/src/MIDIErrors.d.ts.map +1 -0
  102. package/dist-types/src/Parsing.d.ts +2 -0
  103. package/dist-types/src/Parsing.d.ts.map +1 -0
  104. package/dist-types/src/StreamMaker.d.ts +2 -0
  105. package/dist-types/src/StreamMaker.d.ts.map +1 -0
  106. package/dist-types/src/Util.d.ts +2 -0
  107. package/dist-types/src/Util.d.ts.map +1 -0
  108. package/dist-types/src/index.d.ts +9 -0
  109. package/dist-types/src/index.d.ts.map +1 -0
  110. package/dist-types/src/internal/EMIDIAccess.d.ts +339 -0
  111. package/dist-types/src/internal/EMIDIAccess.d.ts.map +1 -0
  112. package/dist-types/src/internal/EMIDIInput.d.ts +48 -0
  113. package/dist-types/src/internal/EMIDIInput.d.ts.map +1 -0
  114. package/dist-types/src/internal/EMIDIOutput.d.ts +93 -0
  115. package/dist-types/src/internal/EMIDIOutput.d.ts.map +1 -0
  116. package/dist-types/src/internal/EMIDIPort.d.ts +87 -0
  117. package/dist-types/src/internal/EMIDIPort.d.ts.map +1 -0
  118. package/dist-types/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPort.d.ts +16 -0
  119. package/dist-types/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPort.d.ts.map +1 -0
  120. package/dist-types/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdAndAccess.d.ts +15 -0
  121. package/dist-types/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdAndAccess.d.ts.map +1 -0
  122. package/dist-types/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdInContext.d.ts +13 -0
  123. package/dist-types/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdInContext.d.ts.map +1 -0
  124. package/dist-types/src/internal/MIDIPortMethodCalls/actOnPort.d.ts +11 -0
  125. package/dist-types/src/internal/MIDIPortMethodCalls/actOnPort.d.ts.map +1 -0
  126. package/dist-types/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPort.d.ts +23 -0
  127. package/dist-types/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPort.d.ts.map +1 -0
  128. package/dist-types/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdAndAccess.d.ts +15 -0
  129. package/dist-types/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdAndAccess.d.ts.map +1 -0
  130. package/dist-types/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdInContext.d.ts +13 -0
  131. package/dist-types/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdInContext.d.ts.map +1 -0
  132. package/dist-types/src/internal/MIDIPortMethodCalls/makeMIDIPortMethodCallerFactory.d.ts +15 -0
  133. package/dist-types/src/internal/MIDIPortMethodCalls/makeMIDIPortMethodCallerFactory.d.ts.map +1 -0
  134. package/dist-types/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPort.d.ts +21 -0
  135. package/dist-types/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPort.d.ts.map +1 -0
  136. package/dist-types/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdAndAccess.d.ts +15 -0
  137. package/dist-types/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdAndAccess.d.ts.map +1 -0
  138. package/dist-types/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdInContext.d.ts +13 -0
  139. package/dist-types/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdInContext.d.ts.map +1 -0
  140. package/dist-types/src/internal/StreamMaker.d.ts +202 -0
  141. package/dist-types/src/internal/StreamMaker.d.ts.map +1 -0
  142. package/dist-types/src/internal/errors.d.ts +260 -0
  143. package/dist-types/src/internal/errors.d.ts.map +1 -0
  144. package/dist-types/src/internal/getPortByPortId/getPortByPortIdAndAccess.d.ts +27 -0
  145. package/dist-types/src/internal/getPortByPortId/getPortByPortIdAndAccess.d.ts.map +1 -0
  146. package/dist-types/src/internal/getPortByPortId/getPortByPortIdInContext.d.ts +20 -0
  147. package/dist-types/src/internal/getPortByPortId/getPortByPortIdInContext.d.ts.map +1 -0
  148. package/dist-types/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPort.d.ts +71 -0
  149. package/dist-types/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPort.d.ts.map +1 -0
  150. package/dist-types/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdAndAccess.d.ts +4 -0
  151. package/dist-types/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdAndAccess.d.ts.map +1 -0
  152. package/dist-types/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdInContext.d.ts +20 -0
  153. package/dist-types/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdInContext.d.ts.map +1 -0
  154. package/dist-types/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPort.d.ts +62 -0
  155. package/dist-types/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPort.d.ts.map +1 -0
  156. package/dist-types/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdAndAccess.d.ts +16 -0
  157. package/dist-types/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdAndAccess.d.ts.map +1 -0
  158. package/dist-types/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdInContext.d.ts +16 -0
  159. package/dist-types/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdInContext.d.ts.map +1 -0
  160. package/dist-types/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPort.d.ts +36 -0
  161. package/dist-types/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPort.d.ts.map +1 -0
  162. package/dist-types/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdAndAccess.d.ts +22 -0
  163. package/dist-types/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdAndAccess.d.ts.map +1 -0
  164. package/dist-types/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdInContext.d.ts +17 -0
  165. package/dist-types/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdInContext.d.ts.map +1 -0
  166. package/dist-types/src/internal/mutablePropertyTools/getValueInRawPortFieldUnsafe.d.ts +7 -0
  167. package/dist-types/src/internal/mutablePropertyTools/getValueInRawPortFieldUnsafe.d.ts.map +1 -0
  168. package/dist-types/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPort.d.ts +71 -0
  169. package/dist-types/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPort.d.ts.map +1 -0
  170. package/dist-types/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdAndAccess.d.ts +7 -0
  171. package/dist-types/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdAndAccess.d.ts.map +1 -0
  172. package/dist-types/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdInContext.d.ts +28 -0
  173. package/dist-types/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdInContext.d.ts.map +1 -0
  174. package/dist-types/src/internal/parsing.d.ts +72 -0
  175. package/dist-types/src/internal/parsing.d.ts.map +1 -0
  176. package/dist-types/src/internal/util.d.ts +33 -0
  177. package/dist-types/src/internal/util.d.ts.map +1 -0
  178. package/index.ts +1 -0
  179. package/package.json +83 -0
  180. package/src/EMIDIAccess.ts +271 -0
  181. package/src/EMIDIInput.ts +270 -0
  182. package/src/EMIDIOutput.ts +269 -0
  183. package/src/EMIDIPort.ts +267 -0
  184. package/src/MIDIErrors.ts +13 -0
  185. package/src/Parsing.ts +12 -0
  186. package/src/StreamMaker.ts +12 -0
  187. package/src/Util.ts +19 -0
  188. package/src/index.ts +8 -0
  189. package/src/internal/EMIDIAccess.ts +893 -0
  190. package/src/internal/EMIDIInput.ts +114 -0
  191. package/src/internal/EMIDIOutput.ts +228 -0
  192. package/src/internal/EMIDIPort.ts +233 -0
  193. package/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPort.ts +43 -0
  194. package/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdAndAccess.ts +39 -0
  195. package/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdInContext.ts +27 -0
  196. package/src/internal/MIDIPortMethodCalls/actOnPort.ts +66 -0
  197. package/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPort.ts +38 -0
  198. package/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdAndAccess.ts +38 -0
  199. package/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdInContext.ts +27 -0
  200. package/src/internal/MIDIPortMethodCalls/makeMIDIPortMethodCallerFactory.ts +73 -0
  201. package/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPort.ts +44 -0
  202. package/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdAndAccess.ts +38 -0
  203. package/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdInContext.ts +27 -0
  204. package/src/internal/StreamMaker.ts +414 -0
  205. package/src/internal/errors.ts +220 -0
  206. package/src/internal/getPortByPortId/getPortByPortIdAndAccess.ts +116 -0
  207. package/src/internal/getPortByPortId/getPortByPortIdInContext.ts +26 -0
  208. package/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPort.ts +148 -0
  209. package/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdAndAccess.ts +14 -0
  210. package/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdInContext.ts +51 -0
  211. package/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPort.ts +127 -0
  212. package/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdAndAccess.ts +74 -0
  213. package/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdInContext.ts +74 -0
  214. package/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPort.ts +63 -0
  215. package/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdAndAccess.ts +110 -0
  216. package/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdInContext.ts +37 -0
  217. package/src/internal/mutablePropertyTools/getValueInRawPortFieldUnsafe.ts +12 -0
  218. package/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPort.ts +183 -0
  219. package/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdAndAccess.ts +29 -0
  220. package/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdInContext.ts +86 -0
  221. package/src/internal/parsing.ts +219 -0
  222. package/src/internal/util.ts +152 -0
@@ -0,0 +1,116 @@
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 Effect from 'effect/Effect'
5
+ import * as EFunction from 'effect/Function'
6
+ import * as EMIDIAccess from '../EMIDIAccess.ts'
7
+ import * as EMIDIInput from '../EMIDIInput.ts'
8
+ import * as EMIDIOutput from '../EMIDIOutput.ts'
9
+ import type * as EMIDIPort from '../EMIDIPort.ts'
10
+ import * as Errors from '../errors.ts'
11
+
12
+ /**
13
+ *
14
+ * @internal
15
+ */
16
+ const getPortByIdAndRemap = <
17
+ EInput,
18
+ EOutput,
19
+ RInput,
20
+ ROutput,
21
+ AInputType extends 'input' = never,
22
+ AOutputType extends 'output' = never,
23
+ >(handlers: {
24
+ onInputFound: (
25
+ rawInput: MIDIInput,
26
+ ) => Effect.Effect<EMIDIPort.EMIDIPort<AInputType>, EInput, RInput>
27
+ onOutputFound: (
28
+ rawOutput: MIDIOutput,
29
+ ) => Effect.Effect<EMIDIPort.EMIDIPort<AOutputType>, EOutput, ROutput>
30
+ }): GetPortById<
31
+ AInputType | AOutputType,
32
+ AInputType | AOutputType,
33
+ never,
34
+ never,
35
+ Errors.PortNotFoundError | EInput | EOutput,
36
+ RInput | ROutput
37
+ > =>
38
+ EFunction.dual(2, (polymorphicAccess, portId) =>
39
+ Effect.flatMap(EMIDIAccess.resolve(polymorphicAccess), e => {
40
+ const rawAccess = EMIDIAccess.assumeImpl(e)._access
41
+
42
+ let rawPort: MIDIOutput | MIDIInput | undefined =
43
+ rawAccess.inputs.get(portId)
44
+
45
+ if (rawPort) return handlers.onInputFound(rawPort)
46
+
47
+ rawPort = rawAccess.outputs.get(portId)
48
+
49
+ if (rawPort) return handlers.onOutputFound(rawPort)
50
+
51
+ return new Errors.PortNotFoundError({
52
+ portId,
53
+ }) as EMIDIAccess.AcquiredThing<
54
+ EMIDIPort.EMIDIPort<AInputType | AOutputType>,
55
+ never,
56
+ never,
57
+ never,
58
+ never,
59
+ Errors.PortNotFoundError | EInput | EOutput,
60
+ RInput | ROutput
61
+ >
62
+ }),
63
+ )
64
+
65
+ /**
66
+ *
67
+ * If you want to ensure the type of returned port match the type of ID, use
68
+ * type-specific getters {@linkcode getInputByPortIdAndAccess} and
69
+ * {@linkcode getOutputByPortIdAndAccess}, because in runtime, these branded
70
+ * port IDs passed as function arguments, are just strings and cannot ensure
71
+ * soundness
72
+ */
73
+ export const getPortByPortIdAndAccess = getPortByIdAndRemap({
74
+ onInputFound: EFunction.flow(EMIDIInput.make, Effect.succeed),
75
+ onOutputFound: EFunction.flow(EMIDIOutput.make, Effect.succeed),
76
+ })
77
+
78
+ /**
79
+ *
80
+ *
81
+ */
82
+ export const getInputByPortIdAndAccess = getPortByIdAndRemap({
83
+ onInputFound: EFunction.flow(EMIDIInput.make, Effect.succeed),
84
+ onOutputFound: rawOutput =>
85
+ Effect.dieMessage(
86
+ `Assertion failed: getInputById found output port with the id=${rawOutput.id}`,
87
+ ),
88
+ })
89
+
90
+ /**
91
+ *
92
+ *
93
+ */
94
+ export const getOutputByPortIdAndAccess = getPortByIdAndRemap({
95
+ onInputFound: rawInput =>
96
+ Effect.dieMessage(
97
+ `Assertion failed: getOutputById found output port with the id=${rawInput.id}`,
98
+ ),
99
+ onOutputFound: EFunction.flow(EMIDIOutput.make, Effect.succeed),
100
+ })
101
+
102
+ export interface GetPortById<
103
+ TReturnedPortType extends TTypeOfPortId,
104
+ TTypeOfPortId extends MIDIPortType,
105
+ TAccessGettingFallbackError,
106
+ TAccessGettingFallbackRequirement,
107
+ TAdditionalError,
108
+ TAdditionalRequirement,
109
+ > extends EMIDIAccess.GetThingByPortId<
110
+ EMIDIPort.EMIDIPort<TReturnedPortType>,
111
+ TTypeOfPortId,
112
+ TAccessGettingFallbackError,
113
+ TAccessGettingFallbackRequirement,
114
+ TAdditionalError | Errors.PortNotFoundError,
115
+ TAdditionalRequirement
116
+ > {}
@@ -0,0 +1,26 @@
1
+ import * as EMIDIAccess from '../EMIDIAccess.ts'
2
+ import type * as EMIDIInput from '../EMIDIInput.ts'
3
+ import type * as EMIDIOutput from '../EMIDIOutput.ts'
4
+ import type * as EMIDIPort from '../EMIDIPort.ts'
5
+ import * as Get from './getPortByPortIdAndAccess.ts'
6
+
7
+ /**
8
+ *
9
+ *
10
+ */
11
+ export const getPortByPortIdInContext = (id: EMIDIPort.BothId) =>
12
+ Get.getPortByPortIdAndAccess(EMIDIAccess.EMIDIAccess, id)
13
+
14
+ /**
15
+ *
16
+ *
17
+ */
18
+ export const getInputByPortIdInContext = (id: EMIDIInput.Id) =>
19
+ Get.getInputByPortIdAndAccess(EMIDIAccess.EMIDIAccess, id)
20
+
21
+ /**
22
+ *
23
+ *
24
+ */
25
+ export const getOutputByPortIdInContext = (id: EMIDIOutput.Id) =>
26
+ Get.getOutputByPortIdAndAccess(EMIDIAccess.EMIDIAccess, id)
@@ -0,0 +1,148 @@
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 EMIDIInput from '../EMIDIInput.ts'
5
+ import * as EMIDIOutput from '../EMIDIOutput.ts'
6
+ import * as EMIDIPort from '../EMIDIPort.ts'
7
+ import * as StreamMaker from '../StreamMaker.ts'
8
+ import * as Util from '../util.ts'
9
+
10
+ /**
11
+ *
12
+ * @internal
13
+ */
14
+ const makePortStateChangesStreamFactory = <
15
+ THighLevelPortType extends MIDIPortType,
16
+ >(
17
+ is: (port: unknown) => port is EMIDIPort.EMIDIPort<THighLevelPortType>,
18
+ ) =>
19
+ StreamMaker.createStreamMakerFrom<MIDIPortEventMap>()(
20
+ is,
21
+ port => ({
22
+ tag: 'MIDIPortStateChange',
23
+ eventListener: {
24
+ target: EMIDIPort.assumeImpl(port)._port,
25
+ type: 'statechange',
26
+ },
27
+ spanAttributes: {
28
+ spanTargetName: 'MIDI port',
29
+ port: Util.getStaticMIDIPortInfo(port),
30
+ },
31
+ nullableFieldName: 'port',
32
+ }),
33
+ rawPort =>
34
+ ({
35
+ newState: rawPort
36
+ ? ({
37
+ ofDevice: rawPort.state,
38
+ ofConnection: rawPort.connection,
39
+ } as const)
40
+ : null,
41
+ }) as const,
42
+ // TODO: check this type is actually needed
43
+ ) as DualMakeStateChangesStream<THighLevelPortType>
44
+
45
+ /**
46
+ * Function to create a stream of remapped {@linkcode MIDIConnectionEvent}s
47
+ *
48
+ * [MDN
49
+ * Reference](https://developer.mozilla.org/docs/Web/API/MIDIConnectionEvent)
50
+ */
51
+ export const makePortStateChangesStreamByPort =
52
+ makePortStateChangesStreamFactory(EMIDIPort.is)
53
+
54
+ /**
55
+ * Function to create a stream of remapped {@linkcode MIDIConnectionEvent}s
56
+ *
57
+ * [MDN
58
+ * Reference](https://developer.mozilla.org/docs/Web/API/MIDIConnectionEvent)
59
+ */
60
+ export const makeInputStateChangesStreamByPort =
61
+ makePortStateChangesStreamFactory(EMIDIInput.is)
62
+
63
+ /**
64
+ * Function to create a stream of remapped {@linkcode MIDIConnectionEvent}s
65
+ *
66
+ * [MDN
67
+ * Reference](https://developer.mozilla.org/docs/Web/API/MIDIConnectionEvent)
68
+ */
69
+ export const makeOutputStateChangesStreamByPort =
70
+ makePortStateChangesStreamFactory(EMIDIOutput.is)
71
+
72
+ /**
73
+ * A custom type is needed because the port type will be generic, but this is
74
+ * not possible if using just {@linkcode createStreamMakerFrom}
75
+ */
76
+ export interface DualMakeStateChangesStream<
77
+ THighLevelPortType extends MIDIPortType = MIDIPortType,
78
+ > extends MakeStateChangesStreamPortFirst<THighLevelPortType>,
79
+ MakeStateChangesStreamPortLast<THighLevelPortType> {}
80
+
81
+ /**
82
+ * A custom type is needed because the port type will be generic, but this is
83
+ * not possible if using just {@linkcode createStreamMakerFrom}
84
+ */
85
+ export interface MakeStateChangesStreamPortFirst<
86
+ THighLevelPortType extends MIDIPortType = MIDIPortType,
87
+ > {
88
+ /**
89
+ * @param options Passing a value of a `boolean` type is equivalent to setting `options.capture`
90
+ * property
91
+ */
92
+ <
93
+ TPortType extends THighLevelPortType,
94
+ const TOnNullStrategy extends StreamMaker.OnNullStrategy = undefined,
95
+ E = never,
96
+ R = never,
97
+ >(
98
+ polymorphicPort: EMIDIPort.PolymorphicPort<E, R, TPortType>,
99
+ options?: StreamMaker.StreamMakerOptions<TOnNullStrategy>,
100
+ ): StateChangesStream<TOnNullStrategy, TPortType, E, R>
101
+ }
102
+
103
+ /**
104
+ * A custom type is needed because the port type will be generic, but this is
105
+ * not possible if using just {@linkcode createStreamMakerFrom}
106
+ */
107
+ export interface MakeStateChangesStreamPortLast<
108
+ THighLevelPortType extends MIDIPortType = MIDIPortType,
109
+ > {
110
+ /**
111
+ * @param options Passing a value of a `boolean` type is equivalent to setting `options.capture`
112
+ * property
113
+ */
114
+ <const TOnNullStrategy extends StreamMaker.OnNullStrategy = undefined>(
115
+ options?: StreamMaker.StreamMakerOptions<TOnNullStrategy>,
116
+ ): {
117
+ /**
118
+ *
119
+ *
120
+ */
121
+ <TPortType extends THighLevelPortType, E = never, R = never>(
122
+ polymorphicPort: EMIDIPort.PolymorphicPort<E, R, TPortType>,
123
+ ): StateChangesStream<TOnNullStrategy, TPortType, E, R>
124
+ }
125
+ }
126
+
127
+ /**
128
+ * A custom type is needed because the port type will be generic, but this is
129
+ * not possible if using just {@linkcode createStreamMakerFrom}
130
+ */
131
+ export interface StateChangesStream<
132
+ TOnNullStrategy extends StreamMaker.OnNullStrategy,
133
+ TPortType extends MIDIPortType,
134
+ E = never,
135
+ R = never,
136
+ > extends StreamMaker.BuiltStream<
137
+ 'MIDIPortStateChange',
138
+ EMIDIPort.EMIDIPort<TPortType>,
139
+ {
140
+ readonly newState: {
141
+ readonly ofDevice: MIDIPortDeviceState
142
+ readonly ofConnection: MIDIPortConnectionState
143
+ } | null
144
+ },
145
+ TOnNullStrategy,
146
+ E,
147
+ R
148
+ > {}
@@ -0,0 +1,14 @@
1
+ // TODO: makeInputStateChangesStreamByPortIdAndAccess
2
+ export const makeInputStateChangesStreamByPortIdAndAccess = () => {
3
+ throw new Error('not implemented')
4
+ }
5
+
6
+ // TODO: makeOutputStateChangesStreamByPortIdAndAccess
7
+ export const makeOutputStateChangesStreamByPortIdAndAccess = () => {
8
+ throw new Error('not implemented')
9
+ }
10
+
11
+ // TODO: makePortStateChangesStreamByPortIdAndAccess
12
+ export const makePortStateChangesStreamByPortIdAndAccess = () => {
13
+ throw new Error('not implemented')
14
+ }
@@ -0,0 +1,51 @@
1
+ import type * as EMIDIInput from '../../EMIDIInput.ts'
2
+ import type * as EMIDIOutput from '../../EMIDIOutput.ts'
3
+ import type * as EMIDIPort from '../../EMIDIPort.ts'
4
+ import * as Get from '../getPortByPortId/getPortByPortIdInContext.ts'
5
+ import type * as StreamMaker from '../StreamMaker.ts'
6
+ import * as Make from './makePortStateChangesStreamByPort.ts'
7
+
8
+ /**
9
+ * @param options Passing a value of a `boolean` type is equivalent to setting
10
+ * `options.capture` property
11
+ */
12
+ export const makePortStateChangesStreamByPortIdInContext = <
13
+ const TOnNullStrategy extends StreamMaker.OnNullStrategy = undefined,
14
+ >(
15
+ id: EMIDIPort.BothId,
16
+ options?: StreamMaker.StreamMakerOptions<TOnNullStrategy>,
17
+ ) =>
18
+ Make.makePortStateChangesStreamByPort(
19
+ Get.getPortByPortIdInContext(id),
20
+ options,
21
+ )
22
+
23
+ /**
24
+ * @param options Passing a value of a `boolean` type is equivalent to setting
25
+ * `options.capture` property
26
+ */
27
+ export const makeInputStateChangesStreamByPortIdInContext = <
28
+ const TOnNullStrategy extends StreamMaker.OnNullStrategy = undefined,
29
+ >(
30
+ id: EMIDIInput.Id,
31
+ options?: StreamMaker.StreamMakerOptions<TOnNullStrategy>,
32
+ ) =>
33
+ Make.makeInputStateChangesStreamByPort(
34
+ Get.getInputByPortIdInContext(id),
35
+ options,
36
+ )
37
+
38
+ /**
39
+ * @param options Passing a value of a `boolean` type is equivalent to setting
40
+ * `options.capture` property
41
+ */
42
+ export const makeOutputStateChangesStreamByPortIdInContext = <
43
+ const TOnNullStrategy extends StreamMaker.OnNullStrategy = undefined,
44
+ >(
45
+ id: EMIDIOutput.Id,
46
+ options?: StreamMaker.StreamMakerOptions<TOnNullStrategy>,
47
+ ) =>
48
+ Make.makeOutputStateChangesStreamByPort(
49
+ Get.getOutputByPortIdInContext(id),
50
+ options,
51
+ )
@@ -0,0 +1,127 @@
1
+ import * as EFunction from 'effect/Function'
2
+ import * as Util from '../../util.ts'
3
+ import * as Get from '../getMutablePortProperty/getMutablePortPropertyByPort.ts'
4
+
5
+ /**
6
+ *
7
+ */
8
+ export const isPortDeviceConnectedByPort = EFunction.flow(
9
+ Get.getPortDeviceStateByPort,
10
+ Util.isDeviceConnected,
11
+ )
12
+
13
+ /**
14
+ *
15
+ */
16
+ export const isPortDeviceDisconnectedByPort = EFunction.flow(
17
+ Get.getPortDeviceStateByPort,
18
+ Util.isDeviceDisconnected,
19
+ )
20
+
21
+ /**
22
+ *
23
+ */
24
+ export const isPortConnectionOpenByPort = EFunction.flow(
25
+ Get.getPortConnectionStateByPort,
26
+ Util.isConnectionOpen,
27
+ )
28
+
29
+ /**
30
+ *
31
+ */
32
+ export const isPortConnectionPendingByPort = EFunction.flow(
33
+ Get.getPortConnectionStateByPort,
34
+ Util.isConnectionPending,
35
+ )
36
+
37
+ /**
38
+ *
39
+ */
40
+ export const isPortConnectionClosedByPort = EFunction.flow(
41
+ Get.getPortConnectionStateByPort,
42
+ Util.isConnectionClosed,
43
+ )
44
+
45
+ //////////////////////////////
46
+
47
+ /**
48
+ *
49
+ */
50
+ export const isInputDeviceConnectedByPort = EFunction.flow(
51
+ Get.getInputDeviceStateByPort,
52
+ Util.isDeviceConnected,
53
+ )
54
+
55
+ /**
56
+ *
57
+ */
58
+ export const isInputDeviceDisconnectedByPort = EFunction.flow(
59
+ Get.getInputDeviceStateByPort,
60
+ Util.isDeviceDisconnected,
61
+ )
62
+
63
+ /**
64
+ *
65
+ */
66
+ export const isInputConnectionOpenByPort = EFunction.flow(
67
+ Get.getInputConnectionStateByPort,
68
+ Util.isConnectionOpen,
69
+ )
70
+
71
+ /**
72
+ *
73
+ */
74
+ export const isInputConnectionPendingByPort = EFunction.flow(
75
+ Get.getInputConnectionStateByPort,
76
+ Util.isConnectionPending,
77
+ )
78
+
79
+ /**
80
+ *
81
+ */
82
+ export const isInputConnectionClosedByPort = EFunction.flow(
83
+ Get.getInputConnectionStateByPort,
84
+ Util.isConnectionClosed,
85
+ )
86
+
87
+ //////////////////////////////
88
+
89
+ /**
90
+ *
91
+ */
92
+ export const isOutputDeviceConnectedByPort = EFunction.flow(
93
+ Get.getOutputDeviceStateByPort,
94
+ Util.isDeviceConnected,
95
+ )
96
+
97
+ /**
98
+ *
99
+ */
100
+ export const isOutputDeviceDisconnectedByPort = EFunction.flow(
101
+ Get.getOutputDeviceStateByPort,
102
+ Util.isDeviceDisconnected,
103
+ )
104
+
105
+ /**
106
+ *
107
+ */
108
+ export const isOutputConnectionOpenByPort = EFunction.flow(
109
+ Get.getOutputConnectionStateByPort,
110
+ Util.isConnectionOpen,
111
+ )
112
+
113
+ /**
114
+ *
115
+ */
116
+ export const isOutputConnectionPendingByPort = EFunction.flow(
117
+ Get.getOutputConnectionStateByPort,
118
+ Util.isConnectionPending,
119
+ )
120
+
121
+ /**
122
+ *
123
+ */
124
+ export const isOutputConnectionClosedByPort = EFunction.flow(
125
+ Get.getOutputConnectionStateByPort,
126
+ Util.isConnectionClosed,
127
+ )
@@ -0,0 +1,74 @@
1
+ // TODO: isInputConnectionClosedByPortIdAndAccess
2
+ export const isInputConnectionClosedByPortIdAndAccess = () => {
3
+ throw new Error('not implemented')
4
+ }
5
+
6
+ // TODO: isInputConnectionOpenByPortIdAndAccess
7
+ export const isInputConnectionOpenByPortIdAndAccess = () => {
8
+ throw new Error('not implemented')
9
+ }
10
+
11
+ // TODO: isInputConnectionPendingByPortIdAndAccess
12
+ export const isInputConnectionPendingByPortIdAndAccess = () => {
13
+ throw new Error('not implemented')
14
+ }
15
+
16
+ // TODO: isInputDeviceConnectedByPortIdAndAccess
17
+ export const isInputDeviceConnectedByPortIdAndAccess = () => {
18
+ throw new Error('not implemented')
19
+ }
20
+
21
+ // TODO: isInputDeviceDisconnectedByPortIdAndAccess
22
+ export const isInputDeviceDisconnectedByPortIdAndAccess = () => {
23
+ throw new Error('not implemented')
24
+ }
25
+
26
+ // TODO: isOutputConnectionClosedByPortIdAndAccess
27
+ export const isOutputConnectionClosedByPortIdAndAccess = () => {
28
+ throw new Error('not implemented')
29
+ }
30
+
31
+ // TODO: isOutputConnectionOpenByPortIdAndAccess
32
+ export const isOutputConnectionOpenByPortIdAndAccess = () => {
33
+ throw new Error('not implemented')
34
+ }
35
+
36
+ // TODO: isOutputConnectionPendingByPortIdAndAccess
37
+ export const isOutputConnectionPendingByPortIdAndAccess = () => {
38
+ throw new Error('not implemented')
39
+ }
40
+
41
+ // TODO: isOutputDeviceConnectedByPortIdAndAccess
42
+ export const isOutputDeviceConnectedByPortIdAndAccess = () => {
43
+ throw new Error('not implemented')
44
+ }
45
+
46
+ // TODO: isOutputDeviceDisconnectedByPortIdAndAccess
47
+ export const isOutputDeviceDisconnectedByPortIdAndAccess = () => {
48
+ throw new Error('not implemented')
49
+ }
50
+
51
+ // TODO: isPortConnectionClosedByPortIdAndAccess
52
+ export const isPortConnectionClosedByPortIdAndAccess = () => {
53
+ throw new Error('not implemented')
54
+ }
55
+
56
+ // TODO: isPortConnectionOpenByPortIdAndAccess
57
+ export const isPortConnectionOpenByPortIdAndAccess = () => {
58
+ throw new Error('not implemented')
59
+ }
60
+
61
+ // TODO: isPortConnectionPendingByPortIdAndAccess
62
+ export const isPortConnectionPendingByPortIdAndAccess = () => {
63
+ throw new Error('not implemented')
64
+ }
65
+
66
+ // TODO: isPortDeviceConnectedByPortIdAndAccess
67
+ export const isPortDeviceConnectedByPortIdAndAccess = () => {
68
+ throw new Error('not implemented')
69
+ }
70
+
71
+ // TODO: isPortDeviceDisconnectedByPortIdAndAccess
72
+ export const isPortDeviceDisconnectedByPortIdAndAccess = () => {
73
+ throw new Error('not implemented')
74
+ }
@@ -0,0 +1,74 @@
1
+ // TODO: isInputConnectionClosedByPortIdInContext
2
+ export const isInputConnectionClosedByPortIdInContext = () => {
3
+ throw new Error('not implemented')
4
+ }
5
+
6
+ // TODO: isInputConnectionOpenByPortIdInContext
7
+ export const isInputConnectionOpenByPortIdInContext = () => {
8
+ throw new Error('not implemented')
9
+ }
10
+
11
+ // TODO: isInputConnectionPendingByPortIdInContext
12
+ export const isInputConnectionPendingByPortIdInContext = () => {
13
+ throw new Error('not implemented')
14
+ }
15
+
16
+ // TODO: isInputDeviceConnectedByPortIdInContext
17
+ export const isInputDeviceConnectedByPortIdInContext = () => {
18
+ throw new Error('not implemented')
19
+ }
20
+
21
+ // TODO: isInputDeviceDisconnectedByPortIdInContext
22
+ export const isInputDeviceDisconnectedByPortIdInContext = () => {
23
+ throw new Error('not implemented')
24
+ }
25
+
26
+ // TODO: isOutputConnectionClosedByPortIdInContext
27
+ export const isOutputConnectionClosedByPortIdInContext = () => {
28
+ throw new Error('not implemented')
29
+ }
30
+
31
+ // TODO: isOutputConnectionOpenByPortIdInContext
32
+ export const isOutputConnectionOpenByPortIdInContext = () => {
33
+ throw new Error('not implemented')
34
+ }
35
+
36
+ // TODO: isOutputConnectionPendingByPortIdInContext
37
+ export const isOutputConnectionPendingByPortIdInContext = () => {
38
+ throw new Error('not implemented')
39
+ }
40
+
41
+ // TODO: isOutputDeviceConnectedByPortIdInContext
42
+ export const isOutputDeviceConnectedByPortIdInContext = () => {
43
+ throw new Error('not implemented')
44
+ }
45
+
46
+ // TODO: isOutputDeviceDisconnectedByPortIdInContext
47
+ export const isOutputDeviceDisconnectedByPortIdInContext = () => {
48
+ throw new Error('not implemented')
49
+ }
50
+
51
+ // TODO: isPortConnectionClosedByPortIdInContext
52
+ export const isPortConnectionClosedByPortIdInContext = () => {
53
+ throw new Error('not implemented')
54
+ }
55
+
56
+ // TODO: isPortConnectionOpenByPortIdInContext
57
+ export const isPortConnectionOpenByPortIdInContext = () => {
58
+ throw new Error('not implemented')
59
+ }
60
+
61
+ // TODO: isPortConnectionPendingByPortIdInContext
62
+ export const isPortConnectionPendingByPortIdInContext = () => {
63
+ throw new Error('not implemented')
64
+ }
65
+
66
+ // TODO: isPortDeviceConnectedByPortIdInContext
67
+ export const isPortDeviceConnectedByPortIdInContext = () => {
68
+ throw new Error('not implemented')
69
+ }
70
+
71
+ // TODO: isPortDeviceDisconnectedByPortIdInContext
72
+ export const isPortDeviceDisconnectedByPortIdInContext = () => {
73
+ throw new Error('not implemented')
74
+ }
@@ -0,0 +1,63 @@
1
+ import * as Effect from 'effect/Effect'
2
+ import type * as EMIDIPort from '../../EMIDIPort.ts'
3
+ import { getValueInRawPortFieldUnsafe } from '../getValueInRawPortFieldUnsafe.ts'
4
+ import type * as Match from '../matchMutablePortProperty/matchMutablePortPropertyByPort.ts'
5
+
6
+ /**
7
+ * @internal
8
+ */
9
+ const getMutableProperty =
10
+ <TMIDIPortType extends MIDIPortType>() =>
11
+ <const TMIDIPortMutableProperty extends Match.MIDIPortMutableProperty>(
12
+ property: TMIDIPortMutableProperty,
13
+ ) =>
14
+ <E = never, R = never>(
15
+ polymorphicPort: EMIDIPort.PolymorphicPort<E, R, TMIDIPortType>,
16
+ ) =>
17
+ Effect.isEffect(polymorphicPort)
18
+ ? Effect.map(polymorphicPort, getValueInRawPortFieldUnsafe(property))
19
+ : Effect.sync(() =>
20
+ getValueInRawPortFieldUnsafe(property)(polymorphicPort),
21
+ )
22
+
23
+ /**
24
+ * @returns A state of the hardware connection between the OS and the device
25
+ * ({@linkcode MIDIPortDeviceState}). Because it can change over time, it's
26
+ * wrapped in effect. It's taken from the {@linkcode MIDIPort.state|state}
27
+ * read-only property of the {@linkcode MIDIPort} interface ([MDN
28
+ * Reference](https://developer.mozilla.org/docs/Web/API/MIDIPort/state)).
29
+ */
30
+ export const getPortDeviceStateByPort = getMutableProperty()('state')
31
+
32
+ /**
33
+ * @returns A state of the connection between the browser's tab and OS
34
+ * abstraction of the device ({@linkcode MIDIPortConnectionState}). Because it
35
+ * can change over time, it's wrapped in effect. It's taken from the
36
+ * {@linkcode MIDIPort.connection|connection} read-only property of the
37
+ * {@linkcode MIDIPort} interface ([MDN
38
+ * Reference](https://developer.mozilla.org/docs/Web/API/MIDIPort/connection)).
39
+ */
40
+ export const getPortConnectionStateByPort = getMutableProperty()('connection')
41
+
42
+ /**
43
+ *
44
+ */
45
+ export const getInputDeviceStateByPort = getMutableProperty<'input'>()('state')
46
+
47
+ /**
48
+ *
49
+ */
50
+ export const getInputConnectionStateByPort =
51
+ getMutableProperty<'input'>()('connection')
52
+
53
+ /**
54
+ *
55
+ */
56
+ export const getOutputDeviceStateByPort =
57
+ getMutableProperty<'output'>()('state')
58
+
59
+ /**
60
+ *
61
+ */
62
+ export const getOutputConnectionStateByPort =
63
+ getMutableProperty<'output'>()('connection')