Skip to content

Commit

Permalink
fix(fjagejs): cleaning up fjage-js types and adding type exporting
Browse files Browse the repository at this point in the history
  • Loading branch information
notthetup committed Oct 15, 2024
1 parent c3c2707 commit 5967ea7
Show file tree
Hide file tree
Showing 10 changed files with 789 additions and 400 deletions.
394 changes: 263 additions & 131 deletions docs/jsdoc/index.html

Large diffs are not rendered by default.

287 changes: 179 additions & 108 deletions gateways/js/dist/esm/fjage.js

Large diffs are not rendered by default.

286 changes: 179 additions & 107 deletions gateways/js/dist/fjage.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion gateways/js/eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default [
'quotes': [
'error',
'single'
]
],
}
}
];
39 changes: 36 additions & 3 deletions gateways/js/package-lock.json

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

10 changes: 6 additions & 4 deletions gateways/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
"dist/**"
],
"scripts": {
"build": "npx rimraf -rf dist/ && eslint src/*.js && rollup --silent -c rollup.config.js",
"pretest": "npx playwright install --with-deps && node test/spec/create-spec.cjs",
"build": "eslint src/*.js && tsc && rollup --silent -c rollup.config.js",
"pretest": "playwright install --with-deps && node test/spec/create-spec.cjs",
"test": "node test/run-tests.cjs",
"docs": "documentation build src/fjage.js -f html --github --document-exported -o ../../docs/jsdoc",
"clean": "npx rimraf -rf dist/"
"clean": "rimraf -rf dist/"
},
"repository": {
"type": "git",
Expand All @@ -36,12 +36,14 @@
"@playwright/test": "^1.41.0",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@types/node": "^22.7.5",
"documentation": "^14.0.2",
"eslint": "^8.55.0",
"globals": "^13.24.0",
"jasmine": "^5.1.0",
"node-static": "^0.7.11",
"rollup": "^4.8.0"
"rollup": "^4.8.0",
"typescript": "^5.6.3"
},
"dependencies": {
"browser-or-node": "^2.1.1"
Expand Down
18 changes: 10 additions & 8 deletions gateways/js/src/TCPConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var createConnection;
* @class
* @ignore
*/
export default class TCPConnector {
class TCPConnector {

/**
* Create an TCPConnector to connect to a fjage master over TCP
Expand Down Expand Up @@ -130,20 +130,20 @@ export default class TCPConnector {
return false;
}

/**
* @callback TCPConnectorReadCallback
* @ignore
* @param {string} s - incoming message string
*/

/**
* Set a callback for receiving incoming strings from the connector
* @param {TCPConnector~ReadCallback} cb - callback that is called when the connector gets a string
* @param {TCPConnectorReadCallback} cb - callback that is called when the connector gets a string
*/
setReadCallback(cb){
if (cb && {}.toString.call(cb) === '[object Function]') this._onSockRx = cb;
}

/**
* @callback TCPConnector~ReadCallback
* @ignore
* @param {string} s - incoming message string
*/

/**
* Add listener for connection events
* @param {function} listener - a listener callback that is called when the connection is opened/closed
Expand Down Expand Up @@ -188,3 +188,5 @@ export default class TCPConnector {
}
}
}

export default TCPConnector;
21 changes: 12 additions & 9 deletions gateways/js/src/WSConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const DEFAULT_RECONNECT_TIME = 5000; // ms, delay between retries to conne
* @class
* @ignore
*/
export default class WSConnector {
class WSConnector {

/**
* Create an WSConnector to connect to a fjage master over WebSockets
Expand All @@ -23,6 +23,7 @@ export default class WSConnector {
this.url.hostname = host;
this.url.port = port.toString();
this.url.pathname = opts.pathname || '/';
this._keepAlive = opts.keepAlive;
this._reconnectTime = opts.reconnectTime || DEFAULT_RECONNECT_TIME;
this.debug = opts.debug || false; // debug info to be logged to console?
this._firstConn = true; // if the Gateway has managed to connect to a server before
Expand Down Expand Up @@ -96,19 +97,19 @@ export default class WSConnector {
}

/**
* Set a callback for receiving incoming strings from the connector
* @param {WSConnector~ReadCallback} cb - callback that is called when the connector gets a string
* @callback WSConnectorReadCallback
* @ignore
* @param {string} s - incoming message string
*/
setReadCallback(cb){
if (cb && {}.toString.call(cb) === '[object Function]') this._onWebsockRx = cb;
}

/**
* @callback WSConnector~ReadCallback
* Set a callback for receiving incoming strings from the connector
* @param {WSConnectorReadCallback} cb - callback that is called when the connector gets a string
* @ignore
* @param {string} s - incoming message string
*/
setReadCallback(cb){
if (cb && {}.toString.call(cb) === '[object Function]') this._onWebsockRx = cb;
}

/**
* Add listener for connection events
Expand Down Expand Up @@ -149,4 +150,6 @@ export default class WSConnector {
this.sock.close();
}
}
}
}

export default WSConnector;
Loading

0 comments on commit 5967ea7

Please sign in to comment.