@neurodevs/ndx-native 0.0.1

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 (67) hide show
  1. package/.nvmrc +1 -0
  2. package/.vscode/launch.json +58 -0
  3. package/.vscode/settings.json +67 -0
  4. package/.vscode/tasks.json +130 -0
  5. package/LICENSE +21 -0
  6. package/README.md +2 -0
  7. package/build/.spruce/settings.json +11 -0
  8. package/build/__tests__/AbstractPackageTest.d.ts +7 -0
  9. package/build/__tests__/AbstractPackageTest.js +14 -0
  10. package/build/__tests__/AbstractPackageTest.js.map +1 -0
  11. package/build/__tests__/impl/LabrecorderAdapter.test.d.ts +30 -0
  12. package/build/__tests__/impl/LabrecorderAdapter.test.js +164 -0
  13. package/build/__tests__/impl/LabrecorderAdapter.test.js.map +1 -0
  14. package/build/__tests__/impl/LiblslAdapter.test.d.ts +84 -0
  15. package/build/__tests__/impl/LiblslAdapter.test.js +750 -0
  16. package/build/__tests__/impl/LiblslAdapter.test.js.map +1 -0
  17. package/build/__tests__/impl/LibxdfAdapter.test.d.ts +45 -0
  18. package/build/__tests__/impl/LibxdfAdapter.test.js +243 -0
  19. package/build/__tests__/impl/LibxdfAdapter.test.js.map +1 -0
  20. package/build/consts.d.ts +11 -0
  21. package/build/consts.js +21 -0
  22. package/build/consts.js.map +1 -0
  23. package/build/impl/LabrecorderAdapter.d.ts +30 -0
  24. package/build/impl/LabrecorderAdapter.js +69 -0
  25. package/build/impl/LabrecorderAdapter.js.map +1 -0
  26. package/build/impl/LiblslAdapter.d.ts +172 -0
  27. package/build/impl/LiblslAdapter.js +360 -0
  28. package/build/impl/LiblslAdapter.js.map +1 -0
  29. package/build/impl/LibxdfAdapter.d.ts +92 -0
  30. package/build/impl/LibxdfAdapter.js +130 -0
  31. package/build/impl/LibxdfAdapter.js.map +1 -0
  32. package/build/index.d.ts +14 -0
  33. package/build/index.js +18 -0
  34. package/build/index.js.map +1 -0
  35. package/build/lib/handleError.d.ts +8 -0
  36. package/build/lib/handleError.js +25 -0
  37. package/build/lib/handleError.js.map +1 -0
  38. package/build/testDoubles/Labrecorder/FakeLabrecorder.d.ts +15 -0
  39. package/build/testDoubles/Labrecorder/FakeLabrecorder.js +26 -0
  40. package/build/testDoubles/Labrecorder/FakeLabrecorder.js.map +1 -0
  41. package/build/testDoubles/Liblsl/FakeLiblsl.d.ts +57 -0
  42. package/build/testDoubles/Liblsl/FakeLiblsl.js +140 -0
  43. package/build/testDoubles/Liblsl/FakeLiblsl.js.map +1 -0
  44. package/build/testDoubles/Libxdf/FakeLibxdf.d.ts +13 -0
  45. package/build/testDoubles/Libxdf/FakeLibxdf.js +25 -0
  46. package/build/testDoubles/Libxdf/FakeLibxdf.js.map +1 -0
  47. package/build/testDoubles/Libxdf/SpyLibxdf.d.ts +6 -0
  48. package/build/testDoubles/Libxdf/SpyLibxdf.js +10 -0
  49. package/build/testDoubles/Libxdf/SpyLibxdf.js.map +1 -0
  50. package/eslint.config.mjs +3 -0
  51. package/package.json +84 -0
  52. package/src/.spruce/settings.json +11 -0
  53. package/src/__tests__/AbstractPackageTest.ts +16 -0
  54. package/src/__tests__/impl/LabrecorderAdapter.test.ts +197 -0
  55. package/src/__tests__/impl/LiblslAdapter.test.ts +907 -0
  56. package/src/__tests__/impl/LibxdfAdapter.test.ts +290 -0
  57. package/src/consts.ts +21 -0
  58. package/src/impl/LabrecorderAdapter.ts +100 -0
  59. package/src/impl/LiblslAdapter.ts +616 -0
  60. package/src/impl/LibxdfAdapter.ts +227 -0
  61. package/src/index.ts +26 -0
  62. package/src/lib/handleError.ts +24 -0
  63. package/src/testDoubles/Labrecorder/FakeLabrecorder.ts +37 -0
  64. package/src/testDoubles/Liblsl/FakeLiblsl.ts +204 -0
  65. package/src/testDoubles/Libxdf/FakeLibxdf.ts +33 -0
  66. package/src/testDoubles/Libxdf/SpyLibxdf.ts +13 -0
  67. package/tsconfig.json +28 -0
