@neurodevs/node-lsl 11.4.1 → 12.0.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/.vscode/tasks.json +19 -1
- package/README.md +44 -34
- package/build/.spruce/settings.json +1 -3
- package/build/__tests__/{AbstractLslTest.d.ts → AbstractPackageTest.d.ts} +6 -4
- package/build/__tests__/AbstractPackageTest.js +58 -0
- package/build/__tests__/AbstractPackageTest.js.map +1 -0
- package/build/__tests__/{modules → impl}/LiblslAdapter.test.d.ts +5 -8
- package/build/__tests__/{modules → impl}/LiblslAdapter.test.js +37 -86
- package/build/__tests__/impl/LiblslAdapter.test.js.map +1 -0
- package/build/__tests__/{modules/EventMarkerOutlet.test.d.ts → impl/LslEventMarkerOutlet.test.d.ts} +5 -4
- package/build/__tests__/{modules/EventMarkerOutlet.test.js → impl/LslEventMarkerOutlet.test.js} +32 -25
- package/build/__tests__/impl/LslEventMarkerOutlet.test.js.map +1 -0
- package/build/__tests__/{modules → impl}/LslStreamInfo.test.d.ts +3 -4
- package/build/__tests__/{modules → impl}/LslStreamInfo.test.js +17 -27
- package/build/__tests__/impl/LslStreamInfo.test.js.map +1 -0
- package/build/__tests__/impl/LslStreamInlet.test.d.ts +10 -0
- package/build/__tests__/{modules → impl}/LslStreamInlet.test.js +9 -26
- package/build/__tests__/impl/LslStreamInlet.test.js.map +1 -0
- package/build/__tests__/{modules → impl}/LslStreamOutlet.test.d.ts +9 -7
- package/build/__tests__/{modules → impl}/LslStreamOutlet.test.js +40 -57
- package/build/__tests__/impl/LslStreamOutlet.test.js.map +1 -0
- package/build/__tests__/impl/LslWebSocketBridge.test.d.ts +7 -0
- package/build/__tests__/impl/LslWebSocketBridge.test.js +63 -0
- package/build/__tests__/impl/LslWebSocketBridge.test.js.map +1 -0
- package/build/assertions.d.ts +1 -1
- package/build/assertions.js +10 -31
- package/build/assertions.js.map +1 -1
- package/build/{modules → impl}/LiblslAdapter.d.ts +3 -1
- package/build/{modules → impl}/LiblslAdapter.js +15 -44
- package/build/impl/LiblslAdapter.js.map +1 -0
- package/build/impl/LslEventMarkerOutlet.d.ts +23 -0
- package/build/{modules/EventMarkerOutlet.js → impl/LslEventMarkerOutlet.js} +6 -6
- package/build/impl/LslEventMarkerOutlet.js.map +1 -0
- package/build/{modules → impl}/LslStreamInfo.js +4 -6
- package/build/impl/LslStreamInfo.js.map +1 -0
- package/build/{modules → impl}/LslStreamInlet.d.ts +8 -8
- package/build/{modules → impl}/LslStreamInlet.js +6 -14
- package/build/impl/LslStreamInlet.js.map +1 -0
- package/build/{modules → impl}/LslStreamOutlet.d.ts +8 -8
- package/build/{modules → impl}/LslStreamOutlet.js +2 -15
- package/build/impl/LslStreamOutlet.js.map +1 -0
- package/build/impl/LslWebSocketBridge.d.ts +8 -0
- package/build/impl/LslWebSocketBridge.js +10 -0
- package/build/impl/LslWebSocketBridge.js.map +1 -0
- package/build/index.d.ts +26 -22
- package/build/index.js +41 -34
- package/build/index.js.map +1 -1
- package/build/scripts/runLslEventMarkerOutlet.d.ts +1 -0
- package/build/scripts/runLslEventMarkerOutlet.js +23 -0
- package/build/scripts/runLslEventMarkerOutlet.js.map +1 -0
- package/build/scripts/runLslStreamOutlet.d.ts +1 -0
- package/build/scripts/runLslStreamOutlet.js +25 -0
- package/build/scripts/runLslStreamOutlet.js.map +1 -0
- package/build/testDoubles/{MarkerOutlet/FakeMarkerOutlet.d.ts → EventMarkerOutlet/FakeEventMarkerOutlet.d.ts} +2 -2
- package/build/testDoubles/EventMarkerOutlet/FakeEventMarkerOutlet.js +29 -0
- package/build/testDoubles/EventMarkerOutlet/FakeEventMarkerOutlet.js.map +1 -0
- package/build/testDoubles/{MarkerOutlet/MockMarkerOutlet.d.ts → EventMarkerOutlet/MockEventMarkerOutlet.d.ts} +2 -2
- package/build/testDoubles/{MarkerOutlet/MockMarkerOutlet.js → EventMarkerOutlet/MockEventMarkerOutlet.js} +3 -3
- package/build/testDoubles/EventMarkerOutlet/MockEventMarkerOutlet.js.map +1 -0
- package/build/testDoubles/EventMarkerOutlet/SpyEventMarkerOutlet.d.ts +9 -0
- package/build/testDoubles/{MarkerOutlet/SpyMarkerOutlet.js → EventMarkerOutlet/SpyEventMarkerOutlet.js} +8 -8
- package/build/testDoubles/EventMarkerOutlet/SpyEventMarkerOutlet.js.map +1 -0
- package/build/testDoubles/{MarkerOutlet/ThrowingMarkerOutlet.d.ts → EventMarkerOutlet/ThrowingEventMarkerOutlet.d.ts} +2 -2
- package/build/testDoubles/{MarkerOutlet/ThrowingMarkerOutlet.js → EventMarkerOutlet/ThrowingEventMarkerOutlet.js} +3 -3
- package/build/testDoubles/EventMarkerOutlet/ThrowingEventMarkerOutlet.js.map +1 -0
- package/build/testDoubles/StreamInfo/FakeStreamInfo.d.ts +1 -1
- package/build/testDoubles/StreamInfo/SpyStreamInfo.d.ts +1 -1
- package/build/testDoubles/StreamInfo/SpyStreamInfo.js +1 -1
- package/build/testDoubles/StreamInfo/SpyStreamInfo.js.map +1 -1
- package/build/testDoubles/StreamInlet/FakeStreamInlet.d.ts +10 -0
- package/build/testDoubles/StreamInlet/FakeStreamInlet.js +16 -0
- package/build/testDoubles/StreamInlet/FakeStreamInlet.js.map +1 -0
- package/build/testDoubles/StreamInlet/SpyStreamInlet.d.ts +7 -0
- package/build/testDoubles/{LslInlet/SpyLslInlet.js → StreamInlet/SpyStreamInlet.js} +5 -5
- package/build/testDoubles/StreamInlet/SpyStreamInlet.js.map +1 -0
- package/build/testDoubles/{LslOutlet/FakeLslOutlet.d.ts → StreamOutlet/FakeStreamOutlet.d.ts} +9 -10
- package/build/testDoubles/StreamOutlet/FakeStreamOutlet.js +62 -0
- package/build/testDoubles/StreamOutlet/FakeStreamOutlet.js.map +1 -0
- package/build/testDoubles/StreamTransportBridge/FakeStreamTransportBridge.d.ts +6 -0
- package/build/testDoubles/StreamTransportBridge/FakeStreamTransportBridge.js +13 -0
- package/build/testDoubles/StreamTransportBridge/FakeStreamTransportBridge.js.map +1 -0
- package/build/testDoubles/generateRandomOutletOptions.d.ts +2 -2
- package/build/testDoubles/generateRandomOutletOptions.js +10 -7
- package/build/testDoubles/generateRandomOutletOptions.js.map +1 -1
- package/build/types.d.ts +3 -3
- package/package.json +26 -18
- package/src/.spruce/settings.json +1 -3
- package/src/__tests__/{AbstractLslTest.ts → AbstractPackageTest.ts} +23 -17
- package/src/__tests__/{modules → impl}/LiblslAdapter.test.ts +36 -76
- package/src/__tests__/{modules/EventMarkerOutlet.test.ts → impl/LslEventMarkerOutlet.test.ts} +38 -27
- package/src/__tests__/{modules → impl}/LslStreamInfo.test.ts +7 -17
- package/src/__tests__/{modules → impl}/LslStreamInlet.test.ts +13 -30
- package/src/__tests__/{modules → impl}/LslStreamOutlet.test.ts +71 -63
- package/src/__tests__/impl/LslWebSocketBridge.test.ts +23 -0
- package/src/assertions.ts +19 -30
- package/src/{modules → impl}/LiblslAdapter.ts +18 -44
- package/src/{modules/EventMarkerOutlet.ts → impl/LslEventMarkerOutlet.ts} +16 -11
- package/src/{modules → impl}/LslStreamInfo.ts +1 -3
- package/src/{modules → impl}/LslStreamInlet.ts +14 -22
- package/src/{modules → impl}/LslStreamOutlet.ts +12 -26
- package/src/impl/LslWebSocketBridge.ts +13 -0
- package/src/index.ts +37 -29
- package/src/scripts/runLslEventMarkerOutlet.ts +23 -0
- package/src/scripts/runLslStreamOutlet.ts +22 -0
- package/src/testDoubles/{MarkerOutlet/FakeMarkerOutlet.ts → EventMarkerOutlet/FakeEventMarkerOutlet.ts} +6 -6
- package/src/testDoubles/{MarkerOutlet/MockMarkerOutlet.ts → EventMarkerOutlet/MockEventMarkerOutlet.ts} +2 -2
- package/src/testDoubles/EventMarkerOutlet/SpyEventMarkerOutlet.ts +24 -0
- package/src/testDoubles/{MarkerOutlet/ThrowingMarkerOutlet.ts → EventMarkerOutlet/ThrowingEventMarkerOutlet.ts} +2 -2
- package/src/testDoubles/StreamInfo/FakeStreamInfo.ts +1 -1
- package/src/testDoubles/StreamInfo/SpyStreamInfo.ts +1 -1
- package/src/testDoubles/StreamInlet/FakeStreamInlet.ts +20 -0
- package/src/testDoubles/StreamInlet/SpyStreamInlet.ts +16 -0
- package/src/testDoubles/{LslOutlet/FakeLslOutlet.ts → StreamOutlet/FakeStreamOutlet.ts} +17 -18
- package/src/testDoubles/StreamTransportBridge/FakeStreamTransportBridge.ts +15 -0
- package/src/testDoubles/generateRandomOutletOptions.ts +3 -3
- package/src/types.ts +3 -3
- package/build/.spruce/errors/errors.types.d.ts +0 -21
- package/build/.spruce/errors/errors.types.js +0 -3
- package/build/.spruce/errors/errors.types.js.map +0 -1
- package/build/.spruce/errors/nodeLsl/failedToLoadLiblsl.schema.d.ts +0 -3
- package/build/.spruce/errors/nodeLsl/failedToLoadLiblsl.schema.js +0 -19
- package/build/.spruce/errors/nodeLsl/failedToLoadLiblsl.schema.js.map +0 -1
- package/build/.spruce/errors/options.types.d.ts +0 -7
- package/build/.spruce/errors/options.types.js +0 -3
- package/build/.spruce/errors/options.types.js.map +0 -1
- package/build/.spruce/schemas/fields/fieldClassMap.d.ts +0 -2
- package/build/.spruce/schemas/fields/fieldClassMap.js +0 -5
- package/build/.spruce/schemas/fields/fieldClassMap.js.map +0 -1
- package/build/.spruce/schemas/fields/fields.types.d.ts +0 -1
- package/build/.spruce/schemas/fields/fields.types.js +0 -3
- package/build/.spruce/schemas/fields/fields.types.js.map +0 -1
- package/build/__tests__/AbstractLslTest.js +0 -86
- package/build/__tests__/AbstractLslTest.js.map +0 -1
- package/build/__tests__/modules/EventMarkerOutlet.test.js.map +0 -1
- package/build/__tests__/modules/LiblslAdapter.test.js.map +0 -1
- package/build/__tests__/modules/LslStreamInfo.test.js.map +0 -1
- package/build/__tests__/modules/LslStreamInlet.test.d.ts +0 -11
- package/build/__tests__/modules/LslStreamInlet.test.js.map +0 -1
- package/build/__tests__/modules/LslStreamOutlet.test.js.map +0 -1
- package/build/errors/SpruceError.d.ts +0 -6
- package/build/errors/SpruceError.js +0 -26
- package/build/errors/SpruceError.js.map +0 -1
- package/build/errors/failedToLoadLiblsl.builder.d.ts +0 -11
- package/build/errors/failedToLoadLiblsl.builder.js +0 -14
- package/build/errors/failedToLoadLiblsl.builder.js.map +0 -1
- package/build/modules/EventMarkerOutlet.d.ts +0 -23
- package/build/modules/EventMarkerOutlet.js.map +0 -1
- package/build/modules/LiblslAdapter.js.map +0 -1
- package/build/modules/LslStreamInfo.js.map +0 -1
- package/build/modules/LslStreamInlet.js.map +0 -1
- package/build/modules/LslStreamOutlet.js.map +0 -1
- package/build/testDoubles/LslInlet/FakeLslInlet.d.ts +0 -11
- package/build/testDoubles/LslInlet/FakeLslInlet.js +0 -16
- package/build/testDoubles/LslInlet/FakeLslInlet.js.map +0 -1
- package/build/testDoubles/LslInlet/SpyLslInlet.d.ts +0 -7
- package/build/testDoubles/LslInlet/SpyLslInlet.js.map +0 -1
- package/build/testDoubles/LslOutlet/FakeLslOutlet.js +0 -59
- package/build/testDoubles/LslOutlet/FakeLslOutlet.js.map +0 -1
- package/build/testDoubles/MarkerOutlet/FakeMarkerOutlet.js +0 -29
- package/build/testDoubles/MarkerOutlet/FakeMarkerOutlet.js.map +0 -1
- package/build/testDoubles/MarkerOutlet/MockMarkerOutlet.js.map +0 -1
- package/build/testDoubles/MarkerOutlet/SpyMarkerOutlet.d.ts +0 -9
- package/build/testDoubles/MarkerOutlet/SpyMarkerOutlet.js.map +0 -1
- package/build/testDoubles/MarkerOutlet/ThrowingMarkerOutlet.js.map +0 -1
- package/src/.spruce/errors/errors.types.ts +0 -37
- package/src/.spruce/errors/nodeLsl/failedToLoadLiblsl.schema.ts +0 -22
- package/src/.spruce/errors/options.types.ts +0 -10
- package/src/.spruce/schemas/fields/fieldClassMap.ts +0 -6
- package/src/.spruce/schemas/fields/fields.types.ts +0 -1
- package/src/errors/SpruceError.ts +0 -23
- package/src/errors/failedToLoadLiblsl.builder.ts +0 -12
- package/src/testDoubles/LslInlet/FakeLslInlet.ts +0 -22
- package/src/testDoubles/LslInlet/SpyLslInlet.ts +0 -16
- package/src/testDoubles/MarkerOutlet/SpyMarkerOutlet.ts +0 -24
- /package/build/{modules → impl}/LslStreamInfo.d.ts +0 -0
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { assertOptions } from '@sprucelabs/schema'
|
|
2
1
|
import {
|
|
3
2
|
assertValidChannelCount,
|
|
4
3
|
assertValidChannelFormat,
|
|
@@ -10,37 +9,24 @@ import { ChannelFormat, BoundOutlet, Liblsl, LslSample } from '../types'
|
|
|
10
9
|
import LiblslAdapter from './LiblslAdapter'
|
|
11
10
|
import LslStreamInfo, { StreamInfo, StreamInfoOptions } from './LslStreamInfo'
|
|
12
11
|
|
|
13
|
-
export default class LslStreamOutlet implements
|
|
14
|
-
public static Class?:
|
|
12
|
+
export default class LslStreamOutlet implements StreamOutlet {
|
|
13
|
+
public static Class?: StreamOutletConstructor
|
|
15
14
|
|
|
16
15
|
private info: StreamInfo
|
|
17
|
-
private options:
|
|
16
|
+
private options: StreamOutletOptions
|
|
18
17
|
private outlet!: BoundOutlet
|
|
19
18
|
private pushSampleByType!: (options: any) => void
|
|
20
19
|
|
|
21
|
-
protected constructor(info: StreamInfo, options:
|
|
20
|
+
protected constructor(info: StreamInfo, options: StreamOutletOptions) {
|
|
22
21
|
this.info = info
|
|
23
22
|
this.options = options
|
|
24
23
|
|
|
25
24
|
this.validateOptions()
|
|
26
|
-
this.
|
|
25
|
+
this.createStreamOutlet()
|
|
27
26
|
this.setPushSampleType()
|
|
28
27
|
}
|
|
29
28
|
|
|
30
|
-
public static async Create(options:
|
|
31
|
-
assertOptions(options, [
|
|
32
|
-
'name',
|
|
33
|
-
'type',
|
|
34
|
-
'sourceId',
|
|
35
|
-
'channelNames',
|
|
36
|
-
'channelFormat',
|
|
37
|
-
'sampleRate',
|
|
38
|
-
'chunkSize',
|
|
39
|
-
'maxBuffered',
|
|
40
|
-
'manufacturer',
|
|
41
|
-
'unit',
|
|
42
|
-
])
|
|
43
|
-
|
|
29
|
+
public static async Create(options: StreamOutletOptions) {
|
|
44
30
|
const { waitAfterConstructionMs = 10 } = options ?? {}
|
|
45
31
|
|
|
46
32
|
const streamInfoOptions = {
|
|
@@ -69,7 +55,7 @@ export default class LslStreamOutlet implements LslOutlet {
|
|
|
69
55
|
assertValidMaxBuffered(this.maxBuffered)
|
|
70
56
|
}
|
|
71
57
|
|
|
72
|
-
private
|
|
58
|
+
private createStreamOutlet() {
|
|
73
59
|
this.outlet = this.lsl.createOutlet({
|
|
74
60
|
info: this.boundStreamInfo,
|
|
75
61
|
chunkSize: this.chunkSize,
|
|
@@ -181,7 +167,7 @@ export default class LslStreamOutlet implements LslOutlet {
|
|
|
181
167
|
}
|
|
182
168
|
}
|
|
183
169
|
|
|
184
|
-
export interface
|
|
170
|
+
export interface StreamOutlet {
|
|
185
171
|
pushSample(sample: LslSample): void
|
|
186
172
|
destroy(): void
|
|
187
173
|
readonly name: string
|
|
@@ -196,12 +182,12 @@ export interface LslOutlet {
|
|
|
196
182
|
readonly unit: string
|
|
197
183
|
}
|
|
198
184
|
|
|
199
|
-
export type
|
|
185
|
+
export type StreamOutletConstructor = new (
|
|
200
186
|
info: StreamInfo,
|
|
201
|
-
options:
|
|
202
|
-
) =>
|
|
187
|
+
options: StreamOutletOptions
|
|
188
|
+
) => StreamOutlet
|
|
203
189
|
|
|
204
|
-
export interface
|
|
190
|
+
export interface StreamOutletOptions {
|
|
205
191
|
name: string
|
|
206
192
|
type: string
|
|
207
193
|
sourceId: string
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export default class LslWebSocketBridge implements StreamTransportBridge {
|
|
2
|
+
public static Class?: StreamTransportBridgeConstructor
|
|
3
|
+
|
|
4
|
+
protected constructor() {}
|
|
5
|
+
|
|
6
|
+
public static Create() {
|
|
7
|
+
return new (this.Class ?? this)()
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface StreamTransportBridge {}
|
|
12
|
+
|
|
13
|
+
export type StreamTransportBridgeConstructor = new () => StreamTransportBridge
|
package/src/index.ts
CHANGED
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
export * from './types'
|
|
2
2
|
|
|
3
|
+
// EventMarkerOutlet
|
|
4
|
+
|
|
5
|
+
export { default as EventMarkerOutlet } from './impl/LslEventMarkerOutlet'
|
|
6
|
+
export * from './impl/LslEventMarkerOutlet'
|
|
7
|
+
|
|
8
|
+
export { default as FakeMarkerOutlet } from './testDoubles/EventMarkerOutlet/FakeEventMarkerOutlet'
|
|
9
|
+
export * from './testDoubles/EventMarkerOutlet/FakeEventMarkerOutlet'
|
|
10
|
+
|
|
11
|
+
export { default as MockMarkerOutlet } from './testDoubles/EventMarkerOutlet/MockEventMarkerOutlet'
|
|
12
|
+
export * from './testDoubles/EventMarkerOutlet/MockEventMarkerOutlet'
|
|
13
|
+
|
|
14
|
+
export { default as SpyMarkerOutlet } from './testDoubles/EventMarkerOutlet/SpyEventMarkerOutlet'
|
|
15
|
+
export * from './testDoubles/EventMarkerOutlet/SpyEventMarkerOutlet'
|
|
16
|
+
|
|
17
|
+
export { default as ThrowingMarkerOutlet } from './testDoubles/EventMarkerOutlet/ThrowingEventMarkerOutlet'
|
|
18
|
+
export * from './testDoubles/EventMarkerOutlet/ThrowingEventMarkerOutlet'
|
|
19
|
+
|
|
3
20
|
// Liblsl
|
|
4
21
|
|
|
5
|
-
export { default as LiblslAdapter } from './
|
|
6
|
-
export * from './
|
|
22
|
+
export { default as LiblslAdapter } from './impl/LiblslAdapter'
|
|
23
|
+
export * from './impl/LiblslAdapter'
|
|
7
24
|
|
|
8
25
|
export { default as FakeLiblsl } from './testDoubles/Liblsl/FakeLiblsl'
|
|
9
26
|
export * from './testDoubles/Liblsl/FakeLiblsl'
|
|
10
27
|
|
|
11
|
-
//
|
|
28
|
+
// StreamInfo
|
|
12
29
|
|
|
13
|
-
export { default as LslStreamInfo } from './
|
|
14
|
-
export * from './
|
|
30
|
+
export { default as LslStreamInfo } from './impl/LslStreamInfo'
|
|
31
|
+
export * from './impl/LslStreamInfo'
|
|
15
32
|
|
|
16
33
|
export { default as SpyStreamInfo } from './testDoubles/StreamInfo/SpyStreamInfo'
|
|
17
34
|
export * from './testDoubles/StreamInfo/SpyStreamInfo'
|
|
@@ -19,38 +36,29 @@ export * from './testDoubles/StreamInfo/SpyStreamInfo'
|
|
|
19
36
|
export { default as FakeStreamInfo } from './testDoubles/StreamInfo/FakeStreamInfo'
|
|
20
37
|
export * from './testDoubles/StreamInfo/FakeStreamInfo'
|
|
21
38
|
|
|
22
|
-
//
|
|
23
|
-
|
|
24
|
-
export { default as LslStreamInlet } from './modules/LslStreamInlet'
|
|
25
|
-
export * from './modules/LslStreamInlet'
|
|
26
|
-
|
|
27
|
-
export { default as FakeLslInlet } from './testDoubles/LslInlet/FakeLslInlet'
|
|
28
|
-
export * from './testDoubles/LslInlet/FakeLslInlet'
|
|
39
|
+
// StreamInlet
|
|
29
40
|
|
|
30
|
-
|
|
41
|
+
export { default as LslStreamInlet } from './impl/LslStreamInlet'
|
|
42
|
+
export * from './impl/LslStreamInlet'
|
|
31
43
|
|
|
32
|
-
export { default as
|
|
33
|
-
export * from './
|
|
44
|
+
export { default as FakeStreamInlet } from './testDoubles/StreamInlet/FakeStreamInlet'
|
|
45
|
+
export * from './testDoubles/StreamInlet/FakeStreamInlet'
|
|
34
46
|
|
|
35
|
-
|
|
36
|
-
export * from './testDoubles/LslOutlet/FakeLslOutlet'
|
|
37
|
-
|
|
38
|
-
// EventMarkerOutlet
|
|
47
|
+
// StreamOutlet
|
|
39
48
|
|
|
40
|
-
export { default as
|
|
41
|
-
export * from './
|
|
49
|
+
export { default as LslStreamOutlet } from './impl/LslStreamOutlet'
|
|
50
|
+
export * from './impl/LslStreamOutlet'
|
|
42
51
|
|
|
43
|
-
export { default as
|
|
44
|
-
export * from './testDoubles/
|
|
52
|
+
export { default as FakeStreamOutlet } from './testDoubles/StreamOutlet/FakeStreamOutlet'
|
|
53
|
+
export * from './testDoubles/StreamOutlet/FakeStreamOutlet'
|
|
45
54
|
|
|
46
|
-
|
|
47
|
-
export * from './testDoubles/MarkerOutlet/MockMarkerOutlet'
|
|
55
|
+
// StreamTransportBridge
|
|
48
56
|
|
|
49
|
-
export { default as
|
|
50
|
-
export * from './
|
|
57
|
+
export { default as LslWebSocketBridge } from './impl/LslWebSocketBridge'
|
|
58
|
+
export * from './impl/LslWebSocketBridge'
|
|
51
59
|
|
|
52
|
-
export { default as
|
|
53
|
-
export * from './testDoubles/
|
|
60
|
+
export { default as FakeStreamTransportBridge } from './testDoubles/StreamTransportBridge/FakeStreamTransportBridge'
|
|
61
|
+
export * from './testDoubles/StreamTransportBridge/FakeStreamTransportBridge'
|
|
54
62
|
|
|
55
63
|
// Utils
|
|
56
64
|
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import LslEventMarkerOutlet from '../impl/LslEventMarkerOutlet'
|
|
2
|
+
|
|
3
|
+
async function main() {
|
|
4
|
+
const outlet = await LslEventMarkerOutlet.Create()
|
|
5
|
+
|
|
6
|
+
const markers = [
|
|
7
|
+
{ name: 'phase-1-begin', durationMs: 100 },
|
|
8
|
+
{ name: 'phase-1-end', durationMs: 10 },
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
// Hangs until complete
|
|
12
|
+
await outlet.pushMarkers(markers)
|
|
13
|
+
|
|
14
|
+
// Void promise, does not hang
|
|
15
|
+
void outlet.pushMarkers(markers)
|
|
16
|
+
|
|
17
|
+
// Interrupts the above pushMarkers process
|
|
18
|
+
outlet.stop()
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
main().catch((error) => {
|
|
22
|
+
console.error('Error in main:', error)
|
|
23
|
+
})
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import LslStreamOutlet from '../impl/LslStreamOutlet'
|
|
2
|
+
|
|
3
|
+
async function main() {
|
|
4
|
+
const instance = await LslStreamOutlet.Create({
|
|
5
|
+
name: 'Muse S (2nd gen)',
|
|
6
|
+
type: 'EEG',
|
|
7
|
+
channelNames: ['TP9', 'AF7', 'AF8', 'TP10', 'AUX'],
|
|
8
|
+
sampleRate: 256,
|
|
9
|
+
channelFormat: 'float32',
|
|
10
|
+
sourceId: 'muse-s-eeg',
|
|
11
|
+
manufacturer: 'Interaxon Inc.',
|
|
12
|
+
unit: 'microvolt',
|
|
13
|
+
chunkSize: 12,
|
|
14
|
+
maxBuffered: 360,
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
instance.pushSample([1, 2, 3, 4, 5])
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
main().catch((error) => {
|
|
21
|
+
console.error('Error in main:', error)
|
|
22
|
+
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EventMarkerOutlet } from '../../impl/LslEventMarkerOutlet'
|
|
2
2
|
import { DurationMarker } from '../../types'
|
|
3
3
|
|
|
4
|
-
export default class
|
|
4
|
+
export default class FakeEventMarkerOutlet implements EventMarkerOutlet {
|
|
5
5
|
public static callsToPushMarker: string[] = []
|
|
6
6
|
public static callsToPushMarkers: DurationMarker[][] = []
|
|
7
7
|
public static numCallsToStop = 0
|
|
@@ -10,19 +10,19 @@ export default class FakeMarkerOutlet implements MarkerOutlet {
|
|
|
10
10
|
public constructor() {}
|
|
11
11
|
|
|
12
12
|
public pushMarker(markerName: string) {
|
|
13
|
-
|
|
13
|
+
FakeEventMarkerOutlet.callsToPushMarker.push(markerName)
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
public async pushMarkers(markers: DurationMarker[]) {
|
|
17
|
-
|
|
17
|
+
FakeEventMarkerOutlet.callsToPushMarkers.push(markers)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
public stop() {
|
|
21
|
-
|
|
21
|
+
FakeEventMarkerOutlet.numCallsToStop++
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
public destroy() {
|
|
25
|
-
|
|
25
|
+
FakeEventMarkerOutlet.numCallsToDestroy++
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
public static resetTestDouble() {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { assert } from '@sprucelabs/test-utils'
|
|
2
|
-
import {
|
|
2
|
+
import { EventMarkerOutlet } from '../../impl/LslEventMarkerOutlet'
|
|
3
3
|
import { DurationMarker, LslSample } from '../../types'
|
|
4
4
|
|
|
5
|
-
export default class
|
|
5
|
+
export default class MockEventMarkerOutlet implements EventMarkerOutlet {
|
|
6
6
|
private didPushMarkers = false
|
|
7
7
|
private pushedMarkers?: DurationMarker[]
|
|
8
8
|
private didPushSamples = false
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import LslEventMarkerOutlet from '../../impl/LslEventMarkerOutlet'
|
|
2
|
+
import { StreamOutlet } from '../../impl/LslStreamOutlet'
|
|
3
|
+
|
|
4
|
+
export default class SpyEventMarkerOutlet extends LslEventMarkerOutlet {
|
|
5
|
+
public totalWaitTimeMs: number
|
|
6
|
+
|
|
7
|
+
public constructor(outlet: StreamOutlet) {
|
|
8
|
+
super(outlet)
|
|
9
|
+
this.totalWaitTimeMs = 0
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public async wait(durationMs: number) {
|
|
13
|
+
this.totalWaitTimeMs += durationMs
|
|
14
|
+
return Promise.resolve()
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public getStreamOutlet() {
|
|
18
|
+
return this.streamOutlet
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public resetTestDouble() {
|
|
22
|
+
this.totalWaitTimeMs = 0
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EventMarkerOutlet } from '../../impl/LslEventMarkerOutlet'
|
|
2
2
|
import { DurationMarker } from '../../types'
|
|
3
3
|
|
|
4
|
-
export default class
|
|
4
|
+
export default class ThrowingEventMarkerOutlet implements EventMarkerOutlet {
|
|
5
5
|
private errorMsg = 'Intentional throwing: '
|
|
6
6
|
|
|
7
7
|
public constructor() {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { StreamInfo } from '../../impl/LslStreamInfo'
|
|
2
|
+
import { StreamInlet, StreamInletOptions } from '../../impl/LslStreamInlet'
|
|
3
|
+
|
|
4
|
+
export default class FakeStreamInlet implements StreamInlet {
|
|
5
|
+
public static callsToConstructor: {
|
|
6
|
+
info?: StreamInfo
|
|
7
|
+
options?: StreamInletOptions
|
|
8
|
+
}[] = []
|
|
9
|
+
|
|
10
|
+
public constructor(info?: StreamInfo, options?: StreamInletOptions) {
|
|
11
|
+
FakeStreamInlet.callsToConstructor.push({
|
|
12
|
+
info,
|
|
13
|
+
options,
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public static resetTestDouble() {
|
|
18
|
+
FakeStreamInlet.callsToConstructor = []
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { StreamInfo } from '../../impl/LslStreamInfo'
|
|
2
|
+
import LslStreamInlet, { StreamInletOptions } from '../../impl/LslStreamInlet'
|
|
3
|
+
|
|
4
|
+
export class SpyStreamInlet extends LslStreamInlet {
|
|
5
|
+
public constructor(info: StreamInfo, options: StreamInletOptions) {
|
|
6
|
+
super(info, options)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
public getName() {
|
|
10
|
+
return this.name
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
public getStreamInfo() {
|
|
14
|
+
return this.info
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -1,27 +1,31 @@
|
|
|
1
1
|
import { randomInt } from 'crypto'
|
|
2
|
-
import
|
|
3
|
-
import { StreamInfo } from '../../
|
|
4
|
-
import {
|
|
2
|
+
import generateId from '@neurodevs/generate-id'
|
|
3
|
+
import { StreamInfo } from '../../impl/LslStreamInfo'
|
|
4
|
+
import { StreamOutlet, StreamOutletOptions } from '../../impl/LslStreamOutlet'
|
|
5
5
|
import { LslSample } from '../../types'
|
|
6
6
|
|
|
7
|
-
export default class
|
|
8
|
-
public static callsToConstructor:
|
|
7
|
+
export default class FakeStreamOutlet implements StreamOutlet {
|
|
8
|
+
public static callsToConstructor: {
|
|
9
|
+
info?: StreamInfo
|
|
10
|
+
options?: StreamOutletOptions
|
|
11
|
+
}[] = []
|
|
12
|
+
|
|
9
13
|
public static callsToPushSample: LslSample[] = []
|
|
10
14
|
public static numCallsToDestroy = 0
|
|
11
15
|
|
|
12
|
-
public options?:
|
|
16
|
+
public options?: StreamOutletOptions
|
|
13
17
|
|
|
14
|
-
public constructor(info?: StreamInfo, options?:
|
|
15
|
-
|
|
18
|
+
public constructor(info?: StreamInfo, options?: StreamOutletOptions) {
|
|
19
|
+
FakeStreamOutlet.callsToConstructor.push({ info, options })
|
|
16
20
|
this.options = options
|
|
17
21
|
}
|
|
18
22
|
|
|
19
23
|
public destroy() {
|
|
20
|
-
|
|
24
|
+
FakeStreamOutlet.numCallsToDestroy++
|
|
21
25
|
}
|
|
22
26
|
|
|
23
27
|
public pushSample(sample: LslSample) {
|
|
24
|
-
|
|
28
|
+
FakeStreamOutlet.callsToPushSample.push(sample)
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
public get name() {
|
|
@@ -69,13 +73,8 @@ export default class FakeLslOutlet implements LslOutlet {
|
|
|
69
73
|
}
|
|
70
74
|
|
|
71
75
|
public static resetTestDouble() {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
76
|
+
FakeStreamOutlet.callsToConstructor = []
|
|
77
|
+
FakeStreamOutlet.callsToPushSample = []
|
|
78
|
+
FakeStreamOutlet.numCallsToDestroy = 0
|
|
75
79
|
}
|
|
76
80
|
}
|
|
77
|
-
|
|
78
|
-
export interface CallToOutletConstructor {
|
|
79
|
-
info?: StreamInfo
|
|
80
|
-
options?: LslOutletOptions
|
|
81
|
-
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { StreamTransportBridge } from '../../impl/LslWebSocketBridge'
|
|
2
|
+
|
|
3
|
+
export default class FakeStreamTransportBridge
|
|
4
|
+
implements StreamTransportBridge
|
|
5
|
+
{
|
|
6
|
+
public static numCallsToConstructor = 0
|
|
7
|
+
|
|
8
|
+
public constructor() {
|
|
9
|
+
FakeStreamTransportBridge.numCallsToConstructor++
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public static resetTestDouble() {
|
|
13
|
+
FakeStreamTransportBridge.numCallsToConstructor = 0
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { randomInt } from 'crypto'
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import generateId from '@neurodevs/generate-id'
|
|
3
|
+
import { StreamOutletOptions } from '../impl/LslStreamOutlet'
|
|
4
4
|
import { TEST_SUPPORTED_CHANNEL_FORMATS } from './consts'
|
|
5
5
|
|
|
6
6
|
export default function generateRandomOutletOptions() {
|
|
@@ -17,5 +17,5 @@ export default function generateRandomOutletOptions() {
|
|
|
17
17
|
unit: generateId(),
|
|
18
18
|
chunkSize: randomInt(0, 10),
|
|
19
19
|
maxBuffered: randomInt(0, 10),
|
|
20
|
-
} as
|
|
20
|
+
} as StreamOutletOptions
|
|
21
21
|
}
|
package/src/types.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { FuncObj, FieldType } from 'ffi-rs'
|
|
2
2
|
import { CHANNEL_FORMATS } from './consts'
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { StreamInlet } from './impl/LslStreamInlet'
|
|
4
|
+
import { StreamOutlet } from './impl/LslStreamOutlet'
|
|
5
5
|
|
|
6
|
-
export type StreamFixuture =
|
|
6
|
+
export type StreamFixuture = StreamOutlet | StreamInlet
|
|
7
7
|
|
|
8
8
|
export type ChannelFormat = (typeof CHANNEL_FORMATS)[number]
|
|
9
9
|
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { default as SchemaEntity } from '@sprucelabs/schema';
|
|
2
|
-
import * as SpruceSchema from '@sprucelabs/schema';
|
|
3
|
-
export declare namespace SpruceErrors.NodeLsl {
|
|
4
|
-
interface FailedToLoadLiblsl {
|
|
5
|
-
'liblslPath': string;
|
|
6
|
-
}
|
|
7
|
-
interface FailedToLoadLiblslSchema extends SpruceSchema.Schema {
|
|
8
|
-
id: 'failedToLoadLiblsl';
|
|
9
|
-
namespace: 'NodeLsl';
|
|
10
|
-
name: 'FAILED_TO_LOAD_LIBLSL';
|
|
11
|
-
fields: {
|
|
12
|
-
/** . */
|
|
13
|
-
'liblslPath': {
|
|
14
|
-
type: 'text';
|
|
15
|
-
isRequired: true;
|
|
16
|
-
options: undefined;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
type FailedToLoadLiblslEntity = SchemaEntity<SpruceErrors.NodeLsl.FailedToLoadLiblslSchema>;
|
|
21
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.types.js","sourceRoot":"","sources":["../../../src/.spruce/errors/errors.types.ts"],"names":[],"mappings":""}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const schema_1 = require("@sprucelabs/schema");
|
|
4
|
-
const failedToLoadLiblslSchema = {
|
|
5
|
-
id: 'failedToLoadLiblsl',
|
|
6
|
-
namespace: 'NodeLsl',
|
|
7
|
-
name: 'FAILED_TO_LOAD_LIBLSL',
|
|
8
|
-
fields: {
|
|
9
|
-
/** . */
|
|
10
|
-
'liblslPath': {
|
|
11
|
-
type: 'text',
|
|
12
|
-
isRequired: true,
|
|
13
|
-
options: undefined
|
|
14
|
-
},
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
schema_1.SchemaRegistry.getInstance().trackSchema(failedToLoadLiblslSchema);
|
|
18
|
-
exports.default = failedToLoadLiblslSchema;
|
|
19
|
-
//# sourceMappingURL=failedToLoadLiblsl.schema.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"failedToLoadLiblsl.schema.js","sourceRoot":"","sources":["../../../../src/.spruce/errors/nodeLsl/failedToLoadLiblsl.schema.ts"],"names":[],"mappings":";;AAAA,+CAAmD;AAKnD,MAAM,wBAAwB,GAAmD;IAChF,EAAE,EAAE,oBAAoB;IACxB,SAAS,EAAE,SAAS;IACpB,IAAI,EAAE,uBAAuB;IACzB,MAAM,EAAE;QACA,QAAQ;QACR,YAAY,EAAE;YACV,IAAI,EAAE,MAAM;YACZ,UAAU,EAAE,IAAI;YAChB,OAAO,EAAE,SAAS;SACrB;KACR;CACL,CAAA;AAED,uBAAc,CAAC,WAAW,EAAE,CAAC,WAAW,CAAC,wBAAwB,CAAC,CAAA;AAElE,kBAAe,wBAAwB,CAAA"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { SpruceErrors } from "./errors.types";
|
|
2
|
-
import { ErrorOptions as ISpruceErrorOptions } from "@sprucelabs/error";
|
|
3
|
-
export interface FailedToLoadLiblslErrorOptions extends SpruceErrors.NodeLsl.FailedToLoadLiblsl, ISpruceErrorOptions {
|
|
4
|
-
code: 'FAILED_TO_LOAD_LIBLSL';
|
|
5
|
-
}
|
|
6
|
-
type ErrorOptions = FailedToLoadLiblslErrorOptions;
|
|
7
|
-
export default ErrorOptions;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"options.types.js","sourceRoot":"","sources":["../../../src/.spruce/errors/options.types.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fieldClassMap.js","sourceRoot":"","sources":["../../../../src/.spruce/schemas/fields/fieldClassMap.ts"],"names":[],"mappings":";;AAAA,+CAAkD;AAKlD,kBAAe,sBAAa,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { FieldDefinitions, FieldDefinitionMap, FieldValueTypeGeneratorMap, FieldMap } from '@sprucelabs/schema';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fields.types.js","sourceRoot":"","sources":["../../../../src/.spruce/schemas/fields/fields.types.ts"],"names":[],"mappings":""}
|