@neurodevs/node-lsl 11.4.0 → 11.4.2

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 (81) hide show
  1. package/README.md +40 -29
  2. package/build/.spruce/settings.json +1 -3
  3. package/build/__tests__/AbstractLslTest.d.ts +1 -0
  4. package/build/__tests__/AbstractLslTest.js +1 -0
  5. package/build/__tests__/AbstractLslTest.js.map +1 -1
  6. package/build/__tests__/modules/LiblslAdapter.test.d.ts +1 -5
  7. package/build/__tests__/modules/LiblslAdapter.test.js +5 -61
  8. package/build/__tests__/modules/LiblslAdapter.test.js.map +1 -1
  9. package/build/__tests__/modules/LslStreamInfo.test.d.ts +0 -1
  10. package/build/__tests__/modules/LslStreamInfo.test.js +0 -11
  11. package/build/__tests__/modules/LslStreamInfo.test.js.map +1 -1
  12. package/build/__tests__/modules/LslStreamInlet.test.d.ts +0 -1
  13. package/build/__tests__/modules/LslStreamInlet.test.js +0 -17
  14. package/build/__tests__/modules/LslStreamInlet.test.js.map +1 -1
  15. package/build/__tests__/modules/LslStreamOutlet.test.d.ts +7 -5
  16. package/build/__tests__/modules/LslStreamOutlet.test.js +34 -52
  17. package/build/__tests__/modules/LslStreamOutlet.test.js.map +1 -1
  18. package/build/assertions.d.ts +1 -1
  19. package/build/assertions.js +10 -31
  20. package/build/assertions.js.map +1 -1
  21. package/build/modules/LiblslAdapter.d.ts +3 -1
  22. package/build/modules/LiblslAdapter.js +15 -44
  23. package/build/modules/LiblslAdapter.js.map +1 -1
  24. package/build/modules/LslStreamInfo.js +0 -2
  25. package/build/modules/LslStreamInfo.js.map +1 -1
  26. package/build/modules/LslStreamInlet.js +2 -10
  27. package/build/modules/LslStreamInlet.js.map +1 -1
  28. package/build/modules/LslStreamOutlet.js +0 -13
  29. package/build/modules/LslStreamOutlet.js.map +1 -1
  30. package/build/scripts/demoMarkerOutlet.d.ts +1 -0
  31. package/build/scripts/demoMarkerOutlet.js +23 -0
  32. package/build/scripts/demoMarkerOutlet.js.map +1 -0
  33. package/build/scripts/demoStreamOutlet.d.ts +1 -0
  34. package/build/scripts/demoStreamOutlet.js +25 -0
  35. package/build/scripts/demoStreamOutlet.js.map +1 -0
  36. package/build/testDoubles/LslOutlet/FakeLslOutlet.d.ts +4 -4
  37. package/build/testDoubles/LslOutlet/FakeLslOutlet.js +12 -10
  38. package/build/testDoubles/LslOutlet/FakeLslOutlet.js.map +1 -1
  39. package/package.json +8 -12
  40. package/src/.spruce/settings.json +1 -3
  41. package/src/__tests__/AbstractLslTest.ts +1 -0
  42. package/src/__tests__/modules/LiblslAdapter.test.ts +12 -58
  43. package/src/__tests__/modules/LslStreamInfo.test.ts +1 -12
  44. package/src/__tests__/modules/LslStreamInlet.test.ts +1 -18
  45. package/src/__tests__/modules/LslStreamOutlet.test.ts +56 -55
  46. package/src/assertions.ts +19 -30
  47. package/src/modules/LiblslAdapter.ts +18 -44
  48. package/src/modules/LslStreamInfo.ts +0 -2
  49. package/src/modules/LslStreamInlet.ts +2 -10
  50. package/src/modules/LslStreamOutlet.ts +0 -14
  51. package/src/scripts/demoMarkerOutlet.ts +23 -0
  52. package/src/scripts/demoStreamOutlet.ts +22 -0
  53. package/src/testDoubles/LslOutlet/FakeLslOutlet.ts +16 -14
  54. package/build/.spruce/errors/errors.types.d.ts +0 -21
  55. package/build/.spruce/errors/errors.types.js +0 -3
  56. package/build/.spruce/errors/errors.types.js.map +0 -1
  57. package/build/.spruce/errors/nodeLsl/failedToLoadLiblsl.schema.d.ts +0 -3
  58. package/build/.spruce/errors/nodeLsl/failedToLoadLiblsl.schema.js +0 -19
  59. package/build/.spruce/errors/nodeLsl/failedToLoadLiblsl.schema.js.map +0 -1
  60. package/build/.spruce/errors/options.types.d.ts +0 -7
  61. package/build/.spruce/errors/options.types.js +0 -3
  62. package/build/.spruce/errors/options.types.js.map +0 -1
  63. package/build/.spruce/schemas/fields/fieldClassMap.d.ts +0 -2
  64. package/build/.spruce/schemas/fields/fieldClassMap.js +0 -5
  65. package/build/.spruce/schemas/fields/fieldClassMap.js.map +0 -1
  66. package/build/.spruce/schemas/fields/fields.types.d.ts +0 -1
  67. package/build/.spruce/schemas/fields/fields.types.js +0 -3
  68. package/build/.spruce/schemas/fields/fields.types.js.map +0 -1
  69. package/build/errors/SpruceError.d.ts +0 -6
  70. package/build/errors/SpruceError.js +0 -26
  71. package/build/errors/SpruceError.js.map +0 -1
  72. package/build/errors/failedToLoadLiblsl.builder.d.ts +0 -11
  73. package/build/errors/failedToLoadLiblsl.builder.js +0 -14
  74. package/build/errors/failedToLoadLiblsl.builder.js.map +0 -1
  75. package/src/.spruce/errors/errors.types.ts +0 -37
  76. package/src/.spruce/errors/nodeLsl/failedToLoadLiblsl.schema.ts +0 -22
  77. package/src/.spruce/errors/options.types.ts +0 -10
  78. package/src/.spruce/schemas/fields/fieldClassMap.ts +0 -6
  79. package/src/.spruce/schemas/fields/fields.types.ts +0 -1
  80. package/src/errors/SpruceError.ts +0 -23
  81. package/src/errors/failedToLoadLiblsl.builder.ts +0 -12