@@ -0,0 +1,130 @@
1
+ import fs from 'fs';
2
+ import { MangledNameExtractor, } from '@neurodevs/node-mangled-names';
3
+ import { DataType, define, open } from 'ffi-rs';
4
+ export default class LibxdfAdapter {
5
+ static Class;
6
+ static ffiRsOpen = open;
7
+ static ffiRsDefine = define;
8
+ static loadXdfName = 'load_xdf_to_json';
9
+ static unmangledNames = [this.loadXdfName];
10
+ bindings;
11
+ libxdfPath;
12
+ mangledNameMap;
13
+ constructor(libxdfPath, mangledNameMap) {
14
+ this.libxdfPath = libxdfPath;
15
+ this.mangledNameMap = mangledNameMap;
16
+ this.tryToLoadBindings();
17
+ }
18
+ static async Create(libxdfPath, throwIfPathNotExists = true) {
19
+ if (throwIfPathNotExists && !fs.existsSync(libxdfPath)) {
20
+ throw new Error(this.generateFailedMessage(libxdfPath));
21
+ }
22
+ const mangledNameMap = await this.loadMangledNameMap(libxdfPath);
23
+ return new (this.Class ?? this)(libxdfPath, mangledNameMap);
24
+ }
25
+ tryToLoadBindings() {
26
+ try {
27
+ this.bindings = this.loadBindings();
28
+ }
29
+ catch (err) {
30
+ this.throwFailedToLoadLiblsl(err);
31
+ }
32
+ }
33
+ loadBindings() {
34
+ this.openLibxdf();
35
+ return this.defineBindings();
36
+ }
37
+ openLibxdf() {
38
+ LibxdfAdapter.ffiRsOpen({
39
+ library: 'xdf',
40
+ path: this.libxdfPath,
41
+ });
42
+ }
43
+ defineBindings() {
44
+ const funcs = this.unmangledNames.reduce((acc, name) => {
45
+ const mangledName = this.mangledNameMap[name].slice(1);
46
+ // @ts-ignore
47
+ acc[mangledName] = {
48
+ library: 'xdf',
49
+ retType: DataType.String,
50
+ paramsType: [DataType.String],
51
+ };
52
+ return acc;
53
+ }, {});
54
+ return LibxdfAdapter.ffiRsDefine(funcs);
55
+ }
56
+ throwFailedToLoadLiblsl(err) {
57
+ throw new Error(this.generateFailedMessage(err));
58
+ }
59
+ generateFailedMessage(err) {
60
+ return `
61
+ ${LibxdfAdapter.generateFailedMessage(this.libxdfPath)}
62
+ \n ${err}
63
+ \n
64
+ `;
65
+ }
66
+ loadXdf(path) {
67
+ const mangledName = this.mangledNameMap[this.loadXdfName].slice(1);
68
+ const mangledFunc = this.bindings[mangledName];
69
+ const serializedData = mangledFunc([path]);
70
+ const parsedData = JSON.parse(serializedData);
71
+ if (!parsedData.events) {
72
+ parsedData.events = [];
73
+ }
74
+ const mappedStreams = parsedData.streams.map((stream) => ({
75
+ id: stream.stream_id,
76
+ name: stream.stream_info.stream_name,
77
+ type: stream.stream_info.stream_type,
78
+ channelCount: stream.stream_info.channel_count,
79
+ channelFormat: stream.stream_info.channel_format,
80
+ nominalSampleRateHz: stream.stream_info.nominal_srate,
81
+ data: stream.time_series,
82
+ timestamps: stream.time_stamps,
83
+ }));
84
+ const mappedEvents = parsedData.events.map((event) => ({
85
+ name: event.event_name,
86
+ timestamp: event.event_timestamp,
87
+ streamId: event.stream_id,
88
+ }));
89
+ return {
90
+ path,
91
+ streams: mappedStreams,
92
+ events: mappedEvents,
93
+ };
94
+ }
95
+ get unmangledNames() {
96
+ return LibxdfAdapter.unmangledNames;
97
+ }
98
+ get loadXdfName() {
99
+ return LibxdfAdapter.loadXdfName;
100
+ }
101
+ static generateFailedMessage(libxdfPath) {
102
+ return `
103
+ \n -----------------------------------
104
+ \n Failed to load libxdf! Tried to load from:
105
+ \n ${libxdfPath}
106
+ \n Instructions to save your day (on MacOS):
107
+ \n 1. git clone https://github.com/neurodevs/libxdf.git
108
+ \n 2. cd libxdf && cmake -S . -B build && cmake --build build
109
+ \n 3. sudo cp build/libxdf.dylib /opt/local/lib/
110
+ \n 4. Try whatever you were doing again!
111
+ \n Modify step 3 for your OS if you are not on MacOS.
112
+ \n Check the official repo for OS-specific instructions:
113
+ \n https://github.com/xdf-modules/libxdf
114
+ \n If you're still unsure, ask an LLM with this error and your OS.
115
+ \n You could also post an issue on the repo:
116
+ \n https://github.com/neurodevs/node-xdf/issues
117
+ \n Good luck!
118
+ \n @ericthecurious
119
+ \n -----------------------------------
120
+ `;
121
+ }
122
+ static async loadMangledNameMap(libxdfPath) {
123
+ const extractor = this.MangledNameExtractor();
124
+ return await extractor.extract(libxdfPath, this.unmangledNames);
125
+ }
126
+ static MangledNameExtractor() {
127
+ return MangledNameExtractor.Create();
128
+ }
129
+ }
130
+ //# sourceMappingURL=LibxdfAdapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LibxdfAdapter.js","sourceRoot":"","sources":["../../src/impl/LibxdfAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EACH,oBAAoB,GAEvB,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAsB,IAAI,EAAE,MAAM,QAAQ,CAAA;AAEnE,MAAM,CAAC,OAAO,OAAO,aAAa;IACvB,MAAM,CAAC,KAAK,CAAoB;IAChC,MAAM,CAAC,SAAS,GAAG,IAAI,CAAA;IACvB,MAAM,CAAC,WAAW,GAAG,MAAM,CAAA;IAC1B,MAAM,CAAU,WAAW,GAAG,kBAAkB,CAAA;IAChD,MAAM,CAAC,cAAc,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IAExC,QAAQ,CAAiB;IAC3B,UAAU,CAAQ;IAClB,cAAc,CAAgB;IAEtC,YAAsB,UAAkB,EAAE,cAA8B;QACpE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAA;QAEpC,IAAI,CAAC,iBAAiB,EAAE,CAAA;IAC5B,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,MAAM,CACtB,UAAkB,EAClB,oBAAoB,GAAG,IAAI;QAE3B,IAAI,oBAAoB,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YACrD,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC,CAAA;QAC3D,CAAC;QAED,MAAM,cAAc,GAAG,MAAM,IA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5B,CAAC,CAAC,CAAA;QAEH,OAAO;YACH,IAAI;YACJ,OAAO,EAAE,aAAa;YACtB,MAAM,EAAE,YAAY;SACvB,CAAA;IACL,CAAC;IAED,IAAY,cAAc;QACtB,OAAO,aAAa,CAAC,cAAc,CAAA;IACvC,CAAC;IAED,IAAY,WAAW;QACnB,OAAO,aAAa,CAAC,WAAW,CAAA;IACpC,CAAC;IAEO,MAAM,CAAC,qBAAqB,CAAC,UAAkB;QACnD,OAAO;;;YAGH,UAAU;;;;;;;;;;;;;;;SAeb,CAAA;IACL,CAAC;IAEO,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,UAAkB;QACtD,MAAM,SAAS,GAAG,IAAI,CAAC,oBAAoB,EAAE,CAAA;QAC7C,OAAO,MAAM,SAAS,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;IACnE,CAAC;IAEO,MAAM,CAAC,oBAAoB;QAC/B,OAAO,oBAAoB,CAAC,MAAM,EAAE,CAAA;IACxC,CAAC"}
@@ -0,0 +1,14 @@
1
+ export { default as LabrecorderAdapter } from './impl/LabrecorderAdapter.js';
2
+ export * from './impl/LabrecorderAdapter.js';
3
+ export { default as FakeLabrecorder } from './testDoubles/Labrecorder/FakeLabrecorder.js';
4
+ export * from './testDoubles/Labrecorder/FakeLabrecorder.js';
5
+ export { default as LiblslAdapter } from './impl/LiblslAdapter.js';
6
+ export * from './impl/LiblslAdapter.js';
7
+ export { default as FakeLiblsl } from './testDoubles/Liblsl/FakeLiblsl.js';
8
+ export * from './testDoubles/Liblsl/FakeLiblsl.js';
9
+ export { default as LibxdfAdapter } from './impl/LibxdfAdapter.js';
10
+ export * from './impl/LibxdfAdapter.js';
11
+ export { default as FakeLibxdf } from './testDoubles/Libxdf/FakeLibxdf.js';
12
+ export * from './testDoubles/Libxdf/FakeLibxdf.js';
13
+ export { default as SpyLibxdf } from './testDoubles/Libxdf/SpyLibxdf.js';
14
+ export * from './testDoubles/Libxdf/SpyLibxdf.js';
package/build/index.js ADDED
@@ -0,0 +1,18 @@
1
+ // Labrecorder
2
+ export { default as LabrecorderAdapter } from './impl/LabrecorderAdapter.js';
3
+ export * from './impl/LabrecorderAdapter.js';
4
+ export { default as FakeLabrecorder } from './testDoubles/Labrecorder/FakeLabrecorder.js';
5
+ export * from './testDoubles/Labrecorder/FakeLabrecorder.js';
6
+ // Liblsl
7
+ export { default as LiblslAdapter } from './impl/LiblslAdapter.js';
8
+ export * from './impl/LiblslAdapter.js';
9
+ export { default as FakeLiblsl } from './testDoubles/Liblsl/FakeLiblsl.js';
10
+ export * from './testDoubles/Liblsl/FakeLiblsl.js';
11
+ // Libxdf
12
+ export { default as LibxdfAdapter } from './impl/LibxdfAdapter.js';
13
+ export * from './impl/LibxdfAdapter.js';
14
+ export { default as FakeLibxdf } from './testDoubles/Libxdf/FakeLibxdf.js';
15
+ export * from './testDoubles/Libxdf/FakeLibxdf.js';
16
+ export { default as SpyLibxdf } from './testDoubles/Libxdf/SpyLibxdf.js';
17
+ export * from './testDoubles/Libxdf/SpyLibxdf.js';
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc;AAEd,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,8BAA8B,CAAA;AAC5E,cAAc,8BAA8B,CAAA;AAE5C,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8CAA8C,CAAA;AACzF,cAAc,8CAA8C,CAAA;AAE5D,SAAS;AAET,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAClE,cAAc,yBAAyB,CAAA;AAEvC,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,oCAAoC,CAAA;AAC1E,cAAc,oCAAoC,CAAA;AAElD,SAAS;AAET,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,yBAAyB,CAAA;AAClE,cAAc,yBAAyB,CAAA;AAEvC,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,oCAAoC,CAAA;AAC1E,cAAc,oCAAoC,CAAA;AAElD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,mCAAmC,CAAA;AACxE,cAAc,mCAAmC,CAAA"}
@@ -0,0 +1,8 @@
1
+ export default function handleError(errorCode: number): void;
2
+ export declare enum LslErrorCode {
3
+ Ok = 0,
4
+ Timeout = -1,
5
+ Lost = -2,
6
+ BadArgument = -3,
7
+ InternalError = -4
8
+ }
@@ -0,0 +1,25 @@
1
+ export default function handleError(errorCode) {
2
+ switch (errorCode) {
3
+ case 0:
4
+ return;
5
+ case -1:
6
+ throw new Error(`The liblsl operation failed due to a timeout!`);
7
+ case -2:
8
+ throw new Error(`The liblsl stream has been lost!`);
9
+ case -3:
10
+ throw new Error(`A liblsl argument was incorrectly specified!`);
11
+ case -4:
12
+ throw new Error(`An internal liblsl error has occurred!`);
13
+ default:
14
+ throw new Error(`An unknown liblsl error has occurred!`);
15
+ }
16
+ }
17
+ export var LslErrorCode;
18
+ (function (LslErrorCode) {
19
+ LslErrorCode[LslErrorCode["Ok"] = 0] = "Ok";
20
+ LslErrorCode[LslErrorCode["Timeout"] = -1] = "Timeout";
21
+ LslErrorCode[LslErrorCode["Lost"] = -2] = "Lost";
22
+ LslErrorCode[LslErrorCode["BadArgument"] = -3] = "BadArgument";
23
+ LslErrorCode[LslErrorCode["InternalError"] = -4] = "InternalError";
24
+ })(LslErrorCode || (LslErrorCode = {}));
25
+ //# sourceMappingURL=handleError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handleError.js","sourceRoot":"","sources":["../../src/lib/handleError.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,SAAiB;IACjD,QAAQ,SAAS,EAAE,CAAC;QAChB,KAAK,CAAC;YACF,OAAM;QACV,KAAK,CAAC,CAAC;YACH,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;QACpE,KAAK,CAAC,CAAC;YACH,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAA;QACvD,KAAK,CAAC,CAAC;YACH,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAA;QACnE,KAAK,CAAC,CAAC;YACH,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAA;QAC7D;YACI,MAAM,IAAI,KAAK,CAAC,uCAAuC,CAAC,CAAA;IAChE,CAAC;AACL,CAAC;AAED,MAAM,CAAN,IAAY,YAMX;AAND,WAAY,YAAY;IACpB,2CAAM,CAAA;IACN,sDAAY,CAAA;IACZ,gDAAS,CAAA;IACT,8DAAgB,CAAA;IAChB,kEAAkB,CAAA;AACtB,CAAC,EANW,YAAY,KAAZ,YAAY,QAMvB"}
@@ -0,0 +1,15 @@
1
+ import { RecordingHandle, Labrecorder } from '../../impl/LabrecorderAdapter.js';
2
+ export default class FakeLabrecorder implements Labrecorder {
3
+ static constructorCalls: string[];
4
+ static createRecordingCalls: {
5
+ filename: string;
6
+ watchFor: string[];
7
+ }[];
8
+ static stopRecordingCalls: RecordingHandle[];
9
+ static deleteRecordingCalls: RecordingHandle[];
10
+ constructor(labrecorderPath: string);
11
+ createRecording(filename: string, watchFor: string[]): RecordingHandle;
12
+ stopRecording(recording: RecordingHandle): void;
13
+ deleteRecording(recording: RecordingHandle): void;
14
+ static resetTestDouble(): void;
15
+ }
@@ -0,0 +1,26 @@
1
+ export default class FakeLabrecorder {
2
+ static constructorCalls = [];
3
+ static createRecordingCalls = [];
4
+ static stopRecordingCalls = [];
5
+ static deleteRecordingCalls = [];
6
+ constructor(labrecorderPath) {
7
+ FakeLabrecorder.constructorCalls.push(labrecorderPath);
8
+ }
9
+ createRecording(filename, watchFor) {
10
+ FakeLabrecorder.createRecordingCalls.push({ filename, watchFor });
11
+ return {};
12
+ }
13
+ stopRecording(recording) {
14
+ FakeLabrecorder.stopRecordingCalls.push(recording);
15
+ }
16
+ deleteRecording(recording) {
17
+ FakeLabrecorder.deleteRecordingCalls.push(recording);
18
+ }
19
+ static resetTestDouble() {
20
+ this.constructorCalls = [];
21
+ this.createRecordingCalls = [];
22
+ this.stopRecordingCalls = [];
23
+ this.deleteRecordingCalls = [];
24
+ }
25
+ }
26
+ //# sourceMappingURL=FakeLabrecorder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FakeLabrecorder.js","sourceRoot":"","sources":["../../../src/testDoubles/Labrecorder/FakeLabrecorder.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,OAAO,eAAe;IACzB,MAAM,CAAC,gBAAgB,GAAa,EAAE,CAAA;IAEtC,MAAM,CAAC,oBAAoB,GAG5B,EAAE,CAAA;IAED,MAAM,CAAC,kBAAkB,GAAsB,EAAE,CAAA;IACjD,MAAM,CAAC,oBAAoB,GAAsB,EAAE,CAAA;IAE1D,YAAmB,eAAuB;QACtC,eAAe,CAAC,gBAAgB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;IAC1D,CAAC;IAEM,eAAe,CAAC,QAAgB,EAAE,QAAkB;QACvD,eAAe,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAA;QACjE,OAAO,EAAqB,CAAA;IAChC,CAAC;IAEM,aAAa,CAAC,SAA0B;QAC3C,eAAe,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACtD,CAAC;IAEM,eAAe,CAAC,SAA0B;QAC7C,eAAe,CAAC,oBAAoB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IACxD,CAAC;IAEM,MAAM,CAAC,eAAe;QACzB,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAA;QAC1B,IAAI,CAAC,oBAAoB,GAAG,EAAE,CAAA;QAC9B,IAAI,CAAC,kBAAkB,GAAG,EAAE,CAAA;QAC5B,IAAI,CAAC,oBAAoB,GAAG,EAAE,CAAA;IAClC,CAAC"}
@@ -0,0 +1,57 @@
1
+ import { OutletHandle, InfoHandle, CreateStreamInfoOptions, AppendChannelsToStreamInfoOptions, CreateOutletOptions, PushSampleFloatTimestampOptions, PushSampleStringTimestampOptions, Liblsl, CreateInletOptions, DestroyInletOptions, InletHandle, FlushInletOptions, PullChunkOptions, PullSampleOptions, DestroyStreamInfoOptions, ResolveByPropOptions, DestroyOutletOptions, OpenStreamOptions, CloseStreamOptions, GetChannelCountOptions } from 'impl/LiblslAdapter.js';
2
+ export default class FakeLiblsl implements Liblsl {
3
+ static fakeInfoHandles: InfoHandle[];
4
+ static fakeSamples: Float32Array[];
5
+ static fakeChunks: Float32Array[];
6
+ static fakeTimestamps: Float64Array[];
7
+ static fakeChannelCount: number;
8
+ static fakeErrorCode: number;
9
+ liblslPath: string;
10
+ fakeSamples: Float32Array<ArrayBufferLike>[];
11
+ fakeChunks: Float32Array<ArrayBufferLike>[];
12
+ fakeTimestamps: Float64Array<ArrayBufferLike>[];
13
+ outletHandle: OutletHandle;
14
+ infoHandle: InfoHandle;
15
+ lastCreateStreamInfoOptions?: CreateStreamInfoOptions;
16
+ lastAppendChannelsToStreamInfoOptions?: AppendChannelsToStreamInfoOptions;
17
+ lastDestroyStreamInfoOptions?: DestroyStreamInfoOptions;
18
+ lastResolveByPropOptions?: ResolveByPropOptions;
19
+ lastGetChannelCountOptions?: GetChannelCountOptions;
20
+ lastCreateOutletOptions?: CreateOutletOptions;
21
+ lastPushSampleFloatTimestampOptions?: PushSampleFloatTimestampOptions;
22
+ lastPushSampleStringTimestampOptions?: PushSampleStringTimestampOptions;
23
+ lastDestroyOutletOptions?: DestroyOutletOptions;
24
+ lastCreateInletOptions?: CreateInletOptions;
25
+ lastOpenStreamOptions?: OpenStreamOptions;
26
+ lastCloseStreamOptions?: CloseStreamOptions;
27
+ lastPullSampleOptions?: PullSampleOptions;
28
+ lastPullChunkOptions?: PullChunkOptions;
29
+ lastFlushInletOptions?: FlushInletOptions;
30
+ lastDestroyInletOptions?: DestroyInletOptions;
31
+ createStreamInfoHitCount: number;
32
+ createOutletHitCount: number;
33
+ destroyOutletHitCount: number;
34
+ createInletHitCount: number;
35
+ flushInletHitCount: number;
36
+ destroyInletHitCount: number;
37
+ localClockHitCount: number;
38
+ pushSampleStringTimestampHitCount: number;
39
+ createStreamInfo(options: CreateStreamInfoOptions): InfoHandle;
40
+ appendChannelsToStreamInfo(options: AppendChannelsToStreamInfoOptions): void;
41
+ getChannelCount(options: GetChannelCountOptions): number;
42
+ destroyStreamInfo(options: DestroyStreamInfoOptions): void;
43
+ resolveByProp(options: ResolveByPropOptions): Promise<InfoHandle[]>;
44
+ pushSampleFloatTimestamp(options: PushSampleFloatTimestampOptions): number;
45
+ pushSampleStringTimestamp(options: PushSampleStringTimestampOptions): number;
46
+ createOutlet(options: CreateOutletOptions): OutletHandle;
47
+ destroyOutlet(options: DestroyOutletOptions): void;
48
+ createInlet(options: CreateInletOptions): InletHandle;
49
+ openStream(options: OpenStreamOptions): Promise<void>;
50
+ closeStream(options: CloseStreamOptions): Promise<void>;
51
+ pullSample(options: PullSampleOptions): 0 | 1;
52
+ pullChunk(options: PullChunkOptions): 0 | 1;
53
+ flushInlet(options: FlushInletOptions): void;
54
+ destroyInlet(options: DestroyInletOptions): void;
55
+ localClock(): number;
56
+ resetTestDouble(): void;
57
+ }
@@ -0,0 +1,140 @@
1
+ import generateId from '@neurodevs/generate-id';
2
+ export default class FakeLiblsl {
3
+ static fakeInfoHandles = [];
4
+ static fakeSamples = [
5
+ new Float32Array([1, 2, 3]),
6
+ new Float32Array([4, 5, 6]),
7
+ ];
8
+ static fakeChunks = [
9
+ new Float32Array([1, 2, 3, 4, 5, 6]),
10
+ new Float32Array([1, 2, 3, 4, 5, 6]),
11
+ ];
12
+ static fakeTimestamps = [
13
+ new Float64Array([7, 8]),
14
+ new Float64Array([7, 8]),
15
+ ];
16
+ static fakeChannelCount = 3;
17
+ static fakeErrorCode = 0;
18
+ liblslPath = generateId();
19
+ fakeSamples = FakeLiblsl.fakeSamples.slice();
20
+ fakeChunks = FakeLiblsl.fakeChunks.slice();
21
+ fakeTimestamps = FakeLiblsl.fakeTimestamps.slice();
22
+ outletHandle = {};
23
+ infoHandle = {};
24
+ lastCreateStreamInfoOptions;
25
+ lastAppendChannelsToStreamInfoOptions;
26
+ lastDestroyStreamInfoOptions;
27
+ lastResolveByPropOptions;
28
+ lastGetChannelCountOptions;
29
+ lastCreateOutletOptions;
30
+ lastPushSampleFloatTimestampOptions;
31
+ lastPushSampleStringTimestampOptions;
32
+ lastDestroyOutletOptions;
33
+ lastCreateInletOptions;
34
+ lastOpenStreamOptions;
35
+ lastCloseStreamOptions;
36
+ lastPullSampleOptions;
37
+ lastPullChunkOptions;
38
+ lastFlushInletOptions;
39
+ lastDestroyInletOptions;
40
+ createStreamInfoHitCount = 0;
41
+ createOutletHitCount = 0;
42
+ destroyOutletHitCount = 0;
43
+ createInletHitCount = 0;
44
+ flushInletHitCount = 0;
45
+ destroyInletHitCount = 0;
46
+ localClockHitCount = 0;
47
+ pushSampleStringTimestampHitCount = 0;
48
+ createStreamInfo(options) {
49
+ this.createStreamInfoHitCount++;
50
+ this.lastCreateStreamInfoOptions = options;
51
+ return this.infoHandle;
52
+ }
53
+ appendChannelsToStreamInfo(options) {
54
+ this.lastAppendChannelsToStreamInfoOptions = options;
55
+ }
56
+ getChannelCount(options) {
57
+ this.lastGetChannelCountOptions = options;
58
+ return FakeLiblsl.fakeChannelCount;
59
+ }
60
+ destroyStreamInfo(options) {
61
+ this.lastDestroyStreamInfoOptions = options;
62
+ }
63
+ async resolveByProp(options) {
64
+ this.lastResolveByPropOptions = options;
65
+ return FakeLiblsl.fakeInfoHandles;
66
+ }
67
+ pushSampleFloatTimestamp(options) {
68
+ this.lastPushSampleFloatTimestampOptions = options;
69
+ return FakeLiblsl.fakeErrorCode;
70
+ }
71
+ pushSampleStringTimestamp(options) {
72
+ this.lastPushSampleStringTimestampOptions = options;
73
+ this.pushSampleStringTimestampHitCount++;
74
+ return FakeLiblsl.fakeErrorCode;
75
+ }
76
+ createOutlet(options) {
77
+ this.createOutletHitCount++;
78
+ this.lastCreateOutletOptions = options;
79
+ return this.outletHandle;
80
+ }
81
+ destroyOutlet(options) {
82
+ this.destroyOutletHitCount++;
83
+ this.lastDestroyOutletOptions = options;
84
+ }
85
+ createInlet(options) {
86
+ this.createInletHitCount++;
87
+ this.lastCreateInletOptions = options;
88
+ return {};
89
+ }
90
+ async openStream(options) {
91
+ this.lastOpenStreamOptions = options;
92
+ }
93
+ async closeStream(options) {
94
+ this.lastCloseStreamOptions = options;
95
+ }
96
+ pullSample(options) {
97
+ this.lastPullSampleOptions = options;
98
+ const sample = this.fakeSamples.shift();
99
+ if (sample) {
100
+ return 1;
101
+ }
102
+ return 0;
103
+ }
104
+ pullChunk(options) {
105
+ this.lastPullChunkOptions = options;
106
+ const chunk = this.fakeChunks.shift();
107
+ const timestamps = this.fakeTimestamps.shift();
108
+ if (chunk && timestamps) {
109
+ return 1;
110
+ }
111
+ return 0;
112
+ }
113
+ flushInlet(options) {
114
+ this.flushInletHitCount++;
115
+ this.lastFlushInletOptions = options;
116
+ }
117
+ destroyInlet(options) {
118
+ this.destroyInletHitCount++;
119
+ this.lastDestroyInletOptions = options;
120
+ }
121
+ localClock() {
122
+ this.localClockHitCount++;
123
+ return new Date().getTime();
124
+ }
125
+ resetTestDouble() {
126
+ this.lastCreateStreamInfoOptions = undefined;
127
+ this.lastAppendChannelsToStreamInfoOptions = undefined;
128
+ this.lastCreateOutletOptions = undefined;
129
+ this.lastPushSampleFloatTimestampOptions = undefined;
130
+ this.lastPushSampleStringTimestampOptions = undefined;
131
+ this.createStreamInfoHitCount = 0;
132
+ this.destroyOutletHitCount = 0;
133
+ this.localClockHitCount = 0;
134
+ this.pushSampleStringTimestampHitCount = 0;
135
+ this.fakeSamples = FakeLiblsl.fakeSamples.slice();
136
+ this.fakeChunks = FakeLiblsl.fakeChunks.slice();
137
+ this.fakeTimestamps = FakeLiblsl.fakeTimestamps.slice();
138
+ }
139
+ }
140
+ //# sourceMappingURL=FakeLiblsl.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FakeLiblsl.js","sourceRoot":"","sources":["../../../src/testDoubles/Liblsl/FakeLiblsl.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,wBAAwB,CAAA;AAyB/C,MAAM,CAAC,OAAO,OAAO,UAAU;IACpB,MAAM,CAAC,eAAe,GAAiB,EAAE,CAAA;IAEzC,MAAM,CAAC,WAAW,GAAmB;QACxC,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAC3B,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;KAC9B,CAAA;IAEM,MAAM,CAAC,UAAU,GAAmB;QACvC,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QACpC,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;KACvC,CAAA;IAEM,MAAM,CAAC,cAAc,GAAmB;QAC3C,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACxB,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;KAC3B,CAAA;IAEM,MAAM,CAAC,gBAAgB,GAAG,CAAC,CAAA;IAC3B,MAAM,CAAC,aAAa,GAAG,CAAC,CAAA;IAExB,UAAU,GAAW,UAAU,EAAE,CAAA;IAEjC,WAAW,GAAG,UAAU,CAAC,WAAW,CAAC,KAAK,EAAE,CAAA;IAC5C,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC,KAAK,EAAE,CAAA;IAC1C,cAAc,GAAG,UAAU,CAAC,cAAc,CAAC,KAAK,EAAE,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C,cAAc,CAAC,KAAK,EAAE,CAAA;IAC3D,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { MangledNameMap } from '@neurodevs/node-mangled-names';
2
+ import { Libxdf, XdfFile } from '../../impl/LibxdfAdapter.js';
3
+ export default class FakeLibxdf implements Libxdf {
4
+ static libxdfPath?: string;
5
+ static loadXdfCalls: string[];
6
+ static mangledNameMap: MangledNameMap;
7
+ static fakeXdfFile: XdfFile;
8
+ constructor(libxdfPath: string, mangledNameMap: MangledNameMap);
9
+ loadXdf(path: string): XdfFile;
10
+ get mangledNameMap(): MangledNameMap;
11
+ get fakeXdfFile(): XdfFile;
12
+ static resetTestDouble(): void;
13
+ }
@@ -0,0 +1,25 @@
1
+ export default class FakeLibxdf {
2
+ static libxdfPath;
3
+ static loadXdfCalls = [];
4
+ static mangledNameMap;
5
+ static fakeXdfFile = { path: '', streams: [], events: [] };
6
+ constructor(libxdfPath, mangledNameMap) {
7
+ FakeLibxdf.libxdfPath = libxdfPath;
8
+ FakeLibxdf.mangledNameMap = mangledNameMap;
9
+ }
10
+ loadXdf(path) {
11
+ FakeLibxdf.loadXdfCalls.push(path);
12
+ return this.fakeXdfFile;
13
+ }
14
+ get mangledNameMap() {
15
+ return FakeLibxdf.mangledNameMap;
16
+ }
17
+ get fakeXdfFile() {
18
+ return FakeLibxdf.fakeXdfFile;
19
+ }
20
+ static resetTestDouble() {
21
+ FakeLibxdf.libxdfPath = undefined;
22
+ FakeLibxdf.loadXdfCalls = [];
23
+ }
24
+ }
25
+ //# sourceMappingURL=FakeLibxdf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FakeLibxdf.js","sourceRoot":"","sources":["../../../src/testDoubles/Libxdf/FakeLibxdf.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,OAAO,OAAO,UAAU;IACpB,MAAM,CAAC,UAAU,CAAS;IAC1B,MAAM,CAAC,YAAY,GAAa,EAAE,CAAA;IAClC,MAAM,CAAC,cAAc,CAAgB;IACrC,MAAM,CAAC,WAAW,GAAY,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAA;IAE1E,YAAmB,UAAkB,EAAE,cAA8B;QACjE,UAAU,CAAC,UAAU,GAAG,UAAU,CAAA;QAClC,UAAU,CAAC,cAAc,GAAG,cAAc,CAAA;IAC9C,CAAC;IAEM,OAAO,CAAC,IAAY;QACvB,UAAU,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAClC,OAAO,IAAI,CAAC,WAAW,CAAA;IAC3B,CAAC;IAED,IAAW,cAAc;QACrB,OAAO,UAAU,CAAC,cAAc,CAAA;IACpC,CAAC;IAED,IAAW,WAAW;QAClB,OAAO,UAAU,CAAC,WAAW,CAAA;IACjC,CAAC;IAEM,MAAM,CAAC,eAAe;QACzB,UAAU,CAAC,UAAU,GAAG,SAAS,CAAA;QACjC,UAAU,CAAC,YAAY,GAAG,EAAE,CAAA;IAChC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { MangledNameMap } from '@neurodevs/node-mangled-names';
2
+ import LibxdfAdapter from '../../impl/LibxdfAdapter.js';
3
+ export default class SpyLibxdf extends LibxdfAdapter {
4
+ constructor(libxdfPath: string, mangledNameMap: MangledNameMap);
5
+ getBindings(): import("../../impl/LibxdfAdapter.js").LibxdfBindings;
6
+ }
@@ -0,0 +1,10 @@
1
+ import LibxdfAdapter from '../../impl/LibxdfAdapter.js';
2
+ export default class SpyLibxdf extends LibxdfAdapter {
3
+ constructor(libxdfPath, mangledNameMap) {
4
+ super(libxdfPath, mangledNameMap);
5
+ }
6
+ getBindings() {
7
+ return this.bindings;
8
+ }
9
+ }
10
+ //# sourceMappingURL=SpyLibxdf.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SpyLibxdf.js","sourceRoot":"","sources":["../../../src/testDoubles/Libxdf/SpyLibxdf.ts"],"names":[],"mappings":"AAEA,OAAO,aAAa,MAAM,6BAA6B,CAAA;AAEvD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,aAAa;IAChD,YAAmB,UAAkB,EAAE,cAA8B;QACjE,KAAK,CAAC,UAAU,EAAE,cAAc,CAAC,CAAA;IACrC,CAAC;IAEM,WAAW;QACd,OAAO,IAAI,CAAC,QAAQ,CAAA;IACxB,CAAC;CACJ"}
@@ -0,0 +1,3 @@
1
+ import eslintConfigSpruce from 'eslint-config-spruce'
2
+
3
+ export default eslintConfigSpruce
package/package.json ADDED
@@ -0,0 +1,84 @@
1
+ {
2
+ "name": "@neurodevs/ndx-native",
3
+ "version": "0.0.1",
4
+ "description": "Native Node.js adapters for LSL, XDF, and LabRecorder",
5
+ "type": "module",
6
+ "keywords": [
7
+ "nodejs",
8
+ "typescript",
9
+ "tdd"
10
+ ],
11
+ "license": "MIT",
12
+ "author": "Eric Yates <hello@ericthecurious.com>",
13
+ "homepage": "https://github.com/neurodevs/ndx-native",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/neurodevs/ndx-native.git"
17
+ },
18
+ "bugs": {
19
+ "url": "https://github.com/neurodevs/ndx-native/issues"
20
+ },
21
+ "main": "build/index.js",
22
+ "scripts": {
23
+ "build.ci": "yarn run build.tsc && yarn run build.resolve-paths && yarn run lint",
24
+ "build.dev": "yarn run build.tsc --sourceMap ; yarn run resolve-paths.lint",
25
+ "build.copy-files": "mkdir -p build && rsync -avzq --exclude='*.ts' ./src/ ./build/",
26
+ "build.resolve-paths": "resolve-path-aliases --target build --patterns '**/*.js,**/*.d.ts'",
27
+ "build.tsc": "yarn run build.copy-files && tsc",
28
+ "clean": "yarn run clean.build",
29
+ "clean.all": "yarn run clean.dependencies && yarn run clean.build",
30
+ "clean.build": "rm -rf build/",
31
+ "clean.dependencies": "rm -rf node_modules/ package-lock.json yarn.lock",
32
+ "fix.lint": "eslint --fix --cache '**/*.ts'",
33
+ "lint": "eslint --cache '**/*.ts'",
34
+ "lint.tsc": "tsc -p . --noEmit",
35
+ "post.watch.build": "yarn run build.copy-files && yarn run build.resolve-paths",
36
+ "rebuild": "yarn run clean.all && yarn install && yarn run build.dev",
37
+ "update.dependencies": "yarn run clean.dependencies && yarn",
38
+ "resolve-paths.lint": "yarn run build.resolve-paths ; yarn run lint",
39
+ "test": "jest",
40
+ "watch.build.dev": "tsc-watch --sourceMap --onCompilationComplete 'yarn run post.watch.build'",
41
+ "watch.rebuild": "yarn run clean.all && yarn install && yarn run watch.build.dev",
42
+ "watch.tsc": "tsc -w"
43
+ },
44
+ "dependencies": {
45
+ "@neurodevs/node-mangled-names": "^1.0.1",
46
+ "ffi-rs": "^1.3.1"
47
+ },
48
+ "devDependencies": {
49
+ "@neurodevs/generate-id": "^1.1.2",
50
+ "@neurodevs/node-tdd": "^0.2.5",
51
+ "@sprucelabs/resolve-path-aliases": "^4.0.15",
52
+ "@types/node": "^25.0.10",
53
+ "chokidar-cli": "^3.0.0",
54
+ "eslint": "^9.39.2",
55
+ "eslint-config-spruce": "^11.2.26",
56
+ "jest": "^30.2.0",
57
+ "jest-circus": "^30.2.0",
58
+ "prettier": "^3.8.1",
59
+ "ts-node": "^10.9.2",
60
+ "tsc-watch": "^7.2.0",
61
+ "typescript": "^5.9.3"
62
+ },
63
+ "skill": {
64
+ "namespace": "ndx-native"
65
+ },
66
+ "jest": {
67
+ "testRunner": "jest-circus/runner",
68
+ "maxWorkers": 4,
69
+ "testTimeout": 120000,
70
+ "testEnvironment": "node",
71
+ "testPathIgnorePatterns": [
72
+ "<rootDir>/tmp/",
73
+ "<rootDir>/src/",
74
+ "<rootDir>/node_modules/",
75
+ "<rootDir>/build/__tests__/testDirsAndFiles/"
76
+ ],
77
+ "testMatch": [
78
+ "**/__tests__/**/*.test.js?(x)"
79
+ ],
80
+ "moduleNameMapper": {
81
+ "^#spruce/(.*)$": "<rootDir>/build/.spruce/$1"
82
+ }
83
+ }
84
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "scriptUpdater": {
3
+ "skipped": []
4
+ },
5
+ "skipped": [
6
+ "skill"
7
+ ],
8
+ "installed": [
9
+ "test"
10
+ ]
11
+ }