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.
- package/README.md +276 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/src/EMIDIAccess.js +129 -0
- package/dist/src/EMIDIAccess.js.map +1 -0
- package/dist/src/EMIDIInput.js +226 -0
- package/dist/src/EMIDIInput.js.map +1 -0
- package/dist/src/EMIDIOutput.js +227 -0
- package/dist/src/EMIDIOutput.js.map +1 -0
- package/dist/src/EMIDIPort.js +218 -0
- package/dist/src/EMIDIPort.js.map +1 -0
- package/dist/src/MIDIErrors.js +4 -0
- package/dist/src/MIDIErrors.js.map +1 -0
- package/dist/src/MIDIEventStreams.js +2 -0
- package/dist/src/MIDIEventStreams.js.map +1 -0
- package/dist/src/Parsing.js +2 -0
- package/dist/src/Parsing.js.map +1 -0
- package/dist/src/StreamMaker.js +1 -0
- package/dist/src/StreamMaker.js.map +1 -0
- package/dist/src/Util.js +2 -0
- package/dist/src/Util.js.map +1 -0
- package/dist/src/index.js +10 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/internal/EMIDIAccess.js +634 -0
- package/dist/src/internal/EMIDIAccess.js.map +1 -0
- package/dist/src/internal/EMIDIInput.js +66 -0
- package/dist/src/internal/EMIDIInput.js.map +1 -0
- package/dist/src/internal/EMIDIOutput.js +120 -0
- package/dist/src/internal/EMIDIOutput.js.map +1 -0
- package/dist/src/internal/EMIDIPort.js +125 -0
- package/dist/src/internal/EMIDIPort.js.map +1 -0
- package/dist/src/internal/MIDIErrors.js +190 -0
- package/dist/src/internal/MIDIErrors.js.map +1 -0
- package/dist/src/internal/MIDIEventStreams.js +41 -0
- package/dist/src/internal/MIDIEventStreams.js.map +1 -0
- package/dist/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPort.js +27 -0
- package/dist/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPort.js.map +1 -0
- package/dist/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdAndAccess.js +19 -0
- package/dist/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdAndAccess.js.map +1 -0
- package/dist/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdInContext.js +16 -0
- package/dist/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdInContext.js.map +1 -0
- package/dist/src/internal/MIDIPortMethodCalls/actOnPort.js +17 -0
- package/dist/src/internal/MIDIPortMethodCalls/actOnPort.js.map +1 -0
- package/dist/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPort.js +27 -0
- package/dist/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPort.js.map +1 -0
- package/dist/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdAndAccess.js +18 -0
- package/dist/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdAndAccess.js.map +1 -0
- package/dist/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdInContext.js +16 -0
- package/dist/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdInContext.js.map +1 -0
- package/dist/src/internal/MIDIPortMethodCalls/makeMIDIPortMethodCallerFactory.js +21 -0
- package/dist/src/internal/MIDIPortMethodCalls/makeMIDIPortMethodCallerFactory.js.map +1 -0
- package/dist/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPort.js +34 -0
- package/dist/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPort.js.map +1 -0
- package/dist/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdAndAccess.js +18 -0
- package/dist/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdAndAccess.js.map +1 -0
- package/dist/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdInContext.js +16 -0
- package/dist/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdInContext.js.map +1 -0
- package/dist/src/internal/Parsing.js +119 -0
- package/dist/src/internal/Parsing.js.map +1 -0
- package/dist/src/internal/StreamMaker.js +105 -0
- package/dist/src/internal/StreamMaker.js.map +1 -0
- package/dist/src/internal/Util.js +59 -0
- package/dist/src/internal/Util.js.map +1 -0
- package/dist/src/internal/getPortByPortId/getPortByPortIdAndAccess.js +53 -0
- package/dist/src/internal/getPortByPortId/getPortByPortIdAndAccess.js.map +1 -0
- package/dist/src/internal/getPortByPortId/getPortByPortIdInContext.js +18 -0
- package/dist/src/internal/getPortByPortId/getPortByPortIdInContext.js.map +1 -0
- package/dist/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPort.js +52 -0
- package/dist/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPort.js.map +1 -0
- package/dist/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdAndAccess.js +21 -0
- package/dist/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdAndAccess.js.map +1 -0
- package/dist/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdInContext.js +21 -0
- package/dist/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdInContext.js.map +1 -0
- package/dist/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPort.js +66 -0
- package/dist/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPort.js.map +1 -0
- package/dist/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdAndAccess.js +61 -0
- package/dist/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdAndAccess.js.map +1 -0
- package/dist/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdInContext.js +68 -0
- package/dist/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdInContext.js.map +1 -0
- package/dist/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPort.js +42 -0
- package/dist/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPort.js.map +1 -0
- package/dist/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdAndAccess.js +43 -0
- package/dist/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdAndAccess.js.map +1 -0
- package/dist/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdInContext.js +33 -0
- package/dist/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdInContext.js.map +1 -0
- package/dist/src/internal/mutablePropertyTools/getValueInRawPortFieldUnsafe.js +6 -0
- package/dist/src/internal/mutablePropertyTools/getValueInRawPortFieldUnsafe.js.map +1 -0
- package/dist/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPort.js +46 -0
- package/dist/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPort.js.map +1 -0
- package/dist/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdAndAccess.js +25 -0
- package/dist/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdAndAccess.js.map +1 -0
- package/dist/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdInContext.js +31 -0
- package/dist/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdInContext.js.map +1 -0
- package/dist-types/index.d.ts +2 -0
- package/dist-types/index.d.ts.map +1 -0
- package/dist-types/src/EMIDIAccess.d.ts +18 -0
- package/dist-types/src/EMIDIAccess.d.ts.map +1 -0
- package/dist-types/src/EMIDIInput.d.ts +26 -0
- package/dist-types/src/EMIDIInput.d.ts.map +1 -0
- package/dist-types/src/EMIDIOutput.d.ts +26 -0
- package/dist-types/src/EMIDIOutput.d.ts.map +1 -0
- package/dist-types/src/EMIDIPort.d.ts +26 -0
- package/dist-types/src/EMIDIPort.d.ts.map +1 -0
- package/dist-types/src/MIDIErrors.d.ts +2 -0
- package/dist-types/src/MIDIErrors.d.ts.map +1 -0
- package/dist-types/src/MIDIEventStreams.d.ts +2 -0
- package/dist-types/src/MIDIEventStreams.d.ts.map +1 -0
- package/dist-types/src/Parsing.d.ts +2 -0
- package/dist-types/src/Parsing.d.ts.map +1 -0
- package/dist-types/src/StreamMaker.d.ts +2 -0
- package/dist-types/src/StreamMaker.d.ts.map +1 -0
- package/dist-types/src/Util.d.ts +2 -0
- package/dist-types/src/Util.d.ts.map +1 -0
- package/dist-types/src/index.d.ts +10 -0
- package/dist-types/src/index.d.ts.map +1 -0
- package/dist-types/src/internal/EMIDIAccess.d.ts +551 -0
- package/dist-types/src/internal/EMIDIAccess.d.ts.map +1 -0
- package/dist-types/src/internal/EMIDIInput.d.ts +50 -0
- package/dist-types/src/internal/EMIDIInput.d.ts.map +1 -0
- package/dist-types/src/internal/EMIDIOutput.d.ts +95 -0
- package/dist-types/src/internal/EMIDIOutput.d.ts.map +1 -0
- package/dist-types/src/internal/EMIDIPort.d.ts +90 -0
- package/dist-types/src/internal/EMIDIPort.d.ts.map +1 -0
- package/dist-types/src/internal/MIDIErrors.d.ts +270 -0
- package/dist-types/src/internal/MIDIErrors.d.ts.map +1 -0
- package/dist-types/src/internal/MIDIEventStreams.d.ts +74 -0
- package/dist-types/src/internal/MIDIEventStreams.d.ts.map +1 -0
- package/dist-types/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPort.d.ts +16 -0
- package/dist-types/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPort.d.ts.map +1 -0
- package/dist-types/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdAndAccess.d.ts +15 -0
- package/dist-types/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdAndAccess.d.ts.map +1 -0
- package/dist-types/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdInContext.d.ts +13 -0
- package/dist-types/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdInContext.d.ts.map +1 -0
- package/dist-types/src/internal/MIDIPortMethodCalls/actOnPort.d.ts +11 -0
- package/dist-types/src/internal/MIDIPortMethodCalls/actOnPort.d.ts.map +1 -0
- package/dist-types/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPort.d.ts +23 -0
- package/dist-types/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPort.d.ts.map +1 -0
- package/dist-types/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdAndAccess.d.ts +15 -0
- package/dist-types/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdAndAccess.d.ts.map +1 -0
- package/dist-types/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdInContext.d.ts +13 -0
- package/dist-types/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdInContext.d.ts.map +1 -0
- package/dist-types/src/internal/MIDIPortMethodCalls/makeMIDIPortMethodCallerFactory.d.ts +15 -0
- package/dist-types/src/internal/MIDIPortMethodCalls/makeMIDIPortMethodCallerFactory.d.ts.map +1 -0
- package/dist-types/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPort.d.ts +21 -0
- package/dist-types/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPort.d.ts.map +1 -0
- package/dist-types/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdAndAccess.d.ts +15 -0
- package/dist-types/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdAndAccess.d.ts.map +1 -0
- package/dist-types/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdInContext.d.ts +13 -0
- package/dist-types/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdInContext.d.ts.map +1 -0
- package/dist-types/src/internal/Parsing.d.ts +110 -0
- package/dist-types/src/internal/Parsing.d.ts.map +1 -0
- package/dist-types/src/internal/StreamMaker.d.ts +204 -0
- package/dist-types/src/internal/StreamMaker.d.ts.map +1 -0
- package/dist-types/src/internal/Util.d.ts +33 -0
- package/dist-types/src/internal/Util.d.ts.map +1 -0
- package/dist-types/src/internal/getPortByPortId/getPortByPortIdAndAccess.d.ts +27 -0
- package/dist-types/src/internal/getPortByPortId/getPortByPortIdAndAccess.d.ts.map +1 -0
- package/dist-types/src/internal/getPortByPortId/getPortByPortIdInContext.d.ts +20 -0
- package/dist-types/src/internal/getPortByPortId/getPortByPortIdInContext.d.ts.map +1 -0
- package/dist-types/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPort.d.ts +76 -0
- package/dist-types/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPort.d.ts.map +1 -0
- package/dist-types/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdAndAccess.d.ts +39 -0
- package/dist-types/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdAndAccess.d.ts.map +1 -0
- package/dist-types/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdInContext.d.ts +29 -0
- package/dist-types/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdInContext.d.ts.map +1 -0
- package/dist-types/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPort.d.ts +62 -0
- package/dist-types/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPort.d.ts.map +1 -0
- package/dist-types/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdAndAccess.d.ts +16 -0
- package/dist-types/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdAndAccess.d.ts.map +1 -0
- package/dist-types/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdInContext.d.ts +65 -0
- package/dist-types/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdInContext.d.ts.map +1 -0
- package/dist-types/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPort.d.ts +36 -0
- package/dist-types/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPort.d.ts.map +1 -0
- package/dist-types/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdAndAccess.d.ts +23 -0
- package/dist-types/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdAndAccess.d.ts.map +1 -0
- package/dist-types/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdInContext.d.ts +35 -0
- package/dist-types/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdInContext.d.ts.map +1 -0
- package/dist-types/src/internal/mutablePropertyTools/getValueInRawPortFieldUnsafe.d.ts +7 -0
- package/dist-types/src/internal/mutablePropertyTools/getValueInRawPortFieldUnsafe.d.ts.map +1 -0
- package/dist-types/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPort.d.ts +71 -0
- package/dist-types/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPort.d.ts.map +1 -0
- package/dist-types/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdAndAccess.d.ts +7 -0
- package/dist-types/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdAndAccess.d.ts.map +1 -0
- package/dist-types/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdInContext.d.ts +28 -0
- package/dist-types/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdInContext.d.ts.map +1 -0
- package/index.ts +1 -0
- package/package.json +87 -0
- package/src/EMIDIAccess.ts +285 -0
- package/src/EMIDIInput.ts +273 -0
- package/src/EMIDIOutput.ts +272 -0
- package/src/EMIDIPort.ts +270 -0
- package/src/MIDIErrors.ts +13 -0
- package/src/MIDIEventStreams.ts +36 -0
- package/src/Parsing.ts +32 -0
- package/src/StreamMaker.ts +12 -0
- package/src/Util.ts +19 -0
- package/src/index.ts +9 -0
- package/src/internal/EMIDIAccess.ts +1280 -0
- package/src/internal/EMIDIInput.ts +114 -0
- package/src/internal/EMIDIOutput.ts +231 -0
- package/src/internal/EMIDIPort.ts +239 -0
- package/src/internal/MIDIErrors.ts +260 -0
- package/src/internal/MIDIEventStreams.ts +255 -0
- package/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPort.ts +48 -0
- package/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdAndAccess.ts +31 -0
- package/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdInContext.ts +28 -0
- package/src/internal/MIDIPortMethodCalls/actOnPort.ts +66 -0
- package/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPort.ts +38 -0
- package/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdAndAccess.ts +38 -0
- package/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdInContext.ts +28 -0
- package/src/internal/MIDIPortMethodCalls/makeMIDIPortMethodCallerFactory.ts +68 -0
- package/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPort.ts +48 -0
- package/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdAndAccess.ts +38 -0
- package/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdInContext.ts +28 -0
- package/src/internal/Parsing.ts +304 -0
- package/src/internal/StreamMaker.ts +416 -0
- package/src/internal/Util.ts +152 -0
- package/src/internal/getPortByPortId/getPortByPortIdAndAccess.ts +117 -0
- package/src/internal/getPortByPortId/getPortByPortIdInContext.ts +26 -0
- package/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPort.ts +148 -0
- package/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdAndAccess.ts +135 -0
- package/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdInContext.ts +70 -0
- package/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPort.ts +128 -0
- package/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdAndAccess.ts +74 -0
- package/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdInContext.ts +132 -0
- package/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPort.ts +64 -0
- package/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdAndAccess.ts +114 -0
- package/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdInContext.ts +47 -0
- package/src/internal/mutablePropertyTools/getValueInRawPortFieldUnsafe.ts +12 -0
- package/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPort.ts +182 -0
- package/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdAndAccess.ts +29 -0
- package/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdInContext.ts +87 -0
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import * as Schema from 'effect/Schema'
|
|
2
|
+
import type * as Types from 'effect/Types'
|
|
3
|
+
|
|
4
|
+
import type * as EMIDIAccess from './EMIDIAccess.ts'
|
|
5
|
+
import * as EMIDIPort from './EMIDIPort.ts'
|
|
6
|
+
|
|
7
|
+
// NOTE: stacks are properly extracted from error instances into structs, while
|
|
8
|
+
// decoding
|
|
9
|
+
|
|
10
|
+
const PortId = Schema.fromBrand(EMIDIPort.BothId)(Schema.NonEmptyTrimmedString)
|
|
11
|
+
|
|
12
|
+
const ErrorSchema = <TSchema extends Schema.Schema.Any | undefined = undefined>(
|
|
13
|
+
nameSchema?: TSchema,
|
|
14
|
+
) =>
|
|
15
|
+
Schema.Struct({
|
|
16
|
+
name: (nameSchema ??
|
|
17
|
+
Schema.NonEmptyTrimmedString) as TSchema extends undefined
|
|
18
|
+
? typeof Schema.NonEmptyTrimmedString
|
|
19
|
+
: TSchema,
|
|
20
|
+
message: Schema.NonEmptyTrimmedString,
|
|
21
|
+
stack: Schema.NonEmptyTrimmedString.pipe(
|
|
22
|
+
Schema.optionalWith({ exact: true }),
|
|
23
|
+
),
|
|
24
|
+
cause: Schema.Unknown.pipe(Schema.optionalWith({ exact: true })),
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const midiAccessFailureFields = {
|
|
28
|
+
whileAskingForPermissions: Schema.Struct({
|
|
29
|
+
sysex: Schema.optional(Schema.Boolean),
|
|
30
|
+
software: Schema.optional(Schema.Boolean),
|
|
31
|
+
}),
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Thrown if the document or page is going to be closed due to user navigation.
|
|
36
|
+
*
|
|
37
|
+
* Wraps `DOMException { name: 'AbortError' }`
|
|
38
|
+
*
|
|
39
|
+
* @see {@link https://webidl.spec.whatwg.org/#aborterror|Web IDL spec}
|
|
40
|
+
*/
|
|
41
|
+
export class AbortError extends Schema.TaggedError<AbortError>()('AbortError', {
|
|
42
|
+
cause: ErrorSchema(Schema.Literal('AbortError')),
|
|
43
|
+
}) {
|
|
44
|
+
override get message() {
|
|
45
|
+
return `MIDI access request was interrupted by user navigation, likely because the page was closed`
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Thrown if the underlying system raises any errors when trying to open the
|
|
51
|
+
* port.
|
|
52
|
+
*
|
|
53
|
+
* Wraps `DOMException { name: 'InvalidStateError' }`
|
|
54
|
+
*
|
|
55
|
+
* @see {@link https://webidl.spec.whatwg.org/#invalidstateerror|Web IDL spec}
|
|
56
|
+
*/
|
|
57
|
+
export class UnderlyingSystemError extends Schema.TaggedError<UnderlyingSystemError>()(
|
|
58
|
+
'UnderlyingSystemError',
|
|
59
|
+
{
|
|
60
|
+
cause: ErrorSchema(Schema.Literal('InvalidStateError')),
|
|
61
|
+
...midiAccessFailureFields,
|
|
62
|
+
},
|
|
63
|
+
) {
|
|
64
|
+
override get message() {
|
|
65
|
+
return `Underlying system (OS/browser) raised an error when attempting to open the port`
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Thrown if the MIDI API, or a certain configuration of it is not supported by
|
|
71
|
+
* the system.
|
|
72
|
+
*
|
|
73
|
+
* Wraps `ReferenceError | TypeError | DOMException { name: 'NotSupportedError' }`
|
|
74
|
+
*
|
|
75
|
+
* @see {@link https://webidl.spec.whatwg.org/#notsupportederror|Web IDL spec}
|
|
76
|
+
*/
|
|
77
|
+
export class MIDIAccessNotSupportedError extends Schema.TaggedError<MIDIAccessNotSupportedError>()(
|
|
78
|
+
'MIDIAccessNotSupportedError',
|
|
79
|
+
{
|
|
80
|
+
cause: ErrorSchema(
|
|
81
|
+
Schema.Literal('ReferenceError', 'TypeError', 'NotSupportedError'),
|
|
82
|
+
),
|
|
83
|
+
...midiAccessFailureFields,
|
|
84
|
+
},
|
|
85
|
+
) {
|
|
86
|
+
override get message() {
|
|
87
|
+
return `This platform doesn't support Web MIDI API`
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Thrown on platforms where `.clear()` method of output ports is not supported
|
|
93
|
+
* (currently supported only in Firefox)
|
|
94
|
+
*
|
|
95
|
+
* Wraps `TypeError | DOMException { name: 'NotSupportedError' }`
|
|
96
|
+
*
|
|
97
|
+
* @see {@link https://webidl.spec.whatwg.org/#notsupportederror|Web IDL spec}
|
|
98
|
+
*/
|
|
99
|
+
export class ClearingSendingQueueIsNotSupportedError extends Schema.TaggedError<ClearingSendingQueueIsNotSupportedError>()(
|
|
100
|
+
'ClearingSendingQueueIsNotSupportedError',
|
|
101
|
+
{
|
|
102
|
+
cause: ErrorSchema(Schema.Literal('TypeError', 'NotSupportedError')),
|
|
103
|
+
portId: PortId,
|
|
104
|
+
},
|
|
105
|
+
) {
|
|
106
|
+
override get message() {
|
|
107
|
+
return `This platform doesn't support "MIDIOutput.prototype.clear()" method`
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Thrown when attempt to open the port failed because it is unavailable (e.g.
|
|
113
|
+
* is already in use by another process and cannot be opened, or is
|
|
114
|
+
* disconnected).
|
|
115
|
+
*
|
|
116
|
+
* Wraps `DOMException { name: 'InvalidAccessError' | 'NotAllowedError' | 'InvalidStateError' }`
|
|
117
|
+
*
|
|
118
|
+
* @see Web IDL specs: {@link https://webidl.spec.whatwg.org/#invalidaccesserror|InvalidAccessError}, {@link https://webidl.spec.whatwg.org/#notallowederror|NotAllowedError}, {@link https://webidl.spec.whatwg.org/#invalidstateerror|InvalidStateError}
|
|
119
|
+
*/
|
|
120
|
+
export class CannotOpenUnavailablePortError extends Schema.TaggedError<CannotOpenUnavailablePortError>()(
|
|
121
|
+
'CannotOpenUnavailablePortError',
|
|
122
|
+
{
|
|
123
|
+
cause: ErrorSchema(
|
|
124
|
+
Schema.Literal(
|
|
125
|
+
'InvalidAccessError',
|
|
126
|
+
'NotAllowedError',
|
|
127
|
+
'InvalidStateError',
|
|
128
|
+
),
|
|
129
|
+
),
|
|
130
|
+
portId: PortId,
|
|
131
|
+
},
|
|
132
|
+
) {
|
|
133
|
+
override get message() {
|
|
134
|
+
return `Cannot open an unavailable port. This might happen when it's already in use by another process or is disconnected`
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Thrown when `.send` operation was called on a disconnected port.
|
|
140
|
+
*
|
|
141
|
+
* Wraps `DOMException { name: 'InvalidStateError' }`
|
|
142
|
+
*
|
|
143
|
+
* @see {@link https://webidl.spec.whatwg.org/#invalidaccesserror|Web IDL spec}
|
|
144
|
+
*/
|
|
145
|
+
export class CannotSendToDisconnectedPortError extends Schema.TaggedError<CannotSendToDisconnectedPortError>()(
|
|
146
|
+
'CannotSendToDisconnectedPortError',
|
|
147
|
+
{
|
|
148
|
+
cause: ErrorSchema(Schema.Literal('InvalidStateError')),
|
|
149
|
+
portId: PortId,
|
|
150
|
+
},
|
|
151
|
+
) {
|
|
152
|
+
override get message() {
|
|
153
|
+
return `Cannot send a MIDI message to a disconnected port`
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Thrown when trying to send system exclusive message from the access handle,
|
|
159
|
+
* that doesn't have this permission
|
|
160
|
+
*
|
|
161
|
+
* Wraps `DOMException { name: 'InvalidAccessError' | 'NotAllowedError' }`
|
|
162
|
+
*
|
|
163
|
+
* @see Web IDL specs: {@link https://webidl.spec.whatwg.org/#invalidaccesserror|InvalidAccessError}, {@link https://webidl.spec.whatwg.org/#notallowederror|NotAllowedError}
|
|
164
|
+
*/
|
|
165
|
+
export class CannotSendSysexMessageError extends Schema.TaggedError<CannotSendSysexMessageError>()(
|
|
166
|
+
'CannotSendSysexMessageError',
|
|
167
|
+
{
|
|
168
|
+
cause: ErrorSchema(Schema.Literal('InvalidAccessError', 'NotAllowedError')),
|
|
169
|
+
portId: PortId,
|
|
170
|
+
},
|
|
171
|
+
) {
|
|
172
|
+
override get message() {
|
|
173
|
+
return `Cannot send a system exclusive MIDI message from a MIDI access handle that wasn't permitted to send such messages`
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Thrown if the user, the system or their security settings denied the
|
|
179
|
+
* application from creating an {@linkcode EMIDIAccess.EMIDIAccessInstance} object
|
|
180
|
+
* with the requested {@linkcode EMIDIAccess.RequestMIDIAccessOptions|options}, or if the
|
|
181
|
+
* document is not allowed to use the feature (for example, because of a
|
|
182
|
+
* Permission Policy, or because the user previously denied a permission
|
|
183
|
+
* request).
|
|
184
|
+
*
|
|
185
|
+
* Wraps `DOMException { name: 'NotAllowedError' | 'SecurityError' }`
|
|
186
|
+
*
|
|
187
|
+
* @see Web IDL specs: {@link https://webidl.spec.whatwg.org/#notallowederror|NotAllowedError}, {@link https://webidl.spec.whatwg.org/#securityerror|SecurityError}
|
|
188
|
+
*/
|
|
189
|
+
export class MIDIAccessNotAllowedError extends Schema.TaggedError<MIDIAccessNotAllowedError>()(
|
|
190
|
+
'MIDIAccessNotAllowedError',
|
|
191
|
+
{
|
|
192
|
+
cause: ErrorSchema(Schema.Literal('NotAllowedError', 'SecurityError')),
|
|
193
|
+
...midiAccessFailureFields,
|
|
194
|
+
},
|
|
195
|
+
) {
|
|
196
|
+
override get message() {
|
|
197
|
+
return `Request to use Web MIDI API with specific options was rejected by the user or their security settings`
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Thrown when data to be sent is not a valid sequence or does not contain a
|
|
203
|
+
* valid MIDI message
|
|
204
|
+
*
|
|
205
|
+
* Wraps `TypeError`
|
|
206
|
+
*/
|
|
207
|
+
export class MalformedMIDIMessageError extends Schema.TaggedError<MalformedMIDIMessageError>()(
|
|
208
|
+
'MalformedMIDIMessageError',
|
|
209
|
+
{
|
|
210
|
+
cause: ErrorSchema(Schema.Literal('TypeError')),
|
|
211
|
+
portId: PortId,
|
|
212
|
+
midiMessage: Schema.Array(Schema.Int),
|
|
213
|
+
},
|
|
214
|
+
) {
|
|
215
|
+
override get message() {
|
|
216
|
+
return `Attempted to send invalid MIDI message (${this.midiMessage.length} bytes)`
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Keep in mind that if port isn't found, it might not mean it's disconnected.
|
|
222
|
+
* For example, virtual ports created by software won't show up in the list of
|
|
223
|
+
* available inputs/outputs of MIDI Access handle with disabled
|
|
224
|
+
* {@linkcode EMIDIAccess.RequestMIDIAccessOptions.software} flag.
|
|
225
|
+
*/
|
|
226
|
+
export class PortNotFoundError extends Schema.TaggedError<PortNotFoundError>()(
|
|
227
|
+
'PortNotFound',
|
|
228
|
+
{ portId: PortId },
|
|
229
|
+
) {
|
|
230
|
+
override get message() {
|
|
231
|
+
return `Port with specific ID wasn't found`
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// TODO: Make so that the function also ensures that cause.name is properly matches the map arg field it's assigned from, so that consistency goes both ways
|
|
236
|
+
/**
|
|
237
|
+
*
|
|
238
|
+
* @internal
|
|
239
|
+
*/
|
|
240
|
+
export const remapErrorByName =
|
|
241
|
+
<TErrorClassUnion extends new (arg: any) => Error>(
|
|
242
|
+
map: { [name: string]: TErrorClassUnion },
|
|
243
|
+
absurdMessage: string,
|
|
244
|
+
rest: Omit<
|
|
245
|
+
Types.UnionToIntersection<
|
|
246
|
+
TErrorClassUnion extends new (arg: infer P) => any ? P : never
|
|
247
|
+
>,
|
|
248
|
+
'cause'
|
|
249
|
+
>,
|
|
250
|
+
) =>
|
|
251
|
+
(cause: unknown) => {
|
|
252
|
+
if (!(cause instanceof Error && cause.name in map))
|
|
253
|
+
throw new Error(absurdMessage)
|
|
254
|
+
// biome-ignore lint/style/noNonNullAssertion: Because we checked it above with `cause.name in map`
|
|
255
|
+
const Class = map[cause.name]!
|
|
256
|
+
return new Class({
|
|
257
|
+
cause,
|
|
258
|
+
...rest,
|
|
259
|
+
}) as InstanceType<TErrorClassUnion>
|
|
260
|
+
}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import * as EFunction from 'effect/Function'
|
|
2
|
+
import * as Stream from 'effect/Stream'
|
|
3
|
+
|
|
4
|
+
import * as EMIDIAccess from './EMIDIAccess.ts'
|
|
5
|
+
import * as EMIDIInput from './EMIDIInput.ts'
|
|
6
|
+
import { getInputByPortIdAndAccess } from './getPortByPortId/getPortByPortIdAndAccess.ts'
|
|
7
|
+
import type * as MIDIErrors from './MIDIErrors.ts'
|
|
8
|
+
import * as Parsing from './Parsing.ts'
|
|
9
|
+
import type * as StreamMaker from './StreamMaker.ts'
|
|
10
|
+
import * as Util from './Util.ts'
|
|
11
|
+
|
|
12
|
+
const buildSpecificEventStreamByInputIdAndAccessMaker = <
|
|
13
|
+
Payload extends Parsing.TaggedObject,
|
|
14
|
+
>(
|
|
15
|
+
predicate: Parsing.MessagePredicate<Payload>,
|
|
16
|
+
): DualMakeSpecificMessageStreamFromAccess<Payload> => {
|
|
17
|
+
const makeSpecificMessageStreamByInput =
|
|
18
|
+
buildSpecificMessageStreamByInputMaker(predicate)
|
|
19
|
+
|
|
20
|
+
return EFunction.dual(
|
|
21
|
+
Util.polymorphicCheckInDual(EMIDIAccess.is),
|
|
22
|
+
(polymorphicAccess, id, options) =>
|
|
23
|
+
makeSpecificMessageStreamByInput(
|
|
24
|
+
getInputByPortIdAndAccess(polymorphicAccess, id),
|
|
25
|
+
options,
|
|
26
|
+
),
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const buildSpecificMessagesStreamByInputIdInContextMaker = <
|
|
31
|
+
Payload extends Parsing.TaggedObject,
|
|
32
|
+
>(
|
|
33
|
+
predicate: Parsing.MessagePredicate<Payload>,
|
|
34
|
+
) => {
|
|
35
|
+
const makeSpecificMessageStreamByAccess =
|
|
36
|
+
buildSpecificEventStreamByInputIdAndAccessMaker(predicate)
|
|
37
|
+
|
|
38
|
+
return <const TForbidNullsStrategy extends ForbidNullsStrategy = undefined>(
|
|
39
|
+
id: EMIDIInput.Id,
|
|
40
|
+
options?: StreamMaker.StreamMakerOptions<TForbidNullsStrategy>,
|
|
41
|
+
) => makeSpecificMessageStreamByAccess(EMIDIAccess.EMIDIAccess, id, options)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const buildSpecificMessageStreamByInputMaker = <
|
|
45
|
+
Payload extends Parsing.TaggedObject,
|
|
46
|
+
>(
|
|
47
|
+
predicate: Parsing.MessagePredicate<Payload>,
|
|
48
|
+
): DualMakeSpecificMessageStreamFromInput<Payload> =>
|
|
49
|
+
EFunction.dual(
|
|
50
|
+
Util.polymorphicCheckInDual(EMIDIInput.is),
|
|
51
|
+
EFunction.flow(
|
|
52
|
+
EMIDIInput.makeMessagesStreamByPort as any,
|
|
53
|
+
Parsing.withParsedDataField,
|
|
54
|
+
Stream.filter(predicate),
|
|
55
|
+
),
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
export type ForbidNullsStrategy = Exclude<
|
|
59
|
+
StreamMaker.OnNullStrategy,
|
|
60
|
+
'passthrough'
|
|
61
|
+
>
|
|
62
|
+
|
|
63
|
+
export interface DualMakeSpecificMessageStreamFromInput<
|
|
64
|
+
Payload extends Parsing.TaggedObject,
|
|
65
|
+
> extends MakeSpecificMessageStreamInputLast<Payload>,
|
|
66
|
+
MakeSpecificMessageStreamInputFirst<Payload> {}
|
|
67
|
+
|
|
68
|
+
export interface MakeSpecificMessageStreamInputFirst<
|
|
69
|
+
Payload extends Parsing.TaggedObject,
|
|
70
|
+
> {
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
*/
|
|
74
|
+
<
|
|
75
|
+
E = never,
|
|
76
|
+
R = never,
|
|
77
|
+
const TForbidNullsStrategy extends ForbidNullsStrategy = undefined,
|
|
78
|
+
>(
|
|
79
|
+
polymorphicInput: EMIDIInput.PolymorphicInput<E, R>,
|
|
80
|
+
options?: StreamMaker.StreamMakerOptions<TForbidNullsStrategy>,
|
|
81
|
+
): MakeSpecificMessageStreamResult<Payload, TForbidNullsStrategy, E, R>
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface MakeSpecificMessageStreamInputLast<
|
|
85
|
+
Payload extends Parsing.TaggedObject,
|
|
86
|
+
> {
|
|
87
|
+
/**
|
|
88
|
+
*
|
|
89
|
+
*/
|
|
90
|
+
<const TForbidNullsStrategy extends ForbidNullsStrategy = undefined>(
|
|
91
|
+
options?: StreamMaker.StreamMakerOptions<TForbidNullsStrategy>,
|
|
92
|
+
): MakeSpecificMessageStreamInputLastSecondPart<Payload, TForbidNullsStrategy>
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface MakeSpecificMessageStreamInputLastSecondPart<
|
|
96
|
+
Payload extends Parsing.TaggedObject,
|
|
97
|
+
TForbidNullsStrategy extends ForbidNullsStrategy,
|
|
98
|
+
> {
|
|
99
|
+
/**
|
|
100
|
+
*
|
|
101
|
+
*/
|
|
102
|
+
<E = never, R = never>(
|
|
103
|
+
polymorphicInput: EMIDIInput.PolymorphicInput<E, R>,
|
|
104
|
+
): MakeSpecificMessageStreamResult<Payload, TForbidNullsStrategy, E, R>
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
////////////////////////////////////////////////////
|
|
108
|
+
////////////////////////////////////////////////////
|
|
109
|
+
////////////////////////////////////////////////////
|
|
110
|
+
|
|
111
|
+
export interface DualMakeSpecificMessageStreamFromAccess<
|
|
112
|
+
Payload extends Parsing.TaggedObject,
|
|
113
|
+
> extends MakeSpecificMessageStreamAccessLast<Payload>,
|
|
114
|
+
MakeSpecificMessageStreamAccessFirst<Payload> {}
|
|
115
|
+
|
|
116
|
+
export interface MakeSpecificMessageStreamAccessFirst<
|
|
117
|
+
Payload extends Parsing.TaggedObject,
|
|
118
|
+
> {
|
|
119
|
+
/**
|
|
120
|
+
*
|
|
121
|
+
*/
|
|
122
|
+
<
|
|
123
|
+
E = never,
|
|
124
|
+
R = never,
|
|
125
|
+
const TForbidNullsStrategy extends ForbidNullsStrategy = undefined,
|
|
126
|
+
>(
|
|
127
|
+
polymorphicAccess: EMIDIAccess.PolymorphicAccessInstance<E, R>,
|
|
128
|
+
id: EMIDIInput.Id,
|
|
129
|
+
options?: StreamMaker.StreamMakerOptions<TForbidNullsStrategy>,
|
|
130
|
+
): MakeSpecificMessageStreamResult<
|
|
131
|
+
Payload,
|
|
132
|
+
TForbidNullsStrategy,
|
|
133
|
+
E | MIDIErrors.PortNotFoundError,
|
|
134
|
+
R
|
|
135
|
+
>
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface MakeSpecificMessageStreamAccessLast<
|
|
139
|
+
Payload extends Parsing.TaggedObject,
|
|
140
|
+
> {
|
|
141
|
+
/**
|
|
142
|
+
*
|
|
143
|
+
*/
|
|
144
|
+
<const TForbidNullsStrategy extends ForbidNullsStrategy = undefined>(
|
|
145
|
+
id: EMIDIInput.Id,
|
|
146
|
+
options?: StreamMaker.StreamMakerOptions<TForbidNullsStrategy>,
|
|
147
|
+
): MakeSpecificMessageStreamAccessLastSecondPart<
|
|
148
|
+
Payload,
|
|
149
|
+
TForbidNullsStrategy
|
|
150
|
+
>
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface MakeSpecificMessageStreamAccessLastSecondPart<
|
|
154
|
+
Payload extends Parsing.TaggedObject,
|
|
155
|
+
TForbidNullsStrategy extends ForbidNullsStrategy,
|
|
156
|
+
> {
|
|
157
|
+
/**
|
|
158
|
+
*
|
|
159
|
+
*/
|
|
160
|
+
<E = never, R = never>(
|
|
161
|
+
polymorphicAccess: EMIDIAccess.PolymorphicAccessInstance<E, R>,
|
|
162
|
+
): MakeSpecificMessageStreamResult<
|
|
163
|
+
Payload,
|
|
164
|
+
TForbidNullsStrategy,
|
|
165
|
+
E | MIDIErrors.PortNotFoundError,
|
|
166
|
+
R
|
|
167
|
+
>
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
export interface MakeSpecificMessageStreamResult<
|
|
171
|
+
Payload extends Parsing.TaggedObject,
|
|
172
|
+
TForbidNullsStrategy extends ForbidNullsStrategy,
|
|
173
|
+
E,
|
|
174
|
+
R,
|
|
175
|
+
> extends Stream.Stream<
|
|
176
|
+
Parsing.ParsedMIDIMessage<Payload>,
|
|
177
|
+
StreamMaker.StreamError<TForbidNullsStrategy, E>,
|
|
178
|
+
R
|
|
179
|
+
> {}
|
|
180
|
+
|
|
181
|
+
export const makeNoteReleaseStreamByInput =
|
|
182
|
+
buildSpecificMessageStreamByInputMaker(Parsing.isNoteRelease)
|
|
183
|
+
|
|
184
|
+
export const makeNoteReleaseStreamByInputIdAndAccess =
|
|
185
|
+
buildSpecificEventStreamByInputIdAndAccessMaker(Parsing.isNoteRelease)
|
|
186
|
+
|
|
187
|
+
export const makeNoteReleaseStreamByInputIdInContext =
|
|
188
|
+
buildSpecificMessagesStreamByInputIdInContextMaker(Parsing.isNoteRelease)
|
|
189
|
+
|
|
190
|
+
export const makeNotePressStreamByInput =
|
|
191
|
+
buildSpecificMessageStreamByInputMaker(Parsing.isNotePress)
|
|
192
|
+
|
|
193
|
+
export const makeNotePressStreamByInputIdAndAccess =
|
|
194
|
+
buildSpecificEventStreamByInputIdAndAccessMaker(Parsing.isNotePress)
|
|
195
|
+
|
|
196
|
+
export const makeNotePressStreamByInputIdInContext =
|
|
197
|
+
buildSpecificMessagesStreamByInputIdInContextMaker(Parsing.isNotePress)
|
|
198
|
+
|
|
199
|
+
export const makeUnknownReplyStreamByInput =
|
|
200
|
+
buildSpecificMessageStreamByInputMaker(Parsing.isUnknownReply)
|
|
201
|
+
|
|
202
|
+
export const makeUnknownReplyStreamByInputIdAndAccess =
|
|
203
|
+
buildSpecificEventStreamByInputIdAndAccessMaker(Parsing.isUnknownReply)
|
|
204
|
+
|
|
205
|
+
export const makeUnknownReplyStreamByInputIdInContext =
|
|
206
|
+
buildSpecificMessagesStreamByInputIdInContextMaker(Parsing.isUnknownReply)
|
|
207
|
+
|
|
208
|
+
export const makeControlChangeStreamByInput =
|
|
209
|
+
buildSpecificMessageStreamByInputMaker(Parsing.isControlChange)
|
|
210
|
+
|
|
211
|
+
export const makeControlChangeStreamByInputIdAndAccess =
|
|
212
|
+
buildSpecificEventStreamByInputIdAndAccessMaker(Parsing.isControlChange)
|
|
213
|
+
|
|
214
|
+
export const makeControlChangeStreamByInputIdInContext =
|
|
215
|
+
buildSpecificMessagesStreamByInputIdInContextMaker(Parsing.isControlChange)
|
|
216
|
+
|
|
217
|
+
export const makeChannelPressureStreamByInput =
|
|
218
|
+
buildSpecificMessageStreamByInputMaker(Parsing.isChannelPressure)
|
|
219
|
+
|
|
220
|
+
export const makeChannelPressureStreamByInputIdAndAccess =
|
|
221
|
+
buildSpecificEventStreamByInputIdAndAccessMaker(Parsing.isChannelPressure)
|
|
222
|
+
|
|
223
|
+
export const makeChannelPressureStreamByInputIdInContext =
|
|
224
|
+
buildSpecificMessagesStreamByInputIdInContextMaker(Parsing.isChannelPressure)
|
|
225
|
+
|
|
226
|
+
export const makeTouchpadReleaseStreamByInput =
|
|
227
|
+
buildSpecificMessageStreamByInputMaker(Parsing.isTouchpadRelease)
|
|
228
|
+
|
|
229
|
+
export const makeTouchpadReleaseStreamByInputIdAndAccess =
|
|
230
|
+
buildSpecificEventStreamByInputIdAndAccessMaker(Parsing.isTouchpadRelease)
|
|
231
|
+
|
|
232
|
+
export const makeTouchpadReleaseStreamByInputIdInContext =
|
|
233
|
+
buildSpecificMessagesStreamByInputIdInContextMaker(Parsing.isTouchpadRelease)
|
|
234
|
+
|
|
235
|
+
export const makePitchBendChangeStreamByInput =
|
|
236
|
+
buildSpecificMessageStreamByInputMaker(Parsing.isPitchBendChange)
|
|
237
|
+
|
|
238
|
+
export const makePitchBendChangeStreamByInputIdAndAccess =
|
|
239
|
+
buildSpecificEventStreamByInputIdAndAccessMaker(Parsing.isPitchBendChange)
|
|
240
|
+
|
|
241
|
+
export const makePitchBendChangeStreamByInputIdInContext =
|
|
242
|
+
buildSpecificMessagesStreamByInputIdInContextMaker(Parsing.isPitchBendChange)
|
|
243
|
+
|
|
244
|
+
export const makeTouchpadPositionUpdateStreamByInput =
|
|
245
|
+
buildSpecificMessageStreamByInputMaker(Parsing.isTouchpadPositionUpdate)
|
|
246
|
+
|
|
247
|
+
export const makeTouchpadPositionUpdateStreamByInputIdAndAccess =
|
|
248
|
+
buildSpecificEventStreamByInputIdAndAccessMaker(
|
|
249
|
+
Parsing.isTouchpadPositionUpdate,
|
|
250
|
+
)
|
|
251
|
+
|
|
252
|
+
export const makeTouchpadPositionUpdateStreamByInputIdInContext =
|
|
253
|
+
buildSpecificMessagesStreamByInputIdInContextMaker(
|
|
254
|
+
Parsing.isTouchpadPositionUpdate,
|
|
255
|
+
)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as Effect from 'effect/Effect'
|
|
2
|
+
import type * as Scope from 'effect/Scope'
|
|
3
|
+
|
|
4
|
+
import * as EMIDIInput from '../../EMIDIInput.ts'
|
|
5
|
+
import * as EMIDIOutput from '../../EMIDIOutput.ts'
|
|
6
|
+
import * as EMIDIPort from '../../EMIDIPort.ts'
|
|
7
|
+
import type * as MIDIErrors from '../../MIDIErrors.ts'
|
|
8
|
+
import * as Close from '../closePortConnection/closePortConnectionByPort.ts'
|
|
9
|
+
import type { TouchPort } from '../makeMIDIPortMethodCallerFactory.ts'
|
|
10
|
+
import * as Open from '../openPortConnection/openPortConnectionByPort.ts'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
const makeConnectionAcquirerReleaser =
|
|
16
|
+
<THighLevelPortType extends MIDIPortType>(
|
|
17
|
+
is: (port: unknown) => port is EMIDIPort.EMIDIPort<THighLevelPortType>,
|
|
18
|
+
): TouchPort<
|
|
19
|
+
MIDIErrors.CannotOpenUnavailablePortError,
|
|
20
|
+
Scope.Scope,
|
|
21
|
+
THighLevelPortType
|
|
22
|
+
> =>
|
|
23
|
+
/**
|
|
24
|
+
* @returns An effect with the same port for easier chaining of operations
|
|
25
|
+
*/
|
|
26
|
+
port =>
|
|
27
|
+
Effect.acquireRelease(
|
|
28
|
+
Open.makePortConnectionOpener(is)(port),
|
|
29
|
+
Close.makePortConnectionCloser(is),
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
*/
|
|
35
|
+
export const acquireReleasePortConnectionByPort =
|
|
36
|
+
makeConnectionAcquirerReleaser(EMIDIPort.is)
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
*/
|
|
41
|
+
export const acquireReleaseInputConnectionByPort =
|
|
42
|
+
makeConnectionAcquirerReleaser(EMIDIInput.is)
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
*
|
|
46
|
+
*/
|
|
47
|
+
export const acquireReleaseOutputConnectionByPort =
|
|
48
|
+
makeConnectionAcquirerReleaser(EMIDIOutput.is)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// TODO: acquireReleasePortConnectionByPortIdAndAccess.ts
|
|
2
|
+
/** biome-ignore-all lint/style/useShorthandFunctionType: It's a nice way to
|
|
3
|
+
* preserve JSDoc comments attached to the function signature */
|
|
4
|
+
|
|
5
|
+
import * as Get from '../../getPortByPortId/getPortByPortIdAndAccess.ts'
|
|
6
|
+
import { actOnPort } from '../actOnPort.ts'
|
|
7
|
+
import * as AR from './acquireReleasePortConnectionByPort.ts'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
*/
|
|
12
|
+
export const acquireReleasePortConnectionByPortIdAndAccess = actOnPort(
|
|
13
|
+
Get.getPortByPortIdAndAccess,
|
|
14
|
+
AR.acquireReleasePortConnectionByPort,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
export const acquireReleaseInputConnectionByPortIdAndAccess = actOnPort(
|
|
21
|
+
Get.getInputByPortIdAndAccess,
|
|
22
|
+
AR.acquireReleaseInputConnectionByPort,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
*
|
|
27
|
+
*/
|
|
28
|
+
export const acquireReleaseOutputConnectionByPortIdAndAccess = actOnPort(
|
|
29
|
+
Get.getOutputByPortIdAndAccess,
|
|
30
|
+
AR.acquireReleaseOutputConnectionByPort,
|
|
31
|
+
)
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { flow } from 'effect/Function'
|
|
2
|
+
|
|
3
|
+
import * as Get from '../../getPortByPortId/getPortByPortIdInContext.ts'
|
|
4
|
+
import * as Acquire from './acquireReleasePortConnectionByPort.ts'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export const acquireReleasePortConnectionByPortIdInContext = flow(
|
|
10
|
+
Get.getPortByPortIdInContext,
|
|
11
|
+
Acquire.acquireReleasePortConnectionByPort,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
export const acquireReleaseInputConnectionByPortIdInContext = flow(
|
|
18
|
+
Get.getInputByPortIdInContext,
|
|
19
|
+
Acquire.acquireReleaseInputConnectionByPort,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
export const acquireReleaseOutputConnectionByPortIdInContext = flow(
|
|
26
|
+
Get.getOutputByPortIdInContext,
|
|
27
|
+
Acquire.acquireReleaseOutputConnectionByPort,
|
|
28
|
+
)
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
|
|
7
|
+
import * as EMIDIAccess from '../EMIDIAccess.ts'
|
|
8
|
+
import type * as EMIDIPort from '../EMIDIPort.ts'
|
|
9
|
+
import type * as Get from '../getPortByPortId/getPortByPortIdAndAccess.ts'
|
|
10
|
+
import type * as Make from './makeMIDIPortMethodCallerFactory.ts'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export const actOnPort = <
|
|
17
|
+
TTypeOfPortId extends MIDIPortType,
|
|
18
|
+
TPortTypeReturnedFromAccess extends TPortTypeSupportedInActing &
|
|
19
|
+
TTypeOfPortId,
|
|
20
|
+
TPortTypeSupportedInActing extends MIDIPortType,
|
|
21
|
+
TPortGettingError = never,
|
|
22
|
+
TPortGettingRequirement = never,
|
|
23
|
+
TPortActingError = never,
|
|
24
|
+
TPortActingRequirement = never,
|
|
25
|
+
>(
|
|
26
|
+
getPortFromAccessAndPortId: Get.GetPortById<
|
|
27
|
+
TPortTypeReturnedFromAccess,
|
|
28
|
+
TTypeOfPortId,
|
|
29
|
+
never,
|
|
30
|
+
never,
|
|
31
|
+
TPortGettingError,
|
|
32
|
+
TPortGettingRequirement
|
|
33
|
+
>,
|
|
34
|
+
act: Make.TouchPort<
|
|
35
|
+
TPortActingError,
|
|
36
|
+
TPortActingRequirement,
|
|
37
|
+
TPortTypeSupportedInActing
|
|
38
|
+
>,
|
|
39
|
+
): EMIDIAccess.GetThingByPortId<
|
|
40
|
+
EMIDIAccess.EMIDIAccessInstance,
|
|
41
|
+
TPortTypeReturnedFromAccess,
|
|
42
|
+
never,
|
|
43
|
+
never,
|
|
44
|
+
TPortGettingError | TPortActingError,
|
|
45
|
+
TPortGettingRequirement | TPortActingRequirement
|
|
46
|
+
> =>
|
|
47
|
+
EFunction.dual(
|
|
48
|
+
2,
|
|
49
|
+
(polymorphicAccess, portId) =>
|
|
50
|
+
Effect.gen(function* () {
|
|
51
|
+
const access = yield* EMIDIAccess.simplify(polymorphicAccess)
|
|
52
|
+
|
|
53
|
+
const port = yield* getPortFromAccessAndPortId(
|
|
54
|
+
access,
|
|
55
|
+
portId as unknown as EMIDIPort.Id<TTypeOfPortId>,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
const actEffect = act(
|
|
59
|
+
port as unknown as EMIDIPort.EMIDIPort<TPortTypeSupportedInActing>,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
yield* actEffect
|
|
63
|
+
|
|
64
|
+
return access
|
|
65
|
+
}) as any,
|
|
66
|
+
)
|