@sprucelabs/heartwood-view-controllers 118.0.31 → 118.1.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.
@@ -19,6 +19,16 @@ const webRtcPlayerSchema = {
19
19
  options: { valueType: `HeartwoodTypes.ViewController<HeartwoodTypes.WebRtcPlayer>`, }
20
20
  },
21
21
  /** . */
22
+ 'shouldAllowCropping': {
23
+ type: 'boolean',
24
+ options: undefined
25
+ },
26
+ /** . */
27
+ 'onCrop': {
28
+ type: 'raw',
29
+ options: { valueType: `HeartwoodTypes.WebRtcPlayerCropHandler`, }
30
+ },
31
+ /** . */
22
32
  'connection': {
23
33
  type: 'raw',
24
34
  options: { valueType: `HeartwoodTypes.WebRtcConnection`, }
@@ -708,6 +708,8 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
708
708
  interface WebRtcPlayer {
709
709
  'id'?: string | undefined | null;
710
710
  'controller'?: (HeartwoodTypes.ViewController<HeartwoodTypes.WebRtcPlayer>) | undefined | null;
711
+ 'shouldAllowCropping'?: boolean | undefined | null;
712
+ 'onCrop'?: (HeartwoodTypes.WebRtcPlayerCropHandler) | undefined | null;
711
713
  'connection'?: (HeartwoodTypes.WebRtcConnection) | undefined | null;
712
714
  'streamer'?: (HeartwoodTypes.WebRtcStreamer) | undefined | null;
713
715
  }
@@ -731,6 +733,18 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
731
733
  };
732
734
  };
733
735
  /** . */
