Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add typings #1

Merged
merged 9 commits into from
Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
final fix
  • Loading branch information
Ilya Istomin committed Dec 20, 2019
commit 598d7568a94e68cfc43052a2ab37a2fb2b0788ba
4 changes: 2 additions & 2 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ tsconfig.json
package-lock.json

# tests
webOS-tests.ts
webOSDev-tests.ts
webOSTV/webOS-tests.ts
webOSTV-dev/webOSDev-tests.ts
42 changes: 20 additions & 22 deletions main.d.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
// declare namespace WebOSTVLibrary {
/**
* Make all properties in T optional
*/
// type Partial<T> = {
// [P in keyof T]?: T[P];
// };
/**
* Make all properties in T optional
*/
type PartialObject<T> = {
[P in keyof T]?: T[P];
};

interface RequestParams<T> {
onSuccess: (result: T) => any;
onFailure: (error: RequestErrorObject) => any;
}
interface RequestParams<T> {
onSuccess: (result: T) => any;
onFailure: (error: RequestErrorObject) => any;
}

interface RequestErrorObject {
errorCode: string;
errorText: string;
}
interface RequestErrorObject {
errorCode: string;
errorText: string;
}

/**
* Construct a type with a set of properties K of type T
*/
interface ObjectValue {
[k: string]: any;
}
// }
/**
* Construct a type with a set of properties K of type T
*/
interface ObjectValue {
[k: string]: any;
}
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "npm run tslint && npm run dtslint",
"tslint": "tslint -p ./tsconfig.json *.ts",
"dtslint": "dtslint ."
"tslint": "tslint -p ./tsconfig.json */*.ts"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"compilerOptions": {
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "ES6", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": ["ES6", "DOM"],
"lib": ["DOM", "ES5"],

"strict": true, /* Enable all strict type-checking options. */
"noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
Expand Down
5 changes: 3 additions & 2 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
"semicolon": false,
"indent": [true, "spaces", 4],
"no-single-declare-module": false,
"quotemark": [true, "single"]
"quotemark": [true, "single"],
"no-bad-reference": false
},
"linterOptions": {
"exclude": [
"node_modules",
"**/*.js"
]
}
}
}
186 changes: 92 additions & 94 deletions webOSTV-dev/drmAgent.d.ts
Original file line number Diff line number Diff line change
@@ -1,99 +1,97 @@
// declare namespace WebOSTVDev.DRMAgent {
interface DRMAgent {
/**
* Returns a client ID of DRM.
*/
getClientId(): string;
/**
* Returns a DRM type to be set.
*/
getDrmType(): DRMType[keyof DRMType];
/**
* Returns an error code from the DRM service.
*/
getErrorCode(): DRMError[keyof DRMError];
/**
* Returns a text represented by an error from the DRM service.
*/
getErrorText(): string;
/**
* Returns error information when an error of the DRM license occurs during content playback.
* This method is supported in the following DRM type only:
* - PlayReady
*/
getRightsError(params: RequestParams<GetRightsErrorResponse>): void;
/**
* Checks whether a DRM client that corresponds to given application ID exists.
*/
isLoaded(params: RequestParams<IsLoadedResponse>): void;
/**
* Creates a client instance for a certain type of DRM.
* The DRM type is specified when a DRM agent is created.
*/
load(params: RequestParams<LoadResponse>): void;
/**
* Sends a DRM message to a DRM service.
* After receiving the message, the DRM service starts to parse the message and perform the DRM operation.
*/
sendDrmMessage(params?: SendDrmMessageParams): void;
/**
* Removes a DRM client instance and deallocates relevant resources.
*/
unload(params: RequestParams<{}>): void;
}
interface DRMAgent {
/**
* Returns a client ID of DRM.
*/
getClientId(): string;
/**
* Returns a DRM type to be set.
*/
getDrmType(): DRMType[keyof DRMType];
/**
* Returns an error code from the DRM service.
*/
getErrorCode(): DRMError[keyof DRMError];
/**
* Returns a text represented by an error from the DRM service.
*/
getErrorText(): string;
/**
* Returns error information when an error of the DRM license occurs during content playback.
* This method is supported in the following DRM type only:
* - PlayReady
*/
getRightsError(params: RequestParams<GetRightsErrorResponse>): void;
/**
* Checks whether a DRM client that corresponds to given application ID exists.
*/
isLoaded(params: RequestParams<IsLoadedResponse>): void;
/**
* Creates a client instance for a certain type of DRM.
* The DRM type is specified when a DRM agent is created.
*/
load(params: RequestParams<LoadResponse>): void;
/**
* Sends a DRM message to a DRM service.
* After receiving the message, the DRM service starts to parse the message and perform the DRM operation.
*/
sendDrmMessage(params?: SendDrmMessageParams): void;
/**
* Removes a DRM client instance and deallocates relevant resources.
*/
unload(params: RequestParams<{}>): void;
}

interface GetRightsErrorResponse {
/**
* Flag that indicates whether the subscription is enabled or not.
* - true: Enabled
* - false: Not enabled
*/
subscribed: boolean;
}
interface GetRightsErrorResponse {
/**
* Flag that indicates whether the subscription is enabled or not.
* - true: Enabled
* - false: Not enabled
*/
subscribed: boolean;
}

interface IsLoadedResponse {
/**
* Indicates the DRM client is loaded.
* - true: the DRM client is loaded.
* - false: the DRM client is not loaded.
*/
loadStatus: boolean;
/**
* Returns the loaded client ID when the DRM client is loaded successfully.
*/
clientId: string;
/**
* Returns the client type of DRM when the DRM client is loaded successfully.
*/
drmType: DRMType[keyof DRMType];
}
interface IsLoadedResponse {
/**
* Indicates the DRM client is loaded.
* - true: the DRM client is loaded.
* - false: the DRM client is not loaded.
*/
loadStatus: boolean;
/**
* Returns the loaded client ID when the DRM client is loaded successfully.
*/
clientId: string;
/**
* Returns the client type of DRM when the DRM client is loaded successfully.
*/
drmType: DRMType[keyof DRMType];
}

interface LoadResponse {
/**
* If the DRM agent loaded the DRM client successfully, return its client ID.
*/
clientId: string;
}
interface LoadResponse {
/**
* If the DRM agent loaded the DRM client successfully, return its client ID.
*/
clientId: string;
}

interface SendDrmMessageParams extends RequestParams<SendDrmMessageResponse> {
/**
* The message to be provided to the underlying DRM server, which is formatted according to the DRM type.
*/
msg: string;
}
interface SendDrmMessageParams extends RequestParams<SendDrmMessageResponse> {
/**
* The message to be provided to the underlying DRM server, which is formatted according to the DRM type.
*/
msg: string;
}

interface SendDrmMessageResponse {
/**
* The unique ID of message which has led to this resulting message.
*/
msgId?: string;
/**
* The result code only for PlayReady.
*/
resultCode?: number;
/**
* The DRM system specific result message only for PlayReady.
*/
resultMsg?: string;
}
// }
interface SendDrmMessageResponse {
/**
* The unique ID of message which has led to this resulting message.
*/
msgId?: string;
/**
* The result code only for PlayReady.
*/
resultCode?: number;
/**
* The DRM system specific result message only for PlayReady.
*/
resultMsg?: string;
}
Loading