@neurodevs/node-lsl 18.0.0 → 18.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/.vscode/launch.json +54 -58
  2. package/.vscode/settings.json +61 -66
  3. package/.vscode/tasks.json +98 -129
  4. package/README.md +14 -12
  5. package/build/__tests__/AbstractPackageTest.d.ts +4 -2
  6. package/build/__tests__/AbstractPackageTest.js +15 -6
  7. package/build/__tests__/AbstractPackageTest.js.map +1 -1
  8. package/build/__tests__/impl/BleDeviceController.test.d.ts +54 -0
  9. package/build/__tests__/impl/BleDeviceController.test.js +333 -0
  10. package/build/__tests__/impl/BleDeviceController.test.js.map +1 -0
  11. package/build/__tests__/impl/LslEventMarkerEmitter.test.js +1 -1
  12. package/build/__tests__/impl/LslEventMarkerEmitter.test.js.map +1 -1
  13. package/build/__tests__/impl/LslStreamInlet.test.js +2 -2
  14. package/build/__tests__/impl/LslStreamInlet.test.js.map +1 -1
  15. package/build/__tests__/impl/LslStreamOutlet.test.js +9 -9
  16. package/build/__tests__/impl/LslStreamOutlet.test.js.map +1 -1
  17. package/build/__tests__/impl/LslWebSocketBridge.test.js +3 -3
  18. package/build/__tests__/impl/LslWebSocketBridge.test.js.map +1 -1
  19. package/build/impl/LslStreamOutlet.d.ts +2 -2
  20. package/build/impl/LslStreamOutlet.js +2 -2
  21. package/build/impl/LslStreamOutlet.js.map +1 -1
  22. package/build/impl/LslWebSocketBridge.js +2 -2
  23. package/build/impl/LslWebSocketBridge.js.map +1 -1
  24. package/build/impl/controllers/BleDeviceController.d.ts +58 -0
  25. package/build/impl/controllers/BleDeviceController.js +145 -0
  26. package/build/impl/controllers/BleDeviceController.js.map +1 -0
  27. package/build/impl/workers/inlet/StreamInletWorker.d.ts +4 -4
  28. package/build/impl/workers/inlet/StreamInletWorker.js +12 -12
  29. package/build/impl/workers/inlet/StreamInletWorker.js.map +1 -1
  30. package/build/impl/workers/outlet/LslStreamOutlet.worker.d.ts +3 -3
  31. package/build/impl/workers/outlet/LslStreamOutlet.worker.js +7 -7
  32. package/build/impl/workers/outlet/LslStreamOutlet.worker.js.map +1 -1
  33. package/build/index.d.ts +6 -4
  34. package/build/index.js +7 -5
  35. package/build/index.js.map +1 -1
  36. package/build/scripts/discoverMuse.d.ts +1 -0
  37. package/build/scripts/discoverMuse.js +40 -0
  38. package/build/scripts/discoverMuse.js.map +1 -0
  39. package/build/scripts/runMuse.d.ts +1 -0
  40. package/build/scripts/runMuse.js +40 -0
  41. package/build/scripts/runMuse.js.map +1 -0
  42. package/build/testDoubles/BleController/FakeBleController.d.ts +24 -0
  43. package/build/testDoubles/BleController/FakeBleController.js +42 -0
  44. package/build/testDoubles/BleController/FakeBleController.js.map +1 -0
  45. package/build/testDoubles/BleController/SpyBleController.d.ts +14 -0
  46. package/build/testDoubles/BleController/SpyBleController.js +48 -0
  47. package/build/testDoubles/BleController/SpyBleController.js.map +1 -0
  48. package/build/testDoubles/StreamOutlet/FakeStreamOutlet.d.ts +2 -2
  49. package/build/testDoubles/StreamOutlet/FakeStreamOutlet.js +5 -2
  50. package/build/testDoubles/StreamOutlet/FakeStreamOutlet.js.map +1 -1
  51. package/build/testDoubles/generateRandomOutletOptions.js +1 -1
  52. package/build/testDoubles/generateRandomOutletOptions.js.map +1 -1
  53. package/eslint.config.js +3 -0
  54. package/package.json +18 -56
  55. package/prettier.config.js +3 -0
  56. package/src/__tests__/AbstractPackageTest.ts +28 -9
  57. package/src/__tests__/impl/BleDeviceController.test.ts +492 -0
  58. package/src/__tests__/impl/LslEventMarkerEmitter.test.ts +2 -1
  59. package/src/__tests__/impl/LslStreamInlet.test.ts +2 -2
  60. package/src/__tests__/impl/LslStreamOutlet.test.ts +10 -10
  61. package/src/__tests__/impl/LslWebSocketBridge.test.ts +4 -3
  62. package/src/impl/LslStreamOutlet.ts +3 -3
  63. package/src/impl/LslWebSocketBridge.ts +2 -2
  64. package/src/impl/controllers/BleDeviceController.ts +223 -0
  65. package/src/impl/workers/inlet/StreamInletWorker.ts +12 -12
  66. package/src/impl/workers/outlet/LslStreamOutlet.worker.ts +8 -8
  67. package/src/index.ts +8 -5
  68. package/src/scripts/discoverMuse.ts +50 -0
  69. package/src/scripts/runMuse.ts +50 -0
  70. package/src/testDoubles/BleController/FakeBleController.ts +70 -0
  71. package/src/testDoubles/BleController/SpyBleController.ts +61 -0
  72. package/src/testDoubles/StreamOutlet/FakeStreamOutlet.ts +6 -3
  73. package/src/testDoubles/generateRandomOutletOptions.ts +2 -1
  74. package/tsconfig.json +23 -27
  75. package/.regressionproof.json +0 -7
  76. package/build/.spruce/settings.json +0 -15
  77. package/build/__tests__/impl/LslBackpressureMonitor.test.d.ts +0 -7
  78. package/build/__tests__/impl/LslBackpressureMonitor.test.js +0 -26
  79. package/build/__tests__/impl/LslBackpressureMonitor.test.js.map +0 -1
  80. package/build/impl/LslBackpressureMonitor.d.ts +0 -8
  81. package/build/impl/LslBackpressureMonitor.js +0 -8
  82. package/build/impl/LslBackpressureMonitor.js.map +0 -1
  83. package/build/testDoubles/BackpressureMonitor/FakeBackpressureMonitor.d.ts +0 -6
  84. package/build/testDoubles/BackpressureMonitor/FakeBackpressureMonitor.js +0 -10
  85. package/build/testDoubles/BackpressureMonitor/FakeBackpressureMonitor.js.map +0 -1
  86. package/eslint.config.mjs +0 -3
  87. package/src/.spruce/settings.json +0 -15
  88. package/src/__tests__/impl/LslBackpressureMonitor.test.ts +0 -25
  89. package/src/impl/LslBackpressureMonitor.ts +0 -13
  90. package/src/testDoubles/BackpressureMonitor/FakeBackpressureMonitor.ts +0 -13
