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.
- package/README.md +7 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/src/EMIDIAccess.js +68 -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 +225 -0
- package/dist/src/EMIDIOutput.js.map +1 -0
- package/dist/src/EMIDIPort.js +213 -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/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 +4 -0
- package/dist/src/Util.js.map +1 -0
- package/dist/src/index.js +9 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/internal/EMIDIAccess.js +409 -0
- package/dist/src/internal/EMIDIAccess.js.map +1 -0
- package/dist/src/internal/EMIDIInput.js +69 -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/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 +18 -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 +30 -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/StreamMaker.js +101 -0
- package/dist/src/internal/StreamMaker.js.map +1 -0
- package/dist/src/internal/errors.js +161 -0
- package/dist/src/internal/errors.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 +13 -0
- package/dist/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdAndAccess.js.map +1 -0
- package/dist/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdInContext.js +18 -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 +61 -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 +42 -0
- package/dist/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdAndAccess.js.map +1 -0
- package/dist/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdInContext.js +29 -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/src/internal/parsing.js +117 -0
- package/dist/src/internal/parsing.js.map +1 -0
- package/dist/src/internal/util.js +59 -0
- package/dist/src/internal/util.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 +27 -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/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 +9 -0
- package/dist-types/src/index.d.ts.map +1 -0
- package/dist-types/src/internal/EMIDIAccess.d.ts +339 -0
- package/dist-types/src/internal/EMIDIAccess.d.ts.map +1 -0
- package/dist-types/src/internal/EMIDIInput.d.ts +48 -0
- package/dist-types/src/internal/EMIDIInput.d.ts.map +1 -0
- package/dist-types/src/internal/EMIDIOutput.d.ts +93 -0
- package/dist-types/src/internal/EMIDIOutput.d.ts.map +1 -0
- package/dist-types/src/internal/EMIDIPort.d.ts +87 -0
- package/dist-types/src/internal/EMIDIPort.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/StreamMaker.d.ts +202 -0
- package/dist-types/src/internal/StreamMaker.d.ts.map +1 -0
- package/dist-types/src/internal/errors.d.ts +260 -0
- package/dist-types/src/internal/errors.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 +71 -0
- package/dist-types/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPort.d.ts.map +1 -0
- package/dist-types/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdAndAccess.d.ts +4 -0
- package/dist-types/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdAndAccess.d.ts.map +1 -0
- package/dist-types/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdInContext.d.ts +20 -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 +16 -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 +22 -0
- package/dist-types/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdAndAccess.d.ts.map +1 -0
- package/dist-types/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdInContext.d.ts +17 -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/dist-types/src/internal/parsing.d.ts +72 -0
- package/dist-types/src/internal/parsing.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/index.ts +1 -0
- package/package.json +83 -0
- package/src/EMIDIAccess.ts +271 -0
- package/src/EMIDIInput.ts +270 -0
- package/src/EMIDIOutput.ts +269 -0
- package/src/EMIDIPort.ts +267 -0
- package/src/MIDIErrors.ts +13 -0
- package/src/Parsing.ts +12 -0
- package/src/StreamMaker.ts +12 -0
- package/src/Util.ts +19 -0
- package/src/index.ts +8 -0
- package/src/internal/EMIDIAccess.ts +893 -0
- package/src/internal/EMIDIInput.ts +114 -0
- package/src/internal/EMIDIOutput.ts +228 -0
- package/src/internal/EMIDIPort.ts +233 -0
- package/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPort.ts +43 -0
- package/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdAndAccess.ts +39 -0
- package/src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdInContext.ts +27 -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 +27 -0
- package/src/internal/MIDIPortMethodCalls/makeMIDIPortMethodCallerFactory.ts +73 -0
- package/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPort.ts +44 -0
- package/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdAndAccess.ts +38 -0
- package/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdInContext.ts +27 -0
- package/src/internal/StreamMaker.ts +414 -0
- package/src/internal/errors.ts +220 -0
- package/src/internal/getPortByPortId/getPortByPortIdAndAccess.ts +116 -0
- package/src/internal/getPortByPortId/getPortByPortIdInContext.ts +26 -0
- package/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPort.ts +148 -0
- package/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdAndAccess.ts +14 -0
- package/src/internal/makePortStateChangesStream/makePortStateChangesStreamByPortIdInContext.ts +51 -0
- package/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPort.ts +127 -0
- package/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdAndAccess.ts +74 -0
- package/src/internal/mutablePropertyTools/doesMutablePortPropertyHaveSpecificValue/doesMutablePortPropertyHaveSpecificValueByPortIdInContext.ts +74 -0
- package/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPort.ts +63 -0
- package/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdAndAccess.ts +110 -0
- package/src/internal/mutablePropertyTools/getMutablePortProperty/getMutablePortPropertyByPortIdInContext.ts +37 -0
- package/src/internal/mutablePropertyTools/getValueInRawPortFieldUnsafe.ts +12 -0
- package/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPort.ts +183 -0
- package/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdAndAccess.ts +29 -0
- package/src/internal/mutablePropertyTools/matchMutablePortProperty/matchMutablePortPropertyByPortIdInContext.ts +86 -0
- package/src/internal/parsing.ts +219 -0
- package/src/internal/util.ts +152 -0
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/useShorthandFunctionType: It's a nice way to
|
|
2
|
+
* preserve JSDoc comments attached to the function signature */
|
|
3
|
+
import * as Brand from 'effect/Brand';
|
|
4
|
+
import * as Equal from 'effect/Equal';
|
|
5
|
+
import * as Hash from 'effect/Hash';
|
|
6
|
+
import * as Inspectable from 'effect/Inspectable';
|
|
7
|
+
import * as Pipeable from 'effect/Pipeable';
|
|
8
|
+
/**
|
|
9
|
+
* Unique symbol used for distinguishing {@linkcode EMIDIPort} instances
|
|
10
|
+
* from other objects at both runtime and type-level
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
const TypeId = Symbol.for('effect-web-midi/EMIDIPort');
|
|
14
|
+
/**
|
|
15
|
+
* Prototype of all {@linkcode EMIDIPort} instances
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
const CommonProto = {
|
|
19
|
+
_tag: 'EMIDIPort',
|
|
20
|
+
[TypeId]: TypeId,
|
|
21
|
+
[Hash.symbol]() {
|
|
22
|
+
return Hash.string(this.id);
|
|
23
|
+
},
|
|
24
|
+
[Equal.symbol](that) {
|
|
25
|
+
return 'id' in that && this.id === that.id;
|
|
26
|
+
},
|
|
27
|
+
pipe() {
|
|
28
|
+
// biome-ignore lint/complexity/noArguments: Effect's tradition
|
|
29
|
+
return Pipeable.pipeArguments(this, arguments);
|
|
30
|
+
},
|
|
31
|
+
toString() {
|
|
32
|
+
return Inspectable.format(this.toJSON());
|
|
33
|
+
},
|
|
34
|
+
toJSON() {
|
|
35
|
+
return {
|
|
36
|
+
_id: 'EMIDIPort',
|
|
37
|
+
id: this.id,
|
|
38
|
+
name: this.name,
|
|
39
|
+
manufacturer: this.manufacturer,
|
|
40
|
+
version: this.version,
|
|
41
|
+
type: this.type,
|
|
42
|
+
};
|
|
43
|
+
},
|
|
44
|
+
[Inspectable.NodeInspectSymbol]() {
|
|
45
|
+
return this.toJSON();
|
|
46
|
+
},
|
|
47
|
+
get id() {
|
|
48
|
+
return BothId(assumeImpl(this)._port.id);
|
|
49
|
+
},
|
|
50
|
+
get name() {
|
|
51
|
+
return assumeImpl(this)._port.name;
|
|
52
|
+
},
|
|
53
|
+
get manufacturer() {
|
|
54
|
+
return assumeImpl(this)._port.manufacturer;
|
|
55
|
+
},
|
|
56
|
+
get version() {
|
|
57
|
+
return assumeImpl(this)._port.version;
|
|
58
|
+
},
|
|
59
|
+
get type() {
|
|
60
|
+
return assumeImpl(this)._port.type;
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
*
|
|
65
|
+
*
|
|
66
|
+
* @internal
|
|
67
|
+
*/
|
|
68
|
+
export const makeImpl = (port, type, ClassToAssertInheritance) => {
|
|
69
|
+
if (port.type !== type || !(port instanceof ClassToAssertInheritance))
|
|
70
|
+
throw new Error(`EMIDIPort constructor accepts only ${type} ports`);
|
|
71
|
+
const instance = Object.create(CommonProto);
|
|
72
|
+
instance._port = port;
|
|
73
|
+
return instance;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Asserts an object to be valid EMIDIPort and casts it to internal
|
|
77
|
+
* implementation type
|
|
78
|
+
*
|
|
79
|
+
* @internal
|
|
80
|
+
*/
|
|
81
|
+
const assertImpl = (port) => {
|
|
82
|
+
if (!isGeneralImpl(port))
|
|
83
|
+
throw new Error('Failed to cast to EMIDIPort');
|
|
84
|
+
return port;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Asserts an object to be valid EMIDIPort
|
|
88
|
+
*/
|
|
89
|
+
export const assert = assertImpl;
|
|
90
|
+
/**
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
export const assumeImpl = (port) => port;
|
|
94
|
+
/**
|
|
95
|
+
*
|
|
96
|
+
*
|
|
97
|
+
* @internal
|
|
98
|
+
*/
|
|
99
|
+
const isGeneralImpl = (port) => typeof port === 'object' &&
|
|
100
|
+
port !== null &&
|
|
101
|
+
Object.getPrototypeOf(port) === CommonProto &&
|
|
102
|
+
TypeId in port &&
|
|
103
|
+
'type' in port &&
|
|
104
|
+
'_port' in port &&
|
|
105
|
+
typeof port._port === 'object' &&
|
|
106
|
+
port._port instanceof MIDIPort;
|
|
107
|
+
/**
|
|
108
|
+
*
|
|
109
|
+
*
|
|
110
|
+
* @internal
|
|
111
|
+
*/
|
|
112
|
+
export const isImplOfSpecificType = (type, ClassToAssertInheritance) => (port) => {
|
|
113
|
+
if (!ClassToAssertInheritance)
|
|
114
|
+
throw new Error('Called in a context where ClassToAssertInheritance is falsy, probably on a platform where MIDI APIs are not supported, like node.js or bun');
|
|
115
|
+
return (isGeneralImpl(port) &&
|
|
116
|
+
port.type === type &&
|
|
117
|
+
port._port instanceof ClassToAssertInheritance);
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
*
|
|
121
|
+
*
|
|
122
|
+
*/
|
|
123
|
+
export const is = isGeneralImpl;
|
|
124
|
+
export const BothId = Brand.nominal();
|
|
125
|
+
//# sourceMappingURL=EMIDIPort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EMIDIPort.js","sourceRoot":"","sources":["../../../src/internal/EMIDIPort.ts"],"names":[],"mappings":"AAAA;gEACgE;AAEhE,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAA;AACnC,OAAO,KAAK,WAAW,MAAM,oBAAoB,CAAA;AACjD,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAA;AAG3C;;;;GAIG;AACH,MAAM,MAAM,GAAkB,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAA;AAQrE;;;GAGG;AACH,MAAM,WAAW,GAAG;IAClB,IAAI,EAAE,WAAoB;IAE1B,CAAC,MAAM,CAAC,EAAE,MAAM;IAEhB,CAAC,IAAI,CAAC,MAAM,CAAC;QACX,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC7B,CAAC;IAED,CAAC,KAAK,CAAC,MAAM,CAAC,CAAsB,IAAiB;QACnD,OAAO,IAAI,IAAI,IAAI,IAAI,IAAI,CAAC,EAAE,KAAK,IAAI,CAAC,EAAE,CAAA;IAC5C,CAAC;IAED,IAAI;QACF,+DAA+D;QAC/D,OAAO,QAAQ,CAAC,aAAa,CAAC,IAAI,EAAE,SAAS,CAAC,CAAA;IAChD,CAAC;IAED,QAAQ;QACN,OAAO,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;IAC1C,CAAC;IAED,MAAM;QACJ,OAAO;YACL,GAAG,EAAE,WAAW;YAChB,EAAE,EAAE,IAAI,CAAC,EAAE;YACX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MIDIOutput.js";
|
|
4
|
+
import * as EMIDIPort from "../../EMIDIPort.js";
|
|
5
|
+
import * as C from "../closePortConnection/closePortConnectionByPort.js";
|
|
6
|
+
import * as O from "../openPortConnection/openPortConnectionByPort.js";
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
const makeConnectionAcquirerReleaser = (is) =>
|
|
11
|
+
/**
|
|
12
|
+
* @returns An effect with the same port for easier chaining of operations
|
|
13
|
+
*/
|
|
14
|
+
port => Effect.acquireRelease(O.makePortConnectionOpener(is)(port), C.makePortConnectionCloser(is));
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
export const acquireReleasePortConnectionByPort = makeConnectionAcquirerReleaser(EMIDIPort.is);
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
export const acquireReleaseInputConnectionByPort = makeConnectionAcquirerReleaser(EMIDIInput.is);
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
export const acquireReleaseOutputConnectionByPort = makeConnectionAcquirerReleaser(EMIDIOutput.is);
|
|
27
|
+
//# sourceMappingURL=acquireReleasePortConnectionByPort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acquireReleasePortConnectionByPort.js","sourceRoot":"","sources":["../../../../../src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAEvC,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,WAAW,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAE/C,OAAO,KAAK,CAAC,MAAM,qDAAqD,CAAA;AAExE,OAAO,KAAK,CAAC,MAAM,mDAAmD,CAAA;AAEtE;;GAEG;AACH,MAAM,8BAA8B,GAClC,CACE,EAAsE,EACJ,EAAE;AACtE;;GAEG;AACH,IAAI,CAAC,EAAE,CACL,MAAM,CAAC,cAAc,CACnB,CAAC,CAAC,wBAAwB,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,EACpC,CAAC,CAAC,wBAAwB,CAAC,EAAE,CAAC,CAC/B,CAAA;AAEL;;GAEG;AACH,MAAM,CAAC,MAAM,kCAAkC,GAC7C,8BAA8B,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;AAE9C;;GAEG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAC9C,8BAA8B,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;AAE/C;;GAEG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAC/C,8BAA8B,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
import { getInputByPortIdAndAccess, getOutputByPortIdAndAccess, getPortByPortIdAndAccess, } from "../../getPortByPortId/getPortByPortIdAndAccess.js";
|
|
5
|
+
import { actOnPort } from "../actOnPort.js";
|
|
6
|
+
import { acquireReleaseInputConnectionByPort, acquireReleaseOutputConnectionByPort, acquireReleasePortConnectionByPort, } from "./acquireReleasePortConnectionByPort.js";
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
export const acquireReleasePortConnectionByPortIdAndAccess = actOnPort(getPortByPortIdAndAccess, acquireReleasePortConnectionByPort);
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
*/
|
|
14
|
+
export const acquireReleaseInputConnectionByPortIdAndAccess = actOnPort(getInputByPortIdAndAccess, acquireReleaseInputConnectionByPort);
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
export const acquireReleaseOutputConnectionByPortIdAndAccess = actOnPort(getOutputByPortIdAndAccess, acquireReleaseOutputConnectionByPort);
|
|
19
|
+
//# sourceMappingURL=acquireReleasePortConnectionByPortIdAndAccess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acquireReleasePortConnectionByPortIdAndAccess.js","sourceRoot":"","sources":["../../../../../src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdAndAccess.ts"],"names":[],"mappings":"AAAA,yDAAyD;AACzD;gEACgE;AAEhE,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,mDAAmD,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EACL,mCAAmC,EACnC,oCAAoC,EACpC,kCAAkC,GACnC,MAAM,yCAAyC,CAAA;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,6CAA6C,GAAG,SAAS,CACpE,wBAAwB,EACxB,kCAAkC,CACnC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,8CAA8C,GAAG,SAAS,CACrE,yBAAyB,EACzB,mCAAmC,CACpC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,+CAA+C,GAAG,SAAS,CACtE,0BAA0B,EAC1B,oCAAoC,CACrC,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { flow } from 'effect/Function';
|
|
2
|
+
import * as Get from "../../getPortByPortId/getPortByPortIdInContext.js";
|
|
3
|
+
import * as Acquire from "./acquireReleasePortConnectionByPort.js";
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
export const acquireReleasePortConnectionByPortIdInContext = flow(Get.getPortByPortIdInContext, Acquire.acquireReleasePortConnectionByPort);
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export const acquireReleaseInputConnectionByPortIdInContext = flow(Get.getInputByPortIdInContext, Acquire.acquireReleaseInputConnectionByPort);
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
export const acquireReleaseOutputConnectionByPortIdInContext = flow(Get.getOutputByPortIdInContext, Acquire.acquireReleaseOutputConnectionByPort);
|
|
16
|
+
//# sourceMappingURL=acquireReleasePortConnectionByPortIdInContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"acquireReleasePortConnectionByPortIdInContext.js","sourceRoot":"","sources":["../../../../../src/internal/MIDIPortMethodCalls/acquireReleasePortConnection/acquireReleasePortConnectionByPortIdInContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,KAAK,GAAG,MAAM,mDAAmD,CAAA;AACxE,OAAO,KAAK,OAAO,MAAM,yCAAyC,CAAA;AAElE;;GAEG;AACH,MAAM,CAAC,MAAM,6CAA6C,GAAG,IAAI,CAC/D,GAAG,CAAC,wBAAwB,EAC5B,OAAO,CAAC,kCAAkC,CAC3C,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,8CAA8C,GAAG,IAAI,CAChE,GAAG,CAAC,yBAAyB,EAC7B,OAAO,CAAC,mCAAmC,CAC5C,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,+CAA+C,GAAG,IAAI,CACjE,GAAG,CAAC,0BAA0B,EAC9B,OAAO,CAAC,oCAAoC,CAC7C,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/useShorthandFunctionType: It's a nice way to
|
|
2
|
+
* preserve JSDoc comments attached to the function signature */
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
import * as EFunction from 'effect/Function';
|
|
5
|
+
import * as EMIDIAccess from "../EMIDIAccess.js";
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export const actOnPort = (portGetterFromAccessAndPortId, act) => EFunction.dual(2, (polymorphicAccess, portId) => Effect.gen(function* () {
|
|
11
|
+
const access = yield* EMIDIAccess.resolve(polymorphicAccess);
|
|
12
|
+
const port = yield* portGetterFromAccessAndPortId(access, portId);
|
|
13
|
+
const actEffect = act(port);
|
|
14
|
+
yield* actEffect;
|
|
15
|
+
return access;
|
|
16
|
+
// biome-ignore lint/suspicious/noExplicitAny: FallbackOnUnknownOrAny backfired a bit, but I don't care about it anymore
|
|
17
|
+
}));
|
|
18
|
+
//# sourceMappingURL=actOnPort.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actOnPort.js","sourceRoot":"","sources":["../../../../src/internal/MIDIPortMethodCalls/actOnPort.ts"],"names":[],"mappings":"AAAA;gEACgE;AAEhE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAA;AAC5C,OAAO,KAAK,WAAW,MAAM,mBAAmB,CAAA;AAKhD;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAUvB,6BAOC,EACD,GAIC,EAQD,EAAE,CACF,SAAS,CAAC,IAAI,CACZ,CAAC,EACD,CAAC,iBAAiB,EAAE,MAAM,EAAE,EAAE,CAC5B,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA;IAE5D,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,6BAA6B,CAC/C,MAAM,EACN,MAAgD,CACjD,CAAA;IAED,MAAM,SAAS,GAAG,GAAG,CACnB,IAAkE,CACnE,CAAA;IAED,KAAK,CAAC,CAAC,SAAS,CAAA;IAEhB,OAAO,MAAM,CAAA;IACb,wHAAwH;AAC1H,CAAC,CAAQ,CACZ,CAAA"}
|
package/dist/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPort.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/useShorthandFunctionType: It's a nice way to
|
|
2
|
+
* preserve JSDoc comments attached to the function signature */
|
|
3
|
+
import * as EMIDIInput from "../../EMIDIInput.js";
|
|
4
|
+
import * as EMIDIOutput from "../../EMIDIOutput.js";
|
|
5
|
+
import * as EMIDIPort from "../../EMIDIPort.js";
|
|
6
|
+
import * as F from "../makeMIDIPortMethodCallerFactory.js";
|
|
7
|
+
/**
|
|
8
|
+
* @internal
|
|
9
|
+
*
|
|
10
|
+
* exported for acquire-release
|
|
11
|
+
*/
|
|
12
|
+
export const makePortConnectionCloser = F.makeMIDIPortMethodCallerFactory('close', () => err => {
|
|
13
|
+
throw err;
|
|
14
|
+
});
|
|
15
|
+
/**
|
|
16
|
+
*
|
|
17
|
+
*/
|
|
18
|
+
export const closePortConnectionByPort = makePortConnectionCloser(EMIDIPort.is);
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
*/
|
|
22
|
+
export const closeInputConnectionByPort = makePortConnectionCloser(EMIDIInput.is);
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
*/
|
|
26
|
+
export const closeOutputConnectionByPort = makePortConnectionCloser(EMIDIOutput.is);
|
|
27
|
+
//# sourceMappingURL=closePortConnectionByPort.js.map
|
package/dist/src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPort.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"closePortConnectionByPort.js","sourceRoot":"","sources":["../../../../../src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPort.ts"],"names":[],"mappings":"AAAA;gEACgE;AAEhE,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,WAAW,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,CAAC,MAAM,uCAAuC,CAAA;AAE1D;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,CAAC,+BAA+B,CACvE,OAAO,EACP,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE;IACV,MAAM,GAAG,CAAA;AACX,CAAC,CACF,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,wBAAwB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,wBAAwB,CAChE,UAAU,CAAC,EAAE,CACd,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,wBAAwB,CACjE,WAAW,CAAC,EAAE,CACf,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/useShorthandFunctionType: It's a nice way to
|
|
2
|
+
* preserve JSDoc comments attached to the function signature */
|
|
3
|
+
import { getInputByPortIdAndAccess, getOutputByPortIdAndAccess, getPortByPortIdAndAccess, } from "../../getPortByPortId/getPortByPortIdAndAccess.js";
|
|
4
|
+
import { actOnPort } from "../actOnPort.js";
|
|
5
|
+
import { closeInputConnectionByPort, closeOutputConnectionByPort, closePortConnectionByPort, } from "./closePortConnectionByPort.js";
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export const closePortConnectionByPortIdAndAccess = actOnPort(getPortByPortIdAndAccess, closePortConnectionByPort);
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
export const closeInputConnectionByPortIdAndAccess = actOnPort(getInputByPortIdAndAccess, closeInputConnectionByPort);
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
export const closeOutputConnectionByPortIdAndAccess = actOnPort(getOutputByPortIdAndAccess, closeOutputConnectionByPort);
|
|
18
|
+
//# sourceMappingURL=closePortConnectionByPortIdAndAccess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"closePortConnectionByPortIdAndAccess.js","sourceRoot":"","sources":["../../../../../src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdAndAccess.ts"],"names":[],"mappings":"AAAA;gEACgE;AAEhE,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,mDAAmD,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,yBAAyB,GAC1B,MAAM,gCAAgC,CAAA;AAEvC;;GAEG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,SAAS,CAC3D,wBAAwB,EACxB,yBAAyB,CAC1B,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,SAAS,CAC5D,yBAAyB,EACzB,0BAA0B,CAC3B,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAG,SAAS,CAC7D,0BAA0B,EAC1B,2BAA2B,CAC5B,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { flow } from 'effect/Function';
|
|
2
|
+
import * as Get from "../../getPortByPortId/getPortByPortIdInContext.js";
|
|
3
|
+
import * as Close from "./closePortConnectionByPort.js";
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
export const closePortConnectionByPortIdInContext = flow(Get.getPortByPortIdInContext, Close.closePortConnectionByPort);
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export const closeInputConnectionByPortIdInContext = flow(Get.getInputByPortIdInContext, Close.closeInputConnectionByPort);
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
export const closeOutputConnectionByPortIdInContext = flow(Get.getOutputByPortIdInContext, Close.closeOutputConnectionByPort);
|
|
16
|
+
//# sourceMappingURL=closePortConnectionByPortIdInContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"closePortConnectionByPortIdInContext.js","sourceRoot":"","sources":["../../../../../src/internal/MIDIPortMethodCalls/closePortConnection/closePortConnectionByPortIdInContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,KAAK,GAAG,MAAM,mDAAmD,CAAA;AACxE,OAAO,KAAK,KAAK,MAAM,gCAAgC,CAAA;AAEvD;;GAEG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,IAAI,CACtD,GAAG,CAAC,wBAAwB,EAC5B,KAAK,CAAC,yBAAyB,CAChC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,IAAI,CACvD,GAAG,CAAC,yBAAyB,EAC7B,KAAK,CAAC,0BAA0B,CACjC,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,sCAAsC,GAAG,IAAI,CACxD,GAAG,CAAC,0BAA0B,EAC9B,KAAK,CAAC,2BAA2B,CAClC,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/useShorthandFunctionType: It's a nice way to
|
|
2
|
+
* preserve JSDoc comments attached to the function signature */
|
|
3
|
+
import * as Effect from 'effect/Effect';
|
|
4
|
+
import * as EMIDIPort from "../EMIDIPort.js";
|
|
5
|
+
import * as Util from "../util.js";
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export const makeMIDIPortMethodCallerFactory = (method, mapError) => (is) => Effect.fn(`EMIDIPort.${method}`)(function* (polymorphicPort) {
|
|
10
|
+
const port = yield* Util.fromPolymorphic(polymorphicPort, is);
|
|
11
|
+
yield* Effect.annotateCurrentSpan({
|
|
12
|
+
method,
|
|
13
|
+
port: Util.getStaticMIDIPortInfo(port),
|
|
14
|
+
});
|
|
15
|
+
yield* Effect.tryPromise({
|
|
16
|
+
try: () => EMIDIPort.assumeImpl(port)._port[method](),
|
|
17
|
+
catch: mapError(port.id),
|
|
18
|
+
});
|
|
19
|
+
return port;
|
|
20
|
+
});
|
|
21
|
+
//# sourceMappingURL=makeMIDIPortMethodCallerFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"makeMIDIPortMethodCallerFactory.js","sourceRoot":"","sources":["../../../../src/internal/MIDIPortMethodCalls/makeMIDIPortMethodCallerFactory.ts"],"names":[],"mappings":"AAAA;gEACgE;AAEhE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAA;AAC5C,OAAO,KAAK,IAAI,MAAM,YAAY,CAAA;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAC1C,CACE,MAAwB,EACxB,QAA4D,EAC5D,EAAE,CACJ,CACE,EAAsE,EACxB,EAAE,CAChD,MAAM,CAAC,EAAE,CAAC,aAAa,MAAM,EAAE,CAAC,CAAC,QAAQ,CAAC,EAKxC,eAIC;IAED,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,eAAe,CACtC,eAAe,EACf,EAE2C,CAC5C,CAAA;IAED,KAAK,CAAC,CAAC,MAAM,CAAC,mBAAmB,CAAC;QAChC,MAAM;QACN,IAAI,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC;KACvC,CAAC,CAAA;IAEF,KAAK,CAAC,CAAC,MAAM,CAAC,UAAU,CAAC;QACvB,GAAG,EAAE,GAAG,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;QACrD,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;KACzB,CAAC,CAAA;IAEF,OAAO,IAAI,CAAA;AACb,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import * as EMIDIInput from "../../EMIDIInput.js";
|
|
2
|
+
import * as EMIDIOutput from "../../EMIDIOutput.js";
|
|
3
|
+
import * as EMIDIPort from "../../EMIDIPort.js";
|
|
4
|
+
import { remapErrorByName, UnavailablePortError } from "../../errors.js";
|
|
5
|
+
import { makeMIDIPortMethodCallerFactory } from "../makeMIDIPortMethodCallerFactory.js";
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*
|
|
9
|
+
* exported for acquire-release
|
|
10
|
+
*/
|
|
11
|
+
export const makePortConnectionOpener = makeMIDIPortMethodCallerFactory('open', portId => remapErrorByName({
|
|
12
|
+
NotAllowedError: UnavailablePortError,
|
|
13
|
+
// InvalidAccessError is kept for compatibility reason
|
|
14
|
+
// (https://github.com/WebAudio/web-midi-api/pull/278):
|
|
15
|
+
InvalidAccessError: UnavailablePortError,
|
|
16
|
+
InvalidStateError: UnavailablePortError,
|
|
17
|
+
}, 'MIDI port open error handling absurd', { portId }));
|
|
18
|
+
/**
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
export const openPortConnectionByPort = makePortConnectionOpener(EMIDIPort.is);
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
export const openInputConnectionByPort = makePortConnectionOpener(EMIDIInput.is);
|
|
26
|
+
/**
|
|
27
|
+
*
|
|
28
|
+
*/
|
|
29
|
+
export const openOutputConnectionByPort = makePortConnectionOpener(EMIDIOutput.is);
|
|
30
|
+
//# sourceMappingURL=openPortConnectionByPort.js.map
|
package/dist/src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPort.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openPortConnectionByPort.js","sourceRoot":"","sources":["../../../../../src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPort.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,WAAW,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AACxE,OAAO,EAAE,+BAA+B,EAAE,MAAM,uCAAuC,CAAA;AAEvF;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,+BAA+B,CACrE,MAAM,EACN,MAAM,CAAC,EAAE,CACP,gBAAgB,CACd;IACE,eAAe,EAAE,oBAAoB;IACrC,sDAAsD;IACtD,uDAAuD;IACvD,kBAAkB,EAAE,oBAAoB;IAExC,iBAAiB,EAAE,oBAAoB;CACxC,EACD,sCAAsC,EACtC,EAAE,MAAM,EAAE,CACX,CACJ,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,wBAAwB,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;AAE9E;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,wBAAwB,CAAC,UAAU,CAAC,EAAE,CAAC,CAAA;AAEhF;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,wBAAwB,CAChE,WAAW,CAAC,EAAE,CACf,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/useShorthandFunctionType: It's a nice way to
|
|
2
|
+
* preserve JSDoc comments attached to the function signature */
|
|
3
|
+
import { getInputByPortIdAndAccess, getOutputByPortIdAndAccess, getPortByPortIdAndAccess, } from "../../getPortByPortId/getPortByPortIdAndAccess.js";
|
|
4
|
+
import { actOnPort } from "../actOnPort.js";
|
|
5
|
+
import { openInputConnectionByPort, openOutputConnectionByPort, openPortConnectionByPort, } from "./openPortConnectionByPort.js";
|
|
6
|
+
/**
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
export const openPortConnectionByPortIdAndAccess = actOnPort(getPortByPortIdAndAccess, openPortConnectionByPort);
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
export const openInputConnectionByPortIdAndAccess = actOnPort(getInputByPortIdAndAccess, openInputConnectionByPort);
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
export const openOutputConnectionByPortIdAndAccess = actOnPort(getOutputByPortIdAndAccess, openOutputConnectionByPort);
|
|
18
|
+
//# sourceMappingURL=openPortConnectionByPortIdAndAccess.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openPortConnectionByPortIdAndAccess.js","sourceRoot":"","sources":["../../../../../src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdAndAccess.ts"],"names":[],"mappings":"AAAA;gEACgE;AAEhE,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,mDAAmD,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EACL,yBAAyB,EACzB,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,+BAA+B,CAAA;AAEtC;;GAEG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,SAAS,CAC1D,wBAAwB,EACxB,wBAAwB,CACzB,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,SAAS,CAC3D,yBAAyB,EACzB,yBAAyB,CAC1B,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,SAAS,CAC5D,0BAA0B,EAC1B,0BAA0B,CAC3B,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { flow } from 'effect/Function';
|
|
2
|
+
import * as Get from "../../getPortByPortId/getPortByPortIdInContext.js";
|
|
3
|
+
import * as Open from "./openPortConnectionByPort.js";
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
export const openPortConnectionByPortIdInContext = flow(Get.getPortByPortIdInContext, Open.openPortConnectionByPort);
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
export const openInputConnectionByPortIdInContext = flow(Get.getInputByPortIdInContext, Open.openInputConnectionByPort);
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
export const openOutputConnectionByPortIdInContext = flow(Get.getOutputByPortIdInContext, Open.openOutputConnectionByPort);
|
|
16
|
+
//# sourceMappingURL=openPortConnectionByPortIdInContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"openPortConnectionByPortIdInContext.js","sourceRoot":"","sources":["../../../../../src/internal/MIDIPortMethodCalls/openPortConnection/openPortConnectionByPortIdInContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AACtC,OAAO,KAAK,GAAG,MAAM,mDAAmD,CAAA;AACxE,OAAO,KAAK,IAAI,MAAM,+BAA+B,CAAA;AAErD;;GAEG;AACH,MAAM,CAAC,MAAM,mCAAmC,GAAG,IAAI,CACrD,GAAG,CAAC,wBAAwB,EAC5B,IAAI,CAAC,wBAAwB,CAC9B,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,IAAI,CACtD,GAAG,CAAC,yBAAyB,EAC7B,IAAI,CAAC,yBAAyB,CAC/B,CAAA;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAG,IAAI,CACvD,GAAG,CAAC,0BAA0B,EAC9B,IAAI,CAAC,0BAA0B,CAChC,CAAA"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/** biome-ignore-all lint/style/useShorthandFunctionType: It's a nice way to
|
|
2
|
+
* preserve JSDoc comments attached to the function signature */
|
|
3
|
+
import * as Cause from 'effect/Cause';
|
|
4
|
+
import * as Effect from 'effect/Effect';
|
|
5
|
+
import * as EFunction from 'effect/Function';
|
|
6
|
+
import * as Stream from 'effect/Stream';
|
|
7
|
+
import * as Util from "./util.js";
|
|
8
|
+
// TODO: make an experiment to see if listeners are automatically removed on disconnect
|
|
9
|
+
/**
|
|
10
|
+
* Set of possible ways to react when the MIDI-related event will have relevant
|
|
11
|
+
* field be null. Although there should be no sane scenario where it would be
|
|
12
|
+
* the case, it's still allowed by the spec, and for a better UX this lib lets
|
|
13
|
+
* the developer make a decision on how to handle such cases.
|
|
14
|
+
*
|
|
15
|
+
* - `fail` will add an error into a signature of a stream, allowing the user to
|
|
16
|
+
* handle it
|
|
17
|
+
* - `die` will throw a defect, which won't be reflected as a possible failure
|
|
18
|
+
* in types
|
|
19
|
+
* - `ignore` will just silently remove such events from the stream
|
|
20
|
+
* - `passthrough` - will pass such events with an unmodified content of the
|
|
21
|
+
* relevant field
|
|
22
|
+
*
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
const validOnNullStrategies = new Set([
|
|
26
|
+
'fail',
|
|
27
|
+
'die',
|
|
28
|
+
'ignore',
|
|
29
|
+
'passthrough',
|
|
30
|
+
]);
|
|
31
|
+
/**
|
|
32
|
+
* Helper utility to turn MIDI event listeners into effect's Streams.
|
|
33
|
+
*
|
|
34
|
+
* The signature is split into 2 calls, so that you are able at first call pass
|
|
35
|
+
* into generic an interface with `addEventListener` types of the raw web MIDI
|
|
36
|
+
* objects as keys and according event structures as values.
|
|
37
|
+
*
|
|
38
|
+
* **Second call arguments**
|
|
39
|
+
*
|
|
40
|
+
* - `isSelf` - Function determining if the maker was called as an overload with
|
|
41
|
+
* all parameters passed all at once, or with them spread by 2 calls. `self`
|
|
42
|
+
* will be later assigned to a `cameFrom` property of the object in the
|
|
43
|
+
* success channel of the stream
|
|
44
|
+
*
|
|
45
|
+
* - `buildConfig` - Function that makes config out of an effectful version
|
|
46
|
+
* (e.g. {@linkcode EMIDIAccess.EMIDIAccessInstance}, {@linkcode EMIDIInput.EMIDIInput},
|
|
47
|
+
* {@linkcode EMIDIOutput.EMIDIOutput}) of a MIDI object.
|
|
48
|
+
*
|
|
49
|
+
* - `remapValueToContainer` - Callback that maps the value of the event's
|
|
50
|
+
* selected field to an extension of the object inside stream's success
|
|
51
|
+
* channel. All fields of the returned object must always be present and
|
|
52
|
+
* should be consistently nullable, when the incoming event's field is null.
|
|
53
|
+
*
|
|
54
|
+
* @template TEventTypeToEventValueMap An interface with event types of raw
|
|
55
|
+
* Web MIDI objects as keys and according event structures as values. e.g.
|
|
56
|
+
* `MIDIAccessEventMap`, `MIDIPortEventMap`, `MIDIInputEventMap`
|
|
57
|
+
*
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
export const createStreamMakerFrom = () =>
|
|
61
|
+
/**
|
|
62
|
+
* @param isSelf Function determining if the maker was called as an overload
|
|
63
|
+
* with all parameters passed all at once, or with them spread by 2 calls.
|
|
64
|
+
* `self` will be later assigned to a `cameFrom` property of the object in the
|
|
65
|
+
* success channel of the stream
|
|
66
|
+
*
|
|
67
|
+
* @param buildConfig Function that makes config out of an effectful version
|
|
68
|
+
* (e.g. {@linkcode EMIDIAccess.EMIDIAccessInstance}, {@linkcode EMIDIInput.EMIDIInput},
|
|
69
|
+
* {@linkcode EMIDIOutput.EMIDIOutput}) of a MIDI object.
|
|
70
|
+
*
|
|
71
|
+
* @param remapValueToContainer Callback that maps the `fieldValue` of the
|
|
72
|
+
* event's selected field (`nullableFieldName`) to an extension of the object
|
|
73
|
+
* inside stream's success channel. The value is not null, except when
|
|
74
|
+
* `onNullStrategy` is `'passthrough'`. All fields of the returned object must
|
|
75
|
+
* always be present and should be consistently nullable, if the incoming
|
|
76
|
+
* event's field is null.
|
|
77
|
+
*/
|
|
78
|
+
(isSelf, buildConfig, remapValueToContainer) => EFunction.dual(Util.polymorphicCheckInDual(isSelf), (cameFromPolymorphic, options) => Effect.gen(function* () {
|
|
79
|
+
const onNullStrategy = (options?.onExtremelyRareNullableField ?? 'die');
|
|
80
|
+
if (!validOnNullStrategies.has(onNullStrategy))
|
|
81
|
+
throw new Error(`Invalid strategy to handle nullish values: ${onNullStrategy}`);
|
|
82
|
+
const cameFrom = yield* Util.fromPolymorphic(cameFromPolymorphic, isSelf);
|
|
83
|
+
const { tag, eventListener: { target, type }, spanAttributes, nullableFieldName: field, } = buildConfig(cameFrom);
|
|
84
|
+
const missingFieldMessage = `Property ${field} of ${tag} is null`;
|
|
85
|
+
const NullCausedErrorEffect = new Cause.NoSuchElementException(missingFieldMessage);
|
|
86
|
+
return Stream.fromEventListener(target, type, options).pipe(Stream.filter(event => !!event[field] || onNullStrategy !== 'ignore'), Stream.mapEffect(event => event[field] || onNullStrategy === 'passthrough'
|
|
87
|
+
? Effect.succeed({
|
|
88
|
+
_tag: tag,
|
|
89
|
+
...remapValueToContainer(event[field]),
|
|
90
|
+
cameFrom,
|
|
91
|
+
capturedAt: new Date(),
|
|
92
|
+
})
|
|
93
|
+
: onNullStrategy === 'fail'
|
|
94
|
+
? NullCausedErrorEffect
|
|
95
|
+
: Effect.dieMessage(missingFieldMessage)), Stream.withSpan('MIDI Web API event stream', {
|
|
96
|
+
kind: 'producer',
|
|
97
|
+
attributes: { eventType: type, ...spanAttributes },
|
|
98
|
+
}));
|
|
99
|
+
// biome-ignore lint/suspicious/noExplicitAny: <I don't care>
|
|
100
|
+
}).pipe(Stream.unwrap));
|
|
101
|
+
//# sourceMappingURL=StreamMaker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StreamMaker.js","sourceRoot":"","sources":["../../../src/internal/StreamMaker.ts"],"names":[],"mappings":"AAAA;gEACgE;AAEhE,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AACrC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AACvC,OAAO,KAAK,SAAS,MAAM,iBAAiB,CAAA;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAA;AAIvC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAA;AAEjC,uFAAuF;AAEvF;;;;;;;;;;;;;;;GAeG;AACH,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC;IACpC,MAAM;IACN,KAAK;IACL,Q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