@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.
- package/.nvmrc +1 -0
- package/.vscode/launch.json +58 -0
- package/.vscode/settings.json +67 -0
- package/.vscode/tasks.json +130 -0
- package/LICENSE +21 -0
- package/README.md +2 -0
- package/build/.spruce/settings.json +11 -0
- package/build/__tests__/AbstractPackageTest.d.ts +7 -0
- package/build/__tests__/AbstractPackageTest.js +14 -0
- package/build/__tests__/AbstractPackageTest.js.map +1 -0
- package/build/__tests__/impl/LabrecorderAdapter.test.d.ts +30 -0
- package/build/__tests__/impl/LabrecorderAdapter.test.js +164 -0
- package/build/__tests__/impl/LabrecorderAdapter.test.js.map +1 -0
- package/build/__tests__/impl/LiblslAdapter.test.d.ts +84 -0
- package/build/__tests__/impl/LiblslAdapter.test.js +750 -0
- package/build/__tests__/impl/LiblslAdapter.test.js.map +1 -0
- package/build/__tests__/impl/LibxdfAdapter.test.d.ts +45 -0
- package/build/__tests__/impl/LibxdfAdapter.test.js +243 -0
- package/build/__tests__/impl/LibxdfAdapter.test.js.map +1 -0
- package/build/consts.d.ts +11 -0
- package/build/consts.js +21 -0
- package/build/consts.js.map +1 -0
- package/build/impl/LabrecorderAdapter.d.ts +30 -0
- package/build/impl/LabrecorderAdapter.js +69 -0
- package/build/impl/LabrecorderAdapter.js.map +1 -0
- package/build/impl/LiblslAdapter.d.ts +172 -0
- package/build/impl/LiblslAdapter.js +360 -0
- package/build/impl/LiblslAdapter.js.map +1 -0
- package/build/impl/LibxdfAdapter.d.ts +92 -0
- package/build/impl/LibxdfAdapter.js +130 -0
- package/build/impl/LibxdfAdapter.js.map +1 -0
- package/build/index.d.ts +14 -0
- package/build/index.js +18 -0
- package/build/index.js.map +1 -0
- package/build/lib/handleError.d.ts +8 -0
- package/build/lib/handleError.js +25 -0
- package/build/lib/handleError.js.map +1 -0
- package/build/testDoubles/Labrecorder/FakeLabrecorder.d.ts +15 -0
- package/build/testDoubles/Labrecorder/FakeLabrecorder.js +26 -0
- package/build/testDoubles/Labrecorder/FakeLabrecorder.js.map +1 -0
- package/build/testDoubles/Liblsl/FakeLiblsl.d.ts +57 -0
- package/build/testDoubles/Liblsl/FakeLiblsl.js +140 -0
- package/build/testDoubles/Liblsl/FakeLiblsl.js.map +1 -0
- package/build/testDoubles/Libxdf/FakeLibxdf.d.ts +13 -0
- package/build/testDoubles/Libxdf/FakeLibxdf.js +25 -0
- package/build/testDoubles/Libxdf/FakeLibxdf.js.map +1 -0
- package/build/testDoubles/Libxdf/SpyLibxdf.d.ts +6 -0
- package/build/testDoubles/Libxdf/SpyLibxdf.js +10 -0
- package/build/testDoubles/Libxdf/SpyLibxdf.js.map +1 -0
- package/eslint.config.mjs +3 -0
- package/package.json +84 -0
- package/src/.spruce/settings.json +11 -0
- package/src/__tests__/AbstractPackageTest.ts +16 -0
- package/src/__tests__/impl/LabrecorderAdapter.test.ts +197 -0
- package/src/__tests__/impl/LiblslAdapter.test.ts +907 -0
- package/src/__tests__/impl/LibxdfAdapter.test.ts +290 -0
- package/src/consts.ts +21 -0
- package/src/impl/LabrecorderAdapter.ts +100 -0
- package/src/impl/LiblslAdapter.ts +616 -0
- package/src/impl/LibxdfAdapter.ts +227 -0
- package/src/index.ts +26 -0
- package/src/lib/handleError.ts +24 -0
- package/src/testDoubles/Labrecorder/FakeLabrecorder.ts +37 -0
- package/src/testDoubles/Liblsl/FakeLiblsl.ts +204 -0
- package/src/testDoubles/Libxdf/FakeLibxdf.ts +33 -0
- package/src/testDoubles/Libxdf/SpyLibxdf.ts +13 -0
- package/tsconfig.json +28 -0
package/.nvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
lts/*
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "0.2.0",
|
|
3
|
+
"configurations": [
|
|
4
|
+
{
|
|
5
|
+
"type": "node",
|
|
6
|
+
"request": "attach",
|
|
7
|
+
"name": "attach.tests",
|
|
8
|
+
"port": 5200,
|
|
9
|
+
"restart": true,
|
|
10
|
+
"timeout": 10000
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"type": "node",
|
|
14
|
+
"request": "launch",
|
|
15
|
+
"name": "test.file",
|
|
16
|
+
"runtimeExecutable": "node",
|
|
17
|
+
"runtimeArgs": [
|
|
18
|
+
"--inspect-brk",
|
|
19
|
+
"--trace-warnings",
|
|
20
|
+
"${workspaceFolder}/node_modules/.bin/jest",
|
|
21
|
+
"${fileBasenameNoExtension}",
|
|
22
|
+
"--detectOpenHandles"
|
|
23
|
+
],
|
|
24
|
+
"cwd": "${workspaceFolder}",
|
|
25
|
+
"console": "integratedTerminal",
|
|
26
|
+
"internalConsoleOptions": "neverOpen"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"type": "node",
|
|
30
|
+
"request": "launch",
|
|
31
|
+
"name": "test.all",
|
|
32
|
+
"runtimeExecutable": "node",
|
|
33
|
+
"runtimeArgs": [
|
|
34
|
+
"--inspect-brk",
|
|
35
|
+
"--trace-warnings",
|
|
36
|
+
"${workspaceFolder}/node_modules/.bin/jest"
|
|
37
|
+
],
|
|
38
|
+
"cwd": "${workspaceFolder}",
|
|
39
|
+
"console": "integratedTerminal",
|
|
40
|
+
"internalConsoleOptions": "neverOpen"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"type": "node",
|
|
44
|
+
"request": "launch",
|
|
45
|
+
"name": "boot",
|
|
46
|
+
"runtimeExecutable": "yarn",
|
|
47
|
+
"runtimeArgs": [
|
|
48
|
+
"run",
|
|
49
|
+
"--inspect-brk",
|
|
50
|
+
"--trace-warnings",
|
|
51
|
+
"boot"
|
|
52
|
+
],
|
|
53
|
+
"cwd": "${workspaceFolder}",
|
|
54
|
+
"console": "integratedTerminal",
|
|
55
|
+
"internalConsoleOptions": "neverOpen"
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"debug.node.autoAttach": "on",
|
|
3
|
+
"git.ignoreLimitWarning": true,
|
|
4
|
+
"javascript.validate.enable": false,
|
|
5
|
+
"files.watcherExclude": {
|
|
6
|
+
"**/.git/objects/**": true,
|
|
7
|
+
"**/.git/subtree-cache/**": true,
|
|
8
|
+
"**/build/**": true,
|
|
9
|
+
"**/node_modules/**": true,
|
|
10
|
+
},
|
|
11
|
+
"search.exclude": {
|
|
12
|
+
"**/build/**": true,
|
|
13
|
+
"**/node_modules/**": true,
|
|
14
|
+
"**/.next/**": true
|
|
15
|
+
},
|
|
16
|
+
"editor.maxTokenizationLineLength": 20000000,
|
|
17
|
+
"[javascript]": {
|
|
18
|
+
"editor.formatOnSave": false
|
|
19
|
+
},
|
|
20
|
+
"[javascriptreact]": {
|
|
21
|
+
"editor.formatOnSave": false
|
|
22
|
+
},
|
|
23
|
+
"[typescript]": {
|
|
24
|
+
"editor.formatOnSave": false
|
|
25
|
+
},
|
|
26
|
+
"[typescriptreact]": {
|
|
27
|
+
"editor.formatOnSave": false
|
|
28
|
+
},
|
|
29
|
+
"[handlebars]": {
|
|
30
|
+
"editor.formatOnSave": false
|
|
31
|
+
},
|
|
32
|
+
"typescript.tsdk": "node_modules/typescript/lib",
|
|
33
|
+
"cSpell.ignorePaths": [
|
|
34
|
+
"**/package-lock.json",
|
|
35
|
+
"**/node_modules/**",
|
|
36
|
+
"**/build/**",
|
|
37
|
+
"**/vscode-extension/**",
|
|
38
|
+
"**/.git/objects/**",
|
|
39
|
+
".vscode",
|
|
40
|
+
".spruce"
|
|
41
|
+
],
|
|
42
|
+
"cSpell.words": [
|
|
43
|
+
"arkit",
|
|
44
|
+
"autogenerated",
|
|
45
|
+
"scrollable",
|
|
46
|
+
"serializable"
|
|
47
|
+
],
|
|
48
|
+
"debug.javascript.unmapMissingSources": true,
|
|
49
|
+
"javascript.preferences.importModuleSpecifier": "relative",
|
|
50
|
+
"typescript.preferences.importModuleSpecifier": "relative",
|
|
51
|
+
"eslint.useFlatConfig": true,
|
|
52
|
+
"eslint.enable": true,
|
|
53
|
+
"eslint.validate": [
|
|
54
|
+
"javascript",
|
|
55
|
+
"javascriptreact",
|
|
56
|
+
"typescript",
|
|
57
|
+
"typescriptreact"
|
|
58
|
+
],
|
|
59
|
+
"eslint.workingDirectories": [
|
|
60
|
+
"./"
|
|
61
|
+
],
|
|
62
|
+
"typescript.validate.enable": true,
|
|
63
|
+
"editor.formatOnSave": false,
|
|
64
|
+
"editor.codeActionsOnSave": {
|
|
65
|
+
"source.fixAll.eslint": "always"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "2.0.0",
|
|
3
|
+
"tasks": [
|
|
4
|
+
{
|
|
5
|
+
"type": "npm",
|
|
6
|
+
"script": "watch.build.dev",
|
|
7
|
+
"group": "build",
|
|
8
|
+
"label": "watch.build.dev & problem.watcher",
|
|
9
|
+
"isBackground": true,
|
|
10
|
+
"runOptions": {
|
|
11
|
+
"runOn": "folderOpen"
|
|
12
|
+
},
|
|
13
|
+
"promptOnClose": false,
|
|
14
|
+
"presentation": {
|
|
15
|
+
"focus": false,
|
|
16
|
+
"reveal": "never"
|
|
17
|
+
},
|
|
18
|
+
"problemMatcher": {
|
|
19
|
+
"base": "$tsc-watch",
|
|
20
|
+
"applyTo": "allDocuments"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"label": "test.file",
|
|
25
|
+
"command": "spruce",
|
|
26
|
+
"args": [
|
|
27
|
+
"test",
|
|
28
|
+
"--inspect",
|
|
29
|
+
"5200",
|
|
30
|
+
"--pattern",
|
|
31
|
+
"${fileBasenameNoExtension}",
|
|
32
|
+
"--watchMode",
|
|
33
|
+
"standard"
|
|
34
|
+
],
|
|
35
|
+
"promptOnClose": false,
|
|
36
|
+
"group": {
|
|
37
|
+
"kind": "test",
|
|
38
|
+
"isDefault": true
|
|
39
|
+
},
|
|
40
|
+
"presentation": {
|
|
41
|
+
"reveal": "always",
|
|
42
|
+
"panel": "dedicated"
|
|
43
|
+
},
|
|
44
|
+
"problemMatcher": []
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"label": "test.reporter",
|
|
48
|
+
"command": "spruce",
|
|
49
|
+
"args": [
|
|
50
|
+
"test",
|
|
51
|
+
"--shouldHoldAtStart",
|
|
52
|
+
"true",
|
|
53
|
+
"--watchMode",
|
|
54
|
+
"smart"
|
|
55
|
+
],
|
|
56
|
+
"promptOnClose": false,
|
|
57
|
+
"group": "test",
|
|
58
|
+
"runOptions": {
|
|
59
|
+
"runOn": "folderOpen"
|
|
60
|
+
},
|
|
61
|
+
"presentation": {
|
|
62
|
+
"panel": "shared",
|
|
63
|
+
"focus": true,
|
|
64
|
+
"reveal": "always"
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"label": "spruce",
|
|
69
|
+
"type": "shell",
|
|
70
|
+
"command": "spruce ${input:spruceCommand}",
|
|
71
|
+
"problemMatcher": [],
|
|
72
|
+
"presentation": {
|
|
73
|
+
"reveal": "always",
|
|
74
|
+
"focus": true,
|
|
75
|
+
"panel": "new",
|
|
76
|
+
"clear": false
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"label": "shell",
|
|
81
|
+
"type": "shell",
|
|
82
|
+
"command": "${input:command} ${input:optionsCommand}",
|
|
83
|
+
"problemMatcher": [],
|
|
84
|
+
"presentation": {
|
|
85
|
+
"reveal": "always",
|
|
86
|
+
"focus": true,
|
|
87
|
+
"panel": "new",
|
|
88
|
+
"clear": false
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"label": "ndx",
|
|
93
|
+
"type": "shell",
|
|
94
|
+
"command": "ndx ${input:ndxCommand}",
|
|
95
|
+
"problemMatcher": [],
|
|
96
|
+
"presentation": {
|
|
97
|
+
"reveal": "always",
|
|
98
|
+
"focus": true,
|
|
99
|
+
"panel": "new",
|
|
100
|
+
"clear": false
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
"inputs": [
|
|
105
|
+
{
|
|
106
|
+
"id": "spruceCommand",
|
|
107
|
+
"description": "spruce command",
|
|
108
|
+
"default": "create.test",
|
|
109
|
+
"type": "promptString"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"id": "command",
|
|
113
|
+
"description": "command",
|
|
114
|
+
"default": "yarn",
|
|
115
|
+
"type": "promptString"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"id": "optionsCommand",
|
|
119
|
+
"description": "optionsCommand",
|
|
120
|
+
"default": "add",
|
|
121
|
+
"type": "promptString"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"id": "ndxCommand",
|
|
125
|
+
"description": "ndx command",
|
|
126
|
+
"default": "create.module",
|
|
127
|
+
"type": "promptString"
|
|
128
|
+
}
|
|
129
|
+
]
|
|
130
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 neurodevs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import AbstractModuleTest from '@neurodevs/node-tdd';
|
|
2
|
+
export default abstract class AbstractPackageTest extends AbstractModuleTest {
|
|
3
|
+
protected static readonly channelNames: string[];
|
|
4
|
+
protected static readonly channelCount: number;
|
|
5
|
+
protected static readonly chunkSize = 2;
|
|
6
|
+
protected static beforeEach(): Promise<void>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import AbstractModuleTest from '@neurodevs/node-tdd';
|
|
2
|
+
export default class AbstractPackageTest extends AbstractModuleTest {
|
|
3
|
+
static channelNames = [
|
|
4
|
+
this.generateId(),
|
|
5
|
+
this.generateId(),
|
|
6
|
+
this.generateId(),
|
|
7
|
+
];
|
|
8
|
+
static channelCount = this.channelNames.length;
|
|
9
|
+
static chunkSize = 2;
|
|
10
|
+
static async beforeEach() {
|
|
11
|
+
await super.beforeEach();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=AbstractPackageTest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractPackageTest.js","sourceRoot":"","sources":["../../src/__tests__/AbstractPackageTest.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,qBAAqB,CAAA;AAEpD,MAAM,CAAC,OAAO,OAAgB,mBAAoB,SAAQ,kBAAkB;IAC9D,MAAM,CAAU,YAAY,GAAG;QACrC,IAAI,CAAC,UAAU,EAAE;QACjB,IAAI,CAAC,UAAU,EAAE;QACjB,IAAI,CAAC,UAAU,EAAE;KACpB,CAAA;IAES,MAAM,CAAU,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,CAAA;IACvD,MAAM,CAAU,SAAS,GAAG,CAAC,CAAA;IAE7B,MAAM,CAAC,KAAK,CAAC,UAAU;QAC7B,MAAM,KAAK,CAAC,UAAU,EAAE,CAAA;IAC5B,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import AbstractPackageTest from '../AbstractPackageTest.js';
|
|
2
|
+
export default class LabrecorderAdapterTest extends AbstractPackageTest {
|
|
3
|
+
private static instance;
|
|
4
|
+
private static fakeBindings;
|
|
5
|
+
private static ffiRsOpenOptions?;
|
|
6
|
+
private static ffiRsDefineOptions?;
|
|
7
|
+
private static callsToRecordingCreate;
|
|
8
|
+
private static callsToRecordingStop;
|
|
9
|
+
private static callsToRecordingDelete;
|
|
10
|
+
private static readonly filename;
|
|
11
|
+
private static readonly watchFor;
|
|
12
|
+
protected static beforeEach(): Promise<void>;
|
|
13
|
+
protected static canCreateLabrecorderAdapter(): Promise<void>;
|
|
14
|
+
protected static callsFfiRsOpenWithRequiredOptions(): Promise<void>;
|
|
15
|
+
protected static callsFfiRsDefineWithRequiredOptions(): Promise<void>;
|
|
16
|
+
protected static createRecordingCallsBindings(): Promise<void>;
|
|
17
|
+
protected static defaultsToMacOsPath(): Promise<void>;
|
|
18
|
+
protected static stopRecordingCallsBindings(): Promise<void>;
|
|
19
|
+
protected static deleteRecordingCallsBindings(): Promise<void>;
|
|
20
|
+
private static createAndDeleteRecording;
|
|
21
|
+
private static createRecording;
|
|
22
|
+
private static stopRecording;
|
|
23
|
+
private static deleteRecording;
|
|
24
|
+
private static setupFakeBindings;
|
|
25
|
+
private static fakeFfiRsOpen;
|
|
26
|
+
private static fakeFfiRsDefine;
|
|
27
|
+
private static readonly labrecorderPath;
|
|
28
|
+
private static FakeBindings;
|
|
29
|
+
private static LabrecorderAdapter;
|
|
30
|
+
}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import generateId from '@neurodevs/generate-id';
|
|
8
|
+
import { test, assert } from '@neurodevs/node-tdd';
|
|
9
|
+
import { DataType } from 'ffi-rs';
|
|
10
|
+
import LabrecorderAdapter from '../../impl/LabrecorderAdapter.js';
|
|
11
|
+
import AbstractPackageTest from '../AbstractPackageTest.js';
|
|
12
|
+
export default class LabrecorderAdapterTest extends AbstractPackageTest {
|
|
13
|
+
static instance;
|
|
14
|
+
static fakeBindings;
|
|
15
|
+
static ffiRsOpenOptions;
|
|
16
|
+
static ffiRsDefineOptions;
|
|
17
|
+
static callsToRecordingCreate = [];
|
|
18
|
+
static callsToRecordingStop = [];
|
|
19
|
+
static callsToRecordingDelete = [];
|
|
20
|
+
static filename = generateId();
|
|
21
|
+
static watchFor = [generateId(), generateId()];
|
|
22
|
+
static async beforeEach() {
|
|
23
|
+
await super.beforeEach();
|
|
24
|
+
this.setupFakeBindings();
|
|
25
|
+
this.fakeFfiRsOpen();
|
|
26
|
+
this.fakeFfiRsDefine();
|
|
27
|
+
this.instance = this.LabrecorderAdapter();
|
|
28
|
+
}
|
|
29
|
+
static async canCreateLabrecorderAdapter() {
|
|
30
|
+
assert.isTruthy(this.instance, 'Should create an instance!');
|
|
31
|
+
}
|
|
32
|
+
static async callsFfiRsOpenWithRequiredOptions() {
|
|
33
|
+
assert.isEqualDeep(this.ffiRsOpenOptions, {
|
|
34
|
+
library: 'labrecorder',
|
|
35
|
+
path: this.labrecorderPath,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
static async callsFfiRsDefineWithRequiredOptions() {
|
|
39
|
+
this.LabrecorderAdapter();
|
|
40
|
+
assert.isEqualDeep(this.ffiRsDefineOptions, {
|
|
41
|
+
recording_create: {
|
|
42
|
+
library: 'labrecorder',
|
|
43
|
+
retType: DataType.External, // Pointer to the recording object
|
|
44
|
+
paramsType: [
|
|
45
|
+
DataType.String, // filename
|
|
46
|
+
DataType.StringArray, // watchfor
|
|
47
|
+
DataType.U64, // watchfor_count
|
|
48
|
+
],
|
|
49
|
+
},
|
|
50
|
+
recording_stop: {
|
|
51
|
+
library: 'labrecorder',
|
|
52
|
+
retType: DataType.Void,
|
|
53
|
+
paramsType: [
|
|
54
|
+
DataType.External, // Pointer to the recording object
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
recording_delete: {
|
|
58
|
+
library: 'labrecorder',
|
|
59
|
+
retType: DataType.Void,
|
|
60
|
+
paramsType: [
|
|
61
|
+
DataType.External, // Pointer to the recording object
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
}, 'Please pass valid options to ffiRsDefine!');
|
|
65
|
+
}
|
|
66
|
+
static async createRecordingCallsBindings() {
|
|
67
|
+
this.createRecording();
|
|
68
|
+
assert.isEqualDeep(this.callsToRecordingCreate[0], {
|
|
69
|
+
filename: this.filename,
|
|
70
|
+
watchFor: this.watchFor,
|
|
71
|
+
watchForCount: this.watchFor.length,
|
|
72
|
+
}, 'Should create a recording!');
|
|
73
|
+
}
|
|
74
|
+
static async defaultsToMacOsPath() {
|
|
75
|
+
const defaultLabrecorderPath = '/opt/local/lib/liblabrecorder.dylib';
|
|
76
|
+
LabrecorderAdapter.Create();
|
|
77
|
+
const { path } = this.ffiRsOpenOptions ?? {};
|
|
78
|
+
assert.isEqual(path, defaultLabrecorderPath);
|
|
79
|
+
}
|
|
80
|
+
static async stopRecordingCallsBindings() {
|
|
81
|
+
const recording = this.createRecording();
|
|
82
|
+
this.stopRecording(recording);
|
|
83
|
+
assert.isEqualDeep(this.callsToRecordingStop[0], recording);
|
|
84
|
+
}
|
|
85
|
+
static async deleteRecordingCallsBindings() {
|
|
86
|
+
const recording = this.createAndDeleteRecording();
|
|
87
|
+
assert.isEqualDeep(this.callsToRecordingDelete[0], recording);
|
|
88
|
+
}
|
|
89
|
+
static createAndDeleteRecording() {
|
|
90
|
+
const recording = this.createRecording();
|
|
91
|
+
this.deleteRecording(recording);
|
|
92
|
+
return recording;
|
|
93
|
+
}
|
|
94
|
+
static createRecording() {
|
|
95
|
+
return this.instance.createRecording(this.filename, this.watchFor);
|
|
96
|
+
}
|
|
97
|
+
static stopRecording(recording) {
|
|
98
|
+
this.instance.stopRecording(recording);
|
|
99
|
+
}
|
|
100
|
+
static deleteRecording(recording) {
|
|
101
|
+
this.instance.deleteRecording(recording);
|
|
102
|
+
}
|
|
103
|
+
static setupFakeBindings() {
|
|
104
|
+
this.fakeBindings = this.FakeBindings();
|
|
105
|
+
}
|
|
106
|
+
static fakeFfiRsOpen() {
|
|
107
|
+
LabrecorderAdapter.ffiRsOpen = (options) => {
|
|
108
|
+
this.ffiRsOpenOptions = options;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
static fakeFfiRsDefine() {
|
|
112
|
+
LabrecorderAdapter.ffiRsDefine = (options) => {
|
|
113
|
+
this.ffiRsDefineOptions = options;
|
|
114
|
+
return this.fakeBindings;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
static labrecorderPath = generateId();
|
|
118
|
+
static FakeBindings() {
|
|
119
|
+
this.callsToRecordingCreate = [];
|
|
120
|
+
this.callsToRecordingStop = [];
|
|
121
|
+
this.callsToRecordingDelete = [];
|
|
122
|
+
return {
|
|
123
|
+
recording_create: ([filename, watchFor, watchForCount]) => {
|
|
124
|
+
this.callsToRecordingCreate.push({
|
|
125
|
+
filename,
|
|
126
|
+
watchFor,
|
|
127
|
+
watchForCount,
|
|
128
|
+
});
|
|
129
|
+
return {};
|
|
130
|
+
},
|
|
131
|
+
recording_stop: ([recording]) => {
|
|
132
|
+
this.callsToRecordingStop.push(recording);
|
|
133
|
+
},
|
|
134
|
+
recording_delete: ([recording]) => {
|
|
135
|
+
this.callsToRecordingDelete.push(recording);
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
static LabrecorderAdapter(labrecorderPath) {
|
|
140
|
+
return LabrecorderAdapter.Create(labrecorderPath ?? this.labrecorderPath);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
__decorate([
|
|
144
|
+
test()
|
|
145
|
+
], LabrecorderAdapterTest, "canCreateLabrecorderAdapter", null);
|
|
146
|
+
__decorate([
|
|
147
|
+
test()
|
|
148
|
+
], LabrecorderAdapterTest, "callsFfiRsOpenWithRequiredOptions", null);
|
|
149
|
+
__decorate([
|
|
150
|
+
test()
|
|
151
|
+
], LabrecorderAdapterTest, "callsFfiRsDefineWithRequiredOptions", null);
|
|
152
|
+
__decorate([
|
|
153
|
+
test()
|
|
154
|
+
], LabrecorderAdapterTest, "createRecordingCallsBindings", null);
|
|
155
|
+
__decorate([
|
|
156
|
+
test()
|
|
157
|
+
], LabrecorderAdapterTest, "defaultsToMacOsPath", null);
|
|
158
|
+
__decorate([
|
|
159
|
+
test()
|
|
160
|
+
], LabrecorderAdapterTest, "stopRecordingCallsBindings", null);
|
|
161
|
+
__decorate([
|
|
162
|
+
test()
|
|
163
|
+
], LabrecorderAdapterTest, "deleteRecordingCallsBindings", null);
|
|
164
|
+
//# sourceMappingURL=LabrecorderAdapter.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LabrecorderAdapter.test.js","sourceRoot":"","sources":["../../../src/__tests__/impl/LabrecorderAdapter.test.ts"],"names":[],"mappings":";;;;;;AAAA,O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IACL,CAAC;;AA3JsB;IADtB,IAAI,EAAE;+DAGN;AAGsB;IADtB,IAAI,EAAE;qEAMN;AAGsB;IADtB,IAAI,EAAE;uEAiCN;AAGsB;IADtB,IAAI,EAAE;gEAaN;AAGsB;IADtB,IAAI,EAAE;uDAQN;AAGsB;IADtB,IAAI,EAAE;8DAMN;AAGsB;IADtB,IAAI,EAAE;gEAKN"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { FieldType, FuncObj } from 'ffi-rs';
|
|
2
|
+
import AbstractPackageTest from '../AbstractPackageTest.js';
|
|
3
|
+
export default class LiblslAdapterTest extends AbstractPackageTest {
|
|
4
|
+
private static instance;
|
|
5
|
+
private static libraryPath?;
|
|
6
|
+
private static libraryOptions?;
|
|
7
|
+
private static fakeBindings;
|
|
8
|
+
private static shouldThrowWhenCreatingBindings;
|
|
9
|
+
private static fakeInfoHandle;
|
|
10
|
+
private static fakeOutletHandle;
|
|
11
|
+
private static fakeInletHandle;
|
|
12
|
+
private static fakeDescHandle;
|
|
13
|
+
private static fakeChildHandle;
|
|
14
|
+
private static fakeChildNamedChannel;
|
|
15
|
+
private static createStreamInfoParams?;
|
|
16
|
+
private static destroyStreamInfoParams?;
|
|
17
|
+
private static appendChildParams;
|
|
18
|
+
private static appendChildValueParams;
|
|
19
|
+
private static appendChildHitCount;
|
|
20
|
+
private static getDescriptionParams?;
|
|
21
|
+
private static getChannelCountParams?;
|
|
22
|
+
private static createOutletParams?;
|
|
23
|
+
private static pushSampleFloatTimestampParams?;
|
|
24
|
+
private static pushSampleStringTimestampParams?;
|
|
25
|
+
private static destroyOutletParams?;
|
|
26
|
+
private static createInletParams?;
|
|
27
|
+
private static flushInletParams?;
|
|
28
|
+
private static destroyInletParams?;
|
|
29
|
+
private static localClockParams?;
|
|
30
|
+
private static ffiRsOpenOptions?;
|
|
31
|
+
private static ffiRsDefineOptions;
|
|
32
|
+
private static ffiRsLoadOptions?;
|
|
33
|
+
protected static beforeEach(): Promise<void>;
|
|
34
|
+
protected static createsInstance(): Promise<void>;
|
|
35
|
+
protected static throwsWhenBindingsFailToLoad(): Promise<void>;
|
|
36
|
+
protected static callsOpenOnFfiRs(): Promise<void>;
|
|
37
|
+
protected static worksAsASingleton(): Promise<void>;
|
|
38
|
+
protected static singletonIsTheSame(): Promise<void>;
|
|
39
|
+
protected static canSetInstance(): void;
|
|
40
|
+
protected static createsExpectedBindingsWithFfiRs(): Promise<void>;
|
|
41
|
+
protected static createsStreamInfoWithRequiredParams(): Promise<void>;
|
|
42
|
+
protected static destroyStreamInfoPasses(): Promise<void>;
|
|
43
|
+
protected static resolvesStreamInfoByProp(): Promise<void>;
|
|
44
|
+
protected static resolveByPropAcceptsOptionalArgs(): Promise<void>;
|
|
45
|
+
protected static returnsHandlesForResolvedStreamInfos(): Promise<void>;
|
|
46
|
+
protected static createsOutletWithRequiredParams(): Promise<void>;
|
|
47
|
+
protected static pushesFloatSample(): Promise<void>;
|
|
48
|
+
protected static pushesStringSample(): Promise<void>;
|
|
49
|
+
protected static addingSingleChannelGetsDescription(): Promise<void>;
|
|
50
|
+
protected static addingMultpleChannelsAddsChildrenToChannelsChild(): Promise<void>;
|
|
51
|
+
protected static canDestroyOutlet(): Promise<void>;
|
|
52
|
+
protected static callingLocalClockTwiceReturnsDifferentTimestamps(): Promise<void>;
|
|
53
|
+
protected static localClockBindingReceivesEmptyArray(): Promise<void>;
|
|
54
|
+
protected static defaultsToMacOsPath(): Promise<void>;
|
|
55
|
+
protected static createInletWithRequiredParams(): Promise<void>;
|
|
56
|
+
protected static getsChannelCountFromInfoHandle(): Promise<void>;
|
|
57
|
+
protected static openStreamCallsBinding(): Promise<void>;
|
|
58
|
+
protected static closeStreamCallsBinding(): Promise<void>;
|
|
59
|
+
protected static pullSampleCallsBinding(): Promise<void>;
|
|
60
|
+
protected static pullChunkCallsBinding(): Promise<void>;
|
|
61
|
+
protected static flushInletCallsBinding(): Promise<void>;
|
|
62
|
+
protected static destroyInletCallsBinding(): Promise<void>;
|
|
63
|
+
private static createRandomInfoHandle;
|
|
64
|
+
private static resolveByProp;
|
|
65
|
+
private static createRandomOutlet;
|
|
66
|
+
private static createRandomOutletOptions;
|
|
67
|
+
private static createRandomInlet;
|
|
68
|
+
private static createRandomInletOptions;
|
|
69
|
+
private static generateRandomChannelValues;
|
|
70
|
+
private static generateRandomCreateStreamInfoOptions;
|
|
71
|
+
private static readonly maxResults;
|
|
72
|
+
private static readonly bytesPerPointer;
|
|
73
|
+
private static readonly minResults;
|
|
74
|
+
private static readonly timeoutMs;
|
|
75
|
+
private static readonly prop;
|
|
76
|
+
private static readonly value;
|
|
77
|
+
private static readonly fakeNumResolveResults;
|
|
78
|
+
private static readonly resultsBuffer;
|
|
79
|
+
private static readonly resultsBufferRef;
|
|
80
|
+
private static readonly resultsBufferPtr;
|
|
81
|
+
private static generateFailedMessage;
|
|
82
|
+
private static FakeBindings;
|
|
83
|
+
}
|
|
84
|
+
export type FfiRsDefineOptions = FuncObj<FieldType, boolean | undefined>;
|