-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fjage.js): add support for generating typescript types
- Loading branch information
Showing
6 changed files
with
534 additions
and
10 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
// Change this to match your project | ||
"include": ["src/**/*"], | ||
"compilerOptions": { | ||
// Tells TypeScript to read JS files, as | ||
// normally they are ignored as source files | ||
"allowJs": true, | ||
// Generate d.ts files | ||
"declaration": true, | ||
// This compiler run should | ||
// only output d.ts files | ||
"emitDeclarationOnly": true, | ||
// Types should go into this directory. | ||
// Removing this would place the .d.ts files | ||
// next to the .js files | ||
"outDir": "dist", | ||
// go to js file when using IDE functions like | ||
// "Go to Definition" in VSCode | ||
"declarationMap": true | ||
} | ||
} |
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,61 @@ | ||
/** | ||
* @class | ||
* @ignore | ||
*/ | ||
export default class TCPconnector { | ||
/** | ||
* Create an TCPConnector to connect to a fjage master over TCP | ||
* @param {Object} opts | ||
* @param {String} [opts.hostname='localhost'] - ip address/hostname of the master container to connect to | ||
* @param {number} opts.port - port number of the master container to connect to | ||
*/ | ||
constructor(opts?: { | ||
hostname?: string; | ||
port: number; | ||
}); | ||
url: URL; | ||
_buf: string; | ||
pendingOnOpen: any[]; | ||
connListeners: any[]; | ||
_sendConnEvent(val: any): void; | ||
_sockInit(host: any, port: any): void; | ||
_sockSetup(host: any, port: any): void; | ||
sock: any; | ||
_sockReconnect(): void; | ||
_firstReConn: boolean; | ||
_onSockOpen(): void; | ||
_processSockData(s: any): void; | ||
toString(): string; | ||
/** | ||
* Write a string to the connector | ||
* @param {string} s - string to be written out of the connector to the master | ||
* @return {boolean} - true if connect was able to write or queue the string to the underlying socket | ||
*/ | ||
write(s: string): boolean; | ||
/** | ||
* Set a callback for receiving incoming strings from the connector | ||
* @param {TCPConnector~ReadCallback} cb - callback that is called when the connector gets a string | ||
*/ | ||
setReadCallback(cb: any): void; | ||
_onSockRx: any; | ||
/** | ||
* @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 | ||
*/ | ||
addConnectionListener(listener: Function): void; | ||
/** | ||
* Remove listener for connection events | ||
* @param {function} listener - remove the listener for connection | ||
* @return {boolean} - true if the listner was removed successfully | ||
*/ | ||
removeConnectionListener(listener: Function): boolean; | ||
/** | ||
* Close the connector | ||
*/ | ||
close(): void; | ||
} |
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,68 @@ | ||
/** | ||
* @class | ||
* @ignore | ||
*/ | ||
export default class WSConnector { | ||
/** | ||
* Create an WSConnector to connect to a fjage master over WebSockets | ||
* @param {Object} opts | ||
* @param {string} opts.hostname - hostname/ip address of the master container to connect to | ||
* @param {number} opts.port - port number of the master container to connect to | ||
* @param {string} opts.pathname - path of the master container to connect to | ||
* @param {boolean} opts.keepAlive - try to reconnect if the connection is lost | ||
* @param {number} [opts.reconnectTime=5000] - time before reconnection is attempted after an error | ||
*/ | ||
constructor(opts?: { | ||
hostname: string; | ||
port: number; | ||
pathname: string; | ||
keepAlive: boolean; | ||
reconnectTime?: number; | ||
}); | ||
url: URL; | ||
_reconnectTime: number; | ||
_keepAlive: boolean; | ||
debug: any; | ||
_firstConn: boolean; | ||
_firstReConn: boolean; | ||
pendingOnOpen: any[]; | ||
connListeners: any[]; | ||
_sendConnEvent(val: any): void; | ||
_websockSetup(url: any): void; | ||
sock: WebSocket; | ||
_websockReconnect(): void; | ||
_onWebsockOpen(): void; | ||
toString(): string; | ||
/** | ||
* Write a string to the connector | ||
* @param {string} s - string to be written out of the connector to the master | ||
*/ | ||
write(s: string): boolean; | ||
/** | ||
* Set a callback for receiving incoming strings from the connector | ||
* @param {WSConnector~ReadCallback} cb - callback that is called when the connector gets a string | ||
* @ignore | ||
*/ | ||
setReadCallback(cb: any): void; | ||
_onWebsockRx: any; | ||
/** | ||
* @callback WSConnector~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 | ||
*/ | ||
addConnectionListener(listener: Function): void; | ||
/** | ||
* Remove listener for connection events | ||
* @param {function} listener - remove the listener for connection | ||
* @return {boolean} - true if the listner was removed successfully | ||
*/ | ||
removeConnectionListener(listener: Function): boolean; | ||
/** | ||
* Close the connector | ||
*/ | ||
close(): void; | ||
} |
Oops, something went wrong.