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

feat(FEC-9972): floating player #1

Merged
merged 20 commits into from
Jun 17, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
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
21 changes: 21 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"presets": [
"es2015"
],
"plugins": [
"transform-flow-strip-types",
"transform-class-properties",
["transform-react-jsx",
{
"pragma": "KalturaPlayer.ui.h"
}
]
],
"env": {
"test": {
"plugins": [
"istanbul"
]
}
}
}
10 changes: 10 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# http://editorconfig.org
root = true

[*]
charset = utf-8
indent_size = 2
end_of_line = lf
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/flow-typed/
/coverage
/dist
karma.conf.js
webpack.config.js
27 changes: 27 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"parser": "babel-eslint",
"extends": ["eslint:recommended", "plugin:flowtype/recommended", "plugin:react/recommended"],
"parserOptions": {
"sourceType": "module"
},
"plugins": ["prettier", "import", "flowtype", "mocha-no-only", "react"],
"env": {
"browser": true,
"es6": true,
"mocha": true,
"amd": true,
"commonjs": true
},
"globals": {
"should": true,
"sinon": true,
"__VERSION__": true,
"__NAME__": true
},
"rules": {
"prettier/prettier": "error",
"mocha-no-only/mocha-no-only": "off",
"require-jsdoc": ["error"],
"valid-jsdoc": ["error"]
}
}
7 changes: 7 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[ignore]
.*/node_modules
[include]
[libs]
node_modules/@playkit-js/playkit-js/flow-typed/
[options]
unsafe.enable_getters_and_setters=true
14 changes: 14 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### Description of the Changes

Please add a detailed description of the change, weather it's an enhancement or a bugfix.
If the PR is related to an open issue please link to it.

Solves FEC-XXXXX

### CheckLists

- [ ] changes have been done against master branch, and PR does not conflict
- [ ] new unit / functional tests have been added (whenever applicable)
- [ ] test are passing in local environment
- [ ] Travis tests are passing (or test results are not worse than on master branch :))
- [ ] Docs have been updated
45 changes: 45 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# MacOS
.DS_Store

# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm
.npmrc

# Optional REPL history
.node_repl_history

.idea

dist/
6 changes: 6 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/dist
/src/index.html
CHANGELOG.md
yarn.lock
yarn-error.log
LICENSE
12 changes: 12 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"printWidth": 150,
"tabWidth": 2,
"useTabs": false,
"semi": true,
"singleQuote": true,
"trailingComma": "none",
"bracketSpacing": false,
"jsxBracketSameLine": true,
"arrowParens": "avoid",
"proseWrap": "preserve"
}
88 changes: 88 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
conditions: v1
sudo: required
dist: xenial
language: node_js
node_js:
- "node"

addons:
chrome: stable

services:
- xvfb
cache:
yarn: true
directories:
- node_modules

before_install:
- export DISPLAY=:99.0
- chmod +x ./scripts/travis.sh

script: ./scripts/travis.sh

stages:
- Tests
- Release canary
- Release

