@100mslive/hms-video-store 0.2.73 → 0.2.76

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.
@@ -1,3 +1,3 @@
1
- import { HMSPeer, HMSTrack } from '../core';
2
- export declare const makeFakeTrack: (type?: "audio" | "video" | undefined) => HMSTrack;
1
+ import { HMSPeer, HMSTrack, HMSTrackType } from '../core';
2
+ export declare const makeFakeTrack: (type?: HMSTrackType | undefined) => HMSTrack;
3
3
  export declare const makeFakePeer: () => HMSPeer;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.2.73",
2
+ "version": "0.2.76",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -21,6 +21,7 @@
21
21
  "prepare": "tsdx build",
22
22
  "size": "size-limit",
23
23
  "analyze": "size-limit --why",
24
+ "cypress:open": "cypress open",
24
25
  "docs": "rm -rf ./docs && typedoc && rm -f ./docs/README.md && mkdir ./docs/home &&mv ./docs/modules.md ./docs/home/content.md && ./bin/typedoc-mdx && npx prettier --write './docs/**/*'"
25
26
  },
26
27
  "husky": {
@@ -50,25 +51,32 @@
50
51
  }
51
52
  ],
52
53
  "dependencies": {
54
+ "eventemitter2": "^6.4.5",
53
55
  "immer": "^9.0.6",
54
- "reselect": "^4.0.0",
56
+ "reselect": "4.0.0",
55
57
  "zustand": "3.5.7"
56
58
  },
57
59
  "peerDependencies": {
58
- "@100mslive/hms-video": "^0.1.19",
59
- "events": "^3.3.0"
60
+ "@100mslive/hms-video": "^0.1.26"
60
61
  },
61
62
  "devDependencies": {
62
- "@100mslive/hms-video": "^0.1.19",
63
+ "@100mslive/hms-video": "^0.1.26",
64
+ "@cypress/code-coverage": "^3.9.11",
65
+ "@istanbuljs/nyc-config-typescript": "^1.0.1",
63
66
  "@size-limit/file": "^5.0.3",
64
- "events": "^3.3.0",
67
+ "babel-plugin-istanbul": "^6.1.1",
68
+ "cypress": "^8.7.0",
69
+ "dotenv": "^10.0.0",
65
70
  "husky": "^6.0.0",
71
+ "istanbul-lib-coverage": "^3.2.0",
72
+ "nyc": "^15.1.0",
66
73
  "size-limit": "^5.0.3",
74
+ "ts-node": "^10.4.0",
67
75
  "tsdx": "^0.14.1",
68
76
  "tslib": "^2.2.0",
69
77
  "typedoc": "^0.21.5",
70
78
  "typedoc-plugin-markdown": "^3.10.4",
71
- "typescript": "^4.3.2"
79
+ "typescript": "^4.4.4"
72
80
  },
73
81
  "description": "This is an addon to the core sdk provided by 100ms. It abstracts away the intricacies of data management and provides a flux based reactive data store where data flows in only one direction.",
74
82
  "repository": {
@@ -85,7 +93,34 @@
85
93
  "url": "https://github.com/100mslive/hms-video-store/issues"
86
94
  },
87
95
  "resolutions": {
88
- "tsdx/**/node-notifier": "10.0.0"
96
+ "tsdx/**/node-notifier": "10.0.0",
97
+ "**/@typescript-eslint/eslint-plugin": "^4.11.1",
98
+ "**/@typescript-eslint/parser": "^4.11.1",
99
+ "**/jest": "^26.6.3",
100
+ "**/ts-jest": "^26.4.4",
101
+ "**/typescript": "^4.4.4"
89
102
  },
90
- "homepage": "https://github.com/100mslive/hms-video-store#readme"
103
+ "homepage": "https://github.com/100mslive/hms-video-store#readme",
104
+ "nyc": {
105
+ "reporter": [
106
+ "lcov",
107
+ "text-summary",
108
+ "html"
109
+ ],
110
+ "extends": "@istanbuljs/nyc-config-typescript",
111
+ "all": true,
112
+ "check-coverage": true,
113
+ "include": [
114
+ "src/core/hmsSDKStore/**/*.ts",
115
+ "src/core/selectors/**/*.ts"
116
+ ],
117
+ "extension": [
118
+ ".ts",
119
+ ".js"
120
+ ],
121
+ "exclude": [
122
+ "**/*.spec.ts"
123
+ ],
124
+ "report-dir": "cy-coverage"
125
+ }
91
126
  }
@@ -1,4 +1,4 @@
1
- import EventEmitter from 'events';
1
+ import { EventEmitter2 as EventEmitter } from 'eventemitter2';
2
2
  import { IHMSNotifications } from '../IHMSNotifications';
3
3
  import { IHMSStore } from '../IHMSStore';
4
4
  import { selectPeerByID, selectTrackByID } from '../selectors';
@@ -70,4 +70,9 @@ export class HMSPlaylist implements IHMSPlaylistActions {
70
70
  setIsAutoplayOn(autoplay: boolean) {
71
71
  this.playlistManager.setIsAutoplayOn(this.type, autoplay);
72
72
  }
73
+
74
+ setPlaybackRate(playbackRate: number) {
75
+ this.playlistManager.setPlaybackRate(this.type, playbackRate);
76
+ this.syncPlaylistState(`set${this.type}PlaybackRate`);
77
+ }
73
78
  }
@@ -222,6 +222,7 @@ export class SDKToHMS {
222
222
  progress,
223
223
  volume,
224
224
  currentTime: playlistManager.getCurrentTime(type),
225
+ playbackRate: playlistManager.getPlaybackRate(type),
225
226
  };
226
227
  }
227
228
 
@@ -28,6 +28,7 @@ export interface HMSPlaylist<T> {
28
28
  progress: number;
29
29
  volume: number;
30
30
  currentTime: number;
31
+ playbackRate: number;
31
32
  };
32
33
  video: {
33
34
  list: Record<string, HMSPlaylistItem<T>>;
@@ -35,6 +36,7 @@ export interface HMSPlaylist<T> {
35
36
  progress: number;
36
37
  volume: number;
37
38
  currentTime: number;
39
+ playbackRate: number;
38
40
  };
39
41
  }
40
42
 
@@ -85,6 +87,12 @@ export interface IHMSPlaylistActions {
85
87
  * @param {boolean} autoplay
86
88
  */
87
89
  setIsAutoplayOn(autoplay: boolean): void;
90
+ /**
91
+ * Control the playback speed - 1.0 being normal, less than 1.0 will play it slowly
92
+ * and more than 1.0 will play it faster.
93
+ * @param playbackRate - value from 0.25 and 2.0
94
+ */
95
+ setPlaybackRate(playbackRate: number): void;
88
96
  }
89
97
 
90
98
  export interface HMSPlaylistSelector {
@@ -102,4 +110,5 @@ export interface HMSPlaylistSelector {
102
110
  progress: (store: HMSStore) => number;
103
111
  volume: (store: HMSStore) => number;
104
112
  currentTime: (store: HMSStore) => number;
113
+ playbackRate: (store: HMSStore) => number;
105
114
  }
@@ -64,6 +64,7 @@ export const createDefaultStoreState = (): HMSStore => {
64
64
  progress: 0,
65
65
  volume: 0,
66
66
  currentTime: 0,
67
+ playbackRate: 1.0,
67
68
  },
68
69
  video: {
69
70
  list: {},
@@ -71,6 +72,7 @@ export const createDefaultStoreState = (): HMSStore => {
71
72
  progress: 0,
72
73
  volume: 0,
73
74
  currentTime: 0,
75
+ playbackRate: 1.0,
74
76
  },
75
77
  },
76
78
  messages: { byID: {}, allIDs: [] },
@@ -19,6 +19,10 @@ const selectPlaylistCurrentTime = (type: HMSPlaylistType = HMSPlaylistType.audio
19
19
  store: HMSStore,
20
20
  ) => store.playlist[type].currentTime;
21
21
 
22
+ const selectPlaylistPlaybackRate = (type: HMSPlaylistType = HMSPlaylistType.audio) => (
23
+ store: HMSStore,
24
+ ) => store.playlist[type].playbackRate;
25
+
22
26
  const selectPlaylistVolume = (type: HMSPlaylistType = HMSPlaylistType.audio) => (store: HMSStore) =>
23
27
  store.playlist[type].volume;
24
28
 
@@ -46,6 +50,7 @@ export const selectAudioPlaylist: HMSPlaylistSelector = {
46
50
  selection: selectPlaylistSelection(HMSPlaylistType.audio),
47
51
  progress: selectPlaylistProgress(HMSPlaylistType.audio),
48
52
  currentTime: selectPlaylistCurrentTime(HMSPlaylistType.audio),
53
+ playbackRate: selectPlaylistPlaybackRate(HMSPlaylistType.audio),
49
54
  volume: selectPlaylistVolume(HMSPlaylistType.audio),
50
55
  list: selectPlaylist(HMSPlaylistType.audio),
51
56
  selectedItem: <any>selectPlaylistSelectedItem(HMSPlaylistType.audio),
@@ -54,7 +59,8 @@ export const selectAudioPlaylist: HMSPlaylistSelector = {
54
59
  export const selectVideoPlaylist: HMSPlaylistSelector = {
55
60
  selection: selectPlaylistSelection(HMSPlaylistType.video),
56
61
  progress: selectPlaylistProgress(HMSPlaylistType.video),
57
- currentTime: selectPlaylistCurrentTime(HMSPlaylistType.audio),
62
+ currentTime: selectPlaylistCurrentTime(HMSPlaylistType.video),
63
+ playbackRate: selectPlaylistPlaybackRate(HMSPlaylistType.video),
58
64
  volume: selectPlaylistVolume(HMSPlaylistType.video),
59
65
  list: selectPlaylist(HMSPlaylistType.video),
60
66
  selectedItem: <any>selectPlaylistSelectedItem(HMSPlaylistType.video),
@@ -128,6 +128,7 @@ export const makeFakeStore = (): HMSStore => {
128
128
  progress: 20,
129
129
  volume: 100,
130
130
  currentTime: 10,
131
+ playbackRate: 0.5,
131
132
  },
132
133
  video: {
133
134
  list: {
@@ -152,6 +153,7 @@ export const makeFakeStore = (): HMSStore => {
152
153
  progress: 30,
153
154
  volume: 100,
154
155
  currentTime: 20,
156
+ playbackRate: 1.0,
155
157
  },
156
158
  },
157
159
  messages: {
@@ -164,6 +164,8 @@ describe('secondary selectors', () => {
164
164
  const list = Object.values(playlist.audio.list);
165
165
  expect(selectAudioPlaylist.list(fakeStore)).toEqual(list);
166
166
  expect(selectAudioPlaylist.progress(fakeStore)).toBe(20);
167
+ expect(selectAudioPlaylist.currentTime(fakeStore)).toBe(10);
168
+ expect(selectAudioPlaylist.playbackRate(fakeStore)).toBe(0.5);
167
169
  expect(selectAudioPlaylist.selection(fakeStore)).toEqual({
168
170
  id: list[0].id,
169
171
  hasNext: true,
@@ -176,6 +178,8 @@ describe('secondary selectors', () => {
176
178
  const list = Object.values(playlist.video.list);
177
179
  expect(selectVideoPlaylist.list(fakeStore)).toEqual(list);
178
180
  expect(selectVideoPlaylist.progress(fakeStore)).toBe(30);
181
+ expect(selectVideoPlaylist.currentTime(fakeStore)).toBe(20);
182
+ expect(selectVideoPlaylist.playbackRate(fakeStore)).toBe(1.0);
179
183
  expect(selectVideoPlaylist.selection(fakeStore)).toEqual({
180
184
  id: list[0].id,
181
185
  hasNext: true,