Skip to content

Commit 1747064

Browse files
committed
Update Docs & Readme
1 parent 2a236b7 commit 1747064

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1425
-1532
lines changed

LogEmitter/index.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,17 @@ export declare interface Logger {
1212
}
1313

1414
export class Logger extends EventEmitter {
15-
1615
private logStream: fs.WriteStream = null;
1716
private static _instance: Logger;
1817
private timeStart: number;
1918

20-
constructor (_fileName?: string) {
19+
20+
/**
21+
* Logger Utility Class
22+
* @param {string} _fileName
23+
*/
24+
constructor(_fileName?: string) {
2125
super();
22-
2326
const fileName = _fileName || 'log.txt';
2427
this.logStream = fs.createWriteStream(fileName);//, {flags: 'a'});
2528
const hrTime = process.hrtime();
@@ -32,7 +35,7 @@ export class Logger extends EventEmitter {
3235
return this._instance || (this._instance = new this());
3336
}
3437

35-
private logEntry(...args: any){
38+
private logEntry(...args: any) {
3639
const hrTime = process.hrtime();
3740
const logTime = Math.floor((hrTime[0] * 1000000 + hrTime[1] / 1000));
3841
this.logStream.write(`[${logTime - this.timeStart}] ${[args.join(' ')]}\n`);

README.md

+9-6
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,21 @@ const stageLinqOptions: StageLinqOptions = {
4141
downloadDbSources: true,
4242
actingAs: ActingAsDevice.StageLinqJS,
4343
services: [
44-
ServiceList.StateMap,
45-
ServiceList.BeatInfo,
46-
ServiceList.FileTransfer,
44+
Services.StateMap,
45+
Services.BeatInfo,
46+
Services.FileTransfer,
4747
],
4848
}
4949
```
5050

5151
## Starting StageLinq
5252

53-
StageLinq is started as it was previously:
53+
The main StageLinq class is now a Static Class:
5454
```ts
55-
const stageLinq = new StageLinq(stageLinqOptions);
55+
StageLinq.options = stageLinqOptions;
5656

57-
await stageLinq.connect();
57+
await StageLinq.connect();
58+
await StageLinq.disconnect();
5859
```
5960

6061

@@ -112,6 +113,8 @@ public getDevices(): ConnectionInfo[] {
112113

113114

114115
## StateMap
116+
117+
115118
```ts
116119
StateMap.emitter.on('newDevice', (service: StateMapDevice) => {
117120
console.log(`[STATEMAP] Subscribing to States on ${service.deviceId.string}`);

Sources/DbConnection.ts

+8-13
Original file line numberDiff line numberDiff line change
@@ -55,33 +55,28 @@ export class DbConnection {
5555
* @returns {Promise<Track>}
5656
*/
5757
async getTrackInfo(_trackPath: string): Promise<TrackDBEntry> {
58-
let result: TrackDBEntry[];
59-
60-
//console.dir(_trackPath.split('/'))
6158
const trackPath = _trackPath.split('/').slice(5, _trackPath.length).join('/')
62-
//console.log(trackPath)
63-
//if (/streaming:\/\//.test(trackPath)) {
64-
// result = this.querySource('SELECT * FROM Track WHERE uri = (?) LIMIT 1', trackPath);
65-
//} else {
66-
result = this.querySource('SELECT * FROM Track WHERE path = (?) LIMIT 1', trackPath);
67-
//}
59+
const result: TrackDBEntry[] = this.querySource('SELECT * FROM Track WHERE path = (?) LIMIT 1', trackPath);
6860
if (!result) throw new Error(`Could not find track: ${trackPath} in database.`);
61+
6962
result[0].trackData = await this.zInflate(result[0].trackData);
7063
result[0].overviewWaveFormData = await this.zInflate(result[0].overviewWaveFormData);
7164
result[0].beatData = await this.zInflate(result[0].beatData);
7265

7366
return result[0];
7467
}
7568

69+
/**
70+
*
71+
* @param {number} id /ID of track in the database
72+
* @returns {Promise<TrackDBEntry>}
73+
*/
7674
async getTrackById(id: number): Promise<TrackDBEntry> {
77-
let result: TrackDBEntry[];
78-
79-
result = this.querySource('SELECT * FROM Track WHERE id = (?) LIMIT 1', id);
75+
const result: TrackDBEntry[] = this.querySource('SELECT * FROM Track WHERE id = (?) LIMIT 1', id);
8076
if (!result) throw new Error(`Could not find track id: ${id} in database.`);
8177
result[0].trackData = await this.zInflate(result[0].trackData);
8278
result[0].overviewWaveFormData = await this.zInflate(result[0].overviewWaveFormData);
8379
result[0].beatData = await this.zInflate(result[0].beatData);
84-
8580
return result[0];
8681
}
8782

Sources/Sources.ts

+43-3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ export declare interface Sources {
2222
export class Sources extends EventEmitter {
2323
#sources: Map<string, Source> = new Map();
2424

25+
/**
26+
* Sources EndPoint Class
27+
*/
28+
29+
2530
/**
2631
* Check if sources has Source
2732
* @param {string} sourceName - Name of source in EngineOS, eg: 'DJ STICK (USB 1)'
@@ -141,19 +146,43 @@ export class Source {
141146
deviceId: DeviceId;
142147
#databases: Map<string, Database> = new Map();
143148

149+
/**
150+
* Source Type Class
151+
* @constructor
152+
* @param {string} name
153+
* @param {DeviceId} deviceId
154+
*/
155+
156+
144157
constructor(name: string, deviceId: DeviceId) {
145158
this.name = name;
146159
this.deviceId = deviceId;
147160
}
148-
149-
getDatabase(name?: string) {
161+
/**
162+
* Get a Database by File Name
163+
* @param {string }name Filename eg "m.db"
164+
* @returns {Database}
165+
*/
166+
getDatabase(name?: string): Database {
150167
return this.#databases.get(name || "m.db")
151168
}
152169

170+
/**
171+
* Get an array of all Databases
172+
* @returns {Database[]}
173+
*/
174+
153175
getDatabases(): Database[] {
154176
return [...this.#databases.values()]
155177
}
156178

179+
/**
180+
* New Database Constructor
181+
* @param {string} filename
182+
* @param {number} size
183+
* @param {string} remotePath
184+
* @returns
185+
*/
157186
newDatabase(filename: string, size: number, remotePath: string): Database {
158187
const db = new Database(filename, size, remotePath, this)
159188
this.#databases.set(db.filename, db);
@@ -176,6 +205,7 @@ class Database {
176205
downloaded: boolean = false;
177206

178207
/**
208+
* Database Type Class
179209
* @constructor
180210
* @param {string} filename name of the file EG: 'm.db'
181211
* @param {number} size size of the file
@@ -193,15 +223,25 @@ class Database {
193223
this.localPath = getTempFilePath(`${source.deviceId.string}/${source.name}/`);
194224
}
195225

226+
/**
227+
* Get full remote path & filename
228+
*/
196229
get remoteDBPath() {
197230
return `${this.remotePath}/${this.filename}`
198231
}
199232

233+
/**
234+
* Get full local path & filename
235+
*/
200236
get localDBPath() {
201237
return `${this.localPath}/${this.filename}`
202238
}
203239

204-
connection() {
240+
/**
241+
* Create new Connection to the DB for Querying
242+
* @returns {DbConnection}
243+
*/
244+
connection(): DbConnection {
205245
return new DbConnection(this.localDBPath)
206246
}
207247

StageLinq/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class StageLinq {
2828
/**
2929
* Service Constructor Factory Function
3030
* @param {Service<T>} Service
31-
* @param {DeviceId} deviceId
31+
* @param {DeviceId} [deviceId]
3232
* @returns {Promise<Service<T>>}
3333
*/
3434
static async startServiceListener<T extends InstanceType<typeof Service>>(ctor: {

devices/Devices.ts

+27-3
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ export class Devices extends EventEmitter {
7676
await this.#devices.set(deviceId.string, device);
7777
}
7878

79-
79+
/**
80+
* Get an array of all current Service Instances
81+
* @returns {Promise<InstanceType<typeof Service>[]>}
82+
*/
8083
async getDeviceServices(): Promise<InstanceType<typeof Service>[]> {
8184
return [...this.#devices.values()].flatMap(device => device.getServices())
8285
}
@@ -117,23 +120,44 @@ export class Device {
117120
this.info = info;
118121
}
119122

123+
/**
124+
* Get # of decks on this device
125+
* @returns {number}
126+
*/
120127
deckCount(): number {
121128
return this.info.unit.decks
122129
}
123130

124-
125-
service(serviceName: string) {
131+
/**
132+
* Get a service instance by name
133+
* @param {string} serviceName
134+
* @returns {InstanceType<typeof Service>}
135+
*/
136+
service(serviceName: string): InstanceType<typeof Service> {
126137
return this.#services.get(serviceName)
127138
}
128139

140+
/**
141+
* Check if Device has Service
142+
* @param {string} serviceName
143+
* @returns {boolean}
144+
*/
129145
hasService(serviceName: string): boolean {
130146
return this.#services.has(serviceName)
131147
}
132148

149+
/**
150+
* Get an Array of names of all current Services on this Device
151+
* @returns {string[]}
152+
*/
133153
getServiceNames(): string[] {
134154
return [...this.#services.keys()]
135155
}
136156

157+
/**
158+
* Get an Array of all current Services on this Device
159+
* @returns {InstanceType<typeof Service>[]}
160+
*/
137161
getServices(): InstanceType<typeof Service>[] {
138162
return [...this.#services.values()]
139163
}

docs/assets/highlight.css

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
--dark-hl-3: #4EC9B0;
1010
--light-hl-4: #001080;
1111
--dark-hl-4: #9CDCFE;
12-
--light-hl-5: #795E26;
13-
--dark-hl-5: #DCDCAA;
14-
--light-hl-6: #AF00DB;
15-
--dark-hl-6: #C586C0;
12+
--light-hl-5: #AF00DB;
13+
--dark-hl-5: #C586C0;
14+
--light-hl-6: #795E26;
15+
--dark-hl-6: #DCDCAA;
1616
--light-hl-7: #A31515;
1717
--dark-hl-7: #CE9178;
1818
--light-hl-8: #000000FF;

docs/assets/search.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)