@sprucelabs/heartwood-view-controllers 118.0.30 → 118.0.31
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/build/esm/tests/MockRtcPeerConnection.d.ts +13 -5
- package/build/esm/tests/MockRtcPeerConnection.js +36 -6
- package/build/esm/webRtcStreaming/WebRtcConnection.js +11 -1
- package/build/tests/MockRtcPeerConnection.d.ts +13 -5
- package/build/tests/MockRtcPeerConnection.js +36 -6
- package/build/webRtcStreaming/WebRtcConnection.js +11 -1
- package/package.json +3 -3
|
@@ -2,17 +2,21 @@ export default class MockRtcPeerConnection implements RTCPeerConnection {
|
|
|
2
2
|
static instance: MockRtcPeerConnection;
|
|
3
3
|
private static onCreateOfferHandler?;
|
|
4
4
|
private constructorOptions?;
|
|
5
|
-
private offerOptions?;
|
|
6
5
|
offer: RTCSessionDescription;
|
|
7
6
|
private lastAddedEventListener?;
|
|
7
|
+
private addedTransceivers;
|
|
8
|
+
private lastCreatedDataChannel?;
|
|
9
|
+
private tranceiverAndDataChannelCalls;
|
|
8
10
|
constructor(options?: RTCConfiguration);
|
|
9
11
|
assertCreatedOfferEquals(offer: RTCSessionDescriptionInit): void;
|
|
12
|
+
assertCreatedDataChannel(label: string, dataChannelDict?: RTCDataChannelInit): void;
|
|
13
|
+
assertTranceiversAndDataChannelCreatedInOrder(expected: string[]): void;
|
|
10
14
|
assertCreatedOfferSdpEquals(sdp: string): void;
|
|
11
15
|
assertCreatedWithOptions(expected: {
|
|
12
16
|
sdpSemantics: string;
|
|
13
17
|
iceServers: never[];
|
|
14
18
|
}): void;
|
|
15
|
-
|
|
19
|
+
assertAddedTranseivers(expected: RTCOfferOptions): void;
|
|
16
20
|
assertSetsResponseToConnectionLocalDescription(): void;
|
|
17
21
|
assertSetAnswerEquals(options: {
|
|
18
22
|
type: string;
|
|
@@ -44,11 +48,11 @@ export default class MockRtcPeerConnection implements RTCPeerConnection {
|
|
|
44
48
|
signalingState: RTCSignalingState;
|
|
45
49
|
addIceCandidate(_candidate?: unknown, _successCallback?: unknown, _failureCallback?: unknown): Promise<void>;
|
|
46
50
|
addTrack(_track: unknown, ..._streams: unknown[]): RTCRtpSender;
|
|
47
|
-
addTransceiver(
|
|
51
|
+
addTransceiver(trackOrKind: MediaStreamTrack | string, init?: RTCRtpTransceiverInit): RTCRtpTransceiver;
|
|
48
52
|
close(): void;
|
|
49
53
|
createAnswer(_successCallback?: unknown, _failureCallback?: unknown): Promise<any>;
|
|
50
|
-
createDataChannel(
|
|
51
|
-
createOffer(
|
|
54
|
+
createDataChannel(label: string, dataChannelDict?: RTCDataChannelInit): RTCDataChannel;
|
|
55
|
+
createOffer(_options?: RTCOfferOptions): Promise<any>;
|
|
52
56
|
getConfiguration(): RTCConfiguration;
|
|
53
57
|
getReceivers(): RTCRtpReceiver[];
|
|
54
58
|
getSenders(): RTCRtpSender[];
|
|
@@ -66,3 +70,7 @@ export default class MockRtcPeerConnection implements RTCPeerConnection {
|
|
|
66
70
|
removeEventListener(_type: unknown, _listener: unknown, _options?: unknown): void;
|
|
67
71
|
dispatchEvent(_event: Event): boolean;
|
|
68
72
|
}
|
|
73
|
+
export interface AddedTransceiver {
|
|
74
|
+
trackOrKind: MediaStreamTrack | string;
|
|
75
|
+
init?: RTCRtpTransceiverInit;
|
|
76
|
+
}
|
|
@@ -13,6 +13,8 @@ export default class MockRtcPeerConnection {
|
|
|
13
13
|
this.offer = {
|
|
14
14
|
[generateId()]: generateId(),
|
|
15
15
|
};
|
|
16
|
+
this.addedTransceivers = [];
|
|
17
|
+
this.tranceiverAndDataChannelCalls = [];
|
|
16
18
|
this.canTrickleIceCandidates = null;
|
|
17
19
|
this.connectionState = {};
|
|
18
20
|
this.currentLocalDescription = null;
|
|
@@ -40,14 +42,33 @@ export default class MockRtcPeerConnection {
|
|
|
40
42
|
assertCreatedOfferEquals(offer) {
|
|
41
43
|
assert.isEqualDeep(offer, this.offer, 'Did not return the generated offer');
|
|
42
44
|
}
|
|
45
|
+
assertCreatedDataChannel(label, dataChannelDict) {
|
|
46
|
+
assert.isEqualDeep(this.lastCreatedDataChannel, {
|
|
47
|
+
label,
|
|
48
|
+
dataChannelDict,
|
|
49
|
+
}, 'did not create expected data channel');
|
|
50
|
+
}
|
|
51
|
+
assertTranceiversAndDataChannelCreatedInOrder(expected) {
|
|
52
|
+
assert.isEqualDeep(this.tranceiverAndDataChannelCalls, expected, 'Did not call addTransceiver and createDataChannel in the expected order');
|
|
53
|
+
}
|
|
43
54
|
assertCreatedOfferSdpEquals(sdp) {
|
|
44
55
|
assert.isEqualDeep(this.offer.sdp, sdp, 'Did not return the generated offer sdp');
|
|
45
56
|
}
|
|
46
57
|
assertCreatedWithOptions(expected) {
|
|
47
58
|
assert.isEqualDeep(this.constructorOptions, expected, 'Did not pass default options to peer connection');
|
|
48
59
|
}
|
|
49
|
-
|
|
50
|
-
|
|
60
|
+
assertAddedTranseivers(expected) {
|
|
61
|
+
const expectedMapped = [];
|
|
62
|
+
for (const key in expected) {
|
|
63
|
+
const shouldAdd = expected[key];
|
|
64
|
+
if (shouldAdd) {
|
|
65
|
+
expectedMapped.push({
|
|
66
|
+
trackOrKind: key === 'offerToReceiveAudio' ? 'audio' : 'video',
|
|
67
|
+
init: { direction: 'recvonly' },
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
assert.isEqualDeep(this.addedTransceivers, expectedMapped, 'Did not add transceivers to peer connection');
|
|
51
72
|
}
|
|
52
73
|
assertSetsResponseToConnectionLocalDescription() {
|
|
53
74
|
assert.isEqualDeep(this.offer, this.localDescription, 'Did not set offer to local description');
|
|
@@ -81,7 +102,12 @@ export default class MockRtcPeerConnection {
|
|
|
81
102
|
addTrack(_track, ..._streams) {
|
|
82
103
|
return {};
|
|
83
104
|
}
|
|
84
|
-
addTransceiver(
|
|
105
|
+
addTransceiver(trackOrKind, init) {
|
|
106
|
+
this.addedTransceivers.push({
|
|
107
|
+
trackOrKind,
|
|
108
|
+
init,
|
|
109
|
+
});
|
|
110
|
+
this.tranceiverAndDataChannelCalls.push(`addTransceiver:${trackOrKind}`);
|
|
85
111
|
return {};
|
|
86
112
|
}
|
|
87
113
|
close() {
|
|
@@ -92,14 +118,18 @@ export default class MockRtcPeerConnection {
|
|
|
92
118
|
return {};
|
|
93
119
|
});
|
|
94
120
|
}
|
|
95
|
-
createDataChannel(
|
|
121
|
+
createDataChannel(label, dataChannelDict) {
|
|
122
|
+
this.lastCreatedDataChannel = {
|
|
123
|
+
label,
|
|
124
|
+
dataChannelDict,
|
|
125
|
+
};
|
|
126
|
+
this.tranceiverAndDataChannelCalls.push(`createDataChannel:${label}`);
|
|
96
127
|
return {};
|
|
97
128
|
}
|
|
98
129
|
//@ts-ignore
|
|
99
|
-
createOffer(
|
|
130
|
+
createOffer(_options) {
|
|
100
131
|
return __awaiter(this, void 0, void 0, function* () {
|
|
101
132
|
var _a;
|
|
102
|
-
this.offerOptions = options;
|
|
103
133
|
(_a = MockRtcPeerConnection.onCreateOfferHandler) === null || _a === void 0 ? void 0 : _a.call(MockRtcPeerConnection);
|
|
104
134
|
return this.offer;
|
|
105
135
|
});
|
|
@@ -31,7 +31,17 @@ export default class WebRtcConnectionImpl {
|
|
|
31
31
|
sdpSemantics: 'unified-plan',
|
|
32
32
|
iceServers: [],
|
|
33
33
|
});
|
|
34
|
-
const
|
|
34
|
+
const { offerToReceiveAudio, offerToReceiveVideo } = offerOptions;
|
|
35
|
+
if (offerToReceiveAudio) {
|
|
36
|
+
connection.addTransceiver('audio', { direction: 'recvonly' });
|
|
37
|
+
}
|
|
38
|
+
if (offerToReceiveVideo) {
|
|
39
|
+
connection.addTransceiver('video', { direction: 'recvonly' });
|
|
40
|
+
}
|
|
41
|
+
//must create this and add transceivers in order for Google Devices, if changing, make sure this
|
|
42
|
+
//stays the default behavior
|
|
43
|
+
connection.createDataChannel('dataSendChannel');
|
|
44
|
+
const offer = yield connection.createOffer({});
|
|
35
45
|
yield connection.setLocalDescription(offer);
|
|
36
46
|
void this.emitStateChange('createdOffer');
|
|
37
47
|
return {
|
|
@@ -2,17 +2,21 @@ export default class MockRtcPeerConnection implements RTCPeerConnection {
|
|
|
2
2
|
static instance: MockRtcPeerConnection;
|
|
3
3
|
private static onCreateOfferHandler?;
|
|
4
4
|
private constructorOptions?;
|
|
5
|
-
private offerOptions?;
|
|
6
5
|
offer: RTCSessionDescription;
|
|
7
6
|
private lastAddedEventListener?;
|
|
7
|
+
private addedTransceivers;
|
|
8
|
+
private lastCreatedDataChannel?;
|
|
9
|
+
private tranceiverAndDataChannelCalls;
|
|
8
10
|
constructor(options?: RTCConfiguration);
|
|
9
11
|
assertCreatedOfferEquals(offer: RTCSessionDescriptionInit): void;
|
|
12
|
+
assertCreatedDataChannel(label: string, dataChannelDict?: RTCDataChannelInit): void;
|
|
13
|
+
assertTranceiversAndDataChannelCreatedInOrder(expected: string[]): void;
|
|
10
14
|
assertCreatedOfferSdpEquals(sdp: string): void;
|
|
11
15
|
assertCreatedWithOptions(expected: {
|
|
12
16
|
sdpSemantics: string;
|
|
13
17
|
iceServers: never[];
|
|
14
18
|
}): void;
|
|
15
|
-
|
|
19
|
+
assertAddedTranseivers(expected: RTCOfferOptions): void;
|
|
16
20
|
assertSetsResponseToConnectionLocalDescription(): void;
|
|
17
21
|
assertSetAnswerEquals(options: {
|
|
18
22
|
type: string;
|
|
@@ -44,11 +48,11 @@ export default class MockRtcPeerConnection implements RTCPeerConnection {
|
|
|
44
48
|
signalingState: RTCSignalingState;
|
|
45
49
|
addIceCandidate(_candidate?: unknown, _successCallback?: unknown, _failureCallback?: unknown): Promise<void>;
|
|
46
50
|
addTrack(_track: unknown, ..._streams: unknown[]): RTCRtpSender;
|
|
47
|
-
addTransceiver(
|
|
51
|
+
addTransceiver(trackOrKind: MediaStreamTrack | string, init?: RTCRtpTransceiverInit): RTCRtpTransceiver;
|
|
48
52
|
close(): void;
|
|
49
53
|
createAnswer(_successCallback?: unknown, _failureCallback?: unknown): Promise<any>;
|
|
50
|
-
createDataChannel(
|
|
51
|
-
createOffer(
|
|
54
|
+
createDataChannel(label: string, dataChannelDict?: RTCDataChannelInit): RTCDataChannel;
|
|
55
|
+
createOffer(_options?: RTCOfferOptions): Promise<any>;
|
|
52
56
|
getConfiguration(): RTCConfiguration;
|
|
53
57
|
getReceivers(): RTCRtpReceiver[];
|
|
54
58
|
getSenders(): RTCRtpSender[];
|
|
@@ -66,3 +70,7 @@ export default class MockRtcPeerConnection implements RTCPeerConnection {
|
|
|
66
70
|
removeEventListener(_type: unknown, _listener: unknown, _options?: unknown): void;
|
|
67
71
|
dispatchEvent(_event: Event): boolean;
|
|
68
72
|
}
|
|
73
|
+
export interface AddedTransceiver {
|
|
74
|
+
trackOrKind: MediaStreamTrack | string;
|
|
75
|
+
init?: RTCRtpTransceiverInit;
|
|
76
|
+
}
|
|
@@ -6,6 +6,8 @@ class MockRtcPeerConnection {
|
|
|
6
6
|
this.offer = {
|
|
7
7
|
[(0, test_utils_1.generateId)()]: (0, test_utils_1.generateId)(),
|
|
8
8
|
};
|
|
9
|
+
this.addedTransceivers = [];
|
|
10
|
+
this.tranceiverAndDataChannelCalls = [];
|
|
9
11
|
this.canTrickleIceCandidates = null;
|
|
10
12
|
this.connectionState = {};
|
|
11
13
|
this.currentLocalDescription = null;
|
|
@@ -33,14 +35,33 @@ class MockRtcPeerConnection {
|
|
|
33
35
|
assertCreatedOfferEquals(offer) {
|
|
34
36
|
test_utils_1.assert.isEqualDeep(offer, this.offer, 'Did not return the generated offer');
|
|
35
37
|
}
|
|
38
|
+
assertCreatedDataChannel(label, dataChannelDict) {
|
|
39
|
+
test_utils_1.assert.isEqualDeep(this.lastCreatedDataChannel, {
|
|
40
|
+
label,
|
|
41
|
+
dataChannelDict,
|
|
42
|
+
}, 'did not create expected data channel');
|
|
43
|
+
}
|
|
44
|
+
assertTranceiversAndDataChannelCreatedInOrder(expected) {
|
|
45
|
+
test_utils_1.assert.isEqualDeep(this.tranceiverAndDataChannelCalls, expected, 'Did not call addTransceiver and createDataChannel in the expected order');
|
|
46
|
+
}
|
|
36
47
|
assertCreatedOfferSdpEquals(sdp) {
|
|
37
48
|
test_utils_1.assert.isEqualDeep(this.offer.sdp, sdp, 'Did not return the generated offer sdp');
|
|
38
49
|
}
|
|
39
50
|
assertCreatedWithOptions(expected) {
|
|
40
51
|
test_utils_1.assert.isEqualDeep(this.constructorOptions, expected, 'Did not pass default options to peer connection');
|
|
41
52
|
}
|
|
42
|
-
|
|
43
|
-
|
|
53
|
+
assertAddedTranseivers(expected) {
|
|
54
|
+
const expectedMapped = [];
|
|
55
|
+
for (const key in expected) {
|
|
56
|
+
const shouldAdd = expected[key];
|
|
57
|
+
if (shouldAdd) {
|
|
58
|
+
expectedMapped.push({
|
|
59
|
+
trackOrKind: key === 'offerToReceiveAudio' ? 'audio' : 'video',
|
|
60
|
+
init: { direction: 'recvonly' },
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
test_utils_1.assert.isEqualDeep(this.addedTransceivers, expectedMapped, 'Did not add transceivers to peer connection');
|
|
44
65
|
}
|
|
45
66
|
assertSetsResponseToConnectionLocalDescription() {
|
|
46
67
|
test_utils_1.assert.isEqualDeep(this.offer, this.localDescription, 'Did not set offer to local description');
|
|
@@ -72,7 +93,12 @@ class MockRtcPeerConnection {
|
|
|
72
93
|
addTrack(_track, ..._streams) {
|
|
73
94
|
return {};
|
|
74
95
|
}
|
|
75
|
-
addTransceiver(
|
|
96
|
+
addTransceiver(trackOrKind, init) {
|
|
97
|
+
this.addedTransceivers.push({
|
|
98
|
+
trackOrKind,
|
|
99
|
+
init,
|
|
100
|
+
});
|
|
101
|
+
this.tranceiverAndDataChannelCalls.push(`addTransceiver:${trackOrKind}`);
|
|
76
102
|
return {};
|
|
77
103
|
}
|
|
78
104
|
close() {
|
|
@@ -81,12 +107,16 @@ class MockRtcPeerConnection {
|
|
|
81
107
|
async createAnswer(_successCallback, _failureCallback) {
|
|
82
108
|
return {};
|
|
83
109
|
}
|
|
84
|
-
createDataChannel(
|
|
110
|
+
createDataChannel(label, dataChannelDict) {
|
|
111
|
+
this.lastCreatedDataChannel = {
|
|
112
|
+
label,
|
|
113
|
+
dataChannelDict,
|
|
114
|
+
};
|
|
115
|
+
this.tranceiverAndDataChannelCalls.push(`createDataChannel:${label}`);
|
|
85
116
|
return {};
|
|
86
117
|
}
|
|
87
118
|
//@ts-ignore
|
|
88
|
-
async createOffer(
|
|
89
|
-
this.offerOptions = options;
|
|
119
|
+
async createOffer(_options) {
|
|
90
120
|
MockRtcPeerConnection.onCreateOfferHandler?.();
|
|
91
121
|
return this.offer;
|
|
92
122
|
}
|
|
@@ -25,7 +25,17 @@ class WebRtcConnectionImpl {
|
|
|
25
25
|
sdpSemantics: 'unified-plan',
|
|
26
26
|
iceServers: [],
|
|
27
27
|
});
|
|
28
|
-
const
|
|
28
|
+
const { offerToReceiveAudio, offerToReceiveVideo } = offerOptions;
|
|
29
|
+
if (offerToReceiveAudio) {
|
|
30
|
+
connection.addTransceiver('audio', { direction: 'recvonly' });
|
|
31
|
+
}
|
|
32
|
+
if (offerToReceiveVideo) {
|
|
33
|
+
connection.addTransceiver('video', { direction: 'recvonly' });
|
|
34
|
+
}
|
|
35
|
+
//must create this and add transceivers in order for Google Devices, if changing, make sure this
|
|
36
|
+
//stays the default behavior
|
|
37
|
+
connection.createDataChannel('dataSendChannel');
|
|
38
|
+
const offer = await connection.createOffer({});
|
|
29
39
|
await connection.setLocalDescription(offer);
|
|
30
40
|
void this.emitStateChange('createdOffer');
|
|
31
41
|
return {
|
package/package.json
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"license": "MIT",
|
|
15
15
|
"description": "All the power of Heartwood in one, convenient package.",
|
|
16
|
-
"version": "118.0.
|
|
16
|
+
"version": "118.0.31",
|
|
17
17
|
"skill": {
|
|
18
18
|
"namespace": "HeartwoodViewControllers",
|
|
19
19
|
"commandOverrides": {
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"@babel/plugin-transform-runtime": "^7.26.10",
|
|
78
78
|
"@babel/preset-env": "^7.26.9",
|
|
79
79
|
"@babel/preset-typescript": "^7.27.0",
|
|
80
|
-
"@sprucelabs/calendar-utils": "^42.0.
|
|
80
|
+
"@sprucelabs/calendar-utils": "^42.0.669",
|
|
81
81
|
"@sprucelabs/error": "^6.0.591",
|
|
82
82
|
"@sprucelabs/globby": "^2.0.502",
|
|
83
83
|
"@sprucelabs/mercury-core-events": "^26.0.52",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"babel-plugin-module-resolver": "^5.0.2",
|
|
93
93
|
"dot-prop": "^9.0.0",
|
|
94
94
|
"dotenv": "^16.4.7",
|
|
95
|
-
"esbuild": "^0.25.
|
|
95
|
+
"esbuild": "^0.25.2",
|
|
96
96
|
"object-set": "^1.0.1",
|
|
97
97
|
"terser-webpack-plugin": "5.3.1",
|
|
98
98
|
"uglify-js": "^3.19.3",
|