@@ -1,3 +1,5 @@
1
+ import { randomInt } from 'crypto'
2
+ import { generateId } from '@sprucelabs/test-utils'
1
3
  import { StreamInfo } from '../../modules/LslStreamInfo'
2
4
  import { LslOutlet, LslOutletOptions } from '../../modules/LslStreamOutlet'
3
5
  import { LslSample } from '../../types'
@@ -7,9 +9,9 @@ export default class FakeLslOutlet implements LslOutlet {
7
9
  public static callsToPushSample: LslSample[] = []
8
10
  public static numCallsToDestroy = 0
9
11
 
10
- public options: LslOutletOptions
12
+ public options?: LslOutletOptions
11
13
 
12
- public constructor(info: StreamInfo, options: LslOutletOptions) {
14
+ public constructor(info?: StreamInfo, options?: LslOutletOptions) {
13
15
  FakeLslOutlet.callsToConstructor.push({ info, options })
14
16
  this.options = options
15
17
  }
@@ -23,19 +25,19 @@ export default class FakeLslOutlet implements LslOutlet {
23
25
  }
24
26
 
25
27
  public get name() {
26
- return this.options.name
28
+ return this.options?.name ?? generateId()
27
29
  }
28
30
 
29
31
  public get type() {
30
- return this.options.type
32
+ return this.options?.type ?? generateId()
31
33
  }
32
34
 
33
35
  public get sourceId() {
34
- return this.options.sourceId
36
+ return this.options?.sourceId ?? generateId()
35
37
  }
36
38
 
37
39
  public get channelNames() {
38
- return this.options.channelNames
40
+ return this.options?.channelNames ?? [generateId()]
39
41
  }
40
42
 
41
43
  public get channelCount() {
@@ -43,27 +45,27 @@ export default class FakeLslOutlet implements LslOutlet {
43
45
  }
44
46
 
45
47
  public get channelFormat() {
46
- return this.options.channelFormat
48
+ return this.options?.channelFormat ?? 'float32'
47
49
  }
48
50
 
49
51
  public get sampleRate() {
50
- return this.options.sampleRate
52
+ return this.options?.sampleRate ?? randomInt(1, 1000)
51
53
  }
52
54
 
53
55
  public get chunkSize() {
54
- return this.options.chunkSize
56
+ return this.options?.chunkSize ?? randomInt(1, 1000)
55
57
  }
56
58
 
57
59
  public get maxBuffered() {
58
- return this.options.maxBuffered
60
+ return this.options?.maxBuffered ?? randomInt(1, 1000)
59
61
  }
60
62
 
61
63
  public get manufacturer() {
62
- return this.options.manufacturer
64
+ return this.options?.manufacturer ?? generateId()
63
65
  }
64
66
 
65
67
  public get unit() {
66
- return this.options.unit
68
+ return this.options?.unit ?? generateId()
67
69
  }
68
70
 
69
71
  public static resetTestDouble() {
@@ -74,6 +76,6 @@ export default class FakeLslOutlet implements LslOutlet {
74
76
  }
75
77
 
76
78
  export interface CallToOutletConstructor {
77
- info: StreamInfo
78
- options: LslOutletOptions
79
+ info?: StreamInfo
80
+ options?: LslOutletOptions
79
81
  }
@@ -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,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=errors.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.types.js","sourceRoot":"","sources":["../../../src/.spruce/errors/errors.types.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- import { SpruceErrors } from '../errors.types';
2
- declare const failedToLoadLiblslSchema: SpruceErrors.NodeLsl.FailedToLoadLiblslSchema;
3
- export default failedToLoadLiblslSchema;
@@ -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,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=options.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"options.types.js","sourceRoot":"","sources":["../../../src/.spruce/errors/options.types.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- import { fieldClassMap } from '@sprucelabs/schema';
2
- export default fieldClassMap;
@@ -1,5 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const schema_1 = require("@sprucelabs/schema");
4
- exports.default = schema_1.fieldClassMap;
5
- //# sourceMappingURL=fieldClassMap.js.map
@@ -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,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=fields.types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fields.types.js","sourceRoot":"","sources":["../../../../src/.spruce/schemas/fields/fields.types.ts"],"names":[],"mappings":""}
@@ -1,6 +0,0 @@
1
- import BaseSpruceError from '@sprucelabs/error';
2
- import ErrorOptions from './../.spruce/errors/options.types';
3
- export default class SpruceError extends BaseSpruceError<ErrorOptions> {
4
- /** an easy to understand version of the errors */
5
- friendlyMessage(): string;
6
- }
@@ -1,26 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const error_1 = __importDefault(require("@sprucelabs/error"));
7
- class SpruceError extends error_1.default {
8
- /** an easy to understand version of the errors */
9
- friendlyMessage() {
10
- const { options } = this;
11
- let message;
12
- switch (options?.code) {
13
- case 'FAILED_TO_LOAD_LIBLSL':
14
- message = `Well shoot! Loading the liblsl dylib failed. I tried to load it from ${options.liblslPath}. Original error:\n\n${options.originalError}`;
15
- break;
16
- default:
17
- message = super.friendlyMessage();
18
- }
19
- const fullMessage = options.friendlyMessage
20
- ? options.friendlyMessage
21
- : message;
22
- return fullMessage;
23
- }
24
- }
25
- exports.default = SpruceError;
26
- //# sourceMappingURL=SpruceError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SpruceError.js","sourceRoot":"","sources":["../../src/errors/SpruceError.ts"],"names":[],"mappings":";;;;;AAAA,8DAA+C;AAG/C,MAAqB,WAAY,SAAQ,eAA6B;IAClE,kDAAkD;IAC3C,eAAe;QAClB,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;QACxB,IAAI,OAAO,CAAA;QACX,QAAQ,OAAO,EAAE,IAAI,EAAE,CAAC;YACpB,KAAK,uBAAuB;gBACxB,OAAO,GAAG,wEAAwE,OAAO,CAAC,UAAU,wBAAwB,OAAO,CAAC,aAAa,EAAE,CAAA;gBACnJ,MAAK;YACT;gBACI,OAAO,GAAG,KAAK,CAAC,eAAe,EAAE,CAAA;QACzC,CAAC;QAED,MAAM,WAAW,GAAG,OAAO,CAAC,eAAe;YACvC,CAAC,CAAC,OAAO,CAAC,eAAe;YACzB,CAAC,CAAC,OAAO,CAAA;QAEb,OAAO,WAAW,CAAA;IACtB,CAAC;CACJ;AAnBD,8BAmBC"}
@@ -1,11 +0,0 @@
1
- declare const _default: {
2
- id: string;
3
- name: string;
4
- fields: {
5
- liblslPath: {
6
- type: "text";
7
- isRequired: true;
8
- };
9
- };
10
- };
11
- export default _default;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const schema_1 = require("@sprucelabs/schema");
4
- exports.default = (0, schema_1.buildErrorSchema)({
5
- id: 'failedToLoadLiblsl',
6
- name: 'FAILED_TO_LOAD_LIBLSL',
7
- fields: {
8
- liblslPath: {
9
- type: 'text',
10
- isRequired: true,
11
- },
12
- },
13
- });
14
- //# sourceMappingURL=failedToLoadLiblsl.builder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"failedToLoadLiblsl.builder.js","sourceRoot":"","sources":["../../src/errors/failedToLoadLiblsl.builder.ts"],"names":[],"mappings":";;AAAA,+CAAqD;AAErD,kBAAe,IAAA,yBAAgB,EAAC;IAC5B,EAAE,EAAE,oBAAoB;IACxB,IAAI,EAAE,uBAAuB;IAC7B,MAAM,EAAE;QACJ,UAAU,EAAE;YACR,IAAI,EAAE,MAAM;YACZ,UAAU,EAAE,IAAI;SACnB;KACJ;CACJ,CAAC,CAAA"}
@@ -1,37 +0,0 @@
1
- import { default as SchemaEntity } from '@sprucelabs/schema'
2
- import * as SpruceSchema from '@sprucelabs/schema'
3
-
4
-
5
-
6
-
7
-
8
- export declare namespace SpruceErrors.NodeLsl {
9
-
10
-
11
- export interface FailedToLoadLiblsl {
12
-
13
-
14
- 'liblslPath': string
15
- }
16
-
17
- export interface FailedToLoadLiblslSchema extends SpruceSchema.Schema {
18
- id: 'failedToLoadLiblsl',
19
- namespace: 'NodeLsl',
20
- name: 'FAILED_TO_LOAD_LIBLSL',
21
- fields: {
22
- /** . */
23
- 'liblslPath': {
24
- type: 'text',
25
- isRequired: true,
26
- options: undefined
27
- },
28
- }
29
- }
30
-
31
- export type FailedToLoadLiblslEntity = SchemaEntity<SpruceErrors.NodeLsl.FailedToLoadLiblslSchema>
32
-
33
- }
34
-
35
-
36
-
37
-
@@ -1,22 +0,0 @@
1
- import { SchemaRegistry } from '@sprucelabs/schema'
2
- import { SpruceErrors } from '../errors.types'
3
-
4
-
5
-
6
- const failedToLoadLiblslSchema: SpruceErrors.NodeLsl.FailedToLoadLiblslSchema = {
7
- id: 'failedToLoadLiblsl',
8
- namespace: 'NodeLsl',
9
- name: 'FAILED_TO_LOAD_LIBLSL',
10
- fields: {
11
- /** . */
12
- 'liblslPath': {
13
- type: 'text',
14
- isRequired: true,
15
- options: undefined
16
- },
17
- }
18
- }
19
-
20
- SchemaRegistry.getInstance().trackSchema(failedToLoadLiblslSchema)
21
-
22
- export default failedToLoadLiblslSchema
@@ -1,10 +0,0 @@
1
- import { SpruceErrors } from "#spruce/errors/errors.types"
2
- import { ErrorOptions as ISpruceErrorOptions} from "@sprucelabs/error"
3
-
4
- export interface FailedToLoadLiblslErrorOptions extends SpruceErrors.NodeLsl.FailedToLoadLiblsl, ISpruceErrorOptions {
5
- code: 'FAILED_TO_LOAD_LIBLSL'
6
- }
7
-
8
- type ErrorOptions = | FailedToLoadLiblslErrorOptions
9
-
10
- export default ErrorOptions
@@ -1,6 +0,0 @@
1
- import { fieldClassMap } from '@sprucelabs/schema'
2
-
3
-
4
-
5
-
6
- export default fieldClassMap
@@ -1 +0,0 @@
1
- export { FieldDefinitions, FieldDefinitionMap, FieldValueTypeGeneratorMap, FieldMap } from '@sprucelabs/schema'
@@ -1,23 +0,0 @@
1
- import BaseSpruceError from '@sprucelabs/error'
2
- import ErrorOptions from '#spruce/errors/options.types'
3
-
4
- export default class SpruceError extends BaseSpruceError<ErrorOptions> {
5
- /** an easy to understand version of the errors */
6
- public friendlyMessage(): string {
7
- const { options } = this
8
- let message
9
- switch (options?.code) {
10
- case 'FAILED_TO_LOAD_LIBLSL':
11
- message = `Well shoot! Loading the liblsl dylib failed. I tried to load it from ${options.liblslPath}. Original error:\n\n${options.originalError}`
12
- break
13
- default:
14
- message = super.friendlyMessage()
15
- }
16
-
17
- const fullMessage = options.friendlyMessage
18
- ? options.friendlyMessage
19
- : message
20
-
21
- return fullMessage
22
- }
23
- }
@@ -1,12 +0,0 @@
1
- import { buildErrorSchema } from '@sprucelabs/schema'
2
-
3
- export default buildErrorSchema({
4
- id: 'failedToLoadLiblsl',
5
- name: 'FAILED_TO_LOAD_LIBLSL',
6
- fields: {
7
- liblslPath: {
8
- type: 'text',
9
- isRequired: true,
10
- },
11
- },
12
- })