jobs:
fast_finish: true
include:
# https://docs.travis-ci.com/user/build-stages/deploy-github-releases/
- stage: Release
name: "Releasing a new version"
if: tag IS present
env: TRAVIS_MODE=release
deploy:
- provider: releases
api_key: $GH_TOKEN
file_glob: true
file: dist/*
prerelease: true
skip_cleanup: true
on:
branch: master
tags: true
- provider: npm
edge: true
api_key: $NPM_TOKEN
email: $NPM_EMAIL
skip_cleanup: true
on:
tags: true
branch: master
after_deploy:
- chmod +x ./scripts/after_deploy.sh
- ./scripts/after_deploy.sh "visibilty" "$TRAVIS_TAG" "$JENKINS_TAG_TOKEN"
RoyBregman marked this conversation as resolved.
Show resolved Hide resolved
# publish canary package if on master
- stage: Release canary
if: (branch = master) AND (type != pull_request) AND commit_message !~ /^chore\(release\)/
env: TRAVIS_MODE=releaseCanary
deploy:
provider: npm
api_key: $NPM_TOKEN
email: $NPM_EMAIL
skip_cleanup: true
tag: canary
on:
tags: false
branch: master
after_deploy:
- currentVersion=$(npx -c 'echo "$npm_package_version"')
- echo $currentVersion
- chmod +x ./scripts/after_deploy.sh
- ./scripts/after_deploy.sh "visibilty" "$currentVersion" "$JENKINS_CANARY_TOKEN"
# Required tests
- stage: Tests
if: (branch = master) OR (tag IS present) OR (type = pull_request)
name: "Running lint"
env: TRAVIS_MODE=lint
- stage: Tests
if: (branch = master) OR (tag IS present) OR (type = pull_request)
name: "Running Flow type check"
env: TRAVIS_MODE=flow
- stage: Tests
if: (branch = master) OR (tag IS present) OR (type = pull_request)
name: "Running unit tests"
env: TRAVIS_MODE=unitTests
Empty file added CHANGELOG.md
Empty file.
106 changes: 106 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# PlayKit JS Visibility - Visibility plugin for the [PlayKit JS Player]


PlayKit JS Visibility is written in [ECMAScript6], statically analysed using [Flow] and transpiled in ECMAScript5 using [Babel].

[flow]: https://flow.org/
[ecmascript6]: https://github.com/ericdouglas/ES6-Learning#articles--tutorials
[babel]: https://babeljs.io

## Getting Started

### Prerequisites

The plugin requires [PlayKit JS Player] to be loaded first.

[playkit js player]: https://github.com/kaltura/playkit-js-visibility

### Installing

First, clone and run [yarn] to install dependencies:

[yarn]: https://yarnpkg.com/lang/en/

```
git clone https://github.com/kaltura/playkit-js-visibility.git
cd playkit-js-visibility
yarn install
```

### Building

Then, build the player

```javascript
yarn run build
```

### Embed the library in your test page

Finally, add the bundle as a script tag in your page, and initialize the player

```html
<script type="text/javascript" src="/PATH/TO/FILE/playkit.js"></script> <!--PlayKit player-->
<script type="text/javascript" src="/PATH/TO/FILE/playkit-visibility.js"></script> <!--PlayKit Visibility plugin-->
<div id="player-placeholder" style="height:360px; width:640px">
<script type="text/javascript">
var playerContainer = document.querySelector("#player-placeholder");
var config = {
...
plugins: {
visibility: {
}
}
...
};
var player = playkit.core.loadPlayer(config);
playerContainer.appendChild(player.getView());
player.play();
</script>
```

## Documentation

* **[Configuration](docs/configuration.md)**

## Running the tests

Tests can be run locally via [Karma], which will run on Chrome, Firefox and Safari

[karma]: https://karma-runner.github.io/1.0/index.html

```
yarn run test
```

You can test individual browsers:

```
yarn run test:chrome
yarn run test:firefox
yarn run test:safari
```

### And coding style tests

We use ESLint [recommended set](http://eslint.org/docs/rules/) with some additions for enforcing [Flow] types and other rules.

See [ESLint config](.eslintrc.json) for full configuration.

We also use [.editorconfig](.editorconfig) to maintain consistent coding styles and settings, please make sure you comply with the styling.

## Compatibility

TBD

## Contributing

Please read [CONTRIBUTING.md](https://gist.github.com/PurpleBooth/b24679402957c63ec426) for details on our code of conduct, and the process for submitting pull requests to us.

## Versioning

We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/kaltura/playkit-js-visibility/tags).

## License

This project is licensed under the AGPL-3.0 License - see the [LICENSE.md](LICENSE.md) file for details
27 changes: 27 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## Configuration
Visibility plugin configuration parameters are provided whenever a player instance is created.
```js
var config = {
plugins: {
visibility: {
// Visibility configuration here
}
}
};
var player = KalturaPlayer.setup(config);
```

#### Configuration Structure

The configuration uses the following structure:

```js
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

}
```

#### Default Configuration Values
```js
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't do any documentation yet. Will complete this in the next phase

{
}
```
4 changes: 4 additions & 0 deletions flow-typed/modules/intersection-observer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @flow
declare module 'intersection-observer' {
declare module.exports: any;
}
4 changes: 4 additions & 0 deletions flow-typed/modules/playkit-js-ui.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @flow
declare module 'playkit-js-ui' {
declare module.exports: any;
}
4 changes: 4 additions & 0 deletions flow-typed/modules/playkit-js.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// @flow
declare module 'playkit-js' {
declare module.exports: any;
}
2 changes: 2 additions & 0 deletions flow-typed/types/visibility-types.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// @flow
declare type PKVisibilityTypes = { [type: string]: string };
Loading