@neurodevs/node-lsl 2.0.1 → 3.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 +1 -1
- package/build/Liblsl.d.ts +33 -25
- package/build/Liblsl.js +29 -30
- package/build/Liblsl.js.map +1 -1
- package/build/LslOutlet.d.ts +7 -5
- package/build/LslOutlet.js +26 -18
- package/build/LslOutlet.js.map +1 -1
- package/build/__tests__/behavioral/LslOutlet.test.d.ts +10 -10
- package/build/__tests__/behavioral/LslOutlet.test.js +60 -57
- package/build/__tests__/behavioral/LslOutlet.test.js.map +1 -1
- package/build/__tests__/implementation/Liblsl.test.d.ts +9 -9
- package/build/__tests__/implementation/Liblsl.test.js +76 -66
- package/build/__tests__/implementation/Liblsl.test.js.map +1 -1
- package/package.json +1 -1
- package/src/Liblsl.ts +76 -73
- package/src/LslOutlet.ts +37 -30
- package/src/__tests__/behavioral/LslOutlet.test.ts +74 -71
- package/src/__tests__/implementation/Liblsl.test.ts +96 -84
package/README.md
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
# node-lsl
|
|
2
|
-
Lab Streaming Layer (LSL) on Node
|
|
2
|
+
Lab Streaming Layer (LSL) on Node + TypeScript
|
package/build/Liblsl.d.ts
CHANGED
|
@@ -4,22 +4,21 @@ export default class LiblslImpl implements Liblsl {
|
|
|
4
4
|
static ffi: typeof ffi;
|
|
5
5
|
private bindings;
|
|
6
6
|
static getInstance(): Liblsl;
|
|
7
|
-
static reset(): void;
|
|
8
7
|
static setInstance(instance: Liblsl): void;
|
|
8
|
+
static resetInstance(): void;
|
|
9
9
|
constructor();
|
|
10
|
-
appendChannelsToStreamInfo(info: LslBindingsStreamInfo, channels: LslChannel[]): void;
|
|
11
10
|
private loadBindings;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
createStreamInfo(options: CreateStreamInfoOptions): BoundStreamInfo;
|
|
12
|
+
appendChannelsToStreamInfo(options: AppendChannelsToStreamInfoOptions): void;
|
|
13
|
+
createOutlet(options: CreateOutletOptions): BoundOutlet;
|
|
14
|
+
pushSample(options: PushSampleOptions): void;
|
|
15
15
|
}
|
|
16
16
|
export interface Liblsl {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
createOutlet(options: CreateOutletOptions):
|
|
20
|
-
pushSample(
|
|
17
|
+
createStreamInfo(options: CreateStreamInfoOptions): BoundStreamInfo;
|
|
18
|
+
appendChannelsToStreamInfo(options: AppendChannelsToStreamInfoOptions): void;
|
|
19
|
+
createOutlet(options: CreateOutletOptions): BoundOutlet;
|
|
20
|
+
pushSample(options: PushSampleOptions): void;
|
|
21
21
|
}
|
|
22
|
-
export type LslSample = (number | string | undefined)[];
|
|
23
22
|
export interface CreateStreamInfoOptions {
|
|
24
23
|
name: string;
|
|
25
24
|
type: string;
|
|
@@ -30,30 +29,39 @@ export interface CreateStreamInfoOptions {
|
|
|
30
29
|
manufacturer?: string;
|
|
31
30
|
unit?: string;
|
|
32
31
|
}
|
|
32
|
+
export interface AppendChannelsToStreamInfoOptions {
|
|
33
|
+
info: BoundStreamInfo;
|
|
34
|
+
channels: LslChannel[];
|
|
35
|
+
}
|
|
36
|
+
export interface CreateOutletOptions {
|
|
37
|
+
info: BoundStreamInfo;
|
|
38
|
+
chunkSize: number;
|
|
39
|
+
maxBuffered: number;
|
|
40
|
+
}
|
|
41
|
+
export interface PushSampleOptions {
|
|
42
|
+
outlet: BoundOutlet;
|
|
43
|
+
sample: LslSample;
|
|
44
|
+
}
|
|
33
45
|
export interface LslChannel {
|
|
34
46
|
label: string;
|
|
35
47
|
unit: string;
|
|
36
48
|
type: string;
|
|
37
49
|
}
|
|
50
|
+
export type LslSample = (number | string | undefined)[];
|
|
38
51
|
export interface LiblslBindings {
|
|
39
|
-
lsl_create_streaminfo(name: string, type: string, channelCount: number, sampleRate: number, channelFormat: number, sourceId: string):
|
|
40
|
-
lsl_create_outlet(info:
|
|
41
|
-
lsl_push_sample_ft(outlet:
|
|
52
|
+
lsl_create_streaminfo(name: string, type: string, channelCount: number, sampleRate: number, channelFormat: number, sourceId: string): BoundStreamInfo;
|
|
53
|
+
lsl_create_outlet(info: BoundStreamInfo, chunkSize: number, maxBuffered: number): BoundOutlet;
|
|
54
|
+
lsl_push_sample_ft(outlet: BoundOutlet, sample: LslSample, timestamp: number): void;
|
|
42
55
|
lsl_local_clock(): number;
|
|
43
|
-
lsl_get_desc(info:
|
|
44
|
-
lsl_append_child(desc:
|
|
45
|
-
lsl_append_child_value(child:
|
|
46
|
-
}
|
|
47
|
-
export interface CreateOutletOptions {
|
|
48
|
-
info: LslBindingsStreamInfo;
|
|
49
|
-
chunkSize: number;
|
|
50
|
-
maxBuffered: number;
|
|
56
|
+
lsl_get_desc(info: BoundStreamInfo): BoundDesc;
|
|
57
|
+
lsl_append_child(desc: BoundDesc, name: string): BoundChild;
|
|
58
|
+
lsl_append_child_value(child: BoundChild, name: string, value: string): void;
|
|
51
59
|
}
|
|
52
|
-
export interface
|
|
60
|
+
export interface BoundStreamInfo {
|
|
53
61
|
}
|
|
54
|
-
export interface
|
|
62
|
+
export interface BoundOutlet {
|
|
55
63
|
}
|
|
56
|
-
export interface
|
|
64
|
+
export interface BoundDesc {
|
|
57
65
|
}
|
|
58
|
-
export interface
|
|
66
|
+
export interface BoundChild {
|
|
59
67
|
}
|
package/build/Liblsl.js
CHANGED
|
@@ -11,16 +11,16 @@ const SpruceError_1 = __importDefault(require("./errors/SpruceError"));
|
|
|
11
11
|
class LiblslImpl {
|
|
12
12
|
static getInstance() {
|
|
13
13
|
if (!this.instance) {
|
|
14
|
-
this.
|
|
14
|
+
this.setInstance(new this());
|
|
15
15
|
}
|
|
16
16
|
return this.instance;
|
|
17
17
|
}
|
|
18
|
-
static reset() {
|
|
19
|
-
delete this.instance;
|
|
20
|
-
}
|
|
21
18
|
static setInstance(instance) {
|
|
22
19
|
this.instance = instance;
|
|
23
20
|
}
|
|
21
|
+
static resetInstance() {
|
|
22
|
+
delete this.instance;
|
|
23
|
+
}
|
|
24
24
|
constructor() {
|
|
25
25
|
const path = process.env.LIBLSL_PATH;
|
|
26
26
|
if (!path) {
|
|
@@ -29,25 +29,13 @@ class LiblslImpl {
|
|
|
29
29
|
try {
|
|
30
30
|
this.bindings = this.loadBindings(path);
|
|
31
31
|
}
|
|
32
|
-
catch (
|
|
33
|
-
console.error(err);
|
|
32
|
+
catch (_a) {
|
|
34
33
|
throw new SpruceError_1.default({
|
|
35
34
|
code: 'FAILED_TO_LOAD_LIBLSL',
|
|
36
35
|
liblslPath: path,
|
|
37
36
|
});
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
|
-
appendChannelsToStreamInfo(info, channels) {
|
|
41
|
-
(0, schema_1.assertOptions)({ info, channels }, ['info', 'channels']);
|
|
42
|
-
const desc = this.bindings.lsl_get_desc(info);
|
|
43
|
-
const parent = this.bindings.lsl_append_child(desc, 'channels');
|
|
44
|
-
for (const channel of channels) {
|
|
45
|
-
const c = this.bindings.lsl_append_child(parent, 'channel');
|
|
46
|
-
this.bindings.lsl_append_child_value(c, 'label', channel.label);
|
|
47
|
-
this.bindings.lsl_append_child_value(c, 'unit', channel.unit);
|
|
48
|
-
this.bindings.lsl_append_child_value(c, 'type', channel.type);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
39
|
loadBindings(path) {
|
|
52
40
|
return LiblslImpl.ffi.Library(path, {
|
|
53
41
|
lsl_create_streaminfo: [
|
|
@@ -62,19 +50,6 @@ class LiblslImpl {
|
|
|
62
50
|
lsl_append_child_value: [xmlPtr, [xmlPtr, 'string', 'string']],
|
|
63
51
|
});
|
|
64
52
|
}
|
|
65
|
-
pushSample(outlet, sample) {
|
|
66
|
-
(0, schema_1.assertOptions)({ outlet, sample }, ['outlet', 'sample']);
|
|
67
|
-
const clock = this.bindings.lsl_local_clock();
|
|
68
|
-
this.bindings.lsl_push_sample_ft(outlet, sample, clock);
|
|
69
|
-
}
|
|
70
|
-
createOutlet(options) {
|
|
71
|
-
const { info, chunkSize, maxBuffered } = (0, schema_1.assertOptions)(options, [
|
|
72
|
-
'info',
|
|
73
|
-
'chunkSize',
|
|
74
|
-
'maxBuffered',
|
|
75
|
-
]);
|
|
76
|
-
return this.bindings.lsl_create_outlet(info, chunkSize, maxBuffered);
|
|
77
|
-
}
|
|
78
53
|
createStreamInfo(options) {
|
|
79
54
|
const { name, type, channelCount, sampleRate, channelFormat, sourceId } = (0, schema_1.assertOptions)(options, [
|
|
80
55
|
'name',
|
|
@@ -86,6 +61,30 @@ class LiblslImpl {
|
|
|
86
61
|
]);
|
|
87
62
|
return this.bindings.lsl_create_streaminfo(name, type, channelCount, sampleRate, channelFormat, sourceId);
|
|
88
63
|
}
|
|
64
|
+
appendChannelsToStreamInfo(options) {
|
|
65
|
+
const { info, channels } = (0, schema_1.assertOptions)(options, ['info', 'channels']);
|
|
66
|
+
const desc = this.bindings.lsl_get_desc(info);
|
|
67
|
+
const parent = this.bindings.lsl_append_child(desc, 'channels');
|
|
68
|
+
for (const channel of channels) {
|
|
69
|
+
const child = this.bindings.lsl_append_child(parent, 'channel');
|
|
70
|
+
this.bindings.lsl_append_child_value(child, 'label', channel.label);
|
|
71
|
+
this.bindings.lsl_append_child_value(child, 'unit', channel.unit);
|
|
72
|
+
this.bindings.lsl_append_child_value(child, 'type', channel.type);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
createOutlet(options) {
|
|
76
|
+
const { info, chunkSize, maxBuffered } = (0, schema_1.assertOptions)(options, [
|
|
77
|
+
'info',
|
|
78
|
+
'chunkSize',
|
|
79
|
+
'maxBuffered',
|
|
80
|
+
]);
|
|
81
|
+
return this.bindings.lsl_create_outlet(info, chunkSize, maxBuffered);
|
|
82
|
+
}
|
|
83
|
+
pushSample(options) {
|
|
84
|
+
const { outlet, sample } = (0, schema_1.assertOptions)(options, ['outlet', 'sample']);
|
|
85
|
+
const clock = this.bindings.lsl_local_clock();
|
|
86
|
+
this.bindings.lsl_push_sample_ft(outlet, sample, clock);
|
|
87
|
+
}
|
|
89
88
|
}
|
|
90
89
|
LiblslImpl.ffi = ffi_napi_1.default;
|
|
91
90
|
exports.default = LiblslImpl;
|
package/build/Liblsl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Liblsl.js","sourceRoot":"","sources":["../src/Liblsl.ts"],"names":[],"mappings":";;;;;AAAA,+CAAkD;AAClD,wDAA0B;AAC1B,oEAAsC;AACtC,wDAA0B;AAC1B,uEAA8C;AAE9C,MAAqB,UAAU;IAKvB,MAAM,CAAC,WAAW;QACxB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YACnB,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"Liblsl.js","sourceRoot":"","sources":["../src/Liblsl.ts"],"names":[],"mappings":";;;;;AAAA,+CAAkD;AAClD,wDAA0B;AAC1B,oEAAsC;AACtC,wDAA0B;AAC1B,uEAA8C;AAE9C,MAAqB,UAAU;IAKvB,MAAM,CAAC,WAAW;QACxB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YACnB,IAAI,CAAC,WAAW,CAAC,IAAI,IAAI,EAAE,CAAC,CAAA;SAC5B;QACD,OAAO,IAAI,CAAC,QAAS,CAAA;IACtB,CAAC;IAEM,MAAM,CAAC,WAAW,CAAC,QAAgB;QACzC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IACzB,CAAC;IAEM,MAAM,CAAC,aAAa;QAC1B,OAAO,IAAI,CAAC,QAAQ,CAAA;IACrB,CAAC;IAED;QACC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,WAAY,CAAA;QAErC,IAAI,CAAC,IAAI,EAAE;YACV,IAAA,sBAAa,EAAC,OAAO,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAA;SAC3C;QAED,IAAI;YACH,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;SACvC;QAAC,WAAM;YACP,MAAM,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C7C,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAC,CAAA;IACxD,CAAC;;AAvGa,cAAG,GAAG,kBAAG,CAAA;kBAFH,UAAU;AAsL/B,MAAM,UAAU,GAAG,kBAAG,CAAC,OAAO,CAAC,kBAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;AAC9C,MAAM,UAAU,GAAG,kBAAG,CAAC,OAAO,CAAC,kBAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;AAC9C,MAAM,UAAU,GAAG,IAAA,wBAAS,EAAC,kBAAG,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;AAC7C,MAAM,MAAM,GAAG,kBAAG,CAAC,OAAO,CAAC,kBAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA"}
|
package/build/LslOutlet.d.ts
CHANGED
|
@@ -3,8 +3,11 @@ export default class LslOutletImpl implements LslOutlet {
|
|
|
3
3
|
private outletOptions;
|
|
4
4
|
static Class?: new (options: LslOutletOptions) => LslOutlet;
|
|
5
5
|
private streamInfo;
|
|
6
|
+
private outlet;
|
|
6
7
|
protected constructor(options: LslOutletOptions);
|
|
7
8
|
static Outlet(options: LslOutletOptions): LslOutlet;
|
|
9
|
+
pushSample(sample: LslSample): void;
|
|
10
|
+
private lookupChannelFormat;
|
|
8
11
|
private assertValidMaxBufferred;
|
|
9
12
|
private assertValidChunkSize;
|
|
10
13
|
private assertValidChannelFormat;
|
|
@@ -14,14 +17,16 @@ export default class LslOutletImpl implements LslOutlet {
|
|
|
14
17
|
private isPositiveIntegerOrZero;
|
|
15
18
|
private isPositiveInteger;
|
|
16
19
|
private get lsl();
|
|
17
|
-
pushSample(sample: LslSample): void;
|
|
18
20
|
}
|
|
19
21
|
declare const CHANNEL_FORMATS: readonly ["undefined", "float32", "double64", "string", "int32", "int16", "int8", "int64"];
|
|
20
22
|
export type ChannelFormat = (typeof CHANNEL_FORMATS)[number];
|
|
23
|
+
export interface LslOutlet {
|
|
24
|
+
pushSample(sample: LslSample): void;
|
|
25
|
+
}
|
|
21
26
|
export interface LslOutletOptions {
|
|
22
27
|
name: string;
|
|
23
28
|
type: string;
|
|
24
|
-
|
|
29
|
+
channelNames: string[];
|
|
25
30
|
sampleRate: number;
|
|
26
31
|
channelFormat: ChannelFormat;
|
|
27
32
|
sourceId: string;
|
|
@@ -30,7 +35,4 @@ export interface LslOutletOptions {
|
|
|
30
35
|
chunkSize: number;
|
|
31
36
|
maxBuffered: number;
|
|
32
37
|
}
|
|
33
|
-
export interface LslOutlet {
|
|
34
|
-
pushSample(sample: LslSample): void;
|
|
35
|
-
}
|
|
36
38
|
export {};
|
package/build/LslOutlet.js
CHANGED
|
@@ -21,7 +21,7 @@ class LslOutletImpl {
|
|
|
21
21
|
const { sampleRate, channelFormat } = (0, schema_1.assertOptions)(options, [
|
|
22
22
|
'name',
|
|
23
23
|
'type',
|
|
24
|
-
'
|
|
24
|
+
'channelNames',
|
|
25
25
|
'sampleRate',
|
|
26
26
|
'channelFormat',
|
|
27
27
|
'sourceId',
|
|
@@ -32,25 +32,40 @@ class LslOutletImpl {
|
|
|
32
32
|
]);
|
|
33
33
|
this.outletOptions = options;
|
|
34
34
|
const _a = this
|
|
35
|
-
.outletOptions, { chunkSize, maxBuffered,
|
|
36
|
-
|
|
35
|
+
.outletOptions, { chunkSize, maxBuffered, channelNames } = _a, streamInfoOptions = __rest(_a, ["chunkSize", "maxBuffered", "channelNames"]);
|
|
36
|
+
const channelCount = channelNames.length;
|
|
37
|
+
this.assertValidChannelCount(channelCount);
|
|
37
38
|
this.assertValidSampleRate(sampleRate);
|
|
38
39
|
this.assertValidChannelFormat(channelFormat);
|
|
39
40
|
this.assertValidChunkSize(chunkSize);
|
|
40
41
|
this.assertValidMaxBufferred(maxBuffered);
|
|
41
42
|
delete streamInfoOptions.manufacturer;
|
|
42
43
|
delete streamInfoOptions.unit;
|
|
43
|
-
this.streamInfo = this.lsl.createStreamInfo(Object.assign(Object.assign({}, streamInfoOptions), { channelCount
|
|
44
|
-
this.lsl.appendChannelsToStreamInfo(
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
44
|
+
this.streamInfo = this.lsl.createStreamInfo(Object.assign(Object.assign({}, streamInfoOptions), { channelCount, channelFormat: this.lookupChannelFormat(channelFormat) }));
|
|
45
|
+
this.lsl.appendChannelsToStreamInfo({
|
|
46
|
+
info: this.streamInfo,
|
|
47
|
+
channels: channelNames.map((label) => ({
|
|
48
|
+
label,
|
|
49
|
+
unit: this.outletOptions.unit,
|
|
50
|
+
type: this.outletOptions.type,
|
|
51
|
+
})),
|
|
52
|
+
});
|
|
53
|
+
this.outlet = this.lsl.createOutlet({
|
|
54
|
+
info: this.streamInfo,
|
|
55
|
+
chunkSize: this.outletOptions.chunkSize,
|
|
56
|
+
maxBuffered: this.outletOptions.maxBuffered,
|
|
57
|
+
});
|
|
49
58
|
}
|
|
50
59
|
static Outlet(options) {
|
|
51
60
|
var _a;
|
|
52
61
|
return new ((_a = this.Class) !== null && _a !== void 0 ? _a : this)(options);
|
|
53
62
|
}
|
|
63
|
+
pushSample(sample) {
|
|
64
|
+
this.lsl.pushSample({ outlet: this.outlet, sample });
|
|
65
|
+
}
|
|
66
|
+
lookupChannelFormat(channelFormat) {
|
|
67
|
+
return CHANNEL_FORMATS.indexOf(channelFormat);
|
|
68
|
+
}
|
|
54
69
|
assertValidMaxBufferred(maxBuffered) {
|
|
55
70
|
if (!this.isPositiveIntegerOrZero(maxBuffered)) {
|
|
56
71
|
throw new schema_1.SchemaError({
|
|
@@ -92,8 +107,8 @@ class LslOutletImpl {
|
|
|
92
107
|
if (!this.isPositiveInteger(channelCount)) {
|
|
93
108
|
throw new schema_1.SchemaError({
|
|
94
109
|
code: 'INVALID_PARAMETERS',
|
|
95
|
-
parameters: ['
|
|
96
|
-
friendlyMessage: '
|
|
110
|
+
parameters: ['channelNames'],
|
|
111
|
+
friendlyMessage: 'channelNames must have 1 or more labels.',
|
|
97
112
|
});
|
|
98
113
|
}
|
|
99
114
|
}
|
|
@@ -109,13 +124,6 @@ class LslOutletImpl {
|
|
|
109
124
|
get lsl() {
|
|
110
125
|
return Liblsl_1.default.getInstance();
|
|
111
126
|
}
|
|
112
|
-
pushSample(sample) {
|
|
113
|
-
this.lsl.pushSample(this.lsl.createOutlet({
|
|
114
|
-
info: this.streamInfo,
|
|
115
|
-
chunkSize: this.outletOptions.chunkSize,
|
|
116
|
-
maxBuffered: this.outletOptions.maxBuffered,
|
|
117
|
-
}), sample);
|
|
118
|
-
}
|
|
119
127
|
}
|
|
120
128
|
exports.default = LslOutletImpl;
|
|
121
129
|
const CHANNEL_FORMATS = [
|
package/build/LslOutlet.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LslOutlet.js","sourceRoot":"","sources":["../src/LslOutlet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA+D;AAC/D,
|
|
1
|
+
{"version":3,"file":"LslOutlet.js","sourceRoot":"","sources":["../src/LslOutlet.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA+D;AAC/D,sDAA8E;AAE9E,MAAqB,aAAa;IAMjC,YAAsB,OAAyB;QAC9C,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,IAAA,sBAAa,EAAC,OAAO,EAAE;YAC5D,MAAM;YACN,MAAM;YACN,cAAc;YACd,YAAY;YACZ,eAAe;YACf,UAAU;YACV,cAAc;YACd,MAAM;YACN,WAAW;YACX,aAAa;SACb,CAAC,CAAA;QAEF,IAAI,CAAC,aAAa,GAAG,OAAO,CAAA;QAE5B,MAAM,KAAiE,IAAI;aACzE,aAAoB,EADhB,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,OACtB,EAD2B,iBAAiB,cAA5D,4CAA8D,CAC9C,CAAA;QAEtB,MAAM,YAAY,GAAG,YAAY,CAAC,MAAM,CAAA;QAExC,IAAI,CAAC,uBA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AC,YAAoB;QACnD,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,YAAY,CAAC,EAAE;YAC1C,MAAM,IAAI,oBAAW,CAAC;gBACrB,IAAI,EAAE,oBAAoB;gBAC1B,UAAU,EAAE,CAAC,cAAc,CAAC;gBAC5B,eAAe,EAAE,0CAA0C;aAC3D,CAAC,CAAA;SACF;IACF,CAAC;IAEO,gBAAgB,CAAC,KAAa;QACrC,OAAO,KAAK,GAAG,CAAC,CAAA;IACjB,CAAC;IAEO,uBAAuB,CAAC,KAAa;QAC5C,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,IAAI,CAAC,CAAA;IAC7C,CAAC;IAEO,iBAAiB,CAAC,KAAa;QACtC,OAAO,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,CAAA;IAC5C,CAAC;IAED,IAAY,GAAG;QACd,OAAO,gBAAU,CAAC,WAAW,EAAE,CAAA;IAChC,CAAC;CACD;AAzID,gCAyIC;AAED,MAAM,eAAe,GAAG;IACvB,WAAW;IACX,SAAS;IACT,UAAU;IACV,QAAQ;IACR,OAAO;IACP,OAAO;IACP,MAAM;IACN,OAAO;CACE,CAAA"}
|
|
@@ -2,27 +2,27 @@ import AbstractSpruceTest from '@sprucelabs/test-utils';
|
|
|
2
2
|
import { LslSample } from '../../Liblsl';
|
|
3
3
|
export declare const CHANNEL_FORMATS: readonly ["undefined", "float32", "double64", "string", "int32", "int16", "int8", "int64"];
|
|
4
4
|
export default class LslOutletTest extends AbstractSpruceTest {
|
|
5
|
-
private static
|
|
5
|
+
private static spyLiblsl;
|
|
6
6
|
private static randomOutletOptions;
|
|
7
7
|
private static channelIdx;
|
|
8
8
|
protected static beforeEach(): Promise<void>;
|
|
9
|
-
protected static
|
|
10
|
-
protected static
|
|
11
|
-
protected static throwsWithInvalidChannelCount(): Promise<void>;
|
|
9
|
+
protected static throwsWhenMissingRequiredParams(): Promise<void>;
|
|
10
|
+
protected static throwsWithInvalidChannelNames(): Promise<void>;
|
|
12
11
|
protected static throwsWithInvalidSampleRate(): Promise<void>;
|
|
13
12
|
protected static throwsWithInvalidChannelFormat(): Promise<void>;
|
|
14
|
-
protected static
|
|
15
|
-
protected static throwWithInvalidChunkSize(): Promise<void>;
|
|
13
|
+
protected static throwsWithInvalidChunkSize(): Promise<void>;
|
|
16
14
|
protected static throwsWithInvalidMaxBuffered(): Promise<void>;
|
|
17
|
-
protected static
|
|
18
|
-
protected static
|
|
19
|
-
protected static
|
|
15
|
+
protected static supportsAllKnownChannelFormats(): Promise<void>;
|
|
16
|
+
protected static canPushSampleToLsl(sample: LslSample): Promise<void>;
|
|
17
|
+
protected static constructionCreatesStreamInfo(): Promise<void>;
|
|
18
|
+
protected static canOverrideClassInstantiatedInFactory(): Promise<void>;
|
|
20
19
|
protected static appendsChannelsBasedOnCount(labels: string[]): Promise<void>;
|
|
20
|
+
protected static pushSampleShouldNotCreateMultipleOutlets(): Promise<void>;
|
|
21
21
|
private static pushSample;
|
|
22
22
|
private static assertThrowsInvalidMaxBuffered;
|
|
23
23
|
private static assertThrowsInvalidChunkSize;
|
|
24
24
|
private static assertThrowsInvalidSampleRate;
|
|
25
|
-
private static
|
|
25
|
+
private static assertThrowsInvalidChannelNames;
|
|
26
26
|
private static assertDoesThrowInvalidParameters;
|
|
27
27
|
private static Outlet;
|
|
28
28
|
}
|
|
@@ -66,7 +66,7 @@ class LslOutletTest extends test_utils_1.default {
|
|
|
66
66
|
this.randomOutletOptions = {
|
|
67
67
|
name: (0, test_utils_1.generateId)(),
|
|
68
68
|
type: (0, test_utils_1.generateId)(),
|
|
69
|
-
|
|
69
|
+
channelNames: new Array((0, crypto_1.randomInt)(1, 10)).fill((0, test_utils_1.generateId)()),
|
|
70
70
|
sampleRate: Math.random() * 10,
|
|
71
71
|
channelFormat: exports.CHANNEL_FORMATS[this.channelIdx],
|
|
72
72
|
sourceId: (0, test_utils_1.generateId)(),
|
|
@@ -75,17 +75,17 @@ class LslOutletTest extends test_utils_1.default {
|
|
|
75
75
|
chunkSize: (0, crypto_1.randomInt)(0, 10),
|
|
76
76
|
maxBuffered: (0, crypto_1.randomInt)(0, 10),
|
|
77
77
|
};
|
|
78
|
-
this.
|
|
79
|
-
Liblsl_1.default.setInstance(this.
|
|
78
|
+
this.spyLiblsl = new SpyLiblsl();
|
|
79
|
+
Liblsl_1.default.setInstance(this.spyLiblsl);
|
|
80
80
|
}
|
|
81
|
-
static async
|
|
81
|
+
static async throwsWhenMissingRequiredParams() {
|
|
82
82
|
//@ts-ignore
|
|
83
83
|
const err = test_utils_1.assert.doesThrow(() => new LslOutlet_1.default());
|
|
84
84
|
test_utils_1.errorAssert.assertError(err, 'MISSING_PARAMETERS', {
|
|
85
85
|
parameters: [
|
|
86
86
|
'name',
|
|
87
87
|
'type',
|
|
88
|
-
'
|
|
88
|
+
'channelNames',
|
|
89
89
|
'sampleRate',
|
|
90
90
|
'channelFormat',
|
|
91
91
|
'sourceId',
|
|
@@ -96,11 +96,8 @@ class LslOutletTest extends test_utils_1.default {
|
|
|
96
96
|
],
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
|
-
static async
|
|
100
|
-
this.
|
|
101
|
-
}
|
|
102
|
-
static async throwsWithInvalidChannelCount() {
|
|
103
|
-
this.assertThrowsInvalidChannelLabels(0);
|
|
99
|
+
static async throwsWithInvalidChannelNames() {
|
|
100
|
+
this.assertThrowsInvalidChannelNames(0);
|
|
104
101
|
}
|
|
105
102
|
static async throwsWithInvalidSampleRate() {
|
|
106
103
|
this.assertThrowsInvalidSampleRate(0);
|
|
@@ -113,13 +110,7 @@ class LslOutletTest extends test_utils_1.default {
|
|
|
113
110
|
'channelFormat',
|
|
114
111
|
]);
|
|
115
112
|
}
|
|
116
|
-
static async
|
|
117
|
-
const valid = exports.CHANNEL_FORMATS;
|
|
118
|
-
for (const format of valid) {
|
|
119
|
-
this.Outlet({ channelFormat: format });
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
static async throwWithInvalidChunkSize() {
|
|
113
|
+
static async throwsWithInvalidChunkSize() {
|
|
123
114
|
this.Outlet({ chunkSize: 0 });
|
|
124
115
|
this.assertThrowsInvalidChunkSize(-1);
|
|
125
116
|
this.assertThrowsInvalidChunkSize(-1.5);
|
|
@@ -131,28 +122,35 @@ class LslOutletTest extends test_utils_1.default {
|
|
|
131
122
|
this.assertThrowsInvalidMaxBuffered(-1.5);
|
|
132
123
|
this.assertThrowsInvalidMaxBuffered(1.5);
|
|
133
124
|
}
|
|
134
|
-
static async
|
|
125
|
+
static async supportsAllKnownChannelFormats() {
|
|
126
|
+
const valid = exports.CHANNEL_FORMATS;
|
|
127
|
+
for (const format of valid) {
|
|
128
|
+
this.Outlet({ channelFormat: format });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
static async canPushSampleToLsl(sample) {
|
|
132
|
+
var _a, _b;
|
|
135
133
|
this.pushSample(sample);
|
|
136
|
-
test_utils_1.assert.isEqual(this.
|
|
137
|
-
test_utils_1.assert.isEqualDeep(this.
|
|
138
|
-
test_utils_1.assert.isEqualDeep(this.
|
|
139
|
-
info: this.
|
|
134
|
+
test_utils_1.assert.isEqual((_a = this.spyLiblsl.lastPushSampleOptions) === null || _a === void 0 ? void 0 : _a.outlet, this.spyLiblsl.outlet);
|
|
135
|
+
test_utils_1.assert.isEqualDeep((_b = this.spyLiblsl.lastPushSampleOptions) === null || _b === void 0 ? void 0 : _b.sample, sample);
|
|
136
|
+
test_utils_1.assert.isEqualDeep(this.spyLiblsl.lastCreateOutletOptions, {
|
|
137
|
+
info: this.spyLiblsl.streamInfo,
|
|
140
138
|
chunkSize: this.randomOutletOptions.chunkSize,
|
|
141
139
|
maxBuffered: this.randomOutletOptions.maxBuffered,
|
|
142
140
|
});
|
|
143
141
|
}
|
|
144
|
-
static async
|
|
142
|
+
static async constructionCreatesStreamInfo() {
|
|
145
143
|
this.Outlet();
|
|
146
144
|
const options = __rest(this.randomOutletOptions, []);
|
|
147
|
-
options.channelCount = options.
|
|
145
|
+
options.channelCount = options.channelNames.length;
|
|
148
146
|
delete options.manufacturer;
|
|
149
147
|
delete options.unit;
|
|
150
148
|
delete options.chunkSize;
|
|
151
149
|
delete options.maxBuffered;
|
|
152
|
-
delete options.
|
|
153
|
-
test_utils_1.assert.isEqualDeep(this.
|
|
150
|
+
delete options.channelNames;
|
|
151
|
+
test_utils_1.assert.isEqualDeep(this.spyLiblsl.lastCreateStreamInfoOptions, Object.assign(Object.assign({}, options), { channelFormat: this.channelIdx }));
|
|
154
152
|
}
|
|
155
|
-
static async
|
|
153
|
+
static async canOverrideClassInstantiatedInFactory() {
|
|
156
154
|
LslOutlet_1.default.Class = CheckingOutlet;
|
|
157
155
|
const instance = this.Outlet();
|
|
158
156
|
test_utils_1.assert.isInstanceOf(instance, CheckingOutlet);
|
|
@@ -160,9 +158,9 @@ class LslOutletTest extends test_utils_1.default {
|
|
|
160
158
|
static async appendsChannelsBasedOnCount(labels) {
|
|
161
159
|
const type = (0, test_utils_1.generateId)();
|
|
162
160
|
const unit = (0, test_utils_1.generateId)();
|
|
163
|
-
this.Outlet({
|
|
164
|
-
test_utils_1.assert.isEqualDeep(this.
|
|
165
|
-
info: this.
|
|
161
|
+
this.Outlet({ channelNames: labels, type, unit });
|
|
162
|
+
test_utils_1.assert.isEqualDeep(this.spyLiblsl.lastAppendChannelsToStreamInfoOptions, {
|
|
163
|
+
info: this.spyLiblsl.streamInfo,
|
|
166
164
|
channels: labels.map((label) => ({
|
|
167
165
|
label,
|
|
168
166
|
type,
|
|
@@ -170,6 +168,13 @@ class LslOutletTest extends test_utils_1.default {
|
|
|
170
168
|
})),
|
|
171
169
|
});
|
|
172
170
|
}
|
|
171
|
+
static async pushSampleShouldNotCreateMultipleOutlets() {
|
|
172
|
+
const outlet = this.Outlet();
|
|
173
|
+
outlet.pushSample([1]);
|
|
174
|
+
outlet.pushSample([2]);
|
|
175
|
+
outlet.pushSample([3]);
|
|
176
|
+
test_utils_1.assert.isEqual(this.spyLiblsl.createStreamInfoHitCount, 1);
|
|
177
|
+
}
|
|
173
178
|
static pushSample(sample) {
|
|
174
179
|
const outlet = this.Outlet();
|
|
175
180
|
outlet.pushSample(sample);
|
|
@@ -183,8 +188,8 @@ class LslOutletTest extends test_utils_1.default {
|
|
|
183
188
|
static assertThrowsInvalidSampleRate(sampleRate) {
|
|
184
189
|
this.assertDoesThrowInvalidParameters({ sampleRate }, ['sampleRate']);
|
|
185
190
|
}
|
|
186
|
-
static
|
|
187
|
-
this.assertDoesThrowInvalidParameters({
|
|
191
|
+
static assertThrowsInvalidChannelNames(count) {
|
|
192
|
+
this.assertDoesThrowInvalidParameters({ channelNames: new Array(count).fill((0, test_utils_1.generateId)()) }, ['channelNames']);
|
|
188
193
|
}
|
|
189
194
|
static assertDoesThrowInvalidParameters(options, parameters) {
|
|
190
195
|
const err = test_utils_1.assert.doesThrow(() => this.Outlet(options));
|
|
@@ -199,13 +204,10 @@ class LslOutletTest extends test_utils_1.default {
|
|
|
199
204
|
exports.default = LslOutletTest;
|
|
200
205
|
__decorate([
|
|
201
206
|
(0, test_utils_1.test)()
|
|
202
|
-
], LslOutletTest, "
|
|
207
|
+
], LslOutletTest, "throwsWhenMissingRequiredParams", null);
|
|
203
208
|
__decorate([
|
|
204
209
|
(0, test_utils_1.test)()
|
|
205
|
-
], LslOutletTest, "
|
|
206
|
-
__decorate([
|
|
207
|
-
(0, test_utils_1.test)()
|
|
208
|
-
], LslOutletTest, "throwsWithInvalidChannelCount", null);
|
|
210
|
+
], LslOutletTest, "throwsWithInvalidChannelNames", null);
|
|
209
211
|
__decorate([
|
|
210
212
|
(0, test_utils_1.test)()
|
|
211
213
|
], LslOutletTest, "throwsWithInvalidSampleRate", null);
|
|
@@ -214,49 +216,50 @@ __decorate([
|
|
|
214
216
|
], LslOutletTest, "throwsWithInvalidChannelFormat", null);
|
|
215
217
|
__decorate([
|
|
216
218
|
(0, test_utils_1.test)()
|
|
217
|
-
], LslOutletTest, "
|
|
219
|
+
], LslOutletTest, "throwsWithInvalidChunkSize", null);
|
|
218
220
|
__decorate([
|
|
219
221
|
(0, test_utils_1.test)()
|
|
220
|
-
], LslOutletTest, "
|
|
222
|
+
], LslOutletTest, "throwsWithInvalidMaxBuffered", null);
|
|
221
223
|
__decorate([
|
|
222
224
|
(0, test_utils_1.test)()
|
|
223
|
-
], LslOutletTest, "
|
|
225
|
+
], LslOutletTest, "supportsAllKnownChannelFormats", null);
|
|
224
226
|
__decorate([
|
|
225
|
-
(0, test_utils_1.test)('pushing sample sends to
|
|
226
|
-
(0, test_utils_1.test)('pushing sample sends to
|
|
227
|
-
], LslOutletTest, "
|
|
227
|
+
(0, test_utils_1.test)('pushing [1, 2] sample sends to LSL', [1, 2]),
|
|
228
|
+
(0, test_utils_1.test)('pushing [1] sample sends to LSL', [1])
|
|
229
|
+
], LslOutletTest, "canPushSampleToLsl", null);
|
|
228
230
|
__decorate([
|
|
229
231
|
(0, test_utils_1.test)()
|
|
230
|
-
], LslOutletTest, "
|
|
232
|
+
], LslOutletTest, "constructionCreatesStreamInfo", null);
|
|
231
233
|
__decorate([
|
|
232
234
|
(0, test_utils_1.test)()
|
|
233
|
-
], LslOutletTest, "
|
|
235
|
+
], LslOutletTest, "canOverrideClassInstantiatedInFactory", null);
|
|
234
236
|
__decorate([
|
|
235
|
-
(0, test_utils_1.test)('can add one label', [(0, test_utils_1.generateId)()]),
|
|
236
|
-
(0, test_utils_1.test)('can add two labels', [(0, test_utils_1.generateId)(), (0, test_utils_1.generateId)()])
|
|
237
|
+
(0, test_utils_1.test)('can add one label to channels', [(0, test_utils_1.generateId)()]),
|
|
238
|
+
(0, test_utils_1.test)('can add two labels to channels', [(0, test_utils_1.generateId)(), (0, test_utils_1.generateId)()])
|
|
237
239
|
], LslOutletTest, "appendsChannelsBasedOnCount", null);
|
|
240
|
+
__decorate([
|
|
241
|
+
(0, test_utils_1.test)()
|
|
242
|
+
], LslOutletTest, "pushSampleShouldNotCreateMultipleOutlets", null);
|
|
238
243
|
class SpyLiblsl {
|
|
239
244
|
constructor() {
|
|
240
245
|
this.outlet = {};
|
|
241
246
|
this.streamInfo = {};
|
|
247
|
+
this.createStreamInfoHitCount = 0;
|
|
242
248
|
}
|
|
243
249
|
createStreamInfo(options) {
|
|
244
|
-
this.
|
|
250
|
+
this.createStreamInfoHitCount++;
|
|
251
|
+
this.lastCreateStreamInfoOptions = options;
|
|
245
252
|
return this.streamInfo;
|
|
246
253
|
}
|
|
247
|
-
appendChannelsToStreamInfo(
|
|
248
|
-
this.
|
|
249
|
-
info,
|
|
250
|
-
channels,
|
|
251
|
-
};
|
|
254
|
+
appendChannelsToStreamInfo(options) {
|
|
255
|
+
this.lastAppendChannelsToStreamInfoOptions = options;
|
|
252
256
|
}
|
|
253
257
|
createOutlet(options) {
|
|
254
|
-
this.
|
|
258
|
+
this.lastCreateOutletOptions = options;
|
|
255
259
|
return this.outlet;
|
|
256
260
|
}
|
|
257
|
-
pushSample(
|
|
258
|
-
this.
|
|
259
|
-
this.lastPushedSample = sample;
|
|
261
|
+
pushSample(options) {
|
|
262
|
+
this.lastPushSampleOptions = options;
|
|
260
263
|
}
|
|
261
264
|
}
|
|
262
265
|
class CheckingOutlet extends LslOutlet_1.default {
|