@@ -0,0 +1,492 @@
1
+ import { randomInt } from 'node:crypto'
2
+
3
+ import { test, assert } from '@neurodevs/node-tdd'
4
+ import { FakeLibndx, NativePeripheral } from '@neurodevs/ndx-native'
5
+
6
+ import SpyBleController from '../../testDoubles/BleController/SpyBleController.js'
7
+ import AbstractPackageTest from '../AbstractPackageTest.js'
8
+ import BleDeviceController, {
9
+ BleControllerOptions,
10
+ } from '../../impl/controllers/BleDeviceController.js'
11
+
12
+ export default class BleDeviceControllerTest extends AbstractPackageTest {
13
+ private static instance: SpyBleController
14
+
15
+ private static readonly uuid = this.generateId()
16
+ private static readonly namePrefix = this.generateId()
17
+ private static readonly discoveredUuid = this.generateId()
18
+ private static readonly charUuid = this.generateId()
19
+ private static readonly charValueToWrite = this.generateId()
20
+ private static readonly rssiIntervalMs = randomInt(1, 5)
21
+ private static readonly fakeError = this.generateId()
22
+ private static readonly fake400Error = `400 error: ${this.fakeError}`
23
+ private static readonly fake500Error = `500 error: ${this.fakeError}`
24
+
25
+ private static readonly charCallbacks = [
26
+ {
27
+ charUuid: this.generateId(),
28
+ charName: this.generateId(),
29
+ onData: async () => {},
30
+ },
31
+ {
32
+ charUuid: this.generateId(),
33
+ charName: this.generateId(),
34
+ onData: async () => {},
35
+ },
36
+ ]
37
+
38
+ private static onConnected = (_peripheral: NativePeripheral) => {
39
+ this.wasConnected = true
40
+ }
41
+
42
+ private static wasConnected: boolean
43
+
44
+ private static nativePeripheral: NativePeripheral = {
45
+ uuid: this.generateId(),
46
+ name: this.generateId(),
47
+ }
48
+
49
+ protected static async beforeAll() {
50
+ assert.isEqual(
51
+ BleDeviceController.waitAfterMs,
52
+ 1000,
53
+ 'Set incorrect waitAfterMs!'
54
+ )
55
+ }
56
+
57
+ protected static async beforeEach() {
58
+ await super.beforeEach()
59
+
60
+ BleDeviceController.waitAfterMs = 0
61
+
62
+ this.setFakeLibndx()
63
+ BleDeviceController.Class = SpyBleController
64
+
65
+ this.wasConnected = false
66
+
67
+ this.instance = await this.BleController()
68
+ }
69
+
70
+ @test()
71
+ protected static async createsInstance() {
72
+ assert.isTruthy(this.instance, 'Failed to create instance!')
73
+ }
74
+
75
+ @test()
76
+ protected static async connectCallsLibndxCreateBleBackend() {
77
+ await this.connect()
78
+
79
+ assert.isEqualDeep(
80
+ FakeLibndx.callsToCreateBleBackend[0],
81
+ {
82
+ deviceUuid: this.uuid,
83
+ },
84
+ 'Did not call createBleBackend!'
85
+ )
86
+ }
87
+
88
+ @test()
89
+ protected static async discoversUuidWhenDeviceUuidNotProvided() {
90
+ const instance = await this.BleControllerWithPrefix()
91
+
92
+ await this.connectWithDiscovery(instance)
93
+
94
+ const call = FakeLibndx.callsToDiscoverBleUuid[0]
95
+
96
+ assert.isEqual(
97
+ call?.namePrefix,
98
+ this.namePrefix,
99
+ 'Did not call discoverBleUuid with deviceNamePrefix!'
100
+ )
101
+
102
+ assert.isFunction(
103
+ call?.onDiscovered,
104
+ 'Did not pass an onDiscovered callback to discoverBleUuid!'
105
+ )
106
+ }
107
+
108
+ @test()
109
+ protected static async doesNotDiscoverUuidWhenDeviceUuidProvided() {
110
+ await this.connect()
111
+
112
+ assert.isEqual(
113
+ FakeLibndx.callsToDiscoverBleUuid.length,
114
+ 0,
115
+ 'Should not call discoverBleUuid when deviceUuid is provided!'
116
+ )
117
+ }
118
+
119
+ @test()
120
+ protected static async usesDiscoveredUuidToCreateBleBackend() {
121
+ const instance = await this.BleControllerWithPrefix()
122
+
123
+ await this.connectWithDiscovery(instance)
124
+
125
+ assert.isEqualDeep(
126
+ FakeLibndx.callsToCreateBleBackend[0],
127
+ {
128
+ deviceUuid: this.discoveredUuid,
129
+ },
130
+ 'Did not create BLE backend with the discovered uuid!'
131
+ )
132
+ }
133
+
134
+ @test()
135
+ protected static async usesDiscoveredUuidToStartBleBackend() {
136
+ const instance = await this.BleControllerWithPrefix()
137
+
138
+ await this.connectWithDiscovery(instance)
139
+
140
+ assert.isEqual(
141
+ FakeLibndx.callsToStartBleBackend[0]?.deviceUuid,
142
+ this.discoveredUuid,
143
+ 'Did not start BLE backend with the discovered uuid!'
144
+ )
145
+ }
146
+
147
+ @test()
148
+ protected static async exposesDiscoveredUuid() {
149
+ const instance = await this.BleControllerWithPrefix()
150
+
151
+ await this.connectWithDiscovery(instance)
152
+
153
+ assert.isEqual(
154
+ instance.uuid,
155
+ this.discoveredUuid,
156
+ 'Did not expose the discovered uuid!'
157
+ )
158
+ }
159
+
160
+ @test()
161
+ protected static async createBleBackendThrowsOn400() {
162
+ this.setFake400Error()
163
+
164
+ await assert.doesThrowAsync(
165
+ async () => await this.instance.connect(),
166
+ this.fake400Error,
167
+ 'Did not throw error!'
168
+ )
169
+ }
170
+
171
+ @test()
172
+ protected static async createBleBackendThrowsOn500() {
173
+ this.setFake500Error()
174
+
175
+ await assert.doesThrowAsync(
176
+ async () => await this.instance.connect(),
177
+ this.fake500Error,
178
+ 'Did not throw error!'
179
+ )
180
+ }
181
+
182
+ @test()
183
+ protected static async connectCallsLibndxStartBleBackend() {
184
+ await this.connect()
185
+
186
+ const call = FakeLibndx.callsToStartBleBackend[0]
187
+
188
+ assert.isEqual(
189
+ call.deviceUuid,
190
+ this.uuid,
191
+ 'Did not call startBleBackend with correct deviceUuid!'
192
+ )
193
+
194
+ assert.isEqual(
195
+ call.charCallbacks.length,
196
+ 2,
197
+ 'Did not call startBleBackend with charCallbacks!'
198
+ )
199
+
200
+ let i = 0
201
+ for (const charCallback of call.charCallbacks) {
202
+ assert.isEqual(
203
+ charCallback.charUuid,
204
+ this.charCallbacks[i].charUuid,
205
+ 'Incorrect charUuid!'
206
+ )
207
+
208
+ assert.isEqual(
209
+ charCallback.charName,
210
+ this.charCallbacks[i].charName,
211
+ 'Incorrect charName!'
212
+ )
213
+
214
+ assert.isFunction(
215
+ charCallback.onData,
216
+ 'Callback is not a function!'
217
+ )
218
+ i++
219
+ }
220
+ }
221
+
222
+ @test()
223
+ protected static async startBleBackendThrowsOn400() {
224
+ //@ts-ignore
225
+ this.instance.createBleBackend = () => {}
226
+
227
+ this.setFake400Error()
228
+
229
+ await assert.doesThrowAsync(
230
+ async () => await this.instance.connect(),
231
+ this.fake400Error,
232
+ 'Did not throw error!'
233
+ )
234
+ }
235
+
236
+ @test()
237
+ protected static async startBleBackendThrowsOn500() {
238
+ //@ts-ignore
239
+ this.instance.createBleBackend = () => {}
240
+
241
+ this.setFake500Error()
242
+
243
+ await assert.doesThrowAsync(
244
+ async () => await this.instance.connect(),
245
+ this.fake500Error,
246
+ 'Did not throw error!'
247
+ )
248
+ }
249
+
250
+ @test()
251
+ protected static async connectWaitsForOnConnectedEvent() {
252
+ await this.connect()
253
+
254
+ assert.isTruthy(
255
+ this.wasConnected,
256
+ 'Did not wait for onConnected event!'
257
+ )
258
+ }
259
+
260
+ @test()
261
+ protected static async waitsAfterOnConnectedToDiscoverServices() {
262
+ const waitAfterMs = 20
263
+ BleDeviceController.waitAfterMs = waitAfterMs
264
+
265
+ const t0 = Date.now()
266
+ await this.connect()
267
+ const t1 = Date.now()
268
+
269
+ assert.isAbove(
270
+ t1 - t0,
271
+ 100 + waitAfterMs * 0.8,
272
+ 'Did not wait after on connected!'
273
+ )
274
+ }
275
+
276
+ @test()
277
+ protected static async writeCharacteristicCallsLibndxBinding() {
278
+ await this.writeCharacteristic()
279
+
280
+ assert.isEqualDeep(
281
+ FakeLibndx.callsToWriteBleCharacteristic[0],
282
+ {
283
+ deviceUuid: this.uuid,
284
+ charUuid: this.charUuid,
285
+ value: this.charValueToWrite,
286
+ },
287
+ 'Did not call writeBleCharacteristic as expected!'
288
+ )
289
+ }
290
+
291
+ @test()
292
+ protected static async writeCharacteristicThrowsOn400() {
293
+ this.setFake400Error()
294
+
295
+ await assert.doesThrowAsync(
296
+ async () => await this.writeCharacteristic(),
297
+ this.fake400Error,
298
+ 'Did not throw error!'
299
+ )
300
+ }
301
+
302
+ @test()
303
+ protected static async writeCharacteristicThrowsOn500() {
304
+ this.setFake500Error()
305
+
306
+ await assert.doesThrowAsync(
307
+ async () => await this.writeCharacteristic(),
308
+ this.fake500Error,
309
+ 'Did not throw error!'
310
+ )
311
+ }
312
+
313
+ @test()
314
+ protected static async callsSetBleRssiInterval() {
315
+ await this.connect()
316
+
317
+ const { deviceUuid, intervalMs } =
318
+ FakeLibndx.callsToSetBleRssiInterval[0]
319
+
320
+ assert.isEqualDeep(
321
+ { deviceUuid, intervalMs },
322
+ {
323
+ deviceUuid: this.uuid,
324
+ intervalMs: this.rssiIntervalMs,
325
+ },
326
+ 'Did not call setBleRssiInterval as expected!'
327
+ )
328
+ }
329
+
330
+ @test()
331
+ protected static async disconnectCallsLibndxStopBleBackend() {
332
+ await this.disconnect()
333
+
334
+ assert.isEqualDeep(
335
+ FakeLibndx.callsToStopBleBackend[0],
336
+ {
337
+ deviceUuid: this.uuid,
338
+ },
339
+ 'Did not call stopBleBackend!'
340
+ )
341
+ }
342
+
343
+ @test()
344
+ protected static async disconnectThrowsOn400() {
345
+ this.setFake400Error()
346
+
347
+ await assert.doesThrowAsync(
348
+ async () => await this.disconnect(),
349
+ this.fake400Error,
350
+ 'Did not throw error!'
351
+ )
352
+ }
353
+
354
+ @test()
355
+ protected static async disconnectThrowsOn500() {
356
+ this.setFake500Error()
357
+
358
+ await assert.doesThrowAsync(
359
+ async () => await this.disconnect(),
360
+ this.fake500Error,
361
+ 'Did not throw error!'
362
+ )
363
+ }
364
+
365
+ @test()
366
+ protected static async disconnectResetsConnectedFlag() {
367
+ await this.connect()
368
+ await this.disconnect()
369
+
370
+ assert.isFalse(
371
+ this.instance.getConnected(),
372
+ 'Did not reset connected flag on disconnect!'
373
+ )
374
+ }
375
+
376
+ @test()
377
+ protected static async exposesPeriperalName() {
378
+ await this.connect()
379
+
380
+ assert.isEqual(
381
+ this.instance.name,
382
+ this.nativePeripheral.name,
383
+ 'Did not set peripheral name!'
384
+ )
385
+ }
386
+
387
+ @test()
388
+ protected static async returnsNAIfNameNotAvailable() {
389
+ assert.isEqual(
390
+ this.instance.name,
391
+ 'N/A',
392
+ 'Did not set default name to N/A!'
393
+ )
394
+ }
395
+
396
+ @test()
397
+ protected static async throwsWithUnknownErrorIfNoError() {
398
+ this.setFake500ErrorWithoutError()
399
+
400
+ await assert.doesThrowAsync(
401
+ async () => await this.connect(),
402
+ 'Unknown error',
403
+ 'Did not throw error!'
404
+ )
405
+ }
406
+
407
+ private static async connect() {
408
+ const promise = this.instance.connect()
409
+
410
+ const startCall = FakeLibndx.callsToStartBleBackend[0]
411
+ startCall?.onConnected(this.nativePeripheral)
412
+
413
+ await promise
414
+ }
415
+
416
+ private static async connectWithDiscovery(instance: SpyBleController) {
417
+ const promise = instance.connect()
418
+
419
+ FakeLibndx.callsToDiscoverBleUuid[0]?.onDiscovered(this.discoveredUuid)
420
+
421
+ await this.waitForCall(() => FakeLibndx.callsToStartBleBackend[0])
422
+
423
+ FakeLibndx.callsToStartBleBackend[0]?.onConnected(this.nativePeripheral)
424
+
425
+ await promise
426
+ }
427
+
428
+ private static async waitForCall<T>(getCall: () => T) {
429
+ await new Promise<void>((resolve) => {
430
+ const check = () => {
431
+ if (getCall()) {
432
+ resolve()
433
+ } else {
434
+ setTimeout(check, 10)
435
+ }
436
+ }
437
+ check()
438
+ })
439
+ }
440
+
441
+ private static async writeCharacteristic() {
442
+ await this.instance.writeCharacteristic(
443
+ this.charUuid,
444
+ this.charValueToWrite
445
+ )
446
+ }
447
+
448
+ private static async disconnect() {
449
+ await this.instance.disconnect()
450
+ }
451
+
452
+ private static setFake400Error() {
453
+ FakeLibndx.fakeResult = {
454
+ status: 400,
455
+ error: this.fakeError,
456
+ }
457
+ }
458
+
459
+ private static setFake500Error() {
460
+ FakeLibndx.fakeResult = {
461
+ status: 500,
462
+ error: this.fakeError,
463
+ }
464
+ }
465
+
466
+ private static setFake500ErrorWithoutError() {
467
+ FakeLibndx.fakeResult = {
468
+ status: 500,
469
+ }
470
+ }
471
+
472
+ private static async BleController(
473
+ options?: Partial<BleControllerOptions>
474
+ ) {
475
+ return (await BleDeviceController.Create({
476
+ deviceUuid: this.uuid,
477
+ charCallbacks: this.charCallbacks,
478
+ onConnected: this.onConnected,
479
+ rssiIntervalMs: this.rssiIntervalMs,
480
+ ...options,
481
+ })) as SpyBleController
482
+ }
483
+
484
+ private static async BleControllerWithPrefix() {
485
+ return (await BleDeviceController.Create({
486
+ deviceNamePrefix: this.namePrefix,
487
+ charCallbacks: this.charCallbacks,
488
+ onConnected: this.onConnected,
489
+ rssiIntervalMs: this.rssiIntervalMs,
490
+ } as unknown as BleControllerOptions)) as SpyBleController
491
+ }
492
+ }
@@ -1,4 +1,5 @@
1
- import { randomInt } from 'crypto'
1
+ import { randomInt } from 'node:crypto'
2
+
2
3
  import { assert, test } from '@neurodevs/node-tdd'
3
4
 
4
5
  import LslEventMarkerEmitter, {
@@ -386,7 +386,7 @@ export default class LslStreamInletTest extends AbstractPackageTest {
386
386
  protected static async pushSampleHandlesErrorCode() {
387
387
  let passedErrorCode: number | undefined
388
388
 
389
- StreamInletWorker.handleError = (errorCode: number) => {
389
+ StreamInletWorker.handleLslError = (errorCode: number) => {
390
390
  passedErrorCode = errorCode
391
391
  }
392
392
 
@@ -400,7 +400,7 @@ export default class LslStreamInletTest extends AbstractPackageTest {
400
400
  assert.isEqualDeep(
401
401
  passedErrorCode,
402
402
  FakeLiblsl.fakeErrorCode,
403
- 'Did not pass the expected error code to handleError!'
403
+ 'Did not pass the expected error code to handleLslError!'
404
404
  )
405
405
  }
406
406
 
@@ -7,7 +7,7 @@ import LslStreamOutlet, {
7
7
  StreamOutletOptions,
8
8
  } from '../../impl/LslStreamOutlet.js'
9
9
  import {
10
- setOutletHandleError,
10
+ setOutletHandleLslError,
11
11
  setOutletLiblslAdapter,
12
12
  } from '../../impl/workers/outlet/LslStreamOutlet.worker.js'
13
13
  import {
@@ -128,7 +128,7 @@ export default class LslStreamOutletTest extends AbstractPackageTest {
128
128
  maxBufferedMs: this.randomOutletOptions.maxBufferedMs,
129
129
  })
130
130
  assert.isNumber(
131
- this.fakeLiblsl.lastPushSampleFloatTimestampOptions?.timestamp
131
+ this.fakeLiblsl.lastPushSampleFloatTimestampOptions?.timestampSec
132
132
  )
133
133
  }
134
134
 
@@ -148,7 +148,7 @@ export default class LslStreamOutletTest extends AbstractPackageTest {
148
148
  sample
149
149
  )
150
150
  assert.isNumber(
151
- this.fakeLiblsl.lastPushSampleStringTimestampOptions?.timestamp
151
+ this.fakeLiblsl.lastPushSampleStringTimestampOptions?.timestampSec
152
152
  )
153
153
  }
154
154
 
@@ -159,13 +159,13 @@ export default class LslStreamOutletTest extends AbstractPackageTest {
159
159
 
160
160
  outlet.pushSample(sample)
161
161
  const t1 =
162
- this.fakeLiblsl.lastPushSampleStringTimestampOptions?.timestamp
162
+ this.fakeLiblsl.lastPushSampleStringTimestampOptions?.timestampSec
163
163
 
164
164
  await this.wait(10)
165
165
 
166
166
  outlet.pushSample(sample)
167
167
  const t2 =
168
- this.fakeLiblsl.lastPushSampleStringTimestampOptions?.timestamp
168
+ this.fakeLiblsl.lastPushSampleStringTimestampOptions?.timestampSec
169
169
 
170
170
  assert.isNotEqual(t1, t2)
171
171
  assert.isEqual(this.fakeLiblsl.localClockHitCount, 2)
@@ -227,13 +227,13 @@ export default class LslStreamOutletTest extends AbstractPackageTest {
227
227
  @test()
228
228
  protected static async pushSampleAcceptsOptionalPreciseTimestamp() {
229
229
  const outlet = await this.FloatOutlet()
230
- const fakeTimestamp = Math.random() * 1000
230
+ const timestampSec = Math.random() * 10000
231
231
 
232
- outlet.pushSample([1.0], fakeTimestamp)
232
+ outlet.pushSample([1.0], timestampSec)
233
233
 
234
234
  assert.isEqual(
235
- this.fakeLiblsl.lastPushSampleFloatTimestampOptions?.timestamp,
236
- fakeTimestamp
235
+ this.fakeLiblsl.lastPushSampleFloatTimestampOptions?.timestampSec,
236
+ timestampSec
237
237
  )
238
238
  }
239
239
 
@@ -241,7 +241,7 @@ export default class LslStreamOutletTest extends AbstractPackageTest {
241
241
  protected static async pushSampleHandlesErrorCode() {
242
242
  let passedErrorCode: number | undefined
243
243
 
244
- setOutletHandleError((errorCode: number) => {
244
+ setOutletHandleLslError((errorCode: number) => {
245
245
  passedErrorCode = errorCode
246
246
  })
247
247
 
@@ -1,4 +1,5 @@
1
- import { randomInt } from 'crypto'
1
+ import { randomInt } from 'node:crypto'
2
+
2
3
  import { test, assert } from '@neurodevs/node-tdd'
3
4
 
4
5
  import { StreamInletOptions } from '../../impl/LslStreamInlet.js'
@@ -152,7 +153,7 @@ export default class LslWebSocketBridgeTest extends AbstractPackageTest {
152
153
 
153
154
  await assert.doesThrowAsync(async () => {
154
155
  await this.activate()
155
- }, `\n\n Cannot activate bridge after destroying it! \n\n Please create and activate a new instance. \n`)
156
+ }, `\n\nCannot activate bridge after destroying it! \n\nPlease create and activate a new instance. \n`)
156
157
  }
157
158
 
158
159
  @test()
@@ -161,7 +162,7 @@ export default class LslWebSocketBridgeTest extends AbstractPackageTest {
161
162
 
162
163
  assert.doesThrow(() => {
163
164
  this.deactivate()
164
- }, `\n\n Cannot deactivate bridge after destroying it! \n\n Please create and activate a new instance. \n`)
165
+ }, `\n\nCannot deactivate bridge after destroying it! \n\nPlease create and activate a new instance. \n`)
165
166
  }
166
167
 
167
168
  @test()
@@ -131,12 +131,12 @@ export default class LslStreamOutlet implements StreamOutlet {
131
131
  string: 'pushSampleStringTimestamp',
132
132
  }
133
133
 
134
- public pushSample(sample: LslSample, timestamp?: number) {
134
+ public pushSample(sample: LslSample, timestampSec?: number) {
135
135
  this.worker.postMessage({
136
136
  type: 'pushSample',
137
137
  payload: {
138
138
  sample,
139
- timestamp,
139
+ timestampSec,
140
140
  },
141
141
  })
142
142
  }
@@ -159,7 +159,7 @@ export default class LslStreamOutlet implements StreamOutlet {
159
159
  }
160
160
 
161
161
  export interface StreamOutlet {
162
- pushSample(sample: LslSample, timestamp?: number): void
162
+ pushSample(sample: LslSample, timestampSec?: number): void
163
163
  destroy(): void
164
164
  readonly name: string
165
165
  readonly type: string
@@ -66,7 +66,7 @@ export default class LslWebSocketBridge implements WebSocketBridge {
66
66
  }
67
67
  }
68
68
 
69
- private readonly cannotActivateMessage = `\n\n Cannot activate bridge after destroying it! \n\n Please create and activate a new instance. \n`
69
+ private readonly cannotActivateMessage = `\n\nCannot activate bridge after destroying it! \n\nPlease create and activate a new instance. \n`
70
70
 
71
71
  private async startPullingData() {
72
72
  await this.inlet.startPulling()
@@ -77,7 +77,7 @@ export default class LslWebSocketBridge implements WebSocketBridge {
77
77
  this.stopPullingData()
78
78
  }
79
79
 
80
- private readonly cannotDeactivateMessage = `\n\n Cannot deactivate bridge after destroying it! \n\n Please create and activate a new instance. \n`
80
+ private readonly cannotDeactivateMessage = `\n\nCannot deactivate bridge after destroying it! \n\nPlease create and activate a new instance. \n`
81
81
 
82
82
  private stopPullingData() {
83
83
  this.inlet.stopPulling()