Skip to content

Commit

Permalink
Refactor code to typscript (#256)
Browse files Browse the repository at this point in the history
* Start on copying over typescript code from own fork

* Replace tslint with eslint

* Update to use new import

* make second argument not optional

* Upgrade libs

* Add github action to compile and test the code

* Remove dtslint

* Remove dist folder before building

* Fix the callback method

* Remove test for nodejs 10

* Disable callbacks

* Swap out some libs

* Ignore internal message

* Revert that

* Implement suggestions from review

* Fix workflow file:

* Prepend ws protocol if none is present

* minor fixes
  • Loading branch information
duncte123 authored Aug 15, 2021
1 parent 36633b3 commit 02a0966
Show file tree
Hide file tree
Showing 31 changed files with 5,121 additions and 6,634 deletions.
20 changes: 12 additions & 8 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
node_modules
bower_components
.github
.travis
dist
coverage
.nyc_output
samples
node_modules/
bower_components/
.github/
.travis/
dist/
browser-dist/
coverage/
.nyc_output/
samples/
lib/API.js
test/
src/typings/obsWebsocket.ts
scripts/

# Adding an exclusion for the webpack config to make node 4 travis builds easier.
webpack.config.js
21 changes: 21 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"plugins": ["@typescript-eslint"],
"parser": "@typescript-eslint/parser",
"env": {
"es2021": true,
"node": true
},
"extends": [
"xo",
"xo-typescript/space"
],
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"rules": {
"@typescript-eslint/no-implicit-any-catch": "off",
"@typescript-eslint/no-unsafe-member-access": "off",
"@typescript-eslint/no-unsafe-call": "off"
}
}
42 changes: 42 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions

name: Node.js CI

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [12.x, 14.x, 16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- uses: actions/cache@v2
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
# we may need this, not sure
# - run: npm install json -g
- run: npm ci
- run: npm run build
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- run: npm test
# Currently broken
#- run: npm run node-coveralls
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,6 @@ coverage

# Exclude build outputs (they'll get added automatically by CI).
dist
browser-dist
types/index.d.ts
CHANGELOG.md
31 changes: 0 additions & 31 deletions .travis/tsconfig.json

This file was deleted.

17 changes: 0 additions & 17 deletions .travis/tslint.json

This file was deleted.

14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ OBSWebSocket.JS allows Javascript-based connections to the Open Broadcaster plug
## Installation

```sh
# with npm
npm install obs-websocket-js --save

# with yarn
yarn add obs-websocket-js

# with bower
bower install obs-websocket-js --save
```

Expand All @@ -46,7 +51,7 @@ The web distributable exposes a global named `OBSWebSocket`.
In node...

```js
const OBSWebSocket = require('obs-websocket-js');
const { OBSWebSocket } = require('obs-websocket-js');
```

Create a new WebSocket connection using the following.
Expand All @@ -69,9 +74,6 @@ _Note that all response objects will supply both the original [obs-websocket][li
// Promise API
obs.send('RequestName', {args}) // returns Promise

// Callback API
obs.sendCallback('RequestName', {args}, callback(err, data)) // no return value

// The following are additional supported requests.
obs.connect({ address: 'address', password: 'password' }) // returns Promise
obs.disconnect();
Expand Down Expand Up @@ -112,7 +114,7 @@ obs.on('error', err => {
#### Example
See more examples in [`\samples`](samples).
```js
const OBSWebSocket = require('obs-websocket-js');
const { OBSWebSocket } = require('obs-websocket-js');

const obs = new OBSWebSocket();
obs.connect({
Expand Down Expand Up @@ -205,7 +207,7 @@ obs.on('SwitchScenes');
});

// Use this instead:
obs.sendCallback('StartStreaming', (error) => {
obs.send('StartStreaming').catch(error => {
// Code here...
});
```
Expand Down
179 changes: 0 additions & 179 deletions lib/Socket.js

This file was deleted.

Loading

0 comments on commit 02a0966

Please sign in to comment.