@tivio/sdk-js 2.0.0-alpha → 2.1.0-alpha

Sign up to get free protection for your applications and to get access to all the features.
@@ -18,7 +18,7 @@ export declare type RemoteBundleState = {
18
18
  error: string | null;
19
19
  conf: InternalConf;
20
20
  settings: Settings;
21
- } & Partial<ExposedApi>;
21
+ } & Omit<Partial<ExposedApi>, 'createPlayerWrapper'>;
22
22
  export declare type Api = RemoteBundleState;
23
23
  export declare const fetchBundleViaResolver: (conf: InternalConf) => Promise<string>;
24
24
  /**
@@ -0,0 +1,29 @@
1
+ import { AdMetadata, PlayerInterfaceForPlayerWrapper, PlayerWrapperEventType, Source, TivioPlayerWrapper } from '../api.types';
2
+ import { InternalPlayerWrapper } from './playerWrapperInternal';
3
+ import type { CreatePlayerWrapperType } from './playerWrapperInternal';
4
+ /**
5
+ * Player wrapper which instances are exposed to SDK user.
6
+ */
7
+ export declare class PlayerWrapper implements TivioPlayerWrapper {
8
+ private internalPlayerWrapper;
9
+ constructor(internalPlayerWrapper: InternalPlayerWrapper);
10
+ addEventListener(eventType: PlayerWrapperEventType.adMetadata, listener: (metadata: AdMetadata) => void): void;
11
+ reportError(error: Error): void;
12
+ reportPlaybackEnded(): void;
13
+ reportTimeProgress(ms: number): void;
14
+ seekTo(ms: number): void;
15
+ setSource(source: Source | null): void;
16
+ }
17
+ /**
18
+ * Called when tivio is initialized (remote bundle is ready).
19
+ *
20
+ * @param {CreatePlayerWrapperType} createPlayerWrapper - functions which creates player wrapper in core-js
21
+ */
22
+ export declare const onCreatePlayerWrapperReady: (createPlayerWrapper: CreatePlayerWrapperType) => void;
23
+ /**
24
+ * Public method accessible in SDK.
25
+ *
26
+ * @param {PlayerInterfaceForPlayerWrapper} playerImplementation - player implementation from SDK user
27
+ * @returns player wrapper instance
28
+ */
29
+ export declare const createPlayerWrapper: (playerImplementation: PlayerInterfaceForPlayerWrapper) => PlayerWrapper;
@@ -0,0 +1,28 @@
1
+ import { AdMetadata, PlayerInterfaceForPlayerWrapper, PlayerWrapperEventType, Source, TivioPlayerWrapper } from '../api.types';
2
+ export declare type CreatePlayerWrapperType = (playerImplementation: PlayerInterfaceForPlayerWrapper) => TivioPlayerWrapper;
3
+ /**
4
+ * Responsible for handling of all player wrapper methods (it's called through PlayerWrapper).
5
+ * Also handles state when player wrapper from core-js is not ready yet and situation when it becomes ready.
6
+ */
7
+ export declare class InternalPlayerWrapper implements TivioPlayerWrapper {
8
+ private playerImplementation;
9
+ private id;
10
+ corePlayerWrapperInstance: TivioPlayerWrapper | null;
11
+ listenersWaitingToRegister: {
12
+ eventType: PlayerWrapperEventType.adMetadata;
13
+ listener: (metadata: AdMetadata) => void;
14
+ }[];
15
+ constructor(playerImplementation: PlayerInterfaceForPlayerWrapper, id: string);
16
+ addEventListener(eventType: PlayerWrapperEventType.adMetadata, listener: (metadata: AdMetadata) => void): void;
17
+ reportError(error: Error): void;
18
+ reportPlaybackEnded(): void;
19
+ reportTimeProgress(ms: number): void;
20
+ seekTo(ms: number): void;
21
+ setSource(source: Source | null): void;
22
+ /**
23
+ * Set instance of the real player wrapper (from core-js).
24
+ *
25
+ * @param createPlayerWrapper - create player wrapper method from core-js
26
+ */
27
+ onPlayerWrapperReady(createPlayerWrapper: CreatePlayerWrapperType): void;
28
+ }
package/dist/types.d.ts CHANGED
@@ -6,6 +6,7 @@
6
6
  * Export public client side API
7
7
  */
8
8
  import { InternalConf } from './conf';
9
- export declare type Conf = Pick<InternalConf, 'secret' | 'logger' | 'language'>;
9
+ export { PlayerCapability } from './conf';
10
+ export declare type Conf = Pick<InternalConf, 'bundleUrlOverride' | 'capabilitiesOptions' | 'deviceCapabilities' | 'enableSentry' | 'forceCloudFnResolver' | 'language' | 'logger' | 'secret' | 'verbose'>;
10
11
  export declare type Empty = Promise<void> | void;
11
12
  export declare type Disposer = () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tivio/sdk-js",
3
- "version": "2.0.0-alpha",
3
+ "version": "2.1.0-alpha",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
6
6
  "source": "src/index.ts",
@@ -18,8 +18,10 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "@sentry/browser": "^6.1.0",
21
+ "core-js": "^3.21.0",
21
22
  "firebase": "^8.2.3",
22
- "mobx": "^6.0.4"
23
+ "mobx": "^6.0.4",
24
+ "whatwg-fetch": "^3.6.2"
23
25
  },
24
26
  "devDependencies": {
25
27
  "@tivio/common": "*",
@@ -32,6 +34,7 @@
32
34
  "dotenv": "^8.2.0",
33
35
  "dotenv-webpack": "^7.0.3",
34
36
  "eslint": "^7.19.0",
37
+ "fork-ts-checker-webpack-plugin": "^7.0.0",
35
38
  "jest": "^26.6.3",
36
39
  "jest-cli": "^26.6.3",
37
40
  "jest-fetch-mock": "^3.0.3",