736
+ 'shouldAllowCropping': {
737
+ type: 'boolean';
738
+ options: undefined;
739
+ };
740
+ /** . */
741
+ 'onCrop': {
742
+ type: 'raw';
743
+ options: {
744
+ valueType: `HeartwoodTypes.WebRtcPlayerCropHandler`;
745
+ };
746
+ };
747
+ /** . */
734
748
  'connection': {
735
749
  type: 'raw';
736
750
  options: {
@@ -17,6 +17,16 @@ const webRtcPlayerSchema = {
17
17
  options: { valueType: `HeartwoodTypes.ViewController<HeartwoodTypes.WebRtcPlayer>`, }
18
18
  },
19
19
  /** . */
20
+ 'shouldAllowCropping': {
21
+ type: 'boolean',
22
+ options: undefined
23
+ },
24
+ /** . */
25
+ 'onCrop': {
26
+ type: 'raw',
27
+ options: { valueType: `HeartwoodTypes.WebRtcPlayerCropHandler`, }
28
+ },
29
+ /** . */
20
30
  'connection': {
21
31
  type: 'raw',
22
32
  options: { valueType: `HeartwoodTypes.WebRtcConnection`, }
@@ -708,6 +708,8 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
708
708
  interface WebRtcPlayer {
709
709
  'id'?: string | undefined | null;
710
710
  'controller'?: (HeartwoodTypes.ViewController<HeartwoodTypes.WebRtcPlayer>) | undefined | null;
711
+ 'shouldAllowCropping'?: boolean | undefined | null;
712
+ 'onCrop'?: (HeartwoodTypes.WebRtcPlayerCropHandler) | undefined | null;
711
713
  'connection'?: (HeartwoodTypes.WebRtcConnection) | undefined | null;
712
714
  'streamer'?: (HeartwoodTypes.WebRtcStreamer) | undefined | null;
713
715
  }
@@ -731,6 +733,18 @@ declare module '@sprucelabs/spruce-core-schemas/build/.spruce/schemas/core.schem
731
733
  };
732
734
  };
733
735
  /** . */
736
+ 'shouldAllowCropping': {
737
+ type: 'boolean';
738
+ options: undefined;
739
+ };
740
+ /** . */
741
+ 'onCrop': {
742
+ type: 'raw';
743
+ options: {
744
+ valueType: `HeartwoodTypes.WebRtcPlayerCropHandler`;
745
+ };
746
+ };
747
+ /** . */
734
748
  'connection': {
735
749
  type: 'raw';
736
750
  options: {
@@ -10,6 +10,15 @@ declare const _default: {
10
10
  valueType: string;
11
11
  };
12
12
  };
13
+ shouldAllowCropping: {
14
+ type: "boolean";
15
+ };
16
+ onCrop: {
17
+ type: "raw";
18
+ options: {
19
+ valueType: string;
20
+ };
21
+ };
13
22
  connection: {
14
23
  type: "raw";
15
24
  options: {
@@ -11,6 +11,15 @@ export default buildSchema({
11
11
  valueType: 'HeartwoodTypes.ViewController<HeartwoodTypes.WebRtcPlayer>',
12
12
  },
13
13
  },
14
+ shouldAllowCropping: {
15
+ type: 'boolean',
16
+ },
17
+ onCrop: {
18
+ type: 'raw',
19
+ options: {
20
+ valueType: 'HeartwoodTypes.WebRtcPlayerCropHandler',
21
+ },
22
+ },
14
23
  connection: {
15
24
  type: 'raw',
16
25
  options: {
@@ -24,7 +24,7 @@ export default class MockRtcPeerConnection implements RTCPeerConnection {
24
24
  }): void;
25
25
  assertTrackListenerSet(expected: () => void): void;
26
26
  static onCreateOffer(cb?: () => void): void;
27
- emitTrackAdded(): void;
27
+ emitTrackAdded(event?: RTCTrackEvent): void;
28
28
  canTrickleIceCandidates: boolean | null;
29
29
  connectionState: RTCPeerConnectionState;
30
30
  currentLocalDescription: RTCSessionDescription | null;
@@ -85,10 +85,10 @@ export default class MockRtcPeerConnection {
85
85
  static onCreateOffer(cb) {
86
86
  this.onCreateOfferHandler = cb;
87
87
  }
88
- emitTrackAdded() {
88
+ emitTrackAdded(event) {
89
89
  const lastListener = this.lastAddedEventListener;
90
90
  if ((lastListener === null || lastListener === void 0 ? void 0 : lastListener.eventName) === 'track') {
91
- lastListener.listener({});
91
+ lastListener.listener(event !== null && event !== void 0 ? event : {});
92
92
  }
93
93
  else {
94
94
  assert.fail('Did not call connection.addEventListener with track listener');
@@ -258,6 +258,13 @@ export type TriggerRender = () => void;
258
258
  export type TriggerRenderHandler = () => void;
259
259
  export { WebRtcStreamer } from '../webRtcStreaming/WebRtcStreamer';
260
260
  export * from '../webRtcStreaming/WebRtcConnection';
261
+ export interface Point {
262
+ x: number;
263
+ y: number;
264
+ width: number;
265
+ height: number;
266
+ }
267
+ export type WebRtcPlayerCropHandler = (point?: Point) => void;
261
268
  export interface ViewController<ViewModel extends Record<string, any>> {
262
269
  render(): ViewModel;
263
270
  setTriggerRenderHandler: (handler: TriggerRenderHandler) => void;
@@ -4,7 +4,7 @@ export default class WebRtcConnectionImpl implements WebRtcConnection {
4
4
  static Class: new () => WebRtcConnection;
5
5
  static get RTCPeerConnection(): new (config: RTCConfiguration) => RTCPeerConnection | MockRtcPeerConnection;
6
6
  static set RTCPeerConnection(value: new (config: RTCConfiguration) => RTCPeerConnection | MockRtcPeerConnection);
7
- private stateChangeHandlers;
7
+ private stateChangeListeners;
8
8
  static Connection(): WebRtcConnection;
9
9
  createOffer(options: WebRtcVcPluginCreateOfferOptions): Promise<WebRtcCreateOfferResponse>;
10
10
  private emitStateChange;
@@ -18,7 +18,7 @@ export interface WebRtcVcPluginCreateOfferOptions {
18
18
  };
19
19
  }
20
20
  export type WebRtcConnectionState = 'createdOffer' | 'suppliedAnswer' | 'trackAdded';
21
- export type WebRtcStateChangeHandler = (state: WebRtcConnectionState) => void | Promise<void>;
21
+ export type WebRtcStateChangeHandler = (state: WebRtcConnectionState, event?: RTCTrackEvent) => void | Promise<void>;
22
22
  export interface WebRtcConnection {
23
23
  offStateChange(listener: WebRtcStateChangeHandler): void;
24
24
  createOffer(options: WebRtcVcPluginCreateOfferOptions): Promise<WebRtcCreateOfferResponse>;
@@ -11,7 +11,7 @@ import { assertOptions } from '@sprucelabs/schema';
11
11
  import WebRtcStreamerImpl from './WebRtcStreamer.js';
12
12
  export default class WebRtcConnectionImpl {
13
13
  constructor() {
14
- this.stateChangeHandlers = [];
14
+ this.stateChangeListeners = [];
15
15
  }
16
16
  static get RTCPeerConnection() {
17
17
  return window.RTCPeerConnection;
@@ -44,6 +44,9 @@ export default class WebRtcConnectionImpl {
44
44
  const offer = yield connection.createOffer({});
45
45
  yield connection.setLocalDescription(offer);
46
46
  void this.emitStateChange('createdOffer');
47
+ connection.addEventListener('track', (event) => {
48
+ void this.emitStateChange('trackAdded', event);
49
+ });
47
50
  return {
48
51
  offerSdp: offer,
49
52
  streamer: WebRtcStreamerImpl.Streamer(connection, (status) => __awaiter(this, void 0, void 0, function* () {
@@ -52,17 +55,17 @@ export default class WebRtcConnectionImpl {
52
55
  };
53
56
  });
54
57
  }
55
- emitStateChange(state) {
58
+ emitStateChange(state, event) {
56
59
  return __awaiter(this, void 0, void 0, function* () {
57
- for (const handler of this.stateChangeHandlers) {
58
- yield handler(state);
60
+ for (const handler of this.stateChangeListeners) {
61
+ yield handler(state, event);
59
62
  }
60
63
  });
61
64
  }
62
65
  onStateChange(cb) {
63
- this.stateChangeHandlers.push(cb);
66
+ this.stateChangeListeners.push(cb);
64
67
  }
65
68
  offStateChange(listener) {
66
- this.stateChangeHandlers = this.stateChangeHandlers.filter((handler) => handler !== listener);
69
+ this.stateChangeListeners = this.stateChangeListeners.filter((handler) => handler !== listener);
67
70
  }
68
71
  }
@@ -1,10 +1,10 @@
1
- import { WebRtcStateChangeHandler } from './WebRtcConnection';
1
+ import { WebRtcStateChangeHandler as WebRtcStateChangeListener } from './WebRtcConnection';
2
2
  export default class WebRtcStreamerImpl implements WebRtcStreamer {
3
3
  private connection;
4
- static Class?: new (connection: RTCPeerConnection, stateChangeHandlers?: WebRtcStateChangeHandler) => WebRtcStreamer;
5
- private stateChangeHandler?;
6
- protected constructor(connection: RTCPeerConnection, stateChangeHandler?: WebRtcStateChangeHandler);
7
- static Streamer(connection: RTCPeerConnection, stateChangeHandler?: WebRtcStateChangeHandler): WebRtcStreamer;
4
+ static Class?: new (connection: RTCPeerConnection, stateChangeHandlers?: WebRtcStateChangeListener) => WebRtcStreamer;
5
+ private setAnwserHandler?;
6
+ protected constructor(connection: RTCPeerConnection, stateChangeHandler?: WebRtcStateChangeListener);
7
+ static Streamer(connection: RTCPeerConnection, stateChangeHandler?: WebRtcStateChangeListener): WebRtcStreamer;
8
8
  setAnswer(answerSdp: string): Promise<void>;
9
9
  onTrack(cb: (event: RTCTrackEvent) => void): void;
10
10
  }
@@ -11,7 +11,7 @@ import { assertOptions } from '@sprucelabs/schema';
11
11
  export default class WebRtcStreamerImpl {
12
12
  constructor(connection, stateChangeHandler) {
13
13
  this.connection = connection;
14
- this.stateChangeHandler = stateChangeHandler;
14
+ this.setAnwserHandler = stateChangeHandler;
15
15
  }
16
16
  static Streamer(connection, stateChangeHandler) {
17
17
  var _a;
@@ -25,12 +25,10 @@ export default class WebRtcStreamerImpl {
25
25
  type: 'answer',
26
26
  sdp: answerSdp,
27
27
  });
28
- yield ((_a = this.stateChangeHandler) === null || _a === void 0 ? void 0 : _a.call(this, 'suppliedAnswer'));
28
+ yield ((_a = this.setAnwserHandler) === null || _a === void 0 ? void 0 : _a.call(this, 'suppliedAnswer'));
29
29
  });
30
30
  }
31
31
  onTrack(cb) {
32
- var _a;
33
32
  this.connection.addEventListener('track', cb);
34
- void ((_a = this.stateChangeHandler) === null || _a === void 0 ? void 0 : _a.call(this, 'trackAdded'));
35
33
  }
36
34
  }
@@ -10,6 +10,15 @@ declare const _default: {
10
10
  valueType: string;
11
11
  };
12
12
  };
13
+ shouldAllowCropping: {
14
+ type: "boolean";
15
+ };
16
+ onCrop: {
17
+ type: "raw";
18
+ options: {
19
+ valueType: string;
20
+ };
21
+ };
13
22
  connection: {
14
23
  type: "raw";
15
24
  options: {
@@ -13,6 +13,15 @@ exports.default = (0, schema_1.buildSchema)({
13
13
  valueType: 'HeartwoodTypes.ViewController<HeartwoodTypes.WebRtcPlayer>',
14
14
  },
15
15
  },
16
+ shouldAllowCropping: {
17
+ type: 'boolean',
18
+ },
19
+ onCrop: {
20
+ type: 'raw',
21
+ options: {
22
+ valueType: 'HeartwoodTypes.WebRtcPlayerCropHandler',
23
+ },
24
+ },
16
25
  connection: {
17
26
  type: 'raw',
18
27
  options: {
@@ -24,7 +24,7 @@ export default class MockRtcPeerConnection implements RTCPeerConnection {
24
24
  }): void;
25
25
  assertTrackListenerSet(expected: () => void): void;
26
26
  static onCreateOffer(cb?: () => void): void;
27
- emitTrackAdded(): void;
27
+ emitTrackAdded(event?: RTCTrackEvent): void;
28
28
  canTrickleIceCandidates: boolean | null;
29
29
  connectionState: RTCPeerConnectionState;
30
30
  currentLocalDescription: RTCSessionDescription | null;
@@ -78,10 +78,10 @@ class MockRtcPeerConnection {
78
78
  static onCreateOffer(cb) {
79
79
  this.onCreateOfferHandler = cb;
80
80
  }
81
- emitTrackAdded() {
81
+ emitTrackAdded(event) {
82
82
  const lastListener = this.lastAddedEventListener;
83
83
  if (lastListener?.eventName === 'track') {
84
- lastListener.listener({});
84
+ lastListener.listener(event ?? {});
85
85
  }
86
86
  else {
87
87
  test_utils_1.assert.fail('Did not call connection.addEventListener with track listener');
@@ -258,6 +258,13 @@ export type TriggerRender = () => void;
258
258
  export type TriggerRenderHandler = () => void;
259
259
  export { WebRtcStreamer } from '../webRtcStreaming/WebRtcStreamer';
260
260
  export * from '../webRtcStreaming/WebRtcConnection';
261
+ export interface Point {
262
+ x: number;
263
+ y: number;
264
+ width: number;
265
+ height: number;
266
+ }
267
+ export type WebRtcPlayerCropHandler = (point?: Point) => void;
261
268
  export interface ViewController<ViewModel extends Record<string, any>> {
262
269
  render(): ViewModel;
263
270
  setTriggerRenderHandler: (handler: TriggerRenderHandler) => void;
@@ -4,7 +4,7 @@ export default class WebRtcConnectionImpl implements WebRtcConnection {
4
4
  static Class: new () => WebRtcConnection;
5
5
  static get RTCPeerConnection(): new (config: RTCConfiguration) => RTCPeerConnection | MockRtcPeerConnection;
6
6
  static set RTCPeerConnection(value: new (config: RTCConfiguration) => RTCPeerConnection | MockRtcPeerConnection);
7
- private stateChangeHandlers;
7
+ private stateChangeListeners;
8
8
  static Connection(): WebRtcConnection;
9
9
  createOffer(options: WebRtcVcPluginCreateOfferOptions): Promise<WebRtcCreateOfferResponse>;
10
10
  private emitStateChange;
@@ -18,7 +18,7 @@ export interface WebRtcVcPluginCreateOfferOptions {
18
18
  };
19
19
  }
20
20
  export type WebRtcConnectionState = 'createdOffer' | 'suppliedAnswer' | 'trackAdded';
21
- export type WebRtcStateChangeHandler = (state: WebRtcConnectionState) => void | Promise<void>;
21
+ export type WebRtcStateChangeHandler = (state: WebRtcConnectionState, event?: RTCTrackEvent) => void | Promise<void>;
22
22
  export interface WebRtcConnection {
23
23
  offStateChange(listener: WebRtcStateChangeHandler): void;
24
24
  createOffer(options: WebRtcVcPluginCreateOfferOptions): Promise<WebRtcCreateOfferResponse>;
@@ -7,7 +7,7 @@ const schema_1 = require("@sprucelabs/schema");
7
7
  const WebRtcStreamer_1 = __importDefault(require("./WebRtcStreamer"));
8
8
  class WebRtcConnectionImpl {
9
9
  constructor() {
10
- this.stateChangeHandlers = [];
10
+ this.stateChangeListeners = [];
11
11
  }
12
12
  static get RTCPeerConnection() {
13
13
  return window.RTCPeerConnection;
@@ -38,6 +38,9 @@ class WebRtcConnectionImpl {
38
38
  const offer = await connection.createOffer({});
39
39
  await connection.setLocalDescription(offer);
40
40
  void this.emitStateChange('createdOffer');
41
+ connection.addEventListener('track', (event) => {
42
+ void this.emitStateChange('trackAdded', event);
43
+ });
41
44
  return {
42
45
  offerSdp: offer,
43
46
  streamer: WebRtcStreamer_1.default.Streamer(connection, async (status) => {
@@ -45,16 +48,16 @@ class WebRtcConnectionImpl {
45
48
  }),
46
49
  };
47
50
  }
48
- async emitStateChange(state) {
49
- for (const handler of this.stateChangeHandlers) {
50
- await handler(state);
51
+ async emitStateChange(state, event) {
52
+ for (const handler of this.stateChangeListeners) {
53
+ await handler(state, event);
51
54
  }
52
55
  }
53
56
  onStateChange(cb) {
54
- this.stateChangeHandlers.push(cb);
57
+ this.stateChangeListeners.push(cb);
55
58
  }
56
59
  offStateChange(listener) {
57
- this.stateChangeHandlers = this.stateChangeHandlers.filter((handler) => handler !== listener);
60
+ this.stateChangeListeners = this.stateChangeListeners.filter((handler) => handler !== listener);
58
61
  }
59
62
  }
60
63
  exports.default = WebRtcConnectionImpl;
@@ -1,10 +1,10 @@
1
- import { WebRtcStateChangeHandler } from './WebRtcConnection';
1
+ import { WebRtcStateChangeHandler as WebRtcStateChangeListener } from './WebRtcConnection';
2
2
  export default class WebRtcStreamerImpl implements WebRtcStreamer {
3
3
  private connection;
4
- static Class?: new (connection: RTCPeerConnection, stateChangeHandlers?: WebRtcStateChangeHandler) => WebRtcStreamer;
5
- private stateChangeHandler?;
6
- protected constructor(connection: RTCPeerConnection, stateChangeHandler?: WebRtcStateChangeHandler);
7
- static Streamer(connection: RTCPeerConnection, stateChangeHandler?: WebRtcStateChangeHandler): WebRtcStreamer;
4
+ static Class?: new (connection: RTCPeerConnection, stateChangeHandlers?: WebRtcStateChangeListener) => WebRtcStreamer;
5
+ private setAnwserHandler?;
6
+ protected constructor(connection: RTCPeerConnection, stateChangeHandler?: WebRtcStateChangeListener);
7
+ static Streamer(connection: RTCPeerConnection, stateChangeHandler?: WebRtcStateChangeListener): WebRtcStreamer;
8
8
  setAnswer(answerSdp: string): Promise<void>;
9
9
  onTrack(cb: (event: RTCTrackEvent) => void): void;
10
10
  }
@@ -4,7 +4,7 @@ const schema_1 = require("@sprucelabs/schema");
4
4
  class WebRtcStreamerImpl {
5
5
  constructor(connection, stateChangeHandler) {
6
6
  this.connection = connection;
7
- this.stateChangeHandler = stateChangeHandler;
7
+ this.setAnwserHandler = stateChangeHandler;
8
8
  }
9
9
  static Streamer(connection, stateChangeHandler) {
10
10
  return new (this.Class ?? this)(connection, stateChangeHandler);
@@ -15,11 +15,10 @@ class WebRtcStreamerImpl {
15
15
  type: 'answer',
16
16
  sdp: answerSdp,
17
17
  });
18
- await this.stateChangeHandler?.('suppliedAnswer');
18
+ await this.setAnwserHandler?.('suppliedAnswer');
19
19
  }
20
20
  onTrack(cb) {
21
21
  this.connection.addEventListener('track', cb);
22
- void this.stateChangeHandler?.('trackAdded');
23
22
  }
24
23
  }
25
24
  exports.default = WebRtcStreamerImpl;
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.31",
16
+ "version": "118.1.0",
17
17
  "skill": {
18
18
  "namespace": "HeartwoodViewControllers",
19
19
  "commandOverrides": {