-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add player apis in new provider SDK
- Loading branch information
Showing
17 changed files
with
252 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
build/* | ||
src/* | ||
test/* | ||
.DS_Store | ||
jest.config.* | ||
tsconfig.* |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../CONTRIBUTING.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../../NOTICE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--- | ||
title: Firebolt Provider SDK | ||
--- | ||
|
||
[![semantic-release: conventional](https://img.shields.io/badge/semantic--release-conventional-e10079?logo=semantic-release)](https://github.com/semantic-release/semantic-release) | ||
|
||
# Firebolt Provider SDK | ||
For building Firebolt compliant apps that manage Firebolt devices. | ||
|
||
## Usage | ||
To install, run: | ||
|
||
``` | ||
npm install @firebolt-js/provider-sdk | ||
``` | ||
|
||
To use the package, import one of it's modules, e.g.: | ||
|
||
```js | ||
import { Privacy } from '@firebolt-js/provider-sdk' | ||
``` | ||
|
||
## Contributing | ||
The Firebolt SDKs are built using the Firebolt OpenRPC toolset: | ||
|
||
See [Firebolt OpenRPC](https://www.github.com/rdkcentral/firebolt-openrpc/), for more info. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
if (!window.__firebolt) { | ||
window.__firebolt = {} | ||
} | ||
|
||
// wires up the mock transport w/out waiting | ||
window.__firebolt.mockTransportLayer = true | ||
|
||
// sets a flag that mock defaults impls can use to speed things up, e.g. Lifecycle/defaults.js | ||
window.__firebolt.automation = true | ||
|
||
let sendListener | ||
let receiver | ||
|
||
export const transport = { | ||
send: function(message) { | ||
const json = JSON.parse(message) | ||
sendListener && sendListener(json) | ||
}, | ||
receive: function(callback) { | ||
// store the callback | ||
receiver = callback | ||
}, | ||
onSend: function(listener) { | ||
sendListener = listener | ||
}, | ||
response: function(id, result) { | ||
let response = { | ||
jsonrpc: '2.0', | ||
id: id, | ||
result: result | ||
} | ||
receiver && receiver(JSON.stringify(response)) | ||
} | ||
} | ||
|
||
window.__firebolt.setTransportLayer(transport) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.(jsx?|js?)$", | ||
"transform": {}, | ||
"testPathIgnorePatterns": ["<rootDir>/node_modules/", "<rootDir>/../../../test"], | ||
"moduleFileExtensions": ["js", "jsx", "mjs"], | ||
"verbose": true, | ||
"testEnvironment": "jest-environment-jsdom" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{ | ||
"name": "@firebolt-js/provider-sdk", | ||
"version": "0.16.0-next.3", | ||
"description": "The Firebolt Provider JS SDK", | ||
"main": "./dist/lib/firebolt-provider.mjs", | ||
"types": "./dist/lib/firebolt-provider.d.ts", | ||
"exports": { | ||
".": "./dist/lib/firebolt-provider.mjs" | ||
}, | ||
"type": "module", | ||
"scripts": { | ||
"validate": "npx firebolt-openrpc validate --input ./dist/firebolt-provider-open-rpc.json", | ||
"sdk": "npx firebolt-openrpc sdk --input ./dist/firebolt-provider-open-rpc.json --template ./src/js --output ./build/javascript/src", | ||
"native": "npx firebolt-openrpc sdk --input ./dist/firebolt-provider-open-rpc.json --template ./src/js --output ./build/c/src --language ../../../node_modules/@firebolt-js/openrpc/languages/c", | ||
"compile": "cd ../../.. && npm run compile", | ||
"slice": "npx firebolt-openrpc slice -i ../../../dist/firebolt-open-rpc.json --sdk ./sdk.config.json -o ./dist/firebolt-provider-open-rpc.json", | ||
"docs": "npx firebolt-openrpc docs --input ./dist/firebolt-provider-open-rpc.json --output build/docs/markdown --as-path", | ||
"wiki": "npx firebolt-openrpc docs --input ./dist/firebolt-provider-open-rpc.json --output build/docs/markdown", | ||
"dist:notest": "npm run clean && npm run slice && npm run validate && npm run sdk && npm run docs && npm run dist:copy && echo 'Firebolt Provider SDK /dist/ is ready.\n'", | ||
"dist:copy": "npm run dist:copy:sdk && npm run dist:copy:docs", | ||
"dist:copy:sdk": "mkdirp ./dist && cp -R build/javascript/src dist/lib && cp ./dist/firebolt-provider-open-rpc.json ../../../dist/firebolt-provider-open-rpc.json", | ||
"dist:copy:docs": "mkdirp ./dist && cp -R build/docs/markdown dist/docs", | ||
"dist": "npm run dist:notest && npm run test", | ||
"clean": "rm -rf ./build && rm -rf ./dist", | ||
"test:setup": "rm -rf test/transpiled-suite && npx tsc --target es6 --moduleResolution node --outDir test/transpiled-suite", | ||
"test": "npm run test:setup && NODE_OPTIONS=--experimental-vm-modules npx --config=jest.config.json --detectOpenHandles jest", | ||
"prepack": "node ../../js/version.mjs validate && npm run broilerplate", | ||
"broilerplate": "rm ./CONTRIBUTING.md && cp ../../../CONTRIBUTING.md ./CONTRIBUTING.md && rm ./LICENSE && cp ../../../LICENSE ./LICENSE && rm ./NOTICE && cp ../../../NOTICE ./NOTICE" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/rdkcentral/firebolt-core-sdk", | ||
"directory": "src/sdks/provider" | ||
}, | ||
"author": "", | ||
"bugs": { | ||
"url": "https://github.com/rdkcentral/firebolt-core-sdk/issues" | ||
}, | ||
"homepage": "https://github.com/rdkcentral/firebolt-core-sdk#readme", | ||
"devDependencies": { | ||
"jest": "^28.1.0", | ||
"jest-environment-jsdom": "^28.1.3", | ||
"typescript": "^4.6.4" | ||
}, | ||
"keywords": [ | ||
"firebolt", | ||
"apps", | ||
"sdk" | ||
], | ||
"license": "Apache-2.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"info": { | ||
"title": "Firebolt Provider SDK", | ||
"x-interface-names": {} | ||
}, | ||
"methods": [ | ||
{ | ||
"module": "Player", | ||
"provide": [ | ||
"xrn:firebolt:capability:player:base" | ||
] | ||
}, | ||
{ | ||
"module": "BroadcastPlayer", | ||
"provide": [ | ||
"xrn:firebolt:capability:player:broadcast" | ||
] | ||
}, | ||
{ | ||
"module": "StreamingPlayer", | ||
"provide": [ | ||
"xrn:firebolt:capability:player:streaming" | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2021 Comcast Cable Communications Management, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { setMockResponses } from './Transport/MockTransport.mjs' | ||
|
||
/* ${MOCK_IMPORTS} */ | ||
|
||
setMockResponses({ | ||
/* ${MOCK_OBJECTS} */ | ||
}) | ||
|
||
/* ${EXPORTS} */ | ||
export { default as Log } from './Log/index.mjs' | ||
export { default as Events } from './Events/index.mjs' | ||
export { default as Settings } from './Settings/index.mjs' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright 2021 Comcast Cable Communications Management, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { test, expect } from '@jest/globals' | ||
import { Player } from '../../build/javascript/src/firebolt-provider' | ||
|
||
test('Player.provideStatus()', async () => { | ||
const resp = await Player.provideStatus('abc', { | ||
mediaSessionId: '123', | ||
state: 'PLAYING' | ||
}) | ||
expect(resp).toEqual(null) | ||
}) | ||
|
||
test('Player.provideProgress', async () => { | ||
const resp = await Player.provideProgress('abc', { | ||
startPosition: 0, | ||
position: 60000, | ||
endPosition: 3600000, | ||
liveSyncTime: '2021-04-23T18:25:43.511Z', | ||
speed: 1 | ||
}) | ||
expect(resp).toEqual(null) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"include": [ | ||
"test/suite/*" | ||
] | ||
} |