@sprucelabs/heartwood-view-controllers 119.7.0 → 119.7.2

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.
@@ -68,8 +68,8 @@ export default class ActiveRecordCardViewController extends AbstractViewControll
68
68
  setSelectedRows(rows: (string | number)[]): void;
69
69
  getRowVc(row: string | number): import("../..").ListRowViewController;
70
70
  getValues(): import("../../types/heartwood.types").RowValues[];
71
- setValue(rowId: string, name: string, value: any): Promise<void>;
72
- getValue(rowId: string, name: string): any;
71
+ setValue(rowId: string | number, name: string, value: any): Promise<void>;
72
+ getValue(rowId: string | number, name: string): any;
73
73
  getPayload(): Record<string, any> | undefined;
74
74
  setFooter(footer: CardFooter | null): void;
75
75
  disableFooter(): void;
@@ -471,6 +471,7 @@ class ActiveRecordCardViewController extends AbstractViewController {
471
471
  enableFooter() {
472
472
  this.cardVc.enableFooter();
473
473
  }
474
+ // @deprecated - this is dangerous to use and will break when paging is enabled. Check the MockActiveCard or your ActiveRecordCard for a better solution. If one does not exist, report it here: https://docs.google.com/forms/d/e/1FAIpQLSdqNm0tkmBhzl7L8yuRpXYOWuke9CzKvbPzpUIsIYxB0zDmIQ/viewform
474
475
  getListVc() {
475
476
  var _a, _b;
476
477
  const listVc = (_b = (_a = this.listVc) === null || _a === void 0 ? void 0 : _a.getListVc()) !== null && _b !== void 0 ? _b : this.listVcs[0];
@@ -10,6 +10,9 @@ export default class WebRtcConnectionImpl implements WebRtcConnection {
10
10
  static Connection(): WebRtcConnection;
11
11
  getRtcPeerConnection(): RTCPeerConnection;
12
12
  createOffer(options: WebRtcVcPluginCreateOfferOptions): Promise<WebRtcCreateOfferResponse>;
13
+ private addStateChangeListener;
14
+ private handleStatusFailed;
15
+ private logStatsReport;
13
16
  private emitStateChange;
14
17
  onStateChange(cb: WebRtcStateChangeHandler): void;
15
18
  offStateChange(listener: WebRtcStateChangeHandler): void;
@@ -23,14 +26,21 @@ export interface WebRtcVcPluginCreateOfferOptions {
23
26
  export interface WebRtcStateEventMap {
24
27
  createdOffer: undefined;
25
28
  suppliedAnswer: undefined;
29
+ connecting: WebRtcEvent;
30
+ connected: WebRtcEvent;
31
+ disconnected: WebRtcEvent;
26
32
  trackAdded: RTCTrackEvent;
27
33
  error: WebRtcErrorEvent;
28
34
  }
35
+ interface WebRtcEvent {
36
+ connection: RTCPeerConnection;
37
+ }
29
38
  export type WebRtcConnectionState = keyof WebRtcStateEventMap;
30
39
  export type WebRtcStateChangeEvent<State extends WebRtcConnectionState = WebRtcConnectionState> = WebRtcStateEventMap[State];
31
40
  export type WebRtcStateChangeHandler<State extends WebRtcConnectionState = WebRtcConnectionState> = (state: State, event?: WebRtcStateChangeEvent<State>) => void | Promise<void>;
32
41
  export interface WebRtcErrorEvent {
33
42
  stats: RTCStatsReport;
43
+ connection: RTCPeerConnection;
34
44
  }
35
45
  export interface WebRtcConnection {
36
46
  offStateChange(listener: WebRtcStateChangeHandler): void;
@@ -43,3 +53,4 @@ export interface WebRtcCreateOfferResponse {
43
53
  streamer: WebRtcStreamer;
44
54
  rtcPeerConnection: RTCPeerConnection;
45
55
  }
56
+ export {};
@@ -44,18 +44,7 @@ export default class WebRtcConnectionImpl {
44
44
  iceServers: [],
45
45
  });
46
46
  this.rtcPeerConnection = connection;
47
- connection.addEventListener('connectionstatechange', () => __awaiter(this, void 0, void 0, function* () {
48
- this.log.info(`RTCPeerConnection state changed to ${connection.connectionState}`);
49
- if (connection.connectionState === 'failed') {
50
- const stats = yield connection.getStats();
51
- const messages = [];
52
- stats.forEach((report) => {
53
- messages.push(`[${report.type}] ID: ${report.id}`, report);
54
- });
55
- this.log.error(`RTCPeerConnection failed with stats:\n\n`, messages.join('\n'));
56
- yield this.emitStateChange('error', { stats });
57
- }
58
- }));
47
+ this.addStateChangeListener();
59
48
  const { offerToReceiveAudio, offerToReceiveVideo } = offerOptions;
60
49
  if (offerToReceiveAudio) {
61
50
  connection.addTransceiver('audio', { direction: 'recvonly' });
@@ -81,6 +70,43 @@ export default class WebRtcConnectionImpl {
81
70
  };
82
71
  });
83
72
  }
73
+ addStateChangeListener() {
74
+ var _a;
75
+ (_a = this.rtcPeerConnection) === null || _a === void 0 ? void 0 : _a.addEventListener('connectionstatechange', () => __awaiter(this, void 0, void 0, function* () {
76
+ var _a, _b;
77
+ this.log.info(`RTCPeerConnection state changed to ${(_a = this.rtcPeerConnection) === null || _a === void 0 ? void 0 : _a.connectionState}`);
78
+ const state = (_b = this.rtcPeerConnection) === null || _b === void 0 ? void 0 : _b.connectionState;
79
+ if (state === 'failed') {
80
+ yield this.handleStatusFailed();
81
+ }
82
+ else {
83
+ yield this.emitStateChange(state, {
84
+ connection: this.rtcPeerConnection,
85
+ });
86
+ }
87
+ }));
88
+ }
89
+ handleStatusFailed() {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ const connection = this.rtcPeerConnection;
92
+ if (!connection) {
93
+ return;
94
+ }
95
+ const stats = yield connection.getStats();
96
+ this.logStatsReport(stats);
97
+ yield this.emitStateChange('error', {
98
+ stats,
99
+ connection,
100
+ });
101
+ });
102
+ }
103
+ logStatsReport(stats) {
104
+ const messages = [];
105
+ stats.forEach((report) => {
106
+ messages.push(`[${report.type}] ID: ${report.id}`, JSON.stringify(report, null, 2));
107
+ });
108
+ this.log.error(`RTCPeerConnection failed with stats:\n\n`, messages.join('\n'));
109
+ }
84
110
  emitStateChange(state, event) {
85
111
  return __awaiter(this, void 0, void 0, function* () {
86
112
  for (const handler of this.stateChangeListeners) {
@@ -68,8 +68,8 @@ export default class ActiveRecordCardViewController extends AbstractViewControll
68
68
  setSelectedRows(rows: (string | number)[]): void;
69
69
  getRowVc(row: string | number): import("../..").ListRowViewController;
70
70
  getValues(): import("../../types/heartwood.types").RowValues[];
71
- setValue(rowId: string, name: string, value: any): Promise<void>;
72
- getValue(rowId: string, name: string): any;
71
+ setValue(rowId: string | number, name: string, value: any): Promise<void>;
72
+ getValue(rowId: string | number, name: string): any;
73
73
  getPayload(): Record<string, any> | undefined;
74
74
  setFooter(footer: CardFooter | null): void;
75
75
  disableFooter(): void;
@@ -442,6 +442,7 @@ class ActiveRecordCardViewController extends Abstract_vc_1.default {
442
442
  enableFooter() {
443
443
  this.cardVc.enableFooter();
444
444
  }
445
+ // @deprecated - this is dangerous to use and will break when paging is enabled. Check the MockActiveCard or your ActiveRecordCard for a better solution. If one does not exist, report it here: https://docs.google.com/forms/d/e/1FAIpQLSdqNm0tkmBhzl7L8yuRpXYOWuke9CzKvbPzpUIsIYxB0zDmIQ/viewform
445
446
  getListVc() {
446
447
  const listVc = this.listVc?.getListVc() ?? this.listVcs[0];
447
448
  if (!listVc || this.listVcs.length > 1) {
@@ -10,6 +10,9 @@ export default class WebRtcConnectionImpl implements WebRtcConnection {
10
10
  static Connection(): WebRtcConnection;
11
11
  getRtcPeerConnection(): RTCPeerConnection;
12
12
  createOffer(options: WebRtcVcPluginCreateOfferOptions): Promise<WebRtcCreateOfferResponse>;
13
+ private addStateChangeListener;
14
+ private handleStatusFailed;
15
+ private logStatsReport;
13
16
  private emitStateChange;
14
17
  onStateChange(cb: WebRtcStateChangeHandler): void;
15
18
  offStateChange(listener: WebRtcStateChangeHandler): void;
@@ -23,14 +26,21 @@ export interface WebRtcVcPluginCreateOfferOptions {
23
26
  export interface WebRtcStateEventMap {
24
27
  createdOffer: undefined;
25
28
  suppliedAnswer: undefined;
29
+ connecting: WebRtcEvent;
30
+ connected: WebRtcEvent;
31
+ disconnected: WebRtcEvent;
26
32
  trackAdded: RTCTrackEvent;
27
33
  error: WebRtcErrorEvent;
28
34
  }
35
+ interface WebRtcEvent {
36
+ connection: RTCPeerConnection;
37
+ }
29
38
  export type WebRtcConnectionState = keyof WebRtcStateEventMap;
30
39
  export type WebRtcStateChangeEvent<State extends WebRtcConnectionState = WebRtcConnectionState> = WebRtcStateEventMap[State];
31
40
  export type WebRtcStateChangeHandler<State extends WebRtcConnectionState = WebRtcConnectionState> = (state: State, event?: WebRtcStateChangeEvent<State>) => void | Promise<void>;
32
41
  export interface WebRtcErrorEvent {
33
42
  stats: RTCStatsReport;
43
+ connection: RTCPeerConnection;
34
44
  }
35
45
  export interface WebRtcConnection {
36
46
  offStateChange(listener: WebRtcStateChangeHandler): void;
@@ -43,3 +53,4 @@ export interface WebRtcCreateOfferResponse {
43
53
  streamer: WebRtcStreamer;
44
54
  rtcPeerConnection: RTCPeerConnection;
45
55
  }
56
+ export {};
@@ -38,18 +38,7 @@ class WebRtcConnectionImpl {
38
38
  iceServers: [],
39
39
  });
40
40
  this.rtcPeerConnection = connection;
41
- connection.addEventListener('connectionstatechange', async () => {
42
- this.log.info(`RTCPeerConnection state changed to ${connection.connectionState}`);
43
- if (connection.connectionState === 'failed') {
44
- const stats = await connection.getStats();
45
- const messages = [];
46
- stats.forEach((report) => {
47
- messages.push(`[${report.type}] ID: ${report.id}`, report);
48
- });
49
- this.log.error(`RTCPeerConnection failed with stats:\n\n`, messages.join('\n'));
50
- await this.emitStateChange('error', { stats });
51
- }
52
- });
41
+ this.addStateChangeListener();
53
42
  const { offerToReceiveAudio, offerToReceiveVideo } = offerOptions;
54
43
  if (offerToReceiveAudio) {
55
44
  connection.addTransceiver('audio', { direction: 'recvonly' });
@@ -74,6 +63,39 @@ class WebRtcConnectionImpl {
74
63
  }),
75
64
  };
76
65
  }
66
+ addStateChangeListener() {
67
+ this.rtcPeerConnection?.addEventListener('connectionstatechange', async () => {
68
+ this.log.info(`RTCPeerConnection state changed to ${this.rtcPeerConnection?.connectionState}`);
69
+ const state = this.rtcPeerConnection?.connectionState;
70
+ if (state === 'failed') {
71
+ await this.handleStatusFailed();
72
+ }
73
+ else {
74
+ await this.emitStateChange(state, {
75
+ connection: this.rtcPeerConnection,
76
+ });
77
+ }
78
+ });
79
+ }
80
+ async handleStatusFailed() {
81
+ const connection = this.rtcPeerConnection;
82
+ if (!connection) {
83
+ return;
84
+ }
85
+ const stats = await connection.getStats();
86
+ this.logStatsReport(stats);
87
+ await this.emitStateChange('error', {
88
+ stats,
89
+ connection,
90
+ });
91
+ }
92
+ logStatsReport(stats) {
93
+ const messages = [];
94
+ stats.forEach((report) => {
95
+ messages.push(`[${report.type}] ID: ${report.id}`, JSON.stringify(report, null, 2));
96
+ });
97
+ this.log.error(`RTCPeerConnection failed with stats:\n\n`, messages.join('\n'));
98
+ }
77
99
  async emitStateChange(state, event) {
78
100
  for (const handler of this.stateChangeListeners) {
79
101
  await handler(state, event);
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": "119.7.0",
16
+ "version": "119.7.2",
17
17
  "skill": {
18
18
  "namespace": "HeartwoodViewControllers",
19
19
  "commandOverrides": {