@digipair/skill-web-heygen 0.90.0 → 0.91.0-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.
- package/.swcrc +28 -0
- package/README.md +7 -0
- package/eslint.config.mjs +22 -0
- package/package.json +21 -5
- package/rollup.config.cjs +28 -0
- package/src/lib/skill-web-heygen.spec.ts +7 -0
- package/src/lib/skill-web-heygen.ts +87 -0
- package/tsconfig.json +13 -0
- package/tsconfig.lib.json +19 -0
- package/index.cjs.d.ts +0 -1
- package/index.cjs.js +0 -2062
- package/index.esm.js +0 -2058
- package/libs/skill-web-heygen/src/lib/skill-web-heygen.d.ts +0 -13
- /package/{index.d.ts → src/index.d.ts} +0 -0
- /package/{libs/skill-web-heygen/src/index.d.ts → src/index.ts} +0 -0
- /package/{schema.fr.json → src/schema.fr.json} +0 -0
- /package/{schema.json → src/schema.json} +0 -0
package/.swcrc
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
{
|
2
|
+
"jsc": {
|
3
|
+
"target": "es2017",
|
4
|
+
"parser": {
|
5
|
+
"syntax": "typescript",
|
6
|
+
"decorators": true,
|
7
|
+
"dynamicImport": true
|
8
|
+
},
|
9
|
+
"transform": {
|
10
|
+
"decoratorMetadata": true,
|
11
|
+
"legacyDecorator": true
|
12
|
+
},
|
13
|
+
"keepClassNames": true,
|
14
|
+
"externalHelpers": true,
|
15
|
+
"loose": true
|
16
|
+
},
|
17
|
+
"module": {
|
18
|
+
"type": "es6"
|
19
|
+
},
|
20
|
+
"sourceMaps": true,
|
21
|
+
"exclude": [
|
22
|
+
"jest.config.ts",
|
23
|
+
".*\\.spec.tsx?$",
|
24
|
+
".*\\.test.tsx?$",
|
25
|
+
"./src/jest-setup.ts$",
|
26
|
+
"./**/jest-setup.ts$"
|
27
|
+
]
|
28
|
+
}
|
package/README.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
import baseConfig from '../../eslint.config.mjs';
|
2
|
+
|
3
|
+
export default [
|
4
|
+
...baseConfig,
|
5
|
+
{
|
6
|
+
files: ['**/*.json'],
|
7
|
+
rules: {
|
8
|
+
'@nx/dependency-checks': [
|
9
|
+
'error',
|
10
|
+
{
|
11
|
+
ignoredFiles: [
|
12
|
+
'{projectRoot}/eslint.config.{js,cjs,mjs}',
|
13
|
+
'{projectRoot}/rollup.config.{js,ts,mjs,mts,cjs,cts}',
|
14
|
+
],
|
15
|
+
},
|
16
|
+
],
|
17
|
+
},
|
18
|
+
languageOptions: {
|
19
|
+
parser: await import('jsonc-eslint-parser'),
|
20
|
+
},
|
21
|
+
},
|
22
|
+
];
|
package/package.json
CHANGED
@@ -1,12 +1,28 @@
|
|
1
1
|
{
|
2
2
|
"name": "@digipair/skill-web-heygen",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.91.0-0",
|
4
|
+
"type": "module",
|
5
|
+
"main": "dist/libs/skill-web-heygen/index.cjs.js",
|
6
|
+
"module": "dist/libs/skill-web-heygen/index.esm.js",
|
7
|
+
"types": "dist/libs/skill-web-heygen/index.esm.d.ts",
|
8
|
+
"exports": {
|
9
|
+
"./package.json": "./libs/skill-web-heygen/package.json",
|
10
|
+
".": {
|
11
|
+
"development": "./dist/libs/skill-web-heygen/src/index.ts",
|
12
|
+
"types": "./dist/libs/skill-web-heygen/index.esm.d.ts",
|
13
|
+
"import": "./dist/libs/skill-web-heygen/index.esm.js",
|
14
|
+
"default": "./dist/libs/skill-web-heygen/index.cjs.js"
|
15
|
+
}
|
16
|
+
},
|
4
17
|
"keywords": [
|
5
18
|
"digipair",
|
6
19
|
"web",
|
7
20
|
"util"
|
8
21
|
],
|
9
|
-
"
|
10
|
-
|
11
|
-
|
12
|
-
|
22
|
+
"nx": {
|
23
|
+
"name": "skill-web-heygen"
|
24
|
+
},
|
25
|
+
"dependencies": {
|
26
|
+
"@digipair/engine": "0.91.0-0"
|
27
|
+
}
|
28
|
+
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
const { withNx } = require('@nx/rollup/with-nx');
|
2
|
+
|
3
|
+
module.exports = withNx(
|
4
|
+
{
|
5
|
+
main: 'libs/skill-web-heygen/src/index.ts',
|
6
|
+
outputPath: 'dist/libs/skill-web-heygen',
|
7
|
+
tsConfig: 'libs/skill-web-heygen/tsconfig.lib.json',
|
8
|
+
compiler: 'swc',
|
9
|
+
format: ['esm', "cjs"],
|
10
|
+
assets: [
|
11
|
+
{
|
12
|
+
input: 'libs/skill-web-heygen/',
|
13
|
+
glob: 'package.json',
|
14
|
+
output: '.'
|
15
|
+
},
|
16
|
+
{
|
17
|
+
input: 'libs/skill-web-heygen/src/',
|
18
|
+
glob: '*.json',
|
19
|
+
output: '.'
|
20
|
+
}
|
21
|
+
]
|
22
|
+
},
|
23
|
+
{
|
24
|
+
// Provide additional rollup configuration here. See: https://rollupjs.org/configuration-options
|
25
|
+
// e.g.
|
26
|
+
// output: { sourcemap: true },
|
27
|
+
}
|
28
|
+
);
|
@@ -0,0 +1,87 @@
|
|
1
|
+
import { html, LitElement } from 'lit';
|
2
|
+
import { customElement, query, property } from 'lit/decorators.js';
|
3
|
+
|
4
|
+
@customElement('digipair-heygen')
|
5
|
+
export class HeygenElement extends LitElement {
|
6
|
+
@property()
|
7
|
+
videoStyle = '';
|
8
|
+
|
9
|
+
@query('video') mediaElement!: HTMLVideoElement;
|
10
|
+
|
11
|
+
private peerConnection!: RTCPeerConnection;
|
12
|
+
|
13
|
+
private updateStatus(status: string, data?: any) {
|
14
|
+
this.dispatchEvent(new CustomEvent('status', { detail: { status, data } }));
|
15
|
+
}
|
16
|
+
|
17
|
+
async start(sessionInfo: any) {
|
18
|
+
this.updateStatus('SESSION_CREATING');
|
19
|
+
|
20
|
+
// call the new interface to get the server's offer SDP and ICE server to create a new RTCPeerConnection
|
21
|
+
const { sdp: serverSdp, ice_servers2: iceServers } = sessionInfo;
|
22
|
+
|
23
|
+
// Create a new RTCPeerConnection
|
24
|
+
this.peerConnection = new RTCPeerConnection({ iceServers: iceServers });
|
25
|
+
|
26
|
+
// When audio and video streams are received, display them in the video element
|
27
|
+
this.peerConnection.ontrack = event => {
|
28
|
+
if (event.track.kind === 'audio' || event.track.kind === 'video') {
|
29
|
+
this.mediaElement.srcObject = event.streams[0];
|
30
|
+
}
|
31
|
+
};
|
32
|
+
|
33
|
+
// When receiving a message, display it in the status element
|
34
|
+
this.peerConnection.ondatachannel = (event: any) => {
|
35
|
+
const dataChannel = event.channel;
|
36
|
+
dataChannel.onmessage = (message: any) => {
|
37
|
+
this.dispatchEvent(new CustomEvent('message', { detail: { message: message.data } }));
|
38
|
+
};
|
39
|
+
};
|
40
|
+
|
41
|
+
// Set server's SDP as remote description
|
42
|
+
const remoteDescription = new RTCSessionDescription(serverSdp);
|
43
|
+
await this.peerConnection.setRemoteDescription(remoteDescription);
|
44
|
+
|
45
|
+
this.updateStatus('SESSION_CREATED');
|
46
|
+
|
47
|
+
// Create and set local SDP description
|
48
|
+
const localDescription = await this.peerConnection.createAnswer();
|
49
|
+
await this.peerConnection.setLocalDescription(localDescription);
|
50
|
+
|
51
|
+
// When ICE candidate is available, send to the server
|
52
|
+
this.peerConnection.onicecandidate = ({ candidate }) => {
|
53
|
+
if (candidate) {
|
54
|
+
this.dispatchEvent(
|
55
|
+
new CustomEvent('icecandidate', {
|
56
|
+
detail: { sessionId: sessionInfo.session_id, candidate: candidate.toJSON() },
|
57
|
+
}),
|
58
|
+
);
|
59
|
+
}
|
60
|
+
};
|
61
|
+
|
62
|
+
// When ICE connection state changes, display the new state
|
63
|
+
this.peerConnection.oniceconnectionstatechange = (event: any) => {
|
64
|
+
this.updateStatus('ICE_CONNECTION_STATE_CHANGED', this.peerConnection.iceConnectionState);
|
65
|
+
};
|
66
|
+
|
67
|
+
var receivers = this.peerConnection.getReceivers();
|
68
|
+
|
69
|
+
receivers.forEach((receiver: any) => {
|
70
|
+
receiver.jitterBufferTarget = 500;
|
71
|
+
});
|
72
|
+
|
73
|
+
this.updateStatus('SESSION_STARTED');
|
74
|
+
|
75
|
+
// Return the local SDP to the server
|
76
|
+
return { sessionId: sessionInfo.session_id, sdp: localDescription };
|
77
|
+
}
|
78
|
+
|
79
|
+
async stop() {
|
80
|
+
this.peerConnection.close();
|
81
|
+
this.updateStatus('SESSION_STOPPED');
|
82
|
+
}
|
83
|
+
|
84
|
+
override render() {
|
85
|
+
return html` <video style=${this.videoStyle} autoplay></video> `;
|
86
|
+
}
|
87
|
+
}
|
package/tsconfig.json
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"extends": "../../tsconfig.base.json",
|
3
|
+
"compilerOptions": {
|
4
|
+
"rootDir": "src",
|
5
|
+
"outDir": "dist",
|
6
|
+
"tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
|
7
|
+
"emitDeclarationOnly": true,
|
8
|
+
"module": "esnext",
|
9
|
+
"moduleResolution": "node",
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
11
|
+
"types": ["node"]
|
12
|
+
},
|
13
|
+
"include": ["src/**/*.ts"],
|
14
|
+
"references": [
|
15
|
+
{
|
16
|
+
"path": "../engine/tsconfig.lib.json"
|
17
|
+
}
|
18
|
+
]
|
19
|
+
}
|
package/index.cjs.d.ts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export * from "./src/index";
|