@twilio/video-node-sdk 1.0.0-rc.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/CHANGELOG.md +389 -0
- package/FRAME_CONTRACT.md +204 -0
- package/LICENSE.md +3 -0
- package/LIFECYCLE.md +123 -0
- package/README.md +609 -0
- package/dist/index.cjs +1821 -0
- package/dist/index.d.cts +1671 -0
- package/dist/index.d.mts +1671 -0
- package/dist/index.mjs +1739 -0
- package/package.json +116 -0
- package/scripts/common.js +66 -0
- package/scripts/install.js +95 -0
package/package.json
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@twilio/video-node-sdk",
|
|
3
|
+
"version": "1.0.0-rc.1",
|
|
4
|
+
"description": "Twilio Video Media Streams SDK for Node.js - Server-side access to decoded video/audio frames",
|
|
5
|
+
"homepage": "https://github.com/twilio/twilio-video-node#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/twilio/twilio-video-node/issues"
|
|
8
|
+
},
|
|
9
|
+
"main": "dist/index.cjs",
|
|
10
|
+
"module": "dist/index.mjs",
|
|
11
|
+
"types": "dist/index.d.cts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"import": {
|
|
15
|
+
"types": "./dist/index.d.mts",
|
|
16
|
+
"default": "./dist/index.mjs"
|
|
17
|
+
},
|
|
18
|
+
"require": {
|
|
19
|
+
"types": "./dist/index.d.cts",
|
|
20
|
+
"default": "./dist/index.cjs"
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"install": "node scripts/install.js",
|
|
26
|
+
"build": "node scripts/build.js",
|
|
27
|
+
"build:debug": "cmake-js build --debug",
|
|
28
|
+
"build:release": "cmake-js build --CDCMAKE_BUILD_TYPE=Release",
|
|
29
|
+
"rebuild": "cmake-js rebuild",
|
|
30
|
+
"clean": "cmake-js clean",
|
|
31
|
+
"package": "node scripts/prebuild.js",
|
|
32
|
+
"upload": "node scripts/upload.js",
|
|
33
|
+
"upload:darwin": "node scripts/upload.js darwin-x64",
|
|
34
|
+
"upload:linux": "node scripts/upload.js linux-x64",
|
|
35
|
+
"fetch-deps": "node scripts/fetch-deps.js",
|
|
36
|
+
"build:ts": "tsdown",
|
|
37
|
+
"docs": "typedoc",
|
|
38
|
+
"test": "vitest run",
|
|
39
|
+
"test:unit": "vitest run --exclude '**/integration.test.ts' --exclude '**/node_modules/**'",
|
|
40
|
+
"test:integration": "vitest run test/integration.test.ts",
|
|
41
|
+
"test:coverage": "vitest run --coverage --exclude '**/integration.test.ts' --exclude '**/node_modules/**'",
|
|
42
|
+
"lint": "eslint .",
|
|
43
|
+
"format": "prettier --write .",
|
|
44
|
+
"format:check": "prettier --check .",
|
|
45
|
+
"prepare": "husky",
|
|
46
|
+
"test:unit:pure": "vitest run test/frame_stream.test.ts test/remote_track.test.ts test/errors.test.ts test/room.test.ts test/participant.test.ts",
|
|
47
|
+
"typecheck": "tsc --noEmit -p tsconfig.test.json",
|
|
48
|
+
"test:soak": "node test/soak.mjs",
|
|
49
|
+
"typecheck:examples": "tsc --noEmit -p examples/tsconfig.json",
|
|
50
|
+
"check:examples": "node --check examples/audio_push.js && node --check examples/data_channel.js && node --check examples/video_mirror.js && node --check examples/virtual_camera.js && node --check examples/voice_agent.js && node --check examples/cv_object_detection.js && node --check examples/cv_face_analysis.js && node --check examples/helpers/cv-runner.js && node --check examples/helpers/cv-postprocess.js && node --check examples/helpers/draw.js && node --check examples/helpers/onnx-model.js && npm run typecheck:examples"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@eslint/js": "^10.0.1",
|
|
54
|
+
"@types/node": "^22.0.0",
|
|
55
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
56
|
+
"cmake-js": "^7.3.0",
|
|
57
|
+
"eslint": "^10.0.2",
|
|
58
|
+
"husky": "^9.1.7",
|
|
59
|
+
"lint-staged": "^16.2.7",
|
|
60
|
+
"node-addon-api": "^8.0.0",
|
|
61
|
+
"prettier": "^3.8.1",
|
|
62
|
+
"tsdown": "^0.21.1",
|
|
63
|
+
"twilio": "^5.12.1",
|
|
64
|
+
"typedoc": "^0.28.20",
|
|
65
|
+
"typescript": "^5.0.0",
|
|
66
|
+
"typescript-eslint": "^8.57.0",
|
|
67
|
+
"vitest": "^4.0.18"
|
|
68
|
+
},
|
|
69
|
+
"files": [
|
|
70
|
+
"dist",
|
|
71
|
+
"prebuilds",
|
|
72
|
+
"scripts/install.js",
|
|
73
|
+
"scripts/common.js",
|
|
74
|
+
"package.json",
|
|
75
|
+
"CHANGELOG.md",
|
|
76
|
+
"FRAME_CONTRACT.md",
|
|
77
|
+
"LIFECYCLE.md"
|
|
78
|
+
],
|
|
79
|
+
"engines": {
|
|
80
|
+
"node": ">=24.0.0"
|
|
81
|
+
},
|
|
82
|
+
"os": [
|
|
83
|
+
"darwin",
|
|
84
|
+
"linux"
|
|
85
|
+
],
|
|
86
|
+
"cpu": [
|
|
87
|
+
"x64"
|
|
88
|
+
],
|
|
89
|
+
"keywords": [
|
|
90
|
+
"twilio",
|
|
91
|
+
"video",
|
|
92
|
+
"webrtc",
|
|
93
|
+
"media-streams",
|
|
94
|
+
"real-time",
|
|
95
|
+
"rooms",
|
|
96
|
+
"nodejs",
|
|
97
|
+
"media",
|
|
98
|
+
"audio",
|
|
99
|
+
"frames",
|
|
100
|
+
"napi"
|
|
101
|
+
],
|
|
102
|
+
"lint-staged": {
|
|
103
|
+
"*.{js,mjs,ts}": [
|
|
104
|
+
"prettier --write",
|
|
105
|
+
"eslint --fix"
|
|
106
|
+
],
|
|
107
|
+
"*.{json,md,yml,yaml}": [
|
|
108
|
+
"prettier --write"
|
|
109
|
+
]
|
|
110
|
+
},
|
|
111
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
112
|
+
"repository": {
|
|
113
|
+
"type": "git",
|
|
114
|
+
"url": "https://github.com/twilio/twilio-video-node.git"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
|
|
5
|
+
const ADDON_NAME = 'twilio_video_sdk_node.node';
|
|
6
|
+
const ROOT = path.join(__dirname, '..');
|
|
7
|
+
|
|
8
|
+
function getPlatformDir(override) {
|
|
9
|
+
if (override) {
|
|
10
|
+
return override;
|
|
11
|
+
}
|
|
12
|
+
return `${process.platform}-${process.arch}`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Platforms the native addon is built for, derived from the `os` and `cpu`
|
|
17
|
+
* fields npm enforces at install time. Derived rather than restated so this
|
|
18
|
+
* cannot drift from what the package declares; lib/index.ts derives the same
|
|
19
|
+
* list for its runtime check.
|
|
20
|
+
*/
|
|
21
|
+
function getSupportedPlatforms(pkg) {
|
|
22
|
+
return (pkg.os || ['darwin', 'linux']).flatMap(o => (pkg.cpu || ['x64']).map(c => `${o}-${c}`));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function getPrebuiltName(platformDir) {
|
|
26
|
+
return `${ADDON_NAME.replace('.node', '')}-${platformDir}.node`;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function getPrebuiltPath(platformDir) {
|
|
30
|
+
return path.join(ROOT, 'prebuilds', platformDir, getPrebuiltName(platformDir));
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getGitHubInfo(pkg) {
|
|
34
|
+
let repoUrl = process.env.GITHUB_REPOSITORY || pkg.repository?.url;
|
|
35
|
+
if (!repoUrl) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
repoUrl = repoUrl.replace(/^git\+/, '').replace(/\.git$/, '');
|
|
40
|
+
const match = repoUrl.match(/https?:\/\/([^/]+)\/(.+)$/);
|
|
41
|
+
if (!match) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
host: match[1],
|
|
47
|
+
repo: match[2],
|
|
48
|
+
version: pkg.version,
|
|
49
|
+
tag: pkg.version,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function log(prefix, msg) {
|
|
54
|
+
console.log(`[${prefix}] ${msg}`);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module.exports = {
|
|
58
|
+
ADDON_NAME,
|
|
59
|
+
ROOT,
|
|
60
|
+
getPlatformDir,
|
|
61
|
+
getPrebuiltName,
|
|
62
|
+
getPrebuiltPath,
|
|
63
|
+
getSupportedPlatforms,
|
|
64
|
+
getGitHubInfo,
|
|
65
|
+
log,
|
|
66
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
'use strict';
|
|
4
|
+
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const { execFileSync } = require('child_process');
|
|
8
|
+
const {
|
|
9
|
+
ADDON_NAME,
|
|
10
|
+
ROOT,
|
|
11
|
+
getPlatformDir,
|
|
12
|
+
getPrebuiltPath,
|
|
13
|
+
getPrebuiltName,
|
|
14
|
+
getSupportedPlatforms,
|
|
15
|
+
getGitHubInfo,
|
|
16
|
+
log,
|
|
17
|
+
} = require('./common');
|
|
18
|
+
|
|
19
|
+
const platformDir = getPlatformDir();
|
|
20
|
+
const prebuiltPath = getPrebuiltPath(platformDir);
|
|
21
|
+
const releasePath = path.join(ROOT, 'build', 'Release', ADDON_NAME);
|
|
22
|
+
const debugPath = path.join(ROOT, 'build', 'Debug', ADDON_NAME);
|
|
23
|
+
|
|
24
|
+
function exit(msg, code = 1) {
|
|
25
|
+
console.error(`[install] ${msg}`);
|
|
26
|
+
process.exit(code);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (process.env.TWILIO_VIDEO_NODE_SKIP_DOWNLOAD === '1') {
|
|
30
|
+
log('install', 'Skipping download (TWILIO_VIDEO_NODE_SKIP_DOWNLOAD=1)');
|
|
31
|
+
process.exit(0);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (fs.existsSync(prebuiltPath)) {
|
|
35
|
+
log('install', `Prebuilt found: ${prebuiltPath}`);
|
|
36
|
+
process.exit(0);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (fs.existsSync(releasePath) || fs.existsSync(debugPath)) {
|
|
40
|
+
log('install', 'Local build found, skipping download');
|
|
41
|
+
process.exit(0);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const pkg = require(path.join(ROOT, 'package.json'));
|
|
45
|
+
|
|
46
|
+
if (process.env.TWILIO_VIDEO_NODE_ALLOW_GH_DOWNLOAD !== '1') {
|
|
47
|
+
exit(
|
|
48
|
+
`No prebuilt binary for ${platformDir} in this package. ` +
|
|
49
|
+
'This SDK supports linux-x64; the addon can also be built for ' +
|
|
50
|
+
`${getSupportedPlatforms(pkg).join(', ')} ` +
|
|
51
|
+
'(there is no arm64 build, so on Apple Silicon run Node under Rosetta with ' +
|
|
52
|
+
'`arch -x86_64 node`). Contact the Twilio Video team for access to other platforms.',
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const ghInfo = getGitHubInfo(pkg);
|
|
57
|
+
|
|
58
|
+
if (!ghInfo) {
|
|
59
|
+
exit('No repository info. Set GITHUB_REPOSITORY or add repository field to package.json');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const assetName = getPrebuiltName(platformDir);
|
|
63
|
+
const repo = `${ghInfo.host}/${ghInfo.repo}`;
|
|
64
|
+
|
|
65
|
+
log('install', `Downloading ${assetName} from ${repo} ${ghInfo.tag}...`);
|
|
66
|
+
|
|
67
|
+
fs.mkdirSync(path.dirname(prebuiltPath), { recursive: true });
|
|
68
|
+
|
|
69
|
+
try {
|
|
70
|
+
execFileSync(
|
|
71
|
+
'gh',
|
|
72
|
+
[
|
|
73
|
+
'release',
|
|
74
|
+
'download',
|
|
75
|
+
ghInfo.tag,
|
|
76
|
+
'--repo',
|
|
77
|
+
repo,
|
|
78
|
+
'--pattern',
|
|
79
|
+
assetName,
|
|
80
|
+
'--dir',
|
|
81
|
+
path.dirname(prebuiltPath),
|
|
82
|
+
],
|
|
83
|
+
{ stdio: ['ignore', 'pipe', 'pipe'] },
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
if (!fs.existsSync(prebuiltPath)) {
|
|
87
|
+
exit(`Asset ${assetName} not found in release ${ghInfo.tag}`);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const size = fs.statSync(prebuiltPath).size;
|
|
91
|
+
log('install', `Downloaded ${(size / 1024 / 1024).toFixed(1)} MB`);
|
|
92
|
+
} catch (err) {
|
|
93
|
+
const stderr = err.stderr?.toString() || err.message;
|
|
94
|
+
exit(`Download failed: ${stderr.trim()}`);
|
|
95
|
+